cvs: php4 /ext/standard image.c php-master-web/fetch mirrors.php

From: Date: Fri, 08 Mar 2002 00:57:09 +0000
Subject: cvs: php4 /ext/standard image.c php-master-web/fetch mirrors.php
Groups: php.cvs 
Request: Send a blank email to php-cvs+get-9814@lists.php.net to get a copy of this message
helly Thu Mar 7 19:57:09 2002 EDT Modified files: /php-master-web/fetch mirrors.php /php4/ext/standard image.c Log: TIFF support for 'non' digicam files Index: php-master-web/fetch/mirrors.php diff -u php-master-web/fetch/mirrors.php:1.1 php-master-web/fetch/mirrors.php:1.2 --- php-master-web/fetch/mirrors.php:1.1 Fri Sep 21 15:01:08 2001 +++ php-master-web/fetch/mirrors.php Thu Mar 7 19:57:07 2002 @@ -7,7 +7,7 @@ // Connect and generate the list from the DB if (@mysql_connect("localhost","nobody","")) { if (@mysql_select_db("php3")) { - $res = @mysql_query("SELECT * FROM mirrors ORDER BY cc"); + $res = @mysql_query("SELECT mirrors.*,country.name AS cname FROM mirrors LEFT JOIN country ON mirrors.cc = country.id ORDER BY country.name,hostname"); if ($res) { echo "<?php\n\$MIRRORS = array(\n"; while ($row = @mysql_fetch_array($res)) { Index: php4/ext/standard/image.c diff -u php4/ext/standard/image.c:1.44 php4/ext/standard/image.c:1.45 --- php4/ext/standard/image.c:1.44 Mon Mar 4 13:21:43 2002 +++ php4/ext/standard/image.c Thu Mar 7 19:57:07 2002 @@ -16,7 +16,7 @@ | Marcus Boerger <helly@php.net> | +----------------------------------------------------------------------+ */ -/* $Id: image.c,v 1.44 2002/03/04 18:21:43 sebastian Exp $ */ +/* $Id: image.c,v 1.45 2002/03/08 00:57:07 helly Exp $ */ /* * Based on Daniel Schmitt's imageinfo.c which carried the following * Copyright notice. @@ -57,8 +57,8 @@ PHPAPI const char php_sig_jpg[3] = {(char) 0xff, (char) 0xd8, (char) 0xff}; PHPAPI const char php_sig_png[8] = {(char) 0x89, (char) 0x50, (char) 0x4e, (char) 0x47, (char) 0x0d, (char) 0x0a, (char) 0x1a, (char) 0x0a}; -PHPAPI const char php_sig_tif_ii[8] = {'I','I', (char)0x2A, (char)0x00, (char)0x08, (char)0x00, (char)0x00, (char)0x00}; -PHPAPI const char php_sig_tif_mm[8] = {'M','M', (char)0x00, (char)0x2A, (char)0x00, (char)0x00, (char)0x00, (char)0x08}; +PHPAPI const char php_sig_tif_ii[4] = {'I','I', (char)0x2A, (char)0x00}; +PHPAPI const char php_sig_tif_mm[4] = {'M','M', (char)0x00, (char)0x2A}; /* return info as a struct, to make expansion easier */ @@ -473,13 +473,24 @@ static struct gfxinfo *php_handle_tiff (int socketd, FILE *fp, int issock, pval *info, int motorola_intel) { struct gfxinfo *result = NULL; - + static char skip[1024]; int i, num_entries; unsigned char *dir_entry; - size_t ifd_size, dir_size, entry_value, entry_length, width, height; + size_t ifd_size, dir_size, entry_value, entry_length, width, height, ifd_addr; int entry_tag , entry_type; - char *ifd_data; + char *ifd_data, ifd_ptr[4]; + FP_FREAD(ifd_ptr, 4, socketd, fp, issock); + ifd_addr = php_ifd_get32u(ifd_ptr, motorola_intel)-8; + while ( ifd_addr>sizeof(skip)) { + FP_FREAD( skip, sizeof(skip), socketd, fp, issock); + ifd_addr -= sizeof(skip); + if (FP_FEOF( socketd, fp, issock)) return NULL; + } + if ( ifd_addr > 0) { + FP_FREAD( skip, ifd_addr, socketd, fp, issock); + if (FP_FEOF( socketd, fp, issock)) return NULL; + } ifd_size = 2; ifd_data = emalloc(ifd_size); FP_FREAD(ifd_data, 2, socketd, fp, issock); @@ -496,6 +507,10 @@ entry_type = php_ifd_get16u(dir_entry+2, motorola_intel); entry_length = php_ifd_get32u(dir_entry+4, motorola_intel) * php_tiff_bytes_per_format[entry_type]; switch(entry_type) { + case TAG_FMT_BYTE: + case TAG_FMT_SBYTE: + entry_value = (size_t)(dir_entry[8]); + break; case TAG_FMT_USHORT: entry_value = php_ifd_get16u(dir_entry+8, motorola_intel); break; @@ -625,12 +640,12 @@ result = php_handle_bmp(socketd, fp, issock); itype = IMAGE_FILETYPE_BMP; } else { - FP_FREAD(filetype+3, 5, socketd, fp, issock); - if (!memcmp(filetype, php_sig_tif_ii, 8)) { + FP_FREAD(filetype+3, 1, socketd, fp, issock); + if (!memcmp(filetype, php_sig_tif_ii, 4)) { result = php_handle_tiff(socketd, fp, issock, NULL, 0); itype = IMAGE_FILETYPE_TIFF; } else - if (!memcmp(filetype, php_sig_tif_mm, 8)) { + if (!memcmp(filetype, php_sig_tif_mm, 4)) { result = php_handle_tiff(socketd, fp, issock, NULL, 1); itype = IMAGE_FILETYPE_TIFF; }

« previous php.cvs (#9814) next »