Esempio n. 1
0
 /**
  * 获取单例句柄
  *
  * @access public
  * @return Typecho_Response
  */
 public static function getInstance()
 {
     if (null === self::$_instance) {
         self::$_instance = new Typecho_Response();
     }
     return self::$_instance;
 }
 /**
  * 缓存清空
  *
  * @access private
  * @return void
  */
 private function deletefile()
 {
     $path = __TYPECHO_ROOT_DIR__ . '/usr/plugins/cPlayer/cache/';
     foreach (glob($path . '*') as $filename) {
         unlink($filename);
     }
     Typecho_Widget::widget('Widget_Notice')->set(_t('歌词缓存已清空!'), NULL, 'success');
     Typecho_Response::getInstance()->goBack();
 }
Esempio n. 3
0
    /**
     * 输出错误页面
     *
     * @access public
     * @param mixed $exception 错误信息
     * @return void
     */
    public static function error($exception)
    {
        $isException = is_object($exception);
        $message = '';
        if ($isException) {
            $code = $exception->getCode();
            $message = $exception->getMessage();
        } else {
            $code = $exception;
        }
        $charset = self::$charset;
        if ($isException && $exception instanceof Typecho_Db_Exception) {
            $code = 500;
            @error_log($message);
            //覆盖原始错误信息
            $message = 'Database Server Error';
            if ($exception instanceof Typecho_Db_Adapter_Exception) {
                $code = 503;
                $message = 'Error establishing a database connection';
            } else {
                if ($exception instanceof Typecho_Db_Query_Exception) {
                    $message = 'Database Query Error';
                }
            }
        } else {
            switch ($code) {
                case 500:
                    $message = 'Server Error';
                    break;
                case 404:
                    $message = 'Page Not Found';
                    break;
                default:
                    $code = 'Error';
                    break;
            }
        }
        /** 设置http code */
        if (is_numeric($code) && $code > 200) {
            Typecho_Response::setStatus($code);
        }
        $message = nl2br($message);
        if (defined('__TYPECHO_EXCEPTION_FILE__')) {
            require_once __TYPECHO_EXCEPTION_FILE__;
        } else {
            echo <<<EOF
<!DOCTYPE html>
<html lang="en">
    <head>
        <meta charset="{$charset}">
        <title>{$code}</title>
        <style>
            html {
                padding: 50px 10px;
                font-size: 16px;
                line-height: 1.4;
                color: #666;
                background: #F6F6F3;
                -webkit-text-size-adjust: 100%;
                -ms-text-size-adjust: 100%;
            }

            html,
            input { font-family: "Helvetica Neue", Helvetica, Arial, sans-serif; }
            body {
                max-width: 500px;
                _width: 500px;
                padding: 30px 20px;
                margin: 0 auto;
                background: #FFF;
            }
            ul {
                padding: 0 0 0 40px;
            }
            .container {
                max-width: 380px;
                _width: 380px;
                margin: 0 auto;
            }
        </style>
    </head>
    <body>
        <div class="container">
            {$message}
        </div>
    </body>
</html>
EOF;
        }
        exit;
    }
 protected function throw403()
 {
     Typecho_Response::setStatus(403);
     $this->response->throwJson(array('status' => '403 Forbidden.'));
 }
Esempio n. 5
0
 /**
  * 工厂方法,将类静态化放置到列表中
  *
  * @access public
  * @param string $alias 组件别名
  * @param mixed $params 传递的参数
  * @param mixed $request 前端参数
  * @param boolean $enableResponse 是否允许http回执
  * @return object
  * @throws Typecho_Exception
  */
 public static function widget($alias, $params = NULL, $request = NULL, $enableResponse = true)
 {
     $parts = explode('@', $alias);
     $className = $parts[0];
     $alias = empty($parts[1]) ? $className : $parts[1];
     if (isset(self::$_widgetAlias[$className])) {
         $className = self::$_widgetAlias[$className];
     }
     if (!isset(self::$_widgetPool[$alias])) {
         /** 如果类不存在 */
         if (!class_exists($className)) {
             throw new Typecho_Widget_Exception($className);
         }
         /** 初始化request */
         if (!empty($request)) {
             $requestObject = new Typecho_Request();
             $requestObject->setParams($request);
         } else {
             $requestObject = Typecho_Request::getInstance();
         }
         /** 初始化response */
         $responseObject = $enableResponse ? Typecho_Response::getInstance() : Typecho_Widget_Helper_Empty::getInstance();
         /** 初始化组件 */
         $widget = new $className($requestObject, $responseObject, $params);
         $widget->execute();
         self::$_widgetPool[$alias] = $widget;
     }
     return self::$_widgetPool[$alias];
 }
