<commit_before><?php
# security protection
defined('_we_are_one') || die('Direct access not allowed.');

function switcher($page, $loggedin)
{
    try {
        switch($page) {
            case 'deposit':
            case 'place_order':
            case 'profile':
            case 'turn_on_duo':
            case 'view_order':
            case 'view_request':
            case 'withdraw':
                if ($loggedin)
                    include("$page.php");
                else
                    log_badpage($page);
                break;

            case 'login':
                if (!$loggedin)
                    include("login.php");
                else
                    log_badpage($page);
                break;

            case '404':
            case 'help':
            case 'orderbook':
            case 'test':
            case 'trade':
                include("$page.php");
                break;  

            default:
                log_badpage($page);
                break;
        }
    } 
    catch (Error $e) {
        report_exception($e, SEVERITY::ERROR);
        # Same as below, but flag + log this for review,
        echo "<div class='content_box'><h3>{$e->getTitle()}</h3>";
        echo "<p>{$e->getMessage()}</p></div>";
    }
    catch (Problem $e) {
        echo "<div class='content_box'><h3>{$e->getTitle()}</h3>";
        echo "<p>{$e->getMessage()}</p></div>";
    }
    catch (Exception $e) {
        echo "<div class='content_box'><h3>Technical difficulties</h3>";
        echo "<p>{$e->getMessage()}</p></div>";
    }
}
?><commit_msg>Use the per-user locking functions to stop double-spends, double-withdraws, etc.<commit_after><?php
# security protection
defined('_we_are_one') || die('Direct access not allowed.');

function switcher($page, $loggedin)
{
    try {
        $fp = false;
        if ($loggedin) $fp = get_lock();

        switch($page) {
            case 'deposit':
            case 'place_order':
            case 'profile':
            case 'turn_on_duo':
            case 'view_order':
            case 'view_request':
            case 'withdraw':
                if ($loggedin)
                    include("$page.php");
                else
                    log_badpage($page);
                break;

            case 'login':
                if (!$loggedin)
                    include("login.php");
                else
                    log_badpage($page);
                break;

            case '404':
            case 'help':
            case 'orderbook':
            case 'test':
            case 'trade':
                include("$page.php");
                break;  

            default:
                log_badpage($page);
                break;
        }
    } 
    catch (Error $e) {
        report_exception($e, SEVERITY::ERROR);
        # Same as below, but flag + log this for review,
        echo "<div class='content_box'><h3>{$e->getTitle()}</h3>";
        echo "<p>{$e->getMessage()}</p></div>";
    }
    catch (Problem $e) {
        echo "<div class='content_box'><h3>{$e->getTitle()}</h3>";
        echo "<p>{$e->getMessage()}</p></div>";
    }
    catch (Exception $e) {
        echo "<div class='content_box'><h3>Technical difficulties</h3>";
        echo "<p>{$e->getMessage()}</p></div>";
    }

    if ($fp) release_lock($fp);
}
?>
{'fraction_non_alphanumeric': 0.1569332135369871, 'fraction_numerical': 0.005390835579514825, 'mean_word_length': 1.4685883222468588, 'pattern_counts': {'":': 0, '<': 41, '<?xml version=': 0, '>': 51, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, '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': '2039723', 'n_tokens_mistral': 986, 'n_tokens_neox': 946, 'n_words': 202}