bpssoft
2007-11-11 55da9053f974c69bb888892714e8d0f09403734d
server/lib/classes/system.inc.php
@@ -35,7 +35,12 @@
var $server_conf;
var $data;
function system(){
   /**
    * Construct for this class
    *
    * @return system
    */
   public function system(){
  global $go_info;
  $this->server_id = $go_info["isp"]["server_id"];
  $this->server_conf = $go_info["isp"]["server_conf"];
@@ -44,7 +49,12 @@
  $this->server_conf["group_datei"] = '/etc/group';
}
function hostname(){
   /**
    * Get the hostname from the server
    *
    * @return string
    */
   public function hostname(){
  $dist = $this->server_conf["dist"];
  ob_start();
@@ -67,7 +77,11 @@
  return $hostname;
}
function adduser($user_username, $uid, $gid, $username, $homedir, $shell, $passwort = '*'){
   /**
    * Add an user to the system
    *
    */
   public function adduser($user_username, $uid, $gid, $username, $homedir, $shell, $passwort = '*'){
  global $app;
  if($this->is_user($user_username)){
    return false;
@@ -88,7 +102,6 @@
                      $new_passwd = "\n$user_username:$passwort:$uid:$gid::0:0:$username:$homedir:$shell\n";
            }
            $app->file->af($shadow_datei, $new_passwd);
                // TB: leere Zeilen entfernen
                $app->file->remove_blank_lines($shadow_datei);
                $app->file->remove_blank_lines($user_datei);
@@ -96,23 +109,30 @@
                //$this->order_users_groups();
            if($shadow_datei != "/etc/shadow"){
                      $app->file->af($shadow_datei, "\n");
                        // TB: leere Zeilen entfernen
                        $app->file->remove_blank_lines($shadow_datei);
                      $app->log->caselog("pwd_mkdb $shadow_datei &> /dev/null", $this->FILE, __LINE__);
            }
            return true;
        }
  }
}
   /**
    * Update users when someone edit it
    *
    */
function updateuser($user_username, $uid, $gid, $username, $homedir, $shell, $passwort = '*'){
      //* First delete the users
  $this->deluser($user_username);
      //* Add the user again
  $this->adduser($user_username, $uid, $gid, $username, $homedir, $shell, $passwort);
}
   /**
    * Lock the user
    *
    */
function deactivateuser($user_username){
  $passwort = str_rot13($this->getpasswd($user_username));
  $user_attr = $this->get_user_attributes($user_username);
@@ -124,7 +144,10 @@
  $this->deluser($user_username);
  $this->adduser($user_username, $uid, $gid, $username, $homedir, $shell, $passwort);
}
   /**
    * Delete a user from the system
    *
    */
function deluser($user_username){
  global $app;
  if($this->is_user($user_username)){
@@ -197,6 +220,10 @@
  }
}
   /**
    * Add a usergroup to the system
    *
    */
function addgroup($group, $gid, $members = ''){
  global $app;
  if($this->is_group($group)){
@@ -216,11 +243,19 @@
  }
}
   /**
    * Update usersgroup in way to delete and add it again
    *
    */
function updategroup($group, $gid, $members = ''){
  $this->delgroup($group);
  $this->addgroup($group, $gid, $members);
}
   /**
    * Delete a usergroup from the system
    *
    */
function delgroup($group){
  global $app;
  if($this->is_group($group)){
@@ -252,7 +287,10 @@
    return false;
  }
}
   /**
    * Order usergroups
    *
    */
function order_users_groups(){
  global $app;
  $user_datei = $this->server_conf["passwd_datei"];
@@ -318,6 +356,10 @@
  unset($arr);
}
   /**
    * Find a user / group id
    *
    */
function find_uid_gid($min, $max){
  global $app;
  if($min < $max && $min >= 0 && $max >= 0 && $min <= 65536 && $max <= 65536 && is_int($min) && is_int($max)){
@@ -382,6 +424,10 @@
  }
}
   /**
    * Check if the users is really a user into the system
    *
    */
function is_user($user){
  global $app;
  $user_datei = $this->server_conf["passwd_datei"];
@@ -398,6 +444,10 @@
  return false;
}
   /**
    * Check if the group is on this system
    *
    */
function is_group($group){
  global $app;
  $group_datei = $this->server_conf["group_datei"];
@@ -430,6 +480,10 @@
  return false;
}
   /**
    * Get the groups of an user
    *
    */
function get_user_groups($username){
  global $app;
  $user_groups = array();
@@ -452,6 +506,10 @@
  return '';
}
   /**
    * Get a user password
    *
    */
function getpasswd($user){
  global $app;
  if($this->is_user($user)){
@@ -471,6 +529,10 @@
  }
}
   /**
    * Get the user id from an user
    *
    */
function getuid($user){
  global $app;
  if($this->is_user($user)){
@@ -490,6 +552,10 @@
  }
}
   /**
    * Get all information from a user
    *
    */
function get_user_attributes($user){
  global $app;
  if($this->is_user($user)){
@@ -518,6 +584,10 @@
  }
}
   /**
    * Edit the owner of a file
    *
    */
function chown($file, $owner, $group = ''){
  $owner_change = @chown($file, $owner);
  if($group != ""){
@@ -532,6 +602,10 @@
  }
}
   /**
    * Add an user to a specific group
    *
    */
function add_user_to_group($group, $user = 'admispconfig'){
  global $app;
  $group_file = $app->file->rf($this->server_conf["group_datei"]);
@@ -597,6 +671,9 @@
  }
}
   /**boot autostart etc
    *
    */
