コード例 #1
0
ファイル: Battlefields.php プロジェクト: JLacoude/Atrexus
 public function leave()
 {
     if ($this->_user->isPlaying()) {
         $this->_user->exitBattlefield();
     }
     Url::redirect(Url::generate('Play'));
 }
コード例 #2
0
ファイル: Main.php プロジェクト: JLacoude/Atrexus
 /**
  * Login user
  */
 public function login()
 {
     $redirectTo = Url::generate('Main', 'showLoginForm', '&');
     if ($this->_user->isRegistered()) {
         $redirectTo = Url::generate('');
     }
     $posted = $this->_form->getPosted();
     if (empty($posted)) {
         $this->_messenger->add('error', $this->_lang->get('invalidForm'));
     } else {
         if ($this->_user->loginByUserPass($posted['login'], $posted['password'])) {
             $redirectTo = Url::generate('Play');
         }
     }
     $this->_messenger->saveInSession();
     Url::redirect($redirectTo);
 }
コード例 #3
0
ファイル: Register.php プロジェクト: JLacoude/Atrexus
 public function saveAccount()
 {
     $urlToRedirect = Url::generate('Register');
     $posted = $this->_form->getPosted();
     if (empty($posted)) {
         // Redirect to register page
         $this->_messenger->add('error', $this->_lang->get('invalidForm'));
     } else {
         if ($posted['password'] != $posted['passwordVerif']) {
             $this->_messenger->add('error', $this->_lang->get('passwordMismatch'));
         } else {
             if ($this->_user->register($posted['login'], $posted['password'], $posted['email'])) {
                 $urlToRedirect = Url::generate('');
             }
         }
     }
     $this->_messenger->saveInSession();
     Url::redirect($urlToRedirect);
 }
コード例 #4
0
	<script src="<?php 
echo Url::generate('/js/jquery-1.9.1.min.js');
?>
"></script>

</head>
<body>


<a href="<?php 
echo Url::generate('/');
?>
">Форма поиска</a>
<a href="<?php 
echo Url::generate('/result');
?>
">Результаты</a>

<h3>Данные по результату</h3>

<table class="table">
	<thead>
	<tr>
		<td>Host</td>
	</tr>
	</thead>

	<?php 
foreach ($data as $item) {
    ?>
コード例 #5
0
ファイル: Account.php プロジェクト: JLacoude/Atrexus
 /**
  * Sets a new password for a user
  */
 public function setNewPassword()
 {
     if ($this->_user->isRegistered()) {
         Url::redirect(Url::generate('Account'));
     }
     $redirectTo = Url::generate('Account', 'showResetForm', '&');
     $posted = $this->_form->getPosted();
     if (empty($posted)) {
         $this->_messenger->add('error', $this->_lang->get('invalidForm'));
     } else {
         if (!isset($posted['password'], $posted['password2'], $posted['passwordToken'])) {
             $this->_messenger->add('error', $this->_lang->get('missingData'));
         } else {
             if ($posted['password'] != $posted['password2']) {
                 $this->_messenger->add('error', $this->_lang->get('passwordMismatch'));
             } else {
                 if ($this->_user->setNewPassword($posted['passwordToken'], $posted['password'])) {
                     $this->_messenger->add('success', $this->_lang->get('newPasswordSet'));
                     $redirectTo = Url::generate('');
                 }
             }
         }
     }
     $this->_messenger->saveInSession();
     Url::redirect($redirectTo);
 }
コード例 #6
0
ファイル: Play.php プロジェクト: JLacoude/Atrexus
 /**
  * Capture a headquarter
  */
 public function captureHeadquarter()
 {
     $urlToRedirect = Url::generate('Play');
     $posted = $this->_form->getPosted();
     if (empty($posted) || !isset($posted['headquarterId'])) {
         // Logs an error message
         $this->_messenger->add('error', $this->_lang->get('invalidForm'));
     } else {
         $this->_user->captureHeadquarter($posted['headquarterId']);
     }
     $this->_messenger->saveInSession();
     Url::redirect($urlToRedirect);
 }
コード例 #7
0
	</thead>
	
	<?php 
foreach ($results as $item) {
    ?>
	<tr>
		<td><?php 
    echo $item['host'];
    ?>
</td>
		<td><?php 
    echo $types[$item['type']];
    ?>
</td>
		<td><?php 
    echo $item['count'];
    ?>
</td>
		<td><a href="<?php 
    echo Url::generate('/result/view/' . $item['id']);
    ?>
">View</a></td>
	</tr>
	<?php 
}
?>

</table>

</body>
</html>
コード例 #8
0
				valid = false;
			}
			if (type == TEXT_SEARCH && text.length == 0) {
				error = error + "\nYou should define text to search on page";
				valid = false;
			}
			if (!valid) {
				alert(error);
				return false;
			}
			
			// SEND REQUEST
			$.ajax({
				type : "post",
				url  : "<?php 
echo Url::generate('/index/search');
?>
",
				data : {
					'url'  : url,
					'type' : type,
					'text' : text
				},
				success : function(data) {
					console.log(data, data.error);
					var statusDiv = $('#status-message');
					if (data.error == '' || data.error == undefined) {
						statusDiv.html('<span style="color: green;">Parsing successfully finished</span>').show('slow');
						setTimeout(function() {
							statusDiv.hide('slow').html('');
						}, 3000)
コード例 #9
0
ファイル: User.php プロジェクト: JLacoude/Atrexus
 /**
  * Creates a reset password token for an account identified either by a login or an email.
  *
  * @param string $login User login
  * @param string $meail User email
  *
  * @return boolean
  * @todo replace the call to mail() by a proper mailer class
  */
 public function createResetToken($login, $email)
 {
     $result = false;
     $this->_db->beginTransaction();
     try {
         if (!empty($login)) {
             $account = $this->_db->fetchFirstRequest('getUserByLogin', array(':login' => $login));
             if (!empty($account['email'])) {
                 $email = $account['email'];
             }
         }
         if (empty($email)) {
             if (empty($account)) {
                 $this->_messenger->add('error', $this->_lang->get('loginNotFound'));
             } else {
                 $this->_messenger->add('error', $this->_lang->get('accountWithoutEmail'));
             }
             return false;
         } else {
             if (empty($account)) {
                 $account = $this->_db->fetchFirstRequest('getUserByEmail', array(':email' => $email));
             }
             if (empty($account)) {
                 $this->_messenger->add('error', $this->_lang->get('emailNotFound'));
             } else {
                 do {
                     $token = StringTools::generateToken();
                     $alreadyExists = $this->_db->fetchFirstRequest('getPasswordResetByToken', array(':token' => $token));
                 } while (!empty($alreadyExists));
                 $this->_db->executeRequest('createPasswordReset', array(':token' => $token, ':userId' => $account['ID']));
                 $to = str_replace(array("\r", "\n", "%0a", "%0d"), '', $email);
                 $subject = $this->_lang->get('resetMailTitle');
                 $body = sprintf($this->_lang->get('resetMailBody'), $account['login'], Url::generate('Account', 'showPasswordSetForm', '&', array('token' => $token)));
                 if (mail($to, $subject, $body, 'From: Atrexus <*****@*****.**>' . "\n\r")) {
                     $result = true;
                 } else {
                     $this->_messenger->add('error', $body);
                     $this->_messenger->add('error', $this->_lang->get('emailNotSent'));
                 }
             }
         }
     } catch (Exception $e) {
         $this->_db->rollBack();
         throw $e;
     }
     $this->_db->commit();
     return $result;
 }