mirror of
https://github.com/typecho/typecho.git
synced 2025-01-17 12:38:28 +01:00
准备对各应用引擎的存储进行支持
This commit is contained in:
parent
85bc868760
commit
502cd5f7ca
16
install.php
16
install.php
@ -60,20 +60,6 @@ if (!isset($_GET['finish']) && file_exists(__TYPECHO_ROOT_DIR__ . '/config.inc.p
|
||||
exit;
|
||||
}
|
||||
|
||||
/**
|
||||
* 检测是否为应用引擎
|
||||
*
|
||||
* @access protected
|
||||
* @return void
|
||||
*/
|
||||
function _engine()
|
||||
{
|
||||
return !empty($_SERVER['HTTP_APPNAME']) // SAE
|
||||
|| !!getenv('HTTP_BAE_ENV_APPID') // BAE
|
||||
|| !!getenv('HTTP_BAE_LOGID') // BAE 3.0
|
||||
|| (isset($_SERVER['SERVER_SOFTWARE']) && strpos($_SERVER['SERVER_SOFTWARE'],'Google App Engine') !== false); // GAE
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取传递参数
|
||||
*
|
||||
@ -506,7 +492,7 @@ list($prefixVersion, $suffixVersion) = explode('/', $currentVersion);
|
||||
Typecho_Db::set(\$db);
|
||||
";
|
||||
$contents = implode('', $lines);
|
||||
if (!_engine()) {
|
||||
if (!Typecho_Common::isAppEngine()) {
|
||||
@file_put_contents('./config.inc.php', $contents);
|
||||
}
|
||||
|
||||
|
@ -434,6 +434,23 @@ EOF;
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* 检测是否在app engine上运行,屏蔽某些功能
|
||||
*
|
||||
* @static
|
||||
* @access public
|
||||
* @return boolean
|
||||
*/
|
||||
public static function isAppEngine()
|
||||
{
|
||||
return !empty($_SERVER['HTTP_APPNAME']) // SAE
|
||||
|| !!getenv('HTTP_BAE_ENV_APPID') // BAE
|
||||
|| !!getenv('HTTP_BAE_LOGID') // BAE 3.0
|
||||
|| ini_get('acl.app_url') // ACE
|
||||
|| (isset($_SERVER['SERVER_SOFTWARE']) && strpos($_SERVER['SERVER_SOFTWARE'],'Google App Engine') !== false) // GAE
|
||||
;
|
||||
}
|
||||
|
||||
/**
|
||||
* 递归去掉数组反斜线
|
||||
*
|
||||
|
26
var/Typecho/Storage/Adapter.php
Normal file
26
var/Typecho/Storage/Adapter.php
Normal file
@ -0,0 +1,26 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* Typecho_Storage_Adapter
|
||||
*
|
||||
* @copyright Copyright (c) 2012 Typecho Team. (http://typecho.org)
|
||||
* @author Joyqi <magike.net@gmail.com>
|
||||
* @license GNU General Public License 2.0
|
||||
*/
|
||||
interface Typecho_Storage_Adapter
|
||||
{
|
||||
public static function isAvailable();
|
||||
|
||||
public static function check(array $config);
|
||||
|
||||
public static function config(Typecho_Widget_Helper_Form $form);
|
||||
|
||||
public function get($path);
|
||||
|
||||
public function add($localPath);
|
||||
|
||||
public function set($path, $localPath);
|
||||
|
||||
public function delete($path);
|
||||
}
|
||||
|
0
var/Typecho/Storage/Adapter/ACE.php
Normal file
0
var/Typecho/Storage/Adapter/ACE.php
Normal file
0
var/Typecho/Storage/Adapter/BAE.php
Normal file
0
var/Typecho/Storage/Adapter/BAE.php
Normal file
0
var/Typecho/Storage/Adapter/File.php
Normal file
0
var/Typecho/Storage/Adapter/File.php
Normal file
0
var/Typecho/Storage/Adapter/GAE.php
Normal file
0
var/Typecho/Storage/Adapter/GAE.php
Normal file
0
var/Typecho/Storage/Adapter/SAE.php
Normal file
0
var/Typecho/Storage/Adapter/SAE.php
Normal file
0
var/Typecho/Storage/Exception.php
Normal file
0
var/Typecho/Storage/Exception.php
Normal file
@ -121,7 +121,8 @@ class Widget_Options_Permalink extends Widget_Abstract_Options implements Widget
|
||||
$client = Typecho_Http_Client::get();
|
||||
$hasWrote = false;
|
||||
|
||||
if (!file_exists(__TYPECHO_ROOT_DIR__ . '/.htaccess')) {
|
||||
if (!file_exists(__TYPECHO_ROOT_DIR__ . '/.htaccess')
|
||||
&& !Typecho_Common::isAppEngine()) {
|
||||
if (is_writeable(__TYPECHO_ROOT_DIR__)) {
|
||||
$parsed = parse_url($this->options->siteUrl);
|
||||
$basePath = empty($parsed['path']) ? '/' : $parsed['path'];
|
||||
|
@ -81,7 +81,7 @@ class Widget_Themes_Edit extends Widget_Abstract_Options implements Widget_Inter
|
||||
{
|
||||
$path = __TYPECHO_ROOT_DIR__ . __TYPECHO_THEME_DIR__ . '/' . trim($theme, './') . '/' . trim($file, './');
|
||||
|
||||
if (file_exists($path) && is_writeable($path)) {
|
||||
if (file_exists($path) && is_writeable($path) && !Typecho_Common::isAppEngine()) {
|
||||
$handle = fopen($path, 'wb');
|
||||
if ($handle && fwrite($handle, $this->request->content)) {
|
||||
fclose($handle);
|
||||
|
@ -105,7 +105,7 @@ class Widget_Themes_Files extends Typecho_Widget
|
||||
public function currentIsWriteable()
|
||||
{
|
||||
return is_writeable(__TYPECHO_ROOT_DIR__ . __TYPECHO_THEME_DIR__ . '/' .
|
||||
$this->_currentTheme . '/' . $this->_currentFile);
|
||||
$this->_currentTheme . '/' . $this->_currentFile) && !Typecho_Common::isAppEngine();
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -92,7 +92,7 @@ class Widget_Upload extends Widget_Abstract_Contents implements Widget_Interface
|
||||
|
||||
$ext = self::getSafeName($file['name']);
|
||||
|
||||
if (!self::checkFileType($ext)) {
|
||||
if (!self::checkFileType($ext) || Typecho_Common::isAppEngine()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -164,7 +164,7 @@ class Widget_Upload extends Widget_Abstract_Contents implements Widget_Interface
|
||||
|
||||
$ext = self::getSafeName($file['name']);
|
||||
|
||||
if ($content['attachment']->type != $ext) {
|
||||
if ($content['attachment']->type != $ext || Typecho_Common::isAppEngine()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -226,7 +226,8 @@ class Widget_Upload extends Widget_Abstract_Contents implements Widget_Interface
|
||||
return $result;
|
||||
}
|
||||
|
||||
return @unlink(__TYPECHO_ROOT_DIR__ . '/' . $content['attachment']->path);
|
||||
return !Typecho_Common::isAppEngine()
|
||||
&& @unlink(__TYPECHO_ROOT_DIR__ . '/' . $content['attachment']->path);
|
||||
}
|
||||
|
||||
/**
|
||||
|
Loading…
x
Reference in New Issue
Block a user