2004-12-12 03:51:51 +00:00
|
|
|
<?php
|
2005-01-30 23:12:48 +00:00
|
|
|
/************************************/
|
|
|
|
|
/* user class and related functions */
|
|
|
|
|
/************************************/
|
2004-03-15 16:22:00 +00:00
|
|
|
|
|
|
|
|
|
2005-01-30 23:12:48 +00:00
|
|
|
/**
|
|
|
|
|
* User class for handling users
|
|
|
|
|
*/
|
|
|
|
|
class User {
|
|
|
|
|
var $iUserId;
|
|
|
|
|
var $sEmail;
|
|
|
|
|
var $sRealname;
|
|
|
|
|
var $sStamp;
|
|
|
|
|
var $sDateCreated;
|
|
|
|
|
var $sWineRelease;
|
2004-03-15 16:22:00 +00:00
|
|
|
|
2004-12-12 03:51:51 +00:00
|
|
|
/**
|
2005-01-30 23:12:48 +00:00
|
|
|
* Constructor.
|
|
|
|
|
* If $iUserId is provided, logs in user.
|
2004-03-15 16:22:00 +00:00
|
|
|
*/
|
2005-01-30 23:12:48 +00:00
|
|
|
function User($iUserId="")
|
2004-03-15 16:22:00 +00:00
|
|
|
{
|
2005-01-30 23:12:48 +00:00
|
|
|
if($iUserId)
|
|
|
|
|
{
|
|
|
|
|
$sQuery = "SELECT *
|
|
|
|
|
FROM user_list
|
|
|
|
|
WHERE userId = '".$iUserId."'";
|
|
|
|
|
$hResult = query_appdb($sQuery);
|
|
|
|
|
$oRow = mysql_fetch_object($hResult);
|
|
|
|
|
$this->iUserId = $oRow->userid;
|
|
|
|
|
$this->sEmail = $oRow->email;
|
|
|
|
|
$this->sRealname = $oRow->realname;
|
|
|
|
|
$this->sStamp = $oRow->stamp;
|
|
|
|
|
$this->sDateCreated = $oRow->created;
|
|
|
|
|
$this->sWineRelease = $oRow->CVSrelease;
|
|
|
|
|
}
|
|
|
|
|
return $this->isLoggedIn();
|
2004-03-15 16:22:00 +00:00
|
|
|
}
|
|
|
|
|
|
2004-12-12 03:51:51 +00:00
|
|
|
|
|
|
|
|
/**
|
2005-01-30 23:12:48 +00:00
|
|
|
* Logs in an user using e-mail and password.
|
2004-03-15 16:22:00 +00:00
|
|
|
*/
|
2005-01-10 22:54:04 +00:00
|
|
|
function login($sEmail, $sPassword)
|
2004-03-15 16:22:00 +00:00
|
|
|
{
|
2005-01-30 23:12:48 +00:00
|
|
|
$sQuery = "SELECT *
|
|
|
|
|
FROM user_list
|
|
|
|
|
WHERE email = '".$sEmail."'
|
|
|
|
|
AND password = password('".$sPassword."')";
|
|
|
|
|
$hResult = query_appdb($sQuery);
|
|
|
|
|
$oRow = mysql_fetch_object($hResult);
|
|
|
|
|
$this->iUserId = $oRow->userid;
|
|
|
|
|
$this->sEmail = $oRow->email;
|
|
|
|
|
$this->sRealname = $oRow->realname;
|
|
|
|
|
$this->sStamp = $oRow->stamp;
|
|
|
|
|
$this->sDateCreated = $oRow->created;
|
|
|
|
|
$this->sWineRelease = $oRow->CVSrelease;
|
|
|
|
|
if($this->isLoggedIn())
|
|
|
|
|
{
|
|
|
|
|
// Update timestamp
|
|
|
|
|
query_appdb("UPDATE user_list SET stamp=null WHERE userid=".$this->iUserId);
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
return false;
|
2004-03-15 16:22:00 +00:00
|
|
|
}
|
|
|
|
|
|
2004-12-12 03:51:51 +00:00
|
|
|
|
2004-03-15 16:22:00 +00:00
|
|
|
/*
|
2005-01-30 23:12:48 +00:00
|
|
|
* Creates a new user.
|
|
|
|
|
* returns true on success, false on failure
|
2004-03-15 16:22:00 +00:00
|
|
|
*/
|
2005-01-30 23:12:48 +00:00
|
|
|
function create($sEmail, $sPassword, $sRealname, $sWineRelease)
|
2004-03-15 16:22:00 +00:00
|
|
|
{
|
2005-01-30 23:12:48 +00:00
|
|
|
if(user_exists($sEmail))
|
|
|
|
|
{
|
|
|
|
|
addMsg("An account with this e-mail exists already.","red");
|
|
|
|
|
return false;
|
|
|
|
|
} else
|
|
|
|
|
{
|
2005-01-11 02:32:20 +00:00
|
|
|
$aInsert = compile_insert_string(array( 'realname' => $sRealname,
|
|
|
|
|
'email' => $sEmail,
|
2005-01-30 23:12:48 +00:00
|
|
|
'CVSrelease' => $sWineRelease ));
|
2005-01-08 18:38:29 +00:00
|
|
|
|
|
|
|
|
$sFields = "({$aInsert['FIELDS']}, `password`, `stamp`, `created`)";
|
2005-01-11 02:32:20 +00:00
|
|
|
$sValues = "({$aInsert['VALUES']}, password('".$sPassword."'), NOW(), NOW() )";
|
2005-01-08 18:38:29 +00:00
|
|
|
|
2005-01-14 05:34:25 +00:00
|
|
|
query_appdb("INSERT INTO user_list $sFields VALUES $sValues", "Error while creating a new user.");
|
2005-01-30 23:12:48 +00:00
|
|
|
return $this->login($sEmail, $sPassword);
|
|
|
|
|
}
|
2004-03-15 16:22:00 +00:00
|
|
|
}
|
|
|
|
|
|
2004-12-12 03:51:51 +00:00
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Update User Account;
|
|
|
|
|
*/
|
2005-01-30 23:12:48 +00:00
|
|
|
function update($sEmail = null, $sPassword = null, $sRealname = null, $sWineRelease = null)
|
2004-03-15 16:22:00 +00:00
|
|
|
{
|
2005-01-30 23:12:48 +00:00
|
|
|
if(!$this->isLoggedIn()) return false;
|
|
|
|
|
|
|
|
|
|
if ($sEmail)
|
2004-11-17 23:01:12 +00:00
|
|
|
{
|
2005-01-30 23:12:48 +00:00
|
|
|
if(user_exists($sEmail) && $sEmail != $this->sEmail)
|
|
|
|
|
{
|
|
|
|
|
addMsg("An account with this e-mail exists already.","red");
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
if (!query_appdb("UPDATE user_list SET email = '".addslashes($sEmail)."' WHERE userid = ".$this->iUserId))
|
|
|
|
|
return false;
|
|
|
|
|
$this->sEmail = $sEmail;
|
2004-11-17 23:01:12 +00:00
|
|
|
}
|
2004-12-12 03:51:51 +00:00
|
|
|
|
2005-01-30 23:12:48 +00:00
|
|
|
if ($sPassword)
|
2004-11-17 23:01:12 +00:00
|
|
|
{
|
2005-01-30 23:12:48 +00:00
|
|
|
if (!query_appdb("UPDATE user_list SET password = password('$sPassword') WHERE userid = ".$this->iUserId))
|
|
|
|
|
return false;
|
2004-11-17 23:01:12 +00:00
|
|
|
}
|
2004-12-12 03:51:51 +00:00
|
|
|
|
2005-01-30 23:12:48 +00:00
|
|
|
if ($sRealname)
|
2004-11-17 23:01:12 +00:00
|
|
|
{
|
2005-01-30 23:12:48 +00:00
|
|
|
if (!query_appdb("UPDATE user_list SET realname = '".addslashes($sRealname)."' WHERE userid = ".$this->iUserId))
|
|
|
|
|
return false;
|
|
|
|
|
$this->sRealname = $sRealname;
|
2004-11-17 23:01:12 +00:00
|
|
|
}
|
2005-01-04 19:36:03 +00:00
|
|
|
|
2005-01-30 23:12:48 +00:00
|
|
|
if ($sWineRelease)
|
2005-01-04 19:36:03 +00:00
|
|
|
{
|
2005-01-30 23:12:48 +00:00
|
|
|
if (!query_appdb("UPDATE user_list SET CVSrelease = '".addslashes($sWineRelease)."' WHERE userid = ".$this->iUserId))
|
|
|
|
|
return false;
|
|
|
|
|
$this->sWineRelease = $sWineRelease;
|
2005-01-04 19:36:03 +00:00
|
|
|
}
|
2005-01-30 23:12:48 +00:00
|
|
|
return true;
|
2004-03-15 16:22:00 +00:00
|
|
|
}
|
|
|
|
|
|
2005-01-30 23:12:48 +00:00
|
|
|
|
2004-12-12 03:51:51 +00:00
|
|
|
/**
|
2005-01-30 23:12:48 +00:00
|
|
|
* Removes the current, or specified user and preferences from the database.
|
|
|
|
|
* returns true on success and false on failure.
|
2004-03-15 16:22:00 +00:00
|
|
|
*/
|
2005-01-30 23:12:48 +00:00
|
|
|
function delete()
|
2004-03-15 16:22:00 +00:00
|
|
|
{
|
2005-01-30 23:12:48 +00:00
|
|
|
if(!$this->isLoggedIn()) return false;
|
|
|
|
|
$hResult2 = query_appdb("DELETE FROM user_privs WHERE id = '".$this->iUserId."'");
|
|
|
|
|
$hResult3 = query_appdb("DELETE FROM user_prefs WHERE id = '".$this->iUserId."'");
|
|
|
|
|
return($hResult = query_appdb("DELETE FROM user_list WHERE id = '".$this->iUserId."'"));
|
2004-03-15 16:22:00 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2005-01-30 23:12:48 +00:00
|
|
|
/**
|
|
|
|
|
* Get a preference for the current user.
|
|
|
|
|
*/
|
|
|
|
|
function getPref($sKey, $sDef = null)
|
2004-03-15 16:22:00 +00:00
|
|
|
{
|
2005-01-30 23:12:48 +00:00
|
|
|
if(!$this->isLoggedIn() || !$sKey)
|
|
|
|
|
return $sDef;
|
2004-03-15 16:22:00 +00:00
|
|
|
|
2005-01-30 23:12:48 +00:00
|
|
|
$hResult = query_appdb("SELECT * FROM user_prefs WHERE userid = ".$this->iUserId." AND name = '$sKey'");
|
|
|
|
|
if(!$hResult || mysql_num_rows($hResult) == 0)
|
|
|
|
|
return $sDef;
|
|
|
|
|
$ob = mysql_fetch_object($hResult);
|
2004-11-09 22:41:18 +00:00
|
|
|
return $ob->value;
|
2004-03-15 16:22:00 +00:00
|
|
|
}
|
|
|
|
|
|
2004-12-12 03:51:51 +00:00
|
|
|
|
2005-01-30 23:12:48 +00:00
|
|
|
/**
|
|
|
|
|
* Set a preference for the current user.
|
|
|
|
|
*/
|
|
|
|
|
function setPref($sKey, $sValue)
|
2004-03-15 16:22:00 +00:00
|
|
|
{
|
2005-01-30 23:12:48 +00:00
|
|
|
if(!$this->isLoggedIn() || !$sKey || !$sValue)
|
|
|
|
|
return false;
|
2004-03-15 16:22:00 +00:00
|
|
|
|
2005-01-30 23:12:48 +00:00
|
|
|
$hResult = query_appdb("DELETE FROM user_prefs WHERE userid = ".$this->iUserId." AND name = '$sKey'");
|
|
|
|
|
$hResult = query_appdb("INSERT INTO user_prefs VALUES(".$this->iUserId.", '$sKey', '$sValue')");
|
|
|
|
|
return $hResult;
|
2004-03-15 16:22:00 +00:00
|
|
|
}
|
|
|
|
|
|
2004-12-12 03:51:51 +00:00
|
|
|
|
|
|
|
|
/**
|
2005-01-30 23:12:48 +00:00
|
|
|
* Check if this user has $priv.
|
2004-03-15 16:22:00 +00:00
|
|
|
*/
|
2005-01-30 23:12:48 +00:00
|
|
|
function hasPriv($sPriv)
|
2004-03-15 16:22:00 +00:00
|
|
|
{
|
2005-01-30 23:12:48 +00:00
|
|
|
if(!$this->isLoggedIn() || !$sPriv)
|
|
|
|
|
return false;
|
2004-03-15 16:22:00 +00:00
|
|
|
|
2005-01-30 23:12:48 +00:00
|
|
|
$hResult = query_appdb("SELECT * FROM user_privs WHERE userid = ".$this->iUserId." AND priv = '".$sPriv."'");
|
|
|
|
|
if(!$hResult)
|
|
|
|
|
return false;
|
|
|
|
|
return mysql_num_rows($hResult);
|
2004-03-15 16:22:00 +00:00
|
|
|
}
|
|
|
|
|
|
2004-12-12 03:51:51 +00:00
|
|
|
|
|
|
|
|
/**
|
2005-01-30 23:12:48 +00:00
|
|
|
* Check if this user is a maintainer of a given appId/versionId.
|
2004-11-09 22:41:18 +00:00
|
|
|
*/
|
2005-01-30 23:12:48 +00:00
|
|
|
function isMaintainer($iAppId=null, $iVersionId=null)
|
2004-11-09 22:41:18 +00:00
|
|
|
{
|
2005-01-30 23:12:48 +00:00
|
|
|
if(!$this->isLoggedIn()) return false;
|
2004-11-09 22:41:18 +00:00
|
|
|
|
2004-12-10 00:18:01 +00:00
|
|
|
/* if this user is a super maintainer of this appid then they */
|
|
|
|
|
/* are a maintainer of all of the versionId's of it as well */
|
2005-01-30 23:12:48 +00:00
|
|
|
if($this->isSuperMaintainer($iAppId))
|
2004-12-10 00:18:01 +00:00
|
|
|
{
|
|
|
|
|
return true;
|
|
|
|
|
}
|
2005-01-30 23:12:48 +00:00
|
|
|
|
|
|
|
|
if($iAppId && $iVersionId)
|
|
|
|
|
{
|
|
|
|
|
$sQuery = "SELECT * FROM appMaintainers WHERE userid = '".$this->iUserId."' AND appId = '".$iAppId."' AND versionId = '$iVersionId'";
|
2005-02-02 00:12:35 +00:00
|
|
|
} elseif($iAppId) // isMaintainer ? and we only provided appId => isSupermaintainer.
|
|
|
|
|
{
|
|
|
|
|
return $this->isSuperMaintainer($iAppId);
|
2005-01-30 23:12:48 +00:00
|
|
|
} else
|
|
|
|
|
{
|
|
|
|
|
$sQuery = "SELECT * FROM appMaintainers WHERE userid = '".$this->iUserId."'";
|
|
|
|
|
}
|
|
|
|
|
$hResult = query_appdb($sQuery);
|
|
|
|
|
if(!$hResult)
|
|
|
|
|
return false;
|
|
|
|
|
return mysql_num_rows($hResult);
|
2004-11-09 22:41:18 +00:00
|
|
|
}
|
|
|
|
|
|
2004-12-12 03:51:51 +00:00
|
|
|
|
2004-12-10 00:18:01 +00:00
|
|
|
/*
|
2005-01-30 23:12:48 +00:00
|
|
|
* Check if this user is a maintainer of a given appId/versionId.
|
2004-12-10 00:18:01 +00:00
|
|
|
*/
|
2005-01-30 23:12:48 +00:00
|
|
|
function isSuperMaintainer($iAppId=null)
|
2004-12-10 00:18:01 +00:00
|
|
|
{
|
2005-01-30 23:12:48 +00:00
|
|
|
if(!$this->isLoggedIn()) return false;
|
2004-12-10 00:18:01 +00:00
|
|
|
|
2005-01-30 23:12:48 +00:00
|
|
|
if($iAppId)
|
|
|
|
|
{
|
|
|
|
|
$sQuery = "SELECT * FROM appMaintainers WHERE userid = '$this->iUserId' AND appId = '$iAppId' AND superMaintainer = '1'";
|
|
|
|
|
} else
|
|
|
|
|
{
|
|
|
|
|
$sQuery = "SELECT * FROM appMaintainers WHERE userid = '$this->iUserId' AND superMaintainer = '1'";
|
|
|
|
|
}
|
|
|
|
|
$hResult = query_appdb($sQuery);
|
|
|
|
|
if(!$hResult)
|
|
|
|
|
return false;
|
|
|
|
|
return mysql_num_rows($hResult);
|
2004-12-10 00:18:01 +00:00
|
|
|
}
|
|
|
|
|
|
2004-12-12 03:51:51 +00:00
|
|
|
|
2005-01-30 23:12:48 +00:00
|
|
|
function addPriv($sPriv)
|
2004-03-15 16:22:00 +00:00
|
|
|
{
|
2005-01-30 23:12:48 +00:00
|
|
|
if(!$this->isLoggedIn() || !$sPriv)
|
|
|
|
|
return false;
|
2004-03-15 16:22:00 +00:00
|
|
|
|
2005-01-30 23:12:48 +00:00
|
|
|
if($this->hasPriv($sPriv))
|
|
|
|
|
return true;
|
2004-03-15 16:22:00 +00:00
|
|
|
|
2005-01-30 23:12:48 +00:00
|
|
|
$hResult = query_appdb("INSERT INTO user_privs VALUES ($this->iUserId, '$sPriv')");
|
|
|
|
|
return $hResult;
|
2004-03-15 16:22:00 +00:00
|
|
|
}
|
|
|
|
|
|
2004-12-12 03:51:51 +00:00
|
|
|
|
2005-01-30 23:12:48 +00:00
|
|
|
function delPriv($sPriv)
|
2004-03-15 16:22:00 +00:00
|
|
|
{
|
2005-01-30 23:12:48 +00:00
|
|
|
if(!$this->isLoggedIn() || !$sPriv)
|
|
|
|
|
return false;
|
2004-03-15 16:22:00 +00:00
|
|
|
|
2005-01-30 23:12:48 +00:00
|
|
|
$hRresult = query_appdb("DELETE FROM user_privs WHERE userid = $this->iUserId AND priv = '$sPriv'");
|
|
|
|
|
return $hRresult;
|
2004-03-15 16:22:00 +00:00
|
|
|
}
|
|
|
|
|
|
2005-02-02 02:42:28 +00:00
|
|
|
|
2005-01-30 23:12:48 +00:00
|
|
|
/**
|
|
|
|
|
* Checks if the current user is valid.
|
|
|
|
|
*/
|
|
|
|
|
function isLoggedIn()
|
|
|
|
|
{
|
|
|
|
|
return $this->iUserId;
|
|
|
|
|
}
|
2004-12-12 03:51:51 +00:00
|
|
|
|
2004-03-15 16:22:00 +00:00
|
|
|
|
2005-01-30 23:12:48 +00:00
|
|
|
/**
|
|
|
|
|
* Checks if user should see debugging infos.
|
|
|
|
|
*/
|
|
|
|
|
function showDebuggingInfos()
|
|
|
|
|
{
|
|
|
|
|
return (($this->isLoggedIn() && $this->getPref("debug") == "yes") || APPDB_DEBUG == 1);
|
|
|
|
|
}
|
2005-02-02 02:42:28 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Checks if user wants to get e-mails.
|
|
|
|
|
*/
|
|
|
|
|
function wantsEmail()
|
|
|
|
|
{
|
|
|
|
|
return ($this->isLoggedIn() && $this->getPref("send_email","yes")=="yes");
|
|
|
|
|
}
|
2004-03-15 16:22:00 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2005-01-30 23:12:48 +00:00
|
|
|
/*
|
|
|
|
|
* User functions that are not part of the class
|
|
|
|
|
*/
|
2004-12-12 03:51:51 +00:00
|
|
|
|
|
|
|
|
/**
|
2005-01-30 23:12:48 +00:00
|
|
|
* Creates a new random password.
|
2004-12-12 03:51:51 +00:00
|
|
|
*/
|
2004-03-15 16:22:00 +00:00
|
|
|
function generate_passwd($pass_len = 10)
|
|
|
|
|
{
|
|
|
|
|
$nps = "";
|
|
|
|
|
mt_srand ((double) microtime() * 1000000);
|
|
|
|
|
while (strlen($nps)<$pass_len)
|
|
|
|
|
{
|
|
|
|
|
$c = chr(mt_rand (0,255));
|
|
|
|
|
if (eregi("^[a-z0-9]$", $c)) $nps = $nps.$c;
|
|
|
|
|
}
|
|
|
|
|
return ($nps);
|
|
|
|
|
}
|
|
|
|
|
|
2004-12-12 03:51:51 +00:00
|
|
|
|
|
|
|
|
/**
|
2005-01-30 23:12:48 +00:00
|
|
|
* Get the email address of people to notify for this appId and versionId.
|
2004-11-09 22:42:12 +00:00
|
|
|
*/
|
2005-02-04 02:55:50 +00:00
|
|
|
function get_notify_email_address_list($iAppId = null, $iVersionId = null)
|
2004-11-09 22:42:12 +00:00
|
|
|
{
|
|
|
|
|
$aUserId = array();
|
|
|
|
|
$c = 0;
|
|
|
|
|
$retval = "";
|
2005-02-04 02:55:50 +00:00
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
* Retrieve version maintainers.
|
|
|
|
|
*/
|
|
|
|
|
/*
|
|
|
|
|
* If versionId was supplied we fetch supermaintainers of application and maintainer of version.
|
|
|
|
|
*/
|
|
|
|
|
if($iVersionId)
|
|
|
|
|
{
|
|
|
|
|
$sQuery = "SELECT appMaintainers.userId
|
|
|
|
|
FROM appMaintainers, appVersion
|
|
|
|
|
WHERE appVersion.appId = appMaintainers.appId
|
|
|
|
|
AND appVersion.versionId = '".$iVersionId."'";
|
|
|
|
|
}
|
|
|
|
|
/*
|
|
|
|
|
* If versionId was not supplied we fetch supermaintainers of application and maintainer of all versions.
|
|
|
|
|
*/
|
|
|
|
|
elseif($iAppId)
|
2004-11-09 22:42:12 +00:00
|
|
|
{
|
2005-02-04 02:55:50 +00:00
|
|
|
$sQuery = "SELECT userId
|
|
|
|
|
FROM appMaintainers
|
|
|
|
|
WHERE appId = '".$iAppId."'";
|
|
|
|
|
}
|
|
|
|
|
$hResult = query_appdb($sQuery);
|
|
|
|
|
if(mysql_num_rows($hResult) > 0)
|
|
|
|
|
{
|
|
|
|
|
while($oRow = mysql_fetch_object($hResult))
|
2004-11-09 22:42:12 +00:00
|
|
|
{
|
2005-02-04 02:55:50 +00:00
|
|
|
$aUserId[$c] = array($oRow->userId);
|
2004-11-09 22:42:12 +00:00
|
|
|
$c++;
|
|
|
|
|
}
|
|
|
|
|
}
|
2005-02-04 02:55:50 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
* Retrieve administrators.
|
|
|
|
|
*/
|
|
|
|
|
$hResult = query_appdb("SELECT * FROM user_privs WHERE priv = 'admin'");
|
|
|
|
|
if(mysql_num_rows($hResult) > 0)
|
2004-11-09 22:42:12 +00:00
|
|
|
{
|
2005-02-04 02:55:50 +00:00
|
|
|
while($oRow = mysql_fetch_object($hResult))
|
2004-11-09 22:42:12 +00:00
|
|
|
{
|
2005-02-04 02:55:50 +00:00
|
|
|
$i = array_search($oRow->userid, $aUserId);
|
|
|
|
|
if ($aUserId[$i] != array($oRow->userid))
|
2004-11-09 22:42:12 +00:00
|
|
|
{
|
2005-02-04 02:55:50 +00:00
|
|
|
$aUserId[$c] = array($oRow->userid);
|
2004-11-09 22:42:12 +00:00
|
|
|
$c++;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
if ($c > 0)
|
|
|
|
|
{
|
|
|
|
|
while(list($index, list($userIdValue)) = each($aUserId))
|
|
|
|
|
{
|
2005-01-30 23:12:48 +00:00
|
|
|
$oUser = new User($userIdValue);
|
2005-02-02 02:42:28 +00:00
|
|
|
if ($oUser->wantsEmail())
|
2005-01-30 23:12:48 +00:00
|
|
|
$retval .= $oUser->sEmail." ";
|
2004-11-09 22:42:12 +00:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return $retval;
|
|
|
|
|
}
|
2004-11-09 22:41:18 +00:00
|
|
|
|
2004-12-12 03:51:51 +00:00
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Get the number of users in the database
|
|
|
|
|
*/
|
2005-01-30 23:12:48 +00:00
|
|
|
function get_number_of_users()
|
2004-12-01 22:26:50 +00:00
|
|
|
{
|
2005-01-11 00:26:05 +00:00
|
|
|
$result = query_appdb("SELECT count(*) as num_users FROM user_list;");
|
2004-12-01 22:26:50 +00:00
|
|
|
$row = mysql_fetch_object($result);
|
|
|
|
|
return $row->num_users;
|
|
|
|
|
}
|
|
|
|
|
|
2004-12-12 03:51:51 +00:00
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Get the number of active users within $days of the current day
|
|
|
|
|
*/
|
2005-01-30 23:12:48 +00:00
|
|
|
function get_active_users_within_days($days)
|
2004-12-01 22:26:50 +00:00
|
|
|
{
|
2005-01-11 00:26:05 +00:00
|
|
|
$result = query_appdb("SELECT count(*) as num_users FROM user_list WHERE stamp >= DATE_SUB(CURDATE(), interval $days day);");
|
2004-12-01 22:26:50 +00:00
|
|
|
$row = mysql_fetch_object($result);
|
|
|
|
|
return $row->num_users;
|
|
|
|
|
}
|
|
|
|
|
|
2005-01-30 23:12:48 +00:00
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Check if a user exists.
|
|
|
|
|
* returns TRUE if the user exists
|
|
|
|
|
*/
|
|
|
|
|
function user_exists($sEmail)
|
|
|
|
|
{
|
|
|
|
|
$result = query_appdb("SELECT * FROM user_list WHERE email = '$sEmail'");
|
|
|
|
|
if(!$result || mysql_num_rows($result) != 1)
|
|
|
|
|
return 0;
|
|
|
|
|
return 1;
|
|
|
|
|
}
|
2004-03-15 16:22:00 +00:00
|
|
|
?>
|