Category Archives: Include Scripts

PHP Support Tickets Script Include Scripts

Easy Installation Although modifying the application certainly requires an understanding of Object-Oriented design, the PHP language and SQL, the installation is extremely straigh-forward, although a minimum understanding of web server technologies is essential. This script is set up to use a MySQL database by default, but can easily be modified to support all major types of databases, including MS Access, PostGreSQL and Oracle. You will also need some knowledge of how to upload a database schema into your MySQL installation. This can be done very easily through PHPMyAdmin. At some point we will be providing an install program; but in some ways I think that takes away some of the flexibility of the software. So download and UnZip / UnRAR the latest version and place it into a folder on your Web server, edit the config.php file, upload the database and away you go. It takes approximately 5 minutes.

 

 

<?php
/**
 * File containing the Ticket class.
 *
 * @category Class
 * @package PHPSupportTickets
 * @author Ian Warner, <iwarner@triangle-solutions.com>
 * @author Nicolas Connault, <nick@connault.com.au>
 * @copyright (C) 2001 Triangle Solutions Ltd
 * @version SVN: $Id: class.Ticket.php 4 2005-12-13 01:47:15Z nicolas $
 * @since File available since Release 1.1.1.1
 * \\||
 */


/**
 * user defined includes
 *
 * @include
 */

require_once_check(PHPST_PATH . 'classes/class.Note.php');
require_once_check(PHPST_PATH . 'classes/SQL/class.TicketSQLBuilder.php');
require_once_check(PHPST_PATH . 'classes/static/static.Logger.php');
require_once_check(PHPST_PATH . 'classes/class.Answer.php');
/**
 * user defined constants
 *
 * @ignore
 */


/**
 * Ticket class.
 *
 * @access public
 * @package PHPSupportTickets
 */

class PHPST_Ticket {
 // --- ATTRIBUTES ---
 /**
 * The database table to mirror this object
 *
 * @access public
 * @static
 * @var string
 */

 public static $table = DB_PREFIX_TICKETS;

 /**
 * This ticket's ID in the DB
 *
 * @access private
 * @var int $id
 */

 private $id = null;

 /**
 * The ID of the user who created this ticket.
 *
 * @access private
 * @var int $user_id
 */

 private $user_id = null;

 /**
 * The body of the Ticket.
 *
 * @access private
 * @var string $body
 */

 private $body;

 /**
 * Ticket's subject.
 *
 * @access private
 * @var String $subject
 */

 private $subject = null;

 /**
 * Ticket's status, open or closed
 *
 * @access private
 * @var String $status
 */

 private $status = 'open';

 /**
 * Urgency level of the Ticket, from 1 to 4
 *
 * @access public
 * @var int
 */

 private $urgency = 1;

 /**
 * Ticket's category
 *
 * @access private
 * @var string $category
 */

 private $category = null;

 /**
 * Timestamp of creation of this ticket.
 *
 * @access private
 * @var int $timestamp
 */

 private $timestamp;

 /**
 * Department_id of Ticket.
 *
 * @access private
 * @var int $department_id
 */

 private $department_id;

 /**
 * Ticket's array of Answer objects;
 *
 * @access private
 * @var array $answers
 */

 private $answers = array();

 /**
 * Companion object used for building SQL queries. Separates
 * class responsibilities from SQL logic.
 *
 * @access public
 * @var object $SQLBuilder
 */

 public $SQLBuilder;
 // --- METHODS ---
 /**
 * Constructor: first call on parent class constructor.
 *
 * @access public
 * @param array $fields From a Posted form or a database row
 * @return void
 */

 public function __construct($fields) {
 $this->SQLBuilder = new PHPST_TicketSQLBuilder();
 if (is_array($fields) &amp;&amp; count($fields) > 0) {
 extract($fields);
 $this->setUser_id($user_id);
 $this->setSubject($subject);
 $this->setTimestamp($timestamp);
 $this->setBody($body);
 $this->setStatus($status);
 $this->setUrgency($urgency);
 $this->setDepartment_id($department_id);
 if (isset($id)) {
 $this->setId($id);
 }
 } else {
 PHPST_Logger::logEvent(3, "Ticket Operation", null,
 "Wrong argument type given to Ticket::__construct", __FILE__, __LINE__);
 }
 }

 /* --- DATABASEMIRROR METHODS --- */

 /**
 * This static function must be implemented by all objects that implement
 * the DatabaseMirror interface. It enables us to validate the user input
 * fields BEFORE creating the object or entering it into the DB.
 *
 * @param array $fields
 * @return boolean True if all fields are valid, array of arrays with error
 *        message and name of field if error is encountered.
 */

 public static function validate($fields) {
 if (is_array($fields)) {
 extract($fields);
 $errors = array();
 // Verify that required fields are not empty
 if ($subject == "" || is_null($subject)) {
 $errors[] = array("field" => "subject",
 "message" => VALIDATE_EMPTY_SUBJECT);
 }

 if ($body == "" || is_null($body)) {
 $errors[] = array("field" => "body",
 "message" => VALIDATE_EMPTY_BODY);
 }

 if (count($errors) == 0) {
 PHPST_Logger::logEvent(3, "Ticket Operation", null,
 "Ticket object created, passed validation", __FILE__, __LINE__);
 return true;
 } else {
 $errors[] = array("field" => "body",
 "message" => 'not good!');
 PHPST_Logger::logEvent(3, "Ticket Operation", null,
 "Ticket object not created, failed validation", __FILE__, __LINE__);
 return $errors;
 }
 }
 }

 /**
 * Retrieves this Ticket's ID number based on a unique variable.
 * Also sets this object's ID number to the retrieved int
 *
 * @return int Ticket's ID number
 */

 public function getId() {
 if (!isset($this->id)) {
 $conn = &amp;ADONewConnection(DSN);
 $sql = $this->SQLBuilder->search(PHPST_Ticket::$table, array('id'),
 array(DB_PREFIX_TICKETS . ".timestamp" => $this->getTimestamp()));

 $rs = &amp;$conn->Execute($sql);

 if ($rs != false &amp;&amp; $rs->RecordCount() > 0) {
 $this->setId($rs->fields['id']);
 return $rs->fields['id'];
 } else {
 PHPST_Logger::logEvent(3, "DB Error", null,
 "Could not retrieve Ticket ID", __FILE__, __LINE__);
 }
 } else {
 return $this->id;
 }
 }

 /**
 * Short description of method add
 *
 * @access public
 * @return boolean
 */

 public function addToDB() {
 // Initialise Database object
 $conn = &amp;ADONewConnection(DSN);
 // First check that Ticket doesn't already exist.
 $sql = $this->SQLBuilder->search(PHPST_Ticket::$table, array('id'),
 array(DB_PREFIX_TICKETS . ".timestamp" => $this->getTimestamp()));
 $rs = &amp;$conn->Execute($sql);

 if ($rs->RecordCount() == 0) {
 // Retrieve array of table's column names (always UPPERCASE)
 $columns = $conn->MetaColumnNames(PHPST_Ticket::$table);

 $sql = $this->SQLBuilder->insert($this, $columns);

 $rs = &amp;$conn->Execute($sql);
 // Verify previous query
 if ($rs != false) {
 $id = $conn->Insert_ID();
 PHPST_Logger::logEvent(3, "Ticket Operation", null,
 "Ticket object added to DB", __FILE__, __LINE__);
 return $id;
 } else {

 PHPST_Logger::logEvent(3, "DB Error", null,
 "Could not Insert Ticket object.", __FILE__, __LINE__);
 return false;
 }
 } else {
 PHPST_Logger::logEvent(3, "Ticket Operation", null,
 "Ticket object not added to DB, username already exists", __FILE__, __LINE__);
 return false;
 }
 }

 /**
 * Removes a Ticket from the Database
 *
 * @access public
 * @param int $id
 * @return boolean true if successful
 */

 public function removeFromDB($id) {
 $conn = &amp;ADONewConnection(DSN);
 $sql = $this->SQLBuilder->delete($id);
 $rs = &amp;$conn->Execute($sql);

 if ($conn->Affected_Rows() > 0) {
 PHPST_Logger::logEvent(3, "Ticket Operation", null,
 "Ticket object deleted from DB.", __FILE__, __LINE__);
 return true;
 } else {
 PHPST_Logger::logEvent(3, "DB Error", null,
 "Ticket object could not be deleted", __FILE__, __LINE__);
 return false;
 }
 }

 /**
 * Updates a Ticket in the Database
 *
 * @access public
 * @param int $
 * @return boolean true if successful
 */

 public function updateDB() {
 $conn = &amp;ADONewConnection(DSN);
 $this->getId();

 $columns = $conn->MetaColumnNames(PHPST_Ticket::$table);
 $sql = $this->SQLBuilder->update($this, $columns);

 $rs = &amp;$conn->Execute($sql);

 if ($rs != false &amp;&amp; $conn->Affected_Rows() > 0) {
 PHPST_Logger::logEvent(3, "Ticket Operation", USER_USER_ID,
 "Ticket object updated in DB", __FILE__, __LINE__);
 } elseif ($conn->Affected_Rows() == 0) {
 PHPST_Logger::logEvent(3, "Ticket Operation", USER_USER_ID,
 "Ticket object note updated, no changes to perform", __FILE__, __LINE__);
 } else {
 PHPST_Logger::logEvent(3, "DB Error", USER_USER_ID,
 "Ticket object not updated, DB error", __FILE__, __LINE__);
 return false;
 }

 return true;
 }

 /**
 * Implementation of the DatabaseMirror interface function getFromDB().
 * Returns a single Ticket object from the DB based on input in $fields array
 *
 * @static
 * @access public
 * @return Object Ticket if successful, false otherwise
 */

 public static function getFromDB($fields) {

 if (is_array($fields)) {
 $myTicket = null;

 $conn = &amp;ADONewConnection(DSN);
 $conn->SetFetchMode(ADODB_FETCH_ASSOC);
 $SQLBuilder = new PHPST_TicketSQLBuilder();
 $sql = $SQLBuilder->get($fields);

 if (!$sql) {
 PHPST_Logger::logEvent(3, "Ticket Operation", null,
 "Wrong arguments passed to Ticket::getFromDB()", __FILE__, __LINE__);
 }

 $rs = &amp;$conn->Execute($sql);

 if ($rs != false &amp;&amp; $rs->RecordCount() > 0) {
 PHPST_Logger::logEvent(3, "Ticket Operation", null,
 "Ticket object retrieved from DB", __FILE__, __LINE__);
 $myTicket = new PHPST_Ticket($rs->fields);

 // Add answers to object
 $answers = PHPST_Answer::getArrayFromDB('Admin', $myTicket->getId(),
 DB_PREFIX_ANSWERS . '.ticket_id', 'A.timestamp', 'DESC');
 if (!empty($answers)) {
 foreach($answers as $id => $answer_fields) {
 if ($id != 'count' &amp;&amp; $id != 'csv') {
 $answer = new PHPST_Answer($answer_fields['answer']);
 $myTicket->addAnswer($answer);
 }
 }
 }

 } else {
 PHPST_Logger::logEvent(3, "DB Error", null,
 "Ticket object could not be retrieved from DB", __FILE__, __LINE__);
 return false;
 }
 } else {
 PHPST_Logger::logEvent(3, "Ticket Operation", null,
 "Wrong argument type passed to Ticket::getFromDB()", __FILE__, __LINE__);
 return false;
 }
 return $myTicket;
 }

 /**
 * Returns an array of Ticket objects
 *
 * @access public
 * @param string $user_type Admin or Mod
 * @param string $search The search term
 * @param string $field The field being searched
 * @param string $sort The field by which to sort the results
 * @param string $order The order in which to sort the results
 * @param string $ticket_type 'department' tickets or 'my' tickets
 * @return array of Tickets
 */

 public static function getArrayFromDB($user_type, $search, $field,
 $sort, $order, $max_records, $rs_page, $department_id, $ticket_type) {
 $conn = &amp;ADONewConnection(DSN);
 $tickets = array();
 $ids = array();

 $SQLBuilder = new PHPST_TicketSQLBuilder();
 if (!isset($rs_page)) {
 $rs_page = 1;
 }
 $tickets['count'] = 0;


 // Perform SQL for creating csv file
 $csv_sql = $SQLBuilder->getCSV();
 $csv_rs = $conn->Execute($csv_sql);
 $csv = rs2csv($csv_rs);
 $tickets['csv'] = $csv;

 // If page requested is 'all', show all records on one page
 if ($rs_page == 'all') {
 $max_records = 999999;
 $rs_page = 1;
 }

 // Get query from SQLBuilder object
 $sql = $SQLBuilder->getFullTicketsArray($user_type,
 $search, $field, $sort, $order, $department_id, $ticket_type);

 // Perform the query
 $rs = &amp;$conn->Execute($sql);

 // Build tickets array from query result (use pagination)
 if ($rs != false &amp;&amp; $rs->RecordCount() > 0) {
 $ticket_count = 0;
 while (!$rs->EOF) {
 $row = $rs->fields;
 // Increment ticket count if this ticket is new
 if (!isset($ids[$row['id']])) {
 $ticket_count++;
 }
 // Only add info to array if ticket is within pagination limits
 if ($ticket_count > (($rs_page - 1) * $max_records) &amp;&amp; $ticket_count <= ($rs_page * $max_records)) {
 // prepare arrays
 $ticket_fields = array();
 $user_fields = array();
 $answer_fields = array();
 $department_fields = array();

 // Increment 'recent' index count if ticket within the predefined number of days
 if ($row['timestamp'] >= (time() - OPTION_RECENT_TICKETS_DAYS * 86400)) {
 $tickets[$row['id']]['recent'] = true;
 } else {
 $tickets[$row['id']]['recent'] = false;
 }

 foreach ($row as $field => $value) {
 // echo "$field : $value <br />";
 if (preg_match('/^user_/', $field) > 0) {
 $user_fields[substr($field, 5)] = $value;
 } elseif (preg_match('/^answer_/', $field) > 0 &amp;&amp; $value != null) {
 $answer_fields[substr($field, 7)] = $value;
 } elseif (preg_match('/^department_/', $field) > 0) {
 $department_fields[substr($field, 11)] = $value;
 } else {
 $ticket_fields[$field] = $value;
 }
 }

 if (count($answer_fields) > 1) {
 $tickets[$row['id']]['answers'][] = $answer_fields;
 }

 $tickets[$row['id']]['ticket'] = $ticket_fields;
 $tickets[$row['id']]['user'] = $user_fields;
 $tickets[$row['id']]['department'] = $department_fields;
 }
 $ids[$row['id']] = 1;
 $tickets['count'] = $ticket_count;
 $rs->MoveNext();
 }
 return $tickets;
 } else {
 PHPST_Logger::logEvent(3, "DB Error", null,
 "SQL error trying to get Array of users: " . addslashes($sql), __FILE__, __LINE__);
 return false;
 }
 }

