Author Topic: Return ZIP File Size  (Read 12738 times)

0 Members and 1 Guest are viewing this topic.

Offline WeZ

  • Jr. Member
  • **
  • Posts: 72
    • View Profile
Return ZIP File Size
« on: October 30, 2007, 05:12:40 PM »
Hello all ye 4Images Boffins (and as always a special shout out to V@no)  :!:,

SUMMARY:
I need to get the Total MB size value of the Item downloaded from my 4Images.

DETAIL:
When a user clicks on the zip/File download icon, whether in Lightbox or Image Detail pages, i need to pull that file size of the zip as the items is available to download. i will use this value further down the php page in another SQL statement.

This request is very similar to your mod "User Image Download Counter" : download.php sends zip file to user and updates DB with image count - i will be doing the exact same except with Zip/File Total MB size in a different table.

The Result Value can be rounded off to the nearest whole integer with a minimum size of 1MB.

ENVIRONMENT:
4Images 1.7.2
Running on XAMPP (on Removable USB HD) running on WindowsXP, Windows2000 and Windows2003 (it often changes)
PHP 5.2.3
MySQL 5.0.45-community-nt

Thanking you in advance,
WeZ


Offline thunderstrike

  • 4images Guru
  • *******
  • Posts: 2.327
    • View Profile
Re: Return ZIP File Size
« Reply #1 on: October 30, 2007, 11:46:51 PM »
Quote
The Result Value can be rounded off to the nearest whole integer with a minimum size of 1MB.

And if result is more 1 MB ? (2 MB, 3 MB ... more ?)
8 steps need when ask question -

- PHP version (ACP - > phpinfo())
- mySQL version (ACP - > phpinfo())
- 4images version
- Post screenshot / URL
- Post code in BB Code (no need full file for code) or post attach file
- It doesn't work. What is say - what is do for no work
- Install MOD ? If so - please say (troubleshooting)
- Read FAQ ? Install Bug fixes ?

Offline WeZ

  • Jr. Member
  • **
  • Posts: 72
    • View Profile
Re: Return ZIP File Size
« Reply #2 on: October 30, 2007, 11:57:30 PM »
Hi Thunderstrike,

What i meant was:

if the zip file is 4.6MB in size, then i would like the result to be 5

if the zip file is 2.4MB in size, then i would like the result to be 2

if the zip file size is 800K in size, then i would like the result to be 1

Hope this answers your question and you will hopefully be able to help me...

Kind Regards,
Wesley...

Offline thunderstrike

  • 4images Guru
  • *******
  • Posts: 2.327
    • View Profile
Re: Return ZIP File Size
« Reply #3 on: October 31, 2007, 12:09:55 AM »
Ok so if is very similar to this MOD: "User Image Download Counter" - you can post in the topic for request this. ;)
Some edit is need for request. ;)
8 steps need when ask question -

- PHP version (ACP - > phpinfo())
- mySQL version (ACP - > phpinfo())
- 4images version
- Post screenshot / URL
- Post code in BB Code (no need full file for code) or post attach file
- It doesn't work. What is say - what is do for no work
- Install MOD ? If so - please say (troubleshooting)
- Read FAQ ? Install Bug fixes ?

Offline WeZ

  • Jr. Member
  • **
  • Posts: 72
    • View Profile
Re: Return ZIP File Size
« Reply #4 on: October 31, 2007, 02:27:11 AM »
Hi ThunderStrike,

i think it's very late/early on my side - but i cant find the MOD in the forums??

this is the code on my page:
Code: [Select]
  // Mod User Image Download Counter
  if ($user_info['user_id'] > GUEST) {
$lightboxes_count = explode(" ", trim($user_info['lightbox_image_ids']));
$lightboxes_count = count($lightboxes_count);
$sql = "UPDATE ".USERS_TABLE."
SET image_downloads = image_downloads+".$lightboxes_count."
WHERE ".get_user_table_field("",user_id)." = ".$user_info['user_id'];
  $site_db->query($sql);
  }
  // Mod User Image Download Counter


please can you either help me with finding the mod page, or lets help me in this thread...

the PHP function filesize() will apparently return the size of the specified file... now all i need is how to find the ZIP file location from the download.php file.

i tried:
Code: [Select]
$length = filesize($zipfile);
but it isn't working... please can you help me here?

Kind Regards,
Wesley

Offline thunderstrike

  • 4images Guru
  • *******
  • Posts: 2.327
    • View Profile
Re: Return ZIP File Size
« Reply #5 on: October 31, 2007, 02:45:36 AM »
Quote
now all i need is how to find the ZIP file location from the download.php file.

What you look in download.php file is: $file['file_name'] where $action == "zip" block. ;)
8 steps need when ask question -

- PHP version (ACP - > phpinfo())
- mySQL version (ACP - > phpinfo())
- 4images version
- Post screenshot / URL
- Post code in BB Code (no need full file for code) or post attach file
- It doesn't work. What is say - what is do for no work
- Install MOD ? If so - please say (troubleshooting)
- Read FAQ ? Install Bug fixes ?

