index.php
来自「php 开发的内容管理系统」· PHP 代码 · 共 1,666 行 · 第 1/4 页
PHP
1,666 行
print "<li>Skipped sysop account creation, no name given.</li>\n"; } $titleobj = Title::newFromText( wfMsgNoDB( "mainpage" ) ); $article = new Article( $titleobj ); $newid = $article->insertOn( $wgDatabase ); $revision = new Revision( array( 'page' => $newid, 'text' => wfMsg( 'mainpagetext' ) . "\n\n" . wfMsg( 'mainpagedocfooter' ), 'comment' => '', 'user' => 0, 'user_text' => 'MediaWiki default', ) ); $revid = $revision->insertOn( $wgDatabase ); $article->updateRevisionOn( $wgDatabase, $revision ); print "<li><pre>"; initialiseMessages(); print "</pre></li>\n"; } /* Write out the config file now that all is well */ print "<p>Creating LocalSettings.php...</p>\n\n"; $localSettings = "<" . "?php$endl$local$endl?" . ">"; // Fix up a common line-ending problem (due to CVS on Windows) $localSettings = str_replace( "\r\n", "\n", $localSettings ); if( version_compare( phpversion(), "4.3.2" ) >= 0 ) { $xt = "xt"; # Refuse to overwrite an existing file } else { $xt = "wt"; # 'x' is not available prior to PHP 4.3.2. We did check above, but race conditions blah blah } $f = fopen( "LocalSettings.php", $xt ); if( $f == false ) { dieout( "<p>Couldn't write out LocalSettings.php. Check that the directory permissions are correct and that there isn't already a file of that name here...</p>\n" . "<p>Here's the file that would have been written, try to paste it into place manually:</p>\n" . "<pre>\n" . htmlspecialchars( $localSettings ) . "</pre>\n" ); } if(fwrite( $f, $localSettings ) ) { fclose( $f ); writeSuccessMessage(); } else { fclose( $f ); die("<p class='error'>An error occured while writing the config/LocalSettings.php file. Check user rights and disk space then try again.</p>\n"); } } while( false );}?></ul><?phpif( count( $errs ) ) { /* Display options form */ if( $conf->posted ) { echo "<p class='error-top'>Something's not quite right yet; make sure everything below is filled out correctly.</p>\n"; }?><form action="index.php" name="config" method="post"><h2>Site config</h2><div class="config-section"> <div class="config-input"> <?php aField( $conf, "Sitename", "Wiki name:" ); ?> </div> <p class="config-desc"> Preferably a short word without punctuation, i.e. "Wikipedia".<br /> Will appear as the namespace name for "meta" pages, and throughout the interface. </p> <div class="config-input"> <?php aField( $conf, "EmergencyContact", "Contact e-mail:" ); ?> </div> <p class="config-desc"> Displayed to users in some error messages, used as the return address for password reminders, and used as the default sender address of e-mail notifications. </p> <div class="config-input"> <label class='column' for="LanguageCode">Language:</label> <select id="LanguageCode" name="LanguageCode"> <?php $list = getLanguageList(); foreach( $list as $code => $name ) { $sel = ($code == $conf->LanguageCode) ? 'selected="selected"' : ''; echo "\t\t<option value=\"$code\" $sel>$name</option>\n"; } ?> </select> </div> <p class="config-desc"> Select the language for your wiki's interface. Some localizations aren't fully complete. Unicode (UTF-8) used for all localizations. </p> <div class="config-input"> <label class='column'>Copyright/license:</label> <ul class="plain"> <li><?php aField( $conf, "License", "No license metadata", "radio", "none" ); ?></li> <li><?php aField( $conf, "License", "GNU Free Documentation License 1.2 (Wikipedia-compatible)", "radio", "gfdl" ); ?></li> <li><?php aField( $conf, "License", "A Creative Commons license - ", "radio", "cc" ); $partner = "MediaWiki"; $exit = urlencode( "$wgServer{$conf->ScriptPath}/config/index.php?License=cc&RightsUrl=[license_url]&RightsText=[license_name]&RightsCode=[license_code]&RightsIcon=[license_button]" ); $icon = urlencode( "$wgServer$wgUploadPath/wiki.png" ); $ccApp = htmlspecialchars( "http://creativecommons.org/license/?partner=$partner&exit_url=$exit&partner_icon_url=$icon" ); print "<a href=\"$ccApp\" target='_blank'>choose</a>"; ?> <?php if( $conf->License == "cc" ) { ?> <ul> <li><?php aField( $conf, "RightsIcon", "<img src=\"" . htmlspecialchars( $conf->RightsIcon ) . "\" alt='icon' />", "hidden" ); ?></li> <li><?php aField( $conf, "RightsText", htmlspecialchars( $conf->RightsText ), "hidden" ); ?></li> <li><?php aField( $conf, "RightsCode", "code: " . htmlspecialchars( $conf->RightsCode ), "hidden" ); ?></li> <li><?php aField( $conf, "RightsUrl", "<a href=\"" . htmlspecialchars( $conf->RightsUrl ) . "\">" . htmlspecialchars( $conf->RightsUrl ) . "</a>", "hidden" ); ?></li> </ul> <?php } ?> </li> </ul> </div> <p class="config-desc"> A notice, icon, and machine-readable copyright metadata will be displayed for the license you pick. </p> <div class="config-input"> <?php aField( $conf, "SysopName", "Admin username:" ) ?> </div> <div class="config-input"> <?php aField( $conf, "SysopPass", "Password:", "password" ) ?> </div> <div class="config-input"> <?php aField( $conf, "SysopPass2", "Password confirm:", "password" ) ?> </div> <p class="config-desc"> An admin can lock/delete pages, block users from editing, and other maintenance tasks.<br /> A new account will be added only when creating a new wiki database. </p> <div class="config-input"> <label class='column'>Shared memory caching:</label> <ul class="plain"> <li><?php aField( $conf, "Shm", "No caching", "radio", "none" ); ?></li> <?php if ( $conf->turck ) { echo "<li>"; aField( $conf, "Shm", "Turck MMCache", "radio", "turck" ); echo "</li>"; } if ( $conf->apc ) { echo "<li>"; aField( $conf, "Shm", "APC", "radio", "apc" ); echo "</li>"; } if ( $conf->eaccel ) { echo "<li>"; aField( $conf, "Shm", "eAccelerator", "radio", "eaccel" ); echo "</li>"; } ?> <li><?php aField( $conf, "Shm", "Memcached", "radio", "memcached" ); ?></li> </ul> <div style="clear:left"><?php aField( $conf, "MCServers", "Memcached servers:", "text" ) ?></div> </div> <p class="config-desc"> Using a shared memory system such as Turck MMCache, APC, eAccelerator, or Memcached will speed up MediaWiki significantly. Memcached is the best solution but needs to be installed. Specify the server addresses and ports in a comma-separted list. Only use Turck shared memory if the wiki will be running on a single Apache server. </p></div><h2>E-mail, e-mail notification and authentication setup</h2><div class="config-section"> <div class="config-input"> <label class='column'>E-mail features (global):</label> <ul class="plain"> <li><?php aField( $conf, "Email", "Enabled", "radio", "email_enabled" ); ?></li> <li><?php aField( $conf, "Email", "Disabled", "radio", "email_disabled" ); ?></li> </ul> </div> <p class="config-desc"> Use this to disable all e-mail functions (password reminders, user-to-user e-mail and e-mail notifications) if sending mail doesn't work on your server. </p> <div class="config-input"> <label class='column'>User-to-user e-mail:</label> <ul class="plain"> <li><?php aField( $conf, "Emailuser", "Enabled", "radio", "emailuser_enabled" ); ?></li> <li><?php aField( $conf, "Emailuser", "Disabled", "radio", "emailuser_disabled" ); ?></li> </ul> </div> <p class="config-desc"> The user-to-user e-mail feature (Special:Emailuser) lets the wiki act as a relay to allow users to exchange e-mail without publicly advertising their e-mail address. </p> <div class="config-input"> <label class='column'>E-mail notification about changes:</label> <ul class="plain"> <li><?php aField( $conf, "Enotif", "Disabled", "radio", "enotif_disabled" ); ?></li> <li><?php aField( $conf, "Enotif", "Enabled for changes to user discussion pages only", "radio", "enotif_usertalk" ); ?></li> <li><?php aField( $conf, "Enotif", "Enabled for changes to user discussion pages, and to pages on watchlists (not recommended for large wikis)", "radio", "enotif_allpages" ); ?></li> </ul> </div> <div class="config-desc"> <p> For this feature to work, an e-mail address must be present for the user account, and the notification options in the user's preferences must be enabled. Also note the authentication option below. When testing the feature, keep in mind that your own changes will never trigger notifications to be sent to yourself.</p> <p>There are additional options for fine tuning in /includes/DefaultSettings.php; copy these to your LocalSettings.php and edit them there to change them.</p> </div> <div class="config-input"> <label class='column'>E-mail address authentication:</label> <ul class="plain"> <li><?php aField( $conf, "Eauthent", "Disabled", "radio", "eauthent_disabled" ); ?></li> <li><?php aField( $conf, "Eauthent", "Enabled", "radio", "eauthent_enabled" ); ?></li> </ul> </div> <div class="config-desc"> <p>If this option is enabled, users have to confirm their e-mail address using a magic link sent to them whenever they set or change it, and only authenticated e-mail addresses can receive mails from other users and/or change notification mails. Setting this option is <B>recommended</B> for public wikis because of potential abuse of the e-mail features above.</p> </div></div><h2>Database config</h2><div class="config-section"><div class="config-input"> <label class='column'>Database type:</label> <ul class='plain'><?php database_picker($conf) ?></ul> </div> <div class="config-input" style="clear:left"><?php aField( $conf, "DBserver", "Database host:" ); ?></div> <p class="config-desc"> If your database server isn't on your web server, enter the name or IP address here. </p> <div class="config-input"><?php aField( $conf, "DBname", "Database name:" ); ?></div> <div class="config-input"><?php aField( $conf, "DBuser", "DB username:" ); ?></div> <div class="config-input"><?php aField( $conf, "DBpassword", "DB password:", "password" ); ?></div> <div class="config-input"><?php aField( $conf, "DBpassword2", "DB password confirm:", "password" ); ?></div> <p class="config-desc"> If you only have a single user account and database available, enter those here. If you have database root access (see below) you can specify new accounts/databases to be created. </p> <p> This account will not be created if it pre-exists. If this is the case, ensure that it has SELECT, INSERT, UPDATE and DELETE permissions on the MediaWiki database. </p> <?php database_switcher('mysql'); ?> <div class="config-input"><?php aField( $conf, "DBprefix", "Database table prefix:" ); ?></div> <div class="config-desc"> <p>If you need to share one database between multiple wikis, or MediaWiki and another web application, you may choose to add a prefix to all the table names to avoid conflicts.</p> <p>Avoid exotic characters; something like <tt>mw_</tt> is good.</p> </div> <div class="config-input"><label class="column">Database charset</label> <div>Select one:</div> <ul class="plain"> <li><?php aField( $conf, "DBmysql5", "Backwards-compatible UTF-8", "radio", "false" ); ?></li> <li><?php aField( $conf, "DBmysql5", "Experimental MySQL 4.1/5.0 UTF-8", "radio", "true" ); ?></li> </ul> </div> <p class="config-desc"> <b>EXPERIMENTAL:</b> You can enable explicit Unicode charset support for MySQL 4.1 and 5.0 servers. This is not well tested and may cause things to break. <b>If upgrading an older installation, leave in backwards-compatible mode.</b> </p> </div> <?php database_switcher('postgres'); ?> <div class="config-input"><?php aField( $conf, "DBport", "Database port:" ); ?></div> <div class="config-input"><?php aField( $conf, "DBmwschema", "Schema for mediawiki:" ); ?></div> <div class="config-input"><?php aField( $conf, "DBts2schema", "Schema for tsearch2:" ); ?></div> <div class="config-desc"> <p>The username specified above will have it's search path set to the above schemas, so it is recommended that you create a new user.</p> </div> </div> <div class="config-input"> <?php aField( $conf, "RootUser", "Superuser account:", "superuser" ); ?> </div> <div class="config-input"> <?php aField( $conf, "RootPW", "Superuser password:", "password" ); ?> </div> <p class="config-desc"> If the database user specified above does not exist, or does not have access to create the database (if needed) or tables within it, please provide details of a superuser account, such as <strong>root</strong>, which does. Leave the password set to <strong>-</strong> if this is not needed. </p> <div class="config-input" style="padding:2em 0 3em"> <label class='column'> </label> <input type="submit" value="Install MediaWiki!" class="btn-install" /> </div></div><script type="text/javascript">window.onload = togglearea('<?php echo $conf->DBtype; ?>');</script></form><?php}/* -------------------------------------------------------------------------------------- */function writeSuccessMessage() { if ( ini_get( 'safe_mode' ) && !ini_get( 'open_basedir' ) ) { echo <<<EOT<p>Installation successful!</p><p>To complete the installation, please do the following:<ol> <li>Download config/LocalSettings.php with your FTP client or file manager</li> <li>Upload it to the parent directory</li> <li>Delete config/LocalSettings.php</li> <li>Start using <a href='../index.php'>your wiki</a>!</ol><p>If you are in a shared hosting environment, do <strong>not</strong> just move LocalSettings.phpremotely. LocalSettings.php is currently owned by the user your webserver is running under,which means that anyone on the same server can read your database password! Downloadingit and uploading it again will hopefully change the ownership to a user ID specific to you.</p>EOT; } else { echo "<p>Installation successful! Move the config/LocalSettings.php file into the parent directory, then follow <a href='../index.php'>this link</a> to your wiki.</p>\n"; }}function escapePhpString( $string ) { return strtr( $string, array( "\n" => "\\n", "\r" => "\\r", "\t" => "\\t", "\\" => "\\\\", "\$" => "\\\$", "\"" => "\\\"" ));}function writeLocalSettings( $conf ) { $conf->UseImageResize = $conf->UseImageResize ? 'true' : 'false'; $conf->PasswordSender = $conf->EmergencyContact; $zlib = ($conf->zlib ? "" : "# "); $magic = ($conf->ImageMagick ? "" : "# "); $convert = ($conf->ImageMagick ? $conf->ImageMagick : "/usr/bin/convert" ); $pretty = ($conf->prettyURLs ? "" : "# "); $ugly = ($conf->prettyURLs ? "# " : ""); $rights = ($conf->RightsUrl) ? "" : "# "; $hashedUploads = $conf->safeMode ? '' : '# '; switch ( $conf->Shm ) { case 'memcached': $cacheType = 'CACHE_MEMCACHED'; $mcservers = var_export( $conf->MCServerArray, true ); break; case 'turck': case 'apc': case 'eaccel': $cacheType = 'CACHE_ACCEL'; $mcservers = 'array()'; break; default: $cacheType = 'CACHE_NONE'; $mcservers = 'array()'; } if ( $conf->Email == 'email_enabled' ) {
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?