Beispiel #1
0
 /**
  * Standard modular run function.
  *
  * @return tempcode	The result of execution.
  */
 function run()
 {
     if (!addon_installed('calendar')) {
         return new ocp_tempcode();
     }
     require_lang('calendar');
     $bits = new ocp_tempcode();
     if (get_option('calendar_show_stats_count_events', true) == '1') {
         $bits->attach(do_template('BLOCK_SIDE_STATS_SUBLINE', array('KEY' => do_lang_tempcode('EVENTS'), 'VALUE' => integer_format($GLOBALS['SITE_DB']->query_value('calendar_events', 'COUNT(*)')))));
     }
     if (get_option('calendar_show_stats_count_events_this_week', true) == '1') {
         require_code('calendar');
         $events = calendar_matches($GLOBALS['FORUM_DRIVER']->get_guest_id(), true, utctime_to_usertime(time()), utctime_to_usertime(time() + 60 * 60 * 24 * 7));
         $bits->attach(do_template('BLOCK_SIDE_STATS_SUBLINE', array('KEY' => do_lang_tempcode('EVENTS_THIS_WEEK'), 'VALUE' => integer_format(count($events)))));
     }
     if (get_option('calendar_show_stats_count_events_this_month', true) == '1') {
         require_code('calendar');
         $events = calendar_matches($GLOBALS['FORUM_DRIVER']->get_guest_id(), true, utctime_to_usertime(time()), utctime_to_usertime(time() + 60 * 60 * 24 * 31));
         $bits->attach(do_template('BLOCK_SIDE_STATS_SUBLINE', array('KEY' => do_lang_tempcode('EVENTS_THIS_MONTH'), 'VALUE' => integer_format(count($events)))));
     }
     if (get_option('calendar_show_stats_count_events_this_year', true) == '1') {
         require_code('calendar');
         $events = calendar_matches($GLOBALS['FORUM_DRIVER']->get_guest_id(), true, utctime_to_usertime(time()), utctime_to_usertime(time() + 60 * 60 * 24 * 365));
         $bits->attach(do_template('BLOCK_SIDE_STATS_SUBLINE', array('KEY' => do_lang_tempcode('EVENTS_THIS_YEAR'), 'VALUE' => integer_format(count($events)))));
     }
     if ($bits->is_empty()) {
         return new ocp_tempcode();
     }
     $section = do_template('BLOCK_SIDE_STATS_SECTION', array('SECTION' => do_lang_tempcode('CALENDAR'), 'CONTENT' => $bits));
     return $section;
 }
Beispiel #2
0
 /**
  * Standard modular run function.
  *
  * @return tempcode	The result of execution.
  */
 function run()
 {
     if (!addon_installed('downloads')) {
         return new ocp_tempcode();
     }
     require_lang('downloads');
     require_code('downloads_stats');
     $bits = new ocp_tempcode();
     if (get_option('downloads_show_stats_count_total', true) == '1') {
         $bits->attach(do_template('BLOCK_SIDE_STATS_SUBLINE', array('_GUID' => 'ff2bd884d88ddc8c5a81cff897f99a5a', 'KEY' => do_lang_tempcode('COUNT_TOTAL'), 'VALUE' => integer_format(get_num_archive_downloads()))));
     }
     if (get_option('downloads_show_stats_count_archive', true) == '1') {
         $bits->attach(do_template('BLOCK_SIDE_STATS_SUBLINE', array('_GUID' => '3d221f2145581a3af51c8948f28b7ac7', 'KEY' => do_lang_tempcode('COUNT_ARCHIVE'), 'VALUE' => get_download_archive_size())));
     }
     if (get_option('downloads_show_stats_count_downloads', true) == '1') {
         $bits->attach(do_template('BLOCK_SIDE_STATS_SUBLINE', array('_GUID' => '47c544ef053f9be47e2c48c3a694da1c', 'KEY' => do_lang_tempcode('COUNT_DOWNLOADS'), 'VALUE' => integer_format(get_num_downloads_downloaded()))));
     }
     if (get_option('downloads_show_stats_count_bandwidth', true) == '1') {
         $bits->attach(do_template('BLOCK_SIDE_STATS_SUBLINE', array('_GUID' => 'b2589ae83652953ece220267043d75c9', 'KEY' => do_lang_tempcode('COUNT_BANDWIDTH'), 'VALUE' => clean_file_size(get_download_bandwidth()))));
     }
     if ($bits->is_empty()) {
         return new ocp_tempcode();
     }
     $files = do_template('BLOCK_SIDE_STATS_SECTION', array('_GUID' => '99ae3f35b3e5eda18901e97ac385d99c', 'SECTION' => do_lang_tempcode('SECTION_DOWNLOADS'), 'CONTENT' => $bits));
     return $files;
 }
Beispiel #3
0
/**
 * A page is not validated, so show a warning.
 *
 * @param  ID_TEXT		The zone the page is being loaded from
 * @param  ID_TEXT		The codename of the page
 * @param  tempcode		The edit URL (blank if no edit access)
 * @return tempcode		The warning
 */
function get_page_warning_details($zone, $codename, $edit_url)
{
    $warning_details = new ocp_tempcode();
    if (!has_specific_permission(get_member(), 'jump_to_unvalidated')) {
        access_denied('SPECIFIC_PERMISSION', 'jump_to_unvalidated');
    }
    $uv_warning = do_lang_tempcode(get_param_integer('redirected', 0) == 1 ? 'UNVALIDATED_TEXT_NON_DIRECT' : 'UNVALIDATED_TEXT');
    // Wear sun cream
    if (!$edit_url->is_empty()) {
        $menu_links = $GLOBALS['SITE_DB']->query('SELECT DISTINCT i_menu FROM ' . get_table_prefix() . 'menu_items WHERE ' . db_string_equal_to('i_url', $zone . ':' . $codename) . ' OR ' . db_string_equal_to('i_url', '_SEARCH:' . $codename));
        if (count($menu_links) != 0) {
            $menu_items_linking = new ocp_tempcode();
            foreach ($menu_links as $menu_link) {
                if (!$menu_items_linking->is_empty()) {
                    $menu_items_linking->attach(do_lang_tempcode('LIST_SEP'));
                }
                $menu_edit_url = build_url(array('page' => 'admin_menus', 'type' => 'edit', 'id' => $menu_link['i_menu']), get_module_zone('admin_menus'));
                $menu_items_linking->attach(hyperlink($menu_edit_url, $menu_link['i_menu'], false, true));
            }
            $uv_warning = do_lang_tempcode('UNVALIDATED_TEXT_STAFF', $menu_items_linking);
        }
    }
    $warning_details->attach(do_template('WARNING_TABLE', array('WARNING' => $uv_warning)));
    return $warning_details;
}
 /**
  * Standard modular run function.
  *
  * @param  array		A map of parameters.
  * @return tempcode	The result of execution.
  */
 function run($map)
 {
     require_code('downloads');
     require_css('downloads');
     require_lang('downloads');
     require_code('ocfiltering');
     $number = array_key_exists('param', $map) ? intval($map['param']) : 10;
     $filter = array_key_exists('filter', $map) ? $map['filter'] : '*';
     $zone = array_key_exists('zone', $map) ? $map['zone'] : get_module_zone('downloads');
     $sql_filter = ocfilter_to_sqlfragment($filter, 'p.category_id', 'download_categories', 'parent_id', 'p.category_id', 'id');
     // Note that the parameters are fiddled here so that category-set and record-set are the same, yet SQL is returned to deal in an entirely different record-set (entries' record-set)
     $rows = $GLOBALS['SITE_DB']->query('SELECT * FROM ' . get_table_prefix() . 'download_downloads p WHERE validated=1 AND (' . $sql_filter . ') ORDER BY add_date DESC', $number);
     $title = do_lang_tempcode('RECENT', make_string_tempcode(integer_format($number)), do_lang_tempcode('SECTION_DOWNLOADS'));
     if (array_key_exists('title', $map) && $map['title'] != '') {
         $title = protect_from_escaping(escape_html($map['title']));
     }
     $out = new ocp_tempcode();
     foreach ($rows as $i => $row) {
         if ($i != 0) {
             $out->attach(do_template('BLOCK_SEPARATOR'));
         }
         $out->attach(get_download_html($row, true, true, $zone));
     }
     if ($out->is_empty()) {
         if (has_actual_page_access(NULL, 'cms_downloads', NULL, NULL) && has_submit_permission('mid', get_member(), get_ip_address(), 'cms_downloads')) {
             $submit_url = build_url(array('page' => 'cms_downloads', 'type' => 'ad', 'redirect' => SELF_REDIRECT), get_module_zone('cms_downloads'));
         } else {
             $submit_url = new ocp_tempcode();
         }
         return do_template('BLOCK_NO_ENTRIES', array('_GUID' => '74399763a51102bdd6e6d92c2c11354f', 'HIGH' => false, 'TITLE' => $title, 'MESSAGE' => do_lang_tempcode('NO_DOWNLOADS_YET'), 'ADD_NAME' => do_lang_tempcode('ADD_DOWNLOAD'), 'SUBMIT_URL' => $submit_url));
     }
     return do_template('BLOCK_MAIN_RECENT_DOWNLOADS', array('_GUID' => '257fa1b83d1b6fe3acbceb2b618e6d7f', 'TITLE' => $title, 'CONTENT' => $out, 'NUMBER' => integer_format($number)));
 }
Beispiel #5
0
/**
 * Get information about the specified member.
 *
 * @param  mixed			The member for whom we are getting the page
 * @param  ?string		The member's name (by reference) (NULL: unknown)
 * @param  ?AUTO_LINK 	The member's ID (by reference) (NULL: unknown)
 * @param  ?string		The member's IP (by reference) (NULL: unknown)
 * @return array			The member's stats rows
 */
function lookup_member_page($member, &$name, &$id, &$ip)
{
    if (!addon_installed('stats')) {
        return array();
    }
    if (is_numeric($member)) {
        // From member ID
        $name = $GLOBALS['FORUM_DRIVER']->get_username(intval($member));
        if (is_null($name)) {
            return array();
        }
        $id = intval($member);
        $ip = $GLOBALS['FORUM_DRIVER']->get_member_ip($id);
        if (is_null($ip)) {
            $ip = '127.0.0.1';
        }
    } elseif (strpos($member, '.') !== false || strpos($member, ':') !== false) {
        // From IP
        $ids = wrap_probe_ip($member);
        $ip = $member;
        if (is_null($ip)) {
            $ip = '127.0.0.1';
        }
        if (count($ids) == 0) {
            return array();
        } else {
            $id = $ids[0]['id'];
        }
        if (count($ids) != 1) {
            $also = new ocp_tempcode();
            foreach ($ids as $t => $_id) {
                if ($t != 0) {
                    if (!$also->is_empty()) {
                        $also->attach(do_lang('LIST_SEP'));
                    }
                    $also->attach($GLOBALS['FORUM_DRIVER']->member_profile_hyperlink($_id['id']));
                }
            }
            attach_message(do_lang_tempcode('MEMBERS_ALSO_ON_IP', $also), 'inform');
        }
        $name = $GLOBALS['FORUM_DRIVER']->get_username($id);
        if (is_null($name)) {
            $name = do_lang('UNKNOWN');
        }
    } else {
        // From name
        $id = $GLOBALS['FORUM_DRIVER']->get_member_from_username($member);
        $name = $member;
        if (is_null($id)) {
            return array();
        }
        $ip = $GLOBALS['FORUM_DRIVER']->get_member_ip($id);
        if (is_null($ip)) {
            $ip = '127.0.0.1';
        }
    }
    return $GLOBALS['SITE_DB']->query('SELECT ip,MAX(date_and_time) AS date_and_time FROM ' . get_table_prefix() . 'stats WHERE the_user='******' GROUP BY ip ORDER BY date_and_time DESC');
}
Beispiel #6
0
 /**
  * Standard modular run function.
  *
  * @return tempcode	The result of execution.
  */
 function run()
 {
     if (!addon_installed('quizzes')) {
         return new ocp_tempcode();
     }
     require_lang('quiz');
     $bits = new ocp_tempcode();
     if (get_option('quiz_show_stats_count_total_open', true) == '1') {
         $bits->attach(do_template('BLOCK_SIDE_STATS_SUBLINE', array('KEY' => do_lang_tempcode('QUIZZES'), 'VALUE' => integer_format($GLOBALS['SITE_DB']->query_value('quizzes', 'COUNT(*)')))));
     }
     if ($bits->is_empty()) {
         return new ocp_tempcode();
     }
     $section = do_template('BLOCK_SIDE_STATS_SECTION', array('SECTION' => do_lang_tempcode('QUIZZES'), 'CONTENT' => $bits));
     return $section;
 }
Beispiel #7
0
 /**
  * Standard modular run function.
  *
  * @return tempcode	The result of execution.
  */
 function run()
 {
     if (get_forum_type() != 'none') {
         $bits = new ocp_tempcode();
         if (get_option('forum_show_stats_count_members', true) == '1') {
             $bits->attach(do_template('BLOCK_SIDE_STATS_SUBLINE', array('_GUID' => 'a2dbcdec813d5a5edbb416bf087b4a97', 'KEY' => do_lang_tempcode('COUNT_MEMBERS'), 'VALUE' => integer_format($GLOBALS['FORUM_DRIVER']->get_members()))));
         }
         if (get_forum_type() == 'ocf') {
             if (get_option('forum_show_stats_count_members_new_today', true) == '1') {
                 $bits->attach(do_template('BLOCK_SIDE_STATS_SUBLINE', array('_GUID' => 'fd2e149f6921836e3c2ea1039644e2e7', 'KEY' => do_lang_tempcode('MEMBERS_NEW_TODAY'), 'VALUE' => integer_format($GLOBALS['FORUM_DB']->query_value_null_ok_full('SELECT COUNT(*) FROM ' . $GLOBALS['FORUM_DB']->get_table_prefix() . 'f_members WHERE m_join_time>' . strval(time() - 60 * 60 * 24))))));
             }
             if (get_option('forum_show_stats_count_members_new_this_week', true) == '1') {
                 $bits->attach(do_template('BLOCK_SIDE_STATS_SUBLINE', array('_GUID' => '10128b288dec4a578517de75cc9e404d', 'KEY' => do_lang_tempcode('MEMBERS_NEW_THIS_WEEK'), 'VALUE' => integer_format($GLOBALS['FORUM_DB']->query_value_null_ok_full('SELECT COUNT(*) FROM ' . $GLOBALS['FORUM_DB']->get_table_prefix() . 'f_members WHERE m_join_time>' . strval(time() - 60 * 60 * 24 * 7))))));
             }
             if (get_option('forum_show_stats_count_members_new_this_month', true) == '1') {
                 $bits->attach(do_template('BLOCK_SIDE_STATS_SUBLINE', array('_GUID' => 'b2dbcdec813d5a5edbb416bf087b4a97', 'KEY' => do_lang_tempcode('MEMBERS_NEW_THIS_MONTH'), 'VALUE' => integer_format($GLOBALS['FORUM_DB']->query_value_null_ok_full('SELECT COUNT(*) FROM ' . $GLOBALS['FORUM_DB']->get_table_prefix() . 'f_members WHERE m_join_time>' . strval(time() - 60 * 60 * 24 * 31))))));
             }
             if (get_option('forum_show_stats_count_members_active_today', true) == '1') {
                 $bits->attach(do_template('BLOCK_SIDE_STATS_SUBLINE', array('_GUID' => 'cc9760b2ed9e985e96b53c91c511e84e', 'KEY' => do_lang_tempcode('MEMBERS_ACTIVE_TODAY'), 'VALUE' => integer_format($GLOBALS['FORUM_DB']->query_value_null_ok_full('SELECT COUNT(*) FROM ' . $GLOBALS['FORUM_DB']->get_table_prefix() . 'f_members WHERE m_last_visit_time>' . strval(time() - 60 * 60 * 24))))));
             }
             if (get_option('forum_show_stats_count_members_active_this_week', true) == '1') {
                 $bits->attach(do_template('BLOCK_SIDE_STATS_SUBLINE', array('_GUID' => 'dc9760b2ed9e985e96b53c91c511e84e', 'KEY' => do_lang_tempcode('MEMBERS_ACTIVE_THIS_WEEK'), 'VALUE' => integer_format($GLOBALS['FORUM_DB']->query_value_null_ok_full('SELECT COUNT(*) FROM ' . $GLOBALS['FORUM_DB']->get_table_prefix() . 'f_members WHERE m_last_visit_time>' . strval(time() - 60 * 60 * 24 * 7))))));
             }
             if (get_option('forum_show_stats_count_members_active_this_month', true) == '1') {
                 $bits->attach(do_template('BLOCK_SIDE_STATS_SUBLINE', array('_GUID' => 'ec9760b2ed9e985e96b53c91c511e84e', 'KEY' => do_lang_tempcode('MEMBERS_ACTIVE_THIS_MONTH'), 'VALUE' => integer_format($GLOBALS['FORUM_DB']->query_value_null_ok_full('SELECT COUNT(*) FROM ' . $GLOBALS['FORUM_DB']->get_table_prefix() . 'f_members WHERE m_last_visit_time>' . strval(time() - 60 * 60 * 24 * 31))))));
             }
         }
         if (!has_no_forum()) {
             if (get_option('forum_show_stats_count_topics', true) == '1') {
                 $bits->attach(do_template('BLOCK_SIDE_STATS_SUBLINE', array('_GUID' => '2e0fe7ccbb15052743c94aab6a3654bc', 'KEY' => do_lang_tempcode('COUNT_TOPICS'), 'VALUE' => integer_format($GLOBALS['FORUM_DRIVER']->get_topics()))));
             }
             if (get_option('forum_show_stats_count_posts', true) == '1') {
                 $bits->attach(do_template('BLOCK_SIDE_STATS_SUBLINE', array('_GUID' => 'de7e97b855cfbc4d60d069ca3f652b17', 'KEY' => do_lang_tempcode('COUNT_POSTS'), 'VALUE' => integer_format($GLOBALS['FORUM_DRIVER']->get_num_forum_posts()))));
             }
             if (get_option('forum_show_stats_count_posts_today', true) == '1') {
                 $bits->attach(do_template('BLOCK_SIDE_STATS_SUBLINE', array('_GUID' => '8649eee4a70ce0383c5534da43e2b58c', 'KEY' => do_lang_tempcode('COUNT_POSTSTODAY'), 'VALUE' => integer_format($GLOBALS['FORUM_DRIVER']->get_num_new_forum_posts()))));
             }
         }
         if ($bits->is_empty()) {
             return new ocp_tempcode();
         }
         $forums = do_template('BLOCK_SIDE_STATS_SECTION', array('_GUID' => '52cd616760efe17adcec4b97e1305301', 'SECTION' => do_lang_tempcode('FORUM_SLASH_COMMUNITY'), 'CONTENT' => $bits));
     } else {
         $forums = new ocp_tempcode();
     }
     return $forums;
 }
Beispiel #8
0
/**
 * Shows an HTML page of all authors clickably.
 */
