Fifth pass at adding key files
This commit is contained in:
339
site/fitters/class/mysql.class.php
Normal file
339
site/fitters/class/mysql.class.php
Normal file
@ -0,0 +1,339 @@
|
||||
<?PHP
|
||||
###########################################
|
||||
#-----------Users login system------------#
|
||||
###########################################
|
||||
/*=========================================\
|
||||
Author : Mohammed Ahmed(M@@king) \\
|
||||
Version : 1.0 \\
|
||||
Date Created: Aug 20 2005 \\
|
||||
---------------------------- \\
|
||||
Last Update: August 22 2005 \\
|
||||
---------------------------- \\
|
||||
Country : Palestine \\
|
||||
City : Gaza \\
|
||||
E-mail : m@maaking.com \\
|
||||
MSN : m@maaking.com \\
|
||||
AOL-IM : maa2pal \\
|
||||
WWW : http://www.maaking.com \\
|
||||
Mobile/SMS : 00972-599-622235 \\
|
||||
\\
|
||||
===========================================\
|
||||
------------------------------------------*/
|
||||
if (eregi("mysql.class.php", $_SERVER['SCRIPT_NAME'])) {
|
||||
Header("Location: index.php"); die();
|
||||
}
|
||||
//db class
|
||||
if(!defined("SQL_LAYER"))
|
||||
{
|
||||
|
||||
define("SQL_LAYER","mysql");
|
||||
|
||||
class sql_db
|
||||
{
|
||||
|
||||
var $db_connect_id;
|
||||
var $query_result;
|
||||
var $row = array();
|
||||
var $rowset = array();
|
||||
var $num_queries = 0;
|
||||
|
||||
//
|
||||
// Constructor
|
||||
//
|
||||
function sql_db($sqlserver, $sqluser, $sqlpassword, $database, $persistency = true)
|
||||
{
|
||||
|
||||
$this->persistency = $persistency;
|
||||
$this->user = $sqluser;
|
||||
$this->password = $sqlpassword;
|
||||
$this->server = $sqlserver;
|
||||
$this->dbname = $database;
|
||||
|
||||
if($this->persistency)
|
||||
{
|
||||
$this->db_connect_id = @mysql_pconnect($this->server, $this->user, $this->password);
|
||||
}
|
||||
else
|
||||
{
|
||||
$this->db_connect_id = @mysql_connect($this->server, $this->user, $this->password);
|
||||
}
|
||||
if($this->db_connect_id)
|
||||
{
|
||||
if($database != "")
|
||||
{
|
||||
$this->dbname = $database;
|
||||
$dbselect = @mysql_select_db($this->dbname);
|
||||
if(!$dbselect)
|
||||
{
|
||||
@mysql_close($this->db_connect_id);
|
||||
$this->db_connect_id = $dbselect;
|
||||
}
|
||||
}
|
||||
return $this->db_connect_id;
|
||||
}
|
||||
else
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
// Other base methods
|
||||
//
|
||||
function sql_close()
|
||||
{
|
||||
if($this->db_connect_id)
|
||||
{
|
||||
if($this->query_result)
|
||||
{
|
||||
@mysql_free_result($this->query_result);
|
||||
}
|
||||
$result = @mysql_close($this->db_connect_id);
|
||||
return $result;
|
||||
}
|
||||
else
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
// Base query method
|
||||
//
|
||||
function sql_query($query = "", $transaction = FALSE)
|
||||
{
|
||||
// Remove any pre-existing queries
|
||||
unset($this->query_result);
|
||||
if($query != "")
|
||||
{
|
||||
|
||||
$this->query_result = @mysql_query($query, $this->db_connect_id);
|
||||
|
||||
}
|
||||
if($this->query_result)
|
||||
{
|
||||
unset($this->row[$this->query_result]);
|
||||
unset($this->rowset[$this->query_result]);
|
||||
return $this->query_result;
|
||||
}
|
||||
else
|
||||
{
|
||||
return ( $transaction == END_TRANSACTION ) ? true : false;
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
// Other query methods
|
||||
//
|
||||
function sql_numrows($query_id = 0)
|
||||
{
|
||||
if(!$query_id)
|
||||
{
|
||||
$query_id = $this->query_result;
|
||||
}
|
||||
if($query_id)
|
||||
{
|
||||
$result = @mysql_num_rows($query_id);
|
||||
return $result;
|
||||
}
|
||||
else
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
function sql_affectedrows()
|
||||
{
|
||||
if($this->db_connect_id)
|
||||
{
|
||||
$result = @mysql_affected_rows($this->db_connect_id);
|
||||
return $result;
|
||||
}
|
||||
else
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
function sql_numfields($query_id = 0)
|
||||
{
|
||||
if(!$query_id)
|
||||
{
|
||||
$query_id = $this->query_result;
|
||||
}
|
||||
if($query_id)
|
||||
{
|
||||
$result = @mysql_num_fields($query_id);
|
||||
return $result;
|
||||
}
|
||||
else
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
function sql_fieldname($offset, $query_id = 0)
|
||||
{
|
||||
if(!$query_id)
|
||||
{
|
||||
$query_id = $this->query_result;
|
||||
}
|
||||
if($query_id)
|
||||
{
|
||||
$result = @mysql_field_name($query_id, $offset);
|
||||
return $result;
|
||||
}
|
||||
else
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
function sql_fieldtype($offset, $query_id = 0)
|
||||
{
|
||||
if(!$query_id)
|
||||
{
|
||||
$query_id = $this->query_result;
|
||||
}
|
||||
if($query_id)
|
||||
{
|
||||
$result = @mysql_field_type($query_id, $offset);
|
||||
return $result;
|
||||
}
|
||||
else
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
function sql_fetchrow($query_id = 0)
|
||||
{
|
||||
if(!$query_id)
|
||||
{
|
||||
$query_id = $this->query_result;
|
||||
}
|
||||
if($query_id)
|
||||
{
|
||||
$this->row[$query_id] = @mysql_fetch_array($query_id);
|
||||
return $this->row[$query_id];
|
||||
}
|
||||
else
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
function sql_fetchrowset($query_id = 0)
|
||||
{
|
||||
if(!$query_id)
|
||||
{
|
||||
$query_id = $this->query_result;
|
||||
}
|
||||
if($query_id)
|
||||
{
|
||||
unset($this->rowset[$query_id]);
|
||||
unset($this->row[$query_id]);
|
||||
while($this->rowset[$query_id] = @mysql_fetch_array($query_id))
|
||||
{
|
||||
$result[] = $this->rowset[$query_id];
|
||||
}
|
||||
return $result;
|
||||
}
|
||||
else
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
function sql_fetchfield($field, $rownum = -1, $query_id = 0)
|
||||
{
|
||||
if(!$query_id)
|
||||
{
|
||||
$query_id = $this->query_result;
|
||||
}
|
||||
if($query_id)
|
||||
{
|
||||
if($rownum > -1)
|
||||
{
|
||||
$result = @mysql_result($query_id, $rownum, $field);
|
||||
}
|
||||
else
|
||||
{
|
||||
if(empty($this->row[$query_id]) && empty($this->rowset[$query_id]))
|
||||
{
|
||||
if($this->sql_fetchrow())
|
||||
{
|
||||
$result = $this->row[$query_id][$field];
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if($this->rowset[$query_id])
|
||||
{
|
||||
$result = $this->rowset[$query_id][$field];
|
||||
}
|
||||
else if($this->row[$query_id])
|
||||
{
|
||||
$result = $this->row[$query_id][$field];
|
||||
}
|
||||
}
|
||||
}
|
||||
return $result;
|
||||
}
|
||||
else
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
function sql_rowseek($rownum, $query_id = 0){
|
||||
if(!$query_id)
|
||||
{
|
||||
$query_id = $this->query_result;
|
||||
}
|
||||
if($query_id)
|
||||
{
|
||||
$result = @mysql_data_seek($query_id, $rownum);
|
||||
return $result;
|
||||
}
|
||||
else
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
function sql_nextid(){
|
||||
if($this->db_connect_id)
|
||||
{
|
||||
$result = @mysql_insert_id($this->db_connect_id);
|
||||
return $result;
|
||||
}
|
||||
else
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
function sql_freeresult($query_id = 0){
|
||||
if(!$query_id)
|
||||
{
|
||||
$query_id = $this->query_result;
|
||||
}
|
||||
|
||||
if ( $query_id )
|
||||
{
|
||||
unset($this->row[$query_id]);
|
||||
unset($this->rowset[$query_id]);
|
||||
|
||||
@mysql_free_result($query_id);
|
||||
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
function sql_error($query_id = 0)
|
||||
{
|
||||
$result["message"] = @mysql_error($this->db_connect_id);
|
||||
$result["code"] = @mysql_errno($this->db_connect_id);
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
} // class sql_db
|
||||
|
||||
} // if ... define
|
||||
|
||||
?>
|
406
site/fitters/class/rating/classes/database.class.php
Normal file
406
site/fitters/class/rating/classes/database.class.php
Normal file
@ -0,0 +1,406 @@
|
||||
<?php
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
// Database Class
|
||||
//============================================================================
|
||||
// Dependencies:
|
||||
//----------------------------------------------------------------------------
|
||||
// None
|
||||
//============================================================================
|
||||
// Modification History:
|
||||
//----------------------------------------------------------------------------
|
||||
// 2006-11-04: Created
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
class Database extends Error
|
||||
{
|
||||
## CONSTANT VARIABLES
|
||||
const DB_TYPES = 'mysql,mysqli'; // NO SPACES!
|
||||
## END CONSTANT VARIABLES
|
||||
|
||||
## PUBLIC VARIABLES
|
||||
## END PUBLIC VARIABLES
|
||||
|
||||
## PRIVATE VARIABLES
|
||||
private static $host;
|
||||
private static $port;
|
||||
private static $database;
|
||||
private static $username;
|
||||
private static $password;
|
||||
private static $type;
|
||||
private static $connection;
|
||||
private static $savedQueries;
|
||||
private static $savedResults;
|
||||
## END PRIVATE VARIABLES
|
||||
|
||||
## CONSTRUCTOR
|
||||
## END CONSTRUCTOR
|
||||
|
||||
## DECONSTRUCTOR
|
||||
## END DECONSTRUCTOR
|
||||
|
||||
## PUBLIC METHODS
|
||||
// Initialize the Variables
|
||||
// Does not return anything, but acts like a constructor for Static classes
|
||||
public static function Initialize($varType, $varHost, $varPort, $varDatabase, $varUsername, $varPassword)
|
||||
{
|
||||
Error::Initialize();
|
||||
|
||||
if (!self::ValidDatabaseTypes($varType))
|
||||
{
|
||||
Error::LogError("Database Type Invalid", "Database Type must be one of: " . self::DB_TYPES);
|
||||
}
|
||||
|
||||
self::$host = $varHost;
|
||||
self::$port = $varPort;
|
||||
self::$type = strtolower($varType);
|
||||
self::$database = $varDatabase;
|
||||
self::$password = $varPassword;
|
||||
self::$username = $varUsername;
|
||||
self::$savedQueries = array();
|
||||
self::$savedResults = array();
|
||||
self::$connection = self::ConnectToDatabase();
|
||||
|
||||
self::SelectTheDatabase();
|
||||
}
|
||||
|
||||
// DeInitialize the Variables
|
||||
// Does not return anything, but acts like a destructor for Static classes
|
||||
public static function DeInitialize()
|
||||
{
|
||||
// Remove Saved Queries
|
||||
for ($saved = 0; $saved < sizeof(self::$savedQueries); $saved++)
|
||||
{
|
||||
unset(self::$savedQueries[$saved]);
|
||||
}
|
||||
|
||||
// Remove Saved Results
|
||||
for ($saved = 0; $saved < sizeof(self::$savedResults); $saved++)
|
||||
{
|
||||
unset(self::$savedResults[$saved]);
|
||||
}
|
||||
|
||||
// Close the Database Connection
|
||||
switch (self::$type)
|
||||
{
|
||||
case "mysql":
|
||||
@mysql_close(self::$connection) or Error::LogError("MySQL Failed to Close", mysql_error(self::$connection));
|
||||
break;
|
||||
case "mysqli":
|
||||
@mysqli_close(self::$connection) or Error::LogError("MySQL Failed to Close", mysqli_error(self::$connection));
|
||||
break;
|
||||
}
|
||||
|
||||
// Destroy Variables
|
||||
self::$host = null;
|
||||
self::$port = null;
|
||||
self::$type = null;
|
||||
self::$database = null;
|
||||
self::$password = null;
|
||||
self::$username = null;
|
||||
self::$connection = null;
|
||||
self::$savedQueries = null;
|
||||
self::$savedResults = null;
|
||||
Error::DeInitialize();
|
||||
}
|
||||
|
||||
// Database Types
|
||||
// Returns an array of database types
|
||||
public static function DatabaseTypes()
|
||||
{
|
||||
return split(",", self::DB_TYPES);
|
||||
}
|
||||
|
||||
// Build Order By
|
||||
// Returns the SQL Syntax for ORDER BY
|
||||
public static function BuildOrderBy($varColumnName, $varDirection)
|
||||
{
|
||||
$orderby = "";
|
||||
if (self::$connection)
|
||||
{
|
||||
switch (self::$type)
|
||||
{
|
||||
case "mysql":
|
||||
case "mysqli":
|
||||
$orderby = "ORDER BY `{$varColumnName}` {$varDirection}";
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return $orderby;
|
||||
}
|
||||
|
||||
// Build Limit
|
||||
// Returns the SQL Syntax for LIMIT
|
||||
public static function BuildLimit($varStartingRow, $varNumberOfRows)
|
||||
{
|
||||
$limit = "";
|
||||
if (self::$connection)
|
||||
{
|
||||
switch (self::$type)
|
||||
{
|
||||
case "mysql":
|
||||
case "mysqli":
|
||||
$limit = "LIMIT {$varStartingRow}, {$varNumberOfRows}";
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return $limit;
|
||||
}
|
||||
|
||||
// Execute SQL Query
|
||||
// Returns the result of the query, which is typically a resource id
|
||||
public static function ExecuteQuery($sql, $name)
|
||||
{
|
||||
if (self::$connection)
|
||||
{
|
||||
if (strlen(trim($name)) != 0)
|
||||
{
|
||||
switch (self::$type)
|
||||
{
|
||||
case "mysql":
|
||||
if (!array_key_exists($name, self::$savedQueries))
|
||||
{
|
||||
self::$savedQueries[$name] = @mysql_query($sql, self::$connection) or Error::LogError("Query Failed", mysql_error(self::$connection));
|
||||
}
|
||||
break;
|
||||
case "mysqli":
|
||||
if (!array_key_exists($name, self::$savedQueries))
|
||||
{
|
||||
self::$savedQueries[$name] = @mysqli_query(self::$connection, $sql) or Error::LogError("Query Failed", mysqli_error(self::$connection));
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
return self::$savedQueries[$name];
|
||||
}
|
||||
else
|
||||
{
|
||||
Error::LogError("Execute Query Name Missing", "The name parameter was empty, please provide a name for the query.");
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
// Fetch Results
|
||||
// Returns an array of the query results
|
||||
public static function FetchResults($name)
|
||||
{
|
||||
$results = array();
|
||||
if (self::$connection)
|
||||
{
|
||||
if (strlen(trim($name)) != 0 && (array_key_exists($name, self::$savedQueries) || array_key_exists($name, self::$savedResults)))
|
||||
{
|
||||
if (array_key_exists($name, self::$savedQueries))
|
||||
{
|
||||
switch (self::$type)
|
||||
{
|
||||
case "mysql":
|
||||
$row = 0;
|
||||
while ($currentResult = @mysql_fetch_assoc(self::$savedQueries[$name]))
|
||||
{
|
||||
$col = 0;
|
||||
foreach ($currentResult as $key => $value)
|
||||
{
|
||||
$results[$row][$col] = $value;
|
||||
$results[$row][$key] = $value;
|
||||
$col++;
|
||||
}
|
||||
|
||||
$row++;
|
||||
}
|
||||
break;
|
||||
case "mysqli":
|
||||
$row = 0;
|
||||
while ($currentResult = @mysqli_fetch_assoc(self::$savedQueries[$name]))
|
||||
{
|
||||
$col = 0;
|
||||
foreach ($currentResult as $key => $value)
|
||||
{
|
||||
$results[$row][$col] = $value;
|
||||
$results[$row][$key] = $value;
|
||||
$col++;
|
||||
}
|
||||
|
||||
$row++;
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
self::$savedResults[$name] = $results;
|
||||
}
|
||||
else
|
||||
{
|
||||
$results = self::$savedResults[$name];
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (strlen(trim($name)) == 0)
|
||||
{
|
||||
Error::LogError("Fetch Results Name Missing", "The name parameter was empty, the name is required so it knows which results to return.");
|
||||
}
|
||||
else
|
||||
{
|
||||
Error::LogError("Fetch Results Name ('{$name}') Not Found", "The name provided did not have any query results associated with it.");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return $results;
|
||||
}
|
||||
|
||||
// Free SQL Query Results
|
||||
// Returns nothing
|
||||
public static function FreeResults($name)
|
||||
{
|
||||
if (self::$connection)
|
||||
{
|
||||
if (strlen(trim($name)) != 0 && array_key_exists($name, self::$savedQueries))
|
||||
{
|
||||
switch (self::$type)
|
||||
{
|
||||
case "mysql":
|
||||
@mysql_free_result(self::$savedQueries[$name]) or Error::LogError("Free Results Error", mysql_error(self::$connection));
|
||||
unset(self::$savedQueries[$name]);
|
||||
break;
|
||||
case "mysqli":
|
||||
@mysqli_free_result(self::$savedQueries[$name]) or Error::LogError("Free Results Error", mysqli_error(self::$connection));
|
||||
unset(self::$savedQueries[$name]);
|
||||
break;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (strlen(trim($name)) == 0)
|
||||
{
|
||||
Error::LogError("Free Results Name Missing", "The name parameter was empty, the name is required so it knows which results to free up from memory.");
|
||||
}
|
||||
else
|
||||
{
|
||||
Error::LogWarning("Free Results Name ('{$name}') Not Found", "The name provided did not have any query results associated with it.");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Remove Saved Results
|
||||
// Returns nothing
|
||||
public static function RemoveSavedResults($name)
|
||||
{
|
||||
if (strlen(trim($name)) != 0 && array_key_exists($name, self::$savedResults))
|
||||
{
|
||||
unset(self::$savedResults[$name]);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (strlen(trim($name)) == 0)
|
||||
{
|
||||
Error::LogError("Remove Saved Result Name Missing", "The name parameter was empty, the name is required so it knows which query to remove.");
|
||||
}
|
||||
else
|
||||
{
|
||||
Error::LogWarning("Remove Saved Result Name ('{$name}') Not Found", "The name provided was not a saved query.");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Attempt Connect To Database
|
||||
// Returns true or false depending on if the connection failed or succeeded
|
||||
public static function AttemptConnectToDatabase($varType, $varHost, $varPort, $varDatabase, $varUsername, $varPassword)
|
||||
{
|
||||
self::$type = $varType;
|
||||
self::$host = $varHost;
|
||||
self::$port = $varPort;
|
||||
self::$database = $varDatabase;
|
||||
self::$username = $varUsername;
|
||||
self::$password = $varPassword;
|
||||
|
||||
Error::ClearErrors();
|
||||
self::$connection = self::ConnectToDatabase();
|
||||
|
||||
if (!Error::HasErrors())
|
||||
{
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
// MySQL Version
|
||||
// Returns the mysql version number
|
||||
public static function MysqlVersion()
|
||||
{
|
||||
$version = "";
|
||||
if (self::$connection)
|
||||
{
|
||||
switch (self::$type)
|
||||
{
|
||||
case "mysql":
|
||||
$version = mysql_get_server_info(self::$connection);
|
||||
break;
|
||||
case "mysqli":
|
||||
$version = mysqli_get_server_info(self::$connection);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return $version;
|
||||
}
|
||||
## END PUBLIC METHODS
|
||||
|
||||
## PRIVATE METHODS
|
||||
// Connect to Database
|
||||
// Returns the database connection resource
|
||||
private static function ConnectToDatabase()
|
||||
{
|
||||
$link = null;
|
||||
|
||||
switch (self::$type)
|
||||
{
|
||||
case "mysql":
|
||||
if (strlen(trim(self::$port)) != 0)
|
||||
{
|
||||
$link = mysql_connect(self::$host . ":" . self::$port, self::$username, self::$password) or Error::LogError("Database Error", mysql_error());
|
||||
}
|
||||
else
|
||||
{
|
||||
$link = mysql_connect(self::$host, self::$username, self::$password) or Error::LogError("Database Error", mysql_error());
|
||||
}
|
||||
break;
|
||||
case "mysqli":
|
||||
$link = mysqli_connect(self::$host, self::$username, self::$password, self::$database, self::$port) or Error::LogError("Database Error", mysqli_connect_error());
|
||||
break;
|
||||
}
|
||||
|
||||
return $link;
|
||||
}
|
||||
|
||||
// Select the Database
|
||||
// Returns nothing
|
||||
private static function SelectTheDatabase()
|
||||
{
|
||||
switch (self::$type)
|
||||
{
|
||||
case "mysql":
|
||||
@mysql_select_db(self::$database, self::$connection) or Error::LogError("Database Selection", mysql_error(self::$connection));
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
// Valid Database Types
|
||||
// Returns true or false depending on if the database type is valid
|
||||
private static function ValidDatabaseTypes($varType)
|
||||
{
|
||||
$types = split(',', str_replace(" ", "", self::DB_TYPES));
|
||||
|
||||
return in_array($varType, $types);
|
||||
}
|
||||
## END PRIVATE METHODS
|
||||
|
||||
## PROTECTED METHODS
|
||||
## END PROTECTED METHODS
|
||||
}
|
||||
?>
|
258
site/fitters/class/rating/classes/error.class.php
Normal file
258
site/fitters/class/rating/classes/error.class.php
Normal file
@ -0,0 +1,258 @@
|
||||
<?php
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
// Error Class
|
||||
//============================================================================
|
||||
// Dependencies:
|
||||
//----------------------------------------------------------------------------
|
||||
// none
|
||||
//============================================================================
|
||||
// Modification History:
|
||||
//----------------------------------------------------------------------------
|
||||
// 2006-11-04: Created
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
class Error
|
||||
{
|
||||
## CONSTANT VARIABLES
|
||||
## END CONSTANT VARIABLES
|
||||
|
||||
## PUBLIC VARIABLES
|
||||
## END PUBLIC VARIABLES
|
||||
|
||||
## PRIVATE VARIABLES
|
||||
private static $title;
|
||||
private static $type;
|
||||
private static $description;
|
||||
private static $datetime;
|
||||
|
||||
private static $numErrors;
|
||||
private static $numWarnings;
|
||||
## END PRIVATE VARIABLES
|
||||
|
||||
## CONSTRUCTOR
|
||||
## END CONSTRUCTOR
|
||||
|
||||
## DECONSTRUCTOR
|
||||
## END DECONSTRUCTOR
|
||||
|
||||
## PUBLIC METHODS
|
||||
// Initialize the Variables
|
||||
// Does not return anything, but acts like a constructor for Static classes
|
||||
public static function Initialize()
|
||||
{
|
||||
self::$title = array();
|
||||
self::$type = array();
|
||||
self::$description = array();
|
||||
self::$datetime = array();
|
||||
self::$numErrors = 0;
|
||||
self::$numWarnings = 0;
|
||||
}
|
||||
|
||||
// DeInitialize the Variables
|
||||
// Does not return anything, but acts like a destructor for Static classes
|
||||
public static function DeInitialize()
|
||||
{
|
||||
self::$title = null;
|
||||
self::$type = null;
|
||||
self::$description = null;
|
||||
self::$datetime = null;
|
||||
self::$numErrors = null;
|
||||
self::$numWarnings = null;
|
||||
}
|
||||
|
||||
// Log Error Method (receives Name and Description)
|
||||
// Returns true or false depending on if the logging of the error was successful
|
||||
public static function LogError($varTitle, $varDescription)
|
||||
{
|
||||
// Check Parameters
|
||||
if (strlen(trim($varTitle)) != 0 && strlen(trim($varDescription)) != 0)
|
||||
{
|
||||
array_push(self::$title, $varTitle);
|
||||
array_push(self::$type, "ERROR");
|
||||
array_push(self::$description, $varDescription);
|
||||
array_push(self::$datetime, date("m/d/Y H:i:s"));
|
||||
self::$numErrors++;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
// Show Error Messages
|
||||
// Returns the Error Message Output (in HTML format)
|
||||
public static function ShowErrorMessages()
|
||||
{
|
||||
$output = "";
|
||||
|
||||
// Check to see if 1 error occurred or more than one.
|
||||
if (self::$numErrors > 0)
|
||||
{
|
||||
if (self::$numErrors > 1)
|
||||
{
|
||||
$error = "ERRORS";
|
||||
}
|
||||
else
|
||||
{
|
||||
$error = "ERROR";
|
||||
}
|
||||
|
||||
// Loop through Error Messages
|
||||
for ($i = 0; $i < sizeof(self::$title); $i++)
|
||||
{
|
||||
if (self::$type[$i] == "ERROR")
|
||||
{
|
||||
// Output each individual Error
|
||||
$output .= " <div class=\"divErrorTitle\">\r\n" .
|
||||
" " . self::$title[$i] . "\r\n" .
|
||||
" <span class=\"spnErrorDateTime\">at " . self::$datetime[$i] . "</span>\r\n" .
|
||||
" </div>\r\n" .
|
||||
" <div class=\"divErrorDesc\">" . self::$description[$i] . "<br /><br /></div>\r\n";
|
||||
}
|
||||
}
|
||||
|
||||
// Write Error Template Output
|
||||
$output = "<div class=\"divErrorBox\">\r\n" .
|
||||
" <div class=\"divErrorBoxTitle\"><img src=\"icons/24-em-cross.png\" align=\"left\" /> {$error}:</div>\r\n" .
|
||||
" <div class=\"divErrors\">\r\n" . $output . "\r\n </div>\r\n" .
|
||||
"</div>\r\n";
|
||||
}
|
||||
|
||||
// Return the Error Message Output
|
||||
return $output;
|
||||
}
|
||||
|
||||
// Retrieve Last Error
|
||||
// Returns the title and description of the last error in an array
|
||||
public static function RetrieveLastError()
|
||||
{
|
||||
$output = array();
|
||||
|
||||
// Check to see if 1 error occurred or more than one.
|
||||
if (self::$numErrors > 0)
|
||||
{
|
||||
for ($i = sizeof(self::$title) - 1; $i >= 0; $i++)
|
||||
{
|
||||
if (self::$type[$i] == "ERROR")
|
||||
{
|
||||
array_push($output, self::$title[$i]);
|
||||
array_push($output, self::$description[$i]);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return $output;
|
||||
}
|
||||
|
||||
// Clear Errors
|
||||
// Returns nothing
|
||||
public static function ClearErrors()
|
||||
{
|
||||
self::$numErrors = 0;
|
||||
|
||||
for ($i = 0; $i < sizeof(self::$type); $i++)
|
||||
{
|
||||
if (self::$type[$i] == "ERROR")
|
||||
{
|
||||
self::$title[$i] = null;
|
||||
self::$type[$i] = null;
|
||||
self::$description[$i] = null;
|
||||
self::$datetime[$i] = null;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Has Errors
|
||||
// Returns true or false on whether errors exist
|
||||
public static function HasErrors()
|
||||
{
|
||||
if (self::$numErrors > 0)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
// Log Warning Method (receives Name and Description)
|
||||
// Returns true or false depending on if logging the warning was successful
|
||||
public static function LogWarning($varTitle, $varDescription)
|
||||
{
|
||||
// Check Parameters
|
||||
if (strlen(trim($varTitle)) != 0 && strlen(trim($varDescription)) != 0)
|
||||
{
|
||||
array_push(self::$title, $varTitle);
|
||||
array_push(self::$type, "WARNING");
|
||||
array_push(self::$description, $varDescription);
|
||||
array_push(self::$datetime, date("m/d/Y H:i:s"));
|
||||
self::$numWarnings++;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
// Show Warning Messages
|
||||
// Returns the Warning Message Output (in HTML format)
|
||||
public static function ShowWarningMessages()
|
||||
{
|
||||
$output = "";
|
||||
|
||||
// Check to see if 1 warning occurred or more than one.
|
||||
if (self::$numWarnings > 0)
|
||||
{
|
||||
if (self::$numWarnings > 1)
|
||||
{
|
||||
$warning = "WARNINGS";
|
||||
}
|
||||
else
|
||||
{
|
||||
$warning = "WARNING";
|
||||
}
|
||||
|
||||
// Loop through Warning Messages
|
||||
for ($i = 0; $i < sizeof(self::$title); $i++)
|
||||
{
|
||||
if (self::$type[$i] == "WARNING")
|
||||
{
|
||||
// Output each individual Warning
|
||||
$output .= " <div class=\"divWarningTitle\">\r\n" .
|
||||
" " . self::$title[$i] . "\r\n" .
|
||||
" <span class=\"spnWarningDateTime\">at " . self::$datetime[$i] . "</span>\r\n" .
|
||||
" </div>\r\n" .
|
||||
" <div class=\"divWarningDesc\">" . self::$description[$i] . "<br /><br /></div>\r\n";
|
||||
}
|
||||
}
|
||||
|
||||
// Write Warning Template Output
|
||||
$output = "<div id=\"divWarningBox\">\r\n" .
|
||||
" <div id=\"divWarningBoxTitle\"><img src=\"designs/icons/24-message-warn.png\" align=\"left\" /> {$warning}:</div>\r\n" .
|
||||
" <div id=\"divWarnings\">\r\n" . $output . "\r\n </div>\r\n" .
|
||||
"</div>\r\n";
|
||||
}
|
||||
|
||||
// Return the Warning Message Output
|
||||
return $output;
|
||||
}
|
||||
|
||||
// Has Warnings
|
||||
// Returns true or false on whether there are any Warnings
|
||||
public static function HasWarnings()
|
||||
{
|
||||
if (self::$numWarnings > 0)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
## END PUBLIC METHODS
|
||||
|
||||
## PRIVATE METHODS
|
||||
## END PRIVATE METHODS
|
||||
|
||||
## PROTECTED METHODS
|
||||
## END PROTECTED METHODS
|
||||
}
|
||||
?>
|
7
site/fitters/class/rating/classes/include.all.php
Normal file
7
site/fitters/class/rating/classes/include.all.php
Normal file
@ -0,0 +1,7 @@
|
||||
<?php
|
||||
require_once("error.class.php");
|
||||
require_once("database.class.php");
|
||||
require_once("rating.class.php");
|
||||
|
||||
Database::Initialize("mysql", $dbhost, "3306", $dbname, $dbuname, $dbpass);
|
||||
?>
|
279
site/fitters/class/rating/classes/rating.class.php
Normal file
279
site/fitters/class/rating/classes/rating.class.php
Normal file
@ -0,0 +1,279 @@
|
||||
<?php
|
||||
class Rating
|
||||
{
|
||||
## PRIVATE VARIABLES
|
||||
## END PRIVATE VARIABLES
|
||||
|
||||
## PUBLIC METHODS
|
||||
// Output the Rating information
|
||||
// Returns a string of HTML
|
||||
public static function OutputRating($varParent, $varItem)
|
||||
{
|
||||
// Verify $varItem was provided
|
||||
if ($varItem != null && strlen(trim($varItem)) != 0 && $varParent != null && strlen(trim($varParent)) != 0)
|
||||
{
|
||||
// Check if Magic QUotes is ON
|
||||
if (!get_magic_quotes_gpc())
|
||||
{
|
||||
$varItem = addslashes($varItem);
|
||||
$varParent = addslashes($varParent);
|
||||
}
|
||||
|
||||
// Information for the Output
|
||||
$averageStars = Rating::CalculateAverageRating($varParent, $varItem);
|
||||
|
||||
// Check to see that the user has not already rated this item
|
||||
if (Rating::CheckRatingsByIp($varParent, $varItem) == 0)
|
||||
{
|
||||
$classes = "rating " . Rating::ShowStars($averageStars);
|
||||
$cat_info = Rating::FetchCategoryInfo($varItem);
|
||||
|
||||
// Write Output HTML for the Rating Data
|
||||
$output = "\r\n";
|
||||
$output .= "<div class=\"rating-table\"><div><strong>{$cat_info['rating_cat_name']}</strong></div>\r\n";
|
||||
$output .= "<div>{$cat_info['rating_cat_min']}</div><div><div class=\"rated\"><ul class=\"{$classes}\" style='margin: 0px 0px 10px 0px;' id=\"{$varParent}_{$varItem}\">\r\n";
|
||||
$output .= " <li class=\"one\"><a href=\"javascript:RateItem('{$varParent}','{$varItem}', 1);\" title=\"1 Star\">1</a></li>\r\n";
|
||||
$output .= " <li class=\"two\"><a href=\"javascript:RateItem('{$varParent}','{$varItem}', 2);\" title=\"2 Stars\">2</a></li>\r\n";
|
||||
$output .= " <li class=\"three\"><a href=\"javascript:RateItem('{$varParent}','{$varItem}', 3);\" title=\"3 Stars\">3</a></li>\r\n";
|
||||
$output .= " <li class=\"four\"><a href=\"javascript:RateItem('{$varParent}','{$varItem}', 4);\" title=\"4 Stars\">4</a></li>\r\n";
|
||||
$output .= " <li class=\"five\"><a href=\"javascript:RateItem('{$varParent}','{$varItem}', 5);\" title=\"5 Stars\">5</a></li>\r\n";
|
||||
$output .= "</ul></div></div><div> {$cat_info['rating_cat_max']}</div></div>\r\n";
|
||||
}
|
||||
else
|
||||
{
|
||||
$classes = "rated " . Rating::ShowStars($averageStars);
|
||||
$cat_info = Rating::FetchCategoryInfo($varItem);
|
||||
|
||||
// Write Output HTML for the Rating Data
|
||||
$output = "\r\n";
|
||||
$output .= "<div class=\"rating-table\"><div><strong>{$cat_info['rating_cat_name']}</strong></div>\r\n";
|
||||
$output .= "<div>{$cat_info['rating_cat_min']}</div><div><div class=\"rated\"><ul class=\"{$classes}\" style='margin: 0px 0px 10px 0px;' id=\"{$varParent}_{$varItem}\">\r\n";
|
||||
$output .= " <li class=\"one\">1</li>\r\n";
|
||||
$output .= " <li class=\"two\">2</li>\r\n";
|
||||
$output .= " <li class=\"three\">3</li>\r\n";
|
||||
$output .= " <li class=\"four\">4</li>\r\n";
|
||||
$output .= " <li class=\"five\">5</li>\r\n";
|
||||
$output .= "</ul></div></div><div> {$cat_info['rating_cat_max']}</div></div>\r\n";
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
$output = "";
|
||||
// This is a major issue. NO information can be retrieve if an item name is not passed.
|
||||
Error::LogError("Variable Missing", "You must provide the item name for this function to find the average.");
|
||||
}
|
||||
|
||||
return $output;
|
||||
}
|
||||
|
||||
public static function OutputParentRating($varParent)
|
||||
{
|
||||
// Verify $varParent was provided
|
||||
if ($varParent != null && strlen(trim($varParent)) != 0)
|
||||
{
|
||||
// Check if Magic QUotes is ON
|
||||
if (!get_magic_quotes_gpc())
|
||||
{
|
||||
$varParent = addslashes($varParent);
|
||||
}
|
||||
|
||||
// Information for the Output
|
||||
$averageStars = Rating::CalculateAverageParentRating($varParent);
|
||||
|
||||
$classes = "rated " . Rating::ShowStars($averageStars);
|
||||
//$parent_info = Rating::FetchParentInfo($varParent);
|
||||
|
||||
// Write Output HTML for the Rating Data
|
||||
$output = "\r\n";
|
||||
//$output .= "<div style='clear:both;'>Overall Rating</div>";
|
||||
$output .= "<div style='height: 16px; width: 80px; position: relative;'><ul class=\"{$classes}\" id=\"{$varParent}\" style='margin: 0px 0px 10px 0px;'>\r\n";
|
||||
$output .= " <li class=\"one\">1</li>\r\n";
|
||||
$output .= " <li class=\"two\">2</li>\r\n";
|
||||
$output .= " <li class=\"three\">3</li>\r\n";
|
||||
$output .= " <li class=\"four\">4</li>\r\n";
|
||||
$output .= " <li class=\"five\">5</li>\r\n";
|
||||
$output .= "</ul></div>\r\n";
|
||||
}
|
||||
else
|
||||
{
|
||||
$output = "";
|
||||
// This is a major issue. NO information can be retrieve if an item name is not passed.
|
||||
Error::LogError("Variable Missing", "You must provide the parent name for this function to find the average.");
|
||||
}
|
||||
|
||||
return $output;
|
||||
}
|
||||
|
||||
// Rate an Item
|
||||
// Returns the name/value pair of new class names and the item name
|
||||
public static function RateItem($varParent, $varItem, $varRating, $varClasses)
|
||||
{
|
||||
$newClassNames = $varClasses;
|
||||
|
||||
// Verify $varName was provided
|
||||
if ($varParent != null && strlen(trim($varParent)) != 0
|
||||
&& $varItem != null && strlen(trim($varItem)) != 0
|
||||
&& $varRating != null && strlen(trim($varRating)) != 0 && is_numeric($varRating)
|
||||
&& $varClasses != null && strlen(trim($varClasses)) != 0)
|
||||
{
|
||||
// Check if Magic Quotes is ON
|
||||
if (!get_magic_quotes_gpc())
|
||||
{
|
||||
$varItem = addslashes($varItem);
|
||||
$varParent = addslashes($varParent);
|
||||
}
|
||||
|
||||
// Check to see that the user has not already rated this item
|
||||
if (Rating::CheckRatingsByIp($varParent, $varItem) == 0)
|
||||
{
|
||||
$ipAddress = $_SERVER['REMOTE_ADDR'];
|
||||
$tempTime = time();
|
||||
|
||||
Database::ExecuteQuery("INSERT INTO `gforum_FittersRating` (`fitter_id_fk`, `category_id_fk`, `rating_vote`, `rating_ip`, `rating_date`) VALUES ('{$varParent}', '{$varItem}', {$varRating}, '{$ipAddress}', '{$tempTime}')", "InsertRating");
|
||||
Database::FetchResults("InsertRating");
|
||||
Database::FreeResults("InsertRating");
|
||||
Database::RemoveSavedResults("InsertRating");
|
||||
|
||||
// Information for the Output
|
||||
$averageStars = Rating::CalculateAverageRating($varParent, $varItem);
|
||||
$newClassNames = "rated " . Rating::ShowStars($averageStars);
|
||||
$averageStars = Rating::CalculateAverageParentRating($varParent);
|
||||
$newClassParent = "rated " . Rating::ShowStars($averageStars);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// This is a major issue. NOT enough information was sent to log the item
|
||||
Error::LogError("Variable(s) Missing", "You must provide all of the information to log the rating of this item.");
|
||||
}
|
||||
|
||||
// Build Name/Value Pair to return
|
||||
$nameValue = "classes={$newClassNames}&item={$varItem}&parent={$varParent}&parentClass={$newClassParent}";
|
||||
return $nameValue;
|
||||
}
|
||||
## END PUBLIC METHODS
|
||||
|
||||
## PRIVATE METHODS
|
||||
// Fetch Category Names & Min/Max Values
|
||||
private static function FetchCategoryInfo($varItem)
|
||||
{
|
||||
// Query Category Info for a specific Category ID
|
||||
Database::ExecuteQuery("SELECT * FROM `gforum_FittersRatingCategory` WHERE `rating_cat_id`='{$varItem}'", "CategoryInfo");
|
||||
$results = Database::FetchResults("CategoryInfo");
|
||||
Database::FreeResults("CategoryInfo");
|
||||
Database::RemoveSavedResults("CategoryInfo");
|
||||
|
||||
return $results[0];
|
||||
|
||||
}
|
||||
|
||||
// Calculate Average Rating
|
||||
// Returns the number of stars to show
|
||||
private static function CalculateAverageRating($varParent, $varItem)
|
||||
{
|
||||
$averageStars = 0;
|
||||
|
||||
// Query Average Rating for a specific Item
|
||||
Database::ExecuteQuery("SELECT AVG(`rating_vote`) AS `averageRating` FROM `gforum_FittersRating` WHERE `category_id_fk`='{$varItem}' AND `fitter_id_fk`='{$varParent}'", "AverageRating");
|
||||
$results = Database::FetchResults("AverageRating");
|
||||
Database::FreeResults("AverageRating");
|
||||
Database::RemoveSavedResults("AverageRating");
|
||||
|
||||
// Round the Average into a Whole Number
|
||||
if (sizeof($results) == 1)
|
||||
{
|
||||
if ($results[0]['averageRating'] != null)
|
||||
{
|
||||
$averageStars = round($results[0]["averageRating"], 0);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// This is simply a warning, as it isn't vital if no results were found, as the item may be new.
|
||||
Error::LogWarning("Rating Data Missing", "No entries were found for '{$varName}', this might be the first entry.");
|
||||
}
|
||||
|
||||
return $averageStars;
|
||||
}
|
||||
|
||||
// Calculate Average Rating
|
||||
// Returns the number of stars to show
|
||||
private static function CalculateAverageParentRating($varParent)
|
||||
{
|
||||
$averageStars = 0;
|
||||
|
||||
// Query Average Rating for a specific Item
|
||||
Database::ExecuteQuery("SELECT AVG(`rating_vote`) AS `averageRating` FROM `gforum_FittersRating` WHERE `fitter_id_fk`='{$varParent}'", "AverageRating");
|
||||
$results = Database::FetchResults("AverageRating");
|
||||
Database::FreeResults("AverageRating");
|
||||
Database::RemoveSavedResults("AverageRating");
|
||||
|
||||
// Round the Average into a Whole Number
|
||||
if (sizeof($results) == 1)
|
||||
{
|
||||
if ($results[0]['averageRating'] != null)
|
||||
{
|
||||
$averageStars = round($results[0]["averageRating"], 0);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// This is simply a warning, as it isn't vital if no results were found, as the item may be new.
|
||||
Error::LogWarning("Rating Data Missing", "No entries were found for '{$varName}', this might be the first entry.");
|
||||
}
|
||||
|
||||
return $averageStars;
|
||||
}
|
||||
|
||||
// Show Stars
|
||||
// Returns the class information for the number of stars to show
|
||||
private static function ShowStars($varStars)
|
||||
{
|
||||
// Select the Number of Stars Class
|
||||
switch ($varStars)
|
||||
{
|
||||
case 1:
|
||||
$classes .= "onestar";
|
||||
break;
|
||||
case 2:
|
||||
$classes .= "twostar";
|
||||
break;
|
||||
case 3:
|
||||
$classes .= "threestar";
|
||||
break;
|
||||
case 4:
|
||||
$classes .= "fourstar";
|
||||
break;
|
||||
case 5:
|
||||
$classes .= "fivestar";
|
||||
break;
|
||||
default:
|
||||
$classes .= "nostar";
|
||||
break;
|
||||
}
|
||||
|
||||
return $classes;
|
||||
}
|
||||
|
||||
// Check Ratings By IP Address
|
||||
// Returns the number of ratings for an item by an ip address
|
||||
private static function CheckRatingsByIp($varParent, $varItem)
|
||||
{
|
||||
$ipAddress = $_SERVER['REMOTE_ADDR'];
|
||||
|
||||
Database::ExecuteQuery("SELECT COUNT(*) AS `totalRatings` FROM `gforum_FittersRating` WHERE `category_id_fk`='{$varItem}' AND `fitter_id_fk`='{$varParent}' AND `rating_ip`='{$ipAddress}'", "AlreadyRated");
|
||||
$results = Database::FetchResults("AlreadyRated");
|
||||
Database::FreeResults("AlreadyRated");
|
||||
Database::RemoveSavedResults("AlreadyRated");
|
||||
|
||||
// Check to see that the user has not already rated this item
|
||||
if ($results != null && $results[0]['totalRatings'] != null)
|
||||
{
|
||||
return $results[0]['totalRatings'];
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
## END PRIVATE METHODS
|
||||
}
|
||||
?>
|
55
site/fitters/class/rating/int.to.words.php
Normal file
55
site/fitters/class/rating/int.to.words.php
Normal file
@ -0,0 +1,55 @@
|
||||
<?php
|
||||
|
||||
$nwords = array( "zero", "one", "two", "three", "four", "five", "six", "seven", "eight", "nine", "ten", "eleven", "twelve", "thirteen", "fourteen", "fifteen", "sixteen", "seventeen", "eighteen", "nineteen", "twenty", 30 => "thirty", 40 => "forty", 50 => "fifty", 60 => "sixty", 70 => "seventy", 80 => "eighty", 90 => "ninety" );
|
||||
|
||||
function int_to_words($x) {
|
||||
global $nwords;
|
||||
|
||||
if(!is_numeric($x))
|
||||
$w = '#';
|
||||
else if(fmod($x, 1) != 0)
|
||||
$w = '#';
|
||||
else {
|
||||
if($x < 0) {
|
||||
$w = 'minus ';
|
||||
$x = -$x;
|
||||
} else
|
||||
$w = '';
|
||||
// ... now $x is a non-negative integer.
|
||||
|
||||
if($x < 21) // 0 to 20
|
||||
$w .= $nwords[$x];
|
||||
else if($x < 100) { // 21 to 99
|
||||
$w .= $nwords[10 * floor($x/10)];
|
||||
$r = fmod($x, 10);
|
||||
if($r > 0)
|
||||
$w .= '-'. $nwords[$r];
|
||||
} else if($x < 1000) { // 100 to 999
|
||||
$w .= $nwords[floor($x/100)] .' hundred';
|
||||
$r = fmod($x, 100);
|
||||
if($r > 0)
|
||||
$w .= ' and '. int_to_words($r);
|
||||
} else if($x < 1000000) { // 1000 to 999999
|
||||
$w .= int_to_words(floor($x/1000)) .' thousand';
|
||||
$r = fmod($x, 1000);
|
||||
if($r > 0) {
|
||||
$w .= ' ';
|
||||
if($r < 100)
|
||||
$w .= 'and ';
|
||||
$w .= int_to_words($r);
|
||||
}
|
||||
} else { // millions
|
||||
$w .= int_to_words(floor($x/1000000)) .' million';
|
||||
$r = fmod($x, 1000000);
|
||||
if($r > 0) {
|
||||
$w .= ' ';
|
||||
if($r < 100)
|
||||
$word .= 'and ';
|
||||
$w .= int_to_words($r);
|
||||
}
|
||||
}
|
||||
}
|
||||
return $w;
|
||||
}
|
||||
|
||||
?>
|
71
site/fitters/class/rating/rating-example.php
Normal file
71
site/fitters/class/rating/rating-example.php
Normal file
@ -0,0 +1,71 @@
|
||||
<?php
|
||||
require_once("classes/include.all.php");
|
||||
?>
|
||||
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
|
||||
<html xmlns="http://www.w3.org/1999/xhtml">
|
||||
<head>
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
|
||||
<title>CSS Star Rating System fully functional using AJAX</title>
|
||||
<link type="text/css" href="styles/rating.css" rel="stylesheet" media="all" />
|
||||
<script type="text/javascript" src="scripts/prototype.js"></script>
|
||||
<script type="text/javascript" src="scripts/rating.js"></script>
|
||||
</head>
|
||||
<body>
|
||||
<h4>Race Rating System:</h4>
|
||||
<?php
|
||||
$ratingData = Rating::OutputParentRating('1');
|
||||
|
||||
if (Error::HasErrors())
|
||||
{
|
||||
echo Error::ShowErrorMessages();
|
||||
Error::ClearErrors();
|
||||
}
|
||||
else
|
||||
{
|
||||
echo $ratingData;
|
||||
}
|
||||
?>
|
||||
<?php
|
||||
$ratingData = Rating::OutputRating('1','1');
|
||||
|
||||
if (Error::HasErrors())
|
||||
{
|
||||
echo Error::ShowErrorMessages();
|
||||
Error::ClearErrors();
|
||||
}
|
||||
else
|
||||
{
|
||||
echo $ratingData;
|
||||
}
|
||||
?>
|
||||
<?php
|
||||
$ratingData = Rating::OutputRating('1','2');
|
||||
|
||||
if (Error::HasErrors())
|
||||
{
|
||||
echo Error::ShowErrorMessages();
|
||||
Error::ClearErrors();
|
||||
}
|
||||
else
|
||||
{
|
||||
echo $ratingData;
|
||||
}
|
||||
?>
|
||||
<?php
|
||||
$ratingData = Rating::OutputRating('1','3');
|
||||
|
||||
if (Error::HasErrors())
|
||||
{
|
||||
echo Error::ShowErrorMessages();
|
||||
Error::ClearErrors();
|
||||
}
|
||||
else
|
||||
{
|
||||
echo $ratingData;
|
||||
}
|
||||
?>
|
||||
</body>
|
||||
</html>
|
||||
<?php
|
||||
Database::DeInitialize();
|
||||
?>
|
Reference in New Issue
Block a user