/** * @return string Encoded secret+URL token */ function dbsc_getToken() { return trim(base64_encode(dbsc_getSecret() . ' ' . get_bloginfo('wpurl')), '='); }
function dbsc_push() { //test for secret $secret = dbsc_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 dbsc_makeBackup(); //store options $optionCache = dbsc_cacheOptions(); //store orders $orderCache = dbsc_cacheOrders(); //load posted data dbsc_loadSql($sql); //clear object cache wp_cache_flush(); //reinstate options dbsc_restoreOptions($optionCache); dbsc_restoreOrders($orderCache); echo 'OK'; } else { echo 'Error: invalid SQL dump'; } exit; }