|
|
|
<?php
|
|
|
|
/*
|
|
|
|
*
|
|
|
|
* @copyright (c) 2011 animegame.eu
|
|
|
|
* @license http://www.gnu.org/licenses/gpl-3.0.html GNU General Public Licence
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
|
|
|
include_once (ROOT_PATH.'/include/config/db.inc.php');
|
|
|
|
|
|
|
|
|
|
|
|
$GLOBALS['definesInitialized'] = FALSE;
|
|
|
|
$GLOBALS['definesEditable'] = array();
|
|
|
|
|
|
|
|
function initializeDefines() {
|
|
|
|
$sql = 'SELECT * from defines';
|
|
|
|
$qry = mysql_query($sql);
|
|
|
|
while($row = mysql_fetch_assoc($qry)) {
|
|
|
|
if(!defined($row['key'])) {
|
|
|
|
define($row['key'], $row['value']);
|
|
|
|
$GLOBALS['definesEditable'][$row['key']] = $row['editable'];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
$GLOBALS['definesInitialized'] = TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
function defineIfNotDefined($key, $value, $editable = TRUE) {
|
|
|
|
if(!$GLOBALS['definesInitialized']) {
|
|
|
|
initializeDefines();
|
|
|
|
}
|
|
|
|
|
|
|
|
if(!defined($key)) {
|
|
|
|
// we seem that we need to insert this key - value pair!
|
|
|
|
$sql = 'INSERT INTO defines(`key`, `value`, `editable`) values(\''.$key.'\', \''.$value.'\', \''.$editable.'\')';
|
|
|
|
mysql_query($sql);
|
|
|
|
define($key, $value);
|
|
|
|
} else if($GLOBALS['definesEditable'][$key] != $editable){
|
|
|
|
// if the editableness of this value has been changed, adjust the database ;)
|
|
|
|
$sql = 'UPDATE defines SET editable = ' . ($editable?'1':'0') . ' WHERE `key` = \'' .$key.'\'';
|
|
|
|
// echo $sql.'<br>';
|
|
|
|
mysql_query($sql);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
?>
|