2005-01-12 16:22:55 +00:00
< ? php
2006-07-06 18:37:34 +00:00
/**
* Shows a page with several screenshot thumbnails .
*
* Mandatory parameters :
* - iAppId , application identifier
* AND / OR
* - iVersionId , version identifier
*
* Optional parameters :
* - iImageId , image identifier ( for deletion )
* - sScreenshotDesc , screenshot description ( for insertion )
* - sCmd , action to perform ( " screenshot_upload " , " delete " )
*
* TODO :
* - replace iImageId with iScreenshotId
* - replace sCmd with iAction and replace " delete " , " screenshot_upload " , etc . with integer constants DELETE , UPLOAD , etc .
* - replace require_once with require after checking that it won ' t break anything
*/
2004-12-11 22:33:01 +00:00
2006-07-06 18:37:34 +00:00
// application environment
2006-07-07 18:14:53 +00:00
require ( " 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 " );
2006-07-07 18:14:53 +00:00
require_once ( BASE . " include/application.php " );
require_once ( BASE . " include/version.php " );
2005-01-30 00:57:34 +00:00
2006-07-06 18:37:34 +00:00
// we issued a command
2006-07-06 17:27:54 +00:00
if ( $aClean [ 'sCmd' ])
2004-03-15 16:22:00 +00:00
{
2005-02-04 02:55:50 +00:00
// process screenshot upload
2006-07-06 17:27:54 +00:00
if ( $aClean [ 'sCmd' ] == " screenshot_upload " )
2004-12-18 06:06:46 +00:00
{
2006-07-21 04:18:28 +00:00
//FIXME: use a defined value here instead of just 600000
2006-07-06 17:27:54 +00:00
if ( $_FILES [ 'sImageFile' ][ 'size' ] > 600000 )
2005-07-14 01:32:26 +00:00
{
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 ();
2007-04-21 17:49:43 +00:00
$oScreenshot -> iVersionId = $aClean [ 'iVersionId' ];
2007-05-26 01:41:44 +00:00
$oScreenshot -> sDescription = $aClean [ 'sScreenshotDesc' ];
2007-04-21 17:49:43 +00:00
$oScreenshot -> hFile = $_FILES [ 'sImageFile' ];
$oScreenshot -> create ();
2005-07-14 01:32:26 +00:00
$oScreenshot -> free ();
}
2006-07-06 17:27:54 +00:00
} elseif ( $aClean [ 'sCmd' ] == " delete " && is_numeric ( $aClean [ 'iImageId' ])) // process screenshot deletion
2004-12-11 22:33:01 +00:00
{
2006-07-06 17:27:54 +00:00
$oScreenshot = new Screenshot ( $aClean [ 'iImageId' ]);
2005-02-04 02:55:50 +00:00
$oScreenshot -> delete ();
$oScreenshot -> free ();
2004-12-18 06:06:46 +00:00
}
2006-07-06 18:44:56 +00:00
util_redirect_and_exit ( apidb_fullurl ( " screenshots.php?iAppId= " . $aClean [ 'iAppId' ] . " &iVersionId= " . $aClean [ 'iVersionId' ]));
2004-03-15 16:22:00 +00:00
}
2005-02-04 02:55:50 +00:00
2006-07-06 18:37:34 +00:00
// we didn't issued any command
2007-07-17 04:44:17 +00:00
$hResult = Screenshot :: get_screenshots ( $aClean [ 'iAppId' ], $aClean [ 'iVersionId' ]);
2004-12-18 06:06:46 +00:00
apidb_header ( " Screenshots " );
2006-07-06 17:27:54 +00:00
$oApp = new Application ( $aClean [ 'iAppId' ]);
$oVersion = new Version ( $aClean [ 'iVersionId' ]);
2005-02-07 23:21:33 +00:00
2007-08-03 23:27:25 +00:00
if ( $hResult && query_num_rows ( $hResult ))
2004-03-15 16:22:00 +00:00
{
2007-08-23 02:33:57 +00:00
echo html_frame_start ( " Screenshot Gallery for " . $oApp -> sName , 500 );
2004-11-17 22:57:20 +00:00
2004-12-18 06:06:46 +00:00
// display thumbnails
$c = 1 ;
2007-07-17 04:44:17 +00:00
// optimization so we don't have to perform as many database queries
// only update this variable when $iCurrentVersionId changes
$bUserIsMaintainerOfVersion = false ;
2004-12-18 06:06:46 +00:00
echo " <div align=center><table><tr> \n " ;
2007-08-03 23:27:25 +00:00
while ( $oRow = query_fetch_object ( $hResult ))
2004-12-18 06:06:46 +00:00
{
2007-06-16 21:16:12 +00:00
// if the current version changed then update the current version
// and close the previous html frame if this isn't the
// first frame
2007-08-23 02:33:57 +00:00
if ( $oRow -> versionId != $iCurrentVersionId )
2004-11-17 22:57:20 +00:00
{
2007-07-17 04:44:17 +00:00
if ( $iCurrentVersionId )
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
}
2007-07-17 04:44:17 +00:00
$iCurrentVersionId = $oRow -> versionId ;
2007-08-23 02:33:57 +00:00
$bUserIsMaintainerOfVersion = $_SESSION [ 'current' ] -> isMaintainer ( $iCurrentVersionId );
2007-07-17 04:44:17 +00:00
echo html_frame_start ( " Version " . Version :: lookup_name ( $iCurrentVersionId ));
2004-12-18 06:06:46 +00:00
echo " <div align=center><table><tr> \n " ;
}
2006-07-11 03:37:07 +00:00
$oScreenshot = new Screenshot ( $oRow -> id );
$img = $oScreenshot -> get_thumbnail_img ();
2007-08-23 02:33:57 +00:00
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
2007-07-17 04:44:17 +00:00
if ( $_SESSION [ 'current' ] -> isLoggedIn () &&
(
$_SESSION [ 'current' ] -> hasPriv ( " admin " ) ||
$bUserIsMaintainerOfVersion
)
)
2004-12-18 06:06:46 +00:00
{
2007-09-27 12:26:00 +02:00
$oM = new objectManager ( " screenshot " );
2007-09-29 20:18:16 +02:00
$oM -> setReturnTo ( " screenshots.php?iAppId= " . $oScreenshot -> iAppId . " &iVersionId= " . $oScreenshot -> iVersionId );
2007-09-27 12:26:00 +02:00
echo '<br />[<a href="' . $oM -> makeUrl ( " delete " , $oScreenshot -> iScreenshotId , " Delete Screenshot " ) . '">Delete</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
2007-06-16 21:16:12 +00:00
echo html_frame_end (); // close the current version we are displaying
echo html_frame_end (); // close the "Screenshot Gallary..." html frame
2007-08-23 02:33:57 +00:00
} 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> " ;
}
2007-08-23 01:48:45 +00:00
// let's show the screenshot uploading box, but only
// if the user is logged in
if ( $aClean [ 'iVersionId' ] && $_SESSION [ 'current' ] -> isLoggedIn ())
2004-12-18 06:06:46 +00:00
{
2007-05-26 17:55:09 +00:00
echo " <p align= \" center \" >When submitting screenshots please ensure that the focus is on the application running inside Wine. " ;
2007-10-18 12:05:42 +02:00
echo " <br />This means if the application is running in a window then please crop the image so that only the application is shown and not your desktop. " ;
echo " <br />Do not upload screenshots of error messages, installers, game menus etc.</p> " ;
2007-05-26 17:55:09 +00:00
2006-07-06 17:27:54 +00:00
echo '<form enctype="multipart/form-data" action="screenshots.php" name="sImageForm" 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
2006-07-06 17:27:54 +00:00
echo '<tr><td class=color1>Image</td><td class=color0><input name="sImageFile" type="file" size="24"></td></tr>' , " \n " ;
echo '<tr><td class="color1">Description</td><td class="color0"><input type="text" name="sScreenshotDesc" 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 " ;
2006-07-06 17:27:54 +00:00
echo '<input type="hidden" name="sCmd" value="screenshot_upload" />' , " \n " ;
echo '<input type="hidden" name="iVersionId" value="' . $aClean [ 'iVersionId' ] . '"></form />' , " \n " ;
2007-09-27 12:07:23 +02:00
} else if ( ! $_SESSION [ 'current' ] -> isLoggedIn ()) // else let the person know that if they log in they can submit screenshots
2007-08-23 01:48:45 +00:00
{
echo '<div align="center"><a href="' . login_url () . '">' ;
echo " Log in</a> to submit screenshots</div> \n " ;
2007-09-27 12:07:23 +02:00
} else
{
echo html_frame_start ( " Upload Screenshot " , " 30% " );
echo 'If you would like to submit screenshots, please select an application version below.<br />' ;
echo '<ul>' ;
foreach ( $oApp -> getVersions () as $oVersion )
echo '<li><a href="' . BASE . 'screenshots.php?iVersionId=' . $oVersion -> objectGetId () . '">' . $oVersion -> sName . '</a></li>' ;
echo '</ul>' ;
echo html_frame_end ();
2004-03-15 16:22:00 +00:00
}
2007-09-27 12:07:23 +02:00
2004-12-18 06:06:46 +00:00
echo html_back_link ( 1 );
2006-07-06 18:37:34 +00:00
2004-12-18 06:06:46 +00:00
apidb_footer ();
2004-03-15 16:22:00 +00:00
?>