コード例 #1
0
function resetDatabase()
{
    mp3act_connect();
    $query = array();
    $query[] = "TRUNCATE TABLE mp3act_songs";
    $query[] = "TRUNCATE TABLE mp3act_artists";
    $query[] = "TRUNCATE TABLE mp3act_albums";
    $query[] = "TRUNCATE TABLE mp3act_playlist";
    $query[] = "TRUNCATE TABLE mp3act_saved_playlists";
    $query[] = "TRUNCATE TABLE mp3act_genres";
    $query[] = "TRUNCATE TABLE mp3act_stats";
    $query[] = "TRUNCATE TABLE mp3act_playhistory";
    $query[] = "TRUNCATE TABLE mp3act_currentsong";
    foreach ($query as $q) {
        mysql_query($q);
    }
    $path = $GLOBALS['abs_path'] . "/art/";
    if (is_dir($path)) {
        if ($dh = opendir($path)) {
            while (($file = readdir($dh)) !== false) {
                if ($file != "." && $file != ".." && $file != ".svn") {
                    unlink($path . $file);
                }
            }
            closedir($dh);
        }
    }
    return 1;
}
コード例 #2
0
ファイル: play.php プロジェクト: benbruscella/Grammafone
<?php

include_once "mp3act_functions.php";
set_time_limit(0);
mp3act_connect();
// Play a song
if ($_SERVER['argv'][1] == 1) {
    $query = "SELECT song_id,filename FROM mp3act_songs WHERE song_id=" . $_SERVER['argv'][3] . " ORDER BY track";
    $result = mysql_query($query);
    while ($row = mysql_fetch_array($result)) {
        updateNumPlays($row['song_id'], 0, $_SERVER['argv'][2]);
        setCurrentSong($row['song_id'], 0);
        playLocal($row['filename']);
    }
    $query = "DELETE FROM mp3act_currentsong";
    mysql_query($query);
    if (file_exists("/tmp/mp3act")) {
        unlink("/tmp/mp3act");
    }
    exec(getSystemSetting("phpbin") . " includes/play.php 3 {$id} > /dev/null 2>&1 &");
} elseif ($_SERVER['argv'][1] == 2) {
    $query = "SELECT song_id,filename FROM mp3act_songs WHERE album_id=" . $_SERVER['argv'][3] . " ORDER BY track";
    $result = mysql_query($query);
    while ($row = mysql_fetch_array($result)) {
        updateNumPlays($row['song_id'], 0, $_SERVER['argv'][2]);
        setCurrentSong($row['song_id'], 0);
        playLocal($row['filename']);
    }
    $query = "DELETE FROM mp3act_currentsong";
    mysql_query($query);
    if (file_exists("/tmp/mp3act")) {
コード例 #3
0
 function updateStats()
 {
     mp3act_connect();
     $query = "SELECT COUNT(DISTINCT album_id) as num_albums, \n              COUNT(DISTINCT artist_id) as num_artists, \n              COUNT(song_id) as num_songs, \n              SEC_TO_TIME(SUM(length)) as total_time, \n              SUM(size)/1024000000 as total_size \n              FROM mp3act_songs";
     $result = mysql_query($query);
     $row = mysql_fetch_assoc($result);
     $query = "DELETE FROM mp3act_stats";
     mysql_query($query);
     $query2 = "SELECT COUNT(genre_id) as num_genres FROM mp3act_genres";
     $result2 = mysql_query($query2);
     $row2 = mysql_fetch_assoc($result2);
     $query3 = "INSERT INTO mp3act_stats VALUES ( \n            " . $row['num_artists'] . ", \n            " . $row['num_albums'] . ",\n            " . $row['num_songs'] . ",\n            " . $row2['num_genres'] . ",\n            \"" . $row['total_time'] . "\",\n            \"" . $row['total_size'] . "GB\")" . "";
     mysql_query($query3);
 }
コード例 #4
0
 function updateGenres()
 {
     mp3act_connect();
     $query = "DELETE FROM mp3act_genres";
     mysql_query($query);
     $query = "SELECT album_genre FROM mp3act_albums GROUP BY album_genre";
     $result = mysql_query($query);
     while ($genre = mysql_fetch_assoc($result)) {
         $query = "INSERT INTO mp3act_genres VALUES (NULL,\"" . $genre['album_genre'] . "\")";
         mysql_query($query);
     }
 }
コード例 #5
0
ファイル: browse.php プロジェクト: benbruscella/Grammafone
function getFileList($path)
{
    if ($path[strlen($path) - 1] != '/') {
        $path .= "/";
    }
    $path_sl = addslashes($path);
    $files = "";
    if (!is_dir($path)) {
        $files .= "Given path is not a directory, choose another path";
        return $files;
    }
    mp3act_connect();
    $resdir = @opendir($path);
    if ($resdir != false) {
        while (($entry = readdir($resdir)) !== false) {
            if (is_dir($path . $entry)) {
                if ($entry != "." && $entry != "..") {
                    $directory[] = $entry;
                }
            } else {
                /* filename, only add if it's an mp3 */
                if (strtolower(substr($entry, strlen($entry) - 4, 4)) == ".mp3") {
                    $file[] = $entry;
                }
            }
        }
        closedir($resdir);
        //array_multisort((strtolower($directory)), SORT_ASC, SORT_STRING, $directory);
        $count = 1;
        $dircount = 1;
        if (count($directory) > 0) {
            sort($directory);
            foreach ($directory as $entry) {
                $count % 2 == 0 ? $alt = "class=\"alt\"" : ($alt = '');
                $files .= "<div class='impcell'>";
                $files .= "<input type='checkbox' name='importdir[]' value='{$count}' {$alt}/>";
                $files .= "<img src='img/gray10x10.png'></img>";
                $files .= "<img src='img/gray10x10.png'></img>";
                $files .= "<a href=\"#\" onclick=\"goToDirectory('{$path_sl}', {$dircount}); return false;\" title=\"Go to directory {$entry}\">{$entry}</a>";
                $files .= "</div>";
                $count++;
                $dircount++;
            }
        }
        $count = 1;
        // reset counter for files
        if (count($file) > 0) {
            sort($file);
            foreach ($file as $entry) {
                $count % 2 == 0 ? $alt = "class=\"alt\"" : ($alt = '');
                $fileStatus = fileInDb($path . $entry);
                $files .= "<div class='impcell'>";
                $files .= "<input type='checkbox' name='importfile[]' value='{$count}' {$alt}/>";
                if ($fileStatus['in_db'] == true) {
                    $files .= "<img src='img/check.png' alt='Song is in database'></img>";
                } else {
                    $files .= "<img src='img/gray10x10.png'></img>";
                }
                if ($fileStatus['modified'] == true) {
                    $files .= "<img src='img/modified.png' alt='Song has been modified since it was imported'></img>";
                } else {
                    $files .= "<img src='img/gray10x10.png'></img>";
                }
                $files .= "{$entry}";
                $files .= "</div>";
                $count++;
            }
        }
    } else {
        return "Directory {$path} not open for reading, permission problem?";
    }
    return $files;
}