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


PHP timer_start函数代码示例

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


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

示例1: log_start

 /**
  * Log start of request, for adding to log entry later.
  */
 private function log_start()
 {
     if ($this->logging) {
         $this->log_timestamp = microtime(TRUE);
         timer_start('openruth_net');
     }
 }
开发者ID:AnnaCaraman,项目名称:ding2,代码行数:10,代码来源:OpenruthClient.class.php

示例2: themeInit

function themeInit($archive)
{
    timer_start();
    $archive->parameter->pageSize = 5;
    if ($archive->is('single')) {
        $archive->content = prettify_replace($archive->content);
        $archive->content = url_target_replace($archive->content);
    }
}
开发者ID:m4html,项目名称:typecho-theme-Twentyfifteen,代码行数:9,代码来源:functions.php

示例3: load_controller

 /**
  * Load the content selected by the URI and save the output in load_area.
  * Leave the parameters null if you want to load automatically the controllers
  * 
  * @param string $controller selected controller
  * @param string $action selected action
  * @param string $params array of the selected actions
  * @param string $load_area selected load area where the controller is rendered
  */
 function load_controller($controller = null, $action = null, $params = array(), $load_area = "center")
 {
     // transform the controller string to capitalized. e.g. user => user, news_list => news_list
     $controller = strtolower($controller);
     $controller_file = self::$controllers_dir . "{$controller}/{$controller}." . self::$controller_extension;
     // include the file
     if (file_exists($controller_file = self::$controllers_dir . "{$controller}/{$controller}." . self::$controller_extension)) {
         require_once $controller_file;
     } else {
         return trigger_error("CONTROLLER: FILE <b>{$controller_file}</b> NOT FOUND ", E_USER_WARNING);
     }
     // define the class name of the controller
     $class = $controller . self::$controller_class_name;
     // check if the controller class exists
     if (class_exists($class)) {
         $controller_obj = new $class($this);
     } else {
         return trigger_error("CONTROLLER: CLASS <b>{$controller}</b> NOT FOUND ", E_USER_WARNING);
     }
     if ($action) {
         // start benchmark
         timer_start("controller");
         memory_usage_start("controller");
         // start the output buffer
         ob_start();
         // call the method filter_before
         call_user_func_array(array($controller_obj, "filter_before"), $params);
         // call the selected action
         $action_status = call_user_func_array(array($controller_obj, $action), $params);
         //call the method filter_after
         call_user_func_array(array($controller_obj, "filter_after"), $params);
         $html = ob_get_contents();
         // close the output buffer
         ob_end_clean();
         // verify that the action was executed
         if (false === $action_status) {
             $html = "Action <b>{$action}</b> not found in controller <b>{$class}</b>! Method not declared or declared with different private access";
         }
         $this->loaded_controller[] = array("controller" => $controller, "execution_time" => timer("controller"), "memory_used" => memory_usage("controller"));
         // if it is in ajax mode print and stop the execution of the script
         if ($this->ajax_mode) {
             echo $html;
             $this->_draw_ajax();
         } else {
             // save the output into the load_area array
             if (!isset($this->load_area_array[$load_area])) {
                 $this->load_area_array[$load_area] = array();
             }
             $this->load_area_array[$load_area][] = $html;
         }
     }
 }
开发者ID:jffuchs,项目名称:rainframework,代码行数:61,代码来源:Loader.php

示例4: a_thumbnail_rebuild

 /**
  * Rebuild the image
  * 
  * @access public
  * @return void
  * @author Nicolas Juen
  */
 public static function a_thumbnail_rebuild()
 {
     global $wpdb;
     // Get the nonce
     $nonce = isset($_POST['nonce']) ? $_POST['nonce'] : '';
     // Time a the begining
     timer_start();
     // Get the thumbnails
     $thumbnails = isset($_POST['thumbnails']) ? $_POST['thumbnails'] : NULL;
     // Check the nonce
     if (!wp_verify_nonce($nonce, 'regen')) {
         SIS_Admin_Main::displayJson(array('error' => _e('Trying to cheat ?', 'simple-image-sizes')));
     }
     // Get the id
     $id = isset($_POST["id"]) ? $_POST["id"] : 0;
     SIS_Admin_Main::displayJson(SIS_Admin_Main::thumbnail_rebuild($id, $thumbnails));
 }
