PageRenderTime 44ms CodeModel.GetById 15ms RepoModel.GetById 0ms app.codeStats 0ms

/gas2/functions.php

https://github.com/mauromorello/ReteDES
PHP | 301 lines | 226 code | 37 blank | 38 comment | 41 complexity | c976d3f0512b8522e09166e362decb50 MD5 | raw file
Possible License(s): LGPL-2.1, BSD-3-Clause
  1. <?php
  2. if (preg_match('/functions.php/i',$_SERVER['SCRIPT_NAME'])){
  3. Header("Location: index.php"); die();
  4. }
  5. function _clean($str){
  6. return is_array($str) ? array_map('_clean', $str) : str_replace("\\", "\\\\", htmlspecialchars((get_magic_quotes_gpc() ? stripslashes($str) : $str), ENT_QUOTES));
  7. }
  8. // Disable magic_quotes_runtime
  9. if(get_magic_quotes_runtime())
  10. {
  11. // Deactivate
  12. set_magic_quotes_runtime(false);
  13. }
  14. if (!ini_get("register_globals")) {
  15. import_request_variables('GPC');
  16. }
  17. $phpver = phpversion();
  18. if ($phpver < '4.1.0') {
  19. $_GET = $HTTP_GET_VARS;
  20. $_POST = $HTTP_POST_VARS;
  21. $_SERVER = $HTTP_SERVER_VARS;
  22. }
  23. $phpver = explode(".", $phpver);
  24. $phpver = "$phpver[0]$phpver[1]";
  25. if ($phpver >= 41) {
  26. $PHP_SELF = $_SERVER['PHP_SELF'];
  27. }
  28. if(isset($user)){
  29. $user = base64_decode($user);
  30. $user = addslashes($user);
  31. $user = base64_encode($user);
  32. }
  33. _clean($_POST);
  34. _clean($_GET);
  35. //_clean($_REQUEST);// and so on..
  36. foreach ($_GET as $sec_key => $secvalue) {
  37. if(is_array($secvalue)){
  38. foreach ($secvalue as $thirdvalue) {
  39. //echo "GET: Third:".$thirdvalue."<br>";
  40. if ((eregi("<[^>]*script*\"?[^>]*>", $thirdvalue)) ||
  41. (eregi("<[^>]*object*\"?[^>]*>", $thirdvalue)) ||
  42. (eregi("<[^>]*iframe*\"?[^>]*>", $thirdvalue)) ||
  43. (eregi("<[^>]*applet*\"?[^>]*>", $thirdvalue)) ||
  44. (eregi("<[^>]*meta*\"?[^>]*>", $thirdvalue)) ||
  45. (eregi("<[^>]*style*\"?[^>]*>", $thirdvalue)) ||
  46. (eregi("<[^>]*form*\"?[^>]*>", $thirdvalue)) ||
  47. (eregi("<[^>]*img*\"?[^>]*>", $thirdvalue)) ||
  48. (eregi("<[^>]*onmouseover*\"?[^>]*>", $thirdvalue)) ||
  49. (eregi("\([^>]*\"?[^)]*\)", $thirdvalue)) ||
  50. (eregi("\"", $thirdvalue))) {
  51. die ("not allowed");
  52. }
  53. }
  54. }else{
  55. if ((eregi("<[^>]*script*\"?[^>]*>", $secvalue)) ||
  56. (eregi("<[^>]*object*\"?[^>]*>", $secvalue)) ||
  57. (eregi("<[^>]*iframe*\"?[^>]*>", $secvalue)) ||
  58. (eregi("<[^>]*applet*\"?[^>]*>", $secvalue)) ||
  59. (eregi("<[^>]*meta*\"?[^>]*>", $secvalue)) ||
  60. (eregi("<[^>]*style*\"?[^>]*>", $secvalue)) ||
  61. (eregi("<[^>]*form*\"?[^>]*>", $secvalue)) ||
  62. (eregi("<[^>]*img*\"?[^>]*>", $secvalue)) ||
  63. (eregi("<[^>]*onmouseover*\"?[^>]*>", $secvalue)) ||
  64. (eregi("\([^>]*\"?[^)]*\)", $secvalue)) ||
  65. (eregi("\"", $secvalue))) {
  66. die ("not allowed");
  67. }
  68. }
  69. }
  70. foreach ($_POST as $secvalue) {
  71. //echo "POST: Sec: ".$secvalue."<br>";
  72. if(is_array($secvalue)){
  73. foreach ($secvalue as $thirdvalue) {
  74. //echo "POST: Third:".$thirdvalue."<br>";
  75. if ((eregi("<[^>]*onmouseover*\"?[^>]*>", $thirdvalue)) ||
  76. (eregi("<[^>]script*\"?[^>]*>", $thirdvalue)) ||
  77. (eregi("<[^>]meta*\"?[^>]*>", $thirdvalue)) ||
  78. (eregi("<[^>]style*\"?[^>]*>", $thirdvalue))) {
  79. die ("not allowed");
  80. }
  81. }
  82. }else{
  83. if ((eregi("<[^>]*onmouseover*\"?[^>]*>", $secvalue)) ||
  84. (eregi("<[^>]script*\"?[^>]*>", $secvalue)) ||
  85. (eregi("<[^>]meta*\"?[^>]*>", $secvalue)) ||
  86. (eregi("<[^>]style*\"?[^>]*>", $secvalue))) {
  87. die ("not allowed");
  88. }
  89. }
  90. }
  91. //set root path
  92. $ROOT_DIR = realpath(dirname(__FILE__));
  93. $ROOT_DIR = str_replace('\\', '/', $ROOT_DIR);
  94. define("_ROOOT_",$ROOT_DIR);
  95. include ("$ROOT_DIR/config.php");
  96. include ("$ROOT_DIR/mysql.class.php");
  97. //include ("$ROOT_DIR/lang/italian.php");
  98. include ("$ROOT_DIR/function_engine/structures.class.php");
  99. if ($php_debug=="ON"){
  100. error_reporting(E_ERROR | E_WARNING | E_PARSE);
  101. }else{
  102. //echo "OFF";
  103. error_reporting(0);
  104. }
  105. $db = new sql_db($db_host, $db_username, $db_password, $databse_name, false);
  106. if(!$db->db_connect_id) {
  107. echo "<br><font color=\"red\"><h5><br><center>Error:</b><br><hr><br>
  108. <b>Il database è morto<br>
  109. chiama l'assistenza</center><hr>";
  110. echo mysql_error();
  111. die();
  112. }
  113. $site_name= "ReteDES.it"; // stripslashes($options['site_name']);
  114. $site_email= _SITE_MAIL_LOG; //stripslashes($options['site_email']);
  115. //-----------------------------------------------MENU'
  116. if(in_array("menu",$_FUNCTION_LOADER)){
  117. include ("function_engine/fun_menu.php");
  118. }
  119. //----------------------------------------------- OPZIONI
  120. if(in_array("options",$_FUNCTION_LOADER)){
  121. include ("function_engine/fun_options.php");
  122. }
  123. //----------------------------------------------- WIDGETS
  124. if(in_array("widgets",$_FUNCTION_LOADER)){
  125. include ("function_engine/fun_widgets.php");
  126. }
  127. //----------------------------------------------- DES
  128. if(in_array("des",$_FUNCTION_LOADER)){
  129. include ("function_engine/fun_des.php");
  130. }
  131. // ----------------------------------------------- GRAFICI
  132. if(in_array("gphpchart",$_FUNCTION_LOADER)){
  133. include_once("lib/graph/GphpChart.class.php");
  134. }
  135. // ----------------------------------------------- POSTA
  136. if(in_array("swift",$_FUNCTION_LOADER)){
  137. require_once "lib/Swift-4.1.6/lib/swift_required.php";
  138. }
  139. if(in_array("posta",$_FUNCTION_LOADER)){
  140. include ("function_engine/fun_posta.php");
  141. }
  142. //----------------------------------------------AMICI
  143. if(in_array("amici",$_FUNCTION_LOADER)){
  144. include ("function_engine/fun_amici.php");
  145. }
  146. //----------------------------------------------AIUTANTI
  147. if(in_array("aiutanti",$_FUNCTION_LOADER)){
  148. // include ("function_engine/fun_aiutanti.php");
  149. }
  150. //----------------------------------------------USERS
  151. if(in_array("users",$_FUNCTION_LOADER)){
  152. include ("function_engine/fun_users.php");
  153. }
  154. //-----------------------------------------------GAS
  155. if(in_array("gas",$_FUNCTION_LOADER)){
  156. include ("function_engine/fun_gas.php");
  157. }
  158. //-----------------------------------------------LISTINI
  159. if(in_array("listini",$_FUNCTION_LOADER)){
  160. include ("function_engine/fun_listini.php");
  161. }
  162. //-----------------------------------------------DITTE
  163. if(in_array("ditte",$_FUNCTION_LOADER)){
  164. include ("function_engine/fun_ditte.php");
  165. }
  166. //----------------------------------------------TIPOLOGIE
  167. if(in_array("tipologie",$_FUNCTION_LOADER)){
  168. include ("function_engine/fun_tipologie.php");
  169. }
  170. //----------------------------------------------ARTICOLI
  171. if(in_array("articoli",$_FUNCTION_LOADER)){
  172. include ("function_engine/fun_articoli.php");
  173. }
  174. //----------------------------------------------GRAFICI
  175. if(in_array("graphics",$_FUNCTION_LOADER)){
  176. include ("function_engine/fun_graphics.php");
  177. }
  178. //---------------------------------------------ORDINI
  179. if(in_array("ordini",$_FUNCTION_LOADER)){
  180. include ("function_engine/fun_ordini.php");
  181. }
  182. //---------------------------------------------ORDINI CALCOLI
  183. if(in_array("ordini_valori",$_FUNCTION_LOADER)){
  184. include ("function_engine/fun_ordini_valori.php");
  185. }
  186. //----------------------------------------------BACHECA
  187. if(in_array("bacheca",$_FUNCTION_LOADER)){
  188. include ("function_engine/fun_bacheca.php");
  189. }
  190. //-------------------------------------------DATA CHECK
  191. if(in_array("data_check",$_FUNCTION_LOADER)){
  192. include ("function_engine/fun_data_check.php");
  193. }
  194. //--------------------------------------------RENDERING
  195. if(in_array("rendering",$_FUNCTION_LOADER)){
  196. include ("function_engine/fun_rendering.php");
  197. }
  198. //--------------------------------------------Geocoding
  199. if(in_array("geocoding",$_FUNCTION_LOADER)){
  200. include ("function_engine/fun_geocoding.php");
  201. }
  202. //------------------------------------------ADMINISTRATION
  203. if(in_array("admin",$_FUNCTION_LOADER)){
  204. include ("function_engine/fun_admin.php");
  205. }
  206. //------------------------------------------DAREAVERE
  207. if(in_array("dareavere",$_FUNCTION_LOADER)){
  208. include ("function_engine/fun_dareavere.php");
  209. }
  210. //------------------------------------------CASSA
  211. if(in_array("cassa",$_FUNCTION_LOADER)){
  212. include ("function_engine/fun_cassa.php");
  213. }
  214. //------------------------------------------VARIE
  215. if(in_array("varie",$_FUNCTION_LOADER)){
  216. include ("function_engine/fun_varie.php");
  217. }
  218. //------------------------------------------OPINIONI
  219. if(in_array("opinioni",$_FUNCTION_LOADER)){
  220. include ("function_engine/fun_opinioni.php");
  221. }
  222. //------------------------------------------THEMING
  223. if(in_array("theming",$_FUNCTION_LOADER)){
  224. include ("function_engine/fun_theming.php");
  225. }
  226. //------------------------------------------MOBILE
  227. if(in_array("mobile",$_FUNCTION_LOADER)){
  228. include ("function_engine/fun_mobile.php");
  229. }
  230. //------------------------------------------TWITTER
  231. if(in_array("twitter",$_FUNCTION_LOADER)){
  232. include ("function_engine/fun_twitter.php");
  233. include ("lib/o_auth/tmhOAuth.php");
  234. }
  235. //DEBUG
  236. class debugs{
  237. public $debug_state;
  238. public $debug_msg;
  239. public $debug_start;
  240. public function __construct() {
  241. $this->debug_state = read_option_text(0,"DEBUG");
  242. $this->debug_start = array_sum(explode(' ', microtime()));;
  243. }
  244. public function render_debug(){
  245. unset($h_d);
  246. foreach ($this->debug_msg as $v) {
  247. $h_d .='<div class="sub_debug">'.$v.'</div>';
  248. }
  249. return $h_d;
  250. }
  251. }