Voipbuster script.

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#m sg1772
(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

$username = encryptString('henkoegema');
$password = encryptString('my_voipbuster_password');

$URL =
('https://myaccount.voipbuster.com/clx/index.php?part=plogin &username=' .
$username . '&password=' . $password);

// Get number and message
$number =($_GET['number']);
$msg =($_GET['msg']);

// INIT CURL
$ch = curl_init();

// SET URL FOR THE POST FORM LOGIN
curl_setopt($ch, CURLOPT_URL, $URL);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 0);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);

// SET POST PARAMETERS : FORM VALUES FOR EACH FIELD

// IMITATE CLASSIC BROWSER'S BEHAVIOUR : HANDLE COOKIES
curl_setopt ($ch, CURLOPT_COOKIEJAR, '/tmp/cookie.txt');

# Setting CURLOPT_RETURNTRANSFER variable to 1 will force cURL
# not to print out the results of its query.
# Instead, it will return the results as a string return value
# from curl_exec() instead of the usual true/false.
curl_setopt ($ch, CURLOPT_RETURNTRANSFER, 1);

// EXECUTE 1st REQUEST (FORM LOGIN)
$store = curl_exec ($ch);

// SET Message
curl_setopt($ch,
CURLOPT_URL, 'https://myaccount.voipbuster.com/clx/websms.php');

// ENABLE HTTP POST
curl_setopt ($ch, CURLOPT_POST, 1);


// SET POST PARAMETERS : FORM VALUES FOR EACH FIELD
curl_setopt ($ch, CURLOPT_POSTFIELDS, 'message=' .
$msg . '&bnrphonenumber=' . $number . '&submit=Send&action=send');

// EXECUTE 2nd REQUEST (Send Message)
$content = curl_exec ($ch);

// CLOSE CURL
curl_close ($ch);

//debug
//print $content;

?>

===================================end sms.php =========================

This script works with other people.

With me, the script seems to stop at the line:
// INIT CURL
$ch = curl_init();

When I add the line
print("this is a test line");

//INIT CURL
print("this is a testline");
$ch=curl_init();

than I get output of the print statement


If I move the line as follows (or lower in the file):

//INIT CURL
$ch=curl_init();
print("this is a test line");

then I get NO print output

I'm using php version 5.2.0-10
Other people (were the scripts works) use php version 4.3.2
Could this be the reason that I can't get it working?

Or is there any mistake in my script ?

