Loading chmod.info +6 −1 Changes for chmod.info: 6 added lines, 1 removed line. Original line number Diff line number Diff line name = chmod name = chmod g+w description = Give group file permissions where webserver is file owner. version = 7.1.x core = 7.x package = Custom files[] = chmodgw.pages.inc chmod.module +102 Changes for chmod.module: 102 added lines, 0 removed lines. Original line number Diff line number Diff line <?php /** * @file * chmod main file. */ /** * Implements hook_menu(). */ function chmod_menu() { $items = array(); $items['admin/config/development/chmod'] = array( 'title' => 'chmod change (with webuser)', 'description' => 'chmod change request!', 'page callback' => 'drupal_get_form', 'page arguments' => array('chmod_change'), 'access callback' => 'user_access', 'access arguments' => array('use chmod'), 'weight' => 10, 'file' => 'chmod.pages.inc', ); return $items; } /** * Implements hook_permission(). */ function chmod_permission() { return array( 'use chmod' => array( 'title' => t('Use chmod'), 'description' => t('Use chmod to change writing permissions of file group.'), ), ); } /** * Get standard paths. */ function _chmod_paths() { global $base_path; global $conf; $paths = array(); $webroot = $_SERVER['DOCUMENT_ROOT'] . $base_path; $paths['root'] = $webroot; $tmp = variable_get('file_temporary_path', ''); if ($tmp != '') { $paths['tmp'] = $tmp; } $public = variable_get('file_public_path', ''); if ($public != '') { $paths['public'] = $public; } $private = variable_get('file_private_path', ''); if ($private != '') { $paths['private'] = $private; } if (isset($conf['chmod']) && isset($conf['chmod']['paths'])) { foreach ($conf['chmod']['paths'] as $key => $path) { $paths[$key] = $path; } } return $paths; } /** * Execute chmod command. */ function _chmod_exec($path_key = '') { $system_user = exec("whoami"); $paths = _chmod_paths(); if (array_key_exists($path_key, $paths)) { $path = $paths[$path_key]; } else { drupal_set_message(t('Missing path key or empty argument.'), 'error'); return; } if (file_exists($path)) { $command = "find " . $path . " -user " . $system_user . " -exec chmod g+w {} +"; exec($command); $replace = array( '!cmd' => $command, '!webuser' => $system_user, ); drupal_set_message(t('The following command was executed as system user "!webuser": "exec(!cmd)" ', $replace)); } else { drupal_set_message(t("Configured folder didn't exist."), 'error'); } } chmod.pages.inc +49 Changes for chmod.pages.inc: 49 added lines, 0 removed lines. Original line number Diff line number Diff line <?php /** * @file * Page callbacks for chmod. */ /** * Form builder. */ function chmod_change($form, &$form_state) { $paths = _chmod_paths(); $system_user = exec("whoami"); $replace = array( '!webuser' => $system_user, ); $title = t('Path to exec change as current system user: "!webuser"', $replace); $description = t("You can add more file paths in settings.php as described in README file."); $options = array(); foreach ($paths as $key => $path) { $options[$key] = $key . ': ' . $path; } $form['actions'] = array('#type' => 'actions'); $form['actions']['submit'] = array( '#type' => 'submit', '#value' => t('Execute chmod command.'), ); $form['path_key'] = array( '#type' => 'select', '#title' => $title, '#options' => $options, '#required' => TRUE, '#default_value' => "public", '#description' => $description, ); $form['#submit'][] = 'chmod_change_submit'; return $form; } /** * Submit function for chmod_change(). */ function chmod_change_submit($form, &$form_state) { _chmod_exec($form_state['values']['path_key']); } Loading
chmod.info +6 −1 Changes for chmod.info: 6 added lines, 1 removed line. Original line number Diff line number Diff line name = chmod name = chmod g+w description = Give group file permissions where webserver is file owner. version = 7.1.x core = 7.x package = Custom files[] = chmodgw.pages.inc
chmod.module +102 Changes for chmod.module: 102 added lines, 0 removed lines. Original line number Diff line number Diff line <?php /** * @file * chmod main file. */ /** * Implements hook_menu(). */ function chmod_menu() { $items = array(); $items['admin/config/development/chmod'] = array( 'title' => 'chmod change (with webuser)', 'description' => 'chmod change request!', 'page callback' => 'drupal_get_form', 'page arguments' => array('chmod_change'), 'access callback' => 'user_access', 'access arguments' => array('use chmod'), 'weight' => 10, 'file' => 'chmod.pages.inc', ); return $items; } /** * Implements hook_permission(). */ function chmod_permission() { return array( 'use chmod' => array( 'title' => t('Use chmod'), 'description' => t('Use chmod to change writing permissions of file group.'), ), ); } /** * Get standard paths. */ function _chmod_paths() { global $base_path; global $conf; $paths = array(); $webroot = $_SERVER['DOCUMENT_ROOT'] . $base_path; $paths['root'] = $webroot; $tmp = variable_get('file_temporary_path', ''); if ($tmp != '') { $paths['tmp'] = $tmp; } $public = variable_get('file_public_path', ''); if ($public != '') { $paths['public'] = $public; } $private = variable_get('file_private_path', ''); if ($private != '') { $paths['private'] = $private; } if (isset($conf['chmod']) && isset($conf['chmod']['paths'])) { foreach ($conf['chmod']['paths'] as $key => $path) { $paths[$key] = $path; } } return $paths; } /** * Execute chmod command. */ function _chmod_exec($path_key = '') { $system_user = exec("whoami"); $paths = _chmod_paths(); if (array_key_exists($path_key, $paths)) { $path = $paths[$path_key]; } else { drupal_set_message(t('Missing path key or empty argument.'), 'error'); return; } if (file_exists($path)) { $command = "find " . $path . " -user " . $system_user . " -exec chmod g+w {} +"; exec($command); $replace = array( '!cmd' => $command, '!webuser' => $system_user, ); drupal_set_message(t('The following command was executed as system user "!webuser": "exec(!cmd)" ', $replace)); } else { drupal_set_message(t("Configured folder didn't exist."), 'error'); } }
chmod.pages.inc +49 Changes for chmod.pages.inc: 49 added lines, 0 removed lines. Original line number Diff line number Diff line <?php /** * @file * Page callbacks for chmod. */ /** * Form builder. */ function chmod_change($form, &$form_state) { $paths = _chmod_paths(); $system_user = exec("whoami"); $replace = array( '!webuser' => $system_user, ); $title = t('Path to exec change as current system user: "!webuser"', $replace); $description = t("You can add more file paths in settings.php as described in README file."); $options = array(); foreach ($paths as $key => $path) { $options[$key] = $key . ': ' . $path; } $form['actions'] = array('#type' => 'actions'); $form['actions']['submit'] = array( '#type' => 'submit', '#value' => t('Execute chmod command.'), ); $form['path_key'] = array( '#type' => 'select', '#title' => $title, '#options' => $options, '#required' => TRUE, '#default_value' => "public", '#description' => $description, ); $form['#submit'][] = 'chmod_change_submit'; return $form; } /** * Submit function for chmod_change(). */ function chmod_change_submit($form, &$form_state) { _chmod_exec($form_state['values']['path_key']); }