Пример #1
0
 /**
  * Function to display the HTML-Header
  */
 public function displayHeader()
 {
     self::$IS_SHOWN = true;
     self::$IS_IFRAME = Request::param('mode') == 'iframe';
     $this->setEncoding();
     $this->initTraining();
     $UserId = !is_null($this->ActivityContext) ? SessionAccountHandler::getId() : 0;
     $User = AccountHandler::getDataForId($UserId);
     if (!Request::isAjax()) {
         if (self::$IS_IFRAME) {
             include 'tpl/tpl.FrontendSharedIframe.header.php';
         } else {
             include 'tpl/tpl.FrontendShared.header.php';
         }
     }
     Error::getInstance()->header_sent = true;
 }
Пример #2
0
<?php

/**
* Delete Account
* Call:   call/window.delete.php
*/
require '../inc/class.Frontend.php';
$Frontend = new Frontend();
$Errors = array();
AccountHandler::setAndSendDeletionKeyFor($Errors);
echo HTML::h1(__('Delete your account.'));
if (!empty($Errors)) {
    foreach ($Errors as $Error) {
        echo HTML::error($Error);
    }
} else {
    echo HTML::info(__('<em>A confirmation has been sent via mail.</em><br>' . 'How sad, that you\'ve decided to delete your account.<br>' . 'Your account will be deleted as soon as you click on the confirmation link in your mail.'));
}
Пример #3
0
 /**
  * @covers AccountHandler::tryToActivateAccount
  */
 public function testTryToActivateAccount()
 {
     DB::getInstance()->exec('DELETE FROM `runalyze_account` WHERE `id` = 1');
     DB::getInstance()->insert('account', array('id', 'username', 'mail', 'activation_hash'), array(1, 'test', '*****@*****.**', '8e1e915d08a163ddd4accc6d890dd557'));
     $_GET['activate'] = '908a098ef7e6cb87de7a6';
     $this->assertEquals(false, AccountHandler::tryToActivateAccount());
     $this->assertEquals('8e1e915d08a163ddd4accc6d890dd557', DB::getInstance()->query('SELECT activation_hash FROM `runalyze_account` WHERE `id`=1 LIMIT 1')->fetchColumn());
     $_GET['activate'] = '8e1e915d08a163ddd4accc6d890dd557';
     $this->assertEquals(true, AccountHandler::tryToActivateAccount());
     $this->assertEquals('', DB::getInstance()->query('SELECT activation_hash FROM `runalyze_account` WHERE `id`=1 LIMIT 1')->fetchColumn());
 }
Пример #4
0
 /**
  * Create a new user from post-data
  */
 private static function createNewUserFromPost()
 {
     $errors = array();
     $activationHash = System::isAtLocalhost() ? '' : self::getRandomHash();
     $newSalt = self::getNewSalt();
     $newAccountId = DB::getInstance()->insert('account', array('username', 'name', 'mail', 'language', 'password', 'salt', 'registerdate', 'activation_hash'), array($_POST['new_username'], $_POST['name'], $_POST['email'], Language::getCurrentLanguage(), self::passwordToHash($_POST['password'], $newSalt), $newSalt, time(), $activationHash));
     self::$IS_ON_REGISTER_PROCESS = true;
     self::$NEW_REGISTERED_ID = $newAccountId;
     if ($newAccountId === false) {
         $errors[] = __('Something went wrong. Please contact the administrator.');
     } else {
         self::importEmptyValuesFor($newAccountId);
         self::setSpecialConfigValuesFor($newAccountId);
         if ($activationHash != '') {
             self::setAndSendActivationKeyFor($newAccountId, $errors);
         }
     }
     self::$IS_ON_REGISTER_PROCESS = false;
     self::$NEW_REGISTERED_ID = -1;
     return $errors;
 }
    ?>
<br>
				<br>
				<a href="login.php?delete=<?php 
    echo $_GET['delete'];
    ?>
