index.php

来自「php 开发的内容管理系统」· PHP 代码 · 共 200 行

PHP
200
字号
<?php
// $Id: index.php,v 1.1.1.1 2005/11/10 19:51:04 phppp Exp $
// ------------------------------------------------------------------------ //
// 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: phppp (D.J., infomax@gmail.com)                                  //
// URL: http://xoopsforge.com, http://xoops.org.cn                          //
// Project: Article Project                                                 //
// ------------------------------------------------------------------------ //
include('header.php');

/**
 * Function to check status of a folder
 *
 * @return bool
 */
function art_admin_getPathStatus($path)
{
	if(empty($path)) return false;
	if(@is_writable($path)){
		$path_status = art_constant("AM_AVAILABLE");
	}elseif(!@is_dir($path)){
		$path_status = "<font color=\"red\">".art_constant("AM_NOTAVAILABLE")."</font> <a href=".XOOPS_URL."/modules/".$GLOBALS["artdirname"]."/admin/index.php?op=createdir&amp;path=$path>".art_constant("AM_CREATETHEDIR")."</a>";
	}else{
		$path_status = "<font color=\"red\">".art_constant("AM_NOTWRITABLE")."</font> <a href=".XOOPS_URL."/modules/".$GLOBALS["artdirname"]."/admin/index.php?op=setperm&amp;path=$path>".art_constant("AM_SETMPERM")."</a>";
	}
	return $path_status;
}

/**
 * Function to create directory tree recursively
 *
 * From http://www.php.net/manual/en/function.mkdir.php
 * ".." in path is filtered out however the fullpath is not checked since the action is assumed to access by admin only, which is reasonably trustable
 * 
 *
 * @return bool
 */
function art_admin_mkdir($strPath, $mode = 0777)
{
	$strPath = str_replace("..", "", $strPath);
	return is_dir($strPath) or ( art_admin_mkdir(dirname($strPath), $mode) and @mkdir($strPath, $mode) );
}

function art_admin_chmod($target, $mode = 0777)
{
	$target = str_replace("..", "", $target);
	return @chmod($target, $mode);
}

xoops_cp_header();

$op = (isset($_GET['op']))? $_GET['op'] : "";

switch ($op) {
    case "createdir":
		if (isset($_GET['path'])) $path = $_GET['path'];
        $res = art_admin_mkdir($path);
        $msg = ($res) ? art_constant("AM_DIRCREATED") : art_constant("AM_DIRNOTCREATED");
        redirect_header('index.php', 2, $msg . ': ' . $path);
        exit();
        break;

    case "setperm":
		if (isset($_GET['path'])) $path = $_GET['path'];
        $res = art_admin_chmod($path, 0777);
        $msg = ($res) ? art_constant("AM_PERMSET") : art_constant("AM_PERMNOTSET");
        redirect_header('index.php', 2, $msg . ': ' . $path);
        exit();
        break;

    case "default":
    default:
    break;
}


loadModuleAdminMenu(0);

echo "
	<style type=\"text/css\">
	label,text {
		display: block;
		float: left;
		margin-bottom: 2px;
	}
	label {
		text-align: right;
		width: 150px;
		padding-right: 20px;
	}
	br {
		clear: left;
	}
	</style>
";

