| 136 | | ?> |
| 137 | | <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> |
| 138 | | <html xmlns="http://www.w3.org/1999/xhtml"> |
| 139 | | <head> |
| 140 | | <script type="text/javascript"> |
| 141 | | function validateImageName() { |
| 142 | | /* This is more for convenience than security. Server-side validation is very thorough.*/ |
| 143 | | obj = document.getElementById('upload'); |
| 144 | | r = /.jpg$|.gif$|.png$/i; |
| 145 | | if ( obj.value.match(r) ) |
| 146 | | return true; |
| 147 | | alert('Please select a JPG, PNG or GIF file.'); |
| 148 | | obj.parentNode.reset(); |
| 149 | | return false; |
| 150 | | } |
| 151 | | function cancelUpload() { |
| 152 | | o = document.getElementById('uploadForm'); |
| 153 | | o.method = 'GET'; |
| 154 | | o.action.value = 'view'; |
| 155 | | o.submit(); |
| 156 | | } |
| 157 | | </script> |
| 158 | | <style type="text/css"> |
| 159 | | label { |
| 160 | | float: left; |
| 161 | | width: 18%; |
| 162 | | } |
| 163 | | #title, #descr { |
| 164 | | width: 80%; |
| 165 | | margin-top: 2px; |
| 166 | | } |
| 167 | | #descr { |
| 168 | | height: 3em; |
| 169 | | v-align: top; |
| 170 | | } |
| 171 | | #buttons { |
| 172 | | width: 98%; |
| 173 | | text-align: right; |
| 174 | | } |
| 175 | | </style> |
| 176 | | </head> |
| 177 | | <body> |
| 178 | | <form enctype="multipart/form-data" id="uploadForm" method="POST" action="image-uploading.php" onsubmit="return validateImageName()"> |
| 179 | | <label for="upload">Image:</label><input type="file" id="upload" name="image" onchange="validateImageName()" /><br /> |
| 180 | | <label for="title">Title:</label><input type="text" id="title" name="imgtitle" /><br /> |
| 181 | | <label for="descr">Description:</label><input type="textarea" name="descr" id="descr" value="" /><br /> |
| 182 | | <input type="hidden" name="action" value="save" /> |
| 183 | | <input type="hidden" name="post" value="<?php echo $post; ?>" /> |
| 184 | | <input type="hidden" name="all" value="<?php echo $all; ?>" /> |
| 185 | | <div id="buttons"> |
| 186 | | <input type="submit" value="Upload" /> |
| 187 | | <input type="button" value="Cancel" onclick="cancelUpload()" /> |
| 188 | | </div> |
| 189 | | </form> |
| 190 | | </body> |
| 191 | | </html> |
| 192 | | <?php |
| 212 | | $images = $wpdb->get_results("SELECT ID, post_date, post_title, guid FROM $wpdb->posts WHERE post_status = 'object' AND left(post_type, 5) = 'image' $and_post ORDER BY $sort LIMIT $start, 10", ARRAY_A); |
| | 167 | $images = $wpdb->get_results("SELECT ID, post_date, post_title, guid FROM $wpdb->posts WHERE post_status = 'object' AND left(post_type, 5) = 'image' $and_post ORDER BY $sort LIMIT $start, $double", ARRAY_A); |
| | 183 | $uwidth_sum = 0; |
| | 184 | $images_html = ''; |
| | 185 | if ( count($images) > 0 ) { |
| | 186 | $images = array_slice( $images, 0, $num ); |
| | 187 | foreach ( $images as $key => $image ) { |
| | 188 | $image = array_merge($image, get_post_meta($image['ID'], 'imagedata', true) ); |
| | 189 | list($image['uwidth'], $image['uheight']) = get_udims($image['width'], $image['height']); |
| | 190 | $uwidth_sum += $image['uwidth']; |
| | 191 | $images_html .= "<div class='image left'><a href='{$image['guid']}' onclick='return false;' title='{$image['post_title']}'><img src='{$image['guid']}' alt='{$image['post_title']}' {$image['hwstring_small']} /></a></div>\n"; |
| | 192 | } |
| | 193 | } |
| | 194 | |
| | 195 | $images_width = $uwidth_sum + ( count($images) * 5 ) + 15; |
| | 196 | |
| | 197 | break; |
| | 198 | |
| | 199 | default: |
| | 200 | die('This script was not meant to be called directly.'); |
| | 201 | } |
| | 202 | |
| 235 | | <style type="text/css"> |
| 236 | | form { |
| 237 | | display: inline; |
| 238 | | } |
| 239 | | #images, #buttons { |
| 240 | | position: absolute; |
| 241 | | left: 0px; |
| 242 | | width: 98%; |
| 243 | | text-align: center; |
| 244 | | } |
| 245 | | #images { |
| 246 | | top: 0px; |
| 247 | | } |
| 248 | | #buttons { |
| 249 | | top: 112px; |
| 250 | | } |
| 251 | | </style> |
| | 207 | <meta http-equiv="imagetoolbar" content="no" /> |
| | 208 | <script type="text/javascript"> |
| | 209 | function validateImageName() { |
| | 210 | /* This is more for convenience than security. Server-side validation is very thorough.*/ |
| | 211 | obj = document.getElementById('upload'); |
| | 212 | r = /.jpg$|.gif$|.png$/i; |
| | 213 | if ( obj.value.match(r) ) |
| | 214 | return true; |
| | 215 | alert('Please select a JPG, PNG or GIF file.'); |
| | 216 | return false; |
| | 217 | } |
| | 218 | function cancelUpload() { |
| | 219 | o = document.getElementById('uploadForm'); |
| | 220 | o.method = 'GET'; |
| | 221 | o.action.value = 'view'; |
| | 222 | o.submit(); |
| | 223 | } |
| | 224 | </script> |
| | 225 | <style type="text/css"> |
| | 226 | body { |
| | 227 | font: 13px "Lucida Grande", "Lucida Sans Unicode", Tahoma, Verdana; |
| | 228 | border: none; |
| | 229 | margin: 0px; |
| | 230 | height: 150px; |
| | 231 | background: rgb(223, 232, 241); |
| | 232 | } |
| | 233 | form { |
| | 234 | margin: 6px 2px 0px 6px; |
| | 235 | } |
| | 236 | #wrap { |
| | 237 | clear: both; |
| | 238 | margin: 0px; |
| | 239 | padding: 0px; |
| | 240 | height: 133px; |
| | 241 | width: 100%; |
| | 242 | overflow: auto; |
| | 243 | } |
| | 244 | #images { |
| | 245 | clear: both; |
| | 246 | margin: 0px; |
| | 247 | padding: 5px 5px; |
| | 248 | height: 100px; |
| | 249 | width: <?php echo $images_width; ?>px; |
| | 250 | } |
| | 251 | .image { |
| | 252 | margin-right: 5px; |
| | 253 | } |
| | 254 | .image * { |
| | 255 | margin: 0px; |
| | 256 | padding: 0px; |
| | 257 | border: 0px; |
| | 258 | } |
| | 259 | .image a, .image a img, .image a:hover img, .image a:visited img, .image a:active img { |
| | 260 | text-decoration: none; |
| | 261 | float: left; |
| | 262 | display: block; |
| | 263 | text-align: center; |
| | 264 | } |
| | 265 | #menu { |
| | 266 | margin: 0px; |
| | 267 | list-style: none; |
| | 268 | background: rgb(109, 166, 209); |
| | 269 | padding: 4px 0px 0px 8px; |
| | 270 | text-align: left; |
| | 271 | border-bottom: 3px solid rgb(68, 138, 189); |
| | 272 | } |
| | 273 | #menu li { |
| | 274 | display: inline; |
| | 275 | margin: 0px; |
| | 276 | } |
| | 277 | #menu a, #menu a:visited, #menu a:active { |
| | 278 | padding: 1px 3px 3px; |
| | 279 | text-decoration: none; |
| | 280 | color: #345; |
| | 281 | background: transparent; |
| | 282 | } |
| | 283 | #menu a:hover { |
| | 284 | background: rgb(203, 214, 228); |
| | 285 | color: #000; |
| | 286 | } |
| | 287 | #menu .current a, #menu .current a:hover, #menu .current a:visited, #menu .current a:active { |
| | 288 | background: rgb(223, 232, 241); |
| | 289 | color: #000; |
| | 290 | border-right: 2px solid rgb(20, 86, 138); |
| | 291 | } |
| | 292 | .tip { |
| | 293 | color: rgb(109, 166, 209); |
| | 294 | padding: 1px 3px; |
| | 295 | } |
| | 296 | .inactive { |
| | 297 | color: #68a; |
| | 298 | padding: 1px 3px; |
| | 299 | } |
| | 300 | .left { |
| | 301 | float: left; |
| | 302 | } |
| | 303 | .right { |
| | 304 | float: right; |
| | 305 | } |
| | 306 | .center { |
| | 307 | text-align: center; |
| | 308 | } |
| | 309 | #menu li.spacer { |
| | 310 | margin-left: 40px; |
| | 311 | } |
| | 312 | label { |
| | 313 | float: left; |
| | 314 | width: 18%; |
| | 315 | } |
| | 316 | #title, #descr { |
| | 317 | width: 80%; |
| | 318 | margin-top: 2px; |
| | 319 | } |
| | 320 | #descr { |
| | 321 | height: 35px; |
| | 322 | v-align: top; |
| | 323 | } |
| | 324 | #buttons { |
| | 325 | width: 98%; |
| | 326 | margin-top: 2px; |
| | 327 | text-align: right; |
| | 328 | } |
| | 329 | </style> |
| 254 | | <div id="images"> |
| 255 | | <?php |
| 256 | | if ( count($images) > 0 ) { |
| 257 | | $imagerow = ''; |
| 258 | | $i = 1; |
| 259 | | foreach ( $images as $image ) { |
| 260 | | if ( $i++ > 5 ) break; |
| 261 | | $image = array_merge($image, get_post_meta($image['ID'], 'imagedata', true) ); |
| 262 | | ?> |
| 263 | | <a href="<?php echo $image['guid']; ?>" disabled="true"> |
| 264 | | <img src="<?php echo $image['guid']; ?>" alt="<?php echo $image['post_title']; ?>" <?php echo $image['hwstring_small']; ?> /> |
| 265 | | </a> |
| 266 | | <?php |
| 267 | | } |
| 268 | | } |
| 269 | | ?> |
| 270 | | <div> |
| 271 | | <div id="buttons"> |
| 272 | | <form action="image-uploading.php" method="GET"> |
| 273 | | <input type="hidden" name="action" value="view" /> |
| 274 | | <input type="hidden" name="all" value="<?php echo $all; ?>" /> |
| 275 | | <input type="hidden" name="post" value="<?php echo $post; ?>" /> |
| 276 | | <input type="hidden" name="start" value="0" /> |
| 277 | | <input type="submit" value="| < <" <?php if ( false === $back ) echo 'disabled="true" ' ?>/> |
| 278 | | </form> |
| 279 | | <form action="image-uploading.php" method="GET"> |
| 280 | | <input type="hidden" name="action" value="view" /> |
| 281 | | <input type="hidden" name="all" value="<?php echo $all; ?>" /> |
| 282 | | <input type="hidden" name="post" value="<?php echo $post; ?>" /> |
| 283 | | <input type="hidden" name="start" value="<?php echo $back; ?>" /> |
| 284 | | <input type="submit" value="< < < < <" <?php if ( false === $back ) echo 'disabled="true" ' ?>/> |
| 285 | | </form> |
| 286 | | <form action="image-uploading.php" method="GET"> |
| 287 | | <input type="hidden" name="action" value="upload" /> |
| 288 | | <input type="hidden" name="all" value="<?php echo $all; ?>" /> |
| 289 | | <input type="hidden" name="post" value="<?php echo $post; ?>" /> |
| 290 | | <input type="submit" value="Upload New" /> |
| 291 | | </form> |
| 292 | | <?php if ( $all ) : ?> |
| 293 | | <form action="image-uploading.php" method="GET"> |
| 294 | | <input type="hidden" name="action" value="view" /> |
| 295 | | <input type="hidden" name="all" value="" /> |
| 296 | | <input type="hidden" name="post" value="<?php echo $post; ?>" /> |
| 297 | | <input type="submit" value="Browse Attached" /> |
| 298 | | </form> |
| | 332 | <ul id="menu"> |
| | 333 | <li<?php echo $current_1; ?>><a href="image-uploading.php?action=upload&post=<?php echo $post; ?>&all=<?php echo $all; ?>">Upload Photo</a></li> |
| | 334 | <li<?php echo $current_2; ?>><a href="image-uploading.php?action=view&post=<?php echo $post; ?>">Browse Attached</a></li> |
| | 335 | <li<?php echo $current_3; ?>><a href="image-uploading.php?action=view&post=<?php echo $post; ?>&all=true">Browse All</a></li> |
| | 336 | <li> </li> |
| | 337 | <?php if ( false !== $back ) : ?> |
| | 338 | <li class="spacer"><a href="image-uploading.php?action=view&post=<?php echo $post; ?>&all=<?php echo $all; ?>&start=0" title="First">|<</a></li> |
| | 339 | <li><a href="image-uploading.php?action=view&post=<?php echo $post; ?>&all=<?php echo $all; ?>&start=<?php echo $back; ?>" title="Back"><<</a></li> |
| 307 | | <form action="image-uploading.php" method="GET"> |
| 308 | | <input type="hidden" name="action" value="view" /> |
| 309 | | <input type="hidden" name="all" value="<?php echo $all; ?>" /> |
| 310 | | <input type="hidden" name="post" value="<?php echo $post; ?>" /> |
| 311 | | <input type="hidden" name="start" value="<?php echo $next; ?>" /> |
| 312 | | <input type="submit" value="> > > > >" <?php if ( false === $next ) echo 'disabled="true" ' ?>/> |
| 313 | | </form> |
| 314 | | <form action="image-uploading.php" method="GET"> |
| 315 | | <input type="hidden" name="action" value="view" /> |
| 316 | | <input type="hidden" name="all" value="<?php echo $all; ?>" /> |
| 317 | | <input type="hidden" name="post" value="<?php echo $post; ?>" /> |
| 318 | | <input type="hidden" name="last" value="true" /> |
| 319 | | <input type="submit" value="> > |" <?php if ( false === $next ) echo 'disabled="true" ' ?>/> |
| 320 | | </form> |
| 321 | | </div> |
| 322 | | <?php // echo "<pre>".print_r($images,1)."</pre>"; |
| 323 | | ?> |
| | 344 | <?php if ( false !== $next ) : ?> |
| | 345 | <li><a href="image-uploading.php?action=view&post=<?php echo $post; ?>&all=<?php echo $all; ?>&start=<?php echo $next; ?>" title="Next">>></a></li> |
| | 346 | <li><a href="image-uploading.php?action=view&post=<?php echo $post; ?>&all=<?php echo $all; ?>&last=true" title="Last">>|</a></li> |
| | 347 | <?php else : ?> |
| | 348 | <li class="inactive">>></li> |
| | 349 | <li class="inactive">>|</li> |
| | 350 | <?php endif; ?> |
| | 351 | </ul> |
| | 352 | <?php if ( $action == 'view' ) : ?> |
| | 353 | <span class="left tip">Drag and drop photos to post</span> |
| | 354 | <span class="right tip">Click photos for more options</span> |
| | 355 | <div id="wrap"> |
| | 356 | <div id="images"> |
| | 357 | <?php echo $images_html; ?> |
| | 358 | </div> |
| | 359 | </div> |
| | 360 | <?php elseif ( $action = 'upload' ) : ?> |
| | 361 | <div class="center tip">Duplicated filenames will be numbered (photo.jpg, photo1.jpg, etc.)</div> |
| | 362 | <form enctype="multipart/form-data" id="uploadForm" method="POST" action="image-uploading.php" onsubmit="return validateImageName()"> |
| | 363 | <label for="upload">Image:</label><input type="file" id="upload" name="image" onchange="validateImageName()" /> |
| | 364 | <label for="title">Title:</label><input type="text" id="title" name="imgtitle" /> |
| | 365 | <label for="descr">Description:</label><input type="textarea" name="descr" id="descr" value="" /> |
| | 366 | <input type="hidden" name="action" value="save" /> |
| | 367 | <input type="hidden" name="post" value="<?php echo $post; ?>" /> |
| | 368 | <input type="hidden" name="all" value="<?php echo $all; ?>" /> |
| | 369 | <div id="buttons"> |
| | 370 | <input type="submit" value="Upload" /> |
| | 371 | <input type="button" value="Cancel" onclick="cancelUpload()" /> |
| | 372 | </div> |
| | 373 | </form> |
| | 374 | <?php endif; ?> |