The principles and procedures of the PHP authoring installer are explained in detail _php tutorials

Source: Internet
Author: User
This article explains the principle and steps of PHP production and installation program
1, the principle of making PHP installation program
The installation principle of the PHP program is to import the database structure and content into the corresponding database, from the process to reconfigure the parameters and files of the database, in order to ensure that no one else malicious use of the installation files, when the installation is completed need to modify the installation files.
2. Steps to make PHP installation program
Step1 checking the permissions of a directory or file
Step2 Modify or add a configuration file
Step3 checking configuration file correctness
STEP4 Importing databases
STEP5 locking or deleting installation files
3, make the installation of PHP functions
Check if the file is writable and return a Boolean value: Is_writable ("data/config.php");
Checks if the file is readable and returns a Boolean value: Is_readable ("data/config.php");
fopen () file operation function, open a file or create a new
Fwrite () file operation function, write content to file
Rename () file operation function, renaming files
4. Precautions
(1). check files and associated folder permissions, such as cache, makefile, config file
(2). installation files are as independent as possible, can be deleted, can be renamed.
(3). When the database is imported, you need to check:
A. Checking for permissions to establish a database
B. Whether the database exists with the same name
C. Consider whether the size of the database import is fragmented
(4). Check the configuration environment, the support of various modules, such as: GD2, Pdo,rewirte, etc.
5. Instance Code
  1. $files = "data/config.php";
  2. if (!is_writable ($files)) {
  3. echo "Not writable!!! ";
  4. }else{
  5. echo "writable";
  6. }
  7. if (Isset ($_post[install])) {
  8. $config _str = "
  9. $config _str. = "";
  10. $config _str. = $mysql _host = ". $_post[db_host]. ";;
  11. $config _str. = "";
  12. $config _str. = $mysql _user = ". $_post[db_user]. ";;
  13. $config _str. = "";
  14. $config _str. = $mysql _pass = ". $_post[db_pass]. ";;
  15. $config _str. = "";
  16. $config _str. = $mysql _dbname = ". $_post[db_dbname]. ";;
  17. $config _str. = "";
  18. $config _str. = $mysql _tag = ". $_post[db_tag]. ";;
  19. $config _str. = "";
  20. $config _str. =?>;
  21. $FF = fopen ($files, "w");
  22. Fwrite ($FF, $config _str);
  23. //=====================
  24. Include_once ("data/config.php"); Embedding the configuration file
  25. if (!@ $link = mysql_connect ($mysql _host, $mysql _user, $mysql _pass)) {//Check database connection condition
  26. echo "Database connection failed! Please go back to the previous page to check the connection parameters back to modify ";
  27. } else {
  28. mysql_query ("CREATE DATABASE ' $mysql _dbname '");
  29. mysql_select_db ($mysql _dbname);
  30. $sql _query[] = "CREATE TABLE". $mysql _tag. "Admin_log1" (
  31. ' ID ' int (8) unsigned not NULL auto_increment,
  32. ' username ' varchar (+) not NULL COMMENT operation user name,
  33. ' Types ' varchar is not NULL,
  34. PRIMARY KEY (' id ')
  35. ) ;";
  36. $sql _query[] = "CREATE TABLE". $mysql _tag. "Admin_log2" (
  37. ' ID ' int (8) unsigned not NULL auto_increment,
  38. ' username ' varchar (+) not NULL COMMENT operation user name,
  39. ' Types ' varchar is not NULL,
  40. PRIMARY KEY (' id ')
  41. ) ;";
  42. $sql _query[] = "CREATE TABLE". $mysql _tag. "Admin_log3" (
  43. ' ID ' int (8) unsigned not NULL auto_increment,
  44. ' username ' varchar (+) not NULL COMMENT operation user name,
  45. ' Types ' varchar is not NULL,
  46. PRIMARY KEY (' id ')
  47. ) ;";
  48. foreach ($sql _query as $val) {
  49. mysql_query ($val);
  50. }
  51. echo "";
  52. Rename ("install.php", "Install.lock");
  53. }
  54. }
  55. ?>

I hope this article will get you something.

http://www.bkjia.com/PHPjc/486158.html www.bkjia.com true http://www.bkjia.com/PHPjc/486158.html techarticle This article explains the PHP production installation program principle and step 1, the principle of making PHP installation program PHP program installation principle is to import the database structure and content into the corresponding database, from ...

  • Contact Us

    The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

    If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.