Ignore:
Timestamp:
May 3, 2010, 11:09:40 AM (10 years ago)
Author:
plg
Message:

bug 1635 fixed: new API method pwg.images.checkUpload tells pLoader if Piwigo
is ready for upload (currently, it checks write access on the upload directory)

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/include/ws_functions.inc.php

    r5930 r6049  
    21272127    );
    21282128}
     2129
     2130function ws_images_checkUpload($params, &$service)
     2131{
     2132  global $conf;
     2133
     2134  if (!is_admin() or is_adviser())
     2135  {
     2136    return new PwgError(401, 'Access denied');
     2137  }
     2138
     2139  $relative_dir = preg_replace('#^'.PHPWG_ROOT_PATH.'#', '', $conf['upload_dir']);
     2140
     2141  $ret['message'] = null;
     2142  $ret['ready_for_upload'] = true;
     2143 
     2144  if (!is_dir($conf['upload_dir']))
     2145  {
     2146    if (!is_writable(dirname($conf['upload_dir'])))
     2147    {
     2148      $ret['message'] = sprintf(
     2149        l10n('Create the "%s" directory at the root of your Piwigo installation'),
     2150        $relative_dir
     2151        );
     2152    }
     2153  }
     2154  else
     2155  {
     2156    if (!is_writable($conf['upload_dir']))
     2157    {
     2158      @chmod($conf['upload_dir'], 0777);
     2159     
     2160      if (!is_writable($conf['upload_dir']))
     2161      {
     2162        $ret['message'] = sprintf(
     2163          l10n('Give write access (chmod 777) to "%s" directory at the root of your Piwigo installation'),
     2164          $relative_dir
     2165          );
     2166      }
     2167    }
     2168  }
     2169
     2170  if (!empty($ret['message']))
     2171  {
     2172    $ret['ready_for_upload'] = false;
     2173  }
     2174 
     2175  return $ret;
     2176}
    21292177?>
Note: See TracChangeset for help on using the changeset viewer.