| \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 ' |
| App Name | ',"\n";
- echo "".appIdToName($obj_row->queueappId)." |
\n";
+ echo "".appIdToName($obj_row->appId)." | \n";
// version
echo '| App Version | ',"\n";
- echo "".versionIdToName($obj_row->queueversionId)." |
\n";
+ echo "".versionIdToName($obj_row->versionId)." | \n";
//dataDescription
echo '| Description | ',"\n";
- echo ' |
',"\n";
+ echo ' | ',"\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 '| Submited image | ',"\n";
- echo ' |
',"\n";
- } elseif($obj_row->queuetype == "url")
+ echo '';
+ $imgSRC = ' ';
+ // generate random tag for popup window
+ $randName = generate_passwd(5);
+ // set image link based on user pref
+ $img = ''.$imgSRC.'';
+ if (loggedin())
+ {
+ if ($_SESSION['current']->getpref("window:screenshot") == "no")
+ {
+ $img = ''.$imgSRC.'';
+ }
+ }
+ echo $img;
+ echo ' | ',"\n";
+ } elseif($obj_row->type == "url")
{
echo '| Submitted link | ',"\n";
- echo ' |
',"\n";
+ echo ' | ',"\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);
-
- $query = "INSERT INTO appData VALUES (null, ".$obj_row->queueappId.", ".$obj_row->queueversionId.", 'image', ".
- "'".addslashes($_REQUEST['description'])."', '".$fname."')";
+ $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."'";
+
}
- 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("query: $query
","green");
- if (mysql_query($query))
+ if (mysql_query($str_query))
{
$statusMessage = "The application data was successfully added into the database
\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)
{
diff --git a/admin/screenshotQueue.php b/admin/screenshotQueue.php
index f97f3df..00dc7b8 100644
--- a/admin/screenshotQueue.php
+++ b/admin/screenshotQueue.php
@@ -1,16 +1,14 @@
diff --git a/include/config.php.sample b/include/config.php.sample
index 669cd69..79f0beb 100644
--- a/include/config.php.sample
+++ b/include/config.php.sample
@@ -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".
diff --git a/screenshots.php b/screenshots.php
index 763bbef..c432409 100644
--- a/screenshots.php
+++ b/screenshots.php
@@ -11,98 +11,119 @@
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']))
- {
- if(!copy($_FILES['imagefile']['tmp_name'], "data/screenshots/".$_REQUEST['appId']."-".$_REQUEST['versionId']."-".basename($_FILES['imagefile']['name'])))
- {
- // whoops, copy failed. do something
- errorpage("debug: copy failed; (".$_FILES['imagefile']['tmp_name'].";".$_FILES['imagefile']['name']);
- 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("query: $query
","green");
-
- if (mysql_query($query))
- {
- //success
- $email = getNotifyEmailAddressList($_REQUEST['appId'], $_REQUEST['versionId']);
- if($email)
- {
- $fullAppName = "Application: ".lookupAppName($_REQUEST['appId'])." Version: ".lookupVersionName($_REQUEST['appId'], $_REQUEST['versionId']);
- $ms .= APPDB_ROOT."screenshots.php?appId=".$_REQUEST['appId']."&versionId=".$_REQUEST['versionId']."\n";
- $ms .= "\n";
- $ms .= $_SESSION['current']->username." added screenshot ".$_REQUEST['screenshot_desc']." to ".$fullAppName."\n";
- $ms .= "\n";
- $ms .= STANDARD_NOTIFY_FOOTER;
-
- mail(stripslashes($email), "[AppDB] ".$fullAppName ,$ms);
- } else
- {
- $email = "no one";
- }
- addmsg("mesage sent to: ".$email, "green");
-
- addmsg("The image was successfully added into the database", "green");
- redirect(apidb_fullurl("screenshots.php?appId=".$_REQUEST['appId']."&versionId=".$_REQUEST['versionId']));
- }
- else
- {
- //error
- $statusMessage = "Database Error!
".mysql_error()."
\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())";
+ (loggedin() && $_SESSION['current']->is_maintainer($_REQUEST['appId'],
+ $_REQUEST['versionId'])))
+ {
+ $str_query = "INSERT INTO appData VALUES (null, ".$_REQUEST['appId'].", ".$_REQUEST['versionId'].
+ ", 'image', '".addslashes($_REQUEST['screenshot_desc'])."', '')";
if(debugging()) addmsg("query: $str_query
","green");
if (mysql_query($str_query))
{
- //success
- $email = getNotifyEmailAddressList($_REQUEST['appId'], $_REQUEST['versionId']);
- if($email)
+ $int_id = mysql_insert_id();
+
+ if(!copy($_FILES['imagefile']['tmp_name'], "data/screenshots/".$int_id))
{
- $fullAppName = "Application: ".lookupAppName($_REQUEST['appId'])." Version: ".lookupVersionName($_REQUEST['appId'], $_REQUEST['versionId']);
- $ms .= APPDB_ROOT."admin/adminAppDataQueue.php?queueId=".mysql_insert_id()."\n";
- $ms .= "\n";
- $ms .= ($_SESSION['current']->username ? $_SESSION['current']->username : "an anonymous user")." submitted a screenshot ".$_REQUEST['screenshot_desc']." for ".$fullAppName."\n";
- $ms .= "\n";
- $ms .= STANDARD_NOTIFY_FOOTER;
+ // 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;
+ } 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']);
+ if($email)
+ {
+ $fullAppName = "Application: ".lookupAppName($_REQUEST['appId'])." Version: ".lookupVersionName($_REQUEST['appId'], $_REQUEST['versionId']);
+ $ms .= APPDB_ROOT."screenshots.php?appId=".$_REQUEST['appId']."&versionId=".$_REQUEST['versionId']."\n";
+ $ms .= "\n";
+ $ms .= $_SESSION['current']->username." added screenshot ".$_REQUEST['screenshot_desc']." to ".$fullAppName."\n";
+ $ms .= "\n";
+ $ms .= STANDARD_NOTIFY_FOOTER;
- mail(stripslashes($email), "[AppDB] ".$fullAppName ,$ms);
- } else
- {
- $email = "no one";
- }
- addmsg("mesage sent to: ".$email, "green");
+ mail(stripslashes($email), "[AppDB] ".$fullAppName ,$ms);
+ } else
+ {
+ $email = "no one";
+ }
+ addmsg("mesage sent to: ".$email, "green");
- addmsg("The image you submitted will be added to the database database after being reviewed", "green");
- redirect(apidb_fullurl("screenshots.php?appId=".$_REQUEST['appId']."&versionId=".$_REQUEST['versionId']));
+ addmsg("The image was successfully added into the database", "green");
+ redirect(apidb_fullurl("screenshots.php?appId=".$_REQUEST['appId']."&versionId=".$_REQUEST['versionId']));
+ }
+ else
+ {
+ //error
+ $statusMessage = "Database Error!
".mysql_error()."
\n";
+ addmsg($statusMessage, "red");
+ }
+ }
}
- else
+ } else // we are a normal user or an anonymous and submitted a screenshot
+ {
+ $str_query = "INSERT INTO appDataQueue VALUES (null, ".$_REQUEST['appId'].", ".$_REQUEST['versionId'].
+ ", 'image', '".addslashes($_REQUEST['screenshot_desc'])."', '','".$_SESSION['current']->userid.
+ "', NOW())";
+
+ if(debugging()) addmsg("query: $str_query
","green");
+
+ if (mysql_query($str_query))
{
- //error
- $statusMessage = "Database Error!
".mysql_error()."
\n";
- addmsg($statusMessage, "red");
+ $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
+ $email = getNotifyEmailAddressList($_REQUEST['appId'], $_REQUEST['versionId']);
+ if($email)
+ {
+ $fullAppName = "Application: ".lookupAppName($_REQUEST['appId'])." Version: ".lookupVersionName($_REQUEST['appId'], $_REQUEST['versionId']);
+ $ms .= APPDB_ROOT."admin/adminAppDataQueue.php?queueId=".mysql_insert_id()."\n";
+ $ms .= "\n";
+ $ms .= ($_SESSION['current']->username ? $_SESSION['current']->username : "an anonymous user")." submitted a screenshot ".$_REQUEST['screenshot_desc']." for ".$fullAppName."\n";
+ $ms .= "\n";
+ $ms .= STANDARD_NOTIFY_FOOTER;
+
+ mail(stripslashes($email), "[AppDB] ".$fullAppName ,$ms);
+ } else
+ {
+ $email = "no one";
+ }
+ addmsg("mesage sent to: ".$email, "green");
+
+ addmsg("The image you submitted will be added to the database database after being reviewed", "green");
+ redirect(apidb_fullurl("screenshots.php?appId=".$_REQUEST['appId']."&versionId=".$_REQUEST['versionId']));
+ }
+ else
+ {
+ //error
+ $statusMessage = "Database Error!
".mysql_error()."
\n";
+ addmsg($statusMessage, "red");
+ }
+ }
}
}
} elseif($_REQUEST['cmd'] == "delete")
@@ -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
diff --git a/tables/appdb_tables.sql b/tables/appdb_tables.sql
index 7dca26d..bf2bb27 100644
--- a/tables/appdb_tables.sql
+++ b/tables/appdb_tables.sql
@@ -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)
);