📄 functions.php
字号:
{ $sql .= " AND mime_admin = 1"; } else { $sql .= " AND mime_user = 1"; } $result = $xoopsDB -> query($sql); list($mime_types , $mime_ext) = $xoopsDB -> fetchrow($result); $mimtypes = explode(' ', trim($mime_types)); return $mimtypes;}function wfd_adminmenu($header = '', $menu = '', $extra = '', $scount = 4){ global $xoopsConfig, $xoopsModule; if (isset($_SERVER['PHP_SELF'])) $thispage = basename($_SERVER['PHP_SELF']); $op = (isset($_GET['op'])) ? $op = "?op=" . $_GET['op'] : ''; echo " <table width='100%' cellspacing='0' cellpadding='0' border='0' class='outer'>\n <tr>\n <td style='font-size: 12px; text-align: left; color: #2F5376; padding: 2px 6px; line-height: 150%;'>\n <a href='../../system/admin.php?fct=preferences&op=showmod&mod=" . $xoopsModule -> getVar('mid') . "'>" . _AM_WFD_PREFS . "</a> | \n <a href='../admin/index.php'>" . _AM_WFD_BINDEX . "</a> | \n <a href='../admin/permissions.php'>" . _AM_WFD_PERMISSIONS . "</a> | \n <a href='../admin/myblocksadmin.php'>" . _AM_WFD_BLOCKADMIN . "</a> | \n <a href='../index.php'>" . _AM_WFD_GOMODULE . "</a> | \n <a href='http://wf-projects.com/uploads/readme/wfd/readme.html' target='_blank'>" . _AM_WFD_BHELP . "</a> | \n <a href='about.php'>" . _AM_WFD_ABOUT . "</a>\n </td>\n </tr>\n </table><br />\n "; if (empty($menu)) { /** * You can change this part to suit your own module. Defining this here will save you form having to do this each time. */ $menu = array( // _AM_GENERALSET => "" . XOOPS_URL . "/modules/system/admin.php?fct=preferences&op=showmod&mod=" . $xoopsModule->getVar('mid') . "", _AM_WFD_INDEXPAGE => "indexpage.php", _AM_WFD_MCATEGORY => "category.php", _AM_WFD_MDOWNLOADS => "index.php?op=Download", _AM_WFD_MUPLOADS => "upload.php", _AM_WFD_MMIMETYPES => "mimetypes.php", _AM_WFS_MVOTEDATA => "votedata.php", _AM_WFD_MCOMMENTS => "../../system/admin.php?module=" . $xoopsModule -> mid() . "&status=0&limit=100&fct=comments&selsubmit=Go", ); } if (!is_array($menu)) { echo " <table width = '100%' cellpadding= '2' cellspacing= '1' class='outer'>\n <tr><td class ='even' align ='center' style='font-size: 12px;' ><b>" . _AM_WFD_NOMENUITEMS . "</b></td></tr></table><br />\n "; return false; } $oddnum = array(1 => "1", 3 => "3", 5 => "5", 7 => "7", 9 => "9", 11 => "11", 13 => "13"); // number of rows per menu $menurows = count($menu) / $scount; // total amount of rows to complete menu $menurow = ceil($menurows) * $scount; // actual number of menuitems per row $rowcount = $menurow / ceil($menurows); $count = 0; for ($i = count($menu); $i < $menurow; $i++) { $tempArray = array(1 => null); $menu = array_merge($menu, $tempArray); $count++; } /** * Sets up the width of each menu cell */ $width = 100 / $scount; $width = ceil($width); $menucount = 0; $count = 0; /** * Menu table output */ echo "<table width = '100%' cellpadding= '2' cellspacing= '1' class='outer'><tr>"; /** * Check to see if $menu is and array */ if (is_array($menu)) { $classcounts = 0; $classcol[0] = "even"; for ($i = 1; $i < $menurow; $i++) { $classcounts++; if ($classcounts >= $scount) { if ($classcol[$i-1] == 'odd') { $classcol[$i] = ($classcol[$i-1] == 'odd' && in_array($classcounts, $oddnum)) ? "even" : "odd"; } else { $classcol[$i] = ($classcol[$i-1] == 'even' && in_array($classcounts, $oddnum)) ? "odd" : "even"; } $classcounts = 0; } else { $classcol[$i] = ($classcol[$i-1] == 'even') ? "odd" : "even"; } } unset($classcounts); foreach ($menu as $menutitle => $menulink) { if ($thispage . $op == $menulink) { $classcol[$count] = "outer"; } echo "<td class='" . $classcol[$count] . "' align='center' valign='middle' width='$width%' style='font-size: 12px;'>"; if (is_string($menulink)) { echo "<a href='" . $menulink . "'>" . $menutitle . "</a></td>"; } else { echo " </td>"; } $menucount++; $count++; /** * Break menu cells to start a new row if $count > $scount */ if ($menucount >= $scount) { echo "</tr>"; $menucount = 0; } } echo "</table><br />"; unset($count); unset($menucount); } echo "<h3 style='color: #2F5376;'>" . $header . "</h3>"; if ($extra) { echo "<div>$extra</div>"; }}function wfd_getDirSelectOption($selected, $dirarray, $namearray){ echo "<select size='1' name='workd' onchange='location.href=\"upload.php?rootpath=\"+this.options[this.selectedIndex].value'>"; echo "<option value=''>--------------------------------------</option>"; foreach($namearray as $namearray => $workd) { if ($workd === $selected) { $opt_selected = "selected"; } else { $opt_selected = ""; } echo "<option value='" . htmlspecialchars($namearray, ENT_QUOTES) . "' $opt_selected>" . $workd . "</option>"; } echo "</select>";}/*function filesarray($filearray){ $files = array(); $dir = opendir($filearray); while (($file = readdir($dir)) !== false) { if ((!preg_match("/^[.]{1,2}$/", $file) && preg_match("/[.htm|.html|.xhtml]$/i", $file) && !is_dir($file))) { if (strtolower($file) != 'cvs' && !is_dir($file)) { $files[$file] = $file; } } } closedir($dir); asort($files); reset($files); return $files;}*/function wfd_uploading($_FILES, $uploaddir = "uploads", $allowed_mimetypes = '', $redirecturl = "index.php", $num = 0, $redirect = 0, $usertype = 1){ global $_FILES, $xoopsConfig, $xoopsModuleConfig, $_POST, $xoopsModule; $down = array(); include_once XOOPS_ROOT_PATH . "/modules/wfdownloads/class/uploader.php"; if (empty($allowed_mimetypes)) { $allowed_mimetypes = wfd_retmime($_FILES['userfile']['name'], $usertype); } $upload_dir = XOOPS_ROOT_PATH . "/" . $uploaddir . "/"; $maxfilesize = $xoopsModuleConfig['maxfilesize']; $maxfilewidth = $xoopsModuleConfig['maximgwidth']; $maxfileheight = $xoopsModuleConfig['maximgheight']; $uploader = new XoopsMediaUploader($upload_dir, $allowed_mimetypes, $maxfilesize, $maxfilewidth, $maxfileheight); $uploader -> noAdminSizeCheck(1); if ($uploader -> fetchMedia($_POST['xoops_upload_file'][0])) { if (!$uploader -> upload()) { $errors = $uploader -> getErrors(); redirect_header($redirecturl, 2, $errors); } else { if ($redirect) { redirect_header($redirecturl, 1 , _AM_WFD_UPLOADFILE); } else { if (is_file($uploader->savedDestination)) { $down['url'] = XOOPS_URL . "/" . $uploaddir . "/" . strtolower($uploader->savedFileName); $down['size'] = filesize(XOOPS_ROOT_PATH . "/" . $uploaddir . "/" . strtolower($uploader->savedFileName)); } return $down; } } } else { $errors = $uploader -> getErrors(); redirect_header($redirecturl, 1, $errors); }}function wfd_getforum($forumid){ global $xoopsDB, $xoopsConfig; echo "<select name='forumid'>"; echo "<option value='0'>----------------------</option>"; $result = $xoopsDB -> query("SELECT forum_name, forum_id FROM " . $xoopsDB -> prefix("bb_forums") . " ORDER BY forum_id"); while (list($forum_name, $forum_id) = $xoopsDB -> fetchRow($result)) { if ($forum_id == $forumid) { $opt_selected = "selected='selected'"; } else { $opt_selected = ""; } echo "<option value='" . $forum_id . "' $opt_selected>" . $forum_name . "</option>"; } echo "</select></div>"; return $forumid;}function wfd_downlistheader($heading){ echo " <fieldset><legend style='font-weight: bold; color: #900;'>" . $heading . "</legend><br />\n <table width='100%' cellspacing='1' cellpadding='2' border='0' class = 'outer'>\n <tr>\n <th align='center'><b>" . _AM_WFD_MINDEX_ID . "</b></th>\n <th><b>" . _AM_WFD_MINDEX_TITLE . "</b></th>\n <th align='center'><b>" . _AM_WFD_MINDEX_POSTER . "</b></th>\n <th align='center'><b>" . _AM_WFD_MINDEX_SUBMITTED . "</b></th>\n <th align='center'><b>" . _AM_WFD_MINDEX_ONLINESTATUS . "</b></th>\n <th align='center'><b>" . _AM_WFD_MINDEX_PUBLISHED . "</b></th>\n <th align='center'><b>" . _AM_WFD_MINDEX_ACTION . "</b></th>\n </tr>\n ";}function wfd_downlistbody($published){ global $myts, $imagearray; $lid = $published['lid']; $cid = $published['cid']; $title = "<a href='../singlefile.php?cid=" . $published['cid'] . "&lid=" . $published['lid'] . "'>" . $myts -> htmlSpecialChars(trim($published['title'])) . "</a>";; $submitter = xoops_getLinkedUnameFromId(intval($published['submitter'])); $publish = formatTimestamp($published['published'], 's'); $status = ($published['published'] > 0) ? $imagearray['online'] : "<a href='newdownloads.php'>" . $imagearray['offline'] . "</a>"; $offline = ($published['offline'] == 0) ? $imagearray['online'] : $imagearray['offline']; $modify = "<a href='index.php?op=Download&lid=" . $lid . "'>" . $imagearray['editimg'] . "</a>"; $delete = "<a href='index.php?op=delDownload&lid=" . $lid . "'>" . $imagearray['deleteimg'] . "</a>"; echo " <tr>\n <td class='head' align='center'>" . $lid . "</td>\n <td class='even'>" . $title . "</td>\n <td class='even' align='center'>" . $submitter . "</td>\n <td class='even' align='center'>" . $publish . "</td>\n <td class='even' align='center'>" . $offline . "</td>\n <td class='even' align='center'>" . $status . "</td>\n <td class='even' align='center' width = '10%' nowrap>$modify $delete</td>\n </tr>\n "; unset($published);}function wfd_downlistfooter(){ echo " <tr>\n <td class='head' align='center' colspan= '7'>" . _AM_WFD_MINDEX_NODOWNLOADSFOUND . "</td>\n </tr>\n ";}function wfd_downlistpagenav($pubrowamount, $start, $art = "art"){ global $xoopsModuleConfig; echo "</table>\n"; // Display Page Nav if published is > total display pages amount. $page = ($pubrowamount > $xoopsModuleConfig['admin_perpage']) ? _AM_WFD_MINDEX_PAGE : ''; $pagenav = new XoopsPageNav($pubrowamount, $xoopsModuleConfig['admin_perpage'], $start, 'st' . $art); echo '<div align="right" style="padding: 8px;">' . $page . '' . $pagenav -> renderNav() . '</div>'; echo "</fieldset><br />";}?>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -