Esempio n. 1
0
/**
 * Get a results table showing security alerts matching WHERE constraints.
 *
 * @param  ?array			WHERE constraints (NULL: none)
 * @return tempcode		The results table
 */
function find_security_alerts($where)
{
    // Alerts
    $start = get_param_integer('alert_start', 0);
    $max = get_param_integer('alert_max', 50);
    $sortables = array('date_and_time' => do_lang_tempcode('DATE_TIME'), 'ip' => do_lang_tempcode('IP_ADDRESS'));
    $test = explode(' ', get_param('alert_sort', 'date_and_time DESC'));
    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[] = 'alert_sort';
    $_fields = array(do_lang_tempcode('FROM'), do_lang_tempcode('DATE_TIME'), do_lang_tempcode('IP_ADDRESS'), do_lang_tempcode('REASON'));
    if (has_js()) {
        $_fields[] = new ocp_tempcode();
    }
    $fields_title = results_field_title($_fields, $sortables, 'alert_sort', $sortable . ' ' . $sort_order);
    $max_rows = $GLOBALS['SITE_DB']->query_value('hackattack', 'COUNT(*)', $where);
    $rows = $GLOBALS['SITE_DB']->query_select('hackattack', array('*'), $where, 'ORDER BY ' . $sortable . ' ' . $sort_order, $max, $start);
    $fields = new ocp_tempcode();
    foreach ($rows as $row) {
        $time = get_timezoned_date($row['date_and_time']);
        $lookup_url = build_url(array('page' => 'admin_lookup', 'param' => $row['ip']), '_SELF');
        $member_url = build_url(array('page' => 'admin_lookup', 'param' => $row['the_user']), '_SELF');
        $full_url = build_url(array('page' => 'admin_security', 'type' => 'view', 'id' => $row['id']), '_SELF');
        $reason = do_lang($row['reason'], $row['reason_param_a'], $row['reason_param_b'], NULL, NULL, false);
        if (is_null($reason)) {
            $reason = $row['reason'];
        }
        $reason = symbol_truncator(array($reason, '50', '1'), 'left');
        $username = $GLOBALS['FORUM_DRIVER']->get_username($row['the_user']);
        if (is_null($username)) {
            $username = do_lang('UNKNOWN');
        }
        $_row = array(hyperlink($member_url, escape_html($username)), hyperlink($full_url, escape_html($time)), hyperlink($lookup_url, escape_html($row['ip'])), $reason);
        if (has_js()) {
            $deletion_tick = do_template('RESULTS_TABLE_TICK', array('ID' => strval($row['id'])));
            $_row[] = $deletion_tick;
        }
        $fields->attach(results_entry($_row));
    }
    return results_table(do_lang_tempcode('SECURITY_ALERTS'), $start, 'alert_start', $max, 'alert_max', $max_rows, $fields_title, $fields, $sortables, $sortable, $sort_order, 'alert_sort');
}
 /**
  * Standard aed_module table function.
  *
  * @param  array			Details to go to build_url for link to the next screen.
  * @return array			A quartet: The choose table, Whether re-ordering is supported from this screen, Search URL, Archive URL.
  */
 function nice_get_choose_table($url_map)
 {
     require_code('templates_results_table');
     $current_ordering = get_param('sort', 'c_title ASC', true);
     if (strpos($current_ordering, ' ') === false) {
         warn_exit(do_lang_tempcode('INTERNAL_ERROR'));
     }
     list($sortable, $sort_order) = explode(' ', $current_ordering, 2);
     $sortables = array('c_title' => do_lang_tempcode('TITLE'));
     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';
     $header_row = results_field_title(array(do_lang_tempcode('TITLE'), do_lang_tempcode('EXPANDED_BY_DEFAULT'), do_lang_tempcode('ACTIONS')), $sortables, 'sort', $sortable . ' ' . $sort_order);
     $fields = new ocp_tempcode();
     require_code('form_templates');
     list($rows, $max_rows) = $this->get_entry_rows(false, $current_ordering);
     foreach ($rows as $row) {
         $edit_link = build_url($url_map + array('id' => $row['id']), '_SELF');
         $fields->attach(results_entry(array($row['c_title'], $row['c_expanded_by_default'] == 1 ? do_lang_tempcode('YES') : do_lang_tempcode('NO'), protect_from_escaping(hyperlink($edit_link, do_lang_tempcode('EDIT'), false, true, '#' . strval($row['id'])))), true));
     }
     $search_url = NULL;
     $archive_url = NULL;
     return array(results_table(do_lang($this->menu_label), get_param_integer('start', 0), 'start', either_param_integer('max', 20), 'max', $max_rows, $header_row, $fields, $sortables, $sortable, $sort_order), false, $search_url, $archive_url);
 }
Esempio n. 3
0
/**
 * Show the point transactions a member has had.
 *
 * @param  ID_TEXT		The type of transactions we are looking for
 * @set    from to
 * @param  MEMBER			Who we are looking at transactions for
 * @param  MEMBER			Who we are looking at transactions using the account of
 * @return tempcode		The UI
 */
