Quantcast
Channel: Development - FreePBX Community Forums
Viewing all 996 articles
Browse latest View live

Adding fwconsole commands and hooking them to framework functions

$
0
0

@danielf wrote:

Hello,

After reading @jfinstrom's article (http://wiki.freepbx.org/display/FOP/Adding+fwconsole+commands, I started to build a small additional fwconsole command.

The purpose:
1. fix my predefined iptables rules and fail2ban settings as the freepbx start/stop functions flushes them.
2. run this fwconsole command after the start/stop/restart functions (fwconsole start/stop/restart).

My first try was to write a hook to the start function (really simple and no fancy stuff).

The process itself:

  1. make a directory in your modules directory for your new command:
    mkdir /var/www/html/admin/modules/fixiptables

  2. make a Console sub directory in your fixiptables directory:
    mkdir /var/www/html/admin/modules/fixiptables/Console.

  3. prepapre your module.xml file in the module directory:
    <module>
    <rawname>fixiptables</rawname>
    <repo>standard</repo>
    <name>Fix Iptables Rules</name>
    <hooks>
    <framework class="Start" namespace="FreePBX\Console\Command">
    <method callingMethod="postAsteriskHooks" class="Fixiptables">postAsteriskHooks</method>
    </framework>
    </hooks>
    </module>

  4. make your class file in the Console directory (Fixiptables.class.php):
    <?php
    //Namespace should be FreePBX\Console\Command
    namespace FreePBX\Console\Command;
    //Symfony stuff all needed add these
    use Symfony\Component\Console\Command\Command;
    use Symfony\Component\Console\Input\InputArgument;
    use Symfony\Component\Console\Input\InputInterface;
    use Symfony\Component\Console\Input\InputOption;
    use Symfony\Component\Console\Output\OutputInterface;
    //progress bar
    use Symfony\Component\Console\Helper\ProgressBar;
    //Start class. Class name should be same as file name. Fixiptables.class.php
    class Fixiptables extends Command {
    //Declare component and your options.
    protected function configure(){
    $this->setName('fixiptables')
    ->setDescription('Fixes the iptables rules')
    ->setHelp('Fixes the iptables rules');
    }
    protected function execute(InputInterface $input, OutputInterface $output){
    system('service iptables restart > /dev/null 2>&1');
    system('service fail2ban restart > /dev/null 2>&1');
    $output->writeln('iptables and fail2ban have been fixed');
    }
    public function postAsteriskHooks($output) {
    system('service iptables restart > /dev/null 2>&1');
    system('service fail2ban restart > /dev/null 2>&1');
    $output->writeln('iptables and fail2ban have been fixed');
    }
    }
    ?>

  5. Install the module: fwconsole ma install fixiptables
  6. verify that I can see my command: fwconsole | grep fixiptables.
  7. run the command manually: fwconsole fixiptables.

Everything works great when I run the new fwconsole command: fwconsole fixiptables.

My problem is that for some reason (I must be missing something) I cannot hook it to the start function of the fwconsole.
I tried implementing the code sample itself directly, but with no luck either hooking it to the start/stop functions.

Can you help me to hook it to the start/stop/restart framework functions?

Thank you,

Daniel Friedman
Trixton LTD.

Posts: 11

Participants: 4

Read full topic


Cisco XML patch

Error when trying to add device programmatically

$
0
0

@lowiedaniels wrote:

Hi there,

I'm using the latest version of the FreePBX Distro with FreePBX 13.0 with Asterisk 13.12 on Ubuntu.
I was building a program to add devices automatically using bootstrap but when testing the core_devices_add() function with all parameters filled in I keep getting this exception :

[root@localhost ~]# php DevicesScript.php
locale: Cannot set LC_CTYPE to default locale: No such file or directory
Exception: Account must be set! in file /var/www/html/admin/modules/core/Core.class.php on line 1315
Stack trace:
  1. Exception->() /var/www/html/admin/modules/core/Core.class.php:1315
  2. FreePBX\modules\Core->convertRequest2Array() /var/www/html/admin/modules/core/functions.inc.php:4099
  3. core_devices_add() /root/DevicesScript.php:51

EDIT :

I found this example in the freepbx documentation so I tried to use it but it still gives the same exception

