Skip to content
system.inc.php 35.3 KiB
Newer Older
	    $line = trim($line);
	    if($line != ""){
	      $elms = explode("\t", $line);
	      foreach($elms as $elm){
	        if(trim($elm) != "") $f[] = $elm;
	      }
	      if(!empty($f) && stristr($f[3], "userquota") && stristr($f[3], "groupquota")){
	        $q_dirs[] = trim($f[1]);
	      }
	      unset($f);
	    }
	  }
	  if(!empty($q_dirs)){
	    return $q_dirs;
	  } else {
	    return false;
	  }
	}
	
	/**
	 * Scan the trash for virusses infection
	 *
	 */
	function make_trashscan(){
		global $app;
	  	//trashscan erstellen
	  	// Template ffnen
	  	$app->tpl->clear_all();
	  	$app->tpl->define( array(table    => "trashscan.master"));
	
	  	if(!isset($this->server_conf["virusadmin"]) || trim($this->server_conf["virusadmin"]) == "") $this->server_conf["virusadmin"] = "admispconfig@localhost";
	  	if(substr($this->server_conf["virusadmin"],0,1) == "#"){
		    $notify = "no";
	  	} else {
		    $notify = "yes";
	  	}
	
	  	// Variablen zuweisen
	  	$app->tpl->assign( array(VIRUSADMIN => $this->server_conf["virusadmin"],
	                           NOTIFICATION => $notify));
	
	  	$app->tpl->parse(TABLE, table);
	
	  	$trashscan_text = $app->tpl->fetch();
	
	  	$datei = "/home/admispconfig/ispconfig/tools/clamav/bin/trashscan";
	  	$app->file->wf($datei, $trashscan_text);
	
	  	exec("chown admispconfig:admispconfig $datei &> /dev/null");
	  	exec("chmod 755 $datei");
	}
	
	/**
	 * Get the current time
	 *
	 */
	function get_time(){
	  $addr = "http://www.ispconfig.org/";
	  $timeout = 1;
	  $url_parts = parse_url($addr);
	  $path = $url_parts["path"];
	  $port = 80;
	  $urlHandle = @fsockopen($url_parts["host"], $port, $errno, $errstr, $timeout);
	  if ($urlHandle){
	    socket_set_timeout($urlHandle, $timeout);
	
	    $urlString = "GET $path HTTP/1.0\r\nHost: ".$url_parts["host"]."\r\nConnection: Keep-Alive\r\nUser-Agent: Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1)\r\n";
	    if ($user) $urlString .= "Authorization: Basic ".base64_encode("$user:$pass")."\r\n";
	    $urlString .= "\r\n";
	    fputs($urlHandle, $urlString);
	
	    $month["Jan"] = "01";
	    $month["Feb"] = "02";
	    $month["Mar"] = "03";
	    $month["Apr"] = "04";
	    $month["May"] = "05";
	    $month["Jun"] = "06";
	    $month["Jul"] = "07";
	    $month["Aug"] = "08";
	    $month["Sep"] = "09";
	    $month["Oct"] = "10";
	    $month["Nov"] = "11";
	    $month["Dec"] = "12";
	    $c = 0;
	    $l = 0;
	    $startzeit = time();
	    while(!feof($urlHandle) && $c < 2 && $l == 0){
	      $line = trim(fgets($urlHandle,128));
	      $response .= $line;
	      $c = time() - $startzeit;
	      if($line == "" || substr($line, 0, 5) == "Date:") $l += 1; // nur den Header auslesen
	      if(substr($line, 0, 5) == "Date:"){
	        $parts = explode(" ", $line);
	        $tag = $parts[2];
	        $monat = $month[$parts[3]];
	        $jahr = $parts[4];
	        list($stunde, $minute, $sekunde) = explode(":", $parts[5]);
	        $timestamp = mktime($stunde,$minute,$sekunde,$monat,$tag,$jahr);
	      }
	    }
	
	    @fclose($urlHandle);
	
	    return $timestamp;
	  } else {
	    @fclose($urlHandle);
	    return false;
	  }
	}