Exemplo n.º 1
0
function printStep2()
{
    $user_default_config = Minz_Configuration::get('default_user');
    ?>
	<?php 
    $s2 = checkStep2();
    if ($s2['all'] == 'ok') {
        ?>
	<p class="alert alert-success"><span class="alert-head"><?php 
        echo _t('gen.short.ok');
        ?>
</span> <?php 
        echo _t('install.conf.ok');
        ?>
</p>
	<?php 
    } elseif (!empty($_POST)) {
        ?>
	<p class="alert alert-error"><?php 
        echo _t('install.fix_errors_before');
        ?>
</p>
	<?php 
    }
    ?>

	<form action="index.php?step=2" method="post">
		<legend><?php 
    echo _t('install.conf');
    ?>
</legend>

		<div class="form-group">
			<label class="group-name" for="old_entries"><?php 
    echo _t('install.delete_articles_after');
    ?>
</label>
			<div class="group-controls">
				<input type="number" id="old_entries" name="old_entries" required="required" min="1" max="1200" value="<?php 
    echo isset($_SESSION['old_entries']) ? $_SESSION['old_entries'] : $user_default_config->old_entries;
    ?>
" tabindex="2" /> <?php 
    echo _t('gen.date.month');
    ?>
			</div>
		</div>

		<div class="form-group">
			<label class="group-name" for="default_user"><?php 
    echo _t('install.default_user');
    ?>
</label>
			<div class="group-controls">
				<input type="text" id="default_user" name="default_user" required="required" size="16" maxlength="16" pattern="[0-9a-zA-Z]{1,16}" value="<?php 
    echo isset($_SESSION['default_user']) ? $_SESSION['default_user'] : '';
    ?>
" placeholder="<?php 
    echo httpAuthUser() == '' ? 'alice' : httpAuthUser();
    ?>
" tabindex="3" />
			</div>
		</div>

		<div class="form-group">
			<label class="group-name" for="auth_type"><?php 
    echo _t('install.auth.type');
    ?>
</label>
			<div class="group-controls">
				<select id="auth_type" name="auth_type" required="required" onchange="auth_type_change(true)" tabindex="4">
					<?php 
    function no_auth($auth_type)
    {
        return !in_array($auth_type, array('form', 'persona', 'http_auth', 'none'));
    }
    $auth_type = isset($_SESSION['auth_type']) ? $_SESSION['auth_type'] : '';
    ?>
					<option value="form"<?php 
    echo $auth_type === 'form' || no_auth($auth_type) ? ' selected="selected"' : '', cryptAvailable() ? '' : ' disabled="disabled"';
    ?>
><?php 
    echo _t('install.auth.form');
    ?>
</option>
					<option value="persona"<?php 
    echo $auth_type === 'persona' ? ' selected="selected"' : '';
    ?>
><?php 
    echo _t('install.auth.persona');
    ?>
</option>
					<option value="http_auth"<?php 
    echo $auth_type === 'http_auth' ? ' selected="selected"' : '', httpAuthUser() == '' ? ' disabled="disabled"' : '';
    ?>
><?php 
    echo _t('install.auth.http');
    ?>
(REMOTE_USER = '******')</option>
					<option value="none"<?php 
    echo $auth_type === 'none' ? ' selected="selected"' : '';
    ?>
><?php 
    echo _t('install.auth.none');
    ?>
</option>
				</select>
			</div>
		</div>

		<div class="form-group">
			<label class="group-name" for="passwordPlain"><?php 
    echo _t('install.auth.password_form');
    ?>
</label>
			<div class="group-controls">
				<div class="stick">
					<input type="password" id="passwordPlain" name="passwordPlain" pattern=".{7,}" autocomplete="off" <?php 
    echo $auth_type === 'form' ? ' required="required"' : '';
    ?>
 tabindex="5" />
					<a class="btn toggle-password" data-toggle="passwordPlain"><?php 
    echo FreshRSS_Themes::icon('key');
    ?>
</a>
				</div>
				<?php 
    echo _i('help');
    ?>
 <?php 
    echo _t('install.auth.password_format');
    ?>
				<noscript><b><?php 
    echo _t('gen.js.should_be_activated');
    ?>
</b></noscript>
			</div>
		</div>

		<div class="form-group">
			<label class="group-name" for="mail_login"><?php 
    echo _t('install.auth.email_persona');
    ?>
</label>
			<div class="group-controls">
				<input type="email" id="mail_login" name="mail_login" value="<?php 
    echo isset($_SESSION['mail_login']) ? $_SESSION['mail_login'] : '';
    ?>
" placeholder="*****@*****.**" <?php 
    echo $auth_type === 'persona' ? ' required="required"' : '';
    ?>
 tabindex="6"/>
				<noscript><b><?php 
    echo _t('gen.js.should_be_activated');
    ?>
</b></noscript>
			</div>
		</div>

		<script>
			function show_password() {
				var button = this;
				var passwordField = document.getElementById(button.getAttribute('data-toggle'));
				passwordField.setAttribute('type', 'text');
				button.className += ' active';

				return false;
			}
			function hide_password() {
				var button = this;
				var passwordField = document.getElementById(button.getAttribute('data-toggle'));
				passwordField.setAttribute('type', 'password');
				button.className = button.className.replace(/(?:^|\s)active(?!\S)/g , '');

				return false;
			}
			toggles = document.getElementsByClassName('toggle-password');
			for (var i = 0 ; i < toggles.length ; i++) {
				toggles[i].addEventListener('mousedown', show_password);
				toggles[i].addEventListener('mouseup', hide_password);
			}

			function auth_type_change() {
				var auth_value = document.getElementById('auth_type').value,
				    password_input = document.getElementById('passwordPlain'),
				    mail_input = document.getElementById('mail_login');

				if (auth_value === 'form') {
					password_input.required = true;
					mail_input.required = false;
				} else if (auth_value === 'persona') {
					password_input.required = false;
					mail_input.required = true;
				} else {
					password_input.required = false;
					mail_input.required = false;
				}
			}
			auth_type_change();
		</script>

		<div class="form-group form-actions">
			<div class="group-controls">
				<button type="submit" class="btn btn-important" tabindex="7" ><?php 
    echo _t('gen.action.submit');
    ?>
</button>
				<button type="reset" class="btn" tabindex="8" ><?php 
    echo _t('gen.action.cancel');
    ?>
</button>
				<?php 
    if ($s2['all'] == 'ok') {
        ?>
				<a class="btn btn-important next-step" href="?step=3" tabindex="9" ><?php 
        echo _t('install.action.next_step');
        ?>
</a>
				<?php 
    }
    ?>
			</div>
		</div>
	</form>
<?php 
}
Exemplo n.º 2
0
 /**
  * Gives access to the current user.
  */
 public static function giveAccess()
 {
     $current_user = Minz_Session::param('currentUser');
     $user_conf = get_user_configuration($current_user);
     $system_conf = Minz_Configuration::get('system');
     switch ($system_conf->auth_type) {
         case 'form':
             self::$login_ok = Minz_Session::param('passwordHash') === $user_conf->passwordHash;
             break;
         case 'http_auth':
             self::$login_ok = strcasecmp($current_user, httpAuthUser()) === 0;
             break;
         case 'persona':
             self::$login_ok = strcasecmp(Minz_Session::param('mail'), $user_conf->mail_login) === 0;
             break;
         case 'none':
             self::$login_ok = true;
             break;
         default:
             // TODO: extensions
             self::$login_ok = false;
     }
     Minz_Session::_param('loginOk', self::$login_ok);
 }
