当前位置: 首页>>代码示例>>PHP>>正文


PHP unix::GetUniqueID方法代码示例

本文整理汇总了PHP中unix::GetUniqueID方法的典型用法代码示例。如果您正苦于以下问题:PHP unix::GetUniqueID方法的具体用法?PHP unix::GetUniqueID怎么用?PHP unix::GetUniqueID使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在unix的用法示例。


在下文中一共展示了unix::GetUniqueID方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: iscsi_search

function iscsi_search()
{
    $unix = new unix();
    $uuid = $unix->GetUniqueID();
    $hostname = $unix->hostname_g();
    $hostnameR = explode(".", $hostname);
    krsort($hostnameR);
    $hostname = @implode(".", $hostnameR);
    @file_put_contents("/etc/iscsi/initiatorname.iscsi", "GenerateName=yes\n");
    $ip = $_GET["iscsi-search"];
    $unix = new unix();
    $iscsiadm = $unix->find_program("iscsiadm");
    $cmd = "{$iscsiadm} --mode discovery --type sendtargets --portal {$ip} 2>&1";
    writelogs_framework("{$cmd}", __FUNCTION__, __FILE__, __LINE__);
    exec($cmd, $results);
    writelogs_framework("{$cmd} = " . count($results) . " rows", __FUNCTION__, __FILE__, __LINE__);
    $array = array();
    while (list($index, $line) = each($results)) {
        if (preg_match("#Invalid Initiatorname#", $line)) {
            shell_exec("/etc/init.d/open-iscsi restart");
            return;
        }
        if (!preg_match("#([0-9\\.]+):([0-9]+),([0-9]+)\\s+(.+?):(.+)#", $line, $re)) {
            continue;
        }
        $array[$re[1]][] = array("PORT" => $re[2], "ID" => $re[3], "ISCSI" => $re[4], "FOLDER" => $re[5], "IP" => $re[1]);
    }
    @file_put_contents("/usr/share/artica-postfix/ressources/logs/web/iscsi-search.array", serialize($array));
    @chmod("/usr/share/artica-postfix/ressources/logs/web/iscsi-search.array", 0755);
}
开发者ID:BillTheBest,项目名称:1.6.x,代码行数:30,代码来源:iscsi.php

示例2: RefreshIndex

