Пример #1
0
 public static function Insert($data, $settings, $marathon, $campaign, $database)
 {
     if (!Authorization::IsAuthorized($settings)) {
         return new ZdpArrayObject(['error' => 'You are not authorized to perform this action.']);
     }
     $playerID;
     $gameID;
     $scheduleStartTime;
     $scheduleEndTime;
     $scheduleUnlockAmount;
     $error = false;
     $errorMessage;
     if (array_key_exists('PlayerID', $data)) {
         $playerID = $data['PlayerID'];
     } else {
         $error = true;
         $errorMessage = 'No player id was provided.';
     }
     if (array_key_exists('GameID', $data)) {
         $gameID = $data['GameID'];
     } else {
         $error = true;
         $errorMessage = 'No game id was provided.';
     }
     if (array_key_exists('StartTime', $data)) {
         $scheduleStartTime = $data['StartTime'];
     } else {
         $error = true;
         $errorMessage = 'No start time was provided.';
     }
     if (array_key_exists('EndTime', $data)) {
         $scheduleEndTime = $data['EndTime'];
     } else {
         $error = true;
         $errorMessage = 'No end time was provided.';
     }
     if (array_key_exists('UnlockAmount', $data)) {
         $scheduleUnlockAmount = $data['UnlockAmount'];
     } else {
         $error = true;
         $errorMessage = 'No unlock amount was provided.';
     }
     if ($database instanceof ZdpArrayObject) {
         $error = true;
         $errorMessage = $database['error'];
     }
     if (!$error) {
         $sql = 'CALL sp_insert_schedule (:game_id, :campaign_id, :player_id, :schedule_endtime, :schedule_starttime, :schedule_unlockamount)';
         $statement = $database->prepare($sql);
         if ($statement->execute([':game_id' => $gameID, ':campaign_id' => $campaign, ':player_id' => $playerID, ':schedule_starttime' => $scheduleStartTime, ':schedule_endtime' => $scheduleEndTime, ':schedule_unlockamount' => $scheduleUnlockAmount])) {
             $schedules = $statement->fetchAll(PDO::FETCH_ASSOC);
             $output = new ZdpArrayObject(['result' => new ZdpArrayObject(['schedule' => $schedules])]);
         } else {
             $output = new ZdpArrayObject(['error' => $statement->errorInfo()]);
         }
     } else {
         $output = new ZdpArrayObject(['error' => $errorMessage]);
     }
     return $output;
 }
Пример #2
0
 public static function Insert($data, $settings, $marathon, $campaign, $database)
 {
     if (!Authorization::IsAuthorized($settings)) {
         return new ZdpArrayObject(['error' => 'You are not authorized to perform this action.']);
     }
     $playerName;
     $error = false;
     if (array_key_exists('name', $POST) && trim($_POST['name']) != '') {
         $playerName = $_POST['name'];
     } else {
         $error = true;
         $errorMessage = 'No player name was provided.';
     }
     if ($database instanceof ZdpArrayObject) {
         $error = true;
         $errorMessage = $database['error'];
     }
     if (!$error) {
         $sql = 'CALL sp_insert_player (:campaign_id, :marathon_id, :player_name)';
         $statement = $database->prepare($sql);
         if ($statement->execute([':marathon_id' => $marathon, ':campaign_id' => $campaign, ':player_name' => $playerName])) {
             $players = $statement->fetchAll(PDO::FETCH_ASSOC);
             $output = new ZdpArrayObject(['result' => new ZdpArrayObject(['player' => $players])]);
         } else {
             $output = new ZdpArrayObject(['error' => $statement->errorInfo()]);
         }
     } else {
         $output = new ZdpArrayObject(['error' => $errorMessage]);
     }
     return $output;
 }
Пример #3
0
 public static function Insert($data, $settings, $marathon, $campaign, $database)
 {
     if (!Authorization::IsAuthorized($settings)) {
         return new ZdpArrayObject(['error' => 'You are not authorized to perform this action.']);
     }
     $fileDefinitionLimit;
     $fileDefinitionName;
     $gameId;
     $error = false;
     $errorMessage;
     $output;
     if (array_key_exists('Limit', $data)) {
         $fileDefinitionLimit = $data['Limit'];
     } else {
         $error = true;
         $errorMessage = 'No limit was provided.';
     }
     if (array_key_exists('Name', $data)) {
         $fileDefinitionName = $data['Name'];
     } else {
         $error = true;
         $errorMessage = 'No name was provided.';
     }
     if (array_key_exists('GameId', $data)) {
         $gameId = $data['GameId'];
     } else {
         $error = true;
         $errorMessage = 'No game Id was provided.';
     }
     if ($database instanceof ZdpArrayObject) {
         $error = true;
         $errorMessage = $database['error'];
     }
     if (!$error) {
         $sql = 'CALL sp_insert_filedefinition (:campaign_id, :marathon_id, :game_id, :filedefinition_limit, :filedefinition_name)';
         $statement = $database->prepare($sql);
         if ($statement->execute([':campaign_id' => $campaign, ':marathon_id' => $marathon, ':game_id' => $gameId, ':filedefinition_limit' => $fileDefinitionLimit, ':filedefinition_name' => $fileDefinitionName])) {
             $return = $statement->fetchAll(PDO::FETCH_ASSOC)[0]['Id'];
             $output = new ZdpArrayObject(['result' => new ZdpArrayObject(['fileDefinitionId' => $return])]);
         } else {
             $output = new ZdpArrayObject(['error' => $statement->errorInfo()]);
         }
     } else {
         $output = new ZdpArrayObject(['error' => $errorMessage]);
     }
     return $output;
 }
