本文整理汇总了PHP中unix类的典型用法代码示例。如果您正苦于以下问题:PHP unix类的具体用法?PHP unix怎么用?PHP unix使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了unix类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: cron
function cron()
{
$unix = new unix();
$files = $unix->DirFiles("/etc/cron.d");
$sql = "SELECT CronSchedule,ID FROM imapsync";
$q = new mysql();
$results = $q->QUERY_SQL($sql, "artica_backup");
if (!$q->ok) {
return null;
}
while (list($index, $line) = each($files)) {
if ($index == null) {
continue;
}
if (preg_match("#^imapsync-#", $index)) {
@unlink("/etc/cron.d/{$index}");
}
}
$sql = "SELECT CronSchedule,ID FROM imapsync";
$q = new mysql();
$results = $q->QUERY_SQL($sql, "artica_backup");
while ($ligne = @mysql_fetch_array($results, MYSQL_ASSOC)) {
if (trim($ligne["CronSchedule"] == null)) {
continue;
}
$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[] = "{$ligne["CronSchedule"]} root " . __FILE__ . " --sync {$ligne["ID"]}";
$f[] = "";
@file_put_contents("/etc/cron.d/imapsync-{$ligne["ID"]}", implode("\n", $f));
@chmod("/etc/cron.d/imapsync-{$ligne["ID"]}", 600);
unset($f);
}
}
示例2: startx
function startx()
{
$unix = new unix();
$php = $unix->LOCATE_PHP5_BIN();
$tar = $unix->find_program("tar");
build_progress("{backup_parameters}....", 5);
chdir("/etc/squid3");
system("cd /etc/squid3");
system("{$tar} -czf /root/backup.squid.tar.gz *");
build_progress("{reconfiguring}....", 10);
system("{$php} /usr/share/artica-postfix/exec.squid.php --build --force");
build_progress("{stopping_service}....", 50);
system("/etc/init.d/squid stop");
build_progress("{starting_service}....", 80);
system("/etc/init.d/squid start");
$cachefile = "/usr/share/artica-postfix/ressources/logs/web/squid.start.progress";
if (is_file($cachefile)) {
$textAR = unserialize(@file_get_contents($cachefile));
if ($textAR["POURC"] > 100) {
build_progress("{restore_parameters}....", 90);
shell_exec("{$tar} -xf /root/backup.squid.tar.gz -C /etc/squid3/");
build_progress("{starting_service}....", 90);
system("/etc/init.d/squid start");
}
}
@unlink("/root/backup.squid.tar.gz");
build_progress("{starting_service} {success}", 100);
chdir("/root");
}
示例3: startx
function startx()
{
build_progress("{rebuild_ssl_cache}: Removing SSL cache", 10);
$unix = new unix();
$rm = $unix->find_program("rm");
$chown = $unix->find_program("chown");
if ($GLOBALS["RESTART"]) {
build_progress("{rebuild_ssl_cache}: {stopping_proxy_service}", 30);
system("/etc/init.d/squid stop --script=" . basename(__FILE__));
}
echo "Remove /var/lib/squid/session/ssl/ssl_db\n";
shell_exec("{$rm} -rf /var/lib/squid/session/ssl/ssl_db");
build_progress("{rebuild_ssl_cache}: Reconstruct SSL cache", 50);
$sslcrtd_program = $unix->squid_locate_generic_bin("ssl_crtd");
system("{$sslcrtd_program} -c -s /var/lib/squid/session/ssl/ssl_db");
system("{$chown} -R squid:squid /var/lib/squid/session");
build_progress("{rebuild_ssl_cache}: Reload Proxy service", 60);
system("/etc/init.d/cache-tail restart --force");
if ($GLOBALS["RESTART"]) {
build_progress("{rebuild_ssl_cache}: {starting_proxy_service}", 30);
system("/etc/init.d/squid start --script=" . basename(__FILE__));
build_progress("{rebuild_ssl_cache}: {done}", 100);
return;
}
build_progress("{rebuild_ssl_cache}: Reload Proxy service", 70);
system("/etc/init.d/squid reload --force --script=" . basename(__FILE__));
build_progress("{rebuild_ssl_cache}: {done}", 100);
}
示例4: disks_scan
function disks_scan()
{
$unix = new unix();
$btrfs = $unix->find_program("btrfs");
$blkid = $unix->find_program("blkid");
$cmd = "{$btrfs} filesystem show 2>&1";
writelogs_framework("{$cmd}", __FUNCTION__, __FILE__, __LINE__);
exec($cmd, $results);
while (list($num, $ligne) = each($results)) {
if (preg_match("#Label:\\s+'(.*?)'\\s+uuid:\\s+(.+)#i", $ligne, $re)) {
$UUID = $re[2];
$array[$UUID]["LABEL"] = $re[1];
$array[$UUID]["DEV"] = exec("{$blkid} -U {$UUID}");
$array[$UUID]["MOUNTED"] = $unix->MOUNTED_PATH($array[$UUID]["DEV"]);
$array[$UUID]["DF"] = $unix->BLKID_INFOS($array[$UUID]["DEV"]);
continue;
}
if (preg_match("#Total devices.+?FS bytes used (.+)#", $ligne, $re)) {
$array[$UUID]["USED"] = $re[1];
continue;
}
if (preg_match("#devid\\s+([0-9]+)\\s+size\\s+(.+?)\\s+used\\s+(.+?)\\s+path\\s+(.+)#", $ligne, $re)) {
writelogs_framework("{$UUID}: {$ligne}", __FUNCTION__, __FILE__, __LINE__);
writelogs_framework("{$UUID}: {$re[4]}: SIZE: {$re[2]}", __FUNCTION__, __FILE__, __LINE__);
$array[$UUID]["DEVICES"][$re[1]]["SIZE"] = $re[2];
$array[$UUID]["DEVICES"][$re[1]]["USED"] = $re[3];
$array[$UUID]["DEVICES"][$re[1]]["DEV"] = $re[4];
}
}
echo "<articadatascgi>" . base64_encode(serialize($array)) . "</articadatascgi>";
}
示例5: DropBoxUri
function DropBoxUri()
{
$sock = new sockets();
$DropBoxUri = $sock->GET_INFO("DropBoxUri");
if (strlen($DropBoxUri) > 10) {
echo $DropBoxUri . "\n";
return;
}
$unix = new unix();
$grep = $unix->find_program("grep");
$tail = $unix->find_program("tail");
exec("{$grep} \"Please visit\" /var/log/dropbox.log|{$tail} -n 2000 2>&1", $results);
while (list($dir, $line) = each($results)) {
if (preg_match("#Please visit\\s+(.+?)\\s+to link#", $line, $re)) {
$uri = trim($re[1]);
break;
}
}
if ($uri != null) {
$sock = new sockets();
$sock->SET_INFO("DropBoxUri", $uri);
echo $uri . "\n";
return;
}
}
示例6: 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";
}
示例7: build_rules
function build_rules()
{
$q = new mysql_squid_builder();
$unix = new unix();
$SQUID_BIN = $unix->LOCATE_SQUID_BIN();
build_progress("{IT_charter}", 25);
$sql = "SELECT ID,title FROM itcharters WHERE enabled=1";
$results = $q->QUERY_SQL($sql);
if (!$q->ok) {
build_progress("{IT_charter} {mysql_error}", 110);
echo $q->mysql_error;
return;
}
if (mysql_num_rows($results) == 0) {
@unlink("/etc/squid3/itCharts.enabled.db");
squid_admin_mysql(1, "Reloading Proxy service (itCharts)", null, __FILE__, __LINE__);
build_progress("{IT_charter} {reload_proxy_service}", 90);
system("{$SQUID_BIN} -f /etc/squid3/squid.conf -k reconfigure");
build_progress("{IT_charter} {done} 0 {item}", 100);
return;
}
while ($ligne = mysql_fetch_assoc($results)) {
build_progress("{$ligne["title"]}", 50);
echo "{$ligne["ID"]}: {$ligne["title"]}\n";
$MAIN[$ligne["ID"]] = $ligne["title"];
}
@file_put_contents("/etc/squid3/itCharts.enabled.db", serialize($MAIN));
squid_admin_mysql(1, "Reloading Proxy service (itCharts)", null, __FILE__, __LINE__);
build_progress("{IT_charter} {reload_proxy_service}", 90);
system("{$SQUID_BIN} -f /etc/squid3/squid.conf -k reconfigure");
build_progress("{IT_charter} {done} " . count($MAIN) . " {items}", 100);
}
示例8: xstart
function xstart()
{
$sock = new sockets();
$unix = new unix();
$php = $unix->LOCATE_PHP5_BIN();
$SquidAllow80Port = intval($sock->GET_INFO("SquidAllow80Port"));
build_progress("{starting} {allow_80443_port}", 15);
if ($SquidAllow80Port == 1) {
build_progress("{stopping} {web_service}", 20);
system("/etc/init.d/apache2 stop");
build_progress("{stopping} Reverse Proxy", 30);
system("/etc/init.d/nginx stop");
} else {
build_progress("{remove} 80/443 ports", 20);
$q = new mysql_squid_builder();
$q->QUERY_SQL("DELETE FROM proxy_ports WHERE `port`='80'");
build_progress("{remove} 80/443 ports", 25);
$q->QUERY_SQL("DELETE FROM proxy_ports WHERE `port`='443'");
build_progress("{reconfigure_proxy_service}", 30);
$php = $unix->LOCATE_PHP5_BIN();
shell_exec("{$php} /usr/share/artica-postfix/exec.squid.php --build --force");
}
build_progress("{restarting_artica_status}", 80);
system("/etc/init.d/artica-status restart --force");
build_progress("{done}", 100);
}
示例9: xstart
function xstart()
{
$pidfile = "/etc/artica-postfix/pids/" . basename(__FILE__) . ".pid";
$pidtime = "/etc/artica-postfix/pids/" . basename(__FILE__) . ".time";
$pid = @file_get_contents($pidfile);
if ($GLOBALS["VERBOSE"]) {
echo "{$pidtime}\n";
}
$unix = new unix();
$squid = $unix->LOCATE_SQUID_BIN();
if (!$GLOBALS["FORCE"]) {
if ($unix->process_exists($pid, basename(__FILE__))) {
$time = $unix->PROCCESS_TIME_MIN($pid);
if ($GLOBALS["VERBOSE"]) {
echo "Already executed pid {$pid} since {$time}mn\n";
}
die;
}
}
$mypid = getmypid();
@file_put_contents($pidfile, $mypid);
$timefile = $unix->file_time_min($pidtime);
if ($GLOBALS["VERBOSE"]) {
echo "Timelock:{$pidtime} {$timefile} Mn\n";
}
if (!$GLOBALS["FORCE"]) {
if ($timefile < 5) {
if ($GLOBALS["VERBOSE"]) {
echo "{$timefile}mn require 5mn\n";
}
return;
}
}
@unlink($pidtime);
@file_put_contents($pidtime, time());
if (!is_file("/home/ufdb/smtp-events/ACCESS_LOG")) {
if ($GLOBALS["VERBOSE"]) {
echo "/home/ufdb/smtp-events/ACCESS_LOG no such file\n";
}
}
$array = explode("\n", @file_get_contents("/home/ufdb/smtp-events/ACCESS_LOG"));
@unlink("/home/ufdb/smtp-events/ACCESS_LOG");
$body = array();
$mmstp = new ufdb_msmtp();
$Subject = count($array) . " Web filtering blocked event(s)";
$body[] = "Return-Path: <{$mmstp->smtp_sender}>";
$body[] = "Date: " . date("D, d M Y H:i:s") . " +0100 (CET)";
$body[] = "From: {$mmstp->smtp_sender}";
$body[] = "Subject: {$Subject}";
$body[] = "To: {$mmstp->recipient}";
$body[] = "";
$body[] = "";
$body[] = @implode("\r\n", $array);
$body[] = "";
$body[] = "";
$finalbody = @implode("\r\n", $body);
if (!$mmstp->Send($finalbody)) {
squid_admin_mysql(0, "Unable to send notification {$Subject} to {$mmstp->recipient}", "{$Subject} to {$mmstp->recipient}\n------------------\n" . @implode("\n", $array) . "\n\t\tThe following error encountered\n" . $mmstp->logs . "\n", __FILE__, __LINE__);
}
}
示例10: build
function build()
{
$sock = new sockets();
$unix = new unix();
$sysctl = $unix->find_program("sysctl");
$echo = $unix->find_program("echo");
$HugePages = $sock->GET_INFO("HugePages");
$KernelShmmax = $sock->GET_INFO("KernelShmmax");
$meminfo = MemInfo();
$HUGEPAGESIZE = intval($meminfo["HUGEPAGESIZE"]);
$HUGEPAGESIZEBytes = $HUGEPAGESIZE;
if (!is_numeric($HugePages)) {
$HugePages = 0;
}
if (!is_numeric($KernelShmmax)) {
$KernelShmmax = 0;
}
if ($HugePages > 0) {
$HugePagesB = $HugePages * 1024;
$HugePagesB = $HugePagesB * 1024;
$HugePagesF = $HugePagesB / $HUGEPAGESIZEBytes;
echo "HUGEPAGESIZE = {$HUGEPAGESIZE} ({$HUGEPAGESIZEBytes} bytes) " . FormatBytes($HUGEPAGESIZEBytes / 1024) . "\n";
echo "HugePages = {$HugePages} Mb ({$HugePagesB} bytes)\n";
echo "HugePages Final = {$HugePagesF} " . FormatBytes($HugePagesF / 1024) . " \n";
$unix->sysctl("vm.nr_hugepages", $HugePagesF);
shell_exec("{$sysctl} -w vm.nr_hugepages={$HugePagesF}");
for ($i = 0; $i < 10; $i++) {
shell_exec("{$echo} {$HugePagesF} > /proc/sys/vm/nr_hugepages");
sleep(1);
}
}
// sysctl
}
示例11: export_to_zarafa
function export_to_zarafa($uid)
{
$f[] = "First Name,Middle Name,Last Name,Title,Suffix,Initials,Web Page,Gender,Birthday,Anniversary,Location,Language,Internet Free Busy,Notes,E-mail Address,E-mail 2 Address,E-mail 3 Address,Primary Phone,Home Phone,Home Phone 2,Mobile Phone,Pager,Home Fax,Home Address,Home Street,Home Street 2,Home Street 3,Home Address PO Box,Home City,Home State,Home Postal Code,Home Country,Spouse,Children,Manager's Name,Assistant's Name,Referred By,Company Main Phone,Business Phone,Business Phone 2,Business Fax,Assistant's Phone,Company,Job Title,Department,Office Location,Organizational ID Number,Profession,Account,Business Address,Business Street,Business Street 2,Business Street 3,Business Address PO Box,Business City,Business State,Business Postal Code,Business Country,Other Phone,Other Fax,Other Address,Other Street,Other Street 2,Other Street 3,Other Address PO Box,Other City,Other State,Other Postal Code,Other Country,Callback,Car Phone,ISDN,Radio Phone,TTY/TDD Phone,Telex,User 1,User 2,User 3,User 4,Keywords,Mileage,Hobby,Billing Information,Directory Server,Sensitivity,Priority,Private,Categories";
$ldap = new clladp();
$ct = new user($uid);
$dn = "ou={$uid},ou=People,dc={$ct->ou},dc=NAB,{$ldap->suffix}";
$filter = "(objectClass=inetOrgPerson)";
$attrs = array();
$hash = $ldap->Ldap_search($dn, $filter, array("employeeNumber"));
if ($GLOBALS["VERBOSE"]) {
echo "[{$uid}]: Exporting {$hash["count"]} user(s)\n";
}
for ($i = 0; $i < $hash["count"]; $i++) {
$emp = new contacts(null, $hash[$i]["employeenumber"][0]);
$f[] = @implode(",", $emp->ContactTocsvArray());
}
$tmpfile = "/tmp/{$uid}." . time() . ".csv";
@file_put_contents("{$tmpfile}", @implode("\n", $f));
$unix = new unix();
$php = $unix->LOCATE_PHP5_BIN();
$basename = basename($tmpfile);
$cmd = $php . " " . dirname(__FILE__) . "/exec.zarafa.csv2contacts.php {$uid} \"{$ct->password}\" {$basename} 2>&1";
if ($GLOBALS["VERBOSE"]) {
echo "[{$uid}]: {$cmd}\n";
}
exec($cmd, $results);
if ($GLOBALS["VERBOSE"]) {
while (list($num, $line) = each($results)) {
echo "[{$uid}]: {$line}\n";
}
}
}
示例12: database_empty
function database_empty()
{
$hostname = $_GET["hostname"];
if ($hostname == null) {
$hostname = "master";
}
if ($hostname == "master") {
$d[] = "/var/milter-greylist/greylist.db";
$d[] = "/usr/share/artica-postfix/ressources/logs/mgrelist-db.inc";
}
if ($hostname != "master") {
$d[] = "/var/milter-greylist/{$hostname}/greylist.db";
$d[] = "/usr/share/artica-postfix/ressources/logs/mgrelist-{$_GET["hostname"]}.inc";
}
$d[] = "/usr/share/artica-postfix/ressources/logs/greylist-count-{$hostname}.tot";
$d[] = "/usr/share/artica-postfix/ressources/logs/mgrelist-{$hostname}.inc";
while (list($num, $line) = each($d)) {
if (is_file($line)) {
@unlink($line);
}
}
$unix = new unix();
$nohup = $unix->find_program("nohup");
shell_exec("{$nohup} /etc/init.d/milter-greylist restart >/dev/null 2>&1 &");
}
示例13: fstabmount
function fstabmount()
{
$unix = new unix();
$fstabmount = $_GET["fstabmount"];
$dev = $unix->FSTAB_GETDEV($fstabmount);
if ($dev != null) {
$ext = $unix->DISK_GET_TYPE($dev);
}
if ($ext == null) {
$ext = "auto";
}
if (!is_dir($fstabmount)) {
@mkdir($fstabmount);
}
$tmp = $unix->FILE_TEMP();
if ($ext == "ext4") {
$kernel = $unix->KERNEL_VERSION_BIN();
error_log("framework::" . __FUNCTION__ . " kernel: {$kernel}");
if ($kernel < 20629) {
$ext = "ext4dev";
}
}
$cmd = "/bin/mount -t {$ext} {$dev} {$fstabmount} >{$tmp} 2>&1";
error_log("framework::" . __FUNCTION__ . " {$cmd}");
shell_exec("/bin/mount -t {$ext} {$dev} {$fstabmount} >{$tmp} 2>&1");
$results = @file_get_contents($tmp);
@unlink($tmp);
error_log("framework::" . __FUNCTION__ . " mount point is \"{$dev}\" ({$ext})={$results} line " . __LINE__);
if (strlen($results) > 0) {
echo "<articadatascgi>{$results}</articadatascgi>";
}
}
示例14: ReloadMacHelpers
function ReloadMacHelpers($output = false)
{
@mkdir("/var/log/squid/reload", 0755, true);
$unix = new unix();
$pgrep = $unix->find_program("pgrep");
$rm = $unix->find_program("rm");
shell_exec("{$rm} /var/log/squid/reload/*.ufdbgclient.php");
if (is_file("/var/log/squid/UfdbguardCache.db")) {
@unlink("/var/log/squid/UfdbguardCache.db");
}
exec("{$pgrep} -l -f \"ufdbgclient.php\" 2>&1", $results);
while (list($index, $ligne) = each($results)) {
if (preg_match("#pgrep#", $ligne)) {
continue;
}
if (!preg_match("#^([0-9]+)\\s+#", $ligne, $re)) {
continue;
}
$PIDS[] = $re[1];
echo "Starting......: " . date("H:i:s") . " [INIT]: Webfilter client reloading PID {$re[1]}\n";
@touch("/var/log/squid/reload/{$re[1]}.ufdbgclient.php");
@chown("/var/log/squid/reload/{$re[1]}.ufdbgclient.php", "squid");
@chgrp("/var/log/squid/reload/{$re[1]}.ufdbgclient.php", "squid");
}
squid_admin_mysql(2, count($PIDS) . " Artica helper(s) was reloaded", null, __FILE__, __LINE__);
}
示例15: xstart
function xstart()
{
$unix = new unix();
$php = $unix->LOCATE_PHP5_BIN();
$tar = $unix->find_program("tar");
build_progress("{downloading} roundcubeemail-1.1.2.tar.gz", 20);
$tmpfile = $unix->FILE_TEMP();
$curl = new ccurl("http://articatech.net/download/postfix-debian7/roundcubeemail-1.1.2.tar.gz");
if (!$curl->GetFile($tmpfile)) {
echo "Failed: " . $curl->error . "\n";
@unlink($tmpfile);
build_progress("{failed} roundcubeemail-1.1.2.tar.gz", 110);
return;
}
build_progress("{uncompressing} roundcubeemail-1.1.2.tar.gz", 50);
system("{$tar} xf {$tmpfile} -C /");
@unlink($tmpfile);
if (!is_file("/usr/share/roundcube/index.php")) {
build_progress("{uncompressing} roundcubeemail-1.1.2.tar.gz {failed}", 110);
return;
}
build_progress("{verify_database}", 60);
system("{$php} /usr/share/artica-postfix/exec.roundcube.php --database");
build_progress("{restarting_service}", 70);
system("{$php} /usr/share/artica-postfix/exec.roundcube.php --restart");
system("/etc/init.d/artica-status restart");
build_progress("{installing} roundcubeemail-1.1.2.tar.gz {success}", 100);
}