Welcome to the E-Blah Community!
We would like to welcome you to our community and invite you to register an account or login.
Being a registered member is important, as it gives you several advantages over the normal Guest status. After registering you will be able to download files and images, post messages, and access member-only portions of the forum - just to name a few. Registration is quick and simple, and only takes about a minute of your time.

E-Blah Community    Modifications    Modification Archive  ›  File renaming? Moderators: 10 Series Support Team
Users Browsing Forum
No Members and 1 Guests

File renaming?  This thread currently has 2,274 views. Print
2 Pages 1 2 » Recommend Thread
BigC
January 27, 2003, 7:17am Report to Moderator Report to Moderator

E-Blah Member
Posts: 76
Gender: Male
Posts Per Day: 0.04
Reputation: 20.00%
Location: Atlanta GA
Age: 23
Hi Justin,

I got one for you LOL;) Is there a mod that will rename files that are uploaded to the board to maybe a ramdom number?
Logged Offline
Private Message Private message
Justin
January 27, 2003, 6:21pm Report to Moderator Report to Moderator

The E-Blah Developer
E-Blah Programmer
Posts: 15,075
Gender: Male
Posts Per Day: 6.52
Reputation: 93.40%
Reputation Score: +297 / -21
Time Online: 36 days 23 hours 27 minutes
Location: Tallassee, AL
Age: 22
lol


It could be done.    Maybe someone would do this EASY one.



- Justin


I do installs for $25 and upgrades for $20.
Technical support is always free.

  Donate to E-Blah!  

My Websites: Revolution Reality (My Blog)  |  MinistryTalk.com  |  Portfolio

"But you, O Lord, are a compassionate and gracious God, slow to anger, abounding in love and faithfulness." — Psalm 86:15 NIV

Logged Offline
Site Site Private Message Private message Reply: 1 - 18
DeathBox
January 27, 2003, 7:58pm Report to Moderator Report to Moderator

Official Grammar Nazi
Posts: 326
Gender: Male
Posts Per Day: 0.14
Reputation: 57.14%
Reputation Score: +4 / -3
Location: Prince George, BC, Canada
Age: 18
I can do it I just wanna know more into detail about what you want. How many digits should the number be, and such. Also, what your planning for the mod may help but is very optional



“Before God we are all equally wise - and equally foolish.”
                                           -- Albert Einstein
Logged Offline
Private Message Private message AIM AIM Windows Live Messenger WLM Reply: 2 - 18
BigC
January 27, 2003, 7:59pm Report to Moderator Report to Moderator

E-Blah Member
Posts: 76
Gender: Male
Posts Per Day: 0.04
Reputation: 20.00%
Location: Atlanta GA
Age: 23
Justin,

Is it really easy? or are you just playing with me If it is could you just tell me where to start.
Logged Offline
Private Message Private message Reply: 3 - 18
BigC
January 27, 2003, 8:09pm Report to Moderator Report to Moderator

E-Blah Member
Posts: 76
Gender: Male
Posts Per Day: 0.04
Reputation: 20.00%
Location: Atlanta GA
Age: 23
Cool man,

I just need it to a ten digit number. Well what i am looking for the mod to do is to rename the file so when the user uploads the file they wont get that error.
(The file you have tried to upload already exists on this server. Please rename it and try again.) I would like the board to do that for them. If that makes sense
Logged Offline
Private Message Private message Reply: 4 - 18
DeathBox
January 27, 2003, 8:19pm Report to Moderator Report to Moderator

Official Grammar Nazi
Posts: 326
Gender: Male
Posts Per Day: 0.14
Reputation: 57.14%
Reputation Score: +4 / -3
Location: Prince George, BC, Canada
Age: 18
Oh, its that easy, but requires a decent knowledge of perl. Ill explain some and let you do some of the dirty work

find this line:

   $savedfile = "$uploaddir/$fname";

In Perl, to put random numbers, you do, int(rand(<max number, starting at zero>)); if you want a number that starts at a certain number, and ends at the random paramater, you do int(rand(1200))+100;(say if i wanted to goto 100 to 1200)
so, before that one line, put
   $random = int(rand(99999))+100000;
Thats only saying whether you want a number anywhere from 99999-199999.
replace the:

   $savedfile = "$uploaddir/$fname";

with:

   $savedfile = "$fname";

