report.php
来自「php 开发的内容管理系统」· PHP 代码 · 共 125 行
PHP
125 行
<?php
// $Id: report.php,v 1.3 2005/10/19 17:20:32 phppp Exp $
// ------------------------------------------------------------------------ //
// XOOPS - PHP Content Management System //
// Copyright (c) 2000 XOOPS.org //
// <http://www.xoops.org/> //
// ------------------------------------------------------------------------ //
// 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 //
// ------------------------------------------------------------------------ //
if (!defined("XOOPS_ROOT_PATH")) {
exit();
}
defined("NEWBB_FUNCTIONS_INI") || include XOOPS_ROOT_PATH.'/modules/newbb/include/functions.ini.php';
newbb_load_object();
class Report extends ArtObject {
function Report()
{
$this->ArtObject("bb_report");
$this->initVar('report_id', XOBJ_DTYPE_INT);
$this->initVar('post_id', XOBJ_DTYPE_INT);
$this->initVar('reporter_uid', XOBJ_DTYPE_INT);
$this->initVar('reporter_ip', XOBJ_DTYPE_INT);
$this->initVar('report_time', XOBJ_DTYPE_INT);
$this->initVar('report_text', XOBJ_DTYPE_TXTBOX);
$this->initVar('report_result', XOBJ_DTYPE_INT);
$this->initVar('report_memo', XOBJ_DTYPE_TXTBOX);
}
}
class NewbbReportHandler extends ArtObjectHandler
{
function NewbbReportHandler(&$db) {
$this->ArtObjectHandler($db, 'bb_report', 'Report', 'report_id');
}
function &getByPost($posts)
{
$ret = array();
if (!$posts) {
return $ret;
}
if (!is_array($posts)) $posts = array($posts);
$post_criteria = new Criteria("post_id", "(" . implode(", ", $posts) . ")", "IN");
$ret =& $this->getAll($post_criteria);
return $ret;
}
function &getAllReports($forums = 0, $order = "ASC", $perpage = 0, &$start, $report_result = 0, $report_id = 0)
{
if ($order == "DESC") {
$operator_for_position = '>' ;
} else {
$order = "ASC" ;
$operator_for_position = '<' ;
}
$order_criteria = " ORDER BY r.report_id $order";
if ($perpage <= 0) {
$perpage = 10;
}
if (empty($start)) {
$start = 0;
}
$result_criteria = ' AND r.report_result = ' . $report_result;
if (!$forums) {
$forum_criteria = '';
} else if (!is_array($forums)) {
$forums = array($forums);
$forum_criteria = ' AND p.forum_id IN (' . implode(',', $forums) . ')';
}
$tables_criteria = ' FROM ' . $this->db->prefix('bb_report') . ' r, ' . $this->db->prefix('bb_posts') . ' p WHERE r.post_id= p.post_id';
if ($report_id) {
$result = $this->db->query("SELECT COUNT(*) as report_count" . $tables_criteria . $forum_criteria . $result_criteria . " AND report_id $operator_for_position $report_id" . $order_criteria);
if ($result) $row = $this->db->fetchArray($result);
$position = $row['report_count'];
$start = intval($position / $perpage) * $perpage;
}
$sql = "SELECT r.*, p.subject, p.topic_id, p.forum_id" . $tables_criteria . $forum_criteria . $result_criteria . $order_criteria;
$result = $this->db->query($sql, $perpage, $start);
$ret = array();
//$report_handler = &xoops_getmodulehandler('report', 'newbb');
while ($myrow = $this->db->fetchArray($result)) {
$ret[] = $myrow; // return as array
}
return $ret;
}
/**
* clean orphan items from database
*
* @return bool true on success
*/
function cleanOrphan()
{
return parent::cleanOrphan($this->db->prefix("bb_posts"), "post_id");
}
}
?>
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?