Advertisement
Advertisement
| 08.28.2008 at 07:18AM PDT, ID: 23685543 | Points: 500 |
|
[x]
Attachment Details
|
||
1: 2: 3: 4: 5: 6: 7: 8: 9: 10: 11: 12: 13: 14: 15: 16: 17: 18: 19: 20: 21: 22: 23: 24: 25: 26: 27: 28: 29: 30: 31: 32: 33: 34: 35: 36: 37: 38: 39: 40: 41: 42: 43: 44: 45: 46: 47: 48: 49: 50: 51: 52: 53: 54: 55: 56: 57: 58: 59: 60: 61: 62: 63: 64: 65: 66: 67: 68: 69: 70: 71: 72: 73: 74: 75: 76: 77: 78: 79: 80: 81: 82: 83: 84: 85: 86: 87: 88: 89: 90: 91: 92: 93: 94: 95: 96: 97: 98: 99: 100: 101: 102: 103: 104: 105: 106: 107: 108: 109: 110: 111: 112: 113: 114: 115: 116: 117: 118: 119: 120: 121: 122: 123: 124: 125: 126: 127: 128: 129: 130: 131: 132: 133: 134: 135: 136: 137: 138: 139: 140: 141: 142: 143: 144: 145: 146: 147: 148: 149: 150: 151: 152: 153: 154: 155: 156: 157: 158: 159: 160: 161: 162: 163: 164: 165: 166: 167: 168: 169: 170: 171: 172: 173: 174: 175: 176: 177: 178: 179: 180: 181: 182: 183: 184: 185: 186: 187: 188: 189: 190: 191: 192: 193: 194: 195: 196: 197: 198: 199: 200: 201: 202: 203: 204: 205: 206: 207: 208: 209: 210: 211: 212: 213: 214: 215: 216: 217: 218: 219: 220: 221: 222: 223: 224: 225: 226: 227: 228: 229: 230: 231: 232: 233: 234: 235: 236: 237: 238: 239: 240: 241: 242: 243: 244: 245: 246: 247: 248: 249: 250: 251: 252: 253: 254: 255: 256: 257: 258: 259: 260: 261: 262: 263: 264: 265: 266: 267: 268: 269: 270: 271: 272: 273: 274: 275: 276: 277: 278: 279: 280: 281: 282: 283: 284: 285: 286: 287: 288: 289: 290: 291: 292: 293: 294: 295: 296: 297: 298: 299: 300: 301: 302: 303: 304: 305: 306: 307: 308: 309: 310: 311: 312: 313: 314: 315: 316: 317: 318: 319: 320: 321: 322: 323: 324: 325: 326: 327: 328: 329: 330: 331: 332: 333: 334: 335: 336: 337: 338: 339: 340: 341: 342: 343: 344: 345: 346: 347: 348: 349: 350: 351: 352: 353: 354: 355: 356: 357: 358: 359: 360: 361: 362: 363: 364: 365: 366: 367: 368: 369: 370: 371: 372: 373: 374: 375: 376: 377: 378: 379: 380: 381: 382: 383: 384: 385: 386: 387: 388: 389: 390: 391: 392: 393: 394: 395: 396: 397: 398: 399: 400: 401: 402: 403: 404: 405: 406: 407: 408: 409: 410: 411: 412: 413: 414: 415: 416: 417: 418: 419: 420: 421: 422: 423: 424: 425: 426: 427: 428: 429: 430: 431: 432: 433: 434: 435: 436: 437: 438: 439: 440: 441: 442: 443: 444: 445: 446: 447: 448: 449: 450: 451: 452: 453: 454: 455: 456: 457: 458: 459: 460: 461: 462: 463: 464: 465: 466: 467: 468: 469: 470: 471: 472: 473: 474: 475: 476: 477: 478: 479: 480: 481: 482: 483: 484: 485: 486: 487: 488: 489: 490: 491: 492: 493: 494: 495: 496: 497: 498: 499: 500: 501: |
<?
session_start('login'); // Resume Session.
include('../config.php');
if(session_is_registered(valid_user)) {
echo "<!-- Logged In --> \n";
} else {
// Include Login Page
include('../index.php');
exit;
}
?>
<?php
include('../config.php');
include('../../functions.php');
$pagenum = $_GET["id"];
if($pagenum == "") {
$pagenum = $_POST['id'];
}
if ($_GET['method'] == "delete") {
$photo = $_GET['photo'];
$link = mysql_connect($datab, $user, $pass) or die("Could not connect: " . mysql_error());
mysql_select_db($data_base) or die("Could not select database");
$query = "SELECT * FROM gallery WHERE id=\"$photo\"";
$result = mysql_query($query) or die("Query failed : " . mysql_error());
while ($row = mysql_fetch_assoc($result)) {
if (file_exists("../../images/gallery/".$row['file'])) {
// Delete Image
unlink("../../images/gallery/".$row['file']);
}
}
$link = mysql_connect($datab, $user, $pass) or die("Could not connect: " . mysql_error());
mysql_select_db($data_base) or die("Could not select database");
$query = "DELETE FROM `gallery` WHERE `id` = $photo LIMIT 1";
$result = mysql_query($query) or die("Query failed : " . mysql_error());
}
if ($_POST['addgallery'] == "true") {
$link = mysql_connect($datab, $user, $pass) or die("Could not connect: " . mysql_error());
mysql_select_db($data_base) or die("Could not select database");
$query = "SELECT max(id) as nextid FROM gallery";
$result = mysql_query($query) or die("Query failed : " . mysql_error());
while ($row = mysql_fetch_assoc($result)) {
// $imagename2 = $row['nextid'] + 1;
// $imagename = $imagename2.".jpg";
}
$insertcaption = $_POST['caption'];
$insertpage = $_POST['id'];
$insertdescription = $_POST['description'];
$link = mysql_connect($datab, $user, $pass) or die("Could not connect: " . mysql_error());
mysql_select_db($data_base) or die("Could not select database");
$query = "INSERT INTO `gallery` ( `id` , `page` , `caption` , `file`, `description`) VALUES ('', '$insertpage', '$insertcaption', '$imagename', '$insertdescription')";
mysql_query($query) or die("Query failed : " . mysql_error());
$insertedinto = mysql_insert_id();
$imagename = mysql_insert_id().".jpg";
$thumbnail = '../../images/gallery/' . mysql_insert_id()."_thumb.jpg";
$normalimage = '../../images/gallery/' . mysql_insert_id()."_normal.jpg";
$link = mysql_connect($datab, $user, $pass) or die("Could not connect: " . mysql_error());
mysql_select_db($data_base) or die("Could not select database");
$query = "UPDATE `gallery` SET file='$imagename' WHERE id='$insertedinto'";
mysql_query($query) or die("Query failed : " . mysql_error());
# Uploading of File
$uploaddir = $_SERVER['DOCUMENT_ROOT'].'/images/gallery';
$uploadfile = $uploaddir."/".$imagename; //. basename($_FILES['userfile']['name']);
// echo $uploadfile;
//
// exit;
if (move_uploaded_file($_FILES['userfile']['tmp_name'], $uploadfile)) {
// echo "File is valid, and was successfully uploaded.\n";
list($width, $height, $type, $attr) = getimagesize($uploadfile);
// echo "Supplied Image Size";
// echo "Width: " . $width . "px Height: " . $height . "px <br />";
if ($width == "629" && $height == "481") {
# Limited height and size is 629 (h) x 481 (w)
chmod($uploadfile, 0777);
// Create thumbnail image
# Generate a Thumbnail from the large image
// Resize image
$percent = 0.5;
// Content type
// Resize image
list($width, $height) = getimagesize($uploadfile);
$new_width = 70;
$new_height = 50;
// Resample the image
$image_p = imagecreatetruecolor($new_width, $new_height);
$image = imagecreatefromjpeg($uploadfile);
imagecopyresampled($image_p, $image, 0, 0, 0, 0, $new_width, $new_height, $width, $height);
// Output the actual image
imagejpeg($image_p, $thumbnail, 80);
###############################################################
$percent = 0.5;
// Content type
// Resize image
list($width, $height) = getimagesize($uploadfile);
$new_width = 350;
$new_height = 248;
// Resample the image
$image_p = imagecreatetruecolor($new_width, $new_height);
$image = imagecreatefromjpeg($uploadfile);
imagecopyresampled($image_p, $image, 0, 0, 0, 0, $new_width, $new_height, $width, $height);
// Output the actual image
imagejpeg($image_p, $normalimage, 80);
} else {
echo '<div style="border: 3px solid red; margin: 0 auto; width: 700px; text-align: center; color: red; font-family: verdana; background-color: #ffd1d6;">';
echo "<h4>Wrong Image Size - image must be 629px x 481px</h4>";
echo "Your image was " . $width . "px x " . $height . "px <br /><br />";
echo "</div>";
$link = mysql_connect($datab, $user, $pass) or die("Could not connect: " . mysql_error());
mysql_select_db($data_base) or die("Could not select database");
$query = "DELETE FROM `gallery` WHERE `id` = $insertedinto LIMIT 1";
$result = mysql_query($query) or die("Query failed : " . mysql_error());
if (file_exists($uploadfile)) {
// Delete Image
unlink($uploadfile);
}
}
} else {
echo "Possible file upload attack!\n";
}
}
if ($_POST['updateentry'] == "true") {
$newcaption = $_POST['caption'];
$toupdate = $_POST['phototoupdate'];
$newdescription = $_POST['description'];
// echo $newcaption;
// echo $toupdate;
$link = mysql_connect($datab, $user, $pass) or die("Could not connect: " . mysql_error());
mysql_select_db($data_base) or die("Could not select database");
$query = "UPDATE gallery SET caption=\"".$newcaption."\",description=\"".$newdescription."\" WHERE id=\"".$toupdate."\"";
$result = mysql_query($query) or die("Query failed : " . mysql_error());
}
if ($_POST['updatezoom'] == "true") {
$zoom = $_POST['zoomfeature'];
$link = mysql_connect($datab, $user, $pass) or die("Could not connect: " . mysql_error());
mysql_select_db($data_base) or die("Could not select database");
$query = "UPDATE prefs SET value=\"".$zoom."\" WHERE id='zoom_feature'";
$result = mysql_query($query) or die("Query failed : " . mysql_error());
}
if ($_POST['updateextended'] == "true") {
$extended = $_POST['extendedfeature'];
$link = mysql_connect($datab, $user, $pass) or die("Could not connect: " . mysql_error());
mysql_select_db($data_base) or die("Could not select database");
$query = "UPDATE prefs SET value=\"".$extended."\" WHERE id='show_gallery_description'";
$result = mysql_query($query) or die("Query failed : " . mysql_error());
}
$link = mysql_connect($datab, $user, $pass) or die("Could not connect: " . mysql_error());
mysql_select_db($data_base) or die("Could not select database");
$query = "SELECT * FROM pages WHERE id=\"$pagenum\"";
$result = mysql_query($query) or die("Query failed : " . mysql_error());
$num_rows = mysql_num_rows($result);
while ($row = mysql_fetch_assoc($result)) {
$content = $row["textcontent"];
$p_title = $row["pagetitle"];
$b_title = $row["menutext"];
$image_1 = $row["image1"];
$image1alt = $row["images1alt"];
$image_2 = $row["image2"];
$image2alt = $row["image2alt"];
$pagetype = $row["pagetype"];
}
?>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<title>Discovery Design Content Management System - Version 2.0</title>
<script src="../../scripts/master.js" language="javascript" type="text/javascript"></script>
<link href="../admin.css" type="text/css" media="all" rel="stylesheet" />
<script language="javascript" type="text/javascript" src="../../jscripts/tiny_mce/tiny_mce.js"></script>
<script language="javascript" type="text/javascript">
tinyMCE.init({
mode : "textareas",
relative_urls : false,
theme : "simple"
});
function toggleEditor(id) {
var elm = document.getElementById(id);
if (tinyMCE.getInstanceById(id) == null)
tinyMCE.execCommand('mceAddControl', false, id);
else
tinyMCE.execCommand('mceRemoveControl', false, id);
}
</script>
</head>
<body>
<table width="710" align="center">
<tr bgcolor="#13355E">
<td colspan="2" style="padding: 10px; font-size: 14px; color: white;">
Updating Page: <b><?php echo $b_title; ?> (This is a Photo Gallery Page)</b>
</td>
</tr>
</table>
<table width="710" align="center" style="background:#F2F2F2; ">
<?php
$link = mysql_connect($datab, $user, $pass) or die("Could not connect: " . mysql_error());
mysql_select_db($data_base) or die("Could not select database");
$query = "SELECT * FROM gallery WHERE page=\"$pagenum\" order by id";
$result = mysql_query($query) or die("Query failed : " . mysql_error());
$num_links = mysql_num_rows($result);
?>
<tr>
<td valign="top" bgcolor="#585858" style="color: white; font-weight: bold; font-size: 13px; padding: 5px;">Current Images (<?php echo $num_links; ?>)</td>
</tr>
<tr>
<td>
<form action="InlineGallery.php" method="post">
<table width="100%" cellpadding="5" cellspacing="1" bgcolor="#F5F5F5">
<tr>
<td colspan="3" bgcolor="#0869AF" style="color: white; font-weight: bold; font-size: 13px;">
Add a New Gallery Image
<?php
$link2 = mysql_connect($datab, $user, $pass) or die("Could not connect: " . mysql_error());
mysql_select_db($data_base) or die("Could not select database");
$query2 = "SELECT id,value FROM prefs where id='zoom_feature'";
$result2 = mysql_query($query2) or die("Query failed : " . mysql_error());
while ($row2 = mysql_fetch_assoc($result2)) {
$zoom = $row2['value'];
}
$link2 = mysql_connect($datab, $user, $pass) or die("Could not connect: " . mysql_error());
mysql_select_db($data_base) or die("Could not select database");
$query2 = "SELECT id,value FROM prefs where id='show_gallery_description'";
$result2 = mysql_query($query2) or die("Query failed : " . mysql_error());
while ($row2 = mysql_fetch_assoc($result2)) {
$extended = $row2['value'];
}
?>
<hr />Include Zoom Feature:
<input type="hidden" name="id" value="<?php echo $pagenum; ?>" />
<input type="hidden" name="updatezoom" value="true" />
<select name="zoomfeature">
<option value="yes" <?php if ($zoom == "yes") { echo "selected"; } ?>>Yes</option>
<option value="no" <?php if ($zoom == "no") { echo "selected"; } ?>>No</option>
</select>
<input type="submit" value="Update" />
</form>
<form action="InlineGallery.php" method="post">
<hr />Display Extended Description?:
<input type="hidden" name="id" value="<?php echo $pagenum; ?>" />
<input type="hidden" name="updateextended" value="true" />
<select name="extendedfeature">
<option value="yes" <?php if ($extended == "yes") { echo "selected"; } ?>>Yes</option>
<option value="no" <?php if ($extended == "no") { echo "selected"; } ?>>No</option>
</select>
<input type="submit" value="Update" />
</form>
</td>
</tr>
<form action="InlineGallery.php" method="post" enctype="multipart/form-data" />
<tr bgcolor="#17539D">
<td style="color: #FFFFFF;" width="10"><b>Photo</b></td>
<td colspan="2" style="color: #FFFFFF;"><b>Caption / Description</b></td>
</tr>
<input type="hidden" name="id" value="<?php echo $pagenum; ?>" />
<input type="hidden" name="addgallery" value="true" />
<tr>
<td valign="top">
<input type="file" name="userfile" />
<input type="hidden" name="MAX_FILE_SIZE" value="30000000" />
</td>
<td>
<b>Caption:</b><br />
<textarea name="caption" style="width: 100%; font-family: verdana; height: 20px;" /></textarea>
<b>Description:</b><br />
<textarea name="description" style="width: 100%; font-family: verdana; height: 130px;" /></textarea>
</td>
<td align="center" width="50" valign="bottom"><input type="submit" value="Upload New Gallery Entry" /></td>
</tr>
</table>
</form>
</td>
</tr>
<?php
if ($_GET['method'] == "edit") {
$phototoupdate = $_GET['photo'];
$link = mysql_connect($datab, $user, $pass) or die("Could not connect: " . mysql_error());
mysql_select_db($data_base) or die("Could not select database");
$query = "SELECT caption,description FROM gallery WHERE id=".$phototoupdate."";
$result = mysql_query($query) or die("Query failed : " . mysql_error());
while ($row = mysql_fetch_assoc($result)) {
$caption = $row['caption'];
$description = $row['description'];
}
echo "<tr>";
echo "<td>";
echo '<form action="InlineGallery.php" method="post" />';
echo '<table width="100%" cellpadding="5" cellspacing="1" bgcolor="#F5F5F5">';
echo '<tr>';
echo '<td colspan="3" bgcolor="red" style="color: white; font-weight: bold; font-size: 13px;">Edit Gallery Entry</td>';
echo '</tr>';
echo '<tr bgcolor="#E0E0E0">';
echo '<td style="color: #585858;" width="100"><b>Photo</b></td>';
echo '<td style="color: #585858;"><b>Caption</b></td>';
echo '<td> </td>';
echo '</tr>';
echo '<input type="hidden" name="id" value="'. $pagenum .'" />';
echo '<input type="hidden" name="phototoupdate" value="'. $_GET['photo'] .'" />';
echo '<input type="hidden" name="updateentry" value="true" />';
echo '<tr>';
echo '<td>';
echo "<img src=\"../../images/gallery/".$phototoupdate.".jpg\" width=\"175\" height=\"124\" style=\"border: 1px #000 solid;\" />";
echo '</td><td>';
echo '<b>Caption:</b><br />';
echo '<textarea name="caption" style="width: 100%; font-family: verdana; height: 20px;" />'.$caption.'</textarea>';
echo '<b>Description:</b><br />';
echo '<textarea name="description" style="width: 100%; font-family: verdana; height: 130px;" />'.$description.'</textarea></td>';
echo '<td align="center" width="100"><input type="submit" value="Update Caption" /></td>';
echo '</tr></table></form></td></tr>';
}
?>
<tr>
<td colspan="4">
<table width="100%" cellpadding="5" cellspacing="1">
<tr bgcolor="#17539d">
<td style="color: #FFFFFF;"><b>ID</b></td>
<td style="color: #FFFFFF;"><b>Image</b></td>
<td style="color: #FFFFFF;"><b>Caption</b></td>
<td style="color: #FFFFFF;" align="center"><b>Edit</b></td>
<td style="color: #FFFFFF;" align="center"><b>Delete</b></td>
</tr>
<?php
while ($row = mysql_fetch_assoc($result)) {
echo "<tr>";
echo "<td style=\"border-right: 1px #D4D4D4 solid; border-bottom: 1px #D4D4D4 solid;\" width=\"15\" align=\"center\">".$row['id']."</td>";
echo "<td style=\"border-right: 1px #D4D4D4 solid; border-bottom: 1px #D4D4D4 solid;\" width=\"150\" align=\"center\">";
if (file_exists("../../images/gallery/".$row['file'])) {
echo "<img src=\"showimage.php?thumb=".$row['file']."\" style=\"border: 1px #000 solid;\" /><br />";
echo $row['file'];
} else {
echo "<b style=\"color: red;\">The file $filename does not exist<br /></b>Has it been uploaded correctly?<br />";
}
echo "</td>";
echo "<td style=\"border-right: 1px #D4D4D4 solid; border-bottom: 1px #D4D4D4 solid;\" valign=\"top\">";
echo "<b>Caption:</b> <br />".$row['caption'];
echo "<br /><br />";
echo "<b>Description</b>: <br />".$row['description'];
echo "</td>";
echo "<td align=\"center\" style=\"background-color: #0BA80B; color: white;\" width=\"12%\">";
echo "<b><a href=\"InlineGallery.php?method=edit&id=".$pagenum."&photo=".$row['id']."\" style=\"color: white;\">Edit</a>";
echo "</td>";
echo "<td align=\"center\" style=\"background-color: #E85454; color: white;\" width=\"12%\">";
echo "<b><a href=\"InlineGallery.php?method=delete&id=".$pagenum."&photo=".$row['id']."\" style=\"color: white;\">Delete</a></b>";
echo "</td>";
}
?>
</table>
<br />
</td>
</tr>
</table>
</body>
</html>
|