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

  • Home
  • SEARCH
  • 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 3398682
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 18, 20262026-05-18T04:40:45+00:00 2026-05-18T04:40:45+00:00

<?php set_time_limit(0); $errorArr = array(); if (!isset($argv[1])) { array_push($errorArr, You forgot to enter a

  • 0
<?php
set_time_limit(0);

$errorArr = array();
if (!isset($argv[1]))
{
    array_push($errorArr, "You forgot to enter a host.");
}
if ((isset($argv[1])) AND (!filter_var($argv[1], FILTER_VALIDATE_IP)))
{
    array_push($errorArr, "The host you entered is not a valid IP address.");
}
if (!isset($argv[2]))
{
    array_push($errorArr, "You forgot to select a port.");
}
if (!empty($errorArr))
{
    echo "You have the following errors:\n";
    print_r($errorArr);
    die("Syntax is as follows: php {$argv[0]} host port\n");
}

$host = $argv[1];
$port = $argv[2];

echo ":::Connecting...\n";
$fh = fsockopen($host, $port);
if (!$fh)
{
    die(":::Connection failed.\n:::Aborting.\n");
}
echo ":::Connected!\n:::Sending headers.\n";

$header = "PROPFIND /webdav/ HTTP/1.1\r\n";
$header .= "Host: {$host}\r\n";
$header .= "User-Agent: BitKinex/3.2.3\r\n";
$header .= "Accept: */*\r\n";
$header .= "Pragma: no-cache\r\n";
$header .= "Cache-Control: no-cache\r\n";
$header .= "Depth: 1\r\n";
$header .= "Content-Length: 220\r\n";
$header .= "Content-Type: text/xml\r\n\r\n\r\n";
if (!fwrite($fh, $header))
{
    die(":::Couldn't send headers. Aborting.\n");
}
$exHeader = explode("\r\n", $header);
foreach ($exHeader as $ecHeader)
{
    echo "<<<{$ecHeader}\n";
}
echo "\n:::Retrieving syntax...\n";
while(1)
{
    while ($data = fgets($fh, 512))
    {
        echo ">>>{$data}";
        flush();
    }
}
?>

I’m working on a script to connect to WebDAV, upload a file, and disconnect. It connects and sends headers fine, but then it takes forever to retrieve syntax. At times, it takes several minutes, and I can’t understand why. Is it a problem in my code?

And yes, I realize there’s an infinite while loop there. That’s done on purpose, because I haven’t figured out how to know when the server is done sending information to me. So I guess that’s another question, if anyone could provide insight to that.

Thanks

  • 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-18T04:40:45+00:00Added an answer on May 18, 2026 at 4:40 am

    Your problem is because you are sending the Content-Length header with a value of 220, while not sending any content at all. The server hangs in there expecting content, but it never arrives…

    And for your infinite loop thing, you don’t need it at all. fgets will return false if the connection has closed. Send the Connection: close header to tell Apache to end the connection after the data has been sent. Your while loop will evaluate to false when the data has been read entirely and the connection has closed, and your loop will exit.

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

Sidebar

Related Questions

I've tried the following method in the past: <?php set_time_limit(0); $_SERVER['PATH_INFO'] = 'cron/controller/index'; $_SERVER['REQUEST_URI']
I can set the PHP include path in the php.ini : include_path = /path/to/site/includes/
I currently have my PHP class variables set up like this: class someThing {
How can I best set up my PHP (LAMP) development environment so that I
How can I set the cookies in my PHP apps as HttpOnly cookies ?
I am writing a set of database-driven applications in PHP. These applications will run
I have a PHP-generated page which is displaying some data about a set of
I'm running PHP 5.2.6 on a Windows Server 2003 Enterprise box. IIS is set
I have OS X 10.5 set up with the precompiled versions of PHP 5
Where would set_include_path(../../); point to? I am trying to run some PHP code on

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.