/var/installatron/installers/magento/1.2.0.1/2.1.9
Edit: /var/installatron/installers/magento/1.2.0.1/2.1.9/init.xml (35014B)
read("vendor/magento/magento2-base/composer.json", "/['\"]version['\"]:\s*(['\"])(.+?)\\1/", 2);
if ( $r !== false ) return $r;
$r = $this->read("vendor/magento/framework/AppInterface.php", "/const\s+VERSION\s*=\s*(['\"])(.+?)\\1/", 2);
if ( $r !== false ) return $r;
$r = $this->read("app/Mage.php");
if (preg_match("/function\s+getVersionInfo\(\)\s*\{\s*return\s+array\(\s*'major'\s*=>\s*'(\d+)'\s*,\s*'minor'\s*=>\s*'(\d+)'\s*,\s*'revision'\s*=>\s*'(\d+)'\s*,\s*'patch'\s*=>\s*'(\d+)'/sim",$r,$m))
{
$v = $m[1].".".$m[2].".".$m[3].".".$m[4];
}
else if (preg_match("/function\s+getVersion\(\)\s*{\s*return\s+'([\d\.]+)'/sim",$r,$m))
{
$v = $m[1];
}
else
{
return false;
}
// test if 1.9.1.0 hotfix applied
if ( $v === "1.9.1.0" && strpos($this->read("app/code/core/Mage/Admin/Model/Observer.php"),"getInternallyForwarded") !== false )
{
return $v."-2";
}
// test if 1.9.1.1 hotfix applied
if ( $v === "1.9.1.1" && strpos($this->read("app/code/core/Mage/Core/Controller/Varien/Router/Admin.php"),"_validateControllerInstance") !== false )
{
return $v."-2";
}
return $v;
?>
db_query("SELECT `value` FROM `{$this->db_prefix}core_config_data` WHERE `path`='general/locale/code'",null,"value");
if ( trim($r) === "" )
{
return "en_US";
}
return $r;
?>
input["field_language"] !== "en" )
{
$this->extract("lc_".$this->input["field_language"]);
}
$this->db_query("UPDATE `{$this->db_prefix}core_config_data` SET `value`=? WHERE `path`='general/locale/code'",array($this->input["field_language_value"]));
*/
?>
db_query("SELECT `username` FROM `{$this->db_prefix}admin_user` WHERE `is_active`='1' ORDER BY `user_id` ASC LIMIT 1", null, "username");?>
db_query("SELECT `user_id` FROM `{$this->db_prefix}admin_user` WHERE `is_active`='1' ORDER BY `user_id` ASC LIMIT 1", null, "user_id");
$this->db_query("UPDATE `{$this->db_prefix}admin_user` SET `username`=? WHERE `user_id`=?", array($this->input["field_login"], $uid));
?>
input["field_passwd"]) || !isset($this->input["field_passwd"][1]) )
{
$this->addError("_errors_tooshort", "field_passwd");
}
/* else if (!preg_match("/[a-z].*\d|\d.*[a-z]/iu", $this->input["field_passwd"]))
{
$this->addError("Magento 2 passwords must include both numeric and alphabetic characters.", "field_passwd");
}*/
?>
db_query("SELECT `user_id` FROM `{$this->db_prefix}admin_user` WHERE `is_active`='1' ORDER BY `user_id` ASC LIMIT 1", null, "user_id");
$salt = i_lib::randstr(2);
$this->db_query("UPDATE `{$this->db_prefix}admin_user` SET `password`=? WHERE `user_id`=?", array(md5($salt.$this->input["field_passwd"]).":".$salt.":0", $uid) );
?>
db_query("SELECT `email` FROM `{$this->db_prefix}admin_user` WHERE `is_active`='1' ORDER BY `user_id` ASC LIMIT 1", null, "email");?>
db_query("SELECT `user_id` FROM `{$this->db_prefix}admin_user` WHERE `is_active`='1' ORDER BY `user_id` ASC LIMIT 1", null, "user_id");
$this->db_query("UPDATE `{$this->db_prefix}admin_user` SET `email`=? WHERE `user_id`=?",array($this->input["field_email"], $uid));
?>
db_query("SELECT `name` FROM `{$this->db_prefix}store_website` WHERE `is_default`='1'", null, "name");?>
db_query("UPDATE `{$this->db_prefix}store_website` SET `name`=? WHERE `is_default`='1'",array($this->input["field_sitetitle"]));?>
_installer_magento_input_enckey_text
read("app/etc/env.php", "#['\"]key['\"]\s*=>\s*(['\"])(.*?)\\1\s*,#", 2);?>
extract((($this->input["field_content"] === "yes") ? "demo" : "main"), "upgrtmp");
//@INTERNAL - LEGACY STEP BREAK POINT - DO NOT DISTURB
// @STATUS:
//
// rowan is adding the new magento versions now
//
// 2.2.0 - just released, not added to this installer yet (too early to add this new major release)
// 2.1.9 - have not been able to get this to upgrade successfully, and this is holding up release of 2.0.16/1.9.3.6
// - rowan is going to contact magento's devs
// - note: doesn't work on cp01; would need MySQL 5.6 to install 2.1.x
// 2.0.16 - added and fully tested on da01
// - note: doesn't work on cp01; would need MySQL 5.6 to install 2.1.x
// 1.9.3.6 - added and fully tested on da01 (might have tested on cp01, can't remember?)
$this->mv('upgrtmp/*');
$this->rm('upgrtmp');
$this->chmod(array('app/etc', 'var', 'vendor', 'pub/media', 'pub/static'), 0666, 0777, true);
// turn off symlinks for images
$this->sr("app/etc/di.xml", "/Symlink/", "Copy");
// fix for old servers
//@ref ticket #11631600
$this->sr(".htaccess",array(
"/RewriteCond ..REQUEST_METHOD. .TRAC\[EK\]\s*RewriteRule .. - \[L,R=405\]/sim" => "",
"/Options \+FollowSymLinks/i" => "Options +SymLinksIfOwnerMatch"
));
// chmod fix - only for non-suexec since Magento's 0770/0660 permissions are fine for suexec
#if ( $this->env["has_php_suexec"] === false ) - IT'S NEEDED ACTUALLY FOR SUPHP.
#{
$this->sr("vendor/magento/framework/Filesystem/DriverInterface.php",array(
"#WRITEABLE_DIRECTORY_MODE = \d+#" => "WRITEABLE_DIRECTORY_MODE = ".( $this->env["has_php_suexec"] !== false ? "0755" : "0777" ),
"#WRITEABLE_FILE_MODE = \d+#" => "WRITEABLE_FILE_MODE = ".( $this->env["has_php_suexec"] !== false ? "0644" : "0666" )
));
/*
// @NOTE: neither of these files exist in 2.1.6
$this->sr(array("lib/internal/Cm/Cache/Backend/File.php","vendor/magento/magento2-base/lib/internal/Cm/Cache/Backend/File.php"),array(
"#'directory_mode' => \d+#" => "'directory_mode' => ".( $this->env["has_php_suexec"] !== false ? "0755" : "0777" ),
"#'file_mode' => \d+#" => "'file_mode' => ".( $this->env["has_php_suexec"] !== false ? "0644" : "0666" )
));
*/
$this->sr("update/cron.php", "#0770#", (($this->env["has_php_suexec"] !== false) ? "0755" : "0777"));
// allow short passwords
$this->sr("vendor/magento/module-user/Model/UserValidationRules.php", "/->addRule\(\s*.passwordChars,\s*'password'\s*\)/sim", "");
// fix litespeed
$this->sr("pub/static/.htaccess", "/php_flag engine 0/", "#php_flag engine 0");
#}
// fix cookie error after installation
$this->sr("vendor/magento/framework/Stdlib/Cookie/PhpCookieManager.php", "#MAX_NUM_COOKIES\s*=\s*50#", "MAX_NUM_COOKIES = 200");
$rngadmin = strtolower(i_lib::randstr(8));
$password = "T0".$rngadmin;
//$payload = array(
// 'db' => array(
// 'useExistingDb' => 1,
// 'useAccess' => 1,
// 'host' => $this->db_host,
// 'user' => $this->db_user,
// 'name' => $this->db_name,
// 'password' => $this->db_pass,
// 'tablePrefix' => $this->db_prefix,
// ),
// 'admin' => array(
// 'passwordStatus' => array(
// 'class' => 'strong',
// 'label' => 'Strong',
// ),
// 'username' => "admin",
// 'email' => "devnull@installatron.com",
// 'password' => $password,
// 'confirm' => $password,
// ),
// 'store' => array(
// 'timezone' => 'UTC',
// 'currency' => 'USD',
// 'language' => 'en_US',
// 'useSampleData' => false,
// 'cleanUpDatabase' => false,
// 'loadedAllModules' => true,
// 'showModulesControl' => true,
// 'selectAll' => false,
// ),
// 'config' => array(
// 'encrypt' => array(
// 'type' => 'user',
// 'key' => isset($this->input["field_enckey"]) ? $this->input["field_enckey"] : md5(uniqid(rand(),true)),
// ),
// 'address' => array(
// 'admin' => $rngadmin,
// ),
// ///config.sessionSave.type
// ),
//);
$payload = array(
'admin' => array(
'confirm' => $password,
'email' => "devnull@installatron.com",
'password' => $password,
'passwordStatus' => array(
//'class' => "fair",
//'label' => "Fair",
'class' => 'strong',
'label' => 'Strong',
),
'username' => "admin",
),
'config' => array(
'address' => array(
'actual_base_url' => $this->url,
'admin' => $rngadmin,
'auto_base_url' => $this->url,
'base_url' => $this->url,
),
'advanced' => array(
'expanded' => false,
),
'encrypt' => array(
//'key' => null,
//'type' => "magento",
'type' => 'user',
'key' => isset($this->input["field_enckey"]) ? $this->input["field_enckey"] : md5(uniqid(rand(),true)),
),
'https' => array(
'admin' => false,
'front' => false,
'text' => $this->url,
),
'rewrites' => array(
'allowed' => true,
),
'sessionSave' => array(
'error' => false,
'type' => "files",
),
),
'db' => array(
'host' => $this->db_host,
'name' => $this->db_name,
'password' => $this->db_pass,
'tablePrefix' => $this->db_prefix,
'useAccess' => 1,
'useExistingDb' => 1,
'user' => $this->db_user,
),
'store' => array(
'advanced' => array(
'expanded' => false,
),
'cleanUpDatabase' => false,
'currency' => "USD",
'errorFlag' => false,
'errorMessage' => "",
'force' => false,
'language' => "en_US",
'loadedAllModules' => true,
'selectAll' => true,
'showError' => false,
'showModulesControl' => true,
'timezone' => "UTC",
'useSampleData' => false,
//'allModules' => array(
//'disabledModules' => array(
//'selectedModules' => array(
),
);
$r = $this->fetch("setup/index.php/install/start?".i_lib::json_encode($payload), true);
$this->write(".htinstall.log", $r);
// @NOTE: Rowan's experiments to get Magento locale selection working can be found at this spot in 2.1.7
if ( strpos($r,'"success":true') === false )
{
$this->addError("_errors_script");
return;
}
$this->chmod("var/generation", 0666, 0777, true);
#$this->chmod(array('pub/static'), 0666, 0777, true);
$this->chmod(array('app/etc'), 0644, 0755, true);
//$this->chmod('app/etc', 0755);
// run setup
$this->write("itronsetup.php", '<'.'?php
$_SERVER["argv"] = array("setup:static-content:deploy");
$_SERVER["argc"] = count($_SERVER["argv"]);
try
{
require __DIR__ . "/app/bootstrap.php";
}
catch (\Exception $e)
{
echo "Autoload error: " . $e->getMessage();
exit(1);
}
try
{
$application = new Magento\Framework\Console\Cli("Magento CLI");
$application->run();
}
catch (\Exception $e)
{
while ($e)
{
echo $e->getMessage();
echo $e->getTraceAsString();
$e = $e->getPrevious();
}
exit(1);
}
');
$r = $this->fetch("itronsetup.php", null, null, false);
$this->rm("itronsetup.php");
// run cron
$this->write("itroncron.php", '<'.'?php
$_SERVER["argv"] = array("", "cron:run");
$_SERVER["argc"] = count($_SERVER["argv"]);
try
{
require __DIR__ . "/app/bootstrap.php";
}
catch (\Exception $e)
{
echo "Autoload error: " . $e->getMessage();
exit(1);
}
try
{
$application = new Magento\Framework\Console\Cli("Magento CLI");
$application->run();
}
catch (\Exception $e)
{
while ($e)
{
echo $e->getMessage();
echo $e->getTraceAsString();
$e = $e->getPrevious();
}
exit(1);
}
');
$r = $this->fetch("itroncron.php", null, null, false);
$r = $this->fetch("itroncron.php", null, null, false);//second run, apparently needed
$this->rm("itroncron.php");
$this->chmod('bin/magento', 0744);
?>
extract("main", "upgrtmp");
//@INTERNAL - LEGACY STEP BREAK POINT - DO NOT DISTURB
// @WARNING: Saving from [Version] at the moment will ruin this app's administration link.
// I will remove this warning when the editor problem is resolved.
$this->rm('upgrtmp/.htaccess');
$this->mv('upgrtmp/*');
$this->rm('upgrtmp');
$hasSuexec = ($this->env["has_php_suexec"] !== false);
$dirChmod = ($hasSuexec) ? "0755" : "0777";
$fileChmod = ($hasSuexec) ? "0644" : "0666";
$this->_reclaim(array('var/cache', 'var/page_cache', 'var/generation'));
$this->rm(array('var/cache', 'var/page_cache', 'var/generation'));
$this->mkdir(array('var/cache', 'var/page_cache', 'var/generation'));
$this->chmod(array('app/etc', 'var', 'vendor', 'pub/media', 'pub/static'), 0666, 0777, true);
// turn off symlinks for images
$this->sr("app/etc/di.xml", "/Symlink/", "Copy");
// chmod fix - only for non-suexec since Magento's 0770/0660 permissions are fine for suexec
#if ( $this->env["has_php_suexec"] === false ) - IT'S NEEDED ACTUALLY FOR SUPHP.
#{
$this->sr("vendor/magento/framework/Filesystem/DriverInterface.php",array(
"#WRITEABLE_DIRECTORY_MODE = \d+#" => "WRITEABLE_DIRECTORY_MODE = $dirChmod",
"#WRITEABLE_FILE_MODE = \d+#" => "WRITEABLE_FILE_MODE = $fileChmod"
));
$this->sr("update/cron.php", "#0770#", "$dirChmod");
// allow short passwords
$this->sr("vendor/magento/module-user/Model/UserValidationRules.php", "/->addRule\(\s*.passwordChars,\s*'password'\s*\)/sim", "");
// fix litespeed
$this->sr("pub/static/.htaccess", "/php_flag engine 0/", "#php_flag engine 0");
// fix cookie error when trying to log into administration
$this->sr("vendor/magento/framework/Stdlib/Cookie/PhpCookieManager.php", "#MAX_NUM_COOKIES\s*=\s*50#", "MAX_NUM_COOKIES = 200");
// fix styles
$this->db_query("UPDATE `{$this->db_prefix}core_config_data` SET `value` = ? WHERE `path`='design/head/includes'", array('url).'/pub/media/styles.css" />'));
$contents_consoleoutput = $this->read("vendor/symfony/console/Symfony/Component/Console/Output/ConsoleOutput.php");
$this->sr("vendor/symfony/console/Symfony/Component/Console/Output/ConsoleOutput.php", array(
"/function openOutputStream/" => "function openOutputStream() {return @fopen('.htinstall.deleteme.log','w');} private function _openOutputStream",
"/function openErrorStream/" => "function openErrorStream() {return @fopen('.htinstall.deleteme.log','w');} private function _openErrorStream",
#"/(function openErrorStream)/" => "{}() {return @fopen('install.log','w');} {}xx",
));
$this->write(".htinstall.deleteme.log","");
$this->chmod(".htinstall.deleteme.log", 0666); // @todo: should this use $fileChmod ?
$this->chmod('bin/magento', 0744);
// run setup
$this->write("itronsetup.php", '<'.'?php
use Magento\Framework\App\Bootstrap;
require __DIR__ . "/app/bootstrap.php";
$bootstrap = Bootstrap::create(BP, $_SERVER);
$obj = $bootstrap->getObjectManager();
$state = $obj->get("Magento\Framework\App\State");
$state->setAreaCode("adminhtml");
$k[0]="bin/magento";
$k[1]="setup:upgrade"; // write your proper command like setup:upgrade,cache:enable etc...
$_SERVER["argv"]=$k;
try {
$handler = new \Magento\Framework\App\ErrorHandler();
set_error_handler([$handler, "handler"]);
$application = new Magento\Framework\Console\Cli("Magento CLI");
$application->run();
} catch (\Exception $e) {
while ($e) {
echo $e->getMessage();
echo $e->getTraceAsString();
echo "\n\n";
$e = $e->getPrevious();
}
}
');
$r = $this->fetch("itronsetup.php", null, null, false);
//$this->rm("itronsetup.php");
// run compile
$this->write("itroncompile.php", '<'.'?php
use Magento\Framework\App\Bootstrap;
require __DIR__ . "/app/bootstrap.php";
$bootstrap = Bootstrap::create(BP, $_SERVER);
$obj = $bootstrap->getObjectManager();
$state = $obj->get("Magento\Framework\App\State");
$state->setAreaCode("adminhtml");
$k[0]="bin/magento";
$k[1]="setup:di:compile"; // write your proper command like setup:upgrade,cache:enable etc...
$_SERVER["argv"]=$k;
try {
$handler = new \Magento\Framework\App\ErrorHandler();
set_error_handler([$handler, "handler"]);
$application = new Magento\Framework\Console\Cli("Magento CLI");
$application->run();
} catch (\Exception $e) {
while ($e) {
echo $e->getMessage();
echo $e->getTraceAsString();
echo "\n\n";
$e = $e->getPrevious();
}
}
');
$r = $this->fetch("itroncompile.php", null, null, false);
//$this->rm("itroncompile.php");
//$this->write("itronsetup.php", '<'.'?php
//
//$_SERVER["argv"] = array("setup:upgrade");
//$_SERVER["argc"] = count($_SERVER["argv"]);
//
//try
//{
// require __DIR__ . "/app/bootstrap.php";
//}
//catch (\Exception $e)
//{
// echo "Autoload error: " . $e->getMessage();
// exit(1);
//}
//
//try
//{
// $application = new Magento\Framework\Console\Cli("Magento CLI");
// $application->run();
//}
//catch (\Exception $e)
//{
// while ($e)
// {
// echo $e->getMessage();
// echo $e->getTraceAsString();
// $e = $e->getPrevious();
// }
// exit(1);
//}
//');
//$r = $this->fetch("itronsetup.php", null, null, false);
//$this->rm("itronsetup.php");
?>