WebmasterSite.net: PHP scripts to enable your creativity
WSN Links PHP Directory Software
PHP Scripts Webmaster Links Support Forums

Register | Forgot Password

Mass upload random naming
2.xx, Bug

Version: WSN Forum 1.00 Beta 3
printPrint


Mass upload random naming
Quantum
Forum Regular

Usergroup: Member
Joined: Jul 01, 2003
Total Topics: 39
Total Posts: 173
Posted 01/01/05 - 03:26 PM:
quote post
#1
- Attachment tree: On.

I used the mass upload option to upload a tar.gz file. The files were added to the correct index level and put into the main attachments directory. Everything alright sofar.

Now, when regenerating the files are moved to the correct directory. However, the files aren't randomly named, but still use the same names which they had in the tar.gz file.
Paul
Administrator
Avatar

Usergroup: Administrator
Joined: Dec 21, 2001
Location: Northern California
Total Topics: 55
Total Posts: 6027
Posted 01/03/05 - 03:07 PM:
quote post
#2
In filefunctions.php replace the findfilename function with this one:


function findfilename ($filename)

{

global $inadmindir, $settings, $switches;
$ext = extension($filename);
if ($settings->attachmentmethod != 'natural')
{
$randomname = md5(microtime()) . $ext;
if ($ext == 'php' || $ext == 'asp' || $ext == 'pl' || $ext == 'jsp' || $ext == 'cgi') $changedname = str_replace('.'. $ext, '.txt', $randomname);
else if ($settings->removeextensions == 'yes') $changedname = str_replace('.'. $ext, '.wsn', $randomname);
return $changedname;
}
$filename = strtolower($filename);

$filename = str_replace('(', '', $filename);

$filename = str_replace(')', '', $filename);

$filename = str_replace('/', '', $filename);

$filename = str_replace('\', '', $filename);

$filename = str_replace("'", '', $filename);

$filename = str_replace('" ', '', $filename);

$filename = str_replace(' ', '', $filename);
if ($ext == 'php' || $ext == 'asp' || $ext == 'pl' || $ext == 'jsp' || $ext == 'cgi') $changedname = str_replace('.'. $ext, '.txt', $filename);
else if ($settings->removeextensions == 'yes') $changedname = str_replace('.'. $ext, '.wsn', $filename);

if ($switches[attachmentstree]) { return traverseall($filename); }

else

{

if (!file_exists($settings->uploadpath . $filename) && !file_exists($settings->uploadpath .'avatars/'. $filename)) return $filename;

else

{

for ($x=0; $xuploadpath . $changedname) && !file_exists($settings->uploadpath .'avatars/'. $filename)) return $changedname;

}

}

}

die ("Couldn't find an unused name for $filename . There's got to be a bug in this script if you see this. (Find me in filefunctions.php)");

return true;

}

Haven't tested yet.

"Do things you love doing, because then it ain't work. Don't do something you don't really enjoy, because you're never going to work hard enough at it." - Bob Young, founder of Red Hat
Quantum
Forum Regular

Usergroup: Member
Joined: Jul 01, 2003
Total Topics: 39
Total Posts: 173
Posted 01/04/05 - 01:21 PM:
quote post
#3
Thanks.

Haven't tried it either as I managed to get FTP import to work for me.
Search thread for
Download thread as


You don't have permission to post.

Please login or register.

   
 
© 2008 Paul Knierim. All rights reserved.