Menu

4/10/24

Lab VLAN,SOPHOS ra internet (Mode Trunk)

1.  Kết nối mô hình lab sau với cloud 1 tương tứng pnet1 (Cloud)


2. Các port tương tứng:

Port A: LAN, Port B: WAN. port C: port kết nối PC config:

3. Đặt IP cho các PC (VLAN 20, 30)


VPCS> ip 20.20.20.20/24 20.20.20.254
Checking for duplicate address...
VPCS : 20.20.20.20 255.255.255.0 gateway 20.20.20.254


VPCS>
VPCS> save
Saving startup configuration to startup.vpc
.  done

--------------------------------------------------

VPCS> ip 30.30.30.30/24 30.30.30.254
Checking for duplicate address...
VPCS : 30.30.30.30 255.255.255.0 gateway 30.30.30.254

VPCS> save
Saving startup configuration to startup.vpc
.  done

4. Tạo vlan 20,30 trên sw layer 2, chuyển các port vào vlan tương ứng

Switch(config)#no ip domain-lookup
Switch(config)#vlan 20,30

Switch(config)#int e0/0
Switch(config-if)#switchport mode access
Switch(config-if)#switchport access vlan 20
Switch(config-if)#no shut


Switch(config)#int e0/1
Switch(config-if)#switchport mode access
Switch(config-if)#switchport access vlan 30
Switch(config-if)#no shut





Kết nối internet cho các VM trong Lab eve




1. SSH vào eve, gõ lệnh  sau để đặt ip tĩnh card pnet1: 10.10.10.1/24. 

=> Nhấn ctrl +o để save lại, sau đó nhấn Enter, để thoát lệnh: ctrl +exit

     nano /etc/network/interfaces

2. chạy tiếp lệnh sau để khởi động lại service network

systemctl restart networking

3. mở chế độ forward: 

 nano /etc/sysctl.conf 

-> bỏ dấu # trước lệnh sau đó nhấn ctrl+o để save, enter. và thoát ctrl +exit



4. gõ lệnh sau để nat subnet 10.10.10.0/24 ra pnet0 của EVE:

 iptables -t nat -A POSTROUTING -s 10.10.10.0/24 -o pnet0 -j MASQUERADE




5. Tiến hành đặt IP cho VPC




6. Ping kiểm tra Google DNS: 8.8.8.8





4/9/24

Add sophos Fw to EVE

 Cấu hình fw sophos ver 19.5



1. upload fw lên EVE


2. Chạy lệnh fix permission trong EVE

/opt/unetlab/wrappers/unl_wrapper -a fixpermissions


3. Chỉnh RAM sophos FW lên 4GB (tối thiểu để chạy tốt)


4. Mở trình duyệt web truy cập: https://172.16.16.16:4444 (đặt user/pass: admin/Abc@123456#)






12/11/21

Sử dụng biến toàn cục (Global) kết hợp với bolean xuất message thông báo thông tin đăng nhập sai

 <?php

class AdminController
{
	

	function __construct()
	{
		$GLOBALS['login'] = 0;
		$action = getIndex('action', 'index');

		if (method_exists($this, $action))
			$reflection = new ReflectionMethod($this, $action);
		    if (!$reflection->isPublic()) {
		     echo "Phuong thuc ko phai public!";exit;
		    }
			$this->$action();
		}
		else 
		{
			echo "Chua xay dung...";
			exit;
		}
	}

	function index()
	{

			include 'View/AdminIndex.php';
	}

	function adminlogin()

	{
		
		$u= postIndex('u');
		$p= md5(postIndex('p')) ;
		$m = new UserModel();
		$data = $m->getAdmin($u, $p);
		
		if ($data==false)
		 {	

			if($GLOBALS['login']==0&&$u!=""){
				$message = "sai pass hoac chua dk tai khoan";
				echo "<script type='text/javascript'>alert('$message');</script>";

			}
			
			include 'View/adminlogin.php';
		}
		else
		{
			
			$_SESSION['admin']= $data;
			header('location:index.php?controller=AdminController');
		}
	}

	function adminlogout()
	{
		$GLOBALS['login']=1;
		unset($_SESSION['admin']);
		$this->adminlogin();	
		
	}

	