function authors_script()
{
    require_lang('authors');
    global $NON_CANONICAL_PARAMS;
    $NON_CANONICAL_PARAMS[] = 'max';
    $start = get_param_integer('start', 0);
    $max = get_param_integer('max', 300);
    $author_fields = $GLOBALS['SITE_DB']->query('SELECT m_name,m_table FROM ' . $GLOBALS['SITE_DB']->get_table_prefix() . 'db_meta WHERE m_name LIKE \'' . db_encode_like('%author') . '\'');
    $rows = array();
    foreach ($author_fields as $field) {
        if ($field['m_table'] != 'addons' && $field['m_table'] != 'blocks' && $field['m_table'] != 'modules') {
            $rows_new = $GLOBALS['SITE_DB']->query('SELECT DISTINCT ' . $field['m_name'] . ' AS author FROM ' . $GLOBALS['SITE_DB']->get_table_prefix() . $field['m_table'] . ' WHERE ' . db_string_not_equal_to($field['m_name'], '') . ' ORDER BY ' . $field['m_name'], $max + $start);
            foreach ($rows_new as $a) {
                if (!array_key_exists($a['author'], $rows) || $field['m_table'] == 'authors') {
                    $rows[$a['author']] = $field['m_table'];
                }
            }
        }
    }
    $rows = array_unique($rows);
    $field_name = get_param('field_name');
    $content = new ocp_tempcode();
    $i = 0;
    foreach ($rows as $author => $table) {
        if ($i >= $start && $i < $start + $max) {
            if ($table == 'authors') {
                $content->attach(do_template('AUTHOR_POPUP_WINDOW_DEFINED', array('_GUID' => 'cffa9926cebd3ec2920677266a3299ea', 'FIELD_NAME' => $field_name, 'AUTHOR' => $author)));
            } else {
                $content->attach(do_template('AUTHOR_POPUP_WINDOW_UNDEFINED', array('_GUID' => '6210be6d1eef4bc2bda7f49947301f97', 'FIELD_NAME' => $field_name, 'AUTHOR' => $author)));
            }
        }
        $i++;
    }
    if ($content->is_empty()) {
        $content = paragraph(do_lang_tempcode('NO_ENTRIES'), 'dfids09fi;lk;3');
    }
    if ($i >= $start + $max) {
        $keep = symbol_tempcode('KEEP');
        $next_link = find_script('authors') . '?field_name=' . urlencode($field_name) . '&start=' . strval($start + $max) . '&max=' . strval($max) . $keep->evaluate();
    } else {
        $next_link = NULL;
    }
    $echo = do_template('STYLED_HTML_WRAP', array('_GUID' => 'ab8d8c9d276530d82ddd84202aacf32f', 'TITLE' => do_lang_tempcode('CHOOSE_AUTHOR'), 'NEXT_LINK' => $next_link, 'CONTENT' => $content));
    $echo->evaluate_echo();
}
Beispiel #9
0
 /**
  * Standard modular run function.
  *
  * @return tempcode	The result of execution.
  */
 function run()
 {
     if (!addon_installed('news')) {
         return new ocp_tempcode();
     }
     require_lang('news');
     $bits = new ocp_tempcode();
     if (get_option('news_show_stats_count_total_posts', true) == '1') {
         $bits->attach(do_template('BLOCK_SIDE_STATS_SUBLINE', array('KEY' => do_lang_tempcode('COUNT_POSTS'), 'VALUE' => integer_format($GLOBALS['SITE_DB']->query_value('news', 'COUNT(*)')))));
     }
     if (get_option('news_show_stats_count_blogs', true) == '1') {
         $bits->attach(do_template('BLOCK_SIDE_STATS_SUBLINE', array('KEY' => do_lang_tempcode('BLOGS'), 'VALUE' => integer_format($GLOBALS['SITE_DB']->query_value_null_ok_full('SELECT COUNT(*) FROM ' . get_table_prefix() . 'news_categories WHERE nc_owner IS NOT NULL')))));
     }
     if ($bits->is_empty()) {
         return new ocp_tempcode();
     }
     $section = do_template('BLOCK_SIDE_STATS_SECTION', array('SECTION' => do_lang_tempcode('NEWS'), 'CONTENT' => $bits));
     return $section;
 }
Beispiel #10
0
 /**
  * Standard modular run function.
  *
  * @return tempcode	The result of execution.
  */
 function run()
 {
     if (!addon_installed('cedi')) {
         return new ocp_tempcode();
     }
     require_code('cedi_stats');
     require_lang('cedi');
     $bits = new ocp_tempcode();
     if (get_option('cedi_show_stats_count_pages', true) == '1') {
         $bits->attach(do_template('BLOCK_SIDE_STATS_SUBLINE', array('_GUID' => '8bbd18d5169c4e5449b252880ecda716', 'KEY' => do_lang_tempcode('COUNT_PAGES'), 'VALUE' => integer_format(get_num_cedi_pages()))));
     }
     if (get_option('cedi_show_stats_count_posts', true) == '1') {
         $bits->attach(do_template('BLOCK_SIDE_STATS_SUBLINE', array('_GUID' => 'd8cf3d5aabc18777f609760010303ace', 'KEY' => do_lang_tempcode('COUNT_POSTS'), 'VALUE' => integer_format(get_num_cedi_posts()))));
     }
     if ($bits->is_empty()) {
         return new ocp_tempcode();
     }
     $cedi = do_template('BLOCK_SIDE_STATS_SECTION', array('_GUID' => 'ea19e51db4e62958843ace808016af1e', 'SECTION' => do_lang_tempcode('CEDI'), 'CONTENT' => $bits));
     return $cedi;
 }
Beispiel #11
0
 /**
  * Standard modular run function.
  *
  * @return tempcode	The result of execution.
  */
 function run()
 {
     if (!addon_installed('filedump')) {
         return new ocp_tempcode();
     }
     if (!file_exists(get_custom_file_base() . '/uploads/filedump')) {
         return new ocp_tempcode();
     }
     require_lang('filedump');
     require_code('files2');
     $bits = new ocp_tempcode();
     if (get_option('filedump_show_stats_count_total_files', true) == '1') {
         $bits->attach(do_template('BLOCK_SIDE_STATS_SUBLINE', array('KEY' => do_lang_tempcode('COUNT_FILES'), 'VALUE' => integer_format(count(get_directory_contents(get_custom_file_base() . '/uploads/filedump'))))));
     }
     if (get_option('filedump_show_stats_count_total_space', true) == '1') {
         $bits->attach(do_template('BLOCK_SIDE_STATS_SUBLINE', array('KEY' => do_lang_tempcode('DISK_USAGE'), 'VALUE' => clean_file_size(get_directory_size(get_custom_file_base() . '/uploads/filedump')))));
     }
     if ($bits->is_empty()) {
         return new ocp_tempcode();
     }
     $section = do_template('BLOCK_SIDE_STATS_SECTION', array('SECTION' => do_lang_tempcode('FILE_DUMP'), 'CONTENT' => $bits));
     return $section;
 }
Beispiel #12
0
 /**
  * Standard modular run function.
  *
  * @return tempcode	The result of execution.
  */
 function run()
 {
     if (!addon_installed('chat')) {
         return new ocp_tempcode();
     }
     require_code('chat_stats');
     require_lang('chat');
     $bits = new ocp_tempcode();
     if (get_option('chat_show_stats_count_users', true) == '1') {
         $bits->attach(do_template('BLOCK_SIDE_STATS_SUBLINE', array('_GUID' => '904a46b83a84728243f3fd655705cc04', 'KEY' => do_lang_tempcode('COUNT_CHATTERS'), 'VALUE' => integer_format(get_num_chatters()))));
     }
     if (get_option('chat_show_stats_count_rooms', true) == '1') {
         $bits->attach(do_template('BLOCK_SIDE_STATS_SUBLINE', array('_GUID' => 'adf12b729fd23b6fa7115758a64155c6', 'KEY' => do_lang_tempcode('ROOMS'), 'VALUE' => integer_format(get_num_chatrooms()))));
     }
     if (get_option('chat_show_stats_count_messages', true) == '1') {
         $bits->attach(do_template('BLOCK_SIDE_STATS_SUBLINE', array('_GUID' => '0e86e89171ddd8225ac41e14b18ecdb0', 'KEY' => do_lang_tempcode('COUNT_CHATPOSTS'), 'VALUE' => integer_format(get_num_chatposts()))));
     }
     if ($bits->is_empty()) {
         return new ocp_tempcode();
     }
     $chat = do_template('BLOCK_SIDE_STATS_SECTION', array('_GUID' => '4d688c45e01ed34f257fd03100a6be6d', 'SECTION' => do_lang_tempcode('SECTION_CHAT'), 'CONTENT' => $bits));
     return $chat;
 }
Beispiel #13
0
 /**
  * UI to add an invoice.
  *
  * @return tempcode	The interface.
  */
 function ad()
 {
     $title = get_page_title('CREATE_INVOICE');
     breadcrumb_set_parents(array(array('_SEARCH:admin_ecommerce:ecom_usage', do_lang_tempcode('ECOMMERCE')), array('_SELF:_SELF:misc', do_lang_tempcode('INVOICES'))));
     require_code('form_templates');
     $to = get_param('to', '');
     $products = find_all_products();
     $list = new ocp_tempcode();
     foreach ($products as $product => $details) {
         if ($details[0] == PRODUCT_INVOICE) {
             $text = do_lang_tempcode('CUSTOM_PRODUCT_' . $product);
             if ($details[1] != '?') {
                 $text->attach(escape_html(' (' . $details[1] . ' ' . get_option('currency') . ')'));
             }
             $list->attach(form_input_list_entry($product, false, $text));
         }
     }
     if ($list->is_empty()) {
         inform_exit(do_lang_tempcode('NOTHING_TO_INVOICE_FOR'));
     }
     $fields = new ocp_tempcode();
     $fields->attach(form_input_list(do_lang_tempcode('PRODUCT'), '', 'product', $list));
     $fields->attach(form_input_username(do_lang_tempcode('USERNAME'), do_lang_tempcode('DESCRIPTION_INVOICE_FOR'), 'to', $to, true));
     $fields->attach(form_input_float(do_lang_tempcode('AMOUNT'), do_lang_tempcode('INVOICE_AMOUNT_TEXT', escape_html(get_option('currency'))), 'amount', NULL, false));
     $fields->attach(form_input_line(do_lang_tempcode('INVOICE_SPECIAL'), do_lang_tempcode('DESCRIPTION_INVOICE_SPECIAL'), 'special', '', false));
     $fields->attach(form_input_text(do_lang_tempcode('INVOICE_NOTE'), do_lang_tempcode('DESCRIPTION_INVOICE_NOTE'), 'note', '', false));
     $post_url = build_url(array('page' => '_SELF', 'type' => '_ad'), '_SELF');
     $submit_name = do_lang_tempcode('CREATE_INVOICE');
     return do_template('FORM_SCREEN', array('HIDDEN' => '', 'TITLE' => $title, 'URL' => $post_url, 'FIELDS' => $fields, 'SUBMIT_NAME' => $submit_name, 'TEXT' => do_lang_tempcode('DESCRIPTION_INVOICE_PAGE')));
 }
 /**
  * Show value statistics for a custom profile field (show).
  *
  * @return tempcode		The statistics
  */
 function _stats()
 {
     $title = get_page_title('CUSTOM_PROFILE_FIELD_STATS');
     breadcrumb_set_parents(array());
     $f_name = 'field_' . strval(get_param_integer('id'));
     $_a = get_input_date('start');
     $a = is_null($_a) ? '1=1' : 'm_join_time>' . strval((int) $_a);
     $_b = get_input_date('end');
     $b = is_null($_b) ? '1=1' : 'm_join_time<' . strval((int) $_b);
     $members_in_range = $GLOBALS['FORUM_DB']->query('SELECT ' . $f_name . ',COUNT(' . $f_name . ') AS cnt FROM ' . $GLOBALS['FORUM_DB']->get_table_prefix() . 'f_members m LEFT JOIN ' . $GLOBALS['FORUM_DB']->get_table_prefix() . 'f_member_custom_fields f ON m.id=f.mf_member_id WHERE ' . $a . ' AND ' . $b . ' GROUP BY ' . $f_name . ' ORDER BY cnt', 300);
     if (count($members_in_range) == 300) {
         attach_message(do_lang_tempcode('TOO_MUCH_CHOOSE__TOP_ONLY', escape_html(integer_format(300))), 'warn');
     }
     $lines = new ocp_tempcode();
     foreach ($members_in_range as $row) {
         if (!is_null($row[$f_name])) {
             $val = $row[$f_name];
             if ($val == STRING_MAGIC_NULL) {
                 continue;
             }
             $lines->attach(do_template('OCF_CPF_STATS_LINE', array('CNT' => integer_format($row['cnt']), 'VAL' => is_integer($val) ? integer_format($val) : $val)));
         }
     }
     if ($lines->is_empty()) {
         warn_exit(do_lang_tempcode('NO_DATA'));
     }
     return do_template('OCF_CPF_STATS_SCREEN', array('_GUID' => 'bb7be7acf936cd008e16bd515f7f39ac', 'TITLE' => $title, 'STATS' => $lines));
 }
Beispiel #15
0
/**
 * Fourth installation step.
 *
 * @return tempcode		Progress report / UI
 */
