-
شناسایی کاربر در php
سلام
میخواستم بدونم این سایت از کجا می فهمه که کاربر
javadvjj
الان آنلاین
از سیزن ها اگر استفاده می کنه من هیچ وقت رو دکمه ی خروج کلیک نمی کنم بس تا موقعی که سیزن هست من رو باید اشتباهی انلاین نشون بده که اینطور نیست بس چه جوری من رو میشناسه
با تشکر
سوال دوم چه جوری میشه در php خروجی xml
تولید کرد و rss
برای کاربران
بای تا های
-
یکی جواب بده دیگه
ممممممممممممممممممممممممم ممممممم اهههههههههههههههههههههههه ه
-
در مورد سوال اولتون احتمالاً زمان آخرین فعالیت رو در نظر میگیره و یه ضرب العجل براش میزاره که مثلاً اگر کاربر 10 دقیقه فعالیت نداشت آفلاین نشون داده بشه
سوال دومتون هم خیلی جواب داره ولی کوتاهش که کنیم میشه با استفاده از توابع DOM و SimpleXML
-
واقعا چه قدر توضیح شما گویا بود
کک کنید تا بفهمیم
حداقل ساختار تابع ها رو بگو
-
1- شما پس از هر لوگین توی دیتابیس زمان ورودتون ثبت میشه .
2- اگر شما یه یاد سپردن رو تیک بزنید این برای همیشه ورود شما رو تضمین میکنه
3- تو هر صفحه ای که وارد میشید زمان حضور شما در بانک بروز میشه
4- باقی هم همونی که یاسر گفت توی مدت محدودی اگر حضور نداشتی میگه نیستی !
تشکر//
-
سلام
با تشکر از راهنمایی دوستان
ولی توضیح بدید ولی چه جوری باید ضرب العجل داد و بس از 10 دقیقه کاربر رو آفلاین کرد
لطفا کدش رو بدید چون چیزی به ذهن من نمی رسه هر چی فکر کردم
کد رو بدید ممنون می شم
در آخر با تشکر از بیل گیتس عزیز که واقعا من رو خجالت زده کرده با کمکاش ممنون آقای بیل
آقا بیل من اون سایت هایی رو هم که برای چت روم بیشنهاد دادی امتحان کردم نه جواب نداد در هر حال ممنون
بای تا های
آهان راستی خروجی rss
هم اگر بگید شرمنده کردید
بازم های
-
کلاس زیر توبعی رو داره که میشه سیشن ها رو توسط دیتابیس کنترل کرد و یا بنوعی در دیتابیس ثبتشون کرد که این عمل کنترل بر روی افراد آنلاین و کاربر هارو بیشتر می کنه
[PHP]
class dbSession
{
//this function run
function dbSession($gc_maxlifetime = "600", $gc_probability = "", $gc_divisor = "")
{
global $settings;
if($_COOKIE['rememberMe__ID_main'] == md5("3month"))
{
$gc_maxlifetime = 8035200;
}
elseif($_COOKIE['rememberMe__ID_main'] == md5("6month"))
{
$gc_maxlifetime = 16070400;
}
else
{
$gc_maxlifetime = $settings['session_lifetime'];
}
// if $gc_maxlifetime is specified and is an integer number
if ($gc_maxlifetime != "" && is_integer($gc_maxlifetime)) {
// set the new value
@ini_set('session.gc_maxlifetime', $gc_maxlifetime);
}
// if $gc_probability is specified and is an integer number
if ($gc_probability != "" && is_integer($gc_probability)) {
// set the new value
@ini_set('session.gc_probability', $gc_probability);
}
// if $gc_divisor is specified and is an integer number
if ($gc_divisor != "" && is_integer($gc_divisor)) {
// set the new value
@ini_set('session.gc_divisor', $gc_divisor);
}
// get session lifetime
$this->sessionLifetime = ini_get("session.gc_maxlifetime");
// register the new handler
session_set_save_handler(
array(&$this, 'open'),
array(&$this, 'close'),
array(&$this, 'read'),
array(&$this, 'write'),
array(&$this, 'destroy'),
array(&$this, 'gc')
);
register_shutdown_function('session_write_close');
// start the session
session_start();
}
/**
* Deletes all data related to the session
*
* @return void
*/
function stop()
{
$this->regenerate_id();
session_unset();
session_destroy();
}
/**
* Regenerates the session id.
*
* <b>Call this method whenever you do a privilege change!</b>
*
* @return void
*/
function regenerate_id()
{
// saves the old session's id
$oldSessionID = session_id();
// regenerates the id
// this function will create a new session, with a new id and containing the data from the old session
// but will not delete the old session
session_regenerate_id();
// because the session_regenerate_id() function does not delete the old session,
// we have to delete it manually
$this->destroy($oldSessionID);
}
/**
* Get the number of online users
*
* This is not 100% accurate. It depends on how often the garbage collector is run
*
* @return integer approximate number of users currently online
*/
function get_users_online()
{
global $db;
// counts the rows from the database
$query = $db->simple_select(TABLE_PREFIX."session_data", $fields="COUNT(session_id) as count", $conditions="online_expire > ".time()."", $options=array());
$result = $db->fetch_array($query);
// return the number of found rows
return $result["count"];
}
/**
* Custom open() function
*
* @access private
*/
function open($save_path, $session_name)
{
return true;
}
/**
* Custom close() function
*
* @access private
*/
function close()
{
return true;
}
/**
* Custom read() function
*
* @access private
*/
function read($session_id)
{
global $db;
// reads session data associated with the session id
// but only if the HTTP_USER_AGENT is the same as the one who had previously written to this session
// and if session has not expired
$result = $db->simple_select(TABLE_PREFIX."session_data", $fields="session_data", $conditions="session_id = '".$session_id."' AND http_user_agent = '".$_SERVER["HTTP_USER_AGENT"]."' AND session_expire > '".time()."'");
// if anything was found
if (is_resource($result) && @mysql_num_rows($result) > 0) {
// return found data
$fields = @mysql_fetch_assoc($result);
// don't bother with the unserialization - PHP handles this automatically
return $fields["session_data"];
}
// if there was an error return an empty string - this HAS to be an empty string
return "";
}
/**
* Custom write() function
*
* @access private
*/
function write($session_id, $session_data)
{
global $db,$settings;
// first checks if there is a session with this id
$result = $db->simple_select(TABLE_PREFIX."session_data", $fields="session_data", $conditions="session_id = '".$session_id."'");
// if there is
if (@mysql_num_rows($result) > 0) {
// update the existing session's data
// and set new expiry time
$array = array();
$array['session_data'] = $session_data;
$array['online_expire'] = (time() + $settings['online_expire_time_limit']);
$array['session_expire'] = (time() + $this->sessionLifetime);
$array['memberID'] = $_SESSION['memberID'];
$array['request_URI'] = $_SERVER['REQUEST_URI'];
$array['session_id'] = $session_id;
$result = $db->update_query(TABLE_PREFIX."session_data", $array, $where="session_id = '".$session_id."'");
// if anything happened
if (@mysql_affected_rows()) {
// return true
return true;
}
// if this session id is not in the database
} else {
// insert a new record
$array = array();
$array['session_id'] = $session_id;
$array['http_user_agent'] = $_SERVER["HTTP_USER_AGENT"];
$array['session_data'] = $session_data;
$array['IP'] = $_SERVER['REMOTE_ADDR'];
$array['online_expire'] = (time() + $settings['online_expire_time_limit']);
$array['request_URI'] = $_SERVER['REQUEST_URI'];
$array['session_expire'] = (time() + $this->sessionLifetime);
$result = $db->insert_query(TABLE_PREFIX."session_data", $array);
// if anything happened
if (@mysql_affected_rows()) {
// return an empty string
return "";
}
}
// if something went wrong, return false
return false;
}
/**
* Custom destroy() function
*
* @access private
*/
/* Destroy session record in database */
function destroy($session_id) {
$session_sql = "DELETE FROM ".TABLE_PREFIX."session_data WHERE session_id = '$session_id'";
$session_res = mysql_query($session_sql);
if (!$session_res) {
return false;
} else {
return true;
}
}
/**
* Custom gc() function (garbage collector)
*
* @access private
*/
function gc($maxlifetime)
{
global $db;
// it deletes expired sessions from database
$result = $db->delete_query(TABLE_PREFIX."session_data", $where="session_expire < '".(time() - $maxlifetime)."'");
}
}
[/PHP]
البته یکم باید تغییرش بدی چون این کلاس برای کرنل منه.
بعد می تونی تابعی بنویسی که افرادی رو که زمان انقضای سیشن آنها بیشتر از time()+10min باشه.
مثال: توابعی برای گرفتن افراد آنلاین و میهمان و کل کاربران آنلاین:
[PHP]
/**
* Get the number of online users (logged in users)
*
* This is not 100% accurate. It depends on how often the garbage collector is run
*
* @return integer approximate number of users currently online
*/
function get_users_online()
{
global $db;
// counts the rows from the database
$query = $db->simple_select(TABLE_PREFIX."session_data", $fields="COUNT(session_id) as count", $conditions="online_expire > ".time()." AND session_data LIKE '%user_session%' OR session_data LIKE '%masterUser%'", $options=array());
$result = $db->fetch_array($query);
// return the number of found rows
return $result["count"];
}
[/PHP]
و
[PHP]
function get_guest_online()
{
global $db;
// counts the rows from the database
$query = $db->simple_select(TABLE_PREFIX."session_data", $fields="COUNT(session_id) as count", $conditions="online_expire > ".time()." AND session_data NOT LIKE '%user_session%'", $options=array());
$result = $db->fetch_array($query);
// return the number of found rows
return $result["count"];
}
[/PHP]
باید روش کلی تغییرات انجام بدی تا با هسته تو سازگار بشه!!!! چون من در اینجا از چند کلاس دیگه که قبلا فراخوانی شدند استفاده کردم!!
-
-
قابلی نداره. ما همه جوره در خدمتیم!!!