示例#1
0
/**
 * Standard code module initialisation function.
 */
function init__config()
{
    global $VALUES, $IN_MINIKERNEL_VERSION;
    if ($IN_MINIKERNEL_VERSION == 0) {
        load_options();
        $VALUES = persistant_cache_get('VALUES');
        if (!is_array($VALUES)) {
            $VALUES = $GLOBALS['SITE_DB']->query_select('values', array('*'));
            $VALUES = list_to_map('the_name', $VALUES);
            persistant_cache_set('VALUES', $VALUES);
        }
    } else {
        $VALUES = array();
    }
    global $GET_OPTION_LOOP;
    $GET_OPTION_LOOP = 0;
    global $MULTI_LANG;
    $MULTI_LANG = NULL;
    // Enforce XML db synching
    if (get_db_type() == 'xml' && !running_script('xml_db_import') && is_file(get_file_base() . '/data_custom/xml_db_import.php') && is_dir(get_file_base() . '/.svn')) {
        $last_xml_import = get_value('last_xml_import');
        $mod_time = filemtime(get_file_base() . '/.svn');
        if (is_null($last_xml_import) || intval($last_xml_import) < $mod_time) {
            set_value('last_xml_import', strval(time()));
            header('Location: ' . get_base_url() . '/data_custom/xml_db_import.php');
            exit;
        }
    }
}
示例#2
0
 /**
  * Standard modular listing function for OcCLE FS hooks.
  *
  * @param  array		The current meta-directory path
  * @param  string		The root node of the current meta-directory
  * @param  array		The current directory listing
  * @param  array		A reference to the OcCLE filesystem object
  * @return ~array 		The final directory listing (false: failure)
  */
 function listing($meta_dir, $meta_root_node, $current_dir, &$occle_fs)
 {
     global $OPTIONS;
     if (count($meta_dir) > 0) {
         return false;
     }
     //Directory doesn't exist
     load_options();
     $ret = array_keys($OPTIONS);
     return $ret;
 }
示例#3
0
/**
 * An option has dissappeared somehow - find it via searching our code-base for it's install code. It doesn't get returned, just loaded up. This function will produce a fatal error if we cannot find it.
 *
 * @param  ID_TEXT		The name of the value
 */
function find_lost_option($name)
{
    global $OPTIONS;
    // In the dark dark past, we'd bomb out...
    if (function_exists('find_all_zones') && !defined('HIPHOP_PHP')) {
        // However times are pleasant, the grass is green, the sun high is the summer sky. Let's perform some voodoo magic...
        $all_zones = find_all_zones();
        $search = array();
        $types = array('modules_custom', 'modules');
        foreach ($all_zones as $zone) {
            foreach ($types as $type) {
                $pages = find_all_pages($zone, $type);
                foreach ($pages as $page => $type2) {
                    $search[] = zone_black_magic_filterer(get_file_base() . '/' . $zone . ($zone != '' ? '/' : '') . 'pages/' . $type2 . '/' . $page . '.php');
                }
            }
        }
        require_code('zones2');
        require_code('zones3');
        $all_blocks = find_all_blocks();
        foreach ($all_blocks as $block => $type) {
            $search[] = get_file_base() . '/' . $type . '/blocks/' . $block . '.php';
        }
        if (file_exists(get_file_base() . '/sources_custom/ocf_install.php')) {
            $search[] = get_file_base() . '/sources_custom/ocf_install.php';
        }
        $search[] = get_file_base() . '/sources/ocf_install.php';
        $matches = array();
        foreach ($search as $s) {
            //			echo $s.'<br />';
            $code = file_get_contents($s);
            if (preg_match('#add_config_option\\(\'\\w+\',\'' . str_replace('#', '\\#', preg_quote($name)) . '\',\'\\w+\',\'.+\',\'\\w+\',\'\\w+\'(,1)?\\);#', $code, $matches) > 0) {
                require_code('database_action');
                $upgrade_from = NULL;
                // In case referenced in add_config_option line
                eval($matches[0]);
                load_options();
                break;
                //				fatal_exit(do_ lang_tempcode('CONFIG_OPTION_FETCHED',escape_html($name)));	 CONFIG_OPTION_FETCHED=A config option ({1}) was missing, but has been hunted down and installed. This is an unexpected inconsistency, please refresh the page, and hopefully it has been permanently corrected.
            }
        }
    }
    if (!array_key_exists($name, $OPTIONS)) {
        fatal_exit(do_lang_tempcode('_MISSING_OPTION', escape_html($name)));
    }
}
示例#4
0
/**
 * Add a configuration option into the database, and initialise it with a specified value.
 *
 * @param  ID_TEXT		The language code to the human name of the config option
 * @param  ID_TEXT		The codename for the config option
 * @param  ID_TEXT		The type of the config option
 * @set    float integer tick line text transline transtext list date forum category usergroup colour
 * @param  SHORT_TEXT	The PHP code to execute to get the default value for this option. Be careful not to make a get_option loop.
 * @param  ID_TEXT		The language code for the option category to store the option in
 * @param  ID_TEXT		The language code for the option group to store the option in
 * @param  BINARY			Whether the option is not settable when on a shared ocportal-hosting environment
 * @param  SHORT_TEXT	Extra data for the option
 */
