Development projects ThinkPHP6.0 learning installation page

  We do a project, if it is their own use or to a colleague with the words often do not need to install a page, but if the project is not likely to give some server operation, the program will be less people use it every time, we need a setup page to help them better to install the project. How much crap up, and we just start teaching it, my, if not tp6.0 can also be used on tp6.0, slight modifications based on the line, according to their needs.

       First, we start with import documents to start, first determine what the project has been installed, and we have to be judged by file locks. Determine whether there install.lock file, if there is proof already installed, otherwise it is not already installed, you need to jump to the installation page, the code is as follows:

// [Application of an entry file] 

namespace Think; 

// define directory separator 

DEFINE ( 'the DS', DIRECTORY_SEPARATOR); 

// define root 

DEFINE (... 'Root_path', __DIR__ the DS '..' the DS); 

// defined application directory 

dEFINE (. 'APP_PATH', root_path 'App' the DS.); 

// item determines whether to install 

iF (is_file (APP_PATH 'the install / install.lock')!.) 

{ 

    header ( "LOCATION: ./ the install .php "); 

    Exit; 

} 

the require __DIR__ '/../vendor/autoload.php';. 

// HTTP application executed in response 

$ = HTTP (the App new new ()) -> HTTP; 

$ = $ http- response> RUN (); 

$ Response-> Send (); 

$ http-> End ($ Response);

  

We need to create a new public folder install.php file. There create a folder in the app install folder and name our project database file into the install folder install.sql below.

 

We first define a few constants and variables will be used for later use.

// definition of the directory separator 

DEFINE ( 'the DS', DIRECTORY_SEPARATOR); 

// define root 

DEFINE (... 'Root_path', __DIR__ the DS '..' the DS); 

// custom application directory 

define ( 'APP_PATH', ROOT_PATH .. 'App' DS); 

// installer directory 

the DEFINE ( 'INSTALL_PATH', APP_PATH 'install' DS);.. 

// project name 

$ SiteName = "TP6"; 

// link 

$ link = Array ( 

     'qqun' => "", 

     'Home' => '', 

     'DOC' => '', 

); 

// detect directory exists, this can be modified according to their needs 

$ checkDirs = [ 

    'Vendor' 

]; 

// cache directory 

. $ runtimeDir = APP_PATH 'runtime' ;

// error message 

$ errinfo = ''; 

// database configuration file 

$ dbConfigFile = ROOT_PATH. 'Config database.php ' 'DS..';

// backstage entrance file 

$ adminfile = root_path 'public' DS 'admin.php';... 

// locked files 

$ lockFile = INSTALL_PATH 'install.lock'. ;

After a good definition, let's write a function to determine read and write permissions for specific files or folders, if not read and write permissions, we are unable to operate, Windows systems generally do not worry about it, if it is, then we need to Linux modify the permissions to 777.

// determine whether a file or directory has write permissions

function is_really_writable($file)

{

    if (DIRECTORY_SEPARATOR == '/' AND @ ini_get("safe_mode") == false) {

        return is_writable($file);

    }

    if (!is_file($file) OR ($fp = @fopen($file, "r+")) === false) {

        return false;

    }

    fclose($fp);

    return true;

}

Next we will carry out a series of judgments, this is mainly to be able to properly install the program, you first need to determine whether the project is already installed, then is to determine the environment, such as PHP version is greater than or equal to 7.1.0, whether to open the PDO , database configuration file is read-write, and so on. Come directly on the code:

// current POST request 

