예제 #1
0
 public function create($request)
 {
     $req = $request->getParameters();
     $response = new ViewResponse('assist/ticket');
     if (trim($req['bug']) != '') {
         if (Session::isActive()) {
             $user_id = Session::get()->id;
         } else {
             if (trim($req['email']) != '') {
                 $user_id = $req['email'];
             } else {
                 $user_id = 0;
             }
         }
         if (!empty(Ticket::find('all', ['conditions' => ['ip = ? AND timestamp < ' . (Utils::tps() + 60), $_SERVER['REMOTE_ADDR']]]))) {
             $r = $this->index($request);
             $r->addMessage(ViewMessage::error('Trop d\'envois avec la même IP en une minute, réssayez plus tard.'));
             return $r;
         }
         $ticket = Ticket::create(array('user_id' => $user_id, 'description' => $req['bug'], 'timestamp' => time(), 'ip' => $_SERVER['REMOTE_ADDR']));
         StaffNotification::createNotif('ticket', $user_id, null, $ticket->id);
         $ticket_id = $ticket->id;
         $response->addMessage(ViewMessage::success('Envoyé ! Vous serez notifié de l\'avancement par E-Mail ou Message Privé (Ticket #' . $ticket_id . ')'));
         /*$username = (Session::isActive()) ? Session::get()->username : '******';
         		$notif = new PushoverNotification();
         		$notif->setMessage('Nouveau ticket de '.$username);
         		$notif->setReceiver('all');
         		$notif->setExtraParameter('url', 'http://dreamvids.fr'.WEBROOT.'admin/tickets');
         		$notif->send();*/
     } else {
         $response->addMessage(ViewMessage::error('Merci de nous décrire votre problème.'));
     }
     return $response;
 }
예제 #2
0
 public function create($request)
 {
     $req = $request->getParameters();
     $response = new ViewResponse('assist/ticket');
     if (trim($req['bug']) != '') {
         if (Session::isActive()) {
             $user_id = Session::get()->id;
         } else {
             if (trim($req['email']) != '') {
                 $user_id = $req['email'];
             } else {
                 $user_id = 0;
             }
         }
         $ticket = Ticket::create(array('user_id' => $user_id, 'description' => $req['bug'], 'timestamp' => time(), 'ip' => $_SERVER['REMOTE_ADDR']));
         $ticket_id = $ticket->id;
         $response->addMessage(ViewMessage::success('Envoyé ! Vous serez notifié de l\'avancement par E-Mail ou Message Privé (Ticket #' . $ticket_id . ')'));
         /*$username = (Session::isActive()) ? Session::get()->username : '******';
         		$notif = new PushoverNotification();
         		$notif->setMessage('Nouveau ticket de '.$username);
         		$notif->setReceiver('all');
         		$notif->setExtraParameter('url', 'http://dreamvids.fr'.WEBROOT.'admin/tickets');
         		$notif->send();*/
     } else {
         $response->addMessage(ViewMessage::error('Merci de nous décrire votre problème.'));
     }
     return $response;
 }
 public function update($id, $request)
 {
     if (Session::get()->details !== null) {
         $infos = Session::get()->details;
         $param = $request->getParameters();
         $data['infos'] = Session::get()->details;
         switch ($param['type']) {
             case 'contact':
                 $infos->tel_1 = $param['tel_1'];
                 $infos->tel_2 = $param['tel_2'];
                 $infos->email = $param['email'];
                 $infos->push_bullet_email = $param['push_bullet_email'];
                 $path = "edit";
                 break;
             case 'public':
                 $img_url = $this->_handleUpload($request);
                 $infos->shown_name = isset($param['shown_name']) ? $param['shown_name'] : null;
                 $infos->description = isset($param['description']) ? $param['description'] : null;
                 if (!is_null($img_url)) {
                     $infos->team_img_name = $img_url;
                 }
                 $path = "edit_public_infos";
                 break;
         }
         $infos->save();
         $response = new ViewResponse('admin/staffContactDetails/' . $path, $data);
         $response->addMessage(ViewMessage::success('Informations modifiées'));
         return $response;
     } else {
         return $this->create($request);
     }
 }
