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

📄 functions.php

📁 在综合英文版XOOPS 2.09, 2.091, 2.092 的基础上正式发布XOOPS 2.09中文版 XOOPS 2.09x 版主要是PHP5升级、bug修正和安全补正: 1 全面兼容PHP 5.
💻 PHP
字号:
<?php// $Id: functions.php,v 1.11 2004/12/26 19:11:57 onokazu 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 ////  ------------------------------------------------------------------------ //function newlinkgraphic($time, $status) {	$count = 7;	$new = '';	$startdate = (time()-(86400 * $count));	if ($startdate < $time) {		if($status==1){			$new = "&nbsp;<img src=\"".XOOPS_URL."/modules/mylinks/images/newred.gif\" alt=\""._MD_NEWTHISWEEK."\" />";		}elseif($status==2){			$new = "&nbsp;<img src=\"".XOOPS_URL."/modules/mylinks/images/update.gif\" alt=\""._MD_UPTHISWEEK."\" />";		}	}	return $new;}function popgraphic($hits) {	global $xoopsModuleConfig;	if ($hits >= $xoopsModuleConfig['popular']) {		return "&nbsp;<img src=\"".XOOPS_URL."/modules/mylinks/images/pop.gif\" alt=\""._MD_POPULAR."\" />";	}	return '';}//Reusable Link Sorting Functionsfunction convertorderbyin($orderby) {	switch (trim($orderby)) {	case "titleA":		$orderby = "title ASC";		break;	case "dateA":		$orderby = "date ASC";		break;	case "hitsA":		$orderby = "hits ASC";		break;	case "ratingA":		$orderby = "rating ASC";		break;	case "titleD":		$orderby = "title DESC";		break;	case "hitsD":		$orderby = "hits DESC";		break;	case "ratingD":		$orderby = "rating DESC";		break;	case"dateD":	default:		$orderby = "date DESC";		break;	}	return $orderby;}function convertorderbytrans($orderby) {            if ($orderby == "hits ASC")   $orderbyTrans = ""._MD_POPULARITYLTOM."";            if ($orderby == "hits DESC")    $orderbyTrans = ""._MD_POPULARITYMTOL."";            if ($orderby == "title ASC")    $orderbyTrans = ""._MD_TITLEATOZ."";           if ($orderby == "title DESC")   $orderbyTrans = ""._MD_TITLEZTOA."";            if ($orderby == "date ASC") $orderbyTrans = ""._MD_DATEOLD."";            if ($orderby == "date DESC")   $orderbyTrans = ""._MD_DATENEW."";            if ($orderby == "rating ASC")  $orderbyTrans = ""._MD_RATINGLTOH."";            if ($orderby == "rating DESC") $orderbyTrans = ""._MD_RATINGHTOL."";            return $orderbyTrans;}function convertorderbyout($orderby) {            if ($orderby == "title ASC")            $orderby = "titleA";            if ($orderby == "date ASC")            $orderby = "dateA";            if ($orderby == "hits ASC")          $orderby = "hitsA";            if ($orderby == "rating ASC")        $orderby = "ratingA";            if ($orderby == "title DESC")              $orderby = "titleD";            if ($orderby == "date DESC")            $orderby = "dateD";            if ($orderby == "hits DESC")          $orderby = "hitsD";            if ($orderby == "rating DESC")        $orderby = "ratingD";            return $orderby;}//updates rating data in itemtable for a given itemfunction updaterating($sel_id){        global $xoopsDB;        $query = "select rating FROM ".$xoopsDB->prefix("mylinks_votedata")." WHERE lid = ".$sel_id."";        //echo $query;        $voteresult = $xoopsDB->query($query);            $votesDB = $xoopsDB->getRowsNum($voteresult);        $totalrating = 0;            while(list($rating)=$xoopsDB->fetchRow($voteresult)){                $totalrating += $rating;        }        $finalrating = $totalrating/$votesDB;        $finalrating = number_format($finalrating, 4);        $query =  "UPDATE ".$xoopsDB->prefix("mylinks_links")." SET rating=$finalrating, votes=$votesDB WHERE lid = $sel_id";        //echo $query;            $xoopsDB->query($query) or exit();}//returns the total number of items in items table that are accociated with a given table $table idfunction getTotalItems($sel_id, $status=""){        global $xoopsDB, $mytree;        $count = 0;        $arr = array();        $query = "select count(*) from ".$xoopsDB->prefix("mylinks_links")." where cid=".$sel_id."";        if($status!=""){                $query .= " and status>=$status";        }        $result = $xoopsDB->query($query);        list($thing) = $xoopsDB->fetchRow($result);        $count = $thing;        $arr = $mytree->getAllChildId($sel_id);        $size = count($arr);        for($i=0;$i<$size;$i++){                $query2 = "select count(*) from ".$xoopsDB->prefix("mylinks_links")." where cid=".$arr[$i]."";                if($status!=""){                        $query2 .= " and status>=$status";                }                $result2 = $xoopsDB->query($query2);                list($thing) = $xoopsDB->fetchRow($result2);                $count += $thing;        }        return $count;}?>

⌨️ 快捷键说明

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