echo "<fieldset><legend style='font-weight: bold; color: #900;'>" . art_constant("AM_PREFERENCES") . "</legend>";
echo "<div style='padding: 8px;'>";
echo "<label>" . "<strong>PHP Version:</strong>" . ":</label><text>" . phpversion() . "</text><br />";
echo "<label>" . "<strong>MySQL Version:</strong>" . ":</label><text>" . mysql_get_server_info() . "</text><br />";
echo "<label>" . "<strong>XOOPS Version:</strong>" . ":</label><text>" . XOOPS_VERSION . "</text><br />";
echo "<label>" . "<strong>Module Version:</strong>" . ":</label><text>" . $xoopsModule->getInfo('version') . "</text><br />";
echo "</div>";
echo "<div style='padding: 8px;'>";
echo "<label>" . art_constant("AM_SAFEMODE") . ":</label><text>";
echo ( ini_get( 'safe_mode' ) ) ? art_constant("AM_ON") : art_constant("AM_OFF");
echo "</text><br />";
echo "<label>" . art_constant("AM_REGISTERGLOBALS") . ":</label><text>";
echo ( ini_get( 'register_globals' )) ? art_constant("AM_ON") : art_constant("AM_OFF");
echo "</text><br />";
echo "<label>" . art_constant("AM_MAGICQUOTESGPC") . ":</label><text>";
echo ( ini_get( 'magic_quotes_gpc' )) ? art_constant("AM_ON") : art_constant("AM_OFF");
echo "</text><br />";
echo "<label>" . art_constant("AM_MAXPOSTSIZE") .":</label><text>". ini_get( 'post_max_size' );
echo "</text><br />";
echo "<label>" . art_constant("AM_MAXINPUTTIME") .":</label><text>". ini_get( 'max_input_time' );
echo "</text><br />";
echo "<label>" . art_constant("AM_OUTPUTBUFFERING") .":</label><text>". ini_get( 'output_buffering' );
echo "</text><br />";
echo "<label>" . art_constant("AM_XML_EXTENSION") .":</label><text>";
echo ( extension_loaded( 'xml' )) ? art_constant("AM_ON") : art_constant("AM_OFF");
echo "</text><br />";
echo "<label>" . art_constant("AM_MB_EXTENSION") .":</label><text>";
echo ( extension_loaded( 'mbstring' )) ? art_constant("AM_ON") : art_constant("AM_OFF");
echo "</text><br />";
echo "<label>" . art_constant("AM_CURL") .":</label><text>";
echo ( function_exists('curl_init')) ? art_constant("AM_ON") : art_constant("AM_OFF");
echo "</text><br />";
echo "<label>" . art_constant("AM_FSOCKOPEN") .":</label><text>";
echo ( function_exists('fsockopen')) ? art_constant("AM_ON") : art_constant("AM_OFF");
echo "</text><br />";
echo "<label>" . art_constant("AM_URLFOPEN") .":</label><text>";
echo ( ini_get('allow_url_fopen')) ? art_constant("AM_ON") : art_constant("AM_OFF");
echo "</text><br />";
echo "</div>";

echo "<div style='padding: 8px;'>";
$path_image = XOOPS_ROOT_PATH . '/' . $xoopsModuleConfig['path_image'] . '/';
$path_status = art_admin_getPathStatus($path_image);
echo "<label>" . art_constant("AM_PATH_IMAGE") .":</label><text>". $path_image . ' ( ' . $path_status . ' )';
echo "</text><br />";
$path_file = XOOPS_ROOT_PATH . '/' . $xoopsModuleConfig['path_file'] . '/';
$path_status = art_admin_getPathStatus($path_file);
echo "<label>" . art_constant("AM_PATH_FILE") .":</label><text>". $path_file . ' ( ' . $path_status . ' )';
echo "</text><br />";
echo "</div>";
echo "</fieldset><br />";

echo "<fieldset><legend style='font-weight: bold; color: #900;'>" . art_constant("AM_STATS") . "</legend>";
echo "<div style='padding: 8px;'>";
$category_handler =& xoops_getmodulehandler('category', $GLOBALS["artdirname"]);
$category_count = $category_handler->getCount();
$topic_handler =& xoops_getmodulehandler("topic", $GLOBALS["artdirname"]);
$topic_count = $topic_handler->getCount();
$article_handler =& xoops_getmodulehandler('article', $GLOBALS["artdirname"]);
$article_count = $article_handler->getCount(new Criteria("art_time_publish", 0, ">"));
$category = 0;
$article_submitted = $category_handler->getArticleCountRegistered($category);
$article_published = $category_handler->getArticleCountPublished($category);
$article_featured = $category_handler->getArticleCountFeatured($category);
echo "<label>" . art_constant("AM_TOTAL_CATEGORIES") .":</label><text>". $category_count;
echo "</text><br />";
echo "<label>" . art_constant("AM_TOTAL_TOPICS") .":</label><text>". $topic_count;
echo "</text><br />";
echo "<label>" . art_constant("AM_TOTAL_ARTICLES") .":</label><text>".$article_count;
if($article_submitted>0) $art_extra = "<a href=\"admin.article.php\"><font color=\"red\">". $article_submitted."</font></a> ";
else $art_extra = "0";
$art_extra .= " | ".intval($article_published)." | ".intval($article_featured);
echo " ( ".$art_extra." )";
echo "</text><br />";
$article_stats =& $article_handler->getStats();
echo "<label>" . art_constant("AM_TOTAL_AUTHORS") .":</label><text>".$article_stats['authors'];
echo "</text><br />";
echo "<label>" . art_constant("AM_TOTAL_VIEWS") .":</label><text>".$article_stats['views'];
echo "</text><br />";
echo "<label>" . art_constant("AM_TOTAL_RATES") .":</label><text>".$article_stats['rates'];
echo "</text>";
echo "</div>";
echo "</fieldset>";

xoops_cp_footer();
?>

⌨️ 快捷键说明

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