Вы не зашли.
Главная » PHP » Общие вопросы по PHP
#221. Gemorroj Off (107)
Administrator
2011.09.09 22:10
я чето не догоняю.
$fp = fopen('info.txt', 'a'); // открыли только для записи
while (!feof($this->fp)) { // тут проверка на конец файла, но модификатор "a" как раз помещает указатель на конец файла, так что внутрь while мы не должны попасть
#222. TLENS Off (14)
Moderator
2011.09.09 22:10
Ты не понял Есть $fp а есть $this->fp который открыт выше
в $this->fp открыт вайл со стороннего хоста.
Отредактировано TLENS (2011.09.09 22:10)
#223. Gemorroj Off (107)
Administrator
2011.09.09 22:10
а епт)
дай весь код. запущу на своей фряхе.
#224. TLENS Off (14)
Moderator
2011.09.09 22:10
Я его запускал на других работает как надо. скорее ip
Код:
span style="color: #0000BB"><?phperror_reporting(0);ini_set('zlib.output_compression', 'Off');ini_set('output_handler', '');ini_set('max_execution_time', 999);//var_dump($GLOBALS["HTTP_SERVER_VARS"]);class Parser { public $host; public $path; public $name; public $url; public $header; public $fp; public $err; public $accept_headers; public function __construct($url, $name = '') { if (!$name) { $this->name = basename($url); } else { $this->name = $name; } $url = parse_url($url); $this->host = $url['host']; $this->path = $url['path']; $this->accept_headers = $this->get_accept_headers(); } //--------- Подготовка принятых заголовков для передачи ------// private function get_accept_headers () { foreach($_SERVER as $k => $v) { $http = substr($k, 0, 5); if($http == 'HTTP_') { $h = substr($k, 5); if($h == 'HOST') $headers .= 'Host: ' . $this->host . "\r\n"; elseif($h == 'REFERER') $headers .= 'Referer: http://' . $this->host . "\r\n"; else $headers .= $h . ': ' . $v . "\r\n"; } } return $headers; } //----- Соеденение и передача заголовков ------// public function connect () { $this->fp = @fsockopen($this->host, 80, $errno, $errstr, 10); if (!$this->fp) { $this->err = '<h1>' . $errno . '</h1>' . "\n" . '<p>' . $errstr . '</p>'; return false; } else { fputs ($this->fp, "GET " . $this->path . " HTTP/1.0\r\n" . $this->accept_headers . "\r\n"); return true; } } //----------- Получаю заголовки -------// public function get_headers () { $headers = array(); while (!feof($this->fp)) { $b = trim(fgets($this->fp)); if(!$b) break; if(substr($b ,0, 5) == 'HTTP/') { $headers['HTTP'] = $b; } else { $buf = explode(': ', $b); $headers[$buf[0]] = $buf[1]; } } return $headers; } //--- Выдача файла --// public function readfile () { //fpassthru($this->fp); $starttime = microtime(1); $fp = fopen('info.txt', 'a'); while (!feof($this->fp)) { $f = fread($this->fp, 1024); $len = strlen($f); $stt = microtime(1); fputs($fp, $len . ' - ' . ($stt - $starttime) . "\n"); if ($len < 1024) { fputs($fp, $f . "\n\n\n"); } $starttime = $stt; } }}set_time_limit(999);$file = new Parser ('http://ds.sasisa.ru/fc/upload_files/1199739600/wap_sasisa_ru_homevideo_tanya_xxx.3gp');if (!$file->connect()) exit($file->err);$headers = $file->get_headers();//var_dump($headers); exit;//header($headers['HTTP']);//header('Keep-Alive: timeout=10, max=60');//header('Connection: Keep-Alive, close');//header ("Cache-Control: None");//header('Content-Encoding: binary');//header('Content-Disposition: attachment; filename="' . $file->name . '"');//if($headers['Content-Range']) //header('Content-Range: ' . $headers['Content-Range']); //if($headers['Accept-Ranges']) //header('Accept-Ranges: ' . $headers['Accept-Ranges']); //header('Content-Length: ' . $headers['Content-Length']); //header('Content-Type: ' . $headers['Content-Type']);$file->readfile();
Добавлено спустя   4 минуты  54 секунды:
Ну что там?
#225. Gemorroj Off (107)
Administrator
2011.09.09 22:10
последние строчки:
1024 - 1,5020370483398E-5
1024 - 1,5020370483398E-5
348 - 60,271856069565
а дальше пидарасня какая-то. такое ощущение, что сам файл пишется. щас код повнимательнее посмотрю.
#226. TLENS Off (14)
Moderator
2011.09.09 22:10
А та не парся то я решил глянуть что там 83 строка
Добавлено спустя   6 минут  41 секунду:
Я конечно люблю загадки но не до такой степени.
Выполнил
Код:
span style="color: #0000BB"><?php$starttime = microtime(1);copy('http://ds.sasisa.ru/fc/upload_files/1199739600/wap_sasisa_ru_homevideo_tanya_xxx.3gp', 'test.file');echo round(microtime(1) - $starttime, 4);
Результат 0.6344
Все таки проблема в коде.
Паша вся надежда на тебя. Сейчас попробую отправляемые заголовки перевести в нижний регистр. Но мало верится что поможет я уже не знаю что делать.
#227. TLENS Off (14)
Moderator
2011.09.09 23:11
Подожди дак у тебя тоже вис, это статы с твоего сервера?
1024 - 1,5020370483398E-5
1024 - 1,5020370483398E-5
348 - 60,271856069565
#228. Gemorroj Off (107)
Administrator
2011.09.09 23:11
да.
смотрю в чем дело.
#229. Gemorroj Off (107)
Administrator
2011.09.09 23:11
smile)
вобщем так)
Добавлено спустя    20 секунд:
Код:
span style="color: #0000BB"><?php//error_reporting(0);ini_set('zlib.output_compression', 'Off');ini_set('output_handler', '');ini_set('max_execution_time', 999);//var_dump($GLOBALS["HTTP_SERVER_VARS"]); class Parser{ public $host; public $path; public $name; public $url; public $header; public $fp; public $err; public $accept_headers; public function __construct($url, $name = '') { if (!$name) { $this->name = basename($url); } else { $this->name = $name; } $url = parse_url($url); $this->host = $url['host']; $this->path = $url['path']; $this->accept_headers = $this->get_accept_headers(); } public function __destruct() { is_resource($this->fp) ? fclose($this->fp) : null; } /** * Подготовка принятых заголовков для передачи * * @return string */ private function get_accept_headers () { $headers = ''; foreach ($_SERVER as $k => $v) { $http = substr($k, 0, 5); if ($http == 'HTTP_') { $h = substr($k, 5); if ($h == 'HOST') { $headers .= 'Host: ' . $this->host . "\r\n"; } else if ($h == 'REFERER') { $headers .= 'Referer: http://' . $this->host . "\r\n"; } else if ($h == 'CONNECTION') { $headers .= "Connection: close\r\n"; } else if ($h == 'ACCEPT_ENCODING' || $h == 'TE') { // пропускаем } else { $headers .= str_replace('_', '-', ucwords(strtolower($h))) . ': ' . $v . "\r\n"; } } } return $headers; } /** * Соеденение и передача заголовков * * @return bool */ public function connect () { $this->fp = @fsockopen($this->host, 80, $errno, $errstr, 10); if (!$this->fp) { $this->err = '<h1>' . $errno . '</h1>' . "\n" . '<p>' . $errstr . '</p>'; return false; } else { fputs ($this->fp, "GET " . $this->path . " HTTP/1.0\r\n" . $this->accept_headers . "\r\n"); return true; } } /** * Получаю заголовки * * @return array */ public function get_headers () { $headers = array(); while (($b = fgets($this->fp)) !== false) { $b = trim($b); if ($b === '') break; if (substr($b, 0, 5) == 'HTTP/') { $headers['HTTP'] = $b; } else { $buf = explode(': ', $b); $headers[$buf[0]] = $buf[1]; } } return $headers; } /** * Запись файла */ public function readfile () { $starttime = microtime(1); $fp = fopen('info.txt', 'a'); fputs($fp, $this->accept_headers . "\n\n\n\n"); while (($f = fgets($this->fp)) !== false) { $len = strlen($f); $stt = microtime(1); fputs($fp, $len . ' - ' . ($stt - $starttime) . "\n"); $starttime = $stt; } }}set_time_limit(999);$file = new Parser ('http://ds.sasisa.ru/fc/upload_files/1199739600/wap_sasisa_ru_homevideo_tanya_xxx.3gp');if (!$file->connect()) exit($file->err);$headers = $file->get_headers();//var_dump($headers); exit; //header($headers['HTTP']);//header('Keep-Alive: timeout=10, max=60');//header('Connection: Keep-Alive, close');//header ("Cache-Control: None");//header('Content-Encoding: binary');//header('Content-Disposition: attachment; filename="' . $file->name . '"'); //if($headers['Content-Range']) //header('Content-Range: ' . $headers['Content-Range']); //if($headers['Accept-Ranges']) //header('Accept-Ranges: ' . $headers['Accept-Ranges']); //header('Content-Length: ' . $headers['Content-Length']); //header('Content-Type: ' . $headers['Content-Type']); $file->readfile();
#230. TLENS Off (14)
Moderator
2011.09.09 23:11
Слушаю
Страниц: 121 22 23 24 25118 Все
Главная
WEB
PunBB Mod v0.6.2
0.032 s