plugins/conversions/docs/plugins/conversions/conversion_report/includes prepend.php,NONE,1.1 rss10.php,NONE,1.1

Sebastian Bergmann <[email protected]> Sun, 11 Apr 2004 09:45:18 +0000
Newsgroups gmane.comp.web.phpopentracker.cvs
Message-ID <[email protected]>
Update of /cvsroot/phpopencounter/plugins/conversions/docs/plugins/conversions/conversion_report/includes
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv2596/conversions/docs/plugins/conversions/conversion_report/includes

Added Files:
	prepend.php rss10.php 
Log Message:
Initial import of Conversions plugin by Daniel Kehoe and Adrian Lanning.

--- NEW FILE: rss10.php ---
<?php
//
// phpOpenTracker - The Website Traffic and Visitor Analysis Solution
//
// Copyright 2000 - 2004 Sebastian Bergmann. All rights reserved.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
//   http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//
// $Id: rss10.php,v 1.1 2004/04/11 09:45:15 bergmann Exp $
//

class RSSWriter {

function RSSWriter($uri, $title, $description, $meta=array()) {
	$this->chaninfo=array();
	$this->website=$uri;
	$this->chaninfo["link"]=$uri;
	$this->chaninfo["description"]=$description;
	$this->chaninfo["title"]=$title;
	$this->items=array();
	$this->modules=array("dc" => "http://purl.org/dc/elements/1.1/");
	$this->channelURI="http://" . $GLOBALS["SERVER_NAME"] . $GLOBALS["REQUEST_URI"];
	foreach ($meta as $key => $value) {
		$this->chaninfo[$key]=$value;
	}
}

function useModule($prefix, $uri) {
	$this->modules[$prefix]=$uri;
}

function setImage($imgURI, $imgAlt, $imgWidth=88, $imgHeight=31) {
	$this->image=array(
		"uri" => $imgURI, "title" => $imgAlt, "width" => $imgWidth,
		"height" => $imgHeight);
}

function addItem($uri, $title, $meta=array()) {
	$item=array("uri" => $uri, "link" => $uri, 
		"title" => $this->deTag($title));
	foreach ($meta as $key => $value) {
		if ($key == "description" || $key == "dc:description") {
			$value=$this->deTag($value);
		}
		$item[$key]=$value;
	}
	$this->items[]=$item;
}

function serialize() {
	$this->preamble();
	$this->channelinfo();
	$this->image();
	$this->items();
	$this->postamble();
}

function deTag($in) {
  while(ereg('<[^>]+>', $in)) {
	$in=ereg_replace('<[^>]+>', '', $in);
  }
  return $in;
}

function preamble() {
	header("Content-type: text/xml");
	print '<?xml version="1.0" encoding="iso-8859-1"?>
<rdf:RDF 
         xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
         xmlns="http://purl.org/rss/1.0/"
         xmlns:mn="http://usefulinc.com/rss/manifest/"
';
	foreach ($this->modules as $prefix => $uri) {
		print "         xmlns:${prefix}=\"${uri}\"\n";
	}
	print ">\n\n";
}

function channelinfo() {
	print '  <channel rdf:about="' .  $this->channelURI . '">
';
	$i=$this->chaninfo;
	foreach (array("title", "link", "dc:source", "description", "dc:language", "dc:publisher",
		"dc:creator", "dc:rights") as $f) {
		if (isset($i[$f])) {
			print "    <${f}>" . htmlspecialchars($i[$f]) . "</${f}>\n";
		}
	}
	if (isset($this->image)) {
		print "    <image rdf:resource=\"" . htmlspecialchars($this->image["uri"]) . "\" />\n";
	}
	print "    <items>\n";
	print "      <rdf:Seq>\n";
	foreach ($this->items as $i) {
		print "        <rdf:li rdf:resource=\"" . htmlspecialchars($i["uri"]) . "\" />\n";
	}
	print "      </rdf:Seq>\n";
	print "    </items>\n";
	print "  </channel>\n\n";
}

function image() {
	if (isset($this->image)) {
	print "  <image rdf:about=\"" . htmlspecialchars($this->image["uri"]) . "\">\n";
    print "     <title>" . htmlspecialchars($this->image["title"]) . "</title>\n";
    print "     <url>" . htmlspecialchars($this->image["uri"]) . "</url>\n";
    print "     <link>" . htmlspecialchars($this->website) . "</link>\n";
    if ($this->chaninfo["description"]) 
   	 print "     <dc:description>" . htmlspecialchars($this->chaninfo["description"]) . 
   	 	"</dc:description>\n";
	print "  </image>\n\n";
	}
}

function postamble() {
	print '  <rdf:Description rdf:ID="manifest">
    <mn:channels>
      <rdf:Seq>
        <rdf:li rdf:resource="' . $this->channelURI . '" />
      </rdf:Seq>
    </mn:channels>
  </rdf:Description>

</rdf:RDF>
';
}

function items() {
	foreach ($this->items as $item) {
		print "  <item rdf:about=\"" .  htmlspecialchars($item["uri"]) . "\">\n";
		foreach ($item as $key => $value) {
			if ($key!="uri") {
				if (is_array($value)) {
					foreach ($value as $v1) {
						print "    <${key}>" . htmlspecialchars($v1) . "</${key}>\n";
					}
				} else {
					print "    <${key}>" . htmlspecialchars($value) . "</${key}>\n";
				}
			}
		}
		print "  </item>\n\n";
	}
}

}

