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 $policies = array( 'Administrators', 'LegalpadSignature', 'LunarPhase', 'Pr..

Decoded Output download

<?php

$policies = array(
  'Administrators',
  'LegalpadSignature',
  'LunarPhase',
  'Projects',
  'Users',
);
$map = array();

foreach ($policies as $policy) {
  $old_name = "PhabricatorPolicyRule{$policy}";
  $new_name = "Phabricator{$policy}PolicyRule";
  $map[$old_name] = $new_name;
}

echo pht('Migrating policies...')."
";
$table = new PhabricatorPolicy();
$conn_w = $table->establishConnection('w');

foreach (new LiskMigrationIterator($table) as $policy) {
  $old_rules = $policy->getRules();
  $new_rules = array();

  foreach ($old_rules as $rule) {
    $existing_rule = $rule['rule'];
    $rule['rule'] = idx($map, $existing_rule, $existing_rule);
    $new_rules[] = $rule;
  }

  queryfx(
    $conn_w,
    'UPDATE %T SET rules = %s WHERE id = %d',
    $table->getTableName(),
    json_encode($new_rules),
    $policy->getID());
}
 ?>

Did this file decode correctly?

Original Code

<?php

$policies = array(
  'Administrators',
  'LegalpadSignature',
  'LunarPhase',
  'Projects',
  'Users',
);
$map = array();

foreach ($policies as $policy) {
  $old_name = "PhabricatorPolicyRule{$policy}";
  $new_name = "Phabricator{$policy}PolicyRule";
  $map[$old_name] = $new_name;
}

echo pht('Migrating policies...')."\n";
$table = new PhabricatorPolicy();
$conn_w = $table->establishConnection('w');

foreach (new LiskMigrationIterator($table) as $policy) {
  $old_rules = $policy->getRules();
  $new_rules = array();

  foreach ($old_rules as $rule) {
    $existing_rule = $rule['rule'];
    $rule['rule'] = idx($map, $existing_rule, $existing_rule);
    $new_rules[] = $rule;
  }

  queryfx(
    $conn_w,
    'UPDATE %T SET rules = %s WHERE id = %d',
    $table->getTableName(),
    json_encode($new_rules),
    $policy->getID());
}

Function Calls

pht 1

Variables

$map [{'key': 'PhabricatorPolicyRuleAdministrators', 'value': 'PhabricatorAdministratorsPolicyRule'}]
$policy Users
$new_name PhabricatorAdministratorsPolicyRule
$old_name PhabricatorPolicyRuleAdministrators
$policies [{'key': 0, 'value': 'Administrators'}, {'key': 1, 'value': 'LegalpadSignature'}, {'key': 2, 'value': 'LunarPhase'}, {'key': 3, 'value': 'Projects'}, {'key': 4, 'value': 'Users'}]

Stats

MD5 73402711284a1741232cdf15b158555c
Eval Count 0
Decode Time 96 ms