11/28/21

Quan li loai (crud_database)

 


Cấu trúc thư mục:

Css\style.css

action_add.php

action_delete.php

action_update.php

index.php

add.php

delete.php

update.php

pdo.php

File loai.sql

-- phpMyAdmin SQL Dump
-- version 4.8.3
-- https://www.phpmyadmin.net/
--
-- Host: 127.0.0.1:3306
-- Generation Time: Nov 28, 2021 at 04:41 AM
-- Server version: 5.7.23
-- PHP Version: 7.2.10

SET SQL_MODE = "NO_AUTO_VALUE_ON_ZERO";
SET AUTOCOMMIT = 0;
START TRANSACTION;
SET time_zone = "+00:00";


/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */;
/*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */;
/*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */;
/*!40101 SET NAMES utf8mb4 */;

--
-- Database: `bookstorevn`
--

-- --------------------------------------------------------

--
-- Table structure for table `loai`
--

DROP TABLE IF EXISTS `loai`;
CREATE TABLE IF NOT EXISTS `loai` (
  `maloai` varchar(5) CHARACTER SET utf8 COLLATE utf8_unicode_ci NOT NULL,
  `tenloai` varchar(50) CHARACTER SET utf8 COLLATE utf8_unicode_ci NOT NULL,
  PRIMARY KEY (`maloai`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;

--
-- Dumping data for table `loai`
--

INSERT INTO `loai` (`maloai`, `tenloai`) VALUES
('gk', 'GK'),
('kt', 'Kinh Tế'),
('nn', 'Ngoại Ngữ'),
('pl', 'Pháp Luật'),
('SK', 'SUC KHOE'),
('td', 'Từ Điển'),
('test', 'Loai Moi'),
('th', 'tin hocc'),
('to', 'toan hocs'),
('tt', 'The Thao Du Lich'),
('vh', 'Văn Học'),
('vhxh', 'Van Hoa xa Hoi');
COMMIT;

/*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */;
/*!40101 SET CHARACTER_SET_RESULTS=@OLD_CHARACTER_SET_RESULTS */;
/*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */;

File style.css
		body {
			font:30px arial;
			margin: 30px;
			padding: 10px;
			background: #959393;
		}
		#wrapper{ 
			border: 3px solid black;
			background-color:#9e9e9e;
			height: 500px;
		
		}
		#header{
			background-color:#66917a;
			text-align:center;
			padding: 8px;
			font-size:30px;
		}
		#header h1{
			text-transform: uppercase;
			font-size:30px;
			font-style:italic;
		}
		#menu{
			background-color: blue;
		}
		#menu ul{
			padding: 20px;
			margin: 0px;
			font-weight: bold;
			text-transform: uppercase;

		}
		#menu ul li{
		display: inline-block;
		
		}
		#menu ul li a{
			color: white;
			font-size: 20px;
			padding:8px 10px;
			list-style:none;
			text-decoration: none;
			display: block; 
			transition: all 2s ease;
		}
		#menu ul li a:hover{
			background-color: #4c625678;
		}
		#main-content{

			border: 1px solid yellow;
			min-height: 100px;
			padding: 30px;
			background-color: #efefef;
		}
		#main-content h2{
			text-transform: capitalize;
			padding: 10px;
			font-size: 100px;
		}
		#main-content table{
	
			width: 80%;
    		border: 1px solid black;
    		height: auto;
			
		}
		#main-content th{
			border: 1px solid black;
			background-color: #788f8f;
			text-transform: uppercase;
		}
		#main-content td{
			border: 1px solid black;    
			text-align: center;
			background-color: #e7e7e2;
		}

		#main-content td a{
			font-size: 20px;
			color: white;
			padding: 5px;  
			text-align: center;
			background-color: #e17e21;
			text-transform: uppercase;
			margin: 5px;

		}
		#main-content td a:nth-child(2){
			background-color: red;
		}
		#main-content td a:nth-child(3){
			background-color: #607d8b;
		}

		#main-content .post-form {
			width: 40%;	   
			margin: 0 auto; 
			padding: 30px;
			background-color: #abafafd4;
			border-radius: 10px;
		}
		#main-content .post-form .form-group{
			margin:  0 0 15px;
		}
		#main-content .post-form .form-group label{
				font-size: 30px;
			    display:block;
    			margin: 0 0 12px;
		}
		#main-content .post-form .form-group input{
			font-size:  30px;
		}
		#main-content .post-form .form-group .select{
			font-size: 30px;
		}
		#main-content .post-form .submit{

				    background-color: black;
				    color: white;
				    font-size: 25px;
				    margin-left: 30%;
				    border-radius: 9px;
				    padding: 10px;
		}
