示例#1
0
 public function __construct($sMicrotime)
 {
     $this->iStartMicrotime = self::microtime($sMicrotime);
     $iEndTime = self::microtime();
     self::$tTime[] = array('End', $iEndTime);
     $iDiff = $iEndTime - $this->iStartMicrotime;
     $this->add('Time', sprintf('%0.3f', $iDiff) . 's');
     $this->addComplexTimes('times', self::$tTime);
     $this->addComplex('$_GET', print_r($_GET, 1));
     if (isset($_POST)) {
         $this->addComplex('$_POST', print_r($_POST, 1));
     }
     if (isset($_SESSION)) {
         $this->addComplex('$_SESSION', print_r($_SESSION, 1));
     }
     if (isset($_SERVER)) {
         $this->addComplex('$_SERVER', print_r($_SERVER, 1));
     }
     $oRequest = _root::getRequest();
     $this->add('Module', $oRequest->getModule());
     $this->add('Action', $oRequest->getAction());
     $oFileLog = new _file(_root::getConfigVar('path.log', 'data/log/') . date('Y-m-d') . '_log.csv');
     if ($oFileLog->exist()) {
         $oFileLog->load();
         $sContentLog = $oFileLog->getContent();
         $this->addFileLog('File log', $sContentLog);
     }
     $sVarIniConfig = _root::getConfigVar('model.ini.var', 'db');
     $tClassSgbd = _root::getConfigVar($sVarIniConfig);
     $this->addComplexIni('Connexions', array($sVarIniConfig => $tClassSgbd));
     $tConfigSection = array('path', 'cache', 'language', 'auth', 'acl', 'navigation', 'urlrewriting', 'security', 'log', 'check', 'path', 'model');
     $tConfig = array();
     foreach ($tConfigSection as $sSection) {
         $tConfig[$sSection] = _root::getConfigVar($sSection);
     }
     $this->addComplexIni('Config', $tConfig);
     if (self::$tSpy) {
         $this->addComplexSpy('Spy variables', self::$tSpy);
     }
     $this->addAcl();
 }
