/** * URL'ise specially encoded text-acceptance language strings. * * @param string The language string * @param mixed The URL (either tempcode or string) * @param string The title of the hyperlink * @param boolean Whether to use a new window * @return tempcode The encoded version */ function _urlise_lang($string, $url, $title, $new_window) { $a = strpos($string, '<{'); $b = strpos($string, '}>'); if ($a === false || $b === false || $b < $a) { return make_string_tempcode($string); } $section = substr($string, $a + 2, $b - $a - 2); $prior = substr($string, 0, $a); $after = substr($string, $b + 2); if ($GLOBALS['XSS_DETECT']) { ocp_mark_as_escaped($section); ocp_mark_as_escaped($prior); ocp_mark_as_escaped($after); } if (is_string($url)) { if ($url == '') { return protect_from_escaping($section); } } else { if ($url->is_empty()) { return protect_from_escaping($section); } } $out = new ocp_tempcode(); $out->attach(protect_from_escaping($prior)); $out->attach(hyperlink($url, protect_from_escaping($section), $new_window, false, $title)); $out->attach(protect_from_escaping($after)); return $out; }
/** * Standard modular run function for do_next_menu hooks. They find links to put on standard navigation menus of the system. * * @return array Array of links and where to show */ function run() { if (!addon_installed('quizzes')) { return array(); } return array(array('usage', 'quiz', array('admin_quiz', array('type' => 'misc'), get_module_zone('admin_quiz')), do_lang_tempcode('QUIZZES'), 'DOC_QUIZZES'), array('cms', 'quiz', array('cms_quiz', array('type' => 'misc'), get_module_zone('cms_quiz')), do_lang_tempcode('ITEMS_HERE', do_lang_tempcode('QUIZZES'), make_string_tempcode(escape_html(integer_format($GLOBALS['SITE_DB']->query_value_null_ok('quizzes', 'COUNT(*)', NULL, '', true))))), 'DOC_QUIZZES')); }
/** * Check a post would be valid. * * @param LONG_TEXT The post. * @param ?AUTO_LINK The ID of the topic the post would be in (NULL: don't check with regard to any particular topic). * @param ?MEMBER The poster (NULL: current member). * @return ?array Row of the existing post if a double post (single row map-element in a list of rows) (NULL: not a double post). */ function ocf_check_post($post, $topic_id = NULL, $poster = NULL) { if (is_null($poster)) { $poster = get_member(); } require_code('comcode_check'); check_comcode($post, NULL, false, NULL, true); if (strlen($post) == 0) { warn_exit(do_lang_tempcode('POST_TOO_SHORT')); } require_code('ocf_groups'); if (strlen($post) > ocf_get_member_best_group_property($poster, 'max_post_length_comcode')) { warn_exit(make_string_tempcode(escape_html(do_lang('_POST_TOO_LONG')))); } if (!is_null($topic_id)) { if (running_script('stress_test_loader')) { return NULL; } // Check this isn't the same as the last post here $last_posts = $GLOBALS['FORUM_DB']->query_select('f_posts', array('p_post', 'p_poster', 'p_ip_address'), array('p_topic_id' => $topic_id), 'ORDER BY p_time DESC,id DESC', 1); if (array_key_exists(0, $last_posts)) { if ($last_posts[0]['p_poster'] == $GLOBALS['OCF_DRIVER']->get_guest_id() && get_ip_address() != $last_posts[0]['p_ip_address']) { $last_posts[0]['p_poster'] = -1; } if ($last_posts[0]['p_poster'] == $poster && get_translated_text($last_posts[0]['p_post'], $GLOBALS['FORUM_DB']) == $post && get_param_integer('keep_debug_notifications', 0) != 1) { warn_exit(do_lang_tempcode('DOUBLE_POST_PREVENTED')); } } return $last_posts; } return NULL; }
/** * Standard modular run function for do_next_menu hooks. They find links to put on standard navigation menus of the system. * * @return array Array of links and where to show */ function run() { if (!addon_installed('galleries')) { return array(); } return array(array('cms', 'galleries', array('cms_galleries', array('type' => 'misc'), get_module_zone('cms_galleries')), do_lang_tempcode('ITEMS_HERE', do_lang_tempcode('GALLERIES'), make_string_tempcode(escape_html(integer_format($GLOBALS['SITE_DB']->query_value_null_ok('images', 'COUNT(*)', NULL, '', true) + $GLOBALS['SITE_DB']->query_value_null_ok('videos', 'COUNT(*)', NULL, '', true))))), 'DOC_GALLERIES')); }
/** * Convert a field value to something renderable. * * @param array The field details * @param mixed The raw value * @return mixed Rendered field (tempcode or string) */ function render_field_value($field, $ev) { if (is_object($ev)) { return $ev; } return make_string_tempcode(nl2br(escape_html($ev))); }
/** * Standard modular run function for do_next_menu hooks. They find links to put on standard navigation menus of the system. * * @return array Array of links and where to show */ function run() { if (!addon_installed('chat')) { return array(); } return array(array('cms', 'chatrooms', array('cms_chat', array('type' => 'misc'), get_module_zone('cms_chat')), do_lang_tempcode('ITEMS_HERE', do_lang_tempcode('ROOMS'), make_string_tempcode(escape_html(integer_format($GLOBALS['SITE_DB']->query_value_null_ok('chat_rooms', 'COUNT(*)', NULL, '', true))))), 'DOC_CHAT'), array('structure', 'chatrooms', array('admin_chat', array('type' => 'misc'), get_module_zone('admin_chat')), do_lang_tempcode('ROOMS'), 'DOC_CHAT')); }
/** * Standard modular run function for do_next_menu hooks. They find links to put on standard navigation menus of the system. * * @return array Array of links and where to show */ function run() { if (!addon_installed('calendar')) { return array(); } return array(array('cms', 'calendar', array('cms_calendar', array('type' => 'misc'), get_module_zone('cms_calendar')), do_lang_tempcode('ITEMS_HERE', do_lang_tempcode('CALENDAR'), make_string_tempcode(escape_html(integer_format($GLOBALS['SITE_DB']->query_value_null_ok('calendar_events', 'COUNT(*)', NULL, '', true))))), 'DOC_CALENDAR')); }
/** * 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())); }
/** * Standard modular run function. * * @return tempcode The result of execution. */ function run() { require_javascript('javascript_realtime_rain'); require_javascript('javascript_ajax'); require_javascript('javascript_more'); require_lang('realtime_rain'); require_css('realtime_rain'); $title = get_page_title('REALTIME_RAIN'); if (!has_js()) { // Send them to the page permissions screen $url = build_url(array('page' => 'admin_stats', 'type' => 'misc'), '_SELF'); require_code('site2'); assign_refresh($url, 5.0); return do_template('REDIRECT_SCREEN', array('URL' => $url, 'TITLE' => $title, 'TEXT' => do_lang_tempcode('NO_JS_REALTIME'))); } $GLOBALS['TEMPCODE_SETGET']['chrome_frame'] = make_string_tempcode('1'); if (browser_matches('ie6')) { attach_message(do_lang_tempcode('IE_OLD_PLEASE_UPGRADE'), 'warn'); } if (!has_js()) { // Send them to the stats screen $url = build_url(array('page' => 'admin_stats', 'type' => 'misc'), '_SELF'); require_code('site2'); assign_refresh($url, 5.0); return do_template('REDIRECT_SCREEN', array('URL' => $url, 'TITLE' => $title, 'TEXT' => do_lang_tempcode('NO_JS_ADVANCED_SCREEN_REALTIME_RAIN'))); } $min_time = $GLOBALS['SITE_DB']->query_value('stats', 'MIN(date_and_time)'); if (is_null($min_time)) { $min_time = time(); } return do_template('REALTIME_RAIN_OVERLAY', array('MIN_TIME' => strval($min_time))); }
/** * Standard modular run function. * * @param array A map of parameters. * @return tempcode The result of execution. */ function run($map) { require_code('downloads'); require_css('downloads'); require_lang('downloads'); require_code('ocfiltering'); $number = array_key_exists('param', $map) ? intval($map['param']) : 10; $filter = array_key_exists('filter', $map) ? $map['filter'] : '*'; $zone = array_key_exists('zone', $map) ? $map['zone'] : get_module_zone('downloads'); $sql_filter = ocfilter_to_sqlfragment($filter, 'p.category_id', 'download_categories', 'parent_id', 'p.category_id', 'id'); // Note that the parameters are fiddled here so that category-set and record-set are the same, yet SQL is returned to deal in an entirely different record-set (entries' record-set) $rows = $GLOBALS['SITE_DB']->query('SELECT * FROM ' . get_table_prefix() . 'download_downloads p WHERE validated=1 AND (' . $sql_filter . ') ORDER BY add_date DESC', $number); $title = do_lang_tempcode('RECENT', make_string_tempcode(integer_format($number)), do_lang_tempcode('SECTION_DOWNLOADS')); if (array_key_exists('title', $map) && $map['title'] != '') { $title = protect_from_escaping(escape_html($map['title'])); } $out = new ocp_tempcode(); foreach ($rows as $i => $row) { if ($i != 0) { $out->attach(do_template('BLOCK_SEPARATOR')); } $out->attach(get_download_html($row, true, true, $zone)); } if ($out->is_empty()) { if (has_actual_page_access(NULL, 'cms_downloads', NULL, NULL) && has_submit_permission('mid', get_member(), get_ip_address(), 'cms_downloads')) { $submit_url = build_url(array('page' => 'cms_downloads', 'type' => 'ad', 'redirect' => SELF_REDIRECT), get_module_zone('cms_downloads')); } else { $submit_url = new ocp_tempcode(); } return do_template('BLOCK_NO_ENTRIES', array('_GUID' => '74399763a51102bdd6e6d92c2c11354f', 'HIGH' => false, 'TITLE' => $title, 'MESSAGE' => do_lang_tempcode('NO_DOWNLOADS_YET'), 'ADD_NAME' => do_lang_tempcode('ADD_DOWNLOAD'), 'SUBMIT_URL' => $submit_url)); } return do_template('BLOCK_MAIN_RECENT_DOWNLOADS', array('_GUID' => '257fa1b83d1b6fe3acbceb2b618e6d7f', 'TITLE' => $title, 'CONTENT' => $out, 'NUMBER' => integer_format($number))); }
/** * Standard modular run function for do_next_menu hooks. They find links to put on standard navigation menus of the system. * * @return array Array of links and where to show */ function run() { if (!addon_installed('downloads')) { return array(); } return array(array('cms', 'downloads', array('cms_downloads', array('type' => 'misc'), get_module_zone('cms_downloads')), do_lang_tempcode('ITEMS_HERE', do_lang_tempcode('SECTION_DOWNLOADS'), make_string_tempcode(escape_html(integer_format($GLOBALS['SITE_DB']->query_value_null_ok('download_downloads', 'COUNT(*)', NULL, '', true))))), 'DOC_DOWNLOADS')); }
/** * Standard modular run function for do_next_menu hooks. They find links to put on standard navigation menus of the system. * * @param boolean Whether to look deep into the database (or whatever else might be time-intensive) for links * @return array Array of links and where to show */ function run($exhaustive = false) { if (!addon_installed('catalogues')) { return array(); } $ret = array(); if (has_specific_permission(get_member(), 'submit_cat_highrange_content', 'cms_catalogues')) { $ret[] = array('cms', 'catalogues', array('cms_catalogues', array('type' => 'misc'), get_module_zone('cms_catalogues')), do_lang_tempcode('ITEMS_HERE', do_lang_tempcode('CATALOGUES'), make_string_tempcode(escape_html(integer_format($GLOBALS['SITE_DB']->query_value_null_ok('catalogues', 'COUNT(*)', NULL, '', true))))), 'DOC_CATALOGUES'); } if ($exhaustive) { $catalogues = $GLOBALS['SITE_DB']->query_select('catalogues', array('c_name', 'c_title', 'c_description', 'c_ecommerce'), NULL, '', 10, NULL, true); if (!is_null($catalogues)) { $ret2 = array(); foreach ($catalogues as $row) { if (substr($row['c_name'], 0, 1) == '_') { continue; } if ($row['c_ecommerce'] == 0 || addon_installed('shopping')) { if (has_submit_permission('mid', get_member(), get_ip_address(), 'cms_catalogues', array('catalogues_catalogue', $row['c_name']))) { $ret2[] = array('cms', 'of_catalogues', array('cms_catalogues', array('type' => 'misc', 'catalogue_name' => $row['c_name']), get_module_zone('cms_catalogues')), do_lang_tempcode('ITEMS_HERE', escape_html(get_translated_text($row['c_title'])), escape_html(integer_format($GLOBALS['SITE_DB']->query_value_null_ok('catalogue_entries', 'COUNT(*)', array('c_name' => $row['c_name']), '', true)))), get_translated_text($row['c_description'])); } } } if (count($ret2) < 10) { $ret = array_merge($ret, $ret2); } } } return $ret; }
/** * Standard modular run function for do_next_menu hooks. They find links to put on standard navigation menus of the system. * * @return array Array of links and where to show */ function run() { // TODO: Make workflows register itself in the addon registry //if (!addon_installed('workflows')) return array(); require_lang('workflows'); return array(array('cms', 'workflows', array('admin_workflow', array('type' => 'misc'), get_module_zone('admin_workflow')), do_lang_tempcode('ITEMS_HERE', do_lang_tempcode('WORKFLOWS'), make_string_tempcode(escape_html(integer_format($GLOBALS['SITE_DB']->query_value('workflow_requirements', 'COUNT(DISTINCT workflow_name)'))))), 'DOC_WORKFLOWS')); }
/** * Standard modular render function for profile tab hooks. * * @param MEMBER The ID of the member who is being viewed * @param MEMBER The ID of the member who is doing the viewing * @param boolean Whether to leave the tab contents NULL, if tis hook supports it, so that AJAX can load it later * @return array A triple: The tab title, the tab contents, the suggested tab order */ function render_tab($member_id_of, $member_id_viewing, $leave_to_ajax_if_possible = false) { $title = do_lang_tempcode('MODULE_TRANS_NAME_warnings'); $order = 80; if ($leave_to_ajax_if_possible) { return array($title, NULL, $order); } require_lang('ocf'); require_css('ocf'); $warnings = new ocp_tempcode(); $rows = $GLOBALS['FORUM_DB']->query_select('f_warnings', array('*'), array('w_member_id' => $member_id_of, 'w_is_warning' => 1)); foreach ($rows as $row) { $warning_by = $GLOBALS['FORUM_DRIVER']->member_profile_hyperlink($row['w_by']); $date = get_timezoned_date($row['w_time']); if ($row['w_explanation'] == '') { $row['w_explanation'] = '?'; } else { $row['w_explanation'] = str_replace(chr(10), ' ', $row['w_explanation']); } $row['w_explanation_orig'] = $row['w_explanation']; if (strlen($row['w_explanation']) > 30) { $row['w_explanation'] = substr($row['w_explanation'], 0, 27) . '...'; } $explanation = hyperlink(build_url(array('page' => 'warnings', 'type' => '_ed', 'id' => $row['id'], 'redirect' => get_self_url(true)), get_module_zone('warnings')), $row['w_explanation'], false, true, $row['w_explanation_orig']); $warnings->attach(paragraph(do_lang_tempcode('MEMBER_WARNING', $explanation, $warning_by, array(make_string_tempcode(escape_html($date)))), 'treyerhy34y')); } $content = do_template('OCF_MEMBER_PROFILE_WARNINGS', array('MEMBER_ID' => strval($member_id_of), 'WARNINGS' => $warnings)); return array($title, $content, $order); }
/** * Standard modular run function for snippet hooks. Generates XHTML to insert into a page using AJAX. * * @return tempcode The snippet */ function run() { $val = get_param('name'); $test = file_exists(get_file_base() . '/themes/' . $val) || file_exists(get_custom_file_base() . '/themes/' . $val); if (!$test) { return new ocp_tempcode(); } return make_string_tempcode(str_replace(array('‘', '’', '“', '”'), array('"', '"', '"', '"'), html_entity_decode(do_lang('ALREADY_EXISTS', escape_html($val)), ENT_QUOTES))); }
/** * Standard modular run function for snippet hooks. Generates XHTML to insert into a page using AJAX. * * @return tempcode The snippet */ function run() { $val = get_param('name'); $test = $GLOBALS['FORUM_DB']->query_value_null_ok('f_groups g LEFT JOIN ' . $GLOBALS['FORUM_DB']->get_table_prefix() . 'translate t ON g.g_name=t.id WHERE ' . db_string_equal_to('text_original', $val), 'g.id'); if (is_null($test)) { return new ocp_tempcode(); } return make_string_tempcode(str_replace(array('‘', '’', '“', '”'), array('"', '"', '"', '"'), html_entity_decode(do_lang('ALREADY_EXISTS', escape_html($val)), ENT_QUOTES))); }
/** * Standard modular run function for snippet hooks. Generates XHTML to insert into a page using AJAX. * * @return tempcode The snippet */ function run() { $val = get_param('name'); require_code('captcha'); if (check_captcha($val)) { return new ocp_tempcode(); } return make_string_tempcode(str_replace(array('‘', '’', '“', '”'), array('"', '"', '"', '"'), html_entity_decode(do_lang('INVALID_SECURITY_CODE_ENTERED'), ENT_QUOTES))); }
/** * Standard modular run function for snippet hooks. Generates XHTML to insert into a page using AJAX. * * @return tempcode The snippet */ function run() { $val = get_param('name'); $test = $GLOBALS['SITE_DB']->query_value_null_ok('banner_types', 'id', array('id' => $val)); if (is_null($test)) { return new ocp_tempcode(); } return make_string_tempcode(str_replace(array('‘', '’', '“', '”'), array('"', '"', '"', '"'), html_entity_decode(do_lang('ALREADY_EXISTS', escape_html($val)), ENT_QUOTES))); }
/** * Standard modular run function for do_next_menu hooks. They find links to put on standard navigation menus of the system. * * @return array Array of links and where to show */ function run() { if (!addon_installed('news')) { return array(); } $cnt = $GLOBALS['SITE_DB']->query_value_null_ok('news', 'COUNT(*)', NULL, '', true); $cnt_blogs = $cnt - $GLOBALS['SITE_DB']->query_value_null_ok('news n LEFT JOIN ' . get_table_prefix() . 'news_categories c ON c.id=n.news_category', 'COUNT(*)', array('nc_owner' => NULL), '', true); return array(array('cms', 'news', array('cms_news', array('type' => 'misc'), get_module_zone('cms_news')), do_lang_tempcode('ITEMS_HERE', do_lang_tempcode('NEWS'), make_string_tempcode(escape_html(integer_format($cnt)))), 'DOC_NEWS'), array('cms', 'news', array('cms_blogs', array('type' => 'misc'), get_module_zone('cms_blogs')), do_lang_tempcode('ITEMS_HERE', do_lang_tempcode('BLOGS'), make_string_tempcode(escape_html(integer_format($cnt_blogs)))), 'DOC_BLOGS')); }
/** * Standard modular run function for snippet hooks. Generates XHTML to insert into a page using AJAX. * * @return tempcode The snippet */ function run() { $val = get_param('name'); $test = $GLOBALS['FORUM_DB']->query_value_null_ok('f_invites', 'i_email_address', array('i_email_address' => $val, 'i_taken' => 0)); if (!is_null($test)) { return new ocp_tempcode(); } return make_string_tempcode(str_replace(array('‘', '’', '“', '”'), array('"', '"', '"', '"'), html_entity_decode(do_lang('NO_INVITE'), ENT_QUOTES))); }
/** * 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; }
/** * Standard modular run function for snippet hooks. Generates XHTML to insert into a page using AJAX. * * @return tempcode The snippet */ function run() { $val = get_param('name'); $test = $GLOBALS['FORUM_DB']->query_value_null_ok('f_emoticons', 'e_code', array('e_code' => $val)); if (is_null($test)) { return new ocp_tempcode(); } require_lang('ocf'); return make_string_tempcode(strip_tags(str_replace(array('‘', '’', '“', '”'), array('"', '"', '"', '"'), html_entity_decode(do_lang('CONFLICTING_EMOTICON_CODE', escape_html($val)), ENT_QUOTES)))); }
/** * Standard modular run function for snippet hooks. Generates XHTML to insert into a page using AJAX. * * @return tempcode The snippet */ function run() { $val = get_param('name'); $test = $GLOBALS['FORUM_DB']->query_value_null_ok('f_members', 'm_username', array('m_email_address' => $val)); if (is_null($test)) { return new ocp_tempcode(); } require_lang('ocf'); return make_string_tempcode(strip_tags(str_replace(array('‘', '’', '“', '”'), array('"', '"', '"', '"'), html_entity_decode(do_lang('EMAIL_ADDRESS_IN_USE', escape_html(get_site_name())), ENT_QUOTES)))); }
/** * Get the tempcode for a table row. * * @param array The array of values that make up this row * @param boolean Whether to add escaping * @return tempcode The generated row */ function table_table_row($values, $escape = false) { $cells = new ocp_tempcode(); foreach ($values as $value) { if ($escape && (!is_object($value) || $value->pure_lang !== true)) { $value = make_string_tempcode(escape_html(is_object($value) ? $value->evaluate() : $value)); } $cells->attach(do_template('TABLE_TABLE_ROW_CELL', array('_GUID' => '700a982eb2262149295816ddee91b0e7', 'VALUE' => $value))); } return do_template('TABLE_TABLE_ROW', array('_GUID' => 'a4efacc07ecb165e37c355559f476ae9', 'CELLS' => $cells)); }
/** * Standard modular bind function for comcode link handler hooks. They see if they can bind a pasted URL to a lump of handler Tempcode. * * @param URLPATH Link to use or reject * @param string Title for what is at the other end of the link (was found by downloading and looking for <title>) * @param boolean Whether we are allowed to proceed even if this tag is marked as 'dangerous' * @param string A special identifier to mark where the resultant tempcode is going to end up (e.g. the ID of a post) * @param integer The position this tag occurred at in the Comcode * @param MEMBER The member who is responsible for this Comcode * @param boolean Whether to check as arbitrary admin * @param object The database connection to use * @param string The whole chunk of comcode * @param boolean Whether this is for WML output * @param boolean Whether this is only a structure sweep * @param boolean Whether we are in semi-parse-mode (some tags might convert differently) * @param ?array A list of words to highlight (NULL: none) * @return ?tempcode Handled link (NULL: reject due to inappropriate link pattern) */ function bind($link, $link_captions_title, $comcode_dangerous, $pass_id, $pos, $source_member, $as_admin, $connection, $comcode, $wml, $structure_sweep, $semiparse_mode, $highlight_bits) { if (preg_match('#.mp3$#', $link) != 0) { global $IMPORTED_CUSTOM_COMCODE; if (!$IMPORTED_CUSTOM_COMCODE) { _custom_comcode_import($connection); } return _do_tags_comcode('flash', array('param' => '400x60'), make_string_tempcode($link . '#.mp4'), $comcode_dangerous, $pass_id, $pos, $source_member, $as_admin, $connection, $comcode, $wml, $structure_sweep, $semiparse_mode, $highlight_bits); } return NULL; }
/** * Standard modular bind function for comcode link handler hooks. They see if they can bind a pasted URL to a lump of handler Tempcode. * * @param URLPATH Link to use or reject * @param string Title for what is at the other end of the link (was found by downloading and looking for <title>) * @param boolean Whether we are allowed to proceed even if this tag is marked as 'dangerous' * @param string A special identifier to mark where the resultant tempcode is going to end up (e.g. the ID of a post) * @param integer The position this tag occurred at in the Comcode * @param MEMBER The member who is responsible for this Comcode * @param boolean Whether to check as arbitrary admin * @param object The database connection to use * @param string The whole chunk of comcode * @param boolean Whether this is for WML output * @param boolean Whether this is only a structure sweep * @param boolean Whether we are in semi-parse-mode (some tags might convert differently) * @param ?array A list of words to highlight (NULL: none) * @return ?tempcode Handled link (NULL: reject due to inappropriate link pattern) */ function bind($link, $link_captions_title, $comcode_dangerous, $pass_id, $pos, $source_member, $as_admin, $connection, $comcode, $wml, $structure_sweep, $semiparse_mode, $highlight_bits) { if (preg_match('#^http://www\\.facebook\\.com/video/video\\.php\\?v=(\\w+)#', $link) != 0) { global $IMPORTED_CUSTOM_COMCODE; if (!$IMPORTED_CUSTOM_COMCODE) { _custom_comcode_import($connection); } return _do_tags_comcode('facebook_video', array(), make_string_tempcode($link), $comcode_dangerous, $pass_id, $pos, $source_member, $as_admin, $connection, $comcode, $wml, $structure_sweep, $semiparse_mode, $highlight_bits); } return NULL; }
/** * Standard modular bind function for comcode link handler hooks. They see if they can bind a pasted URL to a lump of handler Tempcode. * * @param URLPATH Link to use or reject * @param string Title for what is at the other end of the link (was found by downloading and looking for <title>) * @param boolean Whether we are allowed to proceed even if this tag is marked as 'dangerous' * @param string A special identifier to mark where the resultant tempcode is going to end up (e.g. the ID of a post) * @param integer The position this tag occurred at in the Comcode * @param MEMBER The member who is responsible for this Comcode * @param boolean Whether to check as arbitrary admin * @param object The database connection to use * @param string The whole chunk of comcode * @param boolean Whether this is for WML output * @param boolean Whether this is only a structure sweep * @param boolean Whether we are in semi-parse-mode (some tags might convert differently) * @param ?array A list of words to highlight (NULL: none) * @return ?tempcode Handled link (NULL: reject due to inappropriate link pattern) */ function bind($link, $link_captions_title, $comcode_dangerous, $pass_id, $pos, $source_member, $as_admin, $connection, $comcode, $wml, $structure_sweep, $semiparse_mode, $highlight_bits) { if (preg_match('#^https?://www\\.youtube\\.com/watch\\?v=([\\w\\-]+)#', $link) != 0 || preg_match('#^https?://youtu\\.be/([\\w\\-]+)#', $link) != 0) { global $IMPORTED_CUSTOM_COMCODE; if (!$IMPORTED_CUSTOM_COMCODE) { _custom_comcode_import($connection); } return _do_tags_comcode('youtube', array(), make_string_tempcode($link), $comcode_dangerous, $pass_id, $pos, $source_member, $as_admin, $connection, $comcode, $wml, $structure_sweep, $semiparse_mode, $highlight_bits); } return NULL; }
/** * Standard modular bind function for comcode link handler hooks. They see if they can bind a pasted URL to a lump of handler Tempcode. * * @param URLPATH Link to use or reject * @param string Title for what is at the other end of the link (was found by downloading and looking for <title>) * @param boolean Whether we are allowed to proceed even if this tag is marked as 'dangerous' * @param string A special identifier to mark where the resultant tempcode is going to end up (e.g. the ID of a post) * @param integer The position this tag occurred at in the Comcode * @param MEMBER The member who is responsible for this Comcode * @param boolean Whether to check as arbitrary admin * @param object The database connection to use * @param string The whole chunk of comcode * @param boolean Whether this is for WML output * @param boolean Whether this is only a structure sweep * @param boolean Whether we are in semi-parse-mode (some tags might convert differently) * @param ?array A list of words to highlight (NULL: none) * @return ?tempcode Handled link (NULL: reject due to inappropriate link pattern) */ function bind($link, $link_captions_title, $comcode_dangerous, $pass_id, $pos, $source_member, $as_admin, $connection, $comcode, $wml, $structure_sweep, $semiparse_mode, $highlight_bits) { $matches = array(); if (preg_match('#^http://(edition\\.)?cnn\\.com/video/[\\#\\?]/(video/)?([\\w/\\.]+)#', $link, $matches) != 0) { global $IMPORTED_CUSTOM_COMCODE; if (!$IMPORTED_CUSTOM_COMCODE) { _custom_comcode_import($connection); } return _do_tags_comcode('cnn_video', array(), make_string_tempcode($link), $comcode_dangerous, $pass_id, $pos, $source_member, $as_admin, $connection, $comcode, $wml, $structure_sweep, $semiparse_mode, $highlight_bits); } return NULL; }
/** * 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); }
/** * Standard modular run function for snippet hooks. Generates XHTML to insert into a page using AJAX. * * @return tempcode The snippet */ function run() { $zone = get_param('name'); $test = file_exists(get_file_base() . '/' . $zone); if (!$test) { return new ocp_tempcode(); } $test = $GLOBALS['SITE_DB']->query_value_null_ok('zones', 'zone_header_text', array('zone_name' => $zone)); if (is_null($test)) { return new ocp_tempcode(); } return make_string_tempcode(str_replace(array('‘', '’', '“', '”'), array('"', '"', '"', '"'), html_entity_decode(do_lang('ALREADY_EXISTS', escape_html($zone)), ENT_QUOTES))); }