public function InitConfig() { $cfg = new Config(); if ($cfg->getVar('application.display_errors') == 1) { ini_set('display_errors', 'On'); } else { ini_set('display_errors', 'Off'); } }
public function setAuth($login, $pass) { $config = new Config(); $this->cookie = new Cookie(); $table = $config->getVar('auth.table'); $table_log = $config->getVar('auth.login'); $table_pass = $config->getVar('auth.pass'); $db = new Db(); $sql = $db->select()->from($table)->where("{$table_log}='{$login}' and {$table_pass}='{$pass}'"); $sql = $sql->exec(); if (is_array($sql) && count($sql) == 1) { $this->cookie->setCookie('login', $login); $this->session->setSesValue('auth', 1); } else { $this->session->setSesValue('auth', 0); } }
private function getEntityManager() { $paths = array(Conf::getRootDir() . Conf::getDcotrineMappingsPath()); $isDevMode = true; // the connection configuration $dbParams = array('driver' => Conf::getDBDriver(), 'user' => Conf::getDBUser(), 'password' => Conf::getDBPassword(), 'dbname' => Conf::getDBName(), 'host' => Conf::getDBHost(), 'port' => Conf::getDBPort()); $configDoctrine = Setup::createXMLMetadataConfiguration($paths, $isDevMode); return EntityManager::create($dbParams, $configDoctrine); }
public function __construct($conn = "mysql") { try { $param_ini = new Config(); switch ($conn) { case "mysql": $this->_pdo = new PDO($param_ini->getVar('db.conn'), $param_ini->getVar('db.user'), $param_ini->getVar('db.pass')); break; case "mssql": $this->_pdo = new PDO($param_ini->getVar('db.conn_mssql'), $param_ini->getVar('db.user_mssql'), $param_ini->getVar('db.pass_mssql')); break; default: $this->_pdo = new PDO($param_ini->getVar('db.conn_' . $conn), $param_ini->getVar('db.user_' . $conn), $param_ini->getVar('db.pass_' . $conn)); } //if ($conn == "mysql") $this->_pdo = new PDO($param_ini->getVar('db.conn'),$param_ini->getVar('db.user'),$param_ini->getVar('db.pass')); //if ($conn == "mssql") $this->_pdo = new PDO($param_ini->getVar('db.conn_mssql'),$param_ini->getVar('db.user_mssql'),$param_ini->getVar('db.pass_mssql')); } catch (\PDOException $e) { throw Exeption::ThrowDb($e); } }
public function setAuth($login, $pass) { $db = new Db(); $conf = new Config(); if ($conf->getVar('super.user') == $login && $conf->getVar('super.pass') == $pass) { $this->session->setSesValue('login', $login); $this->session->setSesValue('pass', $pass); $this->session->setSesValue('organization', 'all'); return true; } else { $sql = $db->select()->from('Authorization')->join('Authorization', 'Organizations', 'User_Id')->where("Authorization.Login='******' AND Authorization.Pass='******'"); $sql = $sql->exec(); if (count($sql) == 1) { $this->session->setSesValue('login', $login); $this->session->setSesValue('pass', $pass); $this->session->setSesValue('organization', $sql[0]['Organization_Id']); return true; } } return false; }
function load() { $num = Conf::$user["role"]; $compteurarray = null; do { do { $role = Conf::$numerorole[$num]; if (is_array($role)) { if (is_null($compteurarray)) { $compteurarray = 0; } $r = $role; $role = $role[$compteurarray]; $compteurarray++; if ($compteurarray == count($r)) { $compteurarray = null; $num--; } } else { $num--; } if ($role === \config\Conf::$numerorole[1]) { $cname = '\\controller\\' . ucfirst($this->request->controller); } else { $cname = '\\controller\\' . strtolower($role) . '\\' . ucfirst($this->request->controller); } } while (!file_exists(ROOT . DS . str_replace("\\", DS, $cname) . ".php") && $num > 0); Conf::$rolevue = strtolower($role); $controller = new $cname($this->request, $this->debug); } while (!in_array($this->request->action, get_class_methods($controller)) && $num > 0); if (!in_array($this->request->action, get_class_methods($controller))) { trigger_error("Le controller " . $this->request->controller . " n'a pas de méthode " . $this->request->action); $this->error("Le controller " . $this->request->controller . " n'a pas de méthode " . $this->request->action); } /*$r = new \ReflectionMethod($controller, $this->request->action); $params = $r->getParameters(); foreach ($params as $param) { //$param is an instance of ReflectionParameter echo $param->getName() . "<br>"; echo $param->isOptional() . "<br>"; } var_dump($this->request->params); var_dump($_GET); var_dump($this->request); die(); */ call_user_func_array(array($controller, $this->request->action), $this->request->params); $controller->render($this->request->action); }
public static function ThrowDef($mes, $display = true, $mes_user = '******', $params = 404) { $cfg = new Config(); if ($cfg->getVar('application.writelog') == 1) { $log = new Log('error'); $log->writeLog("\n"); $log->writeLog("------------Exeption------------"); $log->writeLog("time : " . date('h:i:s')); $log->writeLog('message : ' . $mes); } $staks = (array) debug_backtrace(); if ($display != false) { self::$count_end = count($staks); self::printTrace($staks); } if ($cfg->getVar('application.writelog.trace') == 1) { $log->writeLog('trace : ' . self::$printTraceLog); } $error_view = new Controller(); if ($cfg->getVar('application.trace_errors') == 1) { $error_view->viewError('error', self::$arTrace, $mes, $params); } else { $error_view->viewError('error_user', self::$arTrace, $mes_user, $params); } exit; }
static function makerConfEnd() { \config\Conf::$install = false; $content = MakerConf::maker(); file_put_contents(ROOT . DS . "config" . DS . "Conf.php", $content); }