Нет описания
Вы не можете выбрать более 25 тем Темы должны начинаться с буквы или цифры, могут содержать дефисы(-) и должны содержать не более 35 символов.

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125
  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\controller;
  14. use think\Db;
  15. use think\Cache;
  16. use think\Request;
  17. use think\Page;
  18. class System extends Base
  19. {
  20. // 选项卡是否显示
  21. public $tabase = '';
  22. public function _initialize() {
  23. parent::_initialize();
  24. $this->tabase = input('param.tabase/d');
  25. }
  26. public function index()
  27. {
  28. $this->redirect(url('System/web'));
  29. }
  30. /**
  31. * 网站设置
  32. */
  33. public function web()
  34. {
  35. $inc_type = 'web';
  36. $config = tpCache($inc_type);
  37. if (IS_POST) {
  38. $param = input('post.');
  39. $param['web_basehost'] = preg_replace('/<script([^\>]*)>([\s\S]+)<\/script>/i', '', $param['web_basehost']);
  40. $param['web_title'] = preg_replace('/<script([^\>]*)>([\s\S]+)<\/script>/i', '', $param['web_title']);
  41. $param['web_keywords'] = str_replace(',', ',', $param['web_keywords']);
  42. $param['web_keywords'] = preg_replace('/<script([^\>]*)>([\s\S]+)<\/script>/i', '', $param['web_keywords']);
  43. $param['web_description'] = filter_line_return($param['web_description']);
  44. $param['web_description'] = preg_replace('/<script([^\>]*)>([\s\S]+)<\/script>/i', '', $param['web_description']);
  45. $param['web_status_url'] = trim($param['web_status_url']);
  46. $web_status_tpl = trim($param['web_status_tpl']);
  47. $web_status_tpl = trim($web_status_tpl, '/');
  48. if (!empty($this->root_dir)) {
  49. $web_status_tpl = preg_replace('#^'.$this->root_dir.'/#i', '', '/'.$web_status_tpl);
  50. $web_status_tpl = trim($web_status_tpl, '/');
  51. }
  52. $param['web_status_tpl'] = $web_status_tpl;
  53. if (1 == $param['web_status']) {
  54. /*多语言 - 不知为何v1.4.0新增该逻辑【在静态模式下,关闭网站会自动切换为动态URL模式】*/
  55. // $seo_pseudo = tpCache('global.seo_pseudo');
  56. // if (2 == $seo_pseudo) {
  57. // if (is_language()) {
  58. // $langRow = \think\Db::name('language')->order('id asc')
  59. // ->cache(true, EYOUCMS_CACHE_TIME, 'language')
  60. // ->select();
  61. // foreach ($langRow as $key => $val) {
  62. // tpCache('seo',['seo_pseudo'=>1],$val['mark']);
  63. // }
  64. // } else {
  65. // tpCache('seo',['seo_pseudo'=>1]);
  66. // }
  67. // }
  68. /*--end*/
  69. @unlink('./index.html');
  70. }
  71. // 站点状态关闭时,所关闭的终端口(pc、mobile)
  72. // $param['web_close_port'] = !empty($param['web_close_port']) ? serialize($param['web_close_port']) : '';
  73. // 网站根网址
  74. $web_basehost = rtrim($param['web_basehost'], '/');
  75. if (!is_http_url($web_basehost) && !empty($web_basehost)) {
  76. $web_basehost = $this->request->scheme().'://'.$web_basehost;
  77. }
  78. $param['web_basehost'] = $web_basehost;
  79. // 网站logo
  80. // $web_logo = '';
  81. // $web_logo_is_remote = !empty($param['web_logo_is_remote']) ? $param['web_logo_is_remote'] : 0;
  82. // if ($web_logo_is_remote == 1) {
  83. // $web_logo = $param['web_logo_remote'];
  84. // } else {
  85. // $web_logo = $param['web_logo_local'];
  86. // }
  87. $param['web_logo'] = $param['web_logo_local'];
  88. // unset($param['web_logo_is_remote']);
  89. // unset($param['web_logo_remote']);
  90. unset($param['web_logo_local']);
  91. // 浏览器地址图标
  92. if (!empty($param['web_ico']) && !is_http_url($param['web_ico'])) {
  93. $source = realpath(preg_replace('#^'.$this->root_dir.'/#i', '', $param['web_ico']));
  94. $destination = realpath('favicon.ico');
  95. if (empty($destination) || $source == $destination) {
  96. unset($param['web_ico']);
  97. } else {
  98. /*修复copy一句话图片木马漏洞*/
  99. $image_ext = config('global.image_ext');
  100. $image_ext_arr = explode(',', $image_ext);
  101. $source_ext = pathinfo($source, PATHINFO_EXTENSION);
  102. if (!empty($source_ext) && !in_array($source_ext, $image_ext_arr)) {
  103. $this->error('地址栏图标必须是ico扩展名的图片');
  104. }
  105. /*end*/
  106. if (file_exists($source) && @copy($source, $destination)) {
  107. $param['web_ico'] = $this->root_dir.'/favicon.ico';
  108. }
  109. }
  110. }
  111. $param['web_recordnum'] = preg_replace('/<script([^\>]*)>([\s\S]+)<\/script>/i', '', $param['web_recordnum']);
  112. $param['web_garecordnum'] = preg_replace('/<script([^\>]*)>([\s\S]+)<\/script>/i', '', $param['web_garecordnum']);
  113. tpCache($inc_type, $param);
  114. write_global_params($this->admin_lang); // 写入全局内置参数
  115. if ($config['web_basehost'] != $param['web_basehost']) {
  116. verify_authortoken();
  117. }
  118. $this->success('操作成功', url('System/web'));
  119. exit;
  120. }
  121. // 网站logo
  122. // if (is_http_url($config['web_logo'])) {
  123. // $config['web_logo_is_remote'] = 1;
  124. // $config['web_logo_remote'] = handle_subdir_pic($config['web_logo']);
  125. // } else {
  126. // $config['web_logo_is_remote'] = 0;
  127. // $config['web_logo_local'] = handle_subdir_pic($config['web_logo']);
  128. // }
  129. $config['web_logo_local'] = handle_subdir_pic($config['web_logo']);
  130. $config['web_ico'] = preg_replace('#^(/[/\w\-]+)?(/)#i', $this->root_dir.'$2', $config['web_ico']); // 支持子目录
  131. /*系统模式*/
  132. $web_cmsmode = isset($config['web_cmsmode']) ? $config['web_cmsmode'] : 2;
  133. $this->assign('web_cmsmode', $web_cmsmode);
  134. /*--end*/
  135. /*自定义变量*/
  136. $eyou_row = Db::name('config_attribute')->field('a.attr_id, a.attr_name, a.attr_var_name, a.attr_input_type, b.value, b.id, b.name')
  137. ->alias('a')
  138. ->join('__CONFIG__ b', 'b.name = a.attr_var_name AND b.lang = a.lang', 'LEFT')
  139. ->where([
  140. 'b.lang' => $this->admin_lang,
  141. 'a.inc_type' => $inc_type,
  142. 'b.is_del' => 0,
  143. ])
  144. ->order('a.attr_id asc')
  145. ->select();
  146. foreach ($eyou_row as $key => $val) {
  147. $val['value'] = handle_subdir_pic($val['value'], 'html'); // 支持子目录
  148. $val['value'] = handle_subdir_pic($val['value']); // 支持子目录
  149. $eyou_row[$key] = $val;
  150. }
  151. $this->assign('eyou_row',$eyou_row);
  152. /*--end*/
  153. // 站点状态关闭时,所关闭的终端口(pc、mobile)
  154. // $config['web_close_port'] = !empty($config['web_close_port']) ? unserialize($config['web_close_port']) : ['pc', 'mobile'];
  155. $this->assign('config',$config);//当前配置项
  156. $this->assign('seo_pseudo', tpCache('global.seo_pseudo')); // URL模式
  157. return $this->fetch();
  158. }
  159. /**
  160. * 自定义变量
  161. */
  162. public function customvar()
  163. {
  164. $inc_type = 'web';
  165. if (IS_POST) {
  166. $param = input('post.');
  167. tpCache($inc_type, $param);
  168. write_global_params($this->admin_lang); // 写入全局内置参数
  169. $this->success('操作成功', url('System/customvar'));
  170. exit;
  171. }
  172. $config = tpCache($inc_type);
  173. /*系统模式*/
  174. $web_cmsmode = isset($config['web_cmsmode']) ? $config['web_cmsmode'] : 2;
  175. $this->assign('web_cmsmode', $web_cmsmode);
  176. /*--end*/
  177. /*自定义变量*/
  178. $eyou_row = Db::name('config_attribute')->field('a.attr_id, a.attr_name, a.attr_var_name, a.attr_input_type, b.value, b.id, b.name')
  179. ->alias('a')
  180. ->join('__CONFIG__ b', 'b.name = a.attr_var_name AND b.lang = a.lang', 'LEFT')
  181. ->where([
  182. 'b.lang' => $this->admin_lang,
  183. 'a.inc_type' => $inc_type,
  184. 'b.is_del' => 0,
  185. ])
  186. ->order('a.attr_id asc')
  187. ->select();
  188. foreach ($eyou_row as $key => $val) {
  189. $val['value'] = handle_subdir_pic($val['value'], 'html'); // 支持子目录
  190. $val['value'] = handle_subdir_pic($val['value']); // 支持子目录
  191. $eyou_row[$key] = $val;
  192. }
  193. $this->assign('eyou_row',$eyou_row);
  194. /*--end*/
  195. $this->assign('config',$config);//当前配置项
  196. $this->assign('seo_pseudo', tpCache('global.seo_pseudo')); // URL模式
  197. return $this->fetch();
  198. }
  199. /**
  200. * 核心设置
  201. */
  202. public function web2()
  203. {
  204. $this->language_access(); // 多语言功能操作权限
  205. $inc_type = 'web';
  206. $config = tpCache($inc_type);
  207. if (IS_POST) {
  208. $param = input('post.');
  209. $param['web_show_popup_upgrade'] = intval($param['web_show_popup_upgrade']);
  210. if (empty($param['web_show_popup_upgrade']) && $this->php_servicemeal <= 0) {
  211. $param['web_show_popup_upgrade'] = -1;
  212. }
  213. if (1 == $param['web_mobile_domain_open']) {
  214. $web_mobile_domain = trim($param['web_mobile_domain']);
  215. if (!empty($web_mobile_domain) && ($web_mobile_domain == 'www' || $web_mobile_domain == $this->request->subDomain())) {
  216. $this->error("手机站域名配置不能与主站域名一致!");
  217. }
  218. } else {
  219. unset($param['web_mobile_domain']);
  220. }
  221. /*EyouCMS安装目录*/
  222. empty($param['web_cmspath']) && $param['web_cmspath'] = $this->root_dir; // 支持子目录
  223. $web_cmspath = trim($param['web_cmspath'], '/');
  224. $web_cmspath = !empty($web_cmspath) ? '/'.$web_cmspath : '';
  225. $param['web_cmspath'] = $web_cmspath;
  226. /*前台模板风格*/
  227. $web_tpl_theme = $param['web_tpl_theme'];
  228. $web_tpl_theme_old = tpCache('global.web_tpl_theme');
  229. /*--end*/
  230. $recycle_is_clear = $param['recycle_is_clear']; // 是否要清空回收站
  231. unset($param['recycle_is_clear']);
  232. // $web_language_switch = tpCache('global.web_language_switch');
  233. // if (!empty($web_language_switch)) {
  234. // $param['web_citysite_open'] = 0;
  235. // }
  236. $other_pcwapjs = $param['other_pcwapjs'];
  237. unset($param['other_pcwapjs']);
  238. $seo_pseudo = tpCache('global.seo_pseudo');
  239. /*多语言*/
  240. if (is_language()) {
  241. $langRow = \think\Db::name('language')->order('id asc')
  242. ->cache(true, EYOUCMS_CACHE_TIME, 'language')
  243. ->select();
  244. foreach ($langRow as $key => $val) {
  245. tpCache($inc_type,$param,$val['mark']);
  246. write_global_params($val['mark']); // 写入全局内置参数
  247. // if (!empty($param['web_citysite_open']) && 2 == $seo_pseudo) {
  248. // tpCache('seo', ['seo_pseudo'=>1, 'seo_dynamic_format'=>1], $val['mark']);
  249. // }
  250. // pc/wap跳转js
  251. tpCache('other', ['other_pcwapjs'=>$other_pcwapjs], $val['mark']);
  252. }
  253. } else {
  254. tpCache($inc_type,$param);
  255. write_global_params($this->admin_lang); // 写入全局内置参数
  256. // if (!empty($param['web_citysite_open']) && 2 == $seo_pseudo) {
  257. // tpCache('seo', ['seo_pseudo'=>1, 'seo_dynamic_format'=>1]);
  258. // }
  259. // pc/wap跳转js
  260. tpCache('other', ['other_pcwapjs'=>$other_pcwapjs]);
  261. }
  262. /*--end*/
  263. // 开发模式,清掉缓存
  264. if (2 == $param['web_cmsmode']) {
  265. Cache::clear();
  266. delFile(RUNTIME_PATH);
  267. }
  268. // 清空回收站
  269. if (!empty($param['web_recycle_switch']) && !empty($recycle_is_clear)) {
  270. model('RecycleBin')->clear('all');
  271. }
  272. // 多城市开关
  273. // model('Citysite')->setCitysiteOpen();
  274. if ($web_tpl_theme != $web_tpl_theme_old) {
  275. foreach ([HTML_ROOT,TEMP_PATH] as $k2 => $v2) {
  276. delFile($v2);
  277. }
  278. }
  279. if ((isset($config['absolute_path_open']) && $param['absolute_path_open'] != $config['absolute_path_open']) || (!isset($config['absolute_path_open']) && $param['absolute_path_open'] == 1)){
  280. foreach ([HTML_ROOT,TEMP_PATH,CACHE_PATH] as $k3 => $v3) {
  281. delFile($v3);
  282. }
  283. }
  284. $this->success('操作成功', url('System/web2'));
  285. }
  286. // 当前主域名
  287. $this->assign('subDomain', $this->request->subDomain());
  288. // 当前域名是否IP或者localhost本地
  289. $is_localhost = 0;
  290. if (preg_match('/^\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}$/i', $this->request->host(true)) || 'localhost' == $this->request->host(true)) {
  291. $is_localhost = 1;
  292. }
  293. $this->assign('is_localhost',$is_localhost);
  294. /*模板风格列表*/
  295. $tpl_theme_list = glob('./template/*', GLOB_ONLYDIR);
  296. foreach ($tpl_theme_list as $key => &$val) {
  297. $val = str_replace('\\', '/', $val);
  298. $val = preg_replace('/^(.*)\/([^\/]*)$/i', '${2}', $val);
  299. }
  300. $this->assign('tpl_theme_list', $tpl_theme_list);
  301. $show_uiset = '';
  302. $web_tpl_theme = !empty($config['web_tpl_theme']) ? $config['web_tpl_theme'].DS : '';
  303. if (file_exists(ROOT_PATH.'template'.DS.$web_tpl_theme.'pc'.DS.'uiset.txt') && file_exists(ROOT_PATH.'template'.DS.$web_tpl_theme.'mobile'.DS.'uiset.txt')) {
  304. $show_uiset = 'pc+mobile';
  305. } else if (file_exists(ROOT_PATH.'template'.DS.$web_tpl_theme.'pc'.DS.'uiset.txt')) {
  306. $show_uiset = 'pc';
  307. } else if (file_exists(ROOT_PATH.'template'.DS.$web_tpl_theme.'mobile'.DS.'uiset.txt')) {
  308. $show_uiset = 'mobile';
  309. }
  310. $this->assign('show_uiset', $show_uiset);
  311. /*end*/
  312. /*代理贴牌功能限制-s*/
  313. $upgrade = true;
  314. if (function_exists('checkAuthRule')) {
  315. //系统升级
  316. $upgrade = checkAuthRule('upgrade');
  317. }
  318. $this->assign('upgrade', $upgrade);
  319. /*代理贴牌功能限制-e*/
  320. $this->assign('config',$config);//当前配置项
  321. // pc/wap跳转js
  322. $other_pcwapjs = tpCache('global.other_pcwapjs');
  323. $this->assign('other_pcwapjs', $other_pcwapjs);
  324. return $this->fetch();
  325. }
  326. /**
  327. * 附件设置
  328. */
  329. public function basic()
  330. {
  331. $inc_type = 'basic';
  332. $other_inc_type = 'other';
  333. // 文件上传最大限制
  334. $maxFileupload = @ini_get('file_uploads') ? ini_get('upload_max_filesize') : 0;
  335. if (0 !== $maxFileupload) {
  336. $max_filesize = unformat_bytes($maxFileupload);
  337. $max_filesize = $max_filesize / 1024 / 1024; // 单位是MB的大小
  338. } else {
  339. $max_filesize = 500;
  340. }
  341. $max_sizeunit = 'MB';
  342. $maxFileupload = $max_filesize.$max_sizeunit;
  343. if (IS_POST) {
  344. $param = input('post.');
  345. // 文档默认浏览量
  346. if (isset($param['other_arcclick']) && 0 <= $param['other_arcclick']) {
  347. $arcclick_arr = explode("|", $param['other_arcclick']);
  348. if (count($arcclick_arr) > 1) {
  349. foreach ($arcclick_arr as $k => $v) {
  350. $arcclick_arr[$k] = intval($v);
  351. if ($k > 1) {
  352. unset($arcclick_arr[$k]);
  353. }
  354. }
  355. asort($arcclick_arr);
  356. $other_param['other_arcclick'] = implode('|', $arcclick_arr);
  357. } else {
  358. $other_param['other_arcclick'] = intval($arcclick_arr[0]);
  359. }
  360. }else{
  361. $other_param['other_arcclick'] = '500|1000';
  362. }
  363. unset($param['other_arcclick']);
  364. // 软件默认下载量
  365. if (isset($param['other_arcdownload']) && 0 <= $param['other_arcdownload']) {
  366. $arcdownload_arr = explode("|", $param['other_arcdownload']);
  367. if (count($arcdownload_arr) > 1) {
  368. foreach ($arcdownload_arr as $k => $v) {
  369. $arcdownload_arr[$k] = intval($v);
  370. if ($k > 1) {
  371. unset($arcdownload_arr[$k]);
  372. }
  373. }
  374. asort($arcdownload_arr);
  375. $other_param['other_arcdownload'] = implode('|', $arcdownload_arr);
  376. } else {
  377. $other_param['other_arcdownload'] = intval($arcdownload_arr[0]);
  378. }
  379. }else{
  380. $other_param['other_arcdownload'] = '500|1000';
  381. }
  382. unset($param['other_arcdownload']);
  383. $old_basic_img_setlist = $param['old_basic_img_setlist'];
  384. unset($param['old_basic_img_setlist']);
  385. $param['file_size'] = intval($param['file_size']);
  386. if (0 < $max_filesize && $max_filesize < $param['file_size']) {
  387. $this->error("附件上传大小超过空间的最大限制".$maxFileupload);
  388. }
  389. // 允许上传图片类型
  390. $image_ext = config('global.image_ext');
  391. $image_ext_arr = explode(',', $image_ext);
  392. $image_type = explode('|', $param['image_type']);
  393. foreach ($image_type as $key => $val) {
  394. $val = trim($val);
  395. if (!in_array($val, $image_ext_arr) || empty($val)) {
  396. unset($image_type[$key]);
  397. }
  398. }
  399. $param['image_type'] = implode('|', $image_type);
  400. // 允许上传软件类型,类型太多无法进行白名单处理
  401. $file_type = explode('|', $param['file_type']);
  402. foreach ($file_type as $key => $val) {
  403. $val = trim($val);
  404. if (preg_match('/^(php|asp|jsp|perl|cgi|asa|pht|phtml|htm)/i', $val) || empty($val)) {
  405. unset($file_type[$key]);
  406. }
  407. }
  408. $param['file_type'] = implode('|', $file_type);
  409. // 允许多媒体类型
  410. $media_ext = config('global.media_ext');
  411. $media_ext_arr = explode(',', $media_ext);
  412. $media_type = explode('|', $param['media_type']);
  413. foreach ($media_type as $key => $val) {
  414. $val = trim($val);
  415. if (empty($val)) {
  416. unset($media_type[$key]);
  417. } else if (!in_array($val, $media_ext_arr)) {
  418. $this->error("不支持{$val}格式");
  419. }
  420. }
  421. $param['media_type'] = implode('|', $media_type);
  422. /*end*/
  423. // 内容图片附加功能
  424. $param['basic_img_auto_wh'] = !empty($param['basic_img_auto_wh']) ? $param['basic_img_auto_wh'] : 0;
  425. $param['basic_img_alt'] = !empty($param['basic_img_alt']) ? $param['basic_img_alt'] : 0;
  426. $param['basic_img_title'] = !empty($param['basic_img_title']) ? $param['basic_img_title'] : 0;
  427. $param['basic_img_alt_force'] = !empty($param['basic_img_alt_force']) ? $param['basic_img_alt_force'] : 0;
  428. $param['basic_body_allowurls'] = !empty($param['basic_body_allowurls']) ? $param['basic_body_allowurls'] : '';
  429. /*过滤重复值和域名处理*/
  430. $allowurls_arr = explode(PHP_EOL, $param['basic_body_allowurls']);
  431. foreach ($allowurls_arr as $key => $val) {
  432. $tmp_val = trim($val);
  433. $tmp_val = preg_replace('/^(http(s)?:)?(\/\/)?([^\/\:]*)(.*)$/i', '${4}', $tmp_val);
  434. if (empty($tmp_val)) {
  435. unset($allowurls_arr[$key]);
  436. continue;
  437. }
  438. $allowurls_arr[$key] = $tmp_val;
  439. }
  440. $allowurls_arr = array_unique($allowurls_arr);
  441. $param['basic_body_allowurls'] = implode(PHP_EOL, $allowurls_arr);
  442. /*end*/
  443. /*多语言*/
  444. if (is_language()) {
  445. $newParam['basic_indexname'] = $param['basic_indexname'];
  446. tpCache($inc_type,$newParam);
  447. $synLangParam = $param; // 同步更新多语言的数据
  448. unset($synLangParam['basic_indexname']);
  449. $langRow = \think\Db::name('language')->order('id asc')
  450. ->cache(true, EYOUCMS_CACHE_TIME, 'language')
  451. ->select();
  452. foreach ($langRow as $key => $val) {
  453. tpCache($inc_type, $synLangParam, $val['mark']);
  454. if (!empty($other_param)) {
  455. tpCache($other_inc_type, $other_param, $val['mark']);
  456. }
  457. }
  458. } else {
  459. tpCache($inc_type,$param);
  460. if (!empty($other_param)) {
  461. tpCache($other_inc_type, $other_param);
  462. }
  463. }
  464. /*--end*/
  465. $new_basic_img_setlist = $param['basic_img_auto_wh'].$param['basic_img_alt'].$param['basic_img_title'];
  466. if ($old_basic_img_setlist != $new_basic_img_setlist) {
  467. // 清空详情页缓存
  468. foreach (['http','https'] as $key => $val) {
  469. delFile(HTML_ROOT.$val.'/view');
  470. }
  471. }
  472. // 编辑器选项配置
  473. if (!empty($param['editor_select'])) {
  474. $editor_arr = [
  475. 'editor_select' => $param['editor_select'],
  476. 'editor_bdmap_ak' => $param['editor_bdmap_ak'],
  477. 'editor_remote_img_local' => $param['editor_remote_img_local'],
  478. 'editor_img_clear_link' => $param['editor_img_clear_link'],
  479. ];
  480. /*多语言*/
  481. if (is_language()) {
  482. $langRow = \think\Db::name('language')->order('id asc')
  483. ->cache(true, EYOUCMS_CACHE_TIME, 'language')
  484. ->select();
  485. foreach ($langRow as $key => $val) {
  486. tpSetting('editor', $editor_arr, $val['mark']);
  487. }
  488. } else {
  489. tpSetting('editor',$editor_arr);
  490. }
  491. $bdmap_ak_js = ROOT_PATH.'public/plugins/Ueditor/dialogs/map/bdmap_ak.js';
  492. file_put_contents($bdmap_ak_js,"var bdmap_ak = '{$editor_arr['editor_bdmap_ak']}';");
  493. }
  494. $this->success('操作成功', url('System/basic'));
  495. }
  496. $config = tpCache($inc_type);
  497. $other_config = tpCache($other_inc_type);
  498. $this->assign('config', $config);
  499. $this->assign('other_config', $other_config);
  500. $this->assign('max_filesize', $max_filesize);
  501. $this->assign('max_sizeunit', $max_sizeunit);
  502. $editor = tpSetting('editor');
  503. $this->assign('editor', $editor);
  504. return $this->fetch();
  505. }
  506. /*
  507. *
  508. */
  509. public function basic_open(){
  510. $inc_type = 'basic';
  511. $other_inc_type = 'other';
  512. $config = tpCache($inc_type);
  513. $other_config = tpCache($other_inc_type);
  514. $editor = tpSetting('editor');
  515. if (IS_POST) {
  516. $param = input('post.');
  517. // 文档默认浏览量
  518. if (isset($param['other_arcclick']) && 0 <= $param['other_arcclick']) {
  519. $arcclick_arr = explode("|", $param['other_arcclick']);
  520. if (count($arcclick_arr) > 1) {
  521. foreach ($arcclick_arr as $k => $v) {
  522. $arcclick_arr[$k] = intval($v);
  523. if ($k > 1) {
  524. unset($arcclick_arr[$k]);
  525. }
  526. }
  527. asort($arcclick_arr);
  528. $other_param['other_arcclick'] = implode('|', $arcclick_arr);
  529. } else {
  530. $other_param['other_arcclick'] = intval($arcclick_arr[0]);
  531. }
  532. }else{
  533. $other_param['other_arcclick'] = '500|1000';
  534. }
  535. unset($param['other_arcclick']);
  536. // 软件默认下载量
  537. if (isset($param['other_arcdownload']) && 0 <= $param['other_arcdownload']) {
  538. $arcdownload_arr = explode("|", $param['other_arcdownload']);
  539. if (count($arcdownload_arr) > 1) {
  540. foreach ($arcdownload_arr as $k => $v) {
  541. $arcdownload_arr[$k] = intval($v);
  542. if ($k > 1) {
  543. unset($arcdownload_arr[$k]);
  544. }
  545. }
  546. asort($arcdownload_arr);
  547. $other_param['other_arcdownload'] = implode('|', $arcdownload_arr);
  548. } else {
  549. $other_param['other_arcdownload'] = intval($arcdownload_arr[0]);
  550. }
  551. }else{
  552. $other_param['other_arcdownload'] = '500|1000';
  553. }
  554. unset($param['other_arcdownload']);
  555. $old_basic_img_setlist = $param['old_basic_img_setlist'];
  556. unset($param['old_basic_img_setlist']);
  557. // 内容图片附加功能
  558. $param['basic_img_auto_wh'] = !empty($param['basic_img_auto_wh']) ? $param['basic_img_auto_wh'] : 0;
  559. $param['basic_img_alt'] = !empty($param['basic_img_alt']) ? $param['basic_img_alt'] : 0;
  560. $param['basic_img_title'] = !empty($param['basic_img_title']) ? $param['basic_img_title'] : 0;
  561. /*多语言*/
  562. if (is_language()) {
  563. $newParam['basic_indexname'] = $param['basic_indexname'];
  564. $newParam = array_merge($config,$newParam);
  565. tpCache($inc_type,$newParam);
  566. $synLangParam = $param; // 同步更新多语言的数据
  567. unset($synLangParam['basic_indexname']);
  568. $langRow = \think\Db::name('language')->order('id asc')
  569. ->cache(true, EYOUCMS_CACHE_TIME, 'language')
  570. ->select();
  571. $synLangParam = array_merge($config,$synLangParam);
  572. foreach ($langRow as $key => $val) {
  573. tpCache($inc_type, $synLangParam, $val['mark']);
  574. if (!empty($other_param)) {
  575. $other_param = array_merge($other_config,$other_param);
  576. tpCache($other_inc_type, $other_param, $val['mark']);
  577. }
  578. }
  579. } else {
  580. $param = array_merge($config,$param);
  581. tpCache($inc_type,$param);
  582. if (!empty($other_param)) {
  583. $other_param = array_merge($other_config,$other_param);
  584. tpCache($other_inc_type, $other_param);
  585. }
  586. }
  587. /*--end*/
  588. $new_basic_img_setlist = $param['basic_img_auto_wh'].$param['basic_img_alt'].$param['basic_img_title'];
  589. if ($old_basic_img_setlist != $new_basic_img_setlist) {
  590. // 清空详情页缓存
  591. foreach (['http','https'] as $key => $val) {
  592. delFile(HTML_ROOT.$val.'/view');
  593. }
  594. }
  595. // 编辑器选项配置
  596. if (!empty($param['editor_select'])) {
  597. $editor_arr = [
  598. 'editor_select' => $param['editor_select'],
  599. 'editor_remote_img_local' => $param['editor_remote_img_local'],
  600. 'editor_img_clear_link' => $param['editor_img_clear_link'],
  601. ];
  602. tpSetting('editor', $editor_arr);
  603. }
  604. $this->success('操作成功', url('System/basic_open'));
  605. }
  606. $this->assign('config', $config);
  607. $this->assign('other_config', $other_config);
  608. $this->assign('editor', $editor);
  609. return $this->fetch();
  610. }
  611. /**
  612. * 图片水印
  613. */
  614. public function water()
  615. {
  616. $this->language_access(); // 多语言功能操作权限
  617. $inc_type = 'water';
  618. if (IS_POST) {
  619. $param = input('post.');
  620. $tabase = input('post.tabase/d');
  621. unset($param['tabase']);
  622. if (is_http_url($param['mark_img'])){
  623. $this->error('仅支持本地图片');
  624. // if (preg_match('/^\/\//i',$param['mark_img'])){
  625. // $param['mark_img'] = request()->scheme().':'.$param['mark_img'];
  626. // }
  627. // $r = saveRemote($param['mark_img'], 'temp/',0);
  628. // $r = json_decode($r, true);
  629. // if ('SUCCESS' != $r['state']) {
  630. // $this->error('远程水印图片本地化失败,请检查图片链接域名协议与网站域名协议是否一致');
  631. // }
  632. // $param['mark_img'] = handle_subdir_pic($r['url']);
  633. }
  634. $waterPath = preg_replace('#^(/[/\w\-]+)?(/public/upload/|/uploads/)#i', '$2', $param['mark_img']);
  635. $waterImgInfo = @getimagesize('.'.$waterPath);
  636. $waterImgW = !empty($waterImgInfo[0]) ? $waterImgInfo[0] : 0;
  637. $waterImgH = !empty($waterImgInfo[1]) ? $waterImgInfo[1] : 0;
  638. if ($waterImgW > 2000 || $waterImgH > 2000) {
  639. $this->error('水印图片像素不能过大,否则无法对小图片进行水印!');
  640. }
  641. /*多语言*/
  642. empty($param['mark_img_is_remote']) && $param['mark_img_is_remote'] = 0;
  643. if (is_language()) {
  644. $langRow = \think\Db::name('language')->order('id asc')
  645. ->cache(true, EYOUCMS_CACHE_TIME, 'language')
  646. ->select();
  647. foreach ($langRow as $key => $val) {
  648. tpCache($inc_type, $param, $val['mark']);
  649. }
  650. } else {
  651. tpCache($inc_type,$param);
  652. }
  653. /*--end*/
  654. $this->success('操作成功', url('System/'.$inc_type, ['tabase'=>$tabase]));
  655. }
  656. $config = tpCache($inc_type);
  657. $this->assign('config',$config);//当前配置项
  658. return $this->fetch();
  659. }
  660. /**
  661. * 缩略图配置
  662. */
  663. public function thumb()
  664. {
  665. $this->language_access(); // 多语言功能操作权限
  666. $inc_type = 'thumb';
  667. if (IS_POST) {
  668. $param = input('post.');
  669. $tabase = input('post.tabase/d');
  670. unset($param['tabase']);
  671. isset($param['thumb_width']) && $param['thumb_width'] = preg_replace('/[^0-9]/', '', $param['thumb_width']);
  672. isset($param['thumb_height']) && $param['thumb_height'] = preg_replace('/[^0-9]/', '', $param['thumb_height']);
  673. $thumbConfig = tpCache('thumb'); // 旧数据
  674. /*多语言*/
  675. if (is_language()) {
  676. $langRow = \think\Db::name('language')->order('id asc')
  677. ->cache(true, EYOUCMS_CACHE_TIME, 'language')
  678. ->select();
  679. foreach ($langRow as $key => $val) {
  680. tpCache($inc_type, $param, $val['mark']);
  681. }
  682. } else {
  683. tpCache($inc_type,$param);
  684. }
  685. /*--end*/
  686. /*校验配置是否改动,若改动将会清空缩略图目录*/
  687. unset($param['__token__']);
  688. if (md5(serialize($param)) != md5(serialize($thumbConfig))) {
  689. delFile(HTML_ROOT); // 清空缓存页面
  690. delFile(UPLOAD_PATH.'thumb'); // 清空缩略图
  691. }
  692. /*--end*/
  693. $this->success('操作成功', url('System/'.$inc_type, ['tabase'=>$tabase]));
  694. }
  695. $config = tpCache($inc_type);
  696. // 设置缩略图默认配置
  697. if (!isset($config['thumb_open'])) {
  698. /*多语言*/
  699. $thumbextra = config('global.thumb');
  700. $param = [
  701. 'thumb_open' => $thumbextra['open'],
  702. 'thumb_mode' => $thumbextra['mode'],
  703. 'thumb_color' => $thumbextra['color'],
  704. 'thumb_width' => $thumbextra['width'],
  705. 'thumb_height' => $thumbextra['height'],
  706. ];
  707. if (is_language()) {
  708. $langRow = \think\Db::name('language')->order('id asc')->select();
  709. foreach ($langRow as $key => $val) {
  710. tpCache($inc_type, $param, $val['mark']);
  711. }
  712. } else {
  713. tpCache($inc_type,$param);
  714. }
  715. $config = tpCache($inc_type);
  716. /*--end*/
  717. }
  718. $this->assign('config',$config);//当前配置项
  719. return $this->fetch();
  720. }
  721. // 所有API接口的配置
  722. public function api_conf()
  723. {
  724. /*是否开启支付功能*/
  725. $this->assign('pay_open', $this->usersConfig['pay_open']);
  726. /* END */
  727. /*余额支付开关*/
  728. $pay_balance_open = 1;
  729. if (!isset($this->usersConfig['pay_balance_open'])) {
  730. getUsersConfigData('pay', ['pay_balance_open' => 1]);
  731. } else {
  732. $pay_balance_open = intval($this->usersConfig['pay_balance_open']);
  733. }
  734. $this->assign('pay_balance_open', $pay_balance_open);
  735. /* END */
  736. /*支付接口*/
  737. $pay_api_list = Db::name('pay_api_config')->where('status', 1)->order('pay_id asc')->select();
  738. foreach ($pay_api_list as $key => $val) {
  739. if (1 == $val['system_built']) {
  740. $val['litpic'] = $this->root_dir . "/public/static/admin/images/{$val['pay_mark']}.png";
  741. } else {
  742. $val['litpic'] = $this->root_dir . "/weapp/{$val['pay_mark']}/logo.png";
  743. }
  744. $pay_api_list[$key] = $val;
  745. }
  746. $this->assign('pay_api_list', $pay_api_list);
  747. /* END */
  748. /*开放API开关*/
  749. $confApi = tpSetting("OpenMinicode.conf", [], $this->main_lang);
  750. $confApi = json_decode($confApi, true);
  751. $this->assign('confApi', $confApi);
  752. /* END */
  753. return $this->fetch();
  754. }
  755. /**
  756. * 邮件配置
  757. */
  758. public function smtp()
  759. {
  760. $inc_type = 'smtp';
  761. if (IS_POST) {
  762. $goback = input('param.goback/s');
  763. $param = input('post.');
  764. if (!empty($param['tpl_id'])){
  765. Db::name('smtp_tpl')->where('tpl_id','in',$param['tpl_id'])->update(['is_open'=>1,'update_time'=>getTime()]);
  766. Db::name('smtp_tpl')->where('tpl_id','not in',$param['tpl_id'])->update(['is_open'=>0,'update_time'=>getTime()]);
  767. }else{
  768. Db::name('smtp_tpl')->where('tpl_id','>',0)->update(['is_open'=>0,'update_time'=>getTime()]);
  769. }
  770. if (isset($param['tpl_id'])) unset($param['tpl_id']);
  771. /*多语言*/
  772. if (is_language()) {
  773. $langRow = \think\Db::name('language')->order('id asc')
  774. ->cache(true, EYOUCMS_CACHE_TIME, 'language')
  775. ->select();
  776. foreach ($langRow as $key => $val) {
  777. tpCache($inc_type, $param, $val['mark']);
  778. }
  779. } else {
  780. tpCache($inc_type, $param);
  781. }
  782. /*--end*/
  783. $this->success('操作成功', url('System/smtp', ['goback'=>$goback]));
  784. }
  785. $smtp = tpCache('smtp');
  786. $this->assign('smtp', $smtp);
  787. $goback = input('param.goback/s');
  788. $this->assign('goback', $goback);
  789. $tpl_list = Db::name('smtp_tpl')->where('lang', $this->admin_lang)->order('tpl_id asc')->select();
  790. $this->assign('tpl_list', $tpl_list);
  791. return $this->fetch();
  792. }
  793. /**
  794. * 邮件模板列表
  795. */
  796. public function smtp_tpl()
  797. {
  798. $list = array();
  799. $keywords = input('keywords/s');
  800. $map = array();
  801. if (!empty($keywords)) {
  802. $map['tpl_name'] = array('LIKE', "%{$keywords}%");
  803. }
  804. // 多语言
  805. $map['lang'] = array('eq', $this->admin_lang);
  806. $count = Db::name('smtp_tpl')->where($map)->count('tpl_id');// 查询满足要求的总记录数
  807. $pageObj = new Page($count, config('paginate.list_rows'));// 实例化分页类 传入总记录数和每页显示的记录数
  808. $list = Db::name('smtp_tpl')->where($map)
  809. ->order('tpl_id asc')
  810. ->limit($pageObj->firstRow.','.$pageObj->listRows)
  811. ->select();
  812. $pageStr = $pageObj->show(); // 分页显示输出
  813. $this->assign('list', $list); // 赋值数据集
  814. $this->assign('page', $pageStr); // 赋值分页输出
  815. $this->assign('pager', $pageObj); // 赋值分页对象
  816. // 是否填写邮件配置
  817. $is_conf = 1;
  818. $smtp_config = tpCache('smtp');
  819. if (empty($smtp_config['smtp_user']) || empty($smtp_config['smtp_pwd'])) {
  820. $is_conf = 0;
  821. }
  822. $this->assign('is_conf', $is_conf);
  823. $shop_open = getUsersConfigData('shop.shop_open');
  824. $this->assign('shop_open', $shop_open);
  825. return $this->fetch();
  826. }
  827. /**
  828. * 短信配置
  829. */
  830. public function sms()
  831. {
  832. $inc_type = 'sms';
  833. if (IS_POST) {
  834. $param = input('post.');
  835. empty($param['sms_shop_order_pay']) && $param['sms_shop_order_pay'] = 0;
  836. empty($param['sms_guestbook_send']) && $param['sms_guestbook_send'] = 0;
  837. if (!isset($param['sms_type'])) $param['sms_type'] = 1;
  838. if ($param['sms_type'] == 1) {
  839. unset($param['sms_appkey_tx']);
  840. unset($param['sms_appid_tx']);
  841. }else {
  842. unset($param['sms_appkey']);
  843. unset($param['sms_secretkey']);
  844. }
  845. if (!empty($param['sms_type'])){
  846. if (!empty($param['tpl_id'][$param['sms_type']])){
  847. Db::name('sms_template')->where('sms_type',$param['sms_type'])->where('tpl_id','in',$param['tpl_id'][$param['sms_type']])->update(['is_open'=>1,'update_time'=>getTime()]);
  848. Db::name('sms_template')->where('sms_type',$param['sms_type'])->where('tpl_id','not in',$param['tpl_id'][$param['sms_type']])->update(['is_open'=>0,'update_time'=>getTime()]);
  849. }else{
  850. Db::name('sms_template')->where('sms_type',$param['sms_type'])->where('tpl_id','>',0)->update(['is_open'=>0,'update_time'=>getTime()]);
  851. }
  852. }
  853. if (isset($param['tpl_id'])) unset($param['tpl_id']);
  854. /*多语言*/
  855. if (is_language()) {
  856. $langRow = \think\Db::name('language')->order('id asc')
  857. ->cache(true, EYOUCMS_CACHE_TIME, 'language')
  858. ->select();
  859. foreach ($langRow as $key => $val) {
  860. tpCache($inc_type, $param, $val['mark']);
  861. }
  862. } else {
  863. tpCache($inc_type, $param);
  864. }
  865. /*--end*/
  866. $this->success('操作成功', url('System/sms'));
  867. }
  868. $assign_data = [];
  869. $sms = tpCache('sms');
  870. if (!isset($sms['sms_type'])) {
  871. $sms['sms_type'] = 1;
  872. tpCache('sms', array('sms_type'=>1));
  873. }
  874. $assign_data['sms'] = $sms;
  875. $map = [
  876. 'lang' => $this->admin_lang,
  877. ];
  878. $map['sms_type'] = 1;
  879. $assign_data['sms_list1'] = Db::name('sms_template')->where($map)->order('send_scene asc')->select();
  880. $map['sms_type'] = 2;
  881. $assign_data['sms_list2'] = Db::name('sms_template')->where($map)->order('send_scene asc')->select();
  882. // ToSms短信通知插件内置代码 start
  883. if (file_exists('./weapp/ToSms/model/ToSmsModel.php')) {
  884. $toSmsModel = new \weapp\ToSms\model\ToSmsModel;
  885. $toSmsModel->admin_System_sms($assign_data);
  886. }
  887. // ToSms短信通知插件内置代码 end
  888. $this->assign($assign_data);
  889. return $this->fetch();
  890. }
  891. /**
  892. * 短信模板列表
  893. */
  894. public function sms_tpl()
  895. {
  896. $param = input('param.');
  897. $list = array();
  898. $keywords = input('keywords/s');
  899. $sms_type = input('sms_type/d');
  900. if (empty($sms_type)) {
  901. $sms_type = tpCache('sms.sms_type');
  902. $sms_type = !empty($sms_type) ? $sms_type : 1;
  903. }
  904. $map = [
  905. 'lang' => $this->admin_lang,
  906. 'sms_type' => $sms_type,
  907. ];
  908. if (!empty($keywords)) $map['tpl_title'] = array('LIKE', "%{$keywords}%");
  909. $count = Db::name('sms_template')->where($map)->count('tpl_id');// 查询满足要求的总记录数
  910. $pageObj = new Page($count, config('paginate.list_rows'));// 实例化分页类 传入总记录数和每页显示的记录数
  911. $list = Db::name('sms_template')->where($map)
  912. ->order('tpl_id asc')
  913. ->limit($pageObj->firstRow.','.$pageObj->listRows)
  914. ->select();
  915. $pageStr = $pageObj->show(); // 分页显示输出
  916. $this->assign('list', $list); // 赋值数据集
  917. $this->assign('page', $pageStr); // 赋值分页输出
  918. $this->assign('pager', $pageObj); // 赋值分页对象
  919. $this->assign('sms_type', $sms_type); // 短信服务商
  920. // 是否填写手机短信配置
  921. $is_conf = 1;
  922. $sms_arr = [];
  923. $sms_config = tpCache('sms');
  924. foreach ($sms_config as $key => $val) {
  925. $sms_arr[$key] = $val;
  926. }
  927. foreach (['sms_appkey','sms_secretkey','sms_appkey_tx','sms_appid_tx'] as $key => $val) {
  928. if (2 == $sms_type) {
  929. if (preg_match('/^sms_(.*)_tx$/i', $val) && isset($sms_arr[$val]) && empty($sms_arr[$val])) {
  930. $is_conf = 0;
  931. }
  932. } else {
  933. if (preg_match('/^sms_/i', $val) && isset($sms_arr[$val]) && empty($sms_arr[$val])) {
  934. $is_conf = 0;
  935. }
  936. }
  937. }
  938. $this->assign('is_conf', $is_conf);
  939. $shop_open = getUsersConfigData('shop.shop_open');
  940. $this->assign('shop_open', $shop_open);
  941. // ToSms短信通知插件内置代码 start
  942. $show_sms_tpl_code = true;
  943. if (file_exists('./weapp/ToSms/model/ToSmsModel.php')) {
  944. $toSmsModel = new \weapp\ToSms\model\ToSmsModel;
  945. $show_sms_tpl_code = $toSmsModel->admin_system_sms_tpl($sms_type, 'show_sms_tpl_code');
  946. }
  947. $this->assign('show_sms_tpl_code', $show_sms_tpl_code);
  948. // ToSms短信通知插件内置代码 end
  949. return $this->fetch();
  950. }
  951. /**
  952. * 微站点配置
  953. */
  954. public function microsite()
  955. {
  956. if (IS_POST) {
  957. $post = input('post.');
  958. if (!empty($post)) {
  959. // 过滤左右多余空格
  960. foreach ($post as $key => $val) {
  961. if (is_array($val)) {
  962. foreach ($val as $_k => $_v) {
  963. if (is_string($_v)) {
  964. $post[$key][$_k] = trim($_v);
  965. }
  966. }
  967. } else if (is_string($_v)) {
  968. $post[$key] = trim($val);
  969. }
  970. }
  971. $conf_wechat = tpSetting("OpenMinicode.conf_wechat", [], $this->main_lang);
  972. $conf_wechat = json_decode($conf_wechat, true);
  973. empty($conf_wechat) && $conf_wechat = [];
  974. $appid = !empty($conf_wechat['appid']) ? $conf_wechat['appid'] : '';
  975. $appsecret = !empty($conf_wechat['appsecret']) ? $conf_wechat['appsecret'] : '';
  976. // 同步到微信公众号配置
  977. $conf_wechat['wechat_name'] = $post['login']['wechat_name'];
  978. $conf_wechat['wechat_pic'] = $post['login']['wechat_pic'];
  979. tpSetting('OpenMinicode', ['conf_wechat' => json_encode($conf_wechat)], $this->main_lang);
  980. if (1 == $post['shop']['shop_micro']) {
  981. if (empty($appid) || empty($appsecret)) {
  982. $post['shop']['shop_micro'] = 0;
  983. }
  984. }
  985. if (1 == $post['shop']['shop_force_use_wechat']) {
  986. if (empty($appid) || empty($appsecret)) {
  987. $post['shop']['shop_force_use_wechat'] = 0;
  988. } else {
  989. $post['shop']['shop_micro'] = 1;
  990. }
  991. }
  992. // 微信登录配置处理
  993. $login_config = [
  994. 'appid' => $appid,
  995. 'appsecret' => $appsecret,
  996. ];
  997. $login_config = array_merge($login_config, $post['login']);
  998. $post['wechat']['wechat_login_config'] = serialize($login_config);
  999. unset($post['login']);
  1000. foreach ($post as $key => $val) {
  1001. is_array($val) && getUsersConfigData($key, $val);
  1002. }
  1003. $this->success('操作成功', url('System/microsite'));
  1004. }
  1005. }
  1006. /*微站点配置*/
  1007. $login = !empty($this->usersConfig['wechat_login_config']) ? unserialize($this->usersConfig['wechat_login_config']) : [];
  1008. $this->assign('login', $login);
  1009. /* END */
  1010. return $this->fetch();
  1011. }
  1012. /**
  1013. * 邮件模板列表 - 编辑
  1014. */
  1015. public function smtp_tpl_edit()
  1016. {
  1017. if (IS_POST) {
  1018. $post = input('post.');
  1019. $post['tpl_id'] = eyIntval($post['tpl_id']);
  1020. if(!empty($post['tpl_id'])){
  1021. $post['tpl_title'] = trim($post['tpl_title']);
  1022. /*组装存储数据*/
  1023. $nowData = array(
  1024. 'update_time' => getTime(),
  1025. );
  1026. $saveData = array_merge($post, $nowData);
  1027. /*--end*/
  1028. $r = Db::name('smtp_tpl')->where([
  1029. 'tpl_id' => $post['tpl_id'],
  1030. 'lang' => $this->admin_lang,
  1031. ])->update($saveData);
  1032. if ($r) {
  1033. $tpl_name = Db::name('smtp_tpl')->where([
  1034. 'tpl_id' => $post['tpl_id'],
  1035. 'lang' => $this->admin_lang,
  1036. ])->getField('tpl_name');
  1037. adminLog('编辑邮件模板:'.$tpl_name); // 写入操作日志
  1038. $this->success("操作成功", url('System/smtp_tpl'));
  1039. }
  1040. }
  1041. $this->error("操作失败");
  1042. }
  1043. $id = input('id/d', 0);
  1044. $row = Db::name('smtp_tpl')->where([
  1045. 'tpl_id' => $id,
  1046. 'lang' => $this->admin_lang,
  1047. ])->find();
  1048. if (empty($row)) {
  1049. $this->error('数据不存在,请联系管理员!');
  1050. exit;
  1051. }
  1052. $this->assign('row',$row);
  1053. return $this->fetch();
  1054. }
  1055. /**
  1056. * 阿里云OSS配置
  1057. */
  1058. public function oss()
  1059. {
  1060. $inc_type = 'oss';
  1061. if (IS_POST) {
  1062. $param = input('post.');
  1063. /*多语言*/
  1064. if (is_language()) {
  1065. $langRow = \think\Db::name('language')->order('id asc')
  1066. ->cache(true, EYOUCMS_CACHE_TIME, 'language')
  1067. ->select();
  1068. foreach ($langRow as $key => $val) {
  1069. tpCache($inc_type, $param, $val['mark']);
  1070. }
  1071. } else {
  1072. tpCache($inc_type, $param);
  1073. }
  1074. /*--end*/
  1075. $this->success('操作成功');
  1076. }
  1077. }
  1078. /**
  1079. * 清空缓存
  1080. */
  1081. public function clear_cache()
  1082. {
  1083. if (IS_POST) {
  1084. if (!function_exists('unlink')) {
  1085. $this->error('php.ini未开启unlink函数,请联系空间商处理!');
  1086. }
  1087. $post = input('post.');
  1088. if (!empty($post['clearAll'])) {
  1089. $this->clearSystemCache(1);
  1090. } else {
  1091. if (!empty($post['clearTable'])) {
  1092. if (in_array('table', $post['clearTable'])) {
  1093. $this->clearSystemCache(3);
  1094. }
  1095. }
  1096. if (!empty($post['clearHtml'])) {
  1097. foreach ($post['clearHtml'] as $key => $val) {
  1098. delFile(HTML_ROOT.$val);
  1099. }
  1100. }
  1101. if (!empty($post['clearCache'])) {
  1102. foreach ($post['clearCache'] as $key => $val) {
  1103. if ($val == 'cache') {
  1104. $this->clearSystemCache(0);
  1105. } else {
  1106. delFile(RUNTIME_PATH.$val);
  1107. }
  1108. }
  1109. }
  1110. }
  1111. /*清除旧升级备份包*/
  1112. $backupArr = glob(DATA_PATH.'backup/*');
  1113. foreach ($backupArr as $key => $filepath) {
  1114. if (file_exists($filepath) && !stristr($filepath, '.htaccess')) {
  1115. if (is_dir($filepath)) {
  1116. delFile($filepath, true);
  1117. } else if (is_file($filepath)) {
  1118. @unlink($filepath);
  1119. }
  1120. }
  1121. }
  1122. /*--end*/
  1123. $request = Request::instance();
  1124. $gourl = $request->baseFile();
  1125. $lang = $request->param('lang/s');
  1126. if (!empty($lang) && $lang != get_main_lang()) {
  1127. $gourl .= "?lang={$lang}";
  1128. }
  1129. $this->success('操作成功', $gourl, '', 1, [], '_parent');
  1130. }
  1131. // 页面目录
  1132. $pageDirList = [
  1133. [
  1134. 'dir_title' => '首页',
  1135. 'dir_value' => 'index',
  1136. 'dir_type' => 'system',
  1137. 'sort_order' => $this->get_page_sort_order('index'),
  1138. ],
  1139. [
  1140. 'dir_title' => '列表',
  1141. 'dir_value' => 'lists',
  1142. 'dir_type' => 'system',
  1143. 'sort_order' => $this->get_page_sort_order('lists'),
  1144. ],
  1145. [
  1146. 'dir_title' => '内容',
  1147. 'dir_value' => 'view',
  1148. 'dir_type' => 'system',
  1149. 'sort_order' => $this->get_page_sort_order('view'),
  1150. ],
  1151. [
  1152. 'dir_title' => '标签',
  1153. 'dir_value' => 'tags',
  1154. 'dir_type' => 'system',
  1155. 'sort_order' => $this->get_page_sort_order('tags'),
  1156. ],
  1157. ];
  1158. $directory = HTML_ROOT;
  1159. if (is_dir($directory)) {
  1160. $mydir = dir($directory);
  1161. while ($file = $mydir->read()) {
  1162. if ((is_dir("$directory/$file")) && !in_array($file, ['plugins','.','..','index','lists','view','tags'])) {
  1163. switch ($file) {
  1164. default:
  1165. $dir_title = '其他';
  1166. break;
  1167. }
  1168. $pageDirList[] = [
  1169. 'dir_title' => $dir_title,
  1170. 'dir_value' => $file,
  1171. 'dir_type' => 'system',
  1172. 'sort_order'=> $this->get_page_sort_order($file),
  1173. ];
  1174. }
  1175. }
  1176. $mydir->close();
  1177. }
  1178. // 插件页面目录
  1179. $directory = HTML_ROOT.'plugins';
  1180. if (is_dir($directory)) {
  1181. $mydir = dir($directory);
  1182. while ($file = $mydir->read()) {
  1183. if ((is_dir("$directory/$file")) && !in_array($file, ['.','..'])) {
  1184. switch ($file) {
  1185. case 'ask':
  1186. $dir_title = '问答';
  1187. break;
  1188. default:
  1189. $dir_title = '其他';
  1190. break;
  1191. }
  1192. $pageDirList[] = [
  1193. 'dir_title' => $dir_title,
  1194. 'dir_value' => $file,
  1195. 'dir_type' => 'plugins',
  1196. 'sort_order'=> $this->get_page_sort_order($file),
  1197. ];
  1198. }
  1199. }
  1200. $mydir->close();
  1201. }
  1202. $sort_orders = get_arr_column($pageDirList, 'sort_order');
  1203. array_multisort($sort_orders, SORT_ASC, $pageDirList);
  1204. $this->assign('pageDirList', $pageDirList);
  1205. // 数据目录
  1206. $cacheDirList = [];
  1207. $cache_dir = false;
  1208. $directory = RUNTIME_PATH;
  1209. $mydir = dir($directory);
  1210. while ($file = $mydir->read()) {
  1211. if ((is_dir("$directory/$file")) AND ($file != ".") AND ($file != "..") AND ($file != 'html')) {
  1212. if ($file == 'cache') {
  1213. $cache_dir = true;
  1214. $dir_title = '数据缓存';
  1215. } else if ($file == 'temp') {
  1216. $dir_title = 'php编译';
  1217. } else if ($file == 'data') {
  1218. $dir_title = '项目数据';
  1219. } else if ($file == 'log') {
  1220. $dir_title = '系统日志';
  1221. } else if (stristr($file, 'lotus')) {
  1222. $dir_title = '支付日志';
  1223. } else {
  1224. $dir_title = '其他';
  1225. }
  1226. $cacheDirList[] = [
  1227. 'dir_title' => $dir_title,
  1228. 'dir_value' => $file,
  1229. 'dir_type' => 'system',
  1230. 'sort_order'=> $this->get_file_sort_order($file),
  1231. ];
  1232. }
  1233. }
  1234. $mydir->close();
  1235. if (!$cache_dir) {
  1236. $cacheDirList[] = [
  1237. 'dir_title' => '数据缓存',
  1238. 'dir_value' => 'cache',
  1239. 'dir_type' => 'system',
  1240. 'sort_order'=> $this->get_file_sort_order('cache'),
  1241. ];
  1242. }
  1243. $sort_orders = get_arr_column($cacheDirList, 'sort_order');
  1244. array_multisort($sort_orders, SORT_ASC, $cacheDirList);
  1245. $this->assign('cacheDirList', $cacheDirList);
  1246. return $this->fetch();
  1247. }
  1248. private function get_page_sort_order($name)
  1249. {
  1250. if ($name == 'index') {
  1251. $sort_order = 1;
  1252. } else if ($name == 'lists') {
  1253. $sort_order = 2;
  1254. } else if ($name == 'view') {
  1255. $sort_order = 3;
  1256. } else if ($name == 'tags') {
  1257. $sort_order = 4;
  1258. } else if ($name == 'ask') {
  1259. $sort_order = 5;
  1260. } else {
  1261. $sort_order = 100;
  1262. }
  1263. return $sort_order;
  1264. }
  1265. private function get_file_sort_order($name)
  1266. {
  1267. if ($name == 'cache') {
  1268. $sort_order = 1;
  1269. } else if ($name == 'temp') {
  1270. $sort_order = 2;
  1271. } else if (stristr($name, 'lotus')) {
  1272. $sort_order = 3;
  1273. } else {
  1274. $sort_order = 100;
  1275. }
  1276. return $sort_order;
  1277. }
  1278. /**
  1279. * 清空数据缓存
  1280. */
  1281. private function clearSystemCache($clearall = 0)
  1282. {
  1283. $clearall = input('param.clearall/d', $clearall);
  1284. if ($clearall == 3) { // 数据表文件
  1285. schemaAllTable();
  1286. } else if (1 == $clearall) { // 全部缓存
  1287. Cache::clear();
  1288. delFile(RUNTIME_PATH);
  1289. schemaAllTable();
  1290. } else if (2 == $clearall) { // 页面缓存
  1291. delFile(HTML_ROOT);
  1292. } else { // 数据缓存
  1293. Cache::clear();
  1294. }
  1295. try {
  1296. /*清除大数据缓存表 -- 陈风任*/
  1297. Db::name('sql_cache_table')->execute('TRUNCATE TABLE '.config('database.prefix').'sql_cache_table');
  1298. model('SqlCacheTable')->InsertSqlCacheTable(true);
  1299. /* END */
  1300. } catch (\Exception $e) {}
  1301. if (empty($clearall) || 1 == $clearall) {
  1302. /*多语言*/
  1303. if (is_language()) {
  1304. $langRow = Db::name('language')->order('id asc')
  1305. ->cache(true, EYOUCMS_CACHE_TIME, 'language')
  1306. ->select();
  1307. foreach ($langRow as $key => $val) {
  1308. tpCache('global', '', $val['mark']);
  1309. }
  1310. } else { // 单语言
  1311. tpCache('global');
  1312. }
  1313. /*--end*/
  1314. }
  1315. return true;
  1316. }
  1317. /**
  1318. * 清空页面缓存
  1319. */
  1320. public function clearHtmlCache($arr = array())
  1321. {
  1322. if (empty($arr)) {
  1323. delFile(HTML_ROOT);
  1324. } else {
  1325. $seo_pseudo = tpCache('seo.seo_pseudo');
  1326. foreach ($arr as $key => $val) {
  1327. $fileList = glob(HTML_ROOT.'http*/'.$val.'*');
  1328. if (!empty($fileList)) {
  1329. foreach ($fileList as $k2 => $v2) {
  1330. if (file_exists($v2) && is_dir($v2)) {
  1331. delFile($v2, true);
  1332. } else if (file_exists($v2) && is_file($v2)) {
  1333. @unlink($v2);
  1334. }
  1335. }
  1336. }
  1337. if ($val == 'index' && 2 != $seo_pseudo) {
  1338. foreach (['index.html','indexs.html'] as $sk1 => $sv1) {
  1339. $filename = ROOT_PATH.$sv1;
  1340. if (file_exists($filename)) {
  1341. @unlink($filename);
  1342. }
  1343. }
  1344. }
  1345. }
  1346. }
  1347. }
  1348. /**
  1349. * 发送测试邮件
  1350. */
  1351. public function send_email()
  1352. {
  1353. $param = $smtp_config = input('post.');
  1354. $title = '演示标题';
  1355. $content = '演示一串随机数字:' . mt_rand(1000,9999);
  1356. $res = send_email($param['smtp_from_eamil'], $title, $content, 0, $smtp_config);
  1357. if (intval($res['code']) == 1) {
  1358. unset($smtp_config['tpl_id']);
  1359. /*多语言*/
  1360. if (is_language()) {
  1361. $langRow = \think\Db::name('language')->order('id asc')
  1362. ->cache(true, EYOUCMS_CACHE_TIME, 'language')
  1363. ->select();
  1364. foreach ($langRow as $key => $val) {
  1365. tpCache('smtp', $smtp_config, $val['mark']);
  1366. }
  1367. } else {
  1368. tpCache('smtp',$smtp_config);
  1369. }
  1370. /*--end*/
  1371. $this->success($res['msg']);
  1372. } else {
  1373. $this->error($res['msg']);
  1374. }
  1375. }
  1376. /**
  1377. * 发送测试短信
  1378. */
  1379. public function send_mobile()
  1380. {
  1381. $param = $sms_config = input('post.');
  1382. if (!isset($param['sms_type']) || empty($param['sms_type'])) $param['sms_type'] = 1;
  1383. if ($param['sms_type'] == 1) {
  1384. unset($sms_config['sms_appkey_tx']);
  1385. unset($sms_config['sms_appid_tx']);
  1386. unset($sms_config['sms_test_mobile']);
  1387. }else{
  1388. unset($sms_config['sms_appkey']);
  1389. unset($sms_config['sms_secretkey']);
  1390. unset($sms_config['sms_test_mobile']);
  1391. }
  1392. $send_scene = Db::name('sms_template')->where(['sms_tpl_code'=>['NEQ', ''],'sms_type'=>$param['sms_type'],'is_open'=>1])->order('tpl_id asc')->value("send_scene");
  1393. $send_scene = intval($send_scene);
  1394. $res = sendSms($send_scene, $param['sms_test_mobile'], array('content'=>mt_rand(1000,9999)),0,$sms_config);
  1395. if (intval($res['status']) == 1) {
  1396. unset($sms_config['tpl_id']);
  1397. /*多语言*/
  1398. if (is_language()) {
  1399. $langRow = \think\Db::name('language')->order('id asc')
  1400. ->cache(true, EYOUCMS_CACHE_TIME, 'language')
  1401. ->select();
  1402. foreach ($langRow as $key => $val) {
  1403. tpCache('sms', $sms_config, $val['mark']);
  1404. }
  1405. } else {
  1406. unset($sms_config['sms_type']);
  1407. tpCache('sms', $sms_config);
  1408. }
  1409. /*--end*/
  1410. $this->success($res['msg']);
  1411. } else {
  1412. $this->error($res['msg']);
  1413. }
  1414. }
  1415. //自定义分组列表
  1416. public function config_type(){
  1417. $list = array();
  1418. $condition = array();
  1419. // $keywords = input('keywords/s');
  1420. // if (!empty($keywords)) {
  1421. // $condition['type_name'] = array('LIKE', "%{$keywords}%");
  1422. // }
  1423. $condition['lang'] = array('eq', $this->admin_lang);
  1424. $count = Db::name('config_type')->where($condition)->count('id');// 查询满足要求的总记录数
  1425. $Page = $pager = new Page($count, config('paginate.list_rows'));// 实例化分页类 传入总记录数和每页显示的记录数
  1426. $list = Db::name('config_type')->where($condition)->order('sort_order asc, id asc')->limit($Page->firstRow.','.$Page->listRows)->select();
  1427. $show = $Page->show();// 分页显示输出
  1428. $this->assign('page',$show);// 赋值分页输出
  1429. $this->assign('list',$list);// 赋值数据集
  1430. $this->assign('pager',$pager);// 赋值分页对象
  1431. return $this->fetch();
  1432. }
  1433. //修改(新增)分组
  1434. public function config_type_save(){
  1435. if (IS_AJAX_POST) {
  1436. $post = input('post.');
  1437. if (empty($post['type_name'])) {
  1438. $this->error('至少新增一个链接分组!');
  1439. } else {
  1440. $is_empty = true;
  1441. foreach ($post['type_name'] as $key => $val) {
  1442. $val = trim($val);
  1443. if (!empty($val)) {
  1444. $is_empty = false;
  1445. break;
  1446. }
  1447. }
  1448. if (true === $is_empty) {
  1449. $this->error('分组名称不能为空!');
  1450. }
  1451. }
  1452. // 数据拼装
  1453. $now_time = getTime();
  1454. $addData = $editData = [];
  1455. foreach ($post['type_name'] as $key => $val) {
  1456. $group_name = trim($val);
  1457. if (!empty($group_name)) {
  1458. if (empty($post['id'][$key])) {
  1459. if ($this->admin_lang == $this->main_lang) {
  1460. $addData[] = [
  1461. 'type_name' => $group_name,
  1462. 'sort_order' => $post['sort_order'][$key] ? :100,
  1463. 'lang' => $this->admin_lang,
  1464. 'add_time' => $now_time,
  1465. 'update_time' => $now_time,
  1466. ];
  1467. }
  1468. } else {
  1469. $id = intval($post['id'][$key]);
  1470. $editData[] = [
  1471. 'id' => $id,
  1472. 'type_name' => $group_name,
  1473. 'sort_order' => $post['sort_order'][$key] ? :100,
  1474. 'lang' => $this->admin_lang,
  1475. 'update_time' => $now_time,
  1476. ];
  1477. }
  1478. }
  1479. }
  1480. if (!empty($addData)) {
  1481. $rdata = model('ConfigType')->saveAll($addData);
  1482. }
  1483. $r = true;
  1484. if (!empty($editData)) {
  1485. $r = model('ConfigType')->saveAll($editData);
  1486. }
  1487. if ($r !== false) {
  1488. adminLog('保存自定义变量分组:'.implode(',', $post['type_name']));
  1489. $this->success('操作成功');
  1490. }
  1491. }
  1492. $this->error('操作失败');
  1493. }
  1494. //删除分组
  1495. public function config_type_del(){
  1496. $id_arr = input('del_id/a');
  1497. $id_arr = eyIntval($id_arr);
  1498. if(IS_POST && !empty($id_arr)){
  1499. $group_name_list = Db::name('config_type')->where([
  1500. 'id' => ['IN', $id_arr],
  1501. ])->column('type_name');
  1502. $r = Db::name('config_type')->where([
  1503. 'id' => ['IN', $id_arr],
  1504. ])->delete();
  1505. if($r !== false){
  1506. $attr_var_name = Db::name('config_attribute')->where([
  1507. 'type_id' => ['IN', $id_arr],
  1508. ])->getField('attr_var_name',true);
  1509. if (!empty($attr_var_name)){
  1510. Db::name('config')->where(['name'=>['in',$attr_var_name]])->delete();
  1511. Db::name('config_attribute')->where(['attr_var_name'=>['in',$attr_var_name]])->delete();
  1512. }
  1513. adminLog('删除自定义分组:'.implode(',', $group_name_list));
  1514. $this->success('删除成功');
  1515. }
  1516. }
  1517. $this->error('删除失败');
  1518. }
  1519. //自定义变量列表
  1520. public function customvar_index()
  1521. {
  1522. $list = array();
  1523. $keywords = input('keywords/s');
  1524. $type_id = input('type_id/d',0);
  1525. $condition = array();
  1526. if (!empty($keywords)) {
  1527. $condition['a.attr_name'] = array('LIKE', "%{$keywords}%");
  1528. }
  1529. if (!empty($type_id)){
  1530. $condition['a.type_id'] = $type_id;
  1531. }
  1532. $condition['a.lang'] = array('eq', $this->admin_lang);
  1533. $attr_var_names = Db::name('config')->field('name')
  1534. ->where([
  1535. 'name' => ['LIKE', "web_attr_%"],
  1536. 'lang' => $this->admin_lang,
  1537. 'is_del' => 0,
  1538. ])->getAllWithIndex('name');
  1539. $condition['a.attr_var_name'] = array('IN', array_keys($attr_var_names));
  1540. $count = Db::name('config_attribute')->alias('a')->where($condition)->count();
  1541. $pageObj = new Page($count, config('paginate.list_rows'));
  1542. $list = Db::name('config_attribute')->alias('a')
  1543. ->field('a.*, b.id, b.value')
  1544. ->join('__CONFIG__ b', 'b.name = a.attr_var_name AND b.lang = a.lang', 'LEFT')
  1545. ->where($condition)
  1546. ->where([
  1547. 'b.is_del' => 0,
  1548. ])
  1549. ->order('a.attr_id asc')
  1550. ->limit($pageObj->firstRow.','.$pageObj->listRows)
  1551. ->select();
  1552. $config_type = Db::name('config_type')->field('id, type_name')->order('sort_order asc')->getAllWithIndex('id');
  1553. $this->assign('config_type',$config_type); //分组列表
  1554. foreach ($list as $key => $val) {
  1555. if (3 == $val['attr_input_type']) {
  1556. $val['value'] = handle_subdir_pic($val['value']);
  1557. }
  1558. $val['type_name'] = !empty($config_type[$val['type_id']]['type_name']) ? $config_type[$val['type_id']]['type_name'] : '';
  1559. $val['attr_var_title'] = str_replace('web_attr_', 'web_attrname_', $val['attr_var_name']);
  1560. $list[$key] = $val;
  1561. }
  1562. $attr_input_type = [
  1563. '0' => '单行文本',
  1564. '2' => '多行文本',
  1565. '3' => '上传图片',
  1566. '4' => '开关类型',
  1567. ];
  1568. $this->assign('attr_input_type',$attr_input_type); //类型列表
  1569. $pageStr = $pageObj->show();
  1570. $this->assign('page',$pageStr);
  1571. $this->assign('list',$list);
  1572. $this->assign('pager',$pageObj);
  1573. return $this->fetch();
  1574. }
  1575. /*
  1576. * 保存单个自定义变量
  1577. */
  1578. public function customvar_save_one(){
  1579. if (IS_AJAX_POST){
  1580. $post = input('post.');
  1581. if(isset($post['attr_id']) && isset($post['attr_name']) && isset($post['attr_input_type']) && isset($post['attr_var_name']) && isset($post['attr_value']) && isset($post['type_id'])){
  1582. $a = Db::name("config_attribute")->where([
  1583. 'attr_id'=>$post['attr_id']
  1584. ])->update([
  1585. 'type_id'=>$post['type_id'],
  1586. 'attr_name'=>$post['attr_name'],
  1587. 'attr_input_type'=>$post['attr_input_type'],
  1588. 'update_time'=>getTime(),
  1589. ]);
  1590. $c = tpCache('web', [$post['attr_var_name']=>$post['attr_value']]);
  1591. if($a !== false && $c !== false){
  1592. if($post['attr_input_type'] == 4){
  1593. $post['attr_value'] = $post['attr_value'] == 1 ? '开启' : '关闭';
  1594. }else if($post['attr_input_type'] == 3){
  1595. $img_url = get_default_pic($post['attr_value']);
  1596. $post['attr_value'] = '<img src="'.$img_url.'" height="50">';
  1597. }
  1598. $this->success("修改成功",null,['attr_value'=> $post['attr_value'] ]);
  1599. }
  1600. }
  1601. }
  1602. $this->error('操作错误!');
  1603. }
  1604. /**
  1605. * 保存自定义变量
  1606. */
  1607. public function customvar_save()
  1608. {
  1609. if (IS_AJAX_POST) {
  1610. $post = input('post.');
  1611. if (empty($post['attr_name'])) {
  1612. $this->error('至少新增一个自定义变量!');
  1613. }
  1614. // 数据拼装
  1615. $addData = $editData = [];
  1616. foreach ($post['attr_name'] as $key => $val) {
  1617. $attr_name = trim($val);
  1618. if (!empty($attr_name)) {
  1619. $attr_input_type = intval($post['attr_input_type'][$key]);
  1620. $attr_value = isset($post['attr_value'][$key]) ? $post['attr_value'][$key] : '';
  1621. $attr_var_name = isset($post['attr_var_name'][$key]) ? $post['attr_var_name'][$key] : '';
  1622. $type_id = isset($post['attr_type_id'][$key]) ? $post['attr_type_id'][$key] : '';
  1623. if (empty($post['attr_id'][$key])) {
  1624. if ($this->admin_lang == $this->main_lang) {
  1625. $addData[] = [
  1626. 'inc_type' => 'web',
  1627. 'attr_name' => $attr_name,
  1628. 'attr_input_type' => $attr_input_type,
  1629. 'attr_value' => $attr_value,
  1630. 'type_id' => $type_id,
  1631. 'lang' => $this->admin_lang,
  1632. 'add_time' => getTime(),
  1633. 'update_time' => getTime(),
  1634. ];
  1635. }
  1636. } else {
  1637. $attr_id = intval($post['attr_id'][$key]);
  1638. $editData[] = [
  1639. 'attr_id' => $attr_id,
  1640. 'inc_type' => 'web',
  1641. 'attr_name' => $attr_name,
  1642. 'attr_var_name' => $attr_var_name,
  1643. 'attr_input_type' => $attr_input_type,
  1644. 'attr_value' => $attr_value,
  1645. 'type_id' => $type_id,
  1646. 'lang' => $this->admin_lang,
  1647. 'update_time' => getTime(),
  1648. ];
  1649. }
  1650. }
  1651. }
  1652. /*多语言*/
  1653. $langRow = [];
  1654. if (is_language()) {
  1655. $langRow = Db::name('language')->order('id asc')
  1656. ->cache(true, EYOUCMS_CACHE_TIME, 'language')
  1657. ->select();
  1658. }
  1659. /*end*/
  1660. if (!empty($addData)) {
  1661. $rdata = model('ConfigAttribute')->saveAll($addData);
  1662. if ($rdata !== false) {
  1663. foreach ($rdata as $k1 => $v1) {
  1664. $attr_id = $v1->getData('attr_id');
  1665. $addData[$k1]['attr_id'] = $attr_id;
  1666. $addData[$k1]['attr_var_name'] = 'web_attr_'.$attr_id;
  1667. $addData[$k1]['update_time'] = getTime();
  1668. unset($addData[$k1]['add_time']);
  1669. }
  1670. $editData = array_merge($editData, $addData);
  1671. }
  1672. /*多语言*/
  1673. if (is_language()) {
  1674. $langAddData = [];
  1675. foreach ($langRow as $key => $val) {
  1676. if ($this->admin_lang == $val['mark']) {
  1677. continue;
  1678. }
  1679. foreach ($rdata as $k1 => $v1) {
  1680. $attr_data = $v1->getData();
  1681. $attr_data['lang'] = $val['mark'];
  1682. $attr_data['attr_var_name'] = 'web_attr_'.$attr_data['attr_id'];
  1683. unset($attr_data['attr_id']);
  1684. $langAddData[] = $attr_data;
  1685. }
  1686. }
  1687. !empty($langAddData) && model('ConfigAttribute')->saveAll($langAddData);
  1688. }
  1689. /*end*/
  1690. }
  1691. if (!empty($editData)) {
  1692. $r = model('ConfigAttribute')->saveAll($editData);
  1693. if ($r !== false) {
  1694. // 新增到config表,更新缓存
  1695. if (!empty($addData) && $this->admin_lang == $this->main_lang) {
  1696. $configData = [];
  1697. foreach ($addData as $key => $val) {
  1698. $configData['web_attr_'.$val['attr_id']] = isset($val['attr_value']) ? $val['attr_value'] : '';
  1699. }
  1700. // 多语言
  1701. if (is_language()) {
  1702. foreach ($langRow as $key => $val) {
  1703. tpCache('web', $configData, $val['mark']);
  1704. }
  1705. } else { // 单语言
  1706. tpCache('web', $configData);
  1707. }
  1708. }
  1709. // 更新到config表,更新缓存
  1710. $configData = [];
  1711. foreach ($editData as $key => $val) {
  1712. $configData[$val['attr_var_name']] = isset($val['attr_value']) ? $val['attr_value'] : '';
  1713. }
  1714. tpCache('web', $configData);
  1715. // end
  1716. adminLog('保存自定义变量:'.implode(',', $post['attr_name']));
  1717. $this->success('操作成功', url('System/customvar_index'));
  1718. } else {
  1719. $this->error('操作失败');
  1720. }
  1721. }
  1722. }
  1723. $this->error('非法访问!');
  1724. }
  1725. /**
  1726. * 删除自定义变量
  1727. */
  1728. public function customvar_del()
  1729. {
  1730. $this->language_access(); // 多语言功能操作权限
  1731. $id = input('del_id/d');
  1732. $deltype = input('deltype/s');
  1733. if(!empty($id)){
  1734. $attr_var_name = Db::name('config')->where([
  1735. 'id' => $id,
  1736. 'lang' => $this->admin_lang,
  1737. ])->getField('name');
  1738. if ('del' == $deltype){//彻底删除
  1739. $r = Db::name('config')->where('name', $attr_var_name)->delete();
  1740. }else{
  1741. $r = Db::name('config')->where('name', $attr_var_name)->update(array('is_del'=>1, 'update_time'=>getTime()));
  1742. }
  1743. if($r){
  1744. if ('del' == $deltype){
  1745. Db::name('config_attribute')->where('attr_var_name', $attr_var_name)->delete();
  1746. }else{
  1747. Db::name('config_attribute')->where('attr_var_name', $attr_var_name)->update(array('update_time'=>getTime()));
  1748. }
  1749. adminLog('删除自定义变量:'.$attr_var_name);
  1750. $this->success('删除成功');
  1751. }else{
  1752. $this->error('删除失败');
  1753. }
  1754. }else{
  1755. $this->error('参数有误');
  1756. }
  1757. }
  1758. /**
  1759. * 标签调用的弹窗说明
  1760. */
  1761. public function ajax_tag_call()
  1762. {
  1763. $space = "&nbsp;&nbsp;&nbsp;&nbsp;";
  1764. if (IS_AJAX_POST) {
  1765. $name = input('post.name/s');
  1766. $msg = '';
  1767. switch ($name) {
  1768. case 'web_users_switch': // 会员功能入口标签
  1769. {
  1770. $msg_code = <<<EOF
  1771. {eyou:user type='open'} <br>
  1772. {$space}{eyou:user type='cart'} <br>
  1773. {$space}{$space}&lt;a href="{\$field.url}" id="{\$field.id}" &gt;购物车&lt;/a&gt; <br>
  1774. {$space}{$space}{\$field.hidden} <br>
  1775. {$space}{/eyou:user} <br>
  1776. <br>
  1777. {$space}{eyou:user type='login'} <br>
  1778. {$space}{$space}&lt;a href="{\$field.url}" id="{\$field.id}" &gt;登录&lt;/a&gt; <br>
  1779. {$space}{$space}{\$field.hidden} <br>
  1780. {$space}{/eyou:user} <br>
  1781. <br>
  1782. {$space}{eyou:user type='reg'} <br>
  1783. {$space}{$space}&lt;a href="{\$field.url}" id="{\$field.id}" &gt;注册&lt;/a&gt; <br>
  1784. {$space}{$space}{\$field.hidden} <br>
  1785. {$space}{/eyou:user} <br>
  1786. <br>
  1787. {$space}{eyou:user type='logout'} <br>
  1788. {$space}{$space}&lt;a href="{\$field.url}" id="{\$field.id}" &gt;退出&lt;/a&gt; <br>
  1789. {$space}{$space}{\$field.hidden} <br>
  1790. {$space}{/eyou:user} <br>
  1791. {/eyou:user}
  1792. EOF;
  1793. $tpl_theme = TPL_THEME;
  1794. $msg = <<<EOF
  1795. <strong>前台会员登录注册标签调用</strong><br>
  1796. 比如需要在PC通用头部加入会员入口,复制下方代码在/template/{$tpl_theme}pc/header.htm模板文件里找到合适位置粘贴
  1797. <br/><br/>
  1798. <div style="color:red">
  1799. {$msg_code}
  1800. </div>
  1801. EOF;
  1802. }
  1803. break;
  1804. case 'web_language_switch': // 多语言入口标签
  1805. {
  1806. $tpl_theme = TPL_THEME;
  1807. $msg = <<<EOF
  1808. <strong>前台多语言切换入口标签调用</strong><br>
  1809. 比如需要在PC通用头部加入多语言切换,复制下方代码在/template/{$tpl_theme}pc/header.htm模板文件里找到合适位置粘贴
  1810. <br/><br/>
  1811. <div style="color:red">
  1812. {eyou:language type='default'}<br/>
  1813. {$space}&lt;a href="{\$field.url}"&gt;&lt;img src="{\$field.logo}" alt="{\$field.title}"&gt;{\$field.title}&lt;/a&gt;<br/>
  1814. {/eyou:language}
  1815. </div>
  1816. EOF;
  1817. }
  1818. break;
  1819. case 'thumb_open':
  1820. {
  1821. $msg = <<<EOF
  1822. <span style="color:red">(温馨提示:高级调用不会受缩略图功能的开关影响!)</span><br/>
  1823. 【标签方法的格式】<br/>
  1824. {$space}thumb_img=###,宽度,高度,生成方式<br/>
  1825. <br/>
  1826. 【指定宽高度的调用】<br/>
  1827. {$space}列表页/内容页:{\$eyou.field.litpic<span style="color:red">|thumb_img=###,500,500</span>}<br/>
  1828. {$space}标签arclist/list里:{\$field.litpic<span style="color:red">|thumb_img=###,500,500</span>}<br/>
  1829. <br/>
  1830. 【指定生成方式的调用】<br/>
  1831. {$space}生成方式:1 = 拉伸;2 = 留白;3 = 截减;<br/>
  1832. {$space}以标签arclist为例:<br/>
  1833. {$space}{$space}缩略图拉伸:{\$field.litpic<span style="color:red">|thumb_img=###,500,500,1</span>}<br/>
  1834. {$space}{$space}缩略图留白:{\$field.litpic<span style="color:red">|thumb_img=###,500,500,2</span>}<br/>
  1835. {$space}{$space}缩略图截减:{\$field.litpic<span style="color:red">|thumb_img=###,500,500,3</span>}<br/>
  1836. {$space}{$space}默&nbsp;认&nbsp;生&nbsp;成:{\$field.litpic<span style="color:red">|thumb_img=###,500,500</span>}{$space}(以默认全局配置的生成方式)<br/>
  1837. EOF;
  1838. }
  1839. break;
  1840. case 'shop_open':
  1841. {
  1842. $msg_code = <<<EOF
  1843. &lt;!--购物车组件start--&gt; <br/>
  1844. {eyou:sppurchase id='field' currentstyle='btn-danger'} <br/>
  1845. {$space}&lt;!-- 价格 标签开始 --&gt; <br/>
  1846. {$space}&lt;div class="ey-price"&gt;&lt;span&gt;¥{\$field.users_price}&lt;/span&gt; &lt;/div&gt; <br/>
  1847. {$space}&lt;!-- 价格 标签结束 --&gt; <br/>
  1848. <br/>
  1849. {$space}&lt;!-- 规格 标签开始 --&gt; <br/>
  1850. {$space}&lt;div class="ey-spec"&gt; <br/>
  1851. {$space}{eyou:volist name="\$field.ReturnData" id='field2'} <br/>
  1852. {$space}{$space}&lt;div class="row m-t-15"&gt; <br/>
  1853. {$space}{$space}{$space}&lt;label class="form-control-label col-sm-7"&gt;{\$field2.spec_name}&lt;/label&gt; <br/>
  1854. {$space}{$space}{$space}&lt;div class="col-sm-10"&gt; <br/>
  1855. {$space}{$space}{$space}{eyou:volist name="\$field2.spec_value" id='field3'} <br/>
  1856. {$space}{$space}{$space}{$space}&lt;a href="JavaScript:void(0);" {\$field3.SpecData} class="btn btn-default btn-selected {\$field3.SpecClass}"&gt;{\$field3.spec_value}&lt;/a&gt; <br/>
  1857. {$space}{$space}{$space}{/eyou:volist} <br/>
  1858. {$space}{$space}{$space}&lt;/div&gt; <br/>
  1859. {$space}{$space}&lt;/div&gt; <br/>
  1860. {$space}{/eyou:volist} <br/>
  1861. {$space}&lt;/div&gt; <br/>
  1862. {$space}&lt;!-- 规格 标签结束 --&gt; <br/>
  1863. <br/>
  1864. {$space}&lt;!-- 数量操作 标签开始 --&gt; <br/>
  1865. {$space}&lt;div class="ey-number"&gt; <br/>
  1866. {$space}{$space}&lt;label&gt;数量&lt;/label&gt; <br/>
  1867. {$space}{$space}&lt;div class="btn-input"&gt; <br/>
  1868. {$space}{$space}{$space}&lt;button class="layui-btn" {\$field.ReduceQuantity}&gt;-&lt;/button&gt; <br/>
  1869. {$space}{$space}{$space}&lt;input type="text" class="layui-input" {\$field.UpdateQuantity}&gt; <br/>
  1870. {$space}{$space}{$space}&lt;button class="layui-btn" {\$field.IncreaseQuantity}&gt;+&lt;/button&gt; <br/>
  1871. {$space}{$space}&lt;/div&gt; <br/>
  1872. {$space}&lt;/div&gt; <br/>
  1873. {$space}&lt;!-- 数量操作 标签结束 --&gt; <br/>
  1874. <br/>
  1875. {$space}&lt;!-- 库存量 标签开始 --&gt; <br/>
  1876. {$space}&lt;span {\$field.stock_show}&gt;库存量:{\$field.stock_count} 件&lt;/span&gt; <br/>
  1877. {$space}&lt;!-- 库存量 标签结束 --&gt; <br/>
  1878. <br/>
  1879. {$space}&lt;!-- 购买按钮 标签开始 --&gt; <br/>
  1880. {$space}&lt;div class="ey-buyaction"&gt; <br/>
  1881. {$space}{$space}&lt;a class="ey-joinin" href="JavaScript:void(0);" {\$field.ShopAddCart}&gt;加入购物车&lt;/a&gt; <br/>
  1882. {$space}{$space}&lt;a class="ey-joinbuy" href="JavaScript:void(0);" {\$field.BuyNow}&gt;立即购买&lt;/a&gt; <br/>
  1883. {$space}&lt;/div&gt; <br/>
  1884. {$space}&lt;!-- 购买按钮 标签结束 --&gt; <br/>
  1885. <br/>
  1886. {$space}{\$field.hidden} <br/>
  1887. {/eyou:sppurchase} <br/>
  1888. &lt;!--购物车组件end--&gt;
  1889. EOF;
  1890. $tpl_theme = TPL_THEME;
  1891. $msg = <<<EOF
  1892. <div style="color:red">
  1893. 请手工调用最新版的购买行为入口标签,代码验证通过便可启用
  1894. <br/>
  1895. 复制下方代码在/template/{$tpl_theme}pc/view_product.htm模板文件里找到合适位置粘贴
  1896. </div>
  1897. <br/>
  1898. <div id='ShopOpenCode'>
  1899. {$msg_code}
  1900. </div>
  1901. EOF;
  1902. }
  1903. break;
  1904. default:
  1905. # code...
  1906. break;
  1907. }
  1908. $this->success('请求成功', null, ['msg'=>$msg]);
  1909. }
  1910. $this->error('非法访问!');
  1911. }
  1912. /**
  1913. * 手机面板
  1914. * @return [type] [description]
  1915. */
  1916. public function web_m()
  1917. {
  1918. return $this->fetch();
  1919. }
  1920. public function ajax_check_language_open()
  1921. {
  1922. if (IS_AJAX) {
  1923. $web_language_switch = tpCache('web.web_language_switch');
  1924. if (!empty($web_language_switch)) {
  1925. $this->error('已开启多语言');
  1926. } else {
  1927. $this->success('未开启多语言');
  1928. }
  1929. }
  1930. }
  1931. }