root/contributed_modules/modules/agentadministration/page.agentadministration.php

Revision 5072, 7.1 kB (checked in by p_lindheimer, 5 years ago)

#2149 add agentadministration to contribued module repository

Line 
1 </div>
2
3 <br>
4
5 <!-- The agent dropdown part -->
6 <div class="rnav"><ul>
7
8 <?
9
10   //Basic variable initialization and setup
11
12   $LargestAgentID=agentadministration_getlargestagentid(); //Get the largest Agent ID
13   $data=explode(",",agentadministration_getagentinfo($_GET["ai"],$LargestAgentID)); //Get all agent information and store in this array
14
15   $title=$data[0];
16   $NextAgentID=$data[1];
17   $agentname=$data[2];
18   $agentID=$data[3];
19   $agentpassword=$data[4];
20
21 ?>
22 <?
23                
24   $agentinfo=agentadministration_getdropdownlist(); //Get the huge string that will contain the dropdown list information
25                                                              
26      copy("/etc/asterisk/agents.conf","/etc/asterisk/agents.conf.bak"); //Make backup of original agents.conf file
27                                        
28      echo "<td valign=top>";
29                                        
30      echo "<b>Current List:</b><br>";
31                                        
32     $dropdownname=explode(",",$agentinfo); //Breakdown string into array
33                                                                
34     sort($dropdownname,SORT_STRING); //Sorts the array
35    
36   echo "<li><a href='config.php?display=agentadministration&nai=".$NextAgentID."'>Add Agent</a></li>";
37
38   for ($ct=0;$ct<=count($dropdownname)-1;$ct++) {
39      
40         $passwordstartpos=strrpos($dropdownname[$ct],"::"); //Chop off password
41  
42     echo "<li><a href='config.php?display=agentadministration&ai=displayname&ai=".$dropdownname[$ct]."&nai=".$NextAgentID."'>".substr($dropdownname[$ct],0,$passwordstartpos-1)."</a></li>";
43    
44   }
45  
46 ?>
47 </ul></div>
48
49 <div class="content">
50
51 <table align=left valign=top border=0>
52   <tr><td align=left colspan=3>
53     <table border=0>
54     
55     <?
56      
57       //Gets full file path as well as query strings
58       $urladdress=$_SERVER['PHP_SELF']."?".$_SERVER['QUERY_STRING']
59    
60     ?>
61                                                                                   
62     <form name=frmAgentInformation method="post" action="<? echo $urladdress; ?>">
63                                                                                                                   
64     <tr>
65       <td colspan=3><font size=4><b><? echo $title; ?></b></font>
66             </td>
67         </tr>
68                                                                                                 
69     <tr><td colspan=3 height=20></td></tr>             
70                                                                                                         
71         <tr>
72       <td colspan=3> <!-- Hidden values -->
73                 <input type=hidden name=h_agentname value='<? echo $agentname; ?>'>
74         <input type=hidden name=h_agentid value='<? echo $NextAgentID; ?>'>
75                 <input type=hidden name=h_agentpassword value='<? echo $agentpassword; ?>'>
76       </td>
77         </tr>
78                                                                                                                                                         
79         <tr>
80       <td>Agent Name:</td>
81             <td width=10></td>
82              <td><input type=textbox name=tb_agentname value='<? echo $agentname; ?>'></td>
83         </tr>
84                                                                                                                 
85         <tr>
86              <td>Agent ID:</td>
87              <td width=10></td>
88              <td><input type=textbox name=tb_agentid value='<? echo $NextAgentID; ?>' onkeypress="return fnOnlyNumbers(event);"></td>
89         </tr>
90                                                                                                 
91          <tr>
92             <td>Agent Password:</td>
93             <td width=10></td>
94             <td><input type=textbox name=tb_password value='<? echo $agentpassword; ?>' onkeypress="return fnOnlyNumbers(event);"></td>
95         </tr>
96                                                                                                 
97         <tr><td colspan=3 height=20></td></tr>
98                                                                                                 
99         <tr><td colspan=3><input type=submit name=b_submit value='Submit Changes' onClick="return fnInputChecks();"></td></tr>
100                                                                                                                       
101 </table></td></tr></table>
102
103 <!-- Used to push down footer -->
104 <br><br><br><br><br><br><br><br><br><br><br><br>
105
106 <?
107          
108     if (isset($_POST['b_submit'])){ //The information to submit
109        
110         $originalentry="agent => ".$_POST['h_agentid'].",".$_POST['h_agentpassword'].",".trim($_POST['h_agentname']); //The original entry based on hiddem values
111
112         $newentry="agent => ".$_POST['tb_agentid'].",".$_POST['tb_password'].",".trim($_POST['tb_agentname']);
113        
114         agentadministration_searchreplacewithinfile("agents.conf",$originalentry,$newentry); //Adds new entries as well as serach and replaces within the "agents.conf" file.
115    
116     needreload(); //Show the "Appply Configuration Changes" button
117     redirect_standard(); //Redirect to same page
118                                
119     }
120                        
121 ?>
122
123 <script language="javascript">
124
125 function fnInputChecks() {
126
127      var agentname=document.frmAgentInformation.tb_agentname.value; //For agent name
128      var agentid=document.frmAgentInformation.tb_agentid.value; //For agent id
129      var agentpassword=document.frmAgentInformation.tb_password.value; //For agent password
130         
131      //Makes sure an agent name is entered
132      if (agentname=="") {
133         
134     alert ("Please enter an Agent name.");
135         document.frmAgentInformation.tb_agentname.focus();
136         
137         return false;
138         
139     }
140         
141     //Makes sure an agent id is entered
142     if (agentid=="") {
143         
144         alert ("Please enter an Agent ID.");
145         document.frmAgentInformation.tb_agentid.focus();
146                 
147         return false;
148                 
149     }
150
151     //Makes sure a password is entered
152     if (agentpassword=="") {
153         
154         alert ("Please enter an Agent password.");
155         document.frmAgentInformation.tb_password.focus();
156                 
157         return false;
158                 
159     }       
160                 
161     //Makes sure agent id and password are not the same
162     if (agentid==agentpassword) {
163         
164         alert ("Agent ID and password cannot be the same.");
165                 
166         document.frmAgentInformation.tb_password.value="";
167         document.frmAgentInformation.tb_password.focus();
168
169         return false;
170                         
171     }
172         
173         //Makes sure password is 4 characters or more
174     if (agentpassword.length<=3) {
175         
176         alert ("Agent password must be at least 4 characters or longer.");
177                 
178         document.frmAgentInformation.tb_password.focus();
179
180         return false;
181                 
182     }
183
184     return true;
185         
186 }
187
188 function fnOnlyNumbers(evt) {
189
190     //Allow only Numbers/Digits in TextBox
191
192     var charCode = (evt.which) ? evt.which : event.keyCode
193     
194     if (charCode > 31 && (charCode < 48 || charCode > 57)) {
195         
196         alert ("Please enter only numbers.");   
197         return false;
198
199     }
200         
201     return true;
202
203 }
204
205 </script>
206                                 
Note: See TracBrowser for help on using the browser.