PHP parse error ; syntax error ; unexpected error

 
0
 

<html>
<head>
<script type="text/javascript" src="jquery.js"></script>
<script type="text/javascript" src="Raphael.js"></script>
<script type="text/javascript">
<?php
include("class.logger.php"); //path to class.logger.php file
$log = new logger(); //Instentiate the class
$log->dbconnect(); //connect to database
//pass the name of the table as the parameter. I.e. 'logger"
$log->createtable('logger');

//set date and year text for the info bubble that appears on hover
$date = date('F')." ".date('Y');
//load raphael analytics javascript
//Parameters: "table[class], div[id], text[date], width, height, left gutter, bottom gutter, top gutter,stroke color, fontcolor, fill color, grid color
$log->loadraphael('data','holder',$date, 600, 250, 20, 30, 30,'#474747', '#000', '#eee', '#eee');
//load table hits containing data
//Parameters: month, year, div[id], table[class]
$log->dailyhits(11, 2009, 'holder', 'data');
//show total uniqe visitors to date(parameter: (int) number of months). For example: 3 will start counting from 3 monhts before today.
echo $log->totalunique(3);
//show total visits to date(parameter: (int) number of months). For example: 3 will start counting from 3 monhts before today.
echo $log->totalhits(3);
//visit details (parameter (int) number of last visits to display. For example :100 will show last 100 visits
//the info is displayed in a table with visitdetails[class] for easy CSS styling.
$log->visitdetails(100);
?>
</script>
<script type="text/javascript" src="logger.php?t=<?php echo time(); ?>&f=<?php echo $_SERVER; ?>&r=<?php echo urlencode($_SERVER);"></script>
</body>
</html>

