Example #1
0
function action_getCurStatus($msg = "")
{
    global $config;
    doPrint("got json status request");
    $data = getData();
    $data = fillInDefaults($data);
    $text = "idle";
    if (isset($data['ppid'])) {
        $file = $data['filename'];
        $file = str_replace($config["searchPath"], "", $file);
        if ($data['playingStream'] == 0 and strpos($file, "/") !== 0) {
            $file = "/" . $file;
        }
        $bitrate = "";
        if (isset($data["bitrate"]) and !empty($data["bitrate"])) {
            $bitrate = " (" . $data["bitrate"] . "kb)";
        }
        if ($data['pause']) {
            $text = "paused (pid: " . $data['ppid'] . "): " . $file . $bitrate;
        } else {
            $text = "playing (pid: " . $data['ppid'] . "): " . $file . $bitrate;
        }
    } else {
        $data['playingStream'] = 0;
    }
    list($remMin, $remSec, $remaining, $stream, $started) = getRemaining($data);
    $pre = "-";
    if ($stream == 1 or empty($remSec) and empty($remMin)) {
        $pre = " ";
    }
    if (!empty($msg)) {
        $text = $msg;
    }
    $status[] = array('artist' => utf8_encode($data['artist']), 'album' => utf8_encode($data['album']), 'nr' => $data['track'], 'title' => utf8_encode($data['title']), 'length' => $data['length'], 'token' => $data['token'], 'volume' => getVolume(), 'status' => utf8_encode($text), 'remMin' => $remMin, 'remSec' => $remSec, 'pre' => $pre, 'play' => $data['play'], 'pause' => $data['pause'], 'repeat' => $data['repeat'], 'mute' => $data['mute'], 'quiet' => $data['quiet'], 'totalTime' => $data['totalTime'], "stream" => $data['playingStream'], "version" => "WebMP3 " . $WEBMP3_VERSION, "partymode" => $data['partymode']);
    if (isset($_REQUEST['debug'])) {
        print "<pre>time: " . time() . "\n\nstatus:";
        print_r($status);
        print "\ndata:\n";
        print_r($data);
    }
    if (isset($config['lastError']) and !empty($config['lastError'])) {
        header("HTTP/1.0 508 Application Error");
        print $config['lastError'];
        doPrint("Error: " . $config['lastError']);
        exit(1);
    }
    $jsonstatus = json_encode($status);
    echo '({"total":"' . count($status) . '","results":' . $jsonstatus . '})';
}
Example #2
0
File: index.php Project: sni/webmp3
function action_default()
{
    $failed = 0;
    print "<html><head><title>WebMP3 configuration check...</title></head><body>\n";
    print "doing some sanity checks...<br>";
    # check compiled or loaded modules
    $exts = array("json", "pcre", "gd");
    foreach ($exts as $ext) {
        if (!extension_loaded($ext)) {
            print "ERROR: php extension " . $ext . " missing!<br>\n";
            $failed = 1;
        }
    }
    if (!file_exists("config.php")) {
        if (file_exists("config.php.sample")) {
            print "INFO: trying to copy config.php.sample to config.php<br>\n";
            copy("config.php.sample", "config.php");
        }
    }
    if (!file_exists("config.php")) {
        print "ERROR: no config.php found<br>\n";
        $failed = 1;
    }
    if (file_exists("config.php")) {
        global $config;
        include "config.php";
        # check search path
        if (!isset($config["searchPath"])) {
            print "ERROR: music directory option missing, please set searchPath in the config.php<br>\n";
            $failed = 1;
        } elseif (!is_dir($config["searchPath"])) {
            print "ERROR: " . $config["searchPath"] . " is not a valid directory<br>\n";
            $failed = 1;
        }
        # else {
        #    checkForUptodateTagCache();
        #}
        # check var path
        if (!isset($config["plDir"])) {
            print "ERROR: playlists directory option missing, please set plDir in the config.php<br>\n";
            $failed = 1;
        } elseif (!file_exists($config["plDir"])) {
            print "INFO: trying to create " . $config["plDir"] . "<br>\n";
            mkdir($config['plDir']);
            $failed = 1;
        } elseif (!is_dir($config["plDir"])) {
            print "INFO: playlist directory " . $config["plDir"] . " is not a valid directory<br>\n";
            $failed = 1;
        }
        # check binarys
        if (!isset($config["ext"]) or !is_array($config["ext"])) {
            print 'ERROR: no extensions configured, $config["ext"] is not a vaild array<br>';
            print "\n";
            $failed = 1;
        } else {
            foreach ($config["ext"] as $name => $ext) {
                if (!isset($ext['binary'])) {
                    print "ERROR: Extension " . $name . " has no binary configured<br>\n";
                    $failed = 1;
                } elseif (!file_exists($ext['binary'])) {
                    print "ERROR: " . $ext['binary'] . " does not exist<br>\n";
                    $failed = 1;
                } elseif (!is_executable($ext['binary'])) {
                    print "ERROR: " . $ext['binary'] . " is not executable<br>\n";
                    $failed = 1;
                }
            }
        }
        # check the php binary
        if (!isset($config["cliPHPbinary"])) {
            print "ERROR: php binary option missing, please set cliPHPbinary in the config.php<br>\n";
            $failed = 1;
        } elseif (!file_exists($config["cliPHPbinary"])) {
            print "ERROR: " . $config["cliPHPbinary"] . " does not exist<br>\n";
            $failed = 1;
        } elseif (!is_executable($config["cliPHPbinary"])) {
            print "ERROR: " . $config["cliPHPbinary"] . " is not executable<br>\n";
            $failed = 1;
        }
        # check the stream binary
        if (!isset($config["streamBin"])) {
            print "ERROR: stream binary option missing, please set streamBin in the config.php<br>\n";
            $failed = 1;
        } elseif (!file_exists($config["streamBin"])) {
            print "ERROR: " . $config["streamBin"] . " does not exist<br>\n";
            $failed = 1;
        } elseif (!is_executable($config["streamBin"])) {
            print "ERROR: " . $config["streamBin"] . " is not executable<br>\n";
            $failed = 1;
        }
        if (!isset($config["volumeBin"])) {
            print "ERROR: volume binary option missing, please set volumeBin in the config.php<br>\n";
            $failed = 1;
        } elseif (!is_executable($config["volumeBin"])) {
            print "ERROR: " . $config["volumeBin"] . " is not executable<br>\n";
            $failed = 1;
        } else {
            $vol = getVolume();
            if (isset($config['lastError'])) {
                print "ERROR: failed to get volume<br>\n";
                print "ERROR: " . $config['lastError'] . "<br>\n";
                print "ERROR: please check your volumeBin: " . $config["volumeBin"] . "<br>\n";
                $failed = 1;
            }
        }
    }
    if (!$failed) {
        print "everything is fine...<br>\n";
        print "lets go to <a href='webmp3.php'>webmp3</a><br>\n";
        print '<script type="text/javascript">
               <!--
               document.location = "webmp3.php";
               -->
               </script>
               ';
    } else {
        print "<br>\n";
        print "please correct the errors above and <a href='.'>retry.</a><br>\n";
        print "configuration can be changed in the config.php<br>\n";
        print "<br>\n";
        print "or give it a try <a href='webmp3.php'>webmp3</a><br>\n";
    }
    print "</body></html>\n";
}
Example #3
0
    $enprofit = false;
    debug_print("Enable the computation of profits: false<Br/>");
}
if (isset($_GET['chart']) || $isCmd) {
    $chartDataType = isset($_GET['chart']) ? $_GET['chart'] : $cmdChart;
    //$chartDataType = $_GET['chart'];
    debug_print("Date range: from {$fromDate} to {$toDate}<Br>");
    switch ($chartDataType) {
        case 'close':
            getClose($company, $fromDate, $toDate, $dataorg, $mysql_host, $mysql_database, $mysql_user, $mysql_password);
            break;
        case 'current':
            getCurrentDayPrices($company, $dataorg, $mysql_host, $mysql_database, $mysql_user, $mysql_password);
            break;
        case 'volume':
            getVolume($company, $fromDate, $toDate, $dataorg, $mysql_host, $mysql_database, $mysql_user, $mysql_password);
            break;
        case 'ohlcur':
            getOHLCurrent($company, $dataorg, $mysql_host, $mysql_database, $mysql_user, $mysql_password);
            break;
        case 'ohlc':
            getOHLC($company, $fromDate, $toDate, $dataorg, $mysql_host, $mysql_database, $mysql_user, $mysql_password);
            break;
        case 'ohlcha':
            getOHLCHA($company, $fromDate, $toDate, $dataorg, $mysql_host, $mysql_database, $mysql_user, $mysql_password);
            break;
        case 'sohlcavv':
            $targetDate = null;
            if (isset($_GET['targetdate'])) {
                $targetDate = isset($_GET['targetdate']) ? $_GET['targetdate'] : null;
            }
Example #4
0
     break;
 case 'volumeUp':
     //augmente le volume du mixer de +5 ->ok
     $mySqueezeCLI = new SqueezeCLI(volumeUp());
     break;
 case 'volumeDown':
     //réduit le volume du mixer de -5 ->ok
     $mySqueezeCLI = new SqueezeCLI(volumeDown());
     break;
 case 'setVolume':
     //set le volume exemple: volumeSet_100 ->ok
     $mySqueezeCLI = new SqueezeCLI(setVolume($parameter));
     break;
 case 'getVolume':
     //stop le player exemple: stop ->ok
     echo getVolume();
     break;
     //action type alarm: addAlarm, deleteAlarm-------------------------------------------------------------------------------------------------------------
 //action type alarm: addAlarm, deleteAlarm-------------------------------------------------------------------------------------------------------------
 case 'setAlarm':
     //pour l'instant l'application ne gère qu'un réveil à la fois, ainsi a chaque fois qu'un reveil est set le précédent est delete -> exemple: setAlarm_0,1,2,3*8*30*10 ->ok
     //echo "entrée dans le case setAlarm \n";
     deleteAlarm();
     setAlarm($parameter);
     break;
 case 'deleteAlarm':
     //-> ok
     deleteAlarm();
     break;
 default:
     # code...