| | 2129 | |
| | 2130 | function 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 | } |