Products
GG网络技术分享 2025-03-18 16:12 3
I have created a project with Codeigniter. I want to add a system that can update my project like as Wordpress. Example: Suppose I run Project V.1.0 but when I want to realize V2.0 my client may update my project files via upload zip.
I want this system like as Wordpress. And I don\'t what to use git. Because I have some client. and I want that they download or collect zip file that contains update version\'s file. And they upload this zip to the server via Codeigniter project and project will update automatically to v2.0图片转代码服务由CSDN问答提供
感谢您的意见,我们尽快改进~
功能建议我用Codeigniter创建了一个项目。 我想添加一个可以像Wordpress一样更新我的项目的系统。 示例:假设我运行Project V.1.0但是当我想要实现V2.0时,我的客户端可以通过上传zip更新我的项目文件。
我希望这个系统像Wordpress一样。 而且我不知道如何使用git。 因为我有一些客户。 我希望他们下载或收集包含更新版本文件的zip文件。 他们通过Codeigniter项目将此zip文件上传到服务器,项目将自动更新到v2.0 </ p>
</ div>
As your question is rather broad I will give you a rather broad response; normally I wouldn\'t even answer these types of questions but I just so happen to have a relevant script I made a while back.
This is NOT plug and play and has some third-party dependencies from CakePHP that needs to be autoloaded.
The script creates an image of all the specified folders in an array adds a manifest of files and an identifier file e.g. VERSION 2. The image (zip file) can then be uploaded to a site running VERSION 1 as long as it has the same update model. Once uploaded, the model then extracts the files as long as the zip has a valid identifier file in it (to prevent users from uploading an unrelated zip and nuking the system); the script also creates a current image of the site (at VERSION 1) just in case restoration is necessary.
The script also has a restore previous version function that will remove any additional files that were in version 2 and not 1 and will restore the original files of 1.
I offer no support for this. But hopefully you find it a bit helpful - it\'s sort of hacked together but in my limited testing it worked fine.
Controller:
<?phpif (!defined(\'BASEPATH\')) {
exit(\'No direct script access allowed\');
}
/**
*
* NEOU CMS v4 CI Edition
* @copyright (c) 2018, Alexander Fagard
* @requires PHP version >= 5.6
*
* You cannot redistribute this document without written permission from the author
*
*/
class Update extends MY_Backend {
static $perm = [\'admin_only\' => true];
public function __construct() {
parent::__construct();
$this->lang->load(\'core_update\');
$this->load->model(\'backend/core_update_model\', \'update\');
}
public function index() {
$this->tpl->head($this->lang->line(\'update_heading\'));
$this->tpl->body();
$this->output->append_output($this->messages->display());
$data = array(
\'is_local\' => $this->localization->is_local(),
\'previous_exist\' => $this->update->previous_exists()
);
$this->parser->parse(\'backend/core_update\', $data);
$this->tpl->footer();
}
public function restore() {
try {
$this->update->restore_previous();
rmdir_recursive($this->update->updates_folder);
$this->messages->success($this->lang->line(\'update_previous_restored\'));
} catch (Exception $e) {
$this->messages->error($e->getMessage());
} finally {
redirect(CMS_DIR_NAME . \'/update\');
}
}
public function apply() {
$this->load->helper(\'byte_helper\');
try {
$this->update->mk_update_dir();
$config[\'upload_path\'] = $this->update->updates_folder;
$config[\'overwrite\'] = true;
$config[\'allowed_types\'] = \'zip\';
$config[\'max_size\'] = convert_bytes_to_type(file_upload_max_size(), \'KB\');
$config[\'file_ext_tolower\'] = true;
$this->load->library(\'upload\', $config);
if (!$this->upload->do_upload(\'update\')) {
throw new Exception($this->upload->display_errors(\'\', \'\'));
}
$data = $this->upload->data();
$this->update->apply_update($data[\'full_path\']);
$this->messages->success($this->lang->line(\'update_applied\'));
} catch (Exception $e) {
$this->messages->error($e->getMessage());
} finally {
redirect(CMS_DIR_NAME . \'/update\');
}
}
public function create() {
if (!$this->localization->is_local()) {
show_error($this->lang->line(\'update_localhost\'), 500);
}
try {
$this->update->create_update();
$this->messages->success(sprintf($this->lang->line(\'update_created\'), $this->update->files_processed));
} catch (Exception $e) {
$this->messages->error($e->getMessage());
} finally {
redirect(CMS_DIR_NAME . \'/update\');
}
}
}
###
Upload zip, extract and replace all files.
Keep the zip structure the same of project.Something like this:
update.zip
./root/application/controllers/*.*./root/application/views/*.*
...
This only will be possible if the user running apache/nginx has enough privileges on file system.
Demand feedback