<commit_before><?php

namespace BNETDocs\Controllers\Server;

use \BNETDocs\Libraries\Exceptions\ServerNotFoundException;
use \BNETDocs\Libraries\Server;

use \BNETDocs\Models\Server\UpdateJob as UpdateJobModel;

use \CarlBennett\MVC\Libraries\Common;
use \CarlBennett\MVC\Libraries\Controller;
use \CarlBennett\MVC\Libraries\Router;
use \CarlBennett\MVC\Libraries\View as ViewLib;

use \DateTime;
use \DateTimeZone;

class UpdateJob extends Controller {

  public function &run( Router &$router, ViewLib &$view, array &$args ) {

    $model = new UpdateJobModel();
    $action = $router->getRequestMethod();

    if ( $action !== 'POST' ) {

      $model->_responseCode = 405;
      $model->_responseHeaders[ 'Allow' ] = 'POST';

    } else {

      $query = $router->getRequestQueryArray();

      $server_id = ( isset( $query[ 'id' ]) ? $query[ 'id' ] : null );

      $job_token = (
        isset( $query[ 'job_token' ]) ? $query[ 'job_token' ] : null
      );

      $status = (
        isset( $query[ 'status' ]) ? $query[ 'status' ] : null
      );

      if ( !is_null( $server_id )) $server_id = (int) $server_id;
      if ( !is_null( $status )) $status = (int) $status;

      $authenticated = (
        $job_token === Common::$config->bnetdocs->server_update_job_token
      );

      if ( !( is_int( $server_id ) && is_int( $status ))) {

        $model->_responseCode = 400;

      } else if ( !$authenticated ) {<commit_msg>Use post body instead of query parameters<commit_after><?php

namespace BNETDocs\Controllers\Server;

use \BNETDocs\Libraries\Exceptions\ServerNotFoundException;
use \BNETDocs\Libraries\Server;

use \BNETDocs\Models\Server\UpdateJob as UpdateJobModel;

use \CarlBennett\MVC\Libraries\Common;
use \CarlBennett\MVC\Libraries\Controller;
use \CarlBennett\MVC\Libraries\Router;
use \CarlBennett\MVC\Libraries\View as ViewLib;

use \DateTime;
use \DateTimeZone;

class UpdateJob extends Controller {

  public function &run( Router &$router, ViewLib &$view, array &$args ) {

    $model = new UpdateJobModel();
    $action = $router->getRequestMethod();

    if ( $action !== 'POST' ) {

      $model->_responseCode = 405;
      $model->_responseHeaders[ 'Allow' ] = 'POST';

    } else {

      $q = $router->getRequestBodyArray();

      $server_id = ( isset( $q[ 'id' ]) ? $q[ 'id' ] : null );

      $job_token = (
        isset( $q[ 'job_token' ]) ? $q[ 'job_token' ] : null
      );

      $status = (
        isset( $q[ 'status' ]) ? $q[ 'status' ] : null
      );

      if ( !is_null( $server_id )) $server_id = (int) $server_id;
      if ( !is_null( $status )) $status = (int) $status;

      $authenticated = (
        $job_token === Common::$config->bnetdocs->server_update_job_token
      );

      if ( !( is_int( $server_id ) && is_int( $status ))) {

        $model->_responseCode = 400;

      } else if ( !$authenticated ) {
{'fraction_non_alphanumeric': 0.15930434782608696, 'fraction_numerical': 0.0041739130434782605, 'mean_word_length': 3.0910384068278804, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 17, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1064924', 'n_tokens_mistral': 1027, 'n_tokens_neox': 986, 'n_words': 206}