 /* ---- GETTERS ---- */

 /**
 * Returns the Ticket's user ID.
 *
 * @return int user_id
 * @access public
 */

 public function getUser_id() {
 return $this->user_id;
 }

 /**
 * Returns the Ticket's subject.
 *
 * @return string Subject
 * @access public
 */

 public function getSubject() {
 return $this->subject;
 }

 /**
 * Returns the Ticket's creation timestamp.
 *
 * @return int Timestamp of creation
 * @access public
 */

 public function getTimestamp() {
 return $this->timestamp;
 }

 /**
 * Returns the Ticket's department_id.
 *
 * @return int department_id
 * @access public
 */

 public function getDepartment_id() {
 return $this->department_id;
 }

 /**
 * Returns the Ticket's status (open or closed).
 *
 * @return string Status
 * @access public
 */

 public function getStatus() {
 return $this->status;
 }

 /**
 * Returns the Ticket's urgency level (1 - 4).
 *
 * @return int Urgency level
 * @access public
 */

 public function getUrgency() {
 return $this->urgency;
 }

 /**
 * Returns the Ticket's category.
 *
 * @return string Category
 * @access public
 */

 public function getCategory() {
 return $this->category;
 }

 /**
 * Returns the Ticket's body.
 *
 * @return string Body
 * @access public
 */

 public function getBody() {
 return $this->body;
 }

 /**
 * Returns the Ticket's answers.
 *
 * @return array answers
 * @access public
 */

 public function getAnswers() {
 return $this->answers;
 }

 /* ---- SETTERS ---- */

 /**
 * Sets the Ticket's ID.
 *
 * @param int $id
 * @access public
 */

 public function setId($id) {
 $this->id = $id;
 }

 /**
 * Sets the Ticket's user ID.
 *
 * @param int $user_id
 * @access public
 */

 public function setUser_id($user_id) {
 $this->user_id = $user_id;
 }

 /**
 * Sets the Ticket's subject.
 *
 * @param string $subject
 * @access public
 */

 public function setSubject($subject) {
 $this->subject = $subject;
 }

 /**
 * Sets the Ticket's creation timestamp.
 *
 * @param int $timestamp
 * @access public
 */

 public function setTimestamp($timestamp) {
 $this->timestamp = $timestamp;
 }

 /**
 * Sets the Ticket's department_id.
 *
 * @param int $department_id
 * @access public
 */

 public function setDepartment_id($department_id) {
 $this->department_id = $department_id;
 }

 /**
 * Sets the Ticket's status (open or closed).
 *
 * @param string $status
 * @access public
 */

 public function setStatus($status) {
 $this->status = $status;
 }

 /**
 * Sets the Ticket's urgency level (1 - 4).
 *
 * @param int $urgency
 * @access public
 */

 public function setUrgency($urgency) {
 $this->urgency = $urgency;
 }

 /**
 * Sets the Ticket's category.
 *
 * @param string $category
 * @access public
 */

 public function setCategory($category) {
 $this->category = $category;
 }

 /**
 * Sets the Ticket's body.
 *
 * @param string $body
 * @access public
 */

 public function setBody($body) {
 $this->body = $body;
 }

 /**
 * Adds an answer to the Ticket.
 *
 * @param object $answers
 * @access public
 */

 public function addAnswer(PHPST_Answer $answer) {
 $this->answers[] = $answer;
 }

 /**
 * Returns a formatted thread of responses to this ticket
 * ready for inclusion in email body.
 *
 * @access public
 * @return string
 *
 */

 public function getThread() {
 $user = PHPST_User::getFromDB(array('user_id' => $this->getUser_id()));
 $ticket_attachment = PHPST_Ticket::getAttachmentInfo($user->getUsername(), $this->getId());

 $string = "\nTicket's initial message:\n";
 $string .= "\n/--------------------------------------------------";
 $body = html_entity_decode($this->getBody());
 $body = str_replace("\n", "\n| ", $body);
 $body = str_replace('<br />', "\n| ", $body);
 $body = wordwrap($body, 48, "\n| ");
 $string .= "\n| " . $body;
 $string .= "\n| -------------------------------------------------";
 $string .= "\n| By " . $user->getName() . " (" . $user->getEmail() . ").";
 $string .= "\n| On " . PHPST_DateTime::unix2mysql($this->getTimestamp(), 'UK') . ".";
 if ($ticket_attachment) {
 $string .= "\n| Attachment: " . $ticket_attachment['filename'] . " (" .
 $ticket_attachment['size'] . ", " . $ticket_attachment['url'] . ").";
 }
 $string .= "\n\\--------------------------------------------------\n";
 $string .= "\n\nResponses to this ticket (most recent on top):\n";

 foreach ($this->getAnswers() as $id => $answer) {
 // Get attachment info
 $user = PHPST_User::getFromDB(array('user_id' => $answer->getUser_id()));
 $answer_attachment = PHPST_Answer::getAttachmentInfo($user->getUsername(), $answer->getId());

 // Break up the body of each answer into multiple lines
 $body = html_entity_decode($answer->getBody());
 $body = str_replace("\n", "\n| ", $body);
 $body = str_replace('<br />', "\n| ", $body);
 $body = wordwrap($body, 48, "\n| ");
 $string .= "\n/--------------------------------------------------";
 $string .= "\n| " . $body;
 $string .= "\n| -------------------------------------------------";
 $string .= "\n| By " . $user->getName() . " (" . $user->getEmail() . ").";
 $string .= "\n| On " . PHPST_DateTime::unix2mysql($answer->getTimestamp(), 'UK') . ".";
 if ($answer_attachment) {
 $string .= "\n| Attachment: " . $answer_attachment['filename'] . " (" .
 $answer_attachment['size'] . ", " . $answer_attachment['url'] . ").";
 }
 $string .= "\n\\--------------------------------------------------\n";
 }
 return $string;
 }

 /**
 * Returns info about this ticket's attachment, or false if none exists.
 *
 * @static
 * @access public
 * @param string $username The username of the ticket's owner.
 * @param int $ticket_id The ticket's ID
 * @return mixed Array with attachment info if such exists, false otherwise.
 *
 */

 public static function getAttachmentInfo($username, $ticket_id) {
 $attachment_info = array();
 $ticket_attachment_path = PHPST_UPLOAD_PATH . $username
 . '/phpst_ticket_' . $ticket_id;

 if (is_dir($ticket_attachment_path)) {
 $attachment_info['path'] = $ticket_attachment_path;
 $contents = scandir($attachment_info['path']);
 $attachment_info['filename'] = $contents[2];
 $attachment_info['url'] = PHPST_UPLOAD_RELATIVE_PATH . $username
 . '/phpst_ticket_' . $ticket_id . '/' . $attachment_info['filename'];
 $attachment_info['size'] =
 PHPST_StringFormat::filesize_format(
 filesize($attachment_info['path'] . '/' . $attachment_info['filename']));
 $attachment_info['image'] = PHPST_IconGUI::getIcon('save', '16', 'images/icons/', $attachment_info['url']);

 return $attachment_info;
 } else {
 return false;
 }
 }

 /**
 * Reformats a full tickets array obtained through Ticket::getArrayFrom DB,
 * removes all tickets whose department is suspended, and returns that tickets array.
 *
 * @static
 * @access public
 * @param array $ticketw
 * @return int
 */

 public static function getActiveTickets($tickets) {
 $count = 0;
 $copy = $tickets;

 if (!empty($tickets)) {

 foreach ($tickets as $key => $ticket) {
 if ($key != 'count' &amp;&amp; $key != 'csv' &amp;&amp; $ticket['department']['status'] != 'Suspended') {
 $count++;
 } else {
 unset($copy[$key]);
 }
 }
 $copy['count'] = $count;
 $copy['csv'] = $tickets['csv'];
 }

 return $copy;
 }

 /**
 * Tostring function: returns a string representation of this object
 *
 * @access public
 * @return string
 */

 public function __toString() {
 $string = "Ticket object:
 <br />___________________"
;
 $string .= "<br />id: " . $this->getId();
 $string .= "<br />Department: " . $this->getDepartment_id();
 $string .= "<br />Body: " . $this->getBody();
 $string .= "<br />User_id: " . $this->getUser_id();
 $string .= "<br />Urgency: " . $this->getUrgency();
 $string .= "<br />Date Created: " . gmdate('d/m/Y H:i:s', $this->getTimestamp());
 $string .= "<br />Status: " . $this->getStatus();
 $string .= "<br />Answers: <ul>";
 foreach ($this->getAnswers() as $id => $answer) {
 $string .= "<li>" . $answer->getUser_id() . ": " . $answer->getBody() . "</li>";
 }
 $string .= "</ul>";
 return $string;
 }
}

?>

&amp;nbsp;

phpBB Chat Mod Include Scripts

It can add a live chat room to phpBB, multiple skins and user single sign-on. A chat room makes the phpBB more interactive, and it will boost traffic as well as revenue to your website, also increase user loyalty. Once the mod is installed, a free hosted chat will be offered to your phpBB automatically. It adds a fabulous popup chat room behind a chat button, which has literally everything you will need in a chat module, and the chat statistics can display on the phpBB front page, also a visual admin panel will be available, etc.

 

 

<?php
if (!defined('IN_PHPBB'))
{
 exit;
}

define('SERVICES_JSON_SLICE',   1);
define('SERVICES_JSON_IN_STR',  2);
define('SERVICES_JSON_IN_ARR',  3);
define('SERVICES_JSON_IN_OBJ',  4);
define('SERVICES_JSON_IN_CMT', 5);
define('SERVICES_JSON_LOOSE_TYPE', 16);
define('SERVICES_JSON_SUPPRESS_ERRORS', 32);


class Services_JSON
{
 /**
 * constructs a new JSON instance
 *
 * @param    int     $use    object behavior flags; combine with boolean-OR
 *
 *                           possible values:
 *                           - SERVICES_JSON_LOOSE_TYPE:  loose typing.
 *                                   "{...}" syntax creates associative arrays
 *                                   instead of objects in decode().
 *                           - SERVICES_JSON_SUPPRESS_ERRORS:  error suppression.
 *                                   Values which can't be encoded (e.g. resources)
 *                                   appear as NULL instead of throwing errors.
 *                                   By default, a deeply-nested resource will
 *                                   bubble up with an error, so all return values
 *                                   from encode() should be checked with isError()
 */

 function Services_JSON($use = 0)
 {
 $this->use = $use;
 }

 /**
 * convert a string from one UTF-16 char to one UTF-8 char
 *
 * Normally should be handled by mb_convert_encoding, but
 * provides a slower PHP-only method for installations
 * that lack the multibye string extension.
 *
 * @param    string  $utf16  UTF-16 character
 * @return   string  UTF-8 character
 * @access   private
 */

 function utf162utf8($utf16)
 {
 // oh please oh please oh please oh please oh please
 if(function_exists('mb_convert_encoding')) {
 return mb_convert_encoding($utf16, 'UTF-8', 'UTF-16');
 }

 $bytes = (ord($utf16{0}) << 8) | ord($utf16{1});

 switch(true) {
 case ((0x7F &amp; $bytes) == $bytes):
 // this case should never be reached, because we are in ASCII range
 // see: http://www.cl.cam.ac.uk/~mgk25/unicode.html#utf-8
 return chr(0x7F &amp; $bytes);

 case (0x07FF &amp; $bytes) == $bytes:
 // return a 2-byte UTF-8 character
 // see: http://www.cl.cam.ac.uk/~mgk25/unicode.html#utf-8
 return chr(0xC0 | (($bytes >> 6) &amp; 0x1F))
 . chr(0x80 | ($bytes &amp; 0x3F));

 case (0xFFFF &amp; $bytes) == $bytes:
 // return a 3-byte UTF-8 character
 // see: http://www.cl.cam.ac.uk/~mgk25/unicode.html#utf-8
 return chr(0xE0 | (($bytes >> 12) &amp; 0x0F))
 . chr(0x80 | (($bytes >> 6) &amp; 0x3F))
 . chr(0x80 | ($bytes &amp; 0x3F));
 }

 // ignoring UTF-32 for now, sorry
 return '';
 }

 /**
 * convert a string from one UTF-8 char to one UTF-16 char
 *
 * Normally should be handled by mb_convert_encoding, but
 * provides a slower PHP-only method for installations
 * that lack the multibye string extension.
 *
 * @param    string  $utf8   UTF-8 character
 * @return   string  UTF-16 character
 * @access   private
 */

 function utf82utf16($utf8)
 {
 // oh please oh please oh please oh please oh please
 if(function_exists('mb_convert_encoding')) {
 return mb_convert_encoding($utf8, 'UTF-16', 'UTF-8');
 }

 switch(strlen($utf8)) {
 case 1:
 // this case should never be reached, because we are in ASCII range
 // see: http://www.cl.cam.ac.uk/~mgk25/unicode.html#utf-8
 return $utf8;

 case 2:
 // return a UTF-16 character from a 2-byte UTF-8 char
 // see: http://www.cl.cam.ac.uk/~mgk25/unicode.html#utf-8
 return chr(0x07 &amp; (ord($utf8{0}) >> 2))
 . chr((0xC0 &amp; (ord($utf8{0}) << 6))
 | (0x3F &amp; ord($utf8{1})));

 case 3:
 // return a UTF-16 character from a 3-byte UTF-8 char
 // see: http://www.cl.cam.ac.uk/~mgk25/unicode.html#utf-8
 return chr((0xF0 &amp; (ord($utf8{0}) << 4))
 | (0x0F &amp; (ord($utf8{1}) >> 2)))
 . chr((0xC0 &amp; (ord($utf8{1}) << 6))
 | (0x7F &amp; ord($utf8{2})));
 }

 // ignoring UTF-32 for now, sorry
 return '';
 }

 /**
 * encodes an arbitrary variable into JSON format
 *
 * @param    mixed   $var    any number, boolean, string, array, or object to be encoded.
 *                           see argument 1 to Services_JSON() above for array-parsing behavior.
 *                           if var is a strng, note that encode() always expects it
 *                           to be in ASCII or UTF-8 format!
 *
 * @return   mixed   JSON string representation of input var or an error if a problem occurs
 * @access   public
 */

