当前位置: 首页>>代码示例>>PHP>>正文


PHP get_charset函数代码示例

本文整理汇总了PHP中get_charset函数的典型用法代码示例。如果您正苦于以下问题:PHP get_charset函数的具体用法?PHP get_charset怎么用?PHP get_charset使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了get_charset函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: do_netlink

/**
 * Get a netlink block / direct to a netlink site.
 *
 * @param  URLPATH		The URL we grab our netlink from. If this is not blank, instead of getting a netlink block, we direct to a netlink site.
 * @return tempcode		The netlink block
 */
function do_netlink($redir_url = '')
{
    header('Content-type: text/plain; charset=' . get_charset());
    // If we are redirecting
    if ($redir_url != '') {
        if (strpos($redir_url, chr(10)) !== false || strpos($redir_url, chr(13)) !== false) {
            log_hack_attack_and_exit('HEADER_SPLIT_HACK');
        }
        header('Location: ' . $redir_url);
        exit;
    }
    // Ok we're displaying a netlink, which will be dumped right into the body of the reading site
    //  - this isn't actually a weburl that is actually displayed, its loaded by ocPortal and embedded-inline
    // For all the names in our network
    require_code('textfiles');
    $lines = explode(chr(10), read_text_file('netlink', NULL, true));
    if (count($lines) == 0) {
        return new ocp_tempcode();
    }
    $content = new ocp_tempcode();
    foreach ($lines as $line) {
        $parts = explode('=', $line, 2);
        if (count($parts) != 2) {
            continue;
        }
        $name = rtrim($parts[0]);
        $url = trim($parts[1]);
        // Are we looking at the source site in the network?
        $selected = strtolower($url) == strtolower(get_param('source', ''));
        $content->attach(form_input_list_entry(base64_encode($url), $selected, $name));
    }
    return do_template('NETLINK', array('_GUID' => '180321222dc5dc99a231597c803f0726', 'CONTENT' => $content));
}
开发者ID:erico-deh,项目名称:ocPortal,代码行数:39,代码来源:multi_site_networks.php

示例2: chat_poller

/**
 * Function to quickly (efficiently) check to see if there's been any chat activity.
 */
function chat_poller()
{
    $message_id = get_param_integer('message_id', -1);
    $event_id = get_param_integer('event_id', -1);
    if (file_exists(get_custom_file_base() . '/data_custom/modules/chat/chat_last_full_check.dat') && filemtime(get_custom_file_base() . '/data_custom/modules/chat/chat_last_full_check.dat') > time() - 3 && ($message_id != -1 && file_exists(get_custom_file_base() . '/data_custom/modules/chat/chat_last_msg.dat') && intval(file_get_contents(get_custom_file_base() . '/data_custom/modules/chat/chat_last_msg.dat', FILE_TEXT)) <= $message_id) && ($event_id != -1 && file_exists(get_custom_file_base() . '/data_custom/modules/chat/chat_last_event.dat') && intval(file_get_contents(get_custom_file_base() . '/data_custom/modules/chat/chat_last_event.dat', FILE_TEXT)) <= $event_id)) {
        load_user_stuff();
        require_code('zones');
        // Zone is needed because zones are where all ocPortal pages reside
        require_code('config');
        // Config is needed for much active stuff
        require_code('users');
        // Users are important due to permissions
        $room_id = get_param_integer('room_id', -1);
        require_code('chat');
        chat_room_prune($room_id);
        header("Cache-Control: no-cache, must-revalidate");
        // HTTP/1.1
        header("Expires: Mon, 26 Jul 1997 05:00:00 GMT");
        // Date in the past
        header('Content-Type: application/xml');
        $output = '<?xml version="1.0" encoding="' . get_charset() . '" ?' . '>
			<response>
				<result>
					<chat_null>' . strval($room_id) . '</chat_null>
				</result>
			</response>';
        exit($output);
    }
    touch(get_custom_file_base() . '/data_custom/modules/chat/chat_last_full_check.dat');
}
开发者ID:erico-deh,项目名称:ocPortal,代码行数:33,代码来源:chat_poller.php

示例3: run

 /**
  * Standard modular run function for ajax-tree hooks. Generates XML for a tree list, which is interpreted by Javascript and expanded on-demand (via new calls).
  *
  * @param  ?ID_TEXT		The ID to do under (NULL: root)
  * @param  array			Options being passed through
  * @param  ?ID_TEXT		The ID to select by default (NULL: none)
  * @return string			XML in the special category,entry format
  */
 function run($id, $options, $default = NULL)
 {
     require_code('galleries');
     $only_owned = array_key_exists('only_owned', $options) ? is_null($options['only_owned']) ? NULL : intval($options['only_owned']) : NULL;
     $editable_filter = array_key_exists('editable_filter', $options) ? $options['editable_filter'] : false;
     $tree = get_gallery_content_tree('images', $only_owned, $id, NULL, NULL, is_null($id) ? 0 : 1, false, $editable_filter);
     if (!has_actual_page_access(NULL, 'galleries')) {
         $tree = array();
     }
     $out = '';
     foreach ($tree as $t) {
         $_id = $t['id'];
         if ($id === $_id) {
             foreach ($t['entries'] as $eid => $etitle) {
                 if (is_object($etitle)) {
                     $etitle = @html_entity_decode(strip_tags($etitle->evaluate()), ENT_QUOTES, get_charset());
                 }
                 $out .= '<entry id="' . xmlentities(strval($eid)) . '" title="' . xmlentities($etitle) . '" selectable="true"></entry>';
             }
             continue;
         }
         $title = $t['title'];
         $has_children = $t['child_count'] != 0 || $t['child_entry_count'] != 0;
         $out .= '<category id="' . xmlentities($_id) . '" title="' . xmlentities($title) . '" has_children="' . ($has_children ? 'true' : 'false') . '" selectable="false"></category>';
     }
     // Mark parent cats for pre-expansion
     if (!is_null($default) && $default != '') {
         $cat = $GLOBALS['SITE_DB']->query_value_null_ok('images', 'cat', array('id' => intval($default)));
         while (!is_null($cat) && $cat != '') {
             $out .= '<expand>' . $cat . '</expand>';
             $cat = $GLOBALS['SITE_DB']->query_value_null_ok('galleries', 'parent_id', array('name' => $cat));
         }
     }
     return '<result>' . $out . '</result>';
 }
