PHP Classes

File: siteaccess.php

Recommend this page to a friend!
  Classes of MarPlo   Web Site Traffic and Pages Access   siteaccess.php   Download  
File: siteaccess.php
Role: Application script
Content type: text/plain
Description: Includes the script classes and outputs registered data
Class: Web Site Traffic and Pages Access
Record visits of real users to Web site pages
Author: By
Last change: Simplified the code
Date: 10 years ago
Size: 2,207 bytes
 

Contents

Class file image Download
<?php
// Script - Website Mini-Traffic and Pages Access data - from: http://coursesweb.net/
if(!isset($_SESSION) && !headers_sent()) session_start(); // initiate Session

// sets where to save data, 'mysql' in MySQL database; 'file' in text file on server (in 'storedata' folder)
define('STORE_DATA', 'file');

// Here sets the number or results for number o last accessed pages AND number of top accessed pages
$nrlastacc = 8;
$nrtopacc = 8;

// HERE add data for connecting to mysql database (needed only if STORE_DATA is 'mysql')
$mysql = array(
 
'host' => 'localhost',
 
'user' => 'user_name',
 
'pass' => 'password',
 
'bdname' => 'database_name'
);

define('ISAJAX', isset($_REQUEST['isajax']) ? 1 : 0); // Constant used to check if request from Ajax

include('siteaccess/lang.php');
include(
'siteaccess/class.BaseConn.php');
include(
'siteaccess/class.MiniTrafic.php'); // Includes MiniTrafic class (extends 'class.BaseConn')
include('siteaccess/class.PagesAccess.php'); // Includes PagesAccess class (extends 'class.BaseConn')

// create objects of MiniTrafic and PagesAccess classes
$objMT = new MiniTrafic($mysql);
$objSA = new PagesAccess($mysql);

$siteaccess = ''; // to store all accessing site data that will be added in html page

// if no request to set to create table
if(!isset($_GET['set'])) {
 
$siteaccess .= $objSA->getLastPages($nrlastacc); // Last accessed pages
 
$siteaccess .= $objSA->topMonth($nrtopacc); // Top accessed pages in current month
 
$siteaccess .= $objSA->getTopPages($nrtopacc); // Top most accessed pages
 
$siteaccess .= $objMT->getTraff($objSA->currentpage); // adds data with website traffic data


 
$siteaccess .= '<div id="frm_s"><a href="http://coursesweb.net" title="Courses and tutorials for web programming and development">http://coursesweb.net</a></div>';
  if(isset(
$_GET['pga'])) {
    echo
'if(document.getElementById("siteacc")) document.getElementById("siteacc").innerHTML = \''. str_replace(array(PHP_EOL, "'"), array('', "\\'"), $siteaccess) .'\'; document.write(\'<script src="siteaccess/siteaccess.js" type="text/javascript"></script>\');';
  }
}