public function SearchPeople() { #Goodbye, XSS if ($this->session->accept_token != REQUEST_TOKEN) { Request::redirect(HOST . 'login'); return; } $m = Model::Factory('user u', true, 180); $username = trim($this->post->username); $m->fields("DISTINCT\tu.name\tAS name", "u.id\t\t\t\tAS id", "u.login\t\t\tAS login", "ud.avatar\t\t\tAS avatar"); $m->leftJoin('user_data ud', 'ud.user_id = u.id'); $m->where("((u.login LIKE '{$username}%') OR u.name LIKE '{$username}%') AND u.id NOT IN('{$this->session->user->id}', 0)"); $m->limit(15); $users = $m->all(); foreach ($data as $k => $v) { $users[$k]->friendship_status = Friendship::get_status($this->session->user->id, $v->id); } $o = new stdClass(); header("Content-type:application/json;charset=utf-8"); if ($users) { $o->status = 1; $o->users = $users; } else { $o->status = 0; $o->message = "NOT FOUND"; } die(json_encode($o)); }
public function DisplayPost() { if ($this->get->username == 'wordpressagent') { Request::redirect(HOST); } Phalanx::loadClasses('Profile', 'Friendship', 'Posts'); $profile_data = Profile::get_profile($this->get->username, 0, 0, 0, 0, 0, 0, 0); if ($profile_data->banned == 1) { $this->views->display("profile_banned.phtml"); return; } if ($profile_data->active == 0) { $this->views->display("profile_deactivated.phtml"); return; } $friendship_status = Friendship::get_status($this->session->user->id, $profile_data->id); $this->views->data->friendship_status = $friendship_status; $this->views->data = $profile_data; $p = Posts::from_user($profile_data->id, $this->get->post_id); if (!$p) { $this->views->display("post_unavailable.phtml"); return; } $p = reset($p); $can_be_displayed = true; #Verifica se o post é privado. if ($p->privacy == 1) { if (!$this->session->user->id) { $this->views->display("post_unavailable.phtml"); die; } if ($this->session->user->id == $p->user_id) { $can_be_displayed = true; } else { $can_be_displayed = Friendship::get_status($this->session->user->id, $p->user_id); } } if (!$can_be_displayed) { $this->views->display("post_unavailable.phtml"); die; } $v = new Views(); $v->title = $p->title; $v->user = $p->user; $v->name = $p->name; $v->content = $p->content; $v->comments = $p->comments; $v->comments_array = PostComments::get($this->get->post_id); $v->replies = $p->replies; $v->post_id = $p->id; $v->original_id = $p->original_id; $v->avatar = $p->avatar; $v->rating = $p->rating; $v->promoted = (bool) $p->promoted; $v->accept_nsfw = Profile::acceptNSFW($this->session->user->id); $v->when = $p->date; $v->my_rating = $p->my_rating; $v->current_user = $this->session->user->login; $v->categories = PostCategory::from_post($p->id); $v->its_mine = $profile_data->id == $this->session->user->id ? true : false; $v->is_favorite = $p->is_favorite; $v->user_points = $p->user_points; if (!empty($p->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, $p->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->rating = $originalPost->rating; $v->comments = $originalPost->comments; $v->replies = $originalPost->replies; $v->is_favorite = $originalPost->is_favorite; $v->categories = PostCategory::from_post($p->original_id); $v->comments_array = PostComments::get($p->original_id); $v->id = $p->id; $v->post_id = $originalPost->id; } $content = $v->render("post_body.phtml"); $template = new Template("default"); $template->og = new stdClass(); $template->og->title = $v->user . ': ' . $v->title; $template->og->description = $p->content; $template->og->type = FACEBOOK_APPNAMESPACE . ':article_'; $template->og->img = MEDIA_DIR . 'images/avatar/big/' . $p->avatar; if (!$this->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->post = $content; $this->views->display("single_post_display.phtml"); }