// //Cobalt on the web: http://cobalt.jvroig.com //****************************************************************** require 'path.php'; init_cobalt('Edit system settings'); if (isset($_GET['setting'])) { $setting = urldecode($_GET['setting']); require 'form_data_system_settings.php'; $orig_setting = $setting; } if (xsrf_guard()) { init_var($_POST['btn_cancel']); init_var($_POST['btn_submit']); require 'components/query_string_standard.php'; require 'subclasses/system_settings.php'; $dbh_system_settings = new system_settings(); $object_name = 'dbh_system_settings'; require 'components/create_form_data.php'; $arr_form_data['orig_setting'] = $_POST['orig_setting']; extract($arr_form_data); if ($_POST['btn_cancel']) { log_action('Pressed cancel button'); redirect("listview_system_settings.php?{$query_string}"); } if ($_POST['btn_submit']) { log_action('Pressed submit button'); $message .= $dbh_system_settings->sanitize($arr_form_data)->lst_error; extract($arr_form_data); if ($dbh_system_settings->check_uniqueness_for_editing($arr_form_data)->is_unique) { //Good, no duplicate in database } else {
} else { $message .= 'File not uploaded: invalid file type. Please consult your system admnistrator for allowed file types.<br>'; } if ($upload_destination_file != '') { //Check if file conforms to desired max size and width $image_size = ''; $width = 0; $heigh = 0; $image_size = getimagesize($upload_destination_file); if ($image_size) { $width = $image_size[0]; $height = $image_size[1]; //Get allowable height and width if ($max_attachment_height == 0 || $max_attachment_width == 0) { require_once 'subclasses/system_settings.php'; $obj_settings = new system_settings(); if ($max_attachment_height == 0) { $max_attachment_height = $obj_settings->get('Max Attachment Height', FALSE)->dump['value']; } if ($max_attachment_width == 0) { $max_attachment_width = $obj_settings->get('Max Attachment Width', FALSE)->dump['value']; } } //Check if uploaded image conforms to limits, if there are any if ($max_attachment_height > 0 || $max_attachment_width > 0) { //If one dimension is 0 (or less; just to handle negative cases c/o incorrect config by admin), treat it as "no limit". if ($max_attachment_height <= 0) { if ($width > $max_attachment_width) { ${$file_upload_control_name} = ''; $message .= "File (" . $orig_filename . ") was not uploaded; image is too wide. Max width should only be {$max_attachment_width} px<br>"; }
//****************************************************************** require 'path.php'; init_cobalt('Delete system settings'); if (isset($_GET['setting'])) { $setting = urldecode($_GET['setting']); require 'form_data_system_settings.php'; } elseif (xsrf_guard()) { init_var($_POST['btn_cancel']); init_var($_POST['btn_delete']); require 'components/query_string_standard.php'; if ($_POST['btn_cancel']) { log_action('Pressed cancel button', $_SERVER['PHP_SELF']); redirect("listview_system_settings.php?{$query_string}"); } elseif ($_POST['btn_delete']) { log_action('Pressed delete button', $_SERVER['PHP_SELF']); require 'subclasses/system_settings.php'; $dbh_system_settings = new system_settings(); $object_name = 'dbh_system_settings'; require 'components/create_form_data.php'; $dbh_system_settings->del($arr_form_data); redirect("listview_system_settings.php?{$query_string}"); } } require 'subclasses/system_settings_html.php'; $html = new system_settings_html(); $html->draw_header('Delete System Settings', $message, $message_type); $html->draw_listview_referrer_info($filter_field_used, $filter_used, $page_from, $filter_sort_asc, $filter_sort_desc); $html->draw_hidden('setting'); $html->detail_view = TRUE; $html->draw_controls('delete'); $html->draw_footer();
<?php require_once 'subclasses/system_settings.php'; $obj_settings = new system_settings(); $max_attachment_size_MB = $obj_settings->get('Max Attachment Size (MB)', FALSE)->dump['value']; if ($max_attachment_size_MB < 1) { //This means the setting is set to auto-detect ini values, misconfigured, or has been removed. //Whatever the case, get sensible max size by getting post_max_size and upload_max_filesize, and using the lower value if (!function_exists('return_bytes')) { function return_bytes($val) { //This is taken from phpmanual, as their recommended way of querying for memory size values $val = trim($val); $last = strtoupper($val[strlen($val) - 1]); switch ($last) { case 'G': $val *= 1024; case 'M': $val *= 1024; case 'K': $val *= 1024; } return $val; } } $ini_post_max_size = return_bytes(ini_get('post_max_size')); $ini_upload_max_filesize = return_bytes(ini_get('upload_max_filesize')); if ($ini_post_max_size < $ini_upload_max_filesize) { $max_attachment_size = $ini_post_max_size; } else { $max_attachment_size = $ini_upload_max_filesize;
// //Cobalt on the web: http://cobalt.jvroig.com //****************************************************************** require 'path.php'; init_cobalt('View system settings'); if (xsrf_guard()) { init_var($_POST['btn_cancel']); init_var($_POST['btn_submit']); if ($_POST['btn_cancel']) { log_action('Pressed cancel button', $_SERVER['PHP_SELF']); redirect("listview_system_settings.php"); } if ($_POST['btn_submit']) { log_action('Pressed submit button', $_SERVER['PHP_SELF']); require 'subclasses/system_settings.php'; $dbh_system_settings = new system_settings(); if ($message == "") { log_action("Exported table data to CSV", $_SERVER['PHP_SELF']); $timestamp = date('Y-m-d'); $token = generate_token(0, 'fs'); $csv_name = $token . $_SESSION['user'] . '_system_settings_' . $timestamp . '.csv'; $filename = TMP_DIRECTORY . '/' . $csv_name; $csv_contents = $dbh_system_settings->export_to_csv(); $csv_file = fopen($filename, "wb"); fwrite($csv_file, $csv_contents); fclose($csv_file); chmod($filename, 0755); $csv_name = urlencode($csv_name); $message = 'CSV file successfully generated: <a href="/' . BASE_DIRECTORY . '/download_generic.php?filename=' . $csv_name . '">Download the CSV file.</a>'; $message_type = 'system'; }
<?php require 'components/get_listview_referrer.php'; require 'subclasses/system_settings.php'; $dbh_system_settings = new system_settings(); $dbh_system_settings->set_where("setting='" . quote_smart($setting) . "'"); if ($result = $dbh_system_settings->make_query()->result) { $data = $result->fetch_assoc(); extract($data); }