function localForwardExists($email) { $localForwards = getLocalForwards(); foreach ($localForwards as $localForward) { if ($localForward['email'] == $email) { return TRUE; } } return FALSE; }
<?php include_once '../lib/session.inc.php'; include_once '../lib/localForwards.inc.php'; requireSiteAdmin(); $mode = $_POST['mode']; if ($mode == 'load') { $forwardsRows = getLocalForwards(); $i = 0; foreach ($forwardsRows as $forward) { if ($forward['active'] == 't') { $forwardsRows[$i]['active'] = TRUE; } else { $forwardsRows[$i]['active'] = FALSE; } $i++; } $forwards = array('success' => TRUE, 'forwards' => $forwardsRows); print json_encode($forwards); } else { if ($mode == 'save') { $update = $_POST['update']; $remove = $_POST['remove']; if ($update) { $updates = json_decode($update); foreach ($updates as $tmpForward) { $aliasId = $tmpForward->alias_id; $destination = trim($tmpForward->destination); $active = $tmpForward->active; modifyLocalForward($aliasId, $destination, $active); }