Skip to content

Commit

Permalink
Merge branch 'master' into talmdal_dev
Browse files Browse the repository at this point in the history
  • Loading branch information
Tim Almdal committed Jun 7, 2010
2 parents 097ef93 + 1d91e1b commit 4a6775f
Show file tree
Hide file tree
Showing 11 changed files with 622 additions and 547 deletions.
66 changes: 35 additions & 31 deletions installer/installer.php
Expand Up @@ -187,45 +187,49 @@ static function prepend_prefix($prefix, $sql) {
}

static function check_environment() {
if (!function_exists("mysql_query") && !function_exists("mysqli_set_charset")) {
$errors[] = "Gallery 3 requires a MySQL database, but PHP doesn't have either the <a href=\"http://php.net/mysql\">MySQL</a> or the <a href=\"http://php.net/mysqli\">MySQLi</a> extension.";
}
if (!function_exists("mysql_query") && !function_exists("mysqli_set_charset")) {
$errors[] = "Gallery 3 requires a MySQL database, but PHP doesn't have either the <a href=\"http://php.net/mysql\">MySQL</a> or the <a href=\"http://php.net/mysqli\">MySQLi</a> extension.";
}

if (!@preg_match("/^.$/u", utf8_encode("\xF1"))) {
$errors[] = "PHP is missing <a href=\"http://php.net/pcre\">Perl-Compatible Regular Expression</a> support.";
}
if (!@preg_match("/^.$/u", utf8_encode("\xF1"))) {
$errors[] = "PHP is missing <a href=\"http://php.net/pcre\">Perl-Compatible Regular Expression</a> support.";
}

if (!(function_exists("spl_autoload_register"))) {
$errors[] = "PHP is missing <a href=\"http://php.net/spl\">Standard PHP Library (SPL)</a> support";
}
if (!(function_exists("spl_autoload_register"))) {
$errors[] = "PHP is missing <a href=\"http://php.net/spl\">Standard PHP Library (SPL)</a> support";
}

if (!(class_exists("ReflectionClass"))) {
$errors[] = "PHP is missing <a href=\"http://php.net/reflection\">reflection</a> support";
}
if (!(class_exists("ReflectionClass"))) {
$errors[] = "PHP is missing <a href=\"http://php.net/reflection\">reflection</a> support";
}

if (!(function_exists("filter_list"))) {
$errors[] = "PHP is missing the <a href=\"http://php.net/filter\">filter extension</a>";
}
if (!(function_exists("filter_list"))) {
$errors[] = "PHP is missing the <a href=\"http://php.net/filter\">filter extension</a>";
}

if (!(extension_loaded("iconv"))) {
$errors[] = "PHP is missing the <a href=\"http://php.net/iconv\">iconv extension</a>";
}
if (!(extension_loaded("iconv"))) {
$errors[] = "PHP is missing the <a href=\"http://php.net/iconv\">iconv extension</a>";
}

if (!(extension_loaded("simplexml"))) {
$errors[] = "PHP is missing the <a href=\"http://php.net/simplexml\">SimpleXML extension</a>";
}
if (!(extension_loaded("simplexml"))) {
$errors[] = "PHP is missing the <a href=\"http://php.net/simplexml\">SimpleXML extension</a>";
}

if (!extension_loaded("mbstring")) {
$errors[] = "PHP is missing the <a href=\"http://php.net/mbstring\">mbstring extension</a>";
} else if (ini_get("mbstring.func_overload") & MB_OVERLOAD_STRING) {
$errors[] = "The <a href=\"http://php.net/mbstring\">mbstring extension</a> is overloading PHP's native string functions. Please disable it.";
}
if (!extension_loaded("mbstring")) {
$errors[] = "PHP is missing the <a href=\"http://php.net/mbstring\">mbstring extension</a>";
} else if (ini_get("mbstring.func_overload") & MB_OVERLOAD_STRING) {
$errors[] = "The <a href=\"http://php.net/mbstring\">mbstring extension</a> is overloading PHP's native string functions. Please disable it.";
}

if (!function_exists("json_encode")) {
$errors[] = "PHP is missing the <a href=\"http://php.net/manual/en/book.json.php\">JavaScript Object Notation (JSON) extension</a>. Please install it.";
}
if (!function_exists("json_encode")) {
$errors[] = "PHP is missing the <a href=\"http://php.net/manual/en/book.json.php\">JavaScript Object Notation (JSON) extension</a>. Please install it.";
}

return @$errors;
}
if (!ini_get("short_open_tag")) {
$errors[] = "Gallery requires <a href=\"http://php.net/manual/en/ini.core.php\">short_open_tag</a> to be on. Please enable it in your php.ini.";
}

return @$errors;
}

}
602 changes: 332 additions & 270 deletions modules/exif/lib/exif.php

Large diffs are not rendered by default.

