📄 index.php
字号:
<?php
// $Id: index.php,v 1.7 2004/09/20 22:34:55 phppp Exp $
// ------------------------------------------------------------------------ //
// DIGEST for XOOPS //
// Copyright (c) 2004 Xoops China Community //
// <http://www.xoops.org.cn/> //
// ------------------------------------------------------------------------ //
// This program is free software; you can redistribute it and/or modify //
// it under the terms of the GNU General Public License as published by //
// the Free Software Foundation; either version 2 of the License, or //
// (at your option) any later version. //
// //
// You may not change or alter any portion of this comment or credits //
// of supporting developers from this source code or any supporting //
// source code which is considered copyrighted (c) material of the //
// original comment or credit authors. //
// //
// This program is distributed in the hope that it will be useful, //
// but WITHOUT ANY WARRANTY; without even the implied warranty of //
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the //
// GNU General Public License for more details. //
// //
// You should have received a copy of the GNU General Public License //
// along with this program; if not, write to the Free Software //
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA //
// ------------------------------------------------------------------------ //
// Author: D.J.(phppp) php_pp@hotmail.com //
// URL: http://xoops.org.cn //
// ------------------------------------------------------------------------- //
include '../../../include/cp_header.php';
include_once XOOPS_ROOT_PATH . "/class/xoopslists.php";
include_once XOOPS_ROOT_PATH."/class/xoopstree.php";
include_once(XOOPS_ROOT_PATH."/class/xoopsformloader.php");
include_once(XOOPS_ROOT_PATH.'/modules/digest/include/vars.php');
include_once(XOOPS_ROOT_PATH.'/modules/digest/include/functions.php');
include_once(XOOPS_ROOT_PATH.'/modules/digest/class/uploader.php');
define("_AM_DIGEST_CONFIG_LINK","<a href='index.php' target='_self'>"._AM_DIGEST_CONFIG."</a>");
$op = ( isset( $_GET['op'] ) )? $_GET['op']:'';
$digest_id = ( isset( $_GET['digest_id'] ) )?intval( $_GET['digest_id'] ):0;
if ( isset( $_POST ) ){
foreach ( $_POST as $k => $v ) {
${$k} = $v;
}
}
$action = empty($op)?"":$op;
$op = "";
$category_handler =& xoops_getmodulehandler('category', 'digest');
$digest_handler =& xoops_getmodulehandler('digest', 'digest');
xoops_cp_header();
echo "<h4>" . _AM_DIGEST_CONFIG_LINK . "</h4>";
function serverstatus()
{
global $module_handler, $xoopsModuleConfig;
$CURL_ok = (function_exists('curl_init'))? _AM_DIGEST_OK : _AM_DIGEST_NOK;
$fsockopen_ok = (function_exists('fsockopen')) ? _AM_DIGEST_OK : _AM_DIGEST_NOK;
$allow_url_fopen_ok = (ini_get('allow_url_fopen')) ? _AM_DIGEST_OK : _AM_DIGEST_NOK;
if(!is_object($module_handler)) $module_handler =& xoops_gethandler('module');
$iconv_ok = (function_exists("iconv"))? _AM_DIGEST_OK : _AM_DIGEST_NOK;
$xconv_ok = 0;
$xconv =& $module_handler->getByDirname('xconv');
if(is_object($xconv)) $xconv_ok = $xconv->getVar('isactive');
$xconv_ok = ($xconv_ok)? _AM_DIGEST_OK : _AM_DIGEST_NOK;
$module_ok = (($CURL_ok == _AM_DIGEST_OK)||($fsockopen_ok == _AM_DIGEST_OK)||($allow_url_fopen_ok == _AM_DIGEST_OK))? _AM_DIGEST_MODULE_OK : _AM_DIGEST_MODULE_NOK;
$langconv_ok = (($iconv_ok == _AM_DIGEST_OK)||($xconv_ok == _AM_DIGEST_OK))? _AM_DIGEST_LANGCONV_OK : _AM_DIGEST_LANGCONV_NOK;
$imagepath_ok = (@is_writable(XOOPS_ROOT_PATH.'/'.$xoopsModuleConfig['image_path']))? _AM_DIGEST_OK : _AM_DIGEST_NOK;
$updateapi_ok = (@is_readable(DIGEST_API_FILE))? _AM_DIGEST_OK : _AM_DIGEST_NOK;
$sform = new XoopsThemeForm(_AM_DIGEST_SERVERSTATUS, "", "");
$sform -> addElement(new XoopsFormLabel(_AM_DIGEST_CURL, $CURL_ok));
$sform -> addElement(new XoopsFormLabel(_AM_DIGEST_FSOCKOPEN, $fsockopen_ok));
$sform -> addElement(new XoopsFormLabel(_AM_DIGEST_ALLOW_URL_FOPEN, $allow_url_fopen_ok));
$sform -> addElement(new XoopsFormLabel('=>'._AM_DIGEST_MODULE, $module_ok));
$sform -> addElement(new XoopsFormLabel(_AM_DIGEST_ICONV, $iconv_ok));
$sform -> addElement(new XoopsFormLabel(_AM_DIGEST_XCONV, $xconv_ok));
$sform -> addElement(new XoopsFormLabel('=>'._AM_DIGEST_LANGCONV, $langconv_ok));
$sform -> addElement(new XoopsFormLabel(_AM_DIGEST_IMAGEPATH.'<br />'.XOOPS_ROOT_PATH.'/<strong>'.$xoopsModuleConfig['image_path'].'</strong>', $imagepath_ok.'<br /><a href=index.php?op=createimagepath>'._AM_DIGEST_CREATE_IMAGEPATH.'</a>'));
$sform -> addElement(new XoopsFormLabel(_AM_DIGEST_UPDATEAPI.'<br />'.DIGEST_API_FILE.' <a href="#" title="'._AM_DIGEST_UPDATEAPI_DESC.'"><strong>?</strong></a>', $updateapi_ok.'<br /><a href=index.php?op=createapi>'._AM_DIGEST_CREATE_APIFILE.'</a>'));
$sform -> display();
}
function digestList()
{
global $digest_handler, $category_id;
$digestarray =& $digest_handler->getByCategory($category_id, '', false);
if ( is_array($digestarray)&&count( $digestarray ) > 0 ){
echo "<table border='0' width='100%' cellpadding = '2' cellspacing ='1' class = 'outer'>";
echo "<tr><td align='center' colspan='6' class='even'>" . _AM_DIGEST_DIGESTLIST . "</td></tr>";
echo "<tr>";
echo "<td class = 'head' align='center' height ='16px' ><strong>ID</strong></td>";
echo "<td class = 'head' align='left'><strong>" . _AM_DIGEST_TITLE . "</strong></td>";
echo "<td class = 'head' align='center' width='5%'>" . _EDIT . "</td>";
echo "<td class = 'head' align='center' width='5%'>" . _DELETE . "</td>";
echo "<td class = 'head' align='center'>" . _AM_DIGEST_UPDATE . "</td>";
echo "<td class = 'head' align='center' width='5%'>" . _AM_DIGEST_EMPTY . "</td>";
echo "</tr>\n";
$cid = 0;
foreach( $digestarray as $digest ) {
if($cid && $cid != $digest -> getVar('category_id')){
echo "<tr><td class = 'even' colspan='6' height='10px'></td></tr>";
}
$cid = $digest -> getVar('category_id');
echo "<tr>\n";
echo "<td class = 'odd' nowrap>" . $cid . " -- " . $digest -> getVar('digest_id') . "</td>\n";
echo "<td class = 'odd'><a href='" . $digest -> getVar('url') . "' target='_blank'>" . $digest -> getVar('title') . "</a> : ".$digest -> getVar('description')."</td>\n";
echo "<td class = 'odd'><a href='index.php?op=edit&digest_id=" . $digest -> getVar('digest_id') . "'>" . _EDIT . "</a></td>\n";
echo "<td class = 'odd'><a href='index.php?op=delete&digest_id=" . $digest -> getVar('digest_id') . "'>" . _DELETE . "</a></td>\n";
echo "<td class = 'odd'><a href='index.php?op=update&digest_id=" . $digest -> getVar('digest_id') . "'>" . formatTimestamp($digest -> getVar('lastupdate'),"Y-m-d H:i") . "</a> ->".formatTimestamp($digest -> getVar('lastupdate') +$digest -> getVar('updatetime') * 60,"d-H:i")."</td>\n";
echo "<td class = 'odd'><a href='index.php?op=empty&digest_id=" . $digest -> getVar('digest_id') . "'>" . _AM_DIGEST_EMPTY . "</a></td>\n";
echo "</tr>";
}
echo"</table>";
echo "<br />";
}
}
function CategoryList()
{
global $category_handler, $category_id;
$categoryarray = $category_handler->getAll();
if ( count($categoryarray) > 0 )
{
echo "<table border='0' width='100%' cellpadding = '2' cellspacing ='1' class = 'outer'>";
echo "<tr><td align='center' colspan='6' class='even'>" . _AM_DIGEST_CATEGORYLIST . "</td></tr>";
echo "<tr>";
echo "<td class = 'head' align='center' height ='16px' ><strong>ID</strong></td>";
echo "<td class = 'head' align='left'><strong>" . _AM_DIGEST_TITLE . "</strong></td>";
echo "<td class = 'head' align='center' width='5%'>" . _EDIT . "</td>";
echo "<td class = 'head' align='center' width='5%'>" . _DELETE . "</td>";
echo "</tr>\n";
foreach( $categoryarray as $category ) {
echo "<tr>\n";
echo "<td class = 'odd' nowrap>" . $category -> getVar('category_id') . "</td>\n";
echo "<td class = 'odd'>" . $category -> getVar('title') ."</td>\n";
echo "<td class = 'odd'><a href='index.php?op=modCategory&category_id=" . $category -> getVar('category_id') . "'>" . _EDIT . "</a></td>\n";
echo "<td class = 'odd'><a href='index.php?op=delCategory&category_id=" . $category -> getVar('category_id') . "'>" . _DELETE . "</a></td>\n";
echo "</tr>";
}
echo"</table>";
echo "<br />";
}
}
switch ( $action )
{
case "edit":
echo "<br />";
echo "<h4>" . _AM_DIGEST_EDITSITE . "</h4>";
$digest = & $digest_handler->get( $digest_id );
$title = $digest ->getVar('title', 'Edit');
$url = $digest ->getVar('url', 'Edit');
$description = $digest ->getVar('description', 'Edit');
$image = $digest ->getVar('image', 'Edit');
$charset = $digest ->getVar('charset', 'Edit');
$charset_inter = $digest ->getVar('charset_inter', 'Edit');
$reg_exp = $digest ->getVar('reg_exp', 'Edit');
$criteria = $digest ->getVar('criteria', 'Edit');
$digest_order = $digest ->getVar('digest_order');
$online = $digest ->getVar('online');
$offset = $digest ->getVar('offset');
$maxitems = $digest ->getVar('maxitems');
$minlength = $digest ->getVar('minlength');
$updatetime = $digest ->getVar('updatetime');
$category_id = $digest ->getVar('category_id');
include "../include/digestform.inc.php";
break;
case "siteManager":
digestList();
echo "<br />";
echo "<h4>" . _AM_DIGEST_NEWSITE . "</h4>";
$title = '';
$url = '';
$description = '';
$image = '';
$charset = '';
$charset_inter = '';
$reg_exp = '';
$criteria = '';
$digest_order = 1;
$online = 1;
$offset = 0;
$maxitems = 20;
$minlength = 20;
$updatetime = 60;
$category_id = 0;
include "../include/digestform.inc.php";
break;
case "update":
$digest = $digest_handler->get( $digest_id );
$digest_handler->update( $digest, true );
redirect_header( 'index.php?op=siteManager', 1, _AM_DIGEST_DBUPDATED );
exit();
break;
case "empty":
$digest = & $digest_handler->get( $digest_id );
$digest -> emptyItems();
redirect_header( 'index.php?op=siteManager', 1, _AM_DIGEST_DBUPDATED );
exit();
break;
case "save":
$error_upload = '';
if (!empty($_FILES['userfile']['name'])) {
$uploader = new digest_uploader(
XOOPS_ROOT_PATH . "/".$xoopsModuleConfig['image_path'],
$xoopsModuleConfig['allowed_extension']
);
if ( $uploader->fetchMedia( $_POST['xoops_upload_file'][0]) ) {
if ( !$uploader->upload() ){
$error_upload = $uploader->getErrors();
}elseif ( is_file( $uploader->getSavedDestination() )){
$image = $uploader->getSavedFileName();
}
}else{
$error_upload = $uploader->getErrors();
}
}
$image = empty($image)?(empty($_POST['image'])?"":$_POST['image']):$image;
if ( empty( $digest_id ) ) $digest = & $digest_handler->create();
else $digest = & $digest_handler->get( $digest_id );
$digest -> setVar( 'category_id', $category_id );
$digest -> setVar( 'title', $title );
$digest -> setVar( 'online', $online );
$digest -> setVar( 'digest_order', $digest_order );
$digest -> setVar( 'url', $url );
$digest -> setVar( 'description', $description );
$digest -> setVar( 'image', $image );
$digest -> setVar( 'offset', $offset );
$digest -> setVar( 'maxitems', $maxitems );
$digest -> setVar( 'minlength', $minlength );
$digest -> setVar( 'charset', $charset );
$digest -> setVar( 'charset_inter', $charset_inter );
$digest -> setVar( 'reg_exp', $reg_exp );
$digest -> setVar( 'criteria', $criteria );
$digest -> setVar( 'updatetime', $updatetime );
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -