public function form() { $this->views = new Views(new Template("admin")); Phalanx::loadClasses('Mailing'); $this->views->data = Mailing::get($this->get->id); $this->views->display('mailing_form.phtml'); }
public function show() { $this->views = new Views(new Template("admin")); Phalanx::loadClasses('BillBoard'); $this->views->data = BillBoard::get(); $this->views->display('billboard_list.phtml'); }
public static function from_user($uid, $list_id = false) { $m = Model::Factory('user_lists', true, 0); if ($list_id === false) { $m = Model::Factory('user_lists', true, 0, 'lists_' . $uid); $m->where("user_id='{$uid}'"); } else { $m->where("user_id='{$uid}' AND id='{$list_id}'"); } $lists = $m->all(); $return = array(); if (is_array($lists)) { foreach ($lists as $list) { $o = new stdClass(); $o->id = $list->id; $o->name = $list->name; $c = Model::Factory('user_lists_has_category ulhc')->fields('ulhc.category_id AS id')->where("ulhc.user_lists_id='{$list->id}'")->all(); if ($c) { Phalanx::loadClasses('PostCategory'); $categories = array(); foreach ($c as $category) { $categories[] = PostCategory::translate($category->id); } $o->categories = $categories; } $o->social_networks = Model::Factory('user_lists_has_social_network ulhsn')->fields('sn.id AS id', 'sn.name')->innerJoin('social_network sn', 'ulhsn.social_network_id = sn.id')->where("ulhsn.user_lists_id='{$list->id}'")->all(); $return[] = $o; } } if ($list_id) { return $return[0]; } else { return $return; } }
public function init() { $this->session = new Session(); $this->get = Request::get(); $this->post = Request::post(); Phalanx::loadClasses('Profile', 'Badges'); }
public function form() { $this->views = new Views(new Template("admin")); Phalanx::loadClasses('News'); $this->views->data = News::get($this->get->id); $this->views->display('news_form.phtml'); }
public static function get_profile($u, $privacy = true, $badges = true, $social_networks = true, $friends = true, $exp = true, $aditional_info = true, $gamertags = true) { Phalanx::loadClasses('Privacy', 'Badges', 'Friendship', 'SocialNetwork', 'Posts', 'GamerTags'); $m = Model::Factory('user u'); $m->where("login='******'"); $user = $m->get(); if (!$user) { return false; } # Em alguns casos, não é necessário utilizarmos todos os dados do usuário if ($privacy) { $user->privacy = Privacy::from_user($user->id); } if ($badges) { $user->badges = Badges::from_user($user->id); } if ($social_networks) { $user->social_networks = SocialNetwork::from_user($user->id); } if ($friends) { $user->friends = Friendship::from_user($user->id, 12); } if ($exp) { $user->experience = self::experience($user->id); } if ($aditional_info) { $user->aditional_info = self::other_data($user->id); } if ($gamertags) { $user->gamertags = GamerTags::from_user($user->id); } return $user; }
public function CancelAccount() { Phalanx::loadClasses('Notification'); $this->session->took_the_first_step_to_cancel = 'yes'; $this->views->data = Model::Factory('notifications n')->innerJoin('user u', 'u.id = n.took_by_user_id')->innerJoin('user_data ud', 'ud.user_id=u.id')->fields('DISTINCT u.login', 'ud.avatar')->where("n.notify_user_id='{$this->session->user->id}' AND n.readed=1")->order('n.date DESC')->limit(9)->all(); $this->views->display("cancel_account.phtml"); }
public function form() { $this->views = new Views(new Template("admin")); Phalanx::loadClasses('PressReleases'); $this->views->data = PressReleases::get($this->get->id); $this->views->display('pressreleases_form.phtml'); }
public function ShowAll() { Phalanx::loadClasses('Accounting'); $current_year = $this->get->year ? $this->get->year : date('Y'); $this->views->data = Accounting::getByYear($current_year); $this->views->current_year = $current_year; $this->views->display('accounting_list.phtml'); }
public function adopted() { Phalanx::loadClasses('Cats'); $this->views = new Views(new Template("admin")); $this->views->special = 1; $this->views->data = Cats::get_adopted(1, $this->session->user->id); $this->views->display('adopted_cat_list.phtml'); }
public function init() { $this->session = new Session(); $this->get = Request::get(); $this->post = Request::post(); $this->views = new Views(new Template("admin")); Phalanx::loadClasses('Posts'); }
public function init() { $this->get = Request::get(); $this->session = new Session(); Phalanx::loadController('LoginController'); $loginController = new LoginController(); $this->isLoggedIn = $loginController->checkStatus(); Phalanx::loadClasses('Posts', 'Notification'); }
public function init() { $this->get = Request::get(); $this->post = Request::post(); $this->files = Request::files(); $this->session = new Session(); if ($this->session->logged_in !== true) { Request::redirect(HOST . 'adm/login'); } Phalanx::loadClasses('Godfather'); }
public function init() { Phalanx::loadClasses('Users'); $this->get = Request::get(); $this->post = Request::post(); $this->session = new Session(); if ($this->session->logged_in !== true) { Request::redirect(HOST . 'adm/login'); } define("PERMISSIONS", $this->session->user->level); }
public function ShowDebit() { $year = $this->get->year ? $this->get->year : date('Y'); Phalanx::loadClasses('public.Accounting'); // $this->views = new Views(new Template("public")); $template = new Template("public", "novo/default.phtml"); $this->views = new Views($template); $this->views->current_year = $year; $this->views->data = Accounting::getAccounting($year, "<"); $this->views->display('novo/accounting_d.phtml'); }
public function saveSharingOptions() { Phalanx::loadClasses('SocialNetwork'); if (!is_object($this->post->facebook_options)) { $this->post->facebook_options = new stdClass(); } if (!is_object($this->post->twitter_options)) { $this->post->twitter_options = new stdClass(); } SocialNetwork::saveOptions($this->session->user->id, SocialNetwork::FACEBOOK, $this->post->facebook_options); SocialNetwork::saveOptions($this->session->user->id, SocialNetwork::TWITTER, $this->post->twitter_options); }
public function feed() { Phalanx::loadClasses('SocialNetwork'); $token = SocialNetwork::get_access_token(1, INSTAGRAM); $token = json_decode($token); $instagram = new Instagram($this->config); $instagram->setAccessToken($token->access_token); $popular = $instagram->getUserFeed(); $response = json_decode($popular, true); foreach ($response['data'] as $each) { echo "<img src='{$each['images']['thumbnail']['url']}'>"; } }
public function init() { $this->post = Request::post(); $this->get = Request::get(); $this->session = new Session(); Phalanx::loadController('LoginController'); $loginController = new LoginController(); $loginController->checkStatus(); if ($this->session->accept_token != REQUEST_TOKEN) { Request::redirect(HOST . 'login'); } Phalanx::loadClasses('Facebook', 'SocialNetwork'); }
public static function approve($uid, $fid) { $m = Model::Factory('friendship'); $m->status = 1; $m->where("user_id='{$uid}' AND friend_id='{$fid}'"); $data = $m->update(); if ($data) { Model::ExecuteQuery("UPDATE user_data SET friend_count=friend_count+1 WHERE user_id='{$uid}' OR user_id='{$fid}'"); Phalanx::loadClasses('Notification'); $n = new Notification(Notification::BEFRIENDED, $fid, $fid, $uid); return true; } return false; }
public function callback() { $m = Model::Factory('user'); $m->where("id='{$this->get->uid}'"); $data = $m->get(); $expected_token = md5(date('Ymd') . $data->id . $data->login . $data->login . 'COMPRABASTANTEAQUINERD'); if ($expected_token == $this->get->token) { Phalanx::loadClasses('SocialNetwork'); SocialNetwork::activate_account($this->session->user->id, NERDSTORE); Request::redirect(HOST . 'perfil/configuracoes'); } else { Request::redirect(HOST . 'perfil/configuracoes'); } }
public function init() { $this->post = Request::post(); $this->session = new Session(); Phalanx::loadController('LoginController'); $loginController = new LoginController(); $loginController->checkStatus(); Phalanx::loadClasses('Friendship', 'Timeline', 'Notification', 'Message'); #Goodbye, XSS if ($this->session->accept_token != REQUEST_TOKEN) { Request::redirect(HOST . 'login'); return; } }
public function form() { Phalanx::loadClasses('Users'); Phalanx::loadClasses('Godfather'); $this->views = new Views(new Template("admin")); if (isset($this->get->cat_id)) { $this->views->data = Cats::get_details($this->get->cat_id); $this->views->title = "Gatos (Editando Registro)"; } else { $this->views->title = "Gatos (Adicionar)"; } $this->views->godfathers = Godfather::get_all(NULL, NULL, "nome ASC"); $this->views->data->godfathers_list = unserialize($this->views->data->godfathers_list); $this->views->users = Users::get(); $this->views->display('cats_form.phtml'); }
public function proccess() { Phalanx::loadClasses('Favorites', 'Notification'); switch ($this->post->action) { case 'favorite': $n = new Notification(Notification::FAVORITED_A_POST, $this->session->user->id, $this->post->post_id); $status = Favorites::add($this->session->user->id, $this->post->post_id); break; case 'unfavorite': $status = Favorites::remove($this->session->user->id, $this->post->post_id); break; } header("Content-type: text/html; charset=utf-8"); $o = new stdClass(); $o->status = $status; die(json_encode($o)); }
public static function get($post_id, $cache_time = 0, $sort = null) { Phalanx::loadClasses('public.Profile', 'public.Badges'); $cache_time = $cache_time ? $cache_time : MEMCACHE_SECONDS; $m = Model::Factory('comment c', true, $cache_time); $m->fields('c.id AS id', 'u.id AS user_id', 'c.comment AS comment', 'c.date AS date', 'c.in_reply_to AS in_reply_to', 'c.like_count AS likes', 'c.dislike_count AS dislikes', 'u.login AS user', 'ud.avatar AS avatar', 'c.wp_comment_author AS wp_comment_author', 'c.wp_comment_author_email AS wp_comment_author_email'); $m->leftJoin('user u', 'u.id = c.user_id'); $m->leftJoin('user_data ud', 'ud.user_id = u.id'); $m->where("posts_id='{$post_id}' AND c.status=1 AND u.banned IS NULL"); if (is_null($sort)) { $m->order("c.id ASC"); } elseif ($sort == 'like') { $m->order("c.like_count DESC"); } $data = $m->all(); $comments = array(); $Session = new Session(); if (is_array($data)) { foreach ($data as $each) { $o = new stdClass(); $o->id = $each->id; $o->comment = $each->comment; $o->date = Date::RelativeTime($each->date); $o->rating = new stdClass(); $o->rating->megaboga = (int) $each->likes; $o->rating->whatever = (int) $each->dislikes; $o->my_rating = self::userRating($Session->user->id, $each->id); $o->user = new stdClass(); $o->create_links = $each->user_id == 0 ? false : true; $o->user->login = $each->user_id == 0 ? $each->wp_comment_author : $each->user; $o->user->avatar = $each->user_id == 0 ? "http://www.gravatar.com/avatar/" . md5(strtolower(trim($each->wp_comment_author_email))) . "?d=" . urlencode(MEDIA_DIR . 'images/avatar/square/default.jpg') . "&s=44" : $each->avatar; $o->user->id = $each->user_id; if ($each->user_id != 0) { $o->user->experience = Profile::experience($each->user_id); $o->user->badges = Badges::from_user($each->user_id, 4); } if ($each->in_reply_to == '' || $each->in_reply_to == '0') { $o->replies = is_array($comments[$each->id]->replies) ? $comments[$each->id]->replies : array(); $comments[$each->id] = $o; } else { $comments[$each->in_reply_to]->replies[] = $o; } } } return $comments; }
public function form() { Phalanx::loadClasses('public.PostComments'); if ($this->get->id != '') { $post = Model::Factory('posts', false)->where("id='{$this->get->id}'")->get(); } else { if ($this->get->wpid != '') { $post = Model::Factory('posts', false)->where("wp_posts_ID='{$this->get->wpid}'")->get(); } } if ($post) { $this->views->post = $post; $this->views->comments = PostComments::get($post->id, false); } $this->views->pid = $this->get->id; $this->views->wpid = $this->get->wpid; $this->views->display("form-comentarios.phtml"); }
public function sharePost($data = false) { if (!$data) { $data = $this->post; } Phalanx::loadClasses("SocialNetwork"); $twitter_token = SocialNetwork::get_access_token($data->uid, SocialNetwork::TWITTER); if ($twitter_token) { if (USE_HTTP_PROXY == 1) { $context = stream_context_create(array('http' => array('proxy' => HTTP_PROXY_HOST . ':' . HTTP_PROXY_PORT, 'request_fulluri' => true))); $short_url = file_get_contents("http://migre.me/api.txt?url=" . $data->url, false, $context); } else { $short_url = file_get_contents("http://migre.me/api.txt?url=" . $data->url); } Phalanx::loadClasses('twitteroauth', 'Twitter'); $connection = new TwitterOAuth(TWITTER_CONSUMER_KEY, TWITTER_CONSUMER_SECRET, $twitter_token['oauth_token'], $twitter_token['oauth_token_secret']); Twitter::post($connection, html_entity_decode($data->title) . ' ' . $short_url . ' #Skynerd'); } }
public static function from_user($uid, stdClass $config) { $where = ""; if (property_exists($config, 'min')) { $where .= " AND p.id < '{$config->min}'"; } if (property_exists($config, 'max')) { $where .= " AND p.id < '{$config->max}'"; } Phalanx::loadClasses('Posts', 'PostComments', 'PostCategory'); $m = Model::Factory('posts p', true, 120); $m->fields('DISTINCT p.id AS id', 'p.user_id AS user_id', 'p.content AS content', 'p.date AS date', 'p.title AS title', 'p.like_count AS likes', 'p.dislike_count AS dislikes', 'p.comment_count AS comments', 'p.reply_count AS replies', 'u.name AS name', 'u.login AS user', 'ud.avatar AS avatar'); $m->innerJoin('user u', 'u.id = p.user_id'); $m->leftJoin('user_data ud', 'ud.user_id = p.user_id'); $m->innerJoin('favorites f', 'f.posts_id = p.id'); $m->order('p.date DESC'); $m->where("f.user_id='{$uid}' AND wp_posts_ID IS NULL AND p.status=1 {$where}"); $m->limit(NUMBER_OF_POSTS_LOADED_PER_TIME); $data = $m->all(); $ret = array(); foreach ($data as $v) { $o = new stdClass(); $o->date = Date::RelativeTime($v->date); $o->id = $v->id; $o->name = $v->name; $o->title = $v->title; $o->avatar = $v->avatar; $o->user_id = $v->user_id; $o->rating = new stdClass(); $o->rating->megaboga = $v->likes; $o->rating->whatever = $v->dislikes; $o->my_rating = Posts::userRating($uid, $v->id); $o->content = trim($v->content); $o->comments = $v->comments; $o->replies = $v->replies; $o->user = $v->user; $o->categories = PostCategory::from_post($v->id); $o->is_favorite = true; $ret[] = $o; } return $ret; }
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 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"); }
public function Render($data) { Phalanx::loadClasses('Profile'); $posts = array(); foreach ($data as $key => $each) { $v = new Views(); $v->accept_nsfw = Profile::acceptNSFW($this->session->user->id); $v->original_id = $each->original_id; $v->reblog_count = $each->reblog_count; $v->is_reblogged = $each->is_reblogged; $v->current_user = $this->session->user->login; $v->user = $each->user; $v->title = $each->title; $v->name = $each->name; $v->when = $each->when ? $each->when : $each->date; $v->content = $each->content; $v->via = $each->via; $v->comments = $each->comments; $v->replies = $each->replies; $v->rating = $each->rating; $v->my_rating = $each->my_rating; $v->post_id = $each->id; $v->avatar = $each->avatar; $v->categories = $each->categories; $v->is_favorite = $each->is_favorite; $v->is_reblogged = $each->is_reblogged; $v->its_mine = $each->user_id == $this->session->user->id ? true : false; $v->user_points = $each->user_points; $v->promoted = (bool) $each->promoted; 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; } return $posts; }