Changeset 573301
- Timestamp:
- 07/16/2012 11:18:54 PM (14 years ago)
- Location:
- shopsite-plugin/trunk
- Files:
-
- 3 edited
-
oauth.php (modified) (6 diffs)
-
readme.txt (modified) (1 diff)
-
shopsite.php (modified) (8 diffs)
Legend:
- Unmodified
- Added
- Removed
-
shopsite-plugin/trunk/oauth.php
r514950 r573301 40 40 41 41 curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, $verify_peer); 42 curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 30); 42 43 43 44 $json = curl_exec($ch); 44 45 45 46 46 if ( !$json) {47 if ($json == false) { 47 48 return array('success'=>false, 'error'=>'Curl OAUTH call failed. Curl error: '.curl_error($ch)); 48 49 } … … 54 55 55 56 $json = json_decode($json, true); 57 if (!is_array($json)) 58 return array('success'=>false, 'error'=>'Malformed response or bad URL'); 56 59 57 60 if (array_key_exists("error", $json)) { … … 116 119 $db_request = trim($db_request, "&"); 117 120 118 debug_print("db_request: $db_request");121 //debug_print("db_request: $db_request"); 119 122 120 123 $ch = curl_init(); … … 137 140 138 141 curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, $verify_peer); 142 curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 30); 139 143 140 144 $downloaddata = curl_exec($ch); … … 146 150 147 151 //debug_print($downloaddata); 148 debug_print("downloaddata: $downloaddata");152 //debug_print("downloaddata: $downloaddata"); 149 153 150 154 if (($json2 = json_decode($downloaddata, true)) != NULL) { … … 195 199 curl_setopt($ch, CURLOPT_POSTFIELDS, $db_request); 196 200 curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, $verify_peer); 201 curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 30); 197 202 $downloaddata = curl_exec($ch); 198 203 -
shopsite-plugin/trunk/readme.txt
r556965 r573301 29 29 30 30 == Changelog == 31 = 1.2 = 32 * Added a Test Connection button on the configuration screen. Added a 30-second connection timeout. 33 31 34 = 1.1 = 32 35 * Fixed a bug preventing product display in the blog for some PHP config settings -
shopsite-plugin/trunk/shopsite.php
r556965 r573301 2 2 /** 3 3 * @package ShopSite 4 * @version 1. 14 * @version 1.2 5 5 */ 6 6 /* … … 9 9 Description: ShopSite plugin to put products into your WordPress blog 10 10 Author: ShopSite 11 Version: 1. 111 Version: 1.2 12 12 Author URI: http://shopsite.com/ 13 13 */ … … 34 34 } 35 35 36 37 36 38 $product_list; 37 39 $wp_id; … … 51 53 function show_shopsite_menu() { 52 54 global $wpdb; 55 include_once "oauth.php"; 56 $testing = false; 53 57 54 58 add_option('shopsite_url'); … … 71 75 72 76 if (isset($_REQUEST['identifier'])) update_option('identifier', $_REQUEST['identifier']); 77 if (isset($_REQUEST['test'])) { 78 $testing = true; 79 $test_result = test_connection(); 80 } 81 73 82 74 83 $shopsite_url = get_option('shopsite_url'); … … 86 95 $GUID_selected = "checked"; 87 96 97 //ss_action=plugins.php?page=shopsite_menu 88 98 echo "<h1>ShopSite configuration</h1> 89 <form method=post ss_action=plugins.php?page=shopsite_menu>99 <form method=post> 90 100 <table> 91 101 <tr><th colspan=2>Application settings</th></tr> 92 <tr><td>Client ID:</td><td><input type=text name=clientid value='$clientid' size=100></td></tr> 93 <tr><td>Secret Key for Signing:</td><td><input type=text name=secretkey value='$secretkey' size=100></td></tr> 94 <tr><td>Authorization Code:</td><td><input type=text name=code value='$code' size=100></td></tr> 95 <tr><td>Authorization URL:</td><td><input type=text name=authorizationurl value='$authorizationurl' size=100></td></tr> 96 <tr><th colspan=2>Other settings</th></tr> 102 <tr><td>Client ID:</td><td><input type=text name=clientid id=clientid value='$clientid' size=100></td></tr> 103 <tr><td>Secret Key for Signing:</td><td><input type=text name=secretkey id=secretkey value='$secretkey' size=100></td></tr> 104 <tr><td>Authorization Code:</td><td><input type=text name=code id=code value='$code' size=100></td></tr> 105 <tr><td>Authorization URL:</td><td><input type=text name=authorizationurl id=authorizationurl value='$authorizationurl' size=100></td></tr>"; 106 107 108 109 echo "<tr><th colspan=2>Other settings</th></tr> 97 110 <tr><td>ShopSite callback URL:</td><td><input type=text name=shopsite_url value='$shopsite_url' size=100></td></tr> 98 111 <tr><td>Unique product identifier:</td> … … 101 114 <input type=radio name=identifier value='SKU' $SKU_selected/>SKU</td></tr> 102 115 </table> 103 <br/><input type=submit value='Save settings'></form>"; 104 } 105 106 107 116 <br/><input type=submit name=test value='Test connection'>"; 117 118 if ($testing) { 119 echo "<br>"; 120 if ($test_result['success'] == true) 121 echo "<font color=green><b>Connection test successful</b></font>"; 122 if ($test_result['success'] == false) { 123 echo "<font color=red><b>Connection test failed, check your settings.<br>Error: ".$test_result["error"]; 124 } 125 } 126 127 echo "<br/><input type=submit value='Save settings'></form>"; 128 } 129 130 /*onclick='window.open(\"".plugin_dir_url(__FILE__)."shopsite.php?ss_action=test&clientid=\"+document.forms[0].clientid.value+\"&secretkey=\"+document.forms[0].secretkey.value 131 +\"&code=\"+document.forms[0].code.value+\"&authorizationurl=\"+document.forms[0].authorizationurl.value 132 ,\"\",\"width=400,height=300\");' */ 133 //document.forms[0].clientid.value 108 134 109 135 … … 479 505 } 480 506 507 function test_connection() { 508 $test_download_xml = oauth( 509 get_option('clientid'), get_option('secretkey'), get_option('code'), get_option('authorizationurl'), 510 DOWNLOAD, 511 array('clientApp'=>'1', 'dbname'=>'products', 'version'=>'11.2', 'fields'=>'|Product GUID|Name|SKU|', 'search_term'=>"B0gu5", 'search_on'=>'name', 'search_filter'=>'contains', 'limit'=>1) 512 ); 513 if (!$test_download_xml["success"]) 514 return $test_download_xml; 515 516 517 518 $shopsite_url = get_option('shopsite_url'); 519 $url_openable = ini_get('allow_url_fopen'); 520 ini_set('allow_url_fopen', true); 521 $url = $shopsite_url; 522 $handle = fopen($url,'r'); 523 ini_set('allow_url_fopen', $url_openable); 524 525 if ($handle == false) 526 return array("success"=>false, "error"=>"Check your callback URL"); 527 528 return array("success"=>true); 529 } 530 481 531 function debug_print($text) { 482 532 file_put_contents("log.txt", $text."\n", FILE_APPEND);
Note: See TracChangeset
for help on using the changeset viewer.