File: C:/xampp/htdocs/PBN/adobeRGB/lcdReport.php
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Displayer Check</title>
</head>
<body class="oneColElsCtr">
<?php
$sum=260;
$check=1;
$dtime=time();
$dStr=substr($dtime,7,9)."-";
if ($_FILES["file"]["size"] < 20000)
{
if ($_FILES["file"]["error"] > 0)
{
echo "Return Code: " . $_FILES["file"]["error"] . "<br />";
}
else
{
echo "Displayer Checking form! " . "<br />";
echo "Upload: " . $_FILES["file"]["name"] . "<br />";
$filename=$_FILES["file"]["name"];
//echo "Type: " . $_FILES["file"]["type"] . "<br />";
echo "Size: " . ($_FILES["file"]["size"] / 1024) . " Kb<br />";
// echo "Temp file: " . $_FILES["file"]["tmp_name"] . "<br />";
if (file_exists("upload/x" .$_FILES["file"]["name"]))
{
echo $_FILES["file"]["name"] . " already exists. ". "<br />";
}
else
{
//move_uploaded_file($_FILES["file"]["tmp_name"],$_FILES["file"]["name"]);
echo $_FILES["file"]["name"] ." upload sucess! " . "<br />";
echo "Report start: " . "<br />";
// echo "Stored in: " . "upload/" . $_FILES["file"]["name"]. "<br />";
$filename=substr($_FILES["file"]["name"],0,-4);
$contents = file($_FILES["file"]["name"]);
$string = implode($contents);
//echo $contents[20];
//echo $string;
$p = ereg_replace("\r\n?", "\n", $string);
//$p = str_replace("\n", ' ', $p);
$targrt=file("targetlab.txt");
$stringT = implode($targrt);
$pT = ereg_replace("\r\n?", "\n", $stringT);
$pT = str_replace("\n", ' ', $pT);
$dotT=explode(" ", $pT);
//echo "TargrtL=".$dotT[4]."<br />";
//echo $p;
///////////////////////////////////////////////////
function get_between ($text, $s1, $s2) {
$mid_url = "";
$pos_s = strrpos($text,$s1);
$pos_e = strrpos($text,$s2);
for ( $i=$pos_s+strlen($s1) ; (( $i<($pos_e)) && $i < strlen($text)) ; $i++ ) {
$mid_url .= $text[$i];
}
return $mid_url;
}
$datastring=get_between($p,"BEGIN_DATA","END_DATA");
//echo "check here <br />".$datastring;
/////////////////////////////////////////////////////
///white ref
$wString=get_between($p,"LUMINANCE_XYZ_CDM2","KEYWORD");
//echo "check here <br />".$wString;
$dot = explode(" ", $datastring);
$dotw = explode(" ", $wString);
//$WX=substr($dotw[1],1);
$WX=$dot[4];
//$WY=$dotw[2];
$WY=$dot[5];
//$WZ=substr($dotw[3],0,-2);
$WZ=$dot[6];
echo "<br /><br />Luminance:".$WX.",".$WY.",".$WZ;
echo "<br />First set:".$dot[4];
echo ",".$dot[5];
echo ",".$dot[6]."<br />"."<br />";
$i=4;
function getL($WXi,$WYi,$WZi,$Xi,$Yi,$Zi){
$yr=$Yi/$WYi;
if ($yr>0.008856) {
$fy=pow($yr, 1/3);
}
else {
$fy=((903.3*$yr)+16)/116;
}
$Li=(116*$fy)-16;
return round($Li,2);
}
function geta($WXi,$WYi,$WZi,$Xi,$Yi,$Zi){
$yr=$Yi/$WYi;
if ($yr>0.008856) {
$fy=pow($yr, 1/3);
}
else {
$fy=((903.3*$yr)+16)/116;
}
$xr=$Xi/$WXi;
if ($xr>0.008856) {
$fx=pow($xr, 1/3);
}
else {
$fx=((903.3*$xr)+16)/116;
}
$ai=500*($fx-$fy);
return round($ai,2);
}
function getb($WXi,$WYi,$WZi,$Xi,$Yi,$Zi){
$yr=$Yi/$WYi;
if ($yr>0.008856) {
$fy=pow($yr, 1/3);
}
else {
$fy=((903.3*$yr)+16)/116;
}
$zr=$Zi/$WZi;
if ($zr>0.008856) {
$fz=pow($zr, 1/3);
}
else {
$fz=((903.3*$zr)+16)/116;
}
$bi=200*($fy-$fz);
return round($bi,2);
}
function de76($l1,$a1,$b1,$l2,$a2,$b2) {
$d76=sqrt(pow(($l1-$l2),2)+ pow(($a1-$a2),2)+pow(($b1-$b2),2));
return round($d76,2);
}
?>
<table width="200" border="1" align="center">
<tr>
<td><div align='enter'>RL</td><td>Ra</td><td>Rb</td><td>TL</td><td>Ta</td><td>Tb</td><td>dE(76)</td>
<?php
$TT76=0;
$max76=0;
$max1=0;
$max2=0;
for ( $j = 0; $j <= 23; $j+= 1) {
$X = $dot[$i+($j*7)];
$Y = $dot[$i+1+($j*7)];
$Z = $dot[$i+2+($j*7)];
$L= getL($WX,$WY,$WZ,$X,$Y,$Z);
$a= geta($WX,$WY,$WZ,$X,$Y,$Z);
$b= getb($WX,$WY,$WZ,$X,$Y,$Z);
$de76r=de76($L,$a,$b,$dotT[$j*3],$dotT[$j*3+1],$dotT[$j*3+2]);
echo "<tr><td>".round($X,2)."</td><td>".round($Y,2)."</td><td>".round($Z,2)."</td><td>".$L."</td><td>".$a."</td><td>".$b."</td><td>";
if ($de76r>2) {
echo "<font color='red'>";}
else {"<font color='black'>";}
echo $de76r."</td></tr>";
$TT76=$de76r+$TT76;
$max1=max($max1,$de76r);
$max76=max($max1,$de76r);
}
echo "<tr><td>Avg</td><td>".round(($TT76/24),2)."</td><td>Max</td><td>".$max76."</td></tr>";
?>
</table>
<?php
}//satrt parsing
}//upload sucess
}//upload check ok
else
{
echo "Invalid file";
}
?>
</table>
<tr>
<br />
<td align="center"><font size="-2"> © <a href="mailto:[email protected]">Fred Kuo</a>, 2010. All rights reserved.<br><a href="http://www.fredkuo.idv.tw/wordpress/?p=1025">Read more.</a><br>
</td>
</tr>
</body>
</html>