<?php $path = $_GET['path']; $log_data = array('action' => 'chmod', 'path' => $path, 'result' => null); $json = array('status' => 'success', 'filename' => basename($path)); try { $log_data['path'] = $path; if (!$GLOBALS['RFP']->canWrite($_SESSION['pidm'], $path)) { throw new Exception('You do not have write access to ' . htmlentities($path)); } try { // hard code perms for now: global rw $GLOBALS['SCP']->chmod($path, 0666); } catch (SCPException $e) { $log_data['result'] = 'failure'; throw new Exception('There was an error modifying file permissions: ' . $e->getMessage() . ' (' . $e->getCode() . ')'); } $log_data['result'] = 'success'; } catch (Exception $e) { // default result if ($log_data['result'] === null) { $log_data['result'] = 'denied'; } $json['status'] = 'error'; $json['message'] = $e->getMessage(); } rf_log($log_data); PSUTools::jsonAndExit($json); // vim:ts=2:sw=2:noet:
/** * action_cleanup() creates an HTTP response for a page that is responding * to a form submission. This response might be a redirect to another page, * or outputting a JSON string. This function causes script processing to end. * * @param string $url the url to redirect to * @param mixed $response any messages that should be passed to the user * @param bool $is_ajax whether or not the response should be done in json */ function action_cleanup($url, $response = '', $is_ajax = false) { if ($is_ajax) { PSUTools::jsonAndExit($response); } else { $_SESSION['messages'] = array_merge($_SESSION['messages'], $response['messages']); $_SESSION['errors'] = array_merge($_SESSION['errors'], $response['errors']); PSUHTML::redirect($url); } }