Ejemplo n.º 1
0
 public function __invoke($context)
 {
     // _GET vars
     $context['_GET'] = array();
     if (isset($context['env']['QUERY_STRING'])) {
         parse_str($context['env']['QUERY_STRING'], $context['_GET']);
     }
     // _COOKIE vars
     if (isset($context['env']['HTTP_COOKIE'])) {
         $ck = new Cookies($context['env']['HTTP_COOKIE']);
     } else {
         $ck = new Cookies(null);
     }
     $context['_COOKIE'] = $ck;
     // _POST and _FILES
     if ($context['env']['REQUEST_METHOD'] == 'POST') {
         $context['_POST'] = array();
         $context['_FILES'] = array();
         echo "getting buffer\n";
         $buffer = stream_get_contents($context['stdin'], $context['env']['CONTENT_LENGTH']);
         echo "got buffer\n";
         if (isset($this->options['forward_stream']) and $this->options['forward_stream'] === true) {
             // user asks us to provide a valid stream to app
             $stream_name = StringStreamKeeper::keep($buffer);
             $_old_stdin = $context['stdin'];
             $context['stdin'] = fopen($stream_name, 'r');
         }
         if (isset($context['env']['CONTENT_TYPE']) and strpos($context['env']['CONTENT_TYPE'], 'multipart/form-data') === 0) {
             self::parseMultipart($context['env']['CONTENT_TYPE'], $buffer, $context['_POST'], $context['_FILES']);
         } else {
             echo "parsing…\n";
             parse_str($buffer, $context['_POST']);
         }
         unset($buffer);
         // free memory
     }
     // EXECUTE
     $result = call_user_func($this->app, $context);
     if (!is_array($result)) {
         return $result;
     }
     // Append cookie-headers
     $result[1] = array_merge($result[1], $ck->_getHeaders());
     // Cleanup
     if (isset($_old_stdin)) {
         // remove our "fake" stream
         fclose($context['stdin']);
         StringStreamKeeper::cleanup();
         $context['stdin'] = $_old_stdin;
     }
     if (isset($context['env']['_FILES'])) {
         // remove created files, if there were any
         foreach ($context['env']['_FILES'] as $file) {
             if ($file['error'] == UPLOAD_ERR_OK and file_exists($file['tmp_name'])) {
                 unlink($file['tmp_name']);
             }
         }
     }
     return $result;
 }
Ejemplo n.º 2
0
 public function login($username = null, $pass = null, $remember = false)
 {
     if (!$username && !$pass && $this->exist()) {
         Session::put($this->_sessionName, $this->data()->id);
     } else {
         $user = $this->find($username);
         if ($user) {
             if ($this->_data->password === Hash::make($pass, $this->_data->salt)) {
                 Session::put($this->_sessionName, $this->_data->id);
                 if ($remember) {
                     $hash = hash::unique();
                     $hashCheck = $this->_db->get('user_session', array('user_id', '=', $this->data()->id));
                     if (!$hashCheck->count()) {
                         $this->_db->insert('user_session', array('user_id' => $this->_data->id, 'hash' => $hash));
                     } else {
                         $hash = $hashCheck->first()->hash;
                     }
                     Cookies::put($this->_cookieName, $hash, config::get('remember/expiry'));
                 }
                 return true;
             }
         }
     }
     return false;
 }
Ejemplo n.º 3
0
 public function __construct()
 {
     Cookies::del('sid');
     Cookies::del('uid');
     Cookies::del('data');
     header('Location: /');
 }
Ejemplo n.º 4
0
 public function __construct()
 {
     global $config;
     $username = strip_tags(addslashes(trim($_POST['username'])));
     $password = md5(trim($_POST['password']));
     $viewonly = $_POST['view'] == 1;
     $sql = "SELECT user_id, hours\r\n                FROM users\r\n                WHERE username = '******'\r\n                AND password = '******'";
     if ($data = Db::query($sql)) {
         $user_id = $data['user_id'];
         $hours = $data['hours'];
         if ($config['expires']) {
             $expires = $config['expires'];
         } else {
             $expires = intval($hours) * 3600;
         }
         # if ( headers_sent($file, $line) )
         #     die( "Headers Sent on $file:$line" );
         $modules = $this->getModules($user_id);
         $data = array('username' => $username, 'viewOnly' => $viewonly, 'hours' => $hours, 'modules' => $modules);
         Cookies::set('sid', md5($user_id), $expires);
         Cookies::set('uid', $user_id, $expires);
         Cookies::set('data', Json::encode($data), $expires);
     }
     header('Location: /');
 }
