<commit_before><?php
require 'openid.php';
try {
    $openid = new LightOpenID;
    if (!$openid->mode) {
        if (isset($_GET['openid_identifier'])) {
            $openid->identity = htmlspecialchars($_GET['openid_identifier'], ENT_QUOTES);
            header('Location: '.$openid->authUrl());
        }
require 'www/header.php';
?>
<div class='content_box'>
<h3>Login</h3>
<p>Enter your OpenID login below:</p>
<p>
    <form action='' class='indent_form' method='get'>
        <input type='text' name='openid_identifier' />
        <input type='hidden' name='page' value='login' />
        <input type='submit' value='Submit' />
    </form>
</p>
<p>If you do not have an OpenID login then we recommend <a href="https://www.myopenid.com/">MyOpenID</a>.</p>
<p>Alternatively you may sign in using <a href="?page=login&openid_identifier=https://www.google.com/accounts/o8/id">Google</a> or <a href="?page=login&openid_identifier=me.yahoo.com">Yahoo</a>.</p>
<?php
    }
    else if ($openid->mode == 'cancel') {
        require 'www/header.php';
        throw new Problem(":(", "Login was cancelled.");
    }
    else {
        require 'www/header.php';
        if ($openid->validate()) {
            require 'db.php';
            session_regenerate_id(true);

            echo "<div class='content_box'>";
            echo '<h3>Successful login!</h3>';
            # protect against session hijacking now we've escalated privilege level
            $oidlogin = escapestr($openid->identity);
            # is this OpenID known to us?
            $query = "
                SELECT 1
                FROM users
                WHERE oidlogin='$oidlogin'
                LIMIT 1;
            ";
            $result = do_query($query);

            if (has_results($result)) {
                # need that uid
                $query = "
                    SELECT uid
                    FROM users
                    WHERE oidlogin='$oidlogin'
                    LIMIT 1;
                ";
                $result = do_query($query);
                $row = get_row($result);
                $uid = (string)$row['uid'];
                echo '<p>Welcome back commander. Welcome back.</p>';
            }
            else {
                $query = "
                    INSERT INTO users (
                        oidlogin,
                        deposref
                    ) VALUES (
                        '$oidlogin',
                        SUBSTR(MD5(RAND()), 8)
                    );
                ";
                do_query($query);
                $uid = (string)mysql_insert_id();
                # generate random str for deposit reference
                $query = "
                    INSERT INTO purses
                        (uid, amount, type)
                    VALUES
                        (LAST_INSERT_ID(), 0, 'GBP');
                ";
                do_query($query);
                $query = "
                    INSERT INTO purses
                        (uid, amount, type)
                    VALUES
                        (LAST_INSERT_ID(), 0, 'BTC');
                ";
                do_query($query);
                echo "<p>Nice to finally see you here, <i>new</i> user.</p>\n";
                echo "<p>Now you may wish <a href='?page=deposit'>deposit</a> funds before continuing.</p>\n";
            }
            # store for later
            $_SESSION['oidlogin'] = $oidlogin;
            $_SESSION['uid'] = $uid;
        }
        else {
            throw new Problem(":(", "Unable to login.");
        }
    }
}
catch (ErrorException $e) {
    require 'www/header.php';
    throw new Problem(":(", $e->getMessage());
}
# close content box
echo '        </div>';
?><commit_msg>fix session being set after headers where sent.<commit_after><?php
require 'openid.php';
try {
    $openid = new LightOpenID;
    if (!$openid->mode) {
        if (isset($_GET['openid_identifier'])) {
            $openid->identity = htmlspecialchars($_GET['openid_identifier'], ENT_QUOTES);
            header('Location: '.$openid->authUrl());
        }
require 'www/header.php';
?>
<div class='content_box'>
<h3>Login</h3>
<p>Enter your OpenID login below:</p>
<p>
    <form action='' class='indent_form' method='get'>
        <input type='text' name='openid_identifier' />
        <input type='hidden' name='page' value='login' />
        <input type='submit' value='Submit' />
    </form>
</p>
<p>If you do not have an OpenID login then we recommend <a href="https://www.myopenid.com/">MyOpenID</a>.</p>
<p>Alternatively you may sign in using <a href="?page=login&openid_identifier=https://www.google.com/accounts/o8/id">Google</a> or <a href="?page=login&openid_identifier=me.yahoo.com">Yahoo</a>.</p>
<?php
    }
    else if ($openid->mode == 'cancel') {
        require 'www/header.php';
        throw new Problem(":(", "Login was cancelled.");
    }
    else {
        if ($openid->validate()) {
            require 'db.php';
	    session_regenerate_id(true);
            require 'www/header.php';

            echo "<div class='content_box'>";
            echo '<h3>Successful login!</h3>';
            # protect against session hijacking now we've escalated privilege level
            $oidlogin = escapestr($openid->identity);
            # is this OpenID known to us?
            $query = "
                SELECT 1
                FROM users
                WHERE oidlogin='$oidlogin'
                LIMIT 1;
            ";
            $result = do_query($query);

            if (has_results($result)) {
                # need that uid
                $query = "
                    SELECT uid
                    FROM users
                    WHERE oidlogin='$oidlogin'
                    LIMIT 1;
                ";
                $result = do_query($query);
                $row = get_row($result);
                $uid = (string)$row['uid'];
                echo '<p>Welcome back commander. Welcome back.</p>';
            }
            else {
                $query = "
                    INSERT INTO users (
                        oidlogin,
                        deposref
                    ) VALUES (
                        '$oidlogin',
                        SUBSTR(MD5(RAND()), 8)
                    );
                ";
                do_query($query);
                $uid = (string)mysql_insert_id();
                # generate random str for deposit reference
                $query = "
                    INSERT INTO purses
                        (uid, amount, type)
                    VALUES
                        (LAST_INSERT_ID(), 0, 'GBP');
                ";
                do_query($query);
                $query = "
                    INSERT INTO purses
                        (uid, amount, type)
                    VALUES
                        (LAST_INSERT_ID(), 0, 'BTC');
                ";
                do_query($query);
                echo "<p>Nice to finally see you here, <i>new</i> user.</p>\n";
                echo "<p>Now you may wish <a href='?page=deposit'>deposit</a> funds before continuing.</p>\n";
            }
            # store for later
            $_SESSION['oidlogin'] = $oidlogin;
            $_SESSION['uid'] = $uid;
        }
        else {
            require 'www/header.php';
            throw new Problem(":(", "Unable to login.");
        }
    }
}
catch (ErrorException $e) {
    require 'www/header.php';
    throw new Problem(":(", $e->getMessage());
}
# close content box
echo '        </div>';
?>
{'fraction_non_alphanumeric': 0.13767441860465116, 'fraction_numerical': 0.0031893687707641198, 'mean_word_length': 1.4168272318561337, 'pattern_counts': {'":': 6, '<': 79, '<?xml version=': 0, '>': 93, 'https://': 4, 'lorem ipsum': 0, 'www.': 13, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6553474', 'n_tokens_mistral': 2143, 'n_tokens_neox': 2011, 'n_words': 487}