@@ -163,7 +163,6 @@ function main($id, $mode)
163163 'img_create_thumbnail ' => array ('lang ' => 'CREATE_THUMBNAIL ' , 'validate ' => 'bool ' , 'type ' => 'radio:yes_no ' , 'explain ' => true ),
164164 'img_max_thumb_width ' => array ('lang ' => 'MAX_THUMB_WIDTH ' , 'validate ' => 'int:0:999999999999999 ' , 'type ' => 'number:0:999999999999999 ' , 'explain ' => true , 'append ' => ' ' . $ user ->lang ['PIXEL ' ]),
165165 'img_min_thumb_filesize ' => array ('lang ' => 'MIN_THUMB_FILESIZE ' , 'validate ' => 'int:0:999999999999999 ' , 'type ' => 'number:0:999999999999999 ' , 'explain ' => true , 'append ' => ' ' . $ user ->lang ['BYTES ' ]),
166- 'img_imagick ' => array ('lang ' => 'IMAGICK_PATH ' , 'validate ' => 'absolute_path ' , 'type ' => 'text:20:200 ' , 'explain ' => true , 'append ' => ' <span>[ <a href=" ' . $ this ->u_action . '&action=imgmagick"> ' . $ user ->lang ['SEARCH_IMAGICK ' ] . '</a> ]</span> ' ),
167166 'img_max ' => array ('lang ' => 'MAX_IMAGE_SIZE ' , 'validate ' => 'int:0:9999 ' , 'type ' => 'dimension:0:9999 ' , 'explain ' => true , 'append ' => ' ' . $ user ->lang ['PIXEL ' ]),
168167 'img_link ' => array ('lang ' => 'IMAGE_LINK_SIZE ' , 'validate ' => 'int:0:9999 ' , 'type ' => 'dimension:0:9999 ' , 'explain ' => true , 'append ' => ' ' . $ user ->lang ['PIXEL ' ]),
169168 )
@@ -230,38 +229,6 @@ function main($id, $mode)
230229
231230 $ template ->assign_var ('S_ATTACHMENT_SETTINGS ' , true );
232231
233- if ($ action == 'imgmagick ' )
234- {
235- $ this ->new_config ['img_imagick ' ] = $ this ->search_imagemagick ();
236- }
237-
238- // We strip eventually manual added convert program, we only want the patch
239- if ($ this ->new_config ['img_imagick ' ])
240- {
241- // Change path separator
242- $ this ->new_config ['img_imagick ' ] = str_replace ('\\' , '/ ' , $ this ->new_config ['img_imagick ' ]);
243- $ this ->new_config ['img_imagick ' ] = str_replace (array ('convert ' , '.exe ' ), array ('' , '' ), $ this ->new_config ['img_imagick ' ]);
244-
245- // Check for trailing slash
246- if (substr ($ this ->new_config ['img_imagick ' ], -1 ) !== '/ ' )
247- {
248- $ this ->new_config ['img_imagick ' ] .= '/ ' ;
249- }
250- }
251-
252- $ supported_types = get_supported_image_types ();
253-
254- // Check Thumbnail Support
255- if (!$ this ->new_config ['img_imagick ' ] && (!isset ($ supported_types ['format ' ]) || !count ($ supported_types ['format ' ])))
256- {
257- $ this ->new_config ['img_create_thumbnail ' ] = 0 ;
258- }
259-
260- $ template ->assign_vars (array (
261- 'U_SEARCH_IMAGICK ' => $ this ->u_action . '&action=imgmagick ' ,
262- 'S_THUMBNAIL_SUPPORT ' => (!$ this ->new_config ['img_imagick ' ] && (!isset ($ supported_types ['format ' ]) || !count ($ supported_types ['format ' ]))) ? false : true )
263- );
264-
265232 // Secure Download Options - Same procedure as with banning
266233 $ allow_deny = ($ this ->new_config ['secure_allow_deny ' ]) ? 'ALLOWED ' : 'DISALLOWED ' ;
267234
@@ -1485,44 +1452,47 @@ function group_select($select_name, $default_group = false, $key = '')
14851452 }
14861453
14871454 /**
1488- * Search Imagick
1455+ * Test Settings
14891456 */
1490- function search_imagemagick ( )
1457+ function test_upload (& $ error , $ upload_dir , $ create_directory = false )
14911458 {
1492- $ imagick = '' ;
1493-
1494- $ exe = ((defined ('PHP_OS ' )) && (preg_match ('#^win#i ' , PHP_OS ))) ? '.exe ' : '' ;
1459+ global $ user , $ phpbb_root_path ;
14951460
1496- $ magic_home = getenv ('MAGICK_HOME ' );
1497-
1498- if (empty ($ magic_home ))
1461+ // Does the target directory exist, is it a directory and writable.
1462+ if ($ create_directory )
14991463 {
1500- $ locations = array ('C:/WINDOWS/ ' , 'C:/WINNT/ ' , 'C:/WINDOWS/SYSTEM/ ' , 'C:/WINNT/SYSTEM/ ' , 'C:/WINDOWS/SYSTEM32/ ' , 'C:/WINNT/SYSTEM32/ ' , '/usr/bin/ ' , '/usr/sbin/ ' , '/usr/local/bin/ ' , '/usr/local/sbin/ ' , '/opt/ ' , '/usr/imagemagick/ ' , '/usr/bin/imagemagick/ ' );
1501- $ path_locations = str_replace ('\\' , '/ ' , (explode (($ exe ) ? '; ' : ': ' , getenv ('PATH ' ))));
1502-
1503- $ locations = array_merge ($ path_locations , $ locations );
1504-
1505- foreach ($ locations as $ location )
1464+ if (!file_exists ($ phpbb_root_path . $ upload_dir ))
15061465 {
1507- // The path might not end properly, fudge it
1508- if (substr ($ location , -1 ) !== '/ ' )
1466+ @mkdir ($ phpbb_root_path . $ upload_dir , 0777 );
1467+
1468+ try
15091469 {
1510- $ location .= ' / ' ;
1470+ $ this -> filesystem -> phpbb_chmod ( $ phpbb_root_path . $ upload_dir , CHMOD_READ | CHMOD_WRITE ) ;
15111471 }
1512-
1513- if (@file_exists ($ location ) && @is_readable ($ location . 'mogrify ' . $ exe ) && @filesize ($ location . 'mogrify ' . $ exe ) > 3000 )
1472+ catch (\phpbb \filesystem \exception \filesystem_exception $ e )
15141473 {
1515- $ imagick = str_replace ('\\' , '/ ' , $ location );
1516- continue ;
1474+ // Do nothing
15171475 }
15181476 }
15191477 }
1520- else
1478+
1479+ if (!file_exists ($ phpbb_root_path . $ upload_dir ))
15211480 {
1522- $ imagick = str_replace ('\\' , '/ ' , $ magic_home );
1481+ $ error [] = sprintf ($ user ->lang ['NO_UPLOAD_DIR ' ], $ upload_dir );
1482+ return ;
15231483 }
15241484
1525- return $ imagick ;
1485+ if (!is_dir ($ phpbb_root_path . $ upload_dir ))
1486+ {
1487+ $ error [] = sprintf ($ user ->lang ['UPLOAD_NOT_DIR ' ], $ upload_dir );
1488+ return ;
1489+ }
1490+
1491+ if (!$ this ->filesystem ->is_writable ($ phpbb_root_path . $ upload_dir ))
1492+ {
1493+ $ error [] = sprintf ($ user ->lang ['NO_WRITE_UPLOAD ' ], $ upload_dir );
1494+ return ;
1495+ }
15261496 }
15271497
15281498 /**
0 commit comments