Ejemplo n.º 5
0
 public function __construct()
 {
     $this->userid = Cookies::isLoggedIn();
     if ($this->userid === false) {
         header('Location: /login');
         exit;
     }
 }
Ejemplo n.º 6
0
 public static function set($name, $value, $time, $path = "/", $domain = Null, $secure = False, $httponly = False)
 {
     $time2 = Cookies::getTime($time);
     if ($domain == Null) {
         setcookie($name, $value, $time2, $path);
     } else {
         setcookie($name, $value, $time2, $path, $domain, $secure, $httponly);
     }
 }
Ejemplo n.º 7
0
 /**
  * Process an AJAX call from the login form
  * Input:
  *  user name, password
  * Output:
  *  HTTP status code, completion message, user name and session
  *  cookies set.
  */
 public function run()
 {
     if ($this->validInput()) {
         if ($this->loginUser()) {
             Cookies::setLoginCookies($this->nickName, $this->id, $this->firstName, $this->lastName);
             print 'Success!';
         }
     }
 }
Ejemplo n.º 8
0
 public function destroy($id)
 {
     if ($this->consult->getConsultar("\n            DELETE FROM user\n            WHERE id_user = '******'\n        ")) {
         Cookies::set("delete", "Se ha eliminado el usuario correctamente", "20-s");
         Redirection::go("user");
     } else {
         Cookies::set("alert", "Error: No se ha podido eliminar el usuario intenta de nuevo", "20-s");
         Redirection::go("user");
     }
 }
Ejemplo n.º 9
0
 protected function sendCookies()
 {
     if (!$this->cookies) {
         return;
     }
     foreach ($this->cookies as $key => $value) {
         $str = $this->cookies->parseValue($key, $value);
         header("Set-Cookie: {$str}", true);
     }
 }
Ejemplo n.º 10
0
 /**
  * We track visitors to the website by setting a unique ID string into
  * a cookie.
  */
 private function setTrackingCookie()
 {
     if (!isset($_COOKIE['u'])) {
         // create a unique string
         $uid = md5($_SERVER['REMOTE_ADDR'] . $_SERVER['REQUEST_TIME']);
         // expire 6 months in the future
         $expires = time() + 60 * 60 * 24 * 30 * 6;
         $domain = Cookies::getThisDomainName();
         setcookie('u', $uid, $expires, '/', $domain);
     }
 }
Ejemplo n.º 11
0
 public static function getTopFull()
 {
     $msg = Cookies::restore('flashTopFull');
     $type = Cookies::restore('flashTopFullType');
     Cookies::delete('flashTopFull');
     Cookies::delete('flashTopFullType');
     if ($msg !== null) {
         return '"text":"' . $msg . '","layout":"top","type":"' . $type . '"';
     }
     return false;
 }
Ejemplo n.º 12
0
 static function checkLogStatusForSite()
 {
     if (!isset($_SESSION)) {
         session_start();
     }
     if (!isset($_SESSION['user_id'])) {
         if (Cookies::isSetLoginCookies()) {
             if (Cookies::verifyLoginCookies()) {
                 $id = Cookies::getLoginIdFromCookie();
                 $username = Users::getUserById($id)['username'];
                 self::staticSetSession($id, $username);
             }
         }
     }
 }
Ejemplo n.º 13
0
 public function run()
 {
     // get the base domain name
     $domain = Cookies::getThisDomainName();
     // clear the session cookie
     setcookie('s', '', time() - 3600, '/', $domain);
     // refresh the page
     $url = $_SERVER['PHP_SELF'];
     $url = str_replace('.php', '', $url);
     $url = preg_replace('/\\?.*$/', '', $url);
     if ($url == '/index') {
         $url = '/';
     }
     header("Refresh: 0; url={$url}");
 }
 public function load()
 {
     require_once HM_LIMIT_LOGIN_DIR . 'inc/class-options.php';
     require_once HM_LIMIT_LOGIN_DIR . 'inc/class-errors.php';
     require_once HM_LIMIT_LOGIN_DIR . 'inc/class-cookies.php';
     require_once HM_LIMIT_LOGIN_DIR . 'inc/class-validation.php';
     require_once HM_LIMIT_LOGIN_DIR . 'inc/class-notifications.php';
     if (HM_LIMIT_LOGIN_VERSION !== get_option('hm_limit_login_version')) {
         $this->set_default_variables();
     }
     load_plugin_textdomain('limit-login-attempts', false, dirname(plugin_basename(__FILE__)));
     Options::get_instance();
     Errors::get_instance();
     Cookies::get_instance();
     Validation::get_instance();
     Notifications::get_instance();
 }
