Example #1
0
 * Grid of Media
 *
 * @author   Anton Shevchuk
 */
/**
 * @namespace
 */
namespace Application;

use Bluz\Proxy\Layout;
use Bluz\Proxy\Request;
use Bluz\Proxy\Response;
return function () use($view) {
    /**
     * @var Bootstrap $this
     * @var \Bluz\View\View $view
     */
    Layout::setTemplate('dashboard.phtml');
    Layout::breadCrumbs([$view->ahref('Dashboard', ['dashboard', 'index']), __('Media')]);
    $grid = new Media\Grid();
    $countCol = Request::getParam('countCol');
    if ($countCol != null) {
        Response::setCookie("countCol", $countCol, time() + 3600, '/');
    } else {
        $countCol = Request::getCookie('countCol', 4);
    }
    $lnCol = (int) (12 / $countCol);
    $view->countCol = $countCol;
    $view->col = $lnCol;
    $view->grid = $grid;
};
Example #2
0
 /**
  * Generates cookie for authentication
  *
  * @throws \Bluz\Db\Exception\DbException
  */
 public function generateCookie()
 {
     $hash = hash('md5', microtime(true));
     $ttl = Config::getModuleData('users', 'rememberMe');
     $this->delete(['userId' => Auth::getIdentity()->id, 'foreignKey' => Auth::getIdentity()->login, 'provider' => self::PROVIDER_COOKIE, 'tokenType' => self::TYPE_ACCESS]);
     $row = new Row();
     $row->userId = Auth::getIdentity()->id;
     $row->foreignKey = Auth::getIdentity()->login;
     $row->provider = self::PROVIDER_COOKIE;
     $row->tokenType = self::TYPE_ACCESS;
     $row->expired = gmdate('Y-m-d H:i:s', time() + $ttl);
     $row->tokenSecret = $this->generateSecret(Auth::getIdentity()->id);
     $row->token = hash('md5', $row->tokenSecret . $hash);
     $row->save();
     Response::setCookie('rToken', $hash, time() + $ttl, '/');
     Response::setCookie('rId', Auth::getIdentity()->id, time() + $ttl, '/');
 }