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

📄 functions.php

📁 在综合英文版XOOPS 2.09, 2.091, 2.092 的基础上正式发布XOOPS 2.09中文版 XOOPS 2.09x 版主要是PHP5升级、bug修正和安全补正: 1 全面兼容PHP 5.
💻 PHP
📖 第 1 页 / 共 3 页
字号:
    $groups = (is_object($xoopsUser)) ? $xoopsUser -> getGroups() : XOOPS_GROUP_ANONYMOUS;    $gperm_handler = & xoops_gethandler('groupperm');    $count = 0;    $published_date = 0;    $arr = array();    $query = "select lid, published from " . $xoopsDB -> prefix('wfdownloads_downloads') . "		WHERE offline = 0 AND published > 0 AND published <= " . time() . " AND (expired = 0 OR expired > " . time() . ")";    if ($sel_id)    {        $query .= " AND cid=" . $sel_id . "";    }    $result = $xoopsDB -> query($query);    while (list($lid, $published) = $xoopsDB -> fetchRow($result))    {        if ($gperm_handler -> checkRight('WFDownFilePerm', $lid , $groups, $xoopsModule -> getVar('mid')))        {            $count++;            $published_date = ($published > $published_date) ? $published : $published_date;        }    }    $thing = 0;    if ($get_child == 1)    {        $arr = $mytree -> getAllChildId($sel_id);        $size = count($arr);        for($i = 0;$i < count($arr);$i++)        {            $query2 = "select lid, published from " . $xoopsDB -> prefix('wfdownloads_downloads') . " WHERE status > 0 AND offline = 0 AND published > 0 AND published <= " . time() . " AND (expired = 0 OR expired > " . time() . ") AND cid=" . $arr[$i] . "";            $result2 = $xoopsDB -> query($query2);            while (list($lid, $published) = $xoopsDB -> fetchRow($result2))            {                if ($gperm_handler -> checkRight('WFDownFilePerm', $lid , $groups, $xoopsModule -> getVar('mid')))                {                    $published_date = ($published > $published_date) ? $published : $published_date;                    $thing++;                }            }        }    }    $info['count'] = $count + $thing;    $info['published'] = $published_date;    return $info;}function wfd_imageheader(){    global $xoopsDB, $xoopsModule, $xoopsModuleConfig;    $image = '';    $result = $xoopsDB -> query("SELECT indeximage, indexheading FROM " . $xoopsDB -> prefix("wfdownloads_indexpage ") . " ");    list($indeximage, $indexheading) = $xoopsDB -> fetchrow($result);    if (!empty($indeximage))    {        $image = wfd_displayimage($indeximage, "'index.php'", $xoopsModuleConfig['mainimagedir'], $indexheading);    }    return $image;}function wfd_displayimage($image = '', $path = '', $imgsource = '', $alttext = ''){    global $xoopsConfig, $xoopsUser, $xoopsModule;    $showimage = '';    /**     * Check to see if link is given     */    if ($path)    {        $showimage = "<a href=" . $path . ">";    }    /**     * checks to see if the file is valid else displays default blank image     */    if (!is_dir(XOOPS_ROOT_PATH . "/" . $imgsource . "/" . $image) && file_exists(XOOPS_ROOT_PATH . "/" . $imgsource . "/" . $image))    {        $showimage .= "<img src='" . XOOPS_URL . "/" . $imgsource . "/" . $image . "' border='0' alt='" . $alttext . "' /></a>";    }    else    {        if ($xoopsUser && $xoopsUser -> isAdmin($xoopsModule -> mid()))        {            $showimage .= "<img src='" . XOOPS_URL . "/modules/wfdownloads/images/brokenimg.png' alt='" . _MD_WFD_ISADMINNOTICE . "' /></a>";        }        else        {            $showimage .= "<img src='" . XOOPS_URL . "/modules/wfdownloads/images/blank.png' alt=" . $alttext . " /></a>";        }    }    clearstatcache();    return $showimage;}/** * down_createthumb() * * @param $img_name * @param $img_path * @param $img_savepath * @param integer $img_w * @param integer $img_h * @param integer $quality * @param integer $update * @param integer $aspect * @return **/function down_createthumb($img_name, $img_path, $img_savepath, $img_w = 100, $img_h = 100, $quality = 100, $update = 0, $aspect = 1){    global $xoopsModuleConfig, $xoopsConfig;    // paths    if ($xoopsModuleConfig['usethumbs'] == 0)    {        $image_path = XOOPS_URL . "/{$img_path}/{$img_name}";        return $image_path;    }    $image_path = XOOPS_ROOT_PATH . "/{$img_path}/{$img_name}";    $savefile = $img_path . "/" . $img_savepath . "/" . $img_w . "x" . $img_h . "_" . $img_name;    $savepath = XOOPS_ROOT_PATH . "/" . $savefile;    // Return the image if no update and image exists    if ($update == 0 && file_exists($savepath))    {        return XOOPS_URL . "/" . $savefile;    }    list($width, $height, $type, $attr) = getimagesize($image_path, $info);    switch ($type)    {        case 1:            # GIF image            if (function_exists('imagecreatefromgif'))            {                $img = @imagecreatefromgif($image_path);            }            else            {                $img = @imageCreateFromPNG($image_path);            }            break;        case 2:            # JPEG image            $img = @imageCreateFromJPEG($image_path);            break;        case 3:            # PNG image            $img = @imageCreateFromPNG($image_path);            break;        default:            return $image_path;            break;    }    if (!empty($img))    {        /**         * Get image size and scale ratio         */        $scale = min($img_w / $width, $img_h / $height);        /**         * If the image is larger than the max shrink it         */        if ($scale < 1 && $aspect == 1)        {            $img_w = floor($scale * $width);            $img_h = floor($scale * $height);        }        /**         * Create a new temporary image         */        if (function_exists('imagecreatetruecolor'))        {            $tmp_img = imagecreatetruecolor($img_w, $img_h);        }        else        {            $tmp_img = imagecreate($img_w, $img_h);        }        /**         * Copy and resize old image into new image         */        ImageCopyResampled($tmp_img, $img, 0, 0, 0, 0, $img_w, $img_h, $width, $height);        imagedestroy($img);        flush();        $img = $tmp_img;    }    switch ($type)    {        case 1:        default:            # GIF image            if (function_exists('imagegif'))            {                imagegif($img, $savepath);            }            else            {                imagePNG($img, $savepath);            }            break;        case 2:            # JPEG image            imageJPEG($img, $savepath, $quality);            break;        case 3:            # PNG image            imagePNG($img, $savepath);            break;    }    imagedestroy($img);    flush();    return XOOPS_URL . "/" . $savefile;}function wfd_letters(){    global $xoopsModule;    $letterchoice = "<div>" . _MD_WFD_BROWSETOTOPIC . "</div>";    $letterchoice .= "[  ";    $alphabet = array ("0", "1", "2", "3", "4", "5", "6", "7", "8", "9", "A", "B", "C", "D", "E", "F", "G", "H", "I", "J", "K", "L", "M", "N", "O", "P", "Q", "R", "S", "T", "U", "V", "W", "X", "Y", "Z");    $num = count($alphabet) - 1;    $counter = 0;    while (list(, $ltr) = each($alphabet))    {        $letterchoice .= "<a href='" . XOOPS_URL . "/modules/wfdownloads/viewcat.php?list=$ltr'>$ltr</a>";        if ($counter == round($num / 2))            $letterchoice .= " ]<br />[ ";        elseif ($counter != $num)            $letterchoice .= "&nbsp;|&nbsp;";        $counter++;    }    $letterchoice .= " ]";    return $letterchoice;}function wfd_isnewimage($published){    global $xoopsDB;    $oneday = (time() - (86400 * 1));    $threedays = (time() - (86400 * 3));    $week = (time() - (86400 * 7));    if ($published > 0 && $published < $week)    {        $indicator['image'] = "images/icon/download4.gif";        $indicator['alttext'] = _MD_WFD_NEWLAST;    } elseif ($published >= $week && $published < $threedays)    {        $indicator['image'] = "images/icon/download3.gif";        $indicator['alttext'] = _MD_WFD_NEWTHIS;    } elseif ($published >= $threedays && $published < $oneday)    {        $indicator['image'] = "images/icon/download2.gif";        $indicator['alttext'] = _MD_WFD_THREE;    } elseif ($published >= $oneday)    {        $indicator['image'] = "images/icon/download1.gif";        $indicator['alttext'] = _MD_WFD_TODAY;    }    else    {        $indicator['image'] = "images/icon/download.gif";        $indicator['alttext'] = _MD_WFD_NO_FILES;    }    return $indicator;}// GetDownloadTime()// This function is used to show some different download times// BCMATH-Support in PHP needed!// (c)02.04.04 by St@neCold, stonecold@csgui.de, http://www.csgui.defunction wfd_GetDownloadTime($size = 0, $gmodem = 1, $gisdn = 1, $gdsl = 1, $gslan = 0, $gflan = 0){    $aflag = array();    $amtime = array();    $artime = array();    $ahtime = array();    $asout = array();    $aflag = array($gmodem, $gisdn, $gdsl, $gslan, $gflan);    $amtime = array($size / 6300 / 60, $size / 7200 / 60, $size / 86400 / 60, $size / 1125000 / 60, $size / 11250000 / 60);    $amname = array('Modem(56k)', 'ISDN(64k)', 'DSL(768k)', 'LAN(10M)', 'LAN(100M');    for($i = 0;$i < 5;$i++)    {        $artime[$i] = ($amtime[$i] % 60);    }    for($i = 0;$i < 5;$i++)    {        $ahtime[$i] = sprintf(' %2.0f', $amtime[$i] / 60);    }    if ($size <= 0) $dltime = 'N/A';    else    {        for($i = 0;$i < 5;$i++)        {            if (!$aflag[$i]) $asout[$i] = '';            else            {                if (($amtime[$i] * 60) < 1) $asout[$i] = sprintf(' : %4.2fs', $amtime[$i] * 60);                else                {                    if ($amtime[$i] < 1) $asout[$i] = sprintf(' : %2.0fs', round($amtime[$i] * 60));                    else                    {                        if ($ahtime[$i] == 0) $asout[$i] = sprintf(' : %5.1fmin', $amtime[$i]);                        else $asout[$i] = sprintf(' : %2.0fh%2.0fmin', $ahtime[$i], $artime[$i]);                    }                }                $asout[$i] = $amname[$i] . $asout[$i];                if ($i < 4) $asout[$i] = $asout[$i] . ' | ';            }        }        $dltime = '';        for($i = 0;$i < 5;$i++)        {            $dltime = $dltime . $asout[$i];        }    }    return $dltime;}function wfd_strrrchr($haystack, $needle){    return substr($haystack, 0, strpos($haystack, $needle) + 1);}function wfd_retmime($filename, $usertype = 1){    global $xoopsDB;    $ext = ltrim(strrchr($filename, '.'), '.');    $sql = "SELECT mime_types, mime_ext FROM " . $xoopsDB -> prefix('wfdownloads_mimetypes') . " WHERE mime_ext = '" . strtolower($ext) . "'";    if ($usertype == 1)

⌨️ 快捷键说明

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