Пример #1
0
function do_htaccess($oldfilename, $newfilename, $base, $url)
{
    // remove ending slash from $base and $url
    $htaccess = '';
    if (substr($base, -1) == '/') {
        $base = substr($base, 0, -1);
    }
    if (substr($url, -1) == '/') {
        $url = substr($url, 0, -1);
    }
    $err = '';
    if (is_file($oldfilename)) {
        $fp = @fopen($oldfilename, "r");
        if ($fp) {
            while (!feof($fp)) {
                $htaccess .= fgets($fp, 4096);
            }
            fclose($fp);
            $htaccess = str_replace("BASE", $base, $htaccess);
            if (touch($newfilename)) {
                $fp = fopen($newfilename, "w");
                if ($fp) {
                    fwrite($fp, $htaccess);
                    fclose($fp);
                } else {
                    $err = "could not open {$newfilename} for writing";
                }
            } else {
                $err = "could not open {$newfilename} for writing";
            }
        } else {
            $err = "could not open {$oldfilename} for reading";
        }
    } else {
        $err = "{$oldfilename} not found";
    }
    if ($err != '') {
        print "<h2>Warning!</h2>";
        print "<p><strong>There was a problem creating the .htaccess file.</strong> </p>";
        print "<p style='color: #900'>Error: ";
        if ($err == "could not open {$newfilename} for writing") {
            print "Could Not Write To {$newfilename}.";
        } elseif ($err == "could not open {$oldfilename} for reading") {
            print "I could not read from {$oldfilename}. ";
        } elseif ($err == "{$oldfilename} not found") {
            print "The file, {$oldfilename}, is missing.";
        }
        print "</p>";
        filestats($err);
        print "<p>Please ensure that the webserver can write to this directory.</p>";
        print "<p>If you use Cpanel then read <a href='http://mu.wordpress.org/forums/topic.php?id=99'>this post</a>. Cpanel creates files that I need to overwrite and you have to fix that.</p>";
        print "<p>If all else fails then you'll have to create it by hand:";
        print "<ul>\n\t\t\t<li> Download htaccess.dist to your computer and open it in your favourite text editor.</li>\n\t\t\t<li> Replace the following text:\n\t\t\t<ul>\n\t\t\t<li>BASE by '{$base}'</li>\n\t\t\t<li>HOST by '{$url}'</li>\n\t\t\t</ul>\n\t\t\t</li>\n\t\t\t<li> Rename htaccess.dist to .htaccess and upload it back to the same directory.</li>\n\t\t\t</ul>";
        die("Installation Aborted!");
    }
}
Пример #2
0
                        $farr[$i][1] = $dr . '/' . $el;
                    }
                }
            }
        }
        $i++;
        $el = readdir($d);
    }
    closedir($d);
    usort($dirarr, 'namesort');
    usort($farr, 'namesort');
    foreach ($dirarr as $direlem) {
        $ret2 .= "<tr><td class='w0'><a href='javascript:void(0);' onclick='showFileMenu(\\\"" . myconv(str_replace("'", "&#39;", "{$direlem[1]}")) . "\\\",event,1);'>[dir]</a></td><td><a href='javascript:void(0);' onclick='getDir(\\\"" . myconv(str_replace(array("'", '\\'), array("&#39;", '/'), $direlem[1])) . "\\\");'>" . cutlen(myconv(str_replace("'", "&#39;", $direlem[0]))) . "</a></td><td class='w1'>" . filestats($direlem[1]) . "</td><td class='w1'>-</td><td class='w1'>" . myfiletime($direlem[1]) . "</td></tr>";
    }
    foreach ($farr as $felem) {
        $ret .= "<tr><td class='w0'>&nbsp;</td><td><a href='javascript:void(0);' onclick='showFileMenu(\\\"" . myconv(str_replace("'", "&#39;", $felem[1])) . "\\\",event);'>" . cutlen(myconv(str_replace("'", "&#39;", $felem[0]))) . "</a></td><td class='w1'>" . filestats($felem[1]) . "</td><td class='w1'>" . myfilesize($felem[1]) . "</td><td class='w1'>" . myfiletime($felem[1]) . "</td></tr>";
    }
    ajax_die("set_files(\"{$xadd}<br><table class='ftable' cellpadding=1 cellspacing=1><tr class='hd' align=center><td>&nbsp;</td><td>Имя</td><td>Права</td><td>Размер</td><td>Изменён</td></tr>{$ret3}{$ret2}{$ret}</table>\",\"" . myconv($dr) . "\");");
}
if (isset($_POST['fileact']) && !is_array($_POST['fileact']) && isset($_POST['params']) && !is_array($_POST['params']) && isset($_POST['fl']) && !is_array($_POST['fl'])) {
    $p = $_POST['params'];
    if (get_magic_quotes_gpc()) {
        $p = stripslashes($p);
    }
    $fl = $_POST['fl'];
    if (get_magic_quotes_gpc()) {
        $fl = stripslashes($fl);
    }
    $p = myconv($p, 1);
    $fl = myconv($fl, 1);
    $fl = str_replace('\\', '/', $fl);