function step_4()
{
    global $LANG;
    if (count($_POST) == 0) {
        exit(do_lang('INST_POST_ERROR'));
    }
    require_code('database/' . post_param('db_type'));
    $GLOBALS['DB_STATIC_OBJECT'] = object_factory('Database_Static_' . post_param('db_type'));
    $domain = ocp_srv('HTTP_HOST');
    if (substr($domain, 0, 4) == 'www.') {
        $domain = substr($domain, 4);
    }
    $colon_pos = strpos($domain, ':');
    if ($colon_pos !== false) {
        $domain = substr($domain, 0, $colon_pos);
    }
    $pos = strpos(ocp_srv('PHP_SELF'), 'install.php');
    if ($pos === false) {
        $pos = strlen(ocp_srv('PHP_SELF'));
    } else {
        $pos--;
    }
    $port = ocp_srv('SERVER_PORT');
    if ($port == '' || $port == '80' || $port == '443') {
        $port = '';
    } else {
        $port = ':' . $port;
    }
    $base_url = post_param('base_url', 'http://' . $domain . $port . substr(ocp_srv('PHP_SELF'), 0, $pos));
    if (substr($base_url, -1) == '/') {
        $base_url = substr($base_url, 0, strlen($base_url) - 1);
    }
    // Our forum is
    $forum_type = post_param('forum_type');
    require_code('forum/' . $forum_type);
    $GLOBALS['FORUM_DRIVER'] = object_factory('forum_driver_' . filter_naughty_harsh($forum_type));
    $GLOBALS['FORUM_DRIVER']->MEMBER_ROWS_CACHED = array();
    // Try and grab ourselves forum details
    global $INFO;
    $INFO['sql_database'] = '';
    $INFO['sql_user'] = '';
    $INFO['sql_pass'] = '';
    $board_path = post_param('board_path');
    find_forum_path($board_path);
    if (!array_key_exists('board_url', $INFO) || !(strlen($INFO['board_url']) > 0)) {
        $file_base = get_file_base();
        for ($i = 0; $i < strlen($board_path); $i++) {
            if ($i >= strlen($file_base)) {
                break;
            }
            if ($board_path[$i] != $file_base[$i]) {
                break;
            }
        }
        $append = str_replace('\\', '/', substr($board_path, $i));
        $INFO['board_url'] = strlen($append) < 15 ? substr($base_url, 0, strlen($base_url) - ($i - strlen($board_path))) . (strlen($append) > 0 && $append[0] == '/' ? '' : '/') . $append : $base_url . '/forums';
    }
    if (!array_key_exists('cookie_member_id', $INFO)) {
        $INFO['cookie_member_id'] = 'ocp_member_id';
    }
    if (!array_key_exists('cookie_member_hash', $INFO)) {
        $INFO['cookie_member_hash'] = 'ocp_member_hash';
    }
    $cookie_domain = '';
    //(($domain=='localhost') || (strpos($domain,'.')===false))?'':('.'.$domain);
    $cookie_path = '/';
    $cookie_days = '120';
    $use_persistent = false;
    require_code('version');
    $table_prefix = $domain == 'test.ocportal.com' ? $forum_type . '_ocp_' : 'ocp_';
    if (strpos(strtoupper(PHP_OS), 'WIN') !== false) {
        $db_site_host = '127.0.0.1';
    } else {
        $db_site_host = 'localhost';
    }
    $db_site_user = $INFO['sql_user'];
    $db_site_password = $INFO['sql_pass'];
    $db_site = $INFO['sql_database'];
    $db_forums_host = $db_site_host;
    $db_forums_user = $db_site_user;
    $db_forums_password = $db_site_password;
    $db_forums = $db_site;
    $board_prefix = $INFO['board_url'];
    $member_cookie = $INFO['cookie_member_id'];
    $pass_cookie = $INFO['cookie_member_hash'];
    if (function_exists('posix_getpwuid') && strpos(@ini_get('disable_functions'), 'posix_getpwuid') === false) {
        $u_info = posix_getpwuid(fileowner(get_file_base() . '/install.php'));
        if ($u_info !== false) {
            $ftp_username = $u_info['name'];
        } else {
            $ftp_username = '';
        }
    } else {
        $ftp_username = '';
    }
    if (is_null($ftp_username)) {
        $ftp_username = '';
    }
    $dr = array_key_exists('DOCUMENT_ROOT', $_SERVER) ? $_SERVER['DOCUMENT_ROOT'] : (array_key_exists('DOCUMENT_ROOT', $_ENV) ? $_ENV['DOCUMENT_ROOT'] : '');
    if (strpos($dr, '/') !== false) {
        $dr_parts = explode('/', $dr);
    } else {
        $dr_parts = explode('\\', $dr);
    }
    $webdir_stub = $dr_parts[count($dr_parts) - 1];
    // If we have a host where the FTP is two+ levels down (often when we have one FTP covering multiple virtual hosts), then this "last component" rule would be insufficient; do a search through for critical strings to try and make a better guess
    $special_root_dirs = array('public_html', 'www', 'webroot', 'httpdocs', 'wwwroot');
    $webdir_stub = $dr_parts[count($dr_parts) - 1];
    foreach ($dr_parts as $i => $part) {
        if (in_array($part, $special_root_dirs)) {
            $webdir_stub = implode('/', array_slice($dr_parts, $i));
        }
    }
    $ftp_folder = '/' . $webdir_stub . substr(ocp_srv('PHP_SELF'), 0, $pos);
    $ftp_domain = $domain;
    $specifics = $GLOBALS['FORUM_DRIVER']->install_specifics();
    // Now we've gone through all the work of detecting it, lets grab from info.php to see what we had last time we installed
    global $SITE_INFO;
    if (file_exists(get_file_base() . '/info.php') && filesize(get_file_base() . '/info.php') != 0) {
        require_once get_file_base() . '/info.php';
        if ($INFO['sql_database'] != '') {
            if (!array_key_exists('forum_type', $SITE_INFO) || $SITE_INFO['forum_type'] != $forum_type) {
                unset($SITE_INFO['user_cookie']);
                unset($SITE_INFO['pass_cookie']);
            }
            foreach ($specifics as $specific) {
                if (array_key_exists($specific['name'], $SITE_INFO)) {
                    unset($SITE_INFO[$specific['name']]);
                }
            }
            unset($SITE_INFO['db_forums_host']);
            unset($SITE_INFO['db_forums_user']);
            unset($SITE_INFO['db_forums_password']);
            unset($SITE_INFO['db_forums']);
            unset($SITE_INFO['db_site_host']);
            unset($SITE_INFO['db_site_user']);
            unset($SITE_INFO['db_site_password']);
            unset($SITE_INFO['db_site']);
        }
        unset($SITE_INFO['base_url']);
    }
    $sections = new ocp_tempcode();
    // Is this autoinstaller?
    global $FILE_ARRAY;
    if (@is_array($FILE_ARRAY) && !is_suexec_like()) {
        $title = protect_from_escaping(escape_html('FTP'));
        $text = do_lang_tempcode('AUTO_INSTALL');
        $hidden = new ocp_tempcode();
        $options = new ocp_tempcode();
        $options->attach(make_option(do_lang_tempcode('FTP_DOMAIN'), new ocp_tempcode(), 'ftp_domain', post_param('ftp_domain', $ftp_domain), false, true));
        $options->attach(make_option(do_lang_tempcode('FTP_USERNAME'), new ocp_tempcode(), 'ftp_username', post_param('ftp_username', $ftp_username), false, true));
        $options->attach(make_option(do_lang_tempcode('FTP_PASSWORD'), new ocp_tempcode(), 'ftp_password', post_param('ftp_password', ''), true));
        $options->attach(make_option(do_lang_tempcode('FTP_DIRECTORY'), do_lang_tempcode('FTP_FOLDER'), 'ftp_folder', post_param('ftp_folder', $ftp_folder)));
        $options->attach(make_option(do_lang_tempcode('FTP_FILES_PER_GO'), do_lang_tempcode('DESCRIPTION_FTP_FILES_PER_GO'), 'max', post_param('max', '1000')));
        $sections->attach(do_template('INSTALLER_STEP_4_SECTION', array('_GUID' => '50fcb00f4d1da1813e94d86529ea0862', 'HIDDEN' => $hidden, 'TITLE' => $title, 'TEXT' => $text, 'OPTIONS' => $options)));
    }
    $title = do_lang_tempcode('GENERAL_SETTINGS');
    $text = new ocp_tempcode();
    $options = new ocp_tempcode();
    $hidden = new ocp_tempcode();
    $options->attach(make_option(do_lang_tempcode('DOMAIN'), example('DOMAIN_EXAMPLE', 'DOMAIN_TEXT'), 'domain', $domain, false, true));
    $options->attach(make_option(do_lang_tempcode('BASE_URL'), example('BASE_URL_EXAMPLE', 'BASE_URL_TEXT'), 'base_url', $base_url, false, true));
    if (post_param('db_type') != 'xml') {
        $options->attach(make_option(do_lang_tempcode('TABLE_PREFIX'), example('TABLE_PREFIX_EXAMPLE', 'TABLE_PREFIX_TEXT'), 'table_prefix', $table_prefix));
    } else {
        $hidden->attach(form_input_hidden('table_prefix', $table_prefix));
    }
    $admin_password = '';
    $options->attach(make_option(do_lang_tempcode('MASTER_PASSWORD'), example('', 'CHOOSE_ADMIN_PASSWORD'), 'admin_password', $admin_password, true));
    $options->attach(make_tick(do_lang_tempcode('USE_PERSISTENT'), example('', 'USE_PERSISTENT_TEXT'), 'use_persistent', $use_persistent ? 1 : 0));
    //	$options->attach(make_tick(do_lang_tempcode('MULTI_LANG'),example('','MULTI_LANG_TEXT'),'multi_lang',true));
    require_lang('config');
    $options->attach(make_tick(do_lang_tempcode('SEND_ERROR_EMAILS_OCPRODUCTS'), example('', 'CONFIG_OPTION_send_error_emails_ocproducts'), 'allow_reports_default', 1));
    $sections->attach(do_template('INSTALLER_STEP_4_SECTION', array('_GUID' => 'f051465e86a7a53ec078e0d9de773993', 'HIDDEN' => $hidden, 'TITLE' => $title, 'TEXT' => $text, 'OPTIONS' => $options)));
    $hidden = new ocp_tempcode();
    $forum_text = new ocp_tempcode();
    if ($forum_type == 'ocf' || $forum_type == 'none') {
        $forum_title = do_lang_tempcode('FORUM_SETTINGS');
    } else {
        $_forum_type = do_lang('FORUM_CLASS_' . preg_replace('#\\d+$#', '', $forum_type), NULL, NULL, NULL, NULL, false);
        if (is_null($_forum_type)) {
            $_forum_type = ucwords($forum_type);
        }
        $forum_title = do_lang_tempcode('_FORUM_SETTINGS', escape_html($_forum_type));
    }
    $forum_options = new ocp_tempcode();
    $use_msn = post_param_integer('use_msn', 0);
    if ($use_msn == 0) {
        $use_msn = post_param_integer('use_multi_db', 0);
    }
    $forum_type = post_param('forum_type');
    if ($forum_type != 'none') {
        if ($use_msn == 1) {
            if ($forum_type != 'ocf') {
                $forum_text = do_lang_tempcode('AUTODETECT');
            }
            $forum_options->attach(make_option(do_lang_tempcode('DATABASE_NAME'), new ocp_tempcode(), 'db_forums', $db_forums, false, true));
            if (!$GLOBALS['DB_STATIC_OBJECT']->db_is_flat_file_simple()) {
                $forum_options->attach(make_option(do_lang_tempcode('DATABASE_HOST'), example('', 'DATABASE_HOST_TEXT'), 'db_forums_host', $db_forums_host, false, true));
                $forum_options->attach(make_option(do_lang_tempcode('DATABASE_USERNAME'), new ocp_tempcode(), 'db_forums_user', $db_forums_user, false, true));
                $forum_options->attach(make_option(do_lang_tempcode('DATABASE_PASSWORD'), new ocp_tempcode(), 'db_forums_password', $db_forums_password, true));
            } else {
                $hidden->attach(form_input_hidden('db_forums_host', 'localhost'));
                $hidden->attach(form_input_hidden('db_forums_user', ''));
                $hidden->attach(form_input_hidden('db_forums_password', ''));
            }
            $hidden->attach(form_input_hidden('use_msn', strval($use_msn)));
        }
        if ($forum_type != 'ocf' || $use_msn == 1) {
            $forum_options->attach(make_option(do_lang_tempcode('BASE_URL'), example('FORUM_BASE_URL_EXAMPLE', 'BASE_URL_TEXT_FORUM'), 'board_prefix', $board_prefix, false, true));
        }
    }
    foreach ($specifics as $specific) {
        if ($specific['name'] == 'clear_existing_forums_on_install') {
            $hidden->attach(form_input_hidden('clear_existing_forums_on_install', 'yes'));
        } elseif ($specific['name'] == 'ocf_table_prefix' && $use_msn == 0) {
            // Nothing
        } else {
            $forum_options->attach(make_option(is_object($specific['title']) ? $specific['title'] : make_string_tempcode($specific['title']), is_object($specific['description']) ? $specific['description'] : make_string_tempcode($specific['description']), $specific['name'], array_key_exists($specific['name'], $SITE_INFO) ? $SITE_INFO[$specific['name']] : $specific['default'], strpos($specific['name'], 'password') !== false));
        }
    }
    $text = $use_msn == 1 ? do_lang_tempcode($forum_type == 'ocf' ? 'DUPLICATE_OCF' : 'DUPLICATE') : new ocp_tempcode();
    $options = make_option(do_lang_tempcode('DATABASE_NAME'), new ocp_tempcode(), 'db_site', $db_site, false, true);
    if (!$GLOBALS['DB_STATIC_OBJECT']->db_is_flat_file_simple()) {
        $options->attach(make_option(do_lang_tempcode('DATABASE_HOST'), example('', 'DATABASE_HOST_TEXT'), 'db_site_host', $db_site_host, false, true));
        $options->attach(make_option(do_lang_tempcode('DATABASE_USERNAME'), new ocp_tempcode(), 'db_site_user', $db_site_user, false, true));
        $options->attach(make_option(do_lang_tempcode('DATABASE_PASSWORD'), new ocp_tempcode(), 'db_site_password', $db_site_password, true));
    } else {
        $hidden->attach(form_input_hidden('db_site_host', 'localhost'));
        $hidden->attach(form_input_hidden('db_site_user', ''));
        $hidden->attach(form_input_hidden('db_site_password', ''));
    }
    if ($use_msn == 0 && $forum_type != 'ocf') {
        $forum_options->attach($options);
        $sections->attach(do_template('INSTALLER_STEP_4_SECTION', array('HIDDEN' => $hidden, 'TITLE' => $forum_title, 'TEXT' => $forum_text, 'OPTIONS' => $forum_options)));
    } else {
        $title = do_lang_tempcode('OCPORTAL_SETTINGS');
        if (!$forum_options->is_empty()) {
            $sections->attach(do_template('INSTALLER_STEP_4_SECTION', array('_GUID' => '232b69a995f384275c1cd9269a42c3b8', 'HIDDEN' => '', 'TITLE' => $forum_title, 'TEXT' => $forum_text, 'OPTIONS' => $forum_options)));
        }
        $sections->attach(do_template('INSTALLER_STEP_4_SECTION', array('_GUID' => '15e0f275f78414b6c4fe7775a1cacb23', 'HIDDEN' => $hidden, 'TITLE' => $title, 'TEXT' => $text, 'OPTIONS' => $options)));
    }
    $title = do_lang_tempcode('COOKIE_SETTINGS');
    $text = new ocp_tempcode();
    $options = new ocp_tempcode();
    $hidden = new ocp_tempcode();
    $options->attach(make_option(do_lang_tempcode('COOKIE'), example('COOKIE_EXAMPLE', 'COOKIE_TEXT'), 'user_cookie', $member_cookie, false, true));
    $options->attach(make_option(do_lang_tempcode('COOKIE_PASSWORD'), example('COOKIE_PASSWORD_EXAMPLE', 'COOKIE_PASSWORD_TEXT'), 'pass_cookie', $pass_cookie, false, true));
    $options->attach(make_option(do_lang_tempcode('COOKIE_DOMAIN'), example('COOKIE_DOMAIN_EXAMPLE', 'COOKIE_DOMAIN_TEXT'), 'cookie_domain', $cookie_domain));
    $options->attach(make_option(do_lang_tempcode('COOKIE_PATH'), example('COOKIE_PATH_EXAMPLE', 'COOKIE_PATH_TEXT'), 'cookie_path', $cookie_path));
    $options->attach(make_option(do_lang_tempcode('COOKIE_DAYS'), example('COOKIE_DAYS_EXAMPLE', 'COOKIE_DAYS_TEXT'), 'cookie_days', $cookie_days, false, true));
    $temp = do_template('INSTALLER_STEP_4_SECTION', array('_GUID' => '3b9ea022164801f4b60780a4a966006f', 'HIDDEN' => $hidden, 'TITLE' => $title, 'TEXT' => $text, 'OPTIONS' => $options));
    $sections->attach(do_template('INSTALLER_STEP_4_SECTION_HIDE', array('_GUID' => '42eb3d44bcf8ef99987b6daa9e6530aa', 'TITLE' => $title, 'CONTENT' => $temp)));
    $js = do_template('JAVASCRIPT');
    $js->attach(chr(10));
    $js->attach(do_template('JAVASCRIPT_AJAX'));
    $message = paragraph(do_lang_tempcode('BASIC_CONFIG'));
    if ($forum_type != 'none' && $forum_type != 'ocf') {
        $message->attach(paragraph(do_lang_tempcode('FORUM_DRIVER_NATIVE_LOGIN')));
    }
    return do_template('INSTALLER_STEP_4', array('_GUID' => '73c3ac0a7108709b74b2e89cae30be12', 'JS' => $js, 'MESSAGE' => $message, 'LANG' => $LANG, 'DB_TYPE' => post_param('db_type'), 'FORUM_TYPE' => $forum_type, 'BOARD_PATH' => $board_path, 'SECTIONS' => $sections, 'MAX' => strval(post_param_integer('max', 1000))));
}
 function testNoMissingParams()
 {
     global $ATTACHED_MESSAGES, $ATTACHED_MESSAGES_RAW;
     $lists = find_all_previews__by_screen();
     foreach ($lists as $function => $tpls) {
         $template = $tpls[0];
         $hook = NULL;
         if (is_file(get_file_base() . '/_tests/screens_tested/nonemissing__' . $function)) {
             continue;
         }
         // To make easier to debug through
         if (function_exists('set_time_limit')) {
             @set_time_limit(0);
         }
         $ATTACHED_MESSAGES = new ocp_tempcode();
         $ATTACHED_MESSAGES_RAW = array();
         $out1 = render_screen_preview($template, $hook, $function);
         $put_out = !$ATTACHED_MESSAGES->is_empty() || count($ATTACHED_MESSAGES_RAW) > 0;
         $this->assertFalse($put_out, 'Messages put out by ' . $function . '  (' . strip_tags($ATTACHED_MESSAGES->evaluate()) . ')');
         if (!$put_out) {
             fclose(fopen(get_file_base() . '/_tests/screens_tested/nonemissing__' . $function, 'wb'));
             sync_file(get_file_base() . '/_tests/screens_tested/nonemissing__' . $function);
             fix_permissions(get_file_base() . '/_tests/screens_tested/nonemissing__' . $function);
         }
         unset($out1);
     }
 }
 /**
  * Standard modular run function.
  *
  * @param  array		A map of parameters.
  * @return tempcode	The result of execution.
  */
 function run($map)
 {
     if (has_no_forum()) {
         return new ocp_tempcode();
     }
     require_css('news');
     // Read in variables
     $forum_name = array_key_exists('param', $map) ? $map['param'] : 'General chat';
     $limit = array_key_exists('limit', $map) ? intval($map['limit']) : 6;
     $hot = array_key_exists('hot', $map) ? intval($map['hot']) : 0;
     $date_key = array_key_exists('date_key', $map) ? $map['date_key'] : 'lasttime';
     if ($date_key != 'lasttime' && $date_key != 'firsttime') {
         $date_key = 'firsttime';
     }
     $username_key = array_key_exists('username_key', $map) ? $map['username_key'] : 'firstusername';
     if ($username_key != 'lastusername' && $username_key != 'firstusername') {
         $username_key = 'firstusername';
     }
     $memberid_key = $username_key == 'firstusername' ? 'firstmemberid' : 'lastmemberid';
     // Work out exactly what forums we're reading
     $forum_ids = array();
     if (get_forum_type() == 'ocf' && (strpos($forum_name, ',') !== false || strpos($forum_name, '*') !== false || preg_match('#\\d[-\\*\\+]#', $forum_name) != 0 || is_numeric($forum_name))) {
         require_code('ocfiltering');
         $forum_names = ocfilter_to_idlist_using_db($forum_name, 'id', 'f_forums', 'f_forums', 'f_parent_forum', 'f_parent_forum', 'id', true, true, $GLOBALS['FORUM_DB']);
     } else {
         $forum_names = explode(',', $forum_name);
     }
     foreach ($forum_names as $forum_name) {
         if (!is_string($forum_name)) {
             $forum_name = strval($forum_name);
         }
         $forum_name = trim($forum_name);
         if ($forum_name == '<announce>') {
             $forum_id = NULL;
         } else {
             $forum_id = is_numeric($forum_name) ? intval($forum_name) : $GLOBALS['FORUM_DRIVER']->forum_id_from_name($forum_name);
         }
         if (get_forum_type() == 'ocf' && array_key_exists('check', $map) && $map['check'] == '1') {
             if (!has_category_access(get_member(), 'forums', strval($forum_id))) {
                 continue;
             }
         }
         if (!is_null($forum_id)) {
             $forum_ids[$forum_id] = $forum_name;
         }
     }
     // Block title
     $forum_name = array_key_exists('param', $map) ? $map['param'] : 'General chat';
     if (is_numeric($forum_name) && get_forum_type() == 'ocf') {
         $forum_name = $GLOBALS['FORUM_DB']->query_value_null_ok('f_forums', 'f_name', array('id' => intval($forum_name)));
         if (is_null($forum_name)) {
             return paragraph(do_lang_tempcode('MISSING_RESOURCE'));
         }
     }
     $_title = do_lang_tempcode('ACTIVE_TOPICS_IN', escape_html($forum_name));
     if (array_key_exists('title', $map) && $map['title'] != '') {
         $_title = protect_from_escaping(escape_html($map['title']));
     }
     // Add topic link
     if (count($forum_names) == 1 && get_forum_type() == 'ocf' && !is_null($forum_id)) {
         $submit_url = build_url(array('page' => 'topics', 'type' => 'new_topic', 'id' => $forum_id), get_module_zone('topics'));
         $add_name = do_lang_tempcode('ADD_TOPIC');
     } else {
         $submit_url = new ocp_tempcode();
         $add_name = new ocp_tempcode();
     }
     // Show all topics
     if (get_forum_type() == 'ocf') {
         $forum_names_map = collapse_2d_complexity('id', 'f_name', $GLOBALS['FORUM_DB']->query('SELECT id,f_name FROM ' . $GLOBALS['FORUM_DB']->get_table_prefix() . 'f_forums WHERE f_cache_num_posts>0'));
     } else {
         $forum_names_map = NULL;
     }
     if (!has_no_forum()) {
         $max_rows = 0;
         $topics = $GLOBALS['FORUM_DRIVER']->show_forum_topics($forum_ids, $limit, 0, $max_rows, '', true, $date_key, $hot == 1);
         $out = new ocp_tempcode();
         if (!is_null($topics)) {
             global $M_SORT_KEY;
             $M_SORT_KEY = $date_key;
             usort($topics, 'multi_sort');
             $topics = array_reverse($topics, false);
             if (count($topics) < $limit && $hot == 1) {
                 $more_topics = $GLOBALS['FORUM_DRIVER']->show_forum_topics($forum_ids, $limit, 0, $max_rows, '', true, $date_key);
                 if (is_null($more_topics)) {
                     $more_topics = array();
                 }
                 $topics = array_merge($topics, $more_topics);
             }
             $done = 0;
             $seen = array();
             foreach ($topics as $topic) {
                 if (array_key_exists($topic['id'], $seen)) {
                     continue;
                 }
                 $seen[$topic['id']] = 1;
                 $topic_url = $GLOBALS['FORUM_DRIVER']->topic_url($topic['id'], $forum_name);
                 $topic_url_unread = mixed();
                 if (get_forum_type() == 'ocf') {
                     $topic_url_unread = build_url(array('page' => 'topicview', 'id' => $topic['id'], 'type' => 'first_unread'), get_module_zone('topicview'), NULL, false, false, false, 'first_unread');
                 }
                 $title = escape_html($topic['title']);
                 $date = get_timezoned_date($topic[$date_key]);
                 $username = $topic[$username_key];
                 $member_id = array_key_exists($memberid_key, $topic) ? $topic[$memberid_key] : NULL;
                 if (!is_null($forum_names_map) && !array_key_exists($topic['forum_id'], $forum_names_map)) {
                     continue;
                 }
                 // Maybe Private Topic, slipped in via reference to a missing forum
                 $forum_name = is_null($forum_names_map) ? NULL : $forum_names_map[$topic['forum_id']];
                 $out->attach(do_template('BLOCK_MAIN_FORUM_TOPICS_TOPIC', array('_GUID' => 'ae4e351b3fa5422bf8ecdfb7e49076d1', 'POST' => $topic['firstpost'], 'FORUM_ID' => is_null($forum_names_map) ? NULL : strval($topic['forum_id']), 'FORUM_NAME' => $forum_name, 'TOPIC_LINK' => $topic_url, 'TOPIC_LINK_UNREAD' => $topic_url_unread, 'TITLE' => $title, 'DATE' => $date, 'DATE_RAW' => strval($topic[$date_key]), 'USERNAME' => $username, 'MEMBER_ID' => is_null($member_id) ? '' : strval($member_id), 'NUM_POSTS' => integer_format($topic['num']))));
                 $done++;
                 if ($done == $limit) {
                     break;
                 }
             }
         }
         if ($out->is_empty()) {
             return do_template('BLOCK_NO_ENTRIES', array('_GUID' => 'c76ab018a0746c2875c6cf69c92a01fb', 'HIGH' => false, 'FORUM_NAME' => array_key_exists('param', $map) ? $map['param'] : 'General chat', 'TITLE' => $_title, 'MESSAGE' => do_lang_tempcode($hot == 1 ? 'NO_TOPICS_HOT' : 'NO_TOPICS'), 'ADD_NAME' => $add_name, 'SUBMIT_URL' => $submit_url));
         }
         return do_template('BLOCK_MAIN_FORUM_TOPICS', array('_GUID' => '368b80c49a335ad035b00510681d5008', 'TITLE' => $_title, 'CONTENT' => $out, 'FORUM_NAME' => array_key_exists('param', $map) ? $map['param'] : 'General chat', 'SUBMIT_URL' => $submit_url));
     } else {
         return new ocp_tempcode();
     }
 }
