|
|
BigC |
|
|
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? |
|
|
|
|
|
Justin |
|
|
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
|
|
|
|
|
|
DeathBox |
|
|
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 |
|
|
|
|
|
BigC |
|
|
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.  |
|
|
|
|
|
BigC |
|
|
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  |
|
|
|
|
|
DeathBox |
|
|
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 |
|
|
|
|
|
DeathBox |
|
|
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 |
|
|
|
|
|
BigC |
|
|
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 |
|
|
|
|
|
BigC |
|
|
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? |
|
|
|
|
|
DeathBox |
|
|
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 |
|
|
|
|
|
BigC |
|
|
Posts: 76
Gender:  Male
Posts Per Day: 0.04
Reputation: 20.00%
Location: Atlanta GA
Age: 23
|
Thanks again man  |
|
|
|
|
|
DeathBox |
|
|
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 |
|
|
|
|
|
BigC |
| January 28, 2003, 12:13pm |
|
|
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; } |
|
|
|
|
|
|
|
DeathBox |
|
|
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 |
|
|
|
|
|
Justin |
|
|
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  |
|
|
|
|
|
|