开发者ID:erico-deh,项目名称:ocPortal,代码行数:43,代码来源:choose_image.php

示例4: go

 /**
  * Run the loader, to load up field-restrictions from the XML file.
  *
  * @param  string			The default breadcrumbs
  * @param  string			The breadcrumb XML data
  */
 function go($current_breadcrumbs, $data)
 {
     $this->tag_stack = array();
     $this->attribute_stack = array();
     $this->substitution_current_match_key = NULL;
     $this->substitution_current_label = NULL;
     $this->links = array();
     $this->substitutions = array();
     $breadcrumb_tpl = do_template('BREADCRUMB_ESCAPED');
     $this->breadcrumb_tpl = $breadcrumb_tpl->evaluate();
     $this->current_breadcrumbs = $current_breadcrumbs;
     // Create and setup our parser
     $xml_parser = @xml_parser_create();
     if ($xml_parser === false) {
         return;
         // PHP5 default build on windows comes with this function disabled, so we need to be able to escape on error
     }
     xml_set_object($xml_parser, $this);
     @xml_parser_set_option($xml_parser, XML_OPTION_TARGET_ENCODING, get_charset());
     @xml_parser_set_option($xml_parser, XML_OPTION_CASE_FOLDING, 0);
     xml_set_element_handler($xml_parser, 'startElement', 'endElement');
     xml_set_character_data_handler($xml_parser, 'startText');
     // Run the parser
     if (@xml_parse($xml_parser, $data, true) == 0) {
         attach_message('breadcrumbs.xml: ' . xml_error_string(xml_get_error_code($xml_parser)), 'warn');
         return;
     }
     @xml_parser_free($xml_parser);
 }
开发者ID:erico-deh,项目名称:ocPortal,代码行数:35,代码来源:breadcrumbs.php

示例5: run

 /**
  * Standard modular run function for ajax-tree hooks. Generates XML for a tree list, which is interpreted by Javascript and expanded on-demand (via new calls).
  *
  * @param  ?ID_TEXT		The ID to do under (NULL: root)
  * @param  array			Options being passed through
  * @param  ?ID_TEXT		The ID to select by default (NULL: none)
  * @return string			XML in the special category,entry format
  */
 function run($id, $options, $default = NULL)
 {
     require_code('galleries');
     require_lang('galleries');
     $must_accept_images = array_key_exists('must_accept_images', $options) ? $options['must_accept_images'] : false;
     $must_accept_videos = array_key_exists('must_accept_videos', $options) ? $options['must_accept_videos'] : false;
     $filter = array_key_exists('filter', $options) ? $options['filter'] : NULL;
     $purity = array_key_exists('purity', $options) ? $options['purity'] : false;
     $member_id = array_key_exists('member_id', $options) ? $options['member_id'] : NULL;
     $compound_list = array_key_exists('compound_list', $options) ? $options['compound_list'] : false;
     $addable_filter = array_key_exists('addable_filter', $options) ? $options['addable_filter'] : false;
     $stripped_id = $compound_list ? preg_replace('#,.*$#', '', $id) : $id;
     $tree = get_gallery_tree(is_null($id) ? 'root' : $stripped_id, '', NULL, true, $filter, false, false, $purity, $compound_list, is_null($id) ? 0 : 1, $member_id, $addable_filter);
     if (!has_actual_page_access(NULL, 'galleries')) {
         $tree = array();
     }
     if ($compound_list) {
         list($tree, ) = $tree;
     }
     $out = '';
     for ($i = 0; $i < count($tree); $i++) {
         $t = $tree[$i];
         $_id = $compound_list ? $t['compound_list'] : $t['id'];
         if ($stripped_id === $t['id']) {
             // Possible when we look under as a root
             if (array_key_exists('children', $t)) {
                 $tree = $t['children'];
                 $i = 0;
             }
             continue;
         }
         $title = $t['title'];
         if (is_object($title)) {
             $title = @html_entity_decode(strip_tags($title->evaluate()), ENT_QUOTES, get_charset());
         }
         $has_children = $t['child_count'] != 0;
         $selectable = ($addable_filter !== true || $t['addable']) && ($t['accept_videos'] == 1 && $t['is_member_synched'] == 0 || !$must_accept_videos) && ($t['accept_images'] == 1 && $t['is_member_synched'] == 0 || !$must_accept_images);
         $tag = 'category';
         // category
         $out .= '<' . $tag . ' id="' . xmlentities($_id) . '" title="' . xmlentities($title) . '" has_children="' . ($has_children ? 'true' : 'false') . '" selectable="' . ($selectable ? 'true' : 'false') . '"></' . $tag . '>';
         // Mark parent cats for pre-expansion
         if (!is_null($default) && $default != '') {
             $cat = $default;
             while (!is_null($cat) && $cat != '') {
                 $out .= '<expand>' . $cat . '</expand>';
                 $cat = $GLOBALS['SITE_DB']->query_value_null_ok('galleries', 'parent_id', array('name' => $cat));
             }
         }
     }
     $tag = 'result';
     // result
     return '<' . $tag . '>' . $out . '</' . $tag . '>';
 }