function RefreshIndex()
{
    $unix = new unix();
    $nice = EXEC_NICE();
    $sock = new sockets();
    $users = new usersMenus();
    $nohup = $unix->find_program("nohup");
    $php = $unix->LOCATE_PHP5_BIN();
    $wget = $unix->find_program("wget");
    $SYSTEMID = $unix->GetUniqueID();
    if ($SYSTEMID == null) {
        build_progress("System ID is Null !!!", 5);
        return;
    }
    build_progress_index("Register server...", 10);
    build_progress("Register server...", 10);
    shell_exec("{$nohup} {$nice} {$php} /usr/share/artica-postfix/exec.web-community-filter.php --register-lic >/dev/null 2>&1 &");
    if ($SYSTEMID == null) {
        build_progress_index("No system ID, force...", 15);
        build_progress("No system ID, force", 15);
        shell_exec("{$nice} /usr/share/artica-postfix/bin/artica-update -refresh-index --force >/dev/null 2>&1");
        return;
    }
    $xMEM_TOTAL_INSTALLEE = $users->MEM_TOTAL_INSTALLEE;
    $CPU_NUMBER = $users->CPU_NUMBER;
    $LinuxDistributionFullName = $users->LinuxDistriFullName;
    if ($LinuxDistributionFullName == null) {
        $LinuxDistributionFullName = "Linux Default";
    }
    $ARTICA_VERSION = GetCurrentVersion();
    $hostname = $unix->hostname_g();
    $CheckUserCount = CheckUserCount();
    $RebootAfterArticaUpgrade = $sock->GET_INFO("RebootAfterArticaUpgrade");
    if (!is_numeric($RebootAfterArticaUpgrade)) {
        $RebootAfterArticaUpgrade = 0;
    }
    $EnableScheduleUpdates = $sock->GET_INFO("EnableScheduleUpdates");
    $ArticaUpdateIntervalAllways = intval($sock->GET_INFO("EnableScheduleUpdates"));
    if (!is_numeric($EnableScheduleUpdates)) {
        $EnableScheduleUpdates = 0;
    }
    $ArticaAutoUpateOfficial = $sock->GET_INFO("ArticaAutoUpateOfficial");
    $ArticaAutoUpateNightly = intval($sock->GET_INFO("ArticaAutoUpateNightly"));
    $ArticaUpdateIntervalAllways = intval($sock->GET_INFO("ArticaUpdateIntervalAllways"));
    $OfficialArticaUri = $sock->GET_INFO("OfficialArticaUri");
    if (!is_numeric($ArticaAutoUpateOfficial)) {
        $ArticaAutoUpateOfficial = 1;
    }
    if ($OfficialArticaUri == null) {
        $OfficialArticaUri = "http://articatech.net/artica.update.php";
    }
    $uri = $OfficialArticaUri;
    $dmidecode = @file_get_contents("/etc/artica-postfix/dmidecode.cache.url");
    @unlink($GLOBALS["MasterIndexFile"]);
    $tarballs_file = "/usr/share/artica-postfix/ressources/logs/web/tarballs.cache";
    echo "Starting......: " . date("H:i:s") . " CPU NUMBER: {$CPU_NUMBER}\n";
    echo "Starting......: " . date("H:i:s") . " Hostname..: {$hostname}\n";
    echo "Starting......: " . date("H:i:s") . " Artica ver: {$ARTICA_VERSION}\n";
    echo "Starting......: " . date("H:i:s") . " Users.....: {$CheckUserCount}\n";
    build_progress_index("Configuration done...", 15);
    build_progress("Configuration done", 15);
    $DATA["UUID"] = $SYSTEMID;
    $DATA["MEM"] = $xMEM_TOTAL_INSTALLEE;
    $DATA["CPU"] = $CPU_NUMBER;
    $DATA["LINUX"] = $LinuxDistributionFullName;
    $DATA["VERSION"] = $ARTICA_VERSION;
    $DATA["HOSTNAME"] = $hostname;
    $DATA["USERS"] = $CheckUserCount;
    $DATA["DMICODE"] = $dmidecode;
    build_progress_index("Check repositories...", 20);
    build_progress("Check repositories", 20);
    $MAIN_URI = $unix->MAIN_URI();
    echo "Starting......: " . date("H:i:s") . " Main URI..: {$MAIN_URI}\n";
    $md5string = @md5_file($GLOBALS["MasterIndexFile"]);
    build_progress_index("Get Index...", 25);
    build_progress("Get Index...", 25);
    echo "Starting......: " . date("H:i:s") . " Update index file..\n";
    $curl = new ccurl($OfficialArticaUri);
    $curl->parms["datas"] = base64_encode(serialize($DATA));
    if (!$curl->get()) {
        echo "Last detected error: {$curl->error}\n";
        build_progress_index("Get Index...{failed}", 110);
        build_progress("Get Index file !! FAILED !!", 110);
        _artica_update_event(0, "Unable to download index file with error {$curl->error_num}, {$curl->error}", null, __FILE__, __LINE__);
        return false;
    }
    @unlink("/etc/artica-postfix/settings/Daemons/ArticaUpdateRepos");
    build_progress_index("Parse Index from repository", 40);
    build_progress("Parse Index from repository", 40);
    if (preg_match("#<ERROR>(.+?)</ERROR>#is", $curl->data, $re)) {
        echo "{$re[1]} !! FAILED !!\n";
        build_progress_index("Corrupted index from repository !! FAILED !!", 110);
        build_progress("Corrupted index from repository !! FAILED !!", 110);
        return;
    }
    if (!preg_match("#<CONTENT>(.+?)</CONTENT>#is", $curl->data, $re)) {
        echo "Corrupted index from repository !! FAILED !!\n";
        build_progress_index("Corrupted index from repository !! FAILED !!", 110);
        build_progress("Corrupted index from repository !! FAILED !!", 110);
        return;
//.........这里部分代码省略.........
开发者ID:BillTheBest,项目名称:1.6.x,代码行数:101,代码来源:exec.nightly.php

示例3: quicklinks_main_menu

function quicklinks_main_menu()
{
    $sock = new sockets();
    $users = new usersMenus();
    if ($GLOBALS["AS_ROOT"]) {
        $users->AsSystemAdministrator = true;
    }
    $CachePage = "/usr/share/artica-postfix/ressources/logs/web/" . __FUNCTION__ . ".html";
    if (!$GLOBALS["AS_ROOT"]) {
        if ($users->AsSystemAdministrator) {
            if (is_file($CachePage)) {
                $tpl = new templates();
                echo $tpl->_ENGINE_parse_body(@file_get_contents($CachePage));
                return;
            }
        }
        $uuid = $sock->getFrameWork("services.php?GetMyHostId=yes");
        $debian_version = $sock->getFrameWork("system.php?debian_version=yes");
    } else {
        $debian_version = debian_version_asroot();
        $unix = new unix();
        $uuid = $unix->GetUniqueID();
    }
    $tpl = new templates();
    $version = @file_get_contents(dirname(__FILE__) . "/VERSION");
    $WizardSavedSettings = unserialize(base64_decode($sock->GET_INFO("WizardSavedSettings")));
    $LicenseInfos = unserialize(base64_decode($sock->GET_INFO("LicenseInfos")));
    if ($LicenseInfos["COMPANY"] == null) {
        $LicenseInfos["COMPANY"] = $WizardSavedSettings["company_name"];
    }
    $productName = "Artica";
    if (is_file(dirname(__FILE__) . "/ressources/templates/{$_COOKIE["artica-template"]}/ProducName.conf")) {
        $productName = @file_get_contents(dirname(__FILE__) . "/ressources/templates/{$_COOKIE["artica-template"]}/ProducName.conf");
    }
    $tr[] = paragrapheWin("license-white-64.png", "{artica_license}", "GoToArticaLicense()");
    $tr[] = paragrapheWin("update-64.png", "{update2}", "GotToArticaUpdate()");
    $tr[] = paragrapheWin("64-settings-white.png", "{web_interface_settings}", "GotoArticaSettings()");
    $tr[] = paragrapheWin("backup-64-white.png", "{backup_restore}", "GotoArticaBackup()");
    $license_type = "Community Edition";
    if ($users->CORP_LICENSE) {
        $license_type = "Entreprise Edition";
    }
    $company = $tpl->javascript_parse_text("{company}");
    $companytext = $LicenseInfos["COMPANY"];
    $len = strlen($companytext);
    if ($len > 22) {
        $companytext = substr($companytext, 0, 19) . "...";
    }
    $back = "x86-256-opac20.png";
    if ($users->ArchStruct == 64) {
        $back = "x64-256-opac20.png";
    }
    $html = "\n\t<div style='background-image:url(img/{$back});background-repeat:no-repeat;background-position:43% 20%;'>\n\t\t<div style='font-size:64px;color:white;width:767px'>{$productName} v.{$version}\n\t\t\t<div style='font-size:15px;text-align:right;border-top:1px solid #FFFFFF;padding-top:5px'>{$company}: {$companytext} &nbsp;|&nbsp; uuid: {$uuid} &nbsp;|&nbsp; {$license_type}</div>\n\t\t\t<div style='font-size:32px;text-align:right;'>{$users->LinuxDistriFullName} {$users->ArchStruct}bits</div>\n\t\t</div>\n\t\n\t\n\t" . CompileTr5_win($tr);
    $html = $html . "</div>";
    if ($GLOBALS['AS_ROOT']) {
        @file_put_contents($CachePage, $html);
    }
    echo $html;
}
开发者ID:articatech,项目名称:artica,代码行数:59,代码来源:quicklinks.php

示例4: inject

function inject($category, $table = null, $file = null)
{
    include_once dirname(__FILE__) . "/ressources/class.dansguardian.inc";
    $unix = new unix();
    $q = new mysql_squid_builder();
    if (is_file($category)) {
        $file = $category;
        $category_name = basename($file);
        echo "{$file} -> {$category_name}\n";
        if (preg_match("#(.+?)\\.gz\$#", $category_name)) {
            echo "{$category_name} -> gunzip\n";
            $new_category_name = str_replace(".gz", "", $category_name);
            $gunzip = $unix->find_program("gunzip");
            $target_file = dirname($file) . "/{$new_category_name}";
            $cmd = "/bin/gunzip -d -c \"{$file}\" >{$target_file} 2>&1";
            echo "{$cmd}\n";
            shell_exec($cmd);
            if (!is_file($target_file)) {
                echo "Uncompress failed\n";
                return;
            }
            $file = $target_file;
            $table = $new_category_name;
            $category = $q->tablename_tocat($table);
            echo "{$new_category_name} -> {$table}\n";
        } else {
            $table = $category_name;
            echo "{$new_category_name} -> {$table}\n";
            $category = $q->tablename_tocat($table);
        }
        echo "Table: {$table}\nSource File:{$file}\nCategory: {$category}\n";
    }
    if (!is_file($file)) {
        if (!is_file($table)) {
            echo "`{$table}` No such file\n";
        }
        if (is_file($table)) {
            $file = $table;
            $table = null;
        }
    }
    if ($table == null) {
        $table = "category_" . $q->category_transform_name($category);
        echo "Table will be {$table}\n";
    }
    if (!$q->TABLE_EXISTS($table)) {
        echo "{$table} does not exists, check if it is an official one\n";
        $dans = new dansguardian_rules();
        if (isset($dans->array_blacksites[$category])) {
            $q->CreateCategoryTable($category);
        }
    }
    if (!$q->TABLE_EXISTS($table)) {
        echo "`{$category}` -> no such table \"{$table}\"\n";
        return;
    }
    $sql = "SELECT COUNT(*) AS TCOUNT FROM {$table}";
    $q->QUERY_SQL($sql);
    if (!$q->ok) {
        echo $q->mysql_error . "\n";
        if (preg_match("#is marked as crashed and last#", $q->mysql_error)) {
            echo "`{$table}` -> crashed, remove \"{$table}\"\n";
            $q->QUERY_SQL("DROP TABLE {$table}");
            $q->QUERY_SQL("flush tables");
            $q = new mysql_squid_builder();
            echo "`{$table}` -> Create category \"{$category}\"\n";
            $q->CreateCategoryTable($category);
            $q->CreateCategoryTable($category);
            $q = new mysql_squid_builder();
        }
        if (!$q->TABLE_EXISTS($table)) {
            echo "`{$category}` -> no such table \"{$table}\"\n";
            return;
        }
    }
    if ($file == null) {
        $dir = "/var/lib/squidguard";
        if ($GLOBALS["SHALLA"]) {
            $dir = "/root/shalla/BL";
        }
        if (!is_file("{$dir}/{$category}/domains")) {
            echo "{$dir}/{$category}/domains no such file";
            return;
        }
        $file = "{$dir}/{$category}/domains";
    }
    if (!is_file($file)) {
        echo "{$file} no such file";
        return;
    }
    $sock = new sockets();
    $unix = new unix();
    $uuid = $unix->GetUniqueID();
    if ($uuid == null) {
        echo "No uuid\n";
        return;
    }
    echo "open {$file}\n";
    $handle = @fopen($file, "r");
    if (!$handle) {
//.........这里部分代码省略.........
开发者ID:brucewu16899,项目名称:1.6.x,代码行数:101,代码来源:exec.squidguard.php

示例5: include_tpl_file

function include_tpl_file($path, $category)
{
    $sock = new sockets();
    $unix = new unix();
    $uuid = $unix->GetUniqueID();
    if ($uuid == null) {
        echo "UUID=NULL; Aborting";
        return;
    }
    if ($category == null) {
        echo "CATEGORY=NULL; Aborting";
        return;
    }
    if (!is_file($path)) {
        echo "{$path} no such file\n";
        return;
    }
    $q = new mysql_squid_builder();
    $q->CreateCategoryTable($category);
    $TableDest = "category_" . $q->category_transform_name($category);
    $array = array();
    $f = @explode("\n", @file_get_contents($path));
    $count_websites = count($f);
    $i = 0;
    $d = 0;
    $group = 0;
    $prefix = "INSERT IGNORE INTO {$TableDest} (zmd5,zDate,category,pattern,uuid) VALUES";
    while (list($index, $website) = each($f)) {
        $i++;
        $d++;
        if ($d > 1000) {
            $group = $group + $d;
            events_tail("include_tpl_file({$category}):: importing {$group} sites...");
            $d = 0;
        }
        if ($website == null) {
            return;
        }
        $www = trim(strtolower($website));
        if (preg_match("#www\\.(.+?)\$#i", $www, $re)) {
            $www = $re[1];
        }
        $md5 = md5($www . $category);
        if ($array[$md5]) {
            echo "{$www} already exists\n";
            continue;
        }
        $enabled = 1;
        $sql_add[] = "('{$md5}',NOW(),'{$category}','{$www}','{$uuid}')";
        $array[$md5] = true;
        if ($GLOBALS["SIMULATE"]) {
            echo "{$i}/{$count_websites}: {$sql_add}\n";
            continue;
        }
        if (count($sql_add) > 500) {
            $sql = $prefix . @implode(",", $sql_add);
            $q->QUERY_SQL($sql);
            if (!$q->ok) {
                echo "{$i}/{$count_websites} Failed: {$www}\n";
            } else {
                echo "{$i}/{$count_websites} Success: {$www}\n";
            }
            $sql_add = array();
        }
    }
    if (count($sql_add) > 0) {
        $sql = $prefix . @implode(",", $sql_add);
        $q->QUERY_SQL($sql);
        if (!$q->ok) {
            echo "{$i}/{$count_websites} Failed: {$www}\n";
        } else {
            echo "{$i}/{$count_websites} Success: {$www}\n";
        }
        $sql_add = array();
    }
    echo " -------------------------------------------------\n";
    echo count($array) . " websites done\n";
    echo " -------------------------------------------------\n";
}
开发者ID:BillTheBest,项目名称:1.6.x,代码行数:79,代码来源:exec.dansguardian.injector.php

示例6: xrun

function xrun()
{
    $unix = new unix();
    $pidfile = "/etc/artica-postfix/pids/" . basename(__FILE__);
    $pid = $unix->get_pid_from_file($pidfile);
    if ($unix->process_exists($pid, basename(__FILE__))) {
        echo "Starting......: " . date("H:i:s") . " [META]: Already executed {$pid}\n";
        return;
    }
    if ($unix->SQUID_ENABLED() == 0) {
        echo "Starting......: " . date("H:i:s") . " [META]: Squid Not installed or disabled\n";
        return;
    }
    $myuuid = $unix->GetUniqueID();
    echo "Starting......: " . date("H:i:s") . " [META]: My UUID = {$myuuid}\n";
    $md5_org = md5_file("/etc/squid3/acls_center_meta.conf");
    $q = new mysql();
    $results = $q->QUERY_SQL("SELECT gpid FROM metagroups_link WHERE uuid='{$myuuid}'", "metaclient");
    $acls = new squid_acls();
    $acls->Build_Acls(false, true);
    if (count($acls->acls_array) == 0) {
        @file_put_contents("/etc/squid3/acls_center_meta.conf", "\n");
        @chown("/etc/squid3/acls_center_meta.conf", "squid");
        @chgrp("/etc/squid3/acls_center_meta.conf", "squid");
        $md5_new = md5_file("/etc/squid3/acls_center_meta.conf");
        if ($md5_new != $md5_org) {
            $squidbin = $unix->LOCATE_SQUID_BIN();
            squid_admin_mysql(1, "Reload proxy service for Meta acls", null, __FILE__, __LINE__);
            shell_exec("{$squidbin} -f /etc/squid3/squid.conf -k reconfigure");
        }
        return;
    }
    $all_acls = @implode("\n", $acls->acls_array);
    $php = $unix->LOCATE_PHP5_BIN();
    $ACLS = array();
    while ($ligne = mysql_fetch_assoc($results)) {
        echo "{$myuuid} is a member of group id {$ligne["gpid"]}\n";
        $ACLS = buildacls_fromgroup($ligne["gpid"], $ACLS);
    }
    $q = new mysql();
    $results = $q->QUERY_SQL("SELECT * FROM meta_webfilters_acls WHERE metauuid='{$myuuid}'", "metaclient");
    $aclsGroups = new squid_acls_groups();
    $aclsGroups->AsMeta = true;
    while ($ligne = mysql_fetch_assoc($results)) {
        $aclname = $ligne["aclname"];
        $httpaccess = $ligne["httpaccess"];
        $httpaccess_data = $ligne["httpaccess_data"];
        $reverse = false;
        $ID = $ligne["ID"];
        $valueToAdd = null;
        if ($httpaccess == "deny_access_except") {
            $reverse = true;
        }
        echo "Starting......: " . date("H:i:s") . " [META]: aclname[{$ID}]: {$aclname}/{$httpaccess}\n";
        if (isset($GLOBALS["ACLRULEXEC"][$ID])) {
            echo "Starting......: " . date("H:i:s") . " [META]: aclname[{$ID}]: Already executed, skip\n";
            continue;
        }
        $Groups = $aclsGroups->buildacls_bytype_items($ID, $reverse);
        if (count($Groups) == 0) {
            echo "Starting......: " . date("H:i:s") . " [META]: aclname[{$ID}]: no group, skip...\n";
            continue;
        }
        $GLOBALS["ACLRULEXEC"][$ID] = true;
        $firstToken = getFirstToken($httpaccess, $httpaccess_data, $ID);
        $ACLS[] = "{$firstToken} {$valueToAdd}" . @implode(" ", $Groups);
    }
    @file_put_contents("/etc/squid3/acls_center_meta.conf", "{$all_acls}\n" . @implode("\n", $ACLS) . "\n");
    @chown("/etc/squid3/acls_center_meta.conf", "squid");
    @chgrp("/etc/squid3/acls_center_meta.conf", "squid");
    if (count($ACLS) == 0) {
        $md5_new = md5_file("/etc/squid3/acls_center_meta.conf");
        if ($md5_new != $md5_org) {
            $squidbin = $unix->LOCATE_SQUID_BIN();
            squid_admin_mysql(1, "Reload proxy service for Meta acls", null, __FILE__, __LINE__);
            shell_exec("{$squidbin} -f /etc/squid3/squid.conf -k reconfigure");
        }
        return;
    }
    if (!$GLOBALS["NOCHECK"]) {
        if (!isInSquidConf()) {
            squid_admin_mysql(1, "Reconfigure proxy service for Meta acls", null, __FILE__, __LINE__);
            system("{$php} /usr/share/artica-postfix/exec.squid.php --build --force --for-meta");
            return;
        }
    }
    $md5_new = md5_file("/etc/squid3/acls_center_meta.conf");
    if ($md5_new != $md5_org) {
        $squidbin = $unix->LOCATE_SQUID_BIN();
        squid_admin_mysql(1, "Reload proxy service for Meta acls", null, __FILE__, __LINE__);
        shell_exec("{$squidbin} -f /etc/squid3/squid.conf -k reconfigure");
    }
}
开发者ID:articatech,项目名称:artica,代码行数:93,代码来源:exec.squid-meta.php

示例7: export_push

function export_push()
{
    $sock = new sockets();
    $unix = new unix();
    $export_stamp = "/etc/artica-postfix/pids/" . basename(__FILE__) . ".EXPORT.time";
    $export_time = $unix->file_time_min($export_stamp);
    if ($export_time < 60) {
        return;
    }
    $ArticaProxyStatisticsBackupFolder = $sock->GET_INFO("ArticaProxyStatisticsBackupFolder");
    if ($ArticaProxyStatisticsBackupFolder == null) {
        $ArticaProxyStatisticsBackupFolder = "/home/artica/squid/backup-statistics";
    }
    $ArticaProxyStatisticsBackupFolder = $ArticaProxyStatisticsBackupFolder . "/export";
    $WizardStatsAppliance = unserialize(base64_decode($sock->GET_INFO("WizardStatsAppliance")));
    $proto = "http";
    if ($WizardStatsAppliance["SSL"] == 1) {
        $proto = "https";
    }
    $uri = "{$proto}://{$WizardStatsAppliance["SERVER"]}:{$WizardStatsAppliance["PORT"]}/nodes.listener.php";
    if ($GLOBALS["VERBOSE"]) {
        echo "{$uri}\n";
    }
    $credentials["MANAGER"] = $WizardStatsAppliance["MANAGER"];
    $credentials["PASSWORD"] = $WizardStatsAppliance["MANAGER-PASSWORD"];
    $files = $unix->DirFiles($ArticaProxyStatisticsBackupFolder);
    Export_logs("PUSH Scanning {$ArticaProxyStatisticsBackupFolder}");
    while (list($filename, $none) = each($files)) {
        $size = @filesize("{$ArticaProxyStatisticsBackupFolder}/{$filename}");
        Export_logs("PUSH Scanning {$ArticaProxyStatisticsBackupFolder}/{$filename} ( {$size} bytes )");
        $array = array("UUID" => $unix->GetUniqueID(), "HOSTNAME" => $unix->hostname_g(), "SIZE" => $size, "FILENAME" => $filename, "creds" => base64_encode(serialize($credentials)));
        if ($GLOBALS["VERBOSE"]) {
            echo "PUSH {$ArticaProxyStatisticsBackupFolder}/{$filename}\n";
        }
        $curl = new ccurl($uri, false, null, true);
        if (!$curl->postFile("SQUID_STATS_CONTAINER", "{$ArticaProxyStatisticsBackupFolder}/{$filename}", $array)) {
            if ($GLOBALS["VERBOSE"]) {
                echo "Posting informations Failed {$curl->error}...\n";
            }
            Export_logs("Failed {$curl->error}");
            continue;
        }
        if (!preg_match("#<RESULTS>(.*?)</RESULTS>#is", $curl->data, $re)) {
            Export_logs("{$WizardStatsAppliance["SERVER"]} did not report something");
            stats_admin_events(0, "{$WizardStatsAppliance["SERVER"]} did not report something", $curl->data, __FILE__, __LINE__);
            continue;
        }
        $RESULT = $re[1];
        Export_logs("RESULT = {$RESULT}");
        if ($RESULT != "SUCCESS") {
            Export_logs("Failed, {$WizardStatsAppliance["SERVER"]} report {$RESULT} ");
            stats_admin_events(0, "{$WizardStatsAppliance["SERVER"]} report {$RESULT}", $curl->data, __FILE__, __LINE__);
            continue;
        }
        Export_logs("Success, removing {$ArticaProxyStatisticsBackupFolder}/{$filename}");
        @unlink("{$ArticaProxyStatisticsBackupFolder}/{$filename}");
        stats_admin_events(0, "Success uploading {$filename} to {$WizardStatsAppliance["SERVER"]} report {$RESULT}", $curl->data, __FILE__, __LINE__);
    }
}
开发者ID:brucewu16899,项目名称:1.6.x,代码行数:59,代码来源:exec.squid.stats.central.php

示例8: inject

function inject($category, $table = null, $file = null)
{
    include_once dirname(__FILE__) . "/ressources/class.dansguardian.inc";
    $unix = new unix();
    $q = new mysql_squid_builder();
    if (is_file($category)) {
        $file = $category;
        $category_name = basename($file);
        echo "{$file} -> {$category_name}\n";
        if (preg_match("#(.+?)\\.gz\$#", $category_name)) {
            echo "{$category_name} -> gunzip\n";
            $new_category_name = str_replace(".gz", "", $category_name);
            $gunzip = $unix->find_program("gunzip");
            $target_file = dirname($file) . "/{$new_category_name}";
            $cmd = "/bin/gunzip -d -c \"{$file}\" >{$target_file} 2>&1";
            echo "{$cmd}\n";
            shell_exec($cmd);
            if (!is_file($target_file)) {
                echo "Uncompress failed\n";
                return;
            }
            $file = $target_file;
            $table = $new_category_name;
            $category = $q->tablename_tocat($table);
            echo "{$new_category_name} -> {$table}\n";
        } else {
            $table = $category_name;
            echo "{$new_category_name} -> {$table}\n";
            $category = $q->tablename_tocat($table);
        }
        echo "Table: {$table}\nSource File:{$file}\nCategory: {$category}\n";
    }
    if (!is_file($file)) {
        if (!is_file($table)) {
            echo "`{$table}` No such file\n";
        }
        if (is_file($table)) {
            $file = $table;
            $table = null;
        }
    }
    if ($table == null) {
        $table = "category_" . $q->category_transform_name($category);
        echo "Table will be {$table}\n";
    }
    if (!$q->TABLE_EXISTS($table)) {
        echo "{$table} does not exists, check if it is an official one\n";
        $dans = new dansguardian_rules();
        if (isset($dans->array_blacksites[$category])) {
            $q->CreateCategoryTable($category);
        }
    }
    if (!$q->TABLE_EXISTS($table)) {
        echo "`{$category}` -> no such table \"{$table}\"\n";
        return;
    }
    $sql = "SELECT COUNT(*) AS TCOUNT FROM {$table}";
    $q->QUERY_SQL($sql);
    if (!$q->ok) {
        echo $q->mysql_error . "\n";
        if (preg_match("#is marked as crashed and last#", $q->mysql_error)) {
            echo "`{$table}` -> crashed, remove \"{$table}\"\n";
            $q->QUERY_SQL("DROP TABLE {$table}");
            $q->QUERY_SQL("flush tables");
            $q = new mysql_squid_builder();
            echo "`{$table}` -> Create category \"{$category}\"\n";
            $q->CreateCategoryTable($category);
            $q->CreateCategoryTable($category);
            $q = new mysql_squid_builder();
        }
        if (!$q->TABLE_EXISTS($table)) {
            echo "`{$category}` -> no such table \"{$table}\"\n";
            return;
        }
    }
    if ($file == null) {
        $dir = "/var/lib/squidguard";
        if ($GLOBALS["SHALLA"]) {
            $dir = "/root/shalla/BL";
        }
        if (!is_file("{$dir}/{$category}/domains")) {
            echo "{$dir}/{$category}/domains no such file";
            return;
        }
        $file = "{$dir}/{$category}/domains";
    }
    if (!is_file($file)) {
        echo "{$file} no such file";
        return;
    }
    $sock = new sockets();
    $unix = new unix();
    $uuid = $unix->GetUniqueID();
    if ($uuid == null) {
        echo "No uuid\n";
        return;
    }
    echo "open {$file}\n";
    $handle = @fopen($file, "r");
    if (!$handle) {
//.........这里部分代码省略.........
开发者ID:BillTheBest,项目名称:1.6.x,代码行数:101,代码来源:exec.squidguard.php

示例9: WizardExecute

function WizardExecute($aspid = false)
{
    $unix = new unix();
    $sock = new sockets();
    @chmod("/usr/share/artica-postfix/bin/process1", 0755);
    @mkdir("/etc/artica-postfix/settings/Daemons", 0755, true);
    if (!$aspid) {
        $pidfile = "/etc/artica-postfix/pids/" . basename(__FILE__) . ".pid";
        $pid = @file_get_contents($pidfile);
        if ($unix->process_exists($pid, basename(__FILE__))) {
            die;
        }
        $pid = $unix->PIDOF_PATTERN(basename(__FILE__));
        if ($pid != getmypid()) {
            return;
        }
    }
    @file_put_contents($pidfile, getmypid());
    $unix->CREATE_NEW_UUID();
    $uuid = $unix->GetUniqueID();
    $php5 = $unix->LOCATE_PHP5_BIN();
    $php = $php5;
    $nohup = $unix->find_program("nohup");
    $squidbin = $unix->LOCATE_SQUID_BIN();
    $DEBUG_LOG = "/var/log/artica-wizard.log";
    @mkdir("/etc/artica-postfix/ldap_settings", 0755, true);
    @mkdir("/var/lib/ldap", 0755, true);
    $rmbin = $unix->find_program("rm");
    writeprogress(5, "{set_permissions}...");
    shell_exec("{$php} /usr/share/artica-postfix/exec.checkfolder-permissions.php --force --wizard");
    writeprogress(10, "{uuid}: {$uuid}");
    sleep(2);
    $savedsettings = unserialize(base64_decode(file_get_contents("/etc/artica-postfix/settings/Daemons/WizardSavedSettings")));
    if (!is_array($savedsettings)) {
        writeprogress(110, "No saved settings Corrupted Array...");
        die;
    }
    if (count($savedsettings) < 4) {
        writeprogress(110, "No saved settings no enough element...");
        die;
    }
    $smtp_domainname = trim($savedsettings["smtp_domainname"]);
    if ($smtp_domainname == null) {
        if (isset($savedsettings["domain"])) {
            $smtp_domainname = $savedsettings["domain"];
        }
    }
    if (strlen($smtp_domainname) < 3) {
        $smtp_domainname = "my-domain.com";
    }
    if ($smtp_domainname == ".") {
        $smtp_domainname = "my-domain.com";
    }
    if ($smtp_domainname == null) {
        $smtp_domainname = "my-domain.com";
    }
    if (strpos($smtp_domainname, ".") == 0) {
        $smtp_domainname = "my-domain.com";
    }
    writeprogress(12, "Using `{$smtp_domainname}` as LDAP suffix");
    if (strpos($smtp_domainname, ".") > 0) {
        $smtp_domainname_exploded = explode(".", $smtp_domainname);
        writeprogress(12, "{$smtp_domainname} " . count($smtp_domainname_exploded) . " items");
        $suffix = "dc=" . @implode(",dc=", $smtp_domainname_exploded);
    } else {
        $suffix = "dc={$smtp_domainname}";
    }
    $SQUIDEnable = 1;
    $AsCategoriesAppliance = intval($savedsettings["AsCategoriesAppliance"]);
    $AsTransparentProxy = intval($savedsettings["AsTransparentProxy"]);
    $AsReverseProxyAppliance = intval($savedsettings["AsReverseProxyAppliance"]);
    $AsMetaServer = intval($savedsettings["AsMetaServer"]);
    $WizardWebFilteringLevel = $sock->GET_INFO("WizardWebFilteringLevel");
    if (is_numeric($WizardWebFilteringLevel)) {
        $WizardSavedSettings["EnableWebFiltering"] = 1;
    }
    @file_put_contents("/etc/artica-postfix/settings/Daemons/DisableBWMng", 1);
    @file_put_contents("/etc/artica-postfix/settings/Daemons/SquidDatabasesUtlseEnable", 1);
    @file_put_contents("/etc/artica-postfix/settings/Daemons/AsMetaServer", $AsMetaServer);
    @file_put_contents("/etc/artica-postfix/settings/Daemons/AsCategoriesAppliance", $AsCategoriesAppliance);
    if ($AsCategoriesAppliance == 1) {
        $savedsettings["EnableWebFiltering"] = 0;
        @file_put_contents("/etc/artica-postfix/settings/Daemons/EnableUfdbGuard", 0);
        @file_put_contents("/etc/artica-postfix/settings/Daemons/SQUIDEnable", 0);
        @file_put_contents("/etc/artica-postfix/settings/Daemons/ProxyUseArticaDB", 0);
        @file_put_contents("/etc/artica-postfix/settings/Daemons/EnableArpDaemon", 0);
        @file_put_contents("/etc/artica-postfix/settings/Daemons/EnableFreeWeb", 0);
        @file_put_contents("/etc/artica-postfix/settings/Daemons/SlapdThreads", 2);
        @file_put_contents("/etc/artica-postfix/settings/Daemons/DisableBWMng", 1);
        @file_put_contents("/etc/artica-postfix/settings/Daemons/DisableNetDiscover", 1);
        @file_put_contents("/etc/artica-postfix/settings/Daemons/SambaEnabled", 0);
        $SQUIDEnable = 0;
    }
    if ($AsMetaServer == 1) {
        $savedsettings["EnableWebFiltering"] = 0;
        @file_put_contents("/etc/artica-postfix/settings/Daemons/EnableUfdbGuard", 0);
        @file_put_contents("/etc/artica-postfix/settings/Daemons/SQUIDEnable", 0);
        @file_put_contents("/etc/artica-postfix/settings/Daemons/ProxyUseArticaDB", 0);
        @file_put_contents("/etc/artica-postfix/settings/Daemons/EnableArpDaemon", 0);
        @file_put_contents("/etc/artica-postfix/settings/Daemons/EnableFreeWeb", 0);
//.........这里部分代码省略.........
开发者ID:BillTheBest,项目名称:1.6.x,代码行数:101,代码来源:exec.wizard-install.php

示例10: build

function build()
{
    $sock = new sockets();
    $emailprefix = null;
    $unix = new unix();
    $ini = new Bs_IniHandler();
    $IPADDRSSL = array();
    $IPADDRSSL2 = array();
    $users = new usersMenus();
    $uuid = $unix->GetUniqueID();
    if ($uuid == null) {
        if ($GLOBALS["OUTPUT"]) {
            echo "Starting......: " . date("H:i:s") . " [INIT]: {$GLOBALS["SERVICE_NAME"]} no UUID !!, return\n";
        }
        return;
    }
    $ArticaSquidParameters = $sock->GET_INFO('ArticaSquidParameters');
    $visible_hostname = $ini->_params["NETWORK"]["visible_hostname"];
    if ($visible_hostname == null) {
        $visible_hostname = $unix->hostname_g();
    }
    $SquidBinIpaddr = $sock->GET_INFO("SquidBinIpaddr");
    $AllowAllNetworksInSquid = $sock->GET_INFO("AllowAllNetworksInSquid");
    if (!is_numeric($AllowAllNetworksInSquid)) {
        $AllowAllNetworksInSquid = 1;
    }
    $ini->loadString($ArticaSquidParameters);
    NETWORK_ALL_INTERFACES();
    $LISTEN_PORT = intval($ini->_params["NETWORK"]["LISTEN_PORT"]);
    $ICP_PORT = intval(trim($ini->_params["NETWORK"]["ICP_PORT"]));
    $certificate_center = $ini->_params["NETWORK"]["certificate_center"];
    $SSL_BUMP = intval($ini->_params["NETWORK"]["SSL_BUMP"]);
    $ssl = false;
    if ($ICP_PORT == 0) {
        $ICP_PORT = 3130;
    }
    if ($LISTEN_PORT == 0) {
        $LISTEN_PORT = 3128;
    }
    $squid = new squidbee();
    $q = new mysql_squid_builder();
    $LogsWarninStop = intval($sock->GET_INFO("LogsWarninStop"));
    $chown = $unix->find_program("chown");
    $python = $unix->find_program("python");
    $StreamCachePort = intval($sock->GET_INFO("StreamCachePort"));
    $StreamCacheSize = intval($sock->GET_INFO("StreamCacheSize"));
    $StreamCacheSSLPort = intval($sock->GET_INFO("StreamCacheSSLPort"));
    $StreamCacheICPPort = intval($sock->GET_INFO("StreamCacheICPPort"));
    $StreamCacheLocalPort = intval($sock->GET_INFO("StreamCacheLocalPort"));
    $StreamCacheUrlRewiteNumber = intval($sock->GET_INFO("StreamCacheUrlRewiteNumber"));
    if ($StreamCacheSize == 0) {
        $StreamCacheSize = 1500;
    }
    if ($StreamCachePort == 0) {
        $StreamCachePort = 5559;
    }
    if ($StreamCacheLocalPort == 0) {
        $StreamCacheLocalPort = 5563;
    }
    if ($StreamCacheSSLPort == 0) {
        $StreamCacheSSLPort = 5560;
    }
    if ($StreamCacheICPPort == 0) {
        $StreamCacheICPPort = 5562;
    }
    if ($StreamCacheUrlRewiteNumber == 0) {
        $StreamCacheUrlRewiteNumber = 15;
    }
    $StreamCacheBindProxy = $squid->VerifStreamProxyBindIP();
    $StreamCacheOutProxy = $sock->GET_INFO("StreamCacheOutProxy");
    if (!isset($GLOBALS["NETWORK_ALL_INTERFACES"][$StreamCacheOutProxy])) {
        $StreamCacheOutProxy = null;
    }
    $f[] = "";
    $f[] = "# ************** REDIRECTOR ********************";
    $f[] = "url_rewrite_program {$python} /usr/share/videocache/videocache.py";
    $f[] = "url_rewrite_children {$StreamCacheUrlRewiteNumber}";
    $f[] = "url_rewrite_concurrency {$StreamCacheUrlRewiteNumber}";
    $f[] = "";
    $f[] = "# ***********************************************";
    $f[] = "";
    $f[] = "acl vc_deny_myport myport {$StreamCacheLocalPort}";
    $f[] = "";
    $f[] = "acl vc_deny_url url_regex -i \\.blip\\.tv\\/(.*)filename \\.hardsextube\\.com\\/videothumbs \\.xtube\\.com\\/(.*)(Thumb|videowall) www\\.youtube\\.com\\/";
    $f[] = "acl vc_deny_url url_regex -i \\.(youtube|googlevideo)\\.com\\/.*\\/manifest";
    $f[] = "acl vc_deny_url url_regex -i \\.(youtube|googlevideo)\\.com\\/videoplayback?.*playerretry=[0-9]";
    $f[] = "acl vc_deny_dom dstdomain .manifest.youtube.com .manifest.googlevideo.com";
    $f[] = "acl vc_deny_dom dstdomain .redirector.googlevideo.com .redirector.youtube.com";
    $f[] = "";
    $f[] = "acl vc_url url_regex -i \\/youku\\/[0-9A-Z]+\\/[0-9A-Z\\-]+\\.(flv|mp4|avi|mkv|mp3|rm|rmvb|m4v|mov|wmv|3gp|mpg|mpeg)";
    $f[] = "acl vc_url url_regex -i \\/(.*)key=[a-z0-9]+(.*)\\.flv";
    $f[] = "acl vc_url url_regex -i \\-xh\\.clients\\.cdn[0-9a-zA-Z]?[0-9a-zA-Z]?[0-9a-zA-Z]?\\.com\\/data\\/(.*)\\.flv";
    $f[] = "acl vc_url url_regex -i \\.(youtube|youtube-nocookie|googlevideo)\\.com\\/feeds\\/api\\/videos\\/[0-9a-zA-Z_-]{11}\\/";
    $f[] = "acl vc_url url_regex -i \\.(youtube|youtube-nocookie|googlevideo)\\.com\\/(videoplayback|get_video|watch_popup|user_watch|stream_204|get_ad_tags|get_video_info|player_204|ptracking|set_awesome)\\?";
    $f[] = "acl vc_url url_regex -i \\.(youtube|youtube-nocookie|googlevideo)\\.com\\/(v|e|embed)\\/[0-9a-zA-Z_-]{11}";
    $f[] = "acl vc_url url_regex -i \\.youtube\\.com\\/s\\? \\.youtube\\.com\\/api\\/stats\\/(atr|delayplay|playback|watchtime)\\?";
    $f[] = "acl vc_url url_regex -i \\.(youtube|youtube-nocookie|googlevideo)\\.com\\/videoplayback\\/id\\/[0-9a-zA-Z_-]+\\/";
    $f[] = "acl vc_url url_regex -i \\.android\\.clients\\.google\\.com\\/market\\/GetBinary\\/";
    $f[] = "acl vc_url url_regex -i cs(.*)\\.vk\\.me\\/(.*)/([a-zA-Z0-9.]+)\\.(flv|mp4|avi|mkv|mp3|rm|rmvb|m4v|mov|wmv|3gp|mpg|mpeg)";
    $f[] = "acl vc_url url_regex -i video(.*)\\.rutube\\.ru\\/(.*)/([a-zA-Z0-9.]+)\\.(flv|mp4|avi|mkv|mp3|rm|rmvb|m4v|mov|wmv|3gp|mpg|mpeg)Seg[0-9]+-Frag[0-9]+";
//.........这里部分代码省略.........
开发者ID:brucewu16899,项目名称:1.6.x,代码行数:101,代码来源:exec.squidstream.php

示例11: meta_admin_mysql_check

function meta_admin_mysql_check($nopid = false)
{
    $f = array();
    $unix = new unix();
    $sock = new sockets();
    $users = new usersMenus();
    $hostname = $unix->hostname_g();
    $BaseWorkDir = "{$GLOBALS["ARTICALOGDIR"]}/meta_admin_mysql";
    $uuid = $unix->GetUniqueID();
    if (!($handle = opendir($BaseWorkDir))) {
        echo "Failed open {$BaseWorkDir}\n";
        return;
    }
    $hostname = "master";
    $EnableArticaMetaServer = intval($sock->GET_INFO("EnableArticaMetaServer"));
    if ($EnableArticaMetaServer == 0) {
        $hostname = $unix->hostname_g();
    }
    $q = new mysql();
    if (!$q->test_mysql_connection()) {
        return;
    }
    if (!$q->TABLE_EXISTS("meta_admin_mysql", "artica_events")) {
        return;
    }
    if (!$q->ok) {
        meta_events("{$q->mysql_error}", __FUNCTION__, __FILE__, __LINE__);
        return;
    }
    while (false !== ($filename = readdir($handle))) {
        if ($filename == ".") {
            continue;
        }
        if ($filename == "..") {
            continue;
        }
        $targetFile = "{$BaseWorkDir}/{$filename}";
        if ($unix->file_time_min($targetFile) > 240) {
            @unlink($targetFile);
            continue;
        }
        $array = unserialize(@file_get_contents($targetFile));
        if (!is_array($array)) {
            @unlink($targetFile);
            continue;
        }
        if (!is_numeric($array["TASKID"])) {
            $array["TASKID"] = 0;
        }
        $content = mysql_escape_string2($array["text"]);
        $subject = mysql_escape_string2($array["subject"]);
        $zdate = $array["zdate"];
        $function = $array["function"];
        $file = $array["file"];
        $line = $array["line"];
        $TASKID = $array["TASKID"];
        $severity = $array["severity"];
        $zm5 = md5("{$zdate}{$subject}{$function}{$file}{$line}{$uuid}");
        meta_events("[meta_admin_mysql]:: {$subject} ", __FUNCTION__, __FILE__, __LINE__);
        $q->QUERY_SQL("INSERT IGNORE INTO `meta_admin_mysql`\n\t\t\t\t(`zmd5`,`uuid`,`zDate`,`content`,`subject`,`function`,`filename`,`line`,`severity`,`hostname`) VALUES\n\t\t\t\t('{$zm5}','{$uuid}','{$zdate}','{$content}','{$subject}','{$function}','{$file}','{$line}','{$severity}','{$hostname}')", "artica_events");
        $q->QUERY_SQL("INSERT IGNORE INTO `meta_admin_mysql`\n\t\t\t\t(`zDate`,`content`,`subject`,`function`,`filename`,`line`,`severity`,`hostname`) VALUES\n\t\t\t\t('{$zdate}','{$content}','{$subject}','{$function}','{$file}','{$line}','{$severity}','{$hostname}')", "artica_events");
        if (!$q->ok) {
            meta_events("{$q->mysql_error}", __FUNCTION__, __FILE__, __LINE__);
            return;
        }
        @unlink($targetFile);
    }
}
开发者ID:BillTheBest,项目名称:1.6.x,代码行数:68,代码来源:exec.syslog-engine.php

示例12: caches_infos


//.........这里部分代码省略.........
                if ($timepid < 15) {
                    ToSyslog("caches_infos(): Already task PID: {$pid} running since {$timepid}Mn");
                }
                $kill = $unix->find_program("{$kill}");
                unix_system_kill_force($pid);
            }
        }
    }
    if ($GLOBALS["VERBOSE"]) {
        echo "init...\n";
    }
    $q = new mysql_squid_builder();
    if (!$GLOBALS["FORCE"]) {
        $CacheTime = $unix->file_time_min($cacheFile);
        if ($CacheTime < 15) {
            EventsWatchdog("Max 15Mn, current={$CacheTime} ({$cacheFile})...");
            if ($GLOBALS["VERBOSE"]) {
                echo "Max 15Mn, current={$CacheTime}\n";
            }
            return;
        }
    }
    $squid_pid = SQUID_PID();
    if (!$unix->process_exists($squid_pid)) {
        $nohup = $unix->find_program("nohup");
        squid_admin_mysql(0, "Squid-Cache is not running..., start it", null, __FILE__, __LINE__);
        ToSyslog("caches_infos(): Squid-Cache is not running..., start it");
        shell_exec("{$nohup} /etc/init.d/squid start >/dev/null 2>&1 &");
        return;
    }
    @unlink($cacheFile);
    @file_put_contents($cacheFile, time());
    $ttl = $unix->PROCCESS_TIME_MIN($squid_pid);
    if ($unix->PROCCESS_TIME_MIN($squid_pid) < 5) {
        ToSyslog("caches_infos(): squid-cache running only since {$ttl}mn, aborting");
        return;
    }
    ToSyslog("caches_infos(): Starting get Squid-cache informations.");
    $array = $unix->squid_get_cache_infos();
    for ($i = 0; $i < 10; $i++) {
        $check = true;
        if (!is_array($array)) {
            if ($GLOBALS["VERBOSE"]) {
                echo "unix->squid_get_cache_infos() Not an array...\n";
            }
            $check = false;
            sleep(1);
            $array = $unix->squid_get_cache_infos();
            continue;
        }
        if (count($array) == 0) {
            if ($GLOBALS["VERBOSE"]) {
                echo "unix->squid_get_cache_infos() O items !!\n";
            }
            $check = false;
            sleep(1);
            $array = $unix->squid_get_cache_infos();
            continue;
        }
        if ($check) {
            break;
        }
    }
    if (!is_array($array)) {
        if ($GLOBALS["VERBOSE"]) {
            echo "unix->squid_get_cache_infos() Not an array...\n";
        }
        return;
    }
    if (count($array) == 0) {
        if ($GLOBALS["VERBOSE"]) {
            echo basename(__FILE__) . "[" . __LINE__ . "] unix->squid_get_cache_infos() O items !!...\n";
        }
        @file_put_contents("/usr/share/artica-postfix/ressources/logs/web/squid_get_cache_infos.db", serialize($array));
        @chmod("/usr/share/artica-postfix/ressources/logs/web/squid_get_cache_infos.db", 0755);
        return;
    }
    @unlink("/usr/share/artica-postfix/ressources/logs/web/squid_get_cache_infos.db");
    @file_put_contents("/usr/share/artica-postfix/ressources/logs/web/squid_get_cache_infos.db", serialize($array));
    @chmod("/usr/share/artica-postfix/ressources/logs/web/squid_get_cache_infos.db", 0755);
    $uuid = $unix->GetUniqueID();
    $profix = "INSERT IGNORE INTO cachestatus(uuid,cachedir,maxsize,currentsize,pourc) VALUES ";
    while (list($directory, $arrayDir) = each($array)) {
        $directory = trim($directory);
        if ($directory == null) {
            continue;
        }
        if ($GLOBALS["VERBOSE"]) {
            echo "('{$uuid}','{$directory}','{$arrayDir["MAX"]}','{$arrayDir["CURRENT"]}','{$arrayDir["POURC"]}')\n";
        }
        $f[] = "('{$uuid}','{$directory}','{$arrayDir["MAX"]}','{$arrayDir["CURRENT"]}','{$arrayDir["POURC"]}')";
    }
    if (count($f) > 0) {
        $q->QUERY_SQL("DELETE FROM cachestatus WHERE uuid='{$uuid}'");
        $q->QUERY_SQL("{$profix}" . @implode(",", $f));
        if (!$q->ok) {
            echo $q->mysql_error . "\n";
        }
    }
}
开发者ID:brucewu16899,项目名称:1.6.x,代码行数:101,代码来源:exec.squid.php

示例13: HyperCache_create_license

function HyperCache_create_license()
{
    $sock = new sockets();
    $unix = new unix();
    $uuid = $unix->GetUniqueID();
    if ($uuid == null) {
        if ($GLOBALS["VERBOSE"]) {
            echo "No system ID !\n";
        }
        return;
    }
    $HyperCacheStoreID = intval($sock->GET_INFO("HyperCacheStoreID"));
    if ($HyperCacheStoreID == 0) {
        return;
    }
    $HyperCacheStoreIDLicense = $sock->GET_INFO("HyperCacheStoreIDLicense");
    if ($HyperCacheStoreIDLicense == null) {
        echo "No license set..., continue in evalution mode\n";
        return;
    }
    $uri = "https://svb.unveiltech.com/svblicenseaction.php?ma=86&license={$HyperCacheStoreIDLicense}";
    $curl = new ccurl($uri);
    $curl->parms["ma"] = 86;
    $curl->parms["license"] = $HyperCacheStoreIDLicense;
    $curl->parms["artid"] = $uuid;
    if (!$curl->get()) {
        echo "HyperCache:: Check license failed\n";
        return false;
    }
    echo $curl->data . "\n";
    if (intval(trim($curl->data)) == 1) {
        return true;
    }
    if (stripos($curl->data, "The Activation Code is not valid") > 0) {
        return false;
    }
    if (stripos($curl->data, "The Activation Code is already activated") > 0) {
        return true;
    }
    if (stripos($curl->data, "The Activation Code is already activated with another server") > 0) {
        return false;
    }
}
开发者ID:BillTheBest,项目名称:1.6.x,代码行数:43,代码来源:exec.hypercache-dedup.php

示例14: Export

function Export($asPid = false)
{
    return;
    $unix = new unix();
    $restartProcess = false;
    $nohup = $unix->find_program("nohup");
    $php5 = $unix->LOCATE_PHP5_BIN();
    $cachetime = "/etc/artica-postfix/pids/" . basename(__FILE__) . "." . __FUNCTION__ . ".time";
    if ($GLOBALS["VERBOSE"]) {
        echo "CacheTime: {$cachetime}\n";
    }
    $restart_cmd = trim("{$nohup} {$php5} " . __FILE__ . " --export >/dev/null 2>&1 &");
    $sock = new sockets();
    shell_exec(trim("{$nohup} {$php5} " . __FILE__ . " --export-not-categorized >/dev/null 2>&1 &"));
    if ($asPid) {
        $pidfile = "/etc/artica-postfix/pids/" . basename(__FILE__) . "." . __FUNCTION__ . ".pid";
        $unix = new unix();
        $pid = @file_get_contents($pidfile);
        if ($unix->process_exists($pid, basename(__FILE__))) {
            WriteMyLogs("Already executed PID:{$pid}, die()", __FUNCTION__, __FILE__, __LINE__);
            die;
        }
        @file_put_contents($pidfile, getmypid());
    }
    $uuid = $unix->GetUniqueID();
    if ($uuid == null) {
        if ($GLOBALS["VERBOSE"]) {
            echo "No system ID !\n";
        }
        return;
    }
    $q = new mysql_squid_builder();
    $tables = $q->LIST_TABLES_CATEGORIES();
    $c = 0;
    while (list($table, $www) = each($tables)) {
        $limit = null;
        $limitupate = null;
        if (!preg_match("#category_(.+?)\$#", $table)) {
            continue;
        }
        if (!$q->TABLE_EXISTS($table)) {
            continue;
        }
        $sql = "SELECT COUNT(zmd5) as tcount FROM {$table} WHERE sended=0 and enabled=1";
        $q->CreateCategoryTable(null, $table);
        $ligne = mysql_fetch_array($q->QUERY_SQL($sql));
        if (!$q->ok) {
            writelogs("{$table} {$q->mysql_error}", __FUNCTION__, __FILE__, __LINE__);
            return;
        }
        $prefix = "INSERT IGNORE INTO categorize (zmd5 ,pattern,zDate,uuid,category) VALUES";
        if ($ligne["tcount"] > 0) {
            writelogs("{$table} {$ligne["tcount"]} items to export", __FUNCTION__, __FILE__, __LINE__);
            if ($ligne["tcount"] > 5000) {
                $limit = "LIMIT 0,5000";
                $limitupate = "LIMIT 5000";
            }
            $results = $q->QUERY_SQL("SELECT * FROM {$table} WHERE sended=0 AND enabled=1 {$limit}");
            while ($ligne2 = mysql_fetch_array($results, MYSQL_ASSOC)) {
                $md5 = md5("{$ligne2["category"]}{$ligne2["pattern"]}");
                $f[] = "('{$md5}','{$ligne2["pattern"]}','{$ligne2["zDate"]}','{$uuid}','{$ligne2["category"]}')";
                $c++;
                if (count($f) > 1000) {
                    $q->QUERY_SQL($prefix . @implode(",", $f));
                    if (!$q->ok) {
                        echo $q->mysql_error . "\n";
                        return;
                    }
                    $f = array();
                }
            }
            $q->QUERY_SQL("UPDATE {$table} SET sended=1 WHERE sended=0 {$limitupate}");
        }
    }
    if (count($f) > 0) {
        $q->QUERY_SQL($prefix . @implode(",", $f));
        $f = array();
    }
    $ALLCOUNT = $q->COUNT_ROWS("categorize");
    if ($GLOBALS["VERBOSE"]) {
        echo "Total row in categorize table: {$ALLCOUNT}\n";
    }
    if ($ALLCOUNT > 2000) {
        $restartProcess = true;
    }
    $sql = "SELECT * FROM categorize ORDER BY zDate DESC LIMIT 0,2000";
    if ($GLOBALS["VERBOSE"]) {
        echo "Execute query\n";
    }
    $results = $q->QUERY_SQL($sql, "artica_backup");
    if (!$q->ok) {
        echo $q->mysql_error . "\n{$sql}\n";
        return;
    }
    while ($ligne = @mysql_fetch_array($results, MYSQL_ASSOC)) {
        if ($ligne["category"] == null) {
            continue;
        }
        if ($ligne["pattern"] == null) {
            continue;
//.........这里部分代码省略.........
开发者ID:BillTheBest,项目名称:1.6.x,代码行数:101,代码来源:exec.web-community-filter.php

示例15: caches_infos

function caches_infos()
{
    $unix = new unix();
    $squid_pid = SQUID_PID();
    if (!$unix->process_exists($squid_pid)) {
        $nohup = $unix->find_program("nohup");
        squid_admin_mysql(0, "Squid-Cache is not running...", null, __FILE__, __LINE__);
        return;
    }
    $ttl = $unix->PROCCESS_TIME_MIN($squid_pid);
    if ($unix->PROCCESS_TIME_MIN($squid_pid) < 5) {
        ToSyslog("caches_infos(): squid-cache running only since {$ttl}mn, aborting");
        return;
    }
    ToSyslog("caches_infos(): Starting get Squid-cache informations.");
    $array = $unix->squid_get_cache_infos();
    for ($i = 0; $i < 10; $i++) {
        $check = true;
        if (!is_array($array)) {
            if ($GLOBALS["VERBOSE"]) {
                echo "unix->squid_get_cache_infos() Not an array...\n";
            }
            $check = false;
            sleep(1);
            $array = $unix->squid_get_cache_infos();
            continue;
        }
        if (count($array) == 0) {
            if ($GLOBALS["VERBOSE"]) {
                echo "unix->squid_get_cache_infos() O items !!\n";
            }
            $check = false;
            sleep(1);
            $array = $unix->squid_get_cache_infos();
            continue;
        }
        if ($check) {
            break;
        }
    }
    if (!is_array($array)) {
        if ($GLOBALS["VERBOSE"]) {
            echo "unix->squid_get_cache_infos() Not an array...\n";
        }
        return;
    }
    if (count($array) == 0) {
        if ($GLOBALS["VERBOSE"]) {
            echo basename(__FILE__) . "[" . __LINE__ . "] unix->squid_get_cache_infos() O items !!...\n";
        }
        @file_put_contents("/usr/share/artica-postfix/ressources/logs/web/squid_get_cache_infos.db", serialize($array));
        @chmod("/usr/share/artica-postfix/ressources/logs/web/squid_get_cache_infos.db", 0755);
        return;
    }
    @unlink("/usr/share/artica-postfix/ressources/logs/web/squid_get_cache_infos.db");
    @file_put_contents("/usr/share/artica-postfix/ressources/logs/web/squid_get_cache_infos.db", serialize($array));
    @chmod("/usr/share/artica-postfix/ressources/logs/web/squid_get_cache_infos.db", 0755);
    $q = new mysql_squid_builder();
    $uuid = $unix->GetUniqueID();
    $profix = "INSERT IGNORE INTO cachestatus(uuid,cachedir,maxsize,currentsize,pourc) VALUES ";
    while (list($directory, $arrayDir) = each($array)) {
        $directory = trim($directory);
        if ($directory == null) {
            continue;
        }
        if ($GLOBALS["VERBOSE"]) {
            echo "('{$uuid}','{$directory}','{$arrayDir["MAX"]}','{$arrayDir["CURRENT"]}','{$arrayDir["POURC"]}')\n";
        }
        $f[] = "('{$uuid}','{$directory}','{$arrayDir["MAX"]}','{$arrayDir["CURRENT"]}','{$arrayDir["POURC"]}')";
    }
    if (count($f) > 0) {
        $q->QUERY_SQL("TRUNCATE TABLE cachestatus");
        $q->QUERY_SQL("{$profix}" . @implode(",", $f));
        if (!$q->ok) {
            echo $q->mysql_error . "\n";
        }
    }
}
开发者ID:articatech,项目名称:artica,代码行数:78,代码来源:exec.squid.watchdog.php


注:本文中的unix::GetUniqueID方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。