OSS PBX End Point Manager 14.0.2.1 Broken

This post is for the Free (NOT THE COMMERCIAL) OSS PBX End Point Manager
Debian and Rasbian users unable to run the commercial modules!

Has anyone been able to get the free 14.0.2.1 working with Freepbx version 15

when I install it I get a

Whoops \ Exception \ ErrorException (E_WARNING)

Illegal string offset 'disable_epm'


/var
/www
/html
/admin
/modules
/endpointman
/lib
/Config.class.php

        return $this->module_conf;
    }
    public function isExiste($var)     { 
        return isset($this->module_conf[$var]); 
    }
    public function get($var, $defvar="") {
        $varreturn = "";
        if ($this->isExiste($var)) { 
            $varreturn = $this->module_conf[$var]; 
        }
        elseif ($defvar != "") {
            $this->module_conf[$var] = $defvar;
        }
        if ($varreturn == "") {
            $varreturn = $defvar;
        }
        return $varreturn;
    }

What php version are you running? The module needs work for php 7.x compatibility.

You may be able to get things running by changing the Advanced Settings->System Setup->PHP Error Level in advanced settings. Not sure I really recommend that. There still seemed to be issues.

Urgh, I some how got into my mind that version 15 was all about a big redesign.

You know like working with php7 and eliminated the redhat distro restrictionsā€¦ the more I look at it its not changed much.

So What is the preferred version of php I should have installed?
can someone clarify if this module works in a older version php?

I am running Debian 10
I used as a reference the https://wiki.freepbx.org/display/FDT/How+to+Install+FreePBX+15+on+Debian+10+with+Asterisk+16%2C+PHP+7.3 You get the feeling PHP 7.3 works. In general everything is working for me but this module

# dpkg -l |grep php
ii  libapache2-mod-php               2:7.3+69                      all          server-side, HTML-embedded scripting language (Apache 2 module) (default)
ii  libapache2-mod-php7.3            7.3.14-1~deb10u1              amd64        server-side, HTML-embedded scripting language (Apache 2 module)
ii  php                              2:7.3+69                      all          server-side, HTML-embedded scripting language (default)
ii  php-bcmath                       2:7.3+69                      all          Bcmath module for PHP [default]
ii  php-cgi                          2:7.3+69                      all          server-side, HTML-embedded scripting language (CGI binary) (default)
ii  php-common                       2:69                          all          Common files for PHP packages
ii  php-curl                         2:7.3+69                      all          CURL module for PHP [default]
ii  php-fpm                          2:7.3+69                      all          server-side, HTML-embedded scripting language (FPM-CGI binary) (default)
ii  php-gd                           2:7.3+69                      all          GD module for PHP [default]
ii  php-gettext                      1.0.12-0.1                    all          transitional dummy package for php-php-gettext
ii  php-imap                         2:7.3+69                      all          IMAP module for PHP [default]
ii  php-json                         2:7.3+69                      all          JSON module for PHP [default]
ii  php-mbstring                     2:7.3+69                      all          MBSTRING module for PHP [default]
ii  php-mysql                        2:7.3+69                      all          MySQL module for PHP [default]
ii  php-pear                         1:1.10.6+submodules+notgz-1.1 all          PEAR Base System
ii  php-php-gettext                  1.0.12-0.1                    all          read gettext MO files directly, without requiring anything other than PHP
ii  php-snmp                         2:7.3+69                      all          SNMP module for PHP [default]
ii  php-xml                          2:7.3+69                      all          DOM, SimpleXML, WDDX, XML, and XSL module for PHP [default]
ii  php-zip                          2:7.3+69                      all          Zip module for PHP [default]
ii  php7.3                           7.3.14-1~deb10u1              all          server-side, HTML-embedded scripting language (metapackage)
ii  php7.3-bcmath                    7.3.14-1~deb10u1              amd64        Bcmath module for PHP
ii  php7.3-cgi                       7.3.14-1~deb10u1              amd64        server-side, HTML-embedded scripting language (CGI binary)
ii  php7.3-cli                       7.3.14-1~deb10u1              amd64        command-line interpreter for the PHP scripting language
ii  php7.3-common                    7.3.14-1~deb10u1              amd64        documentation, examples and common module for PHP
ii  php7.3-curl                      7.3.14-1~deb10u1              amd64        CURL module for PHP
ii  php7.3-fpm                       7.3.14-1~deb10u1              amd64        server-side, HTML-embedded scripting language (FPM-CGI binary)
ii  php7.3-gd                        7.3.14-1~deb10u1              amd64        GD module for PHP
ii  php7.3-imap                      7.3.14-1~deb10u1              amd64        IMAP module for PHP
ii  php7.3-json                      7.3.14-1~deb10u1              amd64        JSON module for PHP
ii  php7.3-mbstring                  7.3.14-1~deb10u1              amd64        MBSTRING module for PHP
ii  php7.3-mysql                     7.3.14-1~deb10u1              amd64        MySQL module for PHP
ii  php7.3-opcache                   7.3.14-1~deb10u1              amd64        Zend OpCache module for PHP
ii  php7.3-readline                  7.3.14-1~deb10u1              amd64        readline module for PHP
ii  php7.3-snmp                      7.3.14-1~deb10u1              amd64        SNMP module for PHP
ii  php7.3-xml                       7.3.14-1~deb10u1              amd64        DOM, SimpleXML, WDDX, XML, and XSL module for PHP
ii  php7.3-zip                       7.3.14-1~deb10u1              amd64        Zip module for PHP

