Example #1
0
function sec_login()
{
    global $lng, $settings;
    $_URL_forgotpass = "******";
    if (isset($_GET['forgotpass'])) {
        if (!isset($_POST['_retry'])) {
            title($lng->getTrn('login/forgotpass'));
        }
        if (isset($_GET['cid']) && isset($_GET['activation_code'])) {
            $c = new Coach((int) $_GET['cid']);
            status($new_passwd = $c->confirmActivation($_GET['activation_code']));
            echo "<br><br>";
            echo $lng->getTrn('login/temppasswd') . " <b>{$new_passwd}</b><br>\n";
            echo '<a href="' . urlcompile(T_URL_PROFILE, T_OBJ_COACH, $_GET['cid'], false, false) . '&amp;subsec=profile">' . $lng->getTrn('login/setnewpasswd') . '.</a>';
        } else {
            if (isset($_POST['coach_AC']) && isset($_POST['email'])) {
                $cid = get_alt_col('coaches', 'name', $_POST['coach_AC'], 'coach_id');
                $c = new Coach($cid);
                $correct_user = $c->mail == $_POST['email'];
                status($correct_user, $correct_user ? '' : $lng->getTrn('login/mismatch'));
                if ($correct_user) {
                    $c->requestPasswdReset();
                    echo "<br><br>";
                    echo $lng->getTrn('login/resetpasswdmail') . '.';
                } else {
                    // Return to same page.
                    unset($_POST['coach']);
                    unset($_POST['email']);
                    $_POST['_retry'] = true;
                    sec_login();
                }
            } else {
                ?>
            <div class='boxCommon'>
                <h3 class='boxTitle<?php 
                echo T_HTMLBOX_COACH;
                ?>
'><?php 
                echo $lng->getTrn('login/forgotpass');
                ?>
</h3>
                <div class='boxBody'>
                <form method="POST" action="<?php 
                echo $_URL_forgotpass;
                ?>
">
                    <?php 
                echo $lng->getTrn('login/loginname');
                ?>
<br>
                    <input type="text" name="coach_AC" size="20" maxlength="50">
                    <br><br>
                    Email<br>
                    <input type="text" name="email" size="20" maxlength="50">
                    <br><br>
                    <input type="submit" name="reqAC" value="<?php 
                echo $lng->getTrn('common/submit');
                ?>
">
                </form>
                </div>
            </div>
            <?php 
            }
        }
    } else {
        title($lng->getTrn('menu/login'));
        ?>
        <div class='boxCommon'>
            <h3 class='boxTitle<?php 
        echo T_HTMLBOX_COACH;
        ?>
'><?php 
        echo $lng->getTrn('menu/login');
        ?>
</h3>
            <div class='boxBody'>
            <form method="POST" action="<?php 
        echo getFormAction('');
        ?>
">
                <?php 
        echo $lng->getTrn('login/loginname');
        ?>
<br>
                <input type="text" name="coach" size="20" maxlength="50"><br><br>
                <?php 
        echo $lng->getTrn('login/passwd');
        ?>
<br>
                <input type="password" name="passwd" size="20" maxlength="50">
                <div style='display: none;'><input type='text' name='hackForHittingEnterToLogin' size='1'></div>
                <br><br>
                <?php 
        echo $lng->getTrn('login/remember');
        ?>
                <input type='checkbox' name='remember' value='1'>
                <br><br>
                <input type="submit" name="login" value="<?php 
        echo $lng->getTrn('login/loginbutton');
        ?>
">
            </form>
            <br><br>
            <?php 
        if (!Mobile::isMobile()) {
            if (Module::isRegistered('Registration') && $settings['allow_registration']) {
                echo "<a href='handler.php?type=registration'><b>Register</b></a>";
            }
            echo "<br><br>";
            echo "<a href='{$_URL_forgotpass}'><b>" . $lng->getTrn('login/forgotpass') . '</b></a>';
        }
        ?>
            </div>
        </div>
        <?php 
    }
}