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

📄 main.php

📁 在综合英文版XOOPS 2.09, 2.091, 2.092 的基础上正式发布XOOPS 2.09中文版 XOOPS 2.09x 版主要是PHP5升级、bug修正和安全补正: 1 全面兼容PHP 5.
💻 PHP
📖 第 1 页 / 共 2 页
字号:
		}
		if (count($err) > 0) {
			xoops_cp_header();
			xoops_error($err);
			xoops_cp_footer();
			exit();
		}
		redirect_header('admin.php?fct=images',2,_MD_AM_DBUPDATED);
	}

	if ($op == 'addcat') {
		$imgcat_handler =& xoops_gethandler('imagecategory');
		$imagecategory =& $imgcat_handler->create();
		$imagecategory->setVar('imgcat_name', $imgcat_name);
		$imagecategory->setVar('imgcat_maxsize', $imgcat_maxsize);
		$imagecategory->setVar('imgcat_maxwidth', $imgcat_maxwidth);
		$imagecategory->setVar('imgcat_maxheight', $imgcat_maxheight);
		$imgcat_display = empty($imgcat_display) ? 0 : 1;
		$imagecategory->setVar('imgcat_display', $imgcat_display);
		$imagecategory->setVar('imgcat_weight', $imgcat_weight);
		$imagecategory->setVar('imgcat_storetype', $imgcat_storetype);
		$imagecategory->setVar('imgcat_type', 'C');
		if (!$imgcat_handler->insert($imagecategory)) {
			exit();
		}
		$newid = $imagecategory->getVar('imgcat_id');
		$imagecategoryperm_handler =& xoops_gethandler('groupperm');
		if (!isset($readgroup)) {
			$readgroup = array();
		}
		if (!in_array(XOOPS_GROUP_ADMIN, $readgroup)) {
			array_push($readgroup, XOOPS_GROUP_ADMIN);
		}
		foreach ($readgroup as $rgroup) {
			$imagecategoryperm =& $imagecategoryperm_handler->create();
			$imagecategoryperm->setVar('gperm_groupid', $rgroup);
			$imagecategoryperm->setVar('gperm_itemid', $newid);
			$imagecategoryperm->setVar('gperm_name', 'imgcat_read');
			$imagecategoryperm->setVar('gperm_modid', 1);
			$imagecategoryperm_handler->insert($imagecategoryperm);
			unset($imagecategoryperm);
		}
		if (!isset($writegroup)) {
			$writegroup = array();
		}
		if (!in_array(XOOPS_GROUP_ADMIN, $writegroup)) {
			array_push($writegroup, XOOPS_GROUP_ADMIN);
		}
		foreach ($writegroup as $wgroup) {
			$imagecategoryperm =& $imagecategoryperm_handler->create();
			$imagecategoryperm->setVar('gperm_groupid', $wgroup);
			$imagecategoryperm->setVar('gperm_itemid', $newid);
			$imagecategoryperm->setVar('gperm_name', 'imgcat_write');
			$imagecategoryperm->setVar('gperm_modid', 1);
			$imagecategoryperm_handler->insert($imagecategoryperm);
			unset($imagecategoryperm);
		}
		redirect_header('admin.php?fct=images',2,_MD_AM_DBUPDATED);
	}

	if ($op == 'editcat') {
		if ($imgcat_id <= 0) {
			redirect_header('admin.php?fct=images',1);
		}
		$imgcat_handler = xoops_gethandler('imagecategory');
		$imagecategory =& $imgcat_handler->get($imgcat_id);
		if (!is_object($imagecategory)) {
			redirect_header('admin.php?fct=images',1);
		}
		include_once XOOPS_ROOT_PATH.'/class/xoopsformloader.php';
		$imagecategoryperm_handler =& xoops_gethandler('groupperm');
		$form = new XoopsThemeForm(_MD_EDITIMGCAT, 'imagecat_form', 'admin.php');
		$form->addElement(new XoopsFormText(_MD_IMGCATNAME, 'imgcat_name', 50, 255, $imagecategory->getVar('imgcat_name')), true);
		$form->addElement(new XoopsFormSelectGroup(_MD_IMGCATRGRP, 'readgroup', true, $imagecategoryperm_handler->getGroupIds('imgcat_read', $imgcat_id), 5, true));
		$form->addElement(new XoopsFormSelectGroup(_MD_IMGCATWGRP, 'writegroup', true, $imagecategoryperm_handler->getGroupIds('imgcat_write', $imgcat_id), 5, true));
		$form->addElement(new XoopsFormText(_IMGMAXSIZE, 'imgcat_maxsize', 10, 10, $imagecategory->getVar('imgcat_maxsize')));
		$form->addElement(new XoopsFormText(_IMGMAXWIDTH, 'imgcat_maxwidth', 3, 4, $imagecategory->getVar('imgcat_maxwidth')));
		$form->addElement(new XoopsFormText(_IMGMAXHEIGHT, 'imgcat_maxheight', 3, 4, $imagecategory->getVar('imgcat_maxheight')));
		$form->addElement(new XoopsFormText(_MD_IMGCATWEIGHT, 'imgcat_weight', 3, 4, $imagecategory->getVar('imgcat_weight')));
		$form->addElement(new XoopsFormRadioYN(_MD_IMGCATDISPLAY, 'imgcat_display', $imagecategory->getVar('imgcat_display'), _YES, _NO));
		$storetype = array('db' => _MD_INDB, 'file' => _MD_ASFILE);
		$form->addElement(new XoopsFormLabel(_MD_IMGCATSTRTYPE, $storetype[$imagecategory->getVar('imgcat_storetype')]));
		$form->addElement(new XoopsFormHidden('imgcat_id', $imgcat_id));
		$form->addElement(new XoopsFormHidden('op', 'updatecat'));
		$form->addElement(new XoopsFormHidden('fct', 'images'));
		$form->addElement(new XoopsFormButton('', 'imgcat_button', _SUBMIT, 'submit'));
		xoops_cp_header();
		echo '<a href="admin.php?fct=images">'. _MD_IMGMAIN .'</a>&nbsp;<span style="font-weight:bold;">&raquo;&raquo;</span>&nbsp;'.$imagecategory->getVar('imgcat_name').'<br /><br />';
		$form->display();
		xoops_cp_footer();
		exit();
	}

	if ($op == 'updatecat') {
		if ($imgcat_id <= 0) {
			redirect_header('admin.php?fct=images',1);
		}
		$imgcat_handler = xoops_gethandler('imagecategory');
		$imagecategory =& $imgcat_handler->get($imgcat_id);
		if (!is_object($imagecategory)) {
			redirect_header('admin.php?fct=images',1);
		}
		$imagecategory->setVar('imgcat_name', $imgcat_name);
		$imgcat_display = empty($imgcat_display) ? 0 : 1;
		$imagecategory->setVar('imgcat_display', $imgcat_display);
		$imagecategory->setVar('imgcat_maxsize', $imgcat_maxsize);
		$imagecategory->setVar('imgcat_maxwidth', $imgcat_maxwidth);
		$imagecategory->setVar('imgcat_maxheight', $imgcat_maxheight);
		$imagecategory->setVar('imgcat_weight', $imgcat_weight);
		if (!$imgcat_handler->insert($imagecategory)) {
			exit();
		}
		$imagecategoryperm_handler =& xoops_gethandler('groupperm');
		$criteria = new CriteriaCompo(new Criteria('gperm_itemid', $imgcat_id));
		$criteria->add(new Criteria('gperm_modid', 1));
		$criteria2 = new CriteriaCompo(new Criteria('gperm_name', 'imgcat_write'));
		$criteria2->add(new Criteria('gperm_name', 'imgcat_read'), 'OR');
		$criteria->add($criteria2);
		$imagecategoryperm_handler->deleteAll($criteria);
		if (!isset($readgroup)) {
			$readgroup = array();
		}
		if (!in_array(XOOPS_GROUP_ADMIN, $readgroup)) {
			array_push($readgroup, XOOPS_GROUP_ADMIN);
		}
		foreach ($readgroup as $rgroup) {
			$imagecategoryperm =& $imagecategoryperm_handler->create();
			$imagecategoryperm->setVar('gperm_groupid', $rgroup);
			$imagecategoryperm->setVar('gperm_itemid', $imgcat_id);
			$imagecategoryperm->setVar('gperm_name', 'imgcat_read');
			$imagecategoryperm->setVar('gperm_modid', 1);
			$imagecategoryperm_handler->insert($imagecategoryperm);
			unset($imagecategoryperm);
		}
		if (!isset($writegroup)) {
			$writegroup = array();
		}
		if (!in_array(XOOPS_GROUP_ADMIN, $writegroup)) {
			array_push($writegroup, XOOPS_GROUP_ADMIN);
		}
		foreach ($writegroup as $wgroup) {
			$imagecategoryperm =& $imagecategoryperm_handler->create();
			$imagecategoryperm->setVar('gperm_groupid', $wgroup);
			$imagecategoryperm->setVar('gperm_itemid', $imgcat_id);
			$imagecategoryperm->setVar('gperm_name', 'imgcat_write');
			$imagecategoryperm->setVar('gperm_modid', 1);
			$imagecategoryperm_handler->insert($imagecategoryperm);
			unset($imagecategoryperm);
		}
		redirect_header('admin.php?fct=images',2,_MD_AM_DBUPDATED);
	}

	if ($op == 'delfile') {
		xoops_cp_header();
		xoops_confirm(array('op' => 'delfileok', 'image_id' => $image_id, 'fct' => 'images'), 'admin.php', _MD_RUDELIMG);
		xoops_cp_footer();
		exit();
	}

	if ($op == 'delfileok') {
		$image_id = intval($image_id);
		if ($image_id <= 0) {
			redirect_header('admin.php?fct=images',1);
		}
		$image_handler =& xoops_gethandler('image');
		$image =& $image_handler->get($image_id);
		if (!is_object($image)) {
			redirect_header('admin.php?fct=images',1);
		}
		if (!$image_handler->delete($image)) {
			xoops_cp_header();
			xoops_error(sprintf(_MD_FAILDEL, $image->getVar('image_id')));
			xoops_cp_footer();
			exit();
		}
		@unlink(XOOPS_UPLOAD_PATH.'/'.$image->getVar('image_name'));
		redirect_header('admin.php?fct=images',2,_MD_AM_DBUPDATED);
	}

	if ($op == 'delcat') {
		xoops_cp_header();
		xoops_confirm(array('op' => 'delcatok', 'imgcat_id' => $imgcat_id, 'fct' => 'images'), 'admin.php', _MD_RUDELIMGCAT);
		xoops_cp_footer();
		exit();
	}

	if ($op == 'delcatok') {
		$imgcat_id = intval($imgcat_id);
		if ($imgcat_id <= 0) {
			redirect_header('admin.php?fct=images',1);
		}
		$imgcat_handler = xoops_gethandler('imagecategory');
		$imagecategory =& $imgcat_handler->get($imgcat_id);
		if (!is_object($imagecategory)) {
			redirect_header('admin.php?fct=images',1);
		}
		if ($imagecategory->getVar('imgcat_type') != 'C') {
			xoops_cp_header();
			xoops_error(_MD_SCATDELNG);
			xoops_cp_footer();
			exit();
		}
		$image_handler =& xoops_gethandler('image');
		$images =& $image_handler->getObjects(new Criteria('imgcat_id', $imgcat_id), true, false);
		$errors = array();
		foreach (array_keys($images) as $i) {
			if (!$image_handler->delete($images[$i])) {
				$errors[] = sprintf(_MD_FAILDEL, $i);
			} else {
				if (file_exists(XOOPS_UPLOAD_PATH.'/'.$images[$i]->getVar('image_name')) && !unlink(XOOPS_UPLOAD_PATH.'/'.$images[$i]->getVar('image_name'))) {
					$errors[] = sprintf(_MD_FAILUNLINK, $i);
				}
			}
		}
		if (!$imgcat_handler->delete($imagecategory)) {
			$errors[] = sprintf(_MD_FAILDELCAT, $imagecategory->getVar('imgcat_name'));
		}
		if (count($errors) > 0) {
			xoops_cp_header();
			xoops_error($errors);
			xoops_cp_footer();
			exit();
		}
		redirect_header('admin.php?fct=images',2,_MD_AM_DBUPDATED);
	}
}
?>

⌨️ 快捷键说明

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