static public function install($dir = ".")
    {
        $cookieCode = md5(rand());
        $strReplaceS = array("{SRC_DIR}", "{CUR_DIR}", "{COOKIE_CODE}");
        $strReplaceR = array(__DIR__."/..", $dir, $cookieCode);
        $f = fopen($dir . "/.htaccess", "a");
        if(strpos(file_get_contents($dir."/.htaccess"), "##START twofactor-dir")===false)
        {
            fwrite($f, str_replace($strReplaceS, $strReplaceR, file_get_contents(__DIR__ . "/../files/x.htaccess")));
        }
        else
        {
            //I get the old cookie code
            $preg = "/RewriteCond %{HTTP_COOKIE}  !twofactorDir-.*=(.*)/";
            $ret = array();
            preg_match($preg, file_get_contents($dir."/.htaccess"),$ret);
            $strReplaceR[2] = $ret[1];
        }
        fclose($f);

        $f = fopen($dir . "/redirect.php", "w");
        fwrite($f, str_replace($strReplaceS,$strReplaceR,file_get_contents(__DIR__ . "/../files/redirect.php")));
        fclose($f);

        $f = fopen($dir . "/get_qr.php", "w");
        fwrite($f, str_replace($strReplaceS,$strReplaceR,file_get_contents(__DIR__ . "/../files/get_qr.php")));
        fclose($f);

        fclose(fopen($dir . "/secret.php", "a")); //create secret if it doesn't exists
    }