Example #1
0
 *
 */
// common include
include '/srv/http/app/config/config.php';
opcache_invalidate('/srv/http/command/cachectl.php');
// insect GET['action']
if (isset($_GET['action'])) {
    switch ($_GET['action']) {
        case 'prime':
            OpCacheCtl('prime', '/srv/http/', $redis);
            break;
        case 'primeall':
            OpCacheCtl('primeall', '/srv/http/');
            break;
        case 'reset':
            OpCacheCtl('reset', '/srv/http/');
            opcache_reset();
            runelog('cacheCTL RESET');
            echo "PHP OPCACHE CLEARED";
            break;
        case 'debug':
            // opcache_reset();
            echo "<pre>";
            echo "OPcache status:\n";
            print_r(opcache_get_status());
            echo "OPcache configuration:\n";
            print_r(opcache_get_configuration());
            echo "</pre>";
            break;
    }
}
Example #2
0
function ui_mpd_response($mpd, $notify = null)
{
    runelog('ui_mpd_response invoked');
    $response = json_encode(readMpdResponse($mpd));
    // --- TODO: check this condition
    if (strpos($response, "OK") && isset($notify)) {
        runelog('send UI notify: ', $notify);
        ui_notify($notify['title'], $notify['text']);
    }
    echo $response;
}
Example #3
0
$libs = APP . 'libs/vendor';
set_include_path(get_include_path() . PATH_SEPARATOR . $libs);
// RuneAudio Library include
include APP . 'libs/runeaudio.php';
// Connect to Redis backend
$redis = new Redis();
$redis->pconnect('127.0.0.1');
//$redis->pconnect('/tmp/redis.sock');
$devmode = $redis->get('dev');
$activePlayer = $redis->get('activePlayer');
// LogSettings
if ($redis->get('debug') > 0) {
    $activeLog = 1;
} else {
    $activeLog = 0;
}
ini_set('log_errors', $activeLog);
ini_set('error_log', '/var/log/runeaudio/runeui.log');
ini_set('display_errors', $activeLog);
// connect to MPD daemon
if ($_SERVER["SCRIPT_FILENAME"] === '/var/www/command/index.php' && $activePlayer === 'MPD') {
    // debug
    runelog('[connection.php] >>> OPEN MPD SOCKET [NORMAL MODE [0] (blocking)] <<<', '');
    $mpd = openMpdSocket('/run/mpd.sock', 0);
} elseif ($activePlayer === 'MPD') {
    // debug
    runelog('[connection.php] >>> OPEN MPD SOCKET [BURST MODE [1] (blocking)] <<<', '');
    $mpd = openMpdSocket('/run/mpd.sock', 1);
} elseif ($redis->hGet('spotify', 'enable') === '1' && $activePlayer === 'Spotify') {
    $spop = openSpopSocket('localhost', 6602, 1);
}
Example #4
0
            sendSpopCommand($spop, 'image');
            unset($spotify_cover);
            $spotify_cover = readSpopResponse($spop);
            $spotify_cover = json_decode($spotify_cover);
            usleep(500000);
            runelog('coverart (spotify): retry n: ' . $count, $spotify_cover->status);
            if ($spotify_cover->status === 'ok') {
                $spotify_cover = base64_decode($spotify_cover->data);
                break;
            }
            $count++;
        } while ($count !== 10);
        $bufferinfo = new finfo(FILEINFO_MIME);
        $spotify_cover_mime = $bufferinfo->buffer($spotify_cover);
        header('Cache-Control: no-cache, no-store, must-revalidate');
        // HTTP 1.1.
        header('Pragma: no-cache');
        // HTTP 1.0.
        header('Expires: 0');
        // Proxies.
        header('Content-Type: ' . $spotify_cover_mime);
        echo $spotify_cover;
    } else {
        // redirect to /covers NGiNX location
        $local_cover_url = 'http://' . $_SERVER["SERVER_ADDR"] . '/covers/' . $request_folder . '/' . $request_coverfile;
        runelog("coverart: redirect to local-coverart (url): ", $local_cover_url);
        header('Location: ' . $local_cover_url, true, 301);
    }
}
runelog("\n--------------------- coverart (end) ---------------------");