Eliminate some php notices caused by use of uninitialized variables

This commit is contained in:
Edwin Smulders
2007-07-24 01:45:19 +00:00
committed by WineHQ
parent f961187287
commit 023ece493b
26 changed files with 150 additions and 110 deletions

View File

@@ -6,8 +6,9 @@ require_once(BASE."include/category.php");
if(!$_SESSION['current']->hasPriv("admin"))
util_show_error_page_and_exit();
$aClean['iCatId'] = (isset($aClean['iCatId']) ? $aClean['iCatId'] : '');
$oCat = new Category( $aClean['iCatId'] );
if($aClean['sSubmit'])
if(isset($aClean['sSubmit']))
{
$oCat->update($aClean['sName'],$aClean['sDescription'],$aClean['iParentId']);
util_redirect_and_exit(apidb_fullurl("appbrowse.php?iCatId=".$oCat->iCatId));

View File

@@ -14,7 +14,7 @@ require_once(BASE."include/bugs.php");
if(!$_SESSION['current']->hasPriv("admin"))
util_show_error_page_and_exit("Insufficient privileges.");
if ($aClean['sSub'])
if (isset($aClean['sSub']))
{
if(($aClean['sSub'] == 'delete' ) && ($aClean['iBuglinkId']))
{
@@ -34,15 +34,12 @@ if ($aClean['sSub'])
apidb_header("Administer Bugs");
$pageRange = 10;
$ItemsPerPage = 10;
$currentPage = 1;
$QueuedOnly = empty($aClean['sQueuedOnly'])? NULL: $aClean['sQueuedOnly'];
$BugLinks = ($QueuedOnly == 'on')?getNumberOfQueuedBugLinks():getNumberOfBugLinks();
if($aClean['iItemsPerPage'])
$ItemsPerPage = $aClean['iItemsPerPage'];
if($aClean['iPage'])
$currentPage = $aClean['iPage'];
$ItemsPerPage = isset($aClean['iItemsPerPage']) ? $aClean['iItemsPerPage'] : 10;
$currentPage = isset($aClean['iPage']) ? $aClean['iPage'] : 1;
$ItemsPerPage = min($ItemsPerPage,100);
$totalPages = max(ceil($BugLinks/$ItemsPerPage),1);

View File

@@ -12,13 +12,8 @@ apidb_header("Comments");
/* display a range of 10 pages */
$pageRange = 10;
$ItemsPerPage = 10;
$currentPage = 1;
if($aClean['iItemsPerPage'])
$ItemsPerPage = $aClean['iItemsPerPage'];
if($aClean['iPage'])
$currentPage = $aClean['iPage'];
$ItemsPerPage = isset($aClean['iItemsPerPage']) ? $aClean['iItemsPerPage'] : 10;
$currentPage = isset($aClean['iPage']) ? $aClean['iPage'] : 1;
$totalPages = ceil(getNumberOfComments()/$ItemsPerPage);

View File

@@ -16,7 +16,7 @@ if(!$_SESSION['current']->hasPriv("admin"))
apidb_header("Admin Maintainers");
echo '<form name="sQform" action="adminMaintainers.php" method="post" enctype="multipart/form-data">',"\n";
if ($aClean['sSub'])
if (isset($aClean['sSub']))
{
if($aClean['sSub'] == 'delete')
{

View File

@@ -16,7 +16,7 @@ if(!$_SESSION['current']->hasPriv("admin"))
/*
* We issued a delete command.
*/
if($aClean['sCmd'])
if(isset($aClean['sCmd']))
{
// process screenshot deletion
if($aClean['sCmd'] == "delete" && is_numeric($aClean['iImageId']))
@@ -33,7 +33,7 @@ if($aClean['sCmd'])
apidb_header("Screenshots");
// regenerate all screenshots
if($aClean['sRegenerate'])
if(isset($aClean['sRegenerate']))
{
$sQuery = "SELECT id FROM appData WHERE type = 'screenshot'";
$hResult = query_parameters($sQuery);
@@ -55,13 +55,8 @@ echo "</center>";
/* display a range of 10 pages */
$pageRange = 10;
$ItemsPerPage = 6;
$currentPage = 1;
if($aClean['iItemsPerPage'])
$ItemsPerPage = $aClean['iItemsPerPage'];
if($aClean['iPage'])
$currentPage = $aClean['iPage'];
$ItemsPerPage = isset($aClean['iItemsPerPage']) ? $aClean['iItemsPerPage'] : 6;
$currentPage = isset($aClean['iPage']) ? $aClean['iPage'] : 1;
$ItemsPerPage = min($ItemsPerPage,100);
$totalPages = ceil(appData::objectGetEntriesCount("all", false,

View File

@@ -13,28 +13,70 @@ if(!$_SESSION['current']->hasPriv("admin"))
// we want to delete a user
if($aClean['sAction'] == "delete" && is_numeric($aClean['iUserId']))
if(isset($aClean['sAction']) && $aClean['sAction'] == "delete" &&
is_numeric($aClean['iUserId']))
{
$oUser = new User($aClean['iUserId']);
$oUser->delete();
}
// search form
echo html_frame_start("Users Management","400","",0)
echo html_frame_start("Users Management","400","",0);
$aClean['sSearch'] = isset($aClean['sSearch']) ? $aClean['sSearch'] : '';
$sLimit100 = $sLimit200 = $sLimit500 = '';
if ( isset($aClean['iLimit']) )
{
switch ($aClean['iLimit'])
{
case '100':
$sLimit100 = 'selected';
break;
case '200':
$sLimit200 = 'selected';
break;
case '500':
$sLimit500 = 'selected';
break;
}
}
$sOrder1 = $sOrder2 = $sOrder3 = '';
if ( isset($aClean['sOrderBy']) )
{
switch ($aClean['sOrderBy'])
{
case 'email':
$sOrder1 = 'selected';
break;
case 'realname':
$sOrder2 = 'selected';
break;
case 'created':
$sOrder3 = 'selected';
break;
}
}
?>
<form action="<?php echo $_SERVER['PHP_SELF'];?>" method="post">
<table width="100%" border=0 cellpadding=0 cellspacing=0>
<tr>
<td class="color1">Pattern</td>
<td><input type="text" name="sSearch" value="<?php echo $aClean['sSearch'];?>"/><br /><small>(leave blank to match all)</small></td>
<td>
<input type="text" name="sSearch" value="<?php echo $aClean['sSearch'];?>"/>
<br /><small>(leave blank to match all)</small>
</td>
</tr>
<tr>
<td class="color1">Show first</td>
<td>
<select name="iLimit">
<option value="100"<?php if($aClean['iLimit']=="100")echo" SELECTED";?>>100 results</option>
<option value="200"<?php if($aClean['iLimit']=="200")echo" SELECTED";?>>200 results</option>
<option value="500"<?php if($aClean['iLimit']=="500")echo" SELECTED";?>>500 result</option>
<option value="100" <?php echo $sLimit100; ?>>100 results</option>
<option value="200" <?php echo $sLimit200; ?>>200 results</option>
<option value="500" <?php echo $sLimit500; ?>>500 results</option>
</select>
</td>
</tr>
@@ -42,9 +84,9 @@ echo html_frame_start("Users Management","400","",0)
<td class="color1">Order by</td>
<td>
<select name="sOrderBy">
<option value="email"<?php if($aClean['sOrderBy']=="email")echo" SELECTED";?>>e-mail</option>
<option value="realname"<?php if($aClean['sOrderBy']=="realname")echo" SELECTED";?>>real name</option>
<option value="created"<?php if($aClean['sOrderBy']=="created")echo" SELECTED";?>>creation date</option>
<option value="email" <?php echo $sOrder1;?>>e-mail</option>
<option value="realname" <?php echo $sOrder2;?>>real name</option>
<option value="created" <?php echo $sOrder3;?>>creation date</option>
</select>
</td>
</tr>
@@ -57,7 +99,7 @@ echo html_frame_start("Users Management","400","",0)
echo html_frame_end();
// if the search form was submitted
if($aClean['sSubmit'])
if(isset($aClean['sSubmit']))
{
echo html_frame_start("Query Results","90%","",0);
echo "<table width='100%' border=0 cellpadding=3 cellspacing=0>\n\n";

View File

@@ -24,13 +24,14 @@ function admin_menu()
$m->done();
}
$iCatId = isset($aClean['iCatId']) ? $aClean['iCatId'] : 0;
// list sub categories
$oCat = new Category($aClean['iCatId']?$aClean['iCatId']:"0");
$oCat = new Category( $iCatId );
$sCatFullPath = Category::make_cat_path($oCat->getCategoryPath());
$subs = $oCat->aSubcatsIds;
//display admin box
if($_SESSION['current']->hasPriv("admin") && $aClean['iCatId'] != 0)
if($_SESSION['current']->hasPriv("admin") && isset($aClean['iCatId']) && $aClean['iCatId'] != 0 )
apidb_sidebar_add("admin_menu");
//output header
@@ -96,7 +97,7 @@ if($subs)
// output the table
echo $oTable->GetString();
echo html_frame_end("$c categories");
echo html_frame_end( count($subs) . ' categories');
}
@@ -156,7 +157,7 @@ if($apps)
// output table
echo $oTable->GetString();
echo html_frame_end("$c applications in this category");
echo html_frame_end( count($apps) . " applications in this category");
}
// Disabled for now

View File

@@ -27,8 +27,6 @@ require_once(BASE."include/category.php");
require_once(BASE."include/maintainer.php");
require_once(BASE."include/monitor.php");
$oApp = new Application($aClean['iAppId']);
$oVersion = new Version($aClean['iVersionId']);
/**
* Displays the SUB apps that belong to this application.
@@ -76,7 +74,7 @@ function display_bundle($iAppId)
if(empty($aClean['iAppId']) && empty($aClean['iVersionId']))
util_show_error_page_and_exit("Something went wrong with the application or version id");
if ($aClean['sSub'])
if (isset($aClean['sSub']))
{
if(($aClean['sSub'] == 'delete' ) && ($aClean['iBuglinkId']))
{
@@ -135,14 +133,15 @@ if ($aClean['sSub'])
/**
* We want to see an application family (=no version).
*/
if($aClean['iAppId'])
if( isset($aClean['iAppId']) )
{
$oApp = new Application($aClean['iAppId']);
$oApp->display();
} else if($aClean['iVersionId']) // We want to see a particular version.
} else if( isset($aClean['iVersionId']) ) // We want to see a particular version.
{
$oVersion = new Version($aClean['iVersionId']);
$oVersion->display($aClean['iTestingId']);
$iTestingId = isset($aClean['iTestingId']) ? $aClean['iTestingId'] : null;
$oVersion->display($iTestingId);
} else
{
// Oops! Called with no params, bad llamah!

View File

@@ -12,13 +12,14 @@ apidb_header("Browse Downloadable Applications");
echo "<div class='default_container'>\n";
/* Match specific license? */
$sLicense = version::checkLicense($aClean['sLicense']);
$sLicenseString = isset($aClean['sLicense']) ? $aClean['sLicense'] : '';
$sLicense = version::checkLicense( $sLicenseString );
/* Set default values */
if(!$aClean['iNumVersions'] || $aClean['iNumVersions'] > 200 || $aClean['iNumVersions'] < 0)
if(!isset($aClean['iNumVersions']) || $aClean['iNumVersions'] > 200 || $aClean['iNumVersions'] < 0)
$aClean['iNumVersions'] = 25;
if(!$aClean['iPage'])
if( !isset($aClean['iPage']) )
$aClean['iPage'] = 1;
/* Count the possible matches */
@@ -39,7 +40,7 @@ else
if($hResult && mysql_num_rows($hResult))
$num = mysql_num_rows($hResult);
$iNumPages = ceil($num / $aClean['iNumVersions']);
$iNumPages = isset($num) ? ceil($num/$aClean['iNumVersions']) : 0;
/* Check page logic */
$aClean['iPage'] = min($aClean['iPage'], $iNumPages);
@@ -50,9 +51,11 @@ $iLimitLower = ($aClean['iPage'] - 1) * $aClean['iNumVersions'];
/* Page selection */
echo "<div align=\"center\">\n";
echo "<b>Page ".$aClean['iPage']." of $iNumPages</b><br />\n";
// $iPageRange is non-existent here? creating it
$iPageRange = 10;
display_page_range($aClean['iPage'], $iPageRange, $iNumPages,
$_SERVER['PHP_SELF']."?iNumVersions=".$aClean['iNumVersions']."&sLicense=".
$aClean['sLicense']);
$sLicenseString);
/* Selector for how many versions to display */
echo "<form method=\"get\" action=\"".$_SERVER['PHP_SELF']."\">\n";
@@ -78,7 +81,7 @@ echo $oVersion->makeLicenseList($sLicense);
echo " <input type=\"submit\" value=\"Refresh\" />\n";
echo "</form></div>\n<br />\n";
if(!$num)
if(!isset($num))
{
echo "<div align=\"center\"><font color=\"red\">No matches found</font></div>\n";
echo html_frame_end("&nbsp;");

View File

@@ -8,7 +8,7 @@ require(BASE."include/"."incl.php");
$help_path = BASE."/help";
if($aClean['sTopic'])
if(isset($aClean['sTopic']))
{
display_help($aClean['sTopic']);
} else {

View File

@@ -258,6 +258,8 @@ class appData
{
if($sQueued == "true" || $sQueued == "false")
$sAppDataQueued = " AND appData.queued = '$sQueued'";
else
$sAppDataQueued = '';
if($sType)
$sSelectType = " AND type = '?'";

View File

@@ -879,7 +879,7 @@ class Application {
if($_SESSION['current']->hasPriv("admin"))
return TRUE;
if(is_object($this) && $this->iAppId)
if(isset($this) && is_object($this) && $this->iAppId)
{
if(maintainer::isUserSuperMaintainer($_SESSION['current'],
$this->iAppId))

View File

@@ -435,7 +435,7 @@ class Comment {
else
$mode = "threaded"; /* default non-logged in users to threaded comment display mode */
if ($aClean['sMode']=="nested")
if ( isset($aClean['sMode']) && $aClean['sMode']=="nested")
$mode = "nested";
switch ($mode)

View File

@@ -50,6 +50,8 @@ class downloadurl
if(!($hResult = appData::getData($iVersionId, "downloadurl")))
return FALSE;
// we're appending, so initialize it
$sReturn = '';
for($i = 0; $oRow = mysql_fetch_object($hResult); $i++)
{
$sReturn .= html_tr(array(

View File

@@ -22,9 +22,10 @@ class error_log
$sQuery = 'INSERT INTO error_log (submitTime, userid, type, log_text, request_text, deleted) '.
"VALUES(?, '?', '?', '?', '?', '?')";
$iUser = (isset($_SESSION['current']) ? $_SESSION['current']->iUserId : 0);
$hResult = query_parameters($sQuery,
"NOW()",
$_SESSION['current']->iUserId,
$iUser,
$sErrorType,
$sLogText,
$sRequestText,

View File

@@ -9,7 +9,7 @@ echo '<form method="post" name="sFlogin" action="account.php">',"\n";
echo html_frame_start("Login to Application DB","400","",0);
/* Pass on the URL we should return to after log-in */
global $aClean;
echo '<input type="hidden" name="sReturnTo" value="'.$aClean['sReturnTo'].'" />';
echo '<input type="hidden" name="sReturnTo" value="' . (isset($aClean['sReturnTo']) ? $aClean['sReturnTo'] : '') . '" />';
?>
<!-- start of login form -->

View File

@@ -31,7 +31,7 @@ echo html_frame_start("Create New Application DB Account","400","",0)
<?php
echo "<tr><td class=color1>&nbsp; Wine version </td><td class=color0>";
make_bugzilla_version_list("sWineRelease", $aClean['sWineRelease']);
echo make_bugzilla_version_list("sWineRelease", isset($aClean['sWineRelease']) ? $aClean['sWineRelease'] : '');
echo "</td></tr>";
?>

View File

@@ -47,13 +47,15 @@ class Monitor {
WHERE userId = '".$iUserId."'
AND versionId = '".$iVersionId."'";
$hResult = query_appdb($sQuery);
$oRow = mysql_fetch_object($hResult);
if( $oRow = mysql_fetch_object($hResult) )
{
$this->iMonitorId = $oRow->monitorId;
$this->iAppId = $oRow->appId;
$this->iVersionId = $oRow->versionId;
$this->iUserId = $oRow->userId;
}
}
}
/*
* Creates a new Monitor.

View File

@@ -492,7 +492,7 @@ class ObjectManager
// is the value we modify and we'll be passing that into methods in the future
global $aClean;
if(!$aClean['sSubmit'])
if(!isset($aClean['sSubmit']))
return;
$this->checkMethods(array("getOutputEditorValues", "update", "create",
@@ -513,12 +513,11 @@ class ObjectManager
// handle the common response radio button value
// if sReplyText is empty, if sOMCommonReply was set because
// the user selected a radio button then use that text instead
if(($aClean['sReplyText'] == "") && isset($aClean['sOMCommonReply']))
if( isset($aClean['sReplyText']) && $aClean['sReplyText'] == "" && isset($aClean['sOMCommonReply']))
{
$aClean['sReplyText'] = $aClean['sOMCommonReply'];
}
$oObject->getOutputEditorValues($aClean);
/* Check input, if necessary */
@@ -635,10 +634,7 @@ class ObjectManager
function getIdFromInput($aClean)
{
$sId = "i".ucfirst($this->sClass)."Id";
$iId = $aClean['sId'];
if(!$iId)
$iId = $aClean['iId'];
$iId = isset($aClean['sId']) ? $aClean['sId'] : $aClean['iId'];
return $iId;
}
@@ -678,12 +674,11 @@ class ObjectManager
$aItemsPerPage = $aReturn[0];
$iDefaultPerPage = $aReturn[1];
$iItemsPerPage = $iDefaultPerPage;
foreach($aItemsPerPage as $iNum)
{
if($iNum == $aClean['iItemsPerPage'])
if ( isset($aClean['iItemsPerPage']) && in_array($aClean['iItemsPerPage'], $aItemsPerPage) )
$iItemsPerPage = $aClean['iItemsPerPage'];
}
$sControls = "<form action=\"".$this->makeUrl()."\" method=\"get\">";
@@ -705,9 +700,7 @@ class ObjectManager
$iNumPages = ceil($iTotalEntries / $iItemsPerPage);
/* Check current page value */
$iPage = $aClean['iPage'];
if(!$iPage)
$iPage = 1;
$iPage = isset($aClean['iPage']) ? $aClean['iPage'] : 1;
$iCurrentPage = min($iPage, $iNumPages);
/* Display selectors and info */
@@ -778,7 +771,7 @@ class MultiPage
function getDataFromInput($aClean)
{
if($aClean['iItemsPerPage'] && $aClean['iPage'])
if(isset($aClean['iItemsPerPage']) && isset($aClean['iPage']))
$this->bEnabled = TRUE;
else
return;

View File

@@ -401,6 +401,9 @@ class screenshot
function get_random_screenshot_img($iAppId = null, $iVersionId = null,
$bFormatting = true)
{
// initialize variables to avoid notices when appending to them
$sImgFile = '';
$sImg = '';
// we want a random screenshots for this app
if($iAppId && !$iVersionId)
{

View File

@@ -444,7 +444,7 @@ class testData{
$link = mysql_real_escape_string($link);
$iDisplayLimit = mysql_real_escape_string($iDisplayLimit);
$sShowAll = $aClean['sShowAll'];
$sShowAll = isset($aClean['sShowAll']) ? $aClean['sShowAll'] : false;
$sQuery = "SELECT *
FROM testResults

View File

@@ -402,6 +402,8 @@ function cleanupSearchWords($search_words)
/* search each word in $search_words */
$split_words = split(" ", $search_words);
$removed_words = '';
foreach($split_words as $key=>$value)
{
/* see if this word is in the ignore list */

View File

@@ -67,6 +67,8 @@ if(!$_SESSION['current']->isLoggedIn())
echo "There are <b>$iNumApps</b> applications currently in the database";
// don't mention the top application if there are no votes yet
if( !empty($oRow) )
{
if($oRow->versionId)
{
$shVoteAppLink = version::fullNameLink($oRow->versionId);
@@ -77,6 +79,7 @@ if(!$_SESSION['current']->isLoggedIn())
echo " please <a href=\"".BASE."help/?sTopic=voting\" title=\"help on voting\"".
"style=\"cursor: help\">vote</a> for your favourite application.\n";
}
}
?>
<br /><br />

View File

@@ -25,7 +25,7 @@ require_once(BASE.'include/testData_queue.php');
require_once(BASE.'include/browse_newest_apps.php');
/* if we have no valid class name we should abort */
if(!$aClean['sClass'])
if(!isset($aClean['sClass']))
{
echo "No class defined.\n";
exit;
@@ -38,13 +38,16 @@ if(!class_exists($aClean['sClass']))
exit;
}
$aClean['iId'] = isset($aClean['iId']) ? $aClean['iId'] : 0;
$oObject = new objectManager($aClean['sClass'], $aClean['sTitle'], $aClean['iId']);
if($aClean['bIsQueue'] == 'true')
if(isset($aClean['bIsQueue']) && $aClean['bIsQueue'] == 'true')
$oObject->bIsQueue = true;
else
$oObject->bIsQueue = false;
$aClean['bIsRejected'] = isset($aClean['bIsRejected']) ? $aClean['bIsRejected'] : false;
/* If it is rejected it is defined as queued */
if($aClean['bIsRejected'] == 'true')
{
@@ -65,7 +68,7 @@ $sErrors = $oObject->processForm($aClean);
if($oObject->iId && $aClean['sAction'] == "delete")
$oObject->delete_entry();
if($aClean['sAction'] == "add")
if(isset($aClean['sAction']) && $aClean['sAction'] == "add")
$oObject->handle_anonymous_submission();
/* Provided the necessary values are present, an object's children may be moved
@@ -96,7 +99,7 @@ if($oObject->iId)
$oObject->view($_SERVER['REQUEST_URI']);
break;
}
} else if ($aClean['sAction'] == "add")
} else if (isset($aClean['sAction']) && $aClean['sAction'] == "add")
{
$oObject->add_entry($_SERVER['REQUEST_URI'], $sErrors);
} else

View File

@@ -108,8 +108,9 @@ if(!$_SESSION['current']->isLoggedIn())
// we come from the administration to edit an user
if($_SESSION['current']->hasPriv("admin") &&
is_numeric($aClean['iUserId']) &&
is_numeric($aClean['iLimit']) &&
isset($aClean['iUserId']) &&
isset($aClean['iLimit']) &&
isset($aClean['sOrderBy']) &&
in_array($aClean['sOrderBy'],array("email","realname","created"))
)
{
@@ -119,7 +120,7 @@ if($_SESSION['current']->hasPriv("admin") &&
$oUser = &$_SESSION['current'];
}
if($aClean['sSubmit'] == "Update")
if(isset($aClean['sSubmit']) && $aClean['sSubmit'] == "Update")
{
while(list($sKey, $sValue) = each($aClean))
{
@@ -182,7 +183,7 @@ echo "<div class='default_container'>\n";
echo "<form method=\"post\" action=\"preferences.php\">\n";
// if we manage another user we give the parameters to go back to the admin
if($oUser->iUserId == $aClean['iUserId'])
if( isset($aClean['iUserId']) && $oUser->iUserId == $aClean['iUserId'])
{
echo "<input type=\"hidden\" name=\"iLimit\" value=\"".$aClean['iLimit']."\">\n";
echo "<input type=\"hidden\" name=\"sOrderBy\" value=\"".$aClean['sOrderBy']."\">\n";
@@ -210,7 +211,7 @@ foreach($aTableRows as $oTableRow)
$oTable->AddRow($oTableRow);
// if we don't manage another user
if($oUser->iUserId != $aClean['iUserId'])
if( !isset($aClean['iUserId']) || $oUser->iUserId != $aClean['iUserId'])
{
$aTableRows = build_prefs_list($oUser);
foreach($aTableRows as $oTableRow)

View File

@@ -16,13 +16,8 @@ echo "<div class='default_container'>\n";
/* display a range of 10 pages */
$pageRange = 10;
$ItemsPerPage = 6;
$currentPage = 1;
if($aClean['iItemsPerPage'])
$ItemsPerPage = $aClean['iItemsPerPage'];
if($aClean['iPage'])
$currentPage = $aClean['iPage'];
$ItemsPerPage = isset($aClean['iItemsPerPage']) ? $aClean['iItemsPerPage'] : 6;
$currentPage = isset($aClean['iPage']) ? $aClean['iPage'] : 1;
$ItemsPerPage = min($ItemsPerPage,100);
$totalPages = ceil(appData::objectGetEntriesCount("false", false,