* Clean a string, escaping any meta characters that could be
* used to disrupt an SQL string. i.e. "'" => "\'" etc.
*
* @param String (or Array)
* @return String (or Array) of cleaned data, suitable for use within an SQL
* statement.
*/
function escape_string ($string)
{
global $CONF;
// if the string is actually an array, do a recursive cleaning.
// Note, the array keys are not cleaned.
if(is_array($string)) {
$clean = array();
foreach($string as $row) {
$clean[] = escape_string($row);
}
return $clean;
}
if (get_magic_quotes_gpc ())
{
$string = stripslashes($string);
@ -619,23 +662,38 @@ function check_alias_owner ($username, $alias)
}
//
// list_domains_for_admin
// Action: Lists all the domains for an admin.
// Call: list_domains_for_admin (string admin)
//
/**
* List domains for an admin user. If $username is empty, it returns all
* available damains for a user.
* Otherwise, it returns only those domains for a particular user.
* @param String $username
* @return array of domain names.
*/
function list_domains_for_admin ($username)
{
global $CONF;
global $table_domain, $table_domain_admins;
$list = array ();
$query = "SELECT $table_domain.domain FROM $table_domain LEFT JOIN $table_domain_admins ON $table_domain.domain=$table_domain_admins.domain WHERE $table_domain_admins.username='$username' AND $table_domain.active='1' AND $table_domain.backupmx='0' ORDER BY $table_domain_admins.domain";
if ('pgsql'==$CONF['database_type'])
{
$query = "SELECT $table_domain.domain FROM $table_domain LEFT JOIN $table_domain_admins ON $table_domain.domain=$table_domain_admins.domain WHERE $table_domain_admins.username='$username' AND $table_domain.active=true AND $table_domain.backupmx=false ORDER BY $table_domain_admins.domain";
$username_sql = '';
$active_sql = db_get_boolean(True);
$backupmx_sql = db_get_boolean(False);
if($username != '') {
$query = "SELECT $table_domain.domain, $table_domain_admins.username FROM $table_domain
LEFT JOIN $table_domain_admins ON $table_domain.domain=$table_domain_admins.domain
WHERE $table_domain_admins.username='$username'
AND $table_domain.active=$active_sql
AND $table_domain.backupmx=$backupmx_sql
ORDER BY $table_domain_admins.domain";
}
else {
$query = "SELECT $table_domain.domain FROM $table_domain
LEFT JOIN $table_domain_admins ON $table_domain.domain=$table_domain_admins.domain