<?php

$lastKnownBrowser = "blarg";
$knownBrowsers = array("MSIE" => "Internet Explorer", "Opera Tablet" => "Opera Mobile (tablet)", "Opera Mobile" => "Opera Mobile", "Opera Mini" => "Opera Mini", 'iPod' => 'iPod', 'iPad' => 'iPad', 'iPhone' => 'iPhone', "Nintendo Wii" => "Wii Internet Channel", "Nintendo DSi" => "Nintendo DSi Browser", "Nitro" => "Nintendo DS Browser", "Nintendo 3DS" => "Nintendo 3DS", "Opera" => "Opera", "MozillaDeveloperPreview" => "Firefox (Development build)", "Firefox" => "Firefox", "dwb" => "DWB", "Chrome" => "Chrome", "Android" => "Android", "Midori" => "Midori", "Safari" => "Safari", "Konqueror" => "Konqueror", "Mozilla" => "Mozilla", "Lynx" => "Lynx", "ELinks" => "ELinks", "Links" => "Links", "Nokia" => "Nokia mobile");
$mobileBrowsers = array('Opera Tablet', 'Opera Mobile', 'Opera Mini', 'Nintendo DSi', 'Nitro', 'Nintendo 3DS', 'Android', 'Nokia', 'iPod', 'iPad', 'iPhone');
$mobileLayout = false;
$ua = $_SERVER['HTTP_USER_AGENT'];
foreach ($knownBrowsers as $code => $name) {
    if (strpos($ua, $code) !== FALSE) {
        $versionStart = strpos($ua, $code) + strlen($code);
        if ($code != "dwb") {
            $version = GetVersion($ua, $versionStart);
        }
        //Opera Mini wasn't detected properly because of the Opera 10 hack.
        if (strpos($ua, "Opera/9.80") !== FALSE && $code != "Opera Mini" || $code == "Safari" && strpos($ua, "Version/") !== FALSE) {
            $version = substr($ua, strpos($ua, "Version/") + 8);
        }
        if (in_array($code, $mobileBrowsers)) {
            $mobileLayout = true;
        }
        break;
    }
}
if ($_COOKIE['forcelayout'] == 1) {
    $mobileLayout = true;
} else {
    if ($_COOKIE['forcelayout'] == -1) {
        $mobileLayout = false;
    }
}
$oldAndroid = false;
Example #2
0
function sphBenchmark($name, $locals, $force_reindex)
{
    // load config
    $config = new SphinxConfig($locals);
    if (!($config->Load("bench/{$name}.xml") && CheckConfig($config, $name))) {
        return false;
    }
    global $g_locals;
    $g_locals['rt_mode'] = $config->Requires('force-rt');
    // temporary limitations
    assert($config->SubtestCount() == 1);
    assert($config->IsQueryTest());
    // find unused output prefix
    $i = 0;
    for (; file_exists("bench-results/{$name}.{$i}.bin"); $i++) {
    }
    $output = "bench-results/{$name}.{$i}";
    printf("benchmarking: %s\n", $config->Name());
    // grab index names and paths
    $msg = '';
    if (!$config->IsRt()) {
        // enable only in non rt-mode
        $config->EnableCompat098();
    }
    $config->WriteConfig('config.conf', 'all', $msg);
    $indexes = array();
    $text = file_get_contents('config.conf');
    preg_match_all('/index\\s+(\\S+)\\s+{[^}]+path\\s*=\\s*(.*)[^}]+}/m', $text, $matches);
    for ($i = 0; $i < count($matches[1]); $i++) {
        $indexes[$matches[1][$i]] = $matches[2][$i];
    }
    // checksum/reindex as needed
    $hash = null;
    foreach ($indexes as $indexName => $path) {
        printf("index: %s - ", $indexName);
        if ($config->IsRt() && $force_reindex) {
            EraseRtIndex($locals['data'], $path);
        }
        if (!$config->IsRt() && (!is_readable("{$path}.spa") || !is_readable("{$path}.spi") || $force_reindex)) {
            printf("indexing... ");
            $tm = MyMicrotime();
            $result = RunIndexer($error, $indexName);
            $tm = MyMicrotime() - $tm;
            if ($result == 1) {
                printf("\nerror running the indexer:\n%s\n", $error);
                return false;
            } else {
                if ($result == 2) {
                    printf("done in %s, there were warnings:\n%s\n", sphFormatTime($tm), $error);
                } else {
                    printf("done in %s - ", sphFormatTime($tm));
                }
            }
        }
        if (!$config->IsRt()) {
            $hash = array('spi' => md5_file("{$path}.spi"), 'spa' => md5_file("{$path}.spa"));
            printf("%s\n", $hash['spi']);
        } else {
            $hash = array('xml' => md5_file("bench/{$name}.xml"));
            printf("%s\n", $hash['xml']);
        }
    }
    // start searchd
    if (!$locals['skip-searchd']) {
        $result = StartSearchd('config.conf', "{$output}.searchd.txt", 'searchd.pid', $error);
        if ($result == 1) {
            printf("error starting searchd:\n%s\n", $error);
            return false;
        } else {
            if ($result == 2) {
                printf("searchd warning: %s\n", $error);
            }
        }
    }
    // run the benchmark
    $isOK = false;
    if ($config->IsSphinxqlTest()) {
        $isOK = $config->RunQuerySphinxQL($error, true);
    } else {
        $isOK = $config->RunQuery('*', $error, 'warming-up:') && $config->RunQuery('*', $error, 'profiling:');
    }
    if ($isOK) {
        $report = array('results' => array(), 'time' => time(), 'hash' => $hash, 'version' => GetVersion());
        $i = 0;
        $q = null;
        $last = '';
        foreach ($config->Results() as $result) {
            if ($config->IsSphinxqlTest()) {
                if ($result['sphinxql'] == 'show meta') {
                    $report['results'][] = array('total' => $result['rows'][0]['Value'], 'total_found' => $result['rows'][1]['Value'], 'time' => $result['rows'][2]['Value'], 'query' => $last, 'tag' => $last);
                }
                $last = $result['sphinxql'];
            } else {
                if ($result[0] !== $q) {
                    $i = 0;
                    $q = $result[0];
                }
                $query = $config->GetQuery($q);
                $report['results'][] = array('total' => $result[1], 'total_found' => $result[2], 'time' => $result[3], 'query' => $query['query'][$i++], 'tag' => $query['tag']);
            }
        }
        file_put_contents("{$output}.bin", serialize($report));
        printf("results saved to: {$output}.bin\n");
    } else {
        printf("\nfailed to run queries:\n%s\n", $error);
    }
    // shutdown
    StopSearchd('config.conf', 'searchd.pid');
    // all good
    return $output;
}
Example #3
0
function ViewLog()
{
    global $db_host, $db_user, $db_pass, $db_name;
    global $total, $page, $size, $view_size, $order, $who, $nf, $version;
    global $client_count_info, $client_from_info, $client_where_info, $client_select_info, $client_order_info;
    $page = $_GET["page"];
    $order = $_GET["order"];
    $Conn = mysql_connect($db_host, $db_user, $db_pass);
    mysql_query("SET NAMES 'GBK'");
    mysql_select_db($db_name, $Conn);
    $who = $_GET["who"];
    $query_by_user = "";
    if ($who == "") {
        $query_by_user = "";
    } else {
        $query_by_user = "******";
    }
    $version = $_GET["version"];
    $query_by_version = "";
    if ($version != "") {
        $query_by_version = " and version = '{$version}' ";
    }
    $query_by_nf = "";
    $nf = intval($_GET["nf"]);
    if ($nf == 1) {
        $query_by_nf = " and clc.network_flag = 1 ";
    } else {
        if ($nf == 2) {
            $query_by_nf = " and clc.network_flag = 2 ";
        }
    }
    $qs = "select lat_dtDateTime from tbl_last_action_time";
    $rows = mysql_query($qs);
    $last_update_time = "";
    if ($row = mysql_fetch_row($rows)) {
        $last_update_time = $row[0];
    }
    printf("<p>同步数据的最近时间是: {$last_update_time} </p>");
    $qs = "select count(distinct clc.error_code) from tbl_client_log_common clc, tbl_log_info li, tbl_guid_info gi where li.error_code = clc.error_code and gi.guid = clc.client_guid and li.error_type='程序' {$query_by_user} {$query_by_nf} {$query_by_version}";
    $result = mysql_query($qs);
    $row = mysql_fetch_row($result);
    $total = $row[0];
    $b = $page * $size - $size;
    $e = $size;
    $order_str = " order by first desc ";
    if ($order == 1) {
        $order_str = " order by last desc ";
    }
    $qs = "select li.error_code, li.error_title, max(clc.happened_time) as last, min(clc.happened_time) as first, count(clc.happened_time), count(distinct clc.client_guid), li.error_owner, li.error_status, max(clc.version) {$client_from_info} {$client_where_info} and li.error_type='程序' {$query_by_user} {$query_by_nf} {$query_by_version} group by li.error_code {$order_str}, clc_uId limit {$b}, {$e}";
    $result = mysql_query($qs);
    $str = sprintf("<tr bgcolor='#9acd32'>\n") . sprintf("<th width=400>log标题(点击查看堆栈)</th><th width=100>错误码</th><th width=125><a href='list_client_log.php?order=1&page=1&who={$who}&nf={$nf}&version={$version}'>最后发生时间</a></th><th width=125><a href='list_client_log.php?order=2&page=1&who={$who}&nf={$nf}&version={$version}'>首次发生时间</a></th><th width=75>次数(点击查看列表)</th><th width=75>客户端数</th><th width='100'>" . GetNetFlagTitle($nf, "list_client_log.php?order={$order}&page=1&who={$who}&version={$version}") . "</th><th width=75>") . GetOwner($who, "list_client_log.php?order={$order}&page=1&nf={$nf}&version={$version}") . sprintf("</th><th width=75>处理状态</th><th width=75>") . GetVersion("c", $version, "list_client_log.php?order={$order}&page=1&nf={$nf}&who={$who}") . sprintf("</th>\n") . sprintf("</tr>\n");
    $str_code = "<a href='list_by_code_c.php?page=1&code=%s' target='_blank'>%s</a>";
    $str_title = "<a href='detail_c.php?code=%s' target='_blank'>%s</a>";
    $i = 1;
    while ($row = mysql_fetch_row($result)) {
        $code = $row[0];
        $title = $row[1];
        $last = $row[2];
        $first = $row[3];
        $times = $row[4];
        $clients = $row[5];
        $color = "#ffffff";
        $owner = $row[6];
        $status = $row[7];
        $ver = $row[8];
        $qs2 = "select sum(distinct network_flag) from tbl_client_log_common where error_code = '{$code}'";
        $result2 = mysql_query($qs2);
        $row2 = mysql_fetch_row($result2);
        $cnf = intval($row2[0]);
        $network_flag = GetNetFlag($cnf);
        if ($i % 2) {
            $color = "#d8d8d8";
        }
        $str = $str . sprintf("<tr bgcolor='%s'>\n", $color) . sprintf("<td align='left'>&nbsp;") . sprintf($str_title, urlencode($code), str_replace('%', '%%', $title)) . sprintf("</td>\n") . sprintf("<td align='center'>%s</td>", $code) . sprintf("<td align='center'>%s</td>", $last) . sprintf("<td align='center'>%s</td>", $first) . sprintf("<td align='center'>") . sprintf($str_code, $code, $times) . sprintf("</td>") . sprintf("<td align='center'>{$clients}</td>") . sprintf("<td align='center'>%s</td>", $network_flag) . sprintf("<td align='center'>%s</td>", WriteOwner($owner)) . sprintf("<td align='center'><script>WriteStatus(%d)</script></td>", $status) . sprintf("<td align='center'>%s</td>", $ver) . sprintf("</tr>");
        $i++;
    }
    printf($str);
}
Example #4
0
    echo "Updated Clients Table\n";
}
$DBversion = '0.30.00.04';
if (GetVersion() < TransformToNum($DBversion)) {
    mysql_query("ALTER TABLE `logins` CHANGE `id` `id` INT( 11 ) NOT NULL AUTO_INCREMENT");
    SetVersion($DBversion);
    echo "Updated Logins Table ( Set id to auto increment )\n";
}
$DBversion = '0.30.00.05';
if (GetVersion() < TransformToNum($DBversion)) {
    mysql_query(" ALTER TABLE `clients` ADD `command` VARCHAR( 10 ) NULL");
    SetVersion($DBversion);
    echo "Updated Logins Table ( Set id to auto increment )\n";
}
echo "Finished updating Libki Database\n";
$version = GetVersion();
echo "Libki Database is now at version {$version}\n";
function TransformToNum($version)
{
    # remove the 3 last . to have a Perl number
    $parts = explode('.', $version);
    $primary = $parts[0];
    $secondary = implode(null, array($parts[1], $parts[2], $parts[3]));
    $version = "{$primary}.{$secondary}";
    return $version;
}
function SetVersion($libki_version)
{
    $libki_version = TransformToNum($libki_version);
    $dbh = GetDBH();
    $sql = "REPLACE INTO settings ( name, value, description ) VALUES ( 'version', '{$libki_version}', 'Current Version of the LibKi Database' )";
Example #5
0
function GetServerDataFromDB(&$targetTable)
{
    global $site;
    global $userInfo;
    $targetTable = array();
    // Put Site Server in $targetTable.
    $serverRec = new ServerTableRecord("Site Server", "");
    $serverKey = $site->GetCurrentSiteAddress();
    $targetTable[$serverKey] = $serverRec;
    $dbData = $site->EnumerateServers();
    $buffer = "";
    $chunk = "";
    do {
        $chunkSize = $dbData->Read($chunk, 4096);
        $buffer = $buffer . $chunk;
    } while ($chunkSize != 0);
    // Parse XML in $buffer
    parseUnicodeData($buffer, $supportServers, 'Server', 'serverRecParser');
    // Add support servers to target table.
    foreach ($supportServers as $key => $val) {
        $targetTable[$key] = $val;
    }
    // Get values for Online and Services fields
    foreach ($targetTable as $key => $val) {
        try {
            $serverAdmin = new MgServerAdmin();
            $serverAdmin->Open($key, $userInfo);
            $val->services = GetOptionalServerServices($serverAdmin);
            $val->online = GetOnline($serverAdmin);
            $val->version = GetVersion($serverAdmin);
            $val->poweredUp = true;
        } catch (MgException $e) {
            $val->poweredUp = false;
        }
        if ($serverAdmin != NULL) {
            $serverAdmin->Close();
        }
    }
}
Example #6
0
function GetLangPack($dir)
{
    return "download/" . $dir . "/sws-" . GetVersion($dir) . "-template.ReaperLangPack";
}
Example #7
0
}
// Get Variables
$product = $_GET["product"];
$major = $_GET["major"];
$minor = $_GET["minor"];
$debug = $_GET["debug"];
$build = $_GET["build_id"];
$user = $_GET["username"];
$machine = $_GET["machine_name"];
$changeset = $_GET["changeset_id"];
$checked_out = $_GET["checked_out"];
$template = $_GET["template"];
// Check the variables
if ($product == "" || $major == "" || $minor == "" || $debug == "" || $build == "" || $template == "") {
    exit(1);
}
// Get and increment the version number of the DB
$conn = ConnectVersionDB();
$version = GetVersion($conn, $product);
$version = IncrementVersion($version, $major, $minor, $debug, $build);
SetVersion($conn, $product, $version);
// Build the response
$template = str_replace("\\\"", "\"", $template);
$response = str_replace("VERSION", $version, $template);
// Add the new build to the database
AddVersionBuild($conn, $product, $version, $user, $machine, $changeset, $checked_out, $response);
// Return the response
echo $response;
?>

