示例#1
0
 /**
  * Standard modular render function for profile tab hooks.
  *
  * @param  MEMBER			The ID of the member who is being viewed
  * @param  MEMBER			The ID of the member who is doing the viewing
  * @param  boolean		Whether to leave the tab contents NULL, if tis hook supports it, so that AJAX can load it later
  * @return array			A triple: The tab title, the tab contents, the suggested tab order
  */
 function render_tab($member_id_of, $member_id_viewing, $leave_to_ajax_if_possible = false)
 {
     $title = do_lang_tempcode('MODULE_TRANS_NAME_warnings');
     $order = 80;
     if ($leave_to_ajax_if_possible) {
         return array($title, NULL, $order);
     }
     require_lang('ocf');
     require_css('ocf');
     $warnings = new ocp_tempcode();
     $rows = $GLOBALS['FORUM_DB']->query_select('f_warnings', array('*'), array('w_member_id' => $member_id_of, 'w_is_warning' => 1));
     foreach ($rows as $row) {
         $warning_by = $GLOBALS['FORUM_DRIVER']->member_profile_hyperlink($row['w_by']);
         $date = get_timezoned_date($row['w_time']);
         if ($row['w_explanation'] == '') {
             $row['w_explanation'] = '?';
         } else {
             $row['w_explanation'] = str_replace(chr(10), ' ', $row['w_explanation']);
         }
         $row['w_explanation_orig'] = $row['w_explanation'];
         if (strlen($row['w_explanation']) > 30) {
             $row['w_explanation'] = substr($row['w_explanation'], 0, 27) . '...';
         }
         $explanation = hyperlink(build_url(array('page' => 'warnings', 'type' => '_ed', 'id' => $row['id'], 'redirect' => get_self_url(true)), get_module_zone('warnings')), $row['w_explanation'], false, true, $row['w_explanation_orig']);
         $warnings->attach(paragraph(do_lang_tempcode('MEMBER_WARNING', $explanation, $warning_by, array(make_string_tempcode(escape_html($date)))), 'treyerhy34y'));
     }
     $content = do_template('OCF_MEMBER_PROFILE_WARNINGS', array('MEMBER_ID' => strval($member_id_of), 'WARNINGS' => $warnings));
     return array($title, $content, $order);
 }
 /**
  * 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)));
 }
示例#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;
}
/**
 * Get a netlink block / direct to a netlink site.
 *
 * @param  URLPATH		The URL we grab our netlink from. If this is not blank, instead of getting a netlink block, we direct to a netlink site.
 * @return tempcode		The netlink block
 */
function do_netlink($redir_url = '')
{
    header('Content-type: text/plain; charset=' . get_charset());
    // If we are redirecting
    if ($redir_url != '') {
        if (strpos($redir_url, chr(10)) !== false || strpos($redir_url, chr(13)) !== false) {
            log_hack_attack_and_exit('HEADER_SPLIT_HACK');
        }
        header('Location: ' . $redir_url);
        exit;
    }
    // Ok we're displaying a netlink, which will be dumped right into the body of the reading site
    //  - this isn't actually a weburl that is actually displayed, its loaded by ocPortal and embedded-inline
    // For all the names in our network
    require_code('textfiles');
    $lines = explode(chr(10), read_text_file('netlink', NULL, true));
    if (count($lines) == 0) {
        return new ocp_tempcode();
    }
    $content = new ocp_tempcode();
    foreach ($lines as $line) {
        $parts = explode('=', $line, 2);
        if (count($parts) != 2) {
            continue;
        }
        $name = rtrim($parts[0]);
        $url = trim($parts[1]);
        // Are we looking at the source site in the network?
        $selected = strtolower($url) == strtolower(get_param('source', ''));
        $content->attach(form_input_list_entry(base64_encode($url), $selected, $name));
    }
    return do_template('NETLINK', array('_GUID' => '180321222dc5dc99a231597c803f0726', 'CONTENT' => $content));
}
示例#5
0
 /**
  * Standard modular run function.
  *
  * @return tempcode	The result of execution.
  */
 function run()
 {
     require_lang('leader_board');
     require_code('points');
     require_css('points');
     $title = get_page_title('POINT_LEADERBOARD');
     $start_date = intval(get_option('leaderboard_start_date'));
     $weeks = $GLOBALS['SITE_DB']->query('SELECT DISTINCT date_and_time FROM ' . $GLOBALS['SITE_DB']->get_table_prefix() . 'leader_board WHERE date_and_time>=' . strval($start_date) . ' ORDER BY date_and_time DESC');
     if (count($weeks) == 0) {
         warn_exit(do_lang_tempcode('NO_ENTRIES'));
     }
     $first_week = $weeks[count($weeks) - 1]['date_and_time'];
     $weeks = collapse_1d_complexity('date_and_time', $weeks);
     $out = new ocp_tempcode();
     foreach ($weeks as $week) {
         $rows = collapse_2d_complexity('lb_member', 'lb_points', $GLOBALS['SITE_DB']->query_select('leader_board', array('lb_member', 'lb_points'), array('date_and_time' => $week)));
         $week_tpl = new ocp_tempcode();
         foreach ($rows as $member => $points) {
             $points_url = build_url(array('page' => 'points', 'type' => 'member', 'id' => $member), get_module_zone('points'));
             $profile_url = $GLOBALS['FORUM_DRIVER']->member_profile_url($member, false, true);
             $name = $GLOBALS['FORUM_DRIVER']->get_username($member);
             if (is_null($name)) {
                 $name = do_lang('UNKNOWN');
             }
             $week_tpl->attach(do_template('POINTS_LEADERBOARD_ROW', array('_GUID' => '6d323b4b5abea0e82a14cb4745c4af4f', 'POINTS_URL' => $points_url, 'PROFILE_URL' => $profile_url, 'POINTS' => integer_format($points), 'NAME' => $name, 'ID' => strval($member))));
         }
         $nice_week = intval(($week - $first_week) / (7 * 24 * 60 * 60) + 1);
         $out->attach(do_template('POINTS_LEADERBOARD_WEEK', array('_GUID' => '3a0f71bf20f9098e5711e85cf25f6549', 'WEEK' => integer_format($nice_week), 'ROWS' => $week_tpl)));
     }
     return do_template('POINTS_LEADERBOARD_SCREEN', array('_GUID' => 'bab5f7b661435b83800532d3eebd0d54', 'TITLE' => $title, 'WEEKS' => $out));
 }
示例#6
0
 /**
  * Standard interface stage of pointstore item purchase.
  *
  * @return tempcode		The UI
  */
 function action()
 {
     $class = str_replace('hook_pointstore_', '', strtolower(get_class($this)));
     if (get_option('is_on_' . $class . '_buy') == '0') {
         return new ocp_tempcode();
     }
     $title = get_page_title('TOPIC_PINNING');
     $cost = intval(get_option($class));
     $next_url = build_url(array('page' => '_SELF', 'type' => 'action_done', 'id' => $class), '_SELF');
     $points_left = available_points(get_member());
     // Check points
     if ($points_left < $cost && !has_specific_permission(get_member(), 'give_points_self')) {
         return warn_screen($title, do_lang_tempcode('_CANT_AFFORD', integer_format($cost), integer_format($points_left)));
     }
     require_code('form_templates');
     $fields = new ocp_tempcode();
     if (get_forum_type() == 'ocf') {
         $fields->attach(form_input_tree_list(do_lang_tempcode('FORUM_TOPIC'), '', 'select_topic_id', NULL, 'choose_forum_topic', array(), false));
         $fields->attach(form_input_integer(do_lang_tempcode('ALT_FIELD', do_lang_tempcode('FORUM_TOPIC')), do_lang_tempcode('DESCRIPTION_FORUM_TOPIC_ID'), 'manual_topic_id', NULL, false));
     } else {
         $fields->attach(form_input_integer(do_lang_tempcode('FORUM_TOPIC'), do_lang_tempcode('ENTER_TOPIC_ID_MANUALLY'), 'manual_topic_id', NULL, false));
     }
     $text = do_lang_tempcode('PIN_TOPIC_A', integer_format($cost), integer_format($points_left - $cost));
     return do_template('FORM_SCREEN', array('_GUID' => '8cabf882d5cbe4d354cc6efbcf92ebf9', 'TITLE' => $title, 'TEXT' => $text, 'URL' => $next_url, 'FIELDS' => $fields, 'HIDDEN' => '', 'SUBMIT_NAME' => do_lang_tempcode('PURCHASE'), 'JAVASCRIPT' => 'standardAlternateFields(\'select_topic_id\',\'manual_topic_id\');'));
 }
