File: click_to_dial.php

package info (click to toggle)
openser 1.1.0-9etch1
  • links: PTS
  • area: main
  • in suites: etch, etch-m68k
  • size: 9,828 kB
  • ctags: 11,809
  • sloc: ansic: 120,528; sh: 5,249; yacc: 1,716; makefile: 1,261; php: 656; perl: 205; sql: 190
file content (66 lines) | stat: -rw-r--r-- 1,278 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
<html>
<!-- $Id: click_to_dial.php,v 1.1.1.1 2005/06/13 16:47:30 bogdan_iancu Exp $ -->
<header>
<title>
Click-To-Dial
</title>
</header>

<body>
<h1>
Click-To-Dial
</h1>

<?php

/* config values */
$web_contact="sip:daemon@siphub.net";
$fifo="/tmp/ser_fifo";
$signature="web_test_0.0.0";

/* open reply fifo */
$myfilename="webfifo_".rand();
$mypath="/tmp/".$myfilename;

echo "Initiating your request...<p>";

/* open fifo now */
$fifo_handle=fopen( $fifo, "w" );
if (!$fifo_handle) {
    exit ("Sorry -- cannot open fifo: ".$fifo);
}

/* construct FIFO command */
$fifo_cmd=":t_uac:".$myfilename."\n".
    "REFER\n".$caller."\n".
    "p-version: ".$signature."\n".
    "Contact: ".$web_contact."\n".
    "Referred-By: ".$web_contact."\n".
	"Refer-To: ".$callee."\n".
    "\n". /* EoHeader */
    ".\n\n"; /* EoFifoRequest */

/* create fifo for replies */
system("mkfifo -m 666 ".$mypath );

/* write fifo command */
if (fwrite( $fifo_handle, $fifo_cmd)==-1) {
    unlink($mypath);
    fclose($fifo_handle);
    exit("Sorry -- fifo writing error");
}
fclose($fifo_handle);

/* read output now */
if (readfile( $mypath )==-1) {
    unlink($mypath);
	exit("Sorry -- fifo reading error");
}
unlink($mypath);
echo "<p>Thank you for using click-to-dial<p>";

?>

</body>
</html>