Example #1
0
/**
 * Get a splurghified version of the specified item.
 *
 * @param  string			The name of what the key we want to reference is in our array of maps (e.g. 'id')
 * @param  array			A row of maps for data we are splurghing; this is probably just the result of $GLOBALS['SITE_DB']->query_select
 * @param  URLPATH		The stub that links will be passed through
 * @param  ID_TEXT		The page name we will be saving customised HTML under
 * @param  TIME			The time we did our last change to the data being splurghed (so it can see if we can simply decache instead of deriving)
 * @param  ?AUTO_LINK	The ID that is at the root of our tree (NULL: db_get_first_id)
 * @return string			A string of HTML that represents our splurghing (will desplurgh in the users browser)
 */
function splurgh_master_build($key_name, $map, $url_stub, $_cache_file, $last_change_time, $first_id = NULL)
{
    if (is_null($first_id)) {
        $first_id = db_get_first_id();
    }
    if (!array_key_exists($first_id, $map)) {
        return '';
    }
    if (!has_js()) {
        warn_exit(do_lang_tempcode('MSG_JS_NEEDED'));
    }
    require_javascript('javascript_splurgh');
    if (is_browser_decacheing()) {
        $last_change_time = time();
    }
    $cache_file = zone_black_magic_filterer(get_custom_file_base() . '/' . get_zone_name() . '/pages/html_custom/' . filter_naughty(user_lang()) . '/' . filter_naughty($_cache_file) . '.htm');
    if (!file_exists($cache_file) || is_browser_decacheing() || filesize($cache_file) == 0 || $last_change_time > filemtime($cache_file)) {
        $myfile = @fopen($cache_file, 'wt');
        if ($myfile === false) {
            intelligent_write_error($cache_file);
        }
        $fulltable = array();
        $splurgh = _splurgh_do_node($map, $first_id, '', $fulltable, 0);
        $page = do_template('SPLURGH', array('_GUID' => '8775edfc5a386fdf2cec69b0fc889952', 'KEY_NAME' => $key_name, 'URL_STUB' => $url_stub, 'SPLURGH' => str_replace('"', '\'', $splurgh)));
        $ev = $page->evaluate();
        if (fwrite($myfile, $ev) < strlen($ev)) {
            warn_exit(do_lang_tempcode('COULD_NOT_SAVE_FILE'));
        }
        fclose($myfile);
        fix_permissions($cache_file);
        sync_file($cache_file);
        return $ev;
    }
    return file_get_contents($cache_file, FILE_TEXT);
}
Example #2
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()));
}
Example #3
0
 /**
  * Run the checks
  */
 function run_tool()
 {
     $this->check_table_flash_bbcodes(POSTS_TABLE, 'post_id', 'post_text', 'bbcode_uid', 'bbcode_bitfield');
     $this->check_table_flash_bbcodes(PRIVMSGS_TABLE, 'msg_id', 'message_text', 'bbcode_uid', 'bbcode_bitfield');
     $this->check_table_flash_bbcodes(USERS_TABLE, 'user_id', 'user_sig', 'user_sig_bbcode_uid', 'user_sig_bbcode_bitfield');
     // Not checked atm
     //		check_table_flash_bbcodes(FORUMS_TABLE, 'forum_id', 'forum_desc', 'forum_desc_uid', 'forum_desc_bitfield');
     //		check_table_flash_bbcodes(FORUMS_TABLE, 'forum_id', 'forum_rules', 'forum_rules_uid', 'forum_rules_bitfield');
     //		check_table_flash_bbcodes(GROUPS_TABLE, 'group_id', 'group_desc', 'group_desc_uid', 'group_desc_bitfield');
     // Nothing found
     if (empty($this->_vulnerable)) {
         trigger_error('FLASH_CHECKER_NO_FOUND');
     }
     // Here we'll create the cache files the reparse BBCode tool expects so
     // the tool can be run straight away
     global $cache;
     $ids = implode(',', $this->_vulnerable[POSTS_TABLE]);
     if ($ids) {
         $cache->put('_stk_reparse_posts', $ids);
         $ids = implode(',', $this->_vulnerable[POSTS_TABLE]);
         $message = user_lang('FLASH_CHECKER_FOUND', append_sid(STK_INDEX, array('c' => 'admin', 't' => 'reparse_bbcode', 'reparseids' => $ids, 'submit' => true)));
         $message .= '<br />' . user_lang('FLASH_CHECKER_POST', append_sid(PHPBB_ROOT_PATH . 'viewtopic.' . PHP_EXT . '?p=' . $ids . '#' . $ids)) . '';
     }
     if (!empty($this->_vulnerable[PRIVMSGS_TABLE])) {
         $cache->put('_stk_reparse_pms', implode(',', $this->_vulnerable[PRIVMSGS_TABLE]));
         $privmsgs_ids = implode(',', $this->_vulnerable[PRIVMSGS_TABLE]);
         $message = user_lang('FLASH_CHECKER_FOUND', append_sid(STK_INDEX, array('c' => 'admin', 't' => 'reparse_bbcode', 'reparsepms' => $privmsgs_ids, 'submit' => true)));
     }
     trigger_error($message, E_USER_WARNING);
 }
Example #4
0
 /**
  * Standard modular run function.
  *
  * @param  array		A map of parameters.
  * @return tempcode	The result of execution.
  */
 function run($map)
 {
     unset($map);
     require_css('side_blocks');
     $langs = nice_get_langs(user_lang());
     return do_template('BLOCK_SIDE_LANGUAGE', array('_GUID' => '5dd7dd434722d7fd958773bd08e838c7', 'LANGS' => $langs));
 }
Example #5
0
/**
 * Put a result into the cache.
 *
 * @param  ID_TEXT			The codename to check for cacheing
 * @param  integer			The TTL of what is being cached in minutes
 * @param  LONG_TEXT			The requisite situational information (a serialized map) [-> further restraints when reading]
 * @param  mixed				The result we are cacheing
 * @param  ?array				A list of the language files that need loading to use tempcode embedded in the cache (NULL: none required)
 * @param  ?array				A list of the javascript files that need loading to use tempcode embedded in the cache (NULL: none required)
 * @param  ?array				A list of the css files that need loading to use tempcode embedded in the cache (NULL: none required)
 * @param  boolean			Whether we are cacheing Tempcode (needs special care)
 * @param  ?ID_TEXT			The theme this is being cached for (NULL: current theme)
 * @param  ?LANGUAGE_NAME	The language this is being cached for (NULL: current language)
 */
function put_into_cache($codename, $ttl, $cache_identifier, $cache, $_langs_required = NULL, $_javascripts_required = NULL, $_csss_required = NULL, $tempcode = false, $theme = NULL, $lang = NULL)
{
    if ($theme === NULL) {
        $theme = $GLOBALS['FORUM_DRIVER']->get_theme();
    }
    if ($lang === NULL) {
        $lang = user_lang();
    }
    global $KEEP_MARKERS, $SHOW_EDIT_LINKS;
    if ($KEEP_MARKERS || $SHOW_EDIT_LINKS) {
        return;
    }
    $langs_required = is_null($_langs_required) ? '' : implode(':', $_langs_required);
    $langs_required .= '!';
    $langs_required .= is_null($_javascripts_required) ? '' : implode(':', $_javascripts_required);
    $langs_required .= '!';
    $langs_required .= is_null($_csss_required) ? '' : implode(':', $_csss_required);
    if (!is_null($GLOBALS['MEM_CACHE'])) {
        $pcache = persistant_cache_get(array('CACHE', $codename));
        if (is_null($pcache)) {
            $pcache = array();
        }
        $pcache[$cache_identifier][$lang][$theme] = array('langs_required' => $langs_required, 'date_and_time' => time(), 'the_value' => $cache);
        persistant_cache_set(array('CACHE', $codename), $pcache, false, $ttl * 60);
    } else {
        $GLOBALS['SITE_DB']->query_delete('cache', array('lang' => $lang, 'the_theme' => $theme, 'cached_for' => $codename, 'identifier' => md5($cache_identifier)), '', 1);
        $GLOBALS['SITE_DB']->query_insert('cache', array('langs_required' => $langs_required, 'lang' => $lang, 'cached_for' => $codename, 'the_value' => $tempcode ? $cache->to_assembly($lang) : serialize($cache), 'date_and_time' => time(), 'the_theme' => $theme, 'identifier' => md5($cache_identifier)), false, true);
    }
}
Example #6
0
 /**
  * Display Options
  *
  * Output the options available
  */
 function display_options()
 {
     global $template, $user;
     // This is kinda like the main page
     // Output the main page
     page_header($user->lang['SUPPORT_TOOL_KIT']);
     // Category title and desc if available
     $template->assign_vars(array('L_TITLE' => $user->lang['CAT_ERK'], 'L_TITLE_EXPLAIN' => user_lang('CAT_ERK_EXPLAIN', append_sid(STK_ROOT_PATH . 'erk.' . PHP_EXT))));
     $template->set_filenames(array('body' => 'index_body.html'));
     page_footer();
 }
