Skip to content

Commit a957b93

Browse files
committed
update:
1、完善关于我们 2、完善接口逻辑
1 parent 2e27ed8 commit a957b93

File tree

3 files changed

+16
-8
lines changed

3 files changed

+16
-8
lines changed

src/index.php

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
<?php
22

3-
// error_reporting(E_ALL);
4-
// ini_set('log_errors', true);
3+
error_reporting(E_ALL);
54

5+
header("X-Powered-By: URL Shortener");
66
date_default_timezone_set('Asia/Shanghai');
77
define('ROOT_PATH', __DIR__);
88
define('CACHE_TYPE', 'file'); // 支持REDIS OR FILE
@@ -182,10 +182,10 @@ function hashToUrl($hash)
182182
*
183183
* @param $url
184184
* @param string $encrypt_type
185-
* @param string $extent
185+
* @param array $extent
186186
* @return string
187187
*/
188-
function urlToShort($url, $encrypt_type = 'encrypt', $extent = '')
188+
function urlToShort($url, $encrypt_type = 'encrypt', $extent = [])
189189
{
190190
if (!preg_match('/^[A-z]+:\/\//i', $url)) {
191191
$url = 'http://' . $url;
@@ -727,13 +727,13 @@ function responseJavascript($requestId)
727727
$response = json(__('url cannot be empty'), 500);
728728
} else if (mb_strlen($url) > 2047) {
729729
$response = json(__('Too long url'), 500);
730-
} else if (mb_strlen($extent) > 10000) {
730+
} else if (!empty($extent) && mb_strlen(json_encode($extent)) > 10000) {
731731
$response = json(__('Too much content'), 500);
732732
} else {
733-
$extent = json_decode($extent, true);
734733
$response = urlToShort($url, $encrypt_type, isset($extent) && !empty($extent) ? $extent : []);
735734
$response = json(__('Link created successfully'), 200, $response);
736735
}
736+
header('Content-type:text/json;charset=utf-8');
737737
echo $response;
738738
});
739739

src/library/language.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
'Mobile access only' => '仅限手机访问',
2424
'Forked from' => '衍生自',
2525
'More items' => '更多项目',
26+
'Friendship links' => '友情链接',
2627

2728
'Jump directly to the website' => '直接跳转到目标网站',
2829
'No Referer parameter' => '无 Referer 参数,目标网站无法获取来源站地址',

src/views/about.php

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,8 +33,15 @@
3333
<div class="card-header text-center"><?php echo __('PHP URL Shortener') ?></div>
3434
<div class="card-body">
3535
<p><?php echo __('GITHUB'); ?>: <a href="https://github.com/crogram/php-app-shorturl" target="_blank">https://github.com/crogram/php-app-shorturl</a></p>
36-
<p><?php echo __('Forked from'); ?>: <a href="https://github.com/ellermister/shorturl" target="_blank">https://github.com/ellermister/shorturl</a></p>
37-
<p><?php echo __('More items'); ?>: <a href="https://crogram.org" target="_blank">https://crogram.org</a></p>
36+
<hr />
37+
<p><?php echo __('More items'); ?>:</p>
38+
<ul>
39+
<li><a href="https://github.com/crogram" target="_blank">https://github.com/crogram</a></li>
40+
<li><a href="https://crogram.org" target="_blank">https://crogram.org</a></li>
41+
<li><a href="https://github.com/jksdou" target="_blank">Jackson Dou</a></li>
42+
</ul>
43+
<hr />
44+
<p><?php echo __('Friendship links'); ?>: <a href="http://uinote.com" target="_blank">UINOTE</a>, <a href="http://uiisc.tk" target="_blank">UIISC.TK</a>, <a href="http://uiisc.ml" target="_blank">UIISC.ML</a></p>
3845
</div>
3946
<div class="card-footer text-muted text-center">
4047
<p class="py-0 mb-0">&copy <?php echo date('Y');?> <a href="http://uiisc.org" target="_blank">UIISC</a> All Rights Reserved. Powered by <a href="https://crogram.org" target="_blank">CROGRAM</a></p>

0 commit comments

Comments
 (0)