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 $table = new PhabricatorCalendarEvent(); $conn = $table->establishConnection('w'); ..

Decoded Output download

<?php

$table = new PhabricatorCalendarEvent();
$conn = $table->establishConnection('w');
$table_name = 'calendar_event';

foreach (new LiskRawMigrationIterator($conn, $table_name) as $row) {
  $parameters = phutil_json_decode($row['parameters']);
  if (isset($parameters['recurrenceRule'])) {
    // This event has already been migrated.
    continue;
  }

  if (!$row['isRecurring']) {
    continue;
  }

  $old_rule = $row['recurrenceFrequency'];
  if (!$old_rule) {
    continue;
  }

  try {
    $frequency = phutil_json_decode($old_rule);
    if ($frequency) {
      $frequency_rule = $frequency['rule'];
      $frequency_rule = phutil_utf8_strtoupper($frequency_rule);

      $rrule = id(new PhutilCalendarRecurrenceRule())
        ->setFrequency($frequency_rule);
    }
  } catch (Exception $ex) {
    continue;
  }

  $parameters['recurrenceRule'] = $rrule->toDictionary();

  queryfx(
    $conn,
    'UPDATE %T SET parameters = %s WHERE id = %d',
    $table_name,
    phutil_json_encode($parameters),
    $row['id']);
}
 ?>

Did this file decode correctly?

Original Code

<?php

$table = new PhabricatorCalendarEvent();
$conn = $table->establishConnection('w');
$table_name = 'calendar_event';

foreach (new LiskRawMigrationIterator($conn, $table_name) as $row) {
  $parameters = phutil_json_decode($row['parameters']);
  if (isset($parameters['recurrenceRule'])) {
    // This event has already been migrated.
    continue;
  }

  if (!$row['isRecurring']) {
    continue;
  }

  $old_rule = $row['recurrenceFrequency'];
  if (!$old_rule) {
    continue;
  }

  try {
    $frequency = phutil_json_decode($old_rule);
    if ($frequency) {
      $frequency_rule = $frequency['rule'];
      $frequency_rule = phutil_utf8_strtoupper($frequency_rule);

      $rrule = id(new PhutilCalendarRecurrenceRule())
        ->setFrequency($frequency_rule);
    }
  } catch (Exception $ex) {
    continue;
  }

  $parameters['recurrenceRule'] = $rrule->toDictionary();

  queryfx(
    $conn,
    'UPDATE %T SET parameters = %s WHERE id = %d',
    $table_name,
    phutil_json_encode($parameters),
    $row['id']);
}

Function Calls

None

Variables

None

Stats

MD5 353376cd8ddf8409c242e95134404a96
Eval Count 0
Decode Time 77 ms