IF (isset ($ _ SERVER [ 'REQUEST_METHOD']) && $ _SERVER [ 'REQUEST_METHOD'] == 'POST') { 

    IF ($ errinfo) {// an error message 

        echo $ errinfo; 

        Exit; 

    } 

    ERR = $ ''; 

    $ mysqlHostname = isset ($ _ POST [ 'mysqlHost']) $ _POST? [ 'mysqlHost']: '127.0.0.1'; // address database 

    $ mysqlHostport = isset ($ _ POST [ 'mysqlHostport'] ?) $ _POST [ 'mysqlHostport' ]: 3306; // port number 

    $ hostArr = explode ( ':' , $ mysqlHostname); // if the address of the database fill port numbers, separate them 

    if (count ($ hostArr) >. 1) { 

        $ $ hostArr mysqlHostname = [0]; 

        $ mysqlHostport hostArr = $ [. 1]; 

    } 

    $ MySQLUserName = isset ($ _ the POST [ 'MySQLUserName'?]) $ _POST [ 'mysqlUsername']: 'root'; // username

    $ mysqlPassword = isset ($ _ POST [ 'mysqlPassword']) $ _POST [ 'mysqlPassword']:? ''; // password 

    $ mysqlDatabase = isset ($ _ POST [ 'mysqlDatabase']?) $ _POST [ 'mysqlDatabase']: 'tp6'; // database name 

    $ mysqlPrefix = isset ($ _ POST [ 'mysqlPrefix']) $ _POST [ 'mysqlPrefix']: 'tp _'; // prefix? 

    $ AdminUserName = isset ($ _ POST [ 'AdminUserName']) ? $ _POST [ 'adminUsername'] : 'admin'; // backstage manager username 

    $ adminPassword = isset ($ _ POST [ 'adminPassword']) $ _POST [ 'adminPassword']:? '123456'; // Admin codon 

    $ adminPasswordConfirmation = isset ($ _ POST [ 'adminPasswordConfirmation']) $ _POST [ 'adminPasswordConfirmation']:? '123456'; // repeat password 

    $ adminEmail = isset ($ _ POST [ 'adminEmail']) ? $_POST['adminEmail'] : '[email protected]';//邮箱

    if (!preg_match("/^\w{3,12}$/", $adminUsername)) {

        echo "user name only by 3-12 digits, letters, underline combination"; 

        Exit; 

    } 

    IF (! the preg_match ( "/ ^ [\ S] {6,16} $ /", $ adminPassword)) { 

        echo " the password must be between 6-16, no spaces "; 

        Exit; 

    } 

    IF ($ $ adminPasswordConfirmation adminPassword ==!) { 

        echo" code mismatch "two input; 

        Exit; 

    } 

    the try { 

        // detect whether read the installation files 

        $ SQL = @file_get_contents (INSTALL_PATH 'install.sql'.); 

        iF (! $ SQL) { 

            the throw new new Exception ( "unable to read app / install / install.sql file, check whether there is read access" ); 

        } 

        $ SQL = str_replace ( "` fa_ "," $ `mysqlPrefix {}", $ SQL);

        the PDO PDO new new = $ ( "MySQL: Host} = {$ mysqlHostname; mysqlHostport Port = {} $", MySQLUserName $, $ Mysqlpassword, Array ( 

            the PDO ATTR_ERRMODE = ::> :: ERRMODE_EXCEPTION the PDO, 

            the PDO :: MYSQL_ATTR_INIT_COMMAND => " NAMES utf8 the SET " 

        )); 

        // detect whether to support innodb storage engine 

        $ PDOStatement PDO-$ => Query (" the LIKE SHOW VARIABLES 'innodb_version' "); 

        $ $ pdoStatement- the Result => FETCH (); 

        iF ($ the Result! ) { 

            the throw new new Exception ( "The current database does not support innodb storage engine, and then turn on again try to install"); 

        } 

        $ PDO-> Query ( "the CREATE dATABASE IF the nOT EXISTS` `CHARACTER} {$ mysqlDatabase the SET utf8 COLLATE utf8_general_ci; "); 

        $ PDO-> Query ("USE `{$mysqlDatabase}`");

        $pdo->exec($sql);

        $config = @file_get_contents($dbConfigFile);

        $callback = function ($matches) use ($mysqlHostname, $mysqlHostport, $mysqlUsername, $mysqlPassword, $mysqlDatabase, $mysqlPrefix) {

            $field = ucfirst($matches[1]);//首字符大写

            $replace = ${"mysql{$field}"};//$mysqlHostname,$mysqlHostport,$mysqlUsername,$mysqlPassword,$mysqlDatabase,$mysqlPrefix

            if ($matches[1] == 'hostport' && $mysqlHostport == 3306) {

                $replace = '';

            }

            return "'{$matches[1]}'{$matches[2]}=>{$matches[3]}env('database.{$matches[1]}', '{$replace}'),";

        };

        $ config = preg_replace_callback ( "/ ' (hostname | database | username | password | hostport | prefix)'. (\ s +) => (\ s +) env \ ((*) \) \, /", $ callback, $ config); 

        // detect whether a successful write database configuration 

        $ @file_put_contents the Result = ($ dbConfigFile, $ config); 

        ! IF ($ the Result) { 

            the throw new new Exception ( "unable to write database information to the config / database.php file check if you have write access "); 

        } 

        // check whether a successful write lock file 

        $ @file_put_contents the Result = ($ LockFile, 1); 

        ! iF ($ the Result) { 

            the throw new new Exception (" can not write lock installation to app / install / install.lock file, check if you have write access "); 

        } 

        $ newSalt = substr (MD5 (uniqid (to true)), 0, 6); 

        . $ newPassword = MD5 (MD5 ($ adminPassword) $ newSalt);

        $pdo->query("UPDATE {$mysqlPrefix}admin SET username = '{$adminUsername}', email = '{$adminEmail}',password = '{$newPassword}', salt = '{$newSalt}' WHERE username = 'admin'");

        $adminName = '';

        if (is_file($adminFile)) {//修改后台入口文件名

            $x = '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ';

            $adminName = substr(str_shuffle(str_repeat($x, ceil(10 / strlen($x)))), 1, 10) . '.php';

            rename($adminFile, ROOT_PATH . 'public' . DS . $adminName);

        }

        echo "success|{$adminName}";

    } catch (PDOException $e) {

        $err = $e->getMessage();

    } catch (Exception $e) {

        $err = $e->getMessage();

    }

    echo $err;

    exit;

}