Beispiel #18
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));
 }
Beispiel #19
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));
 }
Beispiel #20
0
 /**
  * The UI to translate code.
  *
  * @return tempcode		The UI
  */
 function interface_code()
 {
     $lang = filter_naughty_harsh(get_param('lang', ''));
     $lang_new = get_param('lang_new', $lang);
     if ($lang_new != '') {
         require_code('type_validation');
         if (!is_alphanumeric($lang_new, true)) {
             warn_exit(do_lang_tempcode('BAD_CODENAME'));
         }
         if (strlen($lang_new) > 5) {
             warn_exit(do_lang_tempcode('INVALID_LANG_CODE'));
         }
         $lang = $lang_new;
     }
     if ($lang == '') {
         $title = get_page_title('TRANSLATE_CODE');
         $GLOBALS['HELPER_PANEL_TEXT'] = comcode_lang_string('DOC_FIND_LANG_STRING_TIP');
         return $this->choose_lang($title, true, true, do_lang_tempcode('CHOOSE_EDIT_LIST_LANG_FILE'));
     }
     breadcrumb_set_parents(array(array('_SELF:_SELF:misc', do_lang_tempcode('CHOOSE'))));
     breadcrumb_set_self(do_lang_tempcode('TRANSLATE_CODE'));
     $base_lang = fallback_lang();
     $map_a = get_file_base() . '/lang/langs.ini';
     $map_b = get_custom_file_base() . '/lang_custom/langs.ini';
     $search = get_param('search', '', true);
     if ($search != '') {
         $title = get_page_title('TRANSLATE_CODE');
         require_code('form_templates');
         $fields = new ocp_tempcode();
         global $LANGUAGE;
         foreach ($LANGUAGE[user_lang()] as $key => $value) {
             if (strpos(strtolower($value), strtolower($search)) !== false) {
                 $fields->attach(form_input_text($key, '', 'l_' . $key, str_replace('\\n', chr(10), $value), false));
             }
         }
         if ($fields->is_empty()) {
             inform_exit(do_lang_tempcode('NO_ENTRIES'));
         }
         $post_url = build_url(array('page' => '_SELF', 'type' => '_code2'), '_SELF');
         $hidden = new ocp_tempcode();
         $hidden->attach(form_input_hidden('redirect', get_self_url(true)));
         $hidden->attach(form_input_hidden('lang', $lang));
         return do_template('FORM_SCREEN', array('_GUID' => '2d7356fd2c4497ceb19450e65331c9c5', 'TITLE' => $title, 'HIDDEN' => $hidden, 'FIELDS' => $fields, 'URL' => $post_url, 'TEXT' => '', 'SUBMIT_NAME' => do_lang('TRANSLATE_CODE')));
     }
     $lang_file = get_param('lang_file');
     if (!file_exists($map_b)) {
         $map_b = $map_a;
     }
     $map = better_parse_ini_file($map_b);
     $title = get_page_title('_TRANSLATE_CODE', true, array(escape_html($lang_file), escape_html(array_key_exists($lang, $map) ? $map[$lang] : $lang)));
     // Upgrade to custom if not there yet (or maybe we are creating a new lang - same difference)
     $custom_dir = get_custom_file_base() . '/lang_custom/' . $lang;
     if (!file_exists($custom_dir)) {
         require_code('abstract_file_manager');
         force_have_afm_details();
         afm_make_directory('lang_custom/' . $lang, true);
         $cached_dir = get_custom_file_base() . '/lang_cached/' . $lang;
         if (!file_exists($cached_dir)) {
             afm_make_directory('lang_cached/' . $lang, true);
         }
         // Make comcode page dirs
         $zones = find_all_zones();
         foreach ($zones as $zone) {
             $_special_dir = get_custom_file_base() . '/' . $zone . '/pages/comcode_custom/' . $lang;
             if (!file_exists($_special_dir)) {
                 afm_make_directory($zone . ($zone == '' ? '' : '/') . 'pages/comcode_custom/' . $lang, true);
             }
             $_special_dir = get_custom_file_base() . '/' . $zone . '/pages/html_custom/' . $lang;
             if (!file_exists($_special_dir)) {
                 afm_make_directory($zone . ($zone == '' ? '' : '/') . 'pages/html_custom/' . $lang, true);
             }
         }
         // Make templates_cached dirs
         require_code('themes2');
         $themes = find_all_themes();
         foreach (array_keys($themes) as $theme) {
             $_special_dir = get_custom_file_base() . '/themes/' . $theme . '/templates_cached/' . $lang;
             if (!file_exists($_special_dir)) {
                 afm_make_directory('themes/' . $theme . '/templates_cached/' . $lang, true);
             }
         }
     }
     // Get some stuff
     $for_lang = get_lang_file_map($lang, $lang_file);
     $for_base_lang = get_lang_file_map($base_lang, $lang_file, true);
     $descriptions = get_lang_file_descriptions($base_lang, $lang_file);
     // Make our translation page
     $lines = '';
     $intertrans = $this->get_intertran_conv($lang);
     $actions = new ocp_tempcode();
     $next = 0;
     $trans_lot = '';
     $delimit = chr(10) . '=-=-=-=-=-=-=-=-' . chr(10);
     foreach ($for_base_lang as $name => $old) {
         if (array_key_exists($name, $for_lang)) {
             $current = $for_lang[$name];
         } else {
             $current = '';
             //$this->find_lang_matches($old,$lang); Too slow / useless for code translation
         }
         if ($current == '' && strtolower($name) != $name) {
             $trans_lot .= str_replace('\\n', chr(10), str_replace(array('{', '}'), array('(((', ')))'), $old)) . $delimit;
         }
     }
     $translated_stuff = array();
     if ($trans_lot != '' && $intertrans != '') {
         $result = http_download_file('http://translate.google.com/translate_t', NULL, false, false, 'ocPortal', array('text' => $trans_lot, 'langpair' => 'en|' . $intertrans));
         if (!is_null($result)) {
             require_code('character_sets');
             $result = convert_to_internal_encoding($result);
             $matches = array();
             if (preg_match('#<div id=result_box dir="ltr">(.*)</div>#Us', convert_to_internal_encoding($result), $matches) != 0) {
                 $result2 = $matches[1];
                 $result2 = @html_entity_decode($result2, ENT_QUOTES, get_charset());
                 $result2 = preg_replace('#\\s?<br>\\s?#', chr(10), $result2);
                 $result2 = str_replace('> ', '>', str_replace(' <', ' <', str_replace('</ ', '</', str_replace(array('(((', ')))'), array('{', '}'), $result2))));
                 $translated_stuff = explode(trim($delimit), $result2 . chr(10));
             }
         }
     }
     foreach ($for_base_lang + $for_lang as $name => $old) {
         if (array_key_exists($name, $for_lang)) {
             $current = $for_lang[$name];
         } else {
             $current = '';
             //$this->find_lang_matches($old,$lang); Too slow / useless for code translation
         }
         $description = array_key_exists($name, $descriptions) ? $descriptions[$name] : '';
         if ($current == '' && strtolower($name) != $name && array_key_exists($next, $translated_stuff)) {
             $_current = '';
             $translate_auto = trim($translated_stuff[$next]);
             $next++;
         } else {
             $_current = str_replace('\\n', chr(10), $current);
             $translate_auto = NULL;
         }
         if ($_current == '') {
             $_current = str_replace('\\n', chr(10), $old);
         }
         if ($intertrans != '' && get_value('google_translate_api_key') !== NULL) {
             $actions = do_template('TRANSLATE_ACTION', array('_GUID' => '9e9a68cb2c1a1e23a901b84c9af2280b', 'LANG_FROM' => get_site_default_lang(), 'LANG_TO' => $lang, 'NAME' => 'trans_' . $name, 'OLD' => $_current));
         }
         $temp = do_template('TRANSLATE_LINE', array('_GUID' => '9cb331f5852ee043e6ad30b45aedc43b', 'TRANSLATE_AUTO' => $translate_auto, 'DESCRIPTION' => $description, 'NAME' => $name, 'OLD' => str_replace('\\n', chr(10), $old), 'CURRENT' => $_current, 'ACTIONS' => $actions));
         $lines .= $temp->evaluate();
     }
     $url = build_url(array('page' => '_SELF', 'type' => '_code', 'lang_file' => $lang_file, 'lang' => $lang), '_SELF');
     return do_template('TRANSLATE_SCREEN', array('_GUID' => 'b3429f8bd0b4eb79c33709ca43e3207c', 'PAGE' => $lang_file, 'INTERTRANS' => get_value('google_translate_api_key') !== NULL ? $intertrans : '', 'LANG' => $lang, 'LINES' => $lines, 'TITLE' => $title, 'URL' => $url));
 }
Beispiel #21
0
 /**
  * Standard modular UI to edit an entry.
  *
  * @return tempcode	The UI
  */
 function _ed()
 {
     $doing = 'EDIT_' . $this->lang_type;
     if ($this->catalogue && get_param('catalogue_name', '') != '') {
         $catalogue_title = get_translated_text($GLOBALS['SITE_DB']->query_value('catalogues', 'c_title', array('c_name' => get_param('catalogue_name'))));
         if ($this->type_code == 'd') {
             $doing = do_lang('CATALOGUE_GENERIC_EDIT', escape_html($catalogue_title));
         } elseif ($this->type_code == 'c') {
             $doing = do_lang('CATALOGUE_GENERIC_EDIT_CATEGORY', escape_html($catalogue_title));
         }
     }
     $title = get_page_title($doing);
     //$submit_name=(strpos($doing,' ')!==false)?protect_from_escaping($doing):do_lang($doing);
     //if (!is_null($this->edit_submit_name)) $submit_name=$this->edit_submit_name;
     $submit_name = do_lang_tempcode('SAVE');
     //$test=$this->choose_catalogue($title);
     //if (!is_null($test)) return $test;
     $id = mixed();
     // Define type as mixed
     $id = $this->non_integer_id ? get_param('id', false, true) : strval(get_param_integer('id'));
     $map = array('page' => '_SELF', 'type' => '__e' . $this->type_code, 'id' => $id);
     if (get_param('catalogue_name', '') != '') {
         $map['catalogue_name'] = get_param('catalogue_name');
     }
     if (!is_null(get_param('redirect', NULL))) {
         $map['redirect'] = get_param('redirect');
     }
     if (!is_null(get_param('continue', NULL))) {
         $map['continue'] = get_param('continue');
     }
     if (!is_null($this->upload) || $this->possibly_some_kind_of_upload) {
         $map['uploading'] = 1;
     }
     $post_url = build_url($map, '_SELF');
     if (multi_lang() && has_actual_page_access(get_member(), 'admin_lang') && user_lang() != get_site_default_lang()) {
         require_code('lang2');
         $switch_url = get_self_url(false, false, array('keep_lang' => get_site_default_lang()));
         attach_message(do_lang_tempcode('lang:EDITING_CONTENT_IN_LANGUAGE_STAFF', escape_html(lookup_language_full_name(user_lang())), escape_html(lookup_language_full_name(get_site_default_lang())), escape_html($switch_url->evaluate())), 'warn');
     }
     if (method_exists($this, 'get_submitter')) {
         list($submitter, $date_and_time) = $this->get_submitter($id);
     } else {
         $submitter = NULL;
         $date_and_time = NULL;
     }
     if (!is_null($this->permissions_require)) {
         check_edit_permission($this->permissions_require, $submitter, array($this->permissions_cat_require, is_null($this->permissions_cat_name) ? NULL : $this->get_cat($id), $this->permissions_cat_require_b, is_null($this->permissions_cat_name_b) ? NULL : $this->get_cat_b($id)), $this->permission_page_name);
     }
     if (!is_null($this->permissions_cat_require) && !has_category_access(get_member(), $this->permissions_cat_require, $this->get_cat($id))) {
         access_denied('CATEGORY_ACCESS');
     }
     if (!is_null($this->permissions_cat_require_b) && !has_category_access(get_member(), $this->permissions_cat_require_b, $this->get_cat_b($id))) {
         access_denied('CATEGORY_ACCESS');
     }
     $bits = $this->fill_in_edit_form($id);
     $delete_fields = new ocp_tempcode();
     $all_delete_fields_given = false;
     $fields2 = new ocp_tempcode();
     if (is_array($bits)) {
         $fields = $bits[0];
         $hidden = $bits[1];
         if (array_key_exists(2, $bits) && !is_null($bits[2])) {
             $delete_fields = $bits[2];
         }
         if (array_key_exists(3, $bits) && !is_null($bits[3])) {
             $this->edit_text = $bits[3];
         }
         if (array_key_exists(4, $bits) && $bits[4]) {
             $all_delete_fields_given = true;
         }
         if (array_key_exists(5, $bits) && !is_null($bits[5])) {
             $this->posting_form_text = $bits[5];
         }
         if (array_key_exists(6, $bits) && !is_null($bits[6])) {
             $fields2 = $bits[6];
         }
         if (array_key_exists(7, $bits)) {
             $this->posting_form_text_parsed = $bits[7];
         }
     } else {
         $fields = $bits;
         $hidden = new ocp_tempcode();
     }
     // Add in custom fields
     if ($this->has_tied_catalogue()) {
         require_code('fields');
         $fields->attach(do_template('FORM_SCREEN_FIELD_SPACER', array('TITLE' => do_lang_tempcode('MORE'))));
         append_form_custom_fields($this->award_type, $id, $fields, $hidden);
     }
     // SEO?
     if (!is_null($this->seo_type)) {
         require_code('seo2');
         $fields2->attach(seo_get_fields($this->seo_type, $id));
     }
     // Awards?
     if (addon_installed('awards')) {
         if (!is_null($this->award_type)) {
             require_code('awards');
             $fields2->attach(get_award_fields($this->award_type, $id));
         }
     }
     // Action fields / deletion options
     $delete_permission = true;
     if (!is_null($this->permissions_require)) {
         $delete_permission = has_delete_permission($this->permissions_require, get_member(), $submitter, is_null($this->permission_page_name) ? get_page_name() : $this->permission_page_name, array($this->permissions_cat_require, is_null($this->permissions_cat_name) ? NULL : $this->get_cat($id), $this->permissions_cat_require_b, is_null($this->permissions_cat_name_b) ? NULL : $this->get_cat_b($id)));
     }
     $may_delete = (!method_exists($this, 'may_delete_this') || $this->may_delete_this($id)) && (!is_numeric($id) || intval($id) >= db_get_first_id() + $this->protect_first) && $delete_permission;
     // Deletion options
     $action_fields = new ocp_tempcode();
     if ($may_delete) {
         if (!$all_delete_fields_given) {
             $action_fields->attach(form_input_tick(do_lang_tempcode('DELETE'), do_lang_tempcode('DESCRIPTION_DELETE'), 'delete', false));
         }
         if (addon_installed('points') && !is_null($submitter) && !is_null($date_and_time)) {
             $points_test = $GLOBALS['SITE_DB']->query_value_null_ok('gifts', 'id', array('date_and_time' => $date_and_time, 'gift_to' => $submitter, 'gift_from' => $GLOBALS['FORUM_DRIVER']->get_guest_id()));
             if (!is_null($points_test)) {
                 require_lang('points');
                 $action_fields->attach(form_input_tick(do_lang_tempcode('REVERSE_TITLE'), do_lang_tempcode('REVERSE_TITLE_DESCRIPTION'), 'reverse_point_transaction', false));
             }
         }
         $action_fields->attach($delete_fields);
     }
     if (!$this->appended_actions_already && !$action_fields->is_empty()) {
         $fields2->attach(do_template('FORM_SCREEN_FIELD_SPACER', array('TITLE' => do_lang_tempcode('ACTIONS'))));
     }
     $fields2->attach($action_fields);
     if (!is_object($this->edit_text)) {
         $this->edit_text = make_string_tempcode(is_null($this->edit_text) ? '' : $this->edit_text);
     }
     if (!is_null($this->upload)) {
         if ($this->upload == 'image') {
             require_code('images');
             $max = floatval(get_max_image_size()) / floatval(1024 * 1024);
             if ($max < 3.0) {
                 require_code('files2');
                 $config_url = get_upload_limit_config_url();
                 $this->edit_text->attach(paragraph(do_lang_tempcode(is_null($config_url) ? 'MAXIMUM_UPLOAD' : 'MAXIMUM_UPLOAD_STAFF', escape_html($max > 10.0 ? integer_format(intval($max)) : float_format($max)), escape_html(is_null($config_url) ? '' : $config_url))));
             }
         } else {
             require_code('files2');
             $max = floatval(get_max_file_size()) / floatval(1024 * 1024);
             if ($max < 30.0) {
                 $config_url = get_upload_limit_config_url();
                 $this->edit_text->attach(paragraph(do_lang_tempcode(is_null($config_url) ? 'MAXIMUM_UPLOAD' : 'MAXIMUM_UPLOAD_STAFF', escape_html($max > 10.0 ? integer_format(intval($max)) : float_format($max)), escape_html(is_null($config_url) ? '' : $config_url))));
             }
         }
     }
     if (get_param('type', '_ed') == '_edit_catalogue') {
         require_javascript('javascript_catalogues');
         // Existing fields
         $field_count = 0;
         $c_name = get_param('id', false, true);
         $rows = $GLOBALS['SITE_DB']->query_select('catalogue_fields', array('*'), array('c_name' => $c_name), 'ORDER BY cf_order');
         $fields_existing = new ocp_tempcode();
         foreach ($rows as $i => $myrow) {
             $name = get_translated_text($myrow['cf_name']);
             $description = get_translated_text($myrow['cf_description']);
             $prefix = 'existing_field_' . strval($myrow['id']) . '_';
             list($_fields_existing, $_fields_hidden) = $this->get_field_fields($i == 0 && substr($c_name, 0, 1) != '_', count($rows) + 10, $prefix, $field_count, $name, $description, $myrow['cf_type'], $myrow['cf_defines_order'], $myrow['cf_visible'], $myrow['cf_searchable'], $myrow['cf_default'], $myrow['cf_required'], $myrow['cf_put_in_category'], $myrow['cf_put_in_search']);
             if (!is_ecommerce_catalogue($c_name) || $i > 9) {
                 $_fields_existing->attach(do_template('FORM_SCREEN_FIELD_SPACER', array('TITLE' => do_lang_tempcode('ACTIONS'))));
                 $_fields_existing->attach(form_input_tick(do_lang_tempcode('DELETE'), do_lang_tempcode('DESCRIPTION_DELETE'), $prefix . 'delete', false));
             }
             $temp = do_template('FORM_FIELD_SET_GROUPER', array('_GUID' => '1492d973db45cbecff892ad4ac1af28f' . get_class($this), 'NAME' => $name, 'ID' => 'FIELD_' . strval($i + 1), 'FIELDS' => $_fields_existing->evaluate()));
             $fields_existing->attach($temp);
             $hidden->attach($_fields_hidden);
             $field_count++;
         }
         // New field
         $fields_new = new ocp_tempcode();
         for ($i = 0; $i < 5; $i++) {
             list($_fields_new, $_fields_hidden) = $this->get_field_fields(false, count($rows) + 10, 'new_field_' . strval($i) . '_', $field_count);
             $temp = do_template('FORM_FIELD_SET_GROUPER', array('_GUID' => '8b9a632eafae003ccc6b007eefb0ce3d' . get_class($this), 'NAME' => do_lang_tempcode('NEW_FIELD', strval($i + 1)), 'ID' => 'NEW_FIELD_' . strval($i + 1), 'FIELDS' => $_fields_new->evaluate()));
             $fields_new->attach($temp);
             $hidden->attach($_fields_hidden);
             $field_count++;
         }
         $fields->attach($fields2);
         return do_template('CATALOGUE_EDITING_SCREEN', array('_GUID' => '584d7dc7c2c13939626102374f13f508' . get_class($this), 'HIDDEN' => $hidden, 'TITLE' => $title, 'TEXT' => $this->add_text, 'URL' => $post_url, 'FIELDS' => $fields->evaluate(), 'FIELDS_EXISTING' => $fields_existing->evaluate(), 'FIELDS_NEW' => $fields_new->evaluate(), 'SUBMIT_NAME' => $submit_name, 'JAVASCRIPT' => $this->javascript));
     }
     list($warning_details, $ping_url) = handle_conflict_resolution();
     if (!is_null($this->posting_form_title)) {
         $posting_form = get_posting_form($submit_name, $this->posting_form_text, $post_url, $hidden, $fields, $this->posting_form_title, '', $fields2, $this->posting_form_text_parsed, $this->javascript, NULL, $this->posting_field_required);
         return do_template('POSTING_SCREEN', array('_GUID' => '841b9af3aa80bcab86b907e4b942786a' . get_class($this), 'PREVIEW' => $this->do_preview, 'TITLE' => $title, 'SEPARATE_PREVIEW' => $this->second_stage_preview, 'PING_URL' => $ping_url, 'WARNING_DETAILS' => $warning_details, 'TEXT' => $this->add_text, 'POSTING_FORM' => $posting_form->evaluate(), 'JAVASCRIPT' => $this->javascript));
     } else {
         $fields->attach($fields2);
         return do_template('FORM_SCREEN', array('_GUID' => '2d70be34595a16c6f170d966b894bfe2' . get_class($this), 'PREVIEW' => $this->do_preview, 'SEPARATE_PREVIEW' => $this->second_stage_preview, 'TITLE' => $title, 'SKIP_VALIDATION' => $this->skip_validation, 'PING_URL' => $ping_url, 'WARNING_DETAILS' => $warning_details, 'HIDDEN' => $hidden, 'TEXT' => $this->edit_text, 'URL' => $post_url, 'FIELDS' => $fields->evaluate(), 'SUBMIT_NAME' => $submit_name, 'JAVASCRIPT' => $this->javascript));
     }
 }
