Soporte & Consultoria

Soporte Remoto y Consultoria skype : ambiorixg12.
Nota no se brinda ningun tipo de consulta o soporte fuera del blog de forma gratuita

martes, 20 de septiembre de 2016

AMI postback

<?php

$host="localhost";
$username="admin";
$secret="amp111";

$socket = fsockopen($host,"5038", $errno, $errstr,10);
      if (!$socket){
        echo "$errstr ($errno)\n";
        }else{
            fputs($socket, "Action: Login\r\n");
            fputs($socket, "UserName: $username\r\n");
            fputs($socket, "Secret: $secret\r\n\r\n");
            fputs($socket, "Action: WaitEvent\r\n");
            fputs($socket, "Action: Logoff\r\n\r\n");

   while(!feof($socket)){

  $result=fread($socket,5000);


if (preg_match("/\b$argv[1]\b/i", $result, $match)){

$r=explode("\n",$result);
//catch the event name
$event=explode(" ",$r[0]);
echo "Event name is $event[1]\n";
//Match the Event
if (preg_match("/AgentCalled/","$event[1]")){
//extract parameters from AgentCalled
foreach( $r as $key=>$value){


echo " $key : $value\n";

}

//clean variables
$member=cleanstr($r[32]);
$queue=cleanstr($r[30]);
$descaller=cleanstr($r[19]);
$callerid=cleanstr($r[5]);
$linkedid=cleanstr($r[15]);

echo "$member\n";
echo "$queue\n";
echo "$descaller\n";
echo "$callerid\n";
echo "$linkedid\n";
echo count_chars($member,3);
//clean variables from special characters.We could use trim($var,"\r")
$member=trim($member);
$queue=trim($queue);
$descaller=trim($descaller);
$callerid=trim($callerid);
$linkedid=trim($linkedid);





//$postback=file_get_contents("http://65.181.118.232/code.php?id=$queue&pos=$member");

System("curl -X GET \"http://msn.com/Webservice1.asmx/GetDataFromAsterisk?Queue=$queue&MemberName=$member&DestCallerIdNum=$descaller&CallerIdNum=$callerid&Linkedid=$linkedid\"");

echo ("http://alterscheduler.kindlebit.com/Webservice1.asmx/GetDataFromAsterisk?Queue=$queue&MemberName=$member&DestCallerIdNum=$descaller&CallerIdNum=$callerid&Linkedid=$linkedid");


}
continue;


}

}
}


fclose($socket);
function cleanstr($var){
$var = explode(" ",$var);
 $var=$var[1];
return($var);

}
?>

sábado, 17 de septiembre de 2016

Installing freepbx modules manually

fwconsole ma downloadinstall userman
fwconsole reload
http://wiki.freepbx.org/pages/viewpage.action?pageId=37912685

martes, 13 de septiembre de 2016

AMI alert event only for some extensions and events

#!/usr/bin/php
<?php
require("setting.php");

$socket = fsockopen($host,"5038", $errno, $errstr,10);
      if (!$socket){
        echo "$errstr ($errno)\n";
        }else{
            fputs($socket, "Action: Login\r\n");
            fputs($socket, "UserName: $username\r\n");
            fputs($socket, "Secret: $secret\r\n\r\n");
            fputs($socket, "Action: WaitEvent\r\n");
            fputs($socket, "Action: Logoff\r\n\r\n");

   while(!feof($socket)){

  $result=fread($socket,5000);
  $result.=date("Y-m-d H:i:s");

$events=array("HangupRequest","MusicOnHoldStart","MusicOnHoldStop");


foreach($events as $value) {

if (preg_match("/\b$value\b/i", $result, $match)){


if (preg_match("/\bHangupRequest\b/i", $result, $match)){

$elements=explode("\n",$result);

foreach($elements as $key=>$value) {
echo "$key $value\n";
$message="You have  missed call from number $elements[5]\n to extension $elements[7] at $elements[17]";
}

$num=explode(" ",$elements[5]);
$extensions=array(1001,100,1005);

if(in_array($num[1],$extensions)){

mail("ambiorixg12@gmail.com","  You have a missed call from $num[1]",$message);
}


}

}

continue;


}

}

}

fclose($socket);

?>



PHP setting file

<?php
$host="127.0.0.1";
$username="admin";
$secret="11336";
?>
nohup /usr/bin/php /var/www/monitor/alert.php &
root@asterisk-dominicana:/var/www/monitor# ps aux | grep -i aler | grep -v grep
root     28755  0.0  2.4 259320 12052 pts/0    S    00:05   0:00 /usr/bin/php /var/www/monitor/alert.php

