applicaton->app

This commit is contained in:
icret 2023-03-09 21:45:54 +08:00
parent 2a898ed814
commit 589f87d32f
11 changed files with 409 additions and 54 deletions

View File

@ -770,6 +770,13 @@ auto_delete(); //定时删除
<label style="font-weight: bold">环境自检</label>
</div>
</div>
<div class="col-md-2">
<div class="switch switch-inline" data-toggle="tooltip" title="开发者模式 - Debug">
<input type="hidden" name="Debug" value="0">
<input type="checkbox" name="Debug" value="1" <?php if ($config['Debug']) echo 'checked="checked"'; ?>>
<label style="font-weight: bold">开发模式</label>
</div>
</div>
</div>
<div class="col-md-12">
<div class="panel">
@ -952,7 +959,7 @@ auto_delete(); //定时删除
<a href="<?php echo is_file(APP_ROOT . '/docs/index.html') ? '../docs' : 'https://icret.github.io/EasyImages2.0/#/'; ?>" target="_blank"><span class="label label-badge label-primary" data-toggle="tooltip" title="使用手册"><i class="icon icon-book"></i> Manual</span></a>
<a href="https://t.me/Easy_Image" target="_blank"><span class="label label-badge label-primary" data-toggle="tooltip" title="EasyImage Telegram Group"><i class="icon icon-comments-alt"></i> Telegram</span></a>
<a href="https://github.com/icret/EasyImages2.0/discussions" target="_blank"><span class="label label-badge label-primary" data-toggle="tooltip" title="GitHub 社区"><i class="icon icon-comments-alt"></i> Discuss</span></a>
<span data-toggle="tooltip" title="当前版本"><button type="button" class="btn btn-sm btn-primary label label-badge label-primary" data-toggle="modal" data-moveable="true" ata-size="sm" data-scroll-inside="true" data-icon="heart" data-title="当前版本更新日志" data-custom="<pre style='background-color: rgba(0, 0, 0, 0);border-color:rgba(0, 0, 0, 0);'><?php echo getVersion('name') . '<br/><br/>' . getVersion('body'); ?></pre>"><i class="icon icon-github"></i> <?php echo get_current_version(); ?></button></span>
<span data-toggle="tooltip" title="当前版本"><button type="button" class="btn btn-sm btn-primary label label-badge label-primary" data-toggle="modal" data-moveable="true" ata-size="sm" data-scroll-inside="true" data-icon="heart" data-title="当前版本更新日志" data-custom="<pre style='background-color: rgba(0, 0, 0, 0);border-color:rgba(0, 0, 0, 0);'><?php echo getVersion('name') . '<br/><br/>' . getVersion('body'); ?></pre>"><i class="icon icon-github"></i> <?php echo APP_VERSION; ?></button></span>
<span data-toggle="tooltip" title="您的赞美是我开发的动力!"><button type="button" class="btn btn-sm btn-danger label label-badge label-danger" data-toggle="modal" data-moveable="true" data-size="sm" data-icon="heart" data-title="您的赞美是我开发的动力!" data-custom="<ul class='nav nav-tabs'><li class='active'><a data-tab href='#wechat'><i class='icon icon-wechat' style='color:#329d38;'> 微信</i></a></li><li><a data-tab href='#alipay'><i class='icon icon-zhifubao-square' style='color:#1970fc;'> 支付宝</i></a></li></ul><div class='tab-content'><div class='tab-pane active' id='wechat'><img src='../public/images/wechat.jpg'></div><div class='tab-pane' id='alipay'><img src='../public/images/alipay.jpg'></div></div>"><i class="icon icon-yen"></i><small>打赏开发者</small></button></span>
</p>
<h6>程序依赖</h6>
@ -987,7 +994,7 @@ auto_delete(); //定时删除
<h6>* 下载 <a href="https://raw.githubusercontent.com/lionsoul2014/ip2region/master/data/ip2region.xdb" target="_blank">ip2region.xdb</a> IP数据库上传到 <small style="color: black;">/app/ip2region/</small> 文件夹, 如遇到下载失败可访问开源地址下载: [ <a href="https://github.com/lionsoul2014/ip2region" target="_blank"><small style="color: black;">Github</small></a> | <a href="https://gitee.com/lionsoul/ip2region" target="_blank"><small style="color: black;">Gitee</small></a> ] 更新方法与此相同。</h6>
</div>
</div>
<?php if (getVersion() !== get_current_version()) : ?>
<?php if (getVersion() !== APP_VERSION) : ?>
<div class="bg-warning with-padding hidden-xs">
<h5 class="header-dividing"><span class="label label-success">New</span> <?php echo getVersion('name'); ?></h5>
<pre style="background-color: rgba(0, 0, 0, 0);border-color:rgba(0, 0, 0, 0);">更新内容: <br /><?php echo getVersion('body'); ?></pre>

View File

