[ Index ]
 

Code source de Dolibarr 2.0.1

Accédez au Source d'autres logiciels libres

Classes | Fonctions | Variables | Constantes | Tables

title

Body

[fermer]

/htdocs/telephonie/script/ -> commande_presel_statut_view.php (source)

   1  <?PHP
   2  /* Copyright (C) 2005 Rodolphe Quiedeville <rodolphe@quiedeville.org>
   3   *
   4   * This program is free software; you can redistribute it and/or modify
   5   * it under the terms of the GNU General Public License as published by
   6   * the Free Software Foundation; either version 2 of the License, or
   7   * (at your option) any later version.
   8   *
   9   * This program is distributed in the hope that it will be useful,
  10   * but WITHOUT ANY WARRANTY; without even the implied warranty of
  11   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  12   * GNU General Public License for more details.
  13   *
  14   * You should have received a copy of the GNU General Public License
  15   * along with this program; if not, write to the Free Software
  16   * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
  17   *
  18   * $Id: commande_presel_statut_view.php,v 1.4 2005/12/01 13:53:08 rodolphe Exp $
  19   * $Source: /cvsroot/dolibarr/dolibarr/htdocs/telephonie/script/commande_presel_statut_view.php,v $
  20   *
  21   *
  22   * Recupération des fichiers CDR
  23   *
  24   */
  25  require  ("../../master.inc.php");
  26  require_once DOL_DOCUMENT_ROOT."/telephonie/lignetel.class.php";
  27  
  28  set_time_limit(0);
  29  
  30  $host          = CMD_PRESEL_WEB_HOST;
  31  $user_login    = CMD_PRESEL_WEB_USER;
  32  $user_passwd   = CMD_PRESEL_WEB_PASS;
  33  
  34  $sql = "SELECT rowid,ligne";
  35  $sql .= " FROM ".MAIN_DB_PREFIX."telephonie_societe_ligne";
  36  $sql .= " WHERE fk_fournisseur = 4";
  37  $sql .= " AND statut = 2;";
  38  
  39  $resql = $db->query($sql);
  40  
  41  if ($resql)
  42  {
  43    $ids = array();
  44    while ($row = $db->fetch_row($resql))
  45      {
  46        array_push($ids, $row[1]);
  47      }
  48  }
  49  else
  50  {
  51    exit(1);
  52  }
  53  
  54  GetPreselection_byRef($db, $host, $user_login, $user_passwd, $ids);
  55  
  56  /*
  57   * Fonctions
  58   *
  59   */
  60  
  61  function GetPreselection_byRef($db, $host, $user_login, $user_passwd, $ids)
  62  {  
  63    $numcli = sizeof($ids);
  64    $i = 0;
  65  
  66    foreach($ids as $cli)
  67      {
  68        $i++;
  69        $fp = @fsockopen($host, 80, $errno, $errstr, 30);
  70        if (!$fp)
  71      {
  72        print "Impossible de se connecter au server $errstr ($errno)";
  73      }
  74        else
  75      {
  76        $ligne_numero = "";
  77        $ligne_service = "";
  78        $ligne_presel = "";
  79  
  80        //GetPreselection_byRef  
  81        $url = "/AzurApp_websvc_b3gdb/account.asmx/GetPreselection_byRef?";
  82  
  83        $url .= "user_login=".  $user_login;
  84        $url .= "&user_passwd=".$user_passwd;
  85        $url .= "&telnum=".$cli;
  86  
  87        $out = "GET $url HTTP/1.1\r\n";
  88        $out .= "Host: $host\r\n";
  89        $out .= "Connection: Close\r\n\r\n";
  90        
  91        if (fwrite($fp, $out) )
  92          {
  93            while (!feof($fp))
  94          {
  95            $line = fgets($fp, 1024);
  96            
  97            if (preg_match("/<Preselection .* \/>/",$line))
  98              {          
  99                $results = split(" ",trim($line));
 100                //print_r($results);
 101                
 102                $array = array();
 103                preg_match('/telnum="([0123456789]*)"/', $line, $array);
 104                $ligne_numero = $array[1];
 105  
 106                $array = array();
 107                preg_match('/ServiceActive="([\S]*)"/i', $line, $array);
 108                $service_active = $array[1];
 109                
 110                $array = array();
 111                preg_match('/PreSelectionActive="([\S]*)"/i', $line, $array);
 112                $presel_active = $array[1];
 113                
 114                $array = array();
 115                preg_match('/Service_Statut="([\S]*)"/i', $line, $array);
 116                $ligne_service = $array[1];
 117                
 118                $array = array();
 119                preg_match('/PreSelection_Statut="([\S]*)"/i', $line, $array);
 120                $ligne_presel = $array[1];
 121                
 122                print "$i/$numcli ";
 123                print $ligne_numero." ";
 124                print "$service_active/$presel_active ";
 125                print substr($ligne_service.str_repeat(" ",20),0,20);
 126                print substr($ligne_presel.str_repeat(" ",20),0,20);
 127                print "\n";
 128              }
 129            
 130            if (preg_match("/<Error .* \/>/",$line))
 131              {          
 132                $array = array();
 133                preg_match('/libelle="(.*)" xmlns:d4p1/', $line, $array);
 134                
 135                print "$i/$numcli ";
 136                print "$cli ErreurAPI ".$array[1]."\n";
 137              }
 138          }
 139          }
 140        else
 141          {
 142            print "Impossible d'ecrire sur la socket\n";
 143            print "Host : $host\n";
 144            print "URL : $url\n";
 145          }
 146        fclose($fp);
 147      }
 148      }
 149  }
 150  
 151  ?>


Généré le : Mon Nov 26 12:29:37 2007 par Balluche grâce à PHPXref 0.7
  Clicky Web Analytics