diff --git a/TODO b/TODO index 986cb6d..54da060 100644 --- a/TODO +++ b/TODO @@ -11,13 +11,6 @@ RELATED TODO: how to handle deleting accounts that have comments? go through and assign them to a special account number that prints (account deleted due to inactivity) -# replace all mysql_query() by query_appdb() (available from include/db.php). -When it's done we have to remove opendb() function call in incl.php and definition -in util.php as query_appdb already does the connection when needed. - -# we have to check if we really need to separate user database from appdb database -(as seen in the config file and include/db.php) - # when deleting an application we should delete linked entries (screenshots, comments, etc.) # when deleting a screenshot we should delete the image file as well @@ -43,4 +36,4 @@ In particular globally registered vars should be replaced by superglobals (nearl # add new table for maintainer ratings. fields: userid, appId versionId ,rating, wineversion, distro, source/package -# add user management \ No newline at end of file +# add user management diff --git a/admin/addAppFamily.php b/admin/addAppFamily.php index 5a54599..2308e74 100644 --- a/admin/addAppFamily.php +++ b/admin/addAppFamily.php @@ -24,7 +24,7 @@ else $table = "appFamily"; $query = "INSERT INTO $table VALUES(0, 'NONAME', 0, null, null, null, $catId)"; - mysql_query("DELETE FROM $table WHERE appName = 'NONAME'"); + query_appdb("DELETE FROM $table WHERE appName = 'NONAME'"); if(debugging()) { echo "

query: $query

"; } diff --git a/admin/addAppNote.php b/admin/addAppNote.php index 058c9d0..628722a 100644 --- a/admin/addAppNote.php +++ b/admin/addAppNote.php @@ -35,7 +35,7 @@ if($_REQUEST['sub'] == "Submit") addslashes($_REQUEST['noteTitle'])."', '". addslashes($_REQUEST['noteDesc'])."', ". "{$_REQUEST['appId']}, {$_REQUEST['versionId']})"; - if (mysql_query($query)) + if (query_appdb($query)) { // successful $email = getNotifyEmailAddressList($_REQUEST['appId'], $_REQUEST['versionId']); diff --git a/admin/addAppVersion.php b/admin/addAppVersion.php index b7a88e7..e1cb88a 100644 --- a/admin/addAppVersion.php +++ b/admin/addAppVersion.php @@ -31,7 +31,7 @@ else $table = "appVersion"; $query = "INSERT INTO $table VALUES(0, $appId, 'NONAME', null, null, null, 0.0, 0.0)"; - mysql_query("DELETE FROM $table WHERE versionName = 'NONAME'"); + query_appdb("DELETE FROM $table WHERE versionName = 'NONAME'"); if(debugging()) echo "$query

\n"; diff --git a/admin/addCategory.php b/admin/addCategory.php index ca5db5c..6cc2adc 100644 --- a/admin/addCategory.php +++ b/admin/addCategory.php @@ -28,7 +28,7 @@ else $table = "appCategory"; $query = "INSERT INTO $table VALUES(0, 'NONAME', null, 0)"; - mysql_query("DELETE FROM $table WHERE catName = 'NONAME'"); + query_appdb("DELETE FROM $table WHERE catName = 'NONAME'"); if(debugging()) echo "$query

\n"; diff --git a/admin/addVendor.php b/admin/addVendor.php index cca8afd..27573f6 100644 --- a/admin/addVendor.php +++ b/admin/addVendor.php @@ -28,7 +28,7 @@ else $table = "vendor"; $query = "INSERT INTO $table VALUES(0, 'NONAME', null)"; - mysql_query("DELETE FROM $table WHERE vendorName = 'NONAME'"); + query_appdb("DELETE FROM $table WHERE vendorName = 'NONAME'"); if(debugging()) echo "$query

