Esempio n. 1
0
<?php

$pageLocalModel = new ProfileModel();
$stamina = 0;
$uid = Request::getParam('user')->id;
$pageLocalModel->checkStamina($uid);
$stamina = $pageLocalModel->getStamina($uid);
$staminaMax = $pageLocalModel->getStaminaMax($uid);
$staminaPercent = $stamina * 100 / $staminaMax;
$staminaPercent = $staminaPercent < 0 ? 0 : $staminaPercent;
?>
<a href="{URL:/main}"><div class="logo"></div></a>

<?php 
if (Request::getParam('user')->id) {
    echo '<div class="profile_bar">';
    echo '<div class="nav_profile">';
    echo '<img class="avatar" src="' . getAvatar(Request::getParam('user')->id) . '" alt="Avatar" />';
    echo '<div class="nav_profile_name"><a href="' . url(Request::getParam('user')->id) . '">' . Request::getParam('user')->nickname . '</a></div>';
    echo '<div class="stamina-bar"><div class="full" style="width:' . $staminaPercent . '%"></div></div>';
    echo '</div>';
    echo '<ul class="nav_personal">';
    echo '<li class="friends-icon"><a href="' . url('friends') . '" title="{L:FRIENDS}">' . (Request::getParam('countRequests') > 0 ? '(+' . Request::getParam('countRequests') . ')' : '') . '</a></li>';
    echo '<li class="mail-icon"><a href="' . url('mail') . '" title="{L:MAIL}">' . (Request::getParam('countMsg') > 0 ? '(+' . Request::getParam('countMsg') . ')' : '') . '</a></li>';
    echo '<li class="settings-icon"><a href="' . url('settings') . '" title="{L:SETTINGS}"></a></li>';
    echo '<li class="exit-icon"><a href="' . url('profile', 'exit') . '" title="{L:EXIT}"></a></li>';
    echo '</ul>';
    echo '</div>';
    echo '<div class="nav_menu">';
    if (Request::getRole() == 'moder' or Request::getRole() == 'admin') {
        echo '<a class="admin-panel" href="{URL:admin}">{L:ADMIN_PANEL}</a>';
Esempio n. 2
0
 public function challengeAction()
 {
     if (empty($_SERVER['HTTP_X_REQUESTED_WITH'])) {
         error404();
     }
     $model = new ProfileModel();
     $data['uid'] = Request::getParam('user')->id;
     $role = Request::getParam('user')->role;
     $model->checkStamina($data['uid']);
     $data['pid'] = post('pid', 'int');
     $data['startTime'] = time();
     if ($model->getStamina($data['uid']) - 1 >= 0 or $role == 'admin') {
         if ($data['uid'] != $data['pid']) {
             if ($model->getUserByID($data['pid'])->id && !$model->getMatchesByUP($data['uid'], $data['pid'])->id) {
                 $result = $model->insert('matches', $data);
                 if ($result) {
                     if ($role != 'admin') {
                         $model->updateStamina($data['uid'], "-1");
                     }
                     $response['target_h']['#challenge'] = 'Challenge sent';
                     $response['target_h']['#challenge' . $data['pid']] = 'Challenge sent';
                 } else {
                     $response['target_h']['#challenge'] = 'Error challenge!';
                     $response['target_h']['#challenge' . $data['pid']] = 'Error challenge!';
                 }
             } else {
                 $response['target_h']['#challenge'] = 'You have already challenged this profile!';
                 $response['target_h']['#challenge' . $data['pid']] = 'You have already challenged this profile!';
             }
         } else {
             $response['target_h']['#challenge'] = 'You can not challenge for yourself!';
             $response['target_h']['#challenge' . $data['pid']] = 'You can not challenge for yourself!';
         }
     } else {
         $response['target_h']['#challenge'] = 'Not enough stamina, recover your stamina points or try again tomorrow.';
         $response['target_h']['#challenge' . $data['pid']] = 'Not enough stamina, recover your stamina points or try again tomorrow.';
     }
     $response['error'] = 0;
     echo json_encode($response);
     exit;
 }