/* Simulation Resource Push class 2012-09-14 by Pooy */ Class tuisongpost{ Using Construction login Authentication function Tuisongpost () { Files that store cookies Global $cookie _jar; $this->cookie_jar = Tempnam ('./tmp ', ' Cookie '); $url = "http://www. your address"; $post _data = Array ("username" = "admin", "password" and "admin"); $ch = Curl_init (); curl_setopt ($ch, Curlopt_url, $url); curl_setopt ($ch, Curlopt_post, 1); curl_setopt ($ch, Curlopt_header, 1); curl_setopt ($ch, Curlopt_returntransfer, 0); curl_setopt ($ch, Curlopt_postfields, $post _data); curl_setopt ($ch, Curlopt_cookiejar, $this->cookie_jar); Save Cookie Information $output 1 = curl_exec ($ch); Curl_close ($ch); echo $this->cookie_jar. " n "; } /* Get Group id*/ function Getgid ($groupname, $channel, $lanmu) { $url = "Http://XXXX.com/creategroup"; Format the data to be pushed $data = $this->getgidarr ($groupname, $channel, $LANMU); $ch = Curl_init (); $Ref _url = "http://www. your address"; curl_setopt ($ch, Curlopt_url, $url); curl_setopt ($ch, Curlopt_referer, $Ref _url); Camouflage Referer curl_setopt ($ch, Curlopt_post, 1); Post mode submit data curl_setopt ($ch, Curlopt_returntransfer, 1); Return data instead of direct output curl_setopt ($ch, Curlopt_header, 0); Set whether to show header information 0 is not displayed, 1 is display default is 0 curl_setopt ($ch, Curlopt_cookiefile, $this->cookie_jar); Send Cookie File curl_setopt ($ch, Curlopt_postfields, $data); Send post data $output 2 = curl_exec ($ch); Send HTTP request This return value is used as a basis for judgment. return $output 2; Curl_close ($ch); $this->unlink ($this->cookie_jar); } Push data function Sendpic ($note, $groupid, $groupindex, $img) { $url = "Http://XXXX/addimage"; $groupid = Intval ($groupid); $data = $this->sendpicarr ($note, $groupid, $groupindex, $img); $ch = Curl_init (); $Ref _url = "http://www. your address"; curl_setopt ($ch, Curlopt_url, $url); curl_setopt ($ch, Curlopt_referer, $Ref _url); Camouflage Referer curl_setopt ($ch, Curlopt_post, 1); Post mode submit data curl_setopt ($ch, Curlopt_returntransfer, 1); Return data instead of direct output curl_setopt ($ch, Curlopt_header, 0); Set whether to show header information 0 is not displayed, 1 is display default is 0 curl_setopt ($ch, Curlopt_cookiefile, $this->cookie_jar); Send Cookie File curl_setopt ($ch, Curlopt_postfields, $data); Send post data $output 2 = curl_exec ($ch); Send HTTP request return $output 2; Curl_close ($ch); $this->unlink ($this->cookie_jar); } /* Push Data operation */ function Sendmes ($url, $img, $imgdesc, $groupid, $groupname, $channel, $LANMU) { Var_dump ($this->cookie_jar); Exit (); $url = "Http://XXXX/add"; $data = $this->getarr ($img, $imgdesc, $groupid, $groupname, $channel, $LANMU); $ch = Curl_init (); $Ref _url = "http://www. your address"; curl_setopt ($ch, Curlopt_url, $url); curl_setopt ($ch, Curlopt_referer, $Ref _url); Camouflage Referer curl_setopt ($ch, Curlopt_post, 1); Post mode submit data curl_setopt ($ch, Curlopt_returntransfer, 1); Return data instead of direct output curl_setopt ($ch, Curlopt_header, 0); Set whether to show header information 0 is not displayed, 1 is display default is 0 curl_setopt ($ch, Curlopt_cookiefile, $this->cookie_jar); Send Cookie File curl_setopt ($ch, Curlopt_postfields, $data); Send post data $output 2 = curl_exec ($ch); Send HTTP request Curl_close ($ch); $this->unlink ($this->cookie_jar); } function Getarr ($img, $imgdesc, $groupid, $groupname, $channel, $LANMU) { $post _data = Array ( Windows uses the following notation, Linux does not apply "img" = "@". $img. "; Type=image/jpeg ", "img" = "@". $img, "Imgdesc" = $imgdesc, "GroupID" = $groupid, "GroupName" = $groupname, "Channel" = $channel, "Lanmu" = $lanmu, "CDate" =>date (' y-m-d ') ); return $post _data; } Formatting Getgidarr function Getgidarr ($groupname, $channel, $LANMU) { $post _data = Array ( "GroupName" = $groupname, "Channel" = $channel, "Lanmu" = $lanmu, "CDate" =>date (' y-m-d ') ); return $post _data; } Formatting Sendpicarr function Sendpicarr ($note, $groupid, $groupindex, $img) { $post _data = Array ( "Notes" = $note, "id" = $groupid, "Index" = $groupindex, "CDate" =>date (' y-m-d '), Windows uses the following notation, Linux does not apply "img" = "@". $img. "; Type=image/jpeg ", "img" = "@". $img ); return $post _data; } Clean up Cookie Files Function unlink ($cookie _jar) { Unlink ($cookie _jar); } } |