Jump to content
php.lv forumi

IPB session_id formula


Wuu

Recommended Posts

	$result = mysql_query('select count(*) from '.$INFO['sql_tbl_prefix'].'sessions where id = "'.session_id().'";');
$r = mysql_fetch_array($result);
if ($r[0] < 1) {
	mysql_query('insert into '.$INFO['sql_tbl_prefix'].'sessions values("'.session_id().'","",0,"'.$_SERVER['REMOTE_ADDR'].'","",'.time().',0,"idx,0,",2,0,"",0,"",0,"",0);');
}

 

Ir vajadzība ievietot manuāli sesiju lai pievienotu lietotāju online skaitītājam. Tik nevaru saprast kādā veidā IPB izvedo jaunu sesijas id?

Link to comment
Share on other sites

	$result = mysql_query('select count(*) from '.$INFO['sql_tbl_prefix'].'sessions where id = "'.session_id().'";');
$r = mysql_fetch_array($result);
if ($r[0] < 1) {
	mysql_query('insert into '.$INFO['sql_tbl_prefix'].'sessions values("'.session_id().'","",0,"'.$_SERVER['REMOTE_ADDR'].'","",'.time().',0,"idx,0,",2,0,"",0,"",0,"",0);');
}

 

Ir vajadzība ievietot manuāli sesiju lai pievienotu lietotāju online skaitītājam. Tik nevaru saprast kādā veidā IPB izvedo jaunu sesijas id?

Ko tieši Tu nevari saprast? Kas nesanāk? Manuprāt, neesi īsti aprakstījis problēmu. Pēc koda izskatās, ka viss ir ok. Ja runa ir par pašu ID, tad tas ir parasts md5. Lai vai kā, lūk izrāvus no paveca mana koda, varbūt noder:

 

private function createMemberSession() {
	$iMember_ID = (int)$this->iMember_ID;
	if ($iMember_ID < 1)
		return false;

	$this->destroyMemberSession();
	$sSession_Expiration = time() - 3600;

	$sSession_ID = md5(uniqid(microtime()));
	$this->sSession_ID = $sSession_ID;

	$saFields = array(
		'id'                 => array('s', $this->sSession_ID),
		'member_name'        => array('s', $this->saMember['members_display_name']),
		'member_id'          => array('i', $iMember_ID),
		'member_group'       => array('s', $this->saMember['mgroup']),
		'login_type'         => array('i', (int)substr($this->saMember['login_anonymous'], 0, 1)),
		'running_time'       => array('i', time()),
		'ip_address'         => array('s', $this->sIP),
		'browser'            => array('s', $this->sUserAgent),
		'location'           => array('s', 'idx,0,'),
		'in_error'           => array('i', 0),
		'location_1_type'    => array('s', ''),
		'location_1_id'      => array('i', 0),
		'location_2_type'    => array('s', ''),
		'location_2_id'      => array('i', 0),
		'location_3_type'    => array('s', ''),
		'location_3_id'      => array('i', 0)
	);
	$oSQLResult = fDB_DoInsert(self::$sIBFpre . 'sessions', $saFields);
}

Link to comment
Share on other sites

Paldies ,man tieši šo arī vajadzēja!

 

Gatavs kods ,varbūt kāds meklēs.

	$_COOKIE['session_id'] = mysql_escape_string($_COOKIE['session_id']);
$result = mysql_query('select count(*) from '.$INFO['sql_tbl_prefix'].'sessions where id = "'.$_COOKIE['session_id'].'" limit 1;');
$r = mysql_fetch_array($result);
if ($r[0] < 1) {
	$id = md5(uniqid(microtime()));
	mysql_query('insert into '.$INFO['sql_tbl_prefix'].'sessions values("'.$id.'","",0,"'.$_SERVER['REMOTE_ADDR'].'","",'.time().',0,"idx,0,",2,0,"",0,"",0,"",0);');
	setcookie('session_id',$id,0,'/','xxx.lv',false,false);
}

Edited by Wuu
Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
×
×
  • Create New...