/** * getFromId function. * * @access public * @param mixed $_id * @return void */ public function getFromId($_id) { try { $db = new DB(); $_id = (int) $_id; $item = $db->query("SELECT * FROM " . $this->table . " WHERE id = '{$_id}'"); $result = $item->fetchAll(); if ($result) { $this->setItem($result[0]); $obj_user = new User(); $this->_author = $obj_user->getFromId($this->user); $this->getReplies(); } return $this; } catch (PDOException $e) { print "Error!: " . $e->getMessage() . "<br/>"; die; } }
public function getUserVotes() { $return = NULL; $_id = NULL; try { $db = new DB(); $return = array(); $_id = $this->id; $hUser = new User(); #Helper $items = $db->query("SELECT DISTINCT u.id\n FROM " . $hUser->table . " u\n JOIN " . $this->table_points . " p ON ( p.user = u.id ) \n WHERE p.project = '{$_id}'\n ORDER BY u.id"); if ($items) { foreach ($items->fetchAll() as $item) { $obj_u = new User(); $return[] = $obj_u->getFromId($item['id']); } } } catch (PDOException $e) { print "Error!: " . $e->getMessage() . "<br/>"; die; } return $return; }
$datetime = DateTime::createFromFormat('Y-m-d', $last_date); $datetime->sub(new DateInterval('P1D')); $date = $datetime->format('Y-m-d'); $dateHeader = $datetime->format("l, F jS"); $headerBlock = '<div class="block-day"> <time class="date center" datetime="' . $date . '"> <i class="fa fa-calendar"></i> ' . $dateHeader . ' </time>'; $footerBlock = '</div>'; //Limit our results within a specified date $results = $p->getLastProjects($date); if ($results) { //set new user $u = new User(); if (!$_user->logged) { $modal = 'data-toggle="modal" data-target="#postModal"'; } foreach ($results as $item) { if ($_user->logged) { if ($u->checkPoint($item->id, $_user->id)) { $point = '<a href="#" class="vote" data-id="' . $item->id . '" data-status="1" ' . $modal . '> <i class="vote-icon-active fa fa-caret-square-o-up fa-2x"></i></a>'; } else { $point = '<a href="#" class="vote" data-id="' . $item->id . '" data-status="0" ' . $modal . '> <i class="vote-icon fa fa-caret-square-o-up fa-2x"></i></a>'; } } else { $point = '<a href="#" class="vote" data-id="' . $item->id . '" data-status="0" ' . $modal . '> <i class="vote-icon fa fa-caret-square-o-up fa-2x"></i></a>';
} else { if (empty($response['auth']) || empty($response['timestamp']) || empty($response['signature']) || empty($response['auth']['provider']) || empty($response['auth']['uid'])) { echo '<strong style="color: red;">Invalid auth response: </strong>Missing key auth response components.' . "<br>\n"; } elseif (!$Opauth->validate(sha1(print_r($response['auth'], true)), $response['timestamp'], $response['signature'], $reason)) { echo '<strong style="color: red;">Invalid auth response: </strong>' . $reason . ".<br>\n"; } else { // REF $goTo = '/'; if (!empty($_GET['ref'])) { $goTo = strip_tags(addslashes($_GET['ref'])); } elseif (!empty($_SERVER['HTTP_REFERER'])) { $goTo = strip_tags(addslashes($_SERVER['HTTP_REFERER'])); } switch ($response['auth']['provider']) { case 'Twitter': $user = new User(); $_idU = $user->isRegistered($response['auth']['uid']); if ($_idU) { $user->getFromId($_idU); if ($user->isActive()) { $item['name'] = $response['auth']['info']['name']; $item['active'] = 1; $item['last_login'] = time(); // Login data $item['uid'] = $response['auth']['uid']; $item['token'] = $response['auth']['credentials']['token']; $item['secret'] = $response['auth']['credentials']['secret']; $item['signature'] = $response['signature']; //Profile data $item['account'] = $response['auth']['info']['nickname']; if (isset($response['auth']['info']['description'])) {
<?php /* * Copyright (c) 2014 Alberto González * Distributed under Apache License 2.0 * (see README for details) */ namespace Quaver\Controller; use Quaver\Model\User; $ac = NULL; $ac = $this->url_var[1]; // Check if user is logged to get profile data and display if (!empty($ac)) { $profile = new User(); $_getProfile = $profile->getFromAccount($ac); if ($_getProfile->id > 0) { $this->addTwigVars('profile', $_getProfile); $pointsAdded = NULL; $pointsAdded = $_getProfile->getPointsAdded(); $this->addTwigVars('pointsAdded', $pointsAdded); } else { header("Location: /"); exit; } } else { header("Location: /"); exit; } $template = $this->twig->loadTemplate('profiles/profile.twig'); echo $template->render($this->twigVars);
/** * @param bool $_mvc */ public function start($_mvc = true) { global $_lang; // Set user_default global global $_user; $_user = new User(); if (!empty($_COOKIE[COOKIE_NAME . "_log"])) { $_user->getFromCookie($_COOKIE[COOKIE_NAME . "_log"]); } // Load language $_lang = new Lang(); if (!empty($_GET['lang'])) { $lang_slug = substr($_GET['lang'], 0, 3); $_lang->getFromSlug($lang_slug); $_lang->setCookie(); } else { $_lang->getSiteLanguage(); } $this->language = $_lang->id; // Assoc URL to MVC if ($_mvc) { $this->loadMVC(); } }