예제 #1
0
 public function profile()
 {
     if (!$this->isLogged()) {
         header("Location: " . Helpers::url() . 'editor/login');
         exit;
     }
     $userModel = new Editor(self::DB_INSTANCE);
     $viewModel = new ProfileInformation();
     $userRow = $userModel->getInfo($_SESSION['id']);
     $user = new EditorViewModel($userRow['username'], $userRow['password'], $userRow['id'], $userRow['email']);
     $viewModel->setUser($user);
     if (isset($_POST['edit'])) {
         try {
             $bm = new UserEditBindingModel();
             if ($_POST['password'] != $_POST['confirm'] || empty($_POST['password'])) {
                 throw new \Exception('Empty password or passwords do not match');
             }
             $acsrf = new \Hyper\Core\Csrf();
             if ($acsrf->validateToken()) {
                 $user = new EditorViewModel($bm->getUsername(), $bm->getPassword(), $_SESSION['id'], $bm->getEmail());
                 if ($userModel->edit($user)) {
                     $viewModel->getUser()->setUsername($user->getUsername());
                     $viewModel->success = 'Edit successful';
                 }
             } else {
                 throw new \Exception('Anti-CSRF token does not match');
             }
         } catch (\Exception $e) {
             $viewModel->error = $e->getMessage();
             return new View($viewModel);
         }
     }
     return new View($viewModel);
 }
예제 #2
0
파일: header.php 프로젝트: pgyordanov/PHP
                    <ul class="nav navbar-nav navbar-right">
                        <li><a href="<?php 
    echo \Hyper\Helpers\Helpers::url() . 'editor/login';
    ?>
" class="hvr-underline-reveal"><span class="glyphicon glyphicon-log-in"></span> Login</a></li>
                    </ul>
                    <?php 
} else {
    ?>
                        <ul class="nav navbar-nav">
                            <li><a href="<?php 
    echo \Hyper\Helpers\Helpers::url() . 'editor/profile';
    ?>
" class="hvr-underline-reveal"><span class="glyphicon glyphicon-user"></span> Profile</a></li>
                        </ul>
                        <ul class="nav navbar-nav navbar-right">
                            <li><a href="<?php 
    echo \Hyper\Helpers\Helpers::url() . 'editor/logout';
    ?>
" class="hvr-underline-reveal"><span class="glyphicon glyphicon-log-out"></span> Logout</a></li>
                        </ul>
                    <?php 
}
?>
                </ul>
            </div><!-- /.navbar-collapse -->
        </div><!-- /.container-fluid -->
    </nav>
</header>

<main class="row">
예제 #3
0
파일: header.php 프로젝트: pgyordanov/PHP
" class="hvr-underline-reveal"><span class="glyphicon glyphicon-log-in"></span> Login</a></li>
                        <li><a href="<?php 
    echo \Hyper\Helpers\Helpers::url() . 'User/register';
    ?>
" class="hvr-underline-reveal"><span class="glyphicon glyphicon-registration-mark"></span> Register</a></li>
                    </ul>
                    <?php 
} else {
    ?>
                        <ul class="nav navbar-nav">
                            <li><a href="<?php 
    echo \Hyper\Helpers\Helpers::url() . 'User/profile';
    ?>
" class="hvr-underline-reveal"><span class="glyphicon glyphicon-user"></span> Profile</a></li>
                        </ul>
                        <ul class="nav navbar-nav navbar-right">
                            <li><a href="<?php 
    echo \Hyper\Helpers\Helpers::url() . 'User/logout';
    ?>
" class="hvr-underline-reveal"><span class="glyphicon glyphicon-log-out"></span> Logout</a></li>
                        </ul>
                    <?php 
}
?>
                </ul>
            </div><!-- /.navbar-collapse -->
        </div><!-- /.container-fluid -->
    </nav>
</header>

<main class="row">