Kód: Vybrat vše
<?php
// -------------------------------------------------------------
//
// $Id: cash_db.php 490 2007-06-27 02:17:56Z roadydude $
//
// FILENAME : cash_db.php
// STARTED : Tue March 05, 2007
// COPYRIGHT : © 2006-2007 StarTrekGuide Development Group
// WWW : http://startrekguide.com
// LICENCE : All Rights Reserved
//
// -------------------------------------------------------------
//
// Security message:
//
// This script is potentially dangerous.
// Do NOT FORGET to either remove this script or disable it after you have used it.
// Remove or uncomment the next line (die(".... ) to disable this script.
//
//die();
define('IN_PHPBB', true);
$phpbb_root_path = './';
$phpEx = substr(strrchr(__FILE__, '.'), 1);
include($phpbb_root_path . 'common.' . $phpEx);
// Start session management
$user->session_begin();
$auth->acl($user->data);
if (!$user->data['is_registered'])
{
if ($user->data['is_bot'])
{
redirect(append_sid("{$phpbb_root_path}index.$phpEx"));
}
login_box('', 'LOGIN');
}
else if ($user->data['user_type'] != USER_FOUNDER)
{
die('You are not allowed in here. :)');
}
$mode = request_var('mode', '');
$sql = $sql_id = array();
switch ($mode)
{
case 'install':
$sql[] = 'CREATE TABLE ' . $table_prefix . "cash_amt (
user_id mediumint(8) unsigned NOT NULL default '0',
cash_id mediumint(8) unsigned NOT NULL default '1',
cash_amt int(15) unsigned NOT NULL default '0',
KEY cash_user (user_id, cash_id)
);";
$sql[] = 'CREATE TABLE ' . $table_prefix . "cash (
cash_id MEDIUMINT( 8 ) UNSIGNED NOT NULL AUTO_INCREMENT PRIMARY KEY ,
cash_name VARCHAR( 255 ) NOT NULL ,
cash_value INT( 11 ) UNSIGNED NOT NULL DEFAULT '1',
cash_trade TINYINT( 1 ) UNSIGNED NOT NULL DEFAULT '1'
)";
$sql[] = 'INSERT INTO ' . $table_prefix . "cash (cash_id, cash_name, cash_value, cash_trade)
VALUES ('1', 'Cash', '1', '1')";
$sql[] = 'INSERT INTO ' . ACL_OPTIONS_TABLE . " (auth_option, is_global, is_local) VALUES ('f_cash', 0, 1);";
$sql[] = 'INSERT INTO ' . ACL_OPTIONS_TABLE . " (auth_option, is_global, is_local) VALUES ('a_bank_manage', 1, 0);";
$sql[] = 'INSERT INTO ' . ACL_OPTIONS_TABLE . " (auth_option, is_global, is_local) VALUES ('m_bank_manage', 1, 0);";
$sql[] = 'ALTER TABLE ' . USERS_TABLE . " ADD user_cash int(11) unsigned NOT NULL default '0'";
$sql[] = 'ALTER TABLE ' . USERS_TABLE . " ADD user_cash_date varchar(10) collate utf8_bin NOT NULL default ''";
foreach ($sql as $var)
{
$db->sql_query($var);
$sql_id[] = $db->sql_nextid();
}
unset($sql);
set_config('cash_amt', 1);
set_config('cash_id', 1);
set_config('cash_mod', 1);
set_config('cash_name', 'Cash');
set_config('cash_limit', 0);
set_config('cash_version', '0.3.1');
set_config('load_tplcompile', 1);
//setup cash to add up for all roles which allow posting without mod intervention
$role_ary = "
'ROLE_FORUM_LIMITED',
'ROLE_FORUM_LIMITED_POLLS',
'ROLE_FORUM_STANDARD',
'ROLE_FORUM_POLLS',
'ROLE_FORUM_FULL'";
$sql = 'SELECT role_id
FROM ' . ACL_ROLES_TABLE . "
WHERE role_name IN ($role_ary)
AND role_type = 'f_'";
$result = $db->sql_query($sql);
while ($row = $db->sql_fetchrow($result))
{
$sql_ary[] = array(
'role_id' => $row['role_id'],
'auth_option_id' => $sql_id[3],
'auth_setting' => 1,
);
}
$db->sql_freeresult($result);
$db->sql_multi_insert(ACL_ROLES_DATA_TABLE, $sql_ary);
//insert the modules
$sql = 'SELECT * FROM ' . MODULES_TABLE . " WHERE module_langname = 'ACP_CAT_DOT_MODS'";
$result = $db->sql_query($sql);
$row = $db->sql_fetchrow($result);
$db->sql_freeresult($result);
$sql_ary = array(
'module_enabled' => 1,
'module_display' => 1,
'module_basename' => '',
'module_class' => 'acp',
'parent_id' => $row['module_id'],
'left_id' => $row['right_id'],
'right_id' => $row['right_id'] + 3,
'module_langname' => 'ACP_HANDY_MODS',
'module_mode' => '',
'module_auth' => '',
);
$sql = 'INSERT INTO ' . MODULES_TABLE . ' ' . $db->sql_build_array('INSERT', $sql_ary);
$db->sql_query($sql);
$module_id = $db->sql_nextid();
$sql = 'UPDATE ' . MODULES_TABLE . "
SET left_id = left_id + 4, right_id = right_id + 4
WHERE left_id >= {$sql_ary['left_id']} AND module_id != $module_id";
$db->sql_query($sql);
$sql = 'UPDATE ' . MODULES_TABLE . "
SET right_id = right_id + 4
WHERE left_id < {$sql_ary['left_id']} AND right_id >= {$sql_ary['left_id']} AND module_id != $module_id";
$db->sql_query($sql);
$sql_ary = array(
'module_enabled' => 1,
'module_display' => 1,
'module_basename' => 'cash',
'module_class' => 'acp',
'parent_id' => $module_id,
'left_id' => $row['right_id'] + 1,
'right_id' => $row['right_id'] + 2,
'module_langname' => 'ACP_CASH',
'module_mode' => 'default',
'module_auth' => 'acl_a_',
);
$sql = 'INSERT INTO ' . MODULES_TABLE . ' ' . $db->sql_build_array('INSERT', $sql_ary);
$db->sql_query($sql);
//install the bank management module into the UCP
$sql = 'SELECT MAX(right_id) AS total_right FROM ' . MODULES_TABLE . " WHERE module_class = 'ucp'";
$result = $db->sql_query($sql);
$row = $db->sql_fetchrow($result);
$db->sql_freeresult($result);
$sql_ary = array(
'module_enabled' => 1,
'module_display' => 1,
'module_basename' => '',
'module_class' => 'ucp',
'parent_id' => 0,
'left_id' => $row['total_right'] + 1,
'right_id' => $row['total_right'] + 4,
'module_langname' => 'UCP_BANK',
'module_mode' => '',
'module_auth' => '',
);
$sql = 'INSERT INTO ' . MODULES_TABLE . ' ' . $db->sql_build_array('INSERT', $sql_ary);
$db->sql_query($sql);
$module_id = $db->sql_nextid();
$sql_ary = array(
'module_enabled' => 1,
'module_display' => 1,
'module_basename' => 'bank',
'module_class' => 'ucp',
'parent_id' => $module_id,
'left_id' => $row['total_right'] + 2,
'right_id' => $row['total_right'] + 3,
'module_langname' => 'UCP_BANK_MANAGEMENT',
'module_mode' => 'management',
'module_auth' => 'acl_a_bank_manage || acl_m_bank_manage',
);
$sql = 'INSERT INTO ' . MODULES_TABLE . ' ' . $db->sql_build_array('INSERT', $sql_ary);
$db->sql_query($sql);
//all is finished… remove this file and purge the cache
global $cache;
$cache->purge();
add_log('admin', 'LOG_PURGE_CACHE');
if (file_exists('cash_db.php'))
{
$unlink = @unlink('cash_db.php') ? '' : 'Delete this file (cash_db.php) from your server.';
}
trigger_error("Database successfully updated. This mod has been installed into the ACP/.MODS<br />
$unlink When you are finished installing the cash mod, make sure to purge the cache using the purge cache option in the ACP");
break;
}
?>