To be clear no one has this free endpoint module working using version 15 freepbx?

What does it need to work!?

I ran an install with php 5.6 and the module still had issues. Hopefully someone will address, but considering both Sangoma and the ClearlyIP have their own versions, I donā€™t know if OSS will get any more love from @tm1000 or anyone else even semi-official.

Sticking with my own scripts for now.

I am open to do a bounty but would not know a good site to do it on. i imagine like me there has to be some interest to keep this alive? If you got it to actually install you got farther then me it barfs before it finishes installingā€¦

if this is the case let me know

then it would be a php7.3 issue just to get it to go again. possibly ?

I submitted a number of backward-compatible patches related to supporting PHP 7.3. To be honest most of the fixes are trivial; itā€™s just a matter of going through and finding them.

OSS EPM is not something I use, so I didnā€™t look into it. i think I found all the changes needed for modules in the standard repo. I believe OSS EPM is in the extended or unsupported repo; I didnā€™t go through all of those.

If you know a little PHP or even if you donā€™t but can understand the PHP.net manuals you can probably tackle it.

There should be an copy of the original code on the FreePBX repo on GitHub. Clone it to a local machine and make the changes, then load it back up and notify whoever is maintaining the code these days.

I think itā€™s more than just php7+ issues. Like I said, it still had issues with my Buster/php5.6 install.

I think there might just be some missing dependency issues. I keep a very minimalistic install, It seems much more functional under @wardmundyā€™s IncrediblePBX build ( a non distro build using php5.6 on CentOS7). Iā€™ll try to compare and see if Iā€™m missing something.

EDIT: I had failed to apply changes after setting the error level. The debian and centos builds seem equivalent with php5.6.

I got the module loading under php7.3. There had already been some 7.x work done and posted on github, but some additional updates were needed for 7.3.

By ā€œloadingā€ I mean the module installs and pages seem to display correctly. Randomly clicking around, most things seem to work on the surface. I HAVE NOT done any full feature testing, such as actually deploying to phones.

I will be SHOCKED if these changes result in a fully functional module, but it should be enough to start going down the rabbit hole. If so inclined, load the updated module, test and report back. I donā€™t have time to devote to testing, but will go through a few rounds of trying to get it functional. No promises - it could ultimately be a waste of time.

To install by command line:

fwconsole ma remove endpointman
cd /var/www/html/admin/modules
git clone https://github.com/jerrm/endpointman.git
cd -
fwconsole ma install endpointman
fwconsole reload
fwconsole chown

