Example #1
0
function getSettings($mysettings)
{
    $pdo = getDbHandle($mysettings);
    $sth = $pdo->prepare('SELECT * FROM `kvstore` where `module`=? and id="noid"');
    $sth->execute(array('FreePBX\\modules\\Firewall'));
    $retarr = array();
    $res = $sth->fetchAll();
    foreach ($res as $row) {
        $retarr[$row['key']] = $row['val'];
    }
    // Should we be running?
    if (isset($retarr['status']) && $retarr['status']) {
        $retarr['active'] = true;
    } else {
        $retarr['active'] = false;
    }
    if (!isset($retarr['refresh'])) {
        $retarr['refresh'] = "normal";
    }
    if ($retarr['refresh'] == "fast") {
        $period = 15;
    } elseif ($retarr['refresh'] == "slow") {
        $period = 120;
    } else {
        $period = 30;
    }
    $retarr['period'] = $period;
    return $retarr;
}
Example #2
0
require_once 'init/memcache.php';
$defaultPage = 'index';
$app = new \Slim\Slim();
// create a session if one does not exists
$session = false;
$session_id = false;
if (!empty($_COOKIE['session'])) {
    $session_id = $_COOKIE['session'];
    $session = $memcache->get($session_id);
} else {
    $session = createSession($memcache, false, $config);
}
// init mongo and pdo
$mongo = new MongoClient();
$db = $mongo->{__MONGODB__};
$pdo = getDbHandle(driver, host, database, username, password);
// this array stores all the important objects
$aInit = array('app' => $app, 'memcache' => $memcache, 'session' => $session, 'config' => $config, 'mongo' => $db, 'pdo' => $pdo);
$aInit['session']->last_request = $defaultPage;
// fill essential memcache tables
$pages = $memcache->get(APP_ID . '_' . 'pages');
if (empty($pages)) {
    loadStartupTables($aInit);
}
// get the page patterns, copy them from db if they do not exist,
// if they don't exist in the db, then populate the db with what we have in the html dir
$pages = $aInit['memcache']->get(APP_ID . '_pages');
if (!empty($pages)) {
    foreach ($pages as $oPage) {
        $app->get($oPage->path . "(/:var1(/:var2))", function ($var1 = '', $var2 = '') use($app, $aInit, $oPage) {
            $parms = compact("var1", "var2");