-
Notifications
You must be signed in to change notification settings - Fork 67
/
cache_settings.php
69 lines (65 loc) · 2.49 KB
/
cache_settings.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
<?php
/*!
* ATTENTION: THIS FREE LICENSE IS ONLY FOR PERSONAL NON-COMMERCIAL USER. FOR COMMERCIAL PURPOSES, PLEASE PURCHASE A COMMERCIAL LICENSE! *
* module: Centcount Analyticsb Free Settings Cache PHP Code *
* version: 1.00 Free *
* author: WM Jonssen *
* date: 05/23/2018 *
* copyright 2015-2018 WM Jonssen <[email protected]> - All rights reserved.*
* license: Dual licensed under the Free License and Commercial License. *
* https://www.centcount.com *
*/
if (isset($_SERVER['argv'][1])) {
$siteid = (int)$_SERVER['argv'][1];
$force_update = (int)$_SERVER['argv'][2];
} else if (isset($_GET['siteid'])) {
$siteid = (int)$_GET['siteid'];
}
empty($siteid) AND exit;
@require './config/config_common.php';
ignore_user_abort(1);
set_time_limit(0);
$REDIS = new Redis();
$REDIS->CONNECT(REDIS_IP_2, REDIS_PORT_2) !== true AND exit;
$REDIS->SELECT(REDIS_DB_2);
$con = mysqli_connect(DB_HOST_LOCAL, ROOT_USER_LOCAL, ROOT_PASSWORD_LOCAL);
if (mysqli_connect_errno($con)) exit;
$db_selected = mysqli_select_db($con, 'site'.$siteid);
if (!$db_selected) {
mysqli_close($con);
exit;
}
if ($REDIS->SETNX($siteid.'-Updating', '') !== true && $force_update === 0) exit;
$REDIS->SET($siteid.'-UpdateTime', time());
$REDIS->DEL($siteid.'-1');
$REDIS->DEL($siteid.'-2');
$REDIS->DEL($siteid.'-3');
$REDIS->DEL($siteid.'-4');
$REDIS->DEL($siteid.'-5');
$REDIS->DEL($siteid.'-6');
$result = mysqli_query($con, 'SELECT MD5, DomainType FROM domain');
if ($result && mysqli_num_rows($result)) {
while ($row = mysqli_fetch_assoc($result)) {
$REDIS->SADD($siteid.'-'.$row['DomainType'], $row['MD5']);
}
mysqli_free_result($result);
}
$result = mysqli_query($con, "SELECT TimeZone,IPDatabase,SiteStatus FROM setting WHERE pKey=0");
if ($result && mysqli_num_rows($result)) {
$row = mysqli_fetch_assoc($result);
$REDIS->SET($siteid.'-SiteStatus', $row['SiteStatus']);
$REDIS->SET($siteid.'-TimeZone', $row['TimeZone']);
$REDIS->SET($siteid.'-IPDatabase', $row['IPDatabase']);
mysqli_free_result($result);
}
$result = mysqli_query($con, 'SELECT NIP, DomainType FROM robot');
if ($result && mysqli_num_rows($result)) {
while ($row = mysqli_fetch_assoc($result)) {
$REDIS->SADD($siteid.'-'.$row['DomainType'], $row['MD5']);
}
mysqli_free_result($result);
}
$REDIS->DEL($siteid.'-Updating');
mysqli_close($con);
if (isset($_GET['siteid'])) echo 'Update OK!';
?>