Example #8
0
function buildConfig($aspid = false)
{
    $unix = new unix();
    if ($aspid) {
        $pidfile = "/etc/artica-postfix/pids/" . basename(__FILE__) . "." . __FUNCTION__ . ".pid";
        $pid = $unix->get_pid_from_file($pidfile);
        if ($unix->process_exists($pid, basename(__FILE__))) {
            $time = $unix->PROCCESS_TIME_MIN($pid);
            if ($GLOBALS["OUTPUT"]) {
                echo "Starting......: " . date("H:i:s") . " [INIT]: PHP-FPM: Already Artica task running PID {$pid} since {$time}mn\n";
            }
            return;
        }
        @file_put_contents($pidfile, getmypid());
    }
    $sock = new sockets();
    $phpfpm = $unix->APACHE_LOCATE_PHP_FPM();
    if (!is_file($phpfpm)) {
        return;
    }
    $APACHE_USER = $unix->APACHE_SRC_ACCOUNT();
    $APACHE_GROUP = $unix->APACHE_SRC_GROUP();
    $VERSION = GetVersion();
    $AsRoot = false;
    $tr = explode(".", $VERSION);
    $MAJOR = $tr[0];
    $MINOR = $tr[1];
    $REV = $tr[2];
    $process_priority = false;
    $syslog_facility = true;
    $process_max = true;
    if ($MAJOR > 4) {
        if ($MINOR > 2) {
            if ($REV > 20) {
                $process_priority = true;
            }
        }
    }
    if ($GLOBALS["OUTPUT"]) {
        echo "Starting......: " . date("H:i:s") . " [INIT]: PHP-FPM: Parse Parameters\n";
    }
    $ParseParams = ParseParams();
    $AsRoot = true;
    if (isset($ParseParams["allow-to-run-as-root"])) {
        if ($GLOBALS["OUTPUT"]) {
            echo "Starting......: " . date("H:i:s") . " [INIT]: PHP-FPM: Allow run as root TRUE\n";
        }
        $AsRoot = true;
    } else {
        if ($GLOBALS["OUTPUT"]) {
            echo "Starting......: " . date("H:i:s") . " [INIT]: PHP-FPM: Allow run as root is disabled\n";
        }
    }
    $PHPFPMNoSyslog = trim(@file_get_contents("/etc/artica-postfix/settings/Daemons/PHPFPMNoSyslog"));
    $PHPFPMNoProcessMax = trim(@file_get_contents("/etc/artica-postfix/settings/Daemons/PHPFPMNoProcessMax"));
    if (!is_numeric($PHPFPMNoSyslog)) {
        $PHPFPMNoSyslog = 0;
    }
    if (!is_numeric($PHPFPMNoProcessMax)) {
        $PHPFPMNoProcessMax = 0;
    }
    if ($GLOBALS["OUTPUT"]) {
        echo "Starting......: " . date("H:i:s") . " [INIT]: PHP-FPM: PHPFPMNoSyslog:{$PHPFPMNoSyslog}\n";
    }
    if ($PHPFPMNoSyslog == 1) {
        if ($GLOBALS["OUTPUT"]) {
            echo "Starting......: " . date("H:i:s") . " [INIT]: PHP-FPM: Disabling process.priority token\n";
        }
        $syslog_facility = false;
    }
    if ($PHPFPMNoProcessMax == 1) {
        $process_max = false;
    }
    $ProcessNice = $unix->GET_PERFS('ProcessNice');
    if (!is_numeric($ProcessNice)) {
        $ProcessNice = 19;
    }
    if ($ProcessNice > 19) {
        $ProcessNice = 19;
    }
    if ($ProcessNice < 1) {
        $ProcessNice = 19;
    }
    $EnableArticaApachePHPFPM = intval($sock->GET_INFO("EnableArticaApachePHPFPM"));
    $EnablePHPFPMFreeWeb = intval($sock->GET_INFO("EnablePHPFPMFreeWeb"));
    $EnablePHPFPMFrameWork = $sock->GET_INFO("EnablePHPFPMFrameWork");
    $EnableFreeWeb = $sock->GET_INFO("EnableFreeWeb");
    if (!is_numeric($EnablePHPFPMFrameWork)) {
        $EnablePHPFPMFrameWork = 0;
    }
    if (!is_numeric($EnableArticaApachePHPFPM)) {
        $EnableArticaApachePHPFPM = 0;
    }
    if (!is_numeric($EnablePHPFPMFreeWeb)) {
        $EnablePHPFPMFreeWeb = 0;
    }
    if (!is_numeric($EnableFreeWeb)) {
        $EnableFreeWeb = 0;
    }
    if ($EnableFreeWeb == 0) {
        $EnablePHPFPMFreeWeb = 0;
    }
    if (is_file("/etc/artica-postfix/WORDPRESS_APPLIANCE")) {
        $EnablePHPFPMFreeWeb = 1;
    }
    if ($GLOBALS["OUTPUT"]) {
        echo "Starting......: " . date("H:i:s") . " [INIT]: PHP-FPM: will run as {$APACHE_USER}:{$APACHE_GROUP}\n";
    }
    $f[] = ";Writing by Artica," . date("Y-m-d H:i:s") . " file will be erased, change the " . __FILE__ . " code instead...";
    @unlink("/etc/php5/fpm/pool.d/www.conf");
    @unlink("/etc/php5/fpm/pool.d/apache2.conf");
    @unlink("/etc/php5/fpm/pool.d/zarafa.conf");
    @unlink("/etc/php5/fpm/pool.d/framework.conf");
    @unlink("/etc/php5/fpm/pool.d/nginx-authenticator.conf");
    if ($EnableArticaApachePHPFPM == 1) {
        $f[] = "[www]";
        $f[] = "user = {$APACHE_USER}";
        $f[] = "group = {$APACHE_GROUP}";
        $f[] = "listen = /var/run/php-fpm.sock";
        $f[] = "listen.mode = 0777";
        $f[] = ";listen.allowed_clients = 127.0.0.1";
        if ($process_priority) {
            $f[] = "process.priority = {$ProcessNice}";
        }
        $f[] = "pm = dynamic";
        //$f[]="log_level = debug";
        $f[] = "pm.max_children = 20";
        $f[] = "pm.start_servers = 2";
        $f[] = "pm.min_spare_servers = 1";
        $f[] = "pm.max_spare_servers = 5";
        $f[] = ";pm.process_idle_timeout = 10s;";
        $f[] = "pm.max_requests = 80";
        $f[] = "pm.status_path = /fpm.status.php";
        $f[] = "ping.path = /fpm.ping";
        $f[] = ";ping.response = pong";
        $f[] = "chdir = /";
        $f[] = "";
        @mkdir("/etc/php5/fpm/pool.d", 0755, true);
        @file_put_contents("/etc/php5/fpm/pool.d/www.conf", @implode("\n", $f));
        if ($GLOBALS["OUTPUT"]) {
            echo "Starting......: " . date("H:i:s") . " [INIT]: PHP-FPM: /etc/php5/fpm/pool.d/www.conf done\n";
        }
    }
    $f = array();
    if ($EnablePHPFPMFreeWeb == 1) {
        $f[] = "[apache2]";
        $f[] = "user = {$APACHE_USER}";
        $f[] = "group = {$APACHE_GROUP}";
        $f[] = "listen = /var/run/php-fpm-apache2.sock";
        $f[] = "listen.mode = 0777";
        $f[] = ";listen.allowed_clients = 127.0.0.1";
        if ($process_priority) {
            $f[] = "process.priority = {$ProcessNice}";
        }
        $f[] = "pm = dynamic";
        $f[] = "pm.max_children = 50";
        $f[] = "pm.start_servers = 2";
        $f[] = "pm.min_spare_servers = 1";
        $f[] = "pm.max_spare_servers = 5";
        $f[] = ";pm.process_idle_timeout = 10s;";
        $f[] = "pm.max_requests = 60";
        $f[] = "pm.status_path = /fpm.status.php";
        $f[] = "request_terminate_timeout = 605";
        $f[] = "ping.path = /php-fpm-ping";
        $f[] = ";ping.response = pong";
        $f[] = "chdir = /";
        $f[] = "";
        @file_put_contents("/etc/php5/fpm/pool.d/apache2.conf", @implode("\n", $f));
        if ($GLOBALS["OUTPUT"]) {
            echo "Starting......: " . date("H:i:s") . " [INIT]: PHP-FPM: /etc/php5/fpm/pool.d/apache2.conf done\n";
        }
    }
    $zarafabin = $unix->find_program("zarafa-server");
    if (is_file($zarafabin)) {
        $FreeWebPerformances = unserialize(base64_decode($sock->GET_INFO("ZarafaApachePerformances")));
        if (!is_numeric($FreeWebPerformances["post_max_size"])) {
            $FreeWebPerformances["post_max_size"] = 50;
        }
        if (!is_numeric($FreeWebPerformances["upload_max_filesize"])) {
            $FreeWebPerformances["upload_max_filesize"] = 50;
        }
        if (!is_numeric($FreeWebPerformances["PhpStartServers"])) {
            $FreeWebPerformances["PhpStartServers"] = 20;
        }
        if (!is_numeric($FreeWebPerformances["PhpMinSpareServers"])) {
            $FreeWebPerformances["PhpMinSpareServers"] = 5;
        }
        if (!is_numeric($FreeWebPerformances["PhpMaxSpareServers"])) {
            $FreeWebPerformances["PhpMaxSpareServers"] = 25;
        }
        if (!is_numeric($FreeWebPerformances["PhpMaxClients"])) {
            $FreeWebPerformances["PhpMaxClients"] = 128;
        }
        $f = array();
        $f[] = "[zarafa]";
        $f[] = "user = {$APACHE_USER}";
        $f[] = "group = {$APACHE_GROUP}";
        $f[] = "listen = /var/run/php-fpm-zarafa.sock";
        $f[] = "listen.mode = 0777";
        $f[] = ";listen.allowed_clients = 127.0.0.1";
        if ($process_priority) {
            $f[] = "process.priority = {$ProcessNice}";
        }
        $f[] = "pm = dynamic";
        if ($GLOBALS["OUTPUT"]) {
            echo "Starting......: " . date("H:i:s") . " [INIT]: PHP-FPM: Zarafa max_children.....: {$FreeWebPerformances["PhpMaxClients"]}\n";
        }
        if ($GLOBALS["OUTPUT"]) {
            echo "Starting......: " . date("H:i:s") . " [INIT]: PHP-FPM: Zarafa start_servers....: {$FreeWebPerformances["PhpStartServers"]}\n";
        }
        if ($GLOBALS["OUTPUT"]) {
            echo "Starting......: " . date("H:i:s") . " [INIT]: PHP-FPM: Zarafa min_spare_servers: {$FreeWebPerformances["PhpMinSpareServers"]}\n";
        }
        if ($GLOBALS["OUTPUT"]) {
            echo "Starting......: " . date("H:i:s") . " [INIT]: PHP-FPM: Zarafa max_spare_servers: {$FreeWebPerformances["PhpMaxSpareServers"]}\n";
        }
        @mkdir("/var/lib/php5-zarafa", 0755, true);
        $unix->chown_func($APACHE_USER, $APACHE_GROUP, "/var/lib/php5-zarafa");
        $f[] = "pm.max_children = {$FreeWebPerformances["PhpMaxClients"]}";
        $f[] = "pm.start_servers = {$FreeWebPerformances["PhpStartServers"]}";
        $f[] = "pm.min_spare_servers = {$FreeWebPerformances["PhpMinSpareServers"]}";
        $f[] = "pm.max_spare_servers = {$FreeWebPerformances["PhpMaxSpareServers"]}";
        $f[] = ";pm.process_idle_timeout = 10s;";
        $f[] = "pm.max_requests = 60";
        $f[] = "pm.status_path = /fpm.status.php";
        $f[] = "request_terminate_timeout = 605";
        $f[] = "ping.path = /php-fpm-ping";
        $f[] = ";ping.response = pong";
        $f[] = "chdir = /";
        $f[] = "php_value[include_path]=\".:/usr/share/php:/usr/share/php5:/usr/local/share/php:/usr/share/php5/PEAR:/usr/share/pear:/tmp\"";
        $f[] = "php_value[magic_quotes_gpc] = 0";
        $f[] = "php_value[short_open_tag] = 0";
        $f[] = "php_value[magic_quotes_runtime] = 0";
        $f[] = "php_value[safe_mode] = 0";
        $f[] = "php_value[register_globals] = 0";
        $f[] = "php_value[max_input_time] = 300";
        $f[] = "php_value[register_globals] = 0";
        $f[] = "php_value[post_max_size] = {$FreeWebPerformances["post_max_size"]}M";
        $f[] = "php_value[upload_max_filesize] = {$FreeWebPerformances["upload_max_filesize"]}M";
        $f[] = "php_value[session.save_path] = /var/lib/php5-zarafa";
        $f[] = "";
        @file_put_contents("/etc/php5/fpm/pool.d/zarafa.conf", @implode("\n", $f));
        if ($GLOBALS["OUTPUT"]) {
            echo "Starting......: " . date("H:i:s") . " [INIT]: PHP-FPM: Zarafa /etc/php5/fpm/pool.d/zarafa.conf done\n";
        }
    }
    $f = array();
    if ($EnablePHPFPMFrameWork == 1) {
        if ($AsRoot) {
            $f[] = "[framework]";
            $f[] = "user = root";
            $f[] = "group = root";
            $f[] = "listen = /var/run/php-fpm-framework.sock";
            $f[] = "listen.mode = 0777";
            $f[] = ";listen.allowed_clients = 127.0.0.1";
            if ($process_priority) {
                $f[] = "process.priority = {$ProcessNice}";
            }
            $f[] = "pm = dynamic";
            $f[] = "pm.max_children = 50";
            $f[] = "pm.start_servers = 2";
            $f[] = "pm.min_spare_servers = 1";
            $f[] = "pm.max_spare_servers = 5";
            $f[] = ";pm.process_idle_timeout = 10s;";
            $f[] = "pm.max_requests = 60";
            $f[] = "pm.status_path = /fpm.status.php";
            $f[] = "request_terminate_timeout = 605";
            $f[] = "ping.path = /php-fpm-ping";
            $f[] = ";ping.response = pong";
            $f[] = "chdir = /";
            $f[] = "";
            @file_put_contents("/etc/php5/fpm/pool.d/framework.conf", @implode("\n", $f));
            if ($GLOBALS["OUTPUT"]) {
                echo "Starting......: " . date("H:i:s") . " [INIT]: PHP-FPM: /etc/php5/fpm/pool.d/framework.conf done\n";
            }
        } else {
            if ($GLOBALS["OUTPUT"]) {
                echo "Starting......: " . date("H:i:s") . " [INIT]: PHP-FPM: As root is FALSE for framework..\n";
            }
        }
    }
    $f = array();
    $f[] = ";Writing by Artica," . date("Y-m-d H:i:s") . " file will be erased, change the " . __FILE__ . " code instead...";
    $f[] = "[global]";
    $f[] = "pid = /var/run/php5-fpm.pid";
    $f[] = "error_log = /var/log/php.log";
    if ($syslog_facility) {
        $f[] = "syslog.facility = daemon";
    }
    if ($syslog_facility) {
        $f[] = "syslog.ident = php-fpm";
    }
    $f[] = "log_level = ERROR";
    $f[] = ";emergency_restart_threshold = 0";
    $f[] = ";emergency_restart_interval = 0";
    $f[] = ";process_control_timeout = 0";
    if ($process_max) {
        $f[] = "process.max = 128";
    }
    if ($process_priority) {
        $f[] = "process.priority = {$ProcessNice}";
    }
    $f[] = "daemonize = yes";
    $f[] = ";rlimit_files = 1024";
    $f[] = ";rlimit_core = 0";
    $f[] = "include=/etc/php5/fpm/pool.d/*.conf\n";
    @file_put_contents("/etc/php5/fpm/php-fpm.conf", @implode("\n", $f));
    if ($GLOBALS["OUTPUT"]) {
        echo "Starting......: " . date("H:i:s") . " [INIT]: PHP-FPM: /etc/php5/fpm/php-fpm.conf done\n";
    }
    if ($GLOBALS["OUTPUT"]) {
        echo "Starting......: " . date("H:i:s") . " [INIT]: PHP-FPM: Check settings\n";
    }
    $sock = new sockets();
    exec("{$phpfpm} -t -y /etc/php5/fpm/php-fpm.conf 2>&1", $results);
    while (list($index, $line) = each($results)) {
        if (trim($line) == null) {
            continue;
        }
        if (strpos($line, "unknown entry 'syslog.facility'") > 0) {
            if ($GLOBALS["OUTPUT"]) {
                echo "Starting......: " . date("H:i:s") . " [INIT]: PHP-FPM: syslog not supported..\n";
            }
            @file_put_contents("/etc/artica-postfix/settings/Daemons/PHPFPMNoSyslog", 1);
            buildConfig();
            return;
        }
        if (strpos($line, "unknown entry 'process.max'") > 0) {
            if ($GLOBALS["OUTPUT"]) {
                echo "Starting......: " . date("H:i:s") . " [INIT]: PHP-FPM: process.max not supported..\n";
            }
            @file_put_contents("/etc/artica-postfix/settings/Daemons/PHPFPMNoProcessMax", 1);
            buildConfig();
            return;
        }
        if ($GLOBALS["OUTPUT"]) {
            echo "Starting......: " . date("H:i:s") . " [INIT]: PHP-FPM: {$line}\n";
        }
    }
}