Here is the complete code:

? <PHP 
/ ** 
 * After installation is complete proposed to delete this file 
 * / 
// error_reporting (E_ERROR | E_WARNING | E_PARSE | E_NOTICE); 
// ini_set ( 'display_errors', '1'); 
// define the directory separator 
define ( 'the DS', DIRECTORY_SEPARATOR); 

// define root 
dEFINE ( 'root_path', __DIR__ the DS '..' the DS);... 

// definition of the application catalog 
.. define ( 'APP_PATH', rOOT_PATH 'app' DS); 

// installation package directory 
define ( 'INSTALL_PATH', APP_PATH ' install' DS..); 

whether // determine the file or directory has write permissions 
function is_really_writable ($ file) 
{ 
    iF (DIRECTORY_SEPARATOR == '/' @ ini_get the AND ( "safe_mode") == to false) { 
        return is_writable ($ File); 
    } 
    IF (!is_file($file) OR ($fp = @fopen($file, "r+")) === false) {
        to false return; 
    }
    fclose($fp);
    return to true; 
} 

$ SiteName = "TP6"; 

$ Link = Array ( 
    'qqun' => "", 
    'Home' => '', 
    'DOC' => '', 
); 

// directory is detected there is 
$ checkDirs = [ 
    'Vendor' 
    // 'public' DS 'Assets' DS 'libs'.... 
]; 
// cache directory 
$ runtimeDir = APP_PATH 'Runtime';. 

// error message 
$ errInfo = ''; 

// database configuration file 
$ = root_path dbConfigFile 'config' the DS 'database.php';... 

@ AdminPort file 
$ adminFile = rOOT_PATH 'public' DS 'admin.php'...;

// file locking 
. LockFile = $ INSTALL_PATH 'install.lock'; 