예제 #4
0
 public function edit($id, $request)
 {
     $data = [];
     if (User::exists(['id' => $id])) {
         $data['user'] = User::find($id);
         $r = new ViewResponse("admin/user/edit", $data);
     } else {
         $r = new ViewResponse("admin/user/edit");
         $r->addMessage(ViewMessage::error("L'utilisateur n'existe pas."));
     }
     return $r;
 }
예제 #5
0
 public function update($id, $request)
 {
     $data = $request->getParameters();
     $channel = UserChannel::find($id);
     $channel->verified = $data['verified'];
     $channel->description = $data['description'];
     $channel->save();
     $data['channel'] = $channel;
     $data['channel_admin'] = User::find($channel->owner_id);
     $r = new ViewResponse('admin/channel/edit', $data);
     $r->addMessage(ViewMessage::success("Chaîne modifiée"));
     return $r;
 }
예제 #6
0
 public function edit($id, $request)
 {
     $data = [];
     if ($id == '' || !Eggs::exists(['id' => $id])) {
         return new RedirectResponse(WEBROOT . 'admin/egg');
     }
     $egg = Eggs::find_by_id($id);
     $data['egg'] = $egg;
     $data['edit'] = true;
     $r = new ViewResponse('admin/egg/edit', $data);
     if ($egg->found) {
         $r->addMessage(ViewMessage::error("Attention, cet oeuf a déjà été trouvé par quelqu'un !"));
     }
     return $r;
 }
예제 #7
0
 public function create($request)
 {
     $params = $request->getParameters();
     if ($params['name'] == '') {
         $data['params'] = $params = $request->getParameters();
         $data['partners'] = Partners::find('all');
         $r = new ViewResponse('admin/partners/index', $data);
         $r->addMessage(ViewMessage::error("Champs 'Nom' manquant"));
     } else {
         Partners::create(['name' => $params['name'], 'url' => $params['url'], 'contact_email' => $params['contact_email']]);
         $r = $this->index($request);
         $r->addMessage(ViewMessage::success("Partenaire ajouté"));
     }
     return $r;
 }
예제 #8
0
 public function update($id, $request)
 {
     $req = $request->getParameters();
     if (Faq::exists($id)) {
         $faq = Faq::find($id);
     } else {
         $r = $this->index($request);
         $r->addMessage(ViewMessage::error("Id inexistant."));
         return $r;
     }
     foreach (self::$fields as $field) {
         if (isset($req[$field])) {
             $faq->{$field} = $req[$field];
         }
     }
     $faq->save();
     $r = new ViewResponse('admin/faq/edit', ['faq' => $faq]);
     $r->addMessage(ViewMessage::success("Cette question réponse à bien été sauvegardée. <a href=\"" . WEBROOT . "admin/faq\">Retour à la liste</a>"));
     return $r;
 }
예제 #9
0
 public function update($id, $request)
 {
     $config = new Config(CONFIG . 'app.json');
     $config->parseFile();
     $data = $request->getParameters();
     if (isset($data['userRankSubmit'])) {
         if (User::exists($id)) {
             $user = User::find($id);
             $data['ranks'][$config->getValue('rankAdmin')] = ['Administrateur', 'danger'];
             $data['ranks'][$config->getValue('rankModo')] = ['Modérateur', 'warning'];
             $data['ranks'][$config->getValue('rankTeam')] = ['Equipe', 'success'];
             $data['ranks'][$config->getValue('rankContributor')] = ['Contributeur', 'info'];
             $data['ranks'][$config->getValue('rankUser')] = ['Utilisateur', 'primary'];
             $user->rank = $data['rank'];
             $user->save();
             $data['user'] = $user;
             $r = new ViewResponse("admin/settings/edit_user", $data);
             $r->addMessage(ViewMessage::success($user->username . " désormais {$data['ranks'][$user->rank][0]}"));
             return $r;
         }
     }
 }
