svn:eol-style got murdered on some files for whatever reason so it gets resurrected now, also set some svn:keywords

This commit is contained in:
Robert Foerster (Dessa)
2010-01-27 08:54:31 +00:00
parent 30f2de8f9e
commit 883963d2e2
190 changed files with 34136 additions and 34136 deletions

View File

@@ -1,91 +1,91 @@
<?php
/**
* This file is part of the Froxlor project.
* Copyright (c) 2003-2009 the SysCP Team (see authors).
* Copyright (c) 2010 the Froxlor Team (see authors).
*
* For the full copyright and license information, please view the COPYING
* file that was distributed with this source code. You can also view the
* COPYING file online at http://files.froxlor.org/misc/COPYING.txt
*
* @copyright (c) the authors
* @author Florian Lippert <flo@syscp.org> (2003-2009)
* @author Froxlor team <team@froxlor.org> (2010-)
* @license GPLv2 http://files.froxlor.org/misc/COPYING.txt
* @package Functions
* @version $Id$
*/
function correctMysqlUsers($mysql_access_host_array)
{
global $db, $settings, $sql, $sql_root;
foreach($sql_root as $mysql_server => $mysql_server_details)
{
$db_root = new db($mysql_server_details['host'], $mysql_server_details['user'], $mysql_server_details['password'], '');
unset($db_root->password);
$users = array();
$users_result = $db_root->query('SELECT * FROM `mysql`.`user`');
while($users_row = $db_root->fetch_array($users_result))
{
if(!isset($users[$users_row['User']])
|| !is_array($users[$users_row['User']]))
{
$users[$users_row['User']] = array(
'password' => $users_row['Password'],
'hosts' => array()
);
}
$users[$users_row['User']]['hosts'][] = $users_row['Host'];
}
$databases = array(
$sql['db']
);
$databases_result = $db->query('SELECT * FROM `' . TABLE_PANEL_DATABASES . '` WHERE `dbserver` = \'' . $mysql_server . '\'');
while($databases_row = $db->fetch_array($databases_result))
{
$databases[] = $databases_row['databasename'];
}
foreach($databases as $username)
{
if(isset($users[$username])
&& is_array($users[$username])
&& isset($users[$username]['hosts'])
&& is_array($users[$username]['hosts']))
{
$password = $users[$username]['password'];
foreach($mysql_access_host_array as $mysql_access_host)
{
$mysql_access_host = trim($mysql_access_host);
if(!in_array($mysql_access_host, $users[$username]['hosts']))
{
$db_root->query('GRANT ALL PRIVILEGES ON `' . str_replace('_', '\_', $db_root->escape($username)) . '`.* TO `' . $db_root->escape($username) . '`@`' . $db_root->escape($mysql_access_host) . '` IDENTIFIED BY \'password\'');
$db_root->query('SET PASSWORD FOR `' . $db_root->escape($username) . '`@`' . $db_root->escape($mysql_access_host) . '` = \'' . $db_root->escape($password) . '\'');
}
}
foreach($users[$username]['hosts'] as $mysql_access_host)
{
if(!in_array($mysql_access_host, $mysql_access_host_array))
{
$db_root->query('REVOKE ALL PRIVILEGES ON * . * FROM `' . $db_root->escape($username) . '`@`' . $db_root->escape($mysql_access_host) . '`');
$db_root->query('REVOKE ALL PRIVILEGES ON `' . str_replace('_', '\_', $db_root->escape($username)) . '` . * FROM `' . $db_root->escape($username) . '`@`' . $db_root->escape($mysql_access_host) . '`');
$db_root->query('DELETE FROM `mysql`.`user` WHERE `User` = "' . $db_root->escape($username) . '" AND `Host` = "' . $db_root->escape($mysql_access_host) . '"');
}
}
}
}
$db_root->query('FLUSH PRIVILEGES');
$db_root->close();
unset($db_root);
}
}
<?php
/**
* This file is part of the Froxlor project.
* Copyright (c) 2003-2009 the SysCP Team (see authors).
* Copyright (c) 2010 the Froxlor Team (see authors).
*
* For the full copyright and license information, please view the COPYING
* file that was distributed with this source code. You can also view the
* COPYING file online at http://files.froxlor.org/misc/COPYING.txt
*
* @copyright (c) the authors
* @author Florian Lippert <flo@syscp.org> (2003-2009)
* @author Froxlor team <team@froxlor.org> (2010-)
* @license GPLv2 http://files.froxlor.org/misc/COPYING.txt
* @package Functions
* @version $Id$
*/
function correctMysqlUsers($mysql_access_host_array)
{
global $db, $settings, $sql, $sql_root;
foreach($sql_root as $mysql_server => $mysql_server_details)
{
$db_root = new db($mysql_server_details['host'], $mysql_server_details['user'], $mysql_server_details['password'], '');
unset($db_root->password);
$users = array();
$users_result = $db_root->query('SELECT * FROM `mysql`.`user`');
while($users_row = $db_root->fetch_array($users_result))
{
if(!isset($users[$users_row['User']])
|| !is_array($users[$users_row['User']]))
{
$users[$users_row['User']] = array(
'password' => $users_row['Password'],
'hosts' => array()
);
}
$users[$users_row['User']]['hosts'][] = $users_row['Host'];
}
$databases = array(
$sql['db']
);
$databases_result = $db->query('SELECT * FROM `' . TABLE_PANEL_DATABASES . '` WHERE `dbserver` = \'' . $mysql_server . '\'');
while($databases_row = $db->fetch_array($databases_result))
{
$databases[] = $databases_row['databasename'];
}
foreach($databases as $username)
{
if(isset($users[$username])
&& is_array($users[$username])
&& isset($users[$username]['hosts'])
&& is_array($users[$username]['hosts']))
{
$password = $users[$username]['password'];
foreach($mysql_access_host_array as $mysql_access_host)
{
$mysql_access_host = trim($mysql_access_host);
if(!in_array($mysql_access_host, $users[$username]['hosts']))
{
$db_root->query('GRANT ALL PRIVILEGES ON `' . str_replace('_', '\_', $db_root->escape($username)) . '`.* TO `' . $db_root->escape($username) . '`@`' . $db_root->escape($mysql_access_host) . '` IDENTIFIED BY \'password\'');
$db_root->query('SET PASSWORD FOR `' . $db_root->escape($username) . '`@`' . $db_root->escape($mysql_access_host) . '` = \'' . $db_root->escape($password) . '\'');
}
}
foreach($users[$username]['hosts'] as $mysql_access_host)
{
if(!in_array($mysql_access_host, $mysql_access_host_array))
{
$db_root->query('REVOKE ALL PRIVILEGES ON * . * FROM `' . $db_root->escape($username) . '`@`' . $db_root->escape($mysql_access_host) . '`');
$db_root->query('REVOKE ALL PRIVILEGES ON `' . str_replace('_', '\_', $db_root->escape($username)) . '` . * FROM `' . $db_root->escape($username) . '`@`' . $db_root->escape($mysql_access_host) . '`');
$db_root->query('DELETE FROM `mysql`.`user` WHERE `User` = "' . $db_root->escape($username) . '" AND `Host` = "' . $db_root->escape($mysql_access_host) . '"');
}
}
}
}
$db_root->query('FLUSH PRIVILEGES');
$db_root->close();
unset($db_root);
}
}

