From 67550405c35e1d29092973b4643137b6ea715217 Mon Sep 17 00:00:00 2001 From: Chris Morgan Date: Wed, 21 Jun 2006 01:04:12 +0000 Subject: [PATCH] Make code more consistent by making it follow the appdb coding standards. Fix some spaces vs. tabs odd indenting. --- addcomment.php | 14 +- admin/adminCommentView.php | 6 +- admin/adminMaintainerQueue.php | 58 ++-- admin/editAppFamily.php | 16 +- admin/editAppVersion.php | 16 +- admin/editBundle.php | 81 +++-- appview.php | 10 +- include/comment.php | 86 ++--- include/distributions.php | 16 +- include/incl.php | 8 +- include/maintainer.php | 24 +- include/tableve.php | 569 ++++++++++++++++----------------- include/user.php | 50 +-- include/util.php | 96 +++--- include/vendor.php | 4 +- include/vote.php | 20 +- index.php | 8 +- preferences.php | 4 +- votestats.php | 14 +- 19 files changed, 544 insertions(+), 556 deletions(-) diff --git a/addcomment.php b/addcomment.php index a54fa1c..ba14e30 100644 --- a/addcomment.php +++ b/addcomment.php @@ -58,14 +58,14 @@ else if($aClean['thread'] > 0) { - $result = query_appdb("SELECT * FROM appComments WHERE commentId = ".$aClean['thread']); - $ob = mysql_fetch_object($result); - if($ob) + $hResult = query_appdb("SELECT * FROM appComments WHERE commentId = ".$aClean['thread']); + $oRow = mysql_fetch_object($hResult); + if($oRow) { - $mesTitle = "Replying To ... $ob->subject\n"; - $originator = $ob->userId; - echo html_frame_start($ob->subject,500); - echo htmlify_urls($ob->body), "

\n"; + $mesTitle = "Replying To ... $oRow->subject\n"; + $originator = $oRow->userId; + echo html_frame_start($oRow->subject,500); + echo htmlify_urls($oRow->body), "

\n"; echo html_frame_end(); } } diff --git a/admin/adminCommentView.php b/admin/adminCommentView.php index 24c0e14..749ece8 100644 --- a/admin/adminCommentView.php +++ b/admin/adminCommentView.php @@ -64,12 +64,12 @@ $commentIds = query_appdb("SELECT commentId from appComments ORDER BY ". "appComments.time ASC LIMIT $offset, $ItemsPerPage;"); while ($ob = mysql_fetch_object($commentIds)) { - $qstring = "SELECT from_unixtime(unix_timestamp(time), \"%W %M %D %Y, %k:%i\") as time, ". + $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 = $ob->commentId;"; - $result = query_appdb($qstring); + $hResult = query_appdb($sQuery); /* call view_app_comment to display the comment */ - $comment_ob = mysql_fetch_object($result); + $comment_ob = mysql_fetch_object($hResult); view_app_comment($comment_ob); } diff --git a/admin/adminMaintainerQueue.php b/admin/adminMaintainerQueue.php index 5814d8b..d651cf9 100644 --- a/admin/adminMaintainerQueue.php +++ b/admin/adminMaintainerQueue.php @@ -30,14 +30,14 @@ if ($aClean['sub']) if ($aClean['queueId']) { //get data - $query = "SELECT queueId, appId, versionId,". + $sQuery = "SELECT queueId, appId, versionId,". "userId, maintainReason, superMaintainer,". "UNIX_TIMESTAMP(submitTime) as submitTime ". "FROM appMaintainerQueue WHERE queueId = ".$aClean['queueId'].";"; - $result = query_appdb($query); - $ob = mysql_fetch_object($result); - $oUser = new User($ob->userId); - mysql_free_result($result); + $hResult = query_appdb($sQuery); + $oRow = mysql_fetch_object($hResult); + $oUser = new User($oRow->userId); + mysql_free_result($hResult); } else { @@ -70,7 +70,7 @@ if ($aClean['sub']) $firstDisplay = true; /* if false we need to fix up table rows appropriately */ - $other_users = getMaintainersUserIdsFromAppIdVersionId($ob->versionId); + $other_users = getMaintainersUserIdsFromAppIdVersionId($oRow->versionId); if($other_users) { $foundMaintainers = true; @@ -88,7 +88,7 @@ if ($aClean['sub']) } } - $other_users = getSuperMaintainersUserIdsFromAppId($ob->appId); + $other_users = getSuperMaintainersUserIdsFromAppId($oRow->appId); if($other_users) { $foundMaintainers = true; @@ -115,7 +115,7 @@ if ($aClean['sub']) echo 'This user also maintains these apps:',"\n"; $firstDisplay = true; - $other_apps = getAppsFromUserId($ob->userId); + $other_apps = getAppsFromUserId($oRow->userId); if($other_apps) { while(list($index, list($appIdOther, $versionIdOther, $superMaintainerOther)) = each($other_apps)) @@ -142,8 +142,8 @@ if ($aClean['sub']) echo "User maintains no other applications\n"; } - $oApp = new Application($ob->appId); - $oVersion = new Version($ob->versionId); + $oApp = new Application($oRow->appId); + $oVersion = new Version($oRow->versionId); //app name echo 'App Name',"\n"; @@ -155,7 +155,7 @@ if ($aClean['sub']) //maintainReason echo 'Maintainer request reason',"\n"; - echo '',"\n"; + echo '',"\n"; //email response echo 'Email reply',"\n"; @@ -183,11 +183,11 @@ if ($aClean['sub']) else if ($aClean['add'] && $aClean['queueId']) { /* create a new user object for the maintainer */ - $maintainerUser = new User($ob->userId); + $maintainerUser = new User($oRow->userId); /* add the user as a maintainer and return the statusMessage */ - $statusMessage = $maintainerUser->addAsMaintainer($ob->appId, $ob->versionId, - $ob->superMaintainer, + $statusMessage = $maintainerUser->addAsMaintainer($oRow->appId, $oRow->versionId, + $oRow->superMaintainer, $aClean['queueId']); //done addmsg("

$statusMessage

", 'green'); @@ -197,8 +197,8 @@ if ($aClean['sub']) $sEmail = $oUser->sEmail; if ($sEmail) { - $oApp = new Application($ob->appId); - $oVersion = new Version($ob->versionId); + $oApp = new Application($oRow->appId); + $oVersion = new Version($oRow->versionId); $sSubject = "Application Maintainer Request Report"; $sMsg = "Your application to be the maintainer of ".$oApp->sName." ".$oVersion->sName." was rejected. "; $sMsg .= $aClean['replyText']; @@ -209,10 +209,10 @@ if ($aClean['sub']) } //delete main item - $query = "DELETE from appMaintainerQueue where queueId = ".$aClean['queueId'].";"; - $result = query_appdb($query,"unable to delete selected maintainer application"); + $sQuery = "DELETE from appMaintainerQueue where queueId = ".$aClean['queueId'].";"; + $hResult = query_appdb($sQuery,"unable to delete selected maintainer application"); echo html_frame_start("Delete maintainer application",400,"",0); - if($result) + if($hResult) { //success echo "

Maintainer application was successfully deleted from the Queue.

\n"; @@ -232,14 +232,14 @@ if ($aClean['sub']) echo '
',"\n"; //get available maintainers - $query = "SELECT queueId, appId, versionId,". + $sQuery = "SELECT queueId, appId, versionId,". "userId, maintainReason,". "superMaintainer,". "submitTime as submitTime ". "from appMaintainerQueue;"; - $result = query_appdb($query); + $hResult = query_appdb($sQuery); - if(!$result || !mysql_num_rows($result)) + if(!$hResult || !mysql_num_rows($hResult)) { //no apps in queue echo html_frame_start("","90%"); @@ -269,17 +269,17 @@ if ($aClean['sub']) echo "\n\n"; $c = 1; - while($ob = mysql_fetch_object($result)) + while($oRow = mysql_fetch_object($hResult)) { - $oUser = new User($ob->userId); - $oApp = new Application($ob->appId); - $oVersion = new Version($ob->versionId); + $oUser = new User($oRow->userId); + $oApp = new Application($oRow->appId); + $oVersion = new Version($oRow->versionId); if ($c % 2 == 1) { $bgcolor = 'color0'; } else { $bgcolor = 'color1'; } echo "\n"; - echo " ".print_date(mysqldatetime_to_unixtimestamp($ob->submitTime))."  \n"; + echo " ".print_date(mysqldatetime_to_unixtimestamp($oRow->submitTime))."  \n"; echo " ".$oApp->sName."\n"; - if($ob->superMaintainer) + if($oRow->superMaintainer) { echo "N/A\n"; echo "Yes\n"; @@ -290,7 +290,7 @@ if ($aClean['sub']) } echo " sEmail."\">".$oUser->sRealname."\n"; - echo " [queueId\">answer]\n"; + echo " [queueId\">answer]\n"; echo "\n\n"; $c++; } diff --git a/admin/editAppFamily.php b/admin/editAppFamily.php index c37953a..b3b7932 100644 --- a/admin/editAppFamily.php +++ b/admin/editAppFamily.php @@ -67,12 +67,12 @@ else echo '',"\n"; $i = 0; - $result = query_appdb("SELECT * FROM appData WHERE appId = $oApp->iAppId AND type = 'url' AND versionId = 0"); - if($result && mysql_num_rows($result) > 0) + $hResult = query_appdb("SELECT * FROM appData WHERE appId = $oApp->iAppId AND type = 'url' AND versionId = 0"); + if($hResult && mysql_num_rows($hResult) > 0) { echo '',"\n"; - while($ob = mysql_fetch_object($result)) + while($oRow = mysql_fetch_object($hResult)) { $temp0 = "adelete[".$i."]"; $temp1 = "adescription[".$i."]"; @@ -81,11 +81,11 @@ else $temp4 = "aOldDesc[".$i."]"; $temp5 = "aOldURL[".$i."]"; echo '',"\n"; - echo '',"\n"; - echo ''; - echo ''; - echo '',"\n"; + echo '',"\n"; + echo ''; + echo ''; + echo '',"\n"; $i++; } } else diff --git a/admin/editAppVersion.php b/admin/editAppVersion.php index 8f3e287..b3b00aa 100644 --- a/admin/editAppVersion.php +++ b/admin/editAppVersion.php @@ -59,12 +59,12 @@ if(!empty($aClean['submit'])) echo '
Delete',"\n"; echo 'DescriptionURL
',"\n"; - echo '
',"\n"; + echo '
',"\n"; $i = 0; - $result = query_appdb("SELECT * FROM appData WHERE versionId = ".$oVersion->iVersionId." AND type = 'url'"); - if($result && mysql_num_rows($result) > 0) + $hResult = query_appdb("SELECT * FROM appData WHERE versionId = ".$oVersion->iVersionId." AND type = 'url'"); + if($hResult && mysql_num_rows($hResult) > 0) { echo '',"\n"; - while($ob = mysql_fetch_object($result)) + while($oRow = mysql_fetch_object($hResult)) { $temp0 = "adelete[".$i."]"; $temp1 = "adescription[".$i."]"; @@ -73,11 +73,11 @@ if(!empty($aClean['submit'])) $temp4 = "aOldDesc[".$i."]"; $temp5 = "aOldURL[".$i."]"; echo '',"\n"; - echo '',"\n"; - echo ''; - echo ''; - echo '',"\n"; + echo '',"\n"; + echo ''; + echo ''; + echo '',"\n"; $i++; } } else diff --git a/admin/editBundle.php b/admin/editBundle.php index a3b2a39..9f259a9 100644 --- a/admin/editBundle.php +++ b/admin/editBundle.php @@ -11,13 +11,13 @@ if(!$_SESSION['current']->hasPriv("admin")) function build_app_list() { - $result = query_appdb("SELECT appId, appName FROM appFamily ORDER BY appName"); + $hResult = query_appdb("SELECT appId, appName FROM appFamily ORDER BY appName"); echo "\n"; } @@ -25,17 +25,17 @@ function build_app_list() if($cmd) { if($cmd == "delete") - { - $result = query_appdb("DELETE FROM appBundle WHERE appId = $appId AND bundleId = $bundleId"); - if($result) - addmsg("App deleted from bundle", "green"); - } + { + $hResult = query_appdb("DELETE FROM appBundle WHERE appId = $appId AND bundleId = $bundleId"); + if($hResult) + addmsg("App deleted from bundle", "green"); + } if($cmd == "add") - { - $result = query_appdb("INSERT INTO appBundle VALUES ($bundleId, $appId)"); - if($result) - addmsg("App $appId added to Bundle $bundleId", "green"); - } + { + $hResult = query_appdb("INSERT INTO appBundle VALUES ($bundleId, $appId)"); + if($hResult) + addmsg("App $appId added to Bundle $bundleId", "green"); + } redirectref(); exit; } @@ -43,39 +43,38 @@ else { apidb_header("Edit Application Bundle"); - $result = query_appdb("SELECT bundleId, appBundle.appId, appName FROM appBundle, appFamily ". - "WHERE bundleId = $bundleId AND appFamily.appId = appBundle.appId"); + $hResult = query_appdb("SELECT bundleId, appBundle.appId, appName FROM appBundle, appFamily ". + "WHERE bundleId = $bundleId AND appFamily.appId = appBundle.appId"); - if($result && mysql_num_rows($result)) - { - echo html_frame_start("Apps in this Bundle","300",'',0); - echo "
Delete',"\n"; echo 'DescriptionURL
',"\n"; - echo '
',"\n"; + echo '
\n\n"; + if($hResult && mysql_num_rows($hResult)) + { + echo html_frame_start("Apps in this Bundle","300",'',0); + echo "
\n\n"; - echo "\n"; - echo " \n"; - echo " \n"; - echo "\n\n"; + echo "\n"; + echo " \n"; + echo " \n"; + echo "\n\n"; - $c = 1; - while($ob = mysql_fetch_object($result)) - { - //set row color - if ($c % 2 == 1) { $bgcolor = 'color0'; } else { $bgcolor = 'color1'; } + $c = 1; + while($oRow = mysql_fetch_object($hResult)) + { + //set row color + if ($c % 2 == 1) { $bgcolor = 'color0'; } else { $bgcolor = 'color1'; } - $delete_link = "[delete]"; + $delete_link = "[delete]"; - echo "\n"; - echo " \n"; - echo " \n"; - echo "\n\n"; + echo "\n"; + echo " \n"; + echo " \n"; + echo "\n\n"; - $c++; - } + $c++; + } - echo "
Application Name Delete
Application Name Delete
$ob->appName  $delete_link  
$oRow->appName  $delete_link  
\n\n"; - echo html_frame_end(); - - } + echo "\n\n"; + echo html_frame_end(); + } echo "\n"; diff --git a/appview.php b/appview.php index d2714c5..3c4ef8a 100644 --- a/appview.php +++ b/appview.php @@ -47,9 +47,9 @@ function display_catpath($catId, $appId, $versionId = '') function display_bundle($appId) { $oApp = new Application($appId); - $result = query_appdb("SELECT appFamily.appId, appName, description FROM appBundle, appFamily ". + $hResult = query_appdb("SELECT appFamily.appId, appName, description FROM appBundle, appFamily ". "WHERE appFamily.queued='false' AND bundleId = $appId AND appBundle.appId = appFamily.appId"); - if(!$result || mysql_num_rows($result) == 0) + if(!$hResult || mysql_num_rows($hResult) == 0) { return; // do nothing } @@ -63,7 +63,8 @@ function display_bundle($appId) echo "\n\n"; $c = 0; - while($ob = mysql_fetch_object($result)) { + while($ob = mysql_fetch_object($hResult)) + { //set row color $bgcolor = ($c % 2 == 0) ? "color0" : "color1"; @@ -81,7 +82,8 @@ function display_bundle($appId) } /* Show note */ -function show_note($sType,$oData){ +function show_note($sType,$oData) +{ global $oVersion; switch($sType) diff --git a/include/comment.php b/include/comment.php index 8e2baa2..e4fc4c2 100644 --- a/include/comment.php +++ b/include/comment.php @@ -207,47 +207,47 @@ function forum_lookup_user($iUserId) } /** - * display a single comment (in $ob) + * display a single comment (in $oRow) */ -function view_app_comment($ob) +function view_app_comment($oRow) { echo html_frame_start('','98%'); echo '',"\n"; - $ob->subject = stripslashes($ob->subject); - $ob->body = stripslashes($ob->body); + $oRow->subject = stripslashes($oRow->subject); + $oRow->body = stripslashes($oRow->body); // message header - echo "\n"; // delete message button, for admins if ($_SESSION['current']->hasPriv("admin") - || $_SESSION['current']->isMaintainer($ob->versionId) - || $_SESSION['current']->isSuperMaintainer($ob->appId)) + || $_SESSION['current']->isMaintainer($oRow->versionId) + || $_SESSION['current']->isSuperMaintainer($oRow->appId)) { echo ""; echo ""; } @@ -273,9 +273,9 @@ function grab_comments($versionId, $parentId = -1) "FROM appComments, appVersion WHERE appComments.versionId = appVersion.versionId AND appComments.versionId = '$versionId' ". $extra. "ORDER BY appComments.time ASC"; - $result = query_appdb($qstring); + $hResult = query_appdb($qstring); - return $result; + return $hResult; } @@ -283,16 +283,16 @@ function grab_comments($versionId, $parentId = -1) * display nested comments * handle is a db result set */ -function do_display_comments_nested($handle) +function do_display_comments_nested($hResult) { - while($ob = mysql_fetch_object($handle)) + while($oRow = mysql_fetch_object($hResult)) { - view_app_comment($ob); - $result = grab_comments($ob->versionId, $ob->commentId); - if($result && mysql_num_rows($result)) + view_app_comment($oRow); + $hResult2 = grab_comments($oRow->versionId, $oRow->commentId); + if($hResult && mysql_num_rows($hResult2)) { echo "
\n"; - do_display_comments_nested($result); + do_display_comments_nested($hResult2); echo "
\n"; } } @@ -301,9 +301,9 @@ function do_display_comments_nested($handle) function display_comments_nested($versionId, $threadId) { - $result = grab_comments($versionId, $threadId); + $hResult = grab_comments($versionId, $threadId); - do_display_comments_nested($result); + do_display_comments_nested($hResult); } @@ -311,27 +311,27 @@ function display_comments_nested($versionId, $threadId) * display threaded comments * handle is a db result set */ -function do_display_comments_threaded($handle, $is_main) +function do_display_comments_threaded($hResult, $is_main) { if (!$is_main) echo "
commentId.">\n"; - echo " ".$ob->subject."
\n"; - echo " by ".forum_lookup_user($ob->userId)." on ".$ob->time."
\n"; + echo "
commentId.">\n"; + echo " ".$oRow->subject."
\n"; + echo " by ".forum_lookup_user($oRow->userId)." on ".$oRow->time."
\n"; echo "
\n"; // body - echo htmlify_urls($ob->body), "

\n"; + echo htmlify_urls($oRow->body), "

\n"; // only add RE: once - if(eregi("RE:", $ob->subject)) - $subject = $ob->subject; + if(eregi("RE:", $oRow->subject)) + $subject = $oRow->subject; else - $subject = "RE: ".$ob->subject; + $subject = "RE: ".$oRow->subject; // reply post buttons - echo " [appId&versionId=$ob->versionId\">post new] \n"; - echo " [appId&versionId=$ob->versionId&subject=". - urlencode("$subject")."&thread=$ob->commentId\">reply to this] \n"; + echo " [appId&versionId=$oRow->versionId\">post new] \n"; + echo " [appId&versionId=$oRow->versionId&subject=". + urlencode("$subject")."&thread=$oRow->commentId\">reply to this] \n"; echo "
\n"; - echo "commentId\" />"; + echo "commentId\" />"; echo "\n"; echo "
\n"; //echo "\n"; //echo "\n\n"; $c = 0; - while($ob = mysql_fetch_object($hResult)) + while($oRow = mysql_fetch_object($hResult)) { //skip if a NONAME - if ($ob->appName == "NONAME") { continue; } + if ($oRow->appName == "NONAME") { continue; } //set row color $bgcolor = ($c % 2) ? 'color0' : 'color1'; //count versions - $query = query_appdb("SELECT count(*) as versions FROM appVersion WHERE appId = $ob->appId AND versionName != 'NONAME' and queued = 'false'"); - $y = mysql_fetch_object($query); + $hResult2 = query_appdb("SELECT count(*) as versions FROM appVersion WHERE appId = $oRow->appId AND versionName != 'NONAME' and queued = 'false'"); + $y = mysql_fetch_object($hResult2); //display row echo "\n"; - echo " \n"; - echo " \n"; + echo " \n"; + echo " \n"; echo " \n"; echo "\n\n"; diff --git a/include/vendor.php b/include/vendor.php index 420b9c8..12e92b6 100644 --- a/include/vendor.php +++ b/include/vendor.php @@ -142,8 +142,8 @@ function getNumberOfVendors() $hResult = query_appdb("SELECT count(*) as num_vendors FROM vendor"); if($hResult) { - $row = mysql_fetch_object($hResult); - return $row->num_vendors; + $oRow = mysql_fetch_object($hResult); + return $oRow->num_vendors; } return 0; } diff --git a/include/vote.php b/include/vote.php index bc2ffa0..da8656a 100644 --- a/include/vote.php +++ b/include/vote.php @@ -17,8 +17,8 @@ function vote_count($appId, $userId = null) else return 0; } - $result = query_appdb("SELECT * FROM appVotes WHERE appId = $appId AND userId = $userId"); - return mysql_num_rows($result); + $hResult = query_appdb("SELECT * FROM appVotes WHERE appId = $appId AND userId = $userId"); + return mysql_num_rows($hResult); } @@ -34,8 +34,8 @@ function vote_count_user_total($userId = null) else return 0; } - $result = query_appdb("SELECT * FROM appVotes WHERE userId = $userId"); - return mysql_num_rows($result); + $hResult = query_appdb("SELECT * FROM appVotes WHERE userId = $userId"); + return mysql_num_rows($hResult); } @@ -44,8 +44,8 @@ function vote_count_user_total($userId = null) */ function vote_count_app_total($appId) { - $result = query_appdb("SELECT * FROM appVotes WHERE appId = $appId"); - return mysql_num_rows($result); + $hResult = query_appdb("SELECT * FROM appVotes WHERE appId = $appId"); + return mysql_num_rows($hResult); } @@ -98,13 +98,13 @@ function vote_get_user_votes($userId = null) if(!$userId) return array(); } - $result = query_appdb("SELECT * FROM appVotes WHERE userId = $userId"); - if(!$result) + $hResult = query_appdb("SELECT * FROM appVotes WHERE userId = $userId"); + if(!$hResult) return array(); $obs = array(); - while($ob = mysql_fetch_object($result)) - $obs[$ob->slot] = $ob; + while($oRow = mysql_fetch_object($hResult)) + $obs[$oRow->slot] = $oRow; return $obs; } diff --git a/index.php b/index.php index b5e91da..4a8b9ba 100644 --- a/index.php +++ b/index.php @@ -63,11 +63,11 @@ If you have screenshots or links to contribute, please browse the database and u "FROM appVotes, appFamily ". "WHERE appVotes.appId = appFamily.appId ". "GROUP BY appId ORDER BY count DESC LIMIT 1"; - $result = query_appdb($voteQuery); - $ob = mysql_fetch_object($result); + $hResult = query_appdb($voteQuery); + $oRow = mysql_fetch_object($hResult); - $voteAppId = $ob->appId; - $voteAppName = $ob->appName; + $voteAppId = $oRow->appId; + $voteAppName = $oRow->appName; /* don't mention the top application if there are no votes yet */ if($voteAppId != "") diff --git a/preferences.php b/preferences.php index 4c091ea..9915ee4 100644 --- a/preferences.php +++ b/preferences.php @@ -54,8 +54,8 @@ if($_SESSION['current']->hasPriv("admin") && function build_prefs_list() { global $oUser; - $result = query_appdb("SELECT * FROM prefs_list ORDER BY id"); - while($result && $r = mysql_fetch_object($result)) + $hResult = query_appdb("SELECT * FROM prefs_list ORDER BY id"); + while($hResult && $r = mysql_fetch_object($hResult)) { //skip admin options //TODO: add a field to prefs_list to flag the user level for the pref diff --git a/votestats.php b/votestats.php index 30bc6c9..7430c52 100644 --- a/votestats.php +++ b/votestats.php @@ -67,11 +67,11 @@ if($catId != 0) { $catQuery = "SELECT appCategory.catName, appCategory.catParent ". "FROM appCategory WHERE appCategory.catId = '$currentCatId';"; - $result = query_appdb($catQuery); + $hResult = query_appdb($catQuery); - if($result) + if($hResult) { - $row = mysql_fetch_object($result); + $row = mysql_fetch_object($hResult); $catParent = $row->catParent; array_push($cat_array, "$currentCatId"); @@ -168,7 +168,7 @@ if(strcasecmp($categoryId, "any") == 0) ORDER BY count DESC LIMIT $topNumber"; } -if($result = query_appdb($sVoteQuery)) +if($hResult = query_appdb($sVoteQuery)) { echo html_frame_start("", "90%", '', 0); echo html_table_begin("width='100%' align=center"); @@ -176,11 +176,11 @@ if($result = query_appdb($sVoteQuery)) echo "\n"; $c = 1; - while($row = mysql_fetch_object($result)) + while($row = mysql_fetch_object($hResult)) { - $bgcolor = ($c % 2) ? "color0" : "color1"; + $bgcolor = ($c % 2) ? "color0" : "color1"; $link = "$row->appName"; - echo "\n"; + echo "\n"; $c++; }
\n"; - echo html_frame_start("Viewing $titleValue $titleText","80%","",0); - echo "\n"; + echo html_frame_start("Viewing $titleValue $titleText","80%","",0); + echo "
\n"; - for($i = 0; $i < $nfields; $i++) - { - $field = mysql_fetch_field($result, $i); + for($i = 0; $i < $nfields; $i++) + { + $field = mysql_fetch_field($hResult, $i); if(ereg("^impl_(.+)$", $field->table, $arr)) { @@ -108,214 +107,208 @@ class TableVE { $cur_impl = $arr[1]; } - echo ""; - echo "\n"; - } + echo ""; + echo "\n"; + } echo "
$field->name "; - $this->view_entry_output_field($field, $fields[$i], 0); - echo "
$field->name "; + $this->view_entry_output_field($field, $fields[$i], 0); + echo "
\n"; echo html_frame_end(); - } function edit($query) { - $result = query_appdb($query); - $nrows = mysql_num_rows($result); + $hResult = query_appdb($query); + $nrows = mysql_num_rows($hResult); echo "
\n"; for($i = 0; $i < $nrows; $i++) - { - $this->edit_entry($result); - echo "
\n"; - } + { + $this->edit_entry($hResult); + echo "
\n"; + } echo html_frame_start("Update Database",100); echo "\n"; - echo html_frame_end(); + echo html_frame_end(); - echo "
\n"; + echo "\n"; } - function edit_entry($result) + function edit_entry($hResult) { - $nfields = mysql_num_fields($result); - $fields = mysql_fetch_array($result); + $nfields = mysql_num_fields($hResult); + $fields = mysql_fetch_array($hResult); - echo html_frame_start(ucfirst($this->mode),"80%","",0); - echo "\n"; + echo html_frame_start(ucfirst($this->mode),"80%","",0); + echo "
\n"; - $cur_impl = null; + $cur_impl = null; for($i = 0; $i < $nfields; $i++) + { + global $testvar; + $field = mysql_fetch_field($hResult, $i); + $len = mysql_field_len($hResult, $i); + + if(ereg("^impl_(.+)$", $field->table, $arr)) { - global $testvar; - $field = mysql_fetch_field($result, $i); - $len = mysql_field_len($result, $i); - - if(ereg("^impl_(.+)$", $field->table, $arr)) - { - if($cur_impl != $arr[1]) - echo "\n"; - $cur_impl = $arr[1]; - } - - echo ""; - echo "\n"; + if($cur_impl != $arr[1]) + echo "\n"; + $cur_impl = $arr[1]; } + echo ""; + echo "\n"; + } + echo "
".ucfirst($arr[1])." Implementation
$field->name    "; - $this->edit_entry_output_field($field, $fields[$i], $len); - echo "
".ucfirst($arr[1])." Implementation
$field->name    "; + $this->edit_entry_output_field($field, $fields[$i], $len); + echo "
\n"; - echo html_frame_end(); + echo html_frame_end(); } function make_option_list($varname, $cvalue, $table, $idField, $nameField, $where = "") { - - $result = query_appdb("SELECT $idField, $nameField FROM $table $where ORDER BY $nameField"); - if(!$result) - return; // Oops + $hResult = query_appdb("SELECT $idField, $nameField FROM $table $where ORDER BY $nameField"); + if(!$hResult) + return; // Oops - echo "\n"; + echo "\n"; } function edit_entry_output_field($field, $value, $len) { - static $idx = 0; + static $idx = 0; - $idx++; - if($len > 50) - $len = 50; + $idx++; + if($len > 50) + $len = 50; - $varname = "FIELD_".$field->table."___".$field->name."[]"; - echo "\n"; + $varname = "FIELD_".$field->table."___".$field->name."[]"; + echo "\n"; - if($field->name == "appId" && $field->table != "appFamily") - { - $this->make_option_list($varname, $value, "appFamily", "appId", "appName"); - return; - } + if($field->name == "appId" && $field->table != "appFamily") + { + $this->make_option_list($varname, $value, "appFamily", "appId", "appName"); + return; + } - if($field->name == "vendorId" && $field->table != "vendor") - { - $this->make_option_list($varname, $value, "vendor", "vendorId", "vendorName"); - return; - } + if($field->name == "vendorId" && $field->table != "vendor") + { + $this->make_option_list($varname, $value, "vendor", "vendorId", "vendorName"); + return; + } - if($field->name == "catId" && $field->table != "appCategory") - { - $this->make_option_list($varname, $value, "appCategory", "catId", "catName"); - return; - } + if($field->name == "catId" && $field->table != "appCategory") + { + $this->make_option_list($varname, $value, "appCategory", "catId", "catName"); + return; + } - if($field->name == "catParent") - { - $this->make_option_list($varname, $value, "appCategory", "catId", "catName"); - return; - } + if($field->name == "catParent") + { + $this->make_option_list($varname, $value, "appCategory", "catId", "catName"); + return; + } - if($field->name == "keywords") - { - echo "\n"; - return; - } + if($field->name == "keywords") + { + echo "\n"; + return; + } - switch($field->type) - { - case "string": - case "enum": - case "int": - case "text": - echo "\n"; - break; - case "blob": - echo "\n"; - break; - case "timestamp": - $time = mysqltimestamp_to_unixtimestamp($value); - echo print_date($time); - break; - case "datetime": - $time = mysqldatetime_to_unixtimestamp($value); - echo print_date($time); - break; - default: - echo "$value  \n"; - break; - } + switch($field->type) + { + case "string": + case "enum": + case "int": + case "text": + echo "\n"; + break; + case "blob": + echo "\n"; + break; + case "timestamp": + $time = mysqltimestamp_to_unixtimestamp($value); + echo print_date($time); + break; + case "datetime": + $time = mysqldatetime_to_unixtimestamp($value); + echo print_date($time); + break; + default: + echo "$value  \n"; + break; + } - $this->entry_add_extra($field, $value); + $this->entry_add_extra($field, $value); } - - function view_entry_output_field($field, $value, $len) { if($len > 50) $len = 50; - //FIXME: need a better way for special cases - if(!$value && $field->name == "comments") - { - echo "none"; - return; - } - if(!$value && ($field->name == "location" || $field->name == "quality")) - { - echo "unknown"; - return; - } + //FIXME: need a better way for special cases + if(!$value && $field->name == "comments") + { + echo "none"; + return; + } + if(!$value && ($field->name == "location" || $field->name == "quality")) + { + echo "unknown"; + return; + } if($field->name == "lastmodby") - { - $user = new user(); - $name = $user->lookup_realname($value); - if(!$name) - $name = "system"; - echo "$name ($value)"; - return; - } + { + $user = new user(); + $name = $user->lookup_realname($value); + if(!$name) + $name = "system"; + echo "$name ($value)"; + return; + } - switch($field->type) - { - case "string": - case "enum": - case "int": - case "blob": - echo "$value  \n"; - break; - case "timestamp": - $time = mysqltimestamp_to_unixtimestamp($value); - echo print_date($time); - break; - case "datetime": - $time = mysqldatetime_to_unixtimestamp($value); - echo print_date($time); - break; - default: - echo "$value  \n"; - break; - } + { + case "string": + case "enum": + case "int": + case "blob": + echo "$value  \n"; + break; + case "timestamp": + $time = mysqltimestamp_to_unixtimestamp($value); + echo print_date($time); + break; + case "datetime": + $time = mysqldatetime_to_unixtimestamp($value); + echo print_date($time); + break; + default: + echo "$value  \n"; + break; + } - $this->entry_add_extra($field, $value); + $this->entry_add_extra($field, $value); } @@ -324,22 +317,21 @@ class TableVE { */ function entry_add_extra($field, $value) { - /* + /* * add extra stuff to certain fields */ if($field->name == "mslink" && $value) - { - echo html_imagebutton("Go!", $value); - } - - if($field->name == "apiname") - { - echo html_imagebutton("Wine LXR", "http://twine.codeweavers.com/lxr/ident?i=$value"); - echo html_imagebutton("Wine API", "http://www.winehq.com/WineAPI/$value.html"); - } - } + { + echo html_imagebutton("Go!", $value); + } + if($field->name == "apiname") + { + echo html_imagebutton("Wine LXR", "http://twine.codeweavers.com/lxr/ident?i=$value"); + echo html_imagebutton("Wine API", "http://www.winehq.com/WineAPI/$value.html"); + } + } /* @@ -359,18 +351,18 @@ class TableVE { function get_id($name) { - reset($this->table_ids); - while(list($table, $id) = each($this->table_ids)) - { - $r = "^$table$"; - //echo "Checking $r against $name
\n"; - if(ereg($r, $name)) - { - //echo "ID for $name -> $id
\n"; - return $id; - } - } - return null; + reset($this->table_ids); + while(list($table, $id) = each($this->table_ids)) + { + $r = "^$table$"; + //echo "Checking $r against $name
\n"; + if(ereg($r, $name)) + { + //echo "ID for $name -> $id
\n"; + return $id; + } + } + return null; } /** @@ -380,101 +372,96 @@ class TableVE { */ function update($vars) { - - $tables = array(); - $fieldnames = array(); - $num_entries = 0; + $tables = array(); + $fieldnames = array(); + $num_entries = 0; - while(list($varname, $arr) = each($vars)) - { - if(!ereg("^FIELD_([a-zA-Z_]+)___(.+)$", $varname, $regs)) - continue; + while(list($varname, $arr) = each($vars)) + { + if(!ereg("^FIELD_([a-zA-Z_]+)___(.+)$", $varname, $regs)) + continue; - $tables[$regs[1]][] = $regs[2]; - $fieldnames[$regs[2]] = $arr; - $num_entries = sizeof($arr); - } + $tables[$regs[1]][] = $regs[2]; + $fieldnames[$regs[2]] = $arr; + $num_entries = sizeof($arr); + } - while(list($table, $fields) = each($tables)) - { - echo " $table (".$this->get_id($table).") "; + while(list($table, $fields) = each($tables)) + { + echo " $table (".$this->get_id($table).") "; - if($fieldnames[$this->get_id($table)]) - echo "OK!"; + if($fieldnames[$this->get_id($table)]) + echo "OK!"; - echo "
\n"; + echo "
\n"; - for($i = 0; $i < sizeof($fields); $i++) - echo "- $fields[$i]
\n"; + for($i = 0; $i < sizeof($fields); $i++) + echo "- $fields[$i]
\n"; - echo "
\n"; - } + echo "
\n"; + } - for($i = 0; $i < $num_entries; $i++) - { - reset($tables); - while(list($table, $fields) = each($tables)) - { - $update = "UPDATE $table SET "; - - $count = sizeof($fields); - reset($fields); - while(list($idx, $field) = each($fields)) - { - $count--; + for($i = 0; $i < $num_entries; $i++) + { + reset($tables); + while(list($table, $fields) = each($tables)) + { + $update = "UPDATE $table SET "; + + $count = sizeof($fields); + reset($fields); + while(list($idx, $field) = each($fields)) + { + $count--; - if($this->table_ids[$table] == $field) - { - continue; - } - $key = "FIELD_".$table."___".$field; - $type = $vars["TYPE_$key"][$i]; + if($this->table_ids[$table] == $field) + { + continue; + } + $key = "FIELD_".$table."___".$field; + $type = $vars["TYPE_$key"][$i]; - if($type == "int") - $update .= "$field = ".$vars[$key][$i]; - else - $update .= "$field = '".addslashes($vars[$key][$i])."'"; + if($type == "int") + $update .= "$field = ".$vars[$key][$i]; + else + $update .= "$field = '".addslashes($vars[$key][$i])."'"; - if($count) - $update .= ", "; - } + if($count) + $update .= ", "; + } - $value = $fieldnames[$this->get_id($table)][$i]; + $value = $fieldnames[$this->get_id($table)][$i]; - $update .= " WHERE ".$this->get_id($table)." = $value"; + $update .= " WHERE ".$this->get_id($table)." = $value"; - if(query_appdb($update)) - { - addmsg("Database Operation Complete!","green"); - } - - if(ereg("^impl_.+$", $table)) - { - $value = $fieldnames["apiid"][$i]; - query_appdb("UPDATE $table SET lastmodby = ".$_SESSION['current']->userid." WHERE apiid = $value"); - } - } - } - - + if(query_appdb($update)) + { + addmsg("Database Operation Complete!","green"); + } + if(ereg("^impl_.+$", $table)) + { + $value = $fieldnames["apiid"][$i]; + query_appdb("UPDATE $table SET lastmodby = ".$_SESSION['current']->userid." WHERE apiid = $value"); + } + } + } } function set_title_field($newTitleField) { - $this->titleField = $newTitleField; + $this->titleField = $newTitleField; } function set_title_text($newTitleText) { - $this->titleText = $newTitleText; + $this->titleText = $newTitleText; } function set_numbered_titles() { - $this->numberedTitles = 1; + $this->numberedTitles = 1; } - }; ?> diff --git a/include/user.php b/include/user.php index 9d74c0d..9dc084e 100644 --- a/include/user.php +++ b/include/user.php @@ -342,7 +342,7 @@ class User { if($sQuery) { - if($result = query_appdb($sQuery)) + if($hResult = query_appdb($sQuery)) return true; } @@ -356,31 +356,31 @@ class User { if(!$this->hasPriv("admin")) return 0; - $qstring = "SELECT count(*) as queued_apps FROM appFamily WHERE queued='true'"; - $result = query_appdb($qstring); - $ob = mysql_fetch_object($result); - return $ob->queued_apps; + $sQuery = "SELECT count(*) as queued_apps FROM appFamily WHERE queued='true'"; + $hResult = query_appdb($sQuery); + $oRow = mysql_fetch_object($hResult); + return $oRow->queued_apps; } function getQueuedVersionCount() { if($this->hasPriv("admin")) { - $qstring = "SELECT count(*) as queued_versions FROM appVersion WHERE queued='true'"; + $sQuery = "SELECT count(*) as queued_versions FROM appVersion WHERE queued='true'"; } else { /* find all queued versions of applications that the user is a super maintainer of */ - $qstring = "SELECT count(*) as queued_versions FROM appVersion, appMaintainers + $sQuery = "SELECT count(*) as queued_versions FROM appVersion, appMaintainers WHERE queued='true' AND appMaintainers.superMaintainer ='1' AND appVersion.appId = appMaintainers.appId AND appMaintainers.userId ='".$this->iUserId."';"; } - $result = query_appdb($qstring); - $ob = mysql_fetch_object($result); + $hResult = query_appdb($sQuery); + $oRow = mysql_fetch_object($hResult); /* we don't want to count the versions that are implicit in the applications */ /* that are in the queue */ - return $ob->queued_versions - $this->getQueuedAppCount(); + return $oRow->queued_versions - $this->getQueuedAppCount(); } @@ -388,8 +388,8 @@ class User { function getQueuedAppDataCount() { $hResult = $this->getAppDataQuery(0, true, false); - $ob = mysql_fetch_object($hResult); - return $ob->queued_appdata; + $oRow = mysql_fetch_object($hResult); + return $oRow->queued_appdata; } function addPriv($sPriv) @@ -582,20 +582,20 @@ class User { function getAllRejectedApps() { - $result = query_appdb("SELECT appVersion.versionId, appFamily.appId + $hResult = query_appdb("SELECT appVersion.versionId, appFamily.appId FROM appVersion, appFamily WHERE appFamily.appId = appVersion.appId AND (appFamily.queued = 'rejected' OR appVersion.queued = 'rejected') AND appVersion.submitterId = '".$this->iUserId."';"); - if(!$result || mysql_num_rows($result) == 0) + if(!$hResult || mysql_num_rows($hResult) == 0) return; $retval = array(); $c = 0; - while($row = mysql_fetch_object($result)) + while($oRow = mysql_fetch_object($hResult)) { - $retval[$c] = array($row->appId, $row->versionId); + $retval[$c] = array($oRow->appId, $oRow->versionId); $c++; } @@ -1110,9 +1110,9 @@ function get_notify_email_address_list($iAppId = null, $iVersionId = null) */ function get_number_of_users() { - $result = query_appdb("SELECT count(*) as num_users FROM user_list;"); - $row = mysql_fetch_object($result); - return $row->num_users; + $hResult = query_appdb("SELECT count(*) as num_users FROM user_list;"); + $oRow = mysql_fetch_object($hResult); + return $oRow->num_users; } @@ -1121,9 +1121,9 @@ function get_number_of_users() */ function get_active_users_within_days($days) { - $result = query_appdb("SELECT count(*) as num_users FROM user_list WHERE stamp >= DATE_SUB(CURDATE(), interval $days day);"); - $row = mysql_fetch_object($result); - return $row->num_users; + $hResult = query_appdb("SELECT count(*) as num_users FROM user_list WHERE stamp >= DATE_SUB(CURDATE(), interval $days day);"); + $oRow = mysql_fetch_object($hResult); + return $oRow->num_users; } @@ -1146,12 +1146,12 @@ function get_inactive_users_pending_deletion() */ function user_exists($sEmail) { - $result = query_appdb("SELECT userid FROM user_list WHERE email = '$sEmail'"); - if(!$result || mysql_num_rows($result) != 1) + $hResult = query_appdb("SELECT userid FROM user_list WHERE email = '$sEmail'"); + if(!$hResult || mysql_num_rows($hResult) != 1) return 0; else { - $oRow = mysql_fetch_object($result); + $oRow = mysql_fetch_object($hResult); return $oRow->userid; } } diff --git a/include/util.php b/include/util.php index ce8cd4b..5b01733 100644 --- a/include/util.php +++ b/include/util.php @@ -71,9 +71,9 @@ function get_remote() global $REMOTE_HOST, $REMOTE_ADDR; if($REMOTE_HOST) - $ip = $REMOTE_HOST; + $ip = $REMOTE_HOST; else - $ip = $REMOTE_ADDR; + $ip = $REMOTE_ADDR; return $ip; } @@ -101,12 +101,12 @@ function get_xml_tag ($file, $mode = null) if ($mode and file_exists($file)) { $fp = @fopen($file, "r"); - $data = fread($fp, filesize($file)); - @fclose($fp); - if (eregi("<" . $mode . ">(.*)", $data, $out)) - { - return $out[1]; - } + $data = fread($fp, filesize($file)); + @fclose($fp); + if (eregi("<" . $mode . ">(.*)", $data, $out)) + { + return $out[1]; + } } else { @@ -119,14 +119,14 @@ function make_bugzilla_version_list($varname, $cvalue) { $table = BUGZILLA_DB.".versions"; $where = "WHERE product_id=".BUGZILLA_PRODUCT_ID; - $query = "SELECT value FROM $table $where ORDER BY value"; + $sQuery = "SELECT value FROM $table $where ORDER BY value"; - $result = query_bugzilladb($query); - if(!$result) return; + $hResult = query_bugzilladb($sQuery); + if(!$hResult) return; echo "
".html_ahref($ob->appName,BASE."appview.php?appId=$ob->appId")."".trim_description($ob->description)."".html_ahref($oRow->appName,BASE."appview.php?appId=$oRow->appId")."".trim_description($oRow->description)."$y->versions  
Votes
$c. $link $row->count
$c. $link $row->count