/Quản lý website trường trung học phổ thông PHP/lc1/modules/banners/admin/show_list_stat.php

https://gitlab.com/phamngsinh/baitaplon_sinhvien · PHP · 153 lines · 116 code · 27 blank · 10 comment · 24 complexity · 1e0994ff98c2e6e4058aa7e5c0c61b3a MD5 · raw file

  1. <?php
  2. /**
  3. * @Project NUKEVIET 3.0
  4. * @Author VINADES.,JSC (contact@vinades.vn)
  5. * @Copyright (C) 2010 VINADES., JSC. All rights reserved
  6. * @Createdate 3/19/2010 12:19
  7. */
  8. if (! defined ( 'NV_IS_FILE_ADMIN' ))
  9. die ( 'Stop!!!' );
  10. //if ( $client_info['is_myreferer'] != 1 ) die( 'Wrong URL' );
  11. $bid = $nv_Request->get_int ( 'bid', 'get', 0 );
  12. if (empty ( $bid ))
  13. die ( 'Stop!!!' );
  14. $query = "SELECT * FROM `" . NV_BANNERS_ROWS_GLOBALTABLE . "` WHERE `id`=" . $bid;
  15. $result = $db->sql_query ( $query );
  16. $numrows = $db->sql_numrows ( $result );
  17. if ($numrows != 1)
  18. die ( 'Stop!!!' );
  19. $row = $db->sql_fetchrow ( $result );
  20. $current_day = date ( "d" );
  21. $current_month = date ( "n" );
  22. $current_year = date ( "Y" );
  23. $publ_day = date ( "d", $row ['publ_time'] );
  24. $publ_month = date ( "n", $row ['publ_time'] );
  25. $publ_year = date ( "Y", $row ['publ_time'] );
  26. $data_month = $current_month;
  27. if (preg_match ( "/^[0-9]{1,2}$/", $nv_Request->get_int ( 'month', 'get' ) )) {
  28. $post_month = $nv_Request->get_int ( 'month', 'get' );
  29. if ($post_month < $current_month) {
  30. if ($current_year != $publ_year) {
  31. $data_month = $post_month;
  32. } elseif ($post_month > $publ_month) {
  33. $data_month = $post_month;
  34. }
  35. }
  36. }
  37. //$table = ( $data_month == $current_month ) ? NV_BANNERS_CLICK_GLOBALTABLE : NV_BANNERS_CLICK_GLOBALTABLE . '_' . $current_year . '_' . str_pad( $get_month, 2, "0", STR_PAD_LEFT );
  38. $table = NV_BANNERS_CLICK_GLOBALTABLE;
  39. $time = mktime ( 0, 0, 0, $data_month, 15, $current_year );
  40. $day_max = ($data_month == $current_month) ? $current_day : date ( "t", $time );
  41. $day_min = ($current_month == $publ_month and $current_year == $publ_year) ? $publ_day : 1;
  42. $query = "SELECT COUNT(*) FROM `" . $table . "` WHERE `bid`=" . $bid . "";
  43. $base_url = NV_BASE_ADMINURL . "index.php?" . NV_NAME_VARIABLE . "=" . $module_name . "&amp;" . NV_OP_VARIABLE . "=show_list_stat&amp;bid=" . $bid . "&amp;month=" . $data_month;
  44. $caption = sprintf ( $lang_module ['show_list_stat1'], nv_monthname ( $data_month ), $current_year );
  45. $data_ext = $data_val = "";
  46. $countries = array ();
  47. include (NV_ROOTDIR . "/includes/ip_files/countries.php");
  48. if (in_array ( $nv_Request->get_string ( 'ext', 'get', 'no' ), array ('day', 'country', 'browse', 'os' ) )) {
  49. switch ($nv_Request->get_string ( 'ext', 'get' )) {
  50. case 'day' :
  51. if ($nv_Request->isset_request ( 'val', 'get' ) and preg_match ( "/^[0-9]+$/", $nv_Request->get_string ( 'val', 'get' ) ) and $nv_Request->get_int ( 'val', 'get', 0 ) <= $day_max and $nv_Request->get_int ( 'val', 'get', 0 ) >= $day_min) {
  52. $data_ext = 'day';
  53. $data_val = $nv_Request->get_int ( 'val', 'get' );
  54. $maxday = mktime ( 24, 60, 60, $data_month, $data_val, $current_year );
  55. $minday = mktime ( 0, 0, 0, $data_month, $data_val, $current_year );
  56. $query .= " AND `click_time`>=" . $minday . " AND `click_time`<=" . $maxday;
  57. $base_url .= "&amp;ext=" . $data_ext . "&amp;val=" . $data_val;
  58. $caption = sprintf ( $lang_module ['show_list_stat2'], str_pad ( $data_val, 2, "0", STR_PAD_LEFT ), nv_monthname ( $data_month ), $current_year );
  59. }
  60. break;
  61. case 'country' :
  62. if ($nv_Request->isset_request ( 'val', 'get' ) and ($nv_Request->get_string ( 'val', 'get' ) == 'Unknown' or preg_match ( "/^[A-Z]{2}$/", $nv_Request->get_string ( 'val', 'get' ) ))) {
  63. $data_ext = 'country';
  64. $data_val = $nv_Request->get_string ( 'val', 'get' );
  65. $query .= " AND `click_country`=" . $db->dbescape ( $data_val );
  66. $base_url .= "&amp;ext=" . $data_ext . "&amp;val=" . $data_val;
  67. $caption = sprintf ( $lang_module ['show_list_stat3'], (isset ( $countries [$data_val] ) ? $countries [$data_val] [1] : $data_val), nv_monthname ( $data_month ), $current_year );
  68. }
  69. break;
  70. case 'browse' :
  71. if ($nv_Request->isset_request ( 'val', 'get' ) and preg_match ( "/^[a-zA-Z0-9]+$/", $nv_Request->get_string ( 'val', 'get' ) )) {
  72. $data_ext = 'browse';
  73. $data_val = $nv_Request->get_string ( 'val', 'get' );
  74. $query .= " AND `click_browse_name`=" . $db->dbescape ( $data_val );
  75. $base_url .= "&amp;ext=" . $data_ext . "&amp;val=" . $data_val;
  76. $caption = sprintf ( $lang_module ['show_list_stat4'], "{pattern}", nv_monthname ( $data_month ), $current_year );
  77. }
  78. break;
  79. case 'os' :
  80. if ($nv_Request->isset_request ( 'val', 'get' ) and preg_match ( "/^[a-zA-Z0-9-\\s]+$/", $nv_Request->get_string ( 'val', 'get' ) )) {
  81. $data_ext = 'os';
  82. $data_val = $nv_Request->get_string ( 'val', 'get' );
  83. $query .= " AND `click_os_name`=" . $db->dbescape ( $data_val );
  84. $base_url .= "&amp;ext=" . $data_ext . "&amp;val=" . $data_val;
  85. $caption = sprintf ( $lang_module ['show_list_stat5'], "{pattern}", nv_monthname ( $data_month ), $current_year );
  86. }
  87. break;
  88. }
  89. }
  90. list ( $all_page ) = $db->sql_fetchrow ( $db->sql_query ( $query ) );
  91. if (empty ( $all_page ))
  92. die ( 'Wrong URL' );
  93. $page = $nv_Request->get_int ( 'page', 'get', 0 );
  94. $per_page = 50;
  95. $query .= " ORDER BY `click_time` DESC LIMIT " . $page . "," . $per_page;
  96. /*echo $query;
  97. die;*/
  98. $query = preg_replace ( "/COUNT\(\*\)/", "*", $query );
  99. $result = $db->sql_query ( $query );
  100. $contents = array ();
  101. $replacement = "";
  102. $a = 0;
  103. while ( $row = $db->sql_fetchrow ( $result ) ) {
  104. $contents ['rows'] [$a] [] = nv_date ( "d-m-Y H:i", $row ['click_time'] );
  105. $contents ['rows'] [$a] [] = $row ['click_ip'];
  106. $contents ['rows'] [$a] [] = isset ( $countries [$row ['click_country']] ) ? $countries [$row ['click_country']] [1] : $row ['click_country'];
  107. $contents ['rows'] [$a] [] = $row ['click_browse_name'];
  108. $contents ['rows'] [$a] [] = $row ['click_os_name'];
  109. $contents ['rows'] [$a] [] = ! empty ( $row ['click_ref'] ) ? "<a href=\"" . $row ['click_ref'] . "\">" . $lang_module ['select'] . "</a>" : "";
  110. if ($data_ext == 'browse' and empty ( $replacement ))
  111. $replacement = $row ['click_browse_name'];
  112. elseif ($data_ext == 'os' and empty ( $replacement ))
  113. $replacement = $row ['click_os_name'];
  114. $a ++;
  115. }
  116. if (! empty ( $replacement )) {
  117. $caption = preg_replace ( "/\{pattern\}/", $replacement, $caption );
  118. }
  119. $contents ['caption'] = $caption;
  120. $contents ['thead'] = array ($lang_module ['click_date'], $lang_module ['click_ip'], $lang_module ['click_country'], $lang_module ['click_browse'], $lang_module ['click_os'], $lang_module ['click_ref'] );
  121. $contents ['generate_page'] = nv_generate_page ( $base_url, $all_page, $per_page, $page, true, true, 'nv_urldecode_ajax', 'statistic' );
  122. $contents = call_user_func ( "nv_show_list_stat_theme", $contents );
  123. include (NV_ROOTDIR . "/includes/header.php");
  124. echo $contents;
  125. include (NV_ROOTDIR . "/includes/footer.php");
  126. ?>