Beispiel #22
0
 /**
  * The main user interface for the file dump.
  *
  * @return tempcode	The UI.
  */
 function module_do_gui()
 {
     $title = get_page_title('FILE_DUMP');
     $place = filter_naughty(get_param('place', '/'));
     if (substr($place, -1, 1) != '/') {
         $place .= '/';
     }
     $GLOBALS['FEED_URL'] = find_script('backend') . '?mode=filedump&filter=' . $place;
     // Show tree
     $dirs = explode('/', substr($place, 0, strlen($place) - 1));
     $i = 0;
     $pre = '';
     $file_tree = new ocp_tempcode();
     while (array_key_exists($i, $dirs)) {
         if ($i > 0) {
             $d = $dirs[$i];
         } else {
             $d = do_lang('FILE_DUMP');
         }
         if (array_key_exists($i + 1, $dirs)) {
             $tree_url = build_url(array('page' => '_SELF', 'place' => $pre . $dirs[$i] . '/'), '_SELF');
             if (!$file_tree->is_empty()) {
                 $file_tree->attach(do_template('BREADCRUMB', array('_GUID' => '7ee62e230d53344a7d9667dc59be21c6')));
             }
             $file_tree->attach(hyperlink($tree_url, $d));
         }
         $pre .= $dirs[$i] . '/';
         $i++;
     }
     if (!$file_tree->is_empty()) {
         breadcrumb_add_segment($file_tree, $d);
     } else {
         breadcrumb_set_self($i == 1 ? do_lang_tempcode('FILE_DUMP') : make_string_tempcode(escape_html($d)));
     }
     // Check directory exists
     $fullpath = get_custom_file_base() . '/uploads/filedump' . $place;
     if (!file_exists(get_custom_file_base() . '/uploads/filedump' . $place)) {
         if (has_specific_permission(get_member(), 'upload_filedump')) {
             @mkdir($fullpath, 0777) or warn_exit(do_lang_tempcode('WRITE_ERROR_DIRECTORY', escape_html($fullpath), escape_html(dirname($fullpath))));
             fix_permissions($fullpath, 0777);
             sync_file($fullpath);
         }
     }
     // Find all files in the incoming directory
     $handle = opendir(get_custom_file_base() . '/uploads/filedump' . $place);
     $i = 0;
     $filename = array();
     $description = array();
     $filesize = array();
     $filetime = array();
     $directory = array();
     $deletable = array();
     while (false !== ($file = readdir($handle))) {
         if (!should_ignore_file('uploads/filedump' . $place . $file, IGNORE_ACCESS_CONTROLLERS | IGNORE_HIDDEN_FILES)) {
             $directory[$i] = !is_file(get_custom_file_base() . '/uploads/filedump' . $place . $file);
             $filename[$i] = $directory[$i] ? $file . '/' : $file;
             if ($directory[$i]) {
                 $filesize[$i] = do_lang_tempcode('NA_EM');
             }
             $dbrows = $GLOBALS['SITE_DB']->query_select('filedump', array('description', 'the_member'), array('name' => $file, 'path' => $place));
             if (!array_key_exists(0, $dbrows)) {
                 $description[$i] = $directory[$i] ? do_lang_tempcode('NA_EM') : do_lang_tempcode('NONE_EM');
             } else {
                 $description[$i] = make_string_tempcode(escape_html(get_translated_text($dbrows[0]['description'])));
             }
             if ($description[$i]->is_empty()) {
                 $description[$i] = do_lang_tempcode('NONE_EM');
             }
             $deletable[$i] = array_key_exists(0, $dbrows) && $dbrows[0]['the_member'] == get_member() || has_specific_permission(get_member(), 'delete_anything_filedump');
             if ($directory[$i]) {
                 $size = get_directory_size(get_custom_file_base() . '/uploads/filedump' . $place . $file);
                 $timestamp = NULL;
             } else {
                 $size = filesize(get_custom_file_base() . '/uploads/filedump' . $place . $file);
                 $timestamp = filemtime(get_custom_file_base() . '/uploads/filedump' . $place . $file);
             }
             $filesize[$i] = clean_file_size($size);
             $filetime[$i] = is_null($timestamp) ? NULL : get_timezoned_date($timestamp);
             $i++;
         }
     }
     closedir($handle);
     if ($i != 0) {
         require_code('templates_table_table');
         $header_row = table_table_header_row(array(do_lang_tempcode('FILENAME'), do_lang_tempcode('DESCRIPTION'), do_lang_tempcode('SIZE'), do_lang_tempcode('DATE_TIME'), do_lang_tempcode('ACTIONS')));
         $rows = new ocp_tempcode();
         for ($a = 0; $a < $i; $a++) {
             if ($directory[$a]) {
                 $link = build_url(array('page' => '_SELF', 'place' => $place . $filename[$a]), '_SELF');
             } else {
                 $link = make_string_tempcode(get_custom_base_url() . '/uploads/filedump' . str_replace('%2F', '/', rawurlencode($place . $filename[$a])));
             }
             if (!$directory[$a]) {
                 if ($deletable[$a]) {
                     $delete_url = build_url(array('page' => '_SELF', 'type' => 'ed', 'file' => $filename[$a], 'place' => $place), '_SELF');
                     $actions = do_template('TABLE_TABLE_ACTION_DELETE_ENTRY', array('_GUID' => '9b91e485d80417b1664145f9bca5a2f5', 'NAME' => $filename[$a], 'URL' => $delete_url));
                 } else {
                     $actions = new ocp_tempcode();
                 }
             } else {
                 $delete_url = build_url(array('page' => '_SELF', 'type' => 'ec', 'file' => $filename[$a], 'place' => $place), '_SELF');
                 $actions = do_template('TABLE_TABLE_ACTION_DELETE_CATEGORY', array('_GUID' => '0fa7d4090c6195328191399a14799169', 'NAME' => $filename[$a], 'URL' => $delete_url));
             }
             $rows->attach(table_table_row(array(hyperlink($link, escape_html($filename[$a]), !$directory[$a]), escape_html($description[$a]), escape_html($filesize[$a]), is_null($filetime[$a]) ? do_lang_tempcode('NA') : make_string_tempcode(escape_html($filetime[$a])), $actions)));
         }
         $files = do_template('TABLE_TABLE', array('_GUID' => '1c0a91d47c5fc8a7c2b35c7d9b36132f', 'HEADER_ROW' => $header_row, 'ROWS' => $rows));
     } else {
         $files = new ocp_tempcode();
     }
     // Do a form so people can upload their own stuff
     if (has_specific_permission(get_member(), 'upload_filedump')) {
         $post_url = build_url(array('page' => '_SELF', 'type' => 'ad', 'uploading' => 1), '_SELF');
         $submit_name = do_lang_tempcode('FILEDUMP_UPLOAD');
         $max = floatval(get_max_file_size());
         $text = new ocp_tempcode();
         if ($max < 30.0) {
             $config_url = get_upload_limit_config_url();
             $text->attach(do_lang_tempcode(is_null($config_url) ? 'MAXIMUM_UPLOAD' : 'MAXIMUM_UPLOAD_STAFF', escape_html($max > 10.0 ? integer_format(intval($max)) : float_format($max / 1024.0 / 1024.0)), escape_html(is_null($config_url) ? '' : $config_url)));
         }
         require_code('form_templates');
         $fields = form_input_upload(do_lang_tempcode('UPLOAD'), do_lang_tempcode('_DESCRIPTION_UPLOAD'), 'file', true);
         $fields->attach(form_input_line(do_lang_tempcode('DESCRIPTION'), do_lang_tempcode('DESCRIPTION_DESCRIPTION'), 'description', '', false));
         $hidden = new ocp_tempcode();
         $hidden->attach(form_input_hidden('place', $place));
         handle_max_file_size($hidden);
         $upload_form = do_template('FORM', array('TABINDEX' => strval(get_form_field_tabindex()), 'SKIP_REQUIRED' => true, 'HIDDEN' => $hidden, 'TEXT' => $text, 'FIELDS' => $fields, 'SUBMIT_NAME' => $submit_name, 'URL' => $post_url));
     } else {
         $upload_form = new ocp_tempcode();
     }
     // Do a form so people can make folders
     if (get_option('is_on_folder_create') == '1') {
         $post_url = build_url(array('page' => '_SELF', 'type' => 'ac'), '_SELF');
         require_code('form_templates');
         $fields = form_input_line(do_lang_tempcode('NAME'), do_lang_tempcode('DESCRIPTION_NAME'), 'name', '', true);
         $hidden = form_input_hidden('place', $place);
         $submit_name = do_lang_tempcode('FILEDUMP_CREATE_FOLDER');
         $create_folder_form = do_template('FORM', array('_GUID' => '043f9b595d3699b7d8cd7f2284cdaf98', 'TABINDEX' => strval(get_form_field_tabindex()), 'SKIP_REQUIRED' => true, 'SECONDARY_FORM' => true, 'HIDDEN' => $hidden, 'TEXT' => '', 'FIELDS' => $fields, 'SUBMIT_NAME' => $submit_name, 'URL' => $post_url));
     } else {
         $create_folder_form = new ocp_tempcode();
     }
     return do_template('FILE_DUMP_SCREEN', array('_GUID' => '3f49a8277a11f543eff6488622949c84', 'TITLE' => $title, 'PLACE' => $place, 'FILES' => $files, 'UPLOAD_FORM' => $upload_form, 'CREATE_FOLDER_FORM' => $create_folder_form));
 }
Beispiel #23
0
 /**
  * The UI to select to view a past newsletter.
  *
  * @return tempcode		The UI
  */
 function archive()
 {
     $title = get_page_title('NEWSLETTER_ARCHIVE');
     $lang = choose_language($title);
     if (is_object($lang)) {
         return $lang;
     }
     $newsletters = new ocp_tempcode();
     $where = multi_lang() ? array('language' => $lang) : NULL;
     $rows = $GLOBALS['SITE_DB']->query_select('newsletter_archive', array('id', 'subject', 'date_and_time'), $where, 'ORDER BY date_and_time DESC');
     foreach ($rows as $newsletter) {
         $newsletters->attach(form_input_list_entry(strval($newsletter['id']), false, $newsletter['subject']));
     }
     if ($newsletters->is_empty()) {
         inform_exit(do_lang_tempcode('NO_ENTRIES'));
     }
     require_code('form_templates');
     $fields = form_input_list(do_lang_tempcode('NEWSLETTER'), '', 'id', $newsletters, NULL, true);
     $hidden = form_input_hidden('lang', $lang);
     $submit_name = do_lang_tempcode('VIEW');
     $post_url = build_url(array('page' => '_SELF', 'type' => 'view'), '_SELF', NULL, false, true);
     return do_template('FORM_SCREEN', array('_GUID' => 'ee295e41dc86c4583c123e6e0e445380', 'GET' => true, 'SKIP_VALIDATION' => true, 'HIDDEN' => $hidden, 'TITLE' => $title, 'TEXT' => '', 'FIELDS' => $fields, 'SUBMIT_NAME' => $submit_name, 'URL' => $post_url));
 }
