Esempio n. 1
0
function tbxUploadStepOne()
{
    global $t;
    $v = Validator::Create();
    $_REQUEST['tags'] = Tags::Format($_REQUEST['tags']);
    $v->Register($_REQUEST['title'], Validator_Type::LENGTH_BETWEEN, _T('Validation:Invalid Length', _T('Label:Title'), Config::Get('title_min_length'), Config::Get('title_max_length')), Config::Get('title_min_length') . ',' . Config::Get('title_max_length'));
    $v->Register($_REQUEST['description'], Validator_Type::LENGTH_BETWEEN, _T('Validation:Invalid Length', _T('Label:Description'), Config::Get('description_min_length'), Config::Get('description_max_length')), Config::Get('description_min_length') . ',' . Config::Get('description_max_length'));
    $v->Register(Tags::Count($_REQUEST['tags']), Validator_Type::IS_BETWEEN, _T('Validation:Invalid Num Tags', Config::Get('tags_min'), Config::Get('tags_max')), Config::Get('tags_min') . ',' . Config::Get('tags_max'));
    // Register user-defined field validators
    $schema = GetDBSchema();
    $v->RegisterFromXml($schema->el('//table[name="tbx_video_custom"]'), 'user', 'create');
    // Check blacklist
    $_REQUEST['ip_address'] = $_SERVER['REMOTE_ADDR'];
    if (($match = Blacklist::Match($_REQUEST, Blacklist::ITEM_VIDEO)) !== false) {
        $v->SetError(_T('Validation:Blacklisted', $match['match']));
    }
    // Validate CAPTCHA
    if (Config::Get('flag_captcha_on_upload')) {
        Captcha::Verify();
    }
    if (!$v->Validate()) {
        $t->Assign('g_errors', $v->GetErrors());
        $t->AssignByRef('g_form', $_REQUEST);
        return tbxDisplayUpload();
    }
    $_REQUEST['step_one_data'] = base64_encode(serialize($_REQUEST));
    $_REQUEST['step_one_sig'] = sha1($_REQUEST['step_one_data'] . Config::Get('random_value'));
    $t->Assign('g_file_types', '*.' . str_replace(',', ';*.', Config::Get('upload_extensions')));
    $t->Assign('g_cookie', $_COOKIE[LOGIN_COOKIE]);
    $t->AssignByRef('g_form', $_REQUEST);
    $t->Display('upload-step-two.tpl');
}
Esempio n. 2
0
 public static function add($friend)
 {
     $hosts = preg_split('/\\r\\n|\\r|\\n/', $friend);
     foreach ($hosts as $entry) {
         $entry = explode('=', $entry);
         Blacklist::create(array('user_id' => Auth::user()->id, 'ip' => $entry[0], 'desc' => !empty($entry[1]) ? $entry[1] : 'none'));
     }
     return Redirect::to('/admin/blacklist/overview');
 }
Esempio n. 3
0
 public function get_delete($id = NULL)
 {
     $friend = Blacklist::find($id);
     if (empty($friend)) {
         return View::make('msg.error')->with('error', 'This host doesn\'t exist.');
     }
     $friend->delete();
     return Redirect::to('/admin/blacklist/overview');
 }
Esempio n. 4
0
 public function removeFromBlacklist()
 {
     $required = array('blocked_user_id' => true);
     $blacklist = \Blacklist::model()->findByAttributes(array('user_id' => $this->controller->identity->getId(), 'blocked_user_id' => $this->controller->getParams($required)['blocked_user_id']));
     if (!$blacklist) {
         throw new NotFoundApiException('UserNotFoundInBlacklist');
     }
     $blacklist->delete();
     $this->controller->setMessage('Success');
 }
Esempio n. 5
0
 private static function Load()
 {
     if (!isset(self::$blacklist)) {
         self::$blacklist = array();
         $DB = GetDB();
         $result = $DB->Query('SELECT * FROM `tbx_blacklist`');
         while ($row = $DB->NextRow($result)) {
             if (!$row['regex']) {
                 $row['value'] = preg_quote($row['value'], '~');
             }
             self::$blacklist[] = $row;
         }
     }
 }
Esempio n. 6
0
/**
 * @see inc/RuleCollection::prepareInputDataForProcess()
 * @since 0.84
 * @param $params           input data
 * @return an array of criteria value to add for processing
 **/
