home *** CD-ROM | disk | FTP | other *** search
/ Chip 2004 April / CMCD0404.ISO / Software / Freeware / Programare / groupoffice-com-2.01 / modules / daogen / rewrite.php < prev    next >
PHP Script  |  2004-03-08  |  4KB  |  163 lines

  1. <?php
  2. /*
  3. Copyright T & M Web Enterprises 2003
  4. Author: Mike Hostetler <mike@tm-web.com>
  5. Version: 1.0 Release date: 01 November 2003
  6.  
  7. This program is free software; you can redistribute it and/or modify it
  8. under the terms of the GNU General Public License as published by the
  9. Free Software Foundation; either version 2 of the License, or (at your
  10. option) any later version.
  11. */
  12.  
  13. /**
  14.  **MODULE CONFIG VARIABLES
  15.  **/
  16.  
  17. //This should correspond with the name of 
  18. //the directory the module currently resides in
  19. global $moduleName;
  20. $moduleName = 'daogen';
  21. //set the page title for the header file
  22. $page_title = "DAO Generator";
  23. error_reporting(E_ALL);
  24. /*
  25.  *    THIS FILE IS NOT MEANT TO BE MODIFIED BELOW THIS POINT!
  26.  *    
  27.  *    This file serves as a frontController for all module file.  It sets
  28.  *  up global module variables and includes global module files.
  29.  *
  30.  *    DO NOT MODIFY BELOW THIS POINT IF YOU DON'T KNOW WHAT YOU'RE DOING!
  31.  */
  32.  
  33. /**
  34.  **START GROUP OFFICE STUFF
  35.  **/
  36.  
  37. //Pull in the global configuration file
  38. require("../../Group-Office.php");
  39.  
  40. $GO_SECURITY->authenticate();
  41.  
  42. $GO_MODULES->authenticate($moduleName);
  43.  
  44. // security check, can be improved
  45. if (preg_match('/[^\/,-_;a-z]/i', $_REQUEST['rw_url'])) die('NO MESSING AROUND!');
  46.                                                             
  47. // check for dynamic content and bring the string together
  48. $page = implode('/',array_filter(explode('/', $_REQUEST['rw_url']), create_function('$v','return "$v" !== "";')));
  49.                                                                             
  50. //Rewrite this so it doesn't point to 'rewrite.php'
  51. $PHP_SELF = $page;
  52.  
  53. //Force the extension to php
  54. $page = preg_replace('/\..*/','.php',$page);
  55.  
  56. //Test out the XUL extension
  57. if(isset($_REQUEST['xul']) && $_REQUEST['xul'] == 1) {
  58.     @require($GO_THEME->theme_path."header.inc");
  59.     $page = 'xul/'.$page;
  60.     //Force the extension to xul
  61.     $page = preg_replace('/\..*/','.xul',$page);
  62.  
  63.     $page = 'xul/Login.xul';
  64.     //Check if the action exists
  65.     if(file_exists($page)) {
  66.         echo '<iframe src="'.$page.'" width="100%" height="100%">';
  67.     }
  68.     else {
  69.         //Error, include the error page
  70.         if(!file_exists('errorPage.php'))
  71.             echo "ERROR";
  72.         else
  73.             include_once('errorPage.php');
  74.     }
  75.     @require($GO_THEME->theme_path."footer.inc");
  76. }
  77. else {
  78.     //require the header file. This will draw the logo's and the menu
  79.     // there is also the simple_header.inc file without logo's and menu
  80.     @require($GO_THEME->theme_path."header.inc");
  81.  
  82.     //Check if the action exists
  83.     if(file_exists($page)) {
  84.         //We have a winner, include the file
  85.  
  86.         @include_once($page);
  87.     }
  88.     else {
  89.         //Error, include the error page
  90.         if(!file_exists('errorPage.php'))
  91.             echo "ERROR";
  92.         else
  93.             @include_once('errorPage.php');
  94.     }
  95.  
  96.     @require($GO_THEME->theme_path."footer.inc");
  97. }
  98.  
  99. //********************
  100. //SPECIAL FUNCTIONS
  101. //********************
  102. //Mimiced Behavior: eval('$classname::$methodname($param1,$param2)');
  103. //using call_user_func is safer and faster, that's why it's wrapped
  104. //To use do call_static_class_method('class::method',$arg1,$arg2,$arg3);
  105. function call_static_class_method() {
  106.     $args = array_slice(func_get_args(),1);        //Take of the first element of the array
  107.     $arg = func_get_arg(0);
  108.     list($class,$method) = explode('::',$arg);    //Snag out the class and method name
  109.     return call_user_func_array(array($class,$method),$args);    //Call the function and return it's value
  110. }
  111.  
  112. //A very useful debug function
  113. function debug( $v )
  114. {
  115.     print "<pre>";
  116.     if( is_array( $v ) || is_object( $v )) 
  117.         print_r( $v );
  118.     else 
  119.         print $v;
  120.     print "</pre>";
  121. }
  122.  
  123. function import( $type,$file ) {
  124.     global $GO_CONFIG,$moduleName;
  125.     $module_path = $GO_CONFIG->root_path."modules/".$moduleName."/";
  126.     //Import a file and optionally return the path to the common directory
  127.     switch($type) {
  128.         case 'vo':
  129.             $path = $module_path."vo/";
  130.             break;
  131.         case 'dao':
  132.             $path = $module_path."dao/";
  133.             break;
  134.         case 'class':
  135.             $path = $module_path."classes/";
  136.             break;
  137.         case 'action':
  138.             $path = $module_path."actions/";
  139.             break;
  140.         default:
  141.             //A special feature of this function is that if a type is specified
  142.             //that is not recognized, it will use the type as part of the path
  143.             $path = $module_path.$type;
  144.             break;
  145.     }
  146.  
  147.     //if($this->vars['debug'])
  148.         //echo "Type: $type File: $file Path: $path Exists: $path$file.php<br>\n";
  149.  
  150.     //Make sure to strip off the extension just in case someone included it
  151.     $file = str_replace('.php','',$file);
  152.  
  153.     if(file_exists($path.$file.'.php')) {
  154.         require_once( $path . $file . '.php' );
  155.         return $path;
  156.     }
  157.     else {
  158.         return FALSE;
  159.     }
  160. }
  161.  
  162. ?>
  163.