public function testSanitize() { $r = new Router($this->container); $this->assertEquals('plop', $r->sanitize('PloP', 'default')); $this->assertEquals('default', $r->sanitize('', 'default')); $this->assertEquals('default', $r->sanitize('123-AB', 'default')); $this->assertEquals('default', $r->sanitize('R&D', 'default')); $this->assertEquals('default', $r->sanitize('Test123', 'default')); }
/** * Renders the main content of the captures info inside the rest of the page * * @see \App\Common\Views\appView::renderContent() */ protected function renderContent() { /* Captures table */ $this->pLine('<div class="row">'); $this->pLine('<div class="col-md-8">', 1); /* Toolbar of the table */ $this->pLine('<div id="toolbar">', 1); $this->pLine('<label><input type="radio" id="allCaptures" name="typeCapture" value="all" checked>' . _('All') . '</label>', 1); $this->pLine('<label><input type="radio" id="simpleCaptures" name="typeCapture" value="simple">' . _('Simple') . '</label>'); $this->pLine('<label><input type="radio" id="pcapCaptures" name="typeCapture" value="pcap">' . _('Pcap') . '</label>'); $this->pLine('<label><input type="checkbox" id="autoRefresh">' . _('Auto Refresh') . '</label>'); $this->pLine('</div>', -1); $this->pLine('<div class="table-responsive">'); $this->pLine('<table id="tableCaptures"', 1); $this->pLine(' class="table"'); $this->pLine(' data-toggle="table"'); $this->pLine(' data-height="500"'); $this->pLine(' data-search="true"'); $this->pLine(' data-show-refresh="true"'); $this->pLine(' data-toolbar="#toolbar"'); $this->pLine(' style="cursor: pointer">'); $this->pLine('<thead>', 1); $this->pLine('<tr>', 1); $this->pLine('<th data-field="name" data-sortable="true">' . _('Name') . '</th>', 1); $this->pLine('<th data-field="type" data-sortable="true">' . _('Type') . '</th>'); $this->pLine('<th data-field="size" data-sortable="true">' . _('Size') . '</th>'); $this->pLine('<th data-field="date" data-sortable="true">' . _('Date') . '</th>'); $this->pLine('</tr>', -1); $this->pLine('</thead>', -1); $this->pLine('</table>', -1); $this->pLine('</div>', -1); $this->pLine('</div>', -1); /* Right action menu */ $this->pLine('<div class="col-md-4">'); /* Selected capture */ $this->pLine('<div id="captureNamePanel" class="panel panel-info">', 1); $this->pLine('<div class="panel-heading">', 1); $this->pLine('<h3 id="captureName" class="panel-title">' . _('Select a capture from the table') . '</h3>', 1); $this->pLine('</div>', -1); $this->pLine('</div>', -1); /* Convert panel */ $this->pLine('<div class="panel panel-default">'); $this->pLine('<div class="panel-heading">', 1); $this->pLine('<h3 class="panel-title">' . _('Convert') . '</h3>', 1); $this->pLine('</div>', -1); $this->pLine('<div class="panel-body">'); $this->pLine('<div id="convertInputFeedback" class="input-group has-feedback">', 1); $this->pLine('<input type="text" class="form-control" placeholder="' . _('Converted name') . '" id="convertedName" name="convertedName">', 1); $this->pLine('<span class="input-group-btn">'); $this->pLine('<button class="btn btn-default" type="button" id="convertOK" name="convertOK">', 1); $this->pLine(_('OK'), 1); $this->pLine('</button>', -1); $this->pLine('</span>', -1); $this->pLine('</div>', -1); $this->pLine('</div>', -1); $this->pLine('</div>', -1); /* Rename panel */ $this->pLine('<div class="panel panel-default">'); $this->pLine('<div class="panel-heading">', 1); $this->pLine('<h3 class="panel-title">' . _('Rename') . '</h3>', 1); $this->pLine('</div>', -1); $this->pLine('<div class="panel-body">'); $this->pLine('<div id="renameInputFeedback" class="input-group has-feedback">', 1); $this->pLine('<input type="text" class="form-control has-feedback" placeholder="' . _('New name') . '" id="newName">', 1); $this->pLine('<span class="input-group-btn">'); $this->pLine('<button class="btn btn-default" type="button" id="renameOK">', 1); $this->pLine(_('OK'), 1); $this->pLine('</button>', -1); $this->pLine('</span>', -1); $this->pLine('</div>', -1); $this->pLine('</div>', -1); $this->pLine('</div>', -1); /* Delete panel */ $this->pLine('<div class="panel panel-danger">'); $this->pLine('<div class="panel-heading" data-toggle="collapse" data-target="#deletePanel" id="deleteBox">', 1); $this->pLine('<h3 class="panel-title" style="cursor: pointer">' . _('Delete') . '</h3>', 1); $this->pLine('</div>', -1); $this->pLine('<div class="panel-body collapse" id="deletePanel">'); $this->pLine('<button type="button" class="btn btn-danger pull-right" id="deleteCapture" data-toggle="modal" data-target="#confirmDeleteModal">', 1); $this->pLine(_('Delete this capture (permanently)'), 1); $this->pLine('</button>', -1); $this->pLine('</div>', -1); $this->pLine('</div>', -1); $this->pLine('</div>', -1); $this->pLine('</div>', -1); /* Lower panel with info about adding external captures */ $this->pLine('<div class="row"> </div>'); $this->pLine('<div class="row">'); $this->pLine('<div class="col-md-8">', 1); $this->pLine('<div class="panel panel-info">', 1); $this->pLine('<div class="panel-body">', 1); $this->pLine(_('Add additional captures generated outside NetWatcher by copying the capture file (or adding symbolic link to it) to the captures directory on the FPGA remote server') . '.<br>', 1); $this->pLine('<code id="pathCaptures">' . \Core\Router::sanitize('scp <capture_name> <user>@<FPGA_server>:' . $this->model->capturesFolder) . '</code>'); $this->pLine('</div>', -1); $this->pLine('</div>', -1); $this->pLine('</div>', -1); $this->pLine('</div>', -1); }
/** * Renders the main content of the page inside the rest of the page * * @see \App\Common\Views\appView::renderContent() */ protected function renderContent() { /* Form for settings */ $this->pLine('<form class="form-horizontal" role="form" action="settings/save" method="post">'); /* Server settings */ $this->pLine('<div class="row">', 1); $this->pLine('<div class="col-md-4">', 1); $this->pLine('<h3 class="pull-right">' . _('Server Settings') . '</h3>', 1); $this->pLine('</div>', -1); $this->pLine('</div>', -1); $this->pLine('<div class="row">'); $this->pLine('<div class="col-md-8 col-md-offset-2">', 1); $this->pLine('<hr>', 1); $this->pLine('</div>', -1); $this->pLine('</div>', -1); $this->pLine('<div class="form-group has-feedback" id="serverIpForm">'); $this->pLine('<label for="serverIp" class="col-sm-4 control-label">' . _('FPGA API base address') . '</label>', 1); $this->pLine('<div class="col-sm-6">'); $this->pLine('<input type="text" class="form-control" name="serverIp" id="serverIp" value="' . \Core\Router::sanitize(\Core\Config::$REMOTE_SERVER_IP) . '">', 1); $this->pLine('<span class="glyphicon form-control-feedback" id="ipIcon" aria-hidden="true"></span>'); $this->pLine('</div>', -1); $this->pLine('</div>', -1); /* App settings */ /* Language */ $this->pLine('<div class="row">'); $this->pLine('<div class="col-md-4">', 1); $this->pLine('<h3 class="pull-right">' . _('App Settings') . '</h3>', 1); $this->pLine('</div>', -1); $this->pLine('</div>', -1); $this->pLine('<div class="row">'); $this->pLine('<div class="col-md-8 col-md-offset-2">', 1); $this->pLine('<hr>', 1); $this->pLine('</div>', -1); $this->pLine('</div>', -1); $this->pLine('<div class="form-group">'); $this->pLine('<label for="language" class="col-sm-4 control-label">' . _('Language') . '</label>', 1); $this->pLine('<div class="col-sm-6">'); $this->pLine('<select class="form-control custom" name="language" id="language">', 1); $this->moveIndent(1); foreach (\Core\Config::$LANGUAGES as $text => $lang) { if ($text == \Core\Config::$DEFAULT_LANG) { $this->pLine('<option value="' . $text . '" selected>' . $text . '</option>'); } else { $this->pLine('<option value="' . $text . '">' . $text . '</option>'); } } $this->pLine('</select>', -1); $this->pLine('</div>', -1); $this->pLine('</div>', -1); /* Theme */ $this->pLine('<div class="form-group">'); $this->pLine('<label for="theme" class="col-sm-4 control-label">' . _('Theme') . '</label>', 1); $this->pLine('<div class="col-sm-6">'); $this->pLine('<select class="form-control custom" name="theme" id="theme">', 1); $this->moveIndent(1); foreach (\Core\Config::$CSS_THEMES as $text => $theme) { if ($text == \Core\Config::$DEFAULT_CSS_THEME) { $this->pLine('<option value="' . $text . '" selected>' . $text . '</option>'); } else { $this->pLine('<option value="' . $text . '">' . $text . '</option>'); } } $this->pLine('</select>', -1); $this->pLine('</div>', -1); $this->pLine('</div>', -1); /* Save button */ $this->pLine('<div class="form-group">'); $this->pLine('<div class="col-sm-offset-8 col-sm-2">', 1); $this->pLine('<button type="submit" class="btn btn-primary pull-right">' . _('Save') . '</button>', 1); $this->pLine('</div>', -1); $this->pLine('</div>', -1); $this->pLine('</form>', -1); }