Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
69 changes: 69 additions & 0 deletions luka_ergemlidze/gitex.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
.page {
background-color: rgb(187, 190, 223) ;
}

.startercontainer {
width: 250px;
height: 250px;
background-color: lawngreen;
border-radius: 5%;
border: 1px solid rgb(33, 77, 99);
margin: auto;
}

.username {
padding: 9px;
margin-top: 20%;
background-color: black;
border: none;
color: white;
font-size: large;
}

.username:hover {
background-color: white;
color: black;
}

.submit {
padding: 10px;
margin-top: 20%;
margin-left: 30%;
background-color: brown;
font-size: x-large;
}

.submit:hover{
background-color: yellow;
color: green;
}

.maintxt {
margin: auto;
text-align: center;
font-size: 4vw;
}

.sectxt {
margin: auto;
text-align: center;
font-size: x-small;
}

/* second page */


table, th, td {
border: 1px solid gold;
border-collapse: collapse;
}

.noninfodiv {
margin: auto;
}

.noninfo {
text-decoration: underline;
margin-left: 450px;
margin-top: 500px;
}
75 changes: 75 additions & 0 deletions luka_ergemlidze/gitex.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
<!DOCTYPE html>
<html lang = "en">
<head>
<meta charset = "utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Information Page</title>
<link rel="stylesheet" href="/gitex.css">
</head>

<body class = "page">
<?php if (empty($_POST)): ?>
<form action="gitex.php" method="POST">
<h1 class = "maintxt">github Nickname</h1><br>
<div class="startercontainer">
<input type="text" name="username" class = "username" placeholder="Nickname">
<input type="submit" class = "submit" name="submit">
</div>

</form>
<?php else: ?>
<?php

$nickname = $_POST['username'];
$urlf = 'https://api.github.com/users/'. $nickname .'/followers';
$urlr = 'https://api.github.com/users/'. $nickname .'/repos';

$gituser = array(
'http'=>array(
'method'=>"GET", 'header'=>'user-agent: Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36
(KHTML, like Gecko) Chrome/101.0.4951.54 Safari/537.36')
);
$context = stream_context_create($gituser);

$followers_file = file_get_contents($urlf, false, $context);
$repos_file = file_get_contents($urlr, false, $context);

file_put_contents('followers.json', $followers_file);

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

სალამიი, კოდებს ვათვალიერებდი და მომეწონა შენი კოდი, წამოღების მეთოდი. უბრალოდ ერთი კითხვა გამიჩნდა, ანუ როგორც მიხვდი ინფორმაციის წამოღების მერე data-ს ფაილში ინახავ და მერე ხსნი ხო?

file_put_contents('repos.json', $repos_file);

$json_followers = file_get_contents('followers.json');
$json_followers_data = json_decode($json_followers,true);

$json_repos = file_get_contents('repos.json');
$json_repos_data = json_decode($json_repos,true);

?>
<?php if (empty($json_followers_data and $json_repos_data)): ?>
<div class = "noninfodiv">
<a class = "noninfo" href = "/week01_ex02_bust.php"> you have 0 followers</a>
</div>
<?php else: ?>
<table class = "result">
<tr>
<th>N</th>
<th>your followers</th>
<th>your repos name</th>
<th>your repos users ID</th>
</tr>

<?php for ($i = 0; $i < 21; $i++): ?>
<tr>
<td>N - <?php print $i ?></td>
<td><a href="<?php print $json_followers_data[$i]['avatar_url'] ?>" class="thirdpage"><?php print $json_followers_data[$i]['login'] ?></a></td>
<td><a href="<?php print$json_repos_data[$i]['html_url'] ?>"><?php print $json_repos_data[$i]['name'] ?></a></td>
<td><?php print $json_repos_data[$i]['id'] ?></td>
</tr>

<?php endfor; ?>

</table>
<?php endif;?>
<?php endif; ?>
</body>
</html>
44 changes: 44 additions & 0 deletions luka_ergemlidze/userinput.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
<!DOCTYPE html>
<html lang = "en">

<head>
<meta charset = "utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Registration Page</title>

</head>

<body class = "container">
<?php if (empty($_POST)): ?>
<form action="userinput.php" method="POST" enctype="multipart/form-data">
<div class = "FirstPage">
<input type = "text" name = "Fname" class = "Fname" placeholder = "Name" require /><br>
<input type = "text" name = "Lname" class = "Lname" placeholder = "Surname" require /><br>
<input type = "file" name = "image" class = "image" /><br>
<input type = "submit" name = "submit" class = "submit" />
</div>
</form>
<?php else: ?>
<?php
$img = $_FILES['image']['name'];
$imgPath = '';

if(!file_exists('images')) {
mkdir('images');
}

$imgPath = 'images/'.$img;
move_uploaded_file($_FILES['image']['tmp_name'], $imgPath);
?>
<?php if(isset($_POST['submit'])) { ?>
<div class = "SecondPage">
<img src="<?php print './' . $imgPath ?>" class = "UploadedImage">
<h3 class = "FullName"><?php print $_POST['Fname'] . " " . $_POST['Lname'] ?></h3>
</div>
<?php } ?>
<?php endif; ?>

</body>

</html>