plugins/gallery/upload.php
changeset 12 3893b99cd443
parent 10 b38afb86dcad
child 17 ecb96b051d08
equal deleted inserted replaced
11:3c4304fae21e 12:3893b99cd443
   137               if ( !unlink($thumb_filename) )
   137               if ( !unlink($thumb_filename) )
   138               {
   138               {
   139                 $errors[] = "Could not delete $thumb_filename";
   139                 $errors[] = "Could not delete $thumb_filename";
   140                 break 2;
   140                 break 2;
   141               }
   141               }
   142               $magick = getConfig('imagemagick_path');
   142               
   143               $command = "$magick '{$filename}' -resize ".'"'."80x80>".'"'." -quality 85 $thumb_filename";
   143               if ( !scale_image($filename, $thumb_filename, 80, 80) )
   144               
       
   145               @system($command, $stat);
       
   146               
       
   147               if ( !file_exists($thumb_filename) )
       
   148               {
   144               {
   149                 $errors[] = 'Couldn\'t scale image '.$i.': ImageMagick failed us';
   145                 $errors[] = 'Couldn\'t scale image '.$i.': ImageMagick failed us';
   150                 break 2;
   146                 break 2;
   151               }
   147               }
   152               
   148               
   155               if ( !unlink($preview_filename) )
   151               if ( !unlink($preview_filename) )
   156               {
   152               {
   157                 $errors[] = "Could not delete $preview_filename";
   153                 $errors[] = "Could not delete $preview_filename";
   158                 break 2;
   154                 break 2;
   159               }
   155               }
   160               $magick = getConfig('imagemagick_path');
   156               
   161               $command = "$magick '{$filename}' -resize ".'"'."640x640>".'"'." -quality 85 $preview_filename";
   157               if ( !scale_image($filename, $preview_filename, 640, 480) )
   162               
       
   163               @system($command, $stat);
       
   164               
       
   165               if ( !file_exists($preview_filename) )
       
   166               {
   158               {
   167                 $errors[] = 'Couldn\'t scale image '.$i.': ImageMagick failed us';
   159                 $errors[] = 'Couldn\'t scale image '.$i.': ImageMagick failed us';
   168                 break 2;
   160                 break 2;
   169               }
   161               }
       
   162               
   170               $to_update['img_time_mod'] = strval(time());
   163               $to_update['img_time_mod'] = strval(time());
   171             }
   164             }
   172           }
   165           }
   173           
   166           
   174           $vars = array(
   167           $vars = array(
   735         {
   728         {
   736           //
   729           //
   737           // Time for some unzipping fun.
   730           // Time for some unzipping fun.
   738           //
   731           //
   739           
   732           
   740           // for debugging only
       
   741           system('rm -fr ' . ENANO_ROOT . '/cache/temp');
       
   742           
       
   743           error_reporting(E_ALL);
   733           error_reporting(E_ALL);
   744           
   734           
   745           mkdir(ENANO_ROOT . '/cache/temp') or $errors[] = 'Could not create temporary directory for extraction.';
   735           mkdir(ENANO_ROOT . '/cache/temp') or $errors[] = 'Could not create temporary directory for extraction.';
   746           if ( count($errors) > 0 )
   736           if ( count($errors) > 0 )
   747             break 2;
   737             break 2;
   835             if ( !$db->sql_query($sql) )
   825             if ( !$db->sql_query($sql) )
   836               $db->_die();
   826               $db->_die();
   837             
   827             
   838             $idlist[] = $db->insert_id();
   828             $idlist[] = $db->insert_id();
   839             
   829             
       
   830             //
       
   831             // Create scaled images
       
   832             //
       
   833             
   840             // Create thumbnail image
   834             // Create thumbnail image
   841             $thumb_filename = ENANO_ROOT . '/cache/' . $stored_name . '-thumb.jpg';
   835             $thumb_filename = ENANO_ROOT . '/cache/' . $stored_name . '-thumb.jpg';
   842             $magick = getConfig('imagemagick_path');
   836             if ( !unlink($thumb_filename) )
   843             $command = "$magick '{$store}' -resize ".'"'."80x80>".'"'." -quality 85 $thumb_filename";
   837             {
   844             
   838               $errors[] = "Could not delete $thumb_filename";
   845             @system($command, $stat);
   839               break 2;
   846             
   840             }
   847             if ( !file_exists($thumb_filename) )
   841             
       
   842             if ( !scale_image($store, $thumb_filename, 80, 80) )
   848             {
   843             {
   849               $errors[] = 'Couldn\'t scale image '.$i.': ImageMagick failed us';
   844               $errors[] = 'Couldn\'t scale image '.$i.': ImageMagick failed us';
   850               break 2;
   845               break 2;
   851             }
   846             }
   852             
   847             
   853             // Create preview image
   848             // Create preview image
   854             $preview_filename = ENANO_ROOT . '/cache/' . $stored_name . '-preview.jpg';
   849             $preview_filename = ENANO_ROOT . '/cache/' . $stored_name . '-preview.jpg';
   855             $magick = getConfig('imagemagick_path');
   850             if ( !unlink($preview_filename) )
   856             $command = "$magick '{$store}' -resize ".'"'."640x640>".'"'." -quality 85 $preview_filename";
   851             {
   857             
   852               $errors[] = "Could not delete $preview_filename";
   858             @system($command, $stat);
   853               break 2;
   859             
   854             }
   860             if ( !file_exists($preview_filename) )
   855             
       
   856             if ( !scale_image($store, $preview_filename, 640, 640) )
   861             {
   857             {
   862               $errors[] = 'Couldn\'t scale image '.$i.': ImageMagick failed us';
   858               $errors[] = 'Couldn\'t scale image '.$i.': ImageMagick failed us';
   863               break 2;
   859               break 2;
   864             }
   860             }
   865             
   861