View File

@@ -1,122 +1,122 @@
<?php
/**
* This file is part of the Froxlor project.
* Copyright (c) 2003-2009 the SysCP Team (see authors).
* Copyright (c) 2010 the Froxlor Team (see authors).
*
* For the full copyright and license information, please view the COPYING
* file that was distributed with this source code. You can also view the
* COPYING file online at http://files.froxlor.org/misc/COPYING.txt
*
* @copyright (c) the authors
* @author Florian Lippert <flo@syscp.org> (2003-2009)
* @author Froxlor team <team@froxlor.org> (2010-)
* @license GPLv2 http://files.froxlor.org/misc/COPYING.txt
* @package Functions
* @version $Id$
*/
/**
* Returns an array with all tables with keys which are in the currently selected database
*
* @param db A valid DB-object
* @return array Array with tables and keys
*
* @author Florian Lippert <flo@syscp.org>
*/
function getTables(&$db)
{
// This variable is our return-value
$tables = array();
// The fieldname in the associative array which we get by fetch_array()
$tablefieldname = 'Tables_in_' . $db->database;
// Query for a list of tables in the currently selected database
$tables_result = $db->query('SHOW TABLES');
while($tables_row = $db->fetch_array($tables_result))
{
// Extract tablename
$tablename = $tables_row[$tablefieldname];
// Create sub-array with key tablename
$tables[$tablename] = array();
// Query for a list of indexes of the currently selected table
$keys_result = $db->query('SHOW INDEX FROM ' . $tablename);
while($keys_row = $db->fetch_array($keys_result))
{
// Extract keyname
$keyname = $keys_row['Key_name'];
// If there is aleady a key in our tablename-sub-array with has the same name as our key
// OR if the sequence is not one
// then we have more then index-columns for our keyname
if((isset($tables[$tablename][$keyname]) && $tables[$tablename][$keyname] != '')
|| $keys_row['Seq_in_index'] != '1')
{
// If there is no keyname in the tablename-sub-array set ...
if(!isset($tables[$tablename][$keyname]))
{
// ... then create one
$tables[$tablename][$keyname] = array();
}
// If the keyname-sub-array isn't an array ...
elseif (!is_array($tables[$tablename][$keyname]))
{
// temporary move columname
$tmpkeyvalue = $tables[$tablename][$keyname];
// unset keyname-key
unset($tables[$tablename][$keyname]);
// create new array for keyname-key
$tables[$tablename][$keyname] = array();
// keyindex will be 1 by default, if seq is also 1 we'd better use 0 (this case shouldn't ever occur)
$keyindex = ($keys_row['Seq_in_index'] == '1') ? '0' : '1';
// then move back our tmp columname from above
$tables[$tablename][$keyname][$keyindex] = $tmpkeyvalue;
// end unset the variable afterwards
unset($tmpkeyvalue);
}
// set columname
$tables[$tablename][$keyname][$keys_row['Seq_in_index']] = $keys_row['Column_name'];
}
else
{
// set columname
$tables[$tablename][$keyname] = $keys_row['Column_name'];
}
}
}
return $tables;
}
<?php
/**
* This file is part of the Froxlor project.
* Copyright (c) 2003-2009 the SysCP Team (see authors).
* Copyright (c) 2010 the Froxlor Team (see authors).
*
* For the full copyright and license information, please view the COPYING
* file that was distributed with this source code. You can also view the
* COPYING file online at http://files.froxlor.org/misc/COPYING.txt
*
* @copyright (c) the authors
* @author Florian Lippert <flo@syscp.org> (2003-2009)
* @author Froxlor team <team@froxlor.org> (2010-)
* @license GPLv2 http://files.froxlor.org/misc/COPYING.txt
* @package Functions
* @version $Id$
*/
/**
* Returns an array with all tables with keys which are in the currently selected database
*
* @param db A valid DB-object
* @return array Array with tables and keys
*
* @author Florian Lippert <flo@syscp.org>
*/
function getTables(&$db)
{
// This variable is our return-value
$tables = array();
// The fieldname in the associative array which we get by fetch_array()
$tablefieldname = 'Tables_in_' . $db->database;
// Query for a list of tables in the currently selected database
$tables_result = $db->query('SHOW TABLES');
while($tables_row = $db->fetch_array($tables_result))
{
// Extract tablename
$tablename = $tables_row[$tablefieldname];
// Create sub-array with key tablename
$tables[$tablename] = array();
// Query for a list of indexes of the currently selected table
$keys_result = $db->query('SHOW INDEX FROM ' . $tablename);
while($keys_row = $db->fetch_array($keys_result))
{
// Extract keyname
$keyname = $keys_row['Key_name'];
// If there is aleady a key in our tablename-sub-array with has the same name as our key
// OR if the sequence is not one
// then we have more then index-columns for our keyname
if((isset($tables[$tablename][$keyname]) && $tables[$tablename][$keyname] != '')
|| $keys_row['Seq_in_index'] != '1')
{
// If there is no keyname in the tablename-sub-array set ...
if(!isset($tables[$tablename][$keyname]))
{
// ... then create one
$tables[$tablename][$keyname] = array();
}
// If the keyname-sub-array isn't an array ...
elseif (!is_array($tables[$tablename][$keyname]))
{
// temporary move columname
$tmpkeyvalue = $tables[$tablename][$keyname];
// unset keyname-key
unset($tables[$tablename][$keyname]);
// create new array for keyname-key
$tables[$tablename][$keyname] = array();
// keyindex will be 1 by default, if seq is also 1 we'd better use 0 (this case shouldn't ever occur)
$keyindex = ($keys_row['Seq_in_index'] == '1') ? '0' : '1';
// then move back our tmp columname from above
$tables[$tablename][$keyname][$keyindex] = $tmpkeyvalue;
// end unset the variable afterwards
unset($tmpkeyvalue);
}
// set columname
$tables[$tablename][$keyname][$keys_row['Seq_in_index']] = $keys_row['Column_name'];
}
else
{
// set columname
$tables[$tablename][$keyname] = $keys_row['Column_name'];
}
}
}
return $tables;
}

