(root)/tagwall.class.php - Rev 70
Rev 3 |
Blame |
Compare with Previous |
Last modification |
View Log
| RSS feed
<?PHP
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
* This file is part of Uberghey CMS
* A content management system with modules, based on wiki syntax
*
* Author: Dan Jensen <admin@leinir.dk>
* Copyright 2003/2004
*
* 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 2 of the License, or
* (at your option) any later version.
*
* The GNU General Public License is available at: http://www.gnu.org/copyleft/
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
/**
* This was modified heavily from a tagwall linked from www.experten.dk
*/
class Tagwall
{
var $ERRORS;
var $txtfile;
/**
* This function sets the file where tagwall data will be saved
* REMEMBER TO GIVE THIS FILE WRITE PERMISSION (chmod 777)
*
* @param $file name of text file to save tagwall info
*/
function setFile
($file) {
$this->txtfile = $file;
}
/**
* This function fetches tagwall data
*
* @return array tagwall entries
*/
function fetchTagwallData
() {
$fp = fopen($this->txtfile, "r");
if ($fp) {
$contents = fread($fp, filesize($this->txtfile));
$contents = explode(chr(0), $contents);
foreach ($contents as $key => $value) {
$contents[$key] = unserialize(&$contents[$key]);
if (!empty($contents[$key]["name"])) {
$data[] = $contents[$key];
}
}
fclose($fp);
if (is_array($data)) {
//These regular expression replaces make sure the botched up data from web forms
$data["text"] = preg_replace("/\\'/", "'", $data["text"]);
$data["text"] = preg_replace("/\\\\\"/", "\"", $data["text"]);
$data["text"] = preg_replace("/\\\\\\\\/", "\\", $data["text"]);
$data = array_reverse($data);
return $data;
} else {
return false;
}
} else {
$this->ERRORS = "Could not open file.";
return false;
}
}
/**
* This function inserts an entry to the tagwall
*
* @param $name name of user
* @param $email users email address
* @param $text text message
*
* @return boolean true or false
*/
function insertTagwallData
($name, $email, $text) {
//These regular expression replaces make sure the botched up data from web forms
$text = preg_replace("/\\\'/", "'", $text);
$text = preg_replace("/\\\\\"/", "\"", $text);
$text = preg_replace("/\\\\\\\\/", "\\", $text);
$data = array( "name" => $name,
"email" => $email,
"text" => $text,
"date" => date("F j, Y, g:i a"));
$data = serialize($data);
$fp = fopen($this->txtfile, "a");
if ($fp) {
$fp = fwrite($fp, $data . chr(0));
return true;
} else {
$this->ERRORS = "Could not open file.";
return false;
}
}
}
?>