-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathlocalsave.php
More file actions
48 lines (47 loc) · 2.07 KB
/
localsave.php
File metadata and controls
48 lines (47 loc) · 2.07 KB
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
<?php
$WebFolder ='/srv/www/telphone';
Function Show_log($mess, $Type = 0){
global $WebFolder;
if ($Type === 1) $mess = "!!! ВНИМАНИЕ !!! $mess" ;
file_put_contents($WebFolder.'/logs/localsave.log', date("Y-m-d H:i:s").' - '.$mess."\r\n",FILE_APPEND);
Echo date("Y-m-d H:i:s")." - $mess<br>";
};
require_once("config.php");
require_once("ldaps.php");
set_time_limit(600);
ini_set('memory_limit', '256M');
Show_log ("Начинаем обновления кеша на сервере ".$_SERVER['SERVER_ADDR']);
foreach ($P_LDAP as $P_LDAP_K => $P_LDAP_P) {
$LDAPCon = new LDAP($P_LDAP_P['Server'], $P_LDAP_P['User'], $P_LDAP_P['Pass']);
empty($P_LDAP_P["FullNameDepartment"]) ? null : $LDAPCon->FullNameDepartment = $P_LDAP_P["FullNameDepartment"];
$ArrData = array();
foreach ($P_LDAP_P['OU'] as $P_LDAP_OU_K => $P_LDAP_OU_P) {
$ArrDataTemp = $LDAPCon->getArray(
(($P_LDAP_OU_K=='0')?'':"OU=$P_LDAP_OU_K, ").$P_LDAP_P['DC'],
"",
array('displayname'),
//array(),
array("displayname", 'title', 'mail', 'telephonenumber', 'ipphone', 'department', 'objectguid'),
'',
$P_LDAP_OU_P
, false
);
if (!empty($ArrDataTemp))
$ArrData[$P_LDAP_OU_K] = $ArrDataTemp;
}
if (!empty($ArrData)){
//$FileBody = fopen("$WebFolder/localsave/Cache_".(explode('.',$P_LDAP_P['Server'][0])[1]).".php", "w");
$FileBody = fopen("$WebFolder/localsave/Cache_".(str_replace('.','_',substr($P_LDAP_P['Server'][0],0, strrpos($P_LDAP_P['Server'][0],'.')))).".php", "w");
fwrite($FileBody, '<?php ');
fwrite($FileBody, 'return '.var_export($ArrData,true));
unset($ArrData);
fwrite($FileBody, ' ?>');
fclose($FileBody);
Show_log ("Обновлен кеш по ".$P_LDAP_K.' '.$P_LDAP_P['Name']);
}
Else
Show_log ("Не удалось обновить кеш по ".$P_LDAP_K.' '.$P_LDAP_P['Name'], 1);
unset($LDAPCon);
}
Show_log ("Закончили обновления кеша");/**/
Show_log("=========================================================");