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

📄 main.php

📁 在综合英文版XOOPS 2.09, 2.091, 2.092 的基础上正式发布XOOPS 2.09中文版 XOOPS 2.09x 版主要是PHP5升级、bug修正和安全补正: 1 全面兼容PHP 5.
💻 PHP
📖 第 1 页 / 共 5 页
字号:
									$new_image->setVar('imgsetimg_imgset', $new_imgsetid);
									if (!$image_handler->insert($new_image)) {
										$msgs[] = '&nbsp;&nbsp;<span style="color:#ff0000;">错误: 图形文件 <b>'.$orig_images[$j]->getVar('imgsetimg_file').'</b>的数据复制出错.</span>';
									} else {
										$thisimage = $orig_images[$j]->getVar('imgsetimg_file');
										$msgs[] = '&nbsp;&nbsp;图形文件 <b>'.$thisimage.'</b>数据复制完毕.</span>';
									}
								}
								if (!$imageset_handler->linktplset($new_imgsetid, $newtheme)) {
									$msgs[] = '&nbsp;&nbsp;<span style="color:#ff0000;">错误: 无法在模板图片集 (ID : <b>'.$new_imgsetid.'</b>) 和模板 <b>'.$newtheme.'</b>之间建立有效连接.</span>';
								} else {
									$msgs[] = '&nbsp;&nbsp;模板图片集 (ID: <b>'.$new_imgsetid.'</b>) and 模板<b>'.$newtheme.'</b> linked.</span>';
								}
							}
						} else {
							// module image set, so just create another link to the new template set
							if (!$imageset_handler->linktplset($orig_imgset[$i]->getVar('imgset_id'), $newtheme)) {
								$msgs[] = '&nbsp;&nbsp;<span style="color:#ff0000;">错误: 无法在图片集 <b>'.$orig_imgset[$i]->getVar('imgset_name').'</b> (ID <b>'.$orig_imgset[$i]->getVar('imgset_id').'</b>) 和模板<b>'.$newtheme.'</b>之间建立有效连接.</span>';
							} else {
								$msgs[] = '&nbsp;&nbsp;图片集 <b>'.$orig_imgset[$i]->getVar('imgset_name').'</b> (ID <b>'.$orig_imgset[$i]->getVar('imgset_id').'</b>) 和模板<b>'.$newtheme.'</b> 之间的连接建立成功.';
							}
						}
					}
*/
					$msgs[] = '模板<b>'.$newtheme.'</b>创建完毕. (ID: <b>'.$tplsetid.'</b>)<br />';
				} else {
					$msgs[] = '<span style="color:#ff0000;">错误: '.$theme.'的模板文件不存在</span>';
				}
			}
		}
		foreach ($msgs as $msg) {
			echo '<code>'.$msg.'</code><br />';
		}
		echo '<br /><a href="admin.php?fct=tplsets">'._MD_AM_BTOTADMIN.'</a>';
		xoops_cp_footer();
		break;
