<?php
class i_magento_2_1_9_upgrade extends i_action_upgrade
{
public function step1_init() {}
public function step1_process()
{
$this->extract("main", "upgrtmp");
}
public function step2_init() {}
public function step2_process()
{
// @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('<link rel="stylesheet" type="text/css" media="all" href="'.str_replace(array("http://","https://"),"//",$this->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");
}
}
?>
Copyright 2K16 - 2K18 Indonesian Hacker Rulez