清除补丁升级系统

This commit is contained in:
Comsenz 2017-07-08 16:33:10 +08:00
parent d2555bd8c5
commit f5e19668ae
10 changed files with 3 additions and 1099 deletions

View File

@ -243,7 +243,6 @@ if($isfounder) {
$menu['founder'] = array(
array('menu_founder_perm', 'founder_perm'),
array('menu_setting_mail', 'setting_mail'),
array('menu_patch', 'patch'),
array('menu_setting_uc', 'setting_uc'),
array('menu_db', 'db_export'),
array('menu_membersplit', 'membersplit_check'),

View File

@ -1,160 +0,0 @@
<?php
/**
* [Discuz!] (C)2001-2099 Comsenz Inc.
* This is NOT a freeware, use is subject to license terms
*
* $Id: admincp_patch.php 29258 2012-03-31 03:56:17Z zhengqingpeng $
*/
if(!defined('IN_DISCUZ') || !defined('IN_ADMINCP')) {
exit('Access Denied');
}
cpheader();
$operation = in_array($operation , array('patchsetting', 'fixpatch', 'checkpatch', 'recheckpatch')) ? $operation : 'checkpatch';
$discuz_patch = new discuz_patch();
if($operation == 'patchsetting') {
$save_master = C::t('common_setting')->fetch_all(array('mastermobile', 'masterqq', 'masteremail'));
$save_mastermobile = $save_master['mastermobile'];
$save_mastermobile = !empty($save_mastermobile) ? authcode($save_mastermobile, 'DECODE', $_G['config']['security']['authkey']) : '';
if(!submitcheck('settingsubmit')) {
$view_mastermobile = !empty($save_mastermobile) ? substr($save_mastermobile, 0 , 3).'*****'.substr($save_mastermobile, -3) : '';
shownav('founder', 'nav_founder_patch');
showsubmenu('nav_founder_patch', array(
array('founder_patch_list', 'patch&operation=fixpatch', 0),
array('founder_patch_updatesetting', 'patch&operation=patchsetting', 1),
));
showformheader('patch&operation=patchsetting');
showtableheader();
showsetting('founder_patch_autoupdate', 'settingnew[patch][autoopened]', $_G['setting']['patch']['autoopened'], 'radio');
showsubmit('settingsubmit', 'submit');
showtablefooter();
showformfooter();
} else {
$settings = array();
$settingnew = $_POST['settingnew'];
if($settingnew) {
if(!$discuz_patch->save_patch_setting($settingnew)) {
cpmsg('patch_no_privilege_autoupdate', '', 'error');
}
}
cpmsg('patch_updatesetting_successful', 'action=patch&operation='.$operation, 'succeed');
}
} elseif($operation == 'fixpatch') {
if(!submitcheck('fixpatchsubmit', 1)) {
shownav('founder', 'nav_founder_patch');
showsubmenu('nav_founder_patch', array(
array('founder_patch_list', 'patch&operation=fixpatch', 1),
array('founder_patch_updatesetting', 'patch&operation=patchsetting', 0),
));
showformheader('patch&operation=fixpatch');
showtableheader('', 'fixpadding', '', 5);
showtablerow('class="header"', array('class="td25"','class="td24"','', 'class="td31"', 'class="td25"'), array(
'',
$lang['founder_patch_serial'],
$lang['founder_patch_note'],
$lang['founder_patch_dateline'],
$lang['founder_patch_status'],
));
$patchlist = C::t('common_patch')->fetch_all();
foreach($patchlist as $patch) {
showtablerow($patch['status'] <= 0 ? 'title="'.$lang['founder_patchstatus_'.($patch['status'] < 0 ? 'error'.$patch['status'] : $patch['status'])].'"' : '', '', array(
'<input class="checkbox" type="checkbox" value="'.$patch['serial'].'"'.($patch['status'] >= 1 ? ' disabled' : ' name="deletefix[]" checked').'>',
$patch['serial'],
$patch['note'],
dgmdate($patch['dateline'], 'Y-m-d H:i:s'),
'<em class="'.($patch['status'] <= 0 ? 'unfixed' : 'fixed').'">&nbsp;</em>',
));
}
showsubmit('fixpatchsubmit', 'founder_patch_fix', 'select_all', ' <input type="button" class="btn" onclick="window.location.href=\''.ADMINSCRIPT.'?action=patch&operation=recheckpatch'.'\';" value="'.$lang['founder_patch_rescan'].'">');
showtablefooter();
showformfooter();
} else {
$patchlist = $_GET['deletefix'];
if(empty($patchlist)) {
cpmsg('patch_please_select_patch', '', 'error');
}
$confirm = $_GET['confirm'];
if(!$confirm) {
if($_GET['siteftpsetting']) {
$action = 'patch&operation=fixpatch&fixpatchsubmit=yes&confirm=ftp';
foreach($patchlist as $serial) {
$action .= '&deletefix[]='.$serial;
}
siteftp_form($action);
exit;
}
$flag = 0;
foreach(C::t('common_patch')->fetch_needfix_patch($patchlist) as $patch) {
if(!$discuz_patch->test_patch_writable($patch)) {
$flag = 1;
break;
}
}
if(!$flag) {
$confirm = 'file';
} else {
$linkurl = ADMINSCRIPT.'?action=patch&operation='.$operation.'&fixpatchsubmit=yes';
foreach($patchlist as $serial) {
$linkurl .= '&deletefix[]='.$serial;
}
$ftplinkurl = $linkurl.'&siteftpsetting=1';
cpmsg('patch_cannot_access_file',
'',
'',
array(),
'<br><input type="button" class="btn" onclick="window.location.href=\''.$ftplinkurl.'\'" value="'.$lang['founder_patch_set_ftpinfo'].'">'.
'&nbsp;&nbsp;&nbsp;<input type="button" class="btn" onclick="window.location.href=\''.$linkurl.'\'" value="'.$lang['founder_patch_reset'].'"><br><br>'
);
}
}
$failed = array();
if($patchlist) {
$patchlist = C::t('common_patch')->fetch_needfix_patch($patchlist);
foreach($patchlist as $patch) {
$result = $discuz_patch->fix_patch($patch, $confirm);
if($result < 0) {
$failed[] = array('serial' => $patch['serial'], 'reason' => $lang['founder_patchstatus_'.($result < 0 ? 'error'.$result : $result)]);
}
}
}
if($failed) {
$failstr = '';
foreach($failed as $v) {
$failstr .= $lang['founder_patch_fixpatch'].$v['serial'].'&nbsp;&nbsp;&nbsp;&nbsp;'.$lang['founder_patch_failedreason'].': '.$v['reason']."<br>\r\n";
}
cpmsg('patch_updatesetting_failed', 'action=patch&operation='.$operation, 'error', array('list' => $failstr));
} else {
cpmsg('patch_successful', 'action=patch&operation='.$operation, 'succeed', array(), '<script type="text/javascript">if(parent.document.getElementById(\'notice\')) parent.document.getElementById(\'notice\').style.display = \'none\';</script>');
}
}
} elseif($operation == 'checkpatch') {
if(!intval($_GET['checking'])) {
cpmsg('patch_cheking', 'action=patch&operation=checkpatch&checking=1', 'loading', '', false);
}
$discuz_patch->check_patch(1);
dheader('Location: '.ADMINSCRIPT.'?action=patch&operation=fixpatch');
} elseif($operation == 'recheckpatch') {
$discuz_patch->recheck_patch();
cpmsg('patch_successful', 'action=patch&operation=fixpatch', 'succeed');
}
?>

View File

@ -1,413 +0,0 @@
<?php
/**
* [Discuz!] (C)2001-2099 Comsenz Inc.
* This is NOT a freeware, use is subject to license terms
*
* $Id: admincp_upgrade.php 33274 2013-05-14 02:08:00Z jeffjzhang $
*/
if(!defined('IN_DISCUZ') || !defined('IN_ADMINCP')) {
exit('Access Denied');
}
@set_time_limit(0);
cpheader();
include_once 'source/discuz_version.php';
$discuz_upgrade = new discuz_upgrade();
$step = intval($_GET['step']);
$step = $step ? $step : 1;
$operation = $operation ? $operation : 'check';
if(!$_G['setting']['bbclosed'] && in_array($operation, array('cross', 'patch'))) {
cpmsg('upgrade_close_site', '', 'error');
}
if($operation == 'patch' || $operation == 'cross') {
$version = trim($_GET['version']);
$release = trim($_GET['release']);
$locale = trim($_GET['locale']);
$charset = trim($_GET['charset']);
$upgradeinfo = $upgrade_step = array();
if($_GET['ungetfrom']) {
if(md5($_GET['ungetfrom'].$_G['config']['security']['authkey']) == $_GET['ungetfrommd5']) {
$dbreturnurl = $_G['siteurl'].ADMINSCRIPT.'?action=upgrade&operation='.$operation.'&version='.$version.'&release='.$release.'&step=5';
dheader('Location: '.$_G['siteurl'].'install/update.php?step=prepare&from='.rawurlencode($dbreturnurl).'&frommd5='.rawurlencode(md5($dbreturnurl.$_G['config']['security']['authkey'])));
} else {
cpmsg('upgrade_param_error', '', 'error');
}
}
$upgrade_step = C::t('common_cache')->fetch('upgrade_step');
$upgrade_step = dunserialize($upgrade_step['cachevalue']);
$upgrade_step['step'] = $step;
$upgrade_step['operation'] = $operation;
$upgrade_step['version'] = $version;
$upgrade_step['release'] = $release;
$upgrade_step['charset'] = $charset;
$upgrade_step['locale'] = $locale;
C::t('common_cache')->insert(array(
'cachekey' => 'upgrade_step',
'cachevalue' => serialize($upgrade_step),
'dateline' => $_G['timestamp'],
), false, true);
$upgrade_run = C::t('common_cache')->fetch('upgrade_run');
if(!$upgrade_run) {
C::t('common_cache')->insert(array(
'cachekey' => 'upgrade_run',
'cachevalue' => serialize($_G['setting']['upgrade']),
'dateline' => $_G['timestamp'],
), false, true);
$upgrade_run = $_G['setting']['upgrade'];
} else {
$upgrade_run = dunserialize($upgrade_run['cachevalue']);
}
shownav('tools', 'nav_founder_upgrade');
showsubmenusteps('nav_founder_upgrade', array(
array('founder_upgrade_updatelist', $step == 1),
array('founder_upgrade_download', $step == 2),
array('founder_upgrade_compare', $step == 3),
array('founder_upgrade_upgrading', $step == 4),
array('founder_upgrade_complete', $step == 5),
));
showtableheader();
if($step != 5) {
foreach($upgrade_run as $type => $list) {
if($type == $operation && $version == $list['latestversion'] && $release == $list['latestrelease']) {
$discuz_upgrade->locale = $locale;
$discuz_upgrade->charset = $charset;
$upgradeinfo = $list;
break;
}
}
if(!$upgradeinfo) {
cpmsg('upgrade_none', '', '', array('upgradeurl' => upgradeinformation(-1)));
}
$updatefilelist = $discuz_upgrade->fetch_updatefile_list($upgradeinfo);
$updatemd5filelist = $updatefilelist['md5'];
$updatefilelist = $updatefilelist['file'];
$theurl = 'upgrade&operation='.$operation.'&version='.$version.'&locale='.$locale.'&charset='.$charset.'&release='.$release;
if(empty($updatefilelist)) {
cpmsg('upgrade_download_upgradelist_error', 'action='.$theurl, 'form', array('upgradeurl' => upgradeinformation(-2)));
}
}
if($step == 1) {
showtablerow('class="header"', '', $lang['founder_upgrade_preupdatelist']);
foreach($updatefilelist as $file) {
$file = '<em class="files bold">'.$file.'</em>';
showtablerow('', '', array($file));
}
$linkurl = ADMINSCRIPT.'?action='.$theurl.'&step=2';
showtablerow('', '', array($lang['founder_upgrade_store_directory'].'./data/update/Discuz! X'.$version.' Release['.$release.']'));
showtablerow('', '', array('<input type="button" class="btn" onclick="window.location.href=\''.$linkurl.'\'" value="'.$lang['founder_upgrade_download'].'">'));
echo upgradeinformation(0);
} elseif($step == 2) {
$fileseq = intval($_GET['fileseq']);
$fileseq = $fileseq ? $fileseq : 1;
if($fileseq > count($updatefilelist)) {
if($upgradeinfo['isupdatedb']) {
$discuz_upgrade->download_file($upgradeinfo, 'install/data/install.sql');
$discuz_upgrade->download_file($upgradeinfo, 'install/data/install_data.sql');
$discuz_upgrade->download_file($upgradeinfo, 'update.php', 'utility');
}
$linkurl = 'action='.$theurl.'&step=3';
cpmsg('upgrade_download_complete_to_compare', $linkurl, 'loading', array('upgradeurl' => upgradeinformation(0)));
} else {
$downloadstatus = $discuz_upgrade->download_file($upgradeinfo, $updatefilelist[$fileseq-1], 'upload', $updatemd5filelist[$fileseq-1]);
if($downloadstatus == 1) {
$linkurl = 'action='.$theurl.'&step=2&fileseq='.$fileseq;
cpmsg('upgrade_downloading_file', $linkurl, 'loading', array('file' => $updatefilelist[$fileseq-1], 'percent' => sprintf("%2d", 100 * $fileseq/count($updatefilelist)).'%', 'upgradeurl' => upgradeinformation(1)));
} elseif($downloadstatus == 2) {
$linkurl = 'action='.$theurl.'&step=2&fileseq='.($fileseq+1);
cpmsg('upgrade_downloading_file', $linkurl, 'loading', array('file' => $updatefilelist[$fileseq-1], 'percent' => sprintf("%2d", 100 * $fileseq/count($updatefilelist)).'%', 'upgradeurl' => upgradeinformation(1)));
} else {
cpmsg('upgrade_redownload', 'action='.$theurl.'&step=2&fileseq='.$fileseq, 'form', array('file' => $updatefilelist[$fileseq-1], 'upgradeurl' => upgradeinformation(-3)));
}
}
} elseif($step == 3) {
list($modifylist, $showlist, $ignorelist) = $discuz_upgrade->compare_basefile($upgradeinfo, $updatefilelist);
if(empty($modifylist) && empty($showlist) && empty($ignorelist)) {
cpmsg('filecheck_nofound_md5file', '', 'error', array('upgradeurl' => upgradeinformation(-4)));
}
showtablerow('class="header"', 'colspan="2"', $lang['founder_upgrade_diff_show']);
foreach($updatefilelist as $v) {
if(isset($ignorelist[$v])) {
continue;
} elseif(isset($modifylist[$v])) {
showtablerow('', array('class="" style="color:red;"', 'class="td24" style="color:red;"'), array('<em class="files bold">'.$v.'</em>', $lang['founder_upgrade_diff'].'<em class="edited">&nbsp;</em>'));
} elseif(isset($showlist[$v])) {
showtablerow('', array('class=""', 'class="td24"'), array('<em class="files bold">'.$v.'</em>', $lang['founder_upgrade_normal'].'<em class="fixed">&nbsp;</em>'));
} else {
showtablerow('', array('class=""', 'class="td24"'), array('<em class="files bold">'.$v.'</em>', $lang['founder_upgrade_new'].'<em class="unknown">&nbsp;</em>'));
}
}
$linkurl = ADMINSCRIPT.'?action='.$theurl.'&step=4';
showtablerow('', 'colspan="2"', $lang['founder_upgrade_download_file'].' ./data/update/Discuz! X'.$version.' Release['.$release.']'.'');
showtablerow('', 'colspan="2"', $lang['founder_upgrade_backup_file'].' ./data/back/Discuz! '.DISCUZ_VERSION.' Release['.DISCUZ_RELEASE.']'.$lang['founder_upgrade_backup_file2']);
showtablerow('', 'colspan="2"', '<input type="button" class="btn" onclick="window.location.href=\''.$linkurl.'\'" value="'.(!empty($modifylist) ? $lang['founder_upgrade_force'] : $lang['founder_upgrade_regular']).'" />');
echo upgradeinformation(0);
} elseif($step == 4) {
$confirm = $_GET['confirm'];
if(!$confirm) {
if($_GET['siteftpsetting']) {
$action = $theurl.'&step=4&confirm=ftp'.($_GET['startupgrade'] ? '&startupgrade=1' : '');
siteftp_form($action);
exit;
}
if($upgradeinfo['isupdatedb']) {
$checkupdatefilelist = array('install/update.php', 'install/data/install.sql','install/data/install_data.sql');
$checkupdatefilelist = array_merge($checkupdatefilelist, $updatefilelist);
} else {
$checkupdatefilelist = $updatefilelist;
}
if($discuz_upgrade->check_folder_perm($checkupdatefilelist)) {
$confirm = 'file';
} else {
$linkurl = ADMINSCRIPT.'?action='.$theurl.'&step=4';
$ftplinkurl = $linkurl.'&siteftpsetting=1';
cpmsg('upgrade_cannot_access_file',
'',
'',
array(),
'<br /><input type="button" class="btn" onclick="window.location.href=\''.$ftplinkurl.'\'" value="'.$lang['founder_upgrade_set_ftp'].'" />'.
' &nbsp; <input type="button" class="btn" onclick="window.location.href=\''.$linkurl.'\'" value="'.$lang['founder_upgrade_reset'].'" /><br /><br />'
);
}
}
$paraftp = '';
if($_GET['siteftp']) {
foreach($_GET['siteftp'] as $k => $v) {
$paraftp .= '&siteftp['.$k.']='.$v;
}
}
if(!$_GET['startupgrade']) {
if(!$_GET['backfile']) {
cpmsg('upgrade_backuping', 'action='.$theurl.'&step=4&backfile=1&confirm='.$confirm.$paraftp, 'loading', array('upgradeurl' => upgradeinformation(2)), false);
}
foreach($updatefilelist as $updatefile) {
$destfile = DISCUZ_ROOT.$updatefile;
$backfile = DISCUZ_ROOT.'./data/back/Discuz! X'.substr(DISCUZ_VERSION, 1).' Release['.DISCUZ_RELEASE.']/'.$updatefile;
if(is_file($destfile)) {
if(!$discuz_upgrade->copy_file($destfile, $backfile, 'file')) {
cpmsg('upgrade_backup_error', '', 'error', array('upgradeurl' => upgradeinformation(-5)));
}
}
}
cpmsg('upgrade_backup_complete', 'action='.$theurl.'&step=4&startupgrade=1&confirm='.$confirm.$paraftp, 'loading', array('upgradeurl' => upgradeinformation(3)), false);
}
$linkurl = ADMINSCRIPT.'?action='.$theurl.'&step=4&startupgrade=1&confirm='.$confirm.$paraftp;
$ftplinkurl = ADMINSCRIPT.'?action='.$theurl.'&step=4&startupgrade=1&siteftpsetting=1';
foreach($updatefilelist as $updatefile) {
$srcfile = DISCUZ_ROOT.'./data/update/Discuz! X'.$version.' Release['.$release.']/'.$updatefile;
if($confirm == 'ftp') {
$destfile = $updatefile;
} else {
$destfile = DISCUZ_ROOT.$updatefile;
}
if(!$discuz_upgrade->copy_file($srcfile, $destfile, $confirm)) {
if($confirm == 'ftp') {
cpmsg('upgrade_ftp_upload_error',
'',
'',
array('file' => $updatefile, 'upgradeurl' => upgradeinformation(-6)),
'<br /><input type="button" class="btn" onclick="window.location.href=\''.$linkurl.'\'" value="'.$lang['founder_upgrade_reupload'].'" />'.
' &nbsp; <input type="button" class="btn" onclick="window.location.href=\''.$ftplinkurl.'\'" value="'.$lang['founder_upgrade_reset_ftp'].'" /><br /><br />'
);
} else {
cpmsg('upgrade_copy_error',
'',
'',
array('file' => $updatefile, 'upgradeurl' => upgradeinformation(-7)),
'<br /><input type="button" class="btn" onclick="window.location.href=\''.$linkurl.'\'" value="'.$lang['founder_upgrade_recopy'].'" />'.
' &nbsp; <input type="button" class="btn" onclick="window.location.href=\''.$ftplinkurl.'\'" value="'.$lang['founder_upgrade_set_ftp'].'" /><br /><br />'
);
}
}
}
if($upgradeinfo['isupdatedb']) {
$dbupdatefilearr = array('update.php', 'install/data/install.sql','install/data/install_data.sql');
foreach($dbupdatefilearr as $dbupdatefile) {
$srcfile = DISCUZ_ROOT.'./data/update/Discuz! X'.$version.' Release['.$release.']/'.$dbupdatefile;
$dbupdatefile = $dbupdatefile == 'update.php' ? 'install/update.php' : $dbupdatefile;
if($confirm == 'ftp') {
$destfile = $dbupdatefile;
} else {
$destfile = DISCUZ_ROOT.$dbupdatefile;
}
if(!$discuz_upgrade->copy_file($srcfile, $destfile, $confirm)) {
if($confirm == 'ftp') {
cpmsg('upgrade_ftp_upload_error',
'',
'',
array('file' => $dbupdatefile, 'upgradeurl' => upgradeinformation(-6)),
'<br /><input type="button" class="btn" onclick="window.location.href=\''.$linkurl.'\'" value="'.$lang['founder_upgrade_reupload'].'" />'.
' &nbsp; <input type="button" class="btn" onclick="window.location.href=\''.$ftplinkurl.'\'" value="'.$lang['founder_upgrade_reset_ftp'].'" /><br /><br />'
);
} else {
cpmsg('upgrade_copy_error',
'',
'',
array('file' => $dbupdatefile, 'upgradeurl' => upgradeinformation(-7)),
'<br /><input type="button" class="btn" onclick="window.location.href=\''.$linkurl.'\'" value="'.$lang['founder_upgrade_recopy'].'" />'.
' &nbsp; <input type="button" class="btn" onclick="window.location.href=\''.$ftplinkurl.'\'" value="'.$lang['founder_upgrade_set_ftp'].'" /><br /><br />'
);
}
}
}
$upgrade_step['step'] = 'dbupdate';
C::t('common_cache')->insert(array(
'cachekey' => 'upgrade_step',
'cachevalue' => serialize($upgrade_step),
'dateline' => $_G['timestamp'],
), false, true);
$dbreturnurl = $_G['siteurl'].ADMINSCRIPT.'?action=upgrade&operation='.$operation.'&version='.$version.'&release='.$release.'&step=5';
cpmsg('upgrade_file_successful', $_G['siteurl'].'install/update.php?step=prepare&from='.rawurlencode($dbreturnurl).'&frommd5='.rawurlencode(md5($dbreturnurl.$_G['config']['security']['authkey'])), '', array('upgradeurl' => upgradeinformation(4)));
}
dheader('Location: '.ADMINSCRIPT.'?action=upgrade&operation='.$operation.'&version='.$version.'&release='.$release.'&step=5');
} elseif($step == 5) {
$file = DISCUZ_ROOT.'./data/update/Discuz! X'.$version.' Release['.$release.']/updatelist.tmp';
@unlink($file);
@unlink(DISCUZ_ROOT.'./install/update.php');
C::t('common_cache')->delete('upgrade_step');
C::t('common_cache')->delete('upgrade_run');
C::t('common_setting')->update('upgrade', '');
updatecache('setting');
$old_update_dir = './data/update/';
$new_update_dir = './data/update'.md5('update'.$_G['config']['security']['authkey']).'/';
$old_back_dir = './data/back/';
$new_back_dir = './data/back'.md5('back'.$_G['config']['security']['authkey']).'/';
$discuz_upgrade->copy_dir(DISCUZ_ROOT.$old_update_dir, DISCUZ_ROOT.$new_update_dir);
$discuz_upgrade->copy_dir(DISCUZ_ROOT.$old_back_dir, DISCUZ_ROOT.$new_back_dir);
$discuz_upgrade->rmdirs(DISCUZ_ROOT.$old_update_dir);
$discuz_upgrade->rmdirs(DISCUZ_ROOT.$old_back_dir);
cpmsg('upgrade_successful', '', 'succeed', array('version' => $version, 'release' => $release, 'save_update_dir' => $new_update_dir, 'save_back_dir' => $new_back_dir, 'upgradeurl' => upgradeinformation(0)), '<script type="text/javascript">if(parent.document.getElementById(\'notice\')) parent.document.getElementById(\'notice\').style.display = \'none\';</script>');
}
showtablefooter();
} elseif($operation == 'check') {
if(!intval($_GET['rechecking'])) {
$upgrade_step = C::t('common_cache')->fetch('upgrade_step');
if(!empty($upgrade_step['cachevalue'])) {
$upgrade_step['cachevalue'] = dunserialize($upgrade_step['cachevalue']);
if(!empty($upgrade_step['cachevalue']['step'])) {
$theurl = 'upgrade&operation='.$upgrade_step['cachevalue']['operation'].'&version='.$upgrade_step['cachevalue']['version'].'&locale='.$upgrade_step['cachevalue']['locale'].'&charset='.$upgrade_step['cachevalue']['charset'].'&release='.$upgrade_step['cachevalue']['release'];
$steplang = array('', cplang('founder_upgrade_updatelist'), cplang('founder_upgrade_download'), cplang('founder_upgrade_compare'), cplang('founder_upgrade_upgrading'), cplang('founder_upgrade_complete'), 'dbupdate' => cplang('founder_upgrade_dbupdate'));
$recheckurl = ADMINSCRIPT.'?action=upgrade&operation=recheck';
if($upgrade_step['cachevalue']['step'] == 'dbupdate') {
$dbreturnurl = $_G['siteurl'].ADMINSCRIPT.'?action='.$theurl.'&step=5';
$stepurl = $_G['siteurl'].'install/update.php?step=prepare&from='.rawurlencode($dbreturnurl).'&frommd5='.rawurlencode(md5($dbreturnurl.$_G['config']['security']['authkey']));
cpmsg('upgrade_continue',
'',
'',
array('step' => $steplang['dbupdate']),
'<br /><input type="button" class="btn" onclick="window.location.href=\''.$stepurl.'\'" value="'.$lang['founder_upgrade_continue'].'" />&nbsp;&nbsp;&nbsp;&nbsp;<input type="button" class="btn" onclick="window.location.href=\''.$recheckurl.'\'" value="'.$lang['founder_upgrade_recheck'].'" /><br /><br />'
);
} else {
$stepurl = ADMINSCRIPT.'?action='.$theurl.'&step='.$upgrade_step['cachevalue']['step'];
cpmsg('upgrade_continue',
'',
'',
array('step' => $steplang[$upgrade_step['cachevalue']['step']]),
'<br /><input type="button" class="btn" onclick="window.location.href=\''.$stepurl.'\'" value="'.$lang['founder_upgrade_continue'].'" />&nbsp;&nbsp;&nbsp;&nbsp;<input type="button" class="btn" onclick="window.location.href=\''.$recheckurl.'\'" value="'.$lang['founder_upgrade_recheck'].'" /><br /><br />'
);
}
}
}
} else {
C::t('common_cache')->delete('upgrade_step');
}
if(!intval($_GET['checking'])) {
cpmsg('upgrade_checking', 'action=upgrade&operation=check&checking=1', 'loading', '', false);
}
$discuz_upgrade->check_upgrade();
dheader('Location: '.ADMINSCRIPT.'?action=upgrade&operation=showupgrade');
} elseif($operation == 'showupgrade') {
shownav('tools', 'nav_founder_upgrade');
showsubmenu('nav_founder_upgrade');
showtableheader();
if(!$_G['setting']['upgrade']) {
cpmsg('upgrade_latest_version', '', 'succeed');
} else {
C::t('common_cache')->insert(array(
'cachekey' => 'upgrade_step',
'cachevalue' => serialize(array('curversion' => $discuz_upgrade->versionpath(), 'currelease' => DISCUZ_RELEASE)),
'dateline' => $_G['timestamp'],
), false, true);
$upgraderow = $patchrow = array();
$charset = str_replace('-', '', strtoupper($_G['config']['output']['charset']));
$dbversion = helper_dbtool::dbversion();
$locale = '';
if($charset == 'BIG5') {
$locale = 'TC';
} elseif($charset == 'GBK') {
$locale = 'SC';
} elseif($charset == 'UTF8') {
if($_G['config']['output']['language'] == 'zh_cn') {
$locale = 'SC';
} elseif($_G['config']['output']['language'] == 'zh_tw') {
$locale = 'TC';
}
}
foreach($_G['setting']['upgrade'] as $type => $upgrade) {
$unupgrade = 0;
if(version_compare($upgrade['phpversion'], PHP_VERSION) > 0 || version_compare($upgrade['mysqlversion'], $dbversion) > 0) {
$unupgrade = 1;
}
$linkurl = ADMINSCRIPT.'?action=upgrade&operation='.$type.'&version='.$upgrade['latestversion'].'&locale='.$locale.'&charset='.$charset.'&release='.$upgrade['latestrelease'];
if($unupgrade) {
$upgraderow[] = showtablerow('', '', array('Discuz! X'.$upgrade['latestversion'].'_'.$locale.'_'.$charset.$lang['version'].' [Release '.$upgrade['latestrelease'].']'.($type == 'patch' ? '('.$lang['founder_upgrade_newword'].'release)' : '').'', $lang['founder_upgrade_require_config'].' php v'.PHP_VERSION.'MYSQL v'.$dbversion, ''), TRUE);
} else {
$upgraderow[] = showtablerow('', '', array('Discuz! X'.$upgrade['latestversion'].'_'.$locale.'_'.$charset.$lang['version'].' [Release '.$upgrade['latestrelease'].']'.($type == 'patch' ? '('.$lang['founder_upgrade_newword'].'release)' : '').'', '<input type="button" class="btn" onclick="confirm(\''.$lang['founder_upgrade_backup_remind'].'\') ? window.location.href=\''.$linkurl.'\' : \'\';" value="'.$lang['founder_upgrade_automatically'].'">', '<a href="'.$upgrade['official'].'" target="_blank">'.$lang['founder_upgrade_manually'].'</a>'), TRUE);
}
}
showtablerow('class="header"','', array($lang['founder_upgrade_select_version'], '', ''));
if($upgraderow) {
foreach($upgraderow as $row) {
echo $row;
}
}
if($patchrow) {
foreach($patchrow as $row) {
echo $row;
}
}
}
showtablefooter();
} elseif($operation == 'recheck') {
$upgrade_step = C::t('common_cache')->fetch('upgrade_step');
$upgrade_step = dunserialize($upgrade_step['cachevalue']);
$file = DISCUZ_ROOT.'./data/update/Discuz! X'.$upgrade_step['version'].' Release['.$upgrade_step['release'].']/updatelist.tmp';
@unlink($file);
@unlink(DISCUZ_ROOT.'./install/update.php');
C::t('common_cache')->delete('upgrade_step');
C::t('common_cache')->delete('upgrade_run');
C::t('common_setting')->update('upgrade', '');
updatecache('setting');
$old_update_dir = './data/update/';
$discuz_upgrade->rmdirs(DISCUZ_ROOT.$old_update_dir);
dheader('Location: '.ADMINSCRIPT.'?action=upgrade');
}
?>

View File

@ -1,364 +0,0 @@
<?php
/**
* [Discuz!] (C)2001-2099 Comsenz Inc.
* This is NOT a freeware, use is subject to license terms
*
* $Id: discuz_patch.php 33628 2013-07-22 03:48:48Z jeffjzhang $
*/
if(!defined('IN_DISCUZ')) {
exit('Access Denied');
}
class discuz_patch {
public function save_patch_setting($settingnew) {
if($settingnew['patch']['autoopened'] && !$this->test_writable(DISCUZ_ROOT)) {
return false;
}
C::t('common_setting')->update_batch($settingnew);
include_once libfile('function/cache');
updatecache('setting');
return true;
}
public function fetch_patch_notice() {
global $_G;
$serials = $fixed_serials = $unfixed_serials = array();
$showpatchnotice = 1;
$serials = C::t('common_patch')->fetch_all();
if($serials) {
foreach($serials as $serial) {
if($serial['status'] <= 0) {
$showpatchnotice = 2;
$unfixed_serials[] = $serial;
} else {
$fixed_serials[] = $serial;
}
}
}
if($showpatchnotice == 2) {
$serials = $unfixed_serials;
} else {
C::t('common_setting')->delete('showpatchnotice');
include_once libfile('function/cache');
updatecache('setting');
}
return array('fixed' => (!empty($serials) && $showpatchnotice == 1) ? 1 : 0, 'data' => $serials);
}
public function check_patch($ignore = 0) {
global $_G;
if(!$ignore && $_G['cookie']['checkpatch']) {
return false;
}
require_once DISCUZ_ROOT.'source/discuz_version.php';
require_once libfile('class/xml');
$versionpath = '';
foreach(explode(' ', substr(DISCUZ_VERSION, 1)) as $unit) {
$versionpath = $unit;
break;
}
$patchdir = 'http://upgrade.discuz.com/DiscuzX/'.$versionpath.'/';
$checkurl = $patchdir.'md5sums';
$patchlist = dfsockopen($checkurl);
if(defined('DISCUZ_FIXBUG')) {
C::t('common_patch')->update_status_by_serial(1, DISCUZ_FIXBUG, '<=');
}
if($patchlist) {
$serial_md5s = explode("\r\n", $patchlist);
$bound = intval(substr($serial_md5s[count($serial_md5s)-2], 0, 8));
$maxpatch = intval(C::t('common_patch')->fetch_max_serial());
if(defined('DISCUZ_FIXBUG')) {
$maxpatch = $maxpatch < DISCUZ_FIXBUG ? DISCUZ_FIXBUG : $maxpatch;
}
if($bound > $maxpatch) {
$insertarrlist = array();
foreach($serial_md5s as $serial_md5) {
$downloadpatch = $patch = '';
list($serial, $md5, $release) = explode(' ', $serial_md5);
if($serial > $maxpatch && (!$release || in_array(DISCUZ_RELEASE, explode(',', $release)))) {
$downloadpatch = $patchdir.$serial.'.xml';
$patch = dfsockopen($downloadpatch);
if(md5($patch) != $md5) {
continue;
}
$patch = xml2array($patch);
if(is_array($patch) && !empty($patch)) {
$insertarr = array(
'serial' => intval($patch['serial']),
'rule' => serialize($patch['rule']),
'note' => $patch['note'],
'status' => 0,
'dateline' => $patch['dateline'],
);
C::t('common_patch')->insert($insertarr);
$insertarrlist[$insertarr['serial']] = $insertarr;
}
}
}
if($insertarrlist && $_G['setting']['patch']['autoopened']) {
foreach($insertarrlist as $key => $patch) {
$this->fix_patch($patch);
}
}
if($insertarrlist) {
C::t('common_setting')->update('showpatchnotice', 1);
include_once libfile('function/cache');
updatecache('setting');
}
}
}
dsetcookie('checkpatch', 1, 60);
return true;
}
public function fix_patch($patch, $type = 'file') {
global $_G;
$serial = $patch['serial'];
if(!$serial) {
return -1;
}
$returnflag = 1;
$trymax = 1000;
$rules = dunserialize($patch['rule']);
$tmpfiles = $bakfiles = array();
if($type == 'ftp') {
$siteftp = $_GET['siteftp'];
}
foreach($rules as $rule) {
$filename = DISCUZ_ROOT.$rule['filename'];
$search = base64_decode($rule['search']);
$replace = base64_decode($rule['replace']);
$count = $rule['count'];
$nums = $rule['nums'];
if(!$siteftp && !is_writable($filename)) {
$returnflag = -2;
break;
}
$str = file_get_contents($filename);
$findcount = substr_count($str, $search);
if($findcount != $count) {
$returnflag = 2;
break;
}
$bakfile = basename($rule['filename']);
$bakfile = '_'.$serial.'_'.substr($bakfile, 0, strrpos($bakfile, '.')).'_'.substr(md5($_G['config']['security']['authkey']), -6).'.bak.'.substr($bakfile, strrpos($bakfile, '.') +1);
$bakfile = $siteftp ? dirname($rule['filename']).'/'.$bakfile : dirname($filename).'/'.$bakfile;
$tmpfile = tempnam(DISCUZ_ROOT.'./data', 'patch');
$strarr = explode($search, $str);
$replacestr = '';
foreach($strarr as $key => $value) {
if($key == $findcount) {
$replacestr .= $value;
} else {
if(in_array(($key + 1), $nums)) {
$replacestr .= $value.$replace;
} else {
$replacestr .= $value.$search;
}
}
}
if(!file_put_contents($tmpfile, $replacestr)) {
$returnflag = -3;
break;
}
if($siteftp) {
if(!file_exists(DISCUZ_ROOT.$bakfile) && !$this->copy_file($filename, $bakfile, 'ftp')) {
$returnflag = -4;
break;
}
$i = 0;
while(!$this->copy_file($tmpfile, $rule['filename'], 'ftp')) {
if($i >= $trymax) {
$returnflag = -4;
break;
}
$i++;
}
} else {
if(!file_exists($bakfile) && !$this->copy_file($filename, $bakfile, 'file')) {
$returnflag = -5;
break;
}
$i = 0;
while(!$this->copy_file($tmpfile, $filename, 'file')) {
if($i >= $trymax) {
$returnflag = -5;
break;
}
$i++;
}
}
$tmpfiles[] = $tmpfile;
$bakfiles[] = $bakfile;
}
if($returnflag < 0) {
if(!empty($bakfiles)) {
foreach($bakfiles as $backfile) {
if($siteftp) {
$i = 0;
while(!$this->copy_file($backfile, substr($backfile, -12), 'ftp')) {
if($i >= $trymax) {
$returnflag = -6;
break;
}
$i++;
}
} else {
$i = 0;
while(!$this->copy_file($backfile, substr($backfile, -12), 'file')) {
if($i >= $trymax) {
$returnflag = -6;
break;
}
$i++;
}
}
}
}
}
if(!empty($tmpfiles)) {
foreach($tmpfiles as $tmpfile) {
@unlink($tmpfile);
}
}
C::t('common_patch')->update($serial, array('status' => $returnflag));
return $returnflag;
}
public function test_writable($sdir) {
$dir = opendir($sdir);
while($entry = readdir($dir)) {
$file = $sdir.$entry;
if($entry != '.' && $entry != '..') {
if(is_dir($file) && !strrpos($file.'/', '.svn')) {
if(!self::test_writable($file.'/')) {
return false;
}
}
}
}
if($fp = @fopen("$sdir/test.txt", 'w')) {
@fclose($fp);
@unlink("$sdir/test.txt");
$writeable = true;
} else {
$writeable = false;
}
return $writeable;
}
public function test_patch_writable($patch) {
$rules = dunserialize($patch['rule']);
if($rules) {
foreach($rules as $rule) {
if(!is_writable(DISCUZ_ROOT.$rule['filename'])) {
return false;
}
}
return true;
}
return false;
}
public function copy_file($srcfile, $desfile, $type) {
global $_G;
if(!is_file($srcfile)) {
return false;
}
if($type == 'file') {
$this->mkdirs(dirname($desfile));
copy($srcfile, $desfile);
} elseif($type == 'ftp') {
$siteftp = $_GET['siteftp'];
$siteftp['on'] = 1;
$siteftp['password'] = authcode($siteftp['password'], 'ENCODE', md5($_G['config']['security']['authkey']));
$ftp = & discuz_ftp::instance($siteftp);
$ftp->connect();
$ftp->upload($srcfile, $desfile);
if($ftp->error()) {
return false;
}
}
return true;
}
public function mkdirs($dir) {
if(!is_dir($dir)) {
if(!self::mkdirs(dirname($dir))) {
return false;
}
if(!mkdir($dir)) {
return false;
}
}
return true;
}
public function test_patch($patch) {
$serial = $patch['serial'];
$rules = dunserialize($patch['rule']);
foreach($rules as $rule) {
$filename = DISCUZ_ROOT.$rule['filename'];
$search = base64_decode($rule['search']);
$replace = base64_decode($rule['replace']);
$count = $rule['count'];
$nums = $rule['nums'];
$str = file_get_contents($filename);
$findcount = substr_count($str, $search);
if($findcount != $count) {
return true;
}
$replacefindcount = substr_count($str, $replace);
if($replacefindcount == $count) {
return true;
}
}
return false;
}
public function recheck_patch() {
$updatestatus = array();
$patchlist = C::t('common_patch')->fetch_patch_by_status(array(1,2));
foreach($patchlist as $patch) {
if(!$this->test_patch($patch)) {
$updatestatus[] = $patch['serial'];
}
}
if($updatestatus) {
C::t('common_patch')->update_status_by_serial(0, $updatestatus);
}
return true;
}
}
?>

View File

@ -1,48 +0,0 @@
<?php
/**
* [Discuz!] (C)2001-2099 Comsenz Inc.
* This is NOT a freeware, use is subject to license terms
*
* $Id: optimizer_patch.php 31344 2012-08-15 04:01:32Z zhangjie $
*/
if(!defined('IN_DISCUZ')) {
exit('Access Denied');
}
class optimizer_patch {
public function __construct() {
}
public function check() {
$discuz_patch = new discuz_patch();
$discuz_patch->check_patch();
$discuz_patch = new discuz_patch();
$patchnum = 0;
$patchnotice = $discuz_patch->fetch_patch_notice();
if($patchnotice['data']) {
foreach($patchnotice['data'] as $patch) {
if($patch['status'] <= 0) {
$patchnum++;
}
}
}
if($patchnum) {
$return = array('status' => 1, 'type' =>'header', 'lang' => lang('optimizer', 'optimizer_patch_have', array('patchnum' => $patchnum)));
} else {
$return = array('status' => 0, 'type' =>'none', 'lang' => lang('optimizer', 'optimizer_patch_check_safe'));
}
return $return;
}
public function optimizer() {
$adminfile = defined(ADMINSCRIPT) ? ADMINSCRIPT : 'admin.php';
dheader('Location: '.$_G['siteurl'].$adminfile.'?action=patch');
}
}
?>

View File

@ -1,36 +0,0 @@
<?php
/**
* [Discuz!] (C)2001-2099 Comsenz Inc.
* This is NOT a freeware, use is subject to license terms
*
* $Id: optimizer_upgrade.php 31344 2012-08-15 04:01:32Z zhangjie $
*/
if(!defined('IN_DISCUZ')) {
exit('Access Denied');
}
class optimizer_upgrade {
public function __construct() {
}
public function check() {
$discuz_upgrade = new discuz_upgrade();
if($discuz_upgrade->check_upgrade()) {
$return = array('status' => 1, 'type' =>'header', 'lang' => lang('optimizer', 'optimizer_upgrade_need_optimizer'));
} else {
$return = array('status' => 0, 'type' =>'none', 'lang' => lang('optimizer', 'optimizer_upgrade_no_need'));
}
return $return;
}
public function optimizer() {
$adminfile = defined(ADMINSCRIPT) ? ADMINSCRIPT : 'admin.php';
dheader('Location: '.$_G['siteurl'].$adminfile.'?action=upgrade');
}
}
?>

View File

@ -1,17 +0,0 @@
<?php
/**
* [Discuz!] (C)2001-2099 Comsenz Inc.
* This is NOT a freeware, use is subject to license terms
*
* $Id: cron_checkpatch_daily.php 23672 2011-08-03 06:27:03Z svn_project_zhangjie $
*/
if(!defined('IN_DISCUZ')) {
exit('Access Denied');
}
$discuz_patch = new discuz_patch();
$discuz_patch->check_patch();
?>

View File

@ -11,52 +11,7 @@ if(!defined('IN_DISCUZ')) {
exit('Access Denied');
}
if($_GET['action'] == 'checkpatch') {
header('Content-Type: text/javascript');
if($_G['uid'] && $_G['member']['allowadmincp'] == 1) {
$discuz_patch = new discuz_patch();
$discuz_patch->check_patch();
}
exit;
} elseif($_GET['action'] == 'patchnotice') {
$patchlist = '';
if($_G['member']['allowadmincp'] == 1) {
$discuz_patch = new discuz_patch();
$patchnotice = $discuz_patch->fetch_patch_notice();
if(!empty($patchnotice['data'])) {
$lang = lang('forum/misc');
$patchlist .= '<div class="bm'.($patchnotice['fixed'] ? ' allfixed' : '').'"><div class="bm_h cl"><a href="javascript:;" onclick="$(\'patch_notice\').style.display=\'none\'" class="y" title="'.$lang['patch_close'].'">'.$lang['patch_close'].'</a><h2 class="i">';
if($patchnotice['fixed']) {
$patchlist .= $lang['patch_site_have'].' '.count($patchnotice['data']).' '.$lang['patch_is_fixed'];
} else {
$patchlist .= $lang['patch_site_have'].' '.count($patchnotice['data']).' '.$lang['patch_need_fix'];
}
$patchlist .= '</h2></div><div class="bm_c"><table width="100%" class="mbm"><tr><th>'.$lang['patch_name'].'</th><th class="patchdate">'.$lang['patch_dateline'].'</th><th class="patchstat">'.$lang['patch_status'].'</th><tr>';
foreach($patchnotice['data'] as $notice) {
$patchlist .= '<tr><td>'.$notice['serial'].'</td><td>'.dgmdate($notice['dateline'], 'Y-m-d').'</td><td>';
if($notice['status'] >= 1) {
$patchlist .= '<span class="fixed">'.$lang['patch_fixed_status'].'<span>';
} elseif($notice['status'] < 0) {
$patchlist .= '<span class="unfixed">'.$lang['patch_fix_failed_status'].'</span>';
} else {
$patchlist .= '<span class="unfixed">'.$lang['patch_unfix_status'].'</span>';
}
$patchlist .= '</td></tr>';
}
$patchlist .= '</table><p class="cl"><a href="admin.php?action=patch" class="y pn"><strong>'.($patchnotice['fixed'] ? $lang['patch_view_fix_detail'] : $lang['patch_fix_right_now']).'</strong></a></p>';
$patchlist .= '</div></div>';
}
}
include template('common/header_ajax');
echo $patchlist;
include template('common/footer_ajax');
exit;
} elseif($_GET['action'] == 'pluginnotice') {
if($_GET['action'] == 'pluginnotice') {
require_once libfile('function/admincp');
require_once libfile('function/plugin');
require_once libfile('function/cloudaddons');

View File

@ -1753,12 +1753,6 @@ function strLenCalc(obj, checklen, maxlen) {
}
}
function patchNotice() {
if($('patch_notice')) {
ajaxget('misc.php?mod=patch&action=patchnotice', 'patch_notice', '');
}
}
function pluginNotice() {
if($('plugin_notice')) {
ajaxget('misc.php?mod=patch&action=pluginnotice', 'plugin_notice', '');

View File

@ -44,9 +44,6 @@
var focusautoshow = window.setInterval('showfocus(\'next\', 1);', 5000);
</script>
<!--{/if}-->
<!--{if $_G['uid'] && $_G['member']['allowadmincp'] == 1 && $_G['setting']['showpatchnotice'] == 1}-->
<div class="focus patch" id="patch_notice"></div>
<!--{/if}-->
<!--{ad/footerbanner/wp a_f/1}--><!--{ad/footerbanner/wp a_f/2}--><!--{ad/footerbanner/wp a_f/3}-->
<!--{ad/float/a_fl/1}--><!--{ad/float/a_fr/2}-->
@ -102,9 +99,6 @@
<script type="text/javascript" src="home.php?mod=misc&ac=sendmail&rand=$_G[timestamp]"></script>
<!--{/if}-->
<!--{if $_G[uid] && $_G['member']['allowadmincp'] == 1 && !isset($_G['cookie']['checkpatch'])}-->
<script type="text/javascript" src="misc.php?mod=patch&action=checkpatch&rand=$_G[timestamp]"></script>
<!--{/if}-->
<!--{/if}-->
<!--{if $_GET['diy'] == 'yes'}-->