last update: Mon, 05 Sep 2011 17:17:04 +0000
  1. <?
  2. $sript_start_time = microtime(true);
  3. //enable gzip compression
  4. require_once('enable_gzip.php');
  5. require_once('mysql_cfg.php');
  6. require_once('files.php');
  7. function lol_detect_ie()
  8. {
  9. if (isset($_SERVER['HTTP_USER_AGENT']) && (strpos($_SERVER['HTTP_USER_AGENT'], 'MSIE') !== false))
  10. return true;
  11. else
  12. return false;
  13. }
  14. if (isset($_SERVER['DOCUMENT_ROOT']))
  15. {
  16. define( 'DOCUMENT_ROOT', $_SERVER['DOCUMENT_ROOT']);
  17. }
  18. else
  19. {
  20. define( 'DOCUMENT_ROOT', 'E:/web');
  21. }
  22. define('SMARTY_DIR', DOCUMENT_ROOT.'/Smarty/libs/');
  23. require_once(SMARTY_DIR.'Smarty.class.php');
  24. $smarty = new Smarty();
  25. $smarty->template_dir = '/templates/';
  26. if (DOCUMENT_ROOT == "D:/web")
  27. $smarty->compile_dir = DOCUMENT_ROOT . '/peq/templates/compiled/';
  28. else
  29. $smarty->compile_dir = DOCUMENT_ROOT . '/templates/compiled/';
  30. $smarty->config_dir = '/templates/';
  31. $smarty->cache_dir = '/templates/cache/';
  32. //defaults:
  33. $additional_headers = array();
  34. $smarty->assign('additional_headers', $additional_headers);
  35. $footer_scripts = array();
  36. $smarty->assign('footer_scripts', $footer_scripts);
  37. $smarty->assign('title', '^-^');
  38. $smarty->assign('backpath','');
  39. $smarty->assign('InternetExplorer',lol_detect_ie());
  40. $smarty->assign('peqdevu_css',$_FILE_peqdevu_css);
  41. /*echo "<!--";
  42. print_r($_SERVER);
  43. echo "-->";*/
  44. //stats
  45. $url = mysql_real_escape_string(@$_SERVER['REQUEST_URI']);
  46. $USER_AGENT = mysql_real_escape_string(@$_SERVER['HTTP_USER_AGENT']);
  47. $REFERER = mysql_real_escape_string(@$_SERVER['HTTP_REFERER']);
  48. $ip = mysql_real_escape_string(@$_SERVER['REMOTE_ADDR']);
  49. $reload = false;
  50. $query = 'SELECT * FROM stats_details WHERE UNIX_TIMESTAMP(NOW()) - UNIX_TIMESTAMP(`time`) < 60*60 AND URL = "'.($url).'" AND ip = "'.$ip.'";';
  51. $data = mysql_query($query);
  52. echo mysql_error();
  53. if ($row = mysql_fetch_array($data))
  54. {
  55. $reload=true;
  56. }
  57. $query = 'SELECT * FROM stats_counter WHERE URL = "'.($url).'";';
  58. $data = mysql_query($query);
  59. if ($row = mysql_fetch_array($data))
  60. {
  61. $smarty->assign('counter',$row['counter']);
  62. if (!$reload)
  63. {
  64. $query = 'UPDATE stats_counter SET counter = counter + 1 WHERE URL = "'.($url).'";';
  65. $data = mysql_query($query);
  66. }
  67. }
  68. else
  69. {
  70. $smarty->assign('counter',0);
  71. if (!$reload)
  72. {
  73. $query = 'INSERT INTO stats_counter (`URL`, `counter`) VALUES ("'.($url).'", 1);';
  74. $data = mysql_query($query);
  75. }
  76. }
  77. $query = 'INSERT INTO stats_details (`URL`, `REFERER`, `ip`, `USERAGENT`, `time`)
  78. VALUES ("'.$url.'", "'.$REFERER.'", "'.$ip.'", "'.$USER_AGENT.'", NOW());';
  79. $data = mysql_query($query);
  80. ?>

goto line:
Compare with:
text copy window edit this code post new code