Exemplo n.º 1
0
 public function check()
 {
     Phalanx::loadController('public.LoginController');
     $loginController = new LoginController();
     if (!($loginController->isLoggedIn() && in_array($this->session->user->id, array(26, 66382, 66380, 65, 1300, 83922, 95394, 138505)))) {
         Request::redirect(HOST);
     }
 }
 public function init()
 {
     $this->post = Request::post(true, REPLACE);
     $this->files = Request::files();
     $this->session = new Session();
     Phalanx::loadController('LoginController');
     $loginController = new LoginController();
     $this->isLoggedIn = $loginController->isLoggedIn();
 }
Exemplo n.º 3
0
 public function Index()
 {
     Phalanx::loadController('LoginController');
     $loginController = new LoginController();
     if ($loginController->isLoggedIn()) {
         $this->feed();
     } else {
         Request::redirect(HOST . 'login');
     }
 }
Exemplo n.º 4
0
 public function init()
 {
     $this->get = Request::get();
     $this->post = Request::post();
     $this->files = Request::files();
     $this->session = new Session();
     Phalanx::loadController("LoginController");
     $LoginController = new LoginController();
     if (!$LoginController->isLoggedIn()) {
         $this->isLoggedIn = $template->show_login_bar = true;
     }
 }
Exemplo n.º 5
0
 public function UserCard()
 {
     Phalanx::loadController("LoginController");
     $loginController = new LoginController();
     $status = $loginController->isLoggedIn();
     if ($status) {
         $v = new Views();
         $v->login = $this->session->user->login;
         $v->avatar = $this->session->user->other_data->avatar;
         $v->experience = Profile::experience($this->session->user->id);
         $v->badges = Badges::from_user($this->session->user->id, 4);
         echo $v->render("user_mini_card.phtml");
     } else {
         $v = new Views();
         echo $v->render("user_mini_card_login.phtml");
     }
 }
 public function DisplayWordpressPost()
 {
     Phalanx::loadController('LoginController');
     $loginController = new LoginController();
     $this->isLoggedIn = $loginController->isLoggedIn();
     Phalanx::loadClasses('public.Posts', 'public.PostComments');
     $post = Posts::GetWPPostData($this->get->post_id, $this->session->user->id, true);
     $slug = mb_strtolower(preg_replace('/--+/u', '-', preg_replace('/[^\\w\\-]+/u', '-', $post->content->post_title)));
     if ($slug != $this->get->slug) {
         Request::redirect_301(HOST . "site/post/{$this->get->post_id}-{$slug}");
     }
     $v = new Views();
     $v->title = $post->content->post_title;
     $v->content = $post->content->post_content;
     $v->comments = $post->comments;
     $v->comments_array = PostComments::get($post->post_id);
     $v->replies = $post->replies;
     $v->post_id = $post->post_id;
     $v->rating = $post->rating;
     $v->when = Date::RelativeTime($post->content->post_date);
     $v->my_rating = $p->my_rating;
     $v->current_user = $this->session->user->login;
     $v->is_favorite = $p->is_favorite;
     $content = $v->render("post_body_wp.phtml");
     $template = new Template("default");
     $template->og = new stdClass();
     $template->og->title = $v->title;
     $template->og->description = substr(strip_tags($content), 0, 250);
     //$template->og->img = MEDIA_DIR . 'images/avatar/big/' . $profile_data->aditional_info->avatar;
     if (!$this->isLoggedIn) {
         $template->show_login_bar = true;
     }
     $v = new Views($template);
     $v->data = new stdClass();
     $v->data->post = $content;
     $v->display("single_post_display.phtml");
 }
