1
1
<?php
2
- 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 '
3
- ' ; 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 '
4
- ' ; $ 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
2
+ 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 '
3
+ ' ; 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 '
4
+ ' ; $ 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
5
5
' . join ('
6
- ' , $ 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: 解压失败
6
+ ' , $ 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: 解压失败
7
7
' . join ('
8
- ' , $ 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 '
8
+ ' , $ 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 '
9
9
' ; $ this ->alert ('请注意手动设置目录权限 ' ); $ this ->comment (' storage 可读可写 ' ); $ this ->comment (' bootstrap/cache/ 可读可写 ' ); echo '
10
10
11
- ' ; } 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 '
11
+ ' ; } 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 '
12
12
' ; die; } }
0 commit comments