diff --git a/application/controllers/information.php b/application/controllers/information.php index 52f1e0ca..e7e61f10 100644 --- a/application/controllers/information.php +++ b/application/controllers/information.php @@ -526,7 +526,8 @@ class Information extends CI_Controller { if ($delete_only === true) { $url = 'https://www.asiahighlights.com/index.php/information/delete_cache_8X913mksJ/?static_html_url=' . $url; } else { - $url = 'https://www.asiahighlights.com/index.php/information/detail/?static_html_url=' . $url; + // static_html_optimize=comeon 启用静态化压缩和js、css延迟加载 + $url = 'https://www.asiahighlights.com/index.php/information/detail/?static_html_url=' . $url . '&static_html_optimize=comeon'; } } else { //子站点使用 $url = $this->config->item('site_url') . $url . '@cache@refresh'; diff --git a/application/controllers/sendmail.php b/application/controllers/sendmail.php index 7325bc27..f63debf8 100644 --- a/application/controllers/sendmail.php +++ b/application/controllers/sendmail.php @@ -92,7 +92,7 @@ class Sendmail extends CI_Controller } } - $this->InfoSMS_model->set_mail_status($m->M_SN,1,$order_condition); + $this->InfoSMS_model->set_mail_status($m->M_SN,1); $this->email->clear(TRUE); } } diff --git a/application/controllers/welcome.php b/application/controllers/welcome.php index efaaf3a3..bbea50bc 100644 --- a/application/controllers/welcome.php +++ b/application/controllers/welcome.php @@ -12,7 +12,9 @@ class Welcome extends CI_Controller { $this->load->model('Area_model'); $this->load->model('InfoStructures_model'); $this->load->model('Information_model'); + $this->load->model('InfoContents_model'); $this->load->model('Coupon_model'); + $this->load->model('Logs_model'); } public function index() { @@ -94,6 +96,130 @@ class Welcome extends CI_Controller { $this->load->view('bootstrap/footer'); } + public function get_infomation_urls($is_parent_id) { + $this->output->enable_profiler(FALSE); + $structure = $this->InfoStructures_model->Detail($is_parent_id); + if (empty($structure)) { + show_404(); + return false; + } + $data['all_information'] = $this->Information_model->get_list_by_path($structure->is_path); + + $this->load->view('bootstrap/header', $data); + $this->load->view('bootstrap/static_url', $data); + $this->load->view('bootstrap/footer'); + } + + public function get_info_backup_id($info_id) { + $last_backup = $this->Logs_model->get_last_backup($info_id); + if (empty($last_backup)) { + $this->echo_json(array( + 'status' => 'error', + 'logId' => 0, + 'datetime' => 0, + 'username' => 0 + )); + } else { + $this->echo_json(array( + 'status' => 'success', + 'logId' => $last_backup->log_id, + 'datetime' => $last_backup->log_datetime, + 'username' => $last_backup->log_ht_username + )); + } + } + + public function change_static_url($info_id) { + $information = $this->Information_model->Detail($info_id); + $htm_doc = new DOMDocument(); + $htm_doc->encoding='UTF-8'; + libxml_use_internal_errors(true); + $htm_doc->strictErrorChecking = false; + if (empty($information->ic_content)) { + $this->echo_json(array( + 'status' => 'error', + 'infoId' => $info_id, + 'message' => 'info content is empty' + )); + return; + } + $htm_doc->loadHTML( + mb_convert_encoding($information->ic_content, 'HTML-ENTITIES', 'UTF-8')); + $htm_doc->normalizeDocument(); + $img_list = $htm_doc->getElementsByTagName('img'); + foreach ($img_list as $img) { + $img_src = $img->getAttribute('src'); + $img_src = $this->check_url($img_src); + $img->setAttribute('src', $img_src); + } + + $information->ic_content = $htm_doc->saveHTML(); + $this->InfoContents_model->Update( + $information->ic_id, + $information->ic_url, + $information->ic_url_title, + $information->ic_type, + $information->ic_title, + $information->ic_content, + $information->ic_summary, + $information->ic_seo_title, + $information->ic_seo_description, + $information->ic_seo_keywords, + $information->ic_show_bread_crumbs, + $information->ic_status, + $information->ic_template, + $information->ic_photo, + $information->ic_photo_width, + $information->ic_photo_height, + $information->ic_recommend_tours, + $information->ic_recommend_packages, + $information->ic_ht_area_id, + $information->ic_ht_area_type, + $information->ic_ht_product_id, + $information->ic_ht_product_type, + $information->ic_author); + + $this->echo_json(array( + 'status' => 'ok', + 'infoId' => $info_id, + 'message' => 'success', + 'date' => date('Y-m-d h:i:s') + )); + } + + private function echo_json($obj) { + $this->output + ->set_content_type('application/json') + ->set_output(json_encode($obj)); + } + + private function check_url($subject) { + $result = $subject; + $check_rules = array( + '/^\/image\/(.*)/' => '//data.chinahighlights.com/image/', + '/^\/pic\/(.*)/' => '//data.chinahighlights.com/pic/', + '/^\/allpicture\/(.*)/' => '//data.chinahighlights.com/allpicture/', + '/^http:\/\/images.chinahighlights.com(.*)/' => '//images.chinahighlights.com', + '/^http:\/\/data.chinahighlights.com(.*)/' => '//data.chinahighlights.com', + '/^http:\/\/www.chinahighlights.com(.*)/' => '//www.chinahighlights.com'); + + foreach ($check_rules as $pattern => $replace) { + $result = $this->replace_url($pattern, $replace, $result); + } + return $result; + } + + private function replace_url($pattern, $replace, $subject) { + $result = $subject; + $match_result = array(); + preg_match($pattern, $subject, $match_result); + $result_count = count($match_result); + if ($result_count == 2) { + $result = $replace.$match_result[1]; + } + return $result; + } + //生肖促销订单查询 public function coupon() { $data['countryList'] = $this->Area_model->get_country_list(); diff --git a/application/helpers/info_helper.php b/application/helpers/info_helper.php index fc53eb95..99909ace 100644 --- a/application/helpers/info_helper.php +++ b/application/helpers/info_helper.php @@ -296,7 +296,12 @@ function get_content_by_url($url) { curl_setopt($curl, CURLOPT_URL, $url); // 要访问的地址 curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, 0); // 对认证证书来源的检查 curl_setopt($curl, CURLOPT_SSL_VERIFYHOST, 0); // 从证书中检查SSL加密算法是否存在 - curl_setopt($curl, CURLOPT_USERAGENT, $_SERVER['HTTP_USER_AGENT']); // 模拟用户使用的浏览器 + if (isset($_SERVER['HTTP_USER_AGENT'])) { + $HTTP_USER_AGENT = $_SERVER['HTTP_USER_AGENT']; + } else { + $HTTP_USER_AGENT = 'Mozilla/5.0 (Windows NT 6.1; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/56.0.2924.87 Safari/537.36'; + } + curl_setopt($curl, CURLOPT_USERAGENT, $HTTP_USER_AGENT); // 模拟用户使用的浏览器 curl_setopt($curl, CURLOPT_FOLLOWLOCATION, 1); // 使用自动跳转 curl_setopt($curl, CURLOPT_AUTOREFERER, 1); // 自动设置Referer if ($method == 'POST' && !empty($data)) { diff --git a/application/libraries/simple_html_dom_lib.php b/application/libraries/simple_html_dom_lib.php new file mode 100644 index 00000000..0e0d7192 --- /dev/null +++ b/application/libraries/simple_html_dom_lib.php @@ -0,0 +1,9 @@ +config->item('site_image_url'), $this->config->item('site_image_url'),$ic_content); $ic_content=str_replace($this->config->item('media_image_url_remote2'), $this->config->item('site_image_url'),$ic_content); $ic_content=str_replace($this->config->item('media_image_url_org'), $this->config->item('site_image_url'),$ic_content); + $ic_content=str_replace($this->config->item('media_image_url'), $this->config->item('site_image_url'),$ic_content); + $ic_content=str_replace($this->config->item('media_image_url2'), $this->config->item('site_image_url'),$ic_content); + $ic_content=str_replace($this->config->item('media_image_url_remote'), $this->config->item('site_image_url'),$ic_content); $ic_content=str_replace('#textarea#', 'textarea',$ic_content); $sql = "INSERT INTO infoContents \n" . " ( \n" @@ -41,7 +45,9 @@ class InfoContents_model extends CI_Model $ic_show_bread_crumbs, $ic_status, $ic_template, $ic_photo, $ic_photo_width, $ic_photo_height, $ic_recommend_tours, $ic_recommend_packages, $ic_ht_area_id, $ic_ht_area_type, $ic_ht_product_id, $ic_ht_product_type,$ic_author) { + $ic_content=str_replace('http:'.$this->config->item('site_image_url'), $this->config->item('site_image_url'),$ic_content); $ic_content=str_replace($this->config->item('media_image_url'), $this->config->item('site_image_url'),$ic_content); + $ic_content=str_replace($this->config->item('media_image_url2'), $this->config->item('site_image_url'),$ic_content); $ic_content=str_replace($this->config->item('media_image_url_org'), $this->config->item('site_image_url'),$ic_content); $ic_content=str_replace($this->config->item('media_image_url_remote'), $this->config->item('site_image_url'),$ic_content); $ic_content=str_replace($this->config->item('media_image_url_remote2'), $this->config->item('site_image_url'),$ic_content); diff --git a/application/models/logs_model.php b/application/models/logs_model.php index 5be5e378..9e269469 100644 --- a/application/models/logs_model.php +++ b/application/models/logs_model.php @@ -41,6 +41,15 @@ class Logs_model extends CI_Model { return $this->get_list(); } + //获取最近的备份信息内容 + function get_last_backup($is_id) { + $this->init(); + $this->top_num = 1; + $this->log_res_id = " AND il.log_res_id =" . $this->HT->escape($is_id); + $this->log_action = " AND il.log_action = 'backup_info'"; + return $this->get_list(); + } + //获取所有备份信息内容 function get_all_backup_list($is_id) { $this->init(); @@ -76,13 +85,13 @@ class Logs_model extends CI_Model { $map = ''; if ($last_id) $map = " AND log_id > $last_id"; - $sql = " SELECT log_id,is_sitecode,ic_url - FROM infoLogs - LEFT JOIN infoStructures ON is_id=log_res_id - LEFT JOIN infoContents ON is_ic_id=ic_id - WHERE ic_url != '' - AND log_action = 'backup_info' - + $sql = " SELECT log_id,is_sitecode,ic_url + FROM infoLogs + LEFT JOIN infoStructures ON is_id=log_res_id + LEFT JOIN infoContents ON is_ic_id=ic_id + WHERE ic_url != '' + AND log_action = 'backup_info' + $map ORDER BY log_id ASC"; $query = $this->HT->query($sql); @@ -170,7 +179,7 @@ class Logs_model extends CI_Model { ,log_datetime ) VALUES - ( ?,?,N?,?,?,GETDATE()) + ( ?,?,N?,?,?,GETDATE()) "; $query = $this->HT->query($sql, array('write_test', 0, '数据库写入测试', 'system', 'system')); diff --git a/application/third_party/htmlcompressor/controllers/index.php b/application/third_party/htmlcompressor/controllers/index.php new file mode 100644 index 00000000..bbf12e44 --- /dev/null +++ b/application/third_party/htmlcompressor/controllers/index.php @@ -0,0 +1,141 @@ +load->library('simple_html_dom_lib'); + } + + public function index() { + $this->load->view('welcome'); + } + + public function optimize() { + $htmlsource = $this->input->post('htmlsource'); + $websitehost = $this->input->post('websitehost'); + if (empty($htmlsource) || empty($websitehost)) { + $this->output->set_status_header(500); + echo 'error:htmlsource or websitehost is empty!'; + return false; + } + //域名后面不能有/ + if (substr($websitehost, -1, 1) == '/') { + $websitehost = substr($websitehost, 0, -1); + } + + $html_object = str_get_html($htmlsource); + if (!empty($html_object)) { + +//提取和下载所有CSS样式,包括链接文件和页面样式 + $link_css_array = array(); + $css_content = ''; + foreach ($html_object->find('link') as $link_css) { + if ($link_css->rel == 'stylesheet' && !empty($link_css->href)) { + $link_css_array[] = $link_css->href; + $link_css->outertext = ''; //删除链接 + } + } + //print_r($link_css_array); + foreach ($link_css_array as $item) { + $get_http_temp = GET_HTTP($this->format_url($item, $websitehost)); + if ($get_http_temp == false) { + $this->output->set_status_header(404); + echo 'CSS文件下载错误'; + return FALSE; + } + $css_content.=$get_http_temp; + } + foreach ($html_object->find('style') as $style_css) { + if ($style_css->type == "text/css") { + $css_content .= $style_css->innertext; + } + } + // echo $css_content; + // echo $html_object;die(); + // +//提取和下载所有JS脚本,包括链接文件和页面脚本 + $link_js_array = array(); + $js_inline_content = ''; + $js_jquery_content = ''; + foreach ($html_object->find('script') as $link_script) { + if (!empty($link_script->src)) { + $link_js_array[] = $link_script->src; + $link_script->outertext = ''; //删除链接,移动到页底 + } else { + //网页内的js不需要提取 + //$js_content.= $link_script->innertext;//js的内容 + // $js_content.= $link_script;//js的内容,包含'; + + $js_content = $js_scr_content . $js_jquery_content; + //延迟加载js,需要把返回的js代码保存到一个文件中,然后替换占位符,以便加载js文件 + $lastload_js.=''; + $lastload_js.=$js_inline_content; + + $html_object = str_replace('', $lastload_js . '', $html_object); + } + echo json_encode(array('result' => 'ok', 'data' => array('html_object' => $html_object, 'js_content' => $js_content))); + } + +//格式化url,保证请求的URL有域名,//更换为对应的域名路径 + function format_url($url, $host = '') { + if (substr($url, 0, 8) == 'https://' || substr($url, 0, 7) == 'http://') { + return urldecode($url); + } + + if (substr($url, 0, 2) == '//') { //https或http + return urldecode(str_replace('//', 'http://', $url)); + } + + return urldecode($host . $url); + } + +} diff --git a/application/third_party/htmlcompressor/views/welcome.php b/application/third_party/htmlcompressor/views/welcome.php new file mode 100644 index 00000000..e18468fd --- /dev/null +++ b/application/third_party/htmlcompressor/views/welcome.php @@ -0,0 +1,22 @@ + + + + + + + + HTML-Compressor + + + +

页面样式精简

+
+

+ + +
+ + + diff --git a/application/third_party/pagespeed/controllers/index.php b/application/third_party/pagespeed/controllers/index.php new file mode 100644 index 00000000..eb50c26e --- /dev/null +++ b/application/third_party/pagespeed/controllers/index.php @@ -0,0 +1,132 @@ +load->model('PageSpeedData_model'); + } + + public function index() { + $this->permission->is_admin(); + $data = array(); + $data['score_data'] = $this->PageSpeedData_model->score_chart($this->config->item('site_code')); + $this->load->view('bootstrap3/header', $data); + $this->load->view('welcome'); + $this->load->view('bootstrap3/footer'); + } + + //根据分数段来查询页面 + public function search_score() { + $this->permission->is_admin(); + $data = array(); + $device = $this->input->post('device'); + $start_score = $this->input->post('start_score'); + $end_score = $this->input->post('end_score'); + $data['score_data_list'] = $this->PageSpeedData_model->search_score_list($start_score, $end_score, $this->config->item('site_code'), $device); + if (empty($data['score_data_list'])) { + echo json_encode('没有找到数据'); + } else { + echo json_encode($this->load->view('search', $data, true)); + } + } + + //自动抓取分数和排名 + public function auto($sitecode = 'cht') { + //添加数据,信息平台中发布的,并且当前数据库没有的 + $this->PageSpeedData_model->insert_list($sitecode); + $update_list = $this->PageSpeedData_model->get_update_list($sitecode, 2); + if (empty($update_list)) { + echo'all done!'; + return; + } + + foreach ($update_list as $item) { + $this->run($item->psd_URL, $item-> + psd_SiteCode); + } + } + + public function show_score() { + $psd_URL = $this->input->get_post('psd_URL'); + $psd_SiteCode = $this->input->get_post('psd_SiteCode'); + if (empty($psd_URL) || empty($psd_SiteCode)) { + echo json_encode(array('result' => 'error', 'data' => 'url或站点为空')); + return false; + } + $pagespeed_data = $this->PageSpeedData_model->detail($psd_URL, $psd_SiteCode); + if (!empty($pagespeed_data)) { + echo json_encode(array('result' => 'ok', 'data' => 'M:' . $pagespeed_data->psd_MobileScore . ',D:' . $pagespeed_data-> + psd_DesktopScore)); + } + } + + public function run($psd_URL = false, $psd_SiteCode = false) { + if (empty($psd_URL) || empty($psd_SiteCode)) { + $psd_URL = $this->input->get_post('psd_URL'); + $psd_SiteCode = $this->input->get_post('psd_SiteCode'); + if (empty($psd_URL) || empty($psd_SiteCode)) { + echo json_encode(array('result' => 'error', 'data' => 'url或站点为空')); + + return false; + } + } + $sites = $this->config->item('site'); + if (empty($sites[$psd_SiteCode])) { + echo json_encode(array('result' => 'error', 'data' => '找不到站点')); + return false; + } + $site_url = rtrim($sites[$psd_SiteCode]['site_url'], '/'); //删除/,因为URL已经含有了 + $run_URL = urlencode(trim($site_url . $psd_URL)); + $pagespeed_data = $this->PageSpeedData_model->detail($psd_URL, $psd_SiteCode); + $PageSpeedData = new StdClass; + + $desktop_url = "https://www.googleapis.com/pagespeedonline/v2/runPagespeed?strategy=desktop&locale=zh_CN&url=$run_URL"; + //$desktop_url = "http://pagespeed.mycht.cn/pagespeedonline/v2/runPagespeed?strategy=desktop&locale=zh_CN&url=$run_URL"; + $mobile_url = "https://www.googleapis.com/pagespeedonline/v2/runPagespeed?strategy=mobile&locale=zh_CN&url=$run_URL"; + //$mobile_url = "http://pagespeed.mycht.cn/pagespeedonline/v2/runPagespeed?strategy=mobile&locale=zh_CN&url=$run_URL"; + //echo $desktop_url;die(); + $desktop_data = GET_HTTP($desktop_url); + $mobile_data = GET_HTTP($mobile_url); + if (empty($desktop_data) || empty($mobile_data)) { + echo json_encode(array('result' => 'error', 'data' => 'API不返回数据')); + return false; + } + $desktop_object = json_decode($desktop_data); + $mobile_object = json_decode($mobile_data); + if (isset($desktop_object->error) || isset($mobile_object->error)) { + $this->PageSpeedData_model->update_error($pagespeed_data->psd_id); + echo json_encode(array('result' => 'error', 'data' => 'API返回错误')); + log_message('error ', 'pagespeed_error:' . json_encode($desktop_object) . ' ' . json_encode($mobile_object)); + return false; + } + + if ($desktop_object->responseCode !== 200 || $mobile_object->responseCode !== 200) { + $this->PageSpeedData_model->update_error($pagespeed_data->psd_id); + echo json_encode(array('result' => 'error', 'data' => 'API返回错误,网页打不开')); + log_message('error ', 'pagespeed_error:' . json_encode($desktop_object) . ' ' . json_encode($mobile_object)); + return FALSE; + } + + $PageSpeedData->psd_DesktopScore = $desktop_object->ruleGroups->SPEED->score; + $PageSpeedData->psd_MobileScore = $mobile_object->ruleGroups->SPEED->score; + $PageSpeedData->psd_DesktopData = $desktop_data; + $PageSpeedData->psd_MobileData = $mobile_data; + $PageSpeedData->psd_URL = $psd_URL; + $PageSpeedData->psd_Datetime = date('Y-m-d H:i:s', time()); + $PageSpeedData->psd_SiteCode = $psd_SiteCode; + $PageSpeedData->psd_ErrorCount = 0; + + if (empty($pagespeed_data)) { + $psd_id = $this->PageSpeedData_model->add('PageSpeedData', $PageSpeedData); + } else { + $where = array('psd_id' => $pagespeed_data->psd_id); + $this->PageSpeedData_model->update('PageSpeedData', $PageSpeedData, $where); + } + echo json_encode(array('result' => 'ok', 'data' => 'M:' . $PageSpeedData->psd_MobileScore . ',D:' . $PageSpeedData->psd_DesktopScore)); + } + +} diff --git a/application/third_party/pagespeed/models/PageSpeedData_model.php b/application/third_party/pagespeed/models/PageSpeedData_model.php new file mode 100644 index 00000000..420aebed --- /dev/null +++ b/application/third_party/pagespeed/models/PageSpeedData_model.php @@ -0,0 +1,177 @@ +HT = $this->load->database('HT', TRUE); + $this->INFO = $this->load->database('INFO', TRUE); + } + + public function init() { + $this->topnum = false; + $this->where = false; + $this->orderby = ' ORDER BY psd_Datetime ASC '; + } + + public function detail($psd_URL, $psd_SiteCode) { + $this->init(); + $this->topnum = 1; + $this->where = ' AND psd.psd_URL=' . $this->INFO->escape($psd_URL); + $this->where .= ' AND psd.psd_SiteCode=' . $this->INFO->escape($psd_SiteCode); + return $this->get_list(); + } + + public function add($table, $data) { + if ($this->INFO->insert($table, $data)) { + return $this->INFO->last_id($table); + } else { + return false; + } + } + + public function insert_list($psd_SiteCode) { + $sql = " + INSERT INTO PageSpeedData + ( + psd_URL + ,psd_SiteCode + ) + SELECT TOP 200 ic.ic_url + ,ic.ic_sitecode + FROM Tourmanager.dbo.infoContents ic + WHERE ic.ic_status = 1 + AND ic.ic_url<>'' + AND ic.ic_sitecode = ? + AND NOT EXISTS( + SELECT TOP 1 1 + FROM PageSpeedData psd + WHERE psd.psd_URL = ic.ic_url + AND psd.psd_SiteCode = ic.ic_sitecode + ) + ORDER BY + ic.ic_datetime ASC + "; + $this->INFO->query($sql, array($psd_SiteCode)); + } + + public function get_update_list($psd_SiteCode, $topnum = 3) { + $this->init(); + $this->topnum = $topnum; + $this->where = ' AND psd.psd_SiteCode=' . $this->INFO->escape($psd_SiteCode); + $this->where .= ' AND ISNULL(psd.psd_Datetime,1999) < GETDATE()-1 '; + $this->where .= ' AND psd.psd_ErrorCount<=3 '; + $this->orderby = ' ORDER BY psd_Datetime ASC '; + return $this->get_list(); + } + + public function update($table, $data, $where) { + $this->INFO->update($table, $data, $where); + } + + //记录错误次数 + public function update_error($psd_id) { + $sql = " + UPDATE PageSpeedData + SET psd_ErrorCount = psd_ErrorCount+1 + , psd_Datetime=GETDATE() + WHERE psd_id = ? + "; + $this->INFO->query($sql, array($psd_id)); + //删除错误数大于3的数据,保持没有冗余数据 ,不删除,很多页面信息平台发布了,但是网前删除了 + //$sql = " DELETE FROM PageSpeedData WHERE psd_ErrorCount>3 "; + // $this->INFO->query($sql); + } + + //删除数据 + // public function delete($psd_id) { + // $sql = " DELETE FROM PageSpeedData WHERE psd_id=? "; + // return $this->INFO->query($sql, array($psd_id)); + // } + + public function get_list() { + $this->topnum ? $sql = "SELECT TOP " . $this->topnum : $sql = "SELECT "; + $sql .= " + psd.psd_id, + psd.psd_DesktopScore, + psd.psd_MobileScore, + psd.psd_DesktopData, + psd.psd_MobileData, + psd.psd_URL, + psd.psd_Datetime, + psd.psd_SiteCode, + psd.psd_ErrorCount + FROM + PageSpeedData psd + WHERE 1 = 1 + "; + $this->where ? $sql.=$this->where : false; + $this->orderby ? $sql.=$this->orderby : false; + $query = $this->INFO->query($sql); + //print_r($this->INFO->queries); + if ($this->topnum === 1) { + if ($query->num_rows() > 0) { + $row = $query->row(); + return $row; + } else { + return FALSE; + } + } else { + return $query->result(); + } + } + + public function search_score_list($start_score, $end_score, $psd_SiteCode, $device = 'moblie') { + $this->init(); + $this->topnum = 50; + $this->where = ' AND psd.psd_SiteCode=' . $this->INFO->escape($psd_SiteCode); + if ($device == 'moblie') { + $this->where .= " AND psd.psd_MobileScore BETWEEN $start_score AND $end_score "; + $this->orderby = ' ORDER BY psd_MobileScore ASC '; + } else { + $this->where .= " AND psd.psd_DesktopScore BETWEEN $start_score AND $end_score "; + $this->orderby = ' ORDER BY psd_DesktopScore ASC '; + } + $this->where .= " AND psd.psd_ErrorCount<=3 "; + return $this->get_list(); + } + + //分数段统计 + public function score_chart($psd_SiteCode) { + $sql = " + SELECT COUNT(psd.psd_id) AS [page_count] + ,AVG(psd.psd_DesktopScore)AS [d_avg] + ,COUNT(CASE WHEN psd.psd_DesktopScore BETWEEN 96 AND 100 THEN 1 END) AS [d96_100] + ,COUNT(CASE WHEN psd.psd_DesktopScore BETWEEN 90 AND 95 THEN 1 END) AS [d90_95] + ,COUNT(CASE WHEN psd.psd_DesktopScore BETWEEN 86 AND 89 THEN 1 END) AS [d86_89] + ,COUNT(CASE WHEN psd.psd_DesktopScore BETWEEN 80 AND 85 THEN 1 END) AS [d80_85] + ,COUNT(CASE WHEN psd.psd_DesktopScore BETWEEN 70 AND 79 THEN 1 END) AS [d70_79] + ,COUNT(CASE WHEN psd.psd_DesktopScore BETWEEN 60 AND 69 THEN 1 END) AS [d60_69] + ,COUNT(CASE WHEN psd.psd_DesktopScore<60 THEN 1 END) AS [d60_0] + ,AVG(psd.psd_MobileScore)AS [m_avg] + ,COUNT(CASE WHEN psd.psd_MobileScore BETWEEN 96 AND 100 THEN 1 END) AS [m96_100] + ,COUNT(CASE WHEN psd.psd_MobileScore BETWEEN 90 AND 95 THEN 1 END) AS [m90_95] + ,COUNT(CASE WHEN psd.psd_MobileScore BETWEEN 86 AND 89 THEN 1 END) AS [m86_89] + ,COUNT(CASE WHEN psd.psd_MobileScore BETWEEN 80 AND 85 THEN 1 END) AS [m80_85] + ,COUNT(CASE WHEN psd.psd_MobileScore BETWEEN 70 AND 79 THEN 1 END) AS [m70_79] + ,COUNT(CASE WHEN psd.psd_MobileScore BETWEEN 60 AND 69 THEN 1 END) AS [m60_69] + ,COUNT(CASE WHEN psd.psd_MobileScore<60 THEN 1 END) AS [m60_0] + FROM PageSpeedData psd + WHERE 1=1 + AND psd.psd_SiteCode=? + AND psd.psd_ErrorCount<=3 + "; + $query = $this->INFO->query($sql, array($psd_SiteCode)); + if ($query->num_rows() > 0) { + $row = $query->row(); + return $row; + } else { + return FALSE; + } + } + +} diff --git a/application/third_party/pagespeed/views/search.php b/application/third_party/pagespeed/views/search.php new file mode 100644 index 00000000..d766a811 --- /dev/null +++ b/application/third_party/pagespeed/views/search.php @@ -0,0 +1,44 @@ + $item) { + +} +?> + + +
+ + + + + + + + + + + + + config->item('site_url'), '/'); + if (!empty($score_data_list)) { + foreach ($score_data_list as $key => $item) { + ?> + + + + + + + + + + + +
#页面移动端桌面端更新时间操作
psd_URL; ?>psd_MobileScore; ?>psd_DesktopScore; ?>psd_Datetime)); ?> + 查看页面 | + Google insights +
+
\ No newline at end of file diff --git a/application/third_party/pagespeed/views/welcome.php b/application/third_party/pagespeed/views/welcome.php new file mode 100644 index 00000000..34265f84 --- /dev/null +++ b/application/third_party/pagespeed/views/welcome.php @@ -0,0 +1,80 @@ + + + +
+ +根据分数搜索页面 + + +
+ + \ No newline at end of file diff --git a/application/views/bootstrap/header.php b/application/views/bootstrap/header.php index 6b471097..0789cad2 100644 --- a/application/views/bootstrap/header.php +++ b/application/views/bootstrap/header.php @@ -73,11 +73,12 @@ 更多 diff --git a/application/views/bootstrap/static_url.php b/application/views/bootstrap/static_url.php new file mode 100644 index 00000000..a1c2bb85 --- /dev/null +++ b/application/views/bootstrap/static_url.php @@ -0,0 +1,97 @@ + + +
+
+ +
+ +
+ + + + + + + + + + + + + $info) { + if ($info->ic_status == 1 && !empty($info->ic_url)) { + ?> + + + + + + + + + +
#IDURL备份操作
is_id; ?>ic_url; ?>查看 + 更换 | + 看看 +
+
+
diff --git a/application/views/bootstrap3/header.php b/application/views/bootstrap3/header.php index 8d164b96..c5ef8df2 100644 --- a/application/views/bootstrap3/header.php +++ b/application/views/bootstrap3/header.php @@ -77,6 +77,7 @@ 更多