Category Archives: Validation

10+ PHP Online Code Checkers/Validators

Our PHP code checker/validator may not always be available on other computers we use besides our own. That’s why we are sharing you our collection of the best PHP Online Code Checkers/Validators you can use no matter where and no matter when. Choose your favorite!

1. PHP code checker

A completely free service that will not execute or save your code. It performs an analysis line-by-line for common mistakes and errors in your PHP syntax.

2. Write Code Online

A pretty neat little tool that lets you test your PHP (and even JavaScript) online.

3. Codepad: Quickly Check Your Code Online

It is a web based compiler which acts as a paste-bin that can execute code and point out the mistakes in it.

4. Ideone

It is something more than a pastebin; it’s an online compiler and debugging tool which allows to compile and run code online in more than 40 programming languages.

5. PHP Sandbox

Test PHP sunctions online. You can test your PHP code here on many PHP versions.

6. CodeRun Studio

A cross-platform Integrated Development Environment (IDE), designed for the cloud. It enables you to easily develop, debug and deploy web applications using your browser.

7. php.fnlist

A beta online utility for testing PHP functions where you can test PHP function online.

8. phptester.net

This application will help you test most of php functions without the need to install a web server and PHP.

9. codepad.viper-7

This one is another version of codepad. Pretty cool PHP code checker.

10. PHPLint on-line

PHP source validator and documentator.

11. Php Docbook Online Editor

Built using PHP and the phpWebApp framework. You will have to create an account on this one before you can actually use it.

12. Online PHP IDE

Edit files on your FTP server (Open Source Project).

All PHP Scripts on this website are provided by phpscripts4u.com where you can find all the latest PHP code snippets, plugins and libraries.

PHP Scripts for Php MySQL Console

phpMySQLConsole (PMC) is a web based MySQL command shell. PMC aims to be a web shell has same and more feautures and functionalites of real MySQL Shell. Integrating of PMC to any web application is very easy and dont need any firewall construction to access. Its completly http based.PMC consist of 2 important part, javascript console and PHP command interpreter. Javascript console provide a MySQL command prompt for user to type their commands with some usefull functionalities such as *nix like select-copy and command history which can be used arrow keys. Then other important part is PHP command interpeter run on server side. This is a PHP script run on PHP and MySQL supported server The script interperets commands which coming from javascript console via XMLHttp request and print out results to javascript console again XMLHttp.

 

<?
 function prepareQueryOutput($recordsArr, $titlesArr) {

 $maxLenArr = Array();

 //Calculating longest field from fields of record
 foreach ($recordsArr as $recordIndex => $recordArr)
 foreach ($recordArr as $index => $value)
 if (strlen($value) > $maxLenArr[$index])
 $maxLenArr[$index] = strlen($value);

 //Calculating longest field from fields of header
 foreach ($titlesArr as $index => $value)
 if (strlen($value) > $maxLenArr[$index])
 $maxLenArr[$index] = strlen($value);

 //Creating header output
 $line = '+';
 $title = '|';
 foreach($titlesArr as $index => $fieldName) {
 $line .= str_repeat('-', $maxLenArr[$index]+1).'-+';
 $title .= ' '.$fieldName.str_repeat(' ', $maxLenArr[$index] - strlen($fieldName)).' |';
 }

 //Creating records output
 foreach($recordsArr as $rowIndex => $rowArr) {
 $row = '|';
 foreach($rowArr as $fieldIndex => $value)
 $row .= ' '.$value.str_repeat(' ', $maxLenArr[$fieldIndex] - strlen($value)).' |';
 $rows .= $row."\n";
 }

 return $line."\n".$title."\n".$line."\n".$rows.$line."\n";
 }

 function getDatabaseConfig() {
 include('config.php');
 /*
 URL regex check:
 echo "Error: Connection URL format error, URL: ".$URL;
 */

 $URL = $DB_CONNECTION_URL;
 $dbConfig['DB_TYPE'] = substr($URL, 0, strpos($URL, '://'));
 $URL = str_replace($dbConfig['DB_TYPE'].'://', '', $URL);

 $dbConfig['DB_USERNAME'] = substr($URL, 0, strpos($URL, ':'));
 $URL = str_replace($dbConfig['DB_USERNAME'].':', '', $URL);

 $dbConfig['DB_PASSWORD'] = substr($URL, 0, strpos($URL, '@'));
 $URL = str_replace($dbConfig['DB_PASSWORD'].'@', '', $URL);

 if (strpos($URL, '/') != false) {
 $dbConfig['DB_HOST'] = substr($URL, 0, strpos($URL, '/'));
 $URL = str_replace($dbConfig['DB_HOST'].'/', '', $URL);
 $dbConfig['DB_DATABASE_NAME'] = trim($URL);
 } else {
 $dbConfig['DB_HOST'] = trim($URL);
 $dbConfig['DB_DATABASE_NAME'] = '';
 }

 if(empty($_POST['database']))
 if (!empty($dbConfig['DB_DATABASE_NAME']))
 echo "js{ SRV_DATABASE = '{$dbConfig['DB_DATABASE_NAME']}'; }js";
 return $dbConfig;
 }

 function execQuery($conn, $query) {

 if (!$conn) return;
 $start = microtime(true);
 $result = @mysql_query($query, $conn);
 if (!$result) $output = "Error ".mysql_errno().": ".mysql_error();
 $second = number_format(microtime(true) - $start, 2, '.', '');

 if ($result)
 if (@mysql_num_rows($result) > 0) {
 $recordsArr = Array();
 while (($row = mysql_fetch_assoc($result))) {
 $titlesArr = array_keys($row);
 $recordArr = array_values($row);
 array_push($recordsArr, $recordArr);
 }
 $output .= prepareQueryOutput($recordsArr, $titlesArr);
 $output .= mysql_num_rows($result).' rows in set ('.$second.' sec)';
 $output .= "\n";
 } else
 $output .= 'Affected rows number : '.mysql_affected_rows($conn);

 @mysql_free_result($result);
 return $output."\n";
 }

 function changeDatabase($conn, $cmd) {
 if (!$conn) return;
 $curDB = $_POST['database'];
 $newDB = trim(substr($cmd, strpos($cmd,' '), strlen($cmd) - strpos($cmd, ' ')));
 if ($curDB != $newDB) {
 if (!mysql_select_db($newDB, $conn))
 $output = "Error ".mysql_errno().": ".mysql_error()."\n";
 else {
 $output = "Database changed\n";
 echo "js{ SRV_DATABASE = '$newDB'; }js";
 }
 } else
 $output = "Current database is $curDB\n";
 return $output;
 }

 function getDatabaseConnection($dbConfig, $showMess = true) {

 if (get_cfg_var('mysql.allow_persistent')) {
 $conn = @mysql_pconnect($dbConfig['DB_HOST'], $dbConfig['DB_USERNAME'], $dbConfig['DB_PASSWORD']);
 if (isset($_POST['database']))
 if (!empty($_POST['database']))
 mysql_select_db($_POST['database'], $conn);

 } else {
 $conn = @mysql_connect($dbConfig['DB_HOST'], $dbConfig['DB_USERNAME'], $dbConfig['DB_PASSWORD']);
 if (isset($_POST['database']))
 if (!mysql_select_db($_POST['database'], $conn))
 $output = "Error ".mysql_errno().": ".mysql_error()."\n";
 }

 if ((!$conn) and ($showMess))
 echo "\nError ".mysql_errno().": ".mysql_error();
 return $conn;
 }

 function initialize() {

 /* Checking Mysql Persistent Connection Support */
 if (!get_cfg_var('mysql.allow_persistent')) {
 $output .= "WARNING: There is a no support for mysql persistent connections! (Check readme.txt)\n\n";
 }

 /*Checking for database configuration settings for config.php */
 $dbConfig = getDatabaseConfig();
 $dbConn = getDatabaseConnection($dbConfig, false);
 $output .= "Welcome to the phpMySQlConsole.\n";
 if (!$dbConn)
 $output .= "\nError: Couldn't connect to mysql server ! Please type <help connect> for help.\n\n";
 else $output .= "Connected to server version ".mysql_get_server_info().". Commands end with ;\n\n";
 $output .= "Type 'help;' for help.\n\n";

 return $output;
 }

 function getStatusInformationFromServer() {

 $dbConfig = getDatabaseConfig();
 mysql_connect($dbConfig['DB_HOST'], $dbConfig['DB_USERNAME'], $dbConfig['DB_PASSWORD']);

 $output .= "\n";
 $output .= "Connection id       :\n";
 $output .= "Current user        : {$dbConfig['DB_USERNAME']}\n";
 $output .= "Current database    : {$_POST['database']}\n";
 $output .= "Server version      : ".mysql_get_server_info()."\n";
 $output .= "Protocol            : ".mysql_get_proto_info()."\n";
 $output .= "Connection          : ".mysql_get_host_info()."\n";
 $output .= "Server characterset :\n";
 $output .= "Db characterset     :\n";
 $output .= "Client characterset : ".mysql_client_encoding()."\n";
 $output .= "Conn. characterset  :\n";
 $output .= "TCP port            :\n";

 $mysqlStat = explode("  ", mysql_stat());
 for ($i = 0; $i < count($mysqlStat); $i++) {
 $keyAndValue = explode(": ", $mysqlStat[$i]);
 $key = $keyAndValue[0];
 $val = $keyAndValue[1];
 $val = ($key == 'Uptime') ? date('G', $val).' hours '.date('i', $val).' minutes '.date('s', $val).' seconds ' : $val;
 $output .= $key.str_repeat(' ', 23 - strlen($key)).": ".$val."\n";
 }
 $output .= "\n";

 return $output;
 }
?>

&amp;nbsp;

PHP Scripts for URLShort

PHP URLShort script to run your own URL shortening service online like TinyURL.com. Quicker and easier URL redirection. Totally viral-No registration required. Multiple URLs shortening. Absolutely NO MYSQL configuration required.
System Requirements: UNIX/Linux Operating System, PHP Version 4.2.x or PHP V 5.x, Ability To Use and Edit .htaccess Files With Mod-Rewrite Redirect Enabled.TinyURL clone PHP script. PHP URLShort script to run your own URL shortening service online like TinyURL.com. Quicker and easier URL redirection. Totally viral-No registration required. Multiple URLs shortening. Absolutely NO MYSQL configuration required.

 

<?php
/************************************************************************
* txtSQL                                                 ver. 2.2 Final *
*************************************************************************
* A php class of functions which simulats, and acts almost like a mySQL *
* service                                                               *
*-----------------------------------------------------------------------*
* This program is free software; you can redistribute it and/or         *
* modify it under the terms of the GNU General Public License           *
* as published by the Free Software Foundation; either version 2        *
* of the License, or (at your option) any later version.                *
*                                                                       *
* This program is distributed in the hope that it will be useful,       *
* but WITHOUT ANY WARRANTY; without even the implied warranty of        *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
* GNU General Public License for more details.                          *
*                                                                       *
* You should have received a copy of the GNU General Public License     *
* along with this program; if not, write to the Free Software           *
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307 *
* USA.                                                                  *
*-----------------------------------------------------------------------*
*  NOTE- Tab size in this file: 8 spaces/tab                            *
*-----------------------------------------------------------------------*
*  ©2003 Faraz Ali, ChibiGuy Production [http://txtsql.sourceforge.net] *
*  File: txtsql.core.php                                                *
************************************************************************/

if ( !defined("TXTSQL_CORE_PATH") )
{
 define('TXTSQL_CORE_PATH', './');
}
require_once(TXTSQL_CORE_PATH.'txtSQL.core.php');

/**
 * Extracts data from a flatfile database via a limited SQL
 *
 * @package txtSQL
 * @author Faraz Ali <Faraz87@comcast.net>
 * @version 2.2 Final
 * @access public
 */

class txtSQL
{
 /**
 * If set to true, prints all errors and warnings
 * @var bool
 * @access public
 * @see strict()
 */

 var $_STRICT        = TRUE;

 /**
 * Holds the path of the txtSQL data directory
 * @var string
 * @access private
 */

 var $_LIBPATH       = NULL;

 /**
 * Holds the name of the currently logged in user
 * @var string
 * @access private
 * @see _isconnected()
 */

 var $_USER          = NULL;

 /**
 * Holds the md5() hash of the password of the currently logged in user
 * @var string
 * @access private
 * @see _isconnected()
 * @see disconnect()
 */

 var $_PASS          = NULL;

 /**
 * Contains a cache of any files that have been read to increase execution time
 * @var array
 * @access private
 * @see readFile()
 */

 var $_CACHE         = array();

 /**
 * Holds the name of the currently selected database
 * @var string
 * @access private
 * @see selectdb()
 */

 var $_SELECTEDDB    = NULL;

 /**
 * Holds the number of queries sent to txtSQL
 * @var int
 * @access private
 * @see query_count()
 */

 var $_QUERYCOUNT    = 0;

 /**
 * The constructor of the txtSQL class
 * @param string $path The path to which the databases are located
 * @return void
 * @access public
 */

 function txtSQL ($path='./data')
 {
 $this->_LIBPATH = $path;
 return TRUE;
 }

 /**
 * Connects a user to the txtSQL service
 * @param string $user The username of the user
 * @param string $pass The corressponding password of the user
 * @return void
 * @access public
 */

 function connect ($user, $pass)
 {
 /* Check to see if our data exists */
 if ( !is_dir($this->_LIBPATH) )
 {
 $this->_error(E_USER_ERROR, 'Invalid data directory specified');
 }

 /* Instantiate parser and core class */
 $this->_query            = new txtSQLCore;
 $this->_query->_LIBPATH  = $this->_LIBPATH;

 /* Read in the user/pass information */
 if ( ($DATA = $this->_readFile("$this->_LIBPATH/txtsql/txtsql.MYI")) === FALSE )
 {
 $this->_error(E_USER_WARNING, 'Database file is corrupted!');
 return FALSE;
 }
 $this->_data = $DATA;

 /* Check to see if the username exists, and for a matching password */
 if ( !isset($DATA[strtolower($user)]) || $DATA[strtolower($user)] != md5($pass) )
 {
 $this->_error(E_USER_NOTICE, 'Access denied for user \''.$user.'\' (using password: '.(!empty($pass)?'yes':'no').')');
 return FALSE;
 }

 $this->_USER = $user;
 $this->_PASS = $pass;
 return TRUE;
 }

 /**
 * Disconnects a user from the txtSQL Service
 * @return void
 * @access public
 */

 function disconnect ()
 {
 /* Check to see that we are already connected */
 if( !$this->_isconnected() )
 {
 $this->_error(E_USER_NOTICE, 'Can only disconnect when connected!');
 return FALSE;
 }

 /* Unset user, pass variables
 * Then remove the core executer object and the parser object
 * And finally return */

 unset($this->_USER, $this->_PASS, $this->_query);
 return TRUE;
 }

 /**
 * Selects rows of information from a selected database and a table
 * that fits the given 'where' clause
 * @param mixed $arguments The arguments in form of "[$key] => $value"
 *                         where $key can be 'db', 'table', 'select', 'where', 'limit'
 *                         and 'orderby'
 * @return mixed $results An array that txtSQL returns that matches the given criteria
 * @access public
 */

 function select ($arguments)
 {
 /* Check for a connection, and valid arguments */
 $this->_validate($arguments);
 $this->_QUERYCOUNT++;

 return $this->_query->select($arguments);
 }

 /**
 * Inserts a new row into a table with the given information
 * @param mixed $arguments The arguments in form of "[$key] => $value"
 *                         where $key can be 'db', 'table', 'values'
 * @return int $inserted The number of rows inserted into the table
 * @access public
 */

 function insert ($arguments)
 {
 /* Check for a connection, and valid arguments */
 $this->_validate($arguments);
 $this->_QUERYCOUNT++;

 return $this->_query->insert($arguments);
 }

 /**
 * Updates a row that matches a 'where' clause, with new information
 * @param mixed $arguments The arguments in form of "[$key] => $value"
 *                         where $key can be 'db', 'table', 'where', 'limit',
 *                         and 'values'
 * @return int $inserted The number of rows updated
 * @access public
 */

 function update ($arguments)
 {
 /* Check for a connection, and valid arguments */
 $this->_validate($arguments);
 $this->_QUERYCOUNT++;

 return $this->_query->update($arguments);
 }

 /**
 * Deletes a row from a table that matches a 'where' clause
 * @param mixed $arguments The arguments in form of "[$key] => $value"
 *                         where $key can be 'db', 'table', 'where', 'limit'
 * @return int $inserted The number of rows deleted
 * @access public
 */

 function delete ($arguments)
 {
 /* Check for a connection, and valid arguments */
 $this->_validate($arguments);
 $this->_QUERYCOUNT++;

 return $this->_query->delete($arguments);
 }

 /**
 * Returns a list containing the current valid txtSQL databases
 * @return mixed $databases A list containing the databases
 * @access public
 */

 function showdbs ()
 {
 /* Check for a connection, and valid arguments */
 $this->_validate(array());
 $this->_QUERYCOUNT++;

 return $this->_query->showdatabases();
 }

 /**
 * Creates a new database
 * @param mixed $arguments The arguments in form of "[$key] => $value"
 *                         where $key can be 'db'
 * @return void
 * @access public
 */

 function createdb ($arguments)
 {
 /* Check for a connection, and valid arguments */
 $this->_validate($arguments);
 $this->_QUERYCOUNT++;

 return $this->_query->createdatabase($arguments);
 }

 /**
 * Drops a database
 * @param mixed $arguments The arguments in form of "[$key] => $value"
 *                         where $key can be 'db'
 * @return void
 * @access public
 */

 function dropdb ($arguments)
 {
 /* Check for a connection, and valid arguments */
 $this->_validate($arguments);
 $this->_QUERYCOUNT++;

 return $this->_query->dropdatabase($arguments);
 }

 /**
 * Renames a database
 * @param mixed $arguments The arguments in form of "[old db name], [new db name]"
 * @return void
 * @access public
 */

 function renamedb ($arguments)
 {
 /* Check for a connection, and valid arguments */
 $this->_validate($arguments);
 $this->_QUERYCOUNT++;

 return $this->_query->renamedatabase($arguments);
 }

 /**
 * Returns an array containing a list of tables inside of a database
 * @param mixed $arguments The arguments in form of "[$key] => $value"
 *                         where $key can be 'db'
 * @return mixed $tables   An array with a list of tables
 * @access public
 */

 function showtables ($arguments)
 {
 /* Check for a connection, and valid arguments */
 $this->_validate($arguments);
 $this->_QUERYCOUNT++;

 return $this->_query->showtables($arguments);
 }

 /**
 * Creates a new table with the given criteria inside a database
 * @param mixed $arguments The arguments in form of "[$key] => $value"
 *                         where $key can be 'db', 'table', 'columns'
 * @return int $deleted The number of rows deleted
 * @access public
 */

 function createtable ($arguments)
 {
 /* Check for a connection, and valid arguments */
 $this->_validate($arguments);
 $this->_QUERYCOUNT++;

 return $this->_query->createtable($arguments);
 }

 /**
 * Drops a table from a database
 * @param mixed $arguments The arguments in form of "[$key] => $value"
 *                         where $key can be 'db', 'table'
 * @return void
 * @access public
 */