Attachments class.logger_.php (12.79 KB)
The attachment preview is chopped off after the first 10 KB. Please download the entire file.
<?php
//start session
class logger {
//database setup
var $hostname_logon = 'localhost';  //Database server LOCATION
var $database_logon = '';    //Database NAME
var $username_logon = '';    //Database USERNAME
var $password_logon = '';    //Database PASSWORD
 
//table fields
var $tablename = '';        //logger table name
var $filter = array();      //array of ip's you don't want tracked
 
//connect to database
function dbconnect(){
    $connections = mysql_connect($this->hostname_logon, $this->username_logon, $this->password_logon) or die ('Unabale to connect to the database');
    mysql_select_db($this->database_logon) or die ("Error in query: $qry. " . mysql_error());
}
 
//log visit
function logvisit($ip, $host, $filename, $referring){
    //check if ip is filtered
    if(!in_array($ip,$this->filter)){
        $qry = "INSERT INTO ".$this->tablename." (ip, host, visitdate, visitedpage, referring)VALUES('".$ip."','".$host."',NOW(), '".$filename."', '".$referring."' )";
        $result = mysql_query($qry) or die ("Error in query: $qry. " . mysql_error());
 
    }
}
 
//show total uniqe visitors to date(parameter: (int) number of months). For example: 3 will start counting from 3 monhts before today.
function totalunique($month){
    $lastmonth = mktime(01, 01, 01, date("m")-$month, date("d"),   date("Y"));
    $from =  date("Y-m-d H:i:s", $lastmonth);
    $to = date("Y-m-d H:i:s");
    $qry = "SELECT DISTINCT ip, visitdate, host FROM ".$this->tablename." WHERE visitdate BETWEEN '".$from."' AND '".$to."' GROUP BY ip";
    $result = mysql_query($qry) or die ("Error in query: $qry. " . mysql_error());
    $totalunique = mysql_num_rows($result);
    return $totalunique;
}
 
//show total visits to date(parameter: (int) number of months). For example: 3 will start counting from 3 monhts before today.
function totalhits($month){
    $lastmonth = mktime(01, 01, 01, date("m")-$month, date("d"),   date("Y"));
    $from =  date("Y-m-d H:i:s", $lastmonth);
    $to = date("Y-m-d H:i:s");
    $qry = "SELECT ip, visitdate, host FROM ".$this->tablename." WHERE visitdate BETWEEN '".$from."' AND '".$to."'";
    $result = mysql_query($qry) or die ("Error in query: $qry. " . mysql_error());
    $totalhitsmonth = mysql_num_rows($result);
    return $totalhitsmonth;
}
 
//show daily visits for a specific month /  year and div in which to laod the graph
function dailyhits($month, $year, $div, $tableid){
    //current month and year
    if($month == ""){
        $month = date("m");
    }
    if($year == ""){
        $year = date("Y");
    }
 
    //get number of days
    $numdaysinmonth = cal_days_in_month(CAL_GREGORIAN, $month, $year);          
 
    echo '<table cellpadding="0" cellspacing="0" border="0" class="'.$tableid.'" >
    <tfoot>
        <tr>';
 
        for($x=1;$x<=$numdaysinmonth;$x++){
            echo '<th>'.$x.'</th>';
        }
 
    echo '</tr>
    </tfoot>
    <tbody>
        <tr>';
        $totalhits = 0;
        for($y=1;$y<=$numdaysinmonth;$y++){
         if($y < 10){
            $b = '0'.$y;
         }else{
            $b = $y;
         }
         $current_month = date('Y-m').'-'.$b;
         $qry = "SELECT DISTINCT ip FROM ".$this->tablename." WHERE visitdate LIKE '$current_month%' GROUP BY visitdate";
         $result = mysql_query($qry) or die ("Error in query: $qry. " . mysql_error());
         $numrows = mysql_num_rows($result);
 
            echo '<td>';
            echo $numrows;
            $totalhits = $totalhits + $numrows;
            echo '</td>';
        }
 
     echo '</tr>
    </tbody>
    </table>
    <div id="'.$div.'"></div>';
}
 
//display visit details (parameter (int) number of last visits to display
function visitdetails($num){
 
    $qry = "SELECT * FROM ".$this->tablename." WHERE visitdate!='' ORDER BY logid DESC LIMIT 0, ".$num."";
    $result = mysql_query($qry) or die ("Error in query: $qry. " . mysql_error());;
 
    if (mysql_num_rows($result) != 0){
        echo '<table cellpadding="0" cellspacing="0" border="0" class="visitdetails">';
        echo '<thead><tr><th>IP</th><th>Host</th><th>Referring Page</th><th>Page Visited</th><tr></thead>';
        echo '<tbody>';
        while ($row = mysql_fetch_object($result)){
            $nowww = ereg_replace('www.','',$row->referring);
            $domain = parse_url($nowww);
            if(!empty($domain["host"]))  {
                $host = $domain["host"];
            }
          echo '<tr><td>'.$row->ip.'</td>
          <td>'.$row->host.'</td>
          <td><a href="'.$row->referring.'" target="_blank">'.$host.'</a></td>
          <td><a href="..'.$row->filename.'" target="_blank">'.$row->filename.'</a></td>
          </tr>';
        }
        echo '</tbody>';
        echo '</table>';
    }
}
 
//raphael stuff(depends on including raphael.js library
function loadraphael($tableid, $div, $month_year, $width, $height, $leftgutter, $bottomgutter, $topgutter,$strokecolor, $fontcolor,$fillcolor,$gridcolor,$raphael_path){
//load latest jquery. Uncomment if you are already using jquery.
echo '<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.6.1/jquery.min.js"></script>';
echo '<script type="text/javascript" src="'.$raphael_path.'"></script><script type="text/javascript">
    //raphael.path.methods.js
    Raphael.el.isAbsolute = true;
    Raphael.el.absolutely = function () {
        this.isAbsolute = 1;
        return this;
    };
    Raphael.el.relatively = function () {
        this.isAbsolute = 0;
        return this;
    };
    Raphael.el.moveTo = function (x, y) {
        this._last = {x: x, y: y};
        return this.attr({path: this.attrs.path + ["m", "M"][+this.isAbsolute] + parseFloat(x) + " " + parseFloat(y)});
    };
    Raphael.el.lineTo = function (x, y) {
        this._last = {x: x, y: y};
        return this.attr({path: this.attrs.path + ["l", "L"][+this.isAbsolute] + parseFloat(x) + " " + parseFloat(y)});
    };
    Raphael.el.arcTo = function (rx, ry, large_arc_flag, sweep_flag, x, y, angle) {
        this._last = {x: x, y: y};
        return this.attr({path: this.attrs.path + ["a", "A"][+this.isAbsolute] + [parseFloat(rx), parseFloat(ry), +angle, large_arc_flag, sweep_flag, parseFloat(x), parseFloat(y)].join(" ")});
    };
    Raphael.el.curveTo = function () {
        var args = Array.prototype.splice.call(arguments, 0, arguments.length),
            d = [0, 0, 0, 0, "s", 0, "c"][args.length] || "";
        this.isAbsolute && (d = d.toUpperCase());
        this._last = {x: args[args.length - 2], y: args[args.length - 1]};
        return this.attr({path: this.attrs.path + d + args});
    };
    Raphael.el.cplineTo = function (x, y, w) {
        this.attr({path: this.attrs.path + ["C", this._last.x + w, this._last.y, x - w, y, x, y]});
        this._last = {x: x, y: y};
        return this;
    };
    Raphael.el.qcurveTo = function () {
        var d = [0, 1, "t", 3, "q"][arguments.length],
            args = Array.prototype.splice.call(arguments, 0, arguments.length);
        if (this.isAbsolute) {
            d = d.toUpperCase();
        }
        this._last = {x: args[args.length - 2], y: args[args.length - 1]};
        return this.attr({path: this.attrs.path + d + args});
    };
    Raphael.el.addRoundedCorner = function (r, dir) {
        var rollback = this.isAbsolute;
        rollback && this.relatively();
        this._last = {x: r * (!!(dir.indexOf("r") + 1) * 2 - 1), y: r * (!!(dir.indexOf("d") + 1) * 2 - 1)};
        this.arcTo(r, r, 0, {"lu": 1, "rd": 1, "ur": 1, "dl": 1}[dir] || 0, this._last.x, this._last.y);
        rollback && this.absolutely();
        return this;
    };
    Raphael.el.andClose = function () {
        return this.attr({path: this.attrs.path + "z"});
    };
 
    //raphael analytics
    Raphael.fn.drawGrid = function (x, y, w, h, wv, hv, color) {
    color = color || "'.$fillcolor.'";
    var path = ["M", x, y, "L", x + w, y, x + w, y + h, x, y + h, x, y],
        rowHeight = h / hv,
        columnWidth = w / wv;
    for (var i = 1; i < hv; i++) {
        path = path.concat(["M", x, y + i * rowHeight, "L", x + w, y + i * rowHeight]);
    }
    for (var i = 1; i < wv; i++) {
        path = path.concat(["M", x + i * columnWidth, y, "L", x + i * columnWidth, y + h]);
    }
    return this.path(path.join(",")).attr({stroke: color});
    };
    $(function () {
        $(".'.$tableid.'").css({
            position: "absolute",
            left: "-9999em",
            top: "-9999em"
        });
    });
    window.onload = function () {
    // Grab the data
    var labels = [],
        data = [];
    $(".'.$tableid.' tfoot th").each(function () {
        labels.push($(this).html());
    });
    $(".'.$tableid.' tbody td").each(function () {
        data.push($(this).html());
    });
 
    // Draw
    var width = '.$width.',
        height = '.$height.',
        leftgutter = '.$leftgutter.',
        bottomgutter = '.$bottomgutter.',
        topgutter = '.$topgutter.',
        colorhue = .6 || Math.random(),
        color = "hsb(" + [colorhue, 1, .75] + ")",
        r = Raphael("'.$div.'", width, height),
        txt = {font: \'12px Fontin-Sans, Arial\', fill: "'.$fontcolor.'"},
        txt1 = {font: \'10px Fontin-Sans, Arial\', fill: "'.$fontcolor.'"},
        txt2 = {font: \'12px Fontin-Sans, Arial\', fill: "'.$fillcolor.'"},
        X = (width - leftgutter) / labels.length,
        max = Math.max.apply(Math, data),
        Y = (height - bottomgutter - topgutter) / max;
    r.drawGrid(leftgutter + X * .5, topgutter, width - leftgutter - X, height - topgutter - bottomgutter, 10, 10, "'.$gridcolor.'");
    var path = r.path().attr({stroke: color, "stroke-width": 4, "stroke-linejoin": "round"}),
        bgp = r.path().attr({stroke: "none", opacity: .3, fill: color}).moveTo(leftgutter + X * .5, height - bottomgutter),
        frame = r.rect(10, 10, 100, 40, 5).attr({fill: "'.$fillcolor.'", stroke: "'.$strokecolor.'", "stroke-width": 2}).hide(),
        label = [],
logger.php (0.84 KB)
<?php
header('Content-type: text/javascript');
include("class.logger.php");                   //path to class.logger.php file
$log = new logger();                            //Instentiate the class
$log->tablename = "logger";                //set logger table name
$log->dbconnect();                             //connect to database
//$log->filter = array('00.00.00.000');      //array of IP addresses you don't want to track
 
//get IP
$ip = $_SERVER['REMOTE_ADDR'];
//get host
$host = gethostbyaddr($_SERVER['REMOTE_ADDR']);
//get fisited page
$filevisited = $_REQUEST['f'];
if($filevisited ==""){
    $filevisited = $_SERVER["PHP_SELF"];
}
//get referring page
$referring = urldecode($_REQUEST['r']);
if($referring ==""){
    $referring = $_SERVER["HTTP_REFERER"];
}
//log visit
$log->logvisit($ip, $host, $filevisited,  $referring);
?>
Raphael.js (207.2 KB)
The attachment preview is chopped off after the first 10 KB. Please download the entire file.
//  \\
//  Raphal 2.0.1 - JavaScript Vector Library                            \\
//  \\
//  Copyright (c) 2008-2011 Dmitry Baranovskiy (http://raphaeljs.com)    \\
//  Copyright (c) 2008-2011 Sencha Labs (http://sencha.com)              \\
//  Licensed under the MIT (http://raphaeljs.com/license.html) license.  \\
//  \\

//  \\
//  Eve 0.4.0 - JavaScript Events Library                                                 \\
//  \\
//  Copyright (c) 2008-2011 Dmitry Baranovskiy (http://dmitry.baranovskiy.com/)           \\
//  Licensed under the MIT (http://www.opensource.org/licenses/mit-license.php) license.  \\
//  \\

(function (glob) {
    var version = "0.4.0",
        has = "hasOwnProperty",
        separator = /[\.\/]/,
        wildcard = "*",
        fun = function () {},
        numsort = function (a, b) {
            return a - b;
        },
        current_event,
        stop,
        events = {n: {}},
    
        eve = function (name, scope) {
            var e = events,
                oldstop = stop,
                args = Array.prototype.slice.call(arguments, 2),
                listeners = eve.listeners(name),
                z = 0,
                f = false,
                l,
                indexed = [],
                queue = {},
                out = [],
                errors = [];
            current_event = name;
            stop = 0;
            for (var i = 0, ii = listeners.length; i < ii; i++) if ("zIndex" in listeners[i]) {
                indexed.push(listeners[i].zIndex);
                if (listeners[i].zIndex < 0) {
                    queue[listeners[i].zIndex] = listeners[i];
                }
            }
            indexed.sort(numsort);
            while (indexed[z] < 0) {
                l = queue[indexed[z++]];
                out.push(l.apply(scope, args));
                if (stop) {
                    stop = oldstop;
                    return out;
                }
            }
            for (i = 0; i < ii; i++) {
                l = listeners[i];
                if ("zIndex" in l) {
                    if (l.zIndex == indexed[z]) {
                        out.push(l.apply(scope, args));
                        if (stop) {
                            stop = oldstop;
                            return out;
                        }
                        do {
                            z++;
                            l = queue[indexed[z]];
                            l && out.push(l.apply(scope, args));
                            if (stop) {
                                stop = oldstop;
                                return out;
                            }
                        } while (l)
                    } else {
                        queue[l.zIndex] = l;
                    }
                } else {
                    out.push(l.apply(scope, args));
                    if (stop) {
                        stop = oldstop;
                        return out;
                    }
                }
            }
            stop = oldstop;
            return out.length ? out : null;
        };
    
    eve.listeners = function (name) {
        var names = name.split(separator),
            e = events,
            item,
            items,
            k,
            i,
            ii,
            j,
            jj,
            nes,
            es = [e],
            out = [];
        for (i = 0, ii = names.length; i < ii; i++) {
            nes = [];
            for (j = 0, jj = es.length; j < jj; j++) {
                e = es[j].n;
                items = [e[names[i]], e[wildcard]];
                k = 2;
                while (k--) {
                    item = items[k];
                    if (item) {
                        nes.push(item);
                        out = out.concat(item.f || []);
                    }
                }
            }
            es = nes;
        }
        return out;
    };
    
    
    eve.on = function (name, f) {
        var names = name.split(separator),
            e = events;
        for (var i = 0, ii = names.length; i < ii; i++) {
            e = e.n;
            !e[names[i]] && (e[names[i]] = {n: {}});
            e = e[names[i]];
        }
        e.f = e.f || [];
        for (i = 0, ii = e.f.length; i < ii; i++) if (e.f[i] == f) {
            return fun;
        }
        e.f.push(f);
        return function (zIndex) {
            if (+zIndex == +zIndex) {
                f.zIndex = +zIndex;
            }
        };
    };
    
    eve.stop = function () {
        stop = 1;
    };
    
    eve.nt = function (subname) {
        if (subname) {
            return new RegExp("(?:\\.|\\/|^)" + subname + "(?:\\.|\\/|$)").test(current_event);
        }
        return current_event;
    };
    
    eve.unbind = function (name, f) {
        var names = name.split(separator),
            e,
            key,
            splice,
            i, ii, j, jj,
            cur = [events];
        for (i = 0, ii = names.length; i < ii; i++) {
            for (j = 0; j < cur.length; j += splice.length - 2) {
                splice = [j, 1];
                e = cur[j].n;
                if (names[i] != wildcard) {
                    if (e[names[i]]) {
                        splice.push(e[names[i]]);
                    }
                } else {
                    for (key in e) if (e[has](key)) {
                        splice.push(e[key]);
                    }
                }
                cur.splice.apply(cur, splice);
            }
        }
        for (i = 0, ii = cur.length; i < ii; i++) {
            e = cur[i];
            while (e.n) {
                if (f) {
                    if (e.f) {
                        for (j = 0, jj = e.f.length; j < jj; j++) if (e.f[j] == f) {
                            e.f.splice(j, 1);
                            break;
                        }
                        !e.f.length && delete e.f;
                    }
                    for (key in e.n) if (e.n[has](key) && e.n[key].f) {
                        var funcs = e.n[key].f;
                        for (j = 0, jj = funcs.length; j < jj; j++) if (funcs[j] == f) {
                            funcs.splice(j, 1);
                            break;
                        }
                        !funcs.length && delete e.n[key].f;
                    }
                } else {
                    delete e.f;
                    for (key in e.n) if (e.n[has](key) && e.n[key].f) {
                        delete e.n[key].f;
                    }
                }
                e = e.n;
            }
        }
    };
    
    eve.once = function (name, f) {
        var f2 = function () {
            f.apply(this, arguments);
            eve.unbind(name, f2);
        };
        return eve.on(name, f2);
    };
    
    eve.version = version;
    eve.toString = function () {
        return "You are running Eve " + version;
    };
    (typeof module != "undefined" && module.exports) ? (module.exports = eve) : (glob.eve = eve);
})(this);

//  \\
//  "Raphal 2.0.1" - JavaScript Vector Library                          \\
//  \\
//  Copyright (c) 2008-2011 Dmitry Baranovskiy (http://raphaeljs.com)    \\
//  Copyright (c) 2008-2011 Sencha Labs (http://sencha.com)              \\
//  Licensed under the MIT (http://raphaeljs.com/license.html) license.  \\
//  \\
(function () {
    
    function R(first) {
        if (R.is(first, "function")) {
            return loaded ? first() : eve.on("DOMload", first);
        } else if (R.is(first, array)) {
            return R._engine.create[apply](R, first.splice(0, 3 + R.is(first[0], nu))).add(first);
        } else {
            var args = Array.prototype.slice.call(arguments, 0);
            if (R.is(args[args.length - 1], "function")) {
                var f = args.pop();
 
0
 

You are missing a ?> tag on line 30 (if you used CODE tags, the lines would be numbered :-). So line 30 should be

<script type="text/javascript" src="logger.php?t=<?php echo time(); ?>&f=<?php echo $_SERVER['REQUEST_URI']; ?>&r=<?php echo urlencode($_SERVER['REQUEST_URL']);?>"></script>

or something similar.

You
This article has been dead for over six months: Start a new discussion instead
Post:
Start New Discussion
View similar articles that have also been tagged: