コード例 #1
0
ファイル: User.php プロジェクト: PierreClouet/picasa
 public function register()
 {
     //Sanitize Data using Gump helper
     $_POST = Gump::sanitize($_POST);
     if (isset($_POST['login'])) {
         //Validate data using Gump
         $is_valid = Gump::is_valid($_POST, array('login' => 'required|alpha_numeric', 'email' => 'required|valid_email', 'password' => 'required', 'password-again' => 'required'));
         if ($is_valid === true) {
             //Test for duplicate username`
             $user = $this->userSQL->prepareFindByLogin($_POST['login']);
             if ($_POST['password'] != $_POST['password-again']) {
                 $error[] = "Les deux mots de passes doivent être identiques";
             }
             if ($user != false) {
                 $error[] = 'Ce compte existe déjà';
             }
             $user = $this->userSQL->prepareFindByEmail($_POST['email'])->execute();
             //Test for dupicate email address
             if (count($user) > 0) {
                 $error[] = 'Ce compte email existe déjà.';
             }
         } else {
             $error = $is_valid;
         }
         if (!$error) {
             //Register and return the data as an array $data[]
             $user = new Utilisateur($_POST['login'], $_POST['email'], Password::make($_POST['password']), "");
             $this->entityManager->save($user);
             Session::set('id', $user->getId());
             Session::set('login', $user->login);
             Session::set('loggedin', true);
             Url::redirect();
         }
     }
     $data['title'] = 'Inscription';
     View::rendertemplate('header', $data);
     View::render('user/register', $data, $error);
     View::rendertemplate('footer', $data);
 }
コード例 #2
0
ファイル: Category.php プロジェクト: Oluwafemikorede/gbedu
 public function edit($parameter)
 {
     $item_id = $parameter[0];
     $this->data['title'] = 'Add Item';
     $this->data['page_section'] = 'edit';
     $category_model = new \Models\Category();
     $this->data['category'] = $category_model->find($item_id);
     if (isset($_POST) && !empty($_POST)) {
         $category_title = $_POST['category_title'];
         $category_slug = $_POST['category_slug'];
         $category_modified = time();
         $update_array = array('category_title' => $category_title, 'category_modified' => $category_created);
         $update_array = Gump::xss_clean($update_array);
         $update_array = Gump::sanitize($update_array);
         $update_id = $category_model->updateId($update_array, $item_id);
         if ($update_id > 0) {
             Session::set('success', 'category edited');
             Url::redirect('category');
         }
     }
     View::rendertemplate('header', $this->data);
     View::rendertemplate('sidebar', $this->data);
     View::render('category/category.add', $this->data);
     View::rendertemplate('footer', $this->data);
 }
コード例 #3
0
ファイル: Connexion.php プロジェクト: jordandevolder/Algogoal
 public function inscription()
 {
     $data['title'] = "Inscription";
     $data['inscription'] = "Ici l'espace pour créer un compte";
     $_POST = Gump::sanitize($_POST);
     if (isset($_POST['pseudo'])) {
         //Validate data using Gump
         $is_valid = Gump::is_valid($_POST, array('pseudo' => 'required|alpha_numeric', 'email' => 'required|valid_email', 'password' => 'required', 'password-again' => 'required'));
         if ($is_valid === true) {
             //Test for duplicate username`
             $user = $this->userSQL->prepareFindByLogin($_POST['pseudo']);
             if ($_POST['password'] != $_POST['password-again']) {
                 $error[] = "Les deux mots de passes doivent être identiques";
             }
             if ($user != false) {
                 $error[] = 'Ce compte existe déjà';
             }
             $user = $this->userSQL->prepareFindByEmail($_POST['email'])->execute();
             //Test for dupicate email address
             if (count($user) > 0) {
                 $error[] = 'Ce compte email existe déjà.';
             }
             $data['erreurs'] = $error;
             View::renderTemplate('header', $data);
             View::render('connexion/inscription', $data);
             View::renderTemplate('footer', $data);
         } else {
             $error = $is_valid;
         }
         if (!$error) {
             //Register and return the data as an array $data[]
             $pseudo = $_POST['pseudo'];
             $mail = $_POST['email'];
             $password = Password::make($_POST['password']);
             $user = new Personne($pseudo, $mail, $password);
             print_r($user);
             $this->entityManager->save($user);
             Session::set('id', $user->getId());
             Session::set('pseudo', $user->login);
             Session::set('level', $user->currentLvl);
             Session::set('loggedin', true);
             Url::redirect();
         }
     }
 }
