Skip to content
This repository has been archived by the owner on Aug 11, 2023. It is now read-only.

Commit

Permalink
Merge pull request #6 from justnx/master
Browse files Browse the repository at this point in the history
more fixes
  • Loading branch information
DicsyDel committed Feb 12, 2014
2 parents a4f82ef + 01d78b2 commit fbb1b93
Show file tree
Hide file tree
Showing 5 changed files with 98 additions and 122 deletions.
1 change: 1 addition & 0 deletions app/clean_cache.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
#!/bin/sh
rm -rf ./cache/*.xml
rm -rf ./cache/smarty/*
rm -rf ./cache/smarty_bin/*
rm -rf ./cache/adodb/*
14 changes: 7 additions & 7 deletions app/etc/config.ini → app/etc/config.ini.example
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
[database]
dsn="mysqli://dbuser:[email protected]/eppdrs?fetchmode=ADODB_FETCH_ASSOC#pear:extend:date:transaction"
cache=0

[dev]
debug=0
demomode=0
[database]
dsn="mysqli://dbuser:[email protected]/eppdrs?fetchmode=ADODB_FETCH_ASSOC#pear:extend:date:transaction"
cache=0

[dev]
debug=0
demomode=0
156 changes: 78 additions & 78 deletions app/src/LibWebta/library/class.Core.php
Original file line number Diff line number Diff line change
Expand Up @@ -52,15 +52,15 @@ abstract class Core
* @static
*/
private static $DB = array();

/**
* PDO Instances
*
* @var array
* @access private
* @static
*/
private static $PDO = array();

/**
* PDO Instances
*
* @var array
* @access private
* @static
*/
private static $PDO = array();

