Script SMS GRATIS IM3
Ini file lib-nya dulu:

<?php
/**
* M3SMSlib.php
* modified Desember 2008 By. dewa
**/

define("M3SMS_USERAGENT", "Mozilla/4.0 (compatible; MSIE 5.01; Windows NT 5.0)");
define("M3SMS_URL", "http://www.m3-access.com/index.php");
define("M3SMS_LOGIN", "http://www.m3-access.com/xt_login.php");
define("M3SMS_REDIRECT", "sms/send_sms.php");
define("M3SMS_FORMSMS", "http://www.m3-access.com/sms/send_sms.php");
define("M3SMS_KIRIM_SMS", "http://www.m3-access.com/sms/xt_send_sms.php");
define("M3SMS_LOGOUT", "http://www.m3-access.com/account/logout.php");

define("m3_COOKIE_PATH", "./");

class M3SMS {
var $username;
var $password;
var $m3;

var $version;
var $created;
var $cookie_string;
var $cookie;
var $proxy_host;
var $proxy_auth;
var $sid;
var $is_login;
var $sent;
var $ch; // curl handle
var $status_log = array();
var $status;

function M3SMS() {
$this->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->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("<span class\=\"genmed\">\+([0-9a-z]+)", $formSMSContent, $ketemu_m3);
$this->m3 = $ketemu_m3[1];
//echo "\$m3 = $ketemu_m3[1]<br />";
}
// KIRIM SMS
$this->recipient = $recipient;
$this->message = $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 .= "&message=".urlencode($this->message);
$kirimPost .= "&jml_kar=125";
$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("masuk antrian", $kirimContent)) { $this->status = "terkirim"; }
elseif(ereg("Wah, sms hari ini dah 10 sms nih", $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("<br>\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 "<br>";
echo "cURL error number:" .curl_errno($this->ch);
echo "<br>";
echo "cURL error:" . curl_error($this->ch);
}
}
}
?>

Save file: m3smslib.php

Untuk Script buat login ke m3-access dan buat kirim sms :
<?php
include("m3smslib.php");
$username = "username m3-access elo";
$password = "password m3-access elo";

echo "
<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Transitional//EN\" \"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd\">
<html xmlns=\"http://www.w3.org/1999/xhtml\" xml:lang=\"id\" lang=\"id\">
<head>
<title>Free IM3 SMS</title>
<script type=\"text/javascript\">
function focusit() {
document.getElementById('recipient').focus();
}
window.onload = focusit;

var digits = \"0123456789\";

var phoneNumberDelimiters = \"\";

var validWorldPhoneChars = phoneNumberDelimiters + \"\";

var minDigitsInIPhoneNumber = 10;


function textCounter(field,cntfield,maxlimit) {
if (field.value.length > maxlimit) // if too long...trim it!
field.value = field.value.substring(0, maxlimit);
// otherwise, update 'characters left' counter
else
cntfield.value = maxlimit - field.value.length;
}


function isInteger(s)
{ var i;
for (i = 0; i < s.length; i++)
{
// Check that current character is number.
var c = s.charAt(i);
if (((c < \"0\") || (c > \"9\"))) return false;
}
// All characters are numbers.
return true;
}

function awal(s)
{ var i;
var x=\"\";
for (i = 0; i < 2; i++)
{
// Check that current character is number.
var c = s.charAt(i);
if ((c==\"0\") || (c==\"+\")) return false;
x=x+c
}
//if (x !=\"628\") return false;

return true;
}

function stripCharsInBag(s, bag)
{ var i;
var returnString = \"\";
// Search through string's characters one by one.
// If character is not in bag, append to returnString.
for (i = 0; i < s.length; i++)
{
// Check that current character isn't whitespace.
var c = s.charAt(i);
if (bag.indexOf(c) == -1) returnString += c;
}
return returnString;
}

function checkInternationalPhone(strPhone){
s=stripCharsInBag(strPhone,validWorldPhoneChars);
return (isInteger(s) && awal(s) && s.length >= minDigitsInIPhoneNumber);
}

function ValidateForm(){
var Phone=document.smsform.recipient
var Msg=document.smsform.message

if ((Phone.value==null)||(Phone.value==\"\")){
alert(\"Masukkan no.HP-nya \")
Phone.focus()
Phone.value=\"628\"
return false
}
if (checkInternationalPhone(Phone.value)==false){
alert(\"Format nomor salah atau tidak lengkap\\nPake format internasional 628xxxxx\")
Phone.value=\"\"
Phone.focus()
Phone.value=\"628\"
return false
}
if ((Msg.value==null)||(Msg.value==\"\")){
alert(\"Lho, kok isi smsnya blank?\")
Msg.focus()
return false
}
return true
}
</script>
</head>
<body>
";

if($_POST['message'] && $_POST['recipient']) {
$m3 = new m3sms();
$m3->Login($username, $password);
$m3->kirimSms($_POST['recipient'], $_POST['message']);
echo "
<div id=\"smsform\"><h1><span class=\"hide\">Laporan</span></h1>
<fieldset>
<legend class=\"legend\">Laporan</legend>
<p>
<label>SMS dari:</label><br />
<input class=\"input\" readonly type=\"text\" size=\"20\" id=\"recipient\" name=\"recipient\" value=\"".$m3->m3."\"><br />
</p>
<p>
<label>ke:</label><br />
<input class=\"input\" readonly type=\"text\" size=\"20\" id=\"recipient\" name=\"recipient\" value=\"".$_POST['recipient']."\"><br />
</p>
<p>
<label>Status:</label><br />
<input class=\"input\" readonly type=\"text\" size=\"20\" id=\"status\" name=\"status\" value=\"".$m3->status()."\"><br />
</p>
<p>
<ul>
<li><a class=\"linkback\" href=\"".$_SERVER['PHP_SELF']."\">« Kirim SMS Kembali</a></li>
<li>By. dewa(adminscript@yahoo.com)</a></li>
</ul>
</p>
</fieldset>
</div>";
}
else {
echo "
<div id=\"berita\">SMS GRATIS (c)2008
</div>
<div id=\"smsform\"><h1><span class=\"hide\">SMS GRATIS</span></h1>
<form method=\"post\" name=\"smsform\" id=\"smsform\" onSubmit=\"return ValidateForm()\">
<fieldset>
<legend class=\"legend\">SMS Gratis IM3</legend>
<p>
<label>Kirim : </label><br />
<input class=\"input\" type=\"text\" size=\"20\" id=\"recipient\" name=\"recipient\" value=\"628\" tabindex=\"10\"><br />
</p>
<p>
<label>Teks SMS:</label><br />
<textarea class=\"textarea\" name=\"message\" id=\"message\" cols=\"30\" rows=\"3\" wrap=\"physical\" onKeyDown=\"textCounter(document.smsform.message,d ocument.smsform.remainchars,120)\" onKeyUp=\"textCounter(document.smsform.message,doc ument.smsform.remainchars,120)\" tabindex=\"20\"></textarea><br />
</p>
<p>
<input readonly type=\"text\" name=\"remainchars\" size=\"3\" maxlength=\"3\" value=\"120\"> characters left
</p>
<p class=\"submit\">
<input type=\"submit\" name=\"Submit\" value=\"Kirim\" class=\"submit\"><br />
</p>
<p>
<ul>
<li>By. dewa(adminscript@yahoo.com)</a></li>
</ul>
</p>
</fieldset>
</form>
</div>
";
}

echo "
</body>
</html> ";
?>

Skrip ini 100% jalan, tested by me.


XtGem Forum catalog