Beispiel #24
0
 /**
  * Standard modular run function.
  *
  * @return tempcode	The result of execution.
  */
 function run()
 {
     if (get_forum_type() != 'ocf') {
         warn_exit(do_lang_tempcode('NO_OCF'));
     } else {
         ocf_require_all_forum_stuff();
     }
     require_code('ocf_topicview');
     require_css('ocf');
     global $NON_CANONICAL_PARAMS;
     $NON_CANONICAL_PARAMS[] = 'max';
     $NON_CANONICAL_PARAMS[] = 'start';
     $NON_CANONICAL_PARAMS[] = 'threaded';
     $start = get_param_integer('start', 0);
     $default_max = intval(get_option('forum_posts_per_page'));
     $max = get_param_integer('max', $default_max);
     if ($max == 0) {
         $max = $default_max;
     }
     if ($max == 0) {
         $max = 1;
     }
     if ($max > 30 && !has_specific_permission(get_member(), 'remove_page_split')) {
         $max = $default_max;
     }
     $first_unread_id = -1;
     global $NON_CANONICAL_PARAMS;
     foreach (array_keys($_GET) as $key) {
         if (substr($key, 0, 3) == 'kfs') {
             $NON_CANONICAL_PARAMS[] = $key;
         }
     }
     $type = get_param('type', 'misc');
     $id = get_param_integer('id', NULL);
     if (is_guest() && is_null($id)) {
         access_denied('NOT_AS_GUEST');
     }
     if ($type == 'findpost') {
         $post_id = get_param_integer('id');
         $redirect = find_post_id_url($post_id);
         require_code('site2');
         assign_refresh($redirect, 0.0);
         return do_template('REDIRECT_SCREEN', array('_GUID' => '76e6d34c20a4f5284119827e41c7752f', 'URL' => $redirect, 'TITLE' => get_page_title('VIEW_TOPIC'), 'TEXT' => do_lang_tempcode('REDIRECTING')));
     } else {
         if ($type == 'first_unread') {
             $redirect = find_first_unread_url($id);
             require_code('site2');
             assign_refresh($redirect, 0.0);
             return do_template('REDIRECT_SCREEN', array('_GUID' => '12c5d16f60e8c4df03536d9a7a932528', 'URL' => $redirect, 'TITLE' => get_page_title('VIEW_TOPIC'), 'TEXT' => do_lang_tempcode('REDIRECTING')));
         }
     }
     if (!is_null($id)) {
         $GLOBALS['FEED_URL'] = find_script('backend') . '?mode=ocf_topicview&filter=' . strval($id);
     }
     $view_poll_results = get_param_integer('view_poll_results', 0);
     // Mark as read
     if (!is_null($id)) {
         if (!is_guest()) {
             $GLOBALS['FORUM_DB']->query_delete('f_read_logs', array('l_member_id' => get_member(), 'l_topic_id' => $id), '', 1);
             $GLOBALS['FORUM_DB']->query_insert('f_read_logs', array('l_member_id' => get_member(), 'l_topic_id' => $id, 'l_time' => time()), false, true);
             // race condition
         }
         $GLOBALS['FORUM_DB']->query('UPDATE ' . $GLOBALS['FORUM_DB']->get_table_prefix() . 'f_topics SET t_num_views=(t_num_views+1) WHERE id=' . strval((int) $id), 1, NULL, true);
     }
     // Load up topic info
     $topic_info = ocf_read_in_topic($id, $start, $max, $view_poll_results == 1);
     $GLOBALS['META_DATA'] += $topic_info['meta_data'];
     global $SEO_TITLE;
     $SEO_TITLE = do_lang('_VIEW_TOPIC', $topic_info['title']);
     // Render posts according to whether threaded or not
     $threaded = $topic_info['is_threaded'] == 1;
     $may_reply = array_key_exists('may_reply', $topic_info) && ($topic_info['is_open'] || array_key_exists('may_post_closed', $topic_info));
     if (!$threaded) {
         $GLOBALS['META_DATA']['description'] = $topic_info['description'];
         // Poster detail hooks
         $hooks = find_all_hooks('modules', 'topicview');
         $hook_objects = array();
         foreach (array_keys($hooks) as $hook) {
             require_code('hooks/modules/topicview/' . filter_naughty_harsh($hook));
             $object = object_factory('Hook_' . filter_naughty_harsh($hook), true);
             if (is_null($object)) {
                 continue;
             }
             $hook_objects[$hook] = $object;
         }
         // Render non-threaded
         $posts = new ocp_tempcode();
         $replied = false;
         if (is_null($topic_info['forum_id'])) {
             decache('side_ocf_personal_topics', array(get_member()));
             decache('_new_pp', array(get_member()));
         }
         $second_poster = $topic_info['first_poster'];
         foreach ($topic_info['posts'] as $array_id => $_postdetails) {
             if ($array_id == 0) {
                 $description = $topic_info['description'];
             } else {
                 $description = NULL;
             }
             if ($_postdetails['poster'] == get_member()) {
                 $replied = true;
             }
             if ($array_id == 1 && $start == 0 || $array_id == 0 && $start != 0) {
                 $second_poster = $_postdetails['poster'];
             }
             if (array_key_exists('last_edit_time', $_postdetails)) {
                 $last_edited = do_template('OCF_TOPIC_POST_LAST_EDITED', array('_GUID' => '77a28e8bc3cf2ec2211aafdb5ba192bf', 'LAST_EDIT_DATE_RAW' => is_null($_postdetails['last_edit_time']) ? '' : strval($_postdetails['last_edit_time']), 'LAST_EDIT_DATE' => $_postdetails['last_edit_time_string'], 'LAST_EDIT_PROFILE_URL' => $GLOBALS['FORUM_DRIVER']->member_profile_url($_postdetails['last_edit_by'], false, true), 'LAST_EDIT_USERNAME' => $_postdetails['last_edit_by_username']));
             } else {
                 $last_edited = new ocp_tempcode();
             }
             $last_edited_raw = array_key_exists('last_edit_time', $_postdetails) ? is_null($_postdetails['last_edit_time']) ? '' : strval($_postdetails['last_edit_time']) : '0';
             $is_spacer_post = $_postdetails['is_spacer_post'];
             // Post buttons
             $buttons = new ocp_tempcode();
             if (!$is_spacer_post) {
                 $buttons = ocf_render_post_buttons($topic_info, $_postdetails, $may_reply);
             }
             // Avatar
             if (array_key_exists('poster_avatar', $_postdetails) && $_postdetails['poster_avatar'] != '') {
                 $post_avatar = do_template('OCF_TOPIC_POST_AVATAR', array('_GUID' => 'd647ada9c11d56eedc0ff7894d33e83c', 'AVATAR' => $_postdetails['poster_avatar']));
             } else {
                 $post_avatar = new ocp_tempcode();
             }
             // Rank images
             $rank_images = new ocp_tempcode();
             if (!$is_spacer_post) {
                 $posters_groups = $GLOBALS['FORUM_DRIVER']->get_members_groups($_postdetails['poster'], true);
                 foreach ($posters_groups as $group) {
                     $rank_image = ocf_get_group_property($group, 'rank_image');
                     $group_leader = ocf_get_group_property($group, 'group_leader');
                     $group_name = ocf_get_group_name($group);
                     $rank_image_pri_only = ocf_get_group_property($group, 'rank_image_pri_only');
                     if ($rank_image != '' && ($rank_image_pri_only == 0 || $group == $GLOBALS['FORUM_DRIVER']->get_member_row_field($_postdetails['poster'], 'm_primary_group'))) {
                         $rank_images->attach(do_template('OCF_RANK_IMAGE', array('_GUID' => '0ff7855482b901be95591964d4212c44', 'GROUP_NAME' => $group_name, 'USERNAME' => $GLOBALS['FORUM_DRIVER']->get_username($_postdetails['poster']), 'IMG' => $rank_image, 'IS_LEADER' => $group_leader == $_postdetails['poster'])));
                     }
                 }
             }
             // Poster details
             if (!$is_spacer_post) {
                 if (!is_guest($_postdetails['poster'])) {
                     require_code('ocf_members2');
                     $poster_details = ocf_show_member_box($_postdetails, false, $hooks, $hook_objects, false);
                 } else {
                     $custom_fields = new ocp_tempcode();
                     if (array_key_exists('ip_address', $_postdetails)) {
                         $custom_fields->attach(do_template('OCF_TOPIC_POST_CUSTOM_FIELD', array('_GUID' => 'd85be094dff0d039a64120d6f8f381bb', 'NAME' => do_lang_tempcode('IP_ADDRESS'), 'VALUE' => $_postdetails['ip_address'])));
                         $poster_details = do_template('OCF_GUEST_DETAILS', array('_GUID' => 'e43534acaf598008602e8da8f9725f38', 'CUSTOM_FIELDS' => $custom_fields));
                     } else {
                         $poster_details = new ocp_tempcode();
                     }
                 }
             } else {
                 $poster_details = new ocp_tempcode();
             }
             if (!is_guest($_postdetails['poster'])) {
                 $poster = do_template('OCF_POSTER_MEMBER', array('_GUID' => 'dbbed1850b6c01a6c9601d85c6aee43f', 'ONLINE' => member_is_online($_postdetails['poster']), 'ID' => strval($_postdetails['poster']), 'POSTER_DETAILS' => $poster_details, 'PROFILE_URL' => $GLOBALS['FORUM_DRIVER']->member_profile_url($_postdetails['poster'], false, true), 'POSTER_USERNAME' => $_postdetails['poster_username'], 'HIGHLIGHT_NAME' => array_key_exists('poster_highlighted_name', $_postdetails) ? strval($_postdetails['poster_highlighted_name']) : NULL));
             } else {
                 $ip_link = array_key_exists('ip_address', $_postdetails) && has_actual_page_access(get_member(), 'admin_lookup') ? build_url(array('page' => 'admin_lookup', 'param' => $_postdetails['ip_address']), get_module_zone('admin_lookup')) : new ocp_tempcode();
                 $poster = do_template('OCF_POSTER_GUEST', array('_GUID' => '36a8e550222cdac5165ef8f722be3def', 'IP_LINK' => $ip_link, 'POSTER_DETAILS' => $poster_details, 'POSTER_USERNAME' => $_postdetails['poster_username']));
             }
             // Signature
             $signature = new ocp_tempcode();
             if (array_key_exists('signature', $_postdetails) && !$_postdetails['signature']->is_empty()) {
                 $signature = $_postdetails['signature'];
             }
             $post_title = $_postdetails['title'];
             $first_unread = $_postdetails['id'] == $first_unread_id || $first_unread_id < 0 && $array_id == count($topic_info['posts']) - 1 ? do_template('OCF_TOPIC_FIRST_UNREAD') : new ocp_tempcode();
             $unvalidated = $_postdetails['validated'] == 0 ? do_lang_tempcode('UNVALIDATED') : new ocp_tempcode();
             $post_url = $GLOBALS['FORUM_DRIVER']->post_url($_postdetails['id'], is_null($topic_info['forum_id']) ? '' : strval($topic_info['forum_id']), true);
             if (array_key_exists('intended_solely_for', $_postdetails) && $_postdetails['intended_solely_for'] == get_member()) {
                 decache('side_ocf_personal_topics', array(get_member()));
                 decache('_new_pp', array(get_member()));
             }
             $emphasis = ocf_get_post_emphasis($_postdetails);
             require_code('feedback');
             if (!array_key_exists('intended_solely_for', $_postdetails)) {
                 actualise_rating(true, 'post', strval($_postdetails['id']), get_self_url(), $_postdetails['title']);
                 $rating = display_rating(get_self_url(), $_postdetails['title'], 'post', strval($_postdetails['id']), 'RATING_INLINE_DYNAMIC', $_postdetails['poster']);
             } else {
                 $rating = new ocp_tempcode();
             }
             $rendered_post = do_template('OCF_TOPIC_POST', array('_GUID' => 'sacd09wekfofpw2f', 'ID' => $is_spacer_post ? '' : strval($_postdetails['id']), 'TOPIC_FIRST_POST_ID' => is_null($topic_info['first_post_id']) ? '' : strval($topic_info['first_post_id']), 'TOPIC_FIRST_POSTER' => is_null($topic_info['first_poster']) ? '' : strval($topic_info['first_poster']), 'POST_ID' => $is_spacer_post ? '' : (get_value('seq_post_ids') === '1' ? strval($start + $array_id + 1) : strval($_postdetails['id'])), 'URL' => $post_url, 'CLASS' => $_postdetails['is_emphasised'] ? 'ocf_post_emphasis' : (array_key_exists('intended_solely_for', $_postdetails) ? 'ocf_post_personal' : ''), 'EMPHASIS' => $emphasis, 'FIRST_UNREAD' => $first_unread, 'POSTER_TITLE' => $is_spacer_post ? '' : $_postdetails['poster_title'], 'POST_TITLE' => $post_title, 'POST_DATE_RAW' => strval($_postdetails['time']), 'POST_DATE' => $_postdetails['time_string'], 'POST' => $_postdetails['post'], 'TOPIC_ID' => is_null($id) ? '' : strval($id), 'LAST_EDITED_RAW' => $last_edited_raw, 'LAST_EDITED' => $last_edited, 'POSTER_ID' => strval($_postdetails['poster']), 'POSTER' => $is_spacer_post ? '' : $poster, 'POSTER_DETAILS' => $poster_details, 'POST_AVATAR' => $post_avatar, 'RANK_IMAGES' => $rank_images, 'BUTTONS' => $buttons, 'SIGNATURE' => $signature, 'UNVALIDATED' => $unvalidated, 'DESCRIPTION' => $description, 'RATING' => $rating));
             $posts->attach($rendered_post);
         }
         $serialized_options = mixed();
         $hash = mixed();
     } else {
         require_code('topics');
         $threaded_topic_ob = new OCP_Topic();
         // Load some settings into the renderer
         $threaded_topic_ob->first_post_id = $topic_info['first_post_id'];
         $threaded_topic_ob->topic_description = $topic_info['description'];
         $threaded_topic_ob->topic_description_link = $topic_info['description_link'];
         $threaded_topic_ob->topic_title = $topic_info['title'];
         $threaded_topic_ob->topic_info = $topic_info;
         // Other settings we need
         $max_thread_depth = intval(get_option('max_thread_depth'));
         $num_to_show_limit = get_param_integer('max_comments', intval(get_option('comments_to_show_in_thread')));
         // Load posts
         $threaded_topic_ob->load_from_topic($id, $num_to_show_limit, $start, false, NULL, true);
         $threaded_topic_ob->is_threaded = true;
         // Render posts
         list($posts, $serialized_options, $hash) = $threaded_topic_ob->render_posts($num_to_show_limit, $max_thread_depth, $may_reply, $topic_info['first_poster'], array(), $topic_info['forum_id'], NULL, false);
         $GLOBALS['META_DATA']['description'] = $threaded_topic_ob->topic_description;
         // Get other gathered details
         $replied = $threaded_topic_ob->replied;
         if (!is_null($threaded_topic_ob->topic_title)) {
             // Updated topic title
             $topic_info['title'] = $threaded_topic_ob->topic_title;
         }
         $topic_info['max_rows'] = $threaded_topic_ob->total_posts;
         $second_poster = $GLOBALS['FORUM_DRIVER']->get_guest_id();
         // No definitive post orders
     }
     // Buttons for topic as whole
     $button_array = array();
     if (!is_null($id)) {
         if (get_value('no_threaded_buttons') !== '1') {
             if ($threaded) {
                 $view_as_linear_url = get_self_url(false, false, array('threaded' => 0));
                 $button_array[] = array('immediate' => true, 'title' => do_lang_tempcode('VIEW_AS_LINEAR'), 'url' => $view_as_linear_url, 'img' => 'linear');
             } else {
                 $view_as_threaded_url = get_self_url(false, false, array('threaded' => 1));
                 $button_array[] = array('immediate' => true, 'title' => do_lang_tempcode('VIEW_AS_THREADED'), 'url' => $view_as_threaded_url, 'img' => 'threaded');
             }
         }
         if (!is_guest()) {
             $too_old = $topic_info['last_time'] < time() - 60 * 60 * 24 * intval(get_option('post_history_days'));
             if (get_value('disable_mark_topic_unread') !== '1' && !$too_old) {
                 $map = array('page' => 'topics', 'type' => 'mark_unread_topic', 'id' => $id);
                 $test = get_param_integer('kfs' . (is_null($topic_info['forum_id']) ? '' : strval($topic_info['forum_id'])), -1);
                 if ($test != -1 && $test != 0) {
                     $map['kfs' . (is_null($topic_info['forum_id']) ? '' : strval($topic_info['forum_id']))] = $test;
                 }
                 $test = get_param_integer('threaded', -1);
                 if ($test != -1) {
                     $map['threaded'] = $test;
                 }
                 $mark_unread_url = build_url($map, get_module_zone('topics'));
                 $button_array[] = array('immediate' => true, 'title' => do_lang_tempcode('MARK_UNREAD'), 'url' => $mark_unread_url, 'img' => 'mark_unread');
             }
         }
         if ($may_reply && is_null(get_bot_type())) {
             $reply_prevented = false;
             // "Staff-only" reply for support tickets
             if ($GLOBALS['FORUM_DRIVER']->is_staff(get_member()) && addon_installed('tickets')) {
                 require_code('tickets');
                 if (is_ticket_forum($topic_info['forum_id'])) {
                     if (is_guest($second_poster)) {
                         $reply_prevented = true;
                     }
                     require_lang('tickets');
                     $map = array('page' => 'topics', 'type' => 'new_post', 'id' => $id, 'intended_solely_for' => $GLOBALS['FORUM_DRIVER']->get_guest_id());
                     $test = get_param_integer('kfs' . (is_null($topic_info['forum_id']) ? '' : strval($topic_info['forum_id'])), -1);
                     if ($test != -1 && $test != 0) {
                         $map['kfs' . (is_null($topic_info['forum_id']) ? '' : strval($topic_info['forum_id']))] = $test;
                     }
                     $test = get_param_integer('threaded', -1);
                     if ($test != -1) {
                         $map['threaded'] = $test;
                     }
                     $new_post_url = build_url($map, get_module_zone('topics'));
                     $button_array[] = array('immediate' => false, 'rel' => 'add', 'title' => do_lang_tempcode('TICKET_STAFF_ONLY_REPLY'), 'url' => $new_post_url, 'img' => 'staff_only_reply');
                 }
             }
             if (!$reply_prevented) {
                 if ($topic_info['is_threaded'] == 0) {
                     $map = array('page' => 'topics', 'type' => 'new_post', 'id' => $id);
                     $test = get_param_integer('kfs' . (is_null($topic_info['forum_id']) ? '' : strval($topic_info['forum_id'])), -1);
                     if ($test != -1 && $test != 0) {
                         $map['kfs' . (is_null($topic_info['forum_id']) ? '' : strval($topic_info['forum_id']))] = $test;
                     }
                     $test = get_param_integer('threaded', -1);
                     if ($test != -1) {
                         $map['threaded'] = $test;
                     }
                     $new_post_url = build_url($map, get_module_zone('topics'));
                     $button_array[] = array('immediate' => false, 'rel' => 'add', 'title' => do_lang_tempcode($topic_info['is_open'] ? 'REPLY' : 'CLOSED'), 'url' => $new_post_url, 'img' => $topic_info['is_open'] ? 'reply' : 'closed');
                 }
             } else {
                 unset($topic_info['may_use_quick_reply']);
             }
         } elseif ((is_null($topic_info['forum_id']) || has_specific_permission(get_member(), 'submit_lowrange_content', 'topics', array('forums', $topic_info['forum_id']))) && $topic_info['last_poster'] == get_member() && !is_guest() && ocf_may_edit_post_by(get_member(), $topic_info['forum_id'])) {
             $map = array('page' => 'topics', 'type' => 'edit_post', 'id' => $topic_info['last_post_id']);
             $test = get_param_integer('kfs' . strval($topic_info['forum_id']), -1);
             if ($test != -1 && $test != 0) {
                 $map['kfs' . strval($topic_info['forum_id'])] = $test;
             }
             $test = get_param_integer('threaded', -1);
             if ($test != -1) {
                 $map['threaded'] = $test;
             }
             $new_post_url = build_url($map, get_module_zone('topics'));
             $button_array[] = array('immediate' => false, 'rel' => 'edit', 'title' => do_lang_tempcode('LAST_POST'), 'url' => $new_post_url, 'img' => 'amend');
         }
         if (!is_null($topic_info['forum_id'])) {
             if (get_value('disable_add_topic_btn_in_topic') !== '1') {
                 if (ocf_may_post_topic($topic_info['forum_id'], get_member())) {
                     $new_topic_url = build_url(array('page' => 'topics', 'type' => 'new_topic', 'id' => $topic_info['forum_id']), get_module_zone('topics'));
                     $button_array[] = array('immediate' => false, 'rel' => 'add', 'title' => do_lang_tempcode('ADD_TOPIC'), 'url' => $new_topic_url, 'img' => 'new_topic');
                 }
             }
         } else {
             $invite_url = build_url(array('page' => 'topics', 'type' => 'invite_member', 'id' => $id), get_module_zone('topics'));
             $button_array[] = array('immediate' => false, 'title' => do_lang_tempcode('INVITE_MEMBER_TO_PT'), 'url' => $invite_url, 'img' => 'invite_member');
         }
     }
     $buttons = ocf_screen_button_wrap($button_array);
     // Poll
     if (array_key_exists('poll', $topic_info)) {
         $_poll = $topic_info['poll'];
         $voted_already = $_poll['voted_already'];
         $poll_results = array_key_exists(0, $_poll['answers']) && array_key_exists('num_votes', $_poll['answers'][0]);
         $answers = new ocp_tempcode();
         $real_button = false;
         if ($_poll['is_open']) {
             if ($poll_results) {
                 $button = new ocp_tempcode();
             } elseif ($_poll['requires_reply'] && !$replied) {
                 $button = do_lang_tempcode('POLL_REQUIRES_REPLY');
             } else {
                 if (!has_specific_permission(get_member(), 'vote_in_polls') || is_guest()) {
                     $button = do_lang_tempcode('VOTE_DENIED');
                 } else {
                     if (!is_null($voted_already)) {
                         $button = do_lang_tempcode('NOVOTE');
                     } else {
                         require_lang('polls');
                         $map = array('page' => 'topicview', 'id' => $id, 'view_poll_results' => 1, 'start' => $start == 0 ? NULL : $start, 'max' => $max == $default_max ? NULL : $max);
                         $test = get_param_integer('kfs' . (is_null($topic_info['forum_id']) ? '' : strval($topic_info['forum_id'])), -1);
                         if ($test != -1 && $test != 0) {
                             $map['kfs' . (is_null($topic_info['forum_id']) ? '' : strval($topic_info['forum_id']))] = $test;
                         }
                         $test = get_param_integer('threaded', -1);
                         if ($test != -1) {
                             $map['threaded'] = $test;
                         }
                         $results_url = build_url($map, get_module_zone('topics'));
                         $button = do_template('OCF_TOPIC_POLL_BUTTON', array('_GUID' => '94b932fd01028df8f67bb5864d9235f9', 'RESULTS_URL' => $results_url));
                         $real_button = true;
                     }
                 }
             }
         } else {
             $button = do_lang_tempcode('TOPIC_POLL_CLOSED');
         }
         foreach ($_poll['answers'] as $answer) {
             if ($poll_results && ($_poll['requires_reply'] == 0 || $replied)) {
                 $num_votes = $answer['num_votes'];
                 $total_votes = $_poll['total_votes'];
                 if ($total_votes != 0) {
                     $width = intval(round(70.0 * floatval($num_votes) / floatval($total_votes)));
                 } else {
                     $width = 0;
                 }
                 $answer_tpl = do_template('OCF_TOPIC_POLL_ANSWER_RESULTS', array('_GUID' => 'b32f4c526e147abf20ca0d668e40d515', 'ID' => strval($_poll['id']), 'NUM_VOTES' => integer_format($num_votes), 'WIDTH' => strval($width), 'ANSWER' => $answer['answer'], 'I' => strval($answer['id'])));
             } else {
                 $answer_tpl = do_template('OCF_TOPIC_POLL_ANSWER' . ($_poll['maximum_selections'] == 1 ? '_RADIO' : ''), array('REAL_BUTTON' => $real_button, 'ID' => strval($_poll['id']), 'ANSWER' => $answer['answer'], 'I' => strval($answer['id'])));
             }
             $answers->attach($answer_tpl);
         }
         $map = array('page' => 'topics', 'type' => 'vote_poll', 'id' => $id, 'start' => $start == 0 ? NULL : $start, 'max' => $max == $default_max ? NULL : $max);
         $test = get_param_integer('kfs' . (is_null($topic_info['forum_id']) ? '' : strval($topic_info['forum_id'])), -1);
         if ($test != -1 && $test != 0) {
             $map['kfs' . (is_null($topic_info['forum_id']) ? '' : strval($topic_info['forum_id']))] = $test;
         }
         $test = get_param_integer('threaded', -1);
         if ($test != -1) {
             $map['threaded'] = $test;
         }
         $vote_url = build_url($map, get_module_zone('topics'));
         if ($_poll['is_private']) {
             $private = paragraph(do_lang_tempcode('TOPIC_POLL_IS_PRIVATE'), 'dfgsdgdsgs');
         } else {
             $private = new ocp_tempcode();
         }
         if ($_poll['maximum_selections'] > 1) {
             $num_choices = paragraph($_poll['minimum_selections'] == $_poll['maximum_selections'] ? do_lang_tempcode('POLL_NOT_ENOUGH_ERROR_2', integer_format($_poll['minimum_selections'])) : do_lang_tempcode('POLL_NOT_ENOUGH_ERROR', integer_format($_poll['minimum_selections']), integer_format($_poll['maximum_selections'])), 'dsfsdfsdfs');
         } else {
             $num_choices = new ocp_tempcode();
         }
         $poll = do_template('OCF_TOPIC_POLL' . ($poll_results ? '_VIEW_RESULTS' : ''), array('ID' => strval($_poll['id']), 'NUM_CHOICES' => $num_choices, 'PRIVATE' => $private, 'QUESTION' => $_poll['question'], 'ANSWERS' => $answers, 'REAL_BUTTON' => $real_button, 'BUTTON' => $button, 'VOTE_URL' => $vote_url, 'MINIMUM_SELECTIONS' => integer_format($_poll['minimum_selections']), 'MAXIMUM_SELECTIONS' => integer_format($_poll['maximum_selections'])));
     } else {
         $poll = new ocp_tempcode();
     }
     // Forum nav tree
     if (!is_null($topic_info['forum_id'])) {
         $tree = ocf_forum_breadcrumbs($topic_info['forum_id'], NULL, NULL, false);
     } else {
         $tree = new ocp_tempcode();
         $tree->attach(hyperlink(build_url(array('page' => 'members'), get_module_zone('members')), do_lang_tempcode('MEMBERS'), false, false, do_lang_tempcode('GO_BACKWARDS_TO', do_lang_tempcode('MEMBERS')), NULL, NULL, 'up'));
         $tree->attach(do_template('BREADCRUMB_ESCAPED'));
         if (has_specific_permission(get_member(), 'view_other_pt')) {
             $of_member = $topic_info['pt_from'] == get_member() ? $topic_info['pt_from'] : $topic_info['pt_to'];
         } else {
             $of_member = get_member();
         }
         $of_username = $GLOBALS['FORUM_DRIVER']->get_username($of_member);
         if (is_null($of_username)) {
             $of_username = do_lang('UNKNOWN');
         }
         $personal_topic_url = build_url(array('page' => 'members', 'type' => 'view', 'id' => $of_member), get_module_zone('members'), NULL, true, false, false, 'tab__pts');
         $tree->attach(hyperlink($personal_topic_url, do_lang_tempcode('MEMBER_PROFILE', escape_html($of_username)), false, false, do_lang_tempcode('GO_BACKWARDS_TO', do_lang_tempcode('MEMBERS')), NULL, NULL, 'up'));
     }
     // Quick reply
     if (array_key_exists('may_use_quick_reply', $topic_info) && $may_reply && !is_null($id)) {
         $map = array('page' => 'topics', 'type' => '_add_reply', 'topic_id' => $id);
         $test = get_param_integer('kfs' . (is_null($topic_info['forum_id']) ? '' : strval($topic_info['forum_id'])), -1);
         if ($test != -1 && $test != 0) {
             $map['kfs' . (is_null($topic_info['forum_id']) ? '' : strval($topic_info['forum_id']))] = $test;
         }
         $test = get_param_integer('threaded', -1);
         if ($test != -1) {
             $map['threaded'] = $test;
         }
         $_post_url = build_url($map, get_module_zone('topics'));
         $post_url = $_post_url->evaluate();
         $map = array('page' => 'topics', 'type' => 'new_post', 'id' => $id);
         if ($test != -1 && $test != 0) {
             $map['kfs' . (is_null($topic_info['forum_id']) ? '' : strval($topic_info['forum_id']))] = $test;
         }
         $more_url = build_url($map, get_module_zone('topics'));
         $_postdetails = array_key_exists('first_post', $topic_info) ? get_translated_tempcode($topic_info['first_post'], $GLOBALS['FORUM_DB']) : new ocp_tempcode();
         $first_post = $_postdetails;
         $first_post_url = $GLOBALS['FORUM_DRIVER']->post_url($topic_info['first_post_id'], is_null($topic_info['forum_id']) ? '' : strval($topic_info['forum_id']), true);
         $display = 'block';
         $expand_type = 'contract';
         if ($topic_info['max_rows'] > $start + $max) {
             $display = 'none';
             $expand_type = 'expand';
         }
         $em = $GLOBALS['FORUM_DRIVER']->get_emoticon_chooser();
         require_javascript('javascript_editing');
         require_javascript('javascript_validation');
         if (addon_installed('captcha')) {
             require_code('captcha');
             $use_captcha = use_captcha();
             if ($use_captcha) {
                 generate_captcha();
             }
         } else {
             $use_captcha = false;
         }
         $post_warning = '';
         if ($topic_info['is_really_threaded'] == 1) {
             $post_warning = do_lang('THREADED_REPLY_NOTICE', $post_warning);
         }
         $quick_reply = do_template('COMMENTS_POSTING_FORM', array('_GUID' => '4c532620f3eb68d9cc820b18265792d7', 'JOIN_BITS' => '', 'USE_CAPTCHA' => $use_captcha, 'GET_EMAIL' => false, 'EMAIL_OPTIONAL' => true, 'GET_TITLE' => false, 'POST_WARNING' => $post_warning, 'COMMENT_TEXT' => '', 'EM' => $em, 'EXPAND_TYPE' => $expand_type, 'DISPLAY' => $display, 'FIRST_POST_URL' => $first_post_url, 'FIRST_POST' => $first_post, 'MORE_URL' => $more_url, 'COMMENT_URL' => $post_url, 'TITLE' => do_lang_tempcode('QUICK_REPLY'), 'SUBMIT_NAME' => do_lang_tempcode('MAKE_POST')));
     } else {
         $quick_reply = new ocp_tempcode();
     }
     $action_url = build_url(array('page' => 'topics', 'id' => $id), get_module_zone('topics'));
     if (!is_null($id)) {
         // Moderation options
         $moderator_actions = '';
         if (is_null($topic_info['forum_id'])) {
             $moderator_actions .= '<option value="categorise_pts">' . do_lang('_CATEGORISE_PTS') . '</option>';
         }
         if (array_key_exists('may_multi_moderate', $topic_info) && array_key_exists('forum_id', $topic_info)) {
             $multi_moderations = ocf_list_multi_moderations($topic_info['forum_id']);
             if (count($multi_moderations) != 0) {
                 $moderator_actions .= '<optgroup label="' . do_lang('MULTI_MODERATIONS') . '">';
                 foreach ($multi_moderations as $mm_id => $mm_name) {
                     $moderator_actions .= '<option value="mm_' . strval($mm_id) . '">' . $mm_name . '</option>';
                 }
                 $moderator_actions .= '</optgroup>';
             }
         }
         if (array_key_exists('may_move_topic', $topic_info)) {
             $moderator_actions .= '<option value="move_topic">' . do_lang('MOVE_TOPIC') . '</option>';
         }
         if (array_key_exists('may_edit_topic', $topic_info)) {
             $moderator_actions .= '<option value="edit_topic">' . do_lang('EDIT_TOPIC') . '</option>';
         }
         if (array_key_exists('may_delete_topic', $topic_info)) {
             $moderator_actions .= '<option value="delete_topic">' . do_lang('DELETE_TOPIC') . '</option>';
         }
         if (array_key_exists('may_pin_topic', $topic_info)) {
             $moderator_actions .= '<option value="pin_topic">' . do_lang('PIN_TOPIC') . '</option>';
         }
         if (array_key_exists('may_unpin_topic', $topic_info)) {
             $moderator_actions .= '<option value="unpin_topic">' . do_lang('UNPIN_TOPIC') . '</option>';
         }
         if (array_key_exists('may_sink_topic', $topic_info)) {
             $moderator_actions .= '<option value="sink_topic">' . do_lang('SINK_TOPIC') . '</option>';
         }
         if (array_key_exists('may_unsink_topic', $topic_info)) {
             $moderator_actions .= '<option value="unsink_topic">' . do_lang('UNSINK_TOPIC') . '</option>';
         }
         if (array_key_exists('may_cascade_topic', $topic_info)) {
             $moderator_actions .= '<option value="cascade_topic">' . do_lang('CASCADE_TOPIC') . '</option>';
         }
         if (array_key_exists('may_uncascade_topic', $topic_info)) {
             $moderator_actions .= '<option value="uncascade_topic">' . do_lang('UNCASCADE_TOPIC') . '</option>';
         }
         if (array_key_exists('may_open_topic', $topic_info)) {
             $moderator_actions .= '<option value="open_topic">' . do_lang('OPEN_TOPIC') . '</option>';
         }
         if (array_key_exists('may_close_topic', $topic_info)) {
             $moderator_actions .= '<option value="close_topic">' . do_lang('CLOSE_TOPIC') . '</option>';
         }
         if (array_key_exists('may_edit_poll', $topic_info)) {
             $moderator_actions .= '<option value="edit_poll">' . do_lang('EDIT_TOPIC_POLL') . '</option>';
         }
         if (array_key_exists('may_delete_poll', $topic_info)) {
             $moderator_actions .= '<option value="delete_poll">' . do_lang('DELETE_TOPIC_POLL') . '</option>';
         }
         if (array_key_exists('may_attach_poll', $topic_info)) {
             $moderator_actions .= '<option value="add_poll">' . do_lang('ADD_TOPIC_POLL') . '</option>';
         }
         if (has_specific_permission(get_member(), 'view_content_history') && $GLOBALS['FORUM_DB']->query_value('f_post_history', 'COUNT(*)', array('h_topic_id' => $id)) != 0) {
             $moderator_actions .= '<option value="topic_history">' . do_lang('POST_HISTORY') . '</option>';
         }
         if (array_key_exists('may_make_personal', $topic_info) && !is_null($topic_info['forum_id'])) {
             $moderator_actions .= '<option value="make_personal">' . do_lang('MAKE_PERSONAL') . '</option>';
         }
         if ($GLOBALS['XSS_DETECT']) {
             ocp_mark_as_escaped($moderator_actions);
         }
         // Marked post actions
         $map = array('page' => 'topics', 'id' => $id);
         $test = get_param_integer('kfs' . (is_null($topic_info['forum_id']) ? '' : strval($topic_info['forum_id'])), -1);
         if ($test != -1 && $test != 0) {
             $map['kfs' . (is_null($topic_info['forum_id']) ? '' : strval($topic_info['forum_id']))] = $test;
         }
         $test = get_param_integer('threaded', -1);
         if ($test != -1) {
             $map['threaded'] = $test;
         }
         $action_url = build_url($map, get_module_zone('topics'), NULL, false, true);
         $marked_post_actions = '';
         if (array_key_exists('may_move_posts', $topic_info)) {
             $marked_post_actions .= '<option value="move_posts_a">' . do_lang('MERGE_POSTS') . '</option>';
             $marked_post_actions .= '<option value="move_posts_b">' . do_lang('SPLIT_POSTS') . '</option>';
         }
         if (array_key_exists('may_delete_posts', $topic_info)) {
             $marked_post_actions .= '<option value="delete_posts">' . do_lang('DELETE_POSTS') . '</option>';
         }
         if (array_key_exists('may_validate_posts', $topic_info)) {
             $marked_post_actions .= '<option value="validate_posts">' . do_lang('VALIDATE_POSTS') . '</option>';
         }
         if (get_value('disable_multi_quote') !== '1') {
             if ($may_reply) {
                 $marked_post_actions .= '<option value="new_post">' . do_lang('QUOTE_POSTS') . '</option>';
             }
         }
         if ($GLOBALS['XSS_DETECT']) {
             ocp_mark_as_escaped($marked_post_actions);
         }
     } else {
         $moderator_actions = '';
         $marked_post_actions = '';
     }
     $max_rows = $topic_info['max_rows'];
     if ($max_rows > $max && !$threaded) {
         require_code('templates_results_browser');
         $results_browser = results_browser(do_lang_tempcode('FORUM_POSTS'), $id, $start, 'start', $max, 'max', $max_rows, NULL, 'misc', true, false, 7, array(10, 20, 30));
     } else {
         $results_browser = new ocp_tempcode();
     }
     // Members viewing this topic
     $members = is_null($id) ? array() : get_members_viewing('topicview', '', strval($id), true);
     $num_guests = 0;
     $num_members = 0;
     if (is_null($members)) {
         $members_viewing = new ocp_tempcode();
     } else {
         $members_viewing = new ocp_tempcode();
         foreach ($members as $member_id => $at_details) {
             $username = $at_details['mt_cache_username'];
             if (is_guest($member_id)) {
                 $num_guests++;
             } else {
                 $num_members++;
                 $profile_url = $GLOBALS['FORUM_DRIVER']->member_profile_url($member_id, false, true);
                 $map = array('PROFILE_URL' => $profile_url, 'USERNAME' => $username);
                 if (has_specific_permission(get_member(), 'show_user_browsing') || in_array($at_details['the_page'], array('topics', 'topicview')) && $at_details['the_id'] == strval($id)) {
                     $map['AT'] = escape_html($at_details['the_title']);
                 }
                 $map['COLOUR'] = get_group_colour(ocf_get_member_primary_group($member_id));
                 $members_viewing->attach(do_template('OCF_USER_MEMBER', $map));
             }
         }
         if ($members_viewing->is_empty()) {
             $members_viewing = do_lang_tempcode('NONE_EM');
         }
     }
     if (!is_null($id)) {
         breadcrumb_add_segment($tree, do_lang_tempcode(is_null($topic_info['forum_id']) ? 'VIEW_PERSONAL_TOPIC' : 'VIEW_TOPIC'));
     }
     if (is_null($id)) {
         $root_forum_name = $GLOBALS['FORUM_DB']->query_value('f_forums', 'f_name', array('id' => db_get_first_id()));
         $tree = hyperlink(build_url(array('page' => 'forumview', 'id' => db_get_first_id()), get_module_zone('forumview')), escape_html($root_forum_name), false, false, do_lang('GO_BACKWARDS_TO'));
         breadcrumb_add_segment($tree, do_lang('INLINE_PERSONAL_POSTS'));
     }
     if ($topic_info['validated'] == 0) {
         $warning_details = do_template('WARNING_TABLE', array('WARNING' => do_lang_tempcode(get_param_integer('redirected', 0) == 1 ? 'UNVALIDATED_TEXT_NON_DIRECT' : 'UNVALIDATED_TEXT')));
     } else {
         $warning_details = new ocp_tempcode();
     }
     $topic_tpl = do_template('OCF_TOPIC_WRAP', array('_GUID' => 'bb201d5d59559e5e2bd60e7cf2e6f7e9', 'SERIALIZED_OPTIONS' => $serialized_options, 'HASH' => $hash, 'ID' => strval($id), 'TITLE' => $topic_info['title'], 'MAY_DOUBLE_POST' => has_specific_permission(get_member(), 'double_post'), 'LAST_POSTER' => array_key_exists('last_poster', $topic_info) ? is_null($topic_info['last_poster']) ? '' : strval($topic_info['last_poster']) : '', 'WARNING_DETAILS' => $warning_details, 'MAX' => strval($max), 'MAY_CHANGE_MAX' => array_key_exists('may_change_max', $topic_info), 'ACTION_URL' => $action_url, 'NUM_GUESTS' => integer_format($num_guests), 'NUM_MEMBERS' => integer_format($num_members), 'MEMBERS_VIEWING' => $members_viewing, 'RESULTS_BROWSER' => $results_browser, 'MODERATOR_ACTIONS' => $moderator_actions, 'MARKED_POST_ACTIONS' => $marked_post_actions, 'QUICK_REPLY' => $quick_reply, 'TREE' => $tree, 'POLL' => $poll, 'SCREEN_BUTTONS' => $buttons, 'POSTS' => $posts, 'THREADED' => $threaded));
     if (is_null($id)) {
         $title = get_page_title('INLINE_PERSONAL_POSTS');
     } else {
         if (is_null($topic_info['forum_id'])) {
             $title = get_page_title(do_lang_tempcode('NAMED_PERSONAL_TOPIC', escape_html($topic_info['title'])), false, NULL, do_lang_tempcode('READING_PERSONAL_TOPIC'));
         } else {
             if (addon_installed('awards')) {
                 require_code('awards');
                 $awards = find_awards_for('topic', strval($id));
             } else {
                 $awards = array();
             }
             $title = get_page_title(do_lang_tempcode('NAMED_TOPIC', escape_html($topic_info['title'])), false, NULL, NULL, $awards);
         }
     }
     return ocf_wrapper($title, $topic_tpl, true, false, $topic_info['forum_id']);
 }
