📄 main.php
字号:
} 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[] = 'Image file '.$uploader->getMediaName().' already exists'; } } 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[] = 'Could not create image set.'; } else { $newimgsetid = $imgset->getVar('imgset_id'); $image->setVar('imgsetimg_imgset', $newimgsetid); if (!$imageset_handler->linktplset($newimgsetid, $tplset)) { $err[] = 'Failed linking image set to template set '.$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&op=editimage&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>'.htmlspecialchars($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 'Selected file does not exist'; } 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')); } header('Content-length: '.strlen($output)); echo $output; } break; case 'uploadtpl': $tpltpl_handler =& xoops_gethandler('tplfile'); $id = intval($_GET['id']); $tpl =& $tpltpl_handler->get($id); xoops_cp_header(); echo '<a href="admin.php?fct=tplsets">'. _MD_TPLMAIN .'</a> <span style="font-weight:bold;">»»</span> <a href="./admin.php?fct=tplsets&op=listtpl&moddir='.$tpl->getVar('tpl_module').'&tplset='.$tpl->getVar('tpl_tplset').'">'.$tpl->getVar('tpl_tplset').'</a> <span style="font-weight:bold;">»»</span> '._MD_UPLOAD.'<br /><br />'; if (is_object($tpl)) { include_once XOOPS_ROOT_PATH.'/class/xoopsformloader.php'; $form = new XoopsThemeForm(_MD_UPLOAD, 'tplupload_form', 'admin.php', 'post', true); $form->setExtra('enctype="multipart/form-data"'); $form->addElement(new XoopsFormLabel(_MD_FILENAME, $tpl->getVar('tpl_file').' ('.$tpl->getVar('tpl_tplset').')')); $form->addElement(new XoopsFormFile(_MD_CHOOSEFILE.'<br /><span style="color:#ff0000;">'._MD_UPWILLREPLACE.'</span>', 'tpl_upload', 200000), true); $form->addElement(new XoopsFormHidden('tpl_id', $id)); $form->addElement(new XoopsFormHidden('op', 'uploadtpl_go')); $form->addElement(new XoopsFormHidden('fct', 'tplsets')); $form->addElement(new XoopsFormButton('', 'upload_button', _MD_UPLOAD, 'submit')); $form->display(); xoops_cp_footer(); exit(); } else { echo 'Selected template does not exist'; } xoops_cp_footer(); break; case 'uploadtpl_go': if (!$GLOBALS['xoopsSecurity']->check()) { redirect_header('admin.php?fct=tplsets', 1, implode('<br />', $GLOBALS['xoopsSecurity']->getErrors())); } $tpltpl_handler =& xoops_gethandler('tplfile'); $tpl =& $tpltpl_handler->get($tpl_id); if (is_object($tpl)) { include_once XOOPS_ROOT_PATH.'/class/uploader.php'; $uploader = new XoopsMediaUploader(XOOPS_UPLOAD_PATH, array('text/html', 'application/x-cdf', 'text/plain'), 200000); $uploader->setPrefix('tmp'); if ($uploader->fetchMedia($_POST['xoops_upload_file'][0])) { if (!$uploader->upload()) { $err = $uploader->getErrors(); } else { $tpl->setVar('tpl_lastmodified', time()); $fp = @fopen($uploader->getSavedDestination(), 'r'); $fsource = @fread($fp, filesize($uploader->getSavedDestination())); @fclose($fp); $tpl->setVar('tpl_source', $fsource, true); @unlink($uploader->getSavedDestination()); if (!$tpltpl_handler->insert($tpl)) { $err = 'Failed inserting data to database'; } else { if ($tpl->getVar('tpl_tplset') == $xoopsConfig['template_set']) { include_once XOOPS_ROOT_PATH.'/class/template.php'; xoops_template_touch($tpl_id, true); } } } } else { $err = implode('<br />', $uploader->getErrors(false)); } if (isset($err)) { xoops_cp_header(false); xoops_error($err); xoops_cp_footer(); exit(); } redirect_header('admin.php?fct=tplsets&op=listtpl&moddir='.$tpl->getVar('tpl_module').'&tplset='.urlencode($tpl->getVar('tpl_tplset')), 2, _MD_AM_DBUPDATED); } break; // upload new file
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -