Det script vil jeg gerne se så!
PHP er serverside! - det er altså ikke muligt at tilgå klienten i andet omfang end hvad browseren tillader det..
<?
function ttfName($font) {
$found=false;
if (!$fp = @fopen ("$font","r")) {
return false;
}
$magic=false;
$pos=0;
while (($magic==false) && (ftell($fp)<=1024)) {
$data=fread($fp,4);
if ($data=="head") {
$data=fread($fp, 12);
$headData=unpack("N3",$data);
fseek($fp,$headData[2], SEEK_SET);
$data=fread($fp,16);
$headTableData=unpack("N4",$data);
if ($headTableData[4]==0x5F0F3CF5) {
$magic=true;
} else {
return false;
}
}
}
if ($magic==false) {
return false;
}
fseek($fp,0,SEEK_SET);
while (!feof($fp)) {
$data=fread($fp,4);
if ($data=="name") {
$tableDir=fread($fp, 8);
$tableDirData=unpack("N2",$tableDir);
$found=true;
break;
}
}
if ($found) {
fseek($fp,$tableDirData[2], SEEK_SET);
$data=fread($fp, 8);
$info=unpack("n4", $data);
switch($info[4]) {
case 0:
$name["platform"]="Unicode";
break;
case 1:
$name["platform"]="Apple Macintosh";
break;
case 2:
$name["platform"]="ISO";
break;
case 3:
$name["platform"]="Microsoft Windows";
break;
case 4:
$name["platform"]="Custom";
break;
default:
$name["platform"]="unknown";
}
fseek($fp, ftell($fp)-2, SEEK_SET);
$i=0;
for ($x=0; $x<=$info[2]; $x++) {
$a=fread($fp, 12);
$data=unpack("n6",$a);
if (($data[4]==0) && (!isset($indexData["copy"]))) {
$indexData["copy"]=$data;
} else
if (($data[4]==1) && (!isset($indexData["font family"]))) {
$indexData["font family"]=$data;
} else
if (($data[4]==2) && (!isset($indexData["font subfamily"]))) {
$indexData["font subfamily"]=$data;
} else
if (($data[4]==3) && (!isset($indexData["id"]))) {
$indexData["id"]=$data;
} else
if (($data[4]==4) && (!isset($indexData["name"]))) {
$indexData["name"]=$data;
} else
if (($data[4]==5) && (!isset($indexData["version"]))) {
$indexData["version"]=$data;
} else
if (($data[4]==6) && (!isset($indexData["postscript name"]))) {
$indexData["postscript name"]=$data;
} else
if (($data[4]==7) && (!isset($indexData["tm"]))) {
$indexData["tm"]=$data;
} else
if (($data[4]==8) && (!isset($indexData["manufacturer"]))) {
$indexData["manufacturer"]=$data;
} else
if (($data[4]==9) && (!isset($indexData["designer"]))) {
$indexData["designer"]=$data;
} else
if (($data[4]==10) && (!isset($indexData["description"]))) {
$indexData["description"]=$data;
} else
if (($data[4]==11) && (!isset($indexData["vendor url"]))) {
$indexData["vendor url"]=$data;
} else
if (($data[4]==12) && (!isset($indexData["designer url"]))) {
$indexData["designer url"]=$data;
} else
if (($data[4]==13) && (!isset($indexData["license"]))) {
$indexData["license"]=$data;
} else
if (($data[4]==14) && (!isset($indexData["license url"]))) {
$indexData["license url"]=$data;
} else
if (($data[4]==19) && (!isset($indexData["sample text"]))) {
$indexData["sample text"]=$data;
}
}
$stringStorageStart=ftell($fp)-12;
foreach ($indexData as $key=>$val) {
fseek($fp, ($stringStorageStart+$indexData[$key][6]), SEEK_SET);
$name[$key]=fread($fp, $indexData[$key][5]);
}
$name=str_replace("\\n"," ",$name);
$name=str_replace("\\r","",$name);
$name=str_replace("\\x00","",$name);
fclose($fp);
return $name;
} else {
fclose($fp);
return false;
}
}
$extension = "c:\\WINDOWS\\Fonts\\\\";
$handle = opendir($extension);
while($file = readdir($handle))
{
$tjek = explode(".", $file);
if($tjek[1] == "TTF" || $tjek[1] == "ttf"){
$array = ttfName($extension.$file);
$ttfName = $array['name'];
echo $ttfName;
}
}
closedir($handle);
?>
Jan Larsen
CO-owner Jabo-web.com
http://www.jabo-web.com/ref=3[Redigeret d. 13/07-04 22:54:39 af Jan L]