All pastes #609130 Raw Edit

Miscellany

public text v1 · immutable
·published 2007-07-08 18:10 UTC
rendered paste body
<?php
$Types = array();
$Types['Music'] = array('Music', 'aac', 'aif', 'iff', 'm3u', 'mid', 'midi', 'mp3', 'mpa', 'ra', 'ram', 'wav', 'ogg', 'wma', 'm4a', 'aiff', 'wav', 'm4p');
$Types['Video'] = array('Video', 'asf', 'asx', 'avi', 'mov', 'mp4', 'mpg', 'mpeg', 'qt', 'rm', 'wmv');
$Types['Images'] = array('Images', '3df', '3dm', 'ai', 'bmp', 'drw', 'eps', 'gif', 'indd', 'jpg', 'jpeg', 'mng', 'pct', 'png', 'ps', 'psd', 'psp', 'qxd', 'qxp', 'svg', 'tif', 'tiff');
$Types['Documents']   = array('Documents', 'doc', 'log', 'msg', 'rtf', 'txt', 'wpd', 'wps', 'odt', 'abw');

foreach (scandir('/home/m/') as $i) {
    if ($i == '.' or $i == '..' or is_dir("/home/m/$i") ){ continue; }
    $arg =array(); $arg = explode(".", $i, 2);
    $files[] = array($arg[0], $arg[1]);
}

foreach ($files as $file) {
    foreach($Types as $type) {
        if (in_array($file[count($file)-1], $type)) {
            rename("/home/m/".join('.', $file), "/home/m/public_html/$type[0]/".join('.', $file));
        }
    }
}


foreach(scandir('.') as $i ){
    if ($i == '.' or $i == '..' or $i == 'index.php'){ continue;}
    if (is_dir($i)) {
        print "<a href=\"$i\"><h3>$i</h3></a>";
        $counter = 0;
        foreach(scandir($i) as $file) { 
            if ($file == '.' or $file == '..' or $file == 'index.php'){ continue; }
            $counter++;
        }
        if ($counter == 1) {
            print "<p>1 file</p></br>";
        } else {
            print "<p>$counter files</p></br>";
        }
    }
}
?>

<html>
<!-- Start of StatCounter Code -->
<script type="text/javascript" language="javascript">
var sc_project=2719036; 
var sc_invisible=0; 
var sc_partition=27; 
var sc_security="a615c312"; 
</script>
<script type="text/javascript" language="javascript" src="http://www.statcounter.com/counter/counter.js"></script><noscript><a href="http://www.statcounter.com/" target="_blank"><img  src="http://c28.statcounter.com/counter.php?sc_project=2719036&java=0&security=a615c312&invisible=0" alt="website metrics" border="0"></a> </noscript>
<!-- End of StatCounter Code -->
</html>