Posted by Vince Morgan on 04/19/07 13:15
"Henk Oegema" <henk@oegema.com> wrote in message
news:vIGVh.128805$z84.945241@phobos.telenet-ops.be...
> Dear forum.
>
> I'm trying to get a (test) script working which would log me in to
> VoipBuster and then send a SMS to my mobile phone.
> When it is working this script will be used in my Asterisk PBX to send
> automatically a SMS message, with the message that telephone number xxxxxx
> has called me.
> This function is discussed in forum
> http://forum.asteriskportal.nl/index.php?topic=288.msg1772#msg1772
> (unfortunately (for this forum) in the Dutch language)
>
> To test the script I put in a browser the following address:
> http://localhost/sms/sms.php?number=00324763788xx&msg=This is a test
>
>
> File /srv/www/htdocs/sms/sms.php (SuSE10.2):
> =================================
>
> <?php
>
> function encryptString($string)
> {
> for ($i=0;$i<strlen($string);$i++)
> {
> $chr = $string{$i};
> if ($chr == "0")
> {
> $chr = "5";
> $string{$i} = $chr;
> }
> elseif ($chr == "1")
> {
> $chr = "6";
> $string{$i} = $chr;
> }
> elseif ($chr == "2")
> {
> $chr = "7";
> $string{$i} = $chr;
> }
> elseif ($chr == "3")
> {
> $chr = "8";
> $string{$i} = $chr;
> }
> elseif ($chr == "4")
> {
> $chr = "9";
> $string{$i} = $chr;
> }
> elseif ($chr == "5")
> {
> $chr = "0";
> $string{$i} = $chr;
> }
> elseif ($chr == "6")
> {
> $chr = "1";
> $string{$i} = $chr;
> }
> elseif ($chr == "7")
> {
> $chr = "2";
> $string{$i} = $chr;
> }
> elseif ($chr == "8")
> {
> $chr = "3";
> $string{$i} = $chr;
> }
> elseif ($chr == "9")
> {
> $chr = "4";
> $string{$i} = $chr;
> }
> }
> return str_rot13($string);
> }
>
> // Set username and password
You could reduce the if; elseif block to the following.
$string[$i] = $string[$i]< 5 ? $string[$i]+=5 : ($string[$i]+=5)-10;
That's if, as Jeff has already enquired, $string{$i} should be $string[$i].
HTH
Vince
Navigation:
[Reply to this message]
|