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 $map = array(); echo pht('Merging duplicate answers by authors...')."\n"; $atable..

Decoded Output download

<?php

$map = array();

echo pht('Merging duplicate answers by authors...')."
";

$atable = new PonderAnswer();
$conn_w = $atable->establishConnection('w');
$conn_w->openTransaction();

$answers = new LiskMigrationIterator(new PonderAnswer());
foreach ($answers as $answer) {
  $aid = $answer->getID();
  $qid = $answer->getQuestionID();
  $author_phid = $answer->getAuthorPHID();

  echo pht('Processing answer ID #%d...', $aid)."
";

  if (empty($map[$qid][$author_phid])) {
    echo pht('Answer is unique.')."
";
    $map[$qid][$author_phid] = $answer;
    continue;
  } else {
    echo pht('Merging answer.')."
";
    $target = $map[$qid][$author_phid];
    queryfx(
      $conn_w,
      'UPDATE %T SET content = %s WHERE id = %d',
      $target->getTableName(),

      $target->getContent().
      "

".
      "---".
      "

".
      "> (This content was automatically merged from another answer by the ".
      "same author.)".
      "

".
      $answer->getContent(),

      $target->getID());

    queryfx(
      $conn_w,
      'DELETE FROM %T WHERE id = %d',
      $target->getTableName(),
      $answer->getID());

    queryfx(
      $conn_w,
      'UPDATE %T SET targetPHID = %s WHERE targetPHID = %s',
      'ponder_comment',
      $target->getPHID(),
      $answer->getPHID());
  }
}

$conn_w->saveTransaction();
echo pht('Done.')."
";
 ?>

Did this file decode correctly?

Original Code

<?php

$map = array();

echo pht('Merging duplicate answers by authors...')."\n";

$atable = new PonderAnswer();
$conn_w = $atable->establishConnection('w');
$conn_w->openTransaction();

$answers = new LiskMigrationIterator(new PonderAnswer());
foreach ($answers as $answer) {
  $aid = $answer->getID();
  $qid = $answer->getQuestionID();
  $author_phid = $answer->getAuthorPHID();

  echo pht('Processing answer ID #%d...', $aid)."\n";

  if (empty($map[$qid][$author_phid])) {
    echo pht('Answer is unique.')."\n";
    $map[$qid][$author_phid] = $answer;
    continue;
  } else {
    echo pht('Merging answer.')."\n";
    $target = $map[$qid][$author_phid];
    queryfx(
      $conn_w,
      'UPDATE %T SET content = %s WHERE id = %d',
      $target->getTableName(),

      $target->getContent().
      "\n\n".
      "---".
      "\n\n".
      "> (This content was automatically merged from another answer by the ".
      "same author.)".
      "\n\n".
      $answer->getContent(),

      $target->getID());

    queryfx(
      $conn_w,
      'DELETE FROM %T WHERE id = %d',
      $target->getTableName(),
      $answer->getID());

    queryfx(
      $conn_w,
      'UPDATE %T SET targetPHID = %s WHERE targetPHID = %s',
      'ponder_comment',
      $target->getPHID(),
      $answer->getPHID());
  }
}

$conn_w->saveTransaction();
echo pht('Done.')."\n";

Function Calls

pht 1

Variables

$map []

Stats

MD5 d9d67fdd996bd1bdc82963b2373d4220
Eval Count 0
Decode Time 93 ms