コード例 #1
0
ファイル: energy.php プロジェクト: RobQuistNL/LamPI-2.0
        // switch $ind
    }
    // for
    return true;
}
// function
/*	=================================================================================	
										MAIN PROGRAM
	=================================================================================	*/
$ret = -1;
// Parse the URL sent by client
// post_parse will parse the commands that are sent by the java app on the client
// $_POST is used for data that should not be sniffed from URL line, and
// for changes sent to the devices
$log->lwrite("Starting Log record EnerPI");
if (($ret = get_parse()) === false) {
    $log->lwrite("No _GET message was found");
    $ret = post_parse();
}
$log->lwrite("Starting Main Program, graphAction: " . $graphAction);
// Do Processing
switch ($graphAction) {
    // We generate a "STANDARD" temperature graph. Obsolete for most applications.
    // XXX Can be called as a standalone program by external script.
    // In case the user defines his own graph
    case "sensor":
    case "weather":
        $log->lwrite("Starting weather specific graphs, type: " . $graphType . ", period: " . $graphPeriod);
        if (!make_energy_graph($graphType, $graphPeriod, $graphSensors)) {
            $appmsg .= "user error. ";
        } else {
コード例 #2
0
ファイル: frontend_set.php プロジェクト: RobQuistNL/LamPI-2.0
//
//	=======================================================================================
$ret = 0;
$cfg = 0;
// ----------------------------------------------------------------------------------------
// PARSE COMMAND LINE AND CALLING PROGRAM $_GET AND $_POST COMMANDS
//
// post_parse will parse the commands that are sent by the java app on the client
// $_POST is used for data that should not be sniffed from URL line, and
// for changes sent to the devices
$ret = post_parse();
// get_parse will parse more than just the commands that are sent by the java app on the client
// it will also respond to other $_GET commands if you call the php file directly
// The URL commands are shown in the get_parse function
if ($testing == 1) {
    $ret = get_parse();
}
// ----------------------------------------------------------------------------------------
// PROCESS RESULTING ACTIONS FROM CALLING AJAX PROGRAM
//
// MIND: If program called as URL on browser, look in get_parse for more
// information.
// XXX Needs some cleaning and better/consistent messaging specification
// could also include the setting of debug on the client side
switch ($action) {
    case "load":
        $cfg = read_database($config_dir . "database.cfg");
        // Load $cfg Object from File
        $ret = print_database($cfg);
        $ret = fill_database($cfg);
        // Fill the MySQL Database with $cfg object
コード例 #3
0
ファイル: LamPI-daemon.php プロジェクト: RobQuistNL/LamPI-2.0
$log->lwrite("-------------- STARTING DAEMON ----------------------");
sleep(2);
// Open the SQL handler to the mysql daemon
$pisql = new mysqli($dbhost, $dbuser, $dbpass, $dbname);
if ($pisql->connect_errno) {
    $log->lwrite("LamPI-daemon:: Failed to connect to MySQL: (" . $pisql->connect_errno . ") " . $pisql->connect_error, 1);
    exit(1);
}
// Some variables that are probably (re)set by get_parse();
$doinit = false;
$doreset = false;
$dofile = "";
// Parse the comamndline (starting) for commandparameters
// 1. Parse the URL sent by client (not working, but could restart itself later version)
// XXX Need to adapt get_parse to also read URL-like (should that be necessary)
if (get_parse()) {
    // Do some Processing of commandline arguments. For init, the standard filename IS database.cfg
    // could also include the setting of debug on the client side
    if ($doinit) {
        $dbfile = $config_dir . "database.cfg";
        if ($dofile != "") {
            $dbfile = $dofile;
        }
        $log->lwrite("main:: Option do_init selected, reading db file: " . $dofile, 1);
        $cfg = read_database($dbfile);
        // Load $cfg Object from File
        $ret = fill_database($cfg);
        // Fill the MySQL Database with $cfg object
        $ret = file_database($config_dir . "newdbms.cfg", $cfg);
        // Make backup to other file
        $ret = print_database($cfg);