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'm not sure where this is handled. I need the equivalent of PHP's set_time_limit(seconds)
How to solve set_time_limit not affecting PHP-CLI? #!/usr/bin/php -q <?php set_time_limit(2); sleep(5); // actually,
Some code here, I want store mysql query result into an array with php,
i need to get links with pdf extension. my code is : <?php set_time_limit
<?php set_time_limit(0); $php_userid = my yahoo id; $php_password = my yahoo password; $agent =
There is this situation: Wampserver is running A PHP script is running (set_time_limit(0), endless
I've tried the following method in the past: <?php set_time_limit(0); $_SERVER['PATH_INFO'] = 'cron/controller/index'; $_SERVER['REQUEST_URI']
I just tried this code: <?php set_time_limit(0); $address = '176.9.117.136'; $port = 9000; $sock
If I have this PHP code : <?php set_time_limit(0); //mysql connection while(true) { //check
I'm wondering how to set the max possible time limit for a php page,

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.