You are here

function photos_admin_settings_submit in Album Photos 6.2

Same name and namespace in other branches
  1. 7.3 inc/photos.admin.inc \photos_admin_settings_submit()
1 string reference to 'photos_admin_settings_submit'
photos_admin_settings in inc/photos.admin.inc

File

inc/photos.admin.inc, line 498

Code

function photos_admin_settings_submit($form, &$form_state) {
  global $user;
  for ($i = 0; $i < $form_state['values']['photos_thumb_count']; $i++) {
    if ($form_state['values']['photos_size_' . $i]) {
      $size = explode('x', trim($form_state['values']['photos_size_' . $i]));
      if (is_numeric($size[0]) && is_numeric($size[0])) {
        $t[] = array(
          'w' => $size[0],
          'h' => $size[1],
          'r' => $form_state['values']['photos_res_' . $i],
          'name' => drupal_strtolower(trim($form_state['values']['photos_title_' . $i])),
        );
      }
    }
  }
  variable_set('photos_size', $t);
  $filepath = file_directory_path() . '/' . current(explode('/', $form_state['values']['photos_path']));
  if (!file_check_directory($filepath, FILE_CREATE_DIRECTORY)) {
    return false;
  }
  if ($form_state['values']['photos_access_photos']) {
    if (!is_file($filepath . '/.htaccess')) {
      drupal_set_message(t('%name creating successful', array(
        '%name' => $filepath . '/.htaccess',
      )));
      if ($handle = @fopen($filepath . '/.htaccess', 'wb')) {
        $str = '<FilesMatch "\\.*$">Order allow,deny</FilesMatch>';
        if (fwrite($handle, $str)) {
          fclose($handle);
        }
      }
    }
  }
  else {
    if (is_file($filepath . '/.htaccess')) {
      file_delete($filepath . '/.htaccess');
    }
  }
  cache_clear_all('*', 'cache_menu', TRUE);

  //  if($form_state['values']['photos_exif_cache'] == 1){
  //    $filepath = $filepath . '/cache_exif';
  //  	if (!file_check_directory($filepath, FILE_CREATE_DIRECTORY)) {
  //  		return false;
  //  	}
  //    if(!is_file($filepath. '/.htaccess')){
  //      drupal_set_message(t('%name creating successful', array('%name' => $filepath. '/.htaccess')));
  //      if ($handle = @fopen($filepath. '/.htaccess', 'wb')) {
  //        $str = '<FilesMatch "\.*$">Order allow,deny</FilesMatch>';
  //        if(fwrite($handle, $str)){
  //          fclose($handle);
  //        }
  //      }
  //    }
  //  }
}