4images Forum & Community
Welcome, Guest. Please login or register.
Did you miss your activation email?
September 19, 2018, 10:15:14 PM

Login with username, password and session length
Search:     Advanced search
4images is now on facebook. Click here and become a fan!
Togle to toolbar
Translate this page with =>
Translate this page >
* Home Help Search Login Register
 
+  4images Forum & Community
|-+  4images Issues / Ausgaben
| |-+  Discussion & Troubleshooting (Moderators: Acidgod, ivan, Rembrandt)
| | |-+  DOWNLOAD BUTTON & ADMIN TOP 5 PICTURE HITS ERRORS
0 Members and 1 Guest are viewing this topic. « previous next »
Pages: [1] 2 » »» Print
Author Topic: DOWNLOAD BUTTON & ADMIN TOP 5 PICTURE HITS ERRORS  (Read 10012 times)
Alain
Newbie
*
Offline Offline

Posts: 24

Thank You
-Given: 0
-Receive: 0


View Profile
« on: June 16, 2002, 10:33:20 PM »

Hi, first, thank you very much!

2 things however that need to be solved :

if I click on the DOWNLOAD button then it is starting to download but it is only downloading the first segment of the file : never more than 1000 bytes then it is finishing. Result : a file that should be 50K heavy is downloaded at only 1K so obviously the file is corrupted (this is NOT A REMOTE/URL file, it is a local file).

Environment : Windows 2000 + Apache 1.3 + PHP 4

I have manually debugged DOWNLOAD.PHP and it seems that the file length is correctly checked but then in the code, this value is missed and so the browser is only downloading a small part of the picture. The resulted picture is simply the header of the picture.

Also in the admin. panel, if I look at the TOP 5 PICTURE HITS then the total is always 0 (Total:0) as if it was unable to make the sum of the hits.

Thank you!!!
Logged
Nicky
Administrator
4images Guru
*****
Offline Offline

Posts: 3195

Thank You
-Given: 26
-Receive: 57


View Profile
« Reply #1 on: June 16, 2002, 11:22:40 PM »

TOP 5 Hits:

admin/home.php change line 251:
1
2

  $row = $site_db->query_firstrow();

to
1
2

  $row = $site_db->query_firstrow($sql);
Logged

cheers
Nicky
Your first three "must do" before you ask a question ! (© by V@no)
- please read the Forum Rules ...
- please study the FAQ ...
- please try to Search for your answer ...

nicky.net 4 4images
Signature stolen from mawenzi
Jan
Administrator
4images Guru
*****
Offline Offline

Posts: 5024

Thank You
-Given: 0
-Receive: 31


View Profile WWW
« Reply #2 on: June 16, 2002, 11:29:38 PM »

What PHP Version are exactly running? Can you post a URL?

Greets Jan
Logged

Your first three "must do" before you ask a question:
1. Forum rules
2. FAQ
3. Search
Alain
Newbie
*
Offline Offline

Posts: 24

Thank You
-Given: 0
-Receive: 0


View Profile
« Reply #3 on: June 16, 2002, 11:36:45 PM »

apache 1.3.24 - php 4.2.0

Also I have corrected at the line 251 the appropriate file but what is the meaning of this :

Top 5 images by hits (Total: 359)

when I have :

Top 5 categories by hits (Total: 56)

I can't unfortunately post the URL as it is an intranet site.

Thanks!

AL
Logged
Nicky
Administrator
4images Guru
*****
Offline Offline

Posts: 3195

Thank You
-Given: 26
-Receive: 57


View Profile
« Reply #4 on: June 16, 2002, 11:39:14 PM »

TOP 5 viewed Categories
TOP 5 viewed Images
Logged

cheers
Nicky
Your first three "must do" before you ask a question ! (© by V@no)
- please read the Forum Rules ...
- please study the FAQ ...
- please try to Search for your answer ...

nicky.net 4 4images
Signature stolen from mawenzi
Alain
Newbie
*
Offline Offline

Posts: 24

Thank You
-Given: 0
-Receive: 0


View Profile
« Reply #5 on: June 16, 2002, 11:42:08 PM »

In the download.php :

  $file_size = filesize($file_path);
    $fp = fopen($file_path, "r");
    if ($fp) {
      $file_data = fread($fp, $file_size);
      fclose($fp);
    }

$file_size is OK

  if (eregi("MSIE", getenv("HTTP_USER_AGENT"))) {
    $disposition = ($action != "zip" && $action != "lightbox") ? 'attachment' : 'inline';
    header("Content-Disposition: $disposition; filename=".$file['file_name']."\n");
    header("Content-Type: application/x-ms-download\n");
    header("Cache-Control: must-revalidate, post-check=0, pre-check=0");
    header("Pragma: public");
  }
  elseif (eregi("Opera", getenv("HTTP_USER_AGENT"))) {
    header("Content-Disposition: attachment; filename=".$file['file_name']."\n");
    header("Content-Type: application/octetstream\n");
    header("Cache-Control: no-cache");
    header("Pragma: no-cache");
  }
  else {
    header("Content-Disposition: attachment; filename=".$file['file_name']."\n");
    header("Content-Type: application/octet-stream\n");
    header("Cache-Control: no-cache");
    header("Pragma: no-cache");
  }
  header("Last Modified: ".gmdate("D, d M Y H:i:s")."GMT\n");
  header("Expires: 0\n");
  header("Content-Length: ".$file['file_size']."\n");

  if (eregi("Mac", getenv("HTTP_USER_AGENT"))) {
    header("Content-Transfer-Encoding: binary\n");
    header("Accept-Ranges: bytes\n");
    header("Connection: close\n");
  }
  echo $file['file_data'];

