<?php
/**
* WordPress
*
* @author Installatron Converter
*/
class i_wordpress_4_3_4_install extends i_action_install
{
//==========================================================================
// STEP II: ARCHIVE EXTRACTION
//==========================================================================
public function step2_init()
{
$this->setStepLabel("_step_progress_extracting");
}
public function step2_process()
{
$this->extract("main");
$this->extract( $this->input["field_multisite"] === "yes" ? "data_mu" : "data" );
}
//==========================================================================
// STEP III: CONFIGURING INSTALL
//==========================================================================
public function step3_init()
{
$this->setStepLabel("_step_progress_processing");
}
public function step3_process()
{
$this->mv('wordpress/*');
$this->rm('wordpress');
$this->mkdir(array('wp-content/uploads','wp-content/languages', "wp-content/uploads/et_temp"));//'wp-content/blogs.dir',
// to avoid safe_mode restrictions:
//@note if anyone is still using PHP <5.4 (when safe_mode is junked) in 2016 I will not be surprised.
if (version_compare($this->env["has_php"], "5.4", "<"))
{
$r = array();
for ( $i = 2013; $i < 2017; ++$i)
{
$r[] = "wp-content/uploads/$i";
for ( $j = 1; $j < 13; ++$j)
{
$r[] = "wp-content/uploads/$i/".sprintf("%02d",$j);
}
}
$this->mkdir($r);
}
$this->chmod("wp-content", 0666, 0777, true);
$this->chmod("wp-content/index.php", 0644);
// $this->write("wp-content/uploads/.htaccess","<Files *.php>\ndeny from all\n</Files>\n<Files *.css.php>\nallow from all\n</Files>");
$urlinfo = parse_url($this->url);
// write new .htaccess for WPMU
if ( $this->input["field_multisite"] === "yes" )
{
$this->write(".htaccess",'
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase '.$urlinfo["path"].'/
RewriteRule ^index\\.php$ - [L]
# uploaded files
RewriteRule ^([_0-9a-zA-Z-]+/)?files/(.+) wp-includes/ms-files.php?file=$2 [L]
# add a trailing slash to /wp-admin
RewriteRule ^([_0-9a-zA-Z-]+/)?wp-admin$ $1wp-admin/ [R=301,L]
RewriteCond %{REQUEST_FILENAME} -f [OR]
RewriteCond %{REQUEST_FILENAME} -d
RewriteRule ^ - [L]
RewriteRule ^([_0-9a-zA-Z-]+/)?(wp-(content|admin|includes).*) $2 [L]
RewriteRule ^([_0-9a-zA-Z-]+/)?(.*\\.php)$ $2 [L]
RewriteRule . index.php [L]
</IfModule>
');
}
else
{
$urlinfo = parse_url($this->url);
$this->write(".htaccess",'
# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase '.$urlinfo["path"].'/
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . '.$urlinfo["path"].'/index.php [L]
</IfModule>
# END WordPress');
}
$this->cp('wp-config-sample.php','wp-config.php');
//$charSet = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789<>[]()+-=`|#:;~?!@#$%^&*.,';
$r = array(
"#'localhost'#" => var_export($this->db_host,true),
"#'username_here'#" => var_export($this->db_user,true),
"#'database_name_here'#" => var_export($this->db_name,true),
"#'password_here'#" => var_export($this->db_pass,true),
"#'wp_'#" => var_export($this->db_prefix,true),
"#define\('AUTH_KEY',.+'put your unique phrase here'\);#s" //matches whole block
=>
"define('AUTH_KEY', ".var_export(i_lib::randstr(64),true).");
define('SECURE_AUTH_KEY', ".var_export(i_lib::randstr(64),true).");
define('LOGGED_IN_KEY', ".var_export(i_lib::randstr(64),true).");
define('NONCE_KEY', ".var_export(i_lib::randstr(64),true).");
define('AUTH_SALT', ".var_export(i_lib::randstr(64),true).");
define('SECURE_AUTH_SALT', ".var_export(i_lib::randstr(64),true).");
define('LOGGED_IN_SALT', ".var_export(i_lib::randstr(64),true).");
define('NONCE_SALT', ".var_export(i_lib::randstr(64),true).");
/**
* Other customizations.
*/
"
.( $this->env["has_php_suexec"] === false && $this->env["has_php_safe_mode"] !== false ? "" : "define('FS_METHOD','direct');".( $this->env["has_php_suexec"] !== false ? "define('FS_CHMOD_DIR',0755);define('FS_CHMOD_FILE',0644);" : "define('FS_CHMOD_DIR',0777);define('FS_CHMOD_FILE',0666);" )."\n" )
."define('WP_TEMP_DIR',dirname(__FILE__).'/wp-content/uploads');
/**
* Turn off automatic updates since these are managed upstream.
*/
define('AUTOMATIC_UPDATER_DISABLED', true);
"
.( $this->input["field_multisite"] === "yes" ? "
/**
* Multi-site
*
*/
define('MULTISITE', true);
define('SUBDOMAIN_INSTALL', false);
\$base = ".var_export($urlinfo["path"]."/",true).";
define('DOMAIN_CURRENT_SITE', ".var_export($urlinfo["host"],true).");
define('PATH_CURRENT_SITE', ".var_export($urlinfo["path"]."/",true).");
define('SITE_ID_CURRENT_SITE', 1);
define('BLOG_ID_CURRENT_SITE', 1);
define('WP_ALLOW_MULTISITE', true);
" : "" )
.( isset($this->input["livedemo"]) ? "
define( 'DISALLOW_FILE_MODS', true );
" : "" )
);
$this->sr("wp-config.php", $r);
if ( $this->input["field_multisite"] === "yes" )
{
$r = array(
"#ynri_#" => $this->db_prefix,
"#http://www.testing.installatron.com/djfkl#" => $this->url,
"#'www.testing.installatron.com'#" => "'".$urlinfo["host"]."'",
"#'/djfkl/'#" => "'".$urlinfo["path"]."/'",
);
}
else
{
$r = array(
"#zzct_#" => $this->db_prefix,
"#http://www.testing.installatron.com/wordpress\d*#" => $this->url
);
}
//needs to be looser, b/c WP uses it in vlaues: $this->sr("install.sql", "#`zzct_#", "`$this->db_prefix");
$this->db_import("install.sql", null, $r);
$this->rm("install.sql");
//@see wp-admin/includes/upgrade.php for schema changes
$sql = "";
$sql .= "UPDATE `{$this->db_prefix}posts` SET post_date=NOW(), post_date_gmt=NOW(), post_modified=NOW(), post_modified_gmt=NOW();\n";
$sql .= "UPDATE `{$this->db_prefix}users` SET user_pass='".md5($this->input["field_passwd"])."', user_login='".$this->db_escape($this->input["field_login"])."', user_email='".$this->db_escape($this->input["field_email"])."', user_registered=NOW() WHERE ID='1';\n";
if ( $this->input["field_multisite"] === "yes" )
{
$this->db_query("UPDATE `{$this->db_prefix}sitemeta` SET `meta_value`=? WHERE `meta_key`='site_admins'",array(serialize(array($this->input["field_login"]))));
$this->db_query("UPDATE `{$this->db_prefix}sitemeta` SET `meta_value`=? WHERE `meta_key`='admin_email'",array($this->input["field_email"]));
}
$sql .= "UPDATE `{$this->db_prefix}options` SET `option_value`='".$this->db_escape("$this->path/wp-content/uploads")."' WHERE `option_name`='upload_path';\n";
$sql .= "UPDATE `{$this->db_prefix}options` SET `option_value`='".$this->db_escape($this->input["field_email"])."' WHERE `option_name`='admin_email';\n";
$sql .= "UPDATE `{$this->db_prefix}usermeta` SET `meta_value`='0' WHERE `meta_key`='default_password_nag' AND `user_id`='1';\n";
$sql .= "UPDATE `{$this->db_prefix}options` SET `option_value`='1' WHERE `option_name`='blog_public';\n";
// use twentyeleven theme
$sql .= "UPDATE `{$this->db_prefix}options` SET `option_value`='twentyfifteen' WHERE `option_name`='stylesheet' OR `option_name`='template';\n";
// use permalinks instead of query string
if ( !isset($this->env["has_apache"]) || $this->env["has_apache"] !== false || $this->env["has_nginx"] !== false )
{
$sql .= "UPDATE `{$this->db_prefix}options` SET `option_value`='".( $this->ds === "/" ? "/%category%/%postname%/" : "" )."' WHERE `option_name`='permalink_structure';\n";
}
$sql .= "INSERT INTO `{$this->db_prefix}options` (`option_name`, `option_value`) VALUES
('ftp_credentials', '".$this->db_escape(serialize(array( "hostname" => "localhost", "username" => $this->input["field_ftpuser"], "connection_type" => "ftp" )))."');\n";
//3.0 database version--set in SQL
//$this->db_query("UPDATE {$this->db_prefix}options SET option_value='15260' WHERE option_name='db_version'");
$this->write("install2.sql",$sql);
$this->db_import("install2.sql");
$this->rm("install2.sql");
$this->chmod(array(".htaccess","wp-config.php"),0666);
// to fix the upgrade screen after the first install:
$r = $this->fetch('wp-admin/upgrade.php?step=1', null, null, false);
//$this->write(".htinstall.log",$r);
// multisite upgrade patch
if ( $this->input["field_multisite"] === "yes" )
{
$this->cp("wp-admin/network/upgrade.php", "wp-admin/network/upgrade.php.bak");
$this->sr("wp-admin/network/upgrade.php",array(
"#require_once\( './admin.php' \);#" => "require( '../../wp-load.php' );set_time_limit(0);",
"#get_current_screen\(\)->add.+'</h2>';#sim" => "",
"#LIMIT ..n., 5#" => ""
));
$this->fetch("wp-admin/network/upgrade.php?action=upgrade", null, null, false);
sleep(5);
$this->mv("wp-admin/network/upgrade.php.bak", "wp-admin/network/upgrade.php");
}
#$this->write("wp-content/.htaccess","<Files *.php>
#deny from all
#</Files>");
$this->write("wp-includes/.htaccess","<Files *.php>
deny from all
</Files>
<Files wp-tinymce.php>
allow from all
</Files>
<Files ms-files.php>
allow from all
</Files>");
//$this->sr("wp-admin/menu.php", "!(".preg_quote('$submenu[ \'index.php\' ][5] = array( __(\'My Sites\'), \'read\', \'my-sites.php\' );',"!").")!", "$1\n\$submenu[ 'index.php' ][6] = array( __('Manage Sites'), 'read', 'network/index.php' );");
$this->rm("readme.html");
#$this->addError('test');
}
}
?>
Copyright 2K16 - 2K18 Indonesian Hacker Rulez