Home > Backend Development > PHP Tutorial > Introduction to how to use include to encrypt paths in PHP

Introduction to how to use include to encrypt paths in PHP

WBOY
Release: 2016-07-25 09:05:46
Original
1072 people have browsed it
  1. include_once 'include/Base.php';
  2. $path = '';
  3. $url = isBase::decrypt(urlDecode($_SERVER['QUERY_STRING']));
  4. parse_str($ url); //Get the variable passed through url address GET
  5. if(!empty($_POST['path'])){ //Get the variable passed by POST
  6. $path = $_POST['path'];
  7. $path = isBase::decrypt(urlDecode($path));
  8. }
  9. //Resolve the real path
  10. if(empty($path)){
  11. //header("Location: login.php");
  12. exit ;
  13. }
  14. if(!preg_match("/(^http://)|([?|&|=])/",$path)){
  15. //Jump to the path of the actual executed file
  16. chdir(dirname ($path));
  17. include_once basename($path);
  18. exit;
  19. }
  20. ?>
Copy code

index.php is in the same directory as include.inc

  1. include include.inc;
  2. ?>
Copy the code

2. Modify the link in the program ()

  1. "index.php?".encrypt("path=/test/test.php&test=123&test2=4321")
Copy the code

3. Modify the POST form in the program Forms are submitted to index.php Add a hidden form in the middle

4. Modify the path of the front-end Html page baseref=/test

5. Friends, please write the encryption and decryption functions yourself.



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