├── VERSION ├── README.md ├── .gitattributes ├── .gitignore ├── header.php ├── foot.php ├── charthitsperhour.php ├── chartcountriesperhour.php ├── charthitsperday.php ├── chartcountriesperday.php ├── autocomplete.php ├── functions.php ├── dialtodayhits.php ├── head.php ├── dialtodaycountryhits.php ├── config.php.dist ├── dialtodaybannedhits.php ├── dialtodayallowedhits.php ├── login.php ├── stylesheet.css ├── viewcountry.php ├── countryarray.php ├── index.php └── viewall.php /VERSION: -------------------------------------------------------------------------------- 1 | 3 -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # hMailServer IDS Viewer 2 | 3 | -------------------------------------------------------------------------------- /.gitattributes: -------------------------------------------------------------------------------- 1 | # Auto detect text files and perform LF normalization 2 | * text=auto 3 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # Ignore config file 2 | /config.php 3 | /test* 4 | 5 | # Ignoring directories 6 | # Both the directory itself and its contents will be ignored. 7 | uploads/ 8 | photos/ 9 | tmp/ 10 | examples/ -------------------------------------------------------------------------------- /header.php: -------------------------------------------------------------------------------- 1 |
2 | 3 | 6 | 9 | 10 |
11 | -------------------------------------------------------------------------------- /foot.php: -------------------------------------------------------------------------------- 1 | 2 |
3 | 13 | 14 | 15 | 16 | -------------------------------------------------------------------------------- /charthitsperhour.php: -------------------------------------------------------------------------------- 1 | 2 | 3 | 44 | -------------------------------------------------------------------------------- /chartcountriesperhour.php: -------------------------------------------------------------------------------- 1 | 2 | 3 | 44 | -------------------------------------------------------------------------------- /charthitsperday.php: -------------------------------------------------------------------------------- 1 | 2 | 3 | 45 | -------------------------------------------------------------------------------- /chartcountriesperday.php: -------------------------------------------------------------------------------- 1 | 2 | 3 | 45 | -------------------------------------------------------------------------------- /autocomplete.php: -------------------------------------------------------------------------------- 1 | prepare($count_sql_query); 13 | $count_sql->execute(); 14 | $count = $count_sql->fetchColumn(); 15 | 16 | $all_sql = $pdo->prepare("SELECT COUNT(*) FROM ".$Database['tablename']); 17 | $all_sql->execute(); 18 | $countall = $all_sql->fetchColumn(); 19 | 20 | if ($useGeoIP) { 21 | $finder_query = " 22 | SELECT DISTINCT(TRIM(BOTH '\"' FROM country)) AS result FROM ".$Database['tablename']." WHERE country LIKE '%".$search."%' 23 | UNION 24 | SELECT ipaddress AS result FROM ".$Database['tablename']." WHERE ipaddress LIKE '%".$search."%'"; 25 | } else { 26 | $finder_query = "SELECT ipaddress AS result FROM ".$Database['tablename']." WHERE ipaddress LIKE '%".$search."%'"; 27 | } 28 | $sql = $pdo->prepare($finder_query); 29 | $sql->execute(); 30 | 31 | $arr = array(); 32 | if (($count > 0) && ($count != $countall)) { 33 | while($row = $sql->fetch(PDO::FETCH_ASSOC)){ 34 | $data['value'] = $row['result']; 35 | array_push($arr, $data); 36 | } 37 | } 38 | echo json_encode($arr); 39 | ?> -------------------------------------------------------------------------------- /functions.php: -------------------------------------------------------------------------------- 1 | '; 17 | echo 'window.location.href="'.$url.'";'; 18 | echo ''; 19 | echo ''; exit; 22 | } 23 | } 24 | 25 | function allowedCountries() { 26 | global $allowedCountries,$countriesArray; 27 | include_once("countryarray.php"); 28 | 29 | $countryNameList[] = "^("; 30 | foreach ($allowedCountries as $countryCode) { 31 | $countryNameList[] = $countriesArray[$countryCode]."|"; 32 | } 33 | return preg_replace("/\|$/",")$",implode($countryNameList)); 34 | } 35 | 36 | function bannedCountries() { 37 | global $allowedCountries, $countriesArray; 38 | include_once("countryarray.php"); 39 | 40 | $countryNameList[] = "^(?!"; 41 | foreach ($allowedCountries as $countryCode) { 42 | $countryNameList[] = $countriesArray[$countryCode]."|"; 43 | } 44 | return preg_replace("/\|$/",").*$",implode($countryNameList)); 45 | } 46 | 47 | ?> 48 | -------------------------------------------------------------------------------- /dialtodayhits.php: -------------------------------------------------------------------------------- 1 | 67 | -------------------------------------------------------------------------------- /head.php: -------------------------------------------------------------------------------- 1 | 12 | 13 | 14 | 15 | 16 | hMailServer IDS 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 48 | 49 | 50 | 51 | 52 | 53 | 54 |
55 |
-------------------------------------------------------------------------------- /dialtodaycountryhits.php: -------------------------------------------------------------------------------- 1 | 67 | -------------------------------------------------------------------------------- /config.php.dist: -------------------------------------------------------------------------------- 1 | 'localhost', 30 | 'username' => 'hmailserver', 31 | 'password' => 'supersecretpassword', 32 | 'dbname' => 'hmailserver', 33 | 'tablename' => 'hm_ids', 34 | 'driver' => 'mysql', 35 | 'port' => '3306', 36 | 'dsn' => 'MariaDB ODBC 3.1 Driver' 37 | ); 38 | 39 | 40 | /* Pagination 41 | Number of records per page 42 | */ 43 | 44 | $no_of_records_per_page = 20; 45 | 46 | 47 | /* GeoIP 48 | 49 | *** $useGeoIP *** 50 | Bool switch to enable more dials, charts and stats if your IDS table also collects country 51 | name information. 52 | 53 | *** $countryColumnName *** 54 | The name of the db column containing geoip country name 55 | 56 | *** $allowedCountries *** 57 | List of countries allowed to connect to your hMailServer. If you do not block by geoip, then 58 | use your home country. This feature separates two dials for allowed and banned countries. At 59 | least one country is required!!! 60 | Check Alpha-2 Code here -> https://en.wikipedia.org/wiki/ISO_3166-1 61 | */ 62 | 63 | $useGeoIP = true; 64 | $countryColumnName = "country"; 65 | $allowedCountries = array('US','CA','AT','BE','CH','CZ','DE','DK','ES','FI','FR','GB','GL','GR','HR','HU','IE','IS','IT','LI','MC','NL','NO','PL','PT','RO','RS','SE','SI','SK','SM','AU','NZ','KR'); 66 | 67 | ?> -------------------------------------------------------------------------------- /dialtodaybannedhits.php: -------------------------------------------------------------------------------- 1 | 68 | -------------------------------------------------------------------------------- /dialtodayallowedhits.php: -------------------------------------------------------------------------------- 1 | 68 | -------------------------------------------------------------------------------- /login.php: -------------------------------------------------------------------------------- 1 | 31 | 32 | 33 | 34 | 35 | 36 | Log In 37 | 38 | 39 | 43 | 44 | 45 |
46 |