예제 #10
0
 public function update($id, $request)
 {
     $req = $request->getParameters();
     if (!Session::isActive()) {
         return Utils::getUnauthorizedResponse();
     }
     if ($video = Video::find($id)) {
         if (isset($req['video-edit-submit'], $req['video-title'], $req['video-description'], $req['video-tags'])) {
             $data = array();
             $data['currentPageTitle'] = $video->title . ' - Modification';
             if (UserChannel::find(Video::find($id)->poster_id)->belongToUser(Session::get()->id) || Session::get()->isModerator() || Session::get()->isAdmin()) {
                 $data['video'] = $video;
                 $title = $req['video-title'];
                 $description = $req['video-description'];
                 $tags = $req['video-tags'];
                 $visibility = $req['video-visibility'];
                 if (Utils::validateVideoInfo($title, $description, $tags) && in_array($visibility, array(0, 1, 2))) {
                     $video->updateInfo($title, $description, $tags, $req['_FILES_']['tumbnail'], $visibility);
                     $data['video'] = $video;
                     $response = new ViewResponse('video/edit', $data);
                     $response->addMessage(ViewMessage::success('Votre video a bien été modifiée !'));
                     return $response;
                 } else {
                     $response = new ViewResponse('video/edit', $data);
                     $response->addMessage(ViewMessage::error('Les informations ne sont pas valides.'));
                     return $response;
                 }
             }
         } else {
             if (isset($req['flag']) && !empty($req['flag'])) {
                 $flag = $req['flag'];
                 if ($flag == 'false' && (Session::get()->isModerator() || Session::get()->isAdmin())) {
                     $video->unFlag(Session::get()->id);
                     return new Response(200);
                 } else {
                     if ($flag == 'true') {
                         $video->flag(Session::get()->id);
                         return new Response(200);
                     }
                 }
             } else {
                 if (isset($req['suspend']) && !empty($req['suspend']) && (Session::get()->isModerator() || Session::get()->isAdmin())) {
                     $suspend = $req['suspend'];
                     if ($suspend == 'false') {
                         $video->unSuspend(Session::get()->id);
                         return new Response(200);
                     } else {
                         if ($suspend == 'true') {
                             $video->suspend(Session::get()->id);
                             return new Response(200);
                         }
                     }
                 } else {
                     if (isset($req['like'])) {
                         $userId = Session::get()->id;
                         if (!$video->isLikedByUser($userId)) {
                             if ($video->isDislikedByUser($userId)) {
                                 $video->removeDislike($userId);
                             }
                             $video->like($userId);
                             return new Response(200);
                         }
                     } else {
                         if (isset($req['dislike'])) {
                             $userId = Session::get()->id;
                             if (!$video->isDislikedByUser($userId)) {
                                 if ($video->isLikedByUser($userId)) {
                                     $video->removeLike($userId);
                                 }
                                 $video->dislike($userId);
                                 return new Response(200);
                             }
                         } else {
                             if (isset($req['unlike'])) {
                                 $userId = Session::get()->id;
                                 if ($video->isLikedByUser($userId)) {
                                     $video->removeLike($userId);
                                     return new Response(200);
                                 }
                             } else {
                                 if (isset($req['undislike'])) {
                                     $userId = Session::get()->id;
                                     if ($video->isDislikedByUser($userId)) {
                                         $video->removeDislike($userId);
                                         return new Response(200);
                                     }
                                 } else {
                                     if (isset($req['discover']) && (Session::get()->isModerator() || Session::get()->isAdmin())) {
                                         $video->discover = Utils::tps();
                                         $video->save();
                                         $author = $video->getAuthor();
                                         $receiver = ChannelAction::filterReceiver($author->admins_ids, "staff_select");
                                         ChannelAction::create(['id' => ChannelAction::generateId(6), 'channel_id' => $author->id, 'recipients_ids' => $receiver, 'type' => 'staff_select', 'target' => $video->id, 'timestamp' => Utils::tps()]);
                                         return new Response(200);
                                     }
                                 }
                             }
                         }
                     }
                 }
             }
         }
     }
     return new Response(500);
 }