示例#2
0
 public function genModelTplCrudembeddedReadonly($sModule, $sClass, $tColumn, $sTableName)
 {
     //$tColumn=_root::getParam('tColumn');
     $tType = _root::getParam('tType');
     $tTpl = array('list', 'show');
     foreach ($tTpl as $sTpl) {
         $oFile = new _file('data/sources/fichiers/module/crudembeddedreadonly/view/' . $sTpl . '.php');
         $sContent = $oFile->getContent();
         preg_match_all('/#lignetd(.*)?#fin_lignetd/s', $sContent, $tMatch);
         $sLigne = $tMatch[1][0];
         preg_match_all('/#input(.*)?#fin_input/s', $sContent, $tMatch);
         $sInputText = $tMatch[1][0];
         preg_match_all('/#textarea(.*)?#fin_textarea/s', $sContent, $tMatch);
         $sInputTextarea = $tMatch[1][0];
         preg_match_all('/#select(.*)?#fin_select/s', $sContent, $tMatch);
         $sInputSelect = $tMatch[1][0];
         preg_match_all('/#upload(.*)?#fin_upload/s', $sContent, $tMatch);
         $sInputUpload = $tMatch[1][0];
         if ($sTpl == 'list') {
             //TH
             preg_match_all('/#ligneth(.*)?#fin_ligneth/s', $sContent, $tMatch);
             $sLigneTH = $tMatch[1][0];
         }
         $sTable = '';
         $sTableTh = '';
         $sEnctype = '';
         foreach ($tColumn as $i => $sColumn) {
             $sType = $tType[$i];
             if ($sType == 'text' or $sType == 'date') {
                 $sInput = preg_replace('/examplecolumn/', $sColumn, $sInputText);
                 $sInput = preg_replace('/oExamplemodel/', 'o' . ucfirst($sTableName), $sInput);
             } elseif ($sType == 'textarea') {
                 $sInput = preg_replace('/examplecolumn/', $sColumn, $sInputTextarea);
                 $sInput = preg_replace('/oExamplemodel/', 'o' . ucfirst($sTableName), $sInput);
             } elseif (substr($sType, 0, 7) == 'select;') {
                 $sInput = preg_replace('/examplecolumn/', $sColumn, $sInputSelect);
                 $sInput = preg_replace('/oExamplemodel/', 'o' . ucfirst($sTableName), $sInput);
                 $sInput = preg_replace('/examplemodel/', substr($sType, 7), $sInput);
             } elseif ($sType == 'upload') {
                 $sInput = preg_replace('/examplecolumn/', $sColumn, $sInputUpload);
                 $sInput = preg_replace('/oExamplemodel/', 'o' . ucfirst($sTableName), $sInput);
                 $sEnctype = ' enctype="multipart/form-data"';
                 //changement du enctype du formulaire
             }
             $sTable .= preg_replace('/examplecolumn/', $sColumn, preg_replace('/exampletd/', $sInput, $sLigne));
             $sTableTh .= preg_replace('/exampleth/', $sColumn, $sLigneTH);
         }
         $sContent = module_builder::getTools()->stringReplaceIn(array('oExamplemodel' => 'o' . ucfirst($sTableName), 'tExamplemodel' => 't' . ucfirst($sTableName), 'examplemodule' => $sModule, '<\\?php \\/\\/enctype\\?>' => $sEnctype, '<\\?php \\/\\/ici\\?>' => $sTable, '<\\?php \\/\\/icith\\?>' => $sTableTh, '<\\?php\\/\\*variables(.*)variables\\*\\/\\?>' => ''), 'data/sources/fichiers/module/crudembeddedreadonly/view/' . $sTpl . '.php');
         $oFile = new _file(_root::getConfigVar('path.generation') . _root::getParam('id') . '/module/' . $sModule . '/view/' . $sTpl . '.php');
         $oFile->setContent($sContent);
         $oFile->save();
         $oFile->chmod(0777);
     }
 }