Log In

47 |
" method="post"> 48 |
49 | 50 | 51 |
52 |
53 | 54 | 55 |
56 |
57 | 58 | 59 |
60 |
61 | 62 |
63 |
64 | "; 67 | echo "alert('Username/Password Invalid');"; 68 | echo ""; 69 | } 70 | ?> 71 |
72 | 73 | -------------------------------------------------------------------------------- /stylesheet.css: -------------------------------------------------------------------------------- 1 | body { 2 | background: #fefefe; 3 | font-family: "Roboto"; 4 | font-size: 12pt; 5 | } 6 | 7 | .header { 8 | position: fixed; 9 | top: 0; 10 | left: 0; 11 | width: 100%; 12 | color: #000; 13 | background: #fefefe; 14 | z-index: 1; 15 | overflow: hidden; 16 | text-align:center; 17 | } 18 | 19 | .header h1 { 20 | font-size:25px; 21 | font-weight:normal; 22 | margin:0 auto; 23 | } 24 | 25 | .header h2 { 26 | font-size:15px; 27 | font-weight:normal; 28 | margin:0 auto; 29 | } 30 | 31 | .wrapper { 32 | max-width: 920px; 33 | position: relative; 34 | margin: 30px auto 30px auto; 35 | padding-top: 0px; 36 | } 37 | 38 | .clear { 39 | clear: both; 40 | } 41 | 42 | .banner { 43 | width: 100%; 44 | } 45 | 46 | .headlinks { 47 | max-width: 720px; 48 | min-width: 300px; 49 | position:relative; 50 | margin: 0px auto; 51 | } 52 | 53 | .headlinks a:link, a:active, a:visited { 54 | color: red; 55 | text-decoration: underline; 56 | } 57 | 58 | .headlinks a:hover { 59 | color: red; 60 | text-decoration: none; 61 | } 62 | 63 | .section { 64 | padding: 5px 0 15px 0; 65 | margin: 0; 66 | } 67 | 68 | .section a:link, a:visited { 69 | color: black; 70 | text-decoration: none; 71 | } 72 | 73 | .section a:hover, a:active { 74 | color: red; 75 | text-decoration: underline; 76 | } 77 | 78 | .section h2 { 79 | font-size:16px; 80 | font-weight:bold; 81 | text-align:left; 82 | } 83 | 84 | .section h3 { 85 | font-size:16px; 86 | font-weight:bold; 87 | } 88 | 89 | .secleft { 90 | float: left; 91 | width: 49%; 92 | padding-right: 3px; 93 | } 94 | 95 | .secright { 96 | float: right; 97 | width: 49%; 98 | padding-left: 3px; 99 | } 100 | 101 | table.section { 102 | border-collapse: collapse; 103 | border: 1px solid black; 104 | border-spacing: 10px; 105 | width: 100%; 106 | font-size: 10pt; 107 | } 108 | 109 | table.section tr:nth-child(even) { 110 | background-color: #F8F8F8; 111 | padding: 4px; 112 | } 113 | 114 | table.section th, table.section td { 115 | border: 1px solid black; 116 | padding: 4px; 117 | word-wrap: break-word; 118 | } 119 | 120 | .footer { 121 | width: 100%; 122 | text-align: center; 123 | font-size: 8pt; 124 | } 125 | 126 | .nav { 127 | font-size: 0.8em; 128 | } 129 | 130 | .nav a:link, a:active, a:visited { 131 | /* color: red; */ 132 | text-decoration: underline; 133 | } 134 | 135 | .nav a:hover { 136 | /* color: red; */ 137 | text-decoration: none; 138 | } 139 | 140 | ul { 141 | list-style-type: none; 142 | padding: 0; 143 | } 144 | 145 | li { 146 | padding: 0 3px 0 0; 147 | display: inline; 148 | } 149 | 150 | 151 | 152 | /* ### NEW TABLE CSS ### */ 153 | .div-table { 154 | display: table; 155 | width: 100%; 156 | font-size: 0.8em; 157 | border-left: 1px solid #ccc; 158 | border-bottom: 1px solid #ccc; 159 | } 160 | 161 | .div-table-row-header { 162 | display: table-row; 163 | font-weight: bold; 164 | text-align: center; 165 | } 166 | 167 | .div-table-row { 168 | display: table-row; 169 | } 170 | 171 | .div-table-row:nth-of-type(even) { 172 | background: #eee; 173 | border: 1px solid #ccc; 174 | } 175 | 176 | .center { 177 | text-align: center; 178 | } 179 | 180 | .div-table-col { 181 | display: table-cell; 182 | padding: 3px; 183 | border-right: 1px solid #ccc; 184 | border-top: 1px solid #ccc; 185 | } 186 | 187 | .mobile-bold { 188 | font-weight: normal; 189 | } 190 | 191 | form { 192 | display: inline-block; 193 | padding-left:0px; 194 | } 195 | 196 | @media only screen and (max-width: 629px) { 197 | .mobile-bold { 198 | font-weight: bold; 199 | } 200 | 201 | .secleft { 202 | float: none; 203 | width: 100%; 204 | padding: 0 0 10px 0; 205 | text-align: left; 206 | } 207 | .secright { 208 | float: none ; 209 | width: 100% ; 210 | } 211 | 212 | /* ### NEW TABLE CSS ### */ 213 | .div-table, .div-table-row-header, .div-table-row, .div-table-col { 214 | display: block; 215 | } 216 | 217 | .div-table { 218 | border: none; 219 | } 220 | 221 | /* Hide table headers (but not display: none;, for accessibility) */ 222 | .div-table-row-header { 223 | position: absolute; 224 | top: -9999px; 225 | left: -9999px; 226 | } 227 | 228 | .div-table-row { 229 | border: none; 230 | border-left: 1px solid #ccc; 231 | border-right: 1px solid #ccc; 232 | } 233 | 234 | .div-table-col { 235 | /* Behave like a "row" */ 236 | border: none; 237 | border-bottom: 1px solid #e6e6e6; 238 | position: relative; 239 | padding-left: 25%; 240 | text-align: left; 241 | white-space: pre; /* CSS 2.0 */ 242 | white-space: pre-wrap; /* CSS 2.1 */ 243 | white-space: pre-line; /* CSS 3.0 */ 244 | white-space: -pre-wrap; /* Opera 4-6 */ 245 | white-space: -o-pre-wrap; /* Opera 7 */ 246 | white-space: -moz-pre-wrap; /* Mozilla */ 247 | white-space: -hp-pre-wrap; /* HP Printers */ 248 | word-wrap: break-word; /* IE 5+ */ 249 | } 250 | 251 | .div-table-col:before { 252 | /* Now like a table header */ 253 | border: none; 254 | position: absolute; 255 | top: 3px; 256 | left: 6px; 257 | padding-right: 10px; 258 | /* Label the data */ 259 | content: attr(data-column); 260 | color: #000; 261 | font-weight: bold; 262 | } 263 | 264 | } 265 | -------------------------------------------------------------------------------- /viewcountry.php: -------------------------------------------------------------------------------- 1 | 2 | 3 | "; 20 | $search_page = "&search=".$search; 21 | } else { 22 | $search = ""; 23 | $search_SQL = ""; 24 | $search_ph = ""; 25 | $search_hidden = ""; 26 | $search_page = ""; 27 | } 28 | if (isset($_GET['clear'])) { 29 | header("Location: viewcountry.php"); 30 | } 31 | 32 | if (isset($_GET['sort1'])) { 33 | $sort1_val = $_GET['sort1']; 34 | $sort1_page = "&sort1=".$sort1_val; 35 | $sort1_hidden = ""; 36 | if ($_GET['sort1'] == "hitsasc") {$sort1_sql = "sumhits ASC"; $sort1_ph = "↑ Hits";} 37 | else if ($_GET['sort1'] == "hitsdesc") {$sort1_sql = "sumhits DESC"; $sort1_ph = "↓ Hits";} 38 | else if ($_GET['sort1'] == "newest") {$sort1_sql = "maxts ASC"; $sort1_ph = "↑ Date";} 39 | else if ($_GET['sort1'] == "oldest") {$sort1_sql = "maxts DESC"; $sort1_ph = "↓ Date";} 40 | else if ($_GET['sort1'] == "countryasc") {$sort1_sql = "trimcountry ASC"; $sort1_ph = "↑ Country";} 41 | else if ($_GET['sort1'] == "countrydesc") {$sort1_sql = "trimcountry DESC"; $sort1_ph = "↓ Country";} 42 | else {unset($_GET['sort1']); $sort1_sql = ""; $sort1_ph = "Sort";} 43 | } else { 44 | $sort1_val = ""; 45 | $sort1_sql = ""; 46 | $sort1_ph = "Sort"; 47 | $sort1_page = ""; 48 | $sort1_hidden = ""; 49 | } 50 | if ((isset($_GET['sort1'])) || (isset($_GET['sort2']))) { 51 | $orderby = "ORDER BY "; 52 | } else { 53 | $orderby = "ORDER BY trimcountry ASC"; 54 | } 55 | 56 | 57 | echo " 58 |
59 |
60 |
61 | 70 | ".$search_hidden." 71 |
"; 72 | 73 | echo " 74 |

75 | 76 | 77 | 78 | ".$sort1_hidden." 79 |
80 |
81 |
82 | 83 |
"; 84 | 85 | 86 | $offset = ($page-1) * $no_of_records_per_page; 87 | 88 | $total_pages_sql = $pdo->prepare(" 89 | SELECT COUNT(DISTINCT(TRIM(BOTH '\"' FROM ".$countryColumnName."))) AS count 90 | FROM ".$Database['tablename']." 91 | ".$search_SQL." 92 | "); 93 | $total_pages_sql->execute(); 94 | $total_rows = $total_pages_sql->fetchColumn(); 95 | $total_pages = ceil($total_rows / $no_of_records_per_page); 96 | 97 | $sql = $pdo->prepare(" 98 | SELECT 99 | TRIM(BOTH '\"' FROM ".$countryColumnName.") AS trimcountry, 100 | SUM(hits) AS sumhits, 101 | MAX(timestamp) AS maxts 102 | FROM ".$Database['tablename']." 103 | ".$search_SQL." 104 | GROUP BY trimcountry 105 | ".$orderby.$sort1_sql." 106 | LIMIT ".$offset.", ".$no_of_records_per_page 107 | ); 108 | $sql->execute(); 109 | 110 | if ($search==""){ 111 | $search_res=""; 112 | } else { 113 | $search_res=" for \"".$search."\""; 114 | } 115 | 116 | if ($total_pages < 2){ 117 | $pagination = ""; 118 | } else { 119 | $pagination = "(Page: ".number_format($page)." of ".number_format($total_pages).")"; 120 | } 121 | 122 | if ($total_rows == 1){$singular = '';} else {$singular= 's';} 123 | if ($total_rows == 0){ 124 | if ($search == "" && $sort1_val == ""){ 125 | echo "Please enter a search term"; 126 | } else { 127 | echo "No results ".$search_res; 128 | } 129 | } else { 130 | echo " 131 | Results ".$search_res.": ".number_format($total_rows)." Record".$singular." ".$pagination."
132 |
133 |
134 |
Country
135 |
Hits
136 |
Last
137 |
"; 138 | 139 | while($row = $sql->fetch(PDO::FETCH_ASSOC)){ 140 | echo " 141 |
142 |
".$row['trimcountry']."
143 |
".number_format($row['sumhits'])."
144 |
".date("y/m/d H:i:s", strtotime($row['maxts']))."
145 |
"; 146 | } 147 | echo " 148 |
"; // End table 149 | 150 | if ($total_pages == 1){ 151 | echo ""; 152 | } else { 153 | echo " 154 | 155 |
    156 | "; 157 | if($page <= 1){echo "
  • First
  • ";} else {echo "
  • First
  • ";} 158 | if($page <= 1){echo "
  • Prev
  • ";} else {echo "
  • Prev
  • ";} 159 | if($page >= $total_pages){echo "
  • Next
  • ";} else {echo "
  • Next
  • ";} 160 | if($page >= $total_pages){echo "
  • Last
  • ";} else {echo "
  • Last
  • ";} 161 | echo " 162 |
163 |
"; 164 | } 165 | } 166 | 167 | // JS autocomplete 168 | echo " 169 | "; 180 | 181 | ?> 182 | 183 |
184 | 185 | -------------------------------------------------------------------------------- /countryarray.php: -------------------------------------------------------------------------------- 1 | '"Åland"', 5 | 'AS' => '"American Samoa"', 6 | 'AG' => '"Antigua and Barbuda"', 7 | 'BQ' => '"Bonaire', 8 | 'BA' => '"Bosnia and Herzegovina"', 9 | 'BV' => '"Bouvet Island"', 10 | 'IO' => '"British Indian Ocean Territory"', 11 | 'VG' => '"British Virgin Islands"', 12 | 'BF' => '"Burkina Faso"', 13 | 'CV' => '"Cabo Verde"', 14 | 'KY' => '"Cayman Islands"', 15 | 'CF' => '"Central African Republic"', 16 | 'CX' => '"Christmas Island"', 17 | 'CC' => '"Cocos (Keeling) Islands"', 18 | 'CG' => '"Congo Republic"', 19 | 'CK' => '"Cook Islands"', 20 | 'CR' => '"Costa Rica"', 21 | 'DO' => '"Dominican Republic"', 22 | 'CD' => '"DR Congo"', 23 | 'SV' => '"El Salvador"', 24 | 'GQ' => '"Equatorial Guinea"', 25 | 'FK' => '"Falkland Islands"', 26 | 'FO' => '"Faroe Islands"', 27 | 'FM' => '"Federated States of Micronesia"', 28 | 'GF' => '"French Guiana"', 29 | 'PF' => '"French Polynesia"', 30 | 'TF' => '"French Southern Territories"', 31 | 'HM' => '"Heard and McDonald Islands"', 32 | 'HK' => '"Hong Kong"', 33 | 'IM' => '"Isle of Man"', 34 | 'CI' => '"Ivory Coast"', 35 | 'MH' => '"Marshall Islands"', 36 | 'NC' => '"New Caledonia"', 37 | 'NZ' => '"New Zealand"', 38 | 'NF' => '"Norfolk Island"', 39 | 'KP' => '"North Korea"', 40 | 'MK' => '"North Macedonia"', 41 | 'MP' => '"Northern Mariana Islands"', 42 | 'PG' => '"Papua New Guinea"', 43 | 'PN' => '"Pitcairn Islands"', 44 | 'PR' => '"Puerto Rico"', 45 | 'BL' => '"Saint Barthélemy"', 46 | 'SH' => '"Saint Helena"', 47 | 'LC' => '"Saint Lucia"', 48 | 'MF' => '"Saint Martin"', 49 | 'PM' => '"Saint Pierre and Miquelon"', 50 | 'SM' => '"San Marino"', 51 | 'ST' => '"São Tomé and Príncipe"', 52 | 'SA' => '"Saudi Arabia"', 53 | 'SL' => '"Sierra Leone"', 54 | 'SX' => '"Sint Maarten"', 55 | 'SB' => '"Solomon Islands"', 56 | 'ZA' => '"South Africa"', 57 | 'GS' => '"South Georgia and the South Sandwich Islands"', 58 | 'KR' => '"South Korea"', 59 | 'SS' => '"South Sudan"', 60 | 'LK' => '"Sri Lanka"', 61 | 'KN' => '"St Kitts and Nevis"', 62 | 'VC' => '"St Vincent and Grenadines"', 63 | 'SJ' => '"Svalbard and Jan Mayen"', 64 | 'TT' => '"Trinidad and Tobago"', 65 | 'TC' => '"Turks and Caicos Islands"', 66 | 'UM' => '"U.S. Outlying Islands"', 67 | 'VI' => '"U.S. Virgin Islands"', 68 | 'AE' => '"United Arab Emirates"', 69 | 'GB' => '"United Kingdom"', 70 | 'US' => '"United States"', 71 | 'VA' => '"Vatican City"', 72 | 'WF' => '"Wallis and Futuna"', 73 | 'EH' => '"Western Sahara"', 74 | 'AF' => 'Afghanistan', 75 | 'AL' => 'Albania', 76 | 'DZ' => 'Algeria', 77 | 'AD' => 'Andorra', 78 | 'AO' => 'Angola', 79 | 'AI' => 'Anguilla', 80 | 'AQ' => 'Antarctica', 81 | 'AR' => 'Argentina', 82 | 'AM' => 'Armenia', 83 | 'AW' => 'Aruba', 84 | 'AU' => 'Australia', 85 | 'AT' => 'Austria', 86 | 'AZ' => 'Azerbaijan', 87 | 'BS' => 'Bahamas', 88 | 'BH' => 'Bahrain', 89 | 'BD' => 'Bangladesh', 90 | 'BB' => 'Barbados', 91 | 'BY' => 'Belarus', 92 | 'BE' => 'Belgium', 93 | 'BZ' => 'Belize', 94 | 'BJ' => 'Benin', 95 | 'BM' => 'Bermuda', 96 | 'BT' => 'Bhutan', 97 | 'BO' => 'Bolivia', 98 | 'BW' => 'Botswana', 99 | 'BR' => 'Brazil', 100 | 'BN' => 'Brunei', 101 | 'BG' => 'Bulgaria', 102 | 'BI' => 'Burundi', 103 | 'KH' => 'Cambodia', 104 | 'CM' => 'Cameroon', 105 | 'CA' => 'Canada', 106 | 'TD' => 'Chad', 107 | 'CL' => 'Chile', 108 | 'CN' => 'China', 109 | 'CO' => 'Colombia', 110 | 'KM' => 'Comoros', 111 | 'HR' => 'Croatia', 112 | 'CU' => 'Cuba', 113 | 'CW' => 'Curaçao', 114 | 'CY' => 'Cyprus', 115 | 'CZ' => 'Czechia', 116 | 'DK' => 'Denmark', 117 | 'DJ' => 'Djibouti', 118 | 'DM' => 'Dominica', 119 | 'EC' => 'Ecuador', 120 | 'EG' => 'Egypt', 121 | 'ER' => 'Eritrea', 122 | 'EE' => 'Estonia', 123 | 'SZ' => 'Eswatini', 124 | 'ET' => 'Ethiopia', 125 | 'FJ' => 'Fiji', 126 | 'FI' => 'Finland', 127 | 'FR' => 'France', 128 | 'GA' => 'Gabon', 129 | 'GM' => 'Gambia', 130 | 'GE' => 'Georgia', 131 | 'DE' => 'Germany', 132 | 'GH' => 'Ghana', 133 | 'GI' => 'Gibraltar', 134 | 'GR' => 'Greece', 135 | 'GL' => 'Greenland', 136 | 'GD' => 'Grenada', 137 | 'GP' => 'Guadeloupe', 138 | 'GU' => 'Guam', 139 | 'GT' => 'Guatemala', 140 | 'GG' => 'Guernsey', 141 | 'GN' => 'Guinea', 142 | 'GW' => 'Guinea-Bissau', 143 | 'GY' => 'Guyana', 144 | 'HT' => 'Haiti', 145 | 'HN' => 'Honduras', 146 | 'HU' => 'Hungary', 147 | 'IS' => 'Iceland', 148 | 'IN' => 'India', 149 | 'ID' => 'Indonesia', 150 | 'IR' => 'Iran', 151 | 'IQ' => 'Iraq', 152 | 'IE' => 'Ireland', 153 | 'IL' => 'Israel', 154 | 'IT' => 'Italy', 155 | 'JM' => 'Jamaica', 156 | 'JP' => 'Japan', 157 | 'JE' => 'Jersey', 158 | 'JO' => 'Jordan', 159 | 'KZ' => 'Kazakhstan', 160 | 'KE' => 'Kenya', 161 | 'KI' => 'Kiribati', 162 | 'XK' => 'Kosovo', 163 | 'KW' => 'Kuwait', 164 | 'KG' => 'Kyrgyzstan', 165 | 'LA' => 'Laos', 166 | 'LV' => 'Latvia', 167 | 'LB' => 'Lebanon', 168 | 'LS' => 'Lesotho', 169 | 'LR' => 'Liberia', 170 | 'LY' => 'Libya', 171 | 'LI' => 'Liechtenstein', 172 | 'LT' => 'Lithuania', 173 | 'LU' => 'Luxembourg', 174 | 'MO' => 'Macao', 175 | 'MG' => 'Madagascar', 176 | 'MW' => 'Malawi', 177 | 'MY' => 'Malaysia', 178 | 'MV' => 'Maldives', 179 | 'ML' => 'Mali', 180 | 'MT' => 'Malta', 181 | 'MQ' => 'Martinique', 182 | 'MR' => 'Mauritania', 183 | 'MU' => 'Mauritius', 184 | 'YT' => 'Mayotte', 185 | 'MX' => 'Mexico', 186 | 'MD' => 'Moldova', 187 | 'MC' => 'Monaco', 188 | 'MN' => 'Mongolia', 189 | 'ME' => 'Montenegro', 190 | 'MS' => 'Montserrat', 191 | 'MA' => 'Morocco', 192 | 'MZ' => 'Mozambique', 193 | 'MM' => 'Myanmar', 194 | 'NA' => 'Namibia', 195 | 'NR' => 'Nauru', 196 | 'NP' => 'Nepal', 197 | 'NL' => 'Netherlands', 198 | 'NI' => 'Nicaragua', 199 | 'NE' => 'Niger', 200 | 'NG' => 'Nigeria', 201 | 'NU' => 'Niue', 202 | 'NO' => 'Norway', 203 | 'OM' => 'Oman', 204 | 'PK' => 'Pakistan', 205 | 'PW' => 'Palau', 206 | 'PS' => 'Palestine', 207 | 'PA' => 'Panama', 208 | 'PY' => 'Paraguay', 209 | 'PE' => 'Peru', 210 | 'PH' => 'Philippines', 211 | 'PL' => 'Poland', 212 | 'PT' => 'Portugal', 213 | 'QA' => 'Qatar', 214 | 'RE' => 'Réunion', 215 | 'RO' => 'Romania', 216 | 'RU' => 'Russia', 217 | 'RW' => 'Rwanda', 218 | 'WS' => 'Samoa', 219 | 'SN' => 'Senegal', 220 | 'RS' => 'Serbia', 221 | 'SC' => 'Seychelles', 222 | 'SG' => 'Singapore', 223 | 'SK' => 'Slovakia', 224 | 'SI' => 'Slovenia', 225 | 'SO' => 'Somalia', 226 | 'ES' => 'Spain', 227 | 'SD' => 'Sudan', 228 | 'SR' => 'Suriname', 229 | 'SE' => 'Sweden', 230 | 'CH' => 'Switzerland', 231 | 'SY' => 'Syria', 232 | 'TW' => 'Taiwan', 233 | 'TJ' => 'Tajikistan', 234 | 'TZ' => 'Tanzania', 235 | 'TH' => 'Thailand', 236 | 'TL' => 'Timor-Leste', 237 | 'TG' => 'Togo', 238 | 'TK' => 'Tokelau', 239 | 'TO' => 'Tonga', 240 | 'TN' => 'Tunisia', 241 | 'TR' => 'Turkey', 242 | 'TM' => 'Turkmenistan', 243 | 'TV' => 'Tuvalu', 244 | 'UG' => 'Uganda', 245 | 'UA' => 'Ukraine', 246 | 'UY' => 'Uruguay', 247 | 'UZ' => 'Uzbekistan', 248 | 'VU' => 'Vanuatu', 249 | 'VE' => 'Venezuela', 250 | 'VN' => 'Vietnam', 251 | 'YE' => 'Yemen', 252 | 'ZM' => 'Zambia', 253 | 'ZW' => 'Zimbabwe' 254 | ); 255 | 256 | ?> -------------------------------------------------------------------------------- /index.php: -------------------------------------------------------------------------------- 1 | 2 | 3 | 12 |
13 |

