1 | <?php
|
---|
2 | /**
|
---|
3 | * Retrieves and creates the wp-config.php file.
|
---|
4 | *
|
---|
5 | * The permissions for the base directory must allow for writing files in order
|
---|
6 | * for the wp-config.php to be created using this page.
|
---|
7 | *
|
---|
8 | * @package WordPress
|
---|
9 | * @subpackage Administration
|
---|
10 | */
|
---|
11 |
|
---|
12 | /**
|
---|
13 | * We are installing.
|
---|
14 | *
|
---|
15 | * @package WordPress
|
---|
16 | */
|
---|
17 | define('WP_INSTALLING', true);
|
---|
18 |
|
---|
19 | /**#@+
|
---|
20 | * These three defines are required to allow us to use require_wp_db() to load
|
---|
21 | * the database class while being wp-content/db.php aware.
|
---|
22 | * @ignore
|
---|
23 | */
|
---|
24 | define('ABSPATH', dirname(dirname(__FILE__)).'/');
|
---|
25 | define('WPINC', 'wp-includes');
|
---|
26 | define('WP_CONTENT_DIR', ABSPATH . 'wp-content');
|
---|
27 | /**#@-*/
|
---|
28 |
|
---|
29 | require_once(ABSPATH . WPINC . '/compat.php');
|
---|
30 | require_once(ABSPATH . WPINC . '/functions.php');
|
---|
31 | require_once(ABSPATH . WPINC . '/classes.php');
|
---|
32 |
|
---|
33 | if (!file_exists(ABSPATH . 'wp-config-sample.php'))
|
---|
34 | wp_die('Spiacente, mi serve un file wp-config-sample.php su cui lavorare. Per favore ricaricare questo file dalla installazione di WordPress.');
|
---|
35 |
|
---|
36 | $configFile = file(ABSPATH . 'wp-config-sample.php');
|
---|
37 |
|
---|
38 | if ( !is_writable(ABSPATH))
|
---|
39 | wp_die("Spiacente, non posso scrivere la directory. Occorre cambiare i permessi sulla directory di WordPress o creare il file wp-config.php manualmente.");
|
---|
40 |
|
---|
41 | // Check if wp-config.php has been created
|
---|
42 | if (file_exists(ABSPATH . 'wp-config.php'))
|
---|
43 | wp_die("<p>The file 'wp-config.php' already exists. If you need to reset any of the configuration items in this file, please delete it first. You may try <a href='install.php'>installing now</a>.</p>");
|
---|
44 |
|
---|
45 | // Check if wp-config.php exists above the root directory but is not part of another install
|
---|
46 | if (file_exists(ABSPATH . '../wp-config.php') && ! file_exists(ABSPATH . '../wp-settings.php'))
|
---|
47 | wp_die("<p>Il file 'wp-config.php' esiste già ad un livello superiore rispetto a quello dell'installazione di WordPress. Se si desidera azzerare uno qualsiasi degli elementi di configurazione di questo file, cancellarlo. È anche possibile <a href='install.php'>provare ad installare ora</a>.</p>");
|
---|
48 |
|
---|
49 | if (isset($_GET['step']))
|
---|
50 | $step = $_GET['step'];
|
---|
51 | else
|
---|
52 | $step = 0;
|
---|
53 |
|
---|
54 | /**
|
---|
55 | * Display setup wp-config.php file header.
|
---|
56 | *
|
---|
57 | * @ignore
|
---|
58 | * @since 2.3.0
|
---|
59 | * @package WordPress
|
---|
60 | * @subpackage Installer_WP_Config
|
---|
61 | */
|
---|
62 | function display_header() {
|
---|
63 | header( 'Content-Type: text/html; charset=utf-8' );
|
---|
64 | ?>
|
---|
65 | <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
|
---|
66 | <html xmlns="http://www.w3.org/1999/xhtml">
|
---|
67 | <head>
|
---|
68 | <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
|
---|
69 | <title>WordPress › Impostazione File di Configurazione</title>
|
---|
70 | <link rel="stylesheet" href="css/install.css" type="text/css" />
|
---|
71 |
|
---|
72 | </head>
|
---|
73 | <body>
|
---|
74 | <h1 id="logo"><img alt="WordPress" src="images/wordpress-logo.png" /></h1>
|
---|
75 | <?php
|
---|
76 | }//end function display_header();
|
---|
77 |
|
---|
78 | switch($step) {
|
---|
79 | case 0:
|
---|
80 | display_header();
|
---|
81 | ?>
|
---|
82 |
|
---|
83 | <p>Benvenuti in WordPress. Prima di iniziare ci occorrono alcune informazioni sul database. Occorre conoscere i seguenti elementi prima di procedere.</p>
|
---|
84 | <ol>
|
---|
85 | <li>Nome del database</li>
|
---|
86 | <li>Username del database</li>
|
---|
87 | <li>Password del database</li>
|
---|
88 | <li>Host del database</li>
|
---|
89 | <li>Prefisso tabella (se si desidera eseguire diverse istanze di WordPress con un solo database) </li>
|
---|
90 | </ol>
|
---|
91 | <p><strong>Se per qualsiasi ragione la creazione automatica del file non funzionasse non preoccuparsi. Tutto quello che si deve fare è immettere le informazioni sul database in un file di configurazione. Èpossibile anche semplicemente aprire il file <code>wp-config-sample.php</code> con un editor di testo, immettere le informazioni e salvare il file come <code>wp-config.php</code>. </strong></p>
|
---|
92 | <p>In ogni caso, queste informazioni vengono fornite dal proprio ISP. Se non si dispone di tali informazioni, allora si dovrà contattarlo prima di proseguire. Se si è pronti <a href="setup-config.php?step=1">iniziamo</a>! </p>
|
---|
93 |
|
---|
94 | <p class="step"><a href="setup-config.php?step=1" class="button">Iniziamo!</a></p>
|
---|
95 | <?php
|
---|
96 | break;
|
---|
97 |
|
---|
98 | case 1:
|
---|
99 | display_header();
|
---|
100 | ?>
|
---|
101 | <form method="post" action="setup-config.php?step=2">
|
---|
102 | <p>Di seguito si dovranno immettere i dettagli della connessione al database. Se non si è sicuri riguardo a questi dati, contattare il proprio fornitore di hosting.</p>
|
---|
103 | <table class="form-table">
|
---|
104 | <tr>
|
---|
105 | <th scope="row"><label for="dbname">Nome del database</label></th>
|
---|
106 | <td><input name="dbname" id="dbname" type="text" size="25" value="wordpress" /></td>
|
---|
107 | <td>Il nome del database da usare per far funzionare WP. </td>
|
---|
108 | </tr>
|
---|
109 | <tr>
|
---|
110 | <th scope="row"><label for="uname">Nome utente del database</label></th></th>
|
---|
111 | <td><input name="uname" id="uname" type="text" size="25" value="username" /></td>
|
---|
112 | <td>Il nome utente MySQL</td>
|
---|
113 | </tr>
|
---|
114 | <tr>
|
---|
115 | <th scope="row"><label for="pwd">Password</label></th>
|
---|
116 | <td><input name="pwd" id="pwd" type="text" size="25" value="password" /></td>
|
---|
117 | <td>...e la password MySQL.</td>
|
---|
118 | </tr>
|
---|
119 | <tr>
|
---|
120 | <th scope="row"><label for="dbhost">Host del database</label></th>
|
---|
121 | <td><input name="dbhost" id="dbhost" type="text" size="25" value="localhost" /></td>
|
---|
122 | <td>al 99% non si dovrà cambiare questa impostazione.</td>
|
---|
123 | </tr>
|
---|
124 | <tr>
|
---|
125 | <th scope="row"><label for="prefix">Prefisso tabella</label></th>
|
---|
126 | <td><input name="prefix" id="prefix" type="text" id="prefix" value="wp_" size="25" /></td>
|
---|
127 | <td>Se si desidera eseguire più istanze di WordPress con un singolo database, modificare questo valore.</td>
|
---|
128 | </tr>
|
---|
129 | </table>
|
---|
130 | <p class="step"><input name="submit" type="submit" value="Prosegui" class="button" /></p>
|
---|
131 | </form>
|
---|
132 | <?php
|
---|
133 | break;
|
---|
134 |
|
---|
135 | case 2:
|
---|
136 | $dbname = trim($_POST['dbname']);
|
---|
137 | $uname = trim($_POST['uname']);
|
---|
138 | $passwrd = trim($_POST['pwd']);
|
---|
139 | $dbhost = trim($_POST['dbhost']);
|
---|
140 | $prefix = trim($_POST['prefix']);
|
---|
141 | if (empty($prefix)) $prefix = 'wp_';
|
---|
142 |
|
---|
143 | // Test the db connection.
|
---|
144 | /**#@+
|
---|
145 | * @ignore
|
---|
146 | */
|
---|
147 | define('DB_NAME', $dbname);
|
---|
148 | define('DB_USER', $uname);
|
---|
149 | define('DB_PASSWORD', $passwrd);
|
---|
150 | define('DB_HOST', $dbhost);
|
---|
151 | /**#@-*/
|
---|
152 |
|
---|
153 | // We'll fail here if the values are no good.
|
---|
154 | require_wp_db();
|
---|
155 | if ( !empty($wpdb->error) )
|
---|
156 | wp_die($wpdb->error->get_error_message());
|
---|
157 |
|
---|
158 | $handle = fopen(ABSPATH . 'wp-config.php', 'w');
|
---|
159 |
|
---|
160 | foreach ($configFile as $line_num => $line) {
|
---|
161 | switch (substr($line,0,16)) {
|
---|
162 | case "define('DB_NAME'":
|
---|
163 | fwrite($handle, str_replace("putyourdbnamehere", $dbname, $line));
|
---|
164 | break;
|
---|
165 | case "define('DB_USER'":
|
---|
166 | fwrite($handle, str_replace("'usernamehere'", "'$uname'", $line));
|
---|
167 | break;
|
---|
168 | case "define('DB_PASSW":
|
---|
169 | fwrite($handle, str_replace("'yourpasswordhere'", "'$passwrd'", $line));
|
---|
170 | break;
|
---|
171 | case "define('DB_HOST'":
|
---|
172 | fwrite($handle, str_replace("localhost", $dbhost, $line));
|
---|
173 | break;
|
---|
174 | case '$table_prefix =':
|
---|
175 | fwrite($handle, str_replace('wp_', $prefix, $line));
|
---|
176 | break;
|
---|
177 | default:
|
---|
178 | fwrite($handle, $line);
|
---|
179 | }
|
---|
180 | }
|
---|
181 | fclose($handle);
|
---|
182 | chmod(ABSPATH . 'wp-config.php', 0666);
|
---|
183 |
|
---|
184 | display_header();
|
---|
185 | ?>
|
---|
186 | <p>Tutto a posto! Si è superata questa fase della installazione. Ora WordPress può comunicare con il database. Se si è, pronti ora è il momento di <a href="install.php">eseguire la installazione!</a></p>
|
---|
187 |
|
---|
188 | <p class="step"><a href="install.php" class="button">Avvia installazione</a></p>
|
---|
189 | <?php
|
---|
190 | break;
|
---|
191 | }
|
---|
192 | ?>
|
---|
193 | </body>
|
---|
194 | </html>
|
---|