2004-03-15 16:22:00 +00:00
|
|
|
<?
|
|
|
|
|
|
|
|
|
|
include("path.php");
|
|
|
|
|
require(BASE."include/"."incl.php");
|
2004-11-17 22:57:20 +00:00
|
|
|
require(BASE."include/"."application.php");
|
2004-03-15 16:22:00 +00:00
|
|
|
|
2004-12-10 01:07:45 +00:00
|
|
|
|
2004-03-15 16:22:00 +00:00
|
|
|
|
|
|
|
|
/*=========================================================================
|
|
|
|
|
*
|
|
|
|
|
* this script expects appId and versionId as arguments
|
|
|
|
|
*
|
|
|
|
|
* OR
|
|
|
|
|
*
|
|
|
|
|
* cmd and imageId
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if($cmd)
|
|
|
|
|
{
|
2004-11-17 22:57:20 +00:00
|
|
|
if(havepriv("admin") || isMaintainer($appId, $versionId))
|
|
|
|
|
{
|
|
|
|
|
//process screenshot upload
|
|
|
|
|
if($cmd == "screenshot_upload")
|
|
|
|
|
{
|
|
|
|
|
if(!copy($imagefile, "data/screenshots/".$appId."-".$versionId."-".basename($imagefile_name)))
|
|
|
|
|
{
|
|
|
|
|
// whoops, copy failed. do something
|
|
|
|
|
errorpage('debug: copy failed; $imagefile; $imagefile_name');
|
|
|
|
|
exit;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
$query = "INSERT INTO appData VALUES (null, $appId, $versionId, 'image', ".
|
|
|
|
|
"'".addslashes($screenshot_desc)."', '".$appId."-".$versionId."-".basename($imagefile_name)."')";
|
|
|
|
|
|
|
|
|
|
if(debugging()) { addmsg("<p align=center><b>query:</b> $query </p>",green); }
|
|
|
|
|
|
|
|
|
|
if (mysql_query($query))
|
|
|
|
|
{
|
|
|
|
|
//success
|
|
|
|
|
$email = getNotifyEmailAddressList($appId, $versionId);
|
|
|
|
|
if($email)
|
|
|
|
|
{
|
|
|
|
|
$fullAppName = "Application: ".lookupAppName($appId)." Version: ".lookupVersionName($appId, $versionId);
|
|
|
|
|
$ms .= APPDB_ROOT."screenshots.php?appId=$appId&versionId=$versionId"."\n";
|
|
|
|
|
$ms .= "\n";
|
2004-12-10 01:07:45 +00:00
|
|
|
$ms .= ($_SESSION['current']->username ? $_SESSION['current']->username : "Anonymous")." added screenshot ".$screenshot_desc." to ".$fullAppName."\n";
|
2004-11-17 22:57:20 +00:00
|
|
|
$ms .= "\n";
|
|
|
|
|
$ms .= STANDARD_NOTIFY_FOOTER;
|
|
|
|
|
|
|
|
|
|
mail(stripslashes($email), "[AppDB] ".$fullAppName ,$ms);
|
|
|
|
|
|
|
|
|
|
} else
|
|
|
|
|
{
|
|
|
|
|
$email = "no one";
|
|
|
|
|
}
|
|
|
|
|
addmsg("mesage sent to: ".$email, green);
|
|
|
|
|
|
|
|
|
|
addmsg("The image was successfully added into the database", "green");
|
|
|
|
|
redirect(apidb_fullurl("screenshots.php?appId=$appId&versionId=$versionId"));
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
//error
|
|
|
|
|
$statusMessage = "<p><b>Database Error!<br>".mysql_error()."</b></p>\n";
|
|
|
|
|
addmsg($statusMessage, "red");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
} else
|
2004-03-15 16:22:00 +00:00
|
|
|
{
|
|
|
|
|
if($cmd == "delete")
|
2004-11-17 22:57:20 +00:00
|
|
|
{
|
|
|
|
|
$result = mysql_query("DELETE FROM appData WHERE id = $imageId");
|
|
|
|
|
if($result)
|
|
|
|
|
{
|
|
|
|
|
$email = getNotifyEmailAddressList($appId, $versionId);
|
|
|
|
|
if($email)
|
|
|
|
|
{
|
|
|
|
|
$fullAppName = "Application: ".lookupAppName($appId)." Version: ".lookupVersionName($appId, $versionId);
|
|
|
|
|
$ms .= APPDB_ROOT."screenshots.php?appId=$appId&versionId=$versionId"."\n";
|
|
|
|
|
$ms .= "\n";
|
2004-12-10 01:07:45 +00:00
|
|
|
$ms .= ($_SESSION['current']->username ? $_SESSION['current']->username : "Anonymous")." deleted screenshot from ".$fullAppName."\n";
|
2004-11-17 22:57:20 +00:00
|
|
|
$ms .= "\n";
|
|
|
|
|
$ms .= STANDARD_NOTIFY_FOOTER;
|
|
|
|
|
|
|
|
|
|
mail(stripslashes($email), "[AppDB] ".$fullAppName ,$ms);
|
|
|
|
|
|
|
|
|
|
} else
|
|
|
|
|
{
|
|
|
|
|
$email = "no one";
|
|
|
|
|
}
|
|
|
|
|
addmsg("mesage sent to: ".$email, green);
|
|
|
|
|
|
|
|
|
|
addmsg("Image deleted", "green");
|
|
|
|
|
redirect(apidb_fullurl("screenshots.php?appId=$appId&versionId=$versionId"));
|
|
|
|
|
|
|
|
|
|
} else
|
|
|
|
|
{
|
|
|
|
|
addmsg("Failed to delete image: ".mysql_error(), "red");
|
|
|
|
|
redirect(apidb_fullurl("screenshots.php?appId=$appId&versionId=$versionId"));
|
|
|
|
|
}
|
|
|
|
|
}
|
2004-03-15 16:22:00 +00:00
|
|
|
}
|
2004-11-17 22:57:20 +00:00
|
|
|
}
|
2004-03-15 16:22:00 +00:00
|
|
|
exit;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
$result = mysql_query("SELECT * FROM appData WHERE type = 'image' AND appId = $appId AND versionId = $versionId");
|
2004-11-17 22:57:20 +00:00
|
|
|
if((!$result || !mysql_num_rows($result)) && (!havepriv("admin") && !isMaintainer($appId, $versionId)))
|
2004-03-15 16:22:00 +00:00
|
|
|
{
|
|
|
|
|
errorpage("No Screenshots Found","There are no screenshots currently linked to this application.");
|
|
|
|
|
exit;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
apidb_header("Screenshots");
|
2004-11-17 22:57:20 +00:00
|
|
|
if($result && mysql_num_rows($result))
|
2004-03-15 16:22:00 +00:00
|
|
|
{
|
2004-11-17 22:57:20 +00:00
|
|
|
echo html_frame_start("Screenshot Gallery",500);
|
|
|
|
|
|
|
|
|
|
// display thumbnails
|
|
|
|
|
$c = 1;
|
|
|
|
|
echo "<div align=center><table><tr>\n";
|
|
|
|
|
while($ob = mysql_fetch_object($result))
|
|
|
|
|
{
|
|
|
|
|
//set img tag
|
|
|
|
|
$imgSRC = '<img src="appimage.php?imageId='.$ob->id.'&width=128&height=128" border=0 alt="'.$ob->description.'">';
|
2004-03-15 16:22:00 +00:00
|
|
|
|
2004-11-17 22:57:20 +00:00
|
|
|
//get image size
|
|
|
|
|
$size = getimagesize("data/screenshots/".$ob->url);
|
2004-03-15 16:22:00 +00:00
|
|
|
|
2004-11-17 22:57:20 +00:00
|
|
|
//generate random tag for popup window
|
|
|
|
|
$randName = generate_passwd(5);
|
2004-03-15 16:22:00 +00:00
|
|
|
|
2004-11-17 22:57:20 +00:00
|
|
|
//set image link based on user pref
|
|
|
|
|
$img = '<a href="javascript:openWin(\'appimage.php?imageId='.$ob->id.'\',\''.$randName.'\','.$size[0].','.$size[1].');">'.$imgSRC.'</a>';
|
|
|
|
|
if (loggedin())
|
2004-03-15 16:22:00 +00:00
|
|
|
{
|
2004-12-10 01:07:45 +00:00
|
|
|
if ($_SESSION['current']->getpref("window:screenshot") == "no")
|
2004-11-17 22:57:20 +00:00
|
|
|
{
|
|
|
|
|
$img = '<a href="appimage.php?imageId='.$ob->id.'">'.$imgSRC.'</a>';
|
|
|
|
|
}
|
2004-03-15 16:22:00 +00:00
|
|
|
}
|
|
|
|
|
|
2004-11-17 22:57:20 +00:00
|
|
|
//display image
|
|
|
|
|
echo "<td>\n";
|
|
|
|
|
echo html_frame_start(substr(stripslashes($ob->description),0,20),128,"",0);
|
|
|
|
|
echo $img;
|
2004-03-15 16:22:00 +00:00
|
|
|
|
2004-11-17 22:57:20 +00:00
|
|
|
//show admin delete link
|
|
|
|
|
if(loggedin() && (havepriv("admin") || isMaintainer($appId, $versionId)))
|
|
|
|
|
{
|
|
|
|
|
echo "<div align=center>[<a href='screenshots.php?cmd=delete&imageId=$ob->id&appId=$appId&versionId=$versionId'>Delete Image</a>]</div>";
|
|
|
|
|
}
|
2004-03-15 16:22:00 +00:00
|
|
|
|
2004-11-17 22:57:20 +00:00
|
|
|
echo html_frame_end(" ");
|
|
|
|
|
echo "</td>\n";
|
2004-03-15 16:22:00 +00:00
|
|
|
|
2004-11-17 22:57:20 +00:00
|
|
|
//end row if counter of 3
|
|
|
|
|
if ($c % 3 == 0) { echo "</tr><tr>\n"; }
|
2004-03-15 16:22:00 +00:00
|
|
|
|
2004-11-17 22:57:20 +00:00
|
|
|
$c++;
|
|
|
|
|
}
|
|
|
|
|
echo "</tr></table></div><br>\n";
|
2004-03-15 16:22:00 +00:00
|
|
|
|
|
|
|
|
|
2004-11-17 22:57:20 +00:00
|
|
|
echo html_frame_end("Click thumbnail to view image in new window.");
|
|
|
|
|
}
|
|
|
|
|
if(havepriv("admin") || isMaintainer($appId, $versionId))
|
|
|
|
|
{
|
|
|
|
|
//image upload box
|
|
|
|
|
echo '<form enctype="multipart/form-data" action="screenshots.php" name=imageForm method="post">',"\n";
|
|
|
|
|
echo html_frame_start("Upload Screenshot","400","",0);
|
|
|
|
|
echo '<table border=0 cellpadding=6 cellspacing=0 width="100%">',"\n";
|
|
|
|
|
|
|
|
|
|
echo '<tr><td class=color1>Image</td><td class=color0><input name="imagefile" type="file"></td></tr>',"\n";
|
|
|
|
|
echo '<tr><td class=color1>Description</td><td class=color0><input type="text" name="screenshot_desc"></td></tr>',"\n";
|
|
|
|
|
|
|
|
|
|
echo '<tr><td colspan=2 align=center class=color3><input type="submit" value="Send File"></td></tr>',"\n";
|
|
|
|
|
|
|
|
|
|
echo '</table>',"\n";
|
|
|
|
|
echo html_frame_end();
|
|
|
|
|
echo '<input type="hidden" name="MAX_FILE_SIZE" value="10000000">',"\n";
|
|
|
|
|
echo '<input type="hidden" name="cmd" value="screenshot_upload">',"\n";
|
|
|
|
|
echo '<input type="hidden" name="appId" value="'.$appId.'">',"\n";
|
|
|
|
|
echo '<input type="hidden" name="versionId" value="'.$versionId.'"></form>',"\n";
|
|
|
|
|
}
|
2004-03-15 16:22:00 +00:00
|
|
|
echo html_back_link(1);
|
|
|
|
|
|
|
|
|
|
apidb_footer();
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
?>
|