Today's Activity:

14 |
15 |
16 |
17 |
18 | IPs Added:
19 | Banned Countries 20 |
21 |
22 |
23 |
24 |
25 | IPs Added:
26 | Allowed Countries 27 |
28 |
29 |
30 |
31 | 32 |
33 |
34 |
35 | Countries Added 36 |
37 |
38 |
39 |
40 | "; 41 | } else { 42 | echo " 43 | 44 |
45 |

Today's Activity:

46 |
47 |
48 |
49 | IPs Added 50 |
51 |
52 |
53 | "; 54 | } 55 | 56 | 57 | if ($useGeoIP) { 58 | echo " 59 | 60 |
61 |
62 |

Last hits per day:

63 |
64 |
65 |
66 |

Last hits per day by country:

67 |
68 |
69 |
70 |
71 | 72 |
73 |
74 |

Last hits averaged per hour:

75 |
76 |
77 |
78 |

Last hits by country averaged per hour:

79 |
80 |
81 |
82 |
83 | "; 84 | 85 | } else { 86 | echo " 87 | 88 |
89 |
90 |

Last hits per day:

91 |
92 |
93 |
94 |

Last hits averaged per hour:

95 |
96 |
97 |
98 |
99 | "; 100 | } 101 | 102 | 103 | // TABLES 104 | 105 | echo " 106 |
107 | 108 |
109 |