Example #7
0
 /**
  * Standard modular run function for CRON hooks. Searches for tasks to perform.
  */
 function run()
 {
     //if (!addon_installed('octhief')) return;
     require_lang('insults');
     // ensure it is done once per week
     $time = time();
     $last_time = intval(get_value('last_insult_time'));
     if ($last_time > time() - 24 * 60 * 60) {
         return;
     }
     // run it once a day
     set_value('last_insult_time', strval($time));
     // how many points a correct response will give
     $_insult_points = get_option('insult_points', true);
     if (is_null($_insult_points)) {
         // add option and default value if not installed yet
         require_code('database_action');
         add_config_option('INSULT_POINTS', 'insult_points', 'integer', 'return \'10\';', 'POINTS', 'INSULT_TITLE');
     }
     $insult_points = isset($_insult_points) && is_numeric($_insult_points) ? intval($_insult_points) : 10;
     // who to insult?
     $selected_members = $GLOBALS['FORUM_DB']->query('SELECT id FROM ' . $GLOBALS['FORUM_DB']->get_table_prefix() . 'f_members WHERE  id <> ' . strval($GLOBALS['FORUM_DRIVER']->get_guest_id()) . ' ORDER BY RAND( ) ', 2, NULL, true);
     $selected_member1 = isset($selected_members[0]['id']) && $selected_members[0]['id'] > 0 ? $selected_members[0]['id'] : 0;
     $selected_member2 = isset($selected_members[1]['id']) && $selected_members[1]['id'] > 0 ? $selected_members[1]['id'] : 0;
     // send insult to picked members
     if ($selected_member1 != 0 && $selected_member2 != 0) {
         $get_insult = '';
         if (is_file(get_file_base() . '/text_custom/' . user_lang() . '/insults.txt')) {
             $insults = file(get_file_base() . '/text_custom/' . user_lang() . '/insults.txt');
             $insults_array = array();
             foreach ($insults as $insult) {
                 $x = explode('=', $insult);
                 $insults_array[] = $x[0];
             }
             $rand_key = array_rand($insults_array, 1);
             $rand_key = is_array($rand_key) ? $rand_key[0] : $rand_key;
             $get_insult = $insults_array[$rand_key];
         }
         if ($get_insult != '') {
             global $SITE_INFO;
             $insult_pt_topic_post = do_lang('INSULT_EXPLANATION', get_site_name(), $get_insult, $insult_points);
             $subject = do_lang('INSULT_PT_TOPIC', $GLOBALS['FORUM_DRIVER']->get_username($selected_member2), $GLOBALS['FORUM_DRIVER']->get_username($selected_member1));
             require_code('ocf_topics_action');
             $topic_id = ocf_make_topic(NULL, $subject, '', 1, 1, 0, 0, 0, $selected_member2, $selected_member1, true, 0, NULL, '');
             require_code('ocf_posts_action');
             $post_id = ocf_make_post($topic_id, $subject, $insult_pt_topic_post, 0, true, 1, 0, do_lang('SYSTEM'), NULL, NULL, $GLOBALS['FORUM_DRIVER']->get_guest_id(), NULL, NULL, NULL, false, true, NULL, true, $subject, 0, NULL, true, true, true);
             require_code('ocf_topics_action2');
             send_pt_notification($post_id, $subject, $topic_id, $selected_member2, $selected_member1);
         }
     }
 }
