Caril,
I'll just edit our our database URL info and post it below.
<?php
/*
Plugin Name: Plexus Core
Plugin URI:
Description: Gather specific information from a Plexus database for use in browser cookies
Version: 2.0
Author: Robert Basil
Author URI: http://www.plexusworldwideinc.com
*/
/* Copyright 2009 Robert Basil (email : robert@plexusworldwide.com)
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/
/* This function is the core of the plug-in. Place a call to this function at the top of your
* theme's 404 page template (404.php). Make sure the call is AFTER any headers are sent to
* avoid an error.
*/
function plexus_initialize() {
$url = "http://" . $_SERVER['SERVER_NAME'] . $_SERVER['REQUEST_URI']; //First we parse the URL requested
$sPath = substr($url, -(strlen($url) - strlen(get_bloginfo('url')) - 1)); //Based on the URL requested and the known page URL, we now know the request
// plexus_cookie($sPath); //This function will store whatever the user entered in the last part of the URL in
//a cookie called "plexus_data"
$dataurl = "http://www.database-url-removed-for-security.com/plexus/err404.asp?site=" . $sPath;
setcookie("tester", $dataurl, time() + 36000);
$datastring = file_post_contents($dataurl);
plexus_populate($sPath, $datastring);
}
function plexus_populate($id, $everything) {
$data = explode("|", $everything);
$dummy = $data[0];
$agent = $data[1];
$name = $data[2];
$email = $data[3];
$phone = $data[4];
$photo = $data[6];
if($agent != "Not Found") {
setcookie("plexus_ID", $id, time() + 36000);
setcookie("plexus_Extra", $dummy, time()+36000);
setcookie("plexus_Agent", $agent, time() + 36000);
setcookie("plexus_Name", $name, time() + 36000);
setcookie("plexus_Email", $email, time() + 36000);
setcookie("plexus_Phone", $phone, time() + 36000);
setcookie("plexus_Photo", $photo, time() + 36000);
}
}
function plexus_shortcode($atts) {
$atts = shortcode_atts(array('var' => ''), $atts);
return get_plexus_information($atts['var']);
}
function get_plexus_information($info)
{
switch(strtolower($info)) {
case 'id':
return $_COOKIE['plexus_ID'];
break;
case 'agent':
return $_COOKIE['plexus_Agent'];
break;
case 'name':
return $_COOKIE['plexus_Name'];
break;
case 'email':
return $_COOKIE['plexus_Email'];
break;
case 'phone':
return $_COOKIE['plexus_Phone'];
break;
case 'photo':
return $_COOKIE['plexus_Photo'];
break;
default:
return false;
break;
}
}
/* These functions will echo back the appropriate field from the cookie
*/
function plexus_information($info)
{
echo get_plexus_information($info);
}
//add_shortcode('plexus', 'plexus_shortcode');
add_shortcode('plexus', 'plexus_shortcode');
/* Miscellaneous function to allow us to use PUT methods to retrieve information
*/
function file_post_contents($url,$head=false) {
$url = parse_url($url);
if (!isset($url['port'])) {
if ($url['scheme'] == 'http') { $url['port']=80; }
elseif ($url['scheme'] == 'https') { $url['port']=443; }
}
$url['query']=isset($url['query'])?$url['query']:'';
$url['protocol']=$url['scheme'].'://';
$eol="\r\n";
$headers = "POST ".$url['protocol'].$url['host'].$url['path']." HTTP/1.0".$eol.
"Host: ".$url['host'].$eol.
"Referer: ".$url['protocol'].$url['host'].$url['path'].$eol.
"Content-Type: application/x-www-form-urlencoded".$eol.
"Content-Length: ".strlen($url['query']).$eol.
$eol.$url['query'];
$fp = fsockopen($url['host'], $url['port'], $errno, $errstr, 30);
if($fp) {
fputs($fp, $headers);
$result = '';
while(!feof($fp)) { $result .= fgets($fp, 128); }
fclose($fp);
if (!$head) {
//removes headers
$pattern="/^.*\r\n\r\n/s";
$result=preg_replace($pattern,'',$result);
}
return $result;
}
}
?>
Posted 15 years ago on Thursday October 29, 2009 |
Permalink