开发者ID:EcvetStep,项目名称:ecvet-step.eu,代码行数:24,代码来源:post.php

示例5: bootstrap_configuration

function bootstrap_configuration()
{
    if (version_compare(PHP_VERSION, PHP_REQUIRED, '<')) {
        header($_SERVER['SERVER_PROTOCOL'] . ' 500 PHP_VERSION');
        exit;
    }
    if (get_magic_quotes_gpc() || get_magic_quotes_runtime()) {
        header($_SERVER['SERVER_PROTOCOL'] . ' 500 magic_quotes');
        exit;
    }
    date_default_timezone_set('PRC');
    ini_set('session.use_cookies', '1');
    ini_set('session.use_only_cookies', '1');
    ini_set('session.use_trans_sid', '0');
    ini_set('session.cache_limiter', '');
    timer_start();
    set_error_handler('pyramid_error_handler');
    set_exception_handler('pyramid_exception_handler');
}
开发者ID:royalwang,项目名称:Pyramid,代码行数:19,代码来源:bootstrap.php

示例6: thumbnail_rebuild

 /**
  * Rebuild the given attribute with the given thumbnails
  *
  * @param $att_id
  * @param $thumbnails
  *
  * @return array
  * @author Nicolas Juen
  */
 public static function thumbnail_rebuild($att_id, $thumbnails = null)
 {
     // Time a the begining
     timer_start();
     // Check Id
     if ((int) $att_id <= 0) {
         return array('time' => timer_stop(false, 4), 'error' => __('No id given in POST datas.', 'simple-image-sizes'));
     }
     // Get the path
     $fullsizepath = get_attached_file($att_id);
     // Regen the attachment
     if (false !== $fullsizepath && file_exists($fullsizepath)) {
         if (false == wp_update_attachment_metadata($att_id, self::wp_generate_attachment_metadata_custom($att_id, $fullsizepath, $thumbnails))) {
             return array('src' => wp_get_attachment_thumb_url($att_id), 'time' => timer_stop(false, 4), 'message' => sprintf(__('This file already exists in this size and have not been regenerated :<br/><a target="_blank" href="%1$s" >%2$s</a>', 'simple-image-sizes'), get_edit_post_link($att_id), get_the_title($att_id)));
         }
     } else {
         return array('src' => wp_get_attachment_thumb_url($att_id), 'time' => timer_stop(false, 4), 'error' => sprintf(__('This file does not exists and have not been regenerated :<br/><a target="_blank" href="%1$s" >%2$s</a>', 'simple-image-sizes'), get_edit_post_link($att_id), get_the_title($att_id)));
     }
     // Display the attachment url for feedback
     return array('time' => timer_stop(false, 4), 'src' => wp_get_attachment_thumb_url($att_id), 'title' => get_the_title($att_id));
 }
开发者ID:waynestedman,项目名称:commodore-new,代码行数:30,代码来源:main.php

示例7: sitebilder_inicializador

 private function sitebilder_inicializador($phase)
 {
     switch ($phase) {
         case SITEBILDER_CONFIGURATION:
             timer_start('config');
             $this->LoadConfig();
             $this->LoadConfigDb();
             $this->LoadConfigSmarty();
             $this->ConfigLocation();
             break;
         case SITEBILDER_LANGUAGE:
             $this->ListLanguages();
             $this->GetLanguage();
             $this->LoadLanguage();
             break;
         case SITEBILDER_ACCESS:
             if ($this->is_denied('host', ip_address())) {
                 header('HTTP/1.1 403 Forbidden');
                 print 'Sorry, ' . check_plain(ip_address()) . ' has been banned.';
                 exit;
             }
             break;
         case SITEBILDER_PERFIL:
             $this->LoadPerfil();
             break;
         case SITEBILDER_SESSION:
             session_start();
             $this->LoadMap();
             break;
         case SITEBILDER_PAGE:
             $this->LoadPages();
             $this->LoadModulo();
             break;
         case SITEBILDER_SAJAX:
             break;
         case SITEBILDER_FULL:
             break;
     }
 }
开发者ID:renatoinnocenti,项目名称:ModulosZend,代码行数:39,代码来源:lib.StartSite.php

