Home  >  Article  >  CMS Tutorial  >  How to modify the phpcms management background path

How to modify the phpcms management background path

王林
王林Original
2020-02-06 17:06:072512browse

How to modify the phpcms management background path

The first step:

Create a folder in the root directory of the website. You will enter the background login interface through this folder in the future, so the folder name must be Choose a name that won’t be easily guessed. As a demonstration here, I will call it admpub. Next, create a new file index.php in this folder with the content:

<?php 
define(&#39;PHPCMS_PATH&#39;, realpath(dirname(__FILE__) . &#39;/..&#39;) . &#39;/&#39;);
include PHPCMS_PATH . &#39;/phpcms/base.php&#39;; // pc_base::creat_app();
$session_storage = &#39;session_&#39; . pc_base :: load_config(&#39;system&#39;, &#39;session_storage&#39;);
pc_base :: load_sys_class($session_storage);
session_start();
$_SESSION[&#39;right_enter&#39;] = 1;
unset($session_storage);
header(&#39;location:../index.php?m=admin&#39;);

Step 2:

Create a new file MY_index.php in the phpcms/modules/admin/ folder , the content is:

<?php 
defined(&#39;IN_PHPCMS&#39;) or exit(&#39;No permission resources.&#39;);
class MY_index extends index {
public function __construct() {
if (empty($_SESSION[&#39;right_enter&#39;])) {
header(&#39;location:./&#39;);
exit;
}
parent :: __construct();
}
public function public_logout() {
$_SESSION[&#39;right_enter&#39;] = 0;
parent :: public_logout();
}
}

Okay, the modification is completed. In the future, you can only access the backend login portal through the admpub/ directory. If you directly use index.php?m=admin to access it, it will jump directly to the homepage of the website, thus preventing direct access to the backend login portal.

Recommended related articles and tutorials: phpcms tutorial

The above is the detailed content of How to modify the phpcms management background path. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn