Файл: htaccess-editor.php
Строк: 151
<?php
require_once "core.php";
head();
if (isset($_POST['ht-edit'])) {
$fn = $_SERVER['DOCUMENT_ROOT'] . "/.htaccess";
@chmod($fn, 0777);
@$file = fopen($fn, "w+");
fwrite($file, $_POST['htaccess']);
fclose($file);
}
?>
<div class="content-wrapper">
<!--CONTENT CONTAINER-->
<!--===================================================-->
<div class="content-header">
<div class="container-fluid">
<div class="row mb-2">
<div class="col-sm-6">
<h1 class="m-0 "><i class="fas fa-columns"></i> .htaccess Editor</h1>
</div>
<div class="col-sm-6">
<ol class="breadcrumb float-sm-right">
<li class="breadcrumb-item"><a href="dashboard.php"><i class="fas fa-home"></i> Admin Panel</a></li>
<li class="breadcrumb-item active">.htaccess Editor</li>
</ol>
</div>
</div>
</div>
</div>
<!--Page content-->
<!--===================================================-->
<div class="content">
<div class="container-fluid">
<?php
$htaccess = $_SERVER['DOCUMENT_ROOT'] . "/.htaccess";
if (!file_exists($htaccess)) {
echo '<div class="callout callout-info">
<strong>.htaccess</strong> file was not found on your website and will now be created in the website's root folder - <strong>' . $htaccess . '</strong> .
</div>';
$content = "";
@chmod($htaccess, 0777);
$fp = fopen($htaccess, "w+");
fwrite($fp, $content);
fclose($fp);
}
?>
<div class="row">
<div class="col-md-9">
<div class="card card-primary card-outline">
<div class="card-header">
<h3 class="card-title"><i class="far fa-file-code"></i> .htaccess Editor</h3>
</div>
<div class="card-body">
<form method="post">
<div class="row">
<div class="col-md-8">
<textarea class="form-control" name="htaccess" rows="20" type="text"><?php
$htaccess = $_SERVER['DOCUMENT_ROOT'] . "/.htaccess";
@chmod($htaccess, 0777);
echo file_get_contents($htaccess);
?></textarea>
</div>
<div class="col-md-4">
<p>Please double check them before saving as a mistake could make your website inaccessible.</p>
<ul class="description">
<li><a href="https://www.google.com/search?q=htaccess+tutorial" data-toggle="tooltip" title="Search for htaccess tutorials" target="_blank">
<img width="16px" src="http://google.com/favicon.ico" alt="google favicon"> htaccess tutorial</a>
</li>
<li><a href="https://httpd.apache.org/docs/current/howto/htaccess.html" data-toggle="tooltip" title="Read about htaccess at apache.org" target="_blank">
<img width="16px" src="http://apache.org/favicon.ico" alt="apache favicon"> htaccess</a>
</li>
<li><a href="https://httpd.apache.org/docs/current/mod/mod_rewrite.html" data-toggle="tooltip" title="Read about mod_rewrite at apache.org" target="_blank">
<img width="16px" src="https://apache.org/favicon.ico" alt="apache favicon"> mod_rewrite</a>
</li>
</ul>
</div>
</div>
</div>
<div class="card-footer text-right">
<input class="btn btn-flat btn-primary" type="submit" name="ht-edit" value="Save all changes">
</div>
</form>
</div>
<div class="card card-primary card-outline">
<div class="card-header">
<h3 class="card-title"><i class="fas fa-receipt"></i> Common Usage</h3>
</div>
<div class="card-body">
<ul>
<li><strong>Authorization, authentication</strong></li>
A .htaccess file is often used to specify security restrictions for a directory, hence the filename "access". The .htaccess file is often accompanied by a .htpasswd file which stores valid usernames and their passwords.
<li><strong>Rewriting URLs</strong></li>
Servers often use .htaccess to rewrite long, overly comprehensive URLs to shorter and more memorable ones.
<li><strong>Blocking</strong></li>
Use allow/deny to block users by IP address or domain. Also, use to block bad bots, rippers and referrers. Often used to restrict access by Search Engine spiders
<li><strong>SSI</strong></li>
Enable server-side includes.
<li><strong>Directory listing</strong></li>
Control how the server will react when no specific web page is specified.
<li><strong>Customized error responses</strong></li>
Changing the page that is shown when a server-side error occurs, for example HTTP 404 Not Found or, to indicate to a search engine that a page has moved, HTTP 301 Moved Permanently.
<li><strong>MIME types</strong></li>
Instruct the server how to treat different varying file types.
<li><strong>Cache Control</strong></li>
.htaccess files allow a server to control caching by web browsers and proxies to reduce bandwidth usage, server load, and perceived lag.
</ul>
</div>
</div>
</div>
<div class="col-md-3">
<div class="card card-primary card-outline">
<div class="card-header">
<h3 class="card-title"><i class="fas fa-info-circle"></i> Information & Tips</h3>
</div>
<div class="card-body">
A .htaccess (hypertext access) file is a directory-level configuration file supported by several web servers, that allows for decentralized management of web server configuration. They are placed inside the web tree, and are able to override a subset of the server's global configuration for the directory that they are in, and all sub-directories.
</div>
</div>
</div>
</div>
</div>
</div>
<!--===================================================-->
<!--End page content-->
</div>
<!--===================================================-->
<!--END CONTENT CONTAINER-->
</div>
<?php
footer();
?>