This repository has been archived on 2025-05-24. You can view files and clone it, but cannot push or open issues or pull requests.
Files
qemudb/admin/adminScreenshots.php

157 lines
4.6 KiB
PHP
Raw Normal View History

2005-01-27 15:42:53 +00:00
<?php
/************************************************************/
/* Page for managing all of the screenshots in the AppDB */
/* Without having go into each application version to do so */
/************************************************************/
include("path.php");
include(BASE."include/incl.php");
require(BASE."include/screenshot.php");
require(BASE."include/application.php");
require(BASE."include/mail.php");
2005-01-27 15:42:53 +00:00
// deny access if not admin
if(!$_SESSION['current']->hasPriv("admin"))
2005-01-27 15:42:53 +00:00
{
errorpage("Insufficient privileges.");
exit;
}
/*
* We issued a delete command.
*/
if($_REQUEST['cmd'])
{
// process screenshot deletion
if($_REQUEST['cmd'] == "delete" && is_numeric($_REQUEST['imageId']))
{
$oScreenshot = new Screenshot($_REQUEST['imageId']);
$oScreenshot->delete();
$oScreenshot->free();
}
redirect($_SERVER['PHP_SELF'].
"?ItemsPerPage=".$_REQUEST['ItemsPerPage'].
"&page=".$_REQUEST['page']);
exit;
}
2005-01-27 15:42:53 +00:00
apidb_header("Screenshots");
2005-01-27 15:42:53 +00:00
// regenerate all screenshots
if($_REQUEST['regenerate'])
{
$sQuery = "SELECT id FROM appData WHERE type = 'image'";
2005-01-27 15:42:53 +00:00
$hResult = query_appdb($sQuery);
while($oRow = mysql_fetch_object($hResult))
{
echo "REGENERATING IMAGE ".$oRow->id."<br/>";
$screenshot = new Screenshot($oRow->id);
$screenshot->generate();
$screenshot->free();
set_time_limit(60);
2005-01-27 15:42:53 +00:00
}
}
echo "<center>";
echo "<a href=\"".$_SERVER['PHP_SELF'].
"?regenerate=true\">Regenerate all screenshots ! ".
"(use only if you know what you are doing)</a><br />";
echo "</center>";
2005-01-27 15:42:53 +00:00
/* display a range of 10 pages */
$pageRange = 10;
2005-01-27 15:42:53 +00:00
$ItemsPerPage = 6;
$currentPage = 1;
2005-01-27 15:42:53 +00:00
if($_REQUEST['ItemsPerPage'])
$ItemsPerPage = $_REQUEST['ItemsPerPage'];
2005-01-27 15:42:53 +00:00
if($_REQUEST['page'])
$currentPage = $_REQUEST['page'];
$ItemsPerPage = min($ItemsPerPage,100);
$totalPages = max(ceil($BugLinks/$ItemsPerPage),1);
$currentPage = min($currentPage,$totalPages);
$offset = (($currentPage-1) * $ItemsPerPage);
2005-01-27 15:42:53 +00:00
/* display page selection links */
echo "<center>";
echo "<b>Page $currentPage of $totalPages</b><br />";
display_page_range($currentPage, $pageRange, $totalPages,
$_SERVER['PHP_SELF']."?ItemsPerPage=".$ItemsPerPage);
2005-01-27 15:42:53 +00:00
echo "<br />";
echo "<br />";
/* display the option to choose how many screenshots per-page to display */
echo '<form method="get" name="message" action="'.$_SERVER['PHP_SELF'].'">';
echo '<b>Number of Screenshots per page:</b>';
echo "&nbsp<select name='ItemsPerPage'>";
2005-01-27 15:42:53 +00:00
$ItemsPerPageArray = array(6, 9, 12, 15, 18, 21, 24);
foreach($ItemsPerPageArray as $i => $value)
2005-01-27 15:42:53 +00:00
{
if($ItemsPerPageArray[$i] == $ItemsPerPage)
echo "<option value='$ItemsPerPageArray[$i]' SELECTED>$ItemsPerPageArray[$i]";
2005-01-27 15:42:53 +00:00
else
echo "<option value='$ItemsPerPageArray[$i]'>$ItemsPerPageArray[$i]";
2005-01-27 15:42:53 +00:00
}
echo "</select>";
echo "<input type=hidden name=page value=$currentPage>";
echo "&nbsp<input type=submit value='Refresh'>";
2005-01-27 15:42:53 +00:00
echo "</form>";
echo "</center>";
/* query for all of the Screenshots in assending order */
$Ids = query_appdb("SELECT * from appData
WHERE type = 'image'
ORDER BY id ASC LIMIT $offset, $ItemsPerPage;");
$c = 1;
echo "<div align=center><table><tr>\n";
while ($oRow = mysql_fetch_object($Ids))
2005-01-27 15:42:53 +00:00
{
// display thumbnail
$oVersion = new version($oRow->versionId);
$oApp = new Application($oVersion->iAppId);
$img = get_thumbnail($oRow->id);
echo "<td align=center>\n";
echo $img;
echo "<div align=center>". substr($oRow->description,0,20). "\n";
echo "<br />[<a href='".apidb_fullurl("appview.php");
echo "?appId=".$oApp->iAppId."'>";
echo $oApp->sName."</a>]";
echo "<br />[<a href='".apidb_fullurl("appview.php");
echo "?versionId=".$oVersion->iVersionId."'>";
echo "Version: ".$oVersion->sName."</a>]";
//show admin delete link
if($_SESSION['current']->isLoggedIn() &&
($_SESSION['current']->hasPriv("admin") ||
$_SESSION['current']->isMaintainer($_REQUEST['versionId'])))
{
echo "<br />[<a href='".$_SERVER['PHP_SELF'];
echo "?cmd=delete&imageId=$oRow->id";
echo "&page=".$currentPage."&ItemsPerPage=".$ItemsPerPage."'>";
echo "Delete Image</a>]";
}
echo "</div></td>\n";
// end row if counter of 3
if ($c % 3 == 0) echo "</tr><tr>\n";
$c++;
2005-01-27 15:42:53 +00:00
}
echo "</tr></table></div><br />\n";
2005-01-27 15:42:53 +00:00
/* display page selection links */
echo "<center>";
display_page_range($currentPage, $pageRange, $totalPages,
$_SERVER['PHP_SELF']."?ItemsPerPage=".$ItemsPerPage);
2005-01-27 15:42:53 +00:00
echo "</center>";
apidb_footer();
?>