Skip to content

Commit

Permalink
Use absolute path when including config
Browse files Browse the repository at this point in the history
  • Loading branch information
vampy committed May 22, 2014
1 parent 3f6326c commit b8b9a90
Show file tree
Hide file tree
Showing 23 changed files with 43 additions and 54 deletions.
3 changes: 1 addition & 2 deletions about.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,7 @@
* along with stkaddons. If not, see <http://www.gnu.org/licenses/>.
*/

define('ROOT', './');
require_once(ROOT . 'config.php');
require_once(__DIR__ . DIRECTORY_SEPARATOR . "config.php");

$tpl = new StkTemplate('about.tpl');
$tpl->assign('title', htmlspecialchars(_('STK Add-ons') . ' | ' . _('About')));
Expand Down
6 changes: 1 addition & 5 deletions addons-panel.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,7 @@
* along with stkaddons. If not, see <http://www.gnu.org/licenses/>.
*/

if (!defined('ROOT'))
{
define('ROOT', './');
}
require_once(ROOT . 'config.php');
require_once(__DIR__ . DIRECTORY_SEPARATOR . "config.php");

$a_tpl = new StkTemplate('addons-panel.tpl');

Expand Down
3 changes: 1 addition & 2 deletions addons.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,7 @@
* along with stkaddons. If not, see <http://www.gnu.org/licenses/>.
*/

define('ROOT', './');
require_once(ROOT . 'config.php');
require_once(__DIR__ . DIRECTORY_SEPARATOR . "config.php");
$_GET['type'] = (isset($_GET['type'])) ? $_GET['type'] : NULL;
switch ($_GET['type']) {
default:
Expand Down
3 changes: 1 addition & 2 deletions download.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,7 @@
* along with stkaddons. If not, see <http://www.gnu.org/licenses/>.
*/

define('ROOT', './');
require_once(ROOT . 'config.php');
require_once(__DIR__ . DIRECTORY_SEPARATOR . "config.php");

$dir = $_GET['type'];
$file = $_GET['file'];
Expand Down
3 changes: 1 addition & 2 deletions error.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,7 @@
break;
}

define('ROOT', './');
require_once(ROOT . 'config.php');
require_once(__DIR__ . DIRECTORY_SEPARATOR . "config.php");

$tpl = new StkTemplate('error-page.tpl');
switch ($error_code)
Expand Down
3 changes: 1 addition & 2 deletions generate_xml.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,7 @@
* along with stkaddons. If not, see <http://www.gnu.org/licenses/>.
*/

define('ROOT', './');
require_once(ROOT . 'config.php');
require_once(__DIR__ . DIRECTORY_SEPARATOR . "config.php");

$xml = writeNewsXML();
echo 'News xml written: ' . $xml . '<br />';
Expand Down
3 changes: 1 addition & 2 deletions image.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,5 @@
You should have received a copy of the GNU General Public License along with
stkaddons. If not, see <http://www.gnu.org/licenses/>. */

define('ROOT', './');
require_once(ROOT . 'config.php');
require_once(__DIR__ . DIRECTORY_SEPARATOR . "config.php");
resizeImage($_GET['pic']);
2 changes: 1 addition & 1 deletion include.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
* along with stkaddons. If not, see <http://www.gnu.org/licenses/>.
*/

require_once(ROOT . 'config.php');
require_once(__DIR__ . DIRECTORY_SEPARATOR . "config.php");
require_once(INCLUDE_PATH . 'AccessControl.class.php');
require_once(INCLUDE_PATH . 'DBConnection.class.php');
require_once(INCLUDE_PATH . 'Constants.php');
Expand Down
21 changes: 19 additions & 2 deletions include/DBConnection.class.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,23 @@
<?php

require_once(ROOT . 'config.php');
/**
* copyright 2013 Glenn De Jonghe
* 2013 Stephen Just <[email protected]>
* 2014 Daniel Butum <danibutum at gmail dot com>
* This file is part of SuperTuxKart
*
* stkaddons 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 3 of the License, or
* (at your option) any later version.
*
* stkaddons 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 stkaddons. If not, see <http://www.gnu.org/licenses/>.
*/

/**
* Class DBException
Expand Down
2 changes: 1 addition & 1 deletion include/SLocale.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ private static function setLocale($locale)
$_COOKIE['lang'] = $locale;

// Set translation file info
bindtextdomain('translations', ROOT . 'locale');
bindtextdomain('translations', ROOT_PATH . 'locale');
textdomain('translations');
bind_textdomain_codeset('translations', 'UTF-8');

Expand Down
4 changes: 2 additions & 2 deletions include/Template.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -184,13 +184,13 @@ public static function getTemplateDir($template)
{
if ($template === null)
{
return ROOT . 'tpl/default/';
return TPL_PATH;
}
if (preg_match('/[a-z0-9\\-_]/i', $template))
{
throw new TemplateException('Invalid character in template name.');
}
$dir = ROOT . 'tpl/' . $template . '/';
$dir = ROOT_PATH . 'tpl' . DS . $template . DS;
if (file_exists($dir) && is_dir($dir))
{
return $dir;
Expand Down
3 changes: 1 addition & 2 deletions index.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,7 @@
You should have received a copy of the GNU General Public License along with
stkaddons. If not, see <http://www.gnu.org/licenses/>. */

define('ROOT', './');
require(ROOT . "config.php");
require_once(__DIR__ . DIRECTORY_SEPARATOR . "config.php");
//AccessControl::setLevel(NULL);

