186 lines
5.6 KiB
PHP
Executable File
186 lines
5.6 KiB
PHP
Executable File
<?php
|
|
/*******************************************************************************
|
|
* SMF Arcade 2.0.8 (http://www.smfarcade.info) *
|
|
* Copyright (C) 2004-2007 Niko Pahajoki (http://www.madjoki.com) *
|
|
* This program 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. *
|
|
* *
|
|
* This program 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 this program; if not, write to the Free Software *
|
|
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA *
|
|
********************************************************************************
|
|
* ArcadeSettings.php *
|
|
********************************************************************************/
|
|
|
|
if (!defined('SMF'))
|
|
die('Hacking attempt...');
|
|
|
|
/*
|
|
void ArcadeSettings()
|
|
- ...
|
|
|
|
void ArcadeSettingsEdit()
|
|
- ...
|
|
|
|
void ArcadeCategory()
|
|
- ...
|
|
|
|
*/
|
|
|
|
function ArcadeSettings()
|
|
{
|
|
global $sourcedir;
|
|
|
|
require_once($sourcedir . '/Arcade.php');
|
|
ArcadeLoad('admin', 'arcade_settings');
|
|
|
|
$subActions = array(
|
|
'edit' => array('ArcadeSettingsEdit', 'arcade_admin'),
|
|
'save' => array('ArcadeSettingsSave', 'arcade_admin'),
|
|
);
|
|
|
|
$_REQUEST['sa'] = isset($_REQUEST['sa']) && isset($subActions[$_REQUEST['sa']]) ? $_REQUEST['sa'] : 'edit';
|
|
isAllowedTo($subActions[$_REQUEST['sa']][1]);
|
|
|
|
$subActions[$_REQUEST['sa']][0]();
|
|
}
|
|
|
|
function ArcadeSettingsEdit()
|
|
{
|
|
global $context;
|
|
$context['sub_template'] = 'arcadeadmin_settings';
|
|
}
|
|
|
|
function ArcadeSettingsSave()
|
|
{
|
|
// Validate session
|
|
checkSession('post');
|
|
|
|
// This is array for updateSettings
|
|
$settings = array(
|
|
'arcadeEnabled' => isset($_REQUEST['enabled']) ? true : false,
|
|
'gamesPerPage' => (int) $_REQUEST['gamesPerPage'],
|
|
'scoresPerPage' => (int) $_REQUEST['scoresPerPage'],
|
|
'arcadeCheckLevel' => (int) $_REQUEST['arcadeCheckLevel'],
|
|
'gamesDirectory' => $_REQUEST['gamesDirectory'],
|
|
'gamesUrl' => $_REQUEST['gamesUrl'],
|
|
'arcadeGameInformationSide' => (int) $_REQUEST['arcadeGameInformationSide'],
|
|
'arcadeMaxScores' => (int) $_REQUEST['arcadeMaxScores'],
|
|
'arcadePermissionMode' => (int) $_REQUEST['arcadePermissionMode'],
|
|
'arcadePostPermission' => isset($_REQUEST['arcadePostPermission']) ? true : false,
|
|
'arcadePostsPlay' => (int) $_REQUEST['arcadePostsPlay'],
|
|
'arcadePostsPlayPerDay' => (int) $_REQUEST['arcadePostsPlayPerDay']
|
|
);
|
|
|
|
updateSettings($settings);
|
|
|
|
redirectexit('action=arcadesettings');
|
|
}
|
|
|
|
function ArcadeCategory()
|
|
{
|
|
global $context, $sourcedir;
|
|
|
|
require_once($sourcedir . '/Arcade.php');
|
|
ArcadeLoad('admin', 'manage_category');
|
|
|
|
$subActions = array(
|
|
'edit' => array('ArcadeCategoryEdit', 'arcade_admin'),
|
|
'save' => array('ArcadeCategorySave', 'arcade_admin'),
|
|
);
|
|
|
|
$_REQUEST['sa'] = isset($_REQUEST['sa']) && isset($subActions[$_REQUEST['sa']]) ? $_REQUEST['sa'] : 'edit';
|
|
isAllowedTo($subActions[$_REQUEST['sa']][1]);
|
|
|
|
$subActions[$_REQUEST['sa']][0]();
|
|
}
|
|
|
|
function ArcadeCategoryEdit()
|
|
{
|
|
global $context;
|
|
|
|
$context['sub_template'] = 'arcadeadmin_category';
|
|
prepareMemberGroups();
|
|
|
|
$context['arcade']['category'] = prepareCategories();
|
|
|
|
}
|
|
|
|
function ArcadeCategorySave()
|
|
{
|
|
global $db_prefix, $modSettings, $context, $sourcedir;
|
|
|
|
checkSession('post', '',true);
|
|
|
|
$categories = prepareCategories();
|
|
|
|
// Create new categories
|
|
if (isset($_REQUEST['new']) && is_array($_REQUEST['new']))
|
|
foreach ($_REQUEST['new'] as $new)
|
|
{
|
|
$new = trim($new);
|
|
|
|
if (!empty($new))
|
|
db_query("
|
|
INSERT INTO {$db_prefix}arcade_categories
|
|
SET catName = '$new', memberGroups = '-1,0,2'",__FILE__,__LINE__);
|
|
}
|
|
|
|
// Handle modifying old ones
|
|
if (isset($_REQUEST['category']) && is_array($_REQUEST['category']))
|
|
foreach ($_REQUEST['category'] as $id => $category)
|
|
{
|
|
// Handle name changes
|
|
$name = trim($category['name']);
|
|
|
|
if ($category['name'] == '' && !isset($category['delete']))
|
|
continue;
|
|
|
|
if (isset($category['delete']) && $categories[$id]['canRemove'])
|
|
{
|
|
db_query("
|
|
DELETE FROM {$db_prefix}arcade_categories
|
|
WHERE ID_CAT = $id", __FILE__, __LINE__);
|
|
|
|
db_query("
|
|
UPDATE {$db_prefix}arcade_games
|
|
SET ID_CAT = $modSettings[arcadeDefaultCategory]
|
|
WHERE ID_CAT = $id", __FILE__, __LINE__);
|
|
|
|
continue;
|
|
}
|
|
elseif (isset($category['delete']))
|
|
fatal_lang_error('arcade_unable_to_remove', false, array($name));
|
|
|
|
$groups = implode(',', $category['memberGroups']);
|
|
$special = '';
|
|
|
|
if (isset($category['default']) && !$categories[$id]['default'])
|
|
{
|
|
$special = ', special = 1';
|
|
$change['arcadeDefaultCategory'] = $id;
|
|
updateSettings($change);
|
|
|
|
db_query("
|
|
UPDATE {$db_prefix}arcade_categories
|
|
SET special = 0
|
|
WHERE special = 1", __FILE__, __LINE__); // To make sure thre won't be double defaults
|
|
}
|
|
|
|
db_query("
|
|
UPDATE {$db_prefix}arcade_categories
|
|
SET catName = '$name', memberGroups = '$groups' $special
|
|
WHERE ID_CAT = $id", __FILE__, __LINE__);
|
|
}
|
|
|
|
redirectexit('action=arcadecategory');
|
|
}
|
|
|
|
?>
|