Example #1
1
    case "getLogicalGridSize":
        echo getLogicalGridSize();
        break;
    case "getOrigin":
        echo getOrigin();
        break;
    case "setOrigin":
        echo setOrigin($input);
        break;
    case "getNotesForKeys":
        echo getNotesForKeys();
        break;
    case "getTick":
        echo getTick();
        break;
    case "setTick":
        echo setTick($input);
        break;
    case "getTickInterval":
        echo getTickInterval();
        break;
    case "newGame":
        echo newGame("");
        break;
    case "shutdown":
        echo shutdown();
        break;
    default:
        echo "invalid";
        break;
}
Example #2
0
 private function encodeOutput($data)
 {
     shutdown();
     $this->contentType('json');
     return json_encode($data);
     // Something like this:
     //if ($this->request->accepts('json')) {
     //  return json_encode($data);
     //} else {
     //  return xml_encode($data);
     //}
 }
Example #3
0
function sigHandler($signo)
{
    switch ($signo) {
        case SIGTERM:
            shutdown("Got SIGTERM");
            break;
        case SIGHUP:
            logWrite(L_SYSTEM, "[SYSTEM] Got SIGHUP, Forced rehash.");
            rehash();
            break;
    }
}
Example #4
0
/**
 * resource actions => access
 *                     shutdown
 */
function _moduleContent(&$smarty, $module_name)
{
    //folder path for custom templates
    $local_templates_dir = getWebDirModule($module_name);
    //user credentials
    global $arrCredentials;
    global $arrPermission;
    $action = getAction();
    $content = "";
    switch ($action) {
        case "shutdown":
            $content = shutdown($smarty, $module_name, $local_templates_dir, $arrPermission, $arrCredentials);
        default:
            $content = showModule($smarty, $module_name, $local_templates_dir, $arrPermission, $arrCredentials);
    }
    return $content;
}
 /**
  * Forwards to the given url/action
  * 
  * @param string $action
  * @return void
  */
 protected function forward($action)
 {
     shutdown();
     header('Location: ' . $this->configuration['baseUrl'] . $action);
     exit;
 }
