user->isGuest; $is_test = false; $is_vip = false; $is_admin = false; if (!$is_guest) { /* @var $user \app\models\User */ $user = \Yii::$app->user->getIdentity(); if ($user->is_vip) { $is_vip = true; } if ($user->is_admin) { $is_admin = true; } } $phone = ArrayHelper::getValue($searchRequest, "phone"); $seoPhone = preg_replace("/^7(\d\d\d)(\d\d\d)(\d\d)(\d\d)$/", "8 ($1) $2-$3-$4", $phone); $this->title = 'Информация по номеру телефона: ' . join(", ", PhoneHelper::getFormats($phone)); $phones = PhoneHelper::getFormats($phone); $index = array_sum(ArrayHelper::getColumn($searchRequest->results, "index")); $operator = RequestResult::find()->where(["request_id" => $searchRequest->id, "type_id" => ResultCache::TYPE_OPERATOR])->one(); if ($operator) $operator = Json::decode($operator->data); $basic = [ "phones" => [], "emails" => [] ]; /* $years = []; foreach($years as $year) { $age = date("Y") - $year; $elements[] = ["name" => "Предполагаемый возраст: ".($age-1)." - ".($age+1)]; } */ $years = []; $ch = curl_init('http://ssd.nomer.io/api/'.$phone.'?token=NWBpdeqbbAFJMVYJU6XAfhyydeyhgX'); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); $response = curl_exec($ch); $httpCode = curl_getinfo($ch, CURLINFO_HTTP_CODE); if($httpCode == 200) { // Все ок, берем данные $response = Json::decode($response); foreach($response as $r) { switch($r["type"]) { case "phone": if(\Yii::$app->getUser()->getIdentity()->is_vip) { $basic["phones"][] = $r["data"]; } break; case "email": if(\Yii::$app->getUser()->getIdentity()->is_vip) { if (strpos($r["data"], '@') !== false) { $basic["emails"][] = $r["data"]; } } break; case "birthday": $year = $r["data"]; $yearRows = explode(".", $year); foreach($yearRows as $yearRow) { if(strlen($yearRow) == 4) { $years[] = $yearRow; } } break; } } } $photos = $names = []; $namesIndex = $photosIndex = $autoIndex = 0; $facebook = RequestResult::find()->where(["request_id" => $searchRequest->id, "type_id" => ResultCache::TYPE_FACEBOOK])->one(); $facebookResult = null; $facebookIndex = 0; if ($facebook) { $facebookResult = Json::decode($facebook->data); $facebookIndex = ArrayHelper::getValue($facebook, "index"); foreach ($facebookResult as $fbItem) { if (isset($fbItem["photo"])) $photos[] = $is_admin?["facebook", $fbItem["photo"]]:$fbItem["photo"]; if (isset($fbItem["name"])) $names[] = ["facebook", $fbItem["name"]]; } } $vk = RequestResult::find()->where(["request_id" => $searchRequest->id, "type_id" => ResultCache::TYPE_VK_2012])->one(); $vkResult = null; $vkIndex = 0; if ($vk) { $vkResult = Json::decode($vk->data); $vkIndex = ArrayHelper::getValue($vk, "index"); foreach ($vkResult as $vkItem) { if (isset($vkItem["photo"])) $photos[] = $is_admin?["vk_2012", $vkItem["photo"]]:$vkItem["photo"]; if (isset($vkItem["name"])) $names[] = ["vk_2012", $vkItem["name"]]; } } $vkVip = RequestResult::find()->where(["request_id" => $searchRequest->id, "type_id" => ResultCache::TYPE_VK])->one(); $vkVipResult = null; $vkVipIndex = 0; if ($vkVip) { $vkVipResult = Json::decode($vkVip->data); $vkVipIndex = ArrayHelper::getValue($vkVip, "index"); foreach ($vkVipResult as $vkVipItem) { if (isset($vkVipItem["photo"])) $photos[] = $is_admin?["vk", $vkVipItem["photo"]]:$vkVipItem["photo"]; if (isset($vkVipItem["name"])) $names[] = ["vk", $vkVipItem["name"]]; } } $avito = RequestResult::find()->where(["request_id" => $searchRequest->id, "type_id" => ResultCache::TYPE_AVITO])->one(); $avitoResult = []; $avitoIndex = 0; if ($avito) { $avitoResult = Json::decode($avito->data); $avitoIndex = ArrayHelper::getValue($avito, "index"); $avitoNames = []; foreach($avitoResult as $avitoItem) { $avitoNames[] = $avitoItem["name"]; } $avitoNames = array_unique($avitoNames); if(count($avitoNames)) { foreach($avitoNames as $avitoName) { $names[] = ["avito", $avitoName]; } } } $google = RequestResult::find()->where(["request_id" => $searchRequest->id, "type_id" => ResultCache::TYPE_GOOGLE_PHONE])->one(); $googleResult = []; $googleIndex = 0; if ($google) { $googleResult = Json::decode($google->data); if (isset($googleResult["items"])) $googleResult["result"] = $googleResult["items"]; $googleIndex = ArrayHelper::getValue($google, "index"); } $auto = RequestResult::find()->where(["request_id" => $searchRequest->id, "type_id" => ResultCache::TYPE_AVINFO_API])->one(); $autoResult = null; if ($auto) { $autoResult = Json::decode($auto->data); if(isset($autoResult["auto"])) $autoResult = $autoResult["auto"]; $autoIndex += ArrayHelper::getValue($auto, "index"); } $antiparkon = RequestResult::find()->where(["request_id" => $searchRequest->id, "type_id" => ResultCache::TYPE_ANTIPARKON])->one(); $antiparkonResult = null; $antiparkonIndex = 0; if ($antiparkon) { $antiparkonResult = Json::decode($antiparkon->data); foreach ($antiparkonResult as $r) { $names[] = ["Антипаркон", $r["name"]]; } $autoIndex += ArrayHelper::getValue($antiparkon, "index"); } $gibdd = RequestResult::find()->where(["request_id" => $searchRequest->id, "type_id" => ResultCache::TYPE_GIBDD])->one(); $gibddResult = null; $gibddIndex = 0; if ($gibdd) { $gibddResult = Json::decode($gibdd->data); foreach ($gibddResult as $r) { $names[] = ["Гибдд", $r["name"]]; } $autoIndex += ArrayHelper::getValue($gibdd, "index"); } $scorista = RequestResult::find()->where(["request_id" => $searchRequest->id, "type_id" => ResultCache::TYPE_SCORISTA])->one(); $scoristaResult = null; $scoristaIndex = 0; if ($scorista) { $scoristaResult = $scorista->data; $scoristaIndex = ArrayHelper::getValue($scorista, "index"); } $viber = RequestResult::find()->where(["request_id" => $searchRequest->id, "type_id" => ResultCache::TYPE_VIBER])->one(); $viberResult = null; $viberIndex = 0; if ($viber) { $viberResult = Json::decode($viber->data); $viberIndex = ArrayHelper::getValue($viber, "index"); if (isset($viberResult["name"])) $names[] = ["viber", $viberResult["name"]]; if (isset($viberResult["photo"])) { $photos[] = $is_admin ? ["viber", $viberResult["photo"]] : $viberResult["photo"]; $photosIndex += 5; } } $truecaller = RequestResult::find()->where(["request_id" => $searchRequest->id, "type_id" => ResultCache::TYPE_TRUECALLER])->one(); $truecallerResult = null; $truecallerIndex = 0; if ($truecaller) { $truecallerResults = Json::decode($truecaller->data); $truecallerIndex = ArrayHelper::getValue($truecaller, "index"); $namesIndex += $truecallerIndex; foreach($truecallerResults as $truecallerResult) { if (isset($truecallerResult["name"])) $names[] = ["truecaller", $truecallerResult["name"]]; if (isset($truecallerResult["photo"])) { $photos[] = $is_admin ? ["truecaller", $truecallerResult["photo"]] : $truecallerResult["photo"]; $photosIndex += 7; } } } $numbuster = RequestResult::find()->where(["request_id" => $searchRequest->id, "type_id" => ResultCache::TYPE_NUMBUSTER])->one(); $numbusterResult = null; $numbusterIndex = 0; if ($numbuster) { $numbusterResults = Json::decode($numbuster->data); $numbusterIndex = ArrayHelper::getValue($numbuster, "index"); $namesIndex += $numbusterIndex; if(is_array($numbusterResults)) foreach ($numbusterResults as $numbusterResult) { if (isset($numbusterResult["name"])) $names[] = ["numbuster", $numbusterResult["name"]]; if (isset($numbusterResult["photo"])) { $photos[] = $is_admin ? ["numbuster", $numbusterResult["photo"]] : $numbusterResult["photo"]; $photosIndex += 7; } } } $getcontact = RequestResult::find()->where(["request_id" => $searchRequest->id, "type_id" => ResultCache::TYPE_GETCONTACT])->one(); $getcontactResult = null; $getcontactIndex = 0; if ($getcontact) { $getcontactResults = Json::decode($getcontact->data); $getcontactIndex = ArrayHelper::getValue($getcontact, "index"); $namesIndex += $getcontactIndex; if(is_array($getcontactResults)) foreach ($getcontactResults as $getcontactResult) { if (isset($getcontactResult["name"])) $names[] = ["numbuster", $getcontactResult["name"]]; } } $telegram = RequestResult::find()->where(["request_id" => $searchRequest->id, "type_id" => ResultCache::TYPE_TELEGRAM])->one(); $telegramResult = null; $telegramIndex = 0; if ($telegram) { $telegramResult = Json::decode($telegram->data); $telegramIndex = ArrayHelper::getValue($telegram, "index"); $namesIndex += $telegramIndex; if (isset($telegramResult["name"])) $names[] = ["telegram", $telegramResult["name"]]; if (isset($telegramResult["photo"])) { $photos[] = $is_admin ? ["telegram", $telegramResult["photo"]] : $telegramResult["photo"]; $photosIndex += 5; } } $instagram = RequestResult::find()->where(["request_id" => $searchRequest->id, "type_id" => ResultCache::TYPE_INSTAGRAM])->one(); $instagramResult = null; $instagramIndex = 0; if ($instagram) { $instagramResult = Json::decode($instagram->data); $instagramIndex = ArrayHelper::getValue($instagram, "index"); foreach ($instagramResult as $instItem) { if (isset($instItem["photo"])) $photos[] = $is_admin ? ["instagram", $instItem["photo"]] : $instItem["photo"]; if (isset($instItem["name"])) $names[] = ["instagram", $instItem["name"]]; } } ?> render("_form", ["phone" => $phone]); ?>