Example #1
0
 public function receive()
 {
     $this->checkConnection();
     Debug_Profiler::__do("receive");
     $rcvd = "";
     $rcvd = fread($this->socket, 4096);
     Debug_Profiler::__do("received: " . htmlentities($rcvd));
     $this->serverStream[$this->messageId++] = $rcvd;
     if (strlen($rcvd) > 0) {
         return $rcvd;
     } else {
         return false;
     }
 }
Example #2
0
 public function __construct($host, $port, $realm, $username, $password, $digestURI)
 {
     $this->socket = new Socket_Client($host, $port);
     Debug_Profiler::__do("connectionEstablished");
     $this->realm = $realm;
     $this->handshake();
     Debug_Profiler::__do("handshakeComplete. connID={$this->connectionId}");
     $this->authenticate($username, $password, $digestURI);
     if (!$this->isAuthenticated()) {
         throw new Exception("Authentication failed");
     }
     Debug_Profiler::__do("authed ok");
     $this->bindService();
     Debug_Profiler::__do("service bound");
 }
Example #3
0
 /**
  * @return Profiler
  */
 public function profiler($type = 'default')
 {
     return Debug_Profiler::instance($type);
 }
Example #4
0
 public static function setup()
 {
     static $run = null;
     if (!$run) {
         /**
          * 是否管理模式
          *
          * @var boolean
          */
         \define('IS_ADMIN_MODE', false);
         $is_online_debug = function () {
             if (!isset($_COOKIE['_debug_open'])) {
                 return false;
             }
             if (!isset(\Bootstrap::$config['core']['debug_open_password'])) {
                 return false;
             }
             if (!\is_array(\Bootstrap::$config['core']['debug_open_password'])) {
                 \Bootstrap::$config['core']['debug_open_password'] = array((string) \Bootstrap::$config['core']['debug_open_password']);
             }
             foreach (\Bootstrap::$config['core']['debug_open_password'] as $item) {
                 if ($_COOKIE['_debug_open'] == \Bootstrap::get_debug_hash($item)) {
                     return true;
                 }
             }
             return false;
         };
         if ($is_online_debug()) {
             $local_debug = true;
         } elseif (isset(\Bootstrap::$config['core']['local_debug_cfg']) && \Bootstrap::$config['core']['local_debug_cfg']) {
             if (\function_exists('\\get_cfg_var')) {
                 $local_debug = \get_cfg_var(\Bootstrap::$config['core']['local_debug_cfg']) ? true : false;
             } else {
                 $local_debug = false;
             }
         } else {
             $local_debug = false;
         }
         /**
          * 是否AJAX请求
          *
          * @var boolean
          */
         \define('IS_DEBUG', $local_debug);
         if (\IS_DEBUG && isset(\Bootstrap::$config['core']['libraries']['debug']) && \is_array(\Bootstrap::$config['core']['libraries']['debug']) && \Bootstrap::$config['core']['libraries']['debug']) {
             foreach (\Bootstrap::$config['core']['libraries']['debug'] as $lib) {
                 static::import_library($lib);
             }
         }
         static::$project =& \Bootstrap::$project;
         static::$include_puth =& \Bootstrap::$include_path;
         static::$charset = \Bootstrap::$config['core']['charset'];
         # 检查\Bootstrap版本
         if (\version_compare(\Bootstrap::VERSION, '2.0', '<')) {
             static::show_500('系统\\Bootstrap版本太低,请先升级\\Bootstrap。');
             exit;
         }
         if ((\IS_CLI || \IS_DEBUG) && \class_exists('\\DevException', true)) {
             # 注册脚本
             \register_shutdown_function(array('\\DevException', 'shutdown_handler'));
             # 捕获错误
             \set_exception_handler(array('\\DevException', 'exception_handler'));
             \set_error_handler(array('\\DevException', 'error_handler'), \error_reporting());
         } else {
             # 注册脚本
             \register_shutdown_function(array('\\Core', 'shutdown_handler'));
             # 捕获错误
             \set_exception_handler(array('\\Core', 'exception_handler'));
             \set_error_handler(array('\\Core', 'error_handler'), \error_reporting());
         }
         if (!\IS_CLI) {
             \header('X-Powered-By: PHP/' . \PHP_VERSION . ', MyQEE/' . static::VERSION);
             \HttpIO::setup();
         }
         if (\IS_SYSTEM_MODE && false === static::check_system_request_allow()) {
             # 内部请求验证不通过
             static::show_500('system request hash error');
         }
     }
     if (\IS_DEBUG && isset($_REQUEST['debug']) && \class_exists('\\Debug_Profiler', true)) {
         \Debug_Profiler::setup();
     }
     if (!\IS_CLI) {
         \register_shutdown_function(function () {
             \HttpIO::send_headers();
             # 输出内容
             echo \HttpIO::$body;
             if ($_GET['test']) {
                 //TODO///////TEST
                 echo '<br><pre>';
                 echo \microtime(1) - \START_TIME;
                 echo "\n";
                 echo (\memory_get_usage() - \START_MEMORY) / 1024 . 'kb';
                 echo "\n";
                 echo \memory_get_usage() / 1024 . 'kb';
                 echo "\n";
                 echo '<br><hr>include path<br>';
                 \print_r(\Bootstrap::$include_path);
                 \print_r(\get_included_files());
                 echo '</pre>';
             }
         });
     }
 }
Example #5
0
            ?>
</td>
            <td style="width:88%"><?php 
            echo Core::debug_path($value);
            ?>
</td>
        </tr>
            <?php 
        }
        ?>
</table><?php 
    }
    ?>
<table class="profiler">
        <?php 
    $stats = Debug_Profiler::application();
    ?>
        <tr class="final profiler_mark profiler_time">
            <th class="profiler_name" rowspan="2" style="float:none;"><?php 
    echo 'Application Execution (' . $stats['count'] . ')';
    ?>
</th>
            <?php 
    foreach (array('min', 'max', 'average', 'current') as $key) {
        ?>
            <td class="profiler_<?php 
        echo $key;
        ?>
"><?php 
        echo number_format($stats[$key]['time'], 6), ' ', 'seconds';
        ?>
Example #6
0
<?php

function __autoload($className)
{
    global $conf;
    $fileparts = explode("_", $className);
    $classPath = $conf['paths']['basePath'] . "lib/" . implode("/", $fileparts) . ".inc.php";
    require $classPath;
}
// begin program execution
define("DEBUG_ENABLED", true);
set_time_limit(30);
$profiler = new Debug_Profiler();
$template = new Template_Base("wrapper");
if (isset($_REQUEST['xmpp'])) {
    try {
        $_xmpp = new XMPP_MucClient($_REQUEST['xmpp']['host'], $_REQUEST['xmpp']['port'], $_REQUEST['xmpp']['realm'], $_REQUEST['xmpp']['username'], $_REQUEST['xmpp']['password'], "xmpp/" . $_REQUEST['xmpp']['realm']);
        if ($_xmpp->isAuthenticated()) {
            $template->populate("status", "Authenticated ok");
        } else {
            $template->populate("status", "Could not authenticate");
        }
        $template->populate("loginform", "");
    } catch (Exception $e) {
        $template->setSubTemplate("loginform", "login");
        $template->populate("status", "<b>Something went wrong:</b><br />" . $e->getMessage() . "<br /><br />");
    }
} else {
    $template->setSubTemplate("loginform", "login");
    $template->populate("status", "");
}