function points_get_transactions($type, $member_id_of, $member_id_viewing)
{
    $where = array('gift_' . $type => $member_id_of);
    if ($type == 'from') {
        $where['anonymous'] = 0;
    }
    $start = get_param_integer('gift_start_' . $type, 0);
    $max = get_param_integer('gift_max_' . $type, 10);
    $sortables = array('date_and_time' => do_lang_tempcode('DATE'), 'amount' => do_lang_tempcode('AMOUNT'));
    $test = explode(' ', get_param('gift_sort_' . $type, 'date_and_time DESC'));
    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[] = 'gift_sort_' . $type;
    $NON_CANONICAL_PARAMS[] = 'gift_start_' . $type;
    $max_rows = $GLOBALS['SITE_DB']->query_value('gifts', 'COUNT(*)', $where);
    $rows = $GLOBALS['SITE_DB']->query_select('gifts g LEFT JOIN ' . $GLOBALS['SITE_DB']->get_table_prefix() . 'translate t ON ' . db_string_equal_to('language', user_lang()) . ' AND t.id=g.reason', array('*'), $where, 'ORDER BY ' . $sortable . ' ' . $sort_order, $max, $start);
    $out = new ocp_tempcode();
    $viewing_name = $GLOBALS['FORUM_DRIVER']->get_username($member_id_of);
    if (is_null($viewing_name)) {
        $viewing_name = do_lang('UNKNOWN');
    }
    require_code('templates_results_table');
    $fields_title = results_field_title(array(do_lang_tempcode('DATE'), do_lang_tempcode('AMOUNT'), do_lang_tempcode('FROM'), do_lang_tempcode('TO'), do_lang_tempcode('REASON')), $sortables, 'gift_sort_' . $type, $sortable . ' ' . $sort_order);
    foreach ($rows as $myrow) {
        if ($myrow['anonymous'] == 1 && $type == 'from') {
            continue;
        }
        // Their name
        $fromname = is_guest($myrow['gift_from']) ? get_site_name() : $GLOBALS['FORUM_DRIVER']->get_username($myrow['gift_from']);
        $toname = $GLOBALS['FORUM_DRIVER']->get_username($myrow['gift_to']);
        if (is_null($fromname)) {
            $fromname = do_lang('UNKNOWN');
        }
        if ($myrow['anonymous'] == 1 && !is_guest($myrow['gift_from'])) {
            if (!has_specific_permission($member_id_viewing, 'trace_anonymous_gifts')) {
                $_fromname = do_lang_tempcode('ANON');
            } else {
                $_fromname = hyperlink(build_url(array('page' => 'points', 'type' => 'member', 'id' => $myrow['gift_from']), get_module_zone('points')), do_lang_tempcode('ANON'), false, false, escape_html($fromname));
            }
        } else {
            $_fromname = is_guest($myrow['gift_from']) ? make_string_tempcode(escape_html($fromname)) : hyperlink(build_url(array('page' => 'points', 'type' => 'member', 'id' => $myrow['gift_from']), get_module_zone('points')), escape_html($fromname), false, false, do_lang_tempcode('VIEW_POINTS'));
        }
        $_toname = hyperlink(build_url(array('page' => 'points', 'type' => 'member', 'id' => $myrow['gift_to']), get_module_zone('points')), escape_html($toname), false, false, do_lang_tempcode('VIEW_POINTS'));
        $date = get_timezoned_date($myrow['date_and_time']);
        $amount = $myrow['amount'];
        if (get_page_name() != 'search' && array_key_exists('text_parsed', $myrow) && !is_null($myrow['text_parsed']) && $myrow['text_parsed'] != '' && $myrow['reason'] != 0) {
            $reason = new ocp_tempcode();
            if (!$reason->from_assembly($myrow['text_parsed'], true)) {
                $reason = get_translated_tempcode($myrow['reason']);
            }
        } else {
            $reason = get_translated_tempcode($myrow['reason']);
        }
        $out->attach(results_entry(array(escape_html($date), escape_html(integer_format($amount)), $_fromname, $_toname, $reason)));
    }
    $out = results_table(do_lang_tempcode('_POINTS', escape_html($viewing_name)), $start, 'gift_start_' . $type, $max, 'gift_max_' . $type, $max_rows, $fields_title, $out, $sortables, $sortable, $sort_order, 'gift_sort_' . $type, NULL, NULL, NULL, 8, 'gfhfghtrhhjghgfhfgf', false, 'tab__points');
    if ($type == 'to') {
        $title = do_lang_tempcode('POINTS_TO');
    } else {
        $title = do_lang_tempcode('POINTS_FROM');
    }
    return do_template('POINTS_TRANSACTIONS_WRAP', array('_GUID' => 'f19e3eedeb0b8bf398251b24e8389723', 'CONTENT' => $out, 'TITLE' => $title));
}
Esempio n. 4
0
 /**
  * The main user interface for moderating a chat room.
  *
  * @return tempcode	The UI.
  */
 function moderate_chat_room()
 {
     $title = get_page_title('CHAT_MOD_PANEL');
     breadcrumb_set_parents(array(array('_SELF:_SELF:misc', do_lang_tempcode('CHOOSE'))));
     $room_id = get_param_integer('id');
     check_chatroom_access($room_id);
     $room_details = $GLOBALS['SITE_DB']->query_select('chat_rooms', array('*'), array('id' => $room_id), '', 1);
     if (!array_key_exists(0, $room_details)) {
         warn_exit(do_lang_tempcode('MISSING_RESOURCE'));
     }
     $row = $room_details[0];
     $has_mod_access = has_specific_permission(get_member(), 'edit_lowrange_content', 'cms_chat', array('chat', $room_id)) || $row['room_owner'] == get_member() && has_specific_permission(get_member(), 'moderate_my_private_rooms');
     if (!$has_mod_access) {
         access_denied('SPECIFIC_PERMISSION', 'edit_lowrange_content');
     }
     $start = get_param_integer('start', 0);
     $max = get_param_integer('max', 50);
     $sortables = array('date_and_time' => do_lang_tempcode('DATE_TIME'), 'user_id' => do_lang_tempcode('MEMBER'));
     $test = explode(' ', get_param('sort', 'date_and_time 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';
     $max_rows = $GLOBALS['SITE_DB']->query_value('chat_messages', 'COUNT(*)', array('room_id' => $room_id));
     $rows = $GLOBALS['SITE_DB']->query_select('chat_messages', array('*'), array('room_id' => $room_id), 'ORDER BY ' . $sortable . ' ' . $sort_order, $max, $start);
     $fields = new ocp_tempcode();
     require_code('templates_results_table');
     $array = array(do_lang_tempcode('MEMBER'), do_lang_tempcode('DATE_TIME'), do_lang_tempcode('MESSAGE'));
     if (has_js()) {
         $array[] = do_lang_tempcode('DELETE');
     }
     $fields_title = results_field_title($array, $sortables, 'sort', $sortable . ' ' . $sort_order);
     foreach ($rows as $myrow) {
         $url = build_url(array('page' => '_SELF', 'type' => 'ed', 'room_id' => $room_id, 'id' => $myrow['id']), '_SELF');
         $username = $GLOBALS['FORUM_DRIVER']->get_username($myrow['user_id']);
         if (is_null($username)) {
             $username = '';
         }
         //do_lang('UNKNOWN');
         $message = get_translated_tempcode($myrow['the_message']);
         $link_time = hyperlink($url, escape_html(get_timezoned_date($myrow['date_and_time'])));
         $_row = array($GLOBALS['FORUM_DRIVER']->member_profile_hyperlink($GLOBALS['FORUM_DRIVER']->get_member_from_username($username), false, $username), escape_html($link_time), $message);
         if (has_js()) {
             $deletion_tick = do_template('RESULTS_TABLE_TICK', array('ID' => strval($myrow['id'])));
             $_row[] = $deletion_tick;
         }
         $fields->attach(results_entry($_row));
     }
     if ($fields->is_empty()) {
         if ($start != 0) {
             $_GET['start'] = strval(max(0, $start - $max));
             return $this->moderate_chat_room();
         }
         inform_exit(do_lang_tempcode('NO_ENTRIES'));
     }
     $content = results_table(do_lang_tempcode('MESSAGES'), $start, 'start', $max, 'max', $max_rows, $fields_title, $fields, $sortables, $sortable, $sort_order, 'sort');
     $mod_link = hyperlink(build_url(array('page' => '_SELF', 'type' => 'delete', 'stage' => 0, 'id' => $room_id), '_SELF'), do_lang_tempcode('DELETE_ALL_MESSAGES'));
     $view_link = hyperlink(build_url(array('page' => 'chat', 'type' => 'room', 'id' => $room_id), get_module_zone('chat')), do_lang_tempcode('VIEW'));
     $logs_link = hyperlink(build_url(array('page' => 'chat', 'type' => 'download_logs', 'id' => $room_id), get_module_zone('chat')), do_lang_tempcode('CHAT_DOWNLOAD_LOGS'));
     $links = array($mod_link, $view_link, $logs_link);
     $delete_url = build_url(array('page' => '_SELF', 'type' => 'mass_delete', 'room_id' => $room_id, 'start' => $start, 'max' => $max), '_SELF');
     return do_template('CHAT_MODERATE_SCREEN', array('_GUID' => '940de7e8c9a0ac3c575892887c7ef3c0', 'URL' => $delete_url, 'TITLE' => $title, 'INTRODUCTION' => '', 'CONTENT' => $content, 'LINKS' => $links));
 }
Esempio n. 5
0
 /**
  * View survey results.
  *
  * @return tempcode	The result of execution.
  */
 function _survey_results()
 {
     $title = get_page_title('SURVEY_RESULTS');
     breadcrumb_set_parents(array(array('_SELF:_SELF', do_lang_tempcode('MANAGE_QUIZZES'))));
     $GLOBALS['HELPER_PANEL_PIC'] = 'pagepics/survey_results';
     $id = get_param_integer('id');
     // quiz ID
     $fields = new ocp_tempcode();
     require_code('templates_results_table');
     require_code('templates_view_space');
     // Show summary
     $question_rows = $GLOBALS['SITE_DB']->query_select('quiz_questions', array('*'), array('q_quiz' => $id), 'ORDER BY id');
     foreach ($question_rows as $q) {
         $question = get_translated_text($q['q_question_text']);
         $answers = new ocp_tempcode();
         $answer_rows = $GLOBALS['SITE_DB']->query_select('quiz_question_answers', array('*'), array('q_question' => $q['id']), 'ORDER BY id');
         $all_answers = array();
         foreach ($answer_rows as $i => $a) {
             $answer = get_translated_text($a['q_answer_text']);
             $count = $GLOBALS['SITE_DB']->query_value('quiz_entry_answer', 'COUNT(*)', array('q_answer' => strval($a['id'])));
             $all_answers[serialize(array($answer, $i))] = $count;
         }
         arsort($all_answers);
         foreach ($all_answers as $bits => $count) {
             list($answer, $i) = unserialize($bits);
             $answers->attach(paragraph(do_lang_tempcode('SURVEY_ANSWER_RESULT', escape_html($answer), integer_format($count), integer_format($i + 1))));
         }
         if ($answers->is_empty()) {
             $answers = do_lang_tempcode('FREE_ENTRY_ANSWER');
         }
         $fields->attach(view_space_field($question, $answers, true));
     }
     $summary = do_template('VIEW_SPACE', array('_GUID' => '2b0c2ba0070ba810c5e4b5b4aedcb15f', 'WIDTH' => '300', 'FIELDS' => $fields));
     // Show results table
     $start = get_param_integer('start', 0);
     $max = get_param_integer('max', 50);
     $sortables = array('q_time' => do_lang_tempcode('DATE'));
     $test = explode(' ', get_param('sort', 'q_time 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';
     $max_rows = $GLOBALS['SITE_DB']->query_value('quiz_entries', 'COUNT(*)', array('q_quiz' => $id));
     $rows = $GLOBALS['SITE_DB']->query_select('quiz_entries', array('id', 'q_time', 'q_member'), array('q_quiz' => $id), 'ORDER BY ' . $sortable . ' ' . $sort_order, $max, $start);
     if (count($rows) == 0) {
         return inform_screen($title, do_lang_tempcode('NO_ENTRIES'));
     }
     $fields = new ocp_tempcode();
     $fields_title = results_field_title(array(do_lang_tempcode('DATE'), do_lang_tempcode('USERNAME')), $sortables, 'sort', $sortable . ' ' . $sort_order);
     foreach ($rows as $myrow) {
         $date_link = hyperlink(build_url(array('page' => '_SELF', 'type' => '__survey_results', 'id' => $myrow['id']), '_SELF'), escape_html(get_timezoned_date($myrow['q_time'])));
         $member_link = $GLOBALS['FORUM_DRIVER']->member_profile_hyperlink($myrow['q_member']);
         $fields->attach(results_entry(array($date_link, $member_link), false));
     }
     if ($fields->is_empty()) {
         warn_exit(do_lang_tempcode('NO_ENTRIES'));
     }
     $results = results_table(do_lang_tempcode('SURVEY_RESULTS'), $start, 'start', $max, 'max', $max_rows, $fields_title, $fields, $sortables, $sortable, $sort_order, 'sort');
     return do_template('SURVEY_RESULTS_SCREEN', array('_GUID' => '3f38ac1b94fb4de8219b8f7108c7b0a3', 'TITLE' => $title, 'SUMMARY' => $summary, 'RESULTS' => $results));
 }
Esempio n. 6
0
 /**
  * The UI to choose a zone to edit.
  *
  * @param  string			The follow-on type
  * @param  ?tempcode		The title to use (NULL: the EDIT_ZONE title)
  * @return tempcode		The UI
  */
 function edit_zone($type = '_edit', $title = NULL)
 {
     $GLOBALS['HELPER_PANEL_PIC'] = 'pagepics/zones';
     $GLOBALS['HELPER_PANEL_TUTORIAL'] = 'tut_structure';
     if (is_null($title)) {
         $title = get_page_title('EDIT_ZONE');
     }
     $start = get_param_integer('start', 0);
     $max = get_param_integer('max', 50);
     $_zones = find_all_zones(false, true, false, $start, $max);
     $url_map = array('page' => '_SELF', 'type' => $type);
     if ($type == '_editor') {
         $url_map['wide'] = 1;
     }
     require_code('templates_results_table');
     $current_ordering = 'name ASC';
     if (strpos($current_ordering, ' ') === false) {
         warn_exit(do_lang_tempcode('INTERNAL_ERROR'));
     }
     list($sortable, $sort_order) = explode(' ', $current_ordering, 2);
     $sortables = array();
     $header_row = results_field_title(array(do_lang_tempcode('NAME'), do_lang_tempcode('TITLE'), do_lang_tempcode('DEFAULT_PAGE'), do_lang_tempcode('THEME'), do_lang_tempcode('DISPLAYED_IN_MENU'), do_lang_tempcode('WIDE'), do_lang_tempcode('REQUIRE_SESSION'), do_lang_tempcode('ACTIONS')), $sortables, 'sort', $sortable . ' ' . $sort_order);
     $fields = new ocp_tempcode();
     require_code('form_templates');
     $max_rows = $GLOBALS['SITE_DB']->query_value('zones', 'COUNT(*)');
     foreach ($_zones as $_zone_details) {
         list($zone_name, $zone_title, $zone_show_in_menu, $zone_default_page, $remaining_row) = $_zone_details;
         $edit_link = build_url($url_map + array('id' => $zone_name), '_SELF');
         $fields->attach(results_entry(array(hyperlink(build_url(array('page' => ''), $zone_name), $zone_name == '' ? do_lang_tempcode('NA_EM') : make_string_tempcode(escape_html($zone_name))), $zone_title, $zone_default_page, $remaining_row['zone_theme'] == '-1' ? do_lang_tempcode('NA_EM') : hyperlink(build_url(array('page' => 'admin_themes'), 'adminzone'), escape_html($remaining_row['zone_theme'])), $zone_show_in_menu == 1 ? do_lang_tempcode('YES') : do_lang_tempcode('NO'), $remaining_row['zone_wide'] == 1 ? do_lang_tempcode('YES') : do_lang_tempcode('NO'), $remaining_row['zone_require_session'] == 1 ? do_lang_tempcode('YES') : do_lang_tempcode('NO'), protect_from_escaping(hyperlink($edit_link, do_lang_tempcode('EDIT'), false, true, $zone_name))), true));
     }
     $table = results_table(do_lang('ZONES'), get_param_integer('start', 0), 'start', either_param_integer('max', 20), 'max', $max_rows, $header_row, $fields, $sortables, $sortable, $sort_order);
     breadcrumb_set_parents(array(array('_SELF:_SELF:misc', do_lang_tempcode('ZONES'))));
     breadcrumb_set_self(do_lang_tempcode('CHOOSE'));
     $text = do_lang_tempcode('CHOOSE_EDIT_LIST');
     return do_template('TABLE_TABLE_SCREEN', array('TITLE' => $title, 'TEXT' => $text, 'TABLE' => $table, 'SUBMIT_NAME' => NULL, 'POST_URL' => get_self_url()));
 }
Esempio n. 7
0
 /**
  * Standard aed_module table function.
  *
  * @param  array			Details to go to build_url for link to the next screen.
  * @return array			A pair: The choose table, Whether re-ordering is supported from this screen.
  */
 function nice_get_choose_table($url_map)
 {
     require_code('templates_results_table');
     $hr = array();
     $hr[] = do_lang_tempcode('TITLE');
     if (addon_installed('points')) {
         $hr[] = do_lang_tempcode('POINTS');
     }
     $hr[] = do_lang_tempcode('CONTENT_TYPE');
     $hr[] = do_lang_tempcode('USED_PREVIOUSLY');
     $hr[] = do_lang_tempcode('ACTIONS');
     $current_ordering = get_param('sort', 'a_title ASC');
     if (strpos($current_ordering, ' ') === false) {
         warn_exit(do_lang_tempcode('INTERNAL_ERROR'));
     }
     list($sortable, $sort_order) = explode(' ', $current_ordering, 2);
     $sortables = array('a_title' => do_lang_tempcode('TITLE'), 'a_content_type' => do_lang_tempcode('CONTENT_TYPE'));
     if (addon_installed('points')) {
         $sortables['a_points'] = do_lang_tempcode('POINTS');
     }
     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';
     $header_row = results_field_title($hr, $sortables, 'sort', $sortable . ' ' . $sort_order);
     $fields = new ocp_tempcode();
     require_code('form_templates');
     list($rows, $max_rows) = $this->get_entry_rows(false, $current_ordering);
     foreach ($rows as $row) {
         $edit_link = build_url($url_map + array('id' => $row['id']), '_SELF');
         $fr = array();
         $fr[] = protect_from_escaping(hyperlink(build_url(array('page' => 'awards', 'type' => 'award', 'id' => $row['id']), get_module_zone('awards')), get_translated_text($row['a_title']), false, true));
         if (addon_installed('points')) {
             $fr[] = integer_format($row['a_points']);
         }
         $hooks = find_all_hooks('systems', 'awards');
         $hook_title = do_lang('UNKNOWN');
         foreach (array_keys($hooks) as $hook) {
             if ($hook == $row['a_content_type']) {
                 require_code('hooks/systems/awards/' . $hook);
                 $hook_object = object_factory('Hook_awards_' . $hook, true);
                 if (is_null($hook_object)) {
                     continue;
                 }
                 $hook_info = $hook_object->info();
                 if (!is_null($hook_info)) {
                     $hook_title = $hook_info['title']->evaluate();
                 }
             }
         }
         $fr[] = $hook_title;
         $fr[] = integer_format($GLOBALS['SITE_DB']->query_value('award_archive', 'COUNT(*)', array('a_type_id' => $row['id'])));
         $fr[] = protect_from_escaping(hyperlink($edit_link, do_lang_tempcode('EDIT'), false, true, '#' . strval($row['id'])));
         $fields->attach(results_entry($fr, true));
     }
     return array(results_table(do_lang($this->menu_label), get_param_integer('start', 0), 'start', either_param_integer('max', 20), 'max', $max_rows, $header_row, $fields, $sortables, $sortable, $sort_order), false);
 }
Esempio n. 8
0
 /**
  * Create a pie chart of the ratios of the specified statistic for the specified page. The chart is saved as an SVG image in /data_custom/admin_stats/, and the tempcode for display of the graph and results table is returned
  *
  * @param  PATH		The page path
  * @param  string		The statistic to use
  * @param  string		Language identifier for the graph title
  * @param  string		Language identifier for the graph description
  * @param  string		Language identifier for the list title
  * @return array		A linear array containing the graph and list tempcode objects, respectively
  */
 function page_x_share($page, $type, $graph_title, $graph_description, $list_title)
 {
     //Return a pie chart with the $type used to view this page
     $start = get_param_integer('start_' . $type, 0);
     $max = get_param_integer('max_' . $type, 25);
     $sortables = array('views' => do_lang_tempcode('_VIEWS'));
     list($sortable, $sort_order) = explode(' ', get_param('sort', 'views DESC'), 2);
     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';
     $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
     $ip_filter = $GLOBALS['DEBUG_MODE'] ? '' : ' AND ' . db_string_not_equal_to('ip', get_ip_address());
     $rows = $GLOBALS['SITE_DB']->query('SELECT id,' . $type . ' FROM ' . get_table_prefix() . 'stats WHERE (' . $where . ')' . $ip_filter, 5000);
     if (count($rows) < 1) {
         $list = new ocp_tempcode();
         $graph = new ocp_tempcode();
         return array($graph, $list);
     }
     $data1 = array();
     $degrees = 360 / count($rows);
     foreach ($rows as $value) {
         //if($value[$type]==0) $value[$type]=do_lang('_UNKNOWN');
         if (!array_key_exists($value[$type], $data1)) {
             $data1[$value[$type]] = $degrees;
         } else {
             $data1[$value[$type]] = ($data1[$value[$type]] / $degrees + 1) * $degrees;
         }
     }
     require_code('templates_results_table');
     $fields_title = results_field_title(array(do_lang_tempcode($list_title), do_lang_tempcode('COUNT_VIEWS')), $sortables, 'sort', $sortable . ' ' . $sort_order);
     $fields = new ocp_tempcode();
     $data = array();
     $done_total = 0;
     //$done=0;
     $i = 0;
     foreach ($data1 as $key => $value) {
         if ($i < $start) {
             $i++;
             continue;
         } elseif ($i >= $start + $max) {
             break;
         }
         if ($key == '') {
             $link = do_lang('_UNKNOWN');
         } else {
             $link = escape_html($key);
         }
         $fields->attach(results_entry(array($link, escape_html(integer_format($value)))));
         //if ($done<20)
         //{
         $data[$key] = $value * $degrees;
         //$done++;
         $done_total += $value;
         //}
         $i++;
     }
     if (count($rows) > $done_total) {
         $data[do_lang('OTHER')] = 360.0 - $done_total * $degrees;
         $fields->attach(results_entry(array(do_lang('OTHER'), integer_format(count($rows) - $done_total)), true));
     }
     if ($sortable == 'views') {
         asort($data1);
         if ($sort_order == 'DESC') {
             $data1 = array_reverse($data1);
         }
     }
     $list = results_table(do_lang_tempcode('PAGES_STATISTICS', escape_html($page)), $start, 'start_' . $type, $max, 'max_' . $type, $i, $fields_title, $fields, $sortables, $sortable, $sort_order, 'sort_' . $type);
     $output = create_pie_chart($data);
     $this->save_graph(strval($rows[0]['id']) . '-' . $type, $output);
     $graph = do_template('STATS_GRAPH', array('GRAPH' => get_custom_base_url() . '/data_custom/modules/admin_stats/' . strval($rows[0]['id']) . '-' . $type . '.xml', 'TITLE' => do_lang_tempcode($graph_title), 'TEXT' => do_lang_tempcode($graph_description)));
     return array($graph, $list);
 }
Esempio n. 9
0
 /**
  * Standard aed_module table function.
  *
  * @param  array			Details to go to build_url for link to the next screen.
  * @return ?array			A quartet: The choose table, Whether re-ordering is supported from this screen, Search URL, Archive URL (NULL: nothing to select).
  */
 function nice_get_choose_table($url_map)
 {
     require_code('templates_results_table');
     $current_ordering = get_param('sort', 'date_and_time DESC');
     if (strpos($current_ordering, ' ') === false) {
         warn_exit(do_lang_tempcode('INTERNAL_ERROR'));
     }
     list($sortable, $sort_order) = explode(' ', $current_ordering, 2);
     $sortables = array('title' => do_lang_tempcode('TITLE'), 'date_and_time' => do_lang_tempcode('_ADDED'), 'news_views' => do_lang_tempcode('_VIEWS'));
     if (addon_installed('unvalidated')) {
         $sortables['validated'] = do_lang_tempcode('VALIDATED');
     }
     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';
     $fh = array();
     $fh[] = do_lang_tempcode('TITLE');
     $fh[] = do_lang_tempcode('_ADDED');
     $fh[] = do_lang_tempcode('_VIEWS');
     if (addon_installed('unvalidated')) {
         $fh[] = do_lang_tempcode('VALIDATED');
     }
     $fh[] = do_lang_tempcode('ACTIONS');
     $header_row = results_field_title($fh, $sortables, 'sort', $sortable . ' ' . $sort_order);
     $fields = new ocp_tempcode();
     require_code('form_templates');
     $only_owned = has_specific_permission(get_member(), 'edit_midrange_content', 'cms_news') ? NULL : get_member();
     list($rows, $max_rows) = $this->get_entry_rows(false, $current_ordering, is_null($only_owned) ? NULL : array('submitter' => $only_owned), false, ' JOIN ' . get_table_prefix() . 'news_categories c ON c.id=r.news_category AND nc_owner IS NOT NULL');
     if (count($rows) == 0) {
         return NULL;
     }
     foreach ($rows as $row) {
         $edit_link = build_url($url_map + array('id' => $row['id']), '_SELF');
         $fr = array();
         $fr[] = protect_from_escaping(hyperlink(build_url(array('page' => 'news', 'type' => 'view', 'id' => $row['id']), get_module_zone('news')), get_translated_text($row['title']), false, true));
         $fr[] = get_timezoned_date($row['date_and_time']);
         $fr[] = integer_format($row['news_views']);
         if (addon_installed('unvalidated')) {
             $fr[] = $row['validated'] == 1 ? do_lang_tempcode('YES') : do_lang_tempcode('NO');
         }
         $fr[] = protect_from_escaping(hyperlink($edit_link, do_lang_tempcode('EDIT'), false, true, '#' . strval($row['id'])));
         $fields->attach(results_entry($fr, true));
     }
     $search_url = build_url(array('page' => 'search', 'id' => 'news'), get_module_zone('search'));
     $archive_url = build_url(array('page' => 'news'), get_module_zone('news'));
     return array(results_table(do_lang($this->menu_label), get_param_integer('start', 0), 'start', either_param_integer('max', 20), 'max', $max_rows, $header_row, $fields, $sortables, $sortable, $sort_order), false, $search_url, $archive_url);
 }
Esempio n. 10
0
 /**
  * The UI for managing temporary usergroup memberships.
  *
  * @return tempcode		The UI
  */
 function group_member_timeouts()
 {
     $title = get_page_title('GROUP_MEMBER_TIMEOUTS');
     if (!cron_installed()) {
         attach_message(do_lang_tempcode('CRON_NEEDED_TO_WORK', escape_html(brand_base_url() . '/docs' . strval(ocp_version()) . '/pg/tut_configuration')), 'warn');
     }
     $GLOBALS['HELPER_PANEL_PIC'] = 'pagepics/usergroups_temp';
     breadcrumb_set_parents(array(array('_SEARCH:admin_ocf_join:menu', do_lang_tempcode('MEMBERS'))));
     require_code('form_templates');
     require_code('templates_results_table');
     $start = get_param_integer('start', 0);
     $max = get_param_integer('max', 100);
     $max_rows = $GLOBALS[get_forum_type() == 'ocf' ? 'FORUM_DB' : 'SITE_DB']->query_value('f_group_member_timeouts', 'COUNT(*)');
     $fields_title = results_field_title(array(do_lang_tempcode('USERNAME'), do_lang_tempcode('_USERGROUP'), do_lang_tempcode('TIME')));
     $timeouts = $GLOBALS[get_forum_type() == 'ocf' ? 'FORUM_DB' : 'SITE_DB']->query_select('f_group_member_timeouts', array('member_id', 'group_id', 'timeout'), NULL, '', $max, $start);
     $usergroups = $GLOBALS['FORUM_DRIVER']->get_usergroup_list();
     $tfields = new ocp_tempcode();
     foreach ($timeouts as $timeout) {
         $tfields->attach(results_entry(array($GLOBALS['FORUM_DRIVER']->get_username($timeout['member_id']), isset($usergroups[$timeout['group_id']]) ? $usergroups[$timeout['group_id']] : do_lang('UNKNOWN'), display_time_period($timeout['timeout'] - time())), true));
     }
     $results_table = results_table(do_lang('GROUP_MEMBER_TIMEOUTS'), $start, 'start', $max, 'max', $max_rows, $fields_title, $tfields);
     $fields = new ocp_tempcode();
     $fields->attach(form_input_username(do_lang_tempcode('USERNAME'), '', 'username', '', true));
     $_usergroups = new ocp_tempcode();
     foreach ($usergroups as $uid => $name) {
         if ($uid != db_get_first_id()) {
             $_usergroups->attach(form_input_list_entry($uid, false, $name));
         }
     }
     require_lang('dates');
     $fields->attach(form_input_list(do_lang_tempcode('_USERGROUP'), '', 'group_id', $_usergroups, NULL, false, true));
     $fields->attach(form_input_integer(do_lang_tempcode('_MINUTES'), do_lang_tempcode('DESCRIPTION_GROUPMT_MINUTES'), 'num_minutes', 60, true));
     $post_url = build_url(array('page' => '_SELF', 'type' => '_group_member_timeouts'), '_SELF');
     $submit_name = do_lang_tempcode('ADD');
     $form = do_template('FORM', array('TABINDEX' => strval(get_form_field_tabindex()), 'HIDDEN' => '', 'TEXT' => '', 'FIELDS' => $fields, 'URL' => $post_url, 'SUBMIT_NAME' => $submit_name));
     return do_template('RESULTS_TABLE_SCREEN', array('TITLE' => $title, 'RESULTS_TABLE' => $results_table, 'FORM' => $form));
 }
Esempio n. 11
0
function referrer_report_script($ret = false)
{
    $member_id = get_param_integer('member_id', NULL);
    if (!has_zone_access(get_member(), 'adminzone') && $member_id !== get_member()) {
        access_denied('ZONE_ACCESS', 'adminzone');
    }
    require_lang('referrals');
    $csv = get_param_integer('csv', 0) == 1;
    $where = db_string_not_equal_to('i_email_address', '') . ' AND i_inviter<>' . strval($GLOBALS['FORUM_DRIVER']->get_guest_id());
    if ($member_id !== NULL) {
        $where .= ' AND referrer.id=' . strval($member_id);
    }
    $max = get_param_integer('max', $csv ? 10000 : 30);
    $start = get_param_integer('start', 0);
    $data = array();
    $table = 'f_invites i LEFT JOIN ' . $GLOBALS['FORUM_DB']->get_table_prefix() . 'f_members referrer ON referrer.id=i_inviter LEFT JOIN ' . $GLOBALS['FORUM_DB']->get_table_prefix() . 'f_members referee ON referee.m_email_address=i_email_address';
    $referrals = $GLOBALS['FORUM_DB']->query('SELECT i_time AS time,referrer.id AS referrer_id,referrer.m_username AS referrer,referrer.m_email_address AS referrer_email,referee.id AS referee_id,referee.m_username AS referee,referee.m_email_address AS referee_email,i_taken AS qualified
		FROM ' . $GLOBALS['FORUM_DB']->get_table_prefix() . $table . ' WHERE ' . $where . ' ORDER BY i_time DESC', $max, $start);
    $max_rows = $GLOBALS['FORUM_DB']->query_value_null_ok_full('SELECT COUNT(*) FROM ' . $GLOBALS['FORUM_DB']->get_table_prefix() . $table . ' WHERE ' . $where);
    if (count($referrals) == 0) {
        inform_exit(do_lang_tempcode('NO_ENTRIES'));
    }
    foreach ($referrals as $ref) {
        $data_row = array();
        $data_row[do_lang('DATE_TIME')] = get_timezoned_date($ref['time'], true, true, false, true);
        if (is_null($member_id)) {
            if ($csv) {
                $deleted = true;
                $data_row[do_lang('TYPE_REFERRER')] = is_null($ref['referrer']) ? do_lang($deleted ? 'REFEREE_DELETED' : 'REFEREE_NOT_SIGNED_UP') : $ref['referrer'];
            } else {
                $data_row[do_lang('TYPE_REFERRER')] = is_null($ref['referrer_id']) ? '' : strval($ref['referrer_id']);
            }
            $data_row[do_lang('TYPE_REFERRER') . ' (' . do_lang('EMAIL_ADDRESS') . ')'] = $ref['referrer_email'];
            $data_row[do_lang('QUALIFIED_REFERRER')] = do_lang(referrer_is_qualified($ref['referrer_id']) ? 'YES' : 'NO');
        }
        $deleted = false;
        if (is_null($ref['referee'])) {
            $deleted = $ref['qualified'] == 1;
            //!is_null($GLOBALS['SITE_DB']->query_value_null_ok('adminlogs','id',array('the_type'=>'DELETE_MEMBER','param_b'=>TODO Unfortunately we can't tell)));
        }
        if ($csv) {
            $data_row[do_lang('REFEREE')] = is_null($ref['referee']) ? do_lang($deleted ? 'REFEREE_DELETED' : 'REFEREE_NOT_SIGNED_UP') : $ref['referee'];
        } else {
            $data_row[do_lang('REFEREE')] = is_null($ref['referee_id']) ? '' : strval($ref['referee_id']);
        }
        $data_row[do_lang('REFEREE') . ' (' . do_lang('EMAIL_ADDRESS') . ')'] = is_null($ref['referee_email']) ? '' : $ref['referee_email'];
        $data_row[do_lang('QUALIFIED_REFERRAL')] = do_lang($ref['qualified'] == 1 ? 'YES' : 'NO');
        $data[] = $data_row;
    }
    if ($csv) {
        require_code('files2');
        make_csv($data, (is_null($member_id) ? get_site_name() : $GLOBALS['FORUM_DRIVER']->get_username($member_id)) . ' referrals.csv');
    } else {
        require_code('templates_results_table');
        $fields_title = new ocp_tempcode();
        $fields = new ocp_tempcode();
        foreach ($data as $i => $data_row) {
            if ($i == 0) {
                $fields_title->attach(results_field_title(array_keys($data_row)));
            }
            foreach ($data_row as $key => $val) {
                if ($key == do_lang('REFEREE') || $key == do_lang('TYPE_REFERRER')) {
                    if ($val == '') {
                        $val = do_lang('UNKNOWN');
                    } else {
                        $val = $GLOBALS['FORUM_DRIVER']->member_profile_hyperlink($val, true);
                    }
                }
                $data_row[$key] = escape_html($val);
            }
            $fields->attach(results_entry($data_row));
        }
        $table = results_table(do_lang('REFERRALS'), $start, 'start', $max, 'max', $max_rows, $fields_title, $fields);
        if ($ret) {
            return $table;
        }
        $title = get_page_title('REFERRALS');
        $out = new ocp_tempcode();
        $out->attach($title);
        $out->attach($table);
        $out = globalise($out, NULL, '', true);
        $out->evaluate_echo();
    }
    return NULL;
}
Esempio n. 12
0
 /**
  * Standard aed_module table function.
  *
  * @param  array			Details to go to build_url for link to the next screen.
  * @return array			A quartet: The choose table, Whether re-ordering is supported from this screen, Search URL, Archive URL.
  */
 function nice_get_choose_table($url_map)
 {
     require_code('templates_results_table');
     $default_order = 'g_name ASC';
     $current_ordering = get_param('sort', $default_order, true);
     $sortables = array('g_name' => do_lang_tempcode('NAME'));
     if (strpos($current_ordering, ' ') === false) {
         warn_exit(do_lang_tempcode('INTERNAL_ERROR'));
     }
     list($sortable, $sort_order) = explode(' ', $current_ordering, 2);
     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';
     $header_row = results_field_title(array(do_lang_tempcode('NAME'), do_lang_tempcode('OPEN_MEMBERSHIP'), do_lang_tempcode('ACTIONS')), $sortables, 'sort', $sortable . ' ' . $sort_order);
     $fields = new ocp_tempcode();
     $count = $GLOBALS['FORUM_DB']->query_value('f_groups', 'COUNT(*)', array('g_is_private_club' => 1));
     require_code('form_templates');
     list($rows, $max_rows) = $this->get_entry_rows(false, $current_ordering, $count > 300 || !has_specific_permission(get_member(), 'control_usergroups') ? array('g_group_leader' => get_member(), 'g_is_private_club' => 1) : array('g_is_private_club' => 1));
     foreach ($rows as $row) {
         $edit_link = build_url($url_map + array('id' => $row['id']), '_SELF');
         $fr = array(protect_from_escaping(ocf_get_group_link($row['id'])), $row['g_open_membership'] == 1 ? do_lang_tempcode('YES') : do_lang_tempcode('NO'));
         $fr[] = protect_from_escaping(hyperlink($edit_link, do_lang_tempcode('EDIT'), false, true, '#' . strval($row['id'])));
         $fields->attach(results_entry($fr, true));
     }
     $search_url = build_url(array('page' => 'search', 'id' => 'ocf_clubs'), get_module_zone('search'));
     $archive_url = build_url(array('page' => 'groups'), get_module_zone('groups'));
     return array(results_table(do_lang($this->menu_label), get_param_integer('start', 0), 'start', either_param_integer('max', 20), 'max', $max_rows, $header_row, $fields, $sortables, $sortable, $sort_order, 'sort'), false, $search_url, $archive_url);
 }
 /**
  * Standard aed_module table function.
  *
  * @param  array			Details to go to build_url for link to the next screen.
  * @return array			A pair: The choose table, Whether re-ordering is supported from this screen.
  */
 function nice_get_choose_table($url_map)
 {
     require_code('templates_results_table');
     $current_ordering = get_param('sort', 'mm_name ASC');
     if (strpos($current_ordering, ' ') === false) {
         warn_exit(do_lang_tempcode('INTERNAL_ERROR'));
     }
     list($sortable, $sort_order) = explode(' ', $current_ordering, 2);
     $sortables = array('mm_name' => do_lang_tempcode('NAME'), 'mm_pin_state' => do_lang_tempcode('PIN_STATE'), 'mm_open_state' => do_lang_tempcode('OPEN_STATE'), 'mm_sink_state' => do_lang_tempcode('SINK_STATE'));
     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';
     $header_row = results_field_title(array(do_lang_tempcode('NAME'), do_lang_tempcode('DESTINATION'), do_lang_tempcode('PIN_STATE'), do_lang_tempcode('OPEN_STATE'), do_lang_tempcode('SINK_STATE'), do_lang_tempcode('ACTIONS')), $sortables, 'sort', $sortable . ' ' . $sort_order);
     $fields = new ocp_tempcode();
     require_code('form_templates');
     list($rows, $max_rows) = $this->get_entry_rows(false, $current_ordering);
     foreach ($rows as $row) {
         $pin_state = do_lang_tempcode('NA_EM');
         if (!is_null($row['mm_pin_state'])) {
             switch ($row['mm_pin_state']) {
                 case 0:
                     $pin_state = do_lang_tempcode('UNPIN_TOPIC');
                     break;
                 case 1:
                     $pin_state = do_lang_tempcode('PIN_TOPIC');
                     break;
             }
         }
         $open_state = do_lang_tempcode('NA_EM');
         if (!is_null($row['mm_open_state'])) {
             switch ($row['mm_open_state']) {
                 case 0:
                     $open_state = do_lang_tempcode('CLOSE_TOPIC');
                     break;
                 case 1:
                     $open_state = do_lang_tempcode('OPEN_TOPIC');
                     break;
             }
         }
         $sink_state = do_lang_tempcode('NA_EM');
         if (!is_null($row['mm_sink_state'])) {
             switch ($row['mm_sink_state']) {
                 case 0:
                     $sink_state = do_lang_tempcode('SINK_TOPIC');
                     break;
                 case 1:
                     $sink_state = do_lang_tempcode('UNSINK_TOPIC');
                     break;
             }
         }
         $destination = is_null($row['mm_move_to']) ? NULL : $GLOBALS['FORUM_DB']->query_value_null_ok('f_forums', 'f_name', array('id' => $row['mm_move_to']));
         if (is_null($destination)) {
             $destination = do_lang_tempcode('NA_EM');
         }
         $edit_link = build_url($url_map + array('id' => $row['id']), '_SELF');
         $fields->attach(results_entry(array(get_translated_text($row['mm_name'], $GLOBALS['FORUM_DB']), $destination, $pin_state, $open_state, $sink_state, protect_from_escaping(hyperlink($edit_link, do_lang_tempcode('EDIT'), false, true, '#' . strval($row['id'])))), true));
     }
     return array(results_table(do_lang($this->menu_label), get_param_integer('start', 0), 'start', either_param_integer('max', 20), 'max', $max_rows, $header_row, $fields, $sortables, $sortable, $sort_order), false);
 }
Esempio n. 14
0
 /**
  * The UI to choose a page to edit.
  *
  * @return tempcode		The UI
  */
 function ed()
 {
     $title = get_page_title('COMCODE_PAGE_EDIT');
     $lang = choose_language($title, true);
     if (is_object($lang)) {
         return $lang;
     }
     require_code('form_templates');
     $add_new_permission = has_specific_permission(get_member(), 'submit_highrange_content');
     if (!$add_new_permission && !has_specific_permission(get_member(), 'edit_highrange_content') && !has_specific_permission(get_member(), 'edit_own_highrange_content')) {
         check_edit_permission('high', NULL);
     }
     $fields = new ocp_tempcode();
     if ($add_new_permission) {
         $fields->attach(form_input_line(do_lang_tempcode('NEW'), do_lang_tempcode('DESCRIPTION_NEW_COMCODE_PAGE'), 'page_link_2', '', true));
         $submit_name = do_lang_tempcode('ADD');
     } else {
         $submit_name = NULL;
     }
     $hidden = new ocp_tempcode();
     $hidden->attach(form_input_hidden('lang', $lang));
     $hidden->attach(form_input_hidden('type', '_ed'));
     $hidden->attach(build_keep_form_fields('_SELF'));
     $map = array('page' => '_SELF', 'type' => '_ed', 'lang' => $lang);
     $post_url = build_url($map, '_SELF', NULL, false, true);
     breadcrumb_set_self(do_lang_tempcode('CHOOSE'));
     $search_url = build_url(array('page' => 'search', 'id' => 'comcode_pages'), get_module_zone('search'));
     $sitemap_zone = get_page_zone('sitemap', false);
     if ($sitemap_zone !== NULL) {
         $archive_url = build_url(array('page' => 'sitemap'), $sitemap_zone);
     } else {
         $archive_url = build_url(array('page' => ''), '');
     }
     $text = paragraph(do_lang_tempcode('CHOOSE_EDIT_LIST_EXTRA', escape_html($search_url->evaluate()), escape_html($archive_url->evaluate())));
     if (addon_installed('page_management')) {
         if (has_actual_page_access(get_member(), 'admin_sitetree')) {
             $page_wizard = build_url(array('page' => 'admin_sitetree', 'type' => 'pagewizard'), get_module_zone('admin_sitetree'));
             $site_tree_editor = build_url(array('page' => 'admin_sitetree', 'type' => 'site_tree'), get_module_zone('admin_sitetree'));
             attach_message(do_lang_tempcode('SUGGEST_PAGE_WIZARD', escape_html($page_wizard->evaluate()), escape_html($site_tree_editor->evaluate())), 'inform');
         }
     }
     require_code('templates_results_table');
     $current_ordering = get_param('sort', 'page_title ASC');
     if (strpos($current_ordering, ' ') === false) {
         warn_exit(do_lang_tempcode('INTERNAL_ERROR'));
     }
     list($sortable, $sort_order) = explode(' ', $current_ordering, 2);
     $sortables = array('page_title' => do_lang_tempcode('TITLE'), 'page' => do_lang_tempcode('PAGE'), 'zone_name' => do_lang_tempcode('ZONE'), 'pagelink' => do_lang_tempcode('PAGE_LINK'));
     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';
     $header_row = results_field_title(array(do_lang_tempcode('TITLE'), do_lang_tempcode('PAGE'), do_lang_tempcode('ZONE'), do_lang_tempcode('PAGE_LINK'), do_lang_tempcode('ACTIONS')), $sortables, 'sort', $sortable . ' ' . $sort_order);
     $all_zones = find_all_zones(false, true);
     $number_pages_parsed_for_titles = 0;
     $GLOBALS['NO_QUERY_LIMIT'] = true;
     $start = get_param_integer('start', 0);
     $max = get_param_integer('max', 50);
     $filesarray = $this->get_comcode_files_array($lang);
     if (count($filesarray) >= 300) {
         $orderer = 'p_add_date ASC';
         switch ($sortable) {
             case 'page_title':
                 $orderer = 't.text_original ' . $sort_order;
                 break;
             case 'page':
                 $orderer = 'c.the_page ' . $sort_order;
                 break;
             case 'zone_name':
                 $orderer = 'c.the_zone ' . $sort_order;
                 break;
             case 'pagelink':
                 $orderer = 'c.the_zone ' . $sort_order . ',c.the_page ' . $sort_order;
                 break;
         }
         $group_by = '';
         if (can_arbitrary_groupby()) {
             $group_by = 'GROUP BY c.the_zone,c.the_page';
         }
         $where_map = '(' . db_string_equal_to('language', $lang) . ' OR language IS NULL)';
         if (!has_specific_permission(get_member(), 'edit_highrange_content')) {
             $where_map .= ' AND submitter=' . strval(get_member());
         }
         $ttable = get_table_prefix() . 'comcode_pages c LEFT JOIN ' . get_table_prefix() . 'cached_comcode_pages a ON c.the_page=a.the_page AND c.the_zone=a.the_zone LEFT JOIN ' . get_table_prefix() . 'translate t ON t.id=a.cc_page_title';
         $page_rows = $GLOBALS['SITE_DB']->query('SELECT c.*,cc_page_title FROM ' . $ttable . ' WHERE ' . $where_map . $group_by . ' ORDER BY ' . $orderer, $max, $start);
         $max_rows = $GLOBALS['SITE_DB']->query_value_null_ok_full('SELECT COUNT(DISTINCT c.the_zone,c.the_page) FROM ' . $ttable . ' WHERE ' . $where_map);
         $filesarray = array();
         foreach ($page_rows as $row) {
             $located = _request_page($row['the_page'], $row['the_zone'], NULL, $lang);
             if ($located !== false) {
                 $filesarray[$row['the_zone'] . ':' . $row['the_page']] = array($row['the_zone'] . '/pages/' . strtolower($located[0]) . '/' . $row['the_page'], NULL, $row);
             }
         }
         $found_via_query = true;
     } else {
         $max_rows = 0;
         ksort($filesarray);
         $found_via_query = false;
     }
     // Render table rows
     $_table_rows = array();
     foreach ($filesarray as $pagelink => $path_bits) {
         list($zone, $page) = explode(':', $pagelink, 2);
         if (!is_string($page)) {
             $page = strval($page);
         }
         $edit_link = build_url(array('page' => '_SELF', 'type' => '_ed', 'page_link' => $pagelink, 'lang' => $lang), '_SELF');
         $clone_link = build_url(array('page' => '_SELF', 'type' => '_ed', 'page_link' => $zone . ':', 'restore_from' => $path_bits[0] . '.txt', 'lang' => $lang), '_SELF');
         $zone_name = array_key_exists($zone, $all_zones) ? $all_zones[$zone][1] : $zone;
         // We need to separately read from DB to work out meta data?
         $row = mixed();
         if (!array_key_exists(2, $path_bits)) {
             $rows = $GLOBALS['SITE_DB']->query_select('comcode_pages c LEFT JOIN ' . get_table_prefix() . 'cached_comcode_pages a ON c.the_page=a.the_page AND c.the_zone=a.the_zone', array('c.*', 'cc_page_title'), array('c.the_zone' => $zone, 'c.the_page' => $page), '', 1);
             if (!array_key_exists(0, $rows) && $number_pages_parsed_for_titles < 15) {
                 $result = request_page($page, false, $zone, 'comcode_custom', true);
                 $rows = $GLOBALS['SITE_DB']->query_select('comcode_pages c LEFT JOIN ' . get_table_prefix() . 'cached_comcode_pages a ON c.the_page=a.the_page AND c.the_zone=a.the_zone', array('c.*', 'cc_page_title'), array('c.the_zone' => $zone, 'c.the_page' => $page), '', 1);
                 $number_pages_parsed_for_titles++;
             }
             $row = array_key_exists(0, $rows) ? $rows[0] : NULL;
         } else {
             $row = $path_bits[2];
         }
         // Work out meta data
         $page_title = do_lang_tempcode('NA_EM');
         if (!is_null($row)) {
             $username = protect_from_escaping($GLOBALS['FORUM_DRIVER']->member_profile_hyperlink($row['p_submitter']));
             $parent_page = $row['p_parent_page'];
             $add_date = get_timezoned_date($row['p_add_date']);
             $validated = $row['p_validated'] == 1 ? do_lang_tempcode('YES') : do_lang_tempcode('YES');
             if (!is_null($row['cc_page_title'])) {
                 $_page_title = get_translated_text($row['cc_page_title'], NULL, NULL, true);
                 if (!is_null($_page_title)) {
                     if ($_page_title != '') {
                         $page_title = make_string_tempcode($_page_title);
                     }
                 }
             }
         } else {
             $username = do_lang('UNKNOWN');
             $parent_page = '';
             $add_date = get_timezoned_date(filectime(get_file_base() . '/index.php'));
             $validated = do_lang_tempcode('YES');
         }
         $wrappable_pagelink = preg_replace('#([^ ]):([\\w\\-]{10,})$#', '${1}: ${2}', preg_replace('#(^[\\w\\-]{10,}):#', '${1}: ', $pagelink));
         $actions = do_template('COMCODE_PAGE_EDIT_ACTIONS', array('EDIT_URL' => $edit_link, 'CLONE_URL' => $clone_link));
         $_table_rows[] = array('page_title' => $page_title, 'page' => $page, 'zone' => $zone, 'zone_name' => $zone_name, 'pagelink' => $pagelink, 'wrappable_pagelink' => $wrappable_pagelink, 'actions' => $actions);
     }
     // Manual sorting
     global $M_SORT_KEY;
     $M_SORT_KEY = $sortable;
     usort($_table_rows, 'multi_sort');
     if ($sort_order == 'DESC') {
         $_table_rows = array_reverse($_table_rows);
     }
     $table_rows = new ocp_tempcode();
     if (!$found_via_query) {
         $max_rows = count($_table_rows);
     }
     foreach ($_table_rows as $i => $table_row) {
         if (!$found_via_query) {
             if ($i < $start) {
                 continue;
             }
             if ($i > $max + $start) {
                 break;
             }
         }
         $table_rows->attach(results_entry(array(protect_from_escaping(hyperlink(build_url(array('page' => $table_row['page']), $table_row['zone']), $table_row['page_title'])), protect_from_escaping(do_template('COMCODE_TELETYPE', array('CONTENT' => preg_replace('#([\\w\\d\\_]{22})#', '${1}<br />', escape_html($table_row['page']))))), protect_from_escaping(hyperlink(build_url(array('page' => ''), $table_row['zone']), $table_row['zone_name'], false, true)), protect_from_escaping(do_template('COMCODE_TELETYPE', array('CONTENT' => preg_replace('#([\\w\\d\\_]{22})#', '${1}<br />', escape_html($table_row['wrappable_pagelink']))))), protect_from_escaping($table_row['actions'])), true));
     }
     $table = results_table(do_lang('COMCODE_PAGES'), $start, 'start', $max, 'max', $max_rows, $header_row, $table_rows, $sortables, $sortable, $sort_order, 'sort', NULL, NULL, NULL, 8, 'fdgfdfdfdggfd', true);
     return do_template('TABLE_TABLE_SCREEN', array('TITLE' => $title, 'TEXT' => $text, 'TABLE' => $table, 'FIELDS' => $fields, 'POST_URL' => $post_url, 'GET' => true, 'HIDDEN' => $hidden, 'SUBMIT_NAME' => $submit_name));
 }
Esempio n. 15
0
 /**
  * Standard aed_module table function.
  *
  * @param  array			Details to go to build_url for link to the next screen.
  * @return array			A pair: The choose table, Whether re-ordering is supported from this screen.
  */
 function nice_get_choose_table($url_map)
 {
     require_code('templates_results_table');
     $current_ordering = get_param('sort', 'id ASC', true);
     list($sortable, $sort_order) = array(substr($current_ordering, 0, strrpos($current_ordering, ' ')), substr($current_ordering, strrpos($current_ordering, ' ') + 1));
     $sortables = array('id' => do_lang_tempcode('CODENAME'), 't_is_textual' => do_lang_tempcode('BANNER_IS_TEXTUAL'), 't_image_width' => do_lang_tempcode('WIDTH'), 't_image_height' => do_lang_tempcode('HEIGHT'), 't_max_file_size' => do_lang_tempcode('_FILE_SIZE'), 't_comcode_inline' => do_lang_tempcode('COMCODE_INLINE'));
     if (db_has_subqueries($GLOBALS['SITE_DB']->connection_read)) {
         $sortables['(SELECT COUNT(*) FROM ' . get_table_prefix() . 'banners WHERE b_type=r.id)'] = do_lang_tempcode('COUNT_TOTAL');
     }
     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';
     $header_row = results_field_title(array(do_lang_tempcode('CODENAME'), do_lang_tempcode('BANNER_IS_TEXTUAL'), do_lang_tempcode('WIDTH'), do_lang_tempcode('HEIGHT'), do_lang_tempcode('_FILE_SIZE'), do_lang_tempcode('COMCODE_INLINE'), do_lang_tempcode('COUNT_TOTAL'), do_lang_tempcode('ACTIONS')), $sortables, 'sort', $sortable . ' ' . $sort_order);
     $fields = new ocp_tempcode();
     require_code('form_templates');
     list($rows, $max_rows) = $this->get_entry_rows(false, $current_ordering);
     foreach ($rows as $row) {
         $edit_link = build_url($url_map + array('id' => $row['id']), '_SELF');
         $total = integer_format($GLOBALS['SITE_DB']->query_value('banners', 'COUNT(*)', array('b_type' => $row['id'])));
         $fields->attach(results_entry(array($row['id'] == '' ? do_lang('GENERAL') : $row['id'], $row['t_is_textual'] == 1 ? do_lang_tempcode('YES') : do_lang_tempcode('NO'), integer_format($row['t_image_width']), integer_format($row['t_image_height']), clean_file_size($row['t_max_file_size'] * 1024), $row['t_comcode_inline'] == 1 ? do_lang_tempcode('YES') : do_lang_tempcode('NO'), $total, protect_from_escaping(hyperlink($edit_link, do_lang_tempcode('EDIT'), false, true, '#' . $row['id']))), true));
     }
     return array(results_table(do_lang($this->menu_label), get_param_integer('start', 0), 'start', get_param_integer('max', 20), 'max', $max_rows, $header_row, $fields, $sortables, $sortable, $sort_order), false);
 }
 /**
  * Standard aed_module table function.
  *
  * @param  array			Details to go to build_url for link to the next screen.
  * @return array			A pair: The choose table, Whether re-ordering is supported from this screen.
  */
 function nice_get_choose_table($url_map)
 {
     require_code('templates_results_table');
     $current_ordering = get_param('sort', 'w_name ASC');
     if (strpos($current_ordering, ' ') === false) {
         warn_exit(do_lang_tempcode('INTERNAL_ERROR'));
     }
     list($sortable, $sort_order) = explode(' ', $current_ordering, 2);
     $sortables = array('w_name' => do_lang_tempcode('NAME'), 'w_subject' => do_lang_tempcode('SUBJECT'), 'w_send_time' => do_lang_tempcode('SEND_TIME'));
     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';
     $header_row = results_field_title(array(do_lang_tempcode('NAME'), do_lang_tempcode('SUBJECT'), do_lang_tempcode('SEND_TIME'), do_lang_tempcode('ACTIONS')), $sortables, 'sort', $sortable . ' ' . $sort_order);
     $fields = new ocp_tempcode();
     require_code('form_templates');
     list($rows, $max_rows) = $this->get_entry_rows(false, $current_ordering);
     foreach ($rows as $row) {
         $edit_link = build_url($url_map + array('id' => $row['id']), '_SELF');
         $fields->attach(results_entry(array($row['w_name'], get_translated_text($row['w_subject']), do_lang_tempcode('HOURS', escape_html(strval($row['w_send_time']))), protect_from_escaping(hyperlink($edit_link, do_lang_tempcode('EDIT'), false, true, '#' . strval($row['id'])))), true));
     }
     return array(results_table(do_lang($this->menu_label), get_param_integer('start', 0), 'start', either_param_integer('max', 20), 'max', $max_rows, $header_row, $fields, $sortables, $sortable, $sort_order), false);
 }
Esempio n. 17
0
 /**
  * The UI to view security logs.
  *
  * @return tempcode		The UI
  */
 function security_interface()
 {
     $title = get_page_title('SECURITY_LOGGING');
     // Failed logins
     $start = get_param_integer('failed_start', 0);
     $max = get_param_integer('failed_max', 50);
     $sortables = array('date_and_time' => do_lang_tempcode('DATE_TIME'), 'ip' => do_lang_tempcode('IP_ADDRESS'));
     $test = explode(' ', get_param('failed_sort', 'date_and_time DESC'));
     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[] = 'failed_sort';
     require_code('templates_results_table');
     $fields_title = results_field_title(array(do_lang_tempcode('USERNAME'), do_lang_tempcode('DATE_TIME'), do_lang_tempcode('IP_ADDRESS')), $sortables, 'failed_sort', $_sortable . ' ' . $sort_order);
     $member_id = post_param_integer('member_id', NULL);
     $map = !is_null($member_id) ? array('failed_account' => $GLOBALS['FORUM_DRIVER']->get_username($member_id)) : NULL;
     $max_rows = $GLOBALS['SITE_DB']->query_value('failedlogins', 'COUNT(*)', $map);
     $rows = $GLOBALS['SITE_DB']->query_select('failedlogins', array('*'), $map, 'ORDER BY ' . $_sortable . ' ' . $sort_order, $max, $start);
     $fields = new ocp_tempcode();
     foreach ($rows as $row) {
         $time = get_timezoned_date($row['date_and_time']);
         $lookup_url = build_url(array('page' => 'admin_lookup', 'param' => $row['ip']), '_SELF');
         $fields->attach(results_entry(array(escape_html($row['failed_account']), escape_html($time), hyperlink($lookup_url, escape_html($row['ip'])))));
     }
     $failed_logins = results_table(do_lang_tempcode('FAILED_LOGINS'), $start, 'failed_start', $max, 'failed_max', $max_rows, $fields_title, $fields, $sortables, $_sortable, $sort_order, 'failed_sort', new ocp_tempcode());
     $member_id = post_param_integer('member_id', NULL);
     $map = !is_null($member_id) ? array('the_user' => $member_id) : NULL;
     $alerts = find_security_alerts($map);
     $post_url = build_url(array('page' => '_SELF', 'type' => 'clean', 'start' => $start, 'max' => $max), '_SELF');
     return do_template('SECURITY_SCREEN', array('_GUID' => 'e0b5e6557686b2320a8ce8166df07328', 'TITLE' => $title, 'FAILED_LOGINS' => $failed_logins, 'ALERTS' => $alerts, 'URL' => $post_url));
 }
Esempio n. 18
0
 /**
  * The UI to show shopping cart
  *
  * @return tempcode		The UI	
  */
 function view_shopping_cart()
 {
     $pro_ids = array();
     $pro_ids_val = NULL;
     require_code('templates_results_table');
     require_code('form_templates');
     require_css('shopping');
     require_javascript('javascript_shopping');
     $title = get_page_title('SHOPPING');
     log_cart_actions('View cart');
     breadcrumb_set_parents(array(array('_SELF:catalogues:misc:ecommerce=1', do_lang_tempcode('CATALOGUES'))));
     $where = array('ordered_by' => get_member(), 'is_deleted' => 0);
     if (is_guest()) {
         $where['session_id'] = get_session_id();
     } else {
         $where['ordered_by'] = get_member();
     }
     $result = $GLOBALS['SITE_DB']->query_select('shopping_cart', array('*'), $where);
     $max_rows = count($result);
     if ($max_rows > 0) {
         $shopping_cart = new ocp_tempcode();
         $checkout_details = new ocp_tempcode();
         $fields_title = results_field_title(array('', do_lang_tempcode('PRODUCT_NAME'), do_lang_tempcode('UNIT_PRICE'), do_lang_tempcode('QUANTITY'), do_lang_tempcode('ORDER_PRICE_AMT'), do_lang_tempcode('TAX'), do_lang_tempcode('SHIPPING_PRICE'), do_lang_tempcode('TOTAL_PRICE'), do_lang_tempcode('REMOVE_FROM_CART')), NULL);
         $i = 1;
         $sub_tot = 0.0;
         $shipping_cost = 0.0;
         foreach ($result as $value) {
             $pro_ids[] = $value['product_id'];
             $_hook = $value['product_type'];
             $value['sl_no'] = $i;
             require_code('hooks/systems/ecommerce/' . filter_naughty_harsh($_hook));
             $object = object_factory('Hook_' . filter_naughty_harsh($_hook));
             if (method_exists($object, 'show_cart_entry')) {
                 $object->show_cart_entry($shopping_cart, $value);
             }
             if (method_exists($object, 'calculate_tax')) {
                 $tax = $object->calculate_tax($value['price'], $value['price_pre_tax']);
             } else {
                 $tax = 0;
             }
             //Shipping
             if (method_exists($object, 'calculate_shipping_cost')) {
                 $shipping_cost = $object->calculate_shipping_cost($value['product_weight']);
             } else {
                 $shipping_cost = 0;
             }
             $sub_tot += round($value['price'] + $tax + $shipping_cost, 2) * $value['quantity'];
             $i++;
         }
         $width = NULL;
         //array('50','100%','85','85','85','85','85','85','85');
         $results_table = results_table(do_lang_tempcode('MEMBERS'), 0, 'start', $max_rows, 'max', $max_rows, $fields_title, $shopping_cart, NULL, NULL, NULL, 'sort', NULL, $width, 'cart');
         $update_cart = build_url(array('page' => '_SELF', 'type' => 'update_cart'), '_SELF');
         $empty_cart = build_url(array('page' => '_SELF', 'type' => 'empty_cart'), '_SELF');
         $checkout = build_url(array('page' => '_SELF', 'type' => 'pay'), '_SELF');
         $payment_form = payment_form();
         $proceed_box = do_template('SHOPPING_CART_PROCEED', array('SUB_TOTAL' => float_format($sub_tot), 'SHIPPING_COST' => float_format($shipping_cost), 'GRAND_TOTAL' => float_format($sub_tot), 'CHECKOUT_URL' => $checkout, 'PROCEED' => do_lang_tempcode('PROCEED'), 'CURRENCY' => ecommerce_get_currency_symbol(), 'PAYMENT_FORM' => $payment_form));
     } else {
         $update_cart = new ocp_tempcode();
         $empty_cart = new ocp_tempcode();
         $checkout = new ocp_tempcode();
         $results_table = do_lang_tempcode('CART_EMPTY');
         $proceed_box = new ocp_tempcode();
     }
     $ecom_catalogue = $GLOBALS['SITE_DB']->query_value_null_ok('catalogues', 'c_name', array('c_ecommerce' => 1));
     $cont_shopping = is_null($ecom_catalogue) ? new ocp_tempcode() : build_url(array('page' => 'catalogues', 'type' => 'category', 'catalogue_name' => $ecom_catalogue), get_module_zone('catalogues'));
     //Product id string for hidden field in Shopping cart
     $pro_ids_val = is_array($pro_ids) ? implode(',', $pro_ids) : '';
     $allow_opt_out_tax = get_option('allow_opting_out_of_tax');
     $allow_opt_out_tax_value = get_order_tax_opt_out_status();
     return do_template('SHOPPING_CART_SCREEN', array('TITLE' => $title, 'RESULT_TABLE' => $results_table, 'CONTENT' => '', 'FORM_URL' => $update_cart, 'CONT_SHOPPING' => $cont_shopping, 'MESSAGE' => '', 'BACK' => $cont_shopping, 'PRO_IDS' => $pro_ids_val, 'EMPTY_CART' => $empty_cart, 'EMPTY' => do_lang_tempcode('EMPTY_CART'), 'UPDATE' => do_lang_tempcode('UPDATE'), 'CONTINUE_SHOPPING' => do_lang_tempcode('CONTINUE_SHOPPING'), 'PROCEED_BOX' => $proceed_box, 'ALLOW_OPTOUT_TAX' => $allow_opt_out_tax, 'ALLOW_OPTOUT_TAX_VALUE' => strval($allow_opt_out_tax_value)), NULL, false);
 }
Esempio n. 19
0
 /**
  * Standard aed_module table function.
  *
  * @param  array			Details to go to build_url for link to the next screen.
  * @return array			A pair: The choose table, Whether re-ordering is supported from this screen.
  */
 function nice_get_choose_table($url_map)
 {
     require_code('templates_results_table');
     $current_ordering = get_param('sort', 'tag_tag ASC');
     if (strpos($current_ordering, ' ') === false) {
         warn_exit(do_lang_tempcode('INTERNAL_ERROR'));
     }
     list($sortable, $sort_order) = explode(' ', $current_ordering, 2);
     $sortables = array('tag_tag' => do_lang_tempcode('COMCODE_TAG'), 'tag_title' => do_lang_tempcode('TITLE'), 'tag_dangerous_tag' => do_lang_tempcode('DANGEROUS_TAG'), 'tag_block_tag' => do_lang_tempcode('BLOCK_TAG'), 'tag_textual_tag' => do_lang_tempcode('TEXTUAL_TAG'), 'tag_enabled' => do_lang_tempcode('ENABLED'));
     $header_row = results_field_title(array(do_lang_tempcode('COMCODE_TAG'), do_lang_tempcode('TITLE'), do_lang_tempcode('DANGEROUS_TAG'), do_lang_tempcode('BLOCK_TAG'), do_lang_tempcode('TEXTUAL_TAG'), do_lang_tempcode('ENABLED'), do_lang_tempcode('ACTIONS')), $sortables, 'sort', $sortable . ' ' . $sort_order);
     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';
     $fields = new ocp_tempcode();
     require_code('form_templates');
     list($rows, $max_rows) = $this->get_entry_rows(false, $current_ordering);
     foreach ($rows as $row) {
         $edit_link = build_url($url_map + array('id' => $row['tag_tag']), '_SELF');
         $fields->attach(results_entry(array($row['tag_tag'], get_translated_text($row['tag_title']), $row['tag_dangerous_tag'] == 1 ? do_lang_tempcode('YES') : do_lang_tempcode('NO'), $row['tag_block_tag'] == 1 ? do_lang_tempcode('YES') : do_lang_tempcode('NO'), $row['tag_textual_tag'] == 1 ? do_lang_tempcode('YES') : do_lang_tempcode('NO'), $row['tag_enabled'] == 1 ? do_lang_tempcode('YES') : do_lang_tempcode('NO'), protect_from_escaping(hyperlink($edit_link, do_lang_tempcode('EDIT'), false, true, '#' . $row['tag_tag']))), true));
     }
     return array(results_table(do_lang($this->menu_label), get_param_integer('start', 0), 'start', either_param_integer('max', 20), 'max', $max_rows, $header_row, $fields, $sortables, $sortable, $sort_order), false);
 }
Esempio n. 20
0
 /**
  * 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));
 }
Esempio n. 21
0
 /**
  * Standard modular run function.
  *
  * @param  array		A map of parameters.
  * @return tempcode	The result of execution.
  */
 function run($map)
 {
     unset($map);
     require_all_lang();
     require_css('adminzone');
     require_code('actionlog');
     $start = get_param_integer('sa_start', 0);
     $max = get_param_integer('sa_max', 10);
     $sortables = array('date_and_time' => do_lang_tempcode('DATE_TIME'), 'the_type' => do_lang_tempcode('ACTION'));
     $test = explode(' ', get_param('sa_sort', 'date_and_time 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[] = 'sa_sort';
     require_code('templates_results_table');
     $fields_title = results_field_title(array(do_lang_tempcode('USERNAME'), do_lang_tempcode('DATE_TIME'), do_lang_tempcode('ACTION'), do_lang_tempcode('PARAMETER_A'), do_lang_tempcode('PARAMETER_B')), $sortables, 'sa_sort', $sortable . ' ' . $sort_order);
     $max_rows = $max;
     //Don't want to encourage pagination (there's a better module they can go to) $GLOBALS['SITE_DB']->query_value('adminlogs','COUNT(*)');
     $rows = $GLOBALS['SITE_DB']->query_select('adminlogs', array('the_type', 'param_a', 'param_b', 'the_user', 'ip', 'date_and_time'), NULL, 'ORDER BY ' . $sortable . ' ' . $sort_order, $max, $start);
     $fields = new ocp_tempcode();
     foreach ($rows as $myrow) {
         $username = $GLOBALS['FORUM_DRIVER']->get_username($myrow['the_user']);
         if (is_null($username)) {
             $username = do_lang('UNKNOWN');
         }
         $date = get_timezoned_date($myrow['date_and_time']);
         if (!is_null($myrow['param_a'])) {
             $a = $myrow['param_a'];
         } else {
             $a = '';
         }
         if (!is_null($myrow['param_b'])) {
             $b = $myrow['param_b'];
         } else {
             $b = '';
         }
         require_code('templates_interfaces');
         $_a = tpl_crop_text_mouse_over($a, 8);
         $_b = tpl_crop_text_mouse_over($b, 15);
         $type_str = do_lang($myrow['the_type'], $_a, $_b, NULL, NULL, false);
         if (is_null($type_str)) {
             $type_str = $myrow['the_type'];
         }
         $test = actionlog_linkage($myrow['the_type'], $a, $b, $_a, $_b);
         if (!is_null($test)) {
             list($_a, $_b) = $test;
         }
         $ip = tpl_crop_text_mouse_over($myrow['ip'], 12);
         $fields->attach(results_entry(array(escape_html($username), escape_html($date), $type_str, $_a, $_b)));
     }
     return results_table(do_lang_tempcode('ACTIONS'), $start, 'sa_start', $max, 'sa_max', $max_rows, $fields_title, $fields, $sortables, $sortable, $sort_order, 'sa_sort', new ocp_tempcode(), NULL, NULL, 5);
 }
Esempio n. 22
0
 /**
  * The UI to show a results table of moderation actions for a moderator.
  *
  * @return tempcode		The UI
  */
 function choose_action()
 {
     breadcrumb_set_parents(array(array('_SELF:_SELF:misc', do_lang_tempcode('VIEW_ACTION_LOGS'))));
     breadcrumb_set_self(do_lang_tempcode('RESULTS'));
     $title = get_page_title('VIEW_ACTION_LOGS');
     require_code('templates_internalise_screen');
     $test_tpl = internalise_own_screen($title);
     if (is_object($test_tpl)) {
         return $test_tpl;
     }
     $id = get_param_integer('id', -1);
     $start = get_param_integer('start', 0);
     $max = get_param_integer('max', 50);
     $sortables = array('date_and_time' => do_lang_tempcode('DATE_TIME'), 'the_type' => do_lang_tempcode('ACTION'));
     $test = explode(' ', get_param('sort', 'date_and_time 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';
     require_code('templates_results_table');
     $field_titles = array(do_lang_tempcode('USERNAME'), do_lang_tempcode('DATE_TIME'), do_lang_tempcode('ACTION'), do_lang_tempcode('PARAMETER_A'), do_lang_tempcode('PARAMETER_B'));
     if (addon_installed('securitylogging')) {
         $field_titles[] = do_lang_tempcode('_BANNED');
     }
     $fields_title = results_field_title($field_titles, $sortables, 'sort', $sortable . ' ' . $sort_order);
     $filter_to_type = get_param('to_type', '');
     $filter_param_a = get_param('param_a', '');
     $filter_param_b = get_param('param_b', '');
     $max_rows = 0;
     // Pull up our rows: forum
     if (get_forum_type() == 'ocf') {
         // Possible filter (called up by URL)
         $where = '1=1';
         if ($filter_to_type != '') {
             $where .= ' AND ' . db_string_equal_to('l_the_type', $filter_to_type);
         }
         if ($filter_param_a != '') {
             $where .= ' AND l_param_a LIKE \'' . db_encode_like('%' . $filter_param_a . '%') . '\'';
         }
         if ($filter_param_b != '') {
             $where .= ' AND l_param_b LIKE \'' . db_encode_like('%' . $filter_param_b . '%') . '\'';
         }
         if ($id != -1) {
             $where .= ' AND l_by=' . strval($id);
         }
         // Fetch
         $rows1 = $GLOBALS['FORUM_DB']->query('SELECT l_reason,id,l_by AS the_user,l_date_and_time AS date_and_time,l_the_type AS the_type,l_param_a AS param_a,l_param_b AS param_b FROM ' . $GLOBALS['FORUM_DB']->get_table_prefix() . 'f_moderator_logs WHERE ' . $where . ' ORDER BY ' . $sortable . ' ' . $sort_order, $max + $start);
         $max_rows += $GLOBALS['FORUM_DB']->query_value_null_ok_full('SELECT COUNT(*) FROM ' . $GLOBALS['FORUM_DB']->get_table_prefix() . 'f_moderator_logs WHERE ' . $where);
     } else {
         $rows1 = array();
     }
     // Possible filter (called up by URL)
     $where = '1=1';
     if ($filter_to_type != '') {
         $where .= ' AND ' . db_string_equal_to('the_type', $filter_to_type);
     }
     if ($filter_param_a != '') {
         $where .= ' AND param_a LIKE \'' . db_encode_like('%' . $filter_param_a . '%') . '\'';
     }
     if ($filter_param_b != '') {
         $where .= ' AND param_b LIKE \'' . db_encode_like('%' . $filter_param_b . '%') . '\'';
     }
     if ($id != -1) {
         $where .= ' AND the_user='******'SITE_DB']->query('SELECT id,the_user,date_and_time,the_type,param_a,param_b,ip FROM ' . get_table_prefix() . 'adminlogs WHERE ' . $where . ' ORDER BY ' . $sortable . ' ' . $sort_order, $max + $start);
     $max_rows += $GLOBALS['SITE_DB']->query_value_null_ok_full('SELECT COUNT(*) FROM ' . get_table_prefix() . 'adminlogs WHERE ' . $where);
     $rows = array_merge($rows1, $rows2);
     require_code('actionlog');
     $fields = new ocp_tempcode();
     $pos = 0;
     while (count($rows) != 0 && $pos - $start < $max) {
         $best = 0;
         // Initialise type to integer
         $_best = 0;
         // Initialise type to integer
         $best = NULL;
         $_best = NULL;
         foreach ($rows as $x => $row) {
             if (is_null($best) || $row['date_and_time'] < $_best && $sortable == 'date_and_time' && $sort_order == 'ASC' || $row['date_and_time'] > $_best && $sortable == 'date_and_time' && $sort_order == 'DESC' || intval($row['the_type']) < $_best && $sortable == 'the_type' && $sort_order == 'ASC' || intval($row['the_type']) > $_best && $sortable == 'the_type' && $sort_order == 'DESC') {
                 $best = $x;
                 if ($sortable == 'date_and_time') {
                     $_best = $row['date_and_time'];
                 }
                 if ($sortable == 'the_type') {
                     $_best = $row['the_type'];
                 }
             }
         }
         if ($pos >= $start) {
             $myrow = $rows[$best];
             $username = $GLOBALS['FORUM_DRIVER']->member_profile_hyperlink($myrow['the_user']);
             $mode = array_key_exists('l_reason', $myrow) ? 'ocf' : 'ocp';
             $url = build_url(array('page' => '_SELF', 'type' => 'view', 'id' => $myrow['id'], 'mode' => $mode), '_SELF');
             $mode_nice = $mode == 'ocp' ? 'ocPortal' : 'OCF';
             $date = hyperlink($url, get_timezoned_date($myrow['date_and_time']), false, true, $mode_nice . '/' . $row['the_type'] . '/' . strval($myrow['id']), NULL, NULL, NULL, '_top');
             if (!is_null($myrow['param_a'])) {
                 $a = $myrow['param_a'];
             } else {
                 $a = '';
             }
             if (!is_null($myrow['param_b'])) {
                 $b = $myrow['param_b'];
             } else {
                 $b = '';
             }
             require_code('templates_interfaces');
             $_a = tpl_crop_text_mouse_over($a, 8);
             $_b = tpl_crop_text_mouse_over($b, 15);
             $type_str = do_lang($myrow['the_type'], $_a, $_b, NULL, NULL, false);
             if (is_null($type_str)) {
                 $type_str = $myrow['the_type'];
             }
             $test = actionlog_linkage($myrow['the_type'], $a, $b, $_a, $_b);
             if (!is_null($test)) {
                 list($_a, $_b) = $test;
             }
             $result_entry = array($username, $date, $type_str, $_a, $_b);
             if (addon_installed('securitylogging')) {
                 $banned_test_1 = array_key_exists('ip', $myrow) ? $GLOBALS['SITE_DB']->query_value_null_ok('usersubmitban_ip', 'ip', array('ip' => $myrow['ip'])) : NULL;
                 $banned_test_2 = $GLOBALS['SITE_DB']->query_value_null_ok('usersubmitban_member', 'the_member', array('the_member' => $myrow['the_user']));
                 $banned_test_3 = $GLOBALS['FORUM_DRIVER']->is_banned($myrow['the_user']);
                 $banned = is_null($banned_test_1) && is_null($banned_test_2) && !$banned_test_3 ? do_lang_tempcode('NO') : do_lang_tempcode('YES');
                 $result_entry[] = $banned;
             }
             $fields->attach(results_entry($result_entry, true));
         }
         unset($rows[$best]);
         $pos++;
     }
     $table = results_table(do_lang_tempcode('ACTIONS'), $start, 'start', $max, 'max', $max_rows, $fields_title, $fields, $sortables, $sortable, $sort_order, 'sort');
     return do_template('ACTION_LOGS_SCREEN', array('_GUID' => 'd75c813e372c3ca8d1204609e54c9d65', 'TABLE' => $table, 'TITLE' => $title));
 }
Esempio n. 23
0
 /**
  * Standard aed_module table function.
  *
  * @param  array			Details to go to build_url for link to the next screen.
  * @return array			A pair: The choose table, Whether re-ordering is supported from this screen.
  */
 function nice_get_choose_table($url_map)
 {
     require_code('templates_results_table');
     $current_ordering = get_param('sort', 'title ASC', true);
     list($sortable, $sort_order) = array(substr($current_ordering, 0, strrpos($current_ordering, ' ')), substr($current_ordering, strrpos($current_ordering, ' ') + 1));
     $sortables = array('title' => do_lang_tempcode('TITLE'));
     if (db_has_subqueries($GLOBALS['SITE_DB']->connection_read)) {
         $sortables['(SELECT COUNT(*) FROM ' . get_table_prefix() . 'newsletter n JOIN ' . get_table_prefix() . 'newsletter_subscribe s ON n.id=s.newsletter_id WHERE code_confirm=0)'] = do_lang_tempcode('COUNT_MEMBERS');
     }
     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';
     $header_row = results_field_title(array(do_lang_tempcode('TITLE'), do_lang_tempcode('COUNT_MEMBERS'), do_lang_tempcode('ACTIONS')), $sortables, 'sort', $sortable . ' ' . $sort_order);
     $fields = new ocp_tempcode();
     require_code('form_templates');
     list($rows, $max_rows) = $this->get_entry_rows(false, $current_ordering);
     foreach ($rows as $row) {
         $edit_link = build_url($url_map + array('id' => $row['id']), '_SELF');
         $num_readers = $GLOBALS['SITE_DB']->query_value('newsletter n JOIN ' . get_table_prefix() . 'newsletter_subscribe s ON n.id=s.newsletter_id', 'COUNT(*)', array('code_confirm' => 0));
         $fields->attach(results_entry(array(get_translated_text($row['title']), integer_format($num_readers), protect_from_escaping(hyperlink($edit_link, do_lang_tempcode('EDIT'), false, true, '#' . strval($row['id'])))), true));
     }
     return array(results_table(do_lang($this->menu_label), get_param_integer('start', 0), 'start', either_param_integer('max', 20), 'max', $max_rows, $header_row, $fields, $sortables, $sortable, $sort_order), false);
 }
Esempio n. 24
0
 /**
  * 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));
 }
 /**
  * Standard aed_module table function.
  *
  * @param  array			Details to go to build_url for link to the next screen.
  * @return array			A pair: The choose table, Whether re-ordering is supported from this screen.
  */
 function nice_get_choose_table($url_map)
 {
     require_code('templates_results_table');
     $current_ordering = get_param('sort', 'cf_order ASC');
     if (strpos($current_ordering, ' ') === false) {
         warn_exit(do_lang_tempcode('INTERNAL_ERROR'));
     }
     list($sortable, $sort_order) = explode(' ', $current_ordering, 2);
     $sortables = array('cf_name' => do_lang_tempcode('NAME'), 'cf_owner_view' => do_lang_tempcode('OWNER_VIEW'), 'cf_owner_set' => do_lang_tempcode('OWNER_SET'), 'cf_public_view' => do_lang_tempcode('PUBLIC_VIEW'), 'cf_required' => do_lang_tempcode('REQUIRED'), 'cf_order' => do_lang_tempcode('ORDER'));
     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';
     $fh = array(do_lang_tempcode('NAME'), do_lang_tempcode('OWNER_VIEW'), do_lang_tempcode('OWNER_SET'), do_lang_tempcode('PUBLIC_VIEW'), do_lang_tempcode('REQUIRED'));
     $fh[] = do_lang_tempcode('SHOW_ON_JOIN_FORM');
     //$fh[]=do_lang_tempcode('SHOW_IN_POSTS');
     //$fh[]=do_lang_tempcode('SHOW_IN_POST_PREVIEWS');
     $fh[] = do_lang_tempcode('ORDER');
     $fh[] = do_lang_tempcode('ACTIONS');
     $header_row = results_field_title($fh, $sortables, 'sort', $sortable . ' ' . $sort_order);
     // Load up filters
     $hooks = find_all_hooks('systems', 'ocf_cpf_filter');
     $to_keep = array();
     foreach (array_keys($hooks) as $hook) {
         require_code('hooks/systems/ocf_cpf_filter/' . $hook);
         $_hook = object_factory('Hook_ocf_cpf_filter_' . $hook, true);
         if (is_null($_hook)) {
             continue;
         }
         $to_keep += $_hook->to_enable();
     }
     $fields = new ocp_tempcode();
     list($rows, $max_rows) = $this->get_entry_rows(false, $current_ordering, NULL);
     $changed = false;
     foreach ($rows as $row) {
         $order = post_param_integer('order_' . strval($row['id']), NULL);
         if (!is_null($order)) {
             $GLOBALS['FORUM_DB']->query_update('f_custom_fields', array('cf_order' => $order), array('id' => $row['id']), '', 1);
             $changed = true;
         }
     }
     if ($changed) {
         list($rows, $max_rows) = $this->get_entry_rows(false, $current_ordering);
     }
     require_code('form_templates');
     foreach ($rows as $row) {
         $trans = get_translated_text($row['cf_name'], $GLOBALS['FORUM_DB']);
         $used = true;
         if (substr($trans, 0, 4) == 'ocp_') {
             // See if it gets filtered
             if (!array_key_exists(substr($trans, 4), $to_keep)) {
                 $used = false;
             }
             $test = do_lang('SPECIAL_CPF__' . $trans, NULL, NULL, NULL, NULL, false);
             if (!is_null($test)) {
                 $trans = $test;
             }
         }
         $edit_link = build_url($url_map + array('id' => $row['id']), '_SELF');
         $orderlist = new ocp_tempcode();
         $num_cpfs = $GLOBALS['FORUM_DB']->query_value('f_custom_fields', 'COUNT(*)');
         $selected_one = false;
         $order = $row['cf_order'];
         for ($i = 0; $i < max($num_cpfs, $order); $i++) {
             $selected = $i === $order;
             if ($selected) {
                 $selected_one = true;
             }
             $orderlist->attach(form_input_list_entry(strval($i), $selected, integer_format($i + 1)));
         }
         if (!$selected_one) {
             $orderlist->attach(form_input_list_entry(strval($order), true, integer_format($order + 1)));
         }
         $orderer = do_template('TABLE_TABLE_ROW_CELL_SELECT', array('LABEL' => do_lang_tempcode('ORDER'), 'NAME' => 'order_' . strval($row['id']), 'LIST' => $orderlist));
         $fr = array();
         $fr[] = $trans;
         $fr[] = $row['cf_owner_view'] == 1 ? do_lang_tempcode('YES') : do_lang_tempcode('NO');
         $fr[] = $row['cf_owner_set'] == 1 ? do_lang_tempcode('YES') : do_lang_tempcode('NO');
         $fr[] = $row['cf_public_view'] == 1 ? do_lang_tempcode('YES') : do_lang_tempcode('NO');
         $fr[] = $row['cf_required'] == 1 ? do_lang_tempcode('YES') : do_lang_tempcode('NO');
         $fr[] = $row['cf_show_on_join_form'] == 1 ? do_lang_tempcode('YES') : do_lang_tempcode('NO');
         //$fr[]=($row['cf_show_in_posts']==1)?do_lang_tempcode('YES'):do_lang_tempcode('NO');
         //$fr[]=($row['cf_show_in_post_previews']==1)?do_lang_tempcode('YES'):do_lang_tempcode('NO');
         $fr[] = protect_from_escaping($orderer);
         if ($used) {
             $edit_link = hyperlink($edit_link, do_lang_tempcode('EDIT'), false, true, '#' . strval($row['id']));
         } else {
             $edit_link = do_lang_tempcode('UNUSED_CPF');
         }
         $fr[] = protect_from_escaping($edit_link);
         $fields->attach(results_entry($fr, true));
     }
     return array(results_table(do_lang($this->menu_label), get_param_integer('start', 0), 'start', either_param_integer('max', 20), 'max', $max_rows, $header_row, $fields, $sortables, $sortable, $sort_order, 'sort', NULL, NULL, NULL, 8, 'gdfg43tfdgdfgdrfgd', true), true);
 }
Esempio n. 26
0
 /**
  * Standard modular run function.
  *
  * @return tempcode	The result of execution.
  */
 function run()
 {
     $GLOBALS['HELPER_PANEL_PIC'] = 'pagepics/errorlog';
     $GLOBALS['HELPER_PANEL_TUTORIAL'] = 'tut_disaster';
     require_lang('errorlog');
     $title = get_page_title('ERROR_LOG');
     require_code('templates_internalise_screen');
     $test_tpl = internalise_own_screen($title);
     if (is_object($test_tpl)) {
         return $test_tpl;
     }
     // Read in errors
     if (is_readable(get_custom_file_base() . '/data_custom/errorlog.php')) {
         if (filesize(get_custom_file_base() . '/data_custom/errorlog.php') > 1024 * 1024) {
             $myfile = fopen(get_custom_file_base() . '/data_custom/errorlog.php', 'rt');
             fseek($myfile, -1024 * 500, SEEK_END);
             $lines = explode(chr(10), fread($myfile, 1024 * 500));
             fclose($myfile);
             unset($lines[0]);
             $lines[] = '...';
         } else {
             $lines = file(get_custom_file_base() . '/data_custom/errorlog.php');
         }
     } else {
         $lines = array();
     }
     $stuff = array();
     foreach ($lines as $line) {
         $_line = trim($line);
         if ($_line != '' && strpos($_line, '<?php') === false) {
             $matches = array();
             if (preg_match('#\\[(.+?) (.+?)\\] (.+?):  ?(.*)#', $_line, $matches) != 0) {
                 $stuff[] = $matches;
             }
         }
     }
     // Put errors into table
     $start = get_param_integer('start', 0);
     $max = get_param_integer('max', 50);
     $sortables = array('date_and_time' => do_lang_tempcode('DATE_TIME'));
     $test = explode(' ', get_param('sort', 'date_and_time 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 == 'DESC') {
         $stuff = array_reverse($stuff);
     }
     require_code('templates_results_table');
     $fields_title = results_field_title(array(do_lang_tempcode('DATE_TIME'), do_lang_tempcode('TYPE'), do_lang_tempcode('MESSAGE')), $sortables, 'sort', $sortable . ' ' . $sort_order);
     $fields = new ocp_tempcode();
     for ($i = $start; $i < $start + $max; $i++) {
         if (!array_key_exists($i, $stuff)) {
             break;
         }
         $message = str_replace(get_file_base(), '', $stuff[$i][4]);
         $fields->attach(results_entry(array(escape_html($stuff[$i][1] . ' ' . $stuff[$i][2]), escape_html($stuff[$i][3]), escape_html($message))));
     }
     $error = results_table(do_lang_tempcode('ERROR_LOG'), $start, 'start', $max, 'max', $i, $fields_title, $fields, $sortables, $sortable, $sort_order, 'sort', new ocp_tempcode());
     // Read in end of permissions file
     require_all_lang();
     if (is_readable(get_custom_file_base() . '/data_custom/permissioncheckslog.php')) {
         $myfile = @fopen(get_custom_file_base() . '/data_custom/permissioncheckslog.php', 'rt');
         if ($myfile !== false) {
             fseek($myfile, -40000, SEEK_END);
             $data = '';
             while (!feof($myfile)) {
                 $data .= fread($myfile, 8192);
             }
             fclose($myfile);
             $lines = explode(chr(10), $data);
             if (count($lines) != 0) {
                 if (strpos($lines[0], '<' . '?php') !== false) {
                     array_shift($lines);
                 } else {
                     if (strlen($data) == 40000) {
                         $lines[0] = '...';
                     }
                 }
             }
             foreach ($lines as $i => $line) {
                 $matches = array();
                 if (preg_match('#^\\s+has\\_specific\\_permission: (\\w+)#', $line, $matches) != 0) {
                     $looked_up = do_lang('PT_' . $matches[1], NULL, NULL, NULL, NULL, false);
                     if (!is_null($looked_up)) {
                         $line = str_replace($matches[1], $looked_up, $line);
                         $lines[$i] = $line;
                     }
                 }
             }
         }
     }
     // Put permssions into table
     $permission = implode(chr(10), $lines);
     return do_template('ERRORLOG_SCREEN', array('_GUID' => '9186c7beb6b722a52f39e2cbe16aded6', 'TITLE' => $title, 'ERROR' => $error, 'PERMISSION' => $permission));
 }
Esempio n. 27
0
 /**
  * UI to show details of an order
  *
  * @return tempcode	The interface.
  */
 function order_details()
 {
     $id = get_param_integer('id');
     $title = get_page_title('MY_ORDER_DETAILS');
     $order_title = do_lang('CART_ORDER', $id);
     //pagination
     $start = get_param_integer('start', 0);
     $max = get_param_integer('max', 10);
     require_code('templates_results_browser');
     require_code('templates_results_table');
     $sortables = array();
     $query_sort = explode(' ', get_param('sort', 'p_name ASC'), 2);
     if (count($query_sort) == 1) {
         $query_sort[] = 'ASC';
     }
     list($sortable, $sort_order) = $query_sort;
     $fields_title = results_field_title(array(do_lang_tempcode('SLNO'), do_lang_tempcode('PRODUCT_NAME'), do_lang_tempcode('THE_PRICE'), do_lang_tempcode('QUANTITY'), do_lang_tempcode('STATUS')), $sortables, 'sort', $sortable . ' ' . $sort_order);
     $max_rows = $GLOBALS['SITE_DB']->query_value_null_ok('shopping_order_details', 'COUNT(*)', array('order_id' => $id));
     $results_browser = results_browser(do_lang_tempcode('ORDERS'), NULL, $start, 'start', $max, 'max', $max_rows, NULL, 'show_orders', true, true);
     $rows = $GLOBALS['SITE_DB']->query_select('shopping_order_details', array('*'), array('order_id' => $id), 'ORDER BY ' . $sortable . ' ' . $sort_order, $max, $start);
     $product_entries = new ocp_tempcode();
     breadcrumb_set_parents(array(array('_SEARCH:admin_ecommerce:ecom_usage', do_lang_tempcode('ECOMMERCE')), array('_SELF:_SELF:misc', do_lang_tempcode('ORDERS')), array('_SELF:_SELF:show_orders', do_lang_tempcode('ORDER_LIST'))));
     foreach ($rows as $row) {
         $product_info_url = build_url(array('page' => 'catalogues', 'type' => 'entry', 'id' => $row['p_id']), get_module_zone('catalogues'));
         $product_name = $row['p_name'];
         $product = hyperlink($product_info_url, $product_name, false, true, do_lang('VIEW'));
         $product_entries->attach(results_entry(array(escape_html(strval($row['p_id'])), $product, ecommerce_get_currency_symbol() . escape_html(float_format($row['p_price'], 2)), escape_html(strval($row['p_quantity'])), do_lang($row['dispatch_status'])), false, NULL));
     }
     $text = do_lang_tempcode('ORDER_DETAILS_TEXT');
     //Collecting order details
     $rows = $GLOBALS['SITE_DB']->query_select('shopping_order', array('*'), array('id' => $id), '', 1);
     if (!array_key_exists(0, $rows)) {
         warn_exit(do_lang_tempcode('MISSING_RESOURCE'));
     }
     $data = $rows[0];
     $results_table = results_table(do_lang_tempcode('PRODUCTS'), 0, 'start', $max_rows, 'max', $max_rows, $fields_title, $product_entries, $sortables, $sortable, $sort_order, 'sort', NULL, NULL, 'cart');
     $ordered_by_member_id = $data['c_member'];
     $ordered_by_username = $GLOBALS['FORUM_DRIVER']->get_username($data['c_member']);
     $self_url = get_self_url(true, true);
     $ordr_act_submit = build_url(array('page' => '_SELF', 'type' => 'order_act', 'id' => $id, 'redirect' => $self_url), '_SELF');
     $order_actions = do_template('ADMIN_ORDER_ACTIONS', array('ORDER_TITLE' => $order_title, 'ORDR_ACT_URL' => $ordr_act_submit, 'ORDER_STATUS' => do_lang($data['order_status'])));
     //Shipping address display
     $row = $GLOBALS['SITE_DB']->query_select('shopping_order_addresses', array('*'), array('order_id' => $id), '', 1);
     if (array_key_exists(0, $row)) {
         $address = $row[0];
         $shipping_address = do_template('SHIPPING_ADDRESS', array('ADDRESS_NAME' => $address['address_name'], 'ADDRESS_STREET' => $address['address_street'], 'ADDRESS_CITY' => $address['address_city'], 'ADDRESS_ZIP' => $address['address_zip'], 'ADDRESS_COUNTRY' => $address['address_country'], 'RECEIVER_EMAIL' => $address['receiver_email']));
     } else {
         $shipping_address = new ocp_tempcode();
     }
     return do_template('ECOM_ADMIN_ORDERS_DETAILS_SCREEN', array('TITLE' => $title, 'TEXT' => $text, 'CURRENCY' => get_option('currency'), 'RESULT_TABLE' => $results_table, 'RESULTS_BROWSER' => $results_browser, 'ORDER_NUMBER' => strval($id), 'ADD_DATE' => get_timezoned_date($data['add_date'], true, false, true, true), 'TOTAL_PRICE' => float_format($data['tot_price'], 2), 'ORDERED_BY_MEMBER_ID' => strval($ordered_by_member_id), 'ORDERED_BY_USERNAME' => $ordered_by_username, 'ORDER_STATUS' => do_lang($data['order_status']), 'NOTES' => $data['notes'], 'PURCHASED_VIA' => $data['purchase_through'], 'ORDER_ACTIONS' => $order_actions, 'SHIPPING_ADDRESS' => $shipping_address));
 }
Esempio n. 28
0
 /**
  * Standard aed_module table function.
  *
  * @param  array			Details to go to build_url for link to the next screen.
  * @return array			A pair: The choose table, Whether re-ordering is supported from this screen.
  */
 function nice_get_choose_table($url_map)
 {
     require_code('templates_results_table');
     $current_ordering = get_param('sort', 'the_message ASC');
     if (strpos($current_ordering, ' ') === false) {
         warn_exit(do_lang_tempcode('INTERNAL_ERROR'));
     }
     list($sortable, $sort_order) = explode(' ', $current_ordering, 2);
     $sortables = array('the_message' => do_lang_tempcode('MESSAGE'), 'days' => do_lang_tempcode('NUMBER_DAYS'), 'order_time' => do_lang_tempcode('ORDER_DATE'), 'user_id' => do_lang_tempcode('OWNER'));
     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';
     $header_row = results_field_title(array(do_lang_tempcode('MESSAGE'), do_lang_tempcode('NUMBER_DAYS'), do_lang_tempcode('ORDER_DATE'), do_lang_tempcode('_UP_FOR'), do_lang_tempcode('OWNER'), do_lang_tempcode('ACTIONS')), $sortables, 'sort', $sortable . ' ' . $sort_order);
     $fields = new ocp_tempcode();
     require_code('form_templates');
     list($rows, $max_rows) = $this->get_entry_rows(false, $current_ordering);
     foreach ($rows as $row) {
         $edit_link = build_url($url_map + array('id' => $row['id']), '_SELF');
         $username = protect_from_escaping($GLOBALS['FORUM_DRIVER']->member_profile_hyperlink($row['user_id']));
         $activation_time = $row['activation_time'];
         $days = is_null($activation_time) ? '' : float_format(round((time() - $activation_time) / 60 / 60 / 24, 3));
         $fields->attach(results_entry(array(protect_from_escaping(get_translated_tempcode($row['the_message'])), integer_format($row['days']), get_timezoned_date($row['order_time']), $row['active_now'] == 1 ? $days : do_lang_tempcode('NA_EM'), $username, protect_from_escaping(hyperlink($edit_link, do_lang_tempcode('EDIT'), false, true, '#' . strval($row['id'])))), true));
     }
     return array(results_table(do_lang($this->menu_label), get_param_integer('start', 0), 'start', either_param_integer('max', 20), 'max', $max_rows, $header_row, $fields, $sortables, $sortable, $sort_order), false);
 }
Esempio n. 29
0
 /**
  * The UI to show a usergroup.
  *
  * @return tempcode		The UI
  */
 function usergroup()
 {
     $id = get_param_integer('id');
     if ($id == db_get_first_id()) {
         warn_exit(do_lang_tempcode('INTERNAL_ERROR'));
     }
     $map = has_specific_permission(get_member(), 'see_hidden_groups') ? array('id' => $id) : array('id' => $id, 'g_hidden' => 0);
     $groups = $GLOBALS['FORUM_DB']->query_select('f_groups', array('*'), $map, '', 1);
     if (!array_key_exists(0, $groups)) {
         warn_exit(do_lang_tempcode('MISSING_RESOURCE'));
     }
     $group = $groups[0];
     $club = $group['g_is_private_club'] == 1;
     $name = get_translated_text($group['g_name'], $GLOBALS['FORUM_DB']);
     $title = get_page_title($club ? 'CLUB' : 'USERGROUP', true, array(escape_html($name)));
     // Leadership
     if (!is_null($group['g_group_leader']) && !is_null($GLOBALS['FORUM_DRIVER']->get_username($group['g_group_leader']))) {
         $leader_name = $GLOBALS['FORUM_DRIVER']->get_username($group['g_group_leader']);
         if (is_null($leader_name)) {
             $leader_name = do_lang('UNKNOWN');
         }
         $leader_url = build_url(array('page' => 'members', 'type' => 'view', 'id' => $group['g_group_leader']), get_module_zone('members'));
         $leader_link = hyperlink($leader_url, $leader_name, false, true);
         $leader = paragraph(do_lang_tempcode('GROUP_LED_BY', $leader_link), 'gfgdfggdf');
     } else {
         $leader = new ocp_tempcode();
     }
     // Promotion
     if (addon_installed('points') && !is_null($group['g_promotion_threshold']) && !is_null($group['g_promotion_target'])) {
         $promote_link = ocf_get_group_link($group['g_promotion_target']);
         $promotion_info = do_lang_tempcode('OCF_PROMOTION_INFO', integer_format($group['g_promotion_threshold']), $promote_link->evaluate());
     } else {
         $promotion_info = new ocp_tempcode();
     }
     // To add
     if (ocf_may_control_group($id, get_member())) {
         $add_url = build_url(array('page' => '_SELF', 'type' => 'add_to', 'id' => $id), '_SELF');
     } else {
         $add_url = new ocp_tempcode();
     }
     // To apply
     $my_groups = $GLOBALS['FORUM_DRIVER']->get_members_groups(get_member(), false, false);
     if (is_guest()) {
         $apply_url = new ocp_tempcode();
         $apply_text = new ocp_tempcode();
     } else {
         if (!in_array($id, $my_groups)) {
             $apply_url = build_url(array('page' => '_SELF', 'type' => 'apply', 'id' => $id), '_SELF');
             $apply_text = do_lang_tempcode('APPLY_TO_GROUP');
         } elseif (ocf_get_member_primary_group(get_member()) != $id) {
             $apply_url = build_url(array('page' => '_SELF', 'type' => 'resign', 'id' => $id), '_SELF');
             $apply_text = do_lang_tempcode('RESIGN_FROM_GROUP');
         } else {
             $apply_url = new ocp_tempcode();
             $apply_text = new ocp_tempcode();
         }
     }
     require_code('templates_results_table');
     $sortables = array();
     list($sortable, $sort_order) = explode(' ', get_param('p_sort', 'date_and_time DESC'));
     // Primary members
     $start = get_param_integer('p_start', 0);
     $max = get_param_integer('p_max', 50);
     $_primary_members = ocf_get_group_members_raw($id, true, true, false, false, $max, $start);
     if (count($_primary_members) > 0) {
         $max_rows = ocf_get_group_members_raw_count($id, true, true, false, false);
         $primary_members = new ocp_tempcode();
         foreach ($_primary_members as $i => $primary_member) {
             $url = $GLOBALS['FORUM_DRIVER']->member_profile_url($primary_member['gm_member_id'], false, true);
             $temp = do_template('OCF_VIEW_GROUP_MEMBER', array('_GUID' => 'b96b674ac713e9790ecb78c15af1baab', 'NAME' => $primary_member['m_username'], 'URL' => $url));
             $primary_members->attach(results_entry(array($temp)));
         }
         $fields_title = results_field_title(array(do_lang_tempcode('PRIMARY_MEMBERS')), $sortables, 'p_sort', $sortable . ' ' . $sort_order);
         $primary_members = results_table(do_lang_tempcode('PRIMARY_MEMBERS'), $start, 'p_start', $max, 'p_max', $max_rows, $fields_title, $primary_members, $sortables, $sortable, $sort_order, 'p_sort', NULL, NULL, NULL, 6);
     } else {
         $primary_members = new ocp_tempcode();
     }
     $edit_url = new ocp_tempcode();
     $s_start = get_param_integer('s_start', 0);
     $s_max = get_param_integer('s_max', 50);
     $_secondary_members = ocf_get_group_members_raw($id, false, true, true, ocf_may_control_group($id, get_member()), $s_max, $s_start);
     $secondary_members = new ocp_tempcode();
     $prospective_members = new ocp_tempcode();
     $s_max_rows = ocf_get_group_members_raw_count($id, false, false, true, ocf_may_control_group($id, get_member()));
     $d_max_rows = ocf_get_group_members_raw_count($id, false, true, true, ocf_may_control_group($id, get_member()));
     foreach ($_secondary_members as $secondary_member) {
         $m_username = $GLOBALS['FORUM_DRIVER']->get_member_row_field($secondary_member['gm_member_id'], 'm_username');
         if (is_null($m_username)) {
             continue;
         }
         if ($secondary_member['gm_validated'] == 1) {
             $url = $GLOBALS['FORUM_DRIVER']->member_profile_url($secondary_member['gm_member_id'], false, true);
             $remove_url = build_url(array('page' => '_SELF', 'type' => 'remove_from', 'id' => $id, 'member_id' => $secondary_member['gm_member_id']), '_SELF');
             $temp = do_template('OCF_VIEW_GROUP_MEMBER' . (ocf_may_control_group($id, get_member()) ? '_SECONDARY' : ''), array('REMOVE_URL' => $remove_url, 'NAME' => $m_username, 'URL' => $url));
             $secondary_members->attach(results_entry(array($temp)));
         } elseif (!$add_url->is_empty()) {
             $url = $GLOBALS['FORUM_DRIVER']->member_profile_url($secondary_member['gm_member_id'], false, true);
             $accept_url = build_url(array('page' => '_SELF', 'type' => 'accept', 'id' => $id, 'member_id' => $secondary_member['gm_member_id']), '_SELF');
             $decline_url = build_url(array('page' => '_SELF', 'type' => 'decline', 'id' => $id, 'member_id' => $secondary_member['gm_member_id']), '_SELF');
             $temp = do_template('OCF_VIEW_GROUP_MEMBER_PROSPECTIVE', array('_GUID' => '16e93cf50a14e3b6a3bdf31525fd5e7f', 'ACCEPT_URL' => $accept_url, 'DECLINE_URL' => $decline_url, 'NAME' => $m_username, 'URL' => $url));
             $prospective_members->attach(results_entry(array($temp)));
         }
     }
     if (!$secondary_members->is_empty()) {
         $fields_title = results_field_title(array(do_lang_tempcode('SECONDARY_MEMBERS')), $sortables, 'p_sort', $sortable . ' ' . $sort_order);
         $secondary_members = results_table(do_lang_tempcode('SECONDARY_MEMBERS'), $s_start, 's_start', $s_max, 's_max', $s_max_rows, $fields_title, $secondary_members, $sortables, $sortable, $sort_order, 's_sort', NULL, NULL, NULL, 6);
     }
     if (!$prospective_members->is_empty()) {
         $fields_title = results_field_title(array(do_lang_tempcode('PROSPECTIVE_MEMBERS')), $sortables, 'p_sort', $sortable . ' ' . $sort_order);
         $prospective_members = results_table(do_lang_tempcode('PROSPECTIVE_MEMBERS'), $s_start, 's_start', $s_max, 's_max', $d_max_rows, $fields_title, $prospective_members, $sortables, $sortable, $sort_order, 'd_sort', NULL, NULL, NULL, 6);
     } elseif (has_actual_page_access(get_member(), 'cms_ocf_groups', get_module_zone('cms_ocf_groups'))) {
         $is_super_admin = $group['g_is_super_admin'];
         if (!has_specific_permission(get_member(), 'control_usergroups') || $is_super_admin == 1) {
             $leader_tmp = $group['g_group_leader'];
             if ($leader_tmp == get_member()) {
                 $edit_url = build_url(array('page' => 'cms_ocf_groups', 'type' => '_ed', 'id' => $id), get_module_zone('cms_ocf_groups'));
             }
         } else {
             $edit_url = build_url(array('page' => 'cms_ocf_groups', 'type' => '_ed', 'id' => $id), get_module_zone('cms_ocf_groups'));
         }
     }
     breadcrumb_set_self(make_string_tempcode(escape_html($name)));
     breadcrumb_set_parents(array(array('_SELF:_SELF:misc', do_lang_tempcode('USERGROUPS'))));
     if (has_actual_page_access(get_member(), 'admin_ocf_groups', get_module_zone('admin_ocf_groups'))) {
         $edit_url = build_url(array('page' => 'admin_ocf_groups', 'type' => '_ed', 'id' => $id), get_module_zone('admin_ocf_groups'));
     }
     $club_forum = NULL;
     if ($group['g_is_private_club'] == 1) {
         $club_forum = $GLOBALS['FORUM_DB']->query_value_null_ok('f_forums f LEFT JOIN ' . $GLOBALS['FORUM_DB']->get_table_prefix() . 'translate t ON t.id=f.f_description', 'f.id', array('text_original' => do_lang('FORUM_FOR_CLUB', $name)));
     }
     $group_name = get_translated_text($group['g_name'], $GLOBALS['FORUM_DB']);
     $GLOBALS['META_DATA'] += array('created' => '', 'creator' => is_null($group['g_group_leader']) ? '' : $GLOBALS['FORUM_DRIVER']->get_username($group['g_group_leader']), 'publisher' => '', 'modified' => '', 'type' => 'Usergroup', 'title' => $group_name, 'identifier' => '_SEARCH:groups:view:' . strval($id), 'description' => '', 'image' => find_theme_image('bigicons/usergroups'));
     require_javascript('javascript_ajax');
     require_javascript('javascript_ajax_people_lists');
     $forum_id = NULL;
     if ($club) {
         $forum_id = $GLOBALS['FORUM_DB']->query_value_null_ok('f_forums', 'id', array('f_name' => $group_name, 'f_category_id' => intval(get_option('club_forum_parent_category')), 'f_parent_forum' => intval(get_option('club_forum_parent_forum'))));
     }
     return do_template('OCF_VIEW_GROUP_SCREEN', array('_GUID' => 'fc6cac5c73f92ab4410b492d58976dbe', 'GROUP_NAME' => $group_name, 'ID' => strval($id), 'FORUM' => is_null($forum_id) ? '' : strval($forum_id), 'CLUB' => $club, 'EDIT_URL' => $edit_url, 'TITLE' => $title, 'LEADER' => $leader, 'PROMOTION_INFO' => $promotion_info, 'ADD_URL' => $add_url, 'APPLY_URL' => $apply_url, 'APPLY_TEXT' => $apply_text, 'PRIMARY_MEMBERS' => $primary_members, 'SECONDARY_MEMBERS' => $secondary_members, 'PROSPECTIVE_MEMBERS' => $prospective_members));
 }
Esempio n. 30
0
 /**
  * Choose a message.
  *
  * @return tempcode	The message choose screen.
  */
 function choose_message()
 {
     $title = get_page_title('CONTACT_US_MESSAGING');
     $fields = new ocp_tempcode();
     $start = get_param_integer('start', 0);
     $max = get_param_integer('max', 30);
     require_code('templates_results_table');
     $max_rows = 0;
     $rows = $GLOBALS['FORUM_DRIVER']->show_forum_topics(get_option('messaging_forum_name'), $max, $start, $max_rows);
     if (!is_null($rows)) {
         foreach ($rows as $i => $row) {
             $name = $row['firsttitle'];
             if (trim($name) == '') {
                 $name = do_lang('UNKNOWN');
             }
             $looking_at = $row['title'];
             if ($row['description'] != '') {
                 $looking_at = $row['description'];
             }
             $id = substr($looking_at, strrpos($looking_at, '_') + 1);
             $message_type = substr($looking_at, strpos($looking_at, '#') + 1, strrpos($looking_at, '_') - strpos($looking_at, '#') - 1);
             if ($message_type == '') {
                 continue;
             }
             $url = build_url(array('page' => '_SELF', 'type' => 'view', 'id' => $id, 'message_type' => $message_type), '_SELF');
             //$display_string=do_lang_tempcode('MESSAGE_DETAILS',get_timezoned_date($row['firsttime']),$message_type);
             $fields->attach(results_entry(array(hyperlink($url, $name, false, true), get_timezoned_date($row['firsttime']), $message_type), true));
             //			do_template('INDEX_SCREEN_ENTRY',array('URL'=>$url,'NAME'=>$name,'DISPLAY_STRING'=>$display_string))
         }
     }
     $fields_title = results_field_title(array(do_lang_tempcode('TITLE'), do_lang_tempcode('DATE'), do_lang_tempcode('TYPE')));
     $results_table = results_table('messages', $start, 'start', $max, 'max', $max_rows, $fields_title, $fields, NULL, NULL, NULL, NULL, paragraph(do_lang_tempcode('SELECT_A_MESSAGE')));
     return do_template('RESULTS_TABLE_SCREEN', array('TITLE' => $title, 'RESULTS_TABLE' => $results_table));
 }