2005-01-12 16:22:55 +00:00
< ? php
2004-12-11 22:33:01 +00:00
/*******************************************************************/
2005-01-10 22:15:44 +00:00
/* this script expects appId and optionally versionId as arguments */
2004-12-11 22:33:01 +00:00
/* OR */
/* cmd and imageId */
/*******************************************************************/
2004-12-25 20:08:00 +00:00
/*
2004-12-27 23:54:55 +00:00
* application environment
2004-12-25 20:08:00 +00:00
*/
2004-03-15 16:22:00 +00:00
include ( " path.php " );
2005-01-30 00:57:34 +00:00
require ( BASE . " include/incl.php " );
2005-08-05 22:07:41 +00:00
require_once ( BASE . " include/screenshot.php " );
2005-01-30 00:57:34 +00:00
require ( BASE . " include/application.php " );
require ( BASE . " include/mail.php " );
2006-06-17 06:10:10 +00:00
$aClean = array (); //array of filtered user input
$aClean [ 'cmd' ] = makeSafe ( $_REQUEST [ 'cmd' ]);
$aClean [ 'versionId' ] = makeSafe ( $_REQUEST [ 'versionId' ]);
$aClean [ 'screenshot_desc' ] = makeSafe ( $_REQUEST [ 'screenshot_desc' ]);
$aClean [ 'imageId' ] = makeSafe ( $_REQUEST [ 'imageId' ]);
$aClean [ 'appId' ] = makeSafe ( $_REQUEST [ 'appId' ]);
2004-12-25 20:08:00 +00:00
2005-02-04 02:55:50 +00:00
/*
* We issued a command .
*/
2006-06-17 06:10:10 +00:00
if ( $aClean [ 'cmd' ])
2004-03-15 16:22:00 +00:00
{
2005-02-04 02:55:50 +00:00
// process screenshot upload
2006-06-17 06:10:10 +00:00
if ( $aClean [ 'cmd' ] == " screenshot_upload " )
2004-12-18 06:06:46 +00:00
{
2005-07-14 01:32:26 +00:00
if ( $_FILES [ 'imagefile' ][ 'size' ] > 600000 )
{
addmsg ( " Your screenshot was not accepted because it is too big. Please try to keep your screenshots under 600KB by saving games/video screenshots to jpeg and normal applications to png you might be able to achieve very good results with less bytes " , " red " );
} else
{
$oScreenshot = new Screenshot ();
2006-06-17 06:10:10 +00:00
$oScreenshot -> create ( $aClean [ 'versionId' ], $aClean [ 'screenshot_desc' ], $_FILES [ 'imagefile' ]);
2005-07-14 01:32:26 +00:00
$oScreenshot -> free ();
}
2006-06-17 06:10:10 +00:00
} elseif ( $aClean [ 'cmd' ] == " delete " && is_numeric ( $aClean [ 'imageId' ])) // process screenshot deletion
2004-12-11 22:33:01 +00:00
{
2006-06-17 06:10:10 +00:00
$oScreenshot = new Screenshot ( $aClean [ 'imageId' ]);
2005-02-04 02:55:50 +00:00
$oScreenshot -> delete ();
$oScreenshot -> free ();
2004-12-18 06:06:46 +00:00
}
2006-06-17 06:10:10 +00:00
redirect ( apidb_fullurl ( " screenshots.php?appId= " . $aClean [ 'appId' ] . " &versionId= " . $aClean [ 'versionId' ]));
2004-03-15 16:22:00 +00:00
}
2005-02-04 02:55:50 +00:00
/*
* We didn ' t issued any command .
*/
2006-06-17 06:10:10 +00:00
$hResult = get_screenshots ( $aClean [ 'appId' ], $aClean [ 'versionId' ]);
2004-12-18 06:06:46 +00:00
apidb_header ( " Screenshots " );
2006-06-17 06:10:10 +00:00
$oApp = new Application ( $aClean [ 'appId' ]);
$oVersion = new Version ( $aClean [ 'versionId' ]);
2005-02-07 23:21:33 +00:00
2005-02-04 02:55:50 +00:00
if ( $hResult && mysql_num_rows ( $hResult ))
2004-03-15 16:22:00 +00:00
{
2005-02-07 23:21:33 +00:00
echo html_frame_start ( " Screenshot Gallery for " . $oApp -> sName . " " . $oVersion -> sName , 500 );
2004-11-17 22:57:20 +00:00
2004-12-18 06:06:46 +00:00
// display thumbnails
$c = 1 ;
echo " <div align=center><table><tr> \n " ;
2005-02-04 02:55:50 +00:00
while ( $oRow = mysql_fetch_object ( $hResult ))
2004-12-18 06:06:46 +00:00
{
2006-06-17 06:10:10 +00:00
if ( ! $aClean [ 'versionId' ] && $oRow -> versionId != $currentVersionId )
2004-11-17 22:57:20 +00:00
{
2004-12-18 06:06:46 +00:00
if ( $currentVersionId )
2004-12-11 22:33:01 +00:00
{
2004-12-18 06:06:46 +00:00
echo " </tr></table></div> \n " ;
echo html_frame_end ();
$c = 1 ;
2004-12-11 22:33:01 +00:00
}
2005-02-04 02:55:50 +00:00
$currentVersionId = $oRow -> versionId ;
2006-06-29 19:00:41 +00:00
echo html_frame_start ( " Version " . Version :: lookup_name ( $currentVersionId ));
2004-12-18 06:06:46 +00:00
echo " <div align=center><table><tr> \n " ;
}
2005-07-26 03:54:57 +00:00
$img = get_thumbnail ( $oRow -> id );
2004-12-18 06:06:46 +00:00
// display image
echo " <td> \n " ;
echo $img ;
2005-02-04 02:55:50 +00:00
echo " <div align=center> " . substr ( $oRow -> description , 0 , 20 ) . " \n " ;
2005-01-30 22:38:44 +00:00
2004-12-18 06:06:46 +00:00
//show admin delete link
2005-01-30 23:12:48 +00:00
if ( $_SESSION [ 'current' ] -> isLoggedIn () && ( $_SESSION [ 'current' ] -> hasPriv ( " admin " ) ||
2006-06-17 06:10:10 +00:00
$_SESSION [ 'current' ] -> isMaintainer ( $aClean [ 'versionId' ])))
2004-12-18 06:06:46 +00:00
{
2006-06-17 06:10:10 +00:00
echo " <br />[<a href='screenshots.php?cmd=delete&imageId= $oRow->id &appId= " . $aClean [ 'appId' ] . " &versionId= " . $aClean [ 'versionId' ] . " '>Delete Image</a>] " ;
2004-12-18 06:06:46 +00:00
}
2004-12-11 22:33:01 +00:00
2005-01-30 22:38:44 +00:00
echo " </div></td> \n " ;
2004-12-11 22:33:01 +00:00
2004-12-18 06:06:46 +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-12-18 06:06:46 +00:00
$c ++ ;
2004-11-17 22:57:20 +00:00
}
2004-12-29 20:21:31 +00:00
echo " </tr></table></div><br /> \n " ;
2004-12-18 06:06:46 +00:00
echo html_frame_end ( " Click thumbnail to view image in new window. " );
} else {
2006-06-06 18:55:04 +00:00
echo " <p align= \" center \" >There are currently no screenshots for the selected version of this application. " ;
2004-12-18 06:06:46 +00:00
echo " <br />Please consider submitting a screenshot for the selected version yourself.</p> " ;
}
2006-06-17 06:10:10 +00:00
if ( $aClean [ 'versionId' ])
2004-12-18 06:06:46 +00:00
{
//image upload box
2005-02-04 02:55:50 +00:00
echo '<form enctype="multipart/form-data" action="screenshots.php" name="imageForm" method="post">' , " \n " ;
2004-12-18 06:06:46 +00:00
echo html_frame_start ( " Upload Screenshot " , " 400 " , " " , 0 );
echo '<table border=0 cellpadding=6 cellspacing=0 width="100%">' , " \n " ;
2004-11-17 22:57:20 +00:00
2005-01-31 01:42:08 +00:00
echo '<tr><td class=color1>Image</td><td class=color0><input name="imagefile" type="file" size="24"></td></tr>' , " \n " ;
echo '<tr><td class="color1">Description</td><td class="color0"><input type="text" name="screenshot_desc" maxlength="20" size="24"></td></tr>' , " \n " ;
2004-11-17 22:57:20 +00:00
2004-12-18 06:06:46 +00:00
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 ();
2005-07-14 01:32:26 +00:00
echo '<input type="hidden" name="MAX_FILE_SIZE" value="4000000" />' , " \n " ;
2004-12-18 06:06:46 +00:00
echo '<input type="hidden" name="cmd" value="screenshot_upload" />' , " \n " ;
2006-06-17 06:10:10 +00:00
echo '<input type="hidden" name="versionId" value="' . $aClean [ 'versionId' ] . '"></form />' , " \n " ;
2004-03-15 16:22:00 +00:00
}
2004-12-18 06:06:46 +00:00
echo html_back_link ( 1 );
apidb_footer ();
2004-03-15 16:22:00 +00:00
?>