PHP know and ask the collection plug-in code _php tips

Source: Internet
Author: User
Tags explode urlencode
Recently found to know and ask the version of the thief more and more!!
Saw a Baidu thief's website also reached the PR6. Included more than 100,000!!
After 40 days after the practice of recommending that Baidu is really very friendly to this.
Visit from the website to see a lot is also from Baidu Search!
So it is still possible to fill the content of the site with knowledge and questions.
So I developed a collection plug-in that knows how to ask.
In principle fit php+mysql and the article is in the program of a table
Know the Acquisition code
Copy Code code as follows:

<?php
Session_Start ();
Header ("CONTENT-TYPE:TEXT/HTML;CHARSET=GBK");
Require ("stole_config.php");
Require ("conn.php");
Require ("keyword.php");
$searchStr =$_get["Searchstr"];
$ss =explode ("", $searchStr);//Split search keyword
$word = "";//the keyword is set to null
foreach ($ss as $key => $t)
{
if ($key >0)
{
$word. = "+";
}
$word. =urlencode ($t);
}
$JL =intval ($_get[' JL '));
if (Isset ($_get[' page '))
{
$page =intval ($_get[' page '));
}else{
$page = 1;
}
$rs =intval ($_get[' rs '));
if ($rs >=10)
{
$rs = 0;
$page + +;
}
if ($page >76)
{
echo "Collection completed ${JL}";
Exit ();
}
if (!empty ($SEARCHSTR))//If Search
{
Get Problem page
$content = @file_get_contents ("http://zhidao.baidu.com/q?ct=17&lm=0&tn=ikaslist&pn="). ( ($page-1) *10). " &rn=10&word= ". $word);
Get a list of issues
Preg_match_all ("/<a href=\" \/question\/(. *) \.html/ius ", $content, $uid);
$uid = $uid [1];//get detailed page articles
$uid = $uid [$rs];
To determine whether the data exists
$suid = "bd{$uid}";
$SCT =mysql_query ("SELECT count (*) from {$table _prefix}c_article where suid= ' $suid '");
$SCT =mysql_fetch_array ($SCT);
$SCT = $SCT [0];
if ($SCT ==0)
{
$content = @file_get_contents ("http://zhidao.baidu.com/question/". $uid. ". HTML ");
$arr =explode (' <cq> ', $content);
$art _title= $arr [1];
$arr =explode (' </cq> ', $art _title);
$art _title= $arr [0];//get title End
Determine whether the content meets
$word _arr=explode (",", $CJ _word);
$word whether the _allow=false;//initialization allows the acquisition of
$word _count=count ($word _arr);//Total number of keywords
for ($i =0; $i < $word _count; $i + +)
{
if (Substr_count ($art _title, $word _arr[$i]) >0)
{
$word _allow=1;
$i = $word _count;
}
}
if ($word _allow)//If conditions are met
{
$arr =explode (' <cd><pre> ', $content);
$contentQuestion = $arr [1];
$arr =explode (' </pre></cd> ', $contentQuestion);
$contentQuestion = $arr [0];
echo "Start collecting content <br>";
echo "$art _title<br>";
@preg_match_all (' <ca>|<cn>) <pre> (. *) <\/pre> (<\/ca>|<\/cn>)/ius ', $content , $ANSWERARR);
$ANSWERARR = $ANSWERARR [2];
if ($arr _order==1)//random sort
{
Shuffle ($ANSWERARR);
}
if ($arr _order==2)//Reverse
{
$ANSWERARR =krsort ($ANSWERARR);/reverse
}
foreach ($answerArr as $t)
{
$answerTemp =str_replace (' <ca><pre> ', ', $t);
$answerTemp =str_replace (' </pre></ca> ', ', $answerTemp);
$answerTemp =str_replace (' <cn><pre> ', ', $answerTemp);
$answerTemp =str_replace (' </pre></cn> ', ', $answerTemp);
if (strlen ($answerTemp) > $min _t1)
{
$art _content. = $answerTemp. " <br> ";
}
}
Remove link
$s 1= "/(<a .*>) (. *) <\/a>/ius";
$art _content=preg_replace ($s 1,${2},trim ($art _content));
$art _content=str_replace ("\n\r", "<br>", $art _content);
if (strlen ($art _content) > $min _t2)
{
$title _ct=mysql_query ("SELECT count (*) from {$table _prefix}c_article where art_title = ' $art _title '");//See whether the title repeats
$title _ct= @mysql_fetch_array ($title _ct);
$title _ct= $title _ct[0];
if ($title _ct>0)
{
$art _title. = "{$same _title}{$title _ct}";
}
$art _time=date ("y-m-d");
$art _content=strtr ($art _content, $keyword);
$sql = "INSERT INTO {$table _prefix}c_article (art_title,art_content,art_time,art_author,suid) VALUES (' $art _title ', ' $ Art_content ', ' $art _time ', ' $art _author ', ' $suid '); Insert Collection table
mysql_query ($sql);
if (Empty ($t _catx_id))//If no category
{
$sql 2= insert INTO {$t _table} ({$t _art_title},{$t _art_content},{$t _art_time},{$t _artx_author}) VALUES (' $art _title ' , ' $art _content ', ' $art _time ', ' $art _author ');
}else
{
$sql 2= insert INTO {$t _table} ({$t _art_title},{$t _art_content},{$t _art_time},{$t _artx_author},{$t _catx_id}) values (' $art _title ', ' $art _content ', ' $art _time ', ' $art _author ', ' $cat _id ') ";
}
mysql_query ($sql 2);//Insert Article table
$JL + +;
Database processing Complete
}else
{
echo "Insufficient content length";
}
Get end of article content
}else
{
echo "Subject does not meet the requirements";
}
}else
{
echo "already exists";
} $rs + +;
File_put_contents ("Bd.txt", "Collect {$searchStr} to {$page} {$rs}");
echo "<script>location.href= ' baidu.php?searchstr=". UrlEncode ($SEARCHSTR). " &page= ". $page." &rs= ". $rs." &jl= ". $jl." ';</script> ';
Exit ();
}
?>
<link href= "Style.css" rel= "stylesheet" type= "Text/css"/>
<table width= "border=" "0" align= "center" cellspacing= "1" bgcolor= "#CCCCCC" >
<tr>
&LT;TD height= "align=" "Center" bgcolor= "#00CC00" ></tr>
</table>
<table width= "border=" 0 "align=" center "cellspacing=" 1 "bgcolor=" #CCCCCC "style=" MARGIN-TOP:6PX; margin-bottom:6px; " >
<tr>
&LT;TD height= "align=" center "bgcolor=" #FFFFFF "><a href=" cj_config.php "> Collection settings </a> <a href=" uninstall.php "onclick=" return confirm (' Are you sure you want to uninstall the collection plugin? '); " > Uninstall Collection </a> <a href= "cj_view.php" > View capture record </a> <a href= "cj_help.php" > Acquisition help </a> <a href= "baidu.php" target= "_blank" > Know collection </a> <a href= "wenwen.php" target= "_blank" > Ask and collect </a></ Td>
</tr>
</table>
<table width= "537" height= "align=" "Center" style= "margin-top:30px"; &GT;&LT;TR&GT;&LT;TD height= ">"
<form id= "Form1" Name= "Form1" method= "Get" action= "baidu.php" >
<div id= "Search" >
<input name= "Searchstr" type= "text" id= "Searchstr" value= "<?php echo $searchStr;?>" Size= "
<input type= "Submit" Name= "searchbtn" id= "searchbtn" value= "know Secretly" style= "HEIGHT:25PX; line-height:25px; "/>
</div>
</form>
</td></tr></table>

Ask the Acquisition code:
Copy Code code as follows:

<?php
Session_Start ();
Header ("Content-type:text/html;charset=utf-8");
Require ("stole_config.php");
Require ("conn.php");
Require ("keyword.php");
if (!empty ($_post[' ask '))
{
$ask =urlencode (Trim ($_post[' ask '))//Get form Submit
$SP = "S". $ask;
}else
{
$sp =urlencode ($_get[' SP ']);
}
if (Empty ($_get[' JL '))
{
$_get[' JL ']=1;
}
$JL =$_get[' JL '];
$PG =intval ($_get[' pg ']);//Get Number of pages
$rs =intval ($_get[' rs ']);//Get the parameters of the record
if ($rs >9)
{
$rs = 0;
$PG + +;
}
if ($PG >51)
{
echo "Collection completed! Total Collection ". UrlDecode ($SP)." ". $jl." Record ";
Exit ();
}
if ($SP)//has set the answer to start
{
$str = @file_get_contents ("http://wenwen.soso.com/z/search.e?sp={$sp}&pg={$pg}");
@preg_match ("/<ol class=\" result_list\ "> (. *) <\/ol>/ius", $str, $asklist);//Get a question and answer list
echo $asklist [1];
$url = "/<a target=\" _blank\ "href=\" \/z\/(q.*\.htm)/ius ";
@preg_match_all ($url, $asklist [1], $urllist);/Get all the questions
$t = $urllist [1][$rs];
$uid = $t;
$suid = "ww{$uid}";
$SCT =mysql_query ("SELECT count (*) from {$table _prefix}c_article where suid= ' $suid '");
$SCT =mysql_fetch_array ($SCT);
$SCT = $SCT [0];
if ($SCT ==0)
{
$html = @file_get_contents ("Http://wenwen.soso.com/z/${t}");
$html =str_replace ("<pre>", "" ", Str_replace (" </pre> "," ", $html));
$html =str_replace ("<br/><br/><br/>", "<br/><br/>", $html);
Echo $html;
@preg_match ("/<div class=\" question_main\ ">.*$art _title= $ask _title[1];
@preg_match ("/<div class=\" answer_con\ "> (. *) <\/div>/ius", $html, $answer);
$j =count ($answer)-1;
$art _content= "";//Product Details
for ($i = $j; $i >=1; $i-)
{
if (strlen ($answer [$i]) > $min _t1)
{
$art _content. = $answer [$i];
}
}
$art _content=trim ($art _content);
$s 1= "/(<a .*>) (. *) <\/a>/ius";
$art _content=preg_replace ($s 1,${2},trim ($art _content));
$word _arr=explode (",", Iconv ("GBK", "Utf-8", $CJ _word));
$word whether the _allow=false;//initialization allows the acquisition of
$word _count=count ($word _arr)/Total
for ($i =0; $i < $word _count; $i + +)
{
if (Substr_count ($art _title, $word _arr[$i]) >0)
{
$word _allow=1;
$i = $word _count;
}
}
if ($word _allow)//If legal
{//Start processing database
if (strlen ($art _content) > $min _t2)
{
echo "<font color=red> added ............................</font><br>";
echo $art _title. " <br> ";
$art _title=iconv (' utf-8 ', ' GBK ', $art _title);
$title _ct=mysql_query ("SELECT count (*) from {$table _prefix}c_article where art_title = ' $art _title '");//See whether the title repeats
$title _ct= @mysql_fetch_array ($title _ct);
$title _ct= $title _ct[0];
if ($title _ct>0)
{
$art _title. = "{$same _title}{$title _ct}";
}
$art _content=iconv (' utf-8 ', ' GBK ', Str_replace ("\ r \ n", "<br>", $art _content));
$art _content=strtr ($art _content, $keyword);
$art _time=date ("y-m-d");
$sql = "INSERT INTO {$table _prefix}c_article (art_title,art_content,art_time,art_author,suid) VALUES (' $art _title ', ' $ Art_content ', ' $art _time ', ' $art _author ', ' $suid '); Insert Collection table
mysql_query ($sql);
if (Empty ($t _catx_id))//If no category
{
$sql 2= insert INTO {$t _table} ({$t _art_title},{$t _art_content},{$t _art_time},{$t _artx_author}) VALUES (' $art _title ' , ' $art _content ', ' $art _time ', ' $art _author ');
}else
{
$sql 2= insert INTO {$t _table} ({$t _art_title},{$t _art_content},{$t _art_time},{$t _artx_author},{$t _catx_id}) values (' $art _title ', ' $art _content ', ' $art _time ', ' $art _author ', ' $cat _id ') ";
}
mysql_query ($sql 2);//Insert Article table
$JL ++;//Records plus 1 if the database is stored
Processing Database End
}else
{
echo "Length not enough";
}
}else
{
echo "Subject does not meet the requirements";
}
}else
{
echo "already exists";
}
$rs + +;
Record the status of this collection
$f _tt= UrlDecode ($SP). --pages ". $pg." Number of records ". $jl;
File_put_contents ("Ss.txt", $f _tt);
echo "<script>location.href= ' wenwen.php?jl=". $jl. " &sp= ". $sp." &pg= ". $pg." &rs= ". $rs." ';</script> ';
Exit ();
}
?>
<link href= "Style.css" rel= "stylesheet" type= "Text/css"/>
<table width= "border=" "0" align= "center" cellspacing= "1" bgcolor= "#CCCCCC" >
<tr>
&LT;TD height= "align=" "Center" bgcolor= "#00CC00" ></tr>
</table>
<table width= "border=" 0 "align=" center "cellspacing=" 1 "bgcolor=" #CCCCCC "style=" MARGIN-TOP:6PX; margin-bottom:6px; " >
<tr>
&LT;TD height= "align=" center "bgcolor=" #FFFFFF "><a href=" cj_config.php "> Collection settings </a> <a href=" uninstall.php "onclick=" return confirm (' Are you sure you want to uninstall the collection plugin? '); " > Uninstall Collection </a> <a href= "cj_view.php" > View capture record </a> <a href= "cj_help.php" > Acquisition help </a> <a href= "baidu.php" target= "_blank" > Know collection </a> <a href= "wenwen.php" target= "_blank" > Ask and collect </a></ Td>
</tr>
</table>
<form action= "wenwen.php" method= "POST" >
<table width= "628" height= "border=" "0" align= "center" >
<tr>
&LT;TD width= ' 413 ' align= ' right ' ><input name= ' ask ' type= ' text ' id= ' ask ' size= ' ></td>
&LT;TD width= "205" ><input type= "Submit" name= "button" id= "button" value= "to ask Collection" style= "PADDING-LEFT:15PX; padding-right:15px; height:25px; line-height:25px; " ></td>
</tr>
</table>
</form>

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.