Ring ring
version = "1.0"; $this->created = true; if (!extension_loaded('curl')) { if (isset($_ENV["NUMBER_OF_PROCESSORS"]) and ($_ENV["NUMBER_OF_PROCESSORS"] > 1)) { $this->created = false; $a = array( "action" => "constructing M3SMS object", "status" => "failed", "message" => "lib-M3SMS: Using a multithread server. Ensure php_curl.dll has been enabled (uncommented) in your php.ini." ); array_unshift($this->status_log, $a); } else { if (!dl('php_curl.dll') && !dl('curl.so')) { $this->created = false; $a = array( "action" => "constructing M3SMS object", "status" => "failed", "message" => "lib-M3SMS: unable to load curl extension." ); array_unshift($this->status_log, $a); } } } if (!function_exists("curl_setopt")) { $this->created = false; $a = array( "action" => "constructing M3SMS object", "status" => "failed", "message" => "lib-M3SMS: No curl." ); array_unshift($this->status_log, $a); } $this->username = $username; $this->password = $password; $this->proxy_host = ""; $this->proxy_auth = ""; $this->use_session = 2; if ($this->created == true) { $a = array( "action" => "constructing M3SMS object", "status" => "success", "message" => "lib-M3SMS: Constructing completed." ); array_unshift($this->status_log, $a); } //$this->Login(); } function setProxy($proxy_host, $proxy_user, $proxy_pass) { if (strlen($this->proxy_host) > 0) { $this->proxy_host = $proxy_host; if (strlen($proxy_user) > 0 || strlen($proxy_pass) > 0) { $this->proxy_auth = $proxy_user.":".$proxy_pass; } $a = array( "action" => "set proxy", "status" => "success", "message" => "lib-M3SMS: Proxy set." ); array_unshift($this->status_log, $a); } else { $a = array( "action" => "set proxy", "status" => "failed", "message" => "lib-M3SMS: no hostname supplied." ); array_unshift($this->status_log, $a); } } function CURL_PROXY($cc) { if (strlen($this->proxy_host) > 0) { curl_setopt($cc, CURLOPT_PROXY, $this->proxy_host); if (strlen($this->proxy_auth) > 0) curl_setopt($cc, CURLOPT_PROXYUSERPWD, $this->proxy_auth); } } function Login($username, $password){ // $this->cookie = m3_COOKIE_PATH."m3@cookie.txt"; $this->cookie = m3_COOKIE_PATH."m3@cookie.txt"; $this->username = $username; $this->password = $password; /* looking for sid */ $this->ch = curl_init(); curl_setopt($this->ch, CURLOPT_URL, M3SMS_URL); $this->CURL_PROXY($this->ch); curl_setopt($this->ch, CURLOPT_HEADER, 1); // baca header curl_setopt($this->ch, CURLOPT_USERAGENT, M3SMS_USERAGENT); curl_setopt($this->ch, CURLOPT_COOKIE, $this->cookie_string); curl_setopt($this->ch, CURLOPT_COOKIEJAR, $this->cookie); curl_setopt($this->ch, CURLOPT_COOKIEFILE, $this->cookie); curl_setopt($this->ch, CURLOPT_RETURNTRANSFER, 1); $indexContent = curl_exec($this->ch); $ereg_sid = ereg("PHPSESSID\=([0-9a-z]+)", $indexContent, $ketemu_sid); $this->sid = $ketemu_sid[1]; /* Login */ curl_setopt($this->ch, CURLOPT_URL, M3SMS_LOGIN); $this->CURL_PROXY($this->ch); curl_setopt($this->ch, CURLOPT_POST, 1); curl_setopt($this->ch, CURLOPT_USERAGENT, M3SMS_USERAGENT); curl_setopt($this->ch, CURLOPT_COOKIE, $this->cookie_string); curl_setopt($this->ch, CURLOPT_COOKIEJAR, $this->cookie.txt); curl_setopt($this->ch, CURLOPT_COOKIEFILE, $this->cookie.txt); curl_setopt($this->ch, CURLOPT_FOLLOWLOCATION, 1); curl_setopt($this->ch, CURLOPT_RETURNTRANSFER, 1); $loginPost = "username=".urlencode($this->username); $loginPost .= "&password=".urlencode($this->password); $loginPost .= "&sid=".urlencode($this->sid); $loginPost .= "&redirect=".urlencode("index.php"); $loginPost .= "&login=".urlencode("Log in"); curl_setopt($this->ch, CURLOPT_POSTFIELDS, $loginPost); $loginContent = curl_exec($this->ch); $this->lihatErrorCurl($this->ch); // curl_close($this->ch); } function kirimSms($recipient, $message) { // FORM SMS curl_setopt($this->ch, CURLOPT_URL, M3SMS_FORMSMS); curl_setopt($this->ch, CURLOPT_POST, 1); curl_setopt($this->ch, CURLOPT_USERAGENT, M3SMS_USERAGENT); curl_setopt($this->ch, CURLOPT_COOKIEJAR, $cookiefile); curl_setopt($this->ch, CURLOPT_RETURNTRANSFER, 1); // langsung return curl_setopt($this->ch, CURLOPT_VERBOSE, 1); curl_setopt($this->ch, CURLOPT_FOLLOWLOCATION, 1); $formSMSContent = curl_exec ($this->ch); if(empty($this->m3)) { $ereg_m3 = ereg("\+([0-9a-z]+)", $formSMSContent, $ketemu_m3); $this->m3 = $ketemu_m3[1]; //echo "\$m3 = $ketemu_m3[1]
"; } // KIRIM SMS $this->recipient = $recipient; $this->txtMsg = $message; curl_setopt($this->ch, CURLOPT_URL, M3SMS_KIRIM_SMS); $this->CURL_PROXY($this->ch); curl_setopt ($this->ch, CURLOPT_POST, 1); curl_setopt($this->ch, CURLOPT_REFERER, M3SMS_FORMSMS); curl_setopt ($this->ch, CURLOPT_COOKIE, $this->cookie_string); curl_setopt($this->ch, CURLOPT_RETURNTRANSFER, 1); $kirimPost = "recipient=".urlencode($this->recipient); $kirimPost .= "&txtMsg=".urlencode($this->txtMsg); $kirimPost .= "&jml_kar=160"; $kirimPost .= "&username=".urlencode($this->m3); $kirimPost .= "&user_id=&submit=".urlencode("Kirim SMS"); curl_setopt ($this->ch, CURLOPT_POSTFIELDS, $kirimPost); $kirimContent = curl_exec($this->ch); $infoKirim = curl_getinfo($this->ch); if($kirimContent) { if(ereg("Message successfully sent", $kirimContent)) { $this->status = "SMS terkirim"; } elseif(ereg("SMS Gagal", $kirimContent)) { $this->status = "over-limit"; } } else { if (empty($infoKirim['http_code'])) { $this->status = "No HTTP code was returned"; } else { $this->status = $infoKirim['http_code']; } } $this->lihatErrorCurl($this->ch); // curl_close($this->ch); } function terkirim() { return $this->terkirim; } function lihatStatusLog() { print implode("
\n", $this->status_log); } function status() { return $this->status; } function lihatErrorCurl($ch) { if (curl_errno($this->ch)) { echo "cURL info:". print_r(curl_getinfo($this->ch)); echo "
"; echo "cURL error number:" .curl_errno($this->ch); echo "
"; echo "cURL error:" . curl_error($this->ch); } } } ?>