?? functions.php
字號:
<?php
/*------------------------------------------------------------------------------
Reused functions
------------------------------------------------------------------------------*/
/*
Function scramblemail($email)
hides email from spambots
*/
function scramblemail($email){
$mailstring='<a href="mailto:';
for($i=0;$i<strlen($email);$i++){
$scramble.="&#".ord($email{$i}).";";
}
$mailstring.="$scramble\">$scramble</a>";
return $mailstring;
}
/*
Function urlize($name)
converts an item name into a url na,e
*/
function urlize($name){
return strtolower(preg_replace("/[^\w\.]/","",$name));
}
/*
Function load($file)
reads the content of the file that you send and returns it
*/
function load($filelocation){
if (file_exists($filelocation)){
$newfile = fopen($filelocation,"r");
$file_content = fread($newfile, filesize($filelocation));
fclose($newfile);
return $file_content;
}
}
/*
Function save($file,$content)
writes the content to the file and generates it if needed
*/
function save($filelocation,$newdatas){
$newfile = @fopen($filelocation,"w+");
@fwrite($newfile, $newdatas);
@fclose($newfile);
if($newfile!=""){$fileerror=0;}
else {$fileerror=1;}
return $fileerror;
}
/*
Function untag($string,$tag,mode){
written by Chris Heilmann (info@onlinetools.org)
filters the content of tag $tag from $string
when mode is 1 the content gets returned as an array
otherwise as a string
*/
function untag($string,$tag,$mode){
$tmpval="";
$preg="/<".$tag.">(.*?)<\/".$tag.">/si";
preg_match_all($preg,$string,$tags);
foreach ($tags[1] as $tmpcont){
if ($mode==1){$tmpval[]=$tmpcont;}
else {$tmpval.=$tmpcont;}
}
return $tmpval;
}
/*
Function directory($directory,$filters)
reads the content of $directory, takes the files that apply to $filter and returns an
array of the filenames.
You can specify which files to read, for example
$files = directory(".","jpg,gif");
gets all jpg and gif files in this directory.
$files = directory(".","all");
gets all files.
*/
function directory($dir,$filters){
if (is_dir($dir)){
$handle=opendir($dir);
$files=array();
if ($filters == "all"){while(($file = readdir($handle))!==false){$files[] = $file;}}
if ($filters != "all"){
$filters=explode(",",$filters);
while (($file = readdir($handle))!==false) {
for ($f=0;$f<sizeof($filters);$f++):
$system=explode(".",$file);
if ($system[1] == $filters[$f]){$files[] = $file;}
endfor;
}
}
closedir($handle);
}
return $files;
}
function get_file_name($page){
global $navigation;
$mainitems=untag($navigation,"mainitem",1);
$subitems=untag($navigation,"subitem",1);
$meta=untag($navigation,"meta",1);
$homedata=untag($navigation,"home",0);
if ($page==untag($homedata,"link",0)){$file=untag($homedata,"url",0);}
if ($meta[0]!=""){foreach ($meta as $m){if ($page==untag($m,"link",0)){$file=untag($m,"url",0);}}}
foreach ($mainitems as $m){if ($page==untag($m,"link",0)){$file=untag($m,"url",0);}}
if ($subitems[0]!=""){foreach ($subitems as $m){if ($page==untag($m,"sublink",0)){$file=untag($m,"suburl",0);}}}
return $file;
}
function d($name=''){
global $display;
return untag($display,$name,0);
}
?>
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -