namespace App\Http\Controllers; use App\Models\Server as Server_Model; use App\Models\Token; use App\Helpers\Anhyeuem37; use App\Helpers\Smm as Smm_Global; use App\Models\SmmPanel; use Illuminate\Support\Facades\Log; class ApiLive extends Controller { public function checkapi($order) { $server = Server_Model::where("id", $order["server"])->where("status", 1)->first(); if ($server) { if ($server->smmpanel != 0) { $partner = SmmPanel::where("id", $server->smmpanel)->where("status", 1)->first(); $response = $this->smm_order($order, $partner, $server); return array("status" => $response["status"], "message" => $response["message"], "order_api" => $response["order_api"] ?? false); } elseif ($server->token != 0) { $token = Token::find($server->token); if ($token) { if ($token->type == null && $token->name == "app.2mxh.com") { $response = $this->mxh_order($order, $token, $server); return array("status" => $response["status"], "message" => $response["message"]); } elseif ($token->type == "subgiare") { $response = $this->sgr_order($order, $token, $server); return array("status" => $response["status"], "message" => $response["message"], "order_api" => $response["order_api"] ?? false, "type" => $response["type"] ?? false); } elseif ($token->type == null && $token->name == "Minsocial") { $response = $this->Minsocial_order($order, $token, $server); return array("status" => $response["status"], "message" => $response["message"]); } return array("status" => true, "message" => "Token found"); } } } else { return array("status" => false, "message" => "Server not found or inactive"); } } public function smm_order($order, $partner, $server) { Smm_Global::init(array("link" => $partner->link, "token" => $partner->token)); $data = array("action" => "add", "service" => $server->server_smm, "link" => $order["link"]); if (isset($order["comments"]) && $order["comments"] != null) { $data["comments"] = $order["comments"]; } else { if (isset($order["quantity"]) && $order["quantity"] != null) { $data["quantity"] = $order["quantity"]; } else { $data["quantity"] = ''; } if (isset($order["reaction"]) && $order["reaction"] != null) { $data["reaction"] = $order["reaction"]; } } $response = Smm_Global::connect($data); $result = json_decode($response, true); if (!empty($result) && isset($result["order"])) { return array("status" => true, "message" => "Đặt đơn thành công", "order_api" => $result["order"] ?? false); } else { return array("status" => false, "message" => isset($result["error"]) ? $result["error"] : (isset($result["message"]) ? $result["message"] : '')); } } public function sgr_order($order, $token, $server) { $data = array("server_order" => $server->server_smm, "amount" => isset($order["quantity"]) ? $order["quantity"] : '', "note" => '', "time" => "3"); $urlParts = explode("/", parse_url($token->link, PHP_URL_PATH)); $platform = $urlParts[count($urlParts) - 3]; $serviceType = $urlParts[count($urlParts) - 2]; $serviceTypeMap = array("facebook" => array("like-post-sale" => "link_post", "comment-sale" => "link_post", "like-post-speed" => "idpost", "comment-speed" => "idpost", "eye-live" => "idpost", "share-profile" => "idpost", "view-video" => "idpost", "sub-vip" => "idfb", "sub-quality" => "idfb", "sub-speed" => "idfb", "vip-like" => "idfb", "sub-sale" => "idfb", "like-comment" => "idcomment", "like-page-speed" => "idpage", "like-page-sale" => "idpage", "like-page-quality" => "idpage", "member-group" => "idgroup", "view-story" => "link_story"), "tiktok" => array("like" => "link_video", "comment" => "link_video", "share" => "link_video", "sub" => "username", "view" => "link_video"), "instagram" => array("like-post" => "link_post", "sub" => "username")); if (array_key_exists($platform, $serviceTypeMap) && array_key_exists($serviceType, $serviceTypeMap[$platform])) { $data[$serviceTypeMap[$platform][$serviceType]] = $order["link"]; } $fields = array("reaction", "speed", "comments", "minutes", "days"); foreach ($fields as $field) { if (!empty($order[$field])) { if ($field == "comments") { $data["comment"] = preg_replace("/
?
/", "\xa", trim($order[$field])); } else { $data[$field] = $order[$field]; } } } $response = Anhyeuem37::curl_post_with_token_and_data($token->link, $data, $token->token); $result = json_decode($response, true); if ($result && is_array($result) && isset($result["status"]) && $result["status"] == true) { return array("status" => true, "message" => "Đặt đơn thành công", "order_api" => $result["data"]["code_order"] ?? false, "type" => "subgiare"); } else { return array("status" => false, "message" => $result["message"]); } } public function mxh_order($order, $token, $server) { $data = array("object_id" => $order["link"], "server_id" => $server->server_smm, "quantity" => isset($order["quantity"]) ? $order["quantity"] : ''); if (isset($order["reaction"]) && $order["reaction"] != null) { $data["reaction"] = $order["reaction"]; } $response = Anhyeuem37::curl_post_json_with_token($token->link, $data, $token->token); $result = json_decode($response, true); if ($result && is_array($result) && isset($result["status"]) && $result["status"] == 201) { return array("status" => true, "message" => "Đặt đơn thành công"); } else { return array("status" => false, "message" => $result["message"]); } } public function Minsocial_order($order, $token, $server) { $data = array("service_server_id" => $server->server_smm, "qty" => isset($order["quantity"]) ? $order["quantity"] : '', "link" => $order["link"]); $response = Anhyeuem37::curl_post_json_with_token($token->link, $data, $token->token); $result = json_decode($response, true); if ($result && is_array($result) && isset($result["status"]) && $result["status"] == 200) { return array("status" => true, "message" => "Đặt đơn thành công"); } else { return array("status" => false, "message" => $result["message"]); } } }
© 2023 Quttera Ltd. All rights reserved.