IF (is_file ($ LockFile)) {Lock '; 
    $ errinfo = "currently installed {$ sitename}, if the need to reinstall, manually remove the app / install / install.lock document"; 
} the else {
    IF (version_compare (PHP_VERSION, '7.1.0', '<')) { 
        $ errinfo = "current version" is too low, use PHP7.1.0 above ( "PHP_VERSION..)"; 
    } the else { 
        IF (extension_loaded! ( "the PDO")) { 
            $ errinfo = "not currently open PDO, can not be installed"; 
        } the else { 
            IF) {(is_really_writable ($ dbConfigFile!) 
                $ open_basedir = the ini_get ( 'open_basedir'); 
                IF ($ open_basedir) { 
                    dirArr the explode = $ (PATH_SEPARATOR, $ open_basedir); 
                    IF ($ dirArr && the in_array (__ DIR__, $ dirArr)) { 
                IF (!errinfo $) { 
                    $ errinfo = 'current insufficient permissions to write to the configuration file config / database.php <br>'; 
                        $ = errinfo 'Because the current server configuration open_basedir, rendering it unreadable parent directory <br> ';
                    } 
                } 
                } 
            } The else { 
                $ dirArr = []; 
                the foreach ($ checkDirs AS $ K => $ V) { 
                    (!. Is_dir (root_path $ V)) IF { 
                        $ errinfo = 'current code contains only the core code, go official website to download the full package or a resource package cover, and try again, '; 
                        BREAK; 
                    } 
                } 
            } 
        } 
    } 
} 

// this is a POST request 
if (isset ($ _ SERVER [ ' REQUEST_METHOD ']) && $ _SERVER [' REQUEST_METHOD '] = = 'the POST') { 
    IF ($ errinfo) {// an error message 
        echo $ errinfo; 
        Exit;
    }
    $err = '';
    ? $ mysqlHostname = isset ($ _ POST [ 'mysqlHost']) $ _POST [ 'mysqlHost']: '127.0.0.1'; // address database 
    $ mysqlHostport = isset ($ _ POST [ 'mysqlHostport']) $ _POST [ '? mysqlHostport ']: 3306; // port number 
    $ hostArr = explode (': ' , $ mysqlHostname); // fill in the address database if the port number, separate them 
    IF (COUNT ($ hostArr)>. 1) { 
        $ mysqlHostname = $ hostArr [0]; 
        $ mysqlHostport = $ hostArr [. 1]; 
    } 
    $ MySQLUserName = isset ($ _ the POST [ 'MySQLUserName']) $ _POST [ 'MySQLUserName']:? 'the root'; // user name 
    $ mysqlPassword = ? isset ($ _ POST [ ' mysqlPassword']) $ _POST [ 'mysqlPassword']: ''; // password 
    $ mysqlDatabase = isset ($ _ POST [ 'mysqlDatabase']?) $ _POST [ 'mysqlDatabase']: 'tp6' ;//Database name
    $ mysqlPrefix = isset ($ _ POST [ 'mysqlPrefix']) $ _POST [ 'mysqlPrefix']: 'tp _'; // prefix? 
    $ AdminUserName = isset ($ _ POST [ 'AdminUserName']) $ _POST [ 'AdminUserName']? : 'admin'; // backstage manager username 
    $ adminPassword = isset ($ _ POST [ 'adminPassword']) $ _POST [ 'adminPassword']:? '123456'; // backstage supervisor password 
    $ adminPasswordConfirmation = isset ($ _POST [ 'adminPasswordConfirmation']) $ _POST [ 'adminPasswordConfirmation']:? '123456'; // repeat password 
    ? $ adminEmail = isset ($ _ POST [ 'adminEmail']) $ _POST [ 'adminEmail']: 'admin @ admin .com '; // mail 

    IF (! the preg_match ( "/ ^ \ {3,12} $ W /", $ AdminUserName)) { 
        echo "user name only by 3-12 digits, letters, underline combination"; 
        exit;
    }
    if (!preg_match("/^[\S]{6,16}$/", $adminPassword)) {
        echo "password must be between 6-16, no spaces";  
        Exit; 
    }
    IF (! $ adminPassword adminPasswordConfirmation == $) { 
        echo "password input not match twice"; 
        Exit; 
    } 

    the try { 
        // read detecting whether take the installation files 
        $ SQL = @file_get_contents (INSTALL_PATH 'install.sql'.); 
        iF (! $ SQL) { 
            the throw new new Exception ( "unable to read app / install / install.sql file, check whether there is read access") ; 
        } 
        $ SQL = str_replace ( "` fa_ "," `{$ mysqlPrefix}", $ SQL); 
        $ PDO = new new the PDO ( "MySQL: Host = {$ mysqlHostname}; Port = {$ mysqlHostport}", $ MySQLUserName , $ Mysqlpassword, Array ( 
            PDO :: ATTR_ERRMODE => PDO :: ERRMODE_EXCEPTION, 
            PDO ::MYSQL_ATTR_INIT_COMMAND => "SET NAMES utf8" 
        ) ); 

        // Check whether to support innodb storage engine
        PDO-PDOStatement = $ $> Query ( "SHOW the VARIABLES the LIKE 'innodb_version'"); 
        $ Result = $ pdoStatement-> FETCH (); 
        IF (! $ Result) { 
            the throw new new Exception ( "do not support the current database innodb storage engine, Please try again later to install open "); 
        } 

        $ PDO-> Query (" the NOT EXISTS the CREATE DATABASE the IF} `` {$ mysqlDatabase the CHARACTER the SET UTF8 the COLLATE utf8_general_ci; "); 

        $ PDO-> Query (" {$ `the USE mysqlDatabase `}"); 

        $ PDO-> Exec ($ SQL); 

        $ config = @file_get_contents ($ dbConfigFile); 
        $ = the callback function ($ The matches) use ($ mysqlHostname, mysqlHostport $, $ MySQLUserName, Mysqlpassword $, $ mysqlDatabase, mysqlPrefix $) { 
            $ = Field ucfirst (The matches $ [. 1]); // first character capitalized
            $replace = ${"mysql{$field}"};//$mysqlHostname,$mysqlHostport,$mysqlUsername,$mysqlPassword,$mysqlDatabase,$mysqlPrefix
            if ($matches[1] == 'hostport' && $mysqlHostport == 3306) {
                $replace = '';
            }
            return "'{$matches[1]}'{$matches[2]}=>{$matches[3]}env('database.{$matches[1]}', '{$replace}'),";
        };
        $config = preg_replace_callback("/'(hostname|database|username|password|hostport|prefix)'(\s+)=>(\s+)env\((.*)\)\,/", $callback, $config);

        //检测能否成功写入数据库配置
        $result = @file_put_contents($dbConfigFile, $config);
        if (!the Result $) { 
            the throw new new Exception ( "Unable to write database information to the config / database.php file, check if you have write access");
        } 

        // write lock detection success file 
        $ = Result @file_put_contents ($ LockFile,. 1); 
        IF (! $ Result) { 
            the throw new new Exception ( "Can not write lock is mounted to app / install / install.lock document, check that you have write access "); 
        } 

        $ newSalt = substr (MD5 (uniqid (to true)), 0, 6); 
        $ newPassword = MD5 (MD5 ($ adminPassword) $ newSalt);. 
        $ PDO-> Query (" UPDATE {$ mysqlPrefix} admin SET username = '{$ adminUsername}', email = '{$ adminEmail}', password = '{$ newPassword}', salt = '{$ newSalt}' WHERE username = 'admin' ") ; 

        $ adminName = ''; 
        IF (is_file ($ adminfile)) {// modified background file name entry  
            $ x = '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ';
            $ adminName = substr (str_shuffle (str_repeat ($ x, ceil (10 / strlen ($ x)))), 1,10) . '.php';
            rename($adminFile, ROOT_PATH . 'public' . DS . $adminName);
        }
        echo "success|{$adminName}";
    } catch (PDOException $e) {
        $err = $e->getMessage();
    } catch (Exception $e) {
        $err = $e->getMessage();
    }
    echo $err;
    exit;
}
?>
<!doctype html>
<html>
<head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <title>安装<?php echo $sitename; ?></title>
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, minimum-scale=1">
    <meta name="renderer" content="webkit">

    <style>
        body {
            background: #fff;
            margin: 0;
            padding: 0;
            line-height: 1.5;
            -webkit-font-smoothing: antialiased;
            -moz-osx-font-smoothing: grayscale;
        }

        body, input, button {
            font-family: 'Source Sans Pro', 'Helvetica Neue', Helvetica, 'Microsoft Yahei', Arial, sans-serif;
            font-size: 14px;
            color: #7E96B3;
        }

        .container {
            max-width: 480px;
            margin: 0 auto;
            padding: 20px;
            text-align: center;
        }

        a {
            color: #18bc9c;
            text-decoration: none;
        }

        a:hover {
            text-decoration: underline;
        }

        h1 {
            margin-top: 0;
            margin-bottom: 10px;
        }

        h2 {
            font-size: 28px;
            font-weight: normal;
            color: #3C5675;
            margin-bottom: 0;
            margin-top: 0;
        }

        form {
            margin-top: 40px;
        }

        .form-group {
            margin-bottom: 20px;
        }

        .form-group .form-field:first-child input {
            border-top-left-radius: 4px;
            border-top-right-radius: 4px;
        }

        .form-group .form-field:last-child input {
            border-bottom-left-radius: 4px;
            border-bottom-right-radius: 4px;
        }

        .form-field input {
            background: #EDF2F7;
            margin: 0 0 1px;
            border: 2px solid transparent;
            transition: background 0.2s, border-color 0.2s, color 0.2s;
            width: 100%;
            padding: 15px 15px 15px 180px;
            box-sizing: border-box;
        }

        .form-field input:focus {
            border-color: #18bc9c;
            background: #fff;
            color: #444;
            outline: none;
        }

        .form-field label {
            float: left;
            width: 160px;
            text-align: right;
            margin-right: -160px;
            position: relative;
            margin-top: 18px;
            font-size: 14px;
            pointer-events: none;
            opacity: 0.7;
        }

        button, .btn {
            background: #3C5675;
            color: #fff;
            border: 0;
            font-weight: bold;
            border-radius: 4px;
            cursor: pointer;
            padding: 15px 30px;
            -webkit-appearance: none;
        }

        button[disabled] {
            opacity: 0.5;
        }

        .form-buttons {
            height: 52px;
            line-height: 52px;
        }

        .form-buttons .btn {
            margin-right: 5px;
        }

        #error, .error, #success, .success, #warmtips, .warmtips {
            background: #D83E3E;
            color: #fff;
            padding: 15px 20px;
            border-radius: 4px;
            margin-bottom: 20px;
        }

        #success {
            background: #3C5675;
        }

        #error a, .error a {
            color: white;
            text-decoration: underline;
        }

        #warmtips {
            background: #ffcdcd;
            font-size: 14px;
            color: #e74c3c;
        }

        #warmtips a {
            background: #ffffff7a;
            display: block;
            height: 30px;
            line-height: 30px;
            margin-top: 10px;
            color: #e21a1a;
            border-radius: 3px;
        }
    </style>