Offline WeZ

  • Jr. Member
  • **
  • Posts: 72
    • View Profile
Re: Return ZIP File Size
« Reply #6 on: October 31, 2007, 09:49:37 AM »
Hi Thunderstrike,

thanks for the attempt - that value seems to pass the file name and not the zip location.

My value of $file['file_name'] was "080-001.jpg" and not a zip file...

Perhaps i need to pull the value from the Send function inside zip.php:
"$zipfile->send(get_file_name($file['file_name']).".zip");"

i will try doing that, unless you can tell me how to get the zip location from download.php

Kind Regards,
Wesley.

Offline thunderstrike

  • 4images Guru
  • *******
  • Posts: 2.327
    • View Profile
Re: Return ZIP File Size
« Reply #7 on: October 31, 2007, 11:13:22 AM »
Quote
how to get the zip location from download.php

Ok, now you find so - you need edit includes/zip.php file for this. ;)
8 steps need when ask question -

- PHP version (ACP - > phpinfo())
- mySQL version (ACP - > phpinfo())
- 4images version
- Post screenshot / URL
- Post code in BB Code (no need full file for code) or post attach file
- It doesn't work. What is say - what is do for no work
- Install MOD ? If so - please say (troubleshooting)
- Read FAQ ? Install Bug fixes ?

Offline WeZ

  • Jr. Member
  • **
  • Posts: 72
    • View Profile
Re: Return ZIP File Size
« Reply #8 on: October 31, 2007, 11:41:37 AM »
Yup, i think youre right...

so now i think i found the right place to do so, however i need to execute SQL statements within the zip.php file.

when i execute the command:
Code: [Select]
$site_db->query($sql);
i get this error:
Code: [Select]
Fatal error: Call to a member function query() on a non-object in F:\4images\includes\zip.php on line 166


Offline thunderstrike

  • 4images Guru
  • *******
  • Posts: 2.327
    • View Profile
Re: Return ZIP File Size
« Reply #9 on: October 31, 2007, 11:42:16 AM »
You no use $site_db object for global after function line.  :mrgreen:
8 steps need when ask question -

- PHP version (ACP - > phpinfo())
- mySQL version (ACP - > phpinfo())
- 4images version
- Post screenshot / URL
- Post code in BB Code (no need full file for code) or post attach file
- It doesn't work. What is say - what is do for no work
- Install MOD ? If so - please say (troubleshooting)
- Read FAQ ? Install Bug fixes ?

Offline WeZ

  • Jr. Member
  • **
  • Posts: 72
    • View Profile
Re: Return ZIP File Size
« Reply #10 on: October 31, 2007, 11:52:07 AM »
You no use $site_db object for global after function line.  :mrgreen:

Hmm, sorry but i'm not quite sure what you mean? There must be a way i can execut this command from the zip.php function?

Offline WeZ

  • Jr. Member
  • **
  • Posts: 72
    • View Profile
Re: Return ZIP File Size
« Reply #11 on: October 31, 2007, 12:17:57 PM »
Hi Thunderstrike,

i found that by adding:
Code: [Select]
global $site_db;

i can now execute SQL statements in the zip.php file...

Offline thunderstrike

  • 4images Guru
  • *******
  • Posts: 2.327
    • View Profile
Re: Return ZIP File Size
« Reply #12 on: October 31, 2007, 12:23:09 PM »
Bravo :!: ;)
8 steps need when ask question -

- PHP version (ACP - > phpinfo())
- mySQL version (ACP - > phpinfo())
- 4images version
- Post screenshot / URL
- Post code in BB Code (no need full file for code) or post attach file
- It doesn't work. What is say - what is do for no work
- Install MOD ? If so - please say (troubleshooting)
- Read FAQ ? Install Bug fixes ?

Offline WeZ

  • Jr. Member
  • **
  • Posts: 72
    • View Profile
Re: Return ZIP File Size
« Reply #13 on: October 31, 2007, 12:53:06 PM »
Hi Thunderstrike,

editing my zip.php wasnt first prize - i dont like editing my includes files.

i found the first prize !!

executing this command in download.php will return the zip file size in Bytes without any editing of zip.php:
Code: [Select]
$length = $zipfile->prepare();

thanks for your assistance.

Kind Regards,
Wesley.

Offline thunderstrike

  • 4images Guru
  • *******
  • Posts: 2.327
    • View Profile
Re: Return ZIP File Size
« Reply #14 on: October 31, 2007, 12:54:30 PM »
Thank for this.  8O
I no knew is use for ZIP output filename ...

[edit] - if do this - you execute 2 time the prepare function in this. ;)

$this->prepare() is in zip.php file for use. ;)
8 steps need when ask question -

- PHP version (ACP - > phpinfo())
- mySQL version (ACP - > phpinfo())
- 4images version
- Post screenshot / URL
- Post code in BB Code (no need full file for code) or post attach file
- It doesn't work. What is say - what is do for no work
- Install MOD ? If so - please say (troubleshooting)
- Read FAQ ? Install Bug fixes ?