Beispiel #1
0
 /**
  * 获取实例
  * @access public
  * @param bool $isCommandLine 是否为命令行模式? 默认为 FALSE
  * @param bool $is_compile_model 是否编译框架代码再运行?默认为TRUE
  * @return XF_Application
  */
 public static function getInstance($isCommandLine = FALSE, $is_compile_model = TRUE)
 {
     if (self::$_instance === null) {
         self::$_instance = new self();
         self::$_instance->_init($isCommandLine, $is_compile_model);
     }
     return self::$_instance;
 }
Beispiel #2
0
 public function __toString()
 {
     $env = XF_Config::getInstance()->getEnvironmental();
     if ($env == 'development') {
         if ($this->code == 404) {
             header('HTTP/1.1 404 Not Found');
         } else {
             header('HTTP/1.1 500 Internal Server Error');
         }
         echo '<html xmlns="http://www.w3.org/1999/xhtml"><head>';
         echo '<title>Application Error</title>';
         echo '<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">';
         echo '</head><body>';
         echo '<pre>';
         echo parent::__toString();
         echo "\n\n\nRequest URL: " . XF_Controller_Request_Http::getInstance()->getRequestUrl() . "\n";
         echo "Params:\n";
         print_r(XF_Controller_Request_Http::getInstance()->getParams());
         echo "\nRewrites: \n";
         $debug = XF_DataPool::getInstance()->get('DEBUG');
         print_r($debug['Rewites']);
         $_querys = XF_DataPool::getInstance()->get('Querys', array());
         echo '<br/>Querys(' . count($_querys) . ') Time:' . XF_DataPool::getInstance()->get('QueryTimeCount', 0) . 's<br/>';
         print_r($_querys);
         echo '<br/>ReadCache(' . XF_DataPool::getInstance()->get('CacheTimeCount', 0) . 's)<br/>';
         print_r(XF_DataPool::getInstance()->get('CacheTimeList', array()));
         echo '<br/>RunApplication:' . XF_DataPool::getInstance()->get('RunApplication') . 's';
         echo '<br/>RunBootstrap:' . XF_DataPool::getInstance()->get('RunBootstrap') . 's';
         echo '<br/>LoadFile:' . sprintf("%.5fs", XF_Application::getInstance()->loadFileTime());
         echo '<br/>RunTime:' . sprintf('%.5f', microtime(true) - APP_START_TIME) . 's';
         echo '</pre>';
         echo '</body></html>';
     } else {
         $string = $title = '';
         if ($this->code == 404) {
             header('HTTP/1.1 404 Not Found');
             $title = 'Not Found';
             $string = '<h1 style="font-size:60px;">:( 404</h1>';
             $string .= '<p>您请求的网页不存在或已删除!<br/><br/><a href="/">返回</a></p>';
         } else {
             header('HTTP/1.1 500 Internal Server Error');
             $title = 'Internal Server Error';
             $string = '<h1 style="font-size:60px;">:( 500</h1>';
             $string .= '<p>您请求的网页存在错误,请稍后再访问!<br/><br/><a href="/">返回</a></p>';
         }
         echo '<html xmlns="http://www.w3.org/1999/xhtml"><head>';
         echo '<title>' . $title . '</title>';
         echo '<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">';
         echo '</head><body style="padding:10px;">';
         echo $string;
         echo '<p style="color:#999;font-size:14px;">URL:' . XF_Controller_Request_Http::getInstance()->getRequestUrl() . '</p>';
         echo '</body></html>';
     }
     return '';
 }
Beispiel #3
0
 /**
  * 动态加载将要调用的类文件
  * @access public
  * @param string $class
  * @return mixed
  */
 public function autoload($class)
 {
     $stime = microtime(true);
     if ($file = $this->_getFileName($class)) {
         if (is_file($file)) {
             require $file;
             if (!class_exists($class) && !interface_exists($class)) {
                 throw new XF_Loader_Exception("无法加载类或接口:" . $class . '(' . $file . ')');
             }
         }
     }
     XF_Application::getInstance()->addLoadFileTime(microtime(true) - $stime);
 }
Beispiel #4
0
<?php

/**
 * 图片处理程序
 * @author abiao 2015-7-14
 */
