From 0077cb99704fe863cf731fc5cab792af2ede96c2 Mon Sep 17 00:00:00 2001 From: Joseph Hunkeler Date: Sun, 17 Apr 2011 20:13:07 -0400 Subject: Backporting retarded amount of changes outside of version control --- include/classes.php | 474 +++++++++++++++++++++++++------------------------- include/functions.php | 15 +- include/sql.class.php | 6 + 3 files changed, 253 insertions(+), 242 deletions(-) (limited to 'include') diff --git a/include/classes.php b/include/classes.php index 5f51e99..ac62115 100644 --- a/include/classes.php +++ b/include/classes.php @@ -1,238 +1,238 @@ -"; - echo "
"; - } - - function CloseContent() - { - echo "
"; - echo ""; - } -} - -class Bayonet_Theme extends Bayonet_Layout -{ - static public $index; - static public $header; - static public $footer; - - static public $name; - static public $root_path; - static public $include_path; - static public $image_path; - static public $config_path; - static public $config; - static public $primary_css; - - static function init() - { - if (!isset($_GET['theme'])) - { - self::$name = Bayonet_Config::$ini['site']['theme']; - } - else - { - self::$name = $_GET['theme']; - } - - decho('Initializing theme variables for \'' . self::$name . '\''); - self::$root_path = dirname(BAYONET_ROOT) . '/themes/' . self::$name; - self::$include_path = self::$root_path . '/include'; - self::$image_path = self::$root_path . '/images'; - self::$primary_css = self::$include_path . '/primary.css'; - self::$config_path = self::$include_path . '/theme.ini'; - - if (!self::is_valid()) - { - die('Theme failed during initialization.'); - } - self::$config = parse_ini_file(self::$config_path, true); - - self::$index = self::$root_path . '/index.php'; - self::$header = self::$root_path . '/header.php'; - self::$footer = self::$root_path . '/footer.php'; - - //decho(get_class_vars(Bayonet_Theme)); //do not re-enable this - self::load(); - } - - static private function is_valid() - { - if (file_exists(self::$root_path) && file_exists(self::$include_path) && - file_exists(self::$config_path)) return true; - else return false; - } - - static function load() - { - global $db, $config; - decho("Loading theme: '" . self::$name . "'"); - require self::$index; - } -} - -class Bayonet_Config -{ - static $ini; - static function init() - { - decho('Parsing configuration data'); - if (file_exists(BAYONET_CONFIG)) - { - self::$ini = parse_ini_file(BAYONET_CONFIG, true); - decho(self::$ini); - } - else die(BAYONET_CONFIG . ' not found'); - } -} - -class Bayonet -{ - static function init() - { - global $db, $config; - Bayonet_Config::init(); - - // Set globally referenced configuration and database variables - $config = Bayonet_Config::$ini; - $db = new Bayonet_SQL(); - - //Connect to the MySQL server - $db->Connect($config['sql']['hostname'], $config['sql']['username'], $config['sql']['password']); - $db->Select_db($config['sql']['database']); - - decho('Initializing Bayonet'); - Bayonet_Theme::init(); - } -} - - -define('PASSWORD', true); -define('NO_PASSWORD', false); -define('CHECKED', true); - -class BayonetForm -{ - static public $request; - - public function __construct($action, $method) - { - $this->request = $_POST; - echo "
\n"; - } - - public function __destruct() - { - echo "
\n"; - } - - function getKeyStates($keys) - { - $good = array(); - $bad = array(); - - if (!is_array($keys)) return array(); - - foreach ($keys as $key => $value) - { - if (!empty($value)) $good[$key] = $value; - else $bad[$key] = $value; - } - - $data = array('set' => $good, 'unset' => $bad); - - return $data; - } - - function verify($submit_key) - { - return $this->verifySubmit($submit_key); - } - - function verifySubmit($submit_key) - { - return isset($this->request[$submit_key]) ? true : false; - } - - function button($extern_name, $value, $text = "Button") - { - echo "\n"; - } - - function submitButton($extern_name, $value = "Submit") - { - echo "\n"; - } - - function reset($value = "Reset") - { - echo "\n"; - } - - function textField($extern_name, $value = null, $isPassword = false, $size = null, - $max = null) - { - $type = 'text'; - if ($isPassword) $type = 'password'; - - $value = filter_var($value, FILTER_SANITIZE_STRING); - echo "\n"; - } - - function radioButton($extern_name, $value, $isChecked = false) - { - if ($isChecked) - { - echo "\n"; - } - else - { - echo "\n"; - } - } - - function checkBox($extern_name, $value, $isChecked = false) - { - if ($isChecked) - { - echo "\n"; - } - else - { - echo "\n"; - } - } - - function dropDown($extern_name, $values = array('None'), $select = null) - { - $selectIterator = 1; - - echo "\n"; - } - - function textArea($extern_name, $rows = 10, $cols = 30, $value = null) - { - $value = filter_var($value, FILTER_SANITIZE_STRING); - echo "\n"; - } -} - +"; + echo "
"; + } + + function CloseContent() + { + echo "
"; + echo ""; + } +} + +class Bayonet_Theme extends Bayonet_Layout +{ + static public $index; + static public $header; + static public $footer; + + static public $name; + static public $root_path; + static public $include_path; + static public $image_path; + static public $config_path; + static public $config; + static public $primary_css; + + static function init() + { + if (!isset($_GET['theme'])) + { + self::$name = Bayonet_Config::$ini['site']['theme']; + } + else + { + self::$name = $_GET['theme']; + } + + decho('Initializing theme variables for \'' . self::$name . '\''); + self::$root_path = dirname(BAYONET_ROOT) . '/themes/' . self::$name; + self::$include_path = self::$root_path . '/include'; + self::$image_path = self::$root_path . '/images'; + self::$primary_css = self::$include_path . '/primary.css'; + self::$config_path = self::$include_path . '/theme.ini'; + + if (!self::is_valid()) + { + die('Theme failed during initialization.'); + } + self::$config = parse_ini_file(self::$config_path, true); + + self::$index = self::$root_path . '/index.php'; + self::$header = self::$root_path . '/header.php'; + self::$footer = self::$root_path . '/footer.php'; + + //decho(get_class_vars(Bayonet_Theme)); //do not re-enable this + self::load(); + } + + static private function is_valid() + { + if (file_exists(self::$root_path) && file_exists(self::$include_path) && + file_exists(self::$config_path)) return true; + else return false; + } + + static function load() + { + global $db, $config; + decho("Loading theme: '" . self::$name . "'"); + require self::$index; + } +} + +class Bayonet_Config +{ + static $ini; + static function init() + { + decho('Parsing configuration data'); + if (file_exists(BAYONET_CONFIG)) + { + self::$ini = parse_ini_file(BAYONET_CONFIG, true); + decho(self::$ini); + } + else die(BAYONET_CONFIG . ' not found'); + } +} + +class Bayonet +{ + static function init() + { + global $db, $config; + Bayonet_Config::init(); + + // Set globally referenced configuration and database variables + $config = Bayonet_Config::$ini; + $db = new Bayonet_SQL(); + + //Connect to the MySQL server + $db->Connect($config['sql']['hostname'], $config['sql']['username'], $config['sql']['password']); + $db->Select_db($config['sql']['database']); + + decho('Initializing Bayonet'); + Bayonet_Theme::init(); + } +} + + +define('PASSWORD', true); +define('NO_PASSWORD', false); +define('CHECKED', true); + +class BayonetForm +{ + static public $request; + + public function __construct($action, $method) + { + $this->request = $_POST; + echo "
\n"; + } + + public function __destruct() + { + echo "
\n"; + } + + function getKeyStates($keys) + { + $good = array(); + $bad = array(); + + if (!is_array($keys)) return array(); + + foreach ($keys as $key => $value) + { + if (!empty($value)) $good[$key] = $value; + else $bad[$key] = $value; + } + + $data = array('set' => $good, 'unset' => $bad); + + return $data; + } + + function verify($submit_key) + { + return $this->verifySubmit($submit_key); + } + + function verifySubmit($submit_key) + { + return isset($this->request[$submit_key]) ? true : false; + } + + function button($extern_name, $value, $text = "Button") + { + echo "\n"; + } + + function submitButton($extern_name, $value = "Submit") + { + echo "\n"; + } + + function reset($value = "Reset") + { + echo "\n"; + } + + function textField($extern_name, $value = null, $isPassword = false, $size = null, + $max = null) + { + $type = 'text'; + if ($isPassword) $type = 'password'; + + $value = filter_var($value, FILTER_SANITIZE_STRING); + echo "\n"; + } + + function radioButton($extern_name, $value, $isChecked = false) + { + if ($isChecked) + { + echo "\n"; + } + else + { + echo "\n"; + } + } + + function checkBox($extern_name, $value, $isChecked = false) + { + if ($isChecked) + { + echo "\n"; + } + else + { + echo "\n"; + } + } + + function dropDown($extern_name, $values = array('None'), $select = null) + { + $selectIterator = 1; + + echo "\n"; + } + + function textArea($extern_name, $rows = 10, $cols = 30, $value = null) + { + $value = filter_var($value, FILTER_SANITIZE_STRING); + echo "\n"; + } +} + ?> \ No newline at end of file diff --git a/include/functions.php b/include/functions.php index 109f11c..370ed9f 100644 --- a/include/functions.php +++ b/include/functions.php @@ -51,11 +51,13 @@ function bbcode_format ($str) '/\[url\=(.*?)\](.*?)\[\/url\]/is', '/\[align\=(.*?)\](.*?)\[\/align\]/is', '/\[size\=(.*?)\](.*?)\[\/size\]/is', - '/\[img\=(.*?)\](.*?)\[\/img\]/is', + '/\[img\](.*?)\[\/img\]/is', '/\[img align\=(.+?)\](.+?)\[\/img\]/is', '/\[mail\](.*?)\[\/mail\]/is', '/\[mail\=(.*?)\](.*?)\[\/mail\]/is', - '/\[list\](.*?)\[\/list\]/is' + '/\[list\](.*?)\[\/list\]/is', + '/\[list=1\](.*?)\[\/list\]/is', + '/\[\*\]/is' ); $simple_replace = array( @@ -75,13 +77,16 @@ function bbcode_format ($str) '$2', '
$2', '$2', - '$2', - '', + '', + '', '$1', '$2', - '
  • $1
  • ' + '', + '
      $1
    ', + '
  • ' ); + $str = preg_replace ($simple_search, $simple_replace, $str); $str = nl2br($str); return $str; diff --git a/include/sql.class.php b/include/sql.class.php index c32de63..cb95a83 100644 --- a/include/sql.class.php +++ b/include/sql.class.php @@ -162,6 +162,12 @@ class Bayonet_SQL return mysqli_num_rows($result); } + + public function InsertID(){ + decho("Fetching insert id for auto increment"); + + return mysqli_insert_id($GLOBALS['___mysqli_ston']); + } } ?> -- cgit