summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 475bf77)
raw | patch | inline | side by side (parent: 475bf77)
author | hickert <hickert@594d385d-05f5-0310-b6e9-bd551577e9d8> | |
Wed, 26 Mar 2008 14:47:12 +0000 (14:47 +0000) | ||
committer | hickert <hickert@594d385d-05f5-0310-b6e9-bd551577e9d8> | |
Wed, 26 Mar 2008 14:47:12 +0000 (14:47 +0000) |
-Updated error message. Added timeout message
git-svn-id: https://oss.gonicus.de/repositories/gosa/trunk@9999 594d385d-05f5-0310-b6e9-bd551577e9d8
git-svn-id: https://oss.gonicus.de/repositories/gosa/trunk@9999 594d385d-05f5-0310-b6e9-bd551577e9d8
gosa-core/include/class_gosaSupportDaemon.inc | patch | blob | history | |
gosa-core/include/class_socketClient.inc | patch | blob | history |
diff --git a/gosa-core/include/class_gosaSupportDaemon.inc b/gosa-core/include/class_gosaSupportDaemon.inc
index 219fdbb36ca2ed0d03dcce6ff3d5524e5527e3c8..8270f9ffc2fb7abf841ae56f0b5d6a8e04139834 100644 (file)
}
- public function FAI_get_packages($release,$package = "")
+ public function FAI_get_packages($release,$attrs, $package="")
{
$this->reset_error();
+ $ret = array();
+ if(!is_array($attrs) || !count($attrs)){
+ trigger_error("Second parameter must be an array. With at least one attribute name.");
+ return($ret);
+ }
+
+ $attr = "<select>package</select>";
+ foreach($attrs as $at){
+# $attr.= "<select>".trim($at)."</select>";
+ }
+
if(empty($package)){
$xml_msg = "<xml><header>gosa_query_packages_list</header><target>GOSA</target><source>GOSA</source>".
- "<where><clause><phrase><distribution>".$release."</distribution></phrase></clause></where></xml>";
+ $attr.
+ "<where><clause><phrase><distribution>".$release."</distribution></phrase></clause></where><limit>10</limit></xml>";
}else{
$xml_msg =
"<xml><header>gosa_query_packages_list</header><target>GOSA</target><source>GOSA</source>".
+ $attr.
"<where><clause>".
"<connector>AND</connector>".
"<phrase><distribution>".$release."</distribution></phrase>".
"<phrase><package>".$package."</package></phrase>".
"</clause></where>".
- "</xml>";
+ "<limit>10</limit></xml>";
}
- $ret = array();
if($this->connect()){
$this->o_sock->write($xml_msg);
$str = trim($this->o_sock->read());
+
+ /* Check if something went wrong while reading */
+ if($this->o_sock->is_error()){
+ $this->set_error($this->o_sock->get_error());
+ return($ret);
+ }
+
$entries = $this->xml_to_array($str);
if(isset($entries['XML']) && is_array($entries['XML'])){
if($this->connect()){
$this->o_sock->write($xml_msg);
$str = trim($this->o_sock->read());
+
+ /* Check if something went wrong while reading */
+ if($this->o_sock->is_error()){
+ $this->set_error($this->o_sock->get_error());
+ return($ret);
+ }
+
$entries = $this->xml_to_array($str);
if(isset($entries['XML']) && is_array($entries['XML'])){
if($this->connect()){
$this->o_sock->write($xml_msg);
$str = trim($this->o_sock->read());
+
+ /* Check if something went wrong while reading */
+ if($this->o_sock->is_error()){
+ $this->set_error($this->o_sock->get_error());
+ return($ret);
+ }
+
$entries = $this->xml_to_array($str);
if(isset($entries['XML']) && is_array($entries['XML'])){
if($this->connect()){
$this->o_sock->write($xml_msg);
$str = trim($this->o_sock->read());
+
+ /* Check if something went wrong while reading */
+ if($this->o_sock->is_error()){
+ $this->set_error($this->o_sock->get_error());
+ return($ret);
+ }
+
$entries = $this->xml_to_array($str);
if(isset($entries['XML']) && is_array($entries['XML'])){
if($this->connect()){
$this->o_sock->write($xml_msg);
$str = trim($this->o_sock->read());
+
+ /* Check if something went wrong while reading */
+ if($this->o_sock->is_error()){
+ $this->set_error($this->o_sock->get_error());
+ return($ret);
+ }
+
$entries = $this->xml_to_array($str);
if(isset($entries['XML']) && is_array($entries['XML'])){
foreach($entries['XML'] as $entry){
if($this->connect()){
$this->o_sock->write($xml_msg);
$str = trim($this->o_sock->read());
+
+ /* Check if something went wrong while reading */
+ if($this->o_sock->is_error()){
+ $this->set_error($this->o_sock->get_error());
+ return($ret);
+ }
+
$entries = $this->xml_to_array($str);
if(isset($entries['XML'])){
foreach($entries['XML'] as $name => $entry){
if($this->connect()){
$this->o_sock->write($xml_msg);
$str = trim($this->o_sock->read());
+
+ /* Check if something went wrong while reading */
+ if($this->o_sock->is_error()){
+ $this->set_error($this->o_sock->get_error());
+ return($ret);
+ }
+
$entries = $this->xml_to_array($str);
if(isset($entries['XML'])){
foreach($entries['XML'] as $name => $entry){
if($this->connect()){
$this->o_sock->write($xml_msg);
$str = trim($this->o_sock->read());
+
+ /* Check if something went wrong while reading */
+ if($this->o_sock->is_error()){
+ $this->set_error($this->o_sock->get_error());
+ return(FALSE);
+ }
+
$entries = $this->xml_to_array($str);
if( isset($entries['XML']['HEADER']) &&
$entries['XML']['HEADER']=="answer" &&
if($this->connect()){
$this->o_sock->write($xml_msg);
$str = trim($this->o_sock->read());
+
+ /* Check if something went wrong while reading */
+ if($this->o_sock->is_error()){
+ $this->set_error($this->o_sock->get_error());
+ return($ret);
+ }
+
$entries = $this->xml_to_array($str);
if( isset($entries['XML']['HEADER']) &&
$entries['XML']['HEADER']=="answer" &&
if($this->connect()){
$this->o_sock->write($xml_msg);
$str = $this->o_sock->read();
+
+ /* Check if something went wrong while reading */
+ if($this->o_sock->is_error()){
+ $this->set_error($this->o_sock->get_error());
+ return($ret);
+ }
+
$entries = $this->xml_to_array($str);
if(isset($entries['XML']) || isset($entries['COUNT'])){
new log("debug","DaemonEvent (IDS) ", "gosaSupportDaemon::remove_entries()", $ids,"SUCCESS");
$this->o_sock->write($xml_msg);
$str = trim($this->o_sock->read());
+
+ /* Check if something went wrong while reading */
+ if($this->o_sock->is_error()){
+ $this->set_error($this->o_sock->get_error());
+ return(FALSE);
+ }
+
$entries = $this->xml_to_array($str);
if(isset($entries['XML'])){
if(isset($entries['XML']['ERROR_STRING'])) {
if($this->connect()){
$this->o_sock->write($xml_msg);
$str = trim($this->o_sock->read());
+
+ /* Check if something went wrong while reading */
+ if($this->o_sock->is_error()){
+ $this->set_error($this->o_sock->get_error());
+ return(0);
+ }
+
$entries = $this->xml_to_array($str);
if(isset($entries['XML'])){
return($entries['XML']['COUNT']);
$this->o_sock->write($data);
if ($answer_expected){
$str = trim($this->o_sock->read());
+
+ /* Check if something went wrong while reading */
+ if($this->o_sock->is_error()){
+ $this->set_error($this->o_sock->get_error());
+ return($ret);
+ }
+
$entries = $this->xml_to_array($str);
if(isset($entries['XML']) && is_array($entries['XML'])){
$ret = $entries;
index 93e49de40190e2da5eb36409d2c88536157d0ac7..1cef298c7289818374fc2fec5eafa602c6662562 100644 (file)
private $handle = NULL;
private $bytes_read = 0;
private $error = "";
- private $b_encrypt = FALSE;
+ private $is_error = FALSE;
+ private $b_encrypt = FALSE;
/* Crypto information */
private $td= NULL;
$this->host= $host;
$this->port= $port;
$this->timeout= $timeout;
+ $this->reset_error();
/* Connect if needed */
if($connect){
public function setEncryptionKey($key)
{
if(!function_exists("mcrypt_get_iv_size")){
- $this->error = _("The mcrypt module was not found. Please install php5-mcrypt.");
+ $this->set_error(_("The mcrypt module was not found. Please install php5-mcrypt."));
$this->ckey = "";
$this->b_encrypt = FALSE;
}
public function open()
{
+ $this->reset_error();
$this->handle = @fsockopen($this->host, $this->port, $this->errno, $this->errstr, $this->timeout);
if(!$this->handle){
$this->handle = NULL;
- $this->error = $this->errstr;
+ $this->set_error( $this->errstr);
}else{
$this->b_data_send = TRUE;
}
+ public function set_error($str)
+ {
+ $this->is_error =TRUE;
+ $this->error=$str;
+ }
+
+
+ public function reset_error()
+ {
+ $this->is_error =FALSE;
+ $this->error = "";
+ }
+
+
+ public function is_error()
+ {
+ return($this->is_error);
+ }
+
+
public function get_error()
{
return $this->error;
public function read()
{
// Output the request results
+ $this->reset_error();
$str = "";
$data = "test";
socket_set_timeout($this->handle,$this->timeout);
}
}
}
- if((microtime(TRUE) - $start) > $this->timeout ){
+ if((microtime(TRUE) - $start) > $this->timeout ){
+ $this->set_error(sprintf(_("Socket timeout of %s seconds reached."),$this->timeout));
break;
}
}