Changeset 10219

Show
Ignore:
Timestamp:
08/12/10 06:06:14 (3 years ago)
Author:
tm1000
Message:

Lots of updates to Endpoint Manager.
-Fixed CSV export to use freepbx quietmode.
-Other various small fixes

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • contributed_modules/modules/endpointman/config.php

    r10218 r10219  
    88 */ 
    99// Check for safe mode 
     10 
     11 
    1012 
    1113if( ini_get('safe_mode') ){ 
     
    2325include 'includes/functions.inc'; 
    2426 
    25 global $endpoint, $debug; 
    26  
    2727$debug = NULL; 
    2828 
    2929$endpoint = new endpointmanager(); 
    3030 
    31 global $global_cfg, $debug; 
     31if(!file_exists(PHONE_MODULES_PATH)) { 
     32  mkdir(PHONE_MODULES_PATH, 0764); 
     33
     34if(!file_exists(PHONE_MODULES_PATH."temp/")) { 
     35  mkdir(PHONE_MODULES_PATH."temp/", 0764); 
     36
    3237 
    3338if(!is_writeable(LOCAL_PATH)) { 
  • contributed_modules/modules/endpointman/includes/advanced.inc

    r10218 r10219  
    2828        $temp_amp = base64_encode(serialize($temp_amp)); 
    2929 
    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()); 
    3531        //Dave B's Q&D file upload security code (http://us2.php.net/manual/en/features.file-upload.php) 
    3632        if((isset($_REQUEST['action'])) AND (isset($_REQUEST['button_import'])) AND ($_REQUEST['action'] == "import")) { 
     
    106102        $tpl->assign("provisioner_ver", $provisioner_ver); 
    107103 
    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 = ""; 
    110107        $tpl->assign("master_ver", $provisioner_ver); 
    111108        $uploads_dir = PHONE_MODULES_PATH."temp"; 
  • contributed_modules/modules/endpointman/includes/brand_model_manager.inc

    r10218 r10219  
    1313//initialize a Rain TPL object 
    1414$tpl = new RainTPL( LOCAL_PATH.'templates' ); 
    15  
     15$endpoint->error['brand_update_check'] = ""; 
    1616if((isset($_REQUEST['button_install'])) OR (isset($_REQUEST['button_update']))) { 
    1717  if(isset($_REQUEST['brand'])) { 
     
    5353$i = 0; 
    5454$note = ""; 
     55$row_out = array(); 
    5556foreach($brand_list as $row) { 
    5657  $row_out[$i] = $row; 
     
    131132$tpl->assign("web_var", "?type=$type"); 
    132133$tpl->assign("brand2_list", $row_out); 
    133 //$tpl->assign("error", $endpoint->error['brand_update_check']); 
     134$tpl->assign("error", $endpoint->error['brand_update_check']); 
    134135 
    135136//draw the template  
  • contributed_modules/modules/endpointman/includes/export.php

    r10218 r10219  
    88 */ 
    99 
    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 
     10require 'functions.inc'; 
    1711 
    18 $temp_amp = unserialize(base64_decode($contents)); 
    19 $amp_conf = unserialize(base64_decode($temp_amp['amp_serial'])); 
     12$endpoint = new endpointmanager(); 
    2013 
    21 $link = mysql_connect('localhost', $amp_conf['AMPDBUSER'], $amp_conf['AMPDBPASS']); 
    22 mysql_select_db($amp_conf['AMPDBNAME'], $link); 
    2314 
    2415header("Content-type: text/csv"); 
     
    2920$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'; 
    3021 
    31 $result = mysql_query($sql); 
     22$result = $endpoint->db->getAll($sql,array(),DB_FETCHMODE_ASSOC); 
    3223 
    33 while($row = mysql_fetch_assoc($result)) { 
    34   fputcsv($outstream, $row); 
    35      
     24foreach($result as $row) { 
     25  fputcsv($outstream, $row);     
    3626} 
    3727fclose($outstream); 
  • contributed_modules/modules/endpointman/includes/functions.inc

    r10218 r10219  
    3737 
    3838 
    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"); 
    4040 
    4141        define("UPDATE_PATH", $this->global_cfg['update_server']); 
     
    671671        $result = $this->download_xml(UPDATE_PATH . "master.xml"); 
    672672 
    673         $message = NULL
     673        $message = ""
    674674 
    675675        if(!$result) { 
     
    13731373            $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"; 
    13741374        } 
    1375         $result=mysql_query($not_added); 
    1376  
    13771375        $result =& $this->db->getAll($not_added,array(), DB_FETCHMODE_ASSOC); 
    13781376 
  • contributed_modules/modules/endpointman/includes/installer.php

    r10218 r10219  
    88 */ 
    99require 'functions.inc'; 
    10  
    11 global $endpoint; 
    1210 
    1311$endpoint = new endpointmanager(); 
     
    6664                    $endpoint->brand_update_check(); 
    6765                    echo "Updating Brands<br />"; 
    68  
    6966                } 
    7067            } else { 
     
    107104                } 
    108105 
    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"); 
    110107 
    111108                echo "Extracting Tarball........"; 
     
    171168                } 
    172169 
    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                } 
    178212            } 
    179213            break; 
  • contributed_modules/modules/endpointman/install.php

    r10218 r10219  
    1 <?php 
     1<?PHP 
     2ini_set('display_errors', 1); 
     3error_reporting(E_ALL); 
    24/* 
    35Endpoint Manager V2 
    4 Copyright (C) 2009-2010  Ed Macri, John Mullinix and Andrew Nagy  
     6Copyright (C) 2009-2010  Ed Macri, John Mullinix and Andrew Nagy 
    57 
    68This program is free software; you can redistribute it and/or 
     
    3335} 
    3436 
     37function 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 
    3558global $db; 
    3659 
     
    3861out("Creating New phone modules directory"); 
    3962 
    40 mkdir(PHONE_MODULES_PATH, 0777); 
     63define("PHONE_MODULES_PATH", $amp_conf['AMPWEBROOT'].'/admin/modules/_ep_phone_modules/'); 
     64define("LOCAL_PATH", $amp_conf['AMPWEBROOT'].'/admin/modules/endpointman/'); 
     65 
     66 
     67if(!file_exists(PHONE_MODULES_PATH)) { 
     68  mkdir(PHONE_MODULES_PATH, 0764); 
     69
     70 
     71if(!file_exists(PHONE_MODULES_PATH."setup.php")) { 
     72  copy(LOCAL_PATH."Install/setup.php",PHONE_MODULES_PATH."setup.php"); 
     73
     74 
     75if(!file_exists(PHONE_MODULES_PATH."temp/")) { 
     76  mkdir(PHONE_MODULES_PATH."temp/", 0764); 
     77
    4178//Detect Version 
    4279 
    4380function ep_table_exists ($table) { 
     81  global $db; 
    4482    $sql = "SHOW TABLES FROM asterisk"; 
    45     $result = $this->db->getAll($sql); 
    46      
     83    $result = $db->getAll($sql); 
     84 
    4785    foreach($result as $row) { 
    4886        if ($row[0] == $table) { 
     
    6098    $global_cfg['version'] = '?'; 
    6199} 
    62  
     100$new_install = FALSE; 
    63101if(!isset($global_cfg['version'])) { 
    64102    $ver = "1.0.3"; 
     
    88126    $ver = "2.2.0"; 
    89127} else { 
    90     $ver = "?"; 
     128    $ver = "1000"; 
     129  $new_install = TRUE; 
    91130} 
    92131 
     
    95134out('Version Identified as '. $ver); 
    96135 
    97 if($ver < "1.9.0") { 
     136if(($ver < "1.9.0") AND ($ver > 0)) { 
    98137        out("Please Wait While we upgrade your old setup"); 
    99138        //Expand the value option 
     
    103142        out("Locating NMAP + ARP + ASTERISK Executables"); 
    104143 
    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"); 
    108147 
    109148        out("Updating Global Variables table"); 
     
    272311        out("Locating NMAP + ARP + ASTERISK Executables"); 
    273312 
    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"); 
    277316 
    278317        out("Updating Global Variables table"); 
     
    353392        out("Locating NMAP + ARP + ASTERISK Executables"); 
    354393 
    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"); 
    358397 
    359398        out('Updating Global Variables'); 
     
    459498 
    460499        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"); 
    464503 
    465504        $sql_update_vars = "INSERT INTO `endpointman_global_vars` (`idnum`, `var_name`, `value`) VALUES (11, 'nmap_location', '".$asterisk."')"; 
     
    589628            "71" => "7-2-5", 
    590629            "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" 
    605630        ); 
    606631 
    607632        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']; 
    610634            $db->query($sql); 
    611635        } 
    612636 
     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 
    613690        out("Update Version Number"); 
    614691        $sql = "UPDATE endpointman_global_vars SET value = '".$version."' WHERE var_name = 'version'"; 
     
    616693} 
    617694 
    618 if ($ver == "?") { 
     695if ($new_install) { 
    619696 
    620697        out("Creating Brand List Table"); 
     
    640717 
    641718        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"); 
    645722 
    646723        out("Inserting data into the global vars Table"); 
     
    657734            (10, 'arp_location', '".$arp."'), 
    658735            (11, 'nmap_location', '".$nmap."'), 
    659             (12, 'asterisk_location', '".$asterisk."') 
     736            (12, 'asterisk_location', '".$asterisk."'), 
    660737            (13, 'language', ''), 
    661738            (14, 'check_updates', '1'), 
     
    889966        } 
    890967} 
    891  
    892  
    893 ?> 
  • contributed_modules/modules/endpointman/installer.html.php

    r10198 r10219  
    11<?PHP 
    22include('includes/installer.php'); 
    3 ?> 
  • contributed_modules/modules/endpointman/module.xml

    r10052 r10219  
    22  <rawname>endpointman</rawname> 
    33  <name>PBX End Point Manager</name> 
    4   <version>2.0.0</version> 
     4  <version>2.2.0</version> 
    55  <type>tool</type> 
    66  <category>End Point Manager</category> 
  • contributed_modules/modules/endpointman/templates/advanced_settings_iedl.html

    r10052 r10219  
    22<p><?=_('Export CSV file of devices')?>: 
    33  <br> 
    4   <a href="http://{$exporter_address}"><?=_('Export CSV')?></a></p> 
     4  <a href="{$exporter_address}"><?=_('Export CSV')?></a></p> 
    55<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"> 
    66  <label> 
  • contributed_modules/modules/endpointman/templates/advanced_settings_manual_upload.html

    r10218 r10219  
    3232</form> 
    3333    <br /><br /> 
     34{if condition="1 == 0"} 
    3435<form action="" method="post" enctype="multipart/form-data" name="form1"> 
    3536    <label>Master List File (.xml): 
     
    4041</form> 
    4142    <br /><br /> 
     43{/if} 
    4244<form action="" method="post" enctype="multipart/form-data" name="form1"> 
    4345    <label>Brand XML File (.xml):