From 6119246b51acb1ba5042c2057f4b11f3edb741f8 Mon Sep 17 00:00:00 2001 From: Chris Morgan Date: Fri, 3 Aug 2007 23:27:25 +0000 Subject: [PATCH] Replace direct mysql_xxx() calls with query_xxx() calls. Replace calls to mysql_insert_id() with calls specific to the appdb or bugzilla database. Fixes a bug where a call to mysql_insert_id() can potentially retrieve an id from either the bugzilla or appdb database, depending on whichever database was last opened by mysql_connect(). --- addcomment.php | 2 +- admin/addAppNote.php | 2 +- admin/addCategory.php | 2 +- admin/adminBugs.php | 4 +- admin/adminCommentView.php | 4 +- admin/adminMaintainers.php | 4 +- admin/adminScreenshots.php | 4 +- admin/adminUsers.php | 2 +- admin/editBundle.php | 8 +-- admin/maintainerNotification.php | 4 +- admin/moveAppVersion.php | 2 +- appview.php | 4 +- browse_downloadable.php | 8 +-- cron/cleanup.php | 14 ++--- include/appData.php | 10 ++-- include/appdb.php | 8 +-- include/application.php | 28 +++++----- include/application_queue.php | 6 +-- include/bugs.php | 14 ++--- include/category.php | 12 ++--- include/comment.php | 22 ++++---- include/distribution.php | 14 ++--- include/downloadurl.php | 18 +++---- include/error_log.php | 6 +-- include/incl.php | 25 +++------ include/maintainer.php | 34 ++++++------ include/monitor.php | 12 ++--- include/note.php | 4 +- include/objectManager.php | 6 +-- include/query.php | 63 ++++++++++++++++++++-- include/screenshot.php | 10 ++-- include/session.php | 4 +- include/tableve.php | 36 ++++++------- include/testData.php | 24 ++++----- include/url.php | 12 ++--- include/user.php | 44 +++++++-------- include/util.php | 40 +++++++------- include/vendor.php | 12 ++--- include/version.php | 42 +++++++-------- include/version_queue.php | 2 +- include/vote.php | 10 ++-- index.php | 2 +- preferences.php | 2 +- screenshots.php | 4 +- unit_test/run_tests.php | 2 +- unit_test/test_application.php | 2 +- unit_test/test_maintainer.php | 8 +-- unit_test/test_maintainer_notify.php | 4 +- unit_test/test_om_objects.php | 10 ++-- unit_test/test_query.php | 6 +-- unit_test/test_user_password_migration.php | 6 +-- viewScreenshots.php | 2 +- viewbugs.php | 4 +- votestats.php | 4 +- 54 files changed, 343 insertions(+), 295 deletions(-) diff --git a/addcomment.php b/addcomment.php index 8c1272a..92bedaf 100644 --- a/addcomment.php +++ b/addcomment.php @@ -48,7 +48,7 @@ if(!empty($aClean['sBody'])) { $hResult = query_parameters("SELECT * FROM appComments WHERE commentId = '?'", $aClean['iThread']); - $oRow = mysql_fetch_object($hResult); + $oRow = query_fetch_object($hResult); if($oRow) { $mesTitle = "Replying To ... $oRow->subject\n"; diff --git a/admin/addAppNote.php b/admin/addAppNote.php index 8d3cdc2..ae1f96c 100644 --- a/admin/addAppNote.php +++ b/admin/addAppNote.php @@ -10,7 +10,7 @@ require_once(BASE."include/note.php"); //FIXME: get rid of appId references everywhere, as version is enough. $sQuery = "SELECT appId FROM appVersion WHERE versionId = '?'"; $hResult = query_parameters($sQuery, $aClean['iVersionId']); -$oRow = mysql_fetch_object($hResult); +$oRow = query_fetch_object($hResult); $appId = $oRow->appId; //check for admin privs diff --git a/admin/addCategory.php b/admin/addCategory.php index fa6f16e..0159249 100644 --- a/admin/addCategory.php +++ b/admin/addCategory.php @@ -18,7 +18,7 @@ else apidb_header("Add Category"); $sQuery = "SELECT catId, catName FROM appCategory WHERE catId!='?'"; $hResult = query_parameters($sQuery, $aClean['iCatId']); - while($oRow = mysql_fetch_object($hResult)) + while($oRow = query_fetch_object($hResult)) { $aCatsIds[]=$oRow->catId; $aCatsNames[]=$oRow->catName; diff --git a/admin/adminBugs.php b/admin/adminBugs.php index d0ce6ac..4a9cf28 100644 --- a/admin/adminBugs.php +++ b/admin/adminBugs.php @@ -111,13 +111,13 @@ if (isset($aClean['sSub'])) FROM appFamily, appVersion, buglinks, bugs.bugs ".$sWhere." ORDER BY buglinks.bug_id, appName, versionName - LIMIT ".mysql_real_escape_string($offset).", ".mysql_real_escape_string($ItemsPerPage).";"; + LIMIT ".query_escape_string($offset).", ".query_escape_string($ItemsPerPage).";"; $c = 0; if($hResult = query_parameters($sQuery)) { - while($oRow = mysql_fetch_object($hResult)) + while($oRow = query_fetch_object($hResult)) { $oApp = new application($oRow->appId); $oVersion = new version($oRow->versionId); diff --git a/admin/adminCommentView.php b/admin/adminCommentView.php index a12aa62..eb947cf 100644 --- a/admin/adminCommentView.php +++ b/admin/adminCommentView.php @@ -52,14 +52,14 @@ echo ""; $offset = (($currentPage-1) * $ItemsPerPage); $commentIds = query_parameters("SELECT commentId from appComments ORDER BY ". "appComments.time ASC LIMIT ?, ?", $offset, $ItemsPerPage); -while ($oRow = mysql_fetch_object($commentIds)) +while ($oRow = query_fetch_object($commentIds)) { $sQuery = "SELECT from_unixtime(unix_timestamp(time), \"%W %M %D %Y, %k:%i\") as time, ". "commentId, parentId, versionId, userid, subject, body ". "FROM appComments WHERE commentId = '?'"; $hResult = query_parameters($sQuery, $oRow->commentId); /* call view_app_comment to display the comment */ - $oComment_row = mysql_fetch_object($hResult); + $oComment_row = query_fetch_object($hResult); Comment::view_app_comment($oComment_row); } diff --git a/admin/adminMaintainers.php b/admin/adminMaintainers.php index a6ee83f..041a888 100644 --- a/admin/adminMaintainers.php +++ b/admin/adminMaintainers.php @@ -38,7 +38,7 @@ if (isset($aClean['sSub'])) $sQuery.= " AND queued='false' ORDER BY realname;"; $hResult = query_parameters($sQuery); - if(!$hResult || !mysql_num_rows($hResult)) + if(!$hResult || !query_num_rows($hResult)) { // no apps echo html_frame_start("","90%"); @@ -61,7 +61,7 @@ if (isset($aClean['sSub'])) $c = 1; $oldUserId = 0; - while($oRow = mysql_fetch_object($hResult)) + while($oRow = query_fetch_object($hResult)) { $oUser = new User($oRow->userId); $oApp = new application($oRow->appId); diff --git a/admin/adminScreenshots.php b/admin/adminScreenshots.php index 0d433bd..4cca6f5 100644 --- a/admin/adminScreenshots.php +++ b/admin/adminScreenshots.php @@ -37,7 +37,7 @@ if(isset($aClean['sRegenerate'])) { $sQuery = "SELECT id FROM appData WHERE type = 'screenshot'"; $hResult = query_parameters($sQuery); - while($oRow = mysql_fetch_object($hResult)) + while($oRow = query_fetch_object($hResult)) { echo "REGENERATING IMAGE ".$oRow->id."
"; $screenshot = new Screenshot($oRow->id); @@ -100,7 +100,7 @@ $Ids = query_parameters("SELECT * from appData ORDER BY id ASC LIMIT ?, ?", $offset, $ItemsPerPage); $c = 1; echo "
\n"; -while ($oRow = mysql_fetch_object($Ids)) +while ($oRow = query_fetch_object($Ids)) { // display thumbnail $oVersion = new Version($oRow->versionId); diff --git a/admin/adminUsers.php b/admin/adminUsers.php index 81c04d6..20d4957 100644 --- a/admin/adminUsers.php +++ b/admin/adminUsers.php @@ -121,7 +121,7 @@ if(isset($aClean['sSubmit'])) $hResult = query_parameters($sQuery, $sSearch, $sSearch, $aClean['sOrderBy'], $aClean['iLimit']); $i=0; - while($hResult && $oRow = mysql_fetch_object($hResult)) + while($hResult && $oRow = query_fetch_object($hResult)) { $oUser = new User($oRow->userid); $sAreYouSure = "Are you sure that you want to delete user ".addslashes($oUser->sRealname)." ?"; diff --git a/admin/editBundle.php b/admin/editBundle.php index c7e289a..cb45429 100644 --- a/admin/editBundle.php +++ b/admin/editBundle.php @@ -11,7 +11,7 @@ function build_app_list() $hResult = query_parameters("SELECT appId, appName FROM appFamily ORDER BY appName"); echo "\n"; echo " \n"; echo "\n\n"; -if($hResult && mysql_num_rows($hResult)) +if($hResult && query_num_rows($hResult)) { $c = 1; - while($oRow = mysql_fetch_object($hResult)) + while($oRow = query_fetch_object($hResult)) { //set row color if ($c % 2 == 1) { $bgcolor = 'color0'; } else { $bgcolor = 'color1'; } @@ -72,7 +72,7 @@ if($hResult && mysql_num_rows($hResult)) $c++; } -} else if($hResult && !mysql_num_rows($hResult)) +} else if($hResult && !query_num_rows($hResult)) { /* indicate to the user that there are no apps in this bundle at the moment */ echo "\n"; diff --git a/admin/maintainerNotification.php b/admin/maintainerNotification.php index e078ca4..423b306 100644 --- a/admin/maintainerNotification.php +++ b/admin/maintainerNotification.php @@ -15,7 +15,7 @@ $hResult = maintainer::objectGetEntries(false, false); echo "Maintainers with a non-zero notification level
\n"; $bFoundNonZero = false; -while($oRow = mysql_fetch_object($hResult)) +while($oRow = query_fetch_object($hResult)) { $oMaintainer = new maintainer(null, $oRow); @@ -41,7 +41,7 @@ echo "
\n"; // retrieve all of the maintainers echo "Maintainers with notification iTargetLevel != 0
\n"; $hResult = maintainer::objectGetEntries(false, false); -while($oRow = mysql_fetch_object($hResult)) +while($oRow = query_fetch_object($hResult)) { $oMaintainer = new maintainer(null, $oRow); diff --git a/admin/moveAppVersion.php b/admin/moveAppVersion.php index daa69c6..e99478d 100644 --- a/admin/moveAppVersion.php +++ b/admin/moveAppVersion.php @@ -47,7 +47,7 @@ if(!empty($aClean['sAction'])) $sQuery.= "on appVersion.appId = appFamily.appId ORDER BY appFamily.appName, appFamily.appId, appVersion.versionName;"; $hResult = query_parameters($sQuery); $currentAppId = 0; - while($oRow = mysql_fetch_object($hResult)) + while($oRow = query_fetch_object($hResult)) { /* if the version ids differ then we should start a row with a new application */ /* and the version that matches with it */ diff --git a/appview.php b/appview.php index 272f4ca..b5e20f3 100644 --- a/appview.php +++ b/appview.php @@ -37,7 +37,7 @@ function display_bundle($iAppId) $hResult = query_parameters("SELECT appFamily.appId, appName, description FROM appBundle, appFamily ". "WHERE appFamily.queued='false' AND bundleId = '?' AND appBundle.appId = appFamily.appId", $iAppId); - if(!$hResult || mysql_num_rows($hResult) == 0) + if(!$hResult || query_num_rows($hResult) == 0) { return; // do nothing } @@ -51,7 +51,7 @@ function display_bundle($iAppId) echo "\n\n"; $c = 0; - while($ob = mysql_fetch_object($hResult)) + while($ob = query_fetch_object($hResult)) { $oApp = new application($ob->appId); //set row color diff --git a/browse_downloadable.php b/browse_downloadable.php index d80a9bc..0125f84 100644 --- a/browse_downloadable.php +++ b/browse_downloadable.php @@ -37,8 +37,8 @@ else $hResult = query_parameters($sQuery, "downloadurl", $sLicense); } -if($hResult && mysql_num_rows($hResult)) - $num = mysql_num_rows($hResult); +if($hResult && query_num_rows($hResult)) + $num = query_num_rows($hResult); $iNumPages = isset($num) ? ceil($num/$aClean['iNumVersions']) : 0; @@ -108,7 +108,7 @@ if(!$sLicense) $aClean['iNumVersions']); } -if($hResult && mysql_num_rows($hResult)) +if($hResult && query_num_rows($hResult)) { echo html_frame_start("", "90%"); @@ -127,7 +127,7 @@ if($hResult && mysql_num_rows($hResult)) $oTableRow->SetClass("color4"); $oTable->AddRow($oTableRow); - for($iIndex = 1; $oRow = mysql_fetch_object($hResult); $iIndex++) + for($iIndex = 1; $oRow = query_fetch_object($hResult); $iIndex++) { $oVersion = new version($oRow->versionId); diff --git a/cron/cleanup.php b/cron/cleanup.php index 69a9a5c..b16a1cc 100644 --- a/cron/cleanup.php +++ b/cron/cleanup.php @@ -52,7 +52,7 @@ function inactiveUserCheck() $hUsersToWarn = unwarnedAndInactiveSince(6); if($hUsersToWarn) { - while($oRow = mysql_fetch_object($hUsersToWarn)) + while($oRow = query_fetch_object($hUsersToWarn)) { $oUser = new User($oRow->userid); @@ -73,7 +73,7 @@ function inactiveUserCheck() $hUsersToDelete = warnedSince(1); if($hUsersToDelete) { - while($oRow = mysql_fetch_object($hUsersToDelete)) + while($oRow = query_fetch_object($hUsersToDelete)) { $oUser = new User($oRow->userid); if(!$oUser->hasDataAssociated()) @@ -179,11 +179,11 @@ function orphanVersionCheck() $sMsg.= "this sql command '".$sQuery."'\r\n"; /* don't report anything if no orphans are found */ - if(mysql_num_rows($hResult) == 0) + if(query_num_rows($hResult) == 0) return; $sMsg .= "versionId/name\r\n"; - while($oRow = mysql_fetch_object($hResult)) + while($oRow = query_fetch_object($hResult)) { $sMsg .= $oRow->versionId."/".$oRow->versionName."\r\n"; } @@ -209,7 +209,7 @@ function orphanSessionMessagesCheck() $sQuery = "SELECT count(*) as cnt from sessionMessages where TO_DAYS(NOW()) - TO_DAYS(time) > ?"; $hResult = query_parameters($sQuery, $iSessionMessageDayLimit); - $oRow = mysql_fetch_object($hResult); + $oRow = query_fetch_object($hResult); $iMessages = $oRow->cnt; $sMsg = "Found ".$iMessages." that have been orphaned in the sessionMessages table for longer than ".$iSessionMessageDayLimit." days\r\n"; @@ -237,7 +237,7 @@ function orphanSessionListCheck() $sQuery = "SELECT count(*) as cnt from session_list where TO_DAYS(NOW()) - TO_DAYS(stamp) > ?"; $hResult = query_parameters($sQuery, SESSION_DAYS_TO_EXPIRE + 2); - $oRow = mysql_fetch_object($hResult); + $oRow = query_fetch_object($hResult); $iMessages = $oRow->cnt; $sMsg = "Found ".$iMessages." sessions that have expired after ".(SESSION_DAYS_TO_EXPIRE + 2)." days\r\n"; @@ -272,7 +272,7 @@ function getMissingScreenshotArray() $hResult = Screenshot::objectGetEntries(false, false); // go through each screenshot - while($oRow = mysql_fetch_object($hResult)) + while($oRow = query_fetch_object($hResult)) { $iScreenshotId = $oRow->id; $oScreenshot = new Screenshot($iScreenshotId); diff --git a/include/appData.php b/include/appData.php index 58bd46f..4737ffc 100644 --- a/include/appData.php +++ b/include/appData.php @@ -37,7 +37,7 @@ class appData if(!$oRow) { $hResult = query_parameters("SELECT * FROM appData WHERE id = '?'", $iId); - $oRow = mysql_fetch_object($hResult); + $oRow = query_fetch_object($hResult); } if($oRow) @@ -126,7 +126,7 @@ class appData ORDER BY appData.id", $iUserId, $bQueued ? "true" : "false"); - if(!$hResult || !mysql_num_rows($hResult)) + if(!$hResult || !query_num_rows($hResult)) return false; $sReturn = html_table_begin("width=\"100%\" align=\"center\""); @@ -137,7 +137,7 @@ class appData "Submission Date"), "color4"); - for($i = 1; $oRow = mysql_fetch_object($hResult); $i++) + for($i = 1; $oRow = query_fetch_object($hResult); $i++) { if($oRow->versionId) { @@ -180,7 +180,7 @@ class appData versionId = '?' AND TYPE = '?' AND queued = '?'", $iAppId, $iVersionId, $sType, $sQueued); - if(!$hResult || !mysql_num_rows($hResult)) + if(!$hResult || !query_num_rows($hResult)) return FALSE; return $hResult; @@ -297,7 +297,7 @@ class appData if(!$hResult) return FALSE; - for($iCount = 0; $oRow = mysql_fetch_object($hResult);) + for($iCount = 0; $oRow = query_fetch_object($hResult);) $iCount += $oRow->count; return $iCount; diff --git a/include/appdb.php b/include/appdb.php index 532cb8c..51bd8e8 100644 --- a/include/appdb.php +++ b/include/appdb.php @@ -6,9 +6,9 @@ function log_category_visit($catId) $result = query_parameters("SELECT * FROM catHitStats WHERE ip = '?' AND catId = '?'", $REMOTE_ADDR, $catId); - if($result && mysql_num_rows($result) == 1) + if($result && query_num_rows($result) == 1) { - $oStatsRow = mysql_fetch_object($result); + $oStatsRow = query_fetch_object($result); query_parameters("UPDATE catHitStats SET count = count + 1 WHERE catHitId = '?'", $oStatsRow->catHitId); } else @@ -25,9 +25,9 @@ function log_application_visit($appId) $result = query_parameters("SELECT * FROM appHitStats WHERE ip = '?' AND appId = '?'", $REMOTE_ADDR, $appId); - if($result && mysql_num_rows($result) == 1) + if($result && query_num_rows($result) == 1) { - $stats = mysql_fetch_object($result); + $stats = query_fetch_object($result); query_parameters("UPDATE appHitStats SET count = count + 1 WHERE appHitId = '?'", $stats->appHitId); } else diff --git a/include/application.php b/include/application.php index 04c7d6e..d5f26d3 100644 --- a/include/application.php +++ b/include/application.php @@ -56,7 +56,7 @@ class Application { FROM appFamily WHERE appId = '?'"; if($hResult = query_parameters($sQuery, $iAppId)) - $oRow = mysql_fetch_object($hResult); + $oRow = query_fetch_object($hResult); } if($oRow) @@ -89,7 +89,7 @@ class Application { } if($hResult) { - while($oRow = mysql_fetch_object($hResult)) + while($oRow = query_fetch_object($hResult)) { $this->aVersionsIds[] = $oRow->versionId; } @@ -132,7 +132,7 @@ class Application { $this->mustBeQueued() ? "true" : "false"); if($hResult) { - $this->iAppId = mysql_insert_id(); + $this->iAppId = query_appdb_insert_id(); $this->application($this->iAppId); $this->SendNotificationMail(); // Only administrators will be mailed as no supermaintainers exist for this app. @@ -246,7 +246,7 @@ class Application { //FIXME: how to deal with concurrency issues such as // if a new version was added during this deletion? $hResult = $this->_internal_retrieve_all_versions(); - while($oRow = mysql_fetch_object($hResult)) + while($oRow = query_fetch_object($hResult)) { $iVersionId = $oRow->versionId; $oVersion = new Version($iVersionId); @@ -263,7 +263,7 @@ class Application { if($hResult = query_parameters($sQuery, $this->iAppId)) { - while($oRow = mysql_fetch_object($hResult)) + while($oRow = query_fetch_object($hResult)) { $aUrlsIds[] = $oRow->id; } @@ -315,9 +315,9 @@ class Application { /* Unqueue matching super maintainer request */ $hResultMaint = query_parameters("SELECT maintainerId FROM appMaintainers WHERE userId = '?' AND appId = '?'", $this->iSubmitterId, $this->iAppId); - if($hResultMaint && mysql_num_rows($hResultMaint)) + if($hResultMaint && query_num_rows($hResultMaint)) { - $oMaintainerRow = mysql_fetch_object($hResultMaint); + $oMaintainerRow = query_fetch_object($hResultMaint); $oMaintainer = new Maintainer($oMaintainerRow->maintainerId); $oMaintainer->unQueue("OK"); } @@ -420,7 +420,7 @@ class Application { if($hResult = query_parameters($sQuery, $sRating)) { - $oRow = mysql_fetch_object($hResult); + $oRow = query_fetch_object($hResult); } return $oRow->total; } @@ -436,7 +436,7 @@ class Application { if($hResult = query_parameters($sQuery, $sRating, $iOffset, $iItemsPerPage)) { - while($aRow = mysql_fetch_row($hResult)) + while($aRow = query_fetch_row($hResult)) { array_push($aApps, $aRow[0]); } @@ -764,9 +764,9 @@ class Application { if(!$appId) return null; $result = query_parameters("SELECT appName FROM appFamily WHERE appId = '?'", $appId); - if(!$result || mysql_num_rows($result) != 1) + if(!$result || query_num_rows($result) != 1) return null; - $ob = mysql_fetch_object($result); + $ob = query_fetch_object($result); return $ob->appName; } @@ -781,7 +781,7 @@ class Application { queued = '?' ORDER BY appId", $iUserId, $bQueued ? "true" : "false"); - if(!$hResult || !mysql_num_rows($hResult)) + if(!$hResult || !query_num_rows($hResult)) return false; $oTable = new Table(); @@ -796,7 +796,7 @@ class Application { $oTableRow->SetClass("color4"); $oTable->SetHeader($oTableRow); - for($i = 1; $oRow = mysql_fetch_object($hResult); $i++) + for($i = 1; $oRow = query_fetch_object($hResult); $i++) { $oVendor = new vendor($oRow->vendorId); @@ -1013,7 +1013,7 @@ class Application { if(!$hResult) return FALSE; - if(!$oRow = mysql_fetch_object($hResult)) + if(!$oRow = query_fetch_object($hResult)) return FALSE; return $oRow->count; diff --git a/include/application_queue.php b/include/application_queue.php index 5a503c2..b99dbd2 100644 --- a/include/application_queue.php +++ b/include/application_queue.php @@ -30,7 +30,7 @@ class application_queue $hResult = query_parameters($sQuery, $this->oApp->iAppId); if($hResult) { - if($oRow = mysql_fetch_object($hResult)) + if($oRow = query_fetch_object($hResult)) $iVersionId = $oRow->versionId; } } @@ -230,7 +230,7 @@ class application_queue return FALSE; /* There's no point in displaying an empty table */ - if($hResult === null ||mysql_num_rows($hResult) == 0) + if($hResult === null || (query_num_rows($hResult) == 0)) { echo "No matches.
\n"; return; @@ -256,7 +256,7 @@ class application_queue echo "
Application Name Delete
"; echo html_tr($aHeader, "color4"); - for($i = 0; $oRow = mysql_fetch_object($hResult); $i++) + for($i = 0; $oRow = query_fetch_object($hResult); $i++) { $oApp = new application($oRow->appId); $aCells = array( diff --git a/include/bugs.php b/include/bugs.php index ce26712..eea8a78 100644 --- a/include/bugs.php +++ b/include/bugs.php @@ -39,7 +39,7 @@ class Bug { AND linkid = '?'"; if($hResult = query_parameters($sQuery, $iLinkId)) { - $oRow = mysql_fetch_object($hResult); + $oRow = query_fetch_object($hResult); $this->iLinkId = $iLinkId; $this->iAppId = $oRow->appId; $this->iBug_id = $oRow->bug_id; @@ -55,7 +55,7 @@ class Bug { WHERE bug_id = ".$this->iBug_id; if($hResult = query_bugzilladb($sQuery)) { - $oRow = mysql_fetch_object($hResult); + $oRow = query_fetch_object($hResult); $this->sShort_desc = $oRow->short_desc; $this->sBug_status = $oRow->bug_status; $this->sResolution = $oRow->resolution; @@ -95,7 +95,7 @@ class Bug { $sQuery = "SELECT * FROM bugs WHERE bug_id = ".$this->iBug_id; - if(mysql_num_rows(query_bugzilladb($sQuery, "checking bugzilla")) == 0) + if(query_num_rows(query_bugzilladb($sQuery, "checking bugzilla")) == 0) { addmsg("There is no bug in Bugzilla with that bug number.", "red"); return false; @@ -108,7 +108,7 @@ class Bug { WHERE versionId = '?'"; if($hResult = query_parameters($sQuery, $this->iVersionId)) { - while($oRow = mysql_fetch_object($hResult)) + while($oRow = query_fetch_object($hResult)) { if($oRow->bug_id == $this->iBug_id) { @@ -129,7 +129,7 @@ class Bug { $this->bQueued ? "true":"false"); if($hResult) { - $this->iLinkId = mysql_insert_id(); + $this->iLinkId = query_bugzilla_insert_id(); $this->SendNotificationMail(); @@ -259,7 +259,7 @@ class Bug { { $hResult = query_parameters("SELECT appFamily.appName, buglinks.versionId, appVersion.versionName, buglinks.submitTime, buglinks.bug_id FROM buglinks, appFamily, appVersion WHERE appFamily.appId = appVersion.appId AND buglinks.versionId = appVersion.versionId AND buglinks.queued = '?' AND buglinks.submitterId = '?' ORDER BY buglinks.versionId", $bQueued ? "true" : "false", $iUserId); - if(!$hResult || !mysql_num_rows($hResult)) + if(!$hResult || !query_num_rows($hResult)) return FALSE; $sReturn = html_table_begin("width=\"100%\" align=\"center\""); @@ -272,7 +272,7 @@ class Bug { "Submit time"), "color4"); - for($i = 1; $oRow = mysql_fetch_object($hResult); $i++) + for($i = 1; $oRow = query_fetch_object($hResult); $i++) { $oBug = new Bug($oRow->bug_id); $sReturn .= html_tr(array( diff --git a/include/category.php b/include/category.php index c6d7d9d..c91dd0e 100644 --- a/include/category.php +++ b/include/category.php @@ -31,7 +31,7 @@ class Category { WHERE catId = '?' ORDER BY catName;"; if($hResult = query_parameters($sQuery, $iCatId)) { - $oRow = mysql_fetch_object($hResult); + $oRow = query_fetch_object($hResult); if($oRow) { $this->iCatId = $iCatId; @@ -50,7 +50,7 @@ class Category { AND queued = 'false' ORDER BY appName"; if($hResult = query_parameters($sQuery, $iCatId)) { - while($oRow = mysql_fetch_object($hResult)) + while($oRow = query_fetch_object($hResult)) { $this->aApplicationsIds[] = $oRow->appId; } @@ -64,7 +64,7 @@ class Category { WHERE catParent = '?' ORDER BY catName;"; if($hResult = query_parameters($sQuery, $iCatId)) { - while($oRow = mysql_fetch_object($hResult)) + while($oRow = query_fetch_object($hResult)) { $this->aSubcatsIds[] = $oRow->catId; } @@ -83,7 +83,7 @@ class Category { $sName, $sDescription, $iParentId); if($hResult) { - $this->iCatId = mysql_insert_id(); + $this->iCatId = query_appdb_insert_id(); $this->category($this->iCatId); return true; } @@ -171,9 +171,9 @@ class Category { { $hResult = query_parameters("SELECT catName, catId, catParent FROM appCategory WHERE catId = '?'", $iCatId); - if(!$hResult || mysql_num_rows($hResult) != 1) + if(!$hResult || query_num_rows($hResult) != 1) break; - $oCatRow = mysql_fetch_object($hResult); + $oCatRow = query_fetch_object($hResult); $aPath[] = array($oCatRow->catId, $oCatRow->catName); $iCatId = $oCatRow->catParent; } diff --git a/include/comment.php b/include/comment.php index 1144b5d..4e9ffe5 100644 --- a/include/comment.php +++ b/include/comment.php @@ -36,7 +36,7 @@ class Comment { WHERE appComments.versionId = appVersion.versionId AND commentId = '?'"; $hResult = query_parameters($sQuery, $iCommentId); - $oRow = mysql_fetch_object($hResult); + $oRow = query_fetch_object($hResult); $this->iCommentId = $oRow->commentId; $this->iParentId = $oRow->parentId; $this->iAppId = $oRow->appId; @@ -68,7 +68,7 @@ class Comment { if($hResult) { - $this->comment(mysql_insert_id()); + $this->comment(query_appdb_insert_id()); $sEmail = User::get_notify_email_address_list($this->iAppId, $this->iVersionId); $sEmail .= $this->oOwner->sEmail." "; @@ -203,7 +203,7 @@ class Comment { $hResult = query_parameters($sQuery, $iVersionId); if(!$hResult) return 0; - $oRow = mysql_fetch_object($hResult); + $oRow = query_fetch_object($hResult); return $oRow->cnt; } @@ -275,8 +275,8 @@ class Comment { } /* escape input so we can use query_appdb() without concern */ - $iVersionId = mysql_real_escape_string($iVersionId); - $iParentId = mysql_real_escape_string($iParentId); + $iVersionId = query_escape_string($iVersionId); + $iParentId = query_escape_string($iParentId); $sExtra = ""; @@ -300,11 +300,11 @@ class Comment { */ function do_display_comments_nested($hResult) { - while($oRow = mysql_fetch_object($hResult)) + while($oRow = query_fetch_object($hResult)) { Comment::view_app_comment($oRow); $hResult2 = Comment::grab_comments($oRow->versionId, $oRow->commentId); - if($hResult && mysql_num_rows($hResult2)) + if($hResult && query_num_rows($hResult2)) { echo "
\n"; Comment::do_display_comments_nested($hResult2); @@ -328,7 +328,7 @@ class Comment { if (!$is_main) echo "
    \n"; - while ($oRow = mysql_fetch_object($hResult)) + while ($oRow = query_fetch_object($hResult)) { if ($is_main) { @@ -340,7 +340,7 @@ class Comment { } $hResult2 = Comment::grab_comments($oRow->versionId, $oRow->commentId); - if ($hResult2 && mysql_num_rows($hResult2)) + if ($hResult2 && query_num_rows($hResult2)) { echo "
    \n"; Comment::do_display_comments_threaded($hResult2, 0); @@ -367,7 +367,7 @@ class Comment { $hResult = Comment::grab_comments($versionId); if ($hResult) { - while($oRow = mysql_fetch_object($hResult)) + while($oRow = query_fetch_object($hResult)) { Comment::view_app_comment($oRow); } @@ -380,7 +380,7 @@ class Comment { // count posts $hResult = query_parameters("SELECT commentId FROM appComments WHERE versionId = '?'", $versionId); - $messageCount = mysql_num_rows($hResult); + $messageCount = query_num_rows($hResult); //start comment format table echo html_frame_start("","98%",'',0); diff --git a/include/distribution.php b/include/distribution.php index 4f92dcc..3c49062 100644 --- a/include/distribution.php +++ b/include/distribution.php @@ -30,7 +30,7 @@ class distribution { FROM distributions WHERE distributionId = '?'"; if($hResult = query_parameters($sQuery, $iDistributionId)) - $oRow = mysql_fetch_object($hResult); + $oRow = query_fetch_object($hResult); } if($oRow) @@ -69,7 +69,7 @@ class distribution { if($hResult = query_parameters($sQuery, $this->iDistributionId)) { - while($oRow = mysql_fetch_object($hResult)) + while($oRow = query_fetch_object($hResult)) { $this->aTestingIds[] = $oRow->testingId; } @@ -85,9 +85,9 @@ class distribution { WHERE name = '?'"; $hResult = query_parameters($sQuery, $this->sName); - if($hResult && $oRow = mysql_fetch_object($hResult)) + if($hResult && $oRow = query_fetch_object($hResult)) { - if(mysql_num_rows($hResult)) + if(query_num_rows($hResult)) { addmsg("There was an existing distribution called ".$this->sName.".", "red"); $this->distribution($oRow->distributionId); @@ -108,7 +108,7 @@ class distribution { $this->mustBeQueued() ? "true" : "false"); if($hResult) { - $this->iDistributionId = mysql_insert_id(); + $this->iDistributionId = query_appdb_insert_id(); $this->distribution($this->iDistributionId); $this->SendNotificationMail(); return true; @@ -397,7 +397,7 @@ class distribution { if($hResult) { - $oRow = mysql_fetch_object($hResult); + $oRow = query_fetch_object($hResult); return $oRow->num_dists; } return 0; @@ -414,7 +414,7 @@ class distribution { echo "id\" ". @@ -146,7 +146,7 @@ class downloadurl "downloadurl", $aValues["iVersionId"]))) return FALSE; - if(!($oRow = mysql_fetch_object($hResult))) + if(!($oRow = query_fetch_object($hResult))) return FALSE; $num = $oRow->num; @@ -157,7 +157,7 @@ class downloadurl if(!$hResult = appData::getData($aValues["iVersionId"], "downloadurl")) return FALSE; - while($oRow = mysql_fetch_object($hResult)) + while($oRow = query_fetch_object($hResult)) { $oDownloadurl = new downloadurl($oRow->id); @@ -258,7 +258,7 @@ class downloadurl $hResult = appData::getData($iVersionId, "downloadurl", TRUE, TRUE, TRUE)) { - $oRow = mysql_fetch_object($hResult); + $oRow = query_fetch_object($hResult); $sDownloadUrlUrl = $oRow->url; $sDownloadUrlDescription = $oRow->description; } @@ -305,7 +305,7 @@ class downloadurl "NOW()", $_SESSION['current']->iUserId); - $this->iId = mysql_insert_id(); + $this->iId = query_appdb_insert_id(); if(!$hResult) return FALSE; @@ -339,7 +339,7 @@ class downloadurl $iId = null; if($hResult = appData::getData($iVersionId, "downloadurl", TRUE, TRUE)) { - $oObject = mysql_fetch_object($hResult); + $oObject = query_fetch_object($hResult); $iId = $oObject->id; } diff --git a/include/error_log.php b/include/error_log.php index 18799a3..1bbbd0f 100644 --- a/include/error_log.php +++ b/include/error_log.php @@ -47,7 +47,7 @@ class error_log { $sQuery = "SELECT count(*) as cnt FROM error_log WHERE deleted = '0'"; $hResult = query_parameters($sQuery); - $oRow = mysql_fetch_object($hResult); + $oRow = query_fetch_object($hResult); return $oRow->cnt; } @@ -70,7 +70,7 @@ class error_log $hResult = query_parameters($sQuery); $bEmpty = false; - if(mysql_num_rows($hResult) == 0) + if(query_num_rows($hResult) == 0) $bEmpty = true; $sMsg = "Log entries:\r\n"; @@ -82,7 +82,7 @@ class error_log $sMsg.="----------------------------------\r\n\r\n"; /* append each log entry to $sMsg */ - while($oRow = mysql_fetch_object($hResult)) + while($oRow = query_fetch_object($hResult)) { $sMsg.=$oRow->submitTime." ".$oRow->userid." ".$oRow->type."\r\n"; $sMsg.= "---------------------\r\n"; diff --git a/include/incl.php b/include/incl.php index 43bda9d..3d0183e 100644 --- a/include/incl.php +++ b/include/incl.php @@ -28,12 +28,12 @@ if(get_magic_quotes_gpc()) echo "if magic quotes is enabled. "; echo "Ooooooh you say.
    "; echo "\"Aren't magic quotes a convienent way to protect my php code from sql injection attacks?\"

    "; - echo "No! addslashes() isn't adequate. You should use mysql_real_escape_string() or some other function"; + echo "No! addslashes() isn't adequate. You should use query_escape_string() or some other function"; echo " that will handle multi-byte characters. See this article"; echo " for a way to exploit addslash()ed parameters.

    "; - echo "A second reason is that with magic quotes enabled, due to the use of mysql_real_escape_string() to"; + echo "A second reason is that with magic quotes enabled, due to the use of query_escape_string() to"; echo " protect from sql injection attacks we'll end up with variables that have been addslash()ed and"; - echo " mysql_real_escape_string()ed. So you end up having to call stripslashes() on EVERY variable. "; + echo " query_escape_string()ed. So you end up having to call stripslashes() on EVERY variable. "; exit; } @@ -250,25 +250,16 @@ function pHttpDate($sDate) { /** * msgs will be displayed on the Next page view of the same user */ -function addmsg($text, $color = "black") +function addmsg($shText, $color = "black") { - global $hAppdbLink; - - if(!is_resource($hAppdbLink)) - { - // The last argument makes sure we are really opening a new connection - $hAppdbLink = mysql_connect(APPS_DBHOST, APPS_DBUSER, APPS_DBPASS,true); - mysql_select_db(APPS_DB, $hAppdbLink); - } - if($color) - $text = " $text \n"; + $shText = " $shText \n"; $sQuery = "INSERT INTO sessionMessages VALUES (null, ?, '?', '?')"; - if (!query_parameters($sQuery, "NOW()", session_id(), $text)) + if (!query_parameters($sQuery, "NOW()", session_id(), $shText)) { echo "An error has occurred in addmsg()"; - echo $text; + echo $shText; } } @@ -289,7 +280,7 @@ function dumpmsgbuffer() if(!$hResult) return; - while($oRow = mysql_fetch_object($hResult)) + while($oRow = query_fetch_object($hResult)) { echo html_frame_start("","300","",5); echo "
    $oRow->message
    "; diff --git a/include/maintainer.php b/include/maintainer.php index e2c62e6..4769d02 100644 --- a/include/maintainer.php +++ b/include/maintainer.php @@ -62,7 +62,7 @@ class queuedEntries // this application or unqueued versions depending on which user we were $hResult = $oApp->_internal_retrieve_all_versions(); - while($oVersionRow = mysql_fetch_object($hResult)) + while($oVersionRow = query_fetch_object($hResult)) { if($bDebugOutputEnabled) { @@ -108,7 +108,7 @@ class queuedEntries $hResult = query_parameters($sQuery, $iVersionId, "true"); // go through the test results looking for the oldest queued data - while($oTestingRow = mysql_fetch_object($hResult)) + while($oTestingRow = query_fetch_object($hResult)) { if($bDebugOutputEnabled) echo "\tQueued TestData found\n"; @@ -124,7 +124,7 @@ class queuedEntries // queued screenshots $sQuery = "select * from appData where type = 'screenshot' and versionId = '?' and queued = '?'"; $hResult = query_parameters($sQuery, $iVersionId, "true"); - while($oScreenshotRow = mysql_fetch_object($hResult)) + while($oScreenshotRow = query_fetch_object($hResult)) { $oScreenshot = new Screenshot(null, $oScreenshotRow); @@ -187,7 +187,7 @@ class maintainer $sQuery = "SELECT * FROM appMaintainers WHERE maintainerId = '?'"; $hResult = query_parameters($sQuery, $iMaintainerId); if($hResult) - $oRow = mysql_fetch_object($hResult); + $oRow = query_fetch_object($hResult); } if($oRow) @@ -219,8 +219,8 @@ class maintainer $this->iUserId, $this->sMaintainReason, $this->bSuperMaintainer, "NOW()", $this->mustBeQueued() ? "true" : "false"); - /* this objects id is the insert id returned by mysql */ - $this->iMaintainerId = mysql_insert_id(); + /* this objects id is the insert id returned by the database */ + $this->iMaintainerId = query_appdb_insert_id(); /* If this is a non-queued maintainer submission, remove the user's non- super maintainer entries for the application's versions. This check is @@ -469,7 +469,7 @@ class maintainer $hResult = query_parameters($sQuery, $oUser->iUserId, $bSuperMaintainer ? "1" : "0", "false"); if(!$hResult) return 0; - $oRow = mysql_fetch_object($hResult); + $oRow = query_fetch_object($hResult); return $oRow->cnt; } @@ -483,12 +483,12 @@ class maintainer "appFamily, appMaintainers WHERE appFamily.appId = appMaintainers.appId ". "AND userId = '?' AND appMaintainers.queued = '?' ORDER BY appName", $oUser->iUserId, "false"); - if(!$hResult || mysql_num_rows($hResult) == 0) + if(!$hResult || query_num_rows($hResult) == 0) return NULL; $aAppsMaintained = array(); $c = 0; - while($oRow = mysql_fetch_object($hResult)) + while($oRow = query_fetch_object($hResult)) { $aAppsMaintained[$c] = array($oRow->appId, $oRow->versionId, $oRow->superMaintainer); $c++; @@ -528,7 +528,7 @@ class maintainer $bQueued ? "true" : "false"))) return FALSE; - for($iCount = 0; $oRow = mysql_fetch_object($hResult);) + for($iCount = 0; $oRow = query_fetch_object($hResult);) $iCount += $oRow->count; return $iCount; @@ -539,7 +539,7 @@ class maintainer { $sQuery = "SELECT count(*) as maintainers FROM appMaintainers where queued='false'"; $hResult = query_parameters($sQuery); - $oRow = mysql_fetch_object($hResult); + $oRow = query_fetch_object($hResult); return $oRow->maintainers; } @@ -547,7 +547,7 @@ class maintainer function getNumberOfMaintainers() { $hResult = query_parameters("SELECT DISTINCT userId FROM appMaintainers WHERE queued='false';"); - return mysql_num_rows($hResult); + return query_num_rows($hResult); } function isUserMaintainer($oUser, $iVersionId = null) @@ -570,7 +570,7 @@ class maintainer if(!$hResult) return false; - return mysql_num_rows($hResult); + return query_num_rows($hResult); } function isUserSuperMaintainer($oUser, $iAppId = null) @@ -586,7 +586,7 @@ class maintainer } if(!$hResult) return false; - return mysql_num_rows($hResult); + return query_num_rows($hResult); } /* if given an appid or a version id return a handle for a query that has */ @@ -637,7 +637,7 @@ class maintainer $hResult = query_parameters($sQuery, $iAppId, "false"); $aUserIds = array(); $c = 0; - while($oRow = mysql_fetch_object($hResult)) + while($oRow = query_fetch_object($hResult)) { $aUserIds[$c] = $oRow->userId; $c++; @@ -1182,10 +1182,10 @@ class maintainer // retrieve all of the maintainers $hResult = maintainer::objectGetEntries(false, false); - // echo "Processing ".mysql_num_rows($hResult)." maintainers\n"; + // echo "Processing ".query_num_rows($hResult)." maintainers\n"; // notify this user, the maintainer, of queued data, if any exists - while($oRow = mysql_fetch_object($hResult)) + while($oRow = query_fetch_object($hResult)) { $oMaintainer = new maintainer(null, $oRow); $oMaintainer->notifyMaintainerOfQueuedData(); diff --git a/include/monitor.php b/include/monitor.php index d9779d9..47c8b06 100644 --- a/include/monitor.php +++ b/include/monitor.php @@ -30,7 +30,7 @@ class Monitor { FROM appMonitors WHERE monitorId = '".$iMonitorId."'"; $hResult = query_appdb($sQuery); - $oRow = mysql_fetch_object($hResult); + $oRow = query_fetch_object($hResult); } if($oRow) @@ -51,7 +51,7 @@ class Monitor { WHERE userId = '".$iUserId."' AND versionId = '".$iVersionId."'"; $hResult = query_appdb($sQuery); - if( $oRow = mysql_fetch_object($hResult) ) + if( $oRow = query_fetch_object($hResult) ) { $this->iMonitorId = $oRow->monitorId; $this->iAppId = $oRow->appId; @@ -83,7 +83,7 @@ class Monitor { if($hResult) { - $this->Monitor(mysql_insert_id()); + $this->Monitor(query_appdb_insert_id()); $sWhatChanged = "New monitor\n\n"; $this->SendNotificationMail("add", $sWhatChanged); return true; @@ -228,7 +228,7 @@ class Monitor { if(!$hResult) return FALSE; - $oRow = mysql_fetch_object($hResult); + $oRow = query_fetch_object($hResult); if(!$oRow) return FALSE; @@ -247,12 +247,12 @@ class Monitor { { $hResult = query_parameters("SELECT appId, versionId FROM appMonitors WHERE userId = '?'", $oUser->iUserId); - if(!$hResult || mysql_num_rows($hResult) == 0) + if(!$hResult || query_num_rows($hResult) == 0) return NULL; $aVersionsMonitored = array(); - for($i = 0; $oRow = mysql_fetch_object($hResult); $i++) + for($i = 0; $oRow = query_fetch_object($hResult); $i++) $aVersionsMonitored[$i] = array($oRow->appId, $oRow->versionId); return $aVersionsMonitored; diff --git a/include/note.php b/include/note.php index 9f7ceb4..5514b6b 100644 --- a/include/note.php +++ b/include/note.php @@ -31,7 +31,7 @@ class Note { { $sQuery = "SELECT * FROM appNotes WHERE noteId = '?'"; if($hResult = query_parameters($sQuery, $iNoteId)) - $oRow = mysql_fetch_object($hResult); + $oRow = query_fetch_object($hResult); } if($oRow) @@ -64,7 +64,7 @@ class Note { if($hResult) { - $this->note(mysql_insert_id()); + $this->note(query_appdb_insert_id()); $sWhatChanged = "Description is:\n".$this->shDescription.".\n\n"; $this->SendNotificationMail("add", $sWhatChanged); return true; diff --git a/include/objectManager.php b/include/objectManager.php index a165fdd..aafe797 100644 --- a/include/objectManager.php +++ b/include/objectManager.php @@ -114,7 +114,7 @@ class ObjectManager } /* did we get any entries? */ - if(!$hResult || mysql_num_rows($hResult) == 0) + if(!$hResult || query_num_rows($hResult) == 0) { switch($this->getQueueString($this->bIsQueue, $this->bIsRejected)) { @@ -142,7 +142,7 @@ class ObjectManager $this->outputHeader("color4"); /* output each entry */ - for($iCount = 0; $oRow = mysql_fetch_object($hResult); $iCount++) + for($iCount = 0; $oRow = query_fetch_object($hResult); $iCount++) { $oObject = new $this->sClass(null, $oRow); @@ -392,7 +392,7 @@ class ObjectManager "Move here"), "color4"); - for($i = 0; $oRow = mysql_fetch_object($hResult); $i++) + for($i = 0; $oRow = query_fetch_object($hResult); $i++) { $oCandidate = new $this->sClass(null, $oRow); if($oCandidate->objectGetId() == $this->iId) diff --git a/include/query.php b/include/query.php index 5d31c37..1392fa3 100644 --- a/include/query.php +++ b/include/query.php @@ -4,14 +4,14 @@ $hBugzillaLink = null; define("MYSQL_DEADLOCK_ERRNO", 1213); -function query_appdb($sQuery,$sComment="") +function query_appdb($sQuery, $sComment="") { global $hAppdbLink; if(!is_resource($hAppdbLink)) { // The last argument makes sure we are really opening a new connection - $hAppdbLink = mysql_connect(APPS_DBHOST, APPS_DBUSER, APPS_DBPASS,true); + $hAppdbLink = mysql_connect(APPS_DBHOST, APPS_DBUSER, APPS_DBPASS, true); mysql_select_db(APPS_DB, $hAppdbLink); } @@ -77,7 +77,7 @@ function query_parameters() if(!is_resource($hAppdbLink)) { // The last argument makes sure we are really opening a new connection - $hAppdbLink = mysql_connect(APPS_DBHOST, APPS_DBUSER, APPS_DBPASS,true); + $hAppdbLink = mysql_connect(APPS_DBHOST, APPS_DBUSER, APPS_DBPASS, true); mysql_select_db(APPS_DB, $hAppdbLink); } @@ -159,4 +159,61 @@ function query_error($sQuery, $sComment="") $bInQueryError = false; // clear variable upon exit } +function query_fetch_row($hResult) +{ + return mysql_fetch_row($hResult); +} + +function query_fetch_object($hResult) +{ + return mysql_fetch_object($hResult); +} + +function query_appdb_insert_id() +{ + global $hAppdbLink; + return mysql_insert_id($hAppdbLink); +} + +function query_bugzilla_insert_id() +{ + global $hBugzillaLink; + return mysql_insert_id($hBugzillaLink); +} + +function query_num_rows($hResult) +{ + return mysql_num_rows($hResult); +} + +function query_escape_string($sString) +{ + return mysql_real_escape_string($sString); +} + +function query_field_type($hResult, $iFieldOffset) +{ + return mysql_field_type($hResult, $iFieldOffset); +} + +function query_field_name($hResult, $iFieldOffset) +{ + return mysql_field_name($hResult, $iFieldOffset); +} + +function query_field_len($hResult, $ifieldOffset) +{ + return mysql_field_len($hResult, $iFieldOffset); +} + +function query_field_flags($hResult, $iFieldOffset) +{ + return mysql_field_flags($hResult, $iFieldOffset); +} + +function query_fetch_field($hResult, $iFieldOffset) +{ + return mysql_fetch_field($hResult, $iFieldOffset); +} + ?> diff --git a/include/screenshot.php b/include/screenshot.php index 0897e74..bc0265f 100644 --- a/include/screenshot.php +++ b/include/screenshot.php @@ -47,7 +47,7 @@ class screenshot AND id = '?' AND type = 'screenshot'", $iScreenshotId); if($hResult) - $oRow = mysql_fetch_object($hResult); + $oRow = query_fetch_object($hResult); } if($oRow) @@ -80,7 +80,7 @@ class screenshot $_SESSION['current']->iUserId); if($hResult) { - $this->iScreenshotId = mysql_insert_id(); + $this->iScreenshotId = query_appdb_insert_id(); /* make sure we supply the full path to move_uploaded_file() */ $moveToPath = appdb_fullpath("data/screenshots/originals/").$this->iScreenshotId; @@ -432,12 +432,12 @@ class screenshot if($bFormatting) $sImgFile .= '
    '; - if(!$hResult || !mysql_num_rows($hResult)) + if(!$hResult || !query_num_rows($hResult)) { $sImgFile.= 'No Screenshot'; } else { - $oRow = mysql_fetch_object($hResult); + $oRow = query_fetch_object($hResult); $sImgFile.= ''.$oRow->description.''; } @@ -451,7 +451,7 @@ class screenshot $sZoomIcon = Screenshot::get_zoomicon_overlay(); /* we have screenshots */ - if(mysql_num_rows($hResult)) + if(query_num_rows($hResult)) { if($iVersionId) $sImg .= "".$sImgFile.$sZoomIcon."
    View/Submit Screenshot
    "; diff --git a/include/session.php b/include/session.php index a3913d4..6bc7b32 100644 --- a/include/session.php +++ b/include/session.php @@ -2,7 +2,7 @@ /* * session.php - session handler functions - * sessions are stored in a mysql table + * sessions are stored in a database table */ /* the number of days a session cookie is flaged to last */ @@ -72,7 +72,7 @@ class session { $result = query_parameters("SELECT data FROM session_list WHERE session_id = '?'", $key); if (!$result) { return null; } - $oRow = mysql_fetch_object($result); + $oRow = query_fetch_object($result); if($oRow) return $oRow->data; else diff --git a/include/tableve.php b/include/tableve.php index 3c46fb6..2781679 100644 --- a/include/tableve.php +++ b/include/tableve.php @@ -20,19 +20,19 @@ class TableVE { function test($query) { $hResult = query_appdb($query); - $nfields = mysql_num_fields($hResult); - $nrows = mysql_num_rows($hResult); - $table = mysql_field_table($hResult, 0); + $nfields = query_num_fields($hResult); + $nrows = query_num_rows($hResult); + $table = query_field_table($hResult, 0); echo "Table: $table
    Fields: $nfields
    Rows: $nrows

    \n"; $i = 0; while($i < $nfields) { - $type = mysql_field_type($hResult, $i); - $name = mysql_field_name($hResult, $i); - $len = mysql_field_len($hResult, $i); - $flags = mysql_field_flags($hResult, $i); + $type = query_field_type($hResult, $i); + $name = query_field_name($hResult, $i); + $len = query_field_len($hResult, $i); + $flags = query_field_flags($hResult, $i); echo "$type | $name | $len | $flags
    \n"; $i++; @@ -46,7 +46,7 @@ class TableVE { function create($query, $table, $idcolumn) { $hResult = query_appdb($query); - $id = mysql_insert_id(); + $id = query_appdb_insert_id(); $new_query = "SELECT * FROM $table WHERE $idcolumn = $id"; $this->edit($new_query); @@ -60,7 +60,7 @@ class TableVE { $nrows = 0; $hResult = query_appdb($query); - $nrows = mysql_num_rows($hResult); + $nrows = query_num_rows($hResult); if(debugging()) { @@ -76,8 +76,8 @@ class TableVE { function view_entry($hResult, $num) { - $nfields = mysql_num_fields($hResult); - $fields = mysql_fetch_array($hResult, MYSQL_BOTH); + $nfields = query_num_fields($hResult); + $fields = query_fetch_array($hResult, MYSQL_BOTH); $titleValue = $fields[$this->titleField]; $titleText = $this->titleText; @@ -98,7 +98,7 @@ class TableVE { for($i = 0; $i < $nfields; $i++) { - $field = mysql_fetch_field($hResult, $i); + $field = query_fetch_field($hResult, $i); if(ereg("^impl_(.+)$", $field->table, $arr)) { @@ -121,7 +121,7 @@ class TableVE { function edit($query) { $hResult = query_appdb($query); - $nrows = mysql_num_rows($hResult); + $nrows = query_num_rows($hResult); echo "
    \n"; @@ -141,8 +141,8 @@ class TableVE { function edit_entry($hResult) { - $nfields = mysql_num_fields($hResult); - $fields = mysql_fetch_array($hResult); + $nfields = query_num_fields($hResult); + $fields = query_fetch_array($hResult); echo html_frame_start(ucfirst($this->mode),"80%","",0); echo "
\n"; @@ -151,8 +151,8 @@ class TableVE { for($i = 0; $i < $nfields; $i++) { global $testvar; - $field = mysql_fetch_field($hResult, $i); - $len = mysql_field_len($hResult, $i); + $field = query_fetch_field($hResult, $i); + $len = query_field_len($hResult, $i); if(ereg("^impl_(.+)$", $field->table, $arr)) { @@ -189,7 +189,7 @@ class TableVE { $sStr.= "id\" ". @@ -360,7 +360,7 @@ class Url { return FALSE; } - if(!($oRow = mysql_fetch_object($hResult))) + if(!($oRow = query_fetch_object($hResult))) return FALSE; $num = $oRow->num; @@ -378,7 +378,7 @@ class Url { return FALSE; } - while($oRow = mysql_fetch_object($hResult)) + while($oRow = query_fetch_object($hResult)) { $url = new url($oRow->id); @@ -485,7 +485,7 @@ class Url { return FALSE; } - for($i = 0; $oRow = mysql_fetch_object($hResult); $i++) + for($i = 0; $oRow = query_fetch_object($hResult); $i++) { // create a url object $oUrl = new Url(null, $oRow); diff --git a/include/user.php b/include/user.php index 2532e20..b30dee3 100644 --- a/include/user.php +++ b/include/user.php @@ -40,7 +40,7 @@ class User { FROM user_list WHERE userId = '?'"; $hResult = query_parameters($sQuery, $iUserId); - $oRow = mysql_fetch_object($hResult); + $oRow = query_fetch_object($hResult); if($oRow) { $this->iUserId = $oRow->userid; @@ -81,7 +81,7 @@ class User { { $hResult = query_parameters($sQuery.$sMysqlSHAPasswordPart, $sEmail, $sPassword); - $oRow = mysql_fetch_object($hResult); + $oRow = query_fetch_object($hResult); } // if we aren't logged in yet @@ -90,7 +90,7 @@ class User { { $hResult = query_parameters($sQuery.$sMysqlPasswordPart, $sEmail, $sPassword); - $oRow = mysql_fetch_object($hResult); + $oRow = query_fetch_object($hResult); if($oRow) $bUsedOldStylePassword = true; } @@ -107,7 +107,7 @@ class User { { $hResult = query_parameters($sQuery.$sMysql40xPasswordPart, $sEmail, $sPassword); - $oRow = mysql_fetch_object($hResult); + $oRow = query_fetch_object($hResult); if($oRow) $bUsedOldStylePassword = true; } } @@ -265,9 +265,9 @@ class User { $hResult = query_parameters("SELECT * FROM user_prefs WHERE userid = '?' AND name = '?'", $this->iUserId, $sKey); - if(!$hResult || mysql_num_rows($hResult) == 0) + if(!$hResult || query_num_rows($hResult) == 0) return $sDef; - $oRow = mysql_fetch_object($hResult); + $oRow = query_fetch_object($hResult); return $oRow->value; } @@ -300,7 +300,7 @@ class User { $this->iUserId, $sPriv); if(!$hResult) return false; - return mysql_num_rows($hResult); + return query_num_rows($hResult); } @@ -373,7 +373,7 @@ class User { WHERE submitterId = '?' AND appId = '?'", $this->iUserId, $iAppId); - if(mysql_num_rows($hResult)) + if(query_num_rows($hResult)) return true; else return false; @@ -386,7 +386,7 @@ class User { AND appVersion.submitterId = '?' AND appVersion.versionId = '?'", $this->iUserId, $iVersionId); - if(mysql_num_rows($hResult)) + if(query_num_rows($hResult)) return true; else return false; @@ -398,7 +398,7 @@ class User { { $hResult = query_parameters("SELECT count(userId) as c FROM appComments WHERE userId = '?'", $this->iUserId); - $oRow = mysql_fetch_object($hResult); + $oRow = query_fetch_object($hResult); if($oRow->c != 0) return true; if($this->isMaintainer() || $this->isSuperMaintainer()) @@ -406,7 +406,7 @@ class User { $hResult = query_parameters("SELECT count(userId) as c FROM appVotes WHERE userId = '?'", $this->iUserId); - $oRow = mysql_fetch_object($hResult); + $oRow = query_fetch_object($hResult); if($oRow->c != 0) return true; return false; @@ -468,12 +468,12 @@ class User { { $hResult = query_parameters("SELECT userid FROM user_list WHERE email = '?'", $sEmail); - if(!$hResult || mysql_num_rows($hResult) != 1) + if(!$hResult || query_num_rows($hResult) != 1) { return 0; } else { - $oRow = mysql_fetch_object($hResult); + $oRow = query_fetch_object($hResult); return $oRow->userid; } } @@ -485,7 +485,7 @@ class User { function objectGetEntriesCount($bQueued = null, $bRejected = null) { $hResult = query_parameters("SELECT count(*) as num_users FROM user_list;"); - $oRow = mysql_fetch_object($hResult); + $oRow = query_fetch_object($hResult); return $oRow->num_users; } @@ -496,7 +496,7 @@ class User { { $hResult = query_parameters("SELECT count(*) as num_users FROM user_list WHERE stamp >= DATE_SUB(CURDATE(), interval '?' day);", $days); - $oRow = mysql_fetch_object($hResult); + $oRow = query_fetch_object($hResult); return $oRow->num_users; } @@ -508,7 +508,7 @@ class User { { /* retrieve the number of users that have been warned and are pending deletion */ $hResult = query_parameters("select count(*) as count from user_list where inactivity_warned = 'true'"); - $oRow = mysql_fetch_object($hResult); + $oRow = query_fetch_object($hResult); return $oRow->count; } @@ -527,9 +527,9 @@ class User { if($hResult) { - if(mysql_num_rows($hResult) > 0) + if(query_num_rows($hResult) > 0) { - while($oRow = mysql_fetch_object($hResult)) + while($oRow = query_fetch_object($hResult)) $aUserId[] = $oRow->userId; } } @@ -560,9 +560,9 @@ class User { } if($hResult) { - if(mysql_num_rows($hResult) > 0) + if(query_num_rows($hResult) > 0) { - while($oRow = mysql_fetch_object($hResult)) + while($oRow = query_fetch_object($hResult)) $aUserId[] = $oRow->userId; } } @@ -571,9 +571,9 @@ class User { * Retrieve administrators. */ $hResult = query_parameters("SELECT * FROM user_privs WHERE priv = 'admin'"); - if(mysql_num_rows($hResult) > 0) + if(query_num_rows($hResult) > 0) { - while($oRow = mysql_fetch_object($hResult)) + while($oRow = query_fetch_object($hResult)) { $i = array_search($oRow->userid, $aUserId); diff --git a/include/util.php b/include/util.php index aa2122b..59f348f 100644 --- a/include/util.php +++ b/include/util.php @@ -176,7 +176,7 @@ function make_bugzilla_version_list($sVarname, $sSelectedValue) // TODO: if we ever get a reasonable way to order the list replace this code // with that $aVersions = array(); - while(list($sValue) = mysql_fetch_row($hResult)) + while(list($sValue) = query_fetch_row($hResult)) { // exclude unspecified versions and the "CVS" version if(($sValue != "unspecified") && ($sValue != "CVS")) @@ -246,7 +246,7 @@ function make_maintainer_rating_list($varname, $cvalue) function getNumberOfComments() { $hResult = query_parameters("SELECT count(*) as num_comments FROM appComments;"); - $oRow = mysql_fetch_object($hResult); + $oRow = query_fetch_object($hResult); return $oRow->num_comments; } @@ -256,7 +256,7 @@ function getNumberOfQueuedBugLinks() $hResult = query_parameters("SELECT count(*) as num_buglinks FROM buglinks WHERE queued='true';"); if($hResult) { - $oRow = mysql_fetch_object($hResult); + $oRow = query_fetch_object($hResult); return $oRow->num_buglinks; } return 0; @@ -268,7 +268,7 @@ function getNumberOfBugLinks() $hResult = query_parameters("SELECT count(*) as num_buglinks FROM buglinks;"); if($hResult) { - $oRow = mysql_fetch_object($hResult); + $oRow = query_fetch_object($hResult); return $oRow->num_buglinks; } return 0; @@ -316,8 +316,8 @@ function outputTopXRow($oRow) function outputTopXRowAppsFromRating($sRating, $iNumApps) { /* clean the input values so we can continue to use query_appdb() */ - $sRating = mysql_real_escape_string($sRating); - $iNumApps = mysql_real_escape_string($iNumApps); + $sRating = query_escape_string($sRating); + $iNumApps = query_escape_string($iNumApps); /* list of versionIds we've already output, so we don't output */ /* them again when filling in any empty spots in the list */ @@ -331,8 +331,8 @@ function outputTopXRowAppsFromRating($sRating, $iNumApps) ORDER BY c DESC LIMIT ?"; $hResult = query_parameters($sQuery, $sRating, $iNumApps); - $iNumApps -= mysql_num_rows($hResult); /* take away the rows we are outputting here */ - while($oRow = mysql_fetch_object($hResult)) + $iNumApps -= query_num_rows($hResult); /* take away the rows we are outputting here */ + while($oRow = query_fetch_object($hResult)) { /* keep track of the apps we've already output */ $aVersionId[] = $oRow->versionId; @@ -358,7 +358,7 @@ function outputTopXRowAppsFromRating($sRating, $iNumApps) /* get the list that will fill the empty spots */ $hResult = query_appdb($sQuery); - while($oRow = mysql_fetch_object($hResult)) + while($oRow = query_fetch_object($hResult)) outputTopXRow($oRow); } @@ -457,13 +457,13 @@ function searchForApplication($search_words) $sQuery = "SELECT vendorId from vendor where vendorName LIKE '%?%' OR vendorURL LIKE '%?%'"; $hResult = query_parameters($sQuery, $value, $value); - while($oRow = mysql_fetch_object($hResult)) + while($oRow = query_fetch_object($hResult)) { array_push($vendorIdArray, $oRow->vendorId); } } - $search_words = str_replace(' ', '%', mysql_real_escape_string($search_words)); + $search_words = str_replace(' ', '%', query_escape_string($search_words)); /* base query */ $sQuery = "SELECT * @@ -477,7 +477,7 @@ function searchForApplication($search_words) /* append to the query any vendors that we matched with */ foreach($vendorIdArray as $key=>$value) { - $sQuery.=" OR appFamily.vendorId=".mysql_real_escape_string($value); + $sQuery.=" OR appFamily.vendorId=".query_escape_string($value); } $sQuery.=" ) ORDER BY appName"; @@ -497,7 +497,7 @@ function searchForApplicationFuzzy($search_words, $minMatchingPercent) /* add on all of the like matches that we can find */ $hResult = searchForApplication($search_words); - while($oRow = mysql_fetch_object($hResult)) + while($oRow = query_fetch_object($hResult)) { array_push($excludeAppIdArray, $oRow->appId); } @@ -506,7 +506,7 @@ function searchForApplicationFuzzy($search_words, $minMatchingPercent) $sQuery = "SELECT appName, appId FROM appFamily WHERE queued = 'false'"; foreach ($excludeAppIdArray as $key=>$value) { - $sQuery.=" AND appId != '".mysql_real_escape_string($value)."'"; + $sQuery.=" AND appId != '".query_escape_string($value)."'"; } $sQuery.=";"; @@ -514,7 +514,7 @@ function searchForApplicationFuzzy($search_words, $minMatchingPercent) $search_words = strtoupper($search_words); $hResult = query_appdb($sQuery); - while($oRow = mysql_fetch_object($hResult)) + while($oRow = query_fetch_object($hResult)) { $oRow->appName = strtoupper($oRow->appName); /* convert the appname to upper case */ similar_text($oRow->appName, $search_words, $similarity_pst); @@ -535,11 +535,11 @@ function searchForApplicationFuzzy($search_words, $minMatchingPercent) { if($firstEntry == true) { - $sQuery.="appId='".mysql_real_escape_string($value)."'"; + $sQuery.="appId='".query_escape_string($value)."'"; $firstEntry = false; } else { - $sQuery.=" OR appId='".mysql_real_escape_string($value)."'"; + $sQuery.=" OR appId='".query_escape_string($value)."'"; } } $sQuery.=" ORDER BY appName;"; @@ -550,7 +550,7 @@ function searchForApplicationFuzzy($search_words, $minMatchingPercent) function outputSearchTableForhResult($search_words, $hResult) { - if(($hResult == null) || (mysql_num_rows($hResult) == 0)) + if(($hResult == null) || (query_num_rows($hResult) == 0)) { // do something echo html_frame_start("","98%"); @@ -568,7 +568,7 @@ function outputSearchTableForhResult($search_words, $hResult) echo "\n\n"; $c = 0; - while($oRow = mysql_fetch_object($hResult)) + while($oRow = query_fetch_object($hResult)) { $oApp = new application($oRow->appId); //skip if a NONAME @@ -580,7 +580,7 @@ function outputSearchTableForhResult($search_words, $hResult) //count versions $hResult2 = query_parameters("SELECT count(*) as versions FROM appVersion WHERE appId = '?' AND versionName != 'NONAME' and queued = 'false'", $oRow->appId); - $y = mysql_fetch_object($hResult2); + $y = query_fetch_object($hResult2); //display row echo "\n"; diff --git a/include/vendor.php b/include/vendor.php index 82266b1..41105d8 100644 --- a/include/vendor.php +++ b/include/vendor.php @@ -31,7 +31,7 @@ class Vendor { FROM vendor WHERE vendorId = '?'"; if($hResult = query_parameters($sQuery, $iVendorId)) - $oRow = mysql_fetch_object($hResult); + $oRow = query_fetch_object($hResult); } if($oRow) @@ -50,7 +50,7 @@ class Vendor { WHERE vendorId = '?'"; if($hResult = query_parameters($sQuery, $this->iVendorId)) { - while($oRow = mysql_fetch_object($hResult)) + while($oRow = query_fetch_object($hResult)) { $this->aApplicationsIds[] = $oRow->appId; } @@ -71,9 +71,9 @@ class Vendor { /* Check for duplicates */ $hResult = query_parameters("SELECT * FROM vendor WHERE vendorName = '?'", $this->sName); - if($hResult && $oRow = mysql_fetch_object($hResult)) + if($hResult && $oRow = query_fetch_object($hResult)) { - if(mysql_num_rows($hResult)) + if(query_num_rows($hResult)) { $this->vendor($oRow->vendorId); @@ -89,7 +89,7 @@ class Vendor { $this->mustBeQueued() ? "true" : "false"); if($hResult) { - $this->iVendorId = mysql_insert_id(); + $this->iVendorId = query_appdb_insert_id(); $this->vendor($this->iVendorId); return true; } @@ -355,7 +355,7 @@ class Vendor { if(!$hResult) return FALSE; - if(!$oRow = mysql_fetch_object($hResult)) + if(!$oRow = query_fetch_object($hResult)) return FALSE; return $oRow->count; diff --git a/include/version.php b/include/version.php index cc6115b..3f4f75c 100644 --- a/include/version.php +++ b/include/version.php @@ -55,7 +55,7 @@ class version { FROM appVersion WHERE versionId = '?'"; if($hResult = query_parameters($sQuery, $iVersionId)) - $oRow = mysql_fetch_object($hResult); + $oRow = query_fetch_object($hResult); } if($oRow) @@ -96,7 +96,7 @@ class version { if($hResult) { - $this->iVersionId = mysql_insert_id(); + $this->iVersionId = query_appdb_insert_id(); $this->Version($this->iVersionId); $this->SendNotificationMail(); @@ -226,7 +226,7 @@ class version { WHERE versionId = '?'"; if($hResult = query_parameters($sQuery, $this->iVersionId)) { - while($oRow = mysql_fetch_object($hResult)) + while($oRow = query_fetch_object($hResult)) { $aNotesIds[] = $oRow->noteId; } @@ -247,7 +247,7 @@ class version { WHERE versionId = '?'"; if($hResult = query_parameters($sQuery, $this->iVersionId)) { - while($oRow = mysql_fetch_object($hResult)) + while($oRow = query_fetch_object($hResult)) { $aCommentsIds[] = $oRow->commentId; } @@ -269,7 +269,7 @@ class version { if($hResult = query_parameters($sQuery, $this->iVersionId)) { - while($oRow = mysql_fetch_object($hResult)) + while($oRow = query_fetch_object($hResult)) { if($oRow->type="image") $aScreenshotsIds[] = $oRow->id; @@ -307,7 +307,7 @@ class version { ORDER BY testingId"; if($hResult = query_parameters($sQuery, $this->iVersionId)) { - while($oRow = mysql_fetch_object($hResult)) + while($oRow = query_fetch_object($hResult)) { $aTestingIds[] = $oRow->testingId; } @@ -328,7 +328,7 @@ class version { ORDER BY monitorId"; if($hResult = query_parameters($sQuery, $this->iVersionId)) { - while($oRow = mysql_fetch_object($hResult)) + while($oRow = query_fetch_object($hResult)) { $aMonitorIds[] = $oRow->monitorId; } @@ -391,9 +391,9 @@ class version { appMaintainers WHERE userId = '?' AND versionId = '?'", $this->iSubmitterId, $this->iVersionId); - if($hResultMaint && mysql_num_rows($hResultMaint)) + if($hResultMaint && query_num_rows($hResultMaint)) { - $oMaintainerRow = mysql_fetch_object($hResultMaint); + $oMaintainerRow = query_fetch_object($hResultMaint); $oMaintainer = new Maintainer($oMaintainerRow->maintainerId); $oMaintainer->unQueue("OK"); } @@ -569,7 +569,7 @@ class version { ORDER BY bug_id"; if($hResult = query_parameters($sQuery, $this->iVersionId)) { - while($oRow = mysql_fetch_object($hResult)) + while($oRow = query_fetch_object($hResult)) { $aBuglinkIds[] = $oRow->linkId; } @@ -1014,7 +1014,7 @@ class version { $hNotes = query_parameters("SELECT noteId FROM appNotes WHERE versionId = '?'", $this->iVersionId); - while( $oRow = mysql_fetch_object($hNotes) ) + while( $oRow = query_fetch_object($hNotes) ) { $oNote = new Note($oRow->noteId); $oNote->display(); @@ -1029,9 +1029,9 @@ class version { if(!$versionId) return null; $result = query_parameters("SELECT versionName FROM appVersion WHERE versionId = '?'", $versionId); - if(!$result || mysql_num_rows($result) != 1) + if(!$result || query_num_rows($result) != 1) return null; - $ob = mysql_fetch_object($result); + $ob = query_fetch_object($result); return $ob->versionName; } @@ -1046,10 +1046,10 @@ class version { AND versionId = '?'", $iVersionId); - if(!$hResult || !mysql_num_rows($hResult)) + if(!$hResult || !query_num_rows($hResult)) return FALSE; - $oRow = mysql_fetch_object($hResult); + $oRow = query_fetch_object($hResult); return "$oRow->appName $oRow->versionName"; } @@ -1183,7 +1183,7 @@ class version { $hResult = Maintainer::getMaintainersForAppIdVersionId(null, $this->iVersionId); $iCount = 0; - while($oRow = mysql_fetch_object($hResult)) + while($oRow = query_fetch_object($hResult)) { $aMaintainers[$iCount] = $oRow->userId; $iCount++; @@ -1197,7 +1197,7 @@ class version { { $hResult = query_parameters("SELECT appFamily.appName, appVersion.versionName, appVersion.description, appVersion.versionId, appVersion.submitTime FROM appFamily, appVersion WHERE appFamily.appId = appVersion.appId AND appVersion.submitterId = '?' AND appVersion.queued = '?' AND appFamily.queued = '?'", $iUserId, $bQueued ? "true" : "false", "false"); - if(!$hResult || !mysql_num_rows($hResult)) + if(!$hResult || !query_num_rows($hResult)) return false; $oTable = new Table(); @@ -1212,7 +1212,7 @@ class version { $oTableRow->SetClass("color4"); $oTable->SetHeader($oTableRow); - for($i = 1; $oRow = mysql_fetch_object($hResult); $i++) + for($i = 1; $oRow = query_fetch_object($hResult); $i++) { $oTableRow = new TableRow(); $oTableRow->AddTextCell(version::fullNameLink($oRow->versionId)); @@ -1343,7 +1343,7 @@ class version { if(!$hResult) return FALSE; - if(!$oRow = mysql_fetch_object($hResult)) + if(!$oRow = query_fetch_object($hResult)) return FALSE; return $oRow->count; @@ -1546,7 +1546,7 @@ class version { if(!$hResult) return FALSE; - while($oRow = mysql_fetch_object($hResult)) + while($oRow = query_fetch_object($hResult)) { $oTestData = new testData($oRow->testingId); $oTestData->iVersionId = $iNewId; @@ -1563,7 +1563,7 @@ class version { if(!$hResult) return FALSE; - while($oRow = mysql_fetch_object($hResult)) + while($oRow = query_fetch_object($hResult)) { $oAppData = new appData($oRow->testingId); $oAppData->iVersionId = $iNewId; diff --git a/include/version_queue.php b/include/version_queue.php index de3a0ed..6f625e1 100644 --- a/include/version_queue.php +++ b/include/version_queue.php @@ -27,7 +27,7 @@ class version_queue $hResult = appData::getData($iVersionId, "downloadurl", TRUE, TRUE, TRUE)) { - if($oRow = mysql_fetch_object($hResult)) + if($oRow = query_fetch_object($hResult)) $iDownloadUrlId = $oRow->id; } } diff --git a/include/vote.php b/include/vote.php index 506cbd1..cf3d9ec 100644 --- a/include/vote.php +++ b/include/vote.php @@ -17,7 +17,7 @@ function vote_count($iVersionId, $iUserId = null) } $hResult = query_parameters("SELECT * FROM appVotes WHERE versionId = '?' AND userId = '?'", $iVersionId, $iUserId); - return mysql_num_rows($hResult); + return query_num_rows($hResult); } @@ -34,7 +34,7 @@ function vote_count_user_total($iUserId = null) return 0; } $hResult = query_parameters("SELECT * FROM appVotes WHERE userId = '?'", $iUserId); - return mysql_num_rows($hResult); + return query_num_rows($hResult); } @@ -45,7 +45,7 @@ function vote_count_version_total($iVersionId) { $hResult = query_parameters("SELECT * FROM appVotes WHERE versionId = '?'", $iVersionId); - return mysql_num_rows($hResult); + return query_num_rows($hResult); } @@ -105,7 +105,7 @@ function vote_get_user_votes($iUserId = null) return array(); $obs = array(); - while($oRow = mysql_fetch_object($hResult)) + while($oRow = query_fetch_object($hResult)) $obs[$oRow->slot] = $oRow; return $obs; } @@ -198,7 +198,7 @@ function is_vote_in_slot($iSlot, $iUserId = null) $sQuery = "SELECT COUNT(*) as count from appVotes WHERE userId = '?' AND slot = '?'"; if($hResult = query_parameters($sQuery, $iUserId, $iSlot)) { - $oRow = mysql_fetch_object($hResult); + $oRow = query_fetch_object($hResult); if($oRow->count != 0) return true; else diff --git a/index.php b/index.php index 9888e16..5ead491 100644 --- a/index.php +++ b/index.php @@ -62,7 +62,7 @@ if(!$_SESSION['current']->isLoggedIn()) "FROM appVotes ". "GROUP BY versionId ORDER BY count DESC LIMIT 1"; $hResult = query_parameters($voteQuery); - $oRow = mysql_fetch_object($hResult); + $oRow = query_fetch_object($hResult); echo "There are $iNumApps applications currently in the database"; diff --git a/preferences.php b/preferences.php index 13d773d..743cff9 100644 --- a/preferences.php +++ b/preferences.php @@ -32,7 +32,7 @@ function build_prefs_list($oUser) $aTableRows = array(); $hResult = query_parameters("SELECT * FROM prefs_list ORDER BY id"); - while($hResult && $r = mysql_fetch_object($hResult)) + while($hResult && $r = query_fetch_object($hResult)) { // skip admin options if(!$_SESSION['current']->hasPriv("admin")) diff --git a/screenshots.php b/screenshots.php index 042f783..dd47c40 100644 --- a/screenshots.php +++ b/screenshots.php @@ -60,7 +60,7 @@ apidb_header("Screenshots"); $oApp = new Application($aClean['iAppId']); $oVersion = new Version($aClean['iVersionId']); -if($hResult && mysql_num_rows($hResult)) +if($hResult && query_num_rows($hResult)) { echo html_frame_start("Screenshot Gallery for ".$oApp->sName." ".$oVersion->sName,500); @@ -72,7 +72,7 @@ if($hResult && mysql_num_rows($hResult)) $bUserIsMaintainerOfVersion = false; echo "
\n"; - while($oRow = mysql_fetch_object($hResult)) + while($oRow = query_fetch_object($hResult)) { // if the current version changed then update the current version // and close the previous html frame if this isn't the diff --git a/unit_test/run_tests.php b/unit_test/run_tests.php index 5a60378..74ec659 100644 --- a/unit_test/run_tests.php +++ b/unit_test/run_tests.php @@ -117,7 +117,7 @@ class table_counts { $sQuery = "select count(*) as cnt from ?;"; $hResult = query_parameters($sQuery, $sTable); - $oRow = mysql_fetch_object($hResult); + $oRow = query_fetch_object($hResult); $this->aTableCounts[] = $oRow->cnt; } diff --git a/unit_test/test_application.php b/unit_test/test_application.php index 91c8571..d899480 100644 --- a/unit_test/test_application.php +++ b/unit_test/test_application.php @@ -62,7 +62,7 @@ function test_application_delete() if($hResult = query_parameters($sQuery, $iAppId)) { - $iRows = mysql_num_rows($hResult); + $iRows = query_num_rows($hResult); if($iRows > 0) { echo "Found '".$iRows."' versions for this application left over!"; diff --git a/unit_test/test_maintainer.php b/unit_test/test_maintainer.php index 57cf435..1332f88 100644 --- a/unit_test/test_maintainer.php +++ b/unit_test/test_maintainer.php @@ -555,7 +555,7 @@ function test_maintainer_getMaintainersForAppIdVersionId() /* The application should have one maintainer */ $iExpected = 1; - $iReceived = mysql_num_rows($hResult); + $iReceived = query_num_rows($hResult); if($iExpected != $iReceived) { error("Got super maintainer count of $iReceived instead of $iExpected!"); @@ -575,7 +575,7 @@ function test_maintainer_getMaintainersForAppIdVersionId() /* The version should have one maintainer */ $iExpected = 1; - $iReceived = mysql_num_rows($hResult); + $iReceived = query_num_rows($hResult); if($iExpected != $iReceived) { error("Got maintainer count of $iReceived instead of $iExpected!"); @@ -614,7 +614,7 @@ function test_maintainer_getMaintainersForAppIdVersionId() /* The first version should have one maintainer */ $iExpected = 1; - $iReceived = mysql_num_rows($hResult); + $iReceived = query_num_rows($hResult); if($iExpected != $iReceived) { error("Got maintainer count of $iReceived instead of $iExpected!"); @@ -634,7 +634,7 @@ function test_maintainer_getMaintainersForAppIdVersionId() /* The second version should have 1 maintainer */ $iExpected = 1; - $iReceived = mysql_num_rows($hResult); + $iReceived = query_num_rows($hResult); if($iExpected != $iReceived) { error("Got maintainer count of $iReceived instead of $iExpected!"); diff --git a/unit_test/test_maintainer_notify.php b/unit_test/test_maintainer_notify.php index 05261c4..1edbae1 100644 --- a/unit_test/test_maintainer_notify.php +++ b/unit_test/test_maintainer_notify.php @@ -130,7 +130,7 @@ class notifyContainer { $sQuery2 = "select * from appMaintainers where maintainerId = '?'"; $hResult = query_parameters($sQuery2, $this->oMaintainer->iMaintainerId); - $oObject = mysql_fetch_object($hResult); + $oObject = query_fetch_object($hResult); print_r($oObject); } @@ -317,7 +317,7 @@ function test_maintainer_notifyLevel_2_to_3($bTestAsMaintainer) // check to make sure the maintainer doesn't exist $sQuery = "select count(*) as cnt from appMaintainers where maintainerId = '?'"; $hResult = query_parameters($sQuery, $oNotifyContainer->oMaintainer->iMaintainerId); - $oRow = mysql_fetch_object($hResult); + $oRow = query_fetch_object($hResult); if($oRow->cnt != 0) { $bSuccess = false; diff --git a/unit_test/test_om_objects.php b/unit_test/test_om_objects.php index 0655c99..06ad4b2 100644 --- a/unit_test/test_om_objects.php +++ b/unit_test/test_om_objects.php @@ -54,15 +54,15 @@ function test_class($sClassName, $aTestMethods) if(!$hResult) { - error("Got '$hResult' instead of a valid MySQL handle"); + error("Got '$hResult' instead of a valid query handle"); error("FAILED\t\t$sClassName::$sClassName"); $oTestObject->delete(); return FALSE; } - if(!($oRow = mysql_fetch_object($hResult))) + if(!($oRow = query_fetch_object($hResult))) { - error("Failed to fetch MySQL object"); + error("Failed to fetch query object"); error("FAILED\t\t$sClassName::$sClassName"); $oTestObject->delete(); return FALSE; @@ -111,7 +111,7 @@ function test_class($sClassName, $aTestMethods) /* Should return 1 or more, since there may be entries present already */ $iExpected = 1; $hResult = $oTestObject->objectGetEntries(false, false); - $iReceived = mysql_num_rows($hResult); + $iReceived = query_num_rows($hResult); if($iExpected > $iReceived) { error("Got $iReceived instead of >= $iExpected"); @@ -223,7 +223,7 @@ function create_object($sClassName, $oUser) error("FAILED\t\t$sClassName to create screenshot entry"); return FALSE; } - $oTestObject->iScreenshotId = mysql_insert_id(); + $oTestObject->iScreenshotId = query_appdb_insert_id(); } return $oTestObject; diff --git a/unit_test/test_query.php b/unit_test/test_query.php index 69e89de..4ff08af 100644 --- a/unit_test/test_query.php +++ b/unit_test/test_query.php @@ -30,7 +30,7 @@ function test_query_parameters() return false; } - $oRow = mysql_fetch_object($hResult); + $oRow = query_fetch_object($hResult); $iUserCount = $oRow->count; /* see that '~' strings are replaced with parameters */ @@ -41,7 +41,7 @@ function test_query_parameters() $hResult = query_parameters($sQuery, "user_list", "1' OR 1='1"); if($hResult) { - $oRow = mysql_fetch_object($hResult); + $oRow = query_fetch_object($hResult); if($iUserCount != $oRow->count) { echo "sQuery of '".$sQuery."' returned ".$oRow->count." entries instead of the expected ".$iUserCount."\n"; @@ -88,7 +88,7 @@ function test_query_parameters() * properly with slashes in the query, they were incorrectly being recognized * as tokens that should be replaced with parameters */ - $sQuery = "SELECT count(*) as count, '".mysql_real_escape_string("\r\n")."' as x from ?"; + $sQuery = "SELECT count(*) as count, '".query_escape_string("\r\n")."' as x from ?"; $hResult = query_parameters($sQuery, "user_list"); if(!$hResult) { diff --git a/unit_test/test_user_password_migration.php b/unit_test/test_user_password_migration.php index af05b2e..78c1c3c 100644 --- a/unit_test/test_user_password_migration.php +++ b/unit_test/test_user_password_migration.php @@ -19,13 +19,13 @@ function test_user_password_migration() // generate the SHA1() of the users password $sQuery = "select SHA1('?') as password;"; $hResult = query_parameters($sQuery, $sTestPassword); - $oRow = mysql_fetch_object($hResult); + $oRow = query_fetch_object($hResult); $sTestUserPasswordSHA1 = $oRow->password; // test that the user was created with the sha1 hash of their password $sQuery = "select password from user_list where userid = '?';"; $hResult = query_parameters($sQuery, $oUser->iUserId); - $oRow = mysql_fetch_object($hResult); + $oRow = query_fetch_object($hResult); if($sTestUserPasswordSHA1 != $oRow->password) { error("sTestUserPasswordSHA1 $sTestUserPasswordSHA1 doesn't match oRow->password of $oRow->password after user::create()"); @@ -56,7 +56,7 @@ function test_user_password_migration() // after the user was logged in $sQuery = "select password from user_list where userid = '?';"; $hResult = query_parameters($sQuery, $oUser->iUserId); - $oRow = mysql_fetch_object($hResult); + $oRow = query_fetch_object($hResult); if($sTestUserPasswordSHA1 != $oRow->password) { error("sTestUserPasswordSHA1 $sTestUserPasswordSHA1 doesn't match oRow->password of $oRow->password"); diff --git a/viewScreenshots.php b/viewScreenshots.php index a69a8b0..474cc78 100644 --- a/viewScreenshots.php +++ b/viewScreenshots.php @@ -59,7 +59,7 @@ echo ""; $Ids = appData::objectGetEntries(false, false, $ItemsPerPage, $offset, "screenshot"); $c = 1; echo "
\n"; -while ($oRow = mysql_fetch_object($Ids)) +while ($oRow = query_fetch_object($Ids)) { // display thumbnail $oVersion = new version($oRow->versionId); diff --git a/viewbugs.php b/viewbugs.php index 9b1dcfc..dcb0c9f 100644 --- a/viewbugs.php +++ b/viewbugs.php @@ -42,14 +42,14 @@ if(!is_numeric($aClean['iBugId'])) if($hResult) { - while($oRow = mysql_fetch_object($hResult)) + while($oRow = query_fetch_object($hResult)) { $oApp = new application($oRow->appId); $oVersion = new version($oRow->versionId); $sDownloadUrls = ""; if($hDownloadUrls = appData::getData($oRow->versionId, "downloadurl")) { - while($oDownloadUrl = mysql_fetch_object($hDownloadUrls)) + while($oDownloadUrl = query_fetch_object($hDownloadUrls)) $sDownloadUrls .= "url\">". "$oDownloadUrl->description
"; } diff --git a/votestats.php b/votestats.php index 8fdb8a9..7d436bf 100644 --- a/votestats.php +++ b/votestats.php @@ -56,7 +56,7 @@ if(!empty($aClean['iCategoryId'])) if($hResult) { - $oRow = mysql_fetch_object($hResult); + $oRow = query_fetch_object($hResult); $catParent = $oRow->catParent; array_push($cat_array, "$currentCatId"); @@ -174,7 +174,7 @@ if($hResult) $oTable->AddRow($oTableRow); $c = 1; - while($oRow = mysql_fetch_object($hResult)) + while($oRow = query_fetch_object($hResult)) { $sColor = ($c % 2) ? "color0" : "color1";