Top 10 IPs:

"; 110 | 111 | $sql_total = $pdo->prepare("SELECT SUM(HITS) FROM ".$Database['tablename']); 112 | $sql_total->execute(); 113 | $all_rows = $sql_total->fetchColumn(); 114 | 115 | $useGeoIPsql = " 116 | SELECT 117 | TRIM(BOTH '\"' FROM ".$countryColumnName.") AS trimcountry, 118 | hits, 119 | ipaddress 120 | FROM ".$Database['tablename']." 121 | ORDER BY hits DESC 122 | LIMIT 10"; 123 | 124 | $noGeoIPsql = " 125 | SELECT * 126 | FROM ".$Database['tablename']." 127 | ORDER BY hits DESC 128 | LIMIT 10"; 129 | 130 | if ($useGeoIP) { 131 | $sql = $pdo->prepare($useGeoIPsql); 132 | } else { 133 | $sql = $pdo->prepare($noGeoIPsql); 134 | } 135 | $sql->execute(); 136 | echo " 137 |
138 |
139 |
IP Address
"; 140 | if ($useGeoIP) { 141 | echo" 142 |
Country
"; 143 | } 144 | echo " 145 |
Hits
146 |
Percent
147 |
"; 148 | while($row = $sql->fetch(PDO::FETCH_ASSOC)){ 149 | echo " 150 |
151 | "; 152 | if ($useGeoIP) { 153 | echo" 154 |
".$row['trimcountry']."
"; 155 | } 156 | echo " 157 |
".number_format($row['hits'])."
158 |
".round(($row['hits'] / $all_rows * 100),2)."%
159 |
"; 160 | } 161 | echo " 162 |
163 |
164 |
165 | "; 166 | 167 | if ($useGeoIP) { 168 | echo " 169 | 170 |
171 |