コード例 #4
0
ファイル: Song.php プロジェクト: Oluwafemikorede/gbedu
 public function edit($param)
 {
     $song_id = $param[0];
     $songModel = new \Models\Song();
     $this->data['title'] = 'Edit Song';
     $this->data['albums'] = $this->albumModel->all();
     $this->data['artist'] = User::artist();
     $this->data['genre'] = $this->categoryModel->get(array('category_slug' => 'genre'));
     $this->data['tags'] = $this->categoryModel->get(array('category_slug' => 'tag'));
     $this->data['status'] = $this->status_model->get(array('status_slug' => 'album'));
     if (isset($_POST) && !empty($_POST)) {
         $songArray = array('song_album_id' => $_POST['album_id'], 'song_user_id' => Session::get('user_id'), 'song_artist_id' => $_POST['artist_id'], 'song_genre_id' => $_POST['genre_id'], 'song_status_id' => $_POST['status_id'], 'song_title' => $_POST['title'], 'song_description' => $_POST['description'], 'song_modified' => time(), 'song_slug' => Url::generateSafeSlug($_POST['title']));
         $songArray = Gump::xss_clean($songArray);
         $songArray = Gump::sanitize($songArray);
         $update = $songModel->updateId($songArray, $song_id);
         if ($update > 0) {
             $message = 'ok';
         } else {
             $message = 'no';
         }
         if ($_FILES["mp3"]["tmp_name"] != '') {
             //resize youtube image into uploads folder
             Upload::setName(time());
             Upload::upload_file($_FILES["mp3"], UPLOAD_PATH);
             $filepath = UPLOAD_PATH . Upload::getName();
             $outputMp3 = UPLOAD_PATH . 'encoded_' . Upload::getName();
             //check bitrate
             $bitRate = Audio::bitRateSampleRate($filepath, 'bitrate');
             $duration = Audio::duration($filepath);
             if ($bitRate > 128) {
                 $convertMp3 = Audio::convertMp3($filepath, 128, $outputMp3);
             }
             if (is_file($outputMp3)) {
                 $updateArray = array('song_file' => 'images/encoded_' . Upload::getName(), 'song_duration' => $duration);
                 unlink($filepath);
             } else {
                 $updateArray = array('song_file' => Upload::getFileName('images'), 'song_duration' => $duration);
             }
             $saveMp3 = $songModel->updateId($updateArray, $song_id);
         }
         //UPLOAD SONG COVER
         if ($_FILES["image"]["tmp_name"] != '') {
             //upload file into uploads folder
             Upload::setName(time());
             Upload::resizeUpload($_FILES["image"], UPLOAD_PATH, '450px');
             $update_data = array('song_image' => Upload::getFileName('images'));
             $songModel->updateId($update_data, $song_id);
         }
     }
     if ($message == 'ok') {
         Session::set('success', 'record edited');
         Url::redirect('song/item/' . $_POST['album_id']);
     } else {
         if ($message == 'no') {
             $this->data['error'] = 'Operation Fails!';
         }
     }
     $this->data['song'] = \Models\Song::item($song_id);
     View::rendertemplate('header', $this->data);
     View::rendertemplate('sidebar', $this->data);
     View::render('song/song.edit', $this->data);
     View::rendertemplate('footer', $this->data);
 }
