本文整理汇总了PHP中unix::DirFiles方法的典型用法代码示例。如果您正苦于以下问题:PHP unix::DirFiles方法的具体用法?PHP unix::DirFiles怎么用?PHP unix::DirFiles使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类unix
的用法示例。
在下文中一共展示了unix::DirFiles方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: build
function build()
{
$webappFile = null;
$tomcatDir = "/var/lib/tomcat6/webapps";
if (!is_dir($tomcatDir)) {
echo "Starting......: " . date("H:i:s") . " C.A.S server failed `{$tomcatDir}` no such directory...\n";
return;
}
$unix = new unix();
$dirfiles = $unix->DirFiles("/usr/share/cas-server/modules", "cas-server-webapp-.*?\\.war");
echo "Starting......: " . date("H:i:s") . " C.A.S server checking libraries...\n";
echo "Starting......: " . date("H:i:s") . " C.A.S server TomCat webapps `{$tomcatDir}`\n";
while (list($num, $line) = each($dirfiles)) {
$webappFile = "/usr/share/cas-server/modules/{$num}";
}
if ($webappFile == null) {
echo "Starting......: " . date("H:i:s") . " C.A.S server failed to retrive cas-server-webapp war file\n";
return;
}
if (is_file("{$tomcatDir}/cas.war")) {
@unlink("{$tomcatDir}/cas.war");
}
echo "Starting......: " . date("H:i:s") . " C.A.S server installing {$webappFile} into {$tomcatDir}..\n";
@link($webappFile, "{$tomcatDir}/cas.war");
writesettings();
maven2();
tomcat_config();
log4jxml();
if (is_file("/etc/init.d/tomcat6")) {
echo "Starting......: " . date("H:i:s") . " C.A.S server restarting tomcat server...\n";
shell_exec("/etc/init.d/tomcat6 restart >/dev/null 2>&1");
}
WEB_INF_deployerConfigContext();
log4jxml();
}
示例2: ScanQueue
function ScanQueue()
{
$users = new usersMenus();
$GLOBALS["SAMBA_INSTALLED"] = $users->SAMBA_INSTALLED;
$unix = new unix();
$path = "/var/log/artica-postfix/xapian";
$SartOn = time();
$files = $unix->DirFiles($path);
if (count($files) == 0) {
return;
}
cpulimitProcessName("omindex");
while (list($num, $file) = each($files)) {
$toScan = "{$path}/{$file}";
if (ScanFile($toScan)) {
@unlink($toScan);
}
}
$SartOff = time();
$time = distanceOfTimeInWords($SartOn, $SartOff);
$countdir = count($GLOBALS["DIRS"]);
cpulimitProcessNameKill("omindex");
$echo = "InstantSearch {items}: {skipped}: {$GLOBALS["SKIPPED"]} {files}<br>{indexed}: {$GLOBALS["INDEXED"]} {files}<br>{duration}:{$time}";
if ($GLOBALS["INDEXED"] > 0) {
@file_put_contents("/usr/share/artica-postfix/ressources/logs/xapian.results", $echo);
@chmod("/usr/share/artica-postfix/ressources/logs/xapian.results", 0777);
}
echo $echo . "\n";
}
示例3: schedules
function schedules()
{
$unix = new unix();
$files = $unix->DirFiles("/etc/cron.d");
$cron = new cron_macros();
$php5 = $unix->LOCATE_PHP5_BIN();
while (list($index, $line) = each($files)) {
if ($index == null) {
continue;
}
if (preg_match("#^LdapImport-#", $index)) {
@unlink("/etc/cron.d/{$index}");
}
}
$sql = "SELECT * FROM ldap_ou_import WHERE enabled=1";
$q = new mysql();
$results = $q->QUERY_SQL($sql, "artica_backup");
while ($ligne = @mysql_fetch_array($results, MYSQL_ASSOC)) {
if (trim($ligne["ScheduleMin"] == null)) {
continue;
}
$schedule = $cron->cron_defined_macros[$ligne["ScheduleMin"]];
$f[] = "PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/X11R6/bin:/usr/share/artica-postfix/bin";
$f[] = "MAILTO=\"\"";
$f[] = "{$schedule} root {$php5} " . __FILE__ . " --import {$ligne["ID"]} >/dev/null 2>&1";
$f[] = "";
@file_put_contents("/etc/cron.d/LdapImport-{$ligne["ID"]}", implode("\n", $f));
@chmod("/etc/cron.d/LdapImport-{$ligne["ID"]}", 600);
unset($f);
}
}
示例4: reset2
function reset2()
{
system("clear");
echo "Remove databases\n";
$q = new mysql();
echo "Remove database settings\n";
$q->DELETE_DATABASE("artica_backup");
echo "Remove database events\n";
$q->DELETE_DATABASE("artica_events");
echo "Remove database Proxy\n";
$q = new mysql_squid_builder();
$q->QUERY_SQL("DROP DATABASE `squidlogs`");
echo "Remove Artica settings Proxy\n";
$unix = new unix();
$files = $unix->DirFiles("/etc/artica-postfix/settings/Daemons");
while (list($filename, $value) = each($files)) {
$fulename = "/etc/artica-postfix/settings/Daemons/{$filename}";
echo "Removing {$filename}\n";
@unlink($fulename);
}
@file_put_contents("/root/build/etc/artica-postfix/settings/Daemons/ProxyUseArticaDB", 1);
@file_put_contents("/root/build/etc/artica-postfix/settings/Daemons/StatsPerfsSquidAnswered", 1);
@file_put_contents("/root/build/etc/artica-postfix/settings/Daemons/CacheManagement2", 1);
@file_put_contents("/root/build/etc/artica-postfix/settings/Daemons/EnablePHPFPM", 0);
@file_put_contents("/root/build/etc/artica-postfix/settings/Daemons/EnableArticaFrontEndToNGninx", 0);
@file_put_contents("/root/build/etc/artica-postfix/settings/Daemons/EnableArticaFrontEndToApache", 1);
@file_put_contents("/root/build/etc/artica-postfix/settings/Daemons/EnableNginx", 0);
echo "Restarting Web Console...\n";
system('/etc/init.d/artica-webconsole restart');
system("clear");
echo "All data has been erased..\n";
echo "Type Enter key to exit\n";
$answer = trim(strtolower(fgets(STDIN)));
die;
}
示例5: sigtool
function sigtool()
{
$unix = new unix();
$sigtool = $unix->find_program("sigtool");
if (strlen($sigtool) < 5) {
die;
}
if (is_file("/usr/share/artica-postfix/ressources/interface-cache/ClamAVBases")) {
$ttim = $unix->file_time_min("/usr/share/artica-postfix/ressources/interface-cache/ClamAVBases");
if ($ttim < 30) {
return;
}
}
$baseDir = "/var/lib/clamav";
$patnz = $unix->DirFiles($baseDir, "\\.(cvd|cld|hdb|ign2|ndb)\$");
while (list($path, $none) = each($patnz)) {
$patterns[basename($path)] = true;
}
while (list($pattern, $none) = each($patterns)) {
if (!is_file("{$baseDir}/{$pattern}")) {
continue;
}
$results = array();
exec("{$sigtool} --info={$baseDir}/{$pattern} 2>&1", $results);
while (list($index, $line) = each($results)) {
if (preg_match("#Build time:\\s+(.+)#", $line, $re)) {
$time = strtotime($re[1]);
$MAIN[$pattern]["zDate"] = date("Y-m-d H:i:s");
continue;
}
if (preg_match("#Version:\\s+([0-9]+)#", $line, $re)) {
$MAIN[$pattern]["version"] = $re[1];
continue;
}
if (preg_match("#Signatures:\\s+([0-9]+)#", $line, $re)) {
$MAIN[$pattern]["signatures"] = $re[1];
continue;
}
}
if (!isset($MAIN[$pattern]["zDate"])) {
$time = filemtime("{$baseDir}/{$pattern}");
$MAIN[$pattern]["zDate"] = date("Y-m-d H:i:s", $time);
if (!isset($MAIN[$pattern]["version"])) {
$MAIN[$pattern]["version"] = date("YmdHi", $time);
}
}
if (!isset($MAIN[$pattern]["signatures"])) {
$MAIN[$pattern]["signatures"] = $unix->COUNT_LINES_OF_FILE("{$baseDir}/{$pattern}");
}
}
if (count($MAIN) == 0) {
return;
}
@file_put_contents("/usr/share/artica-postfix/ressources/interface-cache/ClamAVBases", serialize($MAIN));
}
示例6: parse
function parse()
{
$TimeFile = "/etc/artica-postfix/pids/exec.squid.stats.quota-week.parser.php.time";
$pidfile = "/etc/artica-postfix/pids/exec.squid.stats.quota-week.parser.php.pid";
$unix = new unix();
$pid = $unix->get_pid_from_file($pidfile);
if ($unix->process_exists($pid, basename(__FILE__))) {
$timepid = $unix->PROCCESS_TIME_MIN($pid);
if ($GLOBALS["VERBOSE"]) {
echo "{$pid} already executed since {$timepid}Mn\n";
}
if ($timepid < 14) {
return;
}
$kill = $unix->find_program("kill");
unix_system_kill_force($pid);
}
@file_put_contents($pidfile, getmypid());
$sock = new sockets();
$SquidPerformance = intval($sock->GET_INFO("SquidPerformance"));
$time = $unix->file_time_min($TimeFile);
if (!$GLOBALS["FORCE"]) {
if ($time < 1440) {
return;
}
}
@unlink($TimeFile);
@file_put_contents($TimeFile, time());
$f = $unix->DirFiles("/var/log/squid", "[0-9]+_QUOTASIZE\\.db");
$export_path = "/home/artica/squid/dbExport";
@mkdir($export_path, 0755, true);
while (list($filename, $none) = each($f)) {
preg_match("#([0-9]+)_#", $filename, $re);
$xdate = $re[1];
echo "{$filename} ( {$xdate} )\n";
if ($SquidPerformance > 1) {
if (!@copy("/var/log/squid/{$filename}", "{$export_path}/{$filename}")) {
continue;
}
@unlink("/var/log/squid/{$filename}");
continue;
}
if (!parse_file("/var/log/squid/{$filename}", $xdate)) {
continue;
}
if (!@copy("/var/log/squid/{$filename}", "{$export_path}/{$filename}")) {
continue;
}
@unlink("/var/log/squid/{$filename}");
}
}
示例7: purge_bysquid
function purge_bysquid()
{
$unix = new unix();
$pidfile = "/etc/artica-postfix/pids/" . basename(__FILE__) . "." . __FUNCTION__ . ".pid";
$pid = @file_get_contents($pidfile);
if ($pid < 100) {
$pid = null;
}
if ($unix->process_exists($pid, basename(__FILE__))) {
$timepid = $unix->PROCCESS_TIME_MIN($pid);
ufdbguard_admin_events("Already executed pid {$pid} since {$timepid}", __FUNCTION__, __FILE__, __LINE__, "purge");
if ($GLOBALS["VERBOSE"]) {
echo "Already executed pid {$pid}\n";
}
return;
}
@file_put_contents($pidfile, getmypid());
$sock = new sockets();
$users = new usersMenus();
$rm = $unix->find_program("rm");
$df = $unix->find_program("df");
$DF_RESULTS[] = "Scanning Artica directories in /var/log\ncurrent status:";
exec("{$df} -i /var/log 2>&1", $DF_RESULTS);
$DF_RESULTS[] = "";
exec("{$df} -h /var/log 2>&1", $DF_RESULTS);
$dirs = $unix->DirFiles("/var/log/artica-postfix");
while (list($directory, $b) = each($dirs)) {
$DF_RESULTS[] = "";
$DF_RESULTS[] = "";
$DF_RESULTS[] = date("Y-m-d H:i:s") . " Removing content of {$directory}";
$DF_RESULTS[] = date("Y-m-d H:i:s") . " {$directory} Before:";
$DF_RESULTS[] = "";
exec("{$df} -i {$directory} 2>&1", $DF_RESULTS);
$DF_RESULTS[] = "";
exec("{$df} -h {$directory} 2>&1", $DF_RESULTS);
shell_exec("{$rm} -rf {$directory}/* 2>&1");
$DF_RESULTS[] = date("Y-m-d H:i:s") . " {$directory} After removing content:";
exec("{$df} -i {$directory} 2>&1", $DF_RESULTS);
$DF_RESULTS[] = "";
exec("{$df} -h {$directory} 2>&1", $DF_RESULTS);
$DF_RESULTS[] = "";
}
squid_admin_mysql(0, "Log partition cleaning report", @implode("\n", $DF_RESULTS) . __FILE__, __LINE__);
}
示例8: restore_all
function restore_all()
{
$unix = new unix();
$pidfile = "/etc/artica-postfix/pids/" . basename(__FILE__) . "." . __FUNCTION__ . ".pid";
$pid = @file_get_contents($pidfile);
if ($pid < 100) {
$pid = null;
}
if ($unix->process_exists($pid, basename(__FILE__))) {
$timepid = $unix->PROCCESS_TIME_MIN($pid);
ufdbguard_admin_events("Already executed pid {$pid} since {$timepid}", __FUNCTION__, __FILE__, __LINE__, "reports");
if ($GLOBALS["VERBOSE"]) {
echo "Already executed pid {$pid}\n";
}
return;
}
@file_put_contents($pidfile, getmypid());
$sock = new sockets();
$ArticaProxyStatisticsRestoreFolder = $sock->GET_INFO("ArticaProxyStatisticsRestoreFolder");
if ($ArticaProxyStatisticsRestoreFolder == null) {
$ArticaProxyStatisticsRestoreFolder = "/home/artica/squid/backup-statistics-restore";
}
if (!is_dir($ArticaProxyStatisticsRestoreFolder)) {
ufdbguard_admin_events("{$ArticaProxyStatisticsRestoreFolder} no such directory", __FUNCTION__, __FILE__, __LINE__, "reports");
}
$SUCC = 0;
$FAI = 0;
$t = time();
$files = $unix->DirFiles($ArticaProxyStatisticsRestoreFolder);
while (list($srf, $line) = each($files)) {
$fullfilename = "{$ArticaProxyStatisticsRestoreFolder}/{$srf}";
if (restore($fullfilename, true)) {
$SUCC++;
} else {
$FAI++;
}
}
$took = $unix->distanceOfTimeInWords($t, time(), true);
ufdbguard_admin_events("{$SUCC} restored backup(s), {$FAI} failed, took {$took}", __FUNCTION__, __FILE__, __LINE__, "reports");
ScanDays();
}
示例9: ScanQueue
function ScanQueue()
{
$unix = new unix();
$GLOBALS["omindex"] = $unix->find_program("omindex");
$pidfile = "/etc/artica-postfix/pids/" . basename(__FILE__) . "." . __FUNCTION__ . ".pid";
$pid = $unix->get_pid_from_file($pidfile);
if ($unix->process_exists($pid)) {
writelogs("Already instance executed pid:{$olpid}", __FUNCTION__, __FILE__, __LINE__);
die;
}
@file_put_contents($pidfile, getmypid());
$users = new usersMenus();
$GLOBALS["SAMBA_INSTALLED"] = $users->SAMBA_INSTALLED;
$path = "{$GLOBALS["ARTICALOGDIR"]}/xapian";
$SartOn = time();
$files = $unix->DirFiles($path);
if (count($files) == 0) {
return;
}
cpulimitProcessName("omindex");
while (list($num, $file) = each($files)) {
$toScan = "{$path}/{$file}";
if (ScanFile($toScan)) {
@unlink($toScan);
}
}
$SartOff = time();
$time = distanceOfTimeInWords($SartOn, $SartOff);
$countdir = count($GLOBALS["DIRS"]);
cpulimitProcessNameKill("omindex");
$echo = "InstantSearch {items}: {skipped}: {$GLOBALS["SKIPPED"]} {files}<br>{indexed}: {$GLOBALS["INDEXED"]} {files}<br>{duration}:{$time}";
if ($GLOBALS["INDEXED"] > 0) {
@file_put_contents("/usr/share/artica-postfix/ressources/logs/xapian.results", $echo);
@chmod("/usr/share/artica-postfix/ressources/logs/xapian.results", 0777);
}
echo $echo . "\n";
}
示例10: clean_events
function clean_events()
{
$q = new mysql();
$unix = new unix();
$rm = $unix->find_program("rm");
$nohup = $unix->find_program("nohup");
$TABLES = $q->LIST_TABLES_EVENTS_SYSTEM();
while (list($tablename, $line) = each($TABLES)) {
echo "DROP {$tablename}\n";
$q->QUERY_SQL("DROP TABLE `{$tablename}`", "artica_events");
}
$datadir = $unix->MYSQL_DATA_DIR();
shell_exec("{$rm} -f {$datadir}/artica_events/*.BAK");
if (is_dir("{$datadir}/syslogstore")) {
$q->DELETE_DATABASE("syslogstore");
shell_exec("{$rm} -f {$datadir}/syslogstore/*.BAK");
}
$files = $unix->DirFiles("{$datadir}/artica_events", "TaskSq[0-9]+\\.MYI");
while (list($file, $line) = each($files)) {
$file = str_replace(".MYI", "", $file);
$q->QUERY_SQL("DROP TABLE `{$file}`", "artica_events");
}
$q->QUERY_SQL("TRUNCATE TABLE `nmap_events`", "artica_events");
$q->QUERY_SQL("TRUNCATE TABLE `nmap_events`", "artica_events");
$q->QUERY_SQL("TRUNCATE TABLE `avgreports`", "artica_events");
$q->QUERY_SQL("TRUNCATE TABLE `events`", "artica_events");
$q->QUERY_SQL("TRUNCATE TABLE `dhcpd_logs`", "artica_events");
$q->QUERY_SQL("TRUNCATE TABLE `update_events`", "artica_events");
shell_exec("{$nohup} /etc/init.d/mysql restart --framework=" . __FILE__ . " >/dev/null 2>&1 &");
shell_exec($unix->LOCATE_PHP5_BIN() . " /usr/share/artica-postfix/exec.mysql.start.php --engines --verbose --framework=" . __FILE__ . " 2>&1 &");
}
示例11: ParseLangs
function ParseLangs()
{
$unix = new unix();
$dirs = $unix->dirdir("/root/squid-lang");
while (list($dirpath, $value) = each($dirs)) {
$lang = basename($dirpath);
$files = $unix->DirFiles($dirpath);
while (list($filename, $value) = each($files)) {
if (strpos($filename, ".") > 0) {
continue;
}
$array[$lang][$filename] = ParseLangs_content("{$dirpath}/{$filename}");
}
@file_put_contents("/usr/share/artica-postfix/ressources/databases/squid.default.templates.db", serialize($array));
}
}
示例12: ParseRetranslatorLogs
function ParseRetranslatorLogs()
{
$unix = new unix();
if ($unix->PIDOF("/usr/share/artica-postfix/bin/retranslator.bin") > 0) {
return;
}
$dir = "/var/log/kretranslator";
if (!is_dir($dir)) {
return null;
}
$unix = new unix();
$files = $unix->DirFiles($dir);
while (list($num, $file) = each($files)) {
if (!preg_match("#retranslator-([0-9\\-]+)_([0-9]+)-([0-9]+)-([0-9]+).debug#", $file, $re)) {
continue;
}
$date = "{$re[1]} {$re[2]}:{$re[3]}:{$re[4]}";
$NumberofFilesUpdated = NumberofRestransFilesUpdated("{$dir}/{$file}");
if ($NumberofFilesUpdated[0] > 0) {
$subject = "Kaspersky Retranslator: {$NumberofFilesUpdated[0]} files updated ({$NumberofFilesUpdated[1]})";
send_email_events($subject, @file_get_contents("{$dir}/{$file}"), "KASPERSKY_UPDATES", $date);
@unlink("{$dir}/{$file}");
continue;
}
@unlink("{$dir}/{$file}");
}
}
示例13: UFDB_LOG_HOURLY_BACKUP
function UFDB_LOG_HOURLY_BACKUP()
{
$unix = new unix();
$sourcefile = "/home/ufdb/relatime-events/ACCESS_LOG";
$Workpath = "{$GLOBALS["LogFileDeamonLogDir"]}/webfilter-work";
$backupdir = "{$GLOBALS["LogFileDeamonLogDir"]}/webfilter-backup";
@mkdir($Workpath, 0755, true);
@mkdir($backupdir, 0755, true);
if (is_file($sourcefile)) {
$workfile = $Workpath . "/" . time() . ".log";
if (is_file($workfile)) {
return;
}
if (!@copy($sourcefile, "{$workfile}")) {
return;
}
@unlink($sourcefile);
}
$files = $unix->DirFiles($Workpath);
while (list($basename, $subarray) = each($files)) {
events("WEBFILTERING Scanning {$Workpath}/{$basename}");
UFDB_LOG_HOURLY_SCAN("{$Workpath}/{$basename}");
}
}
示例14: Dir_Files
function Dir_Files()
{
$queryregex = null;
if (isset($_GET["queryregex"])) {
if ($_GET["queryregex"] != null) {
$queryregex = base64_decode($_GET["queryregex"]);
}
}
$path = base64_decode($_GET["Dir-Files"]);
$path = utf8_encode($path);
writelogs_framework("{$path} ({$queryregex})", __FUNCTION__, __FILE__, __LINE__);
$unix = new unix();
$array = $unix->DirFiles($path, $queryregex);
writelogs_framework("{$path}=" . count($array) . " files", __FUNCTION__, __FILE__, __LINE__);
echo "<articadatascgi>" . base64_encode(serialize($array)) . "</articadatascgi>";
}
示例15: repair_tables
function repair_tables()
{
$pidfile = "/etc/artica-postfix/pids/" . basename(__FILE__) . "." . __FUNCTION__ . ".pid";
$timefile = "/etc/artica-postfix/pids/" . basename(__FILE__) . "." . __FUNCTION__ . ".time";
$pid = @file_get_contents($pidfile);
$unix = new unix();
if ($unix->process_exists($pid, basename(__FILE__))) {
events_tail("Already executed pid {$pid}");
if ($GLOBALS["VERBOSE"]) {
echo "Already executed pid {$pid}\n";
}
return;
}
$files = $unix->DirFiles("/usr/share/artica-postfix/ressources/logs/categorize-tables");
$php5 = $unix->LOCATE_PHP5_BIN();
while (list($none, $tablename) = each($files)) {
$filePath = "/usr/share/artica-postfix/ressources/logs/categorize-tables/{$tablename}";
if (!is_file($filePath)) {
@unlink($filePath);
continue;
}
$ARRAY = unserialize(@file_get_contents($filePath));
if (!is_array($ARRAY)) {
@unlink($filePath);
continue;
}
$PID = $ARRAY["PID"];
$CUR = $ARRAY["CURRENT"];
$MAX = $ARRAY["MAX"];
if ($CUR == $MAX) {
@unlink($filePath);
continue;
}
if ($unix->process_exists($PID)) {
continue;
}
categorize_tables_events("Ask to schedule table Current:{$CUR}/{$MAX}", null, $tablename, 1);
$unix->THREAD_COMMAND_SET("{$php5} " . __FILE__ . " --table {$tablename}");
}
}