芝麻web文件管理V1.00
编辑当前文件:/www/wwwroot/shphe-en.com/extend_api.php
get_row("select pv,uv,ip from wp_stats_day_count where day ='$day'",ARRAY_A); $data['yesterday_pv'] = (int)$res['pv']; $data['yesterday_ip'] = (int)$res['ip']; $data['yesterday_uv'] = (int)$res['uv']; //全部访问统计 $res = array(); $res = $wpdb->get_row("select ip, pv, uv from wp_stats_year_count",ARRAY_A); $totol_ip = $wpdb->get_row("select count(id) t_ip, sum(pv) t_pv from wp_stats_day_ip where is_spider=1",ARRAY_A); $data['total_ip'] = (int)$totol_ip['t_ip']; $data['total_pv'] = (int)$totol_ip['t_pv']; $data['total_uv'] = (int)$res['uv']; //全部询盘数 $res = $wpdb->get_row("select count(*) as total from wp_cf7_data",ARRAY_A); $data['cf_count']= (int)$res['total']; //询盘转化率 $data['total_cf_f']= number_format(($data['cf_count']/$data['total_ip']), 4)*100; //月访问统计 for($k=-30;$k<=-1;$k++){ $d = date('Y-m-d',strtotime ( "$k day")); $res =array(); $res = $wpdb->get_row("select day, ip, pv, uv from wp_stats_day_count where day='$d'",ARRAY_A); $res['ip']=$res['ip']?$res['ip']:0; $res['pv']=$res['pv']?$res['pv']:0; $res['uv']=$res['uv']?$res['uv']:0; $res['day']=$res['day']?$res['day']:$d; $data['last30days_ip'][]=(int)$res['ip']; $data['last30days_pv'][]=(int)$res['pv']; $data['last30days_uv'][]=(int)$res['uv']; //$data['last30days'][$d]=$res; } $data['last7days_start_y']=date('Y',strtotime ( "-30 day")); $data['last7days_start_m']=intval(date('m',strtotime ( "-30 day"))); $data['last7days_start_d']=intval(date('d',strtotime ( "-30 day"))); $data['last7days_end_y']=date('Y',strtotime ( "-1 day")); $data['last7days_end_m']=intval(date('m'),strtotime ( "-1 day")); $data['last7days_end_d']=intval(date('d'),strtotime ( "-1 day")); //访问国家前10 $res = array(); $sql = 'select * from ( select count(1) ip_area,ip_area show_area, SUM(pv) show_pv, SUM(uv) show_uv, count(ip) show_ip from wp_stats_day_ip t group by t.ip_area order by count(1) desc ) t_1 limit 0, 15'; $wpdb->query($sql); $country_top10 = $wpdb->last_result; $tmp_i = 0; $data['country_top10_country'] = $data['country_top10_pv'] = $data['country_top10_ip'] = []; foreach($country_top10 as $key=>$v){ if($v->show_area!='Unknown' && $v->show_area!='香港' && $v->show_area!='中国' && $v->show_area!='台湾' && $v->show_area!=''){ if($tmp_i < 10){ $data['country_top10_country'][]=$v->show_area; $data['country_top10_pv'][]=(int)$v->show_pv; $data['country_top10_ip'][]=(int)$v->show_ip; } $tmp_i ++; } } //访问来源前10 $res =array(); $sql = "select * from ( select count(1) num_referrer,referrer from wp_stats_day_ip t group by t.referrer order by count(1) desc ) t_1 limit 0, 15"; $wpdb->query($sql); $referrer_top8 = array(); if($wpdb->last_result){ foreach($wpdb->last_result as $val){ if(($val->referrer != '')){ if(strpos($val->referrer,home_url()) !== 0){ if(strlen($val->referrer) > 50){ $val->referrer = substr($val->referrer,0,50); } $t_ar['num_referrer'] = $val->num_referrer; $t_ar['referrer'] = $val->referrer; $referrer_top8[] = $t_ar; } } } } $data['referrer_top8'] = $referrer_top8; //访问国家top15 $country_top15_area = array(); $sql = "select * from ( select count(1) ip_area,ip_area show_area from wp_stats_day_ip t group by t.ip_area order by count(1) desc ) t_1 limit 0, 19"; $res = $wpdb->get_results($sql,ARRAY_A); if($res){ foreach($res as $val){ if($val['show_area'] != '中国' && $val['show_area'] != '台湾' && $val['show_area'] != '香港' && $val['show_area'] != 'Unknown' && $val['show_area'] != ''){ $country_top15_area[] = $val; } } } $data['country_top15'] = $country_top15_area; $data['page_num'] = count(query_posts(array( 'post_type' => 'page','posts_per_page'=>-1))); $data['news_num'] = count(query_posts(array( 'post_type' => 'news','posts_per_page'=>-1))); /*$categories = get_categories( $args ); $excpt = []; if($categories){ foreach($categories as $k=>$v){ if($v->name == 'Featured'){ $excpt[] = $v->term_id; } } } $data['posts_num'] = count(query_posts(array('post_type' => 'post','category__not_in'=> $excpt,'showposts' => 10000))); $posts_num123 = $wpdb->get_results("select ID from wp_posts where not post_date_gmt='2016-01-08 00:00:00' and post_type='post' and post_status='publish'",ARRAY_A); $data['posts_num'] = count($posts_num123);*/ $posts_num_all = $wpdb->get_col( $wpdb->prepare( "SELECT ID FROM wp_posts WHERE post_type=%s AND post_status = %s", 'post', 'publish' ) ); $feature = $wpdb->get_row("SELECT count(*) as cnt_feature FROM `wp_term_relationships` WHERE `term_taxonomy_id` = 635"); $data['posts_num'] =count($posts_num_all)- $feature->cnt_feature; // //询盘国家统计 $res_cf7_ip = $wpdb->get_results("select b.`value` as ip from wp_cf7_data as d left join wp_cf7_data_entry as b on d.id=b.data_id where b.`name`='submit_ip'",ARRAY_A); $ar_tmp_ip = array(); if($res_cf7_ip){ foreach($res_cf7_ip as $k=>$v){ if(!in_array($v['ip'],$ar_tmp_ip)){ $ar_tmp_ip[] = $v['ip']; } } } $country_all_area = array(); if($ar_tmp_ip){ $sql = "select * from ( select count(1) ip_area,ip_area show_area from wp_stats_day_ip t where ip in ('".implode("','",$ar_tmp_ip)."') group by t.ip_area order by count(1) desc ) t_1 limit 0, 19"; $wpdb->query($sql); if($wpdb->last_result){ foreach($wpdb->last_result as $val){ if($val->show_area != '台湾' && $val->show_area != '香港' && $val->show_area != 'Unknown' && $val->show_area != ''){ $t_ar['ip_area'] = $val->ip_area; $t_ar['show_area'] = $val->show_area; $country_all_area[] = $t_ar; } } } } $data['xunpan_dis'] = $country_all_area; $email_info = get_post_meta(19,'_mail'); $email = $email_info[0]['recipient']; $data['email'] = $email; $data['phone'] = get_option('sms_phone_num',true); //print_r($data);exit; echo json_encode($data);exit; break; case 2://输出询盘信息 $timelist = $wpdb->get_results("select * from wp_cf7_data order by id desc limit 50",ARRAY_A); $data = []; if($timelist){ foreach ($timelist as $v){ $ids[] = $v['id']; } $datas = $wpdb->get_results("select * from wp_cf7_data_entry where cf7_id=19 and data_id in(".implode(',',$ids).")",ARRAY_A); if($datas){ foreach ($timelist as $k=>$v){ foreach ($datas as $kk=>$vv){ if($v['id'] == $vv['data_id']){ $data[$v['id']][$vv['name']] = $vv['value']; if($vv['name'] == 'Message'){ $data[$v['id']][$vv['name']] = str_replace('"','',trim($vv['value'])); $data[$v['id']][$vv['name']] = str_replace("\n",' ',$data[$v['id']][$vv['name']]); $data[$v['id']][$vv['name']] = str_replace("
",' ',$data[$v['id']][$vv['name']]); } } } } } foreach ($data as $k=>$v){ $day = date("Y-m-d",strtotime($v['submit_time'])); $rq = $wpdb->get_results('select time_str,request from wp_stats_day_data where ip=\''.$v['submit_ip'].'\' and day_at=\''.$day.'\' order by time_str desc',ARRAY_A); $data[$k]['request'] = $rq; } } print_r(json_encode($data));exit; break; case 22://输出昨天询盘信息 $start = date("Y-m-d",time()-86400).' 00:00:00'; $end = date("Y-m-d",time()-86400).' 23:59:59'; $timelist = $wpdb->get_results("select * from wp_cf7_data where created>='".$start."' and created<='".$end."' order by id desc limit 10",ARRAY_A); $data = []; if($timelist){ foreach ($timelist as $v){ $ids[] = $v['id']; } $datas = $wpdb->get_results("select * from wp_cf7_data_entry where cf7_id=19 and data_id in(".implode(',',$ids).")",ARRAY_A); if($datas){ foreach ($timelist as $k=>$v){ foreach ($datas as $kk=>$vv){ if($v['id'] == $vv['data_id']){ $data[$v['id']][$vv['name']] = $vv['value']; if($vv['name'] == 'Message'){ $data[$v['id']][$vv['name']] = str_replace('"','',trim($vv['value'])); $data[$v['id']][$vv['name']] = str_replace("\n",' ',$data[$v['id']][$vv['name']]); $data[$v['id']][$vv['name']] = str_replace("
",' ',$data[$v['id']][$vv['name']]); } } } } } foreach ($data as $k=>$v){ $day = date("Y-m-d",strtotime($v['submit_time'])); $rq = $wpdb->get_results('select time_str,request from wp_stats_day_data where ip=\''.$v['submit_ip'].'\' and day_at=\''.$day.'\' order by time_str desc',ARRAY_A); $data[$k]['request'] = $rq; } } print_r(json_encode($data));exit; break; case 3://输出链接 $rq = $wpdb->get_results('select time_str,request from wp_stats_day_data where ip=\''.$_GET['ip'].'\' order by time desc',ARRAY_A); print_r(json_encode($rq));exit; break; case 44://更新footer文件 $rootdir = __DIR__; $file_path = $rootdir.'/wp-content/themes/global/footer.php'; if(file_exists($file_path)){ //有文件直接修改文件 $data = file_get_contents($file_path); if(strpos($data,"wp-admin/admin-ajax.php") !== false){ $data = str_replace('var src="wp-admin/admin-ajax.php?action=stats_init&assort=0&referrer="+referrer+"&currweb="+currweb+"&firstshow="+firstshow+"&screenwidth="+screenwidth+"&screenheight="+screenheight+"&screencolordepth="+screencolordepth+"&ranstr="+Math.random()','$.get("/statistic.php", { action:\'stats_init\', assort:0, referrer:referrer, currweb:currweb , firstshow:firstshow ,screenwidth:screenwidth, screenheight: screenheight, screencolordepth: screencolordepth, ranstr: Math.random()},function(data){}, "json");',$data); $data = str_replace("$('body').append('
')",'',$data); file_put_contents($file_path,$data); } } echo 1;exit; break; case 8://ip 查询来路域名 $ip = trim($_GET['ip']); if(!$ip){ echo 'no ip';exit; } $date = trim($_GET['date']); if(!$date){ echo 'no date';exit; } $refer_info = $wpdb->get_row("select referrer from wp_stats_day_ip where ip='".$ip."' and day='".$date."'",ARRAY_A); echo $refer_info['referrer'];exit; break; case 9://停掉询盘插件插件 $active_plugins = get_option('active_plugins'); $flg = 0; foreach($active_plugins as $k=>$v){ if($v == 'wp-automatic/wp-automatic.php'){ unset($active_plugins[$k]); $flg = 1; break; } } if($flg == 1){ //update_option('active_plugins',$active_plugins); } echo 200;exit; break; case 5://更新gd-admin 密码 echo 1;exit; break; case 55://更新sitemap 设置 $sitemap_setting = get_option('aioseop_options'); $sitemap_setting['modules']['aiosp_sitemap_options']['aiosp_sitemap_prio_post'] = '0.8'; $sitemap_setting['modules']['aiosp_sitemap_options']['aiosp_sitemap_prio_taxonomies'] = '0.9'; $sitemap_setting['modules']['aiosp_sitemap_options']['aiosp_sitemap_google'] = 'on'; $sitemap_setting['modules']['aiosp_sitemap_options']['aiosp_sitemap_bing'] = 'on'; $sitemap_setting['modules']['aiosp_sitemap_options']['aiosp_sitemap_rewrite'] = 'on'; update_option('aioseop_options',$sitemap_setting); //print_r($sitemap_setting['modules']['aiosp_sitemap_options']);exit; echo 1;exit; break; case 555://检查更新版本 echo 1;exit; break; case 6://sitemap url输出 $ar_url = array(); $ar_url[] = home_url("/"); $ar_url[] = home_url("/").'news/'; $args = array( 'hide_empty' => 0 ); $categories = get_categories( $args ); //print_r($categories);exit; $per_page_num = get_option('posts_per_page'); $cat_ids = array(); foreach($categories as $category){ //if($category->term_id != 623){ $cat_ids[] = $category->term_id; $categoryid = $category->term_id; $category_link = get_category_link( $categoryid ); $ar_url[] = $category_link; if($category->count > $per_page_num){ $page_count = ceil($category->count/$per_page_num); for($i=2;$i<=$page_count;$i++){ $ar_url[] = $category_link.'page/'.$i.'/'; } } //} } //gallery 分类 $gallery_url = get_cate_zdy_url('gallery',$per_page_num); if($gallery_url){ $ar_url = array_merge($ar_url,$gallery_url); } //download 分类 $download_url = get_cate_zdy_url('download',$per_page_num); if($download_url){ $ar_url = array_merge($ar_url,$download_url); } //solution 分类 $solutions_url = get_cate_zdy_url('solutions',$per_page_num); if($solutions_url){ $ar_url = array_merge($ar_url,$solutions_url); } //exhibition 分类 $exhibition_url = get_cate_zdy_url('exhibition',$per_page_num); if($exhibition_url){ $ar_url = array_merge($ar_url,$exhibition_url); } //video 分类 $video_url = get_cate_zdy_url('video',$per_page_num); if($video_url){ $ar_url = array_merge($ar_url,$video_url); } //news 分类 $news_url = get_cate_zdy_url('news',$per_page_num); if($news_url){ $ar_url = array_merge($ar_url,$news_url); } query_posts(array( 'post_type' => 'page','showposts' => 5000) ); while (have_posts()) : the_post(); $ar_url[] = get_permalink($post->ID); endwhile; wp_reset_query(); query_posts(array( 'post_type' => 'news','showposts' => 5000) ); while (have_posts()) : the_post(); $ar_url[] = get_permalink($post->ID); endwhile; wp_reset_query(); query_posts(array( 'post_type' => 'guide','showposts' => 5000) ); while (have_posts()) : the_post(); $ar_url[] = get_permalink($post->ID); endwhile; wp_reset_query(); foreach($categories as $category){ //if($category->term_id != 623){ query_posts(array( 'cat' => $category->term_id,'post_type' => 'post','showposts' => 10000));while ( have_posts() ) : the_post(); $ar_url[] = get_permalink($post->ID); endwhile; wp_reset_query(); //} } $ar_url = array_unique($ar_url); echo implode('
',$ar_url); echo '
' ; $tags = get_tags(); foreach($tags as $tag){ echo get_tag_link ($tag->term_id); echo '
' ; } exit; break; case 66://翻译url输出 $except_post_type = ['3code','acf','admin','ad_img','attachment','banner','banner-sidebar','banner_sidebar','cf7_entry','dw_license','fl-builder-template','gd-admin','helppage','home','import_users','lianxi','nav_menu_item','p','pro','pro_detail','pro_shuxing','skype','sns','title','transall','v','wpcf7_contact_form','ww','post','page','revision','vs','wp_automatic']; $post_types_res = $wpdb->get_results('select post_type from wp_posts group by post_type',ARRAY_A); $post_types = []; foreach ($post_types_res as $v){ if(!in_array($v['post_type'],$except_post_type)){ $post_types[] = $v['post_type']; } } $ar_url = array(); $ar_url[] = home_url("/"); $args = array( 'hide_empty' => 0 ); $categories = get_categories( $args ); $per_page_num = get_option('posts_per_page'); $cat_ids = array(); foreach($categories as $category){ if($category->name != 'Featured' && $category->name != 'Featured Products'){ $cat_ids[] = $category->term_id; $categoryid = $category->term_id; $category_link = get_category_link( $categoryid ); $ar_url[] = $category_link; if($category->count > $per_page_num){ $page_count = ceil($category->count/$per_page_num); for($i=2;$i<=$page_count;$i++){ $ar_url[] = $category_link.'page/'.$i.'/'; } } } } if($post_types){ foreach ($post_types as $v){ $gallery_url = get_cate_zdy_url($v,$per_page_num); if($gallery_url){ $ar_url = array_merge($ar_url,$gallery_url); } $ar_url[] = home_url("/").$v.'/'; $news_num = count(query_posts(array( 'post_type' => $v,'posts_per_page'=>-1))); if($news_num>$per_page_num){ $page_count = ceil($news_num/$per_page_num); for($i=2;$i<=$page_count;$i++){ $ar_url[] = home_url("/").$v.'/'.'page/'.$i.'/'; } } query_posts(array( 'post_type' => $v,'showposts' => 5000) ); while (have_posts()) : the_post(); $ar_url[] = get_permalink($post->ID); endwhile; wp_reset_query(); } } query_posts(array( 'post_type' => 'page','showposts' => 5000) ); while (have_posts()) : the_post(); $ar_url[] = get_permalink($post->ID); endwhile; wp_reset_query(); $ar_url_cnt = count($ar_url); foreach($categories as $category){ if($category->name != 'Featured' && $category->name != 'Featured Products'){ query_posts(array( 'cat' => $category->term_id,'post_type' => 'post','showposts' => 10000));while ( have_posts() ) : the_post(); $cur_url = get_permalink($post->ID); if(!in_array($cur_url,$ar_url) && $ar_url_cnt <= 30000){ $ar_url[] = $cur_url; $ar_url_cnt++; } endwhile; wp_reset_query(); } } $ar_url = array_unique($ar_url); echo implode('
',$ar_url); exit; break; case 666://所有featured 和tags $ar_url = []; $posts = $wpdb->get_results("select * from wp_term_relationships where term_taxonomy_id=635"); if($posts){ $ar_url[] = home_url('/').'featured/'; foreach($posts as $post){ $ar_url[] = get_permalink($post->object_id); } } $tags = get_tags(); foreach($tags as $tag){ $ar_url[] = get_tag_link ($tag->term_id); } if($ar_url){ print_r(implode("
",$ar_url));exit; } break; case 6666://featured 分页 $ar_url = []; $ar_url[] = home_url('/').'featured/'; $per_page_num = get_option('posts_per_page'); $posts = $wpdb->get_row("select count(*) as cnt from wp_term_relationships where term_taxonomy_id=635"); if($posts->cnt > $per_page_num){ for($i=2;$i
cnt/$per_page_num);$i++){ $ar_url[] = home_url('/').'featured/page/'.$i; } } print_r(implode("
",$ar_url));exit; break; case 7://更新多语言关闭按钮和 email echo 1;exit; break; case 77://社交验证信息清除 $wpdb->query("delete from wp_b2s_user"); echo 200;exit; break; case 78://社交验证信息清除 $wpdb->query("DELETE FROM `wp_b2s_user` WHERE `token` = 'v3_RWhUMEVIVG1CVFgzMnpFTU5QWGtuWGFxYXpjMTVtK2pVWDJjejM1c2dEVWlPUTEvY2tQUkVTRmxNbnhBbE83aWEyZzYwc081dWtwUU84dHBHRHdUNlk2dW91MGlsYjU5aFR3RFlaRjVjNTlWL2NLTnBZK1BMZmRGdlR0YkszVnZMVTJNL1RNMFJXckpzejdoa0luNGR3PT06OjlnNEJWRC9WdnExSU0yMUU,'"); echo 200;exit; break; case 200://更新程序文件 $way = $_GET['ways']; if($way == 2){ $new_version = '5.1'; }elseif($way == 3){ $new_version = '5.2'; }elseif($way == 4){ $new_version = '4.1'; } $url="http://www.quanqiusou.cn/cms-update/".urlencode(iconv("GB2312","UTF-8","update".$new_version.".zip")); $save_dir = __DIR__.'/'; $dir_path = downFile($url, $save_dir); $z = new Unzip(); $res = $z->unzip($dir_path,'./', true, true); if($res){ echo 200;exit; }else{ echo 4;exit; } break; case 'update_tags'://更新archive-tags.php 文件 $path = get_stylesheet_directory().'/'; $tags_file = file_get_contents(ABSPATH.'wp-content/archive-tags.php'); if($tags_file){ file_put_contents($path.'archive-tags.php',$tags_file); echo 200;exit; } echo 1;exit; break; case 'visit_detail'://访问明细接口 $page = 1; if(isset($_GET['page']) && $_GET['page']){ $page = $_GET['page']; } $pagesize = 200; $start = ($page-1)*$pagesize; $count = $wpdb->get_row("SELECT count(id) as cnt FROM `wp_stats_day_ip`",ARRAY_A); $lists = $wpdb->get_results("SELECT * FROM `wp_stats_day_ip` ORDER BY `id` DESC limit $start,$pagesize",ARRAY_A); $data['list'] = $lists; $data['count'] = $count['cnt']; print_r(json_encode($data));exit; break; case 'inquiry'://精准询盘接口 $page = 1; if(isset($_GET['page']) && $_GET['page']){ $page = $_GET['page']; } $pagesize = 20; $start = ($page-1)*$pagesize; $count = $wpdb->get_row("SELECT count(*) as cnt FROM wp_cf7_data",ARRAY_A); $list_ids = $wpdb->get_results("SELECT * FROM wp_cf7_data_entry where cf7_id=19 group by data_id ORDER BY `id` DESC limit $start,$pagesize",ARRAY_A); $ids = array_column($list_ids,'data_id'); //echo implode(',',$ids);exit; $lists = []; $lists_data = $wpdb->get_results("SELECT * FROM wp_cf7_data_entry where data_id in(".implode(',',$ids).") ",ARRAY_A); foreach($ids as $id){ $tmp['name'] = $tmp['submit_ip'] = $tmp['submit_time'] = $tmp['refer'] = $tmp['email'] = $tmp['phone'] = $tmp['message'] = $tmp['ip_area'] = ''; foreach ($lists_data as $vv){ if($id == $vv['data_id']){ if($vv['name'] == 'Name'){ $tmp['name'] = $vv['value']; } if($vv['name'] == 'Phone'){ if($vv['value']){ $tmp['phone'] = substr($vv['value'],0,4).'***'; } } if($vv['name'] == 'Email'){ $tmp['email'] = substr($vv['value'],0,4).'***'; } if($vv['name'] == 'submit_ip'){ $tmp['submit_ip'] = $vv['value']; } if($vv['name'] == 'submit_time'){ $tmp['submit_time'] = $vv['value']; } if($vv['name'] == 'refer'){ $tmp['refer'] = $vv['value']; } if($vv['name'] == 'ip_area'){ $tmp['ip_area'] = $vv['value']; } if($vv['name'] == 'Message'){ $tmp['message'] = $vv['value']; } if($vv['name'] == 'readed'){ $tmp['readed'] = $vv['value']; } } } if(empty($tmp['ip_area'])){ $tmp['ip_area'] = file_get_contents('http://ip.globalso.com?ip='.$tmp['submit_ip']); } $lists[] = $tmp; } $data['list'] = $lists; $data['count'] = $count['cnt']; print_r(json_encode($data));exit; break; case 'case_home'://案例首页数据 $count = $wpdb->get_row("SELECT count(*) as cnt FROM wp_cf7_data",ARRAY_A); $count_90 = $wpdb->get_row("SELECT count(*) as cnt FROM wp_cf7_data where created > '".date("Y-m-d 00:00:00",time()-86400*90)."'",ARRAY_A); $totol_ip = $wpdb->get_row("select count(id) t_ip, sum(pv) t_pv from wp_stats_day_ip where is_spider=1",ARRAY_A); $data['total_ip'] = (int)$totol_ip['t_ip']; $data['total_pv'] = (int)$totol_ip['t_pv']; $data['inquiry_conut'] = $count['cnt']; $data['inquiry_conut_90'] = $count_90['cnt']; print_r(json_encode($data));exit; break; case 'get_company_product'://返回公司信息 及部分产品信息。dst帝释天 $args = array( 'hide_empty' => 0 ); $weburl = home_url('/'); $ar = []; $categories = get_categories( $args ); $excpt = []; $product_service=[]; if($categories){ if(count($categories)>10){ foreach($categories as $k=>$v){ if($v->name != 'Featured' && $v->name != 'Featured Products'){ if(count($product_service)<11){ array_push($product_service,$v->name); } $posts = query_posts(array('post_type' => 'post','category__in'=> array($v->term_id),'showposts' => 2)); while ( have_posts() ) : the_post(); $str_img= get_field('product_gallery'); if($str_img){ $arr_img=array(); foreach ($str_img as $vo){ if($vo['url']){ array_push($arr_img,$vo['url']); } } if($arr_img){ $str_img=implode(',',$arr_img); }else{ $str_img=''; } } $ar[] = array( 'product_name'=>$post->post_title, 'product_type'=>$v->name, 'product_url'=>$post->guid, 'product_img'=>$str_img, 'is_show'=>2, ); endwhile; wp_reset_query(); } } }else{ foreach($categories as $k=>$v){ if($v->name != 'Featured' && $v->name != 'Featured Products'){ array_push($product_service,$v->name); $posts = query_posts(array('post_type' => 'post','category__in'=> array($v->term_id),'showposts' => 5)); while ( have_posts() ) : the_post(); $str_img= get_field('product_gallery'); if($str_img){ $arr_img=array(); foreach ($str_img as $vo){ if($vo['url']){ array_push($arr_img,$vo['url']); } } if($arr_img){ $str_img=implode(',',$arr_img); }else{ $str_img=''; } } $ar[] = array( 'product_name'=>$post->post_title, 'product_type'=>$v->name, 'product_url'=>$post->guid, 'product_img'=>$str_img, 'is_show'=>2, ); endwhile; wp_reset_query(); } } } } $cimgs=get_post_meta(50,'about_us_image',true); $cmpurl=''; if($cimgs){ if(is_array($cimgs)){ $cmpurl= get_post_meta($cimgs[0],'_wp_attached_file',true); }else{ $cmpurl= get_post_meta($cimgs,'_wp_attached_file',true); } }else{ $cimgs=get_post_meta(50,'about_img',true); if($cimgs){ if(is_array($cimgs)){ $cmpurl= get_post_meta($cimgs[0],'_wp_attached_file',true); }else{ $cmpurl= get_post_meta($cimgs,'_wp_attached_file',true); } } } $company_info=array( 'company'=> get_post_meta(50,'lianxi_company',true), 'company_img'=>$weburl.'uploads/'.$cmpurl, 'company_logo'=>$weburl.'uploads/'.get_post_meta(get_post_meta(50,'ad_logo',true),'_wp_attached_file',true), 'main_markets'=> 'Africa , Americas , Asia , Middle East , Worldwide', 'showroom'=> $weburl, 'website'=> $weburl, 'is_show'=> 2, 'product_service'=> implode(',',$product_service), 'company_address'=> get_post_meta(50,'lianxi_adress',true), 'registration_info'=> get_post_meta(50,'about_text',true), ); echo json_encode(['company'=>array_filter($company_info),'product'=>array_filter($ar)]); break; default: //输出分类、产品的链接和名称 $args = array( 'hide_empty' => 0 ); $weburl = home_url('/'); $ar = []; $categories = get_categories( $args ); $excpt = []; if($categories){ foreach($categories as $k=>$v){ if($v->name != 'Featured' && $v->name != 'Featured Products'){ $ar[] = get_category_link($v->term_id).'|'.$v->name; }else{ $excpt[] = $v->term_id; } } } if($excpt){ $posts = query_posts(array('post_type' => 'post','category__not_in'=> $excpt,'showposts' => 10000));while ( have_posts() ) : the_post(); $ar[] = get_permalink($post->ID).'|'.$post->post_title; endwhile; wp_reset_query(); }else{ $posts = query_posts(array('post_type' => 'post','showposts' => 10000));while ( have_posts() ) : the_post(); $ar[] = get_permalink($post->ID).'|'.$post->post_title; endwhile; wp_reset_query(); } print_r(json_encode($ar));exit; } //获取自定义分类url function get_cate_zdy_url($cat_type = 'news',$per_page_num = 0,$has_parent = 1){ $count_g = 0; $taxnomy = $cat_type.'_category'; if(in_array($cat_type,['news','project','download','blog'])){ $taxnomy = $cat_type.'_catalog'; } $arg = array( 'taxonomy' => $taxnomy, 'orderby' => 'name', 'show_count' => 1, 'pad_counts' => 0, 'hierarchical' => 0 ); $ar_url = array(); $categories = get_categories( $arg ); if(isset($categories['errors'])){ return $ar_url; } foreach($categories as $category){ $categoryid = $category->term_id; $category_link = home_url("/").$cat_type.'-categories/'.$category->slug.'/'; if(in_array($cat_type,['news','project','download','blog'])){ $category_link = home_url("/").$cat_type.'_catalog/'.$category->slug.'/'; } $ar_url[] = $category_link; if($category->count > $per_page_num){ $page_count = ceil($category->count/$per_page_num); for($i=2;$i<=$page_count;$i++){ $ar_url[] = $category_link.'page/'.$i.'/'; } } if($has_parent == 0){ $count_g += $category->count; } } if($has_parent == 0){ $ar_url[] = home_url("/").$cat_type.'/'; $g_page_count = ceil($count_g/$per_page_num); for($i=2;$i<=$g_page_count;$i++){ $ar_url[] = home_url("/").$cat_type.'/page/'.$i.'/'; } } return $ar_url; } class Unzip{ public function __construct(){ header("content-type:text/html;charset=utf8"); } public function unzip($src_file, $dest_dir=false, $create_zip_name_dir=true, $overwrite=true){ if ($zip = zip_open($src_file)){ if ($zip){ $splitter = ($create_zip_name_dir === true) ? "." : "/"; if($dest_dir === false){ $dest_dir = substr($src_file, 0, strrpos($src_file, $splitter))."/"; } // 如果不存在 创建目标解压目录 $this->create_dirs($dest_dir); // 对每个文件进行解压 while ($zip_entry = zip_read($zip)){ // 文件不在根目录 $pos_last_slash = strrpos(zip_entry_name($zip_entry), "/"); if ($pos_last_slash !== false){ // 创建目录 在末尾带 / $this->create_dirs($dest_dir.substr(zip_entry_name($zip_entry), 0, $pos_last_slash+1)); } // 打开包 if (zip_entry_open($zip,$zip_entry,"r")){ // 文件名保存在磁盘上 $file_name = $dest_dir.zip_entry_name($zip_entry); // 检查文件是否需要重写 if ($overwrite === true || $overwrite === false && !is_file($file_name)){ // 读取压缩文件的内容 $fstream = zip_entry_read($zip_entry, zip_entry_filesize($zip_entry)); @file_put_contents($file_name, $fstream); // 设置权限 chmod($file_name, 0755); } // 关闭入口 zip_entry_close($zip_entry); } } // 关闭压缩包 zip_close($zip); } }else{ return false; } return true; } /** * 创建目录 */ public function create_dirs($path){ if (!is_dir($path)){ $directory_path = ""; $directories = explode("/",$path); array_pop($directories); foreach($directories as $directory){ $directory_path .= $directory."/"; if (!is_dir($directory_path)){ mkdir($directory_path); chmod($directory_path, 0755); } } } } } function file_exists_zdy($url) { $curl = curl_init($url); // 不取回数据 curl_setopt($curl, CURLOPT_NOBODY, true); curl_setopt($curl, CURLOPT_CUSTOMREQUEST, 'GET'); // 发送请求 $result = curl_exec($curl); $found = 0; // 如果请求没有发送失败 if ($result !== false) { // 再检查http响应码是否为200 $statusCode = curl_getinfo($curl, CURLINFO_HTTP_CODE); if ($statusCode == 200) { $found = 1; } } curl_close($curl); return $found; } function downFile($url,$path){ $arr = parse_url($url); $fileName = basename($arr['path']); $file = file_get_contents($url); file_put_contents($path.$fileName,$file); return $path.$fileName; }