Guest User

Untitled

a guest
Jul 18th, 2018
89
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 6.06 KB | None | 0 0
  1. <?php
  2. /* check if lock file exists if not we need to install */
  3. session_start();
  4. require('conf.php');
  5.  
  6. if(!is_file('lock') ) {
  7. echo("
  8. <script type=\"text/javascript\">
  9. <!--
  10. window.location = \"install\"
  11. //-->
  12. </script>");
  13. } else if(is_dir('install') ) {
  14. echo("<font color=\"red\">The install Directory Exists!! Please Rename or remove the install directory.</font>");
  15. die;
  16. }
  17.  
  18. $VAR = array_merge($_GET,$_POST);
  19. $page_title = $VAR['page_title'];
  20.  
  21. $auth = &new Auth($db, 'login.php', 'secret');
  22. require(INCLUDE_URL.SEP.'acl.php');
  23. require(INCLUDE_URL.SEP.'model.php');
  24. require(INCLUDE_URL.SEP.'functions.php');
  25.  
  26. require('modules/core/translate.php');
  27. require('modules/core/form_helper.php');
  28. require('modules/core/report_helper.php');
  29. require('modules/core/currency_helper.php');
  30. ############################
  31. # Debuging #
  32. ############################
  33. function getMicroTime() {
  34. list($usec, $sec) = explode(" ", microtime());
  35. return (float)$usec + (float)$sec;
  36. }
  37.  
  38. $start = getMicroTime();
  39.  
  40.  
  41.  
  42. // If logg of is set then we log off
  43. if (isset($VAR['action']) && $VAR['action'] == 'logout') {
  44. $auth->logout('login.php');
  45. }
  46.  
  47. /* get company info for defaults */
  48. $q = 'SELECT * FROM '.PRFX.'TABLE_COMPANY';
  49. if(!$rs = $db->execute($q)) {
  50. force_page('core', 'error&error_msg=MySQL Error: '.$db->ErrorMsg().'&menu=1&type=database');
  51. exit;
  52. }
  53. $smarty->assign('company_name', $rs->fields['COMPANY_NAME']);
  54. $smarty->assign('company_address', $rs->fields['COMPANY_ADDRESS']);
  55. $smarty->assign('company_city', $rs->fields['COMPANY_CITY']);
  56. $smarty->assign('company_state', $rs->fields['COMPANY_STATE']);
  57. $smarty->assign('company_zip', $rs->fields['COMPANY_ZIP']);
  58. $smarty->assign('company_country', $rs->fields['COMPANY_COUNTRY']);
  59. $smarty->assign('company_phone',$rs->fields['COMPNAY_PHONE']);
  60. $smarty->assign('company_email',$rs->fields['COMPANY_EMAIL']);
  61. $smarty->assign('company_toll_free',$rs->fields['COMPANY_TOLL_FREE']);
  62. $smarty->assign('compnay_mobile',$rs->fields['COMPNAY_MOBILE']);
  63.  
  64.  
  65. #############################################################
  66. # Url Builder This grabs gets and post and builds the url #
  67. # conection strings #
  68. #############################################################
  69. if(!isset($_POST['page'])) {
  70. if ( $_GET['page']) {
  71. // Explode the url so we can get the module and page
  72. list($module, $page) = explode(":", $_GET['page']);
  73. $the_page = 'modules'.SEP.$module.SEP.$page.'.php';
  74.  
  75. // remove page from the $_GET array we dont want it to pass the options
  76. unset($_GET['page']);
  77.  
  78. // Define the global options for each page
  79. foreach($_GET as $key=>$val){
  80. @define($key, $val);
  81. }
  82.  
  83. // Check to see if the page is real other wise send em a 404
  84. if ( file_exists ($the_page) ) {
  85. $the_page= 'modules'.SEP.$module.SEP.$page.'.php';
  86. } else {
  87. $the_page= 'modules'.SEP.'core'.SEP.'404.php';
  88. }
  89. } else {
  90. // If no page is supplied then go to the main page
  91. $the_page= 'modules'.SEP.'core'.SEP.'main.php';
  92. }
  93. } else {
  94. // Explode the url so we can get the module and page
  95. list($module, $page) = explode(":", $_POST['page']);
  96. $the_page = $the_page= 'modules'.SEP.$module.SEP.$page.'.php';
  97.  
  98. // remove page from the $_GET array we dont want it to pass the options
  99. unset($_POST['page']);
  100.  
  101. // Define the global options for each page
  102. foreach($_POST as $key=>$val){
  103. @define($key, $val);
  104. }
  105.  
  106. // Check to see if the page is real other wise send em a 404
  107. if ( file_exists ($the_page) ) {
  108. $the_page= 'modules'.SEP.$module.SEP.$page.'.php';
  109. } else {
  110. $the_page= 'modules'.SEP.'core'.SEP.'404.php';
  111. }
  112. }
  113.  
  114.  
  115. $tracker_page = "$module:$page";
  116.  
  117.  
  118. #####################################
  119. # Display the pages #
  120. #####################################
  121.  
  122. if(isset($_GET['wo_id'])) {
  123. $smarty->assign('wo_id', $_GET['wo_id']);
  124. global $wo_id;
  125. } else {
  126. $smarty->assign('wo_id','0');
  127. }
  128. require('modules'.SEP.'core'.SEP.'error.php');
  129.  
  130. if(isset($page_title)) {
  131. $smarty->assign('page_title', $page_title);
  132. } else {
  133. $page_title ="Home";
  134. $smarty->assign('page_title', $page_title);
  135. }
  136.  
  137. if(isset($VAR['msg'])) {
  138.  
  139. $smarty->assign('msg', $VAR['msg']);
  140. }
  141.  
  142. if($VAR['escape'] != 1 ) {
  143. require('modules'.SEP.'core'.SEP.'header.php');
  144. require('modules'.SEP.'core'.SEP.'navagation.php');
  145. require('modules'.SEP.'core'.SEP.'company.php');
  146. }
  147.  
  148. if($menu == 1 ) {
  149.  
  150. $smarty->assign('menu', '1');
  151. $smarty->display('core'.SEP.'error.tpl');
  152.  
  153. } else {
  154.  
  155. /* check acl for page request */
  156. if(!check_acl($db,$module,$page)) {
  157. force_page('core','error&error_msg=You do not have permission to access this '.$module.':'.$page.'&menu=1');
  158. } else {
  159. require($the_page);
  160. }
  161. }
  162.  
  163. if($VAR['escape'] != 1 ) {
  164. require('modules'.SEP.'core'.SEP.'footer.php');
  165. }
  166.  
  167. /* tracker code */
  168. function getIP() {
  169. $ip;
  170. if (getenv("HTTP_CLIENT_IP")) $ip = getenv("HTTP_CLIENT_IP");
  171. else if(getenv("HTTP_X_FORWARDED_FOR")) $ip = getenv("HTTP_X_FORWARDED_FOR");
  172. else if(getenv("REMOTE_ADDR")) $ip = getenv("REMOTE_ADDR");
  173. else $ip = "UNKNOWN";
  174. return $ip;
  175. }
  176.  
  177.  
  178.  
  179. $logtime = time();
  180. $q = 'INSERT into '.PRFX.'tracker SET
  181. date ='. $db->qstr( $logtime ).',
  182. ip ='. $db->qstr( getIP() ).',
  183. uagent ='. $db->qstr( getenv(HTTP_USER_AGENT) ).',
  184. full_page ='. $db->qstr( $the_page ).',
  185. module ='. $db->qstr( $module ).',
  186. page ='. $db->qstr( $page ).',
  187. referer ='. $db->qstr( getenv(HTTP_REFERER) );
  188.  
  189. if(!$rs = $db->Execute($q)) {
  190. echo 'Error inserting tracker :'. $db->ErrorMsg();
  191. }
  192.  
  193. ?>
Add Comment
Please, Sign In to add comment