function add_config_option($human_name, $name, $type, $eval, $category, $group, $shared_hosting_restricted = 0, $data = '')
{
    if (!in_array($type, array('float', 'integer', 'tick', 'line', 'text', 'transline', 'transtext', 'list', 'date', '?forum', 'forum', 'category', 'usergroup', 'colour'))) {
        fatal_exit('Invalid config option type');
    }
    $map = array('c_set' => 0, 'config_value' => '', 'the_name' => $name, 'human_name' => $human_name, 'the_type' => $type, 'eval' => $eval, 'the_page' => $category, 'section' => $group, 'explanation' => 'CONFIG_OPTION_' . $name, 'shared_hosting_restricted' => $shared_hosting_restricted, 'c_data' => $data);
    if ($GLOBALS['IN_MINIKERNEL_VERSION'] == 0) {
        $GLOBALS['SITE_DB']->query_insert('config', $map, false, true);
        // Allow failure in case the config option got auto-installed through searching (can happen if the option is referenced efore the module installs right)
    } else {
        $GLOBALS['SITE_DB']->query_insert('config', $map);
        // From installer we want to know if there are errors in our install cycle
    }
    if (function_exists('persistant_cache_delete')) {
        persistant_cache_delete('OPTIONS');
    }
    global $OPTIONS;
    if ($OPTIONS == array()) {
        load_options();
    } else {
        $OPTIONS[$name] = $map;
        if (multi_lang()) {
            unset($OPTIONS[$name]['config_value_translated']);
        }
    }
}
示例#5
0
            continue;
        }
        // if it's the default value, erase from the DB
        if ($defaultOption[1] == $value) {
            $db->query("DELETE FROM `" . SQL_PREFIX . "option` WHERE name = '" . addslashes($keyModule . "_" . $keyName) . "'");
            continue;
        }
        // it's a new value must match the regex
        if (!preg_match($defaultOption[3], $value)) {
            $formErrors[$keyModule][$keyName] = 1;
            continue;
        }
        // the regex match, insert in the DB
        $db->query("INSERT INTO `" . SQL_PREFIX . "option` VALUES " . "('" . addslashes($keyModule . "_" . $keyName) . "', '" . addslashes($value) . "') " . "ON DUPLICATE KEY UPDATE value = '" . addslashes($value) . "'");
    }
}
// reload the options
$options = load_options();
include "inc/header.php";
echo "<form method=POST class=\"well form-horizontal\" >\n    <fieldset>";
echo "<h4>General</h4>";
displayOptForm('general', $generalOptions);
foreach ($modules as $moduleName => $module) {
    $moduleGlobalOptions = $module->getGlobalOptions();
    if (is_array($moduleGlobalOptions)) {
        echo "<h4>" . h8($moduleName) . "</h4>";
        displayOptForm($moduleName, $moduleGlobalOptions);
    }
}
echo "\n    <div class='controls' >\n        <input type=submit class='btn btn-primary' />\n    </div>\n\n    </fieldset>\n    \n</form>";
include 'inc/footer.php';