"\x00", "\xC2\xA3" => "\x01", "\x24" => "\x02", "\xC2\xA5" => "\x03", "\xC3\xA8" => "\x04", "\xC3\xA9" => "\x05", "\xC3\xB9" => "\x06", "\xC3\xAC" => "\x07", "\xC3\xB2" => "\x08", "\xC3\xA7" => "\x09", "\xC3\x87" => "\x09", "\xC3\x98" => "\x0B", "\xC3\xB8" => "\x0C", "\xC3\x85" => "\x0E", "\xC3\xA5" => "\x0F", "\xCE\x94" => "\x10", "\x5F" => "\x11", "\xCE\xA6" => "\x12", "\xCE\x93" => "\x13", "\xCE\x9B" => "\x14", "\xCE\xA9" => "\x15", "\xCE\xA0" => "\x16", "\xCE\xA8" => "\x17", "\xCE\xA3" => "\x18", "\xCE\x98" => "\x19", "\xCE\x9E" => "\x1A", "\xC2\xA0" => "\x1B", "\x0C" => "\x1B\x0A", "\x5E" => "\x1B\x14", "\x7B" => "\x1B\x28", "\x7D" => "\x1B\x29", "\x5C" => "\x1B\x2F", "\x5B" => "\x1B\x3C", "\x7E" => "\x1B\x3D", "\x5D" => "\x1B\x3E", "\x7C" => "\x1B\x40", "\xE2\x82\xAC" => "\x1B\x65", "\xC3\x86" => "\x1C", "\xC3\xA6" => "\x1D", "\xC3\x9F" => "\x1E", "\xC3\x89" => "\x1F", "\xC2\xA4" => "\x24", "\xC2\xA1" => "\x40", "\xCE\x91" => "\x41", "\xCE\x92" => "\x42", "\xCE\x95" => "\x45", "\xCE\x97" => "\x48", "\xCE\x99" => "\x49", "\xCE\x9A" => "\x4B", "\xCE\x9C" => "\x4D", "\xCE\x9D" => "\x4E", "\xCE\x9F" => "\x4F", "\xCE\xA1" => "\x50", "\xCE\xA4" => "\x54", "\xCE\xA5" => "\x55", "\xCE\xA7" => "\x58", "\xCE\x96" => "\x5A", "\xC3\x84" => "\x5B", "\xC3\x96" => "\x5C", "\xC3\x91" => "\x5D", "\xC3\x9C" => "\x5E", "\xC2\xA7" => "\x5F", "\xC2\xBF" => "\x60", "\xC3\xA4" => "\x7B", "\xC3\xB6" => "\x7C", "\xC3\xB1" => "\x7D", "\xC3\xBC" => "\x7E", "\xC3\xA0" => "\x7F"); define("SUCCESSFULL", 0); define("FAILED", 1); define("NOT_LOGGED_IN", 2); define("NOT_REGISTERED", 3); define("LOCKED", 4); define("UNKNOWN_RESPONSE", 5); define("ERROR", 6); $login_prefixes = array( "mtn" => array( "072", "073", "074", "076", "078", "082", "083", "084" ), "voda" => array( "072", "076", "082" ) ); $to_prefixes = array( "mtn" => array( "073", "083" ), "voda" => array( "072", "076", "082" ) ); $providers = array( "mtn" => "MyMTN", "voda" => "Vodacom4me" ); $max_lengths = array( "mtn" => 144, "voda" => 431 ); $max_recipients = array( "mtn" => 1, "voda" => 20 ); if ( $_SERVER['SERVER_PORT'] == 443 ) ini_set( 'session.cookie_secure', true ); if ( strpos( $_SERVER['REQUEST_URI'], $_SERVER['PHP_SELF'] ) !== FALSE ) $self = $_SERVER['PHP_SELF']; else $self = str_replace( '.php', '', $_SERVER['PHP_SELF'] ); if ( basename($self) == 'vsms.php' ) $provider = 'voda'; elseif ( basename($self) == 'msms.php' ) $provider = 'mtn'; elseif ( isset($_REQUEST['provider']) ) $provider = $_REQUEST['provider']; $Provider = $providers[$provider]; $error_message = array( NOT_LOGGED_IN => "Not logged into $Provider.", NOT_REGISTERED => "You are not registered with $Provider", LOCKED => "Your $Provider account is locked.", UNKNOWN_RESPONSE => "Unknown response from $Provider", ERROR => "Network error." ); $login = $provider ."_login"; $logout = $provider . "_logout"; $getinfo = $provider . "_getinfo"; $sms = $provider . "_sms"; session_start(); header('Content-type: application/xhtml+xml; charset=utf-8'); $useragent = 'Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1)'; function voda_login( $username, $password ) { global $useragent; if ($GLOBALS['debug']) error_log($GLOBALS['debug'].'Logging into Vodacom4me'); $http = new HttpRequest( 'https://www.vodacom4me.co.za/vodacom4me-personal/login.do', HTTP_METH_POST, array('useragent' => $useragent) ); $http->enableCookies(); $http->setPostFields( array( 'V_LOGIN_NAME' => $username, 'V_PASSWORD' => $password ) ); try { $http->send(); if ( $http->getResponseCode() !== 200 ) { if ($GLOBALS['debug']) error_log($GLOBALS['debug'].'Didn\'t receive HTTP 200'); return UNKNOWN_RESPONSE; } elseif ( strpos( $http->getResponseBody(), 'var framesetTemplate =' ) === FALSE ) { if ( preg_match( '/(?<=

).*(?=<\/p>)/sU', $http->getResponseBody(), $matches ) ) { if ( strpos( $matches[0], 'Login Failed. The username or password that you have entered is invalid' ) !== FALSE ) { return FAILED; } } return UNKNOWN_RESPONSE; } else { $something = $http->getResponseCookies(); $_SESSION['voda']['session'] = $something[0]->cookies['V4MESESSION']; } } catch ( HttpInvalidParamException $e ) { return ERROR; echo $e; } } function voda_sms( $to, $message ) { global $useragent; $http = new HttpRequest( 'https://www.vodacom4me.co.za/vodacom4me-personal/sendSMS.do?operation=init&send=yes', HTTP_METH_POST, array('useragent' => $useragent, 'redirect' => 0) ); $http->addCookies( array('V4MESESSION' => $_SESSION['voda']['session']) ); $http->setPostFields( array( 'message.recipient' => $to, 'message.message' => $message, 'SendSMSButton' => 'Send SMS', 'picture' => 'null.gif', 'Quicklist' => '', 'charsLeft' => (431 - strlen($message)), 'numOfMsg' => (ceil(strlen($message)/143)) ) ); try { $http->send(); $http->getResponseMessage(); if ( $http->getResponseCode() == 302 and $redirect ) { return NOT_LOGGED_IN; } elseif ( $http->getResponseCode() !== 200 ) { return UNKNOWN_RESPONSE; } elseif ( strpos( $http->getResponseBody(), 'will be sent to' ) !== FALSE && strpos( $http->getResponseBody(), 'shortly' ) !== FALSE ) { $_SESSION['voda']['smss'] -= ceil(strlen($message)/143); return; } else { return UNKNOWN_RESPONSE; } } catch ( HttpInvalidParamException $e ) { return ERROR; } } function voda_logout() { global $useragent; $http = new HttpRequest( 'https://www.vodacom4me.co.za/vodacom4me-personal/logout.do', HTTP_METH_GET, array( 'useragent' => $useragent ) ); $http->addCookies( array('V4MESESSION' => $_SESSION['voda']['session']) ); try { $http->send(); if ( $http->getResponseCode() == 200 ) return; else return UNKNOWN_RESPONSE; } catch ( HttpInvalidParamException $e ) { return ERROR; } } function voda_getinfo() { global $useragent; $http = new HttpRequest( 'https://www.vodacom4me.co.za/vodacom4me-personal/sendSMS.do?operation=init', HTTP_METH_GET, array('useragent' => $useragent) ); $http->addCookies( array('V4MESESSION' => $_SESSION['voda']['session']) ); try { $http->send(); if ( $http->getResponseCode() !== 200 ) { return UNKNOWN_RESPONSE; } else { if ( preg_match( '/(?<=SMS - You have )\d*(?= SMS left)/', $http->getResponseBody(), $match ) ) { $_SESSION['voda']['smss'] = (int) $match[0]; } if ( preg_match_all( '/(?<=

'; if ( isset($error) ) echo '

' . $error .'

'; if ( isset($sent) ) : echo '

' . $sent . '
' . $_SESSION[$provider]['smss'] . ' SMS\'s left
Send SMS
Logout

'; elseif ( isset($loggedout) ) : echo '

' . $loggedout . '
Log in

'; elseif ( !isset($_SESSION[$provider]['session']) ) : ?>




Register Retrieve Password Register (from PC)




SMS's left characters left Logout