コード例 #5
0
ファイル: Artist.php プロジェクト: Oluwafemikorede/gbedu
 public function edit($param)
 {
     $edit_id = $param[0];
     $user_model = new User();
     if (isset($_POST) && !empty($_POST)) {
         $artistArray = array('user_firstname' => $_POST['firstname'], 'user_stagename' => $_POST['stagename'], 'user_bio' => $_POST['bio'], 'twitter_handle' => $_POST['twitter_handle'], 'user_modified' => time());
         $artistArray = Gump::xss_clean($artistArray);
         $artistArray = Gump::sanitize($artistArray);
         $update_id = $user_model->updateId($artistArray, $edit_id);
         //UPLOAD ATTACHMENT
         if ($_FILES["image"]["tmp_name"] != '') {
             //upload image into uploads folder
             Upload::setName($slug . time());
             Upload::resizeUpload($_FILES["image"], UPLOAD_PATH, '450px');
             $update_data = array('user_image' => Upload::getFileName('images'));
             if ($this->user_model->updateId($update_data, $edit_id)) {
                 Session::set('success', 'Artist record edited');
             } else {
                 Session::set('error', 'operation fails');
             }
         }
         if ($update_id > 0) {
             Session::set('success', 'Artist record edited');
             Url::redirect('artist');
         } else {
             Session::set('error', 'operation fails');
         }
     }
     $this->data['user_data'] = $user_model->find($edit_id);
     View::rendertemplate('header', $this->data);
     View::rendertemplate('sidebar', $this->data);
     View::render('artist/artist.add', $this->data);
     View::rendertemplate('footer', $this->data);
 }
コード例 #6
0
ファイル: Page.php プロジェクト: Oluwafemikorede/gbedu
 /**
  * define page title and load template files
  */
 public function index()
 {
     $action = $_GET['action'];
     $this->data['album_group'] = $this->albumModel->all();
     $this->data['parent_page'] = $this->pageModel->parent_page();
     $this->data['title'] = 'All Pages';
     if (isset($_POST) && !empty($_POST)) {
         //PAGE DATA
         $pagename = $_POST['pagename'];
         $category = $_POST['category'];
         $parent_page = $_POST['parent_page'];
         $sort_order = $_POST['sort_order'];
         //CONTENT
         $content = $_POST['content'];
         $homepage = $_POST['homepage'];
         $header_menu = $_POST['header_menu'];
         $footer_menu = $_POST['footer_menu'];
         $redirecturl = $_POST['redirecturl'];
         $album = $_POST['album'];
         $meta_keywords = $_POST['meta_keywords'];
         $meta_title = $_POST['meta_title'];
         $meta_description = $_POST['meta_description'];
         // $sort_order = $_POST['sort_order'];
         $slug = Url::generateSafeSlug($pagename);
         $check_if_page_exist = $this->pageModel->get(array('page_alias' => $slug));
         if (count($check_if_page_exist) < 1) {
             $insert_array = array('page_name' => $pagename, 'page_category_id' => $category, 'page_sort_order' => $sort_order, 'page_alias' => $slug);
             $insert_page_id = $this->pageModel->create($insert_array);
             //UPDATE CONTENT PAGE
             if ($parent_page == '') {
                 $parent_page = $insert_page_id;
             }
             // var_dump($parent_page);
             $insert_content_array = array('content_page_id' => $insert_page_id, 'content_subto' => $parent_page, 'content_plugin' => $plugin, 'content_body' => $content, 'content_homepage' => $homepage, 'content_header_menu' => $header_menu, 'content_footer_menu' => $footer_menu, 'content_redirecturl' => $redirecturl, 'content_album' => $album, 'content_meta_keywords' => $meta_keywords, 'content_meta_title' => $meta_title, 'content_meta_description' => $meta_description, 'content_created' => time());
             $insert_content_array = Gump::xss_clean($insert_content_array);
             $insert_content_array = Gump::sanitize($insert_content_array);
             $insert_content_id = $this->contentModel->create($insert_content_array);
             //UPLOAD IMAGE
             $where_array = array('content_id' => $insert_content_id);
             if ($_FILES["image1_extra"]["tmp_name"] != '') {
                 Upload::setName($slug . uniqid());
                 Upload::upload_file($_FILES["image1_extra"], UPLOAD_PATH);
                 $image_name = 'images/' . Upload::$filename;
                 $update_data = array('content_banner' => $image_name);
                 $update = $this->contentModel->update($update_data, $where_array);
             }
             if ($_FILES["image2_extra"]["tmp_name"] != '') {
                 Upload::setName($slug . uniqid());
                 Upload::upload_file($_FILES["image2_extra"], UPLOAD_PATH);
                 $image_name = 'images/' . Upload::$filename;
                 $update_data = array('content_thumbnail' => $image_name);
                 $update = $this->contentModel->update($update_data, $where_array);
             }
             if ($insert_content_id > 0) {
                 $this->data['success'] = 'Page created!';
             } else {
                 $this->data['error'] = 'Operation Fails!';
             }
         } else {
             $this->data['error'] = 'Page already exists!';
         }
         $this->data['page_data'] = $this->pageModel->detail($insert_page_id);
     }
     if ($message == 'ok') {
         $this->data['success'] = 'Record Deleted!';
     } else {
         if ($message == 'no') {
             $this->data['error'] = 'Operation Fails!';
         }
     }
     $this->data['pages'] = $this->pageModel->allPages();
     $this->data['page_categories'] = $this->categoryModel->get(array('category_slug' => 'page'));
     View::rendertemplate('header', $this->data);
     View::rendertemplate('sidebar', $this->data);
     View::render('pages/pages.index', $this->data);
     View::rendertemplate('footer', $this->data);
 }
