$row_cnt = mysqli_num_rows($result); if ($row_cnt == 0) { $limit = checkRateLim($connectionT); //print_r($limit); if ($limit > 0) { $row_cnt = mysqli_num_rows($result); if ($row_cnt == 0) { $user = $connectionT->get("followers/ids", array("count" => '5000')); //print_r($user); $array = $user->ids; $sql = "INSERT INTO registered (userID) VALUES({$currentUser})"; if ($conn->query($sql) === TRUE) { //echo "NEW RECORD CREATED SUCCESSFULLY"; } // print_r($array); saveConnections($currentUser, $array, $conn, $connectionT); deleteFile(); createFile(); MakeJson($currentUser, $conn); } } else { echo "Due to limitations we cannot retrieve any more data at this time. Please try again soon."; } } else { deleteFile(); createfile(); MakeJson($currentUser, $conn); } } echo "We have the data that is currently available for your network."; echo "<a href='visualisation.php'>Visualise!</a>";
function retryCall(&$boxError, $fileName, $parentID, $path, $isFile, $accessToken, &$stringArray) { // Check that there is a valid error code if (empty($boxError['code'])) { return; } if (strcmp($boxError['code'], "item_name_in_use") == 0) { // If there is already a file/folder with this name, change the filename $newName = "_" . $fileName; $boxError = createfile($newName, $parentID, $path, $isFile, $accessToken, $stringArray); } else { if (strcmp($boxError['code'], "item_name_invalid") == 0) { // If the name is invalid, remove any invalid characters // Replaces file names that are '..' or '.' if (strcmp($fileName, "..") == 0) { $fileName = "dotdot"; } else { if (strcmp($fileName, ".") == 0) { $fileName = "dot"; } } // Removes non-printable ascii characters $fileName = preg_replace('/[^[:print:]]/', '', $fileName); // Removes forward and backslashes $fileName = str_replace('/', '', $fileName); $fileName = stripslashes($fileName); // Removes leading and trailing whitespace $fileName = trim($fileName); // If we are left with an empty string, create a randomized file name if (empty($fileName)) { if ($isFile) { $fileName = "File " . rand(); } else { $fileName = "Folder " . rand(); } } $boxError = createfile($fileName, $parentID, $path, $isFile, $accessToken, $stringArray); } else { if (strcmp($boxError['code'], "item_name_too_long") == 0) { // If the file/folder name is too long, chop off the first 255 chars $fileName = substr($fileName, 0, 254); $boxError = createfile($fileName, $parentID, $path, $isFile, $accessToken, $stringArray); } else { if (strcmp($boxError['code'], "file_size_limit_exceeded") == 0) { // If the file is too big, skip it return; } else { if (strcmp($boxError['code'], "rate_limit_exceeded") == 0) { // If the rate limit was exceeded, wait 10 seconds sleep(10); $boxError = createfile($fileName, $parentID, $path, $isFile, $accessToken, $stringArray); } else { if (strcmp($boxError['code'], "unavailable") == 0) { // If the service is unavailable, wait 5 seconds sleep(5); $boxError = createfile($fileName, $parentID, $path, $isFile, $accessToken, $stringArray); } else { if (strcmp($boxError['code'], "retry_this") == 0) { // If the curl request returned an error, retry sleep(5); $boxError = createfile($fileName, $parentID, $path, $isFile, $accessToken, $stringArray); } else { // If it was any other error, we can't handle it return; } } } } } } } if (!is_array($boxError)) { array_push($stringArray, "Retry successful!"); } else { array_push($stringArray, "Retry failed"); } array_push($stringArray, "<br><br>"); }