Tuesday, December 18, 2007

Removing the Linux ext filelimit for scripts that do not circumvent that limit (like Mihalism multi host image hosting script)

With a few changes this will work on any script / system ofcourse, but it was done for Mihalism.

First you need to put all files in directories, go to the 'files' directory and run;

ls -la|awk '{print $8}'|perl -e 'while(<>){chomp; @a=split(//, $_);$d="";for($i=0;$i<5;$i++){$d.=@a[$i]."/"; print `mkdir $d`}; print `mv $_ $d`;}'

Then the code needs a bit of fixing;

open the file

source/global_functions.php

and add a function;

function calc_directory($file){
$dir = "";
for($i=0;$i<5;$i++) $dir .= $file[$i]."/";
return $dir;
}

then you need to fix all files that are calling the $path and $file to reflect the changed;

in the main directory of the script, run;

grep -R \$path.\$file *|awk '{print $1}'|uniq|perl -e 'while(<>){chomp; /^(.*):$/; $f=$1;$s=`cat $f`; $s=~s/\$path.\$filename/\$path.calc_directory\(\$filename\)/isgm; $s=~s/\$path.\$file/\$path.calc_directory\(\$file\)/isgm; open(F, ">$f"); print F $s; close F;}'

and then test; I had no time to test yet, but the idea should be clear enough.