home *** CD-ROM | disk | FTP | other *** search
/ Chip 2004 October / CMCD1004.ISO / Software / Shareware / Programare / cnstats / index.php < prev    next >
Encoding:
PHP Script  |  2004-08-11  |  14.9 KB  |  374 lines

  1. <?
  2. error_reporting(E_ALL & ~E_NOTICE);
  3. $LANG=Array();
  4.  
  5. if (@is_file("install.php") || !is_file("config.php")) {
  6. ?>
  7. <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
  8. <HTML>
  9. <HEAD>
  10. <TITLE>CNStats 2.1</TITLE>
  11. </HEAD>
  12. <BODY>
  13. <P>It is necessary to fullfill the following steps to install CNStats: </P>
  14.  
  15. <OL>
  16. <LI>Run the script "<B>install.php</B>". You may do this by clicking <a href='install.php'>this</a> link. </LI>
  17. <LI>Delete the file "<b>install.php</b>" !!!</LI>
  18. </OL>
  19.  
  20. <HR size=1>
  21. <P>─δ  ≤±≥αφεΓΩΦ ±Φ±≥σ∞√ CNStats φα Γα° ±σ≡Γσ≡ Γα∞ φσεß⌡εΣΦ∞ε Γ√∩εδφΦ≥ⁿ ±δσΣ≤■∙Φσ ΣσΘ±≥ΓΦ : </P>
  22. <OL>
  23. <LI>┬√∩εδφΦ≥ⁿ ±Ω≡Φ∩≥ "<B>install.php</B>". ▌≥ε ∞εµφε ±Σσδα≥ⁿ ∩σ≡σΘΣ  ∩ε <a href=install.php>²≥εΘ</a> ±±√δΩσ. </LI>
  24. <LI>╙ΣαδΦ≥ⁿ ⌠αΘδ "<b>install.php</b>" !!! </LI>
  25. </OL>
  26. </BODY>
  27. </HTML>
  28. <?
  29. print $LANG["copyright"];
  30. exit;
  31. }
  32.  
  33. include "_funct.php";
  34.  
  35. session_start();
  36. session_register("DATA");
  37.  
  38. mysqlconnect();
  39.  
  40. $err=0;
  41. if ($HTTP_SERVER_VARS["REQUEST_METHOD"]=="POST") {
  42. if (md5($HTTP_POST_VARS["password"])!=$STATS_CONF["adminpassword"]) $err=1;
  43. if ($HTTP_POST_VARS["login"]!=$STATS_CONF["cnsoftwarelogin"]) $err=2;
  44.  
  45. if ($err==0) {
  46. $hash=md5(time().$HTTP_POST_VARS["login"].$HTTP_POST_VARS["password"]);
  47. $r=cnstats_sql_query("SELECT hash FROM cns_config;");
  48. $hashs=explode("-",mysql_result($r,0,0));
  49. for ($i=0;$i<count($hashs);$i++) if (strlen($hashs[$i])!=32) unset($hashs[$i]);
  50.  
  51. if (count($hashs)>5) array_shift($hashs);
  52. array_push($hashs,$hash);
  53.  
  54. cnstats_sql_query("ALTER TABLE cns_config CHANGE COLUMN hash hash VARCHAR(165);");
  55. cnstats_sql_query("UPDATE cns_config SET hash='".implode("-",$hashs)."';");
  56. if ($HTTP_POST_VARS["store"]=="on")
  57. setcookie("CNSSESSION",$hash,time()+86400*365);
  58. else
  59. setcookie("CNSSESSION",$hash);
  60. header("Location: ./index.php");
  61. exit;
  62. }
  63. }
  64.  
  65. $CONFIG=mysql_fetch_array(cnstats_sql_query("SELECT * FROM cns_config"));
  66. include "lang/lang_".$CONFIG["language"].".php";
  67.  
  68. if ($COUNTER["disablepassword"]!="yes") {
  69.  
  70. $authed=false;
  71. $hashs=explode("-",$CONFIG["hash"]);
  72. for ($i=0;$i<count($hashs);$i++) if ($hashs[$i]==$HTTP_COOKIE_VARS["CNSSESSION"] && strlen($hashs[$i])==32) $authed=true;
  73.  
  74. if (!$authed) {
  75. ?>
  76. <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
  77. <HTML>
  78. <HEAD>
  79. <TITLE><?=$LANG["softname"];?></TITLE>
  80. <STYLE type="text/css">
  81. <!--
  82. body,td {font-size:11px;font-family:tahoma,sans-serif}
  83. //-->
  84. </STYLE>
  85. </HEAD>
  86. <BODY>
  87. <table style='width:100%;height:100%'><tr><td>
  88. <form class='m0' action='index.php' method='post' name="web">
  89. <table border='0' cellspacing='1' cellpadding='4' bgcolor='#B8D9D9' align='center' width='250'>
  90. <tr bgcolor='#B6D7D7'><td>
  91. <SCRIPT language='JavaScript' type='text/javascript'>
  92. <!--
  93. document.write('<img src="http://www.cn-software.com/stats1/cntg.php?r='+escape(document.referrer)+'&'+Math.random()+'" width=32 height=32 hspace=5 border=0>');
  94. // -->
  95. </SCRIPT><NOSCRIPT><a href='http://www.cn-software.com/' target='_blank'><img src="http://www.cn-software.com/stats1/cntg.php?r=nojs" width="32" hspace="5" height="32"
  96. border="0" alt=""></a></NOSCRIPT></td>
  97. <td width='100%'><a href='http://www.cn-software.com/cnstats/' style='font-size:13px;font-family:verdana;color:white;text-decoration:none;'><B><?=$LANG["softname"];?></B></td></tr>
  98. <tr><td bgcolor='#FEFEFE' align='center' colspan='2'>
  99.  
  100. <table>
  101. <tr><td><?=$LANG["login"];?>: <a href="http://www.cn-software.com/members/manual/#login" target="_blank"><sup>*</sup></a> </td><td><input type='text' name='login'>
  102. <? if ($err==2) print "<br><font color=red>".$LANG["incorrect login"]."</font>";?>
  103. </td></tr>
  104. <tr><td><?=$LANG["password"];?>: </td><td><input type='password' name='password'>
  105. <? if ($err==1) print "<br><font color=red>".$LANG["incorrect password"]."</font>";?>
  106. </td></tr>
  107. <tr><td colspan=2>
  108.  
  109. <input type="checkbox" name="store"> <?=$LANG["store password"];?>
  110.  
  111. </td></tr>
  112. </table>
  113.  
  114. </td></tr>
  115. <tr><td bgcolor='#FEFEFE' colspan='2' align='center'><input type='submit' value='<?=$LANG["submit"];?>' style='font-family:verdana,sans-serif;font-size:11px'></td></tr>
  116. </table>
  117. <input type='hidden' name='action' value='enter'>
  118. </form>
  119. </td></tr><tr><td valign="bottom" align="center">
  120. <font color='red'><B>THIS IS A DEMO VERSION.</B></font> If you want to obtain full version of CNStats, <a href='https://www.regnow.com/softsell/nph-softsell.cgi?item=7428-3' target='_blank'>please, register</a>. Complete information - <a href='http://www.cn-software.com/order.xhtm' target='_blank'>http://www.cn-software.com/order.xhtm</a>.
  121. </td></tr></table>
  122. <script><!--
  123. document.forms["web"].elements[0].focus() // --></script>
  124. </BODY>
  125. </HTML>
  126. <?
  127. exit;
  128. }
  129. }
  130.  
  131. if (empty($CONFIG["date_format"])) $CONFIG["date_format"]=$LANG["date_format"];
  132. if (empty($CONFIG["shortdate_format"])) $CONFIG["shortdate_format"]=$LANG["shortdate_format"];
  133. if (empty($CONFIG["shortdm_format"])) $CONFIG["shortdm_format"]=$LANG["shortdm_format"];
  134. if (empty($CONFIG["datetime_format"])) $CONFIG["datetime_format"]=$LANG["datetime_format"];
  135. if (empty($CONFIG["datetimes_format"])) $CONFIG["datetimes_format"]=$LANG["datetimes_format"];
  136.  
  137.  
  138. $MENU_GROUPS=Array(
  139. 0=>$LANG["pages"],
  140. 1=>$LANG["referers"],
  141. 2=>$LANG["geography"],
  142. 3=>$LANG["system"],
  143. 4=>$LANG["other"],
  144. 5=>$LANG["config"]
  145. );
  146.  
  147. $MENU=Array(
  148. 0,"attendance" ,$LANG["attendance"],
  149. 0,"pages"      ,$LANG["most popular pages"],
  150. 0,"input"      ,$LANG["input pages"],
  151. 0,"output"     ,$LANG["output pages"],
  152. 0,"domains"    ,$LANG["domain names"],
  153. 0,"parts"      ,$LANG["firts level"],
  154.  
  155. 1,"referers"   ,$LANG["refer pages"],
  156. 1,"servers"    ,$LANG["refer sites"],
  157. 1,"who_s"      ,$LANG["search systems"],
  158. 1,"who_c"      ,$LANG["catalogs"],
  159. 1,"who_r"      ,$LANG["ratings"],
  160. 1,"who"        ,$LANG["popular sites"],
  161. 1,"who_history",$LANG["who_history"],
  162. 1,"phrases"    ,$LANG["search phrases"],
  163. 1,"links"      ,$LANG["search links"],
  164. 1,"goodies"    ,$LANG["partners"],
  165. 1,"searchpages",$LANG["found pages"],
  166.  
  167. 2,"ip"         ,$LANG["ip adresses"],
  168. 2,"subnets"    ,$LANG["nets"],
  169. 2,"lang1"      ,$LANG["languages"],
  170. 2,"countries"  ,$LANG["countries"],
  171.  
  172. 3,"system"     ,$LANG["user-agents"],
  173. 3,"lang"       ,$LANG["accept-languages"],
  174. 3,"browsers"   ,$LANG["browsers"],
  175. 3,"robots"     ,$LANG["robots"],
  176. 3,"os"         ,$LANG["operating systems"],
  177.  
  178. 4,"now"        ,$LANG["on-line"],
  179. 4,"log"        ,$LANG["log"],
  180.  
  181.  
  182. 5,"filters"    ,$LANG["filters"],
  183. 5,"getcode"    ,$LANG["getcode"],
  184. 5,"confmail"   ,$LANG["confmail"],
  185. 5,"config"     ,$LANG["config"],
  186. 5,"dbsize"     ,$LANG["dbsize"],
  187. 5,"logout&nowrap=1"     ,$LANG["logout"],
  188.  
  189. );
  190.  
  191. $start=intval($HTTP_GET_VARS["start"]);
  192.  
  193. $st=$HTTP_GET_VARS["st"];
  194. if (empty($st)) $st="attendance";
  195. if (!file_exists("reports/".$st.".php")) $st="attendance";
  196.  
  197. if (isset($HTTP_GET_VARS["sd"])) {
  198. $stm=strtotime($HTTP_GET_VARS["sd"]);
  199. $ftm=strtotime($HTTP_GET_VARS["fd"]);
  200. }
  201. else {
  202. $stm=intval($HTTP_GET_VARS["stm"]);
  203. $ftm=intval($HTTP_GET_VARS["ftm"]);
  204. if ($stm==0) {
  205.  
  206. $stm=mktime(0,0,0,date("m"),date("d"),date("Y"))+$COUNTER["timeoffset"];
  207. $ftm=mktime(23,59,59,date("m"),date("d"),date("Y"))+$COUNTER["timeoffset"];
  208.  
  209. }
  210. }
  211.  
  212. $startdate=date("Y-m-d H:i:s",intval($stm));
  213. $enddate=date("Y-m-d H:i:s",intval($ftm));
  214.  
  215. $DATELINK="";
  216. if ($HTTP_GET_VARS["nowrap"]==1 || $HTTP_POST_VARS["nowrap"]==1) {
  217. include "reports/".$st.".php";
  218. exit;
  219. }
  220.  
  221. ?>
  222. <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
  223. <HTML>
  224. <HEAD>
  225. <TITLE><?=$LANG["softname"];?></TITLE>
  226. <META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=<?=$LANG["charset"];?>">
  227. <STYLE TYPE="text/css">
  228. <!--
  229. h1 {font-size:14px;padding-left:10px;}
  230. pre {color:#34783E;font-size:12px;font-family:courier new;}
  231. hr {height:1px;color:#B8E1BD;}
  232. ul {margin:10px 0 0 15px;}
  233. .tiny {font-size:9px;}
  234. select,input,td {font-family:tahoma,sans-serif;font-size:11px;}
  235. td.title {font-family:tahoma,sans-serif;font-size:11px;font-weight:bold;}
  236. a,a:visited {text-decoration:none;color:blue;}
  237. a:hover {text-decoration:underline}
  238. a.top_menu {text-decoration:none;font-size:10px;}
  239. .tbl0 {background-color:#D4F3D7;}
  240. .tbl1 {background-color:#E7F9EA;}
  241. .tbl2 {background-color:#F2FCF4;}
  242. .vis1 { visibility:visible; display:inline; }
  243. .vis2 { visibility:hidden; display:none; }
  244. .ttl {width:100%;background:#B8E1BD;background-image:url("img/bg.gif");}
  245. .m0 {margin:0px;}
  246. .hint {font-size:9px;color:gray;}
  247. //-->
  248. </STYLE>
  249. <SCRIPT language="JavaScript" TYPE="text/javascript">
  250. <!--
  251. function Calendar(el) {
  252. wnd=window.open('calendar.php?el='+el,'calendar_'+el,'width=120,height=230,top='+(screen.height/2-115)+', left='+(screen.width/2-60)+', scrollbars=no,resizable=no,status=no,toolbar=no,menubar=no');
  253. }
  254. //-->
  255. </SCRIPT>
  256.  
  257. </HEAD>
  258. <BODY bgcolor="white" background="img/<?=$BBG;?>" class='m0'>
  259.  
  260. <table cellspacing=0 cellpadding=0 border=0 width=770><tr><td valign='top' width=170><img alt='' src=img/none.gif width=170 height=1><br>
  261. <?
  262. // MENU
  263. if (isset($HTTP_GET_VARS["filter"])) $flt="&filter=".urlencode($HTTP_GET_VARS["filter"]);
  264.  
  265. for ($i=0;$i<count($MENU_GROUPS);$i++) {
  266. title($MENU_GROUPS[$i]);
  267. print "<table cellspacing=5 cellpadding=0 border=0><tr><td>\n";
  268. for ($j=0;$j<count($MENU);$j+=3) {
  269. if ($MENU[$j]==$i) {
  270. if ($st==$MENU[$j+1])
  271. print "".$MENU[$j+2]."<br>\n";
  272. else
  273. print "<a href='index.php?st=".$MENU[$j+1]."&stm=".$stm."&ftm=".$ftm.$flt."'>".$MENU[$j+2]."</a><br>\n";
  274. }
  275. }
  276. print "</td></tr></table>\n";
  277. }
  278.  
  279. title("CN-Software");
  280. print "<table cellspacing=5 cellpadding=0 border=0><tr><td>";
  281. print $LANG["copyright"];
  282. print "</td></tr></table>";
  283.  
  284. print "</td><td valign=top width=477 align=center>";
  285. print "<table cellspacing=5 cellpadding=0 border=0><tr><td valign=top>";
  286.  
  287. $rmn=false;
  288. if ($HTTP_GET_VARS["dateoff"]!=1 && $st!="attendance" && $st!="filters" && $st!="dbsize" && $st!="config" && $st!="confmail" && $st!="getcode" && $st!="who_history") $rmn=true;
  289.  
  290. if ($rmn) {
  291. print $TABLE."<tr class=tbl2><td style='color:gray;font-size:9px;'>";
  292. if (isset($LANG["reports"][$st])) print $LANG["reports"][$st];
  293. else for ($j=0;$j<count($MENU);$j+=3) if ($st==$MENU[$j+1]) print $MENU[$j+2]."\n";
  294. if (!empty($HTTP_GET_VARS["filter"])) print "<br>".$LANG["filter"].": ".$HTTP_GET_VARS["filter"];
  295. print "<br>".$LANG["report for period from"]." ".date($CONFIG["datetime_format"],strtotime($startdate))." ".$LANG["till"]." ".date($CONFIG["datetime_format"],strtotime($enddate));
  296. print "</td></tr></table>";
  297. print "<img alt='' src=img/none.gif width=1 height=3><br>";
  298. }
  299.  
  300. $ADMENU="";$NOFILTER=0;
  301. $diftime_start = getmicrotime();
  302. include "reports/".$st.".php";
  303. $diftime_end = getmicrotime();
  304. $diftime = $diftime_end - $diftime_start;
  305.  
  306. if ($NOFILTER==0) FormFilter($filter);
  307.  
  308. mysql_close();
  309. print "</td></tr></table>";
  310.  
  311. print "</td><td width=125 valign=top align=center>";
  312.  
  313. if (!empty($ADMENU)) {
  314. title($LANG["right additional"]);
  315. print "<table cellspacing=5 cellpadding=0 border=0 width='100%'><tr><td>";
  316. print $ADMENU;
  317. print "</td></tr></table>";
  318. }
  319.  
  320. if ($rmn) {
  321. $co=time()+$COUNTER["timeoffset"];
  322.  
  323. title($LANG["right bydates"]);
  324. print "<form class='m0' action='index.php' method='get'><table cellspacing=0 cellpadding=0 border=0>\n";
  325. print "<tr><td colspan=2>".$LANG["right startdate"].":</td></tr>\n";
  326. print "<tr><td><input type=text value='".substr($startdate,0,-3)."' name=sd style='font-size:9px;width:100px;' id=sd></td><td><a href='javascript:Calendar(\"sd\");'><img src='img/calendar.gif' alt='┬√ß≡α≥ⁿ Σα≥≤' width=16 height=16 border=0></a></td></tr>\n";
  327. print "<tr><td colspan=2>".$LANG["right enddate"].":</td></tr>\n";
  328. print "<tr><td><input type=text value='".substr($enddate,0,-3)."' name=fd style='font-size:9px;width:100px;' id=fd></td><td><a href='javascript:Calendar(\"fd\");'><img src='img/calendar.gif' alt='┬√ß≡α≥ⁿ Σα≥≤' width=16 height=16 border=0></a></td></tr>\n";
  329. print "<tr><td align=center colspan=2><img alt='' src=img/none.gif width=1 height=3><br><input type=submit value='".$LANG["right show"]."' style='font-size:9px;'></td></tr>\n";
  330. print "</table>\n";
  331. print "<input type=\"hidden\" name=\"st\" value='".$st."'>\n";
  332.  
  333. $fields=explode("&",$DATELINK);
  334. while (list ($key, $val) = each ($fields)) {
  335. list ($vkey,$vval)=explode("=",$val);
  336. if (!empty($vkey)) print "<input type=\"hidden\" name=\"".$vkey."\" value='".cnstats_mhtml(urldecode($vval))."'>\n";
  337. }
  338.  
  339. print "</form>\n";
  340. print "<img alt='' src=img/none.gif width=1 height=3><br>\n";
  341.  
  342. title($LANG["right bydays"]);
  343. print "<table cellspacing=5 cellpadding=0 border=0 width='100%'><tr><td>";
  344.  
  345. print "<a href='index.php?st=".$st."&stm=".(time()-300+$COUNTER["timeoffset"])."&ftm=".(time()+$COUNTER["timeoffset"]).$DATELINK."'>".$LANG["last 5minutes"]."</a><br>\n";
  346. print "<a href='index.php?st=".$st."&stm=".(time()-3600+$COUNTER["timeoffset"])."&ftm=".(time()+$COUNTER["timeoffset"]).$DATELINK."'>".$LANG["last hour"]."</a><br>\n";
  347. print "<a href='index.php?st=".$st."&stm=".(time()-86400+$COUNTER["timeoffset"])."&ftm=".(time()+$COUNTER["timeoffset"]).$DATELINK."'>".$LANG["last day"]."</a><br>\n";
  348. print "<img alt='' src=img/none.gif width=1 height=3><br>";
  349. print "<a href='index.php?st=".$st."&stm=".(mktime(0,0,0,date("m",$co),date("d",$co),date("Y",$co)))."&ftm=".(mktime(23,59,59,date("m",$co),date("d",$co),date("Y",$co))).$DATELINK."'>".$LANG["today"]."</a><br>\n";
  350. print "<a href='index.php?st=".$st."&stm=".(mktime(0,0,0,date("m",$co),date("d",$co)-1,date("Y",$co)))."&ftm=".(mktime(23,59,59,date("m",$co),date("d",$co)-1,date("Y",$co))).$DATELINK."'>".$LANG["yesterday"]."</a><br>\n";
  351. print "<a href='index.php?st=".$st."&stm=".(mktime(0,0,0,date("m",$co),date("d",$co)-7,date("Y",$co)))."&ftm=".(mktime(23,59,59,date("m",$co),date("d",$co),date("Y",$co))).$DATELINK."'>".$LANG["7 days"]."</a><br>\n";
  352. print "<a href='index.php?st=".$st."&stm=".(mktime(0,0,0,date("m",$co),date("d",$co)-30,date("Y",$co)))."&ftm=".(mktime(23,59,59,date("m",$co),date("d",$co),date("Y",$co))).$DATELINK."'>".$LANG["30 days"]."</a><br>\n";
  353. print "</td></tr></table>";
  354. }
  355.  
  356. if ($st!="getcode" && $st!="manual" && $st!="confmail" && $st!="config" && $st!="ipinfo"  && $st!="who_history") {
  357. title($LANG["manual"]);
  358. print "<table cellspacing=5 cellpadding=0 border=0 width='100%'><tr><td>\n";
  359. print "<a href=\"index.php?st=manual&stm=".$stm."&ftm=".$ftm."\">".$LANG["manual"]."</a><br>\n";
  360. print "<a href=\"index.php?st=manual&stm=".$stm."&ftm=".$ftm."#".$st."\">".$LANG["report description"]."</a><br>\n";
  361. print "<img alt='' src=img/none.gif width=1 height=3><br>";
  362. print "<a href=\"http://www.cn-software.com/members/manual/\">".$LANG["online manual"]."</a>\n";
  363. print "</td></tr></table>\n";
  364. }
  365.  
  366. title($LANG["right time"]);
  367. print "<table cellspacing=5 cellpadding=0 border=0 width='100%'><tr><td align='center'>";
  368. printf ($LANG["report was generated"].":<br>%f ".$LANG["sec"]."<br>".$LANG["current time"].":<br>".date($CONFIG["datetime_format"],time()+$COUNTER["timeoffset"]),$diftime);
  369. print "</td></tr></table>";
  370.  
  371. print "<img alt='' src=img/none.gif width=125 height=1><br>";
  372.  
  373. print "</td></tr></table>";
  374. ?>