File action_add.php

<?php
 
    $o = new PDO('mysql:host=localhost;dbname=bookstorevn','root','');
    $o->query('set names utf8');
    $sql='insert into loai(maloai, tenloai) value(?,?)';
    $stm=$o->prepare($sql);
    $arr=[$_POST['maloai'], $_POST['tenloai']];
    $stm->execute($arr);
    header('location:index.php');
?>

File action_delete.php

<?php
    $o = new PDO('mysql:host=localhost;dbname=bookstorevn','root','');
    $o->query('set names utf8');
    $sql='delete from loai where maloai=?';
    $stm=$o->prepare($sql);
    $arr=[$_POST['maloai']];
    $stm->execute($arr);
    header('location:index.php');
?>

File action_update.php

<?php
    $o = new PDO('mysql:host=localhost;dbname=bookstorevn','root','');
    $o->query('set names utf8');
    $sql='update loai set tenloai=? where maloai=?';
    $stm=$o->prepare($sql);
    $arr=[$_POST['tenloai'], $_POST['maloai']];
    $stm->execute($arr);
    header('location:index.php');
?>

File add.php

<!DOCTYPE html>
<html>
<head>
<title>Add</title>
	<link rel="stylesheet" type="text/css" href="css/style.css">
	<?php include "pdo.php" ; ?>
</head>
<body>
		<div id="header">
			<h1>CRUD</h1>

		</div>
        <div id="menu">
            <ul>
                <li>
                    <a href="index.php">Home</a>
                </li>
                <li>
                    <a href="add.php">Add</a>
                </li>
                <li>
                    <a href="update.php">Update</a>
                </li>
                <li>
                    <a href="delete.php">Delete</a>
                </li>
            </ul>
        </div>
		<div id="main-content">
				<h2>add new record</h2>
		<form class="post-form" method="post" action="action_add.php">
				<div class="form-group">
					<label>Ma Loai</label>
					<input type="text" name="maloai">
				</div>
				<div class="form-group">
					<label>Ten Loai </label>
					<input type="text" name="tenloai" >
				</div>
				
				<div class="form-group">
					<label>Ten Loai Trong DB</label>
					<select class="select">
						<option selected disabled>xem loai</option>
						<option value="1">A</option>
						            <?php 

			            foreach ($data as $key=>$value){
			                 ?>                 
			                                
			                 <option value=""> <?php echo $value["tenloai"]; ?></option>
			                       
			                    
			                 <?php

			            }
			            ?>
					</select>
				</div>
				<input class="submit" type="submit" value="Them" />

		</form>

	</div>

</body>
</html>

File delete.php

<!DOCTYPE html>
<html>
<head>
<title>delete</title>
	<link rel="stylesheet" type="text/css" href="css/style.css">
