<? Php
// Wu yanjun
// The collection program 2cto.com
Set_time_limit (0 );
// Cookie storage directory
$ Cookie_jar =/tmp/cookie. tmp;
/* Function compute ------------------------------------------------------------------------------------------------------------*/
// Simulate request data
Function request ($ url, $ postfields, $ cookie_jar, $ referer ){
$ Ch = curl_init ();
$ Options = array (CURLOPT_URL => $ url,
CURLOPT_HEADER => 0,
CURLOPT_NOBODY => 0,
CURLOPT_PORT => 80,
CURLOPT_POST => 1,
CURLOPT_POSTFIELDS => $ postfields,
CURLOPT_RETURNTRANSFER => 1,
CURLOPT_FOLLOWLOCATION => 1,
CURLOPT_COOKIEJAR => $ cookie_jar,
CURLOPT_COOKIEFILE => $ cookie_jar,
CURLOPT_REFERER => $ referer
);
Curl_setopt_array ($ ch, $ options );
$ Code = curl_exec ($ ch );
Curl_close ($ ch );
Return $ code;
}
// Obtain the post list
Function getThreadsList ($ code ){
Preg_match_all (/<! -- [. |] *? <A href = "viewthread. php? Tid = (d +)/, $ code, $ threads );
Return $ threads [1];
}
// Determine whether the post exists
Function isExits ($ code ){
Preg_match (/<p> the specified topic does not exist, has been deleted, or is being reviewed. Please return. </P>/, $ code, $ error );
Return isset ($ error [0])? False: true;
}
// Obtain the post title
Function getTitle ($ code ){
Preg_match (/$ Title = $ title_tmp [0];
Return $ title;
}
// Obtain the post Author:
Function getAuthor ($ code ){
Preg_match (/<a href = "space. php? Uid = d + "target =" _ blank "id =" userinfod + "onmouseover =" showMenu (this. id) ">. +/, $ code, $ author_tmp );
$ Author = strip_tags ($ author_tmp [0]);
Return $ author;
}
// Obtain the table content from the poster
Function getContents ($ code ){
Preg_match (/<div id = "postmessage_d +" class = "t_msgfont"> (. | )*? </Div>/, $ code, $ contents_tmp );
$ Contents = preg_replace (/images //, http://bbs.war3.cn/images/,#contents_tmp%0]);
Return $ contents;
}
// Print the post title
Function printTitle ($ title ){
Echo "<strong> }
// Output post author
Function printAuthor ($ author ){
Echo "<strong> }
// Print the post content
Function printContents ($ contents ){
Echo "<strong> }
// Error
Function printError (){
Echo "<I> This post does not exist! </I> ";
}
/* Function list end functions ---------------------------------------------------------------------------------------------------*/
/* Log on to the Forum begin */
$ Url = http://bbs.war3.cn/logging.php? Action = login;
$ Postfields = loginfield = username & amp; username = 1nject10n & password = xxxxxx & questionid = 0 & cookietime = 315360000 & referer = http://bbs.war3.cn/&loginsubmit=submit;
Request ($ url, $ postfields, $ cookie_jar ,);
Unset ($ postfields, $ url );
/* Log on to the Forum end */
/* Obtain the post list (the post on the first page) begin */
$ Url = http://bbs.war3.cn/forumdisplay.php? Fid = 57;
$ Code = request ($ url, $ cookie_jar ,);
$ ThreadsList = getThreadsList ($ code );
/* Get the post list end */
// Post sequence
$ Rows = 0;
/* Capture the source code of all posts cyclically */
Foreach ($ threadsList as $ list ){
$ Url = "http://bbs.war3.cn/viewthread.php? Tid = $ list ";
If (isExits ($ code )){
$ Code = request ($ url, $ cookie_jar ,);
$ Color = $ rows % 2 = 0? #00 CCFF: # FFFF33;
Echo "<div style = background-color: $ color> ";
Echo "$ Author = getAuthor ($ code );
PrintAuthor ($ author );
$ Title = getTitle ($ code );
PrintTitle ($ title );
$ Contents = getContents ($ code );
PrintContents ($ contents );
Echo "</div> ";
$ Rows ++;
}
Else
PrintError ();
Echo "Success <br/> ";
}
/* Capture the source code end */
?>