public function form() { Phalanx::loadClasses('Profile', 'PostCategory', 'Lists', 'GamerTags', 'NotificationSettings'); $this->views->data = Profile::get_profile($this->session->user->login, 1, 0, 1, 0, 0, 1, 1); $this->views->categories = PostCategory::get(); $this->views->lists = Lists::from_user($this->session->user->id); $this->views->notification_settings = NotificationSettings::from_user($this->session->user->id); $this->views->message = $this->session->message; $this->session->message = ''; $this->views->display("settings_form.phtml"); }
private function feed() { Phalanx::loadClasses('Profile', 'Lists', 'PostCategory'); $user_data = Profile::get_profile($this->session->user->login); #Correção p/ um bug com os nomes de usuários incorretos if (empty($user_data->login)) { Request::redirect(HOST); } else { #Reutilização do mesmo core para criação da timeline - F**k yeah Phalanx::loadController('TimelineController'); $Timeline = new TimelineController(); $posts = $Timeline->BuildFromList($this->cookies->active_list); #Pego os outros dados do usuário que são utilizados na página de feed $this->views = new Views(new Template("default")); $this->views->data = $user_data; $this->views->lists = Lists::from_user($this->session->user->id); $this->views->categories = PostCategory::get(); $this->views->posts = $posts; $this->views->display("feed.phtml"); } }
public function Post() { if (!$this->isLoggedIn) { return; } if ($this->session->accept_token != REQUEST_TOKEN) { Request::redirect(HOST . 'login'); return; } $content = stripslashes(Request::post(false)->content); #Faz a validação do HTML; HTMLPurifier <3 require_once EXTENSIONS_DIR . 'HTMLPurifier/HTMLPurifier.includes.php'; $config = HTMLPurifier_Config::createDefault(); $config->set('Cache.DefinitionImpl', null); $config->set('HTML.TargetBlank', true); $config->set('HTML.SafeObject', true); $config->set('HTML.SafeEmbed', true); $config->set('HTML.SafeIframe', true); $config->set('Output.FlashCompat', true); $config->set('HTML.FlashAllowFullScreen', true); $config->set('HTML.Allowed', 'i, b, a[href], p, ul, ol, li, span[style], img[src|style], strike, br, hr, blockquote, div, object, param[name|value], embed[src|type|width|height|allowscriptaccess], iframe[src|width|height]'); $config->set('CSS.AllowedProperties', 'color, float, height, width, margin, border'); $config->set('AutoFormat.Linkify', true); $config->set('URI.MungeResources', true); $config->set('URI.SafeIframeRegexp', '#^https://((www.)?youtube.com/embed/|player.vimeo.com/video/)#'); $HTMLPurifier = new HTMLPurifier($config); $content = $HTMLPurifier->purify($content); $content = preg_replace('/(?<=^|\\s|>)@([A-Za-z0-9_]{1,20})/', '<a class="profile-link" href="' . HOST . 'perfil/$1" data-login="******">@$1</a>', $content); $bbCodeTags = array('spoiler' => array('<div class="spoiler-alert"><span class="alert"><b>SPOILER ALERT!</b> <a href="javascript:void(0);">Clique aqui</a> para exibir.</span><span class="spoiler-content">', '<span></div>')); $content = BBCode::parse($content, $bbCodeTags); Phalanx::loadClasses('Profile', 'Badges', 'PostCategory'); $m = Model::Factory('posts'); $m->user_id = $this->session->user->id; if (trim($this->post->title) != "") { $m->title = $this->post->title; } $m->content = $content; $m->public = $this->post->post_privacy; $m->date = date('Y-m-d H:i:s'); $m->like_count = 0; $m->dislike_count = 0; $m->comment_count = 0; $post_id = $m->insert(); if (isset($this->post->categories)) { $categories = explode(",", $this->post->categories); foreach ($categories as $category) { $category = trim($category); $categoryID = PostCategory::get($category); $m = Model::Factory('posts_has_category'); $m->posts_id = $post_id; $m->category_id = $categoryID; $m->insert(); } } $view = new Views(); $view->title = $this->post->title; $view->content = $content; $view->user = $this->session->user->login; $view->avatar = $this->session->user->other_data->avatar; $view->when = ' agora'; $view->post_id = $post_id; $view->rating = new stdClass(); $view->rating->whatever = 0; $view->rating->megaboga = 0; $view->my_rating = null; $view->its_mine = true; $view->experience = Profile::experience($this->session->user->id); $view->badges = Badges::from_user($this->session->user->id, 4); preg_match_all('/(?<=|(?<=[.A-Za-z0-9_-]))@([.A-Za-z0-9_-]+[.A-Za-z0-9_-]+)/', $this->post->content, $usernames); foreach ($usernames[1] as $username) { $user = Profile::get_user_info($username); if ($user) { $n = new Notification(Notification::TAGGED_IN_A_POST, $this->session->user->id, $post_id, $user->id); } } if ($this->post->post_to_twitter == 1 or $this->post->post_to_facebook == 1) { $o = new stdClass(); $o->title = $this->post->title; $o->url = HOST . 'perfil/' . $this->session->user->login . '/post/' . $post_id . '-' . mb_strtolower(preg_replace('/--+/u', '-', preg_replace('/[^\\w\\-]+/u', '-', $this->post->title))); $o->uid = $this->session->user->id; $o->content = strip_tags($content); $o->avatar = MEDIA_DIR . 'images/avatar/big/' . $this->session->user->other_data->avatar; $o->post_id = $post_id; try { if ($this->post->post_to_facebook == 1) { Phalanx::loadController('FacebookController'); $facebook = new FacebookController(); $facebook->callOpenGraphAction('write', array('article_' => $o->url)); } if ($this->post->post_to_twitter == 1) { Phalanx::loadController('TwitterController'); $twitter = new TwitterController(); $twitter->sharePost($o); } } catch (Exception $e) { } } header("Content-type: text/html; charset=utf-8"); echo $view->render("post_body.phtml"); }