- replaced mysql_query() with query_appdb()

- removed opendb()
- removed query_userdb()
- removed error handling from the code as it is done with query_appdb()
This commit is contained in:
Jonathan Ernst
2005-01-12 16:22:55 +00:00
committed by WineHQ
parent bb146a0106
commit d3ad0dba41
25 changed files with 67 additions and 167 deletions

7
TODO
View File

@@ -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 and assign them to a special account number that prints (account deleted due
to inactivity) 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 an application we should delete linked entries (screenshots, comments, etc.)
# when deleting a screenshot we should delete the image file as well # when deleting a screenshot we should delete the image file as well

View File

@@ -24,7 +24,7 @@ else
$table = "appFamily"; $table = "appFamily";
$query = "INSERT INTO $table VALUES(0, 'NONAME', 0, null, null, null, $catId)"; $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 "<p align=center><b>query:</b> $query </p>"; } if(debugging()) { echo "<p align=center><b>query:</b> $query </p>"; }

View File

@@ -35,7 +35,7 @@ if($_REQUEST['sub'] == "Submit")
addslashes($_REQUEST['noteTitle'])."', '". addslashes($_REQUEST['noteTitle'])."', '".
addslashes($_REQUEST['noteDesc'])."', ". addslashes($_REQUEST['noteDesc'])."', ".
"{$_REQUEST['appId']}, {$_REQUEST['versionId']})"; "{$_REQUEST['appId']}, {$_REQUEST['versionId']})";
if (mysql_query($query)) if (query_appdb($query))
{ {
// successful // successful
$email = getNotifyEmailAddressList($_REQUEST['appId'], $_REQUEST['versionId']); $email = getNotifyEmailAddressList($_REQUEST['appId'], $_REQUEST['versionId']);

View File

@@ -31,7 +31,7 @@ else
$table = "appVersion"; $table = "appVersion";
$query = "INSERT INTO $table VALUES(0, $appId, 'NONAME', null, null, null, 0.0, 0.0)"; $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()) if(debugging())
echo "$query <br /><br />\n"; echo "$query <br /><br />\n";

View File

@@ -28,7 +28,7 @@ else
$table = "appCategory"; $table = "appCategory";
$query = "INSERT INTO $table VALUES(0, 'NONAME', null, 0)"; $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()) if(debugging())
echo "$query <br /><br />\n"; echo "$query <br /><br />\n";

View File

@@ -28,7 +28,7 @@ else
$table = "vendor"; $table = "vendor";
$query = "INSERT INTO $table VALUES(0, 'NONAME', null)"; $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()) if(debugging())
echo "$query <br /><br />\n"; echo "$query <br /><br />\n";

View File

