mirror of
https://github.com/typecho/typecho.git
synced 2025-04-14 06:41:53 +02:00
fix sandbox
This commit is contained in:
parent
89649522c7
commit
6123f3ae62
@ -23,6 +23,8 @@ a.button:hover, a.balloon-button:hover { background-color: #A5CADC; color: #FFF;
|
||||
/** Forms */
|
||||
input[type=text], input[type=password], input[type=email], textarea { background: #FFF; border: 1px solid #D9D9D6; padding: 7px; border-radius: 2px; box-sizing: border-box; }
|
||||
|
||||
input[type=text]:disabled, input[type=text]:read-only, input[type=password]:disabled, input[type=password]:read-only, input[type=email]:disabled, input[type=email]:read-only, textarea:disabled, textarea:read-only { background: #F3F3F3; }
|
||||
|
||||
textarea { resize: vertical; line-height: 1.5; }
|
||||
|
||||
input[type="radio"], input[type="checkbox"] { margin-right: 3px; }
|
||||
@ -203,9 +205,6 @@ select { border: 1px solid #CCC; height: 28px; }
|
||||
|
||||
.typecho-foot .resource a { margin: 0 3px; color: #999; }
|
||||
|
||||
/* 低版本浏览器升级提示 */
|
||||
.browsehappy { border: none; text-align: center; }
|
||||
|
||||
/** 顶部消息样式 by 70 */
|
||||
.popup { display: none; position: absolute; top: 0; left: 0; margin: 0; padding: 8px 0; border: none; width: 100%; z-index: 10; text-align: center; border-radius: 0; }
|
||||
|
||||
|
@ -11,6 +11,10 @@ textarea {
|
||||
border-radius: 2px;
|
||||
|
||||
box-sizing: border-box;
|
||||
|
||||
&:disabled, &:read-only {
|
||||
background: #F3F3F3;
|
||||
}
|
||||
}
|
||||
|
||||
textarea {
|
||||
|
@ -418,7 +418,7 @@ require_once __TYPECHO_ROOT_DIR__ . '/var/Typecho/Common.php';
|
||||
|
||||
// init
|
||||
\Typecho\Common::init();
|
||||
|
||||
|
||||
// config db
|
||||
\$db = new \Typecho\Db('{$adapter}', '{$dbPrefix}');
|
||||
\$db->addServer(" . (var_export($dbConfig, true)) . ", \Typecho\Db::READ | \Typecho\Db::WRITE);
|
||||
@ -473,7 +473,9 @@ function install_check(string $type): bool
|
||||
if ($type == 'db_data' && empty($values)) {
|
||||
return false;
|
||||
}
|
||||
} catch (\Typecho\Db\Exception $e) {
|
||||
} catch (\Typecho\Db\Adapter\ConnectionException $e) {
|
||||
return true;
|
||||
} catch (\Typecho\Db\Adapter\SQLException $e) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -187,7 +187,7 @@ namespace Typecho {
|
||||
//覆盖原始错误信息
|
||||
$message = 'Database Server Error';
|
||||
|
||||
if ($exception instanceof \Typecho\Db\Adapter\Exception) {
|
||||
if ($exception instanceof \Typecho\Db\Adapter\SQLException) {
|
||||
$code = 503;
|
||||
$message = 'Error establishing a database connection';
|
||||
} elseif ($exception instanceof \Typecho\Db\Query\Exception) {
|
||||
|
18
var/Typecho/Db/Adapter/ConnectionException.php
Normal file
18
var/Typecho/Db/Adapter/ConnectionException.php
Normal file
@ -0,0 +1,18 @@
|
||||
<?php
|
||||
|
||||
namespace Typecho\Db\Adapter;
|
||||
|
||||
if (!defined('__TYPECHO_ROOT_DIR__')) {
|
||||
exit;
|
||||
}
|
||||
|
||||
use Typecho\Db\Exception as DbException;
|
||||
|
||||
/**
|
||||
* 数据库连接异常类
|
||||
*
|
||||
* @package Db
|
||||
*/
|
||||
class ConnectionException extends DbException
|
||||
{
|
||||
}
|
@ -11,7 +11,7 @@ trait MysqlTrait
|
||||
*
|
||||
* @param string $table
|
||||
* @param mixed $handle 连接对象
|
||||
* @throws Exception
|
||||
* @throws SQLException
|
||||
*/
|
||||
public function truncate(string $table, $handle)
|
||||
{
|
||||
|
@ -43,7 +43,7 @@ class Mysqli implements Adapter
|
||||
*
|
||||
* @param Config $config 数据库配置
|
||||
* @return \mysqli
|
||||
* @throws Exception
|
||||
* @throws ConnectionException
|
||||
*/
|
||||
public function connect(Config $config): \mysqli
|
||||
{
|
||||
@ -64,7 +64,7 @@ class Mysqli implements Adapter
|
||||
}
|
||||
|
||||
/** 数据库异常 */
|
||||
throw new Exception(@$this->dbLink->error);
|
||||
throw new ConnectionException(@$this->dbLink->error, @$this->dbLink->errno);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -87,7 +87,7 @@ class Mysqli implements Adapter
|
||||
* @param string|null $action 数据库动作
|
||||
* @param string|null $table 数据表
|
||||
* @return \mysqli_result
|
||||
* @throws Exception
|
||||
* @throws SQLException
|
||||
*/
|
||||
public function query(
|
||||
string $query,
|
||||
@ -101,7 +101,7 @@ class Mysqli implements Adapter
|
||||
}
|
||||
|
||||
/** 数据库异常 */
|
||||
throw new Exception($this->dbLink->error, $this->dbLink->errno);
|
||||
throw new SQLException($this->dbLink->error, $this->dbLink->errno);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -49,7 +49,7 @@ abstract class Pdo implements Adapter
|
||||
*
|
||||
* @param Config $config 数据库配置
|
||||
* @return \PDO
|
||||
* @throws Exception
|
||||
* @throws ConnectionException
|
||||
*/
|
||||
public function connect(Config $config): \PDO
|
||||
{
|
||||
@ -59,7 +59,7 @@ abstract class Pdo implements Adapter
|
||||
return $this->object;
|
||||
} catch (\PDOException $e) {
|
||||
/** 数据库异常 */
|
||||
throw new Exception($e->getMessage());
|
||||
throw new ConnectionException($e->getMessage(), $e->getCode());
|
||||
}
|
||||
}
|
||||
|
||||
@ -94,7 +94,7 @@ abstract class Pdo implements Adapter
|
||||
* @param string|null $action 数据库动作
|
||||
* @param string|null $table 数据表
|
||||
* @return \PDOStatement
|
||||
* @throws Exception
|
||||
* @throws SQLException
|
||||
*/
|
||||
public function query(
|
||||
string $query,
|
||||
@ -109,7 +109,7 @@ abstract class Pdo implements Adapter
|
||||
$resource->execute();
|
||||
} catch (\PDOException $e) {
|
||||
/** 数据库异常 */
|
||||
throw new Exception($e->getMessage(), $e->getCode());
|
||||
throw new SQLException($e->getMessage(), $e->getCode());
|
||||
}
|
||||
|
||||
return $resource;
|
||||
|
@ -3,7 +3,6 @@
|
||||
namespace Typecho\Db\Adapter\Pdo;
|
||||
|
||||
use Typecho\Config;
|
||||
use Typecho\Db\Adapter\Exception;
|
||||
use Typecho\Db\Adapter\MysqlTrait;
|
||||
use Typecho\Db\Adapter\Pdo;
|
||||
|
||||
|
@ -4,7 +4,7 @@ namespace Typecho\Db\Adapter\Pdo;
|
||||
|
||||
use Typecho\Config;
|
||||
use Typecho\Db;
|
||||
use Typecho\Db\Adapter\Exception;
|
||||
use Typecho\Db\Adapter\SQLException;
|
||||
use Typecho\Db\Adapter\Pdo;
|
||||
use Typecho\Db\Adapter\PgsqlTrait;
|
||||
|
||||
@ -41,7 +41,7 @@ class Pgsql extends Pdo
|
||||
* @param string|null $action 数据库动作
|
||||
* @param string|null $table 数据表
|
||||
* @return \PDOStatement
|
||||
* @throws Exception
|
||||
* @throws SQLException
|
||||
*/
|
||||
public function query(
|
||||
string $query,
|
||||
|
@ -35,7 +35,7 @@ class Pgsql implements Adapter
|
||||
*
|
||||
* @param Config $config 数据库配置
|
||||
* @return resource
|
||||
* @throws Exception
|
||||
* @throws ConnectionException
|
||||
*/
|
||||
public function connect(Config $config)
|
||||
{
|
||||
@ -50,7 +50,7 @@ class Pgsql implements Adapter
|
||||
}
|
||||
|
||||
/** 数据库异常 */
|
||||
throw new Exception(pg_last_error($dbLink));
|
||||
throw new ConnectionException(pg_last_error($dbLink));
|
||||
}
|
||||
|
||||
/**
|
||||
@ -74,7 +74,7 @@ class Pgsql implements Adapter
|
||||
* @param string|null $action 数据库动作
|
||||
* @param string|null $table 数据表
|
||||
* @return resource
|
||||
* @throws Exception
|
||||
* @throws SQLException
|
||||
*/
|
||||
public function query(string $query, $handle, int $op = Db::READ, ?string $action = null, ?string $table = null)
|
||||
{
|
||||
@ -84,7 +84,7 @@ class Pgsql implements Adapter
|
||||
}
|
||||
|
||||
/** 数据库异常 */
|
||||
throw new Exception(
|
||||
throw new SQLException(
|
||||
@pg_last_error($handle),
|
||||
pg_result_error_field(pg_get_result($handle), PGSQL_DIAG_SQLSTATE)
|
||||
);
|
||||
|
@ -28,7 +28,7 @@ trait PgsqlTrait
|
||||
*
|
||||
* @param string $table
|
||||
* @param resource $handle 连接对象
|
||||
* @throws Exception
|
||||
* @throws SQLException
|
||||
*/
|
||||
public function truncate(string $table, $handle)
|
||||
{
|
||||
@ -64,7 +64,7 @@ trait PgsqlTrait
|
||||
* @param $handle
|
||||
* @param string|null $action
|
||||
* @param string|null $table
|
||||
* @throws Exception
|
||||
* @throws SQLException
|
||||
*/
|
||||
protected function prepareQuery(string &$query, $handle, ?string $action = null, ?string $table = null)
|
||||
{
|
||||
@ -109,7 +109,7 @@ WHERE
|
||||
* @param resource $resource 查询的资源数据
|
||||
* @param resource $handle 连接对象
|
||||
* @return integer
|
||||
* @throws Exception
|
||||
* @throws SQLException
|
||||
*/
|
||||
public function lastInsertId($resource, $handle): int
|
||||
{
|
||||
@ -164,4 +164,4 @@ WHERE
|
||||
abstract public function quoteValue(string $string): string;
|
||||
|
||||
abstract public function fetch($resource): ?array;
|
||||
}
|
||||
}
|
||||
|
@ -13,6 +13,6 @@ use Typecho\Db\Exception as DbException;
|
||||
*
|
||||
* @package Db
|
||||
*/
|
||||
class Exception extends DbException
|
||||
class SQLException extends DbException
|
||||
{
|
||||
}
|
@ -35,7 +35,7 @@ class SQLite implements Adapter
|
||||
*
|
||||
* @param Config $config 数据库配置
|
||||
* @return \SQLite3
|
||||
* @throws Exception
|
||||
* @throws ConnectionException
|
||||
*/
|
||||
public function connect(Config $config): \SQLite3
|
||||
{
|
||||
@ -43,7 +43,7 @@ class SQLite implements Adapter
|
||||
$dbHandle = new \SQLite3($config->file);
|
||||
$this->isSQLite2 = version_compare(\SQLite3::version()['versionString'], '3.0.0', '<');
|
||||
} catch (\Exception $e) {
|
||||
throw new Exception($e->getMessage(), $e->getCode());
|
||||
throw new ConnectionException($e->getMessage(), $e->getCode());
|
||||
}
|
||||
|
||||
return $dbHandle;
|
||||
@ -69,7 +69,7 @@ class SQLite implements Adapter
|
||||
* @param string|null $action 数据库动作
|
||||
* @param string|null $table 数据表
|
||||
* @return \SQLite3Result
|
||||
* @throws Exception
|
||||
* @throws SQLException
|
||||
*/
|
||||
public function query(
|
||||
string $query,
|
||||
@ -85,7 +85,7 @@ class SQLite implements Adapter
|
||||
}
|
||||
|
||||
/** 数据库异常 */
|
||||
throw new Exception($handle->lastErrorMsg(), $handle->lastErrorCode());
|
||||
throw new SQLException($handle->lastErrorMsg(), $handle->lastErrorCode());
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -16,7 +16,7 @@ trait SQLiteTrait
|
||||
*
|
||||
* @param string $table
|
||||
* @param mixed $handle 连接对象
|
||||
* @throws Exception
|
||||
* @throws SQLException
|
||||
*/
|
||||
public function truncate(string $table, $handle)
|
||||
{
|
||||
@ -99,4 +99,4 @@ trait SQLiteTrait
|
||||
|
||||
return $query;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -136,7 +136,7 @@ abstract class Widget
|
||||
|
||||
$sandbox = false;
|
||||
|
||||
if (isset($request) || $call === true || is_callable($call)) {
|
||||
if (isset($request) || $call === false || is_callable($call)) {
|
||||
$sandbox = true;
|
||||
Request::getInstance()->beginSandbox(new Config($request));
|
||||
Response::getInstance()->beginSandbox();
|
||||
|
Loading…
x
Reference in New Issue
Block a user