 function droptable ($arguments)
 {
 /* Check for a connection, and valid arguments */
 $this->_validate($arguments);
 $this->_QUERYCOUNT++;

 return $this->_query->droptable($arguments);
 }

 /**
 * Alters a database by working with its columns
 * @param mixed $arguments The arguments in form of "[$key] => $value"
 *                         where $key can be 'db', 'table', 'action',
 *                         'name', and 'values'
 * @return void
 * @access public
 */

 function altertable ($arguments)
 {
 /* Check for a connection, and valid arguments */
 $this->_validate($arguments);
 $this->_QUERYCOUNT++;

 return $this->_query->altertable($arguments);
 }

 /**
 * Returns a description of a table using an array
 * @param mixed $arguments The arguments in form of "[$key] => $value"
 *                         where $key can be 'db', 'table'
 * @return int $columns An array with the description of a table
 * @access public
 */

 function describe ($arguments)
 {
 /* Check for a connection, and valid arguments */
 $this->_validate($arguments);
 $this->_QUERYCOUNT++;

 return $this->_query->describe($arguments);
 }

 /**
 * Checks for a connection, and valid arguments
 * @param mixed $arguments The arguments to validify
 * @return void
 * @access private
 */

 function _validate ($arguments)
 {
 /* Check to see user is connected */
 if ( !$this->_isconnected() )
 {
 $this->_error(E_USER_NOTICE, 'Can only perform queries when connected!');
 return FALSE;
 }

 /* Arguments have to be inside of an array */
 if ( !empty($arguments) &amp;&amp; !is_array($arguments) )
 {
 $this->_error(E_USER_ERROR, 'txtSQL can only accept arguments in an array');
 }

 return TRUE;
 }

 /**
 * Evaluates a query with manually inputted arguments.
 * The $action can be either 'show databases', 'create databases', 'drop database', 'rename database'
 * 'show tables', 'create table', 'drop table', 'alter table', 'describe', 'select', 'insert', 'delete',
 * and 'insert'. See the readme for more information.
 *
 * @param string $action The command txtSQL is to perform
 * @param mixed $arguments The arguments in form of "[$key] => $value"
 * @return mixed $results The results that txtSQL returned
 * @access public
 */

 function execute ($action, $arguments = NULL)
 {
 /* Check to see user is connected */
 if ( !$this->_isconnected() )
 {
 $this->_error(E_USER_NOTICE, 'Can only perform queries when connected!');
 return FALSE;
 }

 /* If there is no action */
 if ( empty($action) )
 {
 $this->_error(E_USER_NOTICE, 'You have an error in your txtSQL query');
 return FALSE;
 }

 /* Arguments have to be inside of an array */
 if ( !empty($arguments) &amp;&amp; !is_array($arguments) )
 {
 $this->_error(E_USER_ERROR, 'txtSQL Can only accept arguments in an array');
 }

 /* Depending on what type of action it is, then perform right query */
 switch ( strtolower($action) )
 {
 /* ----- Database Related ----- */
 case 'show databases':
 $results = $this->_query->showdatabases();
 break;
 case 'create database':
 $results = $this->_query->createdatabase($arguments);
 break;
 case 'drop database':
 $results = $this->_query->dropdatabase($arguments);
 break;
 case 'rename database':
 $results = $this->_query->renamedatabase($arguments);
 break;

 /* ----- Table Related ----- */
 case 'show tables':
 $results = $this->_query->showtables($arguments);
 break;
 case 'create table':
 $results = $this->_query->createtable($arguments);
 break;
 case 'drop table':
 $results = $this->_query->droptable($arguments);
 break;
 case 'alter table':
 $results = $this->_query->altertable($arguments);
 break;
 case 'describe':
 $results = $this->_query->describe($arguments);
 break;

 /* ----- Main functions ----- */
 case 'select':
 $results = $this->_query->select($arguments);
 break;
 case 'insert':
 $results = $this->_query->insert($arguments);
 break;
 case 'update':
 $results = $this->_query->update($arguments);
 break;
 case 'delete':
 $results = $this->_query->delete($arguments);
 break;

 default:
 $this->_error(E_USER_NOTICE, 'Unknown action: '.$action);
 return FALSE;
 }

 /* Return whatever results we got back */
 $this->_QUERYCOUNT++;
 return isset($results) ? $results : '';
 }

 /**
 * Turns strict property of txtSQL off/on
 * @param bool $strict The value of the strict property
 * @return void
 * @access public
 */

 function strict ($strict = FALSE)
 {
 $strict        = (bool) $strict;
 $this->_STRICT = $strict;

 if ( $this->_isconnected() )
 {
 $this->_query->strict($strict);
 }
 return TRUE;
 }

 /**
 * To set username and/or passwords, or create/delete users
 * @param string $action The action to perform (add, drop, edit)
 * @param string $user The username to be added/modified
 * @param string $pass The password of the username
 * @param string $pass1 The new password of the username (optional if editing)
 * @return void
 * @access public
 */

 function grant_permissions($action, $user, $pass = NULL, $pass1 = NULL)
 {
 /* Are we connected? */
 if ( !$this->_isconnected() )
 {
 $this->_error(E_USER_NOTICE, 'Not connected');
 return FALSE;
 }

 /* Can only work with strings */
 if ( !is_string($action) || !is_string($user) || (!empty($pass) &amp;&amp; !is_string($pass)) || (!empty($pass1) &amp;&amp; !is_string($pass1)) )
 {
 $this->_error(E_USER_NOTICE, 'The arguments must be a string');
 return FALSE;
 }

 /* Read in user database */
 if ( ($DATA = $this->_readFile("$this->_LIBPATH/txtsql/txtsql.MYI")) === FALSE )
 {
 $this->_error(E_USER_WARNING, 'Database file is corrupted!');
 return FALSE;
 }

 /* Need a username */
 if ( empty($user) )
 {
 $this->_error(E_USER_NOTICE, 'Forgot to input username');
 return FALSE;
 }

 /* Perform the correct operation */
 switch ( strtolower($action) )
 {
 case 'add':
 if ( isset($DATA[strtolower($user)]) )
 {
 $this->_error(E_USER_NOTICE, 'User already exists');
 return FALSE;
 }
 $DATA[strtolower($user)] = md5($pass);
 break;
 case 'drop':
 if ( strtolower($user) == strtolower($this->_USER) )
 {
 $this->_error(E_USER_NOTICE, 'Can\'t drop yourself');
 return FALSE;
 }
 elseif ( strtolower($user) == 'root' )
 {
 $this->_error(E_USER_NOTICE, 'Can\'t drop user root');
 return FALSE;
 }
 elseif ( !isset($DATA[strtolower($user)]) )
 {
 $this->_error(E_USER_NOTICE, 'User doesn\'t exist');
 return FALSE;
 }
 elseif ( md5($pass) != $DATA[strtolower($user)] )
 {
 $this->_error(E_USER_NOTICE, 'Incorrect password');
 return FALSE;
 }
 unset($DATA[strtolower($user)]);
 break;
 case 'edit':
 if ( !isset($DATA[strtolower($user)]) )
 {
 $this->_error(E_USER_NOTICE, 'User doesn\'t exist');
 return FALSE;
 }
 if ( md5($pass) != $DATA[strtolower($user)] )
 {
 $this->_error(E_USER_NOTICE, 'Incorrect password');
 return FALSE;
 }
 $DATA[strtolower($user)] = md5($pass1);
 break;
 default: $this->_error(E_USER_NOTICE, 'Invalid action specified');
 return FALSE;
 }

 /* Save the new information */
 $fp = @fopen("$this->_LIBPATH/txtsql/txtsql.MYI", 'w') or $this->_error(E_USER_FATAL,  "Couldn't open $this->_LIBPATH/txtsql/txtsql.MYI for writing");
 @flock($fp, LOCK_EX);
 @fwrite($fp, serialize($DATA))                   or $this->_error(E_USER_FATAL,  "Couldn't write to $this->_LIBPATH/txtsql/txtsql.MYI");
 @flock($fp, LOCK_UN);
 @fclose($fp)                                     or $this->_error(E_USER_NOTICE, "Error closing $this->_LIBPATH/txtsql/txtsql.MYI");

 /* Save it in the cache */
 $this->_CACHE["$this->_LIBPATH/txtsql/txtsql.MYI"] = $DATA;
 return TRUE;
 }

 /**
 * Returns an array filled with a list of current txtSQL users
 * @return mixed $users
 * @access public
 */

 function getUsers ()
 {
 /* Are we connected? */
 if ( !$this->_isconnected() )
 {
 $this->_error(E_USER_NOTICE, 'Not connected');
 return FALSE;
 }

 /* Read in user database */
 if ( ($DATA = $this->_readFile("$this->_LIBPATH/txtsql/txtsql.MYI")) === FALSE )
 {
 $this->_error(E_USER_WARNING, 'Database file is corrupted!');
 return FALSE;
 }

 $users = array();
 foreach ( $DATA as $key => $value )
 {
 $users[] = $key;
 }
 return $users;
 }

 /**
 * Check whether a database is locked or not
 * @param string $db The database to check
 * @return bool $locked Whether it is locked or not
 * @access public
 */

 function isLocked ($db)
 {
 if ( !$this->_dbexist($db) )
 {
 $this->_error(E_USER_NOTICE, 'Database '.$db.' doesn\'t exist');
 return FALSE;
 }
 return is_file("$this->_LIBPATH/$db/txtsql.lock") ? TRUE : FALSE;
 }

 /**
 * To put a file lock on the database
 * @param string $db The database to have a file lock placed on
 * @return void
 * @access public
 */

 function lockdb ($db)
 {
 /* Make sure that the user is connected */
 if ( !$this->_isConnected() )
 {
 $this->_error(E_USER_NOTICE, 'You must be connected');
 return FALSE;
 }
 elseif ( $this->isLocked($db) )
 {
 $this->_error(E_USER_NOTICE, 'Lock for database '.$db.' already exists');
 return FALSE;
 }

 $fp = fopen("$this->_LIBPATH/$db/txtsql.lock", 'a') or $this->_error(E_USER_ERROR, 'Err1or creating a lock for database '.$db);
 fclose($fp) or $this->_error(E_USER_ERROR, 'Error creating a lock for database '.$db);

 return TRUE;
 }

 /**
 * To remove a file lock from the database
 * @param string $db The database to have a file lock removed from
 * @return void
 * @access public
 */

 function unlockdb ($db)
 {
 /* Make sure that the user is connected */
 if ( !$this->_isConnected() )
 {
 $this->_error(E_USER_NOTICE, 'You must be connected');
 return FALSE;
 }
 elseif ( !$this->isLocked($db) )
 {
 $this->_error(E_USER_NOTICE, 'Lock for database '.$db.' doesn\'t exist');
 return FALSE;
 }

 if ( !@unlink("$this->_LIBPATH/$db/txtsql.lock") )
 {
 $this->_error(E_USER_ERROR, 'Error removing lock for database '.$db);
 }
 return TRUE;
 }

 /**
 * To select a database for txtsql to use as a default
 * @param string $db The name of the database that is to be selected
 * @return void
 * @access public
 */

 function selectdb ($db)
 {
 /* Valid db name? */
 if ( empty($db) )
 {
 $this->_error(E_USER_NOTICE, 'Cannot select database '.$db);
 return FALSE;
 }

 /* Does it exist? */
 if ( !$this->_dbexist($db) )
 {
 $this->_error(E_USER_NOTICE, 'Database '.$db.' doesn\'t exist');
 return FALSE;
 }

 /* Select the database */
 $this->_SELECTEDDB = $db;
 $this->_query->_SELECTEDDB = $db;
 return TRUE;
 }

 /**
 * An alias (but public) of the private function _tableexist()
 * @param $table Table to be checked for existence
 * @param $db The database the table is in
 * @return bool Whether it exists or not
 */

 function table_exists ($table, $db)
 {
 return $this->_tableexist($table, $db);
 }

 /**
 * An alias (public) of the private function _dbexist()
 * @param $table DB to be checked for existence
 * @return bool Whether it exists or not
 */

 function db_exists ($db)
 {
 return $this->_dbexist($db);
 }

 /**
 * To retrieve the number of records inside of a table
 * @param string $table The name of the table
 * @param string $database The database the table is inside of (optional)
 * @return int $count The number of records in the table
 * @access public
 */

 function table_count ($table, $database=NULL)
 {
 /* Inside of another database? */
 if ( !empty($database) )
 {
 if ( !$this->selectdb($database) )
 {
 return FALSE;
 }
 }

 /* No database or no table specified means that we stop here */
 if ( empty($this->_SELECTEDDB) || empty($table) )
 {
 $this->_error(E_USER_NOTICE, 'No database selected');
 return FALSE;
 }

 /* Does table exist? */
 $filename = "$this->_LIBPATH/$this->_SELECTEDDB/$table";
 if ( !is_file($filename.'.MYD') || !is_file($filename.'.FRM') )
 {
 $this->_error(E_USER_NOTICE, 'Table '.$table.' doesn\'t exist');
 return FALSE;
 }

 /* Read in the table's records */
 if ( ($rows = @file($filename.'.MYD')) === FALSE )
 {
 $this->_error(E_USER_NOTICE, 'Table '.$table.' doesn\'t exist');
 return FALSE;
 }
 $count = substr($rows[0], 2, strpos($rows[0], '{') - 3);

 /* Return the count */
 return $count;
 }

 /**
 * To retrieve the last ID generated by an auto_increment field in a table
 * @param string $table The name of the table
 * @param string $db The database the table is inside of (optional)
 * @return string $column Get the last ID generated by this column instead of the priamry key (optional)
 * @access public
 */

 function last_insert_id( $table, $db = '', $column = '' )
 {
 /* Select a database if one is given */
 if ( !empty($db) )
 {
 if ( !$this->selectdb($db) )
 {
 return FALSE;
 }
 }

 /* Check for a selected database */
 if ( empty($this->_SELECTEDDB) )
 {
 $this->_error(E_USER_NOTICE, 'No database selected');
 return FALSE;
 }

 /* Read in the column definitions */
 if ( ( $cols = $this->_readFile("$this->_LIBPATH/$this->_SELECTEDDB/$table.FRM") ) === FALSE )
 {
 $this->_error(E_USER_NOTICE, 'Table "'.$table.'" doesn\'t exist');
 return FALSE;
 }

 /* Check for a valid column that is auto_increment */
 if ( !empty($column) )
 {
 if ( $this->_getColPos($column, $cols) === FALSE )
 {
 $this->_error(E_USER_NOTICE, 'Column '.$column.' doesn\'t exist');
 return FALSE;
 }
 elseif ( $cols[$column]['auto_increment'] != 1 )
 {
 $this->_error(E_USER_NOTICE, 'Column '.$column.' is not an auto_increment field');
 return FALSE;
 }

 $cols['primary'] = $column;
 }

 /* If we are using the primary key, make sure it exists */
 elseif ( empty($cols['primary']) &amp;&amp; empty($column) )
 {
 $this->_error(E_USER_NOTICE, 'There is no primary key defined for table "'.$table.'"');
 return FALSE;
 }

 return $cols[$cols['primary']]['autocount'];
 }

 /**
 * To return the number of queries sent to txtSQL
 * @return int $_QUERYCOUNT
 * @access public
 */

 function query_count()
 {
 return $this->_QUERYCOUNT;
 }

 /**
 * To print the last error that occurred
 * @return void
 * @access public
 */

 function last_error()
 {
 if ( !empty($this->_query->_ERRORS) )
 {
 print '<pre>'.$this->_query->_ERRORSPLAIN[count($this->_query->_ERRORS)-1].'</pre>';
 }
 elseif ( !empty($this->_ERRORS) )
 {
 print '<pre>'.$this->_ERRORSPLAIN[count($this->_ERRORS)-1].'</pre>';
 }
 }

 /**
 * To return the last error that occurred
 * @return string $error The last error
 * @access public
 */

 function get_last_error()
 {
 if ( !empty($this->_query->_ERRORS) )
 {
 return $this->_query->_ERRORSPLAIN[count($this->_query->_ERRORS)-1];
 }
 elseif ( !empty($this->_ERRORS) )
 {
 return $this->_ERRORSPLAIN[count($this->_ERRORS)-1];
 }
 }

 /**
 * To print any errors that occurred during script execution so far
 * @return void
 * @access public
 */

 function errordump()
 {
 /* No errors? */
 if ( empty($this->_ERRORS) &amp;&amp; empty($this->_query->_ERRORS) )
 {
 echo 'No errors occurred during script execution';
 return TRUE;
 }

 /* Errors during this part of script */
 if ( !empty($this->_ERRORS) )
 {
 foreach ( $this->_ERRORS as $key => $value )
 {
 echo 'ERROR #['.$key.'] '.$value;
 }
 }

 /* Errors during query execution portion */
 elseif ( !empty($this->_query->_ERRORS) )
 {
 foreach ( $this->_query->_ERRORS as $key => $value )
 {
 echo 'ERROR #['.$key.'] '.$value;
 }
 }

 return TRUE;
 }

 /**
 * Removes any cache that is being stored
 * @return void
 * @access public
 */

 function emptyCache()
 {
 $this->_CACHE = array();
 return TRUE;
 }

 // PRIVATE FUNCTIONS //////////////////////////////////////////////////////////////////////////////////////
 /**
 * To retrieve the number of records inside of a table
 * @param int $errno The error type (number form)
 * @param string $errstr The error message that will be shown
 * @param string $errtype Prints this string before the message
 * @return void
 * @access private
 */

 function _error ($errno, $errstr, $errtype=NULL)
 {
 /* If this error is not an internal error, then generate a backtrace
 * to the line that originally caused the error */

 $backtrace = array_reverse(@debug_backtrace());
 $errfile   = $backtrace[0]['file'];
 $errline   = $backtrace[0]['line'];

 /* Determine what kind of error this is, so we can display it. */
 switch ($errno)
 {
 case E_USER_ERROR:
 $type = 'Fatal Error';
 break;
 case E_USER_NOTICE:
 $type = "Warning";
 break;
 default:
 $type = "Error";
 break;
 }
 $type = isset($errtype) ? $errtype : $type;

 /* Print the message to the screen, if strict is on */
 $this->_ERRORSPLAIN[] = $errstr;
 $errormsg = "<BR />\n<B>txtSQL $type:</B> $errstr in <B>$errfile</B> on line <B>$errline</B>\n<BR /></DIV>";
 $this->_ERRORS[] = $errormsg;
 if ( $this->_STRICT === TRUE )
 {
 echo $errormsg;
 }

 /* If this is a fatal error, then we are forced to exit and stop execution */
 if ( $errno == E_USER_ERROR )
 {
 exit;
 }
 return TRUE;
 }

 /**
 * To Read a file into a string and return it
 * @param string $filename The path to the file needed to be opened
 * @param bool $useCache Whether to save/retrieve this file from a cache
 * @param bool $unserialize Whether to unserialize the string or not
 * @return string $contents The file's contents
 * @access private
 */