 function encode($var)
 {
 switch (gettype($var)) {
 case 'boolean':
 return $var ? 'true' : 'false';

 case 'NULL':
 return 'null';

 case 'integer':
 return (int) $var;

 case 'double':
 case 'float':
 return (float) $var;

 case 'string':
 // STRINGS ARE EXPECTED TO BE IN ASCII OR UTF-8 FORMAT
 $ascii = '';
 $strlen_var = strlen($var);

 /*
 * Iterate over every character in the string,
 * escaping with a slash or encoding to UTF-8 where necessary
 */

 for ($c = 0; $c < $strlen_var; ++$c) {

 $ord_var_c = ord($var{$c});

 switch (true) {
 case $ord_var_c == 0x08:
 $ascii .= '\b';
 break;
 case $ord_var_c == 0x09:
 $ascii .= '\t';
 break;
 case $ord_var_c == 0x0A:
 $ascii .= '\n';
 break;
 case $ord_var_c == 0x0C:
 $ascii .= '\f';
 break;
 case $ord_var_c == 0x0D:
 $ascii .= '\r';
 break;

 case $ord_var_c == 0x22:
 case $ord_var_c == 0x2F:
 case $ord_var_c == 0x5C:
 // double quote, slash, slosh
 $ascii .= '\'.$var{$c};
 break;

 case (($ord_var_c >= 0x20) &amp;&amp; ($ord_var_c <= 0x7F)):
 // characters U-00000000 - U-0000007F (same as ASCII)
 $ascii .= $var{$c};
 break;

 case (($ord_var_c &amp; 0xE0) == 0xC0):
 // characters U-00000080 - U-000007FF, mask 110XXXXX
 // see http://www.cl.cam.ac.uk/~mgk25/unicode.html#utf-8
 $char = pack('
C*', $ord_var_c, ord($var{$c + 1}));
 $c += 1;
 $utf16 = $this->utf82utf16($char);
 $ascii .= sprintf('
\u%04s', bin2hex($utf16));
 break;

 case (($ord_var_c &amp; 0xF0) == 0xE0):
 // characters U-00000800 - U-0000FFFF, mask 1110XXXX
 // see http://www.cl.cam.ac.uk/~mgk25/unicode.html#utf-8
 $char = pack('
C*', $ord_var_c,
 ord($var{$c + 1}),
 ord($var{$c + 2}));
 $c += 2;
 $utf16 = $this->utf82utf16($char);
 $ascii .= sprintf('
\u%04s', bin2hex($utf16));
 break;

 case (($ord_var_c &amp; 0xF8) == 0xF0):
 // characters U-00010000 - U-001FFFFF, mask 11110XXX
 // see http://www.cl.cam.ac.uk/~mgk25/unicode.html#utf-8
 $char = pack('
C*', $ord_var_c,
 ord($var{$c + 1}),
 ord($var{$c + 2}),
 ord($var{$c + 3}));
 $c += 3;
 $utf16 = $this->utf82utf16($char);
 $ascii .= sprintf('
\u%04s', bin2hex($utf16));
 break;

 case (($ord_var_c &amp; 0xFC) == 0xF8):
 // characters U-00200000 - U-03FFFFFF, mask 111110XX
 // see http://www.cl.cam.ac.uk/~mgk25/unicode.html#utf-8
 $char = pack('
C*', $ord_var_c,
 ord($var{$c + 1}),
 ord($var{$c + 2}),
 ord($var{$c + 3}),
 ord($var{$c + 4}));
 $c += 4;
 $utf16 = $this->utf82utf16($char);
 $ascii .= sprintf('
\u%04s', bin2hex($utf16));
 break;

 case (($ord_var_c &amp; 0xFE) == 0xFC):
 // characters U-04000000 - U-7FFFFFFF, mask 1111110X
 // see http://www.cl.cam.ac.uk/~mgk25/unicode.html#utf-8
 $char = pack('
C*', $ord_var_c,
 ord($var{$c + 1}),
 ord($var{$c + 2}),
 ord($var{$c + 3}),
 ord($var{$c + 4}),
 ord($var{$c + 5}));
 $c += 5;
 $utf16 = $this->utf82utf16($char);
 $ascii .= sprintf('
\u%04s', bin2hex($utf16));
 break;
 }
 }

 return '
"'.$ascii.'"';

 case '
array':
 /*
 * As per JSON spec if any array key is not an integer
 * we must treat the the whole array as an object. We
 * also try to catch a sparsely populated associative
 * array with numeric keys here because some JS engines
 * will create an array with empty indexes up to
 * max_index which can cause memory issues and because
 * the keys, which may be relevant, will be remapped
 * otherwise.
 *
 * As per the ECMA and JSON specification an object may
 * have any string as a property. Unfortunately due to
 * a hole in the ECMA specification if the key is a
 * ECMA reserved word or starts with a digit the
 * parameter is only accessible using ECMAScript'
s
 * bracket notation.
 */

 // treat as a JSON object
 if (is_array($var) &amp;&amp; count($var) &amp;&amp; (array_keys($var) !== range(0, sizeof($var) - 1))) {
 $properties = array_map(array($this, 'name_value'),
 array_keys($var),
 array_values($var));

 foreach($properties as $property) {
 if(Services_JSON::isError($property)) {
 return $property;
 }
 }

 return '{' . join(',', $properties) . '}';
 }

 // treat it like a regular array
 $elements = array_map(array($this, 'encode'), $var);

 foreach($elements as $element) {
 if(Services_JSON::isError($element)) {
 return $element;
 }
 }

 return '[' . join(',', $elements) . ']';

 case 'object':
 $vars = get_object_vars($var);

 $properties = array_map(array($this, 'name_value'),
 array_keys($vars),
 array_values($vars));

 foreach($properties as $property) {
 if(Services_JSON::isError($property)) {
 return $property;
 }
 }

 return '{' . join(',', $properties) . '}';

 default:
 return ($this->use &amp; SERVICES_JSON_SUPPRESS_ERRORS)
 ? 'null'
 : new Services_JSON_Error(gettype($var)." can not be encoded as JSON string");
 }
 }

 /**
 * array-walking function for use in generating JSON-formatted name-value pairs
 *
 * @param    string  $name   name of key to use
 * @param    mixed   $value  reference to an array element to be encoded
 *
 * @return   string  JSON-formatted name-value pair, like '"name":value'
 * @access   private
 */

 function name_value($name, $value)
 {
 $encoded_value = $this->encode($value);

 if(Services_JSON::isError($encoded_value)) {
 return $encoded_value;
 }

 return $this->encode(strval($name)) . ':' . $encoded_value;
 }

 /**
 * reduce a string by removing leading and trailing comments and whitespace
 *
 * @param    $str    string      string value to strip of comments and whitespace
 *
 * @return   string  string value stripped of comments and whitespace
 * @access   private
 */

 function reduce_string($str)
 {
 $str = preg_replace(array(

 // eliminate single line comments in '// ...' form
 '#^\s*//(.+)$#m',

 // eliminate multi-line comments in '/* ... */' form, at start of string
 '#^\s*/\*(.+)\*/#Us',

 // eliminate multi-line comments in '/* ... */' form, at end of string
 '#/\*(.+)\*/\s*$#Us'

 ), '', $str);

 // eliminate extraneous space
 return trim($str);
 }

 /**
 * decodes a JSON string into appropriate variable
 *
 * @param    string  $str    JSON-formatted string
 *
 * @return   mixed   number, boolean, string, array, or object
 *                   corresponding to given JSON input string.
 *                   See argument 1 to Services_JSON() above for object-output behavior.
 *                   Note that decode() always returns strings
 *                   in ASCII or UTF-8 format!
 * @access   public
 */

 function decode($str)
 {
 $str = $this->reduce_string($str);

 switch (strtolower($str)) {
 case 'true':
 return true;

 case 'false':
 return false;

 case 'null':
 return null;

 default:
 $m = array();

 if (is_numeric($str)) {
 // Lookie-loo, it's a number

 // This would work on its own, but I'm trying to be
 // good about returning integers where appropriate:
 // return (float)$str;

 // Return float or int, as appropriate
 return ((float)$str == (integer)$str)
 ? (integer)$str
 : (float)$str;

 } elseif (preg_match('/^("|\').*(\1)$/s', $str, $m) &amp;&amp; $m[1] == $m[2]) {
 // STRINGS RETURNED IN UTF-8 FORMAT
 $delim = substr($str, 0, 1);
 $chrs = substr($str, 1, -1);
 $utf8 = '';
 $strlen_chrs = strlen($chrs);

 for ($c = 0; $c < $strlen_chrs; ++$c) {

 $substr_chrs_c_2 = substr($chrs, $c, 2);
 $ord_chrs_c = ord($chrs{$c});

 switch (true) {
 case $substr_chrs_c_2 == '\b':
 $utf8 .= chr(0x08);
 ++$c;
 break;
 case $substr_chrs_c_2 == '\t':
 $utf8 .= chr(0x09);
 ++$c;
 break;
 case $substr_chrs_c_2 == '\n':
 $utf8 .= chr(0x0A);
 ++$c;
 break;
 case $substr_chrs_c_2 == '\f':
 $utf8 .= chr(0x0C);
 ++$c;
 break;
 case $substr_chrs_c_2 == '\r':
 $utf8 .= chr(0x0D);
 ++$c;
 break;

 case $substr_chrs_c_2 == '\\"':
 case $substr_chrs_c_2 == '\\'':
 case $substr_chrs_c_2 == '
\\\':
 case $substr_chrs_c_2 == '
\\/':
 if (($delim == '
"' &amp;&amp; $substr_chrs_c_2 != '\\'') ||
 ($delim == "
'" &amp;&amp; $substr_chrs_c_2 != '\\"')) {
 $utf8 .= $chrs{++$c};
 }
 break;

 case preg_match('/\\\u[0-9A-F]{4}/i', substr($chrs, $c, 6)):
 // single, escaped unicode character
 $utf16 = chr(hexdec(substr($chrs, ($c + 2), 2)))
 . chr(hexdec(substr($chrs, ($c + 4), 2)));
 $utf8 .= $this->utf162utf8($utf16);
 $c += 5;
 break;

 case ($ord_chrs_c >= 0x20) &amp;&amp; ($ord_chrs_c <= 0x7F):
 $utf8 .= $chrs{$c};
 break;

 case ($ord_chrs_c &amp; 0xE0) == 0xC0:
 // characters U-00000080 - U-000007FF, mask 110XXXXX
 //see http://www.cl.cam.ac.uk/~mgk25/unicode.html#utf-8
 $utf8 .= substr($chrs, $c, 2);
 ++$c;
 break;

 case ($ord_chrs_c &amp; 0xF0) == 0xE0:
 // characters U-00000800 - U-0000FFFF, mask 1110XXXX
 // see http://www.cl.cam.ac.uk/~mgk25/unicode.html#utf-8
 $utf8 .= substr($chrs, $c, 3);
 $c += 2;
 break;

 case ($ord_chrs_c &amp; 0xF8) == 0xF0:
 // characters U-00010000 - U-001FFFFF, mask 11110XXX
 // see http://www.cl.cam.ac.uk/~mgk25/unicode.html#utf-8
 $utf8 .= substr($chrs, $c, 4);
 $c += 3;
 break;

 case ($ord_chrs_c &amp; 0xFC) == 0xF8:
 // characters U-00200000 - U-03FFFFFF, mask 111110XX
 // see http://www.cl.cam.ac.uk/~mgk25/unicode.html#utf-8
 $utf8 .= substr($chrs, $c, 5);
 $c += 4;
 break;

 case ($ord_chrs_c &amp; 0xFE) == 0xFC:
 // characters U-04000000 - U-7FFFFFFF, mask 1111110X
 // see http://www.cl.cam.ac.uk/~mgk25/unicode.html#utf-8
 $utf8 .= substr($chrs, $c, 6);
 $c += 5;
 break;

 }

 }

 return $utf8;

 } elseif (preg_match('/^\[.*\]$/s', $str) || preg_match('/^\{.*\}$/s', $str)) {
 // array, or object notation

 if ($str{0} == '[') {
 $stk = array(SERVICES_JSON_IN_ARR);
 $arr = array();
 } else {
 if ($this->use &amp; SERVICES_JSON_LOOSE_TYPE) {
 $stk = array(SERVICES_JSON_IN_OBJ);
 $obj = array();
 } else {
 $stk = array(SERVICES_JSON_IN_OBJ);
 $obj = new stdClass();
 }
 }

 array_push($stk, array('what'  => SERVICES_JSON_SLICE,
 'where' => 0,
 'delim' => false));

 $chrs = substr($str, 1, -1);
 $chrs = $this->reduce_string($chrs);

 if ($chrs == '') {
 if (reset($stk) == SERVICES_JSON_IN_ARR) {
 return $arr;

 } else {
 return $obj;

 }
 }

 //("
\nparsing {$chrs}\n");

 $strlen_chrs = strlen($chrs);

 for ($c = 0; $c <= $strlen_chrs; ++$c) {

 $top = end($stk);
 $substr_chrs_c_2 = substr($chrs, $c, 2);

 if (($c == $strlen_chrs) || (($chrs{$c} == ',') &amp;&amp; ($top['what'] == SERVICES_JSON_SLICE))) {
 // found a comma that is not inside a string, array, etc.,
 // OR we've reached the end of the character list
 $slice = substr($chrs, $top['where'], ($c - $top['where']));
 array_push($stk, array('what' => SERVICES_JSON_SLICE, 'where' => ($c + 1), 'delim' => false));
 //("
Found split at {$c}: ".substr($chrs, $top['where'], (1 + $c - $top['where']))."\n");

 if (reset($stk) == SERVICES_JSON_IN_ARR) {
 // we are in an array, so just push an element onto the stack
 array_push($arr, $this->decode($slice));

 } elseif (reset($stk) == SERVICES_JSON_IN_OBJ) {
 // we are in an object, so figure
 // out the property name and set an
 // element in an associative array,
 // for now
 $parts = array();

 if (preg_match('/^\s*(["
\'].*[^\\\]["\'])\s*:\s*(\S.*),?$/Uis', $slice, $parts)) {
 // "name":value pair
 $key = $this->decode($parts[1]);
 $val = $this->decode($parts[2]);

 if ($this->use &amp; SERVICES_JSON_LOOSE_TYPE) {
 $obj[$key] = $val;
 } else {
 $obj->$key = $val;
 }
 } elseif (preg_match('/^\s*(\w+)\s*:\s*(\S.*),?$/Uis', $slice, $parts)) {
 // name:value pair, where name is unquoted
 $key = $parts[1];
 $val = $this->decode($parts[2]);

 if ($this->use &amp; SERVICES_JSON_LOOSE_TYPE) {
 $obj[$key] = $val;
 } else {
 $obj->$key = $val;
 }
 }

 }

 } elseif ((($chrs{$c} == '"') || ($chrs{$c} == "'")) &amp;&amp; ($top['what'] != SERVICES_JSON_IN_STR)) {
 // found a quote, and we are not inside a string
 array_push($stk, array('what' => SERVICES_JSON_IN_STR, 'where' => $c, 'delim' => $chrs{$c}));
 //("Found start of string at {$c}\n");

 } elseif (($chrs{$c} == $top['delim']) &amp;&amp;
 ($top['what'] == SERVICES_JSON_IN_STR) &amp;&amp;
 ((strlen(substr($chrs, 0, $c)) - strlen(rtrim(substr($chrs, 0, $c), '\'))) % 2 != 1)) {
 // found a quote, we'
re in a string, and it's not escaped
 // we know that it'
s not escaped becase there is _not_ an
 // odd number of backslashes at the end of the string so far
 array_pop($stk);
 //("Found end of string at {$c}: ".substr($chrs, $top['where'], (1 + 1 + $c - $top['where']))."\n");

 } elseif (($chrs{$c} == '[') &amp;&amp;
 in_array($top['what'], array(SERVICES_JSON_SLICE, SERVICES_JSON_IN_ARR, SERVICES_JSON_IN_OBJ))) {
 // found a left-bracket, and we are in an array, object, or slice
 array_push($stk, array('what' => SERVICES_JSON_IN_ARR, 'where' => $c, 'delim' => false));
 //("Found start of array at {$c}\n");

 } elseif (($chrs{$c} == ']') &amp;&amp; ($top['what'] == SERVICES_JSON_IN_ARR)) {
 // found a right-bracket, and we're in an array
 array_pop($stk);
 //("Found end of array at {$c}: ".substr($chrs, $top['where'], (1 + $c - $top['where']))."\n");

 } elseif (($chrs{$c} == '{') &amp;&amp;
 in_array($top['what'], array(SERVICES_JSON_SLICE, SERVICES_JSON_IN_ARR, SERVICES_JSON_IN_OBJ))) {
 // found a left-brace, and we are in an array, object, or slice
 array_push($stk, array('what' => SERVICES_JSON_IN_OBJ, 'where' => $c, 'delim' => false));
 //("Found start of object at {$c}\n");

 } elseif (($chrs{$c} == '}') &amp;&amp; ($top['what'] == SERVICES_JSON_IN_OBJ)) {
 // found a right-brace, and we're in an object
 array_pop($stk);
 //("Found end of object at {$c}: ".substr($chrs, $top['where'], (1 + $c - $top['where']))."\n");

 } elseif (($substr_chrs_c_2 == '/*') &amp;&amp;
 in_array($top['what'], array(SERVICES_JSON_SLICE, SERVICES_JSON_IN_ARR, SERVICES_JSON_IN_OBJ))) {
 // found a comment start, and we are in an array, object, or slice
 array_push($stk, array('what' => SERVICES_JSON_IN_CMT, 'where' => $c, 'delim' => false));
 $c++;
 //("Found start of comment at {$c}\n");

 } elseif (($substr_chrs_c_2 == '*/') &amp;&amp; ($top['what'] == SERVICES_JSON_IN_CMT)) {
 // found a comment end, and we're in one now
 array_pop($stk);
 $c++;

 for ($i = $top['where']; $i <= $c; ++$i)
 $chrs = substr_replace($chrs, ' ', $i, 1);

 //("Found end of comment at {$c}: ".substr($chrs, $top['where'], (1 + $c - $top['where']))."\n");

 }

 }

 if (reset($stk) == SERVICES_JSON_IN_ARR) {
 return $arr;

 } elseif (reset($stk) == SERVICES_JSON_IN_OBJ) {
 return $obj;

 }

 }
 }
 }

 /**
 * @todo Ultimately, this should just call PEAR::isError()
 */

 function isError($data, $code = null)
 {
 if (class_exists('pear')) {
 return PEAR::isError($data, $code);
 } elseif (is_object($data) &amp;&amp; (get_class($data) == 'services_json_error' ||
 is_subclass_of($data, 'services_json_error'))) {
 return true;
 }

 return false;
 }
}

if (class_exists('PEAR_Error')) {

 class Services_JSON_Error extends PEAR_Error
 {
 function Services_JSON_Error($message = 'unknown error', $code = null,
 $mode = null, $options = null, $userinfo = null)
 {
 parent::PEAR_Error($message, $code, $mode, $options, $userinfo);
 }
 }

} else {

 /**
 * @todo Ultimately, this class shall be descended from PEAR_Error
 */

 class Services_JSON_Error
 {
 function Services_JSON_Error($message = 'unknown error', $code = null,
 $mode = null, $options = null, $userinfo = null)
 {

 }
 }

}

?>

&amp;nbsp;

 

Scripts for BlaB! Lite Include Scripts

An AJAX based and best viewed with any browser fully resizable chat system that features high performance, xHTML 1.0 STRICT compliant output, PHP4/PHP5 compatibility, topics, ‘http’ links, emoticons, text formatting, custom timezone settings, bad words removal, sound alert on new messages, UTF-8 based multilanguage support and options to paint, share and play paintings directly in chat. The latest version is translated in 16 languages, supports MySQL, Postgre and SQLite databases. FLASH, JAVA, additional plugins or server modules are NOT required.

 

 

<?php
require_once 'config.php';
require_once 'incl/main.inc';

dbconnect(); $settings=get_settings(1);

include 'lang/languages.inc';
include 'lang/'.$lang_admin[$settings['admin_lang']];

$wrong_acp=(int)$settings['wrong_acp'];$wrong_acp=$timestamp-$wrong_acp;

if(isset($_POST['acp_key']) &amp;&amp; hsh($_POST['acp_key'])==$settings['acp_key'] &amp;&amp; $wrong_acp>$settings['acp_attempts']){
$acp_key=hsh($settings['acp_key']);
setcookie('blite5_acpkey',$acp_key,time()+3600*$settings['acp_lhours'],'/');
redirect('admin.php');}

elseif(isset($_POST['acp_key'])){
$query='UPDATE '.$dbss['prfx']."_settings SET set_value='$timestamp' WHERE set_id='wrong_acp'";
neutral_query($query);
redirect('admin.php');}

if(!isset($_COOKIE['blite5_acpkey']) || hsh($settings['acp_key'])!=$_COOKIE['blite5_acpkey']){
$title=$lang['acpkey'];
include 'admin/head.pxtm';
include 'admin/acpkey.pxtm';
die();}

if(isset($_GET['q']) &amp;&amp; $_GET['q']=='logout'){
setcookie('blite5_acpkey','',time()+3600,'/');
redirect('admin.php');}

/* --- */


if(isset($_POST['settings'])){

if(isset($_POST['admin_lang']) &amp;&amp; $_POST['admin_lang']!=$settings['admin_lang']){
$admin_lang=neutral_escape($_POST['admin_lang'],2,'int');
$query='UPDATE '.$dbss['prfx']."_settings SET set_value='$admin_lang' WHERE set_id='admin_lang'";
neutral_query($query);}

if(isset($_POST['admin_css']) &amp;&amp; $_POST['admin_css']!=$settings['admin_css']){
$admin_css=neutral_escape($_POST['admin_css'],2,'int');
$query='UPDATE '.$dbss['prfx']."_settings SET set_value='$admin_css' WHERE set_id='admin_css'";
neutral_query($query);}

if(isset($_POST['acp_lhours']) &amp;&amp; $_POST['acp_lhours']!=$settings['acp_lhours']){
$acp_lhours=(int)$_POST['acp_lhours'];
$query='UPDATE '.$dbss['prfx']."_settings SET set_value='$acp_lhours' WHERE set_id='acp_lhours'";
neutral_query($query);}

if(isset($_POST['acp_attempts']) &amp;&amp; $_POST['acp_attempts']!=$settings['acp_attempts']){
$acp_attempts=(int)$_POST['acp_attempts'];
$query='UPDATE '.$dbss['prfx']."_settings SET set_value='$acp_attempts' WHERE set_id='acp_attempts'";
neutral_query($query);}

if(isset($_POST['acp_timezone']) &amp;&amp; $_POST['acp_timezone']!=$settings['acp_timezone']){
$acp_timezone=neutral_escape($_POST['acp_timezone'],3,'int');
$query='UPDATE '.$dbss['prfx']."_settings SET set_value='$acp_timezone' WHERE set_id='acp_timezone'";
neutral_query($query);}

if(isset($_POST['default_timeform']) &amp;&amp; $_POST['default_timeform']!=$settings['default_timeform']){
$default_timeform=neutral_escape($_POST['default_timeform'],1,'int');
$query='UPDATE '.$dbss['prfx']."_settings SET set_value='$default_timeform' WHERE set_id='default_timeform'";
neutral_query($query);}

if(isset($_POST['default_language']) &amp;&amp; $_POST['default_language']!=$settings['default_language']){
$default_language=neutral_escape($_POST['default_language'],2,'int');
$query='UPDATE '.$dbss['prfx']."_settings SET set_value='$default_language' WHERE set_id='default_language'";
neutral_query($query);}

if(isset($_POST['default_effects']) &amp;&amp; $_POST['default_effects']!=$settings['default_effects']){
$default_effects=neutral_escape($_POST['default_effects'],1,'int');
$query='UPDATE '.$dbss['prfx']."_settings SET set_value='$default_effects' WHERE set_id='default_effects'";
neutral_query($query);}

if(isset($_POST['default_sound1']) &amp;&amp; $_POST['default_sound1']!=$settings['default_sound1']){
$default_sound1=neutral_escape($_POST['default_sound1'],1,'int');
$query='UPDATE '.$dbss['prfx']."_settings SET set_value='$default_sound1' WHERE set_id='default_sound1'";
neutral_query($query);}

if(isset($_POST['default_sound2']) &amp;&amp; $_POST['default_sound2']!=$settings['default_sound2']){
$default_sound2=neutral_escape($_POST['default_sound2'],1,'int');
$query='UPDATE '.$dbss['prfx']."_settings SET set_value='$default_sound2' WHERE set_id='default_sound2'";
neutral_query($query);}

if(isset($_POST['default_sound3']) &amp;&amp; $_POST['default_sound3']!=$settings['default_sound3']){
$default_sound3=neutral_escape($_POST['default_sound3'],1,'int');
$query='UPDATE '.$dbss['prfx']."_settings SET set_value='$default_sound3' WHERE set_id='default_sound3'";
neutral_query($query);}

if($_POST['title']!=$settings['title']){
$title=neutral_escape($_POST['title'],512,'str');
$query='UPDATE '.$dbss['prfx']."_settings SET set_value='$title' WHERE set_id='title'";
neutral_query($query);}

if($_POST['url']!=$settings['url']){
$url=neutral_escape($_POST['url'],512,'str');
$query='UPDATE '.$dbss['prfx']."_settings SET set_value='$url' WHERE set_id='url'";
neutral_query($query);}

if($_POST['default_mail']!=$settings['default_mail']){
$default_mail=neutral_escape($_POST['default_mail'],512,'str');
$query='UPDATE '.$dbss['prfx']."_settings SET set_value='$default_mail' WHERE set_id='default_mail'";
neutral_query($query);}

if($_POST['meta_desc']!=$settings['meta_desc']){
$meta_desc=neutral_escape($_POST['meta_desc'],1024,'str');
$query='UPDATE '.$dbss['prfx']."_settings SET set_value='$meta_desc' WHERE set_id='meta_desc'";
neutral_query($query);}

if($_POST['meta_keyw']!=$settings['meta_keyw']){
$meta_keyw=neutral_escape($_POST['meta_keyw'],1024,'str');
$query='UPDATE '.$dbss['prfx']."_settings SET set_value='$meta_keyw' WHERE set_id='meta_keyw'";
neutral_query($query);}

if(isset($_POST['guests']) &amp;&amp; $_POST['guests']!=$settings['guests']){
$guests=neutral_escape($_POST['guests'],1,'int');
$query='UPDATE '.$dbss['prfx']."_settings SET set_value='$guests' WHERE set_id='guests'";
neutral_query($query);}

if(isset($_POST['register']) &amp;&amp; $_POST['register']!=$settings['register']){
$register=neutral_escape($_POST['register'],1,'int');
$query='UPDATE '.$dbss['prfx']."_settings SET set_value='$register' WHERE set_id='register'";
neutral_query($query);}

if(isset($_POST['show_topic']) &amp;&amp; isset($settings['show_topic']) &amp;&amp; $_POST['show_topic']!=$settings['show_topic']){
$show_topic=neutral_escape($_POST['show_topic'],1,'int');
$query='UPDATE '.$dbss['prfx']."_settings SET set_value='$show_topic' WHERE set_id='show_topic'";
neutral_query($query);}

if(isset($_POST['activation']) &amp;&amp; $_POST['activation']!=$settings['activation']){
$activation=neutral_escape($_POST['activation'],1,'int');
$query='UPDATE '.$dbss['prfx']."_settings SET set_value='$activation' WHERE set_id='activation'";
neutral_query($query);}

if(isset($_POST['ajax_update']) &amp;&amp; $_POST['ajax_update']!=$settings['ajax_update']){
$ajax_update=(int)$_POST['ajax_update']; if($ajax_update>15 || $ajax_update<5){$ajax_update=6;}
$query='UPDATE '.$dbss['prfx']."_settings SET set_value='$ajax_update' WHERE set_id='ajax_update'";
neutral_query($query);}

if(isset($_POST['post_interv']) &amp;&amp; $_POST['post_interv']!=$settings['post_interv']){
$post_interv=(int)$_POST['post_interv']; if($post_interv>9000 || $post_interv<500){$post_interv=500;}
$query='UPDATE '.$dbss['prfx']."_settings SET set_value='$post_interv' WHERE set_id='post_interv'";
neutral_query($query);}

if(isset($_POST['ajax_delay']) &amp;&amp; $_POST['ajax_delay']!=$settings['ajax_delay']){
$ajax_delay=(int)$_POST['ajax_delay']; if($ajax_delay>900 || $ajax_delay<10){$ajax_delay=200;}
$query='UPDATE '.$dbss['prfx']."_settings SET set_value='$ajax_delay' WHERE set_id='ajax_delay'";
neutral_query($query);}

if(isset($_POST['post_length']) &amp;&amp; $_POST['post_length']!=$settings['post_length']){
$post_length=(int)$_POST['post_length']; if($post_length>2048 || $post_length<128){$post_length=512;}
$query='UPDATE '.$dbss['prfx']."_settings SET set_value='$post_length' WHERE set_id='post_length'";
neutral_query($query);}

redirect('admin.php?q=options');}

// ----

if(isset($_POST['mass_msg'])){
if(isset($_POST['mltple']) &amp;&amp; is_array($_POST['mltple']) &amp;&amp; count($_POST['mltple'])>0){

$mltple=$_POST['mltple'];
for($i=0;$i<count($mltple);$i++){$mltple[$i]=(int)$mltple[$i];}
$mltple=implode(',',$mltple);
$query='DELETE FROM '.$dbss['prfx']."_lines WHERE line_id IN ($mltple)";
neutral_query($query);}
redirect('admin.php?q=messages');
}

if(isset($_POST['mass_ptn'])){
if(isset($_POST['mltple']) &amp;&amp; is_array($_POST['mltple']) &amp;&amp; count($_POST['mltple'])>0){

$mltple=$_POST['mltple'];
for($i=0;$i<count($mltple);$i++){$mltple[$i]=(int)$mltple[$i]; @unlink('paintings/'.$mltple[$i].'.png');}
$mltple=implode(',',$mltple);
$query='DELETE FROM '.$dbss['prfx']."_paintings WHERE p_id IN ($mltple)";
neutral_query($query);}
redirect('admin.php?q=paintings');
}

if(isset($_POST['mass_usr'])){$ina='';
if(isset($_POST['mltple']) &amp;&amp; is_array($_POST['mltple']) &amp;&amp; count($_POST['mltple'])>0){

$mass_usr=(int)$_POST['mass_usr'];$mltple=$_POST['mltple'];

if($mass_usr>0 &amp;&amp; $mass_usr<3){
for($i=0;$i<count($mltple);$i++){$mltple[$i]=(int)$mltple[$i];}
$mltple=implode(',',$mltple);

if($mass_usr==1){$query='DELETE FROM '.$dbss['prfx']."_users WHERE usr_id IN ($mltple)";}
if($mass_usr==2){$query='UPDATE '.$dbss['prfx']."_users SET usr_status='0' WHERE usr_id IN ($mltple)";$ina='&amp;inact=1';}
neutral_query($query);}}
redirect('admin.php?q=users'.$ina);}


if(isset($_POST['add_user'])){
$new_user=neutral_escape($_POST['add_user'],60,'str');
$add_n='';

$query='SELECT usr_id FROM '.$dbss['prfx']."_users WHERE usr_name='$new_user'";
$result=neutral_query($query);

if(neutral_num_rows($result)>0){$add_n=rand(100,999);$new_user.=$add_n;}

$new_mail=neutral_escape($_POST['add_user'].$add_n.'@'.$_SERVER['SERVER_NAME'],64,'str');
$new_pass=hsh($new_user.$new_mail);

$query='INSERT INTO '.$dbss['prfx']."_users VALUES(NULL,'$new_user','$new_pass','$new_mail',$timestamp,'0')";
neutral_query($query);
redirect('admin.php?q=users');}


if(isset($_GET['del1usr'])){
$del1usr=(int)$_GET['del1usr'];
$query='DELETE FROM '.$dbss['prfx']."_users WHERE usr_id=$del1usr";
neutral_query($query);
redirect('admin.php?q=users');}


if(isset($_GET['act1usr'])){
$act1usr=(int)$_GET['act1usr'];

$query='SELECT usr_mail FROM '.$dbss['prfx']."_users WHERE usr_id=$act1usr";
$result=neutral_query($query);

if(neutral_num_rows($result)>0){
$email=neutral_fetch_array($result);$email=$email['usr_mail'];
$mll=send_mail($email,$lang['adm_ac_sub'],$lang['adm_ac_msg'].$settings['url'],$settings['default_mail']);

$query='UPDATE '.$dbss['prfx']."_users SET usr_status='0' WHERE usr_id=$act1usr";
neutral_query($query);

if($mll!=TRUE){print $lang['acco_m_err'];die();};}

redirect('admin.php?q=users&amp;inact=1');}


if(isset($_POST['usr_id']) &amp;&amp; isset($_POST['usr_name']) &amp;&amp; isset($_POST['usr_pass']) &amp;&amp; isset($_POST['usr_mail'])){

$upd='';

$uid=(int)$_POST['usr_id'];
$uname=neutral_escape($_POST['usr_name'],64,'str');
$upass=hsh($_POST['usr_pass']);
$umail=neutral_escape($_POST['usr_mail'],64,'str');

$query='SELECT usr_id,usr_join_date FROM '.$dbss['prfx']."_users WHERE usr_name='$uname' AND usr_id<>$uid";
$result=neutral_query($query);$usr_join_date=neutral_fetch_array($result);$usr_join_date=(int)$usr_join_date['usr_join_date'];

if(neutral_num_rows($result)<1 &amp;&amp; strlen($uname)>2){$upd.="usr_name='$uname',";}
if(strlen(trim($_POST['usr_pass']))>2){$upd.="usr_pass='$upass',";}
if(strlen(trim($_POST['usr_mail']))>6){$upd.="usr_mail='$umail',";}

if($upd!=''){
$query='UPDATE '.$dbss['prfx']."_users SET $upd usr_status=0 WHERE usr_id=$uid";
neutral_query($query);}

redirect('admin.php?q=user&amp;u='.$uid);}


// ----


if(isset($_POST['mssg_history']) &amp;&amp; isset($_POST['del_gbuddies']) &amp;&amp; isset($_POST['optimize_tbl'])){
if($_POST['mssg_history']!=$settings['mssg_history']){
$mssg_history=(int)$_POST['mssg_history'];
$query='UPDATE '.$dbss['prfx']."_settings SET set_value='$mssg_history' WHERE set_id='mssg_history'";
neutral_query($query);}

if($_POST['del_gbuddies']!=$settings['del_gbuddies']){
$del_gbuddies=(int)$_POST['del_gbuddies'];
$query='UPDATE '.$dbss['prfx']."_settings SET set_value='$del_gbuddies' WHERE set_id='del_gbuddies'";
neutral_query($query);}

if($_POST['optimize_tbl']!=$settings['optimize_tbl']){
$optimize_tbl=(int)$_POST['optimize_tbl'];
$query='UPDATE '.$dbss['prfx']."_settings SET set_value='$optimize_tbl' WHERE set_id='optimize_tbl'";
neutral_query($query);}

redirect('admin.php?q=database');}

// ----

if(isset($_POST['cacp']) &amp;&amp; isset($_POST['nacp']) &amp;&amp; isset($_POST['racp'])){
$cacp=trim($_POST['cacp']);$nacp=trim($_POST['nacp']);$racp=trim($_POST['racp']);

if(strlen($nacp)>4 &amp;&amp; $nacp==$racp &amp;&amp; hsh($cacp)==$settings['acp_key']){
$acp_key=hsh($nacp);
$query='UPDATE '.$dbss['prfx']."_settings SET set_value='$acp_key' WHERE set_id='acp_key'";
neutral_query($query);
redirect('admin.php?q=acpkey');
}}

// -----

if(isset($_POST['notebook']) &amp;&amp; isset($_POST['rdr'])){
$notebook=neutral_escape($_POST['notebook'],10000,'txt');
$query='UPDATE '.$dbss['prfx']."_settings SET set_value='$notebook' WHERE set_id='notebook'";
neutral_query($query);
switch($_POST['rdr']){
case '1':redirect('admin.php?q=settings');break;
default:redirect('admin.php');break;}}

// -----

if(isset($_POST['faq_page'])){
$faq_page=neutral_escape($_POST['faq_page'],65535,'txt');
$query='UPDATE '.$dbss['prfx']."_settings SET set_value='$faq_page' WHERE set_id='faq_page'";
neutral_query($query); redirect('admin.php?q=faq');}

// -----

if(isset($_POST['logo'])){
$logo=neutral_escape($_POST['logo'],65535,'txt');
$query='UPDATE '.$dbss['prfx']."_settings SET set_value='$logo' WHERE set_id='logo'";
neutral_query($query); redirect('admin.php?q=logo');}

// -----

if(isset($_GET['q']) &amp;&amp; $_GET['q']=='dell_all'){
$query='DELETE FROM '.$dbss['prfx'].'_lines';
neutral_query($query);
redirect('admin.php?q=messages');}


if(isset($_GET['update'])){
if(!isset($settings['show_topic'])){neutral_query('INSERT INTO '.$dbss['prfx']."_settings VALUES('show_topic','1',0)");} //5.3

$p_table=1;$query='SELECT COUNT(*) FROM '.$dbss['prfx'].'_paintings';
switch($dbss['type']){
case 'sqlite'    : @sqlite_query($dbo,$query)       or $p_table=0;$auto_increment='integer NOT NULL PRIMARY KEY';break;
case 'postgre'   : @pg_query($query)                or $p_table=0;$auto_increment='serial PRIMARY KEY';break;
case 'mysqli'    : @mysqli_query($sqli_link,$query) or $p_table=0;$auto_increment='integer NOT NULL auto_increment PRIMARY KEY';break;
default:           @mysql_query($query)             or $p_table=0;$auto_increment='integer NOT NULL auto_increment PRIMARY KEY';break;}

if($p_table<1){
$query='CREATE TABLE '.$dbss['prfx'].'_paintings(
p_id '
.$auto_increment.',
p_srx text NOT NULL,
p_sry text NOT NULL,
p_src text NOT NULL,
p_bgc char(6) NOT NULL,
p_views integer NOT NULL,
timestamp integer NOT NULL,
usr_id integer NOT NULL,
usr_name varchar(255) NOT NULL)'
;
neutral_query($query);}

if(!isset($settings['acp_timezone'])){ // 5.5
$cslt=microtime();$cslt=md5($cslt);$cslt=substr($cslt,0,16);
neutral_query('DELETE FROM '.$dbss['prfx']."_settings WHERE set_id='default_timezone'");
neutral_query('INSERT INTO '.$dbss['prfx']."_settings VALUES('acp_timezone','0',0)");
neutral_query('INSERT INTO '.$dbss['prfx']."_settings VALUES('cookie_salt','$cslt',0)");

}

redirect('admin.php?q=update');}

/* --- */

if(!isset($_GET['q'])){$q='main';}else{$q=$_GET['q'];}

switch ($q){
case 'online'   : $title=$lang['main'];     $page='sl_online.pxtm';break;
case 'chatters' : $title=$lang['main'];     $page='sl_chatters.pxtm';break;
case 'messages' : $title=$lang['main'];     $page='sl_messages.pxtm';break;
case 'paintings': $title=$lang['main'];     $page='sl_paintings.pxtm';break;
case 'user'     : $title=$lang['users'];    $page='user.pxtm';break;
case 'users'    : $title=$lang['users'];    $page='users.pxtm';break;
case 'options'  : $title=$lang['settings']; $page='st_settings.pxtm';break;
case 'database' : $title=$lang['settings']; $page='st_database.pxtm';break;
case 'acpkey'   : $title=$lang['settings']; $page='st_acpkey.pxtm';break;
case 'logo'     : $title=$lang['settings']; $page='st_logo.pxtm';break;
case 'faq'      : $title=$lang['settings']; $page='st_faq.pxtm';break;
case 'update'   : $title=$lang['settings']; $page='st_update.pxtm';break;
case 'imp_faq'  : $title=$lang['settings']; $page='st_faq.pxtm';$fp='incl/faq_example.txt';if(is_file($fp)){$fp=file($fp); $settings['faq_page']=implode('',$fp);}break;

default: $title=$lang['main'];$page='main.pxtm';break;}

include 'admin/head.pxtm';
include 'admin/overal_header.pxtm';
include 'admin/'.$page;
include 'admin/overal_footer.pxtm';


?>

&amp;nbsp;

Scripts for Micro Chat Include Scripts

Micro Chat is a simple PHP based chat script with very easy installation. The script is designed for smaller traffic and so no database is required. You only need to upload the files and the script works fine. The look and feel is easy editable via CSS.

 

<?php
session_start();

function createForm(){
?>
 <form action="<?php echo $_SERVER['PHP_SELF']; ?>" method="post">
 <table align="center">
 <tr><td colspan="2">Please eneter a nickname to login!</td></tr>
 <tr><td>Your name: </td>
 <td><input type="text" name="name" /></td></tr>
 <tr><td colspan="2" align="center">
 <input type="submit" name="submitBtn" value="Login" />
 </td></tr>
 </table>
 </form>
<?php
}

if (isset($_GET['u'])){
 unset($_SESSION['nickname']);
}

// Process login info
if (isset($_POST['submitBtn'])){
 $name    = isset($_POST['name']) ? $_POST['name'] : "Unnamed";
 $_SESSION['nickname'] = $name;
}

$nickname = isset($_SESSION['nickname']) ? $_SESSION['nickname'] : "Hidden";
?>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "DTD/xhtml1-transitional.dtd">
<html>
<head>
 <title>Micro Chat</title>
 <link href="style/style.css" rel="stylesheet" type="text/css" />
 <script language="javascript" type="text/javascript">
 <!--
 var httpObject = null;
 var link = "";
 var timerID = 0;
 var nickName = "<?php echo $nickname; ?>";

 // Get the HTTP Object
 function getHTTPObject(){
 if (window.ActiveXObject) return new ActiveXObject("Microsoft.XMLHTTP");
 else if (window.XMLHttpRequest) return new XMLHttpRequest();
 else {
 alert("Your browser does not support AJAX.");
 return null;
 }
 }

 // Change the value of the outputText field
 function setOutput(){
 if(httpObject.readyState == 4){
 var response = httpObject.responseText;
 var objDiv = document.getElementById("result");
 objDiv.innerHTML += response;
 objDiv.scrollTop = objDiv.scrollHeight;
 var inpObj = document.getElementById("msg");
 inpObj.value = "";
 inpObj.focus();
 }
 }

 // Change the value of the outputText field
 function setAll(){
 if(httpObject.readyState == 4){
 var response = httpObject.responseText;
 var objDiv = document.getElementById("result");
 objDiv.innerHTML = response;
 objDiv.scrollTop = objDiv.scrollHeight;
 }
 }

 // Implement business logic
 function doWork(){
 httpObject = getHTTPObject();
 if (httpObject != null) {
 link = "message.php?nick="+nickName+"&amp;msg="+document.getElementById('msg').value;
 httpObject.open("GET", link , true);
 httpObject.onreadystatechange = setOutput;
 httpObject.send(null);
 }
 }

 // Implement business logic
 function doReload(){
 httpObject = getHTTPObject();
 var randomnumber=Math.floor(Math.random()*10000);
 if (httpObject != null) {
 link = "message.php?all=1&amp;rnd="+randomnumber;
 httpObject.open("GET", link , true);
 httpObject.onreadystatechange = setAll;
 httpObject.send(null);
 }
 }

 function UpdateTimer() {
 doReload();
 timerID = setTimeout("UpdateTimer()", 5000);
 }


 function keypressed(e){
 if(e.keyCode=='13'){
 doWork();
 }
 }
 //-->
 </script>
</head>
<body onload="UpdateTimer();">
 <div id="main">
 <div id="caption">Micro Chat</div>
 <div id="icon">&amp;nbsp;</div>
<?php

if (!isset($_SESSION['nickname']) ){
 createForm();
} else  {
 $name    = isset($_POST['name']) ? $_POST['name'] : "Unnamed";
 $_SESSION['nickname'] = $name;
 ?>

 <div id="result">
 <?php
 $data = file("msg.html");
 foreach ($data as $line) {
 echo $line;
 }
 ?>
 </div>
 <div id="sender" onkeyup="keypressed(event);">
 Your message: <input type="text" name="msg" size="30" id="msg" />
 <button onclick="doWork();">Send</button>
 </div>
<?php
 }

?>
 </div>
</body>

&amp;nbsp;

Scripts for Waterfall Chat Include Scripts

Use Waterfall to add a social networking aspect to your website that everyone can benefit from. The chat room uses a text file for storing recent messages and also keeps transcript logs in a separate file. You are free to make changes to the code and use it on your website however you please. Installation is painless, just drag the files into your preferred directory and Waterfall will install automatical

 

 

<!-- Waterfall 1.0 - Zack Spencer 2011 - thelinuxbuzz@gmail.com -->

<?php

 include 'settings.php';

 $fn = "../transcripts/chat.txt";
 $ct = "../transcripts/chat_transcript.txt";
 $maxlines = $MAX_LINES;
 $nick_length = $NICK_LENGTH;

 $waittime_sec = 0;

 $ip = @$REMOTE_ADDR;

 $msg = $_REQUEST["m"];
 $msg = htmlspecialchars(stripslashes($msg));

 $n = $_REQUEST["n"];
 $n = htmlspecialchars(stripslashes($n));

 if (strlen($n) >= $nick_length) {
 $n = substr($n, 0, $nick_length);
 } else {
 for ($i=strlen($n); $i<$nick_length; $i++) $n .= "";
 }

include 'link.php';

 if ($waittime_sec > 0) {
 $lastvisit = $_COOKIE["lachatlv"];
 setcookie("lachatlv", time());

 if ($lastvisit != "") {
 $diff = time() - $lastvisit;
 if ($diff < 5) { die();    }
 }
 }

 if ($msg != "")  {
 if (strlen($msg) < 1) { die(); }
 if (strlen($msg) > 1) {
 if (strtoupper($msg) == $msg) { die(); }
 }
 if (strlen($msg) > 150) { die(); }
 if (strlen($msg) > 15) {
 if (substr_count($msg, substr($msg, 6, 8)) > 1) { die(); }
 }

 foreach ($BLOCKED_IPS as $a) {
 if ($_SERVER["REMOTE_ADDR"] == $a) { die();  }
 }

 $mystring = strtoupper($msg);
 foreach ($spam as $a) {
 if (strpos($mystring, strtoupper($a)) === false) {
 } else {
 die();
 }
 }

 foreach ($espam as $a) {
 if (strtoupper($msg) == strtoupper($a)) { die(); }
 }

 $handle = fopen ($fn, 'r');
 $chattext = fread($handle, filesize($fn)); fclose($handle);

 $arr1 = explode("\n", $chattext);

 if (count($arr1) > $maxlines) {
 $arr1 = array_reverse($arr1);
 for ($i=0; $i<$maxlines; $i++) { $arr2[$i] = $arr1[$i]; }
 $arr2 = array_reverse($arr2);
 } else {
 $arr1 = array_reverse($arr1);
 for ($i=0; $i<$maxlines; $i++) { $arr2[$i] = $arr1[$i]; }
 $arr2 = array_reverse($arr2);
 }

 $chattext = implode("\n", $arr2);

 $out = $chattext . '<span style="color:' . $CHAT_NAME_COLOR . '; font-size: 20px;">' . $n . '</span>&amp;nbsp;| <span style="color: ' . $CHAT_MSG_COLOR . '; font-size: 20px">' . $msg . "</span><br />\n";
 $out = str_replace("\'", "'", $out);
 $out = str_replace("\\\"", "\"", $out);

 $out1 = $n . ": " . $msg. "\n";

 $handle = fopen ($fn, 'w'); fwrite ($handle, $out); fclose($handle);
 $handle1 = fopen ($ct, 'a'); fwrite ($handle1, $out1); fclose($handle1);
 }
?>

&amp;nbsp;

&amp;nbsp;

PHPBB FLASH CHAT MODULE Include Scripts

FlashComs chat and messenger applications are fully compatible with php bb. They are positioned to be the most innovative and feature-rich applications among flash based solutions. Video/audio options as well as basic text chatting provide real time communication experience to website members. Such features like multi-room, one-to-one conversatoins, flexible video window positioning, personal settings, friend/block lists, complete integration with existing users database and many more makes Flashcoms applications all-sufficient and easy to use solutions for both members and owner. The latest version of Community Video Chat boasts of implementation ultra-modern features for flash based software, namely built-in whiteboard, instant messengers support, online games, MP3 player and more. Number of available plugins brings flexibility in chat/messenger configuration and allows meeting requirements of business and entertainment orientated websites.

 

 

<?php
session_start();

require_once './common/server/php/settings.php';
require_once FLASHCOMS_ROOT.'common/server/php/core/core.php';
require_once FLASHCOMS_ROOT.'common/server/php/core/selftest.class.php';
require_once FLASHCOMS_ROOT.'common/server/php/core/db.class.php';

function RenderPage()
{
 switch (getInputParam("action"))
 {
 case 'videochat':            showVideochat();            break;
 case 'videochatEmbedded':    showVideochatEmbedded();    break;
 default:                     showIndex();
 }
}
function showIndex()
{
 ?>
 <div style="padding:30px">
 <font style="font-size:13px;color:#336699;font-weight:bold;">Please select the application you wish to test from the menu on the left.</font>
 </div>
 <?php
}

//// Videochat ////
function showVideochat()
{
 $roomId = getInputParam("roomId");
 $uid = getInputParam("uid", "Test");
 $langId = getInputParam("langId");

 $Test = new SelfTest('Community Video Chat');
 $Test->CheckFiles(array("videochat/languages/help_content.en.xml", "videochat/languages/lang.en.xml",
 "videochat/server/php/handlers.php", "videochat/server/php/videochat.php",
 "videochat/settings/main.xml", "videochat/settings/menu.xml",
 "videochat/settings/plugins.xml", "videochat/skins/main.swf",
 "videochat/sounds/message_receive.mp3", "videochat/sounds/message_personal.mp3",
 "videochat/sounds/message_join_left.mp3", "videochat/sounds/system.mp3",
 "videochat/videochat.swf"));
 $Test->Output();
 ?>
 <div>
 <table border="0" align="center" cellpadding="5" cellspacing="0">
 <tr align="center">
 <td style="background-color:#FFFFFF" align="center">
 <table border="0" align="center" cellpadding="0" cellspacing="0">
 <tr>
 <td width="5px" style="background-image:url(common/images/submit_l.gif);background-repeat:no-repeat;"></td>
 <td align="center"><input type="button" name="Button1" value="Test Community Video Chat (pop up mode)"
 onClick="javascript:openVideochatWindow('<?php echo $roomId; ?>', '<?php echo $uid; ?>', '<?php echo $langId; ?>');"></td>
 <td width="5px" style="background-image:url(common/images/submit_r.gif);background-repeat:no-repeat;"></td>
 </tr>
 </table>
 </td>
 </tr>
 <tr align="center">
 <td style="background-color:#FFFFFF" align="center">
 <table border="0" align="center" cellpadding="0" cellspacing="0">
 <tr>
 <td width="5px" style="background-image:url(common/images/submit_l.gif);background-repeat:no-repeat;"></td>
 <td align="center"><input type="button" name="Button2" value="Test Community Video Chat (embedded mode)"
 onClick="javascript:location.href='./test.php?action=videochatEmbedded';"></td>
 <td width="5px" style="background-image:url(common/images/submit_r.gif);background-repeat:no-repeat;"></td>
 </tr>
 </table>
 </td>
 </tr>
 </table>
 </div>
 <?php
}
function showVideochatEmbedded()
{
 renderApplication("videochat", array(
 "roomId" => getInputParam("roomId"),
 "uid" => getInputParam("uid", "Test"),
 "langId" => getInputParam("langId"),
 "httpRoot" => FLASHCOMS_HTTP_ROOT,
 "rtmpRoot" => FLASHCOMS_RTMP_ROOT));
}

?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
 <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
 <title>Flashcoms 5.1 - Test Page</title>
 <script language="javascript" src="<?php echo FLASHCOMS_HTTP_ROOT; ?>common/js/flashcoms.js"></script>
 <style>
 body,td,th {
 margin: 0px;
 font-family: Verdana, Arial, Helvetica, sans-serif;    font-size: 11px;
 background-color: #F7FBFD;
 }
 a {
 font-family: Verdana, Arial, Helvetica, sans-serif;    font-size: 10px;
 color:#336699; text-decoration: none;
 }
 a:hover { text-decoration: underline; }

 ul { padding:0px; list-style-type:none; }
 li { padding:5px; }

 .navig { border-right:2px solid #7B7B7B; }
 .navig a { display:block; padding:5px; }

 .test_info { padding-top:70px; padding-bottom:20px;    }
 .full_size { width:100%; height:100%; }
 .center { text-align:center; }
 .debug_link { display:block; margin-top:100px; color:#F7FBFD; }

 input {
 color:#336699;
 border-width:0px; border-style:None;
 font-weight:bold;
 height:27px;
 background-repeat:repeat-x;    background-image:url(common/images/submit.gif);
 padding:0px 0px 2px 0px;
 text-align:center;
 vertical-align:middle;
 font-family: Verdana, Arial, Helvetica, sans-serif;    font-size: 10px;
 }
 input.text {
 color:#336699;
 border-width:0px; border-style:None;
 font-weight:bold;
 height:27px;
 background-repeat:repeat-x;    background-image:url(common/images/submit.gif);
 padding:7px 0px 2px 0px;
 text-align:center;
 vertical-align:middle;
 font-family: Verdana, Arial, Helvetica, sans-serif;    font-size: 10px;
 }
 </style>
</head>
<body>
<table width="100%" height="100%" border="0" cellpadding="5" cellspacing="1">
 <tr>
 <td colspan="2" width="100%" height="50px" style="border-bottom:2px solid #7B7B7B;">
 <a href="http://www.flashcoms.com"><img src="common/images/logo.gif" hspace="34" vspace="15" border="0"
 alt="FlashComs - The new feel of communication" title="FlashComs - The new feel of communication"/></a>
 </td>
 </tr>
 <tr valign="top">
 <td width="12%" valign="top" nowrap>
 <a href="?action=videochat">Community Video Chat</a>
 <a href="javascript:openDebugWindow();">debug</a>
 </td>
 <td style="background-color:#ffffff;"><?php RenderPage();?></td>
 </tr>
</table>
</body>
</html>

&amp;nbsp;

 

PHP Community Video Chat Include Scripts

FlashComs Community Video Chat is positioned to be the most innovative and feature-rich application among flash based solutions. It’s truly robust yet lightweight chat solutions in line with the latest multimedia standards. Video/audio options as well as basic text chatting provide real time communication experience to website members. Such features like multi-room, flexible video window positioning, personal settings, friend/block lists, complete integration with existing users database and many more makes Flashcoms chat all-sufficient and easy to use solution for both members and owner. The latest version of Community Video Chat boasts of implementation ultra-modern features for flash based software, namely built-in whiteboard, instant messengers support, online games, MP3 player and more. Number of available plugins brings flexibility in chat configuration and allows meeting requirements of business and entertainment orientated websites.

 

<?php
session_start();

require_once './common/server/php/settings.php';
require_once FLASHCOMS_ROOT.'common/server/php/core/core.php';
require_once FLASHCOMS_ROOT.'common/server/php/core/selftest.class.php';
require_once FLASHCOMS_ROOT.'common/server/php/core/db.class.php';

function RenderPage()
{
 switch (getInputParam("action"))
 {
 case 'videochat':            showVideochat();            break;
 case 'videochatEmbedded':    showVideochatEmbedded();    break;
 default:                     showIndex();
 }
}
function showIndex()
{
 ?>
 <div style="padding:30px">
 <font style="font-size:13px;color:#336699;font-weight:bold;">Please select the application you wish to test from the menu on the left.</font>
 </div>
 <?php
}

//// Videochat ////
function showVideochat()
{
 $roomId = getInputParam("roomId");
 $uid = getInputParam("uid", "Test");
 $langId = getInputParam("langId");

 $Test = new SelfTest('Community Video Chat');
 $Test->CheckFiles(array("videochat/languages/help_content.en.xml", "videochat/languages/lang.en.xml",
 "videochat/server/php/handlers.php", "videochat/server/php/videochat.php",
 "videochat/settings/main.xml", "videochat/settings/menu.xml",
 "videochat/settings/plugins.xml", "videochat/skins/main.swf",
 "videochat/sounds/message_receive.mp3", "videochat/sounds/message_personal.mp3",
 "videochat/sounds/message_join_left.mp3", "videochat/sounds/system.mp3",
 "videochat/videochat.swf"));
 $Test->Output();
 ?>
 <div>
 <table border="0" align="center" cellpadding="5" cellspacing="0">
 <tr align="center">
 <td style="background-color:#FFFFFF" align="center">
 <table border="0" align="center" cellpadding="0" cellspacing="0">
 <tr>
 <td width="5px" style="background-image:url(common/images/submit_l.gif);background-repeat:no-repeat;"></td>
 <td align="center"><input type="button" name="Button1" value="Test Community Video Chat (pop up mode)"
 onClick="javascript:openVideochatWindow('<?php echo $roomId; ?>', '<?php echo $uid; ?>', '<?php echo $langId; ?>');"></td>
 <td width="5px" style="background-image:url(common/images/submit_r.gif);background-repeat:no-repeat;"></td>
 </tr>
 </table>
 </td>
 </tr>
 <tr align="center">
 <td style="background-color:#FFFFFF" align="center">
 <table border="0" align="center" cellpadding="0" cellspacing="0">
 <tr>
 <td width="5px" style="background-image:url(common/images/submit_l.gif);background-repeat:no-repeat;"></td>
 <td align="center"><input type="button" name="Button2" value="Test Community Video Chat (embedded mode)"
 onClick="javascript:location.href='./test.php?action=videochatEmbedded';"></td>
 <td width="5px" style="background-image:url(common/images/submit_r.gif);background-repeat:no-repeat;"></td>
 </tr>
 </table>
 </td>
 </tr>
 </table>
 </div>
 <?php
}
function showVideochatEmbedded()
{
 renderApplication("videochat", array(
 "roomId" => getInputParam("roomId"),
 "uid" => getInputParam("uid", "Test"),
 "langId" => getInputParam("langId"),
 "httpRoot" => FLASHCOMS_HTTP_ROOT,
 "rtmpRoot" => FLASHCOMS_RTMP_ROOT));
}

?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
 <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
 <title>Flashcoms 5.1 - Test Page</title>
 <script language="javascript" src="<?php echo FLASHCOMS_HTTP_ROOT; ?>common/js/flashcoms.js"></script>
 <style>
 body,td,th {
 margin: 0px;
 font-family: Verdana, Arial, Helvetica, sans-serif;    font-size: 11px;
 background-color: #F7FBFD;
 }
 a {
 font-family: Verdana, Arial, Helvetica, sans-serif;    font-size: 10px;
 color:#336699; text-decoration: none;
 }
 a:hover { text-decoration: underline; }

 ul { padding:0px; list-style-type:none; }
 li { padding:5px; }

 .navig { border-right:2px solid #7B7B7B; }
 .navig a { display:block; padding:5px; }

 .test_info { padding-top:70px; padding-bottom:20px;    }
 .full_size { width:100%; height:100%; }
 .center { text-align:center; }
 .debug_link { display:block; margin-top:100px; color:#F7FBFD; }

 input {
 color:#336699;
 border-width:0px; border-style:None;
 font-weight:bold;
 height:27px;
 background-repeat:repeat-x;    background-image:url(common/images/submit.gif);
 padding:0px 0px 2px 0px;
 text-align:center;
 vertical-align:middle;
 font-family: Verdana, Arial, Helvetica, sans-serif;    font-size: 10px;
 }
 input.text {
 color:#336699;
 border-width:0px; border-style:None;
 font-weight:bold;
 height:27px;
 background-repeat:repeat-x;    background-image:url(common/images/submit.gif);
 padding:7px 0px 2px 0px;
 text-align:center;
 vertical-align:middle;
 font-family: Verdana, Arial, Helvetica, sans-serif;    font-size: 10px;
 }
 </style>
</head>
<body>
<table width="100%" height="100%" border="0" cellpadding="5" cellspacing="1">
 <tr>
 <td colspan="2" width="100%" height="50px" style="border-bottom:2px solid #7B7B7B;">
 <a href="http://www.flashcoms.com"><img src="common/images/logo.gif" hspace="34" vspace="15" border="0"
 alt="FlashComs - The new feel of communication" title="FlashComs - The new feel of communication"/></a>
 </td>
 </tr>
 <tr valign="top">
 <td width="12%" valign="top" nowrap>
 <a href="?action=videochat">Community Video Chat</a>
 <a href="javascript:openDebugWindow();">debug</a>
 </td>
 <td style="background-color:#ffffff;"><?php RenderPage();?></td>
 </tr>
</table>
</body>
</html>

&amp;nbsp;

PHP Scripts for Guestbook Include Scripts

GentleSource Guestbook allows you to put a guestbook on your website. Your visitors can sign it and leave a message. The entries can be edited and deleted in the admin area.Once you have the script installed on your server it shows the form fields “name”, “E-mail”, “Homepage”, “Title”, and “Comment”. The field “Comment” is mandatory and the will not be posted until that field has been filled out.In order to prevent the script from being abused by automatic spam bots, you can enable the Captcha feature. The script then asks your visitors to enter a text they see in the image below the comment form into an input box. The comment will only be submitted if the strings match. Visitors have to ensure that their browser support and accept cookies, otherwise the comment cannot be verified.

<?php

/**
 * GentleSource Guestbook Script
 *
 * (C) Ralf Stadtaus http://www.gentlesource.com/
 */


  /*****************************************************
  **
  ** THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY
  ** OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT
  ** LIMITED   TO  THE WARRANTIES  OF  MERCHANTABILITY,
  ** FITNESS    FOR    A    PARTICULAR    PURPOSE   AND
  ** NONINFRINGEMENT.  IN NO EVENT SHALL THE AUTHORS OR
  ** COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES
  ** OR  OTHER  LIABILITY,  WHETHER  IN  AN  ACTION  OF
  ** CONTRACT,  TORT OR OTHERWISE, ARISING FROM, OUT OF
  ** OR  IN  CONNECTION WITH THE SOFTWARE OR THE USE OR
  ** OTHER DEALINGS IN THE SOFTWARE.
  **
  *****************************************************/





// Settings
if (!defined('G10E_ROOT')) {
    define('G10E_ROOT', './');
}


$g10e_detail_template        = 'comment.tpl.html';
$frontend_language          = true;
define('G10E_LOGIN_LEVEL', 0);



// Include
require G10E_ROOT . 'include/core.inc.php';
require 'urlconvert.class.inc.php';

// Check for module standalone call
if (g10e_gpc_vars('module')) {
    $module_data = array('data' => g10e_gpc_vars('module'));
    g10e_module::call_module('standalone', $module_data, $g10e['module_additional']);
    exit;
}

// -----------------------------------------------------------------------------

require_once 'HTML/QuickForm/Renderer/ArraySmarty.php';
require_once 'HTML/QuickForm.php';


// Start output handling
$g10e_out = new g10e_output($g10e_detail_template);


// Start comment handling
$g10e_comment = new g10e_comment;

// Dynamic comment field value
g10e_comment::field_value($_POST);

// Start form handler
$g10e_form_action = getenv('REQUEST_URI');
if (g10e_gpc_vars('g10e_ssi') or g10e_gpc_vars('g10e_ssi_redirect')) {
    $g10e_form_action = $g10e['script_url'] . 'include.php';
}
$g10e_form = new HTML_QuickForm('form', 'POST', $g10e_form_action . '#g10e_form');




// Add redirect URL
if (g10e_gpc_vars('g10e_ssi') or g10e_gpc_vars('g10e_ssi_redirect')) {
    $g10e_form->addElement('hidden', 'g10e_ssi_redirect');
    if ($g10e_ssi_redirect = g10e_gpc_vars('g10e_ssi_redirect')) {
        $g10e['alternative_template'] = 'standalone';
    } else {
        $g10e_ssi_redirect = getenv('REQUEST_URI');
    }
    $g10e_form->setDefaults(array('g10e_ssi_redirect' => $g10e_ssi_redirect));
}

// -----------------------------------------------------------------------------




// Display or hide form
$g10e_active_form = true;
if ($g10e['display_comment_form'] != 'Y') {
    if ($g10e['display_turn_off_messages'] == 'Y') {
        $g10e['message'][] = $g10e['text']['txt_entry_form_turned_off'];
    }
    $g10e_active_form = false;
}


// Get form configuration
require 'comment_form.inc.php';



// Validate form
$g10e_message = array();
if ($g10e['display_comment_form'] == 'Y') {
    $g10e_active_form = true;
    if (g10e_gpc_vars('save')) {
        if (isset($g10e['_post']['save']) and $g10e_form->validate()) {
            if ($g10e_comment->put()) {
                $g10e_active_form = false;

//                header('Location: ' . $g10e['server_protocol'] . $g10e['server_name'] . $g10e['script_url'] . '#g10e_top');
//                exit;
            }
            if ($g10e_ssi_redirect = g10e_gpc_vars('g10e_ssi_redirect')) {
                header('Location: ' . $g10e['server_protocol'] . $g10e['server_name'] . $g10e_ssi_redirect);
                exit;
            }
        } else {
            if (sizeof($g10e['_post']) > 0) {
                $g10e['message'][] = $g10e['text']['txt_fill_out_required'];
            }
        }
    }

    $g10e_form_renderer = new HTML_QuickForm_Renderer_ArraySmarty($g10e_out->get_object, true);
    $g10e_form->accept($g10e_form_renderer);
    $g10e_out->assign('form', $g10e_form_renderer->toArray());
} else {
//    $g10e['message'][] = $g10e['text']['txt_entries_disabled'];
//    $g10e_active_form = false;
}

// -----------------------------------------------------------------------------




// Get comment data
$g10e_comment_list_values = array('result_number' => 0);
if ($g10e['display_comments'] == 'Y'
        and $page = g10e_url_convert::page_input()) {
    require 'commentlist.class.inc.php';
    $g10e_list_setup = array('direction' => $g10e['frontend_order'],
                            'limit'     => 0,
                            'page'      => $page);
    if ((int) $g10e['frontend_result_number'] >= 1) {
        $g10e_list_setup['limit'] = (int) $g10e['frontend_result_number'];
        // Pagination does not work with SSI
        if (g10e_gpc_vars('g10e_ssi')) {
            $g10e_list_setup['limit'] = 0;
        }
        $g10e_out->assign('display_pagination', true);
    }
    $g10e_comment_list = new g10e_comment_list(false, $g10e_list_setup);
        if ($g10e_comment_data = $g10e_comment_list->get_list()) {
            $g10e_out->assign('comment_list', $g10e_comment_data);
        }
    $g10e_comment_list_values = $g10e_comment_list->values();
    $g10e_comment_list_values['start_page_url']      = g10e_url_convert::page_output(1);
    $g10e_comment_list_values['end_page_url']        = g10e_url_convert::page_output($g10e_comment_list_values['result_pages']);
    $g10e_comment_list_values['next_page_url']       = g10e_url_convert::page_output($g10e_comment_list_values['next_page']);
    $g10e_comment_list_values['previous_page_url']   = g10e_url_convert::page_output($g10e_comment_list_values['previous_page']);
    $g10e_out->assign($g10e_comment_list_values);

    if ($g10e_comment_list_values['result_limit'] > 0){
        $g10e_page = ceil(($g10e_comment_list_values['result_number'] + 1) / $g10e_comment_list_values['result_limit']);
    } else {
        $g10e_page = 1;
    }
    $g10e_form->setConstants(array('page' => $g10e_page));
}
$g10e_out->assign($g10e_comment_list_values);

// Page not found
if (!g10e_url_convert::page_input()) {
    $g10e_turned_off = array('frontend_text'         => $g10e['text']['txt_no_entries_found'],
                            'comment_author_name'   => $g10e['text']['txt_administrator'],
                            'comment_number'        => 1,
                            'comment_date'          => g10e_time::format_date(g10e_time::current_timestamp()),
                            'comment_time'          => g10e_time::format_time(g10e_time::current_timestamp())
                            );
    $g10e_out->assign('comment_list', array($g10e_turned_off));
}

// Entry display has been turned off
if ($g10e['display_comments'] != 'Y' and $g10e['display_turn_off_messages'] == 'Y') {
    $g10e_turned_off = array('frontend_text'         => $g10e['text']['txt_entry_display_turned_off'],
                            'comment_author_name'   => $g10e['text']['txt_administrator'],
                            'comment_number'        => 1,
                            'comment_date'          => g10e_time::format_date(g10e_time::current_timestamp()),
                            'comment_time'          => g10e_time::format_time(g10e_time::current_timestamp())
                            );
    $g10e_out->assign('comment_list', array($g10e_turned_off));
}

// -----------------------------------------------------------------------------




// Show or hide comment form and comment list according to settings
$g10e_show_comments  = true;
$g10e_show_form      = true;
$g10e_show_list_link = false;
$g10e_show_sign_link = false;

if ($g10e['separate_comment_form'] == 'Y') {
    $g10e_show_form      = false;
    $g10e_show_sign_link = true;
}

if (g10e_gpc_vars('d') == 'sign') {
    $g10e_show_form      = true;
    $g10e_show_comments  = false;
    $g10e_show_list_link = true;
}

// -----------------------------------------------------------------------------


$page_data = array('page_title' => $g10e['text']['txt_guestbook_script']);
$g10e_out->assign('page_data', $page_data);



// Output
$g10e_out->assign('active_form', $g10e_active_form);
$g10e_out->assign('show_form', $g10e_show_form);
$g10e_out->assign('show_comments', $g10e_show_comments);
$g10e_out->assign('show_list_link', $g10e_show_list_link);
$g10e_out->assign('show_sign_link', $g10e_show_sign_link);
$g10e_output = $g10e_out->finish(false);

Atrise PHP Script Debugger Include Scripts

Atrise PHP Script Debugger is an online debug script for your PHP projects. It can help you to show PHP variables, debug string output, script execution time, the page source and other information that helps you in your PHP development. Features of the PHP Debugger: Handy output with debug points with floating tooltips; Shows PHP variables, objects and arrays; Shows your debug messages; Shows script execution time and time delta; HTML output highlighted view; Online tools like HTML, CSS validate, ping, whois etc. Simply place a few files to your PHP project to begin.

 

<?php include_once('psd.php'); // This is a PSD include
$title = 'Example 4'; include_once('inc/header.php');

echo '<p>This example demonstrates of using Debug Points to display
texts and PHP variables. Place the mouse cursor over debug points (green rectangles).</p>
<p>This PHP code generates for you:</p><ul>'
;

echo "\n".'<li>1. Text output: echo psd_text("Test\t &amp;lt;b&amp;gt;test&amp;lt;/b&amp;gt; test\n")';
 echo psd_text("Test\t <b>test</b> test\n");

echo "</li>\n".'<li>2. HTML output: echo psd_html("Test\t &amp;lt;b&amp;gt;test&amp;lt;/b&amp;gt; test\n")';
 echo psd_html("Test\t <b>test</b> test\n");

echo "</li>\n".'<li>3. Variable content: echo psd_var($x)';
 $x = 3.14; echo psd_var($x);

echo "</li>\n".'<li>4. Multiple variable content: echo psd_var($x, $y, $z)';
 $x = array(1,2,3); $y=true; $z='text'; echo psd_var($x, $y, $z);

echo "</li>\n".'<li>5. Very long text variable with truncation: echo psd_var($x)';
 $x =
 "1234567890123456789012345678901234567890\n".
 "1234567890123456789012345678901234567890\n".
 "1234567890123456789012345678901234567890\n".
 "1234567890123456789012345678901234567890\n".
 "1234567890123456789012345678901234567890\n".
 "1234567890123456789012345678901234567890\n".
 "1234567890123456789012345678901234567890\n".
 "1234567890123456789012345678901234567890\n".
 "1234567890123456789012345678901234567890\n".
 "1234567890123456789012345678901234567890\n".
 "1234567890123456789012345678901234567890\n";
 echo psd_var($x);

echo "</li>\n".'<li>6. Using psd_var_export to see arrays and objects: echo psd_var_export($x)';
 $x = array("aaa","bbb","ccc"); echo psd_var_export($x);

echo "</li>\n".'<li>7. Using psd_print_r to see arrays and objects: echo psd_print_r($x)';
 $x = array("aaa","bbb","ccc"); echo psd_print_r($x);

echo "</li>\n".'<li>8. Using psd_zval_dump to see arrays and objects: echo psd_zval_dump($x)';
 $x = array("aaa","bbb","ccc"); echo psd_zval_dump($x);


echo '</li></ul><p>Debug Points also visible in HTML Source Panel.</p>';
include_once('inc/footer.php');
?>

&amp;nbsp;

Installation and Configuration Include Scripts

This is a Free PHP script to record and view daily website page views (hits) for statistical tracking. Features a chart of daily page views totals displayed with bar graph, total for last x days, most hits in a day for last x days, average hits per day for last x days, projected hits for today, and more. Easy to install.

<?
/*
#####################################################################
#                          Free Statistics                          #
#                           Version 1.1.0                           #
#                       ©2003 Free-Webhosts.com                     #
#####################################################################

#####################################################################
#                                                                   #
#  Author      :  Free-Webhosts.com                                 #
#  Date        :  July 31, 2003                                     #
#  Website     :  http://www.free-webhosts.com/                     #
#  Contact     :  http://www.free-webhosts.com/contact.php          #
#  License     :  FREE (GPL);  See Copyright and Terms below, or    #
#                 http://www.free-webhosts.com/free-statistics.php  #
#                                                                   #
#####################################################################


See readme.txt for installation, copyright, change log, and other notes.


###########################################################################################
###########################################################################################
*/




require "config.php";

if(isset($_GET['last_x_days'])) $last_x_days=$_GET['last_x_days']; # register globals off?
if (isset($last_x_days))
{
  $last_x_days=round($last_x_days);
  if ($last_x_days>0) $limit=$last_x_days;
}


if ($no_cache == 1)
{
  # no cache
  header("Expires: Tue, 17 Jun 2003 01:00:00 GMT");         # Date in the past
  header("Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT");    # always modified
  header("Cache-Control: no-store, no-cache, must-revalidate"); # HTTP/1.1
 header("Cache-Control: post-check=0, pre-check=0", false);
  header("Pragma: no-cache");                           # HTTP/1.0
}

function diff_of_days($start_date,$end_date)
{
    // Gets the difference in days between two dates.(YYYY-MM-DD)
      // total numbers of days in range = diff_of_days($start_date,$end_date) + 1
    $s_parts = explode("-",$start_date);
    $e_parts = explode("-",$end_date);
    $s_timestamp = mktime(0,0,0,$s_parts[1],$s_parts[2],$s_parts[0]);
    $e_timestamp = mktime(0,0,0,$e_parts[1],$e_parts[2],$e_parts[0]);
    $difference = abs($e_timestamp - $s_timestamp)/86400;
    return($difference);
}

function date_x_days_ago($start_date,$xdays)
{
    // Gets the date x days before $start_date. (YYYY-MM-DD)
    $s_parts = explode("-",$start_date);
    $e_timestamp = mktime(0,0,0,$s_parts[1],$s_parts[2]-$xdays,$s_parts[0]);
    $end_date = date("Y-m-d",$e_timestamp);
    return($end_date);
}

$today = date("Y-m-d");
$time1 = date("H:i:s");
$time2 = date("g:i a");


?><html><head>
<title>Free statistics - Daily Hits</title>
<meta http-equiv="Content-Style-Type" content="text/css">
<style type="text/css">
<!--
BODY { COLOR: #344684; FONT-FAMILY: Arial, Helvetica, sans-serif; SCROLLBAR-FACE-COLOR: #0080FF; SCROLLBAR-HIGHLIGHT-COLOR: #FFFFFF; SCROLLBAR-SHADOW-COLOR: #5b6bb6; SCROLLBAR-3DLIGHT-COLOR: #000000; SCROLLBAR-ARROW-COLOR: #fdfc65; SCROLLBAR-TRACK-COLOR: #B9C9FF; SCROLLBAR-DARKSHADOW-COLOR: #000000; }
A:hover { FONT-FAMILY: Arial, Helvetica, sans-serif; COLOR: #FF0000; FONT-WEIGHT: bold; TEXT-DECORATION: underline
}
-->
</style>
</head>
<body>

<?


do {      // BEGIN MAIN ============================================================



$xConn=mysql_connect($host,$uid,$pwd);
mysql_select_db($db,$xConn);


# find first date recorded
$strsql="SELECT * FROM stats_day ORDER BY date LIMIT 0, 1";
if (!($result = mysql_query($strsql)))
{
  $strError0="Open Stats Database Failed<br>";
  $strError1="Error Number: ".mysql_errno().$BR;
  $strError2="Error Description: ".mysql_error.$BR;
  $strError5="Query: ".$strsql.$BR.$BR."strWhere: ".$strWhere.$BR;
  $strError0=$BR.$strError0.$strError1.$strError2.$strError5;
  echo $strError0;
  break;
}
$intTotalRecs=mysql_num_rows($result);
if (($intTotalRecs==0))
  { ?>
<P align=center><font size=5 color=red>No days recorded in database.</font><p>
<? break;
  }
$row=mysql_fetch_row($result);
$first_day=$row[0];
$ndays = diff_of_days($first_day,$today)+1;
$ndaysf = number_format($ndays);


if ($limit>$ndays) $limit=$ndays;
$start_date = date_x_days_ago($today,$limit-1);
if (($start_date < $first_day)) $start_date = $first_day;


$strsql="SELECT * FROM stats_day WHERE date >= '$start_date' ORDER BY date DESC LIMIT 0, $limit";
if (!($result = mysql_query($strsql)))
{
  $strError0="Open Stats Database Failed<br>";
  $strError1="Error Number: ".mysql_errno().$BR;
  $strError2="Error Description: ".mysql_error.$BR;
  $strError5="Query: ".$strsql.$BR.$BR."strWhere: ".$strWhere.$BR;
  $strError0=$BR.$strError0.$strError1.$strError2.$strError5;
  echo $strError0;
  break;
}
$intTotalRecs=mysql_num_rows($result);
if (($intTotalRecs==0))
  { ?>
<P align=center><font size=5 color=red>No non-zero days recorded in database within specified range.</font><p>
<P align=center><b>Hits are recorded since</b> <font color=blue><b><? echo $first_day; ?></b></font> (<? echo $ndaysf; ?> days)</p>

<? break;
  }


$x=0;
$high_hits=0;
$total_hits=0;
$high_day="";
$newest_date="";
$newest2_date="";

while(($row=mysql_fetch_row($result)))
{
  $date[$x]=$row[0];
  $hits[$x]=$row[1];
  $total_hits+=$row[1];
  if($x==0) { $newest_date = $row[0]; $newest_hits=$row[1]; }
  if($x==1) { $newest2_date = $row[0]; $newest2_hits=$row[1]+$newest_hits; }
  if($row[1]>$high_hits) { $high_hits=$row[1]; $high_day=$row[0];}
  if (!isset($low_hits)) { $low_hits=$row[1];  $low_day=$row[0]; }
  if($row[1]<$low_hits)  { $low_hits=$row[1];  $low_day=$row[0];}
  $x++;
}


$number_days=$x;



# fill in array with days that had 0 hits and therefore not recorded
$date[$x]="0000-00-00";     # create next array values to prevent error below
$hits[$x]=0;
if($number_days==$limit) {$date2=$date; $hits2=$hits;} else
{
$currentday=$today;
$currentindex=0;
for ($x=0; $x<$limit; $x++)
{
  $date2[$x]=$currentday;
  if ($date[$currentindex]==$currentday)
  {
    $hits2[$x]=$hits[$currentindex];
    $currentindex++;
  }
  else
  {
    $hits2[$x]=0;
  }
  if (!isset($low_hits)) { $low_hits=$hits2[0];  $low_day=$date2[0]; }
  if($hits2[$x]<=$low_hits)  { $low_hits=$hits2[$x];  $low_day=$date2[$x];}
  $currentday = date_x_days_ago($currentday,1);
}
}



$date=$date2;
$hits=$hits2;
$number_days=$limit;
$today = date("Y") . "-" . date("m") . "-" . date("d");


$proj_hits = 0;
$proj_hitsf = 0;
if($newest_date==$today)
{
  $mins = date("i") + date("G")*60.0;   # minutes used today
 $proj_hits = $newest_hits * (1440.0/$mins);
  if(isset($newest2_hits))
    $proj_hits = $newest_hits + ( (1440.0-$mins)*($newest2_hits/($mins+1440.0)) );
  $proj_hits = round($proj_hits);
  $proj_hitsf = number_format($proj_hits);
}
$average_hits = ($total_hits + $proj_hits - $hits2[0]) / $number_days;
$average_hits =  round($average_hits,2);
$total_hitsf   = number_format($total_hits);
$high_hitsf    = number_format($high_hits);
$low_hitsf     = number_format($low_hits);
$average_hitsf = number_format($average_hits);
if($high_hits==0) $high2=1;
else
{
  $high2=$high_hits;
  if ($proj_hits>$high2) $high2=$proj_hits;
}



?>

<div align=center><center>
<table border=0 cellpadding=10 cellspacing=0><tr><td valign=top>

<div align=center><center>
<table border=1 cellpadding=5 cellspacing=0>
<tr bgColor="#0000FF">
<th colspan=2 align=center><font color="#B9C9FF">General Statistics</font></th>
</tr>
<tr>
<td bgcolor="#B9C9FF"><b>Projected hits for today</b></td>
<td align=center><font color=red><b><? echo $proj_hitsf; ?></b></font>
</td>
</tr>
<tr>
<td bgcolor="#B9C9FF"><b>Server </b><b>date</b></td>
<td align=center><font color=blue><b><? echo $today; ?></b></font></td>
</tr>
<tr>
<td bgcolor="#B9C9FF"><b>Server time</b></td>
<td align=center><font color=blue><b><? echo $time1; ?> </b></font>(<? echo $time2; ?>)</td>
</tr>
<tr>
<td bgcolor="#B9C9FF"><b>Hits are recorded since</b></td>
<td align=center><font color=blue><b><? echo $first_day; ?></b></font> (<? echo $ndaysf; ?> days)</td>
</tr>
</table></center></div>

</td><td>

<div align=center><center>
<table border=1 cellpadding=5 cellspacing=0>
<tr bgcolor="#0000FF">
<th colspan=3 align=center><font color="#B9C9FF">Hits For Last <font color="yellow" size="+1"><? echo $number_days; ?></font> Days</font></th>
</tr>
<tr>
<td bgcolor="#B9C9FF"><b>Total</b></td>
<td colspan=2 align=center><font color=red><b><? echo $total_hitsf; ?></b></font></td>
</tr>
<tr>
<td bgcolor="#B9C9FF"><b>Average</b></td>
<td colspan=2 align=center><font color=red><b><? echo $average_hitsf; ?></b></font></td>
</tr>
<tr>
<td bgcolor="#B9C9FF"><b>Most</b></td>
<td align=right><font color=red><b><? echo $high_hitsf; ?></b></font></td>
<td align=center><font color=blue><b><? echo $high_day; ?></b></font>
</td>
</tr>
<tr>
<td bgcolor="#B9C9FF"><b>Least</b></td>
<td align=right><font color=red><b><? echo $low_hitsf; ?></b></font></td>
<td align=center><font color=blue><b><? echo $low_day; ?></b></font></td>
</tr>
</table></center></div>

</td></tr>
</table></center></div>


<?


echo "
<h1 align=center><font size=5 color=blue face=Arial>Hits graph for last $limit days</font></h1><p>
<center>

<table border=1 cellPadding=0 cellSpacing=0><tr><td bgColor=\"#EEEEEE\">
<table border=0 cellPadding=5 cellSpacing=0>

<tr bgColor=\"#B9C9FF\"><th align=center>Date</th><th align=center>Hits</th><th align=center>Graph</th></tr>
"
;

for ($x=0; $x<$number_days; $x++)           # display graph
{
$width=$bar_width * ($hits[$x] / $high2);
$width=round($width);
$hitsf = number_format($hits[$x]);
$projbar="";
if ($proj_hits>0 &amp;&amp; $x==0)
{
  $width2 = $bar_width * (($proj_hits-$hits[$x])/ $high2);
  $width2 = round($width2);
  if ($width2>0)
    $projbar = "<img src=\"$bar2_image\" border=0 width=$width2 height=$bar_height alt=\"Projected: $proj_hits\">";
}
echo "<tr>
<td>$date[$x]</td>
<td align=right><b>$hitsf</b></td>
<td><img src=\"$bar_image\" border=0 width=$width height=$bar_height>$projbar</td>
</tr>\n"
;
}

echo "\n</table><td></tr></table>\n\n</center>\n\n";



} while(0);

mysql_close();

?>

<br>

<div align=center><center>
<table border=1 cellspacing=0 cellpadding=10 bgcolor="#C0C0C0"><tr><td>
<form method="GET">
<p align=center><b>Show stats for last
<input type="text" name="last_x_days" size=5 value="<? echo $limit?>"> days.<br>
<input type="submit" value="Submit"><input type="reset" value="Reset"></b></p>
</form></td></tr>
</table></center></div>

<p>&amp;nbsp;

<p align=center><font size=2>Free Statistics - Version 1.1.0<br>
Copyright © 2003 <b><a href="http://www.free-webhosts.com/">Free Webspace</a></b> - http://www.Free-Webhosts.com<br></font>

<p>&amp;nbsp;

</body></html>