コード例 #7
0
ファイル: Board.php プロジェクト: Oluwafemikorede/gbedu
 public function password()
 {
     $this->data['title'] = 'Change Password';
     $userModel = new User();
     $user_id = Session::get('user')->user_id;
     $user_details = $userModel->get(array('user_id' => $user_id, 'user_password' => md5($_POST['old_password'])));
     if (isset($_POST['password1']) && !empty($_POST['password1'])) {
         if (count($user_details) > 0) {
             if ($_POST['password1'] == $_POST['password2']) {
                 //update user db
                 $update_array = array('user_password' => md5($_POST['password1']));
                 $update_array = Gump::xss_clean($update_array);
                 $update_array = Gump::sanitize($update_array);
                 $update_id = $user_model->updateId($update_array, $user_id);
                 if ($update_id > 0) {
                     Session::set('success', 'Password Changed');
                 } else {
                     Session::set('error', 'Operation Fails!');
                 }
             } else {
                 Session::set('error', 'Incorrect match, password change fails!');
             }
         } else {
             Session::set('error', 'Incorrect match, password change fails!');
         }
     }
     View::rendertemplate('header', $this->data);
     View::render('workspace/workspace.password', $this->data);
     View::rendertemplate('footer', $this->data);
 }
コード例 #8
0
ファイル: Post.php プロジェクト: Oluwafemikorede/gbedu
 public function edit($parameter)
 {
     $item_id = $parameter[0];
     $this->data['title'] = 'Edit Post';
     $category_model = new \Models\Category();
     $post_model = new \Models\Post();
     $album_model = new \models\album();
     $this->data['post'] = $post_model->getItem($item_id);
     $this->data['album_group'] = $album_model->all();
     $this->data['post_category_groups'] = $category_model->groupByCol('category_slug');
     if (isset($_POST) && !empty($_POST)) {
         $post_category_id = $_POST['post_category_id'];
         $post_album_id = $_POST['post_album_id'];
         $post_title = $_POST['post_title'];
         $post_body = $_POST['post_body'];
         $post_link = $_POST['post_link'];
         $post_excerpt = $_POST['post_excerpt'];
         $post_slug = Url::generateSafeSlug($post_title);
         $post_modified = time();
         $update_array = array('post_category_id' => $post_category_id, 'post_album_id' => $post_album_id, 'post_title' => $post_title, 'post_body' => $post_body, 'post_link' => $post_link, 'post_excerpt' => $post_excerpt, 'post_slug' => $post_slug, 'post_modified' => $post_modified);
         $update_array = Gump::xss_clean($update_array);
         $update_array = Gump::sanitize($update_array);
         $update_id = $post_model->updateId($update_array, $item_id);
         //UPLOAD IMAGE
         if ($_FILES["image"]["tmp_name"] != '') {
             Upload::setName(uniqid());
             Upload::upload_file($_FILES["image"], UPLOAD_PATH);
             $image_name = Upload::getFileName('images');
             $update_data = array('post_image' => $image_name);
             $update = $post_model->updateId($update_data, $update_id);
         }
         if ($update_id > 0) {
             Session::set('success', 'post edited');
             Url::redirect('post');
         }
     }
     View::rendertemplate('header', $this->data);
     View::rendertemplate('sidebar', $this->data);
     View::render('post/post.add', $this->data);
     View::rendertemplate('footer', $this->data);
 }
