作者:BillTheBes
项目:1.6.
function schedules()
{
@unlink("/etc/cron.d/apt-mirror");
$php = LOCATE_PHP5_BIN2();
$file = __FILE__;
$sock = new sockets();
shell_exec("/bin/rm -f /etc/cron.d/apt-mirror-* >/dev/null 2>&1");
$config = unserialize(base64_decode($sock->GET_INFO("AptMirrorConfigSchedule")));
if (!is_array($config)) {
return;
}
$count = 0;
while (list($uid, $schedule) = each($config)) {
if (trim($schedule) == 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[] = "{$schedule} root {$php} {$file} --perform >/dev/null 2>&1";
$f[] = "";
@file_put_contents("/etc/cron.d/apt-mirror-{$count}", @implode("\n", $f));
$count++;
unset($f);
}
shell_exec("/etc/init.d/cron reload");
}
作者:BillTheBes
项目:1.6.
function status()
{
$cmd = LOCATE_PHP5_BIN2() . " /usr/share/artica-postfix/exec.status.php --transmission-daemon --nowachdog";
exec($cmd, $results);
writelogs_framework($cmd . " ->" . count($results) . " lines", __FUNCTION__, __FILE__, __LINE__);
echo "<articadatascgi>" . base64_encode(implode("\n", $results)) . "</articadatascgi>";
}
作者:rs
项目:artica-1.
function schedules_mldonkey(){
@unlink("/etc/artica-postfix/mldonkey.tasks");
$sql="SELECT * FROM mldonkey ORDER BY schedule_time DESC";
$q=new mysql();
$results=$q->QUERY_SQL($sql,"artica_backup");
while($ligne=mysql_fetch_array($results,MYSQL_ASSOC)){
$params=unserialize(base64_decode($ligne["parameters"]));
$params["hours"];
$params["minutes"];
if($params["minutes"]==null){$params["minutes"]="59";}
if($params["hours"]==null){$params["hours"]="0";}
$f[]="{$params["minutes"]} {$params["hours"]} * * * ".LOCATE_PHP5_BIN2()." ".dirname(__FILE__)."/exec.mldonkey.php --settings {$ligne["ID"]}";
}
if(is_array($f)){
@file_put_contents("/etc/artica-postfix/mldonkey.tasks",@implode("\n",$f));
}
}
作者:rs
项目:artica-1.
function Parseline($buffer){
$buffer=trim($buffer);
if($buffer==null){return null;}
if(strpos($buffer,"init urllist")>0){return ;}
if(strpos($buffer,"init expressionlist")>0){return ;}
if(strpos($buffer,"init domainlist")>0){return ;}
if(preg_match('#INFO: loading dbfile (.+)#',$buffer,$re)){
events("LOADING $re[1]");
$GLOBALS[__FILE__]["DBFILE"]=trim($re[1]);
return null;
}
if(preg_match("#FATAL: Error db_open: Unknown error#",$buffer,$re)){
events("ERROR ON {$GLOBALS[__FILE__]["DBFILE"]}");
$file="/etc/artica-postfix/croned.1/squidguard.". md5($GLOBALS[__FILE__]["DBFILE"]).".error";
if(IfFileTime($file)){
shell_exec(LOCATE_PHP5_BIN2()." /usr/share/artica-postfix/exec.squidguard.php --compile-single \"{$GLOBALS[__FILE__]["DBFILE"]}\" &");
WriteFileCache($file);
}
return null;
}
if(strpos($buffer,"ERROR: Going into emergency mode")>0){
events("ERROR: Going into emergency mode");
send_email_events("squidguard: squidguard turn to emergency mode","SquidGuard claim\n$buffer\nPlease contact your support to fix this problem\ncurrently, no filtering urls will be enabled","proxy");
return ;
}
events("Not filtered: $buffer");
}
作者:brucewu1689
项目:artic
$GLOBALS["bcc_maps"] = array();
$GLOBALS["transport_maps"] = array();
$GLOBALS["smtp_generic_maps"] = array();
if (!is_file($GLOBALS["postfix"])) {
die;
}
if (!Build_pid_func(__FILE__, $argv[1])) {
echo "Starting......: Already executed\n";
}
$ldap = new clladp();
if ($ldap->ldapFailed) {
echo "Starting......: failed connecting to ldap server {$ldap->ldap_host}\n";
die;
}
if ($GLOBALS["EnablePostfixMultiInstance"] == 1) {
system(LOCATE_PHP5_BIN2() . " " . dirname(__FILE__) . "/exec.postfix-multi.php");
die;
}
if ($argv[1] == "--postmaster") {
postmaster();
die;
}
if ($argv[1] == "--bcc") {
recipient_bcc_maps();
recipient_bcc_maps_build();
sender_bcc_maps();
sender_bcc_maps_build();
shell_exec("{$GLOBALS["postfix"]} reload >/dev/null 2>&1");
die;
}
if ($argv[1] == "--recipient-canonical") {
作者:BillTheBes
项目:1.6.
function ParseResolvMX()
{
$sock = new sockets();
$WhiteListResolvMX = $sock->GET_INFO("WhiteListResolvMX");
if (!is_numeric($WhiteListResolvMX)) {
return null;
}
if ($WhiteListResolvMX == 0) {
return null;
}
if (!function_exists("getmxrr")) {
echo "getmxrr() no such function\n";
return;
}
$sql = "SELECT sender FROM postfix_global_whitelist WHERE enabled=1 ORDER BY sender";
if ($GLOBALS["VERBOSE"]) {
echo $sql . "\n";
}
$q = new mysql();
if (!$q->TestingConnection()) {
echo "ParseResolvMX()/" . basename(__FILE__) . " Connection to MySQL server failed...\n";
return;
}
$results = $q->QUERY_SQL($sql, "artica_backup");
if (!$q->ok) {
echo $q->mysql_error;
return;
}
$q = new mysql();
$sql = "SELECT * FROM postfix_whitelist_con";
$results = $q->QUERY_SQL($sql, "artica_backup");
if (!$q->ok) {
echo "{$q->mysql_error}\n";
}
while ($ligne = mysql_fetch_array($results, MYSQL_ASSOC)) {
$WHITELISTED[$ligne["ipaddr"]] = true;
$WHITELISTED[$ligne["hostname"]] = true;
}
$count_whitelisted_before = count($WHITELISTED);
while ($ligne = @mysql_fetch_array($results, MYSQL_ASSOC)) {
$domain = trim($ligne["sender"]);
if ($domain == null) {
continue;
}
if (preg_match("#@(.+)#", $domain, $re)) {
$domain = $re[1];
}
if (strpos($domain, "*") > 0) {
continue;
}
$array_mx = resolvMX($domain);
if (count($array_mx) == 0) {
continue;
}
echo "{$domain} = " . count($array_mx) . " mx\n";
while (list($ipaddr, $hostname) = each($array_mx)) {
$notif[] = "{$domain}: {$hostname} [{$ipaddr}]";
$WHITELISTED[$ipaddr] = $hostname;
}
}
$count_whitelisted_after = count($WHITELISTED);
$somme = $count_whitelisted_after - $count_whitelisted_before;
if ($somme == 0) {
echo "Nothing to do...\n";
return;
}
if ($somme > 0) {
if ($GLOBALS["VERBOSE"]) {
echo "{$somme} items added in array\n" . @implode("\n", $notif);
}
$unix = new unix();
$unix->send_email_events("{$somme} items MX has been whitelisted", @implode("\n", $notif), "postfix");
}
reset($WHITELISTED);
while (list($value, $hostname) = each($WHITELISTED)) {
if (trim($value) == null) {
continue;
}
$sql = "DELETE FROM iptables WHERE serverip='{$value}' AND local_port=25";
$q->QUERY_SQL($sql, "artica_backup");
$sql = "INSERT IGNORE INTO postfix_whitelist_con (ipaddr,hostname) VALUES('{$value}','{$hostname}')";
$q->QUERY_SQL($sql, "artica_backup");
}
$cmd = LOCATE_PHP5_BIN2() . " /usr/share/artica-postfix/exec.postfix.maincf.php --postscreen";
shell_exec($cmd);
}
作者:rs
项目:artica-1.
function reconfigure(){
if($GLOBALS["VERBOSE"]){writelogs("starting reconfigure()",__FUNCTION__,__FILE__,__LINE__);}
$unix=new unix();
$sock=new sockets();
if($GLOBALS["VERBOSE"]){writelogs("->clladp()",__FUNCTION__,__FILE__,__LINE__);}
$ldap=new clladp();
$smbpasswd=$unix->find_program("smbpasswd");
if($GLOBALS["VERBOSE"]){writelogs("smbpasswd=$smbpasswd -->samba()",__FUNCTION__,__FILE__,__LINE__);}
$samba=new samba();
$net=$unix->LOCATE_NET_BIN_PATH();
$ldap_passwd=$ldap->ldap_password;
$EnableSambaActiveDirectory=$sock->GET_INFO("EnableSambaActiveDirectory");
$EnableSambaRemoteLDAP=$sock->GET_INFO("EnableSambaRemoteLDAP");
if($EnableSambaRemoteLDAP==1){
$SambaRemoteLDAPInfos=unserialize(base64_decode($sock->GET_INFO("SambaRemoteLDAPInfos")));
$ldap_passwd=$SambaRemoteLDAPInfos["user_dn_password"];
}
if($EnableSambaActiveDirectory==1){activedirectory();}
CheckFilesAndDirectories();
FixsambaDomainName();
echo "Starting......: Samba building main configuration...\n";
@file_put_contents("/etc/samba/smb.conf",$samba->BuildConfig());
shell_exec("$smbpasswd -w $ldap_passwd");
SambaAudit();
fixEtcHosts();
$master_password=$samba->GetAdminPassword("administrator");
$SambaEnableEditPosixExtension=$sock->GET_INFO("SambaEnableEditPosixExtension");
if($SambaEnableEditPosixExtension==1){
$cmd="$net idmap secret {$samba->main_array["global"]["workgroup"]} \"$ldap_passwd\" >/dev/null 2>&1 &";
shell_exec($cmd);
$cmd="$net idmap secret alloc \"$ldap_passwd\" >/dev/null 2>&1 &";
shell_exec($cmd);
}
if($EnableSambaActiveDirectory==1){kinit();}
$unix->THREAD_COMMAND_SET(LOCATE_PHP5_BIN2()." ".__FILE__." --check-dirs");
$unix->THREAD_COMMAND_SET("/usr/share/artica-postfix/bin/artica-install --samba-reconfigure");
reload();
}
作者:BillTheBes
项目:1.6.
function _CheckSambaConfig()
{
if (!is_file("/etc/artica-postfix/settings/Daemons/SambaSMBConf")) {
@copy("/etc/samba/smb.conf", "/etc/artica-postfix/settings/Daemons/SambaSMBConf");
$EXEC_NICE = EXEC_NICE();
shell_exec("{$EXEC_NICE}" . LOCATE_PHP5_BIN2() . " " . dirname(__FILE__) . "/exec.artica.meta.users.php --export-all-settings");
}
}
作者:brucewu1689
项目:1.6.
$unix = new unix();
if ($GLOBALS["VERBOSE"]) {
echo " --> /etc/hosts {$ComputerRealName} -> {$ip}\n";
}
$unix->del_EtcHosts($ip);
$dns = new pdns($GLOBALS["domain"]);
writelogs("EditIPName -> ComputerRealName=`{$ComputerRealName}` {$ip} {$MAC}", __FUNCTION__, __FILE__, __LINE__);
if (trim($ComputerRealName) != null) {
$dns->EditIPName(strtolower($ComputerRealName), $ip, 'A', $MAC);
}
$GLOBALS["FIXIPHOST"] = true;
}
}
if ($GLOBALS["FIXIPHOST"]) {
writelogs("-> exec.samba.php --fix-etc-hosts", __FUNCTION__, __FILE__, __LINE__);
shell_exec(LOCATE_PHP5_BIN2() . " " . dirname(__FILE__) . "/exec.samba.php --fix-etc-hosts");
}
events("Set content cache has {$md5}", "main", __LINE__);
$sock->SET_INFO('DHCPLeaseMD5', $md5);
function events($text, $function, $line)
{
writelogs($text, $function, __FILE__, $line);
}
function Changed()
{
if (!is_file("/var/lib/dhcp3/dhcpd.leases")) {
if ($GLOBALS["VERBOSE"]) {
echo " --> unable to stat /var/lib/dhcp3/dhcpd.leases\n";
}
return false;
}
作者:brucewu1689
项目:1.6.
function execute()
{
$nice = EXEC_NICE();
if (is_file(dirname(__FILE__) . "/exec.sarg.gilou.php")) {
events("Executing exec.sarg.gilou.php instead...");
shell_exec($nice . LOCATE_PHP5_BIN2() . " " . dirname(__FILE__) . "/exec.sarg.gilou.php --exec");
return;
}
$sock = new sockets();
$SargOutputDir = $sock->GET_INFO("SargOutputDir");
if ($SargOutputDir == null) {
$SargOutputDir = "/var/www/html/squid-reports";
}
$nice = EXEC_NICE();
$unix = new unix();
$today = date("d/m/Y");
$sarg_bin = $unix->find_program("sarg");
if (!is_file($sarg_bin)) {
sarg_admin_events("Fatal, unable to locate sarg binary, aborting...", __FUNCTION__, __FILE__, __LINE__, "sarg");
return;
}
events("Building settings..");
buildconf();
$usersauth = false;
$squid = new squidbee();
if ($squid->LDAP_AUTH == 1) {
$usersauth = true;
}
if ($squid->LDAP_EXTERNAL_AUTH == 1) {
$usersauth = true;
}
if (!is_file("/etc/squid/exclude_codes")) {
@file_put_contents("/etc/squid/exclude_codes", "\nNONE/400\n");
}
@mkdir("{$SargOutputDir}", 0755, true);
$u = " -i ";
$cmd = "{$nice}{$sarg_bin} -d {$today}-{$today} {$u}-f /etc/squid3/sarg.conf -l /var/log/squid/access.log -o \"{$SargOutputDir}\" -x -z 2>&1";
$t1 = time();
echo "Starting......: " . date("H:i:s") . " [INIT]: {$GLOBALS["TITLENAME"]}, {$cmd}\n";
sargevents("execute(): {$cmd}");
exec($cmd, $results);
while (list($index, $line) = each($results)) {
if (preg_match("#SARG: No records found#", $line)) {
events("No records found");
$subject_add = "(No records found)";
}
if (preg_match("#SARG:\\s+.+?mixed records format#", $line)) {
send_email_events("SARG: Error, squid was reloaded", "It seems that there is a mixed log file format detected in squid\n\t\t\tThis reason is Artica change squid log format from orginial to http access mode.\n\t\t\tIn this case, the log will be moved and squid will be reloaded \n\t\t\tin order to build a full log file with only one log format.\n\t\t\t\n" . @implode("\n", $results), "proxy");
shell_exec(LOCATE_PHP5_BIN2() . " " . dirname(__FILE__) . "/exec.squid.php --reconfigure");
shell_exec($unix->LOCATE_SQUID_BIN() . " -k rotate");
shell_exec("/etc/init.d/auth-tail restart >/dev/null 2>&1");
shell_exec("/etc/init.d/cache-tail restart >/dev/null 2>&1");
return;
}
if (preg_match("#SARG:\\s+.+?enregistrements de plusieurs formats#", $line)) {
send_email_events("SARG: Error, squid was reloaded", "It seems that there is a mixed log file format detected in squid\n\t\t\tThis reason is Artica change squid log format from orginial to http access mode.\n\t\t\tIn this case, the log will be moved and squid will be reloaded \n\t\t\tin order to build a full log file with only one log format.\n\t\t\t\n" . @implode("\n", $results), "proxy");
shell_exec(LOCATE_PHP5_BIN2() . " " . dirname(__FILE__) . "/exec.squid.php --reconfigure");
shell_exec($unix->LOCATE_SQUID_BIN() . " -k rotate");
shell_exec("/etc/init.d/auth-tail restart >/dev/null 2>&1");
shell_exec("/etc/init.d/cache-tail restart >/dev/null 2>&1");
return;
}
if (preg_match("#SARG.+?Unknown input log file format#", $line)) {
send_email_events("SARG: \"Unknown input log file format\", squid was reloaded", "It seems that there is a input log file format log file format detected in squid\n\t\t\tThis reason is Artica change squid log format from orginial to log_fqn on, this will be disabled\n\t\t\tIn this case, the log will be moved and squid will be reloaded \n\t\t\tin order to build a full log file with only one log format.\n\t\t\t\n" . @implode("\n", $results), "proxy");
shell_exec(LOCATE_PHP5_BIN2() . " " . dirname(__FILE__) . "/exec.squid.php --reconfigure");
shell_exec($unix->LOCATE_SQUID_BIN() . " -k rotate");
shell_exec("/etc/init.d/auth-tail restart >/dev/null 2>&1");
shell_exec("/etc/init.d/cache-tail restart >/dev/null 2>&1");
return;
}
}
$NICE = EXEC_NICE();
$unix = new unix();
$lighttpd_user = $unix->APACHE_SRC_ACCOUNT();
$php = $unix->LOCATE_PHP5_BIN();
$nohup = $unix->find_program("nohup");
echo "Starting......: " . date("H:i:s") . " [INIT]: {$GLOBALS["TITLENAME"]}, lighttpd user: {$lighttpd_user}\n";
$chown = $unix->find_program("chown");
echo "Starting......: " . date("H:i:s") . " [INIT]: {$GLOBALS["TITLENAME"]},{$chown} -R {$lighttpd_user}:{$lighttpd_user} {$SargOutputDir}/*\n";
exec("{$chown} -R {$lighttpd_user}:{$lighttpd_user} {$SargOutputDir}/* >/dev/null 2>&1", $results2);
echo "Starting......: " . date("H:i:s") . " [INIT]: {$GLOBALS["TITLENAME"]},\n" . @implode("\n" . $results2) . "\n";
shell_exec("{$nohup} {$php} " . __FILE__ . " --backup >/dev/null 2>&1 &");
$t2 = time();
$distanceOfTimeInWords = distanceOfTimeInWords($t1, $t2);
echo "Starting......: " . date("H:i:s") . " [INIT]: {$GLOBALS["TITLENAME"]}, {$distanceOfTimeInWords}\n";
events("Statistics generated ({$distanceOfTimeInWords})");
if ($GLOBALS["VERBOSE"]) {
echo "SARG: Statistics generated ({$distanceOfTimeInWords})\n\n";
echo @implode("\n", $results) . "\n";
}
status(true);
sarg_admin_events("SARG: Statistics generated ({$distanceOfTimeInWords}) {$subject_add}", "Command line:\n-----------\n{$cmd}\n" . @implode("\n", $results), __FUNCTION__, __FILE__, __LINE__, "sarg");
}
作者:brucewu1689
项目:1.6.
function NMAP_SCAN($value)
{
$value = base64_decode($value);
$EXEC_NICE = EXEC_NICE();
$unix = new unix();
$tmpstr = $unix->FILE_TEMP();
@unlink("/usr/share/artica-postfix/ressources/logs/nmap.log");
$cmd = $EXEC_NICE . LOCATE_PHP5_BIN2() . " /usr/share/artica-postfix/exec.scan-networks.php >{$tmpstr} 2>&1";
events("running {$cmd}", __FUNCTION__, __FILE__, __LINE__);
$t1 = time();
shell_exec($cmd);
$t2 = time();
$time_duration = distanceOfTimeInWords($t1, $t2);
events("success executing exec.scan-networks.php ", __FUNCTION__, __FILE__, __LINE__);
send_email_events("success executing network scanning ({$time_duration})", @file_get_contents("/usr/share/artica-postfix/ressources/logs/nmap.log"), "CLOUD");
@unlink($tmpstr);
return true;
}
作者:BillTheBes
项目:1.6.
function zarafa_hash()
{
if (isset($_GET["rebuild"])) {
@unlink("/etc/artica-postfix/zarafa-export.db");
}
if (!is_file("/etc/artica-postfix/zarafa-export.db")) {
$cmd = LOCATE_PHP5_BIN2() . " /usr/share/artica-postfix/exec.zarafa.build.stores.php --export-hash";
shell_exec($cmd);
}
echo "<articadatascgi>" . @file_get_contents("/etc/artica-postfix/zarafa-export.db") . "</articadatascgi>";
}
作者:rs
项目:artica-1.
function zarafa_server(){
if(!$GLOBALS["CLASS_USERS"]->ZARAFA_INSTALLED){
if($GLOBALS["VERBOSE"]){echo __FUNCTION__." not installed\n";}
return null;
}
$enabled=1;
$pid_path="/var/run/zarafa-server.pid";
$master_pid=trim(@file_get_contents($pid_path));
$l[]="[APP_ZARAFA_SERVER]";
$l[]="service_name=APP_ZARAFA_SERVER";
$l[]="master_version=".$GLOBALS["CLASS_UNIX"]->ZARAFA_VERSION();
$l[]="service_cmd=zarafa";
$l[]="service_disabled=$enabled";
$l[]="pid_path=$pid_path";
$l[]="remove_cmd=--zarafa-remove";
$l[]="watchdog_features=1";
$l[]="family=mailbox";
if(!$GLOBALS["CLASS_UNIX"]->process_exists($master_pid)){
WATCHDOG("APP_ZARAFA","zarafa");
$l[]="running=0\ninstalled=1";$l[]="";
}else{
$l[]="running=1";
}
$meme=GetMemoriesOf($master_pid);
$l[]=$meme;
$l[]="";
$l[]="[APP_ZARAFA]";
$l[]="service_name=APP_ZARAFA";
$l[]="master_version=".$GLOBALS["CLASS_UNIX"]->ZARAFA_VERSION();
$l[]="family=mailbox";
$l[]="service_cmd=zarafa";
$l[]="service_disabled=$enabled";
$l[]="pid_path=$pid_path";
$l[]="remove_cmd=--zarafa-remove";
$l[]="watchdog_features=1";
if(!$GLOBALS["CLASS_UNIX"]->process_exists($master_pid)){
WATCHDOG("APP_ZARAFA","zarafa");
$l[]="running=0\ninstalled=1";$l[]="";
return implode("\n",$l);
return;
}
if(!$GLOBALS["DISABLE_WATCHDOG"]){
$nohup=$GLOBALS["CLASS_UNIX"]->find_program("nohup")." ";
if($GLOBALS["PHP5"]==null){$GLOBALS["PHP5"]=LOCATE_PHP5_BIN2();}
$cmd=trim($nohup.$GLOBALS["PHP5"]." ".dirname(__FILE__)."/exec.zarafa.build.stores.php --export-hash >/dev/null 2>&1 &");
events("running $cmd",__FUNCTION__,__LINE__);
shell_exec($cmd);
}
$l[]="running=1";
$l[]=$meme;
$l[]="";
return implode("\n",$l);return;
}
作者:brucewu1689
项目:1.6.
function OPENGOO_INSTALL($servername, $root, $hash = array())
{
$srcfolder = "/usr/local/share/artica/opengoo";
$GLOBALS["ADDLOG"] = "{$GLOBALS["ARTICALOGDIR"]}/{$servername}.log";
$sql_file = "/usr/share/artica-postfix/bin/install/opengoo/opengoo.sql";
if ($root == null) {
events("Starting install opengoo Unable to stat root dir");
return false;
}
if (!is_dir($srcfolder)) {
events("Starting install opengoo Unable to stat SRC");
return false;
}
$user = $hash["wwwmysqluser"][0];
$mysql_password = $hash[strtolower("WWWMysqlPassword")][0];
$appli_user = $hash["wwwappliuser"][0];
$appli_password = $hash["wwwapplipassword"][0];
$wwwsslmode = $hash["wwwsslmode"][0];
$server_database = str_replace(".", "_", $servername);
$server_database = str_replace(" ", "_", $server_database);
$server_database = str_replace("-", "_", $server_database);
events("Starting install opengoo sub-system mysql database {$server_database}...");
if ($user == null) {
events("Starting install opengoo Unable to stat Mysql username");
return false;
}
if ($mysql_password == null) {
events("Starting install opengoo Unable to stat Mysql password");
return false;
}
@mkdir($root, 0755, true);
events("Starting install opengoo sub-system mysql database {$server_database}...");
$q = new mysql();
if (!$q->DATABASE_EXISTS($server_database)) {
$q->CREATE_DATABASE($server_database);
}
if (!$q->DATABASE_EXISTS($server_database)) {
events("Starting install opengoo unable to create MYSQL Database");
return false;
}
events("Starting setting permissions on Database with user {$user}");
$q->PRIVILEGES($user, $mysql_password, $server_database);
if (!OPENGOO_TEST_FILES($root)) {
events("Starting install opengoo installing source code");
shell_exec("/bin/cp -rf {$srcfolder}/* {$root}/");
}
$opengoo = new opengoo(null, $server_database);
if (!OPENGOO_CHECK_TABLES($server_database)) {
if ($q->mysql_password != null) {
$password = " --password={$q->mysql_password} ";
} else {
events("Starting install opengoo installing tables datas with null password");
}
$cmd = "mysql --port={$q->mysql_port} --skip-column-names --database={$server_database} --silent --xml ";
$cmd = $cmd . " --user={$q->mysql_admin}{$password} <{$sql_file}";
shell_exec($cmd);
} else {
events("Starting install opengo Mysql tables are already installed");
}
$sock = new sockets();
$ApacheGroupWarePort = $sock->GET_INFO("ApacheGroupWarePort");
events("Starting install opengo SSL={$wwwsslmode}");
if ($wwwsslmode == "TRUE") {
$ROOT_URL = "https://{$servername}";
} else {
$ROOT_URL = "http://{$servername}:{$ApacheGroupWarePort}";
}
$conf = "<?php\n";
$conf = $conf . "define('DB_ADAPTER', 'mysql');\n";
$conf = $conf . "define('DB_HOST', '127.0.0.1');\n";
$conf = $conf . "define('DB_USER', '{$q->mysql_admin}');\n";
$conf = $conf . "define('DB_PASS', '{$q->mysql_password}');\n";
$conf = $conf . "define('DB_NAME', '{$server_database}');\n";
$conf = $conf . "define('DB_PERSIST', true);\n";
$conf = $conf . "define('TABLE_PREFIX', 'og_');\n";
$conf = $conf . "define('DB_ENGINE', 'InnoDB');\n";
$conf = $conf . "define('ROOT_URL', '{$ROOT_URL}');\n";
$conf = $conf . "define('DEFAULT_LOCALIZATION', 'en_us');\n";
$conf = $conf . "define('COOKIE_PATH', '/');\n";
$conf = $conf . "define('DEBUG', false);\n";
$conf = $conf . "define('SEED', '6eb2551152da5a57576754716397703c');\n";
$conf = $conf . "define('DB_CHARSET', 'utf8');\n";
$conf = $conf . "return true;\n";
$conf = $conf . "?>";
@file_put_contents("{$root}/config/config.php", $conf);
$opengoo->DefaultsValues();
events("updating administrator credentials");
$opengoo->www_servername = $servername;
$opengoo->UpdateAdmin($appli_user, $appli_password);
events("updating company name");
$ou = $opengoo->get_Organization($servername);
$opengoo->UpdateCompany($ou);
$unix = new unix();
$sock = new sockets();
sys_THREAD_COMMAND_SET(LOCATE_PHP5_BIN2() . " /usr/share/artica-postfix/exec.opengoo.php");
}
作者:BillTheBes
项目:1.6.
function status()
{
exec(LOCATE_PHP5_BIN2() . " /usr/share/artica-postfix/exec.status.php --squidguard-http --nowachdog", $results);
writelogs_framework("/usr/share/artica-postfix/exec.status.php --squidguard-http " . count($results) . " rows", __FUNCTION__, __FILE__, __LINE__);
echo "<articadatascgi>" . base64_encode(@implode("\n", $results)) . "</articadatascgi>";
}
作者:brucewu1689
项目:1.6.
function compile_databases()
{
$users = new usersMenus();
$squid = new squidbee();
$array = $squid->SquidGuardDatabasesStatus();
$verb = " -d";
$array = $squid->SquidGuardDatabasesStatus(0);
if (count($array) > 0) {
while (list($index, $file) = each($array)) {
echo "Starting......: squidGuard compiling " . count($array) . " databases\n";
$file = str_replace(".db", '', $file);
$textfile = str_replace("/var/lib/squidguard/", "", $file);
echo "Starting......: squidGuard compiling {$textfile} database " . ($index + 1) . "/" . count($array) . "\n";
if ($GLOBALS["VERBOSE"]) {
$verb = " -d";
echo $users->SQUIDGUARD_BIN_PATH . " {$verb} -C {$file}\n";
}
system($users->SQUIDGUARD_BIN_PATH . " -P{$verb} -C {$file}");
}
} else {
echo "Starting......: squidGuard compiling all databases\n";
if ($GLOBALS["VERBOSE"]) {
$verb = " -d";
echo $users->SQUIDGUARD_BIN_PATH . " {$verb} -C all\n";
}
system($users->SQUIDGUARD_BIN_PATH . " -P{$verb} -C all");
}
$user = GetSquidUser();
$unix = new unix();
$chown = $unix->find_program("chown");
$chmod = $unix->find_program("chmod");
shell_exec("{$chown} -R {$user} /var/lib/squidguard/*");
shell_exec("{$chmod} -R 755 /var/lib/squidguard/*");
system(LOCATE_PHP5_BIN2() . " " . dirname(__FILE__) . "/exec.squid.php --build");
build();
KillSquidGuardInstances();
}
作者:BillTheBes
项目:1.6.
function ufdbguard_remote()
{
include_once dirname(__FILE__) . "/ressources/class.ccurl.inc";
$users = new usersMenus();
$sock = new sockets();
$unix = new unix();
$trace = debug_backtrace();
if (isset($trace[1])) {
$called = " called by " . basename($trace[1]["file"]) . " {$trace[1]["function"]}() line {$trace[1]["line"]}";
}
$timeFile = "/etc/artica-postfix/pids/" . basename(__FILE__) . "." . __FUNCTION__ . ".time";
if ($unix->file_time_min($timeFile) < 5) {
writelogs("too short time to change settings, aborting {$called}...", __FUNCTION__, __FILE__, __LINE__);
return;
}
@unlink($timeFile);
@file_put_contents($timeFile, time());
@mkdir("/etc/ufdbguard", null, true);
$tar = $unix->find_program("tar");
$RemoteStatisticsApplianceSettings = unserialize(base64_decode($sock->GET_INFO("RemoteStatisticsApplianceSettings")));
if (!is_numeric($RemoteStatisticsApplianceSettings["SSL"])) {
$RemoteStatisticsApplianceSettings["SSL"] = 1;
}
if (!is_numeric($RemoteStatisticsApplianceSettings["PORT"])) {
$RemoteStatisticsApplianceSettings["PORT"] = 9000;
}
$GLOBALS["REMOTE_SSERVER"] = $RemoteStatisticsApplianceSettings["SERVER"];
$GLOBALS["REMOTE_SPORT"] = $RemoteStatisticsApplianceSettings["PORT"];
$GLOBALS["REMOTE_SSL"] = $RemoteStatisticsApplianceSettings["SSL"];
if ($GLOBALS["REMOTE_SSL"] == 1) {
$refix = "https";
} else {
$refix = "http";
}
$DenyUfdbWriteConf = $sock->GET_INFO("DenyUfdbWriteConf");
if (!is_numeric($DenyUfdbWriteConf)) {
$DenyUfdbWriteConf = 0;
}
$baseUri = "{$refix}://{$GLOBALS["REMOTE_SSERVER"]}:{$GLOBALS["REMOTE_SPORT"]}/ressources/databases";
if ($DenyUfdbWriteConf == 0) {
$uri = "{$baseUri}/ufdbGuard.conf";
$curl = new ccurl($uri, true);
if ($curl->GetFile("/tmp/ufdbGuard.conf")) {
@file_put_contents("/etc/ufdbguard/ufdbGuard.conf", @file_get_contents("/tmp/ufdbGuard.conf"));
@file_put_contents("/etc/squid3/ufdbGuard.conf", @file_get_contents("/tmp/ufdbGuard.conf"));
} else {
ufdbguard_admin_events("Failed to download ufdbGuard.conf aborting `{$curl->error}`", __FUNCTION__, __FILE__, __LINE__, "global-compile");
}
}
$uri = "{$baseUri}/blacklist.tar.gz";
$curl = new ccurl($uri, true);
if ($curl->GetFile("/tmp/blacklist.tar.gz")) {
$cmd = "{$tar} -xf /tmp/blacklist.tar.gz -C /var/lib/squidguard/";
writelogs($cmd, __FUNCTION__, __FILE__, __LINE__);
shell_exec($cmd);
} else {
ufdbguard_admin_events("Failed to download blacklist.tar.gz aborting `{$curl->error}`", __FUNCTION__, __FILE__, __LINE__, "global-compile");
}
$uri = "{$baseUri}/ftpunivtlse1fr.tar.gz";
$curl = new ccurl($uri, true);
if ($curl->GetFile("/tmp/ftpunivtlse1fr.tar.gz")) {
$cmd = "{$tar} -xf /tmp/ftpunivtlse1fr.tar.gz -C /var/lib/ftpunivtlse1fr/";
writelogs($cmd, __FUNCTION__, __FILE__, __LINE__);
shell_exec($cmd);
} else {
ufdbguard_admin_events("Failed to download ftpunivtlse1fr.tar.gz aborting `{$curl->error}`", __FUNCTION__, __FILE__, __LINE__, "global-compile");
}
Dansguardian_remote();
CheckPermissions();
ufdbguard_schedule();
if ($unix->Ufdbguard_remote_srvc_bool()) {
ufdbguard_admin_events("Using a remote UfdbGuard service, aborting", __FUNCTION__, __FILE__, __LINE__, "config");
return;
}
ufdbguard_admin_events("Service will be rebuiled and restarted", __FUNCTION__, __FILE__, __LINE__, "config");
build_ufdbguard_HUP();
$nohup = $unix->find_program("nohup");
$php5 = $unix->LOCATE_PHP5_BIN();
if (is_file($GLOBALS["SQUIDBIN"])) {
echo "Starting......: " . date("H:i:s") . " Squid reloading service\n";
shell_exec("{$nohup} {$php5} " . basename(__FILE__) . "/exec.squid.php --reconfigure-squid >/dev/null 2>&1");
}
$datas = @file_get_contents("/etc/ufdbguard/ufdbGuard.conf");
send_email_events("SquidGuard/ufdbGuard/Dansguardian rules was rebuilded", basename(__FILE__) . "\nFunction:" . __FUNCTION__ . "\nLine:" . __LINE__ . "\n" . "This is new configuration file of the squidGuard/ufdbGuard:\n-------------------------------------\n{$datas}", "proxy");
shell_exec(LOCATE_PHP5_BIN2() . " " . dirname(__FILE__) . "/exec.c-icap.php --maint-schedule");
}
作者:articatec
项目:artic
//.........这里部分代码省略.........
}
continue;
}
if (preg_match("#WEBGET:(.+)#", $WhatToBackup, $re)) {
if (!isset($BACKUP_WEBGET_ALREADY_DONE[$re[1]])) {
$arr = unserialize(base64_decode($re[1]));
if (!is_array($arr)) {
backup_events($ID, "initialization", "ERROR, WEBGET `{$re[1]}` is not an array...", __LINE__);
continue;
}
backup_events($ID, "initialization", "INFO, Backup remote Artica FreeWebs Website {$arr["RemoteArticaSite"]} from source {$arr["RemoteArticaServer"]}", __LINE__);
backup_webget($ID, $arr);
}
continue;
}
backup_events($ID, "initialization", "INFO, `{$WhatToBackup}` could not understood", __LINE__);
}
}
$sql = "SELECT * FROM backup_folders WHERE taskid={$ID}";
$results = $q->QUERY_SQL($sql, "artica_backup");
if (!$q->ok) {
if (strpos($q->mysql_error, "gone away")) {
backup_events($ID, "personal", "ERROR, mysql {$q->mysql_error} Restarting MySQL server (Patch p.20130807)", __LINE__);
mysql_admin_mysql(0, "Restarting mysql service.", $q->mysql_error, __FILE__, __LINE__);
shell_exec("/etc/init.d/mysql restart");
$q = new mysql();
$results = $q->QUERY_SQL($sql, "artica_backup");
}
}
if (!$q->ok) {
backup_events($ID, "personal", "ERROR, mysql {$q->mysql_error}", __LINE__);
return;
}
while ($ligne = @mysql_fetch_array($results, MYSQL_ASSOC)) {
$dd1 = time();
if ($ligne["recursive"] == 1) {
$recursive = " --recursive";
} else {
$recursive = null;
}
$path = trim(base64_decode($ligne["path"]));
if (!is_dir($path)) {
backup_events($ID, "personal", "ERROR, [{$path}] no such file or directory", __LINE__);
continue;
}
backup_events($ID, "personal", "INFO, Backup starting for {$path}", __LINE__);
send_email_events("Backup Task {$ID}:: Backup starting {$path}", "Backup is running for path {$path}", "backup");
backup_mkdir($path);
$results = backup_copy($path, $path, $ID);
$calculate = distanceOfTimeInWords($dd1, time());
backup_events($ID, "personal", "INFO, Backup finish for {$path}\n{$results} {$calculate}", __LINE__);
}
writelogs(date('m-d H:i:s') . " " . "[TASK {$ID}]: Calculate directory size on {$mount_path_final}", __FUNCTION__, __FILE__, __LINE__);
$du = $unix->find_program("du");
$dut1 = time();
$nice = $unix->EXEC_NICE();
$cmd = "{$nice}{$du} -s {$mount_path_final}";
exec($cmd, $du_results);
$calculate = distanceOfTimeInWords($dut1, time());
$BackupSize = 0;
if (preg_match("#^([0-9]+)\\s+#", @implode("", $du_results), $re)) {
$BackupSize = $re[1];
backup_events($ID, "initialization", "INFO, backup size {$BackupSize} bytes time:{$calculate}", __LINE__);
}
if ($GLOBALS["CAN_CLEAN_CONTAINERS"]) {
backup_events($ID, "initialization", "INFO, cleaning containers....", __LINE__);
CleanContainers($ID, $mount_path_final);
} else {
backup_events($ID, "initialization", "INFO, cannot clean containers, check protocols....", __LINE__);
}
$GLOBAL["BACKUP_MEMORY_SQL"]["mount_path_final"] = $mount_path_final;
$zmd5 = md5("{$GLOBAL["BACKUP_MEMORY_SQL"]["CONTAINER"]}{$GLOBALS["MYSERVERNAME"]}");
$cnx_params = addslashes(base64_encode(serialize($GLOBAL["BACKUP_MEMORY_SQL"])));
$sql = "INSERT IGNORE INTO backup_storages (`taskid`,`size`,`cnx_params`,`zmd5`) VALUES('{$ID}','{$BackupSize}','{$cnx_params}','{$zmd5}')";
$q->QUERY_SQL($sql, "artica_backup");
$sql = "UPDATE backup_storages SET `size`='{$BackupSize}' WHERE `zmd5`='{$zmd5}'";
$q->QUERY_SQL($sql, "artica_backup");
if (!$q->ok) {
backup_events($ID, "initialization", "ERROR, {$q->mysql_error}", __LINE__);
}
if (!$GLOBALS["NO_UMOUNT"]) {
writelogs(date('m-d H:i:s') . " " . "[TASK {$ID}]:umount {$mount_path_final}", __FUNCTION__, __FILE__, __LINE__);
if (preg_match("#^\\/opt\\/artica\\/mounts\\/backup\\/[0-9]+(.+)#", $mount_path_final, $re)) {
$mount_path_final = str_replace($re[1], "", $mount_path_final);
writelogs(date('m-d H:i:s') . " " . "[TASK {$ID}]:translated to {$mount_path_final}", __FUNCTION__, __FILE__, __LINE__);
}
backup_events($ID, "initialization", "INFO, umount {$mount_path_final}", __LINE__);
writelogs(date('m-d H:i:s') . " " . "[TASK {$ID}]:umount {$mount_path_final}", __FUNCTION__, __FILE__, __LINE__);
exec("umount -l {$mount_path_final} 2>&1", $resultsUmount);
if (count($resultsUmount) > 0) {
writelogs(date('m-d H:i:s') . " " . "[TASK {$ID}]:umount : ----- \n" . @implode("\n", $resultsUmount) . "\n", __FUNCTION__, __FILE__, __LINE__);
}
}
$date_end = time();
$calculate = distanceOfTimeInWords($date_start, $date_end);
backup_events($ID, "TIME", "INFO, Time: {$calculate} ({$mount_path_final})", __LINE__);
backup_events($ID, "initialization", "INFO, Backup task terminated", __LINE__);
send_email_events("Backup Task {$ID}:: Backup stopping", "Backup is stopped", "backup");
shell_exec(LOCATE_PHP5_BIN2() . " " . dirname(__FILE__) . "/exec.cleanfiles.php");
}
作者:articatec
项目:artic
function create_user($filename)
{
$tpl = new templates();
$unix = new unix();
$nohup = null;
$path = "/usr/share/artica-postfix/ressources/logs/web/create-users/{$filename}";
echo "Path:{$path}\n";
build_progress("Open {$filename}", 10);
if (!is_file($path)) {
echo "{$path} no such file...\n";
return false;
}
$MAIN = unserialize(base64_decode(@file_get_contents($path)));
build_progress("Create new member {$MAIN["login"]}", 15);
$users = new user($MAIN["login"]);
if ($users->password != null) {
echo "User already exists {$MAIN["login"]}\n";
build_progress("{account_already_exists}", 110);
@unlink($path);
return;
}
$ou = $MAIN["ou"];
$password = url_decode_special_tool($MAIN["password"]);
$MAIN["firstname"] = url_decode_special_tool($MAIN["firstname"]);
$MAIN["lastname"] = url_decode_special_tool($MAIN["lastname"]);
build_progress("{$MAIN["firstname"]} {$MAIN["lastname"]}", 20);
if (trim($MAIN["internet_domain"]) == null) {
$MAIN["internet_domain"] = "localhost.localdomain";
}
echo "Add new user {$MAIN["login"]} {$MAIN["ou"]} {$MAIN["gpid"]}\n";
$users->ou = $MAIN["ou"];
$users->password = url_decode_special_tool($MAIN["password"]);
$users->mail = "{$MAIN["email"]}@{$MAIN["internet_domain"]}";
$users->DisplayName = "{$MAIN["firstname"]} {$MAIN["lastname"]}";
$users->givenName = $MAIN["firstname"];
$users->sn = $MAIN["lastname"];
$users->group_id = $MAIN["gpid"];
$users->homeDirectory = "/home/{$MAIN["login"]}";
if (is_numeric($MAIN["gpid"])) {
$gp = new groups($MAIN["gpid"]);
echo "privileges: {$MAIN["gpid"]} -> AsComplexPassword = \"{$gp->Privileges_array["AsComplexPassword"]}\"\n";
if ($gp->Privileges_array["AsComplexPassword"] == "yes") {
$ldap = new clladp();
$hash = $ldap->OUDatas($ou);
$privs = $ldap->_ParsePrivieleges($hash["ArticaGroupPrivileges"], array(), true);
$policiespwd = unserialize(base64_decode($privs["PasswdPolicy"]));
if (is_array($policiespwd)) {
$priv = new privileges();
if (!$priv->PolicyPassword($password, $policiespwd)) {
build_progress("Need complex password", 110);
echo "Need complex password";
@unlink($path);
return;
}
}
}
}
build_progress("{$MAIN["firstname"]} {$MAIN["lastname"]} {save}", 25);
if (!$users->add_user()) {
echo $users->error . "\n" . $users->ldap_error;
build_progress("{failed}", 110);
@unlink($path);
return;
}
@mkdir("{$users->homeDirectory}");
@chown("{$users->homeDirectory}", $users->uid);
if ($MAIN["ByZarafa"] == "yes") {
$terminated = " >/dev/null";
$zarafa_admin = $unix->find_program("zarafa-admin");
if (!$GLOBALS["WAIT"]) {
$nohup = $unix->find_program("nohup");
$terminated = null;
}
if (isset($MAIN["ZARAFA_LANG"])) {
$users->SaveZarafaMbxLang($MAIN["ZARAFA_LANG"]);
$langcmd = " --lang {$MAIN["ZARAFA_LANG"]} ";
}
$ldap = new clladp();
$dn = "ou={$MAIN["ou"]},dc=organizations,{$ldap->suffix}";
$upd["objectClass"] = "zarafa-company";
$upd["cn"] = $MAIN["ou"];
if (!$ldap->Ldap_add_mod("{$dn}", $upd)) {
echo $ldap->ldap_last_error;
build_progress("{failed} OpenLDAP Error", 110);
@unlink($path);
return;
}
build_progress("{create_store} {language}: {$MAIN["ZARAFA_LANG"]}", 30);
$cmd = "{$nohup} {$zarafa_admin} {$langcmd}--create-store {$MAIN["login"]} >/dev/null 2>&1 &";
system(trim($cmd));
if (!$GLOBALS["WAIT"]) {
$sock = new sockets();
$sock->getFrameWork("cmd.php?zarafa-hash=yes&rebuild=yes");
return;
}
@unlink("/usr/share/artica-postfix/ressources/databases/ZARAFA_DB_STATUS.db");
@unlink("/etc/artica-postfix/zarafa-export.db");
$cmd = LOCATE_PHP5_BIN2() . " /usr/share/artica-postfix/exec.zarafa.build.stores.php --export-hash";
build_progress("{export_stores_data}", 35);
echo "{$cmd}\n";
//.........这里部分代码省略.........
作者:brucewu1689
项目:artic
function OCSWEB_FINAL_CERTIFICATE()
{
$path = base64_decode($_GET["path"]);
if (!is_file($path)) {
return null;
}
shell_exec("/bin/cp {$path} /etc/artica-postfix/settings/Daemons/OCSServerDotCrt");
shell_exec("/bin/cp {$path} /etc/ocs/cert/server.crt");
shell_exec(LOCATE_PHP5_BIN2() . " /usr/share/artica-postfix/exec.ocsweb.php --final-cert");
sys_THREAD_COMMAND_SET("/etc/init.d/artica-postfix restart ocsweb");
}