PageRenderTime 78ms CodeModel.GetById 29ms RepoModel.GetById 0ms app.codeStats 0ms

/daemons/daemon_base.php

https://github.com/ComputerScienceHouse/CSH-Members
PHP | 202 lines | 48 code | 33 blank | 121 comment | 5 complexity | 7e6e83d4c1fdbf92a8ed9081d51142f6 MD5 | raw file
  1. <?php
  2. #!/usr/bin/php
  3. /**
  4. *
  5. * @author Sean McGary <sean.mcgary@gmail.com>
  6. */
  7. session_start();
  8. $pwd = trim(shell_exec('pwd'));
  9. set_include_path(get_include_path() . ':../application/libraries');
  10. set_include_path(get_include_path() . ':../application/controllers');
  11. set_include_path(get_include_path() . ':../external');
  12. require_once('Util.php');
  13. require_once('Page_Framework.php');
  14. require_once('Ldap.php');
  15. require_once('Mongodb.php');
  16. require_once('Mongo_db.php');
  17. require_once('Form_Framework.php');
  18. /**
  19. * only a few lines of code will make the best web framework
  20. * function on the command line
  21. */
  22. /* we don't need to be limited by...normal limitations */
  23. set_time_limit(0);
  24. ini_set('memory_limit', '256M');
  25. /* make sure this isn't being called by a web browser */
  26. if (isset($_SERVER['REMOTE_ADDR'])) die('Permission denied.');
  27. /* set some constants */
  28. define('CMD', 1);
  29. /* manually set the URI path based on command line arguments... */
  30. unset($argv[0]); /* ...but not the first one */
  31. $_SERVER['PATH_INFO'] = $_SERVER['REQUEST_URI'] = '/' . implode('/', $argv) . '/';
  32. /*
  33. *---------------------------------------------------------------
  34. * PHP ERROR REPORTING LEVEL
  35. *---------------------------------------------------------------
  36. *
  37. * By default CI runs with error reporting set to ALL. For security
  38. * reasons you are encouraged to change this when your site goes live.
  39. * For more info visit: http://www.php.net/error_reporting
  40. *
  41. */
  42. error_reporting(E_ALL);
  43. /*
  44. *---------------------------------------------------------------
  45. * SYSTEM FOLDER NAME
  46. *---------------------------------------------------------------
  47. *
  48. * This variable must contain the name of your "system" folder.
  49. * Include the path if the folder is not in the same directory
  50. * as this file.
  51. *
  52. */
  53. $system_path = "../system";
  54. /*
  55. *---------------------------------------------------------------
  56. * APPLICATION FOLDER NAME
  57. *---------------------------------------------------------------
  58. *
  59. * If you want this front controller to use a different "application"
  60. * folder then the default one you can set its name here. The folder
  61. * can also be renamed or relocated anywhere on your server. If
  62. * you do, use a full server path. For more info please see the user guide:
  63. * http://codeigniter.com/user_guide/general/managing_apps.html
  64. *
  65. * NO TRAILING SLASH!
  66. *
  67. */
  68. $application_folder = "../application";
  69. /*
  70. * --------------------------------------------------------------------
  71. * DEFAULT CONTROLLER
  72. * --------------------------------------------------------------------
  73. *
  74. * Normally you will set your default controller in the routes.php file.
  75. * You can, however, force a custom routing by hard-coding a
  76. * specific controller class/function here. For most applications, you
  77. * WILL NOT set your routing here, but it's an option for those
  78. * special instances where you might want to override the standard
  79. * routing in a specific front controller that shares a common CI installation.
  80. *
  81. * IMPORTANT: If you set the routing here, NO OTHER controller will be
  82. * callable. In essence, this preference limits your application to ONE
  83. * specific controller. Leave the function name blank if you need
  84. * to call functions dynamically via the URI.
  85. *
  86. * Un-comment the $routing array below to use this feature
  87. *
  88. */
  89. // The directory name, relative to the "controllers" folder. Leave blank
  90. // if your controller is not in a sub-folder within the "controllers" folder
  91. // $routing['directory'] = '';
  92. // The controller class file name. Example: Mycontroller.php
  93. // $routing['controller'] = '';
  94. // The controller function you wish to be called.
  95. // $routing['function'] = '';
  96. /*
  97. * -------------------------------------------------------------------
  98. * CUSTOM CONFIG VALUES
  99. * -------------------------------------------------------------------
  100. *
  101. * The $assign_to_config array below will be passed dynamically to the
  102. * config class when initialized. This allows you to set custom config
  103. * items or override any default config values found in the config.php file.
  104. * This can be handy as it permits you to share one application between
  105. * multiple front controller files, with each file containing different
  106. * config values.
  107. *
  108. * Un-comment the $assign_to_config array below to use this feature
  109. *
  110. */
  111. // $assign_to_config['name_of_config_item'] = 'value of config item';
  112. // --------------------------------------------------------------------
  113. // END OF USER CONFIGURABLE SETTINGS. DO NOT EDIT BELOW THIS LINE
  114. // --------------------------------------------------------------------
  115. /*
  116. * ---------------------------------------------------------------
  117. * Resolve the system path for increased reliability
  118. * ---------------------------------------------------------------
  119. */
  120. if (realpath($system_path) !== FALSE)
  121. {
  122. $system_path = realpath($system_path).'/';
  123. }
  124. // ensure there's a trailing slash
  125. $system_path = rtrim($system_path, '/').'/';
  126. // Is the system path correct?
  127. if ( ! is_dir($system_path))
  128. {
  129. exit("Your system folder path does not appear to be set correctly. Please open the following file and correct this: ".pathinfo(__FILE__, PATHINFO_BASENAME));
  130. }
  131. /*
  132. * -------------------------------------------------------------------
  133. * Now that we know the path, set the main path constants
  134. * -------------------------------------------------------------------
  135. */
  136. // The name of THIS file
  137. define('SELF', pathinfo(__FILE__, PATHINFO_BASENAME));
  138. // The PHP file extension
  139. define('EXT', '.php');
  140. // Path to the system folder
  141. define('BASEPATH', str_replace("\\", "/", $system_path));
  142. // Path to the front controller (this file)
  143. define('FCPATH', str_replace(SELF, '', __FILE__));
  144. // Name of the "system folder"
  145. define('SYSDIR', trim(strrchr(trim(BASEPATH, '/'), '/'), '/'));
  146. // The path to the "application" folder
  147. if (is_dir($application_folder))
  148. {
  149. define('APPPATH', $application_folder.'/');
  150. }
  151. else
  152. {
  153. if ( ! is_dir(BASEPATH.$application_folder.'/'))
  154. {
  155. exit("Your application folder path does not appear to be set correctly. Please open the following file and correct this: ".SELF);
  156. }
  157. define('APPPATH', BASEPATH.$application_folder.'/');
  158. }
  159. /*
  160. * --------------------------------------------------------------------
  161. * LOAD THE BOOTSTRAP FILE
  162. * --------------------------------------------------------------------
  163. *
  164. * And away we go...
  165. *
  166. */
  167. require_once BASEPATH.'core/CodeIgniter'.EXT;
  168. /* End of file index.php */
  169. /* Location: ./index.php */