Пример #1
0
function yourls_get_all_options()
{
    global $ydb;
    $table = YOURLS_DB_TABLE_OPTIONS;
    $allopt = $ydb->get_results("SELECT `option_name`, `option_value` FROM `{$table}` WHERE 1=1");
    foreach ((array) $allopt as $option) {
        $ydb->option[$option->option_name] = yourls_maybe_unserialize($option->option_value);
    }
}
Пример #2
0
/**
 * Read all options from DB at once
 *
 * The goal is to read all options at once and then populate array $ydb->option, to prevent further
 * SQL queries if we need to read an option value later.
 * It's also a simple check whether YOURLS is installed or not (no option = assuming not installed) after
 * a check for DB server reachability has been performed
 *
 * @since 1.4
 */
function yourls_get_all_options()
{
    global $ydb;
    // Allow plugins to short-circuit all options. (Note: regular plugins are loaded after all options)
    $pre = yourls_apply_filter('shunt_all_options', false);
    if (false !== $pre) {
        return $pre;
    }
    $table = YOURLS_DB_TABLE_OPTIONS;
    $allopt = $ydb->get_results("SELECT `option_name`, `option_value` FROM `{$table}` WHERE 1=1");
    foreach ((array) $allopt as $option) {
        $ydb->option[$option->option_name] = yourls_maybe_unserialize($option->option_value);
    }
    if (property_exists($ydb, 'option')) {
        $ydb->option = yourls_apply_filter('get_all_options', $ydb->option);
        $ydb->installed = true;
    } else {
        // Zero option found: either YOURLS is not installed or DB server is dead
        if (!yourls_is_db_alive()) {
            yourls_db_dead();
            // YOURLS will die here
        }
        $ydb->installed = false;
    }
}
Пример #3
0
/**
 * Read all options from DB at once
 *
 */
function yourls_get_all_options()
{
    global $ydb;
    // Allow plugins to short-circuit all options. (Note: regular plugins are loaded after all options)
    $pre = yourls_apply_filter('shunt_all_options', false);
    if (false !== $pre) {
        return $pre;
    }
    $table = YOURLS_DB_TABLE_OPTIONS;
    $allopt = $ydb->get_results("SELECT `option_name`, `option_value` FROM `{$table}` WHERE 1=1");
    foreach ((array) $allopt as $option) {
        $ydb->option[$option->option_name] = yourls_maybe_unserialize($option->option_value);
    }
    $ydb->option = yourls_apply_filter('get_all_options', $ydb->option);
}