Cleaned up whitespace, converted spaces to tabs, and added a timezone specification.
git-svn-id: http://svn.cleancode.org/svn/pickles@9 4d10bc64-7434-11dc-a737-d2d0f8310089
This commit is contained in:
parent
c057838e91
commit
5af71f7ed3
9 changed files with 48 additions and 44 deletions
|
@ -1,18 +1,20 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
class Buffer {
|
class Buffer {
|
||||||
|
|
||||||
public static function get() {
|
public static function get() {
|
||||||
$buffer = ob_get_contents();
|
$buffer = ob_get_contents();
|
||||||
ob_end_clean();
|
ob_end_clean();
|
||||||
|
|
||||||
$buffer = str_replace(
|
$buffer = str_replace(
|
||||||
array(' ', "\r\n", "\n", "\t"),
|
array(' ', "\r\n", "\n", "\t"),
|
||||||
null,
|
null,
|
||||||
$buffer
|
$buffer
|
||||||
);
|
);
|
||||||
|
|
||||||
return $buffer;
|
return $buffer;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
?>
|
?>
|
||||||
|
|
|
@ -7,9 +7,9 @@ class DB {
|
||||||
private static $password;
|
private static $password;
|
||||||
private static $database;
|
private static $database;
|
||||||
|
|
||||||
private static $connection;
|
private static $connection;
|
||||||
private static $results;
|
private static $results;
|
||||||
|
|
||||||
public static function open() {
|
public static function open() {
|
||||||
self::$hostname = Config::get('hostname', 'database');
|
self::$hostname = Config::get('hostname', 'database');
|
||||||
self::$username = Config::get('username', 'database');
|
self::$username = Config::get('username', 'database');
|
||||||
|
@ -50,9 +50,9 @@ class DB {
|
||||||
}
|
}
|
||||||
|
|
||||||
public static function execute($sql) {
|
public static function execute($sql) {
|
||||||
if (!is_resource(self::$connection)) {
|
if (!is_resource(self::$connection)) {
|
||||||
self::open();
|
self::open();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (trim($sql) != '') {
|
if (trim($sql) != '') {
|
||||||
self::$results = @mysql_query($sql, self::$connection);
|
self::$results = @mysql_query($sql, self::$connection);
|
||||||
|
@ -77,9 +77,9 @@ class DB {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (is_resource(self::$results)) {
|
if (is_resource(self::$results)) {
|
||||||
$results = @mysql_fetch_row(self::$results);
|
$results = @mysql_fetch_row(self::$results);
|
||||||
if (is_array($results)) {
|
if (is_array($results)) {
|
||||||
return $results[0];
|
return $results[0];
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
Error::addWarning('There is nothing to return');
|
Error::addWarning('There is nothing to return');
|
||||||
|
@ -98,9 +98,9 @@ class DB {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (is_resource(self::$results)) {
|
if (is_resource(self::$results)) {
|
||||||
$results = @mysql_fetch_assoc(self::$results);
|
$results = @mysql_fetch_assoc(self::$results);
|
||||||
if (is_array($results)) {
|
if (is_array($results)) {
|
||||||
return $results;
|
return $results;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
Error::addWarning('There is nothing to return');
|
Error::addWarning('There is nothing to return');
|
||||||
|
@ -120,13 +120,13 @@ class DB {
|
||||||
|
|
||||||
if (is_resource(self::$results)) {
|
if (is_resource(self::$results)) {
|
||||||
$return = null;
|
$return = null;
|
||||||
while ($row =& mysql_fetch_assoc(self::$results)) {
|
while ($row =& mysql_fetch_assoc(self::$results)) {
|
||||||
if (!is_array($return)) {
|
if (!is_array($return)) {
|
||||||
$return = array();
|
$return = array();
|
||||||
}
|
}
|
||||||
|
|
||||||
array_push($return, $row);
|
array_push($return, $row);
|
||||||
}
|
}
|
||||||
|
|
||||||
return $return;
|
return $return;
|
||||||
}
|
}
|
||||||
|
@ -138,9 +138,9 @@ class DB {
|
||||||
}
|
}
|
||||||
|
|
||||||
public static function insert($table, $columnValues) {
|
public static function insert($table, $columnValues) {
|
||||||
if (!is_resource(self::$connection)) {
|
if (!is_resource(self::$connection)) {
|
||||||
self::open();
|
self::open();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (trim($table) != '') {
|
if (trim($table) != '') {
|
||||||
// @todo Check that the table exists, and possibly check that the columns exist as well
|
// @todo Check that the table exists, and possibly check that the columns exist as well
|
||||||
|
|
|
@ -2,10 +2,10 @@
|
||||||
|
|
||||||
class Request {
|
class Request {
|
||||||
|
|
||||||
private static $request;
|
private static $request;
|
||||||
|
|
||||||
public static function load() {
|
public static function load() {
|
||||||
if (is_array($_REQUEST)) {
|
if (is_array($_REQUEST)) {
|
||||||
foreach ($_REQUEST as $key => $value) {
|
foreach ($_REQUEST as $key => $value) {
|
||||||
self::$request[$key] = $value;
|
self::$request[$key] = $value;
|
||||||
unset($_REQUEST[$key]);
|
unset($_REQUEST[$key]);
|
||||||
|
|
|
@ -1,8 +1,8 @@
|
||||||
disable = false
|
debug = false
|
||||||
debug = false
|
disable = false
|
||||||
session = false
|
|
||||||
smarty = true
|
|
||||||
fckeditor = false
|
fckeditor = false
|
||||||
|
session = false
|
||||||
|
smarty = true
|
||||||
|
|
||||||
[database]
|
[database]
|
||||||
hostname = "localhost"
|
hostname = "localhost"
|
||||||
|
|
|
@ -1,8 +1,8 @@
|
||||||
disable = false
|
debug = false
|
||||||
debug = false
|
disable = false
|
||||||
session = false
|
|
||||||
smarty = false
|
|
||||||
fckeditor = false
|
fckeditor = false
|
||||||
|
session = false
|
||||||
|
smarty = false
|
||||||
|
|
||||||
[database]
|
[database]
|
||||||
hostname = "localhost"
|
hostname = "localhost"
|
||||||
|
|
|
@ -1,8 +1,8 @@
|
||||||
disable = false
|
debug = false
|
||||||
debug = false
|
disable = false
|
||||||
session = false
|
|
||||||
smarty = true
|
|
||||||
fckeditor = false
|
fckeditor = false
|
||||||
|
session = false
|
||||||
|
smarty = true
|
||||||
|
|
||||||
[database]
|
[database]
|
||||||
hostname = "localhost"
|
hostname = "localhost"
|
||||||
|
|
|
@ -1,8 +1,8 @@
|
||||||
disable = false
|
debug = false
|
||||||
debug = false
|
disable = false
|
||||||
session = true
|
|
||||||
smarty = true
|
|
||||||
fckeditor = false
|
fckeditor = false
|
||||||
|
session = true
|
||||||
|
smarty = true
|
||||||
|
|
||||||
[database]
|
[database]
|
||||||
hostname = "localhost"
|
hostname = "localhost"
|
||||||
|
|
|
@ -1,8 +1,8 @@
|
||||||
disable = false
|
debug = false
|
||||||
debug = false
|
disable = false
|
||||||
session = false
|
|
||||||
smarty = true
|
|
||||||
fckeditor = false
|
fckeditor = false
|
||||||
|
session = false
|
||||||
|
smarty = true
|
||||||
|
|
||||||
[database]
|
[database]
|
||||||
hostname = "localhost"
|
hostname = "localhost"
|
||||||
|
|
10
jLib.php
10
jLib.php
|
@ -1,15 +1,17 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
|
date_default_timezone_set('America/New_York');
|
||||||
|
|
||||||
function __autoload($class) {
|
function __autoload($class) {
|
||||||
require_once "/var/www/josh/common/classes/{$class}.php";
|
require_once "/var/www/josh/common/classes/{$class}.php";
|
||||||
}
|
}
|
||||||
|
|
||||||
// Obliterates any passed in PHPSESSID (thanks Google)
|
// Obliterates any passed in PHPSESSID (thanks Google)
|
||||||
if (stripos($_SERVER['REQUEST_URI'], '?PHPSESSID=') !== false) {
|
if (stripos($_SERVER['REQUEST_URI'], '?PHPSESSID=') !== false) {
|
||||||
list($request_uri, $phpsessid) = split('\?PHPSESSID=', $_SERVER['REQUEST_URI'], 2);
|
list($request_uri, $phpsessid) = split('\?PHPSESSID=', $_SERVER['REQUEST_URI'], 2);
|
||||||
header("HTTP/1.1 301 Moved Permanently");
|
header("HTTP/1.1 301 Moved Permanently");
|
||||||
header("Location: {$request_uri}");
|
header("Location: {$request_uri}");
|
||||||
exit();
|
exit();
|
||||||
}
|
}
|
||||||
|
|
||||||
// XHTML compliancy stuff
|
// XHTML compliancy stuff
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue