Example #1
0
function get_parse()
{
    global $appmsg;
    global $apperr;
    global $action;
    global $icsmsg;
    global $config_dir;
    global $log_dir;
    foreach ($_GET as $ind => $val) {
        decho("get_parse:: index: {$ind} and val: {$val}<br>", 1);
        switch ($ind) {
            case "action":
                $action = $val;
                break;
            case "message":
                $icsmsg = json_decode($val);
                $apperr .= "\n ics: " . $icsmsg;
                break;
                // ******* URL COMMANDLINE OPTIONS BELOW ***
                // Initial or repair load of th edatabase for LamPI
                // Need to specify this option on the URL: http://<my-lampi-url>/frontend_set.php?load
                //
            // ******* URL COMMANDLINE OPTIONS BELOW ***
            // Initial or repair load of th edatabase for LamPI
            // Need to specify this option on the URL: http://<my-lampi-url>/frontend_set.php?load
            //
            case "load":
                echo "load:: config file: " . $config_dir . "database.cfg\n";
                $cfg = read_database($config_dir . "database.cfg");
                // Load $cfg Object from File
                echo " cfg read; ";
                print_database($cfg);
                echo " now filling mysql; ";
                $ret = fill_database($cfg);
                // Fill the MySQL Database with $cfg object
                echo " Making backup; ";
                $ret = file_database($config_dir . "newdbms.cfg", $cfg);
                // Make backup to other file
                echo " Backup newdbms.cfg made";
                if ($val < 1) {
                    decho("file_database:: value must be >0");
                }
                exit(0);
                break;
            case "print":
                $cfg = load_database();
                print_database($cfg);
                exit(0);
                break;
            case "store":
                $cfg = load_database();
                // Fill $cfg from MySQL
                $ret = file_database($config_dir . "newdbms.cfg", $cfg);
                // Make backup to other file
                if ($val < 1) {
                    decho("store:: value must be >0");
                }
                echo "Backup is complete";
                exit(0);
                break;
        }
        //   Switch ind
    }
    //  Foreach
    return 0;
}
Example #2
0
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);
    }
    if ($doreset) {
        $log->lwrite("main:: Option do_reset selected", 1);
    }
    $log->lwrite("Done processing command parameters at " . date("r") . "\n", 2);
} else {
    $log->lwrite("main:: get_parse had no commandline parameters " . date("r") . "\n", 1);
}
// Start with loading the database into a local $config structure. This takes
// time once , but once we are in the loop it will save us time every loop.
$log->lwrite("main:: Loading the database");
$config = load_database();
// load the complete configuration object
if ($config == -1) {
    $log->lwrite("main:: FATAL Error loading database, exiting now");