예제 #11
0
 public function get($key, $request)
 {
     if (Password::exists(array('key' => $key))) {
         $pass = Password::find_by_key($key);
         $user = User::find($pass->user_id);
         $pass->delete();
         $pass = Password::generatePass(9);
         $user->pass = password_hash($pass, PASSWORD_BCRYPT);
         $user->save();
         $data = array();
         $data['currentPageTitle'] = 'Connexion';
         $resp = new ViewResponse('login/login', $data);
         $resp->addMessage(ViewMessage::success('Voici votre nouveau mot de passe: <b>' . $pass . '</b>. Connectez-vous dès maintenant !'));
         return $resp;
     } else {
         $data = array();
         $data['currentPageTitle'] = 'Mot de passe oublié';
         $resp = new ViewResponse('password/password', $data);
         $resp->addMessage(ViewMessage::error('Clé invalide ou expirée, merci de recommencer la procédure'));
         return $resp;
     }
 }
예제 #12
0
 public function videos($id, $request)
 {
     if (Session::isActive() && UserChannel::find($id)->belongToUser(Session::get()->id)) {
         $data['videos'] = UserChannel::find($id)->getPostedVideos(false);
         $data['currentPageTitle'] = 'Mon compte';
         $data['current'] = 'videos';
         $response = new ViewResponse('account/videos', $data);
         if (empty($data['videos'])) {
             $response->addMessage(ViewMessage::error('Vous n\'avez posté aucune vidéo'));
         }
         return $response;
     } else {
         return new RedirectResponse(Utils::generateLoginURL());
     }
 }