</head>

<body>
<div class="container">
    <h1>
        <svg width="80px" height="96px" viewBox="0 0 768 830" version="1.1" xmlns="http://www.w3.org/2000/svg"
             xmlns:xlink="http://www.w3.org/1999/xlink">
            <g id="logo" stroke="none" stroke-width="1" fill="none" fill-rule="evenodd">
                <path d="M64.433651,605.899968 C20.067302,536.265612 0,469.698785 0,389.731348 C0,174.488668 171.922656,0 384,0 C596.077344,0 768,174.488668 768,389.731348 C768,469.698785 747.932698,536.265612 703.566349,605.899968 C614.4,753.480595 441.6,870.4 384,870.4 C326.4,870.4 153.6,753.480595 64.433651,605.899968 L64.433651,605.899968 Z"
                      id="body" fill="#18BC9C"></path>
                <path d="M429.648991,190.816 L430.160991,190.816 L429.648991,190.816 L429.648991,190.816 Z M429.648991,156 L427.088991,156 C419.408991,157.024 411.728991,160.608 404.560991,168.8 L403.024991,170.848 L206.928991,429.92 C198.736991,441.184 197.712991,453.984 204.368991,466.784 C210.512991,478.048 222.288991,485.728 235.600991,485.728 L336.464991,486.24 L304.208991,673.632 C301.648991,689.504 310.352991,705.376 325.200991,712.032 C329.808991,714.08 334.416991,714.592 339.536991,714.592 C349.776991,714.592 358.992991,709.472 366.160991,700.256 L561.744991,419.168 C569.936991,407.904 570.960991,395.104 564.304991,382.304 C557.648991,369.504 547.408991,363.36 533.072991,363.36 L432.208991,363.36 L463.952991,199.008 C464.464991,196.448 464.976991,193.376 464.976991,190.816 C464.976991,171.872 449.104991,156 431.184991,156 L429.648991,156 L429.648991,156 Z"
                      the above mentioned id = "Flash" the Fill = "# FFFFFF"> </ path> 
            </ G> 
        </ SVG> 
    </ h1> 
    <h2> install <PHP echo $ SiteName;??> </ h2> 
    <div> 

        <the p- > If you encounter problems during installation, you can visit <a href="<?php echo $link['doc']; ?> "target = " _ blank "> installation documentation </a> <A 
                    href =" <? php echo $ link [ 'forum' ];?> "target =" _ blank "> <a 
                    href="<?php community based echo $link['qqun']; ?> </a> "> QQ exchange group < / a> </ the p-> 
        <- <the p-!> <PHP echo $ SiteName;??> also supports command line php think install a key installation </ the p-> -> 

        <form = Method, "post">
            <?php if ($errInfo): ?>
                <div class="error">
                    <?php echo $errInfo; ?>
                </div>
            <?php endif; ?>
            <div id="error" style="display:none"></div>
            <div id="success" style="display:none"></div>
            <div id="warmtips" style="display:none"></div>

            <div class="form-group">
                <div class="form-field">
                    <label>MySQL 数据库地址</label>
                    <input type="text" name="mysqlHost" value="127.0.0.1" required="">
                </div>

                <div class="form-field">
                    <label>MySQL 数据库名</label>
                    <input type="text" name="mysqlDatabase" value="tp6" required="">
                </div>

                <div class="form-field">
                    <label>MySQL 用户名</label>
                    <input type="text" name="mysqlUsername" value="root" required="">
                </div>

                <div class="form-field">
                    <label>MySQL 密码</label>
                    <input type="password" name="mysqlPassword">
                </div>

                <div class="form-field">
                    <label>MySQL 数据表前缀</label>
                    <input type="text" name="mysqlPrefix" value="fa_">
                </div>

                <div class="form-field">
                    <label>MySQL 端口号</label>
                    <input type="number" name="mysqlHostport" value="3306">
                </div>
            </div>

            <div class="form-group">
                <div class="form-field">
                    <label>管理者用户名</label>
                    <input name="adminUsername" value="admin" required=""/>
                </div>

                <div class="form-field">
                    <label>管理者Email</label>
                    <input name="adminEmail" value="[email protected]" required="">
                </div>

                <div class="form-field">
                    <label>管理者密码</label>
                    <input type="password" name="adminPassword" required="">
                    <label> Repeat password </ label>
                </ div>

                <div class="form-field">
                    <input type="password" name="adminPasswordConfirmation" required="">
                </div>
            </div>

            <div class="form-buttons">
                <button type="submit" <?php echo $errInfo ? 'disabled' : '' ?>>点击安装</button>
            </div>
        </form>

        <!-- jQuery -->
        <script src="https://cdn.staticfile.org/jquery/2.1.4/jquery.min.js"></script>

        <script>
            $(function () {
                $('form :input:first').select();

                $('form').on('submit', function (e) {
                    e.preventDefault();
                    the this form = var; 
                    var $button = $(this).find('button')
                        .text ( 'installation ...') 
                        .prop ( 'Disabled', to true); 

                    $ .post ( '', $ (the this) .serialize ()) 
                        .done (function (RET) { 
                            IF (ret.substr (0,. 7) === 'Success') { 
                                var retArr ret.split = (/ \ | /); 
                                $ ( '# error') hide ();. 
                                $ ( "Group-form. ", form) .remove (); 
                                $ button.remove (); 
                                $ (" # success. ") text (" start your successful installation! <php echo $ sitename;? ?> journey ") show!. ();

                                $buttons = $(".form-buttons", form); 
                                $ ( '<a class = "btn" href = "./ "> Visit Home </a> ') .appendTo ($ buttons);

                                IF (! typeof retArr [. 1] == 'undefined' && retArr [. 1] == ''!) { 
                                    var URL = location.href.replace (/install\.php/, retArr [. 1]); 
                                    $ ( " #warmtips ".) html ( 'tips: Please log entry the following background Add to your favorites, for your safety, do not leak or send them to others if it leaks please modify <a href =!!"' + + URL ' ">' + + URL '</a>') the .Show (); 
                                    $ ( '<= class A" BTN "the href ="' + + URL ' "ID =" BTN-ADMIN "style =" background: # 18bc9c "> background access </a> ') .appendTo ($ Buttons); 
                                } 
                                localStorage.setItem (" fastep "," Installed "); 
                                $ button.prop ( 'Disabled', false) .text ( 'click to install');
                            } else {
                                $ ( '# error') Show () text (RET);.. 
                                $ ( "HTML, body") Animate ({. 
                                    scrollTop: 0 
                                }, 500); 
                            } 
                        }) 
                        .fail (function (Data) { 
                            $ ( '#error') show () text ( ' error: \ the n-\ the n-' + data.responseText);.. 
                            $ button.prop ( 'Disabled', false) .text ( 'click to install'); 
                            $ ( " HTML, body ") Animate ({. 
                                scrollTop: 0 
                            }, 500); 
                        });

                    return false; 
                }); 
            }); 
        </ Script>
    </div>
</div>
</body>
</html>

  

Guess you like

Origin www.cnblogs.com/shengChristine/p/12034353.html