/var/www/www.attenboroughology.co.uk/vendor/thingengineer/mysqli-database-class/MysqliDb.php
*/
public function connect($connectionName = 'default')
{
if(!isset($this->connectionsSettings[$connectionName]))
throw new Exception('Connection profile not set');
$pro = $this->connectionsSettings[$connectionName];
$params = array_values($pro);
$charset = array_pop($params);
if ($this->isSubQuery) {
return;
}
if (empty($pro['host']) && empty($pro['socket'])) {
throw new Exception('MySQL host or socket is not set');
}
$mysqlic = new ReflectionClass('mysqli');
$mysqli = $mysqlic->newInstanceArgs($params);
if ($mysqli->connect_error) {
throw new Exception('Connect Error ' . $mysqli->connect_errno . ': ' . $mysqli->connect_error, $mysqli->connect_errno);
}
if (!empty($charset)) {
$mysqli->set_charset($charset);
}
$this->_mysqli[$connectionName] = $mysqli;
}
/**
* @throws Exception
*/
public function disconnectAll()
{
foreach (array_keys($this->_mysqli) as $k) {
$this->disconnect($k);
}
}
/var/www/www.attenboroughology.co.uk/vendor/thingengineer/mysqli-database-class/MysqliDb.php
*/
public function connect($connectionName = 'default')
{
if(!isset($this->connectionsSettings[$connectionName]))
throw new Exception('Connection profile not set');
$pro = $this->connectionsSettings[$connectionName];
$params = array_values($pro);
$charset = array_pop($params);
if ($this->isSubQuery) {
return;
}
if (empty($pro['host']) && empty($pro['socket'])) {
throw new Exception('MySQL host or socket is not set');
}
$mysqlic = new ReflectionClass('mysqli');
$mysqli = $mysqlic->newInstanceArgs($params);
if ($mysqli->connect_error) {
throw new Exception('Connect Error ' . $mysqli->connect_errno . ': ' . $mysqli->connect_error, $mysqli->connect_errno);
}
if (!empty($charset)) {
$mysqli->set_charset($charset);
}
$this->_mysqli[$connectionName] = $mysqli;
}
/**
* @throws Exception
*/
public function disconnectAll()
{
foreach (array_keys($this->_mysqli) as $k) {
$this->disconnect($k);
}
}
/var/www/www.attenboroughology.co.uk/vendor/thingengineer/mysqli-database-class/MysqliDb.php
$this->_mysqli[$name] = $prm;
if (!is_string($prm))
$prm = null;
}
$this->connectionsSettings[$name][$k] = $prm;
}
return $this;
}
/**
* A method to get mysqli object or create it in case needed
*
* @return mysqli
* @throws Exception
*/
public function mysqli()
{
if (!isset($this->_mysqli[$this->defConnectionName])) {
$this->connect($this->defConnectionName);
}
return $this->_mysqli[$this->defConnectionName];
}
/**
* A method of returning the static instance to allow access to the
* instantiated object from within another class.
* Inheriting this class would require reloading connection info.
*
* @uses $db = MySqliDb::getInstance();
*
* @return MysqliDb Returns the current instance.
*/
public static function getInstance()
{
return self::$_instance;
}
/**
* Reset states after an execution
/var/www/www.attenboroughology.co.uk/vendor/thingengineer/mysqli-database-class/MysqliDb.php
return;
}
if (is_array($numRows)) {
$this->_query .= ' LIMIT ' . (int) $numRows[0] . ', ' . (int) $numRows[1];
} else {
$this->_query .= ' LIMIT ' . (int) $numRows;
}
}
/**
* Method attempts to prepare the SQL query
* and throws an error if there was a problem.
*
* @return mysqli_stmt
* @throws Exception
*/
protected function _prepareQuery()
{
$stmt = $this->mysqli()->prepare($this->_query);
if ($stmt !== false) {
if ($this->traceEnabled)
$this->traceStartQ = microtime(true);
return $stmt;
}
if ($this->mysqli()->errno === 2006 && $this->autoReconnect === true && $this->autoReconnectCount === 0) {
$this->connect($this->defConnectionName);
$this->autoReconnectCount++;
return $this->_prepareQuery();
}
$error = $this->mysqli()->error;
$query = $this->_query;
$errno = $this->mysqli()->errno;
$this->reset();
throw new Exception(sprintf('%s query: %s', $error, $query), $errno);
}
/var/www/www.attenboroughology.co.uk/vendor/thingengineer/mysqli-database-class/MysqliDb.php
list($from_table, $from, $table) = $matches;
return str_replace($table[0], self::$prefix.$table[0], $query);
}
/**
* Execute raw SQL query.
*
* @param string $query User-provided query to execute.
* @param array $bindParams Variables array to bind to the SQL statement.
*
* @return array Contains the returned rows from the query.
* @throws Exception
*/
public function rawQuery($query, $bindParams = null)
{
$query = $this->rawAddPrefix($query);
$params = array(''); // Create the empty 0 index
$this->_query = $query;
$stmt = $this->_prepareQuery();
if (is_array($bindParams) === true) {
foreach ($bindParams as $prop => $val) {
$params[0] .= $this->_determineType($val);
array_push($params, $bindParams[$prop]);
}
call_user_func_array(array($stmt, 'bind_param'), $this->refValues($params));
}
$stmt->execute();
$this->count = $stmt->affected_rows;
$this->_stmtError = $stmt->error;
$this->_stmtErrno = $stmt->errno;
$this->_lastQuery = $this->replacePlaceHolders($this->_query, $params);
$res = $this->_dynamicBindResults($stmt);
$this->reset();
return $res;
}
/var/www/www.attenboroughology.co.uk/src/app/objects/Page.class.php
<?php
namespace src\app\objects;
use src\app\aoop\AOOP_Utility;
use src\app\objects\QueryFactory;
class Page extends AOOP_Utility
{
public function __construct(){}
public function lookup($page)
{
// Needs access control adding
$page_dom = false;
$db = QueryFactory::getDB();
$sql = QueryFactory::getQuery('page');
$page_record = $db->rawQuery($sql, [$page]);
if (is_array($page_record) && count($page_record) == 1) {
$page_dom = $page_record[0];
}
return $page_dom;
}
public function list($page_access = 'public')
{
$page_list = false;
$db = QueryFactory::getDB();
$sql = QueryFactory::getQuery('page_tree_with_access_control');
$page_access_clause = '';
if($page_access == 'public'){
$page_access_clause = "(page_access = 'public')";
}else{
$page_access_clause = "(page_access = 'public' OR page_access = 'private')";
}
$sql = QueryFactory::replaceQuery($sql, ['PAGE_ACCESS' => $page_access_clause]);
$page_list = $db->rawQuery($sql);
return $page_list;
}
}
/var/www/www.attenboroughology.co.uk/src/app/response/Response.class.php
if($route['access'] == 'private'){
if(!Authenticate::isMemberAuthorised()){
// Emit forbidden!
Response::header(403);
sysMsg::error('You must be logged in to access this page!');
Response::redirect('index');
}
}
$function = $route['init'];
$function();
}else{
// Fall back to matched URL (slower - allows for URL parameters/dynamic URLs)
if(($route = Router::matchRoute(Router::getRouteFromURL())) !== false){
$function = $route['init'];
$function();
}else{
// Final Fall back onto CMS controlled URLs ...
$page = new Page();
if(($page_hit = $page->lookup(Router::getRouteFromURL())) !== false){
// Is it a protected page?
if($page_hit['page_access'] == 'private' && !Authenticate::isMemberAuthorised()){
// Emit forbidden!
Response::header(403);
sysMsg::error('You must be logged in to access this page!');
Response::redirect('index');
}
// Has it been marked as deleted or redirected?
if($page_hit['http_status_code'] != ''){
self::header($page_hit['http_status_code']);
// If its marked as 410/gone then we need to redirect or
// output an error page
if($page_hit['http_redirect'] != ''){
self::redirect($page_hit['http_redirect']);
}
}
/var/www/www.attenboroughology.co.uk/index.php
'composer_vendor' => realpath(AOOP_APP_BASE . '/vendor/autoload.php')
];
require_once $aoop_autoload_paths['aoop_internal'];
require_once $aoop_autoload_paths['composer_vendor'];
/**
* Startup the application!
*/
$AOOP = src\app\aoop\AOOP::instance()->init();
/**
* Process the incoming Request
*/
$request = new src\app\request\Request();
$response = $request->process();
/**
* Respond to the request
*/
$response->respond();