开源 企业版 高校版 私有云 模力方舟 AI 队友
代码拉取完成,页面将自动刷新
捐赠
捐赠前请先登录
扫描微信二维码支付
取消
支付完成
支付提示
将跳转至支付宝完成支付
确定
取消
1 Star 0 Fork 3

小程序开发/PHPCMS V10 修改版

加入 Gitee
与超过 1400万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
已有帐号? 立即登录
文件
master
分支 (1)
master
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
项目仓库所选许可证以仓库主分支所使用许可证为准
master
分支 (1)
master
克隆/下载
克隆/下载
提示
下载代码请复制以下命令到终端执行
为确保你提交的代码身份被 Gitee 正确识别,请执行以下命令完成配置
初次使用 SSH 协议进行代码克隆、推送等操作时,需按下述提示完成 SSH 配置
1 生成 RSA 密钥
2 获取 RSA 公钥内容,并配置到 SSH公钥
在 Gitee 上使用 SVN,请访问 使用指南
使用 HTTPS 协议时,命令行会出现如下账号密码验证步骤。基于安全考虑,Gitee 建议 配置并使用私人令牌 替代登录密码进行克隆、推送等操作
Username for 'https://gitee.com': userName
Password for 'https://userName@gitee.com': # 私人令牌
master
分支 (1)
master
phpcms
/
cms
/
modules
/
admin
/
cloud.php
phpcms
/
cms
/
modules
/
admin
/
cloud.php
cloud.php 17.22 KB
一键复制 编辑 原始数据 按行查看 历史
找寻知音 提交于 2024年10月02日 18:00 +08:00 . 初始化仓库
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474
<?php
defined('IN_CMS') or exit('No permission resources.');
pc_base::load_app_class('admin','admin',0);
pc_base::load_sys_class('form','',0);
// 云服务
class cloud extends admin {
private $input,$cache,$config,$db,$menu_db,$cloud;
private $admin_url;
private $service_url;
function __construct() {
parent::__construct();
$this->input = pc_base::load_sys_class('input');
$this->cache = pc_base::load_sys_class('cache');
$this->config = pc_base::load_sys_class('config');
$this->db = pc_base::load_model('site_model');
$this->menu_db = pc_base::load_model('menu_model');
// 不是超级管理员
if (!cleck_admin(param::get_session('roleid'))) {
dr_admin_msg(0,L('需要超级管理员账号操作'));
}
define('CMS_VERSION', pc_base::load_config('version','cms_version'));
define('CMS_RELEASE', pc_base::load_config('version','cms_release'));
define('CMS_ID', pc_base::load_config('license','cms_id'));
define('CMS_LICENSE', pc_base::load_config('license','cms_license') ? pc_base::load_config('license','cms_license') : 'dev');
define('CMS_UPDATETIME', pc_base::load_config('version','cms_updatetime'));
define('CMS_DOWNTIME', pc_base::load_config('version','cms_downtime'));
$this->cloud = CACHE_PATH.'cloud/';
create_folder($this->cloud);
list($this->admin_url) = explode('?', FC_NOW_URL);
$this->service_url = 'http://ceshi.kaixin100.cn/index.php?m=cloud&c=index&a=cloud&domain='.dr_get_domain_name(ROOT_URL).'&admin='.urlencode($this->admin_url).'&version='.CMS_VERSION.'&cms='.CMS_ID.'&license='.CMS_LICENSE.'&updatetime='.strtotime(CMS_UPDATETIME).'&downtime='.strtotime(CMS_DOWNTIME).'&sitename='.base64_encode(dr_site_info('name', 1)).'&siteurl='.urlencode(dr_site_info('domain', 1)).'&php='.PHP_VERSION.'&mysql='.$this->db->version().'&os='.PHP_OS;
}
// 我的网站
public function init() {
$show_header = true;
include $this->admin_tpl('cloud_index');exit;
}
// 常用配置
public function config() {
$show_header = true;
include $this->admin_tpl('cloud_config');exit;
}
// 程序升级
public function upgrade() {
$show_header = true;
if (CMS_LICENSE == 'dev') {
include $this->admin_tpl('cloud_login');exit;
}
$backup = str_replace('\\', '/', $this->_is_backup_file(CACHE_PATH.'bakup/update/cms/'));
include $this->admin_tpl('cloud_update');exit;
}
// 验证授权
public function login() {
$show_header = true;
if (IS_POST) {
$post = $this->input->post('data');
$surl = $this->service_url.'&action=update_login&username='.$post['username'].'&password='.md5($post['password']);
$json = dr_catcher_data($surl);
if (!$json) {
dr_json(0, '本站:没有从服务端获取到数据,建议尝试离线方式');
}
$rt = dr_string2array($json);
if (!$rt) {
dr_json(0, '本站:从服务端获取到的数据不规范');
}
if (!$rt['code']) {
dr_json(0, '服务端:'.$rt['msg']);
}
if (dr_strlen($rt['data']) > 8) {
$myfile = CONFIGPATH.'license.php';
if (is_file($myfile)) {
// 存在就更新id
if ($rt['data'] != CMS_LICENSE) {
$text = array('cms_id' => ''.$rt['id'].'','cms_license' => ''.$rt['data'].'','cms_name' => 'CMS','cms_url' => 'https://gitee.com/zhaoxunzhiyin/phpcms');
$this->config->file($myfile, '此文件是安装授权文件,每次下载安装包会自动生成,请勿修改', 32)->to_require($text);
}
} else {
$text = array('cms_id' => ''.$rt['id'].'','cms_license' => ''.$rt['data'].'','cms_name' => 'CMS','cms_url' => 'https://gitee.com/zhaoxunzhiyin/phpcms');
$this->config->file($myfile, '此文件是安装授权文件,每次下载安装包会自动生成,请勿修改', 32)->to_require($text);
}
if (!is_file($myfile)) {
dr_json(0, '本站:'.str_replace(CMS_PATH, '', $myfile).'目录无法写入文件,请给于777权限');
}
}
dr_json(1, $rt['msg'], $rt['data']);
}
include $this->admin_tpl('cloud_login_ajax');exit;
}
// 下载程序
function down_file() {
$show_header = true;
$ls = intval($this->input->get('ls'));
include $this->admin_tpl('cloud_down_file');exit;
}
// 判断备份目录是否有效
private function _is_backup_file($path) {
if (is_dir($path)) {
if ($dh = opendir($path)) {
while (($file = readdir($dh)) !== false) {
if (strpos($file, '.zip') !== false){
closedir($dh);
return $path;
}
}
closedir($dh);
}
}
return '';
}
// 检查服务器版本
public function check_version() {
$cid = dr_safe_replace($this->input->get('id'));
if ($cid == 'cms') {
// 目录权限检查
$dir = [
CACHE_PATH,
PC_PATH,
CMS_PATH,
];
foreach ($dir as $t) {
if (!dr_check_put_path($t)) {
dr_json(0, L('目录【'.$t.'】不可写'));
}
}
}
$vid = dr_safe_replace($this->input->get('version'));
$surl = $this->service_url.'&action=check_version&id='.$cid.'&version='.$vid;
$json = dr_catcher_data($surl);
if (!$json) {
dr_json(0, '本站:没有从服务端获取到数据');
}
$rt = json_decode($json, true);
dr_json($rt['code'], $rt['msg']);
}
// 执行更新程序的界面
public function todo_update() {
$show_header = true;
$ls = dr_safe_replace($this->input->get('ls'));
$dir = dr_safe_replace($this->input->get('dir'));
$is_bf = intval($this->input->get('is_bf'));
include $this->admin_tpl('cloud_todo_update');exit;
}
// 备份本站文件
public function update_backup() {
$dir = dr_safe_filename($this->input->get('dir'));
if (!$dir) {
dr_json(0, '本站:没有选择任何升级程序');
}
$is_bf = intval($this->input->get('is_bf'));
if ($is_bf) {
dr_json(1, '你选择不备份直接升级程序');
}
if ($dir == 'cms') {
// 主程序备份
$rt = pc_base::load_sys_class('file')->zip(
CACHE_PATH.'bakup/update/cms/'.date('Y-m-d-H-i-s').'.zip',
PC_PATH,
[TPLPATH]
);
}
if ($rt) {
dr_json(0, '本站:文件备份失败('.$rt.')');
}
// 备份api
pc_base::load_sys_class('file')->zip(
CACHE_PATH.'bakup/update/api/'.date('Y-m-d-H-i-s').'.zip',
CMS_PATH.'api'
);
// 备份模板
pc_base::load_sys_class('file')->zip(
CACHE_PATH.'bakup/update/template/'.date('Y-m-d-H-i-s').'.zip',
TPLPATH
);
dr_json(1, 'ok');
}
// 服务器下载升级文件
public function update_file() {
$id = dr_safe_replace($this->input->get('id'));
if (!$id) {
dr_json(0, '本站:没有选择任何升级程序');
}
$surl = $this->service_url.'&action=update_file&ls='.dr_safe_replace($this->input->get('ls'));
$json = dr_catcher_data($surl);
if (!$json) {
dr_json(0, '本站:没有从服务端获取到数据,建议尝试离线方式', $surl);
}
$data = dr_string2array($json);
if (!$data) {
CI_DEBUG && log_message('error', '服务端['.$surl.']返回数据异常:'.$json);
dr_json(0, '本站:服务端数据异常,请重新下载', $json);
} elseif (!$data['code']) {
dr_json(0, $data['msg']);
} elseif (!$data['data']['size']) {
dr_json(0, '本站:服务端文件总大小异常');
} elseif (!$data['data']['url']) {
dr_json(0, '本站:服务端文件下载地址异常');
}
$this->cache->set_data('cloud-update-'.$id, $data['data'], 3600);
dr_json(1, 'ok', $data['data']);
}
// 开始下载脚本
public function update_file_down() {
$id = dr_safe_replace($this->input->get('id'));
$cache = $this->cache->get_data('cloud-update-'.$id);
if (!$cache) {
dr_json(0, '本站:授权验证缓存过期,请重试');
} elseif (!$cache['size']) {
dr_json(0, '本站:关键数据不存在,请重试');
} elseif (!function_exists('fsockopen')) {
dr_json(0, '本站:PHP环境不支持fsockopen,建议尝试离线方式');
}
// 执行下载文件
$file = $this->cloud.$id.'.zip';
set_time_limit(0);
touch($file);
// 做些日志处理
if ($fp = fopen($cache['url'], "rb")) {
if (!$download_fp = fopen($file, "wb")) {
dr_json(0, '本站:无法写入远程文件', $cache['url']);
}
while (!feof($fp)) {
if (!is_file($file)) {
// 如果临时文件被删除就取消下载
fclose($download_fp);
dr_json(0, '本站:临时文件被删除', $cache['url']);
}
fwrite($download_fp, fread($fp, 1024 * 8 ), 1024 * 8);
}
fclose($download_fp);
fclose($fp);
dr_json(1, 'ok');
} else {
unlink($file);
dr_json(0, '本站:fopen打开远程文件失败,建议尝试离线方式', $cache['url']);
}
}
// 检测下载进度
public function update_file_check() {
$id = dr_safe_replace($this->input->get('id'));
$cache = $this->cache->get_data('cloud-update-'.$id);
if (!$cache) {
dr_json(0, '本站:授权验证缓存过期,请重试');
} elseif (!$cache['size']) {
dr_json(0, '本站:关键数据不存在,请重试');
}
// 执行下载文件
$file = $this->cloud.$id.'.zip';
if (is_file($file)) {
$now = max(1, filesize($file));
$jd = max(1, round($now / $cache['size'] * 100, 0)); // 进度百分百
$count = $this->input->get('is_count') ? intval($this->input->get('is_count')) : 0; // 表示请求次数
if (($count > 3 && $jd > 98) || ($this->input->get('is_jd') && $this->input->get('is_jd') == $jd)) {
$jd = 100;
}
dr_json($jd, '<p><label class="rleft">需下载文件大小:'.format_file_size($cache['size']).',已下载:'.format_file_size($now).'</label><label class="rright"><span class="ok">'.$jd.'%</span></label></p>');
} else {
dr_json(0, '本站:文件下载失败,建议尝试离线方式');
}
}
// 升级程序
public function update_file_install() {
$id = dr_safe_replace($this->input->get('id'));
$cache = $this->cache->get_data('cloud-update-'.$id);
if (!$cache) {
dr_json(0, '本站:授权验证缓存过期,请重试');
}
$file = $this->cloud.$id.'.zip';
if (!is_file($file)) {
dr_json(0, '本站:文件还没有被下载');
} elseif (!class_exists('ZipArchive')) {
dr_json(0, '本站:php_zip扩展未开启,无法在线安装功能,建议尝试离线方式');
}
// 解压目录
$cmspath = $this->cloud.$id.'/';
if (!pc_base::load_sys_class('file')->unzip($file, $cmspath)) {
dr_json(0, '本站:文件解压失败');
}
unlink($file);
// cms
// api目录
if (is_dir($cmspath.'api')) {
$this->_copy_dir($cmspath.'api', CMS_PATH.'api');
dr_dir_delete($cmspath.'api', 1);
}
// 缓存目录
if (is_dir($cmspath.'caches')) {
$this->_copy_dir($cmspath.'caches', CACHE_PATH);
dr_dir_delete($cmspath.'caches', 1);
}
// CMS框架目录
if (is_dir($cmspath.'cms')) {
$this->_copy_dir($cmspath.'cms', PC_PATH);
dr_dir_delete($cmspath.'cms', 1);
}
// 模板目录
if (is_dir($cmspath.'templates')) {
$this->_copy_dir($cmspath.'templates', TPLPATH);
dr_dir_delete($cmspath.'templates', 1);
}
// statics目录
if (is_dir($cmspath.'statics')) {
$this->_copy_dir($cmspath.'statics', CMS_PATH.'statics');
dr_dir_delete($cmspath.'statics', 1);
}
$this->_copy_dir($cmspath, CMS_PATH);
dr_dir_delete($cmspath, 1);
// 完成
$this->cache->clear('cloud-update-'.$id);
dr_json(1, '<p><label class="rleft">升级完成</label><label class="rright"><span class="ok">完成</span></label></p>');
}
// 文件对比
public function compare() {
$show_header = true;
include $this->admin_tpl('cloud_bf');exit;
}
public function bf_count() {
$surl = $this->service_url.'&action=bf_count';
$json = dr_catcher_data($surl);
if (!$json) {
dr_json(0, '本站:没有从服务端获取到数据');
}
$data = dr_string2array($json);
if (!$data) {
CI_DEBUG && log_message('error', '云端返回数据异常:'.$json);
dr_json(0, '本站:服务端数据异常,请重新再试');
} elseif (!$data['code']) {
dr_json(0, $data['msg']);
}
$this->cache->set_data('cloud-bf', $data['data'], 3600);
dr_json(dr_count($data['data']), $data['msg']);
}
public function bf_check() {
$page = max(1, intval($this->input->get('page')));
$cache = $this->cache->get_data('cloud-bf');
if (!$cache) {
dr_json(0, '本站:数据缓存不存在');
}
$data = $cache[$page];
if ($data) {
$html = '';
foreach ($data as $filename => $value) {
if (strpos($filename, '/cms') === 0) {
$cname = 'PC_PATH'.substr($filename, 4);
$ofile = PC_PATH.substr($filename, 5);
} else {
$cname = 'CMS_PATH'.$filename;
$ofile = CMS_PATH.substr($filename, 1);
}
$class = '';
if (!is_file($ofile)) {
$ok = "<span class='error'>不存在</span>";
$class = 'p_error';
} elseif (md5_file($ofile) != $value) {
$ok = "<span class='error'>有变化</span>";
$class = 'p_error';
} else {
$ok = "<span class='ok'>正常</span>";
}
$html.= '<p class="'.$class.'"><label class="rleft">'.$cname.'</label><label class="rright">'.$ok.'</label></p>';
if ($class) {
$html.= '<p class="rbf" style="display: none"><label class="rleft">'.(CI_DEBUG ? $ofile : $cname).'</label><label class="rright">'.$ok.'</label></p>';
}
}
dr_json($page + 1, $html);
}
// 完成
$this->cache->clear('cloud-bf');
dr_json(100, '');
}
// 复制目录
private function _copy_dir($src, $dst) {
$dir = opendir($src);
if (!is_dir($dst)) {
@mkdir($dst);
}
$src = rtrim($src, '/');
$dst = rtrim($dst, '/');
while(false !== ( $file = readdir($dir)) ) {
if (( $file != '.' ) && ( $file != '..' )) {
if (is_dir($src . '/' . $file) ) {
create_folder($dst . '/' . $file);
$this->_copy_dir($src . '/' . $file, $dst . '/' . $file);
continue;
} else {
create_folder(dirname($dst . '/' . $file));
$rt = copy($src . '/' . $file, $dst . '/' . $file);
if (!$rt) {
// 验证目标是不是空文件
if (filesize($src . '/' . $file) > 1) {
$this->_error_msg($dst . '/' . $file, '移动失败,检查文件目录权限');
}
}
}
}
}
closedir($dir);
}
// 版本日志
function log_show() {
$url = $this->service_url.'&action=log_show&id='.$this->input->get('id', true).'&version='.$this->input->get('version', true);
include $this->admin_tpl('cloud_online');exit;
}
// 错误进度
private function _error_msg($filename, $msg) {
$html = '<p class=" p_error"><label class="rleft">'.$filename.'</label><label class="rright">'.$msg.'</label></p>';
dr_json(0, $html);
}
}
Loading...
举报
举报成功
我们将于2个工作日内通过站内信反馈结果给你!
请认真填写举报原因,尽可能描述详细。
请选择举报类型
取消
发送
误判申诉

此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。

如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。

取消
提交

简介

PHPCMS V10 修改版 QQ、微信:297885395 QQ讨论群:551419699
取消

发行版

暂无发行版

贡献者

全部

近期动态

不能加载更多了
编辑仓库简介
简介内容
主页
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
PHP
1
https://gitee.com/exphp/phpcms.git
git@gitee.com:exphp/phpcms.git
exphp
phpcms
PHPCMS V10 修改版
master
点此查找更多帮助

搜索帮助

评论
仓库举报
回到顶部
登录提示
该操作需登录 Gitee 帐号,请先登录后再操作。
立即登录
没有帐号,去注册

AltStyle によって変換されたページ (->オリジナル) /