$tpl = new StkTemplate('index.tpl');
Expand Down
1 change: 0 additions & 1 deletion install/config-base.php
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,6 @@
define("ASSET_XML", DOWN_LOCATION . "xml/assets.xml");
define("NEWS_XML_LOCAL", UP_LOCATION . "xml/news.xml");
define("ASSET_XML_LOCAL", UP_LOCATION . "xml/news.xml");
define("JPG_ROOT", ROOT);

// add composer autoload
require_once(ROOT_PATH . 'vendor' . DS . 'autoload.php');
3 changes: 1 addition & 2 deletions login.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,7 @@
* along with stkaddons. If not, see <http://www.gnu.org/licenses/>.
*/

define('ROOT', './');
require_once(ROOT . 'config.php');
require_once(__DIR__ . DIRECTORY_SEPARATOR . "config.php");

// define possibly undefined variables
$_POST['user'] = (isset($_POST['user'])) ? $_POST['user'] : null;
Expand Down
6 changes: 1 addition & 5 deletions manage-panel.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,7 @@
* along with stkaddons. If not, see <http://www.gnu.org/licenses/>.
*/

if (!defined('ROOT'))
{
define('ROOT', './');
}
require_once(ROOT . 'config.php');
require_once(__DIR__ . DIRECTORY_SEPARATOR . "config.php");
AccessControl::setLevel('manageaddons');

$_GET['action'] = (isset($_GET['action'])) ? $_GET['action'] : null;
Expand Down
5 changes: 2 additions & 3 deletions manage.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
<?php

/**
* copyright 2011 Stephen Just <[email protected]>
* 2014 Daniel Butum <danibutum at gmail dot com>
Expand All @@ -18,8 +17,8 @@
* You should have received a copy of the GNU General Public License
* along with stkaddons. If not, see <http://www.gnu.org/licenses/>.
*/
define('ROOT', './');
require_once(ROOT . 'config.php');

require_once(__DIR__ . DIRECTORY_SEPARATOR . "config.php");
AccessControl::setLevel('manageaddons');

$_GET['action'] = (isset($_GET['action'])) ? $_GET['action'] : null;
Expand Down
3 changes: 1 addition & 2 deletions music.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,7 @@
* along with stkaddons. If not, see <http://www.gnu.org/licenses/>.
*/

define('ROOT', './');
require_once(ROOT . 'config.php');
require_once(__DIR__ . DIRECTORY_SEPARATOR . "config.php");

$tpl = new StkTemplate('music-browser.tpl');
$tpl->assign('title', htmlspecialchars(_('STK Add-ons') . ' | ' . _('Browse Music')));
Expand Down
3 changes: 1 addition & 2 deletions password-reset.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,7 @@
* along with stkaddons. If not, see <http://www.gnu.org/licenses/>.
*/

define('ROOT', './');
require_once(ROOT . 'config.php');
require_once(__DIR__ . DIRECTORY_SEPARATOR . "config.php");

$tpl = new StkTemplate('password-reset.tpl');
$tpl->assign('title', htmlspecialchars(_('Reset Password') . ' - ' . _('STK Add-ons')));
Expand Down
3 changes: 1 addition & 2 deletions privacy.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,7 @@
* along with stkaddons. If not, see <http://www.gnu.org/licenses/>.
*/

define('ROOT', './');
require_once(ROOT . 'config.php');
require_once(__DIR__ . DIRECTORY_SEPARATOR . "config.php");

$tpl = new StkTemplate('info-page.tpl');
$tpl->assign('title', htmlspecialchars(_('STK Add-ons') . ' | ' . _('Privacy')));
Expand Down
3 changes: 1 addition & 2 deletions register.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,7 @@
* along with stkaddons. If not, see <http://www.gnu.org/licenses/>.
*/

define('ROOT', './');
require_once(ROOT . 'config.php');
require_once(__DIR__ . DIRECTORY_SEPARATOR . "config.php");

$_POST['user'] = (empty($_POST['user'])) ? NULL : $_POST['user'];
$_POST['name'] = (empty($_POST['name'])) ? NULL : $_POST['name'];
Expand Down
3 changes: 1 addition & 2 deletions upload.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,7 @@
* along with stkaddons. If not, see <http://www.gnu.org/licenses/>.
*/

define('ROOT', './');
require_once(ROOT . 'config.php');
require_once(__DIR__ . DIRECTORY_SEPARATOR . "config.php");
AccessControl::setLevel('addAddon');

// Define possibly undefined variables
Expand Down
6 changes: 1 addition & 5 deletions users-panel.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,7 @@
* along with stkaddons. If not, see <http://www.gnu.org/licenses/>.
*/

if (!defined('ROOT'))
{
define('ROOT', './');
}
require_once(ROOT . 'config.php');
require_once(__DIR__ . DIRECTORY_SEPARATOR . "config.php");
AccessControl::setLevel('basicPage');

$user_name = '';
Expand Down
5 changes: 2 additions & 3 deletions users.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,7 @@
* along with stkaddons. If not, see <http://www.gnu.org/licenses/>.
*/

define('ROOT', './');
require_once(ROOT . 'config.php');
require_once(__DIR__ . DIRECTORY_SEPARATOR . "config.php");
AccessControl::setLevel('basicPage');

// set current user if not defined
Expand Down Expand Up @@ -124,7 +123,7 @@

// right panel
ob_start();
include(ROOT . 'users-panel.php');
include(ROOT_PATH . 'users-panel.php');
$panel['right'] = ob_get_clean();

// output the view
Expand Down

0 comments on commit b8b9a90

Please sign in to comment.