Gr. Henk
Henk Oegema [ Do, 19 April 2007 11:34 ] [ ID #1692438 ]

Re: Voipbuster script.

<posted & mailed>
Henk Oegema wrote:
> Or is there any mistake in my script ?
>
> Gr. Henk

During my struggle with this problem, I tested following script:
(http://be.php.net/curl)


<?php

$ch = curl_init("http://www.example.com/");
$fp = fopen("example_homepage.txt", "w");

curl_setopt($ch, CURLOPT_FILE, $fp);
curl_setopt($ch, CURLOPT_HEADER, 0);

curl_exec($ch);
curl_close($ch);
fclose($fp);
?>

Here I get the same problem that the script also stops at:
$ch = curl_init("http://www.example.com/");
(just as in my previous script)

There is no error message.

Could it be that a package is missing??

Henk
Henk Oegema [ Do, 19 April 2007 13:27 ] [ ID #1692439 ]

Re: Voipbuster script.

On Thu, 19 Apr 2007 09:34:19 GMT, in alt.php Henk Oegema
<henk [at] oegema.com>
<vIGVh.128805$z84.945241 [at] phobos.telenet-ops.be> wrote:

>| 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#m sg1772
>| (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;
>| }

Shouldn't that be $string[$i] ???

Could be simplified

for ($i=0;$i<strlen($string);$i++)
{
$chr = $string{$i};
switch($chr)
{
case "0" : $string[$i] = "5"; break;
case "1" : $string[$i] = "6"; break;
case "2" : $string[$i] = "7"; break;
case "3" : $string[$i] = "8"; break;
case "4" : $string[$i] = "9"; break;
case "5" : $string[$i] = "0"; break;
case "6" : $string[$i] = "1"; break;
case "7" : $string[$i] = "2"; break;
case "8" : $string[$i] = "3"; break;
case "9" : $string[$i] = "4"; break;
}
}


[snip 2 end]
------------------------------------------------------------ ---
jnorthau [at] yourpantsyahoo.com.au : Remove your pants to reply
------------------------------------------------------------ ---
Jeff North [ Do, 19 April 2007 13:56 ] [ ID #1692440 ]

Re: Voipbuster script.

"Henk Oegema" <henk [at] oegema.com> wrote in message
news:vIGVh.128805$z84.945241 [at] 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#m sg1772
> (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
Vince Morgan [ Do, 19 April 2007 15:15 ] [ ID #1692441 ]

Re: Voipbuster script.

"Vince Morgan" <vinhar [at] REMOVEoptusnet.com.au> wrote in message
news:46276af7$0$16552$afc38c87 [at] news.optusnet.com.au...
> 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
>
>

Ooops, I forgot you are dealing with chars rather than integers.

$string[$i] = $string[$i]< "5" ? $string[$i]+=5 : ($string[$i]+=5)-10;

Vince
Vince Morgan [ Do, 19 April 2007 15:37 ] [ ID #1692442 ]

Re: Voipbuster script.

Vince Morgan wrote:

>
> "Vince Morgan" <vinhar [at] REMOVEoptusnet.com.au> wrote in message
> news:46276af7$0$16552$afc38c87 [at] news.optusnet.com.au...
>> 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
>>
>>
>
> Ooops, I forgot you are dealing with chars rather than integers.
>
> $string[$i] = $string[$i]< "5" ? $string[$i]+=5 : ($string[$i]+=5)-10;
>
> Vince

Thanks for your (and Jeff's) input so far.

I'm already changing the script.

However the script(s) still stops at the indicated place ($ch=curl_int();)

Henk
Henk Oegema [ Do, 19 April 2007 16:01 ] [ ID #1692443 ]

Re: Voipbuster script.

"Henk Oegema" <henk [at] oegema.com> wrote in message
news:XCKVh.129145$VW7.855089 [at] phobos.telenet-ops.be...
> Vince Morgan wrote:
>
> >
> > "Vince Morgan" <vinhar [at] REMOVEoptusnet.com.au> wrote in message
> > news:46276af7$0$16552$afc38c87 [at] news.optusnet.com.au...

> However the script(s) still stops at the indicated place ($ch=curl_int();)
>
> Henk
>
>
Shouldn't that be, $ch=curl_intit() Henk;
Gotto go to bed now, good luck ;)
Vince
Vince Morgan [ Do, 19 April 2007 16:15 ] [ ID #1692444 ]

Re: Voipbuster script.

Vince Morgan wrote:

>
> "Henk Oegema" <henk [at] oegema.com> wrote in message
> news:XCKVh.129145$VW7.855089 [at] phobos.telenet-ops.be...
>> Vince Morgan wrote:
>>
>> >
>> > "Vince Morgan" <vinhar [at] REMOVEoptusnet.com.au> wrote in message
>> > news:46276af7$0$16552$afc38c87 [at] news.optusnet.com.au...
>
>> However the script(s) still stops at the indicated place
>> ($ch=curl_int();)
>>
>> Henk
>>
>>
> Shouldn't that be, $ch=curl_intit() Henk;
sorry, typo error $ch=curl_init()
> Gotto go to bed now, good luck ;)
Good night.
(where are you living?
The sun still shines here in Belgium)
> Vince
Henk Oegema [ Do, 19 April 2007 17:05 ] [ ID #1692445 ]

Re: Voipbuster script.

"Henk Oegema" <henk [at] oegema.com> wrote in message
news:1zLVh.129219$DG4.963640 [at] phobos.telenet-ops.be...
> > Gotto go to bed now, good luck ;)
> Good night.
> (where are you living?
> The sun still shines here in Belgium)
> > Vince
>
I'm sorry Henk, I'm in Australia, and it was getting very late here and my
head was disintergrating,
Vince
Vince Morgan [ Fr, 20 April 2007 02:07 ] [ ID #1693621 ]

Re: Voipbuster script.

"Henk Oegema" <henk [at] oegema.com> wrote in message
news:BmIVh.128959$_G6.715806 [at] phobos.telenet-ops.be...
> <posted & mailed>
> Henk Oegema wrote:
> > Or is there any mistake in my script ?
> >
> > Gr. Henk
>
> During my struggle with this problem, I tested following script:
> (http://be.php.net/curl)
> Could it be that a package is missing??

I'm new to php Henk, but reading the contents of the following link,
http://be.php.net/curl, suggests you may not have it supported in your
package.
curl_init() is an undefined function in mine.
Apparently the "libcurl" package is required, amongst other things.
I would be looking at this before I went too much further.
Regards,
Vince
Vince Morgan [ Fr, 20 April 2007 02:48 ] [ ID #1693622 ]

Re: Voipbuster script.

"Henk Oegema" <henk [at] oegema.com> wrote in message
news:vIGVh.128805$z84.945241 [at] phobos.telenet-ops.be...

> 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);
> }
>

I see a bit of a problem here too Henk. str_rot13() shifts only
alphanumeric characters. Which would mean it will do nothing to the members
of your array.
If the forum you mentioned wasn't in Dutch I'd go and have a look, but my
Dutch is 2 * Dutch.
Vince
Vince Morgan [ Fr, 20 April 2007 19:48 ] [ ID #1693633 ]

Re: Voipbuster script.

"Vince Morgan" <vinhar [at] REMOVEoptusnet.com.au> wrote in message
news:4628fc9e$0$9775$afc38c87 [at] news.optusnet.com.au...
>
> "Henk Oegema" <henk [at] oegema.com> wrote in message
> news:vIGVh.128805$z84.945241 [at] phobos.telenet-ops.be...
>
> > 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);
> > }
> >
>
> I see a bit of a problem here too Henk. str_rot13() shifts only
> alphanumeric characters. Which would mean it will do nothing to the
members
> of your array.
> If the forum you mentioned wasn't in Dutch I'd go and have a look, but my
> Dutch is 2 * Dutch.
> Vince
>
>
A man should no when it's a week past his bed time.
Read "NON alphanumeric characters"
Vince Morgan [ Fr, 20 April 2007 19:52 ] [ ID #1693635 ]

Re: Voipbuster script.

Vince Morgan wrote:

>
> "Vince Morgan" <vinhar [at] REMOVEoptusnet.com.au> wrote in message
> news:46276af7$0$16552$afc38c87 [at] news.optusnet.com.au...
>> 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
>>
>>
>
> Ooops, I forgot you are dealing with chars rather than integers.
>
> $string[$i] = $string[$i]< "5" ? $string[$i]+=5 : ($string[$i]+=5)-10;
>
> Vince

Hei Vince

This line:
$string[$i] = $string[$i]< "5" ? $string[$i]+=5 : ($string[$i]+=5)-10;
gives me an Error:

Cannot use assign-op operators with overloaded objects nor string offsets

(I'm using NuSpherePhpED debugger from http://www.phped.com/)
Henk Oegema [ Sa, 21 April 2007 13:02 ] [ ID #1694375 ]

Re: Voipbuster script.

"Henk Oegema" <henk [at] oegema.com> wrote in message
news:sbmWh.132417$oy1.981043 [at] phobos.telenet-ops.be...
> Vince Morgan wrote:

> Hei Vince


for($i=0; $i<strlen($string); $i++)
{
if($string[$i] < "5")
{
$string[$i] = $string[$i] + 5;
}else
{
$string[$i] = $string[$i] - 5;
}
}

Did you get "curl_init()" to work yet?
Regards,
Vince
Vince Morgan [ Sa, 21 April 2007 18:47 ] [ ID #1694378 ]

Re: Voipbuster script.

Vince Morgan wrote:

>
> "Henk Oegema" <henk [at] oegema.com> wrote in message
> news:sbmWh.132417$oy1.981043 [at] phobos.telenet-ops.be...
>> Vince Morgan wrote:
>
>> Hei Vince
>
>
> for($i=0; $i<strlen($string); $i++)
> {
> if($string[$i] < "5")
> {
> $string[$i] = $string[$i] + 5;
> }else
> {
> $string[$i] = $string[$i] - 5;
> }
> }
>
> Did you get "curl_init()" to work yet?
Yes.
It probably worked straight from the beginning without noticing it.

When I used the script to send a SMS to an other mobile phone( with a
different GSM provider) the message was received. :-)
Apparently my provider can't (doesn't allow ?) receive SMS from
VoIPBuster. :-(

However, your short version of the for-loop, gives a different result
compared to the original elseif----elseif.

Grds.
Henk
Henk Oegema [ Sa, 21 April 2007 21:18 ] [ ID #1694385 ]

Re: Voipbuster script.

Vince Morgan wrote:

>
> for($i=0; $i<strlen($string); $i++)
> {
> if($string[$i] < "5")
> {
> $string[$i] = $string[$i] + 5;
> }else
> {
> $string[$i] = $string[$i] - 5;
> }
> }
>
The above for-loop doesn't give the same result as the else-if loop.(in my
original thread)

This one (from Jeff) does:


for ($i=0;$i<strlen($string);$i++)
{
   $chr = $string{$i};
   switch($chr)
   {
      case "0" : $string[$i] = "5"; break;
      case "1" : $string[$i] = "6"; break;
      case "2" : $string[$i] = "7"; break;
      case "3" : $string[$i] = "8"; break;
      case "4" : $string[$i] = "9"; break;
      case "5" : $string[$i] = "0"; break;
      case "6" : $string[$i] = "1"; break;
      case "7" : $string[$i] = "2"; break;
      case "8" : $string[$i] = "3"; break;
      case "9" : $string[$i] = "4"; break;
   }
}

Grds.
Henk
Henk Oegema [ Sa, 21 April 2007 23:46 ] [ ID #1694388 ]

Re: Voipbuster script.

"Henk Oegema" <henk [at] oegema.com> wrote in message
news:9DvWh.133204$8X3.991299 [at] phobos.telenet-ops.be...
> Vince Morgan wrote:

Jeff had the sense to consider there may be non numeric chars in the string
Henk.

for($i=0; $i<strlen($string); $i++)
{
if(is_numeric($string[$i]))
{
if($string[$i] < "5")
{
$string[$i] = $string[$i] + 5;
}else
{
$string[$i] = $string[$i] - 5;
}
}
}

The above would work fine in that case, because it takes non numeric chars
that into consideration.
However, I think Jeff's solution is a lot more intiutive actualy as it's
purpose is more obvious.
Good to see you got it working Henk.
Vince
Vince Morgan [ So, 22 April 2007 04:20 ] [ ID #1694876 ]

Re: Voipbuster script.

On Sun, 22 Apr 2007 12:20:33 +1000, in alt.php "Vince Morgan"
<vinhar [at] REMOVEoptusnet.com.au>
<462ac620$0$5746$afc38c87 [at] news.optusnet.com.au> wrote:

>|
>| "Henk Oegema" <henk [at] oegema.com> wrote in message
>| news:9DvWh.133204$8X3.991299 [at] phobos.telenet-ops.be...
>| > Vince Morgan wrote:
>|
>| Jeff had the sense to consider there may be non numeric chars in the string
>| Henk.

Not really :-)
I was trying to keep the code in a similar format to the OP :-)

>| for($i=0; $i<strlen($string); $i++)
>| {
>| if(is_numeric($string[$i]))
>| {
>| if($string[$i] < "5")
>| {
>| $string[$i] = $string[$i] + 5;
>| }else
>| {
>| $string[$i] = $string[$i] - 5;
>| }
>| }
>| }
>|
>| The above would work fine in that case, because it takes non numeric chars
>| that into consideration.
>| However, I think Jeff's solution is a lot more intiutive actualy as it's
>| purpose is more obvious.
>| Good to see you got it working Henk.
>| Vince
>|
------------------------------------------------------------ ---
jnorthau [at] yourpantsyahoo.com.au : Remove your pants to reply
------------------------------------------------------------ ---
Jeff North [ So, 22 April 2007 05:55 ] [ ID #1694877 ]

Re: Voipbuster script.

"Jeff North" <jnorthau [at] yahoo.com.au> wrote in message
news:74nl23ttu07hshcis4b80ovkmasrbs7ijm [at] 4ax.com...

>
> Not really :-)
> I was trying to keep the code in a similar format to the OP :-)

Yes, and that was much more considerate. Not to mention that it actualy
worked too ;)
Vince
Vince Morgan [ So, 22 April 2007 06:11 ] [ ID #1694878 ]

Re: Voipbuster script.

Vince Morgan wrote:

> "Jeff North" <jnorthau [at] yahoo.com.au> wrote in message
> news:74nl23ttu07hshcis4b80ovkmasrbs7ijm [at] 4ax.com...
>
>>
>> Not really :-)
>> I was trying to keep the code in a similar format to the OP :-)
>
> Yes, and that was much more considerate. Not to mention that it actualy
> worked too ;)
> Vince

I have put the three versions together with their output:

<?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
$username1 = encryptString('henkoegema');
$password1 = encryptString('php4script') ;

print($username1); //output="uraxbrtrzn"
print($password1); //output="cuc9fpevcg"

//==================================================
function encryptString2($string)
{
for($i=0; $i < strlen($string); $i++)
{
if(is_numeric($string[$i]<"5"))
{
$string[$i]= $string[$i]+ 5;
}else
{
$string[$i]= $string[$i]- 5;
}
}
return str_rot13($string);
}

// Set username and password
$username2 = encryptString2('henkoegema');
$password2 = encryptString2('php4script');

print($username2); //output="----------"
print($password2); //output="----------"

//===============================================

function encryptString3($string)
{
for($i=0; $i < strlen($string); $i++)
{
$chr=$string[$i];
switch($chr)
{
case "0":$string[$i]="5";break;
case "1":$string[$i]="6";break;
case "2":$string[$i]="7";break;
case "3":$string[$i]="8";break;
case "4":$string[$i]="9";break;
case "5":$string[$i]="0";break;
case "6":$string[$i]="1";break;
case "7":$string[$i]="2";break;
case "8":$string[$i]="3";break;
case "9":$string[$i]="4";break;
}
}
return str_rot13($string);
}

// Set username and password
$username3 = encryptString3('henkoegema');
$password3 = encryptString3('php4script');

print($username3); //output="uraxbrtrzn"
print($password3); //output="cuc9fpevcg"

print("End test");


//================================================


Rgds
Henk
Henk Oegema [ So, 22 April 2007 11:51 ] [ ID #1694881 ]

Re: Voipbuster script.

"Henk oegema" <henk [at] oegema.com> wrote in message
news:ueGWh.133959$4_7.969815 [at] phobos.telenet-ops.be...
> I have put the three versions together with their output:

Two versions include code that _was_ posted. However, one of them is not
something that was posted here, though it looks similar to one of them.
This block;

> if(is_numeric($string[$i]<"5"))
> {
> $string[$i]= $string[$i]+ 5;
> }else
> {
> $string[$i]= $string[$i]- 5;
> }

is quite similar to the one below, which is what I actualy posted.

> if(is_numeric($string[$i]))
> {
> if($string[$i] < "5")
> {
> $string[$i] = $string[$i] + 5;
> }else
> {
> $string[$i] = $string[$i] - 5;
> }
> }
The one above produces exactly the same output as the other two, if the same
inputs are used.
Perhaps you made a mistake in typing it up. Copying and pasting might have
saved you some time.
Check what was posted against what you have above.
Regards,
Vince
Vince Morgan [ So, 22 April 2007 12:56 ] [ ID #1694883 ]

Re: Voipbuster script.

Vince Morgan wrote:

>
> "Henk oegema" <henk [at] oegema.com> wrote in message
> news:ueGWh.133959$4_7.969815 [at] phobos.telenet-ops.be...
>> I have put the three versions together with their output:
>
> Two versions include code that _was_ posted. However, one of them is not
> something that was posted here, though it looks similar to one of them.
> This block;
>
>> if(is_numeric($string[$i]<"5"))
>> {
>> $string[$i]= $string[$i]+ 5;
>> }else
>> {
>> $string[$i]= $string[$i]- 5;
>> }
>
> is quite similar to the one below, which is what I actualy posted.
>
>> if(is_numeric($string[$i]))
>> {
>> if($string[$i] < "5")
>> {
>> $string[$i] = $string[$i] + 5;
>> }else
>> {
>> $string[$i] = $string[$i] - 5;
>> }
>> }
> The one above produces exactly the same output as the other two, if the
> same inputs are used.
> Perhaps you made a mistake in typing it up. Copying and pasting might
> have saved you some time.
> Check what was posted against what you have above.
> Regards,
> Vince

Your are absolutely correct Vince. :-)
Sorry, my mistake. :-(

Thanks very much for your help and time. (also thanks to Jeff)

I'm a totally happy man now.

Rgds.
Henk
Henk Oegema [ So, 22 April 2007 13:43 ] [ ID #1694885 ]

Re: Voipbuster script.

"Henk oegema" <henk [at] oegema.com> wrote in message
news:YTHWh.134089$eB2.1013850 [at] phobos.telenet-ops.be...
>
> Your are absolutely correct Vince. :-)
> Sorry, my mistake. :-(
>
> Thanks very much for your help and time. (also thanks to Jeff)
>
> I'm a totally happy man now.

You're more than welcome anytime Henk,
Vince
Vince Morgan [ So, 22 April 2007 14:13 ] [ ID #1694887 ]

Re: Voipbuster script.

On Sun, 22 Apr 2007 14:11:59 +1000, in alt.php "Vince Morgan"
<vinhar [at] REMOVEoptusnet.com.au>
<462ae03d$0$11385$afc38c87 [at] news.optusnet.com.au> wrote:

>| "Jeff North" <jnorthau [at] yahoo.com.au> wrote in message
>| news:74nl23ttu07hshcis4b80ovkmasrbs7ijm [at] 4ax.com...
>|
>| >
>| > Not really :-)
>| > I was trying to keep the code in a similar format to the OP :-)
>|
>| Yes, and that was much more considerate. Not to mention that it actualy
>| worked too ;)
>| Vince

I was going to post/mention something like Henk had posted but I hit
the send button a bit too quickly. Also, keep in mind a lot of the
code that is posted is untested.
------------------------------------------------------------ ---
jnorthau [at] yourpantsyahoo.com.au : Remove your pants to reply
------------------------------------------------------------ ---
Jeff North [ So, 22 April 2007 15:08 ] [ ID #1694889 ]

Re: Voipbuster script.

"Jeff North" <jnorthau [at] yahoo.com.au> wrote in message
news:hfnm23ptfr4qm047j5hribu9fc02s81km4 [at] 4ax.com...
> On Sun, 22 Apr 2007 14:11:59 +1000, in alt.php "Vince Morgan"
> <vinhar [at] REMOVEoptusnet.com.au>
> <462ae03d$0$11385$afc38c87 [at] news.optusnet.com.au> wrote:
>
> >| "Jeff North" <jnorthau [at] yahoo.com.au> wrote in message
> >| news:74nl23ttu07hshcis4b80ovkmasrbs7ijm [at] 4ax.com...
> >|
> >| >
> >| > Not really :-)
> >| > I was trying to keep the code in a similar format to the OP :-)
> >|
> >| Yes, and that was much more considerate. Not to mention that it
actualy
> >| worked too ;)
> >| Vince
>
> I was going to post/mention something like Henk had posted but I hit
> the send button a bit too quickly. Also, keep in mind a lot of the
> code that is posted is untested.

I meant that your code worked, and mine didn't Jeff.
You showed more consideration for the OP by keeping it simple.
I hit the send button too soon also, as I often do, and I rarely test it
first, but I've resolved to not do that anymore :]
Vince Morgan [ Mo, 23 April 2007 10:14 ] [ ID #1695508 ]
PHP » alt.php » Voipbuster script.

Vorheriges Thema: TR-069 and PHP/Perl
Nächstes Thema: best practices confusion between framework v.templating ?