Porting New PHP Version Notes
-----------------------------

- Compile eaccelerator
- Compile template - edit Makefile and add "TEMPLATE_SHARED_LIBADD=-lstdc++"

Windows only:

- openssl.dll   (Link with openssl shipped with php - so it does not collide with other openssl installed on the system)

                a) replace ssleay32.dll with phpssl32.dll, replace libeay32.dll with phpeay32.dll
                b) copy original php ssl files phpssl32.dll and phpeay32.dll
                c) replace the name in the ssl files to reflect the php* prefix
                d) ssleay32.dll is phpssl32.dll

- php5ts.dll    (Disable registry php keys and environemnt - so it does not collide with other php installed on the system)

		a) replace "\Per Directory" with "\PHP Directory"
		b) replace "IniFilePath" with "PHPFilePath"
		c) replace "PHPRC" with "PHPEN"


Linux PHP 
---------
Fix php unix socket bug:

RCS file: /repository/php-src/sapi/cgi/cgi_main.c,v
retrieving revision 1.256
diff -u -r1.256 cgi_main.c
--- sapi/cgi/cgi_main.c 14 Jul 2004 22:30:27 -0000      1.256
+++ sapi/cgi/cgi_main.c 8 Aug 2004 14:53:57 -0000
@@ -1130,7 +1130,7 @@
                 * path (it's what the fastcgi library expects)
                 */

-               if (strchr(bindpath, ':') == NULL) {
+               if ((strchr(bindpath, ':') == NULL) && (strchr(bindpath, '/') == NULL)) {



Prepare IMAP libraries:

Download IMAP toolkit and place it under modules/imap-2004c1/ folder 
make lmd
cp c-client/*.c *.h lib
cp c-client/c-client.a lib/libc-client.a


Compile with:

--enable-fastcgi
--with-imap=./modules/imap-2004c1/
--enable-mbstring
--with-iconv
--with-openssl
--enable-calendar
--with-pcre-regex
--enable-cgi
--disable-cli
--disable-pear
--without-mysql
--with-pdo
--with-pdo-sqlite
--enable-static
--enable-bcmath
--enable-zip

strip php


For the libicewarpphp.so create the libphp4.so with:

--disable-all --enable-embed=shared --with-pcre-regex


Extension changes
-----------------

[imap]

- New php function in imap_fetch_fast()
- New objects returned by imap_fetch_overview - cc, priority - To and Cc return a list of all addresses, internaldate
- IMAP c-client library must be updated to support the new changes
- Recompile c-client and php_imap


src/c-client/imap4r1.c:

static char *hdrheader[] = {
  "BODY.PEEK[HEADER.FIELDS (Newsgroups Content-Disposition Content-Language Content-Location",
  "BODY.PEEK[HEADER.FIELDS (Newsgroups Content-Disposition Content-Language Content-Location",
  "BODY.PEEK[HEADER.FIELDS (Newsgroups Content-Language Content-Location",
  "BODY.PEEK[HEADER.FIELDS (Newsgroups Content-Location",
  "BODY.PEEK[HEADER.FIELDS (Newsgroups"
};


+ // add string to first header list
X-Priority 


      ov.message_id = env->message_id;

+ // add line
      ov.priority = env->priority;


void imap_parse_header (MAILSTREAM *stream,ENVELOPE **env,SIZEDTEXT *hdr,

+ // add condition to others
    if (!(*env)->priority) {	/* need Priority? */
      (*env)->priority = nenv->priority;
      nenv->priority = NIL;
    }


void imap_parse_envelope (MAILSTREAM *stream,ENVELOPE **env,

+ // add new variable reset
      (*env)->priority = oenv->priority;
      oenv->priority = NIL;


ADDRESS *imap_parse_address (MAILSTREAM *stream,unsigned char **txtptr, IMAPPARSEDREPLY *reply)

+ // Add comment for both end-of-group and start-of-group block - these conditions must not be true
  // Make the good address the first block being executed
  /* ... else */ {


src/c-client/mail.h: 

typedef struct mail_overview {

+ // add line to both structures
char *priority;		/* X-Priority */


typedef struct mail_envelope {

+ // add line to both structures
char *priority;		/* X-Priority */


src/c-client/rfc822.c: 

void rfc822_parse_msg_full (ENVELOPE **en,BODY **bdy,char *s,unsigned long i,

+ // add new case condition
      case 'X':			/* possible X-Priority: */
	if (!strcmp (tmp+1,"-PRIORITY")) 
	  env->priority = cpystr (d);
	break;


void rfc822_header (char *header,ENVELOPE *env,BODY *body)

+ // add new case condition
  rfc822_header_line (&header,"X-Priority",env,env->priority);


void rfc822_address (char *dest,ADDRESS *adr)

+ // add also check for adr->mailbox to existing condition
  if (adr && adr->host && adr->mailbox) {	/* no-op if no address */



php_imap.c: 

PHP_FUNCTION(imap_fetch_overview)

+ // add new conditon to other conditions and also new property
				if (env->priority) {
					add_property_string(myoverview, "priority", env->priority, 1);
				}
				add_property_long(myoverview, "internaldate", mail_longdate(elt));


+ // Comment out or remove the to->next array so all occurences get returned in the "to" header
-					env->to->next = NULL;


+ // Add the block below to support "cc" header
				if (env->cc && _php_imap_address_size(env->cc) < MAILTMPLEN) {
					address[0] = '\0';
					rfc822_write_address(address, env->cc);
					add_property_string(myoverview, "cc", address, 1);
				}

+ Add new php function in php_imap.h + php_imap.c imap_fetch_fast() - returns fast list of flags, uid and size
PHP_FUNCTION(imap_fetch_fast)
{
 	zval **streamind, **sequence, **pflags;
	pils *imap_le_struct;
	zval *myoverview;
	char address[MAILTMPLEN];
	long status, flags=0L;
	int myargc = ZEND_NUM_ARGS();
	
	if (myargc < 2 || myargc > 3 || zend_get_parameters_ex(myargc, &streamind, &sequence, &pflags) == FAILURE) {
		ZEND_WRONG_PARAM_COUNT();
	}

	ZEND_FETCH_RESOURCE(imap_le_struct, pils *, streamind, -1, "imap", le_imap);

 	convert_to_string_ex(sequence);
	if(myargc == 3) {
		convert_to_long_ex(pflags);
		flags = Z_LVAL_PP(pflags);
	}

	array_init(return_value);
	
	status = (flags & FT_UID) 
		? mail_uid_sequence (imap_le_struct->imap_stream, Z_STRVAL_PP(sequence))
		: mail_sequence (imap_le_struct->imap_stream, Z_STRVAL_PP(sequence));
	
	if (status) {  
		MESSAGECACHE *elt;
		unsigned long i;

		mail_fetch_fast(imap_le_struct->imap_stream, Z_STRVAL_PP(sequence), flags);

		for (i = 1; i <= imap_le_struct->imap_stream->nmsgs; i++) {
			if (((elt = mail_elt (imap_le_struct->imap_stream, i))->sequence)) {
				MAKE_STD_ZVAL(myoverview);
				object_init(myoverview);

				add_property_long(myoverview, "uid", mail_uid(imap_le_struct->imap_stream, i));
				add_property_long(myoverview, "msgno", i);
				add_property_long(myoverview, "size", elt->rfc822_size);
				add_property_long(myoverview, "recent", elt->recent);
				add_property_long(myoverview, "flagged", elt->flagged);
				add_property_long(myoverview, "answered", elt->answered);
				add_property_long(myoverview, "deleted", elt->deleted);
				add_property_long(myoverview, "seen", elt->seen);
				add_property_long(myoverview, "draft", elt->draft);
				add_property_long(myoverview, "internaldate", mail_longdate(elt));
				add_next_index_object(return_value, myoverview TSRMLS_CC);
			}
		}
	}
}



[mailparse]

compile and install php with --with-mbstring=all, copy ext/mbstring to ext/mailparse/ext, phpize


