Jump to content

bogeyman

Members
  • Posts

    21
  • Joined

  • Last visited

    Never

Everything posted by bogeyman

  1. Dear all, I try to make a PHP script for resumable download, so I try to search it on search engine. I got it and I modified the code a little bit. The code is like this <?php $file = "D:\\Software\\Oracle Instant Client\\instantclient-basic-win32-10.1.0.4-20050513.zip"; $fileName = "InstantClient.zip"; $filesize = filesize($file); $offset = 0; $length = $filesize; if ( isset($_SERVER['HTTP_RANGE']) ) { $partialContent = true; preg_match('/bytes=(\d+)-(\d+)', $_SERVER['HTTP_RANGE'], $matches); $offset = intval($matches[1]); $length = intval($matches[2]) - $offset; } else { $partialContent = false; } $file = fopen($file, 'r'); fseek($file, $offset); $data = fread($file, $length); fclose($file); if ( $partialContent ) { header('HTTP/1.1 206 Partial Content'); header('Content-Range: bytes ' . $offset . '-' . ($offset + $length) . '/' . $filesize); } header('Content-Type: ' . $ctype); header('Content-Length: ' . $filesize); header('Content-Disposition: attachment; filename="' . $fileName . '"'); header('Accept-Ranges: bytes'); print($data); ?> I try run the script with Firefox, then I pause the download process. Then the problem start. I got an error message like this. InstantClient.zip.part could not be saved, because the source file could not be read. Try it again later, or contact the server administrator. I can't resume my download. I just can start it from the begining. Can anyone tell me what's wrong? Thanks before.
  2. Is your field's length long enough?
  3. Dear All, I'm just curious about session in CodeIgniter. Where and how was the session stored? Because I didn't find any session file in my temporary directory.
  4. Yes it's possible. The concept is open the image file using fopen(), read it using fread(), then write it to file with fwrite(). If you are on internal network and using a proxy server to connect to the internet, you have to use fsockopen() function.
  5. Dear All, I'm new in Code Igniter. How can I redirect user to the other page? What function should I use?
  6. Maybe you can try this. Change this line. parent::changeValue($this->a + $this->b); To parent::changeValue($this->a + $b);
  7. When you store the image to database, do you use addslashes() function? I ever made the script for upload and download. When I upload a file to database, I store it with statement like this: mysql_query("INSERT INTO upload (filename, filesize, filetype, content) VALUES ('".$name."','".$length."','".$type."','".addslashes($content)."')"); And, In my download script, I use script like this: $result=mysql_query("SELECT filetype, filesize, filename, content FROM upload WHERE id='".mysql_escape_string($_GET['fileid'])."'"); if(mysql_num_rows($result)>0){ $data=mysql_fetch_row($result); header("Content-Type:".$data[0]); header("Content-Length:".$data[1]); header("Content-Disposition: attachment; filename=".$data[2]); echo $data[3]; } I don't think the problem is in your web server configuration. By the way, are you sure the image type is "image/gif"?
  8. Yeah, I think you should store it with the line breaks and use nl2br() function to convert the line breaks into <br> tag.
  9. You can use a table to store the session. To check who is online, just use SELECT statement to retrieve the data. In your PHP script, you also need to use the function session_set_save_handler() to override the default way of PHP in handling session. This article might be helpfull. I read this when I learn about storing session in database. shiflett.org/articles/storing-sessions-in-a-database
  10. Dear all, How do I detect user's location (country) based on the IP address?
  11. Well, I got another solution. I just modify php.ini and change the line : session.cookie_domain = To (the domain name is just an example) : session.cookie_domain = .somewhere.com That means every subdomain can use the same session as long as they are under the same domain name (in this case somewhere.com) and located at the same web server. But, I think your idea is very good and I will try it. I think it can be implemented even if the domains are located at different server and have completely different domain name. Thanx.
  12. Dear all, How can I use just one session for multiple domain? For example, I want to use just one session for domain domain1.somewhere.com and domain2.somewhere.com so users can navigate between those domains with just once login.
  13. Maybe you can use your database. You can add a field named login_time to your users table to store the date and time of user's login time. Everytime users login, update that field with the current date and time. And, everytime users navigate to the other page, compare the current date and time with that login_time field content. If the gap between them is bigger than the defined time, destroy the session.
  14. Not that php 6 is coming out next week but that framework would fail with it because of it dependence on get_magic_quotes_gpc() which may or may not be an easy fix but i would think a newer framework would follow most common standards and since magic quotes are a bad idea(which is why it is finally being removed in php 6) and no one has ever said that magic quotes are great as long as i has been doing PHP programming(2 years) so who knows what other weird stuff that framework does. I would love to ask the lead developer why he/she decided to support magic quotes. Ow, it looks like I can't rely on Yii at this time. Honestly, I'm just impressed by its speed. Right now, i'm still using (and learning) Prado. But I'd love to try another framework which can run faster (maybe Code Igniter).
  15. There is a new framework: http://www.yiiframework.com/ It's called Yii. It's still in beta version. But, maybe the fastest framework.
  16. Dear all, How do I check if an email has attachment with my PHP script? The email server is using POP3 as its protocol. Thanks before.
  17. Dear all, How do I check if an email has attachment with PHP? The email server is using POP3 as its protocol. Thanks before.
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.