Ejemplo n.º 1
0
// @todo delete when release
error_reporting(E_ALL);
ini_set('display_errors', 1);
require 'constants.php';
require CLASS_PATH . SMARTY_CON_PATH;
require 'display_functions.php';
require 'complete_functions.php';
require CLASS_PATH . 'class.mysql.connection.php';
//main db connection
$db = new mysql_connection('localhost', 'julia_usr', 'YsvQz8SfV9', 'julia');
//$db_connection = connect_to_db('localhost', 'paul_dbo', 'BN6uMqvPyv', 'paul');
//main smarty instance
$smarty = new smarty_connect();
$smarty->debugging_ctrl = $_SERVER['SERVER_NAME'] == 'localhost' ? 'URL' : 'NONE';
if (isset($_GET['site']) && $_GET['site'] == 'complete_login') {
    complete_login();
    return true;
} elseif (isset($_GET['site']) && $_GET['site'] == 'complete_logout') {
    complete_logout();
    return true;
}
if (!isset($_SESSION['customer_id']) || !isset($_GET['site'])) {
    $smarty->display('login.tpl');
    return true;
}
display_visitor_info();
parse_messages();
switch ($_GET['site']) {
    case 'jobs':
        display_jobs();
        break;
Ejemplo n.º 2
0
                        $user = Users\UserOpenID::tryLogin(db(), $openid, absolute_url(url_for('login', $args)));
                    } else {
                        if ($email && $password) {
                            // email/password login
                            $user = Users\UserPassword::tryLogin(db(), $email, $password);
                        }
                    }
                }
            } catch (UserAuthenticationMissingAccountException $e) {
                $errors[] = $e->getMessage() . " " . t("You may need to :signup.", array(':signup' => link_to(url_for('signup', array('openid' => $openid, 'email' => $email)), t("signup first"))));
            } catch (UserAuthenticationException $e) {
                $errors[] = $e->getMessage();
            }
            if ($user && !$errors) {
                $user->persist(db());
                complete_login($user, $autologin);
                // redirect
                if (!$destination) {
                    $destination = url_for(get_site_config('default_login'));
                }
                set_temporary_messages($messages);
                set_temporary_errors($errors);
                // possible injection here... strip all protocol information to prevent redirection to external site
                $destination = str_replace('#[a-z]+://#im', '', $destination);
                redirect($destination);
            }
        }
    }
} catch (Exception $e) {
    if (!$e instanceof EscapedException) {
        $e = new EscapedException(htmlspecialchars($e->getMessage()), (int) $e->getCode(), $e);
function custom_login_function()
{
    if (isset($_POST['submit'])) {
        login_validation($_POST['username'], $_POST['password']);
        // sanitize user form input
        global $username, $password;
        $username = sanitize_user($_POST['username']);
        $password = esc_attr($_POST['password']);
        // call @function complete_login to login
        // only when no WP_error is found
        complete_login($username, $password);
    }
    login_form($username, $password);
}