View File

@@ -1,55 +1,55 @@
<?php
/**
* This file is part of the Froxlor project.
* Copyright (c) 2003-2009 the SysCP Team (see authors).
* Copyright (c) 2010 the Froxlor Team (see authors).
*
* For the full copyright and license information, please view the COPYING
* file that was distributed with this source code. You can also view the
* COPYING file online at http://files.froxlor.org/misc/COPYING.txt
*
* @copyright (c) the authors
* @author Florian Lippert <flo@syscp.org> (2003-2009)
* @author Froxlor team <team@froxlor.org> (2010-)
* @license GPLv2 http://files.froxlor.org/misc/COPYING.txt
* @package Functions
* @version $Id$
*/
//
// remove_remarks will strip the sql comment lines out of an uploaded sql file
// The whole function has been taken from the phpbb installer, copyright by the phpbb team, phpbb in summer 2004.
//
function remove_remarks($sql)
{
$lines = explode("\n", $sql);
// try to keep mem. use down
$sql = "";
$linecount = count($lines);
$output = "";
for ($i = 0;$i < $linecount;$i++)
{
if(($i != ($linecount - 1))
|| (strlen($lines[$i]) > 0))
{
if(substr($lines[$i], 0, 1) != "#")
{
$output.= $lines[$i] . "\n";
}
else
{
$output.= "\n";
}
// Trading a bit of speed for lower mem. use here.
$lines[$i] = "";
}
}
return $output;
}
<?php
/**
* This file is part of the Froxlor project.
* Copyright (c) 2003-2009 the SysCP Team (see authors).
* Copyright (c) 2010 the Froxlor Team (see authors).
*
* For the full copyright and license information, please view the COPYING
* file that was distributed with this source code. You can also view the
* COPYING file online at http://files.froxlor.org/misc/COPYING.txt
*
* @copyright (c) the authors
* @author Florian Lippert <flo@syscp.org> (2003-2009)
* @author Froxlor team <team@froxlor.org> (2010-)
* @license GPLv2 http://files.froxlor.org/misc/COPYING.txt
* @package Functions
* @version $Id$
*/
//
// remove_remarks will strip the sql comment lines out of an uploaded sql file
// The whole function has been taken from the phpbb installer, copyright by the phpbb team, phpbb in summer 2004.
//
function remove_remarks($sql)
{
$lines = explode("\n", $sql);
// try to keep mem. use down
$sql = "";
$linecount = count($lines);
$output = "";
for ($i = 0;$i < $linecount;$i++)
{
if(($i != ($linecount - 1))
|| (strlen($lines[$i]) > 0))
{
if(substr($lines[$i], 0, 1) != "#")
{
$output.= $lines[$i] . "\n";
}
else
{
$output.= "\n";
}
// Trading a bit of speed for lower mem. use here.
$lines[$i] = "";
}
}
return $output;
}

