- access most globals by their $_XYZ['varname'] name

- fix some code errors and typos (missing $ in front of variable names
and so on)
- fixed a lot of warnings that would have been thrown when error_reporting
is set to show notices (if(isset($variable))) instead of if($variable) for
example)
This commit is contained in:
Jonathan Ernst
2004-12-10 01:07:45 +00:00
committed by WineHQ
parent 972270f27a
commit bd91db228c
24 changed files with 146 additions and 165 deletions

View File

@@ -217,7 +217,6 @@ function display_comments_flat($appId, $versionId)
function view_app_comments($appId, $versionId, $threadId = 0)
{
global $current;
global $cmode;
// count posts
@@ -235,9 +234,9 @@ function view_app_comments($appId, $versionId, $threadId = 0)
{
//FIXME we need to change this so not logged in users can change current view as well
if ($cmode)
$current->setpref("comments:mode", $cmode);
$_SESSION[current]->setpref("comments:mode", $cmode);
$sel[$current->getpref("comments:mode")] = 'selected';
$sel[$_SESSION['current']->getpref("comments:mode")] = 'selected';
echo '<td><form method=get name=smode action="appview.php">',"\n";
echo "<b>Application Comments</b> $messageCount total comments ";
echo '<b>Mode</b> <select name="cmode" onchange="document.smode.submit();">',"\n";
@@ -268,7 +267,7 @@ function view_app_comments($appId, $versionId, $threadId = 0)
//hide or display depending on pref
if (loggedin())
$mode = $current->getpref("comments:mode");
$mode = $_SESSION['current']->getpref("comments:mode");
else
$mode = "flat";

View File

@@ -11,7 +11,7 @@
<tr>
<td> &nbsp; User Name </td>
<td> <b> <?=$ext_username?> </b> </td>
<td> <b> <?=$ext_username;?> </b> </td>
</tr>
<tr>
<td> &nbsp; Password </td>
@@ -23,11 +23,11 @@
</tr>
<tr>
<td> &nbsp; Real Name </td>
<td> <input type="text" name="ext_realname" value="<?=$ext_realname?>"> </td>
<td> <input type="text" name="ext_realname" value="<?=$ext_realname;?>"> </td>
</tr>
<tr>
<td> &nbsp; Email Address </td>
<td> <input type="text" name="ext_email" value="<?=$ext_email?>"> </td>
<td> <input type="text" name="ext_email" value="<?=$ext_email;?>"> </td>
</tr>
<tr>
<td colspan=2>&nbsp;</td>

View File

@@ -24,7 +24,7 @@ function cmd_send_passwd() {
<table border="0" width="100%" cellspacing=0 cellpadding="10">
<tr>
<td class=color1> User Name </td>
<td class=color0> <input type="text" name="ext_username" value='<?=$ext_username?>'> </td>
<td class=color0> <input type="text" name="ext_username" value='<?if(isset($_POST['ext_username'])) echo $_POST['ext_username']?>'> </td>
</tr>
<tr>
<td class=color1> Password </td>
@@ -43,7 +43,7 @@ function cmd_send_passwd() {
echo html_frame_end("&nbsp;");
echo '<input type="hidden" name="cmd" value="do_login">',"\n";
echo '<input type="hidden" name="ext_referer" value="'.$HTTP_REFERER.'">',"\n";
echo '<input type="hidden" name="ext_referer" value="'.$_SERVER['HTTP_REFERER'].'">',"\n";
echo '</form>',"\n";
?>

View File

@@ -15,7 +15,7 @@ echo html_frame_start("Create New Application DB Account","400","",0)
<table border=0 width="100%" cellspacing=0 cellpadding=20>
<tr>
<td class=color1> User Name </td>
<td class=color0> <input type="text" name="ext_username" value='<?=$ext_username?>'> </td>
<td class=color0> <input type="text" name="ext_username" value='<?if(isset($_POST['ext_username'])) echo $_POST['ext_username']?>'> </td>
</tr>
<tr>
<td class=color1> Password </td>
@@ -27,11 +27,11 @@ echo html_frame_start("Create New Application DB Account","400","",0)
</tr>
<tr>
<td class=color1> Real Name </td>
<td class=color0> <input type="text" name="ext_realname" value='<?=$ext_realname?>'> </td>
<td class=color0> <input type="text" name="ext_realname" value='<?if(isset($_POST['ext_realname'])) echo $_POST['ext_realname']?>'> </td>
</tr>
<tr>
<td class=color1> Email Address </td>
<td class=color0> <input type="text" name="ext_email" value='<?=$ext_email?>'> </td>
<td class=color0> <input type="text" name="ext_email" value='<?if(isset($_POST['ext_email'])) echo $_POST['ext_email']?>'> </td>
</tr>
<tr>

View File

@@ -197,7 +197,7 @@ function html_frame_start($title = "", $width = "", $extra = "", $innerPad = 5)
if ($width) { $width = 'width="'.$width.'"'; }
$str .= '<table '.$width.' border=0 cellpadding=0 cellspacing=0 align=center>'."\n";
$str = '<table '.$width.' border=0 cellpadding=0 cellspacing=0 align=center>'."\n";
if ($title)
{

View File

@@ -6,7 +6,6 @@
*/
//set global path
global $apidb_root;
$apidb_root = BASE;
//get modules
@@ -60,9 +59,9 @@ function apidb_fullpath($path)
*/
function apidb_header($title = 0)
{
global $apidb_root, $current;
global $apidb_root;
$username = $current->username;
$username = isset($_SESSION['current'])?$_SESSION['current']->username:"";
// Set Page Title
$page_title = $title;
@@ -97,7 +96,6 @@ function apidb_header($title = 0)
function apidb_footer()
{
global $apidb_root;
global $current;
echo html_frame_end();
@@ -105,7 +103,7 @@ function apidb_footer()
echo "<br></td></tr></table>\n";
// Display Footer
if(!$header_disabled)
if(!isset($header_disabled))
include(BASE."include/"."footer.php");
}
@@ -202,7 +200,6 @@ function redirectref($url = null)
*/
function addmsg($text, $color = "black")
{
global $current;
global $PHPSESSID;
if($color)
@@ -220,7 +217,6 @@ function addmsg($text, $color = "black")
*/
function dumpmsgbuffer()
{
global $current;
global $PHPSESSID;
$result = mysql_query("SELECT * FROM sessionMessages WHERE sessionId = '$PHPSESSID'");

View File

@@ -15,12 +15,11 @@
*/
function rating_current_for_user($versionId, $system)
{
global $current;
if(!loggedin())
return 0;
$userId = $current->userid;
$userId = $_SESSION['current']->userid;
$result = mysql_query("SELECT score FROM appRating WHERE versionId = $versionId AND system = '$system' AND userId = $userId");
if(!$result)
@@ -38,7 +37,6 @@ function rating_current_for_user($versionId, $system)
*/
function rating_menu()
{
global $versionId;
global $apidb_root;
$s = '<img src="'.$apidb_root.'images/s1.gif" border=0 alt="s1">';
@@ -46,8 +44,8 @@ function rating_menu()
$j = new htmlmenu("Compatibility Rating","updaterating.php");
$r_win = rating_current_for_user($versionId, "windows");
$r_fake = rating_current_for_user($versionId, "fake");
$r_win = rating_current_for_user($_REQUEST['versionId'], "windows");
$r_fake = rating_current_for_user($_REQUEST['versionId'], "fake");
$wchk = array('checked',' ',' ',' ',' ',' ');
$fchk = array('checked',' ',' ',' ',' ',' ');
@@ -78,7 +76,7 @@ function rating_menu()
$j->addmisc("<input type=submit value=' Rate it! ' class=ratebutton>","center");
$j->addmisc("<input type=hidden name=versionId value=$versionId>");
$j->addmisc("<input type=hidden name=versionId value=".$_REQUEST['versionId'].">");
$j->add("Rating Help", $apidb_root."help/?topic=ratings");
@@ -161,7 +159,6 @@ function rating_stars_for_version($versionId, $system)
*/
function rating_update($vars)
{
global $current;
if(!loggedin())
{
@@ -169,7 +166,7 @@ function rating_update($vars)
return;
}
$userId = $current->userid;
$userId = $_SESSION[current]->userid;
$versionId = $vars["versionId"];
$score_w = $vars["score_w"];
$score_f = $vars["score_f"];

View File

@@ -33,7 +33,7 @@ function global_sidebar_menu() {
function app_search_box($q = '')
{
global $apidb_root;
$str .= '<form method="get" action="'.$apidb_root.'search.php">'."\n";
$str = '<form method="get" action="'.$apidb_root.'search.php">'."\n";
$str .= "<input type=text name=q value='$q' size=8 class=searchfield>";
$str .= "<input type=submit value='Search' class=searchbutton>\n";
$str .= "</form>\n";

View File

@@ -16,14 +16,13 @@ function global_sidebar_login() {
if(loggedin())
{
global $current;
$g->add("Logout", $apidb_root."account.php?cmd=logout");
$g->add("Preferences", $apidb_root."preferences.php");
/* if this user maintains any applications list them */
/* in their sidebar */
$apps_user_maintains = getAppsFromUserId($current->userid);
$apps_user_maintains = getAppsFromUserId($_SESSION['current']->userid);
if($apps_user_maintains)
{
$g->addmisc("");

View File

@@ -193,7 +193,7 @@ class TableVE {
{
$result = mysql_query("SELECT $idField, $nameField FROM $table $where ORDER BY $nameField");
if(!result)
if(!$result)
return; // Oops
echo "<select name='$varname'>\n";
@@ -396,7 +396,6 @@ class TableVE {
*/
function update($vars)
{
global $current;
$tables = array();
$fieldnames = array();
@@ -474,7 +473,7 @@ class TableVE {
if(ereg("^impl_.+$", $table))
{
$value = $fieldnames["apiid"][$i];
mysql_query("UPDATE $table SET lastmodby = $current->userid WHERE apiid = $value");
mysql_query("UPDATE $table SET lastmodby = ".$_SESSION['current']->userid." WHERE apiid = $value");
}
}
}

View File

@@ -222,7 +222,6 @@ class User {
*/
function is_maintainer($appId, $versionId)
{
global $current;
if(!loggedin() || !$this->userid)
return false;
@@ -297,9 +296,7 @@ class User {
function loggedin()
{
global $current;
if($current && $current->userid)
if(isset($_SESSION['current']) && $_SESSION['current']->userid)
return true;
return false;

View File

@@ -214,6 +214,14 @@ function getNumberOfVersions()
return $row->num_versions;
}
/* Get the number of maintainers in the database */
function getNumberOfMaintainers()
{
$result = mysql_query("SELECT count(maintainerId ) as num_maintainers FROM appMaintainers;");
$row = mysql_fetch_object($result);
return $row->num_maintainers;
}
/* Get the number of app familes in the database */
function getNumberOfAppFamilies()
{

View File

@@ -9,12 +9,11 @@
*/
function vote_count($appId, $userId = null)
{
global $current;
if(!$userId)
{
if(loggedin())
$userId = $current->userid;
$userId = $_SESSION['current']->userid;
else
return 0;
}
@@ -27,12 +26,10 @@ function vote_count($appId, $userId = null)
*/
function vote_count_user_total($userId = null)
{
global $current;
if(!$userId)
{
if(loggedin())
$userId = $current->userid;
$userId = $_SESSION['current']->userid;
else
return 0;
}
@@ -57,13 +54,12 @@ function vote_count_app_total($appId)
*/
function vote_add($appId, $slot, $userId = null)
{
global $current;
global $MAX_VOTES;
if(!$userId)
{
if(loggedin())
$userId = $current->userid;
$userId = $_SESSION['current']->userid;
else
return;
}
@@ -80,12 +76,12 @@ function vote_add($appId, $slot, $userId = null)
*/
function vote_remove($appId, $slot, $userId = null)
{
global $current;
if(!$userId)
{
if(loggedin())
$userId = $current->userid;
$userId = $_SESSION['current']->userid;
else
return;
}
@@ -94,12 +90,12 @@ function vote_remove($appId, $slot, $userId = null)
function vote_get_user_votes($userId = null)
{
global $current;
if(!$userId)
{
if(loggedin())
$userId = $current->userid;
$userId = $_SESSION['current']->userid;
if(!$userId)
return array();
}
@@ -170,10 +166,10 @@ function dump($arr)
function vote_update($vars)
{
global $current;
//FIXME this doesn't work since msgs only work when logged in
if(!$current)
if(!$_SESSION['current'])
{
addmsg("You must be logged in to vote", "red");
return;