source=$source; } function add_email($email, $check){ $email=strtolower($email); if (in_array($email, $this->address_list)) return -1; if ($check==1) $check_result=$this->do_check($email); if ($check==0 || $check_result==1){ $this->address_list[count($this->address_list)]=$email; return 1; } else { return 0; } } function drop_email($email){ $email=strtolower($email); $temp_array=$this->address_list; $this->address_list=array(); for ($x=0; $xaddress_list[count($this->address_list)]=$temp_array[$x]; } } function list_email($sep, $editlink){ for ($x=0; $xaddress_list); $x++){ $str.=$this->address_list[$x]." ".(($editlink) ? ereg_replace("##id##",$this->address_list[$x],$editlink) : "").$sep; } return $str; } function list_perms($sep, $editlink){ for ($x=0; $xperms_list); $x++){ $str.=getUserName($this->perms_list[$x])." ".(($editlink) ? ereg_replace("##id##",$this->perms_list[$x],$editlink) : "").$sep; } return $str; } function read_alias(){ //read the alias list for this alias - can read from either file system or database if ($this->has_perms()==0) return 0; if ($this->source=="file" || ! $this->source){ if (! file_exists($this->location)) return 0; $in=fopen($this->location, 'r'); if ($in != 0){ while(! feof($in)){ $tempLine=chop(fgets($in, 4096)); if ($tempLine && ! ereg("\#", $tempLine)){ $result=$this->add_email($tempLine, 0); if ($result==-1) $this->logstring.="Error: ($tempLine) email already exists in list\n"; if ($result==0) $this->logstring.="Error: ($tempLine) email fails validation\n"; } } fclose($in); return count($this->address_list); } else { return 0; } } elseif ($this->source=="db"){ $q="select email from mail_alias_map where alias_id='".$this->alias_id."' order by email"; $r=mysql_query($q); if ($r !=0){ if (mysql_num_rows($r)!=0){ while ($rv=mysql_fetch_array($r)) { $result=$this->add_email(stripslashes($rv['email']), 0); if ($result==-1) $this->logstring.="Error: ($tempLine) email already exists in list\n"; if ($result==0) $this->logstring.="Error: ($tempLine) email fails validation\n"; } return count($this->address_list); } else { return 0; } } else { return 0; } } } function read_perms_list(){ //read the perms for this alias - can read from only database if ($this->has_perms()==0) return 0; if ($this->source=="db"){ $this->perms_list=array(); $q="select map.user_id from mail_alias_perms map, buda_users_public bup where map.alias_id='".$this->alias_id."' and bup.user_id=map.user_id order by bup.last_name, bup.first_name"; $r=mysql_query($q); if ($r !=0){ if (mysql_num_rows($r)!=0){ while ($rv=mysql_fetch_array($r)) { $this->perms_list[count($this->perms_list)]=$rv['user_id']; } return count($this->perms_list); } else { return 0; } } else { return 0; } } } function add_perms($user_id){ global $authinfo; if ($this->has_perms()){ $q="select alias_id, user_id from mail_alias_perms where alias_id='".$this->alias_id."' and user_id='".$user_id."'"; if (($r=mysql_query($q)) != 0){ if (mysql_num_rows($r) == 1){ $this->logstring.="User already has perms"; return 0; } } $q="insert into mail_alias_perms (alias_id, user_id) values ('".$this->alias_id."', '".$user_id."')"; if (($r=mysql_query($q)) != 0){ return 1; } } return 0; } function remove_perms($user_id){ global $authinfo; if ($this->has_perms()){ $q="delete from mail_alias_perms where alias_id='".$this->alias_id."' and user_id='".$user_id."'"; if (($r=mysql_query($q)) != 0){ return 1; } } return 0; } function has_perms(){ global $authinfo; if ($authinfo->auth_user_id){ $q="select alias_id, user_id from mail_alias_perms where alias_id='".$this->alias_id."' and user_id='".$authinfo->auth_user_id."'"; if (($r=mysql_query($q)) != 0){ if (mysql_num_rows($r) == 1){ return 1; } } $q="select alias, object_id from buda_users_contact_info where alias='".$this->alias_name."' and user_id='".$authinfo->auth_user_id."'"; if (($r=mysql_query($q)) != 0){ if (mysql_num_rows($r) == 1){ return 1; } } if (isGroupMember('Admin', $authinfo->auth_user_id)==1) return 1; } return 0; } function write_alias(){ if ($this->has_perms()==0) return 0; if ($this->source=="file" || ! $this->source){ $out=fopen($this->location, 'w+'); if ($out != 0){ fwrite($out, $this->list_email("\n",'')); fclose($out); return 1; } else { return 0; } } elseif ($this->source=="db"){ if (! $this->alias_id){ $q="select id from mail_alias where name='buda-".$this->name."'"; if (($r=mysql_query($q))==1){ $rv=mysql_fetch_array($r); $this->alias_id=$rv['id']; } } if (! $this->alias_id){ $this->logstring.="Error: alias not found in database\n"; return 0; } $q="delete from mail_alias_map where alias_id='".$this->alias_id."'"; if (($r=mysql_query($q))==1){ for ($x=0; $xaddress_list); $x++){ $q="insert into mail_alias_map (alias_id, email) values ('".$this->alias_id."', '".addslashes($this->address_list[$x])."')"; if (($r=mysql_query($q))==0) $this->logstring.=mysql_error(); } return 1; } else { return 0; } } } function do_check($email){ //check the email address for the correct format if (eregi("^[_a-z0-9-]+(\.[_a-z0-9-]+)*@([0-9a-z][0-9a-z-]*[0-9a-z]\.)+[a-z]{2}[mtgvu]?$", $email, $check)){ //check for an existing mx record for the domain supplied if (getmxrr(substr(strstr($check[0], "@"), 1), $temp)) { return 1; } else { //if no mx record, check for a dns record of any type... if (checkdnsrr(substr(strstr($check[0], '@'),1), "ANY")){ return 1; } else { $this->logstring.="The portion of your email address after the @ sign does not correspond to a valid server name: ".$email."\n"; return 0; } } } else { $this->logstring.="Email syntax validation failed: ".$email."\n"; return 0; } } } class virtual_user{ var $classname="virtual_user"; var $name; var $type; var $alias; var $logstring; var $vu_id; function virtual_user(){} } /* this is a class to handle the mail aliases, it relies on the alias class above note: the 'end-user' should never have to know about the alias class, all functions in alias should be accessed through buda_mail_alias */ class buda_mail_alias{ // set class variables var $classname='buda_mail_alias'; var $logstring=""; var $remote_root="/usr/home/buda/Mail_Lists"; var $local_root; var $alias_list=array(); var $alias_types=array(); var $virtual_user_list=array(); var $virtual_user_types=array(); var $filter; var $source; function buda_mail_alias(){ $this->local_root=getenv('DOCUMENT_ROOT')."/.buda_aliases/Mail_Lists"; } //------------------------------------------------------------------------------- //deal with the buda-aliases table //------------------------------------------------------------------------------- //short cut to read_aliases where source== file function read_alias_file(){ $this->source="file"; return $this->read_aliases(); } function read_alias_types(){ $q="select distinct type from mail_alias order by type"; $r=mysql_query($q); if ($r !=0){ if (mysql_num_rows($r) != 0){ while ($rv=mysql_fetch_array($r)) { $this->alias_types[count($this->alias_types)]=stripslashes($rv['type']); $y++; } return 1; } else { return 0; } } else { return 0; } } //read in the aliases, either from a file or the database function read_aliases(){ global $authinfo; if (count($this->alias_list)>0) $this->alias_list=array(); if (($this->source == "file" || ! $this->source) && $this->has_perms()){ //test to see if file exists... if (! file_exists($this->local_root."/buda-aliases.txt")) return 0; $in=fopen($this->local_root."/buda-aliases.txt",'r'); if ($in !=0){ while(! feof($in)){ //note: in order to duplicate the format of the original // buda-aliases file, we'll use the comment which began each // section as 'type' $tempLine=chop(fgets($in, 4096)); if ($tempLine && ! ereg("\#",$tempLine)){ list($alias, $trash1,$trash2,$location) = explode(":", $tempLine); $a = new alias($this->source); $a->name=ltrim(rtrim(substr($alias,5))); $a->location=ereg_replace($this->remote_root, $this->local_root, $location); $a->type=$type; $this->alias_list[count($this->alias_list)]=$a; } elseif ($tempLine && ereg("\#", $tempLine)){ $type=ltrim(rtrim(ereg_replace("\#", "", $tempLine))); } $y++; } fclose($in); return 1; } else { return 0; } } elseif ($this->source=="db") { //if in the admin group, we want to pull everything...if not, pull only the aliases that the user has perms on... if ($this->has_perms()){ $q="select id, name, type, location from mail_alias order by type, name"; } else { $q="select id, name, type, location from mail_alias, mail_alias_perms where mail_alias.id=mail_alias_perms.alias_id and mail_alias_perms.user_id='".$authinfo->auth_user_id."'"; } if (($r=mysql_query($q)) !=0){ if (mysql_num_rows($r) != 0){ while ($rv=mysql_fetch_array($r)) { $a = new alias($this->source); $a->name=stripslashes(substr($rv['name'], 5)); $a->location=stripslashes($rv['location']); $a->type=stripslashes($rv['type']); $a->alias_id=$rv['id']; $this->alias_list[count($this->alias_list)]=$a; $y++; } return 1; } else { return 0; } } else { print mysql_error(); return 0; } } } //write the aliases from the alias_list to either a file or the db function write_aliases(){ global $authinfo; if ($this->has_perms()==0) return 0; if (($this->source=="file" || ! $this->source) && $this->has_perms()){ $out=fopen($this->local_root."/buda-aliases.txt", 'w+'); if ($out != 0){ for ($x=0; $xalias_list); $x++){ if ($this->alias_list[$x]->name){ if ($this->alias_list[$x]->type!=$type){ if ($type) fwrite($out, "\n\n"); fwrite($out, "# ".$this->alias_list[$x]->type."\n"); $type=$this->alias_list[$x]->type; } fwrite($out, "buda-".$this->alias_list[$x]->name.": :include:".ereg_replace($this->local_root, $this->remote_root, $this->alias_list[$x]->location)."\n"); } } fclose($out); return 1; } else { return 0; } } elseif ($this->source=="db"){ for ($x=0; $xalias_list); $x++){ if ($this->alias_list[$x]->name){ if ($this->has_perms()){ $q="select id from mail_alias where "; $q.=($this->alias_list[$x]->alias_id) ? "id='".$this->alias_list[$x]->alias_id."'" : "name='buda-".$this->alias_list[$x]->name."'"; } else { $q="select id from buda_alias, mail_alias_perms where buda_alias.id=mail_alias_perms.alias_id and mail_alias_perms.user_id='".$authinfo->auth_user_id." and ("; $q.=($this->alias_list[$x]->alias_id) ? "id='".$this->alias_list[$x]->alias_id."'" : "name='buda-".$this->alias_list[$x]->name."'"; } if (($r=mysql_query($q)) != 0){ if ( ($num_rows=mysql_num_rows($r)) == 1) { if (! $this->alias_list[$x]->alias_id){ $rv=mysql_fetch_array($r); $this->alias_list[$x]->alias_id=$rv['id']; } $q="update mail_alias set name='buda-".addslashes($this->alias_list[$x]->name)."', location='".addslashes($this->alias_list[$x]->location)."', "; $q.="type='".addslashes($this->alias_list[$x]->type)."' where id='".$this->alias_list[$x]->alias_id."'"; if (($r=mysql_query($q))==0) { $this->logstring.="update sql: ".$q."
\n".mysql_error()."
\n"; $errors++; } } elseif ($num_rows==0 && $this->has_perms()){ $q="insert into mail_alias (name, location, type) values ('buda-".addslashes($this->alias_list[$x]->name)."',". "'".addslashes($this->alias_list[$x]->location)."', ". "'".addslashes($this->alias_list[$x]->type)."')"; if (($r=mysql_query($q))==0) { $this->logstring.="insert sql: ".$q."
\n".mysql_error()."
\n"; $errors++; } } elseif ($num_rows>1){ $this->logstring.="More than one match for alias: ".$this->alias_list[$x]->name."\n"; $errors++; } } else { $this->logstring.="Sql error: ".mysql_error(); $errors++; } } } if ($errors==0){ return 1; } else { return 0; } } } // drop a given alias from the alias_list - the changes are not 'saved' until write_aliases is called // the passed argument must be the 'location' or index of the alias within alias_list // get the index using find_alias function drop_alias($index){ //this one we will only do for db - the update to the file will have to be done // through write_aliases using a source of file if ($this->alias_list[$index]->alias_id){ $q="delete from mail_alias where id='".$this->alias_list[$index]->alias_id."'"; if (mysql_query($q)==0){ $this->logstring.=mysql_error(); return 0; } else { $this->alias_list[$index]=new alias($this->source); return 1; } } else { return 0; } } //find an entry in the alias_list and return its location within alias_list function find_alias(){ if (! $this->filter) return 0; for ($x=0; $xalias_list); $x++){ if (ereg($this->filter, $this->alias_list[$x]->name)) return $x; } return -1; } function find_alias_id(){ if (! $this->filter) return 0; //if the filter is not a number, find the alias by name, otherwise assume the number is the id if (intval($this->filter)==0) return $this->find_alias(); for ($x=0; $xalias_list); $x++){ if ($this->alias_list[$x]->alias_id==$this->filter) return $x; } return -1; } //add an alias to the list - the changes are not 'saved' until write_aliases is called function add_alias($name, $type, $location){ if ($name && $type && $location){ $filter=$this->filter; $this->filter=$name; if ($this->find_alias()>=0){ $this->logstring.="Alias already exists\n"; $this->filter=$filter; return -1; } else { $a = new alias($this->source); $a->name=$name; $a->type=$type; $a->location=$location; $this->alias_list[count($this->alias_list)]=$a; $this->filter=$filter; return 1; } } else { return 0; } } //provide a list of the aliases- will only return entries matching 'filter' function list_aliases($class, $alias_editlink, $email_editlink){ $str.="Total Aliases: ".count($this->alias_list)."
"; $str.=""; for ($x=0; $xalias_list); $x++){ if (ereg($this->filter, $this->alias_list[$x]->name) || $this->filter=="display_all"){ $str.="". "". "". "". ""; } } $str.="
".(($alias_editlink) ? ereg_replace("##id##", (($this->alias_list[$x]->alias_id) ? $this->alias_list[$x]->alias_id : $this->alias_list[$x]->name), $alias_editlink) : "")."".$this->alias_list[$x]->name."".$this->alias_list[$x]->location."
"; return $str; } function change_alias($index, $name, $location, $type){ if ($this->has_perms() && $index && $name && $location && $type){ $this->alias_list[$index]->location=$location; $this->alias_list[$index]->name=$name; $this->alias_list[$index]->type=$type; return 1; } else { return 0; } } function add_alias_perms($index, $user_id){ return $this->alias_list[$index]->add_perms($user_id); } function drop_alias_perms($index, $user_id){ return $this->alias_list[$index]->remove_perms($user_id); } //------------------------------------------------------------------------------- // meta functions to manipulate the email list(s) for aliases //------------------------------------------------------------------------------- function edit_alias($class, $index, $alias_editlink, $email_editlink, $perms_editlink, $form){ global $authinfo; if (! $this->has_perms()) $form=""; if ($this->alias_list[$index]->has_perms()){ $str.=($form) ? "
". "". "". "alias_list[$index]->alias_id) ? $this->alias_list[$index]->alias_id : $this->alias_list[$index]->name)."\">" : ""; $str.=""; $str.= "". "". "". "\n"; if ($this->has_perms()){ $str.=""; $str.="\n"; $str.="". "\n"; } } else { $str.="\n"; } $str.="\n"; $str.="\n"; if ($this->has_perms()){ $str.="\n"; $this->alias_list[$index]->read_perms_list(); $str.="\n"; } $str.="
Alias: ".(($form) ? "alias_list[$index]->name.($form ? "\">" :"")."".(($alias_editlink) ? ereg_replace("##id##", (($this->alias_list[$index]->alias_id) ? $this->alias_list[$index]->alias_id : $this->alias_list[$index]->name), $alias_editlink) : "")."
Associated Virtual Users".$this->get_assoc_vu($this->alias_list[$index]->name)."
 