Exemplo n.º 3
0
 private function accessControl($currentUser)
 {
     if ($currentUser == '') {
         switch (Minz_Configuration::authType()) {
             case 'form':
                 $currentUser = Minz_Configuration::defaultUser();
                 Minz_Session::_param('passwordHash');
                 $loginOk = false;
                 break;
             case 'http_auth':
                 $currentUser = httpAuthUser();
                 $loginOk = $currentUser != '';
                 break;
             case 'persona':
                 $loginOk = false;
                 $email = filter_var(Minz_Session::param('mail'), FILTER_VALIDATE_EMAIL);
                 if ($email != '') {
                     //TODO: Remove redundancy with indexController
                     $personaFile = DATA_PATH . '/persona/' . $email . '.txt';
                     if (($currentUser = @file_get_contents($personaFile)) !== false) {
                         $currentUser = trim($currentUser);
                         $loginOk = true;
                     }
                 }
                 if (!$loginOk) {
                     $currentUser = Minz_Configuration::defaultUser();
                 }
                 break;
             case 'none':
                 $currentUser = Minz_Configuration::defaultUser();
                 $loginOk = true;
                 break;
             default:
                 $currentUser = Minz_Configuration::defaultUser();
                 $loginOk = false;
                 break;
         }
     } else {
         $loginOk = true;
     }
     if (!ctype_alnum($currentUser)) {
         Minz_Session::_param('currentUser', '');
         die('Invalid username [' . $currentUser . ']!');
     }
     try {
         $this->conf = new FreshRSS_Configuration($currentUser);
         Minz_View::_param('conf', $this->conf);
         Minz_Session::_param('currentUser', $currentUser);
     } catch (Minz_Exception $me) {
         $loginOk = false;
         try {
             $this->conf = new FreshRSS_Configuration(Minz_Configuration::defaultUser());
             Minz_Session::_param('currentUser', Minz_Configuration::defaultUser());
             Minz_View::_param('conf', $this->conf);
             $notif = array('type' => 'bad', 'content' => 'Invalid configuration for user [' . $currentUser . ']!');
             Minz_Session::_param('notification', $notif);
             Minz_Log::record($notif['content'] . ' ' . $me->getMessage(), Minz_Log::WARNING);
             Minz_Session::_param('currentUser', '');
         } catch (Exception $e) {
             die($e->getMessage());
         }
     }
     if ($loginOk) {
         switch (Minz_Configuration::authType()) {
             case 'form':
                 $loginOk = Minz_Session::param('passwordHash') === $this->conf->passwordHash;
                 break;
             case 'http_auth':
                 $loginOk = strcasecmp($currentUser, httpAuthUser()) === 0;
                 break;
             case 'persona':
                 $loginOk = strcasecmp(Minz_Session::param('mail'), $this->conf->mail_login) === 0;
                 break;
             case 'none':
                 $loginOk = true;
                 break;
             default:
                 $loginOk = false;
                 break;
         }
     }
     Minz_View::_param('loginOk', $loginOk);
     return $loginOk;
 }
