}
    MultiFormReturn($aGetVars["return"]);
    exit;
}
//
// Hook system: after initialization
//
if ($HOOK_DIR !== "") {
    if (!@(include "{$HOOK_DIR}/fmhookpostinit.inc.php")) {
        @(include "{$HOOK_DIR}/fmhookpostinit.inc");
    }
}
//
// check configuration values for potential security problems
//
CheckConfig();
//
// otherwise, do the real processing of FormMail
//
$aStrippedFormVars = $aAllRawValues = StripGPCArray($aFormVars);
if (ENABLE_ATTACK_DETECTION) {
    DetectAttacks($aAllRawValues);
}
//
// Copy in configured session variables, overwriting any
// fields that are empty.
//
$SessionAccessor->CopyIn($aAllRawValues, true);
$SessionAccessor->CopyIn($aStrippedFormVars, true);
//
// process the options
Example #2
0
File: proxy.php Project: hsiun/yoyo
function UCloud_MakePrivateUrl($bucket, $key, $expires = 0)
{
    $err = CheckConfig(ActionType::GETFILE);
    if ($err != null) {
        return array(null, $err);
    }
    global $UCLOUD_PUBLIC_KEY;
    $public_url = UCloud_MakePublicUrl($bucket, $key);
    $req = new HTTP_Request('GET', array('path' => $public_url), null, $bucket, $key);
    if ($expires > 0) {
        $req->Header['Expires'] = $expires;
    }
    $client = new UCloud_AuthHttpClient(null);
    $temp = $client->Auth->SignRequest($req, null, QUERY_STRING_CHECK);
    $signature = substr($temp, -28, 28);
    $url = $public_url . "?UCloudPublicKey=" . $UCLOUD_PUBLIC_KEY . "&Signature=" . $signature;
    if ('' != $expires) {
        $url .= "&Expires=" . $expires;
    }
    return $url;
}
Example #3
0
function CheckConfig($path)
{
    $unix = new unix();
    $RESULTS = true;
    $squidbin = $unix->find_program("squid");
    $SQUID_CONFIG_PATH = $unix->SQUID_CONFIG_PATH();
    if (!is_file($squidbin)) {
        $squidbin = $unix->find_program("squid3");
    }
    build_progress("{checking_configuration}", 79);
    exec("{$squidbin} -f {$path} -k parse 2>&1", $results);
    $f = explode("\n", @file_get_contents($path));
    echo "Starting......: " . date("H:i:s") . " [SYS]: With " . count($f) . " lines\n";
    $Save = false;
    while (list($index, $ligne) = each($results)) {
        if (preg_match("#FATAL: refresh_pattern#", $ligne)) {
            if (preg_match("#FATAL: Bungled .*?line ([0-9]+)#", $results[$index + 1], $re)) {
                build_progress("{operation_failed} !!!", 110);
                $line = $re[1];
                $myLine = $line - 1;
                echo "Starting......: " . date("H:i:s") . " [SYS]: Squid error on `refresh_pattern` on line {$myLine} remove it\n";
                echo "Starting......: " . date("H:i:s") . " [SYS]: {$ligne}\n";
                $GLOBALS["SQUID_PATTERN_ERROR"][] = $f[$myLine];
                $Save = true;
                unset($f[$myLine]);
                continue;
            }
            $RESULTS = false;
        }
        if (preg_match("#FATAL: Bungled .*? line ([0-9]+):\\s+refresh_pattern#", $ligne, $re)) {
            build_progress("{operation_failed} !!!", 110);
            $line = $re[1];
            $myLine = $line - 1;
            echo "Starting......: " . date("H:i:s") . " [SYS]: Squid error on `refresh_pattern` on line {$myLine} remove it\n";
            echo "Starting......: " . date("H:i:s") . " [SYS]: {$ligne}\n";
            $GLOBALS["SQUID_PATTERN_ERROR"][] = $f[$myLine];
            $Save = true;
            unset($f[$myLine]);
            continue;
        }
    }
    if ($Save) {
        echo "Starting......: " . date("H:i:s") . " [SYS]: Saving new file {$path} With " . count($f) . " lines\n";
        @file_put_contents($path, @implode("\n", $f));
        return CheckConfig($path);
    }
    return $RESULTS;
}
Example #4
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 #5
0
    die;
}
if ($argv[1] == "--shm") {
    $GLOBALS["VERBOSE"] = true;
    echo $unix->TMPFS_CURRENTSIZE("/run/shm") . "\n";
}
if ($argv[1] == "--SquidReloadInpublicAlias") {
    SquidReloadInpublicAlias();
    exit;
}
if ($argv[1] == "--disableUFDB") {
    disableUFDB($argv[2]);
    return;
}
if ($argv[1] == "--checks") {
    CheckConfig($argv[2]);
    return;
}
if ($argv[1] == "--notify-clients-proxy") {
    notify_remote_proxys();
    return;
}
if ($argv[1] == "--ping-clients-proxy") {
    notify_remote_proxys("PING");
    return;
}
if ($argv[1] == "--export-tables") {
    StatsApplianceExportTables();
    return;
}
if ($argv[1] == "--reload-squid") {