@ -122,7 +122,7 @@ if (is_array($char_data)) {
<div class="col-xs-3 alert alert-primary autoshadow">
当前版本
<hr />
<?php echo get_current_version(); ?>
<?php echo APP_VERSION; ?>
</div>
</div>
<div class="col-md-12 col-xs-12">

View File

@ -120,7 +120,7 @@ if (is_array($char_data)) {
<div class="col-xs-3 alert alert-primary autoshadow">
当前版本
<hr />
<?php echo get_current_version(); ?>
<?php echo APP_VERSION; ?>
</div>
</div>
<div class="col-md-12 col-xs-12">

270
app/Ftp.php Normal file
View File

@ -0,0 +1,270 @@
<?php
/**
* FTP - access to an FTP server.
*
* @author David Grudl
* @copyright Copyright (c) 2008 David Grudl
* @license New BSD License
* @link http://phpfashion.com/
* @link https://github.com/dg/ftp-php
* @version 1.2
*
* @method void alloc(int $filesize, string & $result) - Allocates space for a file to be uploaded
* @method void cdUp() - Changes to the parent directory
* @method void chDir(string $directory) - Changes the current directory on a FTP server
* @method int chMod(int $mode, string $filename) - Set permissions on a file via FTP
* @method void close() - Closes an FTP connection
* @method void connect(string $host, int $port = 21, int $timeout = 90) - Opens an FTP connection
* @method void delete(string $path) - Deletes a file on the FTP server
* @method bool exec(string $command) - Requests execution of a command on the FTP server
* @method void fGet(resource $handle, string $remote_file, int $mode, int $resumepos = 0) - Downloads a file from the FTP server and saves to an open file
* @method void fPut(string $remote_file, resource $handle, int $mode, int $startpos = 0) - Uploads from an open file to the FTP server
* @method mixed getOption(int $option) - Retrieves various runtime behaviours of the current FTP stream
* @method void get(string $local_file, string $remote_file, int $mode, int $resumepos = 0) - Downloads a file from the FTP server
* @method void login(string $username, string $password) - Logs in to an FTP connection
* @method int mdTm(string $remote_file) - Returns the last modified time of the given file
* @method string mkDir(string $directory) - Creates a directory
* @method int nbContinue() - Continues retrieving/sending a file(non-blocking)
* @method int nbFGet(resource $handle, string $remote_file, int $mode, int $resumepos = 0) - Retrieves a file from the FTP server and writes it to an open file(non-blocking)
* @method int nbFPut(string $remote_file, resource $handle, int $mode, int $startpos = 0) - Stores a file from an open file to the FTP server(non-blocking)
* @method int nbGet(string $local_file, string $remote_file, int $mode, int $resumepos = 0) - Retrieves a file from the FTP server and writes it to a local file(non-blocking)
* @method int nbPut(string $remote_file, string $local_file, int $mode, int $startpos = 0) - Stores a file on the FTP server(non-blocking)
* @method array nList(string $directory) - Returns a list of files in the given directory
* @method void pasv(bool $pasv) - Turns passive mode on or off
* @method void put(string $remote_file, string $local_file, int $mode, int $startpos = 0) - Uploads a file to the FTP server
* @method string pwd() - Returns the current directory name
* @method void quit() - Closes an FTP connection(alias of close)
* @method array raw(string $command) - Sends an arbitrary command to an FTP server
* @method mixed rawList(string $directory, bool $recursive = false) - Returns a detailed list of files in the given directory
* @method void rename(string $oldname, string $newname) - Renames a file or a directory on the FTP server
* @method void rmDir(string $directory) - Removes a directory
* @method bool setOption(int $option, mixed $value) - Set miscellaneous runtime FTP options
* @method void site(string $command) - Sends a SITE command to the server
* @method int size(string $remote_file) - Returns the size of the given file
* @method void sslConnect(string $host, int $port = 21, int $timeout = 90) - Opens an Secure SSL-FTP connection
* @method string sysType() - Returns the system type identifier of the remote FTP server
*/
class Ftp
{
/**#@+ FTP constant alias */
const ASCII = FTP_ASCII;
const TEXT = FTP_TEXT;
const BINARY = FTP_BINARY;
const IMAGE = FTP_IMAGE;
const TIMEOUT_SEC = FTP_TIMEOUT_SEC;
const AUTOSEEK = FTP_AUTOSEEK;
const AUTORESUME = FTP_AUTORESUME;
const FAILED = FTP_FAILED;
const FINISHED = FTP_FINISHED;
const MOREDATA = FTP_MOREDATA;
/**#@-*/
private static $aliases = array(
'sslconnect' => 'ssl_connect',
'getoption' => 'get_option',
'setoption' => 'set_option',
'nbcontinue' => 'nb_continue',
'nbfget' => 'nb_fget',
'nbfput' => 'nb_fput',
'nbget' => 'nb_get',
'nbput' => 'nb_put',
);
/** @var resource|\FTP\Connection */
private $resource;
/** @var array */
private $state;
/** @var string */
private $errorMsg;
/**
* @param string URL ftp://...
* @param bool
*/
public function __construct($url = NULL, $passiveMode = TRUE)
{
if (!extension_loaded('ftp')) {
throw new Exception('PHP extension FTP is not loaded.');
}
if ($url) {
$parts = parse_url($url);
if (!isset($parts['scheme']) || !in_array($parts['scheme'], array('ftp', 'ftps', 'sftp'))) {
throw new InvalidArgumentException('Invalid URL.');
}
$func = $parts['scheme'] === 'ftp' ? 'connect' : 'ssl_connect';
if (empty($parts['port'])) {
$this->$func($parts['host']);
} else {
$this->$func($parts['host'], (int) $parts['port']);
}
$this->login(urldecode($parts['user']), urldecode($parts['pass']));
$this->pasv((bool) $passiveMode);
if (isset($parts['path'])) {
$this->chdir($parts['path']);
}
}
}
/**
* Magic method (do not call directly).
* @param string method name
* @param array arguments
* @return mixed
* @throws Exception
* @throws FtpException
*/
public function __call($name, $args)
{
$name = strtolower($name);
$silent = strncmp($name, 'try', 3) === 0;
$func = $silent ? substr($name, 3) : $name;
$func = 'ftp_' . (isset(self::$aliases[$func]) ? self::$aliases[$func] : $func);
if (!function_exists($func)) {
throw new Exception("Call to undefined method Ftp::$name().");
}
$this->errorMsg = NULL;
set_error_handler(array($this, '_errorHandler'));
if ($func === 'ftp_connect' || $func === 'ftp_ssl_connect') {
$this->state = array($name => $args);
$this->resource = call_user_func_array($func, $args);
$res = NULL;
} elseif (!is_resource($this->resource) && !$this->resource instanceof \FTP\Connection) {
restore_error_handler();
throw new FtpException("Not connected to FTP server. Call connect() or ssl_connect() first.");
} else {
if ($func === 'ftp_login' || $func === 'ftp_pasv') {
$this->state[$name] = $args;
}
array_unshift($args, $this->resource);
$res = call_user_func_array($func, $args);
if ($func === 'ftp_chdir' || $func === 'ftp_cdup') {
$this->state['chdir'] = array(ftp_pwd($this->resource));
}
}
restore_error_handler();
if (!$silent && $this->errorMsg !== NULL) {
if (ini_get('html_errors')) {
$this->errorMsg = html_entity_decode(strip_tags($this->errorMsg));
}
if (($a = strpos($this->errorMsg, ': ')) !== FALSE) {
$this->errorMsg = substr($this->errorMsg, $a + 2);
}
throw new FtpException($this->errorMsg);
}
return $res;
}
/**
* Internal error handler. Do not call directly.
*/
public function _errorHandler($code, $message)
{
$this->errorMsg = $message;
}
/**
* Reconnects to FTP server.
* @return void
*/
public function reconnect()
{
@ftp_close($this->resource); // intentionally @
foreach ($this->state as $name => $args) {
call_user_func_array(array($this, $name), $args);
}
}
/**
* Checks if file or directory exists.
* @param string
* @return bool
*/
public function fileExists($file)
{
return (bool) $this->nlist($file);
}
/**
* Checks if directory exists.
* @param string
* @return bool
*/
public function isDir($dir)
{
$current = $this->pwd();
try {
$this->chdir($dir);
} catch (FtpException $e) {
}
$this->chdir($current);
return empty($e);
}
/**
* Recursive creates directories.
* @param string
* @return void
*/
public function mkDirRecursive($dir)
{
$parts = explode('/', $dir);
$path = '';
while (!empty($parts)) {
$path .= array_shift($parts);
try {
if ($path !== '') $this->mkdir($path);
} catch (FtpException $e) {
if (!$this->isDir($path)) {
throw new FtpException("Cannot create directory '$path'.");
}
}
$path .= '/';
}
}
/**
* Recursive deletes path.
* @param string
* @return void
*/
public function deleteRecursive($path)
{
if (!$this->tryDelete($path)) {
foreach ((array) $this->nlist($path) as $file) {
if ($file !== '.' && $file !== '..') {
$this->deleteRecursive(strpos($file, '/') === FALSE ? "$path/$file" : $file);
}
}
$this->rmdir($path);
}
}
}
class FtpException extends Exception
{
}

View File

@ -66,7 +66,7 @@ if (!file_exists(__DIR__ . '/ip2region/ip2region.xdb')) {
}
// 检查当前版本与GitHub版本
if (getVersion() !== get_current_version()) {
if (getVersion() !== APP_VERSION) {
echo '
new $.zui.Messager("当前版本与GitHub不一致,请检查当前是否最新版本!",{
type: "danger", // 定义颜色主题

View File

@ -199,7 +199,7 @@ if ($config['notice_status'] > 0) : ?>
});
// console
console.log("%cEasyImage <?php echo get_current_version(); ?>", "background: rgba(252,234,187,1);background: -moz-linear-gradient(left, rgba(252,234,187,1) 0%, rgba(175,250,77,1) 12%, rgba(0,247,49,1) 28%, rgba(0,210,247,1) 39%,rgba(0,189,247,1) 51%, rgba(133,108,217,1) 64%, rgba(177,0,247,1) 78%, rgba(247,0,189,1) 87%, rgba(245,22,52,1) 0.5%);background: -webkit-gradient(left top, right top, color-stop(0%, rgba(252,234,187,1)), color-stop(12%, rgba(175,250,77,1)), color-stop(28%, rgba(0,247,49,1)), color-stop(39%, rgba(0,210,247,1)), color-stop(51%, rgba(0,189,247,1)), color-stop(64%, rgba(133,108,217,1)), color-stop(78%, rgba(177,0,247,1)), color-stop(87%, rgba(247,0,189,1)), color-stop(0.5%, rgba(245,22,52,1)));background: -webkit-linear-gradient(left, rgba(252,234,187,1) 0%, rgba(175,250,77,1) 12%, rgba(0,247,49,1) 28%, rgba(0,210,247,1) 39%, rgba(0,189,247,1) 51%, rgba(133,108,217,1) 64%, rgba(177,0,247,1) 78%, rgba(247,0,189,1) 87%, rgba(245,22,52,1) 0.5%);background: -o-linear-gradient(left, rgba(252,234,187,1) 0%, rgba(175,250,77,1) 12%, rgba(0,247,49,1) 28%, rgba(0,210,247,1) 39%, rgba(0,189,247,1) 51%, rgba(133,108,217,1) 64%, rgba(177,0,247,1) 78%, rgba(247,0,189,1) 87%, rgba(245,22,52,1) 0.5%);background: -ms-linear-gradient(left, rgba(252,234,187,1) 0%, rgba(175,250,77,1) 12%, rgba(0,247,49,1) 28%, rgba(0,210,247,1) 39%, rgba(0,189,247,1) 51%, rgba(133,108,217,1) 64%, rgba(177,0,247,1) 78%, rgba(247,0,189,1) 87%, rgba(245,22,52,1) 0.5%);background: linear-gradient(to right, rgba(252,234,187,1) 0%, rgba(175,250,77,1) 12%, rgba(0,247,49,1) 28%, rgba(0,210,247,1) 39%, rgba(0,189,247,1) 51%, rgba(133,108,217,1) 64%, rgba(177,0,247,1) 78%, rgba(247,0,189,1) 87%, rgba(245,22,52,1) 0.5%);filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='#fceabb', endColorstr='#f51634', GradientType=1 );font-size:2.34em;font-weight:bold")
console.log("%cEasyImage <?php echo APP_VERSION; ?>", "background: rgba(252,234,187,1);background: -moz-linear-gradient(left, rgba(252,234,187,1) 0%, rgba(175,250,77,1) 12%, rgba(0,247,49,1) 28%, rgba(0,210,247,1) 39%,rgba(0,189,247,1) 51%, rgba(133,108,217,1) 64%, rgba(177,0,247,1) 78%, rgba(247,0,189,1) 87%, rgba(245,22,52,1) 0.5%);background: -webkit-gradient(left top, right top, color-stop(0%, rgba(252,234,187,1)), color-stop(12%, rgba(175,250,77,1)), color-stop(28%, rgba(0,247,49,1)), color-stop(39%, rgba(0,210,247,1)), color-stop(51%, rgba(0,189,247,1)), color-stop(64%, rgba(133,108,217,1)), color-stop(78%, rgba(177,0,247,1)), color-stop(87%, rgba(247,0,189,1)), color-stop(0.5%, rgba(245,22,52,1)));background: -webkit-linear-gradient(left, rgba(252,234,187,1) 0%, rgba(175,250,77,1) 12%, rgba(0,247,49,1) 28%, rgba(0,210,247,1) 39%, rgba(0,189,247,1) 51%, rgba(133,108,217,1) 64%, rgba(177,0,247,1) 78%, rgba(247,0,189,1) 87%, rgba(245,22,52,1) 0.5%);background: -o-linear-gradient(left, rgba(252,234,187,1) 0%, rgba(175,250,77,1) 12%, rgba(0,247,49,1) 28%, rgba(0,210,247,1) 39%, rgba(0,189,247,1) 51%, rgba(133,108,217,1) 64%, rgba(177,0,247,1) 78%, rgba(247,0,189,1) 87%, rgba(245,22,52,1) 0.5%);background: -ms-linear-gradient(left, rgba(252,234,187,1) 0%, rgba(175,250,77,1) 12%, rgba(0,247,49,1) 28%, rgba(0,210,247,1) 39%, rgba(0,189,247,1) 51%, rgba(133,108,217,1) 64%, rgba(177,0,247,1) 78%, rgba(247,0,189,1) 87%, rgba(245,22,52,1) 0.5%);background: linear-gradient(to right, rgba(252,234,187,1) 0%, rgba(175,250,77,1) 12%, rgba(0,247,49,1) 28%, rgba(0,210,247,1) 39%, rgba(0,189,247,1) 51%, rgba(133,108,217,1) 64%, rgba(177,0,247,1) 78%, rgba(247,0,189,1) 87%, rgba(245,22,52,1) 0.5%);filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='#fceabb', endColorstr='#f51634', GradientType=1 );font-size:2.34em;font-weight:bold")
console.log('%c图床作者及演示网站: https://png.cm\n作为开发者你可以对相应的后台功能进行扩展(增删改相应代码), 但请保留代码中相关来源信息(例如: 本人博客, 邮箱等);\n本程序由 Icret 独自开发并完全开源, 碰到收费发布的请不要轻易付款; 本人仅为程序开源创作, 如非法网站使用与本人无关, 请勿用于非法用途.%c ', 'color: #eaad1a; padding:5px 0; border:1px solid #448ef6; font-size:12px;', '');
</script>
</body>

View File

@ -2,18 +2,19 @@
/**
* @author icret
* @link https://png.cm
* @email lemonim@qq.com
* @project EasyImage2.0 - 简单图床
* @Github https://github.com/icret/easyImages2.0
* QQ Group 954441002
* @Last 2023-02-26 17:38:57
* @Last 2023-03-09 17:38:57
* 上传服务器后第一次打开会检查运行环境,请根据提示操作;
* 检查环境仅会在第一开始开始出现并在config目录下生成EasyImage.lock文件如需再次查看请删除此文件。
* 敬请注意本程序为开源程序你可以使用本程序在任何非商业项目或者网站中。但请你务必保留代码中相关信息页面logo和页面上必要的链接可以更改
* 本人仅为程序开源创作,如非法网站与本人无关,请勿用于非法用途
* 请为本人博客blog.png.cm加上网址链接,谢谢支持。作为开发者你可以对相应的后台功能进行扩展(增删改相应代码),但请保留代码中相关来源信息(例如:本人博客,邮箱等)
* 请为本人网站 (https://png.cm) 加上网址链接,谢谢支持。作为开发者你可以对相应的后台功能进行扩展(增删改相应代码),但请保留代码中相关来源信息(例如:本人博客,邮箱等)
* 如果因安装问题或其他问题可以给我发邮件。
*/
@ -30,6 +31,8 @@ ini_set('memory_limit', '512M');
define('APP_ROOT', str_replace('\\', '/', realpath(dirname(__FILE__) . '/../')));
// 判断当前的系统类型是否为windows
define('IS_WIN', strstr(PHP_OS, 'WIN') ? 1 : 0);
// 定义当前版本
define('APP_VERSION', '2.7.8');
/*---------------基础配置结束-------------------*/
@ -37,6 +40,21 @@ require_once APP_ROOT . '/config/config.php';
require_once APP_ROOT . '/config/config.guest.php';
require_once __DIR__ . '/WaterMask.php';
/**
* 开启DEBUG
* 2023-03-09
*/
function easyimage_debug()
{
global $config;
if ($config['Debug']) {
if (!ini_get('display_errors')) {
ini_set('display_errors', 'On');
}
error_reporting(E_ALL);
}
}
/**
* 判断GIF图片是否为动态
* @param $filename string 文件
@ -66,7 +84,7 @@ function isWebpAnimated($src)
// not animated
return false;
/* 2023-01-24 判断webp是否为动画
/* 2023-01-24 判断webp是否为动画
$result = false;
$fh = fopen($src, "rb");
fseek($fh, 12);
@ -299,7 +317,7 @@ function imgName($source = null)
{
global $config;
function create_guid() // guid生成函数
function create_guid() // guid生成函数
{
if (function_exists('com_create_guid') === true) {
return trim(com_create_guid(), '{}');
@ -486,9 +504,9 @@ function getFile($dir)
* @param string $dir_fileName_suffix 获取文件列表:目录+文件名*:全匹配+文件后缀 *: 全匹配 {jpg,png,gif}:匹配指定格式
* 递归文件数量:目录
* @example get_file_by_glob(__DIR__ . '/i/cache/*.*', $type = 'list'); // 获取目录文件列表
* @example get_file_by_glob(__DIR__ . '/i/', $type = 'number'); // 递归获取文件夹数量
* @example get_file_by_glob(__DIR__ . '/i/', $type = 'number'); // 递归获取文件夹数量
* @param string $type list|number 返回列表还是数量
* @return array|int 返回数组|数量
* @return array|int 返回数组|数量
*/
function get_file_by_glob($dir_fileName_suffix, $type = 'list')
{
@ -500,7 +518,7 @@ function get_file_by_glob($dir_fileName_suffix, $type = 'list')
if ($glob) {
foreach ($glob as $v) {
if (is_file($v)) $res[] = basename($v);
if (is_file($v)) $res[] = basename($v);
}
// 排序
if ($res) {
@ -562,7 +580,7 @@ function getdirnum($file)
/**
* 把文件或目录的大小转化为容易读的方式
* disk_free_space - 磁盘可用空间(比如填写D盘某文件夹则会现在D盘剩余空间
* disk_free_space - 磁盘可用空间(比如填写D盘某文件夹则会现在D盘剩余空间
* disk_total_space 磁盘总空间(比如填写D盘某文件夹则会现在D盘总空间
* @param $number
* @return string
@ -588,7 +606,7 @@ function getDistUsed($number)
/**
* 加密/解密图片路径
* @param string $data 要加密的内容
* @param int $mode =1或0 1解密 0加密
* @param int $mode =1或0 1解密 0加密
* @param String $key
*/
function urlHash($data, $mode, $key = null)
@ -616,7 +634,7 @@ function getDel($url, $type)
{
global $config;
// url本地化
$url = htmlspecialchars(str_replace($config['domain'], '', $url)); // 过滤html 获取url path
$url = htmlspecialchars(str_replace($config['domain'], '', $url)); // 过滤html 获取url path
$url = urldecode(trim($url));
if ($type == 'url') {
@ -666,7 +684,7 @@ function getDel($url, $type)
/**
* 判断是否此用户登录
* @param string $user 判断登录者权限 $user=null 时检查是否登录, 不区分身份
* @param string $user 判断登录者权限 $user=null 时检查是否登录, 不区分身份
* @return bool |
*/
function is_who_login($user)
@ -774,7 +792,7 @@ function getVersion($name = 'tag_name')
return '获取版本文件失败,请检查curl或者网络 错误信息: ' . $e->getMessage();
}
} else {
return '已关闭环境自检, 当前版本:' . get_current_version();
return '已关闭环境自检, 当前版本:' . APP_VERSION;
}
}
@ -882,7 +900,7 @@ function checkImg($imageUrl, $type = 1, $dir = 'suspic/')
/** # 使用moderatecontent */
if ($type == 1) {
$response = moderatecontent_json($imageUrl);
if ($response['rating_index'] == 3 or $response['predictions']['adult'] > $config['checkImg_value']) { // (1 = everyone, 2 = teen, 3 = adult)
if ($response['rating_index'] == 3 or $response['predictions']['adult'] > $config['checkImg_value']) { // (1 = everyone, 2 = teen, 3 = adult)
$bad_pic = true;
}
}
@ -932,7 +950,7 @@ function checkImg($imageUrl, $type = 1, $dir = 'suspic/')
// }
// }
if ($res['Sexy'] * 100 > $config['checkImg_value'] or $res['Porn'] * 100 > $config['checkImg_value']) {
if ($res['Sexy'] * 100 > $config['checkImg_value'] or $res['Porn'] * 100 > $config['checkImg_value']) {
$bad_pic = true;
}
}
@ -945,14 +963,14 @@ function checkImg($imageUrl, $type = 1, $dir = 'suspic/')
/** # 如果违规则移动图片到违规文件夹 */
if ($bad_pic == true) {
$old_path = APP_ROOT . parse_url($imageUrl)['path']; // 提交网址中的文件路径 /i/2021/10/29/p8vypd.png
$name = parse_url($imageUrl)['path']; // 获得图片的相对地址
$name = str_replace($config['path'], '', $name); // 去除 path目录
$name = str_replace('/', '_', $name); // 文件名 2021_10_30_p8vypd.png
$new_path = APP_ROOT . $config['path'] . $dir . $name; // 新路径含文件名
$suspic_dir = APP_ROOT . $config['path'] . $dir; // suspic路径
$old_path = APP_ROOT . parse_url($imageUrl)['path']; // 提交网址中的文件路径 /i/2021/10/29/p8vypd.png
$name = parse_url($imageUrl)['path']; // 获得图片的相对地址
$name = str_replace($config['path'], '', $name); // 去除 path目录
$name = str_replace('/', '_', $name); // 文件名 2021_10_30_p8vypd.png
$new_path = APP_ROOT . $config['path'] . $dir . $name; // 新路径含文件名
$suspic_dir = APP_ROOT . $config['path'] . $dir; // suspic路径
if (!is_dir($suspic_dir)) { // 创建suspic目录并移动
if (!is_dir($suspic_dir)) { // 创建suspic目录并移动
mkdir($suspic_dir, 0777, true);
}
if (is_file($old_path)) {
@ -972,11 +990,11 @@ function re_checkImg($name, $dir = 'suspic/')
{
global $config;
$fileToPath = str_replace('_', '/', $name); // 将图片名称还原为带路径的名称eg:2021_11_03_pbmn1a.jpg =>2021/11/03/pbmn1a.jpg
$now_path_file = APP_ROOT . $config['path'] . $dir . $name; // 当前图片绝对位置 */i/suspic/2021_10_30_p8vypd.png
$fileToPath = str_replace('_', '/', $name); // 将图片名称还原为带路径的名称eg:2021_11_03_pbmn1a.jpg =>2021/11/03/pbmn1a.jpg
$now_path_file = APP_ROOT . $config['path'] . $dir . $name; // 当前图片绝对位置 */i/suspic/2021_10_30_p8vypd.png
if (is_file($now_path_file)) {
$to_file = APP_ROOT . $config['path'] . $fileToPath; // 要还原图片的绝对位置 */i/2021/10/30/p8vypd.png
rename($now_path_file, $to_file); // 移动文件
$to_file = APP_ROOT . $config['path'] . $fileToPath; // 要还原图片的绝对位置 */i/2021/10/30/p8vypd.png
rename($now_path_file, $to_file); // 移动文件
return true;
}
}
@ -990,15 +1008,15 @@ function creat_thumbnail_images($imgName)
require_once __DIR__ . '/class.thumb.php';
global $config;
$old_img_path = APP_ROOT . config_path() . $imgName; // 获取要创建缩略图文件的绝对路径
$old_img_path = APP_ROOT . config_path() . $imgName; // 获取要创建缩略图文件的绝对路径
$cache_path = APP_ROOT . $config['path'] . 'cache/'; // cache目录的绝对路径
if (!is_dir($cache_path)) { // 创建cache目录
if (!is_dir($cache_path)) { // 创建cache目录
mkdir($cache_path, 0777, true);
}
if (!isGifAnimated($old_img_path)) { // 仅针对非gif创建图片缩略图
if (!isGifAnimated($old_img_path)) { // 仅针对非gif创建图片缩略图
$new_imgName = APP_ROOT . $config['path'] . 'cache/' . date('Y_m_d') . '_' . $imgName; // 缩略图缓存的绝对路径
Thumb::out($old_img_path, $new_imgName, $config['thumbnail_w'], $config['thumbnail_h']); // 保存缩略图
Thumb::out($old_img_path, $new_imgName, $config['thumbnail_w'], $config['thumbnail_h']); // 保存缩略图
}
}
@ -1012,13 +1030,13 @@ function return_thumbnail_images($url)
global $config;
$cache_image_file = str_replace($config['imgurl'], '', $url);
if (isGifAnimated(APP_ROOT . $cache_image_file)) { // 仅读取非gif的缩略图
return $url; // 如果是gif则直接返回url
if (isGifAnimated(APP_ROOT . $cache_image_file)) { // 仅读取非gif的缩略图
return $url; // 如果是gif则直接返回url
} else {
$cache_image_file = str_replace($config['path'], '', $cache_image_file); // 将网址中的/i/去除
$cache_image_file = str_replace('/', '_', $cache_image_file); // 将文件的/转换为_
$cache_image_file = str_replace($config['path'], '', $cache_image_file); // 将网址中的/i/去除
$cache_image_file = str_replace('/', '_', $cache_image_file); // 将文件的/转换为_
$isFile = APP_ROOT . $config['path'] . 'cache/' . $cache_image_file; // 缓存文件的绝对路径
if (file_exists($isFile)) { // 缓存文件是否存在
if (file_exists($isFile)) { // 缓存文件是否存在
return $config['imgurl'] . $config['path'] . 'cache/' . $cache_image_file; // 存在则返回缓存文件
} else {
return $url; // 不存在直接返回url
@ -1051,7 +1069,7 @@ function creat_thumbnail_by_list($imgUrl)
{
global $config;
ini_set('max_execution_time', '300'); // 脚本运行的时间以秒为单位0不限制
ini_set('max_execution_time', '300'); // 脚本运行的时间以秒为单位0不限制
// 过滤非指定格式
if (!in_array(pathinfo($imgUrl, PATHINFO_EXTENSION), array('png', 'gif', 'jpeg', 'jpg', 'webp', 'bmp'))) {
@ -1091,7 +1109,7 @@ function creat_thumbnail_by_list($imgUrl)
if (isGifAnimated($abPathName)) {
return $imgUrl;
}
// 如果是webp动图则直接返回网址
// 如果是webp动图则直接返回网址
if (isWebpAnimated($abPathName)) {
return $imgUrl;
}
@ -1219,7 +1237,7 @@ function writefile($filename, $writetext, $openmod = 'w')
/**
* 获得用户的真实IP地址
* 来源ecshop
* @return mixed|string string
* @return mixed|string string
*/
function real_ip()
{
@ -1267,7 +1285,7 @@ function real_ip()
/**
* IP黑白名单检测支持IP段检测
* @param string $ipNow 要检测的IP
* @param string|array $ipList 白名单IP或者黑名单IP
* @param string|array $ipList 白名单IP或者黑名单IP
* @return boolean false|true true:白名单模式false:黑名单模式
* @return bool
*/
@ -1324,7 +1342,7 @@ function privateToken($length = 32)
{
$output = '';
for ($a = 0; $a < $length; $a++) {
$output .= chr(mt_rand(65, 122)); //生成php随机数
$output .= chr(mt_rand(65, 122)); //生成php随机数
}
return md5($output);
}
@ -1395,7 +1413,7 @@ function rand_imgurl($text = null)
{
global $config;
$url = isset($text) ? $text : $config['imgurl'];
$url = explode(',', $url);
$url = explode(',', $url);
return $url[array_rand($url, 1)];
}
@ -1450,11 +1468,11 @@ function water($source)
// 过滤gif
if (!is_Gif_Webp_Animated($source)) {
$arr = [
# 水印图片路径(如果不存在将会被当成是字符串水印)
# 水印图片路径(如果不存在将会被当成是字符串水印)
'res' => $config['waterText'],
# 水印显示位置
# 水印显示位置
'pos' => $config['waterPosition'],
# 不指定name(会覆盖原图也就是保存成thumb.jpeg)
# 不指定name(会覆盖原图也就是保存成thumb.jpeg)
'name' => $source,
'font' => APP_ROOT . $config['textFont'],
'fontSize' => $config['textSize'],
@ -1726,7 +1744,7 @@ function write_login_log($user, $pass, $msg)
* @param String $way 使用方式 upload 上传 | delete 删除
*/
function any_upload($remoteFile = null, $localFile = null, $way = 'upload')
function FTP_upload($remoteFile = null, $localFile = null, $way = 'upload')
{
global $config;
@ -1757,4 +1775,62 @@ function any_upload($remoteFile = null, $localFile = null, $way = 'upload')
break;
}
$ftp->close();
// 上传完毕是否删除本地文件
if ($config['ftped_del_local']) {
@unlink($localFile);
}
}
/**
* 其他上传
* 支持: FTP上传
* @link https://github.com/dg/ftp-php
* @param String $remoteFile 远程地址
* @param String $localFile 本地地址
* @param String $way 使用方式 upload 上传 | delete 删除
*/
function any_upload($remoteFile = null, $localFile = null, $way = 'upload')
{
global $config;
if (!$config['ftp_status']) exit;
require_once __DIR__ . '/Ftp.php';
// 登录FTP
try {
$ftp = new Ftp;
$ftp->connect($config['ftp_host'], $config['ftp_port'], $config['ftp_time']);
$ftp->login($config['ftp_user'], $config['ftp_pass']);
$ftp->pasv($config['ftp_pasv']);
} catch (FtpException $e) {
echo 'Error: ', $e->getMessage();
}
switch ($way) {
case 'upload':
try {
// 创建文件夹
$dir = pathinfo($remoteFile, PATHINFO_DIRNAME);
if (!$ftp->isDir($dir)) {
$ftp->mkDir($dir);
}
// 上传文件 远端->本地
$ftp->put($remoteFile, $localFile);
} catch (FtpException $e) {
echo 'Error: ', $e->getMessage();
}
break;
case 'delete':
$ftp->tryDelete($remoteFile);
break;
}
// 关闭FTP
$ftp->close();
// 上传完毕是否删除本地文件
if ($config['ftped_del_local']) {
@unlink($localFile);
}
}

File diff suppressed because one or more lines are too long

View File

@ -1,7 +1,7 @@
* 2023-03-06 v2.7.8
- 增加WEB端上传签名
- 修改目录命名 `applicaton->app`
- 修复两处漏洞
- 修复漏洞
* 2023-03-05 v2.7.7
- 增加登录日志

View File

@ -191,7 +191,7 @@ function checkPASS($name)
</div>
<?php echo 'Copyright © 2018-' . date('Y'); ?>
<a href="https://png.cm/" target="_blank">EasyImage</a> By
<a href="https://blog.png.cm/902.html" target="_blank">Icret</a> Version:<a href="https://github.com/icret/EasyImages2.0" target="_blank"><?php echo get_current_version(); ?></a>
<a href="https://blog.png.cm/902.html" target="_blank">Icret</a> Version:<a href="https://github.com/icret/EasyImages2.0" target="_blank"><?php echo APP_VERSION; ?></a>
</footer>
</body>

View File

@ -181,7 +181,7 @@ if ($state !== 'checked') {
</div>
<?php echo 'Copyright © 2018-' . date('Y'); ?>
<a href="https://png.cm/" target="_blank">EasyImage</a> By
<a href="https://blog.png.cm/902.html" target="_blank">Icret</a> Version:<a href="https://github.com/icret/EasyImages2.0" target="_blank"><?php echo get_current_version(); ?></a>
<a href="https://blog.png.cm/902.html" target="_blank">Icret</a> Version:<a href="https://github.com/icret/EasyImages2.0" target="_blank"><?php echo APP_VERSION; ?></a>
</footer>
</body>