diff --git a/.version b/.version index 55467441..a916fbe6 100644 --- a/.version +++ b/.version @@ -1 +1 @@ -{"version":"3.14","md5":"5752cb0b79e64506e4865ff01aaefda8","url":"http:\/\/p.qpic.cn\/qqshihua\/0\/9cbb21b47a96c6c2abdd134f8ee6966b\/0\/1.png","description":"","data":{"version":"3.14","description":""}} \ No newline at end of file +{"version":"3.15","md5":"214ff9b7b87323b169bc4e4cf09f4c7c","url":"https:\/\/ghproxy.com\/https:\/\/github.com\/Tai7sy\/card-system\/releases\/download\/3.15\/card_release.tar.gz","description":"","data":{"version":"3.15","description":""}} \ No newline at end of file diff --git a/README.md b/README.md index 89fc95ba..aef606ed 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@

CardSystem

-License +License PHP from Packagist badge License Travis diff --git a/app/Card.php b/app/Card.php index fe040354..8dc83f5c 100644 --- a/app/Card.php +++ b/app/Card.php @@ -1,2 +1,2 @@ hasMany(Order::class); } function product() { return $this->belongsTo(Product::class); } function getCountAttribute() { return $this->count_all - $this->count_sold; } public static function add_cards($sp7aa9af, $sp89bb44, $sp22f15e, $spaa7124, $sp30a549, $sp4c59e7) { DB::statement('call add_cards(?,?,?,?,?,?)', array($sp7aa9af, $sp89bb44, $sp22f15e, $spaa7124, $sp30a549, (int) $sp4c59e7)); } public static function _trash($spa8a4ff) { DB::transaction(function () use($spa8a4ff) { $sp103198 = clone $spa8a4ff; $sp103198->selectRaw('`product_id`,SUM(`count_all`-`count_sold`) as `count_left`')->groupBy('product_id')->orderByRaw('`product_id`')->chunk(100, function ($sp860952) { foreach ($sp860952 as $spe9100b) { $spb395ca = \App\Product::where('id', $spe9100b->product_id)->lockForUpdate()->first(); if ($spb395ca) { $spb395ca->count_all -= $spe9100b->count_left; $spb395ca->saveOrFail(); } } }); $spa8a4ff->delete(); return true; }); } public static function _restore($spa8a4ff) { DB::transaction(function () use($spa8a4ff) { $sp103198 = clone $spa8a4ff; $sp103198->selectRaw('`product_id`,SUM(`count_all`-`count_sold`) as `count_left`')->groupBy('product_id')->orderByRaw('`product_id`')->chunk(100, function ($sp860952) { foreach ($sp860952 as $spe9100b) { $spb395ca = \App\Product::where('id', $spe9100b->product_id)->lockForUpdate()->first(); if ($spb395ca) { $spb395ca->count_all += $spe9100b->count_left; $spb395ca->saveOrFail(); } } }); $spa8a4ff->restore(); return true; }); } } \ No newline at end of file +namespace App; use Illuminate\Database\Eloquent\Model; use Illuminate\Database\Eloquent\SoftDeletes; use Illuminate\Support\Facades\DB; class Card extends Model { protected $guarded = array(); use SoftDeletes; protected $dates = array('deleted_at'); const STATUS_NORMAL = 0; const STATUS_SOLD = 1; const STATUS_USED = 2; const TYPE_ONETIME = 0; const TYPE_REPEAT = 1; function orders() { return $this->hasMany(Order::class); } function product() { return $this->belongsTo(Product::class); } function getCountAttribute() { return $this->count_all - $this->count_sold; } public static function add_cards($spacf00d, $spb429e3, $sp22c639, $sp0194a7, $sp84f9ba, $sp12232b) { DB::statement('call add_cards(?,?,?,?,?,?)', array($spacf00d, $spb429e3, $sp22c639, $sp0194a7, $sp84f9ba, (int) $sp12232b)); } public static function _trash($sp30241a) { DB::transaction(function () use($sp30241a) { $sp005ad9 = clone $sp30241a; $sp005ad9->selectRaw('`product_id`,SUM(`count_all`-`count_sold`) as `count_left`')->groupBy('product_id')->orderByRaw('`product_id`')->chunk(100, function ($sp355056) { foreach ($sp355056 as $spe8264d) { $sp427eba = \App\Product::where('id', $spe8264d->product_id)->lockForUpdate()->first(); if ($sp427eba) { $sp427eba->count_all -= $spe8264d->count_left; $sp427eba->saveOrFail(); } } }); $sp30241a->delete(); return true; }); } public static function _restore($sp30241a) { DB::transaction(function () use($sp30241a) { $sp005ad9 = clone $sp30241a; $sp005ad9->selectRaw('`product_id`,SUM(`count_all`-`count_sold`) as `count_left`')->groupBy('product_id')->orderByRaw('`product_id`')->chunk(100, function ($sp355056) { foreach ($sp355056 as $spe8264d) { $sp427eba = \App\Product::where('id', $spe8264d->product_id)->lockForUpdate()->first(); if ($sp427eba) { $sp427eba->count_all += $spe8264d->count_left; $sp427eba->saveOrFail(); } } }); $sp30241a->restore(); return true; }); } } \ No newline at end of file diff --git a/app/Category.php b/app/Category.php index 0913a7fd..4ea4432b 100644 --- a/app/Category.php +++ b/app/Category.php @@ -1,2 +1,2 @@ id, Helper::ID_TYPE_CATEGORY); } function products() { return $this->hasMany(Product::class); } function user() { return $this->belongsTo(User::class); } function getTmpPassword() { return md5('$wGgMd45Jgi@dBDR' . $this->password . '1#DS2%!VLqJolmMD'); } function getProductsForShop() { $spec356e = Product::where('category_id', $this->id)->where('enabled', 1)->orderBy('sort')->get(); foreach ($spec356e as $spb395ca) { $spb395ca->setForShop($this->user); } $this->addVisible(array('products')); $this->setAttribute('products', $spec356e); return $spec356e; } } \ No newline at end of file +namespace App; use App\Library\Helper; use Illuminate\Database\Eloquent\Model; class Category extends Model { protected $guarded = array(); function getUrlAttribute() { return config('app.url') . '/c/' . Helper::id_encode($this->id, Helper::ID_TYPE_CATEGORY); } function products() { return $this->hasMany(Product::class); } function user() { return $this->belongsTo(User::class); } function getTmpPassword() { return md5('$wGgMd45Jgi@dBDR' . $this->password . '1#DS2%!VLqJolmMD'); } function getProductsForShop() { $sp204e47 = Product::where('category_id', $this->id)->where('enabled', 1)->orderBy('sort')->get(); foreach ($sp204e47 as $sp427eba) { $sp427eba->setForShop($this->user); } $this->addVisible(array('products')); $this->setAttribute('products', $sp204e47); return $sp204e47; } } \ No newline at end of file diff --git a/app/Console/Commands/ResetPassword.php b/app/Console/Commands/ResetPassword.php index 006b9ea3..f5bec189 100644 --- a/app/Console/Commands/ResetPassword.php +++ b/app/Console/Commands/ResetPassword.php @@ -1,4 +1,4 @@ argument('email'); if (!$sp82cba2) { $this->warn('please input the user\'s email -'); return false; } $sp766bcc = \App\User::where('email', $sp82cba2)->first(); if (!$sp766bcc) { $this->warn("can't find the user: {$sp82cba2} \nplease input the user's email\n"); return false; } $spc3374e = $this->argument('password'); $sp766bcc->password = bcrypt($spc3374e); $sp766bcc->save(); $this->info("the password of '{$sp82cba2}' has been set to {$spc3374e}\n"); return true; } } \ No newline at end of file +Usage: php artisan reset:password user@email.com'; public function __construct() { parent::__construct(); } public function handle() { $sp4b6fe6 = $this->argument('email'); if (!$sp4b6fe6) { $this->warn('please input the user\'s email +'); return false; } $sp3db17d = \App\User::where('email', $sp4b6fe6)->first(); if (!$sp3db17d) { $this->warn("can't find the user: {$sp4b6fe6} \nplease input the user's email\n"); return false; } $spe46211 = $this->argument('password'); $sp3db17d->password = bcrypt($spe46211); $sp3db17d->save(); $this->info("the password of '{$sp4b6fe6}' has been set to {$spe46211}\n"); return true; } } \ No newline at end of file diff --git a/app/Console/Commands/Update.php b/app/Console/Commands/Update.php index e1d4da14..f8cf6921 100644 --- a/app/Console/Commands/Update.php +++ b/app/Console/Commands/Update.php @@ -1,13 +1,13 @@ 0) { echo ' download: ' . sprintf('%.2f', $sp4d82bf / $sp4a7a56 * 100) . '%'; } }); curl_setopt($sp0c7650, CURLOPT_NOPROGRESS, false); curl_setopt($sp0c7650, CURLOPT_HEADER, 0); curl_setopt($sp0c7650, CURLOPT_USERAGENT, 'card update'); if (defined('MY_PROXY')) { $sp3b58b9 = MY_PROXY; $sp70bf4e = CURLPROXY_HTTP; if (strpos($sp3b58b9, 'http://') || strpos($sp3b58b9, 'https://')) { $sp3b58b9 = str_replace('http://', $sp3b58b9, $sp3b58b9); $sp3b58b9 = str_replace('https://', $sp3b58b9, $sp3b58b9); $sp70bf4e = CURLPROXY_HTTP; } elseif (strpos($sp3b58b9, 'socks4://')) { $sp3b58b9 = str_replace('socks4://', $sp3b58b9, $sp3b58b9); $sp70bf4e = CURLPROXY_SOCKS4; } elseif (strpos($sp3b58b9, 'socks4a://')) { $sp3b58b9 = str_replace('socks4a://', $sp3b58b9, $sp3b58b9); $sp70bf4e = CURLPROXY_SOCKS4A; } elseif (strpos($sp3b58b9, 'socks5://')) { $sp3b58b9 = str_replace('socks5://', $sp3b58b9, $sp3b58b9); $sp70bf4e = CURLPROXY_SOCKS5_HOSTNAME; } curl_setopt($sp0c7650, CURLOPT_PROXY, $sp3b58b9); curl_setopt($sp0c7650, CURLOPT_PROXYTYPE, $sp70bf4e); if (defined('MY_PROXY_PASS')) { curl_setopt($sp0c7650, CURLOPT_PROXYUSERPWD, MY_PROXY_PASS); } } curl_exec($sp0c7650); curl_close($sp0c7650); echo ' -'; return true; } public function handle() { set_time_limit(0); $sp3b58b9 = $this->option('proxy'); if (!empty($sp3b58b9)) { define('MY_PROXY', $sp3b58b9); } $spea70c1 = $this->option('proxy-auth'); if (!empty($spea70c1)) { define('MY_PROXY_PASS', $spea70c1); } if (!empty(getenv('_'))) { $sp003bfe = '"' . getenv('_') . '" "' . $_SERVER['PHP_SELF'] . '" '; } else { if (!empty($_SERVER['_'])) { $sp003bfe = '"' . $_SERVER['_'] . '" "' . $_SERVER['PHP_SELF'] . '" '; } else { if (PHP_OS === 'WINNT') { $spf4de95 = dirname(php_ini_loaded_file()) . DIRECTORY_SEPARATOR . 'php.exe'; } else { $spf4de95 = dirname(php_ini_loaded_file()); if (ends_with($spf4de95, DIRECTORY_SEPARATOR . 'etc')) { $spf4de95 = substr($spf4de95, 0, -4); } $spf4de95 .= DIRECTORY_SEPARATOR . 'php'; } if (!file_exists($spf4de95)) { if (PHP_OS === 'WINNT') { $spf4de95 = 'php.exe'; } else { $spf4de95 = 'php'; } if ((bool) @exec($spf4de95 . ' --version') === FALSE) { echo '未找到php安装路径! -'; goto LABEL_EXIT; } } $sp003bfe = '"' . $spf4de95 . '" "' . $_SERVER['PHP_SELF'] . '" '; } } exec($sp003bfe . ' cache:clear'); exec($sp003bfe . ' config:clear'); echo ' -'; $this->comment('检查更新中...'); $this->info('当前版本: ' . config('app.version')); $sp58ef60 = @json_decode(CurlRequest::get('https://raw.githubusercontent.com/Tai7sy/card-system/master/.version'), true); if (!@$sp58ef60['version']) { $this->warn('检查更新失败!'); $this->warn('Error: ' . ($sp58ef60 ? json_encode($sp58ef60) : 'Network error')); goto LABEL_EXIT; } $this->info('最新版本: ' . $sp58ef60['version']); $this->info('版本说明: ' . (@$sp58ef60['description'] ?? '无')); if (config('app.version') >= $sp58ef60['version']) { $this->comment('您的版本已是最新!'); $sp7ccf1f = strtolower($this->ask('是否再次更新 (yes/no)', 'no')); if ($sp7ccf1f !== 'yes') { goto LABEL_EXIT; } } else { $sp7ccf1f = strtolower($this->ask('是否现在更新 (yes/no)', 'no')); if ($sp7ccf1f !== 'yes') { goto LABEL_EXIT; } } $spf2f34a = realpath(sys_get_temp_dir()); if (strlen($spf2f34a) < 3) { $this->warn('获取临时目录失败!'); goto LABEL_EXIT; } $spf2f34a .= DIRECTORY_SEPARATOR . Str::random(16); if (!mkdir($spf2f34a) || !is_writable($spf2f34a) || !is_readable($spf2f34a)) { $this->warn('临时目录不可读写!'); goto LABEL_EXIT; } if (!function_exists('exec')) { $this->warn('函数 exec 已被禁用, 无法继续更新!'); goto LABEL_EXIT; } if (PHP_OS === 'WINNT') { $spb79d07 = 'C:\\Program Files\\7-Zip\\7z.exe'; if (!is_file($spb79d07)) { $spb79d07 = strtolower($this->ask('未找到7-Zip, 请手动输入7zG.exe路径', $spb79d07)); } if (!is_file($spb79d07)) { $this->warn('7-Zip不可用, 请安装7-Zip后重试'); goto LABEL_EXIT; } $spb79d07 = '"' . $spb79d07 . '"'; } else { exec('tar --version', $spdb2105, $sp2618e5); if ($sp2618e5) { $this->warn('Error: tar --version +namespace App\Console\Commands; use App\Library\CurlRequest; use function DeepCopy\deep_copy; use Illuminate\Console\Command; use Illuminate\Support\Str; class Update extends Command { protected $signature = 'update {--proxy=} {--proxy-auth=}'; protected $description = 'check update'; public function __construct() { parent::__construct(); } private function download_progress($sp069c22, $spfff5a5) { $sp7f2319 = fopen($spfff5a5, 'w+'); if (!$sp7f2319) { return false; } $sp2df40c = curl_init(); curl_setopt($sp2df40c, CURLOPT_URL, $sp069c22); curl_setopt($sp2df40c, CURLOPT_FOLLOWLOCATION, true); curl_setopt($sp2df40c, CURLOPT_RETURNTRANSFER, true); curl_setopt($sp2df40c, CURLOPT_FILE, $sp7f2319); curl_setopt($sp2df40c, CURLOPT_PROGRESSFUNCTION, function ($spb1b5ca, $sp1e0b27, $spa33621, $sp764491, $spca0b7e) { if ($sp1e0b27 > 0) { echo ' download: ' . sprintf('%.2f', $spa33621 / $sp1e0b27 * 100) . '%'; } }); curl_setopt($sp2df40c, CURLOPT_NOPROGRESS, false); curl_setopt($sp2df40c, CURLOPT_HEADER, 0); curl_setopt($sp2df40c, CURLOPT_USERAGENT, 'card update'); if (defined('MY_PROXY')) { $sp6f2ecf = MY_PROXY; $sp3c6cc7 = CURLPROXY_HTTP; if (strpos($sp6f2ecf, 'http://') || strpos($sp6f2ecf, 'https://')) { $sp6f2ecf = str_replace('http://', $sp6f2ecf, $sp6f2ecf); $sp6f2ecf = str_replace('https://', $sp6f2ecf, $sp6f2ecf); $sp3c6cc7 = CURLPROXY_HTTP; } elseif (strpos($sp6f2ecf, 'socks4://')) { $sp6f2ecf = str_replace('socks4://', $sp6f2ecf, $sp6f2ecf); $sp3c6cc7 = CURLPROXY_SOCKS4; } elseif (strpos($sp6f2ecf, 'socks4a://')) { $sp6f2ecf = str_replace('socks4a://', $sp6f2ecf, $sp6f2ecf); $sp3c6cc7 = CURLPROXY_SOCKS4A; } elseif (strpos($sp6f2ecf, 'socks5://')) { $sp6f2ecf = str_replace('socks5://', $sp6f2ecf, $sp6f2ecf); $sp3c6cc7 = CURLPROXY_SOCKS5_HOSTNAME; } curl_setopt($sp2df40c, CURLOPT_PROXY, $sp6f2ecf); curl_setopt($sp2df40c, CURLOPT_PROXYTYPE, $sp3c6cc7); if (defined('MY_PROXY_PASS')) { curl_setopt($sp2df40c, CURLOPT_PROXYUSERPWD, MY_PROXY_PASS); } } curl_exec($sp2df40c); curl_close($sp2df40c); echo ' +'; return true; } public function handle() { set_time_limit(0); $sp6f2ecf = $this->option('proxy'); if (!empty($sp6f2ecf)) { define('MY_PROXY', $sp6f2ecf); } $sp194496 = $this->option('proxy-auth'); if (!empty($sp194496)) { define('MY_PROXY_PASS', $sp194496); } if (!empty(getenv('_'))) { $sp8afdaf = '"' . getenv('_') . '" "' . $_SERVER['PHP_SELF'] . '" '; } else { if (!empty($_SERVER['_'])) { $sp8afdaf = '"' . $_SERVER['_'] . '" "' . $_SERVER['PHP_SELF'] . '" '; } else { if (PHP_OS === 'WINNT') { $sp36f7e3 = dirname(php_ini_loaded_file()) . DIRECTORY_SEPARATOR . 'php.exe'; } else { $sp36f7e3 = dirname(php_ini_loaded_file()); if (ends_with($sp36f7e3, DIRECTORY_SEPARATOR . 'etc')) { $sp36f7e3 = substr($sp36f7e3, 0, -4); } $sp36f7e3 .= DIRECTORY_SEPARATOR . 'php'; } if (!file_exists($sp36f7e3)) { if (PHP_OS === 'WINNT') { $sp36f7e3 = 'php.exe'; } else { $sp36f7e3 = 'php'; } if ((bool) @exec($sp36f7e3 . ' --version') === FALSE) { echo '未找到php安装路径! +'; goto LABEL_EXIT; } } $sp8afdaf = '"' . $sp36f7e3 . '" "' . $_SERVER['PHP_SELF'] . '" '; } } exec($sp8afdaf . ' cache:clear'); exec($sp8afdaf . ' config:clear'); echo ' +'; $this->comment('检查更新中...'); $this->info('当前版本: ' . config('app.version')); $sp89bfd4 = @json_decode(CurlRequest::get('https://raw.githubusercontent.com/Tai7sy/card-system/master/.version'), true); if (!@$sp89bfd4['version']) { $this->warn('检查更新失败!'); $this->warn('Error: ' . ($sp89bfd4 ? json_encode($sp89bfd4) : 'Network error')); goto LABEL_EXIT; } $this->info('最新版本: ' . $sp89bfd4['version']); $this->info('版本说明: ' . (@$sp89bfd4['description'] ?? '无')); if (config('app.version') >= $sp89bfd4['version']) { $this->comment('您的版本已是最新!'); $sp864c8c = strtolower($this->ask('是否再次更新 (yes/no)', 'no')); if ($sp864c8c !== 'yes') { goto LABEL_EXIT; } } else { $sp864c8c = strtolower($this->ask('是否现在更新 (yes/no)', 'no')); if ($sp864c8c !== 'yes') { goto LABEL_EXIT; } } $spa3600b = realpath(sys_get_temp_dir()); if (strlen($spa3600b) < 3) { $this->warn('获取临时目录失败!'); goto LABEL_EXIT; } $spa3600b .= DIRECTORY_SEPARATOR . Str::random(16); if (!mkdir($spa3600b) || !is_writable($spa3600b) || !is_readable($spa3600b)) { $this->warn('临时目录不可读写!'); goto LABEL_EXIT; } if (!function_exists('exec')) { $this->warn('函数 exec 已被禁用, 无法继续更新!'); goto LABEL_EXIT; } if (PHP_OS === 'WINNT') { $spd1e74d = 'C:\\Program Files\\7-Zip\\7z.exe'; if (!is_file($spd1e74d)) { $spd1e74d = strtolower($this->ask('未找到7-Zip, 请手动输入7zG.exe路径', $spd1e74d)); } if (!is_file($spd1e74d)) { $this->warn('7-Zip不可用, 请安装7-Zip后重试'); goto LABEL_EXIT; } $spd1e74d = '"' . $spd1e74d . '"'; } else { exec('tar --version', $spc7b6d8, $sp588c3c); if ($sp588c3c) { $this->warn('Error: tar --version ' . join(' -', $spdb2105)); goto LABEL_EXIT; } } $this->comment('正在下载新版本...'); $spf228e5 = $spf2f34a . DIRECTORY_SEPARATOR . 'ka_update_' . Str::random(16) . '.tmp'; if (!$this->download_progress($sp58ef60['url'], $spf228e5)) { $this->warn('写入临时文件失败!'); goto LABEL_EXIT; } $spfbda30 = md5_file($spf228e5); if ($spfbda30 !== $sp58ef60['md5']) { $this->warn('更新文件md5校验失败!, file:' . $spfbda30 . ', require:' . $sp58ef60['md5']); goto LABEL_EXIT; } $this->comment('正在解压...'); unset($spdb2105); if (PHP_OS === 'WINNT') { exec("{$spb79d07} x -so {$spf228e5} | {$spb79d07} x -aoa -si -ttar -o{$spf2f34a}", $spdb2105, $sp2618e5); } else { exec("tar -zxf {$spf228e5} -C {$spf2f34a}", $spdb2105, $sp2618e5); } if ($sp2618e5) { $this->warn('Error: 解压失败 +', $spc7b6d8)); goto LABEL_EXIT; } } $this->comment('正在下载新版本...'); $spfff5a5 = $spa3600b . DIRECTORY_SEPARATOR . 'ka_update_' . Str::random(16) . '.tmp'; if (!$this->download_progress($sp89bfd4['url'], $spfff5a5)) { $this->warn('写入临时文件失败!'); goto LABEL_EXIT; } $spbb3a22 = md5_file($spfff5a5); if ($spbb3a22 !== $sp89bfd4['md5']) { $this->warn('更新文件md5校验失败!, file:' . $spbb3a22 . ', require:' . $sp89bfd4['md5']); goto LABEL_EXIT; } $this->comment('正在解压...'); unset($spc7b6d8); if (PHP_OS === 'WINNT') { exec("{$spd1e74d} x -so {$spfff5a5} | {$spd1e74d} x -aoa -si -ttar -o{$spa3600b}", $spc7b6d8, $sp588c3c); } else { exec("tar -zxf {$spfff5a5} -C {$spa3600b}", $spc7b6d8, $sp588c3c); } if ($sp588c3c) { $this->warn('Error: 解压失败 ' . join(' -', $spdb2105)); goto LABEL_EXIT; } $this->comment('正在关闭主站...'); exec($sp003bfe . ' down'); sleep(5); $this->comment(' --> 正在清理旧文件...'); $sp2a4887 = base_path(); foreach (array('app', 'bootstrap', 'config', 'public/dist', 'database', 'routes', 'vendor') as $spc6a7c6) { \File::deleteDirectory($sp2a4887 . DIRECTORY_SEPARATOR . $spc6a7c6); } $this->comment(' --> 正在复制新文件...'); \File::delete($spf2f34a . DIRECTORY_SEPARATOR . 'card_dist' . DIRECTORY_SEPARATOR . 'public' . DIRECTORY_SEPARATOR . 'images' . DIRECTORY_SEPARATOR . 'logo.png'); \File::delete($spf2f34a . DIRECTORY_SEPARATOR . 'card_dist' . DIRECTORY_SEPARATOR . 'public' . DIRECTORY_SEPARATOR . '.htaccess'); \File::delete($spf2f34a . DIRECTORY_SEPARATOR . 'card_dist' . DIRECTORY_SEPARATOR . 'public' . DIRECTORY_SEPARATOR . 'web.config'); \File::delete($spf2f34a . DIRECTORY_SEPARATOR . 'card_dist' . DIRECTORY_SEPARATOR . 'public' . DIRECTORY_SEPARATOR . 'nginx.conf'); \File::delete($spf2f34a . DIRECTORY_SEPARATOR . 'card_dist' . DIRECTORY_SEPARATOR . 'public' . DIRECTORY_SEPARATOR . 'robots.txt'); \File::copyDirectory($spf2f34a . DIRECTORY_SEPARATOR . 'card_system_free_dist', $sp2a4887); $this->comment(' --> 正在创建缓存...'); exec($sp003bfe . ' cache:clear'); exec($sp003bfe . ' route:cache'); exec($sp003bfe . ' config:cache'); $this->comment(' --> 正在更新数据库...'); exec($sp003bfe . ' migrate'); if (PHP_OS === 'WINNT') { echo ' +', $spc7b6d8)); goto LABEL_EXIT; } $this->comment('正在关闭主站...'); exec($sp8afdaf . ' down'); sleep(5); $this->comment(' --> 正在清理旧文件...'); $sp7a8f15 = base_path(); foreach (array('app', 'bootstrap', 'config', 'public/dist', 'database', 'routes', 'vendor') as $sp7c9413) { \File::deleteDirectory($sp7a8f15 . DIRECTORY_SEPARATOR . $sp7c9413); } $this->comment(' --> 正在复制新文件...'); \File::delete($spa3600b . DIRECTORY_SEPARATOR . 'card_dist' . DIRECTORY_SEPARATOR . 'public' . DIRECTORY_SEPARATOR . 'images' . DIRECTORY_SEPARATOR . 'logo.png'); \File::delete($spa3600b . DIRECTORY_SEPARATOR . 'card_dist' . DIRECTORY_SEPARATOR . 'public' . DIRECTORY_SEPARATOR . '.htaccess'); \File::delete($spa3600b . DIRECTORY_SEPARATOR . 'card_dist' . DIRECTORY_SEPARATOR . 'public' . DIRECTORY_SEPARATOR . 'web.config'); \File::delete($spa3600b . DIRECTORY_SEPARATOR . 'card_dist' . DIRECTORY_SEPARATOR . 'public' . DIRECTORY_SEPARATOR . 'nginx.conf'); \File::delete($spa3600b . DIRECTORY_SEPARATOR . 'card_dist' . DIRECTORY_SEPARATOR . 'public' . DIRECTORY_SEPARATOR . 'robots.txt'); \File::copyDirectory($spa3600b . DIRECTORY_SEPARATOR . 'card_system_free_dist', $sp7a8f15); $this->comment(' --> 正在创建缓存...'); exec($sp8afdaf . ' cache:clear'); exec($sp8afdaf . ' route:cache'); exec($sp8afdaf . ' config:cache'); $this->comment(' --> 正在更新数据库...'); exec($sp8afdaf . ' migrate'); if (PHP_OS === 'WINNT') { echo ' '; $this->alert('请注意手动设置目录权限'); $this->comment(' storage 可读可写 '); $this->comment(' bootstrap/cache/ 可读可写 '); echo ' -'; } else { $this->comment(' --> 正在设置目录权限...'); exec('rm -rf storage/framework/cache/data/*'); exec('chmod -R 777 storage/'); exec('chmod -R 777 bootstrap/cache/'); } $this->comment('正在启用主站...'); exec($sp003bfe . ' up'); exec($sp003bfe . ' queue:restart'); $spe2d6a8 = true; LABEL_EXIT: if (isset($spf2f34a) && strlen($spf2f34a) > 19) { $this->comment('清理临时目录...'); \File::deleteDirectory($spf2f34a); } if (isset($spe2d6a8) && $spe2d6a8) { $this->info('更新成功!'); } if (PHP_OS === 'WINNT') { } else { exec('rm -rf storage/framework/cache/data/*'); exec('chmod -R 777 storage/'); exec('chmod -R 777 bootstrap/cache/'); } echo ' +'; } else { $this->comment(' --> 正在设置目录权限...'); exec('rm -rf storage/framework/cache/data/*'); exec('chmod -R 777 storage/'); exec('chmod -R 777 bootstrap/cache/'); } $this->comment('正在启用主站...'); exec($sp8afdaf . ' up'); exec($sp8afdaf . ' queue:restart'); $spdb8486 = true; LABEL_EXIT: if (isset($spa3600b) && strlen($spa3600b) > 19) { $this->comment('清理临时目录...'); \File::deleteDirectory($spa3600b); } if (isset($spdb8486) && $spdb8486) { $this->info('更新成功!'); } if (PHP_OS === 'WINNT') { } else { exec('rm -rf storage/framework/cache/data/*'); exec('chmod -R 777 storage/'); exec('chmod -R 777 bootstrap/cache/'); } echo ' '; die; } } \ No newline at end of file diff --git a/app/Console/Kernel.php b/app/Console/Kernel.php index b0fe206d..9e1729d1 100644 --- a/app/Console/Kernel.php +++ b/app/Console/Kernel.php @@ -1,4 +1,4 @@ runningInConsole()) { return; } try { System::_init(); } catch (\Throwable $spd118f7) { return; } if (System::_getInt('order_clean_unpay_open') === 1) { $speb0111 = System::_getInt('order_clean_unpay_day', 7); $spd458a9->call(function () use($speb0111) { echo '[' . date('Y-m-d H:i:s') . "] cleaning unpaid orders({$speb0111} days ago)...\n"; \App\Order::where('status', \App\Order::STATUS_UNPAY)->where('created_at', '<', (new Carbon())->addDays(-$speb0111))->delete(); $spa7c069 = '[' . date('Y-m-d H:i:s') . '] unpaid-orders cleaned -'; echo $spa7c069; })->dailyAt('01:00'); } $spd458a9->call(function () { $speb0111 = 7; echo '[' . date('Y-m-d H:i:s') . "] cleaning deleted cards({$speb0111} days ago)...\n"; \App\Card::onlyTrashed()->where('deleted_at', '<', (new Carbon())->addDays(-$speb0111))->forceDelete(); $spa7c069 = '[' . date('Y-m-d H:i:s') . '] deleted-cards cleaned -'; echo $spa7c069; })->dailyAt('02:00'); } protected function commands() { $this->load(__DIR__ . '/Commands'); require base_path('routes/console.php'); } } \ No newline at end of file +namespace App\Console; use App\System; use Carbon\Carbon; use Illuminate\Console\Scheduling\Schedule; use Illuminate\Foundation\Console\Kernel as ConsoleKernel; use Illuminate\Support\Facades\DB; use Illuminate\Support\Facades\Log; use Illuminate\Support\Facades\Schema; class Kernel extends ConsoleKernel { protected $commands = array(); protected function schedule(Schedule $spddf716) { if (!app()->runningInConsole()) { return; } try { System::_init(); } catch (\Throwable $sp0b065e) { return; } if (System::_getInt('order_clean_unpay_open') === 1) { $sp3ac394 = System::_getInt('order_clean_unpay_day', 7); $spddf716->call(function () use($sp3ac394) { echo '[' . date('Y-m-d H:i:s') . "] cleaning unpaid orders({$sp3ac394} days ago)...\n"; \App\Order::where('status', \App\Order::STATUS_UNPAY)->where('created_at', '<', (new Carbon())->addDays(-$sp3ac394))->delete(); $sp5b1bec = '[' . date('Y-m-d H:i:s') . '] unpaid-orders cleaned +'; echo $sp5b1bec; })->dailyAt('01:00'); } $spddf716->call(function () { $sp3ac394 = 7; echo '[' . date('Y-m-d H:i:s') . "] cleaning deleted cards({$sp3ac394} days ago)...\n"; \App\Card::onlyTrashed()->where('deleted_at', '<', (new Carbon())->addDays(-$sp3ac394))->forceDelete(); $sp5b1bec = '[' . date('Y-m-d H:i:s') . '] deleted-cards cleaned +'; echo $sp5b1bec; })->dailyAt('02:00'); } protected function commands() { $this->load(__DIR__ . '/Commands'); require base_path('routes/console.php'); } } \ No newline at end of file diff --git a/app/Exceptions/Handler.php b/app/Exceptions/Handler.php index 1de55a90..1fe72a2b 100644 --- a/app/Exceptions/Handler.php +++ b/app/Exceptions/Handler.php @@ -1,2 +1,2 @@ isXmlHttpRequest() ? response()->json(array('message' => $spa7c069), $spaa7124) : response()->view('errors._', array('code' => $spaa7124, 'message' => $spa7c069), $spaa7124); } public function render($spe5a184, Exception $spd118f7) { if ($spd118f7 instanceof \Illuminate\Database\Eloquent\ModelNotFoundException) { return $this->msg($spe5a184, trans('exception.resource_not_found'), 404); } elseif ($spd118f7 instanceof \Symfony\Component\HttpKernel\Exception\UnauthorizedHttpException || $spd118f7 instanceof \Illuminate\Auth\AuthenticationException) { Log::error('Caught a UnauthorizedHttpException', array('exception' => $spd118f7)); return $this->msg($spe5a184, trans('exception.please_login'), 401); } elseif ($spd118f7 instanceof \Illuminate\Auth\Access\AuthorizationException) { return $this->msg($spe5a184, trans('exception.un_authenticated'), 403); } elseif ($spd118f7 instanceof \Illuminate\Validation\ValidationException) { $spe5a184->headers->set('X-Requested-With', 'XMLHttpRequest'); $spe5a184->headers->set('Accept', 'application/json'); return parent::render($spe5a184, $spd118f7); } elseif ($spd118f7 instanceof \Illuminate\Session\TokenMismatchException) { return $this->msg($spe5a184, trans('exception.csrf_token_invalid'), 403); } elseif ($spd118f7 instanceof \Symfony\Component\HttpKernel\Exception\NotFoundHttpException) { return $this->msg($spe5a184, trans('exception.not_found'), 404); } elseif ($spd118f7 instanceof \Symfony\Component\HttpKernel\Exception\MethodNotAllowedHttpException) { return $this->msg($spe5a184, trans('exception.method_not_allowed'), 405); } elseif ($spd118f7 instanceof \Symfony\Component\HttpKernel\Exception\ServiceUnavailableHttpException) { return $this->msg($spe5a184, trans('exception.service_unavailable'), 503); } elseif ($spd118f7 instanceof \Symfony\Component\HttpKernel\Exception\HttpException) { $sp029c73 = $spd118f7->getStatusCode() ?? 500; switch ($sp029c73) { case 429: return $this->msg($spe5a184, trans('exception.too_many_requests'), $sp029c73); break; default: Log::error('Caught a UnknownHttpException', array('exception' => $spd118f7)); return $this->msg($spe5a184, trans('exception.service_unavailable'), $sp029c73); } } elseif ($spd118f7 instanceof \Symfony\Component\HttpFoundation\Exception\SuspiciousOperationException) { return $this->msg($spe5a184, trans('exception.method_not_allowed'), 405); } Log::error('Uncaught Exception', array('exception' => $spd118f7, 'method' => $spe5a184->method(), 'url' => $spe5a184->fullUrl(), 'data' => file_get_contents('php://input'), 'ip' => Helper::getIP() ?? $spe5a184->ip(), 'client_ip' => $spe5a184->getClientIp(), 'headers' => $spe5a184->header())); if (config('app.debug')) { return parent::render($spe5a184, $spd118f7); } else { return $this->msg($spe5a184, trans('exception.unknown_error'), 500); } } } \ No newline at end of file +namespace App\Exceptions; use App\Library\Helper; use App\Library\Response; use Exception; use Illuminate\Foundation\Exceptions\Handler as ExceptionHandler; use Illuminate\Support\Facades\Log; class Handler extends ExceptionHandler { protected $dontReport = array(); protected $dontFlash = array('password', 'password_confirmation'); public function report(Exception $sp24c601) { parent::report($sp24c601); } private function msg($sp517903, $sp5b1bec, $sp0194a7) { return $sp517903->isXmlHttpRequest() ? response()->json(array('message' => $sp5b1bec), $sp0194a7) : response()->view('errors._', array('code' => $sp0194a7, 'message' => $sp5b1bec), $sp0194a7); } public function render($sp517903, Exception $sp0b065e) { if ($sp0b065e instanceof \Illuminate\Database\Eloquent\ModelNotFoundException) { return $this->msg($sp517903, trans('exception.resource_not_found'), 404); } elseif ($sp0b065e instanceof \Symfony\Component\HttpKernel\Exception\UnauthorizedHttpException || $sp0b065e instanceof \Illuminate\Auth\AuthenticationException) { Log::error('Caught a UnauthorizedHttpException', array('exception' => $sp0b065e)); return $this->msg($sp517903, trans('exception.please_login'), 401); } elseif ($sp0b065e instanceof \Illuminate\Auth\Access\AuthorizationException) { return $this->msg($sp517903, trans('exception.un_authenticated'), 403); } elseif ($sp0b065e instanceof \Illuminate\Validation\ValidationException) { $sp517903->headers->set('X-Requested-With', 'XMLHttpRequest'); $sp517903->headers->set('Accept', 'application/json'); return parent::render($sp517903, $sp0b065e); } elseif ($sp0b065e instanceof \Illuminate\Session\TokenMismatchException) { return $this->msg($sp517903, trans('exception.csrf_token_invalid'), 403); } elseif ($sp0b065e instanceof \Symfony\Component\HttpKernel\Exception\NotFoundHttpException) { return $this->msg($sp517903, trans('exception.not_found'), 404); } elseif ($sp0b065e instanceof \Symfony\Component\HttpKernel\Exception\MethodNotAllowedHttpException) { return $this->msg($sp517903, trans('exception.method_not_allowed'), 405); } elseif ($sp0b065e instanceof \Symfony\Component\HttpKernel\Exception\ServiceUnavailableHttpException) { return $this->msg($sp517903, trans('exception.service_unavailable'), 503); } elseif ($sp0b065e instanceof \Symfony\Component\HttpKernel\Exception\HttpException) { $sp8b0a1c = $sp0b065e->getStatusCode() ?? 500; switch ($sp8b0a1c) { case 429: return $this->msg($sp517903, trans('exception.too_many_requests'), $sp8b0a1c); break; default: Log::error('Caught a UnknownHttpException', array('exception' => $sp0b065e)); return $this->msg($sp517903, trans('exception.service_unavailable'), $sp8b0a1c); } } elseif ($sp0b065e instanceof \Symfony\Component\HttpFoundation\Exception\SuspiciousOperationException) { return $this->msg($sp517903, trans('exception.method_not_allowed'), 405); } Log::error('Uncaught Exception', array('exception' => $sp0b065e, 'method' => $sp517903->method(), 'url' => $sp517903->fullUrl(), 'data' => file_get_contents('php://input'), 'ip' => Helper::getIP() ?? $sp517903->ip(), 'client_ip' => $sp517903->getClientIp(), 'headers' => $sp517903->header())); if (config('app.debug')) { return parent::render($sp517903, $sp0b065e); } else { return $this->msg($sp517903, trans('exception.unknown_error'), 500); } } } \ No newline at end of file diff --git a/app/File.php b/app/File.php index e7dbb4c2..1b7318a5 100644 --- a/app/File.php +++ b/app/File.php @@ -1,2 +1,2 @@ driver)->delete($this->path); } catch (\Exception $spd118f7) { \Log::error('File.deleteFile Error: ' . $spd118f7->getMessage(), array('exception' => $spd118f7)); } } public static function getProductFolder() { return 'images/product'; } } \ No newline at end of file +namespace App; use Illuminate\Database\Eloquent\Model; class File extends Model { protected $guarded = array(); public $timestamps = false; function deleteFile() { try { Storage::disk($this->driver)->delete($this->path); } catch (\Exception $sp0b065e) { \Log::error('File.deleteFile Error: ' . $sp0b065e->getMessage(), array('exception' => $sp0b065e)); } } public static function getProductFolder() { return 'images/product'; } } \ No newline at end of file diff --git a/app/Http/Controllers/Admin/Dashboard.php b/app/Http/Controllers/Admin/Dashboard.php index d64c2418..8c43d7a4 100644 --- a/app/Http/Controllers/Admin/Dashboard.php +++ b/app/Http/Controllers/Admin/Dashboard.php @@ -1,2 +1,2 @@ array('count' => 0, 'paid' => 0, 'profit' => 0), 'yesterday' => array('count' => 0, 'paid' => 0, 'profit' => 0)); $spdb2625 = Order::whereUserId(\Auth::Id())->whereDate('paid_at', \Carbon\Carbon::now()->toDateString())->where(function ($spa8a4ff) { $spa8a4ff->where('status', Order::STATUS_PAID)->orWhere('status', Order::STATUS_SUCCESS); })->selectRaw('COUNT(*) as `count`,SUM(`paid`) as `paid`,SUM(`paid`-`sms_price`-`cost`-`fee`) as `profit`')->get()->toArray(); $sp89209e = Order::whereUserId(\Auth::Id())->whereDate('paid_at', \Carbon\Carbon::yesterday()->toDateString())->where(function ($spa8a4ff) { $spa8a4ff->where('status', Order::STATUS_PAID)->orWhere('status', Order::STATUS_SUCCESS); })->selectRaw('COUNT(*) as `count`,SUM(`paid`) as `paid`,SUM(`paid`-`sms_price`-`cost`-`fee`) as `profit`')->get()->toArray(); if (isset($spdb2625[0]) && isset($spdb2625[0]['count'])) { $spfcaacd['today'] = array('count' => (int) $spdb2625[0]['count'], 'paid' => (int) $spdb2625[0]['paid'], 'profit' => (int) $spdb2625[0]['profit']); } if (isset($sp89209e[0]) && isset($sp89209e[0]['count'])) { $spfcaacd['yesterday'] = array('count' => (int) $sp89209e[0]['count'], 'paid' => (int) $sp89209e[0]['paid'], 'profit' => (int) $sp89209e[0]['profit']); } $spfcaacd['need_ship_count'] = Order::whereUserId(\Auth::Id())->where('status', Order::STATUS_PAID)->count(); $spfcaacd['login'] = \App\Log::where('action', \App\Log::ACTION_LOGIN)->latest()->first(); return Response::success($spfcaacd); } function clearCache() { if (function_exists('opcache_reset')) { opcache_reset(); } try { \Artisan::call('cache:clear'); \Artisan::call('route:cache'); \Artisan::call('config:cache'); } catch (\Throwable $spd118f7) { return Response::fail($spd118f7->getMessage()); } return Response::success(); } function version() { $spc3c213 = array(); $spb00d6e = CurlRequest::curl('https://raw.githubusercontent.com/Tai7sy/card-system/master/.version', 0, null, array(), 5, $sp35923d, $spe9590d, $spbb923d); $sp58ef60 = @json_decode($spb00d6e, true); if (!@$sp58ef60['data']['version']) { Log::error('Dashboard.version checkUpdate failed', array('response' => $spb00d6e, 'httpCode' => $spe9590d, 'error' => $spbb923d)); $spc3c213['message'] = '检查更新失败: ' . $spbb923d; } else { $spc3c213 = array('version' => $sp58ef60['data']['version'], 'description' => @$sp58ef60['data']['description'] ?? '无'); } return Response::success(array('version' => config('app.version'), 'update' => $spc3c213)); } function logsToken() { $sp63ab26 = md5(random_bytes(128)); Cache::put($sp63ab26, Auth::getUser(), 15); return response(array('token' => $sp63ab26)); } function logsView(Request $spe5a184, $sp63ab26) { if ($sp766bcc = Cache::get($sp63ab26)) { Cache::put($sp63ab26, $sp766bcc, 15); return (new \Rap2hpoutre\LaravelLogViewer\LogViewerController())->index(); } else { throw new \Symfony\Component\HttpKernel\Exception\UnauthorizedHttpException('logs-token'); } } } \ No newline at end of file +namespace App\Http\Controllers\Admin; use App\Library\CurlRequest; use App\Library\Response; use App\Order; use Illuminate\Http\Request; use App\Http\Controllers\Controller; use Illuminate\Support\Facades\Auth; use Illuminate\Support\Facades\Cache; use Illuminate\Support\Facades\Log; class Dashboard extends Controller { function index(Request $sp517903) { $spbca16f = array('today' => array('count' => 0, 'paid' => 0, 'profit' => 0), 'yesterday' => array('count' => 0, 'paid' => 0, 'profit' => 0)); $sp6e2029 = Order::whereUserId(\Auth::Id())->whereDate('paid_at', \Carbon\Carbon::now()->toDateString())->where(function ($sp30241a) { $sp30241a->where('status', Order::STATUS_PAID)->orWhere('status', Order::STATUS_SUCCESS); })->selectRaw('COUNT(*) as `count`,SUM(`paid`) as `paid`,SUM(`paid`-`sms_price`-`cost`-`fee`) as `profit`')->get()->toArray(); $spb24c43 = Order::whereUserId(\Auth::Id())->whereDate('paid_at', \Carbon\Carbon::yesterday()->toDateString())->where(function ($sp30241a) { $sp30241a->where('status', Order::STATUS_PAID)->orWhere('status', Order::STATUS_SUCCESS); })->selectRaw('COUNT(*) as `count`,SUM(`paid`) as `paid`,SUM(`paid`-`sms_price`-`cost`-`fee`) as `profit`')->get()->toArray(); if (isset($sp6e2029[0]) && isset($sp6e2029[0]['count'])) { $spbca16f['today'] = array('count' => (int) $sp6e2029[0]['count'], 'paid' => (int) $sp6e2029[0]['paid'], 'profit' => (int) $sp6e2029[0]['profit']); } if (isset($spb24c43[0]) && isset($spb24c43[0]['count'])) { $spbca16f['yesterday'] = array('count' => (int) $spb24c43[0]['count'], 'paid' => (int) $spb24c43[0]['paid'], 'profit' => (int) $spb24c43[0]['profit']); } $spbca16f['need_ship_count'] = Order::whereUserId(\Auth::Id())->where('status', Order::STATUS_PAID)->count(); $spbca16f['login'] = \App\Log::where('action', \App\Log::ACTION_LOGIN)->latest()->first(); return Response::success($spbca16f); } function clearCache() { if (function_exists('opcache_reset')) { opcache_reset(); } try { \Artisan::call('cache:clear'); \Artisan::call('route:cache'); \Artisan::call('config:cache'); } catch (\Throwable $sp0b065e) { return Response::fail($sp0b065e->getMessage()); } return Response::success(); } function version() { $sp46268e = array(); $sp25ffb8 = CurlRequest::curl('https://raw.githubusercontent.com/Tai7sy/card-system/master/.version', 0, null, array(), 5, $sp264383, $sp322a14, $spd9676d); $sp89bfd4 = @json_decode($sp25ffb8, true); if (!@$sp89bfd4['data']['version']) { Log::error('Dashboard.version checkUpdate failed', array('response' => $sp25ffb8, 'httpCode' => $sp322a14, 'error' => $spd9676d)); $sp46268e['message'] = '检查更新失败: ' . $spd9676d; } else { $sp46268e = array('version' => $sp89bfd4['data']['version'], 'description' => @$sp89bfd4['data']['description'] ?? '无'); } return Response::success(array('version' => config('app.version'), 'update' => $sp46268e)); } function logsToken() { $sp5f3012 = md5(random_bytes(128)); Cache::put($sp5f3012, Auth::getUser(), 15); return response(array('token' => $sp5f3012)); } function logsView(Request $sp517903, $sp5f3012) { if ($sp3db17d = Cache::get($sp5f3012)) { Cache::put($sp5f3012, $sp3db17d, 15); return (new \Rap2hpoutre\LaravelLogViewer\LogViewerController())->index(); } else { throw new \Symfony\Component\HttpKernel\Exception\UnauthorizedHttpException('logs-token'); } } } \ No newline at end of file diff --git a/app/Http/Controllers/Admin/Order.php b/app/Http/Controllers/Admin/Order.php index 1cfcb75b..cfdb9f32 100644 --- a/app/Http/Controllers/Admin/Order.php +++ b/app/Http/Controllers/Admin/Order.php @@ -1,2 +1,2 @@ validate($spe5a184, array('ids' => 'required|string', 'income' => 'required|integer', 'balance' => 'required|integer')); $sp8152f4 = $spe5a184->post('ids'); $sp152c84 = (int) $spe5a184->post('income'); $sp62805b = (int) $spe5a184->post('balance'); \App\Order::whereIn('id', explode(',', $sp8152f4))->chunk(100, function ($sp5f7c41) use($sp152c84, $sp62805b) { foreach ($sp5f7c41 as $sp42d084) { $sp42d084->cards()->detach(); try { if ($sp152c84) { $sp42d084->fundRecord()->delete(); } if ($sp62805b) { $sp766bcc = \App\User::lockForUpdate()->firstOrFail(); $sp766bcc->m_all -= $sp42d084->income; $sp766bcc->saveOrFail(); } $sp42d084->delete(); } catch (\Exception $spd118f7) { } } }); return Response::success(); } function freeze(Request $spe5a184) { $this->validate($spe5a184, array('ids' => 'required|string')); $sp8152f4 = explode(',', $spe5a184->post('ids')); $spad9b1d = $spe5a184->post('reason'); $sp9154dd = 0; $sp39df7d = 0; foreach ($sp8152f4 as $spc3103e) { $sp9154dd++; if (FundHelper::orderFreeze($spc3103e, $spad9b1d)) { $sp39df7d++; } } return Response::success(array($sp9154dd, $sp39df7d)); } function unfreeze(Request $spe5a184) { $this->validate($spe5a184, array('ids' => 'required|string')); $sp8152f4 = explode(',', $spe5a184->post('ids')); $sp9154dd = 0; $sp39df7d = 0; $spdfe010 = \App\Order::STATUS_FROZEN; foreach ($sp8152f4 as $spc3103e) { $sp9154dd++; if (FundHelper::orderUnfreeze($spc3103e, '后台操作', null, $spdfe010)) { $sp39df7d++; } } return Response::success(array($sp9154dd, $sp39df7d, $spdfe010)); } function set_paid(Request $spe5a184) { $this->validate($spe5a184, array('id' => 'required|integer')); $spb3d6c6 = $spe5a184->post('id', ''); $spe3cc7f = $spe5a184->post('trade_no', ''); if (strlen($spe3cc7f) < 1) { return Response::forbidden('请输入支付系统内单号'); } $sp42d084 = \App\Order::findOrFail($spb3d6c6); if ($sp42d084->status !== \App\Order::STATUS_UNPAY) { return Response::forbidden('只能操作未支付订单'); } $sp369f74 = 'Admin.SetPaid'; $sp0983aa = $sp42d084->order_no; $sp2cb76e = $sp42d084->paid; try { Log::debug($sp369f74 . " shipOrder start, order_no: {$sp0983aa}, amount: {$sp2cb76e}, trade_no: {$spe3cc7f}"); (new \App\Http\Controllers\Shop\Pay())->shipOrder($spe5a184, $sp0983aa, $sp2cb76e, $spe3cc7f); Log::debug($sp369f74 . ' shipOrder end, order_no: ' . $sp0983aa); $sp39df7d = true; $sp1955ac = '发货成功'; } catch (\Exception $spd118f7) { $sp39df7d = false; $sp1955ac = $spd118f7->getMessage(); Log::error($sp369f74 . ' shipOrder Exception: ' . $spd118f7->getMessage()); } $sp42d084 = \App\Order::with(array('pay' => function (Relation $spa8a4ff) { $spa8a4ff->select(array('id', 'name')); }, 'card_orders.card' => function (Relation $spa8a4ff) { $spa8a4ff->select(array('id', 'card')); }))->findOrFail($spb3d6c6); if ($sp42d084->status === \App\Order::STATUS_PAID) { if ($sp42d084->product->delivery === \App\Product::DELIVERY_MANUAL) { $sp39df7d = true; $sp1955ac = '已标记为付款成功
当前商品为手动发货商品, 请手动进行发货。'; } else { $sp39df7d = false; $sp1955ac = '已标记为付款成功,
但是买家库存不足, 发货失败, 请稍后尝试手动发货。'; } } return Response::success(array('code' => $sp39df7d ? 0 : -1, 'msg' => $sp1955ac, 'order' => $sp42d084)); } } \ No newline at end of file +namespace App\Http\Controllers\Admin; use App\Library\FundHelper; use App\Library\Helper; use Carbon\Carbon; use Illuminate\Database\Eloquent\Relations\Relation; use Illuminate\Http\Request; use App\Http\Controllers\Controller; use App\Library\Response; use Illuminate\Support\Facades\DB; use Illuminate\Support\Facades\Log; class Order extends Controller { public function delete(Request $sp517903) { $this->validate($sp517903, array('ids' => 'required|string', 'income' => 'required|integer', 'balance' => 'required|integer')); $sp315ad7 = $sp517903->post('ids'); $sp480598 = (int) $sp517903->post('income'); $spd95776 = (int) $sp517903->post('balance'); \App\Order::whereIn('id', explode(',', $sp315ad7))->chunk(100, function ($sp4fb1a4) use($sp480598, $spd95776) { foreach ($sp4fb1a4 as $sp990b3b) { $sp990b3b->cards()->detach(); try { if ($sp480598) { $sp990b3b->fundRecord()->delete(); } if ($spd95776) { $sp3db17d = \App\User::lockForUpdate()->firstOrFail(); $sp3db17d->m_all -= $sp990b3b->income; $sp3db17d->saveOrFail(); } $sp990b3b->delete(); } catch (\Exception $sp0b065e) { } } }); return Response::success(); } function freeze(Request $sp517903) { $this->validate($sp517903, array('ids' => 'required|string')); $sp315ad7 = explode(',', $sp517903->post('ids')); $spd931ee = $sp517903->post('reason'); $sp7aa4d7 = 0; $spa6425c = 0; foreach ($sp315ad7 as $sp1915a8) { $sp7aa4d7++; if (FundHelper::orderFreeze($sp1915a8, $spd931ee)) { $spa6425c++; } } return Response::success(array($sp7aa4d7, $spa6425c)); } function unfreeze(Request $sp517903) { $this->validate($sp517903, array('ids' => 'required|string')); $sp315ad7 = explode(',', $sp517903->post('ids')); $sp7aa4d7 = 0; $spa6425c = 0; $sp3a090a = \App\Order::STATUS_FROZEN; foreach ($sp315ad7 as $sp1915a8) { $sp7aa4d7++; if (FundHelper::orderUnfreeze($sp1915a8, '后台操作', null, $sp3a090a)) { $spa6425c++; } } return Response::success(array($sp7aa4d7, $spa6425c, $sp3a090a)); } function set_paid(Request $sp517903) { $this->validate($sp517903, array('id' => 'required|integer')); $spd5afc6 = $sp517903->post('id', ''); $sp7b7d53 = $sp517903->post('trade_no', ''); if (strlen($sp7b7d53) < 1) { return Response::forbidden('请输入支付系统内单号'); } $sp990b3b = \App\Order::findOrFail($spd5afc6); if ($sp990b3b->status !== \App\Order::STATUS_UNPAY) { return Response::forbidden('只能操作未支付订单'); } $spca966c = 'Admin.SetPaid'; $sp4c2308 = $sp990b3b->order_no; $sp1058e7 = $sp990b3b->paid; try { Log::debug($spca966c . " shipOrder start, order_no: {$sp4c2308}, amount: {$sp1058e7}, trade_no: {$sp7b7d53}"); (new \App\Http\Controllers\Shop\Pay())->shipOrder($sp517903, $sp4c2308, $sp1058e7, $sp7b7d53); Log::debug($spca966c . ' shipOrder end, order_no: ' . $sp4c2308); $spa6425c = true; $spfc43d6 = '发货成功'; } catch (\Exception $sp0b065e) { $spa6425c = false; $spfc43d6 = $sp0b065e->getMessage(); Log::error($spca966c . ' shipOrder Exception: ' . $sp0b065e->getMessage()); } $sp990b3b = \App\Order::with(array('pay' => function (Relation $sp30241a) { $sp30241a->select(array('id', 'name')); }, 'card_orders.card' => function (Relation $sp30241a) { $sp30241a->select(array('id', 'card')); }))->findOrFail($spd5afc6); if ($sp990b3b->status === \App\Order::STATUS_PAID) { if ($sp990b3b->product->delivery === \App\Product::DELIVERY_MANUAL) { $spa6425c = true; $spfc43d6 = '已标记为付款成功
当前商品为手动发货商品, 请手动进行发货。'; } else { $spa6425c = false; $spfc43d6 = '已标记为付款成功,
但是买家库存不足, 发货失败, 请稍后尝试手动发货。'; } } return Response::success(array('code' => $spa6425c ? 0 : -1, 'msg' => $spfc43d6, 'order' => $sp990b3b)); } } \ No newline at end of file diff --git a/app/Http/Controllers/Admin/Pay.php b/app/Http/Controllers/Admin/Pay.php index b37bd7ef..84bdf86e 100644 --- a/app/Http/Controllers/Admin/Pay.php +++ b/app/Http/Controllers/Admin/Pay.php @@ -1,2 +1,2 @@ input('enabled'); if (strlen($sp89bdae)) { $spa8a4ff->whereIn('enabled', explode(',', $sp89bdae)); } $sp8336a0 = $spe5a184->input('search', false); $spdbda3a = $spe5a184->input('val', false); if ($sp8336a0 && $spdbda3a) { if ($sp8336a0 == 'simple') { return Response::success($spa8a4ff->get(array('id', 'name', 'enabled', 'comment'))); } elseif ($sp8336a0 == 'id') { $spa8a4ff->where('id', $spdbda3a); } else { $spa8a4ff->where($sp8336a0, 'like', '%' . $spdbda3a . '%'); } } $spdf0cee = $spa8a4ff->get(); return Response::success(array('list' => $spdf0cee, 'urls' => array('url' => config('app.url'), 'url_api' => config('app.url_api')))); } function stat(Request $spe5a184) { $this->validate($spe5a184, array('day' => 'required|integer|between:1,30')); $speb0111 = (int) $spe5a184->input('day'); if ($speb0111 === 30) { $sp705209 = Carbon::now()->addMonths(-1)->toDateString() . ' 00:00:00'; } else { $sp705209 = Carbon::now()->addDays(-$speb0111)->toDateString() . ' 00:00:00'; } $spdf0cee = $this->authQuery($spe5a184, \App\Order::class)->where(function ($spa8a4ff) { $spa8a4ff->where('status', \App\Order::STATUS_PAID)->orWhere('status', \App\Order::STATUS_SUCCESS); })->where('paid_at', '>=', $sp705209)->with(array('pay' => function ($spa8a4ff) { $spa8a4ff->select(array('id', 'name')); }))->groupBy('pay_id')->selectRaw('`pay_id`,COUNT(*) as "count",SUM(`paid`) as "sum"')->get()->toArray(); $spa64ee0 = array(); foreach ($spdf0cee as $sp415442) { if (isset($sp415442['pay']) && isset($sp415442['pay']['name'])) { $sp6f5168 = $sp415442['pay']['name']; } else { $sp6f5168 = '未知方式#' . $sp415442['pay_id']; } $spa64ee0[$sp6f5168] = array((int) $sp415442['count'], (int) $sp415442['sum']); } return Response::success($spa64ee0); } function edit(Request $spe5a184) { $this->validate($spe5a184, array('id' => 'sometimes|integer', 'name' => 'required|string', 'driver' => 'required|string', 'way' => 'required|string', 'config' => 'required|string', 'fee_system' => 'required|numeric')); $sp56e1de = \App\Pay::find((int) $spe5a184->post('id')); if (!$sp56e1de) { $sp56e1de = new \App\Pay(); } $sp56e1de->name = $spe5a184->post('name'); $sp56e1de->comment = $spe5a184->post('comment'); $sp56e1de->driver = $spe5a184->post('driver'); $sp56e1de->way = $spe5a184->post('way'); $sp56e1de->config = $spe5a184->post('config'); $sp56e1de->enabled = (int) $spe5a184->post('enabled'); $sp56e1de->fee_system = $spe5a184->post('fee_system'); $sp56e1de->saveOrFail(); return Response::success(); } function comment(Request $spe5a184) { $this->validate($spe5a184, array('id' => 'required|integer')); $spb3d6c6 = (int) $spe5a184->post('id'); $sp56e1de = \App\Pay::findOrFail($spb3d6c6); $sp56e1de->comment = $spe5a184->post('comment'); $sp56e1de->save(); return Response::success(); } function fee_system(Request $spe5a184) { $this->validate($spe5a184, array('id' => 'required|integer')); $spb3d6c6 = (int) $spe5a184->post('id'); $sp56e1de = \App\Pay::findOrFail($spb3d6c6); $sp56e1de->fee_system = $spe5a184->post('fee_system'); $sp56e1de->saveOrFail(); return Response::success(); } function enable(Request $spe5a184) { $this->validate($spe5a184, array('ids' => 'required|string', 'enabled' => 'required|integer|between:0,3')); $sp8152f4 = $spe5a184->post('ids'); $sp89bdae = (int) $spe5a184->post('enabled'); \App\Pay::whereIn('id', explode(',', $sp8152f4))->update(array('enabled' => $sp89bdae)); \App\Pay::flushCache(); return Response::success(); } function delete(Request $spe5a184) { $this->validate($spe5a184, array('ids' => 'required|string')); $sp8152f4 = $spe5a184->post('ids'); \App\Pay::whereIn('id', explode(',', $sp8152f4))->delete(); \App\Pay::flushCache(); return Response::success(); } } \ No newline at end of file +namespace App\Http\Controllers\Admin; use App\Library\Helper; use Carbon\Carbon; use function foo\func; use Illuminate\Http\Request; use App\Http\Controllers\Controller; use App\Library\Response; class Pay extends Controller { function get(Request $sp517903) { $sp30241a = \App\Pay::query(); $spb38401 = $sp517903->input('enabled'); if (strlen($spb38401)) { $sp30241a->whereIn('enabled', explode(',', $spb38401)); } $spee2f3d = $sp517903->input('search', false); $sp5d286a = $sp517903->input('val', false); if ($spee2f3d && $sp5d286a) { if ($spee2f3d == 'simple') { return Response::success($sp30241a->get(array('id', 'name', 'enabled', 'comment'))); } elseif ($spee2f3d == 'id') { $sp30241a->where('id', $sp5d286a); } else { $sp30241a->where($spee2f3d, 'like', '%' . $sp5d286a . '%'); } } $sp38cdfb = $sp30241a->get(); return Response::success(array('list' => $sp38cdfb, 'urls' => array('url' => config('app.url'), 'url_api' => config('app.url_api')))); } function stat(Request $sp517903) { $this->validate($sp517903, array('day' => 'required|integer|between:1,30')); $sp3ac394 = (int) $sp517903->input('day'); if ($sp3ac394 === 30) { $sp30ea99 = Carbon::now()->addMonths(-1)->toDateString() . ' 00:00:00'; } else { $sp30ea99 = Carbon::now()->addDays(-$sp3ac394)->toDateString() . ' 00:00:00'; } $sp38cdfb = $this->authQuery($sp517903, \App\Order::class)->where(function ($sp30241a) { $sp30241a->where('status', \App\Order::STATUS_PAID)->orWhere('status', \App\Order::STATUS_SUCCESS); })->where('paid_at', '>=', $sp30ea99)->with(array('pay' => function ($sp30241a) { $sp30241a->select(array('id', 'name')); }))->groupBy('pay_id')->selectRaw('`pay_id`,COUNT(*) as "count",SUM(`paid`) as "sum"')->get()->toArray(); $spd9807c = array(); foreach ($sp38cdfb as $sp4ae387) { if (isset($sp4ae387['pay']) && isset($sp4ae387['pay']['name'])) { $sp6183be = $sp4ae387['pay']['name']; } else { $sp6183be = '未知方式#' . $sp4ae387['pay_id']; } $spd9807c[$sp6183be] = array((int) $sp4ae387['count'], (int) $sp4ae387['sum']); } return Response::success($spd9807c); } function edit(Request $sp517903) { $this->validate($sp517903, array('id' => 'sometimes|integer', 'name' => 'required|string', 'driver' => 'required|string', 'way' => 'required|string', 'config' => 'required|string', 'fee_system' => 'required|numeric')); $sp38a73e = \App\Pay::find((int) $sp517903->post('id')); if (!$sp38a73e) { $sp38a73e = new \App\Pay(); } $sp38a73e->name = $sp517903->post('name'); $sp38a73e->comment = $sp517903->post('comment'); $sp38a73e->driver = $sp517903->post('driver'); $sp38a73e->way = $sp517903->post('way'); $sp38a73e->config = $sp517903->post('config'); $sp38a73e->enabled = (int) $sp517903->post('enabled'); $sp38a73e->fee_system = $sp517903->post('fee_system'); $sp38a73e->saveOrFail(); return Response::success(); } function comment(Request $sp517903) { $this->validate($sp517903, array('id' => 'required|integer')); $spd5afc6 = (int) $sp517903->post('id'); $sp38a73e = \App\Pay::findOrFail($spd5afc6); $sp38a73e->comment = $sp517903->post('comment'); $sp38a73e->save(); return Response::success(); } function fee_system(Request $sp517903) { $this->validate($sp517903, array('id' => 'required|integer')); $spd5afc6 = (int) $sp517903->post('id'); $sp38a73e = \App\Pay::findOrFail($spd5afc6); $sp38a73e->fee_system = $sp517903->post('fee_system'); $sp38a73e->saveOrFail(); return Response::success(); } function enable(Request $sp517903) { $this->validate($sp517903, array('ids' => 'required|string', 'enabled' => 'required|integer|between:0,3')); $sp315ad7 = $sp517903->post('ids'); $spb38401 = (int) $sp517903->post('enabled'); \App\Pay::whereIn('id', explode(',', $sp315ad7))->update(array('enabled' => $spb38401)); \App\Pay::flushCache(); return Response::success(); } function delete(Request $sp517903) { $this->validate($sp517903, array('ids' => 'required|string')); $sp315ad7 = $sp517903->post('ids'); \App\Pay::whereIn('id', explode(',', $sp315ad7))->delete(); \App\Pay::flushCache(); return Response::success(); } } \ No newline at end of file diff --git a/app/Http/Controllers/Admin/PayWay.php b/app/Http/Controllers/Admin/PayWay.php index 62b03290..d1152eb2 100644 --- a/app/Http/Controllers/Admin/PayWay.php +++ b/app/Http/Controllers/Admin/PayWay.php @@ -1,2 +1,2 @@ input('current_page', 1); $sp048014 = (int) $spe5a184->input('per_page', 20); $spa8a4ff = \App\PayWay::orderBy('sort')->where('type', $spe5a184->input('type')); $sp8336a0 = $spe5a184->input('search', false); $spdbda3a = $spe5a184->input('val', false); if ($sp8336a0 && $spdbda3a) { if ($sp8336a0 == 'simple') { return Response::success($spa8a4ff->get(array('id', 'name'))); } elseif ($sp8336a0 == 'id') { $spa8a4ff->where('id', $spdbda3a); } else { $spa8a4ff->where($sp8336a0, 'like', '%' . $spdbda3a . '%'); } } $sp89bdae = $spe5a184->input('enabled'); if (strlen($sp89bdae)) { $spa8a4ff->whereIn('enabled', explode(',', $sp89bdae)); } $spdf0cee = $spa8a4ff->paginate($sp048014, array('*'), 'page', $sp32b355); return Response::success($spdf0cee); } function edit(Request $spe5a184) { $this->validate($spe5a184, array('id' => 'required|integer', 'type' => 'required|integer|between:1,2', 'name' => 'required|string', 'sort' => 'required|integer', 'channels' => 'required|string', 'enabled' => 'required|integer|between:0,3')); $spb3d6c6 = (int) $spe5a184->post('id'); $spaa0265 = \App\PayWay::find($spb3d6c6); if (!$spaa0265) { if (\App\PayWay::where('name', $spe5a184->post('name'))->exists()) { return Response::fail('名称已经存在'); } $spaa0265 = new \App\PayWay(); } else { if (\App\PayWay::where('name', $spe5a184->post('name'))->where('id', '!=', $spaa0265->id)->exists()) { return Response::fail('名称已经存在'); } } $spaa0265->type = (int) $spe5a184->post('type'); $spaa0265->name = $spe5a184->post('name'); $spaa0265->sort = (int) $spe5a184->post('sort'); $spaa0265->img = $spe5a184->post('img'); $spaa0265->channels = @json_decode($spe5a184->post('channels')) ?? array(); $spaa0265->comment = $spe5a184->post('comment'); $spaa0265->enabled = (int) $spe5a184->post('enabled'); $spaa0265->saveOrFail(); return Response::success(); } function enable(Request $spe5a184) { $this->validate($spe5a184, array('ids' => 'required|string', 'enabled' => 'required|integer|between:0,3')); $sp8152f4 = $spe5a184->post('ids'); $sp89bdae = (int) $spe5a184->post('enabled'); \App\PayWay::whereIn('id', explode(',', $sp8152f4))->update(array('enabled' => $sp89bdae)); return Response::success(); } function sort(Request $spe5a184) { $this->validate($spe5a184, array('id' => 'required|integer')); $spb3d6c6 = (int) $spe5a184->post('id'); $spaa0265 = \App\PayWay::findOrFail($spb3d6c6); $spaa0265->sort = (int) $spe5a184->post('sort'); $spaa0265->save(); return Response::success(); } function delete(Request $spe5a184) { $this->validate($spe5a184, array('ids' => 'required|string')); $sp8152f4 = $spe5a184->post('ids'); \App\PayWay::whereIn('id', explode(',', $sp8152f4))->delete(); return Response::success(); } } \ No newline at end of file +namespace App\Http\Controllers\Admin; use App\Library\Response; use Illuminate\Http\Request; use App\Http\Controllers\Controller; class PayWay extends Controller { function get(Request $sp517903) { $sp542adc = (int) $sp517903->input('current_page', 1); $spf40cb2 = (int) $sp517903->input('per_page', 20); $sp30241a = \App\PayWay::orderBy('sort')->where('type', $sp517903->input('type')); $spee2f3d = $sp517903->input('search', false); $sp5d286a = $sp517903->input('val', false); if ($spee2f3d && $sp5d286a) { if ($spee2f3d == 'simple') { return Response::success($sp30241a->get(array('id', 'name'))); } elseif ($spee2f3d == 'id') { $sp30241a->where('id', $sp5d286a); } else { $sp30241a->where($spee2f3d, 'like', '%' . $sp5d286a . '%'); } } $spb38401 = $sp517903->input('enabled'); if (strlen($spb38401)) { $sp30241a->whereIn('enabled', explode(',', $spb38401)); } $sp38cdfb = $sp30241a->paginate($spf40cb2, array('*'), 'page', $sp542adc); return Response::success($sp38cdfb); } function edit(Request $sp517903) { $this->validate($sp517903, array('id' => 'required|integer', 'type' => 'required|integer|between:1,2', 'name' => 'required|string', 'sort' => 'required|integer', 'channels' => 'required|string', 'enabled' => 'required|integer|between:0,3')); $spd5afc6 = (int) $sp517903->post('id'); $sp418422 = \App\PayWay::find($spd5afc6); if (!$sp418422) { if (\App\PayWay::where('name', $sp517903->post('name'))->exists()) { return Response::fail('名称已经存在'); } $sp418422 = new \App\PayWay(); } else { if (\App\PayWay::where('name', $sp517903->post('name'))->where('id', '!=', $sp418422->id)->exists()) { return Response::fail('名称已经存在'); } } $sp418422->type = (int) $sp517903->post('type'); $sp418422->name = $sp517903->post('name'); $sp418422->sort = (int) $sp517903->post('sort'); $sp418422->img = $sp517903->post('img'); $sp418422->channels = @json_decode($sp517903->post('channels')) ?? array(); $sp418422->comment = $sp517903->post('comment'); $sp418422->enabled = (int) $sp517903->post('enabled'); $sp418422->saveOrFail(); return Response::success(); } function enable(Request $sp517903) { $this->validate($sp517903, array('ids' => 'required|string', 'enabled' => 'required|integer|between:0,3')); $sp315ad7 = $sp517903->post('ids'); $spb38401 = (int) $sp517903->post('enabled'); \App\PayWay::whereIn('id', explode(',', $sp315ad7))->update(array('enabled' => $spb38401)); return Response::success(); } function sort(Request $sp517903) { $this->validate($sp517903, array('id' => 'required|integer')); $spd5afc6 = (int) $sp517903->post('id'); $sp418422 = \App\PayWay::findOrFail($spd5afc6); $sp418422->sort = (int) $sp517903->post('sort'); $sp418422->save(); return Response::success(); } function delete(Request $sp517903) { $this->validate($sp517903, array('ids' => 'required|string')); $sp315ad7 = $sp517903->post('ids'); \App\PayWay::whereIn('id', explode(',', $sp315ad7))->delete(); return Response::success(); } } \ No newline at end of file diff --git a/app/Http/Controllers/Admin/System.php b/app/Http/Controllers/Admin/System.php index e0f1b856..0c8dc75a 100644 --- a/app/Http/Controllers/Admin/System.php +++ b/app/Http/Controllers/Admin/System.php @@ -1,2 +1,2 @@ has($spbc4c78)) { \App\System::_set($spbc4c78, $spe5a184->post($spbc4c78)); } } } private function setMoney(Request $spe5a184, $sp5e4109) { foreach ($sp5e4109 as $spbc4c78) { if ($spe5a184->has($spbc4c78)) { \App\System::_set($spbc4c78, (int) round($spe5a184->post($spbc4c78) * 100)); } } } private function setInt(Request $spe5a184, $sp5e4109) { foreach ($sp5e4109 as $spbc4c78) { if ($spe5a184->has($spbc4c78)) { \App\System::_set($spbc4c78, (int) $spe5a184->post($spbc4c78)); } } } function setItem(Request $spe5a184) { $spbc4c78 = $spe5a184->post('name'); $spb17cea = $spe5a184->post('value'); if (!$spbc4c78 || !$spb17cea) { return Response::forbidden(); } \App\System::_set($spbc4c78, $spb17cea); return Response::success(); } function info(Request $spe5a184) { $sp498148 = array('app_name', 'app_title', 'app_url', 'app_url_api', 'keywords', 'description', 'shop_ann', 'shop_ann_pop', 'shop_qq', 'company', 'js_tj', 'js_kf'); $spd19c16 = array('shop_inventory'); if ($spe5a184->isMethod('GET')) { $sp474860 = array(); foreach ($sp498148 as $spbc4c78) { $sp474860[$spbc4c78] = \App\System::_get($spbc4c78); } foreach ($spd19c16 as $spbc4c78) { $sp474860[$spbc4c78] = (int) \App\System::_get($spbc4c78); } return Response::success($sp474860); } $sp81d92a = array('app_url' => Helper::format_url($_POST['app_url']), 'app_url_api' => Helper::format_url($_POST['app_url_api'])); $spe5a184->merge($sp81d92a); $this->set($spe5a184, $sp498148); $this->setInt($spe5a184, $spd19c16); return Response::success(); } function theme(Request $spe5a184) { if ($spe5a184->isMethod('GET')) { \App\ShopTheme::freshList(); return Response::success(array('themes' => \App\ShopTheme::get(), 'default' => \App\ShopTheme::defaultTheme()->name)); } $sp51da15 = \App\ShopTheme::whereName($spe5a184->post('shop_theme'))->firstOrFail(); \App\System::_set('shop_theme_default', $sp51da15->name); $sp51da15->config = @json_decode($spe5a184->post('theme_config')) ?? array(); $sp51da15->saveOrFail(); return Response::success(); } function order(Request $spe5a184) { $sp5e4109 = array('order_query_password_open', 'order_query_day', 'order_clean_unpay_open', 'order_clean_unpay_day'); if ($spe5a184->isMethod('GET')) { $sp474860 = array(); foreach ($sp5e4109 as $spbc4c78) { $sp474860[$spbc4c78] = (int) \App\System::_get($spbc4c78); } return Response::success($sp474860); } $this->setInt($spe5a184, $sp5e4109); return Response::success(); } function vcode(Request $spe5a184) { $sp498148 = array('vcode_driver', 'vcode_geetest_id', 'vcode_geetest_key'); $spd19c16 = array('vcode_login_admin', 'vcode_shop_buy', 'vcode_shop_search'); if ($spe5a184->isMethod('GET')) { $sp474860 = array(); foreach ($sp498148 as $spbc4c78) { $sp474860[$spbc4c78] = \App\System::_get($spbc4c78); } foreach ($spd19c16 as $spbc4c78) { $sp474860[$spbc4c78] = (int) \App\System::_get($spbc4c78); } return Response::success($sp474860); } $this->set($spe5a184, $sp498148); $this->setInt($spe5a184, $spd19c16); return Response::success(); } function email(Request $spe5a184) { $sp498148 = array('mail_driver', 'mail_smtp_host', 'mail_smtp_port', 'mail_smtp_username', 'mail_smtp_password', 'mail_smtp_from_address', 'mail_smtp_from_name', 'mail_smtp_encryption', 'sendcloud_user', 'sendcloud_key'); $spd19c16 = array('mail_send_order', 'mail_send_order_use_contact'); if ($spe5a184->isMethod('GET')) { $sp474860 = array(); foreach ($sp498148 as $spbc4c78) { $sp474860[$spbc4c78] = \App\System::_get($spbc4c78); } foreach ($spd19c16 as $spbc4c78) { $sp474860[$spbc4c78] = (int) \App\System::_get($spbc4c78); } return Response::success($sp474860); } $this->set($spe5a184, $sp498148); $this->setInt($spe5a184, $spd19c16); return Response::success(); } function sms(Request $spe5a184) { $sp498148 = array('sms_api_id', 'sms_api_key'); $spd19c16 = array('sms_send_order', 'sms_price'); if ($spe5a184->isMethod('GET')) { $sp474860 = array(); foreach ($sp498148 as $spbc4c78) { $sp474860[$spbc4c78] = \App\System::_get($spbc4c78); } foreach ($spd19c16 as $spbc4c78) { $sp474860[$spbc4c78] = (int) \App\System::_get($spbc4c78); } return Response::success($sp474860); } $this->set($spe5a184, $sp498148); $this->setInt($spe5a184, $spd19c16); return Response::success(); } function storage(Request $spe5a184) { $sp498148 = array('storage_driver', 'storage_s3_access_key', 'storage_s3_secret_key', 'storage_s3_region', 'storage_s3_bucket', 'storage_oss_access_key', 'storage_oss_secret_key', 'storage_oss_bucket', 'storage_oss_endpoint', 'storage_oss_cdn_domain', 'storage_qiniu_domains_default', 'storage_qiniu_domains_https', 'storage_qiniu_access_key', 'storage_qiniu_secret_key', 'storage_qiniu_bucket', 'storage_qiniu_notify_url'); $spd19c16 = array('storage_oss_is_ssl', 'storage_oss_is_cname'); if ($spe5a184->isMethod('GET')) { $sp474860 = array(); foreach ($sp498148 as $spbc4c78) { $sp474860[$spbc4c78] = \App\System::_get($spbc4c78); } foreach ($spd19c16 as $spbc4c78) { $sp474860[$spbc4c78] = (int) \App\System::_get($spbc4c78); } return Response::success($sp474860); } $this->set($spe5a184, $sp498148); $this->set($spe5a184, $spd19c16); return Response::success(); } function emailTest(Request $spe5a184) { $this->validate($spe5a184, array('to' => 'required')); $spcc830d = $spe5a184->post('to'); try { $spa64ee0 = Mail::to($spcc830d)->send(new \App\Mail\Test()); return Response::success($spa64ee0); } catch (\Throwable $spd118f7) { \App\Library\LogHelper::setLogFile('mail'); \Log::error('Mail Test Exception:' . $spd118f7->getMessage()); return Response::fail($spd118f7->getMessage(), $spd118f7); } } function orderClean(Request $spe5a184) { $this->validate($spe5a184, array('day' => 'required|integer|min:1')); $speb0111 = (int) $spe5a184->post('day'); \App\Order::where('status', \App\Order::STATUS_UNPAY)->where('created_at', '<', (new \Carbon\Carbon())->addDays(-$speb0111))->delete(); return Response::success(); } function deleteOrders(Request $spe5a184) { $this->validate($spe5a184, array('date' => 'required|date_format:Y-m-d')); $spf2f13b = $spe5a184->input('date'); \App\Order::where('created_at', '<', $spf2f13b)->delete(); return Response::success(); } function deleteFundRecords(Request $spe5a184) { $this->validate($spe5a184, array('date' => 'required|date_format:Y-m-d')); $spf2f13b = $spe5a184->input('date'); \App\FundRecord::where('created_at', '<', $spf2f13b)->delete(); \App\User::where('m_paid', '>', 0)->update(array('m_all' => DB::raw('m_all-m_paid'), 'm_paid' => 0)); return Response::success(); } function deleteLogs(Request $spe5a184) { $this->validate($spe5a184, array('date' => 'required|date_format:Y-m-d')); $spf2f13b = $spe5a184->input('date'); \App\Log::where('created_at', '<', $spf2f13b)->delete(); return Response::success(); } } \ No newline at end of file +namespace App\Http\Controllers\Admin; use App\Library\Helper; use App\Library\Response; use Illuminate\Http\Request; use App\Http\Controllers\Controller; use Illuminate\Support\Facades\DB; use Illuminate\Support\Facades\Mail; class System extends Controller { private function set(Request $sp517903, $sp84deb1) { foreach ($sp84deb1 as $sp832442) { if ($sp517903->has($sp832442)) { \App\System::_set($sp832442, $sp517903->post($sp832442)); } } } private function setMoney(Request $sp517903, $sp84deb1) { foreach ($sp84deb1 as $sp832442) { if ($sp517903->has($sp832442)) { \App\System::_set($sp832442, (int) round($sp517903->post($sp832442) * 100)); } } } private function setInt(Request $sp517903, $sp84deb1) { foreach ($sp84deb1 as $sp832442) { if ($sp517903->has($sp832442)) { \App\System::_set($sp832442, (int) $sp517903->post($sp832442)); } } } function setItem(Request $sp517903) { $sp832442 = $sp517903->post('name'); $spbf479d = $sp517903->post('value'); if (!$sp832442 || !$spbf479d) { return Response::forbidden(); } \App\System::_set($sp832442, $spbf479d); return Response::success(); } function info(Request $sp517903) { $sp277991 = array('app_name', 'app_title', 'app_url', 'app_url_api', 'keywords', 'description', 'shop_ann', 'shop_ann_pop', 'shop_qq', 'company', 'js_tj', 'js_kf'); $spdb2fad = array('shop_inventory'); if ($sp517903->isMethod('GET')) { $sp1c6547 = array(); foreach ($sp277991 as $sp832442) { $sp1c6547[$sp832442] = \App\System::_get($sp832442); } foreach ($spdb2fad as $sp832442) { $sp1c6547[$sp832442] = (int) \App\System::_get($sp832442); } return Response::success($sp1c6547); } $sp069c22 = array('app_url' => Helper::format_url($_POST['app_url']), 'app_url_api' => Helper::format_url($_POST['app_url_api'])); $sp517903->merge($sp069c22); $this->set($sp517903, $sp277991); $this->setInt($sp517903, $spdb2fad); return Response::success(); } function theme(Request $sp517903) { if ($sp517903->isMethod('GET')) { \App\ShopTheme::freshList(); return Response::success(array('themes' => \App\ShopTheme::get(), 'default' => \App\ShopTheme::defaultTheme()->name)); } $sp860574 = \App\ShopTheme::whereName($sp517903->post('shop_theme'))->firstOrFail(); \App\System::_set('shop_theme_default', $sp860574->name); $sp860574->config = @json_decode($sp517903->post('theme_config')) ?? array(); $sp860574->saveOrFail(); return Response::success(); } function order(Request $sp517903) { $sp84deb1 = array('order_query_password_open', 'order_query_day', 'order_clean_unpay_open', 'order_clean_unpay_day'); if ($sp517903->isMethod('GET')) { $sp1c6547 = array(); foreach ($sp84deb1 as $sp832442) { $sp1c6547[$sp832442] = (int) \App\System::_get($sp832442); } return Response::success($sp1c6547); } $this->setInt($sp517903, $sp84deb1); return Response::success(); } function vcode(Request $sp517903) { $sp277991 = array('vcode_driver', 'vcode_geetest_id', 'vcode_geetest_key'); $spdb2fad = array('vcode_login_admin', 'vcode_shop_buy', 'vcode_shop_search'); if ($sp517903->isMethod('GET')) { $sp1c6547 = array(); foreach ($sp277991 as $sp832442) { $sp1c6547[$sp832442] = \App\System::_get($sp832442); } foreach ($spdb2fad as $sp832442) { $sp1c6547[$sp832442] = (int) \App\System::_get($sp832442); } return Response::success($sp1c6547); } $this->set($sp517903, $sp277991); $this->setInt($sp517903, $spdb2fad); return Response::success(); } function email(Request $sp517903) { $sp277991 = array('mail_driver', 'mail_smtp_host', 'mail_smtp_port', 'mail_smtp_username', 'mail_smtp_password', 'mail_smtp_from_address', 'mail_smtp_from_name', 'mail_smtp_encryption', 'sendcloud_user', 'sendcloud_key'); $spdb2fad = array('mail_send_order', 'mail_send_order_use_contact'); if ($sp517903->isMethod('GET')) { $sp1c6547 = array(); foreach ($sp277991 as $sp832442) { $sp1c6547[$sp832442] = \App\System::_get($sp832442); } foreach ($spdb2fad as $sp832442) { $sp1c6547[$sp832442] = (int) \App\System::_get($sp832442); } return Response::success($sp1c6547); } $this->set($sp517903, $sp277991); $this->setInt($sp517903, $spdb2fad); return Response::success(); } function sms(Request $sp517903) { $sp277991 = array('sms_api_id', 'sms_api_key'); $spdb2fad = array('sms_send_order', 'sms_price'); if ($sp517903->isMethod('GET')) { $sp1c6547 = array(); foreach ($sp277991 as $sp832442) { $sp1c6547[$sp832442] = \App\System::_get($sp832442); } foreach ($spdb2fad as $sp832442) { $sp1c6547[$sp832442] = (int) \App\System::_get($sp832442); } return Response::success($sp1c6547); } $this->set($sp517903, $sp277991); $this->setInt($sp517903, $spdb2fad); return Response::success(); } function storage(Request $sp517903) { $sp277991 = array('storage_driver', 'storage_s3_access_key', 'storage_s3_secret_key', 'storage_s3_region', 'storage_s3_bucket', 'storage_oss_access_key', 'storage_oss_secret_key', 'storage_oss_bucket', 'storage_oss_endpoint', 'storage_oss_cdn_domain', 'storage_qiniu_domains_default', 'storage_qiniu_domains_https', 'storage_qiniu_access_key', 'storage_qiniu_secret_key', 'storage_qiniu_bucket', 'storage_qiniu_notify_url'); $spdb2fad = array('storage_oss_is_ssl', 'storage_oss_is_cname'); if ($sp517903->isMethod('GET')) { $sp1c6547 = array(); foreach ($sp277991 as $sp832442) { $sp1c6547[$sp832442] = \App\System::_get($sp832442); } foreach ($spdb2fad as $sp832442) { $sp1c6547[$sp832442] = (int) \App\System::_get($sp832442); } return Response::success($sp1c6547); } $this->set($sp517903, $sp277991); $this->set($sp517903, $spdb2fad); return Response::success(); } function emailTest(Request $sp517903) { $this->validate($sp517903, array('to' => 'required')); $sp968413 = $sp517903->post('to'); try { $spd9807c = Mail::to($sp968413)->send(new \App\Mail\Test()); return Response::success($spd9807c); } catch (\Throwable $sp0b065e) { \App\Library\LogHelper::setLogFile('mail'); \Log::error('Mail Test Exception:' . $sp0b065e->getMessage()); return Response::fail($sp0b065e->getMessage(), $sp0b065e); } } function orderClean(Request $sp517903) { $this->validate($sp517903, array('day' => 'required|integer|min:1')); $sp3ac394 = (int) $sp517903->post('day'); \App\Order::where('status', \App\Order::STATUS_UNPAY)->where('created_at', '<', (new \Carbon\Carbon())->addDays(-$sp3ac394))->delete(); return Response::success(); } function deleteOrders(Request $sp517903) { $this->validate($sp517903, array('date' => 'required|date_format:Y-m-d')); $spea1257 = $sp517903->input('date'); \App\Order::where('created_at', '<', $spea1257)->delete(); return Response::success(); } function deleteFundRecords(Request $sp517903) { $this->validate($sp517903, array('date' => 'required|date_format:Y-m-d')); $spea1257 = $sp517903->input('date'); \App\FundRecord::where('created_at', '<', $spea1257)->delete(); \App\User::where('m_paid', '>', 0)->update(array('m_all' => DB::raw('m_all-m_paid'), 'm_paid' => 0)); return Response::success(); } function deleteLogs(Request $sp517903) { $this->validate($sp517903, array('date' => 'required|date_format:Y-m-d')); $spea1257 = $sp517903->input('date'); \App\Log::where('created_at', '<', $spea1257)->delete(); return Response::success(); } } \ No newline at end of file diff --git a/app/Http/Controllers/Auth/LoginController.php b/app/Http/Controllers/Auth/LoginController.php index b5f5c51d..e4716a89 100644 --- a/app/Http/Controllers/Auth/LoginController.php +++ b/app/Http/Controllers/Auth/LoginController.php @@ -1,2 +1,2 @@ validate($spe5a184, array('email' => 'required|email', 'password' => 'required|string')); if (System::_getInt('vcode_login_admin') === 1) { $this->validateCaptcha($spe5a184); } if ($this->hasTooManyLoginAttempts($spe5a184)) { $this->fireLockoutEvent($spe5a184); $sp2b9d54 = $this->limiter()->availableIn($this->throttleKey($spe5a184)); return response(array('message' => trans('auth.throttle', array('seconds' => $sp2b9d54))), Response::HTTP_BAD_REQUEST); } if ($sp63ab26 = Auth::attempt($spe5a184->only('email', 'password'))) { $sp766bcc = Auth::getUser(); $sp17de72 = Helper::getIP() ?? $spe5a184->ip(); $sp766bcc->logs()->create(array('action' => \App\Log::ACTION_LOGIN, 'ip' => $sp17de72, 'address' => (new QQWry())->getLocation($sp17de72))); return response($this->getUserInfo()->getContent(), Response::HTTP_CREATED, array('Authorization' => 'Bearer ' . $sp63ab26)); } LOGIN_FAILED: $this->incrementLoginAttempts($spe5a184); return response(array('message' => trans('auth.failed')), Response::HTTP_BAD_REQUEST); } public function getUserInfo() { $sp766bcc = Auth::getUser(); $sp766bcc->addHidden(array('created_at', 'updated_at')); $sp766bcc->append(array('last_login_at')); $sp766bcc->setAttribute('shop_name', config('app.name')); $spca52a4 = array(); $spca52a4['user'] = $sp766bcc; return response($spca52a4); } public function logout() { try { @Auth::logout(); } catch (\Throwable $spd118f7) { } return response(array()); } } \ No newline at end of file +namespace App\Http\Controllers\Auth; use App\Http\Controllers\Controller; use App\Library\Helper; use App\Library\QQWry\QQWry; use App\Library\WeChat; use App\System; use Illuminate\Http\Request; use Illuminate\Foundation\Auth\ThrottlesLogins; use Illuminate\Http\Response; use Illuminate\Support\Facades\Auth; class LoginController extends Controller { use ThrottlesLogins; protected function username() { return 'email'; } public function login(Request $sp517903) { $this->validate($sp517903, array('email' => 'required|email', 'password' => 'required|string')); if (System::_getInt('vcode_login_admin') === 1) { $this->validateCaptcha($sp517903); } if ($this->hasTooManyLoginAttempts($sp517903)) { $this->fireLockoutEvent($sp517903); $spd37bf4 = $this->limiter()->availableIn($this->throttleKey($sp517903)); return response(array('message' => trans('auth.throttle', array('seconds' => $spd37bf4))), Response::HTTP_BAD_REQUEST); } if ($sp5f3012 = Auth::attempt($sp517903->only('email', 'password'))) { $sp3db17d = Auth::getUser(); $spdea256 = Helper::getIP() ?? $sp517903->ip(); $sp3db17d->logs()->create(array('action' => \App\Log::ACTION_LOGIN, 'ip' => $spdea256, 'address' => (new QQWry())->getLocation($spdea256))); return response($this->getUserInfo()->getContent(), Response::HTTP_CREATED, array('Authorization' => 'Bearer ' . $sp5f3012)); } LOGIN_FAILED: $this->incrementLoginAttempts($sp517903); return response(array('message' => trans('auth.failed')), Response::HTTP_BAD_REQUEST); } public function getUserInfo() { $sp3db17d = Auth::getUser(); $sp3db17d->addHidden(array('created_at', 'updated_at')); $sp3db17d->append(array('last_login_at')); $sp3db17d->setAttribute('shop_name', config('app.name')); $sp0223d2 = array(); $sp0223d2['user'] = $sp3db17d; return response($sp0223d2); } public function logout() { try { @Auth::logout(); } catch (\Throwable $sp0b065e) { } return response(array()); } } \ No newline at end of file diff --git a/app/Http/Controllers/Auth/ResetPasswordController.php b/app/Http/Controllers/Auth/ResetPasswordController.php index 7651bfe7..cd733561 100644 --- a/app/Http/Controllers/Auth/ResetPasswordController.php +++ b/app/Http/Controllers/Auth/ResetPasswordController.php @@ -1,2 +1,2 @@ validate($spe5a184, array('token' => 'required', 'email' => 'required|email', 'password' => 'required|confirmed|min:6')); $spca52a4 = Password::broker()->reset($spe5a184->only('email', 'password', 'password_confirmation', 'token'), function ($sp766bcc, $spc3374e) { $this->resetPassword($sp766bcc, $spc3374e); }); return $spca52a4 == Password::PASSWORD_RESET ? response(array()) : response(array('message' => trans($spca52a4)), 400); } public function change(Request $spe5a184) { $this->validate($spe5a184, array('old' => 'required|string', 'password' => 'required|string|min:6|max:32|confirmed')); $sp766bcc = Auth::user(); if (!Hash::check($spe5a184->post('old'), $sp766bcc->password)) { return response(array('message' => '旧密码错误,请检查'), Response::HTTP_BAD_REQUEST); } $sp63ab26 = $this->resetPassword($sp766bcc, $spe5a184->post('password')); return response(array(), 200, array('Authorization' => 'Bearer ' . $sp63ab26)); } public static function resetPassword($sp766bcc, $spc3374e, $sp387599 = true) { $sp766bcc->password = Hash::make($spc3374e); $sp766bcc->setRememberToken(time()); $sp766bcc->saveOrFail(); event(new PasswordReset($sp766bcc)); if ($sp387599) { return Auth::login($sp766bcc); } else { return true; } } } \ No newline at end of file +namespace App\Http\Controllers\Auth; use App\Http\Controllers\Controller; use Illuminate\Auth\Events\PasswordReset; use Illuminate\Http\Request; use Illuminate\Http\Response; use Illuminate\Support\Facades\Hash; use Illuminate\Support\Facades\Auth; use Illuminate\Support\Facades\Password; class ResetPasswordController extends Controller { public function reset(Request $sp517903) { $this->validate($sp517903, array('token' => 'required', 'email' => 'required|email', 'password' => 'required|confirmed|min:6')); $sp0223d2 = Password::broker()->reset($sp517903->only('email', 'password', 'password_confirmation', 'token'), function ($sp3db17d, $spe46211) { $this->resetPassword($sp3db17d, $spe46211); }); return $sp0223d2 == Password::PASSWORD_RESET ? response(array()) : response(array('message' => trans($sp0223d2)), 400); } public function change(Request $sp517903) { $this->validate($sp517903, array('old' => 'required|string', 'password' => 'required|string|min:6|max:32|confirmed')); $sp3db17d = Auth::user(); if (!Hash::check($sp517903->post('old'), $sp3db17d->password)) { return response(array('message' => '旧密码错误,请检查'), Response::HTTP_BAD_REQUEST); } $sp5f3012 = $this->resetPassword($sp3db17d, $sp517903->post('password')); return response(array(), 200, array('Authorization' => 'Bearer ' . $sp5f3012)); } public static function resetPassword($sp3db17d, $spe46211, $sp85da8d = true) { $sp3db17d->password = Hash::make($spe46211); $sp3db17d->setRememberToken(time()); $sp3db17d->saveOrFail(); event(new PasswordReset($sp3db17d)); if ($sp85da8d) { return Auth::login($sp3db17d); } else { return true; } } } \ No newline at end of file diff --git a/app/Http/Controllers/Controller.php b/app/Http/Controllers/Controller.php index 797ff880..70deec0c 100644 --- a/app/Http/Controllers/Controller.php +++ b/app/Http/Controllers/Controller.php @@ -1,2 +1,2 @@ validate($spe5a184, array('captcha.key' => 'required|string', 'captcha.code' => 'required|captcha_api:' . $spe5a184->input('captcha.key'))); } elseif ($spfd2d0c === 'geetest') { $this->validate($spe5a184, array('captcha.a' => 'required|string', 'captcha.b' => 'required|string', 'captcha.c' => 'required|string', 'captcha.d' => 'required|string')); if (!Geetest\API::verify($spe5a184->input('captcha.a'), $spe5a184->input('captcha.b'), $spe5a184->input('captcha.c'), $spe5a184->input('captcha.d'))) { throw \Illuminate\Validation\ValidationException::withMessages(array('captcha' => array(trans('validation.captcha')))); } } elseif ($spfd2d0c === 'recaptcha') { $this->validate($spe5a184, array('captcha.t' => 'required|string')); } } function authQuery(Request $spe5a184, $spa8eadd, $sp32f293 = 'user_id', $sp678b2b = 'user_id') { return $spa8eadd::where($sp32f293, \Auth::id()); } protected function getUserId(Request $spe5a184, $sp678b2b = 'user_id') { return \Auth::id(); } protected function getUserIdOrFail(Request $spe5a184, $sp678b2b = 'user_id') { $sp7aa9af = self::getUserId($spe5a184, $sp678b2b); if ($sp7aa9af) { return $sp7aa9af; } else { throw new \Exception('参数缺少 ' . $sp678b2b); } } protected function getUser(Request $spe5a184) { return \Auth::getUser(); } protected function checkIsInMaintain() { if (System::_getInt('maintain') === 1) { $spe4b437 = System::_get('maintain_info'); echo view('message', array('title' => '维护中', 'message' => $spe4b437)); die; } } protected function msg($spa7c069, $sp6bcf3a = null, $sp91143b = null) { return view('message', array('message' => $spa7c069, 'title' => $sp6bcf3a, 'exception' => $sp91143b)); } } \ No newline at end of file +namespace App\Http\Controllers; use App\System; use App\Library\Geetest; use Illuminate\Foundation\Bus\DispatchesJobs; use Illuminate\Http\Response; use Illuminate\Routing\Controller as BaseController; use Illuminate\Foundation\Validation\ValidatesRequests; use Illuminate\Foundation\Auth\Access\AuthorizesRequests; use Illuminate\Http\Request; use Illuminate\Support\Facades\Auth; class Controller extends BaseController { use AuthorizesRequests, DispatchesJobs, ValidatesRequests; public function getCaptcha() { $sped6dfb = System::_get('vcode_driver'); if ($sped6dfb === 'code') { return response(array()); } elseif ($sped6dfb === 'geetest') { return response(Geetest\API::get()); } elseif ($sped6dfb === 'recaptcha') { } return response(array(), Response::HTTP_NOT_IMPLEMENTED); } function validateCaptcha(Request $sp517903) { $sped6dfb = System::_get('vcode_driver'); if ($sped6dfb === 'code') { $this->validate($sp517903, array('captcha.key' => 'required|string', 'captcha.code' => 'required|captcha_api:' . $sp517903->input('captcha.key'))); } elseif ($sped6dfb === 'geetest') { $this->validate($sp517903, array('captcha.a' => 'required|string', 'captcha.b' => 'required|string', 'captcha.c' => 'required|string', 'captcha.d' => 'required|string')); if (!Geetest\API::verify($sp517903->input('captcha.a'), $sp517903->input('captcha.b'), $sp517903->input('captcha.c'), $sp517903->input('captcha.d'))) { throw \Illuminate\Validation\ValidationException::withMessages(array('captcha' => array(trans('validation.captcha')))); } } elseif ($sped6dfb === 'recaptcha') { $this->validate($sp517903, array('captcha.t' => 'required|string')); } } function authQuery(Request $sp517903, $sp0e8bb5, $spb97c4b = 'user_id', $sp3d26d9 = 'user_id') { return $sp0e8bb5::where($spb97c4b, \Auth::id()); } protected function getUserId(Request $sp517903, $sp3d26d9 = 'user_id') { return \Auth::id(); } protected function getUserIdOrFail(Request $sp517903, $sp3d26d9 = 'user_id') { $spacf00d = self::getUserId($sp517903, $sp3d26d9); if ($spacf00d) { return $spacf00d; } else { throw new \Exception('参数缺少 ' . $sp3d26d9); } } protected function getUser(Request $sp517903) { return \Auth::getUser(); } protected function checkIsInMaintain() { if (System::_getInt('maintain') === 1) { $sp42fa43 = System::_get('maintain_info'); echo view('message', array('title' => '维护中', 'message' => $sp42fa43)); die; } } protected function msg($sp5b1bec, $sp400fe5 = null, $sp24c601 = null) { return view('message', array('message' => $sp5b1bec, 'title' => $sp400fe5, 'exception' => $sp24c601)); } } \ No newline at end of file diff --git a/app/Http/Controllers/DevController.php b/app/Http/Controllers/DevController.php index 258d3642..70d50fa8 100644 --- a/app/Http/Controllers/DevController.php +++ b/app/Http/Controllers/DevController.php @@ -1,2 +1,2 @@ R
'; return true; } else { echo $sp6c438a . ' ...... R
'; return false; } } else { if (file_exists($sp6c438a)) { return is_readable($sp6c438a); } } echo $sp6c438a . ' ...... 文件不存在
'; return false; } private function check_writable_r($sp6c438a) { if (is_dir($sp6c438a)) { if (is_writable($sp6c438a)) { $spb81645 = scandir($sp6c438a); foreach ($spb81645 as $sp25c5a2) { if ($sp25c5a2 != '.' && $sp25c5a2 != '..') { if (!self::check_writable_r($sp6c438a . '/' . $sp25c5a2)) { return false; } else { continue; } } } echo $sp6c438a . ' ...... W
'; return true; } else { echo $sp6c438a . ' ...... W
'; return false; } } else { if (file_exists($sp6c438a)) { return is_writable($sp6c438a); } } echo $sp6c438a . ' ...... 文件不存在
'; return false; } private function checkPathPermission($spc6a7c6) { self::check_readable_r($spc6a7c6); self::check_writable_r($spc6a7c6); } public function install() { $sp947e12 = array(); @ob_start(); self::checkPathPermission(base_path('storage')); self::checkPathPermission(base_path('bootstrap/cache')); $sp947e12['permission'] = @ob_get_clean(); return view('install', array('var' => $sp947e12)); } public function test(Request $spe5a184) { } } \ No newline at end of file +namespace App\Http\Controllers; use App\System; use Illuminate\Http\Request; use Illuminate\Support\Facades\Log; use Illuminate\Support\Facades\Mail; class DevController extends Controller { private function check_readable_r($spbf6ca5) { if (is_dir($spbf6ca5)) { if (is_readable($spbf6ca5)) { $spe4a5be = scandir($spbf6ca5); foreach ($spe4a5be as $spa75be6) { if ($spa75be6 != '.' && $spa75be6 != '..') { if (!self::check_readable_r($spbf6ca5 . '/' . $spa75be6)) { return false; } else { continue; } } } echo $spbf6ca5 . ' ...... R
'; return true; } else { echo $spbf6ca5 . ' ...... R
'; return false; } } else { if (file_exists($spbf6ca5)) { return is_readable($spbf6ca5); } } echo $spbf6ca5 . ' ...... 文件不存在
'; return false; } private function check_writable_r($spbf6ca5) { if (is_dir($spbf6ca5)) { if (is_writable($spbf6ca5)) { $spe4a5be = scandir($spbf6ca5); foreach ($spe4a5be as $spa75be6) { if ($spa75be6 != '.' && $spa75be6 != '..') { if (!self::check_writable_r($spbf6ca5 . '/' . $spa75be6)) { return false; } else { continue; } } } echo $spbf6ca5 . ' ...... W
'; return true; } else { echo $spbf6ca5 . ' ...... W
'; return false; } } else { if (file_exists($spbf6ca5)) { return is_writable($spbf6ca5); } } echo $spbf6ca5 . ' ...... 文件不存在
'; return false; } private function checkPathPermission($sp7c9413) { self::check_readable_r($sp7c9413); self::check_writable_r($sp7c9413); } public function install() { $sp9c794a = array(); @ob_start(); self::checkPathPermission(base_path('storage')); self::checkPathPermission(base_path('bootstrap/cache')); $sp9c794a['permission'] = @ob_get_clean(); return view('install', array('var' => $sp9c794a)); } public function test(Request $sp517903) { } } \ No newline at end of file diff --git a/app/Http/Controllers/HomeController.php b/app/Http/Controllers/HomeController.php index 2b348a64..ba3adc9c 100644 --- a/app/Http/Controllers/HomeController.php +++ b/app/Http/Controllers/HomeController.php @@ -1,6 +1,6 @@ config('app.url'), 'company' => config('app.company'), 'name' => config('app.name'), 'logo' => config('app.logo'), 'functions' => array()); if (System::_getInt('product_manual')) { $sp474860['functions'][] = 'product_manual'; } if (System::_getInt('mail_send_order')) { $sp474860['functions'][] = 'mail_send_order'; if (System::_getInt('mail_send_order_use_contact')) { $sp474860['functions'][] = 'mail_send_order_use_contact'; } } if (System::_getInt('order_query_password_open')) { $sp474860['functions'][] = 'order_query_password'; } if (System::_getInt('sms_send_order')) { $sp474860['functions'][] = 'sms_send_order'; $sp474860['sms_send_order'] = array('sms_price' => System::_getInt('sms_price')); } $sp474860['captcha'] = array('driver' => System::_get('vcode_driver'), 'config' => array(), 'scene' => array('shop' => array('buy' => System::_getInt('vcode_shop_buy'), 'search' => System::_getInt('vcode_shop_search')))); $sp44885a = Cookie::get('customer'); $sp35923d = Cookie::make('customer', strlen($sp44885a) !== 32 ? md5(str_random(16)) : $sp44885a, 43200, null, null, false, false); $sp51da15 = null; if (isset($_GET['theme'])) { $sp51da15 = \App\ShopTheme::whereName($_GET['theme'])->first(); } if ($sp766bcc) { $sp474860['shop'] = array('name' => config('app.name'), 'qq' => System::_get('shop_qq'), 'ann' => System::_get('shop_ann'), 'ann_pop' => System::_get('shop_ann_pop'), 'inventory' => System::_getInt('shop_inventory')); $sp1ad2c6 = false; if ($spb395ca) { $spf6286b->setVisible(array('id', 'name', 'password_open')); if ($spf6286b->password_open) { $spf6286b->setAttribute('password', $spf6286b->getTmpPassword()); $spf6286b->addVisible(array('password')); } $spb395ca->setForShop($sp766bcc); $sp474860['categories'] = array($spf6286b); $sp474860['product'] = $spb395ca; $spbc4c78 = $spb395ca->name . ' - ' . $sp474860['name']; $sp1fa267 = $spb395ca->description; if (@$sp1fa267[0] === '{') { $sp333874 = array(); preg_match_all('/"insert":"(.+?)"/', $sp1fa267, $sp333874); $sp1fa267 = str_replace('\\n', ' ', @join(' ', $sp333874[1])); } } elseif ($spf6286b) { $spf6286b->setVisible(array('id', 'name', 'password_open')); $sp474860['categories'] = array($spf6286b); $sp474860['product'] = null; $spbc4c78 = $spf6286b->name . ' - ' . $sp474860['name']; $sp1fa267 = $spf6286b->name; } else { $spd7112d = Category::where('user_id', $sp766bcc->id)->orderBy('sort')->where('enabled', 1)->get(); foreach ($spd7112d as $spf6286b) { $spf6286b->setVisible(array('id', 'name', 'password_open')); } $sp474860['categories'] = $spd7112d; if (config('app.name') && config('app.title')) { $spbc4c78 = config('app.name') . ' - ' . config('app.title'); } else { $spbc4c78 = config('app.name') ? config('app.name') : config('app.title'); } $sp1fa267 = config('app.description'); $sp1ad2c6 = config('app.keywords'); } $sp474860['pays'] = \App\PayWay::gets($sp766bcc, function ($spa8a4ff) { $spa8a4ff->where('type', \App\PayWay::TYPE_SHOP)->whereRaw('enabled&' . (Helper::is_mobile() ? \App\PayWay::ENABLED_MOBILE : \App\PayWay::ENABLED_PC) . '!=0'); }); if (!$sp51da15) { $sp51da15 = \App\ShopTheme::defaultTheme(); } $sp474860['theme'] = $sp766bcc->theme_config && isset($sp766bcc->theme_config[$sp51da15->name]) ? $sp766bcc->theme_config[$sp51da15->name] : $sp51da15->config; $sp1ad2c6 = $sp1ad2c6 ? $sp1ad2c6 : preg_replace('/[、,;。!?]/', ', ', $spbc4c78); } else { throw new \Exception('不可能到这'); } if (isset($sp474860['theme']['background']) && $sp474860['theme']['background'] === '内置1') { $sp474860['theme']['background'] = Helper::b1_rand_background(); } if ($sp766bcc && $spb395ca === null) { if (@$sp474860['theme']['list_type'] === 'list') { foreach ($sp474860['categories'] as $sp103198) { if (!$sp103198->password_open) { $sp103198->getProductsForShop(); } } } else { if (count($sp474860['categories']) === 1) { $sp103198 = $sp474860['categories'][0]; if (!$sp103198->password_open) { $sp103198->getProductsForShop(); } } } } return response()->view('shop_theme.' . $sp51da15->name . '.index', array('name' => $spbc4c78, 'title' => config('app.title'), 'keywords' => $sp1ad2c6, 'description' => $sp1fa267, 'js_tj' => System::_get('js_tj'), 'js_kf' => System::_get('js_kf'), 'config' => $sp474860))->cookie($sp35923d); } public function shop_default(Request $spe5a184) { $this->checkIsInMaintain(); $sp6054a0 = $spe5a184->get('tab', ''); return response()->redirectTo('/?theme=Material#/record?tab=' . $sp6054a0); } private function _shop_404() { $this->checkIsInMaintain(); return view('message', array('title' => '404 NotFound', 'message' => '该链接不存在
-查询订单')); } public function shop_category($sp6ccc2e) { $this->checkIsInMaintain(); $spf6286b = Category::whereId(Helper::id_decode($sp6ccc2e, Helper::ID_TYPE_CATEGORY))->with('user')->first(); if (!$spf6286b && is_numeric($spf6286b)) { $spf6286b = Category::whereId($sp6ccc2e)->where('created_at', '<', \Carbon\Carbon::createFromDate(2019, 1, 1))->with('user')->first(); } if (!$spf6286b) { return $this->_shop_404(); } return $this->_shop_render($spf6286b->user, $spf6286b); } public function shop_product(Request $spe5a184, $sp5e32c8) { $this->checkIsInMaintain(); $spb395ca = Product::whereId(Helper::id_decode($sp5e32c8, Helper::ID_TYPE_PRODUCT))->with(array('user', 'category'))->first(); if (!$spb395ca && is_numeric($sp5e32c8)) { $spb395ca = Product::whereId($sp5e32c8)->where('created_at', '<', \Carbon\Carbon::createFromDate(2019, 1, 1))->with(array('user', 'category'))->first(); } if (!$spb395ca || !$spb395ca->category) { return $this->_shop_404(); } if ($spb395ca->password_open && $spb395ca->password !== $spe5a184->input('p')) { return view('message', array('title' => '当前商品需要密码', 'message' => ($spe5a184->has('p') ? '密码错误,请重新输入' : '请输入商品密码') . '
+namespace App\Http\Controllers; use App\Category; use App\Library\Helper; use App\Pay; use App\Product; use App\System; use App\User; use Illuminate\Database\Eloquent\Relations\Relation; use Illuminate\Http\Request; use App\Library\Geetest; use Illuminate\Support\Facades\Auth; use Illuminate\Support\Facades\Cookie; class HomeController extends Controller { private function _shop_render($sp3db17d, $spe223d2 = null, $sp427eba = null) { $sp1c6547 = array('url' => config('app.url'), 'company' => config('app.company'), 'name' => config('app.name'), 'logo' => config('app.logo'), 'functions' => array()); if (System::_getInt('product_manual')) { $sp1c6547['functions'][] = 'product_manual'; } if (System::_getInt('mail_send_order')) { $sp1c6547['functions'][] = 'mail_send_order'; if (System::_getInt('mail_send_order_use_contact')) { $sp1c6547['functions'][] = 'mail_send_order_use_contact'; } } if (System::_getInt('order_query_password_open')) { $sp1c6547['functions'][] = 'order_query_password'; } if (System::_getInt('sms_send_order')) { $sp1c6547['functions'][] = 'sms_send_order'; $sp1c6547['sms_send_order'] = array('sms_price' => System::_getInt('sms_price')); } $sp1c6547['captcha'] = array('driver' => System::_get('vcode_driver'), 'config' => array(), 'scene' => array('shop' => array('buy' => System::_getInt('vcode_shop_buy'), 'search' => System::_getInt('vcode_shop_search')))); $sp3d6d7b = Cookie::get('customer'); $sp264383 = Cookie::make('customer', strlen($sp3d6d7b) !== 32 ? md5(str_random(16)) : $sp3d6d7b, 43200, null, null, false, false); $sp860574 = null; if (isset($_GET['theme'])) { $sp860574 = \App\ShopTheme::whereName($_GET['theme'])->first(); } if ($sp3db17d) { $sp1c6547['shop'] = array('name' => config('app.name'), 'qq' => System::_get('shop_qq'), 'ann' => System::_get('shop_ann'), 'ann_pop' => System::_get('shop_ann_pop'), 'inventory' => System::_getInt('shop_inventory')); $spcd49cf = false; if ($sp427eba) { $spe223d2->setVisible(array('id', 'name', 'password_open')); if ($spe223d2->password_open) { $spe223d2->setAttribute('password', $spe223d2->getTmpPassword()); $spe223d2->addVisible(array('password')); } $sp427eba->setForShop($sp3db17d); $sp1c6547['categories'] = array($spe223d2); $sp1c6547['product'] = $sp427eba; $sp832442 = $sp427eba->name . ' - ' . $sp1c6547['name']; $specbf72 = $sp427eba->description; if (@$specbf72[0] === '{') { $sp101746 = array(); preg_match_all('/"insert":"(.+?)"/', $specbf72, $sp101746); $specbf72 = str_replace('\\n', ' ', @join(' ', $sp101746[1])); } } elseif ($spe223d2) { $spe223d2->setVisible(array('id', 'name', 'password_open')); $sp1c6547['categories'] = array($spe223d2); $sp1c6547['product'] = null; $sp832442 = $spe223d2->name . ' - ' . $sp1c6547['name']; $specbf72 = $spe223d2->name; } else { $sp639613 = Category::where('user_id', $sp3db17d->id)->orderBy('sort')->where('enabled', 1)->get(); foreach ($sp639613 as $spe223d2) { $spe223d2->setVisible(array('id', 'name', 'password_open')); } $sp1c6547['categories'] = $sp639613; if (config('app.name') && config('app.title')) { $sp832442 = config('app.name') . ' - ' . config('app.title'); } else { $sp832442 = config('app.name') ? config('app.name') : config('app.title'); } $specbf72 = config('app.description'); $spcd49cf = config('app.keywords'); } $sp1c6547['pays'] = \App\PayWay::gets($sp3db17d, function ($sp30241a) { $sp30241a->where('type', \App\PayWay::TYPE_SHOP)->whereRaw('enabled&' . (Helper::is_mobile() ? \App\PayWay::ENABLED_MOBILE : \App\PayWay::ENABLED_PC) . '!=0'); }); if (!$sp860574) { $sp860574 = \App\ShopTheme::defaultTheme(); } $sp1c6547['theme'] = $sp3db17d->theme_config && isset($sp3db17d->theme_config[$sp860574->name]) ? $sp3db17d->theme_config[$sp860574->name] : $sp860574->config; $spcd49cf = $spcd49cf ? $spcd49cf : preg_replace('/[、,;。!?]/', ', ', $sp832442); } else { throw new \Exception('不可能到这'); } if (isset($sp1c6547['theme']['background']) && $sp1c6547['theme']['background'] === '内置1') { $sp1c6547['theme']['background'] = Helper::b1_rand_background(); } if ($sp3db17d && $sp427eba === null) { if (@$sp1c6547['theme']['list_type'] === 'list') { foreach ($sp1c6547['categories'] as $sp005ad9) { if (!$sp005ad9->password_open) { $sp005ad9->getProductsForShop(); } } } else { if (count($sp1c6547['categories']) === 1) { $sp005ad9 = $sp1c6547['categories'][0]; if (!$sp005ad9->password_open) { $sp005ad9->getProductsForShop(); } } } } return response()->view('shop_theme.' . $sp860574->name . '.index', array('name' => $sp832442, 'title' => config('app.title'), 'keywords' => $spcd49cf, 'description' => $specbf72, 'js_tj' => System::_get('js_tj'), 'js_kf' => System::_get('js_kf'), 'config' => $sp1c6547))->cookie($sp264383); } public function shop_default(Request $sp517903) { $this->checkIsInMaintain(); $sp8621ad = $sp517903->get('tab', ''); return response()->redirectTo('/?theme=Material#/record?tab=' . $sp8621ad); } private function _shop_404() { $this->checkIsInMaintain(); return view('message', array('title' => '404 NotFound', 'message' => '该链接不存在
+查询订单')); } public function shop_category($spbee05b) { $this->checkIsInMaintain(); $spe223d2 = Category::whereId(Helper::id_decode($spbee05b, Helper::ID_TYPE_CATEGORY))->with('user')->first(); if (!$spe223d2 && is_numeric($spe223d2)) { $spe223d2 = Category::whereId($spbee05b)->where('created_at', '<', \Carbon\Carbon::createFromDate(2019, 1, 1))->with('user')->first(); } if (!$spe223d2) { return $this->_shop_404(); } return $this->_shop_render($spe223d2->user, $spe223d2); } public function shop_product(Request $sp517903, $sp0d93a0) { $this->checkIsInMaintain(); $sp427eba = Product::whereId(Helper::id_decode($sp0d93a0, Helper::ID_TYPE_PRODUCT))->with(array('user', 'category'))->first(); if (!$sp427eba && is_numeric($sp0d93a0)) { $sp427eba = Product::whereId($sp0d93a0)->where('created_at', '<', \Carbon\Carbon::createFromDate(2019, 1, 1))->with(array('user', 'category'))->first(); } if (!$sp427eba || !$sp427eba->category) { return $this->_shop_404(); } if ($sp427eba->password_open && $sp427eba->password !== $sp517903->input('p')) { return view('message', array('title' => '当前商品需要密码', 'message' => ($sp517903->has('p') ? '密码错误,请重新输入' : '请输入商品密码') . '