2004-03-15 16:22:00 +00:00
|
|
|
<?php
|
|
|
|
|
function build_urlarg($vars)
|
|
|
|
|
{
|
|
|
|
|
$arr = array();
|
|
|
|
|
while(list($key, $val) = each($vars))
|
|
|
|
|
{
|
|
|
|
|
if(is_array($val))
|
|
|
|
|
{
|
|
|
|
|
while(list($idx, $value) = each($val))
|
|
|
|
|
{
|
|
|
|
|
//echo "Encoding $key / $value<br>";
|
|
|
|
|
$arr[] = rawurlencode($key."[]")."=".rawurlencode($value);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
$arr[] = $key."=".rawurlencode($val);
|
|
|
|
|
}
|
|
|
|
|
return implode("&", $arr);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
* return all values of a mapping as an array
|
|
|
|
|
*/
|
|
|
|
|
function values($arr)
|
|
|
|
|
{
|
|
|
|
|
$res = array();
|
|
|
|
|
while(list($k, $v) = each($arr))
|
|
|
|
|
$res[] = $v;
|
|
|
|
|
return $res;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
* format date
|
|
|
|
|
*/
|
2005-02-20 01:55:53 +00:00
|
|
|
function print_date($sTimestamp)
|
2004-03-15 16:22:00 +00:00
|
|
|
{
|
2005-02-20 01:55:53 +00:00
|
|
|
return date("F d Y H:i:s", $sTimestamp);
|
2004-03-15 16:22:00 +00:00
|
|
|
}
|
|
|
|
|
|
2005-02-20 01:55:53 +00:00
|
|
|
function mysqltimestamp_to_unixtimestamp($sTimestamp)
|
|
|
|
|
{
|
|
|
|
|
$d = substr($sTimestamp,6,2); // day
|
|
|
|
|
$m = substr($sTimestamp,4,2); // month
|
|
|
|
|
$y = substr($sTimestamp,0,4); // year
|
|
|
|
|
$hours = substr($sTimestamp,8,2); // year
|
|
|
|
|
$minutes = substr($sTimestamp,10,2); // year
|
|
|
|
|
$seconds = substr($sTimestamp,12,2); // year
|
|
|
|
|
return mktime($hours,$minutes,$seconds,$m, $d, $y);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function mysqldatetime_to_unixtimestamp($sDatetime)
|
|
|
|
|
{
|
|
|
|
|
sscanf($sDatetime, "%4s-%2s-%2s %2s:%2s:%2s",
|
|
|
|
|
&$y, &$m, &$d,
|
|
|
|
|
&$hours, &$minutes, &$seconds);
|
|
|
|
|
return mktime($hours,$minutes,$seconds,$m, $d, $y);
|
|
|
|
|
}
|
2004-03-15 16:22:00 +00:00
|
|
|
|
|
|
|
|
function get_remote()
|
|
|
|
|
{
|
|
|
|
|
global $REMOTE_HOST, $REMOTE_ADDR;
|
|
|
|
|
|
|
|
|
|
if($REMOTE_HOST)
|
|
|
|
|
$ip = $REMOTE_HOST;
|
|
|
|
|
else
|
|
|
|
|
$ip = $REMOTE_ADDR;
|
|
|
|
|
|
|
|
|
|
return $ip;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function htmlify_urls($text)
|
|
|
|
|
{
|
|
|
|
|
//FIXME: wonder what the syntax is, this doesn't seem to work
|
|
|
|
|
// $text = strip_tags($text, "<a>,<b>,<i>,<ul>,<li>");
|
|
|
|
|
|
|
|
|
|
// html-ify urls
|
|
|
|
|
$urlreg = "([a-zA-Z]+://([^\t\r\n ]+))";
|
|
|
|
|
$text = ereg_replace($urlreg, "<a href=\"\\1\"> \\2 </a>", $text);
|
|
|
|
|
|
|
|
|
|
$emailreg = "([a-zA-Z0-9_%+.-]+@[^\t\r\n ]+)";
|
|
|
|
|
$text = ereg_replace($emailreg, " <a href='mailto:\\1'>\\1</a>", $text);
|
|
|
|
|
|
|
|
|
|
$text = str_replace("\n", "<br>", $text);
|
|
|
|
|
|
|
|
|
|
return $text;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// open file and display contents of selected tag
|
|
|
|
|
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 . ">(.*)</" . $mode . ">", $data, $out))
|
|
|
|
|
{
|
|
|
|
|
return $out[1];
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
return null;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2004-12-13 03:50:11 +00:00
|
|
|
/* bugzilla functions */
|
|
|
|
|
function make_bugzilla_version_list($varname, $cvalue)
|
|
|
|
|
{
|
2004-12-23 01:12:03 +00:00
|
|
|
$table = BUGZILLA_DB.".versions";
|
|
|
|
|
$where = "WHERE product_id=".BUGZILLA_PRODUCT_ID;
|
2004-12-13 03:50:11 +00:00
|
|
|
$query = "SELECT value FROM $table $where ORDER BY value";
|
|
|
|
|
|
2005-01-12 02:44:49 +00:00
|
|
|
$result = query_bugzilladb($query);
|
|
|
|
|
if(!$result) return;
|
2004-12-13 03:50:11 +00:00
|
|
|
|
|
|
|
|
echo "<select name='$varname'>\n";
|
2005-01-19 16:53:07 +00:00
|
|
|
echo "<option value=\" \">Choose ...</option>\n";
|
2004-12-13 03:50:11 +00:00
|
|
|
while(list($value) = mysql_fetch_row($result))
|
|
|
|
|
{
|
2005-01-04 19:37:49 +00:00
|
|
|
if($value == $cvalue)
|
2004-12-13 03:50:11 +00:00
|
|
|
echo "<option value=$value selected>$value\n";
|
|
|
|
|
else
|
|
|
|
|
echo "<option value=$value>$value\n";
|
|
|
|
|
}
|
|
|
|
|
echo "</select>\n";
|
|
|
|
|
}
|
|
|
|
|
|
2005-01-04 19:37:49 +00:00
|
|
|
function make_maintainer_rating_list($varname, $cvalue)
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
echo "<select name='$varname'>\n";
|
2005-01-19 16:53:07 +00:00
|
|
|
echo "<option value=\" \">Choose ...</option>\n";
|
2005-01-04 19:37:49 +00:00
|
|
|
$aRating = array("Gold", "Silver", "Bronze", "Garbage");
|
|
|
|
|
$iMax = count($aRating);
|
|
|
|
|
|
|
|
|
|
for($i=0; $i < $iMax; $i++)
|
|
|
|
|
{
|
|
|
|
|
if($aRating[$i] == $cvalue)
|
|
|
|
|
echo "<option value=$aRating[$i] selected>$aRating[$i]\n";
|
|
|
|
|
else
|
|
|
|
|
echo "<option value=$aRating[$i]>$aRating[$i]\n";
|
|
|
|
|
}
|
|
|
|
|
echo "</select>\n";
|
|
|
|
|
}
|
|
|
|
|
|
2005-02-07 23:21:33 +00:00
|
|
|
/* get the number of queued applications */
|
2004-11-09 22:33:54 +00:00
|
|
|
function getQueuedAppCount()
|
|
|
|
|
{
|
2005-02-07 23:21:33 +00:00
|
|
|
$qstring = "SELECT count(*) as queued_apps FROM appFamily WHERE queued='true'";
|
2005-01-11 00:26:05 +00:00
|
|
|
$result = query_appdb($qstring);
|
2004-11-09 22:33:54 +00:00
|
|
|
$ob = mysql_fetch_object($result);
|
|
|
|
|
return $ob->queued_apps;
|
|
|
|
|
}
|
|
|
|
|
|
2005-05-05 02:52:51 +00:00
|
|
|
function getQueuedVersionCount()
|
|
|
|
|
{
|
|
|
|
|
$qstring = "SELECT count(*) as queued_versions FROM appVersion WHERE queued='true'";
|
|
|
|
|
$result = query_appdb($qstring);
|
|
|
|
|
$ob = mysql_fetch_object($result);
|
|
|
|
|
|
|
|
|
|
/* we don't want to count the versions that are implicit in the applications */
|
|
|
|
|
/* that are in the queue */
|
|
|
|
|
return $ob->queued_versions - getQueuedAppCount();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2005-02-07 23:21:33 +00:00
|
|
|
/* get the number of queued appdata */
|
2004-12-18 06:06:46 +00:00
|
|
|
function getQueuedAppDataCount()
|
|
|
|
|
{
|
2005-02-07 23:21:33 +00:00
|
|
|
$qstring = "SELECT count(*) as queued_appdata FROM appData WHERE queued='true'";
|
2005-01-11 00:26:05 +00:00
|
|
|
$result = query_appdb($qstring);
|
2004-12-18 06:06:46 +00:00
|
|
|
$ob = mysql_fetch_object($result);
|
|
|
|
|
return $ob->queued_appdata;
|
|
|
|
|
}
|
|
|
|
|
|
2005-02-07 23:21:33 +00:00
|
|
|
/* get the number of queued maintainers */
|
2004-11-09 22:41:18 +00:00
|
|
|
function getQueuedMaintainerCount()
|
|
|
|
|
{
|
|
|
|
|
$qstring = "SELECT count(*) as queued_maintainers FROM appMaintainerQueue";
|
2005-01-11 00:26:05 +00:00
|
|
|
$result = query_appdb($qstring);
|
2004-11-09 22:41:18 +00:00
|
|
|
$ob = mysql_fetch_object($result);
|
|
|
|
|
return $ob->queued_maintainers;
|
|
|
|
|
}
|
|
|
|
|
|
2004-12-08 03:46:38 +00:00
|
|
|
/* get the total number of maintainers and applications in the appMaintainers table */
|
|
|
|
|
function getMaintainerCount()
|
|
|
|
|
{
|
|
|
|
|
$qstring = "SELECT count(*) as maintainers FROM appMaintainers";
|
2005-01-11 00:26:05 +00:00
|
|
|
$result = query_appdb($qstring);
|
2004-12-08 03:46:38 +00:00
|
|
|
$ob = mysql_fetch_object($result);
|
|
|
|
|
return $ob->maintainers;
|
|
|
|
|
}
|
|
|
|
|
|
2004-12-29 03:44:17 +00:00
|
|
|
/* get the total number of vendors from the vendor table */
|
|
|
|
|
function getVendorCount()
|
|
|
|
|
{
|
|
|
|
|
$qstring = "SELECT count(*) as vendors FROM vendor";
|
2005-01-11 00:26:05 +00:00
|
|
|
$result = query_appdb($qstring);
|
2004-12-29 03:44:17 +00:00
|
|
|
$ob = mysql_fetch_object($result);
|
|
|
|
|
return $ob->vendors;
|
|
|
|
|
}
|
|
|
|
|
|
2004-12-01 22:26:50 +00:00
|
|
|
/* Get the number of users in the database */
|
|
|
|
|
function getNumberOfComments()
|
|
|
|
|
{
|
2005-01-11 00:26:05 +00:00
|
|
|
$result = query_appdb("SELECT count(*) as num_comments FROM appComments;");
|
2004-12-01 22:26:50 +00:00
|
|
|
$row = mysql_fetch_object($result);
|
|
|
|
|
return $row->num_comments;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Get the number of versions in the database */
|
|
|
|
|
function getNumberOfVersions()
|
|
|
|
|
{
|
2005-01-11 00:26:05 +00:00
|
|
|
$result = query_appdb("SELECT count(versionId) as num_versions FROM appVersion WHERE versionName != 'NONAME';");
|
2004-12-01 22:26:50 +00:00
|
|
|
$row = mysql_fetch_object($result);
|
|
|
|
|
return $row->num_versions;
|
|
|
|
|
}
|
|
|
|
|
|
2004-12-10 01:07:45 +00:00
|
|
|
/* Get the number of maintainers in the database */
|
|
|
|
|
function getNumberOfMaintainers()
|
|
|
|
|
{
|
2005-01-23 16:59:09 +00:00
|
|
|
$result = query_appdb("SELECT DISTINCT userId FROM appMaintainers;");
|
|
|
|
|
return mysql_num_rows($result);
|
2004-12-10 01:07:45 +00:00
|
|
|
}
|
|
|
|
|
|
2004-12-01 22:26:50 +00:00
|
|
|
/* Get the number of app familes in the database */
|
|
|
|
|
function getNumberOfAppFamilies()
|
|
|
|
|
{
|
2005-01-11 00:26:05 +00:00
|
|
|
$result = query_appdb("SELECT count(*) as num_appfamilies FROM appFamily;");
|
2004-12-01 22:26:50 +00:00
|
|
|
$row = mysql_fetch_object($result);
|
|
|
|
|
return $row->num_appfamilies;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Get the number of images in the database */
|
|
|
|
|
function getNumberOfImages()
|
|
|
|
|
{
|
2005-01-11 00:26:05 +00:00
|
|
|
$result = query_appdb("SELECT count(*) as num_images FROM appData WHERE type='image';");
|
2004-12-01 22:26:50 +00:00
|
|
|
$row = mysql_fetch_object($result);
|
|
|
|
|
return $row->num_images;
|
|
|
|
|
}
|
|
|
|
|
|
2005-01-08 18:28:32 +00:00
|
|
|
function lookupVendorName($vendorId)
|
|
|
|
|
{
|
|
|
|
|
$sResult = query_appdb("SELECT * FROM vendor ".
|
|
|
|
|
"WHERE vendorId = ".$vendorId);
|
|
|
|
|
if(!$sResult || mysql_num_rows($sResult) != 1)
|
|
|
|
|
return "Unknown vendor";
|
|
|
|
|
|
|
|
|
|
$vendor = mysql_fetch_object($sResult);
|
|
|
|
|
return $vendor->vendorName;
|
|
|
|
|
}
|
|
|
|
|
|
2004-03-15 16:22:00 +00:00
|
|
|
?>
|