예제 #13
0
 public function update($id, $request)
 {
     $req = $request->getParameters();
     $data = $req;
     $data['current'] = 'channels';
     $name = @$req['name'];
     $descr = @$req['description'];
     $admins = @json_decode($req['_admins']);
     if (isset($req['editChannelSubmit']) && Session::isActive()) {
         $channel = UserChannel::exists($id) ? UserChannel::find($id) : UserChannel::find_by_name($id);
         if (!is_object($channel)) {
             return Utils::getNotFoundResponse();
         }
         if (!$channel->belongToUser(Session::get()->id)) {
             return Utils::getForbiddenResponse();
         }
         $data['mainChannel'] = $channel->isUsersMainChannel(Session::get()->id);
         $data['name'] = $channel->name;
         $data['description'] = $channel->description;
         $data['currentPageTitle'] = $channel->name . ' - Edition';
         $data['owner_id'] = $channel->owner_id;
         $admins_array_ids = explode(';', trim($channel->admins_ids, ';'));
         $data['admins_ids'] = $admins_array_ids;
         $data['admins'] = array();
         foreach ($admins_array_ids as $adm) {
             $data['admins'][] = User::find_by_id($adm)->getMainChannel();
         }
         if (isset($req['name'], $req['description'])) {
             if (strlen($name) >= 3 && strlen($name) <= 40) {
                 if (preg_match("#^[a-zA-Z0-9\\_\\-\\.]+\$#", $name)) {
                     if ($channel->isUsersMainChannel(Session::get()->id)) {
                         if ($channel->name != $req['name']) {
                             $data['name'] = $channel->name;
                             $response = new ViewResponse('channel/edit', $data);
                             $response->addMessage(ViewMessage::error('Vous ne pouvez pas changer le nom de votre chaîne principale !'));
                             return $response;
                         }
                     } else {
                         $adm = trim($channel->admins_ids, ';');
                         $adm = explode(';', $adm);
                         foreach ($admins as $admin) {
                             if ($admin > 0) {
                                 if (!in_array($admin, $adm)) {
                                     $adm[] = $admin;
                                     ChannelAction::create(array('id' => ChannelAction::generateId(6), 'channel_id' => $channel->id, 'recipients_ids' => ';' . $admin . ';', 'type' => 'admin', 'target' => $channel->id, 'timestamp' => Utils::tps()));
                                 }
                             } else {
                                 $value = -1 * $admin;
                                 if (in_array($value, $adm) && $channel->owner_id != $value) {
                                     $id = array_keys($adm, $value);
                                     unset($adm[$id[0]]);
                                     ChannelAction::create(array('id' => ChannelAction::generateId(6), 'channel_id' => $channel->id, 'recipients_ids' => ';' . $admin . ';', 'type' => 'unadmin', 'target' => $channel->id, 'timestamp' => Utils::tps()));
                                 }
                             }
                         }
                         $adm = ';' . implode(';', $adm) . ';';
                     }
                     UserChannel::edit($channel->id, $name, $descr, $adm, $req['_FILES_']['avatar'], $req['_FILES_']['background']);
                     //TODO: Support logo/background
                     $data['channels'] = Session::get()->getOwnedChannels();
                     $data['currentPageTitle'] = 'Mes chaines';
                     $response = new ViewResponse('account/channels', $data);
                     $response->addMessage(ViewMessage::success('Votre chaîne ' . $name . ' a bien été modifiée !'));
                     return $response;
                 } else {
                     $response = new ViewResponse('channel/edit', $data);
                     $response->addMessage(ViewMessage::error('Le nom de la chaîne doit contenir uniquement des lettres (majuscules et minuscules), des traits-d\'union, des _ et des points.'));
                     return $response;
                 }
             } else {
                 $response = new ViewResponse('channel/edit', $data);
                 $response->addMessage(ViewMessage::error('Le nom de la chaîne doit être compris entre 3 et 40 caractères.'));
                 return $response;
             }
         } else {
             $response = new ViewResponse('channel/edit', $data);
             $response->addMessage(ViewMessage::error('Tous les champs doivent être remplis.'));
             return $response;
         }
     } else {
         if (isset($req['subscribe'])) {
             if (Session::isActive()) {
                 $channel = UserChannel::exists($id) ? UserChannel::find($id) : UserChannel::find_by_name($id);
                 if (is_object($channel) && !$channel->belongToUser(Session::get()->id)) {
                     $channel->subscribe(Session::get()->id);
                     $response = new Response(200);
                     return $response;
                 }
             } else {
                 return new Response(500);
             }
         } else {
             if (isset($req['unsubscribe'])) {
                 if (Session::isActive()) {
                     $channel = UserChannel::exists($id) ? UserChannel::find($id) : UserChannel::find_by_name($id);
                     if (is_object($channel) && !$channel->belongToUser(Session::get()->id)) {
                         $channel->unsubscribe(Session::get()->id);
                         $response = new Response(200);
                         return $response;
                     }
                 } else {
                     return new Response(500);
                 }
             } else {
                 if (isset($req['admin_edit'])) {
                     if (Session::isActive()) {
                         $channel = UserChannel::exists($id) ? UserChannel::find($id) : UserChannel::find_by_name($id);
                         if (!$channel) {
                             return Utils::getNotFoundResponse();
                         }
                         if (!$channel->isUsersMainChannel(Session::get()->id) && $channel->owner_id != Session::get()->id) {
                             if (in_array($channel, Session::get()->getOwnedChannels())) {
                                 $current_admins = $channel->admins_ids;
                                 $current_admins = trim($current_admins, ";");
                                 $current_admins = explode(";", $current_admins);
                                 foreach ($current_admins as $k => $admin) {
                                     if ($admin == Session::get()->id) {
                                         unset($current_admins[$k]);
                                         $channel->admins_ids = ";" . implode($current_admins, ";") . ";";
                                         $channel->save();
                                         return new RedirectResponse(WEBROOT . "channel/{$id}");
                                     }
                                 }
                             }
                         }
                     }
                     return Utils::getForbiddenResponse();
                 }
             }
         }
     }
 }
예제 #14
0
 public function update($id, $request)
 {
     $req = $request->getParameters();
     if (Session::isActive()) {
         $user = Session::get();
         if (ChannelPost::exists($id)) {
             $post = ChannelPost::find($id);
             if (UserChannel::find($post->channel_id) && UserChannel::find($post->channel_id)->belongToUser($user->id) && isset($req["post_content"], $req["post-message-submit"])) {
                 $data = [];
                 $post->content = $req["post_content"];
                 $data["post_id"] = $post->id;
                 $data["post_content"] = $post->content;
                 $data["channel_id"] = $post->channel_id;
                 $post->save();
                 $r = new ViewResponse("channel/social/edit", $data);
                 $r->addMessage(ViewMessage::success("Post bien modifié"));
                 return $r;
             } else {
                 return Utils::getUnauthorizedResponse();
             }
         } else {
             return Utils::getNotFoundResponse();
         }
     } else {
         return Utils::getUnauthorizedResponse();
     }
 }
