Merhaba intabom alt yapısı ile oynuyordum aklıma spam özelligi eklemek geldi fakat function kısmını ayarlayamadım şuan spam at dedigimde sonusuz döngüye giror işlem yapmıyor
Kod:
function SendreportAction($id) {
try {
$this->instagramReaction = new InstagramReaction($this->findAReactionUser());
} catch(\Exception $e) {
try {
$this->instagramReaction = new InstagramReaction($this->findAReactionUser());
} catch(\Exception $e) {
$this->instagramReaction = new InstagramReaction($this->findAReactionUser());
}
}
if($this->request->method == "POST") {
switch($this->request->query->formType) {
case "send":
$adet = intval($this->request->data->adet);
if($adet <= 0) {
$sonuc = array(
"status" => "error",
"code" => "nolimitdefined",
"message" => "Spam Atılamadı. Adet tanımlanmadı!",
"users" => array()
);
return $this->json($sonuc);
}
$gender = NULL;
if(intval($this->request->data->gender) > 0) {
$gender = intval($this->request->data->gender) == 2 ? 2 : 1;
}
$genderSql = "";
$arrGender = array();
if(!empty($gender)) {
$genderSql = " AND gender=:gender";
$arrGender["gender"] = $gender;
}
if($adet > Wow::get("ayar/bayiPaketBasiIstek")) {
$adet = Wow::get("ayar/bayiPaketBasiIstek");
}
$ReportUsers = array();
if(!isset($_SESSION["ReportForInstaID" . $this->request->data->userID]) || !is_array($_SESSION["ReportForInstaID" . $this->request->data->userID])) {
$nextMaxID = NULL;
$intLoop = 0;
while($report = $this->people->report($this->request->data->userID, $nextMaxID)){
$intLoop++;
foreach($report["users"] as $user) {
$ReportUsers[] = $user["pk"];
}
if(!isset($report["next_max_id"]) || $intLoop >= 8) {
break;
} else {
$nextMaxID = $report["next_max_id"];
}
}
} else {
$ReportUsers = (array)$_SESSION["ReportForInstaID" . $this->request->data->userID];
}
$triedUserIDs = isset($_SESSION["TriedUsersForReportInstaID" . $this->request->data->userID]) ? $_SESSION["TriedUsersForReportInstaID" . $this->request->data->userID] : NULL;
if(empty($triedUserIDs)) {
$triedUserIDs = "0";
}
$userIDs = "0";
foreach(explode(",", $triedUserIDs) as $userID) {
if(intval($userID) > 0) {
$userIDs .= "," . intval($userID);
}
}
$instaIDs = "0";
$ReportInstaIDs = $ReportUsers;
foreach($ReportInstaIDs as $instaID) {
if(intval($instaID) > 0) {
$instaIDs .= "," . intval($instaID);
}
}
$users = $this->db->query("SELECT uyeID,instaID,kullaniciAdi,sifre,isWebCookie FROM uye WHERE isActive=1 AND canFollow=1 and isUsable=1 AND uyeID NOT IN($userIDs) AND instaID NOT IN($instaIDs) " . $genderSql . " ORDER BY sonOlayTarihi ASC LIMIT :adet", array_merge($arrGender, array("adet" => $adet)));
if(empty($users)) {
$sonuc = array(
"status" => "error",
"code" => "nouserleft",
"message" => "Spam Atılamadı. Kullanıcı kalmadı!",
"users" => array()
);
return $this->json($sonuc);
}
$allUserIDs = array_map(function($d) {
return $d["uyeID"];
}, $users);
$allUserIDs = implode(",", $allUserIDs);
$this->db->query("UPDATE uye SET sonOlayTarihi=NOW() WHERE uyeID IN (" . $allUserIDs . ")");
$this->db->CloseConnection();
$bulkReaction = new BulkReaction($users, Wow::get("ayar/bayiEsZamanliIstek"));
$response = $bulkReaction->follow($this->request->data->userID, $this->request->data->userName);
$triedUsers = $response["users"];
$totalSuccessCount = $response["totalSuccessCount"];
$allUserIDs = array_map(function($d) {
return $d["userID"];
}, $triedUsers);
if(!empty($allUserIDs)) {
$allUserIDs = implode(",", $allUserIDs);
$userIDs .= "," . $allUserIDs;
$_SESSION["TriedUsersForReportInstaID" . $this->request->data->userID] = $userIDs;
}
$allFailedUserIDs = array_filter(array_map(function($d) {
if(isset($d["durum"]) && $d["durum"] == 0) {
$this->db->query("UPDATE uye SET isActive=2 WHERE uyeID=:uyeid", array("uyeid" => $d["userID"]));
}
return $d["status"] == "fail" ? $d["userID"] : NULL;
}, $triedUsers), function($d) {
return $d !== NULL;
});
if(!empty($allFailedUserIDs)) {
$allFailedUserIDs = implode(",", $allFailedUserIDs);
$this->db->query("UPDATE uye SET canFollow=0,canFollowControlDate=NOW() WHERE uyeID IN (" . $allFailedUserIDs . ")");
}
$sonuc = array(
"status" => "success",
"message" => "Başarılı.",
"users" => $triedUsers
);
return $this->json($sonuc);
break;
}
}
//GET Method
$user = $this->instagramReaction->objInstagram->getUserInfoById($id);
if($user["status"] != "ok") {
return $this->notFound();
}
return $this->partialView($user);
}
Moderatör tarafında düzenlendi: