You are told by e-mail.

Discuss any topic about Brekeke SIP Server.

Moderator: Brekeke Support Team

Post Reply
makoto
Posts: 12
Joined: Wed Sep 05, 2012 8:26 pm
Location: JAPAN

You are told by e-mail.

Post by makoto »

1. Brekeke Product Name and version:
Brekeke SIP Server 2.4.8.6
2. Java version:
1.7.0_05
3. OS type and the version:
Linu 2.6.32-279.1.1.el6.x86_64
4. UA (phone), gateway or other hardware/software involved:

5. Select your network pattern from http://www.brekeke-sip.com/bbs/network/ ... terns.html :
pattern1
6. Your problem:
Japanese was translated into English with translation software.
I think that there is a miswritten word.
Please read by warm heart.
:)

http://204.200.204.196/bbs_jp/viewtopic.php?t=8

When someone is called and there is no response, how to mail that there was a call is considered.
Made from PHP.
Will be displayed as "ERROR."
makoto
Posts: 12
Joined: Wed Sep 05, 2012 8:26 pm
Location: JAPAN

Re: You are told by e-mail.

Post by makoto »

If "http://[userid]:[password]@localhost:[port]/path?query" is inputted by URL, it will be compulsorily sent to "http://localhost:[port]/gate?bean=sipadmin.web.Login".
* The right way of writing.
* The site etc. which are consulted.
Please let me know.

Thank you.
davi
Posts: 34
Joined: Wed Jan 26, 2011 4:34 pm

Post by davi »

Are you talking about Brekeke PBX's feature?
makoto
Posts: 12
Joined: Wed Sep 05, 2012 8:26 pm
Location: JAPAN

Post by makoto »

[quote="davi"]Are you talking about Brekeke PBX's feature?[/quote]

Thank you for your replay.

No.
I want to apply to SIP, the PHP that can be used in the PBX.
davi
Posts: 34
Joined: Wed Jan 26, 2011 4:34 pm

Post by davi »

Do you want to receive an e-mail notification if a callee doesn't pick a call?

I know the following Brekeke PBX's API allows you to create such a feature.
http://www.brekeke-sip.com/download/bpb ... _db_en.pdf
makoto
Posts: 12
Joined: Wed Sep 05, 2012 8:26 pm
Location: JAPAN

Post by makoto »

> Do you want to receive an e-mail notification if a callee doesn't pick a call?

Yes.

> I know the following Brekeke PBX's API allows you to create such a feature.

Thank you for your information.
However, there is not MySQL in a SIP call log.
thinks by the method of running by PHP.

[code]
<?php
function http($url="http://[userid]:[password]@localhost:[port]/path?query", $method="GET", $headers="Brekeke", $post=array(""))
{
$URL = parse_url($url);
if (isset($URL['query'])) {
$URL['query'] = "?".$URL['query'];
} else {
$URL['query'] = "";
}
if (!isset($URL['port'])) $URL['port'] = 80;
$request = $method." ".$URL['path'].$URL['query']." HTTP/1.0\r\n";
$request .= "Host: ".$URL['host']."\r\n";
$request .= "User-Agent: PHP/".phpversion()."\r\n";
if (isset($URL['user']) && isset($URL['pass'])) {
$request .= "Authorization: Basic ".base64_encode($URL['user'].":".$URL['pass'])."\r\n";
}
$request .= $headers;
if (strtoupper($method) == "POST") {
while (list($name, $value) = each($post)) {
$POST[] = $name."=".urlencode($value);
}
$postdata = implode("&", $POST);
$request .= "Content-Type: application/x-www-form-urlencoded\r\n";
$request .= "Content-Length: ".strlen($postdata)."\r\n";
$request .= "\r\n";
$request .= $postdata;
} else {
$request .= "\r\n";
}
$fp = fsockopen($URL['host'], $URL['port']);
if (!$fp) {
die("ERROR\n");
}
fputs($fp, $request);
$response = "";
while (!feof($fp)) {
$response .= fgets($fp, 4096);
}
fclose($fp);
$DATA = split("\r\n\r\n", $response, 2);
echo "<!--\n".$request."\n-->\n";
echo "<!--\n".$DATA[0]."\n-->\n";
echo $DATA[1];
}
http("http://localhost:[port]/gate?bean=sipadmin.web.LogViewer&operation=html&ymd=20120903");
?>
[/code]
Tata
Posts: 223
Joined: Sun Jan 27, 2008 1:03 pm