Ejemplo n.º 15
0
 public function __construct()
 {
     global $config;
     if (substr(Web::getIP(), 0, strlen($config['internal'])) == $config['internal']) {
         $this->viewOnly = false;
     }
     $this->userId = Cookies::get('uid');
     $this->logId = $this->log();
     switch ($_GET['w']) {
         case 'time':
             $this->return = $this->time;
             break;
         case 'resume':
             $this->return = $this->work();
             break;
         default:
             $this->return = $this->logId;
             break;
     }
 }
Ejemplo n.º 16
0
 static function initialize()
 {
     self::$cookies = $_COOKIE;
     if (class_exists('session')) {
         // Grab the cookie jar and set cookies as needed
         self::$jar = (array) session::get('__cookiejar');
         // Add the cookies from the jar to the cookies collection so
         // we can access them.
         foreach (self::$jar as $cookie) {
             self::$cookies[$cookie[0]] = $cookie[1];
         }
         if (!headers_sent()) {
             foreach (self::$jar as $cookie) {
                 call_user_func_array('setcookie', $cookie);
                 session::clr('__cookiejar');
             }
             // Then empty the jar
             self::$jar = array();
             session::clr('__cookiejar');
         } else {
             throw new BaseException("Cookie jar for delayed cookies loaded but output already started");
         }
     }
 }
Ejemplo n.º 17
0
<?php

require_once __DIR__ . '/includes/all.php';
$cookies = new Cookies();
$user = $cookies->user_from_cookie();
$id = $_GET["id"];
$sid = $_GET["sid"];
if ($user === 0) {
    header("Location: /index.php");
    exit;
}
if ($user->data["permission"] != 4) {
    if ($user->data["service_id"] != $sid && $user->data["permission"] == 3) {
        echo "Invalid permissions";
        //        return;
    }
}
$id = intval($id);
if ($id !== -1) {
    $item = DB::queryOneRow("SELECT * FROM menu_items WHERE id=%d", $id);
    $side_link = DB::query("SELECT * FROM menu_sides_item_link WHERE item_id=%d", $id);
    $used = DBHelper::verticalSlice($side_link, "sides_id");
    if (count($used) == 0) {
        $used = array(-1);
    }
    $osides = DB::query('SELECT * FROM menu_sides WHERE id NOT IN (' . implode(',', array_map('intval', $used)) . ') AND service_id=%d', $sid);
} else {
    $side_link = array();
    $osides = DB::query("SELECT * FROM menu_sides WHERE service_id=%d", $sid);
}
$iname = $id == -1 ? "Name" : "Name: " . $item["name"];
Ejemplo n.º 18
0
Archivo: login.php Proyecto: VSG24/ccms
<?php

require_once '../c_config.php';
$session = new Sessions();
$i = null;
// just a helper for error checking
if (isset($_POST["submit"])) {
    $username = $_POST["username"];
    $password = $_POST["password"];
    if (verifyUser($username, $password)) {
        $id = Users::getIdByUsername($username);
        Cookies::setLoginCookies($id, 30);
        // remember for 30 dayz!
        $session->setSession($id, $username);
        $i = false;
    } else {
        $i = true;
    }
}
?>
<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <script src="js/jquery.min.js"></script>
    <link href="css/login.css" rel='stylesheet' type='text/css' />
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <script type="application/x-javascript"> addEventListener("load", function() { setTimeout(hideURLbar, 0); }, false); function hideURLbar(){ window.scrollTo(0,1); } </script>
    <title>ccms Admin Login</title>
</head>
Ejemplo n.º 19
0
$di->set('crypt', function () {
    $crypt = new \Phalcon\Crypt();
    $crypt->setCipher('blowfish');
    $crypt->setKey('vmS"TG<');
    return $crypt;
}, true);
/**
 * Start the session the first time some component request the session service
 */
