PageRenderTime 46ms CodeModel.GetById 13ms RepoModel.GetById 1ms app.codeStats 0ms

/nukeviet/modules/statistics/theme.php

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