| 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 | |
|---|
| | 20 | if (!is_writable($fileupload_realpath)) |
|---|
| | 21 | $action = 'not-writable'; |
|---|
| | 22 | ?> |
|---|
| | 23 | |
|---|
| | 24 | <div class="wrap"> |
|---|
| | 25 | |
|---|
| | 26 | <?php |
|---|
| | 27 | switch ($action) { |
|---|
| | 28 | case '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 |
|---|
| | 33 | break; |
|---|
| | 34 | case '': |
|---|
| | 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’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" /> |
|---|
| | 60 | Small (200px largest side)</label> |
|---|
| | 61 | <br /> |
|---|
| | 62 | <label for="thumbsize_large"> |
|---|
| | 63 | <input type="radio" name="thumbsize" value="large" id="thumbsize_large" /> |
|---|
| | 64 | Large (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 |
|---|
| | 75 | break; |
|---|
| | 76 | case 'upload': |
|---|
| | 77 | ?> |
|---|
| | 78 | |
|---|
| | 79 | <?php //Makes sure they choose a file |
|---|
| 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('"', '&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('"', '&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 |
|---|
| | 156 | require('admin-footer.php'); |
|---|
| | 157 | die(); |
|---|
| | 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 | |
|---|