Example #1
0
 function uppsite_remote_activation()
 {
     $query_var = isset($_REQUEST['msa_remote_activation']) ? $_REQUEST['msa_remote_activation'] : "";
     if (empty($query_var)) {
         return;
     }
     $decoded = json_decode(base64_decode($query_var), true);
     $dataOpts = get_option(MYSITEAPP_OPTIONS_DATA, array());
     $signKey = 1;
     $signVal = get_bloginfo('pingback_url');
     if (array_key_exists('uppsite_secret', $dataOpts) && !empty($dataOpts['uppsite_secret'])) {
         $signKey = 2;
         $signVal = $dataOpts['uppsite_secret'];
     }
     $signVal = md5($signVal);
     if (md5($decoded['data'] . $decoded['secret' . $signKey]) != $decoded['verify' . $signKey] || $decoded['secret' . $signKey] != $signVal) {
         uppsite_provide_feedback(array('error' => 'verification failed', 'signKey' => $signKey));
         return;
     }
     $data = json_decode($decoded['data'], true);
     $prefsOptions = get_option(MYSITEAPP_OPTIONS_PREFS, array());
     $opts = get_option(MYSITEAPP_OPTIONS_OPTS, array());
     $bizOpts = get_option(MYSITEAPP_OPTIONS_BUSINESS, array());
     $refreshPrefs = false;
     $debugPrefs = false;
     foreach ($data as $key => $val) {
         switch ($key) {
             case "app_id":
             case "uppsite_key":
             case "uppsite_secret":
             case "last_native_check":
                 $dataOpts[$key] = $val;
                 break;
             case "update_prefs":
                 $refreshPrefs = true;
                 break;
             case "activated":
             case "webapp_mode":
             case "site_type":
             case "push_control":
                 $opts[$key] = $val;
                 break;
             case "change_biz":
                 $bizOpts = mysiteapp_update_mysiteapp_options($bizOpts, $val);
                 break;
             case "change_prefs":
                 $prefsOptions = mysiteapp_update_mysiteapp_options($prefsOptions, $val);
                 break;
             case 'debug_uppsite':
                 $debugPrefs = true;
                 break;
             case 'reset_uppsite':
                 uppsite_reset_db_vals($dataOpts);
                 break;
         }
     }
     update_option(MYSITEAPP_OPTIONS_DATA, $dataOpts);
     update_option(MYSITEAPP_OPTIONS_OPTS, $opts);
     update_option(MYSITEAPP_OPTIONS_BUSINESS, $bizOpts);
     update_option(MYSITEAPP_OPTIONS_PREFS, $prefsOptions);
     if ($refreshPrefs) {
         uppsite_prefs_init(true);
     }
     if ($debugPrefs) {
         unset($dataOpts['uppsite_key'], $dataOpts['uppsite_secret']);
         $uppsite_options[MYSITEAPP_OPTIONS_DATA] = $dataOpts;
         $uppsite_options[MYSITEAPP_OPTIONS_OPTS] = $opts;
         $uppsite_options[MYSITEAPP_OPTIONS_PREFS] = $prefsOptions;
         uppsite_provide_feedback($uppsite_options);
     }
     uppsite_provide_feedback(true);
 }
Example #2
0
function mysiteapp_admin_init()
{
    if (!uppsite_admin_did_setup()) {
        return;
    }
    $forcePrefsUpdate = uppsite_needs_prefs_update();
    $options = get_option(MYSITEAPP_OPTIONS_OPTS);
    $options['uppsite_plugin_version'] = isset($options['uppsite_plugin_version']) ? $options['uppsite_plugin_version'] : 0;
    if ($options['uppsite_plugin_version'] != MYSITEAPP_PLUGIN_VERSION) {
        $old_version = $options['uppsite_plugin_version'];
        $options['uppsite_plugin_version'] = MYSITEAPP_PLUGIN_VERSION;
        update_option(MYSITEAPP_OPTIONS_OPTS, $options);
        $forcePrefsUpdate = true;
        do_action('uppsite_has_upgraded', floatval($old_version));
    }
    uppsite_prefs_init($forcePrefsUpdate);
}