示例#3
0
 private function genModelTpl($sModule, $sClass, $tColumn, $sTableName, $tCrud, $tLabel)
 {
     //$tColumn=_root::getParam('tColumn');
     $tType = _root::getParam('tType');
     $tCrud[] = 'list';
     $tTpl = array('list', 'show', 'edit', 'new', 'delete');
     $tTplCrud = array('show' => 'crudShow', 'new' => 'crudNew', 'delete' => 'crudDelete', 'edit' => 'crudEdit', 'list' => 'list');
     foreach ($tTpl as $sTpl) {
         //print $sTpl;
         if (!in_array($tTplCrud[$sTpl], $tCrud)) {
             //print "skip $sTpl ";
             continue;
         }
         $oFile = new _file('data/sources/fichiers/module/crudBootstrap/view/' . $sTpl . '.php');
         $sContent = $oFile->getContent();
         $oVar = simplexml_load_file('data/sources/fichiers/module/crudBootstrap/view/' . $sTpl . '.php.xml');
         $sLigne = (string) $oVar->lignetd;
         $sInputText = (string) $oVar->input;
         $sInputTextarea = (string) $oVar->textarea;
         $sInputSelect = (string) $oVar->select;
         $sInputUpload = (string) $oVar->upload;
         $sLinks = '';
         $sLinkNew = '';
         if ($sTpl == 'list') {
             //TH
             $sLigneTH = (string) $oVar->ligneth;
             //liens
             $tLink['crudNew'] = (string) $oVar->linkNew;
             $tLink['crudEdit'] = (string) $oVar->linkEdit;
             $tLink['crudShow'] = (string) $oVar->linkShow;
             $tLink['crudDelete'] = (string) $oVar->linkDelete;
             $iMaxCrud = count($tCrud);
             $iMaxCrud -= 2;
             foreach ($tCrud as $i => $sAction) {
                 if (in_array($sAction, array('crudNew', 'list'))) {
                     continue;
                 }
                 if (!isset($tLink[$sAction])) {
                     continue;
                 }
                 $sLinks .= $tLink[$sAction];
                 if ($i < $iMaxCrud) {
                     //$sLinks .= '| ';
                 }
             }
             if (in_array('crudNew', $tCrud)) {
                 $sLinkNew = $tLink['crudNew'];
             }
         }
         $sTable = '';
         $sTableTh = '';
         $sEnctype = '';
         foreach ($tColumn as $i => $sColumn) {
             $sLabel = $tLabel[$i];
             $sType = $tType[$i];
             if ($sType == 'text' or $sType == 'date') {
                 $sInput = preg_replace('/examplecolumn/', $sColumn, $sInputText);
                 $sInput = preg_replace('/oExamplemodel/', 'o' . ucfirst($sTableName), $sInput);
             } elseif ($sType == 'textarea') {
                 $sInput = preg_replace('/examplecolumn/', $sColumn, $sInputTextarea);
                 $sInput = preg_replace('/oExamplemodel/', 'o' . ucfirst($sTableName), $sInput);
             } elseif (substr($sType, 0, 7) == 'select;') {
                 $sInput = preg_replace('/examplecolumn/', $sColumn, $sInputSelect);
                 $sInput = preg_replace('/oExamplemodel/', 'o' . ucfirst($sTableName), $sInput);
                 $sInput = preg_replace('/examplemodel/', substr($sType, 7), $sInput);
             } elseif ($sType == 'upload') {
                 $sInput = preg_replace('/examplecolumn/', $sColumn, $sInputUpload);
                 $sInput = preg_replace('/oExamplemodel/', 'o' . ucfirst($sTableName), $sInput);
                 $sEnctype = ' enctype="multipart/form-data"';
                 //changement du enctype du formulaire
             }
             $sTable .= preg_replace('/examplecolumn/', $sLabel, preg_replace('/exampletd/', $sInput, $sLigne));
             $sTableTh .= preg_replace('/exampleth/', $sLabel, $sLigneTH);
         }
         $tReplace = array('<\\?php \\/\\/linknew\\?>' => $sLinkNew, '<\\?php \\/\\/links\\?>' => $sLinks, 'oExamplemodel' => 'o' . ucfirst($sTableName), 'tExamplemodel' => 't' . ucfirst($sTableName), 'examplemodule' => $sModule, '<\\?php \\/\\/enctype\\?>' => $sEnctype, '<\\?php \\/\\/ici\\?>' => $sTable, '<\\?php \\/\\/icith\\?>' => $sTableTh, '<\\?php \\/\\/colspan\\?>' => count($tColumn) + 1);
         $sContent = module_builder::getTools()->stringReplaceIn($tReplace, 'data/sources/fichiers/module/crudBootstrap/view/' . $sTpl . '.php');
         $oFile = new _file(_root::getConfigVar('path.generation') . _root::getParam('id') . '/module/' . $sModule . '/view/' . $sTpl . '.php');
         $oFile->setContent($sContent);
         $oFile->save();
         $oFile->chmod(0666);
     }
 }
示例#4
0
 private function genModuleMenuMain($sModuleMenuName, $tMethod, $tLabel)
 {
     $sData = null;
     foreach ($tMethod as $i => $sLink) {
         $sData .= '\'' . $tLabel[$i] . '\' => \'' . $sLink . '\',' . "\n";
     }
     $oMainFile = new _file('data/sources/fichiers/module/menuBootstrap/main.php');
     $sContentMain = $oMainFile->getContent();
     $sContentMain = preg_replace('/\\/\\/TABLEAUICI/', $sData, $sContentMain);
     $sContentMain = preg_replace('/examplemenu/', $sModuleMenuName, $sContentMain);
     $oFileTpl = new _file(_root::getConfigVar('path.generation') . _root::getParam('id') . '/module/' . $sModuleMenuName . '/main.php');
     $oFileTpl->setContent($sContentMain);
     $oFileTpl->save();
     $oFileTpl->chmod(0666);
     $oViewFile = new _file('data/sources/fichiers/module/menuBootstrap/view/index.php');
     $sContentView = $oViewFile->getContent();
     $oFileTpl2 = new _file(_root::getConfigVar('path.generation') . _root::getParam('id') . '/module/' . $sModuleMenuName . '/view/index.php');
     $oFileTpl2->setContent($sContentView);
     $oFileTpl2->save();
     $oFileTpl2->chmod(0666);
     //update title
     $oTools = new module_builderTools();
     $oTools->updateFile(_root::getParam('id'), array('examplesite' => _root::getParam('id')), 'module/' . $sModuleMenuName . '/view/index.php');
 }
