3

my code is

<?php
if ($_POST['hiddensms']) {
    ini_set("allow_url_fopen", "ON");
    ini_set("allow_url_include", "ON");
    $smsno = explode(',', $_POST['hiddensms']);
    foreach ($smsno as $mono) {
        $baseurl         = "http://api.xxxxxxxxxxxx.com";
        $sql_q           = "select firstname,lastname from tbl_newsletter where phone='" . $mono . "'";
        $resultcount     = mysql_query($sql_q);
        $row_total_count = mysql_fetch_array($resultcount);
        $first_name      = $row_total_count['firstname'];
        $last_name       = $row_total_count['lastname'];
        if ($_POST['sel_name_sms'] == 'FirstName') {
            $setname = $first_name;
        } else {
            $setname = $last_name;
        }
        $smsBodyText = $_POST['sal_sms'] . ' ' . $setname . '\n';
        $text        = urlencode($smsBodyText . $_POST['msg_body']);
        $to          = $mono;
        $url         = "$baseurl/http/auth?user=$user&password=$password&api_id=$api_id";
        // do auth call
        $ret         = file($url);
        // explode our response. return string is on first line of the data returned
        $sess        = explode(":", $ret[0]);
        if ($sess[0] == "OK") {
            $sess_id = trim($sess[1]); // remove any whitespace
            $url     = "$baseurl/http/sendmsg?user=xx&password=xxxxx&api_id=3370743&to=$to&text=$text";
            //ht$ret = file($url);
            $send    = explode(":", $ret[0]);
            if ($send[0] == "ID") {
                echo "success\nmessage ID: " . $send[1];
            } else {
                echo "send message failed";
            }
        } else {
            echo "Authentication failure: " . $ret[0];
        }
    }
}
?>

i am trying to send sms by api, but is giving me this error

Warning: file() [function.file]: URL file-access is disabled in the server configuration in /xxxxxxxsubscriber-list.php on line 622 Warning: file(http://api.xxxxx.com/http/auth?user=xx&xx&api_id=xx) [function.file]: failed to open stream: no suitable wrapper could be found in /xxxxxx/subscriber-list.php on line 622 Authentication failure:

i set .htaccess like

<IfModule mod_php5.c>
php_admin_value allow_url_fopen On
php_admin_value allow_url_include On
</IfModule>

but its not working. i dont know what to do, if any idea, please help me

i have searched out on some web they suggest to in php.ini

allow_url_fopen = On
allow_url_include = On

but i can't access php.ini , so any other way to soved this ?

7
  • maybe try php_admin_flag instead of php_admin_value php.net/manual/en/configuration.changes.php Commented May 7, 2012 at 16:58
  • i use php_admin_flag but till give error Commented May 7, 2012 at 17:02
  • May be it's listed in the disable_functions at php.ini Commented May 7, 2012 at 17:05
  • 1
    If curl is installed, you can use that without allow_url_fopen. On an unrelated note there's actually no good reason to enable allow_url_include in this example. allow_url_include is pretty much always a bad idea. Commented May 7, 2012 at 17:07
  • Oh, on closer examination of the docs: php_admin_* cannot be used in htaccess. That's why your changes to htaccess did nothing. Try php_flag allow_url_fopen on Commented May 7, 2012 at 17:09

1 Answer 1

1

This error is telling you that allow_url_fopen is turned off on your server. It IS possible to config a server to ignore user defined php.ini files they place in their web root. Since they went through this trouble, they probably blocked you from alternative hacks (such as in your htaccess file) too.

allow_url_fopen is disabled by your host for SECURITY reasons! It should be, and should remain, disabled. So stop trying to turn it on. They don't want people running who knows what, getting hacked, and putting the other people on the server at risk.

The only way to get around this is to get a new host, or get a VPS or dedicated server where you have root access.

The alternative to allow_url_fopen would be cURL. You can do the same thing with curl.

cURL Example: http://php.net/manual/en/curl.examples-basic.php

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.