コード例 #1
0
ファイル: playlist.php プロジェクト: RiJo/m3uer
require_once 'Filesystem.php';
if (!isset($_GET['q'])) {
    die("No valid query given");
}
switch ($_GET['q']) {
    case 'create':
        assure_keys($_GET, array('root', 'name', 'path'), 'Could not create playlist: Invalid aguments given');
        create($_GET['root'], $_GET['path'], $_GET['name']);
        break;
    case 'delete':
        assure_keys($_GET, array('root', 'path'), 'Could not delete playlist: Invalid aguments given');
        delete($_GET['root'], $_GET['path']);
        break;
    case 'save':
        assure_keys($_GET, array('root', 'path'), 'Playlist could not be saved: Invalid aguments given');
        assure_keys($_POST, 'data', 'Playlist could not be saved: Invalid aguments given');
        save($_GET['root'], $_GET['path'], $_POST['data']);
        break;
    default:
        die("Unrecognized query {$_GET['q']}");
}
function assure_keys($array, $keys, $error_message = '')
{
    if (!is_array($keys)) {
        $keys = array($keys);
    }
    foreach ($keys as $key) {
        if (!isset($array[$key])) {
            die($error_message);
        }
    }
コード例 #2
0
ファイル: data.php プロジェクト: RiJo/m3uer
    case 'playlist-tree':
        assure_keys($_GET, array('root', 'path'));
        assure_keys($_SESSION, SESSION_MEDIA);
        echo playlist_valid_tree($_GET['root'], $_GET['path'], unserialize($_SESSION[SESSION_MEDIA]));
        break;
    case 'playlist-contents':
        assure_keys($_GET, array('root', 'path'));
        echo playlist_contents($_GET['root'], $_GET['path']);
        break;
    case 'playlist-invalid-count':
        assure_keys($_GET, array('root', 'path'), '-1');
        echo playlist_invalid_count($_GET['root'], $_GET['path']);
        break;
    case 'playlists':
        assure_keys($_GET, array('root'));
        assure_keys($_SESSION, SESSION_PLAYLISTS);
        echo playlists($_GET['root'], unserialize($_SESSION[SESSION_PLAYLISTS]));
        break;
    default:
        die("Unrecognized query {$_GET['q']}");
}
function assure_keys($array, $keys, $error_message = '')
{
    if (!is_array($keys)) {
        $keys = array($keys);
    }
    foreach ($keys as $key) {
        if (!isset($array[$key])) {
            die($error_message);
        }
    }