⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 main.php

📁 在综合英文版XOOPS 2.09, 2.091, 2.092 的基础上正式发布XOOPS 2.09中文版 XOOPS 2.09x 版主要是PHP5升级、bug修正和安全补正: 1 全面兼容PHP 5.
💻 PHP
📖 第 1 页 / 共 2 页
字号:
					}					unset($tpldata);				} else {					$msgs[] = '&nbsp;&nbsp;<span style="color:#ff0000;">ERROR: 不能删除原有模板 <b>'.$tpl['file'].'</b>. 放弃更新.</span>';				}			}		}		$contents = xoops_module_get_admin_menu();		if (!xoops_module_write_admin_menu($contents)) {			$msgs[] = '<p><span style="color:#ff0000;">'._MD_AM_FAILWRITE.'</span></p>';		}		$blocks = $module->getInfo('blocks');		$msgs[] = '重建显示区块...';		if ($blocks != false) {			$count = count($blocks);			$showfuncs = array();			$funcfiles = array();			for ( $i = 1; $i <= $count; $i++ ) {				if (isset($blocks[$i]['show_func']) && $blocks[$i]['show_func'] != '' && isset($blocks[$i]['file']) && $blocks[$i]['file'] != '') {					$editfunc = isset($blocks[$i]['edit_func']) ? $blocks[$i]['edit_func'] : '';					$showfuncs[] = $blocks[$i]['show_func'];					$funcfiles[] = $blocks[$i]['file'];					$template = '';					if ((isset($blocks[$i]['template']) && trim($blocks[$i]['template']) != '')) {						$content =& xoops_module_gettemplate($dirname, $blocks[$i]['template'], true);					}					if (!$content) {						$content = '';					} else {						$template = $blocks[$i]['template'];					}					$options = '';					if (!empty($blocks[$i]['options'])) {						$options = $blocks[$i]['options'];					}					$sql = "SELECT bid, name FROM ".$xoopsDB->prefix('newblocks')." WHERE mid=".$module->getVar('mid')." AND func_num=".$i." AND show_func='".addslashes($blocks[$i]['show_func'])."' AND func_file='".addslashes($blocks[$i]['file'])."'";					$fresult = $xoopsDB->query($sql);					$fcount = 0;					while ($fblock = $xoopsDB->fetchArray($fresult)) {						$fcount++;						$sql = "UPDATE ".$xoopsDB->prefix("newblocks")." SET name='".addslashes($blocks[$i]['name'])."', edit_func='".addslashes($editfunc)."', options='".addslashes($options)."', content='', template='".$template."', last_modified=".time()." WHERE bid=".$fblock['bid'];						$result = $xoopsDB->query($sql);						if (!$result) {							$msgs[] = '&nbsp;&nbsp;ERROR: 无法更新区块 '.$fblock['name'];						} else {							$msgs[] = '&nbsp;&nbsp;区块 <b>'.$fblock['name'].'</b> 已更新. 区块 ID: <b>'.$fblock['bid'].'</b>';							if ($template != '') {								$tplfile =& $tplfile_handler->find('default', 'block', $fblock['bid']);								if (count($tplfile) == 0) {									$tplfile_new =& $tplfile_handler->create();									$tplfile_new->setVar('tpl_module', $dirname);									$tplfile_new->setVar('tpl_refid', $fblock['bid']);									$tplfile_new->setVar('tpl_tplset', 'default');									$tplfile_new->setVar('tpl_file', $blocks[$i]['template'], true);									$tplfile_new->setVar('tpl_type', 'block');								}								else {								    $tplfile_new = $tplfile[0];								}								$tplfile_new->setVar('tpl_source', $content, true);								$tplfile_new->setVar('tpl_desc', $blocks[$i]['description'], true);								$tplfile_new->setVar('tpl_lastmodified', time());								$tplfile_new->setVar('tpl_lastimported', 0);								if (!$tplfile_handler->insert($tplfile_new)) {										$msgs[] = '&nbsp;&nbsp;<span style="color:#ff0000;">ERROR: 无法将区块模板 <b>'.$blocks[$i]['template'].'</b> 添加到数据库中.</span>';									} else {										$msgs[] = '&nbsp;&nbsp;模板 <b>'.$blocks[$i]['template'].'</b> 已添加到数据库中.';										if ($xoopsConfig['template_set'] == 'default') {								        if (!xoops_template_touch($tplfile_new->getVar('tpl_id'))) {												$msgs[] = '&nbsp;&nbsp;<span style="color:#ff0000;">ERROR: 模板 <b>'.$blocks[$i]['template'].'</b> 重编译失败.</span>';											} else {												$msgs[] = '&nbsp;&nbsp;模板 <b>'.$blocks[$i]['template'].'</b> 已重编译.';											}										}								}							}						}					}					if ($fcount == 0) {						$newbid = $xoopsDB->genId($xoopsDB->prefix('newblocks').'_bid_seq');						$block_name = addslashes($blocks[$i]['name']);						$sql = "INSERT INTO ".$xoopsDB->prefix("newblocks")." (bid, mid, func_num, options, name, title, content, side, weight, visible, block_type, isactive, dirname, func_file, show_func, edit_func, template, last_modified) VALUES (".$newbid.", ".$module->getVar('mid').", ".$i.",'".addslashes($options)."','".$block_name."', '".$block_name."', '', 0, 0, 0, 'M', 1, '".addslashes($dirname)."', '".addslashes($blocks[$i]['file'])."', '".addslashes($blocks[$i]['show_func'])."', '".addslashes($editfunc)."', '".$template."', ".time().")";						$result = $xoopsDB->query($sql);						if (!$result) {							$msgs[] = '&nbsp;&nbsp;ERROR: 无法生成区块 '.$blocks[$i]['name'];echo $sql;						} else {							if (empty($newbid)) {								$newbid = $xoopsDB->getInsertId();							}							$groups =& $xoopsUser->getGroups();							$gperm_handler =& xoops_gethandler('groupperm');							foreach ($groups as $mygroup) {								$bperm =& $gperm_handler->create();								$bperm->setVar('gperm_groupid', $mygroup);								$bperm->setVar('gperm_itemid', $newbid);								$bperm->setVar('gperm_name', 'block_read');								$bperm->setVar('gperm_modid', 1);								if (!$gperm_handler->insert($bperm)) {									$msgs[] = '&nbsp;&nbsp;<span style="color:#ff0000;">ERROR: 无法添加区块使用权限. 区块 ID: <b>'.$newbid.'</b> 群组 ID: <b>'.$mygroup.'</b></span>';								} else {									$msgs[] = '&nbsp;&nbsp;已添加区块使用权限. 区块 ID: <b>'.$newbid.'</b> 群组 ID: <b>'.$mygroup.'</b>';								}							}							if ($template != '') {								$tplfile =& $tplfile_handler->create();								$tplfile->setVar('tpl_module', $dirname);								$tplfile->setVar('tpl_refid', $newbid);								$tplfile->setVar('tpl_source', $content, true);								$tplfile->setVar('tpl_tplset', 'default');								$tplfile->setVar('tpl_file', $blocks[$i]['template'], true);								$tplfile->setVar('tpl_type', 'block');								$tplfile->setVar('tpl_lastimported', 0);								$tplfile->setVar('tpl_lastmodified', time());								$tplfile->setVar('tpl_desc', $blocks[$i]['description'], true);								if (!$tplfile_handler->insert($tplfile)) {									$msgs[] = '&nbsp;&nbsp;<span style="color:#ff0000;">ERROR: 无法将区块模板 <b>'.$blocks[$i]['template'].'</b> 添加到数据库中.</span>';								} else {									$newid = $tplfile->getVar('tpl_id');									$msgs[] = '&nbsp;&nbsp;模板 <b>'.$blocks[$i]['template'].'</b> 已添加到数据库中.';									if ($xoopsConfig['template_set'] == 'default') {										if (!xoops_template_touch($newid)) {											$msgs[] = '&nbsp;&nbsp;<span style="color:#ff0000;">ERROR: 模板 <b>'.$blocks[$i]['template'].'</b> 重编译失败.</span>';										} else {											$msgs[] = '&nbsp;&nbsp;模板 <b>'.$blocks[$i]['template'].'</b> 已重编译.';										}									}								}							}							$msgs[] = '&nbsp;&nbsp;区块 <b>'.$blocks[$i]['name'].'</b> 已生成. 区块 ID: <b>'.$newbid.'</b>';							$sql = 'INSERT INTO '.$xoopsDB->prefix('block_module_link').' (block_id, module_id) VALUES ('.$newbid.', -1)';							$xoopsDB->query($sql);						}					}				}			}			$block_arr = XoopsBlock::getByModule($module->getVar('mid'));			foreach ($block_arr as $block) {				if (!in_array($block->getVar('show_func'), $showfuncs) || !in_array($block->getVar('func_file'), $funcfiles)) {					$sql = sprintf("DELETE FROM %s WHERE bid = %u", $xoopsDB->prefix('newblocks'), $block->getVar('bid'));					if(!$xoopsDB->query($sql)) {						$msgs[] = '&nbsp;&nbsp;<span style="color:#ff0000;">ERROR: 无法删除区块 <b>'.$block->getVar('name').'</b> ID: <b>'.$block->getVar('bid').'</b></span>';					} else {						$msgs[] = '&nbsp;&nbsp;已删除区块 <b>'.$block->getVar('name').' ID: <b>'.$block->getVar('bid').'</b>';						if ($block->getVar('template') != '') {							$tplfiles =& $tplfile_handler->find(null, 'block', $block->getVar('bid'));							if (is_array($tplfiles)) {								$btcount = count($tplfiles);								for ($k = 0; $k < $btcount; $k++) {									if (!$tplfile_handler->delete($tplfiles[$k])) {										$msgs[] = '&nbsp;&nbsp;<span style="color:#ff0000;">ERROR: 无法删除失效的模板 (ID: <b>'.$tplfiles[$k]->getVar('tpl_id').'</b>)</span>';									} else {										$msgs[] = '&nbsp;&nbsp;区块模板 <b>'.$tplfiles[$k]->getVar('tpl_file').'</b> 已失效.';									}								}							}						}					}				}			}		}		// first delete all config entries		$config_handler =& xoops_gethandler('config');		$configs =& $config_handler->getConfigs(new Criteria('conf_modid', $module->getVar('mid')));		$confcount = count($configs);		$config_delng = array();		if ($confcount > 0) {			$msgs[] = '删除模块配置参数...';			for ($i = 0; $i < $confcount; $i++) {				if (!$config_handler->deleteConfig($configs[$i])) {					$msgs[] = '&nbsp;&nbsp;<span style="color:#ff0000;">ERROR: 无法从数据库中删除参数 ID: <b>'.$configs[$i]->getvar('conf_id').'</b></span>';					// save the name of config failed to delete for later use					$config_delng[] = $configs[$i]->getvar('conf_name');				} else {					$config_old[$configs[$i]->getvar('conf_name')]['value'] = $configs[$i]->getvar('conf_value', 'N');					$config_old[$configs[$i]->getvar('conf_name')]['formtype'] = $configs[$i]->getvar('conf_formtype');					$config_old[$configs[$i]->getvar('conf_name')]['valuetype'] = $configs[$i]->getvar('conf_valuetype');					$msgs[] = '&nbsp;&nbsp;已从数据库中删除参数 ID: <b>'.$configs[$i]->getVar('conf_id').'</b>';				}			}		}		// now reinsert them with the new settings		$configs = $module->getInfo('config');		if ($configs != false) {			if ($module->getVar('hascomments') != 0) {				include_once(XOOPS_ROOT_PATH.'/include/comment_constants.php');				array_push($configs, array('name' => 'com_rule', 'title' => '_CM_COMRULES', 'description' => '', 'formtype' => 'select', 'valuetype' => 'int', 'default' => 1, 'options' => array('_CM_COMNOCOM' => XOOPS_COMMENT_APPROVENONE, '_CM_COMAPPROVEALL' => XOOPS_COMMENT_APPROVEALL, '_CM_COMAPPROVEUSER' => XOOPS_COMMENT_APPROVEUSER, '_CM_COMAPPROVEADMIN' => XOOPS_COMMENT_APPROVEADMIN)));				array_push($configs, array('name' => 'com_anonpost', 'title' => '_CM_COMANONPOST', 'description' => '', 'formtype' => 'yesno', 'valuetype' => 'int', 'default' => 0));			}		} else {			if ($module->getVar('hascomments') != 0) {				$configs = array();				include_once(XOOPS_ROOT_PATH.'/include/comment_constants.php');				$configs[] = array('name' => 'com_rule', 'title' => '_CM_COMRULES', 'description' => '', 'formtype' => 'select', 'valuetype' => 'int', 'default' => 1, 'options' => array('_CM_COMNOCOM' => XOOPS_COMMENT_APPROVENONE, '_CM_COMAPPROVEALL' => XOOPS_COMMENT_APPROVEALL, '_CM_COMAPPROVEUSER' => XOOPS_COMMENT_APPROVEUSER, '_CM_COMAPPROVEADMIN' => XOOPS_COMMENT_APPROVEADMIN));				$configs[] = array('name' => 'com_anonpost', 'title' => '_CM_COMANONPOST', 'description' => '', 'formtype' => 'yesno', 'valuetype' => 'int', 'default' => 0);			}		}		// RMV-NOTIFY		if ($module->getVar('hasnotification') != 0) {			if (empty($configs)) {				$configs = array();			}            // Main notification options            include_once XOOPS_ROOT_PATH . '/include/notification_constants.php';            include_once XOOPS_ROOT_PATH . '/include/notification_functions.php';			$options = array();			$options['_NOT_CONFIG_DISABLE'] = XOOPS_NOTIFICATION_DISABLE;			$options['_NOT_CONFIG_ENABLEBLOCK'] = XOOPS_NOTIFICATION_ENABLEBLOCK;			$options['_NOT_CONFIG_ENABLEINLINE'] = XOOPS_NOTIFICATION_ENABLEINLINE;			$options['_NOT_CONFIG_ENABLEBOTH'] = XOOPS_NOTIFICATION_ENABLEBOTH;            //$configs[] = array ('name' => 'notification_enabled', 'title' => '_NOT_CONFIG_ENABLED', 'description' => '_NOT_CONFIG_ENABLEDDSC', 'formtype' => 'yesno', 'valuetype' => 'int', 'default' => 1);            $configs[] = array ('name' => 'notification_enabled', 'title' => '_NOT_CONFIG_ENABLE', 'description' => '_NOT_CONFIG_ENABLEDSC', 'formtype' => 'select', 'valuetype' => 'int', 'default' => XOOPS_NOTIFICATION_ENABLEBOTH, 'options'=>$options);			// Event specific notification options			// FIXME: for some reason the default doesn't come up properly			//  initially is ok, but not when 'update' module..			$options = array();            $categories =& notificationCategoryInfo('',$module->getVar('mid'));            foreach ($categories as $category) {                $events =& notificationEvents ($category['name'], false, $module->getVar('mid'));                foreach ($events as $event) {					if (!empty($event['invisible'])) {						continue;					}					$option_name = $category['title'] . ' : ' . $event['title'];					$option_value = $category['name'] . '-' . $event['name'];					$options[$option_name] = $option_value;					//$configs[] = array ('name' => notificationGenerateConfig($category,$event,'name'), 'title' => notificationGenerateConfig($category,$event,'title_constant'), 'description' => notificationGenerateConfig($category,$event,'description_constant'), 'formtype' => 'yesno', 'valuetype' => 'int', 'default' => 1);                }            }			$configs[] = array ('name' => 'notification_events', 'title' => '_NOT_CONFIG_EVENTS', 'description' => '_NOT_CONFIG_EVENTSDSC', 'formtype' => 'select_multi', 'valuetype' => 'array', 'default' => array_values($options), 'options' => $options);		}		if ($configs != false) {			$msgs[] = '添加模块配置参数...';			$config_handler =& xoops_gethandler('config');			$order = 0;			foreach ($configs as $config) {				// only insert ones that have been deleted previously with success				if (!in_array($config['name'], $config_delng)) {					$confobj =& $config_handler->createConfig();					$confobj->setVar('conf_modid', $newmid);					$confobj->setVar('conf_catid', 0);					$confobj->setVar('conf_name', $config['name']);					$confobj->setVar('conf_title', $config['title'], true);					$confobj->setVar('conf_desc', $config['description'], true);					$confobj->setVar('conf_formtype', $config['formtype']);					$confobj->setVar('conf_valuetype', $config['valuetype']);					if (isset($config_old[$config['name']]['value']) && $config_old[$config['name']]['formtype'] == $config['formtype'] && $config_old[$config['name']]['valuetype'] == $config['valuetype']) {						// preserver the old value if any						// form type and value type must be the same						$confobj->setVar('conf_value', $config_old[$config['name']]['value'], true);					} else {						$confobj->setConfValueForInput($config['default'], true);						//$confobj->setVar('conf_value', $config['default'], true);					}					$confobj->setVar('conf_order', $order);					$confop_msgs = '';					if (isset($config['options']) && is_array($config['options'])) {						foreach ($config['options'] as $key => $value) {							$confop =& $config_handler->createConfigOption();							$confop->setVar('confop_name', $key, true);							$confop->setVar('confop_value', $value, true);							$confobj->setConfOptions($confop);							$confop_msgs .= '<br />&nbsp;&nbsp;&nbsp;&nbsp;成功添加参数. 名称: <b>'.$key.'</b> 值: <b>'.$value.'</b>';							unset($confop);						}					}					$order++;					if (false != $config_handler->insertConfig($confobj)) {						$msgs[] = '&nbsp;&nbsp;参数 <b>'.$config['name'].'</b> 已成功添加.'.$confop_msgs;					} else {						$msgs[] = '&nbsp;&nbsp;<span style="color:#ff0000;">ERROR: 无法将参数 <b>'.$config['name'].'</b> 添加到数据库中.</span>';					}					unset($confobj);				}			}			unset($configs);		}		// execute module specific update script if any		$update_script = $module->getInfo('onUpdate');		if (false != $update_script && trim($update_script) != '') {		    $prev_version = $module->getVar('version');		    include_once XOOPS_ROOT_PATH.'/modules/'.$dirname.'/'.trim($update_script);		    if (function_exists('xoops_module_update_'.$dirname)) {		        $func = 'xoops_module_update_'.$dirname;		        if (!$func($module, $prev_version)) {		            $msgs[] = '无法执行 '.$func;		        } else {		            $msgs[] = '<b>'.$func.'</b> 已成功执行.';		        }		    }		}		foreach ($msgs as $msg) {			echo '<code>'.$msg.'</code><br />';		}		echo "<p>".sprintf(_MD_AM_OKUPD, "<b>".$module->getVar('name')."</b>")."</p>";	}	echo "<br /><a href='admin.php?fct=modulesadmin'>"._MD_AM_BTOMADMIN."</a>";	xoops_cp_footer();}?>

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -