function connetti_query($query) { global $Host, $User, $Password, $Database, $link; $ConfigManager = new ConfigManager(); $Host = $ConfigManager->getHost(); $User = $ConfigManager->getUser(); $Database = $ConfigManager->getDatabase(); $Password = $ConfigManager->getPassword(); // Connessione al database if (!($link = mysql_connect($Host, $User, $Password))) { die("Errore nella connessione al database! -> " . mysql_error()); } // Apertura del database if (!mysql_select_db($Database, $link)) { die("Errore nell'apertura del database mba!" . mysql_error()); } // Esucuzione della query if (!($result = mysql_query($query, $link))) { print "Errore nell'esecuzione della query! <br />"; die(mysql_error()); } //chiusura del collegamento al database mysql_close($link); //restituzione all'ambiente chiamante del risultato della query return $result; }
function elenco($idOperatore) { $ConfigManager = new ConfigManager(); $dbhost = $ConfigManager->getHost(); $dbuser = $ConfigManager->getUser(); $dbname = $ConfigManager->getDatabase(); $dbpass = $ConfigManager->getPassword(); $conn = null; try { $conn = new PDO("mysql:host={$dbhost};dbname={$dbname}", $dbuser, $dbpass); $cmd = "\r\n\t\t\t\tselect \r\n\t\t\t\t\trusc_conferimenti.id as id_conferimento,\r\n\t\t\t\t\trusc_tipologia.descrizione as descrizione_conferimento, \r\n\t\t\t\t\trusc_conferimenti.data as data_conferimento,\r\n\t\t\t\t\trusc_operatori.descrizione as descrizione_operatore\r\n\t\t\t\tfrom \r\n\t\t\t\t\trusc_conferimenti, \r\n\t\t\t\t\trusc_tipologia,\r\n\t\t\t\t\trusc_operatori\r\n\t\t\t\twhere \r\n\t\t\t\t\trusc_conferimenti.tipologia = rusc_tipologia.id\r\n\t\t\t\t\tand rusc_conferimenti.operatore = rusc_operatori.id\r\n\t\t\t\t\tand rusc_operatori.id = " . $idOperatore; $result = $conn->prepare($cmd); $result->execute(); $return_arr = array(); $row_array = array(); while ($row = $result->fetch(PDO::FETCH_ASSOC)) { $row_array['idConferimento'] = utf8_encode($row['id_conferimento']); $row_array['descrizioneConferimento'] = utf8_encode($row['descrizione_conferimento']); $row_array['dataConferimento'] = utf8_encode($row['data_conferimento']); $row_array['descrizioneOperatore'] = utf8_encode($row['descrizione_operatore']); array_push($return_arr, $row_array); } $conn = NULL; return json_encode($return_arr); } catch (PDOException $e) { echo $e->getMessage(); } }
function elenco() { $ConfigManager = new ConfigManager(); $dbhost = $ConfigManager->getHost(); $dbuser = $ConfigManager->getUser(); $dbname = $ConfigManager->getDatabase(); $dbpass = $ConfigManager->getPassword(); $conn = null; try { $conn = new PDO("mysql:host={$dbhost};dbname={$dbname}", $dbuser, $dbpass); $cmd = "\r\n\t\t\t\tselect \r\n\t\t\t\t\trusc_tipologia.id as id_tipologia,\r\n\t\t\t\t\trusc_tipologia.codice as codice_tipologia,\r\n\t\t\t\t\trusc_tipologia.descrizione as descrizione_tipologia \r\n\t\t\t\tfrom \r\n\t\t\t\t\trusc_tipologia\r\n\t\t\t\torder by rusc_tipologia.codice"; $result = $conn->prepare($cmd); $result->execute(); $return_arr = array(); $row_array = array(); while ($row = $result->fetch(PDO::FETCH_ASSOC)) { $row_array['idTipologia'] = utf8_encode($row['id_tipologia']); $row_array['codiceTipologia'] = utf8_encode($row['codice_tipologia']); $row_array['descrizioneTipologia'] = utf8_encode($row['descrizione_tipologia']); array_push($return_arr, $row_array); } $conn = NULL; return json_encode($return_arr); } catch (PDOException $e) { echo $e->getMessage(); } }
function login($username, $password) { $ConfigManager = new ConfigManager(); $dbhost = $ConfigManager->getHost(); $dbuser = $ConfigManager->getUser(); $dbname = $ConfigManager->getDatabase(); $dbpass = $ConfigManager->getPassword(); $conn = null; try { $conn = new PDO("mysql:host={$dbhost};dbname={$dbname}", $dbuser, $dbpass); $cmd = "\n\t\t\t\tSELECT \t\n\t\t\t\t\tid as id_operatore,\n\t\t\t\t\tusername as username_operatore,\n\t\t\t\t\tpassword as password_operatore,\n\t\t\t\t\tdescrizione as descrizione_operatore\n\t\t\t\tFROM \trusc_operatori \n\t\t\t\tWHERE \tusername = :username\n\t\t\t\t\t\tAND password = :password"; $result = $conn->prepare($cmd); $result->bindValue(":username", $username); $result->bindValue(":password", $password); $result->execute(); $return_arr = array(); $row_array = array(); while ($row = $result->fetch(PDO::FETCH_ASSOC)) { $row_array['idOperatore'] = utf8_encode($row['id_operatore']); $row_array['usernameOperatore'] = utf8_encode($row['username_operatore']); $row_array['descrizioneOperatore'] = utf8_encode($row['descrizione_operatore']); array_push($return_arr, $row_array); } $conn = NULL; return json_encode($return_arr); } catch (PDOException $e) { return json_encode($e->getMessage()); } }
public function __construct() { $ConfigManager = new ConfigManager(); $this->Host = $ConfigManager->getHost(); $this->User = $ConfigManager->getUser(); $this->Database = $ConfigManager->getDatabase(); $this->Password = $ConfigManager->getPassword(); }
public function testPrefixIfNeeded() { $dm = new Downloader(); $cm1 = new ConfigManager(array("ZipBackupFolder" => "bla"), $this->dm); $cm1->prefixIfNeeded("foo"); $this->assertEquals($cm1->config["ZipBackupFolder"], "foo/bla"); $cm2 = new ConfigManager(array("ZipBackupFolder" => "/bla"), $this->dm); $cm2->prefixIfNeeded("foo"); $this->assertEquals($cm2->config["ZipBackupFolder"], "/bla"); }
function setup($dbHost, $dbUsername, $dbPassword, $dbName, $controlThreads, $controlInterval) { if ($dbHost == "" || $dbUsername == "" || $dbPassword == "" || $dbName == "") { throw new Exception("La configuration de Base de données est incomplète"); } /*if ($controlThreads == "" || $controlInterval == "" || !is_numeric($controlThreads) || !is_numeric($controlInterval)) throw new Exception("La configuration de Contrôle est incomplète");*/ if ($controlThreads == "" || !is_numeric($controlThreads)) { throw new Exception("Le champ Threads de contrôle est vide"); } if ($controlInterval == "" || !is_numeric($controlInterval)) { throw new Exception("Le champ Intervalle de contrôle est vide"); } $cm = new ConfigManager(ADMIN_CONFIG_PATH); $cm->loadINIFile(); $cm->setConfig('database', 'db_host', $dbHost); $cm->setConfig('database', 'db_auth_username', $dbUsername); $cm->setConfig('database', 'db_auth_password', $dbPassword); $cm->setConfig('database', 'db_auth_dbname', $dbName); $cm->setConfig('control', 'ac_control_threads', $controlThreads); $cm->setConfig('control', 'ac_control_frequency', $controlInterval); $cm->saveINIFile(); $_SESSION["message"] = array("type" => "success", "title" => "Configuration terminée", "descr" => "La configuration a été modifiée avec succès."); header('Location: ' . '/monitoring/?v=admin&tab=config'); exir(0); }
function login($username, $password) { $ConfigManager = new ConfigManager(); $elementNamespace = $ConfigManager->getGecredNamespace(); $gecredUrl = $elementNamespace . '.php?wsdl'; $client = new nusoap_client($gecredUrl, true); // false: no WSDL // Call the SOAP method $result = $client->call('login', array('username' => $username, 'password' => $password)); return $result; }
protected function loadYubikeyUserAuthorization() { $usersConfig = ConfigManager::getConfig("Users", "Users"); $resultingConfig = ConfigManager::mergeConfigs($usersConfig->AuxConfig, $this->config->AuxConfig); $yubikeyUserAuthorization = new YubikeyUserAuthorization(Reg::get($usersConfig->Objects->UserManagement), $resultingConfig); $this->register($yubikeyUserAuthorization); }
public function uninstall() { $this->drop_tables(); ConfigManager::delete('web', 'config'); CacheManager::invalidate('module', 'web'); WebService::get_keywords_manager()->delete_module_relations(); }
/** * Get configs from DB and merge them with global config * * @param int $cacheMinutes */ public static function initDBConfig($cacheMinutes = null) { $sql = MySqlDbManager::getQueryObject(); $sql->exec("SELECT * FROM `" . Tbl::get("TBL_CONFIGS") . "`", $cacheMinutes); $dbConfig = static::parseDBRowsToConfig($sql->fetchRecords()); ConfigManager::setGlobalConfig(ConfigManager::mergeConfigs($dbConfig, ConfigManager::getGlobalConfig())); }
/** * Gets the singleton instance of the ConfigManager. */ public static function instance() { if(is_null(self::$INSTANCE)) { self::$INSTANCE = new ConfigManager(); } return self::$INSTANCE; }
/** * Get environment instance (singleton) */ public static function getInstance($entrance = '') { if (is_null(self::$configmanager)) { self::$configmanager = new self($entrance); } return self::$configmanager; }
/** * loads the importSchema configs into sfConfig * * @see sfImportSchemaConfigHandler * @see %sf_plugins_dir%/config_handlers.yml * * @return void */ public static function includeConfig() { include_once sfContext::getInstance()->getConfigCache()->checkConfig('config/sfExportGlobals.yml'); include_once sfContext::getInstance()->getConfigCache()->checkConfig('config/sfExportConfig.yml'); !self::$confSrc && (self::$confSrc = array('reports' => sfConfig::get('mod_export_reports'), 'globals' => sfConfig::get('mod_export_globals'))); return self::$confSrc; }
public static function decrypt($string, $key = null, $salt = null, $iv = null) { $config = ConfigManager::getConfig('Crypto', 'AES256')->AuxConfig; if ($key === null) { $key = $config->key; } if ($salt === null) { $salt = $config->salt; } if ($iv === null) { $iv = $config->iv; } $td = mcrypt_module_open('rijndael-128', '', MCRYPT_MODE_CBC, ''); $ks = mcrypt_enc_get_key_size($td); $bs = mcrypt_enc_get_block_size($td); $iv = substr(hash("sha256", $iv), 0, $bs); // Create key $key = Crypto::pbkdf2("sha512", $key, $salt, $config->pbkdfRounds, $ks); // Initialize encryption module for decryption mcrypt_generic_init($td, $key, $iv); $decryptedString = ""; // Decrypt encrypted string try { if (ctype_xdigit($string)) { $decryptedString = trim(mdecrypt_generic($td, pack("H*", $string))); } } catch (ErrorException $e) { } // Terminate decryption handle and close module mcrypt_generic_deinit($td); mcrypt_module_close($td); // Show string return $decryptedString; }
protected function loadrewriteAliasURL() { $rewriteURLconfig = $this->packageManager->getPluginConfig("RewriteURL", "RewriteURL")->AuxConfig; $hostConfig = ConfigManager::getConfig("Host", "Host"); $this->rewriteAliasURL = new RewriteAliasURL($rewriteURLconfig, $this->aliasMap->getAliasMap(Reg::get($hostConfig->Objects->Host))); $this->register($this->rewriteAliasURL); }
public static function init() { if (!self::$initialized) { Profiler::StartTimer("DNSResolver::Init()", 3); $cfg = ConfigManager::singleton(); if (isset($cfg->servers["dnsresolver"]["ttl"])) { self::$ttl = $cfg->servers["dnsresolver"]["ttl"]; } if (isset($cfg->servers["dnsresolver"]["cache"])) { self::$cache = $cfg->servers["dnsresolver"]["cache"]; } // parse /etc/resolv.conf to get domain/search suffixes if (file_exists("/etc/resolv.conf")) { $resolv = file("/etc/resolv.conf"); for ($i = 0; $i < count($resolv); $i++) { if (preg_match("/^\\s*(.*?)\\s+(.*)\\s*\$/", $resolv[$i], $m)) { switch ($m[1]) { case 'domain': self::$domain = $m[2]; array_unshift(self::$search, self::$domain); break; case 'search': self::$search[] = $m[2]; break; } } } self::$search[] = ""; } self::$initialized = true; Profiler::StopTimer("DNSResolver::Init()"); } }
/** * Does login operation * @param string $username * @param string $password * @param bool $writeCookie * @param bool $isPasswordEncrypted * * @throws RuntimeException (Codes: 1 - Incorrect login/password combination, 2 - Account is disabled) */ public function doLogin($username, $password, $writeCookie = false, $isPasswordEncrypted = false) { if ($this->um->checkCredentials($username, $password, $isPasswordEncrypted)) { $this->usr = $this->um->getObjectByLogin($username); $this->authorize($this->usr); $this->saveUserId($this->usr->getId()); if ($writeCookie) { $secs = getdate(); $exp_time = $secs[0] + 60 * 60 * 24 * $this->config->rememberDaysCount; $cookie_value = $this->usr->getId() . ":" . hash('sha256', $username . ":" . md5($password)); setcookie($this->config->loginCookieName, $cookie_value, $exp_time, '/'); } if (Reg::get('packageMgr')->isPluginLoaded("Security", "RequestLimiter") and $this->config->bruteForceProtectionEnabled) { $this->query->exec("DELETE FROM `" . Tbl::get('TBL_SECURITY_INVALID_LOGINS_LOG') . "` WHERE `ip`='" . $_SERVER['REMOTE_ADDR'] . "'"); } } else { if (Reg::get('packageMgr')->isPluginLoaded("Security", "RequestLimiter") and $this->config->bruteForceProtectionEnabled) { $this->query->exec("SELECT `count` \n\t\t\t\t\t\t\t\t\t\t\tFROM `" . Tbl::get('TBL_SECURITY_INVALID_LOGINS_LOG') . "` \n\t\t\t\t\t\t\t\t\t\t\tWHERE `ip`='" . $_SERVER['REMOTE_ADDR'] . "'"); $failedAuthCount = $this->query->fetchField('count'); $newFailedAuthCount = $failedAuthCount + 1; if ($newFailedAuthCount >= $this->config->failedAuthLimit) { Reg::get(ConfigManager::getConfig("Security", "RequestLimiter")->Objects->RequestLimiter)->blockIP(); $this->query->exec("DELETE FROM `" . Tbl::get('TBL_SECURITY_INVALID_LOGINS_LOG') . "` WHERE `ip`='" . $_SERVER['REMOTE_ADDR'] . "'"); throw new RequestLimiterTooManyAuthTriesException("Too many unsucessful authorization tries."); } $this->query->exec("INSERT INTO `" . Tbl::get('TBL_SECURITY_INVALID_LOGINS_LOG') . "` (`ip`) \n\t\t\t\t\t\t\t\t\t\tVALUES ('" . $_SERVER['REMOTE_ADDR'] . "')\n\t\t\t\t\t\t\t\t\t\tON DUPLICATE KEY UPDATE `count` = `count` + 1"); } throw new RuntimeException("Incorrect login/password combination", static::EXCEPTION_INCORRECT_LOGIN_PASSWORD); } }
function isAuthorized() { if (Reg::isRegistered(ConfigManager::getConfig("Users", "Users")->ObjectsIgnored->User)) { return true; } return false; }
/** * @return ConfigManager instance */ public static function getInstance() { if (is_null(self::$_instance)) { self::$_instance = new ConfigManager(); } return self::$_instance; }
protected function initialize() { $this->config = ConfigManager::bind(); // setting limit time set_time_limit($this->config['webbot']['time_limit']); $this->container = new Pimple(); // initializing persistence $config = $this->config; if ($config['general']['persistence']['use_database']) { if (!isset($config['general']['persistence']['connections'])) { throw new ConfigurationAccessException(101); } if (!is_array($config['general']['persistence']['connections']) || count($config['general']['persistence']['connections']) < 1) { throw new ConfigurationAccessException(102); } $connections = $config['general']['persistence']['connections']; // initializing ActiveRecord ActiveRecord\Config::initialize(function ($cfg) use($connections, $config) { $cfg->set_model_directory($config->getBaseDir() . '/' . $config['general']['persistence']['models_dir']); $cfg->set_connections($connections); // assigning as default conection the first one $default_con_index = array_shift(array_keys($connections)); $cfg->set_default_connection($default_con_index); }); } $this->loadStartups(); }
protected function loadGeoIPGps() { $geoIPConfig = ConfigManager::getConfig("GeoIP", "GeoIP"); $gpsConfig = ConfigManager::getConfig("Gps", "Gps"); $geoIpGps = new GeoIPGps(Reg::get($geoIPConfig->Objects->GeoIP), Reg::get($gpsConfig->Objects->Gps)); $this->register($geoIpGps); }
function smarty_block_config($params, $content, &$smarty) { global $webapp; static $initialized = false; if (empty($params->skipcobrand)) { // FIXME - this should also apply to page_component's getCobrandContent() somehow... $cfgmgr = ConfigManager::singleton(); if (!$initialized) { $heirarchy = $cfgmgr->GetConfigHeirarchy("cobrand." . $webapp->cobrand); foreach (array_reverse($heirarchy) as $cfgname) { // Walk heirarchy from bottom up if (preg_match("/^cobrand\\.(.*)\$/", $cfgname, $m) || $cfgname == "base") { // FIXME - most general-purpose would be to use the cobrand key as imagedir (s/\./\//g?) $cobrandname = $cfgname == "base" ? $cfgname : $m[1]; if (!empty($cobrandname)) { DependencyManager::add(array("type" => "component", "name" => "cobrands." . $cobrandname, "priority" => 4)); //DependencyManager::add(array("type"=>"component", "name"=>"cobrands.".$cobrandname."-fixes", "priority"=>4)); } } } $initialized = true; } } return trim($content); }
/** * Get the current instance of the ConfigManager or a new one if there is no * instance alive. * @return ConfigManager */ public static function &getInstance() { if (ConfigManager::$instance == null) { ConfigManager::$instance = new ConfigManager(); } return ConfigManager::$instance; }
public function updateAttachmentMessageId($attachmentId, $newMessageId) { if (empty($attachmentId) or !is_numeric($attachmentId)) { throw new InvalidIntegerArgumentException("\$attachmentId have to be non zero integer."); } if (empty($newMessageId) or !is_numeric($newMessageId)) { throw new InvalidIntegerArgumentException("\$newMessageId have to be non zero integer."); } $convMgr = Reg::get(ConfigManager::getConfig("Messaging", "Conversations")->Objects->ConversationManager); $filter = new ConversationMessagesFilter(); $filter->setId($newMessageId); $message = $convMgr->getConversationMessage($filter); $qb = new QueryBuilder(); $qb->update(Tbl::get('TBL_CONVERSATION_ATTACHEMENTS'))->set(new Field('message_id'), $message->id)->where($qb->expr()->equal(new Field('id'), $attachmentId)); MySqlDbManager::getDbObject()->startTransaction(); try { $convMgr->setMessageHasAttachment($message); $affected = $this->query->exec($qb->getSQL())->affected(); if (!MySqlDbManager::getDbObject()->commit()) { MySqlDbManager::getDbObject()->rollBack(); } } catch (Exception $e) { MySqlDbManager::getDbObject()->rollBack(); throw $e; } }
private function sendWithSwift($to, $subject, $message, $from) { //mail($to, $subject, $message, $headers); $message = Swift_Message::newInstance()->setSubject($subject)->setFrom(array($from))->setTo(array($to))->setBody($message); $transport = Swift_SmtpTransport::newInstance(ConfigManager::getMailHost(), ConfigManager::getMailPort()); $mailer = Swift_Mailer::newInstance($transport); $result = $mailer->send($message); }
function __construct($PLANET) { $this->Config = ConfigManager::declareConfigValue(); $this->ReactionTime = $this->Config['ReactionTime']; // if the attack will come within 10min, defend the planet // ReactionTime should be longer than the attacks detecting period for the defender $this->PLANET = $PLANET; }
/** * 引导启动服务 * @param Application $app * @throws Exception\BootstrapException */ public static function start(Application $app) { self::$_app = $app; //设置时区 $timeZone = ConfigManager::get('timezone'); date_default_timezone_set($timeZone); self::$_app->run(); }
public function __construct() { $this->app_path = APP_PATH; $configManager = ConfigManager::getInstance(); if ($configManager->valueExists('global.app_path')) { $this->app_path = $configManager->getValue('global.app_path'); } }
public function hookAddMemcacheTimeConfig(array $params) { extract($params); if (isset($pluginConfig->Memcache)) { foreach ($pluginConfig->Memcache->toArray() as $className => $cacheTime) { ConfigManager::addConfig(array('Db', 'Memcache', 'AuxConfig', 'Time'), $className, $cacheTime); } } }