public function show()
 {
     $identicon = new Identicon();
     // $identicon->displayImage('*****@*****.**');
     // $imageData = $identicon->getImageData('*****@*****.**');
     $imageData = $identicon->getImageDataUri('syafiq');
     return view('identicon', compact('imageData'));
 }
Ejemplo n.º 2
0
 /**
  * Get the identicon for a model. This function will overwrite the previous avatar
  *
  * @param string $idData The data (name or id) that will be used to generate an identicon
  *
  * @return string The path to the generated identicon
  */
 protected function getIdenticon($idData)
 {
     Service::getContainer()->get('logger')->info('Generating new identicon for "' . $this->getName() . '" in ' . $this->getAvatarPath());
     $identicon = new Identicon();
     $imageData = $identicon->getImageData($idData, 250);
     $path = $this->getAvatarPath($imageData);
     file_put_contents(DOC_ROOT . $path, $imageData);
     return $path;
 }
Ejemplo n.º 3
0
 /**
  * Get the identicon for a model. This function will overwrite the previous avatar
  *
  * @param string $idData The data (name or id) that will be used to generate an identicon
  *
  * @return string The path to the generated identicon
  */
 protected function getIdenticon($idData)
 {
     $fileName = $this->getAvatarFileName();
     Service::getContainer()->get('logger')->info('Generating new identicon for "' . $this->getName() . '" in ' . static::AVATAR_LOCATION . $fileName);
     $identicon = new Identicon();
     $imageDataUri = $identicon->getImageDataUri($idData, 250);
     file_put_contents(DOC_ROOT . static::AVATAR_LOCATION . $fileName, file_get_contents($imageDataUri));
     return static::AVATAR_LOCATION . $fileName;
 }
Ejemplo n.º 4
0
 public function genIdenticon($name)
 {
     $id = new Identicon();
     return $id->getImageDataUri($name);
 }
Ejemplo n.º 5
0
 /**
  * Set nickname.
  *
  * @access public
  * @param string $nickname
  * @throws Exception
  * @return void
  */
 public function setNickname($nickname)
 {
     if (!Sjcl::isValid($nickname)) {
         throw new Exception('Invalid data.', 66);
     }
     $this->_data->meta->nickname = $nickname;
     // If a nickname is provided, we generate an icon based on a SHA512 HMAC
     // of the users IP. (We assume that if the user did not enter a nickname,
     // the user wants to be anonymous and we will not generate an icon.)
     $icon = $this->_conf->getKey('icon');
     if ($icon != 'none') {
         $pngdata = '';
         $hmac = TrafficLimiter::getHash();
         if ($icon == 'identicon') {
             $identicon = new Identicon();
             $pngdata = $identicon->getImageDataUri($hmac, 16);
         } elseif ($icon == 'vizhash') {
             $vh = new Vizhash16x16();
             $pngdata = 'data:image/png;base64,' . base64_encode($vh->generate($hmac));
         }
         if ($pngdata != '') {
             $this->_data->meta->vizhash = $pngdata;
         }
     }
     // Once the icon is generated, we do not keep the IP address hash.
 }
Ejemplo n.º 6
0
 /**
  * Get the image data uri
  * @param   $string
  * @param   $size
  * @param   $color
  * @return
  */
 public function getImageDataUri($string, $size = 64, $color = null)
 {
     return $this->identicon->getImageDataUri($string, $size, $color);
 }
Ejemplo n.º 7
0
        $errors['PseudoTaken'] = "Le pseudo saisie est déjà utilisé";
    }
    /* Si il y a eu des erreurs on les affiche, sinon on continu l'inscription */
    if ($errors) {
        $allerror = "<ul>";
        foreach ($errors as $key) {
            $allerror .= "<li>" . $key . "</li>";
        }
        $allerror .= "</ul>";
        setFlash($allerror, "danger");
    } else {
        /* On commence l'inscription */
        $nom = ucwords(mb_strtolower($nom, 'UTF-8'));
        $prenom = ucwords(mb_strtolower($prenom, 'UTF-8'));
        /* On lui génère une image de profil */
        $identicon = new Identicon();
        $imageDataUri = $identicon->getImageDataUri($pseudo);
        base64_to_png($imageDataUri, $pseudo);
        $imgname = $pseudo . ".png";
        /* On enregistre notre utilisateur */
        if ($user->register($pseudo, $prenom, $nom, $email, $password, $imgname)) {
            /* Si l'inscription a bien eu lieu, on le connecte */
            $user->login($pseudo, $password);
            /* On rédirige l'utilisateur à l'index */
            $user::redirect('/');
        } else {
            setFlash("Une erreur est survenur lors de votre inscription :/", "danger");
        }
    }
}
//On importe la vue