Skip to content

Commit

Permalink
2.9
Browse files Browse the repository at this point in the history
  • Loading branch information
Tai7sy-Mac committed Jul 22, 2019
1 parent 2adfff1 commit 27669f2
Show file tree
Hide file tree
Showing 122 changed files with 253 additions and 253 deletions.
2 changes: 1 addition & 1 deletion .version
Original file line number Diff line number Diff line change
@@ -1 +1 @@
{"version":"2.9","md5":"12be8c987fc6d46370b9de555236a28d","url":"https:\/\/github.com\/Tai7sy\/card-system\/releases\/download\/2.9\/card_release.tar.gz"}
{"version":"2.9","md5":"9b0367de9ea5caf51669d612b61df9f7","url":"https:\/\/github.com\/Tai7sy\/card-system\/releases\/download\/2.9\/card_release.tar.gz"}
2 changes: 1 addition & 1 deletion app/Card.php
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
<?php
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); } public static function add_cards($spfa021e, $sp0e30a6, $sp8f5ac7, $sp7a9982, $sp62ca36, $sp518449) { DB::statement('call add_cards(?,?,?,?,?,?)', array($spfa021e, $sp0e30a6, $sp8f5ac7, $sp7a9982, $sp62ca36, (int) $sp518449)); } public static function _trash($sp5786ca) { DB::transaction(function () use($sp5786ca) { $sp654541 = clone $sp5786ca; $sp654541->selectRaw('`product_id`,SUM(`count_all`-`count_sold`) as `count_left`')->groupBy('product_id')->orderByRaw('`product_id`')->chunk(100, function ($sp2300d6) { foreach ($sp2300d6 as $sp2fe3cd) { $sp71cb0c = \App\Product::where('id', $sp2fe3cd->product_id)->lockForUpdate()->first(); if ($sp71cb0c) { $sp71cb0c->count_all -= $sp2fe3cd->count_left; $sp71cb0c->saveOrFail(); } } }); $sp5786ca->delete(); return true; }); } public static function _restore($sp5786ca) { DB::transaction(function () use($sp5786ca) { $sp654541 = clone $sp5786ca; $sp654541->selectRaw('`product_id`,SUM(`count_all`-`count_sold`) as `count_left`')->groupBy('product_id')->orderByRaw('`product_id`')->chunk(100, function ($sp2300d6) { foreach ($sp2300d6 as $sp2fe3cd) { $sp71cb0c = \App\Product::where('id', $sp2fe3cd->product_id)->lockForUpdate()->first(); if ($sp71cb0c) { $sp71cb0c->count_all += $sp2fe3cd->count_left; $sp71cb0c->saveOrFail(); } } }); $sp5786ca->restore(); return true; }); } }
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); } public static function add_cards($sp15a746, $spbb5d29, $sp4f56c1, $sp27b58d, $spa5ca46, $spc564ba) { DB::statement('call add_cards(?,?,?,?,?,?)', array($sp15a746, $spbb5d29, $sp4f56c1, $sp27b58d, $spa5ca46, (int) $spc564ba)); } public static function _trash($sp5044a7) { DB::transaction(function () use($sp5044a7) { $spee4521 = clone $sp5044a7; $spee4521->selectRaw('`product_id`,SUM(`count_all`-`count_sold`) as `count_left`')->groupBy('product_id')->orderByRaw('`product_id`')->chunk(100, function ($sp2e1960) { foreach ($sp2e1960 as $sp87990b) { $sp2cf004 = \App\Product::where('id', $sp87990b->product_id)->lockForUpdate()->first(); if ($sp2cf004) { $sp2cf004->count_all -= $sp87990b->count_left; $sp2cf004->saveOrFail(); } } }); $sp5044a7->delete(); return true; }); } public static function _restore($sp5044a7) { DB::transaction(function () use($sp5044a7) { $spee4521 = clone $sp5044a7; $spee4521->selectRaw('`product_id`,SUM(`count_all`-`count_sold`) as `count_left`')->groupBy('product_id')->orderByRaw('`product_id`')->chunk(100, function ($sp2e1960) { foreach ($sp2e1960 as $sp87990b) { $sp2cf004 = \App\Product::where('id', $sp87990b->product_id)->lockForUpdate()->first(); if ($sp2cf004) { $sp2cf004->count_all += $sp87990b->count_left; $sp2cf004->saveOrFail(); } } }); $sp5044a7->restore(); return true; }); } }
2 changes: 1 addition & 1 deletion app/Category.php
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
<?php
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() { $sp8b05f0 = Product::where('category_id', $this->id)->where('enabled', 1)->orderBy('sort')->get(); foreach ($sp8b05f0 as $sp71cb0c) { $sp71cb0c->setForShop($this->user); } $this->addVisible(array('products')); $this->setAttribute('products', $sp8b05f0); return $sp8b05f0; } }
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() { $sp7c2d5f = Product::where('category_id', $this->id)->where('enabled', 1)->orderBy('sort')->get(); foreach ($sp7c2d5f as $sp2cf004) { $sp2cf004->setForShop($this->user); } $this->addVisible(array('products')); $this->setAttribute('products', $sp7c2d5f); return $sp7c2d5f; } }
4 changes: 2 additions & 2 deletions app/Console/Commands/ResetPassword.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<?php
namespace App\Console\Commands; use Illuminate\Console\Command; class ResetPassword extends Command { protected $signature = 'reset:password {email} {password}'; protected $description = 'Reset the password of user
Usage: php artisan reset:password [email protected]'; public function __construct() { parent::__construct(); } public function handle() { $sp807378 = $this->argument('email'); if (!$sp807378) { $this->warn('please input the user\'s email
'); return false; } $spafa70b = \App\User::where('email', $sp807378)->first(); if (!$spafa70b) { $this->warn("can't find the user: {$sp807378} \nplease input the user's email\n"); return false; } $spb6833a = $this->argument('password'); $spafa70b->password = bcrypt($spb6833a); $spafa70b->save(); $this->info("the password of '{$sp807378}' has been set to {$spb6833a}\n"); return true; } }
Usage: php artisan reset:password [email protected]'; public function __construct() { parent::__construct(); } public function handle() { $sp0fa228 = $this->argument('email'); if (!$sp0fa228) { $this->warn('please input the user\'s email
'); return false; } $spbbb773 = \App\User::where('email', $sp0fa228)->first(); if (!$spbbb773) { $this->warn("can't find the user: {$sp0fa228} \nplease input the user's email\n"); return false; } $sp8f68ce = $this->argument('password'); $spbbb773->password = bcrypt($sp8f68ce); $spbbb773->save(); $this->info("the password of '{$sp0fa228}' has been set to {$sp8f68ce}\n"); return true; } }
12 changes: 6 additions & 6 deletions app/Console/Commands/Update.php
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
<?php
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($sp3db1b2, $spb701ff) { $sp8cc2df = fopen($spb701ff, 'w+'); if (!$sp8cc2df) { return false; } $sp9b0943 = curl_init(); curl_setopt($sp9b0943, CURLOPT_URL, $sp3db1b2); curl_setopt($sp9b0943, CURLOPT_FOLLOWLOCATION, true); curl_setopt($sp9b0943, CURLOPT_RETURNTRANSFER, true); curl_setopt($sp9b0943, CURLOPT_FILE, $sp8cc2df); curl_setopt($sp9b0943, CURLOPT_PROGRESSFUNCTION, function ($sp06adb8, $sp61a3e7, $spdd5ef1, $sp891c8d, $sp7de951) { if ($sp61a3e7 > 0) { echo ' download: ' . sprintf('%.2f', $spdd5ef1 / $sp61a3e7 * 100) . '%'; } }); curl_setopt($sp9b0943, CURLOPT_NOPROGRESS, false); curl_setopt($sp9b0943, CURLOPT_HEADER, 0); curl_setopt($sp9b0943, CURLOPT_USERAGENT, 'card update'); curl_exec($sp9b0943); curl_close($sp9b0943); echo '
'; return true; } public function handle() { set_time_limit(0); $sp57f18d = $this->option('proxy'); if (!empty($sp57f18d)) { define('MY_PROXY', $sp57f18d); } $spc34df8 = $this->option('proxy-auth'); if (!empty($spc34df8)) { define('MY_PROXY_PASS', $spc34df8); } \Artisan::call('cache:clear'); \Artisan::call('config:clear'); echo '
'; $this->comment('检查更新中...'); $this->info('当前版本: ' . config('app.version')); $sp631694 = @json_decode(CurlRequest::get('https://raw.githubusercontent.com/Tai7sy/card-system/master/.version'), true); if (!@$sp631694['version']) { $this->warn('检查更新失败!'); $this->warn('Error: ' . ($sp631694 ? json_encode($sp631694) : 'Network error')); goto LABEL_EXIT; } if (config('app.version') >= $sp631694['version']) { $this->comment('您的版本已是最新!'); goto LABEL_EXIT; } $this->info('最新版本: ' . $sp631694['version']); $this->info('版本说明: ' . (@$sp631694['description'] ?? '')); $sp777a44 = strtolower($this->ask('是否现在更新 (yes/no)', 'no')); if ($sp777a44 !== 'yes') { goto LABEL_EXIT; } $sp504e6f = realpath(sys_get_temp_dir()); if (strlen($sp504e6f) < 3) { $this->warn('获取临时目录失败!'); goto LABEL_EXIT; } $sp504e6f .= DIRECTORY_SEPARATOR . Str::random(16); if (!mkdir($sp504e6f) || !is_writable($sp504e6f) || !is_readable($sp504e6f)) { $this->warn('临时目录不可读写!'); goto LABEL_EXIT; } if (!function_exists('exec')) { $this->warn('函数 exec 已被禁用, 无法继续更新!'); goto LABEL_EXIT; } if (PHP_OS === 'WINNT') { $sp328f27 = 'C:\\Program Files\\7-Zip\\7z.exe'; if (!is_file($sp328f27)) { $sp328f27 = strtolower($this->ask('未找到7-Zip, 请手动输入7zG.exe路径', $sp328f27)); } if (!is_file($sp328f27)) { $this->warn('7-Zip不可用, 请安装7-Zip后重试'); goto LABEL_EXIT; } $sp328f27 = '"' . $sp328f27 . '"'; } else { exec('tar --version', $sp8f7022, $spb611b7); if ($spb611b7) { $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($spd2457c, $sp98dd00) { $sp26c226 = fopen($sp98dd00, 'w+'); if (!$sp26c226) { return false; } $sp9f83d6 = curl_init(); curl_setopt($sp9f83d6, CURLOPT_URL, $spd2457c); curl_setopt($sp9f83d6, CURLOPT_FOLLOWLOCATION, true); curl_setopt($sp9f83d6, CURLOPT_RETURNTRANSFER, true); curl_setopt($sp9f83d6, CURLOPT_FILE, $sp26c226); curl_setopt($sp9f83d6, CURLOPT_PROGRESSFUNCTION, function ($sp1facb6, $spfddf8d, $sp32b55b, $spc41e48, $sp0e22a3) { if ($spfddf8d > 0) { echo ' download: ' . sprintf('%.2f', $sp32b55b / $spfddf8d * 100) . '%'; } }); curl_setopt($sp9f83d6, CURLOPT_NOPROGRESS, false); curl_setopt($sp9f83d6, CURLOPT_HEADER, 0); curl_setopt($sp9f83d6, CURLOPT_USERAGENT, 'card update'); curl_exec($sp9f83d6); curl_close($sp9f83d6); echo '
'; return true; } public function handle() { set_time_limit(0); $spa0fa4a = $this->option('proxy'); if (!empty($spa0fa4a)) { define('MY_PROXY', $spa0fa4a); } $spa75587 = $this->option('proxy-auth'); if (!empty($spa75587)) { define('MY_PROXY_PASS', $spa75587); } \Artisan::call('cache:clear'); \Artisan::call('config:clear'); echo '
'; $this->comment('检查更新中...'); $this->info('当前版本: ' . config('app.version')); $sp4d0456 = @json_decode(CurlRequest::get('https://raw.githubusercontent.com/Tai7sy/card-system/master/.version'), true); if (!@$sp4d0456['version']) { $this->warn('检查更新失败!'); $this->warn('Error: ' . ($sp4d0456 ? json_encode($sp4d0456) : 'Network error')); goto LABEL_EXIT; } if (config('app.version') >= $sp4d0456['version']) { $this->comment('您的版本已是最新!'); goto LABEL_EXIT; } $this->info('最新版本: ' . $sp4d0456['version']); $this->info('版本说明: ' . (@$sp4d0456['description'] ?? '')); $sp5eeb86 = strtolower($this->ask('是否现在更新 (yes/no)', 'no')); if ($sp5eeb86 !== 'yes') { goto LABEL_EXIT; } $spe1433d = realpath(sys_get_temp_dir()); if (strlen($spe1433d) < 3) { $this->warn('获取临时目录失败!'); goto LABEL_EXIT; } $spe1433d .= DIRECTORY_SEPARATOR . Str::random(16); if (!mkdir($spe1433d) || !is_writable($spe1433d) || !is_readable($spe1433d)) { $this->warn('临时目录不可读写!'); goto LABEL_EXIT; } if (!function_exists('exec')) { $this->warn('函数 exec 已被禁用, 无法继续更新!'); goto LABEL_EXIT; } if (PHP_OS === 'WINNT') { $sp2003b5 = 'C:\\Program Files\\7-Zip\\7z.exe'; if (!is_file($sp2003b5)) { $sp2003b5 = strtolower($this->ask('未找到7-Zip, 请手动输入7zG.exe路径', $sp2003b5)); } if (!is_file($sp2003b5)) { $this->warn('7-Zip不可用, 请安装7-Zip后重试'); goto LABEL_EXIT; } $sp2003b5 = '"' . $sp2003b5 . '"'; } else { exec('tar --version', $spad2be8, $sp1bf350); if ($sp1bf350) { $this->warn('Error: tar --version
' . join('
', $sp8f7022)); goto LABEL_EXIT; } } $this->comment('正在下载新版本...'); $spb701ff = $sp504e6f . DIRECTORY_SEPARATOR . 'ka_update_' . Str::random(16) . '.tmp'; if (!$this->download_progress($sp631694['url'], $spb701ff)) { $this->warn('写入临时文件失败!'); goto LABEL_EXIT; } $sp26ee73 = md5_file($spb701ff); if ($sp26ee73 !== $sp631694['md5']) { $this->warn('更新文件md5校验失败!, file:' . $sp26ee73 . ', require:' . $sp631694['md5']); goto LABEL_EXIT; } $this->comment('正在解压...'); unset($sp8f7022); if (PHP_OS === 'WINNT') { exec("{$sp328f27} x -so {$spb701ff} | {$sp328f27} x -aoa -si -ttar -o{$sp504e6f}", $sp8f7022, $spb611b7); } else { exec("tar -zxf {$spb701ff} -C {$sp504e6f}", $sp8f7022, $spb611b7); } if ($spb611b7) { $this->warn('Error: 解压失败
', $spad2be8)); goto LABEL_EXIT; } } $this->comment('正在下载新版本...'); $sp98dd00 = $spe1433d . DIRECTORY_SEPARATOR . 'ka_update_' . Str::random(16) . '.tmp'; if (!$this->download_progress($sp4d0456['url'], $sp98dd00)) { $this->warn('写入临时文件失败!'); goto LABEL_EXIT; } $sp565d4d = md5_file($sp98dd00); if ($sp565d4d !== $sp4d0456['md5']) { $this->warn('更新文件md5校验失败!, file:' . $sp565d4d . ', require:' . $sp4d0456['md5']); goto LABEL_EXIT; } $this->comment('正在解压...'); unset($spad2be8); if (PHP_OS === 'WINNT') { exec("{$sp2003b5} x -so {$sp98dd00} | {$sp2003b5} x -aoa -si -ttar -o{$spe1433d}", $spad2be8, $sp1bf350); } else { exec("tar -zxf {$sp98dd00} -C {$spe1433d}", $spad2be8, $sp1bf350); } if ($sp1bf350) { $this->warn('Error: 解压失败
' . join('
', $sp8f7022)); goto LABEL_EXIT; } $this->comment('正在关闭主站...'); \Artisan::call('down'); sleep(5); $this->comment(' --> 正在清理旧文件...'); $spe753b2 = base_path(); foreach (array('app', 'bootstrap', 'config', 'public/dist', 'database', 'routes', 'vendor') as $sp61aa55) { \File::deleteDirectory($spe753b2 . DIRECTORY_SEPARATOR . $sp61aa55); } $this->comment(' --> 正在复制新文件...'); \File::copyDirectory($sp504e6f . DIRECTORY_SEPARATOR . 'card_dist', $spe753b2); $this->comment(' --> 正在创建缓存...'); \Artisan::call('cache:clear'); \Artisan::call('route:cache'); \Artisan::call('config:cache'); $this->comment(' --> 正在更新数据库...'); \Artisan::call('migrate'); if (PHP_OS === 'WINNT') { echo '
', $spad2be8)); goto LABEL_EXIT; } $this->comment('正在关闭主站...'); \Artisan::call('down'); sleep(5); $this->comment(' --> 正在清理旧文件...'); $spbdeee3 = base_path(); foreach (array('app', 'bootstrap', 'config', 'public/dist', 'database', 'routes', 'vendor') as $sp14400e) { \File::deleteDirectory($spbdeee3 . DIRECTORY_SEPARATOR . $sp14400e); } $this->comment(' --> 正在复制新文件...'); \File::copyDirectory($spe1433d . DIRECTORY_SEPARATOR . 'card_system_free_dist', $spbdeee3); $this->comment(' --> 正在创建缓存...'); \Artisan::call('cache:clear'); \Artisan::call('route:cache'); \Artisan::call('config:cache'); $this->comment(' --> 正在更新数据库...'); \Artisan::call('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('正在启用主站...'); \Artisan::call('up'); \Artisan::call('queue:restart'); $spbe70b3 = true; LABEL_EXIT: if (isset($sp504e6f) && strlen($sp504e6f) > 19) { $this->comment('清理临时目录...'); \File::deleteDirectory($sp504e6f); } if (isset($spbe70b3) && $spbe70b3) { $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('正在启用主站...'); \Artisan::call('up'); \Artisan::call('queue:restart'); $spe23ad8 = true; LABEL_EXIT: if (isset($spe1433d) && strlen($spe1433d) > 19) { $this->comment('清理临时目录...'); \File::deleteDirectory($spe1433d); } if (isset($spe23ad8) && $spe23ad8) { $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; } }
Expand Down
Loading

0 comments on commit 27669f2

Please sign in to comment.