function plugin_ocsinventoryng_ruleCollectionPrepareInputDataForProcess($params)
{
    global $PluginOcsinventoryngDBocs;
    switch ($params['rule_itemtype']) {
        case 'RuleImportEntity':
        case 'RuleImportComputer':
            if ($params['rule_itemtype'] == 'RuleImportEntity') {
                $ocsservers_id = $params['values']['input']['ocsservers_id'];
            } else {
                $ocsservers_id = $params['values']['params']['plugin_ocsinventoryng_ocsservers_id'];
            }
            $tables = plugin_ocsinventoryng_getTablesForQuery();
            $fields = plugin_ocsinventoryng_getFieldsForQuery();
            $rule_parameters = array('ocsservers_id' => $ocsservers_id);
            $select_sql = "";
            if (isset($params['values']['params']['ocsid'])) {
                $ocsid = $params['values']['params']['ocsid'];
            } else {
                if ($params['values']['input']['id']) {
                    $ocsid = $params['values']['input']['id'];
                }
            }
            //Get information about network ports
            $query = "SELECT *\n                   FROM `networks`\n                   WHERE `HARDWARE_ID` = '{$ocsid}'";
            $ipblacklist = Blacklist::getIPs();
            $macblacklist = Blacklist::getMACs();
            foreach ($PluginOcsinventoryngDBocs->request($query) as $data) {
                if (isset($data['IPSUBNET'])) {
                    $rule_parameters['IPSUBNET'][] = $data['IPSUBNET'];
                }
                if (isset($data['MACADDR']) && !in_array($data['MACADDR'], $macblacklist)) {
                    $rule_parameters['MACADDRESS'][] = $data['MACADDR'];
                }
                if (isset($data['IPADDRESS']) && !in_array($data['IPADDRESS'], $ipblacklist)) {
                    $rule_parameters['IPADDRESS'][] = $data['IPADDRESS'];
                }
            }
            //Build the select request
            foreach ($fields as $field) {
                switch (Toolbox::strtoupper($field)) {
                    //OCS server ID is provided by extra_params -> get the configuration associated with the ocs server
                    case "OCS_SERVER":
                        $rule_parameters["OCS_SERVER"] = $ocsservers_id;
                        break;
                        //TAG and DOMAIN should come from the OCS DB
                    //TAG and DOMAIN should come from the OCS DB
                    default:
                        $select_sql .= ($select_sql != "" ? " , " : "") . $field;
                }
            }
            //Build the FROM part of the request
            //Remove all the non duplicated table names
            $from_sql = "FROM `hardware` ";
            foreach ($tables as $table => $linkfield) {
                if ($table != 'hardware' && !empty($linkfield)) {
                    $from_sql .= " LEFT JOIN `{$table}` ON (`{$table}`.`{$linkfield}` = `hardware`.`ID`)";
                }
            }
            if ($select_sql != "") {
                //Build the all request
                $sql = "SELECT {$select_sql}\n                    {$from_sql}\n                    WHERE `hardware`.`ID` = '{$ocsid}'";
                PluginOcsinventoryngOcsServer::checkOCSconnection($ocsservers_id);
                $result = $PluginOcsinventoryngDBocs->query($sql);
                $ocs_data = array();
                $fields = plugin_ocsinventoryng_getFieldsForQuery(1);
                //May have more than one line : for example in case of multiple network cards
                if ($PluginOcsinventoryngDBocs->numrows($result) > 0) {
                    while ($datas = $PluginOcsinventoryngDBocs->fetch_assoc($result)) {
                        foreach ($fields as $field) {
                            if ($field != "OCS_SERVER" && isset($datas[$field])) {
                                $ocs_data[$field][] = $datas[$field];
                            }
                        }
                    }
                }
                //This cas should never happend but...
                //Sometimes OCS can't find network ports but fill the right ip in hardware table...
                //So let's use the ip to proceed rules (if IP is a criteria of course)
                if (in_array("IPADDRESS", $fields) && !isset($ocs_data['IPADDRESS'])) {
                    $ocs_data['IPADDRESS'] = PluginOcsinventoryngOcsServer::getGeneralIpAddress($ocsservers_id, $ocsid);
                }
                return array_merge($rule_parameters, $ocs_data);
            }
            return $rule_parameters;
    }
    return array();
}
Esempio n. 7
0
function tbxRegister()
{
    global $t;
    $DB = GetDB();
    $v = Validator::Create();
    $v->Register($_REQUEST['username'], Validator_Type::NOT_EMPTY, _T('Validation:Required', _T('Label:Username')));
    $v->Register($_REQUEST['username'], Validator_Type::IS_ALPHANUM, _T('Validation:Alphanumeric', _T('Label:Username')));
    $v->Register($DB->QueryCount('SELECT COUNT(*) FROM `tbx_user` WHERE `username`=?', array($_REQUEST['username'])), Validator_Type::IS_ZERO, _T('Validation:Username Taken'));
    $v->Register($_REQUEST['password'], Validator_Type::NOT_EMPTY, _T('Validation:Required', _T('Label:Password')));
    $v->Register($_REQUEST['password'], Validator_Type::LENGTH_GREATER_EQ, _T('Validation:Length Greater Equal', _T('Label:Password'), 8), 8);
    $v->Register($_REQUEST['password'], Validator_Type::EQUALS, _T('Validation:Passwords do not match'), $_REQUEST['confirm_password']);
    $v->Register($_REQUEST['email'], Validator_Type::NOT_EMPTY, _T('Validation:Required', _T('Label:E-mail')));
    $v->Register($_REQUEST['email'], Validator_Type::VALID_EMAIL, _T('Validation:E-mail', _T('Label:E-mail')));
    $v->Register($DB->QueryCount('SELECT COUNT(*) FROM `tbx_user` WHERE `email`=?', array($_REQUEST['email'])), Validator_Type::IS_ZERO, _T('Validation:E-mail Taken'));
    $v->Register($_REQUEST['name'], Validator_Type::NOT_EMPTY, _T('Validation:Required', _T('Label:Name')));
    $v->Register(empty($_REQUEST['birth_month']) || empty($_REQUEST['birth_day']) || empty($_REQUEST['birth_year']), Validator_Type::IS_FALSE, _T('Validation:Birthday Required'));
    $v->Register($_REQUEST['gender'], Validator_Type::NOT_EMPTY, _T('Validation:Required', _T('Label:Gender')));
    $v->Register($_REQUEST['terms'], Validator_Type::NOT_EMPTY, _T('Validation:Accept Terms'));
    // Register user-defined field validators
    $schema = GetDBSchema();
    $v->RegisterFromXml($schema->el('//table[name="tbx_user_custom"]'), 'user', 'create');
    // Check blacklist
    $_REQUEST['ip_address'] = $_SERVER['REMOTE_ADDR'];
    if (($match = Blacklist::Match($_REQUEST, Blacklist::ITEM_USER)) !== false) {
        $v->SetError(_T('Validation:Blacklisted', $match['match']));
    }
    // Check CAPTCHA
    if (Config::Get('flag_captcha_on_signup')) {
        Captcha::Verify();
    }
    if (!$v->Validate()) {
        $t->Assign('g_errors', $v->GetErrors());
        $t->Assign('g_form', $_REQUEST);
        return tbxDisplayRegister();
    }
    // Format data
    $_REQUEST['date_birth'] = $_REQUEST['birth_year'] . '-' . $_REQUEST['birth_month'] . '-' . $_REQUEST['birth_day'];
    $_REQUEST['date_created'] = Database_MySQL::Now();
    $_REQUEST['user_level_id'] = $DB->QuerySingleColumn('SELECT `user_level_id` FROM `tbx_user_level` WHERE `is_default`=1');
    $_REQUEST['password'] = sha1($_REQUEST['password']);
    // Strip HTML tags
    if (Config::Get('flag_user_strip_tags')) {
        $_REQUEST = String::StripTags($_REQUEST);
    }
    // Prepare fields for database
    Form_Prepare::Standard('tbx_user');
    Form_Prepare::Standard('tbx_user_stat');
    Form_Prepare::Custom('tbx_user_custom_schema', 'on_submit');
    // Setup account status
    $_REQUEST['status'] = STATUS_ACTIVE;
    $email_template = 'email-user-added.tpl';
    if (Config::Get('flag_user_confirm_email')) {
        $_REQUEST['status'] = STATUS_SUBMITTED;
        $email_template = 'email-user-confirm.tpl';
    } else {
        if (Config::Get('flag_user_approve')) {
            $_REQUEST['status'] = STATUS_PENDING;
            $email_template = 'email-user-pending.tpl';
        }
    }
    // Add data to the database
    DatabaseAdd('tbx_user', $_REQUEST);
    DatabaseAdd('tbx_user_custom', $_REQUEST);
    DatabaseAdd('tbx_user_stat', $_REQUEST);
    if ($_REQUEST['status'] == STATUS_SUBMITTED) {
        $_REQUEST['register_code'] = sha1(uniqid(mt_rand(), true));
        $_REQUEST['timestamp'] = time();
        DatabaseAdd('tbx_user_register_code', $_REQUEST);
        $t->Assign('g_code', $_REQUEST['register_code']);
    }
    $t->AssignByRef('g_user', $_REQUEST);
    $t->AssignByRef('g_form', $_REQUEST);
    // Send e-mail message
    $m = new Mailer();
    $m->Mail($email_template, $t, $_REQUEST['email'], $_REQUEST['name']);
    // Display confirmation
    $t->Display('user-register-complete.tpl');
}
Esempio n. 8
0
<?php

include_once '../../_includes/framework.php';
require_admin();
$page_title = "Admin";
include "_partials/admin-header.php";
$blacklists = Blacklist::all();
?>

<div class="container">
  <div class="col-md-12">
    <h1>Blacklist Entries</h1>
    <table class="table table-striped">
      <tr>
        <th>Badge Name</th>
        <th>Legal Name</th>
        <th>Trigger Badge Names</th>
        <th>Trigger Legal Names</th>
        <th>Reason</th>
        <th>Type</th>
        <th>Actions</th>
      </tr>
      <?php 
