function build(){ CheckHttpdConf(); RemoveAllSites(); create_cron_task(); $sock=new sockets(); $unix=new unix(); $varWwwPerms=$sock->GET_INFO("varWwwPerms"); if($varWwwPerms==null){$varWwwPerms=755;} remove_files(); $sql="SELECT * FROM freeweb ORDER BY servername"; $httpdconf=$unix->LOCATE_APACHE_CONF_PATH(); $apacheusername=$unix->APACHE_SRC_ACCOUNT(); $GLOBALS["apacheusername"]=$apacheusername; $DAEMON_PATH=$unix->getmodpathfromconf($httpdconf); $q=new mysql(); $results=$q->QUERY_SQL($sql,'artica_backup'); if(!$q->ok){if($GLOBALS["VERBOSE"]){echo $q->mysql_error."\n";return;}} $d_path=$unix->APACHE_DIR_SITES_ENABLED(); $mods_enabled=$DAEMON_PATH."/mods-enabled"; echo "Starting......: Apache daemon path: $d_path\n"; echo "Starting......: Apache mods path..: $mods_enabled\n"; if(!is_dir($d_path)){@mkdir($d_path,666,true);} if(!is_dir($mods_enabled)){@mkdir($mods_enabled,666,true);} $count=mysql_num_rows($results); echo "Starting......: Apache checking virtual web sites count:$count\n"; if($count==0){ $users=new usersMenus(); echo "Starting......: Apache building default $users->hostname...\n"; buildHost($unix->LIGHTTPD_USER(),$users->hostname,0,$d_path); } while($ligne=mysql_fetch_array($results,MYSQL_ASSOC)){ $uid=$ligne["uid"]; $hostname=$ligne["servername"]; $ssl=$ligne["useSSL"]; echo "Starting......: Apache \"$hostname\" starting \n"; buildHost($uid,$hostname,$ssl,$d_path); } $users=$GLOBALS["CLASS_USERS_MENUS"]; $APACHE_MOD_AUTHNZ_LDAP=$users->APACHE_MOD_AUTHNZ_LDAP; if(is_file($GLOBALS["a2enmod"])){ if($APACHE_MOD_AUTHNZ_LDAP){ if($GLOBALS["VERBOSE"]){echo "Starting......: Apache {$GLOBALS["a2enmod"]} authnz_ldap\n";} shell_exec("{$GLOBALS["a2enmod"]} authnz_ldap >/dev/null 2>&1"); } } $sock=$GLOBALS["CLASS_SOCKETS"]; if($sock->GET_INFO("ArticaMetaEnabled")==1){ sys_THREAD_COMMAND_SET(LOCATE_PHP5_BIN()." ".dirname(__FILE__)."/exec.artica.meta.users.php --export-freewebs"); } }
function build() { $unix = new unix(); if (is_file("/etc/artica-postfix/FROM_ISO")) { if ($unix->file_time_min("/etc/artica-postfix/FROM_ISO") < 1) { return; } } $mef = basename(__FILE__); $pidfile = "/etc/artica-postfix/pids/" . basename(__FILE__) . "." . __FUNCTION__ . ".pid"; $pid = @file_get_contents($pidfile); if ($unix->process_exists($pid, $mef)) { echo "Starting......: " . date("H:i:s") . " [INIT]: Apache building : Process Already exist pid {$pid} line:" . __LINE__ . "\n"; return; } @file_put_contents($pidfile, getmypid()); if ($GLOBALS["VERBOSE"]) { echo "Starting......: " . date("H:i:s") . " [DEBUG]: Apache -> CheckHttpdConf();\n"; } CheckHttpdConf(); if ($GLOBALS["VERBOSE"]) { echo "Starting......: " . date("H:i:s") . " [DEBUG]: Apache -> RemoveAllSites();\n"; } RemoveAllSites(); if ($GLOBALS["VERBOSE"]) { echo "Starting......: " . date("H:i:s") . " [DEBUG]: Apache -> create_cron_task();\n"; } create_cron_task(); sync_squid(); $sock = new sockets(); $FreeWebDisableSSL = intval(trim($sock->GET_INFO("FreeWebDisableSSL"))); $php5 = $unix->LOCATE_PHP5_BIN(); $varWwwPerms = $sock->GET_INFO("varWwwPerms"); if ($varWwwPerms == null) { $varWwwPerms = 755; } if ($GLOBALS["VERBOSE"]) { echo "Starting......: " . date("H:i:s") . " [DEBUG]: Apache -> remove_files();\n"; } remove_files(); $sql = "SELECT * FROM freeweb ORDER BY servername"; $httpdconf = $unix->LOCATE_APACHE_CONF_PATH(); $apacheusername = $unix->APACHE_SRC_ACCOUNT(); $GLOBALS["apacheusername"] = $apacheusername; $DAEMON_PATH = $unix->getmodpathfromconf($httpdconf); if ($GLOBALS["VERBOSE"]) { echo "Starting......: " . date("H:i:s") . " [DEBUG]: Apache -> sql();\n"; } $q = new mysql(); $results = $q->QUERY_SQL($sql, 'artica_backup'); if (!$q->ok) { if ($GLOBALS["VERBOSE"]) { echo "Starting......: " . date("H:i:s") . " [DEBUG]: Apache {$q->mysql_error}\n"; return; } } $d_path = $unix->APACHE_DIR_SITES_ENABLED(); $mods_enabled = $DAEMON_PATH . "/mods-enabled"; if ($FreeWebDisableSSL == 0) { SSL_DEFAULT_VIRTUAL_HOST(); } echo "Starting......: " . date("H:i:s") . " [INIT]: Apache daemon path: {$d_path}\n"; echo "Starting......: " . date("H:i:s") . " [INIT]: Apache mods path..: {$mods_enabled}\n"; if (!is_dir($d_path)) { @mkdir($d_path, 666, true); } if (!is_dir($mods_enabled)) { @mkdir($mods_enabled, 666, true); } $count = mysql_num_rows($results); echo "Starting......: " . date("H:i:s") . " [INIT]: Apache checking virtual web sites count:{$count}\n"; if ($count == 0) { $users = new usersMenus(); echo "Starting......: " . date("H:i:s") . " [INIT]: Apache building default {$users->hostname}...\n"; buildHost($unix->LIGHTTPD_USER(), $users->hostname, 0, $d_path); } if ($GLOBALS["VERBOSE"]) { $add_plus = " --verbose"; } while ($ligne = mysql_fetch_array($results, MYSQL_ASSOC)) { $uid = $ligne["uid"]; $hostname = $ligne["servername"]; $ssl = $ligne["useSSL"]; if ($FreeWebDisableSSL == 1) { $ssl = 0; } echo "Starting......: " . date("H:i:s") . " [INIT]: Apache \"{$hostname}\" starting\n"; $cmd = "{$php5} " . __FILE__ . " --sitename \"{$hostname}\" --no-httpd-conf --noreload{$add_plus}"; if ($GLOBALS["VERBOSE"]) { echo "Starting......: " . date("H:i:s") . " [INIT]: Apache \"{$cmd}\"\n"; } shell_exec($cmd); } $users = $GLOBALS["CLASS_USERS_MENUS"]; $APACHE_MOD_AUTHNZ_LDAP = $users->APACHE_MOD_AUTHNZ_LDAP; if (is_file($GLOBALS["a2enmod"])) { if ($APACHE_MOD_AUTHNZ_LDAP) { if ($GLOBALS["VERBOSE"]) { echo "Starting......: " . date("H:i:s") . " [INIT]: Apache {$GLOBALS["a2enmod"]} authnz_ldap\n"; } shell_exec("{$GLOBALS["a2enmod"]} authnz_ldap >/dev/null 2>&1"); } } $sock = $GLOBALS["CLASS_SOCKETS"]; if ($sock->GET_INFO("ArticaMetaEnabled") == 1) { sys_THREAD_COMMAND_SET(LOCATE_PHP5_BIN() . " " . dirname(__FILE__) . "/exec.artica.meta.users.php --export-freewebs"); } sys_THREAD_COMMAND_SET(LOCATE_PHP5_BIN() . " " . __FILE__ . " --monit"); }