$file['file_size'] is corresponding to the file size that I've downloaded so it means that we may just need to replace this incorrect value (between 0-1000 bytes) by the correct value (above) which is between (1000-100000 bytes) - the correct file size - for the browser.

I hope it will help! Smile

AL
Logged
Jan
Administrator
4images Guru
*****
Offline Offline

Posts: 5024

Thank You
-Given: 0
-Receive: 31


View Profile WWW
« Reply #6 on: June 16, 2002, 11:42:18 PM »

Hmm..hard to say from here. Can you put a copy of our phpinfo() on the net? Or mail me the copy to jan@4homepages.de

Greets Jan
Logged

Your first three "must do" before you ask a question:
1. Forum rules
2. FAQ
3. Search
Alain
Newbie
*
Offline Offline

Posts: 24

Thank You
-Given: 0
-Receive: 0


View Profile
« Reply #7 on: June 16, 2002, 11:50:42 PM »

http://perso.wanadoo.fr/myserver/phpinfo.htm
Logged
Alain
Newbie
*
Offline Offline

Posts: 24

Thank You
-Given: 0
-Receive: 0


View Profile
« Reply #8 on: June 16, 2002, 11:58:46 PM »

I may not understand 'cause I worked hard today but...

Top 5 categories by hits (Total: 60)

X = 43
Y = 17

Top 5 images by hits (Total: 490)

A = 17
B = 10
C = 8
D = 8
E = 8
F = 8

490 isn't incorrect???
Logged
Nicky
Administrator
4images Guru
*****
Offline Offline

Posts: 3195

Thank You
-Given: 26
-Receive: 57


View Profile
« Reply #9 on: June 17, 2002, 12:03:38 AM »

Top 5 images by hits (Total: 490)

First 5:
A = 17
B = 10
C = 8
D = 8
E = 8

Others:
F = 8
G = 15
I = 44
J = 7
......

= Total 490
Logged

cheers
Nicky
Your first three "must do" before you ask a question ! (© by V@no)
- please read the Forum Rules ...
- please study the FAQ ...
- please try to Search for your answer ...

nicky.net 4 4images
Signature stolen from mawenzi
Alain
Newbie
*
Offline Offline

Posts: 24

Thank You
-Given: 0
-Receive: 0


View Profile
OK
« Reply #10 on: June 17, 2002, 12:11:49 AM »

OK, I have also checked the appropriate table and I was just surprised by the number of hits encountered for the pictures  Wink

Just that download thing which is I think not so hard to solve  Twisted Evil
Logged
Jan
Administrator
4images Guru
*****
Offline Offline

Posts: 5024

Thank You
-Given: 0
-Receive: 31


View Profile WWW
« Reply #11 on: June 17, 2002, 07:54:10 AM »

Hmmm.....no idea at the moment. I think you have to test a little bit around with the headers.

I think $file['file_size'] should be correct. The value is set here:

1
$file['file_size'] = strlen($file['file_data']);


Try to remove:

1
header("Content-Length: ".$file['file_size']."\n");


Or maybe try to remove the \n in the header functions.
1
header("Content-Type: application/x-ms-download[b][color=red]\n[/color][/b]");


Greets Jan
Logged

Your first three "must do" before you ask a question:
1. Forum rules
2. FAQ
3. Search
Alain
Newbie
*
Offline Offline

Posts: 24

Thank You
-Given: 0
-Receive: 0


View Profile
« Reply #12 on: June 17, 2002, 02:02:23 PM »

$file['file_size']  is reporting the wrong value : never more than 1000 bytes but I tried to indicate the file size instead of this variable for the content-length but still the final file is incorrect and the downloaded file is not usable. The problem is the same with Netscape.
Logged
Jan
Administrator
4images Guru
*****
Offline Offline

Posts: 5024

Thank You
-Given: 0
-Receive: 31


View Profile WWW
« Reply #13 on: June 17, 2002, 02:25:00 PM »

Try this:

Replace in download.php

1
$fp = fopen($file_path, "r");

with

1
$fp = fopen($file_path, "rb");


Greets Jan
Logged

Your first three "must do" before you ask a question:
1. Forum rules
2. FAQ
3. Search
Alain
Newbie
*
Offline Offline

Posts: 24

Thank You
-Given: 0
-Receive: 0


View Profile
« Reply #14 on: June 17, 2002, 02:28:17 PM »

I will try this, however, you can reproduce the workflow with http://www.easyphp.org/?lang=en - EasyPHP 1.6 which is installing Apache+PHP+MySQL under Windows 2000.
Logged
Pages: [1] 2 » »» Print 
« previous next »
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF | SMF © 2015, Simple Machines Valid XHTML 1.0! Valid CSS!
Page created in 0.091 seconds with 19 queries.
Post your comments here