예제 #15
0
 public function create($request)
 {
     $req = $request->getParameters();
     if (isset($req['submitRegister'])) {
         if (isset($req['username'])) {
             if (isset($req['pass'])) {
                 if (isset($req['pass-confirm'])) {
                     if (isset($req['mail'])) {
                         if (isset($req["g-recaptcha-response"])) {
                             if (isset($req['CGU']) && $req['CGU'] == 'CGU') {
                                 $data = $_POST;
                                 $data['currentPageTitle'] = 'Inscription';
                                 $data["currentPage"] = "register";
                                 $url = "https://www.google.com/recaptcha/api/siteverify?secret=";
                                 //Adress a get
                                 $url .= Config::getValue_("recaptcha_private");
                                 //Cle prive
                                 $url .= "&response=" . $req['g-recaptcha-response'];
                                 // Resultat de captcha
                                 $check_captcha = true;
                                 if (isset($req['cavicon'])) {
                                     $key = "key";
                                     $check_captcha = $req['cavicon'] != $key;
                                 }
                                 $check_captcha = true;
                                 //Override
                                 if ($check_captcha) {
                                     $json_result = json_decode(file_get_contents($url), true);
                                     //Parsage de la reponse
                                     if (@$json_result["success"] != true) {
                                         $response = new ViewResponse('login/register', $data);
                                         $response->addMessage(ViewMessage::error('Erreur de captcha'));
                                         //Affichage de l'erreur
                                         return $response;
                                     }
                                 } else {
                                     //OK
                                 }
                             } else {
                                 $response = new ViewResponse('login/register', $data);
                                 $response->addMessage(ViewMessage::error('Merci d\'accepter nos conditions avant de vous inscrire'));
                                 return $response;
                             }
                         } else {
                             //Affichage de l'erreur
                             $response = new ViewResponse('login/register', $data);
                             $response->addMessage(ViewMessage::error('Erreur de captcha'));
                             return $response;
                         }
                         $username = Utils::secure($req['username']);
                         $pass = Utils::secure($req['pass']);
                         $pass2 = Utils::secure($req['pass-confirm']);
                         $mail = Utils::secure($req['mail']);
                         if (Utils::validateUsername($username) && Utils::validateMail($mail) && $pass2 != '' && $pass != '') {
                             if ($pass == $pass2) {
                                 if (!User::find_by_username($username)) {
                                     if (!User::isMailRegistered($mail)) {
                                         User::register($username, $pass, $mail);
                                         $created_user = User::find('first', array('username' => $username));
                                         $created_user->sendWelcomeNotification();
                                         $response = new ViewResponse('login/login');
                                         $response->addMessage(ViewMessage::success('Inscription validée. Vous pouvez vous connecter !'));
                                         return $response;
                                     } else {
                                         $response = new ViewResponse('login/register', $data);
                                         $response->addMessage(ViewMessage::error('Cette adresse e-mail est déjà enregistrée'));
                                         return $response;
                                     }
                                 } else {
                                     $response = new ViewResponse('login/register', $data);
                                     $response->addMessage(ViewMessage::error('Ce nom d\'utilisateur est déjà pris'));
                                     return $response;
                                 }
                             } else {
                                 $response = new ViewResponse('login/register', $data);
                                 $response->addMessage(ViewMessage::error('Les mots de passe ne correspondent pas'));
                                 return $response;
                             }
                         } else {
                             $response = new ViewResponse('login/register', $data);
                             $response->addMessage(ViewMessage::error('Veuillez saisir des informations valides (a-z/A-Z/0-9)'));
                             return $response;
                         }
                     } else {
                         $response = new ViewResponse('login/register', $data);
                         $response->addMessage(ViewMessage::error('L\'adresse e-mail est requise'));
                         return $response;
                     }
                 } else {
                     $response = new ViewResponse('login/register', $data);
                     $response->addMessage(ViewMessage::error('Veuillez confirmer le mot de passe'));
                     return $response;
                 }
             } else {
                 $response = new ViewResponse('login/register', $data);
                 $response->addMessage(ViewMessage::error('Le mot de passe est requis'));
                 return $response;
             }
         } else {
             $response = new ViewResponse('login/register', $data);
             $response->addMessage(ViewMessage::error('Le nom d\'utilisateur est requis'));
             return $response;
         }
     }
 }