Post by Tata »

Hi Makoto,
Please explain how the code works.
makoto
Posts: 12
Joined: Wed Sep 05, 2012 8:26 pm
Location: JAPAN

Post by makoto »

> Please explain how the code works.

Thank you for your replay.
OK.

For example, suppose that I call you.
01: I => You
02: However, you are absent.
You is not answered.
03: PHP reads call log of Brekeke SIP Server.
PHP finds Cancel or Time out by result of call log.
04: PHP tells you about "makoto call you, September 11." by e-mail.
05: You could know the call from me by E-mail.
makoto
Posts: 12
Joined: Wed Sep 05, 2012 8:26 pm
Location: JAPAN

Post by makoto »

[code]
<?php
/*
$url : URL which begins from http://( http://user:pass@host:port/path?query )
$method : GET, POST, or HEAD (a default is GET)
$headers : Arbitrary additional headers
$post : Arrangement which stored the data transmitted at the time of POST ("variable identifier" => "value")
*/
[/code]
makoto
Posts: 12
Joined: Wed Sep 05, 2012 8:26 pm
Location: JAPAN

Post by makoto »

[code]
function http($url="http://[userid]:[password]@localhost:[port]/path?query", $method="GET", $headers="Brekeke", $post=array(""))
{
/* URL is decomposed */
$URL = parse_url($url);

/* Query */
if (isset($URL['query'])) {
$URL['query'] = "?".$URL['query'];
} else {
$URL['query'] = "";
}

/* A default port is 80 */
if (!isset($URL['port'])) $URL['port'] = 80;

/* Request line */
$request = $method." ".$URL['path'].$URL['query']." HTTP/1.0\r\n";

/* Request header */
$request .= "Host: ".$URL['host']."\r\n";
$request .= "User-Agent: PHP/".phpversion()."\r\n";

/* The header for Basic attestation */
if (isset($URL['user']) && isset($URL['pass'])) {
$request .= "Authorization: Basic ".base64_encode($URL['user'].":".$URL['pass'])."\r\n";
}

/* An additional header */
$request .= $headers;

/* A header is added at the time of POST.
The data which carried out URL encoding is attached to an end. */
if (strtoupper($method) == "POST") {
while (list($name, $value) = each($post)) {
$POST[] = $name."=".urlencode($value);
}
$postdata = implode("&", $POST);
$request .= "Content-Type: application/x-www-form-urlencoded\r\n";
$request .= "Content-Length: ".strlen($postdata)."\r\n";
$request .= "\r\n";
$request .= $postdata;
} else {
$request .= "\r\n";
}

/* Connects with a WEB server */
$fp = fsockopen($URL['host'], $URL['port']);

/* Processing when connection goes wrong */
if (!$fp) {
die("ERROR\n");
}

/* Demand data transmission */
fputs($fp, $request);

/* Response data reception */
$response = "";
while (!feof($fp)) {
$response .= fgets($fp, 4096);
}

/* Connection is ended */
fclose($fp);

/* A header portion and a body section are separated */
$DATA = split("\r\n\r\n", $response, 2);

/* A request header is commented out and it is an output */
echo "<!--\n".$request."\n-->\n";

/* A response header is commented out and it is an output */
echo "<!--\n".$DATA[0]."\n-->\n";

/* A message body is outputted */
echo $DATA[1];
}

http("http://localhost:[port]/gate?bean=sipadmin.web.LogViewer&operation=html&ymd=20120903");
/* Next, the schedule which puts in an e-mail transmitting script */

?>
[/code]

Thank you.
Tata
Posts: 223
Joined: Sun Jan 27, 2008 1:03 pm

Post by Tata »

> Will be displayed as "ERROR."

From your PHP code, it seems the "ERROR" happens if the PHP program can not open the URL.
Make sure the URL is correct.



By the way, it seems your PHP program gets the call result through the web access.
Since PHP access will not be a real-time manner, I recommend you use the plugin which allow you to send an e-mail in real-time.