コード例 #9
0
ファイル: Album.php プロジェクト: Oluwafemikorede/gbedu
 public function user($param)
 {
     $album_id = $param[0];
     $user_id = $param[1];
     $this->data['album_id'] = $album_id;
     $this->data['user_id'] = $user_id;
     $album_detail = $this->albumModel->find($album_id);
     $this->data['title'] = ucfirst($album_detail->album_name) . ' Album';
     $albumitems = $this->mediaModel->getAlbumItems($album_id);
     $this->data['album_categories'] = $this->categoryModel->get(array('category_slug' => 'album'));
     $this->data['status'] = $this->status_model->get(array('status_slug' => 'album'));
     if (isset($_POST) && !empty($_POST)) {
         $title = $_POST['title'];
         $description = $_POST['description'];
         $youtubelink = $_POST['youtubelink'];
         $category_id = $_POST['category'];
         $status_id = $_POST['status_id'];
         $slug = Url::generateSafeSlug($title);
         $insert_array = array('media_album_id' => $album_id, 'media_category_id' => $category_id, 'media_status_id' => $status_id, 'media_user_id' => $user_id, 'media_title' => $title, 'media_description' => $description, 'media_youtubelink' => $youtubelink, 'media_created' => time(), 'media_alias' => $slug);
         $insert_array = Gump::xss_clean($insert_array);
         $insert_array = Gump::sanitize($insert_array);
         $insert_id = $this->mediaModel->create($insert_array);
         if ($insert_id > 0) {
             $message = 'ok';
         } else {
             $message = 'no';
         }
         //update where_array
         $where_array = array('media_id' => $insert_id);
         //check if item is a video
         $category_type = $this->categoryModel->find($_POST['category']);
         if ($category_type->category_title == 'video' && isset($youtubelink) && $youtubelink != '') {
             //item is a video
             $youtube_url = "https://i.ytimg.com/vi/" . $youtubelink . "/maxresdefault.jpg";
             if (!file_exists($youtube_url)) {
                 $youtube_url = "https://i.ytimg.com/vi/" . $youtubelink . "/hqdefault.jpg";
             }
             //resize youtube image into uploads folder
             Upload::setName(time());
             Upload::resizeUrl($youtube_url, UPLOAD_PATH, '480px');
             $image_name = Upload::getFileName('images');
             $update_data = array('media_file' => $image_name);
             $this->mediaModel->update($update_data, $where_array);
         }
         //UPLOAD ATTACHMENT
         if ($_FILES["image"]["tmp_name"] != '') {
             //upload image into uploads folder
             Upload::setName(uniqid());
             // Upload::upload_file($_FILES["image"],UPLOAD_PATH);
             Upload::resizeUpload($_FILES["image"], UPLOAD_PATH, '480px');
             $image_name = Upload::getFileName('images');
             $update_data = array('media_file' => $image_name);
             $this->mediaModel->update($update_data, $where_array);
         }
     }
     if (isset($_GET['a']) && $_GET['a'] == 'delete') {
         if ($delete = $this->mediaModel->delete(array('media_id' => $_GET['qid']))) {
             $message = 'ok';
         } else {
             $message = 'no';
         }
     }
     if (isset($_GET['status'])) {
         switch ($_GET['status']) {
             case 'deactivate':
                 $deactivate = $this->status_model->get_row(array('status_title' => 'inactive'));
                 $update_user = $this->mediaModel->update(array('media_status_id' => $deactivate->status_id), array('media_id' => $_GET['id']));
                 break;
             case 'activate':
                 $activate = $this->status_model->get_row(array('status_title' => 'active'));
                 $update_user = $this->mediaModel->update(array('media_status_id' => $activate->status_id), array('media_id' => $_GET['id']));
                 break;
         }
         if (isset($update_user)) {
             $this->data['success'] = 'status changed!';
         } else {
             $this->data['error'] = 'operation fails';
         }
     }
     if ($message == 'ok') {
         $this->data['success'] = 'Record Added!';
     } else {
         if ($message == 'no') {
             $this->data['error'] = 'Operation Fails!';
         }
     }
     $this->data['albumitems'] = $this->mediaModel->getAlbumItems($album_id, $user_id);
     View::rendertemplate('header', $this->data);
     View::rendertemplate('sidebar', $this->data);
     View::render('album/album.user.add_item', $this->data);
     View::rendertemplate('footer', $this->data);
 }
