示例#1
0
    if (DIRECTORY_SEPARATOR == '/') {
        # Unix/Linux
        $pidfile = "/tmp/ocsng_fullsync.pid";
    } else {
        # Windows
        $pidfile = GLPI_LOG_DIR . "/ocsng_fullsync.pid";
    }
}
$logfilename = GLPI_LOG_DIR . "/ocsng_fullsync.log";
if (!is_writable(GLPI_LOCK_DIR)) {
    echo "\tERROR : " . GLPI_LOCK_DIR . " not writable\n";
    echo "\trun script as 'apache' user\n";
    exit(1);
}
$log = fopen($logfilename, "at");
readargs();
exit_if_soft_lock();
exit_if_already_running($pidfile);
cleanup($pidfile);
//Only available with PHP5 or later
file_put_contents($pidfile, getmypid());
fwrite($log, date("r") . " " . $_SERVER["argv"][0] . " started\n");
$cmd = "php -q -d -f ocsng_fullsync.php --ocs_server_id={$server_id} --managedeleted=1";
$out = array();
$ret = 0;
exec($cmd, $out, $ret);
foreach ($out as $line) {
    fwrite($log, $line . "\n");
}
if (function_exists("pcntl_fork")) {
    # Unix/Linux
示例#2
0
				if (!isset($commands[$command]['options'])
				    || !isset($commands[$command]['options'][$arg])) {
					usage(1);
				} else {
					$coption[]=$arg;
				}
			}
		} else {
			if ($command === NULL) {
				// this is the command
				if (!isset($commands[$arg])) {
					usage(1);
				} else {
					$command=$arg;
				}
			} else {
				// command parameter
				$cparams[]=$arg;
			}
		}
	}

	if ($command === NULL) {
		usage(1);
	} else {
		$func='command_'.$command;
		$func($goption, $coption, $cparams);
	}
}
readargs($argv);