示例8: timer_start

 private static function &_query($query, $args = NULL)
 {
     $false = FALSE;
     if (empty($query)) {
         return $false;
     }
     if (!isset($GLOBALS['sql_query_count'])) {
         $GLOBALS['sql_query_count'] = 0;
     } else {
         $GLOBALS['sql_query_count']++;
     }
     if (utopia::DebugMode()) {
         $tID = 'QRY' . $GLOBALS['sql_query_count'] . ': ' . $query;
         timer_start($tID, $args);
     }
     $pdo = self::connect();
     $pdo->reset();
     if (is_array($args)) {
         foreach ($args as $a) {
             $pdo->addByVal($a, self::getType($a));
         }
     }
     try {
         self::$queryCount++;
         $stm = $pdo->call($query);
         $stm->setFetchMode(PDO::FETCH_ASSOC);
     } catch (Exception $e) {
         if (utopia::DebugMode()) {
             $timetaken = timer_end($tID);
         }
         throw $e;
     }
     if (utopia::DebugMode()) {
         $timetaken = timer_end($tID);
     }
     return $stm;
 }
开发者ID:OptimalInternet,项目名称:uCore,代码行数:37,代码来源:database.php

示例9: index

 /**
  * Index all posts for a site or network wide
  *
  * @synopsis [--setup] [--network-wide] [--posts-per-page] [--no-bulk] [--offset] [--show-bulk-errors]
  * @param array $args
  *
  * @since 0.1.2
  *
  * @param array $assoc_args
  */
 public function index($args, $assoc_args)
 {
     $this->_connect_check();
     if (!empty($assoc_args['posts-per-page'])) {
         $assoc_args['posts-per-page'] = absint($assoc_args['posts-per-page']);
     } else {
         $assoc_args['posts-per-page'] = 350;
     }
     if (!empty($assoc_args['offset'])) {
         $assoc_args['offset'] = absint($assoc_args['offset']);
     } else {
         $assoc_args['offset'] = 0;
     }
     $total_indexed = 0;
     /**
      * Prior to the index command invoking
      * Useful for deregistering filters/actions that occur during a query request
      *
      * @since 1.4.1
      */
     do_action('ep_wp_cli_pre_index', $args, $assoc_args);
     // Deactivate our search integration
     $this->deactivate();
     timer_start();
     // Run setup if flag was passed
     if (isset($assoc_args['setup']) && true === $assoc_args['setup']) {
         // Right now setup is just the put_mapping command, as this also deletes the index(s) first
         $this->put_mapping($args, $assoc_args);
     }
     if (isset($assoc_args['network-wide']) && is_multisite()) {
         if (!is_numeric($assoc_args['network-wide'])) {
             $assoc_args['network-wide'] = 0;
         }
         WP_CLI::log(__('Indexing posts network-wide...', 'elasticpress'));
         $sites = ep_get_sites($assoc_args['network-wide']);
         foreach ($sites as $site) {
             switch_to_blog($site['blog_id']);
             $result = $this->_index_helper(isset($assoc_args['no-bulk']), $assoc_args['posts-per-page'], $assoc_args['offset'], isset($assoc_args['show-bulk-errors']));
             $total_indexed += $result['synced'];
             WP_CLI::log(sprintf(__('Number of posts synced on site %d: %d', 'elasticpress'), $site['blog_id'], $result['synced']));
             if (!empty($result['errors'])) {
                 WP_CLI::error(sprintf(__('Number of post sync errors on site %d: %d', 'elasticpress'), $site['blog_id'], count($result['errors'])));
             }
             restore_current_blog();
         }
         WP_CLI::log(__('Recreating network alias...', 'elasticpress'));
         $this->_create_network_alias();
         WP_CLI::log(sprintf(__('Total number of posts indexed: %d', 'elasticpress'), $total_indexed));
     } else {
         WP_CLI::log(__('Indexing posts...', 'elasticpress'));
         $result = $this->_index_helper(isset($assoc_args['no-bulk']), $assoc_args['posts-per-page'], $assoc_args['offset'], isset($assoc_args['show-bulk-errors']));
         WP_CLI::log(sprintf(__('Number of posts synced on site %d: %d', 'elasticpress'), get_current_blog_id(), $result['synced']));
         if (!empty($result['errors'])) {
             WP_CLI::error(sprintf(__('Number of post sync errors on site %d: %d', 'elasticpress'), get_current_blog_id(), count($result['errors'])));
         }
     }
     WP_CLI::log(WP_CLI::colorize('%Y' . __('Total time elapsed: ', 'elasticpress') . '%N' . timer_stop()));
     // Reactivate our search integration
     $this->activate();
     WP_CLI::success(__('Done!', 'elasticpress'));
 }
