Example #1
0
function readAllDirs($dirName, &$readCtr, &$mainArray, $searchExt = "false", $displayProgress = "false")
{
    // Let's up the max_execution_time
    ini_set('max_execution_time', '600');
    // Let's look at the directory we are in
    if (is_dir($dirName)) {
        $d = dir($dirName);
        while ($entry = $d->read()) {
            // Let's make sure we are seeing real directories
            if ($entry == "." || $entry == "..") {
                continue;
            }
            // Now let's see if we are looking at a directory or not
            if (filetype($dirName . "/" . $entry) != "file") {
                // Ok, that was a dir, so let's move to the next directory down
                readAllDirs($dirName . "/" . $entry, $readCtr, $mainArray, $searchExt, $displayProgress);
            } else {
                $mainArray[$readCtr] = $dirName . "/" . $entry;
                $readCtr++;
            }
        }
        // Now let's close the directory
        $d->close();
        // Now let's sort that array
        @sort($mainArray);
    }
    // Ok, let's return the data
    return $mainArray;
}
Example #2
0
function readAllDirs($dirName, &$readCtr, &$mainArray, $searchExt = "false", $displayProgress = "false")
{
    global $audio_types, $video_types;
    // Let's up the max_execution_time
    ini_set('max_execution_time', '600');
    // Let's look at the directory we are in
    if (is_dir($dirName)) {
        $d = dir($dirName);
        while ($entry = $d->read()) {
            // Let's make sure we are seeing real directories
            if ($entry == "." || $entry == "..") {
                continue;
            }
            // Now let's see if we are looking at a directory or not
            if (filetype($dirName . "/" . $entry) != "file") {
                // Ok, that was a dir, so let's move to the next directory down
                readAllDirs($dirName . "/" . $entry, $readCtr, $mainArray, $searchExt, $displayProgress);
            } else {
                // Let's see if they wanted status
                if ($displayProgress == "true") {
                    if ($readCtr % 50 == 0) {
                        echo '.';
                        flushDisplay();
                    }
                }
                // Let's see if we want to search a specfic extension or not
                if ($searchExt == "false") {
                    // Ok, we found files, let's make sure they are audio or video files
                    if (preg_match("/\\.({$audio_types})\$/i", $entry) or preg_match("/\\.({$video_types})\$/i", $entry)) {
                        $mainArray[$readCtr] = $dirName . "/" . $entry;
                        $readCtr++;
                    }
                } else {
                    if (stristr($entry, $searchExt) or $searchExt == "true") {
                        $mainArray[$readCtr] = $dirName . "/" . $entry;
                        $readCtr++;
                    }
                }
            }
        }
        // Now let's close the directory
        $d->close();
        // Now let's sort that array
        @sort($mainArray);
    }
    // Ok, let's return the data
    return $mainArray;
}
Example #3
0
// first let's include all the functions and stuff we'll need
$include_path = str_replace("/extras", "", dirname(__FILE__)) . "/";
include_once '../settings.php';
include_once '../system.php';
include_once '../lib/general.lib.php';
include_once '../services/class.php';
$jzSERVICES = new jzServices();
$jzSERVICES->loadService("metadata", "amazon");
// Now let's see if they submitted the form
if (isset($_POST['migrate'])) {
    echo '<br><strong>Beginning reorg of media, please stand by, this could take a while...</strong><br><br>';
    echo "Scanning files";
    flushdisplay();
    // Let's read all the files into a big array
    $readCtr = 0;
    $retArray = readAllDirs($_POST['path'], $readCtr, $retArray, "false", "true", "false");
    echo "<br>";
    $master = "|||";
    // Let's look at each file one by one to see what to do with it
    foreach ($retArray as $item) {
        // Let's strip the full path so we'll have just what we need
        $data = str_replace($_POST['path'] . "/", "", $item);
        // Now using our settings let's figure out what we're looking at
        // First we'll split the directories apart
        $info = explode("/", $data);
        $artist = $info[0];
        $album = $info[1];
        $track = $info[2];
        // Have we looked at this artist before?
        if (!strstr($master, $artist)) {
            // Now let's create our array to pass to the amazon service
Example #4
0
		</form>
		<?php 
    exit;
}
// Ok, let's get on with it
// We'll need to include a few thigns
include_once '../settings.php';
include_once '../lib/general.lib.php';
include_once '../services/class.php';
// First let's clean up their media dir
$media_dir = $_POST['media_dir'];
$media_dir = str_replace("//", "/", str_replace("\\", "/", $media_dir));
// Now let's read each file under there
echo "Reading all files in: " . $media_dir . ", please wait this might take quite a while...<br>";
$readCtr = 0;
$retArray = readAllDirs($media_dir, &$readCtr, &$retArray, "false", "true");
echo "<br>" . count($retArray) . " files read, processing...<br>";
// Let's connect to the database
mysql_connect($dbhost, $dbuser, $dbpass);
mysql_select_db($dbname);
// Let's load up our services
$jzSERVICES = new jzServices();
$jzSERVICES->loadStandardServices();
foreach ($retArray as $file) {
    // Let's read the meta data from the file
    $meta = $jzSERVICES->getTagData($file);
    // Let's insert into Genres
    $query = 'insert into jz_genres (Name) values ("' . $meta['genre'] . '")';
    mysql_query($query);
    // Now let's get the ID for that genre
    $query = 'select ID from jz_genres where Name = "' . $meta['genre'] . '"';