📄 functions.php
字号:
function getLinkUsernameFromUid($userid = 0, $name= 0){ if (!is_numeric($userid)) { return $userid; } $userid = intval($userid); if ($userid > 0) { $member_handler =& xoops_gethandler('member'); $user =& $member_handler->getUser($userid); if (is_object($user)) { $ts =& MyTextSanitizer::getInstance(); $username = $user->getVar('uname'); $usernameu = $user->getVar('name'); if ( ($name) && !empty($usernameu)) { $username = $user->getVar('name'); } if ( !empty($usernameu)) { $linkeduser = "<a href='".XOOPS_URL."/userinfo.php?uid=".$userid."'>". $ts->htmlSpecialChars($username) ."</a>"; } else { $linkeduser = "<a href='".XOOPS_URL."/userinfo.php?uid=".$userid."'>". ucwords($ts->htmlSpecialChars($username)) ."</a>"; } return $linkeduser; } } return $GLOBALS['xoopsConfig']['anonymous'];}function get_user_level($user){ $RPG = $user->getVar('posts'); $RPGDIFF = $user->getVar('user_regdate'); $today = time(); $diff = $today - $RPGDIFF; $exp = round($diff / 86400,0); if ($exp<=0) { $exp = 1; } $ppd= round($RPG / $exp, 0); $level = pow (log10 ($RPG), 3); $ep = floor (100 * ($level - floor ($level))); $showlevel = floor ($level + 1); $hpmulti =round ($ppd / 6, 1); if ($hpmulti > 1.5) { $hpmulti = 1.5; } if ($hpmulti < 1) { $hpmulti = 1; } $maxhp = $level * 25 * $hpmulti; $hp= $ppd / 5; if ($hp >= 1) { $hp= $maxhp; } else { $hp= floor ($hp * $maxhp); } $hp= floor ($hp); $maxhp= floor ($maxhp); if ($maxhp <= 0) { $zhp = 1; } else { $zhp = $maxhp; } $hpf= floor (100 * ($hp / $zhp)) - 1; $maxmp= ($exp * $level) / 5; $mp= $RPG / 3; if ($mp >= $maxmp) { $mp = $maxmp; } $maxmp = floor ($maxmp); $mp = floor ($mp); if ($maxmp <= 0) { $zmp = 1; } else { $zmp = $maxmp; } $mpf= floor (100 * ($mp / $zmp)) - 1; if ( $hpf >= 98 ) { $hpf = $hpf - 2; } if ( $ep >= 98 ) { $ep = $ep - 2; } if ( $mpf >= 98 ) { $mpf = $mpf - 2; } $level = array(); $level['LEVEL'] = $showlevel ; $level['EXP'] = $ep; $level['HP'] = $hp; $level['HP_MAX'] = $maxhp; $level['HP_WIDTH'] = $hpf; $level['MP'] = $mp; $level['MP_MAX'] = $maxmp; $level['MP_WIDTH'] = $mpf; return $level;}function newbb_adminmenu ($currentoption = 0, $breadcrumb = ''){ /* Nice buttons styles */ echo " <style type='text/css'> #buttontop { float:left; width:100%; background: #e7e7e7; font-size:12px; line-height:normal; border-top: 1px solid black; border-left: 1px solid black; border-right: 1px solid black; margin: 0; } #buttonbar { float:left; width:100%; background: #e7e7e7 url('" . XOOPS_URL . "/modules/newbb/images/bg.png') repeat-x left bottom; font-size:12px; line-height:normal; border-left: 1px solid black; border-right: 1px solid black; margin-bottom: 12px; } #buttonbar ul { margin:0; margin-top: 15px; padding:10px 10px 0; list-style:none; } #buttonbar li { display:inline; margin:0; padding:0; } #buttonbar a { float:left; background:url('" . XOOPS_URL . "/modules/newbb/images/left_both.png') no-repeat left top; margin:0; padding:0 0 0 9px; border-bottom:1px solid #000; text-decoration:none; } #buttonbar a span { float:left; display:block; background:url('" . XOOPS_URL . "/modules/newbb/images/right_both.png') no-repeat right top; padding:5px 15px 4px 6px; font-weight:bold; color:#765; } /* Commented Backslash Hack hides rule from IE5-Mac \*/ #buttonbar a span {float:none;} /* End IE5-Mac hack */ #buttonbar a:hover span { color:#333; } #buttonbar #current a { background-position:0 -150px; border-width:0; } #buttonbar #current a span { background-position:100% -150px; padding-bottom:5px; color:#333; } #buttonbar a:hover { background-position:0% -150px; } #buttonbar a:hover span { background-position:100% -150px; } </style> "; global $xoopsModule, $xoopsConfig; $tblColors = Array(); $tblColors[0] = $tblColors[1] = $tblColors[2] = $tblColors[3] = $tblColors[4] = $tblColors[5] = $tblColors[6] = $tblColors[7] = $tblColors[8] = $tblColors[9] = ''; $tblColors[$currentoption] = 'current'; if (file_exists(XOOPS_ROOT_PATH . '/modules/' . $xoopsModule->getVar('dirname') . '/language/' . $xoopsConfig['language'] . '/modinfo.php')) { include_once XOOPS_ROOT_PATH . '/modules/' . $xoopsModule->getVar('dirname') . '/language/' . $xoopsConfig['language'] . '/modinfo.php'; } else { include_once XOOPS_ROOT_PATH . '/modules/newbb/language/english/modinfo.php'; } echo "<div id='buttontop'>"; echo "<table style=\"width: 100%; padding: 0; \" cellspacing=\"0\"><tr>"; echo "<td style=\"width: 60%; font-size: 12px; text-align: left; color: #2F5376; padding: 0 6px; line-height: 18px;\"><a class=\"nobutton\" href=\"../../system/admin.php?fct=preferences&op=showmod&mod=".$xoopsModule -> getVar( 'mid' )."\">" . _AM_NEWBB_GENERALSET . "</a> | <a href=\"../index.php\">" . _AM_NEWBB_GOTOMOD . "</a> | <a href=\"#\">" . _AM_NEWBB_HELP . "</a> | <a href=\"about.php\">" . _AM_NEWBB_ABOUT . "</a></td>"; echo "<td style=\"width: 40%; font-size: 12px; text-align: right; color: #2F5376; padding: 0 6px; line-height: 18px;\"><b>" . $xoopsModule->name() . " " . _AM_NEWBB_MODULEADMIN . "</b> " . $breadcrumb . "</td>"; echo "</tr></table>"; echo "</div>"; echo "<div id='buttonbar'>"; echo "<ul>"; echo "<li id='" . $tblColors[0] . "'><a href=\"index.php\"><span>"._MI_NEWBB_ADMENU1 ."</span></a></li>"; echo "<li id='" . $tblColors[1] . "'><a href=\"admin_cat_manager.php?op=manage\"><span>" . _MI_NEWBB_ADMENU2 . "</span></a></li>"; echo "<li id='" . $tblColors[2] . "'><a href=\"admin_forum_manager.php?op=manage\"><span>" . _MI_NEWBB_ADMENU3 . "</span></a></li>"; echo "<li id='" . $tblColors[3] . "'><a href=\"admin_forum_manager.php?op=sync\"><span>" . _MI_NEWBB_ADMENU4 . "</span></a></li>"; echo "<li id='" . $tblColors[4] . "'><a href=\"admin_forum_reorder.php\"><span>" . _MI_NEWBB_ADMENU5 . "</span></a></li>"; echo "<li id='" . $tblColors[5] . "'><a href=\"admin_forum_prune.php\"><span>" . _MI_NEWBB_ADMENU6 . "</span></a></li>"; echo "<li id='" . $tblColors[6] . "'><a href=\"admin_report.php\"><span>" . _MI_NEWBB_ADMENU7 . "</span></a></li>"; echo "<li id='" . $tblColors[7] . "'><a href=\"myblocksadmin.php\"><span>" . _MI_NEWBB_ADMENU8 . "</span></a></li>"; echo "<li id='" . $tblColors[8] . "'><a href=\"admin_digest.php\"><span>" . _MI_NEWBB_ADMENU9 . "</span></a></li>"; echo "<li id='" . $tblColors[9] . "'><a href=\"admin_votedata.php\"><span>" . _MI_NEWBB_ADMENU10 . "</span></a></li>"; echo "</ul></div>"; echo "<br /><br /><pre> </pre><pre> </pre><pre> </pre><pre> </pre><pre> </pre>";}function &newbb_admin_getPathStatus($path){ if(empty($path)) return false; if(@is_writable($path)){ $path_status = _AM_NEWBB_AVAILABLE; }elseif(!@is_dir($path)){ $path_status = _AM_NEWBB_NOTAVAILABLE." <a href=index.php?op=createdir&path=$path>"._AM_NEWBB_CREATETHEDIR.'</a>'; }else{ $path_status = _AM_NEWBB_NOTWRITABLE." <a href=index.php?op=setperm&path=$path>"._AM_NEWBB_SETMPERM.'</a>'; } return $path_status;}function newbb_admin_mkdir($target){ // http://www.php.net/manual/en/function.mkdir.php // saint at corenova.com // bart at cdasites dot com if (is_dir($target)||empty($target)) return true; // best case check first if (file_exists($target) && !is_dir($target)) return false; if (newbb_admin_mkdir(substr($target,0,strrpos($target,'/')))) if (!file_exists($target)) return mkdir($target); // crawl back up & create dir tree return true;}function newbb_admin_chmod($target, $mode = 0777){ return @chmod($target, $mode);}function pollview($poll_id){ global $xoopsTpl; $poll = new XoopsPoll($poll_id); $renderer = new XoopsPollRenderer($poll); $renderer->assignForm($xoopsTpl); $xoopsTpl->assign('lang_vote' , _PL_VOTE); $xoopsTpl->assign('lang_results' , _PL_RESULTS);}function pollresults($poll_id){ global $xoopsTpl; $poll = new XoopsPoll($poll_id); $renderer = new XoopsPollRenderer($poll); $renderer->assignResults($xoopsTpl);}function newbb_isIE5(){ static $user_agent_is_IE5; if(isset($user_agent_is_IE5)) return $user_agent_is_IE5;; $msie='/msie\s(5\.[5-9]|[6-9]\.[0-9]*).*(win)/i'; if( !isset($_SERVER['HTTP_USER_AGENT']) || !preg_match($msie,$_SERVER['HTTP_USER_AGENT']) || preg_match('/opera/i',$_SERVER['HTTP_USER_AGENT'])){ $user_agent_is_IE5 = false; }else{ $user_agent_is_IE5 = true; } return $user_agent_is_IE5;}function newbb_displayImage($image, $alt = "", $width = 0, $height =0, $style ="margin: 0px;", $sizeMeth='scale'){ global $xoopsModuleConfig, $forumImage; static $image_type; $user_agent_is_IE5 = newbb_isIE5(); if(!isset($image_type)) $image_type = ($xoopsModuleConfig['image_type'] == 'auto')?(($user_agent_is_IE5)?'gif':'png'):$xoopsModuleConfig['image_type']; $image .= '.'.$image_type; $imageuri=str_replace(XOOPS_URL,XOOPS_ROOT_PATH,$image); if(file_exists($imageuri)){ $size=@getimagesize($imageuri); if(is_array($size)){ $width=$size[0]; $height=$size[1]; } }else{ $image=$forumImage['blank'].'.gif'; } $width .='px'; $height .='px'; $img_style = "width: $width; height:$height; $style"; $image_url = "<img src=\"".$image."\" style=\"".$img_style."\" alt=\"".$alt."\" align=\"middle\" />"; return $image_url;}/** * newbb_updaterating() * * @param $sel_id * @return updates rating data in itemtable for a given item **/function newbb_updaterating($sel_id){ global $xoopsDB; $query = "select rating FROM " . $xoopsDB -> prefix('bb_votedata') . " WHERE topic_id = " . $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 topic_id = %u", $xoopsDB -> prefix('bb_topics'), $finalrating, $votesDB, $sel_id); $xoopsDB -> query($sql);}function &newbb_getWysiwygForm($newbb_form, $caption, $name, $value = "", $width = '100%', $height = '400px'){ $editor = false; switch(strtolower($newbb_form)){ case "spaw": if (is_readable(XOOPS_ROOT_PATH . "/class/spaw/formspaw.php")) { include_once(XOOPS_ROOT_PATH . "/class/spaw/formspaw.php"); $editor = new XoopsFormSpaw($caption, $name, $value, $width, $height); } break; case "fck": if ( is_readable(XOOPS_ROOT_PATH . "/class/fckeditor/formfckeditor.php")) { include_once(XOOPS_ROOT_PATH . "/class/fckeditor/formfckeditor.php"); $editor = new XoopsFormFckeditor($caption, $name, $value, $width, $height); } break; case "htmlarea": if ( is_readable(XOOPS_ROOT_PATH . "/class/htmlarea/formhtmlarea.php")) { include_once(XOOPS_ROOT_PATH . "/class/htmlarea/formhtmlarea.php"); $editor = new XoopsFormHtmlarea($caption, $name, $value, $width, $height); } break; case "koivi": if ( is_readable(XOOPS_ROOT_PATH . "/class/wysiwyg/formwysiwygtextarea.php")) { include_once(XOOPS_ROOT_PATH . "/class/wysiwyg/formwysiwygtextarea.php"); $editor = new XoopsFormWysiwygTextArea($caption, $name, $value, $width, $height, ''); } break; } return $editor;}function &newbb_getTextareaForm($newbb_form, $caption, $name, $value = "", $rows = 25, $cols = 60){ switch(strtolower($newbb_form)){ case "textarea": $form = new XoopsFormTextArea($caption, $name, $value, $rows, $cols); break; case "dhtml": default: $form = new XoopsFormDhtmlTextArea($caption, $name, $value, $rows, $cols); break; } return $form;}function newbb_getImageLibs(){/* * exec could be disabled */ global $xoopsModuleConfig; $imageLibs= array(); unset($output, $status); if ( $xoopsModuleConfig['image_lib'] == 1 or $xoopsModuleConfig['image_lib'] == 0 ){ $path = empty($xoopsModuleConfig['path_magick'])?"":$xoopsModuleConfig['path_magick']."/"; @exec($path.'convert -version', $output, $status); if(empty($status)&&!empty($output)){ if(preg_match("/imagemagick[ \t]+([0-9\.]+)/i",$output[0],$matches)) $imageLibs['imagemagick'] = $matches[0]; } unset($output, $status); } if ( $xoopsModuleConfig['image_lib'] == 2 or $xoopsModuleConfig['image_lib'] == 0 ){ $path = empty($xoopsModuleConfig['path_netpbm'])?"":$xoopsModuleConfig['path_netpbm']."/"; @exec($path.'jpegtopnm -version 2>&1', $output, $status); if(empty($status)&&!empty($output)){ if(preg_match("/netpbm[ \t]+([0-9\.]+)/i",$output[0],$matches)) $imageLibs['netpbm'] = $matches[0]; } unset($output, $status); } $GDfuncList = get_extension_funcs('gd'); ob_start(); @phpinfo(INFO_MODULES); $output=ob_get_contents(); ob_end_clean(); $matches[1]=''; if(preg_match("/GD Version[ \t]*(<[^>]+>[ \t]*)+([^<>]+)/s",$output,$matches)){ $gdversion = $matches[2]; } if( $GDfuncList ){ if( in_array('imagegd2',$GDfuncList) ) $imageLibs['gd2'] = $gdversion; else $imageLibs['gd1'] = $gdversion; } return $imageLibs; }?>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -