All Good Things Must Come To An End

As you all know, I have been doing WordPress plugins and supporting it for the past 6 years. These 6 years of my life, I have been through my polytechnic education, my national service as well as my university education.

I just graduated from university in December 2009 and have been looking for full-time jobs. I am offered a full-time job and will be starting work on 1st February 2010.

I regret to say that I am NOT ABLE to provide support for my plugins anymore due to my full-time job commitment. I will leave this forum open and let the community help one another.

However, I WILL still update my plugins whenever I can and you still can report bugs to me via email and I will try to fix it.


Author Topic: Editing a file messes up filesize?  (Read 12678 times)

0 Members and 1 Guest are viewing this topic.

Offline cdehmer

  • Newbie
  • *
  • Posts: 4
    • View Profile
Re: Editing a file messes up filesize?
« Reply #20 on: 15 April 2008, 22:15 »
Re. checkbox, I guess what I had pictured is that when the form opens with non-zero entry in the size box (like when you Edit a file), the box should be unchecked. If it opens with blank or zero (like when you Add File), it should be checked. I'm just not sure if that can be done in the code.

Right now, every time I Edit a file, I have to remember to uncheck the box, or I end up blowing away the correct size.

Of course, you've thought a whole lot more about this program than I have in the few hours I've been working with it.  :)

Offline GaMerZ

  • lesterchan.net
  • Administrator
  • *****
  • Posts: 11,536
    • View Profile
  • WordPress Version: WordPress 2.9.x
  • Theme Name: lesterchan.net v3.4
Re: Editing a file messes up filesize?
« Reply #21 on: 16 April 2008, 09:11 »
I will see if I can improve the UI of it because currently in the edit file page, user can choose to upload a new file and hence it will have a new file size if that happens

++ lesterchan.net - Lester Chan's Website

I regret to say that I am not able to provide support for my plugins anymore due to my full-time job commitment. I will leave this forum open and let the community help one another.

Offline Samutz

  • Newbie
  • *
  • Posts: 8
    • View Profile
Re: Editing a file messes up filesize?
« Reply #22 on: 30 April 2008, 15:59 »
This was bugging me so I looked in to it and made my own fix for it.
The problem is that when editing a a file, if "Current File" is selected (rather than Browse File, Upload File, and Remote File), the form processor doesn't check the filesize (does not set $file_size). And this causes it to set the file_size to 0 in the database (unless Auto Detect is unchecked, in that case code later in the script sets $file_size to what was entered in the field.).

Here's my fix:

In /wp-content/plugins/download-manager.php

Find (around line 116):
Code: [Select]
case -1:
$file = $_POST['old_file'];
break;
Replace it with:
Code: [Select]
case -1:
$file = $_POST['old_file'];
if (is_remote_file($file)) {
$file = addslashes(trim($file));
$file_size = remote_filesize($file);
if ($file_size=="unknown") {
$file_size = 0;
}
} else {
$file_size = filesize($file_path.$file);
}
break;

Offline GaMerZ

  • lesterchan.net
  • Administrator
  • *****
  • Posts: 11,536
    • View Profile
  • WordPress Version: WordPress 2.9.x
  • Theme Name: lesterchan.net v3.4
Re: Editing a file messes up filesize?
« Reply #23 on: 30 April 2008, 16:02 »
nice one there, I think I will add in a hidden field to store the previous file size.

++ lesterchan.net - Lester Chan's Website

I regret to say that I am not able to provide support for my plugins anymore due to my full-time job commitment. I will leave this forum open and let the community help one another.

Offline Samutz

  • Newbie
  • *
  • Posts: 8
    • View Profile
Re: Editing a file messes up filesize?
« Reply #24 on: 30 April 2008, 16:12 »
I did that at first too:
Code: [Select]
$file_size = intval($_POST['old_file_size']);(old_file_size was a hidden field I put in the form).

But the files that had the wrong file_size from the previous problem would keep the wrong file_size rather than being truly auto-detected.

Edit:
Plus, in theory, if someone manually sets the file size, then later decides that they want it auto detected instead, then using the hidden field would just make it keep the old file size (the one that they want replaced with the auto-detected size).

Offline GaMerZ

  • lesterchan.net
  • Administrator
  • *****
  • Posts: 11,536
    • View Profile
  • WordPress Version: WordPress 2.9.x
  • Theme Name: lesterchan.net v3.4
Re: Editing a file messes up filesize?
« Reply #25 on: 30 April 2008, 16:32 »
nice point there, I will add this in after my exams.

++ lesterchan.net - Lester Chan's Website

I regret to say that I am not able to provide support for my plugins anymore due to my full-time job commitment. I will leave this forum open and let the community help one another.