/** * The UI to show download statistics. * * @param object The stats module object * @param string The screen type * @return tempcode The UI */ function downloads($ob, $type) { breadcrumb_set_parents(array(array('_SELF:_SELF:misc', do_lang_tempcode('SITE_STATISTICS')))); require_lang('downloads'); //This will show a plain bar chart with all the downloads listed $title = get_page_title('SECTION_DOWNLOADS'); // Handle time range if (get_param_integer('dated', 0) == 0) { $title = get_page_title('SECTION_DOWNLOADS'); return $ob->get_between($title, false, NULL, do_lang_tempcode('DOWNLOAD_STATS_RANGE')); } $time_start = get_input_date('time_start', true); $time_end = get_input_date('time_end', true); if (!is_null($time_end)) { $time_end += 60 * 60 * 24 - 1; } // So it is end of day not start if (is_null($time_start) && is_null($time_end)) { $rows = $GLOBALS['SITE_DB']->query_select('download_downloads', array('id', 'num_downloads', 'name')); } else { if (is_null($time_start)) { $time_start = 0; } if (is_null($time_end)) { $time_end = time(); } $title = get_page_title('SECTION_DOWNLOADS_RANGE', true, array(escape_html(get_timezoned_date($time_start, false)), escape_html(get_timezoned_date($time_end, false)))); $rows = $GLOBALS['SITE_DB']->query('SELECT id,num_downloads,name FROM ' . $GLOBALS['SITE_DB']->get_table_prefix() . 'download_downloads WHERE add_date>' . strval($time_start) . ' AND add_date<' . strval($time_end)); } //$rows=array(array('id'=>1,'num_downloads'=>10,'name'=>3),array('id'=>2,'num_downloads'=>20,'name'=>4)); if (count($rows) < 1) { return warn_screen($title, do_lang_tempcode('NO_DATA')); } $downloads = array(); foreach ($rows as $i => $row) { if (!array_key_exists('num_downloads', $row)) { $row['num_downloads'] = $GLOBALS['SITE_DB']->query_value_null_ok_full('SELECT COUNT(*) FROM ' . $GLOBALS['SITE_DB']->get_table_prefix() . 'download_logging WHERE id=' . strval($row['id'])); $rows[$i] = $row; } $downloads[get_translated_text($row['name']) . ' (#' . strval($row['id']) . ')'] = $row['num_downloads']; } $start = get_param_integer('start', 0); $max = get_param_integer('max', 30); $csv = get_param_integer('csv', 0) == 1; if ($csv) { if (function_exists('set_time_limit')) { @set_time_limit(0); } $start = 0; $max = 10000; } $sortables = array('num_downloads' => do_lang_tempcode('COUNT_DOWNLOADS')); $test = explode(' ', get_param('sort', 'num_downloads DESC'), 2); if (count($test) == 1) { $test[1] = 'DESC'; } list($sortable, $sort_order) = $test; if (strtoupper($sort_order) != 'ASC' && strtoupper($sort_order) != 'DESC' || !array_key_exists($sortable, $sortables)) { log_hack_attack_and_exit('ORDERBY_HACK'); } global $NON_CANONICAL_PARAMS; $NON_CANONICAL_PARAMS[] = 'sort'; if ($sort_order == 'ASC') { asort($downloads); } else { arsort($downloads); } require_code('templates_results_table'); $fields_title = results_field_title(array(do_lang_tempcode('TITLE'), do_lang_tempcode('COUNT_DOWNLOADS')), $sortables, 'sort', $sortable . ' ' . $sort_order); $fields = new ocp_tempcode(); $real_data = array(); $i = 0; foreach ($downloads as $download_name => $value) { if ($i < $start) { $i++; continue; } elseif ($i >= $start + $max) { break; } $fields->attach(results_entry(array(escape_html($download_name), escape_html(integer_format($value))))); $real_data[] = array('Download name' => $download_name, 'Tally' => $value); $i++; } $list = results_table(do_lang_tempcode('SECTION_DOWNLOADS'), $start, 'start', $max, 'max', count($downloads), $fields_title, $fields, $sortables, $sortable, $sort_order, 'sort', new ocp_tempcode()); if ($csv) { make_csv($real_data, 'download_stats.csv'); } $output = create_bar_chart(array_slice($downloads, $start, $max), do_lang('TITLE'), do_lang('COUNT_DOWNLOADS'), '', ''); $ob->save_graph('Global-Downloads', $output); $graph = do_template('STATS_GRAPH', array('GRAPH' => get_custom_base_url() . '/data_custom/modules/admin_stats/Global-Downloads.xml', 'TITLE' => do_lang_tempcode('SECTION_DOWNLOADS'), 'TEXT' => do_lang_tempcode('DESCRIPTION_DOWNLOADS_STATISTICS'))); return do_template('STATS_SCREEN', array('_GUID' => '4b8e0478231473d690e947ffc4580840', 'TITLE' => $title, 'GRAPH' => $graph, 'STATS' => $list)); }
/** * The actualiser to add a reply. * * @return tempcode The UI */ function _add_reply() { if (addon_installed('captcha')) { require_code('captcha'); enforce_captcha(); } require_code('attachments2'); require_code('ocf_posts_action'); require_code('ocf_posts_action2'); $invited_members = array(); $topic_id = either_param_integer('topic_id', -1); // Posting into an existing topic? $forum_id = post_param_integer('forum_id', -1); // New topic in existing forum? (NB: -2 represents reported posts forum) $member_id = post_param_integer('member_id', -1); // Send TOPIC to specific member? Could be Private Topic (topic_id==-1, forum_id==-1), or personal post (topic_id!=-1, forum_id==-1) $parent_id = either_param_integer('parent_id', NULL); if ($member_id == -1) { $member_username = post_param('to_member_id_0', ''); if ($member_username != '') { $member_id = $GLOBALS['FORUM_DRIVER']->get_member_from_username($member_username); if (is_null($member_id)) { warn_exit(do_lang_tempcode('_USER_NO_EXIST', $member_username)); } } foreach ($_POST as $key => $_invited_member) { if (substr($key, 0, 13) != 'to_member_id_') { continue; } if ($key == 'to_member_id_0') { continue; } if ($_invited_member == '') { continue; } if (get_magic_quotes_gpc()) { $_invited_member = stripslashes($_invited_member); } $invited_member = $GLOBALS['FORUM_DRIVER']->get_member_from_username($_invited_member); if (is_null($invited_member)) { attach_message(do_lang_tempcode('_USER_NO_EXIST', $_invited_member), 'warn'); } else { $invited_members[] = intval($invited_member); } } } $validated = post_param_integer('validated', post_param_integer('_validated', 0)); $is_emphasised = post_param_integer('is_emphasised', 0); $skip_sig = post_param_integer('skip_sig', 0); $post = post_param('post'); $title = post_param('title', NULL); if (is_null($title)) { $title = ''; } $check_permissions = true; $add_poll = post_param_integer('add_poll', 0); $topic_validated = $validated; if ($validated == 1) { $topic_validated = 1 - $add_poll; } // If a topic is gonna have a poll added, it starts unvalidated. Adding the poll will validate it. $anonymous = post_param_integer('anonymous', 0); $poster_name_if_guest = post_param('poster_name_if_guest', NULL); if ($poster_name_if_guest == '') { $poster_name_if_guest = NULL; } if (!is_null($poster_name_if_guest)) { $poster_name_if_guest = trim($poster_name_if_guest); $restricted_usernames = explode(',', get_option('restricted_usernames')); $restricted_usernames[] = do_lang('UNKNOWN'); $restricted_usernames[] = do_lang('SYSTEM'); if (!is_null($GLOBALS['FORUM_DRIVER']->get_member_from_username($poster_name_if_guest))) { $restricted_usernames[] = $poster_name_if_guest; } foreach ($restricted_usernames as $_restricted_username) { $restricted_username = trim($_restricted_username); if ($restricted_username == '') { continue; } if ($poster_name_if_guest == $restricted_username) { $poster_name_if_guest = $poster_name_if_guest . ' (' . do_lang('GUEST') . ')'; break; } } } $new_topic = $topic_id == -1; if (!$new_topic) { $_intended_solely_for = post_param('intended_solely_for', ''); if ($_intended_solely_for == '') { $intended_solely_for = NULL; } else { $intended_solely_for = $GLOBALS['FORUM_DRIVER']->get_member_from_username($_intended_solely_for); if (is_null($intended_solely_for)) { warn_exit(do_lang_tempcode('_USER_NO_EXIST', $_intended_solely_for)); } } } else { $intended_solely_for = NULL; } require_code('ocf_topics_action'); require_code('ocf_topics_action2'); if ($new_topic) { ocf_check_post($post); if ($title == '') { warn_exit(do_lang_tempcode('NO_PARAMETER_SENT', 'title')); } $sunk = post_param_integer('sunk', 0); $topic_title = $title; if ($forum_id == -1) { require_code('ocf_members2'); if (!ocf_may_whisper($member_id)) { warn_exit(do_lang_tempcode('NO_PT_FROM_ALLOW')); } check_specific_permission('use_pt'); $topic_id = ocf_make_topic(NULL, post_param('description', ''), post_param('emoticon', ''), $topic_validated, post_param_integer('open', 0), post_param_integer('pinned', 0), $sunk, post_param_integer('cascading', 0), get_member(), $member_id); $_title = get_page_title('ADD_PERSONAL_TOPIC'); } elseif ($forum_id == -2) { $forum_id = $GLOBALS['FORUM_DRIVER']->forum_id_from_name(get_option('reported_posts_forum')); if (is_null($forum_id)) { warn_exit(do_lang_tempcode('NO_REPORTED_POST_FORUM')); } // See if post already reported... $topic_id = $GLOBALS['FORUM_DB']->query_value_null_ok('f_topics t LEFT JOIN ' . $GLOBALS['FORUM_DB']->get_table_prefix() . 'f_posts p ON p.id=t.t_cache_first_post_id', 't.id', array('p.p_title' => $title, 't.t_forum_id' => $forum_id)); if (!is_null($topic_id)) { // Already a topic } else { $topic_id = ocf_make_topic($forum_id, '', '', 1, 1, 0, 0, 0, NULL, NULL, false); } $_title = get_page_title('REPORT_POST'); $check_permissions = false; decache('main_staff_checklist'); } else { $topic_id = ocf_make_topic($forum_id, post_param('description', ''), post_param('emoticon', ''), $topic_validated, post_param_integer('open', 0), post_param_integer('pinned', 0), $sunk, post_param_integer('cascading', 0)); $_title = get_page_title('ADD_TOPIC'); if (addon_installed('awards')) { require_code('awards'); handle_award_setting('topic', strval($topic_id)); } } $first_post = true; require_code('fields'); if (has_tied_catalogue('topic')) { save_form_custom_fields('topic', strval($topic_id)); } } else { $_title = get_page_title('ADD_POST'); $first_post = false; $topic_info = $GLOBALS['FORUM_DB']->query_select('f_topics', array('t_cache_first_title', 't_sunk', 't_forum_id', 't_is_open', 't_description'), array('id' => $topic_id), '', 1); if (!array_key_exists(0, $topic_info)) { warn_exit(do_lang_tempcode('MISSING_RESOURCE')); } $forum_id = $topic_info[0]['t_forum_id']; $topic_title = $topic_info[0]['t_cache_first_title']; $sunk = $topic_info[0]['t_sunk']; if ($topic_info[0]['t_is_open'] == 0) { $may_moderate_forum = ocf_may_moderate_forum($forum_id); if (!$may_moderate_forum) { warn_exit(do_lang_tempcode('TOPIC_IS_CLOSED')); } } // Moderator reply $new_title = post_param('new_title', NULL); if (!is_null($new_title) && !is_null($forum_id) && ocf_may_moderate_forum($forum_id, get_member())) { $cascading = post_param_integer('cascading', 0); $pinned = post_param_integer('pinned', 0); $sunk = post_param_integer('sunk', 0); $open = post_param_integer('open', 0); $topic_validated = post_param_integer('topic_validated', 0); $to = post_param_integer('to', NULL); $schedule = get_input_date('schedule'); if (!is_null($schedule) && addon_installed('calendar')) { $_intended_solely_for = is_null($intended_solely_for) ? 'NULL' : strval($intended_solely_for); $_postdetailser_name_if_guest = is_null($poster_name_if_guest) ? 'NULL' : '\'' . addslashes($poster_name_if_guest) . '\''; $_first_post = $first_post ? 'true' : 'false'; $__title = is_null($title) ? 'NULL' : '\'' . str_replace(chr(10), '\'.chr(10).\'', addslashes($title)) . '\''; $_postdetails = is_null($post) ? 'NULL' : '\'' . str_replace(chr(10), '\'.chr(10).\'', addslashes($post)) . '\''; $_new_title = is_null($new_title) ? 'NULL' : '\'' . str_replace(chr(10), '\'.chr(10).\'', addslashes($new_title)) . '\''; $schedule_code = <<<END :require_code('ocf_topics_action2'); require_code('ocf_topics_action'); ocf_edit_topic({$topic_id},NULL,NULL,{$validated},{$open},{$pinned},{$sunk},{$cascading},'',{$_new_title}); if (({$to}!={$forum_id}) && (!is_null({$to}))) ocf_move_topics({$forum_id},{$to},array({$topic_id})); \$post_id=ocf_make_post({$topic_id},{$__title},{$_postdetails},{$skip_sig},{$_first_post},{$validated},{$is_emphasised},{$_postdetailser_name_if_guest},NULL,NULL,NULL,{$_intended_solely_for},NULL,NULL,false,true,NULL,true,{$topic_title},{$sunk},NULL,{$anonymous}==1); if (addon_installed('awards')) { require_code('awards'); handle_award_setting('post',strval(\$post_id)); } END; require_code('calendar'); $start_year = post_param_integer('schedule_year'); $start_month = post_param_integer('schedule_month'); $start_day = post_param_integer('schedule_day'); $start_hour = post_param_integer('schedule_hour'); $start_minute = post_param_integer('schedule_minute'); require_code('calendar2'); $event_id = add_calendar_event(db_get_first_id(), '', NULL, 0, do_lang('ADD_POST'), $schedule_code, 3, 0, $start_year, $start_month, $start_day, $start_hour, $start_minute); regenerate_event_reminder_jobs($event_id); $text = do_lang_tempcode('SUCCESS'); $map = array('page' => 'topicview', 'id' => $topic_id, 'type' => 'first_unread'); $test = get_param_integer('kfs' . (is_null($forum_id) ? '' : strval($forum_id)), -1); if ($test != -1 && $test != 0) { $map['kfs' . (is_null($forum_id) ? '' : strval($forum_id))] = $test; } $test = get_param_integer('threaded', -1); if ($test != -1) { $map['threaded'] = $test; } $_url = build_url($map, get_module_zone('topicview')); $url = $_url->evaluate(); $url .= '#first_unread'; $url = get_param('redirect', $url); return redirect_screen($_title, $url, $text); } ocf_edit_topic($topic_id, NULL, NULL, $topic_validated, $open, $pinned, $sunk, $cascading, '', $new_title == '' ? NULL : $new_title); if ($to != $forum_id && !is_null($to)) { ocf_move_topics($forum_id, $to, array($topic_id)); } } } $post_id = ocf_make_post($topic_id, $title, $post, $skip_sig, $first_post, $validated, $is_emphasised, $poster_name_if_guest, NULL, NULL, NULL, $intended_solely_for, NULL, NULL, $check_permissions, true, NULL, true, $topic_title, $sunk, NULL, $anonymous == 1, $forum_id == -1 || is_null($forum_id), $forum_id == -1 || is_null($forum_id), false, $parent_id); if (addon_installed('awards')) { require_code('awards'); handle_award_setting('post', strval($post_id)); } if (!is_null($forum_id) && $anonymous == 0 && $intended_solely_for === NULL) { if (has_actual_page_access($GLOBALS['FORUM_DRIVER']->get_guest_id(), 'forumview') && has_category_access($GLOBALS['FORUM_DRIVER']->get_guest_id(), 'forums', strval($forum_id))) { syndicate_described_activity($first_post ? 'ocf:ACTIVITY_ADD_TOPIC' : 'ocf:ACTIVITY_ADD_POST_IN', $first_post ? $title : $topic_title, '', '', '_SEARCH:topicview:misc:' . strval($topic_id) . '#post_' . strval($post_id), '', '', 'ocf_forum'); } } require_code('fields'); if (has_tied_catalogue('post')) { save_form_custom_fields('post', strval($post_id)); } $validated = $GLOBALS['FORUM_DB']->query_value('f_posts', 'p_validated', array('id' => $post_id)); $rep_post_id = post_param_integer('o_post_id', -1); if ($rep_post_id != -1) { $map = array('page' => 'topicview', 'id' => $rep_post_id, 'type' => 'findpost'); $_url = build_url($map, get_module_zone('topicview')); $url = $_url->evaluate(); $url .= '#post_' . strval($rep_post_id); } else { $map = array('page' => 'topicview', 'id' => $post_id, 'type' => 'findpost'); $test = get_param_integer('kfs' . (is_null($forum_id) ? '' : strval($forum_id)), -1); if ($test != -1 && $test != 0) { $map['kfs' . (is_null($forum_id) ? '' : strval($forum_id))] = $test; } $test = get_param_integer('threaded', -1); if ($test != -1) { $map['threaded'] = $test; } $_url = build_url($map, get_module_zone('topicview')); $url = $_url->evaluate(); if ($validated != 0) { $url .= '#post_' . strval($post_id); } } if ($forum_id >= 0) { $topic_validated = $GLOBALS['FORUM_DB']->query_value('f_topics', 't_validated', array('id' => $topic_id)); if ($topic_validated == 0 && !has_specific_permission(get_member(), 'jump_to_unvalidated')) { $map = array('page' => 'forumview', 'id' => $forum_id); $test = get_param_integer('kfs' . (is_null($forum_id) ? '' : strval($forum_id)), -1); if ($test != -1 && $test != 0) { $map['kfs' . (is_null($forum_id) ? '' : strval($forum_id))] = $test; } $test = get_param_integer('threaded', -1); if ($test != -1) { $map['threaded'] = $test; } $_url = build_url($map, get_module_zone('forumview')); $url = $_url->evaluate(); } } if ($new_topic && $forum_id == -1) { require_code('notifications'); enable_notifications('ocf_topic', strval($topic_id), get_member()); // from enable_notifications('ocf_topic', strval($topic_id), $member_id); // to foreach ($invited_members as $invited_member) { enable_notifications('ocf_topic', strval($topic_id), $invited_member); ocf_invite_to_pt($invited_member, $topic_id); } } if ($anonymous == 1) { log_it('MAKE_ANONYMOUS_POST', strval($post_id), $title); } if (addon_installed('awards')) { require_code('awards'); handle_award_setting('post', strval($post_id)); } if ($forum_id == -1 && $member_id != -1) { send_pt_notification($post_id, $title, $topic_id, $member_id, NULL, $post); } if ($add_poll == 1) { if (post_param_integer('add_poll', 0) == 1) { // Show it worked / Refresh $_url = build_url(array('page' => '_SELF', 'type' => 'add_poll', 'id' => $topic_id, 'try_validate' => 1), '_SELF'); return redirect_screen($_title, $_url, do_lang_tempcode('SUCCESS')); } } if (!$new_topic && $forum_id != -1 && $member_id == -1) { handle_topic_ticket_reply($forum_id, $topic_id, $topic_title, $post); } $text = $validated == 1 ? do_lang_tempcode('SUCCESS') : do_lang_tempcode('SUBMIT_UNVALIDATED'); require_code('autosave'); clear_ocp_autosave(); // Show it worked / Refresh $url = get_param('redirect', $url); return redirect_screen($_title, $url, $text); }
/** * The actualiser to start a backup. * * @return tempcode The UI */ function make_backup() { $title = get_page_title('BACKUP'); breadcrumb_set_parents(array(array('_SELF:_SELF:misc', do_lang_tempcode('BACKUP')))); breadcrumb_set_self(do_lang_tempcode('START')); $b_type = post_param('b_type', 'full'); if ($b_type == 'full') { $file = 'Backup_full_' . date('Y-m-d', utctime_to_usertime()) . '__' . uniqid('', true); // The last bit is unfortunate, but we need to stop URL guessing /*if ( (file_exists(get_custom_file_base().'/exports/backups/'.$file)) || (file_exists(get_custom_file_base().'/exports/backups/'.$file.'.txt')) || (file_exists(get_custom_file_base().'/exports/backups/'.$file.'.tar')) || (file_exists(get_custom_file_base().'/exports/backups/'.$file.'.gz')) ) $file='Backup_full_'.uniqid('',true);*/ } elseif ($b_type == 'incremental') { $file = 'Backup_incremental' . date('Y-m-d', utctime_to_usertime()) . '__' . uniqid('', true); // The last bit is unfortunate, but we need to stop URL guessing /*if ( (file_exists(get_custom_file_base().'/exports/backups/'.$file)) || (file_exists(get_custom_file_base().'/exports/backups/'.$file.'.txt')) || (file_exists(get_custom_file_base().'/exports/backups/'.$file.'.tar')) || (file_exists(get_custom_file_base().'/exports/backups/'.$file.'.gz')) ) $file='Backup_incremental_'.uniqid('',true);*/ } elseif ($b_type == 'sql') { $file = 'Backup_database' . date('Y-m-d', utctime_to_usertime()) . '__' . uniqid('', true); // The last bit is unfortunate, but we need to stop URL guessing /*if ( (file_exists(get_custom_file_base().'/exports/backups/'.$file)) || (file_exists(get_custom_file_base().'/exports/backups/'.$file.'.txt')) || (file_exists(get_custom_file_base().'/exports/backups/'.$file.'.tar')) || (file_exists(get_custom_file_base().'/exports/backups/'.$file.'.gz')) ) $file='Backup_database_'.uniqid('',true);*/ } else { exit; } $max_size = post_param_integer('max_size', 0); if ($max_size == 0 || !is_numeric($max_size)) { $max_size = 1000000000; } if (addon_installed('calendar')) { $schedule = get_input_date('schedule'); if (!is_null($schedule)) { set_value('backup_schedule_time', strval($schedule)); set_value('backup_recurrance_days', strval(post_param_integer('recurrance_days', 0))); set_value('backup_max_size', strval($max_size)); set_value('backup_b_type', $b_type); return inform_screen($title, do_lang_tempcode('SUCCESSFULLY_SCHEDULED_BACKUP')); } } $instant = get_param_integer('keep_backup_instant', 0); // Toggle this to true when debugging $max_time = intval(round(floatval(ini_get('max_execution_time')) / 1.5)); if ($max_time < 60 * 4) { if (function_exists('set_time_limit')) { @set_time_limit(0) or warn_exit(do_lang_tempcode('SAFE_MODE')); } } if ($instant == 1) { make_backup_2($file, $b_type, $max_size); } else { global $MB2_FILE, $MB2_B_TYPE, $MB2_MAX_SIZE; $MB2_FILE = $file; $MB2_B_TYPE = $b_type; $MB2_MAX_SIZE = $max_size; @ignore_user_abort(true); register_shutdown_function('make_backup_2'); } $url = build_url(array('page' => '_SELF'), '_SELF'); redirect_screen($title, $url, do_lang_tempcode('BACKUP_INFO_1', $file)); return new ocp_tempcode(); }
/** * Standard aed_module edit actualiser. * * @param ID_TEXT The entry being edited */ function edit_actualisation($_id) { $id = intval($_id); $validated = post_param_integer('validated', fractional_edit() ? INTEGER_MAGIC_NULL : 0); $news_article = post_param('post', STRING_MAGIC_NULL); if (post_param('main_news_category') != 'personal') { $main_news_category = post_param_integer('main_news_category', INTEGER_MAGIC_NULL); } else { warn_exit(do_lang_tempcode('INTERNAL_ERROR')); } $news_category = array(); if (array_key_exists('news_category', $_POST)) { foreach ($_POST['news_category'] as $val) { $news_category[] = intval($val); } } $allow_rating = post_param_integer('allow_rating', fractional_edit() ? INTEGER_MAGIC_NULL : 0); $allow_comments = post_param_integer('allow_comments', fractional_edit() ? INTEGER_MAGIC_NULL : 0); $allow_trackbacks = post_param_integer('allow_trackbacks', fractional_edit() ? INTEGER_MAGIC_NULL : 0); $notes = post_param('notes', STRING_MAGIC_NULL); $this->donext_type = $main_news_category; if (!fractional_edit()) { $urls = get_url('', 'file', 'uploads/grepimages', 0, OCP_UPLOAD_IMAGE); $url = $urls[0]; if ($url != '' && function_exists('imagecreatefromstring')) { convert_image(get_base_url() . '/' . $url, get_file_base() . '/uploads/grepimages/' . basename(rawurldecode($url)), -1, -1, intval(get_option('thumb_width')), true, NULL, false, true); } if ($url == '' && post_param_integer('file_unlink', 0) != 1) { $url = NULL; } } else { $url = STRING_MAGIC_NULL; } $owner = $GLOBALS['SITE_DB']->query_value_null_ok('news_categories', 'nc_owner', array('id' => $main_news_category)); // null_ok in case somehow category setting corrupted if (!is_null($owner) && $owner != get_member()) { check_specific_permission('can_submit_to_others_categories', array('news', $main_news_category), NULL, 'cms_news'); } $schedule = get_input_date('schedule'); $add_time = is_null($schedule) ? mixed() : $schedule; if (addon_installed('calendar') && has_specific_permission(get_member(), 'scheduled_publication_times')) { require_code('calendar2'); $schedule_code = ':$GLOBALS[\'SITE_DB\']->query_update(\'news\',array(\'date_and_time\'=>$GLOBALS[\'event_timestamp\'],\'validated\'=>1),array(\'id\'=>' . strval($id) . '),\'\',1);'; $past_event = $GLOBALS['SITE_DB']->query_value_null_ok('calendar_events e LEFT JOIN ' . $GLOBALS['SITE_DB']->get_table_prefix() . 'translate t ON e.e_content=t.id', 'e.id', array('text_original' => $schedule_code)); require_code('calendar'); if (!is_null($past_event)) { delete_calendar_event($past_event); } if (!is_null($schedule) && $schedule > time()) { $validated = 0; $start_year = post_param_integer('schedule_year'); $start_month = post_param_integer('schedule_month'); $start_day = post_param_integer('schedule_day'); $start_hour = post_param_integer('schedule_hour'); $start_minute = post_param_integer('schedule_minute'); $event_id = add_calendar_event(db_get_first_id(), 'none', NULL, 0, do_lang('PUBLISH_NEWS', 0, post_param('title')), $schedule_code, 3, 0, $start_year, $start_month, $start_day, $start_hour, $start_minute); regenerate_event_reminder_jobs($event_id, true); } } $title = post_param('title', STRING_MAGIC_NULL); if ($validated == 1 && $main_news_category != INTEGER_MAGIC_NULL && $GLOBALS['SITE_DB']->query_value('news', 'validated', array('id' => intval($id))) == 0) { $is_blog = true; $submitter = $GLOBALS['SITE_DB']->query_value('news', 'submitter', array('id' => $id)); $activity_title = $is_blog ? 'news:ACTIVITY_ADD_NEWS_BLOG' : 'news:ACTIVITY_ADD_NEWS'; $activity_title_validate = $is_blog ? 'news:ACTIVITY_VALIDATE_NEWS_BLOG' : 'news:ACTIVITY_VALIDATE_NEWS'; if (has_actual_page_access($GLOBALS['FORUM_DRIVER']->get_guest_id(), 'news')) { // NB: no category permission check, as syndication choice was explicit, and news categorisation is a bit more complex syndicate_described_activity($submitter != get_member() ? $activity_title_validate : $activity_title, $title, '', '', '_SEARCH:news:view:' . strval($id), '', '', 'news', 1, NULL, true); } } edit_news(intval($id), $title, post_param('news', STRING_MAGIC_NULL), post_param('author', STRING_MAGIC_NULL), $validated, $allow_rating, $allow_comments, $allow_trackbacks, $notes, $news_article, $main_news_category, $news_category, post_param('meta_keywords', STRING_MAGIC_NULL), post_param('meta_description', STRING_MAGIC_NULL), $url, $add_time); }
/** * Standard modular render function for profile tabs edit hooks. * * @param MEMBER The ID of the member who is being viewed * @param MEMBER The ID of the member who is doing the viewing * @param boolean Whether to leave the tab contents NULL, if tis hook supports it, so that AJAX can load it later * @return ?array A tuple: The tab title, the tab body text (may be blank), the tab fields, extra Javascript (may be blank) the suggested tab order, hidden fields (optional) (NULL: if $leave_to_ajax_if_possible was set) */ function render_tab($member_id_of, $member_id_viewing, $leave_to_ajax_if_possible = false) { $order = 0; // Actualiser if (post_param('submitting_settings_tab', NULL) !== NULL) { require_code('ocf_members_action2'); $is_ldap = ocf_is_ldap_member($member_id_of); $is_httpauth = ocf_is_httpauth_member($member_id_of); $is_remote = $GLOBALS['FORUM_DRIVER']->get_member_row_field($member_id_of, 'm_password_compat_scheme') == 'remote'; if ($is_ldap || $is_httpauth || $is_remote || $member_id_of != $member_id_viewing && !has_specific_permission($member_id_viewing, 'assume_any_member')) { $password = NULL; } else { $password = post_param('edit_password'); if ($password == '') { $password = NULL; } else { $password_confirm = trim(post_param('password_confirm')); if ($password != $password_confirm) { warn_exit(make_string_tempcode(escape_html(do_lang('PASSWORD_MISMATCH')))); } } } $custom_fields = ocf_get_all_custom_fields_match($GLOBALS['FORUM_DRIVER']->get_members_groups($member_id_of), $member_id_of != $member_id_viewing && !has_specific_permission($member_id_viewing, 'view_any_profile_field') ? 1 : NULL, $member_id_of != $member_id_viewing ? NULL : 1, $member_id_of != $member_id_viewing ? NULL : 1); $actual_custom_fields = ocf_read_in_custom_fields($custom_fields, $member_id_of); $pt_allow = array_key_exists('pt_allow', $_POST) ? implode(',', $_POST['pt_allow']) : ''; $tmp_groups = $GLOBALS['OCF_DRIVER']->get_usergroup_list(true, true); $all_pt_allow = ''; foreach (array_keys($tmp_groups) as $key) { if ($key != db_get_first_id()) { if ($all_pt_allow != '') { $all_pt_allow .= ','; } $all_pt_allow .= strval($key); } } if ($pt_allow == $all_pt_allow) { $pt_allow = '*'; } $pt_rules_text = post_param('pt_rules_text', NULL); if (has_specific_permission($member_id_viewing, 'member_maintenance')) { $validated = post_param_integer('validated', 0); $primary_group = $is_ldap || !has_specific_permission($member_id_viewing, 'assume_any_member') ? NULL : post_param_integer('primary_group', NULL); $is_perm_banned = post_param_integer('is_perm_banned', 0); $old_is_perm_banned = $GLOBALS['FORUM_DRIVER']->get_member_row_field($member_id_of, 'm_is_perm_banned'); if ($old_is_perm_banned != $is_perm_banned) { if ($is_perm_banned == 1) { ocf_ban_member($member_id_of); } else { ocf_unban_member($member_id_of); } } $highlighted_name = post_param_integer('highlighted_name', 0); if (has_specific_permission($member_id_viewing, 'probate_members')) { $on_probation_until = get_input_date('on_probation_until'); $current__on_probation_until = $GLOBALS['FORUM_DRIVER']->get_member_row_field($member_id_of, 'm_on_probation_until'); if ((is_null($on_probation_until) || $on_probation_until <= time()) && $current__on_probation_until > time()) { log_it('STOP_PROBATION', strval($member_id_of), $GLOBALS['FORUM_DRIVER']->get_username($member_id_of)); } elseif (!is_null($on_probation_until) && $on_probation_until > time() && $current__on_probation_until <= time()) { log_it('START_PROBATION', strval($member_id_of), $GLOBALS['FORUM_DRIVER']->get_username($member_id_of)); } elseif (!is_null($on_probation_until) && $current__on_probation_until > $on_probation_until && $on_probation_until > time() && $current__on_probation_until > time()) { log_it('REDUCE_PROBATION', strval($member_id_of), $GLOBALS['FORUM_DRIVER']->get_username($member_id_of)); } elseif (!is_null($on_probation_until) && $current__on_probation_until < $on_probation_until && $on_probation_until > time() && $current__on_probation_until > time()) { log_it('EXTEND_PROBATION', strval($member_id_of), $GLOBALS['FORUM_DRIVER']->get_username($member_id_of)); } } else { $on_probation_until = NULL; } } else { $validated = NULL; $primary_group = NULL; $highlighted_name = NULL; $on_probation_until = NULL; } if (has_actual_page_access($member_id_viewing, 'admin_ocf_join') || has_specific_permission($member_id_of, 'rename_self')) { $username = $is_ldap || $is_remote ? NULL : post_param('edit_username', NULL); } else { $username = NULL; } $email = post_param('email_address', NULL); if (!is_null($email)) { $email = trim($email); } $theme = post_param('theme', NULL); if ($is_remote) { $preview_posts = NULL; $zone_wide = NULL; $auto_monitor_contrib_content = NULL; $views_signatures = NULL; $timezone = NULL; } else { $preview_posts = post_param_integer('preview_posts', 0); $zone_wide = post_param_integer('zone_wide', 0); $auto_monitor_contrib_content = NULL; //post_param_integer('auto_monitor_contrib_content',0); Moved to notifications tab $views_signatures = post_param_integer('views_signatures', 0); $timezone = post_param('timezone', get_site_timezone()); } ocf_edit_member($member_id_of, $email, $preview_posts, post_param_integer('dob_day', -1), post_param_integer('dob_month', -1), post_param_integer('dob_year', -1), $timezone, $primary_group, $actual_custom_fields, $theme, post_param_integer('reveal_age', 0), $views_signatures, $auto_monitor_contrib_content, post_param('language', NULL), post_param_integer('allow_emails', 0), post_param_integer('allow_emails_from_staff', 0), $validated, $username, $password, $zone_wide, $highlighted_name, $pt_allow, $pt_rules_text, $on_probation_until); if (!array_key_exists('secondary_groups', $_POST)) { $_POST['secondary_groups'] = array(); } require_code('ocf_groups_action2'); $members_groups = $GLOBALS['OCF_DRIVER']->get_members_groups($member_id_of); $group_count = $GLOBALS['FORUM_DB']->query_value('f_groups', 'COUNT(*)'); $groups = list_to_map('id', $GLOBALS['FORUM_DB']->query_select('f_groups', array('*'), $group_count > 200 ? array('g_is_private_club' => 0) : NULL)); foreach ($_POST['secondary_groups'] as $group_id) { $group = $groups[intval($group_id)]; if ($group['g_hidden'] == 1 && !in_array($group['id'], $members_groups) && !has_specific_permission($member_id_viewing, 'see_hidden_groups')) { continue; } if (!in_array($group['id'], $members_groups) && (has_specific_permission($member_id_viewing, 'assume_any_member') || $group['g_open_membership'] == 1)) { ocf_add_member_to_group($member_id_of, $group['id']); } } foreach ($members_groups as $group_id) { if (!in_array(strval($group_id), $_POST['secondary_groups'])) { ocf_member_leave_group($group_id, $member_id_of); } } $GLOBALS['FORUM_DB']->query('DELETE FROM ' . $GLOBALS['FORUM_DB']->get_table_prefix() . 'f_member_known_login_ips WHERE i_member_id=' . strval($member_id_of) . ' AND ' . db_string_not_equal_to('i_val_code', '')); // So any re-confirms can happen if (addon_installed('awards')) { require_code('awards'); handle_award_setting('member', strval($member_id_of)); } attach_message(do_lang_tempcode('SUCCESS_SAVE'), 'inform'); } if ($leave_to_ajax_if_possible) { return NULL; } // UI $title = do_lang_tempcode('SETTINGS'); $myrow = $GLOBALS['FORUM_DRIVER']->get_member_row($member_id_of); if (is_null($myrow)) { warn_exit(do_lang_tempcode('USER_NO_EXIST')); } require_code('ocf_members_action2'); list($fields, $hidden) = ocf_get_member_fields_settings(false, $member_id_of, NULL, $myrow['m_email_address'], $myrow['m_preview_posts'], $myrow['m_dob_day'], $myrow['m_dob_month'], $myrow['m_dob_year'], get_users_timezone($member_id_of), $myrow['m_theme'], $myrow['m_reveal_age'], $myrow['m_views_signatures'], $myrow['m_auto_monitor_contrib_content'], $myrow['m_language'], $myrow['m_allow_emails'], $myrow['m_allow_emails_from_staff'], $myrow['m_validated'], $myrow['m_primary_group'], $myrow['m_username'], $myrow['m_is_perm_banned'], '', $myrow['m_zone_wide'], $myrow['m_highlighted_name'], $myrow['m_pt_allow'], get_translated_text($myrow['m_pt_rules_text'], $GLOBALS['FORUM_DB']), $myrow['m_on_probation_until']); // Awards? if (addon_installed('awards')) { require_code('awards'); $fields->attach(get_award_fields('member', strval($member_id_of))); } $redirect = get_param('redirect', NULL); if (!is_null($redirect)) { $hidden->attach(form_input_hidden('redirect', $redirect)); } $hidden->attach(form_input_hidden('submitting_settings_tab', '1')); $javascript = "\n\t\t\tvar form=document.getElementById('email_address').form;\n\t\t\tform.prior_profile_edit_submit=form.onsubmit;\n\t\t\tform.onsubmit=function()\n\t\t\t\t{\n\t\t\t\t\tif (typeof form.elements['edit_password']!='undefined')\n\t\t\t\t\t{\n\t\t\t\t\t\tif ((form.elements['password_confirm']) && (form.elements['password_confirm'].value!=form.elements['edit_password'].value))\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\twindow.fauxmodal_alert('" . php_addslashes(do_lang('PASSWORD_MISMATCH')) . "');\n\t\t\t\t\t\t\treturn false;\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t\tif (typeof form.prior_profile_edit_submit!='undefined' && form.prior_profile_edit_submit) return form.prior_profile_edit_submit();\n\t\t\t\t\treturn true;\n\t\t\t\t};\n\t\t"; $text = ''; return array($title, $fields, $text, $javascript, $order, $hidden); }
/** * Read booking request from POST environment. * * @return array Booking details structure. */ function get_booking_request_from_form() { $request = array(); $bookables = list_to_map('id', $GLOBALS['SITE_DB']->query_select('bookable', array('*'))); foreach ($bookables as $bookable_id => $bookable) { $all_supplements = $GLOBALS['SITE_DB']->query_select('bookable_supplement', array('*')); $quantity = post_param_integer('bookable_' . strval($bookable_id) . '_quantity', 0); if ($quantity > 0) { $start = get_input_date('bookable_' . strval($bookable_id) . '_date_from'); if (is_null($start)) { $start = get_input_date('bookable_date_from'); } $start_day = intval(date('d', $start)); $start_month = intval(date('m', $start)); $start_year = intval(date('Y', $start)); if ($bookable['dates_are_ranges'] == 1) { $end = get_input_date('bookable_' . strval($bookable_id) . '_date_to'); if (is_null($end)) { $end = get_input_date('bookable_date_to'); } $end_day = intval(date('d', $end)); $end_month = intval(date('m', $end)); $end_year = intval(date('Y', $end)); } else { $end_day = $start_day; $end_month = $start_month; $end_year = $start_year; } $notes = read_booking_notes_from_form('bookable_' . strval($bookable_id) . '_notes'); $supplements = array(); foreach ($all_supplements as $supplement) { $s_quantity = post_param_integer('bookable_' . strval($bookable_id) . '_supplement_' . strval($supplement['id']) . '_quantity', 0); if ($s_quantity > 0) { $s_notes = read_booking_notes_from_form('bookable_' . strval($bookable_id) . '_supplement_' . strval($supplement['id']) . '_notes'); $supplements[$supplement['id']] = array('quantity' => $s_quantity, 'notes' => $s_notes); } } $request[] = array('bookable_id' => $bookable_id, 'start_day' => $start_day, 'start_month' => $start_month, 'start_year' => $start_year, 'end_day' => $end_day, 'end_month' => $end_month, 'end_year' => $end_year, 'quantity' => $quantity, 'notes' => $notes, 'supplements' => $supplements); } } return $request; }
/** * Build up a preview based on what was submitted. * * @param boolean Whether to return additional data * @return mixed Either tempcode for the preview, or a tuple of details */ function build_preview($multi_return = false) { // Check CAPTCHA if it is passed if (addon_installed('captcha')) { if (array_key_exists('post', $_POST) && $_POST['post'] != '' && array_key_exists('security_image', $_POST)) { require_code('captcha'); enforce_captcha(false); } } require_code('attachments2'); $hooks = find_all_hooks('systems', 'preview'); $output = NULL; $new_post_value = NULL; $attachment_type = NULL; $forum_db = false; $limit_to = NULL; foreach (array_keys($hooks) as $hook) { require_code('hooks/systems/preview/' . $hook); $object = object_factory('Hook_Preview_' . $hook, true); if (is_null($object)) { continue; } $apply_bits = $object->applies(); $applies = $apply_bits[0]; if ($applies) { $attachment_type = $apply_bits[1]; $forum_db = array_key_exists(2, $apply_bits) ? $apply_bits[2] : false; $limit_to = array_key_exists(3, $apply_bits) ? $apply_bits[3] : NULL; if (method_exists($object, 'run')) { list($output, $new_post_value) = $object->run(); } break; } } $validation = new ocp_tempcode(); $keyword_density = new ocp_tempcode(); $spelling = new ocp_tempcode(); $meta_keywords = post_param('meta_keywords', ''); $spellcheck = post_param_integer('perform_spellcheck', 0) == 1; $keywordcheck = post_param_integer('perform_keywordcheck', 0) == 1 && $meta_keywords != ''; if (post_param_integer('perform_validation', 0) != 0) { foreach ($_POST as $key => $val) { if (!is_string($val)) { continue; } $val = post_param($key, ''); // stripslashes, and wysiwyg output handling $tempcodecss = post_param_integer('tempcodecss__' . $key, 0) == 1; $supports_comcode = post_param_integer('comcode__' . $key, 0) == 1; if ($supports_comcode) { $temp = $_FILES; $_FILES = array(); $valt = comcode_to_tempcode($val); $_FILES = $temp; require_code('view_modes'); require_code('obfuscate'); require_code('validation'); $validation->attach(do_xhtml_validation($valt->evaluate(), false, post_param_integer('perform_validation', 0), true)); } elseif ($tempcodecss) { $i = 0; $color = post_param(strval($i), ''); while ($color != '') { $val = str_replace('<color-' . strval($i) . '>', '#' . $color, $val); $i++; $color = post_param(strval($i), ''); } $_val_orig = $val; require_lang('validation'); require_css('adminzone'); require_code('view_modes'); require_code('obfuscate'); require_code('validation'); require_code('validation2'); $error = check_css($_val_orig); $show = count($error['errors']) != 0; if ($show) { $validation->attach(display_validation_results($_val_orig, $error, true, true)); } } } } if ($spellcheck) { if (addon_installed('wordfilter')) { $words_skip = collapse_1d_complexity('w_replacement', $GLOBALS['SITE_DB']->query_select('wordfilter', array('w_replacement'))); } else { $words_skip = array(); } require_once get_file_base() . '/data/areaedit/plugins/SpellChecker/spell-check-logic.php'; } $db = $forum_db ? $GLOBALS['FORUM_DB'] : $GLOBALS['SITE_DB']; $view_space_map = array(); require_code('templates_view_space'); foreach ($_POST as $key => $val) { if (!is_string($val)) { continue; } if (!is_null($limit_to) && !in_array($key, $limit_to)) { continue; } $val = post_param($key, ''); // stripslashes, and wysiwyg output handling if ($val == '0') { $val = do_lang('NO'); } if ($val == '1') { $val = do_lang('YES'); } if (substr($key, 0, 14) == 'review_rating' || substr($key, 0, 7) == 'rating') { $val .= '/10'; } $is_hidden = in_array($key, array('from_url', 'password', 'confirm_password', 'edit_password', 'MAX_FILE_SIZE', 'perform_validation', '_validated', 'id', 'posting_ref_id', 'f_face', 'f_colour', 'f_size', 'http_referer')) || strpos($key, 'hour') !== false || strpos($key, 'access_') !== false || strpos($key, 'minute') !== false || strpos($key, 'confirm') !== false || strpos($key, 'pre_f_') !== false || strpos($key, 'label_for__') !== false || strpos($key, 'wysiwyg_version_of_') !== false || strpos($key, 'is_wysiwyg') !== false || strpos($key, 'require__') !== false || strpos($key, 'tempcodecss__') !== false || strpos($key, 'comcode__') !== false || strpos($key, '_parsed') !== false || preg_match('#^caption\\d+$#', $key) != 0 || preg_match('#^attachmenttype\\d+$#', $key) != 0 || substr($key, 0, 1) == '_' || substr($key, 0, 9) == 'hidFileID' || substr($key, 0, 11) == 'hidFileName'; if (substr($key, 0, 14) == 'tick_on_form__') { if (post_param_integer(substr($key, 14), 0) == 1) { $is_hidden = true; } else { $key = substr($key, 14); } } if (substr($key, -4) == '_day') { $key = substr($key, 0, strlen($key) - 4); $timestamp = get_input_date($key); if (is_null($timestamp)) { $is_hidden = true; } else { $val = get_timezoned_date($timestamp, false, true, false, true); } } elseif (substr($key, -6) == '_month' || substr($key, -5) == '_year') { $is_hidden = true; } $key_nice = post_param('label_for__' . $key, ucwords(str_replace('_', ' ', $key))); if ($key_nice == '') { $is_hidden = true; } if (!$is_hidden) { if ($spellcheck) { require_code('comcode_from_html'); $mispellings = spellchecklogic('check', strip_comcode(semihtml_to_comcode($val, true)), $words_skip, true); $_misspellings = array(); foreach ($mispellings as $misspelling) { list($word_bad, $words_good) = $misspelling; $_misspellings[] = array('WORD' => $word_bad, 'CORRECTIONS' => implode(', ', $words_good)); } if (count($_misspellings) != 0) { $spelling->attach(do_template('PREVIEW_SCRIPT_SPELLING', array('_GUID' => '9649572982c01995a8f47c58d16fda39', 'FIELD' => $key_nice, 'MISSPELLINGS' => $_misspellings))); } } if ($keywordcheck && (strpos($val, ' ') !== false || $key == 'title')) { $keyword_explode = explode(',', $meta_keywords); $keywords = array(); $word_count = str_word_count($val); if ($word_count != 0) { foreach ($keyword_explode as $meta_keyword) { $meta_keyword = trim($meta_keyword); if ($meta_keyword != '') { $density = substr_count($val, $meta_keyword) / $word_count; $ideal_density = 1.0 / (9.0 * count($keyword_explode)); // Pretty rough -- common sense is needed $keywords[] = array('sort' => $ideal_density, 'KEYWORD' => $meta_keyword, 'IDEAL_DENSITY' => strval(intval(round($ideal_density * 100))), 'DENSITY' => strval(intval(round($density * 100)))); } } global $M_SORT_KEY; $M_SORT_KEY = 'sort'; usort($keywords, 'multi_sort'); foreach ($keywords as $ti => $meta_keyword) { unset($keywords[$ti]['sort']); } if (count($keywords) != 0) { $keyword_density->attach(do_template('PREVIEW_SCRIPT_KEYWORD_DENSITY', array('_GUID' => '4fa05e9f52023958a3594d1610b00747', 'FIELD' => $key_nice, 'KEYWORDS' => $keywords))); } } } } if (is_null($output)) { if (is_null($attachment_type) || $key != 'post') { $tempcodecss = post_param_integer('tempcodecss__' . $key, 0) == 1; $supports_comcode = post_param_integer('comcode__' . $key, 0) == 1; $preformatted = post_param_integer('pre_f_' . $key, 0) == 1; if ($is_hidden) { continue; } if ($preformatted) { $valt = with_whitespace($val); } elseif ($supports_comcode) { $valt = comcode_to_tempcode($val); } elseif ($tempcodecss) { $i = 0; $color = post_param(strval($i), ''); while ($color != '') { $val = str_replace('<color-' . strval($i) . '>', '#' . $color, $val); $i++; $color = post_param(strval($i), ''); } $_val_orig = $val; $valt = comcode_to_tempcode("[code=\"CSS\"]" . $val . "[/code]"); } else { $valt = make_string_tempcode(escape_html($val)); } $view_space_map[$key_nice] = $valt; } else { $tempcodecss = false; $posting_ref_id = post_param_integer('posting_ref_id'); if ($posting_ref_id < 0) { fatal_exit(do_lang_tempcode('INTERNAL_ERROR')); } $post_bits = do_comcode_attachments($val, $attachment_type, strval(-$posting_ref_id), true, $db); $new_post_value = $post_bits['comcode']; $view_space_map[$key_nice] = $post_bits['tempcode']; $val = $post_bits['tempcode']; $supports_comcode = true; } } } // Make attachments temporarily readable without any permission context global $COMCODE_ATTACHMENTS; $posting_ref_id = post_param_integer('posting_ref_id', NULL); if (!is_null($posting_ref_id)) { if (array_key_exists(strval(-$posting_ref_id), $COMCODE_ATTACHMENTS)) { foreach ($COMCODE_ATTACHMENTS[strval(-$posting_ref_id)] as $attachment) { $db->query_delete('attachment_refs', array('r_referer_type' => 'null', 'r_referer_id' => strval(-$posting_ref_id), 'a_id' => $attachment['id']), '', 1); $db->query_insert('attachment_refs', array('r_referer_type' => 'null', 'r_referer_id' => strval(-$posting_ref_id), 'a_id' => $attachment['id'])); } } } if (is_null($output)) { if (count($view_space_map) == 1) { $output = array_pop($view_space_map); } else { $view_space_fields = new ocp_tempcode(); foreach ($view_space_map as $key => $val) { $view_space_fields->attach(view_space_field($key, $val, true)); } $output = do_template('VIEW_SPACE', array('_GUID' => '3f548883b9eb37054c500d1088d9efa3', 'WIDTH' => '170', 'FIELDS' => $view_space_fields)); } } // This is to get the Comcode attachments updated to the new IDs if (!is_null($new_post_value)) { $new_post_value_html = comcode_to_tempcode($new_post_value, NULL, false, 60, NULL, $db, true); if (strpos($new_post_value_html->evaluate(), '<!-- CC-error -->') === false) { $output->attach(do_template('PREVIEW_SCRIPT_CODE', array('_GUID' => 'bc7432af91e1eaf212dc210f3bf2f756', 'NEW_POST_VALUE_HTML' => $new_post_value_html, 'NEW_POST_VALUE' => $new_post_value))); } } $output->handle_symbol_preprocessing(); if ($multi_return) { return array($output, $validation, $keyword_density, $spelling); } return $output; }
/** * The actualiser to edit a configuration page. * * @return tempcode The UI */ function config_set() { $page = get_param('id', 'MAIN'); $title = get_page_title(do_lang_tempcode('CONFIG_CATEGORY_' . $page), false); // Make sure we haven't locked ourselves out due to clean URL support if (post_param_integer('mod_rewrite', 0) == 1 && substr(ocp_srv('SERVER_SOFTWARE'), 0, 6) == 'Apache' && (!file_exists(get_file_base() . '/.htaccess') || strpos(file_get_contents(get_file_base() . '/.htaccess'), 'RewriteEngine on') === false)) { warn_exit(do_lang_tempcode('BEFORE_MOD_REWRITE')); } // Make sure we haven't just locked staff out $new_site_name = substr(post_param('site_name', ''), 0, 200); if ($new_site_name != '' && get_option('is_on_sync_staff', true) === '1') { $admin_groups = array_merge($GLOBALS['FORUM_DRIVER']->get_super_admin_groups(), $GLOBALS['FORUM_DRIVER']->get_moderator_groups()); $staff = $GLOBALS['FORUM_DRIVER']->member_group_query($admin_groups, 100); if (count($staff) < 100) { foreach ($staff as $row_staff) { $member = $GLOBALS['FORUM_DRIVER']->pname_id($row_staff); if ($GLOBALS['FORUM_DRIVER']->is_staff($member)) { $sites = get_ocp_cpf('sites'); $sites = str_replace(', ' . get_site_name(), '', $sites); $sites = str_replace(',' . get_site_name(), '', $sites); $sites = str_replace(get_site_name() . ', ', '', $sites); $sites = str_replace(get_site_name() . ',', '', $sites); $sites = str_replace(get_site_name(), '', $sites); if ($sites != '') { $sites .= ', '; } $sites .= $new_site_name; $GLOBALS['FORUM_DRIVER']->set_custom_field($member, 'sites', $sites); } } } } // Empty thumbnail cache if needed if (get_option('is_on_gd') == '1' && function_exists('imagetypes')) { if (!is_null(post_param('thumb_width', NULL)) && post_param('thumb_width') != get_option('thumb_width')) { $thumb_fields = $GLOBALS['SITE_DB']->query('SELECT m_name,m_table FROM ' . $GLOBALS['SITE_DB']->get_table_prefix() . 'db_meta WHERE m_name LIKE \'' . db_encode_like('%thumb_url') . '\''); $GLOBALS['NO_DB_SCOPE_CHECK'] = true; foreach ($thumb_fields as $field) { if ($field['m_table'] == 'videos') { continue; } $GLOBALS['SITE_DB']->query_update($field['m_table'], array($field['m_name'] => '')); } $GLOBALS['NO_DB_SCOPE_CHECK'] = false; } } $rows = $GLOBALS['SITE_DB']->query_select('config', array('*'), array('the_page' => $page)); if ($page == 'SITE') { $rows[] = array('the_name' => 'timezone', 'shared_hosting_restricted' => 0, 'the_type' => 'special', 'eval' => ''); } foreach ($rows as $myrow) { if ($myrow['eval'] != '') { if (defined('HIPHOP_PHP')) { require_code('hooks/systems/config_default/' . $myrow['the_name']); $hook = object_factory('Hook_config_default_' . $myrow['the_name']); if (is_null($hook->get_default())) { continue; } } else { $GLOBALS['REQUIRE_LANG_LOOP'] = 10; // LEGACY Workaround for corrupt webhost installers if (is_null(@eval($myrow['eval'] . ';'))) { continue; } // @'d in case default is corrupt, don't want it to give errors forever $GLOBALS['REQUIRE_LANG_LOOP'] = 0; // LEGACY } } if ($myrow['shared_hosting_restricted'] == 1 && !is_null($GLOBALS['CURRENT_SHARE_USER'])) { continue; } if ($myrow['the_type'] == 'tick') { $value = strval(post_param_integer($myrow['the_name'], 0)); } elseif ($myrow['the_type'] == 'date') { $date_value = get_input_date($myrow['the_name']); $value = is_null($date_value) ? '' : strval($date_value); } elseif (($myrow['the_type'] == 'forum' || $myrow['the_type'] == '?forum') && get_forum_type() == 'ocf') { $value = post_param($myrow['the_name']); if (is_numeric($value)) { $value = $GLOBALS['FORUM_DB']->query_value_null_ok('f_forums', 'f_name', array('id' => post_param_integer($myrow['the_name']))); } if (is_null($value)) { $value = ''; } } elseif ($myrow['the_type'] == 'category' && get_forum_type() == 'ocf') { $value = post_param($myrow['the_name']); if (is_numeric($value)) { $value = $GLOBALS['FORUM_DB']->query_value_null_ok('f_categories', 'c_title', array('id' => post_param_integer($myrow['the_name']))); } if (is_null($value)) { $value = ''; } } elseif ($myrow['the_type'] == 'usergroup' && get_forum_type() == 'ocf') { $value = $GLOBALS['FORUM_DB']->query_value_null_ok('f_groups g LEFT JOIN ' . $GLOBALS['FORUM_DB']->get_table_prefix() . 'translate t ON t.id=g.g_name', 'text_original', array('g.id' => post_param_integer($myrow['the_name']))); if (is_null($value)) { $value = ''; } } else { $value = post_param($myrow['the_name'], ''); } if ($myrow['the_type'] == 'special') { if ($myrow['the_name'] == 'timezone') { set_value('timezone', $value); } } else { if (($myrow['the_type'] == 'transline' || $myrow['the_type'] == 'transtext') && is_numeric($myrow['config_value'])) { $old_value = get_translated_text(intval($myrow['config_value'])); } else { $old_value = $myrow['config_value']; } // If the option was changed if ($old_value != $value || $myrow['c_set'] == 0) { set_option($myrow['the_name'], $value, $myrow['the_type'], $myrow['config_value']); } } } // Clear some cacheing require_code('view_modes'); require_code('zones2'); require_code('zones3'); erase_comcode_page_cache(); erase_tempcode_cache(); //persistant_cache_delete('OPTIONS'); Done by set_option persistant_cache_empty(); erase_cached_templates(); // Show it worked / Refresh $redirect = get_param('redirect', NULL); if ($redirect === NULL) { $url = build_url(array('page' => '_SELF', 'type' => 'misc'), '_SELF'); // ,'type'=>'category','id'=>$page } else { $url = make_string_tempcode($redirect); } return redirect_screen($title, $url, do_lang_tempcode('SUCCESS')); }
/** * Show a profit/loss account. * * @return tempcode The result of execution. */ function profit_loss() { $title = get_page_title('PROFIT_LOSS'); $GLOBALS['HELPER_PANEL_PIC'] = 'pagepics/profit_loss'; breadcrumb_set_parents(array(array('_SELF:_SELF:ecom_usage', do_lang_tempcode('ECOMMERCE')))); $d = array(get_input_date('from', true), get_input_date('to', true)); if (is_null($d[0])) { return $this->get_between($title); } list($from, $to) = $d; $types = $this->get_types($from, $to, true); unset($types['OPENING']); unset($types['CLOSING']); breadcrumb_set_parents(array(array('_SELF:_SELF:ecom_usage', do_lang_tempcode('ECOMMERCE')), array('_SELF:_SELF:profit_loss', do_lang_tempcode('PROFIT_LOSS')))); breadcrumb_set_self(do_lang_tempcode('RESULT')); return do_template('ECOM_CASH_FLOW_SCREEN', array('_GUID' => '255681ec95e90e36e085d14cf984b725', 'TITLE' => $title, 'TYPES' => $types)); }
/** * The UI to show top search keywords. * * @param object The stats module object * @param string The screen type * @return tempcode The UI */ function search($ob, $type) { // Handle time range if (get_param_integer('dated', 0) == 0) { $title = get_page_title('SEARCH_STATISTICS'); return $ob->get_between($title); } $time_start = get_input_date('time_start', true); $time_end = get_input_date('time_end', true); if (!is_null($time_end)) { $time_end += 60 * 60 * 24 - 1; } // So it is end of day not start if (is_null($time_start)) { $time_start = 0; } if (is_null($time_end)) { $time_end = time(); } $title = get_page_title('SEARCH_STATISTICS_RANGE', true, array(escape_html(get_timezoned_date($time_start, false)), escape_html(get_timezoned_date($time_end, false)))); $start = get_param_integer('start', 0); $max = get_param_integer('max', 20); $sortables = array('s_primary' => do_lang_tempcode('SEARCH_STATISTICS')); $test = explode(' ', get_param('sort', 's_primary DESC'), 2); if (count($test) == 1) { $test[1] = 'DESC'; } list($sortable, $sort_order) = $test; if (strtoupper($sort_order) != 'ASC' && strtoupper($sort_order) != 'DESC' || !array_key_exists($sortable, $sortables)) { log_hack_attack_and_exit('ORDERBY_HACK'); } global $NON_CANONICAL_PARAMS; $NON_CANONICAL_PARAMS[] = 'sort'; $rows = $GLOBALS['SITE_DB']->query('SELECT s_primary,COUNT(*) AS cnt FROM ' . $GLOBALS['SITE_DB']->get_table_prefix() . 'searches_logged WHERE s_time>' . strval((int) $time_start) . ' AND s_time<' . strval((int) $time_end) . ' GROUP BY s_primary ORDER BY ' . $sortable . ' ' . $sort_order); if (count($rows) < 1) { return warn_screen($title, do_lang_tempcode('NO_DATA')); } $keywords = array(); $total = 0; foreach ($rows as $value) { $keywords[$value['s_primary']] = $value['cnt']; $total += $value['cnt']; } if ($sort_order == 'ASC') { asort($keywords); } else { arsort($keywords); } require_code('templates_results_table'); $fields_title = results_field_title(array(do_lang_tempcode('KEYWORD'), do_lang_tempcode('COUNT_VIEWS')), $sortables, 'sort', $sortable . ' ' . $sort_order); $fields = new ocp_tempcode(); $degrees = 360 / $total; $done_total = 0; //$done=0; $data = array(); $i = 0; foreach ($keywords as $keyword => $views) { if ($i < $start) { $i++; continue; } elseif ($i >= $start + $max) { break; } if ($keyword == '') { $link = do_lang_tempcode('SEARCH_STATS_ADVANCED'); } else { $link = protect_from_escaping(escape_html($keyword)); } $fields->attach(results_entry(array($link, integer_format($views)), true)); //if ($done<20) //{ $data[$keyword] = $keywords[$keyword] * $degrees; //$done++; $done_total += $data[$keyword]; //} $i++; } if (360 - $done_total > 0) { $data[do_lang('OTHER')] = 360 - $done_total; $fields->attach(results_entry(array(do_lang('OTHER'), float_format((360 - $done_total) / $degrees)))); } $list = results_table(do_lang_tempcode('SEARCH_STATISTICS'), $start, 'start', $max, 'max', count($keywords), $fields_title, $fields, $sortables, $sortable, $sort_order, 'sort', new ocp_tempcode()); $output = create_pie_chart($data); $ob->save_graph('Global-Search', $output); $graph = do_template('STATS_GRAPH', array('GRAPH' => get_custom_base_url() . '/data_custom/modules/admin_stats/Global-Search.xml', 'TITLE' => do_lang_tempcode('SEARCH_STATISTICS'), 'TEXT' => do_lang_tempcode('DESCRIPTION_SEARCH_STATISTICS'))); breadcrumb_set_parents(array(array('_SELF:_SELF:misc', do_lang_tempcode('SITE_STATISTICS')))); return do_template('STATS_SCREEN', array('_GUID' => '727a59e061727c4a1e24345cecb769aa', 'TITLE' => $title, 'GRAPH' => $graph, 'STATS' => $list)); }
/** * Get the form posted parameters specifying an event. * * @return array A list of parameters in a certain order (see the return command to see the order) */ function get_event_parameters() { $type = post_param_integer('type', INTEGER_MAGIC_NULL); if (!has_actual_page_access(get_member(), 'admin_occle') && $type == db_get_first_id()) { access_denied('I_ERROR'); } $recurrence = post_param('recurrence', STRING_MAGIC_NULL); if ($recurrence != 'none' && $recurrence != STRING_MAGIC_NULL) { $recurrence_pattern = post_param('recurrence_pattern', ''); if ($recurrence_pattern != '') { $recurrence .= ' ' . $recurrence_pattern; } } $title = post_param('title'); $content = post_param('post', STRING_MAGIC_NULL); $priority = post_param_integer('priority', INTEGER_MAGIC_NULL); $is_public = has_specific_permission(get_member(), 'add_public_events') ? post_param_integer('is_public', fractional_edit() ? INTEGER_MAGIC_NULL : 0) : 0; $recurrences = post_param_integer('recurrences', fractional_edit() ? INTEGER_MAGIC_NULL : -1); if ($recurrences == -1) { $recurrences = NULL; } $timezone = post_param('timezone', STRING_MAGIC_NULL); $do_timezone_conv = post_param_integer('do_timezone_conv', fractional_edit() ? INTEGER_MAGIC_NULL : 0); $start = get_input_date('start'); if (is_null($start)) { $start_year = INTEGER_MAGIC_NULL; $start_month = INTEGER_MAGIC_NULL; $start_day = INTEGER_MAGIC_NULL; $start_hour = INTEGER_MAGIC_NULL; $start_minute = INTEGER_MAGIC_NULL; } else { $start_year = intval(date('Y', $start)); $start_month = intval(date('m', $start)); $start_day = intval(date('d', $start)); if (post_param_integer('all_day_event', 0) == 1) { $start_hour = NULL; $start_minute = NULL; } else { $start_hour = intval(date('H', $start)); $start_minute = intval(date('i', $start)); } } if (fractional_edit()) { $end_year = INTEGER_MAGIC_NULL; $end_month = INTEGER_MAGIC_NULL; $end_day = INTEGER_MAGIC_NULL; $end_hour = INTEGER_MAGIC_NULL; $end_minute = INTEGER_MAGIC_NULL; } else { $end = get_input_date('end'); if (!is_null($end)) { $end_year = intval(date('Y', $end)); $end_month = intval(date('m', $end)); $end_day = intval(date('d', $end)); if (post_param_integer('all_day_event', 0) == 1) { $end_hour = NULL; $end_minute = NULL; } else { $end_hour = intval(date('H', $end)); $end_minute = intval(date('i', $end)); } // Error if wrong way around if ($start > $end) { warn_exit(do_lang_tempcode('EVENT_CANNOT_AROUND')); } } else { $end_year = NULL; $end_month = NULL; $end_day = NULL; $end_hour = NULL; $end_minute = NULL; } } return array($type, $recurrence, $recurrences, $title, $content, $priority, $is_public, $start_year, $start_month, $start_day, $start_hour, $start_minute, $end_year, $end_month, $end_day, $end_hour, $end_minute, $timezone, $do_timezone_conv); }
/** * Standard aed_module add actualiser. * * @return ID_TEXT The entry added */ function add_actualisation() { $explanation = post_param('explanation'); $member_id = post_param_integer('member_id'); $message = post_param('message', ''); $username = $GLOBALS['FORUM_DRIVER']->get_username($member_id); if (is_null($username)) { warn_exit(do_lang_tempcode('_USER_NO_EXIST', escape_html($username))); } $save = post_param('save'); if ($save != '') { $GLOBALS['FORUM_DB']->query_delete('f_saved_warnings', array('s_title' => $save), '', 1); $GLOBALS['FORUM_DB']->query_insert('f_saved_warnings', array('s_title' => $save, 's_explanation' => $explanation, 's_message' => $message)); } // Send PT if ($message != '') { require_code('ocf_topics_action'); require_code('ocf_topics_action2'); require_code('ocf_posts_action'); require_code('ocf_posts_action2'); $_title = do_lang('NEW_WARNING_TO_YOU'); $pt_topic_id = ocf_make_topic(NULL, '', '', 1, 1, 0, 0, 0, get_member(), $member_id); $post_id = ocf_make_post($pt_topic_id, $_title, $message, 0, true, 1, 1, NULL, NULL, NULL, NULL, NULL, NULL, NULL, false); send_pt_notification($post_id, $_title, $pt_topic_id, $member_id); } // Topic silencing $silence_from_topic = post_param_integer('topic_id', NULL); if (!is_null($silence_from_topic)) { $_silence_from_topic = get_input_date('silence_from_topic'); $GLOBALS['SITE_DB']->query_delete('msp', array('member_id' => $member_id, 'specific_permission' => 'submit_lowrange_content', 'the_page' => '', 'module_the_name' => 'topics', 'category_name' => strval($silence_from_topic))); } else { $_silence_from_topic = NULL; } if (!is_null($_silence_from_topic)) { $GLOBALS['SITE_DB']->query_insert('msp', array('active_until' => $_silence_from_topic, 'member_id' => $member_id, 'specific_permission' => 'submit_lowrange_content', 'the_page' => '', 'module_the_name' => 'topics', 'category_name' => strval($silence_from_topic), 'the_value' => '0')); } else { $silence_from_topic = NULL; } // Forum silencing $silence_from_forum = post_param_integer('forum_id', NULL); if (!is_null($silence_from_forum)) { $GLOBALS['SITE_DB']->query_delete('msp', array('member_id' => $member_id, 'specific_permission' => 'submit_lowrange_content', 'the_page' => '', 'module_the_name' => 'forums', 'category_name' => strval($silence_from_forum))); $GLOBALS['SITE_DB']->query_delete('msp', array('member_id' => $member_id, 'specific_permission' => 'submit_midrange_content', 'the_page' => '', 'module_the_name' => 'forums', 'category_name' => strval($silence_from_forum))); $_silence_from_forum = get_input_date('silence_from_forum'); } else { $_silence_from_forum = NULL; } if (!is_null($_silence_from_forum)) { $GLOBALS['SITE_DB']->query_insert('msp', array('active_until' => $_silence_from_forum, 'member_id' => $member_id, 'specific_permission' => 'submit_lowrange_content', 'the_page' => '', 'module_the_name' => 'forums', 'category_name' => strval($silence_from_forum), 'the_value' => '0')); $GLOBALS['SITE_DB']->query_insert('msp', array('active_until' => $_silence_from_forum, 'member_id' => $member_id, 'specific_permission' => 'submit_midrange_content', 'the_page' => '', 'module_the_name' => 'forums', 'category_name' => strval($silence_from_forum), 'the_value' => '0')); } else { $silence_from_forum = NULL; } // Probation $probation = post_param_integer('probation', 0); if (has_specific_permission(get_member(), 'probate_members')) { if ($probation != 0) { $on_probation_until = $GLOBALS['FORUM_DRIVER']->get_member_row_field($member_id, 'm_on_probation_until'); if (is_null($on_probation_until) || $on_probation_until < time()) { $on_probation_until = time(); } $on_probation_until += $probation * 60 * 60 * 24; $GLOBALS['FORUM_DB']->query_update('f_members', array('m_on_probation_until' => $on_probation_until), array('id' => $member_id), '', 1); } } // Ban member if (has_specific_permission(get_member(), 'member_maintenance')) { $banned_member = post_param_integer('banned_member', 0); if ($banned_member == 1) { $GLOBALS['FORUM_DB']->query_update('f_members', array('m_is_perm_banned' => 1), array('id' => $member_id), '', 1); } } else { $banned_member = 0; } // IP ban $banned_ip = ''; if (addon_installed('securitylogging')) { if (has_actual_page_access(get_member(), 'admin_ipban')) { $_banned_ip = post_param_integer('banned_ip', 0); if ($_banned_ip == 1) { $banned_ip = $GLOBALS['FORUM_DRIVER']->get_member_row_field($member_id, 'm_ip_address'); require_code('failure'); add_ip_ban($banned_ip); } } } // Change group $changed_usergroup_from = NULL; if (has_specific_permission(get_member(), 'member_maintenance')) { $__changed_usergroup_from = post_param('changed_usergroup_from'); if ($__changed_usergroup_from == '') { $_changed_usergroup_from = NULL; } else { $_changed_usergroup_from = intval($__changed_usergroup_from); } if (!is_null($_changed_usergroup_from) && $_changed_usergroup_from != -1) { $changed_usergroup_from = $GLOBALS['FORUM_DRIVER']->get_member_row_field($member_id, 'm_primary_group'); $GLOBALS['FORUM_DB']->query_update('f_members', array('m_primary_group' => $_changed_usergroup_from), array('id' => $member_id), '', 1); } } // Prepare to charge points (used in ocf_make_warning) $charged_points = post_param_integer('charged_points', 0); // Make the warning $warning_id = ocf_make_warning($member_id, $explanation, NULL, NULL, post_param_integer('is_warning', 0), $silence_from_topic, $silence_from_forum, $probation, $banned_ip, $charged_points, $banned_member, $changed_usergroup_from); // Charge points if (addon_installed('points')) { if (has_actual_page_access(get_member(), 'admin_points')) { if ($charged_points != 0) { require_code('points2'); charge_member($member_id, $charged_points, do_lang('FOR_PUNISHMENT', strval($warning_id))); } } } return strval($warning_id); }
/** * The UI to show OCF posting rates. * * @param object The stats module object * @param string The screen type * @return tempcode The UI */ function posting_rates($ob, $type) { breadcrumb_set_parents(array(array('_SELF:_SELF:misc', do_lang_tempcode('SITE_STATISTICS')))); require_lang('ocf'); //This will show a plain bar chart with all the downloads listed $title = get_page_title('POSTING_RATES'); // Handle time range if (get_param_integer('dated', 0) == 0) { $title = get_page_title('POSTING_RATES'); $extra_fields = new ocp_tempcode(); require_code('form_templates'); $extra_fields->attach(form_input_tick(do_lang_tempcode('HOURLY_BREAKDOWNS'), do_lang_tempcode('DESCRIPTION_HOURLY_BREAKDOWNS'), 'hourly', false)); return $ob->get_between($title, false, $extra_fields); } $time_start = get_input_date('time_start', true); $time_end = get_input_date('time_end', true); if (!is_null($time_end)) { $time_end += 60 * 60 * 24 - 1; } // So it is end of day not start if (is_null($time_start)) { $time_start = 0; } if (is_null($time_end)) { $time_end = time(); } $title = get_page_title('SECTION_POSTING_RATES_RANGE', true, array(escape_html(get_timezoned_date($time_start, false)), escape_html(get_timezoned_date($time_end, false)))); $poster_exception = ''; foreach (explode(',', get_param('poster_exception', '')) as $e) { if (trim($e) == '') { continue; } $poster_exception .= 'p_poster<>' . strval(intval($e)) . ' AND '; } $csv = get_param_integer('csv', 0) == 1; if ($csv) { $time_start = 0; $time_end = time(); $hourly = false; } $rows = $GLOBALS['FORUM_DB']->query('SELECT p_time FROM ' . $GLOBALS['FORUM_DB']->get_table_prefix() . 'f_posts WHERE ' . $poster_exception . 'p_time>' . strval($time_start) . ' AND p_time<' . strval($time_end)); if (count($rows) < 1) { return warn_screen($title, do_lang_tempcode('NO_DATA')); } $hourly = get_param_integer('hourly', 0) == 1; //($time_end-$time_start)<=60*60*24*2; $iterate_months = floatval($time_end - $time_start) / (60.0 * 60.0 * 24.0) > 100.0; // Gather data $posting_rates = array(); if ($hourly) { for ($i = 0; $i < 24; $i++) { $date = str_pad(strval($i), 2, '0', STR_PAD_LEFT) . ':00'; $posting_rates[$date] = 0; } } else { if ($iterate_months) { $year = intval(date('Y', $time_start)); $month = intval(date('m', $time_start)); while (mktime(0, 0, 0, $month - 1, 0, $year) < $time_end) { $date = date('Y/m', mktime(0, 0, 0, $month, 0, $year)); $posting_rates[$date] = 0; $month++; if ($month == 13) { $month = 1; $year++; } } } else { for ($i = $time_start - 60 * 60 * 12; $i <= $time_end + 60 * 60 * 12; $i += 60 * 60 * 24) { $date = date('Y/m/d', $i); $posting_rates[$date] = 0; } } } foreach ($rows as $row) { if ($hourly) { $date = date('H', $row['p_time']) . ':00'; } else { if ($iterate_months) { $date = date('Y/m', $row['p_time']); } else { $date = date('Y/m/d', $row['p_time']); } } $posting_rates[$date]++; } $start = 0; $max = 1000; // Little trick, as we want all to fit $sortables = array(); require_code('templates_results_table'); $fields_title = results_field_title(array(do_lang_tempcode('DATE'), do_lang_tempcode('COUNT_TOTAL')), $sortables); $fields = new ocp_tempcode(); $real_data = array(); $i = 0; foreach ($posting_rates as $date => $value) { $fields->attach(results_entry(array(escape_html($date), escape_html(integer_format($value))))); $real_data[] = array('Date/Time' => $date, 'Tally' => $value); $i++; } $list = results_table(do_lang_tempcode('POSTING_RATES'), $start, 'start', $max, 'max', count($posting_rates), $fields_title, $fields, $sortables, '', '', 'sort', new ocp_tempcode()); if ($csv) { make_csv($real_data, 'posting_rates.csv'); } $output = create_bar_chart($posting_rates, do_lang('DATE'), do_lang('COUNT_TOTAL'), '', ''); $ob->save_graph('Global-Posting_rates', $output); $graph = do_template('STATS_GRAPH', array('GRAPH' => get_custom_base_url() . '/data_custom/modules/admin_stats/Global-Posting_rates.xml', 'TITLE' => do_lang_tempcode('POSTING_RATES'), 'TEXT' => do_lang_tempcode('DESCRIPTION_POSTING_RATES'))); return do_template('STATS_SCREEN', array('TITLE' => $title, 'GRAPH' => $graph, 'STATS' => $list)); }
/** * The UI to show OCF demographics. * * @param object The stats module object * @param string The screen type * @return tempcode The UI */ function demographics($ob, $type) { breadcrumb_set_parents(array(array('_SELF:_SELF:misc', do_lang_tempcode('SITE_STATISTICS')))); require_lang('ocf'); //This will show a plain bar chart with all the downloads listed $title = get_page_title('DEMOGRAPHICS'); // Handle time range if (get_param_integer('dated', 0) == 0) { $title = get_page_title('DEMOGRAPHICS'); return $ob->get_between($title, false, NULL, do_lang_tempcode('DEMOGRAPHICS_STATS_RANGE')); } $time_start = get_input_date('time_start', true); $time_end = get_input_date('time_end', true); if (!is_null($time_end)) { $time_end += 60 * 60 * 24 - 1; } // So it is end of day not start if (is_null($time_start) && is_null($time_end)) { $rows = $GLOBALS['FORUM_DB']->query_select('f_members', array('m_dob_year', 'COUNT(*) AS cnt', NULL, 'GROUP BY m_dob_year')); } else { if (is_null($time_start)) { $time_start = 0; } if (is_null($time_end)) { $time_end = time(); } $title = get_page_title('SECTION_DEMOGRAPHICS_RANGE', true, array(escape_html(get_timezoned_date($time_start, false)), escape_html(get_timezoned_date($time_end, false)))); $rows = $GLOBALS['FORUM_DB']->query('SELECT m_dob_year,COUNT(*) AS cnt FROM ' . $GLOBALS['FORUM_DB']->get_table_prefix() . 'f_members WHERE m_join_time>' . strval($time_start) . ' AND m_join_time<' . strval($time_end) . ' GROUP BY m_dob_year'); } if (count($rows) < 1) { return warn_screen($title, do_lang_tempcode('NO_DATA')); } // Gather data $demographics = array(); $demographics[do_lang('UNKNOWN')] = 0; for ($i = 0; $i < 30; $i++) { $demographics[strval($i)] = 0; } for ($i = 30; $i < 100; $i += 5) { $demographics[strval($i) . '-' . strval($i + 4)] = 0; } $demographics['100+'] = 0; list($current_day, $current_month, $current_year) = explode(' ', date('j m Y', utctime_to_usertime(time()))); foreach ($rows as $i => $row) { $day = 1; $month = 1; $year = $row['m_dob_year']; if (!is_null($year)) { $age = intval($current_year) - $year; if ($age < 0) { $age = 0; } if ($age >= 100) { $age_string = '100+'; } elseif ($age >= 30) { $age_string = strval(intval($age / 5) * 5) . '-' . strval(intval($age / 5) * 5 + 4); } else { $age_string = strval($age); } $demographics[$age_string] += array_key_exists('cnt', $row) ? $row['cnt'] : 1; } else { $demographics[do_lang('UNKNOWN')] += array_key_exists('cnt', $row) ? $row['cnt'] : 1; } } $start = 0; $max = 1000; // Little trick, as we want all to fit $sortables = array(); require_code('templates_results_table'); $fields_title = results_field_title(array(do_lang_tempcode('AGE'), do_lang_tempcode('COUNT_TOTAL')), $sortables); $fields = new ocp_tempcode(); $i = 0; foreach ($demographics as $_age => $value) { if (is_integer($_age)) { $_age = strval($_age); } $percent = round(100.0 * floatval($value) / floatval(count($rows)), 2); $fields->attach(results_entry(array(escape_html($_age), escape_html(integer_format($value) . ' (' . float_format($percent) . '%)')))); $i++; } $list = results_table(do_lang_tempcode('DEMOGRAPHICS'), $start, 'start', $max, 'max', count($demographics), $fields_title, $fields, $sortables, '', '', 'sort', new ocp_tempcode()); $output = create_bar_chart($demographics, do_lang('AGE'), do_lang('COUNT_TOTAL'), '', ''); $ob->save_graph('Global-Demographics', $output); $graph = do_template('STATS_GRAPH', array('GRAPH' => get_custom_base_url() . '/data_custom/modules/admin_stats/Global-Demographics.xml', 'TITLE' => do_lang_tempcode('DEMOGRAPHICS'), 'TEXT' => do_lang_tempcode('DESCRIPTION_DEMOGRAPHICS'))); return do_template('STATS_SCREEN', array('TITLE' => $title, 'NO_CSV' => '1', 'GRAPH' => $graph, 'STATS' => $list)); }
/** * Read settings the user has chosen, from the POST environment. * * @param array Details of the particular bookable. * @return array Tuple of details: number wanted, date from, date to). */ function _read_chosen_bookable_settings($bookable) { $quantity = post_param_integer('bookable_' . strval($bookable['id']) . '_quantity', 0); $date_from = get_input_date('bookable_' . strval($bookable['id']) . '_date_from'); if (is_null($date_from)) { $date_from = get_input_date('bookable_date_from'); } // allow to be specified for whole form (the norm actually) if (is_null($date_from)) { $date_from = time(); } $date_to = get_input_date('bookable_' . strval($bookable['id']) . '_date_to'); if (is_null($date_to)) { $date_to = get_input_date('bookable_date_to'); } // allow to be specified for whole form (the norm actually); may still be null, if ranges not being used if (is_null($date_to)) { $date_to = $date_from; } return array($quantity, $date_from, $date_to); }
/** * Standard aed_module edit actualiser. * * @param ID_TEXT The entry being edited */ function edit_actualisation($id) { $orig_submitter = $GLOBALS['SITE_DB']->query_value_null_ok('banners', 'submitter', array('name' => $id)); if (is_null($orig_submitter)) { warn_exit(do_lang_tempcode('MISSING_RESOURCE')); } $b_type = post_param('b_type'); $title_text = post_param('title_text', ''); $b_type = post_param('b_type'); $this->donext_type = $b_type; list($url, $title_text) = check_banner($title_text, $b_type); $validated = post_param_integer('validated', 0); $_submitter = post_param('submitter', strval(get_member())); $submitter = !is_numeric($_submitter) ? $GLOBALS['FORUM_DRIVER']->get_member_from_username($_submitter) : intval($_submitter); edit_banner($id, post_param('name'), $url, $title_text, post_param('caption'), post_param_integer('campaignremaining', 0), fixup_protocolless_urls(post_param('site_url')), post_param_integer('importancemodulus'), post_param('notes', ''), post_param_integer('the_type', 1), get_input_date('expiry_date'), $submitter, $validated, $b_type); $this->new_id = post_param('name'); if (get_option('use_banner_permissions') == '1') { $this->set_permissions($id); } }
/** * Standard aed_module edit actualiser. * * @param ID_TEXT The entry being edited */ function edit_actualisation($_id) { $id = intval($_id); $open_time = get_input_date('open_time'); $close_time = get_input_date('close_time'); $_tied_newsletter = post_param('tied_newsletter', ''); $tied_newsletter = $_tied_newsletter == '' ? NULL : intval($_tied_newsletter); $name = post_param('name'); $validated = post_param_integer('validated', 0); if ($validated == 1 && $GLOBALS['SITE_DB']->query_value('quizzes', 'q_validated', array('id' => $id)) == 0) { $submitter = $GLOBALS['SITE_DB']->query_value('quizzes', 'q_submitter', array('id' => $id)); if (has_actual_page_access($GLOBALS['FORUM_DRIVER']->get_guest_id(), 'quiz')) { syndicate_described_activity($submitter != get_member() ? 'quiz:ACTIVITY_VALIDATE_QUIZ' : 'quiz:ACTIVITY_ADD_QUIZ', $name, '', '', '_SEARCH:quiz:do:' . strval($id), '', '', 'quizzes', 1, NULL); } } edit_quiz($id, $name, post_param_integer('timeout', NULL), post_param('start_text'), post_param('end_text'), post_param('end_text_fail'), post_param('notes', ''), post_param_integer('percentage', 0), $open_time, $close_time, post_param_integer('num_winners', 0), post_param_integer('redo_time', NULL), post_param('type'), $validated, post_param('text'), post_param('meta_keywords', ''), post_param('meta_description', ''), post_param_integer('points_for_passing', 0), $tied_newsletter); }
/** * The actualiser to send a newsletter. * * @return tempcode The UI */ function send_message() { $title = get_page_title('NEWSLETTER_SEND'); $lang = choose_language($title); if (is_object($lang)) { return $lang; } if (get_param('old_type', '') == 'whatsnew') { set_value('newsletter_whatsnew', strval(time())); } $message = post_param('message'); $subject = post_param('subject'); $csv_data = post_param('csv_data', ''); // serialized PHP array $template = post_param('template', 'MAIL'); $in_full = post_param_integer('in_full', 0); $html_only = post_param_integer('html_only', 0); $from_email = post_param('from_email', ''); $from_name = post_param('from_name', ''); $priority = post_param_integer('priority', 3); $newsletters = $GLOBALS['SITE_DB']->query_select('newsletters', array('id')); $send_details = array(); foreach ($newsletters as $newsletter) { $send_details[strval($newsletter['id'])] = post_param_integer(strval($newsletter['id']), 0); } if (get_forum_type() == 'ocf') { $groups = $GLOBALS['FORUM_DRIVER']->get_usergroup_list(); foreach (array_keys($groups) as $id) { $send_details['g' . strval($id)] = post_param_integer('g' . strval($id), 0); } $send_details['-1'] = post_param_integer('-1', 0); } if (post_param_integer('make_periodic', 0) == 1) { // We're a periodic newsletter, so we don't actually want to be sent // out now. Rather, we store the newsletter settings so that it can be // regenerated as needed. // Next we store all of our settings in the newsletter_periodic table $when = post_param('periodic_when'); $day = 1; if ($when == 'monthly') { $day = post_param_integer('periodic_monthly') % 29; } elseif ($when == 'biweekly') { $day = post_param_integer('periodic_weekday_biweekly', 5); } elseif ($when == 'weekly') { $day = post_param_integer('periodic_weekday_weekly', 5); } $map = array('np_message' => post_param('chosen_categories', ''), 'np_subject' => $subject, 'np_lang' => $lang, 'np_send_details' => serialize($send_details), 'np_html_only' => $html_only, 'np_from_email' => $from_email, 'np_from_name' => $from_name, 'np_priority' => $priority, 'np_csv_data' => $csv_data, 'np_frequency' => $when, 'np_day' => $day, 'np_in_full' => $in_full, 'np_template' => $template); require_lang('dates'); $week_days = array(1 => do_lang('MONDAY'), 2 => do_lang('TUESDAY'), 3 => do_lang('WEDNESDAY'), 4 => do_lang('THURSDAY'), 5 => do_lang('FRIDAY'), 6 => do_lang('SATURDAY'), 7 => do_lang('SUNDAY')); if ($when == 'weekly') { $each = $week_days[$day]; } elseif ($when == 'biweekly') { $each = $week_days[$day]; } else { $suffix = gmdate('S', gmmktime(0, 0, 0, 1, $day, 1990)); $each = strval($day) . $suffix; } $matches = array(); if (preg_match('#^replace_existing\\_(\\d+)$#', post_param('periodic_choice', ''), $matches) != 0) { if (post_param('periodic_for') != 'future') { $map['np_last_sent'] = 0; } $GLOBALS['SITE_DB']->query_update('newsletter_periodic', $map, array('id' => intval($matches[1])), '', 1); $message = do_lang('PERIODIC_SUCCESS_MESSAGE_EDIT', $when, $each); } else { $last_sent = post_param('periodic_for') == 'future' ? time() : 0; $map['np_last_sent'] = $last_sent; $GLOBALS['SITE_DB']->query_insert('newsletter_periodic', $map, true); $message = do_lang('PERIODIC_SUCCESS_MESSAGE_ADD', $when, $each); } $url = build_url(array('page' => 'admin_newsletter', 'type' => 'misc', 'redirected' => '1'), get_module_zone('admin_newsletter')); return redirect_screen(do_lang('SUCCESS'), $url, $message, false, 'inform'); } if (addon_installed('calendar')) { $schedule = get_input_date('schedule'); if (!is_null($schedule)) { require_code('calendar'); require_code('calendar2'); $send_details_string_exp = ''; foreach ($send_details as $key => $val) { $send_details_string_exp .= '"' . str_replace(chr(10), '\\n', addslashes($key)) . '"=>"' . str_replace(chr(10), '\\n', addslashes($val)) . '",'; } $schedule_code = ':require_code(\'newsletter\'); actual_send_newsletter("' . php_addslashes($message) . '","' . php_addslashes($subject) . '","' . php_addslashes($lang) . '",array(' . $send_details_string_exp . '),' . strval($html_only) . ',"' . php_addslashes($from_email) . '","' . php_addslashes($from_name) . '",' . strval($priority) . ',"' . php_addslashes($template) . '");'; $start_year = post_param_integer('schedule_year'); $start_month = post_param_integer('schedule_month'); $start_day = post_param_integer('schedule_day'); $start_hour = post_param_integer('schedule_hour'); $start_minute = post_param_integer('schedule_minute'); $event_id = add_calendar_event(db_get_first_id(), '', NULL, 0, do_lang('NEWSLETTER_SEND', $subject), $schedule_code, 3, 0, $start_year, $start_month, $start_day, $start_hour, $start_minute); regenerate_event_reminder_jobs($event_id); return inform_screen($title, do_lang_tempcode('NEWSLETTER_DEFERRED', get_timezoned_date($schedule))); } } actual_send_newsletter($message, $subject, $lang, $send_details, $html_only, $from_email, $from_name, $priority, $csv_data, $template); breadcrumb_set_parents(array(array('_SELF:_SELF:misc', do_lang_tempcode('MANAGE_NEWSLETTER')), array('_SELF:_SELF:new', do_lang_tempcode('NEWSLETTER_SEND')))); breadcrumb_set_self(do_lang_tempcode('DONE')); return inform_screen($title, do_lang_tempcode('SENDING_NEWSLETTER')); }
/** * The actualiser to download chat logs. * * @return tempcode The UI */ function _chat_download_logs() { $title = get_page_title('CHAT_DOWNLOAD_LOGS'); $start_date_and_time = get_input_date('start', true); $finish_date_and_time = get_input_date('finish', true); $room = get_param_integer('room_name'); // We have the messages, now we have to create a nice little text file... $keep = symbol_tempcode('KEEP'); $modlink = find_script('dllogs') . '?room=' . strval($room) . '&start=' . strval($start_date_and_time) . '&finish=' . strval($finish_date_and_time) . '&zone=' . get_zone_name() . $keep->evaluate(); //$modlink=hyperlink($modlink,do_lang_tempcode('CHAT_DOWNLOAD_LOGS')); //return do_template('CHAT_SCREEN',array('_GUID'=>'18dd8ecf06301add0f44bdaf801fbdca','TITLE'=>$title,'INTRODUCTION'=>'','CONTENT'=>$modlink,'LINKS'=>array())); require_code('site2'); assign_refresh($modlink, 0.0); return do_template('REDIRECT_SCREEN', array('_GUID' => '227be0596e721d4cbab81b707b6d6ba1', 'URL' => $modlink, 'TITLE' => $title, 'TEXT' => do_lang_tempcode('REDIRECTING'))); }
/** * Show value statistics for a custom profile field (show). * * @return tempcode The statistics */ function _stats() { $title = get_page_title('CUSTOM_PROFILE_FIELD_STATS'); breadcrumb_set_parents(array()); $f_name = 'field_' . strval(get_param_integer('id')); $_a = get_input_date('start'); $a = is_null($_a) ? '1=1' : 'm_join_time>' . strval((int) $_a); $_b = get_input_date('end'); $b = is_null($_b) ? '1=1' : 'm_join_time<' . strval((int) $_b); $members_in_range = $GLOBALS['FORUM_DB']->query('SELECT ' . $f_name . ',COUNT(' . $f_name . ') AS cnt FROM ' . $GLOBALS['FORUM_DB']->get_table_prefix() . 'f_members m LEFT JOIN ' . $GLOBALS['FORUM_DB']->get_table_prefix() . 'f_member_custom_fields f ON m.id=f.mf_member_id WHERE ' . $a . ' AND ' . $b . ' GROUP BY ' . $f_name . ' ORDER BY cnt', 300); if (count($members_in_range) == 300) { attach_message(do_lang_tempcode('TOO_MUCH_CHOOSE__TOP_ONLY', escape_html(integer_format(300))), 'warn'); } $lines = new ocp_tempcode(); foreach ($members_in_range as $row) { if (!is_null($row[$f_name])) { $val = $row[$f_name]; if ($val == STRING_MAGIC_NULL) { continue; } $lines->attach(do_template('OCF_CPF_STATS_LINE', array('CNT' => integer_format($row['cnt']), 'VAL' => is_integer($val) ? integer_format($val) : $val))); } } if ($lines->is_empty()) { warn_exit(do_lang_tempcode('NO_DATA')); } return do_template('OCF_CPF_STATS_SCREEN', array('_GUID' => 'bb7be7acf936cd008e16bd515f7f39ac', 'TITLE' => $title, 'STATS' => $lines)); }
/** * The UI to show page view statistics. * * @return tempcode The UI */ function page_stats() { //This will show a plain bar chart with all the pages listed // Handle time range if (get_param_integer('dated', 0) == 0) { $title = get_page_title('PAGES_STATISTICS'); return $this->get_between($title, true); } $time_start = get_input_date('time_start', true); $time_end = get_input_date('time_end', true); if (!is_null($time_end)) { $time_end += 60 * 60 * 24 - 1; } // So it is end of day not start if (is_null($time_start)) { $time_start = 0; } if (is_null($time_end)) { $time_end = time(); } $first_stat = $GLOBALS['SITE_DB']->query_value_null_ok('stats', 'MIN(date_and_time)'); if ($time_end < $first_stat) { warn_exit(do_lang_tempcode('NO_DATA_SPECIFIC')); } $start = get_param_integer('start', 0); $max = get_param_integer('max', 30); $csv = get_param_integer('csv', 0) == 1; if ($csv) { if (function_exists('set_time_limit')) { @set_time_limit(0); } $start = 0; $max = 10000; /*$time_start=0; Actually, this is annoying. We have legitimate reason to filter, and cannot re-filter the data in Excel retro-actively $time_end=time();*/ } $title = get_page_title('PAGES_STATISTICS_RANGE', true, array(escape_html(get_timezoned_date($time_start, false)), escape_html(get_timezoned_date($time_end, false)))); $rows = $GLOBALS['SITE_DB']->query_select('stats', array('the_page'), NULL, 'GROUP BY the_page ORDER BY COUNT(*) DESC', 3000); if (count($rows) < 1) { return warn_screen($title, do_lang_tempcode('NO_DATA')); } $views = array(do_lang('_ALL') => 0); $total = 0; foreach ($rows as $row) { $page = $row['the_page']; $matches = array(); if (preg_match('#^/?([^/]+)/pages/([^/]+)/(\\w\\w/)?([^/\\.]+)\\.(php|txt|htm)$#', $page, $matches) == 1 && $matches[4] == 'catalogues' && addon_installed('catalogues') && $GLOBALS['SITE_DB']->query_value('catalogue_categories', 'COUNT(*)', NULL, '', true) < 300) { require_lang('catalogues'); $categories = $GLOBALS['SITE_DB']->query_select('catalogue_categories', array('id', 'cc_title'), NULL, '', NULL, NULL, true); foreach ($categories as $cat) { $where = db_string_equal_to('the_page', $page); if (substr($page, 0, 6) == 'pages/') { $where .= ' OR ' . db_string_equal_to('the_page', '/' . $page); } // Legacy compatibility $count = $GLOBALS['SITE_DB']->query_value_null_ok_full('SELECT COUNT(*) FROM ' . $GLOBALS['SITE_DB']->get_table_prefix() . 'stats WHERE (' . $where . ') AND s_get LIKE \'' . db_encode_like('<param>page=catalogues</param>\\n<param>type=category</param>\\n<param>id=' . strval($cat['id']) . '</param>%') . '\' AND date_and_time>' . strval((int) $time_start) . ' AND date_and_time<' . strval((int) $time_end)); $views[do_lang('CATALOGUE_CATEGORY') . ': ' . get_translated_text($cat['cc_title'])] = array($count, $page); $total += $count; } continue; } else { $page2 = page_path_to_pagelink($page); if ($page2 == '') { $page2 = $page; } } $where = db_string_equal_to('the_page', $page); if (substr($page, 0, 6) == 'pages/') { $where .= ' OR ' . db_string_equal_to('the_page', '/' . $page); } // Legacy compatibility $views[$page2] = array($GLOBALS['SITE_DB']->query_value_null_ok_full('SELECT COUNT(*) FROM ' . $GLOBALS['SITE_DB']->get_table_prefix() . 'stats WHERE (' . $where . ') AND date_and_time>' . strval((int) $time_start) . ' AND date_and_time<' . strval((int) $time_end)), $page); $total += $views[$page2][0]; } $views[do_lang('_ALL')] = array($total, NULL); $sortables = array('views' => do_lang_tempcode('COUNT_VIEWS')); $test = explode(' ', get_param('sort', 'views DESC'), 2); if (count($test) == 1) { $test[1] = 'DESC'; } list($sortable, $sort_order) = $test; if (strtoupper($sort_order) != 'ASC' && strtoupper($sort_order) != 'DESC' || !array_key_exists($sortable, $sortables)) { log_hack_attack_and_exit('ORDERBY_HACK'); } global $NON_CANONICAL_PARAMS; $NON_CANONICAL_PARAMS[] = 'sort'; global $M_SORT_KEY; $M_SORT_KEY = 0; uasort($views, 'multi_sort'); if ($sort_order == 'DESC') { $views = array_reverse($views, true); } require_code('templates_results_table'); $fields_title = results_field_title(array(do_lang_tempcode('URL'), do_lang_tempcode('COUNT_VIEWS')), $sortables, 'sort', $sortable . ' ' . $sort_order); $fields = new ocp_tempcode(); $i = 0; $real_data = array(); foreach ($views as $url => $_value) { if ($i < $start) { $i++; continue; } elseif ($i >= $start + $max) { break; } list($value, $page) = $_value; $real_data[] = array('Page/URL' => is_null($page) ? $url : $page, 'Tally' => $value); $fields->attach(results_entry(array(is_null($page) ? make_string_tempcode(escape_html($url)) : hyperlink(build_url(array('page' => '_SELF', 'type' => '_page', 'iscreen' => $page), '_SELF'), escape_html($url)), escape_html(integer_format($value))))); $i++; } unset($views['(' . do_lang('ALL') . ')']); $list = results_table(do_lang_tempcode('PAGES_STATISTICS'), $start, 'start', $max, 'max', count($views), $fields_title, $fields, $sortables, $sortable, $sort_order, 'sort', new ocp_tempcode()); if ($csv) { make_csv($real_data, 'page_stats.csv'); } $output = create_bar_chart(array_slice($views, $start, $max), do_lang('PAGE'), do_lang('COUNT_VIEWS'), '', ''); $this->save_graph('Global-Views', $output); $graph = do_template('STATS_GRAPH', array('_GUID' => 'ea79fdc013046ef94992daeab961f2da', 'GRAPH' => get_custom_base_url() . '/data_custom/modules/admin_stats/Global-Views.xml', 'TITLE' => do_lang_tempcode('PAGES_STATISTICS'), 'TEXT' => do_lang_tempcode('DESCRIPTION_PAGES_STATISTICS'))); breadcrumb_set_parents(array(array('_SELF:_SELF:misc', do_lang_tempcode('SITE_STATISTICS')))); return do_template('STATS_SCREEN', array('_GUID' => 'cfe7d5aee8aa3c0d3a54bd3bf2d09e7f', 'TITLE' => $title, 'GRAPH' => $graph, 'STATS' => $list)); }
/** * Actulizer to build csv from the selected filters * * @param boolean Whether to avoid exit (useful for unit test). */ function _order_export($inline = false) { require_code('shopping'); $start_date = get_input_date('start_date', true); $end_date = get_input_date('end_date', true); $order_status = post_param('order_status'); $filename = 'Orders_' . $order_status . '__' . get_timezoned_date($start_date, false, false, false, true) . '-' . get_timezoned_date($end_date, false, false, false, true) . '.csv'; $orders = array(); $data = array(); $cond = "t1.add_date BETWEEN " . strval($start_date) . " AND " . strval($end_date); if ($order_status != 'all') { $cond .= " AND t1.order_status='" . db_escape_string($order_status) . "'"; } $qry = "SELECT t1.*,(t2.included_tax*t2.p_quantity) as \t\n\t\t\t\t\t\t\t\ttax_amt,t3.address_name,t3.address_street,t3.address_city,t3.address_zip,\n\t\t\t\t\t\t\t\tt3.address_country,t3.receiver_email\n\t\t\t\t\t\t\t\tFROM " . get_table_prefix() . "shopping_order t1\n\t\t\t\t\t\t\t\tLEFT JOIN " . get_table_prefix() . "shopping_order_details t2 ON t1.id = t2.order_id\n\t\t\t\t\t\t\t\tLEFT JOIN " . get_table_prefix() . "shopping_order_addresses t3 ON t1.id = t3.order_id\n\t\t\t\t\t\t\t\tWHERE " . $cond; $row = $GLOBALS['SITE_DB']->query($qry); remove_duplicate_rows($row); foreach ($row as $order) { $orders[do_lang('ORDER_NUMBER')] = strval($order['id']); $orders[do_lang('ORDERED_DATE')] = get_timezoned_date($order['add_date'], true, false, true, true); $orders[do_lang('ORDER_PRICE')] = $order['tot_price']; $orders[do_lang('ORDER_STATUS')] = do_lang($order['order_status']); $orders[do_lang('ORDER_TAX_OPT_OUT')] = $order['tax_opted_out'] ? do_lang('YES') : do_lang('NO'); $orders[do_lang('TOTAL_TAX_PAID')] = is_null($order['tax_amt']) ? float_format(0.0, 2) : float_format($order['tax_amt'], 2); $orders[do_lang('ORDERED_PRODUCTS')] = get_ordered_product_list_string($order['id']); $orders[do_lang('ORDERED_BY')] = $GLOBALS['FORUM_DRIVER']->get_username($order['c_member']); $address = array(); $address['name'] = array_key_exists('address_name', $order) ? $order['address_name'] : NULL; $address['city'] = array_key_exists('address_city', $order) ? $order['address_city'] : NULL; $address['zip'] = array_key_exists('address_zip', $order) ? $order['address_zip'] : NULL; $address['country'] = array_key_exists('address_country', $order) ? $order['address_country'] : NULL; if (!is_null($address['name'])) { $full_address = implode(chr(10), $address); } else { $full_address = ""; } $orders[do_lang('FULL_ADDRESS')] = $full_address; $data[] = $orders; } require_code('files2'); make_csv($data, $filename, !$inline, !$inline); }
/** * Read blacked details from POST environment. * * @return array Tuple: Blacked details, list of bookables. */ function get_bookable_blacked_details_from_form() { if (!isset($_POST['bookables'])) { $_POST['bookables'] = array(); } $bookables = array_map('intval', $_POST['bookables']); $blacked_from = get_input_date('blacked_from'); $blacked_to = get_input_date('blacked_to'); if ($blacked_to < $blacked_from) { warn_exit(do_lang_tempcode('DATE_AROUND')); } return array(array('blacked_from_day' => intval(date('d', $blacked_from)), 'blacked_from_month' => intval(date('m', $blacked_from)), 'blacked_from_year' => intval(date('Y', $blacked_from)), 'blacked_to_day' => intval(date('d', $blacked_to)), 'blacked_to_month' => intval(date('m', $blacked_to)), 'blacked_to_year' => intval(date('Y', $blacked_to)), 'blacked_explanation' => post_param('blacked_explanation')), $bookables); }