Changeset 17675


Ignore:
Timestamp:
Aug 30, 2012, 9:20:00 PM (8 years ago)
Author:
rvelices
Message:

bug 2725: Piwigo isn't compatible with suPHP + better handling of watermark upload errors

Location:
trunk
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • trunk/admin/include/configuration_watermark_process.inc.php

    r17302 r17675  
    4444  {
    4545    $upload_dir = PHPWG_ROOT_PATH.PWG_LOCAL_DIR.'watermarks';
     46    if (mkgetdir($upload_dir, MKGETDIR_DEFAULT&~MKGETDIR_DIE_ON_ERROR))
     47    {
     48      $new_name = get_filename_wo_extension($_FILES['watermarkImage']['name']).'.png';
     49      $file_path = $upload_dir.'/'.$new_name;
    4650
    47     include_once(PHPWG_ROOT_PATH.'admin/include/functions_upload.inc.php');
    48     prepare_directory($upload_dir);
    49 
    50     $new_name = get_filename_wo_extension($_FILES['watermarkImage']['name']).'.png';
    51     $file_path = $upload_dir.'/'.$new_name;
    52 
    53     move_uploaded_file($_FILES['watermarkImage']['tmp_name'], $file_path);
    54 
    55     $pwatermark['file'] = substr($file_path, strlen(PHPWG_ROOT_PATH));
     51      if (move_uploaded_file($_FILES['watermarkImage']['tmp_name'], $file_path))
     52      {
     53        $pwatermark['file'] = substr($file_path, strlen(PHPWG_ROOT_PATH));
     54      }
     55      else
     56      {
     57        $page['errors'][] = $errors['watermarkImage'] = "$file_path " .l10n('no write access');
     58      }
     59    }
     60    else
     61    {
     62      $page['errors'][] = $errors['watermarkImage'] = sprintf( l10n('Add write access to the "%s" directory'), $upload_dir);
     63    }
    5664  }
    5765}
  • trunk/admin/include/functions_upload.inc.php

    r14829 r17675  
    247247    rename($source_filepath, $file_path);
    248248  }
     249  @chmod($file_path, 0644);
    249250
    250251  if (pwg_image::get_library() != 'gd')
  • trunk/admin/themes/default/template/configuration.tpl

    r17509 r17675  
    519519      {'add a new watermark'|@translate} {'... or '|@translate}<a href="#" class="addWatermarkOpen">{'Select a file'|@translate}</a>
    520520      <br><input type="file" size="60" id="watermarkImage" name="watermarkImage"{if isset($ferrors.watermarkImage)} class="dError"{/if}> (png)
    521       {if isset($ferrors.watermarkImage)}<span class="dErrorDesc" title="{$ferrors.watermarkImage}">!</span>{/if}
     521      {if isset($ferrors.watermarkImage)}<span class="dErrorDesc" title="{$ferrors.watermarkImage|@htmlspecialchars}">!</span>{/if}
    522522      </span>{* #addWatermark *}
    523523    </li>
  • trunk/i.php

    r17315 r17675  
    624624$image->write( $page['derivative_path'] );
    625625$image->destroy();
     626@chmod($page['derivative_path'], 0644);
    626627$timing['save'] = time_step($step);
    627628
  • trunk/include/template.class.php

    r17021 r17675  
    7979    }
    8080
    81     if (!isset($conf['combined_dir_checked']))
    82     {
    83       $dir = PHPWG_ROOT_PATH.PWG_COMBINED_DIR;
    84       mkgetdir($dir, MKGETDIR_DEFAULT&~MKGETDIR_DIE_ON_ERROR);
    85       if (!is_writable($dir))
    86       {
    87         load_language('admin.lang');
    88         fatal_error(
    89           sprintf(
    90             l10n('Give write access (chmod 777) to "%s" directory at the root of your Piwigo installation'),
    91             PWG_COMBINED_DIR
    92             ),
    93           l10n('an error happened'),
    94           false // show trace
    95           );
    96       }
    97       if (function_exists('pwg_query')) {
    98         conf_update_param('combined_dir_checked', 1);
    99       }
    100     }
    101 
    102 
    10381    $compile_dir = PHPWG_ROOT_PATH.$conf['data_location'].'templates_c';
    10482    mkgetdir( $compile_dir );
     
    13441322    }
    13451323
    1346     file_put_contents( PHPWG_ROOT_PATH . $file,  $output );
     1324    mkgetdir( dirname(PHPWG_ROOT_PATH.$file) );
     1325    file_put_contents( PHPWG_ROOT_PATH.$file,  $output );
     1326    @chmod(PHPWG_ROOT_PATH.$file, 0644);
    13471327    $out_file = $file;
    13481328    $out_version = false;
  • trunk/include/ws_functions.inc.php

    r17669 r17675  
    15081508
    15091509  // create the upload directory tree if not exists
    1510   if (!is_dir($upload_dir)) {
    1511     umask(0000);
    1512     if (!@mkdir($upload_dir, 0777, true))
    1513     {
    1514       return new PwgError(500, 'error during buffer directory creation');
    1515     }
    1516   }
    1517 
    1518   if (!is_writable($upload_dir))
    1519   {
    1520     // last chance to make the directory writable
    1521     @chmod($upload_dir, 0777);
    1522 
    1523     if (!is_writable($upload_dir))
    1524     {
    1525       return new PwgError(500, 'buffer directory has no write access');
    1526     }
    1527   }
    1528 
    1529   secure_directory($upload_dir);
     1510  if (!mkgetdir($upload_dir, MKGETDIR_DEFAULT&~MKGETDIR_DIE_ON_ERROR))
     1511  {
     1512    return new PwgError(500, 'error during buffer directory creation');
     1513  }
    15301514
    15311515  $filename = sprintf(
Note: See TracChangeset for help on using the changeset viewer.