Page 1 of 1

problems using file()

Posted: Sat Mar 29, 2003 10:55 am
by lloydie-t
I have a script I use for sending SMS messages through clickatell which was working fine but since I have moved to a different host server it does not work. This is on a Virtual host so I do not have access to change any setteing and they are quite security concious, so I doubt the will make any changes to php.ini

The problem seems to be with file command. The message I get is:
Warning: file("http://api.clickatell.com/http/auth?use ... id=xxxxxxx") - No such file or directory in /home/l/l/touch/public_html/support/desktop/jobconfirm.php on line 299
SMS Authentication failure:


please find following code

Code: Select all

<?php
if($smssend =="Yes")
{
if ($suser_mobile == "")
{"";}
else{
$suser_mobile = str_replace(" ","",$suser_mobile);
$baseurl ="http://api.clickatell.com";
$text = urlencode("New iTouch Job. Job $job_id has been created and assigned to you please log on to the iTouch Support Website to check details");
// auth call
$url1 = "$baseurl/http/auth?user=$smsuser&password=$smspassword&api_id=$smsapi_id";
// do auth call prblem line
$ret = file($url1);
// split our response. return string is on first line of the data returned
$sess = split(":",$ret[0]);
if ($sess[0] == "OK") {
$sess_id = trim($sess[1]); // remove any whitespace
$url2 = "$baseurl/http/sendmsg?session_id=$sess_id&to=$suser_mobile&text=$text";
// do sendmsg call problem line 2
$ret = file($url2);
$send = split(":",$ret[0]);
if ($send[0] == "ID")
echo "success<br>message ID: ". $send[1];
else
echo "send message failed";
} else {
echo "SMS Authentication failure: ". $ret[0];
exit();
}
}
}
else
{"";}
?>
Can you Help?

Posted: Sat Mar 29, 2003 11:14 am
by volka
are urlwrappers enabled?

Code: Select all

<html><body>
<?php
echo 'allow_url_fopen: ', (ini_get('allow_url_fopen')) ? 'true':'false';
?>
</body></html>
or simply

Code: Select all

<?php phpinfo(); ?>

Posted: Sat Mar 29, 2003 11:25 am
by lloydie-t
urlwrappers = false.
I have done a bit of looking up and I think I need to ude fsockopen. Is that right? or is there something else

Posted: Sat Mar 29, 2003 1:40 pm
by volka
if sockets are enabled, yes. Again phpinfo() will tell you.
You might want to check http://snoopy.sourceforge.net before coding your own http-function...

Posted: Sat Mar 29, 2003 6:00 pm
by lloydie-t
Sockets are disabled as well. My ISP are super security concious, so I doubt they will let me enable any of those features, I can't even get to my database without using thier web interface(which is pants).
Luckily I found that clickatel have a page you can post to, so you can send sms messages. it means Ihave to open a new window, but I suppose it act's as a confirmation that the message has been sent, which I did'nt have in the previous script. so the code ended up being as follows:

Code: Select all

<?php
if($smssend =="Yes")
{
if ($suser_mobile == "")
{"";}
else{
$suser_mobile = str_replace(" ","",$suser_mobile);
$text = urlencode("New iTouch Job. Job $job_id has been created and assigned to you please log on to the iTouch Support Website to check details");
echo "<body onload="java script:window.open('http://api.clickatell.com/http/sendmsg?api_id=$smsapi_id&user=$smsuser
&password=$smspassword&to=$suser_mobile&text=$text
&from=iTouch','new_win','width=300, height=200, resizable=yes')";>";
}
}
else
{"";}
?>
Thanx for your help