/** * constructor */ public function __construct() { // Create new DB object $this->db = new DB(); // Twig Template System Loader require_once LIB_PATH . '/Twig/Autoloader.php'; \Twig_Autoloader::register(); // Getting all directories in /template $path = VIEW_PATH; $templatesDir = array($path); $dirsToScan = array($path); $dirKey = 0; while (count($dirsToScan) > $dirKey) { $results = scandir($dirsToScan[$dirKey]); foreach ($results as $result) { if ($result === '.' || $result === '..') { continue; } if (is_dir($dirsToScan[$dirKey] . '/' . $result)) { $templatesDir[] = $dirsToScan[$dirKey] . '/' . $result; $dirsToScan[] = $dirsToScan[$dirKey] . '/' . $result; } } $dirKey++; } //get query string from URL to core var $this->getQueryString(); $loader = new \Twig_Loader_Filesystem($templatesDir); $twig_options = array(); if (defined('TEMPLATE_CACHE') && TEMPLATE_CACHE) { $twig_options['cache'] = "./Cache"; } if (defined('CACHE_AUTO_RELOAD') && CACHE_AUTO_RELOAD) { $twig_options['auto_reload'] = true; } $this->twig = new \Twig_Environment($loader, $twig_options); // Clear Twig cache if (defined(TEMPLATE_CACHE) && TEMPLATE_CACHE) { if (isset($this->queryString['clearCache'])) { $this->twig->clearCacheFiles(); $url = parse_url($_SERVER['REQUEST_URI'], PHP_URL_PATH); header("Location: {$url}"); exit; } } // Restoring user_default session sample if (!empty($this->queryString['PHPSESSID'])) { $sessionHash = $this->queryString['PHPSESSID']; $_userFromSession = new User(); $_userFromSession->setCookie($sessionHash); $url = parse_url($_SERVER['REQUEST_URI'], PHP_URL_PATH); header("Location: {$url}"); exit; } }
if (isset($response['auth']['info']['description'])) { $item['biography'] = $response['auth']['info']['description']; } if (isset($response['auth']['info']['location'])) { $item['location'] = $response['auth']['info']['location']; } if (isset($response['auth']['raw']['entities']['url']['urls'][0]['display_url'])) { $item['web_link'] = $response['auth']['raw']['entities']['url']['urls'][0]['display_url']; } //Save image $url_image = $response['auth']['info']['image']; $item['avatar'] = str_replace("_normal", "", $url_image); $user->setItem($item); $user->save(); // Logged in $user->setCookie(); header("Location: {$goTo}"); exit; } else { // User not active $_error_login = true; $goTo = '/login/?user-disabled'; header("Location: /?user-disabled"); exit; } } else { $item['name'] = $response['auth']['info']['name']; $item['email'] = ""; $item['level'] = "user"; $item['active'] = 1; $item['registered'] = time();