function HandleCommand($socket, $cmd)
{
    global $TBS;
    global $pagetitle;
    global $result;
    $pagetitle = $cmd . " result";
    $username = !empty($_POST['username']) ? $_POST['username'] : null;
    $password = !empty($_POST['password']) ? $_POST['password'] : null;
    $confirmation = !empty($_POST['cmd_optn']) ? $_POST['cmd_optn'] : null;
    switch ($cmd) {
        case 'Add':
        case 'Update':
            if (modify_account($socket, $username, $password, 0, false)) {
                $result = $cmd . " succeed.";
            } else {
                $result = $cmd . " failed.";
            }
            $TBS->LoadTemplate('tpl/cmdresult.htm');
            break;
        case 'Ban':
            if (modify_account($socket, $username, "(hidden)", 0, true)) {
                $result = $cmd . " succeed.";
            } else {
                $result = $cmd . " failed.";
            }
            $TBS->LoadTemplate('tpl/cmdresult.htm');
            break;
        case 'Unban':
            if (modify_account($socket, $username, "(hidden)", 0, false)) {
                $result = $cmd . " succeed.";
            } else {
                $result = $cmd . " failed.";
            }
            $TBS->LoadTemplate('tpl/cmdresult.htm');
            break;
        case 'AccessLevel':
            $access_level = intval($_POST['accesslevel']);
            if (modify_account($socket, $username, "(hidden)", $access_level, false)) {
                $result = "Set access level succeed.";
            } else {
                $result = "Set access level failed.";
            }
            $TBS->LoadTemplate('tpl/cmdresult.htm');
            break;
        case 'Disconnect':
            session_destroy();
            $result = "You have been disconnected.";
            $TBS->LoadTemplate('tpl/cmdresult.htm');
            break;
        case 'Save':
            // Antony's enrichment.
            if ($confirmation == "yes") {
                $result = world_save($socket);
                $result = $cmd . " command sent.";
            } else {
                $result = $cmd . " command canceled.";
            }
            $TBS->LoadTemplate('tpl/cmdresult.htm');
            break;
        case 'Shutdown':
            // Antony's enrichment.
            if ($confirmation == "yes") {
                $result = shutdown($socket, false, false);
                if ($result) {
                    $result = $cmd . " command sent.";
                } else {
                    $result = $cmd . " command failed.";
                }
            } else {
                $result = $cmd . " command canceled.";
            }
            $TBS->LoadTemplate('tpl/cmdresult.htm');
            break;
        case 'Restart':
            // Antony's enrichment.
            if ($confirmation == "yes") {
                $result = shutdown($socket, true, false);
                if ($result) {
                    $result = $cmd . " command sent.";
                } else {
                    $result = $cmd . " command failed.";
                }
            } else {
                $result = $cmd . " command canceled.";
            }
            $TBS->LoadTemplate('tpl/cmdresult.htm');
            break;
        case 'SaveShutdown':
            // Antony's enrichment.
            if ($confirmation == "yes") {
                $result = shutdown($socket, false, true);
                if ($result) {
                    $result = $cmd . " command sent.";
                } else {
                    $result = $cmd . " command failed.";
                }
            } else {
                $result = $cmd . " command canceled.";
            }
            $TBS->LoadTemplate('tpl/cmdresult.htm');
            break;
        case 'SaveRestart':
            // Antony's enrichment.
            if ($confirmation == "yes") {
                $result = shutdown($socket, true, true);
                if ($result) {
                    $result = $cmd . " command sent.";
                } else {
                    $result = $cmd . " command failed.";
                }
            } else {
                $result = $cmd . " command canceled.";
            }
            $TBS->LoadTemplate('tpl/cmdresult.htm');
            break;
        case 'Broadcast':
            // Antony's enrichment.
            $message = $_POST['message'];
            $hue = (int) $_POST['hue'];
            $result = world_broadcast($socket, $message, $hue);
            if (!$result) {
                $result = $cmd . " command failed.";
            }
            $TBS->LoadTemplate('tpl/cmdresult.htm');
            break;
    }
}
Example #7
0
function sigHandler($sig)
{
    printd("sigHandler {$sig}\n");
    switch ($sig) {
        case SIGTERM:
        case SIGINT:
            shutdown(1);
            break;
    }
}
Example #8
0
 } else {
     if (isset($_POST['oneSystem'])) {
         //Un sistema en concret.
         echo $_POST['mac'] == "" ? "dummy" : $db->getOneSystem($_POST['mac']);
     } else {
         if (isset($_POST['statusAll'])) {
             //Status de tots els sistemes.
             echo $_POST['macs'] == "" ? "dummy" : $db->getStatusAll($_POST['macs']);
         } else {
             if (isset($_POST['status'])) {
                 //Status de un sistema.
                 echo $_POST['mac'] == "" ? "dummy" : $db->getStatus($_POST['mac']);
             } else {
                 if (isset($_POST['shut'])) {
                     //Shutdown.
                     echo shutdown($_POST['userName'], $_POST['pass'], $_POST['hostname']);
                 } else {
                     if (isset($_POST['wol'])) {
                         //WOL.
                         echo wol($_POST['mac'], $_POST['broad']);
                     } else {
                         if (isset($_POST['addUser'])) {
                             //Add user.
                             echo $db->addUser($_POST['userName'], $_POST['mail'], $_POST['pass']);
                         }
                     }
                 }
             }
         }
     }
 }
Example #9
0
/**
 * Checks if admin access is granted and if not exists script execution
 * 
 * @return void
 **/
