1 00:00:00,600 --> 00:00:06,870 In this lecture, we will create the main page of the control panel. In the main page, 2 00:00:07,110 --> 00:00:13,460 We will be showing all the victims by using HTML tables. To do so, 3 00:00:13,620 --> 00:00:20,430 We will be using query() and fetch_assoc() functions and a while loop in order to retrieve all of the 4 00:00:20,430 --> 00:00:24,120 data from the database if you are new to. 5 00:00:24,160 --> 00:00:31,350 These concepts please learn more about HTML tables and specified functions before continuing. 6 00:00:32,460 --> 00:00:34,590 So let's start coding. 7 00:00:38,190 --> 00:00:46,310 Create a new file called index.php. I know we have already created the file called index.php in the previous 8 00:00:46,320 --> 00:00:49,650 lecture, but I have deleted it by mistake. 9 00:00:49,660 --> 00:01:00,420 So let me create this file again and include session.php because this page will be for authenticated 10 00:01:00,420 --> 00:01:04,620 users only. So inside the index.php 11 00:01:05,800 --> 00:01:08,100 We need to create a table. To do so. 12 00:01:08,970 --> 00:01:10,440 Open your html tag. 13 00:01:12,930 --> 00:01:21,780 We will be using table tag in order to create a table and inside the table tag, 14 00:01:23,030 --> 00:01:34,980 We will be using tr tag in order to create rows and for each row for each row header we will be using 15 00:01:34,980 --> 00:01:42,000 th tag. Our table will have four rows. 16 00:01:42,510 --> 00:01:44,730 First row will be hostname. 17 00:01:46,680 --> 00:01:55,380 And it's header will be the hostname and second role will be used for the IP address and it's header will be IP 18 00:01:55,380 --> 00:02:06,910 address and the third role will be operating system and it's header will be operating system and the forth row 19 00:02:06,930 --> 00:02:09,240 row will be 20 00:02:13,230 --> 00:02:26,730 Action and this row will be used for managing the specified bot in the each row. 21 00:02:30,410 --> 00:02:41,570 So let's check our table by going to localhost slash index.php page, but since we have session control mechanism, 22 00:02:42,230 --> 00:02:43,630 we need to log in first. 23 00:02:43,970 --> 00:02:49,310 So we have already created our control panel user. 24 00:02:49,310 --> 00:02:51,860 So logging it by using it. 25 00:02:56,810 --> 00:03:06,770 As you can see, our headers are here, but they are looking pretty ugly, so let's create a style to 26 00:03:06,770 --> 00:03:09,250 make it look a little bit better. 27 00:03:10,400 --> 00:03:15,900 To do so, create a new tag called style 28 00:03:16,970 --> 00:03:23,990 It's a CSS tag. It is not necessary but I will be doing it anyway because this page is seriously 29 00:03:24,000 --> 00:03:25,050 looking so ugly. 30 00:03:25,070 --> 00:03:27,200 So let's fix it a little bit. 31 00:03:28,530 --> 00:03:33,080 I will create a border for th and td tags. 32 00:03:40,490 --> 00:03:47,110 And it will be solid and 1px. 33 00:03:49,520 --> 00:03:51,070 So let me check again. 34 00:03:53,130 --> 00:04:00,390 Yep, it's a little bit better and also let's move our table in the center by using center tag. 35 00:04:10,570 --> 00:04:20,410 It's still ugly, but it's pretty enough for us, so for the data in each cell, we'll be using TD tag. 36 00:04:20,530 --> 00:04:26,080 But at first you need to retrieve the information from the database. 37 00:04:26,980 --> 00:04:35,940 To do so, we need to include conn.php file because that file has connection variable. 38 00:04:36,190 --> 00:04:42,310 So we will be using this connection variable in order to send SQL queries to our database. 39 00:04:46,100 --> 00:04:48,260 So open the php tag 40 00:04:53,020 --> 00:05:03,220 We need to send a query to our database, so let's create a variable called botQuery, and by using the 41 00:05:03,220 --> 00:05:10,060 MySQL connection variable, we will send the query by using query methods and our query will be 42 00:05:10,480 --> 00:05:12,580 select * from victims. 43 00:05:17,480 --> 00:05:20,600 And for the each row, 44 00:05:23,890 --> 00:05:32,320 We need to retrieve the specified information, hostname IP address, operating system and action 45 00:05:32,320 --> 00:05:32,880 To do so, 46 00:05:33,190 --> 00:05:44,140 We will create a while loop and in the while loop, we will retrieve each row from results. Let's create 47 00:05:44,140 --> 00:05:51,070 a variable called row in order to get the result as an array, 48 00:05:52,330 --> 00:05:56,590 We will be using fetch_assoc() function. 49 00:05:59,040 --> 00:06:11,730 So by using this function in a while loop, we will be retrieving all of the data from results so all 50 00:06:11,730 --> 00:06:15,570 data will be in the row array. 51 00:06:17,880 --> 00:06:24,230 So let's create a variable for the hostname information and our hostname information will be the hostname 52 00:06:24,230 --> 00:06:30,160 index of our row. These indexes are coming from the database. 53 00:06:30,510 --> 00:06:32,160 So let me show it again. 54 00:06:33,180 --> 00:06:35,490 Open a terminal and connect your database. 55 00:06:41,670 --> 00:06:49,880 The indexes are coming from the select table of the control panel database. 56 00:06:49,890 --> 00:06:52,260 Sorry, my terminal is broken. 57 00:06:52,290 --> 00:06:57,240 Now let me open a new terminal and connect the database again. 58 00:07:07,840 --> 00:07:18,490 Our index of the array indexes of the array are coming from the fields of the victims table, so hostname 59 00:07:18,490 --> 00:07:23,020 IP address, operating system, etc., so our operating system 60 00:07:26,440 --> 00:07:39,370 will be equal to the operating system index of the row array and the IP address will be equal to 61 00:07:39,910 --> 00:07:56,050 IP address index of the row array and the action action will be a clickable string that will be used for 62 00:07:56,200 --> 00:08:04,960 directing users to manage page of the specified bot, We will create the manage page in further lectures 63 00:08:04,960 --> 00:08:05,440 further lectures. 64 00:08:05,450 --> 00:08:12,910 So don't mind it just create it. Create a clickable string clickable link. 65 00:08:13,940 --> 00:08:26,440 We will be using a tag of the HTML and by using CRIF attributes we will specify the page that the user 66 00:08:26,440 --> 00:08:37,450 will be redirected to using will be redirected to manage that php page with bot variable and the bot 67 00:08:37,510 --> 00:08:44,140 variable will be equal to hostname of the current row. 68 00:08:46,880 --> 00:08:59,960 So let's close the quote here, because we have opened the quote here, so we need to close it and close 69 00:08:59,960 --> 00:09:00,770 the a tag 70 00:09:04,620 --> 00:09:09,450 And we are done here, I guess. 71 00:09:11,160 --> 00:09:21,180 So we need to print out those informations inside td tags. To do so, we will be using echo function of 72 00:09:21,470 --> 00:09:29,600 php echo open your td tag and append hostname variable next to it 73 00:09:32,640 --> 00:09:37,920 and do it do the same thing for all of the variables. 74 00:09:43,220 --> 00:09:51,920 Operating system variable, I'm sorry, it will be hostname IP address, so second one will be the 75 00:09:51,920 --> 00:09:52,850 IP address. 76 00:09:56,100 --> 00:10:02,520 And the third one will be the operating system and the fourth one will be the action. 77 00:10:06,090 --> 00:10:07,830 And close your table tag 78 00:10:08,130 --> 00:10:09,630 We have already close it here. 79 00:10:11,410 --> 00:10:19,510 And we are done since our database has no records yet, we need to create a sample of record. To do 80 00:10:19,510 --> 00:10:22,360 so, insert data to victims table. 81 00:10:25,860 --> 00:10:37,260 We will be inserting data to id, hostname, ipaddress and operatingsystem fields and our values 82 00:10:37,260 --> 00:10:49,710 will be dummy values a, b, c, I guess we're OK here and let's refresh the page and see if everything's 83 00:10:50,310 --> 00:10:53,760 went well 84 00:10:54,070 --> 00:10:56,160 We have a little problem here. 85 00:10:57,270 --> 00:10:58,200 Because. 86 00:11:00,680 --> 00:11:08,420 The problem is this, we need to move that tr tag to here. 87 00:11:12,790 --> 00:11:19,990 And let's try it again, as you can see, it's working now, but there's a problem with the. 88 00:11:21,890 --> 00:11:29,960 Action variable, so let us fix it first, the problem is here, we didn't give any string to collect 89 00:11:30,470 --> 00:11:34,880 so defined string just before closing the a tag 90 00:11:35,090 --> 00:11:38,510 And I would call it Manage, so. 91 00:11:41,690 --> 00:11:42,830 What's the problem again? 92 00:11:44,560 --> 00:11:45,200 Me check. 93 00:11:47,700 --> 00:11:59,040 Ops, we didn't close this sign, so let's do it first, I forgot it. 94 00:12:00,420 --> 00:12:02,520 I don't remember the name of this sign. 95 00:12:02,530 --> 00:12:13,800 So, um, just close the sign here because you need to first close the quote and then close 96 00:12:13,800 --> 00:12:14,430 this sign. 97 00:12:14,970 --> 00:12:16,480 And it will be okay now. 98 00:12:17,250 --> 00:12:17,630 Yep. 99 00:12:17,640 --> 00:12:26,700 As you can see, it's OK when the user clicks the Manage link, user will be redirected to manage.php and 100 00:12:27,090 --> 00:12:31,710 we will create that manage.php page in the following lectures so don't mind it yet. 101 00:12:32,670 --> 00:12:34,110 So that's it for this lecture. 102 00:12:34,320 --> 00:12:37,050 This page will be the main page of our control panel. 103 00:12:37,830 --> 00:12:39,660 So see you in the next lectures.