116369网赚博客

当前位置:网站首页 / 网站程序 / 正文

写了一个小程序,帝国的入库真是愁死人啊

<?PHP
header("Expires: Mon, 26 Jul 1997 05:00:00 GMT");    
header("Cache-Control: no-store, no-cache, must-revalidate");
header("Cache-Control: post-check=0, pre-check=0", false);    
header("Last-Modified: ".gmdate("D, d M Y H:i:s")." GMT");    
    header( 'Content-Type:text/html;charset=utf8');
$url=$_POST['url'];
$html = getSslPage($url);
preg_match("/class=\"question-name\">(.*)<\/h1/is",$html,$inarr);
$title=trim($inarr[1]);
preg_match_all("/answer-text-full rich-text\">.*?<\/div>/ism",$html,$inarr);
$con = $inarr[0][1].$inarr[0][0];

$con = str_replace("answer-text-full rich-text","",$con);
$con = str_replace('"',"",$con);
$con = substr($con,1);

$con = cleanhtml($con,'<p><br/><span>');

$db = mysql_connect("116.255.255.83","linwei","linwei");
mysql_select_db("linwei", $db);
$q = "select * from phome_ecms_news order by id desc limit 1";
$result = mysql_query("$q");
while($row = mysql_fetch_array($result))
  {
  $flag = $row['id'];
  }
 
 $classid=rand(3,8);
 
 
 
 $result = mysql_query("select * from phome_enewsclass where classid=$classid");
while($row = mysql_fetch_array($result))
  {
    $classpath = $row['classpath'];
  }
 
 

date_default_timezone_set("Asia/Shanghai");
$flag = $flag+1;
$newspath = date("Y-m-d");
$filename = $flag;
$username = 'admin';
$truetime=  time();
$lastdotime = time();
$newstime = time();
$title = $title;
$smalltext = substr($con,0,100);

$titleurl = "/c/"."$classpath/$newspath/$flag.html";
$con = addslashes($con);

mysql_query("set names utf8");
$q = "insert into phome_ecms_news(id,filename,classid,newspath,userid,username,truetime,lastdotime,titleurl,title,newstime,smalltext) values($flag,'$flag',$classid,'$newspath',1,'admin',$truetime,$lastdotime,'$titleurl','$title',$newstime,'$title')";
mysql_query($q);
$q = "insert into phome_ecms_news_index(id,classid,checked,newstime,truetime,lastdotime,havehtml) values($flag,$classid,1,$newstime,$truetime,$lastdotime,1)";
mysql_query($q);
$q = "insert into phome_ecms_news_data_1(id,classid,keyid,dokey,infotags,writer,befrom,newstext)
                                  values($flag,$classid,'',1,'','','','$con')";      
                                    
                              
                                      mysql_query($q);













function cleanhtml($str,$tags='<p><br><img>'){//过滤时默认保留html中的<p><img>标签
    $search = array(
        '@<script[^>]*?>.*?</script>@si',// 除去JavaScript
        /*'@<[\/\!]*?[^<>]*?>@si',//除去html标记*/
        '@<style[^>]*?>.*?</style>@siU',// Strip style tags properly
        '@<![\s\S]*?--[ \t\n\r]*>@'// 带多行注释包括CDATA
    );
    $str = preg_replace($search,'', $str);
    $str = strip_tags($str,$tags);
    return $str;
}






function getSslPage($url) {
$ch = curl_init();
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE);
curl_setopt($ch, CURLOPT_HEADER, false);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_REFERER, $url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE);
$result = curl_exec($ch);
curl_close($ch);
return $result;
}














?>

www.116369.com

推荐阅读

文章标签:

版权声明: 本文除特别说明外均由原创

本文链接: http://116369.com/post/2928.html,尊重共享,欢迎转载,请自觉添加本文链接,谢谢!

分享本文: 请填写您的分享代码。

呃 本文暂时没人评论 来添加一个吧

发表评论

必填

选填

选填

◎欢迎参与讨论,请在这里发表您的看法、交流您的观点。

请填写你的广告代码,或者删除本行文字。