开发者ID:erico-deh,项目名称:ocPortal,代码行数:61,代码来源:choose_gallery.php

示例6: fileGet

 public function fileGet()
 {
     $filename = _DIR($this->in['filename']);
     if (!is_readable($filename)) {
         show_json($this->L['no_permission_read'], false);
     }
     if (filesize($filename) >= 1024 * 1024 * 20) {
         show_json($this->L['edit_too_big'], false);
     }
     $filecontents = file_get_contents($filename);
     //文件内容
     $charset = get_charset($filecontents);
     if ($charset != '' || $charset != 'utf-8') {
         $filecontents = mb_convert_encoding($filecontents, 'utf-8', $charset);
     }
     $data = array('ext' => get_path_ext($filename), 'name' => iconv_app(get_path_this($filename)), 'filename' => rawurldecode($this->in['filename']), 'charset' => $charset, 'content' => $filecontents);
     show_json($data);
 }
开发者ID:fangbei,项目名称:KODExplorer,代码行数:18,代码来源:editor.class.php

示例7: db_get_connection

 /**
  * Get a database connection. This function shouldn't be used by you, as a connection to the database is established automatically.
  *
  * @param  boolean		Whether to create a persistant connection
  * @param  string			The database name
  * @param  string			The database host (the server)
  * @param  string			The database connection username
  * @param  string			The database connection password
  * @param  boolean		Whether to on error echo an error and return with a NULL, rather than giving a critical error
  * @return ?array			A database connection (note for mySQL, it's actually a pair, containing the database name too: because we need to select the name before each query on the connection) (NULL: error)
  */
 function db_get_connection($persistent, $db_name, $db_host, $db_user, $db_password, $fail_ok = false)
 {
     if (!function_exists('dbx_connect')) {
         $error = 'dbx not on server (anymore?). Try using the \'mysql\' database driver. To use it, edit the info.php config file.';
         if ($fail_ok) {
             echo $error;
             return NULL;
         }
         critical_error('PASSON', $error);
     }
     // Potential cacheing
     global $CACHE_DB;
     $x = serialize(array($db_name, $db_host));
     if (array_key_exists($x, $CACHE_DB)) {
         return array($x, $db_name);
     }
     $db = @dbx_connect('mysql', $db_host, $db_name, $db_user, $db_password, $persistent ? 1 : 0);
     if ($db === false || is_null($db)) {
         $error = 'Could not connect to database/database-server';
         if ($fail_ok) {
             echo $error . chr(10);
             return NULL;
         }
         critical_error('PASSON', $error);
         //warn_exit(do_lang_tempcode('CONNECT_DB_ERROR')); // purposely not ===false
     }
     global $LAST_SELECT_DB;
     $LAST_SELECT_DB = $db;
     global $SITE_INFO;
     if (!array_key_exists('database_charset', $SITE_INFO)) {
         $SITE_INFO['database_charset'] = strtolower(get_charset()) == 'utf-8' ? 'utf8' : 'latin1';
     }
     @dbx_query($db, 'SET NAMES "' . addslashes($SITE_INFO['database_charset']) . '"');
     @dbx_query($db, 'SET SQL_BIG_SELECTS=1');
     if (get_forum_type() == 'ocf') {
         @dbx_query($db, 'SET sql_mode=STRICT_ALL_TABLES');
     }
     return array($db, $db_name);
 }
开发者ID:erico-deh,项目名称:ocPortal,代码行数:50,代码来源:mysql_dbx.php

示例8: realtime_rain_script

/**
 * AJAX script for returning realtime-rain data.
 */