foreach ($blacklists as $blacklist) {
    ?>
        <?php 
    $type = BlacklistType::cached_find_by_db_name($blacklist->type);
    ?>
        <tr class="<?php 
    echo $type->alert_color;
    ?>
Esempio n. 9
0
 public function boot($host, $time, $port, $method)
 {
     set_time_limit(800);
     if (!Auth::check()) {
         return View::make('msg.errormn')->with('error', 'You are not logged in.');
     }
     if (Booter::status() == false) {
         return View::make('msg.errormn')->with('error', 'The booter is currently offline, try again later.');
     }
     if (Server::count() == 0) {
         return View::make('msg.errormn')->with('error', 'There are no servers to boot with.');
     }
     if (Auth::user()->hasPlanExpired()) {
         return View::make('msg.errormn')->with('error', 'Your plan has expired.');
     }
     if (empty($host) || !filter_var($host, FILTER_VALIDATE_IP, FILTER_FLAG_IPV4)) {
         return View::make('msg.errormn')->with('error', 'Invalid target IP address.');
     }
     if (Blacklist::where('ip', '=', $host)->count() > 0 || $host == $_SERVER['SERVER_ADDR'] || $host == gethostbyname(gethostname()) || Custblacklist::where('type', '=', 'ip')->where('blacklist', '=', $host)->count() > 0) {
         return View::make('msg.errormn')->with('error', 'This host is blocked from being attacked.');
     }
     if (empty($time) || !is_numeric($time)) {
         return View::make('msg.errormn')->with('error', 'Invalid time.');
     }
     if (empty($port) || !is_numeric($port)) {
         return View::make('msg.errormn')->with('error', 'Invalid port.');
     }
     if ($time > Auth::user()->time) {
         return View::make('msg.errormn')->with('error', 'Your max boot time is ' . Auth::user()->time . ' seconds.');
     }
     if ($time < 1) {
         return View::make('msg.errormn')->with('error', 'Boot for at least 1 second.');
     }
     if ($method != 'stop') {
         if (!Auth::user()->concurrentCheck()) {
             return View::make('msg.errormn')->with('error', 'You already have ' . Auth::user()->concurrent . ' attacks running, you can start your next attack in ' . Auth::user()->secondsToAttackFinish() . ' seconds.');
         }
     }
     //Get all methods
     $settings = parse_ini_file('application/config/config.ini');
     $m = $settings['methods'];
     $m = explode(',', $m);
     for ($i = 0; $i < count($m); $i++) {
         $methods[$i] = $m[$i];
     }
     $methods['stop'] = 'stop';
     if (empty($methods[$method])) {
         return View::make('msg.errormn')->with('error', 'Invalid method.');
     }
     if ($method != 'stop') {
         Attack::create(array('user_id' => Auth::user()->id, 'user_ip' => $_SERVER['REMOTE_ADDR'], 'ip' => $host, 'time' => $time, 'port' => $port, 'method' => strtolower($methods[$method])));
     }
     $mh = curl_multi_init();
     $ch3 = array();
     $cnt = Server::count();
     $servers = Server::all();
     for ($i = 0; $i < $cnt; $i++) {
         $server = $servers[$i];
         $url = $server->url . '?' . $server->host . '=' . $host . '&' . $server->time . '=' . $time . '&' . $server->port . '=' . $port . '&' . $server->method . '=' . strtolower($methods[$method]) . '&' . $server->custom;
         $ch3[$i] = curl_init($url);
         curl_setopt($ch3[$i], CURLOPT_RETURNTRANSFER, 1);
         curl_multi_add_handle($mh, $ch3[$i]);
     }
     $running = NULL;
     do {
         $mrc = curl_multi_exec($mh, $running);
     } while ($running > 0);
     return true;
 }
Esempio n. 10
0
            $image_exists = false;
            $fn = strtolower($product['sku'] . ".jpg");
            if (is_file("{$p1}/{$fn}")) {
                $image_exists = true;
            } else {
                if (is_file("{$p2}/{$fn}")) {
                    $image_exists = true;
                }
            }
            if ($image_exists) {
                $user_id = $product['user_id'];
                $user_role = $db->select('users_in_roles', "`user_id`='{$user_id}'", '*', 1);
                if ($user_role['role_id'] !== 3) {
                    $db->update("products", "approved", 1, $product['id']);
                }
            }
        }
    }
    $unchecked['collections'] = $db->select("collections", "`checked` = '0'");
    $unchecked['products'] = $db->select("products", "`checked` = '0'");
    if ($unchecked['products'] or $unchecked['collections']) {
        $blacklist = new Blacklist();
        $errors = $blacklist->check($unchecked);
        if ($errors) {
            $alerts->display("warning", null, "All collections and their products have been checked against <span class=\\'text-danger\\'>blacklisted</span> words. Please check flagged items on the <span class=\\'text-danger\\'>blacklisted</span> reports page before continuing. Items to ammend:{$errors} <a class=\\'btn btn-default\\' href=\\'blacklist.php\\' role=\\'button\\'>Blacklist Report</a>", null);
        }
    }
    $html->title("Export", "select collection", "left");
    $export->listing();
}
require_once 'footer.php';
Esempio n. 11
0
 /** function buildTicket - Builds,and returns, the major structure of the ticket to be entered.
  *
  * @param $i                  mail ID
  * @param $options   array    of possible options
  *
  * @return ticket fields array
  */
 function buildTicket($i, $options = array())
 {
     global $CFG_GLPI;
     $play_rules = isset($options['play_rules']) && $options['play_rules'];
     $head = $this->getHeaders($i);
     // Get Header Info Return Array Of Headers
     // **Key Are (subject,to,toOth,toNameOth,from,fromName)
     $tkt = array();
     $tkt['_blacklisted'] = false;
     // For RuleTickets
     $tkt['_mailgate'] = $options['mailgates_id'];
     // Use mail date if it's defined
     if ($this->fields['use_mail_date']) {
         $tkt['date'] = $head['date'];
     }
     // Detect if it is a mail reply
     $glpi_message_match = "/GLPI-([0-9]+)\\.[0-9]+\\.[0-9]+@\\w*/";
     // Check if email not send by GLPI : if yes -> blacklist
     if (!isset($head['message_id']) || preg_match($glpi_message_match, $head['message_id'], $match)) {
         $tkt['_blacklisted'] = true;
         return $tkt;
     }
     // manage blacklist
     $blacklisted_emails = Blacklist::getEmails();
     // Add name of the mailcollector as blacklisted
     $blacklisted_emails[] = $this->fields['name'];
     if (Toolbox::inArrayCaseCompare($head['from'], $blacklisted_emails)) {
         $tkt['_blacklisted'] = true;
         return $tkt;
     }
     // max size = 0 : no import attachments
     if ($this->fields['filesize_max'] > 0) {
         if (is_writable(GLPI_TMP_DIR)) {
             $tkt['_filename'] = $this->getAttached($i, GLPI_TMP_DIR . "/", $this->fields['filesize_max']);
             $tkt['_tag'] = $this->tags;
         } else {
             //TRANS: %s is a directory
             Toolbox::logInFile('mailgate', sprintf(__('%s is not writable'), GLPI_TMP_DIR . "/"));
         }
     }
     //  Who is the user ?
     $tkt['_users_id_requester'] = User::getOrImportByEmail($head['from']);
     $tkt["_users_id_requester_notif"]['use_notification'] = 1;
     // Set alternative email if user not found / used if anonymous mail creation is enable
     if (!$tkt['_users_id_requester']) {
         $tkt["_users_id_requester_notif"]['alternative_email'] = $head['from'];
     }
     // Add to and cc as additional observer if user found
     if (count($head['ccs'])) {
         foreach ($head['ccs'] as $cc) {
             if ($cc != $head['from'] && !Toolbox::inArrayCaseCompare($cc, $blacklisted_emails) && ($tmp = User::getOrImportByEmail($cc)) > 0) {
                 $tkt['_additional_observers'][] = array('users_id' => $tmp, 'use_notification' => 1);
             }
         }
     }
     if (count($head['tos'])) {
         foreach ($head['tos'] as $to) {
             if ($to != $head['from'] && !Toolbox::inArrayCaseCompare($to, $blacklisted_emails) && ($tmp = User::getOrImportByEmail($to)) > 0) {
                 $tkt['_additional_observers'][] = array('users_id' => $tmp, 'use_notification' => 1);
             }
         }
     }
     // Auto_import
     $tkt['_auto_import'] = 1;
     // For followup : do not check users_id = login user
     $tkt['_do_not_check_users_id'] = 1;
     $body = $this->getBody($i);
     // Do it before using charset variable
     $head['subject'] = $this->decodeMimeString($head['subject']);
     $tkt['_head'] = $head;
     if (!empty($this->charset) && !$this->body_converted) {
         $body = Toolbox::encodeInUtf8($body, $this->charset);
         $this->body_converted = true;
     }
     if (!Toolbox::seems_utf8($body)) {
         $tkt['content'] = Toolbox::encodeInUtf8($body);
     } else {
         $tkt['content'] = $body;
     }
     // See In-Reply-To field
     if (isset($head['in_reply_to'])) {
         if (preg_match($glpi_message_match, $head['in_reply_to'], $match)) {
             $tkt['tickets_id'] = intval($match[1]);
         }
     }
     // See in References
     if (!isset($tkt['tickets_id']) && isset($head['references'])) {
         if (preg_match($glpi_message_match, $head['references'], $match)) {
             $tkt['tickets_id'] = intval($match[1]);
         }
     }
     // See in title
     if (!isset($tkt['tickets_id']) && preg_match('/\\[.+#(\\d+)\\]/', $head['subject'], $match)) {
         $tkt['tickets_id'] = intval($match[1]);
     }
     $is_html = false;
     //If files are present and content is html
     if (isset($this->files) && count($this->files) && $tkt['content'] != strip_tags($tkt['content']) && !isset($tkt['tickets_id'])) {
         $is_html = true;
         $tkt['content'] = Ticket::convertContentForTicket($tkt['content'], array_merge($this->files, $this->altfiles), $this->tags);
     }
     $tkt['content'] = $this->cleanMailContent($tkt['content']);
     if ($is_html && !isset($tkt['tickets_id'])) {
         $tkt['content'] = nl2br($tkt['content']);
     }
     $tkt['_supplier_email'] = false;
     // Found ticket link
     if (isset($tkt['tickets_id'])) {
         // it's a reply to a previous ticket
         $job = new Ticket();
         $tu = new Ticket_User();
         $st = new Supplier_Ticket();
         // Check if ticket  exists and users_id exists in GLPI
         /// TODO check if users_id have right to add a followup to the ticket
         if ($job->getFromDB($tkt['tickets_id']) && $job->fields['status'] != CommonITILObject::CLOSED && ($CFG_GLPI['use_anonymous_followups'] || $tkt['_users_id_requester'] > 0 || $tu->isAlternateEmailForITILObject($tkt['tickets_id'], $head['from']) || ($tkt['_supplier_email'] = $st->isSupplierEmail($tkt['tickets_id'], $head['from'])))) {
             if ($tkt['_supplier_email']) {
                 $tkt['content'] = sprintf(__('From %s'), $head['from']) . "\n\n" . $tkt['content'];
             }
             $content = explode("\n", $tkt['content']);
             $tkt['content'] = "";
             $to_keep = array();
             // Move requester to author of followup :
             $tkt['users_id'] = $tkt['_users_id_requester'];
             $begin_strip = -1;
             $end_strip = -1;
             $begin_match = "/" . NotificationTargetTicket::HEADERTAG . ".*" . NotificationTargetTicket::HEADERTAG . "/";
             $end_match = "/" . NotificationTargetTicket::FOOTERTAG . ".*" . NotificationTargetTicket::FOOTERTAG . "/";
             foreach ($content as $ID => $val) {
                 // Get first tag for begin
                 if ($begin_strip < 0) {
                     if (preg_match($begin_match, $val)) {
                         $begin_strip = $ID;
                     }
                 }
                 // Get last tag for end
                 if ($begin_strip >= 0) {
                     if (preg_match($end_match, $val)) {
                         $end_strip = $ID;
                         continue;
                     }
                 }
             }
             if ($begin_strip >= 0) {
                 // Clean first and last lines
                 $content[$begin_strip] = preg_replace($begin_match, '', $content[$begin_strip]);
             }
             if ($end_strip >= 0) {
                 // Clean first and last lines
                 $content[$end_strip] = preg_replace($end_match, '', $content[$end_strip]);
             }
             if ($begin_strip >= 0) {
                 $length = count($content);
                 // Use end strip if set
                 if ($end_strip >= 0 && $end_strip < $length) {
                     $length = $end_strip;
                 }
                 for ($i = $begin_strip + 1; $i < $length; $i++) {
                     unset($content[$i]);
                 }
             }
             $to_keep = array();
             // Aditional clean for thunderbird
             foreach ($content as $ID => $val) {
                 if (!isset($val[0]) || $val[0] != '>') {
                     $to_keep[$ID] = $ID;
                 }
             }
             $tkt['content'] = "";
             foreach ($to_keep as $ID) {
                 $tkt['content'] .= $content[$ID] . "\n";
             }
             // Do not play rules for followups : WRONG : play rules only for refuse options
             //$play_rules = false;
         } else {
             // => to handle link in Ticket->post_addItem()
             $tkt['_linkedto'] = $tkt['tickets_id'];
             unset($tkt['tickets_id']);
         }
     }
     // Add message from getAttached
     if ($this->addtobody) {
         $tkt['content'] .= $this->addtobody;
     }
     $tkt['name'] = $this->textCleaner($head['subject']);
     if (!isset($tkt['tickets_id'])) {
         // Which entity ?
         //$tkt['entities_id']=$this->fields['entities_id'];
         //$tkt['Subject']= $head['subject'];   // not use for the moment
         // Medium
         $tkt['urgency'] = "3";
         // No hardware associated
         $tkt['itemtype'] = "";
         // Mail request type
     } else {
         // Reopen if needed
         $tkt['add_reopen'] = 1;
     }
     $tkt['requesttypes_id'] = RequestType::getDefault('mail');
     if ($play_rules) {
         $rule_options['ticket'] = $tkt;
         $rule_options['headers'] = $head;
         $rule_options['mailcollector'] = $options['mailgates_id'];
         $rule_options['_users_id_requester'] = $tkt['_users_id_requester'];
         $rulecollection = new RuleMailCollectorCollection();
         $output = $rulecollection->processAllRules(array(), array(), $rule_options);
         // New ticket : compute all
         if (!isset($tkt['tickets_id'])) {
             foreach ($output as $key => $value) {
                 $tkt[$key] = $value;
             }
         } else {
             // Followup only copy refuse data
             $tobecopied = array('_refuse_email_no_response', '_refuse_email_with_response');
             foreach ($tobecopied as $val) {
                 if (isset($output[$val])) {
                     $tkt[$val] = $output[$val];
                 }
             }
         }
     }
     $tkt = Toolbox::addslashes_deep($tkt);
     return $tkt;
 }
