aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJames Bottomley <JBottomley@Parallels.com>2013-04-26 17:40:55 -0700
committerJames Bottomley <JBottomley@Parallels.com>2013-04-26 17:40:55 -0700
commita95e460c9316c0be6b86949c00c74ac05c215098 (patch)
tree25ab3c84ff9b337385607a193ba75abe168195a0
parent2cdc6582217c2719ee31d251432792a10f2d7bf7 (diff)
downloadasterisk-aastra-a95e460c9316c0be6b86949c00c74ac05c215098.tar.gz
Blacklist: class for managing black and white lists
Signed-off-by: James Bottomley <JBottomley@Parallels.com>
-rw-r--r--include/Blacklist.class.php118
1 files changed, 118 insertions, 0 deletions
diff --git a/include/Blacklist.class.php b/include/Blacklist.class.php
new file mode 100644
index 0000000..97114d1
--- /dev/null
+++ b/include/Blacklist.class.php
@@ -0,0 +1,118 @@
+<?php
+##
+# Copyright 2013 by James Bottomley
+##
+# Blacklist handling class
+##
+require_once('BaseAastra.class.php');
+require_once('AastraIPPhoneTextScreen.class.php');
+require_once('AastraIPPhoneInputScreen.class.php');
+
+class Blacklist extends BaseAastra {
+
+ var $lastnumber;
+ var $name;
+ var $blacklist;
+ var $whitelist;
+
+ private function __initvar() {
+ $this->lastnumber = $this->asm->database_get('lastnumber', '1');
+ $this->blacklist = $this->asm->database_get('blacklist', $this->lastnumber);
+ $this->whitelist = $this->asm->database_get('whitelist', $this->lastnumber);
+ }
+
+ function __construct() {
+ parent::__construct();
+ $this->title = 'Blacklist/Whitelist';
+ $this->__initvar();
+ }
+
+ function del_black() {
+ $this->back = $this->url;
+ if (isset($_GET['yesno'])) {
+ if ($_GET['yesno'] == 'yes') {
+ $this->asm->database_del('blacklist',$this->lastnumber);
+ }
+ return;
+ }
+ $this->displayObject(new AastraIPPhoneTextScreen());
+ $this->do->SetText('Are you sure you want to remove '.$this->lastnumber.' from the Blacklist?');
+ $this->yesno();
+ }
+
+ function black() {
+ $this->back = $this->url;
+ if (isset($_GET['yesno'])) {
+ if ($_GET['yesno'] == 'yes') {
+ $this->asm->database_del('whitelist',$this->lastnumber);
+ $this->asm->database_put('blacklist',$this->lastnumber,'1');
+ }
+ return;
+ }
+ $this->displayObject(new AastraIPPhoneTextScreen());
+ $this->do->SetText('Are you sure you want to blacklist '.$this->lastnumber.'?');
+ $this->yesno();
+ }
+
+ function newnum() {
+ if (isset($_GET['num'])) {
+ $this->asm->database_put('lastnumber','1',$_GET['num']);
+ $this->__initvar();
+ $this->start();
+ return;
+ }
+ $this->back = $this->url;
+ $this->displayObject(new AastraIPPhoneInputScreen());
+ $this->do->setParameter('num');
+ $this->do->setType('number');
+ $this->do->setPrompt('Enter number:');
+ $this->do->setURL($this->fullurl);
+ }
+
+ function del_white() {
+ $this->back = $this->url;
+ if (isset($_GET['yesno'])) {
+ if ($_GET['yesno'] == 'yes') {
+ $this->asm->database_del('whitelist',$this->lastnumber);
+ }
+ return;
+ }
+ $this->displayObject(new AastraIPPhoneTextScreen());
+ $this->do->SetText('Are you sure you want to remove '.$this->lastnumber.' "'.$this->whitelist.'" from the Whitelist?');
+ $this->yesno();
+ }
+
+ function white() {
+ if (isset($_GET['description'])) {
+ $this->asm->database_del('blacklist',$this->lastnumber);
+ $this->asm->database_put('whitelist',$this->lastnumber,'"'.$_GET['description'].'"');
+ return;
+ }
+ $this->back = $this->url;
+ $this->displayObject(new AastraIPPhoneInputScreen());
+ $this->do->setParameter('description');
+ $this->do->setType('string');
+ $this->do->setPrompt('Enter description for '.$this->lastnumber.':');
+ $this->do->setURL($this->fullurl);
+ }
+
+ function start() {
+ $this->displayObject(new AastraIPPhoneTextScreen());
+ $text = 'The last number was '.$this->lastnumber;
+ if ($this->blacklist) {
+ $text .= ' which is already blacklisted';
+ $this->do->addSoftkey('1', 'Remove Blacklist', $this->url.'?action=del_black');
+ } else {
+ $this->do->addSoftkey('1', 'Blacklist', $this->url.'?action=black');
+ }
+ if ($this->whitelist) {
+ $text .= ' which is already in the whitelist as "'.$this->whitelist.'"';
+ $this->do->addSoftkey('2', 'Remove Whitelist', $this->url.'?action=del_white');
+ } else {
+ $this->do->addSoftkey('2', 'Whitelist', $this->url.'?action=white');
+ }
+ $this->do->SetText($text);
+ $this->do->addSoftkey('3', 'New Number', $this->url.'?action=newnum');
+ }
+}
+?>