示例#5
0
 private function stringReplaceIn($tMatch, $sFile)
 {
     $oFile = new _file($sFile);
     $sContent = $oFile->getContent();
     if ($tMatch and is_array($tMatch)) {
         foreach ($tMatch as $sPattern => $sReplace) {
             $sContent = preg_replace('/' . $sPattern . '/s', $sReplace, $sContent);
         }
     }
     return $sContent;
 }
示例#6
0
 private function generate()
 {
     if (!_root::getRequest()->isPost() or _root::getParam('formu') != 'generate') {
         return null;
     }
     $oPluginValid = new plugin_valid(_root::getRequest()->getParams());
     $oPluginValid->isNotEmpty('modulename', 'Le champ doit &ecirc;tre rempli');
     $oPluginValid->isNotEmpty('classmodel', 'Le champ doit &ecirc;tre rempli');
     $oPluginValid->isNotEmpty('redirect', 'Le champ doit &ecirc;tre rempli');
     if (!$oPluginValid->isValid()) {
         return $oPluginValid->getListError();
     }
     $sModuleName = _root::getParam('modulename');
     $sClassModuleName = 'module_' . $sModuleName;
     $sRedirectModuleAction = _root::getParam('redirect');
     $sModelName = _root::getParam('classmodel');
     $sViewName = $sModuleName . '::login';
     $sContent = module_builder::getTools()->stringReplaceIn(array('module_exampleauth' => $sClassModuleName, 'privatemodule_action' => $sRedirectModuleAction, 'model_example' => $sModelName, 'auth_login' => $sViewName), 'data/sources/fichiers/module/auth/main.php');
     module_builder::getTools()->projetmkdir('module/' . $sModuleName);
     $oFile = new _file(_root::getConfigVar('path.generation') . _root::getParam('id') . '/module/' . $sModuleName . '/main.php');
     $oFile->setContent($sContent);
     $oFile->save();
     $oFile->chmod(0666);
     module_builder::getTools()->projetmkdir('module/' . $sModuleName . '/view');
     $oFile = new _file('data/sources/fichiers/module/auth/view/login.php');
     $sContent = $oFile->getContent();
     $oNewViewFile = new _file(_root::getConfigVar('path.generation') . _root::getParam('id') . '/module/' . $sModuleName . '/view/login.php');
     $oNewViewFile->setContent($sContent);
     $oNewViewFile->save();
     return array('success' => 1);
 }
示例#7
0
 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')));
 }
示例#8
0
 public function stringReplaceIn($tMatch, $sFile)
 {
     $oFile = new _file($sFile);
     $sContent = $oFile->getContent();
     foreach ($tMatch as $sPattern => $sReplace) {
         $sContent = preg_replace('/' . $sPattern . '/s', $sReplace, $sContent);
     }
     return $sContent;
 }
