添加删除静态文件功能,临时解决方案

ct-mobile-first
ycc 5 years ago
parent 08ef0dd254
commit c1dbe1cf87

@ -334,6 +334,10 @@ class Information extends CI_Controller
} else {
$data['mobile_first_template'] = '没有找到移动模板';
}
//查找是否有静态文件
if ($this->html_file_helper('find', $data['information']->ic_url)) {
$data['has_html_file'] = true;
}
$this->load->view('bootstrap3/header', $data);
$this->load->view('bootstrap3/information_edit');
@ -557,6 +561,46 @@ class Information extends CI_Controller
return true;
}
//静态文件操作
public function html_file_helper($active = 'find', $ic_url=false)
{
if(empty($ic_url)){
$ic_url=$this->input->get_post('ic_url');
}
if(empty($ic_url)){
return false;
}
$html_file = $this->config->item('cache')[$this->config->item('site_code')]['cache_path'] . $ic_url;
$html_file = str_replace("\\", "/", $html_file);
if (substr($html_file, -1, 1) == '/') {
$html_file = $html_file . 'index.htm';
}
$html_file_mobile = $html_file . '-mobile.htm';
$html_file_pc = $html_file . '-pc.htm';
switch ($active) {
case 'find': //寻找静态文件
if (is_file($html_file_mobile) || is_file($html_file_pc)) {
return true;
} else {
return false;
}
break;
case 'delete':
if (is_file($html_file_mobile)) {
unlink($html_file_mobile);
}
if (is_file($html_file_pc)) {
unlink($html_file_pc);
}
echo '删除静态文件成功! ' . $ic_url;
break;
default:
return false;
}
return false;
}
function make_mobile_html($information)
{
$data = array();
@ -574,16 +618,16 @@ class Information extends CI_Controller
$mobile_template_H1 = $this->call_mobile_template_H1($mobile_first_template_path, $this->input->post('is_path'), $this->input->post('ic_author'), $this->input->post('ic_title'), $this->input->post('ic_photo'));//H1模板替换
$mobile_template = str_replace('<!--@HEAD_1@-->', $mobile_template_H1, $mobile_template);
//额外样式
$meta_addon_css=get_meta($information->ic_id, 'meta_addon_css');
if(!empty($meta_addon_css)){
$mobile_template = str_replace('<!--@ADDON-CSS@-->', '<link href="'.$meta_addon_css.'" rel="stylesheet">', $mobile_template);
$meta_addon_css = get_meta($information->ic_id, 'meta_addon_css');
if (!empty($meta_addon_css)) {
$mobile_template = str_replace('<!--@ADDON-CSS@-->', '<link href="' . $meta_addon_css . '" rel="stylesheet">', $mobile_template);
}
$mobile_template = str_replace('<!--@CUSTOM-CONENT@-->', $this->input->post('ic_content'), $mobile_template);
//Google广告代码
if(!empty(get_meta($information->ic_id, 'meta_google_ad_content'))){
if (!empty(get_meta($information->ic_id, 'meta_google_ad_content'))) {
$mobile_template = str_replace('<!--@Match-Content-GOOGLE@-->', '<script async src="https://pagead2.googlesyndication.com/pagead/js/adsbygoogle.js"></script><ins class="adsbygoogle" style="display:block" data-ad-format="autorelaxed" data-ad-client="ca-pub-4231674166786366" data-ad-slot="1447610161"></ins><script>(adsbygoogle = window.adsbygoogle || []).push({});</script>', $mobile_template);
}
if(!empty(get_meta($information->ic_id, 'meta_google_ad_article'))) {
if (!empty(get_meta($information->ic_id, 'meta_google_ad_article'))) {
$mobile_template = str_replace('<!--@IN-ARTICLE-GOOGLE@-->', '<script async src="https://pagead2.googlesyndication.com/pagead/js/adsbygoogle.js"></script><ins class="adsbygoogle" style="display:block; text-align:center;" data-ad-layout="in-article" data-ad-format="fluid" data-ad-client="ca-pub-4231674166786366" data-ad-slot="5442695494"></ins><script>(adsbygoogle = window.adsbygoogle || []).push({});</script>', $mobile_template);
}
//信息推荐
@ -623,16 +667,16 @@ class Information extends CI_Controller
$template_H1 = $this->call_mobile_template_H1($template_path, $this->input->post('is_path'), $this->input->post('ic_author'), $this->input->post('ic_title'), $this->input->post('ic_photo'));//H1模板替换
$template = str_replace('<!--@HEAD_1@-->', $template_H1, $template);
//额外样式
$meta_addon_css=get_meta($information->ic_id, 'meta_addon_css');
if(!empty($meta_addon_css)){
$template = str_replace('<!--@ADDON-CSS@-->', '<link href="'.$meta_addon_css.'" rel="stylesheet">', $template);
$meta_addon_css = get_meta($information->ic_id, 'meta_addon_css');
if (!empty($meta_addon_css)) {
$template = str_replace('<!--@ADDON-CSS@-->', '<link href="' . $meta_addon_css . '" rel="stylesheet">', $template);
}
$template = str_replace('<!--@CUSTOM-CONENT@-->', $this->input->post('ic_content'), $template);
//Google广告代码
if(!empty(get_meta($information->ic_id, 'meta_google_ad_content'))){
if (!empty(get_meta($information->ic_id, 'meta_google_ad_content'))) {
$template = str_replace('<!--@Match-Content-GOOGLE@-->', '<script async src="https://pagead2.googlesyndication.com/pagead/js/adsbygoogle.js"></script><ins class="adsbygoogle" style="display:block" data-ad-format="autorelaxed" data-ad-client="ca-pub-4231674166786366" data-ad-slot="1447610161"></ins><script>(adsbygoogle = window.adsbygoogle || []).push({});</script>', $template);
}
if(!empty(get_meta($information->ic_id, 'meta_google_ad_article'))) {
if (!empty(get_meta($information->ic_id, 'meta_google_ad_article'))) {
$template = str_replace('<!--@IN-ARTICLE-GOOGLE@-->', '<script async src="https://pagead2.googlesyndication.com/pagead/js/adsbygoogle.js"></script><ins class="adsbygoogle" style="display:block; text-align:center;" data-ad-layout="in-article" data-ad-format="fluid" data-ad-client="ca-pub-4231674166786366" data-ad-slot="5442695494"></ins><script>(adsbygoogle = window.adsbygoogle || []).push({});</script>', $template);
}
//信息推荐

@ -3,20 +3,22 @@
//获取项目类型名称
function get_project_typename($type)
{
$CI = & get_instance();
$type_list=$CI->config->item('project_types');
$CI = &get_instance();
$type_list = $CI->config->item('project_types');
return $type_list[$type];
}
function GetAreaName($HT_areaType, $HT_areaID) {
$CI = & get_instance();
function GetAreaName($HT_areaType, $HT_areaID)
{
$CI = &get_instance();
$CI->load->model('Area_model');
return $CI->Area_model->get_area_name($HT_areaType, $HT_areaID);
}
//查找作者名称,根据参数类型判断查作者表还是翰特表
function get_author_name($author_code_id) {
$CI = & get_instance();
function get_author_name($author_code_id)
{
$CI = &get_instance();
if (is_numeric($author_code_id)) {
$CI->load->model('Infoauthors_model');
$user = $CI->Infoauthors_model->detail_by_id($author_code_id);
@ -34,7 +36,8 @@ function get_author_name($author_code_id) {
}
//根据站点id获取站点名称
function get_sitecode($site_id, $site_array) {
function get_sitecode($site_id, $site_array)
{
foreach ($site_array as $item) {
if ($item['site_id'] == $site_id) {
return $item['site_code'];
@ -47,7 +50,8 @@ function get_sitecode($site_id, $site_array) {
* 递归创建文件夹
*/
function create_folder_by_path($dir, $mode = 0777) {
function create_folder_by_path($dir, $mode = 0777)
{
if (!is_dir($dir)) {
return @mkdir($dir, $mode, true);
}
@ -57,8 +61,9 @@ function create_folder_by_path($dir, $mode = 0777) {
/**
* 获取iis rewrite之前的原始url
*/
function get_origin_url() {
$CI = & get_instance();
function get_origin_url()
{
$CI = &get_instance();
if (isset($_SERVER['HTTP_X_REWRITE_URL'])) {
$origin_url = str_replace($CI->config->item('index_page'), '/', $_SERVER['HTTP_X_REWRITE_URL']);
} else {
@ -68,8 +73,9 @@ function get_origin_url() {
}
//是否是系列站
function is_series_site() {
$CI = & get_instance();
function is_series_site()
{
$CI = &get_instance();
$sitecode = $CI->config->item('site_code');
if ($sitecode == 'vc' || $sitecode == 'ru' || $sitecode == 'jp' || $sitecode == 'vac' || $sitecode == 'it') {
return true;
@ -80,8 +86,9 @@ function is_series_site() {
//是否是子站点
function is_sub_site() {
$CI = & get_instance();
function is_sub_site()
{
$CI = &get_instance();
$sitecode = $CI->config->item('site_code');
if ($sitecode == 'yz' || $sitecode == 'tbt' || $sitecode == 'mbj' || $sitecode == 'sht' || $sitecode == 'gl') {
return true;
@ -90,150 +97,154 @@ function is_sub_site() {
}
}
function add_meta($im_ic_id, $im_key, $im_value) {
$CI = & get_instance();
function add_meta($im_ic_id, $im_key, $im_value)
{
$CI = &get_instance();
$CI->load->model('InfoMetas_model');
return $CI->InfoMetas_model->add($im_ic_id, $im_key, $im_value);
}
function get_meta($im_ic_id, $im_key) {
$CI = & get_instance();
function get_meta($im_ic_id, $im_key)
{
$CI = &get_instance();
$CI->load->model('InfoMetas_model');
return $CI->InfoMetas_model->get($im_ic_id, $im_key);
}
function update_meta($im_ic_id, $im_key, $im_value) {
$CI = & get_instance();
function update_meta($im_ic_id, $im_key, $im_value)
{
$CI = &get_instance();
$CI->load->model('InfoMetas_model');
return $CI->InfoMetas_model->update($im_ic_id, $im_key, $im_value);
}
function delete_meta($im_ic_id, $im_key) {
$CI = & get_instance();
function delete_meta($im_ic_id, $im_key)
{
$CI = &get_instance();
$CI->load->model('InfoMetas_model');
return $CI->InfoMetas_model->delete($im_ic_id, $im_key);
}
//检查是否有短消息
function have_unread_sms($m_object_type,$m_object_id)
function have_unread_sms($m_object_type, $m_object_id)
{
$CI = & get_instance();
$CI->load->model('InfoSMS_model');
$sms_list=$CI->InfoSMS_model->unread_sms($m_object_type,$m_object_id);
$admin_info=$CI->session->userdata('session_admin');
if(empty($sms_list))
{
return false;
}
else
{
$sender=get_author_name($sms_list[0]->m_sender);
if($admin_info['OPI_Name']==$sender){
return false;
}else{
return true;
}
}
$CI = &get_instance();
$CI->load->model('InfoSMS_model');
$sms_list = $CI->InfoSMS_model->unread_sms($m_object_type, $m_object_id);
$admin_info = $CI->session->userdata('session_admin');
if (empty($sms_list)) {
return false;
} else {
$sender = get_author_name($sms_list[0]->m_sender);
if ($admin_info['OPI_Name'] == $sender) {
return false;
} else {
return true;
}
}
}
//截取字符串
function get_text_short($str, $length = 40, $ext = '',$only_content=false) {
$str = strip_tags($str);
$str = htmlspecialchars_decode($str);
$strlenth = 0;
$out = '';
$output = '';
$is_length = false;
preg_match_all("/[\x01-\x7f]|[\xc2-\xdf][\x80-\xbf]|[\xe0-\xef][\x80-\xbf]{2}|[\xf0-\xff][\x80-\xbf]{3}/", $str, $match);
foreach($match[0] as $v){
preg_match("/[\xe0-\xef][\x80-\xbf]{2}/",$v, $matchs);
if(!empty($matchs[0])){
$strlenth += 1;
}elseif(is_numeric($v)){
$strlenth += 0.5; // 字符字节长度比例 汉字为1
}else{
$strlenth += 0.5; // 字符字节长度比例 汉字为1
}
if ($strlenth > $length) {
$output .= $ext;
$is_length=true;
break;
}
$output .= $v;
function get_text_short($str, $length = 40, $ext = '', $only_content = false)
{
$str = strip_tags($str);
$str = htmlspecialchars_decode($str);
$strlenth = 0;
$out = '';
$output = '';
$is_length = false;
preg_match_all("/[\x01-\x7f]|[\xc2-\xdf][\x80-\xbf]|[\xe0-\xef][\x80-\xbf]{2}|[\xf0-\xff][\x80-\xbf]{3}/", $str, $match);
foreach ($match[0] as $v) {
preg_match("/[\xe0-\xef][\x80-\xbf]{2}/", $v, $matchs);
if (!empty($matchs[0])) {
$strlenth += 1;
} elseif (is_numeric($v)) {
$strlenth += 0.5; // 字符字节长度比例 汉字为1
} else {
$strlenth += 0.5; // 字符字节长度比例 汉字为1
}
$data['content']=$output;
$data['length']=$is_length;
if ($only_content) {
return $data['content'];
if ($strlenth > $length) {
$output .= $ext;
$is_length = true;
break;
}
return $data;
$output .= $v;
}
$data['content'] = $output;
$data['length'] = $is_length;
if ($only_content) {
return $data['content'];
}
return $data;
}
//平台头部展示所有未读消息数量
function get_all_unread_sms($type='author',$author=false)
function get_all_unread_sms($type = 'author', $author = false)
{
$CI = & get_instance();
$CI = &get_instance();
$CI->load->model('InfoSMS_model');
if(!$author){
$admin_info=$CI->session->userdata('session_admin');
$author=$admin_info['OPI_Code'];
if (!$author) {
$admin_info = $CI->session->userdata('session_admin');
$author = $admin_info['OPI_Code'];
}
if ($type=='info') {
$unread_sms=$CI->InfoSMS_model->info_unread_sms($author,'info');
}else{
$unread_sms=$CI->InfoSMS_model->all_unread_sms($author,'task');
if ($type == 'info') {
$unread_sms = $CI->InfoSMS_model->info_unread_sms($author, 'info');
} else {
$unread_sms = $CI->InfoSMS_model->all_unread_sms($author, 'task');
}
return $unread_sms;
}
//获取不同任务状态的任务数量
function get_task_count_by_status(){
$CI = & get_instance();
function get_task_count_by_status()
{
$CI = &get_instance();
$CI->load->model('Infotasks_model');
$task_count_by_status=$CI->Infotasks_model->get_task_count_by_status();
$task_count_by_status = $CI->Infotasks_model->get_task_count_by_status();
return $task_count_by_status;
}
//获取作者头像
function get_author_photo($author_code_id=false)
function get_author_photo($author_code_id = false)
{
$CI = & get_instance();
$root_url='';//'http://data.chtcdn.com';
$avatar=$root_url.'/css/images/avatar.jpg';
if($author_code_id && is_numeric($author_code_id))
{
$CI->load->model('Infoauthors_model');
$user=$CI->Infoauthors_model->detail_by_id($author_code_id);
if(isset($user->a_photo) && $user->a_photo!='')
{
$avatar = $root_url.'/author/document/profile_photo/'.$user->a_photo;
}
}
return $avatar;
$CI = &get_instance();
$root_url = '';//'http://data.chtcdn.com';
$avatar = $root_url . '/css/images/avatar.jpg';
if ($author_code_id && is_numeric($author_code_id)) {
$CI->load->model('Infoauthors_model');
$user = $CI->Infoauthors_model->detail_by_id($author_code_id);
if (isset($user->a_photo) && $user->a_photo != '') {
$avatar = $root_url . '/author/document/profile_photo/' . $user->a_photo;
}
}
return $avatar;
}
//补全图片路径
function get_photo_url($photo){
$root_url='';//'http://data.chtcdn.com';
if ($photo=='') {
$avatar = $root_url.'/css/images/uploadPic.jpg';
}else{
$avatar = $root_url.'/author/document/profile_photo/'.$photo;
function get_photo_url($photo)
{
$root_url = '';//'http://data.chtcdn.com';
if ($photo == '') {
$avatar = $root_url . '/css/images/uploadPic.jpg';
} else {
$avatar = $root_url . '/author/document/profile_photo/' . $photo;
}
return $avatar;
}
//获取待审核作者数量
function un_active_count(){
$CI = & get_instance();
function un_active_count()
{
$CI = &get_instance();
$CI->load->model('Infoauthors_model');
$num=$CI->Infoauthors_model->un_active_count();
$num = $CI->Infoauthors_model->un_active_count();
return $num;
}
//分页函数
function show_page($page){
function show_page($page)
{
$pageSize = $page['pageSize'];
$total = $page['total'];
$url = $page['url'];
@ -242,94 +253,106 @@ function show_page($page){
$startPage = ($currentPage - 1) * $pageSize;
$befor = $after = 0;
$nowview=ceil(($currentPage+1)/10);
$befor = $nowview==1?($nowview-1)*10+1:($nowview-1)*10;
if($pageNumber>=$nowview*10){
$after = $nowview*10;
}else{
$nowview = ceil(($currentPage + 1) / 10);
$befor = $nowview == 1 ? ($nowview - 1) * 10 + 1 : ($nowview - 1) * 10;
if ($pageNumber >= $nowview * 10) {
$after = $nowview * 10;
} else {
$after = $pageNumber;
}
$html='';
if($nowview>1) $befor--;
if ($pageSize <= $total) {
for ($i = $befor; $i <= $after; $i++) {
if ($i == $currentPage) {
$html = '';
if ($nowview > 1) $befor--;
if ($pageSize <= $total) {
for ($i = $befor; $i <= $after; $i++) {
if ($i == $currentPage) {
$html .= "<li class=\"active\"><a href=\"javascript:void(0)\">{$i}</a></li>";
}else {
} else {
$html .= "<li><a href=\"{$url}/{$i}\">$i</a></li>";
}
}
}
}
}
$res['htmls']=$html;
$res['prepage']=$currentPage - 1;
$res['nextpage']=$currentPage + 1;
$res['totalpage']=$pageNumber;
return $res;
$res['htmls'] = $html;
$res['prepage'] = $currentPage - 1;
$res['nextpage'] = $currentPage + 1;
$res['totalpage'] = $pageNumber;
return $res;
}
//请求URL并返回数组数据
function get_content_by_url($url) {
//echo $url;
$httpInfo = array();
$ch = curl_init();
curl_setopt($ch, CURLOPT_HTTP_VERSION, CURL_HTTP_VERSION_1_0);
curl_setopt($ch, CURLOPT_USERAGENT, 'Mozilla/5.0 (Windows NT 5.1) AppleWebKit/537.22 (KHTML, like Gecko) Chrome/25.0.1364.172 Safari/537.22');
curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 30);
curl_setopt($ch, CURLOPT_TIMEOUT, 30);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false); //不验证证书
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false);
curl_setopt($ch, CURLOPT_URL, $url);
$response = curl_exec($ch);
if ($response === FALSE) {
#echo "cURL Error: " . curl_error($ch);
return false;
}
return $response;
function get_content_by_url($url)
{
//echo $url;
$httpInfo = array();
$ch = curl_init();
curl_setopt($ch, CURLOPT_HTTP_VERSION, CURL_HTTP_VERSION_1_0);
curl_setopt($ch, CURLOPT_USERAGENT, 'Mozilla/5.0 (Windows NT 5.1) AppleWebKit/537.22 (KHTML, like Gecko) Chrome/25.0.1364.172 Safari/537.22');
curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 30);
curl_setopt($ch, CURLOPT_TIMEOUT, 30);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false); //不验证证书
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false);
curl_setopt($ch, CURLOPT_URL, $url);
$response = curl_exec($ch);
if ($response === FALSE) {
#echo "cURL Error: " . curl_error($ch);
return false;
}
return $response;
}
function GET_HTTP($url, $data = '', $method = 'GET') {
$curl = curl_init(); // 启动一个CURL会话
curl_setopt($curl, CURLOPT_URL, $url); // 要访问的地址
curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, 0); // 对认证证书来源的检查
curl_setopt($curl, CURLOPT_SSL_VERIFYHOST, 0); // 从证书中检查SSL加密算法是否存在
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)) {
curl_setopt($curl, CURLOPT_POST, 1); // 发送一个常规的Post请求
curl_setopt($curl, CURLOPT_POSTFIELDS, $data); // Post提交的数据包
}
curl_setopt($curl, CURLOPT_TIMEOUT, 45); // 设置超时限制防止死循环
curl_setopt($curl, CURLOPT_HEADER, 0); // 显示返回的Header区域内容
curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1); // 获取的信息以文件流的形式返回
$tmpInfo = curl_exec($curl); // 执行操作
$httpCode = curl_getinfo($curl, CURLINFO_HTTP_CODE);
if($httpCode>=400){//页面状态如果大于400说明页面打不开
log_message('error', " curl {$httpCode} {$url} ");
return false;
}
$errno = curl_errno($curl);
if ($errno !== 0) {
return false;
$error_message = $errno . ' ' . curl_error($curl); //记录错误日志
log_message('error', "train/get_http curl {$error_message}");
}
curl_close($curl); //关闭CURL会话
return $tmpInfo; //返回数据
function GET_HTTP($url, $data = '', $method = 'GET')
{
$curl = curl_init(); // 启动一个CURL会话
curl_setopt($curl, CURLOPT_URL, $url); // 要访问的地址
curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, 0); // 对认证证书来源的检查
curl_setopt($curl, CURLOPT_SSL_VERIFYHOST, 0); // 从证书中检查SSL加密算法是否存在
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)) {
curl_setopt($curl, CURLOPT_POST, 1); // 发送一个常规的Post请求
curl_setopt($curl, CURLOPT_POSTFIELDS, $data); // Post提交的数据包
}
curl_setopt($curl, CURLOPT_TIMEOUT, 45); // 设置超时限制防止死循环
curl_setopt($curl, CURLOPT_HEADER, 0); // 显示返回的Header区域内容
curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1); // 获取的信息以文件流的形式返回
$tmpInfo = curl_exec($curl); // 执行操作
$httpCode = curl_getinfo($curl, CURLINFO_HTTP_CODE);
if ($httpCode >= 400) {//页面状态如果大于400说明页面打不开
log_message('error', " curl {$httpCode} {$url} ");
return false;
}
$errno = curl_errno($curl);
if ($errno !== 0) {
return false;
$error_message = $errno . ' ' . curl_error($curl); //记录错误日志
log_message('error', "train/get_http curl {$error_message}");
}
curl_close($curl); //关闭CURL会话
return $tmpInfo; //返回数据
}
//获取内容中图片地址
function get_image_url_by_source($source){
$pattern="/<[img|IMG].*?src=[\'|\"](.*?(?:[\.jpeg|\.png|\.jpg]))[\'|\"].*?[\/]?>/";
preg_match_all($pattern, $source, $match);
return $match;
}
//获取内容中图片地址
function get_image_url_by_source($source)
{
$pattern = "/<[img|IMG].*?src=[\'|\"](.*?(?:[\.jpeg|\.png|\.jpg]))[\'|\"].*?[\/]?>/";
preg_match_all($pattern, $source, $match);
return $match;
}
//压缩css代码
function compress_css($buffer)
{
/* remove comments */
$buffer = preg_replace('!/\*[^*]*\*+([^/][^*]*\*+)*/!', '', $buffer);
/* remove tabs, spaces, newlines, etc. */
$buffer = str_replace(array("\r\n", "\r", "\n", "\t", ' ', ' ', ' '), '', $buffer);
return $buffer;
}

File diff suppressed because it is too large Load Diff
Loading…
Cancel
Save