function parse_object() { global $ignore_menuitems, $ignore_tbitems, $lines, $lineid, $dfm_str, $dfm_prop, $dfm_noadd, $no_add; $in_strings = false; $in_str_count = 0; $in_str_name = ''; $cur_object = ''; if (preg_match('/object (.*):/', $lines[$lineid], $matches)) { // first object is empty if ($lineid !== 0) { $cur_object = $matches[1] . "."; } $lineid = $lineid + 1; } while (false == preg_match('/\\s*end$/', rtrim($lines[$lineid]))) { $lines[$lineid] = rtrim($lines[$lineid]); if (preg_match('/^(\\s)*object (.*): (.*)$/', $lines[$lineid], $matches)) { if ($ignore_menuitems && ($matches[3] == "TMenuItem" || $matches[3] == "TTntMenuItem") || $ignore_tbitems && ($matches[3] == "TTntToolButton" || $matches[3] == "TToolButton")) { $no_add = true; parse_object(); $no_add = false; } else { parse_object(); } } // parse values // we are in .Strings = ( ... ) area if ($in_strings) { if (preg_match('/^\\s*\'(.*)\'\\)?$/', $lines[$lineid], $matches)) { $dfm_prop[] = $cur_object . $in_str_name . '[' . $in_str_count . ']'; $dfm_str[] = $matches[1]; $dfm_noadd[] = $no_add; $in_str_count += 1; $in_strings = !preg_match('/\\)$/', $lines[$lineid]); } else { $in_strings = false; } } else { // value = '...' types if (preg_match('/^\\s+([\\d\\w\\.]*) = \'(.*)\'$/', $lines[$lineid], $matches)) { if ($matches[1] !== 'Name' && !preg_match('/\\.Name$/', $matches[1])) { $dfm_noadd[] = $no_add; $dfm_prop[] = $cur_object . $matches[1]; $dfm_str[] = $matches[2]; } } else { // .Strings = ( ... ) area start if (preg_match('/^\\s+([\\d\\w\\.]+)\\.Strings = \\($/', $lines[$lineid], $matches)) { $in_str_count = 0; $in_strings = true; $in_str_name = $matches[1]; } } } if ($lineid >= count($lines) - 1) { break; } $lineid = $lineid + 1; } }
function start_parse() { if ($GLOBALS["VERBOSE"]) { "echo Loading...\n"; } $unix = new unix(); if ($GLOBALS["VERBOSE"]) { "echo Loading done...\n"; } $pidfile = "/etc/artica-postfix/pids/" . basename(__FILE__) . "." . __FUNCTION__ . ".pid"; $timefile = "/etc/artica-postfix/pids/" . basename(__FILE__) . "." . __FUNCTION__ . ".time"; $pid = @file_get_contents($pidfile); if (!$GLOBALS["FORCE"]) { if ($pid < 100) { $pid = null; } $unix = new unix(); if ($unix->process_exists($pid, basename(__FILE__))) { if ($GLOBALS["VERBOSE"]) { echo "Already executed pid {$pid}\n"; } return; } $timeexec = $unix->file_time_min($timefile); if ($timeexec < 10) { return; } $mypid = getmypid(); @file_put_contents($pidfile, $mypid); } @unlink($timefile); @file_put_contents($timefile, time()); $ldap = new clladp(); if (!$ldap->IsKerbAuth()) { return; } $q = new mysql_squid_builder(); $sql = "SELECT ID,GroupName FROM webfilters_sqgroups WHERE `enabled`=1 AND `GroupType`='proxy_auth_statad'"; $results = $q->QUERY_SQL($sql); $REFRESH = false; $Count = mysql_num_rows($results); $UPDATED = array(); while ($ligne = mysql_fetch_assoc($results)) { if (parse_object($ligne["ID"], $ligne["GroupName"])) { $UPDATED[] = $ligne["GroupName"]; $REFRESH = true; } } if ($REFRESH) { squid_admin_mysql(1, "Reloading proxy service after updating " . count($UPDATED) . " Active Directory group(s)", @implode("\n", $UPDATED), __FILE__, __LINE__); $squid = $unix->LOCATE_SQUID_BIN(); system("/etc/init.d/squid reload --force --script=exec.squid.static.ad.groups.php/" . __LINE__); $sock = new sockets(); $EnableTransparent27 = intval($sock->GET_INFO("EnableTransparent27")); if ($EnableTransparent27 == 1) { system("/etc/init.d/squid-nat reload --script=" . basename(__FILE__)); } } }