jueves, 1 de septiembre de 2016

crontab

@reboot /bin/echo " Today date is $(date)">> /root/date.conf
@reboot /root/check.sh >>/root/ambiorix.conf  2>&1
@reboot /usr/src/freepbx/start_asterisk start >/root/asterisk.log 2>&1

sábado, 27 de agosto de 2016

Instalando FreePBX 13 en Ubuntu Server 14.04.2

Saltar al final de los metadatos
Ir al inicio de los metadatos

Initial System Setup

When installing the machine, at package selection make sure you pick - at least - 'OpenSSH Server', and 'LAMP Packages'.  This installs the base packages required.

MySQL Password

After selecting 'Continue' you will be prompted (several times) for a root password. There is no need to set one, and setting one is discouraged! As part of the FreePBX install, a secure (128 bit) password is generated, and used to lock down MySQL. If you set a password now, it is not possible for the installer to secure your database. Please just push 'enter' when prompted for a password.

Unlock and configure your root password.

You may find it helpful to log in directly as root to manage and update your system. We recommend you do set a root password, and enable SSH logins from root, so you don't need to go through secondary steps that may cause problems.  This command enables SSH root logins, and prompts you for a new root password.
sed -i 's/PermitRootLogin without-password/PermitRootLogin yes/' /etc/sshd/sshd_config
service ssh restart
sudo passwd root

Switch to the Root User

THIS IS IMPORTANT!  You must run the entire process as root. Attempting to use 'sudo' later on will not work. Please don't ignore this. You must run this command to switch to an interactive root shell.
sudo -i

Update Your System

apt-get update && apt-get upgrade -y 

Install Required Dependencies

apt-get install -y build-essential linux-headers-`uname -r` openssh-server apache2 mysql-server\
  mysql-client bison flex php5 php5-curl php5-cli php5-mysql php-pear php5-gd curl sox\
  libncurses5-dev libssl-dev libmysqlclient-dev mpg123 libxml2-dev libnewt-dev sqlite3\
  libsqlite3-dev pkg-config automake libtool autoconf git unixodbc-dev uuid uuid-dev\
  libasound2-dev libogg-dev libvorbis-dev libcurl4-openssl-dev libical-dev libneon27-dev libsrtp0-dev\
  libspandsp-dev libmyodbc
  

Reboot server

reboot

After the Reboot

Ensure that you re-run 'sudo -i', or log in as the root user. As mentioned above, the entire install process must be run as 'root', and failure to do so will cause unexpected problems.

Install Legacy pear requirements

pear install Console_Getopt

Install Dependencies for Google Voice (if required)

You may skip this section if you do not require Google Voice support.

Install iksemel

cd /usr/src
wget https://iksemel.googlecode.com/files/iksemel-1.4.tar.gz
tar xf iksemel-1.4.tar.gz
cd iksemel-*
./configure
make
make install

Install and Configure Asterisk

Download Asterisk source files.

cd /usr/src
wget http://downloads.asterisk.org/pub/telephony/dahdi-linux-complete/dahdi-linux-complete-current.tar.gz
wget http://downloads.asterisk.org/pub/telephony/libpri/libpri-current.tar.gz
wget http://downloads.asterisk.org/pub/telephony/asterisk/asterisk-13-current.tar.gz
wget -O jansson.tar.gz https://github.com/akheron/jansson/archive/v2.7.tar.gz
wget http://www.pjsip.org/release/2.4/pjproject-2.4.tar.bz2

Compile and install DAHDI.

If you don't have any physical PSTN hardware attached to this machine, you don't need to install DAHDI (For example, a T1 or E1 card, or a USB device). Most smaller setups will not have DAHDI hardware, and this step can be safely skipped.
cd /usr/src
tar xvfz dahdi-linux-complete-current.tar.gz
rm -f dahdi-linux-complete-current.tar.gz
cd dahdi-linux-complete-*
make all
make install
make config
cd /usr/src
tar xvfz libpri-current.tar.gz
rm -f libpri-current.tar.gz
cd libpri-*
make
make install
Compile and install pjproject
cd /usr/src
tar -xjvf pjproject-2.4.tar.bz2
rm -f pjproject-2.4.tar.bz2
cd pjproject-2.4
CFLAGS='-DPJ_HAS_IPV6=1' ./configure --enable-shared --disable-sound --disable-resample --disable-video --disable-opencore-amr
make dep
make
make install

Compile and Install jansson

cd /usr/src
tar vxfz jansson.tar.gz
rm -f jansson.tar.gz
cd jansson-*
autoreconf -i
./configure
make
make install

