[PHP-CVS] svn: /php/php-src/ branches/PHP_5_3/NEWS branches/PHP_5_3/ext/curl/interface.c trunk/ext/curl/interface.c

2011-04-01 Thread Pierre Joye
pajoye   Fri, 01 Apr 2011 17:19:08 +

Revision: http://svn.php.net/viewvc?view=revisionrevision=309881

Log:
- add CURLINFO_REDIRECT_URL

Changed paths:
U   php/php-src/branches/PHP_5_3/NEWS
U   php/php-src/branches/PHP_5_3/ext/curl/interface.c
U   php/php-src/trunk/ext/curl/interface.c

Modified: php/php-src/branches/PHP_5_3/NEWS
===
--- php/php-src/branches/PHP_5_3/NEWS   2011-04-01 17:10:52 UTC (rev 309880)
+++ php/php-src/branches/PHP_5_3/NEWS   2011-04-01 17:19:08 UTC (rev 309881)
@@ -13,6 +13,8 @@
 (tomas dot brastavicius at quantum dot lt, Pierrick)
. Fixed bug #48465 (sys_get_temp_dir() possibly inconsistent when using
  TMPDIR on Windows). (Pierre)
+- cURL
+  . Added CURLINFO_REDIRECT_URL support. (Daniel Stenberg, Pierre)

 - DateTime extension:
   . Fixed bug #54340 (DateTime::add() method bug). (Adam)

Modified: php/php-src/branches/PHP_5_3/ext/curl/interface.c
===
--- php/php-src/branches/PHP_5_3/ext/curl/interface.c   2011-04-01 17:10:52 UTC 
(rev 309880)
+++ php/php-src/branches/PHP_5_3/ext/curl/interface.c   2011-04-01 17:19:08 UTC 
(rev 309881)
@@ -331,6 +331,13 @@
 ZEND_GET_MODULE (curl)
 #endif

+/* {{{ PHP_INI_BEGIN */
+PHP_INI_BEGIN()
+   PHP_INI_ENTRY(curl.cainfo, , PHP_INI_SYSTEM, NULL)
+PHP_INI_END()
+/* }}} */
+
+/* }}} */
 /* {{{ PHP_MINFO_FUNCTION
  */
 PHP_MINFO_FUNCTION(curl)
@@ -458,6 +465,8 @@
le_curl = zend_register_list_destructors_ex(_php_curl_close, NULL, 
curl, module_number);
le_curl_multi_handle = 
zend_register_list_destructors_ex(_php_curl_multi_close, NULL, curl_multi, 
module_number);

+   REGISTER_INI_ENTRIES();
+
/* See http://curl.haxx.se/lxr/source/docs/libcurl/symbols-in-versions
   or curl src/docs/libcurl/symbols-in-versions for a (almost) complete 
list
   of options and which version they were introduced */
@@ -632,7 +641,11 @@
 #if LIBCURL_VERSION_NUM   0x071301
REGISTER_CURL_CONSTANT(CURLINFO_CERTINFO);
 #endif
+#if LIBCURL_VERSION_NUM = 0x071202
+REGISTER_CURL_CONSTANT(CURLINFO_REDIRECT_URL);
+#endif

+
/* cURL protocol constants (curl_version) */
REGISTER_CURL_CONSTANT(CURL_VERSION_IPV6);
REGISTER_CURL_CONSTANT(CURL_VERSION_KERBEROS4);
@@ -879,6 +892,7 @@
php_curl_openssl_tsl = NULL;
}
 #endif
+   UNREGISTER_INI_ENTRIES();
return SUCCESS;
 }
 /* }}} */
@@ -1427,6 +1441,7 @@
zval*clone;
char*url = NULL;
int url_len = 0;
+   char *cainfo;