</head>
<body>
		<div id="header">
			<h1>CRUD</h1>

		</div>
        <div id="menu">
            <ul>
                <li>
                    <a href="index.php">Home</a>
                </li>
                <li>
                    <a href="add.php">Add</a>
                </li>
                <li>
                    <a href="update.php">Update</a>
                </li>
                <li>
                    <a href="delete.php">Delete</a>
                </li>
            </ul>
        </div>
		<div id="main-content">
				<h2>delete record</h2>
		<form class="post-form" method="post" action="action_delete.php">
				<div class="form-group">
					<label>Id</label>
					<input type="text" name="maloai">
				</div>
				<input class="submit" type="submit" value="delete">
		</form>

	</div>

</body>
</html>

File index.php

<!DOCTYPE html>
<html>
<head>
	<title>Page Title</title>
	<link rel="stylesheet"  href="css/style.css">
    <?php include "pdo.php"; ?>
</head>
<body>
		<div id="header">
			<h1>CRUD</h1>

		</div>
        <div id="menu">
            <ul>
                <li>
                    <a href="index.php">Home</a>
                </li>
                <li>
                    <a href="add.php">Add</a>
                </li>
                <li>
                    <a href="update.php">Update</a>
                </li>
                <li>
                    <a href="delete.php">Delete</a>
                </li>
            </ul>
        </div>
		<div id="main-content">
				<h2>all record</h2>
				 <table cellpadding="7px">
        <thead>
        <th>stt</th>
        <th>ma loai</th>
        <th>ten loai</th>
        <th>Action</th>
        </thead>
        <tbody>
     
            <?php 

            foreach ($data as $key=>$value){
                 ?>                 
                    <tr>
                        <td><?php echo $key+1 ?></td>
                        <td><?php echo $value["maloai"]; ?></td>
                        <td><?php echo $value["tenloai"]; ?></td>
                        <td> 
                            <a href="add.php?maloai=<?php echo $value['maloai']; ?>">
                            Add
                            </a>
                            <a href="delete.php?maloai=<?php echo $value['maloai']; ?>">
                            Delete
                            </a>
                             <a href="update.php?maloai=<?php echo $value['maloai']; ?>">
                            Edit
                            </a>
                        </td>
                    </tr>
                 <?php

            }
            ?>
            
        </tbody>
    </table>
		</div>



</body>
</html>

File pdo.php

    <?php
    $o = new PDO('mysql:host=localhost;dbname=bookstorevn','root','');
    $o->query('set names utf8');
    $sql='select * from loai';
    $stm=$o->query($sql);
    $data=$stm->fetchAll(PDO::FETCH_ASSOC);
    ?>
File update
<!DOCTYPE html>
<html>
<head>
<title>update</title>
	<link rel="stylesheet" type="text/css" href="css/style.css">
</head>
<body>
		<div id="header">
			<h1>CRUD</h1>

		</div>
        <div id="menu">
            <ul>
                <li>
                    <a href="index.php">Home</a>
                </li>
                <li>
                    <a href="add.php">Add</a>
                </li>
                <li>
                    <a href="update.php">Update</a>
                </li>
                <li>
                    <a href="delete.php">Delete</a>
                </li>
            </ul>
        </div>
		<div id="main-content">
				<h2>edit record</h2>
		<form class="post-form" method="post" action="action_update.php">
				<div class="form-group">
					<label>Ma Loai</label>
					<input type="text" name="maloai">
				</div>
				
				<div class="form-group">
					<label>Ten Loai </label>
					<input type="text" name="tenloai" >
				</div>
				
				<input class="submit" type="submit" value="Save" />

		</form>

	</div>

</body>
</html>

11/27/21

Project menu Crud (html+css)

 


File style.css

