Ejemplo n.º 1
0
 /**
  * @return void 
  */
 public function __construct(array $cfg, $price, $email, $ref, $currency = 'EUR')
 {
     if (isset($cfg['site'], $cfg['rang'], $cfg['id'], $cfg['key'], $cfg['pass']) && is_numeric($price) && $price > 0 && \bbn\str\text::is_email($email) && $this->check_server()) {
         if (isset(self::$currencies[$currency])) {
             $this->currency = self::$currencies[$currency];
             $this->price = $price * 100;
             $this->email = $email;
             $this->binkey = pack("H*", $cfg['key']);
             $this->ref = $ref;
             $this->cfg = $cfg;
             $this->enc = self::$encryptions[array_rand(self::$encryptions)];
             $this->time = date('c');
             $this->params = array('PBX_SITE' => $this->cfg['site'], 'PBX_RANG' => $this->cfg['rang'], 'PBX_IDENTIFIANT' => $this->cfg['id'], 'PBX_TOTAL' => $this->price, 'PBX_DEVISE' => $this->currency, 'PBX_CMD' => $this->ref, 'PBX_PORTEUR' => $this->email, 'PBX_RETOUR' => 'Total:M;nomSession:R;NumAutorisation:A;NumTransaction:T;TypeCarte:C;Erreur:E', 'PBX_REPONDRE_A' => self::$url_reponse, 'PBX_HASH' => $this->enc, 'PBX_TIME' => $this->time);
             $this->process();
             $this->online = 1;
         }
     }
 }
Ejemplo n.º 2
0
 /**
  * Creates a new user and returns its configuration (with the new ID)
  * 
  * @param array $cfg A configuration array
  * @return array 
  */
 public function edit($cfg, $id_user = false)
 {
     $fields = array_unique(array_merge(array_values($this->cfg['arch']['users']), $this->cfg['additional_fields']));
     $cfg[$this->cfg['arch']['users']['status']] = 1;
     foreach ($cfg as $k => $v) {
         if (!in_array($k, $fields)) {
             unset($cfg[$k]);
         }
     }
     if (!$id_user && isset($cfg[$this->cfg['arch']['users']['id']])) {
         $id_user = $cfg[$this->cfg['arch']['users']['id']];
         unset($cfg[$this->cfg['arch']['users']['id']]);
     }
     if ($id_user && (!isset($cfg[$this->cfg['arch']['users']['email']]) || \bbn\str\text::is_email($cfg[$this->cfg['arch']['users']['email']]))) {
         $this->db->update($this->cfg['tables']['users'], $cfg, [$this->cfg['arch']['users']['id'] => $id_user]);
         return $cfg;
     }
     return false;
 }