Esempio n. 1
0
function Init()
{
    LoadConfig();
    LoadUsers();
    LoadEntries();
    LoadThemes();
    LoadAssets();
    InitStream();
    GetNextJamDateAndTime();
}
Esempio n. 2
0
 public static function get()
 {
     if (self::$instance == null) {
         LoadConfig('DbConfig');
         try {
             self::$instance = new DataBase(sprintf(self::$dsn_tpl, DbConfig::driver, DbConfig::host, DbConfig::port, DbConfig::schema), DbConfig::user, DbConfig::pass);
         } catch (Exception $e) {
             error_log("Error accessing database : " . $e->getMessage());
             $msg = "<h5>Si è verificato un'errore di accesso al database</h5>" . "<pre>" . $e->getMessage() . "</pre>" . "<p>Ci scusiamo per il disagio</p>";
             Template::Error_505($msg);
         }
     }
     return self::$instance;
 }
Esempio n. 3
0
function Init()
{
    function LoadConfig()
    {
        global $config;
        $configTxt = file_get_contents("config/config.txt");
        $lines = explode("\n", $configTxt);
        $linesUpdated = array();
        foreach ($lines as $i => $line) {
            $line = trim($line);
            if (StartsWith($line, "#")) {
                //Comment
                continue;
            }
            $linePair = explode("|", $line);
            if (count($linePair) == 2) {
                //key-value pair
                $key = trim($linePair[0]);
                $value = trim($linePair[1]);
                $config[$key] = $value;
                //Validate line
                switch ($key) {
                    case "PEPPER":
                        if (strlen($value) < 1) {
                            //Generate pepper if none exists (first time site launch).
                            $config[$key] = GenerateSalt();
                            $lines[$i] = "{$key} | " . $config[$key];
                            file_put_contents("config/config.txt", implode("\n", $lines));
                        }
                        break;
                    case "SESSION_PASSWORD_ITERATIONS":
                        if (strlen($value) < 1) {
                            //Generate pepper if none exists (first time site launch).
                            $config[$key] = rand(10000, 20000);
                            $lines[$i] = "{$key} | " . $config[$key];
                            file_put_contents("config/config.txt", implode("\n", $lines));
                        } else {
                            $config[$key] = intval($value);
                        }
                        break;
                    default:
                        $linesUpdated[] = $line;
                        break;
                }
            }
        }
    }
    LoadConfig();
}
Esempio n. 4
0
 public static function get()
 {
     static $tplh = null;
     if (!isset($tplh)) {
         LoadConfig('TplConfig');
         LoadLib('Twig');
         Twig_Autoloader::register();
         $loader = new Twig_Loader_Filesystem(ROOT_DIR . TplConfig::templates);
         $tplh = new Twig_Environment($loader, array('cache' => DEBUG ? false : ROOT_DIR . TplConfig::cache, 'debug' => DEBUG, 'strict_variables' => true));
         if (DEBUG) {
             $tplh->addExtension(new Twig_Extension_Debug());
         }
         $tplh->addExtension(new TemplateExtension());
     }
     return $tplh;
 }
Esempio n. 5
0
 function LogIn($username, $password)
 {
     $config = LoadConfig();
     $database = OpenDatabase($config->map_database->data_source_name, $config->map_database->username_readonly, $config->map_database->password_readonly);
     $user_read = new UserRead($database, "SELECT {0} FROM `map_server_users` WHERE username = ?");
     $user_read->ExecuteQuery(array($username));
     if (!$user_read->MoveNext()) {
         return false;
     }
     $password_hash = new PasswordHash(8, true);
     if ($password_hash->CheckPassword($password, $user_read->password_hash)) {
         $this->is_logged_in = true;
         $user = new User();
         $user->username = $user_read->username;
         $user->user_control_permissions = $user_read->user_control_permissions;
         $user->map_database_permissions = $user_read->map_database_permissions;
         $this->logged_in_user = $user;
     } else {
         $this->is_logged_in = false;
         $this->logged_in_user = null;
     }
     $database = null;
     return $this->is_logged_in;
 }