开发者ID:Blueprint-Marketing,项目名称:ElasticPress,代码行数:71,代码来源:wp-cli.php

示例10: ShowData


//.........这里部分代码省略.........
             echo '<th class="field-' . $fieldName . ' sortable' . $icon . '" data-field="' . $fieldName . '" data-mid="' . $this->GetModuleId() . '">';
             // title
             echo nl2br($fieldData['visiblename']);
             echo "</th>";
         }
         echo '</tr>';
         // close column headers
         $header_output = ob_get_clean();
         if ($this->flag_is_set(ALLOW_FILTER) && $this->hasEditableFilters === true && $this->hideFilters !== TRUE) {
             echo '<tr class="noprint"><td class="uFilters" colspan="' . $colcount . '">';
             // other filters
             foreach ($this->filters as $fType) {
                 foreach ($fType as $filterset) {
                     //flag_is_set($fieldData['options'],ALLOW_FILTER)) {
                     foreach ($filterset as $filterInfo) {
                         if ($filterInfo['it'] === itNONE) {
                             continue;
                         }
                         echo $this->GetFilterBox($filterInfo);
                     }
                 }
             }
             echo '</td></tr>';
         }
         if ($num_rows > 0 || $this->flag_is_set(ALLOW_ADD) || $this->hasEditableFilters === true) {
             echo $header_output;
         }
         echo "</thead>\n";
     }
     // now display data rows
     // process POST filters
     $total = array();
     $totalShown = array();
     timer_start('Draw Rows: ' . get_class($this));
     $gUrl = '';
     $body = "<tbody{$gUrl}>";
     if ($num_rows == 0) {
     } else {
         $i = 0;
         $fields = $this->GetFields();
         while ($row = $dataset->fetch()) {
             $i++;
             // move totals here
             foreach ($fields as $fieldName => $fieldData) {
                 switch ($this->GetFieldType($fieldName)) {
                     case ftNUMBER:
                     case ftCURRENCY:
                     case ftPERCENT:
                         if (!array_key_exists($fieldName, $total)) {
                             $total[$fieldName] = 0;
                         }
                         if (!array_key_exists($fieldName, $totalShown)) {
                             $totalShown[$fieldName] = 0;
                         }
                         $preProcessValue = floatval(preg_replace('/[^0-9\\.-]/', '', $this->PreProcess($fieldName, $row[$fieldName], $row)));
                         if ($i <= 150) {
                             $totalShown[$fieldName] += $preProcessValue;
                         }
                         $total[$fieldName] += $preProcessValue;
                         break;
                     default:
                         break;
                 }
             }
             $body .= $this->DrawRow($row);
         }
开发者ID:OptimalInternet,项目名称:uCore,代码行数:67,代码来源:forms.class.php

示例11: get_blocks

 /**
  * добавляет в глобальный шаблон блоки
  */
 function get_blocks($blocks = array())
 {
     foreach ($blocks as $block_name => $block) {
         # создаём объект
         $module_loader =& Registry::get('TModuleLoader');
         $class_name = isset($block['class']) ? $block['class'] : DEFAULT_CLASS;
         //$GLOBALS['blocks'][$class_name] = $module_loader->getModuleObject($class_name);
         $GLOBALS['blocks'][$class_name] =& Registry::get($class_name);
     }
     foreach ($blocks as $block_name => $block) {
         timer_start('block=' . $block_name);
         # массив данных текущего блока
         $data = array();
         $class_name = isset($block['class']) ? $block['class'] : DEFAULT_CLASS;
         $block['cache'] = isset($block['cache']) ? $block['cache'] : false;
         $tables = isset($block['tables']) ? $block['tables'] : array();
         $block['cache_tables'] = isset($block['cache_tables']) ? $block['cache_tables'] : array();
         if (CACHE_BLOCKS && $block['cache']) {
             // Очистка папки cache/blocks с вероятностью 0.001
             if (rand(0, 999) == 13) {
                 $this->cleanCache();
             }
             $cache_id = md5($module_loader->callModuleMethod($class_name, "_cache", array_merge($block, array('block_name' => $block_name))));
             if ($this->is_cached($this->content['type'], $block_name, $cache_id, $tables)) {
                 $data = $this->get_from_cache($this->content['type'], $block_name, $cache_id);
             } else {
                 $data = $this->generate_block_data($block_name, $block);
                 $this->save_in_cache($this->content['type'], $block_name, $cache_id, $data);
             }
         } else {
             $data = $this->generate_block_data($block_name, $block);
         }
         $this->tpl->assign((array) $data);
         timer_end('block=' . $block_name);
     }
 }
开发者ID:romlg,项目名称:cms36,代码行数:39,代码来源:page.class.php

示例12: timer_end

    $row['module_name']::Initialise();
    timer_end('Init: ' . $row['module_name']);
}
timer_end('Static Initialise');
uConfig::DefineConfig();
uConfig::ValidateConfig();
uEvents::TriggerEvent('ConfigDefined');
timer_start('Before Init');
uEvents::TriggerEvent('BeforeInit');
timer_end('Before Init');
timer_start('Table Initialise');
uTableDef::TableExists(null);
// cache table exists
$allmodules = utopia::GetModulesOf('uTableDef');
foreach ($allmodules as $row) {
    // must run second due to requiring GLOB_MOD to be setup fully
    timer_start('Init: ' . $row['module_name']);
    $obj = utopia::GetInstance($row['module_name']);
    $obj->AssertTable();
    // setup Parents
    timer_end('Init: ' . $row['module_name']);
}
timer_end('Table Initialise');
define('INIT_COMPLETE', TRUE);
timer_start('After Init');
uEvents::TriggerEvent('InitComplete');
uEvents::TriggerEvent('AfterInit');
timer_end('After Init');
if ($_SERVER['HTTP_HOST'] !== 'cli') {
    utopia::UseTemplate(TEMPLATE_DEFAULT);
}
开发者ID:OptimalInternet,项目名称:uCore,代码行数:31,代码来源:initialise.php

