npereira Posted February 13, 2007 Share Posted February 13, 2007 Hi all, I have a script that detects the number of active users (sessions in DB) and creates a link. The script contains code for vitis since last week, last month and all times. I need to make a porting to show visits today. From the code bellow, how would I do it for visits today? function GetActiveUserInfo($user){ global $dbconn, $smarty, $lang, $config, $config_index; $active_user_info["name"] = $user[5]; $active_user_info["show_online_str"] = GetSiteSettings("show_online_users_str"); if($active_user_info["show_online_str"] > 0){ $rs = $dbconn->Execute("select count(*) from ".USERS_TABLE." "); $active_user_info["all"] = $rs->fields[0]; $rs = $dbconn->Execute("select count(*) from ".ACTIVE_SESSIONS_TABLE." "); $active_user_info["active"] = $rs->fields[0]; $active_user_info["active_link"] = $config["site_root"].$config_index["leftmenu_path"][2]."?sel=search_on"; } $strSQL = "SELECT count(DISTINCT userid) FROM ".F_CHAT_CONNECTIONS_TABLE." WHERE userid>'0'"; $rs = $dbconn->Execute($strSQL); $active_user_info["fc_active"] = intval($rs->fields[0]); $strSQL = "SELECT COUNT(*) FROM ".UP_CHAT_ACTIVE_USERS_TABLE; $rs = $dbconn->Execute($strSQL); $active_user_info["wc_active"] = intval($rs->fields[0]); if($user[0]>0 && $user[3] != 1 && $user[4] != 1){ include_once dirname(__FILE__)."/class.percent.php"; $profile_percent = new Percent($config, $dbconn, $user[0]); //// profile complition (only for registered users) $active_user_info["completion"] = $profile_percent->GetAllPercent(); $active_user_info["profile_link"] = $config["site_root"].$config_index["leftmenu_path"][0]; $active_user_info["show_completion"] = 1; ///// all (only for registered users) $strSQL = "select count(*) from ".PROFILE_VISIT_TABLE." a, ".USERS_TABLE." b where a.id_user='".$user[0]."' and b.id=a.id_visiter and a.id_user <> a.id_visiter and b.guest_user <> '1'"; $rs = $dbconn->Execute($strSQL); $active_user_info["visit_my_page"] = $rs->fields[0]; ///// this week (only for registered users) $strSQL = "select count(*) from ".PROFILE_VISIT_TABLE." a, ".USERS_TABLE." b where a.id_user='".$user[0]."' and b.id=a.id_visiter and a.id_user <> a.id_visiter and b.guest_user <> '1' and unix_timestamp(a.visit_date)>".(mktime()-24*60*60)." "; $rs = $dbconn->Execute($strSQL); $active_user_info["visit_my_page_1"] = $rs->fields[0]; ///// this month (only for registered users) $strSQL = "select count(*) from ".PROFILE_VISIT_TABLE." a, ".USERS_TABLE." b where a.id_user='".$user[0]."' and b.id=a.id_visiter and a.id_user <> a.id_visiter and b.guest_user <> '1' and unix_timestamp(a.visit_date)>".(mktime()-30*24*60*60)." "; $rs = $dbconn->Execute($strSQL); $active_user_info["visit_my_page_2"] = $rs->fields[0]; if( $active_user_info["visit_my_page_2"] >0){ $active_user_info["show_month_visits"] = 1; } if( $active_user_info["visit_my_page_1"] >0){ $active_user_info["show_week_visits"] = 1; } if($active_user_info["visit_my_page_1"] == 0 && $active_user_info["visit_my_page_2"] ==0){ $active_user_info["show_week_visits"] = 0; $active_user_info["show_month_visits"] = 0; } $active_user_info["visitors_link"] = $config["site_root"].$config_index["leftmenu_path"][8]; $active_user_info["show_visits"] = 1; $strSQL = "Select count(*) from ".MAILBOX_TABLE." where id_to='".$user[0]."' and deleted_to='0'"; $rs = $dbconn->Execute($strSQL); $active_user_info["emailed_me_count"] = intval($rs->fields[0]); $strSQL = "Select count(*) from ".MAILBOX_TABLE." where id_to='".$user[0]."' and was_read='0' and deleted_to='0'"; $rs = $dbconn->Execute($strSQL); $active_user_info["emailed_me_new_count"] = intval($rs->fields[0]); $active_user_info["emails_link"] = $config["site_root"].$config_index["leftmenu_path"][5]; $active_user_info["show_emails"] = 1; $strSQL = "Select count(distinct a.id_from) from ".KISSLIST_TABLE." as a left join ".USERS_TABLE." as b on b.id=a.id_to where a.id_from!='".$user[0]."' and a.id_to ='".$user[0]."' and b.guest_user='0'"; $rs = $dbconn->Execute($strSQL); $active_user_info["kiss_me_count"] = intval($rs->fields[0]); $active_user_info["kisses_link"] = $config["site_root"].$config_index["leftmenu_path"][14]; $active_user_info["show_kisses"] = 1; }else{ $active_user_info["show_completion"] = 0; $active_user_info["show_visits"] = 0; $active_user_info["show_week_visits"] = 0; $active_user_info["show_month_visits"] = 0; $active_user_info["show_emails"] = 0; $active_user_info["show_kisses"] = 0; } return $active_user_info; } Link to comment https://forums.phpfreaks.com/topic/38296-need-help-with-mktime/ Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.