You are not logged in.
#1 2008-03-29 23:31:26
- bradr
- New member
- Registered: 2008-03-29
- Posts: 2
how to remove login code in admin.php - to integrate into another sys
I want to replace the login portion of the code in admin.php because I want to intergrate it into another system that I am working with. The existing code for the system checks the login with the following...
<?php
session_start();
if (!isset($_SESSION['user']) && !isset($_SESSION['name']))
{
header('location: login.php');
}
if ($_GET['action'] == 'logout')
{
session_destroy();
header ('location: login.php');
}
require_once('../include/DbConnector.php');
include ('languages/english.php');
new DbConnector();
$query = "SELECT * FROM settings";
$result = mysql_query($query) or die(mysql_error());
while ($myrow = mysql_fetch_object($result)) {
$websiteName = $myrow->websiteName;
$url = $myrow->websiteUrl;
$logo = $myrow->logo;
}
?>
login section of admin.php ####################################
function doLogin(){
global $IG_CONFIG;
if(isset($_SESSION['user']) AND isset($_SESSION['pass'])){
if($_SESSION['user'] != $IG_CONFIG['admin_user'] OR $_SESSION['pass'] != md5($IG_CONFIG['admin_pass'])){
unset($_SESSION['user']);
unset($_SESSION['pass']);
doLogin();
exit;
}
}elseif(isset($_POST['username']) AND isset($_POST['password'])){
if($_POST['username'] == $IG_CONFIG['admin_user'] AND $_POST['password'] == $IG_CONFIG['admin_pass']){
$_SESSION['user'] = $_POST['username'];
$_SESSION['pass'] = md5($_POST['password']);
}else{
echo "<b>Error:</b> your username and password were not recognised. Please try again";
exit;
}
}else{
$form_to = "http://$_SERVER[HTTP_HOST]$_SERVER[PHP_SELF]";
if(isset($_SERVER["QUERY_STRING"]))
$form_to = $form_to ."?". $_SERVER["QUERY_STRING"];
adminHeader();
####################################
Basically I don't need a login inside a login, so if someone logs into the "main" system they can use the photo gallery admin page...and if you try to use the photo admin page without being logged into the main system it won't see the session like in the first code and you will be asked to login.
The photo gallery is GREAT and I would like to be able to use it in my existing setup as described. Thank you for any help with this, I really would appreciate it.
Brad
Last edited by bradr (2008-03-29 23:33:14)
Offline
2008-03-29 23:31:26
- Advert
#2 2008-03-30 12:39:17
- idut
- Administrator
- Registered: 2007-08-11
- Posts: 108
Re: how to remove login code in admin.php - to integrate into another sys
to use your own login, what to try is on line 10 of the admin.php file, remove doLogin(); and replace it with your own login code as above.
that should be it! good luck.
Offline
#3 2008-03-30 22:03:41
- bradr
- New member
- Registered: 2008-03-29
- Posts: 2
Re: how to remove login code in admin.php - to integrate into another sys
idut wrote:
to use your own login, what to try is on line 10 of the admin.php file, remove doLogin(); and replace it with your own login code as above.
that should be it! good luck.
Thank you for the reply! I was able to get this to work. What I did is listed below, in case someone else is looking for something similar.
I removed the doLogin(); and since you already had a session_start(); I just added my existing login code right below that. I also removed original lines 61 to 78 that reference the login right before "$form_to" is set and removed a few }'s to avoid any parse errors.
Have a good one ![]()
Offline
