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

📄 functions.php

📁 在综合英文版XOOPS 2.09, 2.091, 2.092 的基础上正式发布XOOPS 2.09中文版 XOOPS 2.09x 版主要是PHP5升级、bug修正和安全补正: 1 全面兼容PHP 5.
💻 PHP
📖 第 1 页 / 共 3 页
字号:
<?php/** * $Id: functions.php v 1.03 06 july 2004 Liquid Exp $ * Module: WF-Downloads * Version: v2.0.5a * Release Date: 26 july 2004 * Author: WF-Sections * Licence: GNU *//*function urlExists($url){    $file = '';    $url = htmlentities($url);    $url = ereg_replace("http://", "", $url);	list($domain, $file) = explode("/", $url, 2);    if ($file)    {		$fid = fsockopen($domain, 80, $errno ='', $errstr ='', 30);        fputs($fid, "GET /$file HTTP/1.0\r\nHost: $domain\r\n\r\n");        $gets = fgets($fid, 1024);        fclose($fid);        if (ereg("HTTP/1.1 200 OK", $gets)) return true;        else return false;    }    else    {        return false;    }}*//** * save_Permissions() * * @param $groups * @param $id * @param $perm_name * @return **/function wfd_save_Permissions($groups, $id, $perm_name){    $result = true;    $hModule = & xoops_gethandler('module');    $wfdModule = & $hModule -> getByDirname('wfdownloads');    $module_id = $wfdModule -> getVar('mid');    $gperm_handler = & xoops_gethandler('groupperm');    /*	* First, if the permissions are already there, delete them	*/    $gperm_handler -> deleteByModule($module_id, $perm_name, $id);    /*	*  Save the new permissions	*/    if (is_array($groups))    {        foreach ($groups as $group_id)        {            $gperm_handler -> addRight($perm_name, $id, $group_id, $module_id);        }    }    return $result;}/** * toolbar() * * @return **/function wfd_toolbar(){    global $xoopsModuleConfig, $xoopsUser;    $submissions = ($xoopsModuleConfig['submissions']) ? 1 : 0;    if (!is_object($xoopsUser))    {        $submissions = ($xoopsModuleConfig['anonpost']) ? 1 : 0;    }    $toolbar = "[ ";    if ($submissions == 1)    {        $toolbar .= "<a href='submit.php'>" . _MD_WFD_SUBMITDOWNLOAD . "</a> | ";    }    $toolbar .= "<a href='newlist.php'>" . _MD_WFD_LATESTLIST . "</a> | <a href='topten.php?list=hit'>" . _MD_WFD_POPULARITY . "</a> | <a href='topten.php?list=rate'>" . _MD_WFD_TOPRATED . "</a> ]";    return $toolbar;}/** * wfd_serverstats() * * @return **/function wfd_serverstats(){	echo "		<fieldset><legend style='font-weight: bold; color: #900;'>" . _AM_WFD_DOWN_IMAGEINFO . "</legend>\n		<div style='padding: 8px;'>\n		<div>" . _AM_WFD_DOWN_SPHPINI . "</div>\n		";    $safemode = (ini_get('safe_mode')) ? _AM_WFD_DOWN_ON . _AM_WFD_DOWN_SAFEMODEPROBLEMS : _AM_WFD_DOWN_OFF;    $registerglobals = (ini_get('register_globals') == '') ? _AM_WFD_DOWN_OFF : _AM_WFD_DOWN_ON;	$downloads = (ini_get('file_uploads')) ? _AM_WFD_DOWN_ON : _AM_WFD_DOWN_OFF;    $gdlib = (function_exists('gd_info')) ? _AM_WFD_DOWN_GDON : _AM_WFD_DOWN_GDOFF;	echo "<li>" . _AM_WFD_DOWN_GDLIBSTATUS . $gdlib;    if (function_exists('gd_info'))    {        if (true == $gdlib = gd_info())        {            echo "<li>" . _AM_WFD_DOWN_GDLIBVERSION . "<b>" . $gdlib['GD Version'] . "</b>";        }    }	echo "<br /><br />\n\n";	echo "<li>" . _AM_WFD_DOWN_SAFEMODESTATUS . $safemode;    echo "<li>" . _AM_WFD_DOWN_REGISTERGLOBALS . $registerglobals;	echo "<li>" . _AM_WFD_DOWN_SERVERUPLOADSTATUS . $downloads;    echo "<li>" . _AM_WFD_DOWN_MAXUPLOADSIZE . " <b>" . ini_get('upload_max_filesize') . "</b>\n";    echo "<li>" . _AM_WFD_DOWN_MAXPOSTSIZE . " <b>" . ini_get('post_max_size') . "</b>\n";	echo "</div>";	echo "</fieldset><br />";}/** * displayicons() * * @param  $time * @param integer $status * @param integer $counter * @return */function wfd_displayicons($time, $status = 0, $counter = 0){    global $xoopsModuleConfig;    $new = '';    $pop = '';    $newdate = (time() - (86400 * intval($xoopsModuleConfig['daysnew'])));    $popdate = (time() - (86400 * intval($xoopsModuleConfig['daysupdated']))) ;    if ($xoopsModuleConfig['displayicons'] != 3)    {        if ($newdate < $time)        {            if (intval($status) > 1)            {                if ($xoopsModuleConfig['displayicons'] == 1)                    $new = "&nbsp;<img src=" . XOOPS_URL . "/modules/wfdownloads/images/icon/update.gif alt='' align ='absmiddle'/>";                if ($xoopsModuleConfig['displayicons'] == 2)                    $new = "<i>Updated!</i>";            }            else            {                if ($xoopsModuleConfig['displayicons'] == 1)                    $new = "&nbsp;<img src=" . XOOPS_URL . "/modules/wfdownloads/images/icon/newred.gif alt='' align ='absmiddle'/>";                if ($xoopsModuleConfig['displayicons'] == 2)                    $new = "<i>New!</i>";            }        }        if ($popdate < $time)        {            if ($counter >= $xoopsModuleConfig['popular'])            {                if ($xoopsModuleConfig['displayicons'] == 1)                    $pop = "&nbsp;<img src =" . XOOPS_URL . "/modules/wfdownloads/images/icon/pop.gif alt='' align ='absmiddle'/>";                if ($xoopsModuleConfig['displayicons'] == 2)                    $pop = "<i>Popular</i>";            }        }    }    $icons = $new . " " . $pop;    return $icons;}if (!function_exists('convertorderbyin')){    // Reusable Link Sorting Functions    /**     * convertorderbyin()     *     * @param $orderby     * @return     **/    function convertorderbyin($orderby)    {        switch (trim($orderby))        {            case "titleA":                $orderby = "title ASC";                break;            case "dateA":                $orderby = "published 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 = "published DESC";                break;        }        return $orderby;    }}if (!function_exists('convertorderbytrans')){    function convertorderbytrans($orderby)    {        if ($orderby == "hits ASC") $orderbyTrans = _MD_WFD_POPULARITYLTOM;        if ($orderby == "hits DESC") $orderbyTrans = _MD_WFD_POPULARITYMTOL;        if ($orderby == "title ASC") $orderbyTrans = _MD_WFD_TITLEATOZ;        if ($orderby == "title DESC") $orderbyTrans = _MD_WFD_TITLEZTOA;        if ($orderby == "published ASC") $orderbyTrans = _MD_WFD_DATEOLD;        if ($orderby == "published DESC") $orderbyTrans = _MD_WFD_DATENEW;        if ($orderby == "rating ASC") $orderbyTrans = _MD_WFD_RATINGLTOH;        if ($orderby == "rating DESC") $orderbyTrans = _MD_WFD_RATINGHTOL;        return $orderbyTrans;    }}if (!function_exists('convertorderbyout')){    function convertorderbyout($orderby)    {        if ($orderby == "title ASC") $orderby = "titleA";        if ($orderby == "published ASC") $orderby = "dateA";        if ($orderby == "hits ASC") $orderby = "hitsA";        if ($orderby == "rating ASC") $orderby = "ratingA";        if ($orderby == "title DESC") $orderby = "titleD";        if ($orderby == "published DESC") $orderby = "dateD";        if ($orderby == "hits DESC") $orderby = "hitsD";        if ($orderby == "rating DESC") $orderby = "ratingD";        return $orderby;    }}/** * PrettySize() * * @param $size * @return **/function wfd_PrettySize($size){    $mb = 1024 * 1024;    if ($size > $mb)    {        $mysize = sprintf ("%01.2f", $size / $mb) . " MB";    } elseif ($size >= 1024)    {        $mysize = sprintf ("%01.2f", $size / 1024) . " KB";    }    else    {        $mysize = sprintf(_MD_WFD_NUMBYTES, $size);    }    return $mysize;}/** * updaterating() * * @param $sel_id * @return updates rating data in itemtable for a given item **/function wfd_updaterating($sel_id){    global $xoopsDB;    $query = "select rating FROM " . $xoopsDB -> prefix('wfdownloads_votedata') . " WHERE lid = " . $sel_id . "";    $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);    $sql = sprintf("UPDATE %s SET rating = %u, votes = %u WHERE lid = %u", $xoopsDB -> prefix('wfdownloads_downloads'), $finalrating, $votesDB, $sel_id);    $xoopsDB -> query($sql);}/** * totalcategory() * * @param integer $pid * @return **/function wfd_totalcategory($pid = 0){    global $xoopsDB, $xoopsModule, $xoopsUser;    $groups = (is_object($xoopsUser)) ? $xoopsUser -> getGroups() : XOOPS_GROUP_ANONYMOUS;    $gperm_handler = & xoops_gethandler('groupperm');    $sql = "SELECT cid FROM " . $xoopsDB -> prefix('wfdownloads_cat') . " ";    if ($pid > 0)    {        $sql .= "WHERE pid = 0";    }    $result = $xoopsDB -> query($sql);    $catlisting = 0;    while (list($cid) = $xoopsDB -> fetchRow($result))    {        if ($gperm_handler -> checkRight('WFDownCatPerm', $cid , $groups, $xoopsModule -> getVar('mid')))        {            $catlisting++;        }    }    return $catlisting;}/** * getTotalItems() * * @param integer $sel_id * @param integer $get_child * @return the total number of items in items table that are accociated with a given table $table id **/function wfd_getTotalItems($sel_id = 0, $get_child = 0){    global $xoopsDB, $mytree, $xoopsModule, $xoopsUser;

⌨️ 快捷键说明

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