View File

@@ -1,140 +1,140 @@
<?php
/**
* This file is part of the Froxlor project.
* Copyright (c) 2003-2009 the SysCP Team (see authors).
* Copyright (c) 2010 the Froxlor Team (see authors).
*
* For the full copyright and license information, please view the COPYING
* file that was distributed with this source code. You can also view the
* COPYING file online at http://files.froxlor.org/misc/COPYING.txt
*
* @copyright (c) the authors
* @author Florian Lippert <flo@syscp.org> (2003-2009)
* @author Froxlor team <team@froxlor.org> (2010-)
* @license GPLv2 http://files.froxlor.org/misc/COPYING.txt
* @package Functions
* @version $Id$
*/
//
// split_sql_file will split an uploaded sql file into single sql statements.
// Note: expects trim() to have already been run on $sql
// The whole function has been taken from the phpbb installer, copyright by the phpbb team, phpbb in summer 2004.
//
function split_sql_file($sql, $delimiter)
{
// Split up our string into "possible" SQL statements.
$tokens = explode($delimiter, $sql);
// try to save mem.
$sql = "";
$output = array();
// we don't actually care about the matches preg gives us.
$matches = array();
// this is faster than calling count($oktens) every time thru the loop.
$token_count = count($tokens);
for ($i = 0;$i < $token_count;$i++)
{
// Don't wanna add an empty string as the last thing in the array.
if(($i != ($token_count - 1))
|| (strlen($tokens[$i] > 0)))
{
// This is the total number of single quotes in the token.
$total_quotes = preg_match_all("/'/", $tokens[$i], $matches);
// Counts single quotes that are preceded by an odd number of backslashes,
// which means they're escaped quotes.
$escaped_quotes = preg_match_all("/(?<!\\\\)(\\\\\\\\)*\\\\'/", $tokens[$i], $matches);
$unescaped_quotes = $total_quotes - $escaped_quotes;
// If the number of unescaped quotes is even, then the delimiter did NOT occur inside a string literal.
if(($unescaped_quotes % 2) == 0)
{
// It's a complete sql statement.
$output[] = $tokens[$i];
// save memory.
$tokens[$i] = "";
}
else
{
// incomplete sql statement. keep adding tokens until we have a complete one.
// $temp will hold what we have so far.
$temp = $tokens[$i] . $delimiter;
// save memory..
$tokens[$i] = "";
// Do we have a complete statement yet?
$complete_stmt = false;
for ($j = $i + 1;(!$complete_stmt && ($j < $token_count));$j++)
{
// This is the total number of single quotes in the token.
$total_quotes = preg_match_all("/'/", $tokens[$j], $matches);
// Counts single quotes that are preceded by an odd number of backslashes,
// which means they're escaped quotes.
$escaped_quotes = preg_match_all("/(?<!\\\\)(\\\\\\\\)*\\\\'/", $tokens[$j], $matches);
$unescaped_quotes = $total_quotes - $escaped_quotes;
if(($unescaped_quotes % 2) == 1)
{
// odd number of unescaped quotes. In combination with the previous incomplete
// statement(s), we now have a complete statement. (2 odds always make an even)
$output[] = $temp . $tokens[$j];
// save memory.
$tokens[$j] = "";
$temp = "";
// exit the loop.
$complete_stmt = true;
// make sure the outer loop continues at the right point.
$i = $j;
}
else
{
// even number of unescaped quotes. We still don't have a complete statement.
// (1 odd and 1 even always make an odd)
$temp.= $tokens[$j] . $delimiter;
// save memory.
$tokens[$j] = "";
}
}
// for..
}
// else
}
}
return $output;
}
<?php
/**
* This file is part of the Froxlor project.
* Copyright (c) 2003-2009 the SysCP Team (see authors).
* Copyright (c) 2010 the Froxlor Team (see authors).
*
* For the full copyright and license information, please view the COPYING
* file that was distributed with this source code. You can also view the
* COPYING file online at http://files.froxlor.org/misc/COPYING.txt
*
* @copyright (c) the authors
* @author Florian Lippert <flo@syscp.org> (2003-2009)
* @author Froxlor team <team@froxlor.org> (2010-)
* @license GPLv2 http://files.froxlor.org/misc/COPYING.txt
* @package Functions
* @version $Id$
*/
//
// split_sql_file will split an uploaded sql file into single sql statements.
// Note: expects trim() to have already been run on $sql
// The whole function has been taken from the phpbb installer, copyright by the phpbb team, phpbb in summer 2004.
//
function split_sql_file($sql, $delimiter)
{
// Split up our string into "possible" SQL statements.
$tokens = explode($delimiter, $sql);
// try to save mem.
$sql = "";
$output = array();
// we don't actually care about the matches preg gives us.
$matches = array();
// this is faster than calling count($oktens) every time thru the loop.
$token_count = count($tokens);
for ($i = 0;$i < $token_count;$i++)
{
// Don't wanna add an empty string as the last thing in the array.
if(($i != ($token_count - 1))
|| (strlen($tokens[$i] > 0)))
{
// This is the total number of single quotes in the token.
$total_quotes = preg_match_all("/'/", $tokens[$i], $matches);
// Counts single quotes that are preceded by an odd number of backslashes,
// which means they're escaped quotes.
$escaped_quotes = preg_match_all("/(?<!\\\\)(\\\\\\\\)*\\\\'/", $tokens[$i], $matches);
$unescaped_quotes = $total_quotes - $escaped_quotes;
// If the number of unescaped quotes is even, then the delimiter did NOT occur inside a string literal.
if(($unescaped_quotes % 2) == 0)
{
// It's a complete sql statement.
$output[] = $tokens[$i];
// save memory.
$tokens[$i] = "";
}
else
{
// incomplete sql statement. keep adding tokens until we have a complete one.
// $temp will hold what we have so far.
$temp = $tokens[$i] . $delimiter;
// save memory..
$tokens[$i] = "";
// Do we have a complete statement yet?
$complete_stmt = false;
for ($j = $i + 1;(!$complete_stmt && ($j < $token_count));$j++)
{
// This is the total number of single quotes in the token.
$total_quotes = preg_match_all("/'/", $tokens[$j], $matches);
// Counts single quotes that are preceded by an odd number of backslashes,
// which means they're escaped quotes.
$escaped_quotes = preg_match_all("/(?<!\\\\)(\\\\\\\\)*\\\\'/", $tokens[$j], $matches);
$unescaped_quotes = $total_quotes - $escaped_quotes;
if(($unescaped_quotes % 2) == 1)
{
// odd number of unescaped quotes. In combination with the previous incomplete
// statement(s), we now have a complete statement. (2 odds always make an even)
$output[] = $temp . $tokens[$j];
// save memory.
$tokens[$j] = "";
$temp = "";
// exit the loop.
$complete_stmt = true;
// make sure the outer loop continues at the right point.
$i = $j;
}
else
{
// even number of unescaped quotes. We still don't have a complete statement.
// (1 odd and 1 even always make an odd)
$temp.= $tokens[$j] . $delimiter;
// save memory.
$tokens[$j] = "";
}
}
// for..
}
// else
}
}
return $output;
}