Example #1
0
function myscan(&$arr, $dir)
{
    $cont = glob($dir . "/*");
    // echo "myscan";
    foreach ($cont as $file) {
        if (is_dir($file)) {
            if ($file != '.' && $file != '..') {
                myscan($arr, $file);
            }
        } else {
            if (strpos($file, ".mp3") != false) {
                $tags = mp3tags($file);
                // print_r($tags);
                $artist = $tags["ARTISTS"];
                $filename = substr($file, DIR_CUT_COUNT);
                $filename = iconv("windows-1251", "UTF-8", $filename);
                $artist = iconv("windows-1251", "UTF-8", $tags["ARTISTS"]);
                $album = iconv("windows-1251", "UTF-8", $tags["ALBUM"]);
                $title = iconv("windows-1251", "UTF-8", $tags["NAME"]);
                $genre = getGenre($tags["GENRENO"]);
                $year = $tags["YEAR"];
                $cover = substr(dirname($file) . "/cover.jpg", DIR_CUT_COUNT);
                $cover = substr(dirname(iconv("windows-1251", "UTF-8", $file)) . "/cover.jpg", DIR_CUT_COUNT);
                $filename = mysql_real_escape_string($filename);
                $artist = mysql_real_escape_string($artist);
                $album = mysql_real_escape_string($album);
                $title = mysql_real_escape_string($title);
                $cover = mysql_real_escape_string($cover);
                //записываем в базу данных
                $sql = "insert into " . MUSIC_TABLE . " (artist,albums,tracks,filename,cover,genre,year) values \n\t\t\t\t('{$artist}','{$album}','{$title}','{$filename}','{$cover}','{$genre}','{$year}')";
                $q = mysql_query($sql) or die(mysql_error());
                echo "{$artist}|{$album}|{$title}|{$genre}|{$year}<br>{$filename}";
                echo "<hr><br>";
            }
        }
    }
}
Example #2
0
for ($i = 0; $i < $countdata; $i++) {
    $oldname[$i] = stripslashes($oldname[$i]);
}
//echo "<script>alert('$countdata');</script>";
//echo "<script>alert('new = $newname');</script>";
//echo "<script>alert('old = $oldname');</script>";
$root = "/tmp/usbmounts";
// this will the the root position of this script
//Set our root position and make sure the URL input is not manually manipulated
if (substr($_GET['dir'], 0, 2) != '/.' and substr($_GET['dir'], 0, 1) != '.' and $_GET['dir'] != '') {
    $mydir = $root . $_GET['dir'];
} else {
    $mydir = $root;
}
//Get and sort the directory listing
$files = myscan($mydir);
sort($files);
//Common functions used
function myscan($dir)
{
    $arrfiles = array();
    $arrfiles = opendir($dir);
    while (false !== ($filename = readdir($arrfiles))) {
        $files[] = $filename;
    }
    return $files;
}
$exist = 0;
for ($x = 0; $x < sizeof($files); $x++) {
    if ($files[$x] != '.' and $files[$x] != ".." and $files[$x] != "Recycled" and $files[$x] != "System Volume Information" and substr($files[$x], 0, 1) != "." and $files[$x] != "lost+found") {
        if (strtolower($mediapath . "/" . $files[$x]) == strtolower($newname)) {