View Single Post
  #1  
Old 3rd February 2015, 01:10
Giorgatzelos's Avatar
Giorgatzelos Giorgatzelos is offline
Senior Member
 
Join Date: Nov 2009
Greece
Posts: 300
Default help needed with zen fixes...
Hi i am posting the code that deletes, checks if invalid or adds your ip @ zentracker...i noticed that there is no check if the current ip is in use already and gines a message that Your current ip is already in use and redirects to /membres/options as the other checks do, so when trying to add the ip and the system already has it added you get an integrity sql error...can anyone help me add this check?Thanks in advance...

Code:
/**
  * Suppression d'une IP
  */
  public function executeSupprimerip(sfWebRequest $r) {
    $q = Doctrine_Query::create()
      ->delete('Ip i')
      ->where("UNIX_TIMESTAMP(i.creation) = ?", $r->getUrlParameter("t"))
      ->andWhere("i.mid = ?", $this->getUser()->getAttribute("id"))
      ->execute();
    $this->getUser()->setFlash("notice", $this->getContext()->getI18N()->__("Your IP address has been deleted."));
    $this->redirect("membres/options");
  }
  
 /**
  * Ajout d'une IP
  */
  public function executeAjouterip(sfWebRequest $r) {
    if (!filter_var($r->getPostParameter("adresseip"), FILTER_VALIDATE_IP)) {
      $this->getUser()->setFlash("error", $this->getContext()->getI18N()->__("Invalid IP address."));
      $this->redirect("membres/options");
    }
    
    // On ajoute la nouvelle IP
    $ip = new Ip();
    $ip->setIp(inet_pton($r->getPostParameter("adresseip")));
    $ip->setMid($this->getUser()->getAttribute("id"));
    $ip->setCreation(date("Y-m-d H:i:s"));
    $ip->setLastconnect(date("Y-m-d H:i:s"));
    $ip->save();
    $this->getUser()->setFlash("notice", $this->getContext()->getI18N()->__("Your IP address has been added !"));
    $this->redirect("membres/options");
  }
Reply With Quote