public static function installRemotePlugin($pluginName) { $result = false; if ($pluginName) { $downloadPath = self::_composePath(array(IA_HOME, 'tmp', 'plugins')); if (!is_dir($downloadPath)) { mkdir($downloadPath); } $savePath = $downloadPath . $pluginName . '.plugin'; if (!self::getRemoteContent(sprintf(self::PLUGINS_DOWNLOAD_SOURCE, $pluginName, IA_VERSION), $savePath)) { return false; } if (is_file($savePath)) { $extrasFolder = self::_composePath(array(IA_HOME, 'plugins')); if (is_writable($extrasFolder)) { $pluginFolder = self::_composePath(array($extrasFolder, $pluginName)); if (is_dir($pluginFolder)) { self::cleanUpDirectoryContents($pluginFolder); } else { mkdir($pluginFolder); } require_once self::_composePath(array(IA_HOME, 'includes', 'utils')) . 'pclzip.lib.php'; $zipSource = new PclZip($savePath); if ($zipSource->extract(PCLZIP_OPT_PATH, $extrasFolder . $pluginName)) { $installationFile = file_get_contents($pluginFolder . self::INSTALLATION_FILE_NAME); if ($installationFile !== false) { $iaExtra = self::loadCoreClass('extra'); $iaExtra->setXml($installationFile); $iaExtra->parse(); if (!$iaExtra->getNotes()) { $result = $iaExtra->install(); } } } } iaHelper::cleanUpDirectoryContents(IA_HOME . 'tmp' . IA_DS); } } return $result; }
} $testResult = $testResult ? '' : "session_save_path('" . IA_HOME . "tmp');"; $config = str_replace('{sessionpath}', $testResult, $config); // if (is_writable(IA_HOME . 'includes' . IA_DS) || is_writable($filename)) { if (!($handle = fopen($filename, 'w+'))) { $configMsg = 'Cannot open file: ' . $filename; } if (fwrite($handle, $config) === false) { $configMsg = 'Cannot write to file: ' . $filename; } fclose($handle); } else { $configMsg = 'Cannot write to folder.'; } iaHelper::cleanUpDirectoryContents(IA_HOME . 'tmp' . IA_DS); if (!$error) { $step = 'finish'; $iaOutput->step = 'finish'; } $iaOutput->config = $config; $iaOutput->description = $configMsg; } if (!$error) { defined('IA_SALT') || define('IA_SALT', $salt); $iaUsers = iaHelper::loadCoreClass('users', 'core'); $iaUsers->changePassword(array('id' => 1), iaHelper::getPost('admin_password'), false); iaHelper::cleanUpCacheContents(); $iaTemplate->install(iaTemplate::SETUP_INITIAL); // writing it to the system log $iaLog = iaHelper::loadCoreClass('log', 'core');
if ($fh = fopen(IA_HOME . 'uploads' . IA_DS . $logFile, 'wt')) { fwrite($fh, $textLog); fclose($fh); } // log this event $iaLog = iaHelper::loadCoreClass('log', 'core'); $iaLog->write(iaLog::ACTION_UPGRADE, array('type' => 'app', 'from' => IA_VERSION, 'to' => $_SESSION['upgrade_to'], 'file' => $logFile)); // // processing the upgrade log to show nicely $textLog = htmlspecialchars($textLog); $textLog = str_replace(array(PHP_EOL, 'INFO', 'SUCCESS', 'ERROR', 'ALERT'), array('', '<p>', '<p><span class="label label-success">SUCCESS</span>', '<p><span class="label label-danger">ERROR</span>', '<p><span class="label label-warning">ALERT</span>'), $textLog); // $iaOutput->log = $textLog; // clean up cache files $tempFolder = IA_HOME . 'tmp' . IA_DS; iaHelper::cleanUpDirectoryContents($tempFolder); unset($_SESSION['upgrade_to']); } catch (Exception $e) { @unlink(IA_HOME . 'tmp' . IA_DS . 'patch.iap'); $iaOutput->message = $e->getMessage(); } break; case 'rollback': $iaOutput->steps = array('check' => 'Upgrade Wizard', 'rollback' => 'Rollback'); $fileList = glob(IA_HOME . 'backup/backup_*_*.zip'); $backups = array(); if ($fileList) { foreach ($fileList as $fileName) { $fileName = basename($fileName); $array = explode('_', $fileName); if (3 == count($array)) {