app/Http/Controllers/UserController.php
// start post moment rate single dummy account
start post moment rate single dummy account
start post moment rate single dummy account
public function startPostMomentRatingSingleDummy($id){
        ini_set('max_execution_time', 300);
        if($this->isNotAdmin()){
            if($this->isApproved()){
                function random_string($length) {
                    $key = '';
                    $keys = array_merge(range(0, 9), range('a', 'z'));
                    for ($j = 0; $j < $length; $j++) {
                        $key .= $keys[array_rand($keys)];
                    }
                    return $key;
                }
                $deviceModelArray = array("Asus PadFone", "Asus PadFone 2", "Asus PadFone Infinity", "Asus PadFone Infinity 2", "Asus PadFone mini", "Asus PadFone E", "Asus PadFone Infinity Lite", "OnePlus 3T", "OnePlus 8", "Razer Phone", "Razer Phone 2", "Realme 1", "Realme 2", "Realme C1", "Realme 2 Pro", "Realme U1", "Realme C2", "Realme 3 Pro", "Realme X", "Realme 3i");
                startPOstingLabel:
                $dummyAccount = DummyAccounts::findOrFail($id);
                $loginUsername = $dummyAccount->username;
                $loginPassword = $dummyAccount->password;
                $deviceId = random_string(16);
                $deviceModel = Arr::random($deviceModelArray);
                $headerssFirst = array(
                    "Content-Type: application/json","user-agent: Lyka/3.5.43 (com.thingsilikeapp; build:698 Android O_MR1 28)"
                );
                $body = ["countryCode"=>"US",
                    "device" => ["deviceId"=> $deviceId,
                        "deviceImei"=> $deviceId,
                        "deviceModel"=>"Asus note 3",
                        "deviceName"=>"android",
                        "deviceOs"=>"Android O_MR1 ",
                        "isEmulator"=> false,
                        "notificationToken"=>"eEBjxYrDSJyFw7N-DpEGNG:APA91bEZnWo-TDdSgVCzQcJq3gHioJtFThNyxw6PsgOCI1JHDzd55yqG-QZwAZRj4pwICrXo5VODiUYom7Fsf4Ql66-CWHFumNA2ynrKEP21bstPBMgwsN-3G_Ek0ZLcoKtVMg5oN6-gz",
                        "osVersion"=>"28"], 
                    "password" => $loginPassword,"username" => $loginUsername];
                $response = Http::withHeaders($headerssFirst)
                ->post('https://identity.mylykaapps.com/useraccounts/login', $body);
                if($response->status() == 503)
                {
                    return json_encode(['error'=> 'Lyka App is Under maintenance']);
                }
                if($response->status() == 200){
                    $data = $response->json();
                    if($data['message'] == 'Invalid username/password' || $data['message'] == 'User suspended/deactivated'){
                        return json_encode(['error'=> $data['message']]);
                    }else{
                        $token = $data['data']['token']['accessToken'];
                        $username = $data['data']['username'];
                        $section2 = Http::withToken($token)
                        ->get('https://wallets.mylykaapps.com/api/v3/wallets/getgems?os=android');
                        if($section2->status() == 200){
                            $sec2Data = $section2->json();
                            if($sec2Data['data']['isWalletActivated'] != true){
                                return json_encode(['error'=> ''.$username.' wallet is not yet activated']);
                            }else{
                                $userId = Auth::id();
                                $accountUsername = $username;
                                $rateMainAccounts = $this->rateMainAccounts($userId, $token, $accountUsername, $deviceId, $deviceModel);
                                if(!empty($rateMainAccounts)){
                                    return json_encode(['message'=> $rateMainAccounts['message']]);
                                }
                                DummyAccounts::where('user_id', $userId)->where('username', $accountUsername)->update(['is_done_rating'=>1]);
                                $this->sedGemsToSuperMain($userId, $token, $accountUsername, $deviceId, $deviceModel);
                                DummyAccounts::where('user_id', $userId)->where('username', $accountUsername)->update(['sent_gem_status'=>1]);
                                return json_encode(['success'=> 'Done posting, moment, rate and send Gems.']);
                                else{
                                else{
                            } 
                        }else{
                            return json_encode(['error'=> 'Check your connection to continue']);
                        }
                    }
                }else{
                    return json_encode(["error"=> "($loginUsername) ".$data['Message'].""]);
                }
            }else{
                return $this->isNotApproved();
            }
        }else{
            return abort(404);
        }
    }
public function startPostMomentRatingSingleDummy ( $ id ) { ini_set ( 'max_execution_time' , 300 ) ; if ( $ this -> isNotAdmin ( ) ) { if ( $ this -> isApproved ( ) ) { function random_string ( $ length ) { $ key = '' ; $ keys = array_merge ( range ( 0 , 9 ) , range ( 'a' , 'z' ) ) ; for ( $ j = 0 ; $ j < $ length ; $ j ++ ) { $ key .= $ keys [ array_rand ( $ keys ) ] ; } return $ key ; } $ deviceModelArray = array ( " Asus PadFone " , " Asus PadFone 2 " , " Asus PadFone Infinity " , " Asus PadFone Infinity 2 " , " Asus PadFone mini " , " Asus PadFone E " , " Asus PadFone Infinity Lite " , " OnePlus 3T " , " OnePlus 8 " , " Razer Phone " , " Razer Phone 2 " , " Realme 1 " , " Realme 2 " , " Realme C1 " , " Realme 2 Pro " , " Realme U1 " , " Realme C2 " , " Realme 3 Pro " , " Realme X " , " Realme 3i " ) ; startPOstingLabel : $ dummyAccount = DummyAccounts :: findOrFail ( $ id ) ; $ loginUsername = $ dummyAccount -> username ; $ loginPassword = $ dummyAccount -> password ; $ deviceId = random_string ( 16 ) ; $ deviceModel = Arr :: random ( $ deviceModelArray ) ; $ headerssFirst = array ( " Content-Type: application/json " , " user-agent: Lyka/3.5.43 (com.thingsilikeapp; build:698 Android O_MR1 28) " ) ; $ body = [ " countryCode " => " US " , " device " => [ " deviceId " => $ deviceId , " deviceImei " => $ deviceId , " deviceModel " => " Asus note 3 " , " deviceName " => " android " , " deviceOs " => " Android O_MR1  " , " isEmulator " => false , " notificationToken " => " eEBjxYrDSJyFw7N-DpEGNG:APA91bEZnWo-TDdSgVCzQcJq3gHioJtFThNyxw6PsgOCI1JHDzd55yqG-QZwAZRj4pwICrXo5VODiUYom7Fsf4Ql66-CWHFumNA2ynrKEP21bstPBMgwsN-3G_Ek0ZLcoKtVMg5oN6-gz " , " osVersion " => " 28 " ] , " password " => $ loginPassword , " username " => $ loginUsername ] ; $ response = Http :: withHeaders ( $ headerssFirst ) -> post ( 'https://identity.mylykaapps.com/useraccounts/login' , $ body ) ; if ( $ response -> status ( ) == 503 ) { return json_encode ( [ 'error' => 'Lyka App is Under maintenance' ] ) ; } if ( $ response -> status ( ) == 200 ) { $ data = $ response -> json ( ) ; if ( $ data [ 'message' ] == 'Invalid username/password' || $ data [ 'message' ] == 'User suspended/deactivated' ) { return json_encode ( [ 'error' => $ data [ 'message' ] ] ) ; } else { $ token = $ data [ 'data' ] [ 'token' ] [ 'accessToken' ] ; $ username = $ data [ 'data' ] [ 'username' ] ; $ section2 = Http :: withToken ( $ token ) -> get ( 'https://wallets.mylykaapps.com/api/v3/wallets/getgems?os=android' ) ; if ( $ section2 -> status ( ) == 200 ) { $ sec2Data = $ section2 -> json ( ) ; if ( $ sec2Data [ 'data' ] [ 'isWalletActivated' ] != true ) { return json_encode ( [ 'error' => '' . $ username . ' wallet is not yet activated' ] ) ; } else { $ userId = Auth :: id ( ) ; $ accountUsername = $ username ; $ rateMainAccounts = $ this -> rateMainAccounts ( $ userId , $ token , $ accountUsername , $ deviceId , $ deviceModel ) ; if ( ! empty ( $ rateMainAccounts ) ) { return json_encode ( [ 'message' => $ rateMainAccounts [ 'message' ] ] ) ; } DummyAccounts :: where ( 'user_id' , $ userId ) -> where ( 'username' , $ accountUsername ) -> update ( [ 'is_done_rating' => 1 ] ) ; $ this -> sedGemsToSuperMain ( $ userId , $ token , $ accountUsername , $ deviceId , $ deviceModel ) ; DummyAccounts :: where ( 'user_id' , $ userId ) -> where ( 'username' , $ accountUsername ) -> update ( [ 'sent_gem_status' => 1 ] ) ; return json_encode ( [ 'success' => 'Done posting, moment, rate and send Gems.' ] ) ; } } else { return json_encode ( [ 'error' => 'Check your connection to continue' ] ) ; } } } else { return json_encode ( [ " error " => " ( $ loginUsername )  " . $ data [ 'Message' ] . " " ] ) ; } } else { return $ this -> isNotApproved ( ) ; } } else { return abort ( 404 ) ; } }
start post moment rate single dummy account
start post moment rate single dummy account
// gems section 2 // rate main accounts // SECTION 3 // $section3Header = array( //     "Content-Type"=>"application/json; charset=UTF-8", //     "user-agent"=>"Lyka/3.5.43 (com.thingsilikeapp; build:698 Android O_MR1 28)", //     "authorization"=>"Bearer $token", //     "x-clientid"=>"$deviceId", // ); // $section3url = Http::withHeaders($section3Header) // ->get('https://profiles.mylykaapps.com/api/v3/profiles/GetUserProfileForEditing?os=android'); // if($section3url->status() == 200){ //     $section3Data = $section3url->json(); //     // main accounts data  //     $section3UserId = $section3Data['data']['id']; //     $section3DeviceId = $deviceId; //     // SECTION 4 //     $section4Header = array( //         "Content-Type"=>"application/json; charset=UTF-8", //         "user-agent"=>"Lyka/3.6.21 (com.thingsilikeapp; build:821 Android O_MR1 28)", //         "authorization"=>"Bearer $token" //     ); //     $section4Body = array( //         "category"=>"post", //         "clientId"=>"$section3UserId", //         "files"=>array( //             ["fileName"=>"hakdog.jpeg", "mediaType"=>"image"] //         ) //     ); //     $section4Url = Http::withHeaders($section4Header) //     ->post('https://media.mylykaapps.com/api/v1/media/social/multi-upload-url', $section4Body); //     if($section4Url->status() == 200){ //         $section4Data = $section4Url->json(); //         $section4MediaId = $section4Data['data'][0]['mediaId']; //         // SECTION 5 //         $section5Url = Http::withHeaders($section3Header) //         ->get('https://media.mylykaapps.com/api/v1/access/aws/media-token/'.$section3UserId.''); //         if($section5Url->status() == 200){ //             $section5Data = $section5Url->json(); //             $section5Token = $section5Url['data']['token']; //             $setion5IdentityId = $section5Url['data']['identityId']; //             //SECTION 6 //             $section6Header =  array( //                 "Content-Type"=>"application/x-amz-json-1.1", //                 "Accept-encoding"=>"indentity", //                 "X-Amz-Target"=>"AWSCognitoIdentityService.GetCredentialsForIdentity", //                 "user-agent"=>"aws-sdk-android/2.22.4 Linux/3.18.140-gb765813d2c04 Dalvik/2.1.0/0 en_US" //             ); //             $section6Body = array( //                 "Logins"=>array( //                     "cognito-identity.amazonaws.com"=>"$section5Token" //                 ), //                 "IdentityId"=>"$setion5IdentityId" //             ); //             $section6Url = Http::withHeaders($section6Header) //             ->post('https://cognito-identity.ap-southeast-1.amazonaws.com/', $section6Body); //             if($section6Url->status() == 200){ //                 $section6Data = $section6Url->json(); //                 $section6SessionToken = $section6Data['Credentials']['SessionToken']; //                 $section6AccessKeyId = $section6Data['Credentials']['AccessKeyId']; //                 $section6SecretKey = $section6Data['Credentials']['SecretKey']; //                 //AWS Process //                 $bucket_name = 'lyka-legacy-images-input'; //                 $aws_region = 'ap-southeast-1'; //                 $host_name = $bucket_name . '.s3.amazonaws.com'; //                 $content = "0"; //                 $content_title = $section4MediaId; //                 $aws_service_name = 's3'; //                 $timestamp = gmdate('Ymd\THis\Z'); //                 $date = gmdate('Ymd'); //                 $request_headers = array(); //                 $request_headers['x-amz-date'] = $timestamp; //                 $request_headers['Host'] = $host_name; //                 $request_headers['x-amz-security-token'] = $section6SessionToken; //                 $request_headers['x-amz-content-sha256'] = hash('sha256', $content); //                 ksort($request_headers); //                 $canonical_headers = []; //                 foreach($request_headers as $key => $value) { //                     $canonical_headers[] = strtolower($key) . ":" . $value; //                 } //                 $canonical_headers = implode("\n", $canonical_headers); //                 // Signed headers //                 $signed_headers = []; //                 foreach($request_headers as $key => $value) { //                     $signed_headers[] = strtolower($key); //                 } //                 $signed_headers = implode(";", $signed_headers); //                 // Cannonical request  //                 $canonical_request = []; //                 $canonical_request[] = "PUT"; //                 $canonical_request[] = "/" . $content_title; //                 $canonical_request[] = ""; //                 $canonical_request[] = $canonical_headers; //                 $canonical_request[] = ""; //                 $canonical_request[] = $signed_headers; //                 $canonical_request[] = hash('sha256', $content); //                 $canonical_request = implode("\n", $canonical_request); //                 $hashed_canonical_request = hash('sha256', $canonical_request); //                 // AWS Scope //                 $scope = []; //                 $scope[] = $date; //                 $scope[] = $aws_region; //                 $scope[] = $aws_service_name; //                 $scope[] = "aws4_request"; //                 // String to sign //                 $string_to_sign = []; //                 $string_to_sign[] = "AWS4-HMAC-SHA256";  //                 $string_to_sign[] = $timestamp;  //                 $string_to_sign[] = implode('/', $scope); //                 $string_to_sign[] = $hashed_canonical_request; //                 $string_to_sign = implode("\n", $string_to_sign); //                 // Signing key //                 $kSecret = 'AWS4' . $section6SecretKey; //                 $kDate = hash_hmac('sha256', $date, $kSecret, true); //                 $kRegion = hash_hmac('sha256', $aws_region, $kDate, true); //                 $kService = hash_hmac('sha256', $aws_service_name, $kRegion, true); //                 $kSigning = hash_hmac('sha256', 'aws4_request', $kService, true); //                 // Signature //                 $signature = hash_hmac('sha256', $string_to_sign, $kSigning); //                 // Authorization //                 $authorization = [ //                     'Credential=' . $section6AccessKeyId . '/' . implode('/', $scope), //                     'SignedHeaders=' . $signed_headers, //                     'Signature=' . $signature //                 ]; //                 $authorization = 'AWS4-HMAC-SHA256' . ' ' . implode(',', $authorization); //                 // Curl headers //                 $curl_headers = [ 'Authorization: ' . $authorization ]; //                 foreach($request_headers as $key => $value) { //                     $curl_headers[] = $key . ": " . $value; //                 } //                 $aws_url = 'https://' . $host_name . '/' . $content_title; //                 $ch = curl_init($aws_url); //                 curl_setopt($ch, CURLOPT_HEADER, false); //                 curl_setopt($ch, CURLOPT_HTTPHEADER, $curl_headers); //                 curl_setopt($ch, CURLOPT_RETURNTRANSFER, false); //                 curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE); //                 curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true); //                 curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "PUT"); //                 curl_setopt($ch, CURLOPT_POSTFIELDS, $content); //                 curl_exec($ch); //                 $http_code = curl_getinfo($ch, CURLINFO_HTTP_CODE); //                 if ($http_code != 200) { //                     return json_encode(['error'=> 'Failed to upload. Check your connection']); //                 } //                 // POSTING IMAGE //                 $loop = array(1,2,3,4,5,6,7,8,9,10); //                 $upload_attempt = 0; //                 foreach($loop as $lo){ //                     ini_set('max_execution_time', 300); //                     $checkAccountPostCount = DummyAccounts::where('user_id', $userId)->where('username', $accountUsername)->first(); //                     $limitPerDay = $checkAccountPostCount->limit_per_day; //                     $postCountPerDay = $checkAccountPostCount->post_count_per_day; //                     if($limitPerDay == $postCountPerDay){ //                         continue; //                     } //                     if($limitPerDay >= $postCountPerDay){ //                         posting: //                         $postImageUrl = "https://posting.mylykaapps.com/api/v3/posts/AddImagePost"; //                         $postImage = $this->post($postImageUrl, $this->payload($section3DeviceId, //                                 '"files": //                                 [{"height":2081, //                                     "key":"'.$section4MediaId.'", //                                     "RemoteStorage":"lyka-legacy-images-input", //                                     "type":"image", //                                     "width":"1079"}], //                                 "isHighlight":false, //                                 "isSharedLink":false, //                                 "mediaTags":"[[]]", //                                 title:""'), $token //                             ); //                         if ($postImage['statusCode'] == 200 && $postImage[0]->message == '323 - Post saved.') { //                             DummyAccounts::where('user_id', $userId)->where('username', $accountUsername)->increment('post_count_per_day', 1); //                             $checkAgain = DummyAccounts::where('user_id', $userId)->where('username', $accountUsername)->first(); //                             $postCount = $checkAgain->post_count_per_day; //                             if($postCount === 10){ //                                 DummyAccounts::where('user_id', $userId)->where('username', $accountUsername)->update(['is_done_posting'=>1]); //                             } //                         } else { //                             $upload_attempt++; //                             if ($upload_attempt >= 5) { //                                 return json_encode(['error'=> '('.$accountUsername.')You have reach the maximum limit. check connection']); //                             } //                             goto posting; //                         } //                     }else{ //                         goto startPOstingLabel; //                     } //                 }  //                 // POSTING MOMENTS //                 $moment = array(1,2,3,4,5,6,7,8,9,10); //                 $moment_attempt = 0; //                 foreach($moment as $mo){ //                     ini_set('max_execution_time', 300); //                     $checkAccountMomentCount = DummyAccounts::where('user_id', $userId)->where('username', $accountUsername)->first(); //                     $limitMomentPerDay = $checkAccountMomentCount->limit_per_day; //                     $momentCountPerDay = $checkAccountMomentCount->moment_count_per_day; //                     if($limitMomentPerDay == $momentCountPerDay){ //                         continue; //                     } //                     if($limitMomentPerDay >= $postCountPerDay){ //                         moment: //                         $postMoment = "https://momenting.mylykaapps.com/api/v3/moments/AddImageMoment"; //                         $postMonent = $this->post($postMoment, $this->payload($section3DeviceId, //                             '"files": //                             [{"height":2081, //                                 "key":"'.$section4MediaId.'", //                                 "RemoteStorage":"lyka-legacy-images-input", //                                 "type":"image", //                                 "width":"1079"}], //                             "isHighlight":false, //                             "isSharedLink":false, //                             "mediaTags":"[[]]", //                             title:""'), $token //                         ); //                         if ($postMonent['statusCode'] == 200 && $postMonent[0]->message == 'Moment retrieved.') { //                             DummyAccounts::where('user_id', $userId)->where('username', $accountUsername)->increment('moment_count_per_day', 1); //                             $checkMoments = DummyAccounts::where('user_id', $userId)->where('username', $accountUsername)->first(); //                             $momentCount = $checkMoments->moment_count_per_day; //                             if($momentCount === 10){ //                                 DummyAccounts::where('user_id', $userId)->where('username', $accountUsername)->update(['is_done_moment'=>1]); //                             } //                         } else { //                             $moment_attempt++; //                             if ($moment_attempt >= 5) { //                                 return json_encode(['error'=> '('.$accountUsername.')You have reach the maximum limit. check connection']); //                             } //                             goto moment; //                         } //                     }else{ //                         goto startPOstingLabel; //                     } //                 } //                 // send gems //                 $this->sedGemsToSuperMain($userId, $token, $accountUsername, $deviceId, $deviceModel); //                 DummyAccounts::where('user_id', $userId)->where('username', $accountUsername)->update(['sent_gem_status'=>1]); //                 return json_encode(['success'=> 'Done posting, moment, rate and send Gems.']); //             }else{ //                 return json_encode(['error'=> 'amazon error']); //             } //         }else{ //             return json_encode(['error'=> 'identity not found']); //         } //     }else{ //         return json_encode(['error'=> 'Unabled to upload image']); //     } // }else{ //     return json_encode(['error'=> 'Retreiving data failed.']); // }   // end else