芝麻web文件管理V1.00
编辑当前文件:/home/pulsehostuk9/www/status.pulsehost.co.uk/app/controllers/admin/AdminPlanCreate.php
license->type, ['Extended License', 'extended'])) { /* Get the available taxes from the system */ $taxes = db()->get('taxes'); } $monitor_check_intervals = require APP_PATH . 'includes/monitor_check_intervals.php'; $dns_monitor_check_intervals = require APP_PATH . 'includes/dns_monitor_check_intervals.php'; $server_monitor_check_intervals = require APP_PATH . 'includes/server_monitor_check_intervals.php'; $additional_domains = db()->where('is_enabled', 1)->where('type', 1)->get('domains'); if(!empty($_POST)) { /* Filter some the variables */ $_POST['name'] = input_clean($_POST['name'], 64); $_POST['description'] = input_clean($_POST['description'], 256); /* Prices */ $prices = [ 'monthly' => [], 'annual' => [], 'lifetime' => [], ]; foreach((array) settings()->payment->currencies as $currency => $currency_data) { $prices['monthly'][$currency] = (float) $_POST['monthly_price'][$currency]; $prices['annual'][$currency] = (float) $_POST['annual_price'][$currency]; $prices['lifetime'][$currency] = (float) $_POST['lifetime_price'][$currency]; } $prices = json_encode($prices); $_POST['settings'] = [ 'url_minimum_characters' => (int) $_POST['url_minimum_characters'], 'url_maximum_characters' => (int) $_POST['url_maximum_characters'], 'monitors_limit' => (int) $_POST['monitors_limit'], 'monitors_check_intervals' => $_POST['monitors_check_intervals'] ?? [], 'monitors_ping_servers' => $_POST['monitors_ping_servers'] ?? [], 'heartbeats_limit' => (int) $_POST['heartbeats_limit'], 'domain_names_limit' => (int) $_POST['domain_names_limit'], 'dns_monitors_limit' => (int) $_POST['dns_monitors_limit'], 'dns_monitors_check_intervals' => $_POST['dns_monitors_check_intervals'] ?? [], 'server_monitors_limit' => (int) $_POST['server_monitors_limit'], 'server_monitors_check_intervals' => $_POST['server_monitors_check_intervals'] ?? [], 'status_pages_limit' => (int) $_POST['status_pages_limit'], 'projects_limit' => (int) $_POST['projects_limit'], 'domains_limit' => (int) $_POST['domains_limit'], 'teams_limit' => (int) $_POST['teams_limit'], 'team_members_limit' => (int) $_POST['team_members_limit'], 'active_notification_handlers_per_resource_limit' => (int) $_POST['active_notification_handlers_per_resource_limit'], 'logs_retention' => (int) $_POST['logs_retention'], 'statistics_retention' => (int) $_POST['statistics_retention'], 'additional_domains' => $_POST['additional_domains'] ?? [], 'analytics_is_enabled' => isset($_POST['analytics_is_enabled']), 'qr_is_enabled' => isset($_POST['qr_is_enabled']), 'removable_branding_is_enabled' => isset($_POST['removable_branding_is_enabled']), 'custom_url_is_enabled' => isset($_POST['custom_url_is_enabled']), 'password_protection_is_enabled' => isset($_POST['password_protection_is_enabled']), 'search_engine_block_is_enabled' => isset($_POST['search_engine_block_is_enabled']), 'custom_css_is_enabled' => isset($_POST['custom_css_is_enabled']), 'custom_js_is_enabled' => isset($_POST['custom_js_is_enabled']), 'email_reports_is_enabled' => isset($_POST['email_reports_is_enabled']), 'api_is_enabled' => isset($_POST['api_is_enabled']), 'affiliate_commission_percentage' => (int) $_POST['affiliate_commission_percentage'], 'no_ads' => isset($_POST['no_ads']) ]; foreach(array_keys(require APP_PATH . 'includes/notification_handlers.php') as $notification_handler) { $_POST['settings']['notification_handlers_' . $notification_handler . '_limit'] = (int) $_POST['notification_handlers_' . $notification_handler . '_limit']; } $_POST['settings'] = json_encode($_POST['settings']); $_POST['color'] = !preg_match('/#([A-Fa-f0-9]{3,4}){1,2}\b/i', $_POST['color']) ? null : $_POST['color']; $_POST['status'] = (int) $_POST['status']; $_POST['order'] = (int) $_POST['order']; $_POST['trial_days'] = (int) $_POST['trial_days']; $_POST['taxes_ids'] = json_encode($_POST['taxes_ids'] ?? []); /* Translations */ foreach($_POST['translations'] as $language_name => $array) { foreach($array as $key => $value) { $_POST['translations'][$language_name][$key] = input_clean($value); } if(!array_key_exists($language_name, \Altum\Language::$active_languages)) { unset($_POST['translations'][$language_name]); } } $_POST['translations'] = json_encode($_POST['translations']); //ALTUMCODE:DEMO if(DEMO) Alerts::add_error('This command is blocked on the demo.'); /* Check for any errors */ $required_fields = ['name']; foreach($required_fields as $field) { if(!isset($_POST[$field]) || (isset($_POST[$field]) && empty($_POST[$field]) && $_POST[$field] != '0')) { Alerts::add_field_error($field, l('global.error_message.empty_field')); } } if(!\Altum\Csrf::check()) { Alerts::add_error(l('global.error_message.invalid_csrf_token')); } if(!Alerts::has_field_errors() && !Alerts::has_errors()) { /* Database query */ db()->insert('plans', [ 'name' => $_POST['name'], 'description' => $_POST['description'], 'prices' => $prices, 'settings' => $_POST['settings'], 'translations' => $_POST['translations'], 'taxes_ids' => $_POST['taxes_ids'], 'color' => $_POST['color'], 'status' => $_POST['status'], 'order' => $_POST['order'], 'datetime' => get_date(), ]); /* Clear the cache */ cache()->deleteItem('plans'); /* Set a nice success message */ Alerts::add_success(sprintf(l('global.success_message.create1'), '
' . $_POST['name'] . '
')); redirect('admin/plans'); } } /* Main View */ $data = [ 'taxes' => $taxes ?? null, 'additional_domains' => $additional_domains, 'monitor_check_intervals' => $monitor_check_intervals, 'dns_monitor_check_intervals' => $dns_monitor_check_intervals, 'server_monitor_check_intervals' => $server_monitor_check_intervals, ]; $view = new \Altum\View('admin/plan-create/index', (array) $this); $this->add_view_content('content', $view->run($data)); } }