/**
 * @return string Encoded secret+URL token
 */
function dbs_getToken()
{
    return trim(base64_encode(dbs_getSecret() . ' ' . get_bloginfo('wpurl')), '=');
}
Example #2
0
function dbs_push()
{
    //test for secret
    $secret = dbs_getSecret();
    if (stripslashes($_REQUEST['secret']) != $secret) {
        die("You don't know me");
    }
    $tokens = get_option('outlandish_sync_tokens') ?: array();
    //	echo $sql = gzinflate($_POST['sql']);
    $sql = stripslashes($_POST['sql']);
    if ($sql && preg_match('|^/\\* Dump of database |', $sql)) {
        //backup current DB
        dbs_makeBackup();
        //store options
        $optionCache = dbs_cacheOptions();
        //load posted data
        dbs_loadSql($sql);
        //clear object cache
        wp_cache_flush();
        //reinstate options
        dbs_restoreOptions($optionCache);
        echo 'OK';
    } else {
        echo 'Error: invalid SQL dump';
    }
    exit;
}