本文整理汇总了PHP中get_site_default_lang函数的典型用法代码示例。如果您正苦于以下问题:PHP get_site_default_lang函数的具体用法?PHP get_site_default_lang怎么用?PHP get_site_default_lang使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了get_site_default_lang函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: run
/**
* Standard modular run function for newsletter hooks.
*
* @param TIME The time that the entries found must be newer than
* @param LANGUAGE_NAME The language the entries found must be in
* @param string Category filter to apply
* @return array Tuple of result details
*/
function run($cutoff_time, $lang, $filter)
{
$new = new ocp_tempcode();
require_code('ocfiltering');
if ($filter == '') {
$filter = ',';
}
// Just welcome zone
$or_list = ocfilter_to_sqlfragment($filter, 'b.the_zone', NULL, NULL, NULL, NULL, false);
$_rows = $GLOBALS['SITE_DB']->query('SELECT a.* FROM ' . get_table_prefix() . 'cached_comcode_pages a JOIN ' . get_table_prefix() . 'comcode_pages b ON a.the_page=b.the_page AND a.the_zone=b.the_zone WHERE p_add_date>' . strval($cutoff_time) . ' AND (' . $or_list . ')', 300);
if (count($_rows) == 300) {
return array();
}
$rows = array();
foreach ($_rows as $row) {
$rows[$row['the_zone'] . ':' . $row['the_page']] = $row;
}
$_rows2 = $GLOBALS['SITE_DB']->query_select('seo_meta', array('*'), array('meta_for_type' => 'comcode_page'));
$rows2 = array();
foreach ($_rows2 as $row) {
$rows2[$row['meta_for_id']] = $row;
}
$zones = explode(',', $filter);
//find_all_zones();
foreach ($zones as $zone) {
if ($zone == 'cms') {
continue;
}
if ($zone == 'adminzone') {
continue;
}
$pages = find_all_pages($zone, 'comcode_custom/' . get_site_default_lang(), 'txt', false, $cutoff_time);
foreach (array_keys($pages) as $page) {
if (!is_string($page)) {
$page = strval($page);
}
// PHP can be weird when things like '404' are put in arrays
if (substr($page, 0, 6) == 'panel_') {
continue;
}
$id = $zone . ':' . $page;
$_url = build_url(array('page' => $page), $zone, NULL, false, false, true);
$url = $_url->evaluate();
$name = ucfirst(str_replace('_', ' ', $page));
if (array_key_exists($id, $rows)) {
$_name = get_translated_text($rows[$id]['cc_page_title'], NULL, NULL, true);
if (!is_null($_name)) {
$name = $_name;
}
}
$description = '';
$member_id = NULL;
if (array_key_exists($id, $rows2)) {
$description = get_translated_text($rows2[$id]['meta_description']);
}
$new->attach(do_template('NEWSLETTER_NEW_RESOURCE_FCOMCODE', array('_GUID' => '67f165847dacd54d2965686d561b57ee', 'MEMBER_ID' => $member_id, 'URL' => $url, 'NAME' => $name, 'DESCRIPTION' => $description)));
}
}
return array($new, do_lang('PAGES', '', '', '', $lang));
}
示例2: _find_text_file_path
/**
* Helper function for *_text_file
*
* @param string The file name (without .txt)
* @param ?LANGUAGE_NAME The language to load from (NULL: none) (blank: search)
* @return string The path to the file
*/
function _find_text_file_path($codename, $lang)
{
if (is_null($lang)) {
$langs = array('');
} elseif ($lang != '') {
$langs = array($lang);
} else {
$langs = array(user_lang());
if (get_site_default_lang() != user_lang()) {
$langs[] = get_site_default_lang();
}
if (fallback_lang() != get_site_default_lang()) {
$langs[] = fallback_lang();
}
}
$i = 0;
$path = '';
do {
$lang = $langs[$i];
$path = get_custom_file_base() . '/text_custom/' . $lang . '/' . $codename . '.txt';
if (!file_exists($path)) {
$path = get_file_base() . '/text/' . $lang . '/' . $codename . '.txt';
}
$i++;
} while (!file_exists($path) && array_key_exists($i, $langs));
if (!file_exists($path)) {
$path = '';
}
return $path;
}
示例3: applies
/**
* Find whether this preview hook applies.
*
* @return array A pair: The preview, the updated post Comcode
*/
function applies()
{
$member_id = get_param_integer('id', get_member());
$applies = get_param('page', '') == 'admin_ocf_welcome_emails';
if ($applies) {
require_lang('ocf');
require_code('mail');
$subject_tag = post_param('subject');
$message_raw = do_template('NEWSLETTER_DEFAULT', array('CONTENT' => post_param('text'), 'LANG' => get_site_default_lang()));
$to = $GLOBALS['FORUM_DRIVER']->get_member_email_address(get_member());
if ($to == '') {
$to = get_option('staff_address');
}
mail_wrap($subject_tag, $message_raw->evaluate(get_site_default_lang()), array($to), $GLOBALS['FORUM_DRIVER']->get_username(get_member()), '', '', 3, NULL, false, get_member(), true);
}
return array($applies, NULL);
}
示例4: setUp
function setUp()
{
parent::setUp();
require_code('calendar2');
require_code('feedback');
require_code('ocf_posts_action');
require_code('ocf_forum_driver_helper');
require_lang('lang');
$this->event_id = add_calendar_event(8, '1', NULL, 0, 'test_event', '', 3, 1, 2010, 1, 10, 10, 15, 2010, NULL, 1, 1, 19, NULL, 1, 1, 1, 1, 1, '', NULL, 0, NULL, NULL, NULL);
if ('test_event' == get_translated_text($GLOBALS['SITE_DB']->query_value('calendar_events', 'e_title ', array('id' => $this->event_id)))) {
$lang_id = insert_lang_comcode('test_comment_desc_1', 4, $GLOBALS['FORUM_DB']);
$map = array('p_title' => 'test_comment1', 'p_post' => $lang_id, 'p_ip_address' => '127.0.0.1', 'p_time' => time(), 'p_poster' => 0, 'p_poster_name_if_guest' => '', 'p_validated' => 1, 'p_topic_id' => 4, 'p_is_emphasised' => 0, 'p_cache_forum_id' => 4, 'p_last_edit_time' => NULL, 'p_last_edit_by' => NULL, 'p_intended_solely_for' => NULL, 'p_skip_sig' => 0, 'p_parent_id' => NULL);
$this->post_id = $GLOBALS['FORUM_DB']->query_insert('f_posts', $map, true);
}
$rows = $GLOBALS['FORUM_DB']->query('SELECT p_title FROM ' . $GLOBALS['SITE_DB']->get_table_prefix() . 'f_posts p LEFT JOIN ' . $GLOBALS['SITE_DB']->get_table_prefix() . 'translate t ON t.id=p.p_post WHERE t.text_original NOT LIKE \'%' . db_encode_like(do_lang('SPACER_POST_MATCHER', '', '', '', get_site_default_lang()) . '%') . '\' AND ( p.id = ' . strval($this->post_id) . ') ORDER BY p.id');
$title = $rows[0]['p_title'];
// Test the forum was actually created
$this->assertTrue('test_comment1' == $title);
}
示例5: get_products
/**
* 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;
}
示例6: interface_code
//.........这里部分代码省略.........
$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));
}
示例7: confirm_send
/**
* The UI to confirm sending of our newsletter.
*
* @return tempcode The UI
*/
function confirm_send()
{
$title = get_page_title('NEWSLETTER_SEND');
$message = post_param('message');
$subject = post_param('subject');
$lang = choose_language($title);
$template = post_param('template', 'MAIL');
$in_full = post_param_integer('in_full', 0);
$html_only = post_param_integer('html_only', 0);
$from_email = post_param('from_email', '');
$from_name = post_param('from_name', '');
$extra_post_data = array();
require_code('uploads');
if (is_swf_upload(true) && array_key_exists('file', $_FILES) || array_key_exists('file', $_FILES) && is_uploaded_file($_FILES['file']['tmp_name'])) {
$_csv_data = array();
$myfile = fopen($_FILES['file']['tmp_name'], 'rt');
$del = ',';
$csv_test_line = fgetcsv($myfile, 4096, $del);
if (count($csv_test_line) == 1 && strpos($csv_test_line[0], ';') !== false) {
$del = ';';
}
rewind($myfile);
while (($csv_line = fgetcsv($myfile, 4096, $del)) !== false) {
$_csv_data[] = $csv_line;
}
fclose($myfile);
$extra_post_data['csv_data'] = serialize($_csv_data);
}
if (post_param_integer('make_periodic', 0) == 1) {
// We're making a periodic newsletter. Thus we need to pass this info
// through to the next step
$extra_post_data['make_periodic'] = '1';
// Re-generate preview from latest chosen_categories
$message = $this->generate_whats_new_comcode(post_param('chosen_categories', ''), $in_full, $lang, get_input_date('cutoff'));
}
$address = $GLOBALS['FORUM_DRIVER']->get_member_email_address(get_member());
if ($address == '') {
$address = get_option('staff_address');
}
$username = $GLOBALS['FORUM_DRIVER']->get_username(get_member());
$message = newsletter_variable_substitution($message, $subject, '', '', do_lang('UNKNOWN'), $address, 'test', '');
require_code('mail');
require_code('tempcode_compiler');
$in_html = false;
if (strpos($message, '<html') !== false) {
$_preview = template_to_tempcode($message);
$in_html = true;
} else {
$comcode_version = comcode_to_tempcode($message, get_member(), true);
$_preview = do_template('MAIL', array('TITLE' => $subject, 'CSS' => css_tempcode(true, true, $comcode_version->evaluate()), 'LANG' => get_site_default_lang(), 'LOGOURL' => get_logo_url(''), 'CONTENT' => $comcode_version), NULL, false, NULL, '.tpl', 'templates', $GLOBALS['FORUM_DRIVER']->get_theme(''));
$in_html = $html_only == 1;
}
$text_preview = $html_only == 1 ? '' : comcode_to_clean_text(static_evaluate_tempcode(template_to_tempcode($message)));
require_code('mail');
$preview_subject = $subject;
if (post_param_integer('make_periodic', 0) == 1) {
$preview_subject .= ' - ' . get_timezoned_date(time(), false, false, false, true);
}
require_code('comcode_text');
$preview = do_template('NEWSLETTER_CONFIRM_WRAP', array('_GUID' => '02bd5a782620141f8589e647e2c6d90b', 'TEXT_PREVIEW' => $text_preview, 'PREVIEW' => $_preview, 'SUBJECT' => $subject));
mail_wrap($preview_subject, $html_only == 1 ? $_preview->evaluate() : $message, array($address), $username, $from_email, $from_name, 3, NULL, true, NULL, true, $in_html);
breadcrumb_set_parents(array(array('_SELF:_SELF:misc', do_lang_tempcode('MANAGE_NEWSLETTER')), array('_SELF:_SELF:new', do_lang_tempcode('NEWSLETTER_SEND'))));
breadcrumb_set_self(do_lang_tempcode('CONFIRM'));
require_code('templates_confirm_screen');
return form_confirm_screen($title, $preview, 'send', get_param('old_type', 'new'), $extra_post_data);
}
示例8: _helper_make_post_forum_topic
/**
* Makes a post in the specified forum, in the specified topic according to the given specifications. If the topic doesn't exist, it is created along with a spacer-post.
* Spacer posts exist in order to allow staff to delete the first true post in a topic. Without spacers, this would not be possible with most forum systems. They also serve to provide meta information on the topic that cannot be encoded in the title (such as a link to the content being commented upon).
*
* @param object Link to the real forum driver
* @param SHORT_TEXT The forum name
* @param SHORT_TEXT The topic identifier (usually <content-type>_<content-id>)
* @param MEMBER The member ID
* @param LONG_TEXT The post title
* @param LONG_TEXT The post content in Comcode format
* @param string The topic title; must be same as content title if this is for a comment topic
* @param string This is put together with the topic identifier to make a more-human-readable topic title or topic description (hopefully the latter and a $content_title title, but only if the forum supports descriptions)
* @param ?URLPATH URL to the content (NULL: do not make spacer post)
* @param ?TIME The post time (NULL: use current time)
* @param ?IP The post IP address (NULL: use current members IP address)
* @param ?BINARY Whether the post is validated (NULL: unknown, find whether it needs to be marked unvalidated initially). This only works with the OCF driver.
* @param ?BINARY Whether the topic is validated (NULL: unknown, find whether it needs to be marked unvalidated initially). This only works with the OCF driver.
* @param boolean Whether to skip post checks
* @param SHORT_TEXT The name of the poster
* @param ?AUTO_LINK ID of post being replied to (NULL: N/A)
* @param boolean Whether the reply is only visible to staff
* @param ?ID_TEXT DO NOT send notifications to: The notification code (NULL: no restriction)
* @param ?SHORT_TEXT DO NOT send notifications to: The category within the notification code (NULL: none / no restriction)
* @return array Topic ID (may be NULL), and whether a hidden post has been made
*/
function _helper_make_post_forum_topic($this_ref, $forum_name, $topic_identifier, $member_id, $post_title, $post, $content_title, $topic_identifier_encapsulation_prefix, $content_url, $time, $ip, $validated, $topic_validated, $skip_post_checks, $poster_name_if_guest, $parent_id, $staff_only, $no_notify_for__notification_code, $no_notify_for__code_category)
{
if (is_null($time)) {
$time = time();
}
if (is_null($ip)) {
$ip = get_ip_address();
}
require_code('comcode_check');
check_comcode($post, NULL, false, NULL, true);
require_code('ocf_topics');
require_code('ocf_posts');
//require_code('ocf_forums');
require_lang('ocf');
require_code('ocf_posts_action');
require_code('ocf_posts_action2');
if (!is_integer($forum_name)) {
$forum_id = $this_ref->forum_id_from_name($forum_name);
if (is_null($forum_id)) {
warn_exit(do_lang_tempcode('MISSING_FORUM', escape_html($forum_name)));
}
} else {
$forum_id = (int) $forum_name;
}
$topic_id = $this_ref->find_topic_id_for_topic_identifier($forum_name, $topic_identifier);
$update_caching = false;
$support_attachments = false;
if (!running_script('stress_test_loader') && get_page_name() != 'admin_import') {
$update_caching = true;
$support_attachments = true;
}
if (is_null($topic_id)) {
$is_starter = true;
require_code('ocf_topics_action');
$topic_id = ocf_make_topic($forum_id, $topic_identifier_encapsulation_prefix . ': #' . $topic_identifier, '', $topic_validated, 1, 0, 0, 0, NULL, NULL, false, 0, NULL, $content_url);
if (strpos($topic_identifier, ':') !== false) {
// Sync comment_posted ones to also monitor the forum ones; no need for opposite way as comment ones already trigger forum ones
$start = 0;
$max = 300;
require_code('notifications');
$ob = _get_notification_ob_for_code('comment_posted');
do {
list($members, $possibly_has_more) = $ob->list_members_who_have_enabled('comment_posted', $topic_identifier, NULL, $start, $max);
foreach ($members as $to_member_id => $setting) {
enable_notifications('ocf_topic', strval($topic_id), $to_member_id);
}
$start += $max;
} while ($possibly_has_more);
}
// Make spacer post
if (!is_null($content_url)) {
$spacer_title = $content_title;
$home_link = hyperlink($content_url, escape_html($content_title));
$spacer_post = '[semihtml]' . do_lang('SPACER_POST', $home_link->evaluate(), '', '', get_site_default_lang()) . '[/semihtml]';
ocf_make_post($topic_id, $spacer_title, $spacer_post, 0, true, 1, 0, do_lang('SYSTEM'), $ip, $time, db_get_first_id(), NULL, NULL, NULL, false, $update_caching, $forum_id, $support_attachments, $content_title, 0, NULL, false, false, false, false);
$is_starter = false;
}
$is_new = true;
} else {
$is_starter = false;
$is_new = false;
}
$GLOBALS['LAST_TOPIC_ID'] = $topic_id;
$GLOBALS['LAST_TOPIC_IS_NEW'] = $is_new;
if ($post == '') {
return array(NULL, false);
}
ocf_check_post($post, $topic_id, $member_id);
$poster_name = $poster_name_if_guest;
if ($poster_name == '') {
$poster_name = $this_ref->get_username($member_id);
}
$post_id = ocf_make_post($topic_id, $post_title, $post, 0, $is_starter, $validated, 0, $poster_name, $ip, $time, $member_id, $staff_only ? $GLOBALS['FORUM_DRIVER']->get_guest_id() : NULL, NULL, NULL, false, $update_caching, $forum_id, $support_attachments, $content_title, 0, NULL, false, $skip_post_checks, false, false, $parent_id);
$GLOBALS['LAST_POST_ID'] = $post_id;
if ($is_new) {
//.........这里部分代码省略.........
示例9: show_forum_topics
/**
* Get an array of topics in the given forum. Each topic is an array with the following attributes:
* - id, the topic ID
* - title, the topic title
* - lastusername, the username of the last poster
* - lasttime, the timestamp of the last reply
* - closed, a Boolean for whether the topic is currently closed or not
* - firsttitle, the title of the first post
* - firstpost, the first post (only set if $show_first_posts was true)
*
* @param mixed The forum name or an array of forum IDs
* @param integer The limit
* @param integer The start position
* @param integer The total rows (not a parameter: returns by reference)
* @param SHORT_TEXT The topic title filter
* @param boolean Whether to show the first posts
* @param string The date key to sort by
* @set lasttime firsttime
* @param boolean Whether to limit to hot topics
* @param SHORT_TEXT The topic description filter
* @return ?array The array of topics (NULL: error)
*/
function show_forum_topics($name, $limit, $start, &$max_rows, $filter_topic_title = '', $show_first_posts = false, $date_key = 'lasttime', $hot = false, $filter_topic_description = '')
{
if (is_integer($name)) {
$id_list = 'boardid=' . strval((int) $name);
} elseif (!is_array($name)) {
$id = $this->forum_id_from_name($name);
if (is_null($id)) {
return NULL;
}
$id_list = 'boardid=' . strval((int) $id);
} else {
$id_list = '';
foreach (array_keys($name) as $id) {
if ($id_list != '') {
$id_list .= ' OR ';
}
$id_list .= 'boardid=' . strval((int) $id);
}
if ($id_list == '') {
return NULL;
}
}
$topic_filter = $filter_topic_title != '' ? 'AND topic LIKE \'' . db_encode_like($filter_topic_title) . '\'' : '';
$rows = $this->connection->query('SELECT * FROM ' . $this->connection->get_table_prefix() . 'threads WHERE (' . $id_list . ') ' . $topic_filter . ' ORDER BY ' . ($date_key == 'lasttime' ? 'lastposttime' : 'starttime') . ' DESC', $limit, $start);
$max_rows = $this->connection->query_value_null_ok_full('SELECT COUNT(*) FROM ' . $this->connection->get_table_prefix() . 'threads WHERE (' . $id_list . ') ' . $topic_filter);
$out = array();
foreach ($rows as $i => $r) {
$out[$i] = array();
$out[$i]['id'] = $r['threadid'];
$out[$i]['num'] = $r['replycount'] + 1;
$out[$i]['title'] = $r['topic'];
$out[$i]['description'] = $r['topic'];
$out[$i]['firstusername'] = $r['starter'];
$out[$i]['lastusername'] = $r['lastposter'];
$out[$i]['firsttime'] = $r['starttime'];
$out[$i]['lasttime'] = $r['lastposttime'];
$out[$i]['closed'] = $r['closed'] == 1;
$fp_rows = $this->connection->query('SELECT posttopic,message,userid FROM ' . $this->connection->get_table_prefix() . 'posts WHERE message NOT LIKE \'' . db_encode_like(do_lang('SPACER_POST', '', '', '', get_site_default_lang()) . '%') . '\' AND threadid=' . strval((int) $out[$i]['id']) . ' ORDER BY posttime', 1);
if (!array_key_exists(0, $fp_rows)) {
unset($out[$i]);
continue;
}
$out[$i]['firsttitle'] = $fp_rows[0]['posttopic'];
if ($show_first_posts) {
global $LAX_COMCODE;
$temp = $LAX_COMCODE;
$LAX_COMCODE = true;
$out[$i]['firstpost'] = comcode_to_tempcode($fp_rows[0]['message'], $fp_rows[0]['userid']);
$LAX_COMCODE = $temp;
}
}
if (count($out) != 0) {
return $out;
}
return NULL;
}
示例10: handle_self_referencing_embedment
/**
* Handle GET URLs requesting embedded media files.
*/
function handle_self_referencing_embedment()
{
// If this is self-referring to CSS or logo
if (array_key_exists('type', $_GET)) {
$type = $_GET['type'];
if ($type == 'ajax_ftp_details') {
header('Content-Type: text/plain');
if (!function_exists('ftp_connect')) {
echo do_lang('NO_PHP_FTP');
exit;
}
$conn = false;
$domain = trim(get_param('ftp_domain'));
$port = 21;
if (strpos($domain, ':') !== false) {
list($domain, $_port) = explode(':', $domain, 2);
$port = intval($_port);
}
if (function_exists('ftp_ssl_connect')) {
$conn = @ftp_ssl_connect($domain, $port);
}
$ssl = $conn !== false;
$username = get_param('ftp_username');
$password = get_param('ftp_password');
$ssl = $conn !== false;
if ($ssl && !@ftp_login($conn, $username, $password)) {
$conn = false;
$ssl = false;
}
if ($conn === false) {
$conn = ftp_connect($domain, $port);
}
if ($conn === false) {
echo do_lang('NO_FTP_CONNECT');
exit;
}
if (!$ssl && !@ftp_login($conn, $username, $password)) {
echo do_lang('NO_FTP_LOGIN', @strval($php_errormsg));
ftp_close($conn);
exit;
}
$ftp_folder = get_param('ftp_folder');
if (substr($ftp_folder, -1) != '/') {
$ftp_folder .= '/';
}
if (!@ftp_chdir($conn, $ftp_folder)) {
echo do_lang('NO_FTP_DIR', @strval($php_errormsg), '1');
ftp_close($conn);
exit;
}
$files = @ftp_nlist($conn, '.');
if ($files === false) {
$files = array();
if (@ftp_rename($conn, 'install.php', 'install.php')) {
$files = array('install.php', 'data.ocp');
}
}
if (!in_array('install.php', $files)) {
echo do_lang('NO_FTP_DIR', @strval($php_errormsg), '2');
}
ftp_close($conn);
exit;
}
if ($type == 'ajax_db_details') {
header('Content-Type: text/plain');
global $SITE_INFO;
if (!isset($SITE_INFO)) {
$SITE_INFO = array();
}
$SITE_INFO['db_type'] = get_param('db_type');
require_code('database');
if (get_param('db_site') == '') {
$db = new database_driver(get_param('db_forums'), get_param('db_forums_host'), get_param('db_forums_user'), get_param('db_forums_password'), '', true);
} else {
$db = new database_driver(get_param('db_site'), get_param('db_site_host'), get_param('db_site_user'), get_param('db_site_password'), '', true);
}
$connection =& $db->connection_write;
if (count($connection) > 4) {
call_user_func_array(array($db->static_ob, 'db_get_connection'), $connection);
}
exit;
}
if ($type == 'logo') {
header('Content-type: image/png');
if (!file_exists(get_file_base() . '/themes/default/images/' . get_site_default_lang() . '/logo/trimmed-logo.png')) {
$out = file_array_get('themes/default/images/' . get_site_default_lang() . '/logo/trimmed-logo.png');
echo $out;
} else {
print file_get_contents(get_file_base() . '/themes/default/images/' . get_site_default_lang() . '/logo/trimmed-logo.png');
exit;
}
exit;
}
if ($type == 'contract') {
header('Content-type: image/png');
if (!file_exists(get_file_base() . '/themes/default/images/contract.png')) {
$out = file_array_get('themes/default/images/contract.png');
//.........这里部分代码省略.........
示例11: is_really_empty
/**
* Tests to see if something would evaluate to empty or not
*
* @return boolean Whether it is really empty
*/
function is_really_empty()
{
foreach ($this->bits as $bit) {
if ($bit[1] == TC_KNOWN || $bit[1] == TC_SYMBOL && $bit[2] == 'PAGE_LINK') {
if ($bit[2] != '') {
return false;
}
} else {
$bit_3 = $bit[3];
if ($bit_3 && $bit[1] != TC_DIRECTIVE) {
foreach ($bit_3 as $i => $decode_bit) {
if (is_object($decode_bit)) {
$bit_3[$i] = $decode_bit->evaluate();
}
}
}
$out = ecv(function_exists('get_site_default_lang') ? get_site_default_lang() : 'EN', array(), $bit[1], $bit[2], is_null($bit_3) ? array() : $bit_3);
if ($out != '') {
return false;
}
}
}
return true;
}
示例12: dispatch_cedi_page_notification
/**
* Dispatch a notification about a CEDI page
*
* @param AUTO_LINK The page ID
* @param ID_TEXT The action type
* @set ADD EDIT
*/
function dispatch_cedi_page_notification($page_id, $type)
{
$page_name = get_translated_text($GLOBALS['SITE_DB']->query_value('seedy_pages', 'title', array('id' => $page_id)));
$_the_message = get_translated_text($GLOBALS['SITE_DB']->query_value('seedy_pages', 'description', array('id' => $page_id)));
$_view_url = build_url(array('page' => 'cedi', 'type' => 'misc', 'id' => $page_id == db_get_first_id() ? NULL : $page_id), get_page_zone('cedi'), NULL, false, false, true);
$view_url = $_view_url->evaluate();
$their_username = $GLOBALS['FORUM_DRIVER']->get_username(get_member());
$subject = do_lang($type . '_CEDI_PAGE_SUBJECT', $page_name, NULL, NULL, get_site_default_lang());
$message_raw = do_lang($type . '_CEDI_PAGE_BODY', comcode_escape($their_username), comcode_escape($page_name), array(comcode_escape($view_url), $_the_message), get_site_default_lang());
require_code('notifications');
dispatch_notification('cedi', strval($page_id), $subject, $message_raw);
}
示例13: get_all_image_ids_type
/**
* Get all the image IDs (both already known, and those uncached) of a certain type (i.e. under a subdirectory).
*
* @param ID_TEXT The type of image (e.g. 'ocf_emoticons')
* @param boolean Whether to search recursively; i.e. in subdirectories of the type subdirectory
* @param ?object The database connection to work over (NULL: site db)
* @param ?ID_TEXT The theme to search in, in addition to the default theme (NULL: current theme)
* @param boolean Whether to only return directories (advanced option, rarely used)
* @param boolean Whether to only return from the database (advanced option, rarely used)
* @return array The list of image IDs
*/
function get_all_image_ids_type($type, $recurse = false, $db = NULL, $theme = NULL, $dirs_only = false, $db_only = false)
{
if (is_null($db)) {
$db = $GLOBALS['SITE_DB'];
}
if (is_null($theme)) {
$theme = $GLOBALS['FORUM_DRIVER']->get_theme();
}
if (substr($type, 0, 4) == 'ocf_' && file_exists(get_file_base() . '/themes/default/images/avatars/index.html')) {
$type = substr($type, 4);
}
if (substr($type, -1) == '/') {
$type = substr($type, 0, strlen($type) - 1);
}
$ids = array();
if (!$db_only && ($db->connection_write == $GLOBALS['SITE_DB']->connection_write || $dirs_only || get_db_forums() == get_db_site())) {
_get_all_image_ids_type($ids, get_file_base() . '/themes/default/images/' . ($type == '' ? '' : $type . '/'), $type, $recurse, $dirs_only);
_get_all_image_ids_type($ids, get_file_base() . '/themes/default/images/' . get_site_default_lang() . '/' . ($type == '' ? '' : $type . '/'), $type, $recurse, $dirs_only);
if ($theme != 'default') {
_get_all_image_ids_type($ids, get_custom_file_base() . '/themes/' . $theme . '/images/' . ($type == '' ? '' : $type . '/'), $type, $recurse, $dirs_only);
_get_all_image_ids_type($ids, get_custom_file_base() . '/themes/' . $theme . '/images/' . get_site_default_lang() . '/' . ($type == '' ? '' : $type . '/'), $type, $recurse, $dirs_only);
}
_get_all_image_ids_type($ids, get_file_base() . '/themes/default/images_custom/' . ($type == '' ? '' : $type . '/'), $type, $recurse, $dirs_only);
_get_all_image_ids_type($ids, get_file_base() . '/themes/default/images_custom/' . get_site_default_lang() . '/' . ($type == '' ? '' : $type . '/'), $type, $recurse, $dirs_only);
if ($theme != 'default') {
_get_all_image_ids_type($ids, get_custom_file_base() . '/themes/' . $theme . '/images_custom/' . ($type == '' ? '' : $type . '/'), $type, $recurse, $dirs_only);
_get_all_image_ids_type($ids, get_custom_file_base() . '/themes/' . $theme . '/images_custom/' . get_site_default_lang() . '/' . ($type == '' ? '' : $type . '/'), $type, $recurse, $dirs_only);
}
}
if (!$dirs_only) {
$query = 'SELECT DISTINCT id,path FROM ' . $db->get_table_prefix() . 'theme_images WHERE ';
if (!$db_only) {
$query .= 'path NOT LIKE \'' . db_encode_like('themes/default/images/%') . '\' AND ' . db_string_not_equal_to('path', 'themes/default/images/blank.gif') . ' AND ';
}
$query .= '(' . db_string_equal_to('theme', $theme) . ' OR ' . db_string_equal_to('theme', 'default') . ') AND id LIKE \'' . db_encode_like($type . '%') . '\' ORDER BY path';
$rows = $db->query($query);
foreach ($rows as $row) {
if ($row['path'] == '') {
continue;
}
if (url_is_local($row['path']) && !file_exists((substr($row['path'], 0, 15) == 'themes/default/' ? get_file_base() : get_custom_file_base()) . '/' . rawurldecode($row['path']))) {
continue;
}
if ($row['path'] != 'themes/default/images/blank.gif') {
$ids[] = $row['id'];
} else {
$key = array_search($row['id'], $ids);
if (is_integer($key)) {
unset($ids[$key]);
}
}
}
}
sort($ids);
return array_unique($ids);
}
示例14: show_forum_topics
/**
* Get an array of topics in the given forum. Each topic is an array with the following attributes:
* - id, the topic ID
* - title, the topic title
* - lastusername, the username of the last poster
* - lasttime, the timestamp of the last reply
* - closed, a Boolean for whether the topic is currently closed or not
* - firsttitle, the title of the first post
* - firstpost, the first post (only set if $show_first_posts was true)
*
* @param mixed The forum name or an array of forum IDs
* @param integer The limit
* @param integer The start position
* @param integer The total rows (not a parameter: returns by reference)
* @param SHORT_TEXT The topic title filter
* @param boolean Whether to show the first posts
* @param string The date key to sort by
* @set lasttime firsttime
* @param boolean Whether to limit to hot topics
* @param SHORT_TEXT The topic description filter
* @return ?array The array of topics (NULL: error)
*/
function show_forum_topics($name, $limit, $start, &$max_rows, $filter_topic_title = '', $show_first_posts = false, $date_key = 'lasttime', $hot = false, $filter_topic_description = '')
{
require_code('xhtml');
if (is_integer($name)) {
$id_list = 'forum_id=' . strval((int) $name);
} elseif (!is_array($name)) {
if ($name == '<announce>' || is_null($name)) {
$id_list = '(forum_id IS NULL)';
} else {
$id = $this->forum_id_from_name($name);
if (is_null($id)) {
return NULL;
}
$id_list = 'forum_id=' . strval((int) $id);
}
} else {
$id_list = '';
$id_list_2 = '';
foreach (array_keys($name) as $id) {
if ($id_list != '') {
$id_list .= ' OR ';
}
if (is_null($id) || $id == '') {
$id_list .= '(forum_id IS NULL)';
} else {
$id_list .= 'forum_id=' . strval((int) $id);
}
}
if ($id_list == '') {
return NULL;
}
}
$topic_filter = $filter_topic_title != '' ? 'AND title LIKE \'' . db_encode_like($this->ipb_escape($filter_topic_title)) . '\'' : '';
if ($filter_topic_description != '') {
$topic_filter .= ' AND description LIKE \'' . db_encode_like($this->ipb_escape($filter_topic_description)) . '\'';
}
$rows = $this->connection->query('SELECT * FROM ' . $this->connection->get_table_prefix() . 'topics WHERE (' . $id_list . ') ' . $topic_filter . ' ORDER BY ' . ($date_key == 'lasttime' ? 'last_post' : 'start_date') . ' DESC', $limit, $start);
$max_rows = $this->connection->query_value_null_ok_full('SELECT COUNT(*) FROM ' . $this->connection->get_table_prefix() . 'topics WHERE (' . $id_list . ') ' . $topic_filter);
$emoticons_set_dir = $this->get_emo_dir();
$out = array();
foreach ($rows as $i => $r) {
$out[$i] = array();
$out[$i]['id'] = $r['tid'];
$out[$i]['num'] = $r['posts'];
$out[$i]['title'] = $this->ipb_unescape($r['title']);
$out[$i]['firstusername'] = $this->ipb_unescape($r['starter_name']);
$out[$i]['lastusername'] = $this->ipb_unescape($r['last_poster_name']);
$out[$i]['firstmemberid'] = $r['starter_id'];
$out[$i]['lastmemberid'] = $r['last_poster_id'];
$out[$i]['firsttime'] = $r['start_date'];
$out[$i]['lasttime'] = $r['last_post'];
$out[$i]['closed'] = $r['state'] == 'closed';
$fp_rows = $this->connection->query('SELECT * FROM ' . $this->connection->get_table_prefix() . 'posts WHERE post NOT LIKE \'' . db_encode_like(do_lang('SPACER_POST', '', '', '', get_site_default_lang()) . '%') . '\' AND topic_id=' . strval((int) $out[$i]['id']) . ' ORDER BY post_date', 1);
if (!array_key_exists(0, $fp_rows)) {
unset($out[$i]);
continue;
}
$out[$i]['firsttitle'] = $this->ipb_unescape($fp_rows[0]['post_title']);
if ($show_first_posts) {
$post_id = $fp_rows[0]['pid'];
$post = $fp_rows[0]['post'];
if (array_key_exists('post_htmlstate', $fp_rows[0]) && $fp_rows[0]['post_htmlstate'] != 0) {
if ($fp_rows[0]['post_htmlstate'] == 1) {
$post = str_replace('<br />', '', $post);
}
$post = @html_entity_decode($post, ENT_QUOTES, get_charset());
}
$post = preg_replace('#public/style_emoticons/<\\#EMO_DIR\\#>(.+?)\'#is', $emoticons_set_dir . '\\1\'', $post);
$post = str_replace("class='quotetop'", "class='comcode_quote_h4'", $post);
$post = str_replace("class='quotemain'", "class='comcode_quote_content'", $post);
// Attachments
$attachments = $this->connection->query_select('attachments', array('attach_member_id', 'attach_id', 'attach_file', 'attach_location', 'attach_thumb_location', 'attach_is_image', 'attach_filesize', 'attach_hits'), array('attach_post_key' => $fp_rows[0]['post_key']));
foreach ($attachments as $attachment) {
if ($attachment['attach_thumb_location'] != '' || $attachment['attach_is_image'] == 0) {
$url = get_forum_base_url() . '/index.php?act=Attach&type=post&id=' . $attachment['attach_id'];
if ($attachment['attach_thumb_location'] != '') {
$special = do_template('FORUM_ATTACHMENT_IMAGE_THUMB', array('_GUID' => '98a66462f270f53101c4c0a1b63f0bfc', 'FULL' => $url, 'URL' => get_forum_base_url() . '/uploads/' . $attachment['attach_thumb_location']));
} else {
//.........这里部分代码省略.........
示例15: mail_wrap
/**
* Attempt to send an e-mail to the specified recipient. The mail will be forwarding to the CC address specified in the options (if there is one, and if not specified not to cc).
* The mail will be sent in dual HTML/text format, where the text is the unconverted comcode source: if a member does not read HTML mail, they may wish to fallback to reading that.
*
* @param string The subject of the mail in plain text
* @param LONG_TEXT The message, as Comcode
* @param ?array The destination (recipient) e-mail addresses [array of strings] (NULL: site staff address)
* @param ?mixed The recipient name. Array or string. (NULL: site name)
* @param EMAIL The from address (blank: site staff address)
* @param string The from name (blank: site name)
* @param integer The message priority (1=urgent, 3=normal, 5=low)
* @range 1 5
* @param ?array An list of attachments (each attachment being a map, path=>filename) (NULL: none)
* @param boolean Whether to NOT CC to the CC address
* @param ?MEMBER Convert comcode->tempcode as this member (a privilege thing: we don't want people being able to use admin rights by default!) (NULL: guest)
* @param boolean Replace above with arbitrary admin
* @param boolean HTML-only
* @param boolean Whether to bypass queueing, because this code is running as a part of the queue management tools
* @param ID_TEXT The template used to show the email
* @param boolean Whether to bypass queueing
* @return ?tempcode A full page (not complete XHTML) piece of tempcode to output (NULL: it worked so no tempcode message)
*/
function mail_wrap($subject_tag, $message_raw, $to_email = NULL, $to_name = NULL, $from_email = '', $from_name = '', $priority = 3, $attachments = NULL, $no_cc = false, $as = NULL, $as_admin = false, $in_html = false, $coming_out_of_queue = false, $mail_template = 'MAIL', $bypass_queue = false)
{
if (get_option('smtp_sockets_use') == '0') {
return non_overrided__mail_wrap($subject_tag, $message_raw, $to_email, $to_name, $from_email, $from_name, $priority, $attachments, $no_cc, $as, $as_admin, $in_html, $coming_out_of_queue);
}
if (running_script('stress_test_loader')) {
return NULL;
}
if (is_null($bypass_queue)) {
$bypass_queue = $priority < 3 || strpos(serialize($attachments), 'tmpfile') !== false;
}
global $EMAIL_ATTACHMENTS;
$EMAIL_ATTACHMENTS = array();
require_code('site');
require_code('mime_types');
if (is_null($as)) {
$as = $GLOBALS['FORUM_DRIVER']->get_guest_id();
}
if (!$coming_out_of_queue) {
$GLOBALS['SITE_DB']->query('DELETE FROM ' . get_table_prefix() . 'logged_mail_messages WHERE m_date_and_time<' . strval(time() - 60 * 60 * 24 * 14) . ' AND m_queued=0');
// Log it all for 2 weeks, then delete
$through_queue = !$bypass_queue && (get_option('mail_queue_debug') === '1' || get_option('mail_queue') === '1' && cron_installed());
$GLOBALS['SITE_DB']->query_insert('logged_mail_messages', array('m_subject' => $subject_tag, 'm_message' => $message_raw, 'm_to_email' => serialize($to_email), 'm_to_name' => serialize($to_name), 'm_from_email' => $from_email, 'm_from_name' => $from_name, 'm_priority' => 3, 'm_attachments' => serialize($attachments), 'm_no_cc' => $no_cc ? 1 : 0, 'm_as' => $as, 'm_as_admin' => $as_admin ? 1 : 0, 'm_in_html' => $in_html ? 1 : 0, 'm_date_and_time' => time(), 'm_member_id' => get_member(), 'm_url' => get_self_url(true), 'm_queued' => $through_queue ? 1 : 0, 'm_template' => $mail_template));
if ($through_queue) {
return NULL;
}
}
if (count($attachments) == 0) {
$attachments = NULL;
}
global $SENDING_MAIL;
if ($SENDING_MAIL) {
return NULL;
}
$SENDING_MAIL = true;
// To and from, and language
$staff_address = get_option('staff_address');
if (is_null($to_email)) {
$to_email = array($staff_address);
}
$to_email_new = array();
foreach ($to_email as $test_address) {
if ($test_address != '') {
$to_email_new[] = $test_address;
}
}
$to_email = $to_email_new;
if ($to_email == array()) {
$SENDING_MAIL = false;
return NULL;
}
if ($to_email[0] == $staff_address) {
$lang = get_site_default_lang();
} else {
$lang = user_lang();
if (method_exists($GLOBALS['FORUM_DRIVER'], 'get_member_from_email_address')) {
$member_id = $GLOBALS['FORUM_DRIVER']->get_member_from_email_address($to_email[0]);
if (!is_null($member_id)) {
$lang = get_lang($member_id);
}
}
}
if (is_null($to_name)) {
if ($to_email[0] == $staff_address) {
$to_name = get_site_name();
} else {
$to_name = '';
}
}
if ($from_email == '') {
$from_email = get_option('staff_address');
}
if ($from_name == '') {
$from_name = get_site_name();
}
$theme = method_exists($GLOBALS['FORUM_DRIVER'], 'get_theme') ? $GLOBALS['FORUM_DRIVER']->get_theme() : 'default';
if ($theme == 'default') {
$theme = $GLOBALS['FORUM_DRIVER']->get_theme('');
//.........这里部分代码省略.........