コード例 #10
0
ファイル: Account.php プロジェクト: Oluwafemikorede/gbedu
 public function signup($slug = null)
 {
     $this->data['title'] = 'Join Us';
     $statusModel = new Status();
     $roleModel = new Role();
     $userModel = new User();
     if (isset($_POST['email']) && !empty($_POST['email'])) {
         $firstname = $_POST['firstname'];
         $email = $_POST['email'];
         if ($_POST['password'] == $_POST['password2']) {
             $encrypted = md5($_POST['password']);
             $row_count = $userModel->getColRow('user_email', $email);
             if (!is_bool($row_count)) {
                 Session::set('error', 'Email exists in our records, please use a different email');
             } else {
                 $userArray = array('user_firstname' => $firstname, 'user_email' => $email, 'user_password' => $encrypted, 'user_role_id' => Role::id('user'), 'user_status_id' => Status::id('active'));
                 $userArray = Gump::xss_clean($userArray);
                 $userArray = Gump::sanitize($userArray);
                 $is_valid = Gump::is_valid($userArray, array('user_firstname' => 'required|max_len,200|min_len,1', 'user_email' => 'required|max_len,200|min_len,1', 'user_password' => 'required|max_len,200|min_len,1'));
                 if ($is_valid === true) {
                     $user_id = $userModel->create($userArray);
                     if ($user_id > 0) {
                         $slug = Url::generateSafeSlug($firstname . $user_id);
                         //send email
                         $subject = 'Welcome to GbeduMobile';
                         $content .= "You just opened a new account with us, Get login details below<br><br>";
                         $content .= "Username: "******"<br>";
                         $content .= "Password: "******"<br>";
                         if (ENVIRONMENT == 'production') {
                             $mail = new Mail();
                             $mail->general($email, $subject, $firstname, $content);
                         }
                         Session::set('success', 'Login details has been sent to your email, Congrats!');
                         Url::redirect('home');
                     } else {
                         Session::set('error', 'Operation Fails, Please contact admin');
                     }
                 } else {
                     Session::set('error', $is_valid);
                 }
             }
         } else {
             Session::set('error', 'Password does not match!');
         }
     }
     View::rendertemplate('header', $this->data);
     View::render('account/signup', $this->data);
     View::rendertemplate('footer', $this->data);
 }