Code Monkey home page Code Monkey logo

elastix-api's Introduction

Elastix API

Elastix and Asterisk API Provider to make FreePBX easy to manage, written in PHP4.

Installation

Open your Elastix (CentOS) terminal, and go to elastix directory, then download it:

cd /var/www/html
git clone https://github.com/101t/elastix-api.git

Open api.php and generate token key then replace it in:

$this->key = 'YOUR_SECRETKEY_50_RANDOM_CHARS';

Now you have elastix api ready to use it.

Useful API functions

This api package can implement:

  • Get Authentication
  • Get SIP Peers
  • Get SIP Extensions
  • Check System Resources
  • Get CDR Report
  • Get *.wav files
  • Get Hard Driver State
  • Check IPTable Status
  • Get Active Call (Live Calls)
  • SIP Trunk / Extension Management (Create, Update, Delete, Read)
  • Follow Me Extension Management (Create, Update, Delete, Read)

Documentation

Installation and developer guide here.

Contribute

Thank you for amazing community of FreePBX for useful information.

elastix-api's People

Contributors

101t avatar cmfrtl avatar evanxg852000 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

elastix-api's Issues

?

Is there a way to modify to work on Issabel, even if for a fee?

Generate Token Key

I am sory Iam new in elastix... I want know where is or which one menu in elastix to generate token key ? Thanks

New functions: get voicemail messages

    public function get_voicemail_report() {
            $number         = $_POST["number"];
            # FIXME Get voicemail path from configuration file
            $dir = "/var/spool/asterisk/voicemail/default";
            $numbers = array_diff(scandir($dir,1), array('..', '.'));
            if (isset($number) and in_array($number, $numbers)) {
                    $numbers = array($number);
            }
            foreach ( $numbers as $key => $value ) {
                    if (is_dir($dir . DIRECTORY_SEPARATOR . $value)) {
                            $dir_input = $dir . DIRECTORY_SEPARATOR . $value . DIRECTORY_SEPARATOR . "INBOX";
                            $files = array_diff(scandir($dir_input,1), array('..', '.'));
                            $filelist = array();
                            foreach ( $files as $key2 => $value2 ) {
                                    #$result[$value] = array();
                                    if (is_file($dir_input . DIRECTORY_SEPARATOR . $value2)) {
                                            $filename = $dir_input . DIRECTORY_SEPARATOR . $value2;
                                            $fileparts = pathinfo($filename);
                                            if ($fileparts['extension'] == 'wav') {
                                                    $metadata = array();
                                                    $metadata_file = $dir_input . DIRECTORY_SEPARATOR . $fileparts['filename'] . ".txt";
                                                    if (is_file($metadata_file)) {
                                                            $metadata = parse_ini_file($metadata_file, true, INI_SCANNER_RAW);
                                                    }
                                                    array_push($filelist, array('file' => $value2, 'ctime' => date("Y-m-d H:i:s", filectime($filename)), 'metadata' => $metadata));
                                            }
                                    }
                            }
                            $result[$value] = $filelist;
                    }
            }
            header('Content-Type: application/json');
            echo json_encode($result);
    }

    public function get_voicemail_file() {
            $number         = $_POST["number"];
            $filename       = $_POST["filename"];
             # FIXME Get voicemail path from configuration file
            $directory      = "/var/spool/asterisk/voicemail/default";
            $file           = realpath($directory . DIRECTORY_SEPARATOR . $number . DIRECTORY_SEPARATOR . "INBOX" . DIRECTORY_SEPARATOR . $filename);
            if(strpos($file, $directory) ==  0 && strpos($file, $directory) !== false && file_exists($file) && is_file($file)){
                    header("Content-Disposition: attachment; filename=\"" . basename($file) . "\"");
                    header("Content-Length: " . filesize($file));
                    header("Content-Type: application/octet-stream;");
                    readfile($file);
            } else {
                    header("HTTP/1.0 404 Not Found");
                    header("Content-Type: application/json");
                    echo '{"status": "File not found", "code": 404}';
            }
    }

Security fix main/elastix.php

main/elastix.php

public function get_wav_file() - can take ../../../../../etc/passwd and any readable file
i check path before open file:

$name = $_GET["name"];
$directory = "/var/spool/asterisk/monitor";
$file = realpath($directory . $name);
if(strpos($file, $directory) !== false && strpos($file, $directory) == 0 && file_exists($file) && is_file($file)){

CDR report endpoint Empty Body

The CDR report endpoint returns empty body even with the Elastix dashboard having a lot of data in cdr report. All the other endpoints work properly.
I tried using a combination of the filters without any luck

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.