示例#7
0
/**
 * URL'ise specially encoded text-acceptance language strings.
 *
 * @param  string			The language string
 * @param  mixed			The URL (either tempcode or string)
 * @param  string			The title of the hyperlink
 * @param  boolean		Whether to use a new window
 * @return tempcode		The encoded version
 */
function _urlise_lang($string, $url, $title, $new_window)
{
    $a = strpos($string, '<{');
    $b = strpos($string, '}>');
    if ($a === false || $b === false || $b < $a) {
        return make_string_tempcode($string);
    }
    $section = substr($string, $a + 2, $b - $a - 2);
    $prior = substr($string, 0, $a);
    $after = substr($string, $b + 2);
    if ($GLOBALS['XSS_DETECT']) {
        ocp_mark_as_escaped($section);
        ocp_mark_as_escaped($prior);
        ocp_mark_as_escaped($after);
    }
    if (is_string($url)) {
        if ($url == '') {
            return protect_from_escaping($section);
        }
    } else {
        if ($url->is_empty()) {
            return protect_from_escaping($section);
        }
    }
    $out = new ocp_tempcode();
    $out->attach(protect_from_escaping($prior));
    $out->attach(hyperlink($url, protect_from_escaping($section), $new_window, false, $title));
    $out->attach(protect_from_escaping($after));
    return $out;
}
 /**
  * Standard modular run function.
  *
  * @param  array		A map of parameters.
  * @return tempcode	The result of execution.
  */
 function run($map)
 {
     require_lang('news');
     $categories = $GLOBALS['SITE_DB']->query_select('news_categories', array('*'), array('nc_owner' => NULL));
     $content = new ocp_tempcode();
     $categories2 = array();
     foreach ($categories as $category) {
         if (has_category_access(get_member(), 'news', strval($category['id']))) {
             $join = ' LEFT JOIN ' . get_table_prefix() . 'news_category_entries d ON d.news_entry=p.id';
             $count = $GLOBALS['SITE_DB']->query_value_null_ok_full('SELECT COUNT(*) FROM ' . get_table_prefix() . 'news p' . $join . ' WHERE validated=1 AND (news_entry_category=' . strval($category['id']) . ' OR news_category=' . strval($category['id']) . ') ORDER BY date_and_time DESC');
             if ($count > 0) {
                 $category['_nc_title'] = get_translated_text($category['nc_title']);
                 $categories2[] = $category;
             }
         }
     }
     if (count($categories2) == 0) {
         global $M_SORT_KEY;
         $M_SORT_KEY = '_nc_title';
         usort($categories2, 'multi_sort');
         foreach ($categories as $category) {
             if (has_category_access(get_member(), 'news', strval($category['id']))) {
                 $categories2[] = $category;
             }
         }
     }
     foreach ($categories2 as $category) {
         $url = build_url(array('page' => 'news', 'type' => 'misc', 'id' => $category['id']), get_module_zone('news'));
         $name = $category['_nc_title'];
         $content->attach(do_template('BLOCK_SIDE_NEWS_CATEGORIES_CATEGORY', array('_GUID' => 'fee49cac370ec00fc59d2e9c66b6255a', 'URL' => $url, 'NAME' => $name, 'COUNT' => integer_format($count))));
     }
     return do_template('BLOCK_SIDE_NEWS_CATEGORIES', array('_GUID' => 'b47a0047247096373e5aa626348c4ebb', 'CONTENT' => $content, 'PRE' => '', 'POST' => ''));
 }
 /**
  * Standard modular run function.
  *
  * @param  array		A map of parameters.
  * @return tempcode	The result of execution.
  */
 function run($map)
 {
     unset($map);
     require_lang('custom_comcode');
     $tags = array();
     $wmap = array('tag_enabled' => 1);
     if (!has_specific_permission(get_member(), 'comcode_dangerous')) {
         $wmap['tag_dangerous_tag'] = 0;
     }
     $tags = array_merge($tags, $GLOBALS['SITE_DB']->query_select('custom_comcode', array('tag_title', 'tag_description', 'tag_example', 'tag_parameters', 'tag_replace', 'tag_tag', 'tag_dangerous_tag', 'tag_block_tag', 'tag_textual_tag'), $wmap));
     if (isset($GLOBALS['FORUM_DB']) && $GLOBALS['FORUM_DB']->connection_write != $GLOBALS['SITE_DB']->connection_write && get_forum_type() == 'ocf') {
         $tags = array_merge($tags, $GLOBALS['FORUM_DB']->query_select('custom_comcode', array('tag_title', 'tag_description', 'tag_example', 'tag_parameters', 'tag_replace', 'tag_tag', 'tag_dangerous_tag', 'tag_block_tag', 'tag_textual_tag'), $wmap));
     }
     // From Comcode hooks
     $hooks = find_all_hooks('systems', 'comcode');
     foreach (array_keys($hooks) as $hook) {
         require_code('hooks/systems/comcode/' . filter_naughty_harsh($hook));
         $object = object_factory('Hook_comcode_' . filter_naughty_harsh($hook), true);
         $tags[] = $object->get_tag();
     }
     if (!array_key_exists(0, $tags)) {
         return paragraph(do_lang_tempcode('NONE_EM'), '', 'nothing_here');
     }
     $content = new ocp_tempcode();
     foreach ($tags as $tag) {
         $content->attach(do_template('CUSTOM_COMCODE_TAG_ROW', array('_GUID' => '28c257f5d0c596aa828fd9556b0df4a9', 'TITLE' => is_string($tag['tag_title']) ? $tag['tag_title'] : get_translated_text($tag['tag_title']), 'DESCRIPTION' => is_string($tag['tag_description']) ? $tag['tag_description'] : get_translated_text($tag['tag_description']), 'EXAMPLE' => $tag['tag_example'])));
     }
     return do_template('BLOCK_MAIN_CUSTOM_COMCODE_TAGS', array('_GUID' => 'b8d3436e6e5fe679ae9b0a368e607610', 'TAGS' => $content));
 }