Compile and install Asterisk

cd /usr/src
tar xvfz asterisk-13-current.tar.gz
rm -f asterisk-13-current.tar.gz
cd asterisk-*
contrib/scripts/install_prereq install
./configure
contrib/scripts/get_mp3_source.sh
make menuselect
You will be prompted at the point to pick which modules to build. Most of them will already be enabled, but if you want to have MP3 support (eg, for Music on Hold), you need to manually turn on 'format_mp3' on the first page.
After selecting 'Save & Exit' you can then continue
make
make install
make config
ldconfig
update-rc.d -f asterisk remove

Install Asterisk Soundfiles.

The 'make install' above installs a standard low-quality base sound file by default. This is suitable if you are on a small, underpowered system (such as a Rasberry Pi), but on a larger system you should install higher quality soundfiles.  Note that this installs the (8khz) 'wav' soundfiles and G722 (High Definition 'Wideband') audio.
cd /var/lib/asterisk/sounds
wget http://downloads.asterisk.org/pub/telephony/sounds/asterisk-core-sounds-en-wav-current.tar.gz
wget http://downloads.asterisk.org/pub/telephony/sounds/asterisk-extra-sounds-en-wav-current.tar.gz
tar xvf asterisk-core-sounds-en-wav-current.tar.gz
rm -f asterisk-core-sounds-en-wav-current.tar.gz
tar xfz asterisk-extra-sounds-en-wav-current.tar.gz
rm -f asterisk-extra-sounds-en-wav-current.tar.gz
# Wideband Audio download
wget http://downloads.asterisk.org/pub/telephony/sounds/asterisk-core-sounds-en-g722-current.tar.gz
wget http://downloads.asterisk.org/pub/telephony/sounds/asterisk-extra-sounds-en-g722-current.tar.gz
tar xfz asterisk-extra-sounds-en-g722-current.tar.gz
rm -f asterisk-extra-sounds-en-g722-current.tar.gz
tar xfz asterisk-core-sounds-en-g722-current.tar.gz
rm -f asterisk-core-sounds-en-g722-current.tar.gz

Install and Configure FreePBX

Create the Asterisk user and set base file permissions.

useradd -m asterisk
chown -R asterisk. /var/run/asterisk
chown -R asterisk. /etc/asterisk
chown -R asterisk. /var/{lib,log,spool}/asterisk
chown -R asterisk. /usr/lib/asterisk
rm -rf /var/www/html

A few small modifications to Apache.

sed -i 's/\(^upload_max_filesize = \).*/\120M/' /etc/php5/apache2/php.ini
cp /etc/apache2/apache2.conf /etc/apache2/apache2.conf_orig
sed -i 's/^\(User\|Group\).*/\1 asterisk/' /etc/apache2/apache2.conf
sed -i 's/AllowOverride None/AllowOverride All/' /etc/apache2/apache2.conf
service apache2 restart

Configure ODBC

Edit /etc/odbcinst.ini and add the following. Note that this command assumes you are installing to a new machine, and that the file is empty. If this is not a freshly installed machine, please manually verify the contents of the file, rather than just copying and pasting the lines below. The 'EOF' does no go in the file, it simply signals to the 'cat' command that you have finished pasting.
cat >> /etc/odbcinst.ini << EOF
[MySQL]
Description = ODBC for MySQL
Driver = /usr/lib/x86_64-linux-gnu/odbc/libmyodbc.so
Setup = /usr/lib/x86_64-linux-gnu/odbc/libodbcmyS.so
FileUsage = 1
  
EOF
You may need to verify these paths, if you're not on a x86_64 machine. You can use the command `find / -name libmyodbc.so` to verify the location
Edit or create /etc/odbc.ini and add the following section. Note that, again, this command assumes you are installing to a new machine, and the file is empty. Please manually verify the contents of the files if this is not the case.
cat >> /etc/odbc.ini << EOF
[MySQL-asteriskcdrdb]
Description=MySQL connection to 'asteriskcdrdb' database
driver=MySQL
server=localhost
database=asteriskcdrdb
Port=3306
Socket=/var/run/mysqld/mysqld.sock
option=3
  
EOF

Download and install FreePBX.

cd /usr/src
wget http://mirror.freepbx.org/modules/packages/freepbx/freepbx-13.0-latest.tgz
tar vxfz freepbx-13.0-latest.tgz
rm -f freepbx-13.0-latest.tgz
cd freepbx
./start_asterisk start
./install -n  --dbpass 1234560

crontab -e
@reboot /etc/init.d/asterisk stop && /usr/src/freepbx/start_asterisk start