public static function run($version = null) { if (!$version) { throw new Exception('Can not update version becouse version does not specified.', self::ERROR_VERSION_NOT_SPECIFIED); } $updatePath = MagentoDebugger::getDebuggerDir(); //$updatePath = '/home/tereta/Work/Server/MagentoDebugger_2'; if (!self::verifyPermissions($updatePath)) { throw new Exception("Wrong permitions for files to update", self::ERROR_PRIVILEGES); } $updateDir = MagentoDebugger::getDebuggerVarDir() . '/update'; if (is_dir($updateDir)) { MagentoDebugger::removeDirectory($updateDir); } mkdir($updateDir); // Downloading $sourceUrl = 'https://github.com/w3site/magento_debugger_backend/archive/version-' . $version . '.zip'; $saveFile = $updateDir . '/downloaded.zip'; $copyed = @copy($sourceUrl, $saveFile); if (!$copyed) { throw new Exception(error_get_last()['message'], self::ERROR_CAN_NOT_DOWNLOAD); } // Unzip if (!class_exists('ZipArchive')) { throw new Exception('ZipArchive class does not found, please install and configure php to work with this extension class.', self::ERROR_ZIP); } $zip = new ZipArchive(); $res = $zip->open($saveFile); $zip->extractTo($updateDir); $zip->close(); // Prepare files $updateVersionDir = $updateDir . '/magento_debugger_backend-version-' . $version; $dirResource = opendir($updateVersionDir); while ($item = readdir($dirResource)) { if ($item == '.' || $item == '..') { continue; } if (in_array($item, self::$_excludeUpdateFiles)) { MagentoDebugger::removeDirectory($updateVersionDir . '/' . $item); } } // Update self::updateFiles($updateVersionDir, $updatePath, true); return true; }
public function savePost() { if (!$_POST) { return; } $identifier = null; $projectDirectory = null; if (isset($_POST['project_identifier'])) { $identifier = $this->_postIdentifier = $this->_stripData($_POST['project_identifier']); } if (isset($_POST['project_directory'])) { $projectDirectory = $this->_postProjectDirectory = $this->_stripData(MagentoDebugger::getPath($_POST['project_directory'])); } if (!$this->verifyMagentoDirectory($projectDirectory)) { array_push($this->_errors, 'Please enter a right magento project directory.'); return; } $dataToSave = "[config]\n"; $dataToSave .= "name = '" . $_SERVER['SERVER_NAME'] . "'\n"; $dataToSave .= "dir = '" . $projectDirectory . "'\n"; $configDir = MagentoDebugger::getDebuggerDir() . '/config'; $varDir = MagentoDebugger::getDebuggerDir() . '/var'; $allowed = true; if (!MagentoDebugger::isWritable($varDir)) { array_push($this->_errors, 'Please make "var" dir at the Magento Debugger and all files on it writable ("' . $varDir . '").'); $allowed = false; } if (!MagentoDebugger::isWritable($configDir)) { array_push($this->_errors, 'Please make "config" dir at the Magento Debugger and all files on it writable ("' . $configDir . '").'); $allowed = false; } if ($allowed && @file_put_contents($configDir . '/' . $identifier . '.ini', $dataToSave)) { array_push($this->_messages, 'Host sucefully configured.'); } elseif ($allowed) { array_push($this->_errors, 'Please check the dir "config" on the Magento Debugger. The file ' . $configDir . '/' . $identifier . '.ini can not be written.'); } }
if ($_GET['magento_debug'] == 'message' && isset($_POST['message'])) { $file = MagentoDebugger::getDebuggerVarDir() . '/ajax-console.log'; file_put_contents($file, $_POST['message'] . "\n", FILE_APPEND); return; } if ($_GET['magento_debug'] == 'model' && isset($_GET['magento_debug_model_method'])) { $modelMethodName = $_GET['magento_debug_model_method']; header('Content-Type: text/plain'); require_once MagentoDebugger::getDebuggerDir() . '/libs/Debugger/model.php'; } if ($_GET['magento_debug'] == 'maillist' && isset($_GET['magento_debug_action'])) { require_once MagentoDebugger::getDebuggerDir() . '/libs/Debugger/mails.php'; } if ($_GET['magento_debug'] == 'profiler' && isset($_GET['magento_debug_action'])) { require_once MagentoDebugger::getDebuggerDir() . '/libs/Debugger/profiler.php'; } if ($_GET['magento_debug'] == 'mysql' && isset($_GET['magento_debug_action'])) { require_once MagentoDebugger::getDebuggerDir() . '/libs/Debugger/mysql.php'; } return; } // Profiler if (isset($_COOKIE['magento_debug_profiler']) && $_COOKIE['magento_debug_profiler'] == 'yes') { MagentoDebugger::enableProfiler(); } //$_SERVER['MAGE_IS_DEVELOPER_MODE'] = true; //ini_set('display_errors', 1); chdir(MagentoDebugger::getProjectDir()); require_once 'index.php'; MagentoDebugger::saveConfiguration(); MagentoDebugger::saveProfiler();
public static function getProjectInfo() { if (self::$_projectInfo) { return self::$_projectInfo; } require_once MagentoDebugger::getDebuggerDir() . '/libs/Zend/Exception.php'; require_once MagentoDebugger::getDebuggerDir() . '/libs/Zend/Config/Exception.php'; require_once MagentoDebugger::getDebuggerDir() . '/libs/Zend/Config.php'; require_once MagentoDebugger::getDebuggerDir() . '/libs/Zend/Config/Ini.php'; $currentHost = null; $currentHostName = $_SERVER['SERVER_NAME']; $dir = opendir(self::getDebuggerDir() . '/config'); while ($file = readdir($dir)) { if (!is_file(self::getDebuggerDir() . '/config/' . $file)) { continue; } $fileInfo = pathinfo($file); if (!isset($fileInfo['extension']) || $fileInfo['extension'] != 'ini') { continue; } $config = new Zend_Config_Ini(self::getDebuggerDir() . '/config/' . $file, 'config'); if ($config->name == $currentHostName) { $currentHost = $config->toArray(); $currentHost['identifier'] = $fileInfo['filename']; break; } } if (!$currentHost) { return; } // Append data if (is_file(MagentoDebugger::getDebuggerDir() . '/var/' . $currentHost['identifier'] . '.project.json')) { $extended = file_get_contents(MagentoDebugger::getDebuggerDir() . '/var/' . $currentHost['identifier'] . '.project.json'); $currentHost['extended'] = (array) json_decode($extended); } MagentoDebugger::setProjectDir($currentHost['dir']); self::$_projectInfo = $currentHost; return $currentHost; }
<?php require_once dirname(__FILE__) . '/libs/Debugger/debugger.php'; MagentoDebugger::setDebuggerDir(dirname(__FILE__)); if (!isset($argv[1])) { return; } $version = $argv[1]; require_once MagentoDebugger::getDebuggerDir() . '/libs/Debugger/update.php'; try { MagentoDebugger_Update::run($version); } catch (Exception $e) { echo "Error while updating: " . $e->getMessage . "\n"; }