示例#10
0
 /**
  * Standard modular run function for RSS hooks.
  *
  * @param  string			A list of categories we accept from
  * @param  TIME			Cutoff time, before which we do not show results from
  * @param  string			Prefix that represents the template set we use
  * @set    RSS_ ATOM_
  * @param  string			The standard format of date to use for the syndication type represented in the prefix
  * @param  integer		The maximum number of entries to return, ordering by date
  * @return ?array			A pair: The main syndication section, and a title (NULL: error)
  */
 function run($_filters, $cutoff, $prefix, $date_string, $max)
 {
     if (!addon_installed('news')) {
         return NULL;
     }
     if (!has_actual_page_access(get_member(), 'news')) {
         return NULL;
     }
     $filters_1 = ocfilter_to_sqlfragment($_filters, 'p.news_category', 'news_categories', NULL, 'p.news_category', '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)
     $filters_2 = ocfilter_to_sqlfragment($_filters, 'd.news_entry_category', 'news_categories', NULL, 'd.news_category', '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)
     $filters = '(' . $filters_1 . ' OR ' . $filters_2 . ')';
     $rows = $GLOBALS['SITE_DB']->query('SELECT * FROM ' . $GLOBALS['SITE_DB']->get_table_prefix() . 'news p LEFT JOIN ' . get_table_prefix() . 'news_category_entries d ON d.news_entry=p.id WHERE date_and_time>' . strval($cutoff) . (!has_specific_permission(get_member(), 'see_unvalidated') ? ' AND validated=1 ' : '') . ' AND ' . $filters . (can_arbitrary_groupby() ? ' GROUP BY p.id' : '') . ' ORDER BY date_and_time DESC', $max);
     $rows = remove_duplicate_rows($rows, 'id');
     $_categories = $GLOBALS['SITE_DB']->query_select('news_categories', array('id', 'nc_title'), array('nc_owner' => NULL));
     foreach ($_categories as $i => $_category) {
         $_categories[$i]['text_original'] = get_translated_text($_category['nc_title']);
     }
     $categories = collapse_2d_complexity('id', 'text_original', $_categories);
     $content = new ocp_tempcode();
     foreach ($rows as $row) {
         if (has_category_access(get_member(), 'news', strval($row['news_category']))) {
             $id = strval($row['id']);
             $author = $row['author'];
             $news_date = date($date_string, $row['date_and_time']);
             $edit_date = is_null($row['edit_date']) ? '' : date($date_string, $row['edit_date']);
             $_title = get_translated_tempcode($row['title']);
             $news_title = xmlentities($_title->evaluate());
             $_summary = get_translated_tempcode($row['news']);
             if ($_summary->is_empty()) {
                 $_summary = get_translated_tempcode($row['news_article']);
             }
             $summary = xmlentities($_summary->evaluate());
             if (!is_null($row['news_article'])) {
                 $_news = get_translated_tempcode($row['news_article']);
                 if ($_news->is_empty()) {
                     $news = '';
                 } else {
                     $news = xmlentities($_news->evaluate());
                 }
             } else {
                 $news = '';
             }
             if (!array_key_exists($row['news_category'], $categories)) {
                 $categories[$row['news_category']] = get_translated_text($GLOBALS['SITE_DB']->query_value('news_categories', 'nc_title', array('id' => $row['news_category'])));
             }
             $category = $categories[$row['news_category']];
             $category_raw = strval($row['news_category']);
             $view_url = build_url(array('page' => 'news', 'type' => 'view', 'id' => $row['id']), get_module_zone('news'), NULL, false, false, true);
             if ($prefix == 'RSS_' && get_option('is_on_comments') == '1' && $row['allow_comments'] >= 1) {
                 $if_comments = do_template('RSS_ENTRY_COMMENTS', array('_GUID' => 'b4f25f5cf68304f8d402bb06851489d6', 'COMMENT_URL' => $view_url, 'ID' => strval($row['id'])));
             } else {
                 $if_comments = new ocp_tempcode();
             }
             $content->attach(do_template($prefix . 'ENTRY', array('VIEW_URL' => $view_url, 'SUMMARY' => $summary, 'EDIT_DATE' => $edit_date, 'IF_COMMENTS' => $if_comments, 'TITLE' => $news_title, 'CATEGORY_RAW' => $category_raw, 'CATEGORY' => $category, 'AUTHOR' => $author, 'ID' => $id, 'NEWS' => $news, 'DATE' => $news_date)));
         }
     }
     return array($content, do_lang('NEWS'));
 }
示例#11
0
 /**
  * Standard interface stage of pointstore item purchase.
  *
  * @return tempcode		The UI
  */
 function action()
 {
     require_code('database_action');
     $class = str_replace('hook_pointstore_', '', strtolower(get_class($this)));
     //if (get_option('is_on_'.$class.'_buy')=='0') return new ocp_tempcode();
     $tablename_exists = $GLOBALS['SITE_DB']->table_exists('bank');
     if (!$tablename_exists) {
         $GLOBALS['SITE_DB']->create_table('bank', array('id' => '*AUTO', 'user_id' => 'INTEGER', 'amount' => 'INTEGER', 'divident' => 'INTEGER', 'add_time' => '?TIME'));
     }
     $_bank_dividend = get_option('bank_divident', true);
     if (is_null($_bank_dividend)) {
         //add option and default value
         add_config_option('BANK_DIVIDEND', 'bank_divident', 'integer', 'return \'40\';', 'POINTSTORE', 'BANKING');
         // TODO: Fix spelling
         // IDEA: Make 30 days a config option too, or even have multiple products?
         // IDEA: Send email saying bank returned money?
         // IDEA: Have the bank do marketing to people? http://ocportal.com/forum/topicview/misc/addons/ocbank_4.htm?redirected=1#post_87711
         $bank_dividend = 4;
     } else {
         $bank_dividend = intval($_bank_dividend);
     }
     $title = get_page_title('BANKING');
     $points_left = available_points(get_member());
     $next_url = build_url(array('page' => '_SELF', 'type' => 'action_done', 'id' => $class), '_SELF');
     // Check points
     if ($points_left < 0 && !has_specific_permission(get_member(), 'give_points_self')) {
         return warn_screen($title, do_lang_tempcode('_CANT_AFFORD_BANK'));
     }
     require_code('form_templates');
     $fields = new ocp_tempcode();
     $fields->attach(form_input_integer(do_lang_tempcode('AMOUNT'), do_lang_tempcode('DESCRIPTION_BANK_AMOUNT', integer_format($points_left)), 'amount', $points_left, true));
     $text = do_lang_tempcode('BANK_A', integer_format($points_left));
     return do_template('FORM_SCREEN', array('_GUID' => 'ae703225db618f2bc938290fbae4d6d8', 'TITLE' => $title, 'TEXT' => $text, 'URL' => $next_url, 'FIELDS' => $fields, 'HIDDEN' => '', 'SUBMIT_NAME' => do_lang_tempcode('PROCEED')));
 }
示例#12
0
 /**
  * Standard modular run function for newsletter hooks.
  *
  * @param  TIME				The time that the entries found must be newer than
  * @param  LANGUAGE_NAME	The language the entries found must be in
  * @param  string				Category filter to apply
  * @param  BINARY				Whether to use full article instead of summary
  * @return array				Tuple of result details
  */
 function run($cutoff_time, $lang, $filter, $in_full = 1)
 {
     if (!addon_installed('news')) {
         return array();
     }
     require_lang('news');
     $new = new ocp_tempcode();
     require_code('ocfiltering');
     $or_list = ocfilter_to_sqlfragment($filter, 'news_category');
     $or_list_2 = ocfilter_to_sqlfragment($filter, 'news_entry_category');
     $rows = $GLOBALS['SITE_DB']->query('SELECT title,news,news_article,id,date_and_time,submitter FROM ' . get_table_prefix() . 'news LEFT JOIN ' . get_table_prefix() . 'news_category_entries ON news_entry=id WHERE validated=1 AND date_and_time>' . strval((int) $cutoff_time) . ' AND ((' . $or_list . ') OR (' . $or_list_2 . ')) ORDER BY date_and_time DESC', 300);
     if (count($rows) == 300) {
         return array();
     }
     $rows = remove_duplicate_rows($rows, 'id');
     foreach ($rows as $row) {
         $_url = build_url(array('page' => 'news', 'type' => 'view', 'id' => $row['id']), get_module_zone('news'), NULL, false, false, true);
         $url = $_url->evaluate();
         $name = get_translated_text($row['title'], NULL, $lang);
         $description = get_translated_text($row[$in_full == 1 ? 'news_article' : 'news'], NULL, $lang);
         if ($description == '') {
             $description = get_translated_text($row[$in_full == 1 ? 'news' : 'news_article'], NULL, $lang);
         }
         $member_id = is_guest($row['submitter']) ? NULL : strval($row['submitter']);
         $new->attach(do_template('NEWSLETTER_NEW_RESOURCE_FCOMCODE', array('_GUID' => '4eaf5ec00db1f0b89cef5120c2486521', 'MEMBER_ID' => $member_id, 'URL' => $url, 'NAME' => $name, 'DESCRIPTION' => $description)));
     }
     return array($new, do_lang('NEWS', '', '', '', $lang));
 }
示例#13
0
 /**
  * Standard modular run function.
  *
  * @return tempcode	Results
  */
 function run()
 {
     $out = new ocp_tempcode();
     $tables = $GLOBALS['SITE_DB']->query_select('db_meta', array('DISTINCT m_table'));
     if (count($GLOBALS['SITE_DB']->connection_write) > 4) {
         $GLOBALS['SITE_DB']->connection_write = call_user_func_array(array($GLOBALS['SITE_DB']->static_ob, 'db_get_connection'), $GLOBALS['SITE_DB']->connection_write);
         _general_db_init();
     }
     list($db, $db_name) = $GLOBALS['SITE_DB']->connection_write;
     mysql_select_db($db_name, $db);
     foreach ($tables as $table) {
         if ($table['m_table'] == 'sessions') {
             continue;
         }
         // HEAP, so can't be repaired
         $table = get_table_prefix() . $table['m_table'];
         // Check/Repair
         $result = mysql_query('CHECK TABLE ' . $table . ' FAST', $db);
         echo mysql_error($db);
         mysql_data_seek($result, mysql_num_rows($result) - 1);
         $status_row = mysql_fetch_assoc($result);
         if ($status_row['Msg_type'] != 'status') {
             $out->attach(paragraph(do_lang_tempcode('TABLE_ERROR', escape_html($table), escape_html($status_row['Msg_type']), array(escape_html($status_row['Msg_text']))), 'dfsdgdsgfgd'));
             $result2 = mysql_query('REPAIR TABLE ' . $table, $db);
             mysql_data_seek($result2, mysql_num_rows($result2) - 1);
             $status_row_2 = mysql_fetch_assoc($result2);
             $out->attach(paragraph(do_lang_tempcode('TABLE_FIXED', escape_html($table), escape_html($status_row_2['Msg_type']), array(escape_html($status_row_2['Msg_text']))), 'dfsdfgdst4'));
         }
         // Optimise
         mysql_unbuffered_query('OPTIMIZE TABLE ' . $table, $db);
     }
     return $out;
 }
示例#14
0
 /**
  * Standard modular run function for RSS hooks.
  *
  * @param  string			A list of categories we accept from
  * @param  TIME			Cutoff time, before which we do not show results from
  * @param  string			Prefix that represents the template set we use
  * @set    RSS_ ATOM_
  * @param  string			The standard format of date to use for the syndication type represented in the prefix
  * @param  integer		The maximum number of entries to return, ordering by date
  * @return ?array			A pair: The main syndication section, and a title (NULL: error)
  */
 function run($_filters, $cutoff, $prefix, $date_string, $max)
 {
     if (!has_actual_page_access(get_member(), 'members')) {
         return NULL;
     }
     $rows = $GLOBALS['FORUM_DB']->query('SELECT * FROM ' . $GLOBALS['SITE_DB']->get_table_prefix() . 'f_members p WHERE m_join_time>' . strval($cutoff) . (!has_specific_permission(get_member(), 'see_unvalidated') ? ' AND m_validated=1 AND m_validated_email_confirm_code=\'\' ' : '') . ' ORDER BY m_join_time DESC', $max);
     $categories = $GLOBALS['FORUM_DRIVER']->get_usergroup_list(true);
     $content = new ocp_tempcode();
     foreach ($rows as $row) {
         $id = strval($row['id']);
         $author = '';
         $news_date = date($date_string, $row['m_join_time']);
         $edit_date = '';
         $news_title = xmlentities($row['m_username']);
         $summary = '';
         $news = '';
         $category = array_key_exists($row['m_primary_group'], $categories) ? $categories[$row['m_primary_group']] : '';
         $category_raw = strval($row['m_primary_group']);
         $view_url = build_url(array('page' => 'members', 'type' => 'view', 'id' => $row['id']), get_module_zone('members'), NULL, false, false, true);
         $if_comments = new ocp_tempcode();
         $content->attach(do_template($prefix . 'ENTRY', array('VIEW_URL' => $view_url, 'SUMMARY' => $summary, 'EDIT_DATE' => $edit_date, 'IF_COMMENTS' => $if_comments, 'TITLE' => $news_title, 'CATEGORY_RAW' => $category_raw, 'CATEGORY' => $category, 'AUTHOR' => $author, 'ID' => $id, 'NEWS' => $news, 'DATE' => $news_date)));
     }
     require_lang('ocf');
     return array($content, do_lang('MEMBERS'));
 }
示例#15
0
/**
 * Get hidden fields for a form representing 'keep_x'. If we are having a GET form instead of a POST form, we need to do this. This function also encodes the page name, as we'll always want that.
 *
 * @param  ID_TEXT		The page for the form to go to (blank: don't attach)
 * @param  boolean		Whether to keep all elements of the current URL represented in this form (rather than just the keep_ fields, and page)
 * @param  ?array			A list of parameters to exclude (NULL: don't exclude any)
 * @return tempcode		The builtup hidden form fields
 */
function _build_keep_form_fields($page = '', $keep_all = false, $exclude = NULL)
{
    if (is_null($exclude)) {
        $exclude = array();
    }
    if ($page == '_SELF') {
        $page = get_page_name();
    }
    $out = new ocp_tempcode();
    if (count($_GET) > 0) {
        foreach ($_GET as $key => $val) {
            if (!is_string($val)) {
                continue;
            }
            if (get_magic_quotes_gpc()) {
                $val = stripslashes($val);
            }
            if ((substr($key, 0, 5) == 'keep_' || $keep_all) && !in_array($key, $exclude) && $key != 'page' && !skippable_keep($key, $val)) {
                $out->attach(form_input_hidden($key, $val));
            }
        }
    }
    if ($page != '') {
        $out->attach(form_input_hidden('page', $page));
    }
    return $out;
}
示例#16
0
 /**
  * Standard modular run function.
  *
  * @param  array		A map of parameters.
  * @return tempcode	The result of execution.
  */
 function run($map)
 {
     unset($map);
     $forum = get_forum_type();
     $out = new ocp_tempcode();
     if ($forum != 'none') {
         // Standard welcome back vs into greeting
         $member = get_member();
         if (is_guest($member)) {
             $redirect = get_self_url(true, true);
             $login_url = build_url(array('page' => 'login', 'type' => 'misc', 'redirect' => $redirect), get_module_zone('login'));
             $join_url = $GLOBALS['FORUM_DRIVER']->join_url();
             $join_bits = do_template('JOIN_OR_LOGIN', array('LOGIN_URL' => $login_url, 'JOIN_URL' => $join_url));
             $p = do_lang_tempcode('WELCOME', $join_bits);
             $out->attach(paragraph($p, 'hhrt4dsgdsgd'));
         } else {
             $out->attach(paragraph(do_lang_tempcode('WELCOME_BACK', escape_html($GLOBALS['FORUM_DRIVER']->get_username($member))), 'gfgdf9gjd'));
         }
     }
     $message = get_option('welcome_message');
     if (has_actual_page_access(get_member(), 'admin_config')) {
         if ($message != '') {
             $message .= ' [[page="_SEARCH:admin_config:category:SITE#group_GENERAL"]' . do_lang('EDIT') . '[/page]]';
         }
     }
     $out->attach(comcode_to_tempcode($message, NULL, true));
     return $out;
 }
示例#17
0
 /**
  * Standard modular run function for snippet hooks. Generates XHTML to insert into a page using AJAX.
  *
  * @return tempcode  The snippet
  */
 function run()
 {
     $sup = get_param('block_map_sup', '', true);
     $_map = get_param('block_map', false, true);
     if ($sup != '') {
         $_map .= ',' . $sup;
     }
     require_code('blocks');
     $map = block_params_str_to_arr($_map);
     if (!array_key_exists('block', $map)) {
         return new ocp_tempcode();
     }
     $auth_key = get_param_integer('auth_key');
     // Check permissions
     $test = $GLOBALS['SITE_DB']->query_value_null_ok('temp_block_permissions', 'p_block_constraints', array('p_session_id' => get_session_id(), 'id' => $auth_key));
     if (is_null($test) || !block_signature_check(block_params_str_to_arr($test), $map)) {
         require_lang('permissions');
         return paragraph(do_lang_tempcode('ACCESS_DENIED__ACCESS_DENIED', escape_html($map['block'])));
     }
     // Cleanup
     $GLOBALS['SITE_DB']->query('DELETE FROM ' . get_table_prefix() . 'temp_block_permissions WHERE p_time<' . strval(time() - 60 * 60 * intval(get_option('session_expiry_time'))));
     // Return block snippet
     global $CSSS, $JAVASCRIPTS;
     $CSSS = array();
     $JAVASCRIPTS = array();
     $out = new ocp_tempcode();
     $out->attach(symbol_tempcode('CSS_TEMPCODE'));
     $out->attach(symbol_tempcode('JS_TEMPCODE'));
     $out->attach(do_block($map['block'], $map));
     return $out;
 }
示例#18
0
 /**
  * Standard modular run function.
  *
  * @param  array		A map of parameters.
  * @return tempcode	The result of execution.
  */
 function run($map)
 {
     if (!array_key_exists('param', $map)) {
         $map['param'] = '';
     }
     if (!array_key_exists('extra', $map)) {
         $map['extra'] = '';
     }
     $max = array_key_exists('max', $map) ? intval($map['max']) : 100;
     require_code('banners');
     $b_type = $map['param'];
     $myquery = 'SELECT * FROM ' . get_table_prefix() . 'banners WHERE ((((the_type<>1) OR ((campaign_remaining>0) AND ((expiry_date IS NULL) or (expiry_date>' . strval(time()) . ')))) AND ' . db_string_not_equal_to('name', '') . ')) AND validated=1 AND ' . db_string_equal_to('b_type', $b_type) . ' ORDER BY name';
     $banners = $GLOBALS['SITE_DB']->query($myquery, 200);
     $assemble = new ocp_tempcode();
     if (count($banners) > $max) {
         shuffle($banners);
         $banners = array_slice($banners, 0, $max);
     }
     foreach ($banners as $i => $banner) {
         $bd = show_banner($banner['name'], $banner['b_title_text'], get_translated_tempcode($banner['caption']), $banner['img_url'], '', $banner['site_url'], $banner['b_type']);
         $more_coming = $i < count($banners) - 1;
         $assemble->attach(do_template('BLOCK_MAIN_BANNER_WAVE_BWRAP', array('EXTRA' => $map['extra'], 'TYPE' => $map['param'], 'BANNER' => $bd, 'MORE_COMING' => $more_coming)));
     }
     return do_template('BLOCK_MAIN_BANNER_WAVE', array('EXTRA' => $map['extra'], 'TYPE' => $map['param'], 'ASSEMBLE' => $assemble));
 }
 /**
  * Standard modular run function.
  *
  * @param  array		A map of parameters.
  * @return tempcode	The result of execution.
  */
 function run($map)
 {
     unset($map);
     if (get_forum_type() != 'ocf') {
         return new ocp_tempcode();
     }
     if (is_guest()) {
         return new ocp_tempcode();
     }
     require_css('side_blocks');
     ocf_require_all_forum_stuff();
     require_code('ocf_notifications');
     // Only show what's new in week. Some forums may want to tweak this, but forums themselves only mark unread topics for a week.
     $rows = ocf_get_pp_rows();
     //		if (count($rows)==0) return new ocp_tempcode();
     require_lang('ocf');
     $out = new ocp_tempcode();
     foreach ($rows as $topic) {
         $topic_url = build_url(array('page' => 'topicview', 'id' => $topic['id'], 'type' => 'findpost'), get_module_zone('topicview'));
         $topic_url->attach('#post_' . strval($topic['id']));
         $title = $topic['t_cache_first_title'];
         $date = get_timezoned_date($topic['t_cache_last_time'], true);
         $username = $topic['t_cache_last_username'];
         $member_link = $GLOBALS['OCF_DRIVER']->member_profile_url($topic['t_cache_last_member_id'], false, true);
         $num_posts = $topic['t_cache_num_posts'];
         $out->attach(do_template('TOPIC_LIST', array('_GUID' => '55ae21a9f8d67ba6237c118a18b9657b', 'USER_LINK' => $member_link, 'TOPIC_LINK' => $topic_url, 'TITLE' => $title, 'DATE' => $date, 'DATE_RAW' => strval($topic['t_cache_last_time']), 'USERNAME' => $username, 'NUM_POSTS' => integer_format($num_posts))));
     }
     $send_url = build_url(array('page' => 'topics', 'type' => 'new_pt', 'redirect' => SELF_REDIRECT), get_module_zone('topics'));
     if (!ocf_may_make_personal_topic()) {
         $send_url = new ocp_tempcode();
     }
     $view_url = build_url(array('page' => 'members', 'type' => 'view', 'id' => get_member()), get_module_zone('members'), NULL, true, false, false, 'tab__pts');
     return do_template('BLOCK_SIDE_OCF_PERSONAL_TOPICS', array('_GUID' => '9376cd47884a78f3d1914c176b67ee28', 'SEND_URL' => $send_url, 'VIEW_URL' => $view_url, 'CONTENT' => $out, 'FORUM_NAME' => do_lang_tempcode('PERSONAL_TOPICS')));
 }
示例#20
0
 /**
  * Standard modular run function for features in the setup wizard.
  *
  * @return tempcode	An input field.
  */
 function get_fields()
 {
     require_lang('wordfilter');
     $fields = new ocp_tempcode();
     $fields->attach(form_input_tick(do_lang_tempcode('KEEP_WORD_FILTER'), do_lang_tempcode('DESCRIPTION_HAVE_DEFAULT_WORDFILTER'), 'have_default_wordfilter', true));
     return $fields;
 }
示例#21
0
 /**
  * Standard modular run function for RSS hooks.
  *
  * @param  string			A list of categories we accept from
  * @param  TIME			Cutoff time, before which we do not show results from
  * @param  string			Prefix that represents the template set we use
  * @set    RSS_ ATOM_
  * @param  string			The standard format of date to use for the syndication type represented in the prefix
  * @param  integer		The maximum number of entries to return, ordering by date
  * @return ?array			A pair: The main syndication section, and a title (NULL: error)
  */
 function run($_filters, $cutoff, $prefix, $date_string, $max)
 {
     if (!addon_installed('galleries')) {
         return NULL;
     }
     if (!has_actual_page_access(get_member(), 'galleries')) {
         return NULL;
     }
     $filters_1 = ocfilter_to_sqlfragment($_filters, 'name', 'galleries', 'parent_id', 'name', 'name', false, false);
     // 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)
     $filters = ocfilter_to_sqlfragment($_filters, 'cat', 'galleries', 'parent_id', 'cat', 'name', false, false);
     // 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)
     require_lang('galleries');
     $content = new ocp_tempcode();
     $_galleries = array();
     if ($GLOBALS['SITE_DB']->query_value_null_ok_full('SELECT COUNT(*) FROM ' . get_table_prefix() . 'galleries WHERE ' . $filters_1) < 3000) {
         $_galleries = $GLOBALS['SITE_DB']->query('SELECT fullname,name FROM ' . get_table_prefix() . 'galleries WHERE ' . $filters_1);
         foreach ($_galleries as $i => $_gallery) {
             $_galleries[$i]['text_original'] = get_translated_text($_gallery['fullname']);
         }
     }
     $galleries = collapse_2d_complexity('name', 'text_original', $_galleries);
     $rows1 = $GLOBALS['SITE_DB']->query('SELECT * FROM ' . $GLOBALS['SITE_DB']->get_table_prefix() . 'videos WHERE add_date>' . strval((int) $cutoff) . ' AND ' . $filters . (!has_specific_permission(get_member(), 'see_unvalidated') ? ' AND validated=1 ' : '') . ' ORDER BY add_date DESC', $max);
     $rows2 = $GLOBALS['SITE_DB']->query('SELECT * FROM ' . $GLOBALS['SITE_DB']->get_table_prefix() . 'images WHERE add_date>' . strval((int) $cutoff) . ' AND ' . $filters . (!has_specific_permission(get_member(), 'see_unvalidated') ? ' AND validated=1 ' : '') . ' ORDER BY add_date DESC', $max);
     $rows = array_merge($rows1, $rows2);
     foreach ($rows as $row) {
         $id = strval($row['id']);
         $author = $GLOBALS['FORUM_DRIVER']->get_username($row['submitter']);
         if (is_null($author)) {
             $author = '';
         }
         $news_date = date($date_string, $row['add_date']);
         $edit_date = is_null($row['edit_date']) ? '' : date($date_string, $row['edit_date']);
         $news_title = xmlentities(do_lang('THIS_WITH_SIMPLE', array_key_exists('video_views', $row) ? do_lang('VIDEO') : do_lang('IMAGE'), strval($row['id'])));
         $_summary = get_translated_tempcode($row['comments']);
         $summary = xmlentities($_summary->evaluate());
         $news = '';
         if (!array_key_exists($row['cat'], $galleries)) {
             $_fullname = $GLOBALS['SITE_DB']->query_value_null_ok('galleries', 'fullname', array('name' => $row['cat']));
             if (is_null($_fullname)) {
                 continue;
             }
             $galleries[$row['cat']] = get_translated_text($_fullname);
         }
         $category = $galleries[$row['cat']];
         $category_raw = $row['cat'];
         $view_url = build_url(array('page' => 'galleries', 'type' => array_key_exists('video_views', $row) ? 'video' : 'image', 'id' => $row['id']), get_module_zone('galleries'), NULL, false, false, true);
         if ($prefix == 'RSS_' && get_option('is_on_comments') == '1' && $row['allow_comments'] >= '1') {
             $if_comments = do_template('RSS_ENTRY_COMMENTS', array('_GUID' => '65dc0cec8c75f565c58c95fa1667aa1e', 'COMMENT_URL' => $view_url, 'ID' => strval($row['id'])));
         } else {
             $if_comments = new ocp_tempcode();
         }
         require_code('images');
         $enclosure_url = ensure_thumbnail($row['url'], $row['thumb_url'], 'galleries', array_key_exists('video_views', $row) ? 'videos' : 'images', $row['id']);
         list($enclosure_length, $enclosure_type) = get_enclosure_details($row['url'], $enclosure_url);
         $content->attach(do_template($prefix . 'ENTRY', array('ENCLOSURE_URL' => $enclosure_url, 'ENCLOSURE_LENGTH' => $enclosure_length, 'ENCLOSURE_TYPE' => $enclosure_type, 'VIEW_URL' => $view_url, 'SUMMARY' => $summary, 'EDIT_DATE' => $edit_date, 'IF_COMMENTS' => $if_comments, 'TITLE' => $news_title, 'CATEGORY_RAW' => $category_raw, 'CATEGORY' => $category, 'AUTHOR' => $author, 'ID' => $id, 'NEWS' => $news, 'DATE' => $news_date)));
     }
     require_lang('galleries');
     return array($content, do_lang('GALLERIES'));
 }
示例#22
0
 /**
  * Standard modular run function.
  *
  * @param  array		A map of parameters.
  * @return tempcode	The result of execution.
  */
 function run($map)
 {
     require_code('type_validation');
     require_lang('phpdoc');
     require_code('php');
     require_css('adminzone');
     disable_php_memory_limit();
     $filename = (array_key_exists('param', $map) ? $map['param'] : 'sources/global2') . '.php';
     if (substr($filename, -8) == '.php.php') {
         $filename = substr($filename, 0, strlen($filename) - 4);
     }
     $full_path = (get_file_base() != '' ? get_file_base() . '/' : '') . filter_naughty($filename);
     if (!file_exists($full_path)) {
         return paragraph(do_lang_tempcode('MISSING_RESOURCE'));
     }
     $_classes = get_php_file_api($filename);
     $classes = new ocp_tempcode();
     foreach ($_classes as $class) {
         if ($class['name'] == '__global') {
             $class['name'] = do_lang('GLOBAL_FUNCTIONS') . '_' . basename($filename);
         }
         $function_summaries = new ocp_tempcode();
         $functions = new ocp_tempcode();
         foreach ($class['functions'] as $function) {
             $ret = render_php_function($function, $class);
             $functions->attach($ret[0]);
             $function_summaries->attach($ret[1]);
         }
         $classes->attach(do_template('PHP_CLASS', array('_GUID' => '5d58fc42c5fd3a5dd190f3f3699610c2', 'CLASS_NAME' => $class['name'], 'FUNCTION_SUMMARIES' => $function_summaries, 'FUNCTIONS' => $functions)));
     }
     return do_template('PHP_FILE', array('_GUID' => '6f422e6a6e846d49864d7325b212109f', 'FILENAME' => $filename, 'CLASSES' => $classes));
 }
示例#23
0
 /**
  * Standard modular run function for RSS hooks.
  *
  * @param  string			A list of categories we accept from
  * @param  TIME			Cutoff time, before which we do not show results from
  * @param  string			Prefix that represents the template set we use
  * @set    RSS_ ATOM_
  * @param  string			The standard format of date to use for the syndication type represented in the prefix
  * @param  integer		The maximum number of entries to return, ordering by date
  * @return ?array			A pair: The main syndication section, and a title (NULL: error)
  */
 function run($_filters, $cutoff, $prefix, $date_string, $max)
 {
     require_lang('activities');
     require_code('activities');
     list(, $whereville) = find_activities(get_member(), $_filters == '' ? 'all' : 'some_members', $_filters == '' ? NULL : array_map('intval', explode(',', $_filters)));
     $rows = $GLOBALS['SITE_DB']->query('SELECT * FROM ' . get_table_prefix() . 'activities WHERE (' . $whereville . ') AND a_time>' . strval($cutoff) . ' ORDER BY a_time DESC', $max, 0);
     $content = new ocp_tempcode();
     foreach ($rows as $row) {
         $id = strval($row['id']);
         $author = $GLOBALS['FORUM_DRIVER']->get_username($row['a_member_id']);
         if (is_null($author)) {
             $author = do_lang('UNKNOWN');
         }
         $news_date = date($date_string, $row['a_time']);
         $edit_date = '';
         list($_title, ) = render_activity($row);
         $news_title = xmlentities($_title->evaluate());
         $summary = xmlentities('');
         $news = '';
         $category = '';
         $category_raw = '';
         $view_url = build_url(array('page' => 'members', 'type' => 'view', 'id' => $row['a_member_id']), get_module_zone('members'), NULL, false, false, true);
         $if_comments = new ocp_tempcode();
         $content->attach(do_template($prefix . 'ENTRY', array('VIEW_URL' => $view_url, 'SUMMARY' => $summary, 'EDIT_DATE' => $edit_date, 'IF_COMMENTS' => $if_comments, 'TITLE' => $news_title, 'CATEGORY_RAW' => $category_raw, 'CATEGORY' => $category, 'AUTHOR' => $author, 'ID' => $id, 'NEWS' => $news, 'DATE' => $news_date)));
     }
     return array($content, do_lang('ACTIVITIES_TITLE'));
 }
示例#24
0
 /**
  * Standard modular run function for features in the setup wizard.
  *
  * @param  array		Default values for the fields, from the install-profile.
  * @return tempcode	An input field.
  */
 function get_fields($field_defaults)
 {
     if (get_forum_type() != 'ocf') {
         return new ocp_tempcode();
     }
     require_lang('ocf');
     $fields = new ocp_tempcode();
     $dbs_back = $GLOBALS['NO_DB_SCOPE_CHECK'];
     $GLOBALS['NO_DB_SCOPE_CHECK'] = true;
     $test = $GLOBALS['SITE_DB']->query_value_null_ok('f_groups', 'id', array('id' => db_get_first_id() + 7));
     if (!is_null($test)) {
         $fields->attach(form_input_tick(do_lang_tempcode('HAVE_DEFAULT_RANK_SET'), do_lang_tempcode('DESCRIPTION_HAVE_DEFAULT_RANK_SET'), 'have_default_rank_set', array_key_exists('have_default_rank_set', $field_defaults) ? $field_defaults['have_default_rank_set'] == '1' : false));
     }
     $test = $GLOBALS['SITE_DB']->query('SELECT * FROM ' . get_table_prefix() . 'f_emoticons WHERE e_code<>\':P\' AND e_code<>\';)\' AND e_code<>\':)\' AND e_code<>\':)\' AND e_code<>\':\\\'(\'');
     if (count($test) != 0) {
         $fields->attach(form_input_tick(do_lang_tempcode('HAVE_DEFAULT_FULL_EMOTICON_SET'), do_lang_tempcode('DESCRIPTION_HAVE_DEFAULT_FULL_EMOTICON_SET'), 'have_default_full_emoticon_set', array_key_exists('have_default_full_emoticon_set', $field_defaults) ? $field_defaults['have_default_full_emoticon_set'] == '1' : true));
     }
     $fields_l = array('im_aim', 'im_msn', 'im_jabber', 'im_yahoo', 'im_skype', 'interests', 'location', 'occupation', 'sn_google', 'sn_facebook', 'sn_twitter');
     foreach ($fields_l as $field) {
         $test = $GLOBALS['SITE_DB']->query_value_null_ok('f_custom_fields f LEFT JOIN ' . get_table_prefix() . 'translate t ON t.id=f.cf_name', 'f.id', array('text_original' => do_lang('DEFAULT_CPF_' . $field . '_NAME')));
         if (!is_null($test)) {
             $fields->attach(form_input_tick(do_lang_tempcode('HAVE_DEFAULT_CPF_SET'), do_lang_tempcode('DESCRIPTION_HAVE_DEFAULT_CPF_SET'), 'have_default_cpf_set', array_key_exists('have_default_cpf_set', $field_defaults) ? $field_defaults['have_default_cpf_set'] == '1' : false));
             break;
         }
     }
     $GLOBALS['NO_DB_SCOPE_CHECK'] = $dbs_back;
     return $fields;
 }
示例#25
0
 /**
  * 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');
     $zone = array_key_exists('zone', $map) ? $map['zone'] : get_module_zone('downloads');
     global $NON_CANONICAL_PARAMS;
     $NON_CANONICAL_PARAMS[] = 'max';
     $max = get_param_integer('max', 10);
     if ($max < 1) {
         $max = 1;
     }
     $start = get_param_integer('start', 0);
     $rows = $GLOBALS['SITE_DB']->query_select('download_downloads', array('*'), array('validated' => 1), 'ORDER BY num_downloads DESC', $max, $start);
     $content = new ocp_tempcode();
     foreach ($rows as $i => $row) {
         if ($i != 0) {
             $content->attach(do_template('BLOCK_SEPARATOR'));
         }
         $content->attach(get_download_html($row, true, true, $zone));
     }
     $page_num = intval(floor(floatval($start) / floatval($max))) + 1;
     $count = $GLOBALS['SITE_DB']->query_value('download_downloads', 'COUNT(*)', array('validated' => 1));
     $num_pages = intval(ceil(floatval($count) / floatval($max)));
     if ($num_pages == 0) {
         $page_num = 0;
     }
     $previous_url = $start == 0 ? new ocp_tempcode() : build_url(array('page' => '_SELF', 'start' => $start - $max), '_SELF');
     $next_url = $page_num == $num_pages ? new ocp_tempcode() : build_url(array('page' => '_SELF', 'start' => $start + $max), '_SELF');
     $browse = do_template('NEXT_BROWSER_BROWSE_NEXT', array('_GUID' => '15ca70ec400629f67edefa869fb1f1a8', 'NEXT_LINK' => $next_url, 'PREVIOUS_LINK' => $previous_url, 'PAGE_NUM' => integer_format($page_num), 'NUM_PAGES' => integer_format($num_pages)));
     return do_template('BLOCK_MAIN_DOWNLOAD_TEASE', array('_GUID' => 'a164e33c0b4ace4bae945c39f2f00ca9', 'CONTENT' => $content, 'BROWSE' => $browse));
 }
示例#26
0
/**
 * Get information about new versions of ocPortal (or more accurately, what's wrong with this version).
 *
 * @return tempcode		Information about the installed ocPortal version
 */
function get_future_version_information()
{
    require_lang('version');
    $url = 'http://ocportal.com/version.php?version=' . rawurlencode(ocp_version_full()) . '&lang=' . rawurlencode(user_lang());
    $data = http_download_file($url, NULL, false);
    if (!is_null($data)) {
        $data = str_replace('"../upgrader.php"', '"' . get_base_url() . '/upgrader.php"', $data);
        if ($GLOBALS['XSS_DETECT']) {
            ocp_mark_as_escaped($data);
        }
        require_code('character_sets');
        $data = convert_to_internal_encoding($data);
        $table = new ocp_tempcode();
        $lines = explode(chr(10), $data);
        foreach ($lines as $line) {
            if (trim($line) != '') {
                $table->attach(paragraph($line));
            }
        }
        $table = make_string_tempcode(preg_replace('#<p>\\s*</p>#', '', $table->evaluate()));
    } else {
        $table = paragraph(do_lang_tempcode('CANNOT_CONNECT_HOME'), 'dfsdff32ffd');
    }
    require_code('xhtml');
    /*$table->attach('<script type="text/javascript">// <![CDATA[
    		window.open(\''.$url.'\');
    	//]]></script>');*/
    return make_string_tempcode(xhtmlise_html($table->evaluate()));
}
示例#27
0
 /**
  * Standard modular render function for profile tabs edit hooks.
  *
  * @param  MEMBER			The ID of the member who is being viewed
  * @param  MEMBER			The ID of the member who is doing the viewing
  * @param  boolean		Whether to leave the tab contents NULL, if tis hook supports it, so that AJAX can load it later
  * @return ?array			A tuple: The tab title, the tab body text (may be blank), the tab fields, extra Javascript (may be blank) the suggested tab order, hidden fields (optional) (NULL: if $leave_to_ajax_if_possible was set)
  */
 function render_tab($member_id_of, $member_id_viewing, $leave_to_ajax_if_possible = false)
 {
     $title = do_lang_tempcode('DELETE_MEMBER');
     $order = 200;
     // Actualiser
     $delete_account = post_param_integer('delete', 0);
     if ($delete_account == 1) {
         if (is_guest($member_id_of)) {
             warn_exit(do_lang_tempcode('INTERNAL_ERROR'));
         }
         ocf_delete_member($member_id_of);
         inform_exit(do_lang_tempcode('SUCCESS'));
     }
     if ($leave_to_ajax_if_possible) {
         return NULL;
     }
     // UI fields
     $username = $GLOBALS['FORUM_DRIVER']->get_username($member_id_of);
     $text = do_lang_tempcode('_DELETE_MEMBER' . ($member_id_of == get_member() ? '_SUICIDAL' : ''), escape_html($username));
     $fields = new ocp_tempcode();
     require_code('form_templates');
     $fields->attach(form_input_tick(do_lang_tempcode('DELETE'), do_lang_tempcode('DESCRIPTION_DELETE'), 'delete', false));
     $javascript = '';
     return array($title, $fields, $text, $javascript, $order);
 }
示例#28
0
 /**
  * Standard modular run function for RSS hooks.
  *
  * @param  string			A list of categories we accept from
  * @param  TIME			Cutoff time, before which we do not show results from
  * @param  string			Prefix that represents the template set we use
  * @set    RSS_ ATOM_
  * @param  string			The standard format of date to use for the syndication type represented in the prefix
  * @param  integer		The maximum number of entries to return, ordering by date
  * @return ?array			A pair: The main syndication section, and a title (NULL: error)
  */
 function run($_filters, $cutoff, $prefix, $date_string, $max)
 {
     if (!addon_installed('cedi')) {
         return NULL;
     }
     if (!has_actual_page_access(get_member(), 'cedi')) {
         return NULL;
     }
     $filters = ocfilter_to_sqlfragment($_filters, 'id', 'seedy_children', 'parent_id', 'parent_id', 'child_id');
     $content = new ocp_tempcode();
     $rows = $GLOBALS['SITE_DB']->query('SELECT * FROM ' . $GLOBALS['SITE_DB']->get_table_prefix() . 'seedy_pages WHERE ' . $filters . ' AND add_date>' . strval((int) $cutoff) . ' ORDER BY add_date DESC', $max);
     foreach ($rows as $row) {
         $id = strval($row['id']);
         if (!has_category_access(get_member(), 'seedy_page', strval($row['id']))) {
             continue;
         }
         $author = '';
         $news_date = date($date_string, $row['add_date']);
         $edit_date = '';
         $news_title = xmlentities(escape_html(get_translated_text($row['title'])));
         $_summary = get_translated_tempcode($row['description']);
         $summary = xmlentities($_summary->evaluate());
         $news = '';
         $category = '';
         $category_raw = '';
         $view_url = build_url(array('page' => 'cedi', 'type' => 'misc', 'id' => $row['id'] == db_get_first_id() ? NULL : $row['id']), get_module_zone('cedi'), NULL, false, false, true);
         $if_comments = new ocp_tempcode();
         $content->attach(do_template($prefix . 'ENTRY', array('VIEW_URL' => $view_url, 'SUMMARY' => $summary, 'EDIT_DATE' => $edit_date, 'IF_COMMENTS' => $if_comments, 'TITLE' => $news_title, 'CATEGORY_RAW' => $category_raw, 'CATEGORY' => $category, 'AUTHOR' => $author, 'ID' => $id, 'NEWS' => $news, 'DATE' => $news_date)));
     }
     require_lang('cedi');
     return array($content, do_lang('CEDI_PAGES'));
 }
示例#29
0
 /**
  * Standard modular run function.
  *
  * @param  array		A map of parameters.
  * @return tempcode	The result of execution.
  */
 function run($map)
 {
     unset($map);
     require_all_lang();
     $blocks = new ocp_tempcode();
     require_code('zones2');
     require_code('zones3');
     $_blocks = find_all_blocks();
     foreach (array_keys($_blocks) as $block) {
         $description = do_lang('BLOCK_' . $block . '_DESCRIPTION', NULL, NULL, NULL, NULL, false);
         if (is_null($description)) {
             continue;
         }
         $use = do_lang('BLOCK_' . $block . '_USE');
         $_parameters = get_block_parameters($block);
         if (!is_array($_parameters)) {
             continue;
         }
         $parameters = new ocp_tempcode();
         foreach ($_parameters as $parameter) {
             $_description = do_lang('BLOCK_' . $block . '_PARAM_' . $parameter, NULL, NULL, NULL, NULL, false);
             if (is_null($_description)) {
                 continue;
             }
             $parameters->attach(do_template('BLOCK_MAIN_BLOCK_HELP_PARAMETER', array('_GUID' => 'f23db88061922a68cc2401256cf69ad3', 'NAME' => $parameter, 'DESCRIPTION' => $_description)));
         }
         $blocks->attach(do_template('BLOCK_MAIN_BLOCK_HELP', array('_GUID' => '00652313faa72feac0a07d77e2dddd84', 'NAME' => $block, 'DESCRIPTION' => $description, 'USE' => $use, 'PARAMETERS' => $parameters)));
     }
     return $blocks;
 }
示例#30
0
 /**
  * Get a preview(s) of a (group of) template(s), as a full standalone piece of HTML in Tempcode format.
  * Uses sources/lorem.php functions to place appropriate stock-text. Should not hard-code things, as the code is intended to be declaritive.
  * Assumptions: You can assume all Lang/CSS/Javascript files in this addon have been pre-required.
  *
  * @return array			Array of previews, each is Tempcode. Normally we have just one preview, but occasionally it is good to test templates are flexible (e.g. if they use IF_EMPTY, we can test with and without blank data).
  */
 function tpl_preview__administrative__staff_admin_screen()
 {
     $available = new ocp_tempcode();
     foreach (placeholder_array() as $k => $v) {
         $available->attach(do_lorem_template('STAFF_EDIT_WRAPPER', array('FORM' => placeholder_form(), 'NAME' => lorem_word())));
     }
     return array(lorem_globalise(do_lorem_template('STAFF_ADMIN_SCREEN', array('TITLE' => lorem_title(), 'TEXT' => lorem_sentence_html(), 'FORUM_STAFF' => $available)), NULL, '', true));
 }