Esempio n. 12
0
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 * 
 * You should have received a copy of the GNU General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>. 
 */
require_once '../../core/init.php';
use T4G\BFP4F\Rcon as rcon;
$sv = new rcon\Server();
header('Content-type: application/json');
// Logs class
$log = new Log($db, $config);
// Whitelist class
$wl = new Whitelist($db, $config);
// Blacklist class
$bl = new Blacklist($db, $config);
// Accounts class
$acc = new Accounts($db, $config);
// Default response template
$response = array('status' => 'ERROR', 'msg' => '');
if ($user->checkLogin()) {
    if ($_SERVER['REQUEST_METHOD'] == 'POST' && isset($_POST['cmd']) && isset($_POST['vars'])) {
        $sv = new rcon\Server();
        $pl = new rcon\Players();
        $ct = new rcon\Chat();
        // Commands
        switch ($_POST['cmd']) {
            /**
             * Add a VIP
             */
            case 'addVip':
Esempio n. 13
0
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 * 
 * You should have received a copy of the GNU General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>. 
 */
require_once '../core/init.php';
$user->checkLogin(true);
// Check his rights
if ($userInfo['rights_blacklist'] == 'no') {
    header('Location: ' . HOME_URL . 'panel/accessDenied.php');
    die;
}
// Fetch the whitelist users
$list = new Blacklist($db, $config);
$bans = $list->fetchList();
// Initialize the Accounts class
$acc = new Accounts($db, $config);
$pageTitle = $lang['tool_bl'];
include CORE_DIR . '/cp_header.php';
?>
			
			<div class="row">
				<div class="col-md-12">
					
					<h2><i class="fa fa-ban"></i> <?php 
echo $lang['tool_bl'];
?>
 <small><?php 
echo $lang['tool_bl_desc'];
Esempio n. 14
0
<?php

/**
 * Created by Kent M. Patrick
 * Project: BPU
 * Company: Fingerprints Ltd
 * Date: 21/09/2016
 * Time: 9:58 AM
 */
require_once 'header.php';
$blacklist = new Blacklist();
$form = new Forms();
if (isset($_POST['submit'])) {
    $words = explode("\r\n", $_POST['words']);
    $blacklist->process($words);
}
if (isset($_GET['page'])) {
    $db->admin_confirm();
    switch ($_GET['page']) {
        case 'add':
            echo "<div id='page-title' class='row'>";
            echo "<div class='col-xs-12 col-sm-6'>";
            $html->title("blacklist", "add words", "left");
            echo "</div>";
            echo "<div class='col-xs-12 col-md-6 text-right'>";
            $html->button("blacklist.php", "back", "default");
            $form->button("save", "md", "blacklist_form");
            echo "</div>";
            echo "</div>";
            $blacklist->form();
            break;
Esempio n. 15
0
 /**
  * cmdBanPlayer()
  * Bans player
  * 
  * @param $cmdInfo - Command info
  * @return array - Status
  */
 public function cmdBanPlayer($cmdInfo)
 {
     $return = array('code' => 'ERROR', 'message' => '');
     if (!empty($cmdInfo['vars']) || $cmdInfo['vars'] != null) {
         $varsSplit = explode(' ', $cmdInfo['vars'], 3);
         if (($varsSplit[0] == '0' || !empty($varsSplit[0])) && is_numeric(trim($varsSplit[0]))) {
             if (isset($varsSplit[1]) && !empty($varsSplit[1])) {
                 $result = $this->findPlayerByName($varsSplit[1]);
                 $reason = isset($varsSplit[2]) ? $varsSplit[2] : (!empty($cmdInfo['_cmd']['cmd_response']) ? $cmdInfo['_cmd']['cmd_response'] : 'Unknown');
                 if ($varsSplit[0] == 0) {
                     $until = '0000-00-00 00:00:00';
                 } else {
                     $until = time() + $varsSplit[0] * 3600;
                     $until = date('Y-m-d H:i:s', $until);
                 }
                 if ($result['code'] == 'OK') {
                     $bl = new Blacklist($this->db, $this->config);
                     $ban = $bl->addBan(0, $result['player']['nucleusId'], $reason, $until);
                     if ($ban == true) {
                         $this->ct->sendPlayer($cmdInfo['origin']['name'], '|ccc| ' . $result['player']['name'] . ' is succesfully banned');
                         $return['code'] = 'OK';
                     } else {
                         $return['message'] = '|ccc| Could not ban the player, probably this player already has a ban';
                     }
                 } else {
                     $return['message'] = $result['message'];
                 }
             } else {
                 $return['message'] = '|ccc| Please specify a player to ban';
             }
         } else {
             $return['message'] = '|ccc| Please specify a amount of hours for how long the ban lasts, 0 = permanent';
         }
     } else {
         $return['message'] = '|ccc| There are missing parameters for this command: {time} {player} {reason}';
     }
     return $return;
 }
Esempio n. 16
0
 function apply_blacklist()
 {
     if (empty($this->badge_name) && empty($this->legal_name)) {
         return;
     }
     list($blacklist, $field, $trigger) = Blacklist::match($this->badge_name, $this->legal_name);
     if ($blacklist) {
         $this->blacklisted = true;
         $this->blacklist_id = $blacklist->id;
         $this->blacklist_trigger = "{$field}:{$trigger}";
         $this->blacklist_type = $blacklist->type;
         $this->blacklist_message = $blacklist->reason;
     } else {
         if ($this->blacklisted && !$this->blacklist_id) {
             // Manual blacklists shouldn't be reset.
             return;
         }
         $this->blacklisted = false;
         $this->blacklist_id = null;
         $this->blacklist_trigger = null;
         $this->blacklist_type = null;
         $this->blacklist_message = null;
     }
 }
Esempio n. 17
0
 $DB = GetDB();
 $video = $DB->Row('SELECT * FROM `tbx_video` WHERE `video_id`=?', array($_REQUEST['video_id']));
 $username = AuthenticateUser::GetUsername();
 $video_id = $_REQUEST['video_id'];
 $comment = $_REQUEST['comment'];
 $max_length = Config::Get('comment_max_length');
 $throttle = Config::Get('comment_throttle_period');
 if (!empty($video)) {
     $v = Validator::Create();
     $v->Register($video['allow_comments'], Validator_Type::NOT_EQUALS, _T('Validation:Comments disabled'), COMMENTS_NO);
     $v->Register($_REQUEST['comment'], Validator_Type::NOT_EMPTY, _T('Validation:Required', _T('Label:Comment')));
     $v->Register($_REQUEST['comment'], Validator_Type::LENGTH_LESS_EQ, _T('Validation:Length too long', _T('Label:Comment'), $max_length), $max_length);
     $v->Register($DB->QueryCount('SELECT COUNT(*) FROM `tbx_video_comment` WHERE `video_id`=? AND `username`=? AND `date_commented`>=DATE_SUB(?, INTERVAL ? SECOND)', array($video_id, $username, Database_MySQL::Now(), $throttle)), Validator_Type::IS_ZERO, _T('Validation:Comment throttle', $throttle));
     // Check blacklist
     $_REQUEST['ip_address'] = $_SERVER['REMOTE_ADDR'];
     if (($match = Blacklist::Match($_REQUEST, Blacklist::ITEM_COMMENT)) !== false) {
         $v->SetError(_T('Validation:Blacklisted', $match['match']));
     }
     // Validate CAPTCHA
     if (Config::Get('flag_captcha_on_comment')) {
         Captcha::Verify();
     }
     if (!$v->Validate()) {
         echo join('<br />', $v->GetErrors());
         return;
     }
     $_REQUEST['username'] = $username;
     $_REQUEST['status'] = $video['allow_comments'] == COMMENTS_APPROVE ? STATUS_PENDING : STATUS_ACTIVE;
     $_REQUEST['date_commented'] = Database_MySQL::Now();
     // Strip HTML tags
     if (Config::Get('flag_comment_strip_tags')) {
Esempio n. 18
0
 * RUN THIS SCRIPT WITH A CRONJOB!
 * RUN THIS SCRIPT WITH A CRONJOB!
 * 
 * Run this script every 30 seconds is recommended.
 */
require_once dirname(dirname(__FILE__)) . '/core/init.php';
use T4G\BFP4F\Rcon as rcon;
if ($rc->connect($cn, $cs) && $rc->init()) {
    /**
     * Initialize the classes and stuff...
     */
    $pl = new rcon\Players();
    $ct = new rcon\Chat();
    $sv = new rcon\Server();
    $it = new Itemlist($db, $config);
    $bl = new Blacklist($db, $config);
    $wl = new WhiteList($db, $config);
    /**
     * LIMITERS
     *
     * NOTE: The blacklist comes first before the whitelist
     */
    /**
     * Fetch the players
     */
    $players = $pl->fetch();
    /**
     * Fetch the itemlist
     */
    $itemList = $it->fetchItems();
    $items = $itemList['items'];
Esempio n. 19
0
if (!isset($_SESSION)) {
    session_start();
}
ini_set("display_errors", "off");
//debug mode
$db_username = "******";
$db_password = "******";
$link = new PDO("mysql:host=newpresenceus.ipagemysql.com;dbname=bb1;", $db_username, $db_password);
require_once "init.php";
define("APP_NAME", "BlueBabble");
define("SLOGAN", "Connect with strangers like yourself");
define("COMPANY", "A&D Softworks");
define("STARTER_BOTTLES", 1000000000);
define("DEBUG_MODE", false);
//debug mode (how obvious, lol)
//classes
require_once "obj/User_class.php";
//is a class
require_once "obj/Message_class.php";
//is a class
require_once "obj/Response_class.php";
//is an object
require_once "obj/Blacklist_class.php";
//is an object
//objects
$response = Response::getInstance();
$blacklist = Blacklist::getInstance();
//facebook SDK
require_once "facebook/facebook.php";
$config = array('appId' => '536887286364414', 'secret' => 'ce61c1a9a7b1e89c87d816cd97e700bb', 'fileUpload' => false, 'allowSignedRequest' => false);
$facebook = new Facebook($config);
Esempio n. 20
0
function tbxGenericShowSearch($type)
{
    Privileges::Check(Privileges::FromType($type));
    if ($type == 'search-term') {
        Blacklist::FilterSearchTerms();
    }
    $schema = GetDBSchema();
    $table = $schema->el('//database/table[naming/type="' . $type . '"]')->name->val();
    include_once 'cp-global-search.php';
}
Esempio n. 21
0
/**
 * @see inc/RuleCollection::prepareInputDataForProcess()
 * @since 0.84
 * @param $params           input data
 * @return an array of criteria value to add for processing
 **/
function plugin_ocsinventoryng_ruleCollectionPrepareInputDataForProcess($params)
{
    switch ($params['rule_itemtype']) {
        case 'RuleImportEntity':
        case 'RuleImportComputer':
            if ($params['rule_itemtype'] == 'RuleImportEntity') {
                $ocsservers_id = $params['values']['input']['ocsservers_id'];
            } else {
                $ocsservers_id = $params['values']['params']['plugin_ocsinventoryng_ocsservers_id'];
            }
            $rule_parameters = array('ocsservers_id' => $ocsservers_id, 'OCS_SERVER' => $ocsservers_id);
            if (isset($params['values']['params']['ocsid'])) {
                $ocsid = $params['values']['params']['ocsid'];
            } else {
                if ($params['values']['input']['id']) {
                    $ocsid = $params['values']['input']['id'];
                }
            }
            $ocsClient = PluginOcsinventoryngOcsServer::getDBocs($ocsservers_id);
            $tables = array_keys(plugin_ocsinventoryng_getTablesForQuery($params['rule_itemtype']));
            $fields = plugin_ocsinventoryng_getFieldsForQuery($params['rule_itemtype']);
            $ocsComputer = $ocsClient->getOcsComputer($ocsid, $tables);
            if (!is_null($ocsComputer)) {
                if (isset($ocsComputer['NETWORKS'])) {
                    $networks = $ocsComputer['NETWORKS'];
                    $ipblacklist = Blacklist::getIPs();
                    $macblacklist = Blacklist::getMACs();
                    foreach ($networks as $data) {
                        if (isset($data['IPSUBNET'])) {
                            $rule_parameters['IPSUBNET'][] = $data['IPSUBNET'];
                        }
                        if (isset($data['MACADDR']) && !in_array($data['MACADDR'], $macblacklist)) {
                            $rule_parameters['MACADDRESS'][] = $data['MACADDR'];
                        }
                        if (isset($data['IPADDRESS']) && !in_array($data['IPADDRESS'], $ipblacklist)) {
                            $rule_parameters['IPADDRESS'][] = $data['IPADDRESS'];
                        }
                    }
                }
                $ocs_data = array();
                foreach ($fields as $field) {
                    // TODO cleaner way of getting fields
                    $field = explode('.', $field);
                    if (count($field) < 2) {
                        continue;
                    }
                    $table = strtoupper($field[0]);
                    $fieldSql = explode(' ', $field[1]);
                    $ocsField = $fieldSql[0];
                    $glpiField = $fieldSql[count($fieldSql) - 1];
                    $section = array();
                    if (isset($ocsComputer[$table])) {
                        $section = $ocsComputer[$table];
                    }
                    if (array_key_exists($ocsField, $section)) {
                        // Not multi
                        $ocs_data[$glpiField][] = $section[$ocsField];
                    } else {
                        foreach ($section as $sectionLine) {
                            $ocs_data[$glpiField][] = $sectionLine[$ocsField];
                        }
                    }
                }
                //This case should never happend but...
                //Sometimes OCS can't find network ports but fill the right ip in hardware table...
                //So let's use the ip to proceed rules (if IP is a criteria of course)
                if (in_array("IPADDRESS", $fields) && !isset($ocs_data['IPADDRESS'])) {
                    $ocs_data['IPADDRESS'] = PluginOcsinventoryngOcsServer::getGeneralIpAddress($ocsservers_id, $ocsid);
                }
                return array_merge($rule_parameters, $ocs_data);
            }
    }
    return array();
}
 /**
  * Display a list of computers to add or to link
  *
  * @param $serverId
  * @param display $advanced
  * @param indicates $check
  * @param display $start
  * @param a|int $entity
  * @param bool|false $tolinked
  * @internal param the $plugin_ocsinventoryng_ocsservers_id ID of the ocs server
  * @internal param display $advanced detail about the computer import or not (target entity, matched rules, etc.)
  * @internal param indicates $check if checkboxes are checked or not
  * @internal param display $start a list of computers starting at rowX
  * @internal param a $entity list of entities in which computers can be added or linked
  * @internal param false $tolinked for an import, true for a link
  *
  * @return bool
  */
 static function showComputersToAdd($serverId, $advanced, $check, $start, $entity = 0, $tolinked = false)
 {
     global $DB, $CFG_GLPI;
     if (!Session::haveRight("plugin_ocsinventoryng", UPDATE)) {
         return false;
     }
     $title = __('Import new computers', 'ocsinventoryng');
     if ($tolinked) {
         $title = __('Link new OCSNG computers to existing GLPI computers', 'ocsinventoryng');
     }
     $target = $CFG_GLPI['root_doc'] . '/plugins/ocsinventoryng/front/ocsng.import.php';
     if ($tolinked) {
         $target = $CFG_GLPI['root_doc'] . '/plugins/ocsinventoryng/front/ocsng.link.php';
     }
     // Get all links between glpi and OCS
     $query_glpi = "SELECT ocsid\n                     FROM `glpi_plugin_ocsinventoryng_ocslinks`\n                     WHERE `plugin_ocsinventoryng_ocsservers_id` = '{$serverId}'";
     $result_glpi = $DB->query($query_glpi);
     $already_linked = array();
     if ($DB->numrows($result_glpi) > 0) {
         while ($data = $DB->fetch_array($result_glpi)) {
             $already_linked[] = $data["ocsid"];
         }
     }
     $cfg_ocs = self::getConfig($serverId);
     $computerOptions = array('ORDER' => 'LASTDATE', 'COMPLETE' => '0', 'DISPLAY' => array('CHECKSUM' => PluginOcsinventoryngOcsClient::CHECKSUM_BIOS | PluginOcsinventoryngOcsClient::CHECKSUM_NETWORK_ADAPTERS), 'ORDER' => 'NAME');
     if ($cfg_ocs["tag_limit"] and $tag_limit = explode("\$", trim($cfg_ocs["tag_limit"]))) {
         $computerOptions['FILTER']['TAGS'] = $tag_limit;
     }
     if ($cfg_ocs["tag_exclude"] and $tag_exclude = explode("\$", trim($cfg_ocs["tag_exclude"]))) {
         $computerOptions['FILTER']['EXCLUDE_TAGS'] = $tag_exclude;
     }
     $ocsClient = self::getDBocs($serverId);
     $ocsResult = $ocsClient->getComputers($computerOptions);
     $computerlink = array();
     if (isset($ocsResult['COMPUTERS'])) {
         if (count($ocsResult['COMPUTERS'])) {
             foreach ($ocsResult['COMPUTERS'] as $comp) {
                 if (!in_array($comp['META']['ID'], $already_linked)) {
                     $computerlink[] = $comp;
                 }
             }
             $computers = array_slice($computerlink, $start, $_SESSION['glpilist_limit']);
         }
     }
     $hardware = array();
     if (isset($computers)) {
         if (count($computers)) {
             // Get all hardware from OCS DB
             foreach ($computers as $data) {
                 $data = Toolbox::clean_cross_side_scripting_deep(Toolbox::addslashes_deep($data));
                 $id = $data['META']['ID'];
                 $hardware[$id]["date"] = $data['META']["LASTDATE"];
                 $hardware[$id]["name"] = $data['META']["NAME"];
                 $hardware[$id]["TAG"] = $data['META']["TAG"];
                 $hardware[$id]["id"] = $data['META']["ID"];
                 $hardware[$id]["UUID"] = $data['META']["UUID"];
                 $contact = $data['META']["USERID"];
                 if (!empty($contact)) {
                     $query = "SELECT `id`\n                            FROM `glpi_users`\n                            WHERE `name` = '" . $contact . "';";
                     $result = $DB->query($query);
                     $hardware[$id]["locations_id"] = 0;
                     if ($DB->numrows($result) == 1) {
                         $user_id = $DB->result($result, 0, 0);
                         $user = new User();
                         $user->getFromDB($user_id);
                         $hardware[$id]["locations_id"] = $user->fields["locations_id"];
                     }
                 }
                 if (isset($data['BIOS']) && count($data['BIOS'])) {
                     $hardware[$id]["serial"] = $data['BIOS']["SSN"];
                     $hardware[$id]["model"] = $data['BIOS']["SMODEL"];
                     $hardware[$id]["manufacturer"] = $data['BIOS']["SMANUFACTURER"];
                 } else {
                     $hardware[$id]["serial"] = '';
                     $hardware[$id]["model"] = '';
                     $hardware[$id]["manufacturer"] = '';
                 }
                 if (isset($data['NETWORKS']) && count($data['NETWORKS'])) {
                     $hardware[$id]["NETWORKS"] = $data["NETWORKS"];
                 }
             }
             if ($tolinked && count($hardware)) {
                 echo "<div class='center b'>" . __('Caution! The imported data (see your configuration) will overwrite the existing one', 'ocsinventoryng') . "</div>";
             }
             echo "<div class='center'>";
             if ($numrows = count($computerlink)) {
                 $parameters = "check={$check}";
                 Html::printPager($start, $numrows, $target, $parameters);
                 //Show preview form only in import even in multi-entity mode because computer import
                 //can be refused by a rule
                 if (!$tolinked) {
                     echo "<div class='firstbloc'>";
                     echo "<form method='post' name='ocsng_import_mode' id='ocsng_import_mode'\n                         action='{$target}'>\n";
                     echo "<table class='tab_cadre_fixe'>";
                     echo "<tr><th>" . __('Manual import mode', 'ocsinventoryng') . "</th></tr>\n";
                     echo "<tr class='tab_bg_1'><td class='center'>";
                     if ($advanced) {
                         Html::showSimpleForm($target, 'change_import_mode', __('Disable preview', 'ocsinventoryng'), array('id' => 'false'));
                     } else {
                         Html::showSimpleForm($target, 'change_import_mode', __('Enable preview', 'ocsinventoryng'), array('id' => 'true'));
                     }
                     echo "</td></tr>";
                     echo "<tr class='tab_bg_1'><td class='center b'>" . __('Check first that duplicates have been correctly managed in OCSNG', 'ocsinventoryng') . "</td>";
                     echo "</tr></table>";
                     Html::closeForm();
                     echo "</div>";
                 }
                 echo "<form method='post' name='ocsng_form' id='ocsng_form' action='{$target}'>";
                 if (!$tolinked) {
                     self::checkBox($target);
                 }
                 echo "<table class='tab_cadre_fixe'>";
                 echo "<tr class='tab_bg_1'><td colspan='" . ($advanced || $tolinked ? 10 : 7) . "' class='center'>";
                 echo "<input class='submit' type='submit' name='import_ok' value=\"" . _sx('button', 'Import', 'ocsinventoryng') . "\">";
                 echo "</td></tr>\n";
                 echo "<tr><th>" . __('Name') . "</th>\n";
                 echo "<th>" . __('Manufacturer') . "</th>\n";
                 echo "<th>" . __('Model') . "</th>\n";
                 echo "<th>" . _n('Information', 'Informations', 2) . "</th>\n";
                 echo "<th>" . __('Date') . "</th>\n";
                 echo "<th>" . __('OCSNG TAG', 'ocsinventoryng') . "</th>\n";
                 if ($advanced && !$tolinked) {
                     echo "<th>" . __('Match the rule ?', 'ocsinventoryng') . "</th>\n";
                     echo "<th>" . __('Destination entity') . "</th>\n";
                     echo "<th>" . __('Target location', 'ocsinventoryng') . "</th>\n";
                 }
                 echo "<th width='20%'>&nbsp;</th></tr>\n";
                 $rule = new RuleImportEntityCollection();
                 foreach ($hardware as $ID => $tab) {
                     $comp = new Computer();
                     $comp->fields["id"] = $tab["id"];
                     $data = array();
                     if ($advanced && !$tolinked) {
                         $location = isset($tab["locations_id"]) ? $tab["locations_id"] : 0;
                         $data = $rule->processAllRules(array('ocsservers_id' => $serverId, '_source' => 'ocsinventoryng', 'locations_id' => $location), array('locations_id' => $location), array('ocsid' => $tab["id"]));
                     }
                     echo "<tr class='tab_bg_2'><td>" . $tab["name"] . "</td>\n";
                     echo "<td>" . $tab["manufacturer"] . "</td>";
                     echo "<td>" . $tab["model"] . "</td>";
                     echo "<td>";
                     $ssnblacklist = Blacklist::getSerialNumbers();
                     $ok = 1;
                     if (!in_array($tab['serial'], $ssnblacklist)) {
                         printf(__('%1$s : %2$s'), __('Serial number'), $tab["serial"]);
                     } else {
                         echo "<span class='red'>";
                         printf(__('%1$s : %2$s'), __('Blacklisted serial number', 'ocsinventoryng'), $tab["serial"]);
                         echo "</span>";
                         $ok = 0;
                     }
                     $uuidblacklist = Blacklist::getUUIDs();
                     if (!in_array($tab['UUID'], $uuidblacklist)) {
                         echo "<br>";
                         printf(__('%1$s : %2$s'), __('UUID'), $tab["UUID"]);
                     } else {
                         echo "<br>";
                         echo "<span class='red'>";
                         printf(__('%1$s : %2$s'), __('Blacklisted UUID', 'ocsinventoryng'), $tab["UUID"]);
                         echo "</span>";
                         $ok = 0;
                     }
                     if (isset($tab['NETWORKS'])) {
                         $networks = $tab['NETWORKS'];
                         $ipblacklist = Blacklist::getIPs();
                         $macblacklist = Blacklist::getMACs();
                         foreach ($networks as $opt) {
                             if (isset($opt['MACADDR'])) {
                                 if (!in_array($opt['MACADDR'], $macblacklist)) {
                                     echo "<br>";
                                     printf(__('%1$s : %2$s'), __('MAC'), $opt['MACADDR']);
                                 } else {
                                     echo "<br>";
                                     echo "<span class='red'>";
                                     printf(__('%1$s : %2$s'), __('Blacklisted MAC', 'ocsinventoryng'), $opt['MACADDR']);
                                     echo "</span>";
                                     //$ok = 0;
                                 }
                                 if (!in_array($opt['IPADDRESS'], $ipblacklist)) {
                                     echo " - ";
                                     printf(__('%1$s : %2$s'), __('IP'), $opt['IPADDRESS']);
                                 } else {
                                     echo " - ";
                                     echo "<span class='red'>";
                                     printf(__('%1$s : %2$s'), __('Blacklisted IP', 'ocsinventoryng'), $opt['IPADDRESS']);
                                     echo "</span>";
                                     //$ok = 0;
                                 }
                             }
                         }
                     }
                     echo "</td>";
                     echo "<td>" . Html::convDateTime($tab["date"]) . "</td>\n";
                     echo "<td>" . $tab["TAG"] . "</td>\n";
                     if ($advanced && !$tolinked) {
                         if (!isset($data['entities_id']) || $data['entities_id'] == -1) {
                             echo "<td class='center'><img src=\"" . $CFG_GLPI['root_doc'] . "/pics/redbutton.png\"></td>\n";
                             $data['entities_id'] = -1;
                         } else {
                             echo "<td class='center'>";
                             $tmprule = new RuleImportEntity();
                             if ($tmprule->can($data['_ruleid'], READ)) {
                                 echo "<a href='" . $tmprule->getLinkURL() . "'>" . $tmprule->getName() . "</a>";
                             } else {
                                 echo $tmprule->getName();
                             }
                             echo "</td>\n";
                         }
                         echo "<td width='30%'>";
                         $ent = "toimport_entities[" . $tab["id"] . "]";
                         Entity::dropdown(array('name' => $ent, 'value' => $data['entities_id'], 'comments' => 0));
                         echo "</td>\n";
                         echo "<td width='30%'>";
                         if (!isset($data['locations_id'])) {
                             $data['locations_id'] = 0;
                         }
                         $loc = "toimport_locations[" . $tab["id"] . "]";
                         Location::dropdown(array('name' => $loc, 'value' => $data['locations_id'], 'comments' => 0));
                         echo "</td>\n";
                     }
                     echo "<td>";
                     if (!$tolinked) {
                         echo "<input type='checkbox' name='toimport[" . $tab["id"] . "]' " . ($check == "all" ? "checked" : "") . ">";
                     } else {
                         $tab['entities_id'] = $entity;
                         $rulelink = new RuleImportComputerCollection();
                         $rulelink_results = array();
                         $params = array('entities_id' => $entity, 'plugin_ocsinventoryng_ocsservers_id' => $serverId);
                         $rulelink_results = $rulelink->processAllRules(Toolbox::stripslashes_deep($tab), array(), $params);
                         //Look for the computer using automatic link criterias as defined in OCSNG configuration
                         $options = array('name' => "tolink[" . $tab["id"] . "]");
                         $show_dropdown = true;
                         //If the computer is not explicitly refused by a rule
                         if (!isset($rulelink_results['action']) || $rulelink_results['action'] != self::LINK_RESULT_NO_IMPORT && $ok) {
                             if (!empty($rulelink_results['found_computers'])) {
                                 $options['value'] = $rulelink_results['found_computers'][0];
                                 $options['entity'] = $entity;
                             }
                             $options['width'] = "100%";
                             Computer::dropdown($options);
                         } else {
                             echo "<img src='" . $CFG_GLPI['root_doc'] . "/pics/redbutton.png'>";
                         }
                     }
                     echo "</td></tr>\n";
                 }
                 echo "<tr class='tab_bg_1'><td colspan='" . ($advanced || $tolinked ? 10 : 7) . "' class='center'>";
                 echo "<input class='submit' type='submit' name='import_ok' value=\"" . _sx('button', 'Import', 'ocsinventoryng') . "\">\n";
                 echo "<input type=hidden name='plugin_ocsinventoryng_ocsservers_id' " . "value='{$serverId}'>";
                 echo "</td></tr>";
                 echo "</table>\n";
                 Html::closeForm();
                 if (!$tolinked) {
                     self::checkBox($target);
                 }
                 Html::printPager($start, $numrows, $target, $parameters);
             } else {
                 echo "<table class='tab_cadre_fixe'>";
                 echo "<tr><th>" . $title . "</th></tr>\n";
                 echo "<tr class='tab_bg_1'>";
                 echo "<td class='center b'>" . __('No new computer to be imported', 'ocsinventoryng') . "</td></tr>\n";
                 echo "</table>";
                 echo "<br><div class='center'>";
                 echo "<a href='" . $CFG_GLPI["root_doc"] . "/plugins/ocsinventoryng/front/ocsng.php'>";
                 _e('Back');
                 echo "</a>";
                 echo "</div>";
             }
             echo "</div>";
         } else {
             echo "<div class='center'>";
             echo "<table class='tab_cadre_fixe'>";
             echo "<tr><th>" . $title . "</th></tr>\n";
             echo "<tr class='tab_bg_1'>";
             echo "<td class='center b'>" . __('No new computer to be imported', 'ocsinventoryng') . "</td></tr>\n";
             echo "</table></div>";
             echo "<br><div class='center'>";
             echo "<a href='" . $CFG_GLPI["root_doc"] . "/plugins/ocsinventoryng/front/ocsng.php'>";
             _e('Back');
             echo "</a>";
             echo "</div>";
         }
     } else {
         echo "<div class='center'>";
         echo "<table class='tab_cadre_fixe'>";
         echo "<tr><th>" . $title . "</th></tr>\n";
         echo "<tr class='tab_bg_1'>";
         echo "<td class='center b'>" . __('No new computer to be imported', 'ocsinventoryng') . "</td></tr>\n";
         echo "</table></div>";
         echo "<br><div class='center'>";
         echo "<a href='" . $CFG_GLPI["root_doc"] . "/plugins/ocsinventoryng/front/ocsng.php'>";
         _e('Back');
         echo "</a>";
         echo "</div>";
     }
 }