Home > CMS Tutorial > PHPCMS > How to change the background login address in phpcms

How to change the background login address in phpcms

藏色散人
Release: 2020-01-08 10:47:18
Original
3032 people have browsed it

How to change the background login address in phpcms

How to change the background login address in phpcms?

Many people know that the default phpcmsv9 background management path is not safe for the website. However, we can use some simple techniques to modify the background management login path. After modification, others will We can no longer access our backend login address using the default path.

phpcmsv9 can also modify the background path by default, but his method must bind a second-level domain name, which is very inconvenient. The method we introduce today is very simple and can be completed in two steps:

The first step: Create a folder in the root directory of the website. You will use this folder to enter the backend login interface in the future, so the folder name should be a name that you can remember and will not be easily guessed by others. As a demonstration here, I will call it tianxing. Then, 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;); 
?>
Copy after login

Step 2: Create a new file MY_index.php in the phpcms/modules/admin/ folder with the content:

<?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(); 
} 
} 
?>
Copy after login

After the above two steps of setup, we are done. After the modification is completed, the backend login portal can only be accessed through the tianxing/ directory. If you directly use admin.php and index.php?m=admin to access it, it will jump directly to the homepage of the website, thus preventing access to the backend login portal. of direct access.

The above method is to set a session value in the login entry file, and before entering the background, go back and judge if there is this session value or the session value is correct, you will log in. .

PHP Chinese website, a large number of free PHPCMS tutorials, welcome to learn online!

The above is the detailed content of How to change the background login address in phpcms. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template