$di->setShared('session', function () {
    $session = new SessionAdapter();
    $session->start();
    return $session;
});
$di->set('cookie', function () {
    $cookies = new Cookies();
    $cookies->useEncryption(true);
    return $cookies;
}, true);
$di->setShared('logger', function () use($config) {
    $logger = new Phalcon\Logger\Adapter\File($config->application->logDir . 'application.log');
    return $logger;
});
$di->setShared('flashSession', function () {
    $flash = new Phalcon\Flash\Session();
    $flash->setCssClasses(array('error' => 'alert alert-danger', 'success' => 'alert alert-success', 'warning' => 'alert alert-warning', 'notice' => 'alert alert-info'));
    return $flash;
});
$di->setShared('user', function () {
    return $user = (new Auth())->authByCookie();
});
Ejemplo n.º 20
0
<?php

if (defined('YOi_Start') && $YOi_Token == "5ab7b44c0747390658bbf882ae4df1c7") {
    $type = ["alert", "delete", "edit", "complete"];
    $cookies = Cookies::getAll();
    for ($i = 0; $i < count($cookies); $i++) {
        for ($j = 0; $j < count($type); $j++) {
            if ($cookies[$i] == $type[$j]) {
                ?>
	      <div id="msj" class="hide">
	         <figure><img src="" alt=""></figure>
	         <p></p>
	      </div>
	      <script src="/media/js/messages.js"></script>
	<?php 
            }
        }
    }
}
 public function option_page()
 {
     $validation_object = Validation::get_instance();
     $cookies_object = Cookies::get_instance();
     $cookies_object->cleanup();
     if (!current_user_can('manage_options')) {
         wp_die('Sorry, but you do not have permissions to change settings.');
     }
     /* Make sure post was from this page */
     if (count($_POST) > 0) {
         check_admin_referer('hm-limit-login-attempts-options');
     }
     /* Should we clear log? */
     if (isset($_POST['clear_log'])) {
         delete_option('hm_limit_login_logged');
         echo '<div id="message" class="updated fade"><p>' . __('Cleared IP log', 'limit-login-attempts') . '</p></div>';
     }
     /* Should we reset counter? */
     if (isset($_POST['reset_total'])) {
         update_option('hm_limit_login_lockouts_total', 0);
         echo '<div id="message" class="updated fade"><p>' . __('Reset lockout count', 'limit-login-attempts') . '</p></div>';
     }
     /* Should we restore current lockouts? */
     if (isset($_POST['reset_current'])) {
         update_option('hm_limit_login_lockouts', array());
         echo '<div id="message" class="updated fade"><p>' . __('Cleared current lockouts', 'limit-login-attempts') . '</p></div>';
     }
     /* Should we update options? */
     if (isset($_POST['update_options'])) {
         $new_options = array();
         $new_options['client_type'] = $_POST['client_type'];
         $new_options['allowed_retries'] = absint($_POST['allowed_retries']);
         $new_options['lockout_duration'] = absint($_POST['lockout_duration'] * 60);
         // into seconds
         $new_options['valid_duration'] = absint($_POST['valid_duration'] * 3600);
         // into seconds
         $new_options['allowed_lockouts'] = absint($_POST['allowed_lockouts']);
         $new_options['long_duration'] = absint($_POST['long_duration'] * 3600);
         // into seconds
         $new_options['notify_email_after'] = absint($_POST['email_after']);
         $new_options['cookies'] = absint(isset($_POST['cookies']) && $_POST['cookies'] == '1');
         $v = array();
         if (isset($_POST['lockout_notify_log'])) {
             $v[] = 'log';
         }
         if (isset($_POST['lockout_notify_email'])) {
             $v[] = 'email';
         }
         $new_options['lockout_notify'] = implode(',', $v);
         $selected_lockout_method = array();
         if (isset($_POST['lockout_method_ip'])) {
             $selected_lockout_method[] = 'ip';
         }
         if (isset($_POST['lockout_method_username'])) {
             $selected_lockout_method[] = 'username';
         }
         // This should never be empty. Defaulting to IP.
         if (empty($selected_lockout_method)) {
             $selected_lockout_method[] = 'ip';
         }
         $new_options['lockout_method'] = implode(',', $selected_lockout_method);
         foreach ($new_options as $option_key => $option_value) {
             $meta_key = 'hm_limit_login_' . $option_key;
             $meta_value = $option_value;
             update_option($meta_key, $meta_value);
         }
         echo '<div id="message" class="updated fade"><p>' . esc_html__('Options changed', 'limit-login-attempts') . '</p></div>';
     }
     /* Get current options to populate the form with */
     $client_type = get_option('hm_limit_login_client_type');
     $allowed_retries = absint(get_option('hm_limit_login_allowed_retries'));
     $lockout_duration = absint(get_option('hm_limit_login_lockout_duration')) / 60;
     // in minutes
     $valid_duration = absint(get_option('hm_limit_login_valid_duration')) / 3600;
     // in hours
     $allowed_lockouts = absint(get_option('hm_limit_login_allowed_lockouts'));
     $long_duration = absint(get_option('hm_limit_login_long_duration')) / 3600;
     // in hours
     $notify_email_after = absint(get_option('hm_limit_login_email_after'));
     $cookies = absint(isset($_POST['cookies']) && $_POST['cookies'] == '1');
     $lockouts_total = absint(get_option('hm_limit_login_lockouts_total', 0));
     $lockouts = $validation_object->get_lockouts();
     $lockouts_now = is_array($lockouts) ? count($lockouts) : 0;
     $cookies_yes = get_option('hm_limit_login_cookies') ? ' checked ' : '';
     $cookies_no = get_option('hm_limit_login_cookies') ? '' : ' checked ';
     $client_type_direct = $client_type == HM_LIMIT_LOGIN_DIRECT_ADDR ? ' checked ' : '';
     $client_type_proxy = $client_type == HM_LIMIT_LOGIN_PROXY_ADDR ? ' checked ' : '';
     $client_type_guess = $this->guess_proxy();
     $client_type_message = '';
     $client_type_warning = '';
     if ($client_type_guess == HM_LIMIT_LOGIN_DIRECT_ADDR) {
         $client_type_message = sprintf(__('It appears the site is reached directly (from your IP: %s)', 'limit-login-attempts'), $validation_object->get_address(HM_LIMIT_LOGIN_DIRECT_ADDR));
     } else {
         $client_type_message = sprintf(__('It appears the site is reached through a proxy server (proxy IP: %s, your IP: %s)', 'limit-login-attempts'), $validation_object->get_address(HM_LIMIT_LOGIN_DIRECT_ADDR), $validation_object->get_address(HM_LIMIT_LOGIN_PROXY_ADDR));
     }
     $client_type_message .= '<br />';
     if ($client_type != $client_type_guess) {
         $faq = 'http://wordpress.org/extend/plugins/limit-login-attempts/faq/';
         $client_type_warning = '<p>' . sprintf(__('<strong>Current setting appears to be invalid</strong>. Please make sure it is correct. Further information can be found <a href="%s" title="FAQ">here</a>', 'limit-login-attempts'), $faq) . '</p>';
     }
     $v = explode(',', get_option('hm_limit_login_lockout_notify'));
     $log_checked = in_array('log', $v) ? ' checked ' : '';
     $email_checked = in_array('email', $v) ? ' checked ' : '';
     $saved_lockout_methods = $validation_object->get_lockout_methods();
     $lockout_method_ip = checked(1, $saved_lockout_methods['ip'], false);
     $lockout_method_username = checked(1, $saved_lockout_methods['username'], false);
     include HM_LIMIT_LOGIN_DIR . 'inc/options-page.php';
 }
