66 * without having to worry about the finer details of the API.
77 *
88 * @author Colin Seymour <[email protected] > 9- * @version 1.1
9+ * @version 1.2
1010 * @package phpZenfolio
1111 * @license GNU General Public License version 3 {@link http://www.gnu.org/licenses/gpl.html}
1212 * @copyright Copyright (c) 2010 Colin Seymour
@@ -54,27 +54,28 @@ class PhpZenfolioException extends Exception {}
5454 * @package phpZenfolio
5555 **/
5656class phpZenfolio {
57- static $ version = '1.1 ' ;
57+ static $ version = '1.2 ' ;
5858 private $ cacheType = FALSE ;
5959 private $ cache_expire = 3600 ;
6060 private $ keyring ;
6161 private $ id ;
6262 protected $ authToken ;
6363 private $ adapter = 'curl ' ;
64+ private $ secure = FALSE ;
6465
6566 /**
66- * When your database cache table hits this many rows, a cleanup
67- * will occur to get rid of all of the old rows and cleanup the
68- * garbage in the table. For most personal apps, 1000 rows should
69- * be more than enough. If your site gets hit by a lot of traffic
70- * or you have a lot of disk space to spare, bump this number up.
71- * You should try to set it high enough that the cleanup only
72- * happens every once in a while, so this will depend on the growth
73- * of your table.
74- *
75- * @var integer
76- **/
77- var $ max_cache_rows = 1000 ;
67+ * When your database cache table hits this many rows, a cleanup
68+ * will occur to get rid of all of the old rows and cleanup the
69+ * garbage in the table. For most personal apps, 1000 rows should
70+ * be more than enough. If your site gets hit by a lot of traffic
71+ * or you have a lot of disk space to spare, bump this number up.
72+ * You should try to set it high enough that the cleanup only
73+ * happens every once in a while, so this will depend on the growth
74+ * of your table.
75+ *
76+ * @var integer
77+ **/
78+ var $ max_cache_rows = 1000 ;
7879
7980 /**
8081 * Constructor to set up a phpZenfolio instance.
@@ -94,13 +95,13 @@ class phpZenfolio {
9495 * in the form "AppName/version (URI)"
9596 * e.g. "My Cool App/1.0 (http://my.url.com)".
9697 * @param string $APIVer (Optional) API endpoint you wish to use.
97- * Defaults to 1.4
98+ * Defaults to 1.6
9899 * @return void
99100 **/
100101 public function __construct ()
101102 {
102103 $ args = phpZenfolio::processArgs ( func_get_args () );
103- $ this ->APIVer = ( array_key_exists ( 'APIVer ' , $ args ) ) ? $ args ['APIVer ' ] : '1.4 ' ;
104+ $ this ->APIVer = ( array_key_exists ( 'APIVer ' , $ args ) ) ? $ args ['APIVer ' ] : '1.6 ' ;
104105 // Set the Application Name
105106 if ( ! isset ( $ args ['AppName ' ] ) ) {
106107 throw new PhpZenfolioException ( 'Application name missing. ' , -10001 );
@@ -306,6 +307,7 @@ private function cache( $request, $response )
306307 **/
307308 public function clearCache ( $ delete = FALSE )
308309 {
310+ $ result = TRUE ;
309311 if ( $ this ->cacheType == 'db ' ) {
310312 if ( $ delete ) {
311313 $ result = $ this ->cache_db ->exec ( 'DROP TABLE ' . $ this ->cache_table );
@@ -343,13 +345,13 @@ public function clearCache( $delete = FALSE )
343345 **/
344346 private function request ( $ command , $ args = array () )
345347 {
346- if ( $ command == 'AuthenticatePlain ' ) {
348+ if ( $ command == 'AuthenticatePlain ' || $ this -> secure === TRUE ) {
347349 $ proto = "https " ;
348350 } else {
349351 $ proto = "http " ;
350352 }
351353
352- $ this ->req ->setURL ( "$ proto://www .zenfolio.com/api/ {$ this ->APIVer }/zfapi.asmx " );
354+ $ this ->req ->setURL ( "$ proto://api .zenfolio.com/api/ {$ this ->APIVer }/zfapi.asmx " );
353355
354356 if ( ! is_null ( $ this ->authToken ) ) {
355357 $ this ->req ->setHeader ( 'X-Zenfolio-Token ' , $ this ->authToken );
@@ -420,6 +422,21 @@ public function setProxy()
420422 'proxy_auth_scheme ' => $ this ->proxy ['auth_scheme ' ] ) );
421423 }
422424
425+ /**
426+ * Force phpZenfolio to use HTTPS for ALL requests, not just authentication
427+ * requests.
428+ *
429+ * NOTE: This may have an adverse effect on performance if used for ALL requests.
430+ * Use with caution.
431+ *
432+ * @access public
433+ * @return void
434+ **/
435+ public function setSecureOnly ()
436+ {
437+ $ this ->secure = TRUE ;
438+ }
439+
423440 /**
424441 * Single login function for all login methods.
425442 *
@@ -526,7 +543,7 @@ public function upload()
526543 $ photoset = $ this ->LoadPhotoSet ( $ args ['PhotoSetId ' ] );
527544 $ UploadUrl = 'http://up.zenfolio.com ' . $ photoset ['UploadUrl ' ];
528545 } else {
529- $ photoset = ( $ this ->APIVer == '1.4 ' ) ? $ this ->LoadPhotoSet ( $ args ['PhotoSetId ' ], 'Level1 ' , FALSE ) : $ this ->LoadPhotoSet ( $ args ['PhotoSetId ' ] );
546+ $ photoset = ( $ this ->APIVer == '1.4 ' || $ this -> APIVer == ' 1.6 ' ) ? $ this ->LoadPhotoSet ( $ args ['PhotoSetId ' ], 'Level1 ' , FALSE ) : $ this ->LoadPhotoSet ( $ args ['PhotoSetId ' ] );
530547 $ UploadUrl = $ photoset ['UploadUrl ' ];
531548 }
532549 }
@@ -1353,4 +1370,4 @@ private function _unchunk( $body )
13531370 }
13541371}
13551372
1356- ?>
1373+ ?>
0 commit comments