本文整理汇总了PHP中unix::FILE_TEMP方法的典型用法代码示例。如果您正苦于以下问题:PHP unix::FILE_TEMP方法的具体用法?PHP unix::FILE_TEMP怎么用?PHP unix::FILE_TEMP使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类unix
的用法示例。
在下文中一共展示了unix::FILE_TEMP方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: restore
function restore($filename)
{
$unix = new unix();
$sock = new sockets();
$TMP = $unix->FILE_TEMP();
$filenameBase = basename($filename);
if (!is_file($filename)) {
echo "{$filename} no such file\n";
build_progress("{failed}", 110);
}
$tmpf = $unix->FILE_TEMP();
build_progress("{uncompress} {$filenameBase}", 10);
if (!$unix->uncompress($filename, $tmpf)) {
@unlink($filename);
build_progress("{uncompress} {$filenameBase} {failed}", 110);
return;
}
@unlink($filename);
build_progress("{importing} {$tmpf}", 50);
$q = new mysql_squid_builder();
$nice = $unix->EXEC_NICE();
$mysql = $unix->find_program("mysql");
$gzip = $unix->find_program("gzip");
$nohup = $unix->find_program("nohup");
$echo = $unix->find_program("echo");
$rm = $unix->find_program("rm");
$php = $unix->LOCATE_PHP5_BIN();
$sh[] = "#!/bin/sh";
$sh[] = "{$echo} \"{$mysql} -> {$filenameBase}\"";
$sh[] = "{$nice} {$mysql} {$q->MYSQL_CMDLINES} -f squidlogs < {$tmpf}";
$sh[] = "{$rm} {$TMP}.sh";
$sh[] = "\n";
@file_put_contents("{$TMP}.sh", @implode("\n", $sh));
@chmod("{$TMP}.sh", 0755);
build_progress(10, "Starting restore {$filenameBase} - " . basename("{$TMP}.sh") . " ");
system("{$nohup} {$TMP}.sh >{$TMP}.txt 2>&1 &");
sleep(1);
$PID = $unix->PIDOF_PATTERN("{$TMP}.sh");
echo "Running PID {$PID}\n";
while ($unix->process_exists($PID)) {
build_progress(50, "Starting restoring {$filenameBase}");
sleep(3);
$PID = $unix->PIDOF_PATTERN("{$TMP}.sh");
echo "Running PID {$PID}\n";
}
echo @file_get_contents("{$TMP}.txt") . "\n";
@unlink("{$TMP}.sh");
@unlink("{$TMP}.txt");
build_progress(50, "{restore} {done} {$filenameBase}");
build_progress(50, "{restore} Analyze Hourly tables");
system("{$php} /usr/share/artica-postfix/exec.squid.stats.hours.php --force --verbose");
build_progress(60, "{restore} Repair Hourly tables");
system("{$php} /usr/share/artica-postfix/exec.squid.stats.hours.php --repair --force --verbose");
build_progress(70, "{restore} Repair Table days");
system("{$php} /usr/share/artica-postfix/exec.squid.stats.repair.php --tables-day --repair --force --verbose");
build_progress(80, "{restore} Repair sums");
system("{$php} /usr/share/artica-postfix/exec.squid.stats.totals.php --repair --force --verbose");
build_progress(100, "{restore} Done");
}
示例2: 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>";
}
}
示例3: 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);
}
示例4: iprulesDNS
function iprulesDNS()
{
$unix = new unix();
$IPCHAIN = "dnsfilter";
$pidfile = "/etc/artica-postfix/" . basename(__FILE__) . "." . __FUNCTION__ . ".pid";
if ($unix->process_exists(@file_get_contents($pidfile), basename(__FILE__))) {
echo "Starting......: " . date("H:i:s") . " iptables configurator already executed PID " . @file_get_contents($pidfile) . "\n";
die;
}
$pid = getmypid();
file_put_contents($pidfile, $pid);
$sock = new sockets();
$EnableIptablesDNS = $sock->GET_INFO("EnableIptablesDNS");
if (!is_numeric($EnableIptablesDNS)) {
$EnableIptablesDNS = 1;
}
if ($EnableIptablesDNS == 0) {
$ip = new iptables_exec();
if ($ip->is_chain_exists($IPCHAIN)) {
shell_exec("{$GLOBALS["iptables"]} -F {$IPCHAIN}");
shell_exec("{$GLOBALS["iptables"]} -X {$IPCHAIN}");
}
return;
}
$tmpfile = $unix->FILE_TEMP();
$curl = new ccurl("https://raw.github.com/smurfmonitor/dns-iptables-rules/master/domain-blacklist.txt");
$curl->NoHTTP_POST = true;
if ($curl->GetFile($tmpfile)) {
$size = @filesize($tmpfile);
if ($size < 100) {
$tmpfile = "/usr/share/artica-postfix/bin/install/iptables_defaults.txt";
}
}
$ip = new iptables_exec();
if (!$ip->is_chain_exists($IPCHAIN)) {
echo "Adding chain {$IPCHAIN}\n";
shell_exec("{$GLOBALS["iptables"]} -N {$IPCHAIN}");
shell_exec("{$GLOBALS["iptables"]} -I INPUT -p udp --dport 53 -j {$IPCHAIN}");
} else {
echo "chain {$IPCHAIN} exists...\n";
}
shell_exec("{$GLOBALS["iptables"]} -F {$IPCHAIN}");
shell_exec("{$GLOBALS["iptables"]} -A {$IPCHAIN} -j RETURN");
$f = explode("\n", @file_get_contents($tmpfile));
while (list($num, $ligne) = each($f)) {
$ligne = trim($ligne);
if ($ligne == null) {
continue;
}
$ligne = str_replace("INPUT", $IPCHAIN, $ligne);
$ligne = str_replace("iptables", $GLOBALS["iptables"], $ligne);
$results = array();
exec($ligne, $results);
echo "{$ligne}\n";
while (list($a, $b) = each($results)) {
echo "{$b}\n";
}
}
}
示例5: GetDomains
function GetDomains($i)
{
$unix = new unix();
$tmpfile = $unix->FILE_TEMP();
$curl = new ccurl("http://0675.com.cn/newwebsite_20120101_list._page0.html");
$curl->NoHTTP_POST = true;
echo "Get page {$i}\n";
if (!$curl->GetFile($tmpfile)) {
echo "http://0675.com.cn/newwebsite_20120101_list._page{$i}.html -> error: \n" . $curl->error . "\n";
return;
}
$datas = @file($tmpfile);
$size = strlen(@implode("", $datas)) / 1024;
echo "Page[{$i}]:: {$tmpfile} Size: {$size} Ko\n";
while (list($num, $ligne) = each($datas)) {
if (preg_match("#<div class=.*?newdomain.*?>(.*)#", $ligne)) {
echo "Sure line {$num}";
$newdata = str_replace("</li>", "", $ligne);
$newdata = str_replace("</div>", "", $newdata);
$f = explode("<li>", $newdata);
}
}
$q = new mysql_squid_builder();
while (list($num, $www) = each($f)) {
if (preg_match("#^\\.(.+)#", $www, $re)) {
$www = $re[1];
}
if (strpos($www, ",") > 0) {
continue;
}
if (strpos($www, " ") > 0) {
continue;
}
if (strpos($www, ":") > 0) {
continue;
}
if (strpos($www, "%") > 0) {
continue;
}
if (strpos($www, ">") > 0) {
continue;
}
if (strpos($www, "<") > 0) {
continue;
}
if (preg_match("#^www\\.(.+)#", $www, $re)) {
$www = $re[1];
}
$articacats = trim($q->GET_CATEGORIES($www, true, false));
if ($articacats != null) {
echo "\"{$www}\" SUCCESS - {$articacats} -\n";
continue;
}
echo "\"{$www}\" FAILED\n";
}
}
示例6: 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 &");
}
示例7: certificate_infos
function certificate_infos()
{
$unix = new unix();
$openssl = $unix->find_program("openssl");
$l = $unix->FILE_TEMP();
$cmd = "{$openssl} x509 -in /etc/artica-postfix/openvpn/keys/vpn-server.key -text -noout >{$l} 2>&1";
if ($cmd != null) {
shell_exec($cmd);
$datas = explode("\n", @file_get_contents($l));
writelogs_framework($cmd . " =" . count($datas) . " rows", __FUNCTION__, __FILE__, __LINE__);
@unlink($l);
}
echo "<articadatascgi>" . base64_encode(serialize($datas)) . "</articadatascgi>";
}
示例8: run
function run()
{
$sock = new sockets();
$PhileSizeCpuLimit = $sock->GET_INFO("PhileSizeCpuLimit");
if ($PhileSizeCpuLimit == null) {
$PhileSizeCpuLimit = 0;
}
if (InMemQUestion()) {
writelogs("Already running, aborting", __FUNCTION__, __FILE__, __LINE__);
return null;
}
chdir("/usr/share/artica-postfix/bin");
$unix = new unix();
$tmpfile = $unix->FILE_TEMP();
$cmd = $unix->find_program("nohup") . " /usr/share/artica-postfix/bin/philesight --db /opt/artica/philesight/database.db --index / >{$tmpfile} &";
echo $cmd . "\n";
shell_exec($cmd);
sleep(3);
$f = explode("\n", @file_get_contents($tmpfile));
@unlink($tmpfile);
while (list($num, $ligne) = each($f)) {
if (preg_match("#run database recovery#", $ligne)) {
$corrupted = true;
}
}
if ($corrupted) {
@unlink("/opt/artica/philesight/database.db");
shell_exec($cmd);
}
if ($PhileSizeCpuLimit == 0) {
return;
}
sleep(3);
$pid = getPID();
echo "Pid={$pid}\n";
if ($pid > 2) {
$cpulimit = $unix->find_program("cpulimit");
echo "cpulimit={$cpulimit}\n";
if (is_file($cpulimit)) {
$cmd_limit = "{$cpulimit} -p {$pid} -l {$PhileSizeCpuLimit} -z >>/var/log/cpulimit 2>&1 &";
sleep(1);
echo $cmd_limit . "\n";
shell_exec($cmd_limit);
}
}
}
示例9: 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);
}
示例10: export
function export()
{
$workdir = dirname(__FILE__) . "/ressources/squid-export";
if (!is_dir($workdir)) {
@mkdir($workdir, 0777, true);
}
if (!($handle = opendir("/etc/artica-postfix/settings/Daemons"))) {
@mkdir("/etc/artica-postfix/settings/Daemons", 0755, true);
die;
}
while (false !== ($filename = readdir($handle))) {
if ($filename == ".") {
continue;
}
if ($filename == "..") {
continue;
}
$targetFile = "/etc/artica-postfix/settings/Daemons/{$filename}";
if ($GLOBALS["VERBOSE"]) {
echo "Exporting {$filename}\n";
}
$array[$filename] = @file_get_contents($targetFile);
}
if ($GLOBALS["VERBOSE"]) {
echo count($array) . " items....\n";
}
$finalitems = base64_encode(serialize($array));
$unix = new unix();
$tmpf = $unix->FILE_TEMP();
@file_put_contents($tmpf, $finalitems);
if ($GLOBALS["VERBOSE"]) {
echo "compressing in {$workdir}/settingsHD.gz\n";
}
if (!$unix->compress($tmpf, "{$workdir}/settingsHD.gz")) {
@unlink("{$workdir}/settingsHD.gz");
}
@chmod("{$workdir}/settingsHD.gz", 0777);
@unlink($tmpf);
if ($GLOBALS["VERBOSE"]) {
echo "compressing in {$workdir}/settingsHD.gz done\n";
}
}
示例11: tests_port
function tests_port($port_id)
{
$unix = new unix();
$squid = new squidbee();
$q = new mysql_squid_builder();
$ligne = @mysql_fetch_array($q->QUERY_SQL("SELECT * FROM proxy_ports WHERE ID={$port_id}"));
$ssl_bump_line = $squid->ssl_bump_line($ligne["sslcertificate"]);
$randport = rand(63500, 65535);
build_progress("{testing_ssl_certificate} ID:{$port_id} {$ligne["sslcertificate"]}", 15);
$t = time();
$pid_filename = "/var/run/squid/{$t}.pid";
$cache_log = "/var/log/squid/cache.{$t}.log";
$f[] = "coredump_dir\t/var/squid/cache";
$f[] = "cache_log\t/var/log/squid/cache.log";
$f[] = "pid_filename\t/var/run/squid/squid.pid";
$f[] = "cache_effective_user squid";
$f[] = "http_port 127.0.0.1:{$randport} {$ssl_bump_line}";
echo " ***********************************************************************\n";
echo "Using HTTPS port {$ssl_bump_line} Certificate {$ligne["sslcertificate"]}\n";
echo " ***********************************************************************\n";
$f[] = "";
$tmpfile = $unix->FILE_TEMP();
$squidbin = $unix->LOCATE_SQUID_BIN();
build_progress("{testing_ssl_certificate} {$ligne["sslcertificate"]}", 20);
echo "Conf : {$tmpfile}\n";
echo "Binary: {$squidbin}\n";
@file_put_contents($tmpfile, @implode("\n", $f));
exec("{$squidbin} -f {$tmpfile} -k check 2>&1", $results);
@unlink($tmpfile);
while (list($num, $line) = each($results)) {
echo "Check : {$line}\n";
if (preg_match("#FATAL: No valid signing SSL#", $line)) {
build_progress("{testing_ssl_certificate_failed} {$ligne["sslcertificate"]}", 110);
$sql = "UPDATE proxy_ports SET sslcertificate='' WHERE ID='{$port_id}'";
$q->QUERY_SQL($sql);
return;
}
}
build_progress("{testing_ssl_certificate} {success}", 100);
// FATAL: No valid signing SSL certificate
}
示例12: run
function run()
{
$TimeFile = "/etc/artica-postfix/pids/" . basename(__FILE__) . ".time";
$pidfile = "/etc/artica-postfix/pids/" . basename(__FILE__) . ".pid";
$unix = new unix();
$tmpfile = $unix->FILE_TEMP();
$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 (!$GLOBALS["FORCE"]) {
if ($timepid < 14) {
return;
}
$kill = $unix->find_program("kill");
unix_system_kill_force($pid);
}
}
@file_put_contents($pidfile, getmypid());
if (!$GLOBALS["FORCE"]) {
if (!$GLOBALS["VERBOSE"]) {
$time = $unix->file_time_min($TimeFile);
if ($time < 14) {
echo "Current {$time}Mn, require at least 14mn\n";
return;
}
}
}
$tmpfileSource = $unix->FILE_TEMP();
$year = date("Y");
@copy("/var/log/mail.log", $tmpfileSource);
$binary = "/usr/share/artica-postfix/bin/pflogsumm.pl";
@chmod("{$binary}", 0755);
system("{$binary} -d today {$tmpfileSource} >{$tmpfile}");
@unlink($tmpfileSource);
ParseReport($tmpfile);
@unlink($tmpfile);
stats_total(true);
}
示例13: duplicate_wordpress
function duplicate_wordpress($servername)
{
$unix = new unix();
$q = new mysql();
$free = new freeweb($servername);
$WORKING_DIRECTORY = $free->www_dir;
if ($free->groupware_duplicate == null) {
build_progress("{$servername}: {duplicate} {$servername} no duplicate set...", 42);
sleep(2);
return false;
}
$free2 = new freeweb($free->groupware_duplicate);
if ($free2->mysql_database == null) {
echo "Fatal: {$free->groupware_duplicate} did not have any such DB set, try to find it..\n";
$free2->mysql_database = $free2->CreateDatabaseName();
echo "Fatal: {$free->groupware_duplicate} = {$free2->mysql_database}\n";
}
if (!$q->DATABASE_EXISTS($free2->mysql_database, true)) {
build_progress("{$servername}: {duplicate} {$free->groupware_duplicate} did not have any database...", 42);
sleep(2);
return false;
}
$srcdir = $free2->www_dir;
$Mysqlpassword = null;
$cp = $unix->find_program("cp");
$rm = $unix->find_program("rm");
if (@is_link($WORKING_DIRECTORY)) {
$WORKING_DIRECTORY = @readlink($WORKING_DIRECTORY);
}
if (is_dir($WORKING_DIRECTORY)) {
build_progress("{$servername}: {removing} {$WORKING_DIRECTORY}...", 42);
sleep(2);
shell_exec("{$rm} -rf {$WORKING_DIRECTORY}/*");
}
@mkdir($WORKING_DIRECTORY, 0755, true);
build_progress("{$servername}: {installing} {from} {$srcdir}...", 42);
shell_exec("{$cp} -rf {$srcdir}/* {$WORKING_DIRECTORY}/");
$wordpressDB = $free->mysql_database;
if ($wordpressDB == null) {
$wordpressDB = $free->CreateDatabaseName();
}
if ($q->DATABASE_EXISTS($wordpressDB)) {
build_progress("{$servername}: {remove_database} {$wordpressDB}...", 42);
sleep(2);
if (!$q->DELETE_DATABASE($wordpressDB)) {
build_progress("{$servername}: {remove_database} {$wordpressDB} {failed}...", 42);
return false;
}
if (!$q->CREATE_DATABASE($wordpressDB, true)) {
build_progress("{$servername}: {create_database} {$wordpressDB} {failed}...", 42);
return false;
}
}
if (!$q->DATABASE_EXISTS($wordpressDB)) {
if (!$q->CREATE_DATABASE($wordpressDB, true)) {
build_progress("{$servername}: {create_database} {$wordpressDB} {failed}...", 42);
return false;
}
}
build_progress("{$servername}: {backup_database} {from} {$free2->mysql_database}...", 42);
$mysqldump = $unix->find_program("mysqldump");
$q = new mysql();
if ($q->mysql_password != null) {
$Mysqlpassword = " -p" . $unix->shellEscapeChars($q->mysql_password);
}
$t = time();
$TMP_FILE = $unix->FILE_TEMP();
$cmdline = trim("{$mysqldump} --add-drop-table --single-transaction --force --insert-ignore -S /var/run/mysqld/mysqld.sock -u {$q->mysql_admin}{$Mysqlpassword} {$free2->mysql_database} >{$TMP_FILE} 2>&1");
if ($GLOBALS["VERBOSE"]) {
echo "{$cmdline}\n";
}
$results = array();
exec($cmdline, $results);
while (list($num, $ligne) = each($results)) {
echo "{$ligne}\n";
if (preg_match("#ERROR\\s+([0-9]+)#", $ligne)) {
build_progress("{$servername}: {restore_database} {to} {$wordpressDB} {failed}..", 42);
sleep(3);
return false;
}
}
build_progress("{$servername}: {restore_database} {to} {$wordpressDB}..", 42);
$mysqlbin = $unix->find_program("mysql");
$cmd = "{$mysqlbin} --batch --force -S /var/run/mysqld/mysqld.sock -u {$q->mysql_admin}{$Mysqlpassword} --database={$wordpressDB} <{$TMP_FILE} 2>&1";
if ($GLOBALS["VERBOSE"]) {
echo "{$cmd}\n";
}
exec($cmd, $results);
while (list($num, $ligne) = each($results)) {
echo "{$ligne}\n";
if (preg_match("#ERROR\\s+([0-9]+)#", $ligne)) {
build_progress("{$servername}: {restore_database} {to} {$wordpressDB} {failed}..", 42);
sleep(3);
return false;
}
}
build_progress("{$servername}: {restore_database} {to} {$wordpressDB}..{done}", 42);
@unlink($TMP_FILE);
if (!scan($WORKING_DIRECTORY)) {
build_progress("{$servername}: {install} {failed}", 42);
//.........这里部分代码省略.........
示例14: parse
function parse($filename)
{
$unix = new unix();
$LastScannLine = 0;
$GLOBALS["MYSQL_CATZ"] = new mysql_catz();
$GLOBALS["SQUID_FAMILY_CLASS"] = new squid_familysite();
if (!isset($GLOBALS["MYHOSTNAME"])) {
$unix = new unix();
$GLOBALS["MYHOSTNAME"] = $unix->hostname_g();
}
$filesource = dirname(__FILE__) . "/ressources/conf/upload/{$filename}";
if (!is_file($filesource)) {
build_progress(110, "{$filename} no such file");
return;
}
$tmpfile = $unix->FILE_TEMP();
if (!@copy($filesource, $tmpfile)) {
@unlink($filesource);
build_progress(110, "{$filename} -> {$tmpfile} {failed}");
return;
}
@unlink($filesource);
$SumOflines = $unix->COUNT_LINES_OF_FILE($tmpfile);
echo "{$tmpfile} {$SumOflines} lines\n";
$handle = @fopen($tmpfile, "r");
if (!$handle) {
echo "Fopen failed on {$tmpfile}\n";
build_progress(110, "{$tmpfile} {failed}");
@unlink($tmpfile);
return false;
}
$c = 0;
$d = 0;
$e = 0;
$prc = 0;
$prc_text = 0;
$mysql_first_time = 0;
$SITES = array();
$NOT_CATEGORIZED = array();
$CATEGORIZED = array();
$RQS = array();
$IPClass = new IP();
$FIRSTTIME = 0;
$LASTTIME = 0;
$TIME1 = time();
while (!feof($handle)) {
$c++;
$d++;
$e++;
$prc = $c / $SumOflines;
$prc = round($prc * 100);
$buffer = trim(fgets($handle));
if ($buffer == null) {
continue;
}
$stats_sites = count($SITES);
$stats_categorized = count($CATEGORIZED);
$stats_not_categorized = count($NOT_CATEGORIZED);
if (!isset($GLOBALS["LAST_PRC"])) {
build_progress($prc, "{$c}/{$SumOflines} {please_wait}");
$GLOBALS["LAST_PRC"] = $prc;
}
if ($prc > 5) {
if ($prc < 95) {
if ($GLOBALS["LAST_PRC"] != $prc) {
$array_load = sys_getloadavg();
$internal_load = $array_load[0];
$mem = round(memory_get_usage() / 1024 / 1000, 2);
echo "Load: {$internal_load}, Memory {$mem}MB\n";
echo "Categorized: " . FormatNumber($stats_categorized) . "\n";
echo "Unknown....: " . FormatNumber($stats_not_categorized) . "\n";
echo "Web sites..: " . FormatNumber($stats_sites) . "\n";
build_progress($prc, FormatNumber($c) . "/" . FormatNumber($SumOflines) . " {please_wait} - {$mem}MB {memory}");
$GLOBALS["LAST_PRC"] = $prc;
}
}
}
$array = parseAccessLine($buffer);
if (count($array) == 0) {
continue;
}
$TIME = $array["TIME"];
$LASTTIME = $TIME;
if ($FIRSTTIME == 0) {
$FIRSTTIME = $TIME;
}
$CATEGORY = $array["CATEGORY"];
$FAMILYSITE = $array["FAMILYSITE"];
$SIZE = intval($array["SIZE"]);
if ($IPClass->isIPAddress($FAMILYSITE)) {
if (!isset($IPADDRESSES[$FAMILYSITE]["RQS"])) {
$IPADDRESSES[$FAMILYSITE]["RQS"] = 1;
$IPADDRESSES[$FAMILYSITE]["SIZE"] = 0;
$IPADDRESSES[$FAMILYSITE]["CATEGORY"] = $CATEGORY;
} else {
$IPADDRESSES[$FAMILYSITE]["RQS"] = $IPADDRESSES[$FAMILYSITE]["RQS"] + 1;
$IPADDRESSES[$FAMILYSITE]["SIZE"] = $IPADDRESSES[$FAMILYSITE]["SIZE"] + $SIZE;
}
continue;
}
//.........这里部分代码省略.........
示例15: vxvault
function vxvault()
{
$unix = new unix();
$q = new mysql_squid_builder();
$curl = new ccurl("http://vxvault.net/URL_List.php");
$targetpath = $unix->FILE_TEMP();
if (!$curl->GetFile($targetpath)) {
if ($GLOBALS["VERBOSE"]) {
echo "DOWNLOAD FAILED {$targetpath}\n";
}
@unlink($targetpath);
return false;
}
$lastmd5 = @file_get_contents("/etc/artica-postfix/settings/Daemons/vxvault.md5");
$Currentmd5 = md5_file($targetpath);
if (!$GLOBALS["FORCE"]) {
if ($lastmd5 == $Currentmd5) {
return;
}
}
$fp = @fopen($targetpath, "r");
if (!$fp) {
if ($GLOBALS["DEBUG_GREP"]) {
echo "{$targetpath} BAD FD\n";
}
@unlink($targetpath);
return array();
}
$c = 0;
$t = array();
while (!feof($fp)) {
$line = trim(fgets($fp));
$line = str_replace("\r\n", "", $line);
$line = str_replace("\n", "", $line);
$line = str_replace("\r", "", $line);
$line = str_replace("\\", "/", $line);
if (!preg_match("#^http#", $line)) {
if ($GLOBALS["VERBOSE"]) {
echo "SKIP {$line}\n";
}
continue;
}
if (preg_match("#http:\\/\\/(.+?)#", $line, $re)) {
$line = $re[1];
}
if (preg_match("#https:\\/\\/(.+?)#", $line, $re)) {
$line = $re[1];
}
$md5 = md5($line);
$SQLZ[] = "('{$md5}',NOW(),'{$line}',1)";
if (count($SQLZ) > 500) {
$q->QUERY_SQL($GLOBALS["PREFIX"] . @implode(",", $SQLZ));
if (!$q->ok) {
echo $q->mysql_error;
@fclose($fp);
@unlink($targetpath);
return;
}
}
}
@fclose($fp);
@unlink($targetpath);
if (count($SQLZ) > 0) {
$q->QUERY_SQL($GLOBALS["PREFIX"] . @implode(",", $SQLZ));
if (!$q->ok) {
echo $q->mysql_error;
return;
}
}
@file_put_contents("/etc/artica-postfix/settings/Daemons/vxvault.md5", $Currentmd5);
}