[ticket/269] Fix codesniffer complaints
B3P-269
This commit is contained in:
@@ -1,242 +0,0 @@
|
||||
<?php
|
||||
/**
|
||||
*
|
||||
* @package phpBB3
|
||||
* @copyright (c) 2006 phpBB Group
|
||||
* @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License v2
|
||||
*
|
||||
* This file creates new schema files for every database.
|
||||
* The filenames will be prefixed with an underscore to not overwrite the current schema files.
|
||||
*
|
||||
* If you overwrite the original schema files please make sure you save the file with UNIX linefeeds.
|
||||
*/
|
||||
|
||||
$schema_path = dirname(__FILE__) . '/../tests/schemas/';
|
||||
$supported_dbms = array(
|
||||
'firebird',
|
||||
'mssql',
|
||||
'mysql_40',
|
||||
'mysql_41',
|
||||
'oracle',
|
||||
'postgres',
|
||||
'sqlite',
|
||||
);
|
||||
|
||||
if (!is_writable($schema_path))
|
||||
{
|
||||
die('Schema path not writable');
|
||||
}
|
||||
|
||||
define('IN_PHPBB', true);
|
||||
define('IN_INSTALL', true);
|
||||
$phpbb_root_path = dirname(__FILE__) . '/../../../../';
|
||||
$phpEx = substr(strrchr(__FILE__, '.'), 1);
|
||||
include($phpbb_root_path . 'common.' . $phpEx);
|
||||
|
||||
// Get board3 portal classes first
|
||||
$classes = $phpbb_container->get('ext.manager')
|
||||
->get_finder()
|
||||
->core_path('ext/board3/portal/')
|
||||
->directory('migrations')
|
||||
->get_classes();
|
||||
|
||||
// Get phpBB classes and merge with above
|
||||
$classes = array_merge($classes, $phpbb_container->get('ext.manager')
|
||||
->get_finder()
|
||||
->core_path('phpbb/')
|
||||
->directory('db/migration/data')
|
||||
->get_classes());
|
||||
$db_tools = new \phpbb\db\tools($db, true);
|
||||
|
||||
$schema_generator = new \phpbb\db\migration\schema_generator($classes, $config, $db, $db_tools, $phpbb_root_path, $phpEx, 'phpbb_');
|
||||
$schema_data = $schema_generator->get_schema();
|
||||
$dbms_type_map = phpbb\db\tools::get_dbms_type_map();
|
||||
|
||||
$fp = fopen($schema_path . 'schema.json', 'wb');
|
||||
fwrite($fp, json_encode($schema_data, JSON_PRETTY_PRINT));
|
||||
fclose($fp);
|
||||
|
||||
foreach ($supported_dbms as $dbms)
|
||||
{
|
||||
$fp = fopen($schema_path . $dbms . '_schema.sql', 'wb');
|
||||
|
||||
// Write Header
|
||||
switch ($dbms)
|
||||
{
|
||||
case 'mysql_40':
|
||||
case 'mysql_41':
|
||||
case 'firebird':
|
||||
case 'sqlite':
|
||||
fwrite($fp, "# DO NOT EDIT THIS FILE, IT IS GENERATED\n");
|
||||
fwrite($fp, "#\n");
|
||||
fwrite($fp, "# To change the contents of this file, edit\n");
|
||||
fwrite($fp, "# phpBB/develop/create_schema_files.php and\n");
|
||||
fwrite($fp, "# run it.\n");
|
||||
break;
|
||||
|
||||
case 'mssql':
|
||||
case 'oracle':
|
||||
case 'postgres':
|
||||
fwrite($fp, "/*\n");
|
||||
fwrite($fp, " * DO NOT EDIT THIS FILE, IT IS GENERATED\n");
|
||||
fwrite($fp, " *\n");
|
||||
fwrite($fp, " * To change the contents of this file, edit\n");
|
||||
fwrite($fp, " * phpBB/develop/create_schema_files.php and\n");
|
||||
fwrite($fp, " * run it.\n");
|
||||
fwrite($fp, " */\n\n");
|
||||
break;
|
||||
}
|
||||
|
||||
$line = '';
|
||||
switch ($dbms)
|
||||
{
|
||||
case 'oracle':
|
||||
$line .= custom_data('oracle') . "\n";
|
||||
break;
|
||||
|
||||
case 'postgres':
|
||||
$line .= "BEGIN;\n\n";
|
||||
$line .= custom_data('postgres') . "\n";
|
||||
$line .= "COMMIT;\n\n";
|
||||
break;
|
||||
}
|
||||
|
||||
fwrite($fp, $line);
|
||||
fclose($fp);
|
||||
}
|
||||
|
||||
/**
|
||||
* Data put into the header for various dbms
|
||||
*/
|
||||
function custom_data($dbms)
|
||||
{
|
||||
switch ($dbms)
|
||||
{
|
||||
case 'oracle':
|
||||
return <<<EOF
|
||||
/*
|
||||
This first section is optional, however its probably the best method
|
||||
of running phpBB on Oracle. If you already have a tablespace and user created
|
||||
for phpBB you can leave this section commented out!
|
||||
|
||||
The first set of statements create a phpBB tablespace and a phpBB user,
|
||||
make sure you change the password of the phpBB user before you run this script!!
|
||||
*/
|
||||
|
||||
/*
|
||||
CREATE TABLESPACE "PHPBB"
|
||||
LOGGING
|
||||
DATAFILE 'E:\ORACLE\ORADATA\LOCAL\PHPBB.ora'
|
||||
SIZE 10M
|
||||
AUTOEXTEND ON NEXT 10M
|
||||
MAXSIZE 100M;
|
||||
|
||||
CREATE USER "PHPBB"
|
||||
PROFILE "DEFAULT"
|
||||
IDENTIFIED BY "phpbb_password"
|
||||
DEFAULT TABLESPACE "PHPBB"
|
||||
QUOTA UNLIMITED ON "PHPBB"
|
||||
ACCOUNT UNLOCK;
|
||||
|
||||
GRANT ANALYZE ANY TO "PHPBB";
|
||||
GRANT CREATE SEQUENCE TO "PHPBB";
|
||||
GRANT CREATE SESSION TO "PHPBB";
|
||||
GRANT CREATE TABLE TO "PHPBB";
|
||||
GRANT CREATE TRIGGER TO "PHPBB";
|
||||
GRANT CREATE VIEW TO "PHPBB";
|
||||
GRANT "CONNECT" TO "PHPBB";
|
||||
|
||||
COMMIT;
|
||||
DISCONNECT;
|
||||
|
||||
CONNECT phpbb/phpbb_password;
|
||||
*/
|
||||
EOF;
|
||||
|
||||
break;
|
||||
|
||||
case 'postgres':
|
||||
return <<<EOF
|
||||
/*
|
||||
Domain definition
|
||||
*/
|
||||
CREATE DOMAIN varchar_ci AS varchar(255) NOT NULL DEFAULT ''::character varying;
|
||||
|
||||
/*
|
||||
Operation Functions
|
||||
*/
|
||||
CREATE FUNCTION _varchar_ci_equal(varchar_ci, varchar_ci) RETURNS boolean AS 'SELECT LOWER($1) = LOWER($2)' LANGUAGE SQL STRICT;
|
||||
CREATE FUNCTION _varchar_ci_not_equal(varchar_ci, varchar_ci) RETURNS boolean AS 'SELECT LOWER($1) != LOWER($2)' LANGUAGE SQL STRICT;
|
||||
CREATE FUNCTION _varchar_ci_less_than(varchar_ci, varchar_ci) RETURNS boolean AS 'SELECT LOWER($1) < LOWER($2)' LANGUAGE SQL STRICT;
|
||||
CREATE FUNCTION _varchar_ci_less_equal(varchar_ci, varchar_ci) RETURNS boolean AS 'SELECT LOWER($1) <= LOWER($2)' LANGUAGE SQL STRICT;
|
||||
CREATE FUNCTION _varchar_ci_greater_than(varchar_ci, varchar_ci) RETURNS boolean AS 'SELECT LOWER($1) > LOWER($2)' LANGUAGE SQL STRICT;
|
||||
CREATE FUNCTION _varchar_ci_greater_equals(varchar_ci, varchar_ci) RETURNS boolean AS 'SELECT LOWER($1) >= LOWER($2)' LANGUAGE SQL STRICT;
|
||||
|
||||
/*
|
||||
Operators
|
||||
*/
|
||||
CREATE OPERATOR <(
|
||||
PROCEDURE = _varchar_ci_less_than,
|
||||
LEFTARG = varchar_ci,
|
||||
RIGHTARG = varchar_ci,
|
||||
COMMUTATOR = >,
|
||||
NEGATOR = >=,
|
||||
RESTRICT = scalarltsel,
|
||||
JOIN = scalarltjoinsel);
|
||||
|
||||
CREATE OPERATOR <=(
|
||||
PROCEDURE = _varchar_ci_less_equal,
|
||||
LEFTARG = varchar_ci,
|
||||
RIGHTARG = varchar_ci,
|
||||
COMMUTATOR = >=,
|
||||
NEGATOR = >,
|
||||
RESTRICT = scalarltsel,
|
||||
JOIN = scalarltjoinsel);
|
||||
|
||||
CREATE OPERATOR >(
|
||||
PROCEDURE = _varchar_ci_greater_than,
|
||||
LEFTARG = varchar_ci,
|
||||
RIGHTARG = varchar_ci,
|
||||
COMMUTATOR = <,
|
||||
NEGATOR = <=,
|
||||
RESTRICT = scalargtsel,
|
||||
JOIN = scalargtjoinsel);
|
||||
|
||||
CREATE OPERATOR >=(
|
||||
PROCEDURE = _varchar_ci_greater_equals,
|
||||
LEFTARG = varchar_ci,
|
||||
RIGHTARG = varchar_ci,
|
||||
COMMUTATOR = <=,
|
||||
NEGATOR = <,
|
||||
RESTRICT = scalargtsel,
|
||||
JOIN = scalargtjoinsel);
|
||||
|
||||
CREATE OPERATOR <>(
|
||||
PROCEDURE = _varchar_ci_not_equal,
|
||||
LEFTARG = varchar_ci,
|
||||
RIGHTARG = varchar_ci,
|
||||
COMMUTATOR = <>,
|
||||
NEGATOR = =,
|
||||
RESTRICT = neqsel,
|
||||
JOIN = neqjoinsel);
|
||||
|
||||
CREATE OPERATOR =(
|
||||
PROCEDURE = _varchar_ci_equal,
|
||||
LEFTARG = varchar_ci,
|
||||
RIGHTARG = varchar_ci,
|
||||
COMMUTATOR = =,
|
||||
NEGATOR = <>,
|
||||
RESTRICT = eqsel,
|
||||
JOIN = eqjoinsel,
|
||||
HASHES,
|
||||
MERGES,
|
||||
SORT1= <);
|
||||
|
||||
EOF;
|
||||
break;
|
||||
}
|
||||
|
||||
return '';
|
||||
}
|
||||
|
||||
echo 'done';
|
||||
@@ -1,385 +0,0 @@
|
||||
<?php
|
||||
/**
|
||||
*
|
||||
* @package Board3 Portal v2.1
|
||||
* @copyright (c) 2013 Board3 Group ( www.board3.de )
|
||||
* @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License v2
|
||||
*
|
||||
*/
|
||||
|
||||
die('This script shouldn\'t be run unless you really know what you do. If this script exists on a live board, please delete it.');
|
||||
|
||||
define('IN_PHPBB', true);
|
||||
define('B3_MODULE_ENABLED', 1);
|
||||
define('GROUPS_TABLE', '$this->table_prefix . \'groups');
|
||||
$phpbb_root_path = '../../../../';
|
||||
$root_path = '../'; // one directory down
|
||||
include($phpbb_root_path . 'includes/startup.php');
|
||||
$php_ex = substr(strrchr(__FILE__, '.'), 1);
|
||||
$phpEx = $php_ex;
|
||||
$table_prefix = 'phpbb_';
|
||||
require_once $phpbb_root_path . 'includes/constants.php';
|
||||
require_once $phpbb_root_path . 'phpbb/class_loader.' . $phpEx;
|
||||
|
||||
$phpbb_class_loader_mock = new \phpbb\class_loader('phpbb_mock_', $phpbb_root_path . '../tests/mock/', "php");
|
||||
$phpbb_class_loader_mock->register();
|
||||
$phpbb_class_loader_ext = new \phpbb\class_loader('\\', $phpbb_root_path . 'ext/', "php");
|
||||
$phpbb_class_loader_ext->register();
|
||||
$phpbb_class_loader = new \phpbb\class_loader('phpbb\\', $phpbb_root_path . 'phpbb/', "php");
|
||||
$phpbb_class_loader->register();
|
||||
|
||||
require($phpbb_root_path . 'includes/functions_content.' . $phpEx);
|
||||
require($phpbb_root_path . 'includes/functions_container.' . $phpEx);
|
||||
include($phpbb_root_path . 'includes/functions_compatibility.' . $phpEx);
|
||||
require($root_path . 'develop/phpbb_functions.' . $phpEx);
|
||||
// Set up container
|
||||
$phpbb_container = phpbb_create_default_container($phpbb_root_path, $phpEx);
|
||||
|
||||
$config_entry = $portal_config_entry = $db_data = array();
|
||||
|
||||
function set_config($name, $val)
|
||||
{
|
||||
global $config_entry;
|
||||
|
||||
if (isset($config_entry[$name]))
|
||||
{
|
||||
trigger_error('Duplicate entry: ' . $name);
|
||||
}
|
||||
|
||||
handle_string($val);
|
||||
|
||||
$config_entry[$name] = $val;
|
||||
}
|
||||
|
||||
function handle_string(&$str)
|
||||
{
|
||||
if (is_string($str) && strpos($str, '$') === 0)
|
||||
{
|
||||
// @codingStandardsIgnoreStart
|
||||
$str = str_replace(',', ' . \',\' . ', $str);
|
||||
// @codingStandardsIgnoreEnd
|
||||
}
|
||||
else if (is_string($str))
|
||||
{
|
||||
$str = "'$str'";
|
||||
}
|
||||
|
||||
if (empty($str))
|
||||
{
|
||||
$str = "''";
|
||||
}
|
||||
}
|
||||
|
||||
function set_portal_config($name, $val)
|
||||
{
|
||||
global $portal_config_entry;
|
||||
|
||||
if (isset($portal_config_entry[$name]))
|
||||
{
|
||||
trigger_error('Duplicate entry: ' . $name);
|
||||
}
|
||||
|
||||
handle_string($val);
|
||||
|
||||
// we do not want serialized entries as they are hard to read
|
||||
if (strpos($val, 'a:') === 1)
|
||||
{
|
||||
// cut preceding and appended quote
|
||||
$val = substr($val, 1, -1);
|
||||
// start unserializing and building
|
||||
$val = unserialize($val);
|
||||
$after_val = 'serialize(array(<br />';
|
||||
foreach ($val as $key => $entry)
|
||||
{
|
||||
if (is_array($entry))
|
||||
{
|
||||
$after_val .= ' array(<br />';
|
||||
foreach ($entry as $one => $two)
|
||||
{
|
||||
handle_string($one);
|
||||
handle_string($two);
|
||||
$after_val .= ' ' . $one . ' => ' . $two . ',<br />';
|
||||
}
|
||||
$after_val .= ' ),<br />';
|
||||
}
|
||||
else
|
||||
{
|
||||
handle_string($key);
|
||||
handle_string($entry);
|
||||
$after_val .= ' ' . $key . ' => ' . $entry . ',<br />';
|
||||
}
|
||||
}
|
||||
$after_val .= ' ))';
|
||||
$val = $after_val;
|
||||
}
|
||||
|
||||
$portal_config_entry[$name] = $val;
|
||||
}
|
||||
|
||||
$db = new db($db_data);
|
||||
board3_get_install_data($db, $root_path, $php_ex, $db_data);
|
||||
|
||||
echo 'set_config entries for migrations:<br /><pre>';
|
||||
foreach ($config_entry as $name => $val)
|
||||
{
|
||||
echo ' array(\'config.add\', array(\'' . $name . '\', ' . $val . ')),<br />';
|
||||
}
|
||||
echo '</pre>';
|
||||
|
||||
echo '<br /><br />set_portal_config entries for migrations:<br /><pre>';
|
||||
foreach ($portal_config_entry as $name => $val)
|
||||
{
|
||||
echo ' $this->set_portal_config(\'' . $name . '\', ' . $val . ');<br />';
|
||||
}
|
||||
echo '</pre>';
|
||||
|
||||
echo '<br /><br />database entries:<br /><pre>';
|
||||
echo $db_data . '</pre><br />';
|
||||
|
||||
/**
|
||||
* This function will install the basic set of portal modules
|
||||
*
|
||||
* only set $purge_modules to false if you already know that the table is empty
|
||||
* set $u_action to where the user should be redirected after this
|
||||
* note that already existing data won't be deleted from the config and portal_config
|
||||
* just to make sure we don't overwrite anything, the IDs won't be reset
|
||||
* !! this function should usually only be executed once upon installing the portal !!
|
||||
* DO NOT set $purge_modules to false unless you want to auto-add all modules again after deleting them (i.e. if your database was corrupted)
|
||||
*/
|
||||
function board3_get_install_data($db, $root_path, $php_ex, &$db_data)
|
||||
{
|
||||
global $phpbb_container;
|
||||
|
||||
$directory = $root_path . 'portal/modules/';
|
||||
$db_data = ' $board3_sql_query = array(<br />';
|
||||
|
||||
/*
|
||||
* this is a list of the basic modules that will be installed
|
||||
* module_name => array(module_column, module_order)
|
||||
*/
|
||||
$modules_ary = array(
|
||||
// left column
|
||||
'portal_main_menu' => array(1, 1),
|
||||
'portal_stylechanger' => array(1, 2),
|
||||
'portal_birthday_list' => array(1, 3),
|
||||
'portal_clock' => array(1, 4),
|
||||
'portal_search' => array(1, 5),
|
||||
'portal_attachments' => array(1, 6),
|
||||
'portal_topposters' => array(1, 7),
|
||||
'portal_latest_members' => array(1, 8),
|
||||
'portal_link_us' => array(1, 9),
|
||||
|
||||
// center column
|
||||
'portal_welcome' => array(2, 1),
|
||||
'portal_recent' => array(2, 2),
|
||||
'portal_announcements' => array(2, 3),
|
||||
'portal_news' => array(2, 4),
|
||||
'portal_poll' => array(2, 5),
|
||||
'portal_whois_online' => array(2, 6),
|
||||
|
||||
// right column
|
||||
'portal_user_menu' => array(3, 1),
|
||||
'portal_statistics' => array(3, 2),
|
||||
'portal_calendar' => array(3, 3),
|
||||
'portal_leaders' => array(3, 4),
|
||||
'portal_latest_bots' => array(3, 5),
|
||||
'portal_links' => array(3, 6),
|
||||
);
|
||||
|
||||
foreach ($modules_ary as $module_name => $module_data)
|
||||
{
|
||||
$new_module_name = '\\board3\\portal\\modules\\' . str_replace('portal_', '', $module_name);
|
||||
if (class_exists($new_module_name))
|
||||
{
|
||||
$c_class = $phpbb_container->get('board3.module.' . str_replace('portal_', '', $module_name));
|
||||
$module_name = $new_module_name;
|
||||
}
|
||||
else
|
||||
{
|
||||
$class_name = $module_name . '_module';
|
||||
if (!class_exists($class_name))
|
||||
{
|
||||
include($directory . $module_name . '.' . $php_ex);
|
||||
}
|
||||
if (!class_exists($class_name))
|
||||
{
|
||||
trigger_error('Class not found: ' . $class_name, E_USER_ERROR);
|
||||
}
|
||||
|
||||
$c_class = new $class_name();
|
||||
$module_name = substr($module_name, 7);
|
||||
}
|
||||
|
||||
$sql_ary = array(
|
||||
'module_classname' => $module_name,
|
||||
'module_column' => $module_data[0],
|
||||
'module_order' => $module_data[1],
|
||||
'module_name' => $c_class->get_name(),
|
||||
'module_image_src' => $c_class->get_image(),
|
||||
'module_group_ids' => '',
|
||||
'module_image_width' => 16,
|
||||
'module_image_height' => 16,
|
||||
'module_status' => B3_MODULE_ENABLED,
|
||||
);
|
||||
$sql = 'INSERT INTO \' . $this->table_prefix . \'portal_modules ' . $db->sql_build_array('INSERT', $sql_ary);
|
||||
$db->sql_query($sql, true);
|
||||
|
||||
$data1 = array();
|
||||
$data2 = array();
|
||||
$db_data .= ' array(<br />';
|
||||
foreach ($sql_ary as $key => $val)
|
||||
{
|
||||
$key = (is_string($key)) ? '\'' . $key . '\'' : $key;
|
||||
$val = (is_string($val)) ? '\'' . $val . '\'' : $val;
|
||||
$db_data .= ' ' . $key . ' => ' . $val . ',<br />';
|
||||
}
|
||||
$db_data .= ' ),<br />';
|
||||
$c_class->install($db->sql_id());
|
||||
}
|
||||
$db_data .= ' );';
|
||||
}
|
||||
|
||||
class db
|
||||
{
|
||||
// start at 0
|
||||
private $sql_id = 0;
|
||||
|
||||
private $id = 0;
|
||||
|
||||
private $int_pointer = 0;
|
||||
|
||||
private $sql_ary = array();
|
||||
|
||||
private $sql_in_set = array();
|
||||
|
||||
private $data = array();
|
||||
|
||||
public function __construct(&$data)
|
||||
{
|
||||
$this->data = &$data;
|
||||
}
|
||||
public function sql_id()
|
||||
{
|
||||
return $this->sql_id;
|
||||
}
|
||||
|
||||
public function sql_query($sql, $increase = false)
|
||||
{
|
||||
if (strpos($sql, 'INSERT') !== false)
|
||||
{
|
||||
//$this->data[] = $sql;
|
||||
}
|
||||
if ($increase)
|
||||
{
|
||||
$this->sql_id++;
|
||||
}
|
||||
$this->id++;
|
||||
$this->sql_ary[$this->id] = $sql;
|
||||
return $this->id;
|
||||
}
|
||||
|
||||
public function sql_build_array($type, $ary)
|
||||
{
|
||||
$data1 = array();
|
||||
$data2 = array();
|
||||
foreach ($ary as $key => $val)
|
||||
{
|
||||
$data1[] = $key;
|
||||
$data2[] = (is_string($val)) ? '\'' . $val . '\'' : $val;
|
||||
}
|
||||
return '(' . implode(', ', $data1) . ') VALUES (' . implode(', ', $data2) . ');';
|
||||
}
|
||||
|
||||
public function sql_in_set($data1, $data2, $bool = -1)
|
||||
{
|
||||
$this->sql_in_set[$this->id + 1] = array($data1, $data2);
|
||||
return '\' . $db->sql_in_set('. $data1 . ', array(' . implode(',', $data2) . (($bool !== -1) ? '), ' . $bool : '') . '))';
|
||||
}
|
||||
|
||||
public function sql_fetchrow($id)
|
||||
{
|
||||
if (isset($this->sql_ary[$id]))
|
||||
{
|
||||
preg_match_all('/SELECT+[a-z0-9A-Z,_ ]+FROM/', $this->sql_ary[$id], $match);
|
||||
if (!empty($match))
|
||||
{
|
||||
// cut "SELECT " and " FROM"
|
||||
$match = substr($match[0][0], 7, strlen($match[0][0]) - 5 - 7);
|
||||
$match = str_replace(', ', ',', $match);
|
||||
$match = explode(',', $match);
|
||||
if (isset($this->sql_in_set[$id][1][$this->int_pointer]))
|
||||
{
|
||||
$ret = array();
|
||||
foreach ($match as $key)
|
||||
{
|
||||
if ($key == $this->sql_in_set[$id][0])
|
||||
{
|
||||
$ret[$key] = $this->sql_in_set[$id][1][$this->int_pointer];
|
||||
}
|
||||
else
|
||||
{
|
||||
$ret[$key] = "{foobar.{$key}.{$this->sql_in_set[$id][1][$this->int_pointer]}}";
|
||||
}
|
||||
}
|
||||
$this->int_pointer++;
|
||||
return $this->preg_replace_value($ret);
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
protected function preg_replace_value($value)
|
||||
{
|
||||
return preg_replace("/\{foobar\.group_id\.\s*([A-Z_]+?)\s*+\}/", "\$groups_ary['$1']", $value);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Convert either 3.0 dbms or 3.1 db driver class name to 3.1 db driver class name.
|
||||
*
|
||||
* If $dbms is a valid 3.1 db driver class name, returns it unchanged.
|
||||
* Otherwise prepends phpbb\db\driver\ to the dbms to convert a 3.0 dbms
|
||||
* to 3.1 db driver class name.
|
||||
*
|
||||
* @param string $dbms dbms parameter
|
||||
* @return db driver class
|
||||
*/
|
||||
function phpbb_convert_30_dbms_to_31($dbms)
|
||||
{
|
||||
// Note: this check is done first because mysqli extension
|
||||
// supplies a mysqli class, and class_exists($dbms) would return
|
||||
// true for mysqli class.
|
||||
// However, per the docblock any valid 3.1 driver name should be
|
||||
// recognized by this function, and have priority over 3.0 dbms.
|
||||
if (class_exists('phpbb\db\driver\\' . $dbms))
|
||||
{
|
||||
return 'phpbb\db\driver\\' . $dbms;
|
||||
}
|
||||
|
||||
if (class_exists($dbms))
|
||||
{
|
||||
// Additionally we could check that $dbms extends phpbb\db\driver\driver.
|
||||
// http://php.net/manual/en/class.reflectionclass.php
|
||||
// Beware of possible performance issues:
|
||||
// http://stackoverflow.com/questions/294582/php-5-reflection-api-performance
|
||||
// We could check for interface implementation in all paths or
|
||||
// only when we do not prepend phpbb\db\driver\.
|
||||
|
||||
/*
|
||||
$reflection = new \ReflectionClass($dbms);
|
||||
|
||||
if ($reflection->isSubclassOf('phpbb\db\driver\driver'))
|
||||
{
|
||||
return $dbms;
|
||||
}
|
||||
*/
|
||||
|
||||
return $dbms;
|
||||
}
|
||||
|
||||
throw new \RuntimeException("You have specified an invalid dbms driver: $dbms");
|
||||
}
|
||||
@@ -1,47 +0,0 @@
|
||||
<?php
|
||||
/**
|
||||
*
|
||||
* @package Board3 Portal v2.1
|
||||
* @copyright (c) 2013 Board3 Group ( www.board3.de )
|
||||
* @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License v2
|
||||
*
|
||||
*/
|
||||
|
||||
namespace phpbb\di\extension;
|
||||
|
||||
if (!function_exists('realpath'))
|
||||
{
|
||||
/**
|
||||
* A wrapper for realpath
|
||||
* @ignore
|
||||
*/
|
||||
function phpbb_realpath($path)
|
||||
{
|
||||
return phpbb_own_realpath($path);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
/**
|
||||
* A wrapper for realpath
|
||||
*/
|
||||
function phpbb_realpath($path)
|
||||
{
|
||||
$realpath = realpath($path);
|
||||
|
||||
// Strangely there are provider not disabling realpath but returning strange values. :o
|
||||
// We at least try to cope with them.
|
||||
if ($realpath === $path || $realpath === false)
|
||||
{
|
||||
return phpbb_own_realpath($path);
|
||||
}
|
||||
|
||||
// Check for DIRECTORY_SEPARATOR at the end (and remove it!)
|
||||
if (substr($realpath, -1) == DIRECTORY_SEPARATOR)
|
||||
{
|
||||
$realpath = substr($realpath, 0, -1);
|
||||
}
|
||||
|
||||
return $realpath;
|
||||
}
|
||||
}
|
||||
@@ -1,324 +0,0 @@
|
||||
<?php
|
||||
/**
|
||||
*
|
||||
* @package dbal
|
||||
* @copyright (c) 2013 phpBB Group
|
||||
* @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License v2
|
||||
*
|
||||
*/
|
||||
|
||||
/**
|
||||
* @ignore
|
||||
*/
|
||||
if (!defined('IN_PHPBB'))
|
||||
{
|
||||
exit;
|
||||
}
|
||||
|
||||
/**
|
||||
* Define the basic structure
|
||||
* The format:
|
||||
* array('{TABLE_NAME}' => {TABLE_DATA})
|
||||
* {TABLE_DATA}:
|
||||
* COLUMNS = array({column_name} = array({column_type}, {default}, {auto_increment}))
|
||||
* PRIMARY_KEY = {column_name(s)}
|
||||
* KEYS = array({key_name} = array({key_type}, {column_name(s)})),
|
||||
*
|
||||
* Column Types:
|
||||
* INT:x => SIGNED int(x)
|
||||
* BINT => BIGINT
|
||||
* UINT => mediumint(8) UNSIGNED
|
||||
* UINT:x => int(x) UNSIGNED
|
||||
* TINT:x => tinyint(x)
|
||||
* USINT => smallint(4) UNSIGNED (for _order columns)
|
||||
* BOOL => tinyint(1) UNSIGNED
|
||||
* VCHAR => varchar(255)
|
||||
* CHAR:x => char(x)
|
||||
* XSTEXT_UNI => text for storing 100 characters (topic_title for example)
|
||||
* STEXT_UNI => text for storing 255 characters (normal input field with a max of 255 single-byte chars) - same as VCHAR_UNI
|
||||
* TEXT_UNI => text for storing 3000 characters (short text, descriptions, comments, etc.)
|
||||
* MTEXT_UNI => mediumtext (post text, large text)
|
||||
* VCHAR:x => varchar(x)
|
||||
* TIMESTAMP => int(11) UNSIGNED
|
||||
* DECIMAL => decimal number (5,2)
|
||||
* DECIMAL: => decimal number (x,2)
|
||||
* PDECIMAL => precision decimal number (6,3)
|
||||
* PDECIMAL: => precision decimal number (x,3)
|
||||
* VCHAR_UNI => varchar(255) BINARY
|
||||
* VCHAR_CI => varchar_ci for postgresql, others VCHAR
|
||||
*/
|
||||
|
||||
/**
|
||||
* Step 1: Manipulate phpbb's tables
|
||||
*/
|
||||
$schema_data['phpbb_log']['COLUMNS']['album_id'] = array('UINT', 0);
|
||||
$schema_data['phpbb_log']['COLUMNS']['image_id'] = array('UINT', 0);
|
||||
$schema_data['phpbb_sessions']['COLUMNS']['session_album_id'] = array('UINT', 0);
|
||||
$schema_data['phpbb_sessions']['KEYS']['session_aid'] = array('INDEX', 'session_album_id');
|
||||
|
||||
/**
|
||||
* Step 2: Add own tables
|
||||
*/
|
||||
$schema_data['phpbb_gallery_albums'] = array(
|
||||
'COLUMNS' => array(
|
||||
'album_id' => array('UINT', NULL, 'auto_increment'),
|
||||
'parent_id' => array('UINT', 0),
|
||||
'left_id' => array('UINT', 1),
|
||||
'right_id' => array('UINT', 2),
|
||||
'album_parents' => array('MTEXT_UNI', ''),
|
||||
'album_type' => array('UINT:3', 1),
|
||||
'album_status' => array('UINT:1', 1),
|
||||
'album_contest' => array('UINT', 0),
|
||||
'album_name' => array('VCHAR:255', ''),
|
||||
'album_desc' => array('MTEXT_UNI', ''),
|
||||
'album_desc_options' => array('UINT:3', 7),
|
||||
'album_desc_uid' => array('VCHAR:8', ''),
|
||||
'album_desc_bitfield' => array('VCHAR:255', ''),
|
||||
'album_user_id' => array('UINT', 0),
|
||||
'album_images' => array('UINT', 0),
|
||||
'album_images_real' => array('UINT', 0),
|
||||
'album_last_image_id' => array('UINT', 0),
|
||||
'album_image' => array('VCHAR', ''),
|
||||
'album_last_image_time' => array('INT:11', 0),
|
||||
'album_last_image_name' => array('VCHAR', ''),
|
||||
'album_last_username' => array('VCHAR', ''),
|
||||
'album_last_user_colour' => array('VCHAR:6', ''),
|
||||
'album_last_user_id' => array('UINT', 0),
|
||||
'album_watermark' => array('UINT:1', 1),
|
||||
'album_sort_key' => array('VCHAR:8', ''),
|
||||
'album_sort_dir' => array('VCHAR:8', ''),
|
||||
'display_in_rrc' => array('UINT:1', 1),
|
||||
'display_on_index' => array('UINT:1', 1),
|
||||
'display_subalbum_list' => array('UINT:1', 1),
|
||||
'album_feed' => array('BOOL', 1),
|
||||
'album_auth_access' => array('TINT:1', 0),
|
||||
),
|
||||
'PRIMARY_KEY' => 'album_id',
|
||||
);
|
||||
|
||||
$schema_data['phpbb_gallery_albums_track'] = array(
|
||||
'COLUMNS' => array(
|
||||
'user_id' => array('UINT', 0),
|
||||
'album_id' => array('UINT', 0),
|
||||
'mark_time' => array('TIMESTAMP', 0),
|
||||
),
|
||||
'PRIMARY_KEY' => array('user_id', 'album_id'),
|
||||
);
|
||||
|
||||
$schema_data['phpbb_gallery_comments'] = array(
|
||||
'COLUMNS' => array(
|
||||
'comment_id' => array('UINT', NULL, 'auto_increment'),
|
||||
'comment_image_id' => array('UINT', NULL),
|
||||
'comment_user_id' => array('UINT', 0),
|
||||
'comment_username' => array('VCHAR', ''),
|
||||
'comment_user_colour' => array('VCHAR:6', ''),
|
||||
'comment_user_ip' => array('VCHAR:40', ''),
|
||||
'comment_signature' => array('BOOL', 0),
|
||||
'comment_time' => array('UINT:11', 0),
|
||||
'comment' => array('MTEXT_UNI', ''),
|
||||
'comment_uid' => array('VCHAR:8', ''),
|
||||
'comment_bitfield' => array('VCHAR:255', ''),
|
||||
'comment_edit_time' => array('UINT:11', 0),
|
||||
'comment_edit_count' => array('USINT', 0),
|
||||
'comment_edit_user_id' => array('UINT', 0),
|
||||
),
|
||||
'PRIMARY_KEY' => 'comment_id',
|
||||
'KEYS' => array(
|
||||
'id' => array('INDEX', 'comment_image_id'),
|
||||
'uid' => array('INDEX', 'comment_user_id'),
|
||||
'ip' => array('INDEX', 'comment_user_ip'),
|
||||
'time' => array('INDEX', 'comment_time'),
|
||||
),
|
||||
);
|
||||
|
||||
$schema_data['phpbb_gallery_contests'] = array(
|
||||
'COLUMNS' => array(
|
||||
'contest_id' => array('UINT', NULL, 'auto_increment'),
|
||||
'contest_album_id' => array('UINT', 0),
|
||||
'contest_start' => array('UINT:11', 0),
|
||||
'contest_rating' => array('UINT:11', 0),
|
||||
'contest_end' => array('UINT:11', 0),
|
||||
'contest_marked' => array('TINT:1', 0),
|
||||
'contest_first' => array('UINT', 0),
|
||||
'contest_second' => array('UINT', 0),
|
||||
'contest_third' => array('UINT', 0),
|
||||
),
|
||||
'PRIMARY_KEY' => 'contest_id',
|
||||
);
|
||||
|
||||
$schema_data['phpbb_gallery_favorites'] = array(
|
||||
'COLUMNS' => array(
|
||||
'favorite_id' => array('UINT', NULL, 'auto_increment'),
|
||||
'user_id' => array('UINT', 0),
|
||||
'image_id' => array('UINT', 0),
|
||||
),
|
||||
'PRIMARY_KEY' => 'favorite_id',
|
||||
'KEYS' => array(
|
||||
'uid' => array('INDEX', 'user_id'),
|
||||
'id' => array('INDEX', 'image_id'),
|
||||
),
|
||||
);
|
||||
|
||||
$schema_data['phpbb_gallery_images'] = array(
|
||||
'COLUMNS' => array(
|
||||
'image_id' => array('UINT', NULL, 'auto_increment'),
|
||||
'image_filename' => array('VCHAR:255', ''),
|
||||
'image_name' => array('VCHAR:255', ''),
|
||||
'image_name_clean' => array('VCHAR:255', ''),
|
||||
'image_desc' => array('MTEXT_UNI', ''),
|
||||
'image_desc_uid' => array('VCHAR:8', ''),
|
||||
'image_desc_bitfield' => array('VCHAR:255', ''),
|
||||
'image_user_id' => array('UINT', 0),
|
||||
'image_username' => array('VCHAR:255', ''),
|
||||
'image_username_clean' => array('VCHAR:255', ''),
|
||||
'image_user_colour' => array('VCHAR:6', ''),
|
||||
'image_user_ip' => array('VCHAR:40', ''),
|
||||
'image_time' => array('UINT:11', 0),
|
||||
'image_album_id' => array('UINT', 0),
|
||||
'image_view_count' => array('UINT:11', 0),
|
||||
'image_status' => array('UINT:3', 0),
|
||||
'image_contest' => array('UINT:1', 0),
|
||||
'image_contest_end' => array('TIMESTAMP', 0),
|
||||
'image_contest_rank' => array('UINT:3', 0),
|
||||
'image_filemissing' => array('UINT:3', 0),
|
||||
'image_has_exif' => array('UINT:3', 2),
|
||||
'image_exif_data' => array('TEXT', ''),
|
||||
'image_rates' => array('UINT', 0),
|
||||
'image_rate_points' => array('UINT', 0),
|
||||
'image_rate_avg' => array('UINT', 0),
|
||||
'image_comments' => array('UINT', 0),
|
||||
'image_last_comment' => array('UINT', 0),
|
||||
'image_allow_comments' => array('TINT:1', 1),
|
||||
'image_favorited' => array('UINT', 0),
|
||||
'image_reported' => array('UINT', 0),
|
||||
'filesize_upload' => array('UINT:20', 0),
|
||||
'filesize_medium' => array('UINT:20', 0),
|
||||
'filesize_cache' => array('UINT:20', 0),
|
||||
),
|
||||
'PRIMARY_KEY' => 'image_id',
|
||||
'KEYS' => array(
|
||||
'aid' => array('INDEX', 'image_album_id'),
|
||||
'uid' => array('INDEX', 'image_user_id'),
|
||||
'time' => array('INDEX', 'image_time'),
|
||||
),
|
||||
);
|
||||
|
||||
$schema_data['phpbb_gallery_modscache'] = array(
|
||||
'COLUMNS' => array(
|
||||
'album_id' => array('UINT', 0),
|
||||
'user_id' => array('UINT', 0),
|
||||
'username' => array('VCHAR', ''),
|
||||
'group_id' => array('UINT', 0),
|
||||
'group_name' => array('VCHAR', ''),
|
||||
'display_on_index' => array('TINT:1', 1),
|
||||
),
|
||||
'KEYS' => array(
|
||||
'doi' => array('INDEX', 'display_on_index'),
|
||||
'aid' => array('INDEX', 'album_id'),
|
||||
),
|
||||
);
|
||||
|
||||
$schema_data['phpbb_gallery_permissions'] = array(
|
||||
'COLUMNS' => array(
|
||||
'perm_id' => array('UINT', NULL, 'auto_increment'),
|
||||
'perm_role_id' => array('UINT', 0),
|
||||
'perm_album_id' => array('UINT', 0),
|
||||
'perm_user_id' => array('UINT', 0),
|
||||
'perm_group_id' => array('UINT', 0),
|
||||
'perm_system' => array('INT:3', 0),
|
||||
),
|
||||
'PRIMARY_KEY' => 'perm_id',
|
||||
);
|
||||
|
||||
$schema_data['phpbb_gallery_rates'] = array(
|
||||
'COLUMNS' => array(
|
||||
'rate_image_id' => array('UINT', 0),
|
||||
'rate_user_id' => array('UINT', 0),
|
||||
'rate_user_ip' => array('VCHAR:40', ''),
|
||||
'rate_point' => array('UINT:3', 0),
|
||||
),
|
||||
'PRIMARY_KEY' => array('rate_image_id', 'rate_user_id'),
|
||||
);
|
||||
|
||||
$schema_data['phpbb_gallery_reports'] = array(
|
||||
'COLUMNS' => array(
|
||||
'report_id' => array('UINT', NULL, 'auto_increment'),
|
||||
'report_album_id' => array('UINT', 0),
|
||||
'report_image_id' => array('UINT', 0),
|
||||
'reporter_id' => array('UINT', 0),
|
||||
'report_manager' => array('UINT', 0),
|
||||
'report_note' => array('MTEXT_UNI', ''),
|
||||
'report_time' => array('UINT:11', 0),
|
||||
'report_status' => array('UINT:3', 0),
|
||||
),
|
||||
'PRIMARY_KEY' => 'report_id',
|
||||
);
|
||||
|
||||
$schema_data['phpbb_gallery_roles'] = array(
|
||||
'COLUMNS' => array(
|
||||
'role_id' => array('UINT', NULL, 'auto_increment'),
|
||||
'a_list' => array('UINT:3', 0),
|
||||
'i_view' => array('UINT:3', 0),
|
||||
'i_watermark' => array('UINT:3', 0),
|
||||
'i_upload' => array('UINT:3', 0),
|
||||
'i_edit' => array('UINT:3', 0),
|
||||
'i_delete' => array('UINT:3', 0),
|
||||
'i_rate' => array('UINT:3', 0),
|
||||
'i_approve' => array('UINT:3', 0),
|
||||
'i_lock' => array('UINT:3', 0),
|
||||
'i_report' => array('UINT:3', 0),
|
||||
'i_count' => array('UINT', 0),
|
||||
'i_unlimited' => array('UINT:3', 0),
|
||||
'c_read' => array('UINT:3', 0),
|
||||
'c_post' => array('UINT:3', 0),
|
||||
'c_edit' => array('UINT:3', 0),
|
||||
'c_delete' => array('UINT:3', 0),
|
||||
'm_comments' => array('UINT:3', 0),
|
||||
'm_delete' => array('UINT:3', 0),
|
||||
'm_edit' => array('UINT:3', 0),
|
||||
'm_move' => array('UINT:3', 0),
|
||||
'm_report' => array('UINT:3', 0),
|
||||
'm_status' => array('UINT:3', 0),
|
||||
'a_count' => array('UINT', 0),
|
||||
'a_unlimited' => array('UINT:3', 0),
|
||||
'a_restrict' => array('UINT:3', 0),
|
||||
),
|
||||
'PRIMARY_KEY' => 'role_id',
|
||||
);
|
||||
|
||||
$schema_data['phpbb_gallery_users'] = array(
|
||||
'COLUMNS' => array(
|
||||
'user_id' => array('UINT', 0),
|
||||
'watch_own' => array('UINT:3', 0),
|
||||
'watch_favo' => array('UINT:3', 0),
|
||||
'watch_com' => array('UINT:3', 0),
|
||||
'user_images' => array('UINT', 0),
|
||||
'personal_album_id' => array('UINT', 0),
|
||||
'user_lastmark' => array('TIMESTAMP', 0),
|
||||
'user_last_update' => array('TIMESTAMP', 0),
|
||||
'user_viewexif' => array('UINT:1', 0),
|
||||
'user_permissions' => array('MTEXT_UNI', ''),
|
||||
'user_permissions_changed' => array('TIMESTAMP', 0),
|
||||
'user_allow_comments' => array('TINT:1', 1),
|
||||
'subscribe_pegas' => array('TINT:1', 0),
|
||||
),
|
||||
'PRIMARY_KEY' => 'user_id',
|
||||
'KEYS' => array(
|
||||
'pega' => array('INDEX', array('personal_album_id')),
|
||||
),
|
||||
);
|
||||
|
||||
$schema_data['phpbb_gallery_watch'] = array(
|
||||
'COLUMNS' => array(
|
||||
'watch_id' => array('UINT', NULL, 'auto_increment'),
|
||||
'album_id' => array('UINT', 0),
|
||||
'image_id' => array('UINT', 0),
|
||||
'user_id' => array('UINT', 0),
|
||||
),
|
||||
'PRIMARY_KEY' => 'watch_id',
|
||||
'KEYS' => array(
|
||||
'uid' => array('INDEX', 'user_id'),
|
||||
'id' => array('INDEX', 'image_id'),
|
||||
'aid' => array('INDEX', 'album_id'),
|
||||
),
|
||||
);
|
||||
Reference in New Issue
Block a user