with something else (Not gonna give that away if you wanna do it yourself.) To replace stuff (which youll need to do to get the .type of the file), you do the variable, in this case $fname you do the variable, with an equals and a tilde, almost as if you were to declare it like
   $fname =~
and then, youd do a /<find>/<replace/ after that. also, youd do a gi; to ignore case(i) and search all (g) like

   $fname =~ /<find>/<replace>/gi;

and so, in the find are, you can search for paramaters, a bit more complicated to understand for some. to place a paramater, youd do a (+.?) in the find area. like (+.?).(+.?) to get a filename, because you only wanna get the end of the file, but also wanna replace the actual name. In the replace area, to get a paramater, youd use a variable from $1 to $however-many-paramaters, in this case all you want is the second one. Thats all im giving out for now



“Before God we are all equally wise - and equally foolish.”
                                           -- Albert Einstein
Logged Offline
Private Message Private message AIM AIM Windows Live Messenger WLM Reply: 5 - 18
DeathBox
January 27, 2003, 8:27pm Report to Moderator Report to Moderator

Official Grammar Nazi
Posts: 326
Gender: Male
Posts Per Day: 0.14
Reputation: 57.14%
Reputation Score: +4 / -3
Location: Prince George, BC, Canada
Age: 18
better yet, above sub Upload { put:

sub Radomize {
  $random = int(rand(9999999999));
}

and replace:

   if(-e "$savedfile") { &error($atext[3]); }

with:

   if(-e "$savedfile") { &Randomize; }



“Before God we are all equally wise - and equally foolish.”
                                           -- Albert Einstein
Logged Offline
Private Message Private message AIM AIM Windows Live Messenger WLM Reply: 6 - 18
BigC
January 27, 2003, 8:39pm Report to Moderator Report to Moderator

E-Blah Member
Posts: 76
Gender: Male
Posts Per Day: 0.04
Reputation: 20.00%
Location: Atlanta GA
Age: 23
Man JediWannaB,

You are a true master LOL Thanks so much man. It all looks like Chinese but I am going to give it my best. Wish me luck;D
Logged Offline
Private Message Private message Reply: 7 - 18
BigC
January 27, 2003, 8:41pm Report to Moderator Report to Moderator

E-Blah Member
Posts: 76
Gender: Male
Posts Per Day: 0.04
Reputation: 20.00%
Location: Atlanta GA
Age: 23
One quick ?. Do I do this in the post.pl or the attach.pl?
Logged Offline
Private Message Private message Reply: 8 - 18
DeathBox
January 27, 2003, 8:57pm Report to Moderator Report to Moderator

Official Grammar Nazi
Posts: 326
Gender: Male
Posts Per Day: 0.14
Reputation: 57.14%
Reputation Score: +4 / -3
Location: Prince George, BC, Canada
Age: 18
My bad . Attach.pl sry



“Before God we are all equally wise - and equally foolish.”
                                           -- Albert Einstein
Logged Offline
Private Message Private message AIM AIM Windows Live Messenger WLM Reply: 9 - 18
BigC
January 27, 2003, 9:00pm Report to Moderator Report to Moderator

E-Blah Member
Posts: 76
Gender: Male
Posts Per Day: 0.04
Reputation: 20.00%
Location: Atlanta GA
Age: 23
Thanks again man
Logged Offline
Private Message Private message Reply: 10 - 18
DeathBox
January 27, 2003, 9:52pm Report to Moderator Report to Moderator

Official Grammar Nazi
Posts: 326
Gender: Male
Posts Per Day: 0.14
Reputation: 57.14%
Reputation Score: +4 / -3
Location: Prince George, BC, Canada
Age: 18
Actually, im pretty sure that might not be accurate at making sure it will do another name.

instead of the sub Randomize thing, do

sub Reroll {
&Randomize;
}
sub Radomize {
  $random = int(rand(9999999999));
  if (-e "$savedfile") { &Reroll; }
}

Try testing to see if the script works



“Before God we are all equally wise - and equally foolish.”
                                           -- Albert Einstein
Logged Offline
Private Message Private message AIM AIM Windows Live Messenger WLM Reply: 11 - 18
BigC
January 28, 2003, 12:13pm Report to Moderator Report to Moderator

E-Blah Member
Posts: 76
Gender: Male
Posts Per Day: 0.04
Reputation: 20.00%
Location: Atlanta GA
Age: 23
So should it be set up like this?
Code
sub Reroll {
&Randomize;
}
sub Radomize {
  $random = int(rand(9999999999));
  if (-e "$savedfile") { &Reroll; }
}

sub Upload {
   if($uallow == 0 && (!$avupload && $URL{'v'} ne 'profile')) { &error($atext[1]); }
   if($uallow == 2 && $username eq 'Guest') { &error($atext[55]); }
   if($uallow == 3 && $settings[4] ne 'Administrator') { &error($atext[56]); }
   $fname = lc($FORM{'ulfile'});
   $fname =~ s/.+\\([^\\]+)$|.+\/([^\/]+)$/$1/;
   $fname =~ s/^.*(\\|\/)//;
   $fname =~ s/ /_/g;
   $fname =~ s/[#%+,\\\/:?"<>'|@^\$\&~'\)\(\]\[\;{}!`=-]//g;
   if($fname eq '.htaccess') { &error($atext[5]); }

   $uploadz = new CGI;
   $file = $uploadz->param("ulfile");
   $tmpfile = $uploadz->tmpFileName($file);

   if($allowedext ne '') {
      $fnchk = $fname;
      $fnchk =~ s/(.+?)[(.)]/$2/gsi;

      @allowed = split(",",$allowedext);
      foreach(@allowed) {
         if($fnchk eq lc("$_")) { $okay = 1; last; }
      }
      foreach(@allowed) { $aup .= "$_, "; }
      $aup =~ s/, \Z//i;
      if($okay != 1) { &error("$atext[2] $aup"); }
   }

   $savedfile = "$fname";
   if(-e "$savedfile") { &Reroll; }
Logged Offline
Private Message Private message Reply: 12 - 18
DeathBox
January 28, 2003, 5:15pm Report to Moderator Report to Moderator

Official Grammar Nazi
Posts: 326
Gender: Male
Posts Per Day: 0.14
Reputation: 57.14%
Reputation Score: +4 / -3
Location: Prince George, BC, Canada
Age: 18
not exactly, once i get back on my own comp, ill give you the actual code, on some parts you copied exactly what i said, in which case i meant it for you to try putting in your own values and such.



“Before God we are all equally wise - and equally foolish.”
                                           -- Albert Einstein
Logged Offline
Private Message Private message AIM AIM Windows Live Messenger WLM Reply: 13 - 18
Justin
January 28, 2003, 5:56pm Report to Moderator Report to Moderator

The E-Blah Developer
E-Blah Programmer
Posts: 15,075
Gender: Male
Posts Per Day: 6.52
Reputation: 93.40%
Reputation Score: +297 / -21
Time Online: 36 days 23 hours 27 minutes
Location: Tallassee, AL
Age: 22
NO NO!!!!  It should be done using a time stamp, they are the hardest to make two of.  So, let me get you that. 

Find:
Code
   if($allowedext ne '') {
      $fnchk = $fname;
      $fnchk =~ s/(.+?)[(.)]/$2/gsi;

      @allowed = split(",",$allowedext);
      foreach(@allowed) {
         if($fnchk eq lc("$_")) { $okay = 1; last; }
      }
      foreach(@allowed) { $aup .= "$_, "; }
      $aup =~ s/, \Z//i;
      if($okay != 1) { &error("$atext[2] $aup"); }
   }



Replace that with:
Code
   $fnchk = $fname;
   $fnchk =~ s/(.+?)[(.)]/$2/gsi;

   if($allowedext ne '') {
      @allowed = split(",",$allowedext);
      foreach(@allowed) {
         if($fnchk eq lc("$_")) { $okay = 1; last; }
      }
      foreach(@allowed) { $aup .= "$_, "; }
      $aup =~ s/, \Z//i;
      if($okay != 1) { &error("$atext[2] $aup"); }
   }

   $fname = time.'.'.$fnchk;



It works, tested this one. 


I do installs for $25 and upgrades for $20.
Technical support is always free.

  Donate to E-Blah!  

My Websites: Revolution Reality (My Blog)  |  MinistryTalk.com  |  Portfolio

"But you, O Lord, are a compassionate and gracious God, slow to anger, abounding in love and faithfulness." — Psalm 86:15 NIV

Logged Offline
Site Site Private Message Private message Reply: 14 - 18
2 Pages 1 2 » Recommend Thread
Print

E-Blah Community    Modifications    Modification Archive  ›  File renaming?