function realtime_rain_script()
{
    header("Cache-Control: no-cache, must-revalidate");
    // HTTP/1.1
    header("Expires: Mon, 26 Jul 1997 05:00:00 GMT");
    // Date in the past
    @ini_set('ocproducts.xss_detect', '0');
    header('Content-Type: text/xml');
    echo '<?xml version="1.0" encoding="' . get_charset() . '"?' . '>';
    echo '<request><result>';
    require_code('realtime_rain');
    require_lang('realtime_rain');
    $time_now = time();
    $from = get_param_integer('from', $time_now - 10);
    $to = get_param_integer('to', $time_now);
    if (get_param_integer('keep_realtime_test', 0) == 1) {
        $types = array('post', 'news', 'recommend', 'polls', 'ecommerce', 'actionlog', 'security', 'chat', 'stats', 'join', 'calendar', 'search', 'point_charges', 'banners', 'point_gifts');
        shuffle($types);
        $events = array();
        $cnt = count($types);
        for ($i = 0; $i < max($cnt, 5); $i++) {
            $timestamp = mt_rand($from, $to);
            $type = array_pop($types);
            $event = rain_get_special_icons(get_ip_address(), $timestamp) + array('TYPE' => $type, 'FROM_MEMBER_ID' => NULL, 'TO_MEMBER_ID' => NULL, 'TITLE' => 'Test', 'IMAGE' => rain_get_country_image(get_ip_address()), 'TIMESTAMP' => strval($timestamp), 'RELATIVE_TIMESTAMP' => strval($timestamp - $from), 'TICKER_TEXT' => NULL, 'URL' => NULL, 'IS_POSITIVE' => $type == 'ecommerce' || $type == 'join', 'IS_NEGATIVE' => $type == 'security' || $type == 'point_charges', 'FROM_ID' => NULL, 'TO_ID' => NULL, 'GROUP_ID' => 'example_' . strval(mt_rand(0, 4)));
            $event['SPECIAL_ICON'] = 'email-icon';
            $event['MULTIPLICITY'] = '10';
            $events[] = $event;
        }
    } else {
        $events = get_realtime_events($from, $to);
    }
    shuffle($events);
    $out = new ocp_tempcode();
    foreach ($events as $event) {
        $out->attach(do_template('REALTIME_RAIN_BUBBLE', $event));
    }
    $out->evaluate_echo();
    echo '</result></request>';
}
开发者ID:erico-deh,项目名称:ocPortal,代码行数:42,代码来源:realtime_rain.php

示例9: load_html_page

/**
 * Get the contents of an HTML page.
 * HTML isn't great... no dynamicness/reconfigurability at all.
 * We prefer comcode with [html]HTML goes here[/html] usage
 *
 * @param  PATH			The relative (to ocPortals base directory) path to the HTML page
 * @param  ?PATH			The file base to load from (NULL: standard)
 * @return string			The page
 */
function load_html_page($string, $file_base = NULL)
{
    if (is_null($file_base)) {
        $file_base = get_file_base();
    }
    global $PAGE_STRING;
    if (is_null($PAGE_STRING)) {
        $PAGE_STRING = $string;
    }
    $html = file_get_contents($file_base . '/' . $string, FILE_TEXT);
    // Post-processing
    if (strpos($html, '<html') !== false) {
        $matches = array();
        // Fix links to anything in same dir, by assuming either uploads/website_specific or an ocP page in same zone
        $link_attributes = array('src', 'href', 'action', 'data', 'codebase');
        foreach ($link_attributes as $attribute) {
            $num_matches = preg_match_all('#<[^<>]* ' . $attribute . '="([^&"]+\\.[^&"\\.]+)"[^<>]*>#mis', $html, $matches);
            for ($i = 0; $i < $num_matches; $i++) {
                $old_link = $matches[1][$i];
                $zone = '_SELF';
                if ($old_link[0] == '/') {
                    $old_link = substr($old_link, 1);
                    $zone = '';
                }
                $possible_zone = str_replace('/', '_', dirname($old_link));
                if ($possible_zone == '.') {
                    $possible_zone = '';
                }
                if ($possible_zone != '' && $possible_zone != get_zone_name() && file_exists(get_file_base() . '/' . $possible_zone)) {
                    $zone = $possible_zone;
                }
                if (substr($old_link, -4) == '.htm') {
                    $_new_link = build_url(array('page' => basename(substr($old_link, 0, strlen($old_link) - 4))), $zone);
                    $new_link = $_new_link->evaluate();
                } elseif (substr($old_link, -5) == '.html') {
                    $_new_link = build_url(array('page' => basename(substr($old_link, 0, strlen($old_link) - 5))), $zone);
                    $new_link = $_new_link->evaluate();
                } else {
                    $new_link = $old_link;
                    if (url_is_local($old_link)) {
                        if (is_file(get_custom_file_base() . '/' . dirname($string) . '/' . $old_link)) {
                            $new_link = get_custom_base_url() . '/' . dirname($string) . '/' . $old_link;
                        } else {
                            $new_link = get_custom_base_url() . '/uploads/website_specific/' . $old_link;
                        }
                    }
                }
                $html = str_replace(' ' . $attribute . '="' . $old_link . '"', ' ' . $attribute . '="' . $new_link . '"', $html);
            }
        }
        // Extract script, style, and link elements from head
        if (preg_match('#<\\s*head[^<>]*>(.*)<\\s*/\\s*head\\s*>#mis', $html, $matches) != 0) {
            global $EXTRA_HEAD;
            $head = $matches[1];
            $head_patterns = array('#<\\s*script.*<\\s*/\\s*script\\s*>#misU', '#<\\s*link[^<>]*>#misU', '#<\\s*style.*<\\s*/\\s*style\\s*>#misU');
            foreach ($head_patterns as $pattern) {
                $num_matches = preg_match_all($pattern, $head, $matches);
                for ($i = 0; $i < $num_matches; $i++) {
                    $EXTRA_HEAD->attach($matches[0][$i]);
                }
            }
        }
        // Extra meta keywords and description, and title
        global $SEO_KEYWORDS, $SEO_DESCRIPTION, $SEO_TITLE;
        if (preg_match('#<\\s*meta\\s+name\\s*=\\s*"keywords"\\s+content="([^"]*)"#mi', $html, $matches) != 0) {
            $SEO_KEYWORDS = explode(',', @html_entity_decode(trim($matches[1]), ENT_QUOTES, get_charset()));
        }
        if (preg_match('#<\\s*meta\\s+name\\s*=\\s*"description"\\s+content="([^"]*)"#mi', $html, $matches) != 0) {
            $SEO_DESCRIPTION = @html_entity_decode(trim($matches[1]), ENT_QUOTES, get_charset());
        }
        if (preg_match('#<\\s*title\\s*>([^<>]*)<\\s*/\\s*title\\s*>#mis', $html, $matches) != 0) {
            $SEO_TITLE = @html_entity_decode(trim($matches[1]), ENT_QUOTES, get_charset());
        }
        // Extract body
        if (preg_match('#<\\s*body[^>]*>(.*)<\\s*/\\s*body\\s*>#mis', $html, $matches) != 0) {
            $html = $matches[1];
        } else {
            $html = '';
        }
    }
    return $html;
}
开发者ID:erico-deh,项目名称:ocPortal,代码行数:91,代码来源:site_html_pages.php

