Skip to content

Commit

Permalink
2015/01/26 Minor Changes
Browse files Browse the repository at this point in the history
Update Tietuku SDK file.
Clean some old code.
Some changes.
  • Loading branch information
qakcn committed Jan 26, 2015
1 parent 89c6373 commit f0e8622
Show file tree
Hide file tree
Showing 8 changed files with 299 additions and 158 deletions.
31 changes: 14 additions & 17 deletions api.php
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -7,22 +7,19 @@
header('HTTP/1.1 403 Forbidden'); header('HTTP/1.1 403 Forbidden');
exit('API cannot be direct accessed!'); exit('API cannot be direct accessed!');
} }
if(check_apikey()) {
if(isset($_GET['gettoken']) && $_GET['gettoken']=='file') { if(isset($_GET['gettoken']) && $_GET['gettoken']=='file') {
$result = get_token('file'); $result = get_token('file');
}else if(isset($_GET['gettoken']) && $_GET['gettoken']=='url') { }else if(isset($_GET['gettoken']) && $_GET['gettoken']=='url') {
$result = get_token('url'); $result = get_token('url');
}else if(isset($_GET['type']) && $_GET['type']=='url') { }else if(isset($_GET['type']) && $_GET['type']=='url') {
$result = url_handler(); $result = url_handler();
}else if(isset($_GET['type']) && $_GET['type']=='file') { }else if(isset($_GET['type']) && $_GET['type']=='file') {
$result = array_pop(file_handler()); $result = array_pop(file_handler());
}else {
header('HTTP/1.1 400 Bad Request');
exit('You must set "type" in the query string.');
}
header('Content-Type: application/json');
echo json_encode($result);
}else { }else {
header('HTTP/1.1 403 Forbidden'); header('HTTP/1.1 400 Bad Request');
exit('API KEY ERROR'); exit('You must set "type" in the query string.');
} }
header('Content-Type: application/json');
echo json_encode($result);

153 changes: 153 additions & 0 deletions doc/HOWTO-config.zh_CN.md
Original file line number Original file line Diff line number Diff line change
@@ -0,0 +1,153 @@
如何设置config.php
==========
版本:v1.0

本文介绍如何设置*config.php*文件。

本指引使用Markdown语法书写,若使用文本编辑器查看,请注意正文中的格式标记,这些标记并不是正文的一部分。

以下示例只适用于使用文本编辑器查看:

*表示说明* (两侧各有一个星号)
**表示强调**(两侧各有两个星号)
`表示代码`(两侧各有一个反引号,中间的内容才是代码内容,输入代码时请不要包括反引号)
<表示链接>(两侧各有一个尖括号)

更多关于Markdown语法的说明,请参见<http://wowubuntu.com/markdown/>

