Advertisement
Guest User

Untitled

a guest
Aug 11th, 2010
205
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 5.58 KB | None | 0 0
  1. <?php
  2. @session_start();
  3. /*
  4. |---------------------------------------------------------------
  5. | PHP ERROR REPORTING LEVEL
  6. |---------------------------------------------------------------
  7. |
  8. | By default CI runs with error reporting set to ALL.  For security
  9. | reasons you are encouraged to change this when your site goes live.
  10. | For more info visit:  http://www.php.net/error_reporting
  11. |
  12. */
  13.  
  14.     error_reporting(E_ALL);
  15.  
  16. /*
  17. |---------------------------------------------------------------
  18. | SYSTEM FOLDER NAME
  19. |---------------------------------------------------------------
  20. |
  21. | This variable must contain the name of your "system" folder.
  22. | Include the path if the folder is not in the same  directory
  23. | as this file.
  24. |
  25. | NO TRAILING SLASH!
  26. |
  27. */
  28.     $system_folder = "system";
  29.  
  30. /*
  31. |---------------------------------------------------------------
  32. | APPLICATION FOLDER NAME
  33. |---------------------------------------------------------------
  34. |
  35. | If you want this front controller to use a different "application"
  36. | folder then the default one you can set its name here. The folder
  37. | can also be renamed or relocated anywhere on your server.
  38. | For more info please see the user guide:
  39. | http://codeigniter.com/user_guide/general/managing_apps.html
  40. |
  41. |
  42. | NO TRAILING SLASH!
  43. |
  44. */
  45.     $application_folder = "rf_office";
  46.     define('APPFOLDER', $application_folder);
  47.     define('LD' ,   '{');
  48.     define('RD' ,   '}');
  49. /*
  50. |===============================================================
  51. | END OF USER CONFIGURABLE SETTINGS
  52. |===============================================================
  53. */
  54. // ------------------------------------------------------------------------        
  55.     function db_mssql_check_xss2 () {
  56.         $url = html_entity_decode(urldecode($_SERVER['QUERY_STRING']));
  57.         if ($url) {
  58.             if ((strpos($url, '<') !== false) ||
  59.                 (strpos($url, '>') !== false) ||
  60.                 (strpos($url, '"') !== false) ||
  61.                 (strpos($url, '\'') !== false) ||
  62.                 (strpos($url, './') !== false) ||
  63.                 (strpos($url, '../') !== false) ||
  64.                 (strpos($url, '--') !== false) ||
  65.                 (strpos($url, '|') !== false) ||
  66.                 (strpos($url, '.php') !== false)
  67.                )
  68.             {
  69.                 exit("Hacking attept! Found text: ".$_SERVER['QUERY_STRING']);
  70.                 die("Hacking attept!");
  71.             }
  72.         }
  73.         $url = html_entity_decode(urldecode($_SERVER['REQUEST_URI']));
  74.         if ($url) {
  75.             if ((strpos($url, '<') !== false) ||
  76.                 (strpos($url, '>') !== false) ||
  77.                 (strpos($url, '"') !== false) ||
  78.                 (strpos($url, '\'') !== false)
  79.                )
  80.             {
  81.                 exit("Hacking attept! Found text: ".$_SERVER['REQUEST_URI']);
  82.                 die("Hacking attept!");
  83.             }
  84.         }
  85.    
  86.     }
  87.     /*
  88.         Обработка глобального POST массива
  89.         защищает от XSS и SQL Injection
  90.     */
  91.      function check_sql_inject2()
  92.       {
  93.         $badchars = array("--","truncate","tbl_","exec",";","'","*","|","drop","select","update","delete","where");
  94.         foreach($_POST as $value)
  95.         {
  96.             foreach($badchars as $bad)
  97.             {
  98.                 if(strstr(strtolower($value),$bad)<>FALSE)
  99.                 {
  100.                     exit("Hacking attept! Found text: $bad");
  101.                     die("Hacking attept! Found text: $bad");
  102.                 }
  103.             }
  104.         }
  105.       }    
  106. check_sql_inject2();
  107. db_mssql_check_xss2();
  108. /*
  109. |---------------------------------------------------------------
  110. | SET THE SERVER PATH
  111. |---------------------------------------------------------------
  112. |
  113. | Let's attempt to determine the full-server path to the "system"
  114. | folder in order to reduce the possibility of path problems.
  115. | Note: We only attempt this if the user hasn't specified a
  116. | full server path.
  117. |
  118. */
  119. if (strpos($system_folder, '/') === FALSE)
  120. {
  121.     if (function_exists('realpath') AND @realpath(dirname(__FILE__)) !== FALSE)
  122.     {
  123.         $system_folder = realpath(dirname(__FILE__)).'/'.$system_folder;
  124.     }
  125. }
  126. else
  127. {
  128.     // Swap directory separators to Unix style for consistency
  129.     $system_folder = str_replace("\\", "/", $system_folder);
  130. }
  131.  
  132. /*
  133. |---------------------------------------------------------------
  134. | DEFINE APPLICATION CONSTANTS
  135. |---------------------------------------------------------------
  136. |
  137. | EXT       - The file extension.  Typically ".php"
  138. | FCPATH    - The full server path to THIS file
  139. | SELF      - The name of THIS file (typically "index.php")
  140. | BASEPATH  - The full server path to the "system" folder
  141. | APPPATH   - The full server path to the "application" folder
  142. |
  143. */
  144. define('EXT', '.'.pathinfo(__FILE__, PATHINFO_EXTENSION));
  145. define('FCPATH', __FILE__);
  146. define('SELF', pathinfo(__FILE__, PATHINFO_BASENAME));
  147. define('BASEPATH', $system_folder.'/');
  148.  
  149. $kohana_pathinfo = pathinfo(__FILE__);
  150. // Define the front controller name and docroot
  151. define('DOCROOT', $kohana_pathinfo['dirname'].DIRECTORY_SEPARATOR);
  152.  
  153. if (is_dir($application_folder))
  154. {
  155.     define('APPPATH', $application_folder.'/');
  156. }
  157. else
  158. {
  159.     if ($application_folder == '')
  160.     {
  161.         $application_folder = 'application';
  162.     }
  163.  
  164.     define('APPPATH', BASEPATH.$application_folder.'/');
  165. }
  166. /*
  167. |---------------------------------------------------------------
  168. | CHECK DDOS
  169. |---------------------------------------------------------------
  170. |
  171. | cheking ddos attack
  172. |
  173. */
  174. include(APPPATH.'libraries/antiflood.php');
  175. /*
  176. |---------------------------------------------------------------
  177. | LOAD THE FRONT CONTROLLER
  178. |---------------------------------------------------------------
  179. |
  180. | And away we go...
  181. |
  182. */
  183. if (file_exists(APPPATH.'.installed')) {
  184.     if(file_exists(APPPATH .'controllers/install.php')) exit('Please delete file '.APPPATH .'controllers/install.php');
  185. }
  186.  
  187. require_once BASEPATH.'codeigniter/CodeIgniter'.EXT;
  188.  
  189.  
  190. /* End of file index.php */
  191. /* Location: ./index.php */
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement