- use queued screenshot directory instead of mysql to store queued data

- use the config file to determine thumbnail size
This commit is contained in:
Jonathan Ernst
2004-12-23 01:13:26 +00:00
committed by WineHQ
parent ca749d32d9
commit 52437f5f30
5 changed files with 168 additions and 138 deletions

View File

@@ -22,12 +22,8 @@ if(!loggedin())
if (!$_REQUEST['queueId'])
{
//get available appData
$query = "SELECT queueId, queueappId, queueversionId,".
"queuetype, queuedescription,".
"queueurl,queuecontent,queueuserId,".
"UNIX_TIMESTAMP(submitTime) as submitTime ".
"from appDataQueue;";
$result = mysql_query($query);
$str_query = "SELECT * from appDataQueue;";
$result = mysql_query($str_query);
if(!$result || !mysql_num_rows($result))
{
@@ -68,14 +64,14 @@ if (!$_REQUEST['queueId'])
if ($c % 2 == 1) { $bgcolor = 'color0'; } else { $bgcolor = 'color1'; }
echo "<tr class=$bgcolor>\n";
echo " <td>".date("Y-n-t h:i:sa", $ob->submitTime)." &nbsp;</td>\n";
echo " <td><a href='adminAppDataQueue.php?queueId=$ob->queueId'>$ob->queueId</a></td>\n";
if($ob->queueuserId)
echo " <td>".lookupUsername($ob->queueuserId)." (".lookupEmail($ob->queueuserId).")</td>\n";
echo " <td><a href='adminAppDataQueue.php?queueId=$ob->queueId'>".$ob->queueId."</a></td>\n";
if($ob->userId)
echo " <td>".lookupUsername($ob->userId)." (".lookupEmail($ob->userId).")</td>\n";
else
echo " <td>Anonymous</td>\n";
echo "<td>".appIdToName($ob->queueappId)."</td>\n";
echo "<td>".versionIdToName($ob->queueversionId)."</td>\n";
echo "<td>".$ob->queuetype."</td>\n";
echo "<td>".appIdToName($ob->appId)."</td>\n";
echo "<td>".versionIdToName($ob->versionId)."</td>\n";
echo "<td>".$ob->type."</td>\n";
echo "</tr>\n\n";
$c++;
}
@@ -101,7 +97,7 @@ if (!$_REQUEST['queueId'])
if(!$_REQUEST['sub']=="inside_form")
{
echo '<form name="qform" action="adminAppDataQueue.php" method="get">',"\n";
echo '<form name="qform" action="adminAppDataQueue.php" method="post">',"\n";
// help
echo "<div align=center><table width='90%' border=0 cellpadding=3 cellspacing=0><tr><td>\n\n";
echo "Please enter an accurate and personalized reply anytime a submitted scrrenshot is rejected.\n";
@@ -114,29 +110,39 @@ if (!$_REQUEST['queueId'])
// app name
echo '<tr valign=top><td class=color0><b>App Name</b></td>',"\n";
echo "<td>".appIdToName($obj_row->queueappId)."</td></tr>\n";
echo "<td>".appIdToName($obj_row->appId)."</td></tr>\n";
// version
echo '<tr valign=top><td class=color0><b>App Version</b></td>',"\n";
echo "<td>".versionIdToName($obj_row->queueversionId)."</td></tr>\n";
echo "<td>".versionIdToName($obj_row->versionId)."</td></tr>\n";
//dataDescription
echo '<tr valign=top><td class=color0><b>Description</b></td>',"\n";
echo '<td><textarea name="description" rows=10 cols=35>'.stripslashes($obj_row->queuedescription).'</textarea></td></tr>',"\n";
echo '<td><textarea name="description" rows=10 cols=35>'.stripslashes($obj_row->description).'</textarea></td></tr>',"\n";
//data
if($obj_row->queuetype == "image")
if($obj_row->type == "image")
{
$tmpfname = rand()."screenshotQueue".$obj_row->queueId;
$handle = fopen("../data/screenshots/".$tmpfname, "wb");
fwrite($handle, $obj_row->queuecontent);
fclose($handle);
echo '<tr valign=top><td class=color0><b>Submited image</b></td>',"\n";
echo '<td><img src="screenshotQueue.php?file='.$tmpfname.'" title="'.stripslashes($obj_row->queueurl).'" /></td></tr>',"\n";
} elseif($obj_row->queuetype == "url")
echo '<td>';
$imgSRC = '<img width="'.APPDB_THUMBNAIL_WIDTH.'" height="'.APPDB_THUMBNAIL_HEIGHT.'" src="screenshotQueue.php?queueId='.$obj_row->queueId.'" />';
// generate random tag for popup window
$randName = generate_passwd(5);
// set image link based on user pref
$img = '<a href="javascript:openWin(\'screenshotQueue.php?queueId='.$obj_row->queueId.'\',\''.$randName.'\','.APPDB_SCREENSHOT_MAXWIDTH.','.APPDB_SCREENSHOT_MAXHEIGHT.');">'.$imgSRC.'</a>';
if (loggedin())
{
if ($_SESSION['current']->getpref("window:screenshot") == "no")
{
$img = '<a href="screenshotQueue.php?queueId='.$obj_row->queueId.'">'.$imgSRC.'</a>';
}
}
echo $img;
echo '</td></tr>',"\n";
} elseif($obj_row->type == "url")
{
echo '<tr valign=top><td class=color0><b>Submitted link</b></td>',"\n";
echo '<td><textarea name="content" rows=10 cols=35>'.stripslashes($obj_row->queueurl).'</textarea></td></tr>',"\n";
echo '<td><textarea name="content" rows=10 cols=35>'.stripslashes($obj_row->url).'</textarea></td></tr>',"\n";
}
//email response
@@ -160,30 +166,33 @@ if (!$_REQUEST['queueId'])
$statusMessage = "";
$goodtogo = 0;
if($obj_row->queuetype == "image")
if($obj_row->type == "image")
{
// we write the content in a realfile
$fname = $obj_row->queuappId."-".$obj_row->queueversionId."-".$obj_row->queueurl;
$handle = fopen("../data/screenshots/".$fname, "wb");
fwrite($handle, $obj_row->queuecontent);
fclose($handle);
$str_query = "INSERT INTO appData VALUES (null, ".$obj_row->appId.", ".$obj_row->versionId.", 'image', ".
"'".addslashes($_REQUEST['description'])."', '')";
mysql_query($str_query);
$int_id = mysql_insert_id();
// we move the content in the live directory
rename("../data/queued/screenshots/".$obj_row->queueId, "../data/screenshots/".$int_id);
// we have to update the entry now that we know its name
$str_query = "UPDATE appData SET url = '".$int_id."' WHERE id = '".$int_id."'";
$query = "INSERT INTO appData VALUES (null, ".$obj_row->queueappId.", ".$obj_row->queueversionId.", 'image', ".
"'".addslashes($_REQUEST['description'])."', '".$fname."')";
}
elseif ($obj_row->queuetype == "url") {
$query = "INSERT INTO appData VALUES (null, ".$obj_row->queueappId.", ".$obj_row->queueversionId.", 'url', ".
elseif ($obj_row->type == "url") {
$query = "INSERT INTO appData VALUES (null, ".$obj_row->appId.", ".$obj_row->versionId.", 'url', ".
"'".addslashes($_REQUEST['description'])."', '".$obj_row->url."')";
}
if(debugging()) addmsg("<p align=center><b>query:</b> $query </p>","green");
if (mysql_query($query))
if (mysql_query($str_query))
{
$statusMessage = "<p>The application data was successfully added into the database</p>\n";
//delete the item from the queue
mysql_query("DELETE from appDataQueue where queueId = ".$_REQUEST['queueId'].";");
mysql_query("DELETE from appDataQueue where queueId = ".$obj_row->queueId.";");
$goodtogo = 1; /* set to 1 so we send the response email */
} else
@@ -193,17 +202,17 @@ if (!$_REQUEST['queueId'])
}
//Send Status Email
if (lookupEmail($obj_row->queueuserId) && $goodtogo)
if (lookupEmail($obj_row->userId) && $goodtogo)
{
$ms = "Application Data Request Report\n";
$ms .= "----------------------------------\n\n";
$ms .= "Your submission of an application data for ".appIdToName($obj_row->queueappId).versionIdToName($obj_row->queueversionId)." has been accepted. ";
$ms .= "Your submission of an application data for ".appIdToName($obj_row->appId).versionIdToName($obj_row->versionId)." has been accepted. ";
$ms .= $_REQUEST['replyText'];
$ms .= "We appreciate your help in making the Application Database better for all users.\n\n";
$ms .= "Thanks!\n";
$ms .= "-The AppDB admins\n";
mail(stripslashes(lookupEmail($obj_row->queueuserId)),'[AppDB] Application Data Request Report',$ms);
mail(stripslashes(lookupEmail($obj_row->userId)),'[AppDB] Application Data Request Report',$ms);
}
//done
@@ -220,12 +229,14 @@ if (!$_REQUEST['queueId'])
$ms .= "";
$ms .= "-The AppDB admins\n";
mail(stripslashes(lookupEmail($obj_row->queueuserId)),'[AppDB] Application Data Request Report',$ms);
mail(stripslashes(lookupEmail($obj_row->userId)),'[AppDB] Application Data Request Report',$ms);
}
//delete main item
$query = "DELETE from appDataQueue where queueId = ".$_REQUEST['queueId'].";";
$result = mysql_query($query);
$str_query = "DELETE from appDataQueue where queueId = ".$obj_row->queueId.";";
unlink("../data/queued/screenshots/".$obj_row->queueId);
$result = mysql_query($str_query);
echo html_frame_start("Delete application data submission",400,"",0);
if(!$result)
{

View File

@@ -1,16 +1,14 @@
<?php
/************************************************/
/* code to show an image stored in mysql */
/* code to show a queued image */
/************************************************/
include("path.php");
require(BASE."include/"."incl.php");
if($info=getimagesize("../data/screenshots/".$_REQUEST['file']))
if($info=getimagesize("../data/queued/screenshots/".$_REQUEST['queueId']))
{
header('Content-type: '.$info['mime']);
$handle = fopen("../data/screenshots/".$_REQUEST['file'], "rb");
echo fread($handle, filesize("../data/screenshots/".$_REQUEST['file']));
$handle = fopen("../data/queued/screenshots/".$_REQUEST['queueId'], "rb");
echo fread($handle, filesize("../data/queued/screenshots/".$_REQUEST['queueId']));
fclose($handle);
}
unlink("../data/screenshots/".$_REQUEST['file']);
?>

View File

@@ -8,8 +8,10 @@
* global params
*/
define("APPDB_DEBUG","0"); //turns debugging on/off
define("APPDB_THUMBNAIL_WIDTH","100"); // width of the screenshot's thumbnails
define("APPDB_THUMBNAIL_HEIGHT","75"); // height of the screenshot's thumbnails
define("APPDB_THUMBNAIL_WIDTH","128"); // width of the screenshot's thumbnails
define("APPDB_THUMBNAIL_HEIGHT","128"); // height of the screenshot's thumbnails
define("APPDB_SCREENSHOT_MAXWIDTH","800"); // width of the screenshot's thumbnails
define("APPDB_SCREENSHOT_MAXHEIGHT","600"); // height of the screenshot's thumbnails
define("APPDB_ROOT", "http://appdb.winehq.org/"); // path to AppDB
define("STANDARD_NOTIFY_FOOTER","------- You are receiving this mail because: -------\n".
"You are an maintainer of this application or an AppDB administrator\n".

View File

@@ -11,29 +11,36 @@
include("path.php");
require(BASE."include/"."incl.php");
require(BASE."include/"."application.php");
if($_REQUEST['cmd'])
{
//process screenshot upload
if($_REQUEST['cmd'] == "screenshot_upload")
{
if(havepriv("admin") ||
$_SESSION['current']->is_maintainer($_REQUEST['appId'],
$_REQUEST['versionId']))
(loggedin() && $_SESSION['current']->is_maintainer($_REQUEST['appId'],
$_REQUEST['versionId'])))
{
if(!copy($_FILES['imagefile']['tmp_name'], "data/screenshots/".$_REQUEST['appId']."-".$_REQUEST['versionId']."-".basename($_FILES['imagefile']['name'])))
$str_query = "INSERT INTO appData VALUES (null, ".$_REQUEST['appId'].", ".$_REQUEST['versionId'].
", 'image', '".addslashes($_REQUEST['screenshot_desc'])."', '')";
if(debugging()) addmsg("<p align=center><b>query:</b> $str_query </p>","green");
if (mysql_query($str_query))
{
$int_id = mysql_insert_id();
if(!copy($_FILES['imagefile']['tmp_name'], "data/screenshots/".$int_id))
{
// whoops, copy failed. do something
errorpage("debug: copy failed; (".$_FILES['imagefile']['tmp_name'].";".$_FILES['imagefile']['name']);
$str_query = "DELETE FROM appData WHERE id = '".$int_id."'";
mysql_query($str_query);
exit;
}
$query = "INSERT INTO appData VALUES (null, ".$_REQUEST['appId'].", ".$_REQUEST['versionId'].", 'image', ".
"'".addslashes($_REQUEST['screenshot_desc'])."', '".$_REQUEST['appId']."-".$_REQUEST['versionId']."-".basename($_FILES['imagefile']['name'])."')";
if(debugging()) addmsg("<p align=center><b>query:</b> $query </p>","green");
if (mysql_query($query))
} else
{
// we have to update the entry now that we know it's name
$str_query = "UPDATE appData SET url = '".$int_id."' WHERE id = '".$int_id."'";
if (mysql_query($str_query))
{
//success
$email = getNotifyEmailAddressList($_REQUEST['appId'], $_REQUEST['versionId']);
@@ -62,19 +69,31 @@ if($_REQUEST['cmd'])
$statusMessage = "<p><b>Database Error!<br>".mysql_error()."</b></p>\n";
addmsg($statusMessage, "red");
}
}
}
} else // we are a normal user or an anonymous and submitted a screenshot
{
if(!$str_data = addslashes(fread(fopen($_FILES['imagefile']['tmp_name'], "rb"), filesize($_FILES['imagefile']['tmp_name']))))
{
// whoops, copy failed. do something
errorpage("debug: reading of file failed; (".$_FILES['imagefile']['tmp_name'].";".$_FILES['imagefile']['name']);
exit;
}
$str_query = "INSERT INTO appDataQueue VALUES (null, ".$_REQUEST['appId'].", ".$_REQUEST['versionId'].", 'image', ".
"'".addslashes($_REQUEST['screenshot_desc'])."', '".$_REQUEST['appId']."-".$_REQUEST['versionId']."-".basename($_FILES['imagefile']['name'])."', '$str_data', '".$_SESSION['current']->userid."', NOW())";
$str_query = "INSERT INTO appDataQueue VALUES (null, ".$_REQUEST['appId'].", ".$_REQUEST['versionId'].
", 'image', '".addslashes($_REQUEST['screenshot_desc'])."', '','".$_SESSION['current']->userid.
"', NOW())";
if(debugging()) addmsg("<p align=center><b>query:</b> $str_query </p>","green");
if (mysql_query($str_query))
{
$int_queueId = mysql_insert_id();
if(!copy($_FILES['imagefile']['tmp_name'], "data/queued/screenshots/".$int_queueId))
{
// whoops, copy failed. do something
errorpage("debug: copy failed; (".$_FILES['imagefile']['tmp_name'].";".$_FILES['imagefile']['name']);
$str_query = "DELETE FROM appDataQueue WHERE queueId = '".$int_queueId."'";
mysql_query($str_query);
exit;
} else
{
// we have to update the queued entry now that we know it's name
$str_query = "UPDATE appDataQueue SET url = '".$int_queueId."' WHERE queueId = '".$int_queueId."'";
if (mysql_query($str_query))
{
//success
@@ -105,6 +124,8 @@ if($_REQUEST['cmd'])
addmsg($statusMessage, "red");
}
}
}
}
} elseif($_REQUEST['cmd'] == "delete")
{
if(havepriv("admin") ||
@@ -131,7 +152,6 @@ if($_REQUEST['cmd'])
$email = "no one";
}
addmsg("mesage sent to: ".$email, "green");
addmsg("Image deleted", "green");
redirect(apidb_fullurl("screenshots.php?appId=".$_REQUEST['appId']."&versionId=".$_REQUEST['versionId']));
} else

View File

@@ -206,18 +206,17 @@ create table appData (
* links to screenshots and other stuff waiting to be accepted
*/
create table appDataQueue (
queueid int not null auto_increment,
queueappId int not null,
queueversionId int default 0,
queuetype enum('image', 'url'),
queuedescription text,
queueurl varchar(255),
queuecontent longblob,
queueuserId int not null,
queueId int not null auto_increment,
appId int not null,
versionId int default 0,
type enum('image', 'url'),
description text,
url varchar(255),
userId int not null,
submitTime timestamp,
key(queueid),
index(queueappId),
index(queueversionId)
index(appId),
index(versionId)
);