1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774 |
- <?php
-
-
- namespace app\home\controller;
- use think\Db;
- use think\template\driver\File;
-
- class Buildmhtml extends Base
- {
- public $php_sessid;
- public function _initialize()
- {
- parent::_initialize();
- @ini_set('memory_limit','-1');
- $this->php_sessid = !empty($_COOKIE['PHPSESSID']) ? $_COOKIE['PHPSESSID'] : '';
- if (!session('?admin_id')) {
- $this->error("只允许后台管理员操作!");
- }
-
- $this->makeminfo = \think\Db::name('weapp_makemhtml')->find(1);
- }
-
-
-
- private function clearCache()
- {
- cache("channel_page_total_serialize".$this->php_sessid, null);
- cache("channel_info_serialize".$this->php_sessid, null);
- cache("has_children_Row_serialize".$this->php_sessid, null);
- cache("aid_arr_serialize".$this->php_sessid, null);
- cache("channel_arr_serialize".$this->php_sessid, null);
- cache("article_info_serialize".$this->php_sessid, null);
- cache("article_page_total_serialize".$this->php_sessid, null);
- cache("article_tags_serialize".$this->php_sessid, null);
- cache("article_attr_info_serialize".$this->php_sessid, null);
- cache("article_children_row_serialize".$this->php_sessid, null);
- }
-
-
-
- public function buildIndexAll()
- {
- \think\Session::pause();
- $this->clearCache();
-
- $uphtmltype = input('param.uphtmltype/d');
- if (!empty($uphtmltype)) {
- $this->buildAppointAll($uphtmltype);
- }
- else {
- $channelData = $this->getChannelData(0);
- $archivesArr = getAllArchivesAid(0, $this->home_lang);
- $articleData_pagetotal = count($archivesArr['aid_arr']);
- $allpagetotal = 1 + $channelData['pagetotal'] + $articleData_pagetotal;
- $msg = $this->handleBuildIndex();
-
- $data = [
- 'achievepage' => 1,
- 'channelpagetotal' => $channelData['pagetotal'],
- 'articlepagetotal' => $articleData_pagetotal,
- 'allpagetotal' => $allpagetotal,
- ];
- $this->success($msg, null, $data);
- }
- }
-
-
-
- private function buildAppointAll($uphtmltype = 0)
- {
- if (1 == $uphtmltype) {
- $seo_start_time = $this->eyou['global']['seo_start_time'];
- $seo_start_time = !empty($seo_start_time) ? strtotime($seo_start_time) : 0;
- $startid = Db::name('archives')->where([
- 'add_time' => ['egt', $seo_start_time],
- ])->order('aid asc')->limit(1)->value('aid');
- if (empty($startid)) {
- $startid = Db::name('archives')->max('aid');
- $startid += 1;
- }
- }
- else if (2 == $uphtmltype) {
- $startid = $this->eyou['global']['seo_startid2'];
- }
- $archivesArr = getAllArchivesAid(0, $this->home_lang, $startid);
- $articleData_pagetotal = count($archivesArr['aid_arr']);
- $channelpagetotal = 0;
- $typeid_arr = [];
- if (!empty($articleData_pagetotal)) {
- $typeid_arr = $archivesArr['typeid_arr'];
- foreach ($archivesArr['typeid_arr'] as $key => $val) {
-
- $allParentRow = model('Arctype')->getAllPid($val);
- $typeid_arr = array_merge($typeid_arr, get_arr_column($allParentRow, 'id'));
- }
- $typeid_arr = array_unique($typeid_arr);
- $channelData = $this->getChannelData($typeid_arr, false);
- $channelpagetotal = intval($channelData['pagetotal']);
- }
-
- $allpagetotal = 1 + $channelpagetotal + $articleData_pagetotal;
- $msg = $this->handleBuildIndex();
-
- $data = [
- 'achievepage' => 1,
- 'channelpagetotal' => $channelpagetotal,
- 'articlepagetotal' => $articleData_pagetotal,
- 'allpagetotal' => $allpagetotal,
- 'startid' => $startid,
- 'typeids' => implode(',', $typeid_arr),
- ];
- $this->success($msg, null, $data);
- }
-
-
-
- public function buildIndex()
- {
- \think\Session::pause();
- $msg = $this->handleBuildIndex();
- $this->success($msg);
- }
-
-
-
- private function handleBuildIndex()
- {
- $msg = '';
- $indexurl = $this->request->domain().$this->root_dir;
-
- $seo_html_position_arr = explode('/', $this->eyou['global']['seo_html_position']);
- if (!empty($seo_html_position_arr)) {
- $savefilename = end($seo_html_position_arr);
- } else {
- $savefilename = 'index.html';
- }
-
- $makeminfo = $this->makeminfo;
-
- if($makeminfo['web_url_model']==2){
- $seo_html_arcdir='';
- }else{
- $seo_html_arcdir=$makeminfo['value'];
- }
-
-
-
- if (!empty($this->eyou['global']['seo_showmod'])){
- $seo_html_position = !empty($this->eyou['global']['seo_html_position']) ? $this->eyou['global']['seo_html_position'] : '';
- if ($seo_html_position) {
- $seo_html_position = preg_replace('/^\.{1,}([\\\\\/]+)/i', '', $seo_html_position);
- $seo_html_position = ltrim($seo_html_position, '/');
- $seo_html_position = ROOT_PATH.$seo_html_position;
- $seo_html_position_path = dirname($seo_html_position);
- tp_mkdir($seo_html_position_path);
- clearstatcache();
- if (!is_writeable($seo_html_position_path)) {
- $msg = "目录 {$seo_html_position_path} 没有权限写入,生成失败";
- return $msg;
- }
- }
- $result['pageurl'] = $this->request->domain() . ROOT_DIR;
-
-
-
-
-
-
- $eyou = array(
- 'field' => $result,
- );
- $this->eyou = array_merge($this->eyou, $eyou);
- $this->assign('eyou', $this->eyou);
- try {
-
-
-
-
- $makeminfo =$this->makeminfo;
-
- $savepath = '.'.$makeminfo['value'].'/'.$savefilename;
-
-
- $tpl = 'index';
- $seo_html_templet = !empty($this->eyou['global']['seo_html_templet']) ? $this->eyou['global']['seo_html_templet'] : '';
- $seo_html_templet_arr = explode('.',$seo_html_templet);
- if(!empty($seo_html_templet_arr[0])){
- $tpl = $seo_html_templet_arr[0];
- }
- $this->request->get(['m' => 'Index']);
- $this->filePutContents($savepath, $tpl, 'mobile', 0, '/', 0, 1, $result);
- if ($seo_html_position){
-
-
-
- }else{
-
- }
- } catch (\Exception $e) {
-
- }
- }else{
-
- @unlink($savefilename);
- $msg .= "采用动态浏览模式:<a href='".$indexurl."' target='_blank' onclick='layer.closeAll();'>浏览...</a><br />";
- }
-
- return $msg;
- }
-
-
-
- private function filePutContents($savepath, $tpl, $model = 'mobile', $pages = 0, $dir = '/', $tid = 0, $top = 1, $result = [])
- {
-
- ob_start();
- static $templateConfig = null;
- null === $templateConfig && $templateConfig = \think\Config::get('template');
- $templateConfig['view_path'] = "./template/".TPL_THEME."mobile/";
- $template = "./template/".TPL_THEME."{$model}/{$tpl}.{$templateConfig['view_suffix']}";
- $content = $this->fetch($template, [], [], $templateConfig);
-
-
-
-
-
-
-
- $url = tpCache('web.web_basehost');
- $pattern='#<img(.*?)src="(?!(https|http):)([^"]+)"#';
- $content = preg_replace($pattern,'<img $1 src="' .$url.'$3'.'"',$content);
-
-
- $content = preg_replace('#"/index.php(.*?)#','"'.$url.'/index.php$1',$content);
-
-
- if (stristr($content, '/template/pc/')) {
- $content = str_ireplace('/template/pc/', "/template/mobile/", $content);
- }
-
- if (stristr($content, '/template/eyou/pc/')) {
- $content = str_ireplace('/template/eyou/pc/', "/template/eyou/mobile/", $content);
- }
-
- if (stristr($content, '/template/default/pc/')) {
- $content = str_ireplace('/template/default/pc/', "/template/default/mobile/", $content);
- }
- if (stristr($content, '/tags/')) {
- $content = str_ireplace('/tags/', "/m/tags/", $content);
- }
-
- if ($pages > 0) {
- $page = "/<a(.*?)href(\s*)=(\s*)[\'|\"](.*?)page=([0-9]*)(.*?)data-ey_fc35fdc=[\'|\"]html[\'|\"](.*?)>/i";
- preg_match_all($page, $content, $matchpage);
-
- $dir = trim($dir, '.');
-
- $seo_html_listname = $this->eyou['global']['seo_html_listname'];
-
- foreach ($matchpage[0] as $key1 => $value1) {
- if ($matchpage[5][$key1] == 1) {
- if ($top == 1) {
- $url = $dir;
- } elseif ($top == 2) {
- $url = $dir . '/lists_' . $tid . '.html';
- } else {
- $url = $dir . '/lists_' . $tid . '.html';
- }
- } else {
- if ($seo_html_listname == 4) {
- if (!empty($result['rulelist'])) {
- if (!preg_match('/{page}/i', $result['rulelist'])) {
- $rulelist_filename = '';
- } else {
- $rulelist = trim($result['rulelist'], '/');
- $rulelist_filename = preg_replace('/^((.*)\/)?([^\/]+)$/i', '${3}', $rulelist);
- $rulelist_filename = str_replace("{tid}", $tid, $rulelist_filename);
- $rulelist_filename = str_replace("{page}", $matchpage[5][$key1], $rulelist_filename);
- }
- $url = $dir;
- if (!empty($rulelist_filename)) {
- $url .= '/' . $rulelist_filename;
- }
- }else{
- $url = $dir . '/list_' . $tid . '_' . $matchpage[5][$key1] . '.html';
- }
- } else {
- $url = $dir . '/lists_' . $tid . '_' . $matchpage[5][$key1] . '.html';
- }
- }
-
- $url = ROOT_DIR . '/' . trim($url, '/');
-
- $value1_new = preg_replace('/href(\s*)=(\s*)[\'|\"]([^\'\"]*)[\'|\"]/i', '', $value1);
- $value1_new = str_replace('data-ey_fc35fdc=', " href=\"{$url}\" data-ey_fc35fdc=", $value1_new);
- $content = str_ireplace($value1, $value1_new, $content);
-
- }
- }
-
-
- echo $content;
- $_cache = ob_get_contents();
- ob_end_clean();
- static $File = null;
- null === $File && $File = new File;
- $File->fwrite($savepath, $_cache);
- }
-
-
- public function buildArticle()
- {
- function_exists('set_time_limit') && set_time_limit(0);
- \think\Session::pause();
- $typeid = input("param.id/d", 0);
- $findex = input("param.findex/d", 0);
- $achievepage = input("param.achieve/d", 0);
- if (empty($findex) && empty($achievepage)){
- $this->clearCache();
- }
- $data = $this->handelBuildArticleList($typeid, $findex, $achievepage,true,20);
-
- $this->success($data[0], null, $data[1]);
- }
-
-
- private function handelBuildArticleList($typeid, $nextid = 0, $achievepage = 0, $batch = true, $limit = 20)
- {
- !empty($this->eyou['global']['seo_pagesize']) && $limit = $this->eyou['global']['seo_pagesize'];
- $startid = '';
- $endid = '';
- $uphtmltype = input('param.uphtmltype/d');
- if (!empty($uphtmltype)) {
- $startid = input('param.startid/d');
- empty($startid) && $startid = !empty($this->eyou['global']['seo_startid']) ? $this->eyou['global']['seo_startid'] : '';
- $endid = !empty($this->eyou['global']['seo_endid']) ? $this->eyou['global']['seo_endid'] : '';
- }
- $msg = "";
- $globalConfig = $this->eyou['global'];
- $result = $this->getArticleAidData($typeid,$startid,$endid);
- $aid_arr = $result['aid_arr'];
- $channel_arr = $result['channel_arr'];
- $allAttrInfo = getAllAttrInfo($channel_arr);
- $allTags = $result['allTags'];
- $has_children_Row = $result['has_children_Row'];
-
- $data['allpagetotal'] = $pagetotal = $result['pagetotal'];
- $data['achievepage'] = $achievepage;
- $data['pagetotal'] = 0;
- if ($batch && $pagetotal > $achievepage) {
- while ($limit && isset($aid_arr[$nextid])) {
- $archives = getAllArchives($this->home_lang, 0, $aid_arr[$nextid]);
- $row = $archives['info'][0];
- $arctypeRow = $archives['arctypeRow'];
- $attrInfo = getOneAttrInfo($allAttrInfo, $aid_arr[$nextid]);
- $msg .= $msg_temp = $this->createArticle($row, $globalConfig, $arctypeRow, $allTags, $has_children_Row, $attrInfo);
- $data['achievepage'] += 1;
- $limit--;
- $nextid++;
- }
- $data['findex'] = $nextid;
- } else if (!$batch) {
- foreach ($aid_arr as $key => $val) {
- $archives = getAllArchives($this->home_lang, 0, $val);
- $row = $archives['info'][0];
- $arctypeRow = $archives['arctypeRow'];
- $attrInfo = getOneAttrInfo($allAttrInfo, $val);
- $msg .= $msg_temp = $this->createArticle($row, $globalConfig, $arctypeRow, $allTags, $has_children_Row, $attrInfo);
- $data['achievepage'] += 1;
- $data['findex'] = $key;
- }
- }
- if ($data['allpagetotal'] == $data['achievepage']) {
- cache("aid_arr_serialize".$this->php_sessid, null);
- cache("channel_arr_serialize".$this->php_sessid, null);
- cache("article_page_total_serialize".$this->php_sessid, null);
- cache("article_tags_serialize".$this->php_sessid, null);
- cache("article_attr_info_serialize".$this->php_sessid, null);
- cache("article_children_row_serialize".$this->php_sessid, null);
- }
-
- return [$msg, $data];
- }
-
-
- private function getArticleAidData($typeid = 0,$startid = 0,$endid = 0){
- $aid_arr_serialize = cache("aid_arr_serialize".$this->php_sessid);
- if (empty($aid_arr_serialize)){
- $archivesArr = getAllArchivesAid($typeid, $this->home_lang,$startid,$endid);
- $aid_arr = $archivesArr['aid_arr'];
- $channel_arr = $archivesArr['channel_arr'];
- $pagetotal = count($aid_arr);
- $allTags = getAllTags();
-
- $has_children_Row = Db::name('Arctype')->field('parent_id, count(id) AS total')->where([
- 'current_channel'=>['neq', 51],
- 'is_del' => 0,
- ])->group('parent_id')->getAllWithIndex('parent_id');
- cache("aid_arr_serialize".$this->php_sessid, serialize($aid_arr), null, 'buildhtml');
- cache("channel_arr_serialize".$this->php_sessid, serialize($channel_arr), null, 'buildhtml');
- cache("article_page_total_serialize".$this->php_sessid, $pagetotal, null, 'buildhtml');
- cache("article_tags_serialize".$this->php_sessid, serialize($allTags), null, 'buildhtml');
- cache("article_children_row_serialize".$this->php_sessid, serialize($has_children_Row), null, 'buildhtml');
- }else{
- $aid_arr = unserialize($aid_arr_serialize);
- $channel_arr = cache("channel_arr_serialize".$this->php_sessid);
- $channel_arr = unserialize($channel_arr);
- $pagetotal = cache("article_page_total_serialize".$this->php_sessid);
- $allTags = unserialize(cache("article_tags_serialize".$this->php_sessid));
- $has_children_Row = unserialize(cache("article_children_row_serialize".$this->php_sessid));
- }
-
- return [
- 'aid_arr' => $aid_arr,
- 'channel_arr' => $channel_arr,
- 'pagetotal' => $pagetotal,
- 'allTags' => $allTags,
- 'has_children_Row' => $has_children_Row
- ];
- }
-
-
-
- private function getArticleData($typeid, $aid, $type = 0)
- {
- $info_serialize = cache("article_info_serialize".$this->php_sessid);
- if (empty($info_serialize)) {
- if ($type == 0) {
- $data = getAllArchives($this->home_lang, $typeid, $aid);
- } else if ($type == 1) {
- $data = getPreviousArchives($this->home_lang, $typeid, $aid);
- } else if ($type == 2) {
- $data = getNextArchives($this->home_lang, $typeid, $aid);
- }
- $info = $data['info'];
- $aid_arr = $typeid_arr = $channel_arr = [];
- foreach ($info as $key => $val) {
- $aid_arr[] = $val['aid'];
- $typeid_arr[] = $val['typeid'];
- $channel_arr[$val['channel']][] = $val['aid'];
- }
- $pagetotal = count($info);
- $allTags = getAllTags($aid_arr);
- $allAttrInfo = getAllAttrInfo($channel_arr);
-
- $has_children_Row = model('Arctype')->hasChildren($typeid_arr);
- cache("article_info_serialize".$this->php_sessid, serialize($data), null, 'buildhtml');
- cache("article_page_total_serialize".$this->php_sessid, $pagetotal, null, 'buildhtml');
- cache("article_tags_serialize".$this->php_sessid, serialize($allTags), null, 'buildhtml');
- cache("article_attr_info_serialize".$this->php_sessid, serialize($allAttrInfo), null, 'buildhtml');
- cache("article_children_row_serialize".$this->php_sessid, serialize($has_children_Row), null, 'buildhtml');
- } else {
- $data = unserialize($info_serialize);
- $pagetotal = cache("article_page_total_serialize".$this->php_sessid);
- $allTags = unserialize(cache("article_tags_serialize".$this->php_sessid));
- $allAttrInfo = unserialize(cache("article_attr_info_serialize".$this->php_sessid));
- $has_children_Row = unserialize(cache("article_children_row_serialize".$this->php_sessid));
- }
-
- return ['data' => $data, 'pagetotal' => $pagetotal, 'allTags' => $allTags, 'allAttrInfo' => $allAttrInfo, 'has_children_Row' => $has_children_Row];
- }
-
-
-
- private function handelBuildArticle($typeid, $aid = 0, $nextid = 0, $achievepage = 0, $batch = true, $limit = 20, $type = 0)
- {
- $msg = "";
- $globalConfig = $this->eyou['global'];
- $result = $this->getArticleData($typeid, $aid, $type);
- $info = $result['data']['info'];
- $arctypeRow = $result['data']['arctypeRow'];
- $allTags = $result['allTags'];
- $has_children_Row = $result['has_children_Row'];
- $allAttrInfo = $result['allAttrInfo'];
- $data['allpagetotal'] = $pagetotal = $result['pagetotal'];
- $data['achievepage'] = $achievepage;
- $data['pagetotal'] = 0;
-
- if ($batch && $pagetotal > $achievepage) {
- while ($limit && isset($info[$nextid])) {
- $row = $info[$nextid];
- $msg .= $msg_temp = $this->createArticle($row, $globalConfig, $arctypeRow, $allTags, $has_children_Row, $allAttrInfo);
- $data['achievepage'] += 1;
- $limit--;
- $nextid++;
- }
- $data['findex'] = $nextid;
- } else if (!$batch) {
- foreach ($info as $key => $row) {
- $msg .= $msg_temp = $this->createArticle($row, $globalConfig, $arctypeRow, $allTags, $has_children_Row, $allAttrInfo);
- $data['achievepage'] += 1;
- $data['findex'] = $key;
- }
- }
- if ($data['allpagetotal'] == $data['achievepage']) {
- cache("article_info_serialize".$this->php_sessid, null);
- cache("article_page_total_serialize".$this->php_sessid, null);
- cache("article_tags_serialize".$this->php_sessid, null);
- cache("article_attr_info_serialize".$this->php_sessid, null);
- cache("article_children_row_serialize".$this->php_sessid, null);
- }
-
- return [$msg, $data];
- }
-
-
-
- private function createArticle($result, $globalConfig, $arctypeRow, $allTags, $has_children_Row, $allAttrInfo)
- {
- $msg = "";
- $aid = $result['aid'];
- static $arc_seo_description_length = null;
- null === $arc_seo_description_length && $arc_seo_description_length = config('global.arc_seo_description_length');
- $this->request->get(['aid' => $aid]);
- $this->request->get(['tid' => $result['typeid']]);
-
- $arctypeInfo = $arctypeRow[$result['typeid']];
-
- if (empty($result) || $arctypeInfo['current_channel'] != $result['channel'] || 51 == $result['channel']) {
- return false;
- }
-
- $arctypeInfo = model('Arctype')->parentAndTopInfo($result['typeid'], $arctypeInfo);
-
- $arctypeInfo = $this->fieldLogic->getTableFieldList($arctypeInfo, config('global.arctype_channel_id'));
-
- $arctypeInfo['has_children'] = !empty($has_children_Row[$result['typeid']]) ? 1 : 0;
-
-
- empty($result['tempview']) && $result['tempview'] = $arctypeInfo['tempview'];
-
-
- foreach ($arctypeInfo as $key => $val) {
- if (!preg_match('/^type/i', $key)) {
- $key_new = 'type' . $key;
- !array_key_exists($key_new, $arctypeInfo) && $arctypeInfo[$key_new] = $val;
- }
- }
-
-
- $result = array_merge($arctypeInfo, $result);
-
- if (!empty($result['content_ey_m'])){
- $result['content'] = $result['content_ey_m'];
- }
-
- $result['arcurl'] = $result['pageurl'] = $result['pageurl_m'] = '';
- if ($result['is_jump'] != 1) {
- $result['arcurl'] = $result['pageurl'] = arcurl('home/View/index', $result, true, true);
- $result['pageurl_m'] = pc_to_mobile_url($result['pageurl'], $result['typeid'], $result['aid']);
- }
-
-
-
- $result['mobile_domain'] = '';
- if (!empty($this->eyou['global']['web_mobile_domain_open']) && !empty($this->eyou['global']['web_mobile_domain'])) {
- $result['mobile_domain'] = $this->eyou['global']['web_mobile_domain'] . '.' . $this->request->rootDomain();
- }
-
- $result['seo_title'] = set_arcseotitle($result['title'], $result['seo_title'], $result['typename'], $result['typeid']);
- $result['seo_description'] = checkStrHtml($result['seo_description']);
- $result['tags'] = empty($allTags[$aid]) ? '' : implode(',', $allTags[$aid]);
- $result['litpic'] = handle_subdir_pic($result['litpic']);
- $result = view_logic($aid, $result['channel'], $result, $allAttrInfo);
- $result = $this->fieldLogic->getChannelFieldList($result, $result['channel']);
-
- if (!empty($result['users_id'])){
- $users_where['a.users_id'] = $result['users_id'];
- }elseif (!empty($result['admin_id'])){
- $users_where['a.admin_id'] = $result['admin_id'];
- }else {
- $users_where['a.admin_id'] = ['>',0];
- }
- $users = Db::name('users')->alias('a')->field('a.username,a.nickname,a.head_pic,b.level_name,b.level_value')->where($users_where)->join('users_level b','a.level = b.level_id','left')->find();
- if (!empty($users)) {
- $users['head_pic'] = get_default_pic($users['head_pic']);
- empty($users['nickname']) && $users['nickname'] = $users['username'];
- }
-
-
- $eyou = array(
- 'type' => $arctypeInfo,
- 'field' => $result,
- 'users' => $users,
- );
- $this->eyou = array_merge($this->eyou, $eyou);
- $this->assign('eyou', $this->eyou);
-
-
- $tpl = '';
- if (!empty($result['tempview']) && file_exists("./template/".TPL_THEME."mobile/{$result['tempview']}")) {
- $tpl = str_replace('.' . $this->view_suffix, '', $result['tempview']);
- } else {
- $tpl = 'view_' . $result['nid'];
- }
-
- $dir = $this->getArticleDir($result);
- if (!empty($result['htmlfilename'])) {
- $aid = $result['htmlfilename'];
- }
- if (4 == $this->eyou['global']['seo_html_pagename']) {
- if (!empty($result['ruleview'])) {
- $savepath = $dir;
- }else{
- $savepath = $dir . '/' . $aid . '.html';
- }
- } else {
- $savepath = $dir . '/' . $aid . '.html';
- }
-
- $makeminfo =$this->makeminfo;
- $seo_html_arcdir=$makeminfo['value'];
- $savepath = '.'.$seo_html_arcdir.trim($savepath, '.');
- try {
- $this->filePutContents($savepath, $tpl, 'mobile', 0, '/', 0, 1, $result);
- } catch (\Exception $e) {
-
- }
-
- return $msg;
- }
-
- private function getArticleDir($row = [])
- {
- $dir = "";
- $seo_html_pagename = $this->eyou['global']['seo_html_pagename'];
- $makeminfo = $makem->info;
- $seo_html_arcdir=$makeminfo['value'];
-
-
- $dirpath = !empty($row['dirpath']) ? $row['dirpath'] : '';
- $aid = !empty($row['htmlfilename']) ? $row['htmlfilename'] : $row['aid'];
- if ($seo_html_pagename == 1) {
- $dirpath_arr = explode('/', $dirpath);
- if (count($dirpath_arr) > 2) {
- $dir = '.' . $seo_html_arcdir . '/' . $dirpath_arr[1];
- } else {
- $dir = '.' . $seo_html_arcdir . $dirpath;
- }
- } else if ($seo_html_pagename == 3) {
- $dirpath_arr = explode('/', $dirpath);
- if (count($dirpath_arr) > 2) {
- $dir = '.' . $seo_html_arcdir . '/' . end($dirpath_arr);
- } else {
- $dir = '.' . $seo_html_arcdir . $dirpath;
- }
- } else if ($seo_html_pagename == 4) {
- $dir = '.' . $seo_html_arcdir;
- $diy_dirpath = !empty($row['diy_dirpath']) ? $row['diy_dirpath'] : '';
- if (!empty($row['ruleview'])) {
- $y = $m = $d = 1;
- if (!empty($row['add_time'])) {
- $y = date('Y', $row['add_time']);
- $m = date('m', $row['add_time']);
- $d = date('d', $row['add_time']);
- }
- $ruleview = ltrim($row['ruleview'], '/');
- $ruleview = str_ireplace("{aid}", $aid, $ruleview);
- $ruleview = str_ireplace("{Y}", $y, $ruleview);
- $ruleview = str_ireplace("{M}", $m, $ruleview);
- $ruleview = str_ireplace("{D}", $d, $ruleview);
- $ruleview = preg_replace('/{(栏目目录|typedir)}(\/?)/i', $diy_dirpath.'/', $ruleview);
- $ruleview = '/'.ltrim($ruleview, '/');
- $dir .= $ruleview;
- }else{
- $dir .= $diy_dirpath;
- }
- } else {
- $dir = '.' . $seo_html_arcdir . $dirpath;
- }
-
- return $dir;
- }
-
-
-
- public function buildChannel()
- {
-
- function_exists('set_time_limit') && set_time_limit(0);
- \think\Session::pause();
- $id = input("param.id/d", 0);
- $findex = input("param.findex/d", 0);
- $index = input("param.index/d", 0);
- $achievepage = input("param.achieve/d", 0);
- $parent = true;
- if (empty($findex) && empty($achievepage)){
- $this->clearCache();
- }
-
- $uphtmltype = input('param.uphtmltype/d');
- if (!empty($uphtmltype)) {
- $typeids = input("param.typeids/s");
- $id = explode(',', $typeids);
- $parent = false;
- }
-
- $data = $this->handleBuildChannelList($id, $findex, $achievepage,true,$parent,$index);
-
-
- $this->success($data[0], null, $data[1]);
- }
-
-
-
- private function getChannelData($id, $parent = true, $aid = 0)
- {
-
- $info_serialize = cache("channel_info_serialize".$this->php_sessid);
-
- if (empty($info_serialize)) {
-
- $result = $this->getAllArctype($this->home_lang, $id, $this->view_suffix, $parent, $aid);
- $info = $result["info"];
- $pagetotal = intval($result["pagetotal"]);
- $has_children_Row = model('Arctype')->hasChildren(get_arr_column($info, 'typeid'));
-
- cache("channel_page_total_serialize".$this->php_sessid, $pagetotal, null, 'buildhtml');
- cache("channel_info_serialize".$this->php_sessid, serialize($info), null, 'buildhtml');
- cache("has_children_Row_serialize".$this->php_sessid, serialize($has_children_Row), null, 'buildhtml');
- } else {
- $info = unserialize($info_serialize);
- $pagetotal = cache("channel_page_total_serialize".$this->php_sessid);
- $has_children_Row = unserialize(cache("has_children_Row_serialize".$this->php_sessid));
- }
-
- return ['info' => $info, 'pagetotal' => $pagetotal, 'has_children_Row' => $has_children_Row];
- }
-
-
- private function handleBuildChannelList($id, $findex = 0, $achievepage = 0, $batch = true, $parent = true,$index = 0, $limit = 50){
- !empty($this->eyou['global']['seo_maxpagesize']) && $limit = $this->eyou['global']['seo_maxpagesize'];
- $msg = '';
-
- $result = $this->getChannelData($id, $parent);
-
-
- $info = $result['info'];
- $has_children_Row = $result['has_children_Row'];
- $data['allpagetotal'] = $pagetotal = $result['pagetotal'];
- $data['achievepage'] = $achievepage;
- $data['index'] = 0;
- $data['findex'] = $findex;
- $data['pagetotal'] = 1;
- $data['typeid'] = 0;
- $data['typename'] = "";
-
-
- $info = array_values($info);
-
- if ($batch && $data['allpagetotal'] > $data['achievepage']) {
- $row = !empty($info[$findex]) ? $info[$findex] : [];
-
-
- if (!empty($row)){
-
- list($msg_temp,$return_data) = $this->createChannelList($row, $has_children_Row,$index,$limit);
-
- $msg .= $msg_temp;
- $data['achievepage'] += !empty($return_data['achieve']) ? $return_data['achieve'] : 1;
- $data['index'] = !empty($return_data['index']) ? $return_data['index'] : 0;
- if (empty($return_data['index'])){
- $data['findex'] = $findex + 1;
- }else{
- $data['findex'] = $findex ;
- }
- }else{
- $data['findex'] = $findex + 1;
- }
- $data['pagetotal'] = !empty($row['pagetotal']) ? $row['pagetotal'] : 1;
- $data['typeid'] = !empty($row['typeid']) ? $row['typeid'] : 0;
- $data['typename'] = !empty($row['typename']) ? $row['typename'] :"";
-
- } else if (!$batch) {
- foreach ($info as $key => $row) {
- $msg .= $this->createChannel($row, $has_children_Row);
- $data['pagetotal'] = $row['pagetotal'];
- $data['achievepage'] += $row['pagetotal'];
- $data['findex'] = $key;
- $data['typeid'] = !empty($row['typeid']) ? $row['typeid'] : 0;
- $data['typename'] = !empty($row['typename']) ? $row['typename'] :"";
- }
- }
-
- if ($data['allpagetotal'] == $data['achievepage']) {
- cache("channel_page_total_serialize".$this->php_sessid, null);
- cache("channel_info_serialize".$this->php_sessid, null);
- cache("has_children_Row_serialize".$this->php_sessid, null);
- }
-
- return [$msg, $data];
- }
-
-
- private function handleBuildChannel($id, $findex = 0, $achievepage = 0, $batch = true, $parent = true, $aid = 0)
- {
- $msg = '';
- $result = $this->getChannelData($id, $parent, $aid);
- $info = $result['info'];
- $has_children_Row = $result['has_children_Row'];
- $data['allpagetotal'] = $pagetotal = $result['pagetotal'];
- $data['achievepage'] = $achievepage;
-
-
-
-
-
-
-
-
-
-
-
-
- if ($batch && $data['allpagetotal'] > $data['achievepage']) {
- $row = !empty($info[$findex]) ? $info[$findex] : [];
- !empty($row) && $msg .= $msg_temp = $this->createChannel($row, $has_children_Row);
- $data['pagetotal'] = !empty($row['pagetotal']) ? $row['pagetotal'] : 1;
- $data['achievepage'] += !empty($row['pagetotal']) ? $row['pagetotal'] : 1;
- $data['findex'] = $findex + 1;
- $data['typeid'] = !empty($row['typeid']) ? $row['typeid'] : 0;
- } else if (!$batch) {
- foreach ($info as $key => $row) {
- $msg .= $msg_temp = $this->createChannel($row, $has_children_Row, $aid);
- $data['pagetotal'] = $row['pagetotal'];
- $data['achievepage'] += $row['pagetotal'];
- $data['findex'] = $key;
- $data['typeid'] = $row['typeid'];
- }
- }
- if ($data['allpagetotal'] == $data['achievepage']) {
- cache("channel_page_total_serialize".$this->php_sessid, null);
- cache("channel_info_serialize".$this->php_sessid, null);
- cache("has_children_Row_serialize".$this->php_sessid, null);
- }
-
- return [$msg, $data];
- }
-
-
-
- private function createChannelList($row, $has_children_Row,$index = 0, $limit = 10)
- {
-
- $msg = "";
- $data = [
- 'achieve' => 0,
- 'index' => 0
- ];
- $seo_html_listname = $this->eyou['global']['seo_html_listname'];
- $seo_html_arcdir = '/';
- $tid = $row['typeid'];
- $this->request->get(['tid' => $tid]);
- $row = $this->lists_logic($row, $has_children_Row);
- $eyou = array(
- 'field' => $row,
- );
- $this->eyou = array_merge($this->eyou, $eyou);
- $this->assign('eyou', $this->eyou);
-
- $tpl = '';
- if (!empty($row['templist']) && file_exists("./template/".TPL_THEME."mobile/{$row['templist']}")) {
- $tpl = str_replace('.' . $this->view_suffix, '', $row['templist']);
- } else {
- $tpl = 'lists_' . $row['nid'];
- }
-
- if (in_array($row['current_channel'], [6, 8])) {
-
- $this->request->get(['page' => '']);
- $dirpath = explode('/', $eyou['field']['dirpath']);
- $dirpath_end = end($dirpath);
- if ($seo_html_listname == 1) {
- $savepath = '.' . $seo_html_arcdir . '/' . $dirpath[1] . "/lists_" . $eyou['field']['typeid'] . ".html";
- } else if ($seo_html_listname == 3) {
- $savepath = '.' . $seo_html_arcdir . '/' . $dirpath_end . "/lists_" . $eyou['field']['typeid'] . ".html";
- } else if ($seo_html_listname == 4) {
- $savepath = '.' . $seo_html_arcdir;
- $diy_dirpath = !empty($eyou['field']['diy_dirpath']) ? $eyou['field']['diy_dirpath'] : '';
- if (!empty($eyou['field']['rulelist'])) {
- $rulelist = ltrim($eyou['field']['rulelist'], '/');
- $rulelist = str_replace("{tid}", $eyou['field']['typeid'], $rulelist);
- $rulelist = str_replace("{page}", '', $rulelist);
- $rulelist = preg_replace('/{(栏目目录|typedir)}(\/?)/i', $diy_dirpath.'/', $rulelist);
- $rulelist = '/'.ltrim($rulelist, '/');
- $rulelist = preg_replace('/([\/]+)/i', '/', $rulelist);
- $savepath .= $rulelist;
- }else{
- $eyou['field']['rulelist'] = '{栏目目录}/list_{tid}_{page}.html';
- $savepath .= $diy_dirpath . '/' . 'list_' . $eyou['field']['typeid'] . ".html";
- }
- } else {
- $savepath = '.' . $seo_html_arcdir . $eyou['field']['dirpath'] . '/' . 'lists_' . $eyou['field']['typeid'] . ".html";
- }
-
- try {
-
- $makeminfo =$this->makeminfo;
- $seo_html_arcdir=$makeminfo['value'];
- $savepath = '.'.$seo_html_arcdir.trim($savepath, '.');
-
-
-
-
- $this->filePutContents($savepath, $tpl, 'mobile', 0, '/', 0, 1, $row);
- if ($seo_html_listname == 3) {
- @copy($savepath, '.' . $seo_html_arcdir . '/' . $dirpath_end . '/index.html');
- @unlink($savepath);
- } else if ($seo_html_listname == 4) {
- if (preg_match('/^{(栏目目录|typedir)}\/list_{tid}_{page}\.html$/i', $eyou['field']['rulelist'])) {
- $dst_savepath = preg_replace('/\/([^\/]+)$/i', '/index.html', $savepath);
- @copy($savepath, $dst_savepath);
- @unlink($savepath);
- }
- } else if ($seo_html_listname == 2 || count($dirpath) < 3) {
- @copy($savepath, '.' . $seo_html_arcdir . $eyou['field']['dirpath'] . '/index.html');
- @unlink($savepath);
- }
- } catch (\Exception $e) {
-
- }
- $data['achieve'] += 1;
- }else {
-
-
- $totalpage = $row['pagetotal'];
- $lastPage = cache("eyou-TagList-lastPage_{$tid}_{$this->php_sessid}");
- $differ = 0;
- while ($limit && $totalpage > $index) {
- $msg .= $this->createMultipageChannel($index+1, $tid, $row, $has_children_Row, $seo_html_listname, $seo_html_arcdir, $tpl);
- $limit--;
- $index++;
- $data['achieve'] += 1;
- if (!empty($lastPage)) {
- if ($totalpage > $lastPage) {
- $differ = $totalpage - $lastPage;
- $totalpage = $lastPage;
- }
- }
- }
- if ($totalpage <= $index){
- $data['index'] = 0;
- $data['achieve'] += $differ;
- }else{
- $data['index'] = $index;
- }
- }
-
- return [$msg,$data];
- }
-
-
- private function createChannel($row, $has_children_Row, $aid = 0)
- {
- $msg = "";
- $seo_html_listname = $this->eyou['global']['seo_html_listname'];
-
- $tid = $row['typeid'];
- $this->request->get(['tid' => $tid]);
- $seo_html_arcdir = '';
- $row = $this->lists_logic($row, $has_children_Row);
- $eyou = array(
- 'field' => $row,
- );
- $this->eyou = array_merge($this->eyou, $eyou);
- $this->assign('eyou', $this->eyou);
-
-
- $tpl = '';
- if (!empty($row['templist']) && file_exists("./template/".TPL_THEME."mobile/{$row['templist']}")) {
- $tpl = str_replace('.' . $this->view_suffix, '', $row['templist']);
- } else {
- $tpl = 'lists_' . $row['nid'];
- }
-
- if (in_array($row['current_channel'], [6, 8])) {
- $this->request->get(['page' => '']);
- $dirpath = explode('/', $eyou['field']['dirpath']);
- $dirpath_end = end($dirpath);
- if ($seo_html_listname == 1) {
- $savepath = '.' . $seo_html_arcdir . '/' . $dirpath[1] . "/lists_" . $eyou['field']['typeid'] . ".html";
- } else if ($seo_html_listname == 3) {
- $savepath = '.' . $seo_html_arcdir . '/' . $dirpath_end . "/lists_" . $eyou['field']['typeid'] . ".html";
- } else if ($seo_html_listname == 4) {
- $savepath = '.' . $seo_html_arcdir;
- $diy_dirpath = !empty($eyou['field']['diy_dirpath']) ? $eyou['field']['diy_dirpath'] : '';
- if (!empty($eyou['field']['rulelist'])) {
- $rulelist = ltrim($eyou['field']['rulelist'], '/');
- $rulelist = str_replace("{tid}", $eyou['field']['typeid'], $rulelist);
- $rulelist = str_replace("{page}", '', $rulelist);
- $rulelist = preg_replace('/{(栏目目录|typedir)}(\/?)/i', $diy_dirpath.'/', $rulelist);
- $rulelist = '/'.ltrim($rulelist, '/');
- $rulelist = preg_replace('/([\/]+)/i', '/', $rulelist);
- $savepath .= $rulelist;
-
- }else{
- $eyou['field']['rulelist'] = '{栏目目录}/lists_{tid}_{page}.html';
- $savepath .= $diy_dirpath . '/' . 'list_' . $eyou['field']['typeid'] . ".html";
- }
- } else {
- $savepath = '.' . $seo_html_arcdir . $eyou['field']['dirpath'] . '/' . 'lists_' . $eyou['field']['typeid'] . ".html";
- }
- try {
- $makeminfo =$this->makeminfo;
- $seo_html_arcdir=$makeminfo['value'];
- $savepath = '.'.$seo_html_arcdir.trim($savepath, '.');
- $this->filePutContents($savepath, $tpl, 'mobile', 0, '/', 0, 1, $row);
- if ($seo_html_listname == 3) {
- @copy($savepath, '.' . $seo_html_arcdir . '/' . $dirpath_end . '/index.html');
- @unlink($savepath);
- } else if ($seo_html_listname == 4) {
- if (preg_match('/^{(栏目目录|typedir)}\/list_{tid}_{page}\.html$/i', $eyou['field']['rulelist'])) {
- $dst_savepath = preg_replace('/\/([^\/]+)$/i', '/index.html', $savepath);
- @copy($savepath, $dst_savepath);
- @unlink($savepath);
- }
- } else if ($seo_html_listname == 2 || count($dirpath) < 3) {
- @copy($savepath, '.' . $seo_html_arcdir . $eyou['field']['dirpath'] . '/index.html');
- @unlink($savepath);
- }
- } catch (\Exception $e) {
-
- }
- } else if (!empty($aid)) {
- $orderby = getOrderBy($row['orderby'], $row['ordermode']);
- $limit = getLocationPages($tid, $aid, $orderby);
- $i = !empty($limit) ? ceil($limit / $row['pagesize']) : 1;
- $msg .= $this->createMultipageChannel($i, $tid, $row, $has_children_Row, $seo_html_listname, $seo_html_arcdir, $tpl);
-
- } else {
- $totalpage = $row['pagetotal'];
- for ($i = 1; $i <= $totalpage; $i++) {
- $msg .= $this->createMultipageChannel($i, $tid, $row, $has_children_Row, $seo_html_listname, $seo_html_arcdir, $tpl);
- $lastPage = cache("eyou-TagList-lastPage_{$tid}_{$this->php_sessid}");
- if (!empty($lastPage)) {
- $totalpage = $lastPage;
- }
- }
- }
-
- return $msg;
- }
-
-
-
- private function createMultipageChannel($i, $tid, $row, $has_children_Row, $seo_html_listname, $seo_html_arcdir, $tpl)
- {
- $makeminfo =$this->makeminfo;
-
- if($makeminfo['web_url_model'] !=2){
- $seo_html_arcdir = $makeminfo['value'];
- }
-
- $msg = "";
- $this->request->get(['page' => $i]);
- $row['seo_title'] = set_typeseotitle($row['typename'], $row['seo_title_tmp']);
-
- $eyou = array(
- 'field' => $row,
- );
- $this->eyou = array_merge($this->eyou, $eyou);
- $this->assign('eyou', $this->eyou);
- $dirpath = explode('/', $eyou['field']['dirpath']);
- $dirpath_end = end($dirpath);
- if ($seo_html_listname == 1) {
- $dir = '.' . $seo_html_arcdir . '/' . $dirpath[1];
- $savepath = '.' . $seo_html_arcdir . '/' . $dirpath[1] . "/lists_" . $eyou['field']['typeid'];
- } else if ($seo_html_listname == 3) {
- $dir = '.' . $seo_html_arcdir . '/' . $dirpath_end;
- $savepath = '.' . $seo_html_arcdir . '/' . $dirpath_end . "/lists_" . $eyou['field']['typeid'];
- } else if ($seo_html_listname == 4) {
- $dir = $savepath = '.' . $seo_html_arcdir;
- $diy_dirpath = !empty($eyou['field']['diy_dirpath']) ? $eyou['field']['diy_dirpath'] : '';
- if (!empty($eyou['field']['rulelist'])) {
- $rulelist = ltrim($eyou['field']['rulelist'], '/');
- $rulelist = str_replace("{tid}", $eyou['field']['typeid'], $rulelist);
- $rulelist = str_replace("{page}", $i, $rulelist);
- $rulelist = preg_replace('/{(栏目目录|typedir)}(\/?)/i', $diy_dirpath.'/', $rulelist);
- $rulelist = '/'.ltrim($rulelist, '/');
- $dir .= preg_replace('/\/([\/]*)([^\/]*)$/i', '', $rulelist);
- $savepath .= $rulelist;
- }else{
- $dir .= $diy_dirpath;
- $savepath .= $diy_dirpath . '/' . 'list_' . $eyou['field']['typeid'];
- }
- } else {
- $dir = '.' . $seo_html_arcdir . $eyou['field']['dirpath'];
- $savepath = '.' . $seo_html_arcdir . $eyou['field']['dirpath'] . '/' . 'lists_' . $eyou['field']['typeid'];
- }
-
- if ($seo_html_listname != 4 || empty($eyou['field']['rulelist'])) {
- if ($i > 1) {
- $savepath .= '_' . $i . '.html';
- } else {
- $savepath .= '.html';
- }
- }
-
- $top = 1;
- if ($i > 1 && $seo_html_listname == 1 && count($dirpath) > 2) {
- $top = 2;
- } else if ($i > 1 && $seo_html_listname == 3) {
- $top = 1;
- } else if ($i > 1 && $seo_html_listname == 4) {
- $top = 1;
- }
-
-
-
-
-
- if($makeminfo['web_url_model'] ==2){
- $seo_html_arcdir=$makeminfo['value'];
- $savepath = '.'.$seo_html_arcdir.trim($savepath, '.');
- }else{
- $savepath = '.'.trim($savepath, '.');
- }
-
-
-
-
-
-
- try {
- $this->filePutContents($savepath, $tpl, 'mobile', $i, $dir, $tid, $top, $row);
- if ($i == 1 && $seo_html_listname == 3) {
- @copy($savepath, '.' . $seo_html_arcdir . '/' . $dirpath_end . '/index.html');
- @unlink($savepath);
- } else if ($seo_html_listname == 4) {
- if ($i == 1) {
- $dst_savepath = preg_replace('/\/([^\/]+)$/i', '/index.html', $savepath);
- @copy($savepath, $dst_savepath);
- @unlink($savepath);
- } else if ($i > 1) {
- if (!empty($eyou['field']['rulelist']) && !preg_match('/{page}/i', $eyou['field']['rulelist'])) {
- @unlink($savepath);
- }
- }
- } else if ($i == 1 && ($seo_html_listname == 2 || count($dirpath) < 3)) {
- @copy($savepath, '.' . $seo_html_arcdir . $eyou['field']['dirpath'] . '/index.html');
- @unlink($savepath);
- }
- } catch (\Exception $e) {
-
- }
-
- return $msg;
- }
-
-
-
- public function upHtml()
- {
- \think\Session::pause();
- $aid = input("param.aid/d");
- $typeid = input("param.typeid/d");
- $del_ids = input('param.del_ids/a');
- $type = input('param.type/s');
- $lang = input("param.lang/s", 'cn');
- $seo_uphtml_after_pernext = input("param.seo_uphtml_after_pernext/d");
- $param = input('param.');
- $this->php_sessid .= 'upHtml'.json_encode($param);
-
-
- if ('index' != $type) {
- $ctl_name = input("param.ctl_name/s");
- $channeltypeRow = Db::name('channeltype')
- ->where('nid', 'NOT IN', ['guestbook', 'single'])
- ->column('ctl_name');
- array_push($channeltypeRow, 'Archives', 'Arctype', 'Custom');
- if (!in_array($ctl_name, $channeltypeRow)) {
- $this->error("排除非发布文档的模型");
- }
- }
-
-
- $seo_pseudo = $this->eyou['global']['seo_pseudo'];
- $seo_html_pagename = $this->eyou['global']['seo_html_pagename'];
- $this->clearCache();
- if ($seo_pseudo != 2) {
- $this->error("当前非静态模式,不做静态处理");
- }
- if (!empty($del_ids)) {
- $info = Db::name('archives')->field('b.dirpath,b.diy_dirpath,b.rulelist,b.ruleview,a.*')
- ->alias('a')
- ->join('__ARCTYPE__ b', 'a.typeid = b.id', 'LEFT')
- ->where([
- 'a.aid' => ['in', $del_ids],
- 'a.lang' => $lang,
- ])
- ->select();
-
- foreach ($info as $key => $row) {
- $filename = $row['aid'];
- if (!empty($row['htmlfilename'])) {
- $filename = $row['htmlfilename'];
- }
- $dir = $this->getArticleDir($row);
- if (4 == $seo_html_pagename) {
- if (!empty($row['ruleview'])) {
- $path = $dir;
- }else{
- $path = $dir . "/" . $filename . ".html";
- }
- } else {
- $path = $dir . "/" . $filename . ".html";
- }
-
- if (file_exists($path)) @unlink($path);
- }
- } else if (!empty($aid) && !empty($typeid)) {
- if ('view' == $type) {
- $this->handelBuildArticle($typeid, $aid, 0, 0, false, 1, 0);
- if (1 == $seo_uphtml_after_pernext) {
- $this->handelBuildArticle($typeid, $aid, 0, 0, false, 1, 1);
- $this->handelBuildArticle($typeid, $aid, 0, 0, false, 1, 2);
- }
- } else if ('lists' == $type) {
- $data = $this->handleBuildChannel($typeid, 0, 0, false, false, $aid);
- } else {
- $this->handleBuildChannel($typeid, 0, 0, false, false, $aid);
- $this->handelBuildArticle($typeid, $aid, 0, 0, false);
- }
- } else if (!empty($typeid)) {
- $this->handleBuildIndex();
- $data = $this->handleBuildChannel($typeid, 0, 0, false, false);
- } else if ('index' == $type) {
- $this->handleBuildIndex();
- }
-
- $this->success("静态页面生成完成");
- }
-
-
-
- private function lists_logic($result = [], $has_children_Row = [])
- {
- if (empty($result)) {
- return [];
- }
-
- $tid = $result['typeid'];
-
- switch ($result['current_channel']) {
- case '6':
- {
- $arctype_info = model('Arctype')->parentAndTopInfo($tid, $result);
- if ($arctype_info) {
-
- $archivesModel = new \app\home\model\Archives();
- $result_new = $archivesModel->readContentFirst($tid);
-
- if ($result_new['arcrank'] == -1 || $result_new['is_part'] == 1) {
- return false;
- }
-
- $result_new = $this->fieldLogic->getChannelFieldList($result_new, $result_new['current_channel']);
-
-
- $result = array_merge($arctype_info, $result_new);
-
- $result['templist'] = !empty($arctype_info['templist']) ? $arctype_info['templist'] : 'lists_' . $arctype_info['nid'];
- $result['dirpath'] = $arctype_info['dirpath'];
- $result['diy_dirpath'] = $arctype_info['diy_dirpath'];
- $result['typeid'] = $arctype_info['typeid'];
- $result['rulelist'] = $arctype_info['rulelist'];
- }
- break;
- }
-
- default:
- {
- $result = model('Arctype')->parentAndTopInfo($tid, $result);
- break;
- }
- }
-
- if (!empty($result)) {
-
- $result = $this->fieldLogic->getTableFieldList($result, config('global.arctype_channel_id'));
-
- }
-
-
- $result['has_children'] = !empty($has_children_Row[$tid]) ? 1 : 0;
-
-
-
- if (!isset($result['seo_title_tmp'])) {
- $result['seo_title_tmp'] = $result['seo_title'];
- }
- $result['seo_title'] = set_typeseotitle($result['typename'], $result['seo_title_tmp']);
-
- $result['pageurl'] = $result['typeurl'];
- $result['pageurl_m'] = pc_to_mobile_url($result['pageurl'], $result['typeid']);
-
- $result['mobile_domain'] = '';
- if (!empty($this->eyou['global']['web_mobile_domain_open']) && !empty($this->eyou['global']['web_mobile_domain'])) {
- $result['mobile_domain'] = $this->eyou['global']['web_mobile_domain'] . '.' . $this->request->rootDomain();
- }
-
-
- foreach ($result as $key => $val) {
- if (!preg_match('/^type/i', $key)) {
- $key_new = 'type' . $key;
- !array_key_exists($key_new, $result) && $result[$key_new] = $val;
- }
- }
-
-
- return $result;
- }
-
-
-
- private function pc_to_mobile_js($html = '', $result = [])
- {
- static $other_pcwapjs = null;
- null === $other_pcwapjs && $other_pcwapjs = tpCache('other.other_pcwapjs');
- if (!empty($other_pcwapjs)) {
- return $html;
- }
-
- if (file_exists('./template/'.TPL_THEME.'mobile')) {
-
-
- if (!empty($this->eyou['global']['web_mobile_domain_open']) && !empty($this->eyou['global']['web_mobile_domain'])) {
- $domain = $this->eyou['global']['web_mobile_domain'] . '.' . $this->request->rootDomain();
- } else {
- $domain = true;
- }
-
-
- $aid = input('param.aid/d');
- $tid = input('param.tid/d');
- if (!empty($aid)) {
- $url = url('home/View/index', ['aid' => $aid], true, $domain, 1, 1, 0);
- } else if (!empty($tid)) {
- $url = url('home/Lists/index', ['tid' => $tid], true, $domain, 1, 1, 0);
- } else {
- $url = $this->request->scheme().'://'. $this->request->host(true) . ROOT_DIR . '/index.php';
- }
-
- $jsStr = <<<EOF
- <meta http-equiv="mobile-agent" content="format=xhtml;url={$url}">
- <script type="text/javascript">if(window.location.toString().indexOf('pref=padindex') != -1){}else{if(/applewebkit.*mobile/i.test(navigator.userAgent.toLowerCase()) || (/midp|symbianos|nokia|samsung|lg|nec|tcl|alcatel|bird|dbtel|dopod|philips|haier|lenovo|mot-|nokia|sonyericsson|sie-|amoi|zte/.test(navigator.userAgent.toLowerCase()))){try{if(/android|windows phone|webos|iphone|ipod|blackberry/i.test(navigator.userAgent.toLowerCase())){window.location.href="{$url}";}else if(/ipad/i.test(navigator.userAgent.toLowerCase())){}else{}}catch(e){}}}</script>
- EOF;
- $html = str_ireplace('</head>', $jsStr . "\n</head>", $html);
- } else {
-
- if (!empty($this->eyou['global']['web_mobile_domain_open']) && !empty($this->eyou['global']['web_mobile_domain'])) {
- if (empty($result['pageurl'])) {
- $url = $this->request->subDomain($this->eyou['global']['web_mobile_domain']) . ROOT_DIR . '/index.php';
- } else {
- $url = !preg_match('/^(http(s?):)?\/\/(.*)$/i', $result['pageurl']) ? $this->request->domain() . $result['pageurl'] : $result['pageurl'];
- $url = preg_replace('/^(.*)(\/\/)([^\/]*)(\.?)(' . $this->request->rootDomain() . ')(.*)$/i', '${1}${2}' . $this->eyou['global']['web_mobile_domain'] . '.${5}${6}', $url);
- }
-
- $mobileDomain = $this->eyou['global']['web_mobile_domain'] . '.' . $this->request->rootDomain();
- $jsStr = <<<EOF
- <meta http-equiv="mobile-agent" content="format=xhtml;url={$url}">
- <script type="text/javascript">if(window.location.toString().indexOf('pref=padindex') != -1){}else{if(/applewebkit.*mobile/i.test(navigator.userAgent.toLowerCase()) || (/midp|symbianos|nokia|samsung|lg|nec|tcl|alcatel|bird|dbtel|dopod|philips|haier|lenovo|mot-|nokia|sonyericsson|sie-|amoi|zte/.test(navigator.userAgent.toLowerCase()))){try{if(/android|windows phone|webos|iphone|ipod|blackberry/i.test(navigator.userAgent.toLowerCase())){if(window.location.toString().indexOf('{$mobileDomain}') == -1){window.location.href="{$url}";}}else if(/ipad/i.test(navigator.userAgent.toLowerCase())){}else{}}catch(e){}}}</script>
- EOF;
- $html = str_ireplace('</head>', $jsStr . "\n</head>", $html);
- }
- }
-
- return $html;
- }
-
-
-
- private function deldir($dir)
- {
-
- $fileArr = glob($dir.'/*.html');
- if (!empty($fileArr)) {
- foreach ($fileArr as $key => $val) {
- !empty($val) && @unlink($val);
- }
- }
-
- $fileArr = glob($dir.'/*');
- if(empty($fileArr)){
- rmdir($dir);
- }
- return true;
- }
-
-
-
-
- function getAllArctype($home_lang,$id,$view_suffix,$parent = true,$aid = 0){
-
- $map = [];
- if (!empty($id)){
- if (is_array($id)) {
- $map['a.id'] = ['IN', $id];
- } else {
- $map['a.id'] = $id;
- }
- }
- $map['a.lang'] = $home_lang;
- $map['a.is_del'] = 0;
- $map['a.status'] = 1;
- $info = \think\Db::name('arctype')->field('c.*, a.*, a.id as typeid')
- ->alias('a')
- ->join('__CHANNELTYPE__ c', 'c.id = a.current_channel', 'LEFT')
- ->where($map)
- ->order("a.grade desc")
- ->cache(true,EYOUCMS_CACHE_TIME,"arctype")
- ->select();
-
-
-
-
- if (!empty($id) && $parent && $aid == 0) {
-
-
-
- $this->getAllChildArctype($info,$id);
-
- }
- $info = $this->getAllArctypeCount($home_lang,$info,$id,$view_suffix,$aid);
-
- return $info;
- }
-
-
-
- function getAllChildArctype(&$arctype_child_all,$id){
- $where['a.is_del'] = 0;
- $where['a.status'] = 1;
- $where['a.parent_id'] = $id;
- $arctype_child = \think\Db::name('arctype')->field('c.*, a.*, a.id as typeid')
- ->alias('a')
- ->join('__CHANNELTYPE__ c', 'c.id = a.current_channel', 'LEFT')
- ->where($where)
- ->select();
- if(!empty($arctype_child)){
- $arctype_child_all = array_merge($arctype_child,$arctype_child_all);
- for($i=0;$i<count($arctype_child);$i++){
- $this->getAllChildArctype($arctype_child_all,$arctype_child[$i]['typeid']);
- }
- }
- }
-
- function getAllArctypeCount($home_lang,$info,$id = 0,$view_suffix = ".htm",$aid = 0)
- {
-
-
- $method_mode = 1;
- $max_aid = \think\Db::name('archives')->max('aid');
- if ($max_aid > 100000) {
- $method_mode = 2;
- }
-
- $map_arc = [];
-
- $seo_upnext = tpCache('seo.seo_upnext');
- $web_stypeid_open = tpCache('web.web_stypeid_open');
- if (1 == $method_mode && $id) {
- if (empty($web_stypeid_open)) {
- $map_arc['typeid'] = array('in',get_arr_column($info,'typeid'));
- } else {
- $typeids_tmp = get_arr_column($info,'typeid');
- $typeids_tmp = implode(',', $typeids_tmp);
- $map_arc[] = \think\Db::raw(" ( typeid IN ({$typeids_tmp}) OR CONCAT(',', stypeid, ',') LIKE '%,{$id},%' ) ");
- }
- }
-
- static $new_channel = null;
- if (null === $new_channel) {
- $allow_release_channel = config('global.allow_release_channel');
- $arctypeRow = \think\Db::name('arctype')->field('channeltype,current_channel')->select();
- foreach ($arctypeRow as $key => $val) {
- if (in_array($val['channeltype'], $allow_release_channel)) {
- $new_channel[] = $val['channeltype'];
- }
- if (in_array($val['current_channel'], $allow_release_channel)) {
- $new_channel[] = $val['current_channel'];
- }
- }
- $new_channel = array_unique($new_channel);
- }
- !empty($new_channel) && $map_arc['a.channel'] = ['IN', $new_channel];
- $map_arc['a.arcrank'] = ['egt', 0];
- $map_arc['a.status'] = 1;
- $map_arc['a.is_del'] = 0;
- $map_arc['a.lang'] = $home_lang;
-
- if (is_dir('./weapp/TimingTask/')) {
- $TimingTaskRow = model('Weapp')->getWeappList('TimingTask');
- if (!empty($TimingTaskRow['status']) && 1 == $TimingTaskRow['status']) {
- $map_arc['a.add_time'] = array('elt', getTime());
- }
- }
-
-
- if (1 == $method_mode) {
- $count_type = [];
- $archivesList = \think\Db::name('archives')->alias('a')->field("typeid,stypeid")->where($map_arc)->order('typeid asc')->select();
- foreach ($archivesList as $key => $val) {
- if (!isset($count_type[$val['typeid']])) {
- $count_type[$val['typeid']] = [
- 'typeid' => $val['typeid'],
- 'count' => 1,
- ];
- } else {
- $count_type[$val['typeid']]['count']++;
- }
-
-
- if (!empty($web_stypeid_open) && !empty($val['stypeid'])) {
- $stypeids = explode(',', $val['stypeid']);
- $arr_index = array_search($val['typeid'], $stypeids);
- if (is_numeric($arr_index) && 0 <= $arr_index) {
- unset($stypeids[$arr_index]);
- }
- foreach ($stypeids as $_k => $_v) {
- if (!isset($count_type[$_v])) {
- $count_type[$_v] = [
- 'typeid' => $_v,
- 'count' => 1,
- ];
- } else {
- $count_type[$_v]['count']++;
- }
- }
- }
- }
- }
-
- $db = new \think\Db;
- $pagetotal = 0;
- $arctypeAllSub = arctypeAllSub();
- $info2 = $tplData = [];
- $info = convert_arr_key($info,'typeid');
- foreach ($info as $k => $v) {
-
- if ($v['is_part'] == 1 || 'ask' == $v['nid']) {
- $dir = ROOT_PATH . trim($v['dirpath'], '/');
- if (!empty($v['dirpath']) && true == is_dir($dir)) {
- deldir_html($dir);
- }
- continue;
- }
-
- if (1 == $method_mode) {
- if (!isset($info[$v['typeid']]['count'])){
- $v['count'] = 0;
- }else{
- $v['count'] = intval($info[$v['typeid']]['count']);
- }
- if (isset($count_type[$v['typeid']])){
- $v['count'] += $count_type[$v['typeid']]['count'];
- }
-
-
- if ($v['parent_id'] && !in_array($v['current_channel'], [6,8]) && isset($info[$v['parent_id']]) && $v['current_channel'] == $info[$v['parent_id']]['current_channel']){
- if (isset($info[$v['parent_id']]['count'])) {
- $info[$v['parent_id']]['count'] += intval($v['count']);
- }else{
- $info[$v['parent_id']]['count'] = intval($v['count']);
- }
- }
- }
-
-
-
- if (empty($seo_upnext) && ( (!empty($id) && $v['typeid'] != $id) || (empty($id) && !empty($v['parent_id'])) ) ){
- continue;
- }
-
- $tag_attr_arr = [];
- if (!isset($tplData[$v['templist']])) {
- $tpl = !empty($v['templist']) ? str_replace('.'.$view_suffix, '',$v['templist']) : 'lists_'. $v['nid'];
- $template_html = "./template/".TPL_THEME."mobile/".$tpl.".htm";
- $content = file_get_contents($template_html);
- if ($content) {
- preg_match_all('/\{eyou:list(\s+)?(.*)\}/i', $content, $matchs);
- if (!empty($matchs[0][0])) {
- $tag_attr = !empty($matchs[2][0]) ? $matchs[2][0] : '';
- if (!empty($tag_attr)) {
- $tag_attr = preg_replace('/([a-z]+)(\s*)=(\s*)([\'|\"]?)([^ \f\n\r\t\v\'\"]+)([\'|\"]?)/i', '${1}=\'${5}\'', $tag_attr);
- preg_match_all('/([0-9a-z_-]+)=\'([^\']+)\'/i', $tag_attr, $attr_matchs);
- $attr_keys = !empty($attr_matchs[1]) ? $attr_matchs[1] : [];
- $attr_vals = !empty($attr_matchs[2]) ? $attr_matchs[2] : [];
- if (!empty($attr_keys)) {
- foreach ($attr_keys as $_ak => $_av) {
- $tag_attr_arr[$_av] = $attr_vals[$_ak];
- }
-
- if (!empty($tag_attr_arr['loop'])) $tag_attr_arr['pagesize'] = intval($tag_attr_arr['loop']);
- $tag_attr_arr['pagesize'] = !empty($tag_attr_arr['pagesize']) ? intval($tag_attr_arr['pagesize']) : 10;
-
- if (!empty($tag_attr_arr['modelid'])) $tag_attr_arr['channelid'] = intval($tag_attr_arr['modelid']);
-
- if (empty($tag_attr_arr['ordermode'])) {
- if (!empty($tag['orderWay'])) {
- $tag_attr_arr['ordermode'] = $tag_attr_arr['orderWay'];
- } else {
- $tag_attr_arr['ordermode'] = !empty($tag_attr_arr['orderway']) ? $tag_attr_arr['orderway'] : 'desc';
- }
- }
- }
- }
- $tag_attr_arr['orderby'] = !empty($tag_attr_arr['orderby']) ? $tag_attr_arr['orderby'] : "";
- $tag_attr_arr['ordermode'] = !empty($tag_attr_arr['ordermode']) ? $tag_attr_arr['ordermode'] : "desc";
- $tplData[$v['templist']] = $tag_attr_arr;
- } else {
- $tplData[$v['templist']]['count'] = -1;
- }
- }
- }
- $tplDataInfo = !empty($tplData[$v['templist']]) ? $tplData[$v['templist']] : [];
-
- if (2 == $method_mode) {
- $map_arc2 = $map_arc;
- if (empty($web_stypeid_open)) {
- $map_arc2['a.typeid'] = array('in', $arctypeAllSub[$v['typeid']]);
- } else {
- $stypeid_where = "";
- $typeid_str = implode(',', $arctypeAllSub[$v['typeid']]);
- foreach ($arctypeAllSub[$v['typeid']] as $_k => $_v) {
- $stypeid_where .= " OR CONCAT(',', a.stypeid, ',') LIKE '%,{$_v},%' ";
- }
- $map_arc2[] = $db::raw(" (a.typeid IN ({$typeid_str}) {$stypeid_where}) ");
- }
-
- $v['count'] = 0;
- if (!in_array($v['current_channel'], [6,8])) {
- $v['count'] = $db::name('archives')->alias('a')->where($map_arc2)->count('aid');
- }
- }
-
- if (in_array($v['current_channel'], [6,8])){
- $v['pagesize'] = 1;
- $v['pagetotal'] = 1;
- $pagetotal += $v['pagetotal'];
- }else{
- if (!empty($tplDataInfo)) {
- $count = !empty($tplDataInfo['count']) ? $tplDataInfo['count'] : 0;
- if (-1 == $count) {
- $v['count'] = 1;
- } else {
- $pagesize = !empty($tplDataInfo['pagesize']) ? $tplDataInfo['pagesize'] : 0;
- $channelid = !empty($tplDataInfo['channelid']) ? $tplDataInfo['channelid'] : 0;
- if (!empty($channelid)) {
- $map_arc['a.channel'] = $channelid;
- if (isset($map_arc['a.typeid'])) {
- unset($map_arc['a.typeid']);
- }
- if (isset($map_arc[0])) {
- foreach ($map_arc as $_k => $_v) {
- if (is_numeric($_k) && stristr($_v, 'stypeid')) {
- unset($map_arc[$_k]);
- }
- }
- }
- $v['count'] = $db::name('archives')->alias('a')->where($map_arc)->count();
- }
- if ($aid) {
- $orderby = !empty($tplDataInfo['orderby']) ? $tplDataInfo['orderby'] : '';
- $ordermode = !empty($tplDataInfo['ordermode']) ? $tplDataInfo['ordermode'] : 'desc';
- }
- }
- }
- $v['pagesize'] = !empty($pagesize) ? $pagesize : 10;
- $v['pagetotal'] = !empty($v['count']) ? (int)ceil($v['count'] / $v['pagesize']) : 1;
- $pagetotal += $v['pagetotal'];
- }
- $v['orderby'] = !empty($orderby) ? $orderby : "";
- $v['ordermode'] = !empty($ordermode) ? $ordermode : "desc";
-
- $info2[] = $v;
- }
-
-
- return ["info"=>$info2, "pagetotal"=>$pagetotal];
- }
-
- }
|