I basically want to know how to do it. I have found what i think is the authentication page. I then need a configurable LDAP script that will contain all the LDAP settings. Then hopefully it will all work fine. I have attached the file that i think would be the file i need to edit.
Thanks
J
FIle: class_session.php
PHP Code:
<?php
/*
#======================================================
| Trellis Desk
| =====================================
| By DJ "someotherguy" (sog@accord5.com)
| © 2007 ACCORD5
| http://www.accord.com/products/trellis/
| =====================================
| Email: sales@accord5.com
#======================================================
| @ Version: v1.0 RC 1 Build 10031234
| @ Version Int: 100.3.1.234
| @ Version Num: 10031234
| @ Build: 0234
#======================================================
| | Session Class :: Session Handler
#======================================================
*/
class session {
var $member = array();
#=======================================
# @ Load Session
# Loads the session. What else? :D
#=======================================
function load_session()
{
$authorized = 0; // Initialize for Security
#=============================
# Kill Any Bad Sessions
#=============================
$this->kill_old_sessions();
$this->kill_old_tokens();
#=============================
# Get Information
#=============================
$cookie_sid = $this->ifthd->get_cookie('hdsid');
$cookie_mid = intval( $this->ifthd->get_cookie('hdmid') );
$cookie_hash = $this->ifthd->get_cookie('hdphash');
#=============================
# If We Have A Session Cookie
#=============================
if ( $cookie_sid )
{
#=============================
# Load Member
#=============================
$this->ifthd->core->db->construct( array(
'select' => array( 's' => 'all',
'm' => array( 'id', 'name', 'email', 'login_key', 'mgroup', 'title', 'joined', 'ipadd', 'open_tickets', 'tickets', 'email_notify', 'email_html', 'email_new_ticket', 'email_ticket_reply', 'email_announce', 'email_staff_ticket_reply', 'email_staff_new_ticket', 'ban_ticket_center', 'ban_ticket_open', 'ban_ticket_escalate', 'ban_ticket_rate', 'ban_kb', 'ban_kb_comment', 'ban_kb_rate', 'time_zone', 'dst_active', 'lang', 'skin', 'use_rte', 'cpfields' ),
'g' => 'all',
),
'from' => array( 's' => 'sessions' ),
'join' => array( array( 'from' => array( 'm' => 'members' ), 'where' => array( 's' => 's_mid', '=', 'm' => 'id' ) ), array( 'from' => array( 'g' => 'groups' ), 'where' => array( 'g' => 'g_id', '=', 'm' => 'mgroup' ) ) ),
'where' => array( array( 's' => 's_id' ), '=', $cookie_sid ),
'limit' => array( 0, 1 ),
) );
$this->ifthd->core->db->execute();
if ( $this->ifthd->core->db->get_num_rows() == 1 )
{
$this->member = $this->ifthd->core->db->fetch_row();
#=============================
# Update Session
#=============================
$this->ifthd->core->db->construct( array(
'update' => 'sessions',
'set' => array( 's_location' => $this->ifthd->input['act'], 's_time' => time() ),
'where' => array( 's_id', '=', $cookie_sid ),
'limit' => array( 1 ),
) );
$this->ifthd->core->db->next_shutdown();
$this->ifthd->core->db->execute();
$this->ifthd->set_cookie( 'hdsid', $cookie_sid, time() + ( $this->ifthd->core->cache['config']['session_timeout'] * 60 ) );
if ( $this->member['s_guest'] )
{
$this->member['id'] = 0;
$this->member['name'] = 'Guest';
$this->member['mgroup'] = 2;
$this->member = array_merge( $this->member, $this->ifthd->core->cache['group'][2] );
}
$authorized = 1;
}
}
#=============================
# If We Have A Remember Cookie
#=============================
if ( $cookie_mid && $cookie_hash && ! $authorized )
{
#=============================
# Load Member
#=============================
$this->ifthd->core->db->construct( array(
'select' => array( 'm' => array( 'id', 'name', 'email', 'login_key', 'mgroup', 'title', 'joined', 'ipadd', 'open_tickets', 'tickets', 'email_notify', 'email_html', 'email_new_ticket', 'email_ticket_reply', 'email_announce', 'email_staff_new_ticket', 'email_staff_ticket_reply', 'ban_ticket_center', 'ban_ticket_open', 'ban_ticket_escalate', 'ban_ticket_rate', 'ban_kb', 'ban_kb_comment', 'ban_kb_rate', 'time_zone', 'dst_active', 'lang', 'skin', 'use_rte', 'cpfields' ),
'g' => 'all',
),
'from' => array( 'm' => 'members' ),
'join' => array( array( 'from' => array( 'g' => 'groups' ), 'where' => array( 'g' => 'g_id', '=', 'm' => 'mgroup' ) ) ),
'where' => array( array( 'm' => 'id' ), '=', $cookie_mid ),
'limit' => array( 0, 1 ),
) );
$this->ifthd->core->db->execute();
$this->member = $this->ifthd->core->db->fetch_row();
#=============================
# Checkie Checkie
#=============================
if ( $this->member['login_key'] == $cookie_hash )
{
#=============================
# Create Session
#=============================
$new_session = md5( 's' . time() . $this->member['id'] . uniqid( rand(), true ) );
$db_array = array(
's_id' => $new_session,
's_mid' => $this->member['id'],
's_mname' => $this->member['name'],
's_ipadd' => $this->ifthd->input['ip_address'],
's_location' => $this->ifthd->input['act'],
's_time' => time(),
);
$this->ifthd->core->db->construct( array(
'insert' => 'sessions',
'set' => $db_array,
) );
$this->ifthd->core->db->execute();
$this->ifthd->set_cookie( 'hdsid', $new_session, time() + ( $this->ifthd->core->cache['config']['session_timeout'] * 60 ) );
$authorized = 1;
}
else
{
$this->ifthd->delete_cookie('hdmid');
$this->ifthd->delete_cookie('hdphash');
}
}
#=============================
# If We Are Not Authorized
#=============================
if ( ! $authorized )
{
$this->member['id'] = 0;
$this->member['name'] = 'Guest';
$this->member['mgroup'] = 2;
$this->member['guest'] = 1;
#=============================
# Create Session
#=============================
$new_session = md5( 's' . time() . $this->member['id'] . uniqid( rand(), true ) );
$db_array = array(
's_id' => $new_session,
's_mid' => $this->member['id'],
's_mname' => $this->member['name'],
's_ipadd' => $this->ifthd->input['ip_address'],
's_location' => $this->ifthd->input['act'],
's_time' => time(),
's_guest' => 1,
);
$this->ifthd->core->db->construct( array(
'insert' => 'sessions',
'set' => $db_array,
) );
$this->ifthd->core->db->execute();
$this->ifthd->set_cookie( 'hdsid', $new_session, time() + ( $this->ifthd->core->cache['config']['session_timeout'] * 60 ) );
$this->member['s_id'] = $new_session;
$this->member = array_merge( $this->member, $this->ifthd->core->cache['group'][2] );
}
return $this->member;
}
#=======================================
# @ Do Login
# Attempt to login.
#=======================================
function do_login()
{
#=============================
# Security Checks
#=============================
$this->ifthd->check_token('login');
if ( ! $this->ifthd->input['username'] || ! $this->ifthd->input['password'] )
{
$this->ifthd->skin->error('fill_form_completely', 1);
}
#=============================
# Select Member
#=============================
$this->ifthd->core->db->construct( array(
'select' => array( 'id', 'name', 'email', 'password', 'pass_salt', 'login_key', 'email_val', 'admin_val' ),
'from' => 'members',
'where' => array( 'name|lower', '=', strtolower( $this->ifthd->input['username'] ) ),
'limit' => array( 0, 1 ),
) );
$this->ifthd->core->db->execute();
if ( ! $this->ifthd->core->db->get_num_rows() )
{
$this->ifthd->skin->error('login_no_user', 1);
}
$mem = $this->ifthd->core->db->fetch_row();
#=============================
# Compare Password
#=============================
if ( sha1( md5( $this->ifthd->input['password'] . $mem['pass_salt'] ) ) == $mem['password'] )
{
#=============================
# Validation Check
#=============================
if ( ! $mem['email_val'] )
{
$this->ifthd->skin->error('login_must_val');
}
if ( ! $mem['admin_val'] )
{
$this->ifthd->skin->error('login_must_val_admin');
}
#=============================
# Delete Old Sessoin
#=============================
if ( $this->member['s_id'] )
{
$this->ifthd->core->db->construct( array(
'delete' => 'sessions',
'where' => array( 's_id', '=', $this->member['s_id'] ),
'limit' => array( 1 ),
) );
$this->ifthd->core->db->execute();
}
#=============================
# Create Session
#=============================
$new_session = md5( time() . $mem['id'] . uniqid( rand(), true ) );
$db_array = array(
's_id' => $new_session,
's_mid' => $mem['id'],
's_mname' => $mem['name'],
's_email' => $mem['email'],
's_ipadd' => $this->ifthd->input['ip_address'],
's_location' => $this->ifthd->input['act'],
's_time' => time(),
);
$this->ifthd->core->db->construct( array(
'insert' => 'sessions',
'set' => $db_array,
) );
$this->ifthd->core->db->execute();
$this->ifthd->set_cookie( 'hdsid', $new_session, time() + ( $this->ifthd->core->cache['config']['session_timeout'] * 60 ) );
#=============================
# Remember Me?
#=============================
if ( $this->ifthd->input['remember'] )
{
$this->ifthd->set_cookie( 'hdmid', $mem['id'] );
$this->ifthd->set_cookie( 'hdphash', $mem['login_key'] );
}
#=============================
# Redirect
#=============================
if ( $this->ifthd->input['extra_l'] )
{
$this->ifthd->skin->redirect( '?'. str_replace( "&", "&", $this->ifthd->input['extra_l'] ), 'login_success' );
}
else
{
$this->ifthd->skin->redirect( '?act=portal', 'login_success' );
}
}
else
{
$this->ifthd->skin->error('login_no_pass', 1);
}
}
#=======================================
# @ Do Guest Login
# Attempt to login a guest.
#=======================================
function do_guest_login($onthefly=0)
{
#=============================
# Security Checks
#=============================
if ( $onthefly )
{
$this->ifthd->input['email_address'] = $this->ifthd->input['email'];
$this->ifthd->input['ticket_key'] = $this->ifthd->input['key'];
}
else
{
$this->ifthd->check_token('glogin');
}
if ( ! $this->ifthd->validate_email( $this->ifthd->input['email_address'] ) )
{
$this->ifthd->skin->error('no_valid_email');
}
if ( strlen( $this->ifthd->input['ticket_key'] ) != 11 )
{
$this->ifthd->skin->error('no_valid_tkey');
}
#=============================
# Select Ticket
#=============================
$this->ifthd->core->db->construct( array(
'select' => array( 'id', 'mname', 'email' ),
'from' => 'tickets',
'where' => array( array( 'tkey', '=', $this->ifthd->input['ticket_key'] ), array( 'email', '=', $this->ifthd->input['email_address'], 'and' ), array( 'guest', '=', 1, 'and' ) ),
) );
$this->ifthd->core->db->execute();
if ( $this->ifthd->core->db->get_num_rows() != 1 )
{
$this->ifthd->skin->error('no_ticket_guest');
}
$ticket = $this->ifthd->core->db->fetch_row();
#=============================
# Update Session
#=============================
$new_session = md5( time() . $mem['id'] . uniqid( rand(), true ) );
$db_array = array( 's_mname' => $ticket['mname'], 's_email' => $ticket['email'], 's_tkey' => $this->ifthd->input['ticket_key'] );
$this->ifthd->core->db->construct( array(
'update' => 'sessions',
'set' => $db_array,
'where' => array( 's_id', '=', $this->member['s_id'] ),
'limit' => array( 1 ),
) );
$this->ifthd->core->db->execute();
$this->ifthd->member = array_merge( $this->ifthd->member, $db_array );
if ( ! $onthefly ) $this->ifthd->skin->redirect( '?act=tickets&code=view&id='. $ticket['id'], 'login_success' );
}
#=======================================
# @ Do Logout
# Attempt to logout.
#=======================================
function do_logout()
{
if ( $this->ifthd->member['id'] )
{
#=============================
# Security Checks
#=============================
$this->ifthd->core->db->construct( array(
'select' => array( 'id' ),
'from' => 'members',
'where' => array( 'login_key', '=', $this->ifthd->input['key'] ),
'limit' => array( 0, 1 ),
) );
$this->ifthd->core->db->execute();
if ( ! $this->ifthd->core->db->get_num_rows() )
{
$this->ifthd->skin->error('logout_no_key');
}
$lk = $this->ifthd->core->db->fetch_row();
if ( $this->ifthd->member['id'] != $lk['id'] )
{
$this->ifthd->skin->error('logout_no_key');
}
}
#=============================
# Delete Cookies
#=============================
$this->ifthd->delete_cookie('hdsid');
$this->ifthd->delete_cookie('hdmid');
$this->ifthd->delete_cookie('hdphash');
#=============================
# Delete Session
#=============================
$this->ifthd->core->db->construct( array(
'delete' => 'sessions',
'where' => array( 's_id', '=', $this->member['s_id'] ),
'limit' => array( 1 ),
) );
$this->ifthd->core->db->execute();
#=============================
# Redirect
#=============================
$this->ifthd->skin->redirect( '?act=portal', 'logout_success' );
}
#=======================================
# @ Kill Old Sessions
# Kills sessions older than the session
# timeout (defined in ACP).
#=======================================
function kill_old_sessions()
{
$timeout = time() - ( $this->ifthd->core->cache['config']['session_timeout'] * 60 );
$this->ifthd->core->db->construct( array(
'delete' => 'sessions',
'where' => array( 's_time', '<=', $timeout ),
) );
$this->ifthd->core->db->next_shutdown();
$this->ifthd->core->db->execute();
$num_killed = $this->ifthd->core->db->get_num_rows();
return $num_killed;
}
#=======================================
# @ Kill Old Tokens
# Kills tokens older than 1 hour.
#=======================================
function kill_old_tokens()
{
if ( $this->ifthd->core->cache['config']['use_form_tokens'] )
{
$timeout = time() - ( 60 * 60 );
$this->ifthd->core->db->construct( array(
'delete' => 'tokens',
'where' => array( 'date', '<=', $timeout ),
) );
$this->ifthd->core->db->next_shutdown();
$this->ifthd->core->db->execute();
$num_killed = $this->ifthd->core->db->get_num_rows();
return $num_killed;
}
}
}
?>
FIle: class_session.php
PHP Code:
<?php
/*
#======================================================
| Trellis Desk
| =====================================
| By DJ "someotherguy" (sog@accord5.com)
| © 2007 ACCORD5
| http://www.accord.com/products/trellis/
| =====================================
| Email: sales@accord5.com
#======================================================
| @ Version: v1.0 RC 1 Build 10031234
| @ Version Int: 100.3.1.234
| @ Version Num: 10031234
| @ Build: 0234
#======================================================
| | Admin Session Class :: Session Handler
#======================================================
*/
class asession {
var $member = array();
#=======================================
# @ Load Session
# Loads the session. What else? :D
#=======================================
function load_session()
{
$authorized = 0; // Initialize for Security
#=============================
# Kill Any Bad Sessions
#=============================
$this->kill_old_sessions();
$this->kill_old_tokens();
#=============================
# Get Information
#=============================
$cookie_sid = $this->ifthd->get_cookie('hdasid');
#=============================
# If We Have A Session Cookie
#=============================
if ( $cookie_sid )
{
#=============================
# Load Member
#=============================
$this->ifthd->core->db->construct( array(
'select' => array( 's' => 'all',
'm' => array( 'id', 'name', 'email', 'login_key', 'mgroup', 'title', 'joined', 'ipadd', 'time_zone', 'dst_active', 'lang', 'skin', 'use_rte', 'cpfields', 'rss_key', 'signature', 'auto_sig', 'assigned' ),
'g' => 'all',
),
'from' => array( 's' => 'asessions' ),
'join' => array( array( 'from' => array( 'm' => 'members' ), 'where' => array( 's' => 's_mid', '=', 'm' => 'id' ) ), array( 'from' => array( 'g' => 'groups' ), 'where' => array( 'g' => 'g_id', '=', 'm' => 'mgroup' ) ) ),
'where' => array( array( 's' => 's_id' ), '=', $cookie_sid ),
'limit' => array( 0, 1 ),
) );
$this->ifthd->core->db->execute();
if ( $this->ifthd->core->db->get_num_rows() )
{
$this->member = $this->ifthd->core->db->fetch_row();
if ( $this->member['g_acp_access'] )
{
#=============================
# Update Ticket
#=============================
if ( $this->ifthd->input['section'] != 'manage' || $this->ifthd->input['act'] != 'tickets' || $this->ifthd->input['code'] != 'view' )
{
if ( $this->member['s_inticket'] )
{
$this->ifthd->core->db->construct( array(
'select' => array( 'status' ),
'from' => 'tickets',
'where' => array( 'id', '=', $this->member['s_inticket'] ),
'limit' => array( 0, 1 ),
) );
$this->ifthd->core->db->execute();
if ( $this->ifthd->core->db->get_num_rows() )
{
$t = $this->ifthd->core->db->fetch_row();
if ( $t['status'] == 2 )
{
$this->ifthd->core->db->construct( array(
'update' => 'tickets',
'set' => array( 'status' => 1 ),
'where' => array( 'id', '=', $this->member['s_inticket'] ),
'limit' => array( 1 ),
) );
$this->ifthd->core->db->execute();
}
}
}
}
#=============================
# Update Session
#=============================
$db_array = array(
's_location' => $this->ifthd->input['act'],
's_time' => time(),
);
if ( $this->ifthd->input['section'] == 'manage' && $this->ifthd->input['act'] == 'tickets' && $this->ifthd->input['code'] == 'view' )
{
$db_array['s_inticket'] = $this->ifthd->input['id'];
}
else
{
$db_array['s_inticket'] = 0;
}
$this->ifthd->core->db->construct( array(
'update' => 'asessions',
'set' => $db_array,
'where' => array( 's_id', '=', $cookie_sid ),
'limit' => array( 1 ),
) );
$this->ifthd->core->db->next_shutdown();
$this->ifthd->core->db->execute();
$this->ifthd->set_cookie( 'hdasid', $cookie_sid, time() + ( $this->ifthd->core->cache['config']['acp_session_timeout'] * 60 * 60 ) );
#=============================
# ACP Permissions
#=============================
if ( $this->member['id'] == 1 )
{
$this->member['acp'] = unserialize('a:76:{s:5:"admin";i:1;s:10:"admin_logs";i:1;s:16:"admin_logs_admin";i:1;s:17:"admin_logs_member";i:1;s:16:"admin_logs_email";i:1;s:16:"admin_logs_error";i:1;s:19:"admin_logs_security";i:1;s:17:"admin_logs_ticket";i:1;s:16:"admin_logs_prune";i:1;s:6:"manage";i:1;s:13:"manage_ticket";i:1;s:19:"manage_ticket_reply";i:1;s:25:"manage_ticket_assign_self";i:1;s:24:"manage_ticket_assign_any";i:1;s:18:"manage_ticket_hold";i:1;s:22:"manage_ticket_escalate";i:1;s:18:"manage_ticket_move";i:1;s:19:"manage_ticket_close";i:1;s:20:"manage_ticket_delete";i:1;s:20:"manage_ticket_reopen";i:1;s:13:"manage_canned";i:1;s:17:"manage_canned_add";i:1;s:18:"manage_canned_edit";i:1;s:20:"manage_canned_delete";i:1;s:13:"manage_depart";i:1;s:17:"manage_depart_add";i:1;s:18:"manage_depart_edit";i:1;s:20:"manage_depart_delete";i:1;s:21:"manage_depart_reorder";i:1;s:21:"manage_depart_cfields";i:1;s:15:"manage_announce";i:1;s:19:"manage_announce_add";i:1;s:20:"manage_announce_edit";i:1;s:22:"manage_announce_delete";i:1;s:13:"manage_member";i:1;s:17:"manage_member_add";i:1;s:18:"manage_member_edit";i:1;s:20:"manage_member_delete";i:1;s:21:"manage_member_approve";i:1;s:21:"manage_member_cfields";i:1;s:12:"manage_group";i:1;s:16:"manage_group_add";i:1;s:17:"manage_group_edit";i:1;s:19:"manage_group_delete";i:1;s:14:"manage_article";i:1;s:18:"manage_article_add";i:1;s:19:"manage_article_edit";i:1;s:21:"manage_article_delete";i:1;s:10:"manage_cat";i:1;s:14:"manage_cat_add";i:1;s:15:"manage_cat_edit";i:1;s:17:"manage_cat_delete";i:1;s:12:"manage_pages";i:1;s:16:"manage_pages_add";i:1;s:17:"manage_pages_edit";i:1;s:19:"manage_pages_delete";i:1;s:15:"manage_settings";i:1;s:22:"manage_settings_update";i:1;s:4:"look";i:1;s:9:"look_skin";i:1;s:16:"look_skin_manage";i:1;s:15:"look_skin_tools";i:1;s:16:"look_skin_import";i:1;s:16:"look_skin_export";i:1;s:9:"look_lang";i:1;s:16:"look_lang_manage";i:1;s:15:"look_lang_tools";i:1;s:16:"look_lang_import";i:1;s:16:"look_lang_export";i:1;s:5:"tools";i:1;s:11:"tools_maint";i:1;s:19:"tools_maint_recount";i:1;s:17:"tools_maint_clean";i:1;s:16:"tools_maint_optm";i:1;s:20:"tools_maint_syscheck";i:1;s:12:"tools_backup";i:1;}');
}
else
{
$this->member['acp'] = unserialize( $this->member['g_acp_perm'] );
}
$authorized = 1;
}
}
}
#=============================
# If We Are Not Authorized
#=============================
if ( ! $authorized )
{
$this->member['id'] = 0;
$this->ifthd->delete_cookie( 'hdasid' );
$this->ifthd->skin->error( 'must_login', 1 );
}
return $this->member;
}
#=======================================
# @ Do Login
# Attempt to login.
#=======================================
function do_login()
{
#=============================
# Security Checks
#=============================
if ( ! isset( $this->ifthd->input['username'] ) || ! isset( $this->ifthd->input['password'] ) )
{
$this->ifthd->skin->error( 'fill_form_completely', 1 );
}
#=============================
# Select Member
#=============================
$this->ifthd->core->db->construct( array(
'select' => array( 'm' => array( 'id', 'name', 'email', 'password', 'pass_salt', 'login_key', 'mgroup', 'title', 'joined', 'ipadd', 'time_zone', 'dst_active', 'lang', 'skin', 'use_rte', 'cpfields', 'rss_key', 'signature', 'auto_sig', 'assigned' ),
'g' => 'all',
),
'from' => array( 'm' => 'members' ),
'join' => array( array( 'from' => array( 'g' => 'groups' ), 'where' => array( 'g' => 'g_id', '=', 'm' => 'mgroup' ) ) ),
'where' => array( array( 'm' => 'name|lower' ), '=', strtolower( $this->ifthd->input['username'] ) ),
'limit' => array( 0, 1 ),
) );
$this->ifthd->core->db->execute();
if ( ! $this->ifthd->core->db->get_num_rows() )
{
$this->ifthd->log( 'admin', "ACP Failed Login Attempt '". $this->ifthd->input['username'] ."'", 2 );
$this->ifthd->log( 'security', "ACP Failed Login Attempt '". $this->ifthd->input['username'] ."'", 2 );
$this->ifthd->skin->error( 'login_no_user', 1 );
}
$mem = $this->ifthd->core->db->fetch_row();
#=============================
# Compare Password
#=============================
if ( sha1( md5( $this->ifthd->input['password'] . $mem['pass_salt'] ) ) == $mem['password'] )
{
// Permission
if ( ! $mem['g_acp_access'] )
{
$this->ifthd->log( 'admin', "ACP Login Blocked Access '". $mem['name'] ."'", 2, $mem['id'] );
$this->ifthd->log( 'security', "ACP Login Blocked Access '". $mem['name'] ."'", 2, $mem['id'] );
$this->ifthd->skin->error( 'login_no_admin', 1 );
}
#=============================
# Create Session
#=============================
$new_session = md5( 's' . time() . $mem['id'] . uniqid( rand(), true ) );
$db_array = array(
's_id' => $new_session,
's_mid' => $mem['id'],
's_mname' => $mem['name'],
's_ipadd' => $this->ifthd->input['ip_address'],
's_location' => $this->ifthd->input['act'],
's_time' => time(),
);
if ( $this->ifthd->input['section'] == 'manage' && $this->ifthd->input['act'] == 'tickets' && $this->ifthd->input['code'] == 'view' )
{
$db_array['s_inticket'] = $this->ifthd->input['id'];
}
else
{
$db_array['s_inticket'] = 0;
}
$this->ifthd->core->db->construct( array(
'insert' => 'asessions',
'set' => $db_array,
) );
$this->ifthd->core->db->execute();
$this->ifthd->set_cookie( 'hdasid', $new_session, time() + ( $this->ifthd->core->cache['config']['acp_session_timeout'] * 60 * 60 ) );
$this->ifthd->log( 'admin', "ACP Successful Login '". $mem['name'] ."'", 1, $mem['id'] );
// Play It Safe
$mem['password'] = $mem['pass_salt'] = $mem['login_key'] = "";
$mem = array_merge( $mem, $db_array );
$this->member = $mem;
#=============================
# ACP Permissions
#=============================
if ( $this->member['id'] == 1 )
{
$this->member['acp'] = unserialize('a:76:{s:5:"admin";i:1;s:10:"admin_logs";i:1;s:16:"admin_logs_admin";i:1;s:17:"admin_logs_member";i:1;s:16:"admin_logs_email";i:1;s:16:"admin_logs_error";i:1;s:19:"admin_logs_security";i:1;s:17:"admin_logs_ticket";i:1;s:16:"admin_logs_prune";i:1;s:6:"manage";i:1;s:13:"manage_ticket";i:1;s:19:"manage_ticket_reply";i:1;s:25:"manage_ticket_assign_self";i:1;s:24:"manage_ticket_assign_any";i:1;s:18:"manage_ticket_hold";i:1;s:22:"manage_ticket_escalate";i:1;s:18:"manage_ticket_move";i:1;s:19:"manage_ticket_close";i:1;s:20:"manage_ticket_delete";i:1;s:20:"manage_ticket_reopen";i:1;s:13:"manage_canned";i:1;s:17:"manage_canned_add";i:1;s:18:"manage_canned_edit";i:1;s:20:"manage_canned_delete";i:1;s:13:"manage_depart";i:1;s:17:"manage_depart_add";i:1;s:18:"manage_depart_edit";i:1;s:20:"manage_depart_delete";i:1;s:21:"manage_depart_reorder";i:1;s:21:"manage_depart_cfields";i:1;s:15:"manage_announce";i:1;s:19:"manage_announce_add";i:1;s:20:"manage_announce_edit";i:1;s:22:"manage_announce_delete";i:1;s:13:"manage_member";i:1;s:17:"manage_member_add";i:1;s:18:"manage_member_edit";i:1;s:20:"manage_member_delete";i:1;s:21:"manage_member_approve";i:1;s:21:"manage_member_cfields";i:1;s:12:"manage_group";i:1;s:16:"manage_group_add";i:1;s:17:"manage_group_edit";i:1;s:19:"manage_group_delete";i:1;s:14:"manage_article";i:1;s:18:"manage_article_add";i:1;s:19:"manage_article_edit";i:1;s:21:"manage_article_delete";i:1;s:10:"manage_cat";i:1;s:14:"manage_cat_add";i:1;s:15:"manage_cat_edit";i:1;s:17:"manage_cat_delete";i:1;s:12:"manage_pages";i:1;s:16:"manage_pages_add";i:1;s:17:"manage_pages_edit";i:1;s:19:"manage_pages_delete";i:1;s:15:"manage_settings";i:1;s:22:"manage_settings_update";i:1;s:4:"look";i:1;s:9:"look_skin";i:1;s:16:"look_skin_manage";i:1;s:15:"look_skin_tools";i:1;s:16:"look_skin_import";i:1;s:16:"look_skin_export";i:1;s:9:"look_lang";i:1;s:16:"look_lang_manage";i:1;s:15:"look_lang_tools";i:1;s:16:"look_lang_import";i:1;s:16:"look_lang_export";i:1;s:5:"tools";i:1;s:11:"tools_maint";i:1;s:19:"tools_maint_recount";i:1;s:17:"tools_maint_clean";i:1;s:16:"tools_maint_optm";i:1;s:20:"tools_maint_syscheck";i:1;s:12:"tools_backup";i:1;}');
}
else
{
$this->member['acp'] = unserialize( $this->member['g_acp_perm'] );
}
#=============================
# Redirect
#=============================
/*if ( $this->ifthd->input['extra_l'] )
{
$this->ifthd->skin->redirect( '?'. str_replace( "&", "&", $this->ifthd->input['extra_l'] ), 'login_success' );
}
else
{
$this->ifthd->skin->redirect( '?act=admin', 'login_success' );
}*/
return $this->member;
}
else
{
$this->ifthd->log( 'admin', "ACP Failed Login Attempt '". $mem['name'] ."'", 2, $mem['id'] );
$this->ifthd->log( 'security', "ACP Failed Login Attempt '". $mem['name'] ."'", 2, $mem['id'] );
$this->ifthd->skin->error( 'login_no_pass', 1 );
}
}
#=======================================
# @ Do Logout
# Attempt to logout.
#=======================================
function do_logout()
{
#=============================
# Delete Cookie
#=============================
$this->ifthd->delete_cookie('hdasid');
#=============================
# Update Ticket
#=============================
if ( $this->member['s_inticket'] )
{
$this->ifthd->core->db->construct( array(
'update' => 'tickets',
'set' => array( 'status' => 1 ),
'where' => array( array( 'id', '=', $this->member['s_inticket'] ), array( 'status', '=', 2, 'and' ) ),
) );
$this->ifthd->core->db->next_shutdown();
$this->ifthd->core->db->execute();
}
#=============================
# Delete Session
#=============================
$this->ifthd->core->db->construct( array(
'delete' => 'asessions',
'where' => array( 's_id', '=', $this->member['s_id'] ),
'limit' => array( 1 ),
) );
$this->ifthd->core->db->execute();
#=============================
# Redirect
#=============================
$this->ifthd->skin->redirect( '?act=home', 'logout_success' );
}
#=======================================
# @ Kill Old Sessions
# Kills sessions older than the session
# timeout (defined in ACP).
#=======================================
function kill_old_sessions()
{
#=============================
# Grab Sessions
#=============================
$timeout = time() - ( $this->ifthd->core->cache['config']['acp_session_timeout'] * 60 * 60 );
$this->ifthd->core->db->construct( array(
'select' => array( 's_id', 's_inticket' ),
'from' => 'asessions',
'where' => array( 's_time' ,'<=', $timeout ),
) );
$this->ifthd->core->db->execute();
if ( $num_killed = $this->ifthd->core->db->get_num_rows() )
{
$sessions = array(); // Initialize For Security
$tickets = array(); // Initialize For Security
while ( $s = $this->ifthd->core->db->fetch_row() )
{
$sessions[] = $s['s_id'];
$tickets[] = $s['s_inticket'];
}
#=============================
# Update Tickets
#=============================
$this->ifthd->core->db->construct( array(
'update' => 'tickets',
'set' => array( 'status' => 1 ),
'where' => array( array( 'id', 'in', $tickets ), array( 'status', '=', 2, 'and' ) ),
) );
$this->ifthd->core->db->next_shutdown();
$this->ifthd->core->db->execute();
#=============================
# Delete Sessions
#=============================
$this->ifthd->core->db->construct( array(
'delete' => 'asessions',
'where' => array( 's_id' ,'in', $sessions ),
) );
$this->ifthd->core->db->next_shutdown();
$this->ifthd->core->db->execute();
}
return $num_killed;
}
#=======================================
# @ Kill Old Tokens
# Kills tokens older than 1 hour.
#=======================================
function kill_old_tokens()
{
if ( $this->ifthd->core->cache['config']['use_form_tokens'] )
{
$timeout = time() - ( 60 * 60 );
$this->ifthd->core->db->construct( array(
'delete' => 'tokens',
'where' => array( 'date', '<=', $timeout ),
) );
$this->ifthd->core->db->next_shutdown();
$this->ifthd->core->db->execute();
$num_killed = $this->ifthd->core->db->get_num_rows();
return $num_killed;
}
}
}
?>
Bookmarks