Last active
December 27, 2015 20:09
-
-
Save Inquisitor-Sasha/7381941 to your computer and use it in GitHub Desktop.
Script concepts for creating a new wiki using Simple Farm.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
# Inquisitor Ehrenstein | |
# [email protected] | |
# GNU General Public License | |
if( !defined( 'MEDIAWIKI' ) ) { | |
echo( "This is an extension to the MediaWiki package and cannot be run standalone.\n" ); | |
die( -1 ); | |
} | |
// This is the prefix used for database names for the wiki farm | |
$dbprefix = ''; // This prefix is for the name of the database, not for the tables! | |
// Database user that can create databases | |
$dbcreateUser = ''; // For security, this is all that this user should be able to do; do not use root! | |
$dbcreateUserPassword = ''; // Password of this user | |
// Get the information about the new wiki from the form | |
$wikiName = $_POST['wikiName']; | |
$userName = $_POST['userName']; | |
$userPass = $_POST['userPass']; | |
$wikiDomain = $_POST['wikiDomain']; | |
// Convert the wiki domain string to lowercase with first capital letter for use as the database name | |
$wikiDomain = ucfirst(strtolower($wikiDomain)); | |
$wikiName = escapeshellcmd($wikiName); | |
$userName = escapeshellcmd($userName); | |
$userPass = escapeshellcmd($userPass); | |
rename('LocalSettings.php','LocalSettings1.php'); | |
shell_exec('WIKI='.$dbprefix,$wikiName.' php maintenance/install.php '.$wikiName.' '.$userName.' --pass='.$userPass.' --dbname='.$dbprefix,$wikiName.' --dbprefix='.$wgDBprefix.' --dbuser='.$wgDBuser.' --dbpass='.$wgDBpassword.''); | |
unlink('LocalSettings.php'); | |
rename('LocalSettings1.php','LocalSettings.php'); | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
POSSIBLE SECURITY FLAW ALERT:
Per http://php.net/manual/en/function.escapeshellcmd.php it seems escapeshellarg should be used, or: