コード例 #1
0
ファイル: page.blacklist.php プロジェクト: hardikk/HNH
$dispnum = "blacklist";
//used for switch on config.php
//if submitting form, update database
if (isset($_REQUEST['action'])) {
    switch ($action) {
        case "add":
            blacklist_add($_POST);
            redirect_standard();
            break;
        case "delete":
            blacklist_del($number);
            redirect_standard();
            break;
        case "edit":
            blacklist_del($editnumber);
            blacklist_add($_POST);
            redirect_standard('editnumber');
            break;
    }
}
$numbers = blacklist_list();
?>
</div>

<!-- NO rnav in this module -->


<div class="content">
<?php 
if ($action == 'delete') {
    echo '<h3>' . _("Blacklist entry") . ' ' . $itemid . ' ' . _("deleted") . '!</h3>';
コード例 #2
0
 public function doConfigPageInit($page)
 {
     $dispnum = 'blacklist';
     $astver = $this->FreePBX->Config->get('ASTVERSION');
     $request = $_REQUEST;
     if (isset($request['goto0'])) {
         $destination = $request[$request['goto0'] . '0'];
     }
     isset($request['action']) ? $action = $request['action'] : ($action = '');
     isset($request['oldval']) ? $action = 'edit' : $action;
     isset($request['number']) ? $number = $request['number'] : ($number = '');
     isset($request['description']) ? $description = $request['description'] : ($description = '');
     if (isset($request['action'])) {
         switch ($action) {
             case 'settings':
                 $this->destinationSet($destination);
                 $this->blockunknownSet($request['blocked']);
                 break;
             case 'import':
                 if ($_FILES['file']['error'] > 0) {
                     echo '<div class="alert alert-danger" role="alert">' . _('There was an error uploading the file') . '</div>';
                 } else {
                     if (pathinfo($_FILES['blacklistfile']['name'], PATHINFO_EXTENSION) == 'csv') {
                         $path = sys_get_temp_dir() . '/' . $_FILES['blacklistfile']['name'];
                         move_uploaded_file($_FILES['blacklistfile']['tmp_name'], $path);
                         if (file_exists($path)) {
                             ini_set('auto_detect_line_endings', true);
                             $handle = fopen($path, 'r');
                             set_time_limit(0);
                             while (($data = fgetcsv($handle)) !== false) {
                                 if ($data[0] == 'number' && $data[1] == 'description') {
                                     continue;
                                 }
                                 blacklist_add(array('number' => $data[0], 'description' => $data[1], 'blocked' => 0));
                             }
                             unlink($path);
                             echo '<div class="alert alert-success" role="alert">' . _('Sucessfully imported all entries') . '</div>';
                         } else {
                             echo '<div class="alert alert-danger" role="alert">' . _('Could not find file after upload') . '</div>';
                         }
                     } else {
                         echo '<div class="alert alert-danger" role="alert">' . _('The file must be in CSV format!') . '</div>';
                     }
                 }
                 break;
             case 'export':
                 $list = $this->getBlacklist();
                 if (!empty($list)) {
                     header('Content-Type: text/csv; charset=utf-8');
                     header('Content-Disposition: attachment; filename=blacklist.csv');
                     $output = fopen('php://output', 'w');
                     fputcsv($output, array('number', 'description'));
                     foreach ($list as $l) {
                         fputcsv($output, $l);
                     }
                 } else {
                     header('HTTP/1.0 404 Not Found');
                     echo _('No Entries to export');
                 }
                 die;
                 break;
         }
     }
 }