+

Last commit for index.php: 7146effad4b1d46f0edd888b00be72bbd6de7eaa

Initial commit

Benjamin Renard [2016-07-21 18:04:07]
Initial commit
  1. <?php
  2.  
  3. require('include.php');
  4.  
  5. MyAMI :: configure(
  6. 'ami' => array(
  7. 'host' => '127.0.0.1',
  8. 'scheme' => 'tcp://',
  9. 'port' => 5038,
  10. 'username' => 'manage-blacklist',
  11. 'secret' => 'xxxxxxx',
  12. 'connect_timeout' => 10000,
  13. 'read_timeout' => 10000
  14. ),
  15. 'logFile' => '/var/log/apache2/asterisk-ami.log',
  16. 'debug' => true
  17. )
  18. );
  19.  
  20. $tree=MyAMI :: dbGetTree();
  21. $info=false;
  22. $error=false;
  23.  
  24. if (isset($_POST['name']) && isset($_POST['number'])) {
  25. if(MyAMI :: dbPut('blacklist',$_REQUEST['number'],$_REQUEST['name'])) {
  26. $tree=MyAMI :: dbGetTree();
  27. $info="Caller ".$_REQUEST['name']." successfully blacklisted.";
  28. }
  29. else {
  30. $error="An error occured blacklisting caller ".$_REQUEST['name'].".";
  31. }
  32. }
  33. elseif (isset($_REQUEST['delete']) && isset($tree['blacklist'][urldecode($_REQUEST['delete'])])) {
  34. $number=urldecode($_REQUEST['delete']);
  35. if (MyAMI :: dbDel('blacklist',$number)) {
  36. $tree=MyAMI :: dbGetTree();
  37. $info="Number $number successfully unblacklisted.";
  38. }
  39. else {
  40. $error="An error occured unblacklisting number $number.";
  41. }
  42. }
  43.  
  44. ?>
  45.  
  46.  
  47. <!DOCTYPE html>
  48. <html lang="en">
  49. <head>
  50. <meta charset="utf-8">
  51. <meta http-equiv="X-UA-Compatible" content="IE=edge">
  52. <meta name="viewport" content="width=device-width, initial-scale=1">
  53.  
  54. <title>Asterisk Blacklist</title>
  55.  
  56. <!-- Latest compiled and minified CSS -->
  57. <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css" integrity="sha384-1q8mTJOASx8j1Au+a5WDVnPi2lkFfwwEAa8hDDdjZlpLegxhjVME1fgjWPGmkzs7" crossorigin="anonymous">
  58.  
  59. <!-- Optional theme -->
  60. <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap-theme.min.css" integrity="sha384-fLW2N01lMqjakBkx3l/M9EahuwpSfeNvV63J5ezn3uZzapT0u7EYsXMjQV+0En5r" crossorigin="anonymous">
  61.  
  62. <!-- HTML5 shim and Respond.js for IE8 support of HTML5 elements and media queries -->
  63. <!--[if lt IE 9]>
  64. <script src="https://oss.maxcdn.com/html5shiv/3.7.2/html5shiv.min.js"></script>
  65. <script src="https://oss.maxcdn.com/respond/1.4.2/respond.min.js"></script>
  66. <![endif]-->
  67. </head>
  68.  
  69. <body>
  70.  
  71. <div class="container">
  72.  
  73. <h1>Asterisk callers blacklist</h1>
  74.  
  75. <?php
  76.  
  77. if ($error) {
  78. echo "<div class='alert alert-warning' role='alert'>$error</div>";
  79. }
  80. if ($info) {
  81. echo "<div class='alert alert-success' role='alert'>$info</div>";
  82. }
  83. ?>
  84. <h3>Backlist a telephone number</h3>
  85.  
  86. <form method='POST' class="form-inline">
  87. <div class="form-group">
  88. <label for="name">Name</label>
  89. <input type="text" class="form-control" name="name" placeholder="Jane Doe">
  90. </div>
  91. <div class="form-group">
  92. <label for="number">Number</label>
  93. <input type="number" class="form-control" name="number" placeholder="0123456789">
  94. </div>
  95. <button type="submit" class="btn btn-default"><span class="glyphicon glyphicon-plus" aria-hidden="true"></span> Add</button>
  96. </form>
  97.  
  98. <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>
  99. <table class="table table-condensed">
  100. <thead>
  101. <tr>
  102. <th>Name</th>
  103. <th>Number</th>
  104. <th>Action</th>
  105. </tr>
  106. </thead>
  107. <tbody>
  108. <?php
  109. if (is_array($tree['blacklist'])) {
  110. foreach ($tree['blacklist'] as $num => $name) {
  111. echo "
  112. <tr>
  113. <td>$name</td>
  114. <td>$num</td>
  115. <td><a href='?delete=".urlencode($num)."'><span class='glyphicon glyphicon-trash' aria-hidden='true'></span></a></td>
  116. </tr>\n";
  117. }
  118. }
  119. ?>
  120. </tbody>
  121. </table>
  122.  
  123. </div>
  124.  
  125. <!-- Latest compiled and minified JavaScript -->
  126. <script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/js/bootstrap.min.js" integrity="sha384-0mSbJDEHialfmuBBQP6A4Qrprq5OVfW37PRR3j5ELqxss1yVqOtnepnHVP9aJ7xS" crossorigin="anonymous"></script>
  127. </body>
  128. </html>