\n"; diff --git a/admin/adminAppDataQueue.php b/admin/adminAppDataQueue.php index 5f48db3..d39c39f 100644 --- a/admin/adminAppDataQueue.php +++ b/admin/adminAppDataQueue.php @@ -22,10 +22,10 @@ if(!havepriv("admin")) if (!$_REQUEST['queueId']) { //get available appData - $str_query = "SELECT * from appDataQueue;"; - $result = mysql_query($str_query); + $sQuery = "SELECT * from appDataQueue;"; + $hResult = query_appdb($sQuery); - if(!$result || !mysql_num_rows($result)) + if(!$hResult || !mysql_num_rows($hResult)) { //no appData in queue echo html_frame_start("","90%"); @@ -55,7 +55,7 @@ if (!$_REQUEST['queueId']) echo "\n\n"; $c = 1; - while($ob = mysql_fetch_object($result)) + while($ob = mysql_fetch_object($hResult)) { if($_SESSION['current']->is_maintainer($ob->queueappId, $ob->queueversionId) @@ -90,9 +90,9 @@ if (!$_REQUEST['queueId']) exit; } - $str_request="SELECT * FROM appDataQueue WHERE queueId='".$_REQUEST['queueId']."'"; - $res_result=mysql_query($str_request); - $obj_row=mysql_fetch_object($res_result); + $sQuery="SELECT * FROM appDataQueue WHERE queueId='".$_REQUEST['queueId']."'"; + $hResult=query_appdb($sQuery); + $obj_row=mysql_fetch_object($hResult); if(!$_REQUEST['sub']=="inside_form") { @@ -168,16 +168,16 @@ if (!$_REQUEST['queueId']) if($obj_row->type == "image") { - $str_query = "INSERT INTO appData VALUES (null, ".$obj_row->appId.", ".$obj_row->versionId.", 'image', ". + $sQuery = "INSERT INTO appData VALUES (null, ".$obj_row->appId.", ".$obj_row->versionId.", 'image', ". "'".addslashes($_REQUEST['description'])."', '')"; - mysql_query($str_query); + query_appdb($sQuery); $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."'"; + $sQuery = "UPDATE appData SET url = '".$int_id."' WHERE id = '".$int_id."'"; } elseif ($obj_row->type == "url") { @@ -187,23 +187,16 @@ if (!$_REQUEST['queueId']) if(debugging()) addmsg("

query: $query

","green"); - if (mysql_query($str_query)) + if (query_appdb($sQuery)) { $statusMessage = "

The application data was successfully added into the database

\n"; //delete the item from the queue - mysql_query("DELETE from appDataQueue where queueId = ".$obj_row->queueId.";"); - - $goodtogo = 1; /* set to 1 so we send the response email */ - } else - { - //error - $statusMessage = "

Database Error!
".mysql_error()."

\n"; - } - - //Send Status Email - if (lookupEmail($obj_row->userId) && $goodtogo) - { + query_appdb("DELETE from appDataQueue where queueId = ".$obj_row->queueId.";"); + + //Send Status Email + if (lookupEmail($obj_row->userId)) + { $ms = "Application Data Request Report\n"; $ms .= "----------------------------------\n\n"; $ms .= "Your submission of an application data for ".appIdToName($obj_row->appId).versionIdToName($obj_row->versionId)." has been accepted. "; @@ -213,11 +206,12 @@ if (!$_REQUEST['queueId']) $ms .= "-The AppDB admins\n"; mail(stripslashes(lookupEmail($obj_row->userId)),'[AppDB] Application Data Request Report',$ms); - } + } - //done - echo html_frame_start("Submit App Data","600"); - echo "

$statusMessage

\n"; + //done + echo html_frame_start("Submit App Data","600"); + echo "

$statusMessage

\n"; + } } elseif ($_REQUEST['reject']) { if (lookupEmail($obj_row->userId)) @@ -233,17 +227,12 @@ if (!$_REQUEST['queueId']) } //delete main item - $str_query = "DELETE from appDataQueue where queueId = ".$obj_row->queueId.";"; + $sQuery = "DELETE from appDataQueue where queueId = ".$obj_row->queueId.";"; unlink("../data/queued/screenshots/".$obj_row->queueId); - $result = mysql_query($str_query); + $hResult = query_appdb($sQuery); echo html_frame_start("Delete application data submission",400,"",0); - if(!$result) - { - //error - echo "

Internal Error: unable to delete selected maintainer application!

\n"; - } - else + if($result) { //success echo "

Application data was successfully deleted from the Queue.

\n"; diff --git a/admin/adminAppQueue.php b/admin/adminAppQueue.php index 3ff2e46..435fc7b 100644 --- a/admin/adminAppQueue.php +++ b/admin/adminAppQueue.php @@ -27,7 +27,7 @@ if ($_REQUEST['sub']) { //get data $query = "SELECT * from appQueue where queueId = ".$_REQUEST['queueId'].";"; - $result = mysql_query($query); + $result = query_appdb($query); $ob = mysql_fetch_object($result); mysql_free_result($result); } @@ -110,7 +110,7 @@ if ($_REQUEST['sub']) //category $query = "select * from appCategory where catId = '$ob->queueCatId';"; - $result = mysql_query($query); + $result = query_appdb($query); if($result) { $ob2 = mysql_fetch_object($result); @@ -143,7 +143,7 @@ if ($_REQUEST['sub']) // Use the first match if we found one and clear out the vendor field, // otherwise don't pick a vendor $query = "select * from vendor where vendorname = '$ob->queueVendor';"; - $result = mysql_query($query); + $result = query_appdb($query); $checkvendor = 0; if($result) { @@ -154,7 +154,7 @@ if ($_REQUEST['sub']) { // try for a partial match $query = "select * from vendor where vendorname like '%$ob->queueVendor%';"; - $result = mysql_query($query); + $result = query_appdb($query); if($result) { $ob2 = mysql_fetch_object($result); @@ -236,7 +236,7 @@ if ($_REQUEST['sub']) //get the id of the app just added $_REQUEST['appParent'] = mysql_insert_id(); //delete queue item - mysql_query("DELETE from appQueue where queueId = ".$_REQUEST['queueId'].";"); + query_appdb("DELETE from appQueue where queueId = ".$_REQUEST['queueId'].";"); //set ver if not set if (!$_REQUEST['queueVersion']) @@ -294,7 +294,7 @@ if ($_REQUEST['sub']) $_REQUEST['appVersion'] = mysql_insert_id(); $statusMessage = "

The application ".$_REQUEST['queueName']." was successfully added into the database

\n"; addmsg($statusMessage,"Green"); - mysql_query("DELETE from appQueue where queueId = ".$_REQUEST['queueId'].";"); + query_appdb("DELETE from appQueue where queueId = ".$_REQUEST['queueId'].";"); $goodtogo = 1; } @@ -360,12 +360,10 @@ if ($_REQUEST['sub']) { //delete main item $query = "DELETE from appQueue where queueId = ".$_REQUEST['queueId'].";"; - $result = mysql_query($query); + $result = query_appdb($query, "unable to delete selected application!"); if(!$result) { - //error - addmsg("Internal Error: unable to delete selected application!", "red"); - redirect(apidb_fullurl("admin/adminAppQueue.php?appId=".$_REQUEST['appId']."&versionId=".$_REQUEST['versionId'])); + redirect(apidb_fullurl("admin/adminAppQueue.php?appId=".$_REQUEST['appId']."&versionId=".$_REQUEST['versionId'])); } else { @@ -413,7 +411,7 @@ else "queueVersion, queueEmail, queueCatId,". "UNIX_TIMESTAMP(submitTime) as submitTime ". "from appQueue;"; - $result = mysql_query($query); + $result = query_appdb($query); if(!$result || !mysql_num_rows($result)) { @@ -454,7 +452,7 @@ else if ($ob->queueCatId == -1) { $query2 = "select * from appFamily where appId = '$ob->queueName';"; - $result2 = mysql_query($query2); + $result2 = query_appdb($query2); if($result2) { $ob2 = mysql_fetch_object($result2); diff --git a/admin/adminCommentView.php b/admin/adminCommentView.php index ab480ee..e9c4d4b 100644 --- a/admin/adminCommentView.php +++ b/admin/adminCommentView.php @@ -93,14 +93,14 @@ echo ""; /* query for all of the commentId's, ordering by their time in reverse order */ $offset = $currentPage * $commentsPerPage; -$commentIds = mysql_query("SELECT commentId from appComments ORDER BY ". +$commentIds = query_appdb("SELECT commentId from appComments ORDER BY ". "appComments.time ASC LIMIT $offset, $commentsPerPage;"); while ($ob = mysql_fetch_object($commentIds)) { $qstring = "SELECT from_unixtime(unix_timestamp(time), \"%W %M %D %Y, %k:%i\") as time, ". "commentId, parentId, appId, versionId, userid, subject, body ". "FROM appComments WHERE commentId = $ob->commentId;"; - $result = mysql_query($qstring); + $result = query_appdb($qstring); /* call view_app_comment to display the comment */ $comment_ob = mysql_fetch_object($result); diff --git a/admin/adminMaintainerQueue.php b/admin/adminMaintainerQueue.php index e6cae25..87e5edb 100644 --- a/admin/adminMaintainerQueue.php +++ b/admin/adminMaintainerQueue.php @@ -24,7 +24,7 @@ if ($_REQUEST['sub']) "userId, maintainReason, superMaintainer,". "UNIX_TIMESTAMP(submitTime) as submitTime ". "FROM appMaintainerQueue WHERE queueId = ".$_REQUEST['queueId'].";"; - $result = mysql_query($query); + $result = query_appdb($query); $ob = mysql_fetch_object($result); mysql_free_result($result); } @@ -167,10 +167,6 @@ if ($_REQUEST['sub']) } else if ($_REQUEST['add'] && $_REQUEST['queueId']) { - //add this user, app and version to the database - $statusMessage = ""; - $goodtogo = 0; - // insert the new entry into the maintainers list $query = "INSERT into appMaintainers VALUES(null,". "$ob->appId,". @@ -179,23 +175,16 @@ if ($_REQUEST['sub']) "$ob->superMaintainer,". "NOW());"; - if (mysql_query($query)) + if (query_appdb($query)) { $statusMessage = "

The maintainer was successfully added into the database

\n"; //delete the item from the queue - mysql_query("DELETE from appMaintainerQueue where queueId = ".$_REQUEST['queueId'].";"); - - $goodtogo = 1; /* set to 1 so we send the response email */ - } else - { - //error - $statusMessage = "

Database Error!
".mysql_error()."

\n"; - } - - //Send Status Email - if (lookupEmail($ob->userId) && $goodtogo) - { + query_appdb("DELETE from appMaintainerQueue where queueId = ".$_REQUEST['queueId'].";"); + + //Send Status Email + if (lookupEmail($ob->userId)) + { $ms = "Application Maintainer Request Report\n"; $ms .= "----------------------------------\n\n"; $ms .= "Your application to be the maintainer of ".appIdToName($ob->appId).versionIdToName($ob->versionId)." has been accepted. "; @@ -205,10 +194,11 @@ if ($_REQUEST['sub']) $ms .= "-The AppDB admins\n"; mail(stripslashes(lookupEmail($ob->userId)),'[AppDB] Maintainer Request Report',$ms); - } + } - //done - addmsg("

$statusMessage

", 'green'); + //done + addmsg("

$statusMessage

", 'green'); + } } else if (($_REQUEST['reject'] || ($_REQUEST['sub'] == 'reject')) && $_REQUEST['queueId']) { @@ -226,14 +216,9 @@ if ($_REQUEST['sub']) //delete main item $query = "DELETE from appMaintainerQueue where queueId = ".$_REQUEST['queueId'].";"; - $result = mysql_query($query); + $result = query_appdb($query,"unable to delete selected maintainer application"); echo html_frame_start("Delete maintainer application",400,"",0); - if(!$result) - { - //error - echo "

Internal Error: unable to delete selected maintainer application!

\n"; - } - else + if($result) { //success echo "

Maintainer application was successfully deleted from the Queue.

\n"; @@ -258,7 +243,7 @@ if ($_REQUEST['sub']) "superMaintainer,". "UNIX_TIMESTAMP(submitTime) as submitTime ". "from appMaintainerQueue;"; - $result = mysql_query($query); + $result = query_appdb($query); if(!$result || !mysql_num_rows($result)) { diff --git a/admin/editAppFamily.php b/admin/editAppFamily.php index 71b2f7a..77a4b19 100644 --- a/admin/editAppFamily.php +++ b/admin/editAppFamily.php @@ -250,7 +250,7 @@ else echo '',"\n"; $i = 0; - $result = mysql_query("SELECT * FROM appData WHERE appId = $ob->appId AND type = 'url' AND versionId = 0"); + $result = query_appdb("SELECT * FROM appData WHERE appId = $ob->appId AND type = 'url' AND versionId = 0"); if($result && mysql_num_rows($result) > 0) { echo '
Delete',"\n"; diff --git a/admin/editBundle.php b/admin/editBundle.php index fa0ace9..14db254 100644 --- a/admin/editBundle.php +++ b/admin/editBundle.php @@ -11,7 +11,7 @@ if(!havepriv("admin")) function build_app_list() { - $result = mysql_query("SELECT appId, appName FROM appFamily ORDER BY appName"); + $result = query_appdb("SELECT appId, appName FROM appFamily ORDER BY appName"); echo "