<commit_before><?php

/**
 * This file is part of the dsExtDirectPlugin
 *
 * @package   dsExtDirectPlugin
 * @author    <NAME> <<EMAIL>>
 * @copyright Copyright (c) 2009, <NAME>
 * @license   http://www.opensource.org/licenses/mit-license.php MIT License
 * @version   SVN: $Id$
 */

/**
 * dsExtDirectRouter is a symfony implementation of the Ext JS 3.x Direct RPC Router.
 *
 * @package    dsExtDirectPlugin
 * @author     <NAME> <<EMAIL>>
 */
class dsExtDirectRouter
{
  protected static $isForm = false;
  protected static $isUpload = false;
  protected static $data;
  protected static $response;

  public static function handle()
  {
    $sfContext = sfContext::getInstance();
    $sfRequest = $sfContext->getRequest();
    $sfResponse = $sfContext->getResponse();
    
    // Verify request method is POST
    if($sfRequest->getMethod() != sfWebRequest::POST)
    {
      throw new Exception('Invalid request.');
    }
    
    // Check for form and/or upload action type
    $extAction = $sfRequest->getParameter('extAction');
    if(! empty($extAction))
    {
      self::$isForm = true;
      
      // Is this an upload?
      $extUpload = $sfRequest->getParameter('extUpload');
      self::$isUpload = ! empty($extUpload) === true;
      
      //Create a data object
      self::$data = new stdClass();
      self::$data->action = $sfRequest->getParameter('extAction');
      self::$data->method = $sfRequest->getParameter('extMethod');
      self::$data->tid = $sfRequest->getParameter('extTID');
      self::$data->data = array($_POST, $_FILES);
    }
    // Not a form submit, pull and decode raw POST data
    else
    {<commit_msg>Fixed bug where a formhandler request may be falsely interpreted as a file upload<commit_after><?php

/**
 * This file is part of the dsExtDirectPlugin
 *
 * @package   dsExtDirectPlugin
 * @author    <NAME> <<EMAIL>>
 * @copyright Copyright (c) 2009, <NAME>
 * @license   http://www.opensource.org/licenses/mit-license.php MIT License
 * @version   SVN: $Id$
 */

/**
 * dsExtDirectRouter is a symfony implementation of the Ext JS 3.x Direct RPC Router.
 *
 * @package    dsExtDirectPlugin
 * @author     <NAME> <<EMAIL>>
 */
class dsExtDirectRouter
{
  protected static $isForm = false;
  protected static $isUpload = false;
  protected static $data;
  protected static $response;

  public static function handle()
  {
    $sfContext = sfContext::getInstance();
    $sfRequest = $sfContext->getRequest();
    $sfResponse = $sfContext->getResponse();
    
    // Verify request method is POST
    if($sfRequest->getMethod() != sfWebRequest::POST)
    {
      throw new Exception('Invalid request.');
    }
    
    // Check for form and/or upload action type
    $extAction = $sfRequest->getParameter('extAction');
    if(! empty($extAction))
    {
      self::$isForm = true;
      
      // Is this an upload?
      $extUpload = $sfRequest->getParameter('extUpload');
      self::$isUpload = $extUpload == "true";
      
      //Create a data object
      self::$data = new stdClass();
      self::$data->action = $sfRequest->getParameter('extAction');
      self::$data->method = $sfRequest->getParameter('extMethod');
      self::$data->tid = $sfRequest->getParameter('extTID');
      self::$data->data = array($_POST, $_FILES);
    }
    // Not a form submit, pull and decode raw POST data
    else
    {
{'fraction_non_alphanumeric': 0.1421772754312909, 'fraction_numerical': 0.00297441998810232, 'mean_word_length': 3.1062271062271063, 'pattern_counts': {'":': 0, '<': 19, '<?xml version=': 0, '>': 41, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, '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': '4416940', 'n_tokens_mistral': 1000, 'n_tokens_neox': 1000, 'n_words': 271}