如果您使用Windows,可以使用[MarkdownEditor](https://github.com/jijinggang/MarkdownEditor)来查看本文档。下载地址:<https://github.com/jijinggang/MarkdownEditor/blob/master/download/MarkdownEditor.zip?raw=true>

如果您使用Mozilla Firefox,亦可安装扩展[Markdown Viewer](https://addons.mozilla.org/zh-CN/firefox/addon/markdown-viewer/),然后直接用Firefox打开本文件。

设置格式
----------
所有设置都使用常量声明来完成,常量声明的格式是:

define('常量名', 常量值);

*config.php*中,常量名即设置项的名称,由大写字母和下划线组成。
常量值可以是字符串、布尔值、整型、浮点型等标量类型。修改设置时,请**仅修改常量值的部分**

* 字符串由英文单引号(')或双引号(")包围,本文件中使用单引号;
* 布尔值只有`true``false`,不区分大小写,本文件中使用小写(注意有的设置项虽然是true或false,但其值为字符串而不是布尔值,需要用引号包围);
* 整型数值直接用十进制表示;浮点型用小数点分隔的两段十进制数字来表示。

设置说明
----------
下面对每一个设置项进行说明,包括设置项的作用和取值。


### UI_LANG
字符串值
默认值:`'zh-CN'`

设置界面的默认语言,用户可以在界面右上角的语言切换自行切换成其他语言。
取值为合法的ISO 639-1语言缩写,若使用default主题,目前仅支持`'en'`(英语)、`'zh-CN'`(中文(中国))和`'ja'`(日本语);若使用其他主题,以主题的说明为准。关于翻译事宜,请联系<qakcnyn@gmail.com>


### UI_THEME
字符串值
默认值:`'default'`

设置主界面所使用的主题,该主题必须在*themes*目录下。


### SITE_TITLE
字符串值

设置网站的标题,显示在浏览器的标题栏中。


### SITE_DESCRIPTION
字符串值

设置网站的说明,包含在网站头部的`<meta>`元素中。


### SITE_KEYWORDS
字符串值

设置网站的关键字,包含在网站头部的`<meta>`元素中。


### ADMIN_EMAIL
字符串值

管理员的Email地址,会包含在页面的反馈信息中。

### MAIN_SITE
布尔值
默认值:`false`

是否启用主站链接。启用后会在default主题的左下角显示,其他主题参见主题说明。


### MAIN_SITE_NAME
字符串值

主站的名称。


### MAIN_SITE_LOGO
字符串值

主站的LOGO图片的URL。


### MAIN_SITE_URL
字符串值

主站的URL。


### COPYRIGHT
字符串值

这是在页面底部的版权声明,可以使用HTML代码。


### SERVICE
字符串值
默认值:`'tietuku'`

设置图床使用的存储服务提供商,目前仅支持贴图库`'tietuku'`


### ALBUM_STRATEGY
字符串值
默认值:`'single'`

设置相册使用的策略。设置为`'single'`则使用指定的相册;设置为`'monthly'`则每个月生成一个相册。


### SINGLE_ALBUM
整型数值
默认值:`0`

`ALBUM_STRATEGY``'single'`时所使用的相册的ID。


### ALBUM_PREFIX
字符串值
默认值:`'qchan'`

`ALBUM_STRATEGY``'monthly'`时相册名称的前缀。


### DIRECT_AJAX
布尔值
默认值:`true`

设置为`true`时通过AJAX直接上传到存储服务提供商;`false`时先上传到Qchan所在服务器,再从服务器上传到存储服务提供商。


### TIETUKU_ACCESSKEY
字符串值

贴图库提供的Access Key,请到[贴图库开放平台](http://open.tietuku.com),登录后在*管理中心*下的*密钥*页面获取。


### TIETUKU_SECRETKEY
字符串值

贴图库提供的Secret Key,请到[贴图库开放平台](http://open.tietuku.com),登录后在*管理中心*下的*密钥*页面获取。
123 changes: 6 additions & 117 deletions engine.php
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -6,128 +6,18 @@
exit('This file must be loaded in flow.'); exit('This file must be loaded in flow.');
} }


// Check if config.php is correct if (version_compare(phpversion(), '5.3.0', '<')) {
function check_config() { exit('This program need PHP > 5.3.0');
if (!(
defined('UI_LANG') &&
preg_match('/[a-z]{2,3}(-[A-Z]{2})?|zh-Han[ts]/', UI_LANG)
)) {
exit('UI_LANG set incorrectly.');
}
if (!(
defined('UI_THEME') &&
file_exists(ABSPATH . '/themes/' . UI_THEME)
)) {
exit('UI_THEME set incorrectly.');
}
if(!(
defined('SITE_TITLE') &&
is_string(SITE_TITLE)
)) {
exit('SITE_TITLE set incorrectly.');
}
if(!(
defined('SITE_DESCRIPTION') &&
is_string(SITE_DESCRIPTION)
)) {
exit('SITE_DESCRIPTION set incorrectly.');
}
if(!(
defined('SITE_KEYWORDS') &&
is_string(SITE_KEYWORDS)
)) {
exit('SITE_KEYWORDS set incorrectly.');
}
if(!(
defined('ADMIN_EMAIL') &&
preg_match('/(\w+\.)*\w+@(\w+\.)+[A-Za-z]+/', ADMIN_EMAIL)
)) {
exit('ADMIN_EMAIL set incorrectly.');
}
if(!(
defined('MAIN_SITE') &&
is_bool(MAIN_SITE)
)) {
exit('MAIN_SITE set incorrectly.');
}else if(MAIN_SITE) {
if(!(
defined('MAIN_SITE_NAME') &&
is_string(MAIN_SITE_NAME)
)) {
exit('MAIN_SITE_NAME set incorrectly.');
}
if(!(
defined('MAIN_SITE_LOGO') &&
is_string(MAIN_SITE_LOGO)
)) {
exit('MAIN_SITE_LOGO set incorrectly.');
}
if(!(
defined('MAIN_SITE_URL') &&
preg_match('/^https?:\/\/[a-zA-Z0-9_\-.]+(\/.*)?$/', MAIN_SITE_URL)
)) {
exit('MAIN_SITE_URL set incorrectly.');
}
}
if(!(
defined('COPYRIGHT') &&
is_string(COPYRIGHT)
)) {
exit('COPYRIGHT set incorrectly.');
}
if(!(
defined('SERVICE') &&
SERVICE == 'tietuku'
)) {
exit('SERVICE set incorrectly.');
}else if(SERVICE == 'tietuku') {
if(!(
defined('TIETUKU_ACCESSKEY') &&
preg_match('/^[0-9a-f]{40}$/', TIETUKU_ACCESSKEY)
)) {
exit('TIETUKU_ACCESSKEY set incorrectly.');
}
if(!(
defined('TIETUKU_SECRETKEY') &&
preg_match('/^[0-9a-f]{40}$/', TIETUKU_ACCESSKEY)
)) {
exit('TIETUKU_SECRETKEY set incorrectly.');
}
}
if(!(
defined('ALBUM_STRATEGY') &&
(ALBUM_STRATEGY == 'single' || ALBUM_STRATEGY == 'monthly')
)) {
exit('ALBUM_STRATEGY set incorrectly.');
}else if(ALBUM_STRATEGY == 'single') {
if(!(
defined('SINGLE_ALBUM') &&
is_int(SINGLE_ALBUM) &&
SINGLE_ALBUM != 0
)) {
exit('SINGLE_ALBUM set incorrectly.');
}
}else if(ALBUM_STRATEGY == 'monthly') {
if(!(
defined('ALBUM_PREFIX') &&
is_string(SALBUM_PREFIX)
)) {
exit('ALBUM_PREFIX set incorrectly.');
}
}
if(!(
defined('DIRECT_AJAX') &&
is_bool(DIRECT_AJAX)
)) {
exit('DIRECT_AJAX set incorrectly.');
}
} }


define('QCHAN_VER', 'lite-1.0pre build 20140912'); define('QCHAN_VER', 'lite-1.0pre build 20150126');
define('QCHAN_URL', 'https://github.com/qakcn/qchan-lite'); define('QCHAN_URL', 'https://github.com/qakcn/qchan-lite');
date_default_timezone_set('UTC'); date_default_timezone_set('UTC');
define('ABSPATH', __DIR__); define('ABSPATH', __DIR__);


/* load core functions */
require_once ABSPATH.'/includes/functions.common.php';

if(!is_writable(ABSPATH . '/')) { if(!is_writable(ABSPATH . '/')) {
exit(ABSPATH.' is not writable.'); exit(ABSPATH.' is not writable.');
} }
Expand All @@ -154,7 +44,6 @@ function check_config() {
header("\x58\x2D\x51\x63\x68\x61\x6E\x2D\x49\x6E\x66\x6F\x3A\x20\x51\x63\x68\x61\x6E\x20\x69\x73\x20\x61\x6E\x20\x69\x6D\x61\x67\x65\x20\x68\x6F\x73\x74\x69\x6E\x67\x20\x66\x72\x65\x65\x77\x61\x72\x65\x2C\x20\x69\x73\x20\x64\x65\x76\x65\x6C\x6F\x70\x65\x64\x20\x62\x79\x20\x51\x75\x61\x64\x72\x61\x20\x53\x74\x75\x64\x69\x6F\x2C\x20\x61\x6E\x64\x20\x70\x75\x62\x6C\x69\x73\x68\x65\x64\x20\x75\x6E\x64\x65\x72\x20\x47\x50\x4C\x76\x33\x2E"); header("\x58\x2D\x51\x63\x68\x61\x6E\x2D\x49\x6E\x66\x6F\x3A\x20\x51\x63\x68\x61\x6E\x20\x69\x73\x20\x61\x6E\x20\x69\x6D\x61\x67\x65\x20\x68\x6F\x73\x74\x69\x6E\x67\x20\x66\x72\x65\x65\x77\x61\x72\x65\x2C\x20\x69\x73\x20\x64\x65\x76\x65\x6C\x6F\x70\x65\x64\x20\x62\x79\x20\x51\x75\x61\x64\x72\x61\x20\x53\x74\x75\x64\x69\x6F\x2C\x20\x61\x6E\x64\x20\x70\x75\x62\x6C\x69\x73\x68\x65\x64\x20\x75\x6E\x64\x65\x72\x20\x47\x50\x4C\x76\x33\x2E");


/* Load functions */ /* Load functions */
require_once ABSPATH.'/includes/functions.common.php';
require_once ABSPATH.'/includes/functions.language.php'; require_once ABSPATH.'/includes/functions.language.php';
require_once ABSPATH.'/includes/functions.theme.php'; require_once ABSPATH.'/includes/functions.theme.php';
require_once ABSPATH.'/includes/functions.upload.php'; require_once ABSPATH.'/includes/functions.upload.php';
Expand Down
Loading

0 comments on commit f0e8622

Please sign in to comment.