Changeset 1092

Show
Ignore:
Timestamp:
10/03/08 06:12:33 (3 months ago)
Author:
areski
Message:

bad indentation

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/customer/callback.php

    r1091 r1092  
    3838 
    3939 
    40 if ($callback)
     40if ($callback)
    4141         
    42         if (strlen($called)>4 && strlen($calling)>4 && is_numeric($called) && is_numeric($calling)){ 
    43                                  
    44                         $A2B -> DBHandle = DbConnect(); 
    45                         $instance_table = new Table(); 
    46                         $A2B -> set_instance_table ($instance_table); 
    47                         $A2B -> cardnumber = $_SESSION["pr_login"]; 
    48                                  
    49                         if ($A2B -> callingcard_ivr_authenticate_light ($error_msg)){ 
    50                          
    51                                 $RateEngine = new RateEngine(); 
    52                                 $RateEngine -> webui = 0; 
    53                                 // LOOKUP RATE : FIND A RATE FOR THIS DESTINATION 
    54                                  
    55                                 $A2B ->agiconfig['accountcode']=$_SESSION["pr_login"]; 
    56                                 $A2B ->agiconfig['use_dnid']=1; 
    57                                 $A2B ->agiconfig['say_timetocall']=0;                                            
    58                                 $A2B ->dnid = $A2B ->destination = $called; 
    59                                  
    60                                 $resfindrate = $RateEngine->rate_engine_findrates($A2B, $called, $_SESSION["tariff"]); 
    61                                  
    62                                 // IF FIND RATE 
    63                                 if ($resfindrate!=0){                            
    64                                         $res_all_calcultimeout = $RateEngine->rate_engine_all_calcultimeout($A2B, $A2B->credit); 
    65                                         if ($res_all_calcultimeout){                                                     
    66                                                  
    67                                                 // MAKE THE CALL 
    68                                                 if ($RateEngine -> ratecard_obj[0][34]!='-1'){ 
    69                                                         $usetrunk = 34;  
    70                                                         $usetrunk_failover = 1; 
    71                                                         $RateEngine -> usedtrunk = $RateEngine -> ratecard_obj[$k][34]; 
    72                                                 } else { 
    73                                                         $usetrunk = 29; 
    74                                                         $RateEngine -> usedtrunk = $RateEngine -> ratecard_obj[$k][29]; 
    75                                                         $usetrunk_failover = 0; 
     42        if (strlen($called)>4 && strlen($calling)>4 && is_numeric($called) && is_numeric($calling)) { 
     43                 
     44                $A2B -> DBHandle = DbConnect(); 
     45                $instance_table = new Table(); 
     46                $A2B -> set_instance_table ($instance_table); 
     47                $A2B -> cardnumber = $_SESSION["pr_login"]; 
     48                         
     49                if ($A2B -> callingcard_ivr_authenticate_light ($error_msg)){ 
     50                 
     51                        $RateEngine = new RateEngine(); 
     52                        $RateEngine -> webui = 0; 
     53                        // LOOKUP RATE : FIND A RATE FOR THIS DESTINATION 
     54                         
     55                        $A2B ->agiconfig['accountcode']=$_SESSION["pr_login"]; 
     56                        $A2B ->agiconfig['use_dnid']=1; 
     57                        $A2B ->agiconfig['say_timetocall']=0;                                            
     58                        $A2B ->dnid = $A2B ->destination = $called; 
     59                         
     60                        $resfindrate = $RateEngine->rate_engine_findrates($A2B, $called, $_SESSION["tariff"]); 
     61                         
     62                        // IF FIND RATE 
     63                        if ($resfindrate!=0){                            
     64                                $res_all_calcultimeout = $RateEngine->rate_engine_all_calcultimeout($A2B, $A2B->credit); 
     65                                if ($res_all_calcultimeout){                                                     
     66                                         
     67                                        // MAKE THE CALL 
     68                                        if ($RateEngine -> ratecard_obj[0][34]!='-1'){ 
     69                                                $usetrunk = 34;  
     70                                                $usetrunk_failover = 1; 
     71                                                $RateEngine -> usedtrunk = $RateEngine -> ratecard_obj[$k][34]; 
     72                                        } else { 
     73                                                $usetrunk = 29; 
     74                                                $RateEngine -> usedtrunk = $RateEngine -> ratecard_obj[$k][29]; 
     75                                                $usetrunk_failover = 0; 
     76                                        } 
     77                                         
     78                                        $prefix                 = $RateEngine -> ratecard_obj[0][$usetrunk+1]; 
     79                                        $tech                   = $RateEngine -> ratecard_obj[0][$usetrunk+2]; 
     80                                        $ipaddress              = $RateEngine -> ratecard_obj[0][$usetrunk+3]; 
     81                                        $removeprefix   = $RateEngine -> ratecard_obj[0][$usetrunk+4]; 
     82                                        $timeout                = $RateEngine -> ratecard_obj[0]['timeout'];     
     83                                        $failover_trunk = $RateEngine -> ratecard_obj[0][40+$usetrunk_failover]; 
     84                                        $addparameter   = $RateEngine -> ratecard_obj[0][42+$usetrunk_failover]; 
     85                                         
     86                                        $destination = $called; 
     87                                        if (strncmp($destination, $removeprefix, strlen($removeprefix)) == 0) $destination= substr($destination, strlen($removeprefix)); 
     88                                         
     89                                        $pos_dialingnumber = strpos($ipaddress, '%dialingnumber%' ); 
     90                                        $ipaddress = str_replace("%cardnumber%", $A2B->cardnumber, $ipaddress); 
     91                                        $ipaddress = str_replace("%dialingnumber%", $prefix.$destination, $ipaddress); 
     92                                         
     93                                        if ($pos_dialingnumber !== false){                                          
     94                                                $dialstr = "$tech/$ipaddress".$dialparams; 
     95                                        }else{ 
     96                                                if ($A2B->agiconfig['switchdialcommand'] == 1){ 
     97                                                        $dialstr = "$tech/$prefix$destination@$ipaddress".$dialparams; 
     98                                                }else{ 
     99                                                        $dialstr = "$tech/$ipaddress/$prefix$destination".$dialparams; 
    76100                                                } 
    77                                                  
    78                                                 $prefix                 = $RateEngine -> ratecard_obj[0][$usetrunk+1]; 
    79                                                 $tech                   = $RateEngine -> ratecard_obj[0][$usetrunk+2]; 
    80                                                 $ipaddress              = $RateEngine -> ratecard_obj[0][$usetrunk+3]; 
    81                                                 $removeprefix   = $RateEngine -> ratecard_obj[0][$usetrunk+4]; 
    82                                                 $timeout                = $RateEngine -> ratecard_obj[0]['timeout'];     
    83                                                 $failover_trunk = $RateEngine -> ratecard_obj[0][40+$usetrunk_failover]; 
    84                                                 $addparameter   = $RateEngine -> ratecard_obj[0][42+$usetrunk_failover]; 
    85                                                  
    86                                                 $destination = $called; 
    87                                                 if (strncmp($destination, $removeprefix, strlen($removeprefix)) == 0) $destination= substr($destination, strlen($removeprefix)); 
    88                                                  
    89                                                 $pos_dialingnumber = strpos($ipaddress, '%dialingnumber%' ); 
    90                                                 $ipaddress = str_replace("%cardnumber%", $A2B->cardnumber, $ipaddress); 
    91                                                 $ipaddress = str_replace("%dialingnumber%", $prefix.$destination, $ipaddress); 
    92                                                  
    93                                                 if ($pos_dialingnumber !== false){                                          
    94                                                         $dialstr = "$tech/$ipaddress".$dialparams; 
    95                                                 }else{ 
    96                                                         if ($A2B->agiconfig['switchdialcommand'] == 1){ 
    97                                                                 $dialstr = "$tech/$prefix$destination@$ipaddress".$dialparams; 
    98                                                         }else{ 
    99                                                                 $dialstr = "$tech/$ipaddress/$prefix$destination".$dialparams; 
    100                                                         } 
    101                                                 }        
    102                                                  
    103                                                 //ADDITIONAL PARAMETER                  %dialingnumber%,        %cardnumber%     
    104                                                 if (strlen($addparameter)>0){ 
    105                                                         $addparameter = str_replace("%cardnumber%", $A2B->cardnumber, $addparameter); 
    106                                                         $addparameter = str_replace("%dialingnumber%", $prefix.$destination, $addparameter); 
    107                                                         $dialstr .= $addparameter; 
    108                                                 } 
    109                                                  
     101                                        }        
     102                                         
     103                                        //ADDITIONAL PARAMETER                  %dialingnumber%,        %cardnumber%     
     104                                        if (strlen($addparameter)>0){ 
     105                                                $addparameter = str_replace("%cardnumber%", $A2B->cardnumber, $addparameter); 
     106                                                $addparameter = str_replace("%dialingnumber%", $prefix.$destination, $addparameter); 
     107                                                $dialstr .= $addparameter; 
     108                                        } 
     109                                         
     110                                        $channel= $dialstr; 
     111                                        $exten = $calling; 
     112                                        $context = $A2B -> config["callback"]['context_callback']; 
     113                                        $id_server_group = $A2B -> config["callback"]['id_server_group']; 
     114                                        $priority=1; 
     115                                        $timeout = $A2B -> config["callback"]['timeout']*1000; 
     116                                        $application=''; 
     117                                        $callerid = $A2B -> config["callback"]['callerid']; 
     118                                        $account = $_SESSION["pr_login"]; 
     119                                         
     120                                        $uniqueid       =  MDP_NUMERIC(5).'-'.MDP_STRING(7); 
     121                                        $status = 'PENDING'; 
     122                                        $server_ip = 'localhost'; 
     123                                        $num_attempt = 0; 
     124                                        $variable = "CALLED=$called|CALLING=$calling|CBID=$uniqueid|LEG=".$A2B->cardnumber; 
     125                                         
     126                                        $QUERY = " INSERT INTO cc_callback_spool (uniqueid, status, server_ip, num_attempt, channel, exten, context, priority, variable, id_server_group, callback_time, account, callerid, timeout ) VALUES ('$uniqueid', '$status', '$server_ip', '$num_attempt', '$channel', '$exten', '$context', '$priority', '$variable', '$id_server_group',  now(), '$account', '$callerid', '30000')"; 
     127                                        $res = $A2B -> DBHandle -> Execute($QUERY); 
     128                                         
     129                                        if (!$res){ 
     130                                                $error_msg= gettext("Cannot insert the callback request in the spool!"); 
     131                                        }else{ 
     132                                                $error_msg = gettext("Your callback request has been queued correctly!"); 
     133                                                $color_msg = 'green'; 
     134                                        } 
     135                                         
     136                                        /* 
     137                                        $as = new AGI_AsteriskManager(); 
     138                                         
     139                                        // && CONNECTING  connect($server=NULL, $username=NULL, $secret=NULL) 
     140                                         
     141                                        $res = $as->connect(MANAGER_HOST,MANAGER_USERNAME,MANAGER_SECRET); 
     142                                         
     143                                        if      ($res){ 
    110144                                                $channel= $dialstr; 
    111145                                                $exten = $calling; 
    112146                                                $context = $A2B -> config["callback"]['context_callback']; 
    113                                                 $id_server_group = $A2B -> config["callback"]['id_server_group']; 
    114147                                                $priority=1; 
    115148                                                $timeout = $A2B -> config["callback"]['timeout']*1000; 
    116149                                                $application=''; 
    117150                                                $callerid = $A2B -> config["callback"]['callerid']; 
    118                                                 $account = $_SESSION["pr_login"]; 
    119                                                  
    120                                                 $uniqueid       =  MDP_NUMERIC(5).'-'.MDP_STRING(7); 
    121                                                 $status = 'PENDING'; 
    122                                                 $server_ip = 'localhost'; 
    123                                                 $num_attempt = 0; 
    124                                                 $variable = "CALLED=$called|CALLING=$calling|CBID=$uniqueid|LEG=".$A2B->cardnumber; 
    125                                                  
    126                                                 $QUERY = " INSERT INTO cc_callback_spool (uniqueid, status, server_ip, num_attempt, channel, exten, context, priority, variable, id_server_group, callback_time, account, callerid, timeout ) VALUES ('$uniqueid', '$status', '$server_ip', '$num_attempt', '$channel', '$exten', '$context', '$priority', '$variable', '$id_server_group',  now(), '$account', '$callerid', '30000')"; 
    127                                                 $res = $A2B -> DBHandle -> Execute($QUERY); 
    128                                                  
    129                                                 if (!$res){ 
    130                                                         $error_msg= gettext("Cannot insert the callback request in the spool!"); 
    131                                                 }else{ 
    132                                                         $error_msg = gettext("Your callback request has been queued correctly!"); 
    133                                                         $color_msg = 'green'; 
     151                                                $account=$_SESSION["pr_login"]; 
     152 
     153                                                $variable = "CALLED=$called|CALLING=$calling"; 
     154                                                $res = $as->Originate($channel, $exten, $context, $priority, $application, $data, $timeout, $callerid, $variable, $account, $async, $actionid);                                                  
     155                                                if($res["Response"]=='Error'){ 
     156                                                        if (is_numeric($failover_trunk) && $failover_trunk>=0){ 
     157                                                                $QUERY = "SELECT trunkprefix, providertech, providerip, removeprefix FROM cc_trunk WHERE id_trunk='$failover_trunk'"; 
     158                                                                $A2B->instance_table = new Table(); 
     159                                                                $result = $A2B->instance_table -> SQLExec ($A2B -> DBHandle, $QUERY); 
     160                                                                if (is_array($result) && count($result)>0){ 
     161                                                                                 
     162                                                                                //DO SELECT WITH THE FAILOVER_TRUNKID                                                                                    
     163                                                                                $prefix                 = $result[0][0]; 
     164                                                                                $tech                   = $result[0][1]; 
     165                                                                                $ipaddress              = $result[0][2]; 
     166                                                                                $removeprefix   = $result[0][3]; 
     167                                                                                 
     168                                                                                $pos_dialingnumber = strpos($ipaddress, '%dialingnumber%' ); 
     169                                                                                $ipaddress = str_replace("%cardnumber%", $A2B->cardnumber, $ipaddress); 
     170                                                                                $ipaddress = str_replace("%dialingnumber%", $prefix.$destination, $ipaddress); 
     171                                                                                if (strncmp($destination, $removeprefix, strlen($removeprefix)) == 0) $destination= substr($destination, strlen($removeprefix)); 
     172                                                                                $dialparams = str_replace("%timeout%", $timeout *1000, $A2B->agiconfig['dialcommand_param']); 
     173                                                                 
     174                                                                                $A2B->agiconfig['switchdialcommand']=1; 
     175                                                                                $dialparams=''; 
     176                                                                                 
     177                                                                                if ($pos_dialingnumber !== false){                                          
     178                                                                                           $dialstr = "$tech/$ipaddress".$dialparams; 
     179                                                                                }else{ 
     180                                                                                        if ($A2B->agiconfig['switchdialcommand'] == 1){ 
     181                                                                                                $dialstr = "$tech/$prefix$destination@$ipaddress".$dialparams; 
     182                                                                                        }else{ 
     183                                                                                                $dialstr = "$tech/$ipaddress/$prefix$destination".$dialparams; 
     184                                                                                        } 
     185                                                                                }                                                                                        
     186                                                                                $channel= $dialstr;                                                                                      
     187                                                                                $res = $as->Originate($channel, $exten, $context, $priority, $application, $data, $timeout, $callerid, $variable, $account, $async, $actionid); 
     188                                                                } 
     189                                                        } 
    134190                                                } 
    135191                                                 
    136                                                 /* 
    137                                                 $as = new AGI_AsteriskManager(); 
    138                                                  
    139                                                 // && CONNECTING  connect($server=NULL, $username=NULL, $secret=NULL) 
    140                                                  
    141                                                 $res = $as->connect(MANAGER_HOST,MANAGER_USERNAME,MANAGER_SECRET); 
    142                                                  
    143                                                 if      ($res){ 
    144                                                         $channel= $dialstr; 
    145                                                         $exten = $calling; 
    146                                                         $context = $A2B -> config["callback"]['context_callback']; 
    147                                                         $priority=1; 
    148                                                         $timeout = $A2B -> config["callback"]['timeout']*1000; 
    149                                                         $application=''; 
    150                                                         $callerid = $A2B -> config["callback"]['callerid']; 
    151                                                         $account=$_SESSION["pr_login"]; 
    152  
    153                                                         $variable = "CALLED=$called|CALLING=$calling"; 
    154                                                         $res = $as->Originate($channel, $exten, $context, $priority, $application, $data, $timeout, $callerid, $variable, $account, $async, $actionid);                                                  
    155                                                         if($res["Response"]=='Error'){ 
    156                                                                 if (is_numeric($failover_trunk) && $failover_trunk>=0){ 
    157                                                                         $QUERY = "SELECT trunkprefix, providertech, providerip, removeprefix FROM cc_trunk WHERE id_trunk='$failover_trunk'"; 
    158                                                                         $A2B->instance_table = new Table(); 
    159                                                                         $result = $A2B->instance_table -> SQLExec ($A2B -> DBHandle, $QUERY); 
    160                                                                         if (is_array($result) && count($result)>0){ 
    161                                                                                          
    162                                                                                         //DO SELECT WITH THE FAILOVER_TRUNKID                                                                                    
    163                                                                                         $prefix                 = $result[0][0]; 
    164                                                                                         $tech                   = $result[0][1]; 
    165                                                                                         $ipaddress              = $result[0][2]; 
    166                                                                                         $removeprefix   = $result[0][3]; 
    167                                                                                          
    168                                                                                         $pos_dialingnumber = strpos($ipaddress, '%dialingnumber%' ); 
    169                                                                                         $ipaddress = str_replace("%cardnumber%", $A2B->cardnumber, $ipaddress); 
    170                                                                                         $ipaddress = str_replace("%dialingnumber%", $prefix.$destination, $ipaddress); 
    171                                                                                         if (strncmp($destination, $removeprefix, strlen($removeprefix)) == 0) $destination= substr($destination, strlen($removeprefix)); 
    172                                                                                         $dialparams = str_replace("%timeout%", $timeout *1000, $A2B->agiconfig['dialcommand_param']); 
    173                                                                          
    174                                                                                         $A2B->agiconfig['switchdialcommand']=1; 
    175                                                                                         $dialparams=''; 
    176                                                                                          
    177                                                                                         if ($pos_dialingnumber !== false){                                          
    178                                                                                                    $dialstr = "$tech/$ipaddress".$dialparams; 
    179                                                                                         }else{ 
    180                                                                                                 if ($A2B->agiconfig['switchdialcommand'] == 1){ 
    181                                                                                                         $dialstr = "$tech/$prefix$destination@$ipaddress".$dialparams; 
    182                                                                                                 }else{ 
    183                                                                                                         $dialstr = "$tech/$ipaddress/$prefix$destination".$dialparams; 
    184                                                                                                 } 
    185                                                                                         }                                                                                        
    186                                                                                         $channel= $dialstr;                                                                                      
    187                                                                                         $res = $as->Originate($channel, $exten, $context, $priority, $application, $data, $timeout, $callerid, $variable, $account, $async, $actionid); 
    188                                                                         } 
    189                                                                 } 
    190                                                         } 
    191                                                          
    192                                                         // && DISCONNECTING      
    193                                                         $as->disconnect(); 
    194                                                 }else{ 
    195                                                         $error_msg= gettext("Cannot connect to the asterisk manager!<br>Please check the manager configuration..."); 
    196                                                 } 
    197                                                 */ 
    198                                                  
     192                                                // && DISCONNECTING      
     193                                                $as->disconnect(); 
    199194                                        }else{ 
    200                                                 $error_msg = gettext("Error : You don t have enough credit to call you back!"); 
    201                                         } 
     195                                                $error_msg= gettext("Cannot connect to the asterisk manager!<br>Please check the manager configuration..."); 
     196                                        } 
     197                                        */ 
     198                                         
    202199                                }else{ 
    203                                         $error_msg = gettext("Error : There is no route to call back your phonenumber!"); 
     200                                        $error_msg = gettext("Error : You don t have enough credit to call you back!"); 
    204201                                } 
    205                                  
    206202                        }else{ 
    207                                 // ERROR MESSAGE IS CONFIGURE BY THE callingcard_ivr_authenticate_light 
     203                                $error_msg = gettext("Error : There is no route to call back your phonenumber!"); 
    208204                        } 
     205                         
    209206                }else{ 
    210                         $error_msg = gettext("Error : You have to specify your phonenumber and the number you wish to call!"); 
    211                  
     207                        // ERROR MESSAGE IS CONFIGURE BY THE callingcard_ivr_authenticate_light 
    212208                } 
     209        }else{ 
     210                $error_msg = gettext("Error : You have to specify your phonenumber and the number you wish to call!"); 
     211         
     212        } 
    213213} 
    214214$customer = $_SESSION["pr_login"]; 


Google