If you prefer using the GUI, download https://github.com/jerrm/endpointman/archive/release/14.0.zip to your local PC, then in FreePBX go to Admin->Module Admin->Upload Modules->Upload(From Hard Disk) and select the file downloaded from githubā€¦

Awesome. It seems to displayā€¦ configuresā€¦

so i went to set it all up . when I went to the package manager it pukedā€¦ (when I hit update)!

Whoops \ Exception \ ErrorException (E_WARNING)

mkdir(): Permission denied

OOOOps spoke too soon I did a fwconsole chown and that fixed that ā€¦ I will continue to test
Maybe I have a permission some place not properā€¦

So after the update

I selected to install the Linksys packages then I got

SQLSTATE[HY000]: General error: 1364 Field 'firmware_vers' doesn't have a default value

PDOException

/var/www/html/admin/libraries/BMO/Database.class.php 215

At this point I guess we need someone familiar with the database?

Thereā€™s a commit on another fork that looks applicable. I want to review and see if it looks like the most appropriate fix. Will try to get something to try today or tomorrow.

I enabled issues reporting on the github repo, but honestly posting here may be better if it doesnā€™t get too verbose.

Hopefully the visibility will encourage others to do some testing.

This wasnā€™t a php7 issue at all, but a change in the default mariadb behavior. Distro is at 5.5.vs Debian Buster at 10.3.22.

I added default values to the columns that were throwing errors. I get a lot further, but there may need to be a few rounds of whack-a-mole with full testing.

Please re-install the module again and see how far you get:.

fwconsole ma remove endpointman
git clone https://github.com/jerrm/endpointman.git /var/www/html/admin/modules/endpointman
fwconsole ma install endpointman
fwconsole reload
fwconsole chown
1 Like

Just committed an additional php7.3 fix the db fix allowed to surfaceā€¦

@roger8 if you did anything with the prior commit and donā€™t want to lose your work, it should be safe to clone into a different folder and copy the Endpointman_Config.class.php file into /var/www/html/admin/modules/endpointman

Alternatively, downloading the github zip file to PC and then uploading via the GUI is effectively the same as an in-place module upgrade and should not lose changes.

EDIT 5/19/2020:
I stole a little time to actually step though this last night. If anyone has tested this, they know it is still very broken.

Does anyone have a FreePBX 14 version of the distro running? Was it running php 5.6 or an older version?

One thing this has uncovered is some consistent use of the ā€œcountā€ function that was already broken in php5.6 but throws errors now. Basically a bunch of ā€œifā€ statements in the code that were always true.

Need to evaluate whether to restore the same broken behavior or restore the intended logic which would probably open up even more issues.

Not sure if my situation applies. Iā€™m running IncrediblePBX ā€œ2020ā€ public server. And It looks like Iā€™m running asterik 14 cli, but the distro ā€œIncrediblepbxā€ says 13. I am running PHP 5.6 and all that being said, I followed the command line from this thread to installing the latest endpointman and downloading and refreshing the provisioner and enabled a few phone models and tried to add a phone and just @jerrm said. I got an error about MariaDBā€¦

"SQLSTATE[42000]: Syntax error or access violation: 1064 You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near '' at line 1 ā—€"

Iā€™m not sure If I should paste my whole environment details page here. Not that itā€™s got anything sensitive, but not sure if itā€™s kosher with etiquette here.

Wardā€™s build should be as compatible as the distro is with 14.0.2.1. I would start there first. No real benefit, and likely some headache using this version - it is pre-pre-pre alpha stage.

My only goal at this point is to get parity with 14.0.2.1 running under the distro for folks using php7.3. There will be no benefit using this under a php5.6 environment.

Ultimately I would like to have some testers to do some meaningful side by side testing, but need to get the basics functioning first (if I can).

Ok so now I can load all the devices I need in the package manager I have some linksys and snom devicesā€¦ all no issues getting and enabling ā€¦

