Php knows and asks the collection plug-in code

Source: Internet
Author: User

I recently found that more and more versions are available to know and ask thieves !!
The number of websites that have seen a Baidu thief reaches pr6. More than 100,000 !!
After 40 days of provisioning, I found that Baidu is really friendly to this.
From the perspective of Website access, many of them are also from Baidu search!
Therefore, it is feasible to fill in the website content by knowing and asking.
So I developed a collection plug-in that knows the question.
In principle, it is suitable for php + mysql and the article is in a table program.
Know the collection code
Copy codeThe Code is 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 the search keyword
$ Word = ""; // enter the keyword
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 you search
{
// Obtain the 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 );
// Obtain the question list
Preg_match_all ("/<a href = \" \/question \/(. *) \. html/iUs ", $ content, $ uid );
$ Uid = $ uid [1]; // get detailed page article
$ Uid = $ uid [$ rs];
// 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]; // The title is obtained.
// Determine whether the content meets the requirements
$ Word_arr = explode (",", $ cj_word );
$ Word_allow = false; // whether collection is allowed during initialization
$ Word_count = count ($ word_arr); // The 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 to collect 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 sorting
{
Shuffle ($ answerArr );
}
If ($ arr_order = 2) // Reverse Order
{
$ 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 the link
$ S1 = "/(<a. *>) (. *) <\/a>/iUs ";
$ Art_content = preg_replace ($ s1, $ {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'"); // check whether the title is repeated
$ 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 a collection table
Mysql_query ($ SQL );
If (empty ($ t_catx_id) // if no category exists
{
$ Sql2 = "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
{
$ Sql2 = "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 ($ sql2); // insert an article table
$ Jl ++;
// The database has been processed
} Else
{
Echo "insufficient content length ";
}
// Get the content of the article.
} Else
{
Echo "the topic does not meet the requirements ";
}
} Else
{
Echo "already exists ";
} $ Rs ++;
File_put_contents ("bd.txt", "collect {$ searchStr} to Article {$ 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 = "700" border = "0" align = "center" cellspacing = "1" bgcolor = "# CCCCCC">
<Tr>
<Td height = "50" align = "center" bgcolor = "#00CC00"> </Tr>
</Table>
<Table width = "700" border = "0" align = "center" cellspacing = "1" bgcolor = "# CCCCCC" style = "margin-top: 6px; margin-bottom: 6px; ">
<Tr>
<Td height = "30" 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 plug-in '); "> uninstall collection </a> <a href =" cj_view.php "> View Collection records </a> <a href =" cj_help.php "> collect help </a> <a href = "baidu. php "target =" _ blank "> know collection </a> <a href =" wenwen. php "target =" _ blank "> query collection </a> </td>
</Tr>
</Table>
<Table width = "537" height = "45" align = "center" style = "margin-top: 30px;"> <tr> <td height = "39">
<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 =" 60 "/>
<Input type = "submit" name = "searchBtn" id = "searchBtn" value = "" style = "height: 25px; line-height: 25px;"/>
</Div>
</Form>
</Td> </tr> </table>

Ask the collection code:
Copy codeThe Code is 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 ']); // obtain the form submission question
$ Sp = "S". $ ask;
} Else
{
$ Sp = urlencode ($ _ GET ['SP ']);
}
If (empty ($ _ GET ['jl '])
{
$ _ GET ['jl '] = 1;
}
$ Jl = $ _ GET ['jl '];
$ Pg = intval ($ _ GET ['pg ']); // GET the page number
$ Rs = intval ($ _ GET ['rs ']); // Obtain Record Parameters
If ($ rs> 9)
{
$ Rs = 0;
$ Pg ++;
}
If ($ pg> 51)
{
Echo "Collection Completed! Collect a total of ". urldecode ($ sp)." ". $ jl." records ";
Exit ();
}
If ($ sp) // starts with a set answer
{
$ 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); // obtain the Q & A list
// Echo $ asklist [1];
$ Url = "/<a target = \" _ blank \ "href = \" \/z \/(q. * \. htm)/iUs ";
@ Preg_match_all ($ url, $ asklist [1], $ urllist); // obtain all 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/>", $ 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 );
$ S1 = "/(<a. *>) (. *) <\/a>/iUs ";
$ Art_content = preg_replace ($ s1, $ {2}, trim ($ art_content ));
$ Word_arr = explode (",", iconv ("gbk", "UTF-8", $ cj_word ));
$ Word_allow = false; // whether collection is allowed during initialization
$ Word_count = count ($ word_arr); // total number
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 valid
{// Start processing the database
If (strlen ($ art_content)> $ min_t2)
{
Echo "<font color = red> adding ............................ </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'"); // check whether the title is repeated
$ 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 a collection table
Mysql_query ($ SQL );
If (empty ($ t_catx_id) // if no category exists
{
$ Sql2 = "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
{
$ Sql2 = "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 ($ sql2); // insert an article table
$ Jl ++; // Add 1 to the record if it is stored in the database
// Process the database.
} Else
{
Echo "not long enough ";
}
} Else
{
Echo "the topic does not meet the requirements ";
}
} Else
{
Echo "already exists ";
}
$ Rs ++;
// Record the status of this collection
$ F_tt = urldecode ($ sp). "-- page number". $ 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 = "700" border = "0" align = "center" cellspacing = "1" bgcolor = "# CCCCCC">
<Tr>
<Td height = "50" align = "center" bgcolor = "#00CC00"> </Tr>
</Table>
<Table width = "700" border = "0" align = "center" cellspacing = "1" bgcolor = "# CCCCCC" style = "margin-top: 6px; margin-bottom: 6px; ">
<Tr>
<Td height = "30" 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 plug-in '); "> uninstall collection </a> <a href =" cj_view.php "> View Collection records </a> <a href =" cj_help.php "> collect help </a> <a href = "baidu. php "target =" _ blank "> know collection </a> <a href =" wenwen. php "target =" _ blank "> query collection </a> </td>
</Tr>
</Table>
<Form action = "wenwen. php" method = "post">
<Table width = "628" height = "49" border = "0" align = "center">
<Tr>
<Td width = "413" align = "right"> <input name = "ask" type = "text" id = "ask" size = "50"> </td>
<Td width = "205"> <input type = "submit" name = "button" id = "button" value = "" 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.