Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6745919
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T12:15:41+00:00 2026-05-26T12:15:41+00:00

I have the following PHP code which simply grabs a URL behind HTTP-Basic authentication

  • 0

I have the following PHP code which simply grabs a URL behind HTTP-Basic authentication and re-serves it:

<?PHP
    header("Content-Type: text/xml");

    $username = "username";
    $password = "password";
    $url = "http://s6.voscast.com:7158/admin.cgi?mode=viewxml";

    $context = stream_context_create(array(
        'http' => array (
            'method' => "GET",
            'header' => "Authorization: Basic ".base64_encode($username.":".$password)."\r\n".
                        "User-Agent: Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/535.1 (KHTML, like Gecko) Ubuntu/11.04 Chromium/14.0.835.202 Chrome/14.0.835.202 Safari/535.1"
        )
    ));

    print file_get_contents($url, false, $context);
?>

It works without any issues locally on my Linux Mint 11 machine (v. 5.3.5), but fails on another Linux server of a client which is running 5.2.14:

enter image description here

It seems like it’s trying to validate the XML, which is totally unnecessary. Is there a way I can disable this feature or investigate further as to what’s going wrong?

When I look at the source of the response, I see the following:

failed to open stream: Connection refused in /home/livshin/public_html/wp-content/uploads/_radio/songinfo.php on line 16

It’s working fine locally, but is failing online? How can I further debug this?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-26T12:15:42+00:00Added an answer on May 26, 2026 at 12:15 pm

    Try a simple test case to see if you can access any internet website. e.g. <?php echo file_get_contents('http://google.com'); ?> Assuming the code and configuration (username/password) is identical on your local machine and the server, then the problem must be that the server itself is different in some way (e.g. doesn’t have internet access).

    Another thing to check would be the PHP configuration on the server. Opening a URL with file_get_contents() can be disabled using the allow_url_fopen setting.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have the following code: http://www.nomorepasting.com/getpaste.php?pasteid=22615 Which is called by the javascript mentioned in
I have the following PHP code which works out the possible combinations from a
I have the following php code, which has been snipped for brevity. I am
I have to following code: http://www.nomorepasting.com/getpaste.php?pasteid=22987 If PHPSESSID is not already in the table
I have a script that generates a csv file using the following code: header('Content-type:
I have the following PHP code which is attempting to check for password complexity
I have a simple PHP page (for testing) that simply calls header(Location: http://www.example.com );exit;
I have a css question. I have the following php code which displays a
I have following PHP code $val=<div id=user.$row['cid']. userid=.$row['cid']. class=innertxt><img src=images/images.jpg width=50 height=50><strong>.$uname.</strong><ul> <li>Email: .$row['cemail'].</li>
I have the following PHP code doing a very simple select into a table.

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.