body {
			font:30px arial;
			margin: 30px;
			padding: 10px;
			background: #959393;
		}
		#wrapper{ 
			border: 3px solid black;
			background-color:#9e9e9e;
			height: 500px;
		
		}
		#header{
			background-color:#66917a;
			text-align:center;
			padding: 8px;
			font-size:30px;
		}
		#header h1{
			text-transform: uppercase;
			font-size:30px;
			font-style:italic;
		}
		#menu{
			background-color: blue;
		}
		#menu ul{
			padding: 20px;
			margin: 0px;
			font-weight: bold;
			text-transform: uppercase;

		}
		#menu ul li{
		display: inline-block;
		
		}
		#menu ul li a{
			color: white;
			font-size: 20px;
			padding:8px 10px;
			list-style:none;
			text-decoration: none;
			display: block; 
			transition: all 2s ease;
		}
		#menu ul li a:hover{
			background-color: #4c625678;
		}
		#main-content{

			border: 1px solid yellow;
			min-height: 100px;
			padding: 30px;
			background-color: #efefef;
		}
		#main-content h2{
			text-transform: capitalize;
			padding: 10px;
			font-size: 100px;
		}
		#main-content table{
	
			width: 80%;
    		border: 1px solid black;
    		height: auto;
			
		}
		#main-content th{
			border: 1px solid black;
			background-color: #788f8f;
			text-transform: uppercase;
		}
		#main-content td{
			border: 1px solid black;    
			text-align: center;
			background-color: #e7e7e2;
		}

		#main-content td a{
			font-size: 20px;
			color: white;
			padding: 5px;  
			text-align: center;
			background-color: #e17e21;
			text-transform: uppercase;
		}
		#main-content td a:nth-child(2){
			background-color: red;
		}

		#main-content .post-form {
			width: 40%;	   
			margin: 0 auto; 
			padding: 30px;
			background-color: #abafafd4;
			border-radius: 10px;
		}
		#main-content .post-form .form-group{
			margin:  0 0 15px;
		}
		#main-content .post-form .form-group label{
				font-size: 30px;
			    display:block;
    			width: 30%;
    			margin: 0 0 12px;
		}
		#main-content .post-form .form-group input{
			font-size:  30px;
		}
		#main-content .post-form .form-group .select{
			font-size: 30px;
		}
		#main-content .post-form .submit{

				    background-color: black;
				    color: white;
				    font-size: 25px;
				    margin-left: 30%;
				    border-radius: 9px;
				    padding: 10px;
		}
File add.php

<!DOCTYPE html>
<html>
<head>
<title>Add</title>
	<link rel="stylesheet" type="text/css" href="css/style.css">
</head>
<body>
		<div id="header">
			<h1>CRUD</h1>

		</div>
        <div id="menu">
            <ul>
                <li>
                    <a href="index.php">Home</a>
                </li>
                <li>
                    <a href="add.php">Add</a>
                </li>
                <li>
                    <a href="update.php">Update</a>
                </li>
                <li>
                    <a href="delete.php">Delete</a>
                </li>
            </ul>
        </div>
		<div id="main-content">
				<h2>add new record</h2>
		<form class="post-form" method="get" action="savedata.php">
				<div class="form-group">
					<label>Name</label>
					<input type="text" name="sname">
				</div>
				<div class="form-group">
					<label>Address </label>
					<input type="text" name="saddress" >
				</div>
				<div class="form-group">
					<label>Phone</label>
					<input type="text" name="sphone" />
				</div>
				<div class="form-group">
					<label>Class</label>
					<select class="select" name="class">
						<option selected disabled>Selected Class</option>
						<option value="1">A</option>
						<option value="2">B</option>
						<option value="3">C</option>
					</select>
				</div>
				<input class="submit" type="submit" value="Save" />

		</form>

	</div>

</body>
</html>


File update.php

<!DOCTYPE html>
<html>
<head>
<title>update</title>
	<link rel="stylesheet" type="text/css" href="css/style.css">
