Webmastersite.net
Register Log In

Mass upload random naming
2.xx, Bug

Comments on Mass upload random naming

Quantum
Forum Regular

Usergroup: Member
Joined: Jul 01, 2003

Total Topics: 38
Total Comments: 164
Quantum
Posted Jan 01, 2005 - 5:26 PM:

- 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
developer

Usergroup: Administrator
Joined: Dec 20, 2001
Location: Diamond Springs, California

Total Topics: 61
Total Comments: 7868
Paul
Posted Jan 03, 2005 - 5:07 PM:

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.
Quantum
Forum Regular

Usergroup: Member
Joined: Jul 01, 2003

Total Topics: 38
Total Comments: 164
Quantum
Posted Jan 04, 2005 - 3:21 PM:

Thanks.

Haven't tried it either as I managed to get FTP import to work for me.
Search thread for
Download thread as
  • 0/5
  • 1
  • 2
  • 3
  • 4
  • 5



This thread is closed, so you cannot post a reply.