15 changes: 4 additions & 11 deletions modules/exif/lib/makers/canon.php
Expand Up @@ -40,6 +40,7 @@ function lookup_Canon_tag($tag) {
case "0009": $tag = "OwnerName";break;
case "000c": $tag = "CameraSerialNumber";break;
case "000f": $tag = "CustomFunctions";break;
case "0095": $tag = "LensInfo";break;

default: $tag = "unknown:".$tag;break;
}
Expand All @@ -57,21 +58,15 @@ function formatCanonData($type,$tag,$intel,$data,$exif,&$result) {
if($type=="ASCII") {
$result = $data = str_replace("\0", "", $data);
} else if($type=="URATIONAL" || $type=="SRATIONAL") {
$data = bin2hex($data);
if($intel==1) $data = intel2Moto($data);
$top = hexdec(substr($data,8,8));
$bottom = hexdec(substr($data,0,8));
if($bottom!=0) $data=$top/$bottom;
else if($top==0) $data = 0;
else $data=$top."/".$bottom;
$data = unRational($data,$type,$intel);

if($tag=="0204") { //DigitalZoom
$data=$data."x";
}

} else if($type=="USHORT" || $type=="SSHORT" || $type=="ULONG" || $type=="SLONG" || $type=="FLOAT" || $type=="DOUBLE") {

$data = bin2hex($data);
$data = rational($data,$type,$intel);
$result['RAWDATA'] = $data;

if($tag=="0001") { //first chunk
Expand Down Expand Up @@ -377,20 +372,18 @@ function parseCanon($block,&$result,$seek, $globalOffset) {
//2 byte type
$type = bin2hex(substr($block,$place,2));$place+=2;
if($intel==1) $type = intel2Moto($type);
lookup_type($type,$size);
lookup_type($type,$size);

//4 byte count of number of data units
$count = bin2hex(substr($block,$place,4));$place+=4;
if($intel==1) $count = intel2Moto($count);
$bytesofdata = $size*hexdec($count);

if($bytesofdata<=0) {
return; //if this value is 0 or less then we have read all the tags we can
}

//4 byte value of data or pointer to data
$value = substr($block,$place,4);$place+=4;

if($bytesofdata<=4) {
$data = $value;
} else {
Expand Down
13 changes: 2 additions & 11 deletions modules/exif/lib/makers/fujifilm.php
Expand Up @@ -44,7 +44,6 @@ function lookup_Fujifilm_tag($tag) {
case "1021": $tag = "FocusMode";break;
case "1030": $tag = "SlowSync";break;
case "1031": $tag = "PictureMode";break;
case "1032": $tag = "Unknown";break;
case "1100": $tag = "ContinuousTakingBracket";break;
case "1200": $tag = "Unknown";break;
case "1300": $tag = "BlurWarning";break;
Expand All @@ -66,22 +65,14 @@ function formatFujifilmData($type,$tag,$intel,$data) {


} else if($type=="URATIONAL" || $type=="SRATIONAL") {
$data = bin2hex($data);
if($intel==1) $data = intel2Moto($data);
$top = hexdec(substr($data,8,8));
$bottom = hexdec(substr($data,0,8));
if($bottom!=0) $data=$top/$bottom;
else if($top==0) $data = 0;
else $data=$top."/".$bottom;
$data = unRational($data,$type,$intel);

if($tag=="1011") { //FlashStrength
$data=$data." EV";
}

} else if($type=="USHORT" || $type=="SSHORT" || $type=="ULONG" || $type=="SLONG" || $type=="FLOAT" || $type=="DOUBLE") {
$data = bin2hex($data);
if($intel==1) $data = intel2Moto($data);
$data=hexdec($data);
$data =rational($data,$type,$intel);

if($tag=="1001") { //Sharpness
if($data == 1) $data = (string) t("Soft");
Expand Down
128 changes: 48 additions & 80 deletions modules/exif/lib/makers/gps.php
Expand Up @@ -72,103 +72,66 @@ function lookup_GPS_tag($tag) {
return $tag;
}

//=================
// Formats a rational number
//====================================================================
function GPSRational($data, $intel) {

if($intel==1) $top = hexdec(substr($data,8,8)); //intel stores them bottom-top
else $top = hexdec(substr($data,0,8)); //motorola stores them top-bottom

if($intel==1) $bottom = hexdec(substr($data,0,8)); //intel stores them bottom-top
else $bottom = hexdec(substr($data,8,8)); //motorola stores them top-bottom

if($bottom!=0) $data=$top/$bottom;
else if($top==0) $data = 0;
else $data=$top."/".$bottom;

return $data;
}
//=================
// Formats Data for the data type
//====================================================================
function formatGPSData($type,$tag,$intel,$data) {

if($type=="ASCII") {
if($tag=="0001" || $tag=="0003"){ // Latitude Reference, Longitude Reference
$data = ($data{1} == $data{2} && $data{1} == $data{3}) ? $data{0} : $data;
}
if($tag=="0001" || $tag=="0003"){ // Latitude Reference, Longitude Reference
$data = ($data{1} == $data{2} && $data{1} == $data{3}) ? $data{0} : $data;
}

} else if($type=="URATIONAL" || $type=="SRATIONAL") {
$data = bin2hex($data);
if($intel==1) $data = intel2Moto($data);

if($intel==1) $top = hexdec(substr($data,8,8)); //intel stores them bottom-top
else $top = hexdec(substr($data,0,8)); //motorola stores them top-bottom

if($intel==1) $bottom = hexdec(substr($data,0,8)); //intel stores them bottom-top
else $bottom = hexdec(substr($data,8,8)); //motorola stores them top-bottom

if($type=="SRATIONAL" && $top>2147483647) $top = $top - 4294967296; //this makes the number signed instead of unsigned

if($tag=="0002" || $tag=="0004") { //Latitude, Longitude

if($intel==1){
$seconds = GPSRational(substr($data,0,16),$intel);
$hour = GPSRational(substr($data,32,16),$intel);
} else {
$hour= GPSRational(substr($data,0,16),$intel);
$seconds = GPSRational(substr($data,32,16),$intel);
if($tag=="0002" || $tag=="0004" || $tag=='0007') { //Latitude, Longitude, Time
$datum = array();
for ($i=0;$i<strlen($data);$i=$i+8) {
array_push($datum,substr($data, $i, 8));
}
$hour = unRational($datum[0],$type,$intel);
$minutes = unRational($datum[1],$type,$intel);
$seconds = unRational($datum[2],$type,$intel);
if($tag=="0007") { //Time
$data = $hour.":".$minutes.":".$seconds;
} else {
$data = $hour+$minutes/60+$seconds/3600;
}
$minutes = GPSRational(substr($data,16,16),$intel);

$data = $hour+$minutes/60+$seconds/3600;
} else if($tag=="0007") { //Time
$seconds = GPSRational(substr($data,0,16),$intel);
$minutes = GPSRational(substr($data,16,16),$intel);
$hour = GPSRational(substr($data,32,16),$intel);

$data = $hour.":".$minutes.":".$seconds;
} else {
if($bottom!=0) $data=$top/$bottom;
else if($top==0) $data = 0;
else $data=$top."/".$bottom;

if($tag=="0006"){
$data .= 'm';
}
$data = unRational($data,$type,$intel);

if($tag=="0006"){
$data .= 'm';
}
}
} else if($type=="USHORT" || $type=="SSHORT" || $type=="ULONG" || $type=="SLONG" || $type=="FLOAT" || $type=="DOUBLE") {
$data = bin2hex($data);
if($intel==1) $data = intel2Moto($data);
$data=hexdec($data);


$data = rational($data,$type,$intel);


} else if($type=="UNDEFINED") {



} else if($type=="UBYTE") {
$data = bin2hex($data);
if($intel==1) $num = intel2Moto($data);


if($tag=="0000") { // VersionID
$data = hexdec(substr($data,0,2)) .
$data = hexdec(substr($data,0,2)) .
".". hexdec(substr($data,2,2)) .
".". hexdec(substr($data,4,2)) .
".". hexdec(substr($data,6,2));

} else if($tag=="0005"){ // Altitude Reference
if($data == "00000000"){ $data = 'Above Sea Level'; }
else if($data == "01000000"){ $data = 'Below Sea Level'; }
}
} else if($tag=="0005"){ // Altitude Reference
if($data == "00000000"){ $data = '+'; }
else if($data == "01000000"){ $data = '-'; }
}

} else {
$data = bin2hex($data);
if($intel==1) $data = intel2Moto($data);
}

return $data;
}

Expand Down Expand Up @@ -220,21 +183,26 @@ function parseGPS($block,&$result,$offset,$seek, $globalOffset) {

//4 byte value or pointer to value if larger than 4 bytes
$value = substr($block,$place,4);$place+=4;

if($bytesofdata<=4) {
$data = $value;
} else {
$value = bin2hex($value);
if($intel==1) $value = intel2Moto($value);

$v = fseek($seek,$globalOffset+hexdec($value)); //offsets are from TIFF header which is 12 bytes from the start of the file
if($v==0) {
$data = fread($seek, $bytesofdata);
} else if($v==-1) {
if (strpos('unknown',$tag_name) !== false || $bytesofdata > 1024) {
$result['Errors'] = $result['Errors']++;
$data = '';
$type = 'ASCII';
} else {
$value = bin2hex($value);
if($intel==1) $value = intel2Moto($value);
$v = fseek($seek,$globalOffset+hexdec($value)); //offsets are from TIFF header which is 12 bytes from the start of the file
if($v==0) {
$data = fread($seek, $bytesofdata);
} else {
$result['Errors'] = $result['Errors']++;
$data = '';
$type = 'ASCII';
}
}
}

if($result['VerboseOutput']==1) {
$result['GPS'][$tag_name] = formatGPSData($type,$tag,$intel,$data);
$result['GPS'][$tag_name."_Verbose"]['RawData'] = bin2hex($data);
Expand Down

0 comments on commit 4a6775f

Please sign in to comment.