Zionetrix::Git
Repositories
Help
Report an Issue
manage-asterisk-blacklist
Code
Commits
Branches
Tags
Search
Tree:
7146eff
Branches
Tags
master
manage-asterisk-blacklist
index.php
Initial commit
Benjamin Renard
commited
7146eff
at 2016-07-21 18:04:07
index.php
Blame
History
Raw
<?php require('include.php'); MyAMI :: configure( array( 'ami' => array( 'host' => '127.0.0.1', 'scheme' => 'tcp://', 'port' => 5038, 'username' => 'manage-blacklist', 'secret' => 'xxxxxxx', 'connect_timeout' => 10000, 'read_timeout' => 10000 ), 'logFile' => '/var/log/apache2/asterisk-ami.log', 'debug' => true ) ); $tree=MyAMI :: dbGetTree(); $info=false; $error=false; if (isset($_POST['name']) && isset($_POST['number'])) { if(MyAMI :: dbPut('blacklist',$_REQUEST['number'],$_REQUEST['name'])) { $tree=MyAMI :: dbGetTree(); $info="Caller ".$_REQUEST['name']." successfully blacklisted."; } else { $error="An error occured blacklisting caller ".$_REQUEST['name']."."; } } elseif (isset($_REQUEST['delete']) && isset($tree['blacklist'][urldecode($_REQUEST['delete'])])) { $number=urldecode($_REQUEST['delete']); if (MyAMI :: dbDel('blacklist',$number)) { $tree=MyAMI :: dbGetTree(); $info="Number $number successfully unblacklisted."; } else { $error="An error occured unblacklisting number $number."; } } ?> <!DOCTYPE html> <html lang="en"> <head> <meta charset="utf-8"> <meta http-equiv="X-UA-Compatible" content="IE=edge"> <meta name="viewport" content="width=device-width, initial-scale=1"> <title>Asterisk Blacklist</title> <!-- Latest compiled and minified CSS --> <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css" integrity="sha384-1q8mTJOASx8j1Au+a5WDVnPi2lkFfwwEAa8hDDdjZlpLegxhjVME1fgjWPGmkzs7" crossorigin="anonymous"> <!-- Optional theme --> <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap-theme.min.css" integrity="sha384-fLW2N01lMqjakBkx3l/M9EahuwpSfeNvV63J5ezn3uZzapT0u7EYsXMjQV+0En5r" crossorigin="anonymous"> <!-- HTML5 shim and Respond.js for IE8 support of HTML5 elements and media queries --> <!--[if lt IE 9]> <script src="https://oss.maxcdn.com/html5shiv/3.7.2/html5shiv.min.js"></script> <script src="https://oss.maxcdn.com/respond/1.4.2/respond.min.js"></script> <![endif]--> </head> <body> <div class="container"> <h1>Asterisk callers blacklist</h1> <?php if ($error) { echo "<div class='alert alert-warning' role='alert'>$error</div>"; } if ($info) { echo "<div class='alert alert-success' role='alert'>$info</div>"; } ?> <h3>Backlist a telephone number</h3> <form method='POST' class="form-inline"> <div class="form-group"> <label for="name">Name</label> <input type="text" class="form-control" name="name" placeholder="Jane Doe"> </div> <div class="form-group"> <label for="number">Number</label> <input type="number" class="form-control" name="number" placeholder="0123456789"> </div> <button type="submit" class="btn btn-default"><span class="glyphicon glyphicon-plus" aria-hidden="true"></span> Add</button> </form> <h3>Current blacklisted telephone numbers <a href="index.php" class="btn btn-default" role="button"><span class="glyphicon glyphicon-refresh" aria-hidden="true"></span></a></h3> <table class="table table-condensed"> <thead> <tr> <th>Name</th> <th>Number</th> <th>Action</th> </tr> </thead> <tbody> <?php if (is_array($tree['blacklist'])) { foreach ($tree['blacklist'] as $num => $name) { echo " <tr> <td>$name</td> <td>$num</td> <td><a href='?delete=".urlencode($num)."'><span class='glyphicon glyphicon-trash' aria-hidden='true'></span></a></td> </tr>\n"; } } ?> </tbody> </table> </div> <!-- Latest compiled and minified JavaScript --> <script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/js/bootstrap.min.js" integrity="sha384-0mSbJDEHialfmuBBQP6A4Qrprq5OVfW37PRR3j5ELqxss1yVqOtnepnHVP9aJ7xS" crossorigin="anonymous"></script> </body> </html>