<?php
$bootstrap_settings = array();
$bootstrap_settings['freepbx_auth'] = false;
if (!@include_once(getenv('FREEPBX_CONF') ? getenv('FREEPBX_CONF') : '/etc/freepbx.conf')) {
      include_once('/etc/asterisk/freepbx.conf');
}

/*
USER VARS:
Array
(
    [extension] => 0224
    [password] =>
    [name] => Display Name
    [voicemail] => default
    [ringtimer] => 0
    [noanswer] =>
    [recording] =>
    [outboundcid] =>
    [sipname] =>
    [noanswer_cid] =>
    [busy_cid] =>
    [chanunavail_cid] =>
    [noanswer_dest] =>
    [busy_dest] =>
    [chanunavail_dest] =>
    [mohclass] => default
    [callwaiting] => enabled
    [cid_masquerade] => 0224
    [call_screen] => 0
    [pinless] => disabled
    [cfringtimer] => 0
    [concurrency_limit] => 0
    [dialopts] =>
    [recording_in_external] => dontcare
    [recording_out_external] => dontcare
    [recording_in_internal] => dontcare
    [recording_out_internal] => dontcare
    [recording_ondemand] => disabled
    [recording_priority] => 10
)
*/
$vars = array(
"extension" => 255,
"name" => "Bobby",
"password" => base64_encode(openssl_random_pseudo_bytes(30))
);
core_users_add($vars);
//core_devices_add($id,$tech,$dial,$devicetype,$user,$description,$emergency_cid=null,$editmode=false)

core_devices_add(255,'sip','','fixed',255,'Bobby');
?>

Even though I didn't code the file where the exception is thrown. I was hoping some of you might know how to solve this exception.

Kind regards,
Lowie Daniels

Posts: 11

Participants: 5

Read full topic

Changing/removing ring tones based on scripting

$
0
0

@Philloau wrote:

Hi all,

I will start by saying I am a FreePBX/Asterisk newbie, so please be gentle with me.

I am currently playing around with a "proof of concept" for my local community based radio station. I am looking at replacing our current PSTN phones with a FreePBX setup and would like to include some scripting into the install.

As of the extensions would be in radio studio environments, I would like the phones to not make an audible ringing tone only when the microphones in the studio are live.

The broadcast panel we use can output a closed circuit when the microphones are live. As I am using freepbx on a raspberry pi, I can easily interface this with the GPIO ports and return the port value in a python script.

What I am struggling with is how to configure the scripting on the asterisk side of things.

Additionally, I am hoping to do this at the extension level rather than at the ring group configuration as I would prefer the phone to ring in the studio that ISNT on air at any given time.

Any advice or script samples would be greatly appreciated.

thanks everyone.

Posts: 6

Participants: 3

Read full topic

[RESOLVED] FreePBX 14 Stable release

$
0
0

@zirophyz wrote:

Hello,

I checked out the roadmap but it didn't have any indicative date.

I'm wondering if I can get a rough, indicative date for when FreePBX 14 will go from RC1 to Stable? Just a month or even a quarter would suffice. We have an internal policy that only allows Stable versions of software to be deployed.

Thanks!

Posts: 3

Participants: 2

Read full topic

What Verision of PHPAGI is in FreePBX Distro

$
0
0

@jerryriggin wrote:

Does anyone know which version of the documentation on Sourceforge for phpagi applies to the version in the FreePBX 13 distro? Doing diff between phpagi 2.20 from SourceForge and the version from the FreePBX distro produces 2216 lines. I am having AGI issues, and want to RTFM, but I don't know which one.

Posts: 4

Participants: 2

Read full topic

FreePBX 14 RC stalls at item 570 on install

$
0
0

@gregorywest wrote:

I am trying to do an install of FPBX in a VMWare machine.and Asterisk 14 stalls when it gets to installing item 570 of 646 objects. Any suggestions?

Posts: 8

Participants: 3

Read full topic

Call notification to the desktop - how does it actually work?

$
0
0

@cmaney wrote:

First, let me say that I know there are lots of commercial and open-source products that do this, but so far, I've been unable to figure out how it actually works beyond the very basic side. This is entirely for my own education and experience.

I know I need to create an administrator with at least "Read" access to the "Call" section in Asterisk Manager. I also know that the client uses that username/password for AMI access by connecting via telnet to AMI on port 5038 (which has to be allowed). Obviously, I know that you need to specify in some way what extension(s) you're monitoring. From there, though, I'm drawing blanks.

