Esempio n. 1
0
function mmcache_copy_dir($src, $dir, $f)
{
    $stat = stat($src);
    $old = umask(0);
    $ret = mmcache_mkdir($dir, $f);
    umask($old);
    return $ret;
}
Esempio n. 2
0
function mmcache_encoder_web()
{
    echo "<html><head><title>Turck MMCache Encoder</title></head>" . "<body><h1 align=\"center\">Turck MMCache Encoder " . MMCACHE_VERSION . "</h1>";
    $error = "";
    $source = "";
    $target = "";
    $s = "php";
    $suffixies = "php";
    if (isset($_POST["submit"])) {
        if (isset($_POST["source"])) {
            $source = $_POST["source"];
        }
        if (isset($_POST["target"])) {
            $target = $_POST["target"];
        }
        if (isset($_POST["suffixies"])) {
            $suffixies = $_POST["suffixies"];
            if (strpos($suffixies, ",") !== false) {
                $s = explode(",", $suffixies);
            } else {
                $s = $suffixies;
            }
        }
        $all = isset($_POST["all"]) ? $_POST["all"] : false;
        $links = isset($_POST["links"]) ? $_POST["links"] : false;
        $recursive = isset($_POST["recursive"]) ? $_POST["recursive"] : false;
        $copy = isset($_POST["copy"]) ? $_POST["copy"] : false;
        $force = isset($_POST["force"]) ? $_POST["force"] : false;
        if (empty($source)) {
            $error = "ERROR: Source is not specified!";
        } else {
            if (!file_exists($source)) {
                $error = "ERROR: Source file \"{$source}\" doesn't exist.\n";
            } else {
                if (is_dir($source)) {
                    if (mmcache_mkdir($target, $force, 1)) {
                        if ($all) {
                            $s = "";
                        }
                        mmcache_encode_dir($source, $target, $s, $recursive, $links, $copy, $force, 1);
                    }
                } else {
                    mmcache_encode_file($source, $target, $force, $copy, 1);
                }
                global $web_error;
                if (empty($web_error)) {
                    echo "<br><b>DONE</b></html>";
                    return;
                } else {
                    $error = $web_error;
                }
            }
        }
    }
    echo "<h3 align=\"center\"><font color=\"#ff0000\">{$error}</font></h3>" . "<form method=\"POST\">" . "<table border=\"0\" cellpadding=\"3\" cellspacing=\"1\" width=\"600\" bgcolor=\"#000000\" align=\"center\">" . "<tr valign=\"baseline\" bgcolor=\"#cccccc\"><td width=\"50%\" bgcolor=\"#ccccff\"><b>Souce file or directory name:</b></td><td width=\"50%\"><input type=\"text\" name=\"source\" size=\"32\" value=\"{$source}\" style=\"width:100%\"></td></tr>" . "<tr valign=\"baseline\" bgcolor=\"#cccccc\"><td width=\"50%\" bgcolor=\"#ccccff\"><b>Target file or directory name:</b></td><td width=\"50%\"><input type=\"text\" name=\"target\" size=\"32\" value=\"{$target}\" style=\"width:100%\"></td></tr>" . "<tr valign=\"baseline\" bgcolor=\"#cccccc\"><td width=\"50%\" bgcolor=\"#ccccff\"><b>PHP suffixies <small>(comma separated list)</small>:</b></td><td width=\"50%\"><input type=\"text\" name=\"suffixies\" size=\"32\" value=\"{$suffixies}\" style=\"width:100%\"></td></tr>" . "<tr valign=\"baseline\" bgcolor=\"#cccccc\"><td width=\"50%\" bgcolor=\"#ccccff\"><b>Options:</b></td><td width=\"50%\">" . "<input type=\"checkbox\" id=\"all\" name=\"all\"" . (empty($all) ? "" : " checked") . "> - <label for=\"all\">encode all files</label><br>" . "<input type=\"checkbox\" id=\"links\" name=\"links\"" . (empty($links) ? "" : " checked") . "> - <label for=\"links\">follow symbolic links</label><br>" . "<input type=\"checkbox\" id=\"recursive\" name=\"recursive\"" . (empty($recursive) ? "" : " checked") . "> - <label for=\"recursive\">encode directories recursively</label><br>" . "<input type=\"checkbox\" id=\"copy\" name=\"copy\"" . (empty($copy) ? "" : " checked") . "> - <label for=\"copy\">copy files those shouldn't be encoded</label><br>" . "<input type=\"checkbox\" id=\"force\" name=\"force\"" . (empty($force) ? "" : " checked") . "> - <label for=\"force\">overwrite existing files</label><br>" . "</td></tr>" . "<tr><td colspan=\"2\" align=\"center\" bgcolor=\"#cccccc\"><input type=\"submit\" name=\"submit\" value=\"OK\" style=\"width:100px\"></td></tr>" . "</form></body></html>";
}