function rc_edit($service, $rl, $action){
  // $action = "on|off";
  global $app;
@@ -651,6 +728,10 @@
  }
}
   /**
    * Filter information from the commands
    *
    */
function grep($content, $string, $params = ''){
  global $app;
  // params: i, v, w
@@ -697,6 +778,10 @@
  }
}
   /**
    * Strip content from fields
    *
    */
function cut($content, $field, $delimiter = ':'){
  global $app;
  $content = $app->file->unix_nl($content);
@@ -715,13 +800,21 @@
  }
}
   /**
    * Get the content off a file
    *
    */
function cat($file){
  global $app;
  return $app->file->rf($file);
}
   /**
    * Control services to restart etc
    *
    */
function daemon_init($daemon, $action){
  // $action = start|stop|restart|reload
      //* $action = start|stop|restart|reload
  global $app;
  $dist = $this->server_conf["dist"];
  $dist_init_scripts = $this->server_conf["dist_init_scripts"];
@@ -791,6 +884,10 @@
  return bindec($f1).".".bindec($f2).".".bindec($f3).".".bindec($f4);
}
   /**
    * Make a broadcast address from an IP number in combination with netmask
    *
    */
function broadcast($ip, $netmask){
  $netmask = $this->netmask($netmask);
  $binary_netmask = $this->binary_netmask($netmask);
@@ -802,6 +899,10 @@
  return bindec($f1).".".bindec($f2).".".bindec($f3).".".bindec($f4);
}
   /**
    * Get the network address information
    *
    */
function network_info(){
  $dist = $this->server_conf["dist"];
  ob_start();
@@ -842,6 +943,10 @@
  }
}
   /**
    * Configure the network settings from the system
    *
    */
function network_config(){
  $ifconfig = $this->network_info();
  if($ifconfig){
@@ -912,6 +1017,10 @@
  }
}
   /**
    * Scan the trash for virusses infection
    *
    */
function make_trashscan(){
  global $app;
  //trashscan erstellen
@@ -941,6 +1050,10 @@
  exec("chmod 755 $datei");
}
   /**
    * Get the current time
    *
    */
function get_time(){
  $addr = "http://www.ispconfig.org/";
  $timeout = 1;