示例13: timer_start

# pop3-2-b2 mail to blog
# v0.3 20020716
# with photo attachment email hack
#
# Line 223 (or so) is the line that
# scales the image and puts it on the left.
# Change the left; to right; or whatever you want
# Change the width and height options also
# Next is to click-through to original image
#
# Line 263 (or so) has the category stuff
# there is a comment at the end of the section
#
require_once 'wp-config.php';
timer_start();
$use_cache = 1;
$output_debugging_info = 0;
# =1 if you want to output debugging info
$time_difference = get_settings('time_difference');
//if ($use_phoneemail) {
//	// if you're using phone email, the email will already be in your timezone
//	$time_difference = 0;
//}
//Get Server Time Zone
// If Server Time Zone is not collect, Please comment out following line;
$server_timezone = date("O") / 100;
// If Server Time Zone is not collect, Please uncomment following line and set collect timezone value;
// $server_timezone = 9
$weblog_timezone = $server_timezone + $time_difference;
error_reporting(2037);
开发者ID:BackupTheBerlios,项目名称:nobunobuxoops-svn,代码行数:30,代码来源:wp-moblog.php

示例14: wp_mail_receive

function wp_mail_receive()
{
    global $xoopsDB, $wpdb, $wp_id, $siteurl, $blog_charset, $wp_pop3;
    require_once ABSPATH . WPINC . '/class-pop3.php';
    timer_start();
    $use_cache = 1;
    $time_difference = get_settings('time_difference');
    // Get Server Time Zone
    // If Server Time Zone is not collect, Please comment out following line;
    $server_timezone = date("O");
    // echo "Server TimeZone is ".date('O')."<br />";
    // If Server Time Zone is not collect, Please uncomment following line and set collect timezone value;
    // $server_timezone = "+0900"; //This is a sample value for JST+0900
    $server_timezone = $server_timezone / 100;
    $weblog_timezone = $server_timezone + $time_difference;
    error_reporting(2037);
    $wp_pop3 = new POP3();
    if (!$wp_pop3->connect(get_settings('mailserver_url'), get_settings('mailserver_port'))) {
        echo "Ooops {$wp_pop3->ERROR} <br />\n";
        return;
    }
    $Count = $wp_pop3->login(get_settings('mailserver_login'), get_settings('mailserver_pass'));
    if ($Count == false) {
        if (!$wp_pop3->FP) {
            echo "Oooops Login Failed: {$wp_pop3->ERROR}<br />\n";
        } else {
            echo "No Message<br />\n";
            $wp_pop3->quit();
        }
        return;
    }
    // ONLY USE THIS IF YOUR PHP VERSION SUPPORTS IT!
    register_shutdown_function('wp_mail_quit');
    for ($iCount = 1; $iCount <= $Count; $iCount++) {
        $MsgOne = $wp_pop3->get($iCount);
        if (!$MsgOne || gettype($MsgOne) != 'array') {
            echo "oops, {$wp_pop3->ERROR}<br />\n";
            $wp_pop3->quit();
            return;
        }
        $content = '';
        $content_type = '';
        $boundary = '';
        $att_boundary = '';
        $hatt_boundary = '';
        $bodysignal = 0;
        $dmonths = array('Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec');
        while (list($lineNum, $line) = each($MsgOne)) {
            if (strlen($line) < 3) {
                $bodysignal = 1;
            }
            if ($bodysignal) {
                $content .= $line;
            } else {
                if (preg_match('/^Content-Type:\\s+(.*?)\\;/i', $line, $match)) {
                    $content_type = $match[1];
                    $content_type = strtolower($match[1]);
                }
                if ($content_type == 'multipart/mixed' && preg_match('/boundary=(?:")?([^;"\\s\\n]*?)(?:")?\\s*(?:$|;)/', $line, $match) && $att_boundary == '') {
                    $att_boundary = trim($match[1]);
                }
                if ($content_type == 'multipart/alternative' && preg_match('/boundary=(?:")?([^;"\\s\\n]*?)(?:")?\\s*(?:$|;)/', $line, $match) && $boundary == '') {
                    $boundary = trim($match[1]);
                }
                if ($content_type == 'multipart/related' && preg_match('/boundary=(?:")?([^;"\\s\\n]*?)(?:")?\\s*(?:$|;)/', $line, $match) && $hatt_boundary == '') {
                    $hatt_boundary = trim($match[1]);
                }
                if (preg_match('/Subject: /', $line)) {
                    $subject = trim($line);
                    $subject = substr($subject, 9, strlen($subject) - 9);
                    if (function_exists('mb_decode_mimeheader')) {
                        $subject1 = mb_decode_mimeheader($subject);
                        if ($subject != $subject) {
                            $sub_charset = mb_internal_encoding();
                        } else {
                            $sub_charset = "auto";
                        }
                        $subject = $subject1;
                    }
                    if (get_settings('use_phoneemail')) {
                        $subject = explode(get_settings('phoneemail_separator'), $subject);
                        $subject = trim($subject[0]);
                    }
                }
                if (preg_match('/Date: /', $line)) {
                    // of the form '20 Mar 2002 20:32:37'
                    $ddate = trim($line);
                    $ddate = str_replace('Date: ', '', $ddate);
                    if (strpos($ddate, ',')) {
                        $ddate = trim(substr($ddate, strpos($ddate, ',') + 1, strlen($ddate)));
                    }
                    $date_arr = explode(' ', $ddate);
                    $date_time = explode(':', $date_arr[3]);
                    $ddate_H = $date_time[0];
                    $ddate_i = $date_time[1];
                    $ddate_s = $date_time[2];
                    $ddate_m = $date_arr[1];
                    $ddate_d = $date_arr[0];
                    $ddate_Y = $date_arr[2];
                    $mail_timezone = trim(ereg_replace("\\([^)]*\\)", "", $date_arr[4])) / 100;
//.........这里部分代码省略.........
开发者ID:BackupTheBerlios,项目名称:nobunobuxoops-svn,代码行数:101,代码来源:wp-mail.php

示例15: bangpound_drupal_http_request

/**
 * Overrides Drupal core HTTP request function with Guzzle.
 *
 * @see drupal_http_request()
 */
function bangpound_drupal_http_request($url, array $options = array())
{
    $result = new stdClass();
    // Parse the URL and make sure we can handle the schema.
    $uri = @parse_url($url);
    if ($uri == FALSE) {
        $result->error = 'unable to parse URL';
        $result->code = -1001;
        return $result;
    }
    if (!isset($uri['scheme'])) {
        $result->error = 'missing schema';
        $result->code = -1002;
        return $result;
    }
    timer_start(__FUNCTION__);
    // Merge the default options.
    $options += array('headers' => array(), 'method' => 'GET', 'data' => NULL, 'max_redirects' => 3, 'timeout' => 30.0, 'context' => NULL);
    // Merge the default headers.
    $options['headers'] += array('User-Agent' => 'Drupal (+http://drupal.org/)');
    // Concessions to Guzzle.
    if (isset($options['data'])) {
        $options['body'] = $options['data'];
    }
    if (!$options['max_redirects']) {
        $options['allow_redirects'] = FALSE;
    }
    // Use a proxy if one is defined and the host is not on the excluded list.
    $proxy_server = variable_get('proxy_server', '');
    if ($proxy_server && _drupal_http_use_proxy($uri['host'])) {
        // Set the scheme so we open a socket to the proxy server.
        $uri['scheme'] = 'proxy';
        // Set the path to be the full URL.
        $uri['path'] = $url;
        // Since the URL is passed as the path, we won't use the parsed query.
        unset($uri['query']);
        // Add in username and password to Proxy-Authorization header if needed.
        if ($proxy_username = variable_get('proxy_username', '')) {
            $proxy_password = variable_get('proxy_password', '');
            $options['headers']['Proxy-Authorization'] = 'Basic ' . base64_encode($proxy_username . (!empty($proxy_password) ? ":" . $proxy_password : ''));
        }
        // Some proxies reject requests with any User-Agent headers, while others
        // require a specific one.
        $proxy_user_agent = variable_get('proxy_user_agent', '');
        // The default value matches neither condition.
        if ($proxy_user_agent === NULL) {
            unset($options['headers']['User-Agent']);
        } elseif ($proxy_user_agent) {
            $options['headers']['User-Agent'] = $proxy_user_agent;
        }
    }
    // Make sure the socket opened properly.
    // @todo Migrate error checking.
    // If the server URL has a user then attempt to use basic authentication.
    // @todo Migrate authentication.
    // If the database prefix is being used by SimpleTest to run the tests in a copied
    // database then set the user-agent header to the database prefix so that any
    // calls to other Drupal pages will run the SimpleTest prefixed database. The
    // user-agent is used to ensure that multiple testing sessions running at the
    // same time won't interfere with each other as they would if the database
    // prefix were stored statically in a file or database variable.
    $test_info =& $GLOBALS['drupal_test_info'];
    if (!empty($test_info['test_run_id'])) {
        $options['headers']['User-Agent'] = drupal_generate_test_ua($test_info['test_run_id']);
    }
    // Calculate how much time is left of the original timeout value.
    $timeout = $options['timeout'] - timer_read(__FUNCTION__) / 1000;
    if ($timeout > 0) {
        /** @see \Guzzle\Http\StaticClient::request() */
        static $client;
        if (!$client) {
            $client = new \Guzzle\Http\Client();
        }
        $request = $client->createRequest($options['method'], $url, null, null, $options);
        if ($options['max_redirects']) {
            $client->getConfig()->set('redirect.max', $options['max_redirects']);
        }
        if (isset($options['stream'])) {
            if ($options['stream'] instanceof \Guzzle\Stream\StreamRequestFactoryInterface) {
                $response = $options['stream']->fromRequest($request);
            } elseif ($options['stream'] == true) {
                $streamFactory = new \Guzzle\Stream\PhpStreamRequestFactory();
                $response = $streamFactory->fromRequest($request);
            }
        } else {
            $response = $request->send();
        }
        $result->request = $request->__toString();
    } else {
        $result->code = HTTP_REQUEST_TIMEOUT;
        $result->error = 'request timed out';
        return $result;
    }
    if (isset($response)) {
        // Parse response headers from the response body.
//.........这里部分代码省略.........
开发者ID:bangpound,项目名称:drupal-bridge,代码行数:101,代码来源:override_functions.php


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