Esempio n. 6
0
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
// GNU General Public License for more details.
// You should have received a copy of the GNU General Public License
// along with this program.  If not, see <http://www.gnu.org/licenses/>.
// ------------------------------------------------------------------------------
/* this file includes the database connection, cookies, global functions, and loads the configuration file */
require_once "Mail.php";
require_once "Mail/mime.php";
/* load the configuration info [[these two lines should be the only config variables specific to the website]] */
$cfg = LoadConfig('/nidb/programs/nidb.cfg');
date_default_timezone_set("America/New_York");
if (stristr($_SERVER['HTTP_HOST'], ":8080") != false) {
    $isdevserver = true;
} else {
    $isdevserver = false;
}
/* this is the first include file loaded by all pages, so... we'll put the page load start time in here */
$time = microtime();
$time = explode(' ', $time);
$time = $time[1] + $time[0];
$pagestart = $time;
/* database connection */
if ($isdevserver) {
    /* php-mysql */
    $link = mysql_connect($cfg['mysqldevhost'], $cfg['mysqldevuser'], $cfg['mysqldevpassword']) or die("Could not connect: " . mysql_error());
Esempio n. 7
0
            foreach ($settings as $section) {
                if (isset($oldSettings[$section])) {
                    if (is_array($oldSettings[$section])) {
                        $sectionKeys = array_keys($newSettings[$section]);
                        foreach ($sectionKeys as $sectionKey) {
                            if (isset($oldSettings[$section][$sectionKey])) {
                                UpdateIniValue($conf, $sectionKey, $oldSettings[$section][$sectionKey]);
                            }
                        }
                    } else {
                        UpdateIniValue($conf, $section, $oldSettings[$section]);
                    }
                }
            }
        }
    }
}
// Backup the config files
$suffix = date("Ymdhis") . "-1.8.1";
foreach ($configFiles as $conf) {
    if (file_exists($conf)) {
        echo "Backing up {$conf} to {$conf}{$suffix}.bak" . PHP_EOL;
        exec("cp {$conf} {$conf}{$suffix}.bak");
    }
}
$default_suffix = "181";
CreateIniFiles($default_suffix);
echo "* Initializing INI files" . PHP_EOL;
MergeConfigFiles($configFiles, $suffix);
$CC_CONFIG = LoadConfig($CC_CONFIG);
Esempio n. 8
0
function exec_resources()
{
    $unix = new unix();
    $pidfile = "/etc/artica-postfix/pids/" . basename(__FILE__) . "." . __FUNCTION__ . ".pid";
    $pid = $unix->get_pid_from_file($pidfile);
    if ($unix->process_exists($pid)) {
        $TIMEF = $unix->PROCCESS_TIME_MIN($pid);
        cyrus_admin_mysql(1, "An Artica task already running PID {$pid} since {$TIMEF}Mn", "Aborted", __FILE__, __LINE__);
        return;
    }
    @file_put_contents($pidfile, getmypid());
    LoadConfig();
    if ($GLOBALS["CyrusBackupNas"]["WEBDAV_ENABLE"] == 1) {
        exec_webdav();
    }
    if ($GLOBALS["CyrusBackupNas"]["NAS_ENABLE"] == 0) {
        return;
    }
    $TimeStart = time();
    if (!tests_nas()) {
        cyrus_admin_mysql(0, "Unable to backup cyrus-mailboxes", null, __FILE__, __LINE__);
        return;
    }
    $hostname = $unix->hostname_g();
    $GLOBALS["DIRBYTES"] = date("YmdH");
    $GLOBALS["MOUNTED_PATH__BACKUPDIR"] = "{$GLOBALS["MOUNT_POINT"]}/{$hostname}";
    $GLOBALS["MOUNTED_PATH_FINAL"] = "{$GLOBALS["MOUNT_POINT"]}/{$hostname}/{$GLOBALS["DIRBYTES"]}";
    if (!is_dir($GLOBALS["MOUNTED_PATH_FINAL"])) {
        @mkdir($GLOBALS["MOUNTED_PATH_FINAL"], 0755, true);
        if (!is_dir($GLOBALS["MOUNTED_PATH_FINAL"])) {
            cyrus_admin_mysql(0, "Unable to backup: Permission denied on NAS", null, __FILE__, __LINE__);
            return;
        }
    }
    backup_ldap();
    backup_cyrus();
    $report[] = "Started at : " . date("Y-m-d H:i:s", $TimeStart);
    $report[] = "End at : " . date("Y-m-d H:i:s");
    $report[] = "Duration: " . $unix->distanceOfTimeInWords($TimeStart, time());
    @file_put_contents("{$GLOBALS["MOUNTED_PATH_FINAL"]}/report.txt", @implode("\r\n", $report));
    remove_containers();
    killNas();
}
Esempio n. 9
0
    {
        parent::INIBlockIO("map_server");
    }
}
class ServerConfig extends INIBlockIO
{
    public $map_database;
    public $map_server;
    public function ServerConfig()
    {
        $this->map_database = new MapDatabaseBlock();
        $this->map_server = new MapServerBlock();
        parent::INIBlockIO("");
    }
}
function LoadConfig()
{
    $config_path = "/usr/local/opensauce/config.ini";
    if (empty($config_path)) {
        die("ERROR: config.ini path not yet set in config.php<br/>");
    }
    $config_file = parse_ini_file($config_path, true);
    if ($config_file == FALSE) {
        die("ERROR: failed to load config.ini from the defined path. (" . $config_path . ")<br/>");
    }
    $config = new ServerConfig();
    $config->ReadBlock($config_file);
    return $config;
}
$config = LoadConfig();
Esempio n. 10
0
include_once 'ressources/class.ldap.inc';
include_once 'ressources/class.mysql.inc';
include_once 'ressources/class.os.system.inc';
ini_set('display_errors', 1);
ini_set('error_reporting', E_ALL);
ini_set('error_prepend_string', null);
ini_set('error_append_string', null);
include_once dirname(__FILE__) . '/framework/frame.class.inc';
include_once dirname(__FILE__) . '/framework/class.unix.inc';
if (!isset($GLOBALS["MYPID"])) {
    $GLOBALS["MYPID"] = @getmypid();
}
if (!defined("STDIN")) {
    define("STDIN", @fopen("php://stdin", "r"));
}
LoadConfig();
while (!feof(STDIN)) {
    $input = trim(fgets(STDIN));
    if (trim($input) == null) {
        continue;
    }
    $array = @explode(" ", trim($input));
    $requested_server = $array[3];
    $requested_uri = $array[2];
    $host = uri_to_host($requested_uri);
    while (list($num, $ligne) = each($array)) {
        WriteMyLogs("{$num} = \"{$ligne}\"", __LINE__);
    }
    if ($host == $GLOBALS["EXTERNAL_HOST"]) {
        @fwrite(STDOUT, "OK user=toto\n");
        continue;