Beispiel #25
0
/**
 * Get a templated view of the subcategories directly under the specified category.
 *
 * @param  AUTO_LINK		The category the subcategories are being found for
 * @param  ?AUTO_LINK	The pretend root of our download system (NULL: true root). This system is provided for large sites to be able to do virtually seperated download systems
 * @param  ?ID_TEXT		The zone the download module we're using is in (NULL: find it)
 * @param  ?string		The order to show results in (NULL: default)
 * @return tempcode		The templated view
 */
function get_download_sub_categories($category_id, $root = NULL, $zone = NULL, $order = NULL)
{
    if (is_null($order)) {
        $order = 't.text_original ASC';
    }
    if (is_null($root)) {
        $root = db_get_first_id();
    }
    if (is_null($zone)) {
        $zone = get_module_zone('downloads');
    }
    $rows = $GLOBALS['SITE_DB']->query_select('download_categories c LEFT JOIN ' . get_table_prefix() . 'translate t ON ' . db_string_equal_to('language', user_lang()) . ' AND c.category=t.id', array('rep_image', 'c.id', 'category', 'text_original', 'description'), array('parent_id' => $category_id), $order == 't.text_original ASC' ? '' : 'ORDER BY ' . $order, 400);
    if ($order == 't.text_original ASC') {
        global $M_SORT_KEY;
        $M_SORT_KEY = 'text_original';
        usort($rows, 'multi_sort');
    }
    if (count($rows) == 400) {
        $rows = array();
    }
    // Too much, performance issue
    $out = new ocp_tempcode();
    foreach ($rows as $myrow) {
        if (!has_category_access(get_member(), 'downloads', strval($myrow['id']))) {
            continue;
        }
        if ($GLOBALS['RECORD_LANG_STRINGS_CONTENT'] || is_null($myrow['text_original'])) {
            $myrow['text_original'] = get_translated_text($myrow['category']);
        }
        $child_id = $myrow['id'];
        $child_title = $myrow['text_original'];
        $info = count_download_category_children($child_id);
        $num_children = $info['num_children'];
        $num_downloads = $info['num_downloads_children'];
        $display_string = do_lang_tempcode('CATEGORY_SUBORDINATE', integer_format($num_downloads), integer_format($num_children));
        $url = build_url(array('page' => 'downloads', 'type' => 'misc', 'id' => $child_id == db_get_first_id() ? NULL : $child_id, 'root' => $root == db_get_first_id() ? NULL : $root, 'order' => get_param('order', NULL)), $zone);
        if ($myrow['rep_image'] != '') {
            require_code('images');
            $rep_image = do_image_thumb($myrow['rep_image'], '');
        } else {
            $rep_image = new ocp_tempcode();
        }
        $ajax_edit_url = '_SEARCH:cms_downloads:type=__ec:id=' . strval($child_id);
        $description = get_translated_tempcode($myrow['description']);
        $out->attach(do_template('CATEGORY_ENTRY', array('_GUID' => '8bfb36d75a85e2a7fbf5222f8fc61c7d', 'DESCRIPTION' => $description, 'ID' => strval($child_id), 'NAME_FIELD' => 'category', 'AJAX_EDIT_URL' => $ajax_edit_url, 'URL' => $url, 'REP_IMAGE' => $rep_image, 'CHILDREN' => $display_string, 'NAME' => $child_title, 'NAME_PLAIN' => $child_title)));
    }
    if ($out->is_empty()) {
        return $out;
    }
    return do_template('CATEGORY_LIST', array('_GUID' => '2de3e2cdd0180a584b4f4ec72652716f', 'CONTENT' => $out));
}
Beispiel #26
0
/**
 * Convert a CEDI chain to a nice formatted XHTML tree.
 *
 * @param  string			The chain to convert (which should include the current page ID)
 * @param  ?string		The title of the current CEDI page (if not given, it is looked up) (NULL: work it out)
 * @param  boolean		Whether to show the final tree element with a link to it (all others will always have links if $links is true)
 * @param  boolean		Whether to show links to pages in the tree
 * @param  boolean		Whether to make the link as a virtual-root link (only applies if $final_link is true)
 * @return tempcode		Tempcode of the breadcrumb XHTML
 */