 function _readFile ( $filename, $useCache = TRUE, $unserialize = TRUE )
 {
 if ( is_file($filename) )
 {
 if ( $useCache === TRUE )
 {
 if ( isset($this->_CACHE[$filename]) )
 {
 return $this->_CACHE[$filename];
 }
 }

 if ( ( $contents = @implode('', @file($filename)) ) !== FALSE )
 {
 if ( $unserialize === TRUE )
 {
 if ( ( $contents = @unserialize($contents) ) === FALSE )
 {
 return FALSE;
 }
 }

 if ( $useCache === TRUE )
 {
 $this->_CACHE[$filename] = $contents;
 }
 return $contents;
 }
 }
 return FALSE;
 }

 /**
 * Check to see whether a user is connected or not
 * @return bool $connected Whether the user is connected or not
 * @access private
 */

 function _isconnected ()
 {
 /* If either one of the user or pass vars are empty, then return false; */
 if ( empty($this->_USER) )
 {
 return FALSE;
 }

 /* Are we authenticated? */
 if ( $this->_data[strtolower($this->_USER)] != md5($this->_PASS) )
 {
 return FALSE;
 }
 return TRUE;
 }

 /**
 * To check whether a database exists or not
 * @param string $db The name of the database
 * @return bool Whether the db exists or not
 * @access private
 */

 function _dbexist ($db)
 {
 return is_dir("$this->_LIBPATH/$db") ? TRUE : FALSE;
 }

 /**
 * To check whether a table exists or not
 * @param string $table The name of the table
 * @param string $db The name of the database the table is in
 * @return bool Whether the db exists or not
 * @access private
 */

 function _tableexist ($table, $db)
 {
 /* Check to see if the database exists */
 if ( !empty($db) )
 {
 if ( !$this->selectdb($db) )
 {
 $this->_error(E_USER_NOTICE, 'Database, \''.$db.'\', doesn\'t exist');
 return FALSE;
 }
 }

 /* Check to see if the table exists */
 $filename = "$this->_LIBPATH/$this->_SELECTEDDB/$table";

 if ( is_file($filename.'.MYD') &amp;&amp; is_file($filename.'.FRM') )
 {
 return TRUE;
 }
 return FALSE;
 }

 /**
 * To build an if-statement which can be used to see if a row
 * fits the given credentials
 * @param mixed $where The array containing the where clause
 * @param mixed $cols The array containing the column definitions
 * @return string $query The string which contains the php-equivelent to the where clause
 * @access private
 */

 function _buildIf ($where, $cols)
 {
 /* We can only work with a string containing where */
 if ( !is_array($where) || empty($where) )
 {
 $this->_error(E_USER_NOTICE, 'Where clause must be an array');
 return FALSE;
 }
 $query = '';

 /* Start creating the query */
 foreach ( $where as $key => $value )
 {
 /* Are we on an 'and|or'? */
 if ( $key % 2 == 1 )
 {
 /* Check for a valid "and|or" */
 $and = strtolower($value) == 'and';
 $or  = strtolower($value) == 'or';
 $xor = strtolower($value) == 'xor';
 if ( $and === FALSE &amp;&amp; $or === FALSE &amp;&amp; $xor === FALSE )
 {
 $this->_error(E_USER_NOTICE, 'Only boolean seperators AND, and OR are allowed');
 return FALSE;
 }
 $query .= ( $and === TRUE ) ? ' &amp;&amp; ' : ( ( $xor === TRUE ) ? ' XOR ' : ' || ' );
 continue;
 }

 /* Find out which operator we are going to use to create the if
 * NOTE: I'm pretty sure the order in which these operators are checked
 *       are correct. If anyone notices a bug in the order, let me know*/

 $f1 = '(';
 $f2 = ') ';
 switch ( TRUE )
 {
 case strpos($value, '!='): $type = 1; $op = '!='; break;
 case strpos($value, '!~'): $type = 3; $op = '!~'; break;
 case strpos($value, '=~'): $type = 3; $op = '=~'; break;
 case strpos($value, '<='): $type = 2; $op = '<='; break;
 case strpos($value, '>='): $type = 2; $op = '>='; break;
 case strpos($value, '=' ): $type = 1; $op = '=';  break;
 case strpos($value, '<>'): $type = 1; $op = '<>'; break;
 case strpos($value, '<' ): $type = 2; $op = '<';  break;
 case strpos($value, '>' ): $type = 2; $op = '>';  break;
 case strpos($value, '!?'): $type = 5; $op = '!?'; break;
 case strpos($value, '?' ): $type = 5; $op = '?';  break;
 default:
 /* Check for a valid function that requires no operator */
 $val = 'TRUE';
 if ( substr(trim($value), 0, 1) == '!' )
 {
 $val   = 'FALSE';
 $value = substr($value, strpos($value, '!')+1);
 }

 $function = substr($value, 0, strpos($value, '('));
 $col      = substr($value, strlen($function) + 1, strlen($value) - strlen($function) - 2 );

 if ( $function !== FALSE )
 {
 $type = 4;
 $op   = '===';
 switch ( strtolower($function) )
 {
 case 'isnumeric':  $f1 = 'is_numeric('; break 2;
 case 'isstring':   $f1 = 'is_string('; break 2;
 case 'isfile':     $f1 = 'is_file('; break 2;
 case 'isdir':      $f1 = 'is_dir('; break 2;
 case 'iswritable': $f1 = 'is_writable(';  break 2;
 }
 }

 /* There is an error in your where clause */
 $this->_error(E_USER_NOTICE, 'You have an error in your where clause, (operators allowed: =, !=, <>, =~, !~, <, >, <=, >=)'); return FALSE;
 }

 /* Split string by the proper operator, as long as there is an operator */
 if ( !isset($function) )
 {
 list ( $col, $val ) = explode($op, $value, 2);
 }

 /* Check to see if we are utilizing a function */
 if ( substr_count($col, '(') == 1 &amp;&amp; substr_count($col, ')') == 1 )
 {
 $function = substr($col, 0, strpos($col, '('));

 if ( $val != '' &amp;&amp; $col{strlen($col)-1}.$val{0} == "  " )
 {
 $col  = substr($col, strlen($function) + 1, strlen($col) - strlen($function) - ( ($col{strlen($col)-1} != " " ) ? 2 : 3 ) )." ";
 $val  = $val;
 }
 else
 {
 $col = substr($col, strlen($function) + 1, strlen($col) - strlen($function) - ( ($col{strlen($col)-1} != " " ) ? 2 : 3 ) );
 }

 /* Check for a valid function call */
 switch ( strtolower($function) )
 {
 case 'strlower':   $f1 = 'strtolower(';         break;
 case 'strupper':   $f1 = 'strtoupper(';         break;
 case 'chop':
 case 'rtrim':      $f1 = 'rtrim(';              break;
 case 'ltrim':      $f1 = 'ltrim(';              break;
 case 'trim':       $f1 = 'trim(';               break;
 case 'md5':        $f1 = 'md5(';                break;
 case 'stripslash': $f1 = 'stripslashes(';       break;
 case 'strlength':  $f1 = 'strlen(';             break;
 case 'strreverse': $f1 = 'strrev(';             break;
 case 'ucfirst':    $f1 = 'ucfirst(';            break;
 case 'ucwords':    $f1 = 'ucwords(';            break;
 case 'bin2hex':    $f1 = 'bin2hex(';            break;
 case 'entdecode':  $f1 = 'html_entity_decode('; break;
 case 'entencode':  $f1 = 'htmlentities(';       break;
 case 'soundex':    $f1 = 'soundex(';            break;
 case 'ceil':       $f1 = 'ceil(';               break;
 case 'floor':      $f1 = 'floor(';              break;
 case 'round':      $f1 = 'round(';              break;

 /* These are functions that should NOT have an operator */
 case 'isnumeric':
 case 'isstring':
 case 'isfile':
 case 'isdir':
 $this->_error(E_USER_NOTICE, 'Function, '.$function.', requires that NO operator be present in the clause');
 return FALSE;

 default:
 $this->_error(E_USER_NOTICE, 'Function, '.$function.', hasn\'t been implemented');
 return FALSE;
 }
 }

 /* What if the column name is primary? */
 if ( strtolower(trim($col)) == 'primary' )
 {
 /* Make sure there is a primary key */
 if ( empty($cols['primary']) )
 {
 $this->_error(E_USER_NOTICE, 'No primary key has been assigned to this table');
 return FALSE;
 }
 $col = $cols['primary'];
 }

 /* Does the specified column exist? */
 if ( ( $position = $this->_getColPos(rtrim($col), $cols) ) === FALSE )
 {
 $this->_error(E_USER_NOTICE, 'Column \''.rtrim($col).'\' doesn\'t exist');
 return FALSE;
 }

 /* Create/Add-To the queries */
 $val = str_replace("\'", "'", addslashes($val));
 $val = ( $col{strlen($col)-1}.$val{0} == "  " ) ? substr($val, 1) : $val;

 if ( empty($val) &amp;&amp; ( $type == '5' || $f1 != '(' ) )
 {
 $this->_error(E_USER_NOTICE, 'Forgot to specify a value to match in your where clause');
 return FALSE;
 }

 switch ( $type )
 {
 /* Test for equality */
 case 1:
 case 2: $quotes = ( !is_numeric($val) || $cols[rtrim($col)]['type'] != 'int' ) ? '"' : '';
 $query .= ' ( '.$f1.'$value['.$position.']'.$f2.' '.( $op == '=' ? '==' : $op ).' '.$quotes.$val.$quotes.' ) ';
 break;

 /* Test using regex, with[out] a function */
 case 3:    $val    = str_replace(array('(',   ')',  '{',  '}', '.',  '$',  '/',       '\%',  '*',     '%', '$$PERC$$'),
 array('\(', '\)', '\{', '\}', '\.', '\$', '\/', '$$PERC$$', '\*', '(.+)?',       '%'), $val);
 $query .= ' ( '.($op == '!~' ? '!' : '').'preg_match("/^'.$val.'$/iU", '.$f1.'$value['.$position.']'.$f2.') ) ';
 break;

 /* Test involving a function */
 case 4: $query .= ' ( '.$f1.'$value['.$position.']'.$f2.' === '.$val.' ) ';
 break;

 /* Test involving a strpos with[out] function */
 case 5: $query .= ' ( strpos('.$f1.'\' \'.$value['.$position.']), \''.$val.'\') '.(($op == '!?') ? '=' : '!' ).'== FALSE ) ';
 }
 unset($function, $f1, $f2, $quotes, $position, $val, $col, $op);
 }

 /* Make sure that we have a valid query ending */
 $andor = substr($query, -3, -1);
 if ( $andor == '&amp;&amp;' || $andor == '||' || $andor == 'OR' )
 {
 $this->_error(E_USER_NOTICE, 'You have an error in your where clause, cannot end statement with an AND, OR, or XOR');
 return FALSE;
 }
 return $query;
 }

 /**
 * To retrieve the index of the column from the columns' array
 * @param string $colname The name of the column to be searched for
 * @param mixed $cols The column definitions array
 * @return int $position The index of the column in the array
 * @access private
 */

 function _getColPos ($colname, $cols)
 {
 /* Make sure array is not empty, and the parameter is an array */
 if ( empty($cols) || !is_array($cols) || !array_key_exists($colname, $cols) )
 {
 return FALSE;
 }
 unset($cols['primary']);

 /* Get the index for the column */
 if ( ( $position = array_search($colname, array_keys($cols)) ) === FALSE )
 {
 return FALSE;
 }
 return $position;
 }

 /**
 * To sort a multi-dimensional array by a key
 * @author fmmarzoa@gmx.net <fmmarzoa@gmx.net>
 * @param mixed $array The array to be sorted
 * @param string $num The name of the key to sort the array by
 * @return string $order Either a 'ASC' or 'DESC' for sorting order
 * @access private
 */

 function _qsort($array, $num = 0, $order = "ASC", $left = 0, $right = -1)
 {
 if ( count($array) >= 1 )
 {
 if ( $right == -1 )
 {
 $right = count($array) - 1;
 }

 $links  = $left;
 $rechts = $right;
 $mitte  = $array[($left + $right) / 2][$num];
 if ( $rechts > $links )
 {

 do {
 if ( strtolower($order) == 'asc' )
 {
 while ( $array[$links][$num] < $mitte )
 {
 $links++;
 }
 while ( $array[$rechts][$num] > $mitte )
 {
 $rechts--;
 }
 }
 else
 {
 while ( $array[$links][$num] > $mitte )
 {
 $links++;
 }
 while ( $array[$rechts][$num] < $mitte)
 {
 $rechts--;
 }
 }

 if ( $links <= $rechts )
 {
 $tmp              = $array[$links];
 $array[$links++]  = $array[$rechts];
 $array[$rechts--] = $tmp;
 }

 }
 while ( $links <= $rechts );

 if ( $left < $rechts )
 {
 $array = $this->_qsort($array,$num,$order,$left, $rechts);
 }
 if ( $links < $right )
 {
 $array = $this->_qsort($array,$num,$order,$links,$right);
 }
 }
 return $array;
 }
 return FALSE;
 }

 /**
 * Does what unique_array() does but with multidimensional arrays
 * @param mixed $array The array that will be filtered
 * @param string $sub_key The $key that will be examined for duplicates
 */

 function unique_multi_array ( $array, $sub_key )
 {
 $target                  = array();
 $existing_sub_key_values = array();

 foreach ( $array as $key => $sub_array )
 {
 if ( !in_array($sub_array[$sub_key], $existing_sub_key_values) )
 {
 $existing_sub_key_values[] = $sub_array[$sub_key];
 $target[$key]              = $sub_array;
 }
 }
 return $target;
 }

 /**
 * Returns the current txtSQL version
 * @return string $version The current version of txtSQL
 * @access public
 */

 function version()
 {
 return '2.2 Final';
 }
}
?>

&amp;nbsp;

 

 

PHP Scripts for Validation

The PHP Validation script is a set of validation rules which lets you add server-side validation to your forms quickly and with as little effort as possible. The script checks the values that a user has entered into your form, and if it doesn’t meet the criteria specified (e.g. they failed to enter a value, or they entered a fake email address), they are returned to the original form with a list of all the offending fields. It requires PHP 4 or later.

Click on the various links in the box above to get instructions on how to add it to your form, see and view the PHP for a demonstration form and get a list of all available validation rules. The demonstration page contains all the validation options currently offered by the script. Version 2.0 (Dec 2006) includes some additional validation rules (alphanumeric test, improved range and length tests). It is backward compatible with earlier versions. Many thanks to Mihai Ionescu and Nathan Howard for contributing their code. The 2.3.1 release fixes a bug noticed by Khalid Hanif with the reg_exp option. Thanks Khalid!

 

<?php

/*--------------------------------------------------------------------------------------------*\

 validation.php
 --------------

 v2.3.3, Apr 2010

 This script provides generic validation for any web form. For a discussion and example usage
 of this script, go to http://www.benjaminkeen.com/software/php_validation

 This script is written by Ben Keen with additional code contributed by Mihai Ionescu and
 Nathan Howard. It is free to distribute, to re-write - to do what ever you want with it.

 Before using it, please read the following disclaimer.

 THIS SOFTWARE IS PROVIDED ON AN "AS-IS" BASIS WITHOUT WARRANTY OF ANY KIND. BENJAMINKEEN.COM
 SPECIFICALLY DISCLAIMS ANY OTHER WARRANTY, EXPRESS OR IMPLIED, INCLUDING ANY WARRANTY OF
 MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL BENJAMINKEEN.COM BE
 LIABLE FOR ANY CONSEQUENTIAL, INDIRECT, SPECIAL OR INCIDENTAL DAMAGES, EVEN IF BENJAMINKEEN.COM
 HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH POTENTIAL LOSS OR DAMAGE. USER AGREES TO HOLD
 BENJAMINKEEN.COM HARMLESS FROM AND AGAINST ANY AND ALL CLAIMS, LOSSES, LIABILITIES AND EXPENSES.

\*--------------------------------------------------------------------------------------------*/



/*--------------------------------------------------------------------------------------------*\
 Function: validateFields()
 Purpose:  generic form field validation.
 Parameters: field - the POST / GET fields from a form which need to be validated.
 rules - an array of the validation rules. Each rule is a string of the form:

 "[if:FIELDNAME=VALUE,]REQUIREMENT,fieldname[,fieldname2 [,fieldname3, date_flag]],error message"

 if:FIELDNAME=VALUE,   This allows us to only validate a field
 only if a fieldname FIELDNAME has a value VALUE. This
 option allows for nesting; i.e. you can have multiple
 if clauses, separated by a comma. They will be examined
 in the order in which they appear in the line.

 Valid REQUIREMENT strings are:
 "required"     - field must be filled in
 "digits_only"  - field must contain digits only
 "is_alpha"     - field must only contain alphanumeric characters (0-9, a-Z)
 "custom_alpha" - field must be of the custom format specified.
 fieldname:  the name of the field
 fieldname2: a character or sequence of special characters. These characters are:
 L   An uppercase Letter.          V   An uppercase Vowel.
 l   A lowercase letter.           v   A lowercase vowel.
 D   A letter (upper or lower).    F   A vowel (upper or lower).
 C   An uppercase Consonant.       x   Any number, 0-9.
 c   A lowercase consonant.        X   Any number, 1-9.
 E   A consonant (upper or lower).
 "reg_exp"      - field must match the supplied regular expression.
 fieldname:  the name of the field
 fieldname2: the regular expression
 fieldname3: (optional) flags for the reg exp (like i for case insensitive
 "letters_only" - field must only contains letters (a-Z)

 "length=X"     - field has to be X characters long
 "length=X-Y"   - field has to be between X and Y (inclusive) characters long
 "length>X"     - field has to be greater than X characters long
 "length>=X"    - field has to be greater than or equal to X characters long
 "length<X"     - field has to be less than X characters long
 "length<=X"    - field has to be less than or equal to X characters long

 "valid_email"  - field has to be valid email address
 "valid_date"   - field has to be a valid date
 fieldname:  MONTH
 fieldname2: DAY
 fieldname3: YEAR
 date_flag:  "later_date" / "any_date"
 "same_as"     - fieldname is the same as fieldname2 (for password comparison)

 "range=X-Y"    - field must be a number between the range of X and Y inclusive
 "range>X"      - field must be a number greater than X
 "range>=X"     - field must be a number greater than or equal to X
 "range<X"      - field must be a number less than X
 "range<=X"     - field must be a number less than or equal to X


 Comments:   With both digits_only, valid_email and is_alpha options, if the empty string is passed
 in it won't generate an error, thus allowing validation of non-required fields. So,
 for example, if you want a field to be a valid email address, provide validation for
 both "required" and "valid_email".
\*--------------------------------------------------------------------------------------------*/

