<commit_before><?php
//das ist notwendig damit cli scripte was mit dem apc cache machen können
//direkt in der cli ist das leider nicht möglich, da der speicher im webserver liegt
class Kwf_Util_Apc
{
    public static function getHttpPassword()
    {
        $file = 'cache/apcutilspass';
        if (!file_exists($file)) {
            file_put_contents($file, time().rand(100000, 1000000));
        }
        return file_get_contents($file);
    }

    public static function callClearCacheByCli($params)
    {
        $config = Kwf_Registry::get('config');
        $d = $config->server->domain;
        if (!$d && file_exists('cache/lastdomain')) {
            //this file gets written in Kwf_Setup to make it "just work"
            $d = file_get_contents('cache/lastdomain');
        }
        $s = microtime(true);
        $pwd = Kwf_Util_Apc::getHttpPassword();
        $urlPart = "http".($config->server->https?'s':'')."://apcutils:".Kwf_Util_Apc::getHttpPassword()."@";
        $url = "$urlPart$d/kwf/util/apc/clear-cache";

        $client = new Zend_Http_Client();
        $client->setMethod(Zend_Http_Client::POST);
        $client->setParameterPost($params);
        $client->setConfig(array(
            'timeout' => 60,
            'keepalive' => true
        ));

        $client->setUri($url);
        $body = 'could not reach web per http';
        try {
            $response = $client->request();
            $result = !$response->isError() && substr($response->getBody(), 0, 2) == 'OK';
            $body = $response->getBody();
        } catch (Exception $e) {
            $result = false;
        }
        if (!$result && $config->server->noRedirectPattern) {
            $d = str_replace(array('^', '\\', '$'), '', $config->server->noRedirectPattern);
            $url2 = "$urlPart$d/kwf/util/apc/clear-cache";
            try {
                $client->setUri($url2);
                $response = $client->request();
                $result = !$response->isError() && substr($response->getBody(), 0, 2) == 'OK';
                $body = $response->getBody();
            } catch (Exception $e) {
                $result = false;
            }
        }
        return array(
            'result' => $result,
            'message' => $body,<commit_msg>setting params again for second attempt when clearing apc-cache<commit_after><?php
//das ist notwendig damit cli scripte was mit dem apc cache machen können
//direkt in der cli ist das leider nicht möglich, da der speicher im webserver liegt
class Kwf_Util_Apc
{
    public static function getHttpPassword()
    {
        $file = 'cache/apcutilspass';
        if (!file_exists($file)) {
            file_put_contents($file, time().rand(100000, 1000000));
        }
        return file_get_contents($file);
    }

    public static function callClearCacheByCli($params)
    {
        $config = Kwf_Registry::get('config');
        $d = $config->server->domain;
        if (!$d && file_exists('cache/lastdomain')) {
            //this file gets written in Kwf_Setup to make it "just work"
            $d = file_get_contents('cache/lastdomain');
        }
        $s = microtime(true);
        $pwd = Kwf_Util_Apc::getHttpPassword();
        $urlPart = "http".($config->server->https?'s':'')."://apcutils:".Kwf_Util_Apc::getHttpPassword()."@";
        $url = "$urlPart$d/kwf/util/apc/clear-cache";

        $client = new Zend_Http_Client();
        $client->setMethod(Zend_Http_Client::POST);
        $client->setParameterPost($params);
        $client->setConfig(array(
            'timeout' => 60,
            'keepalive' => true
        ));

        $client->setUri($url);
        $body = 'could not reach web per http';
        try {
            $response = $client->request();
            $result = !$response->isError() && substr($response->getBody(), 0, 2) == 'OK';
            $body = $response->getBody();
        } catch (Exception $e) {
            $result = false;
        }
        if (!$result && $config->server->noRedirectPattern) {
            $d = str_replace(array('^', '\\', '$'), '', $config->server->noRedirectPattern);
            $url2 = "$urlPart$d/kwf/util/apc/clear-cache";
            try {
                $client->setUri($url2);
                $client->setParameterPost($params);
                $response = $client->request();
                $result = !$response->isError() && substr($response->getBody(), 0, 2) == 'OK';
                $body = $response->getBody();
            } catch (Exception $e) {
                $result = false;
            }
        }
        return array(
            'result' => $result,
            'message' => $body,
{'fraction_non_alphanumeric': 0.16122098022355977, 'fraction_numerical': 0.009028374892519347, 'mean_word_length': 2.102, 'pattern_counts': {'":': 2, '<': 5, '<?xml version=': 0, '>': 54, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1304750', 'n_tokens_mistral': 1432, 'n_tokens_neox': 1376, 'n_words': 290}