I have no work to lose I have this as a VM and have a backup (If anyone needs access!) I can spin you up a copy give you access for testing debugging ā€¦ if anyone wants to helpā€¦

I now head over to the extension mapping part and do a scan with arp/nmap
i change the 10.0.0.155/24 to 10.0.0.0/24 (so it scans everything on that range. )

so now i click Search for new devices in netmask
looks like the wheels are spinning ā€¦
then i getā€¦

Whoops \ Exception \ ErrorException (E_WARNING)
count(): Parameter must be an array or an object that implements Countable

/var
/www
/html
/admin
/modules
/endpointman
/includes
/functions.inc

            $ip = $ip[0];
 
            //Pull out the mac address by looking for the delimiter
            $mac = substr($value, (strpos($value, ":") - 2), 17);
 
            //Get rid of the delimiter
            $mac_strip = strtoupper(str_replace(":", "", $mac));
 
            //arp -n will return a MAC address of 000000000000 if no hardware was found, so we need to ignore it
            if ($mac_strip != "000000000000") {
                //only use the first 6 characters for the oui: http://en.wikipedia.org/wiki/Organizationally_Unique_Identifier
                $oui = substr($mac_strip, 0, 6);
 
                //Find the matching brand model to the oui
                $oui_sql = "SELECT endpointman_brand_list.name, endpointman_brand_list.id FROM endpointman_oui_list, endpointman_brand_list WHERE oui LIKE '%" . $oui . "%' AND endpointman_brand_list.id = endpointman_oui_list.brand AND endpointman_brand_list.installed = 1 LIMIT 1";
 
                $brand = $this->eda->sql($oui_sql, 'getRow', DB_FETCHMODE_ASSOC);
 
                $res = $this->eda->sql($oui_sql);
                $brand_count = count($res);
 
                if (!$brand_count) {
                    //oui doesn't have a matching mysql reference, probably a PC/router/wap/printer of some sort.
                    $brand['name'] = FALSE;
                    $brand['id'] = NULL;
                }
 
                //Find out if endpoint has already been configured for this mac address
                $count_sql = "SELECT count(*) FROM endpointman_mac_list WHERE mac LIKE  '%" . $mac_strip . "%'";
                $epm =  $this->eda->sql($count_sql, 'getOne');
 
                //Add into a final array
                $final[$z] = array("ip" => $ip, "mac" => $mac, "mac_strip" => $mac_strip, "oui" => $oui, "brand" => $brand['name'], "brand_id" => $brand['id'], "endpoint_managed" => $epm);
                $z++;
            }
        }
        return !is_array($final) ? FALSE : $final;
    }
 
    function areaAvailable($model, $area=NULL) {

Arguments

    "count(): Parameter must be an array or an object that implements Countable"

I am and I imagine some along with me are trying to move away from 5.6 and move to the latest PHP 7.3 i will say your situation does not apply here. Freepbx has been held back by (In my opinion) older PHP

I never heard of IncrediblePBX so I looked into it. looks like they have images for debian 7. even the rasbian images are based on wheezy I think (Correct me if I am wrong) i have alot of Debian 7 setups wish I could keep them going but the support seems to be dwindling. This is all about the freepbx version 15 and keeping the oss endpoint manager functional and free for basic use. For people who do not use the freepbx distro or centos/redhat setups (needed to run the paied version)

IncrediblePBX including rasbian and all others will benefit from work done here!

Yeah, there are a lot of count($res) instances spread throughout the code, and all of them were also broken in 5.6, they just didnā€™t throw an error. The intended use appears to be that it returns the number of rows returned from the preceding sql query. In realty it always evaluates as ā€œ1ā€.

The initial ā€œfixā€ at this point will be to emulate the broken behavior, but comment to review later. Iā€™m afraid trying to correct the code will cause more issues than it will fix. Hopefully I can get it to be functionally equivalent to running under the distro, and then decide what if any bugs get addressed.

I just need to be able to spend more than 15 minutes at a time on it.

1 Like