PHP Classes

File: CSession.php

Recommend this page to a friend!
  Classes of Moellers Oma   CAuth   CSession.php   Download  
File: CSession.php
Role: ???
Content type: text/plain
Description: contains the Session Variables of the User
Class: CAuth
authenticates users on mysql_db, with session
Author: By
Last change: several bugfixes
Date: 21 years ago
Size: 3,899 bytes
 

Contents

Class file image Download
<?PHP /********************************************************************************* ********************************************************************************** Class CSession{} Klasse für Sessionverwaltung. Desweiteren enthält sie Statistiken über die Nutzung der Webseite, In CSession->pages werden alle besuchten Seiten eingetragen. Mit Komma separiert. Die Funktion CSession->write_to_session() schreibt die Klassenvar CSession->pages in die Sessionvariable $GLOBALS["ses_pages"]. Desweiteren verbindet sich diese Funktion mit einer MySQL- Datenbank und schreibt die Statistiken in die DB. Autoren : Sven Zurnieden, Frank Cawein, Marcel Weilacher Datum : 22.06.2002 !!!!!!!!!!!!!!!V I S I T!!!!!!!!!!!!!!!!!!!!!! http://berl.dyndns.org/ !!!!!!!!!!!!!!!V I S I T!!!!!!!!!!!!!!!!!!!!!! ********************************************************************************** *********************************************************************************/ class CSession{ var $ses_id = "Keine Session ID"; var $remote_ip = "unknown"; var $debug = 0; var $pages = ""; function CSession($debug=0){ session_start(); $this->ses_id = session_id(); $this->pages=$GLOBALS["ses_pages"]; if($this->pages==""){ $this->pages="$GLOBALS[SCRIPT_FILENAME]"; } else{ $this->pages.=", $GLOBALS[SCRIPT_FILENAME]"; } $this->remote_ip = $GLOBALS["REMOTE_ADDR"]; $this->debug = $debug; if ($this->debug==1){ $this->show_debug(); } } function write_to_session(){ if(!session_is_registered("ses_register")){ session_register("ses_register"); session_register("ses_pages"); } $GLOBALS["ses_pages"]=$this->pages; $connect = mysql_connect("localhost","username","password")OR die ("<font size=5 color=#FF0000>!!!!!An Error occured while contacting the database!!!!!</font>"); mysql_select_db("webstats",$connect); $sql = "SELECT * FROM stats WHERE session_id = '$this->ses_id'"; $query = mysql_query($sql,$connect); $row = mysql_fetch_array($query,MYSQL_ASSOC); $now=time(); if($row["session_id"]==""){ $sql="INSERT INTO stats (session_id, remote_ip, pages, visit_time, last_visit) VALUES ('$this->ses_id','$this->remote_ip','$this->pages', '$now', '$now')"; } else{ $sql="UPDATE stats Set pages = '$this->pages', last_visit = '$now' WHERE session_id = '$this->ses_id'"; } mysql_query($sql,$connect); } function show_debug(){ echo "<font size=3 color=#222222><br> OBJEKT CSession<br></font>"; while(list($key,$val)=each($this)){ echo "<font size=3 color=#222222>$key ---> $val</font><br>"; } } function meta_tags($keywords, $title, $author="Sven Zurnieden, Frank Cawein, Marcel Weilacher"){ echo ' <meta http-equiv="Content-Type" content="text/html; charset=windows-1252"> <meta http-equiv="Content-Language" content="de"> <meta name="author" content="'.$author.'"> <meta name="GENERATOR" content="PHPEd"> <meta name="keywords" content="'.$keywords.'"> <meta http-equiv="Page-Enter" content="blendTrans(Duration=0.6)"> <meta http-equiv="Page-Exit" content="blendTrans(Duration=0.6)"> <title>'.$title.'</title> '; } } ?>