/**
  * The UI to view point-store logs.
  *
  * @return tempcode		The UI
  */
 function pointstore_log_interface()
 {
     $title = get_page_title('POINTSTORE_MANAGE_SALES');
     $also_url = build_url(array('page' => '_SELF', 'type' => 'p'), '_SELF');
     attach_message(do_lang_tempcode('ALSO_SEE_SETUP', escape_html($also_url->evaluate())), 'inform');
     $max = get_param_integer('max', 50);
     $start = get_param_integer('start', 0);
     $rows = $GLOBALS['SITE_DB']->query_select('sales', array('*'), NULL, 'ORDER BY date_and_time DESC', $max, $start);
     $max_rows = $GLOBALS['SITE_DB']->query_value('sales', 'COUNT(*)');
     $out = new ocp_tempcode();
     require_code('templates_results_table');
     require_code('templates_table_table');
     $do_other_details = false;
     foreach ($rows as $row) {
         if ($row['details2'] != '') {
             $do_other_details = true;
         }
     }
     foreach ($rows as $row) {
         $member = $GLOBALS['FORUM_DRIVER']->get_username($row['memberid']);
         if (is_null($member)) {
             $member = do_lang('UNKNOWN');
         }
         switch ($row['purchasetype']) {
             case 'banner':
                 require_lang('banners');
                 $type = do_lang('ADD_BANNER');
                 break;
             case 'pop3':
                 $type = do_lang('POP3');
                 break;
             case 'forwarding':
                 $type = do_lang('FORWARDING');
                 break;
             default:
                 $type = do_lang($row['purchasetype'], NULL, NULL, NULL, NULL, false);
                 if (is_null($type)) {
                     $type = $row['purchasetype'];
                 }
                 break;
         }
         $details_1 = $row['details'];
         $details_2 = $row['details2'];
         $date = get_timezoned_date($row['date_and_time']);
         $url = build_url(array('page' => '_SELF', 'type' => '_logs', 'date_and_time' => $row['date_and_time'], 'memberid' => $row['memberid']), '_SELF');
         $actions = do_template('TABLE_TABLE_ACTION_DELETE_ENTRY', array('_GUID' => '12e3ea365f1a1ed2e7800293f3203283', 'NAME' => $member, 'URL' => $url));
         if ($do_other_details) {
             $out->attach(table_table_row(array($member, $type, $details_1, $details_2, $date, $actions)));
         } else {
             $out->attach(table_table_row(array($member, $type, $details_1, $date, $actions)));
         }
     }
     if ($out->is_empty()) {
         return inform_screen($title, do_lang_tempcode('NO_ENTRIES'));
     }
     if ($do_other_details) {
         $header_row = table_table_header_row(array(do_lang_tempcode('USERNAME'), do_lang_tempcode('PURCHASE'), do_lang_tempcode('DETAILS'), do_lang_tempcode('OTHER_DETAILS'), do_lang_tempcode('DATE_TIME'), do_lang_tempcode('ACTIONS')));
     } else {
         $header_row = table_table_header_row(array(do_lang_tempcode('USERNAME'), do_lang_tempcode('PURCHASE'), do_lang_tempcode('DETAILS'), do_lang_tempcode('DATE_TIME'), do_lang_tempcode('ACTIONS')));
     }
     $content = do_template('TABLE_TABLE', array('_GUID' => 'd87800ff26e9e5b8f7593fae971faa73', 'HEADER_ROW' => $header_row, 'ROWS' => $out));
     require_code('templates_pagination');
     $pagination = pagination(do_lang('POINTSTORE_MANAGE_SALES'), NULL, $start, 'start', $max, 'max', $max_rows, NULL, 'misc');
     return do_template('POINTSTORE_LOG_SCREEN', array('_GUID' => '014cf9436ece951edb55f2f7b0efb597', 'TITLE' => $title, 'CONTENT' => $content, 'PAGINATION' => $pagination));
 }