function cedi_breadcrumbs($chain, $current_title = NULL, $final_link = false, $links = true, $this_link_virtual_root = false)
{
    $instree = new ocp_tempcode();
    $token = strtok($chain, '/');
    $rebuild_chain = '';
    while ($token !== false) {
        $next_token = strtok('/');
        if ($rebuild_chain != '') {
            $rebuild_chain .= '/';
        }
        $rebuild_chain .= $token;
        $id = $this_link_virtual_root && $next_token === false ? $token : $rebuild_chain;
        $url = build_url(array('page' => 'cedi', 'type' => 'misc', 'id' => $id == strval(db_get_first_id()) ? NULL : $id) + ($this_link_virtual_root && $next_token === false ? array('keep_cedi_root' => $id) : array()), get_module_zone('cedi'));
        if ($next_token !== false) {
            $title = $GLOBALS['SITE_DB']->query_value_null_ok('seedy_pages', 'title', array('id' => intval($token)));
            if (is_null($title)) {
                continue;
            }
            $token_title = get_translated_text($title);
            $content = $links ? hyperlink($url, escape_html($token_title), false, false, do_lang_tempcode('GO_BACKWARDS_TO', $token_title), NULL, NULL, 'up') : make_string_tempcode(escape_html($token_title));
            if ($instree->is_empty()) {
                $instree->attach($content);
            } else {
                $instree->attach(do_template('BREADCRUMB_ESCAPED'));
                $instree->attach($content);
            }
        } else {
            if (!$instree->is_empty()) {
                $instree->attach(do_template('BREADCRUMB_ESCAPED'));
            }
            if (is_null($current_title)) {
                $_current_title = $GLOBALS['SITE_DB']->query_value_null_ok('seedy_pages', 'title', array('id' => intval($token)));
                $current_title = is_null($_current_title) ? do_lang('MISSING_RESOURCE') : get_translated_text($_current_title);
            }
            if ($final_link) {
                $instree->attach(hyperlink($url, escape_html($current_title), false, false, $this_link_virtual_root ? do_lang_tempcode('VIRTUAL_ROOT') : do_lang_tempcode('GO_BACKWARDS_TO', $current_title), NULL, NULL, 'up'));
            } else {
                $instree->attach($current_title);
            }
        }
        $token = $next_token;
    }
    return $instree;
}
Beispiel #27
0
 /**
  * The UI to browse IOTDs.
  *
  * @return tempcode		The UI
  */
 function iotd_browse()
 {
     $title = get_page_title('IOTD_ARCHIVE');
     global $NON_CANONICAL_PARAMS;
     $NON_CANONICAL_PARAMS[] = 'max';
     $start = get_param_integer('start', 0);
     $max = get_param_integer('max', 20);
     $rows = $GLOBALS['SITE_DB']->query_select('iotd', array('*'), array('used' => 1), 'ORDER BY date_and_time DESC', $max, $start);
     $max_rows = $GLOBALS['SITE_DB']->query_value('iotd', 'COUNT(*)', array('used' => 1));
     $content = new ocp_tempcode();
     foreach ($rows as $myrow) {
         $date = get_timezoned_date($myrow['date_and_time']);
         $url = build_url(array('page' => '_SELF', 'type' => 'view', 'wide' => 1, 'id' => $myrow['id']), '_SELF');
         $thumb_url = $myrow['thumb_url'];
         $caption = get_translated_tempcode($myrow['i_title']);
         require_code('images');
         $thumb_url = ensure_thumbnail($myrow['url'], $thumb_url, 'iotds', 'iotd', $myrow['id']);
         $thumb = do_image_thumb($thumb_url, '');
         $content->attach(do_template('IOTD_VIEW_SCREEN_IOTD', array('SUBMITTER' => strval($myrow['submitter']), 'ID' => strval($myrow['id']), 'VIEWS' => integer_format($myrow['iotd_views']), 'THUMB' => $thumb, 'DATE' => $date, 'DATE_RAW' => strval($myrow['date_and_time']), 'URL' => $url, 'CAPTION' => $caption)));
     }
     if ($content->is_empty()) {
         inform_exit(do_lang_tempcode('NO_ENTRIES'));
     }
     $page_num = intval(floor(floatval($start) / floatval($max))) + 1;
     $num_pages = intval(ceil(floatval($max_rows) / floatval($max)));
     $previous_url = $start == 0 ? new ocp_tempcode() : build_url(array('page' => '_SELF', 'start' => $start - $max == 0 ? NULL : $start - $max), '_SELF');
     $next_url = count($rows) != $max ? new ocp_tempcode() : build_url(array('page' => '_SELF', 'start' => $start + $max), '_SELF');
     $browse = do_template('NEXT_BROWSER_BROWSE_NEXT', array('_GUID' => 'b6933ab44e16fef7e1bec62014254383', 'NEXT_LINK' => $next_url, 'PREVIOUS_LINK' => $previous_url, 'PAGE_NUM' => integer_format($page_num), 'NUM_PAGES' => integer_format($num_pages)));
     return do_template('NEXT_BROWSER_SCREEN', array('_GUID' => 'd8a493c2b007d98074f104ea433c8091', 'TITLE' => $title, 'CONTENT' => $content, 'BROWSE' => $browse));
 }
Beispiel #28
0
 /**
  * Run through tests.
  *
  * @return tempcode	The result of execution.
  */
 function go()
 {
     require_code('comcode_renderer');
     $title = get_page_title('RUN_THROUGH_TESTS');
     $show_for_all = get_param_integer('show_for_all', 0);
     $show_successful = get_param_integer('show_successful', 0);
     $tester = get_member();
     if ($GLOBALS['FORUM_DRIVER']->is_super_admin(get_member())) {
         $tester = get_param_integer('tester', get_member());
     }
     if ($show_for_all == 0) {
         $where = '(t.t_assigned_to=' . strval((int) $tester) . ' OR (t.t_assigned_to IS NULL AND s.s_assigned_to=' . strval((int) $tester) . '))';
     } else {
         $where = 's.id IS NOT NULL';
     }
     if ($show_successful == 0) {
         $where .= ' AND t.t_status<>1';
     }
     $where .= ' AND s.s_inheritable=0';
     $sections = new ocp_tempcode();
     $query = 'SELECT *,t.id AS id FROM ' . $GLOBALS['SITE_DB']->get_table_prefix() . 'tests t LEFT JOIN ' . $GLOBALS['SITE_DB']->get_table_prefix() . 'test_sections s ON t.t_section=s.id WHERE ' . $where . ' ORDER BY s.s_section,t.id';
     $_tests = $GLOBALS['SITE_DB']->query($query);
     $current = NULL;
     $current_2 = NULL;
     $current_3 = NULL;
     $tests = new ocp_tempcode();
     foreach ($_tests as $test) {
         if (!is_null($current) && $current != $test['t_section']) {
             $edit_test_section_url = new ocp_tempcode();
             if (has_specific_permission(get_member(), 'edit_own_tests') && ($test['s_assigned_to'] == get_member() || $GLOBALS['FORUM_DRIVER']->is_staff(get_member()))) {
                 $edit_test_section_url = build_url(array('page' => '_SELF', 'type' => '_ed', 'id' => $current), '_SELF');
             }
             $sections->attach(do_template('TESTER_GO_SECTION', array('_GUID' => '5ac788f72b881e403f75f76815706032', 'ID' => strval($current), 'EDIT_TEST_SECTION_URL' => $edit_test_section_url, 'NOTES' => $current_3, 'SECTION' => $current_2, 'TESTS' => $tests)));
             $tests = new ocp_tempcode();
         }
         $current = $test['t_section'];
         $current_2 = $test['s_section'];
         $current_3 = $test['s_notes'];
         $a_test = make_string_tempcode(escape_html($test['t_test']));
         if (!is_null($test['t_inherit_section'])) {
             $_tests_2 = $GLOBALS['SITE_DB']->query_select('tests', array('*'), array('t_section' => $test['t_inherit_section']));
             if (count($_tests_2) != 0) {
                 $section_notes = $GLOBALS['SITE_DB']->query_value('test_sections', 's_notes', array('id' => $test['t_inherit_section']));
                 if ($section_notes != '') {
                     $a_test->attach(paragraph(escape_html($section_notes)));
                 }
                 $a_test->attach(do_template('TESTER_TEST_SET', array('TESTS' => map_keys_to_upper($_tests_2))));
             }
         }
         $bug_report_url = build_url(array('page' => '_SELF', 'type' => 'report', 'id' => $test['id']), '_SELF');
         $tests->attach(do_template('TESTER_GO_TEST', array('_GUID' => '1e719a51201d27eff7aed58b7f730251', 'BUG_REPORT_URL' => $bug_report_url, 'TEST' => $a_test, 'ID' => strval($test['id']), 'VALUE' => strval($test['t_status']))));
     }
     if ($tests->is_empty() && $sections->is_empty()) {
         $sections = paragraph(do_lang_tempcode('NO_ENTRIES'), '4tregerg344');
     } else {
         $edit_test_section_url = new ocp_tempcode();
         if (has_specific_permission(get_member(), 'edit_own_tests') && ($test['s_assigned_to'] == get_member() || $GLOBALS['FORUM_DRIVER']->is_staff(get_member()))) {
             $edit_test_section_url = build_url(array('page' => '_SELF', 'type' => '_ed', 'id' => $test['t_section']), '_SELF');
         }
         $sections->attach(do_template('TESTER_GO_SECTION', array('_GUID' => '9bd53d8b0f0aab1a683660fac2b6ad85', 'ID' => strval($test['t_section']), 'EDIT_TEST_SECTION_URL' => $edit_test_section_url, 'NOTES' => $test['s_notes'], 'SECTION' => $test['s_section'], 'TESTS' => $tests)));
     }
     $add_test_section_url = new ocp_tempcode();
     if (has_specific_permission(get_member(), 'add_tests')) {
         $add_test_section_url = build_url(array('page' => '_SELF', 'type' => 'ad'), '_SELF');
     }
     $post_url = build_url(array('page' => '_SELF', 'type' => '_go'), '_SELF');
     return do_template('TESTER_GO_SCREEN', array('_GUID' => '22b3b626cb510e64a795d95acc0ad8a2', 'ADD_TEST_SECTION_URL' => $add_test_section_url, 'SHOW_SUCCESSFUL' => strval($show_successful), 'SHOW_FOR_ALL' => strval($show_for_all), 'TITLE' => $title, 'SECTIONS' => $sections, 'URL' => $post_url));
 }
Beispiel #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));
 }
/**
 * Get the tempcode for a results table.
 *
 * @param  mixed			Some text/word describing what is being browsed (Tempcode or string)
 * @param  integer		The result number our table starts at (x of n)
 * @param  ID_TEXT		The parameter name used to store our position in the results (usually, 'start')
 * @param  integer		The total number of results to show per-page
 * @param  ID_TEXT		The parameter name used to store the total number of results to show per-page (usually, 'max')
 * @param  integer		The maximum number of rows in the entire dataset
 * @param  tempcode		The titles of the fields we are showing in our table, presented in preprepared tempcode
 * @param  tempcode		The values of the fields we are showing in our table
 * @param  ?array			A map of sortable code (usually, db field names), to strings giving the human name for the sort order (NULL: no sortables)
 * @param  ?ID_TEXT		The current sortable (NULL: none)
 * @param  ?ID_TEXT		The order we are sorting in (NULL: none)
 * @set    ASC DESC
 * @param  ?ID_TEXT		The parameter name used to store our sortable (usually 'sort') (NULL: none)
 * @param  ?tempcode		Message to show (NULL: auto)
 * @param  ?array			Widths to specify to the table (NULL: none sent)
 * @param  ?string		The template set to use (NULL: default)
 * @param  integer		The maximum number of quick-jump page links to show
 * @param  string			GUID to pass to template
 * @param  boolean		Whether to skip showing a sort form (useful if there is another form wrapped around this)
 * @param  ?ID_TEXT		URL hash component (NULL: none)
 * @return tempcode		The results table
 */
function results_table($text_id, $start, $start_name, $max, $max_name, $max_rows, $fields_title, $fields, $sortables = NULL, $sortable = NULL, $sort_order = NULL, $sort_name = 'sort', $message = NULL, $widths = NULL, $tplset = NULL, $max_page_links = 8, $guid = '1c8645bc2a3ff5bec2e003142185561f', $skip_sortables_form = false, $hash = NULL)
{
    require_code('templates_results_browser');
    if (!is_null($sort_name)) {
        global $NON_CANONICAL_PARAMS;
        $NON_CANONICAL_PARAMS[] = $sort_name;
    }
    if (is_null($widths)) {
        $widths = array();
    }
    if (is_null($message)) {
        $message = new ocp_tempcode();
        if (!is_null($sortables)) {
            foreach ($sortables as $_sortable => $text) {
                if (is_object($text)) {
                    $text = $text->evaluate();
                }
                if ($text == do_lang('DATE_TIME')) {
                    $message = paragraph(do_lang_tempcode('CLICK_DATE_FOR_MORE'));
                }
            }
        }
    }
    // Sorting
    if (!is_null($sortables)) {
        $selectors = new ocp_tempcode();
        foreach ($sortables as $_sortable => $text) {
            $text_ascending = new ocp_tempcode();
            $text_ascending->attach($text);
            $text_ascending->attach(do_lang_tempcode('_ASCENDING'));
            $text_descending = new ocp_tempcode();
            $text_descending->attach($text);
            $text_descending->attach(do_lang_tempcode('_DESCENDING'));
            $selector_value = $_sortable . ' ASC';
            $selected = $sortable . ' ' . $sort_order == $selector_value;
            $selectors->attach(do_template('RESULTS_BROWSER_SORTER', array('_GUID' => $guid, 'SELECTED' => $selected, 'NAME' => $text_ascending, 'VALUE' => $selector_value)));
            $selector_value = $_sortable . ' DESC';
            $selected = $sortable . ' ' . $sort_order == $selector_value;
            $selectors->attach(do_template('RESULTS_BROWSER_SORTER', array('_GUID' => $guid, 'SELECTED' => $selected, 'NAME' => $text_descending, 'VALUE' => $selector_value)));
        }
        if (strpos(ocp_srv('REQUEST_URI'), '/iframe.php') !== false) {
            $sort_url = find_script('iframe') . '?zone=' . get_zone_name();
            $url_array = $_GET;
            foreach ($url_array as $key => $param) {
                if (is_array($param)) {
                    continue;
                }
                if (substr($key, 0, 5) == 'keep_' && skippable_keep($key, $param)) {
                    continue;
                }
                if ($key == 'wide_high') {
                    continue;
                }
                if ($param === '_SELF') {
                    $param = get_page_name();
                }
                if (get_magic_quotes_gpc()) {
                    $param = stripslashes($param);
                }
                $sort_url .= '&' . $key . '=' . urlencode($param);
            }
        } else {
            $sort_url = get_self_url();
        }
        $hidden = build_keep_form_fields('_SELF', true);
        if ($selectors->is_empty()) {
            $sort = new ocp_tempcode();
        } else {
            $sort = do_template('RESULTS_BROWSER_SORT', array('_GUID' => $guid, 'HASH' => $hash, 'HIDDEN' => $hidden, 'SORT' => $sort_name, 'RAND' => strval($GLOBALS['INCREMENTAL_ID_GENERATOR']), 'URL' => $sort_url, 'SELECTORS' => $selectors));
        }
        $GLOBALS['INCREMENTAL_ID_GENERATOR']++;
    } else {
        $sort = new ocp_tempcode();
    }
    // Results browser
    $browser = results_browser(is_object($text_id) ? $text_id : make_string_tempcode($text_id), NULL, $start, $start_name, $max, $max_name, $max_rows, NULL, get_param('type', 'misc'), true, true, $max_page_links, NULL, is_null($hash) ? '' : $hash);
    return do_template(is_null($tplset) ? 'RESULTS_TABLE' : 'RESULTS_' . $tplset . '_TABLE', array('_GUID' => $guid, 'TEXT_ID' => $text_id, 'FIELDS_TITLE' => $fields_title, 'FIELDS' => $fields, 'MESSAGE' => $message, 'SORT' => $skip_sortables_form ? new ocp_tempcode() : $sort, 'BROWSER' => $browser, 'WIDTHS' => $widths), NULL, false, 'RESULTS_TABLE');
}