?>

--- NEW FILE: prepend.php ---
<?php
//
// phpOpenTracker - The Website Traffic and Visitor Analysis Solution
//
// Copyright 2000 - 2004 Sebastian Bergmann. All rights reserved.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
//   http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//
// $Id: prepend.php,v 1.1 2004/04/11 09:45:15 bergmann Exp $
//

// This "prepend" file is included before any script.
// It contains initialization functions that the scripts share in common.

// load phpOpenTracker
require_once 'phpOpenTracker.php';

// load Smarty library
require_once('Smarty.class.php');
$smarty = new Smarty;
// your web server must have write access to the following directories
$smarty-> compile_dir = '/tmp/compile';
$smarty -> config_dir = '/tmp/config';
$smarty -> cache_dir = '/tmp/cache';
// switch to 'true' for production deployment
$smarty-> force_compile = false;

// access control
$user = 'guest';
$loggedin = false;
session_start();
$user = $_SESSION['user'];
$loggedin = $_SESSION['loggedin'];
// if the user has not logged in, redirect to a login page
if (!isset($loggedin) || !$loggedin || $user == 'guest') {
	// redirects to the login page
	header('Location: login.php');
	exit();
}

// Map client IDs to client names
// if you are generating reports for more than one web site
// (optional if you want a client ID number and not a name)
if ($user == 'client1') {
	$clients = array(
	  1 => $_SERVER['HTTP_HOST'],
	  100 => 'site100.com',
	  101 => 'site101.com', 
	  102 => 'site102.com'
	);
	
	$clientSet2 = array(
	  1 => $_SERVER['HTTP_HOST'],
	  103 => 'site103.com',
	  104 => 'site104.com', 
	  105 => 'site105.com'
	);
}

if ($user == 'webmonkey') {
	$clients = array(
	  200 => 'site200.com',
	  201 => 'site201.com', 
	  202 => 'site202.com'
	);
	
	$clientSet2 = array(
	  203 => 'site203.com',
	  204 => 'site204.com', 
	  205 => 'site205.com'
	);
}


// How many "Top X of Total" items would you like to display?
$limit = 10;

// Month Names
$monthNames = array(
  'January',
  'February',
  'March',
  'April',
  'May',
  'June',
  'July',
  'August',
  'September',
  'October',
  'November',
  'December'
);

// allow PHP all the time it needs to generate a report
set_time_limit(0);

// get the current time
$time   = time();

// Prevent caching
header('Expires: Sat, 22 Apr 1978 02:19:00 GMT');
header('Last-Modified: ' . gmdate('D, d M Y H:i:s') . ' GMT');
header('Cache-Control: no-store, no-cache, must-revalidate');
header('Cache-Control: post-check=0, pre-check=0', false);
header('Pragma: no-cache');

header('Content-Type: text/html; charset=iso-8859-1');

// Handle HTTP GET parameters
$clientID = isset($_GET['client_id']) ? $_GET['client_id'] : 1;
$page     = isset($_GET['page'])      ? $_GET['page']      : 'access_statistics';
$day      = isset($_GET['day'])       ? $_GET['day']       : date('j');
$month    = isset($_GET['month'])     ? $_GET['month']     : date('n');
$year     = isset($_GET['year'])      ? $_GET['year']      : date('Y');

// Get references to phpOpenTracker's configuration
// and database objects
$config = &phpOpenTracker_Config::getConfig();
$db     = &phpOpenTracker_DB::getInstance();

if (isset($_REQUEST['debug'])) {
  phpOpenTracker_Config::set('debug_level', 2);
}

// follow this with a PHP script that calls the phpOpenTracker API
// and assigns data to Smarty template variables...
?>



-------------------------------------------------------
This SF.Net email is sponsored by: IBM Linux Tutorials
Free Linux tutorial presented by Daniel Robbins, President and CEO of
GenToo technologies. Learn everything from fundamentals to system
administration.http://ads.osdn.com/?ad_id=1470&alloc_id=3638&op=click