- displays an app screenshot gallery when one of the random screeshot is clicked

- tabs removed
- indentation fixed in screenshots.php
This commit is contained in:
Jonathan Ernst
2004-12-11 22:33:01 +00:00
committed by WineHQ
parent 2306c4be83
commit c4809941b3
2 changed files with 106 additions and 102 deletions

View File

@@ -1,4 +1,4 @@
<? <?php
/**********************************/ /**********************************/
/* code to display an application */ /* code to display an application */
/**********************************/ /**********************************/
@@ -84,10 +84,7 @@ function get_screenshot_img($appId, $versionId="")
} }
$img = html_frame_start("",'128','',2); $img = html_frame_start("",'128','',2);
if($versionId) $img .= "<a href='screenshots.php?appId=$appId&versionId=$versionId'>$imgFile</a>";
$img .= "<a href='screenshots.php?appId=$appId&versionId=$versionId'>$imgFile</a>";
else
$img .= $imgFile;
$img .= html_frame_end()."<br />"; $img .= html_frame_end()."<br />";
return $img; return $img;

View File

@@ -1,77 +1,71 @@
<? <?php
/*******************************************************************/
/* this script expects appId and optionnaly versionId as arguments */
/* OR */
/* cmd and imageId */
/*******************************************************************/
/**
* APPLICATION ENVIRONMENT
*/
include("path.php"); include("path.php");
require(BASE."include/"."incl.php"); require(BASE."include/"."incl.php");
require(BASE."include/"."application.php"); require(BASE."include/"."application.php");
/*=========================================================================
*
* this script expects appId and versionId as arguments
*
* OR
*
* cmd and imageId
*/
if($cmd) if($cmd)
{ {
if(havepriv("admin") || isMaintainer($appId, $versionId)) if(havepriv("admin") || isMaintainer($appId, $versionId))
{ {
//process screenshot upload //process screenshot upload
if($cmd == "screenshot_upload") if($cmd == "screenshot_upload")
{
if(!copy($imagefile, "data/screenshots/".$appId."-".$versionId."-".basename($imagefile_name)))
{ {
if(!copy($imagefile, "data/screenshots/".$appId."-".$versionId."-".basename($imagefile_name))) // whoops, copy failed. do something
{ errorpage("debug: copy failed; $imagefile; $imagefile_name");
// whoops, copy failed. do something exit;
errorpage('debug: copy failed; $imagefile; $imagefile_name'); }
exit;
}
$query = "INSERT INTO appData VALUES (null, $appId, $versionId, 'image', ". $query = "INSERT INTO appData VALUES (null, $appId, $versionId, 'image', ".
"'".addslashes($screenshot_desc)."', '".$appId."-".$versionId."-".basename($imagefile_name)."')"; "'".addslashes($screenshot_desc)."', '".$appId."-".$versionId."-".basename($imagefile_name)."')";
if(debugging()) { addmsg("<p align=center><b>query:</b> $query </p>",green); } if(debugging()) addmsg("<p align=center><b>query:</b> $query </p>",green);
if (mysql_query($query)) if (mysql_query($query))
{ {
//success //success
$email = getNotifyEmailAddressList($appId, $versionId); $email = getNotifyEmailAddressList($appId, $versionId);
if($email) if($email)
{ {
$fullAppName = "Application: ".lookupAppName($appId)." Version: ".lookupVersionName($appId, $versionId); $fullAppName = "Application: ".lookupAppName($appId)." Version: ".lookupVersionName($appId, $versionId);
$ms .= APPDB_ROOT."screenshots.php?appId=$appId&versionId=$versionId"."\n"; $ms .= APPDB_ROOT."screenshots.php?appId=$appId&versionId=$versionId"."\n";
$ms .= "\n"; $ms .= "\n";
$ms .= ($_SESSION['current']->username ? $_SESSION['current']->username : "Anonymous")." added screenshot ".$screenshot_desc." to ".$fullAppName."\n"; $ms .= ($_SESSION['current']->username ? $_SESSION['current']->username : "Anonymous")." added screenshot ".$screenshot_desc." to ".$fullAppName."\n";
$ms .= "\n"; $ms .= "\n";
$ms .= STANDARD_NOTIFY_FOOTER; $ms .= STANDARD_NOTIFY_FOOTER;
mail(stripslashes($email), "[AppDB] ".$fullAppName ,$ms); mail(stripslashes($email), "[AppDB] ".$fullAppName ,$ms);
} else
} else {
{
$email = "no one"; $email = "no one";
} }
addmsg("mesage sent to: ".$email, green); addmsg("mesage sent to: ".$email, green);
addmsg("The image was successfully added into the database", "green"); addmsg("The image was successfully added into the database", "green");
redirect(apidb_fullurl("screenshots.php?appId=$appId&versionId=$versionId")); redirect(apidb_fullurl("screenshots.php?appId=$appId&versionId=$versionId"));
} }
else else
{ {
//error //error
$statusMessage = "<p><b>Database Error!<br>".mysql_error()."</b></p>\n"; $statusMessage = "<p><b>Database Error!<br>".mysql_error()."</b></p>\n";
addmsg($statusMessage, "red"); addmsg($statusMessage, "red");
} }
} else
} else {
{ if($cmd == "delete")
if($cmd == "delete") {
{ $result = mysql_query("DELETE FROM appData WHERE id = $imageId");
$result = mysql_query("DELETE FROM appData WHERE id = $imageId"); if($result)
if($result)
{ {
$email = getNotifyEmailAddressList($appId, $versionId); $email = getNotifyEmailAddressList($appId, $versionId);
if($email) if($email)
@@ -93,58 +87,71 @@ if($cmd)
addmsg("Image deleted", "green"); addmsg("Image deleted", "green");
redirect(apidb_fullurl("screenshots.php?appId=$appId&versionId=$versionId")); redirect(apidb_fullurl("screenshots.php?appId=$appId&versionId=$versionId"));
} else } else
{ {
addmsg("Failed to delete image: ".mysql_error(), "red"); addmsg("Failed to delete image: ".mysql_error(), "red");
redirect(apidb_fullurl("screenshots.php?appId=$appId&versionId=$versionId")); redirect(apidb_fullurl("screenshots.php?appId=$appId&versionId=$versionId"));
} }
} }
} }
} }
exit; exit;
} }
$result = mysql_query("SELECT * FROM appData WHERE type = 'image' AND appId = $appId AND versionId = $versionId"); if($_REQUEST['versionId'])
$result = mysql_query("SELECT * FROM appData WHERE type = 'image' AND appId = $appId AND versionId = $versionId");
else
$result = mysql_query("SELECT * FROM appData WHERE type = 'image' AND appId = $appId ORDER BY versionId");
if((!$result || !mysql_num_rows($result)) && (!havepriv("admin") && !isMaintainer($appId, $versionId))) if((!$result || !mysql_num_rows($result)) && (!havepriv("admin") && !isMaintainer($appId, $versionId)))
{ {
errorpage("No Screenshots Found","There are no screenshots currently linked to this application."); errorpage("No Screenshots Found","There are no screenshots currently linked to this application.");
exit; exit;
} } else
else
{ {
$app=new Application($appId);
apidb_header("Screenshots"); apidb_header("Screenshots");
if($result && mysql_num_rows($result)) if($result && mysql_num_rows($result))
{ {
echo html_frame_start("Screenshot Gallery",500); echo html_frame_start("Screenshot Gallery for ".$app->data->appName,500);
// display thumbnails // display thumbnails
$c = 1; $c = 1;
echo "<div align=center><table><tr>\n"; echo "<div align=center><table><tr>\n";
while($ob = mysql_fetch_object($result)) while($ob = mysql_fetch_object($result))
{ {
//set img tag if(!$_REQUEST['versionId'] && $ob->versionId!=$currentVersionId)
$imgSRC = '<img src="appimage.php?imageId='.$ob->id.'&width=128&height=128" border=0 alt="'.$ob->description.'">'; {
if($currentVersionId)
{
echo "</tr></table></div>\n";
echo html_frame_end();
}
$currentVersionId=$ob->versionId;
echo html_frame_start("Version ".$app->getAppVersion($ob->versionId)->versionName);
echo "<div align=center><table><tr>\n";
}
// set img tag
$imgSRC = '<img src="appimage.php?imageId='.$ob->id.'&width=128&height=128" border=0 alt="'.$ob->description.'">';
//get image size // get image size
$size = getimagesize("data/screenshots/".$ob->url); $size = getimagesize("data/screenshots/".$ob->url);
//generate random tag for popup window // generate random tag for popup window
$randName = generate_passwd(5); $randName = generate_passwd(5);
//set image link based on user pref // set image link based on user pref
$img = '<a href="javascript:openWin(\'appimage.php?imageId='.$ob->id.'\',\''.$randName.'\','.$size[0].','.$size[1].');">'.$imgSRC.'</a>'; $img = '<a href="javascript:openWin(\'appimage.php?imageId='.$ob->id.'\',\''.$randName.'\','.$size[0].','.$size[1].');">'.$imgSRC.'</a>';
if (loggedin()) if (loggedin())
{ {
if ($_SESSION['current']->getpref("window:screenshot") == "no") if ($_SESSION['current']->getpref("window:screenshot") == "no")
{ {
$img = '<a href="appimage.php?imageId='.$ob->id.'">'.$imgSRC.'</a>'; $img = '<a href="appimage.php?imageId='.$ob->id.'">'.$imgSRC.'</a>';
} }
} }
//display image // display image
echo "<td>\n"; echo "<td>\n";
echo html_frame_start(substr(stripslashes($ob->description),0,20),128,"",0); echo html_frame_start(substr(stripslashes($ob->description),0,20),128,"",0);
echo $img; echo $img;
@@ -157,17 +164,17 @@ else
echo html_frame_end("&nbsp;"); echo html_frame_end("&nbsp;");
echo "</td>\n"; echo "</td>\n";
//end row if counter of 3 // end row if counter of 3
if ($c % 3 == 0) { echo "</tr><tr>\n"; } if ($c % 3 == 0) echo "</tr><tr>\n";
$c++; $c++;
} }
echo "</tr></table></div><br>\n"; echo "</tr></table></div><br>\n";
echo html_frame_end("Click thumbnail to view image in new window."); echo html_frame_end("Click thumbnail to view image in new window.");
} }
if(havepriv("admin") || isMaintainer($appId, $versionId)) if((havepriv("admin") || isMaintainer($_REQUEST['appId'], $_REQUEST['versionId']))
&& $_REQUEST['versionId'])
{ {
//image upload box //image upload box
echo '<form enctype="multipart/form-data" action="screenshots.php" name=imageForm method="post">',"\n"; echo '<form enctype="multipart/form-data" action="screenshots.php" name=imageForm method="post">',"\n";