. *******************************************************************************/ /** * */ class ASException extends Exception { } /** * */ class AgentStorm { /** * */ function adminInit() { wp_register_style('AgentStormDefault', WP_PLUGIN_URL . DIRECTORY_SEPARATOR . array_pop(explode('/', dirname(__FILE__))) . '/static/css/default.css'); wp_register_style('AgentStormJqueryUI', WP_PLUGIN_URL . DIRECTORY_SEPARATOR . array_pop(explode('/', dirname(__FILE__))) . '/static/css/custom.css'); } /** * */ function adminRegisterMenu() { $page = add_menu_page('Agent Storm', 'Agent Storm', 'administrator', __FILE__, array(&$this, 'displayAdmin'), WP_PLUGIN_URL . DIRECTORY_SEPARATOR . array_pop(explode('/', dirname(__FILE__))) . '/static/images/icon.png'); add_action('admin_print_styles-' . $page, array($this, 'adminLoadStyles')); } /** * */ function adminLoadStyles() { wp_enqueue_style('AgentStormDefault'); wp_enqueue_style('AgentStormJqueryUI'); wp_enqueue_script("jquery"); wp_enqueue_script("jquery-ui-tabs"); } /** * */ function loadSiteStyles() { // Require jQuery // wp_enqueue_script("jquery"); // Register the Javascript files // wp_register_script('jQueryCarosel', WP_PLUGIN_URL . DIRECTORY_SEPARATOR . array_pop(explode('/', dirname(__FILE__))) . '/static/js/jquery.jcarousel.min.js'); wp_register_script('jQueryPikachoose', WP_PLUGIN_URL . DIRECTORY_SEPARATOR . array_pop(explode('/', dirname(__FILE__))) . '/static/js/jquery.pikachoose.4.js'); wp_register_script('AgentStormGallery', WP_PLUGIN_URL . DIRECTORY_SEPARATOR . array_pop(explode('/', dirname(__FILE__))) . '/static/js/as.gallery-init.js'); wp_register_script('GoogleMaps', 'http://maps.google.com/maps/api/js?sensor=false®ion=US"'); // Register the Site Default Styles // wp_register_style('AgentStormSite', WP_PLUGIN_URL . DIRECTORY_SEPARATOR . array_pop(explode('/', dirname(__FILE__))) . '/static/css/site.css'); wp_register_style('AgentStormSiteRed', WP_PLUGIN_URL . DIRECTORY_SEPARATOR . array_pop(explode('/', dirname(__FILE__))) . '/static/css/site-red.css'); wp_register_style('AgentStormSiteBlue', WP_PLUGIN_URL . DIRECTORY_SEPARATOR . array_pop(explode('/', dirname(__FILE__))) . '/static/css/site-blue.css'); wp_register_style('AgentStormSiteGrey', WP_PLUGIN_URL . DIRECTORY_SEPARATOR . array_pop(explode('/', dirname(__FILE__))) . '/static/css/site-grey.css'); wp_register_style('AgentStormSiteBrown', WP_PLUGIN_URL . DIRECTORY_SEPARATOR . array_pop(explode('/', dirname(__FILE__))) . '/static/css/site-brown.css'); wp_register_style('jQueryPikachooseCSS', WP_PLUGIN_URL . DIRECTORY_SEPARATOR . array_pop(explode('/', dirname(__FILE__))) . '/static/css/styles.css'); wp_register_style('jQueryPikachooseSkin', WP_PLUGIN_URL . DIRECTORY_SEPARATOR . array_pop(explode('/', dirname(__FILE__))) . '/static/css/skin.css'); // Add the correct built in stylesheets // switch (get_option('as_usestyle', '')) { case '1': wp_enqueue_style('AgentStormSite'); break; case '2': wp_enqueue_style('AgentStormSite'); wp_enqueue_style('AgentStormSiteRed'); break; case '3': wp_enqueue_style('AgentStormSite'); wp_enqueue_style('AgentStormSiteBlue'); break; case '4': wp_enqueue_style('AgentStormSite'); wp_enqueue_style('AgentStormSiteGrey'); break; case '5': wp_enqueue_style('AgentStormSite'); wp_enqueue_style('AgentStormSiteBrown'); break; } // Add the required Javascript files // wp_enqueue_script('jQueryCarosel'); wp_enqueue_script('jQueryPikachoose'); wp_enqueue_script('AgentStormGallery'); wp_enqueue_script('GoogleMaps'); // Add the CSS Files // wp_enqueue_style('jQueryPikachooseCSS'); wp_enqueue_style('jQueryPikachooseSkin'); } function isConfigured() { return (get_option('as_hostname', false) && get_option('as_apikey', false)); } /** * */ function displayAdmin() { if (!empty($_POST)) { $this->saveAdmin(); } include dirname(__FILE__) . DIRECTORY_SEPARATOR . 'agentstorm_admin.php'; } /** * */ function saveAdmin() { $as = new AgentStormRequest(get_option('as_hostname'), get_option('as_apikey')); // Save the Settings Variables // if (isset($_POST['as_settings_save'])) { // Save the Options // if (isset($_POST['as_usestyle'])) { update_option('as_usestyle', $_POST['as_usestyle']); } if (isset($_POST['as_hostname'])) { update_option('as_hostname', $_POST['as_hostname']); } if (isset($_POST['as_apikey'])) { update_option('as_apikey', $_POST['as_apikey']); } // Force and Update of the Cities database // $as_tags = $as->getTags(); update_option('as_tags', $as_tags->Tags); // If we have previously selected a tag and it does not exist in the current // dataset (maybe we switched hostnames) then reset the flag. // if (get_option('as_idx_settings_tag', '') != '') { $tag_exists = false; foreach ($as_tags->Tags as $tag) { if (get_option('as_idx_settings_tag', '') == $tag->Name) { $tag_exists = true; } } if (!$tag_exists) update_option('as_idx_settings_tag', ''); } // Get the cities // update_option('as_cities', $as->getCities()); // Schedule the Cities and Tags caches to be refreshed hourly // agentstorm_hourly(); } // Save the Contact Manager Settings // if (isset($_POST['as_contact_save'])) { if (isset($_POST['as_contact_emailnotification'])) { update_option('as_contact_emailnotification', true); } else { update_option('as_contact_emailnotification', false); } if (isset($_POST['as_contact_tags'])) { update_option('as_contact_tags', $_POST['as_contact_tags']); } if (isset($_POST['as_contact_source'])) { update_option('as_contact_source', $_POST['as_contact_source']); } } // Save the IDX Data Settings // if (isset($_POST['as_idx_save'])) { if (isset($_POST['as_idx_seo'])) { update_option('as_idx_seo', true); } else { update_option('as_idx_seo', false); } if (isset($_POST['as_idx_urlprefix'])) { update_option('as_idx_urlprefix', $_POST['as_idx_urlprefix']); } if (isset($_POST['as_idx_gmap'])) { update_option('as_idx_gmap', true); } else { update_option('as_idx_gmap', false); } if (isset($_POST['as_idx_bview'])) { update_option('as_idx_bview', true); } else { update_option('as_idx_bview', false); } if (isset($_POST['as_idx_walkscore'])) { update_option('as_idx_walkscore', $_POST['as_idx_walkscore']); } if (isset($_POST['as_idx_searchtxt'])) { update_option('as_idx_searchtxt', $_POST['as_idx_searchtxt']); } } // Save the IDX Data Settings // if (isset($_POST['as_idx_settings_save'])) { if (isset($_POST['as_idx_settings_pagelimit'])) { update_option('as_idx_settings_pagelimit', $_POST['as_idx_settings_pagelimit']); } if (isset($_POST['as_idx_settings_tag'])) { if (get_option('as_idx_settings_tag') !== $_POST['as_idx_settings_tag']) { update_option('as_idx_settings_tag', $_POST['as_idx_settings_tag']); update_option('as_cities', $as->getCities()); } } } // Save the Agent Information // if (isset($_POST['as_idx_agent_save'])) { if (isset($_POST['as_idx_agent_name'])) { update_option('as_idx_agent_name', $_POST['as_idx_agent_name']); } if (isset($_POST['as_idx_agent_phone'])) { update_option('as_idx_agent_phone', $_POST['as_idx_agent_phone']); } if (isset($_POST['as_idx_agent_email'])) { update_option('as_idx_agent_email', $_POST['as_idx_agent_email']); } if (isset($_POST['as_idx_agent_extra'])) { update_option('as_idx_agent_extra', $_POST['as_idx_agent_extra']); } } } } class AgentStormIDX extends stdClass { public $var1 = ''; public $var2 = ''; public $var3 = ''; public $title = ''; /** * */ function init(&$wp) { $path = $wp->request; $groups = array(); if (preg_match("%" . get_option('as_idx_urlprefix') . "/([a-zA-Z0-9-]+)/?([a-zA-Z0-9-+]+)?/?([0-9]+)?/?%", $path, $groups)) { $this->var1 = urldecode($groups[1]); $this->var2 = urldecode($groups[2]); $this->var3 = urldecode($groups[3]); if (!empty($this->var1) || !empty($this->var2) || !empty($this->var3)) { add_filter('the_posts', array(&$this, 'seoFilter')); add_filter('wp_title', array(&$this, 'seoTitle')); add_action('template_redirect', array(&$this, 'seoPage')); } } elseif (preg_match("%" . get_option('as_idx_urlprefix') . "-search/?%", $path, $groups)) { add_filter('the_posts', array(&$this, 'searchFilter')); add_filter('wp_title', array(&$this, 'searchTitle')); add_action('template_redirect', array(&$this, 'searchPage')); } add_shortcode('agentstorm', array(&$this, 'addShortCode')); } function addShortCode($atts) { extract(shortcode_atts(array( 'template' => 'large' ), $atts)); $file = ''; switch ($template) { case 'small': $file = 'agentstorm_searchsmall.php'; break; case 'tabbed': $file = 'agentstorm_searchtabbed.php'; break; default: $file = 'agentstorm_search.php'; break; } ob_start(); include dirname(__FILE__) . DIRECTORY_SEPARATOR . $file; $page_content = ob_get_contents(); ob_end_clean(); return $page_content; } function seoFilter($posts) { $results = null; $query = array(); $offset = (array_key_exists('offset', $_GET)) ? $_GET['offset'] : '0'; $limit = get_option('as_idx_pagelimit'); $as = new AgentStormRequest(trim(get_option('as_hostname')), trim(get_option('as_apikey'))); if (!empty($this->var3) && is_numeric($this->var3)) { $properties = $as->getProperty($this->var3); } elseif (!empty($this->var1) && !empty($this->var2)) { $properties = $as->getProperties(array( 'State' => $this->var1, 'City' => $this->var2, 'limit' => get_option('as_idx_pagelimit'), 'offset' => $offset )); } elseif (!empty($this->var1) && empty($this->var2)) { $properties = $as->getProperties(array( 'State' => $this->var1, 'limit' => get_option('as_idx_pagelimit'), 'offset' => $offset )); } $results = $properties->Properties; $state = $this->var1; $city = $this->var2; if (sizeof($results) == 0) { $this->title = 'Properties for Sale in '; $this->title .= (!empty($city)) ? ucwords(strtolower($city)) . ', ' : ''; $this->title .= (strlen($state) == 2) ? strtoupper($state) : ucwords(strtolower($state)); ob_start(); include dirname(__FILE__) . DIRECTORY_SEPARATOR . 'agentstorm_noresults.php'; $page_content = ob_get_contents(); ob_end_clean(); } elseif (sizeof($results) == 1) { $result = $results[0]; $this->title = $result->FullAddress . ', ' . ucwords(strtolower($result->City)) . ', ' . ucwords(strtolower($result->State)) . '. ' . $result->Zip; // Get the Walkscore // if (get_option('as_idx_walkscore')) { $walkscore = @json_decode(@file_get_contents('http://api.walkscore.com/score?format=json&address=' . urlencode($result->StreetNumber . ' ' . $result->StreetPrefix . ' ' . $result->StreetName . ' ' . $result->StreetSuffix . ' ' . $result->City . ' ' . $result->State . ' ' . $result->Zip) . '&lat=' . $result->Latitude . '&lon=' . $result->Longitude . '&wsapikey=' . get_option('as_idx_walkscore'))); } ob_start(); include dirname(__FILE__) . DIRECTORY_SEPARATOR . 'agentstorm_result.php'; $page_content = ob_get_contents(); ob_end_clean(); } else { $this->title = 'Properties for Sale in '; $this->title .= (!empty($city)) ? ucwords($city) . ', ' : ''; $this->title .= ucwords($state); ob_start(); include dirname(__FILE__) . DIRECTORY_SEPARATOR . 'agentstorm_results.php'; $page_content = ob_get_contents(); ob_end_clean(); } return array(new AgentStormPage(-1, $this->title, $page_content)); } function seoTitle() { return $this->title . ' - '; } function seoPage() { header("Status: 200",true, 200); include(TEMPLATEPATH . '/page.php'); exit; } function searchFilter($post) { $as = new AgentStormRequest(trim(get_option('as_hostname')), trim(get_option('as_apikey'))); $query = array(); if ($_GET['as_searchwidget_submit']) { // MLS Number // if (isset($_GET['as_mlsnumber']) && !empty($_GET['as_mlsnumber'])) { $query['ListingId'] = $_GET['as_mlsnumber']; } // Property Type // if (isset($_GET['as_propertytype']) && !empty($_GET['as_propertytype'])) { $query['Type'] = $_GET['as_propertytype']; } // Zip Code / Suburb // if (isset($_GET['as_suburbzip']) && !empty($_GET['as_suburbzip'])) { if (preg_match("/^[0-9]{5}$/", $_GET['as_suburbzip'])) { $query['Zip'] = $_GET['as_suburbzip']; } else { $query['City'] = $_GET['as_suburbzip']; } } // Price High to Low Handler // if (isset($_GET['as_pricerange_min']) && isset($_GET['as_pricerange_max']) && $_GET['as_pricerange_min'] > 0 && $_GET['as_pricerange_max'] > 0) { $query['ListPrice'] = $_GET['as_pricerange_min'] . ':' . $_GET['as_pricerange_max']; } elseif (isset($_GET['as_pricerange_min']) && $_GET['as_pricerange_min'] > 0) { $query['ListPrice'] = $_GET['as_pricerange_min'] . '+'; } elseif (isset($_GET['as_pricerange_max']) && $_GET['as_pricerange_max'] > 0) { $query['ListPrice'] = $_GET['as_pricerange_max'] . '-'; } // Lot Size Handler // if (isset($_GET['as_lotsize_min']) && isset($_GET['as_lotsize_max']) && $_GET['as_lotsize_min'] > 0 && $_GET['as_lotsize_max'] > 0) { $query['LotSqft'] = $_GET['as_lotsize_min'] . ':' . $_GET['as_lotsize_max']; } elseif (isset($_GET['as_lotsize_min']) && $_GET['as_lotsize_min'] > 0) { $query['LotSqft'] = $_GET['as_lotsize_min'] . '+'; } elseif (isset($_GET['as_lotsize_max']) && $_GET['as_lotsize_max'] > 0) { $query['LotSqft'] = $_GET['as_lotsize_max'] . '-'; } // Size Handler // if (isset($_GET['as_size_min']) && isset($_GET['as_size_max']) && $_GET['as_size_min'] > 0 && $_GET['as_size_max'] > 0) { $query['Sqft'] = $_GET['as_size_min'] . ':' . $_GET['as_size_max']; } elseif (isset($_GET['as_size_min']) && $_GET['as_size_min'] > 0) { $query['Sqft'] = $_GET['as_size_min'] . '+'; } elseif (isset($_GET['as_size_max']) && $_GET['as_size_max'] > 0) { $query['Sqft'] = $_GET['as_size_max'] . '-'; } // Bedrooms // if (isset($_GET['as_bedrooms']) && !empty($_GET['as_bedrooms'])) { $query['Bedrooms'] = $_GET['as_bedrooms']; } // Bathrooms // if (isset($_GET['as_bathrooms']) && !empty($_GET['as_bathrooms'])) { $query['FullBathrooms'] = $_GET['as_bathrooms']; } // City Search if (isset($_GET['idx_city'])) { $query['City'] = $_GET['as_city']; } // Paging // $offset = 0; if (isset($_GET['offset'])) { $query['offset'] = $offset = $_GET['offset']; } // Sort // if (isset($_GET['sort'])) { $query['FullBathrooms'] = $_GET['sort']; } // Limit // $limit = $query['limit'] = get_option('as_idx_pagelimit'); $properties = $as->getProperties($query); $this->title = 'Search Results'; $results = $properties->Properties; if (sizeof($results) == 0) { ob_start(); include dirname(__FILE__) . DIRECTORY_SEPARATOR . 'agentstorm_noresults.php'; $page_content = ob_get_contents(); ob_end_clean(); } elseif (sizeof($results) == 1) { $result = $results[0]; ob_start(); include dirname(__FILE__) . DIRECTORY_SEPARATOR . 'agentstorm_result.php'; $page_content = ob_get_contents(); ob_end_clean(); } else { ob_start(); include dirname(__FILE__) . DIRECTORY_SEPARATOR . 'agentstorm_results.php'; $page_content = ob_get_contents(); ob_end_clean(); } } else { $this->title = 'Property Search'; ob_start(); include dirname(__FILE__) . DIRECTORY_SEPARATOR . 'agentstorm_search.php'; $page_content = ob_get_contents(); ob_end_clean(); } return array(new AgentStormPage(-1, $this->title, $page_content)); } function searchTitle() { return $this->title . ' - '; } function searchPage() { header("Status: 200",true, 200); include(TEMPLATEPATH . '/page.php'); exit; } } class AgentStormPagination { var $base_url = ''; // The page we are linking to var $total_rows = ''; // Total number of items (database results) var $per_page = 10; // Max number of items you want shown per page var $num_links = 2; // Number of "digit" links to show before/after the currently viewed page var $cur_page = 0; // The current page being viewed var $first_link = '‹ First'; var $next_link = '>'; var $prev_link = '<'; var $last_link = 'Last ›'; var $uri_segment = 3; var $full_tag_open = ''; var $full_tag_close = ''; var $first_tag_open = ''; var $first_tag_close = ' '; var $last_tag_open = ' '; var $last_tag_close = ''; var $cur_tag_open = ' '; var $cur_tag_close = ''; var $next_tag_open = ' '; var $next_tag_close = ' '; var $prev_tag_open = ' '; var $prev_tag_close = ''; var $num_tag_open = ' '; var $num_tag_close = ''; var $page_query_string = FALSE; var $query_string_segment = 'per_page'; /** * Constructor * * @access public * @param array initialization parameters */ function AgentStormPagination($params = array()) { if (count($params) > 0) { $this->initialize($params); } } // -------------------------------------------------------------------- /** * Initialize Preferences * * @access public * @param array initialization parameters * @return void */ function initialize($params = array()) { if (count($params) > 0) { foreach ($params as $key => $val) { if (isset($this->$key)) { $this->$key = $val; } } } } // -------------------------------------------------------------------- /** * Generate the pagination links * * @access public * @return string */ function create_links() { // If our item count or per-page total is zero there is no need to continue. if ($this->total_rows == 0 OR $this->per_page == 0) { return ''; } // Calculate the total number of pages $num_pages = ceil($this->total_rows / $this->per_page); // Is there only one page? Hm... nothing more to do here then. if ($num_pages == 1) { return ''; } // Determine the current page number. $this->num_links = (int)$this->num_links; if ($this->num_links < 1) { show_error('Your number of links must be a positive number.'); } if ( ! is_numeric($this->cur_page)) { $this->cur_page = 0; } // Is the page number beyond the result range? // If so we show the last page if ($this->cur_page > $this->total_rows) { $this->cur_page = ($num_pages - 1) * $this->per_page; } $uri_page_number = $this->cur_page; $this->cur_page = floor(($this->cur_page/$this->per_page) + 1); // Calculate the start and end numbers. These determine // which number to start and end the digit links with $start = (($this->cur_page - $this->num_links) > 0) ? $this->cur_page - ($this->num_links - 1) : 1; $end = (($this->cur_page + $this->num_links) < $num_pages) ? $this->cur_page + $this->num_links : $num_pages; // Is pagination being used over GET or POST? If get, add a per_page query // string. If post, add a trailing slash to the base URL if needed $this->base_url = $this->base_url; // And here we go... $output = ''; // Render the "First" link if ($this->cur_page > ($this->num_links + 1)) { $output .= $this->first_tag_open.''.$this->first_link.''.$this->first_tag_close; } // Render the "previous" link if ($this->cur_page != 1) { $i = $uri_page_number - $this->per_page; if ($i == 0) $i = ''; $output .= $this->prev_tag_open.''.$this->prev_link.''.$this->prev_tag_close; } // Write the digit links for ($loop = $start -1; $loop <= $end; $loop++) { $i = ($loop * $this->per_page) - $this->per_page; if ($i >= 0) { if ($this->cur_page == $loop) { $output .= $this->cur_tag_open.$loop.$this->cur_tag_close; // Current page } else { $n = ($i == 0) ? '' : $i; $output .= $this->num_tag_open.''.$loop.''.$this->num_tag_close; } } } // Render the "next" link if ($this->cur_page < $num_pages) { $output .= $this->next_tag_open.''.$this->next_link.''.$this->next_tag_close; } // Render the "Last" link if (($this->cur_page + $this->num_links) < $num_pages) { $i = (($num_pages * $this->per_page) - $this->per_page); $output .= $this->last_tag_open.''.$this->last_link.''.$this->last_tag_close; } // Kill double slashes. Note: Sometimes we can end up with a double slash // in the penultimate link so we'll kill all double slashes. $output = preg_replace("#([^:])//+#", "\\1/", $output); // Add the wrapper HTML if exists $output = $this->full_tag_open.$output.$this->full_tag_close; return $output; } } class AgentStormCaptcha { var $session_key = null; var $temp_dir = null; var $width = 160; var $height = 60; var $jpg_quality = 15; /** * Constructor - Initializes Captcha class! * * @param string $session_key * @param string $temp_dir * @return captcha */ function captcha( $session_key, $temp_dir ) { $this->session_key = $session_key; $this->temp_dir = $temp_dir; } /** * Generates Image file for captcha * * @param string $location * @param string $char_seq * @return unknown */ function _generate_image( $location, $char_seq ) { $num_chars = strlen($char_seq); $img = imagecreatetruecolor( $this->width, $this->height ); imagealphablending($img, 1); imagecolortransparent( $img ); // generate background of randomly built ellipses for ($i=1; $i<=200; $i++) { $r = round( rand( 0, 100 ) ); $g = round( rand( 0, 100 ) ); $b = round( rand( 0, 100 ) ); $color = imagecolorallocate( $img, $r, $g, $b ); imagefilledellipse( $img, round(rand(0, $this->width)), round(rand(0, $this->height)), round(rand(0, $this->width/16)), round(rand(0, $this->height/4)), $color ); } $start_x = round($this->width / $num_chars); $max_font_size = $start_x; $start_x = round(0.5*$start_x); $max_x_ofs = round($max_font_size*0.9); // set each letter with random angle, size and color for ($i=0;$i<=$num_chars;$i++) { $r = round( rand( 127, 255 ) ); $g = round( rand( 127, 255 ) ); $b = round( rand( 127, 255 ) ); $y_pos = ($this->height/2)+round( rand( 5, 20 ) ); $fontsize = round( rand( 18, $max_font_size) ); $color = imagecolorallocate( $img, $r, $g, $b); $presign = round( rand( 0, 1 ) ); $angle = round( rand( 0, 25 ) ); if ($presign==true) $angle = -1*$angle; ImageTTFText( $img, $fontsize, $angle, $start_x+$i*$max_x_ofs, $y_pos, $color, 'default.ttf', substr($char_seq, $i, 1) ); } // create image file imagejpeg( $img, $location, $this->jpg_quality ); flush(); imagedestroy( $img ); return true; } /** * Returns name of the new generated captcha image file * * @param unknown_type $num_chars * @return unknown */ function get_pic( $num_chars=8 ) { // define characters of which the captcha can consist $alphabet = array( 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z', '1', '2', '3', '4', '5', '6', '7', '8', '9', '0' ); $max = sizeof( $alphabet ); // generate random string $captcha_str = ''; for ($i=1;$i<=$num_chars;$i++) // from 1..$num_chars { // choose randomly a character from alphabet and append it to string $chosen = rand( 1, $max ); $captcha_str .= $alphabet[$chosen-1]; } // generate a picture file that displays the random string if ( $this->_generate_image( $this->temp_dir.'/'.'cap_'.md5( strtolower( $captcha_str )).'.jpg' , $captcha_str ) ) { $fh = fopen( $this->temp_dir.'/'.'cap_'.$this->session_key.'.txt', "w" ); fputs( $fh, md5( strtolower( $captcha_str ) ) ); return( md5( strtolower( $captcha_str ) ) ); } else { return false; } } /** * check hash of password against hash of searched characters * * @param string $char_seq * @return boolean */ function verify( $char_seq ) { $fh = fopen( $this->temp_dir.'/'.'cap_'.$this->session_key.'.txt', "r" ); $hash = fgets( $fh ); if (md5(strtolower($char_seq)) == $hash) return true; else return false; } } class AgentStormPage { public $ID = -1; public $post_title = 'This is a Page'; public $post_content = '
Here is the content
'; public $post_author; public $post_status = 'publish'; public $post_type = 'page'; public $ping_status = 'closed'; public $comment_status = 'closed'; public $comment_count = 0; public $post_date = ''; public $post_date_gmt = ''; /** * */ function __construct($id, $title, $content) { $this->post_date = current_time('mysql'); $this->post_date_gmt = current_time('mysql', 1); $this->post_author = 1; $this->ID = $id; $this->post_title = $title; $this->post_content = $content; } /** * */ function toArray() { $return = array(); foreach ($this as $key => $value) { $return[$key] = $value; } return $return; } } class AgentStormWidgetContact { /** * */ function init() { register_sidebar_widget('Agent Storm Contact Manager Widget', array($this, 'display')); register_widget_control('Agent Storm Contact Manager Widget', array($this, 'displayAdmin')); } /** * */ function canCreateCaptcha() { return function_exists('imagecreatetruecolor'); } /** * */ function display($args) { // Build our captcha session code // if (array_key_exists('as_session_code', $_POST)) { $session_code = $_POST['as_session_code']; } else { $session_code = md5(round(rand(0, 40000))); } $as_saved = false; if (!empty($_POST)) { if (isset($_POST['as_contactwidget_submit'])) { // Build the basic document to be posted // $xmldoc = new SimpleXMLElement('