Location:".(($form) ? "alias_list[$index]->location.($form ? "\">" :"")."
Type: \n"; if ($form){ $str.="\n
Type:".$this->alias_list[$index]->type."
 
Email Addresses:".$this->alias_list[$index]->list_email('
', ereg_replace("##alias##",(($this->alias_list[$index]->alias_id) ? $this->alias_list[$index]->alias_id : $this->alias_list[$index]->name),$email_editlink))."
 
Alias Perms:".$this->alias_list[$index]->list_perms('
', ereg_replace("##alias##",(($this->alias_list[$index]->alias_id) ? $this->alias_list[$index]->alias_id : $this->alias_list[$index]->name),$perms_editlink))."
\n"; $str.=($form) ? "
" : ""; } else { $str.="Sorry, you do not have permissions to edit this object"; } return $str; } function add_email($index, $email, $check){ return $this->alias_list[$index]->add_email($email, $check); } function drop_email($index, $email){ return $this->alias_list[$index]->drop_email($email); } function write_alias($index){ return $this->alias_list[$index]->write_alias(); } function load_aliases($index){ $this->logstring.=$this->alias_list[$index]->read_alias(); return 1; } function set_alias_source($index, $source){ $this->alias_list[$index]->source=$source; } //------------------------------------------------------------------------------- //deal with the virtual user table //------------------------------------------------------------------------------- function edit_virtual_user($class, $index, $editlink, $aliaslink, $form){ if ($this->has_perms()){ $str.=($form) ? "
". "". "". "virtual_user_list[$index]->vu_id) ? $this->virtual_user_list[$index]->vu_id : $this->virtual_user_list[$index]->name)."\">" : ""; $str.=""; $str.="". "". "". "". "". ""; $str.=""; $str.=""; } else { $str.=$this->virtual_user_list[$index]->type.""; } $str.="
Name: ".(($form) ? "virtual_user_list[$index]->name.($form ? "\">" :"")."".(($editlink) ? ereg_replace("##id##", (($this->virtual_user_list[$index]->vu_id) ? $this->virtual_user_list[$index]->vu_id : $this->virtual_user_list[$index]->name), $editlink) : "")."
Alias: ".(($form) ? "virtual_user_list[$index]->alias.($form ? "\">" :"")."".ereg_replace("##id##", $this->virtual_user_list[$index]->alias, $aliaslink)."
Type: "; if ($form){ $str.="
"; $str.=($form) ? "
" : ""; } else { $str.="Sorry, you do not have permissions to edit this object"; } return $str; } function change_virtual_user($index, $name, $alias, $type){ if ($this->has_perms() && $index && $name && $alias && $type){ $this->virtual_user_list[$index]->alias=$alias; $this->virtual_user_list[$index]->name=$name; $this->virtual_user_list[$index]->type=$type; return 1; } else { return 0; } } //add a virutal_user - changes are not saved until write_virtual_users is called function add_virtual_user($name, $alias, $type){ if ($name && $type && $alias){ $filter=$this->filter; $this->filter=$name; if ($this->find_virtual_user()>=0){ $this->logstring.="Virtual User already exists\n"; $this->filter=$filter; return -1; } else { $vu = new virtual_user(); $vu->name=$name; $vu->type=$type; $vu->alias=$alias; $this->virtual_user_list[count($this->virtual_user_list)]=$vu; $this->filter=$filter; return 1; } } else { return 0; } } function read_virtual_user_types(){ $q="select distinct type from mail_vu order by type"; $r=mysql_query($q); if ($r !=0){ if (mysql_num_rows($r) != 0){ while ($rv=mysql_fetch_array($r)) { $this->virtual_user_types[count($this->virtual_user_types)]=stripslashes($rv['type']); $y++; } return 1; } else { return 0; } } else { return 0; } } //find a virtual user function find_virtual_user(){ if (! $this->filter) return -1; for ($x=0; $xvirtual_user_list); $x++){ if (ereg($this->filter, $this->virtual_user_list[$x]->name)) return $x; if (ereg($this->filter, $this->virtual_user_list[$x]->alias)) return $x; } return -1; } function find_virtual_user_id(){ if (! $this->filter) return -1; if (intval($this->filter)==0) return $this->find_virtual_user(); for ($x=0; $xvirtual_user_list); $x++){ if ($this->virtual_user_list[$x]->vu_id==$this->filter) return $x; } return -1; } //find a virtual user function get_assoc_vu($filter){ for ($x=0; $xvirtual_user_list); $x++){ if ($filter==$this->virtual_user_list[$x]->alias) $str.=(($str) ? '
' : '').$this->virtual_user_list[$x]->name; } return $str; } //drop a virtual user - changes are not saved until write_virtual_users is called function drop_virtual_user($index){ //this one we will only do for db - the update to the file will have to be done // through write_aliases using a source of file if ($this->virtual_user_list[$index]->vu_id){ $q="delete from mail_vu where id='".$this->virtual_user_list[$index]->vu_id."'"; if (mysql_query($q)==0){ $this->logstring.=mysql_error(); return 0; } else { $this->virtual_user_list[$index]=new virtual_user(); return 1; } } else { return 0; } } //provide a list of virtual users matching filter function list_virtual_users($class, $editlink){ $str.="Total Virtual Users: ".count($this->virtual_user_list)."
"; $str.=""; for ($x=0; $xvirtual_user_list); $x++){ if (ereg($this->filter, $this->virtual_user_list[$x]->name) || $this->filter=="display_all") $str.="". "". "". "". ""; } $str.="
".(($editlink) ? ereg_replace("##id##", (($this->virtual_user_list[$x]->vu_id) ? $this->virtual_user_list[$x]->vu_id : $this->virtual_user_list[$x]->name), $editlink) : "")."".$this->virtual_user_list[$x]->name."".$this->virtual_user_list[$x]->alias."
"; return $str; } //read the virtual users table from either a file or the db table function read_virtual_users(){ if (count($this->virtual_user_list)>0) $this->virtual_user_list=array(); if ($this->source == "file" || ! $this->source){ //check to see if the file exists... if (! file_exists($this->local_root."/buda-virtualusertable.txt")) return 0; $in=fopen($this->local_root."/buda-virtusertable.txt",'r'); if ($in !=0){ while(! feof($in)){ $tempLine=chop(fgets($in, 4096)); if ($tempLine && ! ereg("\#",$tempLine)){ $items=array(); $items = explode("\t", $tempLine); $vu = new virtual_user(); $vu->name=ltrim(rtrim($items[0])); $vu->alias=substr(ltrim(rtrim($items[count($items)-1])), 5); $vu->type=$type; $this->virtual_user_list[count($this->virtual_user_list)]=$vu; } elseif ($tempLine && ereg("\#", $tempLine)){ $type=ltrim(rtrim(ereg_replace("\#", "", $tempLine))); } $y++; } fclose($in); return 1; } else { return 0; } } else { $q="select id, name, alias, type from mail_vu order by type, name"; $r=mysql_query($q); if ($r !=0){ if (mysql_num_rows($r)!=0){ while ($rv=mysql_fetch_array($r)) { $vu = new virtual_user(); $vu->name=stripslashes($rv['name']); $vu->alias=substr(stripslashes($rv['alias']), 5); $vu->type=stripslashes($rv['type']); $vu->vu_id=$rv['id']; $this->virtual_user_list[count($this->virtual_user_list)]=$vu; $y++; } return 1; } else { return 0; } } else { return 0; } } } //write the virtual users table from the virtual_user_list to either a file or the db table function write_virtual_users(){ if ($this->has_perms()==0) return 0; if ($this->source=="file" || ! $this->source){ $out=fopen($this->local_root."/buda-virtusertable.txt", 'w+'); if ($out != 0){ for ($x=0; $xvirtual_user_list); $x++){ if ($this->virtual_user_list[$x]->name){ if ($this->virtual_user_list[$x]->type!=$type){ if ($type) fwrite($out, "\n\n"); fwrite($out, "# ".$this->virtual_user_list[$x]->type."\n"); $type=$this->virtual_user_list[$x]->type; } fwrite($out, $this->virtual_user_list[$x]->name."\tbuda-".$this->virtual_user_list[$x]->alias."\n"); } } fclose($out); return 1; } else { return 0; } } elseif ($this->source=="db"){ for ($x=0; $xvirtual_user_list); $x++){ if ($this->virtual_user_list[$x]->name){ $q="select id from mail_vu where "; $q.=($this->virtual_user_list[$x]->vu_id) ? "id='".$this->virtual_user_list[$x]->vu_id."'" : "name='".$this->virtual_user_list[$x]->name."'"; if (($r=mysql_query($q)) != 0){ if ( ($num_rows=mysql_num_rows($r)) == 1) { if (! $this->virtual_user_list[$x]->vu_id){ $rv=mysql_fetch_array($r); $this->virtual_user_list[$x]->vu_id=$rv['id']; } $q="update mail_vu set name='".addslashes($this->virtual_user_list[$x]->name)."', ". "alias='buda-".addslashes($this->virtual_user_list[$x]->alias)."', ". "type='".addslashes($this->virtual_user_list[$x]->type)."' where id='".$this->virtual_user_list[$x]->vu_id."'"; if (($r=mysql_query($q))==0) { $this->logstring.=mysql_error(); $errors++; } } elseif ($num_rows==0){ $q="insert into mail_vu (name, alias, type) values (". "'".addslashes($this->virtual_user_list[$x]->name)."',". "'buda-".addslashes($this->virtual_user_list[$x]->alias)."', ". "'".addslashes($this->virtual_user_list[$x]->type)."')"; if (($r=mysql_query($q))==0) { $this->logstring.=mysql_error(); $errors++; } } elseif ($num_rows>1){ $logstring.="More than one match for alias: ".$this->virtual_user_list[$x]->name."\n"; $errors++; } } else { $errors++; } } } if ($errors==0){ return 1; } else { return 0; } } } function has_perms(){ global $authinfo; if ($authinfo->auth_user_id){ if (isGroupMember('Admin', $authinfo->auth_user_id)==1) return 1; } return 0; } } ?>