@@ -22,10 +22,10 @@ if(!havepriv("admin"))
if (!$_REQUEST['queueId']) if (!$_REQUEST['queueId'])
{ {
//get available appData //get available appData
$str_query = "SELECT * from appDataQueue;"; $sQuery = "SELECT * from appDataQueue;";
$result = mysql_query($str_query); $hResult = query_appdb($sQuery);
if(!$result || !mysql_num_rows($result)) if(!$hResult || !mysql_num_rows($hResult))
{ {
//no appData in queue //no appData in queue
echo html_frame_start("","90%"); echo html_frame_start("","90%");
@@ -55,7 +55,7 @@ if (!$_REQUEST['queueId'])
echo "</tr>\n\n"; echo "</tr>\n\n";
$c = 1; $c = 1;
while($ob = mysql_fetch_object($result)) while($ob = mysql_fetch_object($hResult))
{ {
if($_SESSION['current']->is_maintainer($ob->queueappId, if($_SESSION['current']->is_maintainer($ob->queueappId,
$ob->queueversionId) $ob->queueversionId)
@@ -90,9 +90,9 @@ if (!$_REQUEST['queueId'])
exit; exit;
} }
$str_request="SELECT * FROM appDataQueue WHERE queueId='".$_REQUEST['queueId']."'"; $sQuery="SELECT * FROM appDataQueue WHERE queueId='".$_REQUEST['queueId']."'";
$res_result=mysql_query($str_request); $hResult=query_appdb($sQuery);
$obj_row=mysql_fetch_object($res_result); $obj_row=mysql_fetch_object($hResult);
if(!$_REQUEST['sub']=="inside_form") if(!$_REQUEST['sub']=="inside_form")
{ {
@@ -168,16 +168,16 @@ if (!$_REQUEST['queueId'])
if($obj_row->type == "image") 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'])."', '')"; "'".addslashes($_REQUEST['description'])."', '')";
mysql_query($str_query); query_appdb($sQuery);
$int_id = mysql_insert_id(); $int_id = mysql_insert_id();
// we move the content in the live directory // we move the content in the live directory
rename("../data/queued/screenshots/".$obj_row->queueId, "../data/screenshots/".$int_id); rename("../data/queued/screenshots/".$obj_row->queueId, "../data/screenshots/".$int_id);
// we have to update the entry now that we know its name // 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") { elseif ($obj_row->type == "url") {
@@ -187,23 +187,16 @@ if (!$_REQUEST['queueId'])
if(debugging()) addmsg("<p align=center><b>query:</b> $query </p>","green"); if(debugging()) addmsg("<p align=center><b>query:</b> $query </p>","green");
if (mysql_query($str_query)) if (query_appdb($sQuery))
{ {
$statusMessage = "<p>The application data was successfully added into the database</p>\n"; $statusMessage = "<p>The application data was successfully added into the database</p>\n";
//delete the item from the queue //delete the item from the queue
mysql_query("DELETE from appDataQueue where queueId = ".$obj_row->queueId.";"); query_appdb("DELETE from appDataQueue where queueId = ".$obj_row->queueId.";");
$goodtogo = 1; /* set to 1 so we send the response email */ //Send Status Email
} else if (lookupEmail($obj_row->userId))
{ {
//error
$statusMessage = "<p><b>Database Error!<br>".mysql_error()."</b></p>\n";
}
//Send Status Email
if (lookupEmail($obj_row->userId) && $goodtogo)
{
$ms = "Application Data Request Report\n"; $ms = "Application Data Request Report\n";
$ms .= "----------------------------------\n\n"; $ms .= "----------------------------------\n\n";
$ms .= "Your submission of an application data for ".appIdToName($obj_row->appId).versionIdToName($obj_row->versionId)." has been accepted. "; $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"; $ms .= "-The AppDB admins\n";
mail(stripslashes(lookupEmail($obj_row->userId)),'[AppDB] Application Data Request Report',$ms); mail(stripslashes(lookupEmail($obj_row->userId)),'[AppDB] Application Data Request Report',$ms);
} }
//done //done
echo html_frame_start("Submit App Data","600"); echo html_frame_start("Submit App Data","600");
echo "<p><b>$statusMessage</b></p>\n"; echo "<p><b>$statusMessage</b></p>\n";
}
} elseif ($_REQUEST['reject']) } elseif ($_REQUEST['reject'])
{ {
if (lookupEmail($obj_row->userId)) if (lookupEmail($obj_row->userId))
@@ -233,17 +227,12 @@ if (!$_REQUEST['queueId'])
} }
//delete main item //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); 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); echo html_frame_start("Delete application data submission",400,"",0);
if(!$result) if($result)
{
//error
echo "<p>Internal Error: unable to delete selected maintainer application!</p>\n";
}
else
{ {
//success //success
echo "<p>Application data was successfully deleted from the Queue.</p>\n"; echo "<p>Application data was successfully deleted from the Queue.</p>\n";

View File

@@ -27,7 +27,7 @@ if ($_REQUEST['sub'])
{ {
//get data //get data
$query = "SELECT * from appQueue where queueId = ".$_REQUEST['queueId'].";"; $query = "SELECT * from appQueue where queueId = ".$_REQUEST['queueId'].";";
$result = mysql_query($query); $result = query_appdb($query);
$ob = mysql_fetch_object($result); $ob = mysql_fetch_object($result);
mysql_free_result($result); mysql_free_result($result);
} }
@@ -110,7 +110,7 @@ if ($_REQUEST['sub'])
//category //category
$query = "select * from appCategory where catId = '$ob->queueCatId';"; $query = "select * from appCategory where catId = '$ob->queueCatId';";
$result = mysql_query($query); $result = query_appdb($query);
if($result) if($result)
{ {
$ob2 = mysql_fetch_object($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, // Use the first match if we found one and clear out the vendor field,
// otherwise don't pick a vendor // otherwise don't pick a vendor
$query = "select * from vendor where vendorname = '$ob->queueVendor';"; $query = "select * from vendor where vendorname = '$ob->queueVendor';";
$result = mysql_query($query); $result = query_appdb($query);
$checkvendor = 0; $checkvendor = 0;
if($result) if($result)
{ {
@@ -154,7 +154,7 @@ if ($_REQUEST['sub'])
{ {
// try for a partial match // try for a partial match
$query = "select * from vendor where vendorname like '%$ob->queueVendor%';"; $query = "select * from vendor where vendorname like '%$ob->queueVendor%';";
$result = mysql_query($query); $result = query_appdb($query);
if($result) if($result)
{ {
$ob2 = mysql_fetch_object($result); $ob2 = mysql_fetch_object($result);
@@ -236,7 +236,7 @@ if ($_REQUEST['sub'])
//get the id of the app just added //get the id of the app just added
$_REQUEST['appParent'] = mysql_insert_id(); $_REQUEST['appParent'] = mysql_insert_id();
//delete queue item //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 //set ver if not set
if (!$_REQUEST['queueVersion']) if (!$_REQUEST['queueVersion'])
@@ -294,7 +294,7 @@ if ($_REQUEST['sub'])
$_REQUEST['appVersion'] = mysql_insert_id(); $_REQUEST['appVersion'] = mysql_insert_id();
$statusMessage = "<p>The application ".$_REQUEST['queueName']." was successfully added into the database</p>\n"; $statusMessage = "<p>The application ".$_REQUEST['queueName']." was successfully added into the database</p>\n";
addmsg($statusMessage,"Green"); addmsg($statusMessage,"Green");
mysql_query("DELETE from appQueue where queueId = ".$_REQUEST['queueId'].";"); query_appdb("DELETE from appQueue where queueId = ".$_REQUEST['queueId'].";");
$goodtogo = 1; $goodtogo = 1;
} }
@@ -360,12 +360,10 @@ if ($_REQUEST['sub'])
{ {
//delete main item //delete main item
$query = "DELETE from appQueue where queueId = ".$_REQUEST['queueId'].";"; $query = "DELETE from appQueue where queueId = ".$_REQUEST['queueId'].";";
$result = mysql_query($query); $result = query_appdb($query, "unable to delete selected application!");
if(!$result) if(!$result)
{ {
//error redirect(apidb_fullurl("admin/adminAppQueue.php?appId=".$_REQUEST['appId']."&versionId=".$_REQUEST['versionId']));
addmsg("Internal Error: unable to delete selected application!", "red");
redirect(apidb_fullurl("admin/adminAppQueue.php?appId=".$_REQUEST['appId']."&versionId=".$_REQUEST['versionId']));
} }
else else
{ {
@@ -413,7 +411,7 @@ else
"queueVersion, queueEmail, queueCatId,". "queueVersion, queueEmail, queueCatId,".
"UNIX_TIMESTAMP(submitTime) as submitTime ". "UNIX_TIMESTAMP(submitTime) as submitTime ".
"from appQueue;"; "from appQueue;";
$result = mysql_query($query); $result = query_appdb($query);
if(!$result || !mysql_num_rows($result)) if(!$result || !mysql_num_rows($result))
{ {
@@ -454,7 +452,7 @@ else
if ($ob->queueCatId == -1) if ($ob->queueCatId == -1)
{ {
$query2 = "select * from appFamily where appId = '$ob->queueName';"; $query2 = "select * from appFamily where appId = '$ob->queueName';";
$result2 = mysql_query($query2); $result2 = query_appdb($query2);
if($result2) if($result2)
{ {
$ob2 = mysql_fetch_object($result2); $ob2 = mysql_fetch_object($result2);

View File

@@ -93,14 +93,14 @@ echo "</center>";
/* query for all of the commentId's, ordering by their time in reverse order */ /* query for all of the commentId's, ordering by their time in reverse order */
$offset = $currentPage * $commentsPerPage; $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;"); "appComments.time ASC LIMIT $offset, $commentsPerPage;");
while ($ob = mysql_fetch_object($commentIds)) while ($ob = mysql_fetch_object($commentIds))
{ {
$qstring = "SELECT from_unixtime(unix_timestamp(time), \"%W %M %D %Y, %k:%i\") as time, ". $qstring = "SELECT from_unixtime(unix_timestamp(time), \"%W %M %D %Y, %k:%i\") as time, ".
"commentId, parentId, appId, versionId, userid, subject, body ". "commentId, parentId, appId, versionId, userid, subject, body ".
"FROM appComments WHERE commentId = $ob->commentId;"; "FROM appComments WHERE commentId = $ob->commentId;";
$result = mysql_query($qstring); $result = query_appdb($qstring);
/* call view_app_comment to display the comment */ /* call view_app_comment to display the comment */
$comment_ob = mysql_fetch_object($result); $comment_ob = mysql_fetch_object($result);

View File

@@ -24,7 +24,7 @@ if ($_REQUEST['sub'])
"userId, maintainReason, superMaintainer,". "userId, maintainReason, superMaintainer,".
"UNIX_TIMESTAMP(submitTime) as submitTime ". "UNIX_TIMESTAMP(submitTime) as submitTime ".
"FROM appMaintainerQueue WHERE queueId = ".$_REQUEST['queueId'].";"; "FROM appMaintainerQueue WHERE queueId = ".$_REQUEST['queueId'].";";
$result = mysql_query($query); $result = query_appdb($query);
$ob = mysql_fetch_object($result); $ob = mysql_fetch_object($result);
mysql_free_result($result); mysql_free_result($result);
} }
@@ -167,10 +167,6 @@ if ($_REQUEST['sub'])
} }
else if ($_REQUEST['add'] && $_REQUEST['queueId']) 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 // insert the new entry into the maintainers list
$query = "INSERT into appMaintainers VALUES(null,". $query = "INSERT into appMaintainers VALUES(null,".
"$ob->appId,". "$ob->appId,".
@@ -179,23 +175,16 @@ if ($_REQUEST['sub'])
"$ob->superMaintainer,". "$ob->superMaintainer,".
"NOW());"; "NOW());";
if (mysql_query($query)) if (query_appdb($query))
{ {
$statusMessage = "<p>The maintainer was successfully added into the database</p>\n"; $statusMessage = "<p>The maintainer was successfully added into the database</p>\n";
//delete the item from the queue //delete the item from the queue
mysql_query("DELETE from appMaintainerQueue where queueId = ".$_REQUEST['queueId'].";"); query_appdb("DELETE from appMaintainerQueue where queueId = ".$_REQUEST['queueId'].";");
$goodtogo = 1; /* set to 1 so we send the response email */ //Send Status Email
} else if (lookupEmail($ob->userId))
{ {
//error
$statusMessage = "<p><b>Database Error!<br>".mysql_error()."</b></p>\n";
}
//Send Status Email
if (lookupEmail($ob->userId) && $goodtogo)
{
$ms = "Application Maintainer Request Report\n"; $ms = "Application Maintainer Request Report\n";
$ms .= "----------------------------------\n\n"; $ms .= "----------------------------------\n\n";
$ms .= "Your application to be the maintainer of ".appIdToName($ob->appId).versionIdToName($ob->versionId)." has been accepted. "; $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"; $ms .= "-The AppDB admins\n";
mail(stripslashes(lookupEmail($ob->userId)),'[AppDB] Maintainer Request Report',$ms); mail(stripslashes(lookupEmail($ob->userId)),'[AppDB] Maintainer Request Report',$ms);
} }
//done //done
addmsg("<p><b>$statusMessage</b></p>", 'green'); addmsg("<p><b>$statusMessage</b></p>", 'green');
}
} }
else if (($_REQUEST['reject'] || ($_REQUEST['sub'] == 'reject')) && $_REQUEST['queueId']) else if (($_REQUEST['reject'] || ($_REQUEST['sub'] == 'reject')) && $_REQUEST['queueId'])
{ {
@@ -226,14 +216,9 @@ if ($_REQUEST['sub'])
//delete main item //delete main item
$query = "DELETE from appMaintainerQueue where queueId = ".$_REQUEST['queueId'].";"; $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); echo html_frame_start("Delete maintainer application",400,"",0);
if(!$result) if($result)
{
//error
echo "<p>Internal Error: unable to delete selected maintainer application!</p>\n";
}
else
{ {
//success //success
echo "<p>Maintainer application was successfully deleted from the Queue.</p>\n"; echo "<p>Maintainer application was successfully deleted from the Queue.</p>\n";
@@ -258,7 +243,7 @@ if ($_REQUEST['sub'])
"superMaintainer,". "superMaintainer,".
"UNIX_TIMESTAMP(submitTime) as submitTime ". "UNIX_TIMESTAMP(submitTime) as submitTime ".
"from appMaintainerQueue;"; "from appMaintainerQueue;";
$result = mysql_query($query); $result = query_appdb($query);
if(!$result || !mysql_num_rows($result)) if(!$result || !mysql_num_rows($result))
{ {

View File

@@ -250,7 +250,7 @@ else
echo '<table border=0 cellpadding=6 cellspacing=0 width="100%">',"\n"; echo '<table border=0 cellpadding=6 cellspacing=0 width="100%">',"\n";
$i = 0; $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) if($result && mysql_num_rows($result) > 0)
{ {
echo '<tr><td class=color1><b>Delete</b></td><td class=color1>',"\n"; echo '<tr><td class=color1><b>Delete</b></td><td class=color1>',"\n";

View File

@@ -11,7 +11,7 @@ if(!havepriv("admin"))
function build_app_list() 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 "<select name=appId size=5 onChange='this.form.submit()'>\n"; echo "<select name=appId size=5 onChange='this.form.submit()'>\n";
while($ob = mysql_fetch_object($result)) while($ob = mysql_fetch_object($result))
@@ -26,7 +26,7 @@ if($cmd)
{ {
if($cmd == "delete") if($cmd == "delete")
{ {
$result = mysql_query("DELETE FROM appBundle WHERE appId = $appId AND bundleId = $bundleId"); $result = query_appdb("DELETE FROM appBundle WHERE appId = $appId AND bundleId = $bundleId");
if($result) if($result)
addmsg("App deleted from bundle", "green"); addmsg("App deleted from bundle", "green");
else else
@@ -34,7 +34,7 @@ if($cmd)
} }
if($cmd == "add") if($cmd == "add")
{ {
$result = mysql_query("INSERT INTO appBundle VALUES ($bundleId, $appId)"); $result = query_appdb("INSERT INTO appBundle VALUES ($bundleId, $appId)");
if($result) if($result)
addmsg("App $appId added to Bundle $bundleId", "green"); addmsg("App $appId added to Bundle $bundleId", "green");
else else
@@ -47,7 +47,7 @@ else
{ {
apidb_header("Edit Application Bundle"); apidb_header("Edit Application Bundle");
$result = mysql_query("SELECT bundleId, appBundle.appId, appName FROM appBundle, appFamily ". $result = query_appdb("SELECT bundleId, appBundle.appId, appName FROM appBundle, appFamily ".
"WHERE bundleId = $bundleId AND appFamily.appId = appBundle.appId"); "WHERE bundleId = $bundleId AND appFamily.appId = appBundle.appId");
if($result && mysql_num_rows($result)) if($result && mysql_num_rows($result))

View File

@@ -36,8 +36,6 @@ if(!$versionId) {
$versionId = 0; $versionId = 0;
} }
opendb();
// We have input, but wrong input // We have input, but wrong input
if( ( $width AND !is_numeric($width) ) || ( $height AND !is_numeric($height) ) ) if( ( $width AND !is_numeric($width) ) || ( $height AND !is_numeric($height) ) )
{ {

View File

@@ -32,8 +32,6 @@ if(!havepriv("admin") &&
exit; exit;
} }
opendb();
/* retrieve the parentID of the comment we are deleting */ /* retrieve the parentID of the comment we are deleting */
/* so we can fix up the parentIds of this comments children */ /* so we can fix up the parentIds of this comments children */
$result = query_appdb("SELECT parentId FROM appComments WHERE commentId = '".$_REQUEST['commentId']."'"); $result = query_appdb("SELECT parentId FROM appComments WHERE commentId = '".$_REQUEST['commentId']."'");

View File

@@ -87,7 +87,7 @@ function grab_comments($appId, $versionId, $parentId = -1)
$extra. $extra.
"ORDER BY appComments.time ASC"; "ORDER BY appComments.time ASC";
$result = mysql_query($qstring); $result = query_appdb($qstring);
return $result; return $result;
} }
@@ -99,7 +99,7 @@ function grab_comments($appId, $versionId, $parentId = -1)
function count_comments($appId, $versionId) function count_comments($appId, $versionId)
{ {
$qstring = "SELECT count(commentId) as hits FROM appComments WHERE appId = $appId AND versionId = $versionId"; $qstring = "SELECT count(commentId) as hits FROM appComments WHERE appId = $appId AND versionId = $versionId";
$result = mysql_query($qstring); $result = query_appdb($qstring);
$ob = mysql_fetch_object($result); $ob = mysql_fetch_object($result);
return $ob->hits; return $ob->hits;
} }
@@ -192,7 +192,7 @@ function display_comments_flat($appId, $versionId)
function view_app_comments($appId, $versionId, $threadId = 0) function view_app_comments($appId, $versionId, $threadId = 0)
{ {
// count posts // count posts
$result = mysql_query("SELECT commentId FROM appComments WHERE appId = $appId AND versionId = $versionId"); $result = query_appdb("SELECT commentId FROM appComments WHERE appId = $appId AND versionId = $versionId");
$messageCount = mysql_num_rows($result); $messageCount = mysql_num_rows($result);
//start comment format table //start comment format table

View File

@@ -30,15 +30,6 @@ define("APPS_DBHOST","localhost");
define("APPS_DB","apidb"); define("APPS_DB","apidb");
/*
* users database info
*/
define("USERS_DBUSER","wineowner");
define("USERS_DBPASS","lemonade");
define("USERS_DBHOST","localhost");
define("USERS_DB","apidb");
/* /*
* bugzilla database info * bugzilla database info
*/ */

View File

@@ -14,21 +14,6 @@ function query_appdb($sQuery,$sComment="")
} }
function query_userdb($sQuery)
{
global $hUserLink;
if(!$hUserLink)
{
$hUserLink = mysql_pconnect(USERS_DBHOST, USERS_DBUSER, USERS_DBPASS);
mysql_select_db(USERS_DB);
}
$hResult = mysql_query($sQuery, $hUserLink);
if(!$hResult) query_error($sComment);
return $hResult;
}
function query_bugzilladb($sQuery,$sComment="") function query_bugzilladb($sQuery,$sComment="")
{ {
global $hBugzillaLink; global $hBugzillaLink;

View File

@@ -210,13 +210,7 @@ function dumpmsgbuffer()
query_appdb("DELETE FROM sessionMessages WHERE sessionId = '".session_id()."'"); query_appdb("DELETE FROM sessionMessages WHERE sessionId = '".session_id()."'");
} }
/**
/*
* Start DB Connection
*/
opendb();
/*
* Init Session (stores user info and cart info in session) * Init Session (stores user info and cart info in session)
*/ */
$session = new session("whq_appdb"); $session = new session("whq_appdb");

View File

@@ -18,8 +18,6 @@ class TableVE {
$this->titleField = ""; $this->titleField = "";
$this->titleText = ""; $this->titleText = "";
$this->numberedTitles = 0; $this->numberedTitles = 0;
opendb();
} }
function test($query) function test($query)

View File

@@ -122,7 +122,7 @@ class User {
$sFields = "({$aInsert['FIELDS']}, `password`, `stamp`, `created`)"; $sFields = "({$aInsert['FIELDS']}, `password`, `stamp`, `created`)";
$sValues = "({$aInsert['VALUES']}, password('".$sPassword."'), NOW(), NOW() )"; $sValues = "({$aInsert['VALUES']}, password('".$sPassword."'), NOW(), NOW() )";
if (!query_userdb("INSERT INTO user_list $sFields VALUES $sValues")) if (!query_appdb("INSERT INTO user_list $sFields VALUES $sValues"))
{ {
return mysql_error(); return mysql_error();
} }

View File

@@ -1,27 +1,4 @@
<?php <?php
$dbcon = null;
$dbref = 0;
function opendb()
{
global $dbcon, $dbref;
$dbref++;
if($dbcon)
return $dbcon;
$dbcon = mysql_connect(APPS_DBHOST, APPS_DBUSER, APPS_DBPASS);
if(!$dbcon)
{
echo "An error occurred: ".mysql_error()."<p>\n";
exit;
}
mysql_select_db(APPS_DB);
return $dbcon;
}
function build_urlarg($vars) function build_urlarg($vars)
{ {
$arr = array(); $arr = array();

View File

@@ -17,8 +17,6 @@ if(!loggedin())
exit; exit;
} }
opendb();
$appId = strip_tags($_POST['appId']); $appId = strip_tags($_POST['appId']);
$versionId = strip_tags($_POST['versionId']); $versionId = strip_tags($_POST['versionId']);
$confirmed = strip_tags($_POST['confirmed']); $confirmed = strip_tags($_POST['confirmed']);

View File

@@ -41,8 +41,6 @@ if(!loggedin())
exit; exit;
} }
opendb();
$appId = strip_tags($_POST['appId']); $appId = strip_tags($_POST['appId']);
$versionId = strip_tags($_POST['versionId']); $versionId = strip_tags($_POST['versionId']);
$superMaintainer = strip_tags($_POST['superMaintainer']); $superMaintainer = strip_tags($_POST['superMaintainer']);

View File

@@ -17,8 +17,6 @@ if(!loggedin())
function build_prefs_list() function build_prefs_list()
{ {
opendb();
$result = query_appdb("SELECT * FROM prefs_list ORDER BY id"); $result = query_appdb("SELECT * FROM prefs_list ORDER BY id");
while($r = mysql_fetch_object($result)) while($r = mysql_fetch_object($result))
{ {

View File

@@ -1,4 +1,4 @@
<?php <?php
/*******************************************************************/ /*******************************************************************/
/* this script expects appId and optionally versionId as arguments */ /* this script expects appId and optionally versionId as arguments */
/* OR */ /* OR */