<?xml version="1.0" encoding="utf-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">
	<channel>
		<title><![CDATA[PunBB Forums — Improving login security]]></title>
		<link>https://punbb.informer.com/forums/topic/16668/improving-login-security/</link>
		<atom:link href="https://punbb.informer.com/forums/feed/rss/topic/16668/" rel="self" type="application/rss+xml" />
		<description><![CDATA[The most recent posts in Improving login security.]]></description>
		<lastBuildDate>Sat, 28 Jul 2007 16:34:29 +0000</lastBuildDate>
		<generator>PunBB</generator>
		<item>
			<title><![CDATA[Re: Improving login security]]></title>
			<link>https://punbb.informer.com/forums/post/98692/#p98692</link>
			<description><![CDATA[<p>You just send the hashed password in a different variable, it&#039;s a fairly common technique that I&#039;ve seen used in several apps <img src="https://punbb.informer.com/forums/img/smilies/wink.png" width="15" height="15" alt="wink" /></p>]]></description>
			<author><![CDATA[null@example.com (Smartys)]]></author>
			<pubDate>Sat, 28 Jul 2007 16:34:29 +0000</pubDate>
			<guid>https://punbb.informer.com/forums/post/98692/#p98692</guid>
		</item>
		<item>
			<title><![CDATA[Re: Improving login security]]></title>
			<link>https://punbb.informer.com/forums/post/98691/#p98691</link>
			<description><![CDATA[<p>In fact, actually when there is not Javascript activated, the form send passwords normally. <br />To detect the hashed passwords before the SQL check, I think it could be made by limit the password lenght&nbsp; (always &lt; of lenght hash)&nbsp; or by activating the $_SESSION variable in&nbsp; dependece of Javascript :<br />&lt;script&gt;<br />if (true) {<br /> &lt;? $_SESSION[&quot;t_parcial&quot;]=sha1(date(&quot;l dS of F Y h:i:s A&quot;));?&gt;<br />}<br />&lt;/script&gt;</p><p>the second one sounds more insecure, although allows some message to the visitor. If there is not session, then we can show some warning to the viistor.</p><p>Well,&nbsp; just a pair of ideas. I will try some of both <img src="https://punbb.informer.com/forums/img/smilies/smile.png" width="15" height="15" alt="smile" /></p>]]></description>
			<author><![CDATA[null@example.com (svo)]]></author>
			<pubDate>Sat, 28 Jul 2007 16:17:28 +0000</pubDate>
			<guid>https://punbb.informer.com/forums/post/98691/#p98691</guid>
		</item>
		<item>
			<title><![CDATA[Re: Improving login security]]></title>
			<link>https://punbb.informer.com/forums/post/98687/#p98687</link>
			<description><![CDATA[<p>Well, the function could be passed the form variable to hash <img src="https://punbb.informer.com/forums/img/smilies/wink.png" width="15" height="15" alt="wink" /></p>]]></description>
			<author><![CDATA[null@example.com (Smartys)]]></author>
			<pubDate>Sat, 28 Jul 2007 13:55:17 +0000</pubDate>
			<guid>https://punbb.informer.com/forums/post/98687/#p98687</guid>
		</item>
		<item>
			<title><![CDATA[Re: Improving login security]]></title>
			<link>https://punbb.informer.com/forums/post/98686/#p98686</link>
			<description><![CDATA[<p>that&#039;s a good idea <img src="https://punbb.informer.com/forums/img/smilies/smile.png" width="15" height="15" alt="smile" /></p><p>and maybe a function able to work with diferent form variables, because also there is the &quot;change password&quot; option in the Profile section.</p>]]></description>
			<author><![CDATA[null@example.com (svo)]]></author>
			<pubDate>Sat, 28 Jul 2007 13:16:14 +0000</pubDate>
			<guid>https://punbb.informer.com/forums/post/98686/#p98686</guid>
		</item>
		<item>
			<title><![CDATA[Re: Improving login security]]></title>
			<link>https://punbb.informer.com/forums/post/98685/#p98685</link>
			<description><![CDATA[<p>The easiest way would just be to add an onsubmit function that takes the value from password, hashes it, sticks it in hashed_password, and removes password.<br />That way, if hashed_password is set, we look there for a hash. If not, we look at password for the password. If there&#039;s Javascript, we have a hash, and if not there&#039;s no hash <img src="https://punbb.informer.com/forums/img/smilies/smile.png" width="15" height="15" alt="smile" /></p>]]></description>
			<author><![CDATA[null@example.com (Smartys)]]></author>
			<pubDate>Sat, 28 Jul 2007 12:52:19 +0000</pubDate>
			<guid>https://punbb.informer.com/forums/post/98685/#p98685</guid>
		</item>
		<item>
			<title><![CDATA[Re: Improving login security]]></title>
			<link>https://punbb.informer.com/forums/post/98684/#p98684</link>
			<description><![CDATA[<p>To avoid Javascript maybe there is some way to apply a hash before sending password. Perhaps in dependence of the Session unique id?&nbsp; <br />I don&#039;t know. If somebody want to polish this code or make somehting similar I would be glad to know. </p><p>** I have edited the message to add these two lines to keep clean the /tmp directory:</p><p>$_SESSION = array();<br />session_destroy();</p><p>regards,</p>]]></description>
			<author><![CDATA[null@example.com (svo)]]></author>
			<pubDate>Sat, 28 Jul 2007 12:45:31 +0000</pubDate>
			<guid>https://punbb.informer.com/forums/post/98684/#p98684</guid>
		</item>
		<item>
			<title><![CDATA[Re: Improving login security]]></title>
			<link>https://punbb.informer.com/forums/post/98682/#p98682</link>
			<description><![CDATA[<p>Not this idea specifically though. It is worth thinking about (and it should be easy to make it work for browsers with Javascript and without).</p>]]></description>
			<author><![CDATA[null@example.com (Smartys)]]></author>
			<pubDate>Sat, 28 Jul 2007 11:43:36 +0000</pubDate>
			<guid>https://punbb.informer.com/forums/post/98682/#p98682</guid>
		</item>
		<item>
			<title><![CDATA[Re: Improving login security]]></title>
			<link>https://punbb.informer.com/forums/post/98681/#p98681</link>
			<description><![CDATA[<p>Already done in 1.3, iirc.</p>]]></description>
			<author><![CDATA[null@example.com (Jérémie)]]></author>
			<pubDate>Sat, 28 Jul 2007 08:40:53 +0000</pubDate>
			<guid>https://punbb.informer.com/forums/post/98681/#p98681</guid>
		</item>
		<item>
			<title><![CDATA[Re: Improving login security]]></title>
			<link>https://punbb.informer.com/forums/post/98676/#p98676</link>
			<description><![CDATA[<p>A SHA1 hash could still be useful...</p>]]></description>
			<author><![CDATA[null@example.com (guardian34)]]></author>
			<pubDate>Sat, 28 Jul 2007 04:30:33 +0000</pubDate>
			<guid>https://punbb.informer.com/forums/post/98676/#p98676</guid>
		</item>
		<item>
			<title><![CDATA[Re: Improving login security]]></title>
			<link>https://punbb.informer.com/forums/post/98650/#p98650</link>
			<description><![CDATA[<div class="quotebox"><cite>svo wrote:</cite><blockquote><p>So here there is a way to apply a secure one-way password approach by using Javascript SHA1 and MD5 libraries.</p></blockquote></div><p>You can&#039;t use javascript to do anything important, because some UA don&#039;t have javascript (enable, or at all).</p><p>Anyway, I think security related suggestions and possible hole are supposed to be mailed to Rickard, to avoid giving idea to the script kiddies around.</p>]]></description>
			<author><![CDATA[null@example.com (Jérémie)]]></author>
			<pubDate>Fri, 27 Jul 2007 07:44:36 +0000</pubDate>
			<guid>https://punbb.informer.com/forums/post/98650/#p98650</guid>
		</item>
		<item>
			<title><![CDATA[Improving login security]]></title>
			<link>https://punbb.informer.com/forums/post/98649/#p98649</link>
			<description><![CDATA[<p>(Modification for version 1.2.14)</p><p>A security hole in PunBB exist when we enter user/password in login.php page. Both are travelling in a open way.:</p><p>&nbsp; &nbsp; POST /forums/login.php?action=in HTTP/1.1<br />&nbsp; &nbsp; Host: punbb.org<br />&nbsp; &nbsp; .....<br />&nbsp; &nbsp; req_username=myname<br />&nbsp; &nbsp; req_password=mypass<br />&nbsp; &nbsp; login=Login</p><br /><p>Database hashes becomes useless when&nbsp; there is not difficulty in capturing passwords in Intranet, etc. So here there is a way to apply a secure one-way password approach by using Javascript SHA1 and MD5 libraries.<br />In this way, password is ciphered in the client side: </p><p>&nbsp; &nbsp; POST /forums/login.php?action=in HTTP/1.1<br />&nbsp; &nbsp; Host: myhost.com<br />&nbsp; &nbsp; &nbsp; &nbsp; .....<br />&nbsp; &nbsp; req_username=myname<br />&nbsp; &nbsp; req_password=1538cbbd73ce4079230a93bb738b1867<br />&nbsp; &nbsp; login=Login</p><br /><p>When hash is never the same, it is a much better approach. Note DB hashes are useless when passwords are travelling in plain way.<br />Administrators must be aware of this.</p><br /><p>HOW TO IMPLEMENT: <br />------------------<br />Download sha1.js and md5.js. <br /><a href="http://pajhome.org.uk/crypt/md5/sha1src.html">http://pajhome.org.uk/crypt/md5/sha1src.html</a><br /><a href="http://pajhome.org.uk/crypt/md5/md5src.html">http://pajhome.org.uk/crypt/md5/md5src.html</a></p><p>Put both in the main PunBB folder, where is login.php page. </p><p>Make security backups of: <br />- header.php<br />- login.php</p><br /><br /><p>PAGE CHANGES: <br />------------</p><p>HEADER.PHP:</p><p>Find line: <br />&lt;?php $max=10; ?&gt;</p><p>...until line:<br />function process_form(the_form)</p><p>and between them, put this:</p><div class="codebox"><pre><code>&lt;?
/**** START ************************************************/    

// Hashing SHA1 or MD5
$urlogin = $_SERVER[&#039;REQUEST_URI&#039;]; 

if (preg_match(&#039;/login.php/i&#039;, $urlogin)) {    

    $sha1_available = (function_exists(&#039;sha1&#039;) || function_exists(&#039;mhash&#039;)) ? true : false;        

    if ($sha1_available) {
        $_SESSION[&quot;t_parcial&quot;]=sha1(date(&quot;l dS of F Y h:i:s A&quot;));        
        echo &#039;&lt;script src=&quot;sha1.js&quot;&gt;&lt;/script&gt;&#039;;
        $sha1ok = 1; 

    } else {
        $_SESSION[&quot;t_parcial&quot;]=md5(date(&quot;l dS of F Y h:i:s A&quot;));                
        echo &#039;&lt;script src=&quot;md5.js&quot;&gt;&lt;/script&gt;&#039;;
        $sha1ok = 0; 
    }    
}    

?&gt;

&lt;script type=&quot;text/javascript&quot;&gt;
&lt;!--
var max=&lt;?php echo $max; ?&gt;;
var randomValue1=Math.floor(Math.random()*max);
var randomValue2=Math.floor(Math.random()*max);
var theSum=randomValue1+randomValue2;
max*=2;

function upAndDown(the_form, sign){
    var theValue=the_form.elements[&quot;mathValue&quot;].value;
    if(sign==&quot;+&quot; &amp;&amp; theValue&lt;max) theValue++;
    else if(sign==&quot;-&quot; &amp;&amp; theValue&gt;0) theValue--;
    the_form.elements[&quot;mathValue&quot;].value=theValue;
}



&lt;?     

if ($sha1ok == 1) {     ?&gt;

function encrypt() {
    var sha1_pre=hex_sha1(document.login.req_password.value);
    var sha1=hex_sha1(sha1_pre+&quot;&lt;? echo sha1($_SESSION[&quot;t_parcial&quot;] .getenv(&quot;REMOTE_ADDR&quot;)); ?&gt;&quot;)
    document.login.req_password.value=sha1
}

&lt;?        
$eslogin = &#039;&#039;;
} else { ?&gt;

function encrypt() {
    var md5_pre=md5(document.login.req_password.value)
    var md5=hex_md5(md5_pre+&quot;&lt;? echo md5($_SESSION[&quot;t_parcial&quot;] .getenv(&quot;REMOTE_ADDR&quot;)); ?&gt;&quot;)
    document.login.req_password.value=md5
}

&lt;? 
    $eslogin = &#039;&#039;;
} 
?&gt;

/**** END ************************************************/</code></pre></div><p>LOGIN.PHP<br />Replace all code with this:</p><br /><div class="codebox"><pre><code>&lt;?php
/***********************************************************************

  Copyright (C) 2002-2005  Rickard Andersson (rickard@punbb.org)

  This file is part of PunBB.

  PunBB is free software; you can redistribute it and/or modify it
  under the terms of the GNU General Public License as published
  by the Free Software Foundation; either version 2 of the License,
  or (at your option) any later version.

  PunBB is distributed in the hope that it will be useful, but
  WITHOUT ANY WARRANTY; without even the implied warranty of
  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  GNU General Public License for more details.

  You should have received a copy of the GNU General Public License
  along with this program; if not, write to the Free Software
  Foundation, Inc., 59 Temple Place, Suite 330, Boston,
  MA  02111-1307  USA

************************************************************************/

if (isset($_GET[&#039;action&#039;])) {
    define(&#039;PUN_QUIET_VISIT&#039;, 1);
}

define(&#039;PUN_ROOT&#039;, &#039;./&#039;);
require PUN_ROOT.&#039;include/common.php&#039;;


// Load the login.php language file
require PUN_ROOT.&#039;lang/&#039;.$pun_user[&#039;language&#039;].&#039;/login.php&#039;;

$action = isset($_GET[&#039;action&#039;]) ? $_GET[&#039;action&#039;] : null;

if (isset($_POST[&#039;form_sent&#039;]) &amp;&amp; $action == &#039;in&#039;) {

    session_start();
    
            
    $form_username = trim($_POST[&#039;req_username&#039;]);
    $form_password = trim($_POST[&#039;req_password&#039;]);


    $username_sql = ($db_type == &#039;mysql&#039; || $db_type == &#039;mysqli&#039;) ? &#039;username=\&#039;&#039;.$db-&gt;escape($form_username).&#039;\&#039;&#039; : &#039;LOWER(username)=LOWER(\&#039;&#039;.$db-&gt;escape($form_username).&#039;\&#039;)&#039;;

    $result = $db-&gt;query(&#039;SELECT id, group_id, password, save_pass FROM &#039;.$db-&gt;prefix.&#039;users WHERE &#039;.$username_sql) or error(&#039;Unable to fetch user info&#039;, __FILE__, __LINE__, $db-&gt;error());
    list($user_id, $group_id, $db_password_hash, $save_pass) = $db-&gt;fetch_row($result);

    $authorized = false;

    if (!empty($db_password_hash))    {

        $sha1_in_db = (strlen($db_password_hash) == 40) ? true : false;
        $sha1_available = (function_exists(&#039;sha1&#039;) || function_exists(&#039;mhash&#039;)) ? true : false;

        if ($sha1_available)
            $t=sha1($_SESSION[&quot;t_parcial&quot;] .getenv(&quot;REMOTE_ADDR&quot;));
        else
          $t=md5($_SESSION[&quot;t_parcial&quot;].getenv(&quot;REMOTE_ADDR&quot;));
    

        if ($sha1_in_db &amp;&amp; $sha1_available &amp;&amp; sha1($db_password_hash.$t) == $form_password) 
            $authorized = true;
         else if (!$sha1_in_db &amp;&amp; md5($db_password_hash.$t) == $form_password)     
         {
            $authorized = true;

         }
        
     }

    if (!$authorized)  {
             $_SESSION = array();
        session_destroy();
        message($lang_login[&#039;Wrong user/pass&#039;].&#039; &lt;a href=&quot;login.php?action=forget&quot;&gt;&#039;.$xx.$lang_login[&#039;Forgotten pass&#039;].&#039;&lt;/a&gt;&#039;);
       }
    

    // Update the status if this is the first time the user logged in
    if ($group_id == PUN_UNVERIFIED) 
        $db-&gt;query(&#039;UPDATE &#039;.$db-&gt;prefix.&#039;users SET group_id=&#039;.$pun_config[&#039;o_default_user_group&#039;].&#039; WHERE id=&#039;.$user_id) or error(&#039;Unable to update user status&#039;, __FILE__, __LINE__, $db-&gt;error());
    

    // Remove this users guest entry from the online list
    $db-&gt;query(&#039;DELETE FROM &#039;.$db-&gt;prefix.&#039;online WHERE ident=\&#039;&#039;.$db-&gt;escape(get_remote_address()).&#039;\&#039;&#039;) or error(&#039;Unable to delete from online list&#039;, __FILE__, __LINE__, $db-&gt;error());
        
    $expire = ($save_pass == &#039;1&#039;) ? time() + 31536000 : 0;
    
    //pun_setcookie($user_id, $form_password_hash, $expire);  
    pun_setcookie($user_id, $db_password_hash, $expire);

       $_SESSION = array();
      session_destroy();
 
      redirect(htmlspecialchars($_POST[&#039;redirect_url&#039;]), $lang_login[&#039;Login redirect&#039;]);
    
}


else if ($action == &#039;out&#039;)
{
    if ($pun_user[&#039;is_guest&#039;] || !isset($_GET[&#039;id&#039;]) || $_GET[&#039;id&#039;] != $pun_user[&#039;id&#039;])
    {
        header(&#039;Location: index.php&#039;);
        exit;
    }

    // Remove user from &quot;users online&quot; list.
    $db-&gt;query(&#039;DELETE FROM &#039;.$db-&gt;prefix.&#039;online WHERE user_id=&#039;.$pun_user[&#039;id&#039;]) or error(&#039;Unable to delete from online list&#039;, __FILE__, __LINE__, $db-&gt;error());

    // Update last_visit (make sure there&#039;s something to update it with)
    if (isset($pun_user[&#039;logged&#039;]))
        $db-&gt;query(&#039;UPDATE &#039;.$db-&gt;prefix.&#039;users SET last_visit=&#039;.$pun_user[&#039;logged&#039;].&#039; WHERE id=&#039;.$pun_user[&#039;id&#039;]) or error(&#039;Unable to update user visit data&#039;, __FILE__, __LINE__, $db-&gt;error());

    pun_setcookie(1, random_pass(8), time() + 31536000);

    redirect(&#039;index.php&#039;, $lang_login[&#039;Logout redirect&#039;]);
}


else if ($action == &#039;forget&#039;)
{
    if (!$pun_user[&#039;is_guest&#039;])
        header(&#039;Location: index.php&#039;);

    if (isset($_POST[&#039;form_sent&#039;]))
    {
        require PUN_ROOT.&#039;include/email.php&#039;;

        // Validate the email-address
        $email = strtolower(trim($_POST[&#039;req_email&#039;]));
        if (!is_valid_email($email))
            message($lang_common[&#039;Invalid e-mail&#039;]);

        $result = $db-&gt;query(&#039;SELECT id, username FROM &#039;.$db-&gt;prefix.&#039;users WHERE email=\&#039;&#039;.$db-&gt;escape($email).&#039;\&#039;&#039;) or error(&#039;Unable to fetch user info&#039;, __FILE__, __LINE__, $db-&gt;error());

        if ($db-&gt;num_rows($result))
        {
            // Load the &quot;activate password&quot; template
            $mail_tpl = trim(file_get_contents(PUN_ROOT.&#039;lang/&#039;.$pun_user[&#039;language&#039;].&#039;/mail_templates/activate_password.tpl&#039;));

            // The first row contains the subject
            $first_crlf = strpos($mail_tpl, &quot;\n&quot;);
            $mail_subject = trim(substr($mail_tpl, 8, $first_crlf-8));
            $mail_message = trim(substr($mail_tpl, $first_crlf));

            // Do the generic replacements first (they apply to all e-mails sent out here)
            $mail_message = str_replace(&#039;&lt;base_url&gt;&#039;, $pun_config[&#039;o_base_url&#039;].&#039;/&#039;, $mail_message);
            $mail_message = str_replace(&#039;&lt;board_mailer&gt;&#039;, $pun_config[&#039;o_board_title&#039;].&#039; &#039;.$lang_common[&#039;Mailer&#039;], $mail_message);

            // Loop through users we found
            while ($cur_hit = $db-&gt;fetch_assoc($result))
            {
                // Generate a new password and a new password activation code
                $new_password = random_pass(8);
                $new_password_key = random_pass(8);

                $db-&gt;query(&#039;UPDATE &#039;.$db-&gt;prefix.&#039;users SET activate_string=\&#039;&#039;.pun_hash($new_password).&#039;\&#039;, activate_key=\&#039;&#039;.$new_password_key.&#039;\&#039; WHERE id=&#039;.$cur_hit[&#039;id&#039;]) or error(&#039;Unable to update activation data&#039;, __FILE__, __LINE__, $db-&gt;error());

                // Do the user specific replacements to the template
                $cur_mail_message = str_replace(&#039;&lt;username&gt;&#039;, $cur_hit[&#039;username&#039;], $mail_message);
                $cur_mail_message = str_replace(&#039;&lt;activation_url&gt;&#039;, $pun_config[&#039;o_base_url&#039;].&#039;/profile.php?id=&#039;.$cur_hit[&#039;id&#039;].&#039;&amp;action=change_pass&amp;key=&#039;.$new_password_key, $cur_mail_message);
                $cur_mail_message = str_replace(&#039;&lt;new_password&gt;&#039;, $new_password, $cur_mail_message);

                pun_mail($email, $mail_subject, $cur_mail_message);
            }

            message($lang_login[&#039;Forget mail&#039;].&#039; &lt;a href=&quot;mailto:&#039;.$pun_config[&#039;o_admin_email&#039;].&#039;&quot;&gt;&#039;.$pun_config[&#039;o_admin_email&#039;].&#039;&lt;/a&gt;.&#039;);
        }
        else
            message($lang_login[&#039;No e-mail match&#039;].&#039; &#039;.htmlspecialchars($email).&#039;.&#039;);
    }


    $page_title = pun_htmlspecialchars($pun_config[&#039;o_board_title&#039;]).&#039; / &#039;.$lang_login[&#039;Request pass&#039;];
    $required_fields = array(&#039;req_email&#039; =&gt; $lang_common[&#039;E-mail&#039;]);
    $focus_element = array(&#039;request_pass&#039;, &#039;req_email&#039;);
    require PUN_ROOT.&#039;header.php&#039;;




?&gt;
&lt;div class=&quot;blockform&quot;&gt;
    &lt;h2&gt;&lt;span&gt;&lt;?php echo $lang_login[&#039;Request pass&#039;] ?&gt;&lt;/span&gt;&lt;/h2&gt;
    &lt;div class=&quot;box&quot;&gt;
        &lt;form id=&quot;request_pass&quot; method=&quot;post&quot; action=&quot;login.php?action=forget_2&quot; onsubmit=&quot;this.request_pass.disabled=true;if(process_form(this)){return true;}else{this.request_pass.disabled=false;return false;}&quot;&gt;
            &lt;div class=&quot;inform&quot;&gt;
                &lt;fieldset&gt;
                    &lt;legend&gt;&lt;?php echo $lang_login[&#039;Request pass legend&#039;] ?&gt;&lt;/legend&gt;
                    &lt;div class=&quot;infldset&quot;&gt;
                        &lt;input type=&quot;hidden&quot; name=&quot;form_sent&quot; value=&quot;1&quot; /&gt;
                        &lt;input id=&quot;req_email&quot; type=&quot;text&quot; name=&quot;req_email&quot; size=&quot;50&quot; maxlength=&quot;50&quot; /&gt;
                        &lt;p&gt;&lt;?php echo $lang_login[&#039;Request pass info&#039;] ?&gt;&lt;/p&gt;
                    &lt;/div&gt;
                &lt;/fieldset&gt;
            &lt;/div&gt;
            &lt;p&gt;&lt;input type=&quot;submit&quot; name=&quot;request_pass&quot; value=&quot;&lt;?php echo $lang_common[&#039;Submit&#039;] ?&gt;&quot; /&gt;&lt;a href=&quot;javascript:history.go(-1)&quot;&gt;&lt;?php echo $lang_common[&#039;Go back&#039;] ?&gt;&lt;/a&gt;&lt;/p&gt;
        &lt;/form&gt;
    &lt;/div&gt;
&lt;/div&gt;
&lt;?php

    require PUN_ROOT.&#039;footer.php&#039;;
}


if (!$pun_user[&#039;is_guest&#039;])
    header(&#039;Location: index.php&#039;);

// Try to determine if the data in HTTP_REFERER is valid (if not, we redirect to index.php after login)
$redirect_url = (isset($_SERVER[&#039;HTTP_REFERER&#039;]) &amp;&amp; preg_match(&#039;#^&#039;.preg_quote($pun_config[&#039;o_base_url&#039;]).&#039;/(.*?)\.php#i&#039;, $_SERVER[&#039;HTTP_REFERER&#039;])) ? htmlspecialchars($_SERVER[&#039;HTTP_REFERER&#039;]) : &#039;index.php&#039;;

$page_title = pun_htmlspecialchars($pun_config[&#039;o_board_title&#039;]).&#039; / &#039;.$lang_common[&#039;Login&#039;];
$required_fields = array(&#039;req_username&#039; =&gt; $lang_common[&#039;Username&#039;], &#039;req_password&#039; =&gt; $lang_common[&#039;Password&#039;]);
$focus_element = array(&#039;login&#039;, &#039;req_username&#039;);


session_start();    

require PUN_ROOT.&#039;header.php&#039;;


?&gt;
&lt;div class=&quot;blockform&quot;&gt;
    &lt;h2&gt;&lt;span&gt;&lt;?php echo $lang_common[&#039;Login&#039;] ?&gt;&lt;/span&gt;&lt;/h2&gt;
    &lt;div class=&quot;box&quot;&gt;
        &lt;form id=&quot;login&quot; name=&quot;login&quot; method=&quot;post&quot; action=&quot;login.php?action=in&quot; onsubmit=&quot;encrypt()&quot;&gt;
            &lt;div class=&quot;inform&quot;&gt;
                &lt;fieldset&gt;
                    &lt;legend&gt;&lt;?php echo $lang_login[&#039;Login legend&#039;] ?&gt;&lt;/legend&gt;
                        &lt;div class=&quot;infldset&quot;&gt;
                            &lt;input type=&quot;hidden&quot; name=&quot;form_sent&quot; value=&quot;1&quot; /&gt;
                            &lt;input type=&quot;hidden&quot; name=&quot;redirect_url&quot; value=&quot;&lt;?php echo $redirect_url ?&gt;&quot; /&gt;
                            &lt;label class=&quot;conl&quot;&gt;&lt;strong&gt;&lt;?php echo $lang_common[&#039;Username&#039;] ?&gt;&lt;/strong&gt;&lt;br /&gt;&lt;input type=&quot;text&quot; name=&quot;req_username&quot; size=&quot;25&quot; maxlength=&quot;25&quot; tabindex=&quot;1&quot; /&gt;&lt;br /&gt;&lt;/label&gt;
                            &lt;label class=&quot;conl&quot;&gt;&lt;strong&gt;&lt;?php echo $lang_common[&#039;Password&#039;] ?&gt;&lt;/strong&gt;&lt;br /&gt;&lt;input type=&quot;password&quot; name=&quot;req_password&quot; size=&quot;16&quot; maxlength=&quot;40&quot; tabindex=&quot;2&quot; /&gt;&lt;br /&gt;&lt;/label&gt;
                            &lt;p class=&quot;clearb&quot;&gt;&lt;?php echo $lang_login[&#039;Login info&#039;] ?&gt;&lt;/p&gt;
                            &lt;p&gt;&lt;a href=&quot;register.php&quot; tabindex=&quot;4&quot;&gt;&lt;?php echo $lang_login[&#039;Not registered&#039;] ?&gt;&lt;/a&gt;  
                            &lt;a href=&quot;login.php?action=forget&quot; tabindex=&quot;5&quot;&gt;&lt;?php echo $lang_login[&#039;Forgotten pass&#039;] ?&gt;&lt;/a&gt;&lt;/p&gt;
                        &lt;/div&gt;
                &lt;/fieldset&gt;
            &lt;/div&gt;
            &lt;p&gt;&lt;input type=&quot;submit&quot; name=&quot;login&quot; value=&quot;&lt;?php echo $lang_common[&#039;Login&#039;] ?&gt;&quot; tabindex=&quot;3&quot; /&gt;&lt;/p&gt;
        &lt;/form&gt;
    &lt;/div&gt;
&lt;/div&gt;
&lt;?php

require PUN_ROOT.&#039;footer.php&#039;;</code></pre></div><p>code sure be improved although it works.</p>]]></description>
			<author><![CDATA[null@example.com (svo)]]></author>
			<pubDate>Fri, 27 Jul 2007 05:02:42 +0000</pubDate>
			<guid>https://punbb.informer.com/forums/post/98649/#p98649</guid>
		</item>
	</channel>
</rss>