if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, |s, url, 
url_len) == FAILURE) {
return;
@@ -1453,6 +1468,8 @@
MAKE_STD_ZVAL(clone);
ch-clone = clone;

+
+
curl_easy_setopt(ch-cp, CURLOPT_NOPROGRESS,1);
curl_easy_setopt(ch-cp, CURLOPT_VERBOSE,   0);
curl_easy_setopt(ch-cp, CURLOPT_ERRORBUFFER,   ch-err.str);
@@ -1465,6 +1482,12 @@
curl_easy_setopt(ch-cp, CURLOPT_DNS_USE_GLOBAL_CACHE, 1);
curl_easy_setopt(ch-cp, CURLOPT_DNS_CACHE_TIMEOUT, 120);
curl_easy_setopt(ch-cp, CURLOPT_MAXREDIRS, 20); /* prevent infinite 
redirects */
+
+   cainfo = INI_STR(curl.cainfo);
+   if (cainfo  strlen(cainfo)  0) {
+   curl_easy_setopt(ch-cp, CURLOPT_CAINFO, cainfo);
+   }
+
 #if defined(ZTS)
curl_easy_setopt(ch-cp, CURLOPT_NOSIGNAL, 1);
 #endif
@@ -2306,6 +2329,11 @@
CAAZ(certinfo, listcode);
}
 #endif