Beispiel #2
0
 /**
  * The main user interface for the file dump.
  *
  * @return tempcode	The UI.
  */
 function module_do_gui()
 {
     $title = get_page_title('FILE_DUMP');
     $place = filter_naughty(get_param('place', '/'));
     if (substr($place, -1, 1) != '/') {
         $place .= '/';
     }
     $GLOBALS['FEED_URL'] = find_script('backend') . '?mode=filedump&filter=' . $place;
     // Show tree
     $dirs = explode('/', substr($place, 0, strlen($place) - 1));
     $i = 0;
     $pre = '';
     $file_tree = new ocp_tempcode();
     while (array_key_exists($i, $dirs)) {
         if ($i > 0) {
             $d = $dirs[$i];
         } else {
             $d = do_lang('FILE_DUMP');
         }
         if (array_key_exists($i + 1, $dirs)) {
             $tree_url = build_url(array('page' => '_SELF', 'place' => $pre . $dirs[$i] . '/'), '_SELF');
             if (!$file_tree->is_empty()) {
                 $file_tree->attach(do_template('BREADCRUMB', array('_GUID' => '7ee62e230d53344a7d9667dc59be21c6')));
             }
             $file_tree->attach(hyperlink($tree_url, $d));
         }
         $pre .= $dirs[$i] . '/';
         $i++;
     }
     if (!$file_tree->is_empty()) {
         breadcrumb_add_segment($file_tree, $d);
     } else {
         breadcrumb_set_self($i == 1 ? do_lang_tempcode('FILE_DUMP') : make_string_tempcode(escape_html($d)));
     }
     // Check directory exists
     $fullpath = get_custom_file_base() . '/uploads/filedump' . $place;
     if (!file_exists(get_custom_file_base() . '/uploads/filedump' . $place)) {
         if (has_specific_permission(get_member(), 'upload_filedump')) {
             @mkdir($fullpath, 0777) or warn_exit(do_lang_tempcode('WRITE_ERROR_DIRECTORY', escape_html($fullpath), escape_html(dirname($fullpath))));
             fix_permissions($fullpath, 0777);
             sync_file($fullpath);
         }
     }
     // Find all files in the incoming directory
     $handle = opendir(get_custom_file_base() . '/uploads/filedump' . $place);
     $i = 0;
     $filename = array();
     $description = array();
     $filesize = array();
     $filetime = array();
     $directory = array();
     $deletable = array();
     while (false !== ($file = readdir($handle))) {
         if (!should_ignore_file('uploads/filedump' . $place . $file, IGNORE_ACCESS_CONTROLLERS | IGNORE_HIDDEN_FILES)) {
             $directory[$i] = !is_file(get_custom_file_base() . '/uploads/filedump' . $place . $file);
             $filename[$i] = $directory[$i] ? $file . '/' : $file;
             if ($directory[$i]) {
                 $filesize[$i] = do_lang_tempcode('NA_EM');
             }
             $dbrows = $GLOBALS['SITE_DB']->query_select('filedump', array('description', 'the_member'), array('name' => $file, 'path' => $place));
             if (!array_key_exists(0, $dbrows)) {
                 $description[$i] = $directory[$i] ? do_lang_tempcode('NA_EM') : do_lang_tempcode('NONE_EM');
             } else {
                 $description[$i] = make_string_tempcode(escape_html(get_translated_text($dbrows[0]['description'])));
             }
             if ($description[$i]->is_empty()) {
                 $description[$i] = do_lang_tempcode('NONE_EM');
             }
             $deletable[$i] = array_key_exists(0, $dbrows) && $dbrows[0]['the_member'] == get_member() || has_specific_permission(get_member(), 'delete_anything_filedump');
             if ($directory[$i]) {
                 $size = get_directory_size(get_custom_file_base() . '/uploads/filedump' . $place . $file);
                 $timestamp = NULL;
             } else {
                 $size = filesize(get_custom_file_base() . '/uploads/filedump' . $place . $file);
                 $timestamp = filemtime(get_custom_file_base() . '/uploads/filedump' . $place . $file);
             }
             $filesize[$i] = clean_file_size($size);
             $filetime[$i] = is_null($timestamp) ? NULL : get_timezoned_date($timestamp);
             $i++;
         }
     }
     closedir($handle);
     if ($i != 0) {
         require_code('templates_table_table');
         $header_row = table_table_header_row(array(do_lang_tempcode('FILENAME'), do_lang_tempcode('DESCRIPTION'), do_lang_tempcode('SIZE'), do_lang_tempcode('DATE_TIME'), do_lang_tempcode('ACTIONS')));
         $rows = new ocp_tempcode();
         for ($a = 0; $a < $i; $a++) {
             if ($directory[$a]) {
                 $link = build_url(array('page' => '_SELF', 'place' => $place . $filename[$a]), '_SELF');
             } else {
                 $link = make_string_tempcode(get_custom_base_url() . '/uploads/filedump' . str_replace('%2F', '/', rawurlencode($place . $filename[$a])));
             }
             if (!$directory[$a]) {
                 if ($deletable[$a]) {
                     $delete_url = build_url(array('page' => '_SELF', 'type' => 'ed', 'file' => $filename[$a], 'place' => $place), '_SELF');
                     $actions = do_template('TABLE_TABLE_ACTION_DELETE_ENTRY', array('_GUID' => '9b91e485d80417b1664145f9bca5a2f5', 'NAME' => $filename[$a], 'URL' => $delete_url));
                 } else {
                     $actions = new ocp_tempcode();
                 }
             } else {
                 $delete_url = build_url(array('page' => '_SELF', 'type' => 'ec', 'file' => $filename[$a], 'place' => $place), '_SELF');
                 $actions = do_template('TABLE_TABLE_ACTION_DELETE_CATEGORY', array('_GUID' => '0fa7d4090c6195328191399a14799169', 'NAME' => $filename[$a], 'URL' => $delete_url));
             }
             $rows->attach(table_table_row(array(hyperlink($link, escape_html($filename[$a]), !$directory[$a]), escape_html($description[$a]), escape_html($filesize[$a]), is_null($filetime[$a]) ? do_lang_tempcode('NA') : make_string_tempcode(escape_html($filetime[$a])), $actions)));
         }
         $files = do_template('TABLE_TABLE', array('_GUID' => '1c0a91d47c5fc8a7c2b35c7d9b36132f', 'HEADER_ROW' => $header_row, 'ROWS' => $rows));
     } else {
         $files = new ocp_tempcode();
     }
     // Do a form so people can upload their own stuff
     if (has_specific_permission(get_member(), 'upload_filedump')) {
         $post_url = build_url(array('page' => '_SELF', 'type' => 'ad', 'uploading' => 1), '_SELF');
         $submit_name = do_lang_tempcode('FILEDUMP_UPLOAD');
         $max = floatval(get_max_file_size());
         $text = new ocp_tempcode();
         if ($max < 30.0) {
             $config_url = get_upload_limit_config_url();
             $text->attach(do_lang_tempcode(is_null($config_url) ? 'MAXIMUM_UPLOAD' : 'MAXIMUM_UPLOAD_STAFF', escape_html($max > 10.0 ? integer_format(intval($max)) : float_format($max / 1024.0 / 1024.0)), escape_html(is_null($config_url) ? '' : $config_url)));
         }
         require_code('form_templates');
         $fields = form_input_upload(do_lang_tempcode('UPLOAD'), do_lang_tempcode('_DESCRIPTION_UPLOAD'), 'file', true);
         $fields->attach(form_input_line(do_lang_tempcode('DESCRIPTION'), do_lang_tempcode('DESCRIPTION_DESCRIPTION'), 'description', '', false));
         $hidden = new ocp_tempcode();
         $hidden->attach(form_input_hidden('place', $place));
         handle_max_file_size($hidden);
         $upload_form = do_template('FORM', array('TABINDEX' => strval(get_form_field_tabindex()), 'SKIP_REQUIRED' => true, 'HIDDEN' => $hidden, 'TEXT' => $text, 'FIELDS' => $fields, 'SUBMIT_NAME' => $submit_name, 'URL' => $post_url));
     } else {
         $upload_form = new ocp_tempcode();
     }
     // Do a form so people can make folders
     if (get_option('is_on_folder_create') == '1') {
         $post_url = build_url(array('page' => '_SELF', 'type' => 'ac'), '_SELF');
         require_code('form_templates');
         $fields = form_input_line(do_lang_tempcode('NAME'), do_lang_tempcode('DESCRIPTION_NAME'), 'name', '', true);
         $hidden = form_input_hidden('place', $place);
         $submit_name = do_lang_tempcode('FILEDUMP_CREATE_FOLDER');
         $create_folder_form = do_template('FORM', array('_GUID' => '043f9b595d3699b7d8cd7f2284cdaf98', 'TABINDEX' => strval(get_form_field_tabindex()), 'SKIP_REQUIRED' => true, 'SECONDARY_FORM' => true, 'HIDDEN' => $hidden, 'TEXT' => '', 'FIELDS' => $fields, 'SUBMIT_NAME' => $submit_name, 'URL' => $post_url));
     } else {
         $create_folder_form = new ocp_tempcode();
     }
     return do_template('FILE_DUMP_SCREEN', array('_GUID' => '3f49a8277a11f543eff6488622949c84', 'TITLE' => $title, 'PLACE' => $place, 'FILES' => $files, 'UPLOAD_FORM' => $upload_form, 'CREATE_FOLDER_FORM' => $create_folder_form));
 }