示例#9
0
 /** 
  * lance le framework (dispatch...)
  * @access public	
  */
 public function run()
 {
     try {
         self::loadConf();
         self::loadAutoload();
         self::loadRequest();
         //parametrage du niveau d'erreur
         if (self::getConfigVar('site.mode') == 'dev') {
             error_reporting(E_ALL);
         } else {
             error_reporting(0);
         }
         self::getLog()->setInformation((int) self::getConfigVar('log.information'));
         self::getLog()->setWarning((int) self::getConfigVar('log.warning'));
         self::getLog()->setError((int) self::getConfigVar('log.error'));
         self::getLog()->setApplication((int) self::getConfigVar('log.application'));
         date_default_timezone_set(self::getConfigVar('site.timezone'));
         //auth
         if ((int) self::getConfigVar('auth.enabled') == 1) {
             self::getAuth()->enable();
         }
         //desactivation des magic quotes
         if (get_magic_quotes_gpc()) {
             $_POST = array_map('stripslashes_deep', $_POST);
             $_GET = array_map('stripslashes_deep', $_GET);
             $_COOKIE = array_map('stripslashes_deep', $_COOKIE);
             $this->getRequest()->magic_quote();
         }
         if ((int) self::getConfigVar('urlrewriting.enabled') == 1) {
             self::getUrlRewriting()->parseUrl($_SERVER['REQUEST_URI']);
         }
         $sModuleToLoad = self::getRequest()->getModule();
         $sModuleActionToLoad = self::getRequest()->getAction();
         /*LOG*/
         self::getLog()->info('module a appeler [' . $sModuleToLoad . '::' . $sModuleActionToLoad . ']');
         //chargement module/action
         $sClassModule = 'module_' . $sModuleToLoad;
         $oModule = new $sClassModule();
         if (method_exists($oModule, '_' . $sModuleActionToLoad)) {
             /*LOG*/
             self::getLog()->info('appel module [' . $sModuleToLoad . '::before]');
             $oModule->before();
             //pre action
             if (method_exists($oModule, 'before_' . $sModuleActionToLoad)) {
                 /*LOG*/
                 self::getLog()->info('appel module [' . $sModuleToLoad . '::before_' . $sModuleActionToLoad . ']');
                 $sActionBefore = 'before_' . $sModuleActionToLoad;
                 $oModule->{$sActionBefore}();
             }
             //debut cache
             if ((int) self::getConfigVar('cache.enabled') == 1) {
                 $sNomPageCache = 'cache_' . str_replace('::', '_', implode('_', self::getRequest()->getParams())) . '.html';
                 $oFichierCache = new _file(self::getConfigVar('path.cache') . $sNomPageCache);
                 if ($oFichierCache->exist() and (int) self::getConfigVar('cache.lifetime') == 0 or $oFichierCache->exist() and time() - $oFichierCache->filemtime() < (int) self::getConfigVar('cache.lifetime')) {
                     /*LOG*/
                     self::getLog()->info('utilisation page en cache [' . $sNomPageCache . ']');
                     echo $oFichierCache->getContent();
                     return;
                 }
                 ob_start();
             }
             $sAction = '_' . $sModuleActionToLoad;
             /*LOG*/
             self::getLog()->info('appel module [' . $sModuleToLoad . '::' . $sAction . ']');
             $oModule->{$sAction}();
             //post action
             if (method_exists($oModule, 'after_' . $sModuleActionToLoad)) {
                 /*LOG*/
                 self::getLog()->info('appel module [' . $sModuleToLoad . '::after_' . $sModuleActionToLoad . ']');
                 $sActionAfter = 'after_' . $sModuleActionToLoad;
                 $oModule->{$sActionAfter}();
             }
             //post module
             /*LOG*/
             self::getLog()->info('appel module [' . $sModuleToLoad . '::after]');
             $oModule->after();
             //fin cache
             if ((int) self::getConfigVar('cache.enabled') == 1) {
                 $sSortie = ob_get_contents();
                 ob_end_clean();
                 $oFichierCache->write($sSortie . "\n<!--cache -->");
                 echo $sSortie;
             }
         } else {
             $tErreur = array('Erreur dans module/' . $sModuleToLoad . '/main.php', 'Pas de m&eacute;thode _' . $sModuleActionToLoad . '() dans le module "' . $sModuleToLoad . '" &agrave; charger', 'Note: vous pouvez modifier le couple module/action par defaut ', 'en modifiant la section [navigation] dans le fichier conf/site.ini.php');
             throw new Exception(implode("\n", $tErreur));
         }
     } catch (Exception $e) {
         self::erreurLog($e->getMessage() . "\n" . self::showException($e), $e);
     }
 }