示例10: gui

 /**
  * The UI for recommending the site.
  *
  * @return tempcode	The UI.
  */
 function gui()
 {
     require_code('form_templates');
     global $EXTRA_HEAD;
     $EXTRA_HEAD->attach('<meta name="robots" content="noindex" />');
     // XHTMLXHTML
     global $NON_CANONICAL_PARAMS;
     $NON_CANONICAL_PARAMS[] = 'page_title';
     $NON_CANONICAL_PARAMS[] = 'subject';
     $NON_CANONICAL_PARAMS[] = 's_message';
     $NON_CANONICAL_PARAMS[] = 'from';
     $NON_CANONICAL_PARAMS[] = 'title';
     $NON_CANONICAL_PARAMS[] = 'ocp';
     $page_title = get_param('page_title', NULL, true);
     $submit_name = !is_null($page_title) ? make_string_tempcode($page_title) : do_lang_tempcode('SEND');
     $post_url = build_url(array('page' => '_SELF', 'type' => 'actual'), '_SELF', NULL, true);
     $hidden = new ocp_tempcode();
     $name = post_param('name', is_guest() ? '' : $GLOBALS['FORUM_DRIVER']->get_username(get_member()));
     $recommender_email_address = post_param('recommender_email_address', $GLOBALS['FORUM_DRIVER']->get_member_email_address(get_member()));
     $fields = new ocp_tempcode();
     $fields->attach(form_input_line(do_lang_tempcode('YOUR_NAME'), '', 'name', $name, true));
     $fields->attach(form_input_email(do_lang_tempcode('YOUR_EMAIL_ADDRESS'), '', 'recommender_email_address', $recommender_email_address, true));
     $already = array();
     foreach ($_POST as $key => $email_address) {
         if (substr($key, 0, 14) != 'email_address_') {
             continue;
         }
         if (get_magic_quotes_gpc()) {
             $email_address = stripslashes($email_address);
         }
         $already[] = $email_address;
     }
     if (is_guest()) {
         $fields->attach(form_input_email(do_lang_tempcode('FRIEND_EMAIL_ADDRESS'), '', 'email_address_0', array_key_exists(0, $already) ? $already[0] : '', true));
     } else {
         $fields->attach(form_input_line_multi(do_lang_tempcode('FRIEND_EMAIL_ADDRESS'), do_lang_tempcode('THEIR_ADDRESS'), 'email_address_', $already, 1, NULL, 'email'));
     }
     if (may_use_invites() && get_forum_type() == 'ocf' && !is_guest()) {
         $invites = get_num_invites(get_member());
         if ($invites > 0) {
             require_lang('ocf');
             $invite = count($_POST) == 0 ? true : post_param_integer('invite', 0) == 1;
             $fields->attach(form_input_tick(do_lang_tempcode('USE_INVITE'), do_lang_tempcode('USE_INVITE_DESCRIPTION', $GLOBALS['FORUM_DRIVER']->is_super_admin(get_member()) ? do_lang('NA_EM') : integer_format($invites)), 'invite', $invite));
         }
     }
     $message = post_param('message', NULL);
     $subject = get_param('subject', do_lang('RECOMMEND_MEMBER_SUBJECT', get_site_name()), true);
     if (is_null($message)) {
         $message = get_param('s_message', '', true);
         if ($message == '') {
             $from = get_param('from', NULL, true);
             if (!is_null($from)) {
                 $resource_title = get_param('title', '', true);
                 if ($resource_title == '') {
                     $downloaded_at_link = http_download_file($from, 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) {
                             $resource_title = trim(str_replace('&ndash;', '-', str_replace('&mdash;', '-', @html_entity_decode($matches[1], ENT_QUOTES, get_charset()))));
                             $resource_title = preg_replace('#^' . str_replace('#', '\\#', preg_quote(get_site_name())) . ' - #', '', $resource_title);
                             $resource_title = preg_replace('#\\s+[^\\d\\s][^\\d\\s]?[^\\d\\s]?\\s+' . str_replace('#', '\\#', preg_quote(get_site_name())) . '$#i', '', $resource_title);
                         }
                     }
                 }
                 if ($resource_title == '') {
                     $resource_title = do_lang('THIS');
                     // Could not find at all, so say 'this'
                 } else {
                     $subject = get_param('subject', do_lang('RECOMMEND_MEMBER_SUBJECT_SPECIFIC', get_site_name(), $resource_title), true);
                 }
                 $message = do_lang('FOUND_THIS_ON', get_site_name(), comcode_escape($from), comcode_escape($resource_title));
             }
         }
         if (get_param_integer('ocp', 0) == 1) {
             $message = do_lang('RECOMMEND_OCPORTAL');
         }
     }
     $text = is_null($page_title) ? do_lang_tempcode('RECOMMEND_SITE_TEXT') : new ocp_tempcode();
     if (!is_null(get_param('from', NULL, true))) {
         if (is_null($page_title)) {
             $title = get_page_title('RECOMMEND_LINK');
         } else {
             $title = get_page_title($page_title, false);
         }
         $submit_name = do_lang_tempcode('SEND');
         $text = do_lang_tempcode('RECOMMEND_AUTO_TEXT', get_site_name());
         $need_message = true;
     } else {
         if (is_null($page_title)) {
             $title = get_page_title('_RECOMMEND_SITE', true, array(escape_html(get_site_name())));
         } else {
             $title = get_page_title($page_title, false);
         }
         $hidden->attach(form_input_hidden('wrap_message', '1'));
         $need_message = false;
//.........这里部分代码省略.........
开发者ID:erico-deh,项目名称:ocPortal,代码行数:101,代码来源:recommend.php

示例11: comcode_text__to__comcode_xml


//.........这里部分代码省略.........
                                                    $spec = true;
                                                    $c_type = '';
                                                    foreach ($cells as $cell) {
                                                        if ($spec) {
                                                            $c_type = strpos($cell, '!') !== false ? 'th' : 'td';
                                                        } else {
                                                            $xml .= '<' . $c_type . '>';
                                                            $xml .= comcode_text__to__comcode_xml(rtrim($cell), true);
                                                            $xml .= '</' . $c_type . '>';
                                                        }
                                                        $spec = !$spec;
                                                    }
                                                    $xml .= '</tr>';
                                                }
                                                $xml .= '</table>';
                                            }
                                            $pos = $end_tbl + 3;
                                            $differented = true;
                                        }
                                    }
                                }
                                // Link lookahead
                                if (!$differented) {
                                    if (!$in_semihtml && $next == 'h' && (substr($comcode, $pos - 1, strlen('http://')) == 'http://' || substr($comcode, $pos - 1, strlen('https://')) == 'https://' || substr($comcode, $pos - 1, strlen('ftp://')) == 'ftp://')) {
                                        list($link_end_pos, $auto_link) = detect_link($comcode, $pos);
                                        $xml .= $continuation;
                                        $continuation = '';
                                        $downloaded_at_link = http_download_file($auto_link, 3000, false);
                                        $link_captions_title = '';
                                        if (is_string($downloaded_at_link)) {
                                            $matches = array();
                                            if (preg_match('#<title>\\s*(.*)\\s*</title>#', $downloaded_at_link, $matches) != 0) {
                                                require_code('character_sets');
                                                $link_captions_title = @html_entity_decode(convert_to_internal_encoding($matches[1]), ENT_QUOTES, get_charset());
                                            }
                                        }
                                        $xml .= '<url param="' . escape_html($auto_link) . '">' . escape_html($link_captions_title) . '</url>';
                                        $pos += $link_end_pos - $pos;
                                        $differented = true;
                                        break;
                                    }
                                }
                            }
                            if (!$differented) {
                                if (!$in_separate_parse_section && (!$in_semihtml || !$comcode_dangerous && !$is_all_semihtml)) {
                                    if ($next == '&') {
                                        $ahead = substr($comcode, $pos, 20);
                                        $ahead_lower = strtolower($ahead);
                                        $matches = array();
                                        $entity = preg_match('#(\\#)?([\\w]*);#', $ahead_lower, $matches) != 0;
                                        // If it is a SAFE entity, use it
                                        if ($entity) {
                                            if ($matches[1] == '' && isset($ALLOWED_ENTITIES[$matches[2]])) {
                                                $pos += strlen($matches[2]) + 1;
                                                $continuation .= '&' . $matches[2] . ';';
                                            } elseif (is_numeric($matches[2]) && $matches[1] == '#') {
                                                $matched_entity = intval(base_convert($matches[1], 16, 10));
                                                if ($matched_entity < 127 && array_key_exists(chr($matched_entity), $POTENTIAL_JS_NAUGHTY_ARRAY)) {
                                                    $continuation .= escape_html($next);
                                                } else {
                                                    $pos += strlen($matches[2]) + 2;
                                                    $continuation .= '&#' . $matches[2] . ';';
                                                }
                                            } else {
                                                $continuation .= '&amp;';
                                            }
开发者ID:erico-deh,项目名称:ocPortal,代码行数:67,代码来源:comcode_conversion.php

示例12: fix_links

 /**
  * Convert WowBB URLs pasted in text fields into ocPortal ones.
  *
  * @param  string			The text field text (e.g. a post)
  * @param  object			The DB connection to import from
  * @param  string			The table prefix the target prefix is using
  * @param  PATH			The base directory we are importing from
  * @return string			The new text field text
  */
 function fix_links($post, $db, $table_prefix, $file_base)
 {
     require $file_base . '/config.php';
     $OLD_BASE_URL = constant('HOMEPAGE');
     $post = preg_replace_callback('#' . preg_quote($OLD_BASE_URL) . '/(view_topic\\.php\\?id=)(\\d*)&forum_id=(\\d*)#', array($this, '_fix_links_callback_topic'), $post);
     $post = preg_replace_callback('#' . preg_quote($OLD_BASE_URL) . '/(view_forum\\.php\\?id=)(\\d*)#', array($this, '_fix_links_callback_forum'), $post);
     $post = preg_replace_callback('#' . preg_quote($OLD_BASE_URL) . '/(view_user\\.php\\?id=)(\\d*)#', array($this, '_fix_links_callback_member'), $post);
     $post = preg_replace('#:[0-9a-f]{10}#', '', $post);
     $post = @html_entity_decode($post, ENT_QUOTES, get_charset());
     return $post;
 }
开发者ID:erico-deh,项目名称:ocPortal,代码行数:20,代码来源:wowbb.php

示例13: import_ocf_posts

 /**
  * Standard import function.
  *
  * @param  object			The DB connection to import from
  * @param  string			The table prefix the target prefix is using
  * @param  PATH			The base directory we are importing from
  */
 function import_ocf_posts($db, $table_prefix, $file_base)
 {
     global $STRICT_FILE;
     $row_start = 0;
     $rows = array();
     do {
         $rows = $db->query('SELECT * FROM ' . $table_prefix . 'post WHERE visible=1 ORDER BY postid', 200, $row_start);
         foreach ($rows as $row) {
             if (import_check_if_imported('post', strval($row['postid']))) {
                 continue;
             }
             $topic_id = import_id_remap_get('topic', strval($row['threadid']), true);
             if (is_null($topic_id)) {
                 import_id_remap_put('post', strval($row['postid']), -1);
                 continue;
             }
             $member_id = import_id_remap_get('member', strval($row['userid']), true);
             if (is_null($member_id)) {
                 $member_id = db_get_first_id();
             }
             // This speeds up addition... using the cache can reduce about 7/8 of a query per post on average
             global $TOPIC_FORUM_CACHE;
             if (array_key_exists($topic_id, $TOPIC_FORUM_CACHE)) {
                 $forum_id = $TOPIC_FORUM_CACHE[$topic_id];
             } else {
                 $forum_id = $GLOBALS['FORUM_DB']->query_value_null_ok('f_topics', 't_forum_id', array('id' => $topic_id));
                 if (is_null($forum_id)) {
                     continue;
                 }
                 $TOPIC_FORUM_CACHE[$topic_id] = $forum_id;
             }
             $title = '';
             if ($row['parentid'] == 0) {
                 $topics = $db->query('SELECT title FROM ' . $table_prefix . 'thread WHERE threadid=' . $row['threadid']);
                 $title = $topics[0]['title'];
             } elseif (!is_null($row['title'])) {
                 $title = $row['title'];
             }
             $post = $this->fix_links($row['pagetext'], $db, $table_prefix);
             $last_edit_by = NULL;
             $id_new = ocf_make_post($topic_id, @html_entity_decode($title, ENT_QUOTES, get_charset()), $post, 0, $row['parentid'] == 0, $row['visible'], 0, $row['username'], $row['ipaddress'], $row['dateline'], $member_id, NULL, NULL, $last_edit_by, false, false, $forum_id, false);
             import_id_remap_put('post', strval($row['postid']), $id_new);
         }
         $row_start += 200;
     } while (count($rows) > 0);
 }
开发者ID:erico-deh,项目名称:ocPortal,代码行数:53,代码来源:vb3.php

示例14: comcode_to_clean_text

/**
 * Make some Comcode more readable.
 *
 * @param  string			Comcode text to change
 * @return string			Clean text
 */
function comcode_to_clean_text($message_plain)
{
    //$message_plain=str_replace("\n",'',$message_plain);
    if (strpos($message_plain, '[') === false && strpos($message_plain, '{') === false) {
        return $message_plain;
    }
    require_code('tempcode_compiler');
    if (strpos($message_plain, '[code') === false && strpos($message_plain, '[no_parse') === false && strpos($message_plain, '[tt') === false) {
        // Change username links to plain username namings
        $message_plain = preg_replace('#\\{\\{([^\\}\\{]*)\\}\\}#', '\\1', $message_plain);
        // Remove directives etc
        do {
            $before = $message_plain;
            $message_plain = preg_replace('#\\{([^\\}\\{]*)\\}#', '', $message_plain);
        } while ($message_plain != $before);
        if (strpos($message_plain, '{') !== false) {
            $message_plain = static_evaluate_tempcode(template_to_tempcode($message_plain, 0, false, '', NULL, NULL, true));
        }
    }
    $match = array();
    if (preg_match("#\\[semihtml\\](.*)\\[\\/semihtml\\]#Us", $message_plain, $match) != 0) {
        require_code('comcode_from_html');
        $message_plain = str_replace($match[0], semihtml_to_comcode($match[0]), $message_plain);
    }
    if (preg_match("#^\\s*\\[html\\](.*)\\[\\/html\\]\\s*\$#Us", $message_plain, $match) != 0) {
        require_code('comcode_from_html');
        $message_plain = str_replace($match[0], semihtml_to_comcode($match[0]), $message_plain);
    }
    $message_plain = array_key_exists(1, $match) ? $match[1] : $message_plain;
    $message_plain = preg_replace("#\\[url=\"([^\"]*)\"(.*)\\]([^\\[\\]]*)\\[/url\\]#", '${1}', $message_plain);
    $message_plain = preg_replace("#\\[img(.*)\\]([^\\[\\]]*)\\[/img\\]#", '', $message_plain);
    $message_plain = @html_entity_decode(strip_tags($message_plain), ENT_QUOTES, get_charset());
    $message_plain = str_replace(']http', ']' . chr(10) . 'http', str_replace('[/url]', chr(10) . '[/url]', $message_plain));
    $message_plain = preg_replace('#\\[random [^=]*="([^"]*)"[^\\]]*\\].*\\[/random\\]#Us', '${1}', $message_plain);
    $message_plain = preg_replace('#\\[abbr="([^"]*)"[^\\]]*\\].*\\[/abbr\\]#Us', '${1}', $message_plain);
    $message_plain = preg_replace_callback('#\\[indent[^\\]]*\\](.*)\\[/indent\\]#Us', '_indent_callback', $message_plain);
    $message_plain = preg_replace_callback('#\\[title([^\\]])*\\](.*)\\[/title\\]#Us', '_title_callback', $message_plain);
    $message_plain = preg_replace_callback('#\\[box="([^"]*)"[^\\]]*\\](.*)\\[/box\\]#Us', '_box_callback', $message_plain);
    $tags_to_strip_inards = array('if_in_group', 'snapback', 'post', 'thread', 'topic', 'include', 'staff_note', 'attachment', 'attachment2', 'attachment_safe', 'contents', 'block', 'random');
    foreach ($tags_to_strip_inards as $s) {
        $message_plain = preg_replace('#\\[' . $s . '[^\\]]*\\].*\\[/' . $s . '\\]#Us', '', $message_plain);
    }
    $message_plain = preg_replace('#\\[surround="accessibility_hidden"\\].*\\[/surround\\]#Us', '', $message_plain);
    $tags_to_strip = array('surround', 'ticker', 'jumping', 'right', 'center', 'left', 'align', 'list', 'concepts', 'html', 'semihtml', 'concept', 'size', 'color', 'font', 'tt', 'address', 'sup', 'sub', 'box');
    foreach ($tags_to_strip as $s) {
        $message_plain = preg_replace('#\\[' . $s . '[^\\]]*\\](.*)\\[/' . $s . '\\]#U', '${1}', $message_plain);
    }
    $message_plain = str_replace(array('[/*]', '[*]', '[list]' . chr(10), chr(10) . '[/list]', '[list]', '[/list]', '[b]', '[/b]', '[i]', '[/i]', '[u]', '[/u]', '[highlight]', '[/highlight]'), array('', ' - ', '', '', '', '', '**', '**', '*', '*', '__', '__', '***', '***'), $message_plain);
    $message_plain = preg_replace('#\\[list[^\\[\\]]*\\]#', '', $message_plain);
    $message_plain = preg_replace('#\\{\\$,[^\\{\\}]*\\}#', '', $message_plain);
    return trim($message_plain);
}
开发者ID:erico-deh,项目名称:ocPortal,代码行数:58,代码来源:mail.php

示例15: sql_query

            $sql .= ", {$tbl_repeat} T" . " WHERE E.repeat_id={$repeat_id}" . " AND E.repeat_id=T.id";
        } else {
            $sql .= " WHERE E.id={$id}";
        }
        $sql .= " AND E.room_id=R.id\n              AND R.area_id=A.id";
        if ($series) {
            $sql .= " ORDER BY E.ical_recur_id";
        }
        $res = sql_query($sql);
        if ($res === FALSE) {
            trigger_error(sql_error(), E_USER_WARNING);
            fatal_error(FALSE, get_vocab("fatal_db_error"));
        }
        // Export the calendar
        require_once "functions_ical.inc";
        header("Content-Type: application/ics;  charset=" . get_charset() . "; name=\"" . $mail_settings['ics_filename'] . ".ics\"");
        header("Content-Disposition: attachment; filename=\"" . $mail_settings['ics_filename'] . ".ics\"");
        export_icalendar($res, $keep_private);
        exit;
    }
}
// PHASE 1 - VIEW THE ENTRY
// ------------------------
print_header($day, $month, $year, $area, isset($room) ? $room : "");
// Need to tell all the links where to go back to after an edit or delete
if (!isset($returl)) {
    if (isset($HTTP_REFERER)) {
        $returl = $HTTP_REFERER;
    } else {
        switch ($default_view) {
            case "month":
开发者ID:bdwong-mirrors,项目名称:mrbs,代码行数:31,代码来源:view_entry.php


注:本文中的get_charset函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。