table_options = $wpdb->prefix . "amazonfeed_options"; $this->table_cache = $wpdb->prefix . "amazonfeed_cache"; // Default REST Parameters (can be over-ridden) $this->params = array( 'Operation' => 'ItemSearch', 'SearchIndex' => 'Books', 'ResponseGroup' => 'Small,Images' ); // Load Options $this->options = get_option('amazonFeedOptions'); // If we're ready to run live, activate the controls. if( isset($this->options['ServicePath']) AND isset($this->options['AWSAccessKeyId']) AND isset($this->options['AssociateTag']) AND isset($this->options['DefaultTags']) AND isset($this->options['DefaultSearchField']) AND isset($this->options['MaxResults']) AND isset($this->options['Version']) AND function_exists('simplexml_load_string') ) { $this->live = true; } } function unInstall() { global $wpdb; $sql = "DROP TABLE `" . $this->table_cache . "`;"; $wpdb->query($sql); delete_option('amazonFeedOptions'); } function checkInstall() { global $wpdb; if(!function_exists('simplexml_load_string')) { $this->admin_alert("WARNING: This plugin currently only works on servers running PHP v 5.x or higher."); return(false); } // Plugin options are not installed, implying that the plugin itself has not yet been installed either. if(!$this->options['Version']) { $this->admin_alert("Previous installation not found. Installing necessary tables now."); $sql = "CREATE TABLE IF NOT EXISTS `" . $this->table_cache . "` ( `keyword` varchar(255) NOT NULL, `timestamp` bigint(20) unsigned zerofill NOT NULL, `data` longblob NOT NULL, PRIMARY KEY (`keyword`) );"; $result = $wpdb->query($sql); if($result === false) { $this->admin_alert("Failed to create table."); return(false); } $this->options = array( 'Locale' => 'United States', 'LocaleTipTag' => 'usamazonfeed-20', 'ServicePath' => 'http://ecs.amazonaws.com/onca/xml?Service=AWSECommerceService', 'AWSAccessKeyId' => '', 'AssociateTag' => '', 'SearchFrom' => 'categories', 'DefaultTags' => '', 'ShowOnPosts' => true, 'ShowOnPages' => true, 'ShowOnHome' => true, 'ShowOnCategories' => true, 'ShowOnTags' => true, 'ShowOnSearch' => true, 'TitleText' => '
$msg
"; print_r($msg); echo ""; } function getpath($path, $username = false, $password = false) { $this->debug("Using built-in function to load data. Slower, but should work."); // Test URL and ensure that it is valid. if(false !== $username AND false !== $password) $match = "^([a-z]{2,10})\://" . $username . "\:" . $password . "([a-z0-9\.\-]+)/?([^\?]*)(.*)$"; else $match = "^([a-z]{2,10})\://([a-z0-9\.\-]+)(/?[^\?]*)(.*)$"; // Return false if the path does not look like a url. if(!eregi($match, $path, $regs)) { return(false); } else { list($path, $protocol, $hostname, $request, $query) = $regs; // Determine port protocol. switch(strtoupper($protocol)) { case "HTTPS": $port = 443; break; case "FTP": $port = 21; break; default: $port = 80; break; } } // Load url data $fp = fsockopen($hostname, $port, $errno, $errstr, 10); if (!$fp) { echo "$errstr ($errno)