* Copyright 2003 Mark O'Sullivan * This file is part of Vanilla. * Vanilla is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. * Vanilla is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. * You should have received a copy of the GNU General Public License along with Vanilla; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * The latest source code for Vanilla is available at www.lussumo.com * Contact Mark O'Sullivan at mark [at] lussumo [dot] com * * Description: File used by Dynamic Data Management object to change the order of roles */ include '../appg/settings.php'; include '../appg/init_ajax.php'; $PostBackKey = ForceIncomingString('PostBackKey', ''); if ($PostBackKey = '' || $PostBackKey !== $Context->Session->GetCsrfValidationKey()) { die($Context->GetDefinition('ErrPostBackKeyInvalid')); } if (!$Context->Session->User->Permission('PERMISSION_SORT_ROLES')) { die($Context->GetDefinition('ErrPermissionSortRoles')); } $Sql = 'update ' . GetTableName('Role', $DatabaseTables, $Configuration["DATABASE_TABLE_PREFIX"]) . ' set ' . $DatabaseColumns['Role']['Priority'] . " = '//1' where " . $DatabaseColumns['Role']['RoleID'] . " = '//2';"; $SortOrder = ForceIncomingArray('RoleID', array()); $ItemCount = count($SortOrder); for ($i = 0; $i < $ItemCount; $i++) { $RoleID = ForceInt($SortOrder[$i], null); if ($RoleID !== null) { $ExecSql = str_replace(array('//1', '//2'), array($i, $RoleID), $Sql); $Context->Database->Execute($ExecSql, 'AJAX', 'ReorderRoles', 'Failed to reorder roles', 0); } } echo $SortOrder; $Context->Unload();
} // Define a constant to prevent a register_globals attack on the configuration paths define('IN_VANILLA', '1'); //upgrade database if ($Configuration['DATABASE_VERSION'] < 2) { include_once $Configuration['APPLICATION_PATH'] . 'appg/database.php'; include_once $Configuration['DATABASE_PATH']; include_once $Configuration['LIBRARY_PATH'] . 'Framework/Framework.Functions.php'; include_once $Configuration['LIBRARY_PATH'] . 'Framework/Framework.Class.Database.php'; include_once $Configuration['LIBRARY_PATH'] . 'Framework/Framework.Class.' . $Configuration['DATABASE_SERVER'] . '.php'; include_once $Configuration['LIBRARY_PATH'] . 'Framework/Framework.Class.SqlBuilder.php'; include_once $Configuration['LIBRARY_PATH'] . 'Framework/Framework.Class.MessageCollector.php'; include_once $Configuration['LIBRARY_PATH'] . 'Framework/Framework.Class.ErrorManager.php'; include_once $Configuration['LIBRARY_PATH'] . 'Framework/Framework.Class.ObjectFactory.php'; include_once $Configuration['LIBRARY_PATH'] . 'Framework/Framework.Class.StringManipulator.php'; include_once $Configuration['LIBRARY_PATH'] . 'Framework/Framework.Class.Context.php'; include_once $Configuration['LIBRARY_PATH'] . 'Framework/Framework.Class.Delegation.php'; include_once $Configuration['LIBRARY_PATH'] . 'Vanilla/Vanilla.Functions.php'; include_once $Configuration['LIBRARY_PATH'] . $Configuration['AUTHENTICATION_MODULE']; include_once $Configuration['LIBRARY_PATH'] . 'People/People.Class.Session.php'; include_once $Configuration['LIBRARY_PATH'] . 'People/People.Class.PasswordHash.php'; include_once $Configuration['LIBRARY_PATH'] . 'People/People.Class.User.php'; $Context = new Context($Configuration); $Context->DatabaseTables =& $DatabaseTables; $Context->DatabaseColumns =& $DatabaseColumns; $Query = 'ALTER TABLE ' . GetTableName('User', $DatabaseTables, $Configuration["DATABASE_TABLE_PREFIX"]) . ' CHANGE ' . $DatabaseColumns['User']['Password'] . ' ' . $DatabaseColumns['User']['Password'] . ' VARBINARY( 34 ) NULL DEFAULT NULL'; if ($Context->Database->Execute($Query, '', '', '', 0)) { AddConfigurationSetting($Context, 'DATABASE_VERSION', '2'); } unset($Context, $Query); }
if (version_compare(mysql_get_server_info($Connection), '4.1.0', '>=')) { mysql_query('SET NAMES "utf8"', $Connection); $DatabaseCharacterEncoding = 'utf8'; } // Make sure there are no conflicting tables in the database $TableData = @mysql_query('show tables', $Connection); if (!$TableData) { $Context->WarningCollector->Add('We had some problems identifying the tables already in your database: ' . mysql_error($Connection)); } else { $TableConflicts = array(); $TableToCompare = array(); while ($Row = mysql_fetch_array($TableData)) { $TableToCompare[] = strtolower($Row[0]); } foreach ($DatabaseTables as $TableKey => $TableName) { $TableName = GetTableName($TableKey, $DatabaseTables, $DBTablePrefix); $TableName = strtolower(iif($TableKey == 'User', $DBTablePrefix, '') . $TableName); if (in_array($TableName, $TableToCompare)) { $TableConflicts[] = $TableName; } } if (count($TableConflicts) == count($DatabaseTables)) { $Context->WarningCollector->Add('It appears as though you’ve already got Vanilla installed. If you are attempting to upgrade your existing installation of Vanilla, you should be using the <a href="upgrader.php">upgrade script</a>.'); $AllowNext = 1; } elseif (count($TableConflicts) > 0) { $Context->WarningCollector->Add('There appear to be some tables already in your database that conflict with the tables Vanilla would need to insert. Those tables are: <code>' . implode(', ', $TableConflicts) . '</code>If you are attempting to upgrade your existing installation of Vanilla, you should be using the <a href="upgrader.php">upgrade script</a>.'); } else { // Go ahead and install the database tables // Open the database file & retrieve sql $SqlLines = @file($WorkingDirectory . 'mysql.sql'); if (!$SqlLines) {
function GetID($var, $adm = true) { $de = bindechex($var, 3); $num = strlen($de); $num2 = $num - 2; $num3 = $num2 - 2; $type = substr($de, $num2 - 2, $num2); $type = GetItemType(substr($type, 0, 2)); $item = substr($de, 0, $num2 - 2); $code = bindechex($item, 5); if ($type == '') { return lang('off_emptyslot'); } else { return GetItemID(GetTableName($type), $code, $adm); } }
/** * Set main table * * @param string $TableName Table name * @param string $TableAlias Table reference * @param string $CustomTablePrefix * @return void * * <b>Usage example:</b> * <code> * $sql->SetMainTable('Discussion','Discussion'); * </code> * * <b>Complete examples</b> * For complete workable examples check out the {@link http://lussumo.com/docs/doku.php?id=vanilla:development:sqlbuilder Sqlbuilder wiki page} */ function SetMainTable($TableName, $TableAlias = '', $CustomTablePrefix = '') { $CustomTablePrefix = $CustomTablePrefix == '' ? $this->TablePrefix : $CustomTablePrefix; $MapKey = $TableAlias == "" ? $TableName : $TableAlias; $this->TableMap[$MapKey] = $TableName; $this->MainTable = array("TableName" => GetTableName($TableName, $this->Context->DatabaseTables, $CustomTablePrefix), "TableAlias" => $TableAlias); }