[ASK] PHP Session and Undefined offset

Status
Not open for further replies.

dewaforex

Active Member
120
2011
17
0
Hi,

I'm not familiar with PHP. So please help me :D
I used script from here http://ee.php.net/manual/en/function.fread.php#84115 for download page.

I got this error message :
Code:
2013/04/12 23:52:36 [error] 22344#0: *7617 FastCGI sent in stderr: "PHP message: PHP Notice:  Undefined offset: 1 in /var/web/get.php on line 83" while reading response header from upstream, client: 111.111.111.111, server: _, request: "GET /get.php?link=0prvhy HTTP/1.1", upstream: "fastcgi://unix:/dev/shm/php-fpm.0.sock:", host: "blabla.com", referrer: xxx"
Searching at google, said something about array value.

PHP:
     74      
     75     if($is_resume && isset($_SERVER['HTTP_RANGE'])) 
     76     { 
     77         list($size_unit, $range_orig) = explode('=', $_SERVER['HTTP_RANGE'], 2); 
     78 
     79         if ($size_unit == 'bytes') 
     80         { 
     81              
     82              
     83             list($range, $extra_ranges) = explode(',', $range_orig, 2); 
     84         } 
     85         else 
     86         { 
     87             $range = ''; 
     88         } 
     89     } 
     90     else 
     91     { 
     92         $range = ''; 
     93     }
line 83:
PHP:
83             list($range, $extra_ranges) = explode(',', $range_orig, 2);
Said that we can use isset to test variable but I can't find way to implement at that line.

Second problem about PHP session.
If I add session to this script seem the download only can run on single thread at download manager.

This what I added to download script:
PHP:
session_start();
if($_SESSION["download"]){
If session true serve the file to user but only can run single thread
How to implement the session so can run on multiple thread just like without using session?

Thank you very much :-=
 
3 comments
Use preg_match() to make sure the values you explode() have the expected format?

The default PHP session driver is file based: Each session is locked until released - other requests have to wait. You can explicitly close a session with session_write_close(). Alternatively, you can use a different session driver.
 
before this

Code:
83             list($range, $extra_ranges) = explode(',', $range_orig, 2);

do var_dump on $range, $extra_ranges or $range_orig
 
Hi,

The problem just solved by someone help at WHT :D
For Undefined offset as the error said just found 1 string so the code reduce too

PHP:
list($range) = explode(',', $range_orig, 2);
And for session, seem working with multi thread too just at posting this my connection is very bad/slow so can not split the download.
 
Status
Not open for further replies.
Back
Top