function checkAdminAccess()
{
    // always allow access via console
    if (php_sapi_name() == 'cli') {
        return;
    }
    // in any other case use token authentication
    global $configuration;
    $token = isset($_GET['token']) ? urldecode($_GET['token']) : '';
    if ($token !== $configuration['security']['token']) {
        shutdown();
        exit;
    }
}
    case 'prevaudio':
        $result = send('j');
        break;
    case 'togglesubtitles':
        $result = send('s');
        break;
    case 'nextsubtitles':
        $result = send('m');
        break;
    case 'prevsubtitles':
        $result = send('n');
        break;
    case 'next_vid':
        $result = send('next_vid');
        break;
    case 'shutdown':
        $result = shutdown();
        break;
    case 'reboot':
        $result = reboot();
        break;
    case 'continous':
        $result = togglefile(CONTINOUS);
        break;
    case 'loopall':
        $result = togglefile(LOOPALL);
        break;
    default:
        $err = 'wrong command';
}
$GLOBALS['_RESULT'] = $result;
Example #11
0
function logIt($text, $exit = false)
{
    file_put_contents('pintweet.log', date('Y-m-d H:i:s') . ' ' . trim($text) . "\n", FILE_APPEND);
    if ($exit) {
        echo trim($text) . "\n";
        shutdown();
    }
}
Example #12
0
                header("Cache-Control: private", 1);
            }
            #cumulé depuis J9 à J11
            if (function_exists('GT') && defined('J9') && J9) {
                gt('die');
            }
            header('A: shutdowns: ' . $_ENV['lasttime'], 1);
        }
    }
    if ($anotations && filemtime(SFN) > filemtime(PATHANOT)) {
        #si fichier changé depuis dernier cache anotations
        file_put_contents(PATHANOT, igbinary_serialize($anotations));
    }
    myErrorHandler();
    myErrorHandler(1);
    shutdown(1);
    myErrorHandler(1);
    #si jamais des erreurs se sont produites dans le cycle de shutdown
});
#global handler
function shutdown($x = null, $top = 0)
{
    #$e=error_get_last();fb($e);
    global $shutdown;
    if (!is_array($shutdown)) {
        $shutdown = [];
    }
    if ($x === 1) {
        #fired once but allows other functions to be fired & allows second pass, third pass etc...
        if ($unlinks and is_array($unlinks)) {
            foreach ($unlinks as $file) {
function HandleCommand($socket, $cmd)
{
    global $TBS;
    global $pagetitle;
    global $result;
    $pagetitle = $cmd . " result";
    $username = $_POST['username'];
    $password = $_POST['password'];
    $confirmation = $_POST['cmd_optn'];
    switch ($cmd) {
        case 'Add':
        case 'Update':
            if (modify_account($socket, $username, $password, 0, false)) {
                // assuming the access level is 0 [player]
                $result = $cmd . " succeed.";
            } else {
                $result = $cmd . " failed.";
            }
            $TBS->LoadTemplate('tpl/cmdresult.htm');
            break;
        case 'Ban':
            if (modify_account($socket, $username, "(hidden)", 0, true)) {
                $result = $cmd . " succeed.";
            } else {
                $result = $cmd . " failed.";
            }
            $TBS->LoadTemplate('tpl/cmdresult.htm');
            break;
        case 'Unban':
            if (modify_account($socket, $username, "(hidden)", 0, false)) {
                $result = $cmd . " succeed.";
            } else {
                $result = $cmd . " failed.";
            }
            $TBS->LoadTemplate('tpl/cmdresult.htm');
            break;
        case 'AccessLevel':
            $access_level = intval($POST['accesslevel']);
            if (modify_account($socket, $username, "(hidden)", $access_level, false)) {
                $result = "Set access level succeed.";
            } else {
                $result = "Set access level failed.";
            }
            $TBS->LoadTemplate('tpl/cmdresult.htm');
            break;
        case 'Disconnect':
            //disconnect($socket);	// need not to disconnect, the socket has already closed on every page request ends.
            session_destroy();
            $result = "You have been disconnected.";
            $TBS->LoadTemplate('tpl/cmdresult.htm');
            break;
            /************************************************************************/
            /* Caution! Below features are added by Antony.
             * If you do not want to use my remote admin enrichment C# script on your shard. Remove below cases would be a safe way to avoid problem.
             */
        /************************************************************************/
        /* Caution! Below features are added by Antony.
         * If you do not want to use my remote admin enrichment C# script on your shard. Remove below cases would be a safe way to avoid problem.
         */
        case 'Save':
            if ($confirmation == "yes") {
                $result = world_save($socket);
                if (!$result) {
                    $result = $cmd . " failed.";
                }
            } else {
                $result = $cmd . " command canceled.";
            }
            $TBS->LoadTemplate('tpl/cmdresult.htm');
            break;
        case 'Shutdown':
            if ($confirmation == "yes") {
                $result = shutdown($socket, false, false);
                if ($result) {
                    $result = $cmd . " command sent.";
                } else {
                    $result = $cmd . " command failed.";
                }
            } else {
                $result = $cmd . " command canceled.";
            }
            $TBS->LoadTemplate('tpl/cmdresult.htm');
            break;
        case 'Restart':
            if ($confirmation == "yes") {
                $result = shutdown($socket, true, false);
                if ($result) {
                    $result = $cmd . " command sent.";
                } else {
                    $result = $cmd . " command failed.";
                }
            } else {
                $result = $cmd . " command canceled.";
            }
            $TBS->LoadTemplate('tpl/cmdresult.htm');
            break;
        case 'SaveShutdown':
            if ($confirmation == "yes") {
                $result = shutdown($socket, false, true);
                if ($result) {
                    $result = $cmd . " command sent.";
                } else {
                    $result = $cmd . " command failed.";
                }
            } else {
                $result = $cmd . " command canceled.";
            }
            $TBS->LoadTemplate('tpl/cmdresult.htm');
            break;
        case 'SaveRestart':
            if ($confirmation == "yes") {
                $result = shutdown($socket, true, true);
                if ($result) {
                    $result = $cmd . " command sent.";
                } else {
                    $result = $cmd . " command failed.";
                }
            } else {
                $result = $cmd . " command canceled.";
            }
            $TBS->LoadTemplate('tpl/cmdresult.htm');
            break;
        case 'Broadcast':
            $message = $_POST['message'];
            $hue = (int) $_POST['hue'];
            $result = world_broadcast($socket, $message, $hue);
            if (!$result) {
                $result = $cmd . " command failed.";
            }
            $TBS->LoadTemplate('tpl/cmdresult.htm');
            break;
            /*** End of Antony's enrichment ***/
            /************************************************************************/
    }
}
Example #14
0
function shutdown_silent()
{
    shutdown(true);
}
Example #15
0
            // No /, it's a host. Skip, we'll pick it up later
            continue;
        }
        list($network, $cidr) = explode("/", $n);
        $driver->addNetworkToZone($zone, $network, $cidr);
    }
}
// Turns out that this is unreliable. Which is why we use sigSleep below.
pcntl_signal(SIGHUP, "sigHupHandler");
// Always run the update the first time.
$lastfin = 1;
while (true) {
    $fwconf = getSettings($mysettings);
    if (!$fwconf['active']) {
        fwLog("Not active. Shutting down");
        shutdown();
    }
    checkPhar();
    $runafter = $lastfin + $fwconf['period'];
    if ($runafter < time()) {
        // We finished more than $period ago. We can run again.
        updateFirewallRules($lastfin === 1);
        // param (bool) true if this is the first run.
        $lastfin = time();
        continue;
    } else {
        // Sleep until we're ready to go again.
        sigSleep($fwconf['period'] / 10);
    }
}
function getSettings($mysettings)
function sigint_handler()
{
    _debug("[MASTER] SIG_INT received.\n");
    shutdown(posix_getpid());
    die;
}
function sigint_handler()
{
    shutdown();
    die("[SIGINT] removing lockfile and exiting.\n");
}
Example #18
0
function FAP($file, $k = '', $v = '', $inc = 0, $sofort = 0)
{
    shutdown(function () {
        FAP(1);
    });
    static $t, $stime, $a, $i, $e;
    if (!$t) {
        $t = 1;
    }
    $a = is_array($a) ? $a : [];
    $e = is_array($e) ? $e : [];
    $i++;
    if ($v === 0) {
        $v = '';
    }
    if (is_array($file)) {
        extract($file);
    }
    if (!isset($e[$file])) {
        $e[$file] = 0;
    }
    $e[$file]++;
    #err:undefined index ..ecrire n fois dans le même fichier ..
    #if($k=='lh')av($k.'='.var_dump($v,1));#FAP(ipf,'lh','!200')
    #av(pre(dbgt()ce()));#
    if ($file === 2) {
        return count($a);
    }
    if ($file == 1 && $a) {
        foreach ($a as $file => $t) {
            FPC($file, $a[$file]);
        }
        #;Touch($file,$stime[$file]);if(j9)kill("$file,$k,$v".pre($a));
        $a = [];
        return;
    }
    GT("fap{$i}-{$file}");
    if ($y = param($file, '&')) {
        extract($y);
    } elseif ($y = param($inc, '&')) {
        extract($y);
    }
    #FAP(dr.$db.'.db',Array($u=>$data));FAP(dr.$db.'.db',Array($score));FAP(dr.$db.'.db',$key,$data);-> titre.db or desc.db
    if (!isset($a[$file]) or !$a[$file]) {
        $a[$file] = FGC($file);
        $stime = is_array($stime) ? $stime : [];
        $stime[$file] = is_file($file) ? filemtime($file) : 0;
        $e = error_get_last();
        #fb($e,'error');
        if (strpos($e['message'], 'Illegal string offset') > -1) {
            FB(compact('e', 'file', 'stime'));
            if (J9) {
                print_r(compact('e', 'file', 'stime'));
                die;
            }
        }
        if (!is_array($a[$file])) {
            $a[$file] = [];
        }
    }
    #vide
    #if($e[$file]==5)Dbm('fap e file',SU.'<br>'.$file.':'.$e[$file].' times > switch to FAPD');#FAPD($file,$k,$v); deprecated
    if ($v == '$') {
        return end(array_keys($a[$file], $k));
    }
    #lecture de l'offset
    if ($v == '*') {
        if (in_array($k, $a[$file])) {
            return;
        }
        $a[$file] = $k;
    }
    #insertion d'un nouvel offset ex: Fap($f,$mail,*)=>$a[]=$k;
    if (!is_array($v) && substr($v, 0, 1) == '!') {
        $a[$file][$k] = trim($v, '!');
    } elseif (is_array($k)) {
        foreach ($k as $k2 => $v2) {
            if ($inc && is_numeric($v2)) {
                $a[$file][$k2] += $v2;
            } else {
                $a[$file][$k2] = $v2;
            }
        }
    } elseif ($k && is_array($v)) {
        #en cas de multiples dimensions ??
        foreach ($v as $k2 => $v2) {
            $a[$file][$k][$k2] = $v2;
            $x = error_get_last();
            if (strpos($x['message'], 'annot use a scalar value')) {
                Dbm("{$k} {$k2} {$v2} " . __LINE__ . pre($a));
            }
        }
    } elseif (is_array($v)) {
        foreach ($v as $k2 => $v2) {
            $a[$file][$k][$k2] = $v2;
        }
    } elseif (is_numeric($v)) {
        $a[$file][$k] += $v;
    } elseif ($v) {
        $v = str_replace('"', "'", stripslashes($v));
        if ($k) {
            $a[$file][$k] = $v;
        } else {
            $a[$file][] = $v;
        }
    } elseif ($k) {
        $a[$file][$k]++;
    }
    #sinon incrémentation valeur simple
    #pas d'incrémentation de clé 'nulle'
    #[0]=Array([annuaire/Blogs.p1.12.html] => Annuaire blogs 112,[annuaire/blogs.p1.12.html] => Annuaire blogs 113);
    //todo:fapd(file,clé,0,1); -- ne transmet pas l'inc #fap(file,clé)
    if (strpos($file, 'titre.db') || strpos($file, 'desc.db')) {
        $de = dep($a[$file]);
        if ($de > 1) {
            dbm(SU . "-> {$tx} (depth={$de}) file:{$file} k:" . pre($k) . " v:" . pre($v) . " db2:" . pre(DB2()) . " a:" . pre($a));
        }
        unset($a[$file][0]);
    }
    if ($sofort == 1) {
        FAP(1);
    }
}