public static function getCurrentUserID() { $p_userID = null; $infoHeader = getallheaders(); if (Utility::getCheckCode(Utility::getHeaderValue('Userid'), Utility::getHeaderValue('Logintime')) == Utility::getHeaderValue('Checkcode')) { $p_userID = Utility::getHeaderValue('Userid'); } if ($p_userID > 0) { $_clsHandler = USERHANDLER_NAME; $tmpModel = $_clsHandler::loadModelById($p_userID); if (is_object($tmpModel) && W2Time::getTimeBetweenDateTime($tmpModel->getLastLoginTime()) < -60 * 5) { if (method_exists($tmpModel, 'setLastLoginTime')) { $tmpModel->setLastLoginTime(W2Time::timetostr()); $tmpModel = $_clsHandler::saveModel($tmpModel); } } if (is_object($tmpModel)) { if (method_exists($tmpModel, 'getStatus')) { switch ($tmpModel->getStatus()) { case STATUS_DRAFT: //未激活 // return Utility::getArrayForResults(RUNTIME_CODE_ERROR_DATA_EMPTY,'未激活'); break; case STATUS_PENDING: //待审禁言 // return Utility::getArrayForResults(RUNTIME_CODE_ERROR_DATA_EMPTY,'禁言用户'); break; case STATUS_DISABLED: //封号 $p_userID = null; break; default: break; } } } } return $p_userID; }
/** * 时间转化成当前时间的对应关系 * @param [type] $p_datetime 待转换时间 * @return [string] 对应关系,如5分钟前 */ public static function getTimeToStringBetweenDateTimeWithToday($p_datetime) { $p_datetime = W2Time::getTimestamp($p_datetime); $_interval = W2Time::getTimeBetweenDateTime($p_datetime, time()); $_r = '未知'; if ($_interval < -60 * 60 * 24 * 30 * 12) { $_r = sprintf('%s年前 %s', 0 - intval($_interval / 60 / 60 / 24 / 30 / 12), W2Time::timetostr('m-d H:i', $p_datetime)); } else { if ($_interval < -60 * 60 * 24 * 30) { $_r = sprintf('%s月前 %s', 0 - intval($_interval / 60 / 60 / 24 / 30), W2Time::timetostr('m-d H:i', $p_datetime)); } else { if ($_interval < -60 * 60 * 24 * 7) { $_r = sprintf('%s周前 %s', 0 - intval($_interval / 60 / 60 / 24 / 7), W2Time::timetostr('m-d H:i', $p_datetime)); } else { if ($_interval < -60 * 60 * 24 * 2) { $_r = sprintf('%s天前 %s', 0 - intval($_interval / 60 / 60 / 24), W2Time::timetostr('m-d H:i', $p_datetime)); } else { if ($_interval < -60 * 60 * 24 * 2) { $_r = sprintf('%s天前 %s', 0 - intval($_interval / 60 / 60 / 24), W2Time::timetostr('m-d H:i', $p_datetime)); } else { if (W2Time::getTimeBetweenDateTime($p_datetime, date("Y-m-d 00:00:00", strtotime("-1 day"))) < 0) { $_r = sprintf('前天 %s', W2Time::timetostr('H:i:s', $p_datetime)); } else { if (W2Time::getTimeBetweenDateTime($p_datetime, date("Y-m-d 00:00:00", time())) < 0) { $_r = sprintf('昨天 %s', W2Time::timetostr('H:i:s', $p_datetime)); } else { if ($_interval < -60 * 60 * 2) { $_r = sprintf('今天 %s', W2Time::timetostr('H:i:s', $p_datetime)); } else { if ($_interval < -60 * 60) { $_r = sprintf('一小时前 %s', W2Time::timetostr('H:i:s', $p_datetime)); } else { if ($_interval < -60) { $_r = sprintf('%s分钟%s %s', 0 - intval($_interval / 60), $_isBeforeOrAfter ? '前' : '内', W2Time::timetostr('H:i:s', $p_datetime)); } else { if ($_interval < 0) { $_r = sprintf('刚才 %s', W2Time::timetostr('H:i:s', $p_datetime)); } else { if ($_interval < 60) { $_r = sprintf('马上 %s', W2Time::timetostr('H:i:s', $p_datetime)); } else { if ($_interval < 60 * 60) { $_r = sprintf('%s分钟内 %s', intval($_interval / 60), W2Time::timetostr('H:i:s', $p_datetime)); } else { if ($_interval < 60 * 60 * 2) { $_r = sprintf('一小时后 %s', W2Time::timetostr('H:i:s', $p_datetime)); } else { if (W2Time::getTimeBetweenDateTime($p_datetime, date("Y-m-d 00:00:00", strtotime("+1 day"))) < 0) { $_r = sprintf('今天 %s', W2Time::timetostr('H:i:s', $p_datetime)); } else { if (W2Time::getTimeBetweenDateTime($p_datetime, date("Y-m-d 00:00:00", strtotime("+2 day"))) < 0) { $_r = sprintf('明天 %s', W2Time::timetostr('H:i:s', $p_datetime)); } else { if ($_interval < 60 * 60 * 24 * 7) { $_r = sprintf('%s天后 %s', intval($_interval / 60 / 60 / 24), W2Time::timetostr('m-d H:i', $p_datetime)); } else { if ($_interval < 60 * 60 * 24 * 30) { $_r = sprintf('%s周后 %s', intval($_interval / 60 / 60 / 24 / 7), W2Time::timetostr('m-d H:i', $p_datetime)); } else { if ($_interval < 60 * 60 * 24 * 30 * 12) { $_r = sprintf('%s月后 %s', intval($_interval / 60 / 60 / 24 / 30), W2Time::timetostr('m-d H:i', $p_datetime)); } else { $_r = sprintf('%s年后 %s', intval($_interval / 60 / 60 / 24 / 30 / 12), W2Time::timetostr('m-d H:i', $p_datetime)); } } } } } } } } } } } } } } } } } } } return $_r; }