PageRenderTime 49ms CodeModel.GetById 19ms RepoModel.GetById 0ms app.codeStats 0ms

/nukeviet/modules/statistics/theme.php

http://nuke-viet.googlecode.com/
PHP | 644 lines | 440 code | 149 blank | 55 comment | 58 complexity | 6e3e9b7bb1361e6cc8137632669f6f92 MD5 | raw file
Possible License(s): BSD-3-Clause, LGPL-2.1, GPL-2.0
  1. <?php
  2. /**
  3. * @Project NUKEVIET 3.x
  4. * @Author VINADES.,JSC (contact@vinades.vn)
  5. * @copyright 2009
  6. * @createdate 10/03/2010 10:51
  7. */
  8. if( ! defined( 'NV_IS_MOD_STATISTICS' ) ) die( 'Stop!!!' );
  9. /**
  10. * referer()
  11. *
  12. * @return
  13. */
  14. function referer()
  15. {
  16. global $module_info, $global_config, $module_file, $db, $lang_module, $lang_global, $nv_Request, $module_name, $all_page, $countries_list, $cts, $host_list, $total;
  17. $xtpl = new XTemplate( "referer.tpl", NV_ROOTDIR . "/themes/" . $module_info['template'] . '/modules/' . $module_file );
  18. if( $total )
  19. {
  20. $xtpl->assign( 'CTS', $cts );
  21. foreach( $cts['rows'] as $m )
  22. {
  23. if( ! empty( $m['count'] ) )
  24. {
  25. $proc = ceil( ( $m['count'] / $cts['max'] ) * 100 );
  26. $xtpl->assign( 'M', $m );
  27. $xtpl->assign( 'SRC', NV_BASE_SITEURL . "themes/" . $module_info['template'] . "/images/statistics/bg.gif" );
  28. $xtpl->assign( 'HEIGHT', $proc * 2 );
  29. $xtpl->parse( 'main.loop.img' );
  30. }
  31. $xtpl->parse( 'main.loop' );
  32. }
  33. foreach( $cts['rows'] as $key => $m )
  34. {
  35. $xtpl->assign( 'M', $m );
  36. if( $key == $cts['current_month'] )
  37. {
  38. $xtpl->parse( 'main.loop_1.m_c' );
  39. }
  40. else
  41. {
  42. $xtpl->parse( 'main.loop_1.m_o' );
  43. }
  44. $xtpl->parse( 'main.loop_1' );
  45. }
  46. }
  47. $xtpl->parse( 'main' );
  48. return $xtpl->text( 'main' );
  49. }
  50. /**
  51. * allreferers()
  52. *
  53. * @return
  54. */
  55. function allreferers()
  56. {
  57. global $module_info, $global_config, $module_file, $db, $lang_module, $lang_global, $nv_Request, $module_name, $all_page, $countries_list, $cts, $host_list;
  58. $xtpl = new XTemplate( "allreferers.tpl", NV_ROOTDIR . "/themes/" . $module_info['template'] . '/modules/' . $module_file );
  59. if( $all_page )
  60. {
  61. if( ! empty( $host_list ) )
  62. {
  63. $xtpl->assign( 'CTS', $cts );
  64. $a = 0;
  65. foreach( $cts['rows'] as $key => $value )
  66. {
  67. $class = ( $a % 2 == 0 ) ? " class=\"second\"" : "";
  68. $xtpl->assign( 'CLASS', $class );
  69. $xtpl->assign( 'VALUE', $value );
  70. $xtpl->assign( 'KEY', $key );
  71. if( $value[0] )
  72. {
  73. $proc = ceil( ( $value[0] / $cts['max'] ) * 100 );
  74. $xtpl->assign( 'SRC', NV_BASE_SITEURL . "themes/" . $module_info['template'] . "/images/statistics/bg2.gif" );
  75. $xtpl->assign( 'WIDTH', $proc * 3 );
  76. $xtpl->parse( 'main.loop.img' );
  77. }
  78. ++$a;
  79. $xtpl->parse( 'main.loop' );
  80. }
  81. if( ! empty( $cts['generate_page'] ) )
  82. {
  83. $xtpl->parse( 'main.gp' );
  84. }
  85. }
  86. }
  87. $xtpl->parse( 'main' );
  88. return $xtpl->text( 'main' );
  89. }
  90. /**
  91. * allbots()
  92. *
  93. * @return
  94. */
  95. function allbots()
  96. {
  97. global $module_info, $global_config, $module_file, $db, $lang_module, $lang_global, $nv_Request, $module_name, $all_page, $bot_list, $cts;
  98. $xtpl = new XTemplate( "allbots.tpl", NV_ROOTDIR . "/themes/" . $module_info['template'] . '/modules/' . $module_file );
  99. if( $all_page )
  100. {
  101. if( ! empty( $bot_list ) )
  102. {
  103. $xtpl->assign( 'CTS', $cts );
  104. $a = 0;
  105. foreach( $cts['rows'] as $key => $value )
  106. {
  107. $class = ( $a % 2 == 0 ) ? " class=\"second\"" : "";
  108. $xtpl->assign( 'CLASS', $class );
  109. $xtpl->assign( 'KEY', $key );
  110. $xtpl->assign( 'VALUE', $value );
  111. if( $value[0] )
  112. {
  113. $proc = ceil( ( $value[0] / $cts['max'] ) * 100 );
  114. $xtpl->assign( 'SRC', NV_BASE_SITEURL . "themes/" . $module_info['template'] . "/images/statistics/bg2.gif" );
  115. $xtpl->assign( 'WIDTH', $proc * 3 );
  116. $xtpl->parse( 'main.loop.img' );
  117. }
  118. ++$a;
  119. $xtpl->parse( 'main.loop' );
  120. }
  121. if( ! empty( $cts['generate_page'] ) )
  122. {
  123. $xtpl->parse( 'main.gp' );
  124. }
  125. }
  126. }
  127. $xtpl->parse( 'main' );
  128. return $xtpl->text( 'main' );
  129. }
  130. /**
  131. * allos()
  132. *
  133. * @return
  134. */
  135. function allos()
  136. {
  137. global $module_info, $global_config, $module_file, $db, $lang_module, $lang_global, $nv_Request, $module_name, $all_page, $os_list, $cts;
  138. $xtpl = new XTemplate( "allos.tpl", NV_ROOTDIR . "/themes/" . $module_info['template'] . '/modules/' . $module_file );
  139. if( $all_page )
  140. {
  141. if( ! empty( $os_list ) )
  142. {
  143. $xtpl->assign( 'CTS', $cts );
  144. $a = 0;
  145. foreach( $cts['rows'] as $key => $value )
  146. {
  147. $class = ( $a % 2 == 0 ) ? " class=\"second\"" : "";
  148. $xtpl->assign( 'CLASS', $class );
  149. $xtpl->assign( 'KEY', $key );
  150. $xtpl->assign( 'VALUE', $value );
  151. if( $value[0] )
  152. {
  153. $proc = ceil( ( $value[0] / $cts['max'] ) * 100 );
  154. $xtpl->assign( 'SRC', NV_BASE_SITEURL . "themes/" . $module_info['template'] . "/images/statistics/bg2.gif" );
  155. $xtpl->assign( 'WIDTH', $proc * 3 );
  156. $xtpl->parse( 'main.loop.img' );
  157. }
  158. ++$a;
  159. $xtpl->parse( 'main.loop' );
  160. }
  161. if( ! empty( $cts['generate_page'] ) )
  162. {
  163. $xtpl->parse( 'main.gp' );
  164. }
  165. }
  166. }
  167. $xtpl->parse( 'main' );
  168. return $xtpl->text( 'main' );
  169. }
  170. /**
  171. * allbrowsers()
  172. *
  173. * @return
  174. */
  175. function allbrowsers()
  176. {
  177. global $module_info, $global_config, $module_file, $db, $lang_module, $lang_global, $nv_Request, $module_name, $all_page, $browsers_list, $cts;
  178. $xtpl = new XTemplate( "allbrowsers.tpl", NV_ROOTDIR . "/themes/" . $module_info['template'] . '/modules/' . $module_file );
  179. if( $all_page )
  180. {
  181. if( ! empty( $browsers_list ) )
  182. {
  183. $xtpl->assign( 'CTS', $cts );
  184. $a = 0;
  185. foreach( $cts['rows'] as $key => $value )
  186. {
  187. $class = ( $a % 2 == 0 ) ? " class=\"second\"" : "";
  188. $xtpl->assign( 'CLASS', $class );
  189. $xtpl->assign( 'KEY', $key );
  190. $xtpl->assign( 'VALUE', $value );
  191. if( $value[0] )
  192. {
  193. $proc = ceil( ( $value[0] / $cts['max'] ) * 100 );
  194. $xtpl->assign( 'SRC', NV_BASE_SITEURL . "themes/" . $module_info['template'] . "/images/statistics/bg2.gif" );
  195. $xtpl->assign( 'WIDTH', $proc * 3 );
  196. $xtpl->parse( 'main.loop.img' );
  197. }
  198. ++$a;
  199. $xtpl->parse( 'main.loop' );
  200. }
  201. if( ! empty( $cts['generate_page'] ) )
  202. {
  203. $xtpl->parse( 'main.gp' );
  204. }
  205. }
  206. }
  207. $xtpl->parse( 'main' );
  208. return $xtpl->text( 'main' );
  209. }
  210. /**
  211. * allcountries()
  212. *
  213. * @return
  214. */
  215. function allcountries()
  216. {
  217. global $module_info, $global_config, $module_file, $db, $lang_module, $lang_global, $nv_Request, $module_name, $all_page, $countries_list, $cts;
  218. $xtpl = new XTemplate( "allcountries.tpl", NV_ROOTDIR . "/themes/" . $module_info['template'] . '/modules/' . $module_file );
  219. if( $all_page )
  220. {
  221. if( ! empty( $countries_list ) )
  222. {
  223. $xtpl->assign( 'CTS', $cts );
  224. $a = 0;
  225. foreach( $cts['rows'] as $key => $value )
  226. {
  227. $class = ( $a % 2 == 0 ) ? " class=\"second\"" : "";
  228. $xtpl->assign( 'CLASS', $class );
  229. $xtpl->assign( 'VALUE', $value );
  230. $xtpl->assign( 'KEY', $key );
  231. if( $value[0] )
  232. {
  233. $proc = ceil( ( $value[1] / $cts['max'] ) * 100 );
  234. $xtpl->assign( 'SRC', NV_BASE_SITEURL . "themes/" . $module_info['template'] . "/images/statistics/bg2.gif" );
  235. $xtpl->assign( 'WIDTH', $proc * 3 );
  236. $xtpl->parse( 'main.loop.img' );
  237. }
  238. ++$a;
  239. $xtpl->parse( 'main.loop' );
  240. }
  241. if( ! empty( $cts['generate_page'] ) )
  242. {
  243. $xtpl->parse( 'main.gp' );
  244. }
  245. }
  246. }
  247. $xtpl->parse( 'main' );
  248. return $xtpl->text( 'main' );
  249. }
  250. /**
  251. * main()
  252. *
  253. * @return
  254. */
  255. function main()
  256. {
  257. global $module_info, $global_config, $module_file, $db, $lang_module, $lang_global, $ctsy, $ctsm, $ctsdm, $ctsdw, $ctsc, $ctsb, $ctso, $ctsh, $contents;
  258. $xtpl = new XTemplate( "main.tpl", NV_ROOTDIR . "/themes/" . $module_info['template'] . '/modules/' . $module_file );
  259. $xtpl->assign( 'CTS', $ctsy );
  260. foreach( $ctsy['rows'] as $key => $m )
  261. {
  262. if( ! empty( $m ) )
  263. {
  264. $xtpl->assign( 'M', $m );
  265. $proc = ceil( ( $m / $ctsy['max'] ) * 100 );
  266. $xtpl->assign( 'SRC', NV_BASE_SITEURL . "themes/" . $module_info['template'] . "/images/statistics/bg.gif" );
  267. $xtpl->assign( 'HEIGHT', $proc * 2 );
  268. $xtpl->parse( 'main.year.loop.img' );
  269. }
  270. $xtpl->parse( 'main.year.loop' );
  271. }
  272. foreach( $ctsy['rows'] as $key => $m )
  273. {
  274. $xtpl->assign( 'KEY', $key );
  275. if( $key == $ctsy['current_year'] )
  276. {
  277. $xtpl->parse( 'main.year.loop_1.yc' );
  278. }
  279. else
  280. {
  281. $xtpl->parse( 'main.year.loop_1.yc_o' );
  282. }
  283. $xtpl->parse( 'main.year.loop_1' );
  284. }
  285. $xtpl->parse( 'main.year' );
  286. //Thong ke theo thang
  287. $xtpl->assign( 'CTS', $ctsm );
  288. foreach( $ctsm['rows'] as $m )
  289. {
  290. if( ! empty( $m['count'] ) )
  291. {
  292. $contents .= $m['count'] . "<br />";
  293. $proc = ceil( ( $m['count'] / $ctsm['max'] ) * 100 );
  294. $xtpl->assign( 'M', $m );
  295. $xtpl->assign( 'SRC', NV_BASE_SITEURL . "themes/" . $module_info['template'] . "/images/statistics/bg.gif" );
  296. $xtpl->assign( 'HEIGHT', $proc * 2 );
  297. $xtpl->parse( 'main.month.loop.img' );
  298. }
  299. $xtpl->parse( 'main.month.loop' );
  300. }
  301. foreach( $ctsm['rows'] as $key => $m )
  302. {
  303. $xtpl->assign( 'KEY', $key );
  304. $xtpl->assign( 'M', $m );
  305. if( $key == $ctsm['current_month'] )
  306. {
  307. $xtpl->parse( 'main.month.loop_1.mc' );
  308. }
  309. else
  310. {
  311. $xtpl->parse( 'main.month.loop_1.mc_o' );
  312. }
  313. $xtpl->parse( 'main.month.loop_1' );
  314. }
  315. $xtpl->parse( 'main.month' );
  316. //Thong ke theo thang
  317. //thong ke theo ngay trong thang
  318. $xtpl->assign( 'CTS', $ctsdm );
  319. foreach( $ctsdm['rows'] as $key => $m )
  320. {
  321. $xtpl->assign( 'M', $m );
  322. if( ! empty( $m ) )
  323. {
  324. $proc = ceil( ( $m / $ctsdm['max'] ) * 100 );
  325. $xtpl->assign( 'SRC', NV_BASE_SITEURL . "themes/" . $module_info['template'] . "/images/statistics/bg.gif" );
  326. $xtpl->assign( 'HEIGHT', $proc * 2 );
  327. $xtpl->parse( 'main.day_m.loop.img' );
  328. }
  329. $xtpl->parse( 'main.day_m.loop' );
  330. }
  331. foreach( $ctsdm['rows'] as $key => $m )
  332. {
  333. $xtpl->assign( 'KEY', $key );
  334. if( $key == $ctsdm['current_day'] )
  335. {
  336. $xtpl->parse( 'main.day_m.loop_1.dc' );
  337. }
  338. else
  339. {
  340. $xtpl->parse( 'main.day_m.loop_1.dc_o' );
  341. }
  342. $xtpl->parse( 'main.day_m.loop_1' );
  343. }
  344. $xtpl->parse( 'main.day_m' );
  345. //thong ke theo ngay trong thang
  346. //Thong ke theo ngay cua tuan
  347. $xtpl->assign( 'CTS', $ctsdw );
  348. foreach( $ctsdw['rows'] as $key => $m )
  349. {
  350. $xtpl->assign( 'M', $m );
  351. if( ! empty( $m['count'] ) )
  352. {
  353. $proc = ceil( ( $m['count'] / $ctsdw['max'] ) * 100 );
  354. $xtpl->assign( 'SRC', NV_BASE_SITEURL . "themes/" . $module_info['template'] . "/images/statistics/bg.gif" );
  355. $xtpl->assign( 'HEIGHT', $proc * 2 );
  356. $xtpl->parse( 'main.day_k.loop.img' );
  357. }
  358. $xtpl->parse( 'main.day_k.loop' );
  359. }
  360. foreach( $ctsdw['rows'] as $key => $m )
  361. {
  362. $xtpl->assign( 'KEY', $key );
  363. $xtpl->assign( 'M', $m );
  364. if( $key == $ctsdw['current_dayofweek'] )
  365. {
  366. $xtpl->parse( 'main.day_k.loop_1.dc' );
  367. }
  368. else
  369. {
  370. $xtpl->parse( 'main.day_k.loop_1.dc_o' );
  371. }
  372. $xtpl->parse( 'main.day_k.loop_1' );
  373. }
  374. $xtpl->parse( 'main.day_k' );
  375. //Thong ke theo ngay cua tuan
  376. //Thong ke theo gio trong ngay
  377. $xtpl->assign( 'CTS', $ctsh );
  378. if( ! empty( $ctsh['rows'] ) )
  379. {
  380. foreach( $ctsh['rows'] as $key => $m )
  381. {
  382. if( ! empty( $m ) )
  383. {
  384. $xtpl->assign( 'M', $m );
  385. $proc = ceil( ( $m / $ctsh['max'] ) * 100 );
  386. $xtpl->assign( 'SRC', NV_BASE_SITEURL . "themes/" . $module_info['template'] . "/images/statistics/bg.gif" );
  387. $xtpl->assign( 'HEIGHT', $proc * 2 );
  388. $xtpl->parse( 'main.hour.loop.img' );
  389. }
  390. $xtpl->parse( 'main.hour.loop' );
  391. }
  392. foreach( $ctsh['rows'] as $key => $m )
  393. {
  394. $xtpl->assign( 'KEY', $key );
  395. if( $key == $ctsh['current_hour'] )
  396. {
  397. $xtpl->parse( 'main.hour.loop_1.h' );
  398. }
  399. else
  400. {
  401. $xtpl->parse( 'main.hour.loop_1.h_o' );
  402. }
  403. $xtpl->parse( 'main.hour.loop_1' );
  404. }
  405. }
  406. $xtpl->parse( 'main.hour' );
  407. //Thong ke theo gio trong ngay
  408. //Thong ke theo quoc gia
  409. $xtpl->assign( 'CTS', $ctsc );
  410. $a = 0;
  411. foreach( $ctsc['rows'] as $key => $value )
  412. {
  413. $class = ( $a % 2 == 0 ) ? " class=\"second\"" : "";
  414. $xtpl->assign( 'CLASS', $class );
  415. $xtpl->assign( 'VALUE', $value );
  416. $xtpl->assign( 'KEY', $key );
  417. if( $value[1] )
  418. {
  419. $proc = ceil( ( $value[1] / $ctsc['max'] ) * 100 );
  420. $xtpl->assign( 'SRC', NV_BASE_SITEURL . "themes/" . $module_info['template'] . "/images/statistics/bg2.gif" );
  421. $xtpl->assign( 'WIDTH', $proc * 3 );
  422. $xtpl->parse( 'main.ct.loop.img' );
  423. }
  424. ++$a;
  425. $xtpl->parse( 'main.ct.loop' );
  426. }
  427. if( $ctsc['others'][1] )
  428. {
  429. $class = ( $a % 2 == 0 ) ? " class=\"second\"" : "";
  430. $xtpl->assign( 'CLASS', $class );
  431. $xtpl->assign( 'URL', NV_BASE_SITEURL . "index.php?" . NV_LANG_VARIABLE . "=" . NV_LANG_DATA . "&amp;" . NV_NAME_VARIABLE . "=statistics&amp;" . NV_OP_VARIABLE . "=allcountries" );
  432. $xtpl->parse( 'main.ct.ot' );
  433. }
  434. $xtpl->parse( 'main.ct' );
  435. //Thong ke theo quoc gia
  436. //Thong ke theo trinh duyet
  437. $xtpl->assign( 'CTS', $ctsb );
  438. $a = 0;
  439. foreach( $ctsb['rows'] as $key => $value )
  440. {
  441. $class = ( $a % 2 == 0 ) ? " class=\"second\"" : "";
  442. $xtpl->assign( 'CLASS', $class );
  443. $xtpl->assign( 'KEY', $key );
  444. $xtpl->assign( 'VALUE', $value );
  445. if( $value[0] )
  446. {
  447. $proc = ceil( ( $value[0] / $ctsb['max'] ) * 100 );
  448. $xtpl->assign( 'SRC', NV_BASE_SITEURL . "themes/" . $module_info['template'] . "/images/statistics/bg2.gif" );
  449. $xtpl->assign( 'WIDTH', $proc * 3 );
  450. $xtpl->parse( 'main.br.loop.img' );
  451. }
  452. $xtpl->parse( 'main.br.loop' );
  453. ++$a;
  454. }
  455. if( $ctsb['others'][1] )
  456. {
  457. $class = ( $a % 2 == 0 ) ? " class=\"second\"" : "";
  458. $xtpl->assign( 'CLASS', $class );
  459. $xtpl->assign( 'URL', NV_BASE_SITEURL . "index.php?" . NV_LANG_VARIABLE . "=" . NV_LANG_DATA . "&amp;" . NV_NAME_VARIABLE . "=statistics&amp;" . NV_OP_VARIABLE . "=allbrowsers" );
  460. $xtpl->parse( 'main.br.ot' );
  461. }
  462. $xtpl->parse( 'main.br' );
  463. //Thong ke theo trinh duyet
  464. //Thong ke theo he dieu hanh
  465. $xtpl->assign( 'CTS', $ctso );
  466. $a = 0;
  467. foreach( $ctso['rows'] as $key => $value )
  468. {
  469. $class = ( $a % 2 == 0 ) ? " class=\"second\"" : "";
  470. $xtpl->assign( 'CLASS', $class );
  471. $xtpl->assign( 'KEY', $key );
  472. $xtpl->assign( 'VALUE', $value );
  473. if( $value[0] )
  474. {
  475. $proc = ceil( ( $value[0] / $ctso['max'] ) * 100 );
  476. $xtpl->assign( 'SRC', NV_BASE_SITEURL . "themes/" . $module_info['template'] . "/images/statistics/bg2.gif" );
  477. $xtpl->assign( 'WIDTH', $proc * 3 );
  478. $xtpl->parse( 'main.os.loop.img' );
  479. }
  480. $xtpl->parse( 'main.os.loop' );
  481. ++$a;
  482. }
  483. if( $ctso['others'][1] )
  484. {
  485. $class = ( $a % 2 == 0 ) ? " class=\"second\"" : "";
  486. $xtpl->assign( 'CLASS', $class );
  487. $xtpl->assign( 'URL', NV_BASE_SITEURL . "index.php?" . NV_LANG_VARIABLE . "=" . NV_LANG_DATA . "&amp;" . NV_NAME_VARIABLE . "=statistics&amp;" . NV_OP_VARIABLE . "=allos" );
  488. $xtpl->parse( 'main.os.ot' );
  489. }
  490. $xtpl->parse( 'main.os' );
  491. //Thong ke theo he dieu hanh
  492. $xtpl->parse( 'main' );
  493. return $xtpl->text( 'main' );
  494. }
  495. ?>