function validateFields($fields, $rules)
{
 $errors = array();

 // loop through rules
 for ($i=0; $i<count($rules); $i++)
 {
 // split row into component parts
 $row = explode(",", $rules[$i]);

 // while the row begins with "if:..." test the condition. If true, strip the if:..., part and
 // continue evaluating the rest of the line. Keep repeating this while the line begins with an
 // if-condition. If it fails any of the conditions, don't bother validating the rest of the line
 $satisfies_if_conditions = true;
 while (preg_match("/^if:/", $row[0]))
 {
 $condition = preg_replace("/^if:/", "", $row[0]);

 // check if it's a = or != test
 $comparison = "equal";
 $parts = array();
 if (preg_match("/!=/", $condition))
 {
 $parts = explode("!=", $condition);
 $comparison = "not_equal";
 }
 else
 $parts = explode("=", $condition);

 $field_to_check = $parts[0];
 $value_to_check = $parts[1];

 // if the VALUE is NOT the same, we don't need to validate this field. Return.
 if ($comparison == "equal" &amp;&amp; $fields[$field_to_check] != $value_to_check)
 {
 $satisfies_if_conditions = false;
 break;
 }
 else if ($comparison == "not_equal" &amp;&amp; $fields[$field_to_check] == $value_to_check)
 {
 $satisfies_if_conditions = false;
 break;
 }
 else
 array_shift($row);    // remove this if-condition from line, and continue validating line
 }

 if (!$satisfies_if_conditions)
 continue;


 $requirement = $row[0];
 $field_name  = $row[1];

 // depending on the validation test, store the incoming strings for use later...
 if (count($row) == 6)        // valid_date
 {
 $field_name2   = $row[2];
 $field_name3   = $row[3];
 $date_flag     = $row[4];
 $error_message = $row[5];
 }
 else if (count($row) == 5)     // reg_exp (WITH flags like g, i, m)
 {
 $field_name2   = $row[2];
 $field_name3   = $row[3];
 $error_message = $row[4];
 }
 else if (count($row) == 4)     // same_as, custom_alpha, reg_exp (without flags like g, i, m)
 {
 $field_name2   = $row[2];
 $error_message = $row[3];
 }
 else
 $error_message = $row[2];    // everything else!


 // if the requirement is "length=...", rename requirement to "length" for switch statement
 if (preg_match("/^length/", $requirement))
 {
 $length_requirements = $requirement;
 $requirement         = "length";
 }

 // if the requirement is "range=...", rename requirement to "range" for switch statement
 if (preg_match("/^range/", $requirement))
 {
 $range_requirements = $requirement;
 $requirement        = "range";
 }


 // now, validate whatever is required of the field
 switch ($requirement)
 {
 case "required":
 if (!isset($fields[$field_name]) || $fields[$field_name] == "")
 $errors[] = $error_message;
 break;

 case "digits_only":
 if (isset($fields[$field_name]) &amp;&amp; preg_match("/\D/", $fields[$field_name]))
 $errors[] = $error_message;
 break;

 case "letters_only":
 if (isset($fields[$field_name]) &amp;&amp; preg_match("/[^a-zA-Z]/", $fields[$field_name]))
 $errors[] = $error_message;
 break;

 // doesn't fail if field is empty
 case "valid_email":
 $regexp="/^[a-z0-9]+([_+\\.-][a-z0-9]+)*@([a-z0-9]+([\.-][a-z0-9]+)*)+\\.[a-z]{2,}$/i";
 if (isset($fields[$field_name]) &amp;&amp; !empty($fields[$field_name]) &amp;&amp; !preg_match($regexp, $fields[$field_name]))
 $errors[] = $error_message;
 break;

 case "length":
 $comparison_rule = "";
 $rule_string     = "";

 if      (preg_match("/length=/", $length_requirements))
 {
 $comparison_rule = "equal";
 $rule_string = preg_replace("/length=/", "", $length_requirements);
 }
 else if (preg_match("/length>=/", $length_requirements))
 {
 $comparison_rule = "greater_than_or_equal";
 $rule_string = preg_replace("/length>=/", "", $length_requirements);
 }
 else if (preg_match("/length<=/", $length_requirements))
 {
 $comparison_rule = "less_than_or_equal";
 $rule_string = preg_replace("/length<=/", "", $length_requirements);
 }
 else if (preg_match("/length>/", $length_requirements))
 {
 $comparison_rule = "greater_than";
 $rule_string = preg_replace("/length>/", "", $length_requirements);
 }
 else if (preg_match("/length</", $length_requirements))
 {
 $comparison_rule = "less_than";
 $rule_string = preg_replace("/length</", "", $length_requirements);
 }

 switch ($comparison_rule)
 {
 case "greater_than_or_equal":
 if (!(strlen($fields[$field_name]) >= $rule_string))
 $errors[] = $error_message;
 break;
 case "less_than_or_equal":
 if (!(strlen($fields[$field_name]) <= $rule_string))
 $errors[] = $error_message;
 break;
 case "greater_than":
 if (!(strlen($fields[$field_name]) > $rule_string))
 $errors[] = $error_message;
 break;
 case "less_than":
 if (!(strlen($fields[$field_name]) < $rule_string))
 $errors[] = $error_message;
 break;
 case "equal":
 // if the user supplied two length fields, make sure the field is within that range
 if (preg_match("/-/", $rule_string))
 {
 list($start, $end) = explode("-", $rule_string);
 if (strlen($fields[$field_name]) < $start || strlen($fields[$field_name]) > $end)
 $errors[] = $error_message;
 }
 // otherwise, check it's EXACTLY the size the user specified
 else
 {
 if (strlen($fields[$field_name]) != $rule_string)
 $errors[] = $error_message;
 }
 break;
 }
 break;

 case "range":
 $comparison_rule = "";
 $rule_string     = "";

 if      (preg_match("/range=/", $range_requirements))
 {
 $comparison_rule = "equal";
 $rule_string = preg_replace("/range=/", "", $range_requirements);
 }
 else if (preg_match("/range>=/", $range_requirements))
 {
 $comparison_rule = "greater_than_or_equal";
 $rule_string = preg_replace("/range>=/", "", $range_requirements);
 }
 else if (preg_match("/range<=/", $range_requirements))
 {
 $comparison_rule = "less_than_or_equal";
 $rule_string = preg_replace("/range<=/", "", $range_requirements);
 }
 else if (preg_match("/range>/", $range_requirements))
 {
 $comparison_rule = "greater_than";
 $rule_string = preg_replace("/range>/", "", $range_requirements);
 }
 else if (preg_match("/range</", $range_requirements))
 {
 $comparison_rule = "less_than";
 $rule_string = preg_replace("/range</", "", $range_requirements);
 }

 switch ($comparison_rule)
 {
 case "greater_than":
 if (!($fields[$field_name] > $rule_string))
 $errors[] = $error_message;
 break;
 case "less_than":
 if (!($fields[$field_name] < $rule_string))
 $errors[] = $error_message;
 break;
 case "greater_than_or_equal":
 if (!($fields[$field_name] >= $rule_string))
 $errors[] = $error_message;
 break;
 case "less_than_or_equal":
 if (!($fields[$field_name] <= $rule_string))
 $errors[] = $error_message;
 break;
 case "equal":
 list($start, $end) = explode("-", $rule_string);

 if (($fields[$field_name] < $start) || ($fields[$field_name] > $end))
 $errors[] = $error_message;
 break;
 }
 break;

 case "same_as":
 if ($fields[$field_name] != $fields[$field_name2])
 $errors[] = $error_message;
 break;

 case "valid_date":
 // this is written for future extensibility of isValidDate function to allow
 // checking for dates BEFORE today, AFTER today, IS today and ANY day.
 $is_later_date = false;
 if    ($date_flag == "later_date")
 $is_later_date = true;
 else if ($date_flag == "any_date")
 $is_later_date = false;

 if (!is_valid_date($fields[$field_name], $fields[$field_name2], $fields[$field_name3], $is_later_date))
 $errors[] = $error_message;
 break;

 case "is_alpha":
 if (preg_match('/[^A-Za-z0-9]/', $fields[$field_name]))
 $errors[] = $error_message;
 break;

 case "custom_alpha":
 $chars = array();
 $chars["L"] = "[A-Z]";
 $chars["V"] = "[AEIOU]";
 $chars["l"] = "[a-z]";
 $chars["v"] = "[aeiou]";
 $chars["D"] = "[a-zA-Z]";
 $chars["F"] = "[aeiouAEIOU]";
 $chars["C"] = "[BCDFGHJKLMNPQRSTVWXYZ]";
 $chars["x"] = "[0-9]";
 $chars["c"] = "[bcdfghjklmnpqrstvwxyz]";
 $chars["X"] = "[1-9]";
 $chars["E"] = "[bcdfghjklmnpqrstvwxyzBCDFGHJKLMNPQRSTVWXYZ]";

 $reg_exp_str = "";
 for ($j=0; $j<strlen($field_name2); $j++)
 {
 if (array_key_exists($field_name2[$j], $chars))
 $reg_exp_str .= $chars[$field_name2[$j]];
 else
 $reg_exp_str .= $field_name2[$j];
 }

 if (!empty($fields[$field_name]) &amp;&amp; !preg_match("/$reg_exp_str/", $fields[$field_name]))
 $errors[] = $error_message;
 break;

 case "reg_exp":
 $reg_exp_str = $field_name2;

 // rather crumby, but...
 if (count($row) == 5)
 $reg_exp = "/" . $reg_exp_str . "/" . $row[3];
 else
 $reg_exp = "/" . $reg_exp_str . "/";

 if (!empty($fields[$field_name]) &amp;&amp; !preg_match($reg_exp, $fields[$field_name]))
 $errors[] = $error_message;
 break;

 default:
 die("Unknown requirement flag in validate_fields(): $requirement");
 break;
 }
 }

 return $errors;
}


/*------------------------------------------------------------------------------------------------*\
 Function:   is_valid_date
 Purpose:    checks a date is valid / is later than current date
 Parameters: $month       - an integer between 1 and 12
 $day         - an integer between 1 and 31 (depending on month)
 $year        - a 4-digit integer value
 $is_later_date - a boolean value. If true, the function verifies the date being passed
 in is LATER than the current date.
\*------------------------------------------------------------------------------------------------*/

function is_valid_date($month, $day, $year, $is_later_date)
{
 // depending on the year, calculate the number of days in the month
 if ($year % 4 == 0)      // LEAP YEAR
 $days_in_month = array(31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31);
 else
 $days_in_month = array(31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31);


 // first, check the incoming month and year are valid.
 if (!$month || !$day || !$year) return false;
 if (1 > $month || $month > 12)  return false;
 if ($year < 0)                  return false;
 if (1 > $day || $day > $days_in_month[$month-1]) return false;


 // if required, verify the incoming date is LATER than the current date.
 if ($is_later_date)
 {
 // get current date
 $today = date("U");
 $date = mktime(0, 0, 0, $month, $day, $year);
 if ($date < $today)
 return false;
 }

 return true;
}

?>

PHP Scripts for Software List

