<?php
    $QueueStatement = $RUNTIME['PDO']->prepare("SELECT * FROM queue WHERE QueueType = 'regionImageDownload'");
    $QueueStatement->execute(array()); 

    while($row = $QueueStatement->fetch())
    {
        $queueData = json_decode($row['QueueData']);

        if(!is_file('./data/RegionImages/'.$queueData->TargetAssetUUID.'.jpg'))
        {
            $rawImage = getDataFromHTTP($queueData->URL, "");

            file_put_contents("./data/RegionImages/".$queueData->TargetAssetUUID.".jpg", $rawImage);
        }

        $removeQueueStatement = $RUNTIME['PDO']->prepare("DELETE FROM queue WHERE QueueID = ?");
        $removeQueueStatement->execute(array($row['QueueID'])); 
    }

?>