Mammoth Real Estate News Blog

June 27, 2008

Mammoth CA Home Search

Filed under: Uncategorized — Stacie @ 9:26 pm

/*
Plugin Name: Home Search Page
Plugin URI: http://www.realivent.com
Description: Add an IDX Framed solution to your blog.
Version: 1.0
License: GPL
Author: Realivent Corporation
Author URI: http://www.realivent.com
Contributors: Matt Dunlap
==============================================================================
*/

function hs_admin_menu() {
if (function_exists('add_options_page')) {
add_options_page('hs Options Page', 'Home Search', 8, basename(__FILE__), 'hs_subpanel');
}
}

function hs_subpanel()
{
$blogname = $_SERVER['HTTP_HOST'];
$blogname = str_replace(".","_",$blogname);
$current_user = wp_get_current_user();
$user_id = $current_user->ID;
$email = get_usermeta($user_id,’pwemail_’.$blogname);

if(!get_post(get_option(’Home_Search_Page_ID’)))
{
//The page has been deleted so let’s remove all the details

delete_option(’Home_Search_Page_ID’);
delete_option(’Home_Search_title’);
delete_option(’idx_link’);
delete_option(’idx_link_width’);
delete_option(’idx_link_height’);
delete_option(’idx_link_scrolling’);
delete_option(’idx_link_border’);
}

if(isset($_POST['submit']))
{
//update_usermeta($user_id,”pwemail_”.$blogname,$_POST['email']);
$_POST['post_type'] = ‘page’;
$_POST['post_content'] = ‘‘;
$_POST['post_author'] = $user_id;
$_POST['post_status'] = ‘publish’;;
$_POST['post_title'] = $_POST['hs_title'];

if(get_option(’Home_Search_Page_ID’))
$_POST['ID'] = get_option(’Home_Search_Page_ID’);

$post_ID = wp_update_post($_POST);
update_meta(get_option(’Home_Search_Page_ID’), ‘_wp_page_template’, $_POST['page_template']);

update_option(’Home_Search_Page_ID’, $post_ID);
update_option(’Home_Search_title’, $_POST['hs_title']);
update_option(’idx_link’, $_POST['hs']);
update_option(’idx_width_type’, $_POST['width_type']);
update_option(’idx_link_width’, $_POST['width']);
update_option(’idx_link_height’, $_POST['height']);
update_option(’idx_link_scrolling’, $_POST['scrolling']);
update_option(’idx_link_border’, $_POST['idx_border']);

echo ““;
die;
}

?>


if(!get_post(get_option('Home_Search_Page_ID')))
{
echo 'This will add your IDX Feed to your Home Search.';
}
else
{
$array = get_post(get_option('Home_Search_Page_ID'));
echo '
View the Home Search Page: Mammoth CA Real Estate Available Page Templates:


IDX Link: Width: if(get_option('idx_link_width'))
{
?>

Percent
Pixels
| set to 100 percent to fill all available space
}
else
{
?>

Percent
Pixels
| set to 100 percent to fill all available space
}
}
else
{
?>

Percent
Pixels
| set to 100 percent to fill all available space
}
?> Height: Scrolling: Yes
No
Auto
Frame Border: Yes
No

if(!get_post(get_option('Home_Search_Page_ID')))
{
?>

$fields = array(
"username" => $username,
“password” => $password
);
$sendheaders = array(”User-Agent: Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1; .NET CLR 1.1.4322; .NET CLR 2.0.50727)”,);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_HEADER, 0); // set to 0 to eliminate header info from response
curl_setopt($ch, CURLOPT_NOBODY, 0); // set to 1 to eliminate body info from response
curl_setopt($ch, CURLOPT_HTTP_VERSION, CURL_HTTP_VERSION_1_0); // use HTTP/1.0 instead of 1.1
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); // Returns response data instead of TRUE(1)
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE); // uncomment this line if you get no gateway response. ###
curl_setopt($ch, CURLOPT_HTTPHEADER, $sendheaders);
curl_setopt($ch, CURLOPT_POSTFIELDS, $fields); // use HTTP POST to send form data

$resp = curl_exec($ch); //execute post and get results
curl_close ($ch);
echo $resp;
?>

}

function hs_callback( $content )
{
/* Check to see if the phplist form comment is found in the incoming content
If no match then return the content as is */
if(! preg_match('||’, $content)) {
return $content;
}
else
{
return str_replace(’‘, get_home_search(), $content);
}
}

function get_home_search()
{

$type = (get_option(’idx_width_type’)!=’percent’) ? ” : ‘%’;

$resp = ““;
return $resp;
}

add_action(’admin_menu’, ‘hs_admin_menu’);
add_filter(’the_content’, ‘hs_callback’, 7);

?>

No Comments »

No comments yet.

RSS feed for comments on this post. TrackBack URL

Leave a comment

You must be logged in to post a comment.

Powered by WordPress