/**
* Shell instance
Expand Down Expand Up @@ -369,10 +369,10 @@ public static function GetSmartyInstance($smarty_classame = "Smarty")
* @return object
* @static
*/
public static function GetDBInstance($connection_info = NULL, $use_nconnect = false, $driver = 'mysqli', $conn_type = DB_SERVER_MASTER)
public static function GetDBInstance($connection_info = NULL, $use_nconnect = false, $driver = 'mysqli', $conn_type = 'DB_SERVER_MASTER')
{
if (function_exists("NewADOConnection"))
{
if (function_exists("NewADOConnection"))
{
if (is_string($connection_info) || defined("CF_DB_DSN"))
{
$dsn = $connection_info ? $connection_info : CF_DB_DSN;
Expand All @@ -386,17 +386,17 @@ public static function GetDBInstance($connection_info = NULL, $use_nconnect = fa
$driver = ($connection_info["driver"]) ? $connection_info["driver"] : (defined("CF_DB_DRIVER") ? CF_DB_DRIVER : "");
}

// Connect to database;
// Connect to database;

$pid = getmypid();

if (!self::$DB[$pid][$conn_type] || $use_nconnect)
if (!self::$DB[$pid][$conn_type] || $use_nconnect)
{
if ($dsn)
if ($dsn)
{
// Connect using DSN
try
{
{
if ($use_nconnect)
{
// Add forcenew=1 to DSN
Expand All @@ -413,78 +413,78 @@ public static function GetDBInstance($connection_info = NULL, $use_nconnect = fa
{
throw new Exception("Cannot connect to database: {$e->getMessage()}");
}
}
else
}
else
{
// Connect using hostname, user, pass, dbname


if ($host == "")
throw new Exception("Database host not specified");

try
{
throw new Exception("Database host not specified");

try
{
$Conn = NewADOConnection($driver);
if ($use_nconnect)
{
$Conn->NConnect($host, $user, $pass, $name);
}
}
else
{
$Conn->Connect($host, $user, $pass, $name);
}
self::$DB[$pid][$conn_type] = $Conn;
}
catch (ADODB_Exception $e)
{
Core::RaiseError("Cannot connect to database: {$e->getMessage()}", E_ERROR);
}

if (!self::$DB[$pid][$conn_type] || !self::$DB[$pid][$conn_type]->IsConnected())
Core::RaiseError("Cannot connect to database", E_ERROR);

self::$DB[$pid][$conn_type]->debug = defined("CF_DEBUG_DB") ? CF_DEBUG_DB : false;

self::$DB[$pid][$conn_type]->cacheSecs = defined("CF_DB_CACHE") ? CF_DB_CACHE : 0;
self::$DB[$pid][$conn_type]->SetFetchMode(ADODB_FETCH_ASSOC);
}
}

return self::$DB[$pid][$conn_type];
}
else
Core::RaiseError(_("ADODB not loaded."));
}

public static function GetPDOInstance ($config=null, $use_nconnect = false, $conn_type = DB_SERVER_MASTER)
{
if (is_array($config))
{
$dsn = sprintf('%s:dbname=%s;host=%s', $config['driver'], $config['name'], $config['host']);
$user = $config['user'];
$pass = $config['pass'];
}
else if (is_string($config))
{
$pu = parse_url($config);
$dsn = sprintf('%s:dbname=%s;host=%s', $pu['scheme'], substr($pu['path'], 1), $pu['host']);
$user = $pu['user'];
$pass = $pu['pass'];
}
else if (!self::$PDO[$conn_type])
{
throw new Exception('Connection config not specified');
}

if (self::$PDO[$conn_type] === null || $use_nconnect)
{
$db = new PDO($dsn, $user, $pass);
$db->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
$db->setAttribute(PDO::ATTR_DEFAULT_FETCH_MODE, PDO::FETCH_ASSOC);

self::$PDO[$conn_type] = $db;
}

return self::$PDO[$conn_type];
self::$DB[$pid][$conn_type] = $Conn;
}
catch (ADODB_Exception $e)
{
Core::RaiseError("Cannot connect to database: {$e->getMessage()}", E_ERROR);
}

if (!self::$DB[$pid][$conn_type] || !self::$DB[$pid][$conn_type]->IsConnected())
Core::RaiseError("Cannot connect to database", E_ERROR);

self::$DB[$pid][$conn_type]->debug = defined("CF_DEBUG_DB") ? CF_DEBUG_DB : false;

self::$DB[$pid][$conn_type]->cacheSecs = defined("CF_DB_CACHE") ? CF_DB_CACHE : 0;
self::$DB[$pid][$conn_type]->SetFetchMode(ADODB_FETCH_ASSOC);
}
}

return self::$DB[$pid][$conn_type];
}
else
Core::RaiseError(_("ADODB not loaded."));
}

public static function GetPDOInstance ($config=null, $use_nconnect = false, $conn_type = DB_SERVER_MASTER)
{
if (is_array($config))
{
$dsn = sprintf('%s:dbname=%s;host=%s', $config['driver'], $config['name'], $config['host']);
$user = $config['user'];
$pass = $config['pass'];
}
else if (is_string($config))
{
$pu = parse_url($config);
$dsn = sprintf('%s:dbname=%s;host=%s', $pu['scheme'], substr($pu['path'], 1), $pu['host']);
$user = $pu['user'];
$pass = $pu['pass'];
}
else if (!self::$PDO[$conn_type])
{
throw new Exception('Connection config not specified');
}

if (self::$PDO[$conn_type] === null || $use_nconnect)
{
$db = new PDO($dsn, $user, $pass);
$db->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
$db->setAttribute(PDO::ATTR_DEFAULT_FETCH_MODE, PDO::FETCH_ASSOC);

self::$PDO[$conn_type] = $db;
}

return self::$PDO[$conn_type];
}


Expand Down Expand Up @@ -613,4 +613,4 @@ public static function GetTimeStamp()
}
}

?>
?>
24 changes: 12 additions & 12 deletions app/www/admin/src/class.XMLNavigation.php
Original file line number Diff line number Diff line change
Expand Up @@ -74,13 +74,13 @@ class XMLNavigation extends Core
*
* @var object
*/
private $DB;

/**
* Crumb separator
*
* @var object
*/
private $DB;

/**
* Crumb separator
*
* @var object
*/
private $CrumbSeparator;

/**
Expand All @@ -99,9 +99,9 @@ function __construct($search = false)
$this->XML->loadXML("<?xml version=\"1.0\" encoding=\"UTF-8\"?><menu></menu>");
$this->XML->formatOutput = true;

$this->XPath = new DOMXPath($this->XML);

// Default separator
$this->XPath = new DOMXPath($this->XML);

// Default separator
$this->CrumbSeparator = "&nbsp;&raquo;&nbsp;";
}

Expand All @@ -111,7 +111,7 @@ function __construct($search = false)
* @param DOMNode $DOMPart
* @param DOMNode $menu_part
*/
public function AddNode($DOMPart, &$menu_part)
public function AddNode($DOMPart, $menu_part)
{
foreach ($DOMPart->childNodes as $node)
{
Expand Down Expand Up @@ -278,7 +278,7 @@ public function AppendNodesFromArray($nodes, $parentid)
* @access protected
* @return void
*/
protected function GetNodes(&$root)
protected function GetNodes($root)
{
foreach ($root->childNodes as $node)
{
Expand Down
25 changes: 0 additions & 25 deletions app/www/demo.php

This file was deleted.

0 comments on commit fbb1b93

Please sign in to comment.