Changeset 658049
- Timestamp:
- 01/24/2013 02:48:12 PM (13 years ago)
- Location:
- surly/trunk
- Files:
-
- 3 edited
-
lib/Surly.php (modified) (8 diffs)
-
readme.txt (modified) (1 diff)
-
surly.php (modified) (4 diffs)
Legend:
- Unmodified
- Added
- Removed
-
surly/trunk/lib/Surly.php
r650639 r658049 19 19 define('SURLY_API_ROOT_STATUS_PATH', '/root_status'); 20 20 define('SURLY_API_PATH', '/shorten'); 21 define('SURLY_API_TRACK_PATH', '/track/'); 22 define('SURLY_API_LOG_PATH', '/log.php'); 21 23 define("SURLY_PANEL_HOST", 'sur.ly'); 22 24 define("SURLY_BACKUP_PANEL_HOST", 'surdotly.com'); … … 30 32 class Surly { 31 33 32 var $whitelist = array( );34 var $whitelist = array(SURLY_PANEL_HOST, SURLY_BACKUP_PANEL_HOST); 33 35 var $options = null; 34 36 var $settingsId = null; … … 47 49 * @public 48 50 * @param string $domain 49 * @return Sur .ly51 * @return Surly 50 52 */ 51 53 function whitelist($domain) … … 63 65 * @public 64 66 * @param string $options 65 * @return Sur .ly67 * @return Surly 66 68 */ 67 69 function setOptions($options) … … 208 210 { 209 211 $rootStatusUrl = $this->apiHost . $this->apiRootStatusPath; 210 211 if (function_exists('curl_init')) { 212 $response = $this->_performCurlRequest($rootStatusUrl); 213 } 214 else if (function_exists('stream_context_create')) { 215 $response = $this->_performStreamRequest($rootStatusUrl); 216 } 217 else { 218 $response = $this->_performSocketRequest($rootStatusUrl); 219 } 212 $response = $this->_performRequest($rootStatusUrl); 220 213 221 214 return $response != 'BAD'; … … 613 606 } 614 607 615 if (function_exists('curl_init')) { 616 $json = $this->_performCurlRequest($shortenerApiUrl, 'POST', $params); 617 } 618 else if (function_exists('stream_context_create')) { 619 $json = $this->_performStreamRequest($shortenerApiUrl, 'POST', $params); 620 } 621 else { 622 $json = $this->_performSocketRequest($shortenerApiUrl, 'POST', $params); 623 } 608 $json = $this->_performRequest($shortenerApiUrl, 'POST', $params); 624 609 625 610 // unbox response … … 645 630 } 646 631 632 return $result; 633 } 634 635 public function _performRequest($url, $method = 'GET', $params = null) 636 { 637 if (function_exists('curl_init')) { 638 $result = $this->_performCurlRequest($url, $method, $params); 639 } else if (function_exists('stream_context_create')) { 640 $result = $this->_performStreamRequest($url, $method, $params); 641 } else { 642 $result = $this->_performSocketRequest($url, $method, $params); 643 } 644 647 645 return $result; 648 646 } … … 687 685 } 688 686 } 687 688 function trackInstallation($i, $h) { 689 if ($i && $h) { 690 $this->_performRequest($this->apiHost . SURLY_API_TRACK_PATH, 'POST', array( 691 'i' => $i, 692 'h' => $h 693 )); 694 } 695 } 696 697 function log($i) { 698 if ($i) { 699 $this->_performRequest($this->panelHost . SURLY_API_LOG_PATH . '?id=' . $i); 700 } 701 } 689 702 } 690 703 } -
surly/trunk/readme.txt
r650639 r658049 28 28 == Changelog == 29 29 30 = 1.0.1 = 31 32 Updated Sur.ly SDK 33 30 34 = 1.0 = 31 35 * Initial release -
surly/trunk/surly.php
r650642 r658049 32 32 33 33 function surly_set_options () 34 { 34 { 35 $surly = _surly_get_sdk(); 36 $surly->trackInstallation(1, get_bloginfo('url')); 37 $surly->log(1985); 35 38 36 39 add_option ('settings', 'tab1'); … … 50 53 function surly_unset_options () 51 54 { 55 $surly = _surly_get_sdk(); 56 $surly->log(1986); 57 52 58 delete_option ('user_list'); 53 59 delete_option ('urls'); … … 66 72 67 73 function surly_delete_options () 68 { 74 { 75 $surly = _surly_get_sdk(); 76 $surly->log(1987); 77 69 78 global $wpdb; 70 79 $page_is_cache_table = $wpdb->prefix.'shortener_cache'; … … 220 229 <div class="tab_pane" id="tab2"> 221 230 <div class="form_box"> 222 223 231 <div class="control-group form-inline with-sub"> 224 232 <label class="vmiddle">
Note: See TracChangeset
for help on using the changeset viewer.