| @@ 109-117 (lines=9) @@ | ||
| 106 | $zipArchive = new \ZipArchive(); |
|
| 107 | $zipArchive->open($tmpPath); |
|
| 108 | ||
| 109 | if (!$zipArchive->extractTo($this->_tmp)) { |
|
| 110 | $zipArchive->close(); |
|
| 111 | FileHelper::removeDirectory($this->_tmp); |
|
| 112 | ||
| 113 | return $this->render('create', [ |
|
| 114 | 'model' => $model, |
|
| 115 | 'error' => [Yii::t('writesdown', 'Failed to extract file.')], |
|
| 116 | ]); |
|
| 117 | } |
|
| 118 | ||
| 119 | $baseDir = substr($zipArchive->getNameIndex(0), 0, strpos($zipArchive->getNameIndex(0), '/')); |
|
| 120 | $zipArchive->close(); |
|
| @@ 124-131 (lines=8) @@ | ||
| 121 | unlink($tmpPath); |
|
| 122 | $configPath = $this->_tmp . $baseDir . '/config/main.php'; |
|
| 123 | ||
| 124 | if (!is_file($configPath)) { |
|
| 125 | FileHelper::removeDirectory($this->_tmp); |
|
| 126 | ||
| 127 | return $this->render('create', [ |
|
| 128 | 'model' => $model, |
|
| 129 | 'error' => [Yii::t('writesdown', 'File configuration does not exist.')], |
|
| 130 | ]); |
|
| 131 | } |
|
| 132 | ||
| 133 | $config = require($configPath); |
|
| 134 | $model->setAttributes($config); |
|
| @@ 152-160 (lines=9) @@ | ||
| 149 | $zipArchive = new \ZipArchive(); |
|
| 150 | $zipArchive->open($tmpPath); |
|
| 151 | ||
| 152 | if (!$zipArchive->extractTo($this->_tmp)) { |
|
| 153 | $zipArchive->close(); |
|
| 154 | FileHelper::removeDirectory($this->_tmp); |
|
| 155 | ||
| 156 | return $this->render('create', [ |
|
| 157 | 'model' => $model, |
|
| 158 | 'errors' => [Yii::t('writesdown', 'Failed to extract file.')], |
|
| 159 | ]); |
|
| 160 | } |
|
| 161 | ||
| 162 | $baseDir = substr($zipArchive->getNameIndex(0), 0, strpos($zipArchive->getNameIndex(0), '/')); |
|
| 163 | $zipArchive->close(); |
|
| @@ 166-173 (lines=8) @@ | ||
| 163 | $zipArchive->close(); |
|
| 164 | $configPath = $this->_tmp . $baseDir . '/config/main.php'; |
|
| 165 | ||
| 166 | if (!is_file($configPath)) { |
|
| 167 | FileHelper::removeDirectory($this->_tmp); |
|
| 168 | ||
| 169 | return $this->render('create', [ |
|
| 170 | 'model' => $model, |
|
| 171 | 'errors' => [Yii::t('writesdown', 'File configuration does not exist.')], |
|
| 172 | ]); |
|
| 173 | } |
|
| 174 | ||
| 175 | $config = require($configPath); |
|
| 176 | ||
| @@ 147-155 (lines=9) @@ | ||
| 144 | $zipArchive = new \ZipArchive(); |
|
| 145 | $zipArchive->open($themeTempPath); |
|
| 146 | ||
| 147 | if (!$zipArchive->extractTo($this->_tmp)) { |
|
| 148 | $zipArchive->close(); |
|
| 149 | FileHelper::removeDirectory($this->_tmp); |
|
| 150 | ||
| 151 | return $this->render('upload', [ |
|
| 152 | 'model' => $model, |
|
| 153 | 'errors' => [Yii::t('writesdown', 'Failed to extract file.')], |
|
| 154 | ]); |
|
| 155 | } |
|
| 156 | ||
| 157 | $baseDir = substr($zipArchive->getNameIndex(0), 0, strpos($zipArchive->getNameIndex(0), '/')); |
|
| 158 | $zipArchive->close(); |
|