PageRenderTime 48ms CodeModel.GetById 16ms RepoModel.GetById 0ms app.codeStats 0ms

/gulliver/bin/tasks/templates/sysGeneric.php.tpl

https://github.com/caracolazo/pm
Smarty Template | 388 lines | 336 code | 52 blank | 0 comment | 62 complexity | cc8a636920692a8d076d7b127259c910 MD5 | raw file
Possible License(s): BSD-3-Clause, BSD-2-Clause, Apache-2.0, LGPL-2.1, GPL-3.0
  1. <?php
  2. /** autogenerated sysGeneric for project {projectName} */
  3. /*** enable display_error On to caught even fatal errors ***/
  4. ini_set('display_errors','On');
  5. ini_set('error_reporting', E_ALL );
  6. ini_set('memory_limit', '80M');
  7. $path = Array();
  8. $sf = $_SERVER['SCRIPT_FILENAME'];
  9. //sysGeneric, this file is used to redirect to workspace, the url should by encrypted or not
  10. //***************** In the PATH_SEP we know if the the path separator symbol will be '\\' or '/' **************************
  11. if ( PHP_OS == 'WINNT' && !strpos ( $_SERVER['DOCUMENT_ROOT'], '/' ) )
  12. define('PATH_SEP','\\');
  13. else
  14. define('PATH_SEP', '/');
  15. //***************** Defining the Home Directory *********************************
  16. $docuroot = explode ( PATH_SEP , $_SERVER['DOCUMENT_ROOT'] );
  17. // array_pop($docuroot);
  18. array_pop($docuroot);
  19. $pathhome = implode( PATH_SEP, $docuroot ) . PATH_SEP;
  20. //try to find automatically the trunk directory where are placed the RBAC and Gulliver directories
  21. //in a normal installation you don't need to change it.
  22. array_pop($docuroot);
  23. $pathTrunk = implode( PATH_SEP, $docuroot ) . PATH_SEP ;
  24. array_pop($docuroot);
  25. $pathOutTrunk = implode( PATH_SEP, $docuroot ) . PATH_SEP ;
  26. // to do: check previous algorith for Windows $pathTrunk = "c:/home/";
  27. define('PATH_HOME', $pathhome );
  28. define('PATH_TRUNK', $pathTrunk );
  29. define('PATH_OUTTRUNK', $pathOutTrunk );
  30. //***************** In this file we cant to get the PM paths , RBAC Paths and Gulliver Paths ******************************
  31. require_once ( $pathhome . PATH_SEP . 'engine' . PATH_SEP . 'config' . PATH_SEP . 'paths.php' );
  32. //***************** In this file we cant to get the PM definitions ******************************
  33. require_once ( $pathhome . PATH_SEP . 'engine' . PATH_SEP . 'config' . PATH_SEP . 'defines.php' );
  34. //******************* Error handler and log error *******************
  35. //to do: make different environments. sys
  36. //G::setErrorHandler ( );
  37. //G::setFatalErrorHandler ( );
  38. /*** enable ERROR_SHOW_SOURCE_CODE to display the source code for any WARNING OR NOTICE ***/
  39. define ('ERROR_SHOW_SOURCE_CODE', true);
  40. /*** enable ERROR_LOG_NOTICE_ERROR to log Notices messages in default apache log ***/
  41. // define ( 'ERROR_LOG_NOTICE_ERROR', true );
  42. // ************* creat headPublisher singleton *****************
  43. G::LoadSystem('headPublisher');
  44. $oHeadPublisher =& headPublisher::getSingleton();
  45. $oHeadPublisher->addMaborakFile( PATH_GULLIVER_HOME . 'js' . PATH_SEP . 'maborak/core/maborak.js' );
  46. $oHeadPublisher->addMaborakFile( PATH_GULLIVER_HOME . 'js' . PATH_SEP . 'common/core/common.js' );
  47. $oHeadPublisher->addMaborakFile( PATH_GULLIVER_HOME . 'js' . PATH_SEP . 'common/core/webResource.js' );
  48. $oHeadPublisher->addMaborakFile( PATH_GULLIVER_HOME . 'js' . PATH_SEP . 'dveditor/core/dveditor.js' );
  49. $oHeadPublisher->addMaborakFile( PATH_GULLIVER_HOME . 'js' . PATH_SEP . 'common/tree/tree.js' );
  50. $oHeadPublisher->addMaborakFile( PATH_GULLIVER_HOME . 'js' . PATH_SEP . 'json/core/json.js' );
  51. $oHeadPublisher->addMaborakFile( PATH_GULLIVER_HOME . 'js' . PATH_SEP . 'form/core/form.js' );
  52. $oHeadPublisher->addMaborakFile( PATH_GULLIVER_HOME . 'js' . PATH_SEP . 'form/core/pagedTable.js' );
  53. $oHeadPublisher->addMaborakFile( PATH_GULLIVER_HOME . 'js' . PATH_SEP . 'grid/core/grid.js' );
  54. $oHeadPublisher->addMaborakFile( PATH_GULLIVER_HOME . 'js' . PATH_SEP . 'maborak/core/module.panel.js' , true );
  55. $oHeadPublisher->addMaborakFile( PATH_GULLIVER_HOME . 'js' . PATH_SEP . 'maborak/core/module.validator.js', true );
  56. $oHeadPublisher->addMaborakFile( PATH_GULLIVER_HOME . 'js' . PATH_SEP . 'maborak/core/module.app.js' , true );
  57. $oHeadPublisher->addMaborakFile( PATH_GULLIVER_HOME . 'js' . PATH_SEP . 'maborak/core/module.rpc.js' , true );
  58. $oHeadPublisher->addMaborakFile( PATH_GULLIVER_HOME . 'js' . PATH_SEP . 'maborak/core/module.fx.js' , true );
  59. $oHeadPublisher->addMaborakFile( PATH_GULLIVER_HOME . 'js' . PATH_SEP . 'maborak/core/module.drag.js' , true );
  60. $oHeadPublisher->addMaborakFile( PATH_GULLIVER_HOME . 'js' . PATH_SEP . 'maborak/core/module.drop.js' , true );
  61. $oHeadPublisher->addMaborakFile( PATH_GULLIVER_HOME . 'js' . PATH_SEP . 'maborak/core/module.dom.js' , true );
  62. $oHeadPublisher->addMaborakFile( PATH_GULLIVER_HOME . 'js' . PATH_SEP . 'maborak/core/module.abbr.js' , true );
  63. $oHeadPublisher->addMaborakFile( PATH_GULLIVER_HOME . 'js' . PATH_SEP . 'maborak/core/module.dashboard.js', true );
  64. $oHeadPublisher->addMaborakFile( PATH_GULLIVER_HOME . 'js' . PATH_SEP . 'widgets/jscalendar/calendar.js' );
  65. //************ defining Virtual URLs ****************/
  66. $virtualURITable = array();
  67. $virtualURITable['/plugin/(*)'] = 'plugin';
  68. $virtualURITable['/(sys*)/(*.js)'] = 'jsMethod';
  69. $virtualURITable['/js/(*)'] = PATH_GULLIVER_HOME . 'js/';
  70. $virtualURITable['/jscore/(*)'] = PATH_CORE . 'js/';
  71. //$virtualURITable['/fckeditor/(*)'] = PATH_THIRDPARTY . 'fckeditor/';
  72. $virtualURITable['/htmlarea/(*)'] = PATH_THIRDPARTY . 'htmlarea/';
  73. $virtualURITable['/sys[a-zA-Z][a-zA-Z0-9]{0,}()/'] = 'sysNamed';
  74. $virtualURITable['/(sys*)'] = FALSE;
  75. $virtualURITable['/errors/(*)'] = PATH_GULLIVER_HOME . 'methods/errors/';
  76. $virtualURITable['/controls/(*)'] = PATH_GULLIVER_HOME . 'methods/controls/';
  77. $virtualURITable['/html2ps_pdf/(*)'] = PATH_THIRDPARTY . 'html2ps_pdf/';
  78. $virtualURITable['/Krumo/(*)'] = PATH_THIRDPARTY . 'krumo/';
  79. $virtualURITable['/codepress/(*)'] = PATH_THIRDPARTY . 'codepress/';
  80. if(defined('PATH_C'))
  81. {
  82. $virtualURITable['/jsform/(*.js)'] = PATH_C . 'xmlform/';
  83. }
  84. /*To sysUnnamed*/
  85. $virtualURITable['/[a-zA-Z][a-zA-Z0-9]{0,}()'] = 'sysUnnamed';
  86. $virtualURITable['/(*)'] = PATH_HTML;
  87. //************** verify if we need to redirect or stream the file **************
  88. if ( G::virtualURI($_SERVER['REQUEST_URI'], $virtualURITable , $realPath )) {
  89. // review if the file requested belongs to public_html plugin
  90. if ( substr ( $realPath, 0,6) == 'plugin' ) {
  91. $paths = explode ( PATH_SEP, $realPath );
  92. $paths[0] = substr ( $paths[0],6);
  93. if ( count($paths) == 2 ) {
  94. $pathsQuery = explode('?', $paths[1]);
  95. $pluginFilename = PATH_PLUGINS . $paths[0] . PATH_SEP . 'public_html'. PATH_SEP . $pathsQuery[0];
  96. if ( file_exists ( $pluginFilename ) ) {
  97. G::streamFile ( $pluginFilename );
  98. }
  99. }
  100. die;
  101. }
  102. switch ( $realPath ) {
  103. case 'sysUnnamed' :
  104. require_once('sysUnnamed.php'); die;
  105. break;
  106. case 'sysNamed' :
  107. header('location : ' . $_SERVER['REQUEST_URI'] . 'en/classic/login/login' );
  108. die;
  109. break;
  110. case 'jsMethod' :
  111. G::parseURI ( getenv( "REQUEST_URI" ) );
  112. $filename = PATH_METHODS . SYS_COLLECTION . '/' . SYS_TARGET . '.js';
  113. G::streamFile ( $filename );
  114. die;
  115. break;
  116. default :
  117. $realPath = explode('?', $realPath);
  118. G::streamFile ( $realPath[0] );
  119. die;
  120. }
  121. }
  122. //************** verify if the URI is encrypted or not **************
  123. G::parseURI ( getenv( "REQUEST_URI" ) );
  124. define( 'SYS_URI' , '/sys' . SYS_TEMP . '/' . SYS_LANG . '/' . SYS_SKIN . '/' );
  125. require_once ( PATH_THIRDPARTY . 'krumo' . PATH_SEP . 'class.krumo.php' );
  126. //***************** Call Gulliver Classes **************************
  127. G::LoadThirdParty('pear/json','class.json');
  128. G::LoadThirdParty('smarty/libs','Smarty.class');
  129. G::LoadSystem('error');
  130. G::LoadSystem('dbconnection');
  131. G::LoadSystem('dbsession');
  132. G::LoadSystem('dbrecordset');
  133. G::LoadSystem('dbtable');
  134. G::LoadSystem('rbac' );
  135. G::LoadSystem('publisher');
  136. G::LoadSystem('templatePower');
  137. G::LoadSystem('headPublisher');
  138. G::LoadSystem('xmlDocument');
  139. G::LoadSystem('xmlform');
  140. G::LoadSystem('xmlformExtension');
  141. G::LoadSystem('form');
  142. G::LoadSystem('menu');
  143. G::LoadSystem("xmlMenu");
  144. G::LoadSystem('dvEditor');
  145. G::LoadSystem('table');
  146. G::LoadSystem('pagedTable');
  147. G::LoadSystem('tree');
  148. $oHeadPublisher =& headPublisher::getSingleton();
  149. //***************** database and workspace definition ************************
  150. //if SYS_TEMP exists, the URL has a workspace, now we need to verify if exists their db.php file
  151. if ( defined('SYS_TEMP') && SYS_TEMP != '')
  152. {
  153. //this is the default, the workspace db.php file is in /shared/{projectName}/sites/SYS_SYS
  154. if ( file_exists( PATH_DB . SYS_TEMP . '/db.php' ) ) {
  155. require_once( PATH_DB . SYS_TEMP . '/db.php' );
  156. define ( 'SYS_SYS' , SYS_TEMP );
  157. }
  158. else {
  159. $sysParts = explode('-',SYS_TEMP);
  160. //try to find the definition in the module-file
  161. if ( count($sysParts) == 3) {
  162. $fileName = 'dbmodule_'.$sysParts[1].'.php';
  163. $DB_INDEX = 0;
  164. $DB_MODULE = array();
  165. if ( !file_exists( PATH_DB . $fileName)) {
  166. header ("location: errors/error701.php");
  167. die;
  168. }
  169. require_once ( PATH_DB . $fileName );
  170. $moduleName = $DB_MODULE[$DB_INDEX]['name'];
  171. $modulePath = $DB_MODULE[$DB_INDEX]['path'];
  172. $moduleType = $DB_MODULE[$DB_INDEX]['type'];
  173. if ( !file_exists( $modulePath )) {
  174. header ("location: /errors/error704.php"); die;
  175. }
  176. if ( $moduleType == 'single-file' ) {
  177. $workspaceDB = $modulePath. 'db_'. $sysParts[2] . '.php';
  178. }
  179. else {
  180. $workspaceDB = $modulePath. $sysParts[2] . '/db.php';
  181. }
  182. if ( !file_exists( $workspaceDB )) {
  183. header ("location: /errors/error704.php"); die;
  184. }
  185. require_once( $workspaceDB ) ;
  186. define ( 'SYS_SYS', $sysParts[2]);
  187. }
  188. else {
  189. $aMessage['MESSAGE'] = G::LoadTranslation ('ID_NOT_WORKSPACE');
  190. $G_PUBLISH = new Publisher;
  191. $G_PUBLISH->AddContent('xmlform', 'xmlform', 'login/showMessage', '', $aMessage );
  192. G::RenderPage( 'publish' );
  193. die;
  194. }
  195. }
  196. }
  197. else { //when we are in global pages, outside any valid workspace
  198. if ((SYS_TARGET==='sysLoginVerify') || (SYS_TARGET==='sysLogin') || (SYS_TARGET==='newSite')) {
  199. $phpFile = G::ExpandPath('methods') . SYS_COLLECTION . "/" . SYS_TARGET.'.php';
  200. require_once($phpFile);
  201. die();
  202. }
  203. else {
  204. require_once( PATH_METHODS . "login/sysLogin.php" ) ;
  205. die();
  206. }
  207. }
  208. //***************** PM Paths DATA **************************
  209. define( 'PATH_DATA_SITE', PATH_DATA . 'sites/' . SYS_SYS . '/');
  210. define( 'PATH_DOCUMENT', PATH_DATA_SITE . 'files/' );
  211. define( 'PATH_DYNAFORM', PATH_DATA_SITE . 'xmlForms/' );
  212. define( 'PATH_IMAGES_ENVIRONMENT_FILES', PATH_DATA_SITE.'usersFiles'.PATH_SEP);
  213. define( 'PATH_IMAGES_ENVIRONMENT_USERS', PATH_DATA_SITE.'usersPhotographies'.PATH_SEP);
  214. //***************** Plugins **************************
  215. G::LoadClass('plugin');
  216. // //here we are loading all plugins registered
  217. // //the singleton has a list of enabled plugins
  218. // $sSerializedFile = PATH_DATA_SITE . 'plugin.singleton';
  219. // $oPluginRegistry =& PMPluginRegistry::getSingleton();
  220. // if ( file_exists ($sSerializedFile) )
  221. // $oPluginRegistry->unSerializeInstance( file_get_contents ( $sSerializedFile ) );
  222. //
  223. // $oPluginRegistry->setupPlugins(); //get and setup enabled plugins
  224. //***************** create $G_ENVIRONMENTS dependent of SYS_SYS **************************
  225. define ( 'G_ENVIRONMENT', G_DEV_ENV );
  226. $G_ENVIRONMENTS = array (
  227. G_PRO_ENV => array (
  228. 'dbfile' => PATH_DB . 'production' . PATH_SEP . 'db.php' ,
  229. 'cache' => 1,
  230. 'debug' => 0,
  231. ) ,
  232. G_DEV_ENV => array (
  233. 'dbfile' => PATH_DB . SYS_SYS . PATH_SEP . 'db.php',
  234. 'datasource' => 'workflow',
  235. 'cache' => 0,
  236. 'debug' => 0,
  237. ) ,
  238. G_TEST_ENV => array (
  239. 'dbfile' => PATH_DB . 'test' . PATH_SEP . 'db.php' ,
  240. 'cache' => 0,
  241. 'debug' => 0,
  242. )
  243. );
  244. // setup propel definitions and logging
  245. //try {
  246. require_once ( "propel/Propel.php" );
  247. require_once ( "creole/Creole.php" );
  248. if ( $G_ENVIRONMENTS[ G_ENVIRONMENT ]['debug'] ) {
  249. require_once ( "Log.php" );
  250. // register debug connection decorator driver
  251. Creole::registerDriver('*', 'creole.contrib.DebugConnection');
  252. // itialize Propel with converted config file
  253. Propel::init( PATH_CORE . "config/databases.php" );
  254. //log file for workflow database
  255. $logFile = PATH_DATA . 'log' . PATH_SEP . 'workflow.log';
  256. $logger = Log::singleton('file', $logFile, 'wf ' . SYS_SYS, null, PEAR_LOG_INFO);
  257. Propel::setLogger($logger);
  258. $con = Propel::getConnection('workflow');
  259. if ($con instanceof DebugConnection) $con->setLogger($logger);
  260. //log file for rbac database
  261. $logFile = PATH_DATA . 'log' . PATH_SEP . 'rbac.log';
  262. $logger = Log::singleton('file', $logFile, 'rbac ' . SYS_SYS, null, PEAR_LOG_INFO);
  263. Propel::setLogger($logger);
  264. $con = Propel::getConnection('rbac');
  265. if ($con instanceof DebugConnection) $con->setLogger($logger);
  266. }
  267. else
  268. Propel::init( PATH_CORE . "config/databases.php" );
  269. Creole::registerDriver('dbarray', 'creole.contrib.DBArrayConnection');
  270. //***************** Session Initializations **************************/
  271. ini_alter( 'session.auto_start', '1' );
  272. ini_alter( 'register_globals', 'Off' );
  273. session_start();
  274. ob_start();
  275. //********* Log Page Handler *************
  276. // logPage ( $URL , SYS_CURRENT_PARMS);
  277. //*********jump to php file in methods directory *************
  278. // if ( $oPluginRegistry->isRegisteredFolder( SYS_COLLECTION ) )
  279. // $phpFile = PATH_PLUGINS . SYS_COLLECTION . PATH_SEP . SYS_TARGET.'.php';
  280. // else
  281. $phpFile = G::ExpandPath('methods') . SYS_COLLECTION . PATH_SEP . SYS_TARGET.'.php';
  282. //the index.php file, this new feature will allow automatically redirects to valid php file inside the methods directory
  283. if ( SYS_TARGET == '' ) {
  284. $phpFile = str_replace ( '.php', 'index.php', $phpFile );
  285. $phpFile = include ( $phpFile );
  286. }
  287. if ( substr(SYS_COLLECTION , 0,8) === 'gulliver' ) {
  288. $phpFile = PATH_GULLIVER_HOME . 'methods/' . substr( SYS_COLLECTION , 8) . SYS_TARGET.'.php';
  289. }
  290. else {
  291. if ( ! file_exists( $phpFile ) ) {
  292. $_SESSION['phpFileNotFound'] = $phpFile;
  293. header ("location: /errors/error404.php");
  294. die;
  295. }
  296. }
  297. // ***************** enable rbac **************************
  298. $RBAC =& RBAC::getSingleton();
  299. $RBAC->sSystem = '{rbacProjectName}';
  300. // ***************** Headers **************************
  301. if ( ! defined('EXECUTE_BY_CRON') ) {
  302. header("Expires: Tue, 19 Jan 1999 04:30:00 GMT");
  303. header("Last-Modified: Tue, 19 Jan 1999 04:30:00 GMT");
  304. header('Cache-Control: no-cache, must-revalidate, post-check=0,pre-check=0 ');
  305. header('P3P: CP="CAO PSA OUR"');
  306. if(isset( $_SESSION['USER_LOGGED'] )) {
  307. $RBAC->initRBAC();
  308. $RBAC->loadUserRolePermission( $RBAC->sSystem, $_SESSION['USER_LOGGED'] );
  309. }
  310. else {
  311. //This sentence is used when you lost the Session
  312. if ( SYS_TARGET != 'authentication' and SYS_TARGET != 'login'
  313. and SYS_TARGET != 'dbInfo' and SYS_TARGET != 'sysLoginVerify'
  314. and SYS_TARGET != 'updateTranslation' and SYS_COLLECTION != 'services' ){
  315. header ("location: ".SYS_URI."login/login.php");
  316. die();
  317. }
  318. }
  319. require_once( $phpFile );
  320. if ( defined('SKIP_HEADERS') ) {
  321. header("Expires: " . gmdate("D, d M Y H:i:s", mktime( 0,0,0,date('m'),date('d'),date('Y') + 1) ) . " GMT");
  322. header('Cache-Control: public');
  323. header('Pragma: ');
  324. }
  325. ob_end_flush();
  326. }
  327. /*
  328. }
  329. catch ( Exception $e ) {
  330. $aMessage['MESSAGE'] = $e->getMessage();
  331. $G_PUBLISH = new Publisher;
  332. $G_PUBLISH->AddContent('xmlform', 'xmlform', 'login/showMessage', '', $aMessage );
  333. G::RenderPage( 'publish' );
  334. die;
  335. }
  336. */