Ejemplo n.º 22
0
});
// Social Authentication (Facebook) connect
$app->post('/accounts/facebook/connect', function () use($app) {
    $facebook_id = $app->request->input('facebook_id');
    $email = $app->request->input('email');
    $password = $app->request->input('password');
    $user = app('db')->table('accounts')->where('email', 'like', $email)->first();
    // store ID
    if (!empty($user)) {
        require_once __DIR__ . '/../../public/includes/all.php';
        $manager = new UserManager();
        $auth = $manager->auth_user($email, $password);
        // validate password
        if (!empty($auth[1])) {
            app('db')->table('accounts')->where('id', $user->id)->update(['facebook_id' => $facebook_id]);
            $cookies = new Cookies();
            $cookies->set_cookie($user->uid);
            return redirect('/profile.php?p=2&m=6');
        }
    }
    return redirect('/index.php?m=2');
});
// Save main category settings
$app->post('/admin/category/{categoryId}', function ($categoryId) use($app) {
    $inputs = $app->request->input();
    if (empty($inputs['name'])) {
        unset($inputs['name']);
    }
    // grab existing service
    $category = app('db')->table('categories')->where('id', $categoryId)->first();
    if ($category->displayorder != $inputs['displayorder']) {
Ejemplo n.º 23
0
<?php

define('DEBUG', true);
$root = realpath(dirname(__FILE__));
$urls = array('^/$' => 'Principal', '^/ingresar$' => 'Ingresar', '^/ingresar/amnesia$' => 'IngresarAmnesia', '^/personas$' => 'Personas', '^/personas/(\\d+)$' => 'PersonasVer', '^/personas/(\\d+)/editar$' => 'PersonasEditar', '^/empresas$' => 'Empresas', '^/empresas/agregar$' => 'EmpresasAgregar', '^/empresas/(\\d+)$' => 'EmpresasVer', '^/empresas/(\\d+)/editar$' => 'EmpresasEditar', '^/empresas/(\\d+)/personas$' => 'EmpresasPersonas', '^/empresas/(\\d+)/personas/agregar$' => 'EmpresasPersonasAgregar', '^/configuracion$' => 'Configuracion', '^/configuracion/apariencia$' => 'ConfiguracionApariencia', '^/salir$' => 'Salir');
include_once "{$root}/config.php";
if (DEBUG) {
    error_reporting(E_ALL);
}
include_once "{$root}/lib/Request.php";
include_once "{$root}/lib/Response.php";
include_once "{$root}/lib/Web.php";
include_once "{$root}/lib/WebBase.php";
include_once "{$root}/lib/Cookies.php";
include_once "{$root}/lib/Validation.php";
include_once "{$root}/lib/String.php";
include_once "{$root}/lib/Lang.php";
include_once "{$root}/lib/Db.php";
include_once "{$root}/lib/Config.php";
include_once "{$root}/lib/Session.php";
Db::open($dbConfig);
Cookies::$prefix = 'EME_';
Session::start();
Web::errorRegister(404, 'Error404');
Web::dispatch($urls);
Db::close();
Ejemplo n.º 24
0
<?php

session_start();
if (!file_exists('/pages/install/install.php')) {
    spl_autoload_register(function ($class) {
        require 'inc/classes/' . $class . '.class.php';
    });
}
require_once 'sanitize.php';
if (!file_exists('pages/install/install.php')) {
    $db = DB::getInstance();
    if (Cookies::exists(Config::get('session/cookie_name')) && !Session::exists(Config::get('session/session_name'))) {
        $hash = Cookies::get(Config::get('session/cookie_name'));
        $hashCheck = $db->get('user_session', array('hash', '=', $hash));
        if ($hashCheck->count()) {
            $user = new User($hashCheck->first()->user_id);
            $user->login();
        }
    }
    ini_set('diplay_errors', Setting::get('debug'));
    $error_reporting = Setting::get('debug') == 'Off' ? '0' : '-1';
    error_reporting($error_reporting);
} else {
    error_reporting(-1);
}
Ejemplo n.º 25
0
 /**
  * @test
  */
 public function it_gets_and_updates_cookie_value_on_request()
 {
     //
     // Example of naive cookie decryption middleware.
     //
     // Shows how to access and manipulate cookies using PSR-7 Request
     // instances from outside the Request object itself.
     //
     // Simulate a request coming in with several cookies.
     $request = (new FigCookieTestingRequest())->withHeader(Cookies::COOKIE_HEADER, 'theme=light; sessionToken=RAPELCGRQ; hello=world');
     // Get our cookies from the request.
     $cookies = Cookies::fromRequest($request);
     // Ask for the encrypted session token.
     $encryptedSessionToken = $cookies->get('sessionToken');
     // Get the encrypted value from the cookie and decrypt it.
     $encryptedValue = $encryptedSessionToken->getValue();
     $decryptedValue = str_rot13($encryptedValue);
     // Create a new cookie with the decrypted value.
     $decryptedSessionToken = $encryptedSessionToken->withValue($decryptedValue);
     // Include our decrypted session token with the rest of our cookies.
     $cookies = $cookies->with($decryptedSessionToken);
     // Render our cookies, along with the newly decrypted session token, into a request.
     $request = $cookies->renderIntoCookieHeader($request);
     // From this point on, any request based on this one can get the plaintext version
     // of the session token.
     $this->assertEquals('theme=light; sessionToken=ENCRYPTED; hello=world', $request->getHeaderLine(Cookies::COOKIE_HEADER));
 }
Ejemplo n.º 26
0
<?php

require_once __DIR__ . '/includes/all.php';
$vars = set_vars($_GET, array("type", "id"));
if (!$vars) {
    header("Location: /index.php");
    exit;
}
$cookies = new Cookies();
$user = $cookies->user_from_cookie();
if ($user === 0) {
    header("Location: /index.php");
    exit;
}
$cookies->renew_cookie($user->id);
$user_id = $user->data["uid"];
$menu = new Menu($_GET["type"], $_GET["id"]);
?>
<!DOCTYPE HTML>
<html>
	<head>
		<title> </title>
		<meta http-equiv="content-type" content="text/html; charset=utf-8" />
		<meta name="viewport" content="initial-scale=1">
		<meta name="description" content="" />
		<meta name="keywords" content="" />
		<!--[if lte IE 8]><script src="css/ie/html5shiv.js"></script><![endif]-->
		<script src="js/jquery.min.js"></script>
		<script src="js/jquery.scrolly.min.js"></script>
		<script src="js/skel.min.js"></script>
<!--        <script src="js/jquery.cookie.js"></script>-->
Ejemplo n.º 27
0
<?php

/**
 * @Author: lipeng
 * @Date:   2015-12-09 21:56:18
 * @Last Modified by:   lipeng
 * @Last Modified time: 2015-12-09 21:58:35
 */
date_default_timezone_set("PRC");
require './Cookies.class.php';
// 把用户名保存在cookie中
$username = $_GET['username'];
$Cookies = new Cookies();
$Cookies->set('username', $username);
echo $Cookies->get('username');
var_dump($_REQUEST);
var_dump($_COOKIE);
Ejemplo n.º 28
0
 public function Export()
 {
     Phalanx::loadClasses('Profile', 'Badges');
     $profile = Profile::get_profile($this->session->user->login, 0, 0, 0, 0, 1, 1, 1);
     $profile->badges = Badges::from_user($this->sessio->user->id, false);
     $t = new Template("export");
     $t->show_login_bar = true;
     $userPosts = Posts::exportFromUser($this->session->user->id);
     $postsImages = array();
     $avatarImages = array();
     $posts = array();
     Phalanx::loadExtension('simple_html_dom');
     foreach ($userPosts as $key => $each) {
         $html = str_get_html($each->content);
         /*
          * Em alguns casos o objeto não está sendo criado, gerando um fatal error.
          * Conteúdo vazio? Estranho, ainda não sei o que está rolando.
          * Isso aqui resolve.
          * */
         if (is_object($html)) {
             $images = $html->find('img');
             foreach ($images as &$image) {
                 if (stripos($image, HOST)) {
                     $postsImages[] = basename($image->src);
                     $image->src = "./images/posts/" . basename($image->src);
                 }
             }
             $each->content = $html;
         }
         $avatarImages[] = $each->avatar;
         $v = new Views();
         $v->accept_nsfw = Profile::acceptNSFW($this->session->user->id);
         $v->current_user = $this->session->user->login;
         $v->user = $each->user;
         $v->name = $each->name;
         $v->when = $each->date;
         $v->title = $each->title;
         $v->content = $each->content;
         $v->comments = $each->comments;
         $v->comments_array = $each->comments_array;
         $v->replies = $each->replies;
         $v->post_id = $each->id;
         $v->original_id = $each->original_id;
         $v->is_reblogged = $each->is_reblogged;
         $v->avatar = $each->avatar;
         $v->rating = $each->rating;
         $v->my_rating = $each->my_rating;
         $v->categories = $each->categories;
         $v->its_mine = $profile_data->id == $this->session->user->id ? true : false;
         $v->is_favorite = $each->is_favorite;
         $v->user_points = $each->user_points;
         foreach ($each->comments_array as $eachComment) {
             $avatarImages[] = $eachComment->user->avatar;
             foreach ($eachComment->replies as $eachReply) {
                 $avatarImages[] = $eachReply->user->avatar;
             }
         }
         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("export/post_body.phtml");
         $posts[] = $content;
     }
     $v = new Views($t);
     $v->data = $profile;
     $v->data->timeline = $posts;
     ob_start();
     $v->display("export/profile.phtml");
     $profile_html_data = ob_get_contents();
     ob_end_clean();
     if (!is_dir(TMP_DIR . DIRECTORY_SEPARATOR . 'export')) {
         mkdir(TMP_DIR . DIRECTORY_SEPARATOR . 'export', 0755, true);
     }
     $dirname = TMP_DIR . DIRECTORY_SEPARATOR . 'export' . DIRECTORY_SEPARATOR . $this->session->user->login . DIRECTORY_SEPARATOR;
     if (!is_dir($dirname)) {
         mkdir($dirname, 0755, true);
     }
     $filename = "perfil-{$this->session->user->login}.html";
     file_put_contents($dirname . $filename, $profile_html_data);
     $zip = new ZipArchive();
     if ($zip->open("{$dirname}data.zip", ZipArchive::CREATE) === TRUE) {
         $zip->addEmptyDir('css');
         foreach (glob(TEMPLATE_DIR . '/export/css/*') as $file) {
             $zip->addFile($file, "/css/" . basename($file));
         }
         $zip->addEmptyDir('js');
         foreach (glob(TEMPLATE_DIR . '/export/js/*') as $file) {
             $zip->addFile($file, "/js/" . basename($file));
         }
         $zip->addEmptyDir('fonts');
         $zip->addEmptyDir('fonts/Engschrift');
         foreach (glob(TEMPLATE_DIR . '/export/fonts/Engschrift/*') as $file) {
             $zip->addFile($file, "/fonts/Engschrift/" . basename($file));
         }
         $zip->addEmptyDir('images');
         foreach (glob(TEMPLATE_DIR . '/export/images/*.*') as $file) {
             $zip->addFile($file, "/images/" . basename($file));
         }
         $zip->addEmptyDir('images/socialnetworks');
         foreach (glob(TEMPLATE_DIR . '/export/images/socialnetworks/*') as $file) {
             $zip->addFile($file, "/images/socialnetworks/" . basename($file));
         }
         $zip->addEmptyDir('images/images');
         foreach (glob(TEMPLATE_DIR . '/export/images/images/*') as $file) {
             $zip->addFile($file, "/images/images/" . basename($file));
         }
         $zip->addEmptyDir('images/avatar');
         $zip->addEmptyDir('images/avatar/big');
         $zip->addEmptyDir('images/avatar/small');
         $zip->addEmptyDir('images/avatar/square');
         foreach ($avatarImages as $avatar) {
             $zip->addFile(AVATAR_UPLOAD_DIR . "/big/{$avatar}", "/images/avatar/big/{$avatar}");
             $zip->addFile(AVATAR_UPLOAD_DIR . "/small/{$avatar}", "/images/avatar/small/{$avatar}");
             $zip->addFile(AVATAR_UPLOAD_DIR . "/square/{$avatar}", "/images/avatar/square/{$avatar}");
         }
         $zip->addEmptyDir('images/posts');
         foreach ($postsImages as $image) {
             $zip->addFile(POST_IMAGES_UPLOAD_DIR . "/{$image}", "/images/posts/{$image}");
         }
         $zip->addEmptyDir('images/badges');
         foreach (glob(ROOT . PROJECT_DIR . '/media/images/badges/*') as $file) {
             $zip->addFile($file, "/images/badges/" . basename($file));
         }
         $zip->addFile("{$dirname}{$filename}", "/{$filename}");
     }
     $zip->close();
     header("Content-disposition: attachment; filename={$this->session->user->login}.zip");
     header("Content-type: application/zip");
     readfile("{$dirname}data.zip");
     $t = new Template("export", "thankyou.phtml");
     $v = new Views($t);
     $v->display("");
     $c = new Cookies();
     $c->setExpire(strtotime("+15 days"));
     $c->data_exported = 1;
 }
Ejemplo n.º 29
0
<?php

require_once __DIR__ . '/../all.php';
if (!isset($_POST['username']) || empty($_POST['username'])) {
    header("Location: /index.php?m=5");
    // not enough credentials passed
    exit;
}
if (!isset($_POST['password']) || empty($_POST['password'])) {
    header("Location: /index.php?m=5");
    // not enough credentials passed
    exit;
}
$location = "/";
$users = new UserManager();
$cookies = new Cookies();
$data = $users->auth_user($_POST["username"], $_POST["password"]);
$auth_level = $data[0];
$user_uid = $data[1];
if ($auth_level !== 0) {
    // user is valid
    $cookies->set_cookie($user_uid);
    if ($auth_level != 1) {
        $location = "/admin.php";
        //         header("Location: /admin.php");
        //         exit;
    } else {
        $location = "/index.php";
        //         header("Location: /index.php?m=6"); // success no message
        //         exit;
    }
 /**
  * Tidy up retries on a successful login
  */
 protected function cleanup_on_login()
 {
     $cookies = Cookies::get_instance();
     list(, $valid, ) = $cookies->get_retries_data();
     foreach (array($this->get_address(), $this->get_username()) as $lockout_item) {
         if (isset($valid[$lockout_item])) {
             $valid[$lockout_item] = -1;
         }
     }
     // Removes the lockout and retries after a successful login
     $cookies->cleanup(null, null, $valid);
 }