Changeset 831

Show
Ignore:
Timestamp:
02/05/04 14:28:02 (5 years ago)
Author:
saxmatt
Message:

New upload functionality.

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/wp-admin/admin-functions.php

    r815 r831  
    4848} 
    4949 
     50function wp_create_thumbnail($file, $max_side, $effect = '') { 
     51 
     52    // 1 = GIF, 2 = JPEG, 3 = PNG 
     53 
     54    if(file_exists($file)) { 
     55        $type = getimagesize($file); 
     56         
     57        // if the associated function doesn't exist - then it's not 
     58        // handle. duh. i hope. 
     59         
     60        if(!function_exists('imagegif') && $type[2] == 1) { 
     61            $error = 'Filetype not supported. Thumbnail not created.'; 
     62        }elseif(!function_exists('imagejpeg') && $type[2] == 2) { 
     63            $error = 'Filetype not supported. Thumbnail not created.'; 
     64        }elseif(!function_exists('imagepng') && $type[2] == 3) { 
     65            $error = 'Filetype not supported. Thumbnail not created.'; 
     66        } else { 
     67         
     68            // create the initial copy from the original file 
     69            if($type[2] == 1) { 
     70                $image = imagecreatefromgif($file); 
     71            } elseif($type[2] == 2) { 
     72                $image = imagecreatefromjpeg($file); 
     73            } elseif($type[2] == 3) { 
     74                $image = imagecreatefrompng($file); 
     75            } 
     76             
     77            if (function_exists('imageantialias')) 
     78                imageantialias($image, TRUE); 
     79             
     80            $image_attr = getimagesize($file); 
     81             
     82            // figure out the longest side 
     83             
     84            if($image_attr[0] > $image_attr[1]) { 
     85                $image_width = $image_attr[0]; 
     86                $image_height = $image_attr[1]; 
     87                $image_new_width = $max_side; 
     88                 
     89                $image_ratio = $image_width/$image_new_width; 
     90                $image_new_height = $image_height/$image_ratio; 
     91                //width is > height 
     92            } else { 
     93                $image_width = $image_attr[0]; 
     94                $image_height = $image_attr[1]; 
     95                $image_new_height = $max_side; 
     96                 
     97                $image_ratio = $image_height/$image_new_height; 
     98                $image_new_width = $image_width/$image_ratio; 
     99                //height > width 
     100            } 
     101             
     102            $thumbnail = imagecreatetruecolor($image_new_width, $image_new_height); 
     103            @imagecopyresized($thumbnail, $image, 0, 0, 0, 0, $image_new_width, $image_new_height, $image_attr[0], $image_attr[1]); 
     104             
     105            // move the thumbnail to it's final destination 
     106             
     107            $path = explode('/', $file); 
     108            $thumbpath = substr($file, 0, strrpos($file, '/')) . '/thumb-' . $path[count($path)-1]; 
     109             
     110            if($type[2] == 1) { 
     111                if(!imagegif($thumbnail, $thumbpath)) { 
     112                    $error = "Thumbnail path invalid"; 
     113                } 
     114            } elseif($type[2] == 2) { 
     115                if(!imagejpeg($thumbnail, $thumbpath)) { 
     116                    $error = "Thumbnail path invalid"; 
     117                } 
     118            } elseif($type[2] == 3) { 
     119                if(!imagepng($thumbnail, $thumbpath)) { 
     120                    $error = "Thumbnail path invalid"; 
     121                } 
     122            } 
     123             
     124        } 
     125    } 
     126     
     127    if(!empty($error)) 
     128    { 
     129        return $error; 
     130    } 
     131    else 
     132    { 
     133        return 1; 
     134    } 
     135} 
     136 
    50137?> 
  • trunk/wp-admin/admin-header.php

    r829 r831  
    7979//<![CDATA[ 
    8080 
    81 function profile(userID) { 
    82     window.open ("profile.php?action=viewprofile&user="+userID, "Profile", "width=500, height=450, location=0, menubar=0, resizable=0, scrollbars=1, status=1, titlebar=0, toolbar=0, screenX=60, left=60, screenY=60, top=60"); 
    83 } 
    84  
    85 function launchupload() { 
    86     window.open ("upload.php", "wpupload", "width=380,height=360,location=0,menubar=0,resizable=1,scrollbars=yes,status=1,toolbar=0"); 
    87 } 
    88  
    8981function helpWindow(url) { 
    9082    window.open(url, "Help", "width=640, height=450, location=0, menubar=0, resizable=0, scrollbars=1, status=1, titlebar=0, toolbar=0, screenX=60, left=60, screenY=60, top=60"); 
     
    146138</head> 
    147139<body> 
    148  
     140<h1 id="wphead"><a href="http://wordpress.org" rel="external" title="Visit WordPress.org">WordPress</a></h1> 
    149141<?php 
    150142if ($profile==0) { 
    151143    include('menu.php'); 
    152144} 
    153 } 
    154145?> 
     146<h2><?php echo $title; ?></h2> 
     147<?php 
     148} // endif not standalone 
     149?> 
  • trunk/wp-admin/edit-form-advanced.php

    r830 r831  
    154154 
    155155<?php 
    156 if ($action != 'editcomment') { 
    157     if ( ($use_fileupload) && ($user_level >= $fileupload_minlevel) 
    158          && (in_array($user_login, $allowed_users) || (trim($fileupload_allowedusers)=="")) ) { ?> 
    159 <p><input type="button" value="Upload a file or image" onclick="launchupload();" tabindex="10" /></p> 
    160 <?php } 
    161 } 
    162  
    163  
    164156 
    165157// if the level is 5+, allow user to edit the timestamp - not on 'new post' screen though 
  • trunk/wp-admin/edit-form.php

    r830 r831  
    120120  <input name="referredby" type="hidden" id="referredby" value="<?php echo $HTTP_SERVER_VARS['HTTP_REFERER']; ?>" /> 
    121121</p> 
    122 <?php 
    123     if ( ($use_fileupload) && ($user_level >= $fileupload_minlevel) 
    124          && (in_array($user_login, $allowed_users) || (trim($fileupload_allowedusers)=="")) ) { ?> 
    125 <p><input type="button" value="Upload a file or image" onclick="launchupload();" tabindex="10" /></p> 
    126 <?php } ?> 
     122 
    127123</div> 
    128124</form> 
  • trunk/wp-admin/menu.php

    r819 r831  
    1 <h1 id="wphead"><a href="http://wordpress.org" rel="external">WordPress</a></h1> 
    21 
    32<ul id="adminmenu"> 
     
    1413        $self = str_replace('/wp-admin/', '', $PHP_SELF); 
    1514        if ((substr($self, -20) == substr($item[1], -20)) || ($parent_file && ($item[1] == $parent_file))) $class = ' class="current"'; 
    16         if ($user_level >= $item[0]) echo "\n\t<li><a href='{$item[1]}'$class>{$item[2]}</a></li>"; 
     15        if ($user_level >= $item[0]) { 
     16            if (('upload.php' == $item[1] && $use_fileupload && ($user_level >= $fileupload_minlevel) 
     17         && (in_array($user_login, explode(' ', $allowed_users)) || (trim($fileupload_allowedusers)==""))) || 'upload.php' != $item[1]) 
     18                echo "\n\t<li><a href='{$item[1]}'$class>{$item[2]}</a></li>"; 
     19        } 
    1720    } 
    1821} 
    1922 
    2023?> 
    21     <li><a href="<?php echo "$siteurl/$blogfilename"; ?>">View site</a></li> 
    22     <li class="last"><a href="<?php echo $siteurl ?>/wp-login.php?action=logout">Logout (<?php echo stripslashes($user_nickname) ?>)</a></li> 
     24    <li><a href="<?php echo "$siteurl/$blogfilename"; ?>" title="View your site">View site</a></li> 
     25    <li class="last"><a href="<?php echo $siteurl ?>/wp-login.php?action=logout" title="Logout of this account">Logout (<?php echo stripslashes($user_nickname) ?>)</a></li> 
    2326</ul> 
    24  
    25 <h2><?php echo $title; ?></h2> 
  • trunk/wp-admin/menu.txt

    r819 r831  
    664   options.php Options 
    774   templates.php   Templates 
     85   upload.php  Upload 
    890   profile.php My Profile 
    910*** 
  • trunk/wp-admin/upload.php

    r765 r831  
    11<?php 
    2 /* WP File Upload - original hack by shockingbird.com */ 
    3  
    4 $standalone="1"; 
    5 require_once("./admin-header.php"); 
     2$title = 'Upload Image or File'; 
     3 
     4require_once('admin-header.php'); 
    65 
    76if ($user_level == 0) //Checks to see if user has logged in 
    8 die ("Cheatin' uh ?"); 
     7   die ("Cheatin' uh ?"); 
    98 
    109if (!$use_fileupload) //Checks if file upload is enabled in the config 
    11 die ("The admin disabled this function"); 
    12  
    13 $allowed_types = explode(" ", trim($fileupload_allowedtypes)); 
    14  
    15 ?><html> 
    16 <head> 
    17 <title>WordPress &raquo; Upload images/files</title> 
    18 <style type="text/css"> 
    19 <!-- 
    20 body { 
    21  
    22     margin: 30px; 
     10    die ("The admin disabled this function"); 
     11 
     12$allowed_types = explode(' ', trim($fileupload_allowedtypes)); 
     13 
     14if ($HTTP_POST_VARS['submit']) { 
     15    $action = 'upload'; 
     16} else { 
     17    $action = ''; 
    2318} 
    24 <?php 
    25 if (!$is_NS4) { 
    26 ?> 
    27 textarea,input,select { 
    28     background-color: white; 
    29   border-width: 1px; 
    30     border-color: #cccccc; 
    31     border-style: solid; 
    32     padding: 2px; 
    33     margin: 1px; 
    34 
    35 <?php if (!$is_gecko) { ?> 
    36 .checkbox { 
    37     border-width: 0px; 
    38     border-color: transparent; 
    39     border-style: solid; 
    40     padding: 0px; 
    41     margin: 0px; 
    42 
    43 .uploadform { 
    44     background-color: white; 
    45 <?php if ($is_winIE) { ?> 
    46     filter: alpha(opacity:100); 
    47 <?php } ?> 
    48     border-width: 1px; 
    49     border-color: #333333; 
    50     border-style: solid; 
    51     padding: 2px; 
    52     margin: 1px; 
    53     width: 265px; 
    54     height: 24px; 
    55 
    56 <?php } ?> 
    57 <?php 
    58 
    59 ?> 
    60 --> 
    61 </style> 
    62 <script type="text/javascript"> 
    63 <!-- // idocs.com's popup tutorial rules ! 
    64 function targetopener(blah, closeme, closeonly) { 
    65     if (! (window.focus && window.opener))return true; 
    66     window.opener.focus(); 
    67     if (! closeonly)window.opener.document.post.content.value += blah; 
    68     if (closeme)window.close(); 
    69     return false; 
    70 
    71 //--> 
    72 </script> 
    73 </head> 
    74 <body> 
    75  
    76 <table align="center" width="100%" height="100%" cellpadding="15" cellspacing="0" border="1" style="border-width: 1px; border-color: #cccccc;"> 
    77     <tbody> 
    78     <tr> 
    79     <td valign="top" style="background-color: transparent; <?php if ($is_gecko || $is_macIE) { ?>background-image: url('../wp-images/bgbookmarklet3.gif');<?php } elseif ($is_winIE) { ?>background-color: #cccccc; filter: alpha(opacity:60);<?php } ?>;"> 
    80 <?php 
    81  
    82 if (!$HTTP_POST_VARS["submit"]) { 
    83     $i = implode(", ", $allowed_types); 
    84 ?> 
    85     <p><strong>File upload</strong></p> 
    86     <p>You can upload files of type:<br /><em><?php echo $i ?></em></p> 
    87     <p>The maximum size of the file should be:<br /><em><?php echo $fileupload_maxk ?> KB</em></p> 
    88     <form action="upload.php" method="post" enctype="multipart/form-data"> 
    89     <input type="hidden" name="MAX_FILE_SIZE" value="<?php echo $fileupload_maxk*1024 ?>" /> 
    90     <input type="file" name="img1" size="30" class="uploadform" /> 
    91     <br /><br /> 
    92     Description:<br /> 
    93     <input type="text" name="imgdesc" size="30" class="uploadform" /> 
    94     <br /><br /> 
    95     <input type="submit" name="submit" value="upload !" class="search" /> 
    96     </form> 
    97     </td> 
    98     </tr> 
    99     </tbody> 
    100 </table> 
    101 </body> 
    102 </html><?php die(); 
    103 
    104  
    105  
    106  
    107 ?> 
    108  
    109  
    110  
    111 <?php  //Makes sure they choose a file 
     19 
     20if (!is_writable($fileupload_realpath)) 
     21    $action = 'not-writable'; 
     22?> 
     23 
     24<div class="wrap"> 
     25 
     26<?php 
     27switch ($action) { 
     28case 'not-writable': 
     29?> 
     30<p>It doesn't look like you can use the file upload feature at this time because the directory you have specified (<code><?php echo $fileupload_realpath; ?></code>) doesn't appear to be writable by WordPress. Check the permissions on the directory and for typos.</p> 
     31 
     32<?php 
     33break; 
     34case '': 
     35    foreach ($allowed_types as $type) { 
     36        $type_tags[] = "<code>$type</code>"; 
     37    } 
     38    $i = implode(', ', $type_tags); 
     39?> 
     40    <p>You can upload files with the extension <?php echo $i ?> as long as they are no larger than <?php echo $fileupload_maxk; ?> <abbr title="Kilobytes">KB</abbr>. If you&#8217;re an admin your can configure these values under <a href="options.php">options</a>.</p> 
     41    <form action="upload.php" method="post" enctype="multipart/form-data"> 
     42    <p> 
     43      <label for="img1">File:</label> 
     44      <br /> 
     45    <input type="hidden" name="MAX_FILE_SIZE" value="<?php echo $fileupload_maxk * 1024 ?>" /> 
     46    <input type="file" name="img1" id="img1" size="35" class="uploadform" /></p> 
     47    <p> 
     48      <label for="imgdesc">Description:</label><br /> 
     49    <input type="text" name="imgdesc" id="imgdesc" size="30" class="uploadform" /> 
     50    </p> 
     51     
     52    <p>Create a thumbnail?</p> 
     53    <p> 
     54    <label for="thumbsize_no"> 
     55    <input type="radio" name="thumbsize" value="none" checked="checked" id="thumbsize_no" /> 
     56    No thanks</label> 
     57    <br /> 
     58        <label for="thumbsize_small"> 
     59<input type="radio" name="thumbsize" value="small" id="thumbsize_small" /> 
     60Small (200px largest side)</label> 
     61        <br /> 
     62        <label for="thumbsize_large"> 
     63<input type="radio" name="thumbsize" value="large" id="thumbsize_large" /> 
     64Large (400px largest side)</label> 
     65        <br /> 
     66        <label for="thumbsize_custom"> 
     67        <input type="radio" name="thumbsize" value="custom" id="thumbsize_custom" /> 
     68        Custom size</label> 
     69      :  
     70      <input type="text" name="imgthumbsizecustom" size="4" /> 
     71      px (largest side)    </p> 
     72    <p><input type="submit" name="submit" value="Upload File" /></p> 
     73    </form> 
     74</div><?php  
     75break; 
     76case 'upload': 
     77?> 
     78 
     79<?php //Makes sure they choose a file 
    11280 
    11381//print_r($HTTP_POST_FILES); 
    11482//die(); 
    11583 
    116 if (!empty($HTTP_POST_VARS)) { //$img1_name != "") { 
    117  
    118     $imgalt = (isset($HTTP_POST_VARS['imgalt'])) ? $HTTP_POST_VARS['imgalt'] : $imgalt; 
    119  
    120     $img1_name = (strlen($imgalt)) ? $HTTP_POST_VARS['imgalt'] : $HTTP_POST_FILES['img1']['name']; 
    121     $img1_type = (strlen($imgalt)) ? $HTTP_POST_VARS['img1_type'] : $HTTP_POST_FILES['img1']['type']; 
    122     $imgdesc = str_replace('"', '&amp;quot;', $HTTP_POST_VARS['imgdesc']); 
    123  
    124     $imgtype = explode(".",$img1_name); 
    125     $imgtype = $imgtype[count($imgtype)-1]; 
    126  
    127     if (in_array($imgtype, $allowed_types) == false) { 
    128         die("File $img1_name of type $imgtype is not allowed."); 
    129     } 
    130  
    131     if (strlen($imgalt)) { 
    132         $pathtofile = $fileupload_realpath."/".$imgalt; 
    133         $img1 = $HTTP_POST_VARS['img1']; 
    134     } else { 
    135         $pathtofile = $fileupload_realpath."/".$img1_name; 
    136         $img1 = $HTTP_POST_FILES['img1']['tmp_name']; 
    137     } 
    138  
    139     // makes sure not to upload duplicates, rename duplicates 
    140     $i = 1; 
    141     $pathtofile2 = $pathtofile; 
    142     $tmppathtofile = $pathtofile2; 
    143     $img2_name = $img1_name; 
    144  
    145     while (file_exists($pathtofile2)) { 
    146         $pos = strpos($tmppathtofile, '.'.trim($imgtype)); 
    147         $pathtofile_start = substr($tmppathtofile, 0, $pos); 
    148         $pathtofile2 = $pathtofile_start.'_'.zeroise($i++, 2).'.'.trim($imgtype); 
    149         $img2_name = explode('/', $pathtofile2); 
    150         $img2_name = $img2_name[count($img2_name)-1]; 
    151     } 
    152  
    153     if (file_exists($pathtofile) && !strlen($imgalt)) { 
    154         $i = explode(" ",$fileupload_allowedtypes); 
    155         $i = implode(", ",array_slice($i, 1, count($i)-2)); 
    156         $moved = move_uploaded_file($img1, $pathtofile2); 
    157         // if move_uploaded_file() fails, try copy() 
    158         if (!$moved) { 
    159             $moved = copy($img1, $pathtofile2); 
    160         } 
    161         if (!$moved) { 
    162             die("Couldn't Upload Your File to $pathtofile2."); 
    163         } else { 
    164             @unlink($img1); 
    165         } 
    166      
    167     // duplicate-renaming function contributed by Gary Lawrence Murphy 
    168     ?> 
    169     <p><strong>Duplicate File?</strong></p> 
    170     <p><b><em>The filename '<?php echo $img1_name; ?>' already exists!</em></b></p> 
    171     <p> filename '<?php echo $img1; ?>' moved to '<?php echo "$pathtofile2 - $img2_name"; ?>'</p> 
    172     <p>Confirm or rename:</p> 
    173     <form action="upload.php" method="post" enctype="multipart/form-data"> 
    174     <input type="hidden" name="MAX_FILE_SIZE" value="<?php echo $fileupload_maxk*1024 ?>" /> 
    175     <input type="hidden" name="img1_type" value="<?php echo $img1_type;?>" /> 
    176     <input type="hidden" name="img1_name" value="<?php echo $img2_name;?>" /> 
    177     <input type="hidden" name="img1_size" value="<?php echo $img1_size;?>" /> 
    178     <input type="hidden" name="img1" value="<?php echo $pathtofile2;?>" /> 
    179     Alternate name:<br /><input type="text" name="imgalt" size="30" class="uploadform" value="<?php echo $img2_name;?>" /><br /> 
    180     <br /> 
    181     Description:<br /><input type="text" name="imgdesc" size="30" class="uploadform" value="<?php echo $imgdesc;?>" /> 
    182     <br /> 
    183     <input type="submit" name="submit" value="confirm !" class="search" /> 
    184     </form> 
    185     </td> 
    186     </tr> 
    187     </tbody> 
    188 </table> 
    189 </body> 
    190 </html><?php die(); 
    191  
    192     } 
    193  
    194     if (!strlen($imgalt)) { 
    195         @$moved = move_uploaded_file($img1, $pathtofile); //Path to your images directory, chmod the dir to 777 
    196         // move_uploaded_file() can fail if open_basedir in PHP.INI doesn't 
    197         // include your tmp directory. Try copy instead? 
    198         if(!moved) { 
    199             $moved = copy($img1, $pathtofile); 
    200         } 
    201         // Still couldn't get it. Give up. 
    202         if (!moved) { 
    203             die("Couldn't Upload Your File to $pathtofile."); 
    204         } else { 
    205             @unlink($img1); 
    206         } 
    207     } else { 
    208         rename($img1, $pathtofile) 
    209         or die("Couldn't Upload Your File to $pathtofile."); 
    210     } 
    211  
    212 
     84 
     85    $imgalt = (isset($HTTP_POST_VARS['imgalt'])) ? $HTTP_POST_VARS['imgalt'] : $imgalt; 
     86 
     87    $img1_name = (strlen($imgalt)) ? $HTTP_POST_VARS['imgalt'] : $HTTP_POST_FILES['img1']['name']; 
     88    $img1_type = (strlen($imgalt)) ? $HTTP_POST_VARS['img1_type'] : $HTTP_POST_FILES['img1']['type']; 
     89    $imgdesc = str_replace('"', '&amp;quot;', $HTTP_POST_VARS['imgdesc']); 
     90 
     91    $imgtype = explode(".",$img1_name); 
     92    $imgtype = $imgtype[count($imgtype)-1]; 
     93 
     94    if (in_array($imgtype, $allowed_types) == false) { 
     95        die("File $img1_name of type $imgtype is not allowed."); 
     96    } 
     97 
     98    if (strlen($imgalt)) { 
     99        $pathtofile = $fileupload_realpath."/".$imgalt; 
     100        $img1 = $HTTP_POST_VARS['img1']; 
     101    } else { 
     102        $pathtofile = $fileupload_realpath."/".$img1_name; 
     103        $img1 = $HTTP_POST_FILES['img1']['tmp_name']; 
     104    } 
     105 
     106    // makes sure not to upload duplicates, rename duplicates 
     107    $i = 1; 
     108    $pathtofile2 = $pathtofile; 
     109    $tmppathtofile = $pathtofile2; 
     110    $img2_name = $img1_name; 
     111 
     112    while (file_exists($pathtofile2)) { 
     113        $pos = strpos($tmppathtofile, '.'.trim($imgtype)); 
     114        $pathtofile_start = substr($tmppathtofile, 0, $pos); 
     115        $pathtofile2 = $pathtofile_start.'_'.zeroise($i++, 2).'.'.trim($imgtype); 
     116        $img2_name = explode('/', $pathtofile2); 
     117        $img2_name = $img2_name[count($img2_name)-1]; 
     118    } 
     119 
     120    if (file_exists($pathtofile) && !strlen($imgalt)) { 
     121        $i = explode(" ",$fileupload_allowedtypes); 
     122        $i = implode(", ",array_slice($i, 1, count($i)-2)); 
     123        $moved = move_uploaded_file($img1, $pathtofile2); 
     124        // if move_uploaded_file() fails, try copy() 
     125        if (!$moved) { 
     126            $moved = copy($img1, $pathtofile2); 
     127        } 
     128        if (!$moved) { 
     129            die("Couldn't Upload Your File to $pathtofile2."); 
     130        } else { 
     131            @unlink($img1); 
     132        } 
     133     
     134    // duplicate-renaming function contributed by Gary Lawrence Murphy 
     135    ?> 
     136    <p><strong>Duplicate File?</strong></p> 
     137    <p><b><em>The filename '<?php echo $img1_name; ?>' already exists!</em></b></p> 
     138    <p> filename '<?php echo $img1; ?>' moved to '<?php echo "$pathtofile2 - $img2_name"; ?>'</p> 
     139    <p>Confirm or rename:</p> 
     140    <form action="upload.php" method="post" enctype="multipart/form-data"> 
     141    <input type="hidden" name="MAX_FILE_SIZE" value="<?php echo $fileupload_maxk*1024 ?>" /> 
     142    <input type="hidden" name="img1_type" value="<?php echo $img1_type;?>" /> 
     143    <input type="hidden" name="img1_name" value="<?php echo $img2_name;?>" /> 
     144    <input type="hidden" name="img1_size" value="<?php echo $img1_size;?>" /> 
     145    <input type="hidden" name="img1" value="<?php echo $pathtofile2;?>" /> 
     146    <input type="hidden" name="thumbsize" value="<?php echo $_REQUEST['thumbsize'];?>" /> 
     147    <input type="hidden" name="imgthumbsizecustom" value="<?php echo $_REQUEST['imgthumbsizecustom'];?>" /> 
     148    Alternate name:<br /><input type="text" name="imgalt" size="30" class="uploadform" value="<?php echo $img2_name;?>" /><br /> 
     149    <br /> 
     150    Description:<br /><input type="text" name="imgdesc" size="30" class="uploadform" value="<?php echo $imgdesc;?>" /> 
     151    <br /> 
     152    <input type="submit" name="submit" value="Rename" class="search" /> 
     153    </form> 
     154</div> 
     155<?php  
     156require('admin-footer.php'); 
     157die(); 
     158 
     159    } 
     160 
     161    if (!strlen($imgalt)) { 
     162        @$moved = move_uploaded_file($img1, $pathtofile); //Path to your images directory, chmod the dir to 777 
     163        // move_uploaded_file() can fail if open_basedir in PHP.INI doesn't 
     164        // include your tmp directory. Try copy instead? 
     165        if(!moved) { 
     166            $moved = copy($img1, $pathtofile); 
     167        } 
     168        // Still couldn't get it. Give up. 
     169        if (!moved) { 
     170            die("Couldn't Upload Your File to $pathtofile."); 
     171        } else { 
     172            @unlink($img1); 
     173        } 
     174         
     175    } else { 
     176        rename($img1, $pathtofile) 
     177        or die("Couldn't Upload Your File to $pathtofile."); 
     178    } 
     179     
     180    if($HTTP_POST_VARS['thumbsize'] != 'none' ) { 
     181        if($HTTP_POST_VARS['thumbsize'] == 'small') { 
     182            $max_side = 200; 
     183        } 
     184        elseif($HTTP_POST_VARS['thumbsize'] == 'large') { 
     185            $max_side = 400; 
     186        } 
     187        elseif($HTTP_POST_VARS['thumbsize'] == 'custom') { 
     188            $max_side = $HTTP_POST_VARS['imgthumbsizecustom']; 
     189        } 
     190         
     191        $result = wp_create_thumbnail($pathtofile, $max_side, NULL); 
     192        if($result != 1) { 
     193            print $result; 
     194        } 
     195    } 
     196 
    213197 
    214198 
    215199if ( ereg('image/',$img1_type)) { 
    216     $piece_of_code = "&lt;img src=&quot;$fileupload_url/$img1_name&quot; alt=&quot;$imgdesc&quot; /&gt;";  
     200    $piece_of_code = "&lt;img src=&quot;$fileupload_url/$img1_name&quot; alt=&quot;$imgdesc&quot; /&gt;"; 
    217201} else { 
    218     $piece_of_code = "&lt;a href=&quot;$fileupload_url/$img1_name&quot; title=&quot;$imgdesc&quot; /&gt;$imgdesc&lt;/a&gt;";  
     202    $piece_of_code = "&lt;a href=&quot;$fileupload_url/$img1_name&quot; title=&quot;$imgdesc&quot; /&gt;$imgdesc&lt;/a&gt;"; 
    219203}; 
    220204 
    221205?> 
    222206 
    223 <p><strong>File uploaded !</strong></p> 
    224 <p>Your file <b><?php echo "$img1_name"; ?></b> was uploaded successfully !</p> 
    225 <p>Here's the code to display it:</p> 
    226 <p><form> 
    227 <!--<textarea cols="25" rows="3" wrap="virtual"><?php echo "&lt;img src=&quot;$fileupload_url/$img1_name&quot; border=&quot;0&quot; alt=&quot;&quot; /&gt;"; ?></textarea>--> 
    228 <input type="text" name="imgpath" value="<?php echo $piece_of_code; ?>" size="38" style="padding: 5px; margin: 2px;" /><br /> 
    229 <input type="button" name="close" value="Add the code to your post !" class="search" onClick="targetopener('<?php echo $piece_of_code; ?>')" style="margin: 2px;" /> 
    230 </form> 
     207<h3>File uploaded!</h3> 
     208<p>Your file <code><?php echo $img1_name; ?></code> was uploaded successfully !</p> 
     209<p>Here&#8217;s the code to display it:</p> 
     210<p><code><?php echo $piece_of_code; ?></code> 
    231211</p> 
    232212<p><strong>Image Details</strong>: <br /> 
    233 name:  
    234 <?php echo "$img1_name"; ?> 
     213Name: 
     214<?php echo $img1_name; ?> 
    235215<br /> 
    236 size:  
    237 <?php echo round($img1_size/1024,2); ?> KB 
    238 <br /> 
    239 type:  
    240 <?php echo "$img1_type"; ?> 
     216Size: 
     217<?php echo round($img1_size / 1024, 2); ?> <abbr title="Kilobyte">KB</abbr><br /> 
     218Type: 
     219<?php echo $img1_type; ?> 
    241220</p> 
    242 <p align="right"> 
    243 <form> 
    244 <input type="button" name="close" value="Close this window" class="search" onClick="window.close()" /> 
    245 </form> 
    246 </p> 
    247 </td> 
    248 </tr> 
    249 </tbody> 
    250 </table> 
    251  
    252 </body> 
    253  
    254 </html> 
     221</div> 
     222<p><a href="upload.php">Start over</a>.</p> 
     223<?php 
     224break; 
     225
     226include('admin-footer.php'); 
     227?>