repo stringlengths 7 63 | file_url stringlengths 81 284 | file_path stringlengths 5 200 | content stringlengths 0 32.8k | language stringclasses 1 value | license stringclasses 7 values | commit_sha stringlengths 40 40 | retrieved_at stringdate 2026-01-04 15:02:33 2026-01-05 05:24:06 | truncated bool 2 classes |
|---|---|---|---|---|---|---|---|---|
MobilityLab/TransitScreen | https://github.com/MobilityLab/TransitScreen/blob/152cd2d808675d2baeb9e77c229adfbaf9a16475/system/database/drivers/odbc/odbc_utility.php | system/database/drivers/odbc/odbc_utility.php | <?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
/**
* CodeIgniter
*
* An open source application development framework for PHP 5.1.6 or newer
*
* @package CodeIgniter
* @author ExpressionEngine Dev Team
* @copyright Copyright (c) 2008 - 2011, EllisLab, Inc.
* @license http://codeigniter.com/user_guide/license.html
* @link http://codeigniter.com
* @since Version 1.0
* @filesource
*/
// ------------------------------------------------------------------------
/**
* ODBC Utility Class
*
* @category Database
* @author ExpressionEngine Dev Team
* @link http://codeigniter.com/database/
*/
class CI_DB_odbc_utility extends CI_DB_utility {
/**
* List databases
*
* @access private
* @return bool
*/
function _list_databases()
{
// Not sure if ODBC lets you list all databases...
if ($this->db->db_debug)
{
return $this->db->display_error('db_unsuported_feature');
}
return FALSE;
}
// --------------------------------------------------------------------
/**
* Optimize table query
*
* Generates a platform-specific query so that a table can be optimized
*
* @access private
* @param string the table name
* @return object
*/
function _optimize_table($table)
{
// Not a supported ODBC feature
if ($this->db->db_debug)
{
return $this->db->display_error('db_unsuported_feature');
}
return FALSE;
}
// --------------------------------------------------------------------
/**
* Repair table query
*
* Generates a platform-specific query so that a table can be repaired
*
* @access private
* @param string the table name
* @return object
*/
function _repair_table($table)
{
// Not a supported ODBC feature
if ($this->db->db_debug)
{
return $this->db->display_error('db_unsuported_feature');
}
return FALSE;
}
// --------------------------------------------------------------------
/**
* ODBC Export
*
* @access private
* @param array Preferences
* @return mixed
*/
function _backup($params = array())
{
// Currently unsupported
return $this->db->display_error('db_unsuported_feature');
}
}
/* End of file odbc_utility.php */
/* Location: ./system/database/drivers/odbc/odbc_utility.php */ | php | MIT | 152cd2d808675d2baeb9e77c229adfbaf9a16475 | 2026-01-05T05:21:15.334872Z | false |
MobilityLab/TransitScreen | https://github.com/MobilityLab/TransitScreen/blob/152cd2d808675d2baeb9e77c229adfbaf9a16475/system/database/drivers/odbc/odbc_driver.php | system/database/drivers/odbc/odbc_driver.php | <?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
/**
* CodeIgniter
*
* An open source application development framework for PHP 5.1.6 or newer
*
* @package CodeIgniter
* @author ExpressionEngine Dev Team
* @copyright Copyright (c) 2008 - 2011, EllisLab, Inc.
* @license http://codeigniter.com/user_guide/license.html
* @link http://codeigniter.com
* @since Version 1.0
* @filesource
*/
// ------------------------------------------------------------------------
/**
* ODBC Database Adapter Class
*
* Note: _DB is an extender class that the app controller
* creates dynamically based on whether the active record
* class is being used or not.
*
* @package CodeIgniter
* @subpackage Drivers
* @category Database
* @author ExpressionEngine Dev Team
* @link http://codeigniter.com/user_guide/database/
*/
class CI_DB_odbc_driver extends CI_DB {
var $dbdriver = 'odbc';
// the character used to excape - not necessary for ODBC
var $_escape_char = '';
// clause and character used for LIKE escape sequences
var $_like_escape_str = " {escape '%s'} ";
var $_like_escape_chr = '!';
/**
* The syntax to count rows is slightly different across different
* database engines, so this string appears in each driver and is
* used for the count_all() and count_all_results() functions.
*/
var $_count_string = "SELECT COUNT(*) AS ";
var $_random_keyword;
function __construct($params)
{
parent::__construct($params);
$this->_random_keyword = ' RND('.time().')'; // database specific random keyword
}
/**
* Non-persistent database connection
*
* @access private called by the base class
* @return resource
*/
function db_connect()
{
return @odbc_connect($this->hostname, $this->username, $this->password);
}
// --------------------------------------------------------------------
/**
* Persistent database connection
*
* @access private called by the base class
* @return resource
*/
function db_pconnect()
{
return @odbc_pconnect($this->hostname, $this->username, $this->password);
}
// --------------------------------------------------------------------
/**
* Reconnect
*
* Keep / reestablish the db connection if no queries have been
* sent for a length of time exceeding the server's idle timeout
*
* @access public
* @return void
*/
function reconnect()
{
// not implemented in odbc
}
// --------------------------------------------------------------------
/**
* Select the database
*
* @access private called by the base class
* @return resource
*/
function db_select()
{
// Not needed for ODBC
return TRUE;
}
// --------------------------------------------------------------------
/**
* Set client character set
*
* @access public
* @param string
* @param string
* @return resource
*/
function db_set_charset($charset, $collation)
{
// @todo - add support if needed
return TRUE;
}
// --------------------------------------------------------------------
/**
* Version number query string
*
* @access public
* @return string
*/
function _version()
{
return "SELECT version() AS ver";
}
// --------------------------------------------------------------------
/**
* Execute the query
*
* @access private called by the base class
* @param string an SQL query
* @return resource
*/
function _execute($sql)
{
$sql = $this->_prep_query($sql);
return @odbc_exec($this->conn_id, $sql);
}
// --------------------------------------------------------------------
/**
* Prep the query
*
* If needed, each database adapter can prep the query string
*
* @access private called by execute()
* @param string an SQL query
* @return string
*/
function _prep_query($sql)
{
return $sql;
}
// --------------------------------------------------------------------
/**
* Begin Transaction
*
* @access public
* @return bool
*/
function trans_begin($test_mode = FALSE)
{
if ( ! $this->trans_enabled)
{
return TRUE;
}
// When transactions are nested we only begin/commit/rollback the outermost ones
if ($this->_trans_depth > 0)
{
return TRUE;
}
// Reset the transaction failure flag.
// If the $test_mode flag is set to TRUE transactions will be rolled back
// even if the queries produce a successful result.
$this->_trans_failure = ($test_mode === TRUE) ? TRUE : FALSE;
return odbc_autocommit($this->conn_id, FALSE);
}
// --------------------------------------------------------------------
/**
* Commit Transaction
*
* @access public
* @return bool
*/
function trans_commit()
{
if ( ! $this->trans_enabled)
{
return TRUE;
}
// When transactions are nested we only begin/commit/rollback the outermost ones
if ($this->_trans_depth > 0)
{
return TRUE;
}
$ret = odbc_commit($this->conn_id);
odbc_autocommit($this->conn_id, TRUE);
return $ret;
}
// --------------------------------------------------------------------
/**
* Rollback Transaction
*
* @access public
* @return bool
*/
function trans_rollback()
{
if ( ! $this->trans_enabled)
{
return TRUE;
}
// When transactions are nested we only begin/commit/rollback the outermost ones
if ($this->_trans_depth > 0)
{
return TRUE;
}
$ret = odbc_rollback($this->conn_id);
odbc_autocommit($this->conn_id, TRUE);
return $ret;
}
// --------------------------------------------------------------------
/**
* Escape String
*
* @access public
* @param string
* @param bool whether or not the string will be used in a LIKE condition
* @return string
*/
function escape_str($str, $like = FALSE)
{
if (is_array($str))
{
foreach ($str as $key => $val)
{
$str[$key] = $this->escape_str($val, $like);
}
return $str;
}
// ODBC doesn't require escaping
$str = remove_invisible_characters($str);
// escape LIKE condition wildcards
if ($like === TRUE)
{
$str = str_replace( array('%', '_', $this->_like_escape_chr),
array($this->_like_escape_chr.'%', $this->_like_escape_chr.'_', $this->_like_escape_chr.$this->_like_escape_chr),
$str);
}
return $str;
}
// --------------------------------------------------------------------
/**
* Affected Rows
*
* @access public
* @return integer
*/
function affected_rows()
{
return @odbc_num_rows($this->conn_id);
}
// --------------------------------------------------------------------
/**
* Insert ID
*
* @access public
* @return integer
*/
function insert_id()
{
return @odbc_insert_id($this->conn_id);
}
// --------------------------------------------------------------------
/**
* "Count All" query
*
* Generates a platform-specific query string that counts all records in
* the specified database
*
* @access public
* @param string
* @return string
*/
function count_all($table = '')
{
if ($table == '')
{
return 0;
}
$query = $this->query($this->_count_string . $this->_protect_identifiers('numrows') . " FROM " . $this->_protect_identifiers($table, TRUE, NULL, FALSE));
if ($query->num_rows() == 0)
{
return 0;
}
$row = $query->row();
$this->_reset_select();
return (int) $row->numrows;
}
// --------------------------------------------------------------------
/**
* Show table query
*
* Generates a platform-specific query string so that the table names can be fetched
*
* @access private
* @param boolean
* @return string
*/
function _list_tables($prefix_limit = FALSE)
{
$sql = "SHOW TABLES FROM `".$this->database."`";
if ($prefix_limit !== FALSE AND $this->dbprefix != '')
{
//$sql .= " LIKE '".$this->escape_like_str($this->dbprefix)."%' ".sprintf($this->_like_escape_str, $this->_like_escape_chr);
return FALSE; // not currently supported
}
return $sql;
}
// --------------------------------------------------------------------
/**
* Show column query
*
* Generates a platform-specific query string so that the column names can be fetched
*
* @access public
* @param string the table name
* @return string
*/
function _list_columns($table = '')
{
return "SHOW COLUMNS FROM ".$table;
}
// --------------------------------------------------------------------
/**
* Field data query
*
* Generates a platform-specific query so that the column data can be retrieved
*
* @access public
* @param string the table name
* @return object
*/
function _field_data($table)
{
return "SELECT TOP 1 FROM ".$table;
}
// --------------------------------------------------------------------
/**
* The error message string
*
* @access private
* @return string
*/
function _error_message()
{
return odbc_errormsg($this->conn_id);
}
// --------------------------------------------------------------------
/**
* The error message number
*
* @access private
* @return integer
*/
function _error_number()
{
return odbc_error($this->conn_id);
}
// --------------------------------------------------------------------
/**
* Escape the SQL Identifiers
*
* This function escapes column and table names
*
* @access private
* @param string
* @return string
*/
function _escape_identifiers($item)
{
if ($this->_escape_char == '')
{
return $item;
}
foreach ($this->_reserved_identifiers as $id)
{
if (strpos($item, '.'.$id) !== FALSE)
{
$str = $this->_escape_char. str_replace('.', $this->_escape_char.'.', $item);
// remove duplicates if the user already included the escape
return preg_replace('/['.$this->_escape_char.']+/', $this->_escape_char, $str);
}
}
if (strpos($item, '.') !== FALSE)
{
$str = $this->_escape_char.str_replace('.', $this->_escape_char.'.'.$this->_escape_char, $item).$this->_escape_char;
}
else
{
$str = $this->_escape_char.$item.$this->_escape_char;
}
// remove duplicates if the user already included the escape
return preg_replace('/['.$this->_escape_char.']+/', $this->_escape_char, $str);
}
// --------------------------------------------------------------------
/**
* From Tables
*
* This function implicitly groups FROM tables so there is no confusion
* about operator precedence in harmony with SQL standards
*
* @access public
* @param type
* @return type
*/
function _from_tables($tables)
{
if ( ! is_array($tables))
{
$tables = array($tables);
}
return '('.implode(', ', $tables).')';
}
// --------------------------------------------------------------------
/**
* Insert statement
*
* Generates a platform-specific insert string from the supplied data
*
* @access public
* @param string the table name
* @param array the insert keys
* @param array the insert values
* @return string
*/
function _insert($table, $keys, $values)
{
return "INSERT INTO ".$table." (".implode(', ', $keys).") VALUES (".implode(', ', $values).")";
}
// --------------------------------------------------------------------
/**
* Update statement
*
* Generates a platform-specific update string from the supplied data
*
* @access public
* @param string the table name
* @param array the update data
* @param array the where clause
* @param array the orderby clause
* @param array the limit clause
* @return string
*/
function _update($table, $values, $where, $orderby = array(), $limit = FALSE)
{
foreach ($values as $key => $val)
{
$valstr[] = $key." = ".$val;
}
$limit = ( ! $limit) ? '' : ' LIMIT '.$limit;
$orderby = (count($orderby) >= 1)?' ORDER BY '.implode(", ", $orderby):'';
$sql = "UPDATE ".$table." SET ".implode(', ', $valstr);
$sql .= ($where != '' AND count($where) >=1) ? " WHERE ".implode(" ", $where) : '';
$sql .= $orderby.$limit;
return $sql;
}
// --------------------------------------------------------------------
/**
* Truncate statement
*
* Generates a platform-specific truncate string from the supplied data
* If the database does not support the truncate() command
* This function maps to "DELETE FROM table"
*
* @access public
* @param string the table name
* @return string
*/
function _truncate($table)
{
return $this->_delete($table);
}
// --------------------------------------------------------------------
/**
* Delete statement
*
* Generates a platform-specific delete string from the supplied data
*
* @access public
* @param string the table name
* @param array the where clause
* @param string the limit clause
* @return string
*/
function _delete($table, $where = array(), $like = array(), $limit = FALSE)
{
$conditions = '';
if (count($where) > 0 OR count($like) > 0)
{
$conditions = "\nWHERE ";
$conditions .= implode("\n", $this->ar_where);
if (count($where) > 0 && count($like) > 0)
{
$conditions .= " AND ";
}
$conditions .= implode("\n", $like);
}
$limit = ( ! $limit) ? '' : ' LIMIT '.$limit;
return "DELETE FROM ".$table.$conditions.$limit;
}
// --------------------------------------------------------------------
/**
* Limit string
*
* Generates a platform-specific LIMIT clause
*
* @access public
* @param string the sql query string
* @param integer the number of rows to limit the query to
* @param integer the offset value
* @return string
*/
function _limit($sql, $limit, $offset)
{
// Does ODBC doesn't use the LIMIT clause?
return $sql;
}
// --------------------------------------------------------------------
/**
* Close DB Connection
*
* @access public
* @param resource
* @return void
*/
function _close($conn_id)
{
@odbc_close($conn_id);
}
}
/* End of file odbc_driver.php */
/* Location: ./system/database/drivers/odbc/odbc_driver.php */ | php | MIT | 152cd2d808675d2baeb9e77c229adfbaf9a16475 | 2026-01-05T05:21:15.334872Z | false |
MobilityLab/TransitScreen | https://github.com/MobilityLab/TransitScreen/blob/152cd2d808675d2baeb9e77c229adfbaf9a16475/system/database/drivers/sqlite/sqlite_driver.php | system/database/drivers/sqlite/sqlite_driver.php | <?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
/**
* CodeIgniter
*
* An open source application development framework for PHP 5.1.6 or newer
*
* @package CodeIgniter
* @author ExpressionEngine Dev Team
* @copyright Copyright (c) 2008 - 2011, EllisLab, Inc.
* @license http://codeigniter.com/user_guide/license.html
* @link http://codeigniter.com
* @since Version 1.0
* @filesource
*/
// ------------------------------------------------------------------------
/**
* SQLite Database Adapter Class
*
* Note: _DB is an extender class that the app controller
* creates dynamically based on whether the active record
* class is being used or not.
*
* @package CodeIgniter
* @subpackage Drivers
* @category Database
* @author ExpressionEngine Dev Team
* @link http://codeigniter.com/user_guide/database/
*/
class CI_DB_sqlite_driver extends CI_DB {
var $dbdriver = 'sqlite';
// The character used to escape with - not needed for SQLite
var $_escape_char = '';
// clause and character used for LIKE escape sequences
var $_like_escape_str = " ESCAPE '%s' ";
var $_like_escape_chr = '!';
/**
* The syntax to count rows is slightly different across different
* database engines, so this string appears in each driver and is
* used for the count_all() and count_all_results() functions.
*/
var $_count_string = "SELECT COUNT(*) AS ";
var $_random_keyword = ' Random()'; // database specific random keyword
/**
* Non-persistent database connection
*
* @access private called by the base class
* @return resource
*/
function db_connect()
{
if ( ! $conn_id = @sqlite_open($this->database, FILE_WRITE_MODE, $error))
{
log_message('error', $error);
if ($this->db_debug)
{
$this->display_error($error, '', TRUE);
}
return FALSE;
}
return $conn_id;
}
// --------------------------------------------------------------------
/**
* Persistent database connection
*
* @access private called by the base class
* @return resource
*/
function db_pconnect()
{
if ( ! $conn_id = @sqlite_popen($this->database, FILE_WRITE_MODE, $error))
{
log_message('error', $error);
if ($this->db_debug)
{
$this->display_error($error, '', TRUE);
}
return FALSE;
}
return $conn_id;
}
// --------------------------------------------------------------------
/**
* Reconnect
*
* Keep / reestablish the db connection if no queries have been
* sent for a length of time exceeding the server's idle timeout
*
* @access public
* @return void
*/
function reconnect()
{
// not implemented in SQLite
}
// --------------------------------------------------------------------
/**
* Select the database
*
* @access private called by the base class
* @return resource
*/
function db_select()
{
return TRUE;
}
// --------------------------------------------------------------------
/**
* Set client character set
*
* @access public
* @param string
* @param string
* @return resource
*/
function db_set_charset($charset, $collation)
{
// @todo - add support if needed
return TRUE;
}
// --------------------------------------------------------------------
/**
* Version number query string
*
* @access public
* @return string
*/
function _version()
{
return sqlite_libversion();
}
// --------------------------------------------------------------------
/**
* Execute the query
*
* @access private called by the base class
* @param string an SQL query
* @return resource
*/
function _execute($sql)
{
$sql = $this->_prep_query($sql);
return @sqlite_query($this->conn_id, $sql);
}
// --------------------------------------------------------------------
/**
* Prep the query
*
* If needed, each database adapter can prep the query string
*
* @access private called by execute()
* @param string an SQL query
* @return string
*/
function _prep_query($sql)
{
return $sql;
}
// --------------------------------------------------------------------
/**
* Begin Transaction
*
* @access public
* @return bool
*/
function trans_begin($test_mode = FALSE)
{
if ( ! $this->trans_enabled)
{
return TRUE;
}
// When transactions are nested we only begin/commit/rollback the outermost ones
if ($this->_trans_depth > 0)
{
return TRUE;
}
// Reset the transaction failure flag.
// If the $test_mode flag is set to TRUE transactions will be rolled back
// even if the queries produce a successful result.
$this->_trans_failure = ($test_mode === TRUE) ? TRUE : FALSE;
$this->simple_query('BEGIN TRANSACTION');
return TRUE;
}
// --------------------------------------------------------------------
/**
* Commit Transaction
*
* @access public
* @return bool
*/
function trans_commit()
{
if ( ! $this->trans_enabled)
{
return TRUE;
}
// When transactions are nested we only begin/commit/rollback the outermost ones
if ($this->_trans_depth > 0)
{
return TRUE;
}
$this->simple_query('COMMIT');
return TRUE;
}
// --------------------------------------------------------------------
/**
* Rollback Transaction
*
* @access public
* @return bool
*/
function trans_rollback()
{
if ( ! $this->trans_enabled)
{
return TRUE;
}
// When transactions are nested we only begin/commit/rollback the outermost ones
if ($this->_trans_depth > 0)
{
return TRUE;
}
$this->simple_query('ROLLBACK');
return TRUE;
}
// --------------------------------------------------------------------
/**
* Escape String
*
* @access public
* @param string
* @param bool whether or not the string will be used in a LIKE condition
* @return string
*/
function escape_str($str, $like = FALSE)
{
if (is_array($str))
{
foreach ($str as $key => $val)
{
$str[$key] = $this->escape_str($val, $like);
}
return $str;
}
$str = sqlite_escape_string($str);
// escape LIKE condition wildcards
if ($like === TRUE)
{
$str = str_replace( array('%', '_', $this->_like_escape_chr),
array($this->_like_escape_chr.'%', $this->_like_escape_chr.'_', $this->_like_escape_chr.$this->_like_escape_chr),
$str);
}
return $str;
}
// --------------------------------------------------------------------
/**
* Affected Rows
*
* @access public
* @return integer
*/
function affected_rows()
{
return sqlite_changes($this->conn_id);
}
// --------------------------------------------------------------------
/**
* Insert ID
*
* @access public
* @return integer
*/
function insert_id()
{
return @sqlite_last_insert_rowid($this->conn_id);
}
// --------------------------------------------------------------------
/**
* "Count All" query
*
* Generates a platform-specific query string that counts all records in
* the specified database
*
* @access public
* @param string
* @return string
*/
function count_all($table = '')
{
if ($table == '')
{
return 0;
}
$query = $this->query($this->_count_string . $this->_protect_identifiers('numrows') . " FROM " . $this->_protect_identifiers($table, TRUE, NULL, FALSE));
if ($query->num_rows() == 0)
{
return 0;
}
$row = $query->row();
$this->_reset_select();
return (int) $row->numrows;
}
// --------------------------------------------------------------------
/**
* List table query
*
* Generates a platform-specific query string so that the table names can be fetched
*
* @access private
* @param boolean
* @return string
*/
function _list_tables($prefix_limit = FALSE)
{
$sql = "SELECT name from sqlite_master WHERE type='table'";
if ($prefix_limit !== FALSE AND $this->dbprefix != '')
{
$sql .= " AND 'name' LIKE '".$this->escape_like_str($this->dbprefix)."%' ".sprintf($this->_like_escape_str, $this->_like_escape_chr);
}
return $sql;
}
// --------------------------------------------------------------------
/**
* Show column query
*
* Generates a platform-specific query string so that the column names can be fetched
*
* @access public
* @param string the table name
* @return string
*/
function _list_columns($table = '')
{
// Not supported
return FALSE;
}
// --------------------------------------------------------------------
/**
* Field data query
*
* Generates a platform-specific query so that the column data can be retrieved
*
* @access public
* @param string the table name
* @return object
*/
function _field_data($table)
{
return "SELECT * FROM ".$table." LIMIT 1";
}
// --------------------------------------------------------------------
/**
* The error message string
*
* @access private
* @return string
*/
function _error_message()
{
return sqlite_error_string(sqlite_last_error($this->conn_id));
}
// --------------------------------------------------------------------
/**
* The error message number
*
* @access private
* @return integer
*/
function _error_number()
{
return sqlite_last_error($this->conn_id);
}
// --------------------------------------------------------------------
/**
* Escape the SQL Identifiers
*
* This function escapes column and table names
*
* @access private
* @param string
* @return string
*/
function _escape_identifiers($item)
{
if ($this->_escape_char == '')
{
return $item;
}
foreach ($this->_reserved_identifiers as $id)
{
if (strpos($item, '.'.$id) !== FALSE)
{
$str = $this->_escape_char. str_replace('.', $this->_escape_char.'.', $item);
// remove duplicates if the user already included the escape
return preg_replace('/['.$this->_escape_char.']+/', $this->_escape_char, $str);
}
}
if (strpos($item, '.') !== FALSE)
{
$str = $this->_escape_char.str_replace('.', $this->_escape_char.'.'.$this->_escape_char, $item).$this->_escape_char;
}
else
{
$str = $this->_escape_char.$item.$this->_escape_char;
}
// remove duplicates if the user already included the escape
return preg_replace('/['.$this->_escape_char.']+/', $this->_escape_char, $str);
}
// --------------------------------------------------------------------
/**
* From Tables
*
* This function implicitly groups FROM tables so there is no confusion
* about operator precedence in harmony with SQL standards
*
* @access public
* @param type
* @return type
*/
function _from_tables($tables)
{
if ( ! is_array($tables))
{
$tables = array($tables);
}
return '('.implode(', ', $tables).')';
}
// --------------------------------------------------------------------
/**
* Insert statement
*
* Generates a platform-specific insert string from the supplied data
*
* @access public
* @param string the table name
* @param array the insert keys
* @param array the insert values
* @return string
*/
function _insert($table, $keys, $values)
{
return "INSERT INTO ".$table." (".implode(', ', $keys).") VALUES (".implode(', ', $values).")";
}
// --------------------------------------------------------------------
/**
* Update statement
*
* Generates a platform-specific update string from the supplied data
*
* @access public
* @param string the table name
* @param array the update data
* @param array the where clause
* @param array the orderby clause
* @param array the limit clause
* @return string
*/
function _update($table, $values, $where, $orderby = array(), $limit = FALSE)
{
foreach ($values as $key => $val)
{
$valstr[] = $key." = ".$val;
}
$limit = ( ! $limit) ? '' : ' LIMIT '.$limit;
$orderby = (count($orderby) >= 1)?' ORDER BY '.implode(", ", $orderby):'';
$sql = "UPDATE ".$table." SET ".implode(', ', $valstr);
$sql .= ($where != '' AND count($where) >=1) ? " WHERE ".implode(" ", $where) : '';
$sql .= $orderby.$limit;
return $sql;
}
// --------------------------------------------------------------------
/**
* Truncate statement
*
* Generates a platform-specific truncate string from the supplied data
* If the database does not support the truncate() command
* This function maps to "DELETE FROM table"
*
* @access public
* @param string the table name
* @return string
*/
function _truncate($table)
{
return $this->_delete($table);
}
// --------------------------------------------------------------------
/**
* Delete statement
*
* Generates a platform-specific delete string from the supplied data
*
* @access public
* @param string the table name
* @param array the where clause
* @param string the limit clause
* @return string
*/
function _delete($table, $where = array(), $like = array(), $limit = FALSE)
{
$conditions = '';
if (count($where) > 0 OR count($like) > 0)
{
$conditions = "\nWHERE ";
$conditions .= implode("\n", $this->ar_where);
if (count($where) > 0 && count($like) > 0)
{
$conditions .= " AND ";
}
$conditions .= implode("\n", $like);
}
$limit = ( ! $limit) ? '' : ' LIMIT '.$limit;
return "DELETE FROM ".$table.$conditions.$limit;
}
// --------------------------------------------------------------------
/**
* Limit string
*
* Generates a platform-specific LIMIT clause
*
* @access public
* @param string the sql query string
* @param integer the number of rows to limit the query to
* @param integer the offset value
* @return string
*/
function _limit($sql, $limit, $offset)
{
if ($offset == 0)
{
$offset = '';
}
else
{
$offset .= ", ";
}
return $sql."LIMIT ".$offset.$limit;
}
// --------------------------------------------------------------------
/**
* Close DB Connection
*
* @access public
* @param resource
* @return void
*/
function _close($conn_id)
{
@sqlite_close($conn_id);
}
}
/* End of file sqlite_driver.php */
/* Location: ./system/database/drivers/sqlite/sqlite_driver.php */ | php | MIT | 152cd2d808675d2baeb9e77c229adfbaf9a16475 | 2026-01-05T05:21:15.334872Z | false |
MobilityLab/TransitScreen | https://github.com/MobilityLab/TransitScreen/blob/152cd2d808675d2baeb9e77c229adfbaf9a16475/system/database/drivers/sqlite/sqlite_result.php | system/database/drivers/sqlite/sqlite_result.php | <?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
/**
* CodeIgniter
*
* An open source application development framework for PHP 5.1.6 or newer
*
* @package CodeIgniter
* @author ExpressionEngine Dev Team
* @copyright Copyright (c) 2008 - 2011, EllisLab, Inc.
* @license http://codeigniter.com/user_guide/license.html
* @link http://codeigniter.com
* @since Version 1.0
* @filesource
*/
// ------------------------------------------------------------------------
/**
* SQLite Result Class
*
* This class extends the parent result class: CI_DB_result
*
* @category Database
* @author ExpressionEngine Dev Team
* @link http://codeigniter.com/user_guide/database/
*/
class CI_DB_sqlite_result extends CI_DB_result {
/**
* Number of rows in the result set
*
* @access public
* @return integer
*/
function num_rows()
{
return @sqlite_num_rows($this->result_id);
}
// --------------------------------------------------------------------
/**
* Number of fields in the result set
*
* @access public
* @return integer
*/
function num_fields()
{
return @sqlite_num_fields($this->result_id);
}
// --------------------------------------------------------------------
/**
* Fetch Field Names
*
* Generates an array of column names
*
* @access public
* @return array
*/
function list_fields()
{
$field_names = array();
for ($i = 0; $i < $this->num_fields(); $i++)
{
$field_names[] = sqlite_field_name($this->result_id, $i);
}
return $field_names;
}
// --------------------------------------------------------------------
/**
* Field data
*
* Generates an array of objects containing field meta-data
*
* @access public
* @return array
*/
function field_data()
{
$retval = array();
for ($i = 0; $i < $this->num_fields(); $i++)
{
$F = new stdClass();
$F->name = sqlite_field_name($this->result_id, $i);
$F->type = 'varchar';
$F->max_length = 0;
$F->primary_key = 0;
$F->default = '';
$retval[] = $F;
}
return $retval;
}
// --------------------------------------------------------------------
/**
* Free the result
*
* @return null
*/
function free_result()
{
// Not implemented in SQLite
}
// --------------------------------------------------------------------
/**
* Data Seek
*
* Moves the internal pointer to the desired offset. We call
* this internally before fetching results to make sure the
* result set starts at zero
*
* @access private
* @return array
*/
function _data_seek($n = 0)
{
return sqlite_seek($this->result_id, $n);
}
// --------------------------------------------------------------------
/**
* Result - associative array
*
* Returns the result set as an array
*
* @access private
* @return array
*/
function _fetch_assoc()
{
return sqlite_fetch_array($this->result_id);
}
// --------------------------------------------------------------------
/**
* Result - object
*
* Returns the result set as an object
*
* @access private
* @return object
*/
function _fetch_object()
{
if (function_exists('sqlite_fetch_object'))
{
return sqlite_fetch_object($this->result_id);
}
else
{
$arr = sqlite_fetch_array($this->result_id, SQLITE_ASSOC);
if (is_array($arr))
{
$obj = (object) $arr;
return $obj;
} else {
return NULL;
}
}
}
}
/* End of file sqlite_result.php */
/* Location: ./system/database/drivers/sqlite/sqlite_result.php */ | php | MIT | 152cd2d808675d2baeb9e77c229adfbaf9a16475 | 2026-01-05T05:21:15.334872Z | false |
MobilityLab/TransitScreen | https://github.com/MobilityLab/TransitScreen/blob/152cd2d808675d2baeb9e77c229adfbaf9a16475/system/database/drivers/sqlite/sqlite_forge.php | system/database/drivers/sqlite/sqlite_forge.php | <?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
/**
* CodeIgniter
*
* An open source application development framework for PHP 5.1.6 or newer
*
* @package CodeIgniter
* @author ExpressionEngine Dev Team
* @copyright Copyright (c) 2008 - 2011, EllisLab, Inc.
* @license http://codeigniter.com/user_guide/license.html
* @link http://codeigniter.com
* @since Version 1.0
* @filesource
*/
// ------------------------------------------------------------------------
/**
* SQLite Forge Class
*
* @category Database
* @author ExpressionEngine Dev Team
* @link http://codeigniter.com/user_guide/database/
*/
class CI_DB_sqlite_forge extends CI_DB_forge {
/**
* Create database
*
* @access public
* @param string the database name
* @return bool
*/
function _create_database()
{
// In SQLite, a database is created when you connect to the database.
// We'll return TRUE so that an error isn't generated
return TRUE;
}
// --------------------------------------------------------------------
/**
* Drop database
*
* @access private
* @param string the database name
* @return bool
*/
function _drop_database($name)
{
if ( ! @file_exists($this->db->database) OR ! @unlink($this->db->database))
{
if ($this->db->db_debug)
{
return $this->db->display_error('db_unable_to_drop');
}
return FALSE;
}
return TRUE;
}
// --------------------------------------------------------------------
/**
* Create Table
*
* @access private
* @param string the table name
* @param array the fields
* @param mixed primary key(s)
* @param mixed key(s)
* @param boolean should 'IF NOT EXISTS' be added to the SQL
* @return bool
*/
function _create_table($table, $fields, $primary_keys, $keys, $if_not_exists)
{
$sql = 'CREATE TABLE ';
// IF NOT EXISTS added to SQLite in 3.3.0
if ($if_not_exists === TRUE && version_compare($this->db->_version(), '3.3.0', '>=') === TRUE)
{
$sql .= 'IF NOT EXISTS ';
}
$sql .= $this->db->_escape_identifiers($table)."(";
$current_field_count = 0;
foreach ($fields as $field=>$attributes)
{
// Numeric field names aren't allowed in databases, so if the key is
// numeric, we know it was assigned by PHP and the developer manually
// entered the field information, so we'll simply add it to the list
if (is_numeric($field))
{
$sql .= "\n\t$attributes";
}
else
{
$attributes = array_change_key_case($attributes, CASE_UPPER);
$sql .= "\n\t".$this->db->_protect_identifiers($field);
$sql .= ' '.$attributes['TYPE'];
if (array_key_exists('CONSTRAINT', $attributes))
{
$sql .= '('.$attributes['CONSTRAINT'].')';
}
if (array_key_exists('UNSIGNED', $attributes) && $attributes['UNSIGNED'] === TRUE)
{
$sql .= ' UNSIGNED';
}
if (array_key_exists('DEFAULT', $attributes))
{
$sql .= ' DEFAULT \''.$attributes['DEFAULT'].'\'';
}
if (array_key_exists('NULL', $attributes) && $attributes['NULL'] === TRUE)
{
$sql .= ' NULL';
}
else
{
$sql .= ' NOT NULL';
}
if (array_key_exists('AUTO_INCREMENT', $attributes) && $attributes['AUTO_INCREMENT'] === TRUE)
{
$sql .= ' AUTO_INCREMENT';
}
}
// don't add a comma on the end of the last field
if (++$current_field_count < count($fields))
{
$sql .= ',';
}
}
if (count($primary_keys) > 0)
{
$primary_keys = $this->db->_protect_identifiers($primary_keys);
$sql .= ",\n\tPRIMARY KEY (" . implode(', ', $primary_keys) . ")";
}
if (is_array($keys) && count($keys) > 0)
{
foreach ($keys as $key)
{
if (is_array($key))
{
$key = $this->db->_protect_identifiers($key);
}
else
{
$key = array($this->db->_protect_identifiers($key));
}
$sql .= ",\n\tUNIQUE (" . implode(', ', $key) . ")";
}
}
$sql .= "\n)";
return $sql;
}
// --------------------------------------------------------------------
/**
* Drop Table
*
* Unsupported feature in SQLite
*
* @access private
* @return bool
*/
function _drop_table($table)
{
if ($this->db->db_debug)
{
return $this->db->display_error('db_unsuported_feature');
}
return array();
}
// --------------------------------------------------------------------
/**
* Alter table query
*
* Generates a platform-specific query so that a table can be altered
* Called by add_column(), drop_column(), and column_alter(),
*
* @access private
* @param string the ALTER type (ADD, DROP, CHANGE)
* @param string the column name
* @param string the table name
* @param string the column definition
* @param string the default value
* @param boolean should 'NOT NULL' be added
* @param string the field after which we should add the new field
* @return object
*/
function _alter_table($alter_type, $table, $column_name, $column_definition = '', $default_value = '', $null = '', $after_field = '')
{
$sql = 'ALTER TABLE '.$this->db->_protect_identifiers($table)." $alter_type ".$this->db->_protect_identifiers($column_name);
// DROP has everything it needs now.
if ($alter_type == 'DROP')
{
// SQLite does not support dropping columns
// http://www.sqlite.org/omitted.html
// http://www.sqlite.org/faq.html#q11
return FALSE;
}
$sql .= " $column_definition";
if ($default_value != '')
{
$sql .= " DEFAULT \"$default_value\"";
}
if ($null === NULL)
{
$sql .= ' NULL';
}
else
{
$sql .= ' NOT NULL';
}
if ($after_field != '')
{
$sql .= ' AFTER ' . $this->db->_protect_identifiers($after_field);
}
return $sql;
}
// --------------------------------------------------------------------
/**
* Rename a table
*
* Generates a platform-specific query so that a table can be renamed
*
* @access private
* @param string the old table name
* @param string the new table name
* @return string
*/
function _rename_table($table_name, $new_table_name)
{
$sql = 'ALTER TABLE '.$this->db->_protect_identifiers($table_name)." RENAME TO ".$this->db->_protect_identifiers($new_table_name);
return $sql;
}
}
/* End of file sqlite_forge.php */
/* Location: ./system/database/drivers/sqlite/sqlite_forge.php */ | php | MIT | 152cd2d808675d2baeb9e77c229adfbaf9a16475 | 2026-01-05T05:21:15.334872Z | false |
MobilityLab/TransitScreen | https://github.com/MobilityLab/TransitScreen/blob/152cd2d808675d2baeb9e77c229adfbaf9a16475/system/database/drivers/sqlite/sqlite_utility.php | system/database/drivers/sqlite/sqlite_utility.php | <?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
/**
* CodeIgniter
*
* An open source application development framework for PHP 5.1.6 or newer
*
* @package CodeIgniter
* @author ExpressionEngine Dev Team
* @copyright Copyright (c) 2008 - 2011, EllisLab, Inc.
* @license http://codeigniter.com/user_guide/license.html
* @link http://codeigniter.com
* @since Version 1.0
* @filesource
*/
// ------------------------------------------------------------------------
/**
* SQLite Utility Class
*
* @category Database
* @author ExpressionEngine Dev Team
* @link http://codeigniter.com/user_guide/database/
*/
class CI_DB_sqlite_utility extends CI_DB_utility {
/**
* List databases
*
* I don't believe you can do a database listing with SQLite
* since each database is its own file. I suppose we could
* try reading a directory looking for SQLite files, but
* that doesn't seem like a terribly good idea
*
* @access private
* @return bool
*/
function _list_databases()
{
if ($this->db_debug)
{
return $this->db->display_error('db_unsuported_feature');
}
return array();
}
// --------------------------------------------------------------------
/**
* Optimize table query
*
* Is optimization even supported in SQLite?
*
* @access private
* @param string the table name
* @return object
*/
function _optimize_table($table)
{
return FALSE;
}
// --------------------------------------------------------------------
/**
* Repair table query
*
* Are table repairs even supported in SQLite?
*
* @access private
* @param string the table name
* @return object
*/
function _repair_table($table)
{
return FALSE;
}
// --------------------------------------------------------------------
/**
* SQLite Export
*
* @access private
* @param array Preferences
* @return mixed
*/
function _backup($params = array())
{
// Currently unsupported
return $this->db->display_error('db_unsuported_feature');
}
}
/* End of file sqlite_utility.php */
/* Location: ./system/database/drivers/sqlite/sqlite_utility.php */ | php | MIT | 152cd2d808675d2baeb9e77c229adfbaf9a16475 | 2026-01-05T05:21:15.334872Z | false |
MobilityLab/TransitScreen | https://github.com/MobilityLab/TransitScreen/blob/152cd2d808675d2baeb9e77c229adfbaf9a16475/system/database/drivers/mysql/mysql_result.php | system/database/drivers/mysql/mysql_result.php | <?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
/**
* CodeIgniter
*
* An open source application development framework for PHP 5.1.6 or newer
*
* @package CodeIgniter
* @author ExpressionEngine Dev Team
* @copyright Copyright (c) 2008 - 2011, EllisLab, Inc.
* @license http://codeigniter.com/user_guide/license.html
* @link http://codeigniter.com
* @since Version 1.0
* @filesource
*/
// --------------------------------------------------------------------
/**
* MySQL Result Class
*
* This class extends the parent result class: CI_DB_result
*
* @category Database
* @author ExpressionEngine Dev Team
* @link http://codeigniter.com/user_guide/database/
*/
class CI_DB_mysql_result extends CI_DB_result {
/**
* Number of rows in the result set
*
* @access public
* @return integer
*/
function num_rows()
{
return @mysql_num_rows($this->result_id);
}
// --------------------------------------------------------------------
/**
* Number of fields in the result set
*
* @access public
* @return integer
*/
function num_fields()
{
return @mysql_num_fields($this->result_id);
}
// --------------------------------------------------------------------
/**
* Fetch Field Names
*
* Generates an array of column names
*
* @access public
* @return array
*/
function list_fields()
{
$field_names = array();
while ($field = mysql_fetch_field($this->result_id))
{
$field_names[] = $field->name;
}
return $field_names;
}
// --------------------------------------------------------------------
/**
* Field data
*
* Generates an array of objects containing field meta-data
*
* @access public
* @return array
*/
function field_data()
{
$retval = array();
while ($field = mysql_fetch_object($this->result_id))
{
preg_match('/([a-zA-Z]+)(\(\d+\))?/', $field->Type, $matches);
$type = (array_key_exists(1, $matches)) ? $matches[1] : NULL;
$length = (array_key_exists(2, $matches)) ? preg_replace('/[^\d]/', '', $matches[2]) : NULL;
$F = new stdClass();
$F->name = $field->Field;
$F->type = $type;
$F->default = $field->Default;
$F->max_length = $length;
$F->primary_key = ( $field->Key == 'PRI' ? 1 : 0 );
$retval[] = $F;
}
return $retval;
}
// --------------------------------------------------------------------
/**
* Free the result
*
* @return null
*/
function free_result()
{
if (is_resource($this->result_id))
{
mysql_free_result($this->result_id);
$this->result_id = FALSE;
}
}
// --------------------------------------------------------------------
/**
* Data Seek
*
* Moves the internal pointer to the desired offset. We call
* this internally before fetching results to make sure the
* result set starts at zero
*
* @access private
* @return array
*/
function _data_seek($n = 0)
{
return mysql_data_seek($this->result_id, $n);
}
// --------------------------------------------------------------------
/**
* Result - associative array
*
* Returns the result set as an array
*
* @access private
* @return array
*/
function _fetch_assoc()
{
return mysql_fetch_assoc($this->result_id);
}
// --------------------------------------------------------------------
/**
* Result - object
*
* Returns the result set as an object
*
* @access private
* @return object
*/
function _fetch_object()
{
return mysql_fetch_object($this->result_id);
}
}
/* End of file mysql_result.php */
/* Location: ./system/database/drivers/mysql/mysql_result.php */ | php | MIT | 152cd2d808675d2baeb9e77c229adfbaf9a16475 | 2026-01-05T05:21:15.334872Z | false |
MobilityLab/TransitScreen | https://github.com/MobilityLab/TransitScreen/blob/152cd2d808675d2baeb9e77c229adfbaf9a16475/system/database/drivers/mysql/mysql_forge.php | system/database/drivers/mysql/mysql_forge.php | <?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
/**
* CodeIgniter
*
* An open source application development framework for PHP 5.1.6 or newer
*
* @package CodeIgniter
* @author ExpressionEngine Dev Team
* @copyright Copyright (c) 2008 - 2011, EllisLab, Inc.
* @license http://codeigniter.com/user_guide/license.html
* @link http://codeigniter.com
* @since Version 1.0
* @filesource
*/
// ------------------------------------------------------------------------
/**
* MySQL Forge Class
*
* @category Database
* @author ExpressionEngine Dev Team
* @link http://codeigniter.com/user_guide/database/
*/
class CI_DB_mysql_forge extends CI_DB_forge {
/**
* Create database
*
* @access private
* @param string the database name
* @return bool
*/
function _create_database($name)
{
return "CREATE DATABASE ".$name;
}
// --------------------------------------------------------------------
/**
* Drop database
*
* @access private
* @param string the database name
* @return bool
*/
function _drop_database($name)
{
return "DROP DATABASE ".$name;
}
// --------------------------------------------------------------------
/**
* Process Fields
*
* @access private
* @param mixed the fields
* @return string
*/
function _process_fields($fields)
{
$current_field_count = 0;
$sql = '';
foreach ($fields as $field=>$attributes)
{
// Numeric field names aren't allowed in databases, so if the key is
// numeric, we know it was assigned by PHP and the developer manually
// entered the field information, so we'll simply add it to the list
if (is_numeric($field))
{
$sql .= "\n\t$attributes";
}
else
{
$attributes = array_change_key_case($attributes, CASE_UPPER);
$sql .= "\n\t".$this->db->_protect_identifiers($field);
if (array_key_exists('NAME', $attributes))
{
$sql .= ' '.$this->db->_protect_identifiers($attributes['NAME']).' ';
}
if (array_key_exists('TYPE', $attributes))
{
$sql .= ' '.$attributes['TYPE'];
if (array_key_exists('CONSTRAINT', $attributes))
{
switch ($attributes['TYPE'])
{
case 'decimal':
case 'float':
case 'numeric':
$sql .= '('.implode(',', $attributes['CONSTRAINT']).')';
break;
case 'enum':
case 'set':
$sql .= '("'.implode('","', $attributes['CONSTRAINT']).'")';
break;
default:
$sql .= '('.$attributes['CONSTRAINT'].')';
}
}
}
if (array_key_exists('UNSIGNED', $attributes) && $attributes['UNSIGNED'] === TRUE)
{
$sql .= ' UNSIGNED';
}
if (array_key_exists('DEFAULT', $attributes))
{
$sql .= ' DEFAULT \''.$attributes['DEFAULT'].'\'';
}
if (array_key_exists('NULL', $attributes) && $attributes['NULL'] === TRUE)
{
$sql .= ' NULL';
}
else
{
$sql .= ' NOT NULL';
}
if (array_key_exists('AUTO_INCREMENT', $attributes) && $attributes['AUTO_INCREMENT'] === TRUE)
{
$sql .= ' AUTO_INCREMENT';
}
}
// don't add a comma on the end of the last field
if (++$current_field_count < count($fields))
{
$sql .= ',';
}
}
return $sql;
}
// --------------------------------------------------------------------
/**
* Create Table
*
* @access private
* @param string the table name
* @param mixed the fields
* @param mixed primary key(s)
* @param mixed key(s)
* @param boolean should 'IF NOT EXISTS' be added to the SQL
* @return bool
*/
function _create_table($table, $fields, $primary_keys, $keys, $if_not_exists)
{
$sql = 'CREATE TABLE ';
if ($if_not_exists === TRUE)
{
$sql .= 'IF NOT EXISTS ';
}
$sql .= $this->db->_escape_identifiers($table)." (";
$sql .= $this->_process_fields($fields);
if (count($primary_keys) > 0)
{
$key_name = $this->db->_protect_identifiers(implode('_', $primary_keys));
$primary_keys = $this->db->_protect_identifiers($primary_keys);
$sql .= ",\n\tPRIMARY KEY ".$key_name." (" . implode(', ', $primary_keys) . ")";
}
if (is_array($keys) && count($keys) > 0)
{
foreach ($keys as $key)
{
if (is_array($key))
{
$key_name = $this->db->_protect_identifiers(implode('_', $key));
$key = $this->db->_protect_identifiers($key);
}
else
{
$key_name = $this->db->_protect_identifiers($key);
$key = array($key_name);
}
$sql .= ",\n\tKEY {$key_name} (" . implode(', ', $key) . ")";
}
}
$sql .= "\n) DEFAULT CHARACTER SET {$this->db->char_set} COLLATE {$this->db->dbcollat};";
return $sql;
}
// --------------------------------------------------------------------
/**
* Drop Table
*
* @access private
* @return string
*/
function _drop_table($table)
{
return "DROP TABLE IF EXISTS ".$this->db->_escape_identifiers($table);
}
// --------------------------------------------------------------------
/**
* Alter table query
*
* Generates a platform-specific query so that a table can be altered
* Called by add_column(), drop_column(), and column_alter(),
*
* @access private
* @param string the ALTER type (ADD, DROP, CHANGE)
* @param string the column name
* @param array fields
* @param string the field after which we should add the new field
* @return object
*/
function _alter_table($alter_type, $table, $fields, $after_field = '')
{
$sql = 'ALTER TABLE '.$this->db->_protect_identifiers($table)." $alter_type ";
// DROP has everything it needs now.
if ($alter_type == 'DROP')
{
return $sql.$this->db->_protect_identifiers($fields);
}
$sql .= $this->_process_fields($fields);
if ($after_field != '')
{
$sql .= ' AFTER ' . $this->db->_protect_identifiers($after_field);
}
return $sql;
}
// --------------------------------------------------------------------
/**
* Rename a table
*
* Generates a platform-specific query so that a table can be renamed
*
* @access private
* @param string the old table name
* @param string the new table name
* @return string
*/
function _rename_table($table_name, $new_table_name)
{
$sql = 'ALTER TABLE '.$this->db->_protect_identifiers($table_name)." RENAME TO ".$this->db->_protect_identifiers($new_table_name);
return $sql;
}
}
/* End of file mysql_forge.php */
/* Location: ./system/database/drivers/mysql/mysql_forge.php */ | php | MIT | 152cd2d808675d2baeb9e77c229adfbaf9a16475 | 2026-01-05T05:21:15.334872Z | false |
MobilityLab/TransitScreen | https://github.com/MobilityLab/TransitScreen/blob/152cd2d808675d2baeb9e77c229adfbaf9a16475/system/database/drivers/mysql/mysql_driver.php | system/database/drivers/mysql/mysql_driver.php | <?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
/**
* CodeIgniter
*
* An open source application development framework for PHP 5.1.6 or newer
*
* @package CodeIgniter
* @author ExpressionEngine Dev Team
* @copyright Copyright (c) 2008 - 2011, EllisLab, Inc.
* @license http://codeigniter.com/user_guide/license.html
* @link http://codeigniter.com
* @since Version 1.0
* @filesource
*/
// ------------------------------------------------------------------------
/**
* MySQL Database Adapter Class
*
* Note: _DB is an extender class that the app controller
* creates dynamically based on whether the active record
* class is being used or not.
*
* @package CodeIgniter
* @subpackage Drivers
* @category Database
* @author ExpressionEngine Dev Team
* @link http://codeigniter.com/user_guide/database/
*/
class CI_DB_mysql_driver extends CI_DB {
var $dbdriver = 'mysql';
// The character used for escaping
var $_escape_char = '`';
// clause and character used for LIKE escape sequences - not used in MySQL
var $_like_escape_str = '';
var $_like_escape_chr = '';
/**
* Whether to use the MySQL "delete hack" which allows the number
* of affected rows to be shown. Uses a preg_replace when enabled,
* adding a bit more processing to all queries.
*/
var $delete_hack = TRUE;
/**
* The syntax to count rows is slightly different across different
* database engines, so this string appears in each driver and is
* used for the count_all() and count_all_results() functions.
*/
var $_count_string = 'SELECT COUNT(*) AS ';
var $_random_keyword = ' RAND()'; // database specific random keyword
// whether SET NAMES must be used to set the character set
var $use_set_names;
/**
* Non-persistent database connection
*
* @access private called by the base class
* @return resource
*/
function db_connect()
{
if ($this->port != '')
{
$this->hostname .= ':'.$this->port;
}
return @mysql_connect($this->hostname, $this->username, $this->password, TRUE);
}
// --------------------------------------------------------------------
/**
* Persistent database connection
*
* @access private called by the base class
* @return resource
*/
function db_pconnect()
{
if ($this->port != '')
{
$this->hostname .= ':'.$this->port;
}
return @mysql_pconnect($this->hostname, $this->username, $this->password);
}
// --------------------------------------------------------------------
/**
* Reconnect
*
* Keep / reestablish the db connection if no queries have been
* sent for a length of time exceeding the server's idle timeout
*
* @access public
* @return void
*/
function reconnect()
{
if (mysql_ping($this->conn_id) === FALSE)
{
$this->conn_id = FALSE;
}
}
// --------------------------------------------------------------------
/**
* Select the database
*
* @access private called by the base class
* @return resource
*/
function db_select()
{
return @mysql_select_db($this->database, $this->conn_id);
}
// --------------------------------------------------------------------
/**
* Set client character set
*
* @access public
* @param string
* @param string
* @return resource
*/
function db_set_charset($charset, $collation)
{
if ( ! isset($this->use_set_names))
{
// mysql_set_charset() requires PHP >= 5.2.3 and MySQL >= 5.0.7, use SET NAMES as fallback
$this->use_set_names = (version_compare(PHP_VERSION, '5.2.3', '>=') && version_compare(mysql_get_server_info(), '5.0.7', '>=')) ? FALSE : TRUE;
}
if ($this->use_set_names === TRUE)
{
return @mysql_query("SET NAMES '".$this->escape_str($charset)."' COLLATE '".$this->escape_str($collation)."'", $this->conn_id);
}
else
{
return @mysql_set_charset($charset, $this->conn_id);
}
}
// --------------------------------------------------------------------
/**
* Version number query string
*
* @access public
* @return string
*/
function _version()
{
return "SELECT version() AS ver";
}
// --------------------------------------------------------------------
/**
* Execute the query
*
* @access private called by the base class
* @param string an SQL query
* @return resource
*/
function _execute($sql)
{
$sql = $this->_prep_query($sql);
return @mysql_query($sql, $this->conn_id);
}
// --------------------------------------------------------------------
/**
* Prep the query
*
* If needed, each database adapter can prep the query string
*
* @access private called by execute()
* @param string an SQL query
* @return string
*/
function _prep_query($sql)
{
// "DELETE FROM TABLE" returns 0 affected rows This hack modifies
// the query so that it returns the number of affected rows
if ($this->delete_hack === TRUE)
{
if (preg_match('/^\s*DELETE\s+FROM\s+(\S+)\s*$/i', $sql))
{
$sql = preg_replace("/^\s*DELETE\s+FROM\s+(\S+)\s*$/", "DELETE FROM \\1 WHERE 1=1", $sql);
}
}
return $sql;
}
// --------------------------------------------------------------------
/**
* Begin Transaction
*
* @access public
* @return bool
*/
function trans_begin($test_mode = FALSE)
{
if ( ! $this->trans_enabled)
{
return TRUE;
}
// When transactions are nested we only begin/commit/rollback the outermost ones
if ($this->_trans_depth > 0)
{
return TRUE;
}
// Reset the transaction failure flag.
// If the $test_mode flag is set to TRUE transactions will be rolled back
// even if the queries produce a successful result.
$this->_trans_failure = ($test_mode === TRUE) ? TRUE : FALSE;
$this->simple_query('SET AUTOCOMMIT=0');
$this->simple_query('START TRANSACTION'); // can also be BEGIN or BEGIN WORK
return TRUE;
}
// --------------------------------------------------------------------
/**
* Commit Transaction
*
* @access public
* @return bool
*/
function trans_commit()
{
if ( ! $this->trans_enabled)
{
return TRUE;
}
// When transactions are nested we only begin/commit/rollback the outermost ones
if ($this->_trans_depth > 0)
{
return TRUE;
}
$this->simple_query('COMMIT');
$this->simple_query('SET AUTOCOMMIT=1');
return TRUE;
}
// --------------------------------------------------------------------
/**
* Rollback Transaction
*
* @access public
* @return bool
*/
function trans_rollback()
{
if ( ! $this->trans_enabled)
{
return TRUE;
}
// When transactions are nested we only begin/commit/rollback the outermost ones
if ($this->_trans_depth > 0)
{
return TRUE;
}
$this->simple_query('ROLLBACK');
$this->simple_query('SET AUTOCOMMIT=1');
return TRUE;
}
// --------------------------------------------------------------------
/**
* Escape String
*
* @access public
* @param string
* @param bool whether or not the string will be used in a LIKE condition
* @return string
*/
function escape_str($str, $like = FALSE)
{
if (is_array($str))
{
foreach ($str as $key => $val)
{
$str[$key] = $this->escape_str($val, $like);
}
return $str;
}
if (function_exists('mysql_real_escape_string') AND is_resource($this->conn_id))
{
$str = mysql_real_escape_string($str, $this->conn_id);
}
elseif (function_exists('mysql_escape_string'))
{
$str = mysql_escape_string($str);
}
else
{
$str = addslashes($str);
}
// escape LIKE condition wildcards
if ($like === TRUE)
{
$str = str_replace(array('%', '_'), array('\\%', '\\_'), $str);
}
return $str;
}
// --------------------------------------------------------------------
/**
* Affected Rows
*
* @access public
* @return integer
*/
function affected_rows()
{
return @mysql_affected_rows($this->conn_id);
}
// --------------------------------------------------------------------
/**
* Insert ID
*
* @access public
* @return integer
*/
function insert_id()
{
return @mysql_insert_id($this->conn_id);
}
// --------------------------------------------------------------------
/**
* "Count All" query
*
* Generates a platform-specific query string that counts all records in
* the specified database
*
* @access public
* @param string
* @return string
*/
function count_all($table = '')
{
if ($table == '')
{
return 0;
}
$query = $this->query($this->_count_string . $this->_protect_identifiers('numrows') . " FROM " . $this->_protect_identifiers($table, TRUE, NULL, FALSE));
if ($query->num_rows() == 0)
{
return 0;
}
$row = $query->row();
$this->_reset_select();
return (int) $row->numrows;
}
// --------------------------------------------------------------------
/**
* List table query
*
* Generates a platform-specific query string so that the table names can be fetched
*
* @access private
* @param boolean
* @return string
*/
function _list_tables($prefix_limit = FALSE)
{
$sql = "SHOW TABLES FROM ".$this->_escape_char.$this->database.$this->_escape_char;
if ($prefix_limit !== FALSE AND $this->dbprefix != '')
{
$sql .= " LIKE '".$this->escape_like_str($this->dbprefix)."%'";
}
return $sql;
}
// --------------------------------------------------------------------
/**
* Show column query
*
* Generates a platform-specific query string so that the column names can be fetched
*
* @access public
* @param string the table name
* @return string
*/
function _list_columns($table = '')
{
return "SHOW COLUMNS FROM ".$this->_protect_identifiers($table, TRUE, NULL, FALSE);
}
// --------------------------------------------------------------------
/**
* Field data query
*
* Generates a platform-specific query so that the column data can be retrieved
*
* @access public
* @param string the table name
* @return object
*/
function _field_data($table)
{
return "DESCRIBE ".$table;
}
// --------------------------------------------------------------------
/**
* The error message string
*
* @access private
* @return string
*/
function _error_message()
{
return mysql_error($this->conn_id);
}
// --------------------------------------------------------------------
/**
* The error message number
*
* @access private
* @return integer
*/
function _error_number()
{
return mysql_errno($this->conn_id);
}
// --------------------------------------------------------------------
/**
* Escape the SQL Identifiers
*
* This function escapes column and table names
*
* @access private
* @param string
* @return string
*/
function _escape_identifiers($item)
{
if ($this->_escape_char == '')
{
return $item;
}
foreach ($this->_reserved_identifiers as $id)
{
if (strpos($item, '.'.$id) !== FALSE)
{
$str = $this->_escape_char. str_replace('.', $this->_escape_char.'.', $item);
// remove duplicates if the user already included the escape
return preg_replace('/['.$this->_escape_char.']+/', $this->_escape_char, $str);
}
}
if (strpos($item, '.') !== FALSE)
{
$str = $this->_escape_char.str_replace('.', $this->_escape_char.'.'.$this->_escape_char, $item).$this->_escape_char;
}
else
{
$str = $this->_escape_char.$item.$this->_escape_char;
}
// remove duplicates if the user already included the escape
return preg_replace('/['.$this->_escape_char.']+/', $this->_escape_char, $str);
}
// --------------------------------------------------------------------
/**
* From Tables
*
* This function implicitly groups FROM tables so there is no confusion
* about operator precedence in harmony with SQL standards
*
* @access public
* @param type
* @return type
*/
function _from_tables($tables)
{
if ( ! is_array($tables))
{
$tables = array($tables);
}
return '('.implode(', ', $tables).')';
}
// --------------------------------------------------------------------
/**
* Insert statement
*
* Generates a platform-specific insert string from the supplied data
*
* @access public
* @param string the table name
* @param array the insert keys
* @param array the insert values
* @return string
*/
function _insert($table, $keys, $values)
{
return "INSERT INTO ".$table." (".implode(', ', $keys).") VALUES (".implode(', ', $values).")";
}
// --------------------------------------------------------------------
/**
* Replace statement
*
* Generates a platform-specific replace string from the supplied data
*
* @access public
* @param string the table name
* @param array the insert keys
* @param array the insert values
* @return string
*/
function _replace($table, $keys, $values)
{
return "REPLACE INTO ".$table." (".implode(', ', $keys).") VALUES (".implode(', ', $values).")";
}
// --------------------------------------------------------------------
/**
* Insert_batch statement
*
* Generates a platform-specific insert string from the supplied data
*
* @access public
* @param string the table name
* @param array the insert keys
* @param array the insert values
* @return string
*/
function _insert_batch($table, $keys, $values)
{
return "INSERT INTO ".$table." (".implode(', ', $keys).") VALUES ".implode(', ', $values);
}
// --------------------------------------------------------------------
/**
* Update statement
*
* Generates a platform-specific update string from the supplied data
*
* @access public
* @param string the table name
* @param array the update data
* @param array the where clause
* @param array the orderby clause
* @param array the limit clause
* @return string
*/
function _update($table, $values, $where, $orderby = array(), $limit = FALSE)
{
foreach ($values as $key => $val)
{
$valstr[] = $key . ' = ' . $val;
}
$limit = ( ! $limit) ? '' : ' LIMIT '.$limit;
$orderby = (count($orderby) >= 1)?' ORDER BY '.implode(", ", $orderby):'';
$sql = "UPDATE ".$table." SET ".implode(', ', $valstr);
$sql .= ($where != '' AND count($where) >=1) ? " WHERE ".implode(" ", $where) : '';
$sql .= $orderby.$limit;
return $sql;
}
// --------------------------------------------------------------------
/**
* Update_Batch statement
*
* Generates a platform-specific batch update string from the supplied data
*
* @access public
* @param string the table name
* @param array the update data
* @param array the where clause
* @return string
*/
function _update_batch($table, $values, $index, $where = NULL)
{
$ids = array();
$where = ($where != '' AND count($where) >=1) ? implode(" ", $where).' AND ' : '';
foreach ($values as $key => $val)
{
$ids[] = $val[$index];
foreach (array_keys($val) as $field)
{
if ($field != $index)
{
$final[$field][] = 'WHEN '.$index.' = '.$val[$index].' THEN '.$val[$field];
}
}
}
$sql = "UPDATE ".$table." SET ";
$cases = '';
foreach ($final as $k => $v)
{
$cases .= $k.' = CASE '."\n";
foreach ($v as $row)
{
$cases .= $row."\n";
}
$cases .= 'ELSE '.$k.' END, ';
}
$sql .= substr($cases, 0, -2);
$sql .= ' WHERE '.$where.$index.' IN ('.implode(',', $ids).')';
return $sql;
}
// --------------------------------------------------------------------
/**
* Truncate statement
*
* Generates a platform-specific truncate string from the supplied data
* If the database does not support the truncate() command
* This function maps to "DELETE FROM table"
*
* @access public
* @param string the table name
* @return string
*/
function _truncate($table)
{
return "TRUNCATE ".$table;
}
// --------------------------------------------------------------------
/**
* Delete statement
*
* Generates a platform-specific delete string from the supplied data
*
* @access public
* @param string the table name
* @param array the where clause
* @param string the limit clause
* @return string
*/
function _delete($table, $where = array(), $like = array(), $limit = FALSE)
{
$conditions = '';
if (count($where) > 0 OR count($like) > 0)
{
$conditions = "\nWHERE ";
$conditions .= implode("\n", $this->ar_where);
if (count($where) > 0 && count($like) > 0)
{
$conditions .= " AND ";
}
$conditions .= implode("\n", $like);
}
$limit = ( ! $limit) ? '' : ' LIMIT '.$limit;
return "DELETE FROM ".$table.$conditions.$limit;
}
// --------------------------------------------------------------------
/**
* Limit string
*
* Generates a platform-specific LIMIT clause
*
* @access public
* @param string the sql query string
* @param integer the number of rows to limit the query to
* @param integer the offset value
* @return string
*/
function _limit($sql, $limit, $offset)
{
if ($offset == 0)
{
$offset = '';
}
else
{
$offset .= ", ";
}
return $sql."LIMIT ".$offset.$limit;
}
// --------------------------------------------------------------------
/**
* Close DB Connection
*
* @access public
* @param resource
* @return void
*/
function _close($conn_id)
{
@mysql_close($conn_id);
}
}
/* End of file mysql_driver.php */
/* Location: ./system/database/drivers/mysql/mysql_driver.php */ | php | MIT | 152cd2d808675d2baeb9e77c229adfbaf9a16475 | 2026-01-05T05:21:15.334872Z | false |
MobilityLab/TransitScreen | https://github.com/MobilityLab/TransitScreen/blob/152cd2d808675d2baeb9e77c229adfbaf9a16475/system/database/drivers/mysql/mysql_utility.php | system/database/drivers/mysql/mysql_utility.php | <?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
/**
* CodeIgniter
*
* An open source application development framework for PHP 5.1.6 or newer
*
* @package CodeIgniter
* @author ExpressionEngine Dev Team
* @copyright Copyright (c) 2008 - 2011, EllisLab, Inc.
* @license http://codeigniter.com/user_guide/license.html
* @link http://codeigniter.com
* @since Version 1.0
* @filesource
*/
// ------------------------------------------------------------------------
/**
* MySQL Utility Class
*
* @category Database
* @author ExpressionEngine Dev Team
* @link http://codeigniter.com/user_guide/database/
*/
class CI_DB_mysql_utility extends CI_DB_utility {
/**
* List databases
*
* @access private
* @return bool
*/
function _list_databases()
{
return "SHOW DATABASES";
}
// --------------------------------------------------------------------
/**
* Optimize table query
*
* Generates a platform-specific query so that a table can be optimized
*
* @access private
* @param string the table name
* @return object
*/
function _optimize_table($table)
{
return "OPTIMIZE TABLE ".$this->db->_escape_identifiers($table);
}
// --------------------------------------------------------------------
/**
* Repair table query
*
* Generates a platform-specific query so that a table can be repaired
*
* @access private
* @param string the table name
* @return object
*/
function _repair_table($table)
{
return "REPAIR TABLE ".$this->db->_escape_identifiers($table);
}
// --------------------------------------------------------------------
/**
* MySQL Export
*
* @access private
* @param array Preferences
* @return mixed
*/
function _backup($params = array())
{
if (count($params) == 0)
{
return FALSE;
}
// Extract the prefs for simplicity
extract($params);
// Build the output
$output = '';
foreach ((array)$tables as $table)
{
// Is the table in the "ignore" list?
if (in_array($table, (array)$ignore, TRUE))
{
continue;
}
// Get the table schema
$query = $this->db->query("SHOW CREATE TABLE `".$this->db->database.'`.`'.$table.'`');
// No result means the table name was invalid
if ($query === FALSE)
{
continue;
}
// Write out the table schema
$output .= '#'.$newline.'# TABLE STRUCTURE FOR: '.$table.$newline.'#'.$newline.$newline;
if ($add_drop == TRUE)
{
$output .= 'DROP TABLE IF EXISTS '.$table.';'.$newline.$newline;
}
$i = 0;
$result = $query->result_array();
foreach ($result[0] as $val)
{
if ($i++ % 2)
{
$output .= $val.';'.$newline.$newline;
}
}
// If inserts are not needed we're done...
if ($add_insert == FALSE)
{
continue;
}
// Grab all the data from the current table
$query = $this->db->query("SELECT * FROM $table");
if ($query->num_rows() == 0)
{
continue;
}
// Fetch the field names and determine if the field is an
// integer type. We use this info to decide whether to
// surround the data with quotes or not
$i = 0;
$field_str = '';
$is_int = array();
while ($field = mysql_fetch_field($query->result_id))
{
// Most versions of MySQL store timestamp as a string
$is_int[$i] = (in_array(
strtolower(mysql_field_type($query->result_id, $i)),
array('tinyint', 'smallint', 'mediumint', 'int', 'bigint'), //, 'timestamp'),
TRUE)
) ? TRUE : FALSE;
// Create a string of field names
$field_str .= '`'.$field->name.'`, ';
$i++;
}
// Trim off the end comma
$field_str = preg_replace( "/, $/" , "" , $field_str);
// Build the insert string
foreach ($query->result_array() as $row)
{
$val_str = '';
$i = 0;
foreach ($row as $v)
{
// Is the value NULL?
if ($v === NULL)
{
$val_str .= 'NULL';
}
else
{
// Escape the data if it's not an integer
if ($is_int[$i] == FALSE)
{
$val_str .= $this->db->escape($v);
}
else
{
$val_str .= $v;
}
}
// Append a comma
$val_str .= ', ';
$i++;
}
// Remove the comma at the end of the string
$val_str = preg_replace( "/, $/" , "" , $val_str);
// Build the INSERT string
$output .= 'INSERT INTO '.$table.' ('.$field_str.') VALUES ('.$val_str.');'.$newline;
}
$output .= $newline.$newline;
}
return $output;
}
}
/* End of file mysql_utility.php */
/* Location: ./system/database/drivers/mysql/mysql_utility.php */ | php | MIT | 152cd2d808675d2baeb9e77c229adfbaf9a16475 | 2026-01-05T05:21:15.334872Z | false |
MobilityLab/TransitScreen | https://github.com/MobilityLab/TransitScreen/blob/152cd2d808675d2baeb9e77c229adfbaf9a16475/system/database/drivers/mysqli/mysqli_driver.php | system/database/drivers/mysqli/mysqli_driver.php | <?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
/**
* CodeIgniter
*
* An open source application development framework for PHP 5.1.6 or newer
*
* @package CodeIgniter
* @author ExpressionEngine Dev Team
* @copyright Copyright (c) 2008 - 2011, EllisLab, Inc.
* @license http://codeigniter.com/user_guide/license.html
* @link http://codeigniter.com
* @since Version 1.0
* @filesource
*/
// ------------------------------------------------------------------------
/**
* MySQLi Database Adapter Class - MySQLi only works with PHP 5
*
* Note: _DB is an extender class that the app controller
* creates dynamically based on whether the active record
* class is being used or not.
*
* @package CodeIgniter
* @subpackage Drivers
* @category Database
* @author ExpressionEngine Dev Team
* @link http://codeigniter.com/user_guide/database/
*/
class CI_DB_mysqli_driver extends CI_DB {
var $dbdriver = 'mysqli';
// The character used for escaping
var $_escape_char = '`';
// clause and character used for LIKE escape sequences - not used in MySQL
var $_like_escape_str = '';
var $_like_escape_chr = '';
/**
* The syntax to count rows is slightly different across different
* database engines, so this string appears in each driver and is
* used for the count_all() and count_all_results() functions.
*/
var $_count_string = "SELECT COUNT(*) AS ";
var $_random_keyword = ' RAND()'; // database specific random keyword
/**
* Whether to use the MySQL "delete hack" which allows the number
* of affected rows to be shown. Uses a preg_replace when enabled,
* adding a bit more processing to all queries.
*/
var $delete_hack = TRUE;
// whether SET NAMES must be used to set the character set
var $use_set_names;
// --------------------------------------------------------------------
/**
* Non-persistent database connection
*
* @access private called by the base class
* @return resource
*/
function db_connect()
{
if ($this->port != '')
{
return @mysqli_connect($this->hostname, $this->username, $this->password, $this->database, $this->port);
}
else
{
return @mysqli_connect($this->hostname, $this->username, $this->password, $this->database);
}
}
// --------------------------------------------------------------------
/**
* Persistent database connection
*
* @access private called by the base class
* @return resource
*/
function db_pconnect()
{
return $this->db_connect();
}
// --------------------------------------------------------------------
/**
* Reconnect
*
* Keep / reestablish the db connection if no queries have been
* sent for a length of time exceeding the server's idle timeout
*
* @access public
* @return void
*/
function reconnect()
{
if (mysqli_ping($this->conn_id) === FALSE)
{
$this->conn_id = FALSE;
}
}
// --------------------------------------------------------------------
/**
* Select the database
*
* @access private called by the base class
* @return resource
*/
function db_select()
{
return @mysqli_select_db($this->conn_id, $this->database);
}
// --------------------------------------------------------------------
/**
* Set client character set
*
* @access private
* @param string
* @param string
* @return resource
*/
function _db_set_charset($charset, $collation)
{
if ( ! isset($this->use_set_names))
{
// mysqli_set_charset() requires MySQL >= 5.0.7, use SET NAMES as fallback
$this->use_set_names = (version_compare(mysqli_get_server_info($this->conn_id), '5.0.7', '>=')) ? FALSE : TRUE;
}
if ($this->use_set_names === TRUE)
{
return @mysqli_query($this->conn_id, "SET NAMES '".$this->escape_str($charset)."' COLLATE '".$this->escape_str($collation)."'");
}
else
{
return @mysqli_set_charset($this->conn_id, $charset);
}
}
// --------------------------------------------------------------------
/**
* Version number query string
*
* @access public
* @return string
*/
function _version()
{
return "SELECT version() AS ver";
}
// --------------------------------------------------------------------
/**
* Execute the query
*
* @access private called by the base class
* @param string an SQL query
* @return resource
*/
function _execute($sql)
{
$sql = $this->_prep_query($sql);
$result = @mysqli_query($this->conn_id, $sql);
return $result;
}
// --------------------------------------------------------------------
/**
* Prep the query
*
* If needed, each database adapter can prep the query string
*
* @access private called by execute()
* @param string an SQL query
* @return string
*/
function _prep_query($sql)
{
// "DELETE FROM TABLE" returns 0 affected rows This hack modifies
// the query so that it returns the number of affected rows
if ($this->delete_hack === TRUE)
{
if (preg_match('/^\s*DELETE\s+FROM\s+(\S+)\s*$/i', $sql))
{
$sql = preg_replace("/^\s*DELETE\s+FROM\s+(\S+)\s*$/", "DELETE FROM \\1 WHERE 1=1", $sql);
}
}
return $sql;
}
// --------------------------------------------------------------------
/**
* Begin Transaction
*
* @access public
* @return bool
*/
function trans_begin($test_mode = FALSE)
{
if ( ! $this->trans_enabled)
{
return TRUE;
}
// When transactions are nested we only begin/commit/rollback the outermost ones
if ($this->_trans_depth > 0)
{
return TRUE;
}
// Reset the transaction failure flag.
// If the $test_mode flag is set to TRUE transactions will be rolled back
// even if the queries produce a successful result.
$this->_trans_failure = ($test_mode === TRUE) ? TRUE : FALSE;
$this->simple_query('SET AUTOCOMMIT=0');
$this->simple_query('START TRANSACTION'); // can also be BEGIN or BEGIN WORK
return TRUE;
}
// --------------------------------------------------------------------
/**
* Commit Transaction
*
* @access public
* @return bool
*/
function trans_commit()
{
if ( ! $this->trans_enabled)
{
return TRUE;
}
// When transactions are nested we only begin/commit/rollback the outermost ones
if ($this->_trans_depth > 0)
{
return TRUE;
}
$this->simple_query('COMMIT');
$this->simple_query('SET AUTOCOMMIT=1');
return TRUE;
}
// --------------------------------------------------------------------
/**
* Rollback Transaction
*
* @access public
* @return bool
*/
function trans_rollback()
{
if ( ! $this->trans_enabled)
{
return TRUE;
}
// When transactions are nested we only begin/commit/rollback the outermost ones
if ($this->_trans_depth > 0)
{
return TRUE;
}
$this->simple_query('ROLLBACK');
$this->simple_query('SET AUTOCOMMIT=1');
return TRUE;
}
// --------------------------------------------------------------------
/**
* Escape String
*
* @access public
* @param string
* @param bool whether or not the string will be used in a LIKE condition
* @return string
*/
function escape_str($str, $like = FALSE)
{
if (is_array($str))
{
foreach ($str as $key => $val)
{
$str[$key] = $this->escape_str($val, $like);
}
return $str;
}
if (function_exists('mysqli_real_escape_string') AND is_object($this->conn_id))
{
$str = mysqli_real_escape_string($this->conn_id, $str);
}
elseif (function_exists('mysql_escape_string'))
{
$str = mysql_escape_string($str);
}
else
{
$str = addslashes($str);
}
// escape LIKE condition wildcards
if ($like === TRUE)
{
$str = str_replace(array('%', '_'), array('\\%', '\\_'), $str);
}
return $str;
}
// --------------------------------------------------------------------
/**
* Affected Rows
*
* @access public
* @return integer
*/
function affected_rows()
{
return @mysqli_affected_rows($this->conn_id);
}
// --------------------------------------------------------------------
/**
* Insert ID
*
* @access public
* @return integer
*/
function insert_id()
{
return @mysqli_insert_id($this->conn_id);
}
// --------------------------------------------------------------------
/**
* "Count All" query
*
* Generates a platform-specific query string that counts all records in
* the specified database
*
* @access public
* @param string
* @return string
*/
function count_all($table = '')
{
if ($table == '')
{
return 0;
}
$query = $this->query($this->_count_string . $this->_protect_identifiers('numrows') . " FROM " . $this->_protect_identifiers($table, TRUE, NULL, FALSE));
if ($query->num_rows() == 0)
{
return 0;
}
$row = $query->row();
$this->_reset_select();
return (int) $row->numrows;
}
// --------------------------------------------------------------------
/**
* List table query
*
* Generates a platform-specific query string so that the table names can be fetched
*
* @access private
* @param boolean
* @return string
*/
function _list_tables($prefix_limit = FALSE)
{
$sql = "SHOW TABLES FROM ".$this->_escape_char.$this->database.$this->_escape_char;
if ($prefix_limit !== FALSE AND $this->dbprefix != '')
{
$sql .= " LIKE '".$this->escape_like_str($this->dbprefix)."%'";
}
return $sql;
}
// --------------------------------------------------------------------
/**
* Show column query
*
* Generates a platform-specific query string so that the column names can be fetched
*
* @access public
* @param string the table name
* @return string
*/
function _list_columns($table = '')
{
return "SHOW COLUMNS FROM ".$this->_protect_identifiers($table, TRUE, NULL, FALSE);
}
// --------------------------------------------------------------------
/**
* Field data query
*
* Generates a platform-specific query so that the column data can be retrieved
*
* @access public
* @param string the table name
* @return object
*/
function _field_data($table)
{
return "DESCRIBE ".$table;
}
// --------------------------------------------------------------------
/**
* The error message string
*
* @access private
* @return string
*/
function _error_message()
{
return mysqli_error($this->conn_id);
}
// --------------------------------------------------------------------
/**
* The error message number
*
* @access private
* @return integer
*/
function _error_number()
{
return mysqli_errno($this->conn_id);
}
// --------------------------------------------------------------------
/**
* Escape the SQL Identifiers
*
* This function escapes column and table names
*
* @access private
* @param string
* @return string
*/
function _escape_identifiers($item)
{
if ($this->_escape_char == '')
{
return $item;
}
foreach ($this->_reserved_identifiers as $id)
{
if (strpos($item, '.'.$id) !== FALSE)
{
$str = $this->_escape_char. str_replace('.', $this->_escape_char.'.', $item);
// remove duplicates if the user already included the escape
return preg_replace('/['.$this->_escape_char.']+/', $this->_escape_char, $str);
}
}
if (strpos($item, '.') !== FALSE)
{
$str = $this->_escape_char.str_replace('.', $this->_escape_char.'.'.$this->_escape_char, $item).$this->_escape_char;
}
else
{
$str = $this->_escape_char.$item.$this->_escape_char;
}
// remove duplicates if the user already included the escape
return preg_replace('/['.$this->_escape_char.']+/', $this->_escape_char, $str);
}
// --------------------------------------------------------------------
/**
* From Tables
*
* This function implicitly groups FROM tables so there is no confusion
* about operator precedence in harmony with SQL standards
*
* @access public
* @param type
* @return type
*/
function _from_tables($tables)
{
if ( ! is_array($tables))
{
$tables = array($tables);
}
return '('.implode(', ', $tables).')';
}
// --------------------------------------------------------------------
/**
* Insert statement
*
* Generates a platform-specific insert string from the supplied data
*
* @access public
* @param string the table name
* @param array the insert keys
* @param array the insert values
* @return string
*/
function _insert($table, $keys, $values)
{
return "INSERT INTO ".$table." (".implode(', ', $keys).") VALUES (".implode(', ', $values).")";
}
// --------------------------------------------------------------------
/**
* Insert_batch statement
*
* Generates a platform-specific insert string from the supplied data
*
* @access public
* @param string the table name
* @param array the insert keys
* @param array the insert values
* @return string
*/
function _insert_batch($table, $keys, $values)
{
return "INSERT INTO ".$table." (".implode(', ', $keys).") VALUES ".implode(', ', $values);
}
// --------------------------------------------------------------------
/**
* Replace statement
*
* Generates a platform-specific replace string from the supplied data
*
* @access public
* @param string the table name
* @param array the insert keys
* @param array the insert values
* @return string
*/
function _replace($table, $keys, $values)
{
return "REPLACE INTO ".$table." (".implode(', ', $keys).") VALUES (".implode(', ', $values).")";
}
// --------------------------------------------------------------------
/**
* Update statement
*
* Generates a platform-specific update string from the supplied data
*
* @access public
* @param string the table name
* @param array the update data
* @param array the where clause
* @param array the orderby clause
* @param array the limit clause
* @return string
*/
function _update($table, $values, $where, $orderby = array(), $limit = FALSE)
{
foreach ($values as $key => $val)
{
$valstr[] = $key." = ".$val;
}
$limit = ( ! $limit) ? '' : ' LIMIT '.$limit;
$orderby = (count($orderby) >= 1)?' ORDER BY '.implode(", ", $orderby):'';
$sql = "UPDATE ".$table." SET ".implode(', ', $valstr);
$sql .= ($where != '' AND count($where) >=1) ? " WHERE ".implode(" ", $where) : '';
$sql .= $orderby.$limit;
return $sql;
}
// --------------------------------------------------------------------
/**
* Update_Batch statement
*
* Generates a platform-specific batch update string from the supplied data
*
* @access public
* @param string the table name
* @param array the update data
* @param array the where clause
* @return string
*/
function _update_batch($table, $values, $index, $where = NULL)
{
$ids = array();
$where = ($where != '' AND count($where) >=1) ? implode(" ", $where).' AND ' : '';
foreach ($values as $key => $val)
{
$ids[] = $val[$index];
foreach (array_keys($val) as $field)
{
if ($field != $index)
{
$final[$field][] = 'WHEN '.$index.' = '.$val[$index].' THEN '.$val[$field];
}
}
}
$sql = "UPDATE ".$table." SET ";
$cases = '';
foreach ($final as $k => $v)
{
$cases .= $k.' = CASE '."\n";
foreach ($v as $row)
{
$cases .= $row."\n";
}
$cases .= 'ELSE '.$k.' END, ';
}
$sql .= substr($cases, 0, -2);
$sql .= ' WHERE '.$where.$index.' IN ('.implode(',', $ids).')';
return $sql;
}
// --------------------------------------------------------------------
/**
* Truncate statement
*
* Generates a platform-specific truncate string from the supplied data
* If the database does not support the truncate() command
* This function maps to "DELETE FROM table"
*
* @access public
* @param string the table name
* @return string
*/
function _truncate($table)
{
return "TRUNCATE ".$table;
}
// --------------------------------------------------------------------
/**
* Delete statement
*
* Generates a platform-specific delete string from the supplied data
*
* @access public
* @param string the table name
* @param array the where clause
* @param string the limit clause
* @return string
*/
function _delete($table, $where = array(), $like = array(), $limit = FALSE)
{
$conditions = '';
if (count($where) > 0 OR count($like) > 0)
{
$conditions = "\nWHERE ";
$conditions .= implode("\n", $this->ar_where);
if (count($where) > 0 && count($like) > 0)
{
$conditions .= " AND ";
}
$conditions .= implode("\n", $like);
}
$limit = ( ! $limit) ? '' : ' LIMIT '.$limit;
return "DELETE FROM ".$table.$conditions.$limit;
}
// --------------------------------------------------------------------
/**
* Limit string
*
* Generates a platform-specific LIMIT clause
*
* @access public
* @param string the sql query string
* @param integer the number of rows to limit the query to
* @param integer the offset value
* @return string
*/
function _limit($sql, $limit, $offset)
{
$sql .= "LIMIT ".$limit;
if ($offset > 0)
{
$sql .= " OFFSET ".$offset;
}
return $sql;
}
// --------------------------------------------------------------------
/**
* Close DB Connection
*
* @access public
* @param resource
* @return void
*/
function _close($conn_id)
{
@mysqli_close($conn_id);
}
}
/* End of file mysqli_driver.php */
/* Location: ./system/database/drivers/mysqli/mysqli_driver.php */ | php | MIT | 152cd2d808675d2baeb9e77c229adfbaf9a16475 | 2026-01-05T05:21:15.334872Z | false |
MobilityLab/TransitScreen | https://github.com/MobilityLab/TransitScreen/blob/152cd2d808675d2baeb9e77c229adfbaf9a16475/system/database/drivers/mysqli/mysqli_utility.php | system/database/drivers/mysqli/mysqli_utility.php | <?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
/**
* CodeIgniter
*
* An open source application development framework for PHP 5.1.6 or newer
*
* @package CodeIgniter
* @author ExpressionEngine Dev Team
* @copyright Copyright (c) 2008 - 2011, EllisLab, Inc.
* @license http://codeigniter.com/user_guide/license.html
* @link http://codeigniter.com
* @since Version 1.0
* @filesource
*/
// ------------------------------------------------------------------------
/**
* MySQLi Utility Class
*
* @category Database
* @author ExpressionEngine Dev Team
* @link http://codeigniter.com/user_guide/database/
*/
class CI_DB_mysqli_utility extends CI_DB_utility {
/**
* List databases
*
* @access private
* @return bool
*/
function _list_databases()
{
return "SHOW DATABASES";
}
// --------------------------------------------------------------------
/**
* Optimize table query
*
* Generates a platform-specific query so that a table can be optimized
*
* @access private
* @param string the table name
* @return object
*/
function _optimize_table($table)
{
return "OPTIMIZE TABLE ".$this->db->_escape_identifiers($table);
}
// --------------------------------------------------------------------
/**
* Repair table query
*
* Generates a platform-specific query so that a table can be repaired
*
* @access private
* @param string the table name
* @return object
*/
function _repair_table($table)
{
return "REPAIR TABLE ".$this->db->_escape_identifiers($table);
}
// --------------------------------------------------------------------
/**
* MySQLi Export
*
* @access private
* @param array Preferences
* @return mixed
*/
function _backup($params = array())
{
// Currently unsupported
return $this->db->display_error('db_unsuported_feature');
}
}
/* End of file mysqli_utility.php */
/* Location: ./system/database/drivers/mysqli/mysqli_utility.php */ | php | MIT | 152cd2d808675d2baeb9e77c229adfbaf9a16475 | 2026-01-05T05:21:15.334872Z | false |
MobilityLab/TransitScreen | https://github.com/MobilityLab/TransitScreen/blob/152cd2d808675d2baeb9e77c229adfbaf9a16475/system/database/drivers/mysqli/mysqli_result.php | system/database/drivers/mysqli/mysqli_result.php | <?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
/**
* CodeIgniter
*
* An open source application development framework for PHP 5.1.6 or newer
*
* @package CodeIgniter
* @author ExpressionEngine Dev Team
* @copyright Copyright (c) 2008 - 2011, EllisLab, Inc.
* @license http://codeigniter.com/user_guide/license.html
* @link http://codeigniter.com
* @since Version 1.0
* @filesource
*/
// ------------------------------------------------------------------------
/**
* MySQLi Result Class
*
* This class extends the parent result class: CI_DB_result
*
* @category Database
* @author ExpressionEngine Dev Team
* @link http://codeigniter.com/user_guide/database/
*/
class CI_DB_mysqli_result extends CI_DB_result {
/**
* Number of rows in the result set
*
* @access public
* @return integer
*/
function num_rows()
{
return @mysqli_num_rows($this->result_id);
}
// --------------------------------------------------------------------
/**
* Number of fields in the result set
*
* @access public
* @return integer
*/
function num_fields()
{
return @mysqli_num_fields($this->result_id);
}
// --------------------------------------------------------------------
/**
* Fetch Field Names
*
* Generates an array of column names
*
* @access public
* @return array
*/
function list_fields()
{
$field_names = array();
while ($field = mysqli_fetch_field($this->result_id))
{
$field_names[] = $field->name;
}
return $field_names;
}
// --------------------------------------------------------------------
/**
* Field data
*
* Generates an array of objects containing field meta-data
*
* @access public
* @return array
*/
function field_data()
{
$retval = array();
while ($field = mysqli_fetch_object($this->result_id))
{
preg_match('/([a-zA-Z]+)(\(\d+\))?/', $field->Type, $matches);
$type = (array_key_exists(1, $matches)) ? $matches[1] : NULL;
$length = (array_key_exists(2, $matches)) ? preg_replace('/[^\d]/', '', $matches[2]) : NULL;
$F = new stdClass();
$F->name = $field->Field;
$F->type = $type;
$F->default = $field->Default;
$F->max_length = $length;
$F->primary_key = ( $field->Key == 'PRI' ? 1 : 0 );
$retval[] = $F;
}
return $retval;
}
// --------------------------------------------------------------------
/**
* Free the result
*
* @return null
*/
function free_result()
{
if (is_object($this->result_id))
{
mysqli_free_result($this->result_id);
$this->result_id = FALSE;
}
}
// --------------------------------------------------------------------
/**
* Data Seek
*
* Moves the internal pointer to the desired offset. We call
* this internally before fetching results to make sure the
* result set starts at zero
*
* @access private
* @return array
*/
function _data_seek($n = 0)
{
return mysqli_data_seek($this->result_id, $n);
}
// --------------------------------------------------------------------
/**
* Result - associative array
*
* Returns the result set as an array
*
* @access private
* @return array
*/
function _fetch_assoc()
{
return mysqli_fetch_assoc($this->result_id);
}
// --------------------------------------------------------------------
/**
* Result - object
*
* Returns the result set as an object
*
* @access private
* @return object
*/
function _fetch_object()
{
return mysqli_fetch_object($this->result_id);
}
}
/* End of file mysqli_result.php */
/* Location: ./system/database/drivers/mysqli/mysqli_result.php */ | php | MIT | 152cd2d808675d2baeb9e77c229adfbaf9a16475 | 2026-01-05T05:21:15.334872Z | false |
MobilityLab/TransitScreen | https://github.com/MobilityLab/TransitScreen/blob/152cd2d808675d2baeb9e77c229adfbaf9a16475/system/database/drivers/mysqli/mysqli_forge.php | system/database/drivers/mysqli/mysqli_forge.php | <?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
/**
* CodeIgniter
*
* An open source application development framework for PHP 5.1.6 or newer
*
* @package CodeIgniter
* @author ExpressionEngine Dev Team
* @copyright Copyright (c) 2008 - 2011, EllisLab, Inc.
* @license http://codeigniter.com/user_guide/license.html
* @link http://codeigniter.com
* @since Version 1.0
* @filesource
*/
// ------------------------------------------------------------------------
/**
* MySQLi Forge Class
*
* @category Database
* @author ExpressionEngine Dev Team
* @link http://codeigniter.com/user_guide/database/
*/
class CI_DB_mysqli_forge extends CI_DB_forge {
/**
* Create database
*
* @access private
* @param string the database name
* @return bool
*/
function _create_database($name)
{
return "CREATE DATABASE ".$name;
}
// --------------------------------------------------------------------
/**
* Drop database
*
* @access private
* @param string the database name
* @return bool
*/
function _drop_database($name)
{
return "DROP DATABASE ".$name;
}
// --------------------------------------------------------------------
/**
* Process Fields
*
* @access private
* @param mixed the fields
* @return string
*/
function _process_fields($fields)
{
$current_field_count = 0;
$sql = '';
foreach ($fields as $field=>$attributes)
{
// Numeric field names aren't allowed in databases, so if the key is
// numeric, we know it was assigned by PHP and the developer manually
// entered the field information, so we'll simply add it to the list
if (is_numeric($field))
{
$sql .= "\n\t$attributes";
}
else
{
$attributes = array_change_key_case($attributes, CASE_UPPER);
$sql .= "\n\t".$this->db->_protect_identifiers($field);
if (array_key_exists('NAME', $attributes))
{
$sql .= ' '.$this->db->_protect_identifiers($attributes['NAME']).' ';
}
if (array_key_exists('TYPE', $attributes))
{
$sql .= ' '.$attributes['TYPE'];
}
if (array_key_exists('CONSTRAINT', $attributes))
{
$sql .= '('.$attributes['CONSTRAINT'].')';
}
if (array_key_exists('UNSIGNED', $attributes) && $attributes['UNSIGNED'] === TRUE)
{
$sql .= ' UNSIGNED';
}
if (array_key_exists('DEFAULT', $attributes))
{
$sql .= ' DEFAULT \''.$attributes['DEFAULT'].'\'';
}
if (array_key_exists('NULL', $attributes) && $attributes['NULL'] === TRUE)
{
$sql .= ' NULL';
}
else
{
$sql .= ' NOT NULL';
}
if (array_key_exists('AUTO_INCREMENT', $attributes) && $attributes['AUTO_INCREMENT'] === TRUE)
{
$sql .= ' AUTO_INCREMENT';
}
}
// don't add a comma on the end of the last field
if (++$current_field_count < count($fields))
{
$sql .= ',';
}
}
return $sql;
}
// --------------------------------------------------------------------
/**
* Create Table
*
* @access private
* @param string the table name
* @param mixed the fields
* @param mixed primary key(s)
* @param mixed key(s)
* @param boolean should 'IF NOT EXISTS' be added to the SQL
* @return bool
*/
function _create_table($table, $fields, $primary_keys, $keys, $if_not_exists)
{
$sql = 'CREATE TABLE ';
if ($if_not_exists === TRUE)
{
$sql .= 'IF NOT EXISTS ';
}
$sql .= $this->db->_escape_identifiers($table)." (";
$sql .= $this->_process_fields($fields);
if (count($primary_keys) > 0)
{
$key_name = $this->db->_protect_identifiers(implode('_', $primary_keys));
$primary_keys = $this->db->_protect_identifiers($primary_keys);
$sql .= ",\n\tPRIMARY KEY ".$key_name." (" . implode(', ', $primary_keys) . ")";
}
if (is_array($keys) && count($keys) > 0)
{
foreach ($keys as $key)
{
if (is_array($key))
{
$key_name = $this->db->_protect_identifiers(implode('_', $key));
$key = $this->db->_protect_identifiers($key);
}
else
{
$key_name = $this->db->_protect_identifiers($key);
$key = array($key_name);
}
$sql .= ",\n\tKEY {$key_name} (" . implode(', ', $key) . ")";
}
}
$sql .= "\n) DEFAULT CHARACTER SET {$this->db->char_set} COLLATE {$this->db->dbcollat};";
return $sql;
}
// --------------------------------------------------------------------
/**
* Drop Table
*
* @access private
* @return string
*/
function _drop_table($table)
{
return "DROP TABLE IF EXISTS ".$this->db->_escape_identifiers($table);
}
// --------------------------------------------------------------------
/**
* Alter table query
*
* Generates a platform-specific query so that a table can be altered
* Called by add_column(), drop_column(), and column_alter(),
*
* @access private
* @param string the ALTER type (ADD, DROP, CHANGE)
* @param string the column name
* @param array fields
* @param string the field after which we should add the new field
* @return object
*/
function _alter_table($alter_type, $table, $fields, $after_field = '')
{
$sql = 'ALTER TABLE '.$this->db->_protect_identifiers($table)." $alter_type ";
// DROP has everything it needs now.
if ($alter_type == 'DROP')
{
return $sql.$this->db->_protect_identifiers($fields);
}
$sql .= $this->_process_fields($fields);
if ($after_field != '')
{
$sql .= ' AFTER ' . $this->db->_protect_identifiers($after_field);
}
return $sql;
}
// --------------------------------------------------------------------
/**
* Rename a table
*
* Generates a platform-specific query so that a table can be renamed
*
* @access private
* @param string the old table name
* @param string the new table name
* @return string
*/
function _rename_table($table_name, $new_table_name)
{
$sql = 'ALTER TABLE '.$this->db->_protect_identifiers($table_name)." RENAME TO ".$this->db->_protect_identifiers($new_table_name);
return $sql;
}
}
/* End of file mysqli_forge.php */
/* Location: ./system/database/drivers/mysqli/mysqli_forge.php */ | php | MIT | 152cd2d808675d2baeb9e77c229adfbaf9a16475 | 2026-01-05T05:21:15.334872Z | false |
MobilityLab/TransitScreen | https://github.com/MobilityLab/TransitScreen/blob/152cd2d808675d2baeb9e77c229adfbaf9a16475/system/database/drivers/sqlsrv/sqlsrv_result.php | system/database/drivers/sqlsrv/sqlsrv_result.php | <?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
/**
* CodeIgniter
*
* An open source application development framework for PHP 5.1.6 or newer
*
* @package CodeIgniter
* @author ExpressionEngine Dev Team
* @copyright Copyright (c) 2008 - 2011, EllisLab, Inc.
* @license http://codeigniter.com/user_guide/license.html
* @link http://codeigniter.com
* @since Version 1.0
* @filesource
*/
// ------------------------------------------------------------------------
/**
* SQLSRV Result Class
*
* This class extends the parent result class: CI_DB_result
*
* @category Database
* @author ExpressionEngine Dev Team
* @link http://codeigniter.com/user_guide/database/
*/
class CI_DB_sqlsrv_result extends CI_DB_result {
/**
* Number of rows in the result set
*
* @access public
* @return integer
*/
function num_rows()
{
return @sqlsrv_num_rows($this->result_id);
}
// --------------------------------------------------------------------
/**
* Number of fields in the result set
*
* @access public
* @return integer
*/
function num_fields()
{
return @sqlsrv_num_fields($this->result_id);
}
// --------------------------------------------------------------------
/**
* Fetch Field Names
*
* Generates an array of column names
*
* @access public
* @return array
*/
function list_fields()
{
$field_names = array();
foreach(sqlsrv_field_metadata($this->result_id) as $offset => $field)
{
$field_names[] = $field['Name'];
}
return $field_names;
}
// --------------------------------------------------------------------
/**
* Field data
*
* Generates an array of objects containing field meta-data
*
* @access public
* @return array
*/
function field_data()
{
$retval = array();
foreach(sqlsrv_field_metadata($this->result_id) as $offset => $field)
{
$F = new stdClass();
$F->name = $field['Name'];
$F->type = $field['Type'];
$F->max_length = $field['Size'];
$F->primary_key = 0;
$F->default = '';
$retval[] = $F;
}
return $retval;
}
// --------------------------------------------------------------------
/**
* Free the result
*
* @return null
*/
function free_result()
{
if (is_resource($this->result_id))
{
sqlsrv_free_stmt($this->result_id);
$this->result_id = FALSE;
}
}
// --------------------------------------------------------------------
/**
* Data Seek
*
* Moves the internal pointer to the desired offset. We call
* this internally before fetching results to make sure the
* result set starts at zero
*
* @access private
* @return array
*/
function _data_seek($n = 0)
{
// Not implemented
}
// --------------------------------------------------------------------
/**
* Result - associative array
*
* Returns the result set as an array
*
* @access private
* @return array
*/
function _fetch_assoc()
{
return sqlsrv_fetch_array($this->result_id, SQLSRV_FETCH_ASSOC);
}
// --------------------------------------------------------------------
/**
* Result - object
*
* Returns the result set as an object
*
* @access private
* @return object
*/
function _fetch_object()
{
return sqlsrv_fetch_object($this->result_id);
}
}
/* End of file mssql_result.php */
/* Location: ./system/database/drivers/mssql/mssql_result.php */ | php | MIT | 152cd2d808675d2baeb9e77c229adfbaf9a16475 | 2026-01-05T05:21:15.334872Z | false |
MobilityLab/TransitScreen | https://github.com/MobilityLab/TransitScreen/blob/152cd2d808675d2baeb9e77c229adfbaf9a16475/system/database/drivers/sqlsrv/sqlsrv_forge.php | system/database/drivers/sqlsrv/sqlsrv_forge.php | <?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
/**
* CodeIgniter
*
* An open source application development framework for PHP 5.1.6 or newer
*
* @package CodeIgniter
* @author ExpressionEngine Dev Team
* @copyright Copyright (c) 2008 - 2011, EllisLab, Inc.
* @license http://codeigniter.com/user_guide/license.html
* @link http://codeigniter.com
* @since Version 1.0
* @filesource
*/
// ------------------------------------------------------------------------
/**
* SQLSRV Forge Class
*
* @category Database
* @author ExpressionEngine Dev Team
* @link http://codeigniter.com/user_guide/database/
*/
class CI_DB_sqlsrv_forge extends CI_DB_forge {
/**
* Create database
*
* @access private
* @param string the database name
* @return bool
*/
function _create_database($name)
{
return "CREATE DATABASE ".$name;
}
// --------------------------------------------------------------------
/**
* Drop database
*
* @access private
* @param string the database name
* @return bool
*/
function _drop_database($name)
{
return "DROP DATABASE ".$name;
}
// --------------------------------------------------------------------
/**
* Drop Table
*
* @access private
* @return bool
*/
function _drop_table($table)
{
return "DROP TABLE ".$this->db->_escape_identifiers($table);
}
// --------------------------------------------------------------------
/**
* Create Table
*
* @access private
* @param string the table name
* @param array the fields
* @param mixed primary key(s)
* @param mixed key(s)
* @param boolean should 'IF NOT EXISTS' be added to the SQL
* @return bool
*/
function _create_table($table, $fields, $primary_keys, $keys, $if_not_exists)
{
$sql = 'CREATE TABLE ';
if ($if_not_exists === TRUE)
{
$sql .= 'IF NOT EXISTS ';
}
$sql .= $this->db->_escape_identifiers($table)." (";
$current_field_count = 0;
foreach ($fields as $field=>$attributes)
{
// Numeric field names aren't allowed in databases, so if the key is
// numeric, we know it was assigned by PHP and the developer manually
// entered the field information, so we'll simply add it to the list
if (is_numeric($field))
{
$sql .= "\n\t$attributes";
}
else
{
$attributes = array_change_key_case($attributes, CASE_UPPER);
$sql .= "\n\t".$this->db->_protect_identifiers($field);
$sql .= ' '.$attributes['TYPE'];
if (array_key_exists('CONSTRAINT', $attributes))
{
$sql .= '('.$attributes['CONSTRAINT'].')';
}
if (array_key_exists('UNSIGNED', $attributes) && $attributes['UNSIGNED'] === TRUE)
{
$sql .= ' UNSIGNED';
}
if (array_key_exists('DEFAULT', $attributes))
{
$sql .= ' DEFAULT \''.$attributes['DEFAULT'].'\'';
}
if (array_key_exists('NULL', $attributes) && $attributes['NULL'] === TRUE)
{
$sql .= ' NULL';
}
else
{
$sql .= ' NOT NULL';
}
if (array_key_exists('AUTO_INCREMENT', $attributes) && $attributes['AUTO_INCREMENT'] === TRUE)
{
$sql .= ' AUTO_INCREMENT';
}
}
// don't add a comma on the end of the last field
if (++$current_field_count < count($fields))
{
$sql .= ',';
}
}
if (count($primary_keys) > 0)
{
$primary_keys = $this->db->_protect_identifiers($primary_keys);
$sql .= ",\n\tPRIMARY KEY (" . implode(', ', $primary_keys) . ")";
}
if (is_array($keys) && count($keys) > 0)
{
foreach ($keys as $key)
{
if (is_array($key))
{
$key = $this->db->_protect_identifiers($key);
}
else
{
$key = array($this->db->_protect_identifiers($key));
}
$sql .= ",\n\tFOREIGN KEY (" . implode(', ', $key) . ")";
}
}
$sql .= "\n)";
return $sql;
}
// --------------------------------------------------------------------
/**
* Alter table query
*
* Generates a platform-specific query so that a table can be altered
* Called by add_column(), drop_column(), and column_alter(),
*
* @access private
* @param string the ALTER type (ADD, DROP, CHANGE)
* @param string the column name
* @param string the table name
* @param string the column definition
* @param string the default value
* @param boolean should 'NOT NULL' be added
* @param string the field after which we should add the new field
* @return object
*/
function _alter_table($alter_type, $table, $column_name, $column_definition = '', $default_value = '', $null = '', $after_field = '')
{
$sql = 'ALTER TABLE '.$this->db->_protect_identifiers($table)." $alter_type ".$this->db->_protect_identifiers($column_name);
// DROP has everything it needs now.
if ($alter_type == 'DROP')
{
return $sql;
}
$sql .= " $column_definition";
if ($default_value != '')
{
$sql .= " DEFAULT \"$default_value\"";
}
if ($null === NULL)
{
$sql .= ' NULL';
}
else
{
$sql .= ' NOT NULL';
}
if ($after_field != '')
{
$sql .= ' AFTER ' . $this->db->_protect_identifiers($after_field);
}
return $sql;
}
// --------------------------------------------------------------------
/**
* Rename a table
*
* Generates a platform-specific query so that a table can be renamed
*
* @access private
* @param string the old table name
* @param string the new table name
* @return string
*/
function _rename_table($table_name, $new_table_name)
{
// I think this syntax will work, but can find little documentation on renaming tables in MSSQL
$sql = 'ALTER TABLE '.$this->db->_protect_identifiers($table_name)." RENAME TO ".$this->db->_protect_identifiers($new_table_name);
return $sql;
}
}
/* End of file mssql_forge.php */
/* Location: ./system/database/drivers/mssql/mssql_forge.php */ | php | MIT | 152cd2d808675d2baeb9e77c229adfbaf9a16475 | 2026-01-05T05:21:15.334872Z | false |
MobilityLab/TransitScreen | https://github.com/MobilityLab/TransitScreen/blob/152cd2d808675d2baeb9e77c229adfbaf9a16475/system/database/drivers/sqlsrv/sqlsrv_utility.php | system/database/drivers/sqlsrv/sqlsrv_utility.php | <?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
/**
* CodeIgniter
*
* An open source application development framework for PHP 5.1.6 or newer
*
* @package CodeIgniter
* @author ExpressionEngine Dev Team
* @copyright Copyright (c) 2008 - 2011, EllisLab, Inc.
* @license http://codeigniter.com/user_guide/license.html
* @link http://codeigniter.com
* @since Version 1.0
* @filesource
*/
// ------------------------------------------------------------------------
/**
* SQLSRV Utility Class
*
* @category Database
* @author ExpressionEngine Dev Team
* @link http://codeigniter.com/user_guide/database/
*/
class CI_DB_sqlsrv_utility extends CI_DB_utility {
/**
* List databases
*
* @access private
* @return bool
*/
function _list_databases()
{
return "EXEC sp_helpdb"; // Can also be: EXEC sp_databases
}
// --------------------------------------------------------------------
/**
* Optimize table query
*
* Generates a platform-specific query so that a table can be optimized
*
* @access private
* @param string the table name
* @return object
*/
function _optimize_table($table)
{
return FALSE; // Is this supported in MS SQL?
}
// --------------------------------------------------------------------
/**
* Repair table query
*
* Generates a platform-specific query so that a table can be repaired
*
* @access private
* @param string the table name
* @return object
*/
function _repair_table($table)
{
return FALSE; // Is this supported in MS SQL?
}
// --------------------------------------------------------------------
/**
* MSSQL Export
*
* @access private
* @param array Preferences
* @return mixed
*/
function _backup($params = array())
{
// Currently unsupported
return $this->db->display_error('db_unsuported_feature');
}
}
/* End of file mssql_utility.php */
/* Location: ./system/database/drivers/mssql/mssql_utility.php */ | php | MIT | 152cd2d808675d2baeb9e77c229adfbaf9a16475 | 2026-01-05T05:21:15.334872Z | false |
MobilityLab/TransitScreen | https://github.com/MobilityLab/TransitScreen/blob/152cd2d808675d2baeb9e77c229adfbaf9a16475/system/database/drivers/sqlsrv/sqlsrv_driver.php | system/database/drivers/sqlsrv/sqlsrv_driver.php | <?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
/**
* CodeIgniter
*
* An open source application development framework for PHP 5.1.6 or newer
*
* @package CodeIgniter
* @author ExpressionEngine Dev Team
* @copyright Copyright (c) 2008 - 2011, EllisLab, Inc.
* @license http://codeigniter.com/user_guide/license.html
* @link http://codeigniter.com
* @since Version 1.0
* @filesource
*/
// ------------------------------------------------------------------------
/**
* SQLSRV Database Adapter Class
*
* Note: _DB is an extender class that the app controller
* creates dynamically based on whether the active record
* class is being used or not.
*
* @package CodeIgniter
* @subpackage Drivers
* @category Database
* @author ExpressionEngine Dev Team
* @link http://codeigniter.com/user_guide/database/
*/
class CI_DB_sqlsrv_driver extends CI_DB {
var $dbdriver = 'sqlsrv';
// The character used for escaping
var $_escape_char = '';
// clause and character used for LIKE escape sequences
var $_like_escape_str = " ESCAPE '%s' ";
var $_like_escape_chr = '!';
/**
* The syntax to count rows is slightly different across different
* database engines, so this string appears in each driver and is
* used for the count_all() and count_all_results() functions.
*/
var $_count_string = "SELECT COUNT(*) AS ";
var $_random_keyword = ' ASC'; // not currently supported
/**
* Non-persistent database connection
*
* @access private called by the base class
* @return resource
*/
function db_connect($pooling = false)
{
// Check for a UTF-8 charset being passed as CI's default 'utf8'.
$character_set = (0 === strcasecmp('utf8', $this->char_set)) ? 'UTF-8' : $this->char_set;
$connection = array(
'UID' => empty($this->username) ? '' : $this->username,
'PWD' => empty($this->password) ? '' : $this->password,
'Database' => $this->database,
'ConnectionPooling' => $pooling ? 1 : 0,
'CharacterSet' => $character_set,
'ReturnDatesAsStrings' => 1
);
// If the username and password are both empty, assume this is a
// 'Windows Authentication Mode' connection.
if(empty($connection['UID']) && empty($connection['PWD'])) {
unset($connection['UID'], $connection['PWD']);
}
return sqlsrv_connect($this->hostname, $connection);
}
// --------------------------------------------------------------------
/**
* Persistent database connection
*
* @access private called by the base class
* @return resource
*/
function db_pconnect()
{
$this->db_connect(TRUE);
}
// --------------------------------------------------------------------
/**
* Reconnect
*
* Keep / reestablish the db connection if no queries have been
* sent for a length of time exceeding the server's idle timeout
*
* @access public
* @return void
*/
function reconnect()
{
// not implemented in MSSQL
}
// --------------------------------------------------------------------
/**
* Select the database
*
* @access private called by the base class
* @return resource
*/
function db_select()
{
return $this->_execute('USE ' . $this->database);
}
// --------------------------------------------------------------------
/**
* Set client character set
*
* @access public
* @param string
* @param string
* @return resource
*/
function db_set_charset($charset, $collation)
{
// @todo - add support if needed
return TRUE;
}
// --------------------------------------------------------------------
/**
* Execute the query
*
* @access private called by the base class
* @param string an SQL query
* @return resource
*/
function _execute($sql)
{
$sql = $this->_prep_query($sql);
return sqlsrv_query($this->conn_id, $sql, null, array(
'Scrollable' => SQLSRV_CURSOR_STATIC,
'SendStreamParamsAtExec' => true
));
}
// --------------------------------------------------------------------
/**
* Prep the query
*
* If needed, each database adapter can prep the query string
*
* @access private called by execute()
* @param string an SQL query
* @return string
*/
function _prep_query($sql)
{
return $sql;
}
// --------------------------------------------------------------------
/**
* Begin Transaction
*
* @access public
* @return bool
*/
function trans_begin($test_mode = FALSE)
{
if ( ! $this->trans_enabled)
{
return TRUE;
}
// When transactions are nested we only begin/commit/rollback the outermost ones
if ($this->_trans_depth > 0)
{
return TRUE;
}
// Reset the transaction failure flag.
// If the $test_mode flag is set to TRUE transactions will be rolled back
// even if the queries produce a successful result.
$this->_trans_failure = ($test_mode === TRUE) ? TRUE : FALSE;
return sqlsrv_begin_transaction($this->conn_id);
}
// --------------------------------------------------------------------
/**
* Commit Transaction
*
* @access public
* @return bool
*/
function trans_commit()
{
if ( ! $this->trans_enabled)
{
return TRUE;
}
// When transactions are nested we only begin/commit/rollback the outermost ones
if ($this->_trans_depth > 0)
{
return TRUE;
}
return sqlsrv_commit($this->conn_id);
}
// --------------------------------------------------------------------
/**
* Rollback Transaction
*
* @access public
* @return bool
*/
function trans_rollback()
{
if ( ! $this->trans_enabled)
{
return TRUE;
}
// When transactions are nested we only begin/commit/rollback the outermost ones
if ($this->_trans_depth > 0)
{
return TRUE;
}
return sqlsrv_rollback($this->conn_id);
}
// --------------------------------------------------------------------
/**
* Escape String
*
* @access public
* @param string
* @param bool whether or not the string will be used in a LIKE condition
* @return string
*/
function escape_str($str, $like = FALSE)
{
// Escape single quotes
return str_replace("'", "''", $str);
}
// --------------------------------------------------------------------
/**
* Affected Rows
*
* @access public
* @return integer
*/
function affected_rows()
{
return @sqlrv_rows_affected($this->conn_id);
}
// --------------------------------------------------------------------
/**
* Insert ID
*
* Returns the last id created in the Identity column.
*
* @access public
* @return integer
*/
function insert_id()
{
return $this->query('select @@IDENTITY as insert_id')->row('insert_id');
}
// --------------------------------------------------------------------
/**
* Parse major version
*
* Grabs the major version number from the
* database server version string passed in.
*
* @access private
* @param string $version
* @return int16 major version number
*/
function _parse_major_version($version)
{
preg_match('/([0-9]+)\.([0-9]+)\.([0-9]+)/', $version, $ver_info);
return $ver_info[1]; // return the major version b/c that's all we're interested in.
}
// --------------------------------------------------------------------
/**
* Version number query string
*
* @access public
* @return string
*/
function _version()
{
$info = sqlsrv_server_info($this->conn_id);
return sprintf("select '%s' as ver", $info['SQLServerVersion']);
}
// --------------------------------------------------------------------
/**
* "Count All" query
*
* Generates a platform-specific query string that counts all records in
* the specified database
*
* @access public
* @param string
* @return string
*/
function count_all($table = '')
{
if ($table == '')
return '0';
$query = $this->query("SELECT COUNT(*) AS numrows FROM " . $this->dbprefix . $table);
if ($query->num_rows() == 0)
return '0';
$row = $query->row();
$this->_reset_select();
return $row->numrows;
}
// --------------------------------------------------------------------
/**
* List table query
*
* Generates a platform-specific query string so that the table names can be fetched
*
* @access private
* @param boolean
* @return string
*/
function _list_tables($prefix_limit = FALSE)
{
return "SELECT name FROM sysobjects WHERE type = 'U' ORDER BY name";
}
// --------------------------------------------------------------------
/**
* List column query
*
* Generates a platform-specific query string so that the column names can be fetched
*
* @access private
* @param string the table name
* @return string
*/
function _list_columns($table = '')
{
return "SELECT * FROM INFORMATION_SCHEMA.Columns WHERE TABLE_NAME = '".$this->_escape_table($table)."'";
}
// --------------------------------------------------------------------
/**
* Field data query
*
* Generates a platform-specific query so that the column data can be retrieved
*
* @access public
* @param string the table name
* @return object
*/
function _field_data($table)
{
return "SELECT TOP 1 * FROM " . $this->_escape_table($table);
}
// --------------------------------------------------------------------
/**
* The error message string
*
* @access private
* @return string
*/
function _error_message()
{
$error = array_shift(sqlsrv_errors());
return !empty($error['message']) ? $error['message'] : null;
}
// --------------------------------------------------------------------
/**
* The error message number
*
* @access private
* @return integer
*/
function _error_number()
{
$error = array_shift(sqlsrv_errors());
return isset($error['SQLSTATE']) ? $error['SQLSTATE'] : null;
}
// --------------------------------------------------------------------
/**
* Escape Table Name
*
* This function adds backticks if the table name has a period
* in it. Some DBs will get cranky unless periods are escaped
*
* @access private
* @param string the table name
* @return string
*/
function _escape_table($table)
{
return $table;
}
/**
* Escape the SQL Identifiers
*
* This function escapes column and table names
*
* @access private
* @param string
* @return string
*/
function _escape_identifiers($item)
{
return $item;
}
// --------------------------------------------------------------------
/**
* From Tables
*
* This function implicitly groups FROM tables so there is no confusion
* about operator precedence in harmony with SQL standards
*
* @access public
* @param type
* @return type
*/
function _from_tables($tables)
{
if ( ! is_array($tables))
{
$tables = array($tables);
}
return implode(', ', $tables);
}
// --------------------------------------------------------------------
/**
* Insert statement
*
* Generates a platform-specific insert string from the supplied data
*
* @access public
* @param string the table name
* @param array the insert keys
* @param array the insert values
* @return string
*/
function _insert($table, $keys, $values)
{
return "INSERT INTO ".$this->_escape_table($table)." (".implode(', ', $keys).") VALUES (".implode(', ', $values).")";
}
// --------------------------------------------------------------------
/**
* Update statement
*
* Generates a platform-specific update string from the supplied data
*
* @access public
* @param string the table name
* @param array the update data
* @param array the where clause
* @param array the orderby clause
* @param array the limit clause
* @return string
*/
function _update($table, $values, $where)
{
foreach($values as $key => $val)
{
$valstr[] = $key." = ".$val;
}
return "UPDATE ".$this->_escape_table($table)." SET ".implode(', ', $valstr)." WHERE ".implode(" ", $where);
}
// --------------------------------------------------------------------
/**
* Truncate statement
*
* Generates a platform-specific truncate string from the supplied data
* If the database does not support the truncate() command
* This function maps to "DELETE FROM table"
*
* @access public
* @param string the table name
* @return string
*/
function _truncate($table)
{
return "TRUNCATE ".$table;
}
// --------------------------------------------------------------------
/**
* Delete statement
*
* Generates a platform-specific delete string from the supplied data
*
* @access public
* @param string the table name
* @param array the where clause
* @param string the limit clause
* @return string
*/
function _delete($table, $where)
{
return "DELETE FROM ".$this->_escape_table($table)." WHERE ".implode(" ", $where);
}
// --------------------------------------------------------------------
/**
* Limit string
*
* Generates a platform-specific LIMIT clause
*
* @access public
* @param string the sql query string
* @param integer the number of rows to limit the query to
* @param integer the offset value
* @return string
*/
function _limit($sql, $limit, $offset)
{
$i = $limit + $offset;
return preg_replace('/(^\SELECT (DISTINCT)?)/i','\\1 TOP '.$i.' ', $sql);
}
// --------------------------------------------------------------------
/**
* Close DB Connection
*
* @access public
* @param resource
* @return void
*/
function _close($conn_id)
{
@sqlsrv_close($conn_id);
}
}
/* End of file mssql_driver.php */
/* Location: ./system/database/drivers/mssql/mssql_driver.php */ | php | MIT | 152cd2d808675d2baeb9e77c229adfbaf9a16475 | 2026-01-05T05:21:15.334872Z | false |
MobilityLab/TransitScreen | https://github.com/MobilityLab/TransitScreen/blob/152cd2d808675d2baeb9e77c229adfbaf9a16475/system/database/drivers/cubrid/cubrid_forge.php | system/database/drivers/cubrid/cubrid_forge.php | <?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
/**
* CodeIgniter
*
* An open source application development framework for PHP 5.1.6 or newer
*
* @package CodeIgniter
* @author Esen Sagynov
* @copyright Copyright (c) 2008 - 2011, EllisLab, Inc.
* @license http://codeigniter.com/user_guide/license.html
* @link http://codeigniter.com
* @since Version 1.0
* @filesource
*/
// ------------------------------------------------------------------------
/**
* CUBRID Forge Class
*
* @category Database
* @author Esen Sagynov
* @link http://codeigniter.com/user_guide/database/
*/
class CI_DB_cubrid_forge extends CI_DB_forge {
/**
* Create database
*
* @access private
* @param string the database name
* @return bool
*/
function _create_database($name)
{
// CUBRID does not allow to create a database in SQL. The GUI tools
// have to be used for this purpose.
return FALSE;
}
// --------------------------------------------------------------------
/**
* Drop database
*
* @access private
* @param string the database name
* @return bool
*/
function _drop_database($name)
{
// CUBRID does not allow to drop a database in SQL. The GUI tools
// have to be used for this purpose.
return FALSE;
}
// --------------------------------------------------------------------
/**
* Process Fields
*
* @access private
* @param mixed the fields
* @return string
*/
function _process_fields($fields)
{
$current_field_count = 0;
$sql = '';
foreach ($fields as $field=>$attributes)
{
// Numeric field names aren't allowed in databases, so if the key is
// numeric, we know it was assigned by PHP and the developer manually
// entered the field information, so we'll simply add it to the list
if (is_numeric($field))
{
$sql .= "\n\t$attributes";
}
else
{
$attributes = array_change_key_case($attributes, CASE_UPPER);
$sql .= "\n\t\"" . $this->db->_protect_identifiers($field) . "\"";
if (array_key_exists('NAME', $attributes))
{
$sql .= ' '.$this->db->_protect_identifiers($attributes['NAME']).' ';
}
if (array_key_exists('TYPE', $attributes))
{
$sql .= ' '.$attributes['TYPE'];
if (array_key_exists('CONSTRAINT', $attributes))
{
switch ($attributes['TYPE'])
{
case 'decimal':
case 'float':
case 'numeric':
$sql .= '('.implode(',', $attributes['CONSTRAINT']).')';
break;
case 'enum': // As of version 8.4.0 CUBRID does not support
// enum data type.
break;
case 'set':
$sql .= '("'.implode('","', $attributes['CONSTRAINT']).'")';
break;
default:
$sql .= '('.$attributes['CONSTRAINT'].')';
}
}
}
if (array_key_exists('UNSIGNED', $attributes) && $attributes['UNSIGNED'] === TRUE)
{
//$sql .= ' UNSIGNED';
// As of version 8.4.0 CUBRID does not support UNSIGNED INTEGER data type.
// Will be supported in the next release as a part of MySQL Compatibility.
}
if (array_key_exists('DEFAULT', $attributes))
{
$sql .= ' DEFAULT \''.$attributes['DEFAULT'].'\'';
}
if (array_key_exists('NULL', $attributes) && $attributes['NULL'] === TRUE)
{
$sql .= ' NULL';
}
else
{
$sql .= ' NOT NULL';
}
if (array_key_exists('AUTO_INCREMENT', $attributes) && $attributes['AUTO_INCREMENT'] === TRUE)
{
$sql .= ' AUTO_INCREMENT';
}
if (array_key_exists('UNIQUE', $attributes) && $attributes['UNIQUE'] === TRUE)
{
$sql .= ' UNIQUE';
}
}
// don't add a comma on the end of the last field
if (++$current_field_count < count($fields))
{
$sql .= ',';
}
}
return $sql;
}
// --------------------------------------------------------------------
/**
* Create Table
*
* @access private
* @param string the table name
* @param mixed the fields
* @param mixed primary key(s)
* @param mixed key(s)
* @param boolean should 'IF NOT EXISTS' be added to the SQL
* @return bool
*/
function _create_table($table, $fields, $primary_keys, $keys, $if_not_exists)
{
$sql = 'CREATE TABLE ';
if ($if_not_exists === TRUE)
{
//$sql .= 'IF NOT EXISTS ';
// As of version 8.4.0 CUBRID does not support this SQL syntax.
}
$sql .= $this->db->_escape_identifiers($table)." (";
$sql .= $this->_process_fields($fields);
// If there is a PK defined
if (count($primary_keys) > 0)
{
$key_name = "pk_" . $table . "_" .
$this->db->_protect_identifiers(implode('_', $primary_keys));
$primary_keys = $this->db->_protect_identifiers($primary_keys);
$sql .= ",\n\tCONSTRAINT " . $key_name . " PRIMARY KEY(" . implode(', ', $primary_keys) . ")";
}
if (is_array($keys) && count($keys) > 0)
{
foreach ($keys as $key)
{
if (is_array($key))
{
$key_name = $this->db->_protect_identifiers(implode('_', $key));
$key = $this->db->_protect_identifiers($key);
}
else
{
$key_name = $this->db->_protect_identifiers($key);
$key = array($key_name);
}
$sql .= ",\n\tKEY \"{$key_name}\" (" . implode(', ', $key) . ")";
}
}
$sql .= "\n);";
return $sql;
}
// --------------------------------------------------------------------
/**
* Drop Table
*
* @access private
* @return string
*/
function _drop_table($table)
{
return "DROP TABLE IF EXISTS ".$this->db->_escape_identifiers($table);
}
// --------------------------------------------------------------------
/**
* Alter table query
*
* Generates a platform-specific query so that a table can be altered
* Called by add_column(), drop_column(), and column_alter(),
*
* @access private
* @param string the ALTER type (ADD, DROP, CHANGE)
* @param string the column name
* @param array fields
* @param string the field after which we should add the new field
* @return object
*/
function _alter_table($alter_type, $table, $fields, $after_field = '')
{
$sql = 'ALTER TABLE '.$this->db->_protect_identifiers($table)." $alter_type ";
// DROP has everything it needs now.
if ($alter_type == 'DROP')
{
return $sql.$this->db->_protect_identifiers($fields);
}
$sql .= $this->_process_fields($fields);
if ($after_field != '')
{
$sql .= ' AFTER ' . $this->db->_protect_identifiers($after_field);
}
return $sql;
}
// --------------------------------------------------------------------
/**
* Rename a table
*
* Generates a platform-specific query so that a table can be renamed
*
* @access private
* @param string the old table name
* @param string the new table name
* @return string
*/
function _rename_table($table_name, $new_table_name)
{
$sql = 'RENAME TABLE '.$this->db->_protect_identifiers($table_name)." AS ".$this->db->_protect_identifiers($new_table_name);
return $sql;
}
}
/* End of file cubrid_forge.php */
/* Location: ./system/database/drivers/cubrid/cubrid_forge.php */ | php | MIT | 152cd2d808675d2baeb9e77c229adfbaf9a16475 | 2026-01-05T05:21:15.334872Z | false |
MobilityLab/TransitScreen | https://github.com/MobilityLab/TransitScreen/blob/152cd2d808675d2baeb9e77c229adfbaf9a16475/system/database/drivers/cubrid/cubrid_result.php | system/database/drivers/cubrid/cubrid_result.php | <?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
/**
* CodeIgniter
*
* An open source application development framework for PHP 5.1.6 or newer
*
* @package CodeIgniter
* @author Esen Sagynov
* @copyright Copyright (c) 2008 - 2011, EllisLab, Inc.
* @license http://codeigniter.com/user_guide/license.html
* @link http://codeigniter.com
* @since Version 2.0.2
* @filesource
*/
// --------------------------------------------------------------------
/**
* CUBRID Result Class
*
* This class extends the parent result class: CI_DB_result
*
* @category Database
* @author Esen Sagynov
* @link http://codeigniter.com/user_guide/database/
*/
class CI_DB_cubrid_result extends CI_DB_result {
/**
* Number of rows in the result set
*
* @access public
* @return integer
*/
function num_rows()
{
return @cubrid_num_rows($this->result_id);
}
// --------------------------------------------------------------------
/**
* Number of fields in the result set
*
* @access public
* @return integer
*/
function num_fields()
{
return @cubrid_num_fields($this->result_id);
}
// --------------------------------------------------------------------
/**
* Fetch Field Names
*
* Generates an array of column names
*
* @access public
* @return array
*/
function list_fields()
{
return cubrid_column_names($this->result_id);
}
// --------------------------------------------------------------------
/**
* Field data
*
* Generates an array of objects containing field meta-data
*
* @access public
* @return array
*/
function field_data()
{
$retval = array();
$tablePrimaryKeys = array();
while ($field = cubrid_fetch_field($this->result_id))
{
$F = new stdClass();
$F->name = $field->name;
$F->type = $field->type;
$F->default = $field->def;
$F->max_length = $field->max_length;
// At this moment primary_key property is not returned when
// cubrid_fetch_field is called. The following code will
// provide a patch for it. primary_key property will be added
// in the next release.
// TODO: later version of CUBRID will provide primary_key
// property.
// When PK is defined in CUBRID, an index is automatically
// created in the db_index system table in the form of
// pk_tblname_fieldname. So the following will count how many
// columns are there which satisfy this format.
// The query will search for exact single columns, thus
// compound PK is not supported.
$res = cubrid_query($this->conn_id,
"SELECT COUNT(*) FROM db_index WHERE class_name = '" . $field->table .
"' AND is_primary_key = 'YES' AND index_name = 'pk_" .
$field->table . "_" . $field->name . "'"
);
if ($res)
{
$row = cubrid_fetch_array($res, CUBRID_NUM);
$F->primary_key = ($row[0] > 0 ? 1 : null);
}
else
{
$F->primary_key = null;
}
if (is_resource($res))
{
cubrid_close_request($res);
$this->result_id = FALSE;
}
$retval[] = $F;
}
return $retval;
}
// --------------------------------------------------------------------
/**
* Free the result
*
* @return null
*/
function free_result()
{
if(is_resource($this->result_id) ||
get_resource_type($this->result_id) == "Unknown" &&
preg_match('/Resource id #/', strval($this->result_id)))
{
cubrid_close_request($this->result_id);
$this->result_id = FALSE;
}
}
// --------------------------------------------------------------------
/**
* Data Seek
*
* Moves the internal pointer to the desired offset. We call
* this internally before fetching results to make sure the
* result set starts at zero
*
* @access private
* @return array
*/
function _data_seek($n = 0)
{
return cubrid_data_seek($this->result_id, $n);
}
// --------------------------------------------------------------------
/**
* Result - associative array
*
* Returns the result set as an array
*
* @access private
* @return array
*/
function _fetch_assoc()
{
return cubrid_fetch_assoc($this->result_id);
}
// --------------------------------------------------------------------
/**
* Result - object
*
* Returns the result set as an object
*
* @access private
* @return object
*/
function _fetch_object()
{
return cubrid_fetch_object($this->result_id);
}
}
/* End of file cubrid_result.php */
/* Location: ./system/database/drivers/cubrid/cubrid_result.php */ | php | MIT | 152cd2d808675d2baeb9e77c229adfbaf9a16475 | 2026-01-05T05:21:15.334872Z | false |
MobilityLab/TransitScreen | https://github.com/MobilityLab/TransitScreen/blob/152cd2d808675d2baeb9e77c229adfbaf9a16475/system/database/drivers/cubrid/cubrid_utility.php | system/database/drivers/cubrid/cubrid_utility.php | <?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
/**
* CodeIgniter
*
* An open source application development framework for PHP 5.1.6 or newer
*
* @package CodeIgniter
* @author Esen Sagynov
* @copyright Copyright (c) 2008 - 2011, EllisLab, Inc.
* @license http://codeigniter.com/user_guide/license.html
* @link http://codeigniter.com
* @since Version 1.0
* @filesource
*/
// ------------------------------------------------------------------------
/**
* CUBRID Utility Class
*
* @category Database
* @author Esen Sagynov
* @link http://codeigniter.com/user_guide/database/
*/
class CI_DB_cubrid_utility extends CI_DB_utility {
/**
* List databases
*
* @access private
* @return array
*/
function _list_databases()
{
// CUBRID does not allow to see the list of all databases on the
// server. It is the way its architecture is designed. Every
// database is independent and isolated.
// For this reason we can return only the name of the currect
// connected database.
if ($this->conn_id)
{
return "SELECT '" . $this->database . "'";
}
else
{
return FALSE;
}
}
// --------------------------------------------------------------------
/**
* Optimize table query
*
* Generates a platform-specific query so that a table can be optimized
*
* @access private
* @param string the table name
* @return object
* @link http://www.cubrid.org/manual/840/en/Optimize%20Database
*/
function _optimize_table($table)
{
// No SQL based support in CUBRID as of version 8.4.0. Database or
// table optimization can be performed using CUBRID Manager
// database administration tool. See the link above for more info.
return FALSE;
}
// --------------------------------------------------------------------
/**
* Repair table query
*
* Generates a platform-specific query so that a table can be repaired
*
* @access private
* @param string the table name
* @return object
* @link http://www.cubrid.org/manual/840/en/Checking%20Database%20Consistency
*/
function _repair_table($table)
{
// Not supported in CUBRID as of version 8.4.0. Database or
// table consistency can be checked using CUBRID Manager
// database administration tool. See the link above for more info.
return FALSE;
}
// --------------------------------------------------------------------
/**
* CUBRID Export
*
* @access private
* @param array Preferences
* @return mixed
*/
function _backup($params = array())
{
// No SQL based support in CUBRID as of version 8.4.0. Database or
// table backup can be performed using CUBRID Manager
// database administration tool.
return $this->db->display_error('db_unsuported_feature');
}
}
/* End of file cubrid_utility.php */
/* Location: ./system/database/drivers/cubrid/cubrid_utility.php */ | php | MIT | 152cd2d808675d2baeb9e77c229adfbaf9a16475 | 2026-01-05T05:21:15.334872Z | false |
MobilityLab/TransitScreen | https://github.com/MobilityLab/TransitScreen/blob/152cd2d808675d2baeb9e77c229adfbaf9a16475/system/database/drivers/cubrid/cubrid_driver.php | system/database/drivers/cubrid/cubrid_driver.php | <?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
/**
* CodeIgniter
*
* An open source application development framework for PHP 5.1.6 or newer
*
* @package CodeIgniter
* @author Esen Sagynov
* @copyright Copyright (c) 2008 - 2011, EllisLab, Inc.
* @license http://codeigniter.com/user_guide/license.html
* @link http://codeigniter.com
* @since Version 2.0.2
* @filesource
*/
// ------------------------------------------------------------------------
/**
* CUBRID Database Adapter Class
*
* Note: _DB is an extender class that the app controller
* creates dynamically based on whether the active record
* class is being used or not.
*
* @package CodeIgniter
* @subpackage Drivers
* @category Database
* @author Esen Sagynov
* @link http://codeigniter.com/user_guide/database/
*/
class CI_DB_cubrid_driver extends CI_DB {
// Default CUBRID Broker port. Will be used unless user
// explicitly specifies another one.
const DEFAULT_PORT = 33000;
var $dbdriver = 'cubrid';
// The character used for escaping - no need in CUBRID
var $_escape_char = '';
// clause and character used for LIKE escape sequences - not used in CUBRID
var $_like_escape_str = '';
var $_like_escape_chr = '';
/**
* The syntax to count rows is slightly different across different
* database engines, so this string appears in each driver and is
* used for the count_all() and count_all_results() functions.
*/
var $_count_string = 'SELECT COUNT(*) AS ';
var $_random_keyword = ' RAND()'; // database specific random keyword
/**
* Non-persistent database connection
*
* @access private called by the base class
* @return resource
*/
function db_connect()
{
// If no port is defined by the user, use the default value
if ($this->port == '')
{
$this->port = self::DEFAULT_PORT;
}
$conn = cubrid_connect($this->hostname, $this->port, $this->database, $this->username, $this->password);
if ($conn)
{
// Check if a user wants to run queries in dry, i.e. run the
// queries but not commit them.
if (isset($this->auto_commit) && ! $this->auto_commit)
{
cubrid_set_autocommit($conn, CUBRID_AUTOCOMMIT_FALSE);
}
else
{
cubrid_set_autocommit($conn, CUBRID_AUTOCOMMIT_TRUE);
$this->auto_commit = TRUE;
}
}
return $conn;
}
// --------------------------------------------------------------------
/**
* Persistent database connection
* In CUBRID persistent DB connection is supported natively in CUBRID
* engine which can be configured in the CUBRID Broker configuration
* file by setting the CCI_PCONNECT parameter to ON. In that case, all
* connections established between the client application and the
* server will become persistent. This is calling the same
* @cubrid_connect function will establish persisten connection
* considering that the CCI_PCONNECT is ON.
*
* @access private called by the base class
* @return resource
*/
function db_pconnect()
{
return $this->db_connect();
}
// --------------------------------------------------------------------
/**
* Reconnect
*
* Keep / reestablish the db connection if no queries have been
* sent for a length of time exceeding the server's idle timeout
*
* @access public
* @return void
*/
function reconnect()
{
if (cubrid_ping($this->conn_id) === FALSE)
{
$this->conn_id = FALSE;
}
}
// --------------------------------------------------------------------
/**
* Select the database
*
* @access private called by the base class
* @return resource
*/
function db_select()
{
// In CUBRID there is no need to select a database as the database
// is chosen at the connection time.
// So, to determine if the database is "selected", all we have to
// do is ping the server and return that value.
return cubrid_ping($this->conn_id);
}
// --------------------------------------------------------------------
/**
* Set client character set
*
* @access public
* @param string
* @param string
* @return resource
*/
function db_set_charset($charset, $collation)
{
// In CUBRID, there is no need to set charset or collation.
// This is why returning true will allow the application continue
// its normal process.
return TRUE;
}
// --------------------------------------------------------------------
/**
* Version number query string
*
* @access public
* @return string
*/
function _version()
{
// To obtain the CUBRID Server version, no need to run the SQL query.
// CUBRID PHP API provides a function to determin this value.
// This is why we also need to add 'cubrid' value to the list of
// $driver_version_exceptions array in DB_driver class in
// version() function.
return cubrid_get_server_info($this->conn_id);
}
// --------------------------------------------------------------------
/**
* Execute the query
*
* @access private called by the base class
* @param string an SQL query
* @return resource
*/
function _execute($sql)
{
$sql = $this->_prep_query($sql);
return @cubrid_query($sql, $this->conn_id);
}
// --------------------------------------------------------------------
/**
* Prep the query
*
* If needed, each database adapter can prep the query string
*
* @access private called by execute()
* @param string an SQL query
* @return string
*/
function _prep_query($sql)
{
// No need to prepare
return $sql;
}
// --------------------------------------------------------------------
/**
* Begin Transaction
*
* @access public
* @return bool
*/
function trans_begin($test_mode = FALSE)
{
if ( ! $this->trans_enabled)
{
return TRUE;
}
// When transactions are nested we only begin/commit/rollback the outermost ones
if ($this->_trans_depth > 0)
{
return TRUE;
}
// Reset the transaction failure flag.
// If the $test_mode flag is set to TRUE transactions will be rolled back
// even if the queries produce a successful result.
$this->_trans_failure = ($test_mode === TRUE) ? TRUE : FALSE;
if (cubrid_get_autocommit($this->conn_id))
{
cubrid_set_autocommit($this->conn_id, CUBRID_AUTOCOMMIT_FALSE);
}
return TRUE;
}
// --------------------------------------------------------------------
/**
* Commit Transaction
*
* @access public
* @return bool
*/
function trans_commit()
{
if ( ! $this->trans_enabled)
{
return TRUE;
}
// When transactions are nested we only begin/commit/rollback the outermost ones
if ($this->_trans_depth > 0)
{
return TRUE;
}
cubrid_commit($this->conn_id);
if ($this->auto_commit && ! cubrid_get_autocommit($this->conn_id))
{
cubrid_set_autocommit($this->conn_id, CUBRID_AUTOCOMMIT_TRUE);
}
return TRUE;
}
// --------------------------------------------------------------------
/**
* Rollback Transaction
*
* @access public
* @return bool
*/
function trans_rollback()
{
if ( ! $this->trans_enabled)
{
return TRUE;
}
// When transactions are nested we only begin/commit/rollback the outermost ones
if ($this->_trans_depth > 0)
{
return TRUE;
}
cubrid_rollback($this->conn_id);
if ($this->auto_commit && ! cubrid_get_autocommit($this->conn_id))
{
cubrid_set_autocommit($this->conn_id, CUBRID_AUTOCOMMIT_TRUE);
}
return TRUE;
}
// --------------------------------------------------------------------
/**
* Escape String
*
* @access public
* @param string
* @param bool whether or not the string will be used in a LIKE condition
* @return string
*/
function escape_str($str, $like = FALSE)
{
if (is_array($str))
{
foreach ($str as $key => $val)
{
$str[$key] = $this->escape_str($val, $like);
}
return $str;
}
if (function_exists('cubrid_real_escape_string') AND is_resource($this->conn_id))
{
$str = cubrid_real_escape_string($str, $this->conn_id);
}
else
{
$str = addslashes($str);
}
// escape LIKE condition wildcards
if ($like === TRUE)
{
$str = str_replace(array('%', '_'), array('\\%', '\\_'), $str);
}
return $str;
}
// --------------------------------------------------------------------
/**
* Affected Rows
*
* @access public
* @return integer
*/
function affected_rows()
{
return @cubrid_affected_rows($this->conn_id);
}
// --------------------------------------------------------------------
/**
* Insert ID
*
* @access public
* @return integer
*/
function insert_id()
{
return @cubrid_insert_id($this->conn_id);
}
// --------------------------------------------------------------------
/**
* "Count All" query
*
* Generates a platform-specific query string that counts all records in
* the specified table
*
* @access public
* @param string
* @return string
*/
function count_all($table = '')
{
if ($table == '')
{
return 0;
}
$query = $this->query($this->_count_string . $this->_protect_identifiers('numrows') . " FROM " . $this->_protect_identifiers($table, TRUE, NULL, FALSE));
if ($query->num_rows() == 0)
{
return 0;
}
$row = $query->row();
$this->_reset_select();
return (int) $row->numrows;
}
// --------------------------------------------------------------------
/**
* List table query
*
* Generates a platform-specific query string so that the table names can be fetched
*
* @access private
* @param boolean
* @return string
*/
function _list_tables($prefix_limit = FALSE)
{
$sql = "SHOW TABLES";
if ($prefix_limit !== FALSE AND $this->dbprefix != '')
{
$sql .= " LIKE '".$this->escape_like_str($this->dbprefix)."%'";
}
return $sql;
}
// --------------------------------------------------------------------
/**
* Show column query
*
* Generates a platform-specific query string so that the column names can be fetched
*
* @access public
* @param string the table name
* @return string
*/
function _list_columns($table = '')
{
return "SHOW COLUMNS FROM ".$this->_protect_identifiers($table, TRUE, NULL, FALSE);
}
// --------------------------------------------------------------------
/**
* Field data query
*
* Generates a platform-specific query so that the column data can be retrieved
*
* @access public
* @param string the table name
* @return object
*/
function _field_data($table)
{
return "SELECT * FROM ".$table." LIMIT 1";
}
// --------------------------------------------------------------------
/**
* The error message string
*
* @access private
* @return string
*/
function _error_message()
{
return cubrid_error($this->conn_id);
}
// --------------------------------------------------------------------
/**
* The error message number
*
* @access private
* @return integer
*/
function _error_number()
{
return cubrid_errno($this->conn_id);
}
// --------------------------------------------------------------------
/**
* Escape the SQL Identifiers
*
* This function escapes column and table names
*
* @access private
* @param string
* @return string
*/
function _escape_identifiers($item)
{
if ($this->_escape_char == '')
{
return $item;
}
foreach ($this->_reserved_identifiers as $id)
{
if (strpos($item, '.'.$id) !== FALSE)
{
$str = $this->_escape_char. str_replace('.', $this->_escape_char.'.', $item);
// remove duplicates if the user already included the escape
return preg_replace('/['.$this->_escape_char.']+/', $this->_escape_char, $str);
}
}
if (strpos($item, '.') !== FALSE)
{
$str = $this->_escape_char.str_replace('.', $this->_escape_char.'.'.$this->_escape_char, $item).$this->_escape_char;
}
else
{
$str = $this->_escape_char.$item.$this->_escape_char;
}
// remove duplicates if the user already included the escape
return preg_replace('/['.$this->_escape_char.']+/', $this->_escape_char, $str);
}
// --------------------------------------------------------------------
/**
* From Tables
*
* This function implicitly groups FROM tables so there is no confusion
* about operator precedence in harmony with SQL standards
*
* @access public
* @param type
* @return type
*/
function _from_tables($tables)
{
if ( ! is_array($tables))
{
$tables = array($tables);
}
return '('.implode(', ', $tables).')';
}
// --------------------------------------------------------------------
/**
* Insert statement
*
* Generates a platform-specific insert string from the supplied data
*
* @access public
* @param string the table name
* @param array the insert keys
* @param array the insert values
* @return string
*/
function _insert($table, $keys, $values)
{
return "INSERT INTO ".$table." (\"".implode('", "', $keys)."\") VALUES (".implode(', ', $values).")";
}
// --------------------------------------------------------------------
/**
* Replace statement
*
* Generates a platform-specific replace string from the supplied data
*
* @access public
* @param string the table name
* @param array the insert keys
* @param array the insert values
* @return string
*/
function _replace($table, $keys, $values)
{
return "REPLACE INTO ".$table." (\"".implode('", "', $keys)."\") VALUES (".implode(', ', $values).")";
}
// --------------------------------------------------------------------
/**
* Insert_batch statement
*
* Generates a platform-specific insert string from the supplied data
*
* @access public
* @param string the table name
* @param array the insert keys
* @param array the insert values
* @return string
*/
function _insert_batch($table, $keys, $values)
{
return "INSERT INTO ".$table." (\"".implode('", "', $keys)."\") VALUES ".implode(', ', $values);
}
// --------------------------------------------------------------------
/**
* Update statement
*
* Generates a platform-specific update string from the supplied data
*
* @access public
* @param string the table name
* @param array the update data
* @param array the where clause
* @param array the orderby clause
* @param array the limit clause
* @return string
*/
function _update($table, $values, $where, $orderby = array(), $limit = FALSE)
{
foreach ($values as $key => $val)
{
$valstr[] = sprintf('"%s" = %s', $key, $val);
}
$limit = ( ! $limit) ? '' : ' LIMIT '.$limit;
$orderby = (count($orderby) >= 1)?' ORDER BY '.implode(", ", $orderby):'';
$sql = "UPDATE ".$table." SET ".implode(', ', $valstr);
$sql .= ($where != '' AND count($where) >=1) ? " WHERE ".implode(" ", $where) : '';
$sql .= $orderby.$limit;
return $sql;
}
// --------------------------------------------------------------------
/**
* Update_Batch statement
*
* Generates a platform-specific batch update string from the supplied data
*
* @access public
* @param string the table name
* @param array the update data
* @param array the where clause
* @return string
*/
function _update_batch($table, $values, $index, $where = NULL)
{
$ids = array();
$where = ($where != '' AND count($where) >=1) ? implode(" ", $where).' AND ' : '';
foreach ($values as $key => $val)
{
$ids[] = $val[$index];
foreach (array_keys($val) as $field)
{
if ($field != $index)
{
$final[$field][] = 'WHEN '.$index.' = '.$val[$index].' THEN '.$val[$field];
}
}
}
$sql = "UPDATE ".$table." SET ";
$cases = '';
foreach ($final as $k => $v)
{
$cases .= $k.' = CASE '."\n";
foreach ($v as $row)
{
$cases .= $row."\n";
}
$cases .= 'ELSE '.$k.' END, ';
}
$sql .= substr($cases, 0, -2);
$sql .= ' WHERE '.$where.$index.' IN ('.implode(',', $ids).')';
return $sql;
}
// --------------------------------------------------------------------
/**
* Truncate statement
*
* Generates a platform-specific truncate string from the supplied data
* If the database does not support the truncate() command
* This function maps to "DELETE FROM table"
*
* @access public
* @param string the table name
* @return string
*/
function _truncate($table)
{
return "TRUNCATE ".$table;
}
// --------------------------------------------------------------------
/**
* Delete statement
*
* Generates a platform-specific delete string from the supplied data
*
* @access public
* @param string the table name
* @param array the where clause
* @param string the limit clause
* @return string
*/
function _delete($table, $where = array(), $like = array(), $limit = FALSE)
{
$conditions = '';
if (count($where) > 0 OR count($like) > 0)
{
$conditions = "\nWHERE ";
$conditions .= implode("\n", $this->ar_where);
if (count($where) > 0 && count($like) > 0)
{
$conditions .= " AND ";
}
$conditions .= implode("\n", $like);
}
$limit = ( ! $limit) ? '' : ' LIMIT '.$limit;
return "DELETE FROM ".$table.$conditions.$limit;
}
// --------------------------------------------------------------------
/**
* Limit string
*
* Generates a platform-specific LIMIT clause
*
* @access public
* @param string the sql query string
* @param integer the number of rows to limit the query to
* @param integer the offset value
* @return string
*/
function _limit($sql, $limit, $offset)
{
if ($offset == 0)
{
$offset = '';
}
else
{
$offset .= ", ";
}
return $sql."LIMIT ".$offset.$limit;
}
// --------------------------------------------------------------------
/**
* Close DB Connection
*
* @access public
* @param resource
* @return void
*/
function _close($conn_id)
{
@cubrid_close($conn_id);
}
}
/* End of file cubrid_driver.php */
/* Location: ./system/database/drivers/cubrid/cubrid_driver.php */ | php | MIT | 152cd2d808675d2baeb9e77c229adfbaf9a16475 | 2026-01-05T05:21:15.334872Z | false |
MobilityLab/TransitScreen | https://github.com/MobilityLab/TransitScreen/blob/152cd2d808675d2baeb9e77c229adfbaf9a16475/system/database/drivers/pdo/pdo_result.php | system/database/drivers/pdo/pdo_result.php | <?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
/**
* CodeIgniter
*
* An open source application development framework for PHP 5.1.6 or newer
*
* @package CodeIgniter
* @copyright Copyright (c) 2008 - 2011, EllisLab, Inc.
* @license http://codeigniter.com/user_guide/license.html
* @author EllisLab Dev Team
* @link http://codeigniter.com
* @since Version 2.1.0
* @filesource
*/
// ------------------------------------------------------------------------
/**
* PDO Result Class
*
* This class extends the parent result class: CI_DB_result
*
* @category Database
* @author EllisLab Dev Team
* @link http://codeigniter.com/user_guide/database/
*/
class CI_DB_pdo_result extends CI_DB_result {
/**
* Number of rows in the result set
*
* @access public
* @return integer
*/
function num_rows()
{
return $this->result_id->rowCount();
}
// --------------------------------------------------------------------
/**
* Number of fields in the result set
*
* @access public
* @return integer
*/
function num_fields()
{
return $this->result_id->columnCount();
}
// --------------------------------------------------------------------
/**
* Fetch Field Names
*
* Generates an array of column names
*
* @access public
* @return array
*/
function list_fields()
{
if ($this->db->db_debug)
{
return $this->db->display_error('db_unsuported_feature');
}
return FALSE;
}
// --------------------------------------------------------------------
/**
* Field data
*
* Generates an array of objects containing field meta-data
*
* @access public
* @return array
*/
function field_data()
{
$data = array();
try
{
for($i = 0; $i < $this->num_fields(); $i++)
{
$data[] = $this->result_id->getColumnMeta($i);
}
return $data;
}
catch (Exception $e)
{
if ($this->db->db_debug)
{
return $this->db->display_error('db_unsuported_feature');
}
return FALSE;
}
}
// --------------------------------------------------------------------
/**
* Free the result
*
* @return null
*/
function free_result()
{
if (is_object($this->result_id))
{
$this->result_id = FALSE;
}
}
// --------------------------------------------------------------------
/**
* Data Seek
*
* Moves the internal pointer to the desired offset. We call
* this internally before fetching results to make sure the
* result set starts at zero
*
* @access private
* @return array
*/
function _data_seek($n = 0)
{
return FALSE;
}
// --------------------------------------------------------------------
/**
* Result - associative array
*
* Returns the result set as an array
*
* @access private
* @return array
*/
function _fetch_assoc()
{
return $this->result_id->fetch(PDO::FETCH_ASSOC);
}
// --------------------------------------------------------------------
/**
* Result - object
*
* Returns the result set as an object
*
* @access private
* @return object
*/
function _fetch_object()
{
return $this->result_id->fetchObject();
}
}
/* End of file pdo_result.php */
/* Location: ./system/database/drivers/pdo/pdo_result.php */ | php | MIT | 152cd2d808675d2baeb9e77c229adfbaf9a16475 | 2026-01-05T05:21:15.334872Z | false |
MobilityLab/TransitScreen | https://github.com/MobilityLab/TransitScreen/blob/152cd2d808675d2baeb9e77c229adfbaf9a16475/system/database/drivers/pdo/pdo_driver.php | system/database/drivers/pdo/pdo_driver.php | <?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
/**
* CodeIgniter
*
* An open source application development framework for PHP 5.1.6 or newer
*
* @package CodeIgniter
* @copyright Copyright (c) 2008 - 2011, EllisLab, Inc.
* @license http://codeigniter.com/user_guide/license.html
* @author EllisLab Dev Team
* @link http://codeigniter.com
* @since Version 2.1.0
* @filesource
*/
// ------------------------------------------------------------------------
/**
* PDO Database Adapter Class
*
* Note: _DB is an extender class that the app controller
* creates dynamically based on whether the active record
* class is being used or not.
*
* @package CodeIgniter
* @subpackage Drivers
* @category Database
* @author EllisLab Dev Team
* @link http://codeigniter.com/user_guide/database/
*/
class CI_DB_pdo_driver extends CI_DB {
var $dbdriver = 'pdo';
// the character used to excape - not necessary for PDO
var $_escape_char = '';
var $_like_escape_str;
var $_like_escape_chr;
/**
* The syntax to count rows is slightly different across different
* database engines, so this string appears in each driver and is
* used for the count_all() and count_all_results() functions.
*/
var $_count_string = "SELECT COUNT(*) AS ";
var $_random_keyword;
var $options = array();
function __construct($params)
{
parent::__construct($params);
// clause and character used for LIKE escape sequences
if (strpos($this->hostname, 'mysql') !== FALSE)
{
$this->_like_escape_str = '';
$this->_like_escape_chr = '';
//Prior to this version, the charset can't be set in the dsn
if(is_php('5.3.6'))
{
$this->hostname .= ";charset={$this->char_set}";
}
//Set the charset with the connection options
$this->options['PDO::MYSQL_ATTR_INIT_COMMAND'] = "SET NAMES {$this->char_set}";
}
else if (strpos($this->hostname, 'odbc') !== FALSE)
{
$this->_like_escape_str = " {escape '%s'} ";
$this->_like_escape_chr = '!';
}
else
{
$this->_like_escape_str = " ESCAPE '%s' ";
$this->_like_escape_chr = '!';
}
$this->hostname .= ";dbname=".$this->database;
$this->trans_enabled = FALSE;
$this->_random_keyword = ' RND('.time().')'; // database specific random keyword
}
/**
* Non-persistent database connection
*
* @access private called by the base class
* @return resource
*/
function db_connect()
{
$this->options['PDO::ATTR_ERRMODE'] = PDO::ERRMODE_SILENT;
return new PDO($this->hostname, $this->username, $this->password, $this->options);
}
// --------------------------------------------------------------------
/**
* Persistent database connection
*
* @access private called by the base class
* @return resource
*/
function db_pconnect()
{
$this->options['PDO::ATTR_ERRMODE'] = PDO::ERRMODE_SILENT;
$this->options['PDO::ATTR_PERSISTENT'] = TRUE;
return new PDO($this->hostname, $this->username, $this->password, $this->options);
}
// --------------------------------------------------------------------
/**
* Reconnect
*
* Keep / reestablish the db connection if no queries have been
* sent for a length of time exceeding the server's idle timeout
*
* @access public
* @return void
*/
function reconnect()
{
if ($this->db->db_debug)
{
return $this->db->display_error('db_unsuported_feature');
}
return FALSE;
}
// --------------------------------------------------------------------
/**
* Select the database
*
* @access private called by the base class
* @return resource
*/
function db_select()
{
// Not needed for PDO
return TRUE;
}
// --------------------------------------------------------------------
/**
* Set client character set
*
* @access public
* @param string
* @param string
* @return resource
*/
function db_set_charset($charset, $collation)
{
// @todo - add support if needed
return TRUE;
}
// --------------------------------------------------------------------
/**
* Version number query string
*
* @access public
* @return string
*/
function _version()
{
return $this->conn_id->getAttribute(PDO::ATTR_CLIENT_VERSION);
}
// --------------------------------------------------------------------
/**
* Execute the query
*
* @access private called by the base class
* @param string an SQL query
* @return object
*/
function _execute($sql)
{
$sql = $this->_prep_query($sql);
$result_id = $this->conn_id->query($sql);
if (is_object($result_id))
{
$this->affect_rows = $result_id->rowCount();
}
else
{
$this->affect_rows = 0;
}
return $result_id;
}
// --------------------------------------------------------------------
/**
* Prep the query
*
* If needed, each database adapter can prep the query string
*
* @access private called by execute()
* @param string an SQL query
* @return string
*/
function _prep_query($sql)
{
return $sql;
}
// --------------------------------------------------------------------
/**
* Begin Transaction
*
* @access public
* @return bool
*/
function trans_begin($test_mode = FALSE)
{
if ( ! $this->trans_enabled)
{
return TRUE;
}
// When transactions are nested we only begin/commit/rollback the outermost ones
if ($this->_trans_depth > 0)
{
return TRUE;
}
// Reset the transaction failure flag.
// If the $test_mode flag is set to TRUE transactions will be rolled back
// even if the queries produce a successful result.
$this->_trans_failure = (bool) ($test_mode === TRUE);
return $this->conn_id->beginTransaction();
}
// --------------------------------------------------------------------
/**
* Commit Transaction
*
* @access public
* @return bool
*/
function trans_commit()
{
if ( ! $this->trans_enabled)
{
return TRUE;
}
// When transactions are nested we only begin/commit/rollback the outermost ones
if ($this->_trans_depth > 0)
{
return TRUE;
}
$ret = $this->conn->commit();
return $ret;
}
// --------------------------------------------------------------------
/**
* Rollback Transaction
*
* @access public
* @return bool
*/
function trans_rollback()
{
if ( ! $this->trans_enabled)
{
return TRUE;
}
// When transactions are nested we only begin/commit/rollback the outermost ones
if ($this->_trans_depth > 0)
{
return TRUE;
}
$ret = $this->conn_id->rollBack();
return $ret;
}
// --------------------------------------------------------------------
/**
* Escape String
*
* @access public
* @param string
* @param bool whether or not the string will be used in a LIKE condition
* @return string
*/
function escape_str($str, $like = FALSE)
{
if (is_array($str))
{
foreach ($str as $key => $val)
{
$str[$key] = $this->escape_str($val, $like);
}
return $str;
}
//Escape the string
$str = $this->conn_id->quote($str);
//If there are duplicated quotes, trim them away
if (strpos($str, "'") === 0)
{
$str = substr($str, 1, -1);
}
// escape LIKE condition wildcards
if ($like === TRUE)
{
$str = str_replace( array('%', '_', $this->_like_escape_chr),
array($this->_like_escape_chr.'%', $this->_like_escape_chr.'_', $this->_like_escape_chr.$this->_like_escape_chr),
$str);
}
return $str;
}
// --------------------------------------------------------------------
/**
* Affected Rows
*
* @access public
* @return integer
*/
function affected_rows()
{
return $this->affect_rows;
}
// --------------------------------------------------------------------
/**
* Insert ID
*
* @access public
* @return integer
*/
function insert_id($name=NULL)
{
//Convenience method for postgres insertid
if (strpos($this->hostname, 'pgsql') !== FALSE)
{
$v = $this->_version();
$table = func_num_args() > 0 ? func_get_arg(0) : NULL;
if ($table == NULL && $v >= '8.1')
{
$sql='SELECT LASTVAL() as ins_id';
}
$query = $this->query($sql);
$row = $query->row();
return $row->ins_id;
}
else
{
return $this->conn_id->lastInsertId($name);
}
}
// --------------------------------------------------------------------
/**
* "Count All" query
*
* Generates a platform-specific query string that counts all records in
* the specified database
*
* @access public
* @param string
* @return string
*/
function count_all($table = '')
{
if ($table == '')
{
return 0;
}
$query = $this->query($this->_count_string . $this->_protect_identifiers('numrows') . " FROM " . $this->_protect_identifiers($table, TRUE, NULL, FALSE));
if ($query->num_rows() == 0)
{
return 0;
}
$row = $query->row();
$this->_reset_select();
return (int) $row->numrows;
}
// --------------------------------------------------------------------
/**
* Show table query
*
* Generates a platform-specific query string so that the table names can be fetched
*
* @access private
* @param boolean
* @return string
*/
function _list_tables($prefix_limit = FALSE)
{
$sql = "SHOW TABLES FROM `".$this->database."`";
if ($prefix_limit !== FALSE AND $this->dbprefix != '')
{
//$sql .= " LIKE '".$this->escape_like_str($this->dbprefix)."%' ".sprintf($this->_like_escape_str, $this->_like_escape_chr);
return FALSE; // not currently supported
}
return $sql;
}
// --------------------------------------------------------------------
/**
* Show column query
*
* Generates a platform-specific query string so that the column names can be fetched
*
* @access public
* @param string the table name
* @return string
*/
function _list_columns($table = '')
{
return "SHOW COLUMNS FROM ".$table;
}
// --------------------------------------------------------------------
/**
* Field data query
*
* Generates a platform-specific query so that the column data can be retrieved
*
* @access public
* @param string the table name
* @return object
*/
function _field_data($table)
{
return "SELECT TOP 1 FROM ".$table;
}
// --------------------------------------------------------------------
/**
* The error message string
*
* @access private
* @return string
*/
function _error_message()
{
$error_array = $this->conn_id->errorInfo();
return $error_array[2];
}
// --------------------------------------------------------------------
/**
* The error message number
*
* @access private
* @return integer
*/
function _error_number()
{
return $this->conn_id->errorCode();
}
// --------------------------------------------------------------------
/**
* Escape the SQL Identifiers
*
* This function escapes column and table names
*
* @access private
* @param string
* @return string
*/
function _escape_identifiers($item)
{
if ($this->_escape_char == '')
{
return $item;
}
foreach ($this->_reserved_identifiers as $id)
{
if (strpos($item, '.'.$id) !== FALSE)
{
$str = $this->_escape_char. str_replace('.', $this->_escape_char.'.', $item);
// remove duplicates if the user already included the escape
return preg_replace('/['.$this->_escape_char.']+/', $this->_escape_char, $str);
}
}
if (strpos($item, '.') !== FALSE)
{
$str = $this->_escape_char.str_replace('.', $this->_escape_char.'.'.$this->_escape_char, $item).$this->_escape_char;
}
else
{
$str = $this->_escape_char.$item.$this->_escape_char;
}
// remove duplicates if the user already included the escape
return preg_replace('/['.$this->_escape_char.']+/', $this->_escape_char, $str);
}
// --------------------------------------------------------------------
/**
* From Tables
*
* This function implicitly groups FROM tables so there is no confusion
* about operator precedence in harmony with SQL standards
*
* @access public
* @param type
* @return type
*/
function _from_tables($tables)
{
if ( ! is_array($tables))
{
$tables = array($tables);
}
return (count($tables) == 1) ? $tables[0] : '('.implode(', ', $tables).')';
}
// --------------------------------------------------------------------
/**
* Insert statement
*
* Generates a platform-specific insert string from the supplied data
*
* @access public
* @param string the table name
* @param array the insert keys
* @param array the insert values
* @return string
*/
function _insert($table, $keys, $values)
{
return "INSERT INTO ".$table." (".implode(', ', $keys).") VALUES (".implode(', ', $values).")";
}
// --------------------------------------------------------------------
/**
* Insert_batch statement
*
* Generates a platform-specific insert string from the supplied data
*
* @access public
* @param string the table name
* @param array the insert keys
* @param array the insert values
* @return string
*/
function _insert_batch($table, $keys, $values)
{
return "INSERT INTO ".$table." (".implode(', ', $keys).") VALUES ".implode(', ', $values);
}
// --------------------------------------------------------------------
/**
* Update statement
*
* Generates a platform-specific update string from the supplied data
*
* @access public
* @param string the table name
* @param array the update data
* @param array the where clause
* @param array the orderby clause
* @param array the limit clause
* @return string
*/
function _update($table, $values, $where, $orderby = array(), $limit = FALSE)
{
foreach ($values as $key => $val)
{
$valstr[] = $key." = ".$val;
}
$limit = ( ! $limit) ? '' : ' LIMIT '.$limit;
$orderby = (count($orderby) >= 1)?' ORDER BY '.implode(", ", $orderby):'';
$sql = "UPDATE ".$table." SET ".implode(', ', $valstr);
$sql .= ($where != '' AND count($where) >=1) ? " WHERE ".implode(" ", $where) : '';
$sql .= $orderby.$limit;
return $sql;
}
// --------------------------------------------------------------------
/**
* Update_Batch statement
*
* Generates a platform-specific batch update string from the supplied data
*
* @access public
* @param string the table name
* @param array the update data
* @param array the where clause
* @return string
*/
function _update_batch($table, $values, $index, $where = NULL)
{
$ids = array();
$where = ($where != '' AND count($where) >=1) ? implode(" ", $where).' AND ' : '';
foreach ($values as $key => $val)
{
$ids[] = $val[$index];
foreach (array_keys($val) as $field)
{
if ($field != $index)
{
$final[$field][] = 'WHEN '.$index.' = '.$val[$index].' THEN '.$val[$field];
}
}
}
$sql = "UPDATE ".$table." SET ";
$cases = '';
foreach ($final as $k => $v)
{
$cases .= $k.' = CASE '."\n";
foreach ($v as $row)
{
$cases .= $row."\n";
}
$cases .= 'ELSE '.$k.' END, ';
}
$sql .= substr($cases, 0, -2);
$sql .= ' WHERE '.$where.$index.' IN ('.implode(',', $ids).')';
return $sql;
}
// --------------------------------------------------------------------
/**
* Truncate statement
*
* Generates a platform-specific truncate string from the supplied data
* If the database does not support the truncate() command
* This function maps to "DELETE FROM table"
*
* @access public
* @param string the table name
* @return string
*/
function _truncate($table)
{
return $this->_delete($table);
}
// --------------------------------------------------------------------
/**
* Delete statement
*
* Generates a platform-specific delete string from the supplied data
*
* @access public
* @param string the table name
* @param array the where clause
* @param string the limit clause
* @return string
*/
function _delete($table, $where = array(), $like = array(), $limit = FALSE)
{
$conditions = '';
if (count($where) > 0 OR count($like) > 0)
{
$conditions = "\nWHERE ";
$conditions .= implode("\n", $this->ar_where);
if (count($where) > 0 && count($like) > 0)
{
$conditions .= " AND ";
}
$conditions .= implode("\n", $like);
}
$limit = ( ! $limit) ? '' : ' LIMIT '.$limit;
return "DELETE FROM ".$table.$conditions.$limit;
}
// --------------------------------------------------------------------
/**
* Limit string
*
* Generates a platform-specific LIMIT clause
*
* @access public
* @param string the sql query string
* @param integer the number of rows to limit the query to
* @param integer the offset value
* @return string
*/
function _limit($sql, $limit, $offset)
{
if (strpos($this->hostname, 'cubrid') !== FALSE || strpos($this->hostname, 'sqlite') !== FALSE)
{
if ($offset == 0)
{
$offset = '';
}
else
{
$offset .= ", ";
}
return $sql."LIMIT ".$offset.$limit;
}
else
{
$sql .= "LIMIT ".$limit;
if ($offset > 0)
{
$sql .= " OFFSET ".$offset;
}
return $sql;
}
}
// --------------------------------------------------------------------
/**
* Close DB Connection
*
* @access public
* @param resource
* @return void
*/
function _close($conn_id)
{
$this->conn_id = null;
}
}
/* End of file pdo_driver.php */
/* Location: ./system/database/drivers/pdo/pdo_driver.php */ | php | MIT | 152cd2d808675d2baeb9e77c229adfbaf9a16475 | 2026-01-05T05:21:15.334872Z | false |
MobilityLab/TransitScreen | https://github.com/MobilityLab/TransitScreen/blob/152cd2d808675d2baeb9e77c229adfbaf9a16475/system/database/drivers/pdo/pdo_utility.php | system/database/drivers/pdo/pdo_utility.php | <?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
/**
* CodeIgniter
*
* An open source application development framework for PHP 5.1.6 or newer
*
* @package CodeIgniter
* @copyright Copyright (c) 2008 - 2011, EllisLab, Inc.
* @license http://codeigniter.com/user_guide/license.html
* @author EllisLab Dev Team
* @link http://codeigniter.com
* @since Version 2.1.0
* @filesource
*/
// ------------------------------------------------------------------------
/**
* PDO Utility Class
*
* @category Database
* @author EllisLab Dev Team
* @link http://codeigniter.com/database/
*/
class CI_DB_pdo_utility extends CI_DB_utility {
/**
* List databases
*
* @access private
* @return bool
*/
function _list_databases()
{
// Not sure if PDO lets you list all databases...
if ($this->db->db_debug)
{
return $this->db->display_error('db_unsuported_feature');
}
return FALSE;
}
// --------------------------------------------------------------------
/**
* Optimize table query
*
* Generates a platform-specific query so that a table can be optimized
*
* @access private
* @param string the table name
* @return object
*/
function _optimize_table($table)
{
// Not a supported PDO feature
if ($this->db->db_debug)
{
return $this->db->display_error('db_unsuported_feature');
}
return FALSE;
}
// --------------------------------------------------------------------
/**
* Repair table query
*
* Generates a platform-specific query so that a table can be repaired
*
* @access private
* @param string the table name
* @return object
*/
function _repair_table($table)
{
// Not a supported PDO feature
if ($this->db->db_debug)
{
return $this->db->display_error('db_unsuported_feature');
}
return FALSE;
}
// --------------------------------------------------------------------
/**
* PDO Export
*
* @access private
* @param array Preferences
* @return mixed
*/
function _backup($params = array())
{
// Currently unsupported
return $this->db->display_error('db_unsuported_feature');
}
}
/* End of file pdo_utility.php */
/* Location: ./system/database/drivers/pdo/pdo_utility.php */ | php | MIT | 152cd2d808675d2baeb9e77c229adfbaf9a16475 | 2026-01-05T05:21:15.334872Z | false |
MobilityLab/TransitScreen | https://github.com/MobilityLab/TransitScreen/blob/152cd2d808675d2baeb9e77c229adfbaf9a16475/system/database/drivers/pdo/pdo_forge.php | system/database/drivers/pdo/pdo_forge.php | <?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
/**
* CodeIgniter
*
* An open source application development framework for PHP 5.1.6 or newer
*
* @package CodeIgniter
* @copyright Copyright (c) 2008 - 2011, EllisLab, Inc.
* @license http://codeigniter.com/user_guide/license.html
* @author EllisLab Dev Team
* @link http://codeigniter.com
* @since Version 2.1.0
* @filesource
*/
// ------------------------------------------------------------------------
/**
* PDO Forge Class
*
* @category Database
* @author EllisLab Dev Team
* @link http://codeigniter.com/database/
*/
class CI_DB_pdo_forge extends CI_DB_forge {
/**
* Create database
*
* @access private
* @param string the database name
* @return bool
*/
function _create_database()
{
// PDO has no "create database" command since it's
// designed to connect to an existing database
if ($this->db->db_debug)
{
return $this->db->display_error('db_unsuported_feature');
}
return FALSE;
}
// --------------------------------------------------------------------
/**
* Drop database
*
* @access private
* @param string the database name
* @return bool
*/
function _drop_database($name)
{
// PDO has no "drop database" command since it's
// designed to connect to an existing database
if ($this->db->db_debug)
{
return $this->db->display_error('db_unsuported_feature');
}
return FALSE;
}
// --------------------------------------------------------------------
/**
* Create Table
*
* @access private
* @param string the table name
* @param array the fields
* @param mixed primary key(s)
* @param mixed key(s)
* @param boolean should 'IF NOT EXISTS' be added to the SQL
* @return bool
*/
function _create_table($table, $fields, $primary_keys, $keys, $if_not_exists)
{
$sql = 'CREATE TABLE ';
if ($if_not_exists === TRUE)
{
$sql .= 'IF NOT EXISTS ';
}
$sql .= $this->db->_escape_identifiers($table)." (";
$current_field_count = 0;
foreach ($fields as $field=>$attributes)
{
// Numeric field names aren't allowed in databases, so if the key is
// numeric, we know it was assigned by PHP and the developer manually
// entered the field information, so we'll simply add it to the list
if (is_numeric($field))
{
$sql .= "\n\t$attributes";
}
else
{
$attributes = array_change_key_case($attributes, CASE_UPPER);
$sql .= "\n\t".$this->db->_protect_identifiers($field);
$sql .= ' '.$attributes['TYPE'];
if (array_key_exists('CONSTRAINT', $attributes))
{
$sql .= '('.$attributes['CONSTRAINT'].')';
}
if (array_key_exists('UNSIGNED', $attributes) && $attributes['UNSIGNED'] === TRUE)
{
$sql .= ' UNSIGNED';
}
if (array_key_exists('DEFAULT', $attributes))
{
$sql .= ' DEFAULT \''.$attributes['DEFAULT'].'\'';
}
if (array_key_exists('NULL', $attributes) && $attributes['NULL'] === TRUE)
{
$sql .= ' NULL';
}
else
{
$sql .= ' NOT NULL';
}
if (array_key_exists('AUTO_INCREMENT', $attributes) && $attributes['AUTO_INCREMENT'] === TRUE)
{
$sql .= ' AUTO_INCREMENT';
}
}
// don't add a comma on the end of the last field
if (++$current_field_count < count($fields))
{
$sql .= ',';
}
}
if (count($primary_keys) > 0)
{
$primary_keys = $this->db->_protect_identifiers($primary_keys);
$sql .= ",\n\tPRIMARY KEY (" . implode(', ', $primary_keys) . ")";
}
if (is_array($keys) && count($keys) > 0)
{
foreach ($keys as $key)
{
if (is_array($key))
{
$key = $this->db->_protect_identifiers($key);
}
else
{
$key = array($this->db->_protect_identifiers($key));
}
$sql .= ",\n\tFOREIGN KEY (" . implode(', ', $key) . ")";
}
}
$sql .= "\n)";
return $sql;
}
// --------------------------------------------------------------------
/**
* Drop Table
*
* @access private
* @return bool
*/
function _drop_table($table)
{
// Not a supported PDO feature
if ($this->db->db_debug)
{
return $this->db->display_error('db_unsuported_feature');
}
return FALSE;
}
// --------------------------------------------------------------------
/**
* Alter table query
*
* Generates a platform-specific query so that a table can be altered
* Called by add_column(), drop_column(), and column_alter(),
*
* @access private
* @param string the ALTER type (ADD, DROP, CHANGE)
* @param string the column name
* @param string the table name
* @param string the column definition
* @param string the default value
* @param boolean should 'NOT NULL' be added
* @param string the field after which we should add the new field
* @return object
*/
function _alter_table($alter_type, $table, $column_name, $column_definition = '', $default_value = '', $null = '', $after_field = '')
{
$sql = 'ALTER TABLE '.$this->db->_protect_identifiers($table)." $alter_type ".$this->db->_protect_identifiers($column_name);
// DROP has everything it needs now.
if ($alter_type == 'DROP')
{
return $sql;
}
$sql .= " $column_definition";
if ($default_value != '')
{
$sql .= " DEFAULT \"$default_value\"";
}
if ($null === NULL)
{
$sql .= ' NULL';
}
else
{
$sql .= ' NOT NULL';
}
if ($after_field != '')
{
$sql .= ' AFTER ' . $this->db->_protect_identifiers($after_field);
}
return $sql;
}
// --------------------------------------------------------------------
/**
* Rename a table
*
* Generates a platform-specific query so that a table can be renamed
*
* @access private
* @param string the old table name
* @param string the new table name
* @return string
*/
function _rename_table($table_name, $new_table_name)
{
$sql = 'ALTER TABLE '.$this->db->_protect_identifiers($table_name)." RENAME TO ".$this->db->_protect_identifiers($new_table_name);
return $sql;
}
}
/* End of file pdo_forge.php */
/* Location: ./system/database/drivers/pdo/pdo_forge.php */ | php | MIT | 152cd2d808675d2baeb9e77c229adfbaf9a16475 | 2026-01-05T05:21:15.334872Z | false |
MobilityLab/TransitScreen | https://github.com/MobilityLab/TransitScreen/blob/152cd2d808675d2baeb9e77c229adfbaf9a16475/system/database/drivers/oci8/oci8_result.php | system/database/drivers/oci8/oci8_result.php | <?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
/**
* CodeIgniter
*
* An open source application development framework for PHP 5.1.6 or newer
*
* @package CodeIgniter
* @author ExpressionEngine Dev Team
* @copyright Copyright (c) 2008 - 2011, EllisLab, Inc.
* @license http://codeigniter.com/user_guide/license.html
* @link http://codeigniter.com
* @since Version 1.0
* @filesource
*/
// ------------------------------------------------------------------------
/**
* oci8 Result Class
*
* This class extends the parent result class: CI_DB_result
*
* @category Database
* @author ExpressionEngine Dev Team
* @link http://codeigniter.com/user_guide/database/
*/
class CI_DB_oci8_result extends CI_DB_result {
var $stmt_id;
var $curs_id;
var $limit_used;
/**
* Number of rows in the result set.
*
* Oracle doesn't have a graceful way to retun the number of rows
* so we have to use what amounts to a hack.
*
*
* @access public
* @return integer
*/
public function num_rows()
{
if ($this->num_rows === 0 && count($this->result_array()) > 0)
{
$this->num_rows = count($this->result_array());
@oci_execute($this->stmt_id);
if ($this->curs_id)
{
@oci_execute($this->curs_id);
}
}
return $rowcount;
}
// --------------------------------------------------------------------
/**
* Number of fields in the result set
*
* @access public
* @return integer
*/
public function num_fields()
{
$count = @oci_num_fields($this->stmt_id);
// if we used a limit we subtract it
if ($this->limit_used)
{
$count = $count - 1;
}
return $count;
}
// --------------------------------------------------------------------
/**
* Fetch Field Names
*
* Generates an array of column names
*
* @access public
* @return array
*/
public function list_fields()
{
$field_names = array();
for ($c = 1, $fieldCount = $this->num_fields(); $c <= $fieldCount; $c++)
{
$field_names[] = oci_field_name($this->stmt_id, $c);
}
return $field_names;
}
// --------------------------------------------------------------------
/**
* Field data
*
* Generates an array of objects containing field meta-data
*
* @access public
* @return array
*/
public function field_data()
{
$retval = array();
for ($c = 1, $fieldCount = $this->num_fields(); $c <= $fieldCount; $c++)
{
$F = new stdClass();
$F->name = oci_field_name($this->stmt_id, $c);
$F->type = oci_field_type($this->stmt_id, $c);
$F->max_length = oci_field_size($this->stmt_id, $c);
$retval[] = $F;
}
return $retval;
}
// --------------------------------------------------------------------
/**
* Free the result
*
* @return null
*/
public function free_result()
{
if (is_resource($this->result_id))
{
oci_free_statement($this->result_id);
$this->result_id = FALSE;
}
}
// --------------------------------------------------------------------
/**
* Result - associative array
*
* Returns the result set as an array
*
* @access protected
* @return array
*/
protected function _fetch_assoc()
{
$id = ($this->curs_id) ? $this->curs_id : $this->stmt_id;
return oci_fetch_assoc($id);
}
// --------------------------------------------------------------------
/**
* Result - object
*
* Returns the result set as an object
*
* @access protected
* @return object
*/
protected function _fetch_object()
{
$id = ($this->curs_id) ? $this->curs_id : $this->stmt_id;
return @oci_fetch_object($id);
}
// --------------------------------------------------------------------
/**
* Query result. "array" version.
*
* @access public
* @return array
*/
public function result_array()
{
if (count($this->result_array) > 0)
{
return $this->result_array;
}
$row = NULL;
while ($row = $this->_fetch_assoc())
{
$this->result_array[] = $row;
}
return $this->result_array;
}
// --------------------------------------------------------------------
/**
* Data Seek
*
* Moves the internal pointer to the desired offset. We call
* this internally before fetching results to make sure the
* result set starts at zero
*
* @access protected
* @return array
*/
protected function _data_seek($n = 0)
{
return FALSE; // Not needed
}
}
/* End of file oci8_result.php */
/* Location: ./system/database/drivers/oci8/oci8_result.php */
| php | MIT | 152cd2d808675d2baeb9e77c229adfbaf9a16475 | 2026-01-05T05:21:15.334872Z | false |
MobilityLab/TransitScreen | https://github.com/MobilityLab/TransitScreen/blob/152cd2d808675d2baeb9e77c229adfbaf9a16475/system/database/drivers/oci8/oci8_forge.php | system/database/drivers/oci8/oci8_forge.php | <?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
/**
* CodeIgniter
*
* An open source application development framework for PHP 5.1.6 or newer
*
* @package CodeIgniter
* @author ExpressionEngine Dev Team
* @copyright Copyright (c) 2008 - 2011, EllisLab, Inc.
* @license http://codeigniter.com/user_guide/license.html
* @link http://codeigniter.com
* @since Version 1.0
* @filesource
*/
// ------------------------------------------------------------------------
/**
* Oracle Forge Class
*
* @category Database
* @author ExpressionEngine Dev Team
* @link http://codeigniter.com/user_guide/database/
*/
class CI_DB_oci8_forge extends CI_DB_forge {
/**
* Create database
*
* @access public
* @param string the database name
* @return bool
*/
function _create_database($name)
{
return FALSE;
}
// --------------------------------------------------------------------
/**
* Drop database
*
* @access private
* @param string the database name
* @return bool
*/
function _drop_database($name)
{
return FALSE;
}
// --------------------------------------------------------------------
/**
* Create Table
*
* @access private
* @param string the table name
* @param array the fields
* @param mixed primary key(s)
* @param mixed key(s)
* @param boolean should 'IF NOT EXISTS' be added to the SQL
* @return bool
*/
function _create_table($table, $fields, $primary_keys, $keys, $if_not_exists)
{
$sql = 'CREATE TABLE ';
if ($if_not_exists === TRUE)
{
$sql .= 'IF NOT EXISTS ';
}
$sql .= $this->db->_escape_identifiers($table)." (";
$current_field_count = 0;
foreach ($fields as $field=>$attributes)
{
// Numeric field names aren't allowed in databases, so if the key is
// numeric, we know it was assigned by PHP and the developer manually
// entered the field information, so we'll simply add it to the list
if (is_numeric($field))
{
$sql .= "\n\t$attributes";
}
else
{
$attributes = array_change_key_case($attributes, CASE_UPPER);
$sql .= "\n\t".$this->db->_protect_identifiers($field);
$sql .= ' '.$attributes['TYPE'];
if (array_key_exists('CONSTRAINT', $attributes))
{
$sql .= '('.$attributes['CONSTRAINT'].')';
}
if (array_key_exists('UNSIGNED', $attributes) && $attributes['UNSIGNED'] === TRUE)
{
$sql .= ' UNSIGNED';
}
if (array_key_exists('DEFAULT', $attributes))
{
$sql .= ' DEFAULT \''.$attributes['DEFAULT'].'\'';
}
if (array_key_exists('NULL', $attributes) && $attributes['NULL'] === TRUE)
{
$sql .= ' NULL';
}
else
{
$sql .= ' NOT NULL';
}
if (array_key_exists('AUTO_INCREMENT', $attributes) && $attributes['AUTO_INCREMENT'] === TRUE)
{
$sql .= ' AUTO_INCREMENT';
}
}
// don't add a comma on the end of the last field
if (++$current_field_count < count($fields))
{
$sql .= ',';
}
}
if (count($primary_keys) > 0)
{
$primary_keys = $this->db->_protect_identifiers($primary_keys);
$sql .= ",\n\tPRIMARY KEY (" . implode(', ', $primary_keys) . ")";
}
if (is_array($keys) && count($keys) > 0)
{
foreach ($keys as $key)
{
if (is_array($key))
{
$key = $this->db->_protect_identifiers($key);
}
else
{
$key = array($this->db->_protect_identifiers($key));
}
$sql .= ",\n\tUNIQUE COLUMNS (" . implode(', ', $key) . ")";
}
}
$sql .= "\n)";
return $sql;
}
// --------------------------------------------------------------------
/**
* Drop Table
*
* @access private
* @return bool
*/
function _drop_table($table)
{
return FALSE;
}
// --------------------------------------------------------------------
/**
* Alter table query
*
* Generates a platform-specific query so that a table can be altered
* Called by add_column(), drop_column(), and column_alter(),
*
* @access private
* @param string the ALTER type (ADD, DROP, CHANGE)
* @param string the column name
* @param string the table name
* @param string the column definition
* @param string the default value
* @param boolean should 'NOT NULL' be added
* @param string the field after which we should add the new field
* @return object
*/
function _alter_table($alter_type, $table, $column_name, $column_definition = '', $default_value = '', $null = '', $after_field = '')
{
$sql = 'ALTER TABLE '.$this->db->_protect_identifiers($table)." $alter_type ".$this->db->_protect_identifiers($column_name);
// DROP has everything it needs now.
if ($alter_type == 'DROP')
{
return $sql;
}
$sql .= " $column_definition";
if ($default_value != '')
{
$sql .= " DEFAULT \"$default_value\"";
}
if ($null === NULL)
{
$sql .= ' NULL';
}
else
{
$sql .= ' NOT NULL';
}
if ($after_field != '')
{
$sql .= ' AFTER ' . $this->db->_protect_identifiers($after_field);
}
return $sql;
}
// --------------------------------------------------------------------
/**
* Rename a table
*
* Generates a platform-specific query so that a table can be renamed
*
* @access private
* @param string the old table name
* @param string the new table name
* @return string
*/
function _rename_table($table_name, $new_table_name)
{
$sql = 'ALTER TABLE '.$this->db->_protect_identifiers($table_name)." RENAME TO ".$this->db->_protect_identifiers($new_table_name);
return $sql;
}
}
/* End of file oci8_forge.php */
/* Location: ./system/database/drivers/oci8/oci8_forge.php */ | php | MIT | 152cd2d808675d2baeb9e77c229adfbaf9a16475 | 2026-01-05T05:21:15.334872Z | false |
MobilityLab/TransitScreen | https://github.com/MobilityLab/TransitScreen/blob/152cd2d808675d2baeb9e77c229adfbaf9a16475/system/database/drivers/oci8/oci8_driver.php | system/database/drivers/oci8/oci8_driver.php | <?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
/**
* CodeIgniter
*
* An open source application development framework for PHP 5.1.6 or newer
*
* @package CodeIgniter
* @author ExpressionEngine Dev Team
* @copyright Copyright (c) 2008 - 2011, EllisLab, Inc.
* @license http://codeigniter.com/user_guide/license.html
* @link http://codeigniter.com
* @since Version 1.0
* @filesource
*/
// ------------------------------------------------------------------------
/**
* oci8 Database Adapter Class
*
* Note: _DB is an extender class that the app controller
* creates dynamically based on whether the active record
* class is being used or not.
*
* @package CodeIgniter
* @subpackage Drivers
* @category Database
* @author ExpressionEngine Dev Team
* @link http://codeigniter.com/user_guide/database/
*/
/**
* oci8 Database Adapter Class
*
* This is a modification of the DB_driver class to
* permit access to oracle databases
*
* @author Kelly McArdle
*
*/
class CI_DB_oci8_driver extends CI_DB {
var $dbdriver = 'oci8';
// The character used for excaping
var $_escape_char = '"';
// clause and character used for LIKE escape sequences
var $_like_escape_str = " escape '%s' ";
var $_like_escape_chr = '!';
/**
* The syntax to count rows is slightly different across different
* database engines, so this string appears in each driver and is
* used for the count_all() and count_all_results() functions.
*/
var $_count_string = "SELECT COUNT(1) AS ";
var $_random_keyword = ' ASC'; // not currently supported
// Set "auto commit" by default
var $_commit = OCI_COMMIT_ON_SUCCESS;
// need to track statement id and cursor id
var $stmt_id;
var $curs_id;
// if we use a limit, we will add a field that will
// throw off num_fields later
var $limit_used;
/**
* Non-persistent database connection
*
* @access private called by the base class
* @return resource
*/
public function db_connect()
{
return @oci_connect($this->username, $this->password, $this->hostname, $this->char_set);
}
// --------------------------------------------------------------------
/**
* Persistent database connection
*
* @access private called by the base class
* @return resource
*/
public function db_pconnect()
{
return @oci_pconnect($this->username, $this->password, $this->hostname, $this->char_set);
}
// --------------------------------------------------------------------
/**
* Reconnect
*
* Keep / reestablish the db connection if no queries have been
* sent for a length of time exceeding the server's idle timeout
*
* @access public
* @return void
*/
public function reconnect()
{
// not implemented in oracle
return;
}
// --------------------------------------------------------------------
/**
* Select the database
*
* @access private called by the base class
* @return resource
*/
public function db_select()
{
// Not in Oracle - schemas are actually usernames
return TRUE;
}
// --------------------------------------------------------------------
/**
* Set client character set
*
* @access public
* @param string
* @param string
* @return resource
*/
public function db_set_charset($charset, $collation)
{
// @todo - add support if needed
return TRUE;
}
// --------------------------------------------------------------------
/**
* Version number query string
*
* @access protected
* @return string
*/
protected function _version()
{
return oci_server_version($this->conn_id);
}
// --------------------------------------------------------------------
/**
* Execute the query
*
* @access protected called by the base class
* @param string an SQL query
* @return resource
*/
protected function _execute($sql)
{
// oracle must parse the query before it is run. All of the actions with
// the query are based on the statement id returned by ociparse
$this->stmt_id = FALSE;
$this->_set_stmt_id($sql);
oci_set_prefetch($this->stmt_id, 1000);
return @oci_execute($this->stmt_id, $this->_commit);
}
/**
* Generate a statement ID
*
* @access private
* @param string an SQL query
* @return none
*/
private function _set_stmt_id($sql)
{
if ( ! is_resource($this->stmt_id))
{
$this->stmt_id = oci_parse($this->conn_id, $this->_prep_query($sql));
}
}
// --------------------------------------------------------------------
/**
* Prep the query
*
* If needed, each database adapter can prep the query string
*
* @access private called by execute()
* @param string an SQL query
* @return string
*/
private function _prep_query($sql)
{
return $sql;
}
// --------------------------------------------------------------------
/**
* getCursor. Returns a cursor from the datbase
*
* @access public
* @return cursor id
*/
public function get_cursor()
{
$this->curs_id = oci_new_cursor($this->conn_id);
return $this->curs_id;
}
// --------------------------------------------------------------------
/**
* Stored Procedure. Executes a stored procedure
*
* @access public
* @param package package stored procedure is in
* @param procedure stored procedure to execute
* @param params array of parameters
* @return array
*
* params array keys
*
* KEY OPTIONAL NOTES
* name no the name of the parameter should be in :<param_name> format
* value no the value of the parameter. If this is an OUT or IN OUT parameter,
* this should be a reference to a variable
* type yes the type of the parameter
* length yes the max size of the parameter
*/
public function stored_procedure($package, $procedure, $params)
{
if ($package == '' OR $procedure == '' OR ! is_array($params))
{
if ($this->db_debug)
{
log_message('error', 'Invalid query: '.$package.'.'.$procedure);
return $this->display_error('db_invalid_query');
}
return FALSE;
}
// build the query string
$sql = "begin $package.$procedure(";
$have_cursor = FALSE;
foreach ($params as $param)
{
$sql .= $param['name'] . ",";
if (array_key_exists('type', $param) && ($param['type'] === OCI_B_CURSOR))
{
$have_cursor = TRUE;
}
}
$sql = trim($sql, ",") . "); end;";
$this->stmt_id = FALSE;
$this->_set_stmt_id($sql);
$this->_bind_params($params);
$this->query($sql, FALSE, $have_cursor);
}
// --------------------------------------------------------------------
/**
* Bind parameters
*
* @access private
* @return none
*/
private function _bind_params($params)
{
if ( ! is_array($params) OR ! is_resource($this->stmt_id))
{
return;
}
foreach ($params as $param)
{
foreach (array('name', 'value', 'type', 'length') as $val)
{
if ( ! isset($param[$val]))
{
$param[$val] = '';
}
}
oci_bind_by_name($this->stmt_id, $param['name'], $param['value'], $param['length'], $param['type']);
}
}
// --------------------------------------------------------------------
/**
* Begin Transaction
*
* @access public
* @return bool
*/
public function trans_begin($test_mode = FALSE)
{
if ( ! $this->trans_enabled)
{
return TRUE;
}
// When transactions are nested we only begin/commit/rollback the outermost ones
if ($this->_trans_depth > 0)
{
return TRUE;
}
// Reset the transaction failure flag.
// If the $test_mode flag is set to TRUE transactions will be rolled back
// even if the queries produce a successful result.
$this->_trans_failure = ($test_mode === TRUE) ? TRUE : FALSE;
$this->_commit = OCI_DEFAULT;
return TRUE;
}
// --------------------------------------------------------------------
/**
* Commit Transaction
*
* @access public
* @return bool
*/
public function trans_commit()
{
if ( ! $this->trans_enabled)
{
return TRUE;
}
// When transactions are nested we only begin/commit/rollback the outermost ones
if ($this->_trans_depth > 0)
{
return TRUE;
}
$ret = oci_commit($this->conn_id);
$this->_commit = OCI_COMMIT_ON_SUCCESS;
return $ret;
}
// --------------------------------------------------------------------
/**
* Rollback Transaction
*
* @access public
* @return bool
*/
public function trans_rollback()
{
if ( ! $this->trans_enabled)
{
return TRUE;
}
// When transactions are nested we only begin/commit/rollback the outermost ones
if ($this->_trans_depth > 0)
{
return TRUE;
}
$ret = oci_rollback($this->conn_id);
$this->_commit = OCI_COMMIT_ON_SUCCESS;
return $ret;
}
// --------------------------------------------------------------------
/**
* Escape String
*
* @access public
* @param string
* @param bool whether or not the string will be used in a LIKE condition
* @return string
*/
public function escape_str($str, $like = FALSE)
{
if (is_array($str))
{
foreach ($str as $key => $val)
{
$str[$key] = $this->escape_str($val, $like);
}
return $str;
}
$str = remove_invisible_characters($str);
// escape LIKE condition wildcards
if ($like === TRUE)
{
$str = str_replace( array('%', '_', $this->_like_escape_chr),
array($this->_like_escape_chr.'%', $this->_like_escape_chr.'_', $this->_like_escape_chr.$this->_like_escape_chr),
$str);
}
return $str;
}
// --------------------------------------------------------------------
/**
* Affected Rows
*
* @access public
* @return integer
*/
public function affected_rows()
{
return @oci_num_rows($this->stmt_id);
}
// --------------------------------------------------------------------
/**
* Insert ID
*
* @access public
* @return integer
*/
public function insert_id()
{
// not supported in oracle
return $this->display_error('db_unsupported_function');
}
// --------------------------------------------------------------------
/**
* "Count All" query
*
* Generates a platform-specific query string that counts all records in
* the specified database
*
* @access public
* @param string
* @return string
*/
public function count_all($table = '')
{
if ($table == '')
{
return 0;
}
$query = $this->query($this->_count_string . $this->_protect_identifiers('numrows') . " FROM " . $this->_protect_identifiers($table, TRUE, NULL, FALSE));
if ($query == FALSE)
{
return 0;
}
$row = $query->row();
$this->_reset_select();
return (int) $row->numrows;
}
// --------------------------------------------------------------------
/**
* Show table query
*
* Generates a platform-specific query string so that the table names can be fetched
*
* @access protected
* @param boolean
* @return string
*/
protected function _list_tables($prefix_limit = FALSE)
{
$sql = "SELECT TABLE_NAME FROM ALL_TABLES";
if ($prefix_limit !== FALSE AND $this->dbprefix != '')
{
$sql .= " WHERE TABLE_NAME LIKE '".$this->escape_like_str($this->dbprefix)."%' ".sprintf($this->_like_escape_str, $this->_like_escape_chr);
}
return $sql;
}
// --------------------------------------------------------------------
/**
* Show column query
*
* Generates a platform-specific query string so that the column names can be fetched
*
* @access protected
* @param string the table name
* @return string
*/
protected function _list_columns($table = '')
{
return "SELECT COLUMN_NAME FROM all_tab_columns WHERE table_name = '$table'";
}
// --------------------------------------------------------------------
/**
* Field data query
*
* Generates a platform-specific query so that the column data can be retrieved
*
* @access public
* @param string the table name
* @return object
*/
protected function _field_data($table)
{
return "SELECT * FROM ".$table." where rownum = 1";
}
// --------------------------------------------------------------------
/**
* The error message string
*
* @access protected
* @return string
*/
protected function _error_message()
{
// If the error was during connection, no conn_id should be passed
$error = is_resource($this->conn_id) ? oci_error($this->conn_id) : oci_error();
return $error['message'];
}
// --------------------------------------------------------------------
/**
* The error message number
*
* @access protected
* @return integer
*/
protected function _error_number()
{
// Same as _error_message()
$error = is_resource($this->conn_id) ? oci_error($this->conn_id) : oci_error();
return $error['code'];
}
// --------------------------------------------------------------------
/**
* Escape the SQL Identifiers
*
* This function escapes column and table names
*
* @access protected
* @param string
* @return string
*/
protected function _escape_identifiers($item)
{
if ($this->_escape_char == '')
{
return $item;
}
foreach ($this->_reserved_identifiers as $id)
{
if (strpos($item, '.'.$id) !== FALSE)
{
$str = $this->_escape_char. str_replace('.', $this->_escape_char.'.', $item);
// remove duplicates if the user already included the escape
return preg_replace('/['.$this->_escape_char.']+/', $this->_escape_char, $str);
}
}
if (strpos($item, '.') !== FALSE)
{
$str = $this->_escape_char.str_replace('.', $this->_escape_char.'.'.$this->_escape_char, $item).$this->_escape_char;
}
else
{
$str = $this->_escape_char.$item.$this->_escape_char;
}
// remove duplicates if the user already included the escape
return preg_replace('/['.$this->_escape_char.']+/', $this->_escape_char, $str);
}
// --------------------------------------------------------------------
/**
* From Tables
*
* This function implicitly groups FROM tables so there is no confusion
* about operator precedence in harmony with SQL standards
*
* @access protected
* @param type
* @return type
*/
protected function _from_tables($tables)
{
if ( ! is_array($tables))
{
$tables = array($tables);
}
return implode(', ', $tables);
}
// --------------------------------------------------------------------
/**
* Insert statement
*
* Generates a platform-specific insert string from the supplied data
*
* @access public
* @param string the table name
* @param array the insert keys
* @param array the insert values
* @return string
*/
protected function _insert($table, $keys, $values)
{
return "INSERT INTO ".$table." (".implode(', ', $keys).") VALUES (".implode(', ', $values).")";
}
// --------------------------------------------------------------------
/**
* Insert_batch statement
*
* Generates a platform-specific insert string from the supplied data
*
* @access protected
* @param string the table name
* @param array the insert keys
* @param array the insert values
* @return string
*/
protected function _insert_batch($table, $keys, $values)
{
$keys = implode(', ', $keys);
$sql = "INSERT ALL\n";
for ($i = 0, $c = count($values); $i < $c; $i++)
{
$sql .= ' INTO ' . $table . ' (' . $keys . ') VALUES ' . $values[$i] . "\n";
}
$sql .= 'SELECT * FROM dual';
return $sql;
}
// --------------------------------------------------------------------
/**
* Update statement
*
* Generates a platform-specific update string from the supplied data
*
* @access protected
* @param string the table name
* @param array the update data
* @param array the where clause
* @param array the orderby clause
* @param array the limit clause
* @return string
*/
protected function _update($table, $values, $where, $orderby = array(), $limit = FALSE)
{
foreach ($values as $key => $val)
{
$valstr[] = $key." = ".$val;
}
$limit = ( ! $limit) ? '' : ' LIMIT '.$limit;
$orderby = (count($orderby) >= 1)?' ORDER BY '.implode(", ", $orderby):'';
$sql = "UPDATE ".$table." SET ".implode(', ', $valstr);
$sql .= ($where != '' AND count($where) >=1) ? " WHERE ".implode(" ", $where) : '';
$sql .= $orderby.$limit;
return $sql;
}
// --------------------------------------------------------------------
/**
* Truncate statement
*
* Generates a platform-specific truncate string from the supplied data
* If the database does not support the truncate() command
* This function maps to "DELETE FROM table"
*
* @access protected
* @param string the table name
* @return string
*/
protected function _truncate($table)
{
return "TRUNCATE TABLE ".$table;
}
// --------------------------------------------------------------------
/**
* Delete statement
*
* Generates a platform-specific delete string from the supplied data
*
* @access protected
* @param string the table name
* @param array the where clause
* @param string the limit clause
* @return string
*/
protected function _delete($table, $where = array(), $like = array(), $limit = FALSE)
{
$conditions = '';
if (count($where) > 0 OR count($like) > 0)
{
$conditions = "\nWHERE ";
$conditions .= implode("\n", $this->ar_where);
if (count($where) > 0 && count($like) > 0)
{
$conditions .= " AND ";
}
$conditions .= implode("\n", $like);
}
$limit = ( ! $limit) ? '' : ' LIMIT '.$limit;
return "DELETE FROM ".$table.$conditions.$limit;
}
// --------------------------------------------------------------------
/**
* Limit string
*
* Generates a platform-specific LIMIT clause
*
* @access protected
* @param string the sql query string
* @param integer the number of rows to limit the query to
* @param integer the offset value
* @return string
*/
protected function _limit($sql, $limit, $offset)
{
$limit = $offset + $limit;
$newsql = "SELECT * FROM (select inner_query.*, rownum rnum FROM ($sql) inner_query WHERE rownum < $limit)";
if ($offset != 0)
{
$newsql .= " WHERE rnum >= $offset";
}
// remember that we used limits
$this->limit_used = TRUE;
return $newsql;
}
// --------------------------------------------------------------------
/**
* Close DB Connection
*
* @access protected
* @param resource
* @return void
*/
protected function _close($conn_id)
{
@oci_close($conn_id);
}
}
/* End of file oci8_driver.php */
/* Location: ./system/database/drivers/oci8/oci8_driver.php */
| php | MIT | 152cd2d808675d2baeb9e77c229adfbaf9a16475 | 2026-01-05T05:21:15.334872Z | false |
MobilityLab/TransitScreen | https://github.com/MobilityLab/TransitScreen/blob/152cd2d808675d2baeb9e77c229adfbaf9a16475/system/database/drivers/oci8/oci8_utility.php | system/database/drivers/oci8/oci8_utility.php | <?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
/**
* CodeIgniter
*
* An open source application development framework for PHP 5.1.6 or newer
*
* @package CodeIgniter
* @author ExpressionEngine Dev Team
* @copyright Copyright (c) 2008 - 2011, EllisLab, Inc.
* @license http://codeigniter.com/user_guide/license.html
* @link http://codeigniter.com
* @since Version 1.0
* @filesource
*/
// ------------------------------------------------------------------------
/**
* Oracle Utility Class
*
* @category Database
* @author ExpressionEngine Dev Team
* @link http://codeigniter.com/user_guide/database/
*/
class CI_DB_oci8_utility extends CI_DB_utility {
/**
* List databases
*
* @access private
* @return bool
*/
function _list_databases()
{
return FALSE;
}
// --------------------------------------------------------------------
/**
* Optimize table query
*
* Generates a platform-specific query so that a table can be optimized
*
* @access private
* @param string the table name
* @return object
*/
function _optimize_table($table)
{
return FALSE; // Is this supported in Oracle?
}
// --------------------------------------------------------------------
/**
* Repair table query
*
* Generates a platform-specific query so that a table can be repaired
*
* @access private
* @param string the table name
* @return object
*/
function _repair_table($table)
{
return FALSE; // Is this supported in Oracle?
}
// --------------------------------------------------------------------
/**
* Oracle Export
*
* @access private
* @param array Preferences
* @return mixed
*/
function _backup($params = array())
{
// Currently unsupported
return $this->db->display_error('db_unsuported_feature');
}
}
/* End of file oci8_utility.php */
/* Location: ./system/database/drivers/oci8/oci8_utility.php */ | php | MIT | 152cd2d808675d2baeb9e77c229adfbaf9a16475 | 2026-01-05T05:21:15.334872Z | false |
MobilityLab/TransitScreen | https://github.com/MobilityLab/TransitScreen/blob/152cd2d808675d2baeb9e77c229adfbaf9a16475/system/database/drivers/postgre/postgre_driver.php | system/database/drivers/postgre/postgre_driver.php | <?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
/**
* CodeIgniter
*
* An open source application development framework for PHP 5.1.6 or newer
*
* @package CodeIgniter
* @author ExpressionEngine Dev Team
* @copyright Copyright (c) 2008 - 2011, EllisLab, Inc.
* @license http://codeigniter.com/user_guide/license.html
* @link http://codeigniter.com
* @since Version 1.0
* @filesource
*/
// ------------------------------------------------------------------------
/**
* Postgre Database Adapter Class
*
* Note: _DB is an extender class that the app controller
* creates dynamically based on whether the active record
* class is being used or not.
*
* @package CodeIgniter
* @subpackage Drivers
* @category Database
* @author ExpressionEngine Dev Team
* @link http://codeigniter.com/user_guide/database/
*/
class CI_DB_postgre_driver extends CI_DB {
var $dbdriver = 'postgre';
var $_escape_char = '"';
// clause and character used for LIKE escape sequences
var $_like_escape_str = " ESCAPE '%s' ";
var $_like_escape_chr = '!';
/**
* The syntax to count rows is slightly different across different
* database engines, so this string appears in each driver and is
* used for the count_all() and count_all_results() functions.
*/
var $_count_string = "SELECT COUNT(*) AS ";
var $_random_keyword = ' RANDOM()'; // database specific random keyword
/**
* Connection String
*
* @access private
* @return string
*/
function _connect_string()
{
$components = array(
'hostname' => 'host',
'port' => 'port',
'database' => 'dbname',
'username' => 'user',
'password' => 'password'
);
$connect_string = "";
foreach ($components as $key => $val)
{
if (isset($this->$key) && $this->$key != '')
{
$connect_string .= " $val=".$this->$key;
}
}
return trim($connect_string);
}
// --------------------------------------------------------------------
/**
* Non-persistent database connection
*
* @access private called by the base class
* @return resource
*/
function db_connect()
{
return @pg_connect($this->_connect_string());
}
// --------------------------------------------------------------------
/**
* Persistent database connection
*
* @access private called by the base class
* @return resource
*/
function db_pconnect()
{
return @pg_pconnect($this->_connect_string());
}
// --------------------------------------------------------------------
/**
* Reconnect
*
* Keep / reestablish the db connection if no queries have been
* sent for a length of time exceeding the server's idle timeout
*
* @access public
* @return void
*/
function reconnect()
{
if (pg_ping($this->conn_id) === FALSE)
{
$this->conn_id = FALSE;
}
}
// --------------------------------------------------------------------
/**
* Select the database
*
* @access private called by the base class
* @return resource
*/
function db_select()
{
// Not needed for Postgre so we'll return TRUE
return TRUE;
}
// --------------------------------------------------------------------
/**
* Set client character set
*
* @access public
* @param string
* @param string
* @return resource
*/
function db_set_charset($charset, $collation)
{
// @todo - add support if needed
return TRUE;
}
// --------------------------------------------------------------------
/**
* Version number query string
*
* @access public
* @return string
*/
function _version()
{
return "SELECT version() AS ver";
}
// --------------------------------------------------------------------
/**
* Execute the query
*
* @access private called by the base class
* @param string an SQL query
* @return resource
*/
function _execute($sql)
{
$sql = $this->_prep_query($sql);
return @pg_query($this->conn_id, $sql);
}
// --------------------------------------------------------------------
/**
* Prep the query
*
* If needed, each database adapter can prep the query string
*
* @access private called by execute()
* @param string an SQL query
* @return string
*/
function _prep_query($sql)
{
return $sql;
}
// --------------------------------------------------------------------
/**
* Begin Transaction
*
* @access public
* @return bool
*/
function trans_begin($test_mode = FALSE)
{
if ( ! $this->trans_enabled)
{
return TRUE;
}
// When transactions are nested we only begin/commit/rollback the outermost ones
if ($this->_trans_depth > 0)
{
return TRUE;
}
// Reset the transaction failure flag.
// If the $test_mode flag is set to TRUE transactions will be rolled back
// even if the queries produce a successful result.
$this->_trans_failure = ($test_mode === TRUE) ? TRUE : FALSE;
return @pg_exec($this->conn_id, "begin");
}
// --------------------------------------------------------------------
/**
* Commit Transaction
*
* @access public
* @return bool
*/
function trans_commit()
{
if ( ! $this->trans_enabled)
{
return TRUE;
}
// When transactions are nested we only begin/commit/rollback the outermost ones
if ($this->_trans_depth > 0)
{
return TRUE;
}
return @pg_exec($this->conn_id, "commit");
}
// --------------------------------------------------------------------
/**
* Rollback Transaction
*
* @access public
* @return bool
*/
function trans_rollback()
{
if ( ! $this->trans_enabled)
{
return TRUE;
}
// When transactions are nested we only begin/commit/rollback the outermost ones
if ($this->_trans_depth > 0)
{
return TRUE;
}
return @pg_exec($this->conn_id, "rollback");
}
// --------------------------------------------------------------------
/**
* Escape String
*
* @access public
* @param string
* @param bool whether or not the string will be used in a LIKE condition
* @return string
*/
function escape_str($str, $like = FALSE)
{
if (is_array($str))
{
foreach ($str as $key => $val)
{
$str[$key] = $this->escape_str($val, $like);
}
return $str;
}
$str = pg_escape_string($str);
// escape LIKE condition wildcards
if ($like === TRUE)
{
$str = str_replace( array('%', '_', $this->_like_escape_chr),
array($this->_like_escape_chr.'%', $this->_like_escape_chr.'_', $this->_like_escape_chr.$this->_like_escape_chr),
$str);
}
return $str;
}
// --------------------------------------------------------------------
/**
* Affected Rows
*
* @access public
* @return integer
*/
function affected_rows()
{
return @pg_affected_rows($this->result_id);
}
// --------------------------------------------------------------------
/**
* Insert ID
*
* @access public
* @return integer
*/
function insert_id()
{
$v = $this->_version();
$v = $v['server'];
$table = func_num_args() > 0 ? func_get_arg(0) : NULL;
$column = func_num_args() > 1 ? func_get_arg(1) : NULL;
if ($table == NULL && $v >= '8.1')
{
$sql='SELECT LASTVAL() as ins_id';
}
elseif ($table != NULL && $column != NULL && $v >= '8.0')
{
$sql = sprintf("SELECT pg_get_serial_sequence('%s','%s') as seq", $table, $column);
$query = $this->query($sql);
$row = $query->row();
$sql = sprintf("SELECT CURRVAL('%s') as ins_id", $row->seq);
}
elseif ($table != NULL)
{
// seq_name passed in table parameter
$sql = sprintf("SELECT CURRVAL('%s') as ins_id", $table);
}
else
{
return pg_last_oid($this->result_id);
}
$query = $this->query($sql);
$row = $query->row();
return $row->ins_id;
}
// --------------------------------------------------------------------
/**
* "Count All" query
*
* Generates a platform-specific query string that counts all records in
* the specified database
*
* @access public
* @param string
* @return string
*/
function count_all($table = '')
{
if ($table == '')
{
return 0;
}
$query = $this->query($this->_count_string . $this->_protect_identifiers('numrows') . " FROM " . $this->_protect_identifiers($table, TRUE, NULL, FALSE));
if ($query->num_rows() == 0)
{
return 0;
}
$row = $query->row();
$this->_reset_select();
return (int) $row->numrows;
}
// --------------------------------------------------------------------
/**
* Show table query
*
* Generates a platform-specific query string so that the table names can be fetched
*
* @access private
* @param boolean
* @return string
*/
function _list_tables($prefix_limit = FALSE)
{
$sql = "SELECT table_name FROM information_schema.tables WHERE table_schema = 'public'";
if ($prefix_limit !== FALSE AND $this->dbprefix != '')
{
$sql .= " AND table_name LIKE '".$this->escape_like_str($this->dbprefix)."%' ".sprintf($this->_like_escape_str, $this->_like_escape_chr);
}
return $sql;
}
// --------------------------------------------------------------------
/**
* Show column query
*
* Generates a platform-specific query string so that the column names can be fetched
*
* @access public
* @param string the table name
* @return string
*/
function _list_columns($table = '')
{
return "SELECT column_name FROM information_schema.columns WHERE table_name ='".$table."'";
}
// --------------------------------------------------------------------
/**
* Field data query
*
* Generates a platform-specific query so that the column data can be retrieved
*
* @access public
* @param string the table name
* @return object
*/
function _field_data($table)
{
return "SELECT * FROM ".$table." LIMIT 1";
}
// --------------------------------------------------------------------
/**
* The error message string
*
* @access private
* @return string
*/
function _error_message()
{
return pg_last_error($this->conn_id);
}
// --------------------------------------------------------------------
/**
* The error message number
*
* @access private
* @return integer
*/
function _error_number()
{
return '';
}
// --------------------------------------------------------------------
/**
* Escape the SQL Identifiers
*
* This function escapes column and table names
*
* @access private
* @param string
* @return string
*/
function _escape_identifiers($item)
{
if ($this->_escape_char == '')
{
return $item;
}
foreach ($this->_reserved_identifiers as $id)
{
if (strpos($item, '.'.$id) !== FALSE)
{
$str = $this->_escape_char. str_replace('.', $this->_escape_char.'.', $item);
// remove duplicates if the user already included the escape
return preg_replace('/['.$this->_escape_char.']+/', $this->_escape_char, $str);
}
}
if (strpos($item, '.') !== FALSE)
{
$str = $this->_escape_char.str_replace('.', $this->_escape_char.'.'.$this->_escape_char, $item).$this->_escape_char;
}
else
{
$str = $this->_escape_char.$item.$this->_escape_char;
}
// remove duplicates if the user already included the escape
return preg_replace('/['.$this->_escape_char.']+/', $this->_escape_char, $str);
}
// --------------------------------------------------------------------
/**
* From Tables
*
* This function implicitly groups FROM tables so there is no confusion
* about operator precedence in harmony with SQL standards
*
* @access public
* @param type
* @return type
*/
function _from_tables($tables)
{
if ( ! is_array($tables))
{
$tables = array($tables);
}
return implode(', ', $tables);
}
// --------------------------------------------------------------------
/**
* Insert statement
*
* Generates a platform-specific insert string from the supplied data
*
* @access public
* @param string the table name
* @param array the insert keys
* @param array the insert values
* @return string
*/
function _insert($table, $keys, $values)
{
return "INSERT INTO ".$table." (".implode(', ', $keys).") VALUES (".implode(', ', $values).")";
}
// --------------------------------------------------------------------
/**
* Insert_batch statement
*
* Generates a platform-specific insert string from the supplied data
*
* @access public
* @param string the table name
* @param array the insert keys
* @param array the insert values
* @return string
*/
function _insert_batch($table, $keys, $values)
{
return "INSERT INTO ".$table." (".implode(', ', $keys).") VALUES ".implode(', ', $values);
}
// --------------------------------------------------------------------
/**
* Update statement
*
* Generates a platform-specific update string from the supplied data
*
* @access public
* @param string the table name
* @param array the update data
* @param array the where clause
* @param array the orderby clause
* @param array the limit clause
* @return string
*/
function _update($table, $values, $where, $orderby = array(), $limit = FALSE)
{
foreach ($values as $key => $val)
{
$valstr[] = $key." = ".$val;
}
$limit = ( ! $limit) ? '' : ' LIMIT '.$limit;
$orderby = (count($orderby) >= 1)?' ORDER BY '.implode(", ", $orderby):'';
$sql = "UPDATE ".$table." SET ".implode(', ', $valstr);
$sql .= ($where != '' AND count($where) >=1) ? " WHERE ".implode(" ", $where) : '';
$sql .= $orderby.$limit;
return $sql;
}
// --------------------------------------------------------------------
/**
* Truncate statement
*
* Generates a platform-specific truncate string from the supplied data
* If the database does not support the truncate() command
* This function maps to "DELETE FROM table"
*
* @access public
* @param string the table name
* @return string
*/
function _truncate($table)
{
return "TRUNCATE ".$table;
}
// --------------------------------------------------------------------
/**
* Delete statement
*
* Generates a platform-specific delete string from the supplied data
*
* @access public
* @param string the table name
* @param array the where clause
* @param string the limit clause
* @return string
*/
function _delete($table, $where = array(), $like = array(), $limit = FALSE)
{
$conditions = '';
if (count($where) > 0 OR count($like) > 0)
{
$conditions = "\nWHERE ";
$conditions .= implode("\n", $this->ar_where);
if (count($where) > 0 && count($like) > 0)
{
$conditions .= " AND ";
}
$conditions .= implode("\n", $like);
}
$limit = ( ! $limit) ? '' : ' LIMIT '.$limit;
return "DELETE FROM ".$table.$conditions.$limit;
}
// --------------------------------------------------------------------
/**
* Limit string
*
* Generates a platform-specific LIMIT clause
*
* @access public
* @param string the sql query string
* @param integer the number of rows to limit the query to
* @param integer the offset value
* @return string
*/
function _limit($sql, $limit, $offset)
{
$sql .= "LIMIT ".$limit;
if ($offset > 0)
{
$sql .= " OFFSET ".$offset;
}
return $sql;
}
// --------------------------------------------------------------------
/**
* Close DB Connection
*
* @access public
* @param resource
* @return void
*/
function _close($conn_id)
{
@pg_close($conn_id);
}
}
/* End of file postgre_driver.php */
/* Location: ./system/database/drivers/postgre/postgre_driver.php */ | php | MIT | 152cd2d808675d2baeb9e77c229adfbaf9a16475 | 2026-01-05T05:21:15.334872Z | false |
MobilityLab/TransitScreen | https://github.com/MobilityLab/TransitScreen/blob/152cd2d808675d2baeb9e77c229adfbaf9a16475/system/database/drivers/postgre/postgre_result.php | system/database/drivers/postgre/postgre_result.php | <?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
/**
* CodeIgniter
*
* An open source application development framework for PHP 5.1.6 or newer
*
* @package CodeIgniter
* @author ExpressionEngine Dev Team
* @copyright Copyright (c) 2008 - 2011, EllisLab, Inc.
* @license http://codeigniter.com/user_guide/license.html
* @link http://codeigniter.com
* @since Version 1.0
* @filesource
*/
// ------------------------------------------------------------------------
/**
* Postgres Result Class
*
* This class extends the parent result class: CI_DB_result
*
* @category Database
* @author ExpressionEngine Dev Team
* @link http://codeigniter.com/user_guide/database/
*/
class CI_DB_postgre_result extends CI_DB_result {
/**
* Number of rows in the result set
*
* @access public
* @return integer
*/
function num_rows()
{
return @pg_num_rows($this->result_id);
}
// --------------------------------------------------------------------
/**
* Number of fields in the result set
*
* @access public
* @return integer
*/
function num_fields()
{
return @pg_num_fields($this->result_id);
}
// --------------------------------------------------------------------
/**
* Fetch Field Names
*
* Generates an array of column names
*
* @access public
* @return array
*/
function list_fields()
{
$field_names = array();
for ($i = 0; $i < $this->num_fields(); $i++)
{
$field_names[] = pg_field_name($this->result_id, $i);
}
return $field_names;
}
// --------------------------------------------------------------------
/**
* Field data
*
* Generates an array of objects containing field meta-data
*
* @access public
* @return array
*/
function field_data()
{
$retval = array();
for ($i = 0; $i < $this->num_fields(); $i++)
{
$F = new stdClass();
$F->name = pg_field_name($this->result_id, $i);
$F->type = pg_field_type($this->result_id, $i);
$F->max_length = pg_field_size($this->result_id, $i);
$F->primary_key = 0;
$F->default = '';
$retval[] = $F;
}
return $retval;
}
// --------------------------------------------------------------------
/**
* Free the result
*
* @return null
*/
function free_result()
{
if (is_resource($this->result_id))
{
pg_free_result($this->result_id);
$this->result_id = FALSE;
}
}
// --------------------------------------------------------------------
/**
* Data Seek
*
* Moves the internal pointer to the desired offset. We call
* this internally before fetching results to make sure the
* result set starts at zero
*
* @access private
* @return array
*/
function _data_seek($n = 0)
{
return pg_result_seek($this->result_id, $n);
}
// --------------------------------------------------------------------
/**
* Result - associative array
*
* Returns the result set as an array
*
* @access private
* @return array
*/
function _fetch_assoc()
{
return pg_fetch_assoc($this->result_id);
}
// --------------------------------------------------------------------
/**
* Result - object
*
* Returns the result set as an object
*
* @access private
* @return object
*/
function _fetch_object()
{
return pg_fetch_object($this->result_id);
}
}
/* End of file postgre_result.php */
/* Location: ./system/database/drivers/postgre/postgre_result.php */ | php | MIT | 152cd2d808675d2baeb9e77c229adfbaf9a16475 | 2026-01-05T05:21:15.334872Z | false |
MobilityLab/TransitScreen | https://github.com/MobilityLab/TransitScreen/blob/152cd2d808675d2baeb9e77c229adfbaf9a16475/system/database/drivers/postgre/postgre_utility.php | system/database/drivers/postgre/postgre_utility.php | <?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
/**
* CodeIgniter
*
* An open source application development framework for PHP 5.1.6 or newer
*
* @package CodeIgniter
* @author ExpressionEngine Dev Team
* @copyright Copyright (c) 2008 - 2011, EllisLab, Inc.
* @license http://codeigniter.com/user_guide/license.html
* @link http://codeigniter.com
* @since Version 1.0
* @filesource
*/
// ------------------------------------------------------------------------
/**
* Postgre Utility Class
*
* @category Database
* @author ExpressionEngine Dev Team
* @link http://codeigniter.com/user_guide/database/
*/
class CI_DB_postgre_utility extends CI_DB_utility {
/**
* List databases
*
* @access private
* @return bool
*/
function _list_databases()
{
return "SELECT datname FROM pg_database";
}
// --------------------------------------------------------------------
/**
* Optimize table query
*
* Is table optimization supported in Postgre?
*
* @access private
* @param string the table name
* @return object
*/
function _optimize_table($table)
{
return FALSE;
}
// --------------------------------------------------------------------
/**
* Repair table query
*
* Are table repairs supported in Postgre?
*
* @access private
* @param string the table name
* @return object
*/
function _repair_table($table)
{
return FALSE;
}
// --------------------------------------------------------------------
/**
* Postgre Export
*
* @access private
* @param array Preferences
* @return mixed
*/
function _backup($params = array())
{
// Currently unsupported
return $this->db->display_error('db_unsuported_feature');
}
}
/* End of file postgre_utility.php */
/* Location: ./system/database/drivers/postgre/postgre_utility.php */ | php | MIT | 152cd2d808675d2baeb9e77c229adfbaf9a16475 | 2026-01-05T05:21:15.334872Z | false |
MobilityLab/TransitScreen | https://github.com/MobilityLab/TransitScreen/blob/152cd2d808675d2baeb9e77c229adfbaf9a16475/system/database/drivers/postgre/postgre_forge.php | system/database/drivers/postgre/postgre_forge.php | <?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
/**
* CodeIgniter
*
* An open source application development framework for PHP 5.1.6 or newer
*
* @package CodeIgniter
* @author ExpressionEngine Dev Team
* @copyright Copyright (c) 2008 - 2011, EllisLab, Inc.
* @license http://codeigniter.com/user_guide/license.html
* @link http://codeigniter.com
* @since Version 1.0
* @filesource
*/
// ------------------------------------------------------------------------
/**
* Postgre Forge Class
*
* @category Database
* @author ExpressionEngine Dev Team
* @link http://codeigniter.com/user_guide/database/
*/
class CI_DB_postgre_forge extends CI_DB_forge {
/**
* Create database
*
* @access private
* @param string the database name
* @return bool
*/
function _create_database($name)
{
return "CREATE DATABASE ".$name;
}
// --------------------------------------------------------------------
/**
* Drop database
*
* @access private
* @param string the database name
* @return bool
*/
function _drop_database($name)
{
return "DROP DATABASE ".$name;
}
// --------------------------------------------------------------------
/**
* Create Table
*
* @access private
* @param string the table name
* @param array the fields
* @param mixed primary key(s)
* @param mixed key(s)
* @param boolean should 'IF NOT EXISTS' be added to the SQL
* @return bool
*/
function _create_table($table, $fields, $primary_keys, $keys, $if_not_exists)
{
$sql = 'CREATE TABLE ';
if ($if_not_exists === TRUE)
{
if ($this->db->table_exists($table))
{
return "SELECT * FROM $table"; // Needs to return innocous but valid SQL statement
}
}
$sql .= $this->db->_escape_identifiers($table)." (";
$current_field_count = 0;
foreach ($fields as $field=>$attributes)
{
// Numeric field names aren't allowed in databases, so if the key is
// numeric, we know it was assigned by PHP and the developer manually
// entered the field information, so we'll simply add it to the list
if (is_numeric($field))
{
$sql .= "\n\t$attributes";
}
else
{
$attributes = array_change_key_case($attributes, CASE_UPPER);
$sql .= "\n\t".$this->db->_protect_identifiers($field);
$is_unsigned = (array_key_exists('UNSIGNED', $attributes) && $attributes['UNSIGNED'] === TRUE);
// Convert datatypes to be PostgreSQL-compatible
switch (strtoupper($attributes['TYPE']))
{
case 'TINYINT':
$attributes['TYPE'] = 'SMALLINT';
break;
case 'SMALLINT':
$attributes['TYPE'] = ($is_unsigned) ? 'INTEGER' : 'SMALLINT';
break;
case 'MEDIUMINT':
$attributes['TYPE'] = 'INTEGER';
break;
case 'INT':
$attributes['TYPE'] = ($is_unsigned) ? 'BIGINT' : 'INTEGER';
break;
case 'BIGINT':
$attributes['TYPE'] = ($is_unsigned) ? 'NUMERIC' : 'BIGINT';
break;
case 'DOUBLE':
$attributes['TYPE'] = 'DOUBLE PRECISION';
break;
case 'DATETIME':
$attributes['TYPE'] = 'TIMESTAMP';
break;
case 'LONGTEXT':
$attributes['TYPE'] = 'TEXT';
break;
case 'BLOB':
$attributes['TYPE'] = 'BYTEA';
break;
}
// If this is an auto-incrementing primary key, use the serial data type instead
if (in_array($field, $primary_keys) && array_key_exists('AUTO_INCREMENT', $attributes)
&& $attributes['AUTO_INCREMENT'] === TRUE)
{
$sql .= ' SERIAL';
}
else
{
$sql .= ' '.$attributes['TYPE'];
}
// Modified to prevent constraints with integer data types
if (array_key_exists('CONSTRAINT', $attributes) && strpos($attributes['TYPE'], 'INT') === false)
{
$sql .= '('.$attributes['CONSTRAINT'].')';
}
if (array_key_exists('DEFAULT', $attributes))
{
$sql .= ' DEFAULT \''.$attributes['DEFAULT'].'\'';
}
if (array_key_exists('NULL', $attributes) && $attributes['NULL'] === TRUE)
{
$sql .= ' NULL';
}
else
{
$sql .= ' NOT NULL';
}
// Added new attribute to create unqite fields. Also works with MySQL
if (array_key_exists('UNIQUE', $attributes) && $attributes['UNIQUE'] === TRUE)
{
$sql .= ' UNIQUE';
}
}
// don't add a comma on the end of the last field
if (++$current_field_count < count($fields))
{
$sql .= ',';
}
}
if (count($primary_keys) > 0)
{
// Something seems to break when passing an array to _protect_identifiers()
foreach ($primary_keys as $index => $key)
{
$primary_keys[$index] = $this->db->_protect_identifiers($key);
}
$sql .= ",\n\tPRIMARY KEY (" . implode(', ', $primary_keys) . ")";
}
$sql .= "\n);";
if (is_array($keys) && count($keys) > 0)
{
foreach ($keys as $key)
{
if (is_array($key))
{
$key = $this->db->_protect_identifiers($key);
}
else
{
$key = array($this->db->_protect_identifiers($key));
}
foreach ($key as $field)
{
$sql .= "CREATE INDEX " . $table . "_" . str_replace(array('"', "'"), '', $field) . "_index ON $table ($field); ";
}
}
}
return $sql;
}
// --------------------------------------------------------------------
/**
* Drop Table
*
* @access private
* @return bool
*/
function _drop_table($table)
{
return "DROP TABLE IF EXISTS ".$this->db->_escape_identifiers($table)." CASCADE";
}
// --------------------------------------------------------------------
/**
* Alter table query
*
* Generates a platform-specific query so that a table can be altered
* Called by add_column(), drop_column(), and column_alter(),
*
* @access private
* @param string the ALTER type (ADD, DROP, CHANGE)
* @param string the column name
* @param string the table name
* @param string the column definition
* @param string the default value
* @param boolean should 'NOT NULL' be added
* @param string the field after which we should add the new field
* @return object
*/
function _alter_table($alter_type, $table, $column_name, $column_definition = '', $default_value = '', $null = '', $after_field = '')
{
$sql = 'ALTER TABLE '.$this->db->_protect_identifiers($table)." $alter_type ".$this->db->_protect_identifiers($column_name);
// DROP has everything it needs now.
if ($alter_type == 'DROP')
{
return $sql;
}
$sql .= " $column_definition";
if ($default_value != '')
{
$sql .= " DEFAULT \"$default_value\"";
}
if ($null === NULL)
{
$sql .= ' NULL';
}
else
{
$sql .= ' NOT NULL';
}
if ($after_field != '')
{
$sql .= ' AFTER ' . $this->db->_protect_identifiers($after_field);
}
return $sql;
}
// --------------------------------------------------------------------
/**
* Rename a table
*
* Generates a platform-specific query so that a table can be renamed
*
* @access private
* @param string the old table name
* @param string the new table name
* @return string
*/
function _rename_table($table_name, $new_table_name)
{
$sql = 'ALTER TABLE '.$this->db->_protect_identifiers($table_name)." RENAME TO ".$this->db->_protect_identifiers($new_table_name);
return $sql;
}
}
/* End of file postgre_forge.php */
/* Location: ./system/database/drivers/postgre/postgre_forge.php */ | php | MIT | 152cd2d808675d2baeb9e77c229adfbaf9a16475 | 2026-01-05T05:21:15.334872Z | false |
MobilityLab/TransitScreen | https://github.com/MobilityLab/TransitScreen/blob/152cd2d808675d2baeb9e77c229adfbaf9a16475/system/language/english/migration_lang.php | system/language/english/migration_lang.php | <?php
$lang['migration_none_found'] = "No migrations were found.";
$lang['migration_not_found'] = "This migration could not be found.";
$lang['migration_multiple_version'] = "This are multiple migrations with the same version number: %d.";
$lang['migration_class_doesnt_exist'] = "The migration class \"%s\" could not be found.";
$lang['migration_missing_up_method'] = "The migration class \"%s\" is missing an 'up' method.";
$lang['migration_missing_down_method'] = "The migration class \"%s\" is missing an 'up' method.";
$lang['migration_invalid_filename'] = "Migration \"%s\" has an invalid filename.";
/* End of file migration_lang.php */
/* Location: ./system/language/english/migration_lang.php */ | php | MIT | 152cd2d808675d2baeb9e77c229adfbaf9a16475 | 2026-01-05T05:21:15.334872Z | false |
MobilityLab/TransitScreen | https://github.com/MobilityLab/TransitScreen/blob/152cd2d808675d2baeb9e77c229adfbaf9a16475/system/language/english/profiler_lang.php | system/language/english/profiler_lang.php | <?php
$lang['profiler_database'] = 'DATABASE';
$lang['profiler_controller_info'] = 'CLASS/METHOD';
$lang['profiler_benchmarks'] = 'BENCHMARKS';
$lang['profiler_queries'] = 'QUERIES';
$lang['profiler_get_data'] = 'GET DATA';
$lang['profiler_post_data'] = 'POST DATA';
$lang['profiler_uri_string'] = 'URI STRING';
$lang['profiler_memory_usage'] = 'MEMORY USAGE';
$lang['profiler_config'] = 'CONFIG VARIABLES';
$lang['profiler_session_data'] = 'SESSION DATA';
$lang['profiler_headers'] = 'HTTP HEADERS';
$lang['profiler_no_db'] = 'Database driver is not currently loaded';
$lang['profiler_no_queries'] = 'No queries were run';
$lang['profiler_no_post'] = 'No POST data exists';
$lang['profiler_no_get'] = 'No GET data exists';
$lang['profiler_no_uri'] = 'No URI data exists';
$lang['profiler_no_memory'] = 'Memory Usage Unavailable';
$lang['profiler_no_profiles'] = 'No Profile data - all Profiler sections have been disabled.';
$lang['profiler_section_hide'] = 'Hide';
$lang['profiler_section_show'] = 'Show';
/* End of file profiler_lang.php */
/* Location: ./system/language/english/profiler_lang.php */ | php | MIT | 152cd2d808675d2baeb9e77c229adfbaf9a16475 | 2026-01-05T05:21:15.334872Z | false |
MobilityLab/TransitScreen | https://github.com/MobilityLab/TransitScreen/blob/152cd2d808675d2baeb9e77c229adfbaf9a16475/system/language/english/email_lang.php | system/language/english/email_lang.php | <?php
$lang['email_must_be_array'] = "The email validation method must be passed an array.";
$lang['email_invalid_address'] = "Invalid email address: %s";
$lang['email_attachment_missing'] = "Unable to locate the following email attachment: %s";
$lang['email_attachment_unreadable'] = "Unable to open this attachment: %s";
$lang['email_no_recipients'] = "You must include recipients: To, Cc, or Bcc";
$lang['email_send_failure_phpmail'] = "Unable to send email using PHP mail(). Your server might not be configured to send mail using this method.";
$lang['email_send_failure_sendmail'] = "Unable to send email using PHP Sendmail. Your server might not be configured to send mail using this method.";
$lang['email_send_failure_smtp'] = "Unable to send email using PHP SMTP. Your server might not be configured to send mail using this method.";
$lang['email_sent'] = "Your message has been successfully sent using the following protocol: %s";
$lang['email_no_socket'] = "Unable to open a socket to Sendmail. Please check settings.";
$lang['email_no_hostname'] = "You did not specify a SMTP hostname.";
$lang['email_smtp_error'] = "The following SMTP error was encountered: %s";
$lang['email_no_smtp_unpw'] = "Error: You must assign a SMTP username and password.";
$lang['email_failed_smtp_login'] = "Failed to send AUTH LOGIN command. Error: %s";
$lang['email_smtp_auth_un'] = "Failed to authenticate username. Error: %s";
$lang['email_smtp_auth_pw'] = "Failed to authenticate password. Error: %s";
$lang['email_smtp_data_failure'] = "Unable to send data: %s";
$lang['email_exit_status'] = "Exit status code: %s";
/* End of file email_lang.php */
/* Location: ./system/language/english/email_lang.php */ | php | MIT | 152cd2d808675d2baeb9e77c229adfbaf9a16475 | 2026-01-05T05:21:15.334872Z | false |
MobilityLab/TransitScreen | https://github.com/MobilityLab/TransitScreen/blob/152cd2d808675d2baeb9e77c229adfbaf9a16475/system/language/english/imglib_lang.php | system/language/english/imglib_lang.php | <?php
$lang['imglib_source_image_required'] = "You must specify a source image in your preferences.";
$lang['imglib_gd_required'] = "The GD image library is required for this feature.";
$lang['imglib_gd_required_for_props'] = "Your server must support the GD image library in order to determine the image properties.";
$lang['imglib_unsupported_imagecreate'] = "Your server does not support the GD function required to process this type of image.";
$lang['imglib_gif_not_supported'] = "GIF images are often not supported due to licensing restrictions. You may have to use JPG or PNG images instead.";
$lang['imglib_jpg_not_supported'] = "JPG images are not supported.";
$lang['imglib_png_not_supported'] = "PNG images are not supported.";
$lang['imglib_jpg_or_png_required'] = "The image resize protocol specified in your preferences only works with JPEG or PNG image types.";
$lang['imglib_copy_error'] = "An error was encountered while attempting to replace the file. Please make sure your file directory is writable.";
$lang['imglib_rotate_unsupported'] = "Image rotation does not appear to be supported by your server.";
$lang['imglib_libpath_invalid'] = "The path to your image library is not correct. Please set the correct path in your image preferences.";
$lang['imglib_image_process_failed'] = "Image processing failed. Please verify that your server supports the chosen protocol and that the path to your image library is correct.";
$lang['imglib_rotation_angle_required'] = "An angle of rotation is required to rotate the image.";
$lang['imglib_writing_failed_gif'] = "GIF image.";
$lang['imglib_invalid_path'] = "The path to the image is not correct.";
$lang['imglib_copy_failed'] = "The image copy routine failed.";
$lang['imglib_missing_font'] = "Unable to find a font to use.";
$lang['imglib_save_failed'] = "Unable to save the image. Please make sure the image and file directory are writable.";
/* End of file imglib_lang.php */
/* Location: ./system/language/english/imglib_lang.php */ | php | MIT | 152cd2d808675d2baeb9e77c229adfbaf9a16475 | 2026-01-05T05:21:15.334872Z | false |
MobilityLab/TransitScreen | https://github.com/MobilityLab/TransitScreen/blob/152cd2d808675d2baeb9e77c229adfbaf9a16475/system/language/english/unit_test_lang.php | system/language/english/unit_test_lang.php | <?php
$lang['ut_test_name'] = 'Test Name';
$lang['ut_test_datatype'] = 'Test Datatype';
$lang['ut_res_datatype'] = 'Expected Datatype';
$lang['ut_result'] = 'Result';
$lang['ut_undefined'] = 'Undefined Test Name';
$lang['ut_file'] = 'File Name';
$lang['ut_line'] = 'Line Number';
$lang['ut_passed'] = 'Passed';
$lang['ut_failed'] = 'Failed';
$lang['ut_boolean'] = 'Boolean';
$lang['ut_integer'] = 'Integer';
$lang['ut_float'] = 'Float';
$lang['ut_double'] = 'Float'; // can be the same as float
$lang['ut_string'] = 'String';
$lang['ut_array'] = 'Array';
$lang['ut_object'] = 'Object';
$lang['ut_resource'] = 'Resource';
$lang['ut_null'] = 'Null';
$lang['ut_notes'] = 'Notes';
/* End of file unit_test_lang.php */
/* Location: ./system/language/english/unit_test_lang.php */ | php | MIT | 152cd2d808675d2baeb9e77c229adfbaf9a16475 | 2026-01-05T05:21:15.334872Z | false |
MobilityLab/TransitScreen | https://github.com/MobilityLab/TransitScreen/blob/152cd2d808675d2baeb9e77c229adfbaf9a16475/system/language/english/ftp_lang.php | system/language/english/ftp_lang.php | <?php
$lang['ftp_no_connection'] = "Unable to locate a valid connection ID. Please make sure you are connected before peforming any file routines.";
$lang['ftp_unable_to_connect'] = "Unable to connect to your FTP server using the supplied hostname.";
$lang['ftp_unable_to_login'] = "Unable to login to your FTP server. Please check your username and password.";
$lang['ftp_unable_to_makdir'] = "Unable to create the directory you have specified.";
$lang['ftp_unable_to_changedir'] = "Unable to change directories.";
$lang['ftp_unable_to_chmod'] = "Unable to set file permissions. Please check your path. Note: This feature is only available in PHP 5 or higher.";
$lang['ftp_unable_to_upload'] = "Unable to upload the specified file. Please check your path.";
$lang['ftp_unable_to_download'] = "Unable to download the specified file. Please check your path.";
$lang['ftp_no_source_file'] = "Unable to locate the source file. Please check your path.";
$lang['ftp_unable_to_rename'] = "Unable to rename the file.";
$lang['ftp_unable_to_delete'] = "Unable to delete the file.";
$lang['ftp_unable_to_move'] = "Unable to move the file. Please make sure the destination directory exists.";
/* End of file ftp_lang.php */
/* Location: ./system/language/english/ftp_lang.php */ | php | MIT | 152cd2d808675d2baeb9e77c229adfbaf9a16475 | 2026-01-05T05:21:15.334872Z | false |
MobilityLab/TransitScreen | https://github.com/MobilityLab/TransitScreen/blob/152cd2d808675d2baeb9e77c229adfbaf9a16475/system/language/english/date_lang.php | system/language/english/date_lang.php | <?php
$lang['date_year'] = "Year";
$lang['date_years'] = "Years";
$lang['date_month'] = "Month";
$lang['date_months'] = "Months";
$lang['date_week'] = "Week";
$lang['date_weeks'] = "Weeks";
$lang['date_day'] = "Day";
$lang['date_days'] = "Days";
$lang['date_hour'] = "Hour";
$lang['date_hours'] = "Hours";
$lang['date_minute'] = "Minute";
$lang['date_minutes'] = "Minutes";
$lang['date_second'] = "Second";
$lang['date_seconds'] = "Seconds";
$lang['UM12'] = '(UTC -12:00) Baker/Howland Island';
$lang['UM11'] = '(UTC -11:00) Samoa Time Zone, Niue';
$lang['UM10'] = '(UTC -10:00) Hawaii-Aleutian Standard Time, Cook Islands, Tahiti';
$lang['UM95'] = '(UTC -9:30) Marquesas Islands';
$lang['UM9'] = '(UTC -9:00) Alaska Standard Time, Gambier Islands';
$lang['UM8'] = '(UTC -8:00) Pacific Standard Time, Clipperton Island';
$lang['UM7'] = '(UTC -7:00) Mountain Standard Time';
$lang['UM6'] = '(UTC -6:00) Central Standard Time';
$lang['UM5'] = '(UTC -5:00) Eastern Standard Time, Western Caribbean Standard Time';
$lang['UM45'] = '(UTC -4:30) Venezuelan Standard Time';
$lang['UM4'] = '(UTC -4:00) Atlantic Standard Time, Eastern Caribbean Standard Time';
$lang['UM35'] = '(UTC -3:30) Newfoundland Standard Time';
$lang['UM3'] = '(UTC -3:00) Argentina, Brazil, French Guiana, Uruguay';
$lang['UM2'] = '(UTC -2:00) South Georgia/South Sandwich Islands';
$lang['UM1'] = '(UTC -1:00) Azores, Cape Verde Islands';
$lang['UTC'] = '(UTC) Greenwich Mean Time, Western European Time';
$lang['UP1'] = '(UTC +1:00) Central European Time, West Africa Time';
$lang['UP2'] = '(UTC +2:00) Central Africa Time, Eastern European Time, Kaliningrad Time';
$lang['UP3'] = '(UTC +3:00) Moscow Time, East Africa Time';
$lang['UP35'] = '(UTC +3:30) Iran Standard Time';
$lang['UP4'] = '(UTC +4:00) Azerbaijan Standard Time, Samara Time';
$lang['UP45'] = '(UTC +4:30) Afghanistan';
$lang['UP5'] = '(UTC +5:00) Pakistan Standard Time, Yekaterinburg Time';
$lang['UP55'] = '(UTC +5:30) Indian Standard Time, Sri Lanka Time';
$lang['UP575'] = '(UTC +5:45) Nepal Time';
$lang['UP6'] = '(UTC +6:00) Bangladesh Standard Time, Bhutan Time, Omsk Time';
$lang['UP65'] = '(UTC +6:30) Cocos Islands, Myanmar';
$lang['UP7'] = '(UTC +7:00) Krasnoyarsk Time, Cambodia, Laos, Thailand, Vietnam';
$lang['UP8'] = '(UTC +8:00) Australian Western Standard Time, Beijing Time, Irkutsk Time';
$lang['UP875'] = '(UTC +8:45) Australian Central Western Standard Time';
$lang['UP9'] = '(UTC +9:00) Japan Standard Time, Korea Standard Time, Yakutsk Time';
$lang['UP95'] = '(UTC +9:30) Australian Central Standard Time';
$lang['UP10'] = '(UTC +10:00) Australian Eastern Standard Time, Vladivostok Time';
$lang['UP105'] = '(UTC +10:30) Lord Howe Island';
$lang['UP11'] = '(UTC +11:00) Magadan Time, Solomon Islands, Vanuatu';
$lang['UP115'] = '(UTC +11:30) Norfolk Island';
$lang['UP12'] = '(UTC +12:00) Fiji, Gilbert Islands, Kamchatka Time, New Zealand Standard Time';
$lang['UP1275'] = '(UTC +12:45) Chatham Islands Standard Time';
$lang['UP13'] = '(UTC +13:00) Phoenix Islands Time, Tonga';
$lang['UP14'] = '(UTC +14:00) Line Islands';
/* End of file date_lang.php */
/* Location: ./system/language/english/date_lang.php */ | php | MIT | 152cd2d808675d2baeb9e77c229adfbaf9a16475 | 2026-01-05T05:21:15.334872Z | false |
MobilityLab/TransitScreen | https://github.com/MobilityLab/TransitScreen/blob/152cd2d808675d2baeb9e77c229adfbaf9a16475/system/language/english/calendar_lang.php | system/language/english/calendar_lang.php | <?php
$lang['cal_su'] = "Su";
$lang['cal_mo'] = "Mo";
$lang['cal_tu'] = "Tu";
$lang['cal_we'] = "We";
$lang['cal_th'] = "Th";
$lang['cal_fr'] = "Fr";
$lang['cal_sa'] = "Sa";
$lang['cal_sun'] = "Sun";
$lang['cal_mon'] = "Mon";
$lang['cal_tue'] = "Tue";
$lang['cal_wed'] = "Wed";
$lang['cal_thu'] = "Thu";
$lang['cal_fri'] = "Fri";
$lang['cal_sat'] = "Sat";
$lang['cal_sunday'] = "Sunday";
$lang['cal_monday'] = "Monday";
$lang['cal_tuesday'] = "Tuesday";
$lang['cal_wednesday'] = "Wednesday";
$lang['cal_thursday'] = "Thursday";
$lang['cal_friday'] = "Friday";
$lang['cal_saturday'] = "Saturday";
$lang['cal_jan'] = "Jan";
$lang['cal_feb'] = "Feb";
$lang['cal_mar'] = "Mar";
$lang['cal_apr'] = "Apr";
$lang['cal_may'] = "May";
$lang['cal_jun'] = "Jun";
$lang['cal_jul'] = "Jul";
$lang['cal_aug'] = "Aug";
$lang['cal_sep'] = "Sep";
$lang['cal_oct'] = "Oct";
$lang['cal_nov'] = "Nov";
$lang['cal_dec'] = "Dec";
$lang['cal_january'] = "January";
$lang['cal_february'] = "February";
$lang['cal_march'] = "March";
$lang['cal_april'] = "April";
$lang['cal_mayl'] = "May";
$lang['cal_june'] = "June";
$lang['cal_july'] = "July";
$lang['cal_august'] = "August";
$lang['cal_september'] = "September";
$lang['cal_october'] = "October";
$lang['cal_november'] = "November";
$lang['cal_december'] = "December";
/* End of file calendar_lang.php */
/* Location: ./system/language/english/calendar_lang.php */ | php | MIT | 152cd2d808675d2baeb9e77c229adfbaf9a16475 | 2026-01-05T05:21:15.334872Z | false |
MobilityLab/TransitScreen | https://github.com/MobilityLab/TransitScreen/blob/152cd2d808675d2baeb9e77c229adfbaf9a16475/system/language/english/upload_lang.php | system/language/english/upload_lang.php | <?php
$lang['upload_userfile_not_set'] = "Unable to find a post variable called userfile.";
$lang['upload_file_exceeds_limit'] = "The uploaded file exceeds the maximum allowed size in your PHP configuration file.";
$lang['upload_file_exceeds_form_limit'] = "The uploaded file exceeds the maximum size allowed by the submission form.";
$lang['upload_file_partial'] = "The file was only partially uploaded.";
$lang['upload_no_temp_directory'] = "The temporary folder is missing.";
$lang['upload_unable_to_write_file'] = "The file could not be written to disk.";
$lang['upload_stopped_by_extension'] = "The file upload was stopped by extension.";
$lang['upload_no_file_selected'] = "You did not select a file to upload.";
$lang['upload_invalid_filetype'] = "The filetype you are attempting to upload is not allowed.";
$lang['upload_invalid_filesize'] = "The file you are attempting to upload is larger than the permitted size.";
$lang['upload_invalid_dimensions'] = "The image you are attempting to upload exceedes the maximum height or width.";
$lang['upload_destination_error'] = "A problem was encountered while attempting to move the uploaded file to the final destination.";
$lang['upload_no_filepath'] = "The upload path does not appear to be valid.";
$lang['upload_no_file_types'] = "You have not specified any allowed file types.";
$lang['upload_bad_filename'] = "The file name you submitted already exists on the server.";
$lang['upload_not_writable'] = "The upload destination folder does not appear to be writable.";
/* End of file upload_lang.php */
/* Location: ./system/language/english/upload_lang.php */ | php | MIT | 152cd2d808675d2baeb9e77c229adfbaf9a16475 | 2026-01-05T05:21:15.334872Z | false |
MobilityLab/TransitScreen | https://github.com/MobilityLab/TransitScreen/blob/152cd2d808675d2baeb9e77c229adfbaf9a16475/system/language/english/form_validation_lang.php | system/language/english/form_validation_lang.php | <?php
$lang['required'] = "The %s field is required.";
$lang['isset'] = "The %s field must have a value.";
$lang['valid_email'] = "The %s field must contain a valid email address.";
$lang['valid_emails'] = "The %s field must contain all valid email addresses.";
$lang['valid_url'] = "The %s field must contain a valid URL.";
$lang['valid_ip'] = "The %s field must contain a valid IP.";
$lang['min_length'] = "The %s field must be at least %s characters in length.";
$lang['max_length'] = "The %s field can not exceed %s characters in length.";
$lang['exact_length'] = "The %s field must be exactly %s characters in length.";
$lang['alpha'] = "The %s field may only contain alphabetical characters.";
$lang['alpha_numeric'] = "The %s field may only contain alpha-numeric characters.";
$lang['alpha_dash'] = "The %s field may only contain alpha-numeric characters, underscores, and dashes.";
$lang['numeric'] = "The %s field must contain only numbers.";
$lang['is_numeric'] = "The %s field must contain only numeric characters.";
$lang['integer'] = "The %s field must contain an integer.";
$lang['regex_match'] = "The %s field is not in the correct format.";
$lang['matches'] = "The %s field does not match the %s field.";
$lang['is_unique'] = "The %s field must contain a unique value.";
$lang['is_natural'] = "The %s field must contain only positive numbers.";
$lang['is_natural_no_zero'] = "The %s field must contain a number greater than zero.";
$lang['decimal'] = "The %s field must contain a decimal number.";
$lang['less_than'] = "The %s field must contain a number less than %s.";
$lang['greater_than'] = "The %s field must contain a number greater than %s.";
/* End of file form_validation_lang.php */
/* Location: ./system/language/english/form_validation_lang.php */ | php | MIT | 152cd2d808675d2baeb9e77c229adfbaf9a16475 | 2026-01-05T05:21:15.334872Z | false |
MobilityLab/TransitScreen | https://github.com/MobilityLab/TransitScreen/blob/152cd2d808675d2baeb9e77c229adfbaf9a16475/system/language/english/db_lang.php | system/language/english/db_lang.php | <?php
$lang['db_invalid_connection_str'] = 'Unable to determine the database settings based on the connection string you submitted.';
$lang['db_unable_to_connect'] = 'Unable to connect to your database server using the provided settings.';
$lang['db_unable_to_select'] = 'Unable to select the specified database: %s';
$lang['db_unable_to_create'] = 'Unable to create the specified database: %s';
$lang['db_invalid_query'] = 'The query you submitted is not valid.';
$lang['db_must_set_table'] = 'You must set the database table to be used with your query.';
$lang['db_must_use_set'] = 'You must use the "set" method to update an entry.';
$lang['db_must_use_index'] = 'You must specify an index to match on for batch updates.';
$lang['db_batch_missing_index'] = 'One or more rows submitted for batch updating is missing the specified index.';
$lang['db_must_use_where'] = 'Updates are not allowed unless they contain a "where" clause.';
$lang['db_del_must_use_where'] = 'Deletes are not allowed unless they contain a "where" or "like" clause.';
$lang['db_field_param_missing'] = 'To fetch fields requires the name of the table as a parameter.';
$lang['db_unsupported_function'] = 'This feature is not available for the database you are using.';
$lang['db_transaction_failure'] = 'Transaction failure: Rollback performed.';
$lang['db_unable_to_drop'] = 'Unable to drop the specified database.';
$lang['db_unsuported_feature'] = 'Unsupported feature of the database platform you are using.';
$lang['db_unsuported_compression'] = 'The file compression format you chose is not supported by your server.';
$lang['db_filepath_error'] = 'Unable to write data to the file path you have submitted.';
$lang['db_invalid_cache_path'] = 'The cache path you submitted is not valid or writable.';
$lang['db_table_name_required'] = 'A table name is required for that operation.';
$lang['db_column_name_required'] = 'A column name is required for that operation.';
$lang['db_column_definition_required'] = 'A column definition is required for that operation.';
$lang['db_unable_to_set_charset'] = 'Unable to set client connection character set: %s';
$lang['db_error_heading'] = 'A Database Error Occurred';
/* End of file db_lang.php */
/* Location: ./system/language/english/db_lang.php */ | php | MIT | 152cd2d808675d2baeb9e77c229adfbaf9a16475 | 2026-01-05T05:21:15.334872Z | false |
MobilityLab/TransitScreen | https://github.com/MobilityLab/TransitScreen/blob/152cd2d808675d2baeb9e77c229adfbaf9a16475/system/language/english/number_lang.php | system/language/english/number_lang.php | <?php
$lang['terabyte_abbr'] = "TB";
$lang['gigabyte_abbr'] = "GB";
$lang['megabyte_abbr'] = "MB";
$lang['kilobyte_abbr'] = "KB";
$lang['bytes'] = "Bytes";
/* End of file number_lang.php */
/* Location: ./system/language/english/number_lang.php */ | php | MIT | 152cd2d808675d2baeb9e77c229adfbaf9a16475 | 2026-01-05T05:21:15.334872Z | false |
MobilityLab/TransitScreen | https://github.com/MobilityLab/TransitScreen/blob/152cd2d808675d2baeb9e77c229adfbaf9a16475/public/index.php | public/index.php | <?php
/*
*---------------------------------------------------------------
* APPLICATION ENVIRONMENT
*---------------------------------------------------------------
*
* You can load different configurations depending on your
* current environment. Setting the environment also influences
* things like logging and error reporting.
*
* This can be set to anything, but default usage is:
*
* development
* testing
* production
*
* NOTE: If you change these, also change the error_reporting() code below
*
*/
define('ENVIRONMENT', 'development');
/*
*---------------------------------------------------------------
* ERROR REPORTING
*---------------------------------------------------------------
*
* Different environments will require different levels of error reporting.
* By default development will show errors but testing and live will hide them.
*/
if (defined('ENVIRONMENT'))
{
switch (ENVIRONMENT)
{
case 'development':
error_reporting(E_ALL);
break;
case 'testing':
case 'production':
error_reporting(0);
break;
default:
exit('The application environment is not set correctly.');
}
}
/*
*---------------------------------------------------------------
* SYSTEM FOLDER NAME
*---------------------------------------------------------------
*
* This variable must contain the name of your "system" folder.
* Include the path if the folder is not in the same directory
* as this file.
*
*/
//$system_path = 'system';
$system_folder = "/opt/share/php/ci/system";
$system_path = "/opt/share/php/ci/system";
/*
*---------------------------------------------------------------
* APPLICATION FOLDER NAME
*---------------------------------------------------------------
*
* If you want this front controller to use a different "application"
* folder then the default one you can set its name here. The folder
* can also be renamed or relocated anywhere on your server. If
* you do, use a full server path. For more info please see the user guide:
* http://codeigniter.com/user_guide/general/managing_apps.html
*
* NO TRAILING SLASH!
*
*/
$application_folder = '../application';
/*
* --------------------------------------------------------------------
* DEFAULT CONTROLLER
* --------------------------------------------------------------------
*
* Normally you will set your default controller in the routes.php file.
* You can, however, force a custom routing by hard-coding a
* specific controller class/function here. For most applications, you
* WILL NOT set your routing here, but it's an option for those
* special instances where you might want to override the standard
* routing in a specific front controller that shares a common CI installation.
*
* IMPORTANT: If you set the routing here, NO OTHER controller will be
* callable. In essence, this preference limits your application to ONE
* specific controller. Leave the function name blank if you need
* to call functions dynamically via the URI.
*
* Un-comment the $routing array below to use this feature
*
*/
// The directory name, relative to the "controllers" folder. Leave blank
// if your controller is not in a sub-folder within the "controllers" folder
// $routing['directory'] = '';
// The controller class file name. Example: Mycontroller
// $routing['controller'] = '';
// The controller function you wish to be called.
// $routing['function'] = '';
/*
* -------------------------------------------------------------------
* CUSTOM CONFIG VALUES
* -------------------------------------------------------------------
*
* The $assign_to_config array below will be passed dynamically to the
* config class when initialized. This allows you to set custom config
* items or override any default config values found in the config.php file.
* This can be handy as it permits you to share one application between
* multiple front controller files, with each file containing different
* config values.
*
* Un-comment the $assign_to_config array below to use this feature
*
*/
// $assign_to_config['name_of_config_item'] = 'value of config item';
// --------------------------------------------------------------------
// END OF USER CONFIGURABLE SETTINGS. DO NOT EDIT BELOW THIS LINE
// --------------------------------------------------------------------
/*
* ---------------------------------------------------------------
* Resolve the system path for increased reliability
* ---------------------------------------------------------------
*/
// Set the current directory correctly for CLI requests
if (defined('STDIN'))
{
chdir(dirname(__FILE__));
}
if (realpath($system_path) !== FALSE)
{
$system_path = realpath($system_path).'/';
}
// ensure there's a trailing slash
$system_path = rtrim($system_path, '/').'/';
// Is the system path correct?
if ( ! is_dir($system_path))
{
exit("Your system folder path does not appear to be set correctly. Please open the following file and correct this: ".pathinfo(__FILE__, PATHINFO_BASENAME));
}
/*
* -------------------------------------------------------------------
* Now that we know the path, set the main path constants
* -------------------------------------------------------------------
*/
// The name of THIS file
define('SELF', pathinfo(__FILE__, PATHINFO_BASENAME));
// The PHP file extension
// this global constant is deprecated.
define('EXT', '.php');
// Path to the system folder
define('BASEPATH', str_replace("\\", "/", $system_path));
// Path to the front controller (this file)
define('FCPATH', str_replace(SELF, '', __FILE__));
// Name of the "system folder"
define('SYSDIR', trim(strrchr(trim(BASEPATH, '/'), '/'), '/'));
// The path to the "application" folder
if (is_dir($application_folder))
{
define('APPPATH', $application_folder.'/');
}
else
{
if ( ! is_dir(BASEPATH.$application_folder.'/'))
{
exit("Your application folder path does not appear to be set correctly. Please open the following file and correct this: ".SELF);
}
define('APPPATH', BASEPATH.$application_folder.'/');
}
/*
* --------------------------------------------------------------------
* LOAD THE BOOTSTRAP FILE
* --------------------------------------------------------------------
*
* And away we go...
*
*/
require_once BASEPATH.'core/CodeIgniter.php';
/* End of file index.php */
/* Location: ./index.php */
| php | MIT | 152cd2d808675d2baeb9e77c229adfbaf9a16475 | 2026-01-05T05:21:15.334872Z | false |
MobilityLab/TransitScreen | https://github.com/MobilityLab/TransitScreen/blob/152cd2d808675d2baeb9e77c229adfbaf9a16475/application/helpers/transit_functions_helper.php | application/helpers/transit_functions_helper.php | <?php
/**
* Function: clean_destination
* @param string $s
* @return string
*
* Receives an API-generated destination and fixes it to make it fit better
* or read better on the screen. For instance, the WMATA API prints out 'NW'
* incorrectly as 'Nw'. This function fixes that. This is also a good place
* to add other API corrections as you find them.
*
*/
function clean_destination($s){
$s = str_replace('North to ','',$s);
$s = str_replace('South to ','',$s);
$s = str_replace('East to ','',$s);
$s = str_replace('West to ','',$s);
//$s = str_replace('Station','',$s);
$s = str_replace('Square','Sq',$s);
$s = str_replace('Pike','Pk',$s);
$s = str_replace(', ',' » ',$s);
$s = preg_replace('/Nw(\s|$)/','NW', $s);
$s = preg_replace('/Ne(\s|$)/','NE', $s);
$s = preg_replace('/Sw(\s|$)/','SW', $s);
$s = preg_replace('/Se(\s|$)/','SE', $s);
$s = str_replace('Court House Metro - ','', $s);
$s = str_replace('Court House Metro to ','', $s);
$s = str_replace('Columbia Pk/Dinwiddie - ','', $s);
$s = str_replace('Shirlington Station to ','', $s);
return $s;
}
/**
* Function: get_rail_predictions
* @param int $station_id - the WMATA station id
* @param string $api_key - the WMATA API key
* @return mixed - the returned array (data)
*
* This function gets the rail predictions from the WMATA API, formats the data
* nicely and returns the data.
*
*/
function get_rail_predictions($station_id, $api_key){
$trains = array();
// Load the train prediction XML from the API
$railxml = simplexml_load_file("http://api.wmata.com/StationPrediction.svc/GetPrediction/$station_id?api_key=$api_key");
$predictions = $railxml->Trains->AIMPredictionTrainInfo;
// For each prediction, put the data into an array to return
for($t = 0; $t < count($predictions); $t++){
$newitem['stop_name'] = (string) $predictions[$t]->LocationName;
$newitem['agency'] = 'metrorail';
$newitem['route'] = (string) $predictions[$t]->Line;
$newitem['destination'] = (string) $predictions[$t]->DestinationName;
// Ignore "No passengers" and no destination
if (($newitem['destination'] != '') && ($newitem['route'] != 'No')) {
switch ((string) $predictions[$t]->Min) {
case 'ARR':
case 'BRD':
// Predictions 'ARR' and 'BRD' will be omitted
// $newitem['prediction'] = 0;
break;
default:
$newitem['prediction'] = (int) $predictions[$t]->Min;
$trains[] = $newitem;
}
}
}
// Do an array_multisort to sort by prediction time, then color, then destination
foreach($trains as $key => $row){
$r[$key] = $row['route'];
$d[$key] = $row['destination'];
$p[$key] = $row['prediction'];
}
array_multisort($p, SORT_ASC, $r, SORT_ASC, $d, SORT_ASC, $trains);
return $trains;
}
/**
* Function: combine_agencies
*
* @param array $busgroups
* @param int $max
* @return array
*
* Take the groups of bus predictions from different agencies (but for one stop),
* merge them together and sort them by prediction regardless of agency. Return
* the newly sorted array.
*
*/
function combine_agencies(array $busgroups, $max = 99) {
$combined = array();
for($g = 0; $g < count($busgroups); $g++) {
$combined = array_merge($combined,$busgroups[$g]);
}
// Sort by prediction, then route, then destination
foreach($combined as $key => $row){
$r[$key] = $row['route'];
$d[$key] = $row['destination'];
$p[$key] = $row['prediction'];
$a[$key] = $row['agency'];
$s[$key] = $row['stop_name'];
}
array_multisort($p, SORT_ASC, $r, SORT_DESC, $d, SORT_ASC, $combined);
return $combined;
}
/**
* Function: get_bus_predictions
*
* @param mixed $stop_id - the stop id
* @param string $api_key - the API key for the agency
* @param string $agency - the agency id
* @return mixed - array of data (unrendered) or a string (rendered)
*
*
*/
function get_bus_predictions($stop_id,$api_key,$agency) {
$out = '';
// Call the different API function based on the agency name.
switch ($agency) {
case 'wmata':
case 'metrobus':
$out = get_metrobus_predictions($stop_id, $api_key);
break;
case 'dc-circulator':
case 'circulator':
$out = get_nextbus_predictions($stop_id, 'dc-circulator');
break;
case 'pgc':
$out = get_nextbus_predictions($stop_id, 'pgc');
break;
case 'umd':
$buses = get_nextbus_predictions($stop_id, 'umd');
break;
case 'art':
$out = get_connexionz_predictions($stop_id, 'art');
break;
}
return $out;
}
/**
* Function: get_metrobus_predictions
*
* @param int $stop_id - the stop id
* @param string $api_key - the WMATA API key
* @return array - the Metrobus prediction data for this stop
*
* This function gets the Metrobus arrival predictions for a given Metrbus stop
* and returns the predictions in an array.
*
*/
function get_metrobus_predictions($stop_id,$api_key){
$out = '';
// Call the API
if(!($busxml = simplexml_load_file("http://api.wmata.com/NextBusService.svc/Predictions?StopID=$stop_id&api_key=" . $api_key))){
return false;
}
$stop_name = (string) $busxml->StopName;
$predictions = $busxml->Predictions->NextBusPrediction;
$limit = min(count($predictions), 4);
// Add the predictions into an array
for($b = 0; $b < $limit; $b++){
$newitem['stop_name'] = $stop_name;
$newitem['agency'] = 'Metrobus';
$newitem['route'] = (string) $predictions[$b]->RouteID;
$newitem['destination'] = (string) $predictions[$b]->DirectionText;
$newitem['prediction'] = (int) $predictions[$b]->Minutes;
$out[] = $newitem;
}
// Return the array of predictions.
return $out;
}
/**
* Function get_nextbus_predictions
*
* @param int $stop_id
* @param string $agency_tag
* @return array
*
* Get the NextBus predictions for this bus stop and return the data in an array.
* This is what we will use for the DC Circulator, Shuttle UM and Prince George's County's TheBus.
*
*/
function get_nextbus_predictions($stop_id,$agency_tag){
if($agency_tag == 'dc-circulator'){
$agency = 'Circulator';
$busxml = simplexml_load_file("http://webservices.nextbus.com/service/publicXMLFeed?command=predictions&a=$agency_tag&stopId=$stop_id");
}
elseif($agency_tag == 'pgc'){
$agency = 'pgc';
$busxml = simplexml_load_file("http://webservices.nextbus.com/service/publicXMLFeed?command=predictions&a=$agency_tag&$stop_id");
}
elseif($agency_tag == 'umd'){
$agency = 'umd';
$busxml = simplexml_load_file("http://webservices.nextbus.com/service/publicXMLFeed?command=predictions&a=$agency_tag&stopId=$stop_id");
}
//foreach predictions
foreach($busxml->predictions as $pred){
$stopname = (string) $pred->attributes()->stopTitle;
$routename = (string) $pred->attributes()->routeTitle;
//foreach direction
foreach($pred->direction as $dir){
$destination = (string) $dir->attributes()->title;
//foreach prediction
foreach($dir->prediction as $p){
unset($newitem);
$newitem['stop_name'] = $stopname;
$newitem['agency'] = $agency;
$newitem['route'] = $routename;
$newitem['destination'] = $routename . ' (' . $destination . ')';
$newitem['prediction'] = (int) $p['minutes'];
$out[] = $newitem;
}
}
}
return $out;
}
/**
* Function: get_connexionz_predictions
*
* @param mixed $stop_id - the stop id
* @param string $agency - the agency name
* @return array - an array of bus predictions from Connexionz
*
* This function collects the bus arrival predictions from ART's Connexionz API
* and returns the data in an array.
*
*/
function get_connexionz_predictions($stop_id,$agency) {
if($agency == 'art'){
// Call the XML from the API
$busxml = simplexml_load_file("http://realtime.commuterpage.com/RTT/Public/Utility/File.aspx?ContentType=SQLXML&Name=RoutePositionET.xml&PlatformTag=$stop_id");
$agency_name = 'ART';
}
// Put the predictions into an array
$predictions = $busxml->Platform;
$stop_name = (string) $busxml->Platform['Name'];
foreach($predictions->Route as $route){ //For each route
foreach($route->Destination->Trip as $trip){
$newitem['stop_name'] = $stop_name;
$newitem['agency'] = $agency_name;
$newitem['route'] = (string) $route['RouteNo'];
$newitem['destination'] = (string) $route['Name'];
$newitem['prediction'] = (int) $trip['ETA'];
$out[] = $newitem;
}
}
// Use array_multisort to sort the predictions by time, then route, then
// destination, then agency
foreach($out as $key => $row){
$a[$key] = $row['agency'];
$r[$key] = $row['route'];
$d[$key] = $row['destination'];
$p[$key] = $row['prediction'];
}
array_multisort($p, SORT_ASC, $r, SORT_DESC, $d, SORT_ASC, $a, SORT_ASC, $out);
return $out;
}
/**
* Function: get_cabi_status
*
* @param int $station_id - the id of the CaBi station
* @return array - an array of the station data
*
* Given a CaBi station id, get the station data and return an array with the
* station status, e.g. number of bikes, number of docks, and the station name.
*
*/
function get_cabi_status($station_id){
// Load the XML file for the entire system.
$cabixml = simplexml_load_file("http://www.capitalbikeshare.com/stations/bikeStations.xml");
// Find the station with the parameter id and get the data for it.
$stations = $cabixml->station;
foreach($stations as $station){
if((int) $station->id == $station_id) {
$cabi['stop_name'] = (string) $station->name;
$cabi['bikes'] = (int) $station->nbBikes;
$cabi['docks'] = (int) $station->nbEmptyDocks;
break;
}
}
// Return an array with the cabi station data.
return $cabi;
}
?>
| php | MIT | 152cd2d808675d2baeb9e77c229adfbaf9a16475 | 2026-01-05T05:21:15.334872Z | false |
MobilityLab/TransitScreen | https://github.com/MobilityLab/TransitScreen/blob/152cd2d808675d2baeb9e77c229adfbaf9a16475/application/helpers/render_admin_helper.php | application/helpers/render_admin_helper.php | <?php
/**
* Function: get_field_alias
*
* @param string $input
* @return string
*
* This function replaces the machine formated database field names with
* human-readable names.
*
*/
function get_field_alias($input){
$input = str_replace('MoTh_', 'Monday - Thursday ', $input);
$input = str_replace('Fr_', 'Friday ', $input);
$input = str_replace('Sa_', 'Saturday ', $input);
$input = str_replace('Su_', 'Sunday ', $input);
$input = preg_replace('/\sop$/', ' wakeup time', $input);
$input = preg_replace('/\scl$/', ' sleep time', $input);
$input = preg_replace('/^name$/', 'Internal name', $input);
return $input;
}
/**
* Function: get_verbose_status
*
* @param string $input
* @return string
*
* This returns a more descriptive status message to the user.
*
*/
function get_verbose_status($input) {
switch($input){
case 'success':
return 'Changes saved.';
case 'success': // huh? MSC
return 'Screen created.';
default:
return '';
}
}
| php | MIT | 152cd2d808675d2baeb9e77c229adfbaf9a16475 | 2026-01-05T05:21:15.334872Z | false |
MobilityLab/TransitScreen | https://github.com/MobilityLab/TransitScreen/blob/152cd2d808675d2baeb9e77c229adfbaf9a16475/application/helpers/transit_functions.php | application/helpers/transit_functions.php | <?php
/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
?>
| php | MIT | 152cd2d808675d2baeb9e77c229adfbaf9a16475 | 2026-01-05T05:21:15.334872Z | false |
MobilityLab/TransitScreen | https://github.com/MobilityLab/TransitScreen/blob/152cd2d808675d2baeb9e77c229adfbaf9a16475/application/errors/error_general.php | application/errors/error_general.php | <!DOCTYPE html>
<html lang="en">
<head>
<title>Error</title>
<style type="text/css">
::selection{ background-color: #E13300; color: white; }
::moz-selection{ background-color: #E13300; color: white; }
::webkit-selection{ background-color: #E13300; color: white; }
body {
background-color: #fff;
margin: 40px;
font: 13px/20px normal Helvetica, Arial, sans-serif;
color: #4F5155;
}
a {
color: #003399;
background-color: transparent;
font-weight: normal;
}
h1 {
color: #444;
background-color: transparent;
border-bottom: 1px solid #D0D0D0;
font-size: 19px;
font-weight: normal;
margin: 0 0 14px 0;
padding: 14px 15px 10px 15px;
}
code {
font-family: Consolas, Monaco, Courier New, Courier, monospace;
font-size: 12px;
background-color: #f9f9f9;
border: 1px solid #D0D0D0;
color: #002166;
display: block;
margin: 14px 0 14px 0;
padding: 12px 10px 12px 10px;
}
#container {
margin: 10px;
border: 1px solid #D0D0D0;
-webkit-box-shadow: 0 0 8px #D0D0D0;
}
p {
margin: 12px 15px 12px 15px;
}
</style>
</head>
<body>
<div id="container">
<h1><?php echo $heading; ?></h1>
<?php echo $message; ?>
</div>
</body>
</html> | php | MIT | 152cd2d808675d2baeb9e77c229adfbaf9a16475 | 2026-01-05T05:21:15.334872Z | false |
MobilityLab/TransitScreen | https://github.com/MobilityLab/TransitScreen/blob/152cd2d808675d2baeb9e77c229adfbaf9a16475/application/errors/error_404.php | application/errors/error_404.php | <!DOCTYPE html>
<html lang="en">
<head>
<title>404 Page Not Found</title>
<style type="text/css">
::selection{ background-color: #E13300; color: white; }
::moz-selection{ background-color: #E13300; color: white; }
::webkit-selection{ background-color: #E13300; color: white; }
body {
background-color: #fff;
margin: 40px;
font: 13px/20px normal Helvetica, Arial, sans-serif;
color: #4F5155;
}
a {
color: #003399;
background-color: transparent;
font-weight: normal;
}
h1 {
color: #444;
background-color: transparent;
border-bottom: 1px solid #D0D0D0;
font-size: 19px;
font-weight: normal;
margin: 0 0 14px 0;
padding: 14px 15px 10px 15px;
}
code {
font-family: Consolas, Monaco, Courier New, Courier, monospace;
font-size: 12px;
background-color: #f9f9f9;
border: 1px solid #D0D0D0;
color: #002166;
display: block;
margin: 14px 0 14px 0;
padding: 12px 10px 12px 10px;
}
#container {
margin: 10px;
border: 1px solid #D0D0D0;
-webkit-box-shadow: 0 0 8px #D0D0D0;
}
p {
margin: 12px 15px 12px 15px;
}
</style>
</head>
<body>
<div id="container">
<h1><?php echo $heading; ?></h1>
<?php echo $message; ?>
</div>
</body>
</html> | php | MIT | 152cd2d808675d2baeb9e77c229adfbaf9a16475 | 2026-01-05T05:21:15.334872Z | false |
MobilityLab/TransitScreen | https://github.com/MobilityLab/TransitScreen/blob/152cd2d808675d2baeb9e77c229adfbaf9a16475/application/errors/error_php.php | application/errors/error_php.php | <div style="border:1px solid #990000;padding-left:20px;margin:0 0 10px 0;">
<h4>A PHP Error was encountered</h4>
<p>Severity: <?php echo $severity; ?></p>
<p>Message: <?php echo $message; ?></p>
<p>Filename: <?php echo $filepath; ?></p>
<p>Line Number: <?php echo $line; ?></p>
</div> | php | MIT | 152cd2d808675d2baeb9e77c229adfbaf9a16475 | 2026-01-05T05:21:15.334872Z | false |
MobilityLab/TransitScreen | https://github.com/MobilityLab/TransitScreen/blob/152cd2d808675d2baeb9e77c229adfbaf9a16475/application/errors/error_db.php | application/errors/error_db.php | <!DOCTYPE html>
<html lang="en">
<head>
<title>Database Error</title>
<style type="text/css">
::selection{ background-color: #E13300; color: white; }
::moz-selection{ background-color: #E13300; color: white; }
::webkit-selection{ background-color: #E13300; color: white; }
body {
background-color: #fff;
margin: 40px;
font: 13px/20px normal Helvetica, Arial, sans-serif;
color: #4F5155;
}
a {
color: #003399;
background-color: transparent;
font-weight: normal;
}
h1 {
color: #444;
background-color: transparent;
border-bottom: 1px solid #D0D0D0;
font-size: 19px;
font-weight: normal;
margin: 0 0 14px 0;
padding: 14px 15px 10px 15px;
}
code {
font-family: Consolas, Monaco, Courier New, Courier, monospace;
font-size: 12px;
background-color: #f9f9f9;
border: 1px solid #D0D0D0;
color: #002166;
display: block;
margin: 14px 0 14px 0;
padding: 12px 10px 12px 10px;
}
#container {
margin: 10px;
border: 1px solid #D0D0D0;
-webkit-box-shadow: 0 0 8px #D0D0D0;
}
p {
margin: 12px 15px 12px 15px;
}
</style>
</head>
<body>
<div id="container">
<h1><?php echo $heading; ?></h1>
<?php echo $message; ?>
</div>
</body>
</html> | php | MIT | 152cd2d808675d2baeb9e77c229adfbaf9a16475 | 2026-01-05T05:21:15.334872Z | false |
MobilityLab/TransitScreen | https://github.com/MobilityLab/TransitScreen/blob/152cd2d808675d2baeb9e77c229adfbaf9a16475/application/controllers/login.php | application/controllers/login.php | <?php
/**
* Class: Login
*
* This is the login class and is used exclusively for logging in admin users.
* If you wish to handle more sophisticated tasks like password recovery or
* assigning different users to different access privileges, add the code in
* here.
*
*/
class Login extends CI_Controller {
/**
* Function: index()
*
* When a user tries to go to /login/, the MVC model for Code Igniter directs
* the user to the index function of the login class. In this case, the
* function directs the user to the login template.
*/
public function index() {
$data['main_content'] = 'login_form'; // Tells the system which form to load
$this->load->view('includes/template', $data); // Loads this template
}
/**
* Function: validate_credentials()
*
* Load the user model and attempt to log the user in. If the credentials
* validate, redirect the user to the /screen_admin/, otherwise, send them
* back to the login page.
*/
public function validate_credentials(){
// Load the user model
$this->load->model('user_model');
$query = $this->user_model->validate();
// If the user query is successful...
if($query) {
$data = array(
'username' => $this->input->post('username'), // or $query->username?
'id' => $query->id,
'admin' => $query->admin,
'is_logged_in' => true
);
// Create the user session.
$this->session->set_userdata($data);
// Redirect the user to the screen admin page.
redirect('screen_admin');
}
else {
// Otherwise, force the user to the login screen.
$this->index();
}
}
}
?>
| php | MIT | 152cd2d808675d2baeb9e77c229adfbaf9a16475 | 2026-01-05T05:21:15.334872Z | false |
MobilityLab/TransitScreen | https://github.com/MobilityLab/TransitScreen/blob/152cd2d808675d2baeb9e77c229adfbaf9a16475/application/controllers/screen_admin.php | application/controllers/screen_admin.php | <?php
/**
* Class: Screen_admin
*
* This controller is used only for the screen administration pages that an
* administrator sees.
*
*/
class Screen_admin extends CI_Controller {
/**
* This is the contructor and differs from most other constructors. This one
* checks to make sure that a user trying to load any screen_admin page is
* logged in. This ensures that unauthenticated users can't access the admin
* section.
*/
public function __construct() {
parent::__construct();
$this->is_logged_in();
}
/**
* Function: index
* @param string $msg - A status message, e.g. "success" (optional)
*
* This function is called after a user successfully logs in. It's like the
* "homepage" for the screen_admin section. *
*
*/
public function index($msg = '') {
// Load the screen model
$this->load->model('screen_model');
// Load the render_admin helper. This helper provides a few functions
// to clean up code names and replace them with human readable names.
$this->load->helper('render_admin_helper');
// Establish a $data variable for passing to a view. Include the screens in 'rows',
// the template to load in 'main_content', and any sort of status message in 'msg'.
$data['rows'] = $this->screen_model->get_screens_by_user_id(); // $user_id MSC
$data['main_content'] = 'screen_listing';
$data['msg'] = get_verbose_status($msg);
// Load the admin template and pass all the data to it to render.
$this->load->view('includes/template', $data);
}
/**
* Function: is_logged_in
*
* Check the session data for this user to ensure they're logged in. If not,
* redirect the user to the home page, which is a blank url from the root, i.e.
* ''
*/
public function is_logged_in() {
$is_logged_in = $this->session->userdata('is_logged_in');
if(!isset($is_logged_in) || $is_logged_in !== true ){
redirect('');
}
}
/**
* Function: edit
*
* This function builds the page that allows an admin to edit a specific
* screen. It creates a $data variable with the necessary information and
* passes it to the view, which loads the screen_editor template.
*
* @param int $id - the id of the screen to edit
*/
public function edit($id = 0){
// Load this helper. (Helpers are in /application/helpers)
$this->load->helper('render_admin');
// Load the screen model
$this->load->model('screen_model');
// Get all the configuration and set up values for this screen and store
// the values in $data['rows']
$data['rows'] = $this->screen_model->get_screen_values($id);
// Tell the admin page template to load the screen_editor template in the
// main content section.
$data['main_content'] = 'screen_editor';
// Load the view and pass the data.
$this->load->view('includes/template', $data);
}
/**
* Function: save
*
* @param int $id - the id of the screen for which data should be saved
*
* This function saves configuration changes for screens. Most of it is
* straightforward. Since the blocks and agency-stop pairs are stored in
* different tables, the function pulls those data out and saves them in their
* respective tables.
*
*/
public function save($id = 0) {
// MSC check that a new id does not clash with an already-created ID
// Load the screen model
$this->load->model('screen_model');
// Create a placeholder screen that will be filled with variables and then saved.
$updatevals = new Screen_model();
$updatevals->id = $id;
// Admins can't own screens
if (!$this->session->userdata('admin')) {
$updatevals->user_id = $this->session->userdata('id');
}
// Collect all the posted variables from the HTML form into one variable for
// easier access. Delete the submit "variable", which is really just the
// submit button.
$postvars = $this->input->post();
unset($postvars->submit);
// For each of the variables, check to see if the variable name ends with _op (opening)
// or _cl (closing). If so, these variables are the sleep and wake times for the screen.
// We only want to write them if they have values. Beware that Code Igniter
// may treat blank submission as an empty string, which cannot be written
// to a timestamp type in PostgreSQL.
foreach($postvars as $key => $value){
if(substr($key, strlen($key)-3) == '_op' || substr($key, strlen($key)-3) == '_cl'){
if(strlen($value) > 0){
$updatevals->$key = $value;
}
}
else {
$updatevals->$key = $value;
}
}
// Call a function that now writes these values to the database.
$updatevals->save_screen_values($id);
// Redirect the user back to the edit screen to see the changes he just
// made. If he created a new screen or changed the screen id, he may
// be directed back to the screen listing page.
if($updatevals->id == $id){
redirect("screen_admin/edit/$id");
}
else {
redirect('screen_admin');
}
}
}
?>
| php | MIT | 152cd2d808675d2baeb9e77c229adfbaf9a16475 | 2026-01-05T05:21:15.334872Z | false |
MobilityLab/TransitScreen | https://github.com/MobilityLab/TransitScreen/blob/152cd2d808675d2baeb9e77c229adfbaf9a16475/application/controllers/welcome.php | application/controllers/welcome.php | <?php if (!defined('BASEPATH')) exit('No direct script access allowed');
class Welcome extends CI_Controller
{
function __construct()
{
parent::__construct();
//$this->load->helper('url');
//$this->load->library('tank_auth');
}
function index()
{
redirect('/login/');
}
}
/* End of file welcome.php */
/* Location: ./application/controllers/welcome.php */ | php | MIT | 152cd2d808675d2baeb9e77c229adfbaf9a16475 | 2026-01-05T05:21:15.334872Z | false |
MobilityLab/TransitScreen | https://github.com/MobilityLab/TransitScreen/blob/152cd2d808675d2baeb9e77c229adfbaf9a16475/application/controllers/update.php | application/controllers/update.php | <?php
/**
* Class: Update
*
* This class is really more of a behind-the-scenes class that just works to
* produce JSON data for the screens to read. The screens will check in for
* two reason: they need to get updated arrival data or they need to check if
* they need to do a page refresh.
*
* Since this function's purpose is to return JSON data and since the json_encode()
* php function does this easily, this controller class does not need to call
* views the way that other controller classes need to.
*
*/
class Update extends CI_Controller {
/**
* Generic constructor
*/
public function __construct() {
parent::__construct();
}
/**
* Function: index
* @param int $id - This vestigial function may be removed. However, you
* may find it helpful for testing purposes in the future.
*/
public function index($id = 0) {
/*$this->load->model('screen_model');
$this->load->helper('render_admin_helper');
$data['rows'] = $this->screen_model->get_screens_by_user_id();
//$data['main_content'] = 'screen_listing';
print $id;
$this->load->view('includes/template', $data);*/
}
/**
* Function: version
*
* @param int $screen_id - Id of the screen whose version is to be checked
*
* Each screen calls this function for the sole purpose of determining
* whether it needs to refresh itself. The function takes numerous
* configuration variable and hashes them together. It then passes that hash
* back to the screen. If this new hash differs from the screens current hash,
* then it knows it needs to refresh since the screen configuration has changed.
*
* It is important only to hash static configuration data, as including any
* dynamic data in the hash would result in screens refreshing everytime a
* bus prediction updated.
*/
public function version($screen_id){
// Load the screen model and fill it with its values
$this->load->model('screen_model');
$screen = new Screen_model();
$screendata = $this->screen_model->get_screen_values($screen_id);
// Remove the following variables from the hash: the id, the sleep and wake
// times, the name, and the last checkin time. This information does not
// relate to the actual screen layout and should be excluded. Note that the
// sleep and wake status is determined by the server and not the screen
// itself. This would require that each screen have the accurate time set,
// which is something we should not assume.
unset($screendata['settings'][0]->id);
unset($screendata['settings'][0]->MoTh_op);
unset($screendata['settings'][0]->MoTh_cl);
unset($screendata['settings'][0]->Fr_op);
unset($screendata['settings'][0]->Fr_cl);
unset($screendata['settings'][0]->Sa_op);
unset($screendata['settings'][0]->Sa_cl);
unset($screendata['settings'][0]->Su_op);
unset($screendata['settings'][0]->Su_cl);
unset($screendata['settings'][0]->name);
unset($screendata['settings'][0]->last_checkin);
// This is an interesting hashing method: essentially, print out all of the
// relevant configuration functions as one big string and hash that string.
$hash = md5(print_r($screendata,true));
// Return that hash value as JSON
print json_encode($hash);
// Remember that there is no view necessary here since the json_encode() php
// function does the job.
}
/**
* Function: json
* @param int $screen_id - The id of the screen whose updates you need to load
*
* This is one of the biggest and most complicated functions in the application.
* It generates the JSON data update for every screen. More specifically, it
* loads a screen, ensures that it should be awake at this moment, and gets all
* the blocks. For each block it finds the agency-stop pairs and calls the
* appropriate APIs to get the real-time transit data. It assembles all this
* information, including the custom block data and the CaBi status and prints
* it all out as one JSON response.
*/
public function json($screen_id) {
// Load the Update model and the screen model
$this->load->model('update_model');
$update = new Update_model();
$this->load->model('screen_model');
$screen = new Screen_model();
// Fill this variable with the screen values.
$screendata = $this->screen_model->get_screen_values($screen_id, true);
//Load variable of screen model type
$screen->load_model($screen_id);
// We will collect all the data to publish via JSON in the $update variable,
// so set a few of its static properties based on the screendata variable.
$update->screen_name = $screendata['settings'][0]->name;
$update->screen_version = $screendata['settings'][0]->screen_version;
$wmata_key = $screendata['settings'][0]->wmata_key;
// Update the last_checkin value for this screen. This allows us to ensure
// that our screens are regularly calling for updates.
$this->_update_timestamp($screen_id);
// If the screen should be asleep right now, print that in JSON and do not
// bother to load any real-time data.
if($screen->is_asleep()) {
$update->sleep = true;
print json_encode($update);
}
else {
//Gather all the necessary data into the $update variable
//and then output the variable as JSON
// This helper contains the fuctions that call the various agency APIs
$this->load->helper('transit_functions');
// Obviously this screen should be awake.
$update->sleep = false;
$stopname = '';
// For every block... (remember that one block can contain more than one
// stop or CaBi station!)
foreach($screendata['blocks'] as $block){
$stops = $block->stop;
//Set up (or clear) variables to handle the various data
$vehicles = array();
unset($bike);
$bikes = array();
unset($override);
// For each of the agency-stop pairs for this block...
foreach($stops as $stop){
// ... get the arrival predictions for each agency.
// Collected the line exclusions for this block
$exclusions = array();
if(isset($stop['exclusions'])){
$exclusions = explode(',', $stop['exclusions']);
}
// For this agency-stop pair, check to see what mode it is and then
// call the approriate API function.
switch($this->_get_agency_type($stop['agency'])){
case 'bus':
$newset = array();
// Get the bus prediction data back. This get_bus_predictions
// function covers ART, WMATA, DC Circulator, Prince George's TheBus and Shuttle UM
$set = get_bus_predictions($stop['stop_id'],$wmata_key,$stop['agency']);
if(isset($set[0])){
// Loop through the results. If the bus line is not in the
// exclusions array, add it to a new set. We will abandon the
// excluded lines.
foreach($set as $b){
if(!in_array(strtoupper($b['route']),$exclusions)){
$newset[] = $b;
}
}
$vehicles[] = $newset;
}
break;
case 'subway':
// Get predictions from WMATA for rail station with id $stop['stop_id').
$vehicles[] = get_rail_predictions($stop['stop_id'],$wmata_key);
break;
case 'cabi':
// For each bike station, get the status. Notice that the data
// will be put into the $bikes array since each block may have
// multiple CaBi stations.
$bikes[] = get_cabi_status($stop['stop_id']);
break;
case 'custom':
// This is where the custom block data goes. There is no clean up.
$override = $block->custom_body;
break;
}
}
// Combine the different agency predictions for this stop
// into a single array and sort by time. Make sure you have actual
// predictions first!
if(count($vehicles) > 0){
if($this->_get_agency_type($stop['agency']) == 'bus') {
// Combine multi-agency data for buses, then combine same routes
$stopdata = combine_agencies($vehicles);
$stopdata = $this->_combine_duplicates($stopdata);
}
elseif ($this->_get_agency_type($stop['agency']) == 'subway') {
// Combine same routes data for subway
$stopdata = $vehicles[0];
$stopdata = $this->_combine_duplicates($stopdata);
}
else {
$stopdata = $vehicles[0];
}
// If there is a limit to the number of arrival lines to list
// at any bus stop, remove the extra vehicles from the array
if((isset($block->limit) && isset($stopdata)) && (count($stopdata) > $block->limit) && $block->limit > 0){
array_splice($stopdata,$block->limit);
}
// Set the stop name to the API stop name that comes first. WMATA and
// ART will have different descriptions for the same stop, but we will
// just use the first name instead. You can override this with a
// custom stop name in the backend, of course.
if(isset($vehicles[0][0]['stop_name'])){
$stopname = $vehicles[0][0]['stop_name'];
}
}
// If we're working with CaBi here
if(isset($bike)){
$stopdata = $bike;
$stopname = $bike['stop_name'];
}
// Set the stop's custom name
if(strlen(trim($block->custom_name)) > 0 ) {
$stopname = $block->custom_name;
}
// If we're working with bikes, put all the relevant block data into
// an array. Otherwise, do the same for a bus or Metro block.
if(isset($bikes) && count($bikes) > 0){
$stopdata = array(
'id' => $block->id,
'name' => clean_destination($stopname),
'type' => $this->_get_agency_type($stop['agency']),
'column' => (int) $block->column,
'order' => (int) $block->position,
'stations' => $bikes
);
}
else {
$stopdata = array(
'id' => $block->id,
'name' => clean_destination($stopname),
'type' => $this->_get_agency_type($stop['agency']),
'column' => (int) $block->column,
'order' => (int) $block->position,
'vehicles' => $stopdata
);
}
// If this block is a custom block, put in the data here.
if(isset($override)){
$stopdata = array(
'id' => $block->id,
'name' => clean_destination($stopname),
'type' => $this->_get_agency_type($stop['agency']),
'column' => (int) $block->column,
'order' => (int) $block->position,
'custom_body' => $override
);
}
// Add all the stop data for this block to the stops array in the $update
// variable.
$update->stops[] = $stopdata;
}
// Print out the entire $update variable encoded as JSON
print json_encode($update);
}
}
/**
* Function: _combine_duplicates
* @param array $predictions
* @return array
*
* That the word 'private' precedes 'function' means that this is a private
* function only available within this class. It is also common in php to
* prefix an underscore to the name of a private function.
*
* This function combines arrival predictions by route. For instence, there
* is no need to have three lines devoted to X2 buses when we can have one
* line with the next bus prediction highlighted and the subsequent arrivals
* in small text. This requires us to combine these predictions by line number
* and destination.
*
* The return is an array with the predictions grouped into their respective
* lines.
*
*/
private function _combine_duplicates($predictions){
// This array will hold the returned data.
$newout = array();
for($p = 0; $p < count($predictions); $p++){
// Hash together the route and the destination. Since some buses have the
// same route number, but different destinations, we will have to treat
// such buses as separate lines.
$rdhash = hash('adler32', $predictions[$p]['route'] . $predictions[$p]['destination']);
// If the route already exists, just add the prediction
if(isset($newout[$rdhash])){
$newout[$rdhash]['predictions'][] = $predictions[$p]['prediction'];
}
else {
$newout[$rdhash] = array(
'agency' => $predictions[$p]['agency'],
'route' => $predictions[$p]['route'],
'destination' => $predictions[$p]['destination'],
'predictions' => array(0 => $predictions[$p]['prediction'])
);
}
}
$io = array();
// Replace the hash keys with a normal integer index
foreach($newout as $item){
$io[] = $item;
}
// Return the new, clean array.
return $io;
}
/**
* Function: _get_agency_type
* @param string $agency - the string representing the agency name
* @return string - the mode
*
* This private funciton takes the agency name and returns the mode name.
* This helps associate different agencies that are using the same mode. *
*/
private function _get_agency_type($agency) {
switch(strtolower($agency)){
case 'metrobus':
case 'art':
case 'pgc':
case 'umd':
case 'circulator':
case 'dc-circulator':
return 'bus';
case 'cabi':
return 'cabi';
case 'metro':
case 'metrorail':
return 'subway';
}
return $agency;
}
/**
* Function: _update_timestamp
* @param int $id - the id of the screen whose timestamp needs updating
*
* This funciton updates the "last_checkin" timestamp for the screen. This
* allows an administrator to see the last time the screen checked in for
* updated data.
*
* The database functions here are from CodeIgniter' version of Active Record.
*
*/
private function _update_timestamp($id){
$this->db->where('id', $id);
//Postgres format must be ISO 8601, e.g. 2012-01-16 14:43:55
$this->db->update('screens', array(
'last_checkin' => date('c')
));
}
}
?>
| php | MIT | 152cd2d808675d2baeb9e77c229adfbaf9a16475 | 2026-01-05T05:21:15.334872Z | false |
MobilityLab/TransitScreen | https://github.com/MobilityLab/TransitScreen/blob/152cd2d808675d2baeb9e77c229adfbaf9a16475/application/controllers/screen.php | application/controllers/screen.php | <?php
/**
* Class: Screen
*
* This class represents a screen and orchestrates all the page construction
* features for every screen.
*
*/
class Screen extends CI_Controller {
/**
* Basic constructor
*/
public function __construct() {
parent::__construct();
}
/**
* Function: index
* @param int $screenid - This is the id of the screen you wish to load *
*
* This calls the screen_wrapper view and passes it data, including the id
* of the screen to load.
*/
public function index($screenid) {
$data['id'] = $screenid;
$this->load->view('includes/screen_wrapper',$data);
}
/**
* Function: inner
* @param int $screenid - The id of the screen you wish to load
*
* This function differs from the index function in that this function, that is
* /screen/inner is called by the inner IFRAME.
*/
public function inner($screenid) {
//If no parameter, redirect somewhere else
if(!isset($screenid)){
redirect('/');
}
// Load the screen model
$this->load->model('screen_model');
$screen = new Screen_model();
//Load variables of screen model type
$screen->load_model($screenid);
$data['id'] = $screenid;
// Check for sleep mode to determine the view. If the screen is asleep,
// just use the default three_col. If the screen should be awake, set up
// a $data variable and set the numcols to the number of columns and the
// zoom level to the custom zoom level.
if($screen->is_asleep()) {
$data['numcols'] = 3;
$data['template'] = 'three_col';
}
else {
$data['numcols'] = $screen->get_num_columns();
$data['zoom'] = $screen->zoom;
}
// Call the screen_template view and pass the $data variable. Each
// element of the $data array will become a variable, i.e. $data['id'] will
// become $id in the views
$this->load->view('includes/screen_template', $data);
}
}
?>
| php | MIT | 152cd2d808675d2baeb9e77c229adfbaf9a16475 | 2026-01-05T05:21:15.334872Z | false |
MobilityLab/TransitScreen | https://github.com/MobilityLab/TransitScreen/blob/152cd2d808675d2baeb9e77c229adfbaf9a16475/application/models/screen_model.php | application/models/screen_model.php | <?php
/**
* Class: Screen_model
*
* This is the model used to represent a screen, including its wake and sleep times,
* id, name, zoom value, and all the various associated blocks.
*
*/
class Screen_model extends CI_Model {
// These variables correspond to the fields in screens table
var $id = 0;
var $name = '';
var $MoTh_op = '00:00:00';
var $MoTh_cl = '24:00:00';
var $Fr_op = '00:00:00';
var $Fr_cl = '24:00:00';
var $Sa_op = '00:00:00';
var $Sa_cl = '24:00:00';
var $Su_op = '00:00:00';
var $Su_cl = '24:00:00';
var $screen_version = 0;
var $zoom = 1;
var $lat = 0;
var $lon = 0;
var $wmata_key = '';
var $user_id = 0;
// These correspond to the related records in the blocks and agency_stop tables
var $stop_ids = array();
var $pair_ids = array();
var $stop_names = array();
var $stop_columns = array();
var $stop_positions = array();
var $stop_custom_bodies = array();
var $stop_limits = array();
var $new_stop_ids = array();
var $new_stop_names = array();
var $new_stop_columns = array();
var $new_stop_positions = array();
var $new_stop_custom_bodies = array();
var $new_stop_limits = array();
/**
* Generic constructor
*/
public function __construct(){
parent::__construct();
}
/**
* Function: load_model
*
* @param int $id - the id of the screen (record)
*
* This function loads all the values from the database into the model. Remember
* that it's calling from 3 different data tables to assemble this model.
*
* Since the data are stored in the model's properties, nothing is actually
* returned.
*
*/
public function load_model($id){
$this->id = $id;
//Query the screen data
$this->db->select('id, name, MoTh_op, MoTh_cl, Fr_op, Fr_cl, Sa_op, Sa_cl, Su_op, Su_cl, screen_version, zoom, lat, lon, wmata_key');
$q = $this->db->get_where('screens',array('id' => $id));
if ($q->num_rows() > 0) {
//Place the screen data into the object
$result = $q->result();
foreach($result[0] as $key => $value) {
$this->$key = $value;
}
}
//Query the block data
$this->db->select('id, stop, custom_name, column, position, custom_body, limit');
$q = $this->db->get_where('blocks',array('screen_id' => $this->id));
//Place the data into the arrays of this object
if ($q->num_rows() > 0) {
foreach($q->result() as $row){
$serialstops = $this->_assemble_stops($row->id);
$newidrow[$row->id] = $row->stop;
$newnamerow[$row->id] = $row->custom_name;
$newcolumnrow[$row->id] = $row->column;
$newpositionrow[$row->id] = $row->position;
$newcustombodyrow[$row->id] = $row->custom_body;
$newlimitrow[$row->id] = $row->limit;
$this->stop_ids[] = $newidrow[$row->id];
$this->stop_names[] = $newnamerow[$row->id];
$this->stop_columns[] = $newcolumnrow[$row->id];
$this->stop_positions[] = $newpositionrow[$row->id];
$this->stop_custom_bodies[] = $newcustombodyrow[$row->id];
$this->stop_limits[] = $newlimitrow[$row->id];
}
}
}
/**
* Function: _assemble_stops
*
* @param int $parentid - the id of the parent block
* @param bool $separate_excl - whether the exclusions should be separated
* @return string
*
* This function assembles the stops based on the parent block since each block
* can have multiple stops associated with it.
*
* Note that this is a private function and as such can only be accessed from
* within this class.
*
*/
private function _assemble_stops($parentid, $separate_excl = false){
$output = array();
// Get all the agency_stop pairs affiliated with the specified block
$this->db->select('id,agency,stop_id,exclusions');
$q = $this->db->get_where('agency_stop', array('block_id' => $parentid));
// Assemble all these responses into an array
if($q->num_rows() > 0) {
foreach($q->result() as $row){
$rowarray['agency'] = $row->agency;
$rowarray['stop_id'] = $row->stop_id;
if(strlen($row->exclusions) > 0){
if($separate_excl){
$rowarray['exclusions'] = strtoupper($row->exclusions);
}
else {
$rowarray['stop_id'] .= '-' . $row->exclusions;
}
}
$output[$row->id] = $rowarray;
}
}
// Return an array containing the agency names, their stops, and any lines that
// should be excluded.
return $output;
}
/**
* Function: get_screens_by_user_id
*
* @param int $id - the user_id of the screen owner
* @return array
*
* Get a listing of all the screens and return them in an array. Eventually this
* function should differentiate between users since different users will have access
* only to their respective screens.
*
*/
public function get_screens_by_user_id($user_id = 0){
// Get all the screens' names and sort by the name
$this->db->order_by('name', 'asc');
$q = $this->db->get('screens');
if($q->num_rows() > 0) {
foreach($q->result() as $row) {
$data[] = $row;
}
return $data;
}
}
/**
* Function: get_screen_values
*
* @param int $id - the id of the screen to load
* @param bool $separate_excl - whether to exclude bus lines mentioned in the exclusion field
* @return array
*
* This function gets all the screen static values and puts them into an array along with
* the associated blocks and agency-stop pairs. All the data are returned in an array which can
* be used to populate the screen editor page.
*
*/
public function get_screen_values($id, $separate_excl = false) {
// Get all the screen's configuration values
$this->db->select('id, MoTh_op, MoTh_cl, Fr_op, Fr_cl, Sa_op, Sa_cl, Su_op, Su_cl, name, screen_version, zoom, lat, lon, wmata_key');
if($id == 0){
$q = $this->db->get('screens',1);
}
else {
$q = $this->db->get_where('screens',array('id' => $id));
}
// Load the values in to an array that will be used to populate the screen
// editor screen
if ($q->num_rows() > 0) {
foreach($q->result() as $row) {
if($id == 0){
foreach($row as $key => $value){
$blankrow[$key] = '';
}
$row = (object)$blankrow;
$data['settings'][] = $row;
}
else {
$data['settings'][] = $row;
}
}
// Now get the individual block data for this screen.
$this->db->select('id, stop, custom_name, column, position, custom_body, limit');
$this->db->order_by('column', 'asc');
$this->db->order_by('position', 'asc');
$q = $this->db->get_where('blocks',array('screen_id' => $id));
if($q->num_rows() > 0){
foreach($q->result() as $row){
$stopstring = '';
$stoppairs = $this->_assemble_stops($row->id, $separate_excl);
foreach($stoppairs as $pairing){
$stopstring .= implode(':',$pairing) . ';';
}
$row->stop = $stoppairs;
$data['blocks'][] = $row;
}
}
// Return an array with all the data that can be used to populate
// a screen editor.
return $data;
}
}
/**
* Function: save_screen_values
* @param bool $create - true if a screen is being created, otherwise false
*
* This function takes all the screen values and then writes them to the
* relevant database tables. This function is employed whenever someone
* updates the screen settings. Since the purpose of the function is to
* write settings, no values are returned.
*
*/
public function save_screen_values($create) {
//Load the model setting into an array that will be written to the db
$data = array(
'id' => $this->id,
'name' => $this->name,
'MoTh_op' => $this->MoTh_op,
'MoTh_cl' => $this->MoTh_cl,
'Fr_op' => $this->Fr_op,
'Fr_cl' => $this->Fr_cl,
'Sa_op' => $this->Sa_op,
'Sa_cl' => $this->Sa_cl,
'Su_op' => $this->Su_op,
'Su_cl' => $this->Su_cl,
'screen_version' => $this->screen_version,
'zoom' => $this->zoom,
'lat' => $this->lat,
'lon' => $this->lon,
'wmata_key' => $this->wmata_key,
'user_id' => $this->user_id
);
if($create){
$this->db->insert('screens',$data);
}
else {
$this->db->where('id', $this->id);
$this->db->update('screens', $data);
}
// For each agency-stop pair, you will need to split out agency names,
// stop ids, and the bus exclusion lines. All will be written to the
// agency_stop table.
// The data will appear in the [agency]:[stop]-[exclusion] format, e.g.
// metrobus:6001234 or metrobus:6001234-x2
foreach($this->stop_ids as $key => $value){
unset($blockdata);
$oldpairs = array();
$newpairs = array();
$k = explode(',',$this->pair_ids[$key]);
// Explode the string into an array with the comma as a delimiter
// between different stop pairs.
$stop_pairs = explode(';',$value);
// For each stop pair, see if there is an exclusion value appended with
// a hyphen. Write the data to an array of new blocks if this is new or
// write to an array of existing blocks. These arrays are just theoretical
// and will be written to the db a little later down.
foreach($stop_pairs as $skey => $svalue){
$as = explode(':',$svalue);
$se = explode('-',$as[1]);
if(count($se) == 2) {
$exclusions = $se[1];
}
else {
$exclusions = null;
}
if(isset($k[$skey])){
$oldpairs[$k[$skey]] = array(
'agency' => $as[0],
'stop_id' => $se[0],
'exclusions' => $exclusions
//'stop_id' => $as[1]
);
}
else {
$newpairs[] = array(
'agency' => $as[0],
'stop_id' => $se[0],
'exclusions' => $exclusions
//'stop_id' => $as[1]
);
}
}
// Write the updated stop pairs and the new stop pairs to the db. The
// key refers to the parent block's id.
$this->_add_stop_pairs($oldpairs,$newpairs,$key);
// Now time to write the actual block data to the db. Prepare it in an
// array.
$blockdata = array (
'custom_name' => $this->stop_names[$key],
'column' => $this->stop_columns[$key],
'position' => $this->stop_positions[$key],
'custom_body' => $this->stop_custom_bodies[$key],
'limit' => $this->stop_limits[$key]
);
// If the user saved the block as empty, delete it.
if(strlen(trim($value)) == 0 && strlen(trim($blockdata['custom_name'])) == 0){
$this->db->delete('agency_stop', array('block_id' => $key));
$this->db->delete('blocks', array('id' => $key));
}
else { // Otherwise update the block with updated settings
$this->db->where('id', $key);
$this->db->update('blocks', $blockdata);
}
}
// For each of the new blocks, create an array with the new blocks' values
// and insert them into the db.
foreach($this->new_stop_ids as $key => $value){
unset($blockdata);
if(strlen(trim($value)) > 0){
$blockdata = array (
'custom_name' => $this->new_stop_names[$key],
'screen_id' => $this->id,
'column' => $this->new_stop_columns[$key],
'position' => $this->new_stop_positions[$key],
'custom_body' => $this->new_stop_custom_bodies[$key],
'limit' => $this->new_stop_limits[$key]
);
$this->db->insert('blocks', $blockdata);
$newid = $this->db->insert_id();
$stops = explode(';',$value);
foreach($stops as $stop){
$pairings = explode(':',$stop);
$newstop = array(
'agency' => $pairings[0],
'stop_id' => $pairings[1],
'block_id' => $newid
);
$this->db->insert('agency_stop',$newstop);
}
}
}
}
/**
* Function: _add_stop_pairs
*
* @param array $old - existing agency-stop pairs that were updates
* @param array $new - new agency-stop pairsto be added
* @param int $block_id - the id of the parents block
*
* This function receives two arrays, one of existing stop pairs and an array
* of new stop pairs. The existing stop pairs just get updated whereas the
* new stop pairs get inserted and associated with the parent block. Since
* this function just updates the db, it does not return anything.
*
*/
private function _add_stop_pairs($old, $new, $block_id){
foreach($old as $key => $value){
if($key > 0){
$this->db->where('id', $key);
$this->db->update('agency_stop', $old[$key]);
}
}
foreach($new as $pair){
$pair['block_id'] = $block_id;
$this->db->insert('agency_stop',$pair);
}
}
/**
* Function is_asleep
*
* @return bool
*
* This function reads the screens sleep and wake times and the current time
* and day of the week to determine if the screen should be asleep right now
* (return true) or if it should be awake (return false).
*/
public function is_asleep(){
$today = date('D'); // Day of week, e.g. Fri
$time = (int) date('Gis'); // Time of day, e.g. 8 am (8:00:00) formatted as 80000
$morningdivide = 50000; // Time in the morning, e.g. 50000 (5 am) when
// open-close calculations should switch
switch($today){
case 'Sun':
$hours = array(
'yesterday_close' => $this->Sa_cl,
'open' => $this->Su_op,
'close' => $this->Su_cl
);
break;
case 'Tue':
case 'Wed':
case 'Thu':
$hours = array(
'yesterday_close' => $this->MoTh_cl,
'open' => $this->MoTh_op,
'close' => $this->MoTh_cl
);
break;
case 'Mon':
$hours = array(
'yesterday_close' => $this->Su_cl,
'open' => $this->MoTh_op,
'close' => $this->MoTh_cl
);
break;
case 'Fri':
$hours = array(
'yesterday_close' => $this->MoTh_cl,
'open' => $this->Fr_op,
'close' => $this->Fr_cl
);
break;
case 'Sat':
$hours = array(
'yesterday_close' => $this->Fr_cl,
'open' => $this->Sa_op,
'close' => $this->Sa_cl
);
break;
}
foreach($hours as $key => $value){
$hours[$key] = (int) str_replace(':','',$value);
}
// If yesterday's close is early in this morning and the current
// time is in the morning just before that time, sleep = false
if($hours['yesterday_close'] < $morningdivide && $time < $hours['yesterday_close']){
return false;
}
// If it's after opening time...
if($time >= $hours['open']){
// If the closing time is early the next morning, sleep = false
if($hours['close'] < $morningdivide){
return false;
}
// If the current time after close, sleep = true
if($time > $hours['close']){
return true;
}
// In all other cases, e.g. most daytime hours, sleep = false
return false;
}
else {
return true;
}
}
/**
* Function: get_num_columns
*
* @return int
*
* This function looks for and returns the highest column marked for any
* block associated with the screen. This function is used elsewhere to
* generate the screen page with X number of blank columns.
*
*/
public function get_num_columns() {
$max = 0;
$this->db->select('column');
$q = $this->db->get_where('blocks',array('screen_id' => $this->id));
if($q->num_rows() > 0){
foreach($q->result() as $row){
$thiscol = $row->column;
if($thiscol > $max){
$max = $thiscol;
}
}
}
return $max;
}
}
?>
| php | MIT | 152cd2d808675d2baeb9e77c229adfbaf9a16475 | 2026-01-05T05:21:15.334872Z | false |
MobilityLab/TransitScreen | https://github.com/MobilityLab/TransitScreen/blob/152cd2d808675d2baeb9e77c229adfbaf9a16475/application/models/update_model.php | application/models/update_model.php | <?php
/**
* Class: Update_model
*
* This is the model that represents updates. It is called by the update
* controller, which is itself invoked whenever a screen looks for an update.
*
*/
class Update_model extends CI_Model {
// These are properties set to defaults.
var $screen_name = '';
var $screen_version = 1323896592;
var $sleep = false;
var $stops = array();
/**
* Default constructor
*/
public function __construct(){
parent::__construct();
}
/**
* Function load_model
* @param int $id - the ide of the screen to load
*
* This function loads the modele's properties with screen values from the
* database.
*
*/
public function load_model($id){
$this->id = $id;
//Query the screen data
$this->db->select('MoTh_op, MoTh_cl, Fr_op, Fr_cl, Sa_op, Sa_cl, Su_op, Su_cl, name');
$q = $this->db->get_where('screens',array('id' => $id));
if ($q->num_rows() > 0) {
//Place the screen data into the object
$result = $q->result();
foreach($result[0] as $key => $value) {
$this->$key = $value;
}
}
//Query the block data
$this->db->select('id, stop, custom_name, column, position');
$q = $this->db->get_where('blocks',array('screen_id' => $this->id));
//Place the data into the arrays of this object
if ($q->num_rows() > 0) {
}
}
/**
* Function: get_screen_values
* @param int $id - the id of the screen
* @return array - return an array with the screen settings
*
* This function gets all the screen configuration values and puts them
* into an array. The array is then returned.
*
* MSC we should probably not have this duplicate the get_screen_values in screen_model.php
*/
public function get_screen_values($id) {
// Get all the screen's configuration values
$this->db->select('id, MoTh_op, MoTh_cl, Fr_op, Fr_cl, Sa_op, Sa_cl, Su_op, Su_cl, name');
if($id == 0){
$q = $this->db->get('screens',1);
}
else {
$q = $this->db->get_where('screens',array('id' => $id));
}
// Load the values in to an array that will be used
if ($q->num_rows() > 0) {
foreach($q->result() as $row) {
if($id == 0){
foreach($row as $key => $value){
$blankrow[$key] = '';
}
$row = $blankrow;
$data['settings'][] = $row;
}
else {
$data['settings'][] = $row;
}
}
// Now get the individual block data for this screen.
$this->db->select('id, stop, custom_name, column, position');
$this->db->order_by('column', 'desc');
$this->db->order_by('position', 'desc');
$q = $this->db->get_where('blocks',array('screen_id' => $id));
if($q->num_rows() > 0){
foreach($q->result() as $row){
$data['blocks'][] = $row;
}
}
return $data;
}
}
}
?>
| php | MIT | 152cd2d808675d2baeb9e77c229adfbaf9a16475 | 2026-01-05T05:21:15.334872Z | false |
MobilityLab/TransitScreen | https://github.com/MobilityLab/TransitScreen/blob/152cd2d808675d2baeb9e77c229adfbaf9a16475/application/models/user_model.php | application/models/user_model.php | <?php
/**
* Class: User_model
*
* This simple model represents a logged in user to the system. Since Phase 1
* development only accounts for an administrative user and not for the public
* we the class's functions are limited to some basic function.
*
*/
class User_model extends CI_Model {
// Class properties. Account type is for future use.
public $id = '';
public $username = '';
public $password = '';
public $admin = 0;
/*
* Generic constructor
*/
public function __construct(){
parent::__construct();
// This is a Code Igniter feature.
$this->output->enable_profiler(TRUE);
// error reporting //
error_reporting(E_ALL);
}
/**
* Function: create_user
*
* @param array $data - an array of data used to create a user
* @return NULL
*
* This is a function not in use right now, but can be used later when adding
* functionality to create new users.
*
*/
public function create_user($data){
$data->password = md5($data->password);
if($this->db->insert($this->table, $data)) {
$id = $this->db->insert_id();
}
return NULL;
}
/**
* Function: get_user_by_id
*
* @param int $user_id - the user id of the user whose settings yo want to load
* @return array or null
*
* This function returns user information from the db based on the id it has
* been passed. This may not be in actual use yet.
*
*/
public function get_user_by_id($user_id) {
$this->db->where('id',$user_id);
$query = $this->db->get($this->table);
if($query->num_rows() == 1){
return $query->row();
}
else {
return NULL;
}
}
/**
* Function: get_user_by_username
*
* @param string $username
* @return array or null
*
* This function returns user data based on the user name instead of the
* user id. This function may not be in use at this time.
*
*/
public function get_user_by_username($username){
$this->db->where('email',$username);
$query = $this->db->get($this->table);
if($query->num_rows() == 1){
return $query->row();
}
else {
return NULL;
}
}
/**
* Function: validate
*
* @return User_model
*
* This function validates the user credentials in the class properties
* against what's stored in the db. If the user name and password match a
* record, then the user object is returned with the user name and id as
* object properties. This function is necessary to log users, including
* the administrator, in properly.
*
*/
public function validate() {
$this->db->where('email', $this->input->post('username'));
$this->db->where('password', md5($this->input->post('password')));
$query = $this->db->get('users');
if($query->num_rows() == 1) {
$row = $query->row();
$user = new User_model();
$user->id = $row->id;
$user->admin = $row->admin; // 1 for admin, 0 for regular user
$user->username = $row->email; // current db schema uses email
return $user;
}
}
}
?>
| php | MIT | 152cd2d808675d2baeb9e77c229adfbaf9a16475 | 2026-01-05T05:21:15.334872Z | false |
MobilityLab/TransitScreen | https://github.com/MobilityLab/TransitScreen/blob/152cd2d808675d2baeb9e77c229adfbaf9a16475/application/views/three_col.php | application/views/three_col.php | <?php
print_r($data);
?>
<div class="col" id="col-1">A little bit from column A</div>
<div class="col" id="col-2">A little bit from column B</div>
<div class="col" id="col-3">And a little bit from column C</div>
| php | MIT | 152cd2d808675d2baeb9e77c229adfbaf9a16475 | 2026-01-05T05:21:15.334872Z | false |
MobilityLab/TransitScreen | https://github.com/MobilityLab/TransitScreen/blob/152cd2d808675d2baeb9e77c229adfbaf9a16475/application/views/screen_editor.php | application/views/screen_editor.php | <?php
// This is the screen editor view. It is called from the edit method of the
// screen_admin controller. That is where the $rows array is created.
if($rows['settings'][0]->id != 0){
// Screen exists, get id and title
$id = $rows['settings'][0]->id;
$title = $rows['settings'][0]->name;
$create = false;
}
else {
// Create a random ID
// MSC need to check that ID doesn't exist yet
$id = rand(0,999999);
$rows['settings'][0]->id = $id;
$title = 'Create a new screen';
$create = true;
}
?>
<div id="screen-fields">
<h2><?php print $title; ?></h2>
<h3>Screen Settings</h3>
<?php
// Open the form and set the action attribute
echo form_open("screen_admin/save/$create");
// Create a field set for the screen properties and print them out with
// labels
echo form_fieldset('Operating settings');
foreach($rows['settings'][0] as $key => $value){
echo '<div class="edit-field">';
echo form_label(get_field_alias($key), $key);
echo form_input($key, trim($value));
echo '</div>';
}
echo form_fieldset_close();
// Create a field set for the stops
echo form_fieldset('Stops');
$agencies = array(
'metrobus' => 'Metrobus (WMATA)',
'metrorail' => 'Metrorail (WMATA)',
'dc-circulator' => 'Circulator',
'pgc' => 'pgc',
'umd' => 'umd',
'art' => 'ART'
);
// Print out block section with space for 9 blocks
echo '<ol>';
echo '<div class="column-headers"><span>Stop IDs</span><span>Custom stop name (opt.)</span><span class="header-column">Column</span><span class="header-column">Position</span><span class="header-column-ct">Custom text</span><span>Limit</span></div>';
for($r = 0; $r < 9; $r++) {
// Set the options for the columns, positions, and item limits
for($c = 1; $c < 4; $c++){
$coloptions[$c] = $c;
}
for($p = 1; $p < 10; $p++){
$positionoptions[$p] = $p;
}
$limitoptions[0] = 'none';
for($l = 1; $l < 20; $l++){
$limitoptions[$l] = $l;
}
$serialstring = '';
$pairids = array();
// Write the existing agency-stop pairs to the block boxes
if(isset($rows['blocks'][$r]->stop)){
foreach($rows['blocks'][$r]->stop as $key => $value){
$serialstring .= $value['agency'] . ':' . $value['stop_id'] . ';';
$pairids[] = $key;
}
}
if(strlen($serialstring) > 0){
$serialstring = substr($serialstring, 0, strlen($serialstring) - 1);
}
// Write out the lines for each of the blocks. Existing blocks are written
// out first and empty blocks are written out second (in the else{})
echo '<li class="stop-row">';
if(isset($rows['blocks'][$r])){
//echo form_input('stop_ids[' . $rows['blocks'][$r]->id . ']', $rows['blocks'][$r]->stop);
echo form_input('stop_ids[' . $rows['blocks'][$r]->id . ']', $serialstring);
echo form_hidden('pair_ids[' . $rows['blocks'][$r]->id . ']', implode(',', $pairids));
echo form_input('stop_names[' . $rows['blocks'][$r]->id . ']', $rows['blocks'][$r]->custom_name);
echo form_dropdown('stop_columns[' . $rows['blocks'][$r]->id . ']',$coloptions,$rows['blocks'][$r]->column);
echo form_dropdown('stop_positions[' . $rows['blocks'][$r]->id . ']',$positionoptions,$rows['blocks'][$r]->position);
echo form_input('stop_custom_bodies[' . $rows['blocks'][$r]->id . ']', $rows['blocks'][$r]->custom_body);
echo form_dropdown('stop_limits[' . $rows['blocks'][$r]->id . ']',$limitoptions,$rows['blocks'][$r]->limit);
}
else{
echo form_input("new_stop_ids[$r]",'');
echo form_input("new_stop_names[$r]",'');
echo form_dropdown("new_stop_columns[$r]",$coloptions);
echo form_dropdown("new_stop_positions[$r]",$positionoptions);
echo form_input("new_stop_custom_bodies[$r]",'');
echo form_dropdown("new_stop_limits[$r]",$limitoptions);
}
echo '</li>';
}
echo '</ol>';
echo form_fieldset_close();
echo form_submit('submit', 'Save');
echo form_close();
?>
<?php
$this->load->view('includes/screen_admin_instructions');
?>
</div> | php | MIT | 152cd2d808675d2baeb9e77c229adfbaf9a16475 | 2026-01-05T05:21:15.334872Z | false |
MobilityLab/TransitScreen | https://github.com/MobilityLab/TransitScreen/blob/152cd2d808675d2baeb9e77c229adfbaf9a16475/application/views/welcome_message.php | application/views/welcome_message.php | <!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>Welcome to CodeIgniter</title>
<style type="text/css">
::selection{ background-color: #E13300; color: white; }
::moz-selection{ background-color: #E13300; color: white; }
::webkit-selection{ background-color: #E13300; color: white; }
body {
background-color: #fff;
margin: 40px;
font: 13px/20px normal Helvetica, Arial, sans-serif;
color: #4F5155;
}
a {
color: #003399;
background-color: transparent;
font-weight: normal;
}
h1 {
color: #444;
background-color: transparent;
border-bottom: 1px solid #D0D0D0;
font-size: 19px;
font-weight: normal;
margin: 0 0 14px 0;
padding: 14px 15px 10px 15px;
}
code {
font-family: Consolas, Monaco, Courier New, Courier, monospace;
font-size: 12px;
background-color: #f9f9f9;
border: 1px solid #D0D0D0;
color: #002166;
display: block;
margin: 14px 0 14px 0;
padding: 12px 10px 12px 10px;
}
#body{
margin: 0 15px 0 15px;
}
p.footer{
text-align: right;
font-size: 11px;
border-top: 1px solid #D0D0D0;
line-height: 32px;
padding: 0 10px 0 10px;
margin: 20px 0 0 0;
}
#container{
margin: 10px;
border: 1px solid #D0D0D0;
-webkit-box-shadow: 0 0 8px #D0D0D0;
}
</style>
</head>
<body>
<div id="container">
<h1>Welcome to CodeIgniter!</h1>
<div id="body">
<p>The page you are looking at is being generated dynamically by CodeIgniter.</p>
<p>If you would like to edit this page you'll find it located at:</p>
<code>application/views/welcome_message.php</code>
<p>The corresponding controller for this page is found at:</p>
<code>application/controllers/welcome.php</code>
<p>If you are exploring CodeIgniter for the very first time, you should start by reading the <a href="user_guide/">User Guide</a>.</p>
</div>
<p class="footer">Page rendered in <strong>{elapsed_time}</strong> seconds</p>
</div>
</body>
</html> | php | MIT | 152cd2d808675d2baeb9e77c229adfbaf9a16475 | 2026-01-05T05:21:15.334872Z | false |
MobilityLab/TransitScreen | https://github.com/MobilityLab/TransitScreen/blob/152cd2d808675d2baeb9e77c229adfbaf9a16475/application/views/login_form.php | application/views/login_form.php | <div id="login-form">
<h2>Site login</h2>
<?php
// This is the login form. It uses the Code Igniter form funcitons to
// create and print the form.
echo form_open('login/validate_credentials');
echo form_input('username', set_value('username','Email'), 'onmouseover="this.focus();this.select();"');
echo form_password('password', 'Password', 'onmouseover="this.focus();this.select();"');
echo form_submit('submit', 'Login');
?>
</div>
| php | MIT | 152cd2d808675d2baeb9e77c229adfbaf9a16475 | 2026-01-05T05:21:15.334872Z | false |
MobilityLab/TransitScreen | https://github.com/MobilityLab/TransitScreen/blob/152cd2d808675d2baeb9e77c229adfbaf9a16475/application/views/screen_listing.php | application/views/screen_listing.php | <div id="screen-list">
<h2>Your screens</h2>
<?php if(strlen($msg) > 0): ?>
<div class="msg good-msg">
<?php print $msg; ?>
</div>
<?php endif; ?>
<div class="listing">
<?php foreach($rows as $r): ?>
<div class="list-item"">
<span class="screen-name"><?php print $r->name; ?></span>
<?php echo anchor('screen_admin/edit/' . $r->id, 'edit', array('class' => 'edit-link')); ?>
<?php echo anchor('screen/index/' . $r->id, 'view', array('class' => 'view-link')); ?>
<div class="last-checkin"><span>Last checkin:</span>
<?php if($r->last_checkin > 0): ?>
<?php print date('D, M j, Y, g:i:s a',strtotime($r->last_checkin)); ?>
<?php else: ?>
Never
<?php endif; ?>
</div>
</div>
<?php endforeach; ?>
</div>
<?php echo anchor('screen_admin/edit', 'add', array('class' => 'add-link')); ?>
</div> | php | MIT | 152cd2d808675d2baeb9e77c229adfbaf9a16475 | 2026-01-05T05:21:15.334872Z | false |
MobilityLab/TransitScreen | https://github.com/MobilityLab/TransitScreen/blob/152cd2d808675d2baeb9e77c229adfbaf9a16475/application/views/includes/footer.php | application/views/includes/footer.php | </body>
</html> | php | MIT | 152cd2d808675d2baeb9e77c229adfbaf9a16475 | 2026-01-05T05:21:15.334872Z | false |
MobilityLab/TransitScreen | https://github.com/MobilityLab/TransitScreen/blob/152cd2d808675d2baeb9e77c229adfbaf9a16475/application/views/includes/screen_header.php | application/views/includes/screen_header.php | <?php
$appendix = '?' . time(); // Appending this time integer forces the browser to refresh the file instead of using a cached version
?><!DOCTYPE html>
<html>
<head>
<title>Transit arrival screen</title>
<link rel="stylesheet" href="<?php echo base_url(); ?><?php echo PUBLICDIR; ?>css/screen.css" type="text/css" media="screen">
<script type="text/javascript">
var screen_id = '<?php print $id; ?>';
</script>
<script type="text/javascript" src="<?php echo base_url(); ?><?php echo PUBLICDIR; ?>scripts/jquery-1.7.1.min.js"></script>
<script type="text/javascript" src="<?php echo base_url(); ?><?php echo PUBLICDIR; ?>scripts/jquery.timers-1.2.js"></script>
<script type="text/javascript" src="<?php echo base_url(); ?><?php echo PUBLICDIR; ?>scripts/screen.js<?php print $appendix; ?>"></script>
<link rel="stylesheet" href="<?php echo base_url(); ?><?php echo PUBLICDIR; ?>css/reset.css" type="text/css" media="screen">
<link rel="stylesheet" href="<?php echo base_url(); ?><?php echo PUBLICDIR; ?>css/metro.css" type="text/css" media="screen">
<link rel="stylesheet" href="<?php echo base_url(); ?><?php echo PUBLICDIR; ?>css/cabi.css" type="text/css" media="screen">
<link rel="stylesheet" href="<?php echo base_url(); ?><?php echo PUBLICDIR; ?>css/bus.css" type="text/css" media="screen">
<style type="text/css">
body { background:#000000; margin:20px 20px 0 20px; font-family:"Helvetica Neue",Helvetica,Arial,sans-serif;}
/* 1 column layout */
#one-col { width:98%; margin:0 auto 0 auto;}
/* 2 column layout */
.total-cols-2 .col {
width: 48%;
float: left;
}
.total-cols-2 #col-1 {
margin-right: 32px;
}
/* 3 column layout */
.total-cols-3 .col {
width: 31%;
float: left;
}
.total-cols-3 #col-1 {
margin-right: 32px;
}
.total-cols-3 #col-2 {
margin-right: 32px;
}
#cabi_table td {
vertical-align: middle;
line-height: 1em;
}
body {
zoom: <?php print $zoom; ?>;
}
</style>
</head>
<body class="total-cols-<?php print $numcols; ?>">
| php | MIT | 152cd2d808675d2baeb9e77c229adfbaf9a16475 | 2026-01-05T05:21:15.334872Z | false |
MobilityLab/TransitScreen | https://github.com/MobilityLab/TransitScreen/blob/152cd2d808675d2baeb9e77c229adfbaf9a16475/application/views/includes/screen_template.php | application/views/includes/screen_template.php | <?php
// This is the main page template for the screens.
// Load the screen header, which includes the references to the scripts, CSS,
// and other things.
$this->load->view('includes/screen_header');
// Print out the "Loading" box
print '<div id="loading-box">Loading</div>';
// Generate empty columns
for($c = 1; $c <= $numcols; $c++){
print "<div class=\"col\" id=\"col-$c\"></div>";
}
print '<div id="results"></div>';
// Load the footer template to close out the page.
$this->load->view('includes/screen_footer');
?>
| php | MIT | 152cd2d808675d2baeb9e77c229adfbaf9a16475 | 2026-01-05T05:21:15.334872Z | false |
MobilityLab/TransitScreen | https://github.com/MobilityLab/TransitScreen/blob/152cd2d808675d2baeb9e77c229adfbaf9a16475/application/views/includes/screen_wrapper.php | application/views/includes/screen_wrapper.php | <?php
// This page is the "super page" that loads the IFRAME that contains the actual
// screen information.
$callurl = base_url() . 'index.php/screen/inner/' . $id; // The url to call for prediction updates
$pollurl = base_url() . 'index.php/update/version/' . $id; // The url to call to check whether the screen needs
// needs to be refreshed.
?><html>
<head>
<title>Transit Screen</title>
<meta name="robots" content="none">
<link rel="shortcut icon" href="<?php print base_url(); ?>/public/images/favicon.ico" />
<link rel="apple-touch-icon" href="<?php print base_url(); ?>/public/images/CPlogo.png" />
<script type="text/javascript" src="<?php print base_url(); ?>/public/scripts/jquery-1.7.1.min.js"></script>
<script type="text/javascript" src="<?php print base_url(); ?>/public/scripts/jquery.timers-1.2.js"></script>
<script type="text/javascript">
var now = Math.round(new Date().getTime() / 1000);
var latestv = '';
var frameclass = '';
$(document).ready(function(){
//Call the update function
get_update();
});
// Poll the server to find the latest version number
$(document).everyTime(60000, function(){
get_update();
});
function get_update() {
// Poll the server for the latest version number
$.getJSON('<?php print $pollurl; ?>',function(versionval){
// If that version number differs from the current version number,
// create a new hidden iframe and append it to the body. ID = version num
if(versionval != latestv){
//If the element already exists, remove it and replace it with a new version
if($('#frame-' + versionval).length > 0){
$('#frame-' + versionval).remove();
}
$('<iframe />', {
id: 'frame-' + versionval,
src: '<?php print $callurl; ?>?' + now
}).appendTo('body');
if(frameclass.length > 0)
{
$('#frame-' + versionval).show();
}
if (frameclass== 'hidden')
{
$('#frame-' + versionval).hide();
}
frameclass = 'hidden';
// Wait 20 seconds and call another function to check the status of the new iframe
setTimeout('switch_frames("' + versionval + '");',20000);
}
})
.error(function() {
});
}
function switch_frames(ver) {
var newname = '#frame-' + ver;
//console.log('blocks in ' + newname + ': ' + $(newname).contents().find('.block').length);
// If the new iframe has populated with .blocks, remove the old iframe
// and show the new one
if($(newname).contents().find('.block').length > 0) {
// For each iframe, if the id doesn't equal newname, remove it
$.each($('iframe'), function(i, frame) {
//console.log('frame.id = ' + frame.id + '; compare to: frame' + ver);
if(frame.id != 'frame-' + ver){
$('#' + frame.id).remove();
}
// And show the new iframe by removing the .hidden class
$(newname).attr('class', '');
// Set the latest version variable to the new version
latestv = ver;
//console.log(frame.id);
});
}
// Else, remove the new, hidden iframe
else {
$(newname).remove();
//console.log('Removed ' + newname);
}
}
</script>
<style type="text/css">
body {
margin: 0;
background-color: #000;
}
iframe {
border: 0;
width: 100%;
height: 100%;
}
.hidden {
display: none;
}
</style>
</head>
<body>
<noscript>
<div id="noscript-padding"></div>
<div id="noscript-warning" style="color:red">Transit Screen requires a JavaScript-enabled browser. <a href="https://www.google.com/support/adsense/bin/answer.py?answer=12654" target="_blank">Not sure how to enable it?</a></div>
</noscript>
<script type="text/javascript">
if( navigator.userAgent.match(/Mobile/i) &&
navigator.userAgent.match(/Safari/i)
) {
document.title = "Transit Screen";
}
</script>
</body>
</html> | php | MIT | 152cd2d808675d2baeb9e77c229adfbaf9a16475 | 2026-01-05T05:21:15.334872Z | false |
MobilityLab/TransitScreen | https://github.com/MobilityLab/TransitScreen/blob/152cd2d808675d2baeb9e77c229adfbaf9a16475/application/views/includes/screen_admin_instructions.php | application/views/includes/screen_admin_instructions.php | <div class="instructions">
<h4>Finding Stop IDs</h4>
<p><strong>WMATA, ART, DC Circulator</strong>:
Use <a href="http://transitnearme.com/transitapis/">TransitAPIs</a>. Scroll and zoom the window to contain the desired stop.
Read the "Code" field from the Visible Stops text window.
<p><strong>CaBi</strong>: Use <a href="http://cabitracker.com">CaBiTracker</a>. Click the station you want.
Click the more data link (you may have to scroll down inside the window).
The station id (looks like <code>cabi:198</code>) will appear in the URL address bar of your browser (NOT in the text of the webpage).
<p><strong>TheBus</strong>
Go to the <a href="http://www.nextbus.com/googleMap/?a=pgc&r=11&r=12&r=13&r=14&r=15x&r=16&r=17&r=18&r=20&r=21&r=21x&r=22&r=23&r=24&r=25&r=26&r=27&r=28&r=30&r=32&r=33&r=34&r=35&r=51&r=53">NextBus map</a>. Scroll and zoom the window to contain the desired stop. Click on the stop. Note the route name and copy the stop name.
Go to <a href="http://webservices.nextbus.com/service/publicXMLFeed?command=routeConfig&a=pgc">NextBus API</a> and search for the stop name. The stop name and route will be in the same line of code.
<p><strong>Shuttle UM</strong>
Go to the <a href="http://www.nextbus.com/googleMap/?a=umd&r=701&r=702&r=703&r=104&r=105&r=108&r=109&r=110&r=111&r=113&r=113sat&r=114&r=115&r=116&r=117&r=118&r=122&r=124&r=125&r=126&r=127&r=128&r=129&r=130&r=131&r=132">NextBus map</a>. Scroll and zoom the window to contain the desired stop. Click on the stop. Note the route name and copy the stop name.
Go to <a href="http://webservices.nextbus.com/service/publicXMLFeed?command=routeConfig&a=umd">NextBus API</a> and search for the stop name. The stop name and route will be in the same line of code.
<h4>Formatting Stop IDs</h4>
[agency id]:[stop id], e.g. <code>metrobus:6000123</code>.
<p>For TheBus the format is slightly different; pgc:r=[route name]&s=[stop name], e.g. <code>pgc:r=17&s=balthami </code>
<p>If several agencies serve a single stop, separate each agency-stop combination with semicolons, e.g.
<code>cabi:198;cabi:112</code>. </p>
<p>Agency codes:</p>
<ul>
<li>Metrorail: <code>metrorail</code></li>
<li>Metrobus: <code>metrobus</code></li>
<li>ART: <code>art</code></li>
<li>Circulator: <code>dc-circulator</code></li>
<li>Prince George's TheBus: <code>pgc</code></li>
<li>Shuttle UM: <code>umd</code></li>
<li>Capital Bikeshare: <code>cabi</code></li>
<li>Custom text block: <code>custom</code></li>
</ul>
</div> | php | MIT | 152cd2d808675d2baeb9e77c229adfbaf9a16475 | 2026-01-05T05:21:15.334872Z | false |
MobilityLab/TransitScreen | https://github.com/MobilityLab/TransitScreen/blob/152cd2d808675d2baeb9e77c229adfbaf9a16475/application/views/includes/template.php | application/views/includes/template.php | <?php
// This is the page template for the admin section of the site
// Load the header
$this->load->view('includes/header');
// Load the content template
$this->load->view($main_content);
// Load the footer
$this->load->view('includes/footer');
?>
| php | MIT | 152cd2d808675d2baeb9e77c229adfbaf9a16475 | 2026-01-05T05:21:15.334872Z | false |
MobilityLab/TransitScreen | https://github.com/MobilityLab/TransitScreen/blob/152cd2d808675d2baeb9e77c229adfbaf9a16475/application/views/includes/header.php | application/views/includes/header.php | <!DOCTYPE html>
<html>
<head>
<title></title>
<link rel="stylesheet" href="<?php echo base_url(); ?><?php echo PUBLICDIR; ?>css/style.css" type="text/css" media="screen" />
</head>
<body> | php | MIT | 152cd2d808675d2baeb9e77c229adfbaf9a16475 | 2026-01-05T05:21:15.334872Z | false |
MobilityLab/TransitScreen | https://github.com/MobilityLab/TransitScreen/blob/152cd2d808675d2baeb9e77c229adfbaf9a16475/application/views/includes/screen_footer.php | application/views/includes/screen_footer.php | </body>
</html> | php | MIT | 152cd2d808675d2baeb9e77c229adfbaf9a16475 | 2026-01-05T05:21:15.334872Z | false |
MobilityLab/TransitScreen | https://github.com/MobilityLab/TransitScreen/blob/152cd2d808675d2baeb9e77c229adfbaf9a16475/application/config/doctypes.php | application/config/doctypes.php | <?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
$_doctypes = array(
'xhtml11' => '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">',
'xhtml1-strict' => '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">',
'xhtml1-trans' => '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">',
'xhtml1-frame' => '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Frameset//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-frameset.dtd">',
'html5' => '<!DOCTYPE html>',
'html4-strict' => '<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">',
'html4-trans' => '<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">',
'html4-frame' => '<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Frameset//EN" "http://www.w3.org/TR/html4/frameset.dtd">'
);
/* End of file doctypes.php */
/* Location: ./application/config/doctypes.php */ | php | MIT | 152cd2d808675d2baeb9e77c229adfbaf9a16475 | 2026-01-05T05:21:15.334872Z | false |
MobilityLab/TransitScreen | https://github.com/MobilityLab/TransitScreen/blob/152cd2d808675d2baeb9e77c229adfbaf9a16475/application/config/smileys.php | application/config/smileys.php | <?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
/*
| -------------------------------------------------------------------
| SMILEYS
| -------------------------------------------------------------------
| This file contains an array of smileys for use with the emoticon helper.
| Individual images can be used to replace multiple simileys. For example:
| :-) and :) use the same image replacement.
|
| Please see user guide for more info:
| http://codeigniter.com/user_guide/helpers/smiley_helper.html
|
*/
$smileys = array(
// smiley image name width height alt
':-)' => array('grin.gif', '19', '19', 'grin'),
':lol:' => array('lol.gif', '19', '19', 'LOL'),
':cheese:' => array('cheese.gif', '19', '19', 'cheese'),
':)' => array('smile.gif', '19', '19', 'smile'),
';-)' => array('wink.gif', '19', '19', 'wink'),
';)' => array('wink.gif', '19', '19', 'wink'),
':smirk:' => array('smirk.gif', '19', '19', 'smirk'),
':roll:' => array('rolleyes.gif', '19', '19', 'rolleyes'),
':-S' => array('confused.gif', '19', '19', 'confused'),
':wow:' => array('surprise.gif', '19', '19', 'surprised'),
':bug:' => array('bigsurprise.gif', '19', '19', 'big surprise'),
':-P' => array('tongue_laugh.gif', '19', '19', 'tongue laugh'),
'%-P' => array('tongue_rolleye.gif', '19', '19', 'tongue rolleye'),
';-P' => array('tongue_wink.gif', '19', '19', 'tongue wink'),
':P' => array('raspberry.gif', '19', '19', 'raspberry'),
':blank:' => array('blank.gif', '19', '19', 'blank stare'),
':long:' => array('longface.gif', '19', '19', 'long face'),
':ohh:' => array('ohh.gif', '19', '19', 'ohh'),
':grrr:' => array('grrr.gif', '19', '19', 'grrr'),
':gulp:' => array('gulp.gif', '19', '19', 'gulp'),
'8-/' => array('ohoh.gif', '19', '19', 'oh oh'),
':down:' => array('downer.gif', '19', '19', 'downer'),
':red:' => array('embarrassed.gif', '19', '19', 'red face'),
':sick:' => array('sick.gif', '19', '19', 'sick'),
':shut:' => array('shuteye.gif', '19', '19', 'shut eye'),
':-/' => array('hmm.gif', '19', '19', 'hmmm'),
'>:(' => array('mad.gif', '19', '19', 'mad'),
':mad:' => array('mad.gif', '19', '19', 'mad'),
'>:-(' => array('angry.gif', '19', '19', 'angry'),
':angry:' => array('angry.gif', '19', '19', 'angry'),
':zip:' => array('zip.gif', '19', '19', 'zipper'),
':kiss:' => array('kiss.gif', '19', '19', 'kiss'),
':ahhh:' => array('shock.gif', '19', '19', 'shock'),
':coolsmile:' => array('shade_smile.gif', '19', '19', 'cool smile'),
':coolsmirk:' => array('shade_smirk.gif', '19', '19', 'cool smirk'),
':coolgrin:' => array('shade_grin.gif', '19', '19', 'cool grin'),
':coolhmm:' => array('shade_hmm.gif', '19', '19', 'cool hmm'),
':coolmad:' => array('shade_mad.gif', '19', '19', 'cool mad'),
':coolcheese:' => array('shade_cheese.gif', '19', '19', 'cool cheese'),
':vampire:' => array('vampire.gif', '19', '19', 'vampire'),
':snake:' => array('snake.gif', '19', '19', 'snake'),
':exclaim:' => array('exclaim.gif', '19', '19', 'excaim'),
':question:' => array('question.gif', '19', '19', 'question') // no comma after last item
);
/* End of file smileys.php */
/* Location: ./application/config/smileys.php */ | php | MIT | 152cd2d808675d2baeb9e77c229adfbaf9a16475 | 2026-01-05T05:21:15.334872Z | false |
MobilityLab/TransitScreen | https://github.com/MobilityLab/TransitScreen/blob/152cd2d808675d2baeb9e77c229adfbaf9a16475/application/config/profiler.php | application/config/profiler.php | <?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
/*
| -------------------------------------------------------------------------
| Profiler Sections
| -------------------------------------------------------------------------
| This file lets you determine whether or not various sections of Profiler
| data are displayed when the Profiler is enabled.
| Please see the user guide for info:
|
| http://codeigniter.com/user_guide/general/profiling.html
|
*/
/* End of file profiler.php */
/* Location: ./application/config/profiler.php */ | php | MIT | 152cd2d808675d2baeb9e77c229adfbaf9a16475 | 2026-01-05T05:21:15.334872Z | false |
MobilityLab/TransitScreen | https://github.com/MobilityLab/TransitScreen/blob/152cd2d808675d2baeb9e77c229adfbaf9a16475/application/config/mimes.php | application/config/mimes.php | <?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
/*
| -------------------------------------------------------------------
| MIME TYPES
| -------------------------------------------------------------------
| This file contains an array of mime types. It is used by the
| Upload class to help identify allowed file types.
|
*/
$mimes = array( 'hqx' => 'application/mac-binhex40',
'cpt' => 'application/mac-compactpro',
'csv' => array('text/x-comma-separated-values', 'text/comma-separated-values', 'application/octet-stream', 'application/vnd.ms-excel', 'application/x-csv', 'text/x-csv', 'text/csv', 'application/csv', 'application/excel', 'application/vnd.msexcel'),
'bin' => 'application/macbinary',
'dms' => 'application/octet-stream',
'lha' => 'application/octet-stream',
'lzh' => 'application/octet-stream',
'exe' => array('application/octet-stream', 'application/x-msdownload'),
'class' => 'application/octet-stream',
'psd' => 'application/x-photoshop',
'so' => 'application/octet-stream',
'sea' => 'application/octet-stream',
'dll' => 'application/octet-stream',
'oda' => 'application/oda',
'pdf' => array('application/pdf', 'application/x-download'),
'ai' => 'application/postscript',
'eps' => 'application/postscript',
'ps' => 'application/postscript',
'smi' => 'application/smil',
'smil' => 'application/smil',
'mif' => 'application/vnd.mif',
'xls' => array('application/excel', 'application/vnd.ms-excel', 'application/msexcel'),
'ppt' => array('application/powerpoint', 'application/vnd.ms-powerpoint'),
'wbxml' => 'application/wbxml',
'wmlc' => 'application/wmlc',
'dcr' => 'application/x-director',
'dir' => 'application/x-director',
'dxr' => 'application/x-director',
'dvi' => 'application/x-dvi',
'gtar' => 'application/x-gtar',
'gz' => 'application/x-gzip',
'php' => 'application/x-httpd-php',
'php4' => 'application/x-httpd-php',
'php3' => 'application/x-httpd-php',
'phtml' => 'application/x-httpd-php',
'phps' => 'application/x-httpd-php-source',
'js' => 'application/x-javascript',
'swf' => 'application/x-shockwave-flash',
'sit' => 'application/x-stuffit',
'tar' => 'application/x-tar',
'tgz' => array('application/x-tar', 'application/x-gzip-compressed'),
'xhtml' => 'application/xhtml+xml',
'xht' => 'application/xhtml+xml',
'zip' => array('application/x-zip', 'application/zip', 'application/x-zip-compressed'),
'mid' => 'audio/midi',
'midi' => 'audio/midi',
'mpga' => 'audio/mpeg',
'mp2' => 'audio/mpeg',
'mp3' => array('audio/mpeg', 'audio/mpg', 'audio/mpeg3', 'audio/mp3'),
'aif' => 'audio/x-aiff',
'aiff' => 'audio/x-aiff',
'aifc' => 'audio/x-aiff',
'ram' => 'audio/x-pn-realaudio',
'rm' => 'audio/x-pn-realaudio',
'rpm' => 'audio/x-pn-realaudio-plugin',
'ra' => 'audio/x-realaudio',
'rv' => 'video/vnd.rn-realvideo',
'wav' => array('audio/x-wav', 'audio/wave', 'audio/wav'),
'bmp' => array('image/bmp', 'image/x-windows-bmp'),
'gif' => 'image/gif',
'jpeg' => array('image/jpeg', 'image/pjpeg'),
'jpg' => array('image/jpeg', 'image/pjpeg'),
'jpe' => array('image/jpeg', 'image/pjpeg'),
'png' => array('image/png', 'image/x-png'),
'tiff' => 'image/tiff',
'tif' => 'image/tiff',
'css' => 'text/css',
'html' => 'text/html',
'htm' => 'text/html',
'shtml' => 'text/html',
'txt' => 'text/plain',
'text' => 'text/plain',
'log' => array('text/plain', 'text/x-log'),
'rtx' => 'text/richtext',
'rtf' => 'text/rtf',
'xml' => 'text/xml',
'xsl' => 'text/xml',
'mpeg' => 'video/mpeg',
'mpg' => 'video/mpeg',
'mpe' => 'video/mpeg',
'qt' => 'video/quicktime',
'mov' => 'video/quicktime',
'avi' => 'video/x-msvideo',
'movie' => 'video/x-sgi-movie',
'doc' => 'application/msword',
'docx' => 'application/vnd.openxmlformats-officedocument.wordprocessingml.document',
'xlsx' => 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet',
'word' => array('application/msword', 'application/octet-stream'),
'xl' => 'application/excel',
'eml' => 'message/rfc822',
'json' => array('application/json', 'text/json')
);
/* End of file mimes.php */
/* Location: ./application/config/mimes.php */
| php | MIT | 152cd2d808675d2baeb9e77c229adfbaf9a16475 | 2026-01-05T05:21:15.334872Z | false |
MobilityLab/TransitScreen | https://github.com/MobilityLab/TransitScreen/blob/152cd2d808675d2baeb9e77c229adfbaf9a16475/application/config/hooks.php | application/config/hooks.php | <?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
/*
| -------------------------------------------------------------------------
| Hooks
| -------------------------------------------------------------------------
| This file lets you define "hooks" to extend CI without hacking the core
| files. Please see the user guide for info:
|
| http://codeigniter.com/user_guide/general/hooks.html
|
*/
/* End of file hooks.php */
/* Location: ./application/config/hooks.php */ | php | MIT | 152cd2d808675d2baeb9e77c229adfbaf9a16475 | 2026-01-05T05:21:15.334872Z | false |
MobilityLab/TransitScreen | https://github.com/MobilityLab/TransitScreen/blob/152cd2d808675d2baeb9e77c229adfbaf9a16475/application/config/migration.php | application/config/migration.php | <?php defined('BASEPATH') OR exit('No direct script access allowed');
/*
|--------------------------------------------------------------------------
| Enable/Disable Migrations
|--------------------------------------------------------------------------
|
| Migrations are disabled by default but should be enabled
| whenever you intend to do a schema migration.
|
*/
$config['migration_enabled'] = FALSE;
/*
|--------------------------------------------------------------------------
| Migrations version
|--------------------------------------------------------------------------
|
| This is used to set migration version that the file system should be on.
| If you run $this->migration->latest() this is the version that schema will
| be upgraded / downgraded to.
|
*/
$config['migration_version'] = 0;
/*
|--------------------------------------------------------------------------
| Migrations Path
|--------------------------------------------------------------------------
|
| Path to your migrations folder.
| Typically, it will be within your application path.
| Also, writing permission is required within the migrations path.
|
*/
$config['migration_path'] = APPPATH . 'migrations/';
/* End of file migration.php */
/* Location: ./application/config/migration.php */
| php | MIT | 152cd2d808675d2baeb9e77c229adfbaf9a16475 | 2026-01-05T05:21:15.334872Z | false |
MobilityLab/TransitScreen | https://github.com/MobilityLab/TransitScreen/blob/152cd2d808675d2baeb9e77c229adfbaf9a16475/application/config/autoload.php | application/config/autoload.php | <?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
/*
| -------------------------------------------------------------------
| AUTO-LOADER
| -------------------------------------------------------------------
| This file specifies which systems should be loaded by default.
|
| In order to keep the framework as light-weight as possible only the
| absolute minimal resources are loaded by default. For example,
| the database is not connected to automatically since no assumption
| is made regarding whether you intend to use it. This file lets
| you globally define which systems you would like loaded with every
| request.
|
| -------------------------------------------------------------------
| Instructions
| -------------------------------------------------------------------
|
| These are the things you can load automatically:
|
| 1. Packages
| 2. Libraries
| 3. Helper files
| 4. Custom config files
| 5. Language files
| 6. Models
|
*/
/*
| -------------------------------------------------------------------
| Auto-load Packges
| -------------------------------------------------------------------
| Prototype:
|
| $autoload['packages'] = array(APPPATH.'third_party', '/usr/local/shared');
|
*/
$autoload['packages'] = array();
/*
| -------------------------------------------------------------------
| Auto-load Libraries
| -------------------------------------------------------------------
| These are the classes located in the system/libraries folder
| or in your application/libraries folder.
|
| Prototype:
|
| $autoload['libraries'] = array('database', 'session', 'xmlrpc');
*/
$autoload['libraries'] = array('database','session');
/*
| -------------------------------------------------------------------
| Auto-load Helper Files
| -------------------------------------------------------------------
| Prototype:
|
| $autoload['helper'] = array('url', 'file');
*/
$autoload['helper'] = array('url','html', 'form');
/*
| -------------------------------------------------------------------
| Auto-load Config files
| -------------------------------------------------------------------
| Prototype:
|
| $autoload['config'] = array('config1', 'config2');
|
| NOTE: This item is intended for use ONLY if you have created custom
| config files. Otherwise, leave it blank.
|
*/
$autoload['config'] = array();
/*
| -------------------------------------------------------------------
| Auto-load Language files
| -------------------------------------------------------------------
| Prototype:
|
| $autoload['language'] = array('lang1', 'lang2');
|
| NOTE: Do not include the "_lang" part of your file. For example
| "codeigniter_lang.php" would be referenced as array('codeigniter');
|
*/
$autoload['language'] = array();
/*
| -------------------------------------------------------------------
| Auto-load Models
| -------------------------------------------------------------------
| Prototype:
|
| $autoload['model'] = array('model1', 'model2');
|
*/
$autoload['model'] = array();
/* End of file autoload.php */
/* Location: ./application/config/autoload.php */ | php | MIT | 152cd2d808675d2baeb9e77c229adfbaf9a16475 | 2026-01-05T05:21:15.334872Z | false |
MobilityLab/TransitScreen | https://github.com/MobilityLab/TransitScreen/blob/152cd2d808675d2baeb9e77c229adfbaf9a16475/application/config/foreign_chars.php | application/config/foreign_chars.php | <?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
/*
| -------------------------------------------------------------------
| Foreign Characters
| -------------------------------------------------------------------
| This file contains an array of foreign characters for transliteration
| conversion used by the Text helper
|
*/
$foreign_characters = array(
'/ä|æ|ǽ/' => 'ae',
'/ö|œ/' => 'oe',
'/ü/' => 'ue',
'/Ä/' => 'Ae',
'/Ü/' => 'Ue',
'/Ö/' => 'Oe',
'/À|Á|Â|Ã|Ä|Å|Ǻ|Ā|Ă|Ą|Ǎ/' => 'A',
'/à|á|â|ã|å|ǻ|ā|ă|ą|ǎ|ª/' => 'a',
'/Ç|Ć|Ĉ|Ċ|Č/' => 'C',
'/ç|ć|ĉ|ċ|č/' => 'c',
'/Ð|Ď|Đ/' => 'D',
'/ð|ď|đ/' => 'd',
'/È|É|Ê|Ë|Ē|Ĕ|Ė|Ę|Ě/' => 'E',
'/è|é|ê|ë|ē|ĕ|ė|ę|ě/' => 'e',
'/Ĝ|Ğ|Ġ|Ģ/' => 'G',
'/ĝ|ğ|ġ|ģ/' => 'g',
'/Ĥ|Ħ/' => 'H',
'/ĥ|ħ/' => 'h',
'/Ì|Í|Î|Ï|Ĩ|Ī|Ĭ|Ǐ|Į|İ/' => 'I',
'/ì|í|î|ï|ĩ|ī|ĭ|ǐ|į|ı/' => 'i',
'/Ĵ/' => 'J',
'/ĵ/' => 'j',
'/Ķ/' => 'K',
'/ķ/' => 'k',
'/Ĺ|Ļ|Ľ|Ŀ|Ł/' => 'L',
'/ĺ|ļ|ľ|ŀ|ł/' => 'l',
'/Ñ|Ń|Ņ|Ň/' => 'N',
'/ñ|ń|ņ|ň|ʼn/' => 'n',
'/Ò|Ó|Ô|Õ|Ō|Ŏ|Ǒ|Ő|Ơ|Ø|Ǿ/' => 'O',
'/ò|ó|ô|õ|ō|ŏ|ǒ|ő|ơ|ø|ǿ|º/' => 'o',
'/Ŕ|Ŗ|Ř/' => 'R',
'/ŕ|ŗ|ř/' => 'r',
'/Ś|Ŝ|Ş|Š/' => 'S',
'/ś|ŝ|ş|š|ſ/' => 's',
'/Ţ|Ť|Ŧ/' => 'T',
'/ţ|ť|ŧ/' => 't',
'/Ù|Ú|Û|Ũ|Ū|Ŭ|Ů|Ű|Ų|Ư|Ǔ|Ǖ|Ǘ|Ǚ|Ǜ/' => 'U',
'/ù|ú|û|ũ|ū|ŭ|ů|ű|ų|ư|ǔ|ǖ|ǘ|ǚ|ǜ/' => 'u',
'/Ý|Ÿ|Ŷ/' => 'Y',
'/ý|ÿ|ŷ/' => 'y',
'/Ŵ/' => 'W',
'/ŵ/' => 'w',
'/Ź|Ż|Ž/' => 'Z',
'/ź|ż|ž/' => 'z',
'/Æ|Ǽ/' => 'AE',
'/ß/'=> 'ss',
'/IJ/' => 'IJ',
'/ij/' => 'ij',
'/Œ/' => 'OE',
'/ƒ/' => 'f'
);
/* End of file foreign_chars.php */
/* Location: ./application/config/foreign_chars.php */ | php | MIT | 152cd2d808675d2baeb9e77c229adfbaf9a16475 | 2026-01-05T05:21:15.334872Z | false |
MobilityLab/TransitScreen | https://github.com/MobilityLab/TransitScreen/blob/152cd2d808675d2baeb9e77c229adfbaf9a16475/application/config/database.php | application/config/database.php | <?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
/*
| -------------------------------------------------------------------
| DATABASE CONNECTIVITY SETTINGS
| -------------------------------------------------------------------
| This file will contain the settings needed to access your database.
|
| For complete instructions please consult the 'Database Connection'
| page of the User Guide.
|
| -------------------------------------------------------------------
| EXPLANATION OF VARIABLES
| -------------------------------------------------------------------
|
| ['hostname'] The hostname of your database server.
| ['username'] The username used to connect to the database
| ['password'] The password used to connect to the database
| ['database'] The name of the database you want to connect to
| ['dbdriver'] The database type. ie: mysql. Currently supported:
mysql, mysqli, postgre, odbc, mssql, sqlite, oci8
| ['dbprefix'] You can add an optional prefix, which will be added
| to the table name when using the Active Record class
| ['pconnect'] TRUE/FALSE - Whether to use a persistent connection
| ['db_debug'] TRUE/FALSE - Whether database errors should be displayed.
| ['cache_on'] TRUE/FALSE - Enables/disables query caching
| ['cachedir'] The path to the folder where cache files should be stored
| ['char_set'] The character set used in communicating with the database
| ['dbcollat'] The character collation used in communicating with the database
| NOTE: For MySQL and MySQLi databases, this setting is only used
| as a backup if your server is running PHP < 5.2.3 or MySQL < 5.0.7
| (and in table creation queries made with DB Forge).
| There is an incompatibility in PHP with mysql_real_escape_string() which
| can make your site vulnerable to SQL injection if you are using a
| multi-byte character set and are running versions lower than these.
| Sites using Latin-1 or UTF-8 database character set and collation are unaffected.
| ['swap_pre'] A default table prefix that should be swapped with the dbprefix
| ['autoinit'] Whether or not to automatically initialize the database.
| ['stricton'] TRUE/FALSE - forces 'Strict Mode' connections
| - good for ensuring strict SQL while developing
|
| The $active_group variable lets you choose which connection group to
| make active. By default there is only one group (the 'default' group).
|
| The $active_record variables lets you determine whether or not to load
| the active record class
*/
$active_group = 'default';
$active_record = TRUE;
$db['default']['hostname'] = 'localhost';
$db['default']['username'] = 'postgres';
$db['default']['password'] = 'your_password';
$db['default']['database'] = 'transitscreens';
$db['default']['dbdriver'] = 'postgre';
$db['default']['dbprefix'] = '';
$db['default']['pconnect'] = TRUE;
$db['default']['db_debug'] = TRUE;
$db['default']['cache_on'] = FALSE;
$db['default']['cachedir'] = '';
$db['default']['char_set'] = 'utf8';
$db['default']['dbcollat'] = 'utf8_general_ci';
$db['default']['swap_pre'] = '';
$db['default']['autoinit'] = TRUE;
$db['default']['stricton'] = FALSE;
/* End of file database.php */
/* Location: ./application/config/database.php */ | php | MIT | 152cd2d808675d2baeb9e77c229adfbaf9a16475 | 2026-01-05T05:21:15.334872Z | false |
MobilityLab/TransitScreen | https://github.com/MobilityLab/TransitScreen/blob/152cd2d808675d2baeb9e77c229adfbaf9a16475/application/config/config.php | application/config/config.php | <?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
/*
|--------------------------------------------------------------------------
| Base Site URL
|--------------------------------------------------------------------------
|
| URL to your CodeIgniter root. Typically this will be your base URL,
| WITH a trailing slash:
|
| http://example.com/
|
| If this is not set then CodeIgniter will guess the protocol, domain and
| path to your installation.
|
*/
$config['base_url'] = 'http://' . $_SERVER['SERVER_NAME'] . '/Transit-Screen/';
//$config['base_url'] = '';
/*
|--------------------------------------------------------------------------
| Index File
|--------------------------------------------------------------------------
|
| Typically this will be your index.php file, unless you've renamed it to
| something else. If you are using mod_rewrite to remove the page set this
| variable so that it is blank.
|
*/
$config['index_page'] = 'index.php';
//$config['index_page'] = '';
/*
|--------------------------------------------------------------------------
| URI PROTOCOL
|--------------------------------------------------------------------------
|
| This item determines which server global should be used to retrieve the
| URI string. The default setting of 'AUTO' works for most servers.
| If your links do not seem to work, try one of the other delicious flavors:
|
| 'AUTO' Default - auto detects
| 'PATH_INFO' Uses the PATH_INFO
| 'QUERY_STRING' Uses the QUERY_STRING
| 'REQUEST_URI' Uses the REQUEST_URI
| 'ORIG_PATH_INFO' Uses the ORIG_PATH_INFO
|
*/
$config['uri_protocol'] = 'AUTO';
/*
|--------------------------------------------------------------------------
| URL suffix
|--------------------------------------------------------------------------
|
| This option allows you to add a suffix to all URLs generated by CodeIgniter.
| For more information please see the user guide:
|
| http://codeigniter.com/user_guide/general/urls.html
*/
$config['url_suffix'] = '';
/*
|--------------------------------------------------------------------------
| Default Language
|--------------------------------------------------------------------------
|
| This determines which set of language files should be used. Make sure
| there is an available translation if you intend to use something other
| than english.
|
*/
$config['language'] = 'english';
/*
|--------------------------------------------------------------------------
| Default Character Set
|--------------------------------------------------------------------------
|
| This determines which character set is used by default in various methods
| that require a character set to be provided.
|
*/
$config['charset'] = 'UTF-8';
/*
|--------------------------------------------------------------------------
| Enable/Disable System Hooks
|--------------------------------------------------------------------------
|
| If you would like to use the 'hooks' feature you must enable it by
| setting this variable to TRUE (boolean). See the user guide for details.
|
*/
$config['enable_hooks'] = FALSE;
/*
|--------------------------------------------------------------------------
| Class Extension Prefix
|--------------------------------------------------------------------------
|
| This item allows you to set the filename/classname prefix when extending
| native libraries. For more information please see the user guide:
|
| http://codeigniter.com/user_guide/general/core_classes.html
| http://codeigniter.com/user_guide/general/creating_libraries.html
|
*/
$config['subclass_prefix'] = 'MY_';
/*
|--------------------------------------------------------------------------
| Allowed URL Characters
|--------------------------------------------------------------------------
|
| This lets you specify with a regular expression which characters are permitted
| within your URLs. When someone tries to submit a URL with disallowed
| characters they will get a warning message.
|
| As a security measure you are STRONGLY encouraged to restrict URLs to
| as few characters as possible. By default only these are allowed: a-z 0-9~%.:_-
|
| Leave blank to allow all characters -- but only if you are insane.
|
| DO NOT CHANGE THIS UNLESS YOU FULLY UNDERSTAND THE REPERCUSSIONS!!
|
*/
$config['permitted_uri_chars'] = 'a-z 0-9~%.:_\-';
/*
|--------------------------------------------------------------------------
| Enable Query Strings
|--------------------------------------------------------------------------
|
| By default CodeIgniter uses search-engine friendly segment based URLs:
| example.com/who/what/where/
|
| By default CodeIgniter enables access to the $_GET array. If for some
| reason you would like to disable it, set 'allow_get_array' to FALSE.
|
| You can optionally enable standard query string based URLs:
| example.com?who=me&what=something&where=here
|
| Options are: TRUE or FALSE (boolean)
|
| The other items let you set the query string 'words' that will
| invoke your controllers and its functions:
| example.com/index.php?c=controller&m=function
|
| Please note that some of the helpers won't work as expected when
| this feature is enabled, since CodeIgniter is designed primarily to
| use segment based URLs.
|
*/
$config['allow_get_array'] = TRUE;
$config['enable_query_strings'] = FALSE;
$config['controller_trigger'] = 'c';
$config['function_trigger'] = 'm';
$config['directory_trigger'] = 'd'; // experimental not currently in use
/*
|--------------------------------------------------------------------------
| Error Logging Threshold
|--------------------------------------------------------------------------
|
| If you have enabled error logging, you can set an error threshold to
| determine what gets logged. Threshold options are:
| You can enable error logging by setting a threshold over zero. The
| threshold determines what gets logged. Threshold options are:
|
| 0 = Disables logging, Error logging TURNED OFF
| 1 = Error Messages (including PHP errors)
| 2 = Debug Messages
| 3 = Informational Messages
| 4 = All Messages
|
| For a live site you'll usually only enable Errors (1) to be logged otherwise
| your log files will fill up very fast.
|
*/
$config['log_threshold'] = 0;
/*
|--------------------------------------------------------------------------
| Error Logging Directory Path
|--------------------------------------------------------------------------
|
| Leave this BLANK unless you would like to set something other than the default
| application/logs/ folder. Use a full server path with trailing slash.
|
*/
$config['log_path'] = '';
/*
|--------------------------------------------------------------------------
| Date Format for Logs
|--------------------------------------------------------------------------
|
| Each item that is logged has an associated date. You can use PHP date
| codes to set your own date formatting
|
*/
$config['log_date_format'] = 'Y-m-d H:i:s';
/*
|--------------------------------------------------------------------------
| Cache Directory Path
|--------------------------------------------------------------------------
|
| Leave this BLANK unless you would like to set something other than the default
| system/cache/ folder. Use a full server path with trailing slash.
|
*/
$config['cache_path'] = '';
/*
|--------------------------------------------------------------------------
| Encryption Key
|--------------------------------------------------------------------------
|
| If you use the Encryption class or the Session class you
| MUST set an encryption key. See the user guide for info.
|
*/
$config['encryption_key'] = 'cANusethAduvu5WujayacaDrAkEpredr';
/*
|--------------------------------------------------------------------------
| Session Variables
|--------------------------------------------------------------------------
|
| 'sess_cookie_name' = the name you want for the cookie
| 'sess_expiration' = the number of SECONDS you want the session to last.
| by default sessions last 7200 seconds (two hours). Set to zero for no expiration.
| 'sess_expire_on_close' = Whether to cause the session to expire automatically
| when the browser window is closed
| 'sess_encrypt_cookie' = Whether to encrypt the cookie
| 'sess_use_database' = Whether to save the session data to a database
| 'sess_table_name' = The name of the session database table
| 'sess_match_ip' = Whether to match the user's IP address when reading the session data
| 'sess_match_useragent' = Whether to match the User Agent when reading the session data
| 'sess_time_to_update' = how many seconds between CI refreshing Session Information
|
*/
$config['sess_cookie_name'] = 'ci_session';
$config['sess_expiration'] = 7200;
$config['sess_expire_on_close'] = FALSE;
$config['sess_encrypt_cookie'] = TRUE;
$config['sess_use_database'] = TRUE;
$config['sess_table_name'] = 'ci_sessions';
$config['sess_match_ip'] = FALSE;
$config['sess_match_useragent'] = TRUE;
$config['sess_time_to_update'] = 300;
/*
|--------------------------------------------------------------------------
| Cookie Related Variables
|--------------------------------------------------------------------------
|
| 'cookie_prefix' = Set a prefix if you need to avoid collisions
| 'cookie_domain' = Set to .your-domain.com for site-wide cookies
| 'cookie_path' = Typically will be a forward slash
| 'cookie_secure' = Cookies will only be set if a secure HTTPS connection exists.
|
*/
$config['cookie_prefix'] = "";
$config['cookie_domain'] = "";
$config['cookie_path'] = "/";
$config['cookie_secure'] = FALSE;
/*
|--------------------------------------------------------------------------
| Global XSS Filtering
|--------------------------------------------------------------------------
|
| Determines whether the XSS filter is always active when GET, POST or
| COOKIE data is encountered
|
*/
$config['global_xss_filtering'] = FALSE;
/*
|--------------------------------------------------------------------------
| Cross Site Request Forgery
|--------------------------------------------------------------------------
| Enables a CSRF cookie token to be set. When set to TRUE, token will be
| checked on a submitted form. If you are accepting user data, it is strongly
| recommended CSRF protection be enabled.
|
| 'csrf_token_name' = The token name
| 'csrf_cookie_name' = The cookie name
| 'csrf_expire' = The number in seconds the token should expire.
*/
$config['csrf_protection'] = FALSE;
$config['csrf_token_name'] = 'csrf_test_name';
$config['csrf_cookie_name'] = 'csrf_cookie_name';
$config['csrf_expire'] = 7200;
/*
|--------------------------------------------------------------------------
| Output Compression
|--------------------------------------------------------------------------
|
| Enables Gzip output compression for faster page loads. When enabled,
| the output class will test whether your server supports Gzip.
| Even if it does, however, not all browsers support compression
| so enable only if you are reasonably sure your visitors can handle it.
|
| VERY IMPORTANT: If you are getting a blank page when compression is enabled it
| means you are prematurely outputting something to your browser. It could
| even be a line of whitespace at the end of one of your scripts. For
| compression to work, nothing can be sent before the output buffer is called
| by the output class. Do not 'echo' any values with compression enabled.
|
*/
$config['compress_output'] = FALSE;
/*
|--------------------------------------------------------------------------
| Master Time Reference
|--------------------------------------------------------------------------
|
| Options are 'local' or 'gmt'. This pref tells the system whether to use
| your server's local time as the master 'now' reference, or convert it to
| GMT. See the 'date helper' page of the user guide for information
| regarding date handling.
|
*/
$config['time_reference'] = 'local';
/*
|--------------------------------------------------------------------------
| Rewrite PHP Short Tags
|--------------------------------------------------------------------------
|
| If your PHP installation does not have short tag support enabled CI
| can rewrite the tags on-the-fly, enabling you to utilize that syntax
| in your view files. Options are TRUE or FALSE (boolean)
|
*/
$config['rewrite_short_tags'] = FALSE;
/*
|--------------------------------------------------------------------------
| Reverse Proxy IPs
|--------------------------------------------------------------------------
|
| If your server is behind a reverse proxy, you must whitelist the proxy IP
| addresses from which CodeIgniter should trust the HTTP_X_FORWARDED_FOR
| header in order to properly identify the visitor's IP address.
| Comma-delimited, e.g. '10.0.1.200,10.0.1.201'
|
*/
$config['proxy_ips'] = '';
/* End of file config.php */
/* Location: ./application/config/config.php */
| php | MIT | 152cd2d808675d2baeb9e77c229adfbaf9a16475 | 2026-01-05T05:21:15.334872Z | false |
MobilityLab/TransitScreen | https://github.com/MobilityLab/TransitScreen/blob/152cd2d808675d2baeb9e77c229adfbaf9a16475/application/config/routes.php | application/config/routes.php | <?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
/*
| -------------------------------------------------------------------------
| URI ROUTING
| -------------------------------------------------------------------------
| This file lets you re-map URI requests to specific controller functions.
|
| Typically there is a one-to-one relationship between a URL string
| and its corresponding controller class/method. The segments in a
| URL normally follow this pattern:
|
| example.com/class/method/id/
|
| In some instances, however, you may want to remap this relationship
| so that a different class/function is called than the one
| corresponding to the URL.
|
| Please see the user guide for complete details:
|
| http://codeigniter.com/user_guide/general/routing.html
|
| -------------------------------------------------------------------------
| RESERVED ROUTES
| -------------------------------------------------------------------------
|
| There area two reserved routes:
|
| $route['default_controller'] = 'welcome';
|
| This route indicates which controller class should be loaded if the
| URI contains no data. In the above example, the "welcome" class
| would be loaded.
|
| $route['404_override'] = 'errors/page_missing';
|
| This route will tell the Router what URI segments to use if those provided
| in the URL cannot be matched to a valid route.
|
*/
$route['default_controller'] = "welcome";
$route['404_override'] = '';
/* End of file routes.php */
/* Location: ./application/config/routes.php */ | php | MIT | 152cd2d808675d2baeb9e77c229adfbaf9a16475 | 2026-01-05T05:21:15.334872Z | false |
MobilityLab/TransitScreen | https://github.com/MobilityLab/TransitScreen/blob/152cd2d808675d2baeb9e77c229adfbaf9a16475/application/config/user_agents.php | application/config/user_agents.php | <?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
/*
| -------------------------------------------------------------------
| USER AGENT TYPES
| -------------------------------------------------------------------
| This file contains four arrays of user agent data. It is used by the
| User Agent Class to help identify browser, platform, robot, and
| mobile device data. The array keys are used to identify the device
| and the array values are used to set the actual name of the item.
|
*/
$platforms = array (
'windows nt 6.0' => 'Windows Longhorn',
'windows nt 5.2' => 'Windows 2003',
'windows nt 5.0' => 'Windows 2000',
'windows nt 5.1' => 'Windows XP',
'windows nt 4.0' => 'Windows NT 4.0',
'winnt4.0' => 'Windows NT 4.0',
'winnt 4.0' => 'Windows NT',
'winnt' => 'Windows NT',
'windows 98' => 'Windows 98',
'win98' => 'Windows 98',
'windows 95' => 'Windows 95',
'win95' => 'Windows 95',
'windows' => 'Unknown Windows OS',
'os x' => 'Mac OS X',
'ppc mac' => 'Power PC Mac',
'freebsd' => 'FreeBSD',
'ppc' => 'Macintosh',
'linux' => 'Linux',
'debian' => 'Debian',
'sunos' => 'Sun Solaris',
'beos' => 'BeOS',
'apachebench' => 'ApacheBench',
'aix' => 'AIX',
'irix' => 'Irix',
'osf' => 'DEC OSF',
'hp-ux' => 'HP-UX',
'netbsd' => 'NetBSD',
'bsdi' => 'BSDi',
'openbsd' => 'OpenBSD',
'gnu' => 'GNU/Linux',
'unix' => 'Unknown Unix OS'
);
// The order of this array should NOT be changed. Many browsers return
// multiple browser types so we want to identify the sub-type first.
$browsers = array(
'Flock' => 'Flock',
'Chrome' => 'Chrome',
'Opera' => 'Opera',
'MSIE' => 'Internet Explorer',
'Internet Explorer' => 'Internet Explorer',
'Shiira' => 'Shiira',
'Firefox' => 'Firefox',
'Chimera' => 'Chimera',
'Phoenix' => 'Phoenix',
'Firebird' => 'Firebird',
'Camino' => 'Camino',
'Netscape' => 'Netscape',
'OmniWeb' => 'OmniWeb',
'Safari' => 'Safari',
'Mozilla' => 'Mozilla',
'Konqueror' => 'Konqueror',
'icab' => 'iCab',
'Lynx' => 'Lynx',
'Links' => 'Links',
'hotjava' => 'HotJava',
'amaya' => 'Amaya',
'IBrowse' => 'IBrowse'
);
$mobiles = array(
// legacy array, old values commented out
'mobileexplorer' => 'Mobile Explorer',
// 'openwave' => 'Open Wave',
// 'opera mini' => 'Opera Mini',
// 'operamini' => 'Opera Mini',
// 'elaine' => 'Palm',
'palmsource' => 'Palm',
// 'digital paths' => 'Palm',
// 'avantgo' => 'Avantgo',
// 'xiino' => 'Xiino',
'palmscape' => 'Palmscape',
// 'nokia' => 'Nokia',
// 'ericsson' => 'Ericsson',
// 'blackberry' => 'BlackBerry',
// 'motorola' => 'Motorola'
// Phones and Manufacturers
'motorola' => "Motorola",
'nokia' => "Nokia",
'palm' => "Palm",
'iphone' => "Apple iPhone",
'ipad' => "iPad",
'ipod' => "Apple iPod Touch",
'sony' => "Sony Ericsson",
'ericsson' => "Sony Ericsson",
'blackberry' => "BlackBerry",
'cocoon' => "O2 Cocoon",
'blazer' => "Treo",
'lg' => "LG",
'amoi' => "Amoi",
'xda' => "XDA",
'mda' => "MDA",
'vario' => "Vario",
'htc' => "HTC",
'samsung' => "Samsung",
'sharp' => "Sharp",
'sie-' => "Siemens",
'alcatel' => "Alcatel",
'benq' => "BenQ",
'ipaq' => "HP iPaq",
'mot-' => "Motorola",
'playstation portable' => "PlayStation Portable",
'hiptop' => "Danger Hiptop",
'nec-' => "NEC",
'panasonic' => "Panasonic",
'philips' => "Philips",
'sagem' => "Sagem",
'sanyo' => "Sanyo",
'spv' => "SPV",
'zte' => "ZTE",
'sendo' => "Sendo",
// Operating Systems
'symbian' => "Symbian",
'SymbianOS' => "SymbianOS",
'elaine' => "Palm",
'palm' => "Palm",
'series60' => "Symbian S60",
'windows ce' => "Windows CE",
// Browsers
'obigo' => "Obigo",
'netfront' => "Netfront Browser",
'openwave' => "Openwave Browser",
'mobilexplorer' => "Mobile Explorer",
'operamini' => "Opera Mini",
'opera mini' => "Opera Mini",
// Other
'digital paths' => "Digital Paths",
'avantgo' => "AvantGo",
'xiino' => "Xiino",
'novarra' => "Novarra Transcoder",
'vodafone' => "Vodafone",
'docomo' => "NTT DoCoMo",
'o2' => "O2",
// Fallback
'mobile' => "Generic Mobile",
'wireless' => "Generic Mobile",
'j2me' => "Generic Mobile",
'midp' => "Generic Mobile",
'cldc' => "Generic Mobile",
'up.link' => "Generic Mobile",
'up.browser' => "Generic Mobile",
'smartphone' => "Generic Mobile",
'cellphone' => "Generic Mobile"
);
// There are hundreds of bots but these are the most common.
$robots = array(
'googlebot' => 'Googlebot',
'msnbot' => 'MSNBot',
'slurp' => 'Inktomi Slurp',
'yahoo' => 'Yahoo',
'askjeeves' => 'AskJeeves',
'fastcrawler' => 'FastCrawler',
'infoseek' => 'InfoSeek Robot 1.0',
'lycos' => 'Lycos'
);
/* End of file user_agents.php */
/* Location: ./application/config/user_agents.php */ | php | MIT | 152cd2d808675d2baeb9e77c229adfbaf9a16475 | 2026-01-05T05:21:15.334872Z | false |
MobilityLab/TransitScreen | https://github.com/MobilityLab/TransitScreen/blob/152cd2d808675d2baeb9e77c229adfbaf9a16475/application/config/constants.php | application/config/constants.php | <?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
/*
|--------------------------------------------------------------------------
| File and Directory Modes
|--------------------------------------------------------------------------
|
| These prefs are used when checking and setting modes when working
| with the file system. The defaults are fine on servers with proper
| security, but you may wish (or even need) to change the values in
| certain environments (Apache running a separate process for each
| user, PHP under CGI with Apache suEXEC, etc.). Octal values should
| always be used to set the mode correctly.
|
*/
define('FILE_READ_MODE', 0644);
define('FILE_WRITE_MODE', 0666);
define('DIR_READ_MODE', 0755);
define('DIR_WRITE_MODE', 0777);
/*
|--------------------------------------------------------------------------
| File Stream Modes
|--------------------------------------------------------------------------
|
| These modes are used when working with fopen()/popen()
|
*/
define('FOPEN_READ', 'rb');
define('FOPEN_READ_WRITE', 'r+b');
define('FOPEN_WRITE_CREATE_DESTRUCTIVE', 'wb'); // truncates existing file data, use with care
define('FOPEN_READ_WRITE_CREATE_DESTRUCTIVE', 'w+b'); // truncates existing file data, use with care
define('FOPEN_WRITE_CREATE', 'ab');
define('FOPEN_READ_WRITE_CREATE', 'a+b');
define('FOPEN_WRITE_CREATE_STRICT', 'xb');
define('FOPEN_READ_WRITE_CREATE_STRICT', 'x+b');
define('WMATAKEY', 'your_api_key_here');
define('PUBLICDIR', 'public/'); //location of the 'public' directory to add to the page templates
/* End of file constants.php */
/* Location: ./application/config/constants.php */ | php | MIT | 152cd2d808675d2baeb9e77c229adfbaf9a16475 | 2026-01-05T05:21:15.334872Z | false |
MobilityLab/TransitScreen | https://github.com/MobilityLab/TransitScreen/blob/152cd2d808675d2baeb9e77c229adfbaf9a16475/application/language/english/tank_auth_lang.php | application/language/english/tank_auth_lang.php | <?php
// Errors
$lang['auth_incorrect_password'] = 'Incorrect password';
$lang['auth_incorrect_login'] = 'Incorrect login';
$lang['auth_incorrect_email_or_username'] = 'Login or email doesn\'t exist';
$lang['auth_email_in_use'] = 'Email is already used by another user. Please choose another email.';
$lang['auth_username_in_use'] = 'Username already exists. Please choose another username.';
$lang['auth_current_email'] = 'This is your current email';
$lang['auth_incorrect_captcha'] = 'Your confirmation code does not match the one in the image.';
$lang['auth_captcha_expired'] = 'Your confirmation code has expired. Please try again.';
// Notifications
$lang['auth_message_logged_out'] = 'You have been successfully logged out.';
$lang['auth_message_registration_disabled'] = 'Registration is disabled.';
$lang['auth_message_registration_completed_1'] = 'You have successfully registered. Check your email address to activate your account.';
$lang['auth_message_registration_completed_2'] = 'You have successfully registered.';
$lang['auth_message_activation_email_sent'] = 'A new activation email has been sent to %s. Follow the instructions in the email to activate your account.';
$lang['auth_message_activation_completed'] = 'Your account has been successfully activated.';
$lang['auth_message_activation_failed'] = 'The activation code you entered is incorrect or expired.';
$lang['auth_message_password_changed'] = 'Your password has been successfully changed.';
$lang['auth_message_new_password_sent'] = 'An email with instructions for creating a new password has been sent to you.';
$lang['auth_message_new_password_activated'] = 'You have successfully reset your password';
$lang['auth_message_new_password_failed'] = 'Your activation key is incorrect or expired. Please check your email again and follow the instructions.';
$lang['auth_message_new_email_sent'] = 'A confirmation email has been sent to %s. Follow the instructions in the email to complete this change of email address.';
$lang['auth_message_new_email_activated'] = 'You have successfully changed your email';
$lang['auth_message_new_email_failed'] = 'Your activation key is incorrect or expired. Please check your email again and follow the instructions.';
$lang['auth_message_banned'] = 'You are banned.';
$lang['auth_message_unregistered'] = 'Your account has been deleted...';
// Email subjects
$lang['auth_subject_welcome'] = 'Welcome to %s!';
$lang['auth_subject_activate'] = 'Welcome to %s!';
$lang['auth_subject_forgot_password'] = 'Forgot your password on %s?';
$lang['auth_subject_reset_password'] = 'Your new password on %s';
$lang['auth_subject_change_email'] = 'Your new email address on %s';
/* End of file tank_auth_lang.php */
/* Location: ./application/language/english/tank_auth_lang.php */ | php | MIT | 152cd2d808675d2baeb9e77c229adfbaf9a16475 | 2026-01-05T05:21:15.334872Z | false |
dusterio/laravel-plain-sqs | https://github.com/dusterio/laravel-plain-sqs/blob/f79c8faa5bdadb3389c8eea11c9dec7aa15fa6a3/src/Jobs/DispatcherJob.php | src/Jobs/DispatcherJob.php | <?php
namespace Dusterio\PlainSqs\Jobs;
use Illuminate\Bus\Queueable;
use Illuminate\Queue\SerializesModels;
use Illuminate\Queue\InteractsWithQueue;
use Illuminate\Contracts\Queue\ShouldQueue;
class DispatcherJob implements ShouldQueue
{
use InteractsWithQueue, Queueable, SerializesModels;
/**
* @var mixed
*/
protected $data;
/**
* @var bool
*/
protected $plain = false;
/**
* DispatchedJob constructor.
* @param $data
*/
public function __construct($data)
{
$this->data = $data;
}
/**
* @return mixed
*/
public function getPayload()
{
if (! $this->isPlain()) {
return [
'job' => app('config')->get('sqs-plain.default-handler'),
'data' => $this->data
];
}
return $this->data;
}
/**
* @param bool $plain
* @return $this
*/
public function setPlain($plain = true)
{
$this->plain = $plain;
return $this;
}
/**
* @return bool
*/
public function isPlain()
{
return $this->plain;
}
} | php | MIT | f79c8faa5bdadb3389c8eea11c9dec7aa15fa6a3 | 2026-01-05T05:21:40.055169Z | false |
dusterio/laravel-plain-sqs | https://github.com/dusterio/laravel-plain-sqs/blob/f79c8faa5bdadb3389c8eea11c9dec7aa15fa6a3/src/Integrations/LumenServiceProvider.php | src/Integrations/LumenServiceProvider.php | <?php
namespace Dusterio\PlainSqs\Integrations;
use Dusterio\PlainSqs\Sqs\Connector;
use Illuminate\Support\ServiceProvider;
use Illuminate\Support\Facades\Queue;
use Illuminate\Queue\Events\JobProcessed;
/**
* Class CustomQueueServiceProvider
* @package App\Providers
*/
class LumenServiceProvider extends ServiceProvider
{
/**
* Bootstrap any application services.
*
* @return void
*/
public function boot()
{
Queue::after(function (JobProcessed $event) {
$event->job->delete();
});
}
/**
* @return void
*/
public function register()
{
$this->app['queue']->addConnector('sqs-plain', function () {
return new Connector();
});
}
} | php | MIT | f79c8faa5bdadb3389c8eea11c9dec7aa15fa6a3 | 2026-01-05T05:21:40.055169Z | false |
dusterio/laravel-plain-sqs | https://github.com/dusterio/laravel-plain-sqs/blob/f79c8faa5bdadb3389c8eea11c9dec7aa15fa6a3/src/Integrations/LaravelServiceProvider.php | src/Integrations/LaravelServiceProvider.php | <?php
namespace Dusterio\PlainSqs\Integrations;
use Dusterio\PlainSqs\Sqs\Connector;
use Illuminate\Support\ServiceProvider;
use Illuminate\Support\Facades\Queue;
use Illuminate\Queue\Events\JobProcessed;
/**
* Class CustomQueueServiceProvider
* @package App\Providers
*/
class LaravelServiceProvider extends ServiceProvider
{
/**
* Bootstrap any application services.
*
* @return void
*/
public function boot()
{
$this->publishes([
__DIR__ . '/../config/sqs-plain.php' => config_path('sqs-plain.php')
]);
Queue::after(function (JobProcessed $event) {
$event->job->delete();
});
}
/**
* @return void
*/
public function register()
{
$this->app->booted(function () {
$this->app['queue']->extend('sqs-plain', function () {
return new Connector();
});
});
}
}
| php | MIT | f79c8faa5bdadb3389c8eea11c9dec7aa15fa6a3 | 2026-01-05T05:21:40.055169Z | false |
dusterio/laravel-plain-sqs | https://github.com/dusterio/laravel-plain-sqs/blob/f79c8faa5bdadb3389c8eea11c9dec7aa15fa6a3/src/config/sqs-plain.php | src/config/sqs-plain.php | <?php
/**
* List of plain SQS queues and their corresponding handling classes
*/
return [
'handlers' => [
'base-integrations-updates' => App\Jobs\HandlerJob::class,
],
'default-handler' => App\Jobs\HandlerJob::class
]; | php | MIT | f79c8faa5bdadb3389c8eea11c9dec7aa15fa6a3 | 2026-01-05T05:21:40.055169Z | false |
dusterio/laravel-plain-sqs | https://github.com/dusterio/laravel-plain-sqs/blob/f79c8faa5bdadb3389c8eea11c9dec7aa15fa6a3/src/Sqs/Connector.php | src/Sqs/Connector.php | <?php
namespace Dusterio\PlainSqs\Sqs;
use Aws\Sqs\SqsClient;
use Illuminate\Support\Arr;
use Illuminate\Queue\Connectors\SqsConnector;
use Illuminate\Queue\Jobs\SqsJob;
class Connector extends SqsConnector
{
/**
* Establish a queue connection.
*
* @param array $config
* @return \Illuminate\Contracts\Queue\Queue
*/
public function connect(array $config)
{
$config = $this->getDefaultConfiguration($config);
if (isset($config['key']) && isset($config['secret'])) {
$config['credentials'] = Arr::only($config, ['key', 'secret']);
}
$queue = new Queue(
new SqsClient($config),
$config['queue'],
Arr::get($config, 'prefix', '')
);
return $queue;
}
} | php | MIT | f79c8faa5bdadb3389c8eea11c9dec7aa15fa6a3 | 2026-01-05T05:21:40.055169Z | false |
dusterio/laravel-plain-sqs | https://github.com/dusterio/laravel-plain-sqs/blob/f79c8faa5bdadb3389c8eea11c9dec7aa15fa6a3/src/Sqs/Queue.php | src/Sqs/Queue.php | <?php
namespace Dusterio\PlainSqs\Sqs;
use Dusterio\PlainSqs\Jobs\DispatcherJob;
use Illuminate\Queue\SqsQueue;
use Illuminate\Support\Facades\Config;
use Illuminate\Queue\Jobs\SqsJob;
/**
* Class CustomSqsQueue
* @package App\Services
*/
class Queue extends SqsQueue
{
/**
* Create a payload string from the given job and data.
*
* @param string $job
* @param mixed $data
* @param string $queue
* @return string
*/
protected function createPayload($job, $queue, $data = '', $delay = null)
{
if (!$job instanceof DispatcherJob) {
return parent::createPayload($job, $queue, $data, $delay);
}
$handlerJob = $this->getClass($queue) . '@handle';
return $job->isPlain() ? json_encode($job->getPayload()) : json_encode(['job' => $handlerJob, 'data' => $job->getPayload()]);
}
/**
* @param $queue
* @return string
*/
private function getClass($queue = null)
{
if (!$queue) return Config::get('sqs-plain.default-handler');
$queue = end(explode('/', $queue));
return (array_key_exists($queue, Config::get('sqs-plain.handlers')))
? Config::get('sqs-plain.handlers')[$queue]
: Config::get('sqs-plain.default-handler');
}
/**
* Pop the next job off of the queue.
*
* @param string $queue
* @return \Illuminate\Contracts\Queue\Job|null
*/
public function pop($queue = null)
{
$queue = $this->getQueue($queue);
$response = $this->sqs->receiveMessage([
'QueueUrl' => $queue,
'AttributeNames' => ['ApproximateReceiveCount'],
]);
if (isset($response['Messages']) && count($response['Messages']) > 0) {
$queueId = explode('/', $queue);
$queueId = array_pop($queueId);
$class = (array_key_exists($queueId, $this->container['config']->get('sqs-plain.handlers')))
? $this->container['config']->get('sqs-plain.handlers')[$queueId]
: $this->container['config']->get('sqs-plain.default-handler');
$response = $this->modifyPayload($response['Messages'][0], $class);
if (preg_match(
'/(5\.[4-8]\..*)|(6\.[0-9]*\..*)|(7\.[0-9]*\..*)|(8\.[0-9]*\..*)|(9\.[0-9]*\..*)|(10\.[0-9]*\..*)|(11\.[0-9]*\..*)|(12\.[0-9]*\..*)/',
$this->container->version())
) {
return new SqsJob($this->container, $this->sqs, $response, $this->connectionName, $queue);
}
return new SqsJob($this->container, $this->sqs, $queue, $response);
}
}
/**
* @param string|array $payload
* @param string $class
* @return array
*/
private function modifyPayload($payload, $class)
{
if (! is_array($payload)) $payload = json_decode($payload, true);
$body = json_decode($payload['Body'], true);
$body = [
'job' => $class . '@handle',
'data' => isset($body['data']) ? $body['data'] : $body,
'uuid' => $payload['MessageId']
];
$payload['Body'] = json_encode($body);
return $payload;
}
/**
* @param string $payload
* @param null $queue
* @param array $options
* @return mixed|null
*/
public function pushRaw($payload, $queue = null, array $options = [])
{
$payload = json_decode($payload, true);
if (isset($payload['data']) && isset($payload['job'])) {
$payload = $payload['data'];
}
return parent::pushRaw(json_encode($payload), $queue, $options);
}
}
| php | MIT | f79c8faa5bdadb3389c8eea11c9dec7aa15fa6a3 | 2026-01-05T05:21:40.055169Z | false |
dusterio/laravel-plain-sqs | https://github.com/dusterio/laravel-plain-sqs/blob/f79c8faa5bdadb3389c8eea11c9dec7aa15fa6a3/tests/bootstrap.php | tests/bootstrap.php | <?php
$loader = require_once __DIR__ . "/../vendor/autoload.php";
| php | MIT | f79c8faa5bdadb3389c8eea11c9dec7aa15fa6a3 | 2026-01-05T05:21:40.055169Z | false |
dusterio/laravel-plain-sqs | https://github.com/dusterio/laravel-plain-sqs/blob/f79c8faa5bdadb3389c8eea11c9dec7aa15fa6a3/tests/PlainSqs/QueueTest.php | tests/PlainSqs/QueueTest.php | <?php
namespace Dusterio\PlainSqs\Tests;
use Aws\Sqs\SqsClient;
use Dusterio\PlainSqs\Jobs\DispatcherJob;
use Dusterio\PlainSqs\Sqs\Queue;
use PHPUnit\Framework\TestCase;
/**
* Class QueueTest
* @package Dusterio\PlainSqs\Tests
*/
class QueueTest extends TestCase
{
/**
* @test
*/
public function class_named_is_derived_from_queue_name()
{
$content = [
'test' => 'test'
];
$job = new DispatcherJob($content);
$queue = $this->getMockBuilder(Queue::class)
->disableOriginalConstructor()
->getMock();
$method = new \ReflectionMethod(
'Dusterio\PlainSqs\Sqs\Queue', 'createPayload'
);
$method->setAccessible(true);
//$response = $method->invokeArgs($queue, [$job]);
}
} | php | MIT | f79c8faa5bdadb3389c8eea11c9dec7aa15fa6a3 | 2026-01-05T05:21:40.055169Z | false |
woann/yamecent-admin | https://github.com/woann/yamecent-admin/blob/3ca32f67185386e2b2e6cf361831a18ebcc94c0f/server.php | server.php | <?php
/**
* Laravel - A PHP Framework For Web Artisans
*
* @package Laravel
* @author Taylor Otwell <taylor@laravel.com>
*/
$uri = urldecode(
parse_url($_SERVER['REQUEST_URI'], PHP_URL_PATH)
);
// This file allows us to emulate Apache's "mod_rewrite" functionality from the
// built-in PHP web server. This provides a convenient way to test a Laravel
// application without having installed a "real" web server software here.
if ($uri !== '/' && file_exists(__DIR__.'/public'.$uri)) {
return false;
}
require_once __DIR__.'/public/index.php';
| php | MIT | 3ca32f67185386e2b2e6cf361831a18ebcc94c0f | 2026-01-05T05:21:26.903260Z | false |
woann/yamecent-admin | https://github.com/woann/yamecent-admin/blob/3ca32f67185386e2b2e6cf361831a18ebcc94c0f/app/User.php | app/User.php | <?php
namespace App;
use Illuminate\Notifications\Notifiable;
use Illuminate\Contracts\Auth\MustVerifyEmail;
use Illuminate\Foundation\Auth\User as Authenticatable;
class User extends Authenticatable
{
use Notifiable;
/**
* The attributes that are mass assignable.
*
* @var array
*/
protected $fillable = [
'name', 'email', 'password',
];
/**
* The attributes that should be hidden for arrays.
*
* @var array
*/
protected $hidden = [
'password', 'remember_token',
];
}
| php | MIT | 3ca32f67185386e2b2e6cf361831a18ebcc94c0f | 2026-01-05T05:21:26.903260Z | false |
woann/yamecent-admin | https://github.com/woann/yamecent-admin/blob/3ca32f67185386e2b2e6cf361831a18ebcc94c0f/app/AdminUser.php | app/AdminUser.php | <?php
namespace App;
use App\AdminRole;
use App\Utility\Rbac;
use Illuminate\Container\Container;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Support\Collection;
use Illuminate\Support\Facades\Hash;
class AdminUser extends Model
{
//
protected $fillable = ['avatar', 'nickname', 'account', 'password'];
protected $hidden = ['password'];
public function roles()
{
return $this->belongsToMany(AdminRole::class);
}
public function getMenus()
{
$roles = $this->roles;
$dealTopMenuFunc = function ($topMenu) {
$topMenu->hasChild = $topMenu->children->isNotEmpty();
return $topMenu;
};
if ($this->hasSuperRole()) {
$menus = AdminMenu::where('pid', 0)
->get()
->map($dealTopMenuFunc);
} else {
$menus = $roles
->map(function ($role) {
return $role->menus()->where('pid', 0)->get();
})
->collapse()
->map($dealTopMenuFunc);
}
return $menus;
}
public function getPermissionRoutes()
{
if ($this->hasSuperRole()) {
$permissions = Rbac::getAllRoutes()
->map(function ($route) {
return $route->rbacRule;
});
} else {
$permissions = $this->roles->map(function ($role) {
return $role->permissions;
})
->collapse()
->map(function ($permission) {
return $permission->routes;
})
->collapse();
}
return $permissions;
}
public function hasSuperRole()
{
$hasSuperRole = false;
$this->roles->each(function ($role) use (&$hasSuperRole) {
if ($role->id === 1) {
$hasSuperRole = true;
return false;
}
});
return $hasSuperRole;
}
public static function isExist(string $account)
{
$instance = new static;
return $instance->where('account', $account)->count() > 0;
}
public function isExistForUpdate(string $account)
{
return $this->where('id', '!=', $this->id)
->where('account', $account)
->count() > 0;
}
public function getAvatarAttribute($avatar): string
{
return $avatar ?? '/uploads/avatar/20181031/5bd90252493d1.jpg';
}
protected function setPasswordAttribute($value)
{
if (is_null($value) || $value === '') {
return;
}
$this->attributes['password'] = Hash::make($value);
}
}
| php | MIT | 3ca32f67185386e2b2e6cf361831a18ebcc94c0f | 2026-01-05T05:21:26.903260Z | false |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.