Esempio n. 1
0
/**
 * Script to make a bookmark add-form popup.
 */
function bookmarks_script()
{
    require_lang('bookmarks');
    $type = get_param('type');
    switch ($type) {
        case '_ad':
            $title = get_page_title('ADD_BOOKMARK');
            $folder = post_param('folder_new', '');
            if ($folder == '') {
                $folder = post_param('folder');
            }
            if ($folder == '!') {
                $folder = '';
            }
            add_bookmark(get_member(), $folder, post_param('title'), post_param('page_link'));
            $content = inform_screen($title, do_lang_tempcode('SUCCESS'));
            $content->attach('<script type="text/javascript">// <![CDATA[
				if (window.opener) window.close();
			//]]></script>');
            break;
        default:
            $url = find_script('bookmarks') . '?no_redirect=1&type=_ad';
            $keep = symbol_tempcode('KEEP');
            $url .= $keep->evaluate();
            $content = add_bookmark_form($url);
            break;
    }
    $echo = do_template('POPUP_HTML_WRAP', array('TITLE' => do_lang_tempcode('ADD_BOOKMARK'), 'CONTENT' => $content));
    $echo->handle_symbol_preprocessing();
    $echo->evaluate_echo();
}
Esempio n. 2
0
 /**
  * Standard modular run function.
  *
  * @param  array		A map of parameters.
  * @return tempcode	The result of execution.
  */
 function run($map)
 {
     require_lang('staff_checklist');
     $newdata = post_param('stafflinksedit', NULL);
     if (!is_null($newdata)) {
         $items = explode("\n", $newdata);
         $GLOBALS['SITE_DB']->query_delete('stafflinks');
         foreach ($items as $i) {
             $q = trim($i);
             if (!empty($q)) {
                 $bits = explode('=', $q);
                 if (count($bits) >= 2) {
                     $last_bit = array_pop($bits);
                     $bits = array(implode('=', $bits), $last_bit);
                     $link = $bits[0];
                 } else {
                     $link = $q;
                 }
                 $link_title = $GLOBALS['SITE_DB']->query_value_null_ok('url_title_cache', 't_title', array('t_url' => $link));
                 if (is_null($link_title) || substr($link_title, 0, 1) == '!') {
                     $link_title = '';
                     $downloaded_at_link = http_download_file($link, 3000, false);
                     if (is_string($downloaded_at_link)) {
                         $matches = array();
                         if (preg_match('#\\s*<title[^>]*\\s*>\\s*(.*)\\s*\\s*<\\s*/title\\s*>#mi', $downloaded_at_link, $matches) != 0) {
                             require_code('character_sets');
                             $link_title = trim(str_replace('&ndash;', '-', str_replace('&mdash;', '-', @html_entity_decode(convert_to_internal_encoding($matches[1]), ENT_QUOTES, get_charset()))));
                         }
                     }
                     $GLOBALS['SITE_DB']->query_insert('url_title_cache', array('t_url' => $link, 't_title' => $link_title), false, true);
                     // To stop weird race-like conditions
                 }
                 if (count($bits) == 2) {
                     $link_desc = $bits[1];
                 } else {
                     $link_desc = $link_title;
                 }
                 $GLOBALS['SITE_DB']->query_insert('stafflinks', array('link' => $link, 'link_title' => $link_title, 'link_desc' => $link_desc));
             }
         }
     }
     $rows = $GLOBALS['SITE_DB']->query_select('stafflinks', array('*'));
     $formattedstafflinks = array();
     $unformattedstafflinks = array();
     foreach ($rows as $r) {
         if ($r['link_title'] == '') {
             $r['link_title'] = $r['link_desc'];
         }
         if (strlen($r['link_title']) > strlen($r['link_desc'])) {
             $r['link_title'] = $r['link_desc'];
         }
         $formattedstafflinks[] = array('URL' => $r['link'], 'TITLE' => $r['link_title'], 'DESC' => $r['link_title'] == $r['link_desc'] ? '' : $r['link_desc']);
         $unformattedstafflinks[] = array('LINKS' => $r['link'] . '=' . $r['link_desc']);
     }
     $map_comcode = '';
     foreach ($map as $key => $val) {
         $map_comcode .= ' ' . $key . '="' . addslashes($val) . '"';
     }
     return do_template('BLOCK_MAIN_STAFF_LINKS', array('URL' => get_self_url(), 'BLOCK_NAME' => 'main_staff_links', 'MAP' => $map_comcode, 'FORMATTEDLINKS' => $formattedstafflinks, 'UNFORMATTEDLINKS' => $unformattedstafflinks));
 }
Esempio n. 3
0
 /**
  * Standard actualisation stage of pointstore item purchase.
  *
  * @return tempcode		The UI
  */
 function action_done()
 {
     $class = str_replace('hook_pointstore_', '', strtolower(get_class($this)));
     if (get_option('is_on_' . $class . '_buy') == '0') {
         return new ocp_tempcode();
     }
     $topic_id = post_param_integer('select_topic_id', -1);
     if ($topic_id == -1) {
         $_topic_id = post_param('manual_topic_id');
         $topic_id = intval($_topic_id);
     }
     $title = get_page_title('TOPIC_PINNING');
     // Check points
     $cost = intval(get_option($class));
     $points_left = available_points(get_member());
     if ($points_left < $cost && !has_specific_permission(get_member(), 'give_points_self')) {
         return warn_screen($title, do_lang_tempcode('_CANT_AFFORD', integer_format($cost), integer_format($points_left)));
     }
     // Actuate
     $GLOBALS['FORUM_DRIVER']->pin_topic($topic_id);
     require_code('points2');
     charge_member(get_member(), $cost, do_lang('TOPIC_PINNING'));
     $GLOBALS['SITE_DB']->query_insert('sales', array('date_and_time' => time(), 'memberid' => get_member(), 'purchasetype' => 'TOPIC_PINNING', 'details' => strval($topic_id), 'details2' => ''));
     // Show message
     $url = build_url(array('page' => '_SELF', 'type' => 'misc'), '_SELF');
     return redirect_screen($title, $url, do_lang_tempcode('ORDER_GENERAL_DONE'));
 }
Esempio n. 4
0
 /**
  * Standard modular run function.
  *
  * @param  array		A map of parameters.
  * @return tempcode	The result of execution.
  */
 function run($map)
 {
     require_code('textfiles');
     $file = array_key_exists('param', $map) ? $map['param'] : 'admin_notes';
     $title = array_key_exists('title', $map) ? $map['title'] : do_lang('NOTES');
     $lang_none = array_key_exists('lang_none', $map) ? $map['lang_none'] : '0';
     $scrolls = array_key_exists('scrolls', $map) ? $map['scrolls'] : '0';
     $lang = $lang_none == '1' ? NULL : '';
     $file = filter_naughty($file, true);
     $new = post_param('new', NULL);
     if (!is_null($new)) {
         $hooks = find_all_hooks('blocks', 'main_notes');
         foreach (array_keys($hooks) as $hook) {
             require_code('hooks/blocks/main_notes/' . filter_naughty_harsh($hook));
             $ob = object_factory('Hook_notes_' . filter_naughty_harsh($hook), true);
             if (is_null($ob)) {
                 continue;
             }
             $ob->run($file);
         }
         write_text_file($file, $lang, $new);
         log_it('NOTES', $file);
         attach_message(do_lang_tempcode('SUCCESS'), 'inform');
     }
     $contents = read_text_file($file, $lang, true);
     $post_url = get_self_url();
     $map_comcode = '';
     foreach ($map as $key => $val) {
         $map_comcode .= ' ' . $key . '="' . addslashes($val) . '"';
     }
     return do_template('BLOCK_MAIN_NOTES', array('_GUID' => 'f737053505de3bd8ccfe806ec014b8fb', 'TITLE' => $title, 'BLOCK_NAME' => 'main_notes', 'MAP' => $map_comcode, 'CONTENTS' => $contents, 'SCROLLS' => array_key_exists('scrolls', $map) && $map['scrolls'] == '1', 'URL' => $post_url));
 }
Esempio n. 5
0
/**
 * Used by semihtml_to_comcode to fix <a> tag links. preg_replace_callback callback
 *
 * @param  array			Array of matches
 * @return string			Substituted text
 */
function _a_tag_link_fixup($matches)
{
    $referer = post_param('http_referer', ocp_srv('HTTP_REFERER'));
    $caller_url = looks_like_url($referer) ? preg_replace('#/[^/]*$#', '', $referer) : get_base_url();
    $ret = '<a ' . $matches[1] . 'href="' . qualify_url($matches[2], $caller_url) . '"' . $matches[3] . '>';
    return $ret;
}
Esempio n. 6
0
 /**
  * Standard modular run function for preview hooks.
  *
  * @return array			A pair: The preview, the updated post Comcode
  */
 function run()
 {
     if (!has_specific_permission(get_member(), 'comcode_dangerous')) {
         exit;
     }
     require_code('zones2');
     require_code('zones3');
     $bparameters = '';
     $bparameters_xml = '';
     $block = post_param('block');
     $parameters = get_block_parameters($block);
     $parameters[] = 'failsafe';
     $parameters[] = 'cache';
     $parameters[] = 'quick_cache';
     foreach ($parameters as $parameter) {
         $value = post_param($parameter, NULL);
         if (is_null($value)) {
             if (post_param_integer('tick_on_form__' . $parameter, NULL) === NULL) {
                 continue;
             }
             // If not on form, continue, otherwise must be 0
             $value = '0';
         }
         if ($value != '' && ($parameter != 'failsafe' || $value == '1') && ($parameter != 'cache' || $value != block_cache_default($block)) && ($parameter != 'quick_cache' || $value == '1')) {
             $bparameters .= ' ' . $parameter . '="' . str_replace('"', '\\"', $value) . '"';
             $bparameters_xml = '<blockParam key="' . escape_html($parameter) . '" val="' . escape_html($value) . '" />';
         }
     }
     $comcode = '[block' . $bparameters . ']' . $block . '[/block]';
     $preview = comcode_to_tempcode($comcode);
     return array($preview, NULL);
 }
Esempio n. 7
0
 /**
  * Standard modular run function for preview hooks.
  *
  * @return array			A pair: The preview, the updated post Comcode
  */
 function run()
 {
     require_code('uploads');
     $urls = get_url('', 'file', 'uploads/iotds', 0, OCP_UPLOAD_IMAGE, true, '', 'file2');
     if ($urls[0] == '') {
         if (!is_null(post_param_integer('id', NULL))) {
             $rows = $GLOBALS['SITE_DB']->query_select('iotds', array('url', 'thumb_url'), array('id' => post_param_integer('id')), '', 1);
             $urls = $rows[0];
             $url = $urls['url'];
             $thumb_url = $urls['thumb_url'];
         } else {
             warn_exit(do_lang_tempcode('IMPROPERLY_FILLED_IN_UPLOAD'));
         }
     } else {
         $url = $urls[0];
         $thumb_url = $urls[1];
     }
     $caption = comcode_to_tempcode(post_param('caption', ''));
     $title = comcode_to_tempcode(post_param('title', ''));
     require_code('images');
     $thumb = do_image_thumb(url_is_local($thumb_url) ? get_custom_base_url() . '/' . $thumb_url : $thumb_url, $caption, true);
     $url = url_is_local($url) ? get_custom_base_url() . '/' . $url : $url;
     $preview = do_template('IOTD', array('ID' => '', 'IMAGE_URL' => $url, 'SUBMITTER' => strval(get_member()), 'VIEW_URL' => $url, 'IMAGE' => $thumb, 'CAPTION' => $title));
     return array($preview, NULL);
 }
Esempio n. 8
0
/**
 * Handle cloud registrations.
 */
function backend_cloud_script()
{
    // Closed site
    $site_closed = get_option('site_closed');
    if ($site_closed == '1' && !has_specific_permission(get_member(), 'access_closed_site') && !$GLOBALS['IS_ACTUALLY_ADMIN']) {
        header('Content-Type: text/plain');
        @exit(get_option('closed'));
    }
    $path = post_param('path', '');
    $procedure = post_param('registerProcedure', '');
    $protocol = post_param('protocol', '');
    if ($protocol == 'soap') {
        exit('false');
    }
    if ($protocol == 'http-post') {
        exit('false');
    }
    if ($protocol == 'xml-rpc' && !function_exists('xmlrpc_encode')) {
        exit('false');
    }
    $port = post_param_integer('port', '80');
    //	$watching_channel=$_POST['channels'];
    $status = register_them($path, $procedure, $protocol, $port, get_param('type', ''));
    if (!$status) {
        exit('false');
    }
    exit('true');
}
Esempio n. 9
0
 /**
  * Standard modular run function for preview hooks.
  *
  * @return array			A pair: The preview, the updated post Comcode
  */
 function run()
 {
     require_code('comcode_add');
     $comcode = _get_preview_environment_comcode(post_param('tag'));
     $temp_tpl = comcode_to_tempcode($comcode[0]);
     return array($temp_tpl, NULL);
 }
Esempio n. 10
0
 /**
  * Standard modular run function for setting features from the setup wizard.
  */
 function set_fields()
 {
     if (!addon_installed('stats')) {
         return;
     }
     set_option('stats_store_time', post_param('stats_store_time'));
 }
Esempio n. 11
0
 /**
  * Standard modular run function.
  *
  * @return tempcode	The result of execution.
  */
 function run()
 {
     require_lang('bulkupload');
     $GLOBALS['HELPER_PANEL_PIC'] = 'pagepics/bulkuploadassistant';
     $GLOBALS['HELPER_PANEL_TUTORIAL'] = 'tut_adv_comcode';
     $GLOBALS['HELPER_PANEL_TEXT'] = comcode_lang_string('DOC_BULK_UPLOAD');
     $title = get_page_title('BULK_UPLOAD');
     $parameter = post_param('parameter', '');
     require_code('form_templates');
     if ($parameter == '') {
         $post_url = build_url(array('page' => '_SELF'), '_SELF');
         $text = paragraph(do_lang_tempcode('BULK_UPLOAD_HELP'));
         $submit_name = do_lang_tempcode('BULK_UPLOAD');
         $fields = form_input_line(do_lang_tempcode('DIRECTORY'), do_lang_tempcode('DIRECTORY_BULK'), 'parameter', 'uploads/attachments/' . date('Y-m-d', utctime_to_usertime()), true);
         return do_template('FORM_SCREEN', array('_GUID' => '77a2ca460745145d8a1d18cf24971fea', 'SKIP_VALIDATION' => true, 'HIDDEN' => '', 'FIELDS' => $fields, 'URL' => $post_url, 'TITLE' => $title, 'TEXT' => $text, 'SUBMIT_NAME' => $submit_name));
     } else {
         breadcrumb_set_parents(array(array('_SELF:_SELF:misc', do_lang_tempcode('BULK_UPLOAD'))));
         breadcrumb_set_self(do_lang_tempcode('_RESULTS'));
         $out = $this->do_dir(get_custom_file_base() . '/' . filter_naughty($parameter, true));
         if ($out->is_empty()) {
             inform_exit(do_lang_tempcode('NO_FILES'));
         }
         return do_template('BULK_HELPER_RESULTS_SCREEN', array('_GUID' => '5d373553cf21a58f15006bd4e600a9ee', 'TITLE' => $title, 'RESULTS' => $out));
     }
 }
Esempio n. 12
0
 /**
  * Standard modular run function for snippet hooks. Generates XHTML to insert into a page using AJAX.
  *
  * @return tempcode  The snippet
  */
 function run()
 {
     if (has_actual_page_access(get_member(), 'admin_themes')) {
         require_code('tempcode_compiler');
         return template_to_tempcode(post_param('css'));
     }
     return new ocp_tempcode();
 }
Esempio n. 13
0
 /**
  * Standard modular run function for preview hooks.
  *
  * @return array			A pair: The preview, the updated post Comcode
  */
 function run()
 {
     $_GET['keep_theme_seed'] = post_param('seed_hex');
     $_GET['keep_theme_dark'] = post_param('dark', '0');
     $_GET['keep_theme_source'] = 'default';
     $_GET['keep_theme_algorithm'] = 'equations';
     $preview = request_page($GLOBALS['SITE_DB']->query_value('zones', 'zone_default_page'), true, '');
     return array($preview, NULL);
 }
/**
 * A template has not been structurally cached, so compile it and store in the cache.
 *
 * @param  ID_TEXT			The theme the template is in the context of
 * @param  PATH				The path to the template file
 * @param  ID_TEXT			The codename of the template (e.g. foo)
 * @param  ID_TEXT			The actual codename to use for the template (e.g. thin_foo)
 * @param  LANGUAGE_NAME	The language the template is in the context of
 * @param  string				File type suffix of template file
 * @param  ?ID_TEXT			The theme to cache in (NULL: main theme)
 * @return tempcode			The compiled tempcode
 */
function _do_template($theme, $path, $codename, $_codename, $lang, $suffix, $theme_orig = NULL)
{
    if (is_null($theme_orig)) {
        $theme_orig = $theme;
    }
    $base_dir = ($theme == 'default' && ($suffix != '.css' || strpos($path, '/css_custom') === false) ? get_file_base() : get_custom_file_base()) . '/themes/';
    global $CACHE_TEMPLATES, $FILE_ARRAY, $TEMPLATE_PREVIEW_OP, $MEM_CACHE;
    if (isset($FILE_ARRAY)) {
        $html = unixify_line_format(file_array_get('themes/' . $theme . $path . $codename . $suffix));
    } else {
        $html = unixify_line_format(file_get_contents($base_dir . filter_naughty($theme . $path . $codename) . $suffix, FILE_TEXT));
    }
    if (strpos($html, '{$,Parser hint: pure}') !== false) {
        return make_string_tempcode(preg_replace('#\\{\\$,.*\\}#U', '/*no minify*/', $html));
    }
    if ($GLOBALS['SEMI_DEBUG_MODE'] && strpos($html, '.innerHTML') !== false && strpos($html, 'Parser hint: .innerHTML okay') === false) {
        require_code('site');
        attach_message('Do not use the .innerHTML property in your Javascript because it will not work in true XHTML (when the browsers real XML parser is in action). Use ocPortal\'s global setInnerHTML/getInnerHTML functions.', 'warn');
    }
    // Strip off trailing final lines from single lines templates. Editors often put these in, and it causes annoying "visible space" issues
    if (substr($html, -1, 1) == chr(10) && substr_count($html, chr(10)) == 1) {
        $html = substr($html, 0, strlen($html) - 1);
    }
    if ($TEMPLATE_PREVIEW_OP) {
        $test = post_param($codename, NULL);
        if (!is_null($test)) {
            $html = post_param($test . '_new');
        }
    }
    $result = template_to_tempcode($html, 0, false, $codename, $theme, $lang);
    if ($CACHE_TEMPLATES && ($suffix == '.tpl' || $codename == 'no_cache')) {
        if (!is_null($MEM_CACHE)) {
            persistant_cache_set(array('TEMPLATE', $theme, $lang, $_codename), $result->to_assembly(), strpos($path, 'default/templates/') !== false);
        } else {
            $path2 = get_custom_file_base() . '/themes/' . $theme_orig . '/templates_cached/' . filter_naughty($lang) . '/';
            $myfile = @fopen($path2 . filter_naughty($_codename) . $suffix . '.tcd', 'wb');
            if ($myfile === false) {
                if (@mkdir($path2, 0777)) {
                    require_code('files');
                    fix_permissions($path2, 0777);
                } else {
                    if (file_exists($path2 . filter_naughty($_codename) . $suffix . '.tcd')) {
                        warn_exit(do_lang_tempcode('WRITE_ERROR', $path2 . filter_naughty($_codename) . $suffix . '.tcd'));
                    } else {
                        warn_exit(do_lang_tempcode('WRITE_ERROR_CREATE', $path2 . filter_naughty($_codename) . $suffix . '.tcd'));
                    }
                }
            } else {
                fwrite($myfile, $result->to_assembly($lang));
                fclose($myfile);
                fix_permissions($path2 . filter_naughty($_codename) . $suffix . '.tcd');
            }
        }
    }
    return $result;
}
Esempio n. 15
0
/**
 * Check a POST inputted date for validity, and get the Unix timestamp for the inputted date.
 *
 * @param  ID_TEXT		The stub of the parameter name (stub_year, stub_month, stub_day, stub_hour, stub_minute)
 * @param  boolean		Whether to allow over get parameters also
 * @return ?TIME			The timestamp of the date (NULL: no input date was chosen)
 */
function _get_input_date($stub, $get_also = false)
{
    $timezone = post_param('timezone', get_users_timezone());
    if ($get_also) {
        //		if (either_param_integer($stub,0)==0) return NULL; // NULL was chosen		Doesn't work like this now
        $year = either_param_integer($stub . '_year', NULL);
        if (is_null($year)) {
            return NULL;
        }
        $month = either_param_integer($stub . '_month', NULL);
        if (is_null($month)) {
            return NULL;
        }
        $day = either_param_integer($stub . '_day', NULL);
        if (is_null($day)) {
            return NULL;
        }
        $hour = either_param_integer($stub . '_hour', NULL);
        $minute = either_param_integer($stub . '_minute', NULL);
    } else {
        //		if (post_param_integer($stub,0)==0) return NULL; // NULL was chosen		Doesn't work like this now
        $year = post_param_integer($stub . '_year', NULL);
        if (is_null($year)) {
            return NULL;
        }
        $month = post_param_integer($stub . '_month', NULL);
        if (is_null($month)) {
            return NULL;
        }
        $day = post_param_integer($stub . '_day', NULL);
        if (is_null($day)) {
            return NULL;
        }
        $hour = post_param_integer($stub . '_hour', NULL);
        $minute = post_param_integer($stub . '_minute', NULL);
    }
    if (!checkdate($month, $day, $year)) {
        warn_exit(do_lang_tempcode('INVALID_DATE_GIVEN'));
    }
    if (is_null($hour)) {
        if (strpos($stub, 'end') !== false) {
            $hour = 23;
            $minute = 59;
        } else {
            $hour = 0;
            $minute = 0;
        }
    }
    $time = mktime($hour, $minute, 0, $month, $day, $year);
    if ($year >= 1970 || @strftime('%Y', @mktime(0, 0, 0, 1, 1, 1963)) == '1963') {
        $amount_forward = tz_time($time, $timezone) - $time;
        $time = $time - $amount_forward;
    }
    return $time;
}
Esempio n. 16
0
 /**
  * Standard modular run function for preview hooks.
  *
  * @return array			A pair: The preview, the updated post Comcode
  */
 function run()
 {
     require_lang('ocf');
     require_css('ocf');
     $original_comcode = post_param('post');
     $posting_ref_id = post_param_integer('posting_ref_id', mt_rand(0, 100000));
     $post_bits = do_comcode_attachments($original_comcode, 'seedy_post', strval(-$posting_ref_id), true, $GLOBALS['SITE_DB']);
     $post_comcode = $post_bits['comcode'];
     $post_html = $post_bits['tempcode'];
     return array($post_html, $post_comcode);
 }
Esempio n. 17
0
 /**
  * Standard modular run function for preview hooks.
  *
  * @return array			A pair: The preview, the updated post Comcode
  */
 function run()
 {
     // Find review, if there is one
     $individual_review_ratings = array();
     $review_rating = post_param('review_rating', '');
     if ($review_rating != '') {
         $individual_review_ratings[''] = array('REVIEW_TITLE' => '', 'REVIEW_RATING' => $review_rating);
     }
     $poster_name = $GLOBALS['FORUM_DRIVER']->get_username(get_member());
     $post = comcode_to_tempcode(post_param('post'));
     // OCF renderings of poster
     static $hooks = NULL;
     if (is_null($hooks)) {
         $hooks = find_all_hooks('modules', 'topicview');
     }
     static $hook_objects = NULL;
     if (is_null($hook_objects)) {
         $hook_objects = array();
         foreach (array_keys($hooks) as $hook) {
             require_code('hooks/modules/topicview/' . filter_naughty_harsh($hook));
             $object = object_factory('Hook_' . filter_naughty_harsh($hook), true);
             if (is_null($object)) {
                 continue;
             }
             $hook_objects[$hook] = $object;
         }
     }
     if (!is_guest()) {
         require_code('ocf_members2');
         $poster_details = ocf_show_member_box(get_member(), false, $hooks, $hook_objects, false);
     } else {
         $custom_fields = new ocp_tempcode();
         $poster_details = new ocp_tempcode();
     }
     if (addon_installed('ocf_forum')) {
         if (!is_guest()) {
             $poster = do_template('OCF_POSTER_MEMBER', array('ONLINE' => true, 'ID' => strval(get_member()), 'POSTER_DETAILS' => $poster_details, 'PROFILE_URL' => $GLOBALS['FORUM_DRIVER']->member_profile_url(get_member(), false, true), 'POSTER_USERNAME' => $poster_name));
         } else {
             $poster = do_template('OCF_POSTER_GUEST', array('IP_LINK' => '', 'POSTER_DETAILS' => $poster_details, 'POSTER_USERNAME' => $poster_name));
         }
     } else {
         $poster = make_string_tempcode(escape_html($poster_name));
         // Should never happen actually, as applies discounts hook from even running
     }
     $highlight = false;
     $datetime_raw = time();
     $datetime = get_timezoned_date(time());
     $poster_url = $GLOBALS['FORUM_DRIVER']->member_profile_url(get_member());
     $title = post_param('title', '');
     $tpl = do_template('POST', array('INDIVIDUAL_REVIEW_RATINGS' => $individual_review_ratings, 'HIGHLIGHT' => $highlight, 'TITLE' => $title, 'TIME_RAW' => strval($datetime_raw), 'TIME' => $datetime, 'POSTER_URL' => $poster_url, 'POSTER_NAME' => $poster_name, 'POST' => $post, 'POSTER_ID' => strval(get_member()), 'POSTER' => $poster, 'POSTER_DETAILS' => $poster_details, 'ID' => '', 'CHILDREN' => '', 'RATING' => '', 'EMPHASIS' => '', 'BUTTONS' => '', 'TOPIC_ID' => '', 'UNVALIDATED' => '', 'IS_SPACER_POST' => false, 'NUM_TO_SHOW_LIMIT' => '0'));
     return array($tpl, NULL);
 }
Esempio n. 18
0
 /**
  * Find whether this preview hook applies.
  *
  * @return array			Quartet: Whether it applies, the attachment ID type, whether the forum DB is used [optional], list of fields to limit to [optional]
  */
 function applies()
 {
     require_lang('ocf');
     $member_id = get_param_integer('id', get_member());
     $applies = get_param('page', '') == 'members' && post_param('signature', NULL) !== NULL;
     if ($applies) {
         require_code('ocf_groups');
         $max_sig_length = ocf_get_member_best_group_property($member_id, 'max_sig_length_comcode');
         if (strlen(post_param('post', '')) > $max_sig_length) {
             warn_exit(do_lang_tempcode('SIGNATURE_TOO_BIG'));
         }
     }
     return array($applies, 'ocf_signature', true, array('post'));
 }
Esempio n. 19
0
function set_from_referrer_field()
{
    require_lang('referrals');
    $referrer = post_param('referrer', '');
    if ($referrer == '') {
        return;
    }
    // NB: This doesn't mean failure, it may already have been set by the recommend module when the recommendation was *made*
    $referrer_member = $GLOBALS['FORUM_DB']->query_value_null_ok_full('SELECT id FROM ' . $GLOBALS['FORUM_DB']->get_table_prefix() . 'f_members WHERE ' . db_string_equal_to('m_username', $referrer) . ' OR ' . db_string_equal_to('m_email_address', $referrer));
    if (!is_null($referrer_member)) {
        $GLOBALS['FORUM_DB']->query_delete('f_invites', array('i_email_address' => post_param('email_address')), '', 1);
        // Delete old invites for this email address
        $GLOBALS['FORUM_DB']->query_insert('f_invites', array('i_inviter' => $referrer_member, 'i_email_address' => post_param('email_address'), 'i_time' => time(), 'i_taken' => 0));
    }
}
Esempio n. 20
0
 /**
  * Standard modular run function.
  *
  * @param  array		A map of parameters.
  * @return tempcode	The result of execution.
  */
 function run($map)
 {
     require_lang('messaging');
     require_code('feedback');
     $to = array_key_exists('param', $map) ? $map['param'] : get_option('staff_address');
     $post = post_param('post', '');
     if (post_param_integer('_comment_form_post', 0) == 1 && $post != '') {
         if (addon_installed('captcha')) {
             if (get_option('captcha_on_feedback') == '1') {
                 require_code('captcha');
                 enforce_captcha();
             }
         }
         $message = new ocp_tempcode();
         /*Used to be written out here*/
         attach_message(do_lang_tempcode('MESSAGE_SENT'), 'inform');
         require_code('mail');
         $email_from = trim(post_param('email', $GLOBALS['FORUM_DRIVER']->get_member_email_address(get_member())));
         mail_wrap(post_param('title'), $post, array($to), NULL, $email_from, $GLOBALS['FORUM_DRIVER']->get_username(get_member()), 3, NULL, false, get_member());
         if ($email_from != '') {
             mail_wrap(do_lang('YOUR_MESSAGE_WAS_SENT_SUBJECT', post_param('title')), do_lang('YOUR_MESSAGE_WAS_SENT_BODY', $post), array($email_from), NULL, '', '', 3, NULL, false, get_member());
         }
     } else {
         $message = new ocp_tempcode();
     }
     $box_title = array_key_exists('title', $map) ? $map['title'] : do_lang('CONTACT_US');
     $private = array_key_exists('private', $map) && $map['private'] == '1';
     $em = $GLOBALS['FORUM_DRIVER']->get_emoticon_chooser();
     require_javascript('javascript_editing');
     $comcode_help = build_url(array('page' => 'userguide_comcode'), get_comcode_zone('userguide_comcode', false));
     require_javascript('javascript_validation');
     $comment_url = get_self_url();
     $email_optional = array_key_exists('email_optional', $map) ? intval($map['email_optional']) == 1 : true;
     if (addon_installed('captcha')) {
         require_code('captcha');
         $use_captcha = get_option('captcha_on_feedback') == '1' && use_captcha();
         if ($use_captcha) {
             generate_captcha();
         }
     } else {
         $use_captcha = false;
     }
     $comment_details = do_template('COMMENTS_POSTING_FORM', array('JOIN_BITS' => '', 'FIRST_POST_URL' => '', 'FIRST_POST' => '', 'USE_CAPTCHA' => $use_captcha, 'EMAIL_OPTIONAL' => $email_optional, 'POST_WARNING' => '', 'COMMENT_TEXT' => '', 'GET_EMAIL' => !$private, 'GET_TITLE' => !$private, 'EM' => $em, 'DISPLAY' => 'block', 'TITLE' => $box_title, 'COMMENT_URL' => $comment_url));
     $out = do_template('BLOCK_MAIN_CONTACT_SIMPLE', array('_GUID' => '298a357f442f440c6b42e58d6717e57c', 'EMAIL_OPTIONAL' => true, 'COMMENT_DETAILS' => $comment_details, 'MESSAGE' => $message));
     return $out;
 }
Esempio n. 21
0
 /**
  * Standard modular run function for preview hooks.
  *
  * @return array			A pair: The preview, the updated post Comcode
  */
 function run()
 {
     require_code('comcode_text');
     $tag = post_param('tag');
     $replace = post_param('replace');
     $parameters = '';
     foreach ($_POST as $key => $val) {
         if (substr($key, 0, 11) != 'parameters_') {
             continue;
         }
         if ($val == '') {
             continue;
         }
         if ($parameters != '') {
             $parameters .= ',';
         }
         $parameters .= $val;
     }
     $_parameters = $parameters == '' ? array() : explode(',', $parameters);
     $example = post_param('example');
     $content = do_lang_tempcode('EXAMPLE');
     $matches = array();
     if (preg_match('#\\](.*)\\[#', $example, $matches) != 0) {
         $content = make_string_tempcode($matches[1]);
     }
     $binding = array('CONTENT' => $content);
     foreach ($_parameters as $parameter) {
         $parameter = trim($parameter);
         $parts = explode('=', $parameter);
         if (count($parts) == 1) {
             $parts[] = '';
         }
         if (count($parts) != 2) {
             continue;
         }
         list($parameter, $default) = $parts;
         $binding[strtoupper($parameter)] = $default;
         $replace = str_replace('{' . $parameter . '}', '{' . strtoupper($parameter) . '*}', $replace);
     }
     require_code('tempcode_compiler');
     $replace = str_replace('{content}', array_key_exists($tag, $GLOBALS['TEXTUAL_TAGS']) ? '{CONTENT}' : '{CONTENT*}', $replace);
     $temp_tpl = template_to_tempcode($replace);
     $temp_tpl = $temp_tpl->bind($binding, '(custom comcode: ' . $tag . ')');
     return array($temp_tpl, NULL);
 }
 /**
  * Standard modular run function.
  *
  * @param  array		A map of parameters.
  * @return tempcode	The result of execution.
  */
 function run($map)
 {
     $page = array_key_exists('param', $map) && $map['param'] != '' ? $map['param'] : get_page_name();
     $zone = array_key_exists('zone', $map) ? $map['zone'] : post_param('zone', get_comcode_zone($page, false));
     if ($zone == '_SEARCH') {
         $zone = NULL;
     }
     $qmap = array('p_parent_page' => $page);
     if (!is_null($zone)) {
         $qmap['the_zone'] = $zone;
     }
     if (!has_specific_permission(get_member(), 'see_unvalidated')) {
         $qmap['p_validated'] = 1;
     }
     $children = $GLOBALS['SITE_DB']->query_select('comcode_pages', array('the_page', 'the_zone'), $qmap);
     foreach ($children as $i => $child) {
         $_title = $GLOBALS['SITE_DB']->query_value_null_ok('cached_comcode_pages', 'cc_page_title', array('the_page' => $child['the_page'], 'the_zone' => $child['the_zone']));
         if (!is_null($_title)) {
             $title = get_translated_text($_title, NULL, NULL, true);
             if (is_null($title)) {
                 $title = '';
             }
         } else {
             $title = '';
             if (get_option('is_on_comcode_page_cache') == '1') {
                 request_page($child['the_page'], false, $child['the_zone'], NULL, true);
                 $_title = $GLOBALS['SITE_DB']->query_value_null_ok('cached_comcode_pages', 'cc_page_title', array('the_page' => $child['the_page'], 'the_zone' => $child['the_zone']));
                 if (!is_null($_title)) {
                     $title = get_translated_text($_title);
                 }
             }
         }
         if ($title == '') {
             $title = escape_html(ucwords(str_replace('_', ' ', $child['the_page'])));
         }
         $child['TITLE'] = $title;
         $child['PAGE'] = $child['the_page'];
         $child['ZONE'] = $child['the_zone'];
         $children[$i] = $child;
     }
     $GLOBALS['M_SORT_KEY'] = 'TITLE';
     usort($children, 'multi_sort');
     return do_template('BLOCK_MAIN_COMCODE_PAGE_CHILDREN', array('_GUID' => '375aa1907fc6b2ca6b23ab5b5139aaef', 'CHILDREN' => $children, 'THE_PAGE' => $page, 'THE_ZONE' => $zone));
 }
Esempio n. 23
0
 /**
  * Standard modular run function for preview hooks.
  *
  * @return array			A pair: The preview, the updated post Comcode
  */
 function run()
 {
     require_code('setupwizard');
     $collapse_zones = post_param_integer('collapse_user_zones', 0) == 1;
     $installprofile = post_param('installprofile', '');
     if ($installprofile != '') {
         require_code('hooks/modules/admin_setupwizard_installprofiles/' . $installprofile);
         $object = object_factory('Hook_admin_setupwizard_installprofiles_' . $installprofile);
         $installprofileblocks = $object->default_blocks();
         $block_options = $object->block_options();
     } else {
         $installprofileblocks = array();
         $block_options = array();
     }
     $page_structure = _get_zone_pages($installprofileblocks, $block_options, $collapse_zones, $installprofile);
     $zone_structure = array_pop($page_structure);
     $preview = do_template('SETUPWIZARD_BLOCK_PREVIEW', array('LEFT' => $zone_structure['left'], 'RIGHT' => $zone_structure['right'], 'START' => $zone_structure['start']));
     return array($preview, NULL);
 }
Esempio n. 24
0
 /**
  * Standard modular run function for preview hooks.
  *
  * @return array			A pair: The preview, the updated post Comcode
  */
 function run()
 {
     $original_comcode = post_param('post');
     $posting_ref_id = post_param_integer('posting_ref_id', mt_rand(0, 100000));
     $post_bits = do_comcode_attachments($original_comcode, 'news', strval(-$posting_ref_id), true, $GLOBALS['SITE_DB']);
     $post_comcode = $post_bits['comcode'];
     $post_html = $post_bits['tempcode'];
     $view_space_map = array();
     $view_space_map[post_param('label_for__title')] = escape_html(post_param('title'));
     $view_space_map[post_param('label_for__post')] = $post_html;
     $view_space_map[post_param('label_for__news')] = comcode_to_tempcode(post_param('news', ''));
     require_code('templates_view_space');
     $view_space_fields = new ocp_tempcode();
     foreach ($view_space_map as $key => $val) {
         $view_space_fields->attach(view_space_field($key, $val, true));
     }
     $output = do_template('VIEW_SPACE', array('WIDTH' => '170', 'FIELDS' => $view_space_fields));
     return array($output, $post_comcode);
 }
Esempio n. 25
0
 /**
  * Standard modular run function for preview hooks.
  *
  * @return array			A pair: The preview, the updated post Comcode
  */
 function run()
 {
     require_code('uploads');
     $urls = get_url('', 'file', 'safe_mode_temp', 0, OCP_UPLOAD_IMAGE, false);
     if ($urls[0] == '') {
         if (!is_null(post_param_integer('id', NULL))) {
             $rows = $GLOBALS['SITE_DB']->query_select('calendar_types', array('t_logo'), array('id' => post_param_integer('id')), '', 1);
             $urls = $rows[0];
             $url = find_theme_image($urls['t_logo']);
         } elseif (!is_null(post_param('theme_img_code', NULL))) {
             $url = find_theme_image(post_param('theme_img_code'));
         } else {
             warn_exit(do_lang_tempcode('IMPROPERLY_FILLED_IN_UPLOAD'));
         }
     } else {
         $url = $urls[0];
     }
     require_code('images');
     $preview = do_image_thumb(url_is_local($url) ? get_custom_base_url() . '/' . $url : $url, post_param('title'), true);
     return array($preview, NULL);
 }
 /**
  * Standard modular run function.
  *
  * @param  array		A map of parameters.
  * @return tempcode	The result of execution.
  */
 function run($map)
 {
     require_lang('newsletter');
     require_lang('javascript');
     $newsletter_id = array_key_exists('param', $map) ? intval($map['param']) : db_get_first_id();
     $_newsletter_title = $GLOBALS['SITE_DB']->query_value_null_ok('newsletters', 'title', array('id' => $newsletter_id));
     if (is_null($_newsletter_title)) {
         return paragraph(do_lang_tempcode('MISSING_RESOURCE'));
     }
     $newsletter_title = get_translated_text($_newsletter_title);
     $address = post_param('address' . strval($newsletter_id), '');
     if ($address != '') {
         require_code('newsletter');
         require_code('type_validation');
         if (!is_valid_email_address($address)) {
             $msg = do_template('INLINE_WIP_MESSAGE', array('MESSAGE' => do_lang_tempcode('INVALID_EMAIL_ADDRESS')));
             return do_template('BLOCK_MAIN_NEWSLETTER_SIGNUP', array('URL' => get_self_url(), 'MSG' => $msg));
         }
         if (!array_key_exists('path', $map)) {
             $map['path'] = 'uploads/website_specific/signup.txt';
         }
         require_code('character_sets');
         $password = basic_newsletter_join($address, 4, NULL, !file_exists(get_custom_file_base() . '/' . $map['path']), $newsletter_id, post_param('firstname' . strval($newsletter_id), ''), post_param('lastname' . strval($newsletter_id), ''));
         if ($password == '') {
             return do_template('INLINE_WIP_MESSAGE', array('MESSAGE' => do_lang_tempcode('NEWSLETTER_THIS_ALSO')));
         }
         if ($password == do_lang('NA')) {
             $manage_url = build_url(array('page' => 'newsletter', 'email' => $address), get_module_zone('newsletter'));
             return do_template('INLINE_WIP_MESSAGE', array('MESSAGE' => do_lang_tempcode('ALREADY_EMAIL_ADDRESS', escape_html($manage_url->evaluate()))));
         }
         require_code('mail');
         if (file_exists(get_custom_file_base() . '/' . $map['path'])) {
             $url = (url_is_local($map['path']) ? get_custom_base_url() . '/' : '') . $map['path'];
             mail_wrap(array_key_exists('subject', $map) ? $map['subject'] : do_lang('WELCOME'), convert_to_internal_encoding(http_download_file($url)), array($address), array_key_exists('to', $map) ? $map['to'] : '', '', '', 3, NULL, false, NULL, true);
         }
         return do_template('BLOCK_MAIN_NEWSLETTER_SIGNUP_DONE', array('_GUID' => '9953c83685df4970de8f23fcd5dd15bb', 'NEWSLETTER_TITLE' => $newsletter_title, 'NID' => strval($newsletter_id), 'PASSWORD' => $password));
     } else {
         return do_template('BLOCK_MAIN_NEWSLETTER_SIGNUP', array('NEWSLETTER_TITLE' => $newsletter_title, 'NID' => strval($newsletter_id), 'URL' => get_self_url()));
     }
 }
Esempio n. 27
0
 /**
  * Standard modular run function.
  *
  * @param  array		A map of parameters.
  * @return tempcode	The result of execution.
  */
 function run($map)
 {
     $file = array_key_exists('param', $map) ? $map['param'] : 'admin_notes';
     $title = array_key_exists('title', $map) ? $map['title'] : do_lang('NOTES');
     $scrolls = array_key_exists('scrolls', $map) ? $map['scrolls'] : '0';
     $new = post_param('new', NULL);
     if (!is_null($new)) {
         set_long_value('note_text_' . $file, $new);
         log_it('NOTES', $file);
         attach_message(do_lang_tempcode('SUCCESS'), 'inform');
     }
     $contents = get_long_value('note_text_' . $file);
     if (is_null($contents)) {
         $contents = '';
     }
     $post_url = get_self_url();
     $map_comcode = '';
     foreach ($map as $key => $val) {
         $map_comcode .= ' ' . $key . '="' . addslashes($val) . '"';
     }
     return do_template('BLOCK_MAIN_NOTES', array('_GUID' => '2a9e1c512b66600583735552b56e0911', 'TITLE' => $title, 'BLOCK_NAME' => 'main_db_notes', 'MAP' => $map_comcode, 'SCROLLS' => array_key_exists('scrolls', $map) && $map['scrolls'] == '1', 'CONTENTS' => $contents, 'URL' => $post_url));
 }
Esempio n. 28
0
 /**
  * Standard modular run function for preview hooks.
  *
  * @return array			A pair: The preview, the updated post Comcode
  */
 function run()
 {
     require_code('uploads');
     require_lang('banners');
     // Check according to banner type
     $title_text = post_param('title_text', '');
     $direct_code = post_param('direct_code', '');
     $url_param_name = 'image_url';
     $file_param_name = 'file';
     require_code('uploads');
     $is_upload = is_swf_upload() || array_key_exists($file_param_name, $_FILES) && (array_key_exists('tmp_name', $_FILES[$file_param_name]) && is_uploaded_file($_FILES[$file_param_name]['tmp_name']));
     $_banner_type_rows = $GLOBALS['SITE_DB']->query_select('banner_types', array('*'), array('id' => post_param('b_type')), '', 1);
     if (!array_key_exists(0, $_banner_type_rows)) {
         warn_exit(do_lang_tempcode('MISSING_RESOURCE'));
     }
     $banner_type_row = $_banner_type_rows[0];
     if ($banner_type_row['t_is_textual'] == 0) {
         if ($direct_code == '') {
             $urls = get_url($url_param_name, $file_param_name, 'uploads/banners', 0, $is_upload ? OCP_UPLOAD_IMAGE : OCP_UPLOAD_ANYTHING);
             $img_url = fixup_protocolless_urls($urls[0]);
             if ($img_url == '') {
                 warn_exit(do_lang_tempcode('IMPROPERLY_FILLED_IN_UPLOAD_BANNERS'));
             }
         } else {
             $img_url = '';
         }
     } else {
         $img_url = '';
         if ($title_text == '') {
             warn_exit(do_lang_tempcode('IMPROPERLY_FILLED_IN_BANNERS'));
         }
         if (strlen($title_text) > $banner_type_row['t_max_file_size']) {
             warn_exit(do_lang_tempcode('BANNER_TOO_LARGE_2', integer_format(strlen($title_text)), integer_format($banner_type_row['t_max_file_size'])));
         }
     }
     require_code('banners');
     $preview = show_banner(post_param('name'), post_param('title_text', ''), comcode_to_tempcode(post_param('caption')), $img_url, '', post_param('site_url'), post_param('b_type'));
     return array($preview, NULL);
 }
Esempio n. 29
0
/**
 * Move a menu branch.
 */
function menu_management_script()
{
    $id = get_param_integer('id');
    $to_menu = get_param('menu');
    $changes = array('i_menu' => $to_menu);
    $rows = $GLOBALS['SITE_DB']->query_select('menu_items', array('*'), array('id' => $id), '', 1);
    if (array_key_exists(0, $rows)) {
        $row = $rows[0];
    } else {
        $row = NULL;
    }
    $test = false;
    foreach (array_keys($test ? $_GET : $_POST) as $key) {
        $val = $test ? get_param($key) : post_param($key);
        $key = preg_replace('#\\_\\d+$#', '', $key);
        if ($key == 'caption' || $key == 'caption_long') {
            if (is_null($row)) {
                $changes['i_' . $key] = insert_lang($val, 2);
            } else {
                lang_remap($row['i_' . $key], $val);
            }
        } elseif ($key == 'url' || $key == 'theme_img_code') {
            $changes['i_' . $key] = $val;
        } elseif ($key == 'match_tags') {
            $changes['i_page_only'] = $val;
        }
    }
    $changes['i_order'] = post_param_integer('order_' . strval($id), 0);
    $changes['i_new_window'] = post_param_integer('new_window_' . strval($id), 0);
    $changes['i_check_permissions'] = post_param_integer('check_perms_' . strval($id), 0);
    $changes['i_expanded'] = 0;
    $changes['i_parent'] = NULL;
    if (is_null($row)) {
        $GLOBALS['SITE_DB']->query_insert('menu_items', $changes);
    } else {
        $GLOBALS['SITE_DB']->query_update('menu_items', $changes, array('id' => $id), '', 1);
    }
}
Esempio n. 30
0
 /**
  * Try and authenticate for our password compatibility scheme.
  *
  * @param  ?SHORT_TEXT	The member username (NULL: don't use this in the authentication - but look it up using the ID if needed)
  * @param  ?MEMBER		The member id (NULL: use member name)
  * @param  MD5				The md5-hashed password
  * @param  string			The raw password
  * @param  boolean		Whether this is a cookie login
  * @param  array			Row of OCF account
  * @return ?tempcode		Error message (NULL: none)
  */
 function auth($username, $userid, $password_hashed, $password_raw, $cookie_login, $row)
 {
     if ($cookie_login) {
         if ($row['m_pass_hash_salted'] != $password_hashed) {
             return do_lang_tempcode('USER_BAD_PASSWORD');
         }
     } else {
         $usr = strtolower(post_param('login_username', NULL));
         //prepare inputted username
         $passwrd = strtr(stripslashes(post_param('password', NULL)), array_flip(get_html_translation_table(HTML_SPECIALCHARS, ENT_QUOTES)) + array('&#039;' => '\'', '&nbsp;' => ' '));
         //prepare inputted password
         if (function_exists('sha1')) {
             if (sha1($usr . $passwrd) != $row['m_pass_hash_salted']) {
                 return do_lang_tempcode('USER_BAD_PASSWORD');
             }
         } else {
             if (md5($usr . $passwrd) != $row['m_pass_hash_salted']) {
                 return do_lang_tempcode('USER_BAD_PASSWORD');
             }
         }
     }
     return NULL;
 }