本文整理汇总了PHP中CVote::CheckVotingIP方法的典型用法代码示例。如果您正苦于以下问题:PHP CVote::CheckVotingIP方法的具体用法?PHP CVote::CheckVotingIP怎么用?PHP CVote::CheckVotingIP使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CVote
的用法示例。
在下文中一共展示了CVote::CheckVotingIP方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: UserAlreadyVote
public static function UserAlreadyVote($VOTE_ID, $VOTE_USER_ID, $UNIQUE_TYPE, $KEEP_IP_SEC, $USER_ID = false)
{
global $DB, $USER;
$err_mess = CAllVote::err_mess() . "<br>Function: UserAlreadyVote<br>Line: ";
$VOTE_ID = intval($VOTE_ID);
$UNIQUE_TYPE = intval($UNIQUE_TYPE);
$VOTE_USER_ID = intval($VOTE_USER_ID);
$USER_ID = intval($USER_ID);
if ($VOTE_ID <= 0) {
return false;
}
if ($UNIQUE_TYPE <= 0) {
return false;
}
if ($UNIQUE_TYPE > 4) {
$UNIQUE_TYPE -= 5;
}
//No restrictions
if ($UNIQUE_TYPE <= 0) {
return false;
}
//One session
if ($UNIQUE_TYPE & 1 && IsModuleInstalled('statistic') && is_array($_SESSION["VOTE_ARRAY"]) && in_array($VOTE_ID, $_SESSION["VOTE_ARRAY"])) {
return 1;
}
$arSqlSearch = array();
$arSqlSelect = array("VE.ID");
//Same cookie
if ($UNIQUE_TYPE & 2) {
if ($VOTE_USER_ID > 0 && $UNIQUE_TYPE != 6) {
$arSqlSelect[] = "VE.VOTE_USER_ID";
$arSqlSearch[] = "VE.VOTE_USER_ID='" . $VOTE_USER_ID . "'";
}
}
// Same IP
if ($UNIQUE_TYPE & 4) {
$tmp = CVote::CheckVotingIP($VOTE_ID, $_SERVER["REMOTE_ADDR"], $KEEP_IP_SEC, array("RETURN_SEARCH_ARRAY" => "Y"));
if (is_array($tmp)) {
$arSqlSelect[] = $tmp["select"];
$arSqlSearch[] = $tmp["search"];
} else {
return 4;
}
}
// Same ID
if ($UNIQUE_TYPE & 8) {
if ($USER_ID <= 0 || $USER_ID == $USER->GetID() && !!$_SESSION["VOTE"]["VOTES"][$VOTE_ID]) {
return 8;
} else {
if ($UNIQUE_TYPE & 16) {
$rUser = CUser::GetByID($USER_ID);
if ($rUser && ($arUser = $rUser->Fetch())) {
$userRegister = MakeTimeStamp($arUser['DATE_REGISTER']);
$rVote = CVote::GetByID($VOTE_ID);
if ($rVote && ($arVote = $rVote->Fetch())) {
$voteStart = MakeTimeStamp($arVote['DATE_START']);
if ($userRegister > $voteStart) {
return 16;
}
}
}
}
$arSqlSelect[] = "VU.AUTH_USER_ID";
$arSqlSearch[] = "VU.AUTH_USER_ID=" . $USER_ID;
}
}
if (!empty($arSqlSearch)) {
$strSql = "SELECT " . implode(",", $arSqlSelect) . "\n\t\t\t\tFROM b_vote_event VE\n\t\t\t\tLEFT JOIN b_vote_user VU ON (VE.VOTE_USER_ID = VU.ID)\n\t\t\t\tWHERE VE.VOTE_ID=" . $VOTE_ID . " AND ((" . implode(") OR (", $arSqlSearch) . "))";
$db_res = $DB->Query($strSql, false, $err_mess . __LINE__);
if ($db_res && ($res = $db_res->Fetch())) {
$return = 16;
$event_id = 0;
do {
if ($UNIQUE_TYPE & 2 && $res["VOTE_USER_ID"] == $VOTE_USER_ID) {
$return = min($return, 2);
break;
} elseif ($UNIQUE_TYPE & 4 && $res["IP"] == $_SERVER["REMOTE_ADDR"] && ($KEEP_IP_SEC <= 0 || $KEEP_IP_SEC > $res["KEEP_IP_SEC"])) {
$return = min($return, 4);
} elseif ($UNIQUE_TYPE & 8 && $res["AUTH_USER_ID"] == $USER_ID) {
$return = min($return, 8);
$event_id = $event_id > 0 && $USER_ID == $USER->GetID() ? $event_id : intval($res["ID"]);
}
} while ($res = $db_res->Fetch());
if ($event_id > 0) {
$_SESSION["VOTE"]["VOTES"][$VOTE_ID] = $event_id;
}
return $return != 16 ? $return : true;
}
}
return false;
}