-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcurl.class
More file actions
64 lines (48 loc) · 1.56 KB
/
Copy pathcurl.class
File metadata and controls
64 lines (48 loc) · 1.56 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
<?php
class Curl {
public $Result;
public $Vars = '';
public $TempFile;
public $RequestType;
public $URL;
public $Handle;
public function __construct($request_type='POST') {
$this->Handle = curl_init();
$this->RequestType = $request_type;
if ($request_type == 'POST')
curl_setopt($this->Handle, CURLOPT_POST, 1);
curl_setopt($this->Handle, CURLOPT_RETURNTRANSFER, 1);
}
public function CreateCookie() {
$this->TempFile = tempnam("/tmp", "CurlCookie");
curl_setopt($this->Handle, CURLOPT_COOKIEJAR, $this->TempFile);
}
public function UseCookie($filename) {
curl_setopt($this->Handle, CURLOPT_COOKIEFILE, $filename);
}
public function Seturl($url) {
$this->URL = $url;
curl_setopt($this->Handle, CURLOPT_URL, $url);
}
public function AddVar($key, $value) {
$this->Vars .= $key . "=" . urlencode($value) . "&";
}
public function AddVars($arr) {
foreach ($arr as $key => $value) {
$this->AddVar($key, $value);
}
}
public function Execute() {
$this->Vars = substr($this->Vars, 0, -1);
if ($this->RequestType == 'POST') {
curl_setopt($this->Handle, CURLOPT_POSTFIELDS, $this->Vars);
} else {
$this->URL = $this->URL . '?' . $this->Vars;
curl_setopt($this->Handle, CURLOPT_URL, $this->URL);
}
$this->Result = curl_exec($this->Handle);
curl_close($this->Handle);
return $this->Result;
}
}
?>