ini_set('display_errors', '1');
set_time_limit(0);
ini_set('date.timezone', 'PRC');
define('APPLICATION_PATH', realpath(dirname(__FILE__) . '/../application'));
define('XF_PATH', realpath(APPLICATION_PATH . '/../../xf'));
define('TEMP_PATH', APPLICATION_PATH . '/../temp');
require XF_PATH . '/Application.php';
$application = XF_Application::getInstance(TRUE, FALSE);
require XF_PATH . '/Custom/PHPThumb/ThumbLib.inc.php';
$file = 'http://gongpingjia.qiniudn.com/' . $_GET['file'] . '?imageView/1/w/198/h/120';
$saveFile = '';
$location = '';
$width = $height = 0;
//图片 90*60
if ($_GET['type'] == '96x') {
    $width = 90;
    $height = 60;
    $saveFile = APPLICATION_PATH . '/../static/cacheimg/96/' . $_GET['file'];
    $location = 'http://static.souchela.com/cacheimg/96/' . $_GET['file'];
}
//图片 120*80
if ($_GET['type'] == '128x') {
    $width = 120;
    $height = 80;
    $saveFile = APPLICATION_PATH . '/../static/cacheimg/128/' . $_GET['file'];
Beispiel #5
0
<?php

define('APPLICATION_PATH', realpath(dirname(__FILE__) . '/../application'));
define('XF_PATH', realpath(APPLICATION_PATH . '/../../'));
define('TEMP_PATH', APPLICATION_PATH . '/../temp');
require XF_PATH . '/Application.php';
$application = XF_Application::getInstance(false, false);
$application->getBootstrap()->run();
Beispiel #6
0
/**
 * 程序框加调试信息,主要用于开发测试
 */
function funcGetDebugContent()
{
    //$session = new XF_Session('XF_Role');
    //if ($session->isEmpty() == false && $session->read() == 1 && XF_Controller_Request_Http::getInstance()->getParam('debug') == 'true')
    //{
    echo "<pre>Debug info";
    echo "\n\nRequest URL: " . XF_Controller_Request_Http::getInstance()->getRequestUrl();
    echo "\n\nExceptionMessage: " . XF_DataPool::getInstance()->get('ExceptionMessage') . "\n";
    echo "\nParams:\n";
    print_r(XF_Controller_Request_Http::getInstance()->getParams());
    echo "\nRewrites: \n";
    $debug = XF_DataPool::getInstance()->get('DEBUG');
    print_r($debug['Rewites']);
    $_querys = XF_DataPool::getInstance()->get('ConnectionMysql', array());
    echo '<br/>Connection Mysql(' . count($_querys) . ') Time:' . XF_DataPool::getInstance()->get('ConnectionMysqlTimeCount', '0s') . '<br/>';
    print_r($_querys);
    $_querys = XF_DataPool::getInstance()->get('Querys', array());
    echo '<br/>Querys(' . count($_querys) . ') Time:' . XF_DataPool::getInstance()->get('QueryTimeCount', '0s') . '<br/>';
    print_r($_querys);
    $_solrs = XF_DataPool::getInstance()->get('Solrs', null);
    if (is_array($_solrs)) {
        echo '<br/>Solrs(' . count($_solrs) . ') Time:' . XF_DataPool::getInstance()->get('SolrTimeCount', '0s') . '<br/>';
        print_r($_solrs);
    }
    echo '<br/>ReadCache(' . XF_DataPool::getInstance()->get('CacheTimeCount', 0) . 's)<br/>';
    print_r(XF_DataPool::getInstance()->get('CacheTimeList'));
    echo '<br/>RunApplication:' . XF_DataPool::getInstance()->get('RunApplication') . 's';
    echo '<br/>RunBootstrap:' . XF_DataPool::getInstance()->get('RunBootstrap') . 's';
    echo '<br/>RunBootstraps:';
    print_r(XF_DataPool::getInstance()->get('Bootstrap_Inits'));
    echo '<br/>Load_Interface:';
    print_r(XF_DataPool::getInstance()->get('Load_Interface'));
    echo '<br/>LoadFile:' . sprintf("%.5fs", XF_Application::getInstance()->loadFileTime());
    echo '<br/>RunTime:' . sprintf("%.5fs", microtime(true) - APP_START_TIME);
    echo "</pre>";
    //}
}