How do you monitor the events? I'm guessing I need to somehow monitor the AgentCalled event, but I've yet to work out how to do that. Is that the correct event? Is there a way to filter it at the freepbx side, or does the client side actually receive all AgentCalled events and only display the ones for the extension(s) that are selected?

Am I right so far? Can anyone point me in the right direction?

I feel like I'm missing something obvious, but I've been unable to tie things together from the documentation so far. Any help is very much appreciated.

Posts: 6

Participants: 3

Read full topic


Rest API for allowing configuration changes from remote system

$
0
0

@matt_dbp wrote:

Hello,

Does anyone know of an existing Rest API that allows remote configuration of a FreePBX deployment. in particular, CRUD against extensions.

If nothing exists, I might look into creating something. That said I have very little experience with PHP and would prefer to write the Rest API in something like node or .net core.

Looking through the docs it appears Bootstrap (https://wiki.freepbx.org/display/FOP/Bootstrap) would be the best place to hook into FreePBX and using something like Dnode (https://github.com/bergie/dnode-php) to allow piping the commands across to Node.

Thoughts / feedback would be greatly appreciated.

Posts: 3

Participants: 2

Read full topic

Show username instead of extension - SIP Show Peer

Develop Modules without using the MVC model

$
0
0

@mitterhuemer wrote:

Hello,
i try to develop a module for FreePBX but the Coding with the MVC Modell is really hard to understand for me.

I already investigated a lot of time and do not come forward with it.

I created some public functions to the Helloword module and tried to add some simple forms in the views but i cannot get it working in all views.
Its frustrating for one who never had done anything like this with a controller and a view model.

Is it also possible to develop a FreePBX module with simple PHP,HTML,CSS,JS mix without using the FreePBX Framework behind?
I try to develop and extend freepbx but the knowledge stopped after a single database form when i use the MVC. Its a headburner....:cry:

Posts: 9

Participants: 3

Read full topic

AGI script and queue

$
0
0

@ibenomar wrote:

Hi
I am trying to run and AGI script when a call get to a queue and when an agent take the call ,and send to php script the queue name and the agent extension number ,Any help would be incredibly appreciated.
exten => _X.,n,Queue(toqueue.php)

Posts: 2

Participants: 2

Read full topic

[Feature Request] Show pending changes to PBX when about to apply them

$
0
0

@psylock524 wrote:

I've always thought it was a bit weird that FreePBX only shows you that changes are going to be made, not what they are.

I think it would be useful to have a button next to the "Apply" button (or something with better UX design) that allows us to see the changes that are about to be made before we submit them. This is especially useful when working on a PBX that other admins have access to (I work for an MSP), and would prevent me from accidentally applying detrimental changes.

I know that it's possible to copy and diff the /etc/asterisk folder or something akin to that, but it seems really useful to have the ability to revert individual changes that may have been made in error, or mass cancel an update if the customer says, "actually I don't want it to do that".

Posts: 1

Participants: 1

Read full topic

To get caller information using .NET

$
0
0

@Bindu wrote:

I am new to FreePBX, I was able to login into FreePBX server using c#. Can anyone please provide me the information to get the caller details like caller phone number, call Id using c#. I checked with the below code snippet but I get a null value when there is an ongoing call. I have used Aster.NET library.
Please required the suggestion for the above implementation.

NewExtenEvent extnEvents = new NewExtenEvent(manager);
NewChannelEvent channelEvents = new NewChannelEvent(manager);
string callerNumber=channelEvents.CallerIdNum;
NewCallerIdEvent callEvents = new NewCallerIdEvent(manager);

Posts: 1

Participants: 1

Read full topic

Channel Variables Offset When Running AGI Script

$
0
0

@jerryriggin wrote:

I'm having an odd problem with AGI variable in FreePBX 13 with Asterisk 13.

It seems like the same effect as if the channel variables are in an array and the index is somehow offset by 1. I've come across this before some time ago but can't remember what fixed it.

Here's AGI code:

    #!/usr/bin/php
    <?php
    require_once('fafs_include.php');
    require_once('lime_include.php');
    date_default_timezone_set('America/New_York');

    $myagi = new AGI();
    $myagi->set_music(true,"default");

    $APIUser = get_var('APIUser');
    $msg="APIUser: $APIUser";
    $myagi->verbose($msg);
    $APIPass = get_var('APIPass');
    $msg="APIPass: " . $APIPass;
    $myagi->verbose($msg);
    $SiteURL = get_var("SiteURL");
    $myagi->verbose("SiteURL: " . $SiteURL);
    $TransferPhone = get_var("TransferPhone");
    $myagi->verbose("TransferPhone: " .  $TransferPhone);
    $ProdDiscountPct = get_var("ProdDiscountPct");
    $myagi->verbose("ProdDiscountPct: " .  $ProdDiscountPct);

Here's the CLI ouput:

<SIP/png_in-0000002e>AGI Rx << GET VARIABLE APIUser
<SIP/png_in-0000002e>AGI Tx >> 200 result=1 (Test_IVR)
<SIP/png_in-0000002e>AGI Rx << VERBOSE "APIUser: " 1
 find-orders.php: APIUser:
<SIP/png_in-0000002e>AGI Tx >> 200 result=1
<SIP/png_in-0000002e>AGI Rx << GET VARIABLE APIPass
<SIP/png_in-0000002e>AGI Tx >> 200 result=1 (test_pwd!123)
<SIP/png_in-0000002e>AGI Rx << VERBOSE "APIPass: Test_IVR" 1
 find-orders.php: APIPass: Test_IVR
<SIP/png_in-0000002e>AGI Tx >> 200 result=1
<SIP/png_in-0000002e>AGI Rx << GET VARIABLE SiteURL
<SIP/png_in-0000002e>AGI Tx >> 200 result=1 (https://devapi.ourcrm.com/admin/)
<SIP/png_in-0000002e>AGI Rx << VERBOSE "SiteURL: test_pwd!123" 1
 find-orders.php: SiteURL: test_pwd!123
<SIP/png_in-0000002e>AGI Tx >> 200 result=1
<SIP/png_in-0000002e>AGI Rx << GET VARIABLE TransferPhone
<SIP/png_in-0000002e>AGI Tx >> 200 result=1 (17277248006)
<SIP/png_in-0000002e>AGI Rx << VERBOSE "TransferPhone: https://devapi.ourcrm.com/admin/" 1
 find-orders.php: TransferPhone: https://devapi.ourcrm.com/admin/

As you can see the call to get_var() produces expected output, but the variable assignment is offset by 1. The first call returns nothing, 2nd returns first, 3rd returns second, etc. Like somehow an array assumed to start at 0 actually starts with 1. I have googled this till my fingers have calluses and dug through the PHPAGI code until my eyes are blurry and still stuck.

Any help SINCERELY appreciated.

Note: the 2 include files contain functions that are not called before this code, with the exception of get_var() which is copied from distro recordings.agi function agi_get_var().

Posts: 1

Participants: 1

Read full topic


FreePBX Development of new Endpoint Manager

$
0
0

@mitterhuemer wrote:

Hello,

i started learning Developing FreePBX Modules with MVC Model a few weeks ago.

My Project is a new simple Endpoint Manager which should support Third Party Phones from Manufacturers that are not supported by sangoma.

The first brands i want to add are Gigaset and some Panasonic phones.

The first release should only have basic Features

  • Adding new Extensions
  • Rebuilding Configs
  • Update Phones by SIP Notify
  • Very Simple Basefile Editor
  • __ PLACEHOLDERS __ for the most important sip Settings
  • Default Support for TLS/SRTP if the phones support this. The Port Calculation is already done.
  • Multi Account Support with IPEI for DECT Systems.

My developement already can build config files for the Manufacturers and the CFG Files with mac adress.

Future Plans (if i did not already give up :smiley: )
* Function Keys with templates without Basefile edit
* Brand Settings page to set specific values without modify the Basefile manual
* Firmware Management
* Simple Background image Management

What does the community think about that idea?

I already have provisioned my first Aastra Phone with my own Endpoint Manager, but this was just a test.
They will not be added to my EPM because they work already perfectly with the Commercial EPM

I want to start making a new epm. The OSS EPM is totally overloaded, i think it has already too much features and broken things. This EPM should work together with the commercial EPM and not getting in conflict with. That only means that you can have both verisons of installed, but they dont do anything together.

As i said this is a first idea of EPM. Maybe it will never be released. Maybe i get it working well enough to think about a release :smiley:

Regards,

Posts: 13

Participants: 3

Read full topic

Some suggests on modules architecture

$
0
0

@pinkra wrote:

Hi all,
I'm developing some new modules of freepbx.. i think that the architecture should be more MVC compliant as modern software suggests.
For example all that php for the view part should be avoided, why not we use a template language instead? The php should be used only for the model and controller part. This will bring to a more mantainable software and it also will be simpler to write for us.
Another suggest should be to use a common library (classes) to perform all that typical operations (like queries, writing, ...) a module usually performs.

What do you think about?

Posts: 6

Participants: 3

Read full topic

Database, Asterisk Files, Create Extensions, another Page instead of FreePBX page

$
0
0

@saha wrote:

Hi guys
I set some telephony settings with FreePBX, Like: Inbound, outbound, IVR ... settings.
I created my own page (instead of FreePBX page), and it work. (I wrote my page with PHP)
I want to create some new extensions (different from those i have created with FreePBX) with my new page, so I did this by using sip_custom.conf file. These new extensions are registered, but for their "contexts", i have no enough time to write new contexts in extensions_custom.conf file.
I tried to copy extensions_additional.conf file to extensions_custom.conf file and change some cases to modify it to my own needs, but I faced with many errors.
Now i make some scenario for myself to do this, But i don't know which of them is the best:

  1. Instead of using sip_custom.conf file (for create new Extensions), I use the FreePBX database and enter new Extensions directly in FreePBX database.

  2. Under any circumstances, i use the contents of extensions_additional.conf file and change them to be useful for using in extensions_custom.conf file. (but i did this and faced with many errors, so how do this correctly?)

  3. Is there a simple way to write Dialplan, contexts, in extensions_custom.conf file? ( I write some simple context, but not professionally)

Now please tell me:

  • Are my scenarios OK? If they are OK, which one is better? and how i do that?

  • If the scenarios are not OK, show me a good way please.

Thankyou

Posts: 13

Participants: 4

Read full topic

E911 Notification - Dashboard widget / Email / SMS text / Paging

$
0
0

@fibrewire wrote:

Hello! I want to share a quick story with you first. Emergency services responded to a 911 call made at our resort, but they were unable to pinpoint the room from which the emergency call was made. While I was able to very quickly figure out what room the person called from, it exposed a real issue with the liability of using FreePBX in a commercial environment. Specifically, how 911 calls are made and what happens after the call is made.

What I am proposing is a few helpful additions to FreePBX to ensure it's commercial success in the marketplace, and really give it a popular feature set that will keep customers (and attorneys) happy.

First, on the FreePBX dashboard, can we get a "Who called 911?" widget that shows from what extension and the time the call was placed, and perhaps a link to the recorded call (if call recording is enabled.) Maybe there could be a blinking light next to the widget or maybe the whole widget can blink until the 911 notification is acknowledged on the dashboard? Perhaps the user acknowledging the E911 call from the FreePBX Dashboard will also be logged? Most of this info can be generated from the CDR Report when the Destination is specified for 911.

Secondly, can some sort of alert be generated via SMS to the manager on duty or owner/operator of the business, or to on property first responders or even the on-duty lifeguard or something? It would be nice to not have a patron lay dying in a room until emergency services show up which could be 15-30 minutes later.

And lastly, if there is a building operator or front desk, can that ring group get a call regarding the 911 call placed and from what room and time of call?

As a bonus, it would be nice if the dashboard widget had a link to a zipped log file that would show that on-property staff made every effort possible to help the 911 caller receive help, and when the case shows up in court that the log file could be submitted as evidence.

If we can do something like this, it would be a huge win for FreePBX in the commercial realm and for Open Source technology in general.

Thank You all for reading, and I am anxiously waiting to hear a response! The faster this gets outlined into a project, the faster we can provide a bounty on this project.

Posts: 8

Participants: 3

Read full topic

Oauth 2 support

$
0
0

@GPz1100 wrote:

My freepbx distro has recently updated to asterisk 14.7.

My understanding is oauth 2 support was added in the last few months and is now included in asterisk 14.7 and above. It appears an update is needed to chan_motif module to actually make use of this.

I've attempted some of the patches posted in this thread on dslreports starting with this post - https://www.dslreports.com/forum/r31686042- but have run into stability issues.

Has anyone been able to make oauth 2 work on the freepbx distro successfully? How?

Posts: 1

Participants: 1

Read full topic

Viewing all 996 articles
Browse latest View live


Latest Images

<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>