login | register
Fri 04 of Jul, 2008 [20:31 UTC]

voip-info.org

Search with Google
Search this site with Google. Results may not include recent changes.
 
Google Ads
Shoutbox
  • Samuel, Thu 03 of Jul, 2008 [13:41 UTC]: ok thank you
  • Mats Karlsson, Thu 03 of Jul, 2008 [13:37 UTC]: Nice Samuel, will look forward to rad it.
  • bwl_fernstudent, Thu 03 of Jul, 2008 [09:08 UTC]: Your blog shows some usefull code
  • Samuel, Thu 03 of Jul, 2008 [08:04 UTC]: I'll translate it, for sure
  • Mats Karlsson, Wed 02 of Jul, 2008 [20:46 UTC]: LOL, in french! Translate it to English and I will read it.
  • Samuel, Wed 02 of Jul, 2008 [08:07 UTC]: Hello, i wrote a blog about Asterisk, speaking about installation,programming and more http://sambranche.blogspot.com/
  • Nick Barnes, Tue 01 of Jul, 2008 [17:46 UTC]: Steve - Asterisk doesn't 'fit into linux' - it's an application which runs on top of Linux.
  • Steve, Mon 30 of Jun, 2008 [18:07 UTC]: anyone know where I can find a block diagram of how asterisk fits into linux. my f'ing bosses want me to draw something up.. ugh.
  • akbar, Fri 27 of Jun, 2008 [10:37 UTC]: marley_boyz@yahoo.com how to configure call forward, call back, call pick up using TDM and asterisk 1.2.13... please help me.. thx...
  • Matthew Williams, Tue 24 of Jun, 2008 [22:37 UTC]: We are looking for Tier II VoIP Support Technicians in St Louis. Send resumes to mwilliams AT voxitas DOT com.
Server Stats
  • Execution time: 0.39s
  • Memory usage: 2.60MB
  • Database queries: 29
  • GZIP: Disabled
  • Server load: 1.06

Asterisk tips managing CID names

Simple web interface for managing CID names:


Make sure to edit /etc/sudoers accordingly, for example using 'visudo' add an entry like:
  apache    ALL = NOPASSWD: /usr/sbin/asterisk -rx database * 

== cid-form.php ==

<html>
<head>
<title>Asterisk Caller ID form</title>
</head>
<body>
<h1>Asterisk phone book</h1>

<form name="EntryForm" action="cid-store.php" method=POST>

<table cellpadding=2>
<tr>
<td>Phone number:</td>
<td><input name="PhoneNumber" size=30></td>
</tr>
<tr>
<td>Name:</td>
<td><input name="PhoneName" size=30></td>
</tr>
<tr>
<td></td>
<td><div align=right>
<input type=submit value="Save">
</div></td>
</tr>
</table>

</form>
</body>
</html>


== cid-store.php ==

<HTML>
<HEAD>
<TITLE>Storing Asterisk CID data</TITLE>
</HEAD>
<BODY>
<h1>Asterisk phone book</h1>
<?php
set_time_limit(5);
if ($PhoneNumber <> "" && $PhoneName <> "") {
       // Note: this PHP script runs as user "apache"!
       // system("whoami > /tmp/info");
       system("sudo /usr/sbin/asterisk -rx " . escapeshellarg("database put cidname $PhoneNumber \"$PhoneName\"") . " &> /tmp/error");
       print "Successfully stored <b>$PhoneNumber</b> as <b>$PhoneName</b>.";
} else {
       print "Please enter both phone number and name!";
}
?>
</BODY>
</HTML>


== cid-list.php ==

</HEAD>
<BODY>
<h1>Asterisk phone book</h1>
<?php
set_time_limit(5);
system("sudo /usr/sbin/asterisk -rx \"database show cidname\" > /tmp/asterisk_cid-list.txt");

 $fd=fopen("/tmp/asterisk_cid-list.txt","r");
 while ($line=fgets($fd,1000))
 {
    $alltext.=$line;
 }
 fclose ($fd);
 print str_replace("\n", "<br>", $alltext);

?>
</BODY>
</HTML>


Following the examples above you'll not have much trouble to add a DELETE function as well.
Contributed by Philipp von Klitzing

Created by oej, Last modification by gsupp on Wed 10 of Aug, 2005 [07:36 UTC]

Comments Filter

Good example, but..

by Martin Kasztantowicz on Sunday 18 of June, 2006 [12:35:59 UTC]
there is still lots of work needed to make this ready for a production environment. In fact, I was inspired by this script and ended up in creating a php phonebook application that looks appealing and is usable by end users: :-)
http://voip-manager.net/asterisk-phonebook.php

Asterisk@Home users

by dave1216 on Saturday 04 of February, 2006 [10:14:05 UTC]
If your using Asterisk@Home, you need to use:
asterisk ALL = NOPASSWD: /usr/sbin/asterisk -rx database *

This is because httpd is ran from asterisk & not the user apache.

major security risk

by gsupp on Wednesday 10 of August, 2005 [07:35:06 UTC]
Please bear in mind adding the line to /etc/sudoers the author suggests is a major security risk. You're giving anyone with the ability to run a php script full access to your Asterisk server. I would recommend using this line instead, which restricts access to database functions only:

apache ALL = NOPASSWD: /usr/sbin/asterisk -rx database *

Need some help with this

by mantic on Wednesday 09 of February, 2005 [19:46:17 UTC]
I keep getting a parse error. any step by step would be appreciated fo rthis newbie.

tia
jp

POST variables need to get fetched

by felisa on Wednesday 24 of November, 2004 [03:31:26 UTC]
I couldn't get this to work without the following before the If statement in cid-store.php:

$PhoneNumber = $_POSTPhoneNumber>'PhoneNumber';
$PhoneName = $_POSTPhoneName>'PhoneName';

Please update this page with new information, just login and click on the "Edit" or "Add Comment" button above. Get a free login here: Register Thanks! - support@voip-info.org

Page Changes | Comments

Sponsored by:

Terms of Service Privacy Policy
© 2003-2008 VOIP-Info.org LLC

Powered by bitweaver