Top 10 countries:

"; 172 | 173 | $sql_total = $pdo->prepare("SELECT SUM(hits) FROM ".$Database['tablename']); 174 | $sql_total->execute(); 175 | $all_hits = $sql_total->fetchColumn(); 176 | 177 | $sql = $pdo->prepare(" 178 | SELECT 179 | TRIM(BOTH '\"' FROM ".$countryColumnName.") AS trimcountry, 180 | SUM(hits) AS sumhits 181 | FROM ".$Database['tablename']." 182 | GROUP BY ".$countryColumnName." 183 | ORDER BY sumhits DESC 184 | LIMIT 10 185 | "); 186 | $sql->execute(); 187 | echo " 188 |
189 |
190 |
Country
191 |
Hits
192 |
Percent
193 |
"; 194 | while($row = $sql->fetch(PDO::FETCH_ASSOC)){ 195 | echo " 196 |
197 | 198 |
".number_format($row['sumhits'])."
199 |
".round(($row['sumhits'] / $all_hits * 100),2)."%
200 |
"; 201 | } 202 | echo " 203 |
204 |
205 |
206 | "; 207 | } else { 208 | echo " 209 | 210 |
211 |

Last 10 IPs:

"; 212 | 213 | $sql_total = $pdo->prepare("SELECT count(*) FROM ".$Database['tablename']); 214 | $sql_total->execute(); 215 | $all_rows = $sql_total->fetchColumn(); 216 | 217 | $sql = $pdo->prepare(" 218 | SELECT * 219 | FROM ".$Database['tablename']." 220 | ORDER BY timestamp DESC 221 | LIMIT 10 222 | "); 223 | $sql->execute(); 224 | echo " 225 |
226 |
227 |
IP Address
228 |
Hits
229 |
Last
230 |
"; 231 | while($row = $sql->fetch(PDO::FETCH_ASSOC)){ 232 | echo " 233 |
234 | 235 |
".number_format($row['hits'])."
236 |
".date("y/m/d H:i:s", strtotime($row['timestamp']))."
237 |
"; 238 | } 239 | echo " 240 |
241 |
242 |
243 | "; 244 | } 245 | 246 | echo " 247 |
248 |
"; 249 | 250 | ?> 251 | 252 | -------------------------------------------------------------------------------- /viewall.php: -------------------------------------------------------------------------------- 1 | 2 | 3 | "; 20 | $search_page = "&search=".$search; 21 | } else { 22 | $search = ""; 23 | $search_SQL = ""; 24 | $search_ph = ""; 25 | $search_hidden = ""; 26 | $search_page = ""; 27 | } 28 | if (isset($_GET['clear'])) { 29 | redirect("viewall.php"); 30 | } 31 | 32 | if (isset($_GET['sort1'])) { 33 | $sort1_val = $_GET['sort1']; 34 | $sort1_page = "&sort1=".$sort1_val; 35 | $sort1_hidden = ""; 36 | if ($_GET['sort1'] == "hitsasc") {$sort1_sql = "hits ASC"; $sort1_ph = "↑ Hits";} 37 | else if ($_GET['sort1'] == "hitsdesc") {$sort1_sql = "hits DESC"; $sort1_ph = "↓ Hits";} 38 | else if ($_GET['sort1'] == "newest") {$sort1_sql = "DATE(timestamp) ASC"; $sort1_ph = "↑ Date";} 39 | else if ($_GET['sort1'] == "oldest") {$sort1_sql = "DATE(timestamp) DESC"; $sort1_ph = "↓ Date";} 40 | else if ($_GET['sort1'] == "countryasc") {$sort1_sql = "trimcountry ASC"; $sort1_ph = "↑ Country";} 41 | else if ($_GET['sort1'] == "countrydesc") {$sort1_sql = "trimcountry DESC"; $sort1_ph = "↓ Country";} 42 | else if ($_GET['sort1'] == "ipasc") {$sort1_sql = "INET_ATON(ipaddress) ASC"; $sort1_ph = "↑ IP";} 43 | else if ($_GET['sort1'] == "ipdesc") {$sort1_sql = "INET_ATON(ipaddress) DESC"; $sort1_ph = "↓ IP";} 44 | else {unset($_GET['sort1']); $sort1_sql = ""; $sort1_ph = "Sort";} 45 | } else { 46 | $sort1_val = ""; 47 | $sort1_sql = ""; 48 | $sort1_ph = "Sort"; 49 | $sort1_page = ""; 50 | $sort1_hidden = ""; 51 | } 52 | if (isset($_GET['sort2'])) { 53 | $sort2_val = $_GET['sort2']; 54 | $sort2_page = "&sort2=".$sort2_val; 55 | $sort2_hidden = ""; 56 | if ($_GET['sort2'] == "hitsasc") {$sort2_sql = ", hits ASC"; $sort2_ph = "↑ Hits";} 57 | else if ($_GET['sort2'] == "hitsdesc") {$sort2_sql = ", hits DESC"; $sort2_ph = "↓ Hits";} 58 | else if ($_GET['sort2'] == "newest") {$sort2_sql = ", timestamp ASC"; $sort2_ph = "↑ Date";} 59 | else if ($_GET['sort2'] == "oldest") {$sort2_sql = ", timestamp DESC"; $sort2_ph = "↓ Date";} 60 | else if ($_GET['sort2'] == "countryasc") {$sort2_sql = ", trimcountry ASC"; $sort2_ph = "↑ Country";} 61 | else if ($_GET['sort2'] == "countrydesc") {$sort2_sql = ", trimcountry DESC"; $sort2_ph = "↓ Country";} 62 | else if ($_GET['sort2'] == "ipasc") {$sort2_sql = ", INET_ATON(ipaddress) ASC"; $sort2_ph = "↑ IP";} 63 | else if ($_GET['sort2'] == "ipdesc") {$sort2_sql = ", INET_ATON(ipaddress) DESC"; $sort2_ph = "↓ IP";} 64 | else {unset($_GET['sort2']); $sort2_sql = ""; $sort2_ph = "Sort";} 65 | } else { 66 | $sort2_val = ""; 67 | $sort2_sql = ""; 68 | $sort2_ph = "Sort"; 69 | $sort2_page = ""; 70 | $sort2_hidden = ""; 71 | } 72 | if ((isset($_GET['sort1'])) || (isset($_GET['sort2']))) { 73 | $orderby = "ORDER BY "; 74 | } else { 75 | $orderby = "ORDER BY timestamp DESC"; 76 | } 77 | 78 | echo " 79 |
80 |
81 |
82 | 97 | ".$search_hidden." 98 |
"; 99 | 100 | if (isset($_GET['sort1'])) { 101 | echo " 102 |
103 | 118 | ".$search_hidden.$sort1_hidden." 119 |
"; 120 | } 121 | if ($useGeoIP) {$placeholder = "Search Country or IP...";} else {$placeholder = "Search IP...";} 122 | echo " 123 |

