本文整理汇总了PHP中unix::dirdir方法的典型用法代码示例。如果您正苦于以下问题:PHP unix::dirdir方法的具体用法?PHP unix::dirdir怎么用?PHP unix::dirdir使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类unix
的用法示例。
在下文中一共展示了unix::dirdir方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: ParseMainDir
function ParseMainDir()
{
$unix = new unix();
$mypid = getmypid();
$kill = $unix->find_program("kill");
$nohup = $unix->find_program("nohup");
$php5 = $unix->LOCATE_PHP5_BIN();
@mkdir("/etc/artica-postfix/pids", 0755, true);
$pidtime = "/etc/artica-postfix/pids/" . basename(__FILE__) . ".time";
$pidtime_hour = "/etc/artica-postfix/pids/" . basename(__FILE__) . ".hours.time";
$pidfile = "/etc/artica-postfix/pids/" . basename(__FILE__) . ".pid";
$pid = @file_get_contents($pidfile);
if ($pid < 100) {
$pid = null;
}
if ($unix->process_exists($pid, basename(__FILE__))) {
$time = $unix->PROCCESS_TIME_MIN($pid);
if ($time > 60) {
unix_system_kill_force($pid);
} else {
events("Already executed pid {$pid} since {$time}mn-> DIE");
if ($GLOBALS["VERBOSE"]) {
echo "Already executed pid {$pid} since {$time}mn\n";
}
die;
}
}
$timeP = $unix->file_time_min($pidtime);
if ($timeP < 3) {
events("Main::Line: " . __LINE__ . " 3Mn minimal current: {$timeP}mn-> DIE");
die;
}
@unlink($pidtime);
@file_put_contents($pidtime, time());
@file_put_contents($pidfile, $mypid);
$dirs = $unix->dirdir("/var/log/artica-postfix/squid/queues");
while (list($directory, $array) = each($dirs)) {
$dirs2 = $unix->dirdir($directory);
if (count($dirs2) == 0) {
events("{$dirs2} 0 elements, remove...", __LINE__);
@rmdir($directory);
continue;
}
if (is_dir("{$directory}/SearchWords")) {
events("Scanning {$directory}/SearchWords", __LINE__);
ParseSubDir("{$directory}/SearchWords");
}
}
$timeP = $unix->file_time_min($pidtime_hour);
if ($timeP > 30) {
@unlink($pidtime_hour);
@file_put_contents($pidtime_hour, time());
shell_exec("{$nohup} {$php5} /usr/share/artica-postfix/exec.squid-searchwords.php --hour >/dev/null 2>&1");
}
}
示例2: startx
function startx()
{
$unix = new unix();
build_progress(50, "{refresh} CPUS");
@unlink("/etc/artica-postfix/CPU_NUMBER");
build_progress(55, "{refresh} CPUS");
@unlink("/usr/share/artica-postfix/ressources/interface-cache/CPU_NUMBER");
build_progress(60, "{rescan-disk-system}");
$dirs = $unix->dirdir("/sys/class/scsi_host");
$echo = $unix->find_program("echo");
$udevadm = $unix->find_program("udevadm");
$php = $unix->LOCATE_PHP5_BIN();
while (list($dirpath, $line) = each($dirs)) {
$basename = basename($dirpath);
if (!preg_match("#host[0-9]+#", $basename)) {
continue;
}
$cmd = "{$echo} \"- - -\" >{$dirpath}/scan";
build_progress(65, "{rescan-disk-system}" . dirname($dirpath));
shell_exec($cmd);
}
build_progress(70, "{rescan-disk-system}");
$cmdline = "{$php} /usr/share/artica-postfix/exec.usb.scan.write.php --verbose";
system($cmd);
build_progress(80, "{rescan-network-system}");
system("{$udevadm} control --reload-rules");
system("{$udevadm} trigger --attr-match=subsystem=net");
sleep(3);
system("/usr/share/artica-postfix/bin/process1 --force --verbose --" . time());
build_progress(100, "{refresh} {done}");
}
示例3: download
function download()
{
$unix = new unix();
build_progress("{downloading}", 10);
$URI = "http://wordpress.org/latest.tar.gz";
$TMP_FILE = $unix->FILE_TEMP() . ".gz";
$TMP_DIR = $unix->TEMP_DIR();
echo "Downloading {$URI}\n";
$curl = new ccurl($URI);
$curl->WriteProgress = true;
$curl->ProgressFunction = "download_progress";
if (!$curl->GetFile($TMP_FILE)) {
build_progress("{downloading} {failed}", 110);
echo $curl->error;
return;
}
echo "Extracting {$TMP_FILE} in {$TMP_DIR}\n";
$tar = $unix->find_program("tar");
$cmd = "{$tar} xf {$TMP_FILE} -C {$TMP_DIR}/";
build_progress("{uncompress}", 50);
shell_exec("{$tar} xf {$TMP_FILE} -C {$TMP_DIR}/");
@unlink($TMP_FILE);
$dirs = $unix->dirdir($TMP_DIR);
$WDP_DIR = null;
while (list($num, $ligne) = each($dirs)) {
if (!is_file("{$ligne}/wp-admin/install.php")) {
continue;
}
$WDP_DIR = $ligne;
break;
echo "Find Directory {$ligne}\n";
}
if (!is_dir($WDP_DIR)) {
build_progress("Find directory failed", 110);
echo "Find directory failed\n";
return;
}
build_progress("{installing}", 80);
@mkdir("/usr/share/wordpress-src", 0755, true);
$cp = $unix->find_program("cp");
$rm = $unix->find_program("rm");
shell_exec("cp -rfv {$WDP_DIR}/* /usr/share/wordpress-src/");
if (is_dir($WDP_DIR)) {
echo "Removing {$WDP_DIR}\n";
shell_exec("{$rm} -rf {$WDP_DIR}");
}
$sock = new sockets();
$sock->SET_INFO("EnableFreeWeb", 1);
@file_put_contents("/etc/artica-postfix/settings/Daemons/WordPressInstalled", 1);
system("/etc/init.d/artica-status restart --force");
build_progress("{success}", 100);
$nohup = $unix->find_program("nohup");
$sock = new sockets();
shell_exec("{$nohup} /usr/share/artica-postfix/bin/process1 --verbose 654646 >/dev/null 2>&1 &");
}
示例4: xinstall
function xinstall()
{
$unix = new unix();
$curl = new ccurl();
$tmpfile = $unix->FILE_TEMP();
$tmpdir = $unix->TEMP_DIR();
build_progress("{downloading} v3.1.0-25", 15);
$curl = new ccurl("http://articatech.net/download/UpdateUtility/updateutility-3.1.0-25.tar.gz");
if (!$curl->GetFile($tmpfile)) {
@unlink($tmpfile);
build_progress("{downloading} {failed}", 110);
return;
}
$tar = $unix->find_program("tar");
$rm = $unix->find_program("rm");
@mkdir("{$tmpdir}/updateutility", 0755);
build_progress("{uncompress}", 20);
shell_exec("{$tar} -xf {$tmpfile} -C {$tmpdir}/updateutility/");
build_progress("{find_source_directory}", 25);
$dirs = $unix->dirdir("{$tmpdir}/updateutility");
$SOURCE_DIRECTORY = null;
while (list($num, $ligne) = each($dirs)) {
build_progress("{scanning} {$ligne}", 25);
if (is_file("{$ligne}/UpdateUtility-Console")) {
$SOURCE_DIRECTORY = $ligne;
break;
}
}
if ($SOURCE_DIRECTORY == null) {
echo "Unable to find source directory\n";
build_progress("{installing} {failed}", 110);
shell_exec("{$rm} -rf {$tmpdir}/updateutility");
return;
}
echo "Using directory {$SOURCE_DIRECTORY}\n";
build_progress("{installing}...", 80);
$cp = $unix->find_program("cp");
@mkdir("/etc/UpdateUtility", 0755, true);
shell_exec("{$cp} -rfv {$SOURCE_DIRECTORY}/* /etc/UpdateUtility/");
shell_exec("{$rm} -rf {$tmpdir}/updateutility");
if (!is_file("/etc/UpdateUtility/UpdateUtility-Console")) {
echo "/etc/UpdateUtility/UpdateUtility-Console no such binary\n";
build_progress("{installing} {failed}", 110);
}
build_progress("{installing} {success}", 100);
}
示例5: install
function install()
{
$unix = new unix();
$wget = $unix->find_program("wget");
$tar = $unix->find_program("tar");
$rm = $unix->find_program("rm");
$cp = $unix->find_program("cp");
$targetfile = latests();
if (!is_file("{$GLOBALS["WORKDIR"]}/{$targetfile}")) {
echo "Downloading source file `{$targetfile}` on base `{$GLOBALS["URISRC"]}`\n";
shell_exec("{$wget} {$GLOBALS["URISRC"]}/{$targetfile} -O {$GLOBALS["WORKDIR"]}/{$targetfile}");
}
if (!is_file("{$GLOBALS["WORKDIR"]}/{$targetfile}")) {
echo "Failed downloading {$GLOBALS["URISRC"]}/{$targetfile}\n";
return;
}
echo "Extracting {$targetfile}\n";
shell_exec("{$tar} xf {$GLOBALS["WORKDIR"]}/{$targetfile} -C {$GLOBALS["WORKDIR"]}/");
echo "Parsing directories {$GLOBALS["WORKDIR"]}\n";
$dirs = $unix->dirdir($GLOBALS["WORKDIR"]);
while (list($num, $line) = each($dirs)) {
$dirname = basename($num);
if (preg_match("#^cas-server-#", $dirname)) {
$sourcedir = $num;
break;
}
}
echo "Source directory `{$sourcedir}`\n";
if (!is_dir($sourcedir)) {
echo "Failed extracting {$targetfile}\n";
return;
}
if (is_dir("/usr/share/cas-server")) {
echo "Cleaning old installation...\n";
shell_exec("/bin/rm -rf /usr/share/cas-server");
}
@mkdir("/usr/share/cas-server", 0755, true);
echo "installing `{$sourcedir}` in /usr/share/cas-server\n";
shell_exec("{$cp} -rf {$sourcedir}/* /usr/share/cas-server/");
if (!is_file("/usr/share/cas-server/pom.xml")) {
echo "Failed...\n";
return;
}
echo "Cleaning temp files...\n";
shell_exec("/bin/rm -rf {$GLOBALS["WORKDIR"]}");
}
示例6: CleanTempDirs
function CleanTempDirs()
{
$unix = new unix();
$dirs = $unix->dirdir("/tmp");
if (!is_array($dirs)) {
return null;
}
while (list($num, $ligne) = each($dirs)) {
if (trim($num) == null) {
continue;
}
$time = $unix->file_time_min($num);
if ($time < 380) {
continue;
}
if (is_dir($num)) {
shell_exec("/bin/rm -rf \"{$num}\"");
}
}
}
示例7: rotate
function rotate()
{
$unix = new unix();
$pidTime = "/etc/artica-postfix/pids/" . basename(__FILE__) . "." . __FUNCTION__ . ".time";
if ($unix->file_time_min($pidTime) < 55) {
return;
}
@unlink($pidTime);
@file_put_contents($pidTime, time());
$sock = new sockets();
$kill = $unix->find_program("kill");
$NginxWorkLogsDir = $sock->GET_INFO("NginxWorkLogsDir");
if ($NginxWorkLogsDir == null) {
$NginxWorkLogsDir = "/home/nginx/logsWork";
}
@mkdir("{$NginxWorkLogsDir}", 0755, true);
$directories = $unix->dirdir("/var/log/apache2");
while (list($directory, $line) = each($directories)) {
$sitename = basename($directory);
$date = date("Y-m-d-H");
$nginx_source_logs = "{$directory}/nginx.access.log";
$nginx_dest_logs = "{$NginxWorkLogsDir}/{$sitename}-{$date}.log";
if (is_file("{$nginx_dest_logs}")) {
echo "{$nginx_dest_logs} no such file\n";
continue;
}
if (!is_file($nginx_source_logs)) {
continue;
}
if (!@copy($nginx_source_logs, $nginx_dest_logs)) {
echo "Failed to copy {$nginx_dest_logs}\n";
continue;
}
@unlink($nginx_source_logs);
}
$pid = PID_NUM();
shell_exec("{$kill} -USR1 {$pid}");
$php5 = $unix->LOCATE_PHP5_BIN();
$nohup = $unix->find_program("nohup");
$sock = new sockets();
$EnableNginxStats = $sock->GET_INFO("EnableNginxStats");
if (!is_numeric($EnableNginxStats)) {
$EnableNginxStats = 0;
}
if ($EnableNginxStats == 0) {
shell_exec("{$nohup} {$php5} " . __FILE__ . " --awstats >/dev/null 2>&1 &");
return;
} else {
shell_exec("{$nohup} {$php5} /usr/share/artica-postfix/exec.nginx-stats.php --parse >/dev/null 2>&1 &");
}
}
示例8: execute
function execute()
{
$unix = new unix();
@mkdir("/var/clamav", 0755, true);
@mkdir("/var/run/clamav", 0755, true);
@mkdir("/var/lib/clamav", 0755, true);
@mkdir("/var/log/clamav", 0755, true);
$ClamUser = $unix->ClamUser();
$unix->chown_func("{$ClamUser}", "{$ClamUser}", "/var/clamav");
$unix->chown_func("{$ClamUser}", "{$ClamUser}", "/var/run/clamav");
$unix->chown_func("{$ClamUser}", "{$ClamUser}", "/var/lib/clamav");
$unix->chown_func("{$ClamUser}", "{$ClamUser}", "/var/log/clamav");
$pidfile = "/etc/artica-postfix/pids/" . basename(__FILE__) . "." . __FUNCTION__ . ".pid";
$pidTime = "/var/run/clamav/scheduled.time";
$pid = $unix->get_pid_from_file($pidfile);
if ($unix->process_exists($pid, basename(__FILE__))) {
$time = $unix->PROCCESS_TIME_MIN($pid);
build_progress("Already Executed since {$time}mn", 110);
if ($GLOBALS["OUTPUT"]) {
echo "Starting......: " . date("H:i:s") . " [INIT]: {$GLOBALS["TITLENAME"]} Already Artica task running PID {$pid} since {$time}mn\n";
}
return;
}
@file_put_contents($pidfile, getmypid());
if (!$GLOBALS["FORCE"]) {
$TimEx = $unix->file_time_min($pidTime);
if ($TimEx < 120) {
build_progress("Only each 120mn, current is {$TimEx}mn", 110);
if ($GLOBALS["OUTPUT"]) {
echo "Starting......: " . date("H:i:s") . " [INIT]: {$GLOBALS["TITLENAME"]} Only each 120mn, current is {$TimEx}mn\n";
}
return;
}
}
@unlink($pidTime);
@file_put_contents("{$pidTime}", time());
build_progress("{udate_clamav_databases}", 10);
$pid = PID_NUM();
if ($unix->process_exists($pid)) {
$timepid = $unix->PROCCESS_TIME_MIN($pid);
if ($GLOBALS["OUTPUT"]) {
echo "Starting......: " . date("H:i:s") . " [INIT]: {$GLOBALS["TITLENAME"]} Service already started {$pid} since {$timepid}Mn...\n";
}
build_progress("Service already started {$pid} since {$timepid}Mn", 110);
return;
}
$Masterbin = $unix->find_program("freshclam");
if (!is_file($Masterbin)) {
if ($GLOBALS["OUTPUT"]) {
echo "Starting......: " . date("H:i:s") . " [INIT]: {$GLOBALS["TITLENAME"]} service freshclam not installed\n";
}
build_progress("Missing freshclam", 110);
return;
}
if ($GLOBALS["OUTPUT"]) {
echo "Starting......: " . date("H:i:s") . " [INIT]: {$GLOBALS["TITLENAME"]} Building settings\n";
}
build_progress("{building_configuration}", 20);
build();
$verbose = null;
$log = "/var/log/clamav/freshclam.log";
if ($GLOBALS["PROGRESS"]) {
$log = "/usr/share/artica-postfix/ressources/logs/web/clamav.update.progress.txt";
$verbose = " --verbose";
}
$ClamUser = $unix->ClamUser();
$nohup = $unix->find_program("nohup");
@chmod("/usr/share/artica-postfix/ressources/logs/web", 0777);
@chmod($log, 0777);
if (is_file(dirname($Masterbin) . "/freshexec")) {
@unlink(dirname($Masterbin) . "/freshexec");
}
@copy($Masterbin, dirname($Masterbin) . "/freshexec");
@chmod(dirname($Masterbin) . "/freshexec", 0755);
$Masterbin = dirname($Masterbin) . "/freshexec";
$cmd = "{$nohup} {$Masterbin} --config-file=/etc/clamav/freshclam.conf --pid=/var/run/clamav/freshclam_manu.pid --user={$ClamUser} --log={$log}{$verbose} >/dev/null 2>&1 &";
$Dirs = $unix->dirdir("/var/lib/clamav");
$rm = $unix->find_program("rm");
while (list($directory, $MAIN) = each($Dirs)) {
echo "Checking {$directory}\n";
if (!preg_match("#\\.tmp\$#", $directory)) {
continue;
}
echo "Remove directory {$directory}";
shell_exec("{$rm} -rf {$directory}");
}
build_progress("{udate_clamav_databases}", 50);
echo $cmd;
system($cmd);
$PID = fresh_clam_manu_pid();
$WAIT = true;
while ($WAIT) {
if (!$unix->process_exists($PID)) {
break;
}
$ttl = $unix->PROCCESS_TIME_MIN($PID);
echo "PID: Running {$PID} since {$ttl}mn\n";
build_progress("{udate_clamav_databases} {waiting} PID {$PID} {since} {$ttl}mn", 80);
sleep(2);
$PID = fresh_clam_manu_pid();
//.........这里部分代码省略.........
示例9: clean_tmd
function clean_tmd()
{
$unix = new unix();
$pidfile = "/etc/artica-postfix/pids/" . basename(__FILE__) . ".MAIN.pid";
$pidfileTime = "/etc/artica-postfix/pids/exec.mysql.clean.php.clean_tmd.time";
$pid = $unix->get_pid_from_file($pidfile);
if ($unix->process_exists($pid, basename(__FILE__))) {
system_admin_events("Already process {$pid} exists", __FUNCTION__, __FILE__, __LINE__, "clean");
die;
}
$timeExec = $unix->file_time_min($pidfileTime);
if ($timeExec < 240) {
return;
}
@unlink($pidfileTime);
@file_put_contents($pidfileTime, time());
@file_put_contents($pidfile, getmypid());
$SIZES = 0;
$Dirs = $unix->dirdir("/var/lib/mysql");
while (list($directory, $none) = each($Dirs)) {
$Files = $unix->DirFiles($directory, "\\.[0-9]+\\.TMD\$");
while (list($filename, $none) = each($Files)) {
$fullpath = "{$directory}/{$filename}";
if ($unix->file_time_min($fullpath) < 240) {
continue;
}
$SIZES = $SIZES + @filesize($fullpath);
@unlink($fullpath);
}
$Files = $unix->DirFiles($directory, "\\.TMD-[0-9]+\$");
while (list($filename, $none) = each($Files)) {
$fullpath = "{$directory}/{$filename}";
if ($unix->file_time_min($fullpath) < 240) {
continue;
}
$SIZES = $SIZES + @filesize($fullpath);
@unlink($fullpath);
}
}
if (is_dir("/opt/squidsql/data")) {
$Dirs = $unix->dirdir("/opt/squidsql/data");
while (list($directory, $none) = each($Dirs)) {
$Files = $unix->DirFiles($directory, "\\.[0-9]+\\.TMD\$");
while (list($filename, $none) = each($Files)) {
$fullpath = "{$directory}/{$filename}";
if ($unix->file_time_min($fullpath) < 240) {
continue;
}
$SIZES = $SIZES + @filesize($fullpath);
@unlink($fullpath);
}
$Files = $unix->DirFiles($directory, "\\.TMD-[0-9]+\$");
while (list($filename, $none) = each($Files)) {
$fullpath = "{$directory}/{$filename}";
if ($unix->file_time_min($fullpath) < 240) {
continue;
}
$SIZES = $SIZES + @filesize($fullpath);
@unlink($fullpath);
}
}
}
}
示例10: build_index_page
function build_index_page()
{
$sock = new sockets();
$unix = new unix();
$SargOutputDir = $sock->GET_INFO("SargOutputDir");
if ($SargOutputDir == null) {
$SargOutputDir = "/var/www/html/squid-reports";
}
if ($GLOBALS["OUTPUT"]) {
echo "Starting......: " . date("H:i:s") . " [INIT]: {$GLOBALS["TITLENAME"]}, {$SargOutputDir}\n";
}
@copy("/usr/share/artica-postfix/bin/install/sarg.css", "{$SargOutputDir}/sarg.css");
@copy("/usr/share/artica-postfix/img/logo-artica-160.gif", "{$SargOutputDir}/logo.gif");
@copy("/usr/share/artica-postfix/css/images/pattern.png", "{$SargOutputDir}/pattern.png");
@copy("/usr/share/artica-postfix/ressources/templates/default/images/ui-bg_highlight.png", "{$SargOutputDir}/ui-bg_highlight.png");
@copy("/usr/share/artica-postfix/img/arrow-right-16.png", "{$SargOutputDir}/arrow-right-16.png");
@chmod("{$SargOutputDir}/arrow-right-16.png", 0755);
@chmod("{$SargOutputDir}/ui-bg_highlight.png", 0755);
@chmod("{$SargOutputDir}/sarg.css", 0755);
@chmod("{$SargOutputDir}/logo.gif", 0755);
@chmod("{$SargOutputDir}/pattern.png", 0755);
$f[] = "<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.01//EN\" \"http://www.w3.org/TR/html4/strict.dtd\">";
$f[] = "<html>";
$f[] = "<head>";
$f[] = " <meta http-equiv=\"Content-Type\" content=\"text/html; charset=ISO-8859-1\">";
$f[] = "<title>SARG reports</title>";
$f[] = "<link rel=\"stylesheet\" href=\"/sarg.css\" type=\"text/css\">";
$f[] = "</head>";
$f[] = "<body>";
$f[] = "<div class=\"logo\"><img src=\"/logo.gif\"> </div>";
$f[] = "<div class=\"title\"><table cellpadding=\"0\" cellspacing=\"0\">";
$f[] = "<tr><th class=\"title_c\">Squid User Access Reports</th></tr>";
$f[] = "</table>";
$f[] = "</div>";
$f[] = "<table cellpadding=\"0\" cellspacing=\"0\">\n\n";
if (is_file("{$SargOutputDir}/hourly/index.html")) {
$f[] = "<tr><td align='center'><a href=\"hourly/index.html\" style='font-size:22px;font-weight:bold'>« Hourly reports »</td></tr>";
} else {
if ($GLOBALS["OUTPUT"]) {
echo "Starting......: " . date("H:i:s") . " [INIT]: {$GLOBALS["TITLENAME"]}, {$SargOutputDir}/hourly/index.html no such file\n";
}
}
if (is_file("{$SargOutputDir}/daily/index.html")) {
$f[] = "<tr><td align='center'><a href=\"daily/index.html\" style='font-size:22px;font-weight:bold'>« Daily reports »</td></tr>";
} else {
if ($GLOBALS["OUTPUT"]) {
echo "Starting......: " . date("H:i:s") . " [INIT]: {$GLOBALS["TITLENAME"]}, {$SargOutputDir}/daily/index.html no such file\n";
}
}
if (is_file("{$SargOutputDir}/weekly/index.html")) {
$f[] = "<tr><td align='center'><a href=\"weekly/index.html\" style='font-size:22px;font-weight:bold'>« Weekly reports »</td></tr>";
} else {
if ($GLOBALS["OUTPUT"]) {
echo "Starting......: " . date("H:i:s") . " [INIT]: {$GLOBALS["TITLENAME"]}, {$SargOutputDir}/weekly/index.html no such file\n";
}
}
if (is_file("{$SargOutputDir}/monthly/index.html")) {
$f[] = "<tr><td align='center'><a href=\"monthly/index.html\" style='font-size:22px;font-weight:bold'>« Monthly reports »</td></tr>";
} else {
if ($GLOBALS["OUTPUT"]) {
echo "Starting......: " . date("H:i:s") . " [INIT]: {$GLOBALS["TITLENAME"]}, {$SargOutputDir}/monthly/index.html no such file\n";
}
}
$dirs = $unix->dirdir($SargOutputDir);
$monthsz = array('jan' => 1, 'ene' => 1, 'feb' => 2, 'mar' => 3, 'apr' => 4, 'abr' => 4, 'may' => 5, 'jun' => 6, 'jul' => 7, 'aug' => 8, 'ago' => 8, 'sep' => 9, 'oct' => 10, 'nov' => 11, 'dec' => 12, 'dic' => 12);
while (list($index, $line) = each($dirs)) {
$dir = basename($line);
if (!preg_match("#\\/([0-9]+)([A-Za-z]+)([0-9]+)-([0-9]+)([A-Za-z]+)([0-9]+)\$#", $line, $re)) {
echo "Starting......: " . date("H:i:s") . " [INIT]: {$GLOBALS["TITLENAME"]} {$dir}, no match\n";
continue;
}
$day = $re[1];
$month = $re[2];
$year = $re[3];
$day1 = $re[4];
$month1 = $re[5];
$year1 = $re[6];
if (strlen($year) < 4) {
if (strlen($day) == 4) {
$year = $re[1];
$month = $re[2];
$day = $re[3];
$day1 = $re[6];
$month1 = $re[5];
$year1 = $re[4];
}
}
if (strlen($year) < 4) {
echo "Starting......: " . date("H:i:s") . " [INIT]: {$GLOBALS["TITLENAME"]} {$dir}, no match\n";
continue;
}
$monthNum = $monthsz[strtolower($month)];
if (strlen($monthNum) == 1) {
$monthNum = "0{$monthNum}";
}
$time = strtotime("{$year}-{$monthNum}-{$day} 00:00:00");
$ARRAY[$year][$month][$day]["DIR"] = $dir;
$too = array();
if ($day1 != $day) {
$too[] = $day1;
//.........这里部分代码省略.........
示例11: PersonalCategoriesRepair
function PersonalCategoriesRepair()
{
$unix = new unix();
$user = GetSquidUser();
$reload = false;
$dirs = $unix->dirdir("/var/lib/squidguard/personal-categories");
while (list($a, $dir) = each($dirs)) {
if (!is_file("{$dir}/expressions")) {
events_ufdb_tail("exec.squidguard.php: creating {$dir}/expressions", __LINE__);
@file_put_contents("{$dir}/expressions", " ");
$reload = true;
}
}
shell_exec("/bin/chown -R {$user}:{$user} /var/lib/squidguard >/dev/null 2>&1 &");
if ($reload) {
shell_exec("{$GLOBALS["SQUIDBIN"]} -k reconfigure");
}
}
示例12: SERVICE_START
//.........这里部分代码省略.........
if ($MySqlTmpDir == '/tmp') {
$MySqlTmpDir = null;
}
if ($MySQLLOgErrorPath == null) {
$MySQLLOgErrorPath = $datadir . '/mysqld.err';
}
if ($MysqlTooManyConnections == 1) {
echo "Starting......: " . date("H:i:s") . " MySQL MysqlTooManyConnections=1, abort\n";
return;
}
if (isset($GLOBALS["RECOVERY"])) {
$innodb_force_recovery = $GLOBALS["RECOVERY"];
}
if (strlen($MySqlTmpDir) > 3) {
echo "Starting......: " . date("H:i:s") . " MySQL tempdir : {$MySqlTmpDir}\n";
shell_exec("{$php5} /usr/share/artica-postfix/exec.mysql.build.php --tmpfs");
$MySqlTmpDir = str_replace("//", "/", $MySqlTmpDir);
if (!is_dir($MySqlTmpDir)) {
@mkdir($MySqlTmpDir, 0755, true);
$unix->chown_func("mysql", "mysql", $MySqlTmpDir);
}
$MySqlTmpDirCMD = " --tmpdir={$MySqlTmpDir}";
}
if ($EnableMysqlFeatures == 0) {
echo "Starting......: " . date("H:i:s") . " MySQL is disabled by \"EnableMysqlFeatures\"...\n";
return;
}
$pid_file = "/var/run/mysqld/mysqld.pid";
$socket = "/var/run/mysqld/mysqld.sock";
$mysql_user = "mysql";
@mkdir("/var/run/mysqld", 0755, true);
@mkdir("/var/log/mysql", 0755, true);
@mkdir($datadir, 0755, true);
$dirs = $unix->dirdir("/var/lib/mysql");
while (list($num, $directory) = each($dirs)) {
echo "Starting......: " . date("H:i:s") . " MySQL, apply permissions on " . basename($directory) . "\n";
$unix->chown_func("mysql", "mysql", "{$directory}/*");
}
$bind_address = ' --bind-address=127.0.0.1';
$bind_address2 = "127.0.0.1";
if ($MysqlBinAllAdresses == 1) {
$bind_address2 = 'All (0.0.0.0)';
$bind_address = ' --bind-address=0.0.0.0';
}
echo "Starting......: " . date("H:i:s") . " MySQL Pid path.......:{$pid_file}\n";
echo "Starting......: " . date("H:i:s") . " datadir..............:{$datadir}\n";
echo "Starting......: " . date("H:i:s") . " Log error............:{$MySQLLOgErrorPath}\n";
echo "Starting......: " . date("H:i:s") . " socket...............:{$socket}\n";
echo "Starting......: " . date("H:i:s") . " user.................:{$mysql_user}\n";
echo "Starting......: " . date("H:i:s") . " LOGS ENABLED.........:{$EnableMysqlLog}\n";
echo "Starting......: " . date("H:i:s") . " Daemon...............:{$mysqlbin}\n";
echo "Starting......: " . date("H:i:s") . " Bind address.........:{$bind_address2}\n";
echo "Starting......: " . date("H:i:s") . " Temp Dir.............:{$MySqlTmpDir}\n";
echo "Starting......: " . date("H:i:s") . " innodb_force_recovery:{$innodb_force_recovery}\n";
mysql_admin_mysql(1, "Starting MySQL service...", null, __FILE__, __LINE__);
echo "Starting......: " . date("H:i:s") . " Settings permissions..\n";
@mkdir("/var/run/mysqld", 0755, true);
$unix->chown_func($mysql_user, $mysql_user, "/var/run/mysqld");
$unix->chown_func($mysql_user, $mysql_user, "/var/log/mysql");
$unix->chown_func($mysql_user, $mysql_user, $datadir);
$unix->chown_func($mysql_user, $mysql_user, "{$datadir}/*");
if ($unix->is_socket("/var/run/mysqld/mysqld.sock")) {
@unlink("/var/run/mysqld/mysqld.sock");
}
if (is_file('/var/run/mysqld/mysqld.err')) {
@unlink('/var/run/mysqld/mysqld.err');
示例13: BuildPatterns
function BuildPatterns()
{
$unix = new unix();
cpulimit();
$dirs = $unix->dirdir("/etc/dansguardian/lists/blacklists");
if ($GLOBALS["VERBOSE"]) {
echo "open /etc/dansguardian/lists/blacklists array of " . count($dirs) . "\n";
}
if (!is_array($dirs)) {
writelogs("Unable to dir /etc/dansguardian/lists/blacklists", __FUNCTION__, __FILE__, __LINE__);
return;
}
reset($dirs);
while (list($num, $val) = each($dirs)) {
$category = basename($num);
if ($GLOBALS["VERBOSE"]) {
echo "{$category}:: {$num} -> {$val}\n";
}
writelogs("Checking {$category}", __FUNCTION__, __FILE__, __LINE__);
if ($category == "blacklists") {
if ($GLOBALS["VERBOSE"]) {
echo "{$category} == blacklists, aborting\n";
}
continue;
}
$domains = 0;
$urls = 0;
$expressions = 0;
if (is_file("{$num}/domains")) {
$domains = $unix->COUNT_LINES_OF_FILE("{$num}/domains");
if ($GLOBALS["VERBOSE"]) {
echo "{$category}:: {$domains} number\n";
}
$filetime = date("Y-m-d H:i:s", filemtime("{$num}/domains"));
} else {
if ($GLOBALS["VERBOSE"]) {
echo "{$category}:: unable to stat {$num}/domains\n";
}
}
if (is_file("{$num}/urls")) {
$urls = $unix->COUNT_LINES_OF_FILE("{$num}/urls");
} else {
if ($GLOBALS["VERBOSE"]) {
echo "{$category}:: unable to stat {$num}/urls\n";
}
}
if ($GLOBALS["VERBOSE"]) {
echo "{$category}={$domains},{$urls},{$filetime}\n";
}
$array["{$category}"] = array($domains, $urls, $filetime);
}
$datas = base64_encode(serialize($array));
writelogs("writing /usr/share/artica-postfix/ressources/logs/dansguardian.patterns", __FUNCTION__, __FILE__, __LINE__);
@file_put_contents("/usr/share/artica-postfix/ressources/logs/dansguardian.patterns", $datas);
@chmod("/usr/share/artica-postfix/ressources/logs/dansguardian.patterns", 0755);
if (!is_file("/usr/share/artica-postfix/ressources/logs/dansguardian.patterns")) {
writelogs("Error writing dansguardian.patterns", __FUNCTION__, __FILE__, __LINE__);
}
return;
}
示例14: find_sources
function find_sources($sourcedir)
{
if (is_file("{$sourcedir}/domains")) {
return $sourcedir;
}
$unix = new unix();
$dirs = $unix->dirdir($sourcedir);
while (list($dirname, $md5) = each($dirs)) {
if (!is_file("{$dirname}/domains")) {
echo "{$dirname}/domains no such file\n";
continue;
}
return $dirname;
}
}
示例15: homes
function homes()
{
$GLOBALS["INDEXED"] = 0;
$GLOBALS["SKIPPED"] = 0;
$GLOBALS["DIRS"] = array();
$FOLDERS = array();
$RFOLDERS = array();
$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)) {
system_admin_events("Already instance executed pid:{$olpid}", __FUNCTION__, __FILE__, __LINE__, "xapian");
die;
}
@file_put_contents($pidfile, getmypid());
$nice = EXEC_NICE();
$t1 = time();
if (!is_file($GLOBALS["omindex"])) {
system_admin_events("omindex no such binary, aborting", __FUNCTION__, __FILE__, __LINE__, "xapian");
return;
}
$ldap = new clladp();
$attr = array("homeDirectory", "uid", "dn");
$pattern = "(&(objectclass=sambaSamAccount)(uid=*))";
$sock = new sockets();
$sock = new sockets();
$sr = @ldap_search($ldap->ldap_connection, "dc=organizations," . $ldap->suffix, $pattern, $attr);
$hash = ldap_get_entries($ldap->ldap_connection, $sr);
$sock = new sockets();
for ($i = 0; $i < $hash["count"]; $i++) {
$uid = $hash[$i]["uid"][0];
$homeDirectory = $hash[$i][strtolower("homeDirectory")][0];
if ($uid == null) {
writelogs("uid is null, SKIP ", __FUNCTION__, __FILE__, __LINE__);
continue;
}
if ($uid == "nobody") {
writelogs("uid is nobody, SKIP ", __FUNCTION__, __FILE__, __LINE__);
continue;
}
if ($uid == "root") {
writelogs("uid is root, SKIP ", __FUNCTION__, __FILE__, __LINE__);
continue;
}
if (substr($uid, strlen($uid) - 1, 1) == '$') {
writelogs("{$uid}:This is a computer, SKIP ", __FUNCTION__, __FILE__, __LINE__);
continue;
}
if ($homeDirectory == null) {
$homeDirectory = "/home/{$uid}";
}
if (!is_dir($homeDirectory)) {
continue;
}
$FOLDERS[$uid] = $homeDirectory;
$RFOLDERS[$homeDirectory] = true;
}
$SambaXapianAuth = unserialize(base64_decode($sock->GET_INFO("SambaXapianAuth")));
$username = $SambaXapianAuth["username"];
$password = $SambaXapianAuth["password"];
$domain = $SambaXapianAuth["domain"];
$comp = $SambaXapianAuth["ip"];
if (!isset($SambaXapianAuth["lang"])) {
$SambaXapianAuth["lang"] == "none";
}
$lang = $SambaXapianAuth["lang"];
if ($lang == null) {
$lang = "none";
}
$t1 = time();
$dirs = $unix->dirdir("/home");
$samba = new samba();
$localdatabase = "/usr/share/artica-postfix/LocalDatabases";
while (list($dir, $ligne) = each($dirs)) {
if ($dir == "/home/export") {
continue;
}
if ($dir == "/home/netlogon") {
continue;
}
if ($dir == "/home/artica") {
continue;
}
if ($dir == "/home/logs-backup") {
continue;
}
if (isset($RFOLDERS[$dir])) {
continue;
}
if (isset($samba->main_shared_folders[$dir])) {
continue;
}
$FOLDERS[basename($dir)] = $dir;
}
$count = 0;
while (list($uid, $directory) = each($FOLDERS)) {
$BaseUrl = $directory;
$database = "{$localdatabase}/xapian-{$uid}";
@mkdir($database, 0755, true);
//.........这里部分代码省略.........