Changeset 10320
- Timestamp:
- 09/27/10 04:34:12 (3 years ago)
- Files:
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
contributed_modules/modules/endpointman/includes/functions.inc
r10315 r10320 23 23 global $amp_conf, $db, $global_cfg; 24 24 25 //TODO: Need to have this change when the user changes timezones, for now we keep it set to my timezone 25 26 date_default_timezone_set('America/Los_Angeles'); 26 27 28 //The only time dbh_asterisk is set is when we are inside the ARI Recording interface 27 29 if(isset($_SESSION['dbh_asterisk'])) { 28 30 $this->db = $_SESSION['dbh_asterisk']; 31 //We don't want to reference the recordings directory when in the recording interface. 29 32 $_SERVER["SCRIPT_FILENAME"] = str_replace("recordings/", "admin/", $_SERVER["SCRIPT_FILENAME"]); 30 33 } else { 31 34 $this->db = $db; 32 35 } 36 37 //Move all information from the global $amp_conf into our public space. This will help prevent security concerns 33 38 $this->amp_conf = $amp_conf; 39 40 //Generate empty array 34 41 $this->error = array(); 35 42 43 //Get all global variables 36 44 $this->global_cfg =& $this->db->getAssoc("SELECT var_name, value FROM endpointman_global_vars"); 37 45 46 //TODO: Possibly remove these as I don't believe anything uses them anymore 38 47 define("UPDATE_PATH", $this->global_cfg['update_server']); 39 48 define("VER", $this->global_cfg['version']); 49 //end possible removal 50 40 51 //Define the location of phone modules, keeping it outside of the module directory so that when the user updates endpointmanager they don't lose all of their phones 41 52 define("PHONE_MODULES_PATH", dirname($_SERVER["SCRIPT_FILENAME"])."/modules/_ep_phone_modules/"); … … 53 64 } 54 65 55 //Check writable66 //Check if config location is writable and/or exists! 56 67 if(isset($this->global_cfg['config_location'])) { 57 68 if(is_dir($this->global_cfg['config_location'])) { … … 71 82 } 72 83 84 /** 85 * Used to send sample configurations to provisioner.net 86 * NOTE: The user has to explicitly click a link that states they are sending the configuration to the project 87 * We don't take configs on our own accord!! 88 * @param <type> $brand Brand Directory 89 * @param <type> $product Product Directory 90 * @param <type> $orig_name The file's original name we are sending 91 * @param <type> $data The config file's data 92 */ 73 93 function submit_config($brand,$product,$orig_name,$data) { 74 94 $posturl = 'http://www.provisioner.net/submit_config.php'; 75 $postvars = 'brand= &product=&origname='.htmlentities(addslashes($orig_name)).'&config_data='.base64_encode($data);95 $postvars = 'brand='.$brand.'&product='.$product.'&origname='.htmlentities(addslashes($orig_name)).'&config_data='.base64_encode($data); 76 96 77 97 $ch = curl_init($posturl); … … 80 100 curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1); 81 101 curl_setopt($ch, CURLOPT_HEADER, 0); // DO NOT RETURN HTTP HEADERS 82 curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); // RETURN THE CONTENTS OF THE CALL 102 curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); // RETURN THE CONTENTS OF THE CALL, probably not needed 83 103 $Rec_Data = curl_exec($ch); 84 104 … … 144 164 145 165 /** 146 * Get the brand from any mac sent 166 * Get the brand from any mac sent to this function 147 167 * @param string $mac 148 168 * @return array … … 274 294 $phone_info['product_id'] = 0; 275 295 $phone_info['custom_cfg_template'] = 0; 276 $phone_info['ext'] = $row['ext'];277 296 $phone_info['mac'] = $row['mac']; 278 } 279 280 //Final Output needs to look like this: 281 //$this['mac_id'] 282 //$this['model_id'] 283 //$this['brand_id'] 284 //$this['template_id'] 285 //$this['product_id'] 286 //$this['mac'] 287 //$this['cfg_dir'] 288 //$this['cfg_ver'] 289 //$this['model_name'] 290 //$this['brand_name'] 291 //$this['long_name'] 292 //$this['config_files_override'] 293 //$this['global_custom_cfg_data'] 294 //$this['global_user_cfg_data'] 295 //$this['template_data'] 296 //$this['enabled'] 297 //$this['line'][1]['ext'] 298 //$this['line'][1]['description'] 299 //$this['line'][1]['secret'] 300 //$this['line'][1]['custom_cfg_data'] 301 //$this['line'][1]['user_cfg_data'] 302 // 297 $sql = "SELECT endpointman_line_list.*, sip.data as secret, devices.* FROM endpointman_line_list, sip, devices WHERE endpointman_line_list.ext = devices.id AND endpointman_line_list.ext = sip.id AND sip.keyword = 'secret' AND mac_id = ".$mac_id; 298 $lines_info =& $this->db->getAll($sql, array(), DB_FETCHMODE_ASSOC); 299 foreach($lines_info as $line) { 300 $phone_info['line'][$line['line']] = $line; 301 } 302 } 303 304 //Final Output will look something similar to this 305 /**Array 306 ( 307 [config_files_override] => 308 [global_user_cfg_data] => N; 309 [model_id] => 213 310 [brand_id] => 2 311 [name] => Grandstream 312 [directory] => grandstream 313 [model] => GXP2000 314 [mac] => 000B820D0050 315 [template_id] => 0 316 [global_custom_cfg_data] => Serialized Data (Changed Template Values) 317 [long_name] => GXP Enterprise IP series [280,1200,2000,2010,2020] 318 [product_id] => 21 319 [cfg_dir] => gxp 320 [cfg_ver] => 1.5 321 [template_data] => Serialized Data (The default Template Values) 322 [enabled] => 1 323 [line] => Array 324 ( 325 [1] => Array 326 ( 327 [luid] => 2 328 [mac_id] => 2 329 [line] => 1 330 [ext] => 1000 331 [description] => Description 332 [custom_cfg_data] => 333 [user_cfg_data] => 334 [secret] => secret 335 [id] => 1000 336 [tech] => sip 337 [dial] => SIP/1000 338 [devicetype] => fixed 339 [user] => 1000 340 [emergency_cid] => 341 ) 342 343 ) 344 345 ) 346 */ 347 348 echo "<pre>"; 349 print_r($phone_info); 303 350 return $phone_info; 304 351 } … … 671 718 /** 672 719 * Prepare and then send the data that Provisioner expects, then take what provisioner gives us and do what it says 673 * @param array $phone_info 720 * @param array $phone_info Everything from get_phone_info 674 721 */ 675 722 function prepare_configs($phone_info) { contributed_modules/modules/endpointman/module.xml
r10319 r10320 22 22 </changelog> 23 23 <info>http://projects.colsolgrp.net/projects/show/endpointman</info> 24 <location>contributed_modules/release/endpointman-2. 3.0.tgz</location>24 <location>contributed_modules/release/endpointman-2.2.9.tgz</location> 25 25 26 <md5sum> 7adabdcde60d5f27a3dcae7c660e7526</md5sum>26 <md5sum>c9dd08b16ad7e9eb41164ab3a8e0123f</md5sum> 27 27 </module>