Software List is a PHP script that organizes a software catalog. It allows users to see the information about programs, so they are able to download or buy the necessary program quickly and effectively. Software List directory script supports the following affiliates: RegNow, ShareIt and eSellerate. The categorized and searchable directory interface gives maximum of comfort to a user while searching programs. The script allows software developers to quickly and easily share the information about their products using a PAD XML format. The Content Management System (CMS) panel allows webmaster to fully manage a site`s content, manage the registered users and information about their programs, edit the site and letters` templates. The script is cross-platformable, it has a minimum system requirements, easy in performance and installation. It`s powered by PHP+MySQL and Apache web server.

 

<?php @Zend;
3272;
/*  ñ!This is not a text file!Þí
 */

print "<html><body>\n";
print "
<a href=\"http://www.zend.com/store/products/zend-safeguard-suite.php\
"
><img border=\"0\" src=\"http://www.zend.com/images/store/safeguard_icon_nover_64.jpg\" align=\"right\"></a>\n";
print "<center><h1>Zend Optimizer not installed</h1></center>";
print "<p>This file was encoded by the <a href=\"http://www.zend.com/store/products/zend-encoder.php\">Zend Encoder</a> / <a href=\"http://www.zend.com/store/products/zend-safeguard-suite.php\">Zend SafeGuard Suite</a></p>\n";
print "<p>In order to run it, please install the freely available <a href=\"http://www.zend.com/store/products/zend-optimizer.php\">Zend Optimizer</a>, version 2.1.0 or later.</p>\n";
print "<h2>What is the Zend Optimizer?</h2>
"
;
print <<<EOM
<p>The Zend Optimizer is one of the most popular PHP plugins for performance-improvement, and has been freely available since the early days of PHP 4.  It improves performance by taking PHP's intermediate code through multiple Optimization Passes, which replace inefficient code patterns with efficient code blocks.  The replacement code blocks perform exactly the same operations as the original code, only faster.</p>
<p>In addition to performance-improvement, the Zend Optimizer also enables PHP to transparently load files encoded by the Zend Encoder or Zend SafeGuard Suite.</p>
<p>The Zend Optimizer is a freely-available product from <a href="http://www.zend.com">Zend Technologies</a>.  Zend Technologies is the company that develops the scripting engine of PHP, also known as the <a href="http://www.zend.com/store/products/zend-engine.php">Zend Engine</a>.</p>
EOM
;
print "</body></html>\n";
exit();
?>

 2003120701 1 4262 16597 xù
Ÿ2 •<;¬%Å•åáigxÏDNlém°–ýæuýºªfÅÂ0íÀÀ ^ìõ§Õï¾~oîÌýq?#;YÎH$HN̆+™Ä‘µñfm‚E€´F֐¬    0$>U]]]U]Ý÷Ú¿sºÎ©ó?§ª®þÿ^ÍN¯Ìt¢YšÿÕ[s2ÙW\QI$0V×Gÿüì›7|öÄFg-Âåxº%!ç™Ðeîjs²Z/°TDp‘1fþ¸^.櫬˜`2#’ƒ¿Ëj1)GÕɰÄ+½ˆ„`\¬Öår
昐Œ
®;0H†ÅªZïãœ+Œ)¯K„UµZç³bVN«Œs™I‚!h†Øøô sªôRÚý h †Î>ÍåhV¬–ÕyÃÙW°’f˜e†‡ÓñR‚?ç’1¥”Àf3›ÙªZŽ!ƒ¾QQ‰¡DJÃÄB/7-×£Û8ãË,cõGgãIUT¯Wk-Å$ã¹"Zb·«”²Ÿ3ša‘«z§ ÐXq6Ù¬`)E3E2™ ã¼í±LÖÿ‹}ôBlìK] 6U¤ŽùïÚŽñ± 8³ÀŸoûž£Ü÷8þž£ßZÜKuñéQÌ(M²f¢Ð'—‚(ѨœLNÊÑÝKµ
Ö‘R¡‹Öã^c
?5Ú9’¼!™#I±õ(ìâ¶jìàòfU£ùüî¸Zùäá›;Í7mx#>üjÈž3Ó†;b°¾ÞåN¨œ©ÜqGÐÿFÜéúðŒ£Zåò|¤ÿõ³€9Òʰi׿H,»$s$%:‘vD—·ÌOæ'å$”å±Fw’Mʍ+’·¬±ŽÜr4-ÏÇ£âµÍ|]­ŠóÅ(`m‘ÛIj,ipœ^:Öx,5(F|ƒ[/ËÙªXÙfª¡Ï·ˆŽï$:î‰.÷øSŠ8þD$:È13Ý    ˆÅ×óAÀýkœc‹«W^ñÂT±7Ý  ,·ì¢ë\?éWø®~¼Y³©¿©r$šº g3,÷£Ð‡áÊ!§Ø ¼³—â¡å´Æzß~ä÷ƒðâØ¦¤Ú7-¦YÙ
7µý"\†4š/«ãѤ\ÁzÇPêNÁ¤F“K&amp;/ÛÏúmŸÍÎÆçñgÔ•8m
>;=‰?aèk%}Rl:„8úFôU~¥›ßø£ýjø£i9îHBXIxJ=kdæ‹Y¡¯Eº|„ûÐ?…Ðx)ÝzÖG6-v)ao­ë.yFã!
|?AAkÊc–c´è0Ë=è«ýÌê¥4³€u1ÁlM    {k½í˜¥³ ü“ý¿èV‚î² jëæÄIÅmÚõ    ú8¹CZ•…išŠZõŵç,ÖïBW•z¥[·®ÝxѧÇÐoBÇnG’Øn–Å›ehì8
Ç©k]úŽ^ ·Ú”W5ðËžÊÓ©ÝkŽö’’£ÉüÜáü÷@|ð{q|­>šYz¬žÓ&amp;˜è‹&amp;†>"H úvr† ©-
ŠB/Çatqóß®Üô‚ùe2ƪºþލ[¯X¼¢Õn¯×‹'=õä~‘¥šÀ/™Ê2éQŒ‹… ýøøŸ~ôÓãŸ|û[ÿèoø'*PÃ4 ÿüz/²ùh‹Ô`}æ¶HÛlZy‹v'Î#Ô'õQðuܤ„o„óaϼXºÙsx¼qlá7Sª{•Ñf¹¬fëb³œXÔÙ^Íã^@οéì§]›$¬ËÊV}é‚CSÏ_»~¥(V¯,QMÿAlS¶ó2)`ýÿ¶-ÀW–ëáö¼-8 çhôœNc¾³nVƒ¦£p³’ÑC?´’ )G‡å²*íJŸ;&amp;q™ÐaoYÅN.~×G‘
€{ÉÀ¶N«+×a8šzVc]ƒtmñè@xð—‘؏O{·b˵Ò¡„P£ŽW™â´ütr׳†œý&amp;&amp;÷å^£€hïmr©÷ζ0Õf©¡…¢ØíûgîânR2Âw+ìÜŠ`Ò;€ôYß~¬T°ÁúeOèmuYã]ì/pz5š„“ß/…70±ý    ôV³±=Lâ„àEœ GšCG¡ïFŒÂJØßIú¢]ɸ¢ŠýÈ‘ñ×y·fëF—J†®ÏËÓæ§›‰™#Š6Y¯÷Å
Я¤ë¥¸ˆÝo4]Ýš–Ëõ}O ‚¦¢<pZ ÞjZ(€    % ‡½õZÁÈH0õ")Á˜SHc«ùf9ªMSpO6²#>$î‚¿Ó`ñT¾\„+ã¨<­õS#ýß@ð¬ã§ÌõÕB¢ç·²!{ê¼€
©óu‚
Œž´ð§œÐU4…à{­SñØ© ¼­[ª§[xTƒÍ:€cÄ—[¸YOÚñ¹ ¤ßI
à³^Ið‹I¸­wU Uûëõ    ºß†fÒ iÞŽ$k';ML>~áÖµ+ÇcßÄí-Å31XßIEp]E™êùûðIñÌÕ+/¾bÑ?‰9ñIÞ‰¹?·É>ÞÒ”v£{ëXßuº‚¤2>7CÅ@ãU1®!p—x:Ãf–
Ä ?r)0Ln£»'Ëù=Ý¥èErK|úZÏ[‹±÷yü¶ŸlTt*\=J™.ÊõødR–•`Û&amp;/׬[ªíMbàm>&amp;©ˆ!©-•m,ËNƒDåÓÎû<f¥nRÌZŠÒí?ŬDû™•®Kï
¡*Óýø–À H¿ºé{+¼¥=^á‰d>‰Ã¾-ÉÆ_SŨ–ëhmGš€ôé@”0‹£¤Ï†?f    |‚—Î!q®ž©IaƒüËAžkœ{xžº"EµEJ(:£>€~g 18¿M4`% ýÝV
`od MCåmÛ=Àz<¢³‡Ûó z!RMHãí6GÔM^þQ|
‡ðOâŽú›¼˜vj€p”    ¡]ʿْAÙÅQȐ£ã(‚†Z3c"GIq±ƒŸa?!    ?    ¸ø;ü„Æ~Ò9 ”Ü„º    Ý$¤B Ê^B½„Æ^Ò?ÝÉIh×Iñtê9    !86UºÅIè “Ð!'1Ø’/¸'^7àè_† »¶H]‡ád{ŽUc·†Àp„>€Ú_ztØ>k¤Å€å×ßu³0 Ÿ¥ªt³£5ªl»SÅ@ÛöŸð,6wu±qïaÈ•[»:ƒ5ÐÖx§¯#< r²M½€E\Ö¯_ƒöápd08ïlS°Áz¿WÃ5?}*6ÐèØ$!]êÚ^¬w{•lÀ{®*O?ªår¾¬‘6 ü½Ž†rÚr*Ы;hH:…<„
’=“´†aR#Ý’½ì;ú²?؁[…†Üªš=È9VÎ\B޽jÂjØbԠŨíêO[ C‹ò¼jp<{¡±½`â    'H湕“‰¾ó°ÏÎWFN°Ä«a 8¢é³
»[ÅâÍúN ô+©ÖR·?š)»TÍ봝Vgåf².nϧU¡E(3·ç¨#µPO`¬#0æÝ|h¦ÃL¨\pÒŠÁ›®Ù5BZxêö‰Aø‹£â
:¤rG;éó-TBÑÀ\ŽÉ<ˆ#y}Ð7EÀúAòܬáâjg
s?±­ ÖCRm‰‡     ð—@ƒ×NkíäΧs÷œ÷9•…6…oóuùpbæH”§Xéå¦A>¥ 'iÝHëFi>¥;®ïu~âwÄ>ª0Î_ŒO´O‡b=I4Å4óÈ`}ȼ…ìNwYÁnšDhôdž`‘äàÐÑ(›IŸ/Äö 4„_„g¹MÒmÀÿž·ŽÖ ü9úÞ=Û2ЩÏõ(îx]M“r]9FÊ#Ô_é÷IFº¼^LoÖæ?CkÀ7·
–õ̪;‚eN0=‚eÁ‚e}’èr}+ÛA@ÌPÞÛ<H®á‡ÎDqë(¹?À¦.®s–û.—ûSÙøàÊÀ»‚Þ-g?’]ÊO,8¢¢DúÔ~›àI˜dãcyq7Oñtñïà‰Eù$”’pÆ    ÚW–ðÓ´è(K¸¯/m!K¸¸G™ú`"!    •É<‘HeÙDo`™À!ÏfXk3Bâ‹fÑ©‡yå³.×›Õ“‡,c‡/ÎׇÏÏ7³Ó@mðYt͵¹ï+ °¾ž`Ad8c­!ÑεR¿Ø9Æ—³!ptû5ÍCpÛÅçã6?S’8 ¸>•zÂcqÙ½¶rô›x˜>A/ï¼»ÖÎ(E›ÖÎXWý”ë¡Å‘pÖ.aÎ[·Ú Ñ!;ø:v’ùEšSÏëhînÞ¥¼Žæ®|JzÀ¯7‡|ös—@ƳÓêõ–Ü>ãÙÃ,ëyƧ¨;Ð0 ½³m 8é)E°\ƒ²èç ü ¿Ÿc;M5ާ•Óp3þ­Öå¢÷Z©¡;tîŒÄ»y‡0›ß 9!ÚqéNm#ñqdß’…Zð} ÿšT€1€¾:°sâuý;§ñ}DV·Ëe5Ž,Êt¨;nÆmXïšöN½&amp;¬»wÚ&amp;i »8K\Û¬VÕdR-¡Ì
yeZÖ;îŸEÖ4¼îÃ0to@lh
ÄØ.S Æã)PŽ“ñt³
Ù4íêŽÛç±Iõ-yq`çÜMR;烑‡÷D}³s%ôýš„p÷í á³üÐ¥ø Æ€?qQ‰w£’hËÇLp暑Ž{†JæH¥­kU|-<Ì€ ?IϺ¤¹Ðx«~4ò¬»ÀgîÐôøUVC[¿ÊƒÙåh27Y‰ö䬆¾l¹ÆãOóœ£Fâè/{®öédU.âiR7J×?´¡W…¹JÿÕ#’I©¤Ìt{ ôß'ãÙ݃#®($oýüK´‘Gý¼â çú¦ª_…:~Ì AD¤1»g^ØÇŠ2F¡N5¨õ![¡oÛîNyΤ¤æå¦YÄܤ=ÀXpAõJÈ¿#©ßæR²\*n^ºš{qðW–sý<“+ó²i‹Å²:¿¾ÏVYÆôböî‹f’eBqjô±¾ÄeŽõcU7c€~N…0¿œ£ ¬},E®h¦kr©G‹f¢xp„3*$ÁŠ™§®P¸¦ßÑ÷7ö9çC×¥ß`f!¬YQ÷° ÌüjD3²l6ñèQž    _]—êK5öݦ}EÞ>ä4¿õ ÿg¹jB$ì@;óÇá#o§rK¡œ§Új2³Q@ÛÛÿ™kE$ÉÚ#~Øo    ²(Phèø× ôûfÿ•i¦/?ÕEb޸ʲwéÒÒö.ˆ]ÀØ
gõƒ×]wO’ú0ð¥82?³äŸæ3Ï‚N<‰AzÊí‚Æ» ©ñ®~ªJ[>ÛÁöch‡ÏÎØ*f÷ 'ö݆þ¡†Õül}¼îhm¸<l…m k¤Ï¡    Ggådå?Uœ?†?×á½T à[.wd¥ù™Ûùá„0§S—=u|2?½ÿt —*C/ÍïU'Oîî&amp; Ãu¹„,þÝ'Š“I9»ûÄÓ·”뀢6Æ‘&amp;>éElVÔ‡>L&amp;zšï²ê»ýæÏÝkG¥Õ°qþ‚ù=€“ÍÙYµÔQRä”åLÏ¥’AÞܝŸ­«™´bi®¹^8Äǹ¢¤™[þ
*¯UZ

&amp;nbsp;

PHP DataGrid AJAX Enabled Web Control

PHP DataGrid (AJAX Enabled) script is a simple, innovative and powerful tool for generating data-bound grid control. It was specially designed for web developers. The PHP DataGrid is excellent for all PHP database-driven web sites and online-based data administration; it is also useful for dynamic content management and PHP-based hosting providers. The goal of this script is to simplify the generation and editing of DataGrid for web developers. The PHP DG is an excellent tool for: – PHP database-driven web sites – Adding Back-End for existing sites; – Creating online-based data administration; – Creating dynamic content management or your own CMS.

PHP DataGrid (AJAX Enabled)-datagrid control. PHP DataGrid (AJAX Enabled) script is a simple, innovative and powerful tool for generating data-bound grid control. It was specially designed for web developers.

 

<?
################################################################################
##              -= YOU MAY NOT REMOVE OR CHANGE THIS NOTICE =-                 #
## --------------------------------------------------------------------------- #
##  PHP DataGrid version 4.2.8 (01.10.2008)                                    #
##  Author &amp; developer:     Leumas Naypoka <leumas.a@gmail.com>                #
##  Developers:             Zewa           <http://www.softic.at>              #
##                          Fcallez        <http://www.innovavirtual.org>      #
##  Lisence:    GNU GPL                                                        #
##  Site:       http://phpbuilder.blogspot.com                                 #
##  Copyright:  Leumas Naypoka (c) 2006-2008. All rights reserved.             #
################################################################################
## +---------------------------------------------------------------------------+
## | 1. Creating &amp; Calling:                                                    |
## +---------------------------------------------------------------------------+
##  *** define a relative (virtual) path to datagrid.class.php file and "pear"
##  *** directory (relatively to the current file)
##  *** RELATIVE PATH ONLY ***
//
//  define ("DATAGRID_DIR", "");                     /* Ex.: "datagrid/" */
//  define ("PEAR_DIR", "pear/");                    /* Ex.: "datagrid/pear/" */
//
//  require_once(DATAGRID_DIR.'datagrid.class.php');
//  require_once(PEAR_DIR.'PEAR.php');
//  require_once(PEAR_DIR.'DB.php');
##
##  *** creating variables that we need for database connection
//  $DB_USER='name';            /* usually like this: prefix_name             */
//  $DB_PASS='';                /* must be already enscrypted (recommended)   */
//  $DB_HOST='localhost';       /* usually localhost                          */
//  $DB_NAME='dbName';          /* usually like this: prefix_dbName           */
//
//  ob_start();
##  *** (example of ODBC connection string)
##  *** $result_conn = $db_conn->connect(DB::parseDSN('odbc://root:12345@test_db'));
##  *** (example of Oracle connection string)
##  *** $result_conn = $db_conn->connect(DB::parseDSN('oci8://root:12345@localhost:1521/mydatabase));
##  *** (example of PostgreSQL connection string)
##  *** $result_conn = $db_conn->connect(DB::parseDSN('pgsql://root:12345@localhost/mydatabase));
##  === (Examples of connections to other db types see in "docs/pear/" folder)
//  $db_conn = DB::factory('mysql');  /* don't forget to change on appropriate db type */
//  $result_conn = $db_conn->connect(DB::parseDSN('mysql://'.$DB_USER.':'.$DB_PASS.'@'.$DB_HOST.'/'.$DB_NAME));
//  if(DB::isError($result_conn)){ die($result_conn->getDebugInfo()); }
##  *** put a primary key on the first place
//  $sql = "SELECT primary_key, field_1, field_2 ... FROM tableName ;";
##  *** set encoding and collation (default: utf8/utf8_unicode_ci)
/// $dg_encoding = "utf8";
/// $dg_collation = "utf8_unicode_ci";
/// $dgrid->SetEncoding($dg_encoding, $dg_collation);
##  *** set needed options and create a new class instance
//  $debug_mode = false;        /* display SQL statements while processing */
//  $messaging = true;          /* display system messages on a screen */
//  $unique_prefix = "abc_";    /* prevent overlays - must be started with a letter */
//  $dgrid = new DataGrid($debug_mode, $messaging, $unique_prefix, DATAGRID_DIR);
##  *** set data source with needed options
//  $default_order_field = "field_name_1 [, field_name_2...]";
//  $default_order_type = "ASC|DESC [, ASC|DESC...]";
//  $dgrid->DataSource($db_conn, $sql, $default_order_field, $default_order_type);
##
##
## +---------------------------------------------------------------------------+
## | 2. General Settings:                                                      |
## +---------------------------------------------------------------------------+
##  *** set interface language (default - English)
##  *** (en) - English     (de) - German     (se) - Swedish   (hr) - Bosnian/Croatian
##  *** (hu) - Hungarian   (es) - Espanol    (ca) - Catala    (fr) - Francais
##  *** (nl) - Netherlands/"Vlaams"(Flemish) (it) - Italiano  (pl) - Polish
##  *** (ch) - Chinese     (sr) - Serbian    (bg) - Bulgarian (pb) - Brazilian Portuguese
##  *** (ar) - Arabic      (tr) - Turkish    (cz) - Czech     (ro/ro_utf8) - Romanian
##  *** (gk) - Greek       (he) - Hebrew     (ru_utf8) - Russian
/// $dg_language = "en";
/// $dgrid->SetInterfaceLang($dg_language);
##  *** set direction: "ltr" or "rtr" (default - "ltr")
/// $direction = "ltr";
/// $dgrid->SetDirection($direction);
##  *** set layouts: "0" - tabular(horizontal) - default, "1" - columnar(vertical), "2" - customized
/// $layouts = array("view"=>"0", "edit"=>"1", "details"=>"1", "filter"=>"1");
/// $dgrid->SetLayouts($layouts);
/// $details_template = "<table><tr><td>{field_name_1}</td><td>{field_name_2}</td></tr>...</table>";
/// $dgrid->SetTemplates("","",$details_template);
##  *** set modes for operations ("type" => "link|button|image")
##  *** "byFieldValue"=>"fieldName" - make the field to be a link to edit mode page
/// $modes = array(
///     "add"      =>array("view"=>true, "edit"=>false, "type"=>"link", "show_add_button"=>"inside|outside"),
///     "edit"      =>array("view"=>true, "edit"=>true,  "type"=>"link", "byFieldValue"=>""),
///     "cancel"  =>array("view"=>true, "edit"=>true,  "type"=>"link"),
///     "details" =>array("view"=>true, "edit"=>false, "type"=>"link"),
///     "delete"  =>array("view"=>true, "edit"=>true,  "type"=>"image")
/// );
/// $dgrid->SetModes($modes);
##  *** allow scrolling on datagrid
/// $scrolling_option = false;
/// $dgrid->AllowScrollingSettings($scrolling_option);
##  *** set scrolling settings (optional)
/// $scrolling_width = "90%";
/// $scrolling_height = "100%";
/// $dgrid->setScrollingSettings($scrolling_width, $scrolling_height);
##  *** allow multirow operations
//  $multirow_option = true;
//  $dgrid->AllowMultirowOperations($multirow_option);
/// $multirow_operations = array(
///     "delete"  => array("view"=>true),
///     "details" => array("view"=>true),
///     "my_operation_name" => array("view"=>true, "flag_name"=>"my_flag_name", "flag_value"=>"my_flag_value", "tooltip"=>"Do something with selected", "image"=>"image.gif")
/// );
/// $dgrid->SetMultirowOperations($multirow_operations);
##  *** set CSS class for datagrid
##  *** "default" or "blue" or "gray" or "green" or "pink" or your own css file
/// $css_class = "default";
/// $dgrid->SetCssClass($css_class);
##  *** set variables that used to get access to the page (like: my_page.php?act=34&amp;id=56 etc.)
/// $http_get_vars = array("act", "id");
/// $dgrid->SetHttpGetVars($http_get_vars);
##  *** set other datagrid/s unique prefixes (if you use few datagrids on one page)
##  *** format (in which mode to allow processing of another datagrids)
##  *** array("unique_prefix"=>array("view"=>true|false, "edit"=>true|false, "details"=>true|false));
/// $anotherDatagrids = array("abcd_"=>array("view"=>true, "edit"=>true, "details"=>true));
/// $dgrid->SetAnotherDatagrids($anotherDatagrids);
##  *** set DataGrid caption
/// $dg_caption = "My Favorite Lovely PHP DataGrid";
/// $dgrid->SetCaption($dg_caption);
##
##
## +---------------------------------------------------------------------------+
## | 3. Printing &amp; Exporting Settings:                                         |
## +---------------------------------------------------------------------------+
##  *** set printing option: true(default) or false
/// $printing_option = true;
/// $dgrid->AllowPrinting($printing_option);
##  *** set exporting option: true(default) or false and relative (virtual) path
##  *** to export directory (relatively to datagrid.class.php file).
##  *** Ex.: "" - if we use current datagrid folder
/// $exporting_option = true;
/// $exporting_directory = "";
/// $dgrid->AllowExporting($exporting_option, $exporting_directory);
/// $exporting_types = array("excel"=>"true", "pdf"=>"true", "xml"=>"true");
/// $dgrid->AllowExportingTypes($exporting_types);
##
##
## +---------------------------------------------------------------------------+
## | 4. Sorting &amp; Paging Settings:                                             |
## +---------------------------------------------------------------------------+
##  *** set sorting option: true(default) or false
/// $sorting_option = true;
/// $dgrid->AllowSorting($sorting_option);
##  *** set paging option: true(default) or false
/// $paging_option = true;
/// $rows_numeration = false;
/// $numeration_sign = "N #";
/// $dgrid->AllowPaging($paging_option, $rows_numeration, $numeration_sign);
##  *** set paging settings
/// $bottom_paging = array("results"=>true, "results_align"=>"left", "pages"=>true, "pages_align"=>"center", "page_size"=>true, "page_size_align"=>"right");
/// $top_paging = array("results"=>true, "results_align"=>"left", "pages"=>true, "pages_align"=>"center", "page_size"=>true, "page_size_align"=>"right");
//  $pages_array = array("10"=>"10", "25"=>"25", "50"=>"50", "100"=>"100", "250"=>"250", "500"=>"500", "1000"=>"1000");
/// $default_page_size = 10;
/// $paging_arrows = array("first"=>"|&amp;lt;&amp;lt;", "previous"=>"&amp;lt;&amp;lt;", "next"=>"&amp;gt;&amp;gt;", "last"=>"&amp;gt;&amp;gt;|");
/// $dgrid->SetPagingSettings($bottom_paging, $top_paging, $pages_array, $default_page_size, $paging_arrows);
##
##
## +---------------------------------------------------------------------------+
## | 5. Filter Settings:                                                       |
## +---------------------------------------------------------------------------+
##  *** set filtering option: true or false(default)
/// $filtering_option = true;
/// $show_search_type = true;
/// $dgrid->AllowFiltering($filtering_option, $show_search_type);
##  *** set aditional filtering settings
##  *** tips: use "," (comma) if you want to make search by some words, for ex.: hello, bye, hi
/// $fill_from_array = array("0"=>"No", "1"=>"Yes");  /* as "value"=>"option" */
/// $filtering_fields = array(
///     "Caption_1"=>array("type"=>"textbox", "table"=>"tableName_1", "field"=>"fieldName_1|,fieldName_2", "show_operator"=>"false", "default_operator"=>"=|<|>|like|%like|like%|%like%|not like", "case_sensitive"=>"false", "comparison_type"=>"string|numeric|binary", "width"=>"", "on_js_event"=>""),
///     "Caption_2"=>array("type"=>"textbox", "autocomplete"=>"false", "handler"=>"modules/autosuggest/test.php", "maxresults"=>"12", "shownoresults"=>"false", "table"=>"tableName_1", "field"=>"fieldName_1|,fieldName_2", "show_operator"=>"false", "default_operator"=>"=|<|>|like|%like|like%|%like%|not like", "case_sensitive"=>"false", "comparison_type"=>"string|numeric|binary", "width"=>"", "on_js_event"=>""),
///     "Caption_3"=>array("type"=>"dropdownlist", "order"=>"ASC|DESC", "table"=>"tableName_2", "field"=>"fieldName_2", "source"=>"self"|$fill_from_array, "show"=>"", "condition"=>"", "show_operator"=>"false", "default_operator"=>"=|<|>|like|%like|like%|%like%|not like", "case_sensitive"=>"false", "comparison_type"=>"string|numeric|binary", "width"=>"", "on_js_event"=>""),
///     "Caption_4"=>array("type"=>"calendar", "table"=>"tableName_3", "field"=>"fieldName_3", "show_operator"=>"false", "default_operator"=>"=|<|>|like|%like|like%|%like%|not like", "case_sensitive"=>"false", "comparison_type"=>"string|numeric|binary", "width"=>"", "on_js_event"=>""),
/// );
/// $dgrid->SetFieldsFiltering($filtering_fields);
##
##
## +---------------------------------------------------------------------------+
## | 6. View Mode Settings:                                                    |
## +---------------------------------------------------------------------------+
##  *** set view mode table properties
/// $vm_table_properties = array("width"=>"90%");
/// $dgrid->SetViewModeTableProperties($vm_table_properties);
##  *** set columns in view mode
##  *** Ex.: "on_js_event"=>"onclick='alert(\"Yes!!!\");'"
##  ***      "barchart" : number format in SELECT SQL must be equal with number format in max_value
/// $fill_from_array = array("0"=>"Banned", "1"=>"Active", "2"=>"Closed", "3"=>"Removed"); /* as "value"=>"option" */
/// $vm_colimns = array(
///     "FieldName_1"=>array("header"=>"Name_A", "type"=>"label",      "align"=>"left", "width"=>"X%|Xpx", "wrap"=>"wrap|nowrap", "text_length"=>"-1", "tooltip"=>"false", "tooltip_type"=>"floating|simple", "case"=>"normal|upper|lower|camel", "summarize"=>"false", "sort_type"=>"string|numeric", "sort_by"=>"", "visible"=>"true", "on_js_event"=>""),
///     "FieldName_2"=>array("header"=>"Name_B", "type"=>"image",      "align"=>"left", "width"=>"X%|Xpx", "wrap"=>"wrap|nowrap", "text_length"=>"-1", "tooltip"=>"false", "tooltip_type"=>"floating|simple", "case"=>"normal|upper|lower|camel", "summarize"=>"false", "sort_type"=>"string|numeric", "sort_by"=>"", "visible"=>"true", "on_js_event"=>"", "target_path"=>"uploads/", "default"=>"default_image.ext", "image_width"=>"50px", "image_height"=>"30px", "magnify"=>"false"),
///     "FieldName_3"=>array("header"=>"Name_C", "type"=>"linktoview", "align"=>"left", "width"=>"X%|Xpx", "wrap"=>"wrap|nowrap", "text_length"=>"-1", "tooltip"=>"false", "tooltip_type"=>"floating|simple", "case"=>"normal|upper|lower|camel", "summarize"=>"false", "sort_type"=>"string|numeric", "sort_by"=>"", "visible"=>"true", "on_js_event"=>""),
///     "FieldName_4"=>array("header"=>"Name_D", "type"=>"linktoedit", "align"=>"left", "width"=>"X%|Xpx", "wrap"=>"wrap|nowrap", "text_length"=>"-1", "tooltip"=>"false", "tooltip_type"=>"floating|simple", "case"=>"normal|upper|lower|camel", "summarize"=>"false", "sort_type"=>"string|numeric", "sort_by"=>"", "visible"=>"true", "on_js_event"=>""),
///     "FieldName_5"=>array("header"=>"Name_E", "type"=>"linktodelete", "align"=>"left", "width"=>"X%|Xpx", "wrap"=>"wrap|nowrap", "text_length"=>"-1", "tooltip"=>"false", "tooltip_type"=>"floating|simple", "case"=>"normal|upper|lower|camel", "summarize"=>"false", "sort_type"=>"string|numeric", "sort_by"=>"", "visible"=>"true", "on_js_event"=>""),
///     "FieldName_6"=>array("header"=>"Name_F", "type"=>"link",       "align"=>"left", "width"=>"X%|Xpx", "wrap"=>"wrap|nowrap", "text_length"=>"-1", "tooltip"=>"false", "tooltip_type"=>"floating|simple", "case"=>"normal|upper|lower|camel", "summarize"=>"false", "sort_type"=>"string|numeric", "sort_by"=>"", "visible"=>"true", "on_js_event"=>"", "field_key"=>"field_name_0"|"field_key_1"=>"field_name_1"|..., "field_data"=>"field_name_2", "rel"=>"", "title"=>"", "target"=>"_new", "href"=>"{0}"),
///     "FieldName_7"=>array("header"=>"Name_G", "type"=>"link",       "align"=>"left", "width"=>"X%|Xpx", "wrap"=>"wrap|nowrap", "text_length"=>"-1", "tooltip"=>"false", "tooltip_type"=>"floating|simple", "case"=>"normal|upper|lower|camel", "summarize"=>"false", "sort_type"=>"string|numeric", "sort_by"=>"", "visible"=>"true", "on_js_event"=>"", "field_key"=>"field_name_0"|"field_key_1"=>"field_name_1"|..., "field_data"=>"field_name_2", "rel"=>"", "title"=>"", "target"=>"_new", "href"=>"mailto:{0}"),
///     "FieldName_8"=>array("header"=>"Name_H", "type"=>"link",       "align"=>"left", "width"=>"X%|Xpx", "wrap"=>"wrap|nowrap", "text_length"=>"-1", "tooltip"=>"false", "tooltip_type"=>"floating|simple", "case"=>"normal|upper|lower|camel", "summarize"=>"false", "sort_type"=>"string|numeric", "sort_by"=>"", "visible"=>"true", "on_js_event"=>"", "field_key"=>"field_name_0"|"field_key_1"=>"field_name_1"|..., "field_data"=>"field_name_2", "rel"=>"", "title"=>"", "target"=>"_new", "href"=>"http://mydomain.com?act={0}&amp;act={1}&amp;code=ABC"),
///     "FieldName_9"=>array("header"=>"Name_I", "type"=>"money",      "align"=>"left", "width"=>"X%|Xpx", "wrap"=>"wrap|nowrap", "text_length"=>"-1", "tooltip"=>"false", "tooltip_type"=>"floating|simple", "case"=>"normal|upper|lower|camel", "summarize"=>"false", "sort_type"=>"string|numeric", "sort_by"=>"", "visible"=>"true", "on_js_event"=>"", "sign"=>"$", "decimal_places"=>"2", "dec_separator"=>".", "thousands_separator"=>","),
///     "FieldName_10"=>array("header"=>"Name_J", "type"=>"password",   "align"=>"left", "width"=>"X%|Xpx", "wrap"=>"wrap|nowrap", "text_length"=>"-1", "tooltip"=>"false", "tooltip_type"=>"floating|simple", "case"=>"normal|upper|lower|camel", "summarize"=>"false", "sort_type"=>"string|numeric", "sort_by"=>"", "visible"=>"true", "on_js_event"=>""),
///     "FieldName_11"=>array("header"=>"Name_K", "type"=>"barchart",   "align"=>"left", "width"=>"X%|Xpx", "wrap"=>"wrap|nowrap", "text_length"=>"-1", "tooltip"=>"false", "tooltip_type"=>"floating|simple", "case"=>"normal|upper|lower|camel", "summarize"=>"false", "sort_type"=>"string|numeric", "sort_by"=>"", "visible"=>"true", "on_js_event"=>"", "field"=>"field_name", "maximum_value"=>"value"),
///     "FieldName_12"=>array("header"=>"Name_L", "type"=>"enum",      "align"=>"left", "width"=>"X%|Xpx", "wrap"=>"wrap|nowrap", "text_length"=>"-1", "tooltip"=>"false", "tooltip_type"=>"floating|simple", "case"=>"normal|upper|lower|camel", "summarize"=>"false", "sort_type"=>"string|numeric", "sort_by"=>"", "visible"=>"true", "on_js_event"=>"", "source"=>$fill_from_array),
/// );
/// $dgrid->SetColumnsInViewMode($vm_colimns);
##  *** set auto-genereted columns in view mode
//  $auto_column_in_view_mode = false;
//  $dgrid->SetAutoColumnsInViewMode($auto_column_in_view_mode);
##
##
## +---------------------------------------------------------------------------+
## | 7. Add/Edit/Details Mode Settings:                                        |
## +---------------------------------------------------------------------------+
##  *** set add/edit mode table properties
/// $em_table_properties = array("width"=>"70%");
/// $dgrid->SetEditModeTableProperties($em_table_properties);
##  *** set details mode table properties
/// $dm_table_properties = array("width"=>"70%");
/// $dgrid->SetDetailsModeTableProperties($dm_table_properties);
##  ***  set settings for add/edit/details modes
//  $table_name  = "table_name";
//  $primary_key = "primary_key";
//  $condition   = "table_name.field = ".$_REQUEST['abc_rid'];
//  $dgrid->SetTableEdit($table_name, $primary_key, $condition);
##  *** set columns in edit mode
##  *** first letter:  r - required, s - simple (not required)
##  *** second letter: t - text(including datetime), n - numeric, a - alphanumeric,
##                     e - email, f - float, y - any, l - login name, z - zipcode,
##                     p - password, i - integer, v - verified, c - checkbox, u - URL
##  *** third letter (optional):
##          for numbers: s - signed, u - unsigned, p - positive, n - negative
##          for strings: u - upper,  l - lower,    n - normal,   y - any
##  *** Ex.: "on_js_event"=>"onclick='alert(\"Yes!!!\");'"
##  *** Ex.: type = textbox|textarea|label|date(yyyy-mm-dd)|datedmy(dd-mm-yyyy)|datetime(yyyy-mm-dd hh:mm:ss)|datetimedmy(dd-mm-yyyy hh:mm:ss)|time(hh:mm:ss)|image|password|enum|print|checkbox
##  *** make sure your WYSIWYG dir has 777 permissions
/// $fill_from_array = array("0"=>"No", "1"=>"Yes", "2"=>"Don't know", "3"=>"My be"); /* as "value"=>"option" */
/// $em_columns = array(
///     "FieldName_1"  =>array("header"=>"Name_A", "type"=>"textbox",    "req_type"=>"rt", "width"=>"210px", "title"=>"", "readonly"=>"false", "maxlength"=>"-1", "default"=>"", "unique"=>"false", "unique_condition"=>"", "visible"=>"true", "on_js_event"=>""),
///     "FieldName_2"  =>array("header"=>"Name_B", "type"=>"textarea",   "req_type"=>"rt", "width"=>"210px", "title"=>"", "readonly"=>"false", "maxlength"=>"-1", "default"=>"", "unique"=>"false", "unique_condition"=>"", "visible"=>"true", "on_js_event"=>"", "edit_type"=>"simple|wysiwyg", "resizable"=>"false", "rows"=>"7", "cols"=>"50"),
///     "FieldName_3"  =>array("header"=>"Name_C", "type"=>"label",      "req_type"=>"rt", "width"=>"210px", "title"=>"", "readonly"=>"false", "maxlength"=>"-1", "default"=>"", "unique"=>"false", "unique_condition"=>"", "visible"=>"true", "on_js_event"=>""),
///     "FieldName_4"  =>array("header"=>"Name_D", "type"=>"date",       "req_type"=>"rt", "width"=>"187px", "title"=>"", "readonly"=>"false", "maxlength"=>"-1", "default"=>"", "unique"=>"false", "unique_condition"=>"", "visible"=>"true", "on_js_event"=>"", "calendar_type"=>"popup|floating"),
///     "FieldName_5"  =>array("header"=>"Name_E", "type"=>"datetime",   "req_type"=>"st", "width"=>"187px", "title"=>"", "readonly"=>"false", "maxlength"=>"-1", "default"=>"", "unique"=>"false", "unique_condition"=>"", "visible"=>"true", "on_js_event"=>"", "calendar_type"=>"popup|floating"),
///     "FieldName_6"  =>array("header"=>"Name_F", "type"=>"time",       "req_type"=>"st", "width"=>"210px", "title"=>"", "readonly"=>"false", "maxlength"=>"-1", "default"=>"", "unique"=>"false", "unique_condition"=>"", "visible"=>"true", "on_js_event"=>""),
///     "FieldName_7"  =>array("header"=>"Name_G", "type"=>"image",      "req_type"=>"st", "width"=>"220px", "title"=>"", "readonly"=>"false", "maxlength"=>"-1", "default"=>"", "unique"=>"false", "unique_condition"=>"", "visible"=>"true", "on_js_event"=>"", "target_path"=>"uploads/", "max_file_size"=>"100000|100K|10M|1G", "image_width"=>"120px", "image_height"=>"90px", "magnify"=>"false", "file_name"=>"", "host"=>"local|remote"),
///     "FieldName_8"  =>array("header"=>"Name_H", "type"=>"password",   "req_type"=>"rp", "width"=>"210px", "title"=>"", "readonly"=>"false", "maxlength"=>"-1", "default"=>"", "unique"=>"false", "unique_condition"=>"", "visible"=>"true", "on_js_event"=>""),
///     "FieldName_9"  =>array("header"=>"Name_I", "type"=>"enum",       "req_type"=>"st", "width"=>"210px", "title"=>"", "readonly"=>"false", "maxlength"=>"-1", "default"=>"", "unique"=>"false", "unique_condition"=>"", "visible"=>"true", "on_js_event"=>"", "source"=>"self"|$fill_from_array, "view_type"=>"dropdownlist(default)|radiobutton", "radiobuttons_alignment"=>"horizontal|vertical", "multiple"=>"false", "multiple_size"=>"4"),
///     "FieldName_10" =>array("header"=>"Name_J", "type"=>"print",      "req_type"=>"st", "width"=>"210px", "title"=>"", "readonly"=>"false", "maxlength"=>"-1", "default"=>"", "unique"=>"false", "unique_condition"=>"", "visible"=>"true", "on_js_event"=>""),
///     "FieldName_11" =>array("header"=>"Name_K", "type"=>"checkbox",   "req_type"=>"st", "width"=>"210px", "title"=>"", "readonly"=>"false", "maxlength"=>"-1", "default"=>"", "unique"=>"false", "unique_condition"=>"", "visible"=>"true", "on_js_event"=>"", "true_value"=>1, "false_value"=>0),
///     "FieldName_12" =>array("header"=>"Name_L", "type"=>"file",       "req_type"=>"st", "width"=>"210px", "title"=>"", "readonly"=>"false", "maxlength"=>"-1", "default"=>"", "unique"=>"false", "unique_condition"=>"", "visible"=>"true", "on_js_event"=>"", "target_path"=>"uploads/", "max_file_size"=>"100000|100K|10M|1G", "file_name"=>"File_Name", "host"=>"local|remote"),
///     "FieldName_13" =>array("header"=>"Name_M", "type"=>"link",       "req_type"=>"st", "width"=>"210px", "title"=>"", "readonly"=>"false", "maxlength"=>"-1", "default"=>"", "unique"=>"false", "unique_condition"=>"", "visible"=>"true", "on_js_event"=>"", "field_key"=>"field_name_0"|"field_key_1"=>"field_name_1"|..., "field_data"=>"field_name_2", "target"=>"_new", "href"=>"http://mydomain.com?act={0}&amp;act={1}&amp;code=ABC"),
///     "FieldName_14" =>array("header"=>"Name_N", "type"=>"foreign_key","req_type"=>"ri", "width"=>"210px", "title"=>"", "readonly"=>"false", "default"=>"", "unique"=>"false", "unique_condition"=>"", "visible"=>"true"),
///     "FieldName_15" =>array("header"=>"",       "type"=>"hidden",     "req_type"=>"st", "default"=>"default_value", "visible"=>"true", "unique"=>"false"),
///     "validator"    =>array("header"=>"Name_N", "type"=>"validator",  "req_type"=>"rv", "width"=>"210px", "title"=>"", "readonly"=>"false", "maxlength"=>"-1", "default"=>"", "visible"=>"true", "on_js_event"=>"", "for_field"=>"", "validation_type"=>"password|email"),
///     "delimiter"    =>array("inner_html"=>"<br>"),
/// );
/// $dgrid->SetColumnsInEditMode($em_columns);
##  *** set auto-genereted columns in edit mode
//  $auto_column_in_edit_mode = false;
//  $dgrid->SetAutoColumnsInEditMode($auto_column_in_edit_mode);
##  *** set foreign keys for add/edit/details modes (if there are linked tables)
##  *** Ex.: "field_name"=>"CONCAT(field1,','field2) as field3"
##  *** Ex.: "condition"=>"TableName_1.FieldName > 'a' AND TableName_1.FieldName < 'c'"
##  *** Ex.: "on_js_event"=>"onclick='alert(\"Yes!!!\");'"
/// $foreign_keys = array(
///     "ForeignKey_1"=>array("table"=>"TableName_1", "field_key"=>"FieldKey_1", "field_name"=>"FieldName_1", "view_type"=>"dropdownlist(default)|radiobutton|textbox", "radiobuttons_alignment"=>"horizontal|vertical", "condition"=>"", "order_by_field"=>"", "order_type"=>"ASC|DESC", "on_js_event"=>""),
///     "ForeignKey_2"=>array("table"=>"TableName_2", "field_key"=>"FieldKey_2", "field_name"=>"FieldName_2", "view_type"=>"dropdownlist(default)|radiobutton|textbox", "radiobuttons_alignment"=>"horizontal|vertical", "condition"=>"", "order_by_field"=>"", "order_type"=>"ASC|DESC", "on_js_event"=>"")
/// );
/// $dgrid->SetForeignKeysEdit($foreign_keys);
##
##
################################################################################


?>

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
 <title>:: Home</title>
 <meta http-equiv=Content-Type content="text/html; charset=utf-8">
 <?
 ## call of this method between HTML <HEAD> elements
// $dgrid->WriteCssClass();
 ?>
</head>

<body>
<?
 ################################################################################
## +---------------------------------------------------------------------------+
## | 8. Bind the DataGrid:                                                     |
## +---------------------------------------------------------------------------+
##  *** bind the DataGrid and draw it on the screen
//  $dgrid->Bind();
 //  ob_end_flush();
 ################################################################################
?>
</body>
</html>

&amp;nbsp;

PHP Scripts for Web Font Viewer

Web Font Viewer is PHP script which is intended for TTF fonts storing on the Internet in form of catalogue categorized according to fonts.
Web Font Viewer is also intended for font exchange and their selling.
Web Font Viewer will be of use for designers which have to change their workplace frequently, and exchange fonts on the Internet. Web Font Viewer allows not to worry about carrying your font set from one PC to another.

Depending on settings chosen by admin Web Font Viewer may be used as:
1. ready font online-shop (font tracing is shown to the guest in form of picture, guest can change its color, size, look through different symbols – but the very font file is not accessible without paid registration)
2. public designer resource for font exchanging between community members.
3. font web-storehouse with convenient manager
4. any other web-solution demanding displaying of non-standard fonts presented at server, their displaying and differentiation of guest rights.

 

<?

 $i_step=intval($HTTP_POST_VARS[step]);
?>
<html>
 <head>
 <title>
 Fontutilities :: Install
 </title>

 <META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=windows-1251">
 <meta name="description" content="Fontutilities - Fontonizer, Advanced Font Catalog, FastFontSet ,Fontutilities - Fontonizer, Advanced Font Catalog, FastFontSet" />
 <meta name="keywords" content="font, Fonts, fonts, download, downloads,
free fonts, font organizer, Fontonizer, catalog, Advanced Font Catalog, FastFontSet, font files, Fontutilities, free, freeware, font, Fonts, fonts, download, downloads,
free fonts, font organizer, Fontonizer, catalog, Advanced Font Catalog, FastFontSet, font files, Fontutilities" />


 <link href="css/template_css.css" rel="stylesheet" type="text/css" />

 </head>

 <body bgcolor="#f2f2f2" leftmargin="0" topmargin="0" rightmargin="0" alink="#ffffff" link="#FFFFFF" vlink="#FFFFFF">
 <table cellpadding="0" cellspacing="0" border="0" height="100%" width="100%">
 <tr valign="top">
 <td colspan=2>
 <table cellpadding="0" cellspacing="0" border="0" width="100%">
 <tr>
 <td width="268" height="63"><a href='index.php'><img  width="268" height="63" src="img/fontutilities.gif" alt="Fontutilities - Fontonizer, Advanced Font Catalog, FastFontSet" ></a></td>
 <td height="63" align="right"><img width="156" height="63" src="img/center.gif" alt="Fontutilities - Fontonizer, Advanced Font Catalog, FastFontSet" ></td>
 <td width="215" height="63" align="right"><img width="215" height="63" src="img/ur_corner.gif" alt="Fontutilities - Fontonizer, Advanced Font Catalog, FastFontSet" ></td>
 </tr>
 </table>
 </td>
 </tr>
 <tr>
 <td height="24" width="100%" align="left" background="img/center1.gif" valign="middle"></td>


 <td style='text-valign:right' background="img/center1.gif"><nobr>
 </td>

 </tr>
 <tr valign='top' height="100%">
 <td bgcolor="#F2F2F2" colspan=2>
 <table cellpadding="0" cellspacing="0" border="0" width="100%">
 <tr>
 <td height='100%' width='190'>
 <table cellpadding='0' cellspacing='0' border='0' height='100%' width='190'>
 <tr valign='top'>
 <td height='100%' width='190' valign='top'>
 <table cellpadding='0' cellspacing='0' border='0' width='190' height='100%'>
 <tr>
 <td width='190' height='38' valign='top' colspan='3'><img src='img/left_01.gif' width='190' height='38'  ></td>
 </tr>
 <tr>
 <td width='10' height='289' valign='top' bgcolor='FCEEB2'><a name='up' id='up'></a></td>
 <td width='178' height='289' valign='top' bgcolor='FCEEB2'>
 <table border=0 cellspacing="0" cellpadding="1">
 <tr>
 <td>
<table>


<tr>
 <td><br><img src="img/indent1.gif" alt="" /><? echo $i_step==0?"<b>":"";?>&amp;nbsp;&amp;nbsp;MySQL options<? echo $i_step==0?"</b>":"";?></td>
</tr>

<tr>
 <td><br><img src="img/indent1.gif" alt="" /><? echo $i_step==1?"<b>":"";?>&amp;nbsp;&amp;nbsp;Other options<? echo $i_step==1?"</b>":"";?></td>
</tr>

<tr>
 <td><br><img src="img/indent1.gif" alt="" /><? echo $i_step==2?"<b>":"";?>&amp;nbsp;&amp;nbsp;Finish<? echo $i_step==2?"</b>":"";?></td>
</tr>



</table>

<br>







 </td>
 </tr>
 </table>
 </td>
 <td width='12' height='289' valign='top' style="background-image:url('img/lp.gif')"><img src='img/left_04.gif' width='12' height='289'></td>
 </tr>
 <tr>
 <td width='190' height='77' valign='top' colspan='3'><img src='img/left_05.gif' width='190' height='77'  ></td>
 </tr>
 <tr>
 <td width='190' bgcolor="#F2F2F2" height='100%' colspan='3'>&amp;nbsp;</td>
 </tr>
 </table>
 </td>
 </tr>
 </table>
 </td>
 <td height='100%' bgcolor='white' colspan=2>
 <table cellpadding='0' border='0' cellspacing='0' height='100%' width='100%'>

 <tr valign='top'>
 <td height='12' width=17 background='img/center2.gif' width='17'></td>
 <td height='12' colspan='3' background='img/center2.gif' width='100%'></td>
 <td height='12' width=17 background='img/center2.gif' width='20'></td>
 </tr>
 <tr valign='top'>
 <td width='17' height='19' ><img src='img/kor01.gif' width='17' height='19'></td>
 <td width='121' height='19' background='img/kor03.gif'><img src='img/kor02.gif' width='121' height='19'  ></td>
 <td height='19'><img src='img/kor03.gif' width='100%' height='19'  ></td>
 <td align=right background='img/kor03.gif' height='19'><img src='img/kor04.gif' width='117' height='19'  ></td>
 <td width='20' height='19'><img src='img/kor05.gif'   width='20' height='19'></td>
 </tr>
 <tr valign='top'>
 <td width='17' height='82' background='img/kor09.gif'><img src='img/kor06.gif' width='17' height='82'  ></td>
 <td width='100%' height='100%' rowspan='3' bgcolor='white' colspan='3'>
 <table cellpadding='0' cellspacing='0' border='0' height='100%' width='100%'>
 <tr valign='top'>
 <td width='100%' height='100%' bgcolor='white'>

<?
if ($i_step==0)
{
 $fcontents = file ('core/config.php');
 $mysql_opt=Array();
 foreach ($fcontents as $row)
 {
 if (preg_match("/b\-\>data\[\"(\w+)\"\]\=\"(.+)\"\;/i",$row,$ar))
 {
 $mysql_opt[$ar[1]]=$ar[2];
 }
 }
?>
<table><form method='POST'>
<input type='hidden' name=step value='1'>
<?

 foreach ($mysql_opt as $key=>$val)
 {
 echo "<tr><th class='menu'><nobr>".htmlspecialchars($key)."</td><td class='menu'><input type='".(($key=='Password')?'password':'text')."' name='".htmlspecialchars($key)."' value='".htmlspecialchars($val)."'></td></tr>";
 }
?>
<tr><td><input type='submit' value='Next'></td></tr>
</form></table>
</>

<?}elseif ($i_step==1)
{

 $errors=0;
 if(mysql_connect($HTTP_POST_VARS["HostName"],$HTTP_POST_VARS["UserName"],$HTTP_POST_VARS["Password"]))
 {
 echo "<font size=+1>Connection ok!</font><br>";
 if (mysql_select_db($HTTP_POST_VARS["DBName"]))
 {
 echo "<font size=+1>Database ".htmlspecialchars($mysql_opt["DBName"])." selected!</font><br>";
 $result=mysql_query("select * from user");
 if (mysql_num_rows($result)>0)
 {
 echo "<font color=red size=+1>Tables allready created!</font><br>";
 }else
 {
 if($fp = fopen ("core/config.php", "w"))
 {
 fputs ($fp,"<?\n\tglobal \$b;\n");
 fputs ($fp,"\t\$b->data[\"DBName\"]=\"".$HTTP_POST_VARS["DBName"]."\";\n");
 fputs ($fp,"\t\$b->data[\"HostName\"]=\"".$HTTP_POST_VARS["HostName"]."\";\n");
 fputs ($fp,"\t\$b->data[\"UserName\"]=\"".$HTTP_POST_VARS["UserName"]."\";\n");
 fputs ($fp,"\t\$b->data[\"Password\"]=\"".$HTTP_POST_VARS["Password"]."\";\n");
 fputs ($fp,"?>");
 fclose ($fp);


 }else
 {
 echo "<font color=red size=+1>Script can't write to 'core/config.php'!<br>Please write connect options to this file manually before click 'next'!</font><br>";
 }

 $file_name=__FILE__;
 $file_path=preg_replace ("/\/install\.php/i", "", $file_name);
$str_sql="
CREATE TABLE `charsets` (
 `name` varchar(30) NOT NULL default '',
 PRIMARY KEY  (`name`)
) TYPE=MyISAM;
INSERT INTO charsets VALUES(\"ARMSCII-8\");
INSERT INTO charsets VALUES(\"CP1125\");
INSERT INTO charsets VALUES(\"CP1133\");
INSERT INTO charsets VALUES(\"CP1250\");
INSERT INTO charsets VALUES(\"CP1251\");
INSERT INTO charsets VALUES(\"CP1252\");
INSERT INTO charsets VALUES(\"CP1253\");
INSERT INTO charsets VALUES(\"CP1254\");
INSERT INTO charsets VALUES(\"CP1255\");
INSERT INTO charsets VALUES(\"CP1256\");
INSERT INTO charsets VALUES(\"CP1257\");
INSERT INTO charsets VALUES(\"CP1258\");
INSERT INTO charsets VALUES(\"CP437\");
INSERT INTO charsets VALUES(\"CP737\");
INSERT INTO charsets VALUES(\"CP775\");
INSERT INTO charsets VALUES(\"CP850\");
INSERT INTO charsets VALUES(\"CP852\");
INSERT INTO charsets VALUES(\"CP855\");
INSERT INTO charsets VALUES(\"CP857\");
INSERT INTO charsets VALUES(\"CP860\");
INSERT INTO charsets VALUES(\"CP861\");
INSERT INTO charsets VALUES(\"CP862\");
INSERT INTO charsets VALUES(\"CP863\");
INSERT INTO charsets VALUES(\"CP864\");
INSERT INTO charsets VALUES(\"CP865\");
INSERT INTO charsets VALUES(\"CP866\");
INSERT INTO charsets VALUES(\"CP869\");
INSERT INTO charsets VALUES(\"CP874\");
INSERT INTO charsets VALUES(\"Georgian-Academy\");
INSERT INTO charsets VALUES(\"Georgian-PS\");
INSERT INTO charsets VALUES(\"HP-ROMAN8\");
INSERT INTO charsets VALUES(\"ISO-8859-1\");
INSERT INTO charsets VALUES(\"ISO-8859-10\");
INSERT INTO charsets VALUES(\"ISO-8859-13\");
INSERT INTO charsets VALUES(\"ISO-8859-14\");
INSERT INTO charsets VALUES(\"ISO-8859-15\");
INSERT INTO charsets VALUES(\"ISO-8859-16\");
INSERT INTO charsets VALUES(\"ISO-8859-2\");
INSERT INTO charsets VALUES(\"ISO-8859-3\");
INSERT INTO charsets VALUES(\"ISO-8859-4\");
INSERT INTO charsets VALUES(\"ISO-8859-5\");
INSERT INTO charsets VALUES(\"ISO-8859-7\");
INSERT INTO charsets VALUES(\"ISO-8859-8\");
INSERT INTO charsets VALUES(\"ISO-8859-9\");
INSERT INTO charsets VALUES(\"KOI8-R\");
INSERT INTO charsets VALUES(\"KOI8-T\");
INSERT INTO charsets VALUES(\"KOI8-U\");
INSERT INTO charsets VALUES(\"MacCyrillic\");
INSERT INTO charsets VALUES(\"Macintosh\");
INSERT INTO charsets VALUES(\"TCVN\");
INSERT INTO charsets VALUES(\"TIS-620\");
INSERT INTO charsets VALUES(\"UTF-8\");
INSERT INTO charsets VALUES(\"VISCII\");


CREATE TABLE `config` (
 `id` int(10) unsigned NOT NULL auto_increment,
 `name` varchar(127) binary NOT NULL default '',
 `val` varchar(255) binary NOT NULL default '',
 `to_user` enum('yes','no') NOT NULL default 'yes',
 PRIMARY KEY  (`id`)
) TYPE=MyISAM;
INSERT INTO config VALUES(\"1\",\"max_width\",\"1200\",\"no\");
INSERT INTO config VALUES(\"2\",\"max_height\",\"200\",\"no\");
INSERT INTO config VALUES(\"3\",\"charset\",\"ISO-8859-1\",\"yes\");
INSERT INTO config VALUES(\"4\",\"lang\",\"en\",\"yes\");
INSERT INTO config VALUES(\"5\",\"font_color\",\"000000\",\"yes\");
INSERT INTO config VALUES(\"6\",\"font_back_color\",\"ffffff\",\"yes\");
INSERT INTO config VALUES(\"7\",\"font_size\",\"20\",\"yes\");
INSERT INTO config VALUES(\"8\",\"font_text\",\"Sample Text\",\"yes\");
INSERT INTO config VALUES(\"9\",\"max_font_size\",\"524288\",\"yes\");
INSERT INTO config VALUES(\"10\",\"all_font_size\",\"1048576\",\"yes\");
INSERT INTO config VALUES(\"11\",\"min_height\",\"20\",\"no\");
INSERT INTO config VALUES(\"12\",\"temp_file_life\",\"1\",\"no\");
INSERT INTO config VALUES(\"13\",\"md5_add\",\"\",\"no\");
INSERT INTO config VALUES(\"15\",\"guest_access\",\"yes\",\"no\");
INSERT INTO config VALUES(\"16\",\"is_admin\",\"no\",\"yes\");
INSERT INTO config VALUES(\"17\",\"save_cookie\",\"yes\",\"yes\");
INSERT INTO config VALUES(\"18\",\"cur_group\",\"0\",\"yes\");
INSERT INTO config VALUES(\"19\",\"cur_font\",\"0\",\"yes\");
INSERT INTO config VALUES(\"20\",\"font_dir\",\"\",\"no\");
INSERT INTO config VALUES(\"21\",\"image_dir\",\"\",\"no\");
INSERT INTO config VALUES(\"22\",\"html_image_dir\",\"images\",\"no\");
INSERT INTO config VALUES(\"23\",\"max_font_height\",\"75\",\"no\");
INSERT INTO config VALUES(\"24\",\"border_width\",\"1\",\"no\");
INSERT INTO config VALUES(\"25\",\"sq_one_char_width\",\"170\",\"no\");
INSERT INTO config VALUES(\"26\",\"sq_all_char_width\",\"40\",\"no\");
INSERT INTO config VALUES(\"27\",\"sq_char_font_size\",\"100\",\"no\");
INSERT INTO config VALUES(\"28\",\"sq_numer_size\",\"35\",\"no\");
INSERT INTO config VALUES(\"29\",\"sq_numer_mid_space\",\"2\",\"no\");
INSERT INTO config VALUES(\"30\",\"sq_numer_color\",\"000000\",\"no\");
INSERT INTO config VALUES(\"31\",\"sq_numer_font\",\"31\",\"no\");
INSERT INTO config VALUES(\"32\",\"sq_font_color\",\"353e48\",\"no\");
INSERT INTO config VALUES(\"33\",\"sq_line_color\",\"000000\",\"no\");
INSERT INTO config VALUES(\"34\",\"min_width\",\"90\",\"no\");
INSERT INTO config VALUES(\"35\",\"sq_back_color\",\"fceeb2\",\"no\");
INSERT INTO config VALUES(\"36\",\"http_link\",\"\",\"no\");
INSERT INTO config VALUES(\"37\",\"email_template\",\"From: email@email.com\r\nTo: [email]\r\nSubject: Web Font Viewer account info\r\n\r\nWelcome to Web Font Viewer:\r\n[link]\r\nlogin [login]\r\npassword [password]\",\"no\");
INSERT INTO config VALUES(\"38\",\"buy_link\",\"sample_link?font=[font_param]&amp;font_name=[font_name]&amp;font_id=[font_id]\",\"no\");
INSERT INTO config VALUES(\"39\",\"is_buy\",\"yes\",\"no\");
INSERT INTO config VALUES(\"40\",\"self_reg\",\"no\",\"no\");
INSERT INTO config VALUES(\"41\",\"reg_template\",\"From: email@email.com\r\nTo: [email]\r\nSubject: Web Font Viewer Confirmation\r\n\r\nConfirmation link for creating account ([login]):\r\n[link]\",\"no\");


CREATE TABLE `font_files` (
 `id` int(10) unsigned NOT NULL auto_increment,
 `size` int(10) unsigned NOT NULL default '0',
 `counter` int(10) unsigned NOT NULL default '0',
 PRIMARY KEY  (`id`)
) TYPE=MyISAM;


CREATE TABLE `font_groups` (
 `id` int(10) unsigned NOT NULL auto_increment,
 `name` varchar(127) binary NOT NULL default '',
 PRIMARY KEY  (`id`)
) TYPE=MyISAM;


CREATE TABLE `fonts` (
 `id` int(10) unsigned NOT NULL auto_increment,
 `group_id` int(10) unsigned NOT NULL default '0',
 `name` varchar(127) binary NOT NULL default '',
 `filename` varchar(127) binary NOT NULL default '',
 `file_id` int(10) unsigned NOT NULL default '0',
 `guest_download` enum('yes','no') NOT NULL default 'yes',
 `param` varchar(128) binary NOT NULL default '',
 PRIMARY KEY  (`id`)
) TYPE=MyISAM;


CREATE TABLE `temp_files` (
 `id` int(10) unsigned NOT NULL auto_increment,
 `path_md5` varchar(32) binary NOT NULL default '',
 `date` timestamp(14) NOT NULL,
 `width` int(10) unsigned NOT NULL default '0',
 `height` int(10) unsigned NOT NULL default '0',
 PRIMARY KEY  (`id`),
 KEY `path_md5` (`path_md5`),
 KEY `date` (`date`)
) TYPE=MyISAM;



CREATE TABLE `user` (
 `id` int(10) unsigned NOT NULL auto_increment,
 `login` varchar(20) NOT NULL default '',
 `password` varchar(32) binary NOT NULL default '',
 `status` enum('on','off') NOT NULL default 'on',
 `email` varchar(127) binary NOT NULL default '',
 `confirm` varchar(32) binary NOT NULL default '',
 PRIMARY KEY  (`id`)
) TYPE=MyISAM;



CREATE TABLE `user_config` (
 `id` int(10) unsigned NOT NULL auto_increment,
 `user_id` int(10) unsigned NOT NULL default '0',
 `name` varchar(127) binary NOT NULL default '',
 `val` varchar(255) binary NOT NULL default '',
 PRIMARY KEY  (`id`)
) TYPE=MyISAM;


CREATE TABLE `user_font_groups` (
 `id` int(10) unsigned NOT NULL auto_increment,
 `user_id` int(10) unsigned NOT NULL default '0',
 `name` varchar(128) binary NOT NULL default '',
 `opened` enum('yes','no') NOT NULL default 'no',
 `sys_group_id` int(10) unsigned NOT NULL default '0',
 PRIMARY KEY  (`id`)
) TYPE=MyISAM;


CREATE TABLE `user_font_links` (
 `id` int(10) unsigned NOT NULL auto_increment,
 `group_id` int(10) unsigned NOT NULL default '0',
 `sys_font_id` int(10) unsigned NOT NULL default '0',
 `name` varchar(127) binary NOT NULL default '',
 `filename` varchar(127) binary NOT NULL default '',
 `file_id` int(10) unsigned NOT NULL default '0',
 `is_direct_link` enum('yes','no') NOT NULL default 'no',
 `user_id` int(10) unsigned NOT NULL default '0',
 PRIMARY KEY  (`id`)
) TYPE=MyISAM
 "
;

$sql_commands=split (";", $str_sql);
foreach ($sql_commands as $sql_command)
{
 mysql_query($sql_command);
}


?>
<br>

<table><form method='POST'>
<input type='hidden' name=step value='2'>
<script language="javascript">document.write("<input type='hidden' name='http_link' value='"+window.location+"'>");</script>    <tr><th class='menu'><nobr>Admin login</td><td class='menu'>admin</td></tr>
 <tr><th class='menu'><nobr>Admin password</td><td class='menu'><input type='password' name='admin_password' value='root'> (default 'root')</td></tr>
 <tr><th class='menu'><nobr>Font dir</td><td class='menu'><input type='text' name='font_dir' value='<? echo rand();?>'></td></tr>

<tr><td><input type='submit' value='Next'></td></tr>
</form></table>
<?



 }
 }else
 {
 echo "<font size=+1 color=red>Can't find database ".htmlspecialchars($mysql_opt["DBName"])."!</font><br>";
 }

 }else
 {
 echo "<font size=+1 color=red>Can't create MySQL connection!</font><br>";
 $errors++;
 }

}elseif ($i_step==2)
{
 require("core/bufferator.php");
 require("core/config.php");
 if(mysql_connect($b->data["HostName"],$b->data["UserName"],$b->data["Password"]))
 {
 mysql_select_db($b->data["DBName"]);


 if (strlen($HTTP_POST_VARS["admin_password"])==0)
 {
 echo "<font color=red size=+1>Empty password!</font><br>";
 }else
 {
 $result=mysql_query("INSERT INTO user VALUES('1','admin',MD5('".mysql_escape_string($HTTP_POST_VARS["admin_password"])."'),'on','','');");

 $user_id=mysql_insert_id();
 $result=mysql_query("SELECT * from config where to_user='yes'");
 $c_ar=Array();
 if (mysql_num_rows($result)>0)
 {
 while ($g_ar=mysql_fetch_assoc($result))
 {
 $c_ar[]=$g_ar;
 }
 }
 foreach ($c_ar as $key=>$val)
 {
 if ($val[name]=='is_admin')
 {
 $result=mysql_query("insert into user_config (user_id,name,val) VALUES ($user_id,'is_admin','yes')");
 }else
 {
 $result=mysql_query("insert into user_config (user_id,name,val) VALUES ($user_id,'".mysql_escape_string($val[name])."','".mysql_escape_string($val[val])."')");
 }
 }



 $file_name=__FILE__;
 $file_path=preg_replace ("/\/install\.php/i", "", $file_name);
 $font_dir=preg_replace ("/\W/i", "", $HTTP_POST_VARS["font_dir"]);
 if (strlen($font_dir)==0)
 {
 echo "<font color=red size=+1>Empty font directory name!</font><br>";
 }else
 {
 if (is_dir("$file_path/$font_dir"))
 {
 echo "<font size=+1>Directory $file_path/$font_dir allready exist!</font><br>";
 }else
 {
 if (is_dir("$file_path/font_dir"))
 {
 if (!rename("$file_path/font_dir","$file_path/$font_dir"))
 {
 echo "<font size=+1>Can't rename $file_path/font_dir to $file_path/font_dir!<br>Please rename it manually!</font><br>";
 }
 }else
 {
 if (mkdir ("$file_path/$font_dir", 0777))
 {
 echo "<font size=+1>Directory $file_path/$font_dir created!</font><br>";
 }else
 {
 echo "<font color=red size=+1>Script can't create dir '$file_path/$font_dir'!<br>Please create it manually!</font><br>";
 }
 }
 }
 $r_l=$HTTP_POST_VARS["http_link"];
 $r_l=preg_replace ("/install\.php/i", "", $r_l);

 $result=mysql_query("UPDATE config set val='$file_path/$font_dir' where name='font_dir';");
 $result=mysql_query("UPDATE config set val='$file_path/images' where name='image_dir';");
 $result=mysql_query("UPDATE config set val='".rand()."' where name='md5_add';");
 $result=mysql_query("UPDATE config set val='$r_l' where name='http_link';");

 if (unlink(__FILE__))
 {
 echo "<font size=+1>file install.php deleted!</font><br>";
 }else
 {
 echo "<font color=red size=+1>Script can't delete $file_path/install.php, please delete file manually!</font><br>";
 }
 echo "<font size=+1>Installation finished!</font><br><br>";
 echo "<a href='.'>Run Web Font Viewer</a>";
 }

 }

 }else
 {
 echo "<font color=red size=+1>Script can't connect to MySql, please check file 'core/config.php'!</font><br>";
 }



}





?>







 </td>
 </tr>
 </table>
 </td>
 <td width='20' height='82' background='img/kor10.gif'><img src='img/kor08.gif' width='20' height='82'  ></td>
 </tr>
 <tr>
 <td width='17' height='100%' background='img/kor09.gif'><img src='img/kor09.gif' width='17' height='100%'  ></td>
 <td width='20' height='100%' background='img/kor10.gif'><img src='img/kor10.gif' width='20' height='100%'></td>
 </tr>
 <tr valign='bottom'>
 <td width='17' height='126' background='img/kor09.gif'><img src='img/kor11.gif' width='17' height='126'></td>
 <td width='20' height='126' background='img/kor10.gif'><img src='img/kor12.gif' width='20' height='126'></td>
 </tr>
 <tr>
 <td width='17' height='46'><img src='img/kor13.gif' width='17' height='46'></td>
 <td width='121' height='46' background='img/kor15.gif'><img src='img/kor14.gif' width='121' height='46'></td>
 <td width='55%' height='46'><img src='img/kor15.gif' width='100%' height='46'></td>
 <td align=right height='46' background='img/kor15.gif'><img src='img/kor16.gif' width='117' height='46'></td>
 <td width='20' height='46' ><img src='img/kor17.gif' width='20' height='46'></td>
 </tr>
 </table>
 </td>
 </tr>
 </table>
 </td>
 </tr>
 <tr>
 <td colspan=2>
 <table cellpadding="0" cellspacing="0" border="0" width="100%">
 <tr>
 <td height="31" background="img/niz.gif"><p>Designed by <a href="http://www.vibe.ru/">Vibe</a>  &#169;  2004</p></td>
 <td height="31" background="img/niz.gif" align="center"></td>
 <td height="31" background="img/niz.gif" align="right"><p>Fast Reports, Inc. &#169; 2000-2004</p></td>
 </tr>
 </table>
 </td>
 </tr>
 </table>
 </body>
</html>

Atrise PHP Script for Debugger

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 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.

 

<?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;

PHP Scripts for ApPHP DataForm

PHP DataForm script is a simple tool for creating HTML Forms with ease. It was especially designed for web developers, who do not want to spend excessive time on creating Forms in HTML or through PHP, but want to use a first-class OOP backend. Expandable structure, wise usage of common PHP-Patterns and continuous support make this a must for your PHP-swissarmy-knife. The PHP DataForm is an excellent tool for web developers who: – Look for a small, smart and powerful form-creating tool; – Want to improve existing web applications – Plan to use the power of OOP in new projects.

PHP DataForm – data-bound form control. PHP DataForm script is a simple tool for creating HTML Forms with ease. It was especially designed for web developers, who do not want to spend excessive time on creating Forms in HTML or through PHP, but want to use a first-class OOP backend.

 

 

<?php

/** @class: InputFilter (PHP5-Strict with comments)
 * @project: PHP Input Filter
 * @date: 10-05-2005
 * @version: 1.2.2_php5
 * @author: Daniel Morris
 * @contributors: Gianpaolo Racca, Ghislain Picard, Marco Wandschneider, Chris Tobin and Andrew Eddie.
 * @copyright: Daniel Morris
 * @email: dan@rootcube.com
 * @license: GNU General Public License (GPL)
 */

class InputFilter {
 protected $tagsArray;    // default = empty array
 protected $attrArray;    // default = empty array

 protected $tagsMethod;    // default = 0
 protected $attrMethod;    // default = 0

 protected $xssAuto;     // default = 1
 protected $tagBlacklist = array('applet', 'body', 'bgsound', 'base', 'basefont', 'embed', 'frame', 'frameset', 'head', 'html', 'id', 'iframe', 'ilayer', 'layer', 'link', 'meta', 'name', 'object', 'script', 'style', 'title', 'xml');
 protected $attrBlacklist = array('action', 'background', 'codebase', 'dynsrc', 'lowsrc');  // also will strip ALL event handlers

 /**
 * Constructor for inputFilter class. Only first parameter is required.
 * @access constructor
 * @param Array $tagsArray - list of user-defined tags
 * @param Array $attrArray - list of user-defined attributes
 * @param int $tagsMethod - 0= allow just user-defined, 1= allow all but user-defined
 * @param int $attrMethod - 0= allow just user-defined, 1= allow all but user-defined
 * @param int $xssAuto - 0= only auto clean essentials, 1= allow clean blacklisted tags/attr
 */

 public function __construct($tagsArray = array(), $attrArray = array(), $tagsMethod = 0, $attrMethod = 0, $xssAuto = 1) {
 // make sure user defined arrays are in lowercase
 for ($i = 0; $i < count($tagsArray); $i++) $tagsArray[$i] = strtolower($tagsArray[$i]);
 for ($i = 0; $i < count($attrArray); $i++) $attrArray[$i] = strtolower($attrArray[$i]);
 // assign to member vars
 $this->tagsArray = (array) $tagsArray;
 $this->attrArray = (array) $attrArray;
 $this->tagsMethod = $tagsMethod;
 $this->attrMethod = $attrMethod;
 $this->xssAuto = $xssAuto;
 }

 /**
 * Method to be called by another php script. Processes for XSS and specified bad code.
 * @access public
 * @param Mixed $source - input string/array-of-string to be 'cleaned'
 * @return String $source - 'cleaned' version of input parameter
 */

 public function process($source) {
 // clean all elements in this array
 if (is_array($source)) {
 foreach($source as $key => $value)
 // filter element for XSS and other 'bad' code etc.
 if (is_string($value)) $source[$key] = $this->remove($this->decode($value));
 return $source;
 // clean this string
 } else if (is_string($source)) {
 // filter source for XSS and other 'bad' code etc.
 return $this->remove($this->decode($source));
 // return parameter as given
 } else return $source;
 }

 /**
 * Internal method to iteratively remove all unwanted tags and attributes
 * @access protected
 * @param String $source - input string to be 'cleaned'
 * @return String $source - 'cleaned' version of input parameter
 */

 protected function remove($source) {
 $loopCounter=0;
 // provides nested-tag protection
 while($source != $this->filterTags($source)) {
 $source = $this->filterTags($source);
 $loopCounter++;
 }
 return $source;
 }

 /**
 * Internal method to strip a string of certain tags
 * @access protected
 * @param String $source - input string to be 'cleaned'
 * @return String $source - 'cleaned' version of input parameter
 */

 protected function filterTags($source) {
 // filter pass setup
 $preTag = NULL;
 $postTag = $source;
 // find initial tag's position
 $tagOpen_start = strpos($source, '<');
 // interate through string until no tags left
 while($tagOpen_start !== FALSE) {
 // process tag interatively
 $preTag .= substr($postTag, 0, $tagOpen_start);
 $postTag = substr($postTag, $tagOpen_start);
 $fromTagOpen = substr($postTag, 1);
 // end of tag
 $tagOpen_end = strpos($fromTagOpen, '>');
 if ($tagOpen_end === false) break;
 // next start of tag (for nested tag assessment)
 $tagOpen_nested = strpos($fromTagOpen, '<');
 if (($tagOpen_nested !== false) &amp;&amp; ($tagOpen_nested < $tagOpen_end)) {
 $preTag .= substr($postTag, 0, ($tagOpen_nested+1));
 $postTag = substr($postTag, ($tagOpen_nested+1));
 $tagOpen_start = strpos($postTag, '<');
 continue;
 }
 $tagOpen_nested = (strpos($fromTagOpen, '<') + $tagOpen_start + 1);
 $currentTag = substr($fromTagOpen, 0, $tagOpen_end);
 $tagLength = strlen($currentTag);
 if (!$tagOpen_end) {
 $preTag .= $postTag;
 $tagOpen_start = strpos($postTag, '<');
 }
 // iterate through tag finding attribute pairs - setup
 $tagLeft = $currentTag;
 $attrSet = array();
 $currentSpace = strpos($tagLeft, ' ');
 // is end tag
 if (substr($currentTag, 0, 1) == "/") {
 $isCloseTag = TRUE;
 list($tagName) = explode(' ', $currentTag);
 $tagName = substr($tagName, 1);
 // is start tag
 } else {
 $isCloseTag = FALSE;
 list($tagName) = explode(' ', $currentTag);
 }
 // excludes all "non-regular" tagnames OR no tagname OR remove if xssauto is on and tag is blacklisted
 if ((!preg_match("/^[a-z][a-z0-9]*$/i",$tagName)) || (!$tagName) || ((in_array(strtolower($tagName), $this->tagBlacklist)) &amp;&amp; ($this->xssAuto))) {
 $postTag = substr($postTag, ($tagLength + 2));
 $tagOpen_start = strpos($postTag, '<');
 // don't append this tag
 continue;
 }
 // this while is needed to support attribute values with spaces in!
 while ($currentSpace !== FALSE) {
 $fromSpace = substr($tagLeft, ($currentSpace+1));
 $nextSpace = strpos($fromSpace, ' ');
 $openQuotes = strpos($fromSpace, '"');
 $closeQuotes = strpos(substr($fromSpace, ($openQuotes+1)), '"') + $openQuotes + 1;
 // another equals exists
 if (strpos($fromSpace, '=') !== FALSE) {
 // opening and closing quotes exists
 if (($openQuotes !== FALSE) &amp;&amp; (strpos(substr($fromSpace, ($openQuotes+1)), '"') !== FALSE))
 $attr = substr($fromSpace, 0, ($closeQuotes+1));
 // one or neither exist
 else $attr = substr($fromSpace, 0, $nextSpace);
 // no more equals exist
 } else $attr = substr($fromSpace, 0, $nextSpace);
 // last attr pair
 if (!$attr) $attr = $fromSpace;
 // add to attribute pairs array
 $attrSet[] = $attr;
 // next inc
 $tagLeft = substr($fromSpace, strlen($attr));
 $currentSpace = strpos($tagLeft, ' ');
 }
 // appears in array specified by user
 $tagFound = in_array(strtolower($tagName), $this->tagsArray);
 // remove this tag on condition
 if ((!$tagFound &amp;&amp; $this->tagsMethod) || ($tagFound &amp;&amp; !$this->tagsMethod)) {
 // reconstruct tag with allowed attributes
 if (!$isCloseTag) {
 $attrSet = $this->filterAttr($attrSet);
 $preTag .= '<' . $tagName;
 for ($i = 0; $i < count($attrSet); $i++)
 $preTag .= ' ' . $attrSet[$i];
 // reformat single tags to XHTML
 if (strpos($fromTagOpen, "</" . $tagName)) $preTag .= '>';
 else $preTag .= ' />';
 // just the tagname
 } else $preTag .= '</' . $tagName . '>';
 }
 // find next tag's start
 $postTag = substr($postTag, ($tagLength + 2));
 $tagOpen_start = strpos($postTag, '<');
 }
 // append any code after end of tags
 $preTag .= $postTag;
 return $preTag;
 }

 /**
 * Internal method to strip a tag of certain attributes
 * @access protected
 * @param Array $attrSet
 * @return Array $newSet
 */

 protected function filterAttr($attrSet) {
 $newSet = array();
 // process attributes
 for ($i = 0; $i <count($attrSet); $i++) {
 // skip blank spaces in tag
 if (!$attrSet[$i]) continue;
 // split into attr name and value
 $attrSubSet = explode('=', trim($attrSet[$i]));
 list($attrSubSet[0]) = explode(' ', $attrSubSet[0]);
 // removes all "non-regular" attr names AND also attr blacklisted
 if ((!eregi("^[a-z]*$",$attrSubSet[0])) || (($this->xssAuto) &amp;&amp; ((in_array(strtolower($attrSubSet[0]), $this->attrBlacklist)) || (substr($attrSubSet[0], 0, 2) == 'on'))))
 continue;
 // xss attr value filtering
 if ($attrSubSet[1]) {
 // strips unicode, hex, etc
 $attrSubSet[1] = str_replace('&amp;#', '', $attrSubSet[1]);
 // strip normal newline within attr value
 $attrSubSet[1] = preg_replace('/\s+/', '', $attrSubSet[1]);
 // strip double quotes
 $attrSubSet[1] = str_replace('"', '', $attrSubSet[1]);
 // [requested feature] convert single quotes from either side to doubles (Single quotes shouldn't be used to pad attr value)
 if ((substr($attrSubSet[1], 0, 1) == "'") &amp;&amp; (substr($attrSubSet[1], (strlen($attrSubSet[1]) - 1), 1) == "'"))
 $attrSubSet[1] = substr($attrSubSet[1], 1, (strlen($attrSubSet[1]) - 2));
 // strip slashes
 $attrSubSet[1] = stripslashes($attrSubSet[1]);
 }
 // auto strip attr's with "javascript:
 if (    ((strpos(strtolower($attrSubSet[1]), 'expression') !== false) &amp;&amp;    (strtolower($attrSubSet[0]) == 'style')) ||
 (strpos(strtolower($attrSubSet[1]), 'javascript:') !== false) ||
 (strpos(strtolower($attrSubSet[1]), 'behaviour:') !== false) ||
 (strpos(strtolower($attrSubSet[1]), 'vbscript:') !== false) ||
 (strpos(strtolower($attrSubSet[1]), 'mocha:') !== false) ||
 (strpos(strtolower($attrSubSet[1]), 'livescript:') !== false)
 ) continue;

 // if matches user defined array
 $attrFound = in_array(strtolower($attrSubSet[0]), $this->attrArray);
 // keep this attr on condition
 if ((!$attrFound &amp;&amp; $this->attrMethod) || ($attrFound &amp;&amp; !$this->attrMethod)) {
 // attr has value
 if ($attrSubSet[1]) $newSet[] = $attrSubSet[0] . '="' . $attrSubSet[1] . '"';
 // attr has decimal zero as value
 else if ($attrSubSet[1] == "0") $newSet[] = $attrSubSet[0] . '="0"';
 // reformat single attributes to XHTML
 else $newSet[] = $attrSubSet[0] . '="' . $attrSubSet[0] . '"';
 }
 }
 return $newSet;
 }

 /**
 * Try to convert to plaintext
 * @access protected
 * @param String $source
 * @return String $source
 */

 protected function decode($source) {
 // url decode
 $source = html_entity_decode($source, ENT_QUOTES, "ISO-8859-1");
 // convert decimal
 $source = preg_replace('/&amp;#(\d+);/me',"chr(\\1)", $source);                // decimal notation
 // convert hex
 $source = preg_replace('/&amp;#x([a-f0-9]+);/mei',"chr(0x\\1)", $source);    // hex notation
 return $source;
 }

 /**
 * Method to be called by another php script. Processes for SQL injection
 * @access public
 * @param Mixed $source - input string/array-of-string to be 'cleaned'
 * @param Buffer $connection - An open MySQL connection
 * @return String $source - 'cleaned' version of input parameter
 */

 public function safeSQL($source, &amp;$connection) {
 // clean all elements in this array
 if (is_array($source)) {
 foreach($source as $key => $value)
 // filter element for SQL injection
 if (is_string($value)) $source[$key] = $this->quoteSmart($this->decode($value), $connection);
 return $source;
 // clean this string
 } else if (is_string($source)) {
 // filter source for SQL injection
 if (is_string($source)) return $this->quoteSmart($this->decode($source), $connection);
 // return parameter as given
 } else return $source;
 }

 /**
 * @author Chris Tobin
 * @author Daniel Morris
 * @access protected
 * @param String $source
 * @param Resource $connection - An open MySQL connection
 * @return String $source
 */

 protected function quoteSmart($source, &amp;$connection) {
 // strip slashes
 if (get_magic_quotes_gpc()) $source = stripslashes($source);
 // quote both numeric and text
 $source = $this->escapeString($source, $connection);
 return $source;
 }

 /**
 * @author Chris Tobin
 * @author Daniel Morris
 * @access protected
 * @param String $source
 * @param Resource $connection - An open MySQL connection
 * @return String $source
 */

 protected function escapeString($string, &amp;$connection) {
 // depreciated function
 if (version_compare(phpversion(),"4.3.0", "<")) mysql_escape_string($string);
 // current function
 else mysql_real_escape_string($string);
 return $string;
 }
}

?>

&amp;nbsp;