Changeset 10219 for contributed_modules
- Timestamp:
- 08/12/10 06:06:14 (3 years ago)
- Files:
-
- contributed_modules/modules/endpointman/config.php (modified) (2 diffs)
- contributed_modules/modules/endpointman/includes/advanced.inc (modified) (2 diffs)
- contributed_modules/modules/endpointman/includes/brand_model_manager.inc (modified) (3 diffs)
- contributed_modules/modules/endpointman/includes/export.php (modified) (2 diffs)
- contributed_modules/modules/endpointman/includes/functions.inc (modified) (3 diffs)
- contributed_modules/modules/endpointman/includes/installer.php (modified) (4 diffs)
- contributed_modules/modules/endpointman/install.php (modified) (15 diffs)
- contributed_modules/modules/endpointman/installer.html.php (modified) (1 diff)
- contributed_modules/modules/endpointman/module.xml (modified) (1 diff)
- contributed_modules/modules/endpointman/templates/advanced_settings_iedl.html (modified) (1 diff)
- contributed_modules/modules/endpointman/templates/advanced_settings_manual_upload.html (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
contributed_modules/modules/endpointman/config.php
r10218 r10219 8 8 */ 9 9 // Check for safe mode 10 11 10 12 11 13 if( ini_get('safe_mode') ){ … … 23 25 include 'includes/functions.inc'; 24 26 25 global $endpoint, $debug;26 27 27 $debug = NULL; 28 28 29 29 $endpoint = new endpointmanager(); 30 30 31 global $global_cfg, $debug; 31 if(!file_exists(PHONE_MODULES_PATH)) { 32 mkdir(PHONE_MODULES_PATH, 0764); 33 } 34 if(!file_exists(PHONE_MODULES_PATH."temp/")) { 35 mkdir(PHONE_MODULES_PATH."temp/", 0764); 36 } 32 37 33 38 if(!is_writeable(LOCAL_PATH)) { contributed_modules/modules/endpointman/includes/advanced.inc
r10218 r10219 28 28 $temp_amp = base64_encode(serialize($temp_amp)); 29 29 30 $outfile=LOCAL_PATH."/includes/amp.ini"; 31 $wfh=fopen($outfile,'w'); 32 fwrite($wfh, $temp_amp); 33 fclose($wfh); 34 $tpl->assign("exporter_address", $_SERVER["HTTP_HOST"].WEB_PATH."includes/export.php"); 30 $tpl->assign("exporter_address", "config.php?type=tool&display=epm_config&quietmode=1&handler=file&file=export.html.php&module=endpointman&rand=".rand()); 35 31 //Dave B's Q&D file upload security code (http://us2.php.net/manual/en/features.file-upload.php) 36 32 if((isset($_REQUEST['action'])) AND (isset($_REQUEST['button_import'])) AND ($_REQUEST['action'] == "import")) { … … 106 102 $tpl->assign("provisioner_ver", $provisioner_ver); 107 103 108 $provisioner_ver = filemtime(PHONE_MODULES_PATH."master.xml"); 109 $provisioner_ver = date("n-j-y",$provisioner_ver) . " at " . date("g:ia",$provisioner_ver); 104 //$provisioner_ver = filemtime(PHONE_MODULES_PATH."master.xml"); 105 //$provisioner_ver = date("n-j-y",$provisioner_ver) . " at " . date("g:ia",$provisioner_ver); 106 $provisioner_ver = ""; 110 107 $tpl->assign("master_ver", $provisioner_ver); 111 108 $uploads_dir = PHONE_MODULES_PATH."temp"; contributed_modules/modules/endpointman/includes/brand_model_manager.inc
r10218 r10219 13 13 //initialize a Rain TPL object 14 14 $tpl = new RainTPL( LOCAL_PATH.'templates' ); 15 15 $endpoint->error['brand_update_check'] = ""; 16 16 if((isset($_REQUEST['button_install'])) OR (isset($_REQUEST['button_update']))) { 17 17 if(isset($_REQUEST['brand'])) { … … 53 53 $i = 0; 54 54 $note = ""; 55 $row_out = array(); 55 56 foreach($brand_list as $row) { 56 57 $row_out[$i] = $row; … … 131 132 $tpl->assign("web_var", "?type=$type"); 132 133 $tpl->assign("brand2_list", $row_out); 133 //$tpl->assign("error", $endpoint->error['brand_update_check']);134 $tpl->assign("error", $endpoint->error['brand_update_check']); 134 135 135 136 //draw the template contributed_modules/modules/endpointman/includes/export.php
r10218 r10219 8 8 */ 9 9 10 if(file_exists("amp.ini")) { 11 $outfile="amp.ini"; 12 $wfh=fopen($outfile,'r'); 13 $contents = fread($wfh, filesize($outfile)); 14 fclose($wfh); 15 unlink("amp.ini"); 16 } 10 require 'functions.inc'; 17 11 18 $temp_amp = unserialize(base64_decode($contents)); 19 $amp_conf = unserialize(base64_decode($temp_amp['amp_serial'])); 12 $endpoint = new endpointmanager(); 20 13 21 $link = mysql_connect('localhost', $amp_conf['AMPDBUSER'], $amp_conf['AMPDBPASS']);22 mysql_select_db($amp_conf['AMPDBNAME'], $link);23 14 24 15 header("Content-type: text/csv"); … … 29 20 $sql = 'SELECT endpointman_mac_list.mac, endpointman_brand_list.name, endpointman_model_list.model, endpointman_mac_list.ext FROM endpointman_mac_list, endpointman_model_list, endpointman_brand_list WHERE endpointman_model_list.id = endpointman_mac_list.model AND endpointman_model_list.brand = endpointman_brand_list.id'; 30 21 31 $result = mysql_query($sql);22 $result = $endpoint->db->getAll($sql,array(),DB_FETCHMODE_ASSOC); 32 23 33 while($row = mysql_fetch_assoc($result)) { 34 fputcsv($outstream, $row); 35 24 foreach($result as $row) { 25 fputcsv($outstream, $row); 36 26 } 37 27 fclose($outstream); contributed_modules/modules/endpointman/includes/functions.inc
r10218 r10219 37 37 38 38 39 $this->global_cfg =& $ db->getAssoc("SELECT var_name, value FROM endpointman_global_vars");39 $this->global_cfg =& $this->db->getAssoc("SELECT var_name, value FROM endpointman_global_vars"); 40 40 41 41 define("UPDATE_PATH", $this->global_cfg['update_server']); … … 671 671 $result = $this->download_xml(UPDATE_PATH . "master.xml"); 672 672 673 $message = NULL;673 $message = ""; 674 674 675 675 if(!$result) { … … 1373 1373 $not_added="SELECT devices.id, devices.description FROM devices WHERE tech='sip' AND devices.id not in (SELECT devices.id FROM devices, endpointman_mac_list WHERE tech='sip' AND devices.id = endpointman_mac_list.ext AND endpointman_mac_list.ext !=".$ext." ) ORDER BY devices.id"; 1374 1374 } 1375 $result=mysql_query($not_added);1376 1377 1375 $result =& $this->db->getAll($not_added,array(), DB_FETCHMODE_ASSOC); 1378 1376 contributed_modules/modules/endpointman/includes/installer.php
r10218 r10219 8 8 */ 9 9 require 'functions.inc'; 10 11 global $endpoint;12 10 13 11 $endpoint = new endpointmanager(); … … 66 64 $endpoint->brand_update_check(); 67 65 echo "Updating Brands<br />"; 68 69 66 } 70 67 } else { … … 107 104 } 108 105 109 rename(PHONE_MODULES_PATH."temp/".$_REQUEST['xml'], PHONE_MODULES_PATH."endpoint/".$brand_directory." brand_data.xml");106 rename(PHONE_MODULES_PATH."temp/".$_REQUEST['xml'], PHONE_MODULES_PATH."endpoint/".$brand_directory."/brand_data.xml"); 110 107 111 108 echo "Extracting Tarball........"; … … 171 168 } 172 169 173 $brand_version = max($last_mod, $brand_version); 174 echo "Updating data.........."; 175 $sql = "UPDATE endpointman_brand_list SET name = '".$brand_name."', cfg_ver = '".$brand_version."', installed = 1, hidden = 0 WHERE id = ".$brand_id; 176 $endpoint->db->query($sql); 177 echo "Done!<br/>"; 170 $row =& $endpoint->db->getAll('SELECT * FROM endpointman_brand_list WHERE id > 0', array(), DB_FETCHMODE_ASSOC); 171 172 173 if(file_exists(PHONE_MODULES_PATH."endpoint/".$brand_directory."/brand_data.xml")) { 174 $temp = $endpoint->xml2array(PHONE_MODULES_PATH."endpoint/".$brand_directory."/brand_data.xml"); 175 176 $temp = $temp['data']['brands']; 177 178 $temp['oui_list']['oui'] = $endpoint->fix_single_array_keys($temp['oui_list']['oui']); 179 180 foreach($temp['oui_list']['oui'] as $oui) { 181 $sql = "INSERT INTO endpointman_oui_list (`oui`, `brand`, `custom`) VALUES ('".$oui."', '".$temp['brand_id']."', '0')"; 182 $endpoint->db->query($sql); 183 184 } 185 186 $brand_name = $data['directory']; 187 $version[$brand_name] = $temp['last_modified']; 188 189 $last_mod = ""; 190 191 $temp['family_list']['family'] = $endpoint->fix_single_array_keys($temp['family_list']['family']); 192 193 foreach($temp['family_list']['family'] as $list) { 194 $last_mod = max($last_mod, $list['last_modified']); 195 } 196 $last_mod = max($last_mod, $version[$brand_name]); 197 198 $version[$brand_name] = $last_mod; 199 200 if(!($endpoint->arraysearchrecursive($brand_name, $row, 'directory'))) { 201 //insert row 202 $sql = "INSERT INTO endpointman_brand_list (id, name, directory, cfg_ver, installed) VALUES ('".$temp['brand_id']."', '".$temp['name']."', '".$temp['directory']."', '".$version[$brand_name]."', 1)"; 203 $endpoint->db->query($sql); 204 } else { 205 $brand_version = max($last_mod, $brand_version); 206 echo "Updating data.........."; 207 $sql = "UPDATE endpointman_brand_list SET name = '".$temp['name']."', cfg_ver = '".$version[$brand_name]."', installed = 1, hidden = 0 WHERE id = ".$temp['brand_id']; 208 $endpoint->db->query($sql); 209 echo "Done!<br/>"; 210 } 211 } 178 212 } 179 213 break; contributed_modules/modules/endpointman/install.php
r10218 r10219 1 <?php 1 <?PHP 2 ini_set('display_errors', 1); 3 error_reporting(E_ALL); 2 4 /* 3 5 Endpoint Manager V2 4 Copyright (C) 2009-2010 Ed Macri, John Mullinix and Andrew Nagy 6 Copyright (C) 2009-2010 Ed Macri, John Mullinix and Andrew Nagy 5 7 6 8 This program is free software; you can redistribute it and/or … … 33 35 } 34 36 37 function find_exec($exec) { 38 $usr_bin = glob("/usr/bin/".$exec); 39 $usr_sbin = glob("/usr/sbin/".$exec); 40 $sbin = glob("/sbin/".$exec); 41 $bin = glob("/bin/".$exec); 42 $etc = glob("/etc/".$exec); 43 if(isset($usr_bin[0])) { 44 return("/usr/bin/".$exec); 45 } elseif(isset($usr_sbin[0])) { 46 return("/usr/sbin/".$exec); 47 } elseif(isset($sbin[0])) { 48 return("/sbin/".$exec); 49 } elseif(isset($bin[0])) { 50 return("/bin/".$exec); 51 } elseif(isset($etc[0])) { 52 return("/etc/".$exec); 53 } else { 54 return($exec); 55 } 56 } 57 35 58 global $db; 36 59 … … 38 61 out("Creating New phone modules directory"); 39 62 40 mkdir(PHONE_MODULES_PATH, 0777); 63 define("PHONE_MODULES_PATH", $amp_conf['AMPWEBROOT'].'/admin/modules/_ep_phone_modules/'); 64 define("LOCAL_PATH", $amp_conf['AMPWEBROOT'].'/admin/modules/endpointman/'); 65 66 67 if(!file_exists(PHONE_MODULES_PATH)) { 68 mkdir(PHONE_MODULES_PATH, 0764); 69 } 70 71 if(!file_exists(PHONE_MODULES_PATH."setup.php")) { 72 copy(LOCAL_PATH."Install/setup.php",PHONE_MODULES_PATH."setup.php"); 73 } 74 75 if(!file_exists(PHONE_MODULES_PATH."temp/")) { 76 mkdir(PHONE_MODULES_PATH."temp/", 0764); 77 } 41 78 //Detect Version 42 79 43 80 function ep_table_exists ($table) { 81 global $db; 44 82 $sql = "SHOW TABLES FROM asterisk"; 45 $result = $ this->db->getAll($sql);46 83 $result = $db->getAll($sql); 84 47 85 foreach($result as $row) { 48 86 if ($row[0] == $table) { … … 60 98 $global_cfg['version'] = '?'; 61 99 } 62 100 $new_install = FALSE; 63 101 if(!isset($global_cfg['version'])) { 64 102 $ver = "1.0.3"; … … 88 126 $ver = "2.2.0"; 89 127 } else { 90 $ver = "?"; 128 $ver = "1000"; 129 $new_install = TRUE; 91 130 } 92 131 … … 95 134 out('Version Identified as '. $ver); 96 135 97 if( $ver < "1.9.0") {136 if(($ver < "1.9.0") AND ($ver > 0)) { 98 137 out("Please Wait While we upgrade your old setup"); 99 138 //Expand the value option … … 103 142 out("Locating NMAP + ARP + ASTERISK Executables"); 104 143 105 $nmap = $endpoint->find_exec("nmap");106 $arp = $endpoint->find_exec("arp");107 $asterisk = $endpoint->find_exec("asterisk");144 $nmap = find_exec("nmap"); 145 $arp = find_exec("arp"); 146 $asterisk = find_exec("asterisk"); 108 147 109 148 out("Updating Global Variables table"); … … 272 311 out("Locating NMAP + ARP + ASTERISK Executables"); 273 312 274 $nmap = $endpoint->find_exec("nmap");275 $arp = $endpoint->find_exec("arp");276 $asterisk = $endpoint->find_exec("asterisk");313 $nmap = find_exec("nmap"); 314 $arp = find_exec("arp"); 315 $asterisk = find_exec("asterisk"); 277 316 278 317 out("Updating Global Variables table"); … … 353 392 out("Locating NMAP + ARP + ASTERISK Executables"); 354 393 355 $nmap = $endpoint->find_exec("nmap");356 $arp = $endpoint->find_exec("arp");357 $asterisk = $endpoint->find_exec("asterisk");394 $nmap = find_exec("nmap"); 395 $arp = find_exec("arp"); 396 $asterisk = find_exec("asterisk"); 358 397 359 398 out('Updating Global Variables'); … … 459 498 460 499 out("Locating NMAP + ARP + ASTERISK Executables"); 461 $nmap = $endpoint->find_exec("nmap");462 $arp = $endpoint->find_exec("arp");463 $asterisk = $endpoint->find_exec("asterisk");500 $nmap = find_exec("nmap"); 501 $arp = find_exec("arp"); 502 $asterisk = find_exec("asterisk"); 464 503 465 504 $sql_update_vars = "INSERT INTO `endpointman_global_vars` (`idnum`, `var_name`, `value`) VALUES (11, 'nmap_location', '".$asterisk."')"; … … 589 628 "71" => "7-2-5", 590 629 "72" => "7-2-6" 591 );592 593 $new_product_list = array(594 "6" => "1-1",595 "7" => "1-2",596 "1" => "2-1",597 "2" => "2-2",598 "3" => "",599 "5" => "",600 "4" => "4-3",601 "8" => "6-1",602 "9" => "7-1",603 "11" => "7-2",604 "10" => "8-1"605 630 ); 606 631 607 632 foreach($data as $list) { 608 609 $sql = "UPDATE endpointman_mac_list SET model = '".$new_model_list[$list['model']]."' WHERE id = ". $list['id']; 633 $sql = "UPDATE endpointman_mac_list SET model = '".$new_model_list[$list['id']]."' WHERE id = ". $list['id']; 610 634 $db->query($sql); 611 635 } 612 636 637 $data = array(); 638 639 $data =& $db->getAll("SELECT * FROM endpointman_template_list",array(), DB_FETCHMODE_ASSOC); 640 641 $new_product_list = array( 642 "6" => array("product_id" => "1-1", "model_id" => ""), 643 "7" => array("product_id" => "1-2", "model_id" => ""), 644 "1" => array("product_id" => "2-1", "model_id" => ""), 645 "2" => array("product_id" => "2-2", "model_id" => ""), 646 "3" => array("product_id" => "", "model_id" => ""), 647 "5" => array("product_id" => "", "model_id" => ""), 648 "4" => array("product_id" => "4-3", "model_id" => ""), 649 "8" => array("product_id" => "6-1", "model_id" => ""), 650 "9" => array("product_id" => "7-1", "model_id" => ""), 651 "11" => array("product_id" => "7-2", "model_id" => ""), 652 "10" => array("product_id" => "8-1", "model_id" => "") 653 ); 654 655 656 657 foreach($data as $list) { 658 659 $sql = "UPDATE endpointman_template_list SET model_id = '".$new_product_list[$list['id']]['model_id']."', product_id = '".$new_product_list[$list['id']]['product_id']."' WHERE id = ". $list['id']; 660 $db->query($sql); 661 } 662 663 664 665 666 $data = array(); 667 $data =& $db->getAll("SELECT * FROM endpointman_custom_configs",array(), DB_FETCHMODE_ASSOC); 668 $variable_change = array( 669 "{\$srvip}" => "{\$server.ip.1}", 670 "{\$ext}" => "{\$ext.line.1}", 671 "{\$pass}" => "{\$pass.line.1}", 672 "{\$secret}" => "{\$pass.line.1}", 673 "{\$displayname}" => "{\$displayname.line.1}" 674 ); 675 676 foreach($data as $list) { 677 foreach($variable_change as $key => $value) { 678 $list['data'] = str_replace($key, $value, $list['data']); 679 } 680 $sql = "UPDATE endpointman_custom_configs SET data = '".addslashes($list['data'])."' WHERE id = ". $list['id']; 681 $db->query($sql); 682 } 683 684 exec("rm -Rf ".PHONE_MODULES_PATH); 685 686 mkdir(PHONE_MODULES_PATH, 0777); 687 mkdir(PHONE_MODULES_PATH."temp/", 0777); 688 689 613 690 out("Update Version Number"); 614 691 $sql = "UPDATE endpointman_global_vars SET value = '".$version."' WHERE var_name = 'version'"; … … 616 693 } 617 694 618 if ($ ver == "?") {695 if ($new_install) { 619 696 620 697 out("Creating Brand List Table"); … … 640 717 641 718 out("Locating NMAP + ARP + ASTERISK Executables"); 642 $nmap = $endpoint->find_exec("nmap");643 $arp = $endpoint->find_exec("arp");644 $asterisk = $endpoint->find_exec("asterisk");719 $nmap = find_exec("nmap"); 720 $arp = find_exec("arp"); 721 $asterisk = find_exec("asterisk"); 645 722 646 723 out("Inserting data into the global vars Table"); … … 657 734 (10, 'arp_location', '".$arp."'), 658 735 (11, 'nmap_location', '".$nmap."'), 659 (12, 'asterisk_location', '".$asterisk."') 736 (12, 'asterisk_location', '".$asterisk."'), 660 737 (13, 'language', ''), 661 738 (14, 'check_updates', '1'), … … 889 966 } 890 967 } 891 892 893 ?>contributed_modules/modules/endpointman/installer.html.php
r10198 r10219 1 1 <?PHP 2 2 include('includes/installer.php'); 3 ?>contributed_modules/modules/endpointman/module.xml
r10052 r10219 2 2 <rawname>endpointman</rawname> 3 3 <name>PBX End Point Manager</name> 4 <version>2. 0.0</version>4 <version>2.2.0</version> 5 5 <type>tool</type> 6 6 <category>End Point Manager</category> contributed_modules/modules/endpointman/templates/advanced_settings_iedl.html
r10052 r10219 2 2 <p><?=_('Export CSV file of devices')?>: 3 3 <br> 4 <a href=" http://{$exporter_address}"><?=_('Export CSV')?></a></p>4 <a href="{$exporter_address}"><?=_('Export CSV')?></a></p> 5 5 <p><?=_('Import CSV file of devices')?>:<form name="form1" enctype="multipart/form-data" method="post" action="config.php{$web_vars}&display=epm_advanced&subpage=iedl&action=import"> 6 6 <label> contributed_modules/modules/endpointman/templates/advanced_settings_manual_upload.html
r10218 r10219 32 32 </form> 33 33 <br /><br /> 34 {if condition="1 == 0"} 34 35 <form action="" method="post" enctype="multipart/form-data" name="form1"> 35 36 <label>Master List File (.xml): … … 40 41 </form> 41 42 <br /><br /> 43 {/if} 42 44 <form action="" method="post" enctype="multipart/form-data" name="form1"> 43 45 <label>Brand XML File (.xml):
