Skip to content

Commit 6e91219

Browse files
author
AKokarev
committed
Файл настроек
- Все настройки вынесены в config.php - В точках входа поставлены include 'config.php'
1 parent 6fa5b3c commit 6e91219

9 files changed

+109
-95
lines changed

3wifi.php

+21-30
Original file line numberDiff line numberDiff line change
@@ -5,21 +5,12 @@
55
Header('Location: /');
66
exit;
77
}
8+
include 'config.php';
89
require_once 'user.class.php';
910
require_once 'utils.php';
1011
require_once 'db.php';
1112
require_once 'quadkey.php';
1213

13-
$topPort = 30;
14-
$topauth = 100;
15-
$topname = 30;
16-
$topbssid = 30;
17-
$topessid = 30;
18-
$topSecurity = 30;
19-
$topWiFiKey = 30;
20-
$topWPSPIN = 30;
21-
$topDNS = 30;
22-
$topSid = 10;
2314

2415
$action = $_GET['a'];
2516

@@ -1127,7 +1118,7 @@ function highlightWords($text, array $words)
11271118
case 'stdev':
11281119
set_time_limit(30);
11291120
$json['result'] = true;
1130-
$json['stat']['top'] = $topname;
1121+
$json['stat']['top'] = TOP_NAME;
11311122
if (!db_connect())
11321123
{
11331124
$json['result'] = false;
@@ -1140,7 +1131,7 @@ function highlightWords($text, array $words)
11401131
$json['stat']['total'] = (int)$row[0];
11411132
$res->close();
11421133
}
1143-
if ($res = QuerySql("SELECT `name`, COUNT(name) FROM BASE_TABLE WHERE `name` != '' GROUP BY `name` ORDER BY COUNT(name) DESC LIMIT $topname"))
1134+
if ($res = QuerySql("SELECT `name`, COUNT(name) FROM BASE_TABLE WHERE `name` != '' GROUP BY `name` ORDER BY COUNT(name) DESC LIMIT ".TOP_NAME))
11441135
{
11451136
$json['stat']['data'] = array();
11461137
while ($row = $res->fetch_row())
@@ -1159,7 +1150,7 @@ function highlightWords($text, array $words)
11591150
case 'stport':
11601151
set_time_limit(30);
11611152
$json['result'] = true;
1162-
$json['stat']['top'] = $topPort;
1153+
$json['stat']['top'] = TOP_PORT;
11631154
if (!db_connect())
11641155
{
11651156
$json['result'] = false;
@@ -1172,7 +1163,7 @@ function highlightWords($text, array $words)
11721163
$json['stat']['total'] = (int)$row[0];
11731164
$res->close();
11741165
}
1175-
if ($res = QuerySql("SELECT `Port`, COUNT(Port) FROM BASE_TABLE WHERE NOT(`Port` IS NULL) GROUP BY `Port` ORDER BY COUNT(Port) DESC LIMIT $topPort"))
1166+
if ($res = QuerySql("SELECT `Port`, COUNT(Port) FROM BASE_TABLE WHERE NOT(`Port` IS NULL) GROUP BY `Port` ORDER BY COUNT(Port) DESC LIMIT ".TOP_PORT))
11761167
{
11771168
$json['stat']['data'] = array();
11781169
while ($row = $res->fetch_row())
@@ -1191,7 +1182,7 @@ function highlightWords($text, array $words)
11911182
case 'stauth':
11921183
set_time_limit(30);
11931184
$json['result'] = true;
1194-
$json['stat']['top'] = $topauth;
1185+
$json['stat']['top'] = TOP_AUTH;
11951186
if (!db_connect())
11961187
{
11971188
$json['result'] = false;
@@ -1204,7 +1195,7 @@ function highlightWords($text, array $words)
12041195
$json['stat']['total'] = (int)$row[0];
12051196
$res->close();
12061197
}
1207-
if ($res = QuerySql("SELECT `Authorization`, COUNT(Authorization) FROM BASE_TABLE WHERE `Authorization`!='' GROUP BY `Authorization` ORDER BY COUNT(Authorization) DESC LIMIT $topauth"))
1198+
if ($res = QuerySql("SELECT `Authorization`, COUNT(Authorization) FROM BASE_TABLE WHERE `Authorization`!='' GROUP BY `Authorization` ORDER BY COUNT(Authorization) DESC LIMIT ".TOP_AUTH))
12081199
{
12091200
$json['stat']['data'] = array();
12101201
while ($row = $res->fetch_row())
@@ -1223,7 +1214,7 @@ function highlightWords($text, array $words)
12231214
case 'stbss':
12241215
set_time_limit(30);
12251216
$json['result'] = true;
1226-
$json['stat']['top'] = $topbssid;
1217+
$json['stat']['top'] = TOP_BSSID;
12271218
if (!db_connect())
12281219
{
12291220
$json['result'] = false;
@@ -1236,7 +1227,7 @@ function highlightWords($text, array $words)
12361227
$json['stat']['total'] = (int)$row[0];
12371228
$res->close();
12381229
}
1239-
if ($res = QuerySql("SELECT `BSSID`, COUNT(BSSID) FROM BASE_TABLE WHERE `NoBSSID`=0 GROUP BY `BSSID` ORDER BY COUNT(BSSID) DESC LIMIT $topbssid"))
1230+
if ($res = QuerySql("SELECT `BSSID`, COUNT(BSSID) FROM BASE_TABLE WHERE `NoBSSID`=0 GROUP BY `BSSID` ORDER BY COUNT(BSSID) DESC LIMIT ".TOP_BSSID))
12401231
{
12411232
$json['stat']['data'] = array();
12421233
while ($row = $res->fetch_row())
@@ -1255,7 +1246,7 @@ function highlightWords($text, array $words)
12551246
case 'stess':
12561247
set_time_limit(30);
12571248
$json['result'] = true;
1258-
$json['stat']['top'] = $topessid;
1249+
$json['stat']['top'] = TOP_ESSID;
12591250
if (!db_connect())
12601251
{
12611252
$json['result'] = false;
@@ -1268,7 +1259,7 @@ function highlightWords($text, array $words)
12681259
$json['stat']['total'] = (int)$row[0];
12691260
$res->close();
12701261
}
1271-
if ($res = QuerySql('SELECT `ESSID`, COUNT(ESSID) FROM BASE_TABLE GROUP BY `ESSID` ORDER BY COUNT(ESSID) DESC LIMIT '.$topessid))
1262+
if ($res = QuerySql('SELECT `ESSID`, COUNT(ESSID) FROM BASE_TABLE GROUP BY `ESSID` ORDER BY COUNT(ESSID) DESC LIMIT '.TOP_ESSID))
12721263
{
12731264
$json['stat']['data'] = array();
12741265
while ($row = $res->fetch_row())
@@ -1287,7 +1278,7 @@ function highlightWords($text, array $words)
12871278
case 'stsec':
12881279
set_time_limit(30);
12891280
$json['result'] = true;
1290-
$json['stat']['top'] = $topSecurity;
1281+
$json['stat']['top'] = TOP_SECURITY;
12911282
if (!db_connect())
12921283
{
12931284
$json['result'] = false;
@@ -1300,7 +1291,7 @@ function highlightWords($text, array $words)
13001291
$json['stat']['total'] = (int)$row[0];
13011292
$res->close();
13021293
}
1303-
if ($res = QuerySql('SELECT `Security`, COUNT(Security) FROM BASE_TABLE GROUP BY `Security` ORDER BY COUNT(Security) DESC LIMIT '.$topSecurity))
1294+
if ($res = QuerySql('SELECT `Security`, COUNT(Security) FROM BASE_TABLE GROUP BY `Security` ORDER BY COUNT(Security) DESC LIMIT '.TOP_SECURITY))
13041295
{
13051296
$json['stat']['data'] = array();
13061297
while ($row = $res->fetch_row())
@@ -1319,7 +1310,7 @@ function highlightWords($text, array $words)
13191310
case 'stkey':
13201311
set_time_limit(30);
13211312
$json['result'] = true;
1322-
$json['stat']['top'] = $topWiFiKey;
1313+
$json['stat']['top'] = TOP_WIFI_KEY;
13231314
if (!db_connect())
13241315
{
13251316
$json['result'] = false;
@@ -1332,7 +1323,7 @@ function highlightWords($text, array $words)
13321323
$json['stat']['total'] = (int)$row[0];
13331324
$res->close();
13341325
}
1335-
if ($res = QuerySql('SELECT `WiFiKey`, COUNT(WiFiKey) FROM BASE_TABLE GROUP BY `WiFiKey` ORDER BY COUNT(WiFiKey) DESC LIMIT '.$topWiFiKey))
1326+
if ($res = QuerySql('SELECT `WiFiKey`, COUNT(WiFiKey) FROM BASE_TABLE GROUP BY `WiFiKey` ORDER BY COUNT(WiFiKey) DESC LIMIT '.TOP_WIFI_KEY))
13361327
{
13371328
$json['stat']['data'] = array();
13381329
while ($row = $res->fetch_row())
@@ -1351,7 +1342,7 @@ function highlightWords($text, array $words)
13511342
case 'stwps':
13521343
set_time_limit(30);
13531344
$json['result'] = true;
1354-
$json['stat']['top'] = $topWPSPIN;
1345+
$json['stat']['top'] = TOP_WPS_PIN;
13551346
if (!db_connect())
13561347
{
13571348
$json['result'] = false;
@@ -1364,7 +1355,7 @@ function highlightWords($text, array $words)
13641355
$json['stat']['total'] = (int)$row[0];
13651356
$res->close();
13661357
}
1367-
if ($res = QuerySql('SELECT `WPSPIN`, COUNT(WPSPIN) FROM BASE_TABLE WHERE `WPSPIN` != 1 GROUP BY `WPSPIN` ORDER BY COUNT(WPSPIN) DESC LIMIT '.$topWPSPIN))
1358+
if ($res = QuerySql('SELECT `WPSPIN`, COUNT(WPSPIN) FROM BASE_TABLE WHERE `WPSPIN` != 1 GROUP BY `WPSPIN` ORDER BY COUNT(WPSPIN) DESC LIMIT '.TOP_WPS_PIN))
13681359
{
13691360
$json['stat']['data'] = array();
13701361
while ($row = $res->fetch_row())
@@ -1383,7 +1374,7 @@ function highlightWords($text, array $words)
13831374
case 'stdns':
13841375
set_time_limit(30);
13851376
$json['result'] = true;
1386-
$json['stat']['top'] = $topDNS;
1377+
$json['stat']['top'] = TOP_DNS;
13871378
if (!db_connect())
13881379
{
13891380
$json['result'] = false;
@@ -1407,7 +1398,7 @@ function highlightWords($text, array $words)
14071398
SELECT DNS2 AS DNS FROM BASE_TABLE WHERE DNS2 != 0
14081399
UNION ALL
14091400
SELECT DNS3 AS DNS FROM BASE_TABLE WHERE DNS3 != 0) DNSTable
1410-
GROUP BY DNS ORDER BY COUNT(DNS) DESC LIMIT $topDNS"))
1401+
GROUP BY DNS ORDER BY COUNT(DNS) DESC LIMIT ".TOP_DNS))
14111402
{
14121403
$json['stat']['data'] = array();
14131404
while ($row = $res->fetch_row())
@@ -1426,7 +1417,7 @@ function highlightWords($text, array $words)
14261417
case 'stsid':
14271418
set_time_limit(30);
14281419
$json['result'] = true;
1429-
$json['stat']['top'] = $topSid;
1420+
$json['stat']['top'] = TOP_SSID;
14301421

14311422
if (!db_connect())
14321423
{
@@ -1442,7 +1433,7 @@ function highlightWords($text, array $words)
14421433
$res->close();
14431434
}
14441435

1445-
if ($res = $db->query('SELECT nick, COUNT(id) FROM uploads LEFT JOIN users USING(uid) GROUP BY uploads.uid ORDER BY COUNT(id) DESC LIMIT '.$topSid))
1436+
if ($res = $db->query('SELECT nick, COUNT(id) FROM uploads LEFT JOIN users USING(uid) GROUP BY uploads.uid ORDER BY COUNT(id) DESC LIMIT '.TOP_SSID))
14461437
{
14471438
$json['stat']['data'] = array();
14481439
while ($row = $res->fetch_row())

3wifid.php

+1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
<?php
2+
include 'config.php';
23
require_once 'utils.php';
34
require_once 'db.php';
45

add_quadkeys.php

+1
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
66
**/
77
set_time_limit(0);
8+
include 'config.php';
89
require 'db.php';
910
require 'quadkey.php';
1011

config.php

+58
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
<?php
2+
/**
3+
* Configuration file.
4+
* All settings must be there.
5+
*/
6+
7+
// Данные входа в БД
8+
define('DB_SERV', 'localhost');
9+
define('DB_NAME', '3wifi');
10+
define('DB_USER', 'root');
11+
define('DB_PASS', '');
12+
13+
// Settings block
14+
define('TRY_USE_MEMORY_TABLES', false);
15+
define('DEBUG_SQLQUERY', false);
16+
define('MEMORY_TABLES_RELEVANCE_EXPIRES', 60*60*6); // 6 hours
17+
18+
// Tables
19+
define('BASE_TABLE', 'base');
20+
define('GEO_TABLE', 'geo');
21+
define('BASE_TABLE_CONST', BASE_TABLE);
22+
define('GEO_TABLE_CONST', GEO_TABLE);
23+
define('BASE_MEM_TABLE', 'mem_base');
24+
define('GEO_MEM_TABLE', 'mem_geo');
25+
define('STATS_TABLE', 'stats');
26+
27+
28+
// Stats
29+
define('TOP_PORT', 30);
30+
define('TOP_AUTH', 100);
31+
define('TOP_NAME', 30);
32+
define('TOP_BSSID', 30);
33+
define('TOP_ESSID', 30);
34+
define('TOP_SECURITY', 30);
35+
define('TOP_WIFI_KEY', 30);
36+
define('TOP_WPS_PIN', 30);
37+
define('TOP_DNS', 30);
38+
define('TOP_SSID', 10);
39+
40+
// Maps
41+
define('MAX_ZOOM_LEVEL', 23);
42+
define('MAX_YANDEX_ZOOM', 18);
43+
44+
define('DEFAULT_LAT', 55.76);
45+
define('DEFAULT_LON', 37.64);
46+
define('DEFAULT_RAD', 2);
47+
48+
49+
// Users
50+
define('LOGIN_MIN', 5);
51+
define('LOGIN_MAX', 30);
52+
define('NICK_MIN', 5);
53+
define('NICK_MAX', 30);
54+
define('PASS_MIN', 6);
55+
define('PASS_MAX', 100);
56+
define('FAV_MAX', 200);
57+
define('LOC_MAX', 100);
58+
define('INVITE_LEN', 12);

db.php

+1-19
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,6 @@
11
<?php
22
require_once 'utils.php';
33

4-
// Settings block
5-
define('TRY_USE_MEMORY_TABLES', false);
6-
define('DEBUG_SQLQUERY', false);
7-
define('MEMORY_TABLES_RELEVANCE_EXPIRES', 60*60*6); // 6 hours
8-
9-
// Tables
10-
define('BASE_TABLE', 'base');
11-
define('GEO_TABLE', 'geo');
12-
define('BASE_TABLE_CONST', BASE_TABLE);
13-
define('GEO_TABLE_CONST', GEO_TABLE);
14-
define('BASE_MEM_TABLE', 'mem_base');
15-
define('GEO_MEM_TABLE', 'mem_geo');
16-
define('STATS_TABLE', 'stats');
174

185
// Stats table ids
196
define('STATS_DATABASE_STATUS', 1);
@@ -41,11 +28,6 @@
4128

4229
function db_connect()
4330
{
44-
/* Данные входа в БД */
45-
$db_serv = 'localhost';
46-
$db_name = '3wifi';
47-
$db_user = 'root';
48-
$db_pass = '';
4931
global $db;
5032
global $dbUseMemory;
5133

@@ -54,7 +36,7 @@ function db_connect()
5436
while (!$result && $tries--)
5537
{
5638
/* Подключаемся к БД */
57-
$db = mysqli_connect($db_serv, $db_user, $db_pass, $db_name);
39+
$db = mysqli_connect(DB_SERV, DB_USER, DB_PASS, DB_NAME);
5840

5941
/* Проверка подключения */
6042
if($db->connect_errno)

import.free.php

+1
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77

88
set_time_limit(0);
99
//ignore_user_abort(true);
10+
include 'config.php';
1011
require 'utils.php';
1112
require 'db.php';
1213

index.php

+6-3
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11
<?php
2+
include 'config.php';
3+
24
function validPage($page)
35
{
46
$result = '';
@@ -44,9 +46,10 @@ function validPage($page)
4446
$page = validPage(isset($_GET['page']) ? $_GET['page'] : 'home');
4547
if ($page == '') $page = '404';
4648

47-
$lat = 55.76;
48-
$lon = 37.64;
49-
$rad = 2;
49+
$lat = DEFAULT_LAT;
50+
$lon = DEFAULT_LON;
51+
$rad = DEFAULT_RAD;
52+
5053
if (isset($_GET['lat']))
5154
{
5255
$_GET['lat'] = str_replace(',', '.', $_GET['lat']);

quadkey.php

-3
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,4 @@
11
<?php
2-
define('MAX_ZOOM_LEVEL', 23);
3-
define('MAX_YANDEX_ZOOM', 18);
4-
52
/**
63
* Clips a number to the specified minimum and maximum values.
74
*

0 commit comments

Comments
 (0)