Пример #4
0
 public static function Insert($data, $settings, $marathon, $campaign, $database)
 {
     if (!Authorization::IsAuthorized($settings)) {
         return new ZdpArrayObject(['error' => 'You are not authorized to perform this action.']);
     }
     $fileDefinitionId;
     $fileSuggestionName;
     $gameId;
     $error = false;
     $errorMessage;
     $output;
     if (array_key_exists('FileDefinitionId', $data)) {
         $fileDefinitionId = $data['FileDefinitionId'];
     } else {
         $error = true;
         $errorMessage = 'No file definition ID was provided.';
     }
     if (array_key_exists('Name', $data)) {
         $fileSuggestionName = $data['Name'];
     } else {
         $error = true;
         $errorMessage = 'No name was provided.';
     }
     if ($database instanceof ZdpArrayObject) {
         $error = true;
         $errorMessage = $database['error'];
     }
     if (!$error) {
         $fileDefinitionStatement = $database->prepare('SELECT * FROM filedefinitions WHERE filedefinition_id = :fileDefinitionId AND marathon_id = :marathon_id AND campaign_id = :campaign_id LIMIT 1');
         if ($fileDefinitionStatement->execute([':fileDefinitionId' => $fileDefinitionId, ':marathon_id' => $marathon, ':campaign_id' => $campaign])) {
             if ($fileDefinitionStatement->rowCount() == 0) {
                 $error = true;
                 $errorMessage = 'No file definition found for that id.';
             } else {
                 $fileDefinition = $fileDefinitionStatement->fetch(PDO::FETCH_ASSOC);
                 if (strlen($fileSuggestionName) > $fileDefinition['filedefinition_limit']) {
                     $error = true;
                     $errorMessage = 'Provided file name is too long. It can only be ' . $fileDefinition['filedefinition_limit'] . ' characters long.';
                 }
             }
         } else {
             $error = true;
             $errorMessage = $statement->errorInfo();
         }
         if (!$error) {
             $sql = 'CALL sp_insert_filesuggestions (:campaign_id, :filedefinition_id, :filesuggestion_name, :marathon_id)';
             $statement = $database->prepare($sql);
             if ($statement->execute([':campaign_id' => $campaign, ':marathon_id' => $marathon, ':filedefinition_id' => $fileDefinitionId, ':filesuggestion_name' => $fileSuggestionName])) {
                 $return = $statement->fetchAll(PDO::FETCH_ASSOC)[0]['Id'];
                 $output = new ZdpArrayObject(['result' => new ZdpArrayObject(['fileDefinitionId' => $return])]);
             } else {
                 $output = new ZdpArrayObject(['error' => $statement->errorInfo()]);
             }
         } else {
             $output = new ZdpArrayObject(['error' => $errorMessage]);
         }
     } else {
         $output = new ZdpArrayObject(['error' => $errorMessage]);
     }
     return $output;
 }
