Find this useful? Enter your email to receive occasional updates for securing PHP code.

Signing you up...

Thank you for signing up!

PHP Decode

<?php final class PonderAnswerSaveController extends PonderController { public functio..

Decoded Output download

<?php

final class PonderAnswerSaveController extends PonderController {

  public function handleRequest(AphrontRequest $request) {
    $viewer = $request->getViewer();

    if (!$request->isFormPost()) {
      return new Aphront400Response();
    }

    $question_id = $request->getInt('question_id');
    $question = id(new PonderQuestionQuery())
      ->setViewer($viewer)
      ->withIDs(array($question_id))
      ->needAnswers(true)
      ->executeOne();
    if (!$question) {
      return new Aphront404Response();
    }

    $content = $request->getStr('answer');

    if (!strlen(trim($content))) {
      $dialog = id(new AphrontDialogView())
        ->setUser($viewer)
        ->setTitle(pht('Empty Answer'))
        ->appendChild(
          phutil_tag('p', array(), pht('Your answer must not be empty.')))
        ->addCancelButton('/Q'.$question_id);

      return id(new AphrontDialogResponse())->setDialog($dialog);
    }

    $answer = PonderAnswer::initializeNewAnswer($viewer, $question);

    // Question Editor

    $xactions = array();
    $xactions[] = id(new PonderQuestionTransaction())
      ->setTransactionType(PonderQuestionAnswerTransaction::TRANSACTIONTYPE)
      ->setNewValue(
        array(
          '+' => array(
            array('answer' => $answer),
          ),
        ));

    $editor = id(new PonderQuestionEditor())
      ->setActor($viewer)
      ->setContentSourceFromRequest($request);

    $editor->applyTransactions($question, $xactions);

    // Answer Editor

    $template = id(new PonderAnswerTransaction());
    $xactions = array();

    $xactions[] = id(clone $template)
      ->setTransactionType(PonderAnswerQuestionIDTransaction::TRANSACTIONTYPE)
      ->setNewValue($question->getID());

    $xactions[] = id(clone $template)
      ->setTransactionType(PonderAnswerContentTransaction::TRANSACTIONTYPE)
      ->setNewValue($content);

    $editor = id(new PonderAnswerEditor())
      ->setActor($viewer)
      ->setContentSourceFromRequest($request)
      ->setContinueOnNoEffect(true);

    $editor->applyTransactions($answer, $xactions);


    return id(new AphrontRedirectResponse())->setURI(
      id(new PhutilURI('/Q'.$question->getID())));
  }
}
 ?>

Did this file decode correctly?

Original Code

<?php

final class PonderAnswerSaveController extends PonderController {

  public function handleRequest(AphrontRequest $request) {
    $viewer = $request->getViewer();

    if (!$request->isFormPost()) {
      return new Aphront400Response();
    }

    $question_id = $request->getInt('question_id');
    $question = id(new PonderQuestionQuery())
      ->setViewer($viewer)
      ->withIDs(array($question_id))
      ->needAnswers(true)
      ->executeOne();
    if (!$question) {
      return new Aphront404Response();
    }

    $content = $request->getStr('answer');

    if (!strlen(trim($content))) {
      $dialog = id(new AphrontDialogView())
        ->setUser($viewer)
        ->setTitle(pht('Empty Answer'))
        ->appendChild(
          phutil_tag('p', array(), pht('Your answer must not be empty.')))
        ->addCancelButton('/Q'.$question_id);

      return id(new AphrontDialogResponse())->setDialog($dialog);
    }

    $answer = PonderAnswer::initializeNewAnswer($viewer, $question);

    // Question Editor

    $xactions = array();
    $xactions[] = id(new PonderQuestionTransaction())
      ->setTransactionType(PonderQuestionAnswerTransaction::TRANSACTIONTYPE)
      ->setNewValue(
        array(
          '+' => array(
            array('answer' => $answer),
          ),
        ));

    $editor = id(new PonderQuestionEditor())
      ->setActor($viewer)
      ->setContentSourceFromRequest($request);

    $editor->applyTransactions($question, $xactions);

    // Answer Editor

    $template = id(new PonderAnswerTransaction());
    $xactions = array();

    $xactions[] = id(clone $template)
      ->setTransactionType(PonderAnswerQuestionIDTransaction::TRANSACTIONTYPE)
      ->setNewValue($question->getID());

    $xactions[] = id(clone $template)
      ->setTransactionType(PonderAnswerContentTransaction::TRANSACTIONTYPE)
      ->setNewValue($content);

    $editor = id(new PonderAnswerEditor())
      ->setActor($viewer)
      ->setContentSourceFromRequest($request)
      ->setContinueOnNoEffect(true);

    $editor->applyTransactions($answer, $xactions);


    return id(new AphrontRedirectResponse())->setURI(
      id(new PhutilURI('/Q'.$question->getID())));
  }
}

Function Calls

None

Variables

None

Stats

MD5 55a6e8ae86594f939e815a09e779b1e1
Eval Count 0
Decode Time 91 ms