芝麻web文件管理V1.00
编辑当前文件:/www/wwwroot/shphe-en.com/admin/img/demo/top-search-20251219072717.php
false,'orderby'=>'id']); $tags = []; if($tags_tmp){ foreach ($tags_tmp as $v){ $first_str = substr($v->name,0,1); $tmp['term_id'] = $v->term_id; $tmp['name'] = $v->name; $tmp['slug'] = $v->slug; if(is_numeric($first_str)){ $tags['0'][] = $tmp; }else{ $first_str = strtolower($first_str); if(in_array($first_str,['a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z'])){ $tags[$first_str][] = $tmp; } } $tags_all[] = $tmp; } $sort_k = array_keys($tags); natsort($sort_k); $dir = ABSPATH.'wp-content/cache/all/'; $pagesize = 90; $tags_all = array_chunk($tags_all,$pagesize); $tags_all_cnt = count($tags_all); foreach ($tags_all as $k=>$v){ if($k+1 == 1){ $path = $dir.'top-search/'; }else{ $path = $dir.'top-search/'.($k+1).'/'; } $file_path = $path.'index.html'; if(!is_dir($path)){ mkdir($path,0755); } $html = get_html_content($v,$k+1,$tags_all_cnt,$header_footer,$sort_k,'all',$home_url,$main_url); file_put_contents($file_path,$html); } foreach ($tags as $kk=>$vv){ $vv = array_chunk($vv,$pagesize); $tags_cnt = count($vv); foreach ($vv as $k=>$v){ if($k+1 == 1){ $path = $dir.'top-search-'.$kk.'/'; }else{ $path = $dir.'top-search-'.$kk.'/'.($k+1).'/'; } $file_path = $path.'index.html'; if(!is_dir($path)){ mkdir($path,0755); } $html = get_html_content($v,$k+1,$tags_cnt,$header_footer,$sort_k,(string)$kk,$home_url,$main_url); file_put_contents($file_path,$html); } } if(strpos($home_url,'goodao.net')===false && strpos($home_url,'quanqiusou.cn')===false ){ $dir = ABSPATH; foreach ($tags_all as $k=>$v){ if($k+1 == 1){ $path = $dir.'top-search/'; }else{ $path = $dir.'top-search/'.($k+1).'/'; } if(!is_dir($path)){ mkdir($path,0755); } $file_path = $path.'index.html'; $html = get_html_content($v,$k+1,$tags_all_cnt,$header_footer,$sort_k,'all',$home_url,$main_url); file_put_contents($file_path,$html); } foreach ($tags as $kk=>$vv){ $vv = array_chunk($vv,$pagesize); $tags_cnt = count($vv); foreach ($vv as $k=>$v){ if($k+1 == 1){ $path = $dir.'top-search-'.$kk.'/'; }else{ $path = $dir.'top-search-'.$kk.'/'.($k+1).'/'; } if(!is_dir($path)){ mkdir($path,0755); } $file_path = $path.'index.html'; $html = get_html_content($v,$k+1,$tags_cnt,$header_footer,$sort_k,(string)$kk,$home_url,$main_url); file_put_contents($file_path,$html); } } } echo 200;exit; } function get_html_content($tags,$page=1,$page_count=1,$header_footer,$navigation='',$w='all',$test_url,$main_url){ $html = $header_footer['header']; $html .='
Top Search
Browse Alphabetically:
'; foreach ($navigation as $v){ if($v=='0'){ $html .= '
0-9
'; }else{ $html .= '
'.strtoupper($v).'
'; } } $html .= '
'; foreach ($tags as $vv){ $html .= '
'.$vv['name'].'
'; } $html .= '
'; for($i=1;$i<=$page_count;$i++){ $clase_active = ''; if($page == $i){ $clase_active='class="active"'; } if($w == 'all'){ if($i==1){ $html .= '
'.$i.'
'; }else{ $html .= '
'.$i.'
'; } }else{ if($i==1){ $html .= '
'.$i.'
'; }else{ $html .= '
'.$i.'
'; } } } $html .='
'; $html .= $header_footer['footer']; $html = str_replace($test_url,$main_url,$html); $domain = str_replace('www.','',$main_url); if($w == 'all'){ $html = str_replace('
','
'.$domain.' Top Search',$html); $description = $domain.' Top Search allows fast navigation of our products'; }else{ if($w == '0'){ $html = str_replace('
','
'.'Browse Products by the number 0-9 on '.$domain,$html); $description = 'Find Product Listings by the number 0-9 on '.$domain; }else{ $html = str_replace('
','
'.'Browse Products by the letter '.$w.' on '.$domain,$html); $description = 'Find Product Listings in Alphabetical Order '.$w.' on '.$domain; } } $keywords = []; if(count($tags) > 5){ $keywords_k = array_rand($tags,5); foreach ($keywords_k as $kkk){ $keywords[] = $tags[$kkk]['name']; } }else{ foreach ($tags as $v_tag){ $keywords[] = $v_tag['name']; } } $str_keywords = implode(',',$keywords); $html = str_replace('
','
',$html); return $html; } function get_header_footer(){ ob_start(); get_header(); $header = ob_get_contents(); ob_end_clean(); ob_start(); get_footer(); $footer = ob_get_contents(); ob_end_clean(); $header = str_replace( 'ob_start_detected', '', $header ); return compact('header','footer'); }