/*
	case 'editimage':
		xoops_cp_header();
		echo '<a href="admin.php?fct=tplsets">'. _MD_TPLMAIN .'</a>&nbsp;<span style="font-weight:bold;">&raquo;&raquo;</span>&nbsp;'._MD_EDITSKINIMG.' ('.$tplset.')<br /><br />';
		include XOOPS_ROOT_PATH.'/modules/system/admin/tplsets/tplimgform.php';
		xoops_cp_footer();
		break;
	case 'updateimage':
		$tplset = trim($tplset);
		$err = array();
		if ($tplset != 'default') {
			include_once XOOPS_ROOT_PATH.'/class/uploader.php';
			$mimetypes = array('image/gif', "image/pjpeg", "image/jpeg", "image/jpeg", "image/jpeg", "image/png", 'image/x-png', "application/x-shockwave-flash", "image/tiff", "image/tiff", 'image/bmp');
			if ($tplset == $xoopsConfig['template_set']) {
				//directly upload to cache to reduce one step ;-)
				$uploader = new XoopsMediaUploader(XOOPS_CACHE_PATH, $mimetypes, 500000);
			} else {
				$uploader = new XoopsMediaUploader(XOOPS_UPLOAD_PATH, $mimetypes, 500000);
			}
			$image_handler =& xoops_gethandler('imagesetimg');
			foreach ($imgids as $id) {
				if (isset($imgfiles[$id]) && trim($imgfiles[$id]) != '') {
					if ($uploader->fetchMedia('imgfiles', $id)) {
						$image =& $image_handler->get($id);
						$uploader->setTargetFileName($image->getVar('imgsetimg_file'));
						if (!$uploader->upload()) {
							$err[] = $uploader->getErrors();
						} else {
							$fp = @fopen($uploader->getSavedDestination(), 'rb');
							$image->setVar('imgsetimg_body', @fread($fp, filesize($uploader->getSavedDestination())), true);
							@fclose($fp);
							if ($tplset != $xoopsConfig['template_set']) {
								@unlink($uploader->getSavedDestination());
							}
							if (!$image_handler->insert($image)) {
								$err[] = 'Could not save '.$image->getVar('imgsetimg_file');
							}
						}
					} else {
						$err[] = $uploader->getErrors();
					}
				} elseif (!empty($imgdelete[$id])) {
					$image =& $image_handler->get($id);
					if (!$image_handler->delete($image)) {
						$err[] = 'Could not remove image file '.$image->getVar('imgsetimg_file');
					} else {
						if ($tplset == $xoopsConfig['template_set']) {
							@unlink(XOOPS_CACHE_PATH.'/'.$image->getVar('imgsetimg_file'));
						}
					}
				}
			}
		} else {
			$err[] = 'Cannot change XOOPS system default theme set images';
		}
		// delete image set if no more images
		$current_imgs =& $image_handler->getByImageset($imgset);
		if (count($current_imgs) == 0) {
			$imageset_handler =& xoops_gethandler('imageset');
			$imgset =& $imageset_handler->get($imgset);
			if (!$imageset_handler->delete($imgset)) {
				$err[] = '无法删除图片集 '.$imgset->getVar('imgset_name');
			}
		}
		if (count($err) > 0) {
			xoops_cp_header();
			xoops_error($err);
			xoops_cp_footer();
		} else {
			redirect_header('admin.php?fct=tplsets&amp;op=editimage&amp;tplset='.$tplset, 2, _MD_AM_DBUPDATED);
		}
		break;
	case 'addimage':
		$tplset = trim($tplset);
		$err = array();
		if ($tplset != 'default') {
			include_once XOOPS_ROOT_PATH.'/class/uploader.php';
			$mimetypes = array('image/gif', "image/pjpeg", "image/jpeg", "image/jpeg", "image/jpeg", "image/png", 'image/x-png', "application/x-shockwave-flash", "image/tiff", "image/tiff", 'image/bmp');
			if ($tplset == $xoopsConfig['template_set']) {
				//directly upload to cache to reduce one step ;-)
				$uploader = new XoopsMediaUploader(XOOPS_CACHE_PATH, $mimetypes, 500000);
			} else {
				$uploader = new XoopsMediaUploader(XOOPS_UPLOAD_PATH, $mimetypes, 500000);
			}
			$image_handler =& xoops_gethandler('imagesetimg');
			if ($uploader->fetchMedia('imgfile')) {

				if (!empty($imgset)) {
					//check if an image with the same name exists
					if ($image_handler->imageExists($uploader->getMediaName(), $imgset)) {
						$err[] = '图片文件'.$uploader->getMediaName().'已存在';
					}
				}
				if (empty($err)) {
					$image =& $image_handler->create();
					if (!$uploader->upload()) {
						$err[] = $uploader->getErrors();
					} else {
						if (!$fp = @fopen($uploader->getSavedDestination(), 'rb')) {
							$err[] = 'Could not read '.$uploader->getSavedFileName();
						} else {
							$image->setVar('imgsetimg_body', @fread($fp, filesize($uploader->getSavedDestination())), true);
							@fclose($fp);
							if ($tplset != $xoopsConfig['template_set']) {
								@unlink($uploader->getSavedDestination());
							}
							$image->setVar('imgsetimg_file', $uploader->getSavedFileName());
							if (!empty($imgset)) {
								$image->setVar('imgsetimg_imgset', $imgset);
							} else {
								$imageset_handler =& xoops_gethandler('imageset');
								$imgset =& $imageset_handler->create();
								$imgset->setVar('imgset_name', $tplset);
								$imgset->setVar('imgset_refid', 0);
								if (!$imageset_handler->insert($imgset)) {
									$err[] = '无法创建图片集.';
								} else {
									$newimgsetid = $imgset->getVar('imgset_id');
									$image->setVar('imgsetimg_imgset', $newimgsetid);
									if (!$imageset_handler->linktplset($newimgsetid, $tplset)) {
										$err[] = '无法将图片集与模板'.$tplset.'对应';
									}
								}
							}
							if (count($err) == 0) {
								if (!$image_handler->insert($image)) {
									$err[] = 'Could not save '.$image->getVar('imgsetimg_file');
								}
							}
						}
					}
				}
			} else {
				$err[] = $uploader->getErrors();
			}
		}
		if (count($err) > 0) {
			xoops_cp_header();
			xoops_error($err);
			xoops_cp_footer();
		} else {
			redirect_header('admin.php?fct=tplsets&amp;op=editimage&amp;tplset='.$tplset, 2, _MD_AM_DBUPDATED);
		}
		break;
	case 'showimage':
		$image_id = isset($_GET['id']) ? intval($_GET['id']) : 0;
		if (empty($image_id)) {
			header('Content-type: image/gif');
			readfile(XOOPS_UPLOAD_PATH.'/blank.gif');
			exit();
		}
		$image_handler =& xoops_gethandler('imagesetimg');
		$image =& $image_handler->getObjects(new Criteria('imgsetimg_id', $image_id));
		if (count($image) > 0) {
			$mimetypes = array('gif' => 'image/gif', "jpe"=>"image/jpeg", "jpeg"=>"image/jpeg", "jpg"=>"image/jpeg", "png"=>"image/png", "swf"=>"application/x-shockwave-flash", "tif"=>"image/tiff", "tiff"=>"image/tiff", "bmp" => 'image/bmp');
			$ext = substr(strtolower(strrchr($image[0]->getVar('imgsetimg_file'), '.')), 1);
			if (in_array($ext, array_keys($mimetypes))) {
				header('Content-type: '.$mimetypes[$ext]);
			}
			header('Cache-control: max-age=31536000');
			header('Expires: '.gmdate("D, d M Y H:i:s",time()+31536000).'GMT');
			header('Content-disposition: filename='.$image[0]->getVar('imgsetimg_file'));
			header('Content-Length: '.strlen($image[0]->getVar('imgsetimg_body')));
			header('Last-Modified: '.gmdate("D, d M Y H:i:s", time()).'GMT');
			echo $image[0]->getVar('imgsetimg_body');
		} else {
			header('Content-type: image/gif');
			readfile(XOOPS_UPLOAD_PATH.'/blank.gif');
		}
		break;
*/
	case 'viewdefault':
		$tpltpl_handler =& xoops_gethandler('tplfile');
		$tplfile =& $tpltpl_handler->get($id);
		$default =& $tpltpl_handler->find('default', $tplfile->getVar('tpl_type'), $tplfile->getVar('tpl_refid'), null, $tplfile->getVar('tpl_file'));
		echo "<!DOCTYPE html PUBLIC '-//W3C//DTD XHTML 1.0 Transitional//EN' 'http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd'>";
		echo '<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="'._LANGCODE.'" lang="'._LANGCODE.'">
		<head>
		<meta http-equiv="content-type" content="text/html; charset='._CHARSET.'" />
		<meta http-equiv="content-language" content="'._LANGCODE.'" />
		<title>'.$xoopsConfig['sitename'].' Administration</title>
		<link rel="stylesheet" type="text/css" media="all" href="'.XOOPS_URL.'/xoops.css" />
        	<link rel="stylesheet" type="text/css" media="all" href="'.XOOPS_URL.'/modules/system/style.css" />
		</head><body>';
		if (is_object($default[0])) {
			$tpltpl_handler->loadSource($default[0]);
			$last_modified = $default[0]->getVar('tpl_lastmodified');
			$last_imported = $default[0]->getVar('tpl_lastimported');
			if ($default[0]->getVar('tpl_type') == 'block') {
				$path = XOOPS_ROOT_PATH.'/modules/'.$default[0]->getVar('tpl_module').'/blocks/'.$default[0]->getVar('tpl_file');
			} else {
				$path = XOOPS_ROOT_PATH.'/modules/'.$default[0]->getVar('tpl_module').'/'.$default[0]->getVar('tpl_file');
			}
			$colorchange = '';
			if (!file_exists($path)) {
				$filemodified_date = _MD_NOFILE;
				$lastimported_date = _MD_NOFILE;
			} else {
				$tpl_modified = filemtime($path);
				$filemodified_date = formatTimestamp($tpl_modified, 'l');
				if ($tpl_modified > $last_imported) {
					$colorchange = ' bgcolor="#ffCC99"';
				}
				$lastimported_date = formatTimestamp($last_imported, 'l');
			}
			include_once XOOPS_ROOT_PATH.'/class/xoopsformloader.php';
			$form = new XoopsThemeForm(_MD_VIEWDEFAULT, 'template_form', 'admin.php');
			$form->addElement(new XoopsFormTextArea(_MD_FILEHTML, 'html', $default[0]->getVar('tpl_source'), 25));
			$form->display();
		} else {
			echo '所选文件不存在';
		}
		echo '<div style="text-align:center;">[<a href="#" onclick="javascript:window.close();">'._CLOSE.'</a>]</div></body></html>';
		break;
	case 'downloadtpl':
		$tpltpl_handler =& xoops_gethandler('tplfile');
		$tpl =& $tpltpl_handler->get(intval($id), true);
		if (is_object($tpl)) {
			$output = $tpl->getVar('tpl_source');
			strlen($output);
			header('Cache-Control: no-cache, must-revalidate');
			header('Pragma: no-cache');
			header('Content-Type: application/force-download');
			if (preg_match("/MSIE 5.5/", $_SERVER['HTTP_USER_AGENT'])) { 
				header('Content-Disposition: filename='.$tpl->getVar('tpl_file')); 
			} else {
				header('Content-Disposition: attachment; filename='.$tpl->getVar('tpl_file'));

⌨️ 快捷键说明

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