http://www.brekeke-sip.com/download/bss ... gin_en.txt
You can use "eventSessionEnd()" as a trigger for sending an e-mail.
makoto
Posts: 12
Joined: Wed Sep 05, 2012 8:26 pm
Location: JAPAN

Post by makoto »

Very match thank you.

> From your PHP code, it seems the "ERROR" happens if the PHP program can not open the URL.
> Make sure the URL is correct.

I know.
How should it input into URL? It thought.

> By the way, it seems your PHP program gets the call result through the web access.

Yes.

> Since PHP access will not be a real-time manner,

I know.
I'm looking for the software to run the PHP in real time.

> I recommend you use the plugin which allow you to send an e-mail in real-time.

Oh.......
Thank you for your information.
How do I process, such as subject and body etc?

Thank you.
Tata
Posts: 223
Joined: Sun Jan 27, 2008 1:03 pm

Post by Tata »

> How do I process, such as subject and body etc?

Refer to the plugin API document.
The event method "eventSessionEnd()" will be called just after a session closes.
If its result code is 2, it means the call has been canceled.

For composing an e-mail, refer to JavaMail API.
makoto
Posts: 12
Joined: Wed Sep 05, 2012 8:26 pm
Location: JAPAN

Post by makoto »

Thank you for replay.
:)

> Refer to the plugin API document.
> For composing an e-mail, refer to JavaMail API.

I looked in the search engine, I can not find what it looked like.
Where is it?
Please tell us about the site.
makoto
Posts: 12
Joined: Wed Sep 05, 2012 8:26 pm
Location: JAPAN

Post by makoto »

Perhaps, there is a need to create a plug-in, I tried to make Email.java.

[code]
package com.brekeke.net.sip.sv.session.plugins;

import com.brekeke.net.sip.sv.session.*;
import com.brekeke.net.sip.sv.session.plugins.*;

public void eventSessionEnd( EventStat evstat )
int sid;

String callid;

String username;
String usernameAuth;

String urlCaller;
String tagCaller;
AddrPort apCaller;

String urlCallee;
String tagCallee;
AddrPort apCallee;

String methodStart;
long seqStart;

String methodEnd;
long seqEnd;
int senderEnd;

long timeSessionStart;
long timeSessionEnd;
long timeTalkStart;
long timeTalkEnd;

int result;
int errorcode;

[Class name]......
[/code]

If i make it this way is correct, what may be the same as PHP is more writing this?
And this E-mail.java may be saved at a plug-in folder?

Dial plan is......

Matching Patterns:
$request = ^INVITE

Deploy Patterns:
$session = [Class name]
$continue = true
Tata
Posts: 223
Joined: Sun Jan 27, 2008 1:03 pm

Post by Tata »

makoto
Posts: 12
Joined: Wed Sep 05, 2012 8:26 pm
Location: JAPAN

Post by makoto »

> This is the Session Plugin document.
http://www.brekeke-sip.com/download/bss ... gin_en.txt
> This is JavaMail API.
http://www.oracle.com/technetwork/java/ ... index.html

Thank you for guidance to site.

In these two, it will be beyond my understanding.
If it is you when good, do you show me "how it advances, makes and sets up" and the example of description, and get them?

I learn based on this example of description.
makoto
Posts: 12
Joined: Wed Sep 05, 2012 8:26 pm
Location: JAPAN

Post by makoto »

If difficult, as suited first, it will be coped with by PHP.
How should it input in URL so that it can log in by "http://[localhost]:[port]/gate?bean=sipadmin.web.Login" without entering ID and a password? Please let me know.

Ex)
http://[ID].[Password]@[localhost]:[port]/gate?bean=sipadmin.web.Login

Thank you.
ambrosio
Posts: 215
Joined: Thu Mar 27, 2008 12:20 pm

Post by ambrosio »

Have you tried this URL?
http://[ID]:[Password]@[localhost]:[port]/gate?bean=sipadmin.web.Login
Tata
Posts: 223
Joined: Sun Jan 27, 2008 1:03 pm

Post by Tata »

> And this E-mail.java may be saved at a plug-in folder?

The JAR file must be located under
<SIP Server install_dir>\webapps\proxy\WEB-INF\lib
Post Reply