- 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

@@ -13,13 +13,14 @@ header("Pragma: no-cache");
header("Cache-control: no-cache");
//check command and process
do_account($cmd);
if(isset($_POST['cmd']))
do_account($_POST['cmd']);
else
do_account($_GET['cmd']);
//process according to $cmd from URL
function do_account($cmd = null)
{
global $ext_username, $ext_password, $ext_password2, $ext_realname, $ext_email;
if (! $cmd) return 0;
switch($cmd)
{
@@ -68,58 +69,56 @@ function retry($cmd, $msg)
//create new account
function cmd_do_new()
{
global $ext_username, $ext_password, $ext_password2, $ext_realname, $ext_email;
global $current;
if(ereg("^.+@.+\\..+$", $ext_username))
if(ereg("^.+@.+\\..+$", $_POST['ext_username']))
{
$ext_username = "";
$_POST['ext_username'] = "";
retry("new", "Invalid Username, must not contain special characters");
return;
}
if(strlen($ext_username) < 3)
if(strlen($_POST['ext_username']) < 3)
{
$ext_username = "";
$_POST['ext_username'] = "";
retry("new", "Username must be at least 3 characters");
return;
}
if(strlen($ext_password) < 5)
if(strlen($_POST['ext_password']) < 5)
{
retry("new", "Password must be at least 5 characters");
return;
}
if($ext_password != $ext_password2)
if($_POST['ext_password'] != $_POST['ext_password2'])
{
retry("new", "Passwords don't match");
return;
}
if(strlen($ext_realname) == 0)
if(!isset($_POST['ext_realname']))
{
retry("new", "You don't have a Real name?");
return;
}
if(!ereg("^.+@.+\\..+$", $ext_email))
if(!ereg("^.+@.+\\..+$", $_POST['ext_email']))
{
$ext_email = "";
$_POST['ext_email'] = "";
retry("new", "Invalid email address");
return;
}
$user = new User();
if($user->exists($ext_username))
if($user->exists($_POST['ext_username']))
{
$ext_username = "";
$_POST['ext_username'] = "";
retry("new", "That username is already in use");
return;
}
$result = $user->create($ext_username, $ext_password, $ext_realname, $ext_email);
$result = $user->create($_POST['ext_username'], $_POST['ext_password'], $_POST['ext_realname'], $_POST['ext_email']);
if($result == null)
{
$user->login($ext_username, $ext_password);
addmsg("Account created! ($ext_username)", "green");
$user->login($_POST['ext_username'], $_POST['ext_password']);
addmsg("Account created! (".$_POST['ext_username'].")", "green");
redirect(apidb_fullurl());
}
else
@@ -129,11 +128,9 @@ function cmd_do_new()
//email lost password
function cmd_send_passwd()
{
global $ext_username;
$user = new User();
$userid = $user->lookup_userid($ext_username);
$userid = $user->lookup_userid($_POST['ext_username']);
$passwd = generate_passwd();
if ($userid)
@@ -163,7 +160,7 @@ function cmd_send_passwd()
}
else
{
addmsg("Sorry, that username [$ext_username] does not exist.", "red");
addmsg("Sorry, that username (".$_POST['ext_username'].") does not exist.", "red");
}
redirect(apidb_fullurl("account.php?cmd=login"));
@@ -172,23 +169,19 @@ function cmd_send_passwd()
//on login handler
function cmd_do_login()
{
global $ext_username, $ext_password;
global $ext_referer;
global $current;
$user = new User();
$result = $user->login($ext_username, $ext_password);
$result = $user->login($_POST['ext_username'], $_POST['ext_password']);
if($result == null)
{
$current = $user;
$_SESSION['current'] = $user;
addmsg("You are successfully logged in as '$user->username'.", "green");
redirect(apidb_fullurl("index.php"));
}
else
{
retry("login","Login failed ($result)");
$current = 0;
$_SESSION['current'] = "";
}
}

View File

@@ -4,7 +4,7 @@ include("path.php");
require(BASE."include/"."incl.php");
require(BASE."include/"."application.php");
global $current;
if(!$appId) {
errorpage('Internal Database Access Error');
@@ -33,7 +33,7 @@ if($body)
$body1 = mysql_escape_string($body);
// get current userid
$userId = (loggedin()) ? $current->userid : 0;
$userId = (loggedin()) ? $_SESSION['current']->userid : 0;
$result = mysql_query("INSERT INTO appComments VALUES (NOW(), null, $thread, ".
"$appId, $versionId, $userId, '$hostname', '$subject', ".
@@ -53,7 +53,7 @@ if($body)
$fullAppName = "Application: ".lookupAppName($appId)." Version: ".lookupVersionName($appId, $versionId);
$ms .= APPDB_ROOT."appview.php?appId=$appId&versionId=$versionId"."\n";
$ms .= "\n";
$ms .= ($current->username ? $current->username : "Anonymous")." added comment to ".$fullAppName."\n";
$ms .= ($_SESSION['current']->username ? $_SESSION['current']->username : "Anonymous")." added comment to ".$fullAppName."\n";
$ms .= "\n";
$ms .= "Subject: ".$subject."\n";
$ms .= "\n";
@@ -74,7 +74,7 @@ if($body)
$fullAppName = "Application: ".lookupAppName($appId)." Version: ".lookupVersionName($appId, $versionId);
$ms = APPDB_ROOT."appview.php?appId=$appId&versionId=$versionId"."\n";
$ms .= "\n";
$ms .= ($current->username ? $current->username : "Anonymous")." added comment to ".$fullAppName."\n";
$ms .= ($_SESSION['current']->username ? $_SESSION['current']->username : "Anonymous")." added comment to ".$fullAppName."\n";
$ms .= "\n";
$ms .= "Subject: ".$subject."\n";
$ms .= "\n";
@@ -121,7 +121,7 @@ else
echo '<table width="100%" border=0 cellpadding=0 cellspacing=1>',"\n";
echo "<tr bgcolor=#E0E0E0><td align=right><b>From:</b>&nbsp;</td>\n";
echo " <td>&nbsp;". ($current->username ? $current->username : "Anonymous") ." </td></tr>\n";
echo " <td>&nbsp;". ($_SESSION['current']->username ? $_SESSION['current']->username : "Anonymous") ." </td></tr>\n";
echo "<tr bgcolor=#E0E0E0><td align=right><b>Subject:</b>&nbsp;</td>\n";
echo " <td>&nbsp;<input type=text size=35 name=subject value='$subject'> </td></tr>\n";
echo "<tr bgcolor=#C0C0C0><td colspan=2><textarea name=body cols=70 rows=15 wrap=virtual>$body</textarea></td></tr>\n";

View File

@@ -40,7 +40,7 @@ if($sub == "Submit")
$fullAppName = "Application: ".lookupAppName($appId)." Version: ".lookupVersionName($appId, $versionId);
$ms = APPDB_ROOT."appview.php?appId=$appId&versionId=$versionId"."\n";
$ms .= "\n";
$ms .= ($current->username ? $current->username : "Anonymous")." added note to ".$fullAppName."\n";
$ms .= ($_SESSION['current']->username ? $_SESSION['current']->username : "Anonymous")." added note to ".$fullAppName."\n";
$ms .= "\n";
$ms .= "title: ".$noteTitle."\n";
$ms .= "\n";

View File

@@ -20,12 +20,12 @@ else if (!havepriv("admin"))
}
if ($sub)
if ($_REQUEST['sub'])
{
if ($queueId)
if ($_REQUEST['queueId'])
{
//get data
$query = "SELECT * from appQueue where queueId = $queueId;";
$query = "SELECT * from appQueue where queueId = ".$_REQUEST['queueId'].";";
$result = mysql_query($query);
$ob = mysql_fetch_object($result);
mysql_free_result($result);
@@ -39,14 +39,14 @@ if ($sub)
}
//process according to sub flag
if ($sub == 'view' && $queueId)
if ($_REQUEST['sub'] == 'view' && $_REQUEST['queueId'])
{
$x = new TableVE("view");
apidb_header("Admin App Queue");
echo '<form name="qform" action="adminAppQueue.php" method="post" enctype="multipart/form-data">',"\n";
echo '<input type=hidden name="sub" value="add">',"\n";
echo '<input type=hidden name="queueId" value="'.$queueId.'">',"\n";
echo '<input type=hidden name="queueId" value="'.$_REQUEST['queueId'].'">',"\n";
If ($ob->queueCatId == -1) //app version
{
@@ -160,7 +160,7 @@ if ($sub)
$checkvendor = $ob2->vendorId;
}
}
if(checkvendor)
if($checkvendor)
{
$ob->queueVendor = '';
@@ -206,50 +206,50 @@ if ($sub)
echo html_frame_end("&nbsp;");
echo html_back_link(1,'adminAppQueue.php');
}
else if ($sub == 'add' && $queueId)
else if ($_REQUEST['sub'] == 'add' && $_REQUEST['queueId'])
{
//add item to main db
$statusMessage = "";
$goodtogo = 0;
if ($type == 'app')
if ($_REQUEST['type'] == 'app')
{
//process as application family
if ($altvendor == 0 && $queueVendor)
if ($_REQUEST['altvendor'] == 0 && $_REQUEST['queueVendor'])
{
//add new vendor
mysql_query("INSERT into vendor VALUES (null, '".addslashes($queueVendor)."', '');");
$altvendor = mysql_insert_id();
mysql_query("INSERT into vendor VALUES (null, '".addslashes($_REQUEST['queueVendor'])."', '');");
$_REQUEST['altvendor'] = mysql_insert_id();
}
$query = "INSERT into appFamily VALUES (null, '".
addslashes($queueName)."', $altvendor, '', '".
addslashes($queueDesc)."', '".
addslashes($queueURL)."', $cat);";
addslashes($_REQUEST['queueName'])."', ".$_REQUEST['altvendor'].", '', '".
addslashes($_REQUEST['queueDesc'])."', '".
addslashes($_REQUEST['queueURL'])."', ".$_REQUEST['cat'].");";
if (mysql_query($query))
{
//get the id of the app just added
$appParent = mysql_insert_id();
$_REQUEST['appParent'] = mysql_insert_id();
//delete queue item
mysql_query("DELETE from appQueue where queueId = $queueId;");
mysql_query("DELETE from appQueue where queueId = ".$_REQUEST['queueId'].";");
//set ver if not set
if (!$queueVersion)
$queueVersion = '1.0';
if (!$queueDesc)
$queueDesc = 'released version';
if (!$_REQUEST['queueVersion'])
$_REQUEST['queueVersion'] = '1.0';
if (!$_REQUEST['queueDesc'])
$_REQUEST['queueDesc'] = 'released version';
$verQuery = "INSERT into appVersion VALUES (null, $appParent, '".
addslashes($queueVersion)."', '', '".
addslashes($queueDesc)."', '".
addslashes($queueURL)."', 0.0, 0.0);";
$verQuery = "INSERT into appVersion VALUES (null, ".$_REQUEST['appParent'].", '".
addslashes($_REQUEST['queueVersion'])."', '', '".
addslashes($_REQUEST['queueDesc'])."', '".
addslashes($_REQUEST['queueURL'])."', 0.0, 0.0);";
//Now add a version
if (mysql_query($verQuery))
{
//successful
$appVersion = mysql_insert_id();
addmsg("The application $queueName was successfully added into the database", "green");
$_REQUEST['appVersion'] = mysql_insert_id();
addmsg("The application ".$_REQUEST['queueName']." was successfully added into the database", "green");
$goodtogo = 1;
}
else
@@ -268,23 +268,23 @@ if ($sub)
addmsg($statusMessage, "red");
}
}
else if ($type == 'ver')
else if ($_REQUEST['type'] == 'ver')
{
//process as application version
if ($appParent)
if ($_REQUEST['appParent'])
{
$query = "INSERT into appVersion VALUES (null, $appParent, '".
addslashes($queueVersion)."', '', '".
addslashes($queueDesc)."', '".
addslashes($queueURL)."', 0.0, 0.0);";
$query = "INSERT into appVersion VALUES (null, ".$_REQUEST['appParent'].", '".
addslashes($_REQUEST['queueVersion'])."', '', '".
addslashes($_REQUEST['queueDesc'])."', '".
addslashes($_REQUEST['queueURL'])."', 0.0, 0.0);";
if (mysql_query($query))
{
//successful
$appVersion = mysql_insert_id();
$statusMessage = "<p>The application $queueName was successfully added into the database</p>\n";
addmsg($statusMessage,Green);
mysql_query("DELETE from appQueue where queueId = $queueId;");
$_REQUEST['appVersion'] = mysql_insert_id();
$statusMessage = "<p>The application ".$_REQUEST['queueName']." was successfully added into the database</p>\n";
addmsg($statusMessage,"Green");
mysql_query("DELETE from appQueue where queueId = ".$_REQUEST['queueId'].";");
$goodtogo = 1;
}
@@ -292,13 +292,13 @@ if ($sub)
{
//error
$statusMessage = "<p><b>Database Error!<br>".mysql_error()."</b></p>\n";
addmsg($statusMessage,red);
addmsg($statusMessage,"red");
}
}
else
{
addmsg("You did not pick an application Parent!",red);
redirect(apidb_fullurl("admin/adminAppQueue.php?cat=view&queueId=$queueId"));
redirect(apidb_fullurl("admin/adminAppQueue.php?cat=view&queueId=".$_REQUEST['queueId']));
exit;
}
@@ -308,13 +308,13 @@ if ($sub)
//Send Status Email
if ($ob->queueEmail && $goodtogo)
{
$fullAppName = lookupAppName($appParent)." Version: ".lookupVersionName($appParent, $appVersion);
$fullAppName = lookupAppName($_REQUEST['appParent'])." Version: ".lookupVersionName($_REQUEST['appParent'], $_REQUEST['appVersion']);
$ms = "Application Database Status Report\n";
$ms .= "----------------------------------\n\n";
$ms .= "Your application: ".$fullAppName." has been entered ";
$ms .= "into the application database.\n\n";
$ms .= APPDB_ROOT."appview.php?appId=$appParent&versionId=$appVersion"."\n\n";
$ms .= APPDB_ROOT."appview.php?appId=".$_REQUEST['appParent']."&versionId=".$_REQUEST['appVersion']."\n\n";
$ms .= "Thanks!\n\n";
$ms .= $emailtext;
@@ -322,12 +322,12 @@ if ($sub)
}
if ($goodtogo)
{
$email = getNotifyEmailAddressList($appParent, $appVersion);
$email = getNotifyEmailAddressList($_REQUEST['appParent'], $_REQUEST['appVersion']);
if($email)
{
$fullAppName = "Application: ".lookupAppName($appParent).
" Version: ".lookupVersionName($appParent, $appVersion);
$ms = APPDB_ROOT."appview.php?appId=$appParent&versionId=$appVersion"."\n\n";
$fullAppName = "Application: ".lookupAppName($_REQUEST['appParent']).
" Version: ".lookupVersionName($_REQUEST['appParent'], $_REQUEST['appVersion']);
$ms = APPDB_ROOT."appview.php?appId=".$_REQUEST['appParent']."&versionId=".$_REQUEST['appVersion']."\n\n";
$ms .= "New Application added to database:\n\n";
$ms .= $fullAppName."\n\n";
$ms .= STANDARD_NOTIFY_FOOTER;
@@ -338,24 +338,24 @@ if ($sub)
{
$email = "no one";
}
addmsg("mesage sent to: ".$email, green);
addmsg("mesage sent to: ".$email, "green");
}
//done
addmsg("<a href=".apidb_fullurl("appview.php")."?appId=".$appParent."&versionId=".$appVersion.">Veiw App</a>", "green");
addmsg("<a href=".apidb_fullurl("appview.php")."?appId=".$_REQUEST['appParent']."&versionId=".$_REQUEST['appVersion'].">Veiw App</a>", "green");
redirect(apidb_fullurl("admin/adminAppQueue.php"));
exit;
}
else if ($sub == 'Delete' && $queueId)
else if ($_REQUEST['sub'] == 'Delete' && $_REQUEST['queueId'])
{
//delete main item
$query = "DELETE from appQueue where queueId = $queueId;";
$query = "DELETE from appQueue where queueId = ".$_REQUEST['queueId'].";";
$result = mysql_query($query);
if(!$result)
{
//error
addmsg("Internal Error: unable to delete selected application!", "red");
redirect(apidb_fullurl("admin/adminAppQueue.php?appId=$appId&versionId=$versionId"));
redirect(apidb_fullurl("admin/adminAppQueue.php?appId=".$_REQUEST['appId']."&versionId=".$_REQUEST['versionId']));
}
else
{
@@ -364,7 +364,7 @@ if ($sub)
{
if($ob->queueCatId == -1) //app version
{
$fullAppName = lookupAppName($appParent)." Version: ".$ob->queueVersion;
$fullAppName = lookupAppName($_REQUEST['appParent'])." Version: ".$ob->queueVersion;
} else
{
$fullAppName = $ob->queueName." Version: ".$ob->queueVersion;
@@ -381,7 +381,7 @@ if ($sub)
}
//success
addmsg("Application was successfully deleted from the Queue.", "green");
redirect(apidb_fullurl("admin/adminAppQueue.php?appId=$appId&versionId=$versionId"));
redirect(apidb_fullurl("admin/adminAppQueue.php?appId=".$_REQUEST['appId']."&versionId=".$_REQUEST['versionId']));
}
}
else

View File

@@ -11,7 +11,8 @@ require(BASE."include/"."category.php");
function admin_menu()
{
global $catId;
if(isset($_REQUEST['catId'])) $catId=$_REQUEST['catId'];
else $catId="";
$m = new htmlmenu("Admin");
$m->add("Edit this Category", $apidb_root."admin/editCategory.php?catId=$catId");
@@ -22,10 +23,8 @@ function admin_menu()
$m->done();
}
$catId = $_REQUEST['catId'];
if(!$catId)
$catId = 0; // ROOT
if(isset($_REQUEST['catId'])) $catId=$_REQUEST['catId'];
else $catId=0; // ROOT
if( !is_numeric($catId) )
{

View File

@@ -67,7 +67,7 @@ if($email)
$fullAppName = "Application: ".lookupAppName($appId)." Version: ".lookupVersionName($appId, $versionId);
$ms .= APPDB_ROOT."appview.php?appId=$appId&versionId=$versionId\n";
$ms .= "\n";
$ms .= ($current->username ? $current->username : "Anonymous")." deleted comment from ".$fullAppName."\n";
$ms .= ($_SESSION['current']->username ? $_SESSION['current']->username : "Anonymous")." deleted comment from ".$fullAppName."\n";
$ms .= "\n";
$ms .= "Subject: ".$subject."\n";
$ms .= "\n";

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;

View File

@@ -33,7 +33,7 @@ if(!$result || mysql_num_rows($result) == 0)
}
//display admin menu
if(loggedin() && (havepriv("admin") || $current->ownsApp($appId))) {
if(loggedin() && (havepriv("admin") || $_SESSION['current']->ownsApp($appId))) {
apidb_sidebar_add("admin_menu");
}

View File

@@ -11,8 +11,6 @@ if(!loggedin())
function build_prefs_list()
{
global $current;
opendb();
$result = mysql_query("SELECT * FROM prefs_list ORDER BY id");
@@ -37,19 +35,19 @@ function build_prefs_list()
}
$input = html_select("pref_$r->name", explode('|', $r->value_list),
$current->getpref($r->name, $r->def_value));
$_SESSION['current']->getpref($r->name, $r->def_value));
echo html_tr(array("&nbsp; $r->description", $input));
}
}
function show_user_fields()
{
global $current;
$user = new User();
$ext_username = $current->username;
$ext_realname = $user->lookup_realname($current->userid);
$ext_email = $user->lookup_email($current->userid);
$ext_username = $_SESSION['current']->username;
$ext_realname = $user->lookup_realname($_SESSION['current']->userid);
$ext_email = $user->lookup_email($_SESSION['current']->userid);
include(BASE."include/"."form_edit.php");
}
@@ -57,7 +55,7 @@ function show_user_fields()
if($HTTP_POST_VARS)
{
global $ext_username, $ext_password1, $ext_password2, $ext_realname, $ext_email;
global $current;
$user = new User();
@@ -65,7 +63,7 @@ if($HTTP_POST_VARS)
{
if(!ereg("^pref_(.+)$", $key, $arr))
continue;
$current->setpref($arr[1], $value);
$_SESSION['current']->setpref($arr[1], $value);
}
if ($ext_password == $ext_password2)
@@ -77,7 +75,7 @@ if($HTTP_POST_VARS)
addmsg("The Passwords you entered did not match.", "red");
}
if ($user->update($current->userid, $passwd, $ext_realname, $ext_email))
if ($user->update($_SESSION['current']->userid, $passwd, $ext_realname, $ext_email))
{
addmsg("Preferences Updated", "green");
}
@@ -90,7 +88,7 @@ if($HTTP_POST_VARS)
apidb_header("User Preferences");
echo "<form method=post action='preferences.php'>\n";
echo html_frame_start("Preferences for $current->username", "80%");
echo html_frame_start("Preferences for ".$_SESSION['current']->username, "80%");
echo html_table_begin("width='100%' border=0 align=left cellspacing=0 class='box-body'");
show_user_fields();

View File

@@ -4,7 +4,7 @@ include("path.php");
require(BASE."include/"."incl.php");
require(BASE."include/"."application.php");
global $current;
/*=========================================================================
*
@@ -44,7 +44,7 @@ if($cmd)
$fullAppName = "Application: ".lookupAppName($appId)." Version: ".lookupVersionName($appId, $versionId);
$ms .= APPDB_ROOT."screenshots.php?appId=$appId&versionId=$versionId"."\n";
$ms .= "\n";
$ms .= ($current->username ? $current->username : "Anonymous")." added screenshot ".$screenshot_desc." to ".$fullAppName."\n";
$ms .= ($_SESSION['current']->username ? $_SESSION['current']->username : "Anonymous")." added screenshot ".$screenshot_desc." to ".$fullAppName."\n";
$ms .= "\n";
$ms .= STANDARD_NOTIFY_FOOTER;
@@ -79,7 +79,7 @@ if($cmd)
$fullAppName = "Application: ".lookupAppName($appId)." Version: ".lookupVersionName($appId, $versionId);
$ms .= APPDB_ROOT."screenshots.php?appId=$appId&versionId=$versionId"."\n";
$ms .= "\n";
$ms .= ($current->username ? $current->username : "Anonymous")." deleted screenshot from ".$fullAppName."\n";
$ms .= ($_SESSION['current']->username ? $_SESSION['current']->username : "Anonymous")." deleted screenshot from ".$fullAppName."\n";
$ms .= "\n";
$ms .= STANDARD_NOTIFY_FOOTER;
@@ -137,7 +137,7 @@ else
$img = '<a href="javascript:openWin(\'appimage.php?imageId='.$ob->id.'\',\''.$randName.'\','.$size[0].','.$size[1].');">'.$imgSRC.'</a>';
if (loggedin())
{
if ($current->getpref("window:screenshot") == "no")
if ($_SESSION['current']->getpref("window:screenshot") == "no")
{
$img = '<a href="appimage.php?imageId='.$ob->id.'">'.$imgSRC.'</a>';
}

View File

@@ -4,7 +4,7 @@ include("path.php");
require(BASE."include/"."incl.php");
require(BASE."include/"."application.php");
$search = str_replace("'", "\\'", $q);
$search = str_replace("'", "\\'", $_REQUEST['q']);
$search = "%$search%";
$query = "SELECT * FROM appFamily WHERE appName != 'NONAME' AND appName LIKE '$search' ORDER BY appName";

View File

@@ -17,9 +17,9 @@ opendb();
if(loggedin())
{
if($current->getpref("query:hide_header") == "yes")
if($_SESSION['current']->getpref("query:hide_header") == "yes")
disable_header();
if($current->getpref("query:hide_sidebar") == "yes")
if($_SESSION['current']->getpref("query:hide_sidebar") == "yes")
disable_sidebar();
}