Location: PHPKode > scripts > Yet Another Link Directory > yald2/admin/login.php
<?php
/******************************************************************************
* This file is part of Yet Another Link Directory.                            *
*                                                                             *
* Yet Another Link Directory 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.                                         *
*                                                                             *
* Yet Another Link Directory 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 Yet Another Link Directory; if not, write to the Free Software   *
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA  *
******************************************************************************/

require('../inc/config.php');
require('../inc/functions.php');
mysql_connect($mysql['host'],$mysql['username'],$mysql['password']);
mysql_select_db($mysql['db']);

$settings = getSettings();

session_start();


if(isset($_SESSION['yald_admin_logged_in'])){

	if(isset($_GET['logout'])){
		session_destroy();
	}

	header('Location: index.php');
	exit;
}

if(isset($_POST['submit'])){
	if(!empty($_POST['password']) && !empty($_POST['username'])){
		if($_POST['username'] == $settings['admin_user'] && sha1($_POST['password']) == $settings['admin_pass']){
			$_SESSION['yald_admin_logged_in'] = true;
			header('Location: index.php');
		} else {
			$error = 'Incorrent username/password combination.';
		}
	} else {
		$error = 'You must enter a username and password.';
	}
}

$template = file_get_contents('login_template.html');

$yald_head = '';
$yald_body = '';

if(isset($error)){
	$yald_body .= '<div align="center"><div class="errorbox"><b>'.$error.'</b></div></div>';
}

$yald_body .= <<<EOF
<b>Login to the admin panel:</b><br />
<small>Login to the admin panel so that you can manage current links, links pending approval, and  categories.</small><br /><br />
    <form action="{$_SERVER['PHP_SELF']}" method="post">
    
    <table width="233" border="0">
      <tr>
        <td width="79">Username:</td>
        <td width="144">
          <input type="text" name="username" />
        </td>
      </tr>
      <tr>
        <td>Password:</td>
        <td>
          <input type="password" name="password" />
        </td>
      </tr>
      <tr>
        <td><input type="submit" value="Submit" /></td>
        <td>&nbsp;</td>
      </tr>
    </table>
    <input type="hidden" name="submit" value="1" />
    </form>
EOF;

$template = str_replace('@YALD_BODY@',$yald_body,$template);

print $template;

?>
Return current item: Yet Another Link Directory