Пример #1
0
function temp_instead_admin_page_update()
{
    $mode = $_POST['temp_instead_mode'];
    if ($mode) {
        $mode = intval($mode);
        if (yourls_get_option('temp_instead_mode') !== false) {
            echo '<b>Redirect mode was updated successfully.</b>';
            yourls_update_option('temp_instead_mode', $mode);
        } else {
            echo '<b>Redirect mode was stored successfully.</b>';
            yourls_add_option('temp_instead_mode', $mode);
        }
    }
}
Пример #2
0
function abdulrauf_adminreCaptcha_save_admin()
{
    $pubkey = $_POST['abdulrauf_adminreCaptcha_public_key'];
    $privkey = $_POST['abdulrauf_adminreCaptcha_private_key'];
    if (yourls_get_option('abdulrauf_adminreCaptcha_pub_key') !== false) {
        yourls_update_option('abdulrauf_adminreCaptcha_pub_key', $pubkey);
    } else {
        yourls_add_option('abdulrauf_adminreCaptcha_pub_key', $pubkey);
    }
    if (yourls_get_option('abdulrauf_adminreCaptcha_priv_key') !== false) {
        yourls_update_option('abdulrauf_adminreCaptcha_priv_key', $privkey);
    } else {
        yourls_add_option('abdulrauf_adminreCaptcha_priv_key', $privkey);
    }
    echo "Saved";
}
Пример #3
0
/**
 * Main func for upgrade from 1.4.3 to 1.5
 *
 */
function yourls_upgrade_to_15()
{
    // Create empty 'active_plugins' entry in the option if needed
    if (yourls_get_option('active_plugins') === false) {
        yourls_add_option('active_plugins', array());
    }
    echo "<p>Enabling the plugin API. Please wait...</p>";
    // Alter URL table to store titles
    global $ydb;
    $table_url = YOURLS_DB_TABLE_URL;
    $sql = "ALTER TABLE `{$table_url}` ADD `title` TEXT AFTER `url`;";
    $ydb->query($sql);
    echo "<p>Updating table structure. Please wait...</p>";
    // Update .htaccess
    yourls_create_htaccess();
    echo "<p>Updating .htaccess file. Please wait...</p>";
}
Пример #4
0
/**
 * Update (add if doesn't exist) an option to DB
 *
 * Pretty much stolen from WordPress
 *
 * @since 1.4
 * @param string $option Option name. Expected to not be SQL-escaped.
 * @param mixed $newvalue Option value. Must be serializable if non-scalar. Expected to not be SQL-escaped.
 * @return bool False if value was not updated, true otherwise.
 */
function yourls_update_option($option_name, $newvalue)
{
    global $ydb;
    $table = YOURLS_DB_TABLE_OPTIONS;
    $option_name = trim($option_name);
    if (empty($option_name)) {
        return false;
    }
    // Use clone to break object refs -- see commit 09b989d375bac65e692277f61a84fede2fb04ae3
    if (is_object($newvalue)) {
        $newvalue = clone $newvalue;
    }
    $option_name = yourls_escape($option_name);
    $oldvalue = yourls_get_option($option_name);
    // If the new and old values are the same, no need to update.
    if ($newvalue === $oldvalue) {
        return false;
    }
    if (false === $oldvalue) {
        yourls_add_option($option_name, $newvalue);
        return true;
    }
    $_newvalue = yourls_escape(yourls_maybe_serialize($newvalue));
    yourls_do_action('update_option', $option_name, $oldvalue, $newvalue);
    $ydb->query("UPDATE `{$table}` SET `option_value` = '{$_newvalue}' WHERE `option_name` = '{$option_name}'");
    if ($ydb->rows_affected == 1) {
        $ydb->option[$option_name] = $newvalue;
        return true;
    }
    return false;
}
Пример #5
0
function yourls_update_option($option_name, $newvalue)
{
    global $ydb;
    $table = YOURLS_DB_TABLE_OPTIONS;
    $safe_option_name = yourls_escape($option_name);
    $oldvalue = yourls_get_option($safe_option_name);
    // If the new and old values are the same, no need to update.
    if ($newvalue === $oldvalue) {
        return false;
    }
    if (false === $oldvalue) {
        yourls_add_option($option_name, $newvalue);
        return true;
    }
    $_newvalue = yourls_escape(yourls_maybe_serialize($newvalue));
    $ydb->query("UPDATE `{$table}` SET `option_value` = '{$_newvalue}' WHERE `option_name` = '{$option_name}'");
    if ($ydb->rows_affected == 1) {
        $ydb->option[$option_name] = $newvalue;
        return true;
    }
    return false;
}
Пример #6
0
function spb_recaptcha_save_admin()
{
    $pubkey = $_POST['spb_recaptcha_public_key'];
    $privkey = $_POST['spb_recaptcha_private_key'];
    $solvemediaCKey = $_POST['spb_recaptcha_solvemediaCKey'];
    $solvemediaVKey = $_POST['spb_recaptcha_solvemediaVKey'];
    $solvemediaHKey = $_POST['spb_recaptcha_solvemediaHKey'];
    if (yourls_get_option('spb_recaptcha_pub_key') !== false) {
        yourls_update_option('spb_recaptcha_pub_key', $pubkey);
    } else {
        yourls_add_option('spb_recaptcha_pub_key', $pubkey);
    }
    if (yourls_get_option('spb_recaptcha_priv_key') !== false) {
        yourls_update_option('spb_recaptcha_priv_key', $privkey);
    } else {
        yourls_add_option('spb_recaptcha_priv_key', $privkey);
    }
    if (yourls_get_option('spb_recaptcha_solvemediaCKey') !== false) {
        yourls_update_option('spb_recaptcha_solvemediaCKey', $solvemediaCKey);
    } else {
        yourls_add_option('spb_recaptcha_solvemediaCKey', $solvemediaCKey);
    }
    if (yourls_get_option('spb_recaptcha_solvemediaVKey') !== false) {
        yourls_update_option('spb_recaptcha_solvemediaVKey', $solvemediaVKey);
    } else {
        yourls_add_option('spb_recaptcha_solvemediaVKey', $solvemediaVKey);
    }
    if (yourls_get_option('spb_recaptcha_solvemediaHKey') !== false) {
        yourls_update_option('spb_recaptcha_solvemediaHKey', $solvemediaHKey);
    } else {
        yourls_add_option('spb_recaptcha_solvemediaHKey', $solvemediaHKey);
    }
    echo "Saved";
}