+#if LIBCURL_VERSION_NUM = 0x071202
+   if (curl_easy_getinfo(ch-cp, CURLINFO_REDIRECT_URL, s_code) 
== CURLE_OK) {
+   CAAS(redirect_url, s_code);
+   }
+#endif
if (ch-header.str_len  0) {
CAAS(request_header, ch-header.str);
}
@@ -2313,7 +2341,11 @@
switch (option) {
case CURLINFO_PRIVATE:
case CURLINFO_EFFECTIVE_URL:
-   case CURLINFO_CONTENT_TYPE: {
+   case CURLINFO_CONTENT_TYPE:
+#if LIBCURL_VERSION_NUM = 0x071202
+   case CURLINFO_REDIRECT_URL:
+#endif
+   {
char *s_code = NULL;

if (curl_easy_getinfo(ch-cp, option, s_code) 
== CURLE_OK  s_code) {

Modified: php/php-src/trunk/ext/curl/interface.c
===
--- php/php-src/trunk/ext/curl/interface.c  2011-04-01 17:10:52 UTC (rev 
309880)
+++ php/php-src/trunk/ext/curl/interface.c  2011-04-01 17:19:08 UTC (rev 
309881)
@@ -644,7 +644,11 @@
 #if LIBCURL_VERSION_NUM   0x071301
REGISTER_CURL_CONSTANT(CURLINFO_CERTINFO);
 #endif
+#if LIBCURL_VERSION_NUM = 0x071202
+ 

[PHP-CVS] svn: /php/php-src/ branches/PHP_5_3/NEWS branches/PHP_5_3/ext/curl/interface.c trunk/ext/curl/interface.c

2010-11-29 Thread Ilia Alshanetsky
iliaaMon, 29 Nov 2010 14:40:59 +

Revision: http://svn.php.net/viewvc?view=revisionrevision=305835

Log:
Fixed bug #52828 (curl_setopt does not accept persistent streams).

Bug: http://bugs.php.net/52828 (Open) curl_setopt does not accept persistent 
streams
  
Changed paths:
U   php/php-src/branches/PHP_5_3/NEWS
U   php/php-src/branches/PHP_5_3/ext/curl/interface.c
U   php/php-src/trunk/ext/curl/interface.c

Modified: php/php-src/branches/PHP_5_3/NEWS
===
--- php/php-src/branches/PHP_5_3/NEWS   2010-11-29 14:39:00 UTC (rev 305834)
+++ php/php-src/branches/PHP_5_3/NEWS   2010-11-29 14:40:59 UTC (rev 305835)
@@ -14,6 +14,10 @@
 (Ilia)
   . Fixed #53409 (sleep() returns NULL on Windows). (Pierre)

+- Curl extension:
+  . Fixed bug #52828 (curl_setopt does not accept persistent streams).
+(Gustavo, Ilia)
+
 - Hash extension:
   . Fixed bug #51003 (unaligned memory access in ext/hash/hash_tiger.c).
 (Mike, Ilia)

Modified: php/php-src/branches/PHP_5_3/ext/curl/interface.c
===
--- php/php-src/branches/PHP_5_3/ext/curl/interface.c   2010-11-29 14:39:00 UTC 
(rev 305834)
+++ php/php-src/branches/PHP_5_3/ext/curl/interface.c   2010-11-29 14:40:59 UTC 
(rev 305835)
@@ -1761,7 +1761,7 @@
int type;
void * what;

-   what = zend_fetch_resource(zvalue TSRMLS_CC, -1, 
File-Handle, type, 1, php_file_le_stream());
+   what = zend_fetch_resource(zvalue TSRMLS_CC, -1, 
File-Handle, type, 1, php_file_le_stream(), php_file_le_pstream());
if (!what) {
RETVAL_FALSE;
return 1;

Modified: php/php-src/trunk/ext/curl/interface.c
===
--- php/php-src/trunk/ext/curl/interface.c  2010-11-29 14:39:00 UTC (rev 
305834)
+++ php/php-src/trunk/ext/curl/interface.c  2010-11-29 14:40:59 UTC (rev 
305835)
@@ -1771,7 +1771,7 @@
int type;
void * what;

-   what = zend_fetch_resource(zvalue TSRMLS_CC, -1, 
File-Handle, type, 1, php_file_le_stream());
+   what = zend_fetch_resource(zvalue TSRMLS_CC, -1, 
File-Handle, type, 1, php_file_le_stream(), php_file_le_pstream());
if (!what) {
RETVAL_FALSE;
return 1;

-- 
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

[PHP-CVS] svn: /php/php-src/ branches/PHP_5_3/NEWS branches/PHP_5_3/ext/curl/interface.c trunk/ext/curl/interface.c

2010-03-10 Thread Felipe Pena
felipe   Wed, 10 Mar 2010 22:58:46 +

Revision: http://svn.php.net/viewvc?view=revisionrevision=296048

Log:
- Fixed bug #51257 (CURL_VERSION_LARGEFILE incorrectly used after libcurl 
version 7.10.1)
  patch by: aron dot ujvari at microsec dot hu

Bug: http://bugs.php.net/51257 (Open) CURL_VERSION_LARGEFILE incorrectly used 
after libcurl version 7.10.1
  
Changed paths:
U   php/php-src/branches/PHP_5_3/NEWS
U   php/php-src/branches/PHP_5_3/ext/curl/interface.c
U   php/php-src/trunk/ext/curl/interface.c

Modified: php/php-src/branches/PHP_5_3/NEWS
===
--- php/php-src/branches/PHP_5_3/NEWS   2010-03-10 22:46:39 UTC (rev 296047)
+++ php/php-src/branches/PHP_5_3/NEWS   2010-03-10 22:58:46 UTC (rev 296048)
@@ -6,6 +6,8 @@
 - Added stream filter support to mcrypt extension (ported from
   mcrypt_filter). (Stas)

+- Fixed bug #51257 (CURL_VERSION_LARGEFILE incorrectly used after libcurl
+  version 7.10.1). (aron dot ujvari at microsec dot hu)
 - Fixed bug #51242 (Empty mysql.default_port does not default to 3306 anymore,
   but 0). (Adam)
 - Fixed bug #51237 (milter SAPI crash on startup). (igmar at palsenberg dot 
com)

Modified: php/php-src/branches/PHP_5_3/ext/curl/interface.c
===
--- php/php-src/branches/PHP_5_3/ext/curl/interface.c   2010-03-10 22:46:39 UTC 
(rev 296047)
+++ php/php-src/branches/PHP_5_3/ext/curl/interface.c   2010-03-10 22:58:46 UTC 
(rev 296048)
@@ -370,7 +370,7 @@
 #ifdef CURL_VERSION_IPV6
{IPv6, CURL_VERSION_IPV6},
 #endif
-#if LIBCURL_VERSION_NUM  0x070a09 /* 7.10.1 */
+#if LIBCURL_VERSION_NUM  0x070b00 /* 7.11.1 */
{Largefile, CURL_VERSION_LARGEFILE},
 #endif
 #if LIBCURL_VERSION_NUM  0x070a05 /* 7.10.6 */

Modified: php/php-src/trunk/ext/curl/interface.c
===
--- php/php-src/trunk/ext/curl/interface.c  2010-03-10 22:46:39 UTC (rev 
296047)
+++ php/php-src/trunk/ext/curl/interface.c  2010-03-10 22:58:46 UTC (rev 
296048)
@@ -370,7 +370,7 @@
 #ifdef CURL_VERSION_IPV6
{IPv6, CURL_VERSION_IPV6},
 #endif
-#if LIBCURL_VERSION_NUM  0x070a09 /* 7.10.1 */
+#if LIBCURL_VERSION_NUM  0x070b00 /* 7.11.1 */
{Largefile, CURL_VERSION_LARGEFILE},
 #endif
 #if LIBCURL_VERSION_NUM  0x070a05 /* 7.10.6 */

-- 
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

[PHP-CVS] svn: /php/php-src/ branches/PHP_5_3/NEWS branches/PHP_5_3/ext/curl/interface.c trunk/ext/curl/interface.c

2009-09-15 Thread Pierre-Alain Joye
pajoye   Tue, 15 Sep 2009 15:47:06 +

Revision: http://svn.php.net/viewvc?view=revisionrevision=288348

Log:
- #49253, add support for libcurl's CERTINFO option

Bug: http://bugs.php.net/49253 (Assigned) add support for libcurl's CERTINFO 
option
  
Changed paths:
U   php/php-src/branches/PHP_5_3/NEWS
U   php/php-src/branches/PHP_5_3/ext/curl/interface.c
U   php/php-src/trunk/ext/curl/interface.c

Modified: php/php-src/branches/PHP_5_3/NEWS
===
--- php/php-src/branches/PHP_5_3/NEWS	2009-09-15 06:52:03 UTC (rev 288347)
+++ php/php-src/branches/PHP_5_3/NEWS	2009-09-15 15:47:06 UTC (rev 288348)
@@ -1,6 +1,8 @@
 PHPNEWS
 |||
 ?? ??? 2009, PHP 5.3.2
+- Implement FR #49253 (add support for libcurl's CERTINFO option).
+  (Linus Nielsen Feltzing li...@haxx.se)

 ?? ??? 2009, PHP 5.3.1RC?
 - Fixed certificate validation inside php_openssl_apply_verification_policy

Modified: php/php-src/branches/PHP_5_3/ext/curl/interface.c
===
--- php/php-src/branches/PHP_5_3/ext/curl/interface.c	2009-09-15 06:52:03 UTC (rev 288347)
+++ php/php-src/branches/PHP_5_3/ext/curl/interface.c	2009-09-15 15:47:06 UTC (rev 288348)
@@ -629,6 +629,9 @@
 	REGISTER_CURL_CONSTANT(CURLINFO_REDIRECT_COUNT);
 	REGISTER_CURL_CONSTANT(CURLINFO_HEADER_OUT);
 	REGISTER_CURL_CONSTANT(CURLINFO_PRIVATE);
+#if LIBCURL_VERSION_NUM   0x071202
+	REGISTER_CURL_CONSTANT(CURLINFO_CERTINFO);
+#endif

 	/* cURL protocol constants (curl_version) */
 	REGISTER_CURL_CONSTANT(CURL_VERSION_IPV6);
@@ -744,6 +747,9 @@
 	REGISTER_CURL_CONSTANT(CURLFTPSSL_CONTROL);
 	REGISTER_CURL_CONSTANT(CURLFTPSSL_ALL);
 #endif
+#if LIBCURL_VERSION_NUM   0x071202
+	REGISTER_CURL_CONSTANT(CURLOPT_CERTINFO);
+#endif

 /* SSH support works in 7.19.0+ using libssh2 */
 #if LIBCURL_VERSION_NUM = 0x071300
@@ -1336,6 +1342,85 @@
 }
 /* }}} */

+#if LIBCURL_VERSION_NUM   0x071202
+/* {{{ split_certinfo
+ */
+static void split_certinfo(char *string, zval *hash)
+{
+	int i;
+	char *org = estrdup(string);
+	char *s = org;
+	char *split;
+
+	if(org) {
+do {
+			char *key;
+			char *val;
+			char *tmp;
+
+split = strstr(s, ; );
+if(split)
+*split = '\0';
+
+			key = s;
+			tmp = memchr(key, '=', 64);
+			if(tmp) {
+*tmp = '\0';
+val = tmp+1;
+add_assoc_string(hash, key, val, 1);
+			}
+			s = split+2;
+		} while(split);
+		efree(org);
+	}
+}
+
+/* {{{ create_certinfo
+ */
+static void create_certinfo(struct curl_certinfo *ci, zval *listcode)
+{
+	int i;
+
+	if(ci) {
+		zval *certhash = NULL;
+		char *tmp;
+
+		for(i=0; ici-num_of_certs; i++) {
+			struct curl_slist *slist;
+
+			MAKE_STD_ZVAL(certhash);
+			array_init(certhash);
+			for(slist = ci-certinfo[i]; slist; slist = slist-next) {
+int len;
+char s[64];
+char *tmp;
+strncpy(s, slist-data, 64);
+tmp = memchr(s, ':', 64);
+if(tmp) {
+	*tmp = '\0';
+	len = strlen(s);
+	if(!strcmp(s, Subject) || !strcmp(s, Issuer)) {
+		zval *hash;
+
+		MAKE_STD_ZVAL(hash);
+		array_init(hash);
+
+		split_certinfo(slist-data[len+1], hash);
+		add_assoc_zval(certhash, s, hash);
+	} else {
+		add_assoc_string(certhash, s, slist-data[len+1], 1);
+	}
+} else {
+	php_error_docref(NULL TSRMLS_CC, E_WARNING, Could not extract hash key from certificate info);
+}
+			}
+			add_next_index_zval(listcode, certhash);
+		}
+	}
+}
+/* }}} */
+#endif
+
 /* {{{ proto resource curl_init([string url])
Initialize a cURL session */
 PHP_FUNCTION(curl_init)
@@ -1561,6 +1646,9 @@
 #if LIBCURL_VERSION_NUM = 0x070f01
 		case CURLOPT_FTP_FILEMETHOD:
 #endif
+#if LIBCURL_VERSION_NUM   0x071202
+		case CURLOPT_CERTINFO:
+#endif
 			convert_to_long_ex(zvalue);
 #if LIBCURL_VERSION_NUM = 0x71304
 			if (((PG(open_basedir)  *PG(open_basedir)) || PG(safe_mode))  (Z_LVAL_PP(zvalue)  CURLPROTO_FILE)) {
@@ -2105,6 +2193,10 @@
 		char   *s_code;
 		longl_code;
 		double  d_code;
+#if LIBCURL_VERSION_NUM   0x071202
+		struct curl_certinfo *ci = NULL;
+		zval *listcode;
+#endif

 		array_init(return_value);

@@ -2175,6 +2267,14 @@
 		if (curl_easy_getinfo(ch-cp, CURLINFO_REDIRECT_TIME, d_code) == CURLE_OK) {
 			CAAD(redirect_time, d_code);
 		}
+#if LIBCURL_VERSION_NUM   0x071202
+		if (curl_easy_getinfo(ch-cp, CURLINFO_CERTINFO, ci) == CURLE_OK) {
+			MAKE_STD_ZVAL(listcode);
+			array_init(listcode);
+			create_certinfo(ci, listcode);
+			CAAZ(certinfo, listcode);
+		}
+#endif
 		if (ch-header.str_len  0) {
 			CAAS(request_header, ch-header.str);
 		}
@@ -2234,6 +2334,20 @@
 } else {
 	RETURN_FALSE;
 }
+#if LIBCURL_VERSION_NUM   0x071202
+			case CURLINFO_CERTINFO: {
+struct curl_certinfo *ci = NULL;
+
+