In this lecture, we will create the main page of the control panel. In the main page,
We will be showing all the victims by using HTML tables. To do so,
We will be using query() and fetch_assoc() functions and a while loop in order to retrieve all of the
data from the database if you are new to.
These concepts please learn more about HTML tables and specified functions before continuing.
So let's start coding.
Create a new file called index.php. I know we have already created the file called index.php in the previous
lecture, but I have deleted it by mistake.
So let me create this file again and include session.php because this page will be for authenticated
users only. So inside the index.php
We need to create a table. To do so.
Open your html tag.
We will be using table tag in order to create a table and inside the table tag,
We will be using tr tag in order to create rows and for each row for each row header we will be using
th tag. Our table will have four rows.
First row will be hostname.
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
address and the third role will be operating system and it's header will be operating system and the forth row
row will be
Action and this row will be used for managing the specified bot in the each row.
So let's check our table by going to localhost slash index.php page, but since we have session control mechanism,
we need to log in first.
So we have already created our control panel user.
So logging it by using it.
As you can see, our headers are here, but they are looking pretty ugly, so let's create a style to
make it look a little bit better.
To do so, create a new tag called style
It's a CSS tag. It is not necessary but I will be doing it anyway because this page is seriously
looking so ugly.
So let's fix it a little bit.
I will create a border for th and td tags.
And it will be solid and 1px.
So let me check again.
Yep, it's a little bit better and also let's move our table in the center by using center tag.
It's still ugly, but it's pretty enough for us, so for the data in each cell, we'll be using TD tag.
But at first you need to retrieve the information from the database.
To do so, we need to include conn.php file because that file has connection variable.
So we will be using this connection variable in order to send SQL queries to our database.
So open the php tag
We need to send a query to our database, so let's create a variable called botQuery, and by using the
MySQL connection variable, we will send the query by using query methods and our query will be
select * from victims.
And for the each row,
We need to retrieve the specified information, hostname IP address, operating system and action
To do so,
We will create a while loop and in the while loop, we will retrieve each row from results. Let's create
a variable called row in order to get the result as an array,
We will be using fetch_assoc() function.
So by using this function in a while loop, we will be retrieving all of the data from results so all
data will be in the row array.
So let's create a variable for the hostname information and our hostname information will be the hostname
index of our row. These indexes are coming from the database.
So let me show it again.
Open a terminal and connect your database.
The indexes are coming from the select table of the control panel database.
Sorry, my terminal is broken.
Now let me open a new terminal and connect the database again.
Our index of the array indexes of the array are coming from the fields of the victims table, so hostname
IP address, operating system, etc., so our operating system
will be equal to the operating system index of the row array and the IP address will be equal to
IP address index of the row array and the action action will be a clickable string that will be used for
directing users to manage page of the specified bot, We will create the manage page in further lectures
further lectures.
So don't mind it just create it. Create a clickable string clickable link.
We will be using a tag of the HTML and by using CRIF attributes we will specify the page that the user
will be redirected to using will be redirected to manage that php page with bot variable and the bot
variable will be equal to hostname of the current row.
So let's close the quote here, because we have opened the quote here, so we need to close it and close
the a tag
And we are done here, I guess.
So we need to print out those informations inside td tags. To do so, we will be using echo function of
php echo open your td tag and append hostname variable next to it
and do it do the same thing for all of the variables.
Operating system variable, I'm sorry, it will be hostname IP address, so second one will be the
IP address.
And the third one will be the operating system and the fourth one will be the action.
And close your table tag
We have already close it here.
And we are done since our database has no records yet, we need to create a sample of record. To do
so, insert data to victims table.
We will be inserting data to id, hostname, ipaddress and operatingsystem fields and our values
will be dummy values a, b, c, I guess we're OK here and let's refresh the page and see if everything's
went well
We have a little problem here.
Because.
The problem is this, we need to move that tr tag to here.
And let's try it again, as you can see, it's working now, but there's a problem with the.
Action variable, so let us fix it first, the problem is here, we didn't give any string to collect
so defined string just before closing the a tag
And I would call it Manage, so.
What's the problem again?
Me check.
Ops, we didn't close this sign, so let's do it first, I forgot it.
I don't remember the name of this sign.
So, um, just close the sign here because you need to first close the quote and then close
this sign.
And it will be okay now.
Yep.
As you can see, it's OK when the user clicks the Manage link, user will be redirected to manage.php and
we will create that manage.php page in the following lectures so don't mind it yet.
So that's it for this lecture.
This page will be the main page of our control panel.
So see you in the next lectures.