Beispiel #3
0
 /**
  * Helper function to find information about past backups.
  *
  * @return tempcode		The UI
  */
 function get_results()
 {
     // Find all files in the incoming directory
     $path = get_custom_file_base() . '/exports/backups/';
     if (!file_exists($path)) {
         mkdir($path, 0777, true);
         fix_permissions($path, 0777);
         sync_file($path);
     }
     $handle = opendir($path);
     $entries = array();
     while (false !== ($file = readdir($handle))) {
         if (!is_dir($path . $file) && (get_file_extension($file) == 'tar' || get_file_extension($file) == 'txt' || get_file_extension($file) == 'gz' || get_file_extension($file) == '') && is_file($path . $file)) {
             $entries[] = array('file' => $file, 'size' => filesize($path . $file), 'mtime' => filemtime($path . $file));
         }
     }
     closedir($handle);
     global $M_SORT_KEY;
     $M_SORT_KEY = 'mtime';
     uasort($entries, 'multi_sort');
     if (count($entries) != 0) {
         require_code('templates_table_table');
         $header_row = table_table_header_row(array(do_lang_tempcode('FILENAME'), do_lang_tempcode('TYPE'), do_lang_tempcode('SIZE'), do_lang_tempcode('DATE_TIME'), new ocp_tempcode()));
         $rows = new ocp_tempcode();
         foreach ($entries as $entry) {
             $delete_url = build_url(array('page' => '_SELF', 'type' => 'confirm_delete', 'file' => $entry['file']), '_SELF');
             $link = get_custom_base_url() . '/exports/backups/' . $entry['file'];
             $actions = do_template('TABLE_TABLE_ACTION_DELETE_ENTRY', array('_GUID' => '23a8b5d5d345d8fdecc74b01fe5a9042', 'NAME' => $entry['file'], 'URL' => $delete_url));
             $type = do_lang_tempcode('UNKNOWN');
             switch (get_file_extension($entry['file'])) {
                 case 'gz':
                     $type = do_lang_tempcode('BACKUP_FILE_COMPRESSED');
                     break;
                 case 'tar':
                     $type = do_lang_tempcode('BACKUP_FILE_UNCOMPRESSED');
                     break;
                 case 'txt':
                     $type = do_lang_tempcode('BACKUP_FILE_LOG');
                     break;
                 case '':
                     $type = do_lang_tempcode('BACKUP_FILE_UNFINISHED');
                     break;
             }
             $rows->attach(table_table_row(array(hyperlink($link, escape_html($entry['file'])), $type, clean_file_size($entry['size']), get_timezoned_date($entry['mtime']), $actions)));
         }
         $files = do_template('TABLE_TABLE', array('_GUID' => '726070efa71843236e975d87d4a17dae', 'HEADER_ROW' => $header_row, 'ROWS' => $rows));
     } else {
         $files = new ocp_tempcode();
     }
     return $files;
 }