public function send_http_headers()
 {
     #session_start();
     parent::send_http_headers();
     #print_r($_SESSION); exit;
     if (Oedipus_LogInHelper::is_logged_in()) {
         Oedipus_LogInHelper::log_in(Oedipus_LogInHelper::get_current_user_id());
     } else {
         Oedipus_LogInHelper::set_desired_restricted_page_url_to_current_location();
         Oedipus_LogInHelper::redirect_to_log_in_page();
     }
     #print_r($this); exit;
 }
 public function send_http_headers()
 {
     /**
      * Copied this from Oedipus_RestrictedPage
      *
      * But now it only logs you in again (or redirects)
      * if the drama is private or you're already
      * logged in
      */
     parent::send_http_headers();
     if ($this->get_drama()->is_private() || Oedipus_LogInHelper::is_logged_in()) {
         if (Oedipus_LogInHelper::is_logged_in()) {
             Oedipus_LogInHelper::log_in(Oedipus_LogInHelper::get_current_user_id());
         } else {
             Oedipus_LogInHelper::set_desired_restricted_page_url_to_current_location();
             Oedipus_LogInHelper::redirect_to_log_in_page();
         }
     }
 }
    public function attempt_login()
    {
        self::unset_form_session();
        Oedipus_LoginPage::reset_session_form();
        $_SESSION['values']['email'] = $_POST['email'];
        $email = $_POST['email'];
        $password = md5($_POST['password']);
        $dbh = $this->get_dbh();
        $email = mysql_real_escape_string($email, $dbh);
        $query = <<<SQL
SELECT
\tid
FROM
\toedipus_users
WHERE
\temail = '{$email}'
\tAND
\tpassword = '******'
SQL;
        #echo $query; exit;
        $result = mysql_query($query, $dbh);
        if ($row = mysql_fetch_array($result)) {
            #print_r($row); exit;
            $user_id = $row['id'];
            self::unset_form_session();
            /*
             * Log in.
             */
            Oedipus_LogInHelper::log_in($user_id);
            #return '/Oedipus_MemberPage';
            if (Oedipus_LogInHelper::desired_restricted_page_url_is_set()) {
                return Oedipus_LogInHelper::get_desired_restricted_page_url();
            } else {
                return Oedipus_UsersHelper::get_users_page_url($user_id);
            }
        } else {
            #echo "No row found\n"; exit;
            $_SESSION['errors']['login']['class'] = 'error';
            $_SESSION['errors']['login']['message'] = "Unable to log in.";
            #return '/Oedipus_LoginPage';
            return Oedipus_LogInHelper::get_log_in_page_url();
        }
    }
    public function render_body_div_account_status()
    {
        echo '<div id="account_status">' . "\n";
        if (isset($_SESSION['logged-in-id'])) {
            //
            // Why do you havve to log in again everytime?
            //
            Oedipus_LogInHelper::log_in($_SESSION['logged-in-id']);
            $user_id = Oedipus_LogInHelper::get_current_user_id();
            $user = Oedipus_UsersHelper::get_user($user_id);
            echo '<ul>';
            echo '<li>';
            echo '<a href="/Oedipus_UserPage">';
            echo stripcslashes($user['email']);
            echo '</a>';
            echo '</li>';
            echo "\n";
            ?>
<li>
<a href="/Oedipus_LogOutRequest">Log out</a>
</li>
<?php 
        } else {
            ?>
<ul>
<li>
<a href="/Oedipus_RegisterPage">Register</a>
</li>

<li>
<a href="/Oedipus_LoginPage">Log in</a>
</li>
<?php 
        }
        echo '</ul>' . "\n";
        echo '</div>' . "\n";
    }