Location: PHPKode > projects > Bloggie Lite > login.php
<?

// Copyright (C) Bloggie Lite Written by : Sean
// http://www.mywebland.com , http://mybloggie.mywebland.com

// You are requested to retain this copyright notice in order to use
// this software.

//This program 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.

//This program 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.

$bloggie_root_path = "";
define('IN_BLOGGIE', true);

include_once($bloggie_root_path.'init.php');

$pref_data = pref_data() ;

define('USER_COOKIE', 'USER_'.md5($pref_data['cookie_name']));
define('PASS_COOKIE', 'PASS_'.md5($pref_data['cookie_name']));

$site_url =  $pref_data['bloggie_path'];
define("PATH_COOKIE", preg_replace("|http://[^/]+|is","", $site_url."/" ));
$cookie_domain=parse_url($site_url);
if(!strpos("-".$cookie_domain['host'], ".")) {
   $cookie_host= false;
}
else {
   define('DOMAIN_COOKIE', ".".$cookie_domain['host']);
}
if ( !defined('DOMAIN_COOKIE') ) define('DOMAIN_COOKIE', $cookie_host);

if ( isset($mode) && $mode=="logoff" ) {
clear_cookie();
nocache();
redirect($bloggie_root_path."index.php");
exit;
}

include_once($bloggie_root_path.'language/'.$pref_data['language']);
$site_url = $pref_data['bloggie_path'];

$style  =  &$pref_data['default_style'] ;
$template = new Template('./templates/'.$style.'/');

$template->set_filenames(array(
        'footer'       => 'footer.tpl',
));

if(isset($_REQUEST['mode'])) { $mode = htmlspecialchars($_REQUEST['mode']);

if( $mode == "login" ) {

  if(isset($_POST['submit']))
  {
     if (isset($_POST['username'])) { $username=$_POST['username'];  }
     if (isset($_POST['pass']))   { $pass = $_POST['pass']; }
     if (isset($_POST['remember'])) { $remember = $_POST['remember']; }
     else $remember = 0;
     sanitize_username($username);
     $passwd = md5(trim( $pass ));
     if( $username == "" || $pass == "" ) error( $lang['Error'] , $lang['Msg_enter_name_pass'] );

     $sql =  "SELECT user FROM ".USER_TBL." WHERE user='$username' AND password='$passwd'";
     $result = $db->sql_query($sql);
     if ( $db->sql_numrows($result)!= 1  )   {

     echo simpleheader();
     error($lang['Error'],$lang['Msg_invalid_pass']) ;
     }
     else {
        if ( $remember ) {
           $cookie_expire = time() + 31536000;
        }
        else {
           $cookie_expire = 0;
        }
           setcookie(USER_COOKIE, $username, $cookie_expire, PATH_COOKIE , DOMAIN_COOKIE);
           setcookie(PASS_COOKIE, $passwd, $cookie_expire, PATH_COOKIE, DOMAIN_COOKIE);
           redirect($site_url."/admin/admin.php");

    }
  } // post submit
} elseif ( $mode == "logoff" ) { // mode
clear_cookie();
redirect($site_url."/index.php");

exit;
}
}

if (authenticate()) {
redirect($site_url."/admin/admin.php");
exit;
}

echo simpleheader();
?>
<style>
body { background: #ffffff;}
.tdloginheader { font-family: Verdana, Arial, Helvetica, sans-serif;
                  font-weight: bold;
                  font-size: 10pt;
                  letter-spacing: 0.09em;
                  color: #000000;
                  text-align: center;
                  line-height: 24px;
                  vertical-align: middle;
                  height: 20px;
}

.formfont {       font-family: Verdana, Arial, Helvetica, sans-serif;
                  font-weight: bold;
                  font-size: 11px;

}
input,textarea,select {
  font-size: 11px;
  font-family: Verdana;
  height: 22px;
  border-style: solid;
  border-width: 1px;
  border-color: #aaaaaa;
  background: #f0f0f0;
  border-width: 1px;
  margin: 2px;
}

</style>
<br /><br /><center>

<table id="Table_01" width="400"  border="0" cellpadding="0" cellspacing="0">
    <tr>
        <td>
            <img src="templates/<? echo $style ?>/images/login_01.gif" width="24" height="37" alt=""></td>
        <td>
            <img src="templates/<? echo $style ?>/images/login_02.gif" width="351" height="37" alt=""></td>
        <td>
            <img src="templates/<? echo $style ?>/images/login_03.gif" width="25" height="37" alt=""></td>
    </tr>
    <tr>
        <td background="templates/<? echo $style ?>/images/login_04.gif" width="24" height="300">
            </td>
        <td>
<center>
<table width="300" cellppacing="0" cellpadding="3" border="0">
        <tr><td colspan="2" class="tdloginheader">Log In</td></tr>
 <tr><td colspan=2></td></tr>
 <tr><td colspan=2></td></tr>
<form method="post" action="<? echo $_SERVER['PHP_SELF'] ?>?mode=login">
<tr>
<td width='105' height='25' class="formfont">&nbsp;&nbsp; <? echo $lang['User_Name'] ?></td>
<td height='25'><input type='text' name='username'  size='20' maxlength='50' tabindex="1"></td>
</tr>
<tr>
<td width='105' height='25' class="formfont">&nbsp;&nbsp; <? echo $lang['Password'] ?></td>
<td height='25'><input type='password' name='pass' size='20' maxlength='32' tabindex="2"></td>
</tr>
<tr>
<td width='105' height='25' class="formfont">&nbsp;&nbsp; <? echo $lang['Remember_Me'] ?></td>
<td height='25'><input name="remember" type="checkbox" value="persistant" tabindex="3" /></td>
</tr>
<tr>
<td width='105' height='25'></td>
<td height='25'><input type=submit value='login' name=submit></td>
</tr>
 <tr><td colspan=2></td></tr>
</form>
</table
</center>
</td>
        <td background="templates/<? echo $style ?>/images/login_06.gif" width="25" height="300">
            </td>
    </tr>
    <tr>
        <td>
            <img src="templates/<? echo $style ?>/images/login_07.gif" width="24" height="37" alt=""></td>
        <td><img src="templates/<? echo $style ?>/images/login_08.gif" width="351" height="37" alt="" border="0"></td>
        <td>
            <img src="templates/<? echo $style ?>/images/login_09.gif" width="25" height="37" alt=""></td>
    </tr>
</table>

<?php
$template->pparse('footer');
?>
Return current item: Bloggie Lite