Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function getInfo()
- {
- $num = func_num_args();
- if (($num >= 1) AND ($num <= 2))
- {
- $ch = curl_init();
- curl_setopt($ch, CURLOPT_URL, func_get_arg(0));
- curl_setopt($ch, CURLOPT_FAILONERROR, true);
- curl_setopt($ch, CURLOPT_USERAGENT, "Mozilla/5.0 (Windows NT 5.1; rv:20.0) Gecko/20100101 Firefox/20.0");
- curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
- curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false);
- curl_setopt($ch, CURLOPT_FOLLOWLOCATION, false);
- curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
- curl_setopt($ch, CURLOPT_TIMEOUT, 1);
- if ($num == 2)
- {
- if (is_array(func_get_arg(1)))
- {
- $array = array();
- foreach (func_get_arg(1) as $key => $val)
- {
- $array[] = $key."=".$val;
- }
- $postdata = implode("&", $array);
- curl_setopt($ch, CURLOPT_POST, true);
- curl_setopt($ch, CURLOPT_POSTFIELDS, $postdata);
- }
- else
- {
- throw new Exception("2-ой аргумент не является массивом.");
- }
- }
- $data = curl_exec($ch);
- $info = curl_getinfo($ch);
- $info['data'] = $data;
- curl_close($ch);
- return $info;
- }
- else
- {
- throw new Exception("Не верное количество аргументов.");
- }
- }
- /*example*/
- try
- {
- $array = array(
- "username" => "test",
- "password" => "test",
- "thisPage" => "pispWhois",
- "domain_name" => "example.com");
- echo "<pre>";
- print_r(getInfo("https://www.webnames.ru:81/RegTimeSRS.pl", $array));
- echo "</pre>";
- }
- catch(Exception $e)
- {
- echo $e -> getMessage();
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement