📄 functions.php
字号:
<?php/** * $Id: functions.php v 1.4 23 December 2003 Catwolf Exp $ * Module: WF-Channel * Version: v1.0.5 * Release Date: 03 Jan 2004 * Author: Catzwolf * Licence: GNU */include XOOPS_ROOT_PATH . '/modules/' . $xoopsModule->dirname() . '/include/htmlcleaner.php';function wfc_htmlarray($thishtmlpage, $thepath){ global $xoopsConfig, $wfsConfig; $file_array = wfc_filesarray($thepath); echo "<select size='1' name='htmlfile'>"; echo "<option value='0'>---------------------</option>"; foreach($file_array as $htmlpage) { if ($htmlpage == $thishtmlpage) { $opt_selected = "selected='selected'"; } else { $opt_selected = ""; } echo "<option value='" . $htmlpage . "' $opt_selected>" . $htmlpage . "</option>"; } echo "</select>"; return $htmlpage;}function wfc_filesarray($filearray){ $files = array(); $dir = opendir($filearray); while (($file = readdir($dir)) !== false) { if ((!preg_match("/^[.]{1,2}$/", $file) && preg_match("/[.htm|.html|.xhtml|.php]$/i", $file) && !is_dir($file))) { if (strtolower($file) != 'cvs' && !is_dir($file)) { $files[$file] = $file; } } } closedir($dir); asort($files); reset($files); return $files;}function wfc_getDirSelectOption($selected, $dirarray, $namearray, $addnull = 0){ // global $workd; echo "<select size='1' name='workd' onchange='location.href=\"upload.php?rootpath=\"+this.options[this.selectedIndex].value'>"; if ($addnull == 1) { 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>";}/** * adminmenu() * * @param string $header optional : You can gice the menu a nice header * @param string $extra optional : You can gice the menu a nice footer * @param array $menu required : This is an array of links. U can * @param int $scount required : This will difine the amount of cells long the menu will have. * NB: using a value of 3 at the moment will break the menu where the cell colours will be off display. * @return THIS ONE WORKS CORRECTLY */function wfc_adminmenu($header = '', $menu = '', $extra = '', $scount = 5){ global $xoopsConfig, $xoopsModule; if (isset($_SERVER['PHP_SELF'])) $thispage = basename($_SERVER['PHP_SELF']); $op = (isset($_GET['op'])) ? $op = "?op=" . $_GET['op'] : ''; 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_MAINADMIN => "index.php?op=default", _AM_GROUPPERMISSIONS => "permissions.php", _AM_UPLOAD => "upload.php", _AM_INEEDHELP => "http://wfsections.xoops2.com/modules/newbb/index.php?cat=5", _AM_CREATENEWPAGE => "index.php?op=create", _AM_CLINKTOUS => "index.php?op=links", _AM_REFER => "index.php?op=refer", _AM_REORDER => "reorder.php", _AM_REPORTBUGS => "http://wfsections.xoops2.com/modules/mantis/bug_report_page.php", ); } if (!is_array($menu)) { echo "<table width = '100%' cellpadding= '2' cellspacing= '1' class='outer'>"; echo "<tr><td class = even align = center><b>No menu items within the menu</b></td></tr></table><br />"; 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); 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 "<h3>" . $header . "</h3>"; 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%>"; 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); } if ($extra) { echo "<div>$extra</div>"; }}function wfc_uploading($allowed_mimetypes, $httppostfiles, $redirecturl = "index.php", $num = 0, $dir = "uploads", $redirect = 0){ include_once XOOPS_ROOT_PATH . "/class/uploader.php"; global $xoopsConfig, $xoopsModuleConfig, $_POST; $maxfilesize = $xoopsModuleConfig['maxfilesize']; $maxfilewidth = $xoopsModuleConfig['maximgwidth']; $maxfileheight = $xoopsModuleConfig['maximgheight']; $uploaddir = XOOPS_ROOT_PATH . "/" . $dir . "/"; $uploader = new XoopsMediaUploader($uploaddir, $allowed_mimetypes, $maxfilesize, $maxfilewidth, $maxfileheight); if ($uploader->fetchMedia($_POST['xoops_upload_file'][$num])) { if (!$uploader->upload()) { $errors = $uploader->getErrors(); redirect_header($redirecturl, 1, $errors); } else { if ($redirect) { redirect_header($redirecturl, 1 , _AM_FILEUPLOADED); } } } else { $errors = $uploader->getErrors(); redirect_header($redirecturl, 1, $errors); }}function wfc_cleanvars($string){ $string = str_replace(".", ". ", $string); $string = str_replace(",", ", ", $string); $string = str_replace(" ,", ", ", $string); $string = str_replace("!", "! ", $string); $string = str_replace("?", "? ", $string); $string = str_replace(":", ": ", $string); $string = str_replace(";", "; ", $string); $string = str_replace("-", " - ", $string); $string = str_replace('"', "", $string); // Remove multiple spaces/tabs $string = str_replace ("\"", "", $string); $string = str_replace ("'", "", $string); $string = preg_replace('/[ \t]{2,}/', ' ', $string); // $string = preg_replace('/"/',"",$string); // Remove multipule lines $string = preg_replace('/(\n|\r|\r\n){2,}/', '\r', $string); $string = preg_replace(array('/[ \t]{2,}/', '/(\n|\r|\r\n){2,}/'), array('/ /', '\r'), $string); return trim($string);}function wfc_removeShouting($string){ global $xoopsModuleConfig; // $lower_exceptions = array("to" => "1", "a" => "1", "the" => "1", "of" => "1" $lower_exceptions = array("to" => "1", "of" => "1" ); $higher_exceptions = array("I" => "1", "II" => "1", "III" => "1", "IV" => "1", "V" => "1", "VI" => "1", "VII" => "1", "VIII" => "1", "XI" => "1", "X" => "1", "I" => "1", "II" => "1", "III" => "1", "IV" => "1", "V" => "1", "VI" => "1", "VII" => "1", "VIII" => "1", "XI" => "1", "X" => "1", "I:" => "1", "II:" => "1", "III:" => "1", "IV:" => "1", "V:" => "1", "VI:" => "1", "VII:" => "1", "VIII:" => "1", "XI:" => "1", "X:" => "1" ); wfc_cleanvars($string); if (!$xoopsModuleConfig['stopshouting']) { return $string; } $words = split(" ", $string); $newwords = array(); foreach ($words as $word) { if (!in_array($word, $higher_exceptions)) $word = strtolower($word); if (!in_array($word, $lower_exceptions))$word[0] = strtoupper($word[0]); array_push($newwords, $word); } $text = join(" ", $newwords); $text = str_replace ("Array", "", $text); $text = preg_replace('/[ \t]{2,}/', ' ', $text); return $text;}function loadfile($file){ global $xoopsModuleConfig; $file = XOOPS_ROOT_PATH . "/" . $xoopsModuleConfig['htmluploaddir'] . "/" . $file; if (file_exists($file) && false !== $fp = fopen($file, 'r')) { $file = fread($fp, filesize($file)); } fclose($fp); return $file;}// Not used yetfunction convertword($DocumentPath){ global $xoopsModuleConfig, $myts; // $DocumentPath ; // $file = XOOPS_ROOT_PATH . "/" . $xoopsModuleConfig['htmluploaddir'] . "/" . $file;> $word = new COM("word.application") or die("Unable to instantiate Word"); > print "Loaded Word, version {$word->Version}<BR>"; > $word->Visible = 1; > $word->Documents->Add(); > $word->Selection->TypeText("This is a test..."); > $word->Documents[1]->SaveAs("Useless test.doc"); > $word->Quit(); $word = new COM("word.application") or die("Unable to instantiate application object"); $wordDocument = new COM("Word.Application") or die("Unable to instantiate document object"); $wordDocument = $word->Documents->Open($DocumentPath); $htmlfile = substr_replace(basename($DocumentPath), 'html', -3, 3); $htmlfile = strtolower(XOOPS_ROOT_PATH . '/' . $xoopsModuleConfig['htmluploaddir'] . "/" . $myts->htmlSpecialChars($htmlfile)); echo $htmlfile; $wordDocument->SaveAs($htmlfile, 8); $wordDocument = null; $word->Quit(); $word = null; return basename($htmlfile);}// end?>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -