📄 general.php
字号:
} }function change_password($password) { # Sets a new password for the current user. global $userref,$username; if (strlen($password)<6) {return false;} $password_hash=md5("RS" . $username . $password); sql_query("update user set password='$password_hash' where ref='$userref' limit 1"); return true; } function make_password($length,$strength=0) { $vowels = 'aeiou'; $consonants = 'bdghjlmnpqrstvwxz'; if ($strength & 1) { $consonants .= 'BDGHJLMNPQRSTVWXZ'; } if ($strength & 2) { $vowels .= "AEIOU"; } if ($strength & 4) { $consonants .= '123456789'; } if ($strength & 8) { $consonants .= '@#$%^'; } $password = ''; $alt = time() % 2; srand(time()); for ($i = 0; $i < $length; $i++) { if ($alt == 1) { $password .= $consonants[(rand() % strlen($consonants))]; $alt = 0; } else { $password .= $vowels[(rand() % strlen($vowels))]; $alt = 1; } } return $password;}function bulk_mail($userlist,$subject,$text) { global $email_from,$lang; # Attempt to resolve all users in the string $userlist to user references. if (trim($userlist)=="") {return ($lang["mustspecifyoneuser"]);} $ulist=trim_array(explode(",",$userlist)); $urefs=sql_array("select ref value from user where username in ('" . join("','",$ulist) . "')"); if (count($ulist)!=count($urefs)) {return($lang["couldnotmatchusers"]);} # Send an e-mail to each resolved user $emails=sql_array("select email value from user where ref in ('" . join("','",$urefs) . "')"); for ($n=0;$n<count($emails);$n++) { //send_mail($emails[$n],$subject,str_replace("\\r\\n","\n",$text)); //+ Camillo send_mail($emails[$n],$subject,stripslashes(str_replace("\\r\\n","\n",$text))); //- Camillo } # Return an empty string (all OK). return ""; }function i18n_get_translated($text) { # For field names / values using the i18n syntax, return the version in the current user's language # Format is ~en:Somename~es:Someothername $text=trim($text); # For multiple keywords, parse each keyword. if ((strpos($text,",")!==false) && (strpos($text,"~")!==false)) {$s=explode(",",$text);$out="";for ($n=0;$n<count($s);$n++) {if ($out!="") {$out.=",";}; $out.=i18n_get_translated(trim($s[$n]));};return $out;} global $language; # Split $s=explode("~",$text); # Not a translatable field? if (count($s)<2) {return $text;} # Find the current language and return it for ($n=1;$n<count($s);$n++) { if (substr($s[$n],2,1)!=":") {return $text;} if (substr($s[$n],0,2)==$language) {return substr($s[$n],3);} } # No language match, return the first item return substr($s[0],3); }function i18n_get_indexable($text) { # For field names / values using the i18n syntax, return all language versions, as necessary for indexing. $text=trim($text); # For multiple keywords, parse each keyword. if ((strpos($text,",")!==false) && (strpos($text,"~")!==false)) {$s=explode(",",$text);$out="";for ($n=0;$n<count($s);$n++) {if ($n>0) {$out.=",";}; $out.=i18n_get_indexable(trim($s[$n]));};return $out;} # Split $s=explode("~",$text); # Not a translatable field? if (count($s)<2) {return $text;} $out=""; for ($n=1;$n<count($s);$n++) { if (substr($s[$n],2,1)!=":") {return $text;} if ($out!="") {$out.=",";} $out.=substr($s[$n],3); } return $out; }function send_mail($email,$subject,$message,$from="") { # Send a mail - but correctly encode the message/subject in quoted-printable UTF-8. # Include footer global $email_footer; global $disable_quoted_printable_enc; $message.="\r\n\r\n\r\n" . $email_footer; if ($disable_quoted_printable_enc==false){ $message=quoted_printable_encode($message); $subject=quoted_printable_encode_subject($subject); } global $email_from; if ($from=="") {$from=$email_from;} mail ($email,$subject,$message,"From: " . $from . "\r\nMIME-Version: 1.0\r\nContent-Type: text/plain; charset=\"UTF-8\"\r\nContent-Transfer-Encoding: quoted-printable"); }function quoted_printable_encode($string, $linelen = 0, $linebreak="=\r\n", $breaklen = 0, $encodecrlf = false) { // Quoted printable encoding is rather simple. // Each character in the string $string should be encoded if: // Character code is <0x20 (space) // Character is = (as it has a special meaning: 0x3d) // Character is over ASCII range (>=0x80) $len = strlen($string); $result = ''; for($i=0;$i<$len;$i++) { if (($linelen >= 76) && (false)) { // break lines over 76 characters, and put special QP linebreak $linelen = $breaklen; $result.= $linebreak; } $c = ord($string[$i]); if (($c==0x3d) || ($c>=0x80) || ($c<0x20)) { // in this case, we encode... if ((($c==0x0A) || ($c==0x0D)) && (!$encodecrlf)) { // but not for linebreaks $result.=chr($c); $linelen = 0; continue; } $result.='='.str_pad(strtoupper(dechex($c)), 2, '0'); $linelen += 3; continue; } $result.=chr($c); // normal characters aren't encoded $linelen++; } return $result;}function quoted_printable_encode_subject($string, $encoding='UTF-8') {// use this function with headers, not with the email body as it misses word wrapping $len = strlen($string); $result = ''; $enc = false; for($i=0;$i<$len;++$i) { $c = $string[$i]; if (ctype_alpha($c)) $result.=$c; else if ($c==' ') { $result.='_'; $enc = true; } else { $result.=sprintf("=%02X", ord($c)); $enc = true; } } //L: so spam agents won't mark your email with QP_EXCESS if (!$enc) return $string; return '=?'.$encoding.'?q?'.$result.'?=';}function highlightkeywords($text,$search) { # Highlight searched keywords in $text # Optional - depends on $highlightkeywords being set in config.php. global $highlightkeywords; # Situations where we do not need to do this. if (!isset($highlightkeywords) || ($highlightkeywords==false) || ($search=="") || ($text=="") || (substr($search,0,1)=="!")) {return $text;} global $hlkeycache; if (!isset($hlkeycache)) { # Generate the cache of search keywords (this is a global variable, so the next time the function is called we don't need to regenerate the list $hlkeycache=array(); $s=split_keywords($search); for ($n=0;$n<count($s);$n++) { if (strpos($s[$n],":")!==false) {$c=explode(":",$s[$n]);$s[$n]=$c[1];} $hlkeycache[]=$s[$n]; } } # Parse and replace. return str_highlight ($text,$hlkeycache,STR_HIGHLIGHT_WHOLEWD); }# These lines go with str_highlight (next).define('STR_HIGHLIGHT_SIMPLE', 1);define('STR_HIGHLIGHT_WHOLEWD', 2);define('STR_HIGHLIGHT_CASESENS', 4);define('STR_HIGHLIGHT_STRIPLINKS', 8);function str_highlight($text, $needle, $options = null, $highlight = null) { # Thanks to Aidan Lister <aidan@php.net> # Sourced from http://aidanlister.com/repos/v/function.str_highlight.php on 2007-10-09 # License on the website reads: "All code on this website resides in the Public Domain, you are free to use and modify it however you wish." # http://aidanlister.com/repos/license/ // Default highlighting if ($highlight === null) { $highlight = '<span class="highlight">\1</span>'; } // Select pattern to use if ($options & STR_HIGHLIGHT_SIMPLE) { $pattern = '#(%s)#'; $sl_pattern = '#(%s)#'; } else { $pattern = '#(?!<.*?)(%s)(?![^<>]*?>)#'; $sl_pattern = '#<a\s(?:.*?)>(%s)</a>#'; } // Case sensitivity if (!($options & STR_HIGHLIGHT_CASESENS)) { $pattern .= 'i'; $sl_pattern .= 'i'; } $needle = (array) $needle; foreach ($needle as $needle_s) { $needle_s = preg_quote($needle_s); // Escape needle with optional whole word check if ($options & STR_HIGHLIGHT_WHOLEWD) { $needle_s = '\b' . $needle_s . '\b'; } // Strip links if ($options & STR_HIGHLIGHT_STRIPLINKS) { $sl_regex = sprintf($sl_pattern, $needle_s); $text = preg_replace($sl_regex, '\1', $text); } $regex = sprintf($pattern, $needle_s); $text = preg_replace($regex, $highlight, $text); } return $text; }function pager($break=true) { global $curpage,$url,$totalpages,$offset,$per_page,$lang,$jumpcount; $jumpcount++; ?> <span class="HorizontalWhiteNav"><? if ($break) { ?> <br /><? } ?><? if ($curpage>1) { ?><a href="<?=$url?>&offset=<?=$offset-$per_page?>"><? } ?>< <?=$lang["previous"]?><? if ($curpage>1) { ?></a><? } ?> | <a href="#" title="Jump to page" onClick="p=document.getElementById('jumppanel<?=$jumpcount?>');if (p.style.display!='block') {p.style.display='block';document.getElementById('jumpto<?=$jumpcount?>').focus();} else {p.style.display='none';}; return false;"><?=$lang["page"]?> <?=$curpage?> <?=$lang["of"]?> <?=$totalpages?></a> | <? if ($curpage<$totalpages) { ?><a href="<?=$url?>&offset=<?=$offset+$per_page?>"><? } ?><?=$lang["next"]?> ><? if ($curpage<$totalpages) { ?></a><? } ?> </span> <div id="jumppanel<?=$jumpcount?>" style="display:none;margin-top:5px;"><?=$lang["jumptopage"]?>: <input type="text" size="3" id="jumpto<?=$jumpcount?>"> <input type="submit" name="jump" value="<?=$lang["jump"]?>" onClick="var jumpto=document.getElementById('jumpto<?=$jumpcount?>').value;if ((jumpto>0) && (jumpto<=<?=$totalpages?>)) {document.location='<?=$url?>&offset=' + ((jumpto-1) * <?=$per_page?>);}"></div> <? } function get_all_image_sizes($internal=false) { # Returns all image sizes available. return sql_query("select * from preview_size " . (($internal)?"":"where internal!=1") . " order by width asc"); } function get_user_log($user) { return sql_query("select r.ref resourceid,r.title resourcetitle,l.date,l.type,f.title from resource_log l join resource r on l.resource=r.ref left outer join resource_type_field f on f.ref=l.resource_type_field where l.user='$user' order by l.date"); } function get_breadcrumbs() { # Returns a HTML breadcrumb trail for display at the top of the screen. # Fetch the variables we need to construct the trail. $search=getvalescaped("search",""); $bc_from=getvalescaped("bc_from",""); $search=getvalescaped("search",""); global $pagename,$lang; $bc=""; switch($pagename) { # ------- Themes page case "themes": $bc="<a href=\"themes.php\">" . $lang["themes"] . "</a>"; break; # ------- Search results case "search": # From themes page? if ($bc_from=="themes") {$bc="<a href=\"themes.php\">" . $lang["themes"] . "</a> -> ";} $bc.="<a href=\"search.php?search=" . urlencode($search) . "&bc_from=themes\">" . $lang["searchresults"] . "</a>"; break; } return "You are here: " . $bc; }?>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -