-
-
Save VictorFursa/16b077aaaf004dedead2 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?php | |
| header("Content-Type: text/html; charset=utf-8"); | |
| class Curl{ | |
| private $agent = 'Mozilla/4.0 (compatible; MSIE 5.01; Windows NT 5.0)'; | |
| private $curl; | |
| function __construct($login_url){ | |
| $this->curl = curl_init($login_url); | |
| curl_setopt($this->curl, CURLOPT_URL,$login_url); //указываем адрес страницы | |
| curl_setopt($this->curl, CURLOPT_USERAGENT, $this->agent); //указываем заголовок User-Agent | |
| curl_setopt($this->curl, CURLOPT_FOLLOWLOCATION, 1); //указываем, что cURL должен переходить по редиректам | |
| curl_setopt($this->curl, CURLOPT_REFERER, $login_url);//т.е. нужно указать адрес страницы на которой находится форма | |
| curl_setopt($this->curl, CURLOPT_REFERER, $login_url); //указываем, что мы отправляем данные методом post | |
| curl_setopt($this->curl, CURLOPT_POST, 1); //добавляем строку с post данными | |
| $cookiefile = tempnam('/var/www/alcoholic.com/', $_SERVER['DOCUMENT_ROOT'].'/cookies.txt'); | |
| curl_setopt(curl_init(), CURLOPT_COOKIEFILE, $cookiefile); | |
| curl_setopt(curl_init(), CURLOPT_COOKIEJAR, $cookiefile); | |
| } | |
| function setRefer($refer){ | |
| return curl_setopt($this->curl, CURLOPT_REFERER, $refer); | |
| } | |
| function close(){ | |
| curl_close($this->curl); //завершает сеанас | |
| } | |
| function sendPostForm($Data){ | |
| return curl_setopt($this->curl, CURLOPT_POSTFIELDS, http_build_query($Data)); | |
| } | |
| function exec(){ | |
| return curl_exec($this->curl); | |
| } | |
| function setReturnTransfer($value){ | |
| curl_setopt($this->curl,CURLOPT_RETURNTRANSFER,$value); | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment