plugins/gallery/upload.php
changeset 3 10d663f5ed88
parent 2 88c954d2846c
child 10 b38afb86dcad
equal deleted inserted replaced
2:88c954d2846c 3:10d663f5ed88
   226             }
   226             }
   227           }
   227           }
   228           
   228           
   229           if ( $target_folder )
   229           if ( $target_folder )
   230           {
   230           {
       
   231             // Make sure we're not trying to move a folder to itself or a subdirectory of itself
       
   232             
       
   233             $children = gal_fetch_all_children(intval($img_data['id']));
       
   234             if ( $img_data['id'] == $target_folder || in_array($target_folder, $children) )
       
   235             {
       
   236               $errors[] = 'You are trying to move a folder to itself, or to a subdirectory of itself, which is not allowed. If done manually (i.e. via an SQL client) this will result in infinite loops in the folder sorting code.';
       
   237               break 2;
       
   238             }
       
   239             
   231             $to_update['folder_parent'] = $target_folder;
   240             $to_update['folder_parent'] = $target_folder;
   232           }
   241           }
   233           
   242           
   234           if ( count($to_update) > 0 )
   243           if ( count($to_update) > 0 )
   235           {
   244           {
   347         {
   356         {
   348           $folder =& $folders[$j];
   357           $folder =& $folders[$j];
   349           $folder = sanitize_page_id($folder);
   358           $folder = sanitize_page_id($folder);
   350         }
   359         }
   351         $folders = array_reverse($folders);
   360         $folders = array_reverse($folders);
   352         $gal_href = implode('/', $folders) . '/' . sanitize_page_id($row['img_title']);
   361         $gal_href = implode('/', $folders) . ( count($folders) > 0 ? '/' : '' ) . sanitize_page_id($row['img_title']);
   353         
   362         
   354         echo '<div class="tblholder">
   363         echo '<div class="tblholder">
   355                 <table border="0" cellspacing="1" cellpadding="4">';
   364                 <table border="0" cellspacing="1" cellpadding="4">';
   356         
   365         
   357         echo '<tr><th colspan="2">Folder: ' . htmlspecialchars($row['img_title']) . '</th></tr>';
   366         echo '<tr><th colspan="2">Folder: ' . htmlspecialchars($row['img_title']) . '</th></tr>';