public function _new() { if (_root::getRequest()->isPost()) { $sProject = _root::getParam('projet'); if (isset($_POST['opt']) and $_POST['opt'] == 'withexamples') { model_mkfbuilderprojet::getInstance()->create(_root::getParam('projet')); self::getTools()->updateLayoutTitle(_root::getParam('projet')); } else { if (isset($_POST['opt']) and $_POST['opt'] == 'withBootstrap') { model_mkfbuilderprojet::getInstance()->createEmpty($sProject); //copy bootstrap model_mkfbuilderprojet::getInstance()->copyFromTo('data/sources/fichiers/layout/bootstrap.php', 'data/genere/' . $sProject . '/layout/bootstrap.php'); //update title self::getTools()->updateFile(_root::getParam('projet'), array('examplesite' => $sProject), 'layout/bootstrap.php'); //update layout self::getTools()->updateFile(_root::getParam('projet'), array('template1' => 'bootstrap'), 'module/default/main.php'); } else { model_mkfbuilderprojet::getInstance()->createEmpty(_root::getParam('projet')); self::getTools()->updateLayoutTitle(_root::getParam('projet')); } } _root::redirect('builder::list'); } $oTpl = new _tpl('builder::new'); $oTpl->iswritable = is_writable(_root::getConfigVar('path.generation')); $this->oLayout->add('main', $oTpl); }
public function _login() { $oView = new _view('auth::login'); $this->oLayout->add('main', $oView); if (_root::getRequest()->isPost()) { $sLogin = _root::getParam('login'); $sPass = sha1(_root::getParam('password')); $oModelAccount = new model_account(); $tAccount = $oModelAccount->getListAccount(); if (_root::getAuth()->checkLoginPass($tAccount, $sLogin, $sPass)) { $oAccount = _root::getAuth()->getAccount(); $tPermission = model_permission::getInstance()->findByGroup($oAccount->groupe); //on purge les permissions en session _root::getACL()->purge(); //boucle sur les permissions if ($tPermission) { foreach ($tPermission as $oPermission) { if ($oPermission->allowdeny == 'ALLOW') { _root::getACL()->allow($oPermission->action, $oPermission->element); } else { _root::getACL()->deny($oPermission->action, $oPermission->element); } } } _root::redirect('prive::list'); } } }
private function mongodbAddCollection() { $oModelMongo = new model_mkfbuilderfactory(); $oModelMongo->setConfig(_root::getParam('sConfig')); $oModelMongo->getSgbd()->getDb()->createCollection(_root::getParam('collection')); _root::redirect('builder::edit', array('id' => _root::getParam('id'), 'action' => _root::getParam('action'), 'sConfig' => _root::getParam('sConfig'))); }
public function enable() { _root::startSession(); $sModuleToLoad = _root::getRequest()->getModule(); if (preg_match('/::/', _root::getConfigVar('auth.module'))) { $tModuleAction = preg_split('/::/', _root::getConfigVar('auth.module')); $sAuthModule = $tModuleAction[0]; } else { $sAuthModule = _root::getConfigVar('auth.module'); } if (!_root::getAuth()->isConnected() and $sModuleToLoad != $sAuthModule) { _root::redirect(_root::getConfigVar('auth.module')); } }
public static function _redirect($sRootModule, $tRootParams, $sModuleName, $sModuleAction, $tModuleParam = null) { $sPrefix = $sModuleName; $tParam = array(); if ($tRootParams) { $tParam = $tRootParams; } $tParam[$sPrefix . 'Action'] = $sModuleAction; if ($tModuleParam) { foreach ($tModuleParam as $sKey => $sVal) { $tParam[$sPrefix . $sKey] = $sVal; } } return _root::redirect($sRootModule, $tParam); }
public function enable() { _root::startSession(); $sModuleToLoad = _root::getRequest()->getModule(); if (preg_match('/::/', _root::getConfigVar('auth.module'))) { $tModuleAction = preg_split('/::/', _root::getConfigVar('auth.module')); $sAuthModule = $tModuleAction[0]; } else { $sAuthModule = _root::getConfigVar('auth.module'); } $tExcludeModule = explode(',', _root::getConfigVar('auth.module.disabled.list') . ','); $tExcludeModule[] = $sAuthModule; if (!_root::getAuth()->isConnected() and in_array($sModuleToLoad, $tExcludeModule) == false) { _root::redirect(_root::getConfigVar('auth.module')); } }
private function checkLoginPass() { //si le formulaire n'est pas envoye on s'arrete la if (!_root::getRequest()->isPost()) { return null; } $sLogin = _root::getParam('login'); $sPassword = _root::getParam('password'); if (strlen($sPassword > $this->maxPasswordLength)) { return 'Mot de passe trop long'; } //on stoque les mots de passe hashe dans la classe model_example $sHashPassword = model_example::getInstance()->hashPassword($sPassword); $tAccount = model_example::getInstance()->getListAccount(); //on va verifier que l'on trouve dans le tableau retourne par notre model //l'entree $tAccount[ login ][ mot de passe hashe ] if (!_root::getAuth()->checkLoginPass($tAccount, $sLogin, $sHashPassword)) { return 'Mauvais login/mot de passe'; } _root::redirect('privatemodule_action'); }
/** * methode appele a la deconnexion * @access public */ public function logout() { $this->_disconnect(); _root::redirect('auth::login'); }
public function delete() { if (!_root::getRequest()->isPost()) { //si ce n'est pas une requete POST on ne soumet pas return null; } $oPluginXsrf = new plugin_xsrf(); if (!$oPluginXsrf->checkToken(_root::getParam('token'))) { //on verifie que le token est valide return array('token' => $oPluginXsrf->getMessage()); } $oAccountModel = new model_account(); $iId = _root::getParam('id', null); if ($iId != null) { $oAccount = $oAccountModel->findById(_root::getParam('id', null)); } $oAccount->delete(); //une fois enregistre on redirige (vers la page d'edition) _root::redirect('account::list'); }
private function save() { if (!_root::getRequest()->isPost()) { return false; } $oPluginXsrf = new plugin_xsrf(); if (!$oPluginXsrf->checkToken(_root::getParam('token'))) { //on verifie que le token est valide return array('token' => $oPluginXsrf->getMessage()); } $oArticleModel = new model_article(); $iId = _root::getParam('id', null); if ($iId == null) { $oArticle = new row_article(); } else { $oArticle = $oArticleModel->findById(_root::getParam('id', null)); } foreach ($oArticleModel->getListColumn() as $sColumn) { if (_root::getParam($sColumn, null) == null) { continue; } if (in_array($sColumn, $oArticleModel->getIdTab())) { continue; } $oArticle->{$sColumn} = _root::getParam($sColumn, null); } if ($oArticle->save()) { //une fois enregistre on redirige (vers la page de liste) _root::redirect('prive::list'); } else { return $oArticle->getListError(); } }
private function saveFullCode() { if (!_root::getRequest()->isPost()) { return null; } $sContent = $_POST['content']; $oFile = new _file(_root::getParam('file')); //backup $oBackupFile = new _file(_root::getParam('file') . '.bak'); $oBackupFile->setContent($oFile->getContent()); $oBackupFile->save(); $tLine = $oFile->getTab(); $oFile->setContent($sContent); $oFile->save(); _root::redirect('code::editcode', array('project' => _root::getParam('project'), 'file' => _root::getParam('file'))); }
public function processDelete() { if (!_root::getRequest()->isPost()) { //si ce n'est pas une requete POST on ne soumet pas return null; } $oPluginXsrf = new plugin_xsrf(); if (!$oPluginXsrf->checkToken(_root::getParam('token'))) { //on verifie que le token est valide return array('token' => $oPluginXsrf->getMessage()); } $oPosts = model_posts::getInstance()->findById(_root::getParam('id', null)); $oPosts->delete(); //une fois enregistre on redirige (vers la page liste) _root::redirect('privatePosts::list'); }
public function _lang() { $sLang = _root::getParam('switch'); $bChange = false; $iswritable = true; $messageOK = null; $messageNOK = null; $message = null; if (_root::getConfigVar('language.default') != $sLang) { $bChange = true; $ret = "\n"; $sContent = null; $sContent .= '[language]' . $ret; $sContent .= ';fr / en...' . $ret; $sContent .= 'default=' . $sLang . $ret; $sContent .= 'allow=fr,en' . $ret; //check writable $iswritable = is_writable(_root::getConfigVar('path.conf') . 'language.ini.php'); if ($iswritable) { file_put_contents(_root::getConfigVar('path.conf') . 'language.ini.php', $sContent); _root::redirect('builder::new'); } else { $messageNOK = sprintf(tr('builder::new_errorVotreRepertoirePasInscriptible'), _root::getConfigVar('path.conf') . 'language.ini.php'); $message = sprintf(tr('builder::langVousPouvezEcrire'), $sContent, _root::getConfigVar('path.conf') . 'language.ini.php'); } } else { $message = sprintf(tr('builder::langVotreLangueEstDeja'), $sLang); } $oTpl = new _tpl('builder::lang'); $oTpl->bChange = $bChange; $oTpl->messageOK = $messageOK; $oTpl->messageNOK = $messageNOK; $oTpl->message = $message; $this->oLayout->add('main', $oTpl); }
public function _save() { $oAuteurModel = new model_auteur(); $iId = _root::getParam('id', null); if ($iId == null) { $oAuteur = new row_auteur(); } else { $oAuteur = $oAuteurModel->findById(_root::getParam('id', null)); } foreach ($oAuteurModel->getListColumn() as $sColumn) { if (_root::getParam($sColumn, null) === null) { continue; } if (in_array($sColumn, $oAuteurModel->getIdTab())) { continue; } $oAuteur->{$sColumn} = _root::getParam($sColumn, null); } $oAuteur->save(); _root::redirect('auteur::edit', array('id' => $oAuteur->getId())); }
private function processEditUser() { if (!_root::getRequest()->isPost()) { //si ce n'est pas une requete POST on ne soumet pas return null; } $oPluginXsrf = new plugin_xsrf(); if (!$oPluginXsrf->checkToken(_root::getParam('token'))) { //on verifie que le token est valide return array('token' => $oPluginXsrf->getMessage()); } $user_id = _root::getParam('id'); $group_id = _root::getParam('exampleUser_groupsId'); model_examplemodel::getInstance()->updateUserGroup($user_id, $group_id); _root::redirect('examplemodule::index'); }