protected function action() { //Salvataggio nuovo avatar Utente $user = Session::getObj(Session::UTENTE); $msg = new SysMsg(); $avatar = new Avatar($_FILES["browse"]); $this->redirect = "user/adduseravatar"; $abort = 0; if (!($avatar->isValidType() && $avatar->isValidExtension())) { Session::setObj(Session::SYSMSG, $msg->setMessage('Formato file immagine non ammesso. [png - jpeg - gif]')->setType(SysMsg::MSG_ALERT)); $this->redirect = "user/fancymessage"; $abort = 1; } if (!$avatar->isValidSize()) { Session::setObj(Session::SYSMSG, $msg->setMessage('Dimensione file immagine non ammessa. [Max ' . Avatar::MAX_FILE_SIZE . ']')->setType(SysMsg::MSG_ALERT)); $this->redirect = "user/fancymessage"; $abort = 1; } if (!$avatar->noErrorDetected()) { Session::setObj(Session::SYSMSG, $msg->setMessage('Impossibile aprire il file immagine. Errore generico.')->setType(SysMsg::MSG_ALERT)); $this->redirect = "user/fancymessage"; $abort = 1; } if (!$abort) { $avatar->save($user->getId()); } }
public function upload_new_avatar() { //Upload de la nouvelle image de profil $user_id = unserialize($this->session->userdata('user_obj'))->id; $upload = new Upload(); $res = $upload->upload_avatar($user_id, array('userfile')); //Enregistrement dans la BDD if ($res) { $new_avatar = new Avatar(); $new_avatar->url = $upload->files_uploaded[0][0]; $new_avatar->id_user = $user_id; $new_avatar->save(); } redirect('account/change_img_profile', 'refresh'); }
public function activate($user) { // Get Facebook profile info $facebookID = $user["id"]; $name = $user["name"]; $email = $user["email"]; // Put that profile info into the database $sql = "INSERT INTO artists (name, email, photo, facebookID) values(:name, :email, 'facebook.jpg', :facebookID)"; $stmt = $this->profile->con->prepare($sql); $stmt->execute(array("name" => $name, "email" => $email, "facebookID" => $facebookID)); // Get Facebook profile pic and put it in the user's avatar directory $photo = "http://graph.facebook.com/" . $facebookID . "/picture?width=225"; $id = $this->profile->gimme("id", "email", $email); include_once $_SERVER["DOCUMENT_ROOT"] . "/app/model/avatar.model.php"; $avatar = new Avatar(); $avatar->save($photo, $id); return $id; }
<?php include_once $_SERVER["DOCUMENT_ROOT"] . "/app/controller/access.controller.php"; include_once $_SERVER["DOCUMENT_ROOT"] . "/app/model/profile.model.php"; $profile = new Profile(); if (!empty($_POST) && $_SERVER['REQUEST_URI'] != "/search/") { $id = $_SESSION["id"]; if (empty($profile->gimme("name", "id", $id))) { include_once $_SERVER["DOCUMENT_ROOT"] . "/app/model/sign-up.model.php"; $signUp = new signUp(); $signUp->notifySlack($id, $_POST["name"], $_POST["occupation"], $_POST["location"], $_POST["cause"]); } if (!empty($_FILES["photo"]["name"])) { include_once $_SERVER["DOCUMENT_ROOT"] . "/app/model/avatar.model.php"; $avatar = new Avatar(); $avatar->save($_FILES["photo"], $id); } if (isset($_POST["jcrop-x"]) && $_POST["jcrop-w"] != 0) { // Create array to hold jcrop values $jcrop = array(); // Push incoming jcrop values to jcrop[] array_push($jcrop, $_POST["jcrop-x"], $_POST["jcrop-y"], $_POST["jcrop-w"], $_POST["jcrop-h"]); // Get Avatar class so we can crop include_once $_SERVER["DOCUMENT_ROOT"] . "/app/model/avatar.model.php"; $avatar = new Avatar(); $avatar->crop($jcrop, $id); } unset($_POST["jcrop-x"]); unset($_POST["jcrop-y"]); unset($_POST["jcrop-w"]); unset($_POST["jcrop-h"]);
/** * Enregistrement d'un nouvel utilisateur avec une webcam */ public function register_validation_with_cam() { $this->load->library('form_validation'); $this->load->helper('form'); $this->form_validation->set_error_delimiters('<div class="alert alert-error"><button type="button" class="close" data-dismiss="alert">×</button>', '</div>'); //mise en place des regles $this->form_validation->set_rules('name', 'Nom', 'required|encode_php_tags|htmlspecialchars|trim|xss_clean|max_length[20]'); $this->form_validation->set_rules('vorname', 'Prénom', 'required|encode_php_tags|htmlspecialchars|trim|xss_clean|max_length[20]'); $this->form_validation->set_rules('password', 'Mot de passe', 'required|alpha|max_length[20]'); $this->form_validation->set_rules('email', 'Email', 'required|valid_email|max_length[150]'); $this->form_validation->set_rules('sexe', 'Sexe', 'required|matches[sexe]'); $this->form_validation->set_rules('cgu', 'Conditions générales d\'utilisation', 'required'); $this->form_validation->set_rules('url_capture', 'Photo(s) capturée(s)', 'required'); if ($this->form_validation->run() == FALSE) { //on affiche le formulaire $this->register(); } else { //creation de l'utilisateur $user = new User(); $user->name = $this->input->post('name'); $user->vorname = $this->input->post('vorname'); $user->password = strtolower($this->input->post('password')); $user->email = $this->input->post('email'); if ($this->input->post('sexe') == "Femme") { $user->sex = 0; } else { $user->sex = 1; } //sauvegarde de l'utilisateur $user->save(); // decompossition des images capturées $list_capture = explode(',', $this->input->post('url_capture'), 4); //upload de l'avatar $avatar_up = new Upload(); if ($avatar_up->upload_avatar_capture($user->id, $list_capture)) { //Verification de la conformité de l'avatar // appel FaceDetection... //Enregistrement dans la BDD de chaque avatar //print_r($avatar_up->files_uploaded); for ($i = 0; $i < count($avatar_up->files_uploaded); $i++) { $new_avatar = new Avatar(); $new_avatar->url = $avatar_up->files_uploaded[$i][0]; $new_avatar->id_user = $user->id; $new_avatar->save(); } //notification $this->session->set_userdata('notif_ok', '<div class="alert alert-success"><button type="button" class="close" data-dismiss="alert">×</button><strong>Inscription réussite!</strong> Vous pouvez maintenant vous connecter au site !</div>'); //redirection sur l'accueil redirect('home/index', 'refresh'); } else { //on supprime l'utilisateur et son espace de travail $user->delete(); //on affiche le formulaire $this->register(); } } }