124 | 125 | 126 | 127 | ".$sort1_hidden.$sort2_hidden." 128 |
129 |
130 |
131 | 132 |
"; 133 | 134 | 135 | $offset = ($page-1) * $no_of_records_per_page; 136 | 137 | $total_pages_sql = $pdo->prepare(" 138 | SELECT Count( * ) AS count 139 | FROM ".$Database['tablename']." 140 | ".$search_SQL." 141 | "); 142 | $total_pages_sql->execute(); 143 | $total_rows = $total_pages_sql->fetchColumn(); 144 | $total_pages = ceil($total_rows / $no_of_records_per_page); 145 | 146 | if ($useGeoIP) { 147 | $sql_query = " 148 | SELECT 149 | TRIM(BOTH '\"' FROM ".$countryColumnName.") AS trimcountry, 150 | ".$countryColumnName.", 151 | ipaddress, 152 | timestamp, 153 | hits 154 | FROM ".$Database['tablename']." 155 | ".$search_SQL." 156 | ".$orderby.$sort1_sql.$sort2_sql." 157 | LIMIT ".$offset.", ".$no_of_records_per_page; 158 | } else { 159 | $sql_query = " 160 | SELECT * 161 | FROM ".$Database['tablename']." 162 | ".$search_SQL." 163 | ".$orderby.$sort1_sql.$sort2_sql." 164 | LIMIT ".$offset.", ".$no_of_records_per_page; 165 | } 166 | $sql = $pdo->prepare($sql_query); 167 | $sql->execute(); 168 | 169 | if ($search==""){ 170 | $search_res=""; 171 | } else { 172 | $search_res=" for \"".$search."\""; 173 | } 174 | 175 | if ($total_pages < 2){ 176 | $pagination = ""; 177 | } else { 178 | $pagination = "(Page: ".number_format($page)." of ".number_format($total_pages).")"; 179 | } 180 | 181 | if ($total_rows == 1){$singular = '';} else {$singular= 's';} 182 | if ($total_rows == 0){ 183 | if ($search == "" && $sort1_val == "" && $sort2_val == ""){ 184 | echo "Please enter a search term"; 185 | } else { 186 | echo "No results ".$search_res; 187 | } 188 | } else { 189 | echo " 190 | Results ".$search_res.": ".number_format($total_rows)." Record".$singular." ".$pagination."
191 |
192 |
193 |
IP Address
194 |
Hits
195 |
Last
"; 196 | if ($useGeoIP) { 197 | echo " 198 |
Country
"; 199 | } 200 | echo " 201 |
"; 202 | 203 | while($row = $sql->fetch(PDO::FETCH_ASSOC)){ 204 | echo " 205 |
206 |
".$row['ipaddress']."
207 |
".number_format($row['hits'])."
208 |
".date("y/m/d H:i:s", strtotime($row['timestamp']))."
"; 209 | if ($useGeoIP) { 210 | echo " 211 |
".$row['trimcountry']."
"; 212 | } 213 | echo " 214 |
"; 215 | } 216 | echo " 217 |
"; // End table 218 | 219 | if ($total_pages == 1){ 220 | echo ""; 221 | } else { 222 | echo " 223 | 224 |
    225 | "; 226 | if($page <= 1){echo "
  • First
  • ";} else {echo "
  • First
  • ";} 227 | if($page <= 1){echo "
  • Prev
  • ";} else {echo "
  • Prev
  • ";} 228 | if($page >= $total_pages){echo "
  • Next
  • ";} else {echo "
  • Next
  • ";} 229 | if($page >= $total_pages){echo "
  • Last
  • ";} else {echo "
  • Last
  • ";} 230 | echo " 231 |
232 |
"; 233 | } 234 | } 235 | 236 | // JS autocomplete 237 | echo " 238 | "; 249 | 250 | ?> 251 | 252 |
253 | 254 | --------------------------------------------------------------------------------