| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133 |
/** @ Author 80aj * @ email a@80aj.com * @ descripton: author: big waterwheel, achieve discuz2.5 login Post * @ filename class_dz.php */classdiscuz_post {constLOGIN_PROGRAM = 'member. php? Mod = logging & action = login & loginsubmit = yes & infloat = yes '; constPOST_PROGRAM = 'forum. php? Mod = post & action = newthread & fid = '; private $ host; private $ cookie_file;/***** @ param unknown $ host */publicfunction _ construct ($ host) {$ this-> host = $ host;}/***** @ return unknown */publicfunctionget_formhash () {$ login_url = $ this-> _ get_Login_Url (); $ ch = curl_init (); curl_setopt ($ ch, CURLOPT_URL, $ login_url); curl_setopt ($ ch, CURLOPT_HEADER, false); curl_setopt ($ ch, CURLOPT_RETURNTRANSFER, true ); $ contents = curl_exec ($ ch); curl_close ($ ch); preg_match ('//IsU ', $ contents, $ matches); if (! Empty ($ matches) {$ formhash = $ matches [1];} else {// die ('Not found the forumhash. ');} return $ formhash;}/***** @ param unknown $ post * @ return string */publicfunctionlogin ($ user, $ pass) {$ login_info = array ('username' => $ user, 'password' => $ pass, 'referer' => $ this-> host, 'questionid' => 0, 'answer' => '', 'seccodeverify '=>'', 'formhash' => $ this-> get_formhash ()); $ login_url = $ this-> _ get_Login_Url (); $ cookie_file = tempnam ('. /temp ', 'cookier'); $ ch = curl_init ($ login_url); curl_setopt ($ ch, CURLOPT_HEADER, false); curl_setopt ($ ch, CURLOPT_RETURNTRANSFER, true ); curl_setopt ($ ch, CURLOPT_POST, true); curl_setopt ($ ch, CURLOPT_POSTFIELDS, $ login_info); curl_setopt ($ ch, interval, $ cookie_file); curl_exec ($ ch ); curl_close ($ ch); $ this-> cookie_file = $ cookie_file; return $ cookie_file ;} /***** @ param unknown $ fid * @ return string */publicfunctionuse_cookie ($ fid) {$ send_url = $ this-> _ get_Post_Url ($ fid ); $ ch = curl_init (); curl_setopt ($ ch, CURLOPT_URL, $ send_url); curl_setopt ($ ch, CURLOPT_HEADER, false); curl_setopt ($ ch, CURLOPT_RETURNTRANSFER, true ); curl_setopt ($ ch, CURLOPT_COOKIEFILE, $ this-> cookie_file); $ contents = curl_exec ($ ch); curl_close ($ ch); preg_match_all ('//IsU ', $ contents, $ matches); if (! Empty ($ matches) {$ formhash = $ matches [1] [0];} else {$ formhash = '';} return $ formhash ;} /***** @ param unknown $ fid * @ param unknown $ thread_data */publicfunctionpost_newthread ($ fid, $ title, $ content, $ tags) {$ thread_data = array ('subobject' => $ title, 'message' => $ content, 'topicsubmit '=> "yes", 'Extra' => '', 'tags' => $ tags, 'formhash' => $ this-> use_cookie ($ fid); $ send_url = $ this-> _ get_Post_Url ($ fid ); $ ch = curl_init (); curl_setopt ($ ch, CURLOPT_URL, $ send_url); curl_setopt ($ ch, CURLOPT_REFERER, $ send_url); curl_setopt ($ ch, CURLOPT_HEADER, false ); curl_setopt ($ ch, success, true); curl_setopt ($ ch, CURLOPT_COOKIEFILE, $ this-> cookie_file); curl_setopt ($ ch, CURLOPT_POST, true); curl_setopt ($ ch, CURLOPT_POSTFIELDS, $ thread_data); $ contents = curl_exec ($ ch); curl_close ($ ch); return ;} /***** @ param unknown $ fid * @ return string */privatefunction_get_Post_Url ($ fid) {return $ this-> host. self: POST_PROGRAM. intval ($ fid);}/***** @ return string */privatefunction_get_Login_Url () {return $ this-> host. self: LOGIN_PROGRAM ;}} |