No Description
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

AjaxLogic.php 79KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654
  1. <?php
  2. /**
  3. * 易优CMS
  4. * ============================================================================
  5. * 版权所有 2016-2028 海南赞赞网络科技有限公司,并保留所有权利。
  6. * 网站地址: http://www.eyoucms.com
  7. * ----------------------------------------------------------------------------
  8. * 如果商业用途务必到官方购买正版授权, 以免引起不必要的法律纠纷.
  9. * ============================================================================
  10. * Author: 小虎哥 <1105415366@qq.com>
  11. * Date: 2018-4-3
  12. */
  13. namespace app\admin\logic;
  14. use think\Model;
  15. use think\Db;
  16. /**
  17. * 逻辑定义
  18. * Class CatsLogic
  19. * @package admin\Logic
  20. */
  21. class AjaxLogic extends Model
  22. {
  23. private $request = null;
  24. private $admin_lang = 'cn';
  25. private $main_lang = 'cn';
  26. /**
  27. * 析构函数
  28. */
  29. function __construct() {
  30. $this->request = request();
  31. $this->admin_lang = get_admin_lang();
  32. $this->main_lang = get_main_lang();
  33. }
  34. /**
  35. * 进入登录页面需要异步处理的业务
  36. */
  37. public function login_handle()
  38. {
  39. // $this->repairAdmin(); // 修复管理员ID为0的问题
  40. $this->saveBaseFile(); // 存储后台入口文件路径,比如:/login.php
  41. clear_session_file(); // 清理过期的data/session文件
  42. }
  43. /**
  44. * 修复管理员
  45. * @return [type] [description]
  46. */
  47. private function repairAdmin()
  48. {
  49. $row = [];
  50. $result = Db::name('admin')->field('admin_id,user_name')->order('add_time asc')->select();
  51. $total = count($result);
  52. foreach ($result as $key => $val) {
  53. $pre_admin_id = $next_admin_id = 0;
  54. if (empty($val['admin_id'])) {
  55. if (1 == $total) {
  56. Db::name('admin')->where(['user_name'=>$val['user_name']])->update(['admin_id'=>1, 'update_time'=>getTime()]);
  57. } else {
  58. $pre_admin_id = empty($key) ? 0 : $result[$key - 1]['admin_id'];
  59. if ($key < ($total - 1)) {
  60. $next_admin_id = $result[$key + 1]['admin_id'];
  61. } else {
  62. $next_admin_id = $pre_admin_id + 2;
  63. }
  64. if (($next_admin_id - $pre_admin_id) >= 2) {
  65. $admin_id = $pre_admin_id + 1;
  66. Db::name('admin')->where(['user_name'=>$val['user_name']])->update(['admin_id'=>$admin_id, 'update_time'=>getTime()]);
  67. }
  68. }
  69. }
  70. }
  71. }
  72. /**
  73. * 清理未存在的左侧菜单
  74. * @return [type] [description]
  75. */
  76. public function admin_menu_clear()
  77. {
  78. $del_ids = [];
  79. $codeArr = Db::name('weapp')->column('code');
  80. $list = Db::name('admin_menu')->where(['controller_name'=>'Weapp','action_name'=>'execute'])->select();
  81. foreach ($list as $key => $val) {
  82. $code = preg_replace('/^(.*)\|sm\|([^\|]+)\|sc\|(.*)$/i', '${2}', $val['param']);
  83. if (!in_array($code, $codeArr)) {
  84. $del_ids[] = $val['id'];
  85. }
  86. }
  87. if (!empty($del_ids)) {
  88. Db::name('admin_menu')->where(['id'=>['IN', $del_ids]])->delete();
  89. }
  90. }
  91. /**
  92. * 进入欢迎页面需要异步处理的业务
  93. */
  94. public function welcome_handle()
  95. {
  96. getVersion('version_themeusers', 'v1.0.1', true);
  97. getVersion('version_themeshop', 'v1.0.1', true);
  98. $this->addChannelFile(); // 自动补充自定义模型的文件
  99. $this->saveBaseFile(); // 存储后台入口文件路径,比如:/login.php
  100. $this->renameInstall(); // 重命名安装目录,提高网站安全性
  101. $this->renameSqldatapath(); // 重命名数据库备份目录,提高网站安全性
  102. $this->del_adminlog(); // 只保留最近一个月的操作日志
  103. model('Member')->batch_update_userslevel(); // 批量更新会员过期等级
  104. // tpversion(); // 统计装载量,请勿删除,谢谢支持!
  105. }
  106. /**
  107. * 自动补充自定义模型的文件
  108. */
  109. public function addChannelFile()
  110. {
  111. try {
  112. $list = Db::name('channeltype')->where([
  113. 'ifsystem' => 0,
  114. ])->select();
  115. if (!empty($list)) {
  116. $cmodSrc = "data/model/application/common/model/CustomModel.php";
  117. $cmodContent = @file_get_contents($cmodSrc);
  118. $hctlSrc = "data/model/application/home/controller/CustomModel.php";
  119. $hctlContent = @file_get_contents($hctlSrc);
  120. $hmodSrc = "data/model/application/home/model/CustomModel.php";
  121. $hmodContent = @file_get_contents($hmodSrc);
  122. foreach ($list as $key => $val) {
  123. $file = "application/common/model/{$val['ctl_name']}.php";
  124. if (!file_exists($file)) {
  125. $cmodContent = str_replace('CustomModel', $val['ctl_name'], $cmodContent);
  126. $cmodContent = str_replace('custommodel', strtolower($val['nid']), $cmodContent);
  127. $cmodContent = str_replace('CUSTOMMODEL', strtoupper($val['nid']), $cmodContent);
  128. @file_put_contents($file, $cmodContent);
  129. }
  130. $file = "application/home/controller/{$val['ctl_name']}.php";
  131. if (!file_exists($file)) {
  132. $hctlContent = str_replace('CustomModel', $val['ctl_name'], $hctlContent);
  133. $hctlContent = str_replace('custommodel', strtolower($val['nid']), $hctlContent);
  134. $hctlContent = str_replace('CUSTOMMODEL', strtoupper($val['nid']), $hctlContent);
  135. @file_put_contents($file, $hctlContent);
  136. }
  137. $file = "application/home/model/{$val['ctl_name']}.php";
  138. if (!file_exists($file)) {
  139. $hmodContent = str_replace('CustomModel', $val['ctl_name'], $hmodContent);
  140. $hmodContent = str_replace('custommodel', strtolower($val['nid']), $hmodContent);
  141. $hmodContent = str_replace('CUSTOMMODEL', strtoupper($val['nid']), $hmodContent);
  142. @file_put_contents($file, $hmodContent);
  143. }
  144. }
  145. }
  146. } catch (\Exception $e) {}
  147. }
  148. /**
  149. * 只保留最近一个月的操作日志
  150. */
  151. public function del_adminlog()
  152. {
  153. try {
  154. $is_system = true;
  155. if (file_exists(ROOT_PATH.'weapp/Systemdoctor/logic/SystemdoctorLogic.php')) {
  156. $systemdoctorLogic = new \weapp\Systemdoctor\logic\SystemdoctorLogic;
  157. if (method_exists($systemdoctorLogic, 'del_adminlog')) {
  158. $is_system = false;
  159. $systemdoctorLogic->del_adminlog();
  160. }
  161. }
  162. if ($is_system) {
  163. $mtime = strtotime("-1 month");
  164. Db::name('admin_log')->where([
  165. 'log_time' => ['lt', $mtime],
  166. ])->delete();
  167. }
  168. } catch (\Exception $e) {}
  169. }
  170. /*
  171. * 修改备份数据库目录
  172. */
  173. private function renameSqldatapath() {
  174. $default_sqldatapath = config('DATA_BACKUP_PATH');
  175. if (is_dir('.'.$default_sqldatapath)) { // 还是符合初始默认的规则的链接方式
  176. $dirname = get_rand_str(20, 0, 1);
  177. $new_path = '/data/sqldata_'.$dirname;
  178. if (@rename(ROOT_PATH.ltrim($default_sqldatapath, '/'), ROOT_PATH.ltrim($new_path, '/'))) {
  179. /*多语言*/
  180. if (is_language()) {
  181. $langRow = \think\Db::name('language')->order('id asc')->select();
  182. foreach ($langRow as $key => $val) {
  183. tpCache('web', ['web_sqldatapath'=>$new_path], $val['mark']);
  184. }
  185. } else { // 单语言
  186. tpCache('web', ['web_sqldatapath'=>$new_path]);
  187. }
  188. /*--end*/
  189. }
  190. }
  191. }
  192. /**
  193. * 重命名安装目录,提高网站安全性
  194. * 在 Admin@login 和 Index@index 操作下
  195. */
  196. private function renameInstall()
  197. {
  198. if (stristr($this->request->host(), 'eycms.hk')) {
  199. return true;
  200. }
  201. $install_path = ROOT_PATH.'install';
  202. if (is_dir($install_path) && file_exists($install_path)) {
  203. $install_time = get_rand_str(20, 0, 1);
  204. $new_path = ROOT_PATH.'install_'.$install_time;
  205. @rename($install_path, $new_path);
  206. }
  207. else {
  208. $dirlist = glob('install_*');
  209. $install_dirname = current($dirlist);
  210. if (!empty($install_dirname)) {
  211. /*---修补v1.1.6版本删除的安装文件 install.lock start----*/
  212. if (!empty($_SESSION['isset_install_lock'])) {
  213. return true;
  214. }
  215. $_SESSION['isset_install_lock'] = 1;
  216. /*---修补v1.1.6版本删除的安装文件 install.lock end----*/
  217. $install_path = ROOT_PATH.$install_dirname;
  218. if (preg_match('/^install_[0-9]{10}$/i', $install_dirname)) {
  219. $install_time = get_rand_str(20, 0, 1);
  220. $install_dirname = 'install_'.$install_time;
  221. $new_path = ROOT_PATH.$install_dirname;
  222. if (@rename($install_path, $new_path)) {
  223. $install_path = $new_path;
  224. /*多语言*/
  225. if (is_language()) {
  226. $langRow = \think\Db::name('language')->order('id asc')->select();
  227. foreach ($langRow as $key => $val) {
  228. tpSetting('install', ['install_dirname'=>$install_time], $val['mark']);
  229. }
  230. } else { // 单语言
  231. tpSetting('install', ['install_dirname'=>$install_time]);
  232. }
  233. /*--end*/
  234. }
  235. }
  236. $filename = $install_path.DS.'install.lock';
  237. if (!file_exists($filename)) {
  238. @file_put_contents($filename, '');
  239. }
  240. }
  241. }
  242. }
  243. /**
  244. * 存储后台入口文件路径,比如:/login.php
  245. * 在 Admin@login 和 Index@index 操作下
  246. */
  247. private function saveBaseFile()
  248. {
  249. $data = [];
  250. $data['web_adminbasefile'] = $this->request->baseFile();
  251. $data['web_cmspath'] = ROOT_DIR; // EyouCMS安装目录
  252. /*多语言*/
  253. if (is_language()) {
  254. $langRow = \think\Db::name('language')->field('mark')->order('id asc')->select();
  255. foreach ($langRow as $key => $val) {
  256. tpCache('web', $data, $val['mark']);
  257. }
  258. } else { // 单语言
  259. tpCache('web', $data);
  260. }
  261. /*--end*/
  262. }
  263. /**
  264. * 升级前台会员中心的模板文件
  265. */
  266. public function update_template($type = '')
  267. {
  268. if (!empty($type)) {
  269. if ('users' == $type) {
  270. if (file_exists(ROOT_PATH.'template/'.TPL_THEME.'pc/users') || file_exists(ROOT_PATH.'template/'.TPL_THEME.'mobile/users')) {
  271. $upgrade = getDirFile(DATA_PATH.'backup'.DS.'tpl');
  272. if (!empty($upgrade) && is_array($upgrade)) {
  273. delFile(DATA_PATH.'backup'.DS.'template_www');
  274. // 升级之前,备份涉及的源文件
  275. foreach ($upgrade as $key => $val) {
  276. $val_tmp = str_replace("template/", "template/".TPL_THEME, $val);
  277. $source_file = ROOT_PATH.$val_tmp;
  278. if (file_exists($source_file)) {
  279. $destination_file = DATA_PATH.'backup'.DS.'template_www'.DS.$val_tmp;
  280. tp_mkdir(dirname($destination_file));
  281. @copy($source_file, $destination_file);
  282. }
  283. }
  284. // 递归复制文件夹
  285. $this->recurse_copy(DATA_PATH.'backup'.DS.'tpl', rtrim(ROOT_PATH, DS));
  286. }
  287. /*--end*/
  288. }
  289. }
  290. }
  291. }
  292. /**
  293. * 自定义函数递归的复制带有多级子目录的目录
  294. * 递归复制文件夹
  295. *
  296. * @param string $src 原目录
  297. * @param string $dst 复制到的目录
  298. * @return string
  299. */
  300. //参数说明:
  301. //自定义函数递归的复制带有多级子目录的目录
  302. private function recurse_copy($src, $dst)
  303. {
  304. $planPath_pc = "template/".TPL_THEME."pc/";
  305. $planPath_m = "template/".TPL_THEME."mobile/";
  306. $dir = opendir($src);
  307. /*pc和mobile目录存在的情况下,才拷贝会员模板到相应的pc或mobile里*/
  308. $dst_tmp = str_replace('\\', '/', $dst);
  309. $dst_tmp = rtrim($dst_tmp, '/').'/';
  310. if (stristr($dst_tmp, $planPath_pc) && file_exists($planPath_pc)) {
  311. tp_mkdir($dst);
  312. } else if (stristr($dst_tmp, $planPath_m) && file_exists($planPath_m)) {
  313. tp_mkdir($dst);
  314. }
  315. /*--end*/
  316. while (false !== $file = readdir($dir)) {
  317. if (($file != '.') && ($file != '..')) {
  318. if (is_dir($src . '/' . $file)) {
  319. $needle = '/template/'.TPL_THEME;
  320. $needle = rtrim($needle, '/');
  321. $dstfile = $dst . '/' . $file;
  322. if (!stristr($dstfile, $needle)) {
  323. $dstfile = str_replace('/template', $needle, $dstfile);
  324. }
  325. $this->recurse_copy($src . '/' . $file, $dstfile);
  326. }
  327. else {
  328. if (file_exists($src . DIRECTORY_SEPARATOR . $file)) {
  329. /*pc和mobile目录存在的情况下,才拷贝会员模板到相应的pc或mobile里*/
  330. $rs = true;
  331. $src_tmp = str_replace('\\', '/', $src . DIRECTORY_SEPARATOR . $file);
  332. if (stristr($src_tmp, $planPath_pc) && !file_exists($planPath_pc)) {
  333. continue;
  334. } else if (stristr($src_tmp, $planPath_m) && !file_exists($planPath_m)) {
  335. continue;
  336. }
  337. /*--end*/
  338. $rs = @copy($src . DIRECTORY_SEPARATOR . $file, $dst . DIRECTORY_SEPARATOR . $file);
  339. if($rs) {
  340. @unlink($src . DIRECTORY_SEPARATOR . $file);
  341. }
  342. }
  343. }
  344. }
  345. }
  346. closedir($dir);
  347. }
  348. // 记录当前是多语言还是单语言到文件里
  349. public function system_langnum_file()
  350. {
  351. model('Language')->setLangNum();
  352. }
  353. // 记录当前是否多站点到文件里
  354. public function system_citysite_file()
  355. {
  356. $key = base64_decode('cGhwLnBocF9zZXJ2aWNlbWVhbA==');
  357. $value = tpCache($key);
  358. if (2 > $value) {
  359. /*多语言*/
  360. if (is_language()) {
  361. $langRow = Db::name('language')->order('id asc')->select();
  362. foreach ($langRow as $key => $val) {
  363. tpCache('web', ['web_citysite_open'=>0], $val['mark']);
  364. }
  365. } else { // 单语言
  366. tpCache('web', ['web_citysite_open'=>0]);
  367. }
  368. /*--end*/
  369. model('Citysite')->setCitysiteOpen();
  370. }
  371. }
  372. public function admin_logic_1609900642()
  373. {
  374. // 更新自定义的样式表文件
  375. $version = getVersion();
  376. $syn_admin_logic_1697156935 = tpSetting('syn.admin_logic_1697156935', [], 'cn');
  377. if ($version != $syn_admin_logic_1697156935) {
  378. $r = $this->admin_update_theme_css();
  379. if ($r !== false) {
  380. tpSetting('syn', ['admin_logic_1697156935'=>$version], 'cn');
  381. }
  382. }
  383. $vars1 = 'cGhwLnBo'.'cF9zZXJ2aW'.'NlaW5mbw==';
  384. $vars1 = base64_decode($vars1);
  385. $data = tpCache($vars1);
  386. $data = mchStrCode($data, 'DECODE');
  387. $data = json_decode($data, true);
  388. if (empty($data['pid']) || 2 > $data['pid']) return true;
  389. $file = "./data/conf/{$data['code']}.txt";
  390. $vars2 = 'cGhwX3Nl'.'cnZpY2V'.'tZWFs';
  391. $vars2 = base64_decode($vars2);
  392. if (!file_exists($file)) {
  393. /*多语言*/
  394. if (is_language()) {
  395. $langRow = \think\Db::name('language')->order('id asc')->select();
  396. foreach ($langRow as $key => $val) {
  397. tpCache('php', [$vars2=>1], $val['mark']);
  398. }
  399. } else { // 单语言
  400. tpCache('php', [$vars2=>1]);
  401. }
  402. /*--end*/
  403. } else {
  404. /*多语言*/
  405. if (is_language()) {
  406. $langRow = \think\Db::name('language')->order('id asc')->select();
  407. foreach ($langRow as $key => $val) {
  408. tpCache('php', [$vars2=>$data['pid']], $val['mark']);
  409. }
  410. } else { // 单语言
  411. tpCache('php', [$vars2=>$data['pid']]);
  412. }
  413. /*--end*/
  414. }
  415. }
  416. /**
  417. * 更新后台自定义的样式表文件
  418. * @return [type] [description]
  419. */
  420. public function admin_update_theme_css()
  421. {
  422. $r = false;
  423. $file = APP_PATH.'admin/template/public/theme_css.htm';
  424. if (file_exists($file)) {
  425. $view = \think\View::instance(\think\Config::get('template'), \think\Config::get('view_replace_str'));
  426. $view->assign('global', tpCache('global'));
  427. $css = $view->fetch($file);
  428. $css = str_replace(['<style type="text/css">','</style>'], '', $css);
  429. @chmod($file, 0755);
  430. $r = @file_put_contents(ROOT_PATH.'public/static/admin/css/theme_style.css', $css);
  431. }
  432. return $r;
  433. }
  434. /**
  435. * 更新会员中心自定义的样式表文件
  436. * @return [type] [description]
  437. */
  438. public function users_update_theme_css()
  439. {
  440. }
  441. // 评价主表评分由原先的(好评、中评、差评)转至实际星评数(1、2、3、4、5)(v1.6.1节点去掉--陈风任)
  442. public function admin_logic_1651114275()
  443. {
  444. $Prefix = config('database.prefix');
  445. $isTable = Db::query('SHOW TABLES LIKE \''.$Prefix.'shop_order_comment\'');
  446. if (!empty($isTable)) {
  447. $orderCommentTableInfo = Db::query("SHOW COLUMNS FROM {$Prefix}shop_order_comment");
  448. $orderCommentTableInfo = get_arr_column($orderCommentTableInfo, 'Field');
  449. if (!empty($orderCommentTableInfo) && !in_array('is_new_comment', $orderCommentTableInfo)){
  450. $sql = "ALTER TABLE `{$Prefix}shop_order_comment` ADD COLUMN `is_new_comment` tinyint(1) UNSIGNED NOT NULL DEFAULT 0 COMMENT '是否新版评价:0否,1是' AFTER `is_anonymous`;";
  451. @Db::execute($sql);
  452. schemaTable('shop_order_comment');
  453. }
  454. }
  455. }
  456. public function admin_logic_1623036205()
  457. {
  458. $getTableInfo = [];
  459. $Prefix = config('database.prefix');
  460. $arr = [
  461. ROOT_PATH."application/admin/model/UsersLevel.php",
  462. ROOT_PATH."core/library/think/verify/bgs/3e.jpg",
  463. ROOT_PATH."public/plugins/Ueditor/lang/en/images/imglabel1.png",
  464. ROOT_PATH."public/plugins/Ueditor/lang/zh-cn/images/mfusisc.png",
  465. ROOT_PATH."public/plugins/Ueditor/dialogs/template/images/prel2.png",
  466. ROOT_PATH."public/html/article_pay.htm",
  467. ROOT_PATH."public/html/download_pay.htm",
  468. ROOT_PATH."public/html/comment",
  469. ROOT_PATH."public/static/common/js/jquery.tools.min.js",
  470. ];
  471. foreach ($arr as $key => $val) {
  472. if (is_dir($val)) {
  473. try {
  474. delFile($val, true);
  475. } catch (\Exception $e) {}
  476. } else if (file_exists($val)) {
  477. @unlink($val);
  478. }
  479. }
  480. Db::name("admin_menu")->where(['menu_id'=>2004006])->update(['param'=>'|mt20|1|menu|1']);
  481. }
  482. /*
  483. * 初始化原来的菜单栏目
  484. */
  485. public function initialize_admin_menu(){
  486. $total = Db::name("admin_menu")->count();
  487. if (empty($total)){
  488. $menuArr = getAllMenu();
  489. $insert_data = [];
  490. foreach ($menuArr as $key => $val){
  491. foreach ($val['child'] as $nk=>$nrr) {
  492. $sort_order = 100;
  493. $is_switch = 1;
  494. if ($nrr['id'] == 2004){
  495. $sort_order = 10000;
  496. $is_switch = 0;
  497. }
  498. $insert_data[] = [
  499. 'menu_id' => $nrr['id'],
  500. 'title' => $nrr['name'],
  501. 'controller_name' => $nrr['controller'],
  502. 'action_name' => $nrr['action'],
  503. 'param' => !empty($nrr['param']) ? $nrr['param'] : '',
  504. 'is_menu' => $nrr['is_menu'],
  505. 'is_switch' => $is_switch,
  506. 'icon' => $nrr['icon'],
  507. 'sort_order' => $sort_order,
  508. 'add_time' => getTime(),
  509. 'update_time' => getTime()
  510. ];
  511. }
  512. }
  513. Db::name("admin_menu")->insertAll($insert_data);
  514. }
  515. }
  516. //1.5.9相关
  517. public function admin_logic_1658220528(){
  518. $Prefix = config('database.prefix');
  519. $archivesTableInfo = Db::query("SHOW COLUMNS FROM {$Prefix}archives");
  520. $archivesTableInfo = get_arr_column($archivesTableInfo, 'Field');
  521. if (!empty($archivesTableInfo) && !in_array('virtual_sales', $archivesTableInfo)){
  522. $sql = "ALTER TABLE `{$Prefix}archives` ADD COLUMN `virtual_sales` int(10) NULL DEFAULT 0 COMMENT '商品虚拟销售量' AFTER `sales_num`;";
  523. @Db::execute($sql);
  524. }
  525. if (!empty($archivesTableInfo) && !in_array('sales_all', $archivesTableInfo)){
  526. $sql = "ALTER TABLE `{$Prefix}archives` ADD COLUMN `sales_all` int(10) NULL DEFAULT 0 COMMENT '虚拟总销量' AFTER `virtual_sales`;";
  527. @Db::execute($sql);
  528. }
  529. schemaTable('archives');
  530. $guestbookTableInfo = Db::query("SHOW COLUMNS FROM {$Prefix}guestbook");
  531. $guestbookTableInfo = get_arr_column($guestbookTableInfo, 'Field');
  532. if (!empty($guestbookTableInfo) && !in_array('users_id', $guestbookTableInfo)){
  533. $sql = "ALTER TABLE `{$Prefix}guestbook` ADD COLUMN `users_id` int(11) NULL DEFAULT 0 COMMENT '用户id' AFTER `channel`;";
  534. @Db::execute($sql);
  535. schemaTable('guestbook');
  536. }
  537. try {
  538. $specTableInfo = Db::query("SHOW COLUMNS FROM {$Prefix}product_spec_data_handle");
  539. $specTableInfo = convert_arr_key($specTableInfo, 'Field');
  540. if (!empty($specTableInfo['spec_id']['Key'])) {
  541. $sql = "ALTER TABLE `{$Prefix}product_spec_data_handle` DROP PRIMARY KEY;";
  542. @Db::execute($sql);
  543. $sql = "ALTER TABLE `{$Prefix}product_spec_data_handle` MODIFY COLUMN `spec_id` int(10) NULL DEFAULT 0 COMMENT '对应 product_spec_data 数据表' FIRST ;";
  544. @Db::execute($sql);
  545. schemaTable('product_spec_data_handle');
  546. }
  547. } catch (\Exception $e) {
  548. }
  549. $searchTableInfo = Db::query("SHOW COLUMNS FROM {$Prefix}search_word");
  550. $searchTableInfo = get_arr_column($searchTableInfo, 'Field');
  551. if (!empty($searchTableInfo) && !in_array('users_id', $searchTableInfo)){
  552. $sql = "ALTER TABLE `{$Prefix}search_word` ADD COLUMN `users_id` int(11) NULL DEFAULT 0 COMMENT '用户id' AFTER `sort_order`;";
  553. @Db::execute($sql);
  554. }
  555. if (!empty($searchTableInfo) && !in_array('ip', $searchTableInfo)){
  556. $sql = "ALTER TABLE `{$Prefix}search_word` ADD COLUMN `ip` varchar(20) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT '' COMMENT 'ip' AFTER `users_id`;";
  557. @Db::execute($sql);
  558. schemaTable('search_word');
  559. }
  560. if (!empty($searchTableInfo) && !in_array('is_hot', $searchTableInfo)){
  561. $sql = "ALTER TABLE `{$Prefix}search_word` ADD COLUMN `is_hot` tinyint(1) NULL DEFAULT 0 COMMENT '是否热搜' AFTER `ip`;";
  562. @Db::execute($sql);
  563. schemaTable('search_word');
  564. }
  565. $isTable = Db::query('SHOW TABLES LIKE \''.$Prefix.'search_locking\'');
  566. if (empty($isTable)) {
  567. $tableSql = <<<EOF
  568. CREATE TABLE IF NOT EXISTS `{$Prefix}search_locking` (
  569. `id` int(10) NOT NULL AUTO_INCREMENT,
  570. `users_id` int(10) DEFAULT '0' COMMENT '用户ID',
  571. `ip` varchar(20) DEFAULT '' COMMENT 'ip',
  572. `locking_time` int(11) DEFAULT '0' COMMENT '锁定时间',
  573. `add_time` int(11) DEFAULT '0' COMMENT '新增时间',
  574. `update_time` int(11) DEFAULT '0' COMMENT '更新时间',
  575. PRIMARY KEY (`id`)
  576. ) ENGINE=MyISAM AUTO_INCREMENT=1 DEFAULT CHARSET=utf8 COMMENT='搜索记录锁定表';
  577. EOF;
  578. $r = @Db::execute($tableSql);
  579. if ($r !== false) {
  580. schemaTable('search_locking');
  581. }
  582. }
  583. // 优化主表字段的长度
  584. $admin_logic_1673941712 = tpSetting('syn.admin_logic_1673941712', [], 'cn');
  585. if (empty($admin_logic_1673941712)) {
  586. @Db::execute("ALTER TABLE `{$Prefix}archives` MODIFY COLUMN `htmlfilename` varchar(500) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT '' COMMENT '自定义文件名' AFTER `collection`");
  587. tpSetting('syn', ['admin_logic_1673941712'=>1], 'cn');
  588. }
  589. // 积分字段优化
  590. $admin_logic_1676854942 = tpSetting('syn.admin_logic_1676854942', [], 'cn');
  591. if (empty($admin_logic_1676854942)) {
  592. @Db::execute("ALTER TABLE `{$Prefix}users_score` MODIFY COLUMN `score` varchar(20) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL DEFAULT '' COMMENT '积分' AFTER `reply_id`");
  593. tpSetting('syn', ['admin_logic_1676854942'=>1], 'cn');
  594. }
  595. // 更新旧的商品虚拟总销量
  596. $this->handleProductSalesAll();
  597. // 同步模板的付费选择支付文件到前台模板指定位置
  598. $this->copy_tplpayfile();
  599. // 新增海外地区
  600. $this->add_haiwai_region();
  601. // 新增河南济源市地区
  602. $this->add_henan_jiyuan_region();
  603. // 默认收货后可维权时间
  604. $admin_logic_1678762367 = tpSetting('syn.admin_logic_1678762367', [], 'cn');
  605. if (empty($admin_logic_1678762367)) {
  606. getUsersConfigData('order', ['order_right_protect_time' => 7]);
  607. tpSetting('syn', ['admin_logic_1678762367'=>1], 'cn');
  608. }
  609. Db::name("admin_menu")->where(['menu_id'=>2004018])->update(['title'=>'留言中心']);
  610. Db::name("region")->where(['id'=>10961])->update(['name'=>'新吴区', 'initial'=>'X']);
  611. Db::name("region")->where(['id'=>10962])->update(['name'=>'梁溪区', 'initial'=>'L']);
  612. Db::name("region")->where(['id'=>['IN',['10969','10976']]])->delete();
  613. // 升级v1.6.3版本要处理的数据
  614. $this->eyou_v163_handle_data();
  615. // 升级v1.6.4版本要处理的数据
  616. $this->eyou_v164_handle_data();
  617. // 升级v1.6.5版本要处理的数据
  618. $this->eyou_v165_handle_data();
  619. }
  620. // 升级v1.6.3版本要处理的数据
  621. private function eyou_v163_handle_data()
  622. {
  623. // 主题风格同步兼容旧版本数据
  624. $this->theme_syn_olddata();
  625. // 处理站点状态的模板页面
  626. $admin_logic_1687676445 = tpSetting('syn.admin_logic_1687676445', [], 'cn');
  627. if (empty($admin_logic_1687676445)) {
  628. $webConfig = tpCache('web');
  629. if (empty($webConfig['web_status_tpl'])) {
  630. /*多语言*/
  631. $web_basehost = empty($webConfig['web_basehost']) ? request()->domain() : $webConfig['web_basehost'];
  632. $web_basehost = preg_replace('/^(([^\:\.]+):)?(\/\/)?([^\/\:]*)(\:\d+)?(.*)$/i', '${1}${3}${4}${5}', $web_basehost);
  633. $web_status_tpl = $web_basehost.ROOT_DIR.'/public/close.html';
  634. if (is_language()) {
  635. $langRow = \think\Db::name('language')->order('id asc')
  636. ->cache(true, EYOUCMS_CACHE_TIME, 'language')
  637. ->select();
  638. foreach ($langRow as $key => $val) {
  639. tpCache('web', ['web_status_tpl'=>$web_status_tpl], $val['mark']);
  640. }
  641. } else {
  642. tpCache('web', ['web_status_tpl'=>$web_status_tpl]);
  643. }
  644. /*--end*/
  645. }
  646. tpSetting('syn', ['admin_logic_1687676445'=>1], 'cn');
  647. }
  648. // 处理编辑器常用配置
  649. $admin_logic_1687767523 = tpSetting('syn.admin_logic_1687767523', [], 'cn');
  650. if (empty($admin_logic_1687767523)) {
  651. $editor = tpSetting('editor', [], get_default_lang());
  652. if (!empty($editor['editor_select']) || !empty($editor['editor_remote_img_local']) || !empty($editor['editor_img_clear_link'])) {
  653. /*多语言*/
  654. if (is_language()) {
  655. $langRow = \think\Db::name('language')->order('id asc')
  656. ->cache(true, EYOUCMS_CACHE_TIME, 'language')
  657. ->select();
  658. foreach ($langRow as $key => $val) {
  659. tpSetting('editor', $editor, $val['mark']);
  660. }
  661. } else {
  662. tpSetting('editor',$editor);
  663. }
  664. /*--end*/
  665. }
  666. tpSetting('syn', ['admin_logic_1687767523'=>1], 'cn');
  667. }
  668. // 搜索敏感词默认值
  669. $admin_logic_1685584104 = tpSetting('syn.admin_logic_1685584104', [], 'cn');
  670. if (empty($admin_logic_1685584104)) {
  671. $searchConf = tpCache('search');
  672. if (!isset($searchConf['search_tabu_words'])) {
  673. $search_tabu_words = ['<','>','"',';',',','@','&','#','\\','*'];
  674. $searchConf['search_tabu_words'] = implode(PHP_EOL, $search_tabu_words);
  675. }
  676. /*多语言*/
  677. if (is_language()) {
  678. $langRow = \think\Db::name('language')->order('id asc')
  679. ->cache(true, EYOUCMS_CACHE_TIME, 'language')
  680. ->select();
  681. foreach ($langRow as $key => $val) {
  682. tpCache('search', $searchConf, $val['mark']);
  683. }
  684. } else {
  685. tpCache('search', $searchConf);
  686. }
  687. /*--end*/
  688. tpSetting('syn', ['admin_logic_1685584104'=>1], 'cn');
  689. }
  690. // 处理网站防止被刷的默认开关值
  691. $admin_logic_1682580429 = tpSetting('syn.admin_logic_1682580429', [], 'cn');
  692. if (empty($admin_logic_1682580429)) {
  693. /*多语言*/
  694. if (is_language()) {
  695. $langRow = \think\Db::name('language')->order('id asc')
  696. ->cache(true, EYOUCMS_CACHE_TIME, 'language')
  697. ->select();
  698. foreach ($langRow as $key => $val) {
  699. tpCache('web', ['web_anti_brushing'=>'0'], $val['mark']);
  700. }
  701. } else {
  702. tpCache('web', ['web_anti_brushing'=>'0']);
  703. }
  704. /*--end*/
  705. tpSetting('syn', ['admin_logic_1682580429'=>1], 'cn');
  706. }
  707. }
  708. // 升级v1.6.4版本要处理的数据
  709. private function eyou_v164_handle_data()
  710. {
  711. $Prefix = config('database.prefix');
  712. // 删除大数据影响的索引
  713. $admin_logic_1689071584 = tpSetting('syn.admin_logic_1689071584', [], 'cn');
  714. if (empty($admin_logic_1689071584)) {
  715. try {
  716. @Db::execute("ALTER TABLE `{$Prefix}archives` DROP INDEX `aid`;");
  717. } catch (\Exception $e) {
  718. }
  719. tpSetting('syn', ['admin_logic_1689071584'=>1], 'cn');
  720. }
  721. }
  722. // 升级v1.6.5版本要处理的数据
  723. private function eyou_v165_handle_data()
  724. {
  725. // $this->eyou_v165_del_func();
  726. $this->syn_handle_table_data();
  727. $this->syn_handle_formdata();
  728. $this->syn_handle_linksgroupdata();
  729. $this->syn_handle_recycle_switch();
  730. // $this->syn_handle_foreign_pack();
  731. $this->syn_handle_tougao_tpl();
  732. $this->syn_handle_update_archives();
  733. $this->syn_handle_create_index();
  734. }
  735. private function syn_handle_table_data()
  736. {
  737. $Prefix = config('database.prefix');
  738. $admin_logic_1701050542 = tpSetting('syn.admin_logic_1701050542', [], 'cn');
  739. if (empty($admin_logic_1701050542)) {
  740. $data = [
  741. 'seo_uphtml_after_home13' => 1,
  742. 'seo_uphtml_after_channel13' => 1,
  743. 'seo_uphtml_after_pernext13' => 1,
  744. ];
  745. /*多语言*/
  746. if (is_language()) {
  747. $langRow = \think\Db::name('language')->order('id asc')
  748. ->cache(true, EYOUCMS_CACHE_TIME, 'language')
  749. ->select();
  750. foreach ($langRow as $key => $val) {
  751. tpCache('seo', $data, $val['mark']);
  752. }
  753. } else {
  754. tpCache('seo', $data);
  755. }
  756. /*--end*/
  757. tpSetting('syn', ['admin_logic_1701050542'=>1], 'cn');
  758. }
  759. $admin_logic_1700638990 = tpSetting('syn.admin_logic_1700638990', [], 'cn');
  760. if (empty($admin_logic_1700638990)) {
  761. $pay_open = (int) Db::name('users_config')->where(['name'=>'pay_open'])->value('value');
  762. //同步会员中心手机端底部菜单开关
  763. Db::name('users_bottom_menu')->where([
  764. 'mca' => ['IN',['user/Pay/pay_account_recharge']]
  765. ])->update([
  766. 'status' => $pay_open,
  767. 'update_time' => getTime(),
  768. ]);
  769. tpSetting('syn', ['admin_logic_1700638990'=>1], 'cn');
  770. }
  771. $admin_logic_1700789211 = tpSetting('syn.admin_logic_1700789211', [], 'cn');
  772. if (empty($admin_logic_1700789211)) {
  773. try {
  774. $count = Db::name('foreign_pack')->where(['name'=>'page6','type'=>1,'lang'=>'cn'])->count();
  775. if (empty($count)) {
  776. @Db::execute("INSERT INTO `{$Prefix}foreign_pack` (`type`, `name`, `value`, `lang`, `sort_order`, `add_time`, `update_time`) VALUES ('1', 'page6', '第%s页', 'cn', '100', '1543890216', '1543890216');");
  777. }
  778. } catch (\Exception $e) {}
  779. try {
  780. $count = Db::name('foreign_pack')->where(['name'=>'page6','type'=>1,'lang'=>'en'])->count();
  781. if (empty($count)) {
  782. @Db::execute("INSERT INTO `{$Prefix}foreign_pack` (`type`, `name`, `value`, `lang`, `sort_order`, `add_time`, `update_time`) VALUES ('1', 'page6', '%s', 'en', '100', '1543890216', '1543890216');");
  783. }
  784. } catch (\Exception $e) {}
  785. tpSetting('syn', ['admin_logic_1700789211'=>1], 'cn');
  786. }
  787. $tableInfo = Db::query("SHOW COLUMNS FROM {$Prefix}users_recharge_pack");
  788. $tableInfo = get_arr_column($tableInfo, 'Field');
  789. if (!empty($tableInfo) && !in_array('pack_pay_prices', $tableInfo)){
  790. $sql = "ALTER TABLE `{$Prefix}users_recharge_pack` ADD COLUMN `pack_pay_prices` decimal(10,2) NOT NULL DEFAULT 0.00 COMMENT '会员充值套餐购买价格' AFTER `pack_face_value`;";
  791. @Db::execute($sql);
  792. if (in_array('pack_pay_prices', $tableInfo) && in_array('pack_buy_prices', $tableInfo)){
  793. @Db::execute("UPDATE `{$Prefix}users_recharge_pack` SET `pack_pay_prices`=`pack_buy_prices`;");
  794. }
  795. schemaTable('users_recharge_pack');
  796. }
  797. if (!empty($tableInfo) && in_array('pack_buy_prices', $tableInfo)){
  798. $sql = "ALTER TABLE `{$Prefix}users_recharge_pack` DROP COLUMN `pack_buy_prices`;";
  799. @Db::execute($sql);
  800. schemaTable('users_recharge_pack');
  801. }
  802. }
  803. /**
  804. * 创建索引
  805. * @return [type] [description]
  806. */
  807. private function syn_handle_create_index()
  808. {
  809. $admin_logic_1700621159 = tpSetting('syn.admin_logic_1700621159', [], 'cn');
  810. if (empty($admin_logic_1700621159)) {
  811. $Prefix = config('database.prefix');
  812. try {
  813. @Db::execute("CREATE INDEX `add_time` ON `{$Prefix}archives`(`add_time`) USING BTREE ;");
  814. } catch (\Exception $e) {}
  815. try {
  816. @Db::execute("CREATE INDEX `union_id` ON `{$Prefix}users`(`union_id`) USING BTREE ;");
  817. } catch (\Exception $e) {}
  818. try {
  819. @Db::execute("CREATE INDEX `username` ON `{$Prefix}users`(`username`) USING BTREE ;");
  820. } catch (\Exception $e) {}
  821. try {
  822. @Db::execute("CREATE INDEX `mobile` ON `{$Prefix}users`(`mobile`) USING BTREE ;");
  823. } catch (\Exception $e) {}
  824. try {
  825. @Db::execute("CREATE INDEX `open_id` ON `{$Prefix}users`(`open_id`) USING BTREE ;");
  826. } catch (\Exception $e) {}
  827. try {
  828. @Db::execute("CREATE INDEX `users_id` ON `{$Prefix}users_list`(`users_id`) USING BTREE ;");
  829. } catch (\Exception $e) {}
  830. tpSetting('syn', ['admin_logic_1700621159'=>1], 'cn');
  831. }
  832. }
  833. /**
  834. * 更新 远程图片本地化/清除非本站链接
  835. * @return [type] [description]
  836. */
  837. private function syn_handle_update_archives()
  838. {
  839. $syn_admin_logic_1700106425 = tpSetting('syn.syn_admin_logic_1700106425', [], 'cn');
  840. if (empty($syn_admin_logic_1700106425)) {
  841. try{
  842. $Prefix = config('database.prefix');
  843. $editor = tpSetting('editor');
  844. $editor_remote_img_local = !isset($editor['editor_remote_img_local']) ? 1 : intval($editor['editor_remote_img_local']);
  845. $editor_img_clear_link = !isset($editor['editor_img_clear_link']) ? 1 : intval($editor['editor_img_clear_link']);
  846. @Db::execute("UPDATE `{$Prefix}archives` SET `editor_remote_img_local`={$editor_remote_img_local};");
  847. @Db::execute("UPDATE `{$Prefix}archives` SET `editor_img_clear_link`={$editor_img_clear_link};");
  848. tpSetting('syn', ['syn_admin_logic_1700106425'=>1], 'cn');
  849. }catch(\Exception $e){}
  850. }
  851. }
  852. /**
  853. * 同步投稿提醒的模板
  854. * @return [type] [description]
  855. */
  856. private function syn_handle_tougao_tpl()
  857. {
  858. $syn_admin_logic_1700016487 = tpSetting('syn.syn_admin_logic_1700016487', [], 'cn');
  859. if (empty($syn_admin_logic_1700016487)) {
  860. try{
  861. $r = true;
  862. Db::name('sms_template')->where(['send_scene'=>20])->delete();
  863. $saveData = Db::name('sms_template')->field('tpl_id', true)->where(['send_scene'=>0])->select();
  864. if (!empty($saveData)) {
  865. $addData = [];
  866. foreach ($saveData as $key => $val) {
  867. $val['tpl_title'] = '投稿提醒';
  868. $val['send_scene'] = 20;
  869. $val['sms_sign'] = '';
  870. $val['sms_tpl_code'] = '';
  871. $val['tpl_content'] = '您有新的会员投稿,请查看!';
  872. $val['is_open'] = 0;
  873. $addData[] = $val;
  874. }
  875. $r = Db::name('sms_template')->insertAll($addData);
  876. }
  877. if ($r !== false) {
  878. tpSetting('syn', ['syn_admin_logic_1700016487'=>1], 'cn');
  879. }
  880. }catch(\Exception $e){}
  881. }
  882. $syn_admin_logic_1700016488 = tpSetting('syn.syn_admin_logic_1700016488', [], 'cn');
  883. if (empty($syn_admin_logic_1700016488)) {
  884. try{
  885. $r = true;
  886. Db::name('smtp_tpl')->where(['send_scene'=>20])->delete();
  887. $saveData = Db::name('smtp_tpl')->field('tpl_id', true)->where(['send_scene'=>2])->select();
  888. if (!empty($saveData)) {
  889. $addData = [];
  890. foreach ($saveData as $key => $val) {
  891. $val['tpl_name'] = '投稿提醒';
  892. $val['tpl_title'] = '您有新的投稿文档,请及时查看!';
  893. $val['send_scene'] = 20;
  894. $val['is_open'] = 0;
  895. $addData[] = $val;
  896. }
  897. $r = Db::name('smtp_tpl')->insertAll($addData);
  898. }
  899. if ($r !== false) {
  900. tpSetting('syn', ['syn_admin_logic_1700016488'=>1], 'cn');
  901. }
  902. }catch(\Exception $e){}
  903. }
  904. $syn_admin_logic_1700016489 = tpSetting('syn.syn_admin_logic_1700016489', [], 'cn');
  905. if (empty($syn_admin_logic_1700016489)) {
  906. try{
  907. $r = true;
  908. Db::name('users_notice_tpl')->where(['send_scene'=>20])->delete();
  909. $saveData = Db::name('users_notice_tpl')->field('tpl_id', true)->where(['send_scene'=>1])->select();
  910. if (!empty($saveData)) {
  911. $addData = [];
  912. foreach ($saveData as $key => $val) {
  913. $val['tpl_name'] = '投稿提醒';
  914. $val['tpl_title'] = '您有新的投稿文档,请及时查看!';
  915. $val['send_scene'] = 20;
  916. $val['is_open'] = 0;
  917. $addData[] = $val;
  918. }
  919. $r = Db::name('users_notice_tpl')->insertAll($addData);
  920. }
  921. if ($r !== false) {
  922. tpSetting('syn', ['syn_admin_logic_1700016489'=>1], 'cn');
  923. }
  924. }catch(\Exception $e){}
  925. }
  926. }
  927. /**
  928. * 处理外贸助手功能数据表
  929. * @return [type] [description]
  930. */
  931. private function syn_handle_foreign_pack()
  932. {
  933. $admin_logic_1699261141 = tpSetting('syn.admin_logic_1699261141', [], 'cn');
  934. if (empty($admin_logic_1699261141)) {
  935. $Prefix = config('database.prefix');
  936. $isTable = Db::query('SHOW TABLES LIKE \''.$Prefix.'foreign_pack\'');
  937. if (empty($isTable)) {
  938. $tableSql = <<<EOF
  939. CREATE TABLE IF NOT EXISTS `{$Prefix}foreign_pack` (
  940. `id` int(10) NOT NULL AUTO_INCREMENT COMMENT '自增ID',
  941. `type` int(4) DEFAULT '0' COMMENT '分类:1=列表,2=留言',
  942. `name` varchar(50) NOT NULL DEFAULT '' COMMENT '变量名',
  943. `value` text NOT NULL COMMENT '变量值',
  944. `lang` varchar(50) DEFAULT 'cn' COMMENT '语言标识',
  945. `sort_order` int(10) DEFAULT '0' COMMENT '排序号',
  946. `add_time` int(11) DEFAULT '0' COMMENT '新增时间',
  947. `update_time` int(11) DEFAULT '0' COMMENT '更新时间',
  948. PRIMARY KEY (`id`)
  949. ) ENGINE=MyISAM AUTO_INCREMENT=1 DEFAULT CHARSET=utf8 COMMENT='外贸助手语言包变量';
  950. EOF;
  951. $r = @Db::execute($tableSql);
  952. if ($r !== false) {
  953. schemaTable('foreign_pack');
  954. try {
  955. @Db::execute("INSERT INTO `{$Prefix}foreign_pack` VALUES ('1', '1', 'page1', '首页', 'cn', '100', '1543890216', '1543890216');");
  956. @Db::execute("INSERT INTO `{$Prefix}foreign_pack` VALUES ('2', '1', 'page2', '上一页', 'cn', '100', '1543890216', '1543890216');");
  957. @Db::execute("INSERT INTO `{$Prefix}foreign_pack` VALUES ('3', '1', 'page3', '下一页', 'cn', '100', '1543890216', '1543890216');");
  958. @Db::execute("INSERT INTO `{$Prefix}foreign_pack` VALUES ('4', '1', 'page4', '末页', 'cn', '100', '1543890216', '1543890216');");
  959. @Db::execute("INSERT INTO `{$Prefix}foreign_pack` VALUES ('5', '1', 'page5', '共<strong>%s</strong>页 <strong>%s</strong>条', 'cn', '100', '1543890216', '1543890216');");
  960. @Db::execute("INSERT INTO `{$Prefix}foreign_pack` VALUES ('6', '1', 'page1', 'Home', 'en', '100', '1543890216', '1543890216');");
  961. @Db::execute("INSERT INTO `{$Prefix}foreign_pack` VALUES ('7', '1', 'page2', 'Pre', 'en', '100', '1543890216', '1543890216');");
  962. @Db::execute("INSERT INTO `{$Prefix}foreign_pack` VALUES ('8', '1', 'page3', 'Next', 'en', '100', '1543890216', '1543890216');");
  963. @Db::execute("INSERT INTO `{$Prefix}foreign_pack` VALUES ('9', '1', 'page4', 'Last', 'en', '100', '1543890216', '1543890216');");
  964. @Db::execute("INSERT INTO `{$Prefix}foreign_pack` VALUES ('10', '1', 'page5', 'Road <strong>%s</strong> page <strong>%s</strong> strip', 'en', '100', '1543890216', '1543890216');");
  965. @Db::execute("INSERT INTO `{$Prefix}foreign_pack` VALUES ('11', '2', 'gbook1', '操作成功', 'cn', '100', '1543890216', '1543890216');");
  966. @Db::execute("INSERT INTO `{$Prefix}foreign_pack` VALUES ('12', '2', 'gbook1', 'success', 'en', '100', '1543890216', '1543890216');");
  967. @Db::execute("INSERT INTO `{$Prefix}foreign_pack` VALUES ('14', '2', 'gbook2', 'The same IP cannot be submitted repeatedly within %s seconds!', 'en', '100', '1543890216', '1543890216');");
  968. @Db::execute("INSERT INTO `{$Prefix}foreign_pack` VALUES ('13', '2', 'gbook2', '同一个IP在%s秒之内不能重复提交!', 'cn', '100', '1543890216', '1543890216');");
  969. @Db::execute("INSERT INTO `{$Prefix}foreign_pack` VALUES ('15', '2', 'gbook3', '%s不能为空!', 'cn', '100', '1543890216', '1543890216');");
  970. @Db::execute("INSERT INTO `{$Prefix}foreign_pack` VALUES ('16', '2', 'gbook3', '%s Cannot be empty!', 'en', '100', '1543890216', '1543890216');");
  971. @Db::execute("INSERT INTO `{$Prefix}foreign_pack` VALUES ('17', '2', 'gbook4', '%s格式不正确!', 'cn', '100', '1543890216', '1543890216');");
  972. @Db::execute("INSERT INTO `{$Prefix}foreign_pack` VALUES ('18', '2', 'gbook4', '%s Incorrect format!', 'en', '100', '1543890216', '1543890216');");
  973. @Db::execute("INSERT INTO `{$Prefix}foreign_pack` VALUES ('19', '2', 'gbook5', '图片验证码不能为空!', 'cn', '100', '1543890216', '1543890216');");
  974. @Db::execute("INSERT INTO `{$Prefix}foreign_pack` VALUES ('20', '2', 'gbook5', 'Picture verification code cannot be empty!', 'en', '100', '1543890216', '1543890216');");
  975. @Db::execute("INSERT INTO `{$Prefix}foreign_pack` VALUES ('21', '2', 'gbook6', '图片验证码不正确!', 'cn', '100', '1543890216', '1543890216');");
  976. @Db::execute("INSERT INTO `{$Prefix}foreign_pack` VALUES ('22', '2', 'gbook6', 'The picture verification code is incorrect!', 'en', '100', '1543890216', '1543890216');");
  977. @Db::execute("INSERT INTO `{$Prefix}foreign_pack` VALUES ('23', '2', 'gbook7', '请输入手机号码!', 'cn', '100', '1543890216', '1543890216');");
  978. @Db::execute("INSERT INTO `{$Prefix}foreign_pack` VALUES ('24', '2', 'gbook7', 'Please enter your mobile number!', 'en', '100', '1543890216', '1543890216');");
  979. @Db::execute("INSERT INTO `{$Prefix}foreign_pack` VALUES ('25', '2', 'gbook8', '手机号码和手机验证码不一致,请重新输入!', 'cn', '100', '1543890216', '1543890216');");
  980. @Db::execute("INSERT INTO `{$Prefix}foreign_pack` VALUES ('26', '2', 'gbook8', 'Mobile phone number and mobile phone verification code are inconsistent, please re-enter!', 'en', '100', '1543890216', '1543890216');");
  981. @Db::execute("INSERT INTO `{$Prefix}foreign_pack` VALUES ('27', '2', 'gbook9', '手机验证码已被使用或超时,请重新发送!', 'cn', '100', '1543890216', '1543890216');");
  982. @Db::execute("INSERT INTO `{$Prefix}foreign_pack` VALUES ('28', '2', 'gbook9', 'The mobile phone verification code has been used or timed out. Please resend it!', 'en', '100', '1543890216', '1543890216');");
  983. @Db::execute("INSERT INTO `{$Prefix}foreign_pack` VALUES ('29', '2', 'gbook10', '请输入手机验证码!', 'cn', '100', '1543890216', '1543890216');");
  984. @Db::execute("INSERT INTO `{$Prefix}foreign_pack` VALUES ('30', '2', 'gbook10', 'Please enter the mobile phone verification code!', 'en', '100', '1543890216', '1543890216');");
  985. @Db::execute("INSERT INTO `{$Prefix}foreign_pack` VALUES ('31', '2', 'gbook11', '表单缺少标签属性{\$field.hidden}', 'cn', '100', '1543890216', '1543890216');");
  986. @Db::execute("INSERT INTO `{$Prefix}foreign_pack` VALUES ('32', '2', 'gbook11', 'The form is missing label attribute {\$field.hidden}', 'en', '100', '1543890216', '1543890216');");
  987. @Db::execute("INSERT INTO `{$Prefix}foreign_pack` VALUES ('33', '2', 'gbook12', '页面自动 %s跳转%s 等待时间:', 'cn', '100', '1543890216', '1543890216');");
  988. @Db::execute("INSERT INTO `{$Prefix}foreign_pack` VALUES ('34', '2', 'gbook12', 'Page automatic %sjump%s waiting time:', 'en', '100', '1543890216', '1543890216');");
  989. @Db::execute("INSERT INTO `{$Prefix}foreign_pack` VALUES ('35', '2', 'gbook13', '%s至少选择一项!', 'cn', '100', '1543890216', '1543890216');");
  990. @Db::execute("INSERT INTO `{$Prefix}foreign_pack` VALUES ('36', '2', 'gbook13', 'Select at least one item to %s', 'en', '100', '1543890216', '1543890216');");
  991. @Db::execute("INSERT INTO `{$Prefix}foreign_pack` VALUES ('37', '2', 'gbook14', '请选择%s', 'cn', '100', '1543890216', '1543890216');");
  992. @Db::execute("INSERT INTO `{$Prefix}foreign_pack` VALUES ('38', '2', 'gbook14', 'Please select %s', 'en', '100', '1543890216', '1543890216');");
  993. @Db::execute("INSERT INTO `{$Prefix}foreign_pack` VALUES ('39', '2', 'gbook15', '请输入正确的手机号码!', 'cn', '100', '1543890216', '1543890216');");
  994. @Db::execute("INSERT INTO `{$Prefix}foreign_pack` VALUES ('40', '2', 'gbook15', 'Please enter the correct mobile number!', 'en', '100', '1543890216', '1543890216');");
  995. @Db::execute("INSERT INTO `{$Prefix}foreign_pack` VALUES ('41', '2', 'gbook16', '图片验证码', 'cn', '100', '1543890216', '1543890216');");
  996. @Db::execute("INSERT INTO `{$Prefix}foreign_pack` VALUES ('42', '2', 'gbook16', 'Picture verification code', 'en', '100', '1543890216', '1543890216');");
  997. @Db::execute("INSERT INTO `{$Prefix}foreign_pack` VALUES ('43', '2', 'gbook17', '手机验证码', 'cn', '100', '1543890216', '1543890216');");
  998. @Db::execute("INSERT INTO `{$Prefix}foreign_pack` VALUES ('44', '2', 'gbook17', 'Mobile verification code', 'en', '100', '1543890216', '1543890216');");
  999. @Db::execute("INSERT INTO `{$Prefix}foreign_pack` VALUES ('45', '2', 'gbook18', '获取验证码', 'cn', '100', '1543890216', '1543890216');");
  1000. @Db::execute("INSERT INTO `{$Prefix}foreign_pack` VALUES ('46', '2', 'gbook18', 'Get verification code', 'en', '100', '1543890216', '1543890216');");
  1001. @Db::execute("INSERT INTO `{$Prefix}foreign_pack` VALUES ('47', '2', 'gbook19', '看不清?点击更换验证码', 'cn', '100', '1543890216', '1543890216');");
  1002. @Db::execute("INSERT INTO `{$Prefix}foreign_pack` VALUES ('48', '2', 'gbook19', 'Can\'t see clearly? Click to change the verification code', 'en', '100', '1543890216', '1543890216');");
  1003. @Db::execute("INSERT INTO `{$Prefix}foreign_pack` VALUES ('49', '2', 'gbook20', '看不清?%s点击更换%s', 'cn', '100', '1543890216', '1543890216');");
  1004. @Db::execute("INSERT INTO `{$Prefix}foreign_pack` VALUES ('50', '2', 'gbook20', 'Can\'t see clearly? %sClick to replace%s', 'en', '100', '1543890216', '1543890216');");
  1005. } catch (\Exception $e) {
  1006. }
  1007. }
  1008. tpSetting('syn', ['admin_logic_1699261141'=>1], 'cn');
  1009. }
  1010. }
  1011. }
  1012. /**
  1013. * 处理回收站开关,多语言情况下同步
  1014. * @return [type] [description]
  1015. */
  1016. private function syn_handle_recycle_switch()
  1017. {
  1018. $admin_logic_1698799687 = tpSetting('syn.admin_logic_1698799687', [], 'cn');
  1019. if (empty($admin_logic_1698799687)) {
  1020. $web_recycle_switch = Db::name('setting')->where(['name'=>'recycle_switch', 'inc_type'=>'recycle'])->value('value');
  1021. $web_recycle_switch = intval($web_recycle_switch);
  1022. /*多语言*/
  1023. if (is_language()) {
  1024. $langRow = \think\Db::name('language')->order('id asc')
  1025. ->cache(true, EYOUCMS_CACHE_TIME, 'language')
  1026. ->select();
  1027. foreach ($langRow as $key => $val) {
  1028. tpCache('web', ['web_recycle_switch'=>$web_recycle_switch], $val['mark']);
  1029. }
  1030. } else {
  1031. tpCache('web', ['web_recycle_switch'=>$web_recycle_switch]);
  1032. }
  1033. /*--end*/
  1034. tpSetting('syn', ['admin_logic_1698799687'=>1], 'cn');
  1035. }
  1036. }
  1037. /**
  1038. * 同步处理在添加多语言时,友情链接分组没有同步到其他语言里
  1039. * @return [type] [description]
  1040. */
  1041. private function syn_handle_linksgroupdata()
  1042. {
  1043. $admin_logic_1698733259 = tpSetting('syn.admin_logic_1698733259', [], 'cn');
  1044. if (empty($admin_logic_1698733259)) {
  1045. $r = true;
  1046. $main_lang = get_main_lang();
  1047. $linksGroupList = Db::name('links_group')->order('lang asc, id asc')->select();
  1048. $languageAttributeList = Db::name('language_attribute')->where(['attr_group'=>'links_group'])->order('attr_name asc')->getAllWithIndex('attr_name');
  1049. $addData = [];
  1050. foreach ($linksGroupList as $key => $val) {
  1051. if ($main_lang == $val['lang']) {
  1052. if (!isset($languageAttributeList['linksgroup'.$val['id']])) {
  1053. $addData[] = [
  1054. 'attr_title' => $val['group_name'],
  1055. 'attr_name' => "linksgroup{$val['id']}",
  1056. 'attr_group' => 'links_group',
  1057. 'add_time' => getTime(),
  1058. 'update_time' => getTime(),
  1059. ];
  1060. }
  1061. }
  1062. }
  1063. if (!empty($addData)) {
  1064. $r = Db::name('language_attribute')->insertAll($addData);
  1065. }
  1066. if ($r !== false) {
  1067. $languageAttrList = Db::name('language_attr')->where(['attr_group'=>'links_group'])->order('lang asc, attr_name asc')->getAllWithIndex('attr_value');
  1068. $addData = [];
  1069. foreach ($linksGroupList as $key => $val) {
  1070. if (!isset($languageAttrList[$val['id']])) {
  1071. $addData[] = [
  1072. 'attr_name' => "linksgroup{$val['id']}",
  1073. 'attr_value' => $val['id'],
  1074. 'attr_group' => 'links_group',
  1075. 'lang' => $val['lang'],
  1076. 'add_time' => getTime(),
  1077. 'update_time' => getTime(),
  1078. ];
  1079. }
  1080. }
  1081. if (!empty($addData)) {
  1082. $r = Db::name('language_attr')->insertAll($addData);
  1083. }
  1084. if ($r !== false) {
  1085. tpSetting('syn', ['admin_logic_1698733259'=>1], 'cn');
  1086. }
  1087. }
  1088. }
  1089. }
  1090. /**
  1091. * 同步处理在添加多语言时,表单属性没有同步到其他语言里
  1092. * @return [type] [description]
  1093. */
  1094. private function syn_handle_formdata()
  1095. {
  1096. $admin_logic_1698716726 = tpSetting('syn.admin_logic_1698716726', [], 'cn');
  1097. if (empty($admin_logic_1698716726)) {
  1098. $r = true;
  1099. $formAttributeList = Db::name('guestbook_attribute')->where(['form_type'=>1])->order('typeid asc, attr_id asc')->select();
  1100. $languageAttrList = Db::name('language_attr')->where(['attr_group'=>'form_attribute'])->order('lang asc, attr_name asc')->getAllWithIndex('attr_value');
  1101. $addData = [];
  1102. foreach ($formAttributeList as $key => $val) {
  1103. if (!isset($languageAttrList[$val['attr_id']])) {
  1104. $addData[] = [
  1105. 'attr_name' => "attr_{$val['attr_id']}",
  1106. 'attr_value' => $val['attr_id'],
  1107. 'attr_group' => 'form_attribute',
  1108. 'lang' => $val['lang'],
  1109. 'add_time' => getTime(),
  1110. 'update_time' => getTime(),
  1111. ];
  1112. }
  1113. }
  1114. if (!empty($addData)) {
  1115. $r = Db::name('language_attr')->insertAll($addData);
  1116. }
  1117. if ($r !== false) {
  1118. tpSetting('syn', ['admin_logic_1698716726'=>1], 'cn');
  1119. }
  1120. }
  1121. }
  1122. // 移除没有使用的功能模块,在index控制器也在用,要一起去掉
  1123. public function eyou_v165_del_func()
  1124. {
  1125. // $admin_logic_1694048251 = tpSetting('syn.admin_logic_1694048251', [], 'cn');
  1126. // if (empty($admin_logic_1694048251)) {
  1127. // $shopLogic = new \app\admin\logic\ShopLogic;
  1128. // // 列出营销功能里已使用的模块
  1129. // $marketFunc = $shopLogic->marketLogic();
  1130. // if (empty($marketFunc)) {
  1131. // Db::name('admin_menu')->where(['menu_id'=>2008005])->update(['is_menu'=>0, 'update_time'=>getTime()]);
  1132. // }
  1133. // // 列出功能地图里已使用的模块
  1134. // $useFunc = $shopLogic->useFuncLogic();
  1135. // if (!in_array('memgift', $useFunc)) {
  1136. // Db::name('admin_menu')->where(['menu_id'=>2004023])->update(['is_menu'=>0, 'update_time'=>getTime()]);
  1137. // }
  1138. // tpSetting('syn', ['admin_logic_1694048251'=>1], 'cn');
  1139. // }
  1140. }
  1141. private function add_haiwai_region()
  1142. {
  1143. $admin_logic_1677555001 = tpSetting('syn.admin_logic_1677555001', [], 'cn');
  1144. if (empty($admin_logic_1677555001)) {
  1145. $count = Db::name('region')->where(['name'=>'海外','level'=>1])->count();
  1146. if (empty($count)) {
  1147. $insertid1 = Db::name('region')->insertGetId([
  1148. 'name' => '海外',
  1149. 'level' => 1,
  1150. 'parent_id' => 0,
  1151. 'initial' => 'H',
  1152. ]);
  1153. if (!empty($insertid1)) {
  1154. $insertid2 = Db::name('region')->insertGetId([
  1155. 'name' => '海外',
  1156. 'level' => 2,
  1157. 'parent_id' => $insertid1,
  1158. 'initial' => 'H',
  1159. ]);
  1160. if (!empty($insertid2)) {
  1161. Db::name('region')->insertGetId([
  1162. 'name' => '海外',
  1163. 'level' => 3,
  1164. 'parent_id' => $insertid2,
  1165. 'initial' => 'H',
  1166. ]);
  1167. }
  1168. tpSetting('syn', ['admin_logic_1677555001'=>1], 'cn');
  1169. }
  1170. }
  1171. }
  1172. }
  1173. private function add_henan_jiyuan_region()
  1174. {
  1175. $admin_logic_1698388181 = tpSetting('syn.admin_logic_1698388181', [], 'cn');
  1176. if (empty($admin_logic_1698388181)) {
  1177. $count = Db::name('region')->where(['name'=>'济源市','parent_id'=>21387])->count();
  1178. if (empty($count)) {
  1179. $insertid2 = Db::name('region')->insertGetId([
  1180. 'name' => '济源市',
  1181. 'level' => 2,
  1182. 'parent_id' => 21387,
  1183. 'initial' => 'J',
  1184. ]);
  1185. if (!empty($insertid2)) {
  1186. Db::name('region')->insertAll([
  1187. [
  1188. 'name' => '沁园街道',
  1189. 'level' => 3,
  1190. 'parent_id' => $insertid2,
  1191. 'initial' => 'Q',
  1192. ],
  1193. [
  1194. 'name' => '济水街道',
  1195. 'level' => 3,
  1196. 'parent_id' => $insertid2,
  1197. 'initial' => 'J',
  1198. ],
  1199. [
  1200. 'name' => '北海街道',
  1201. 'level' => 3,
  1202. 'parent_id' => $insertid2,
  1203. 'initial' => 'B',
  1204. ],
  1205. [
  1206. 'name' => '天坛街道',
  1207. 'level' => 3,
  1208. 'parent_id' => $insertid2,
  1209. 'initial' => 'T',
  1210. ],
  1211. [
  1212. 'name' => '玉泉街道',
  1213. 'level' => 3,
  1214. 'parent_id' => $insertid2,
  1215. 'initial' => 'Y',
  1216. ],
  1217. [
  1218. 'name' => '克井镇',
  1219. 'level' => 3,
  1220. 'parent_id' => $insertid2,
  1221. 'initial' => 'K',
  1222. ],
  1223. [
  1224. 'name' => '五龙口镇',
  1225. 'level' => 3,
  1226. 'parent_id' => $insertid2,
  1227. 'initial' => 'W',
  1228. ],
  1229. [
  1230. 'name' => '轵城镇',
  1231. 'level' => 3,
  1232. 'parent_id' => $insertid2,
  1233. 'initial' => 'Z',
  1234. ],
  1235. [
  1236. 'name' => '承留镇',
  1237. 'level' => 3,
  1238. 'parent_id' => $insertid2,
  1239. 'initial' => 'C',
  1240. ],
  1241. [
  1242. 'name' => '邵原镇',
  1243. 'level' => 3,
  1244. 'parent_id' => $insertid2,
  1245. 'initial' => 'S',
  1246. ],
  1247. [
  1248. 'name' => '坡头镇',
  1249. 'level' => 3,
  1250. 'parent_id' => $insertid2,
  1251. 'initial' => 'P',
  1252. ],
  1253. [
  1254. 'name' => '梨林镇',
  1255. 'level' => 3,
  1256. 'parent_id' => $insertid2,
  1257. 'initial' => 'L',
  1258. ],
  1259. [
  1260. 'name' => '大峪镇',
  1261. 'level' => 3,
  1262. 'parent_id' => $insertid2,
  1263. 'initial' => 'D',
  1264. ],
  1265. [
  1266. 'name' => '思礼镇',
  1267. 'level' => 3,
  1268. 'parent_id' => $insertid2,
  1269. 'initial' => 'S',
  1270. ],
  1271. [
  1272. 'name' => '王屋镇',
  1273. 'level' => 3,
  1274. 'parent_id' => $insertid2,
  1275. 'initial' => 'W',
  1276. ],
  1277. [
  1278. 'name' => '下冶镇',
  1279. 'level' => 3,
  1280. 'parent_id' => $insertid2,
  1281. 'initial' => 'X',
  1282. ],
  1283. ]);
  1284. tpSetting('syn', ['admin_logic_1698388181'=>1], 'cn');
  1285. }
  1286. }
  1287. }
  1288. }
  1289. // 添加商城订单主表字段(消费获得积分数(obtain_scores);订单是否已赠送积分(is_obtain_scores))
  1290. public function admin_logic_1677653220()
  1291. {
  1292. $Prefix = config('database.prefix');
  1293. // 订单表字段查询
  1294. $shopOrderTableInfo = Db::query("SHOW COLUMNS FROM {$Prefix}shop_order");
  1295. $shopOrderTableInfo = get_arr_column($shopOrderTableInfo, 'Field');
  1296. // 订单是否允许申请售后维权
  1297. if (!empty($shopOrderTableInfo) && !in_array('allow_service', $shopOrderTableInfo)) {
  1298. $sql0 = "ALTER TABLE `{$Prefix}shop_order` ADD COLUMN `allow_service` tinyint(1) UNSIGNED NOT NULL DEFAULT 0 COMMENT '订单是否允许申请售后维权,0=允许申请维权,1=不允许申请维权' AFTER `confirm_time`";
  1299. @Db::execute($sql0);
  1300. schemaTable('shop_order');
  1301. }
  1302. // 消费获得积分数
  1303. if (!empty($shopOrderTableInfo) && !in_array('obtain_scores', $shopOrderTableInfo)) {
  1304. $sql1 = "ALTER TABLE `{$Prefix}shop_order` ADD COLUMN `obtain_scores` int(11) UNSIGNED NOT NULL DEFAULT 0 COMMENT '消费获得积分数' AFTER `allow_service`;";
  1305. @Db::execute($sql1);
  1306. schemaTable('shop_order');
  1307. }
  1308. // 该订单是否已赠送积分
  1309. if (!empty($shopOrderTableInfo) && !in_array('is_obtain_scores', $shopOrderTableInfo)) {
  1310. $sql2 = "ALTER TABLE `{$Prefix}shop_order` ADD COLUMN `is_obtain_scores` tinyint(1) UNSIGNED NOT NULL DEFAULT 0 COMMENT '该订单是否已赠送积分,0=未赠送,1=已赠送' AFTER `obtain_scores`;";
  1311. @Db::execute($sql2);
  1312. schemaTable('shop_order');
  1313. }
  1314. }
  1315. // 更新会员积分数据表,积分类型字段 type
  1316. public function admin_logic_1680749290()
  1317. {
  1318. $admin_logic_1680749290 = tpSetting('syn.admin_logic_1680749290', [], 'cn');
  1319. if (empty($admin_logic_1680749290)) {
  1320. // 表前缀
  1321. $Prefix = config('database.prefix');
  1322. // 会员积分表更新
  1323. $sql = "ALTER TABLE `{$Prefix}users_score` MODIFY COLUMN `type` tinyint(2) NULL DEFAULT 1 COMMENT '类型:1-提问,2-回答,3-最佳答案4-悬赏退回,5-每日签到,6-管理员编辑,7-问题悬赏/获得悬赏,8-消费赠送积分,9-积分兑换/退回,10-登录赠送积分' AFTER `id`;";
  1324. @Db::execute($sql);
  1325. schemaTable('users_score');
  1326. // 增加会员登录日志表
  1327. $isTable = Db::query('SHOW TABLES LIKE \''.$Prefix.'users_login_log\'');
  1328. if (empty($isTable)) {
  1329. $tableSql = <<<EOF
  1330. CREATE TABLE IF NOT EXISTS `{$Prefix}users_login_log` (
  1331. `log_id` int(11) unsigned NOT NULL AUTO_INCREMENT COMMENT '会员日志自增ID',
  1332. `users_id` int(11) unsigned NOT NULL DEFAULT '0' COMMENT '会员ID',
  1333. `log_time` int(11) unsigned NOT NULL DEFAULT '0' COMMENT '日志时间,年月日(例:20230406)',
  1334. `log_count` int(11) unsigned NOT NULL DEFAULT '0' COMMENT '日志次数',
  1335. `add_time` int(11) unsigned NOT NULL DEFAULT '0' COMMENT '创建时间',
  1336. `update_time` int(11) unsigned NOT NULL DEFAULT '0' COMMENT '更新时间',
  1337. PRIMARY KEY (`log_id`),
  1338. UNIQUE KEY `users_id` (`users_id`) USING BTREE
  1339. ) ENGINE=MyISAM DEFAULT CHARSET=utf8 COMMENT='会员登录日志';
  1340. EOF;
  1341. $result = @Db::execute($tableSql);
  1342. if ($result !== false) schemaTable('users_login_log');
  1343. }
  1344. // 设置已完成执行
  1345. tpSetting('syn', ['admin_logic_1680749290'=>1], 'cn');
  1346. }
  1347. }
  1348. /**
  1349. * 更新旧的商品虚拟总销量
  1350. * @return [type] [description]
  1351. */
  1352. private function handleProductSalesAll()
  1353. {
  1354. $admin_logic_1675243579 = tpSetting('syn.admin_logic_1675243579', [], 'cn');
  1355. if (empty($admin_logic_1675243579)) {
  1356. $productList = Db::name('archives')->field('aid,sales_num,virtual_sales,sales_all')
  1357. ->where(['channel'=>2])
  1358. ->select();
  1359. if (!empty($productList)) {
  1360. $specList = Db::name('product_spec_data')->field('aid,count(aid) as total')
  1361. ->group('aid')
  1362. ->getAllWithIndex('aid');
  1363. $salesList = Db::name('product_spec_value')->field('aid,sum(spec_sales_num) as spec_sales_num,count(aid) as spec_counts')
  1364. ->group('aid')
  1365. ->getAllWithIndex('aid');
  1366. $saveData = [];
  1367. foreach ($productList as $key => $val) {
  1368. if (!empty($specList[$val['aid']]['total'])) { // 多规格
  1369. $spec_counts = empty($salesList[$val['aid']]['spec_counts']) ? 0 : $salesList[$val['aid']]['spec_counts'];
  1370. $spec_sales_num = empty($salesList[$val['aid']]['spec_sales_num']) ? 0 : $salesList[$val['aid']]['spec_sales_num'];
  1371. $saveData[] = [
  1372. 'aid' => $val['aid'],
  1373. 'sales_all' => $spec_sales_num, // + ($spec_counts * $val['virtual_sales']),
  1374. ];
  1375. } else {
  1376. $saveData[] = [
  1377. 'aid' => $val['aid'],
  1378. 'sales_all' => $val['sales_num'] + $val['virtual_sales'],
  1379. ];
  1380. }
  1381. }
  1382. if (!empty($saveData)) {
  1383. model('Archives')->saveAll($saveData);
  1384. }
  1385. }
  1386. tpSetting('syn', ['admin_logic_1675243579'=>1], 'cn');
  1387. }
  1388. }
  1389. /**
  1390. * 同步模板的付费选择支付文件到前台模板指定位置
  1391. * @return [type] [description]
  1392. */
  1393. public function copy_tplpayfile($channel = 0)
  1394. {
  1395. $shop_open_comment = getUsersConfigData('shop.shop_open_comment');
  1396. $channelRow = Db::name('channeltype')->where(['status'=>1])->getAllWithIndex('id');
  1397. foreach ($channelRow as $key => $val) {
  1398. $data = json_decode($val['data'], true);
  1399. $val['data'] = empty($data) ? [] : $data;
  1400. $channelRow[$key] = $val;
  1401. }
  1402. $source_path = ROOT_PATH.'public/html/template/';
  1403. $dest_path = ROOT_PATH.'template/'.THEME_STYLE_PATH.'/system/';
  1404. if (stristr($dest_path, '/pc/system/')) {
  1405. tp_mkdir($dest_path);
  1406. if (!empty($channelRow[1]['data']['is_article_pay'])) {
  1407. if (in_array($channel, [0,1]) && !file_exists($dest_path.'article_pay.htm') && file_exists($source_path.'pc/system/article_pay.htm')) {
  1408. @copy($source_path.'pc/system/article_pay.htm', $dest_path.'article_pay.htm');
  1409. }
  1410. }
  1411. if (!empty($channelRow[4]['data']['is_download_pay'])) {
  1412. if (in_array($channel, [0,4]) && !file_exists($dest_path.'download_pay.htm') && file_exists($source_path.'pc/system/download_pay.htm')) {
  1413. @copy($source_path.'pc/system/download_pay.htm', $dest_path.'download_pay.htm');
  1414. }
  1415. }
  1416. if (!empty($shop_open_comment)) {
  1417. if (in_array($channel, [0,2]) && !file_exists($dest_path.'product_comment.htm') && file_exists($source_path.'pc/system/product_comment.htm')) {
  1418. @copy($source_path.'pc/system/product_comment.htm', $dest_path.'product_comment.htm');
  1419. }
  1420. }
  1421. }
  1422. $dest_path = ROOT_PATH.'template/'.THEME_STYLE_PATH;
  1423. $dest_path = preg_replace('/\/pc$/i', '/mobile', $dest_path);
  1424. if (file_exists($dest_path)) {
  1425. $dest_path .= '/system/';
  1426. tp_mkdir($dest_path);
  1427. if (!empty($channelRow[1]['data']['is_article_pay'])) {
  1428. if (in_array($channel, [0,1]) && !file_exists($dest_path.'article_pay.htm') && file_exists($source_path.'mobile/system/article_pay.htm')) {
  1429. @copy($source_path.'mobile/system/article_pay.htm', $dest_path.'article_pay.htm');
  1430. }
  1431. }
  1432. if (!empty($channelRow[4]['data']['is_download_pay'])) {
  1433. if (in_array($channel, [0,4]) && !file_exists($dest_path.'download_pay.htm') && file_exists($source_path.'mobile/system/download_pay.htm')) {
  1434. @copy($source_path.'mobile/system/download_pay.htm', $dest_path.'download_pay.htm');
  1435. }
  1436. }
  1437. if (!empty($shop_open_comment)) {
  1438. if (in_array($channel, [0,2]) && !file_exists($dest_path.'product_comment.htm') && file_exists($source_path.'mobile/system/product_comment.htm')) {
  1439. @copy($source_path.'mobile/system/product_comment.htm', $dest_path.'product_comment.htm');
  1440. }
  1441. if (in_array($channel, [0,2]) && !file_exists($dest_path.'comment_list.htm') && file_exists($source_path.'mobile/system/comment_list.htm')) {
  1442. @copy($source_path.'mobile/system/comment_list.htm', $dest_path.'comment_list.htm');
  1443. }
  1444. }
  1445. }
  1446. }
  1447. public function admin_logic_1685094852()
  1448. {
  1449. $syn_admin_logic_1685094852 = tpSetting('syn.admin_logic_1685094852', [], 'cn');
  1450. if (empty($syn_admin_logic_1685094852)) {
  1451. $articlePay = Db::name('article_pay')->field('id, size, update_time')->select();
  1452. if (!empty($articlePay)) {
  1453. foreach ($articlePay as $key => $value) {
  1454. $value['size'] = intval(floatval($value['size']) * floatval(1024));
  1455. $value['update_time'] = getTime();
  1456. Db::name('article_pay')->where('id', $value['id'])->update($value);
  1457. }
  1458. }
  1459. tpSetting('syn', ['admin_logic_1685094852'=>1], 'cn');
  1460. }
  1461. }
  1462. // 运费模板数据同步--陈风任
  1463. public function admin_logic_1687687709()
  1464. {
  1465. $syn_admin_logic_1687687709 = tpSetting('syn.admin_logic_1687687709', [], 'cn');
  1466. if (empty($syn_admin_logic_1687687709)) {
  1467. // 查询地址表是否存在海外区域
  1468. $where = [
  1469. 'level' => 1,
  1470. 'name' => '海外',
  1471. 'parent_id' => 0,
  1472. ];
  1473. $region = Db::name('region')->where($where)->find();
  1474. // 查询运费模板表是否已添加海外区域
  1475. $where = [
  1476. 'province_id' => $region['id'],
  1477. 'template_region' => $region['name'],
  1478. ];
  1479. $template = Db::name('shop_shipping_template')->where($where)->find();
  1480. // 判断是否需要添加运费模板数据
  1481. if (!empty($region) && empty($template)) {
  1482. // 添加运费模板数据
  1483. $insert = [
  1484. 'update_time' => getTime(),
  1485. 'province_id' => $region['id'],
  1486. 'template_region' => $region['name'],
  1487. ];
  1488. Db::name('shop_shipping_template')->insert($insert);
  1489. }
  1490. tpSetting('syn', ['admin_logic_1687687709'=>1], 'cn');
  1491. }
  1492. }
  1493. /**
  1494. * 主题风格同步兼容旧版本数据
  1495. * @return [type] [description]
  1496. */
  1497. private function theme_syn_olddata()
  1498. {
  1499. $admin_logic_1681199467 = tpSetting('syn.admin_logic_1681199467', [], 'cn');
  1500. if (empty($admin_logic_1681199467)) {
  1501. $count = Db::name('admin_theme')->where(['is_system'=>0,'theme_type'=>1])->count();
  1502. if (empty($count)) {
  1503. $globalConfig = tpCache('global');
  1504. // 后台logo/登录logo
  1505. if (-1 == $globalConfig['web_is_authortoken']) {
  1506. if (empty($globalConfig['web_adminlogo'])) {
  1507. $globalConfig['web_adminlogo'] = ROOT_DIR.'/public/static/admin/images/logo_ey.png';
  1508. }
  1509. if (empty($globalConfig['web_loginlogo'])) {
  1510. $globalConfig['web_loginlogo'] = ROOT_DIR.'/public/static/admin/images/login-logo_ey.png';
  1511. }
  1512. } else {
  1513. if (empty($globalConfig['web_adminlogo'])) {
  1514. $globalConfig['web_adminlogo'] = ROOT_DIR.'/public/static/admin/images/logo.png';
  1515. }
  1516. if (empty($globalConfig['web_loginlogo'])) {
  1517. if ($globalConfig['php_servicemeal'] >= 2) {
  1518. $globalConfig['web_loginlogo'] = ROOT_DIR.'/public/static/admin/images/login-logo_zy.png';
  1519. } else {
  1520. $globalConfig['web_loginlogo'] = ROOT_DIR.'/public/static/admin/images/login-logo.png';
  1521. }
  1522. }
  1523. }
  1524. $addData = [
  1525. 'theme_type' => 1,
  1526. 'theme_title' => '默认主题',
  1527. 'theme_pic' => ROOT_DIR.'/public/static/admin/images/theme/theme_pic_default.png',
  1528. 'theme_color_model' => empty($globalConfig['web_theme_color_model']) ? 1 : $globalConfig['web_theme_color_model'],
  1529. 'theme_main_color' => empty($globalConfig['web_theme_color']) ? '#3398cc' : $globalConfig['web_theme_color'],
  1530. 'theme_assist_color' => empty($globalConfig['web_assist_color']) ? '#2189be' : $globalConfig['web_assist_color'],
  1531. 'login_logo' => empty($globalConfig['web_loginlogo']) ? ROOT_DIR.'/public/static/admin/login/login-logo.png' : $globalConfig['web_loginlogo'],
  1532. 'login_bgimg_model' => empty($globalConfig['web_loginbgimg_model']) ? 1 : $globalConfig['web_loginbgimg_model'],
  1533. 'login_bgimg' => empty($globalConfig['web_loginbgimg']) ? ROOT_DIR.'/public/static/admin/loginbg/login-bg-1.png' : $globalConfig['web_loginbgimg'],
  1534. 'login_tplname' => '',
  1535. 'admin_logo' => empty($globalConfig['web_adminlogo']) ? ROOT_DIR.'/public/static/admin/logo/logo.png' : $globalConfig['web_adminlogo'],
  1536. 'welcome_tplname' => '',
  1537. 'is_system' => 0,
  1538. 'sort_order' => 100,
  1539. 'lang' => get_admin_lang(),
  1540. 'add_time' => getTime(),
  1541. 'update_time' => getTime(),
  1542. ];
  1543. $theme_id = Db::name('admin_theme')->insertGetId($addData);
  1544. if (!empty($theme_id)) {
  1545. /*多语言*/
  1546. if (is_language()) {
  1547. $langRow = \think\Db::name('language')->order('id asc')
  1548. ->cache(true, EYOUCMS_CACHE_TIME, 'language')
  1549. ->select();
  1550. foreach ($langRow as $key => $val) {
  1551. tpCache('web', ['web_theme_styleid'=>$theme_id], $val['mark']);
  1552. }
  1553. } else {
  1554. tpCache('web', ['web_theme_styleid'=>$theme_id]);
  1555. }
  1556. /*--end*/
  1557. tpSetting('syn', ['admin_logic_1681199467'=>1], 'cn');
  1558. }
  1559. }
  1560. }
  1561. }
  1562. }