Exemplo n.º 7
0
 public function DisplayProfile()
 {
     if ($this->get->username == 'wordpressagent') {
         $this->views->display("profile_not_found.phtml");
         return;
     }
     $username = $this->get->username ? $this->get->username : $this->session->user->login;
     $this->session->times_reloaded->{"profile_{$username}"} = 0;
     $profile_data = Profile::get_profile($username);
     #Perfil banido
     if ($profile_data->banned == 1) {
         $this->views->display("profile_banned.phtml");
         return;
     }
     if ($profile_data->active == 0) {
         $this->views->display("profile_deactivated.phtml");
         return;
     }
     # Perfil não encontrado
     if (!$profile_data or $profile_data->login == 'wordpressagent' or $profile_data->id == '0') {
         $this->views->display("profile_not_found.phtml");
         return;
     }
     if ($this->get->username and $this->get->username != $this->session->user->login) {
         $friendship_status = Friendship::get_status($this->session->user->id, $profile_data->id);
         $its_me = false;
     } else {
         if (!$this->session->user) {
             Request::redirect(HOST . 'login');
         }
         $friendship_status = false;
         $its_me = true;
     }
     $template = new Template("default");
     $template->og = new stdClass();
     $template->og->title = $username;
     $template->og->description = 'Skynerd: A rede social do JovemNerd. Vem você também!';
     $template->og->img = MEDIA_DIR . 'images/avatar/big/' . $profile_data->aditional_info->avatar;
     $LoginController = new LoginController();
     if (!$LoginController->isLoggedIn()) {
         $template->show_login_bar = true;
     }
     $this->views = new Views($template);
     $this->views->data = $profile_data;
     $this->views->data->friendship_status = $friendship_status;
     $this->views->data->its_me = $its_me;
     $p = Posts::from_user($profile_data->id);
     $posts = array();
     foreach ($p as $key => $each) {
         $v = new Views();
         $v->accept_nsfw = Profile::acceptNSFW($this->session->user->id);
         $v->current_user = $this->session->user->login;
         $v->user = $each->user;
         $v->name = $each->name;
         $v->when = $each->date;
         $v->title = $each->title;
         $v->content = $each->content;
         $v->comments = $each->comments;
         $v->replies = $each->replies;
         $v->post_id = $each->id;
         $v->original_id = $each->original_id;
         $v->is_reblogged = $each->is_reblogged;
         $v->avatar = $each->avatar;
         $v->rating = $each->rating;
         $v->my_rating = $each->my_rating;
         $v->categories = $each->categories;
         $v->its_mine = $profile_data->id == $this->session->user->id ? true : false;
         $v->is_favorite = $each->is_favorite;
         $v->user_points = $each->user_points;
         if (!empty($each->original_id)) {
             //Se o post for um reblog, então o conteúdo dele deve ser o do reblogado, mostrando as ações
             $originalPost = Posts::from_user(false, $v->original_id);
             $originalPost = reset($originalPost);
             $v->content = $originalPost->content;
             $v->title = $originalPost->title;
             $v->reblogged_from = $originalPost->user;
             $v->reblog_avatar = $originalPost->avatar;
             $v->reblog_points = $originalPost->user_points;
             $v->original_date = $originalPost->date;
             $v->comments = $originalPost->comments;
             $v->replies = $originalPost->replies;
             $v->is_favorite = $originalPost->is_favorite;
             $v->categories = $originalPost->categories;
             $v->rating = $originalPost->rating;
             $v->id = $v->post_id;
             $v->post_id = $originalPost->id;
         }
         $content = $v->render("post_body.phtml");
         $posts[] = $content;
     }
     $this->views->data->timeline = $posts;
     if ($profile_data) {
         $this->views->display("profile.phtml");
     } else {
         $this->views->display("profile_not_found.phtml");
     }
 }
Exemplo n.º 8
0
 public function GetComments()
 {
     $post_id = $this->post->post_id != '' ? $this->post->post_id : false;
     $cache_time = MEMCACHE_SECONDS;
     if (!$post_id) {
         Phalanx::loadClasses('Posts');
         $post = Posts::GetWPPost($this->get->wpid);
         $post_id = $post ? $post->id : false;
         $cache_time = 180;
     }
     $comments = array('');
     header("Content-type: text/html; charset=utf-8");
     if ($post_id) {
         Phalanx::loadClasses("PostComments");
         $comments = PostComments::get($post_id, $cache_time, $this->get->sort);
         foreach ($comments as &$comment) {
             $comment->comment = preg_replace('/(?<=|(?<=[.A-Za-z0-9_-]))@([.A-Za-z0-9_-]+[.A-Za-z0-9_-]+)/', '<a class="profile-link" href="' . HOST . 'perfil/$1"e>@$1</a>', nl2br($comment->comment));
             foreach ($comment->replies as &$reply) {
                 $reply->comment = preg_replace('/(?<=|(?<=[.A-Za-z0-9_-]))@([.A-Za-z0-9_-]+[.A-Za-z0-9_-]+)/', '<a class="profile-link" href="' . HOST . 'perfil/$1"e>@$1</a>', nl2br($reply->comment));
             }
         }
     }
     if ($this->get->render) {
         Phalanx::loadController('LoginController');
         $loginController = new LoginController();
         $v = new Views();
         $v->comments = $post->comment_count;
         $v->replies = $post->reply_count;
         $v->comments_array = $comments;
         $v->post_id = $post_id;
         $v->logged_in = $loginController->isLoggedIn();
         echo $v->render('post_comments.phtml');
     } else {
         die(json_encode($comments));
     }
 }