</head>
<body>
		<div id="header">
			<h1>CRUD</h1>

		</div>
        <div id="menu">
            <ul>
                <li>
                    <a href="index.php">Home</a>
                </li>
                <li>
                    <a href="add.php">Add</a>
                </li>
                <li>
                    <a href="update.php">Update</a>
                </li>
                <li>
                    <a href="delete.php">Delete</a>
                </li>
            </ul>
        </div>
		<div id="main-content">
				<h2>edit record</h2>
		<form class="post-form" method="get" action="savedata.php">
				<div class="form-group">
					<label>Id</label>
					<input type="text" name="sid">
				</div>
				<input class="submit" type="submit" value="show">
				<div class="form-group">
					<label>Name</label>
					<input type="text" name="sname">
				</div>
				<div class="form-group">
					<label>Address </label>
					<input type="text" name="saddress" >
				</div>
				<div class="form-group">
					<label>Phone</label>
					<input type="text" name="sphone" />
				</div>
				<div class="form-group">
					<select class="select" name="class">
						<option selected disabled>Selected Class</option>
						<option value="1">A</option>
						<option value="2">B</option>
						<option value="3">C</option>
					</select>
				</div>
				<input class="submit" type="submit" value="Save" />

		</form>

	</div>

</body>
</html>

File delete.php

<!DOCTYPE html>
<html>
<head>
<title>delete</title>
	<link rel="stylesheet" type="text/css" href="css/style.css">
</head>
<body>
		<div id="header">
			<h1>CRUD</h1>

		</div>
        <div id="menu">
            <ul>
                <li>
                    <a href="index.php">Home</a>
                </li>
                <li>
                    <a href="add.php">Add</a>
                </li>
                <li>
                    <a href="update.php">Update</a>
                </li>
                <li>
                    <a href="delete.php">Delete</a>
                </li>
            </ul>
        </div>
		<div id="main-content">
				<h2>delete record</h2>
		<form class="post-form" method="get" action="savedata.php">
				<div class="form-group">
					<label>Id</label>
					<input type="text" name="sid">
				</div>
				<input class="submit" type="submit" value="delete">
		</form>

	</div>

</body>
</html>

File index.php

<!DOCTYPE html>
<html>
<head>
	<title>Page Title</title>
	<link rel="stylesheet"  href="css/style.css">
</head>
<body>
		<div id="header">
			<h1>CRUD</h1>

		</div>
        <div id="menu">
            <ul>
                <li>
                    <a href="index.php">Home</a>
                </li>
                <li>
                    <a href="add.php">Add</a>
                </li>
                <li>
                    <a href="update.php">Update</a>
                </li>
                <li>
                    <a href="delete.php">Delete</a>
                </li>
            </ul>
        </div>
		<div id="main-content">
				<h2>all record</h2>
				 <table cellpadding="7px">
        <thead>
        <th>Id</th>
        <th>Name</th>
        <th>Address</th>
        <th>Class</th>
        <th>Phone</th>
        <th>Action</th>
        </thead>
        <tbody>
            <tr>
                <td>1</td>
                <td>Ramesh</td>
                <td>Delhi</td>
                <td>BCA</td>
                <td>9876543210</td>
                <td>
                    <a href='edit.php'>Edit</a>
                    <a href='delete-inline.php'>Delete</a>
                </td>
            </tr>
            <tr>
                <td>2</td>
                <td>Suresh</td>
                <td>Punjab</td>
                <td>BCOM</td>
                <td>9876543210</td>
                <td>
                    <a href='edit.php'>Edit</a>
                    <a href='delete-inline.php'>Delete</a>
                </td>
            </tr>
            <tr>
                <td>3</td>
                <td>Suresh</td>
                <td>Haryana</td>
                <td>BSC</td>
                <td>9876543210</td>
                <td>
                    <a href='edit.php'>Edit</a>
                    <a href='delete-inline.php'>Delete</a>
                </td>
            </tr>
            <tr>
                <td>4</td>
                <td>Krishna</td>
                <td>Gujrat</td>
                <td>BCA</td>
                <td>9876543210</td>
                <td>
                    <a href='edit.php'>Edit</a>
                    <a href='delete-inline.php'>Delete</a>
                </td>
            </tr>
            <tr>
                <td>5</td>
                <td>Rohit</td>
                <td>Delhi</td>
                <td>BCA</td>
                <td>9876543210</td>
                <td>
                    <a href='edit.php'>Edit</a>
                    <a href='delete-inline.php'>Delete</a>
                </td>
            </tr>
        </tbody>
    </table>
		</div>



</body>
</html>