Esempio n. 6
0
<?php

!defined('__TYPECHO_ROOT_DIR__') and exit;
$options = Helper::options();
$siteUrl = $options->siteUrl;
$isRewrite = $options->rewrite;
$absUrl = $isRewrite ? rtrim($siteUrl, '/') : $siteUrl . "index.php";
Typecho_Response::getInstance()->redirect($absUrl . __TYPECHO_ADMIN_DIR__ . 'dev-tool/index');
Esempio n. 7
0
 /**
  * 工厂方法,将类静态化放置到列表中
  *
  * @access public
  * @param string $alias 组件别名
  * @param mixed $params 传递的参数
  * @param mixed $request 前端参数
  * @param boolean $enableResponse 是否允许http回执
  * @return object
  * @throws Typecho_Exception
  */
 public static function widget($alias, $params = NULL, $request = NULL, $enableResponse = true)
 {
     list($className) = explode('@', $alias);
     if (!isset(self::$_widgetPool[$alias])) {
         $fileName = str_replace('_', '/', $className) . '.php';
         require_once $fileName;
         /** 如果类不存在 */
         if (!class_exists($className)) {
             /** Typecho_Exception */
             require_once 'Typecho/Widget/Exception.php';
             throw new Typecho_Widget_Exception($className);
         }
         /** 初始化request */
         if (!empty($request)) {
             $requestObject = new Typecho_Request();
             $requestObject->setParams($request);
         } else {
             $requestObject = Typecho_Request::getInstance();
         }
         /** 初始化response */
         $responseObject = $enableResponse ? Typecho_Response::getInstance() : Typecho_Widget_Helper_Empty::getInstance();
         /** 初始化组件 */
         $widget = new $className($requestObject, $responseObject, $params);
         $widget->execute();
         self::$_widgetPool[$alias] = $widget;
     }
     return self::$_widgetPool[$alias];
 }
Esempio n. 8
0
    /**
     * 输出错误页面
     *
     * @access public
     * @param mixed $exception 错误信息
     * @return void
     */
    public static function error($exception)
    {
        $isException = is_object($exception);
        if ($isException) {
            $code = $exception->getCode();
            $message = $exception->getMessage();
        } else {
            $code = $exception;
        }
        require_once 'Typecho/Response.php';
        $charset = self::$charset;
        if ($isException && $exception instanceof Typecho_Db_Exception) {
            $code = 500;
            @error_log($message);
            //覆盖原始错误信息
            $message = 'Database Server Error';
            if ($exception instanceof Typecho_Db_Adapter_Exception) {
                $code = 503;
                $message = 'Error establishing a database connection';
            } else {
                if ($exception instanceof Typecho_Db_Query_Exception) {
                    $message = 'Database Query Error';
                }
            }
        } else {
            switch ($code) {
                case 500:
                    $message = 'Server Error';
                    break;
                case 404:
                    $message = 'Page Not Found';
                    break;
                default:
                    $code = 'Error';
                    break;
            }
        }
        /** 设置http code */
        if (is_numeric($code) && $code > 200) {
            require_once 'Typecho/Response.php';
            Typecho_Response::setStatus($code);
        }
        $message = nl2br($message);
        if (defined('__TYPECHO_EXCEPTION_FILE__')) {
            require_once __TYPECHO_EXCEPTION_FILE__;
        } else {
            echo <<<EOF
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <meta http-equiv="Content-Type" content="text/html; charset={$charset}" />
    <title>{$code}</title>

    <style type="text/css">
        body {
            background: #f7fbe9;
            font-family: "Lucida Grande","Lucida Sans Unicode",Tahoma,Verdana;
        }

        #error {
            background: #333;
            width: 360px;
            margin: 0 auto;
            margin-top: 100px;
            color: #fff;
            padding: 10px;

            -moz-border-radius-topleft: 4px;
            -moz-border-radius-topright: 4px;
            -moz-border-radius-bottomleft: 4px;
            -moz-border-radius-bottomright: 4px;
            -webkit-border-top-left-radius: 4px;
            -webkit-border-top-right-radius: 4px;
            -webkit-border-bottom-left-radius: 4px;
            -webkit-border-bottom-right-radius: 4px;

            border-top-left-radius: 4px;
            border-top-right-radius: 4px;
            border-bottom-left-radius: 4px;
            border-bottom-right-radius: 4px;
        }

        h1 {
            padding: 10px;
            margin: 0;
            font-size: 36px;
        }

        p {
            padding: 0 20px 20px 20px;
            margin: 0;
            font-size: 12px;
        }

        img {
            padding: 0 0 5px 260px;
        }
    </style>
</head>
<body>
    <div id="error">
        <h1>{$code}</h1>
        <p>{$message}</p>
        <img src="?464D-E63E-9D08-97E2-16DD-6A37-BDEC-6021" />
    </div>
</body>
</html>
EOF;
        }
        exit;
    }