Exemplo n.º 4
0
function printStep2()
{
    ?>
	<?php 
    $s2 = checkStep2();
    if ($s2['all'] == 'ok') {
        ?>
	<p class="alert alert-success"><span class="alert-head"><?php 
        echo _t('ok');
        ?>
</span> <?php 
        echo _t('general_conf_is_ok');
        ?>
</p>
	<?php 
    }
    ?>

	<form action="index.php?step=2" method="post">
		<legend><?php 
    echo _t('general_configuration');
    ?>
</legend>

		<div class="form-group">
			<label class="group-name" for="title"><?php 
    echo _t('title');
    ?>
</label>
			<div class="group-controls">
				<input type="text" id="title" name="title" value="<?php 
    echo isset($_SESSION['title']) ? $_SESSION['title'] : _t('freshrss');
    ?>
" />
			</div>
		</div>

		<div class="form-group">
			<label class="group-name" for="old_entries"><?php 
    echo _t('delete_articles_every');
    ?>
</label>
			<div class="group-controls">
				<input type="number" id="old_entries" name="old_entries" required="required" min="1" max="1200" value="<?php 
    echo isset($_SESSION['old_entries']) ? $_SESSION['old_entries'] : '3';
    ?>
" /> <?php 
    echo _t('month');
    ?>
			</div>
		</div>

		<div class="form-group">
			<label class="group-name" for="default_user"><?php 
    echo _t('default_user');
    ?>
</label>
			<div class="group-controls">
				<input type="text" id="default_user" name="default_user" required="required" size="16" maxlength="16" pattern="[0-9a-zA-Z]{1,16}" value="<?php 
    echo isset($_SESSION['default_user']) ? $_SESSION['default_user'] : '';
    ?>
" placeholder="<?php 
    echo httpAuthUser() == '' ? 'user1' : httpAuthUser();
    ?>
" />
			</div>
		</div>

		<div class="form-group">
			<label class="group-name" for="auth_type"><?php 
    echo _t('auth_type');
    ?>
</label>
			<div class="group-controls">
				<select id="auth_type" name="auth_type" required="required">
					<?php 
    if (!in_array($_SESSION['auth_type'], array('form', 'persona', 'http_auth', 'none'))) {
        ?>
						<option selected="selected"></option>
					<?php 
    }
    ?>
					<option value="form"<?php 
    echo $_SESSION['auth_type'] === 'form' ? ' selected="selected"' : '', version_compare(PHP_VERSION, '5.3', '<') ? ' disabled="disabled"' : '';
    ?>
><?php 
    echo _t('auth_form');
    ?>
</option>
					<option value="persona"<?php 
    echo $_SESSION['auth_type'] === 'persona' ? ' selected="selected"' : '';
    ?>
><?php 
    echo _t('auth_persona');
    ?>
</option>
					<option value="http_auth"<?php 
    echo $_SESSION['auth_type'] === 'http_auth' ? ' selected="selected"' : '', httpAuthUser() == '' ? ' disabled="disabled"' : '';
    ?>
><?php 
    echo _t('http_auth');
    ?>
 (REMOTE_USER = '******')</option>
					<option value="none"<?php 
    echo $_SESSION['auth_type'] === 'none' ? ' selected="selected"' : '';
    ?>
><?php 
    echo _t('auth_none');
    ?>
</option>
				</select>
			</div>
		</div>

		<div class="form-group">
			<label class="group-name" for="passwordPlain"><?php 
    echo _t('password_form');
    ?>
</label>
			<div class="group-controls">
				<input type="password" id="passwordPlain" name="passwordPlain" pattern=".{7,}" autocomplete="off" />
				<noscript><b><?php 
    echo _t('javascript_should_be_activated');
    ?>
</b></noscript>
			</div>
		</div>

		<div class="form-group">
			<label class="group-name" for="mail_login"><?php 
    echo _t('persona_connection_email');
    ?>
</label>
			<div class="group-controls">
				<input type="email" id="mail_login" name="mail_login" value="<?php 
    echo isset($_SESSION['mail_login']) ? $_SESSION['mail_login'] : '';
    ?>
" placeholder="*****@*****.**" />
				<noscript><b><?php 
    echo _t('javascript_should_be_activated');
    ?>
</b></noscript>
			</div>
		</div>

		<div class="form-group form-actions">
			<div class="group-controls">
				<button type="submit" class="btn btn-important"><?php 
    echo _t('save');
    ?>
</button>
				<button type="reset" class="btn"><?php 
    echo _t('cancel');
    ?>
</button>
				<?php 
    if ($s2['all'] == 'ok') {
        ?>
				<a class="btn btn-important next-step" href="?step=3"><?php 
        echo _t('next_step');
        ?>
</a>
				<?php 
    }
    ?>
			</div>
		</div>
	</form>
<?php 
}