&want=true"><strong><?php 
    _e('Delete account');
    ?>
 &raquo;</strong></a>
	<?php 
} else {
    ?>
      
		<?php 
    if (AccountHandler::tryToDeleteAccount()) {
        ?>
			<p class="info">
				<?php 
        _e('Your account has been deleted.');
        ?>
<br>
				<?php 
        _e('You cannot use Runalyze anymore.');
        ?>
			</p>
		<?php 
    } else {
        ?>
			<p class="error">
				<?php 
Пример #6
0
 /**
  * Display shared menu
  */
 protected function displaySharedMenu()
 {
     $User = AccountHandler::getDataForId(SharedLinker::getUserId());
     $this->ToolbarLinks = array();
     $this->ToolbarLinks[] = SharedLinker::getStandardLinkTo($this->Context->activity()->id(), Icon::$ATTACH);
     $this->ToolbarLinks[] = '<a href="shared/' . $User['username'] . '/" target="_blank">' . Icon::$TABLE . '</a>';
     $this->displayHeaderMenu();
 }
 /**
  * Get autologin_hash and set it as cookie
  * @return string
  */
 private function getAutologinHash()
 {
     $autologinHash = '';
     if (isset($_POST['autologin'])) {
         $autologinHash = AccountHandler::getAutologinHash();
         setcookie('autologin', $autologinHash, time() + 30 * 86400);
     }
     return $autologinHash;
 }
 /**
  * Init user 
  */
 protected function initUser()
 {
     $this->User = AccountHandler::getDataFor(Request::param('user'));
 }
Пример #9
0
 /**
  * Try to change password
  */
 private function tryToChangePassword()
 {
     if ($_POST['new_pw'] == $_POST['new_pw_repeat']) {
         $Account = DB::getInstance()->query('SELECT `password`, `salt` FROM `' . PREFIX . 'account`' . ' WHERE id = ' . SessionAccountHandler::getId())->fetch();
         if (AccountHandler::comparePasswords($_POST['old_pw'], $Account['password'], $Account['salt'])) {
             if (strlen($_POST['new_pw']) < AccountHandler::$PASS_MIN_LENGTH) {
                 ConfigTabs::addMessage(HTML::error(sprintf(__('The password has to contain at least %s characters.'), AccountHandler::$PASS_MIN_LENGTH)));
             } else {
                 AccountHandler::setNewPassword(SessionAccountHandler::getUsername(), $_POST['new_pw']);
                 ConfigTabs::addMessage(HTML::okay(__('Your password has been changed.')));
             }
         } else {
             ConfigTabs::addMessage(HTML::error(__('You current password is wrong.')));
         }
     } else {
         ConfigTabs::addMessage(HTML::error(__('The passwords have to be the same.')));
     }
 }
Пример #10
0
 /**
  * Get user ID
  * @return int
  */
 public static function getUserId()
 {
     if (self::$USER_ID <= 0) {
         if (strlen(Request::param('user')) > 0) {
             $Data = AccountHandler::getDataFor(Request::param('user'));
             self::$USER_ID = $Data['id'];
         } elseif (strlen(Request::param('url')) > 0) {
             DB::getInstance()->stopAddingAccountID();
             $Data = DB::getInstance()->query('SELECT `accountid` FROM `' . PREFIX . 'training` WHERE id="' . self::getTrainingId() . '" LIMIT 1')->fetch();
             DB::getInstance()->startAddingAccountID();
             self::$USER_ID = $Data['accountid'];
         } elseif (self::isOnMetaCourseForFacebook()) {
             $Data = true;
             self::$USER_ID = (int) Request::param('account');
         } else {
             $Data = false;
         }
         if ($Data === false) {
             self::$USER_ID = -1;
         }
     }
     return self::$USER_ID;
 }
Пример #11
0
?>
</label>
					<input id="send_username" name="send_username" class="middle-size" type="text" value="<?php 
if (isset($_POST['username'])) {
    echo str_replace('"', '', $_POST['username']);
}
?>
">
				</div>

			<?php 
if (isset($_POST['send_username'])) {
    ?>
				<p class="info small">
					<?php 
    echo AccountHandler::sendPasswordLinkTo($_POST['send_username']);
    ?>
				</p>
			<?php 
} else {
    ?>
				<p class="info small">
					<?php 
    _e('A link for changing your password will be sent via email.');
    ?>
				</p>
			<?php 
}
?>
			</fieldset>
<div class="w50" id="login-window">
		<fieldset>
			<legend><?php 
_e('Activate account');
?>
</legend>
		<?php 
if (AccountHandler::tryToActivateAccount()) {
    ?>
			<p class="info">
				<?php 
    _e('Your account has been activated.');
    ?>
<br>
				<?php 
    _e('You can now use Runalyze.');
    ?>
			</p>
		<?php 
} else {
    ?>
			<p class="error">
				<?php 
    _e('The activation did not work.');
    ?>
<br>
				<?php 
    _e('Probably the link was wrong.');
    ?>
			</p>
		<?php 
Пример #13
0
 /**
  * Import all needed sql-dumps to database
  */
 protected function importSqlFiles()
 {
     $this->connectToDatabase($this->mysqlConfig[3], $this->mysqlConfig[0], $this->mysqlConfig[1], $this->mysqlConfig[2]);
     $this->importSqlFile('inc/install/structure.sql');
     define('FRONTEND_PATH', __DIR__ . '/');
     require_once FRONTEND_PATH . '/system/class.Autoloader.php';
     new Autoloader();
     $this->adminPassAsMD5 = md5($this->mysqlConfig[2]);
     DB::connect($this->mysqlConfig[0], $this->mysqlConfig[1], $this->mysqlConfig[2], $this->mysqlConfig[3]);
     AccountHandler::createNewNoLoginUser();
 }
<div class="w50" id="login-window">
	<form action="login.php?chpw=<?php 
echo $_GET['chpw'];
?>
" method="post">

<?php 
$errors = AccountHandler::tryToSetNewPassword();
$user = AccountHandler::getUsernameForChangePasswordHash();
?>

		<fieldset>
			<legend><?php 
_e('Set new password');
?>
</legend>
		<?php 
if ($user) {
    ?>
			<input type="hidden" name="chpw_hash" value="<?php 
    echo $_GET['chpw'];
    ?>
">
			<input type="hidden" name="chpw_username" value="<?php 
    echo $user;
    ?>
">
			<div class="w100">
				<label for="chpw_name"><?php 
    _e('Username');
    ?>