Example #8
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 (get_forum_type() != 'ocf') {
         return NULL;
     }
     if (!has_actual_page_access(get_member(), 'forumview')) {
         return NULL;
     }
     if (is_guest()) {
         return NULL;
     }
     $condition = 'l_time<t_cache_last_time OR (l_time IS NULL AND t_cache_last_time>' . strval(time() - 60 * 60 * 24 * intval(get_option('post_history_days'))) . ')';
     $query = ' FROM ' . $GLOBALS['FORUM_DB']->get_table_prefix() . 'f_topics top LEFT JOIN ' . $GLOBALS['FORUM_DB']->get_table_prefix() . 'f_read_logs l ON (top.id=l.l_topic_id AND l.l_member_id=' . strval((int) get_member()) . ') LEFT JOIN ' . $GLOBALS['FORUM_DB']->get_table_prefix() . 'translate t ON ' . db_string_equal_to('language', user_lang()) . ' AND top.t_cache_first_post=t.id WHERE (' . $condition . ') AND t_forum_id IS NOT NULL ' . (!has_specific_permission(get_member(), 'see_unvalidated') ? ' AND t_validated=1 ' : '') . ' ORDER BY t_cache_last_time DESC';
     $rows = $GLOBALS['FORUM_DB']->query('SELECT *,top.id AS t_id ' . $query, $max);
     $categories = 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'));
     $content = new ocp_tempcode();
     foreach ($rows as $row) {
         if ((!is_null($row['t_forum_id']) || $row['t_pt_to'] == get_member()) && has_category_access(get_member(), 'forums', strval($row['t_forum_id']))) {
             $id = strval($row['id']);
             $author = $row['t_cache_first_username'];
             $news_date = date($date_string, $row['t_cache_first_time']);
             $edit_date = date($date_string, $row['t_cache_last_time']);
             if ($edit_date == $news_date) {
                 $edit_date = '';
             }
             $news_title = xmlentities($row['t_cache_first_title']);
             $_summary = get_translated_tempcode($row['t_cache_first_post'], $GLOBALS['FORUM_DB']);
             $summary = xmlentities($_summary->evaluate());
             $news = '';
             $category = array_key_exists($row['t_forum_id'], $categories) ? $categories[$row['t_forum_id']] : do_lang('NA');
             $category_raw = strval($row['t_forum_id']);
             $view_url = build_url(array('page' => 'topicview', 'id' => $row['t_id']), get_module_zone('topicview'));
             if ($prefix == 'RSS_') {
                 $if_comments = do_template('RSS_ENTRY_COMMENTS', array('COMMENT_URL' => $view_url, 'ID' => strval($row['t_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)));
         }
     }
     require_lang('ocf');
     return array($content, do_lang('TOPICS_UNREAD'));
 }
Example #9
0
/**
 * Write a text file, using the _custom system
 *
 * @param  string				The file name (without .txt)
 * @param  ?LANGUAGE_NAME	The language to write for (NULL: none) (blank: search)
 * @param  string				The data to write
 */
function write_text_file($codename, $lang, $out)
{
    $xpath = _find_text_file_path($codename, $lang);
    if ($xpath == '') {
        $xpath = get_file_base() . '/text/' . user_lang() . '/' . $codename . '.txt';
    }
    $path = str_replace(get_file_base() . '/text/', get_custom_file_base() . '/text_custom/', $xpath);
    $myfile = @fopen($path, 'wt');
    if ($myfile === false) {
        intelligent_write_error($path);
    }
    $out = unixify_line_format($out);
    if (fwrite($myfile, $out) < strlen($out)) {
        warn_exit(do_lang_tempcode('COULD_NOT_SAVE_FILE'));
    }
    fclose($myfile);
    fix_permissions($path);
    sync_file($path);
}
Example #10
0
/**
 * Add to the newsletter, in the simplest way.
 *
 * @param  EMAIL				The email address of the subscriber
 * @param  integer			The interest level
 * @range  1 4
 * @param  ?LANGUAGE_NAME	The language (NULL: users)
 * @param  boolean			Whether to require a confirmation mail
 * @param  ?AUTO_LINK		The newsletter to join (NULL: the first)
 * @param  string				Subscribers forename
 * @param  string				Subscribers surname
 * @return string				Newsletter password
 */
function basic_newsletter_join($email, $interest_level = 4, $lang = NULL, $get_confirm_mail = false, $newsletter_id = NULL, $forename = '', $surname = '')
{
    if (is_null($lang)) {
        $lang = user_lang();
    }
    if (is_null($newsletter_id)) {
        $newsletter_id = db_get_first_id();
    }
    $password = get_rand_password();
    $code_confirm = $get_confirm_mail ? mt_rand(1, 9999999) : 0;
    $test = $GLOBALS['SITE_DB']->query_value_null_ok('newsletter_subscribe', 'the_level', array('newsletter_id' => $newsletter_id, 'email' => $email));
    if ($test === 0) {
        $GLOBALS['SITE_DB']->query_delete('newsletter_subscribe', array('newsletter_id' => $newsletter_id, 'email' => $email), '', 1);
        $test = NULL;
    }
    if (is_null($test)) {
        require_lang('newsletter');
        $test = $GLOBALS['SITE_DB']->query_value_null_ok('newsletter', 'email', array('email' => $email));
        if (is_null($test)) {
            $salt = produce_salt();
            $GLOBALS['SITE_DB']->query_insert('newsletter', array('n_forename' => $forename, 'n_surname' => $surname, 'join_time' => time(), 'email' => $email, 'code_confirm' => $code_confirm, 'pass_salt' => $salt, 'the_password' => md5($password . $salt), 'language' => $lang), false, true);
            // race condition
            if ($get_confirm_mail) {
                $_url = build_url(array('page' => 'newsletter', 'type' => 'confirm', 'email' => $email, 'confirm' => $code_confirm), get_module_zone('newsletter'));
                $url = $_url->evaluate();
                $message = do_lang('NEWSLETTER_SIGNUP_TEXT', comcode_escape($url), comcode_escape($password), array($forename, $surname, $email, get_site_name()), $lang);
                require_code('mail');
                mail_wrap(do_lang('NEWSLETTER_SIGNUP', NULL, NULL, NULL, $lang), $message, array($email));
            }
        } else {
            $GLOBALS['SITE_DB']->query_update('newsletter', array('join_time' => time()), array('email' => $email), '', 1);
            $password = '';
        }
        $GLOBALS['SITE_DB']->query_insert('newsletter_subscribe', array('newsletter_id' => $newsletter_id, 'the_level' => $interest_level, 'email' => $email), false, true);
        // race condition
        return $password;
    }
    return do_lang('NA');
}
Example #11
0
/**
 * List all the multi moderations that may be used in a certain forum.
 *
 * @param  ?AUTO_LINK	The forum we are listing for (NULL: private topics).
 * @return array 			List of multi moderations.
 */
function ocf_list_multi_moderations($forum_id)
{
    if (!addon_installed('ocf_multi_moderations')) {
        return array();
    }
    if (is_null($forum_id)) {
        return array();
    }
    $rows = $GLOBALS['FORUM_DB']->query_select('f_multi_moderations m LEFT JOIN ' . $GLOBALS['FORUM_DB']->get_table_prefix() . 'translate t ON ' . db_string_equal_to('language', user_lang()) . ' AND m.mm_name=t.id', array('mm_forum_multi_code', 'm.id', 'm.mm_name', 'text_original AS _mm_name'), NULL, 'ORDER BY text_original');
    $out = array();
    if (count($rows) == 0) {
        return $out;
    }
    $lots_of_forums = $GLOBALS['FORUM_DB']->query_value('f_forums', 'COUNT(*)') > 200;
    if (!$lots_of_forums) {
        $all_forums = collapse_2d_complexity('id', 'f_parent_forum', $GLOBALS['FORUM_DB']->query_select('f_forums', array('id', 'f_parent_forum')));
    }
    foreach ($rows as $row) {
        if ($GLOBALS['RECORD_LANG_STRINGS_CONTENT'] || is_null($row['_mm_name'])) {
            $row['_mm_name'] = get_translated_text($row['mm_name'], $GLOBALS['FORUM_DB']);
        }
        require_code('ocfiltering');
        if ($lots_of_forums) {
            $sql = ocfilter_to_sqlfragment($row['mm_forum_multi_code'], 'id', 'f_forums', 'f_parent_forum', 'f_parent_forum', 'id', true, true, $GLOBALS['FORUM_DB']);
            if (!is_null($GLOBALS['FORUM_DB']->query_value_null_ok_full('SELECT id FROM ' . $GLOBALS['FORUM_DB']->get_table_prefix() . 'f_forums WHERE id=' . strval($forum_id) . ' AND (' . $sql . ')'))) {
                $out[$row['id']] = $row['_mm_name'];
            }
        } else {
            $idlist = ocfilter_to_idlist_using_memory($row['mm_forum_multi_code'], $all_forums, 'f_forums', 'f_parent_forum', 'f_parent_forum', 'id', true, true, $GLOBALS['FORUM_DB']);
            if (in_array($forum_id, $idlist)) {
                $out[$row['id']] = $row['_mm_name'];
            }
        }
    }
    return $out;
}
Example #12
0
 /**
  * Get the products handled by this eCommerce hook.
  *
  * IMPORTANT NOTE TO PROGRAMMERS: This function may depend only on the database, and not on get_member() or any GET/POST values.
  *  Such dependencies will break IPN, which works via a Guest and no dependable environment variables. It would also break manual transactions from the Admin Zone.
  *
  * @param  boolean	Whether to make sure the language for item_name is the site default language (crucial for when we read/go to third-party sales systems and use the item_name as a key).
  * @param  ?ID_TEXT	Product being searched for (NULL: none).
  * @param  boolean 	Whether $search refers to the product name rather than the product_id.
  * @return array		A map of product name to list of product details.
  */
 function get_products($site_lang = false, $search = NULL, $search_titles_not_ids = false)
 {
     $products = array();
     require_lang('shopping');
     if (function_exists('set_time_limit')) {
         @set_time_limit(0);
     }
     if (!is_null($search)) {
         $where = '1=1';
         if (!$search_titles_not_ids) {
             $l = do_lang('CART_ORDER', '', NULL, NULL, $site_lang ? get_site_default_lang() : user_lang());
             if (substr($search, 0, strlen($l)) != $l) {
                 return array();
             }
             $where .= ' AND id=' . strval(intval(substr($search, strlen($l))));
         }
     } else {
         $where = '(' . db_string_equal_to('order_status', 'ORDER_STATUS_awaiting_payment') . ' OR ' . db_string_equal_to('order_status', 'ORDER_STATUS_payment_received') . ')';
     }
     if (is_null($search)) {
         $count = $GLOBALS['SITE_DB']->query_value_null_ok_full('SELECT COUNT(*) FROM ' . get_table_prefix() . 'shopping_order WHERE ' . $where);
         if ($count > 50) {
             return array();
         }
         // Too many to list
     }
     $start = 0;
     do {
         $orders = $GLOBALS['SITE_DB']->query('SELECT id,tot_price FROM ' . get_table_prefix() . 'shopping_order WHERE ' . $where, 500);
         foreach ($orders as $order) {
             $products[do_lang('CART_ORDER', strval($order['id']), NULL, NULL, $site_lang ? get_site_default_lang() : user_lang())] = array(PRODUCT_ORDERS, $order['tot_price'], 'handle_product_orders', array(), do_lang('CART_ORDER', strval($order['id']), NULL, NULL, $site_lang ? get_site_default_lang() : user_lang()));
         }
         $start += 500;
     } while (count($orders) == 500);
     return $products;
 }
Example #13
0
 /**
  * Run the checks
  */
 function run_tool()
 {
     $this->check_table_flash_bbcodes(POSTS_TABLE, 'post_id', 'post_text', 'bbcode_uid', 'bbcode_bitfield');
     $this->check_table_flash_bbcodes(PRIVMSGS_TABLE, 'msg_id', 'message_text', 'bbcode_uid', 'bbcode_bitfield');
     $this->check_table_flash_bbcodes(USERS_TABLE, 'user_id', 'user_sig', 'user_sig_bbcode_uid', 'user_sig_bbcode_bitfield');
     // Not checked atm
     //		check_table_flash_bbcodes(FORUMS_TABLE, 'forum_id', 'forum_desc', 'forum_desc_uid', 'forum_desc_bitfield');
     //		check_table_flash_bbcodes(FORUMS_TABLE, 'forum_id', 'forum_rules', 'forum_rules_uid', 'forum_rules_bitfield');
     //		check_table_flash_bbcodes(GROUPS_TABLE, 'group_id', 'group_desc', 'group_desc_uid', 'group_desc_bitfield');
     // Nothing found
     if (empty($this->_vulnerable)) {
         trigger_error('FLASH_CHECKER_NO_FOUND');
     }
     // Here we'll create the cache files the reparse BBCode tool expects so
     // the tool can be run straight away
     global $cache;
     if (!empty($this->_vulnerable[POSTS_TABLE])) {
         $cache->put('_stk_reparse_posts', implode(',', $this->_vulnerable[POSTS_TABLE]));
     }
     if (!empty($this->_vulnerable[PRIVMSGS_TABLE])) {
         $cache->put('_stk_reparse_pms', implode(',', $this->_vulnerable[PRIVMSGS_TABLE]));
     }
     trigger_error(user_lang('FLASH_CHECKER_FOUND', append_sid(STK_INDEX, array('c' => 'admin', 't' => 'reparse_bbcode', 'submit' => true))));
 }
Example #14
0
/**
 * Show the point transactions a member has had.
 *
 * @param  ID_TEXT		The type of transactions we are looking for
 * @set    from to
 * @param  MEMBER			Who we are looking at transactions for
 * @param  MEMBER			Who we are looking at transactions using the account of
 * @return tempcode		The UI
 */
function points_get_transactions($type, $member_id_of, $member_id_viewing)
{
    $where = array('gift_' . $type => $member_id_of);
    if ($type == 'from') {
        $where['anonymous'] = 0;
    }
    $start = get_param_integer('gift_start_' . $type, 0);
    $max = get_param_integer('gift_max_' . $type, 10);
    $sortables = array('date_and_time' => do_lang_tempcode('DATE'), 'amount' => do_lang_tempcode('AMOUNT'));
    $test = explode(' ', get_param('gift_sort_' . $type, 'date_and_time DESC'));
    if (count($test) == 1) {
        $test[1] = 'DESC';
    }
    list($sortable, $sort_order) = $test;
    if (strtoupper($sort_order) != 'ASC' && strtoupper($sort_order) != 'DESC' || !array_key_exists($sortable, $sortables)) {
        log_hack_attack_and_exit('ORDERBY_HACK');
    }
    global $NON_CANONICAL_PARAMS;
    $NON_CANONICAL_PARAMS[] = 'gift_sort_' . $type;
    $NON_CANONICAL_PARAMS[] = 'gift_start_' . $type;
    $max_rows = $GLOBALS['SITE_DB']->query_value('gifts', 'COUNT(*)', $where);
    $rows = $GLOBALS['SITE_DB']->query_select('gifts g LEFT JOIN ' . $GLOBALS['SITE_DB']->get_table_prefix() . 'translate t ON ' . db_string_equal_to('language', user_lang()) . ' AND t.id=g.reason', array('*'), $where, 'ORDER BY ' . $sortable . ' ' . $sort_order, $max, $start);
    $out = new ocp_tempcode();
    $viewing_name = $GLOBALS['FORUM_DRIVER']->get_username($member_id_of);
    if (is_null($viewing_name)) {
        $viewing_name = do_lang('UNKNOWN');
    }
    require_code('templates_results_table');
    $fields_title = results_field_title(array(do_lang_tempcode('DATE'), do_lang_tempcode('AMOUNT'), do_lang_tempcode('FROM'), do_lang_tempcode('TO'), do_lang_tempcode('REASON')), $sortables, 'gift_sort_' . $type, $sortable . ' ' . $sort_order);
    foreach ($rows as $myrow) {
        if ($myrow['anonymous'] == 1 && $type == 'from') {
            continue;
        }
        // Their name
        $fromname = is_guest($myrow['gift_from']) ? get_site_name() : $GLOBALS['FORUM_DRIVER']->get_username($myrow['gift_from']);
        $toname = $GLOBALS['FORUM_DRIVER']->get_username($myrow['gift_to']);
        if (is_null($fromname)) {
            $fromname = do_lang('UNKNOWN');
        }
        if ($myrow['anonymous'] == 1 && !is_guest($myrow['gift_from'])) {
            if (!has_specific_permission($member_id_viewing, 'trace_anonymous_gifts')) {
                $_fromname = do_lang_tempcode('ANON');
            } else {
                $_fromname = hyperlink(build_url(array('page' => 'points', 'type' => 'member', 'id' => $myrow['gift_from']), get_module_zone('points')), do_lang_tempcode('ANON'), false, false, escape_html($fromname));
            }
        } else {
            $_fromname = is_guest($myrow['gift_from']) ? make_string_tempcode(escape_html($fromname)) : hyperlink(build_url(array('page' => 'points', 'type' => 'member', 'id' => $myrow['gift_from']), get_module_zone('points')), escape_html($fromname), false, false, do_lang_tempcode('VIEW_POINTS'));
        }
        $_toname = hyperlink(build_url(array('page' => 'points', 'type' => 'member', 'id' => $myrow['gift_to']), get_module_zone('points')), escape_html($toname), false, false, do_lang_tempcode('VIEW_POINTS'));
        $date = get_timezoned_date($myrow['date_and_time']);
        $amount = $myrow['amount'];
        if (get_page_name() != 'search' && array_key_exists('text_parsed', $myrow) && !is_null($myrow['text_parsed']) && $myrow['text_parsed'] != '' && $myrow['reason'] != 0) {
            $reason = new ocp_tempcode();
            if (!$reason->from_assembly($myrow['text_parsed'], true)) {
                $reason = get_translated_tempcode($myrow['reason']);
            }
        } else {
            $reason = get_translated_tempcode($myrow['reason']);
        }
        $out->attach(results_entry(array(escape_html($date), escape_html(integer_format($amount)), $_fromname, $_toname, $reason)));
    }
    $out = results_table(do_lang_tempcode('_POINTS', escape_html($viewing_name)), $start, 'gift_start_' . $type, $max, 'gift_max_' . $type, $max_rows, $fields_title, $out, $sortables, $sortable, $sort_order, 'gift_sort_' . $type, NULL, NULL, NULL, 8, 'gfhfghtrhhjghgfhfgf', false, 'tab__points');
    if ($type == 'to') {
        $title = do_lang_tempcode('POINTS_TO');
    } else {
        $title = do_lang_tempcode('POINTS_FROM');
    }
    return do_template('POINTS_TRANSACTIONS_WRAP', array('_GUID' => 'f19e3eedeb0b8bf398251b24e8389723', 'CONTENT' => $out, 'TITLE' => $title));
}
Example #15
0
 /**
  * Standard modular new-style deep page-link finder function (does not return the main entry-points).
  *
  * @param  string  	Callback function to send discovered page-links to.
  * @param  MEMBER		The member we are finding stuff for (we only find what the member can view).
  * @param  integer	Code for how deep we are tunnelling down, in terms of whether we are getting entries as well as categories.
  * @param  string		Stub used to create page-links. This is passed in because we don't want to assume a zone or page name within this function.
  */
 function get_sitemap_pagelinks($callback, $member_id, $depth, $pagelink_stub)
 {
     // Entries
     if ($depth >= DEPTH__ENTRIES) {
         $rows = $GLOBALS['SITE_DB']->query_select('iotd c LEFT JOIN ' . get_table_prefix() . 'translate t ON ' . db_string_equal_to('language', user_lang()) . ' AND t.id=c.i_title', array('c.i_title', 'c.id', 't.text_original AS title', 'add_date', 'edit_date'), array('used' => 1));
         foreach ($rows as $row) {
             if (is_null($row['title'])) {
                 $row['title'] = get_translated_text($row['i_title']);
             }
             $pagelink = $pagelink_stub . 'view:' . strval($row['id']);
             call_user_func_array($callback, array($pagelink, $pagelink_stub . 'misc', $row['add_date'], $row['edit_date'], 0.2, $row['title']));
             // Callback
         }
     }
 }
Example #16
0
 /**
  * Get the products handled by this eCommerce hook.
  *
  * IMPORTANT NOTE TO PROGRAMMERS: This function may depend only on the database, and not on get_member() or any GET/POST values.
  *  Such dependencies will break IPN, which works via a Guest and no dependable environment variables. It would also break manual transactions from the Admin Zone.
  *
  * @param  boolean	Whether to make sure the language for item_name is the site default language (crucial for when we read/go to third-party sales systems and use the item_name as a key).
  * @return array		A map of product name to list of product details.
  */
 function get_products($site_lang = false)
 {
     $products = array('WORK' => array(PRODUCT_INVOICE, '?', '', array(), do_lang('CUSTOM_PRODUCT_WORK', NULL, NULL, NULL, $site_lang ? get_site_default_lang() : user_lang())));
     return $products;
 }
Example #17
0
/**
 * First installation step.
 *
 * @return tempcode		Progress report / UI
 */
function step_1()
{
    $warnings = new ocp_tempcode();
    global $MYFILE;
    if (!@is_resource($MYFILE)) {
        if (array_key_exists('skip_disk_checks', $_GET) || file_exists(get_file_base() . '/.git')) {
            if (!file_exists(get_file_base() . '/.git')) {
                $warnings->attach(do_template('INSTALLER_WARNING', array('MESSAGE' => do_lang_tempcode('INSTALL_SLOW_SERVER'))));
            }
        } else {
            $files = @unserialize(file_get_contents(get_file_base() . '/data/files.dat', FILE_TEXT));
            if ($files !== false && !file_exists(get_file_base() . '/.svn')) {
                $missing = array();
                $corrupt = array();
                foreach ($files as $file => $file_info) {
                    if ($file == 'data_custom/errorlog.php') {
                        continue;
                    }
                    if ($file == 'ocp_sitemap.xml') {
                        continue;
                    }
                    if ($file == 'data_custom/spelling/output.log') {
                        continue;
                    }
                    if ($file == 'info.php') {
                        continue;
                    }
                    if ($file == 'themes/map.ini') {
                        continue;
                    }
                    if ($file == 'sources/version.php') {
                        continue;
                    }
                    if ($file == 'data_custom/functions.dat') {
                        continue;
                    }
                    if (strpos($file, '/pagepics/') !== false) {
                        continue;
                    }
                    if ($file == 'data/files.dat') {
                        continue;
                    }
                    if ($file == 'data/files_previous.dat') {
                        continue;
                    }
                    if ($file == 'data/modules/admin_stats/IP_Country.txt') {
                        continue;
                    }
                    if ($file == 'data/areaedit/plugins/SpellChecker/aspell/bin/aspell-15.dll') {
                        continue;
                    }
                    if ($file == 'data/areaedit/plugins/SpellChecker/aspell/bin/en-only.rws') {
                        continue;
                    }
                    if (substr($file, -4) == '.ttf') {
                        continue;
                    }
                    $contents = @file_get_contents(get_file_base() . '/' . $file, FILE_BINARY);
                    if (!file_exists(get_file_base() . '/' . $file)) {
                        $missing[] = $file;
                    } elseif ($contents !== false && sprintf('%u', crc32(preg_replace('#[\\r\\n\\t ]#', '', $contents))) != $file_info[0]) {
                        $corrupt[] = $file;
                    }
                }
                if (count($missing) > 4) {
                    $warnings->attach(do_template('INSTALLER_WARNING_LONG', array('_GUID' => '515c2f26a5415224f3c09b2429a78a5f', 'FILES' => $missing, 'MESSAGE' => do_lang_tempcode('_MISSING_INSTALLATION_FILE', integer_format(count($missing))))));
                } else {
                    foreach ($missing as $file) {
                        $warnings->attach(do_template('INSTALLER_WARNING', array('MESSAGE' => do_lang_tempcode('MISSING_INSTALLATION_FILE', $file))));
                    }
                }
                if (count($corrupt) > 4) {
                    $warnings->attach(do_template('INSTALLER_WARNING_LONG', array('_GUID' => 'f8958458d76bd4f6d146d3fe59132a02', 'FILES' => $corrupt, 'MESSAGE' => do_lang_tempcode('_CORRUPT_INSTALLATION_FILE', integer_format(count($corrupt))))));
                } else {
                    foreach ($corrupt as $file) {
                        $warnings->attach(do_template('INSTALLER_WARNING', array('MESSAGE' => do_lang_tempcode('CORRUPT_INSTALLATION_FILE', $file))));
                    }
                }
            }
        }
    }
    $test = ini_get('mbstring.func_overload');
    if ($test !== false && $test !== '' && $test !== '0') {
        $warnings->attach(do_template('INSTALLER_WARNING', array('MESSAGE' => do_lang_tempcode('WARNING_MBSTRING_FUNC_OVERLOAD'))));
    }
    $disk_space = @disk_free_space(get_file_base());
    if (is_integer($disk_space) && $disk_space < 25 * 1024 * 1024) {
        $warnings->attach(do_template('INSTALLER_WARNING', array('MESSAGE' => do_lang_tempcode('WARNING_DISK_SPACE'))));
    }
    if (!function_exists('zip_open') && !@file_exists('/usr/bin/unzip')) {
        $warnings->attach(do_template('INSTALLER_WARNING', array('MESSAGE' => do_lang_tempcode('NO_ZIP_ON_SERVER'))));
    }
    if (!function_exists('imagecreatefromstring')) {
        $warnings->attach(do_template('INSTALLER_WARNING', array('MESSAGE' => do_lang_tempcode('NO_GD_ON_SERVER'))));
    }
    if (!function_exists('xml_parser_create')) {
        $warnings->attach(do_template('INSTALLER_WARNING', array('MESSAGE' => do_lang_tempcode('NO_XML_ON_SERVER'))));
    }
    if (function_exists('memory_get_usage') && @ini_get('memory_limit') != '' && @ini_get('memory_limit') != '-1' && @ini_get('memory_limit') != '0' && intval(trim(str_replace('M', '', @ini_get('memory_limit')))) < 16) {
        $warnings->attach(do_template('INSTALLER_WARNING', array('MESSAGE' => do_lang_tempcode('LOW_MEMORY_LIMIT'))));
    }
    if (is_numeric(@ini_get('max_execution_time')) && intval(@ini_get('max_execution_time')) > 0 && intval(@ini_get('max_execution_time')) < 10 && str_replace(array('on', 'true', 'yes'), array('1', '1', '1'), strtolower(ini_get('safe_mode'))) == '1') {
        $warnings->attach(do_template('INSTALLER_WARNING', array('MESSAGE' => do_lang_tempcode('WARNING_MAX_EXECUTION_TIME'))));
    }
    if (is_numeric(@ini_get('max_input_time')) && intval(@ini_get('max_input_time')) > 0 && intval(@ini_get('max_input_time')) < 60 && str_replace(array('on', 'true', 'yes'), array('1', '1', '1'), strtolower(ini_get('safe_mode'))) == '1') {
        $warnings->attach(do_template('INSTALLER_WARNING', array('MESSAGE' => do_lang_tempcode('WARNING_MAX_INPUT_TIME'))));
    }
    $needed_functions = <<<END
\t\tabs addslashes array_count_values array_diff array_flip array_key_exists array_keys
\t\tarray_intersect array_merge array_pop array_push array_reverse array_search array_shift
\t\tarray_slice array_splice array_unique array_values arsort asort base64_decode base64_encode
\t\tcall_user_func ceil chdir checkdate chmod chr chunk_split class_exists clearstatcache closedir
\t\tconstant copy cos count crypt current date dechex decoct define defined dirname disk_free_space
\t\tdeg2rad error_log error_reporting eval exit explode fclose feof fgets file file_exists
\t\tfile_get_contents filectime filegroup filemtime fileowner fileperms filesize floatval floor
\t\tget_defined_vars get_declared_classes get_defined_functions fopen fread fseek ftell
\t\tfunction_exists fwrite gd_info get_class get_html_translation_table get_magic_quotes_gpc getcwd
\t\tgetdate getenv gmdate gzclose gzopen gzwrite header headers_sent hexdec highlight_string
\t\thtmlentities imagealphablending imagecolorallocate imagecolortransparent imagecopy
\t\timagecopyresampled imagecopyresized imagecreate imagecreatefromstring imagecreatefrompng
\t\timagecreatefromjpeg imagecreatetruecolor imagecolorat imagecolorsforindex
\t\timagedestroy imagefill imagefontheight imagefontwidth imagejpeg imagepng imagesavealpha
\t\timagesetpixel imagestring imagesx imagesy imagestringup imagettfbbox imagettftext imagetypes
\t\timagearc imagefilledarc imagecopymergegray imageline imageellipse imagefilledellipse
\t\timagechar imagefilledpolygon imagepolygon imagefilledrectangle imagerectangle imagefilltoborder
\t\timagegammacorrect imageinterlace imageloadfont imagepalettecopy imagesetbrush
\t\timagesetstyle imagesetthickness imagesettile imagetruecolortopalette
\t\timagecharup imagecolorclosest imagecolorclosestalpha imagecolorclosesthwb
\t\timagecolordeallocate imagecolorexact imagecolorexactalpha imagecolorresolve
\t\timagecolorresolvealpha imagecolorset imagecolorstotal imagecopymerge
\t\timplode in_array include include_once ini_get ini_set intval is_a is_array is_bool is_dir is_file is_float
\t\tis_integer is_null is_numeric is_object is_readable is_resource is_string is_uploaded_file is_writable
\t\tisset krsort ksort localeconv ltrim mail max md5 method_exists microtime min
\t\tmkdir mktime move_uploaded_file mt_getrandmax mt_rand mt_srand number_format ob_end_clean
\t\tob_end_flush ob_get_contents ob_start octdec opendir ord pack parse_url pathinfo phpinfo phpversion
\t\tpreg_match preg_grep preg_match_all
\t\tpreg_replace preg_replace_callback preg_split print_r putenv rawurldecode
\t\trawurlencode readdir realpath register_shutdown_function rename require require_once reset rmdir
\t\tround rsort rtrim serialize set_error_handler set_magic_quotes_runtime
\t\tsetcookie setlocale sha1 sin sort sprintf srand str_pad str_repeat str_replace
\t\tstrcmp strftime strip_tags stripslashes strlen strpos strrpos strstr strtok strtolower
\t\tstrtotime strtoupper strtr strval substr substr_count tempnam time trim trigger_error
\t\tuasort ucfirst ucwords uksort uniqid unlink unserialize unset urldecode urlencode usort
\t\tutf8_decode utf8_encode wordwrap xml_error_string xml_get_current_byte_index xml_get_current_line_number
\t\txml_get_error_code xml_parse xml_parser_create_ns xml_parser_free xml_parser_set_option
\t\txml_set_character_data_handler xml_set_element_handler xml_set_end_namespace_decl_handler xml_set_object
\t\txml_set_start_namespace_decl_handler xmlrpc_encode_request acos array_rand array_unshift asin assert
\t\tassert_options atan base_convert basename bin2hex bindec call_user_func_array
\t\tconnection_aborted connection_status crc32 decbin each empty fflush fileatime flock flush
\t\tget_current_user gethostbyaddr getrandmax gmmktime gmstrftime ip2long
\t\tlevenshtein log log10 long2ip md5_file money_format pow preg_quote prev rad2deg
\t\trange readfile shuffle similar_text sqrt strcasecmp strcoll strcspn stristr strnatcasecmp
\t\tstrnatcmp strncasecmp strncmp strrchr strrev strspn substr_replace tan unpack version_compare
\t\tgettype zend_version zend_logo_guid xml_get_current_column_number xml_parser_create
\t\txml_parser_get_option xml_parse_into_struct xml_set_default_handler xml_set_external_entity_ref_handler
\t\txml_set_notation_decl_handler xml_set_processing_instruction_handler xml_set_unparsed_entity_decl_handler
\t\tvar_dump vprintf vsprintf touch tanh sinh sleep soundex sscanf stripcslashes
\t\treadgzfile restore_error_handler rewind rewinddir quoted_printable_decode
\t\tquotemeta exp ezmlm_hash lcg_value localtime addcslashes
\t\tarray_filter array_map array_merge_recursive array_multisort array_pad array_reduce array_walk
\t\tatan2 fgetc fgetcsv fgetss filetype fscanf fstat ftp_cdup ftp_fget ftp_get ftp_pasv
\t\tftp_pwd ftp_rawlist ftp_systype ftruncate func_get_arg func_get_args func_num_args
\t\tparse_ini_file parse_str is_executable
\t\tis_scalar is_subclass_of metaphone natcasesort natsort nl2br ob_get_length ob_gzhandler
\t\tob_iconv_handler ob_implicit_flush php_sapi_name
\t\tphp_uname printf convert_cyr_string cosh count_chars
\t\tdisk_total_space gethostbynamel getimagesize getlastmod getmypid getmyuid
\t\tgettimeofday get_cfg_var get_magic_quotes_runtime get_meta_tags get_parent_class
\t\tget_included_files get_resource_type gzcompress gzdeflate gzencode gzfile gzinflate
\t\tgzuncompress hypot ignore_user_abort
\t\tgzclose gzopen gzwrite ftp_chdir ftp_close ftp_connect ftp_delete ftp_fput
\t\tftp_login ftp_mkdir ftp_nlist ftp_put ftp_rename ftp_rmdir ftp_site ftp_size
END;
    foreach (preg_split('#\\s+#', $needed_functions) as $function) {
        if (trim($function) == '') {
            continue;
        }
        if (@preg_match('#(\\s|,|^)' . str_replace('#', '\\#', preg_quote($function)) . '(\\s|$|,)#', strtolower(@ini_get('disable_functions') . ',' . ini_get('suhosin.executor.func.blacklist') . ',' . ini_get('suhosin.executor.include.blacklist') . ',' . ini_get('suhosin.executor.eval.blacklist'))) != 0) {
            $warnings->attach(do_template('INSTALLER_WARNING', array('MESSAGE' => do_lang_tempcode('DISABLED_FUNCTION', escape_html($function)))));
        }
    }
    /*client check is wrong if (function_exists('mysqli_get_client_version'))
    	{
    		$x=float_to_raw_string(floatval(mysqli_get_client_version())/10000.0);
    		if (version_compare($x,'4.1.0','<'))
    			$warnings->attach(do_template('INSTALLER_WARNING',array('MESSAGE'=>do_lang_tempcode('MYSQL_TOO_OLD'))));
    	}
    	elseif (function_exists('mysql_get_client_version'))
    	{
    		if (version_compare(mysql_get_client_version(),'4.1.0','<'))
    			$warnings->attach(do_template('INSTALLER_WARNING',array('MESSAGE'=>do_lang_tempcode('MYSQL_TOO_OLD'))));
    	}*/
    global $FILE_ARRAY;
    if (!@is_array($FILE_ARRAY)) {
        if (function_exists('posix_getuid') && strpos(@ini_get('disable_functions'), 'posix_getuid') === false && !isset($_SERVER['HTTP_X_MOSSO_DT']) && @posix_getuid() == @fileowner(get_file_base() . '/install.php')) {
            // NB: Could also be that files are owned by 'apache'/'nobody'. In these cases the users have consciously done something special and know what they're doing (they have open_basedir at least hopefully!) so we'll still consider this 'suexec'. It's too much an obscure situation.
            $warnings->attach(do_template('INSTALLER_NOTICE', array('MESSAGE' => do_lang_tempcode('SUEXEC_SERVER'))));
        } elseif (is_writable_wrap(get_file_base() . '/install.php')) {
            $warnings->attach(do_template('INSTALLER_NOTICE', array('MESSAGE' => do_lang_tempcode('RECURSIVE_SERVER'))));
        }
    }
    if (file_exists(get_file_base() . '/info.php') && !is_writable_wrap(get_file_base() . '/info.php') && !function_exists('posix_getuid') && strpos(PHP_OS, 'WIN') !== false) {
        $warnings->attach(do_template('INSTALLER_WARNING', array('MESSAGE' => do_lang_tempcode('TROUBLESOME_WINDOWS_SERVER'))));
    }
    // Some sanity checks
    if (!@is_array($FILE_ARRAY)) {
        if (file_exists(get_file_base() . '/themes/default/templates/ANCHOR.tpl') && !file_exists(get_file_base() . '/themes/default/templates/COMCODE_REAL_TABLE_CELL.tpl')) {
            warn_exit(do_lang_tempcode('CORRUPT_FILES_CROP'));
        }
        if (!file_exists(get_file_base() . '/themes/default/templates/ANCHOR.tpl') && file_exists(get_file_base() . '/themes/default/templates/anchor.tpl')) {
            warn_exit(do_lang_tempcode('CORRUPT_FILES_LOWERCASE'));
        }
        /*		if (!file_exists(get_file_base().'/themes/default/templates/ADDITIONAL.tpl')) Redundant now
        			warn_exit(do_lang_tempcode('MISSING_FILES'));*/
    }
    if (file_exists('lang_custom/langs.ini')) {
        $lookup = better_parse_ini_file(get_custom_file_base() . '/lang_custom/langs.ini');
    } else {
        $lookup = better_parse_ini_file(get_file_base() . '/lang/langs.ini');
    }
    $lang_count = array();
    $langs1 = get_dir_contents('lang');
    foreach (array_keys($langs1) as $lang) {
        if (array_key_exists($lang, $lookup)) {
            if (!array_key_exists($lang, $lang_count)) {
                $lang_count[$lang] = 0;
            }
            $files = get_dir_contents('lang/' . $lang);
            foreach (array_keys($files) as $file) {
                if (substr($file, -4) == '.ini') {
                    $lang_count[$lang] += count(better_parse_ini_file(get_file_base() . '/lang/' . $lang . '/' . $file));
                }
            }
        }
    }
    $langs2 = get_dir_contents('lang_custom');
    foreach (array_keys($langs2) as $lang) {
        if (array_key_exists($lang, $lookup)) {
            if (!array_key_exists($lang, $lang_count)) {
                $lang_count[$lang] = 0;
            }
            $files = get_dir_contents('lang_custom/' . $lang);
            foreach (array_keys($files) as $file) {
                if (substr($file, -4) == '.ini') {
                    $lang_count[$lang] += count(better_parse_ini_file(get_custom_file_base() . '/lang_custom/' . $lang . '/' . $file));
                }
            }
        }
    }
    $langs = array_merge($langs1, $langs2);
    ksort($langs);
    unset($langs['EN']);
    $langs = array_merge(array('EN' => 'lang'), $langs);
    $tlanguages = new ocp_tempcode();
    foreach (array_keys($langs) as $lang) {
        if (array_key_exists($lang, $lookup)) {
            $stub = $lang == 'EN' ? '' : ' (unofficial, ' . strval(intval(round(100.0 * $lang_count[$lang] / $lang_count['EN']))) . '% changed)';
            $entry = do_template('FORM_SCREEN_INPUT_LIST_ENTRY', array('SELECTED' => $lang == user_lang(), 'DISABLED' => false, 'NAME' => $lang, 'CLASS' => '', 'TEXT' => $lookup[$lang] . $stub));
            $tlanguages->attach($entry);
        }
    }
    $hidden = build_keep_post_fields();
    $max = strval(get_param_integer('max', 1000));
    $hidden->attach(form_input_hidden('max', $max));
    return do_template('INSTALLER_STEP_1', array('_GUID' => '83f0ca881b9f63ab9378264c6ff507a3', 'WARNINGS' => $warnings, 'HIDDEN' => $hidden, 'LANGUAGES' => $tlanguages));
}
Example #18
0
 /**
  * Directly run the script
  * @access private
  * @return void
  */
 function _run_result()
 {
     global $cache, $umil;
     // Read from teh cache
     $this->_upgrader = $cache->get('_stk_mysql_upgrader_result');
     if ($this->_upgrader === false) {
         return;
     }
     // Split up in seperate queries
     $queries = explode(';', $this->_upgrader);
     // The right query
     $step = request_var('step', 0);
     if (!empty($queries[$step])) {
         $query = trim($queries[$step]);
         $umil->db_tools->db->sql_query($query);
         meta_refresh(0, append_sid(STK_INDEX, array('c' => 'support', 't' => 'mysql_upgrader', 'run' => true, 'step' => ++$step)));
         trigger_error(user_lang('QUERY_FINISHED', $step, sizeof($queries)));
     }
     trigger_error('MYSQL_UPGRADER_SUCCESSFULL');
 }
Example #19
0
 /**
  * Assemble the current tempcode object into a single serialised (compiled) tempcode storage representation (parameters and certain symbols and not evaluated). The output of the function is language-tied.
  *
  * @param  ?LANGUAGE_NAME	The language to evaluate with (NULL: current users language)
  * @return string				The assembly result
  */
 function to_assembly($lang = NULL)
 {
     if (is_null($lang)) {
         $lang = user_lang();
     }
     // Decode all language-codes we are allowed to. Escape anything we are told to
     $count = count($this->bits);
     for ($i = 0; $i < $count; ++$i) {
         $bit =& $this->bits[$i];
         // Decode language codes
         $cant_decode = $bit[1] != TC_LANGUAGE_REFERENCE;
         if (!$cant_decode) {
             if (array_key_exists(3, $bit) && !is_null($bit[3])) {
                 foreach ($bit[3] as $decode_bit) {
                     if (is_object($decode_bit)) {
                         $cant_decode = true;
                     }
                 }
             }
         }
         if (!$cant_decode) {
             $bit[1] = TC_KNOWN;
             $bit[2] = ecv($lang, array(), TC_LANGUAGE_REFERENCE, $bit[2], is_null($bit[3]) ? array() : $bit[3]);
             $bit[3] = NULL;
         }
         // Escaping
         if (count($bit[0]) != 0 && $bit[1] == TC_KNOWN) {
             if (count($bit[0]) != 0) {
                 apply_tempcode_escaping($bit[0], $bit[2]);
             }
             $bit[0] = array();
         }
     }
     return serialize($this->bits);
 }
Example #20
0
 /**
  * Generate back link for acp pages
  */
 function adm_back_link($u_action)
 {
     return '<br /><br /><a href="' . $u_action . '">&laquo; ' . user_lang('BACK_TO_PREV') . '</a>';
 }
 /**
  * Start the cleaner
  */
 function introduction()
 {
     global $user;
     // Redirect if they selected quit
     if (isset($_POST['quit'])) {
         redirect(append_sid(STK_ROOT_PATH . 'index.' . PHP_EXT));
     }
     // Start by disabling the board
     set_config('board_disable', 1);
     set_config('board_disable_msg', user_lang('BOARD_DISABLE_REASON'));
 }
Example #22
0
 /**
  * Standard aed_module add actualiser.
  *
  * @return ID_TEXT		The entry added
  */
 function add_actualisation()
 {
     list($allow2, $allow2_groups, $disallow2, $disallow2_groups) = read_in_chat_perm_fields();
     $id = add_chatroom(post_param('c_welcome'), post_param('room_name'), $GLOBALS['FORUM_DRIVER']->get_member_from_username(post_param('room_owner')), $allow2, $allow2_groups, $disallow2, $disallow2_groups, post_param('room_lang', user_lang()));
     $this->set_permissions($id);
     return strval($id);
 }
Example #23
0
 /**
  * The UI to show the usergroup directory.
  *
  * @return tempcode		The UI
  */
 function directory()
 {
     $title = get_page_title('USERGROUPS');
     $map = has_specific_permission(get_member(), 'see_hidden_groups') ? array('g_is_private_club' => 0) : array('g_is_private_club' => 0, 'g_hidden' => 0);
     $groups = $GLOBALS['FORUM_DB']->query_select('f_groups', array('*'), $map, 'ORDER BY g_order,id');
     $staff_groups = array_merge($GLOBALS['FORUM_DRIVER']->get_super_admin_groups(), $GLOBALS['FORUM_DRIVER']->get_moderator_groups());
     foreach ($groups as $g_id => $row) {
         $groups[$g_id]['text_original'] = get_translated_text($row['g_name'], $GLOBALS['FORUM_DB']);
     }
     // Categorise
     $_staff = array();
     $_ranks = array();
     $_others = array();
     foreach ($groups as $group) {
         if ($group['id'] == 1) {
             continue;
         }
         // Don't show guest usergroup
         if (in_array($group['id'], $staff_groups)) {
             $_staff[$group['id']] = $group;
         } else {
             $_others[$group['id']] = $group;
             if (!is_null($group['g_promotion_target'])) {
                 // Are we at the start of a usergroup?
                 $found = false;
                 foreach ($groups as $group2) {
                     if ($group2['g_promotion_target'] == $group['id']) {
                         $found = true;
                         break;
                     }
                 }
                 if (!$found) {
                     $_ranks[$group['id']] = array($group['id'] => $group);
                     $next = $group['g_promotion_target'];
                     while (!is_null($next)) {
                         $found = false;
                         foreach ($groups as $group2) {
                             if ($group2['id'] == $next) {
                                 $next = $group2['g_promotion_target'];
                                 $_ranks[$group['id']][$group2['id']] = $group2;
                                 if (array_key_exists($next, $_ranks[$group['id']])) {
                                     break;
                                 }
                                 // uhoh- loop
                                 $found = true;
                                 break;
                             }
                         }
                         if (!$found) {
                             break;
                         }
                         // uhoh- either loop, or unfound usergroup
                     }
                 }
             }
         }
     }
     // Cleanup so no usergroups in rank lines are in $others
     foreach ($_ranks as $r) {
         foreach (array_keys($r) as $g_id) {
             unset($_others[$g_id]);
         }
     }
     // Generate usergroup result browsers
     require_code('templates_results_table');
     $sortables = array();
     list($sortable, $sort_order) = array('foo', 'ASC');
     //-Staff
     $start = get_param_integer('staff_start', 0);
     $max = get_param_integer('staff_max', 50);
     $max_rows = count($_staff);
     $fields_title = results_field_title(array(do_lang_tempcode('NAME'), do_lang_tempcode('COUNT_MEMBERS')), $sortables);
     $staff = new ocp_tempcode();
     $i = 0;
     foreach ($_staff as $row) {
         if ($i < $start) {
             $i++;
             continue;
         }
         if ($i > $start + $max) {
             break;
         }
         $name = $row['text_original'];
         $url = build_url(array('page' => '_SELF', 'type' => 'view', 'id' => $row['id']), '_SELF');
         $num_members = integer_format(ocf_get_group_members_raw_count($row['id'], true));
         $staff->attach(results_entry(array(hyperlink($url, escape_html($name)), escape_html($num_members))));
         $i++;
     }
     $staff = results_table(do_lang_tempcode('STAFF'), $start, 'staff_start', $max, 'staff_max', $max_rows, $fields_title, $staff, $sortables, $sortable, $sort_order, 'staff_sort', NULL, array('200'));
     //-Ranks
     $ranks = array();
     foreach ($_ranks as $g_id => $_rank) {
         $start = get_param_integer('rank_start_' . strval($g_id), 0);
         $max = get_param_integer('rank_max_' . strval($g_id), 50);
         $max_rows = count($_rank);
         $fields_title = results_field_title(array(do_lang_tempcode('NAME'), do_lang_tempcode('COUNT_MEMBERS'), do_lang_tempcode('PROMOTION_THRESHOLD')), $sortables);
         $rank = new ocp_tempcode();
         $i = 0;
         foreach ($_rank as $row) {
             if ($i < $start) {
                 $i++;
                 continue;
             }
             if ($i > $start + $max) {
                 break;
             }
             $name = $row['text_original'];
             $url = build_url(array('page' => '_SELF', 'type' => 'view', 'id' => $row['id']), '_SELF');
             $num_members = integer_format(ocf_get_group_members_raw_count($row['id'], true));
             $_p_t = $row['g_promotion_threshold'];
             $p_t = new ocp_tempcode();
             if (!is_null($_p_t) && array_key_exists($row['g_promotion_target'], $_rank)) {
                 $p_t = do_lang_tempcode('PROMOTION_TO', escape_html(integer_format($_p_t)), escape_html($_rank[$row['g_promotion_target']]['text_original']));
             }
             $rank->attach(results_entry(array(hyperlink($url, escape_html($name)), escape_html($num_members), $p_t)));
         }
         $rank = results_table(do_lang_tempcode('RANK_SETS'), $start, 'rank_start_' . strval($g_id), $max, 'rank_max_' . strval($g_id), $max_rows, $fields_title, $rank, $sortables, $sortable, $sort_order, 'rank_sort_' . strval($g_id), NULL, array('200'));
         $ranks[] = $rank;
     }
     //-Others
     $start = get_param_integer('others_start', 0);
     $max = get_param_integer('others_max', 20);
     $map = has_specific_permission(get_member(), 'see_hidden_groups') ? array('g_is_private_club' => 1) : array('g_is_private_club' => 1, 'g_hidden' => 0);
     $max_rows = count($_others);
     for ($i = 0; $i < $start; $i++) {
         array_shift($_others);
     }
     $query_max = $max - count($_others);
     $query_start = $start - $max_rows;
     if ($query_start < 0) {
         $query_max += $query_start;
         $query_start = 0;
     }
     if ($query_max < 0) {
         $query_max = 0;
     }
     $_others = array_merge($_others, $GLOBALS['FORUM_DB']->query_select('f_groups g LEFT JOIN ' . $GLOBALS['FORUM_DB']->get_table_prefix() . 'translate t ON ' . db_string_equal_to('language', user_lang()) . ' AND g.g_name=t.id', array('g.*', 'text_original'), $map, 'ORDER BY g_order,g.id', $query_max, $query_start));
     $max_rows += $GLOBALS['FORUM_DB']->query_value('f_groups g', 'COUNT(*)', $map);
     $fields_title = results_field_title(array(do_lang_tempcode('NAME'), do_lang_tempcode('COUNT_MEMBERS')), $sortables);
     $others = new ocp_tempcode();
     foreach ($_others as $row) {
         $row['text_original'] = get_translated_text($row['g_name'], $GLOBALS['FORUM_DB']);
         $name = $row['text_original'];
         $url = build_url(array('page' => '_SELF', 'type' => 'view', 'id' => $row['id']), '_SELF');
         $num_members = integer_format(ocf_get_group_members_raw_count($row['id'], true));
         $others->attach(results_entry(array(hyperlink($url, escape_html($name)), escape_html($num_members))));
     }
     $others = results_table(do_lang_tempcode('OTHER_USERGROUPS'), $start, 'others_start', $max, 'others_max', $max_rows, $fields_title, $others, $sortables, $sortable, $sort_order, 'others_sort', NULL, array('200'));
     return do_template('OCF_GROUP_DIRECTORY_SCREEN', array('_GUID' => '39aebd8fcb618c2ae45e867d0c96a4cf', 'TITLE' => $title, 'STAFF' => $staff, 'OTHERS' => $others, 'RANKS' => $ranks));
 }
Example #24
0
/**
 * Get a nice formatted XHTML list of all the children beneath the specified CEDI page. This function is recursive.
 *
 * @param  ?AUTO_LINK	The CEDI page to select by default (NULL: none)
 * @param  ?AUTO_LINK	The CEDI page to look beneath (NULL: the root)
 * @param  string			Tree built up so far, in recursion (blank: starting recursion)
 * @param  boolean		Whether to include orphaned pages in the tree
 * @param  boolean		Whether to create a compound list (gets pairs: tempcode, and comma-separated list of children)
 * @param  boolean		Whether to use titles in IDs after a ! (used on tree edit page)
 * @return mixed			Tempcode for the list / pair of tempcode and compound
 */
function cedi_show_tree($select = NULL, $id = NULL, $tree = '', $include_orphans = true, $use_compound_list = false, $ins_format = false)
{
    if (is_null($id)) {
        $id = db_get_first_id();
    }
    if ($GLOBALS['SITE_DB']->query_value('seedy_pages', 'COUNT(*)') > 1000) {
        return new ocp_tempcode();
    }
    $cedi_seen = array(db_get_first_id());
    $title = get_translated_text($GLOBALS['SITE_DB']->query_value('seedy_pages', 'title', array('id' => $id)));
    $out = _cedi_show_tree($cedi_seen, $select, $id, $tree, $title, $use_compound_list, $ins_format);
    if ($include_orphans) {
        if (!db_has_subqueries($GLOBALS['SITE_DB']->connection_read)) {
            $cedi_seen = array();
            get_cedi_page_tree($cedi_seen, is_null($id) ? NULL : intval($id));
            // To build up $cedi_seen
            $where = '';
            foreach ($cedi_seen as $seen) {
                if ($where != '') {
                    $where .= ' AND ';
                }
                $where .= 'p.id<>' . strval((int) $seen);
            }
            $orphans = $GLOBALS['SITE_DB']->query('SELECT p.id,text_original,p.title FROM ' . get_table_prefix() . 'seedy_pages p LEFT JOIN ' . get_table_prefix() . 'translate t ON ' . db_string_equal_to('language', user_lang()) . ' AND t.id=p.title WHERE ' . $where . ' ORDER BY add_date DESC', 50);
        } else {
            $orphans = $GLOBALS['SITE_DB']->query('SELECT p.id,text_original,p.title FROM ' . get_table_prefix() . 'seedy_pages p LEFT JOIN ' . get_table_prefix() . 'translate t ON ' . db_string_equal_to('language', user_lang()) . ' AND t.id=p.title WHERE p.id<>' . strval(db_get_first_id()) . ' AND NOT EXISTS(SELECT * FROM ' . get_table_prefix() . 'seedy_children WHERE child_id=p.id) ORDER BY add_date DESC', 50);
            if (count($orphans) < 50) {
                global $M_SORT_KEY;
                $M_SORT_KEY = 'text_original';
                usort($orphans, 'multi_sort');
            }
        }
        foreach ($orphans as $orphan) {
            if (!has_category_access(get_member(), 'seedy_page', strval($orphan['id']))) {
                continue;
            }
            if ($GLOBALS['RECORD_LANG_STRINGS_CONTENT'] || is_null($orphan['text_original'])) {
                $orphan['text_original'] = get_translated_text($orphan['title']);
            }
            $title = $orphan['text_original'];
            //$out->attach(form_input_list_entry(strval($orphan['id']),($select==$orphan['id']),do_template('CEDI_LIST_TREE_LINE',array('_GUID'=>'e3eb3decfac32382cdcb5b745ef0ad7e','DEPTH'=>'?','TITLE'=>$title,'ID'=>$orphan['id']))));
            //			$out.='<option value="'.$orphan['id'].'"> ? '.$title.'</option>';
            $out->attach(form_input_list_entry($ins_format ? strval($orphan['id']) . '!' . $title : strval($orphan['id']), false, do_lang('CEDI_ORPHANED') . ' > ' . $title));
        }
    }
    return $out;
}
Example #25
0
 /**
  * Handle an incoming request.
  *
  * @param  \Illuminate\Http\Request  $request
  * @param  \Closure  $next
  * @return mixed
  */
 public function handle($request, Closure $next)
 {
     // if is false exit
     if (!config('navTools.urlType')) {
         return $next($request);
     }
     if ($request->segment(1) != null) {
         if (config('navTools.urlType') == 'navTools') {
             $navToolsData = explode('-', $request->segment(1));
         } elseif (config('navTools.urlType') == 'lang' || config('navTools.urlType') == 'country') {
             $navToolsData = $request->segment(1);
         }
     } else {
         $navToolsData = [];
     }
     // routine to establish country and language variables in session, with URL data language and country
     if (config('navTools.urlType') == 'lang-country' && count($navToolsData) == 2 && in_array($navToolsData[0], config('navTools.langs')) && in_array($navToolsData[1], config('navTools.countries'))) {
         session(['userLang' => $navToolsData[0]]);
         session(['userCountry' => $navToolsData[1]]);
     } elseif (config('navTools.urlType') == 'lang' && in_array($navToolsData, config('navTools.langs'))) {
         session(['userLang' => $navToolsData]);
     } elseif (config('navTools.urlType') == 'country' && in_array($navToolsData, config('navTools.countries'))) {
         session(['userCountry' => $navToolsData]);
     } elseif ($request->cookie('userLang') != null && $request->cookie('userCountry') != null) {
         session('userLang', $request->cookie('userLang'));
         session('userCountry', $request->cookie('userCountry'));
     } elseif (session('userLang') == null || session('userCountry') == null) {
         if (config('navTools.urlType') == 'lang-country' || config('navTools.urlType') == 'lang') {
             // Routine to know language
             // get header HTTP_ACCEPT_LANGUAGE if there is this variable,
             // the bots like google don't have this variable, in this case we have to complete language data.
             if (isset($_SERVER['HTTP_ACCEPT_LANGUAGE'])) {
                 $browserLang = \Syscover\NavTools\Libraries\NavToolsLibrary::preferedLanguage(config('navTools.langs'));
                 // instantiate browser language
                 if (in_array($browserLang, config('navTools.langs'))) {
                     $lang = $browserLang;
                 } else {
                     $lang = config('app.locale');
                 }
             } else {
                 // in this case, ser default lang
                 $lang = config('app.locale');
             }
             // set user lang on session
             session(['userLang' => $lang]);
         }
         if (config('navTools.urlType') == 'lang-country' || config('navTools.urlType') == 'country') {
             // if is set locale, we get default country from locale
             if (config('navTools.urlType') == 'lang-country' || config('navTools.urlType') == 'lang') {
                 // in the case of not getting a valid country, we take the country as default language
                 $country = config('navTools.countryLang')[$lang];
             } else {
                 $country = config('navTools.defaultCountry');
             }
             session(['userCountry' => $country]);
         }
     }
     if (config('navTools.urlType') == 'lang-country' || config('navTools.urlType') == 'lang') {
         // We establish the language environment
         App::setLocale(user_lang());
     }
     return $next($request);
 }
Example #26
0
 /**
  * Standard modular new-style deep page-link finder function (does not return the main entry-points).
  *
  * @param  string  	Callback function to send discovered page-links to.
  * @param  MEMBER		The member we are finding stuff for (we only find what the member can view).
  * @param  integer	Code for how deep we are tunnelling down, in terms of whether we are getting entries as well as categories.
  * @param  string		Stub used to create page-links. This is passed in because we don't want to assume a zone or page name within this function.
  * @param  ?string	Where we're looking under (NULL: root of tree). We typically will NOT show a root node as there's often already an entry-point representing it.
  * @param  integer	Our recursion depth (used to calculate importance of page-link, used for instance by Google sitemap). Deeper is typically less important.
  * @param  ?array		Non-standard for API [extra parameter tacked on] (NULL: yet unknown). Contents of database table for performance.
  * @param  ?array		Non-standard for API [extra parameter tacked on] (NULL: yet unknown). Contents of database table for performance.
  * @param  ?array		Non-standard for API [extra parameter tacked on] (NULL: yet unknown). Contents of database table for performance.
  */
 function get_sitemap_pagelinks($callback, $member_id, $depth, $pagelink_stub, $parent_pagelink = NULL, $recurse_level = 0, $category_data = NULL, $image_data = NULL, $video_data = NULL)
 {
     // This is where we start
     if (is_null($parent_pagelink)) {
         $parent_pagelink = $pagelink_stub . ':misc';
         // This is the entry-point we're under
         $parent_attributes = array('id' => 'root');
     } else {
         list(, $parent_attributes, ) = page_link_decode($parent_pagelink);
     }
     // We read in all data for efficiency
     if (is_null($category_data)) {
         $category_data_count = $GLOBALS['SITE_DB']->query_value('galleries', 'COUNT(*)');
         if ($category_data_count > 2000) {
             $category_data = $GLOBALS['SITE_DB']->query('SELECT name AS id,name AS title,parent_id,add_date FROM ' . get_table_prefix() . 'galleries WHERE name NOT LIKE \'' . db_encode_like('member\\_%') . '\'');
         } else {
             $category_data = $GLOBALS['SITE_DB']->query_select('galleries', array('name AS id', 'name AS title', 'parent_id', 'add_date'));
         }
     }
     if (is_null($image_data)) {
         $image_data_count = $GLOBALS['SITE_DB']->query_value('images', 'COUNT(*)');
         $image_data = $image_data_count > 2000 ? array() : $GLOBALS['SITE_DB']->query_select('images d LEFT JOIN ' . get_table_prefix() . 'translate t ON ' . db_string_equal_to('language', user_lang()) . ' AND t.id=d.title', array('d.title', 'd.id', 't.text_original AS ntitle', 'cat AS category_id', 'add_date', 'edit_date'));
     }
     if (is_null($video_data)) {
         $video_data_count = $GLOBALS['SITE_DB']->query_value('videos', 'COUNT(*)');
         $video_data = $video_data_count > 2000 ? array() : $GLOBALS['SITE_DB']->query_select('videos d LEFT JOIN ' . get_table_prefix() . 'translate t ON ' . db_string_equal_to('language', user_lang()) . ' AND t.id=d.title', array('d.title', 'd.id', 't.text_original AS ntitle', 'cat AS category_id', 'add_date', 'edit_date'));
     }
     // Subcategories
     foreach ($category_data as $row) {
         if ($row['parent_id'] != '' && $row['parent_id'] == $parent_attributes['id']) {
             $pagelink = $pagelink_stub . 'misc:' . $row['id'];
             if (__CLASS__ != '') {
                 $this->get_sitemap_pagelinks($callback, $member_id, $depth, $pagelink_stub, $pagelink, $recurse_level + 1, $category_data, $image_data, $video_data);
                 // Recurse
             } else {
                 call_user_func_array(__FUNCTION__, array($callback, $member_id, $depth, $pagelink_stub, $pagelink, $recurse_level + 1, $category_data, $image_data, $video_data));
                 // Recurse
             }
             if (has_category_access($member_id, 'galleries', $row['id'])) {
                 call_user_func_array($callback, array($pagelink, $parent_pagelink, $row['add_date'], NULL, max(0.7 - $recurse_level * 0.1, 0.3), $row['title']));
                 // Callback
             } else {
                 call_user_func_array($callback, array($pagelink, $parent_pagelink, $row['add_date'], NULL, max(0.7 - $recurse_level * 0.1, 0.3), do_lang('UNKNOWN'), false));
                 // Callback
             }
         }
     }
     // Entries
     if ($depth >= DEPTH__ENTRIES && has_category_access($member_id, 'galleries', $parent_attributes['id'])) {
         foreach ($image_data as $row) {
             if ($row['category_id'] == $parent_attributes['id']) {
                 $pagelink = $pagelink_stub . 'image:' . strval($row['id']);
                 if (is_null($row['title'])) {
                     $row['ntitle'] = get_translated_text($row['title']);
                 }
                 call_user_func_array($callback, array($pagelink, $parent_pagelink, $row['add_date'], $row['edit_date'], 0.2, $row['ntitle']));
                 // Callback
             }
         }
         foreach ($video_data as $row) {
             if ($row['category_id'] == $parent_attributes['id']) {
                 $pagelink = $pagelink_stub . 'video:' . strval($row['id']);
                 if (is_null($row['title'])) {
                     $row['ntitle'] = get_translated_text($row['title']);
                 }
                 call_user_func_array($callback, array($pagelink, $parent_pagelink, $row['add_date'], $row['edit_date'], 0.2, $row['ntitle']));
                 // Callback
             }
         }
     }
 }
Example #27
0
 /**
  * Generate all the Q/A pages
  */
 function display_options()
 {
     global $cache, $template, $user;
     // Step 0 is easy
     if ($this->step == 0) {
         return 'SRT_GENERATOR_LANDING';
     }
     // Step 1 only needs a single template var set
     if ($this->step == 1) {
         $template->assign_var('S_STEP1', true);
     } elseif ($this->step == 4) {
         $this->_build_srt();
     } else {
         // Fetch the cached results, might need it here
         $_previous_data = $cache->get('_stk_srt_generator');
         // Run through the questions
         $_prefilled = array();
         foreach ($this->_data["step{$this->step}"] as $question) {
             // Some questions are only asked when certain answers are given earlier
             if (isset($question['depends'])) {
                 // Only support booleans atm
                 if (empty($_previous_data[$question['depends']])) {
                     continue;
                 }
             }
             // First call the prefill if there is one
             $_p_callback_result = false;
             if (isset($question['p_callback']) && is_callable($question['p_callback'])) {
                 $_p_callback_result = call_user_func($question['p_callback']);
             } elseif (!empty($question['p_callback'])) {
                 $_p_callback_result = $question['p_callback'];
             }
             // If there is a prefill result use that as answer
             // Handle MODs a bit different (ugly :/)
             if ($_p_callback_result !== false && $question['name'] != 'installed_mods') {
                 $_prefilled[$question['name']] = $_p_callback_result;
             } else {
                 // If this is a dropdown generate the options.
                 if ($question['type'] == 'dropdown') {
                     // Options can be passed ether by an array in the data list or are generated from the language file
                     $options = !empty($question['options']) ? $question['options'] : array();
                     $this->_format_options($options, $question['name']);
                 }
                 $template->assign_block_vars('questionrow', array('EXPLAIN' => !empty($user->lang['SRT_QUESTIONS_EXPLAIN']["step{$this->step}"][$question['name']]) ? $user->lang['SRT_QUESTIONS_EXPLAIN']["step{$this->step}"][$question['name']] : '', 'NAME' => $question['name'], 'OPTIONS' => $question['type'] == 'dropdown' ? $options : '', 'PREFILL' => $_p_callback_result, 'QUESTION' => $user->lang['SRT_QUESTIONS']["step{$this->step}"][$question['name']], 'TYPE' => $question['type']));
             }
         }
     }
     $template->assign_vars(array('S_PREFILL' => !empty($_prefilled) ? htmlspecialchars(serialize($_prefilled)) : '', 'U_ACTION' => append_sid(STK_INDEX, array('c' => 'main', 't' => 'srt_generator', 'step' => $this->step))));
     // Spit out teh page
     page_header(user_lang('SRT_GENERATOR'));
     $template->set_filenames(array('body' => 'tools/srt_generator.html'));
     page_footer();
 }
Example #28
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));
 }
Example #29
0
 /**
  * Try to return the human-readable version of the language id, passed in as $entry.
  *
  * @param  integer			The id
  * @param  ?object			The database connection to use (NULL: standard site connection)
  * @param  ?LANGUAGE_NAME	The language (NULL: uses the current language)
  * @return string				The human-readable version
  */
 function get_translated_text($entry, $connection = NULL, $lang = NULL)
 {
     if ($entry == 0) {
         return do_lang('FAILED_ENTRY');
     }
     if ($entry === NULL) {
         fatal_exit(do_lang_tempcode('NULL_LANG_STRING'));
     }
     if ($connection === NULL) {
         $connection = $GLOBALS['SITE_DB'];
     }
     global $RECORD_LANG_STRINGS_CONTENT;
     if ($RECORD_LANG_STRINGS_CONTENT) {
         global $RECORDED_LANG_STRINGS_CONTENT;
         $RECORDED_LANG_STRINGS_CONTENT[$entry] = $connection->connection_write != $GLOBALS['SITE_DB']->connection_write;
     }
     if ($lang === NULL) {
         $lang = user_lang();
     }
     if (array_key_exists($entry, $connection->text_lookup_original_cache) && $lang == user_lang()) {
         return $connection->text_lookup_original_cache[$entry];
     }
     if ($lang == 'xxx') {
         return '!!!';
     }
     // Helpful for testing language compliancy. We don't expect to see non x's/!'s if we're running this language
     $result = $connection->query_select('translate', array('text_original', 'text_parsed'), array('id' => $entry, 'language' => $lang), '', 1);
     if (!array_key_exists(0, $result)) {
         $result = $connection->query_select('translate', array('*'), array('id' => $entry, 'language' => get_site_default_lang()), '', 1);
         if (!array_key_exists(0, $result)) {
             $result = $connection->query_select('translate', array('*'), array('id' => $entry), '', 1);
         }
         if (array_key_exists(0, $result)) {
             $result[0]['text_original'] = google_translate($result[0]['text_original'], $lang);
             $result[0]['text_parsed'] = '';
             $connection->query_insert('translate', array('broken' => 1, 'language' => $lang) + $result[0]);
         }
     }
     if (!array_key_exists(0, $result)) {
         $member_id = function_exists('get_member') ? get_member() : $GLOBALS['FORUM_DRIVER']->get_guest_id();
         $connection->query_insert('translate', array('id' => $entry, 'source_user' => $member_id, 'broken' => 0, 'importance_level' => 3, 'text_original' => '', 'text_parsed' => '', 'language' => $lang));
         $msg = do_lang('LANGUAGE_CORRUPTION', strval($entry));
         if (preg_match('#^localhost[\\.\\:$]#', ocp_srv('HTTP_HOST')) != 0) {
             fatal_exit($msg);
         }
         require_code('site');
         attach_message(make_string_tempcode($msg), 'warn');
         return '';
     }
     if ($lang == user_lang()) {
         $connection->text_lookup_original_cache[$entry] = $result[0]['text_original'];
         $connection->text_lookup_cache[$entry] = $result[0]['text_parsed'];
     }
     return $result[0]['text_original'];
 }
Example #30
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));
     }
 }