Esempio n. 9
0
 public function __construct()
 {
     $this->response = Typecho_Response::getInstance();
     $this->request = Typecho_Request::getInstance();
 }
Esempio n. 10
0
        }
    }
    if (strpos($do, 'clear') !== false) {
        try {
            $cleartype = substr($do, 6);
            $options = Typecho_Widget::widget('Widget_Options');
            $timeStamp = $options->gmtTime;
            $offset = $options->timezone - $options->serverTimezone;
            $gtime = $timeStamp + $offset;
            $lowtime = $gtime - $cleartype * 86400;
            $db->query($db->delete($prefix . 'logs')->where('ltime < ?', $lowtime));
            Typecho_Widget::widget('Widget_Notice')->set('清除日志成功', NULL, 'success');
            Typecho_Response::redirect(Typecho_Common::url('extending.php?panel=Robots%2FLogs.php', $options->adminUrl));
        } catch (Typecho_Db_Exception $e) {
            Typecho_Widget::widget('Widget_Notice')->set('清除日志失败', NULL, 'notice');
            Typecho_Response::redirect(Typecho_Common::url('extending.php?panel=Robots%2FLogs.php', $options->adminUrl));
        }
    }
}
if (isset($_POST['oldtype'])) {
    $oldtype = $_POST['oldtype'];
}
if (isset($_POST['rpage']) && $_POST['rtype'] !== '') {
    $rtype = $_POST['rtype'];
    if ($oldtype !== $rtype) {
        $p = 1;
    }
    $logs = $db->fetchAll($db->select()->from($prefix . 'logs')->where('bot = ?', $rtype)->order($prefix . 'logs.lid', Typecho_Db::SORT_DESC)->page($p, $pagecount));
    $rows = count($db->fetchAll($db->select('lid')->from($prefix . 'logs')->where('bot = ?', $rtype)));
} else {
    $logs = $db->fetchAll($db->select()->from($prefix . 'logs')->order($prefix . 'logs.lid', Typecho_Db::SORT_DESC)->page($p, $pagecount));
Esempio n. 11
0
<?php

!defined('__TYPECHO_ROOT_DIR__') and exit;
$options = Helper::options();
$siteUrl = $options->siteUrl;
$isRewrite = $options->rewrite;
$absUrl = $isRewrite ? rtrim($siteUrl, '/') : $siteUrl . "index.php";
Typecho_Response::getInstance()->redirect($absUrl . __TYPECHO_ADMIN_DIR__ . 'app-store/market');
Esempio n. 12
0
 /**
  *显示错误信息并跳回登录界面
  *@return void
  */
 public static function showErrorMsg($msg)
 {
     $referer = isset($_SERVER['HTTP_REFERER']) ? $_SERVER['HTTP_REFERER'] : 'javascript:history.back(-1);';
     Typecho_Widget::widget('Widget_Notice')->set(_t($msg), 'error');
     Typecho_Response::redirect($referer);
 }
Esempio n. 13
0
    $file = dirname(__FILE__) . "/themecfg.json";
    $opt = array();
    if (file_exists($file)) {
        $opt = @Json::decode(@file_get_contents($file), true);
        if (!is_array($opt)) {
            $opt = array();
        }
    }
    $form = getThemeForm($_GET["cfgtheme"]);
    $opt[$_GET["cfgtheme"]] = $form->getAllRequest();
    @file_put_contents($file, @Json::encode($opt));
    Typecho_Widget::widget('Widget_Notice')->set(_t('主题配置保存成功'), 'success');
    Typecho_Response::redirect(Helper::url('ThemeShow/config.php') . "&theme=" . $_GET["cfgtheme"]);
}
if (isset($_POST["theme"])) {
    Typecho_Response::redirect(Helper::url('ThemeShow/config.php') . "&theme=" . $_POST["theme"]);
}
$currTheme = empty($_GET["theme"]) ? false : $_GET["theme"];
?>

<div class="main">
    <div class="body container">
        <?php 
include 'page-title.php';
?>
        <div class="row typecho-page-main" role="main">
            <div class="col-mb-12">
                <ul class="typecho-option-tabs fix-tabs clearfix"><?php 
if ($currTheme) {
    ?>
                    <li><a href="<?php 
Esempio n. 14
0
 /**
  * 重设自定义链接
  */
 public function resetLink()
 {
     $link = $this->request->link;
     Helper::removeRoute('go');
     Helper::addRoute('go', $link, 'GoLinks_Action', 'golink');
     Typecho_Response::throwJson('success');
 }