Пример #5
0
 /**
  */
 static function Insert($data, $settings, $marathon, $campaign, $database)
 {
     if (!Authorization::IsAuthorized($settings)) {
         return new ZdpArrayObject(['error' => 'You are not authorized to perform this action.']);
     }
     $donationName;
     $donationEmail;
     $donationComment;
     $donationAmount;
     $donationProcessed;
     $donationTimestamp;
     $error = false;
     $errorMessage;
     $output;
     if (array_key_exists('Name', $data)) {
         $donationName = $data['Name'];
     } else {
         $error = true;
         $errorMessage = 'No name was provided.';
     }
     if (array_key_exists('Email', $data)) {
         $donationEmail = $data['Email'];
     } else {
         $error = true;
         $errorMessage = 'No email was provided.';
     }
     if (array_key_exists('Comment', $data)) {
         $donationComment = $data['Comment'];
     } else {
         $error = true;
         $errorMessage = 'No comment was provided.';
     }
     if (array_key_exists('Amount', $data)) {
         $donationAmount = $data['Amount'];
     } else {
         $error = true;
         $errorMessage = 'No donation amount was provided.';
     }
     if (array_key_exists('Processed', $data)) {
         $donationProcessed = $data['Processed'];
     } else {
         $error = true;
         $errorMessage = 'No donation processed value was provided.';
     }
     if (array_key_exists('Timestamp', $data)) {
         $donationTimestamp = $data['Timestamp'];
     } else {
         $error = true;
         $errorMessage = 'No donation timestamp was provided.';
     }
     if ($database instanceof ZdpArrayObject) {
         $error = true;
         $errorMessage = $database['error'];
     }
     if (!$error) {
         $sql = 'CALL sp_insert_donation (:donation_timestamp, :donation_name, :donation_email, :donation_comment, :campaign_id, :donation_amount, :donation_processed, :marathon_id)';
         $statement = $database->prepare($sql);
         if ($statement->execute([':donation_timestamp' => $donationTimestamp, ':donation_name' => $donationName, ':donation_email' => $donationEmail, ':donation_comment' => $donationComment, ':campaign_id' => $campaign, ':donation_amount' => $donationAmount, ':donation_processed' => $donationProcessed, ':marathon_id' => $marathon])) {
             $return = $statement->fetchAll(PDO::FETCH_ASSOC)[0]['Id'];
             $output = new ZdpArrayObject(['result' => new ZdpArrayObject(['donationId' => $return])]);
         } else {
             $output = new ZdpArrayObject(['error' => $statement->errorInfo()]);
         }
     } else {
         $output = new ZdpArrayObject(['error' => $errorMessage]);
     }
     return $output;
 }
Пример #6
0
 public static function Insert($data, $settings, $marathon, $campaign, $database)
 {
     if (!Authorization::IsAuthorized($settings)) {
         return new ZdpArrayObject(['error' => 'You are not authorized to perform this action.']);
     }
     $challengeGoal;
     $challengeName;
     $challengeStartTime;
     $challengeEndTime;
     $challengeDescription;
     $error = false;
     $errorMessage;
     $output;
     if (array_key_exists('Goal', $data)) {
         $challengeGoal = $data['Goal'];
     } else {
         $error = true;
         $errorMessage = 'No goal amount was provided.';
     }
     if (array_key_exists('Name', $data)) {
         $challengeName = $data['Name'];
     } else {
         $error = true;
         $errorMessage = 'No challenge name was provided.';
     }
     if (array_key_exists('Starttime', $data)) {
         $challengeStartTime = $data['Starttime'];
     } else {
         $error = true;
         $errorMessage = 'No challenge start time was provided.';
     }
     if (array_key_exists('Endtime', $data)) {
         $challengeEndTime = $data['Endtime'];
     } else {
         $error = true;
         $errorMessage = 'No challenge end time was provided.';
     }
     if (array_key_exists('Description', $data)) {
         $challengeDescription = $data['Description'];
     } else {
         $error = true;
         $errorMessage = 'No challenge description was provided.';
     }
     if ($database instanceof ZdpArrayObject) {
         $error = true;
         $errorMessage = $database['error'];
     }
     if (!$error) {
         $sql = 'CALL sp_insert_challenge (:campaign_id, :marathon_id, :challenge_goal, :challenge_name, :challenge_startTime, :challenge_description, :challenge_endTime)';
         $statement = $database->prepare($sql);
         if ($statement->execute([':campaign_id' => $campaign, ':marathon_id' => $marathon, ':challenge_goal' => $challengeGoal, ':challenge_name' => $challengeName, ':challenge_startTime' => $challengeStartTime, ':challenge_description' => $challengeDescription, ':challenge_endTime' => $challengeEndTime])) {
             $return = $statement->fetchAll(PDO::FETCH_ASSOC)[0]['Id'];
             $output = new ZdpArrayObject(['result' => new ZdpArrayObject(['challengeId' => $return])]);
         } else {
             $output = new ZdpArrayObject(['error' => $statement->errorInfo()]);
         }
     } else {
         $output = new ZdpArrayObject(['error' => $errorMessage]);
     }
     return $output;
 }
Пример #7
0
function TestHasAuthority($token, $auths)
{
    global $TESTS;
    $test = 1;
    $A = new Authorization();
    $mundane_id = $A->IsAuthorized($token);
    print_r($A->GetAuthorizations($mundane_id));
    foreach ($auths as $k => $params) {
        if ($A->HasAuthority($mundane_id, $params[0], $params[1], $params[2]) == $params[3]) {
            echo "{$TESTS}.{$test} Passed HasAuthority params: ({$mundane_id}, {$params['0']}, {$params['1']}, {$params['2']}) == {$params['3']}\n";
        } else {
            die("{$TESTS}.{$test} Failed HasAuthority params: ({$mundane_id}, {$params['0']}, {$params['1']}, {$params['2']}) == {$params['3']}\n");
        }
        $TESTS++;
        $test++;
    }
    echo "\n\n";
}