Ejemplo n.º 1
1
 public function post_id_new1_new2_handler()
 {
     global $FANNIE_PLUGIN_SETTINGS, $FANNIE_OP_DB;
     $dbc = FannieDB::get($FANNIE_PLUGIN_SETTINGS['GiveUsMoneyDB']);
     $ret = array('errors' => '');
     $safe = $this->safetyCheck();
     if ($safe !== true) {
         $ret['errors'] = $safe;
     } else {
         $keyfile = realpath(dirname(__FILE__) . '/keys/public.key');
         $pubkey = openssl_pkey_get_public(file_get_contents($keyfile));
         $try = openssl_public_encrypt($this->new1, $encrypted, $pubkey);
         if (!$try) {
             $ret['errors'] = 'Error occurred during encryption';
         } else {
             if ($this->new1 !== $this->new2) {
                 $ret['errors'] = 'New values do not match';
             } else {
                 $model = new GumTaxIdentifiersModel($dbc);
                 $model->card_no($this->id);
                 $model->encryptedTaxIdentifier($encrypted);
                 $model->maskedTaxIdentifier(substr($this->new1, -4));
                 $model->save();
             }
         }
     }
     echo json_encode($ret);
     return false;
 }