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
62 changes: 62 additions & 0 deletions tornike_inalishvili/form.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>PHP Form</title>
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.2.0-beta1/dist/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-0evHe/X+R7YkIZDRvuzKMRqM+OrBnVFBL6DOitfPri4tjfHxaWutUpFmBp4vmVor" crossorigin="anonymous">
<link rel="stylesheet" href="form_style.css">
</head>
<body>
<?php if (empty($_POST)): ?>
<form action="form.php" method="post" enctype="multipart/form-data" class="container">
<div class="col-md-4">
<label for="validationCustom01" class="form-label">First name</label>
<input type="text" class="form-control" id="validationCustom01" name="name" placeholder="Name" required>
</div>
<div class="col-md-4">
<label for="validationCustom02" class="form-label">Last name</label>
<input type="text" class="form-control" id="validationCustom02" name="surname" placeholder="Surname" required><br>
</div>
<div class="input-group mb-3">
<input type="file" class="form-control" id="inputGroupFile02" name="profile_photo" required>
<label class="input-group-text" for="inputGroupFile02">Upload</label>
</div>
<div class="col-12">
<button class="btn btn-primary" type="submit">Submit form</button>
</div>
</form>
<?php else: ?>

<?php
if(!$_POST['name'] || !$_POST['surname']){
echo "<div class='alert alert-danger' role='alert'> Please enter name and surname!</div>";
}
elseif (!preg_match ("/^[a-zA-Z\s]+$/", $_POST['name'] ) || !preg_match ("/^[a-zA-Z\s]+$/", $_POST['surname'] )){
echo "<div class='alert alert-danger' role='alert'>Please use only Latin letters!</div>";
}
else{
$upload_directory = getcwd() . "/uploads/";
$profile_image_name = basename($_FILES["profile_photo"]['name']);
$profile_image_url = NULL;

if (!file_exists($upload_directory)){
mkdir($upload_directory);
}

if (move_uploaded_file($_FILES["profile_photo"]["tmp_name"], $upload_directory . $profile_image_name)){
$profile_image_url = $upload_directory . $profile_image_name;
}
}
?>


<div class="card mb-3">
<img src="<?php print "/uploads/" . $profile_image_name; ?>">
<div class="card-body">
<h5 class="card-title"><?php print $_POST['name']; ?> <?php print $_POST['surname']; ?></h5>
</div>
</div>
<?php endif; ?>
</body>
</html>
24 changes: 24 additions & 0 deletions tornike_inalishvili/form_style.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
body {
background: linear-gradient(45deg, #FC466B, #3F5EFB);
height: 100vh;
font-family: 'Montserrat', sans-serif;
}

.container{
margin-top: 100px;
padding: 3em;
height: 320px;
border-radius: 20px;
backdrop-filter: blur(10px);
text-align: center;
position: relative;
box-shadow: 4px 4px 60px rgba(0,0,0,0.2);
color: #fff;
font-family: Montserrat, sans-serif;
font-weight: 500;
text-shadow: 2px 2px 4px rgba(0,0,0,0.2);
}

#inputGroupFile02 {
width: 50%;
}
130 changes: 130 additions & 0 deletions tornike_inalishvili/repos_index.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,130 @@
<!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">
<link rel="stylesheet" href="repos_style.css">
<title>Github Repositories and Followers</title>
</head>
<body>
<div class="container-1">
<h1>Github User Repos and Followers</h1>
<form class="form" action="repos_index.php" method="get">
<select id="select" name="select">
<option value="choose" hidden>Choose One Option</option>
<option name="repos" value="repos">Show Repositories</option>
<option name="followers" value="followers">Show Folloewrs</option>
</select>
<div>
<input class="user" type="text" name="user_name" placeholder="Enter Username">
<input type="submit" id="submit" name="submit" value="Search">
</div>
</form>
<div class="container-2">
<ol class="repositories">
<?php
if (isset($_GET['submit'])) {
$user_name = $_GET['user_name'];
if (!empty($_GET['user_name'])) {

$curl = curl_init();

$follsonse = [];

$page = 1;
$count = 1;

while($count == 1){
curl_setopt_array($curl, [
CURLOPT_RETURNTRANSFER => 1,
CURLOPT_URL => "https://api.github.com/users/".$user_name."/repos?page={$page}",
CURLOPT_USERAGENT => 'User Repos'
]);

$data = curl_exec($curl);

$result = json_decode($data, true);

if (sizeof($result) == 0) {
$count = 0;
}
$page += 1;

array_push($follsonse,...$result);

}
?>
<?php
if (!empty($_GET['select'])) {
$selected = $_GET['select'];
if ($selected == "repos") {
foreach($follsonse as $folls){
echo '<li><a target="_blank" href="'.$folls["html_url"].'">'.$folls["name"].'</a></li>';
}
}

}


curl_close($curl);
}

}
?>
</ol>
<ol class="followers">
<?php
if (isset($_GET['submit'])) {
$user_name = $_GET['user_name'];

if (!empty($_GET['user_name'])) {


$curL = curl_init();

$follower_results = [];

$followerPage = 1;
$followerCount = 1;

while ($followerCount == 1) {
curl_setopt_array($curL, [
CURLOPT_RETURNTRANSFER => 1,
CURLOPT_URL => "https://api.github.com/users/".$user_name."/followers?page={$followerPage}",
CURLOPT_USERAGENT => 'User Followers'
]);

$datA = curl_exec($curL);

$resulT = json_decode($datA, true);

if (sizeof($resulT) == 0) {
$followerCount = 0;
}
$followerPage += 1;

array_push($follower_results,...$resulT);
}

if (!empty($_GET['select'])) {
$selected = $_GET['select'];
if ($selected == "followers") {
foreach($follower_results as $folls){
echo '<li><a target="_blank" href="'.$folls["html_url"].'"><img src="'.$folls["avatar_url"].'"><span>'.$folls["login"].'</span></a></li>';
}

}

}

curl_close($curL);
}

}
?>
</ol>
</div>
</div>
</body>
</html>
111 changes: 111 additions & 0 deletions tornike_inalishvili/repos_style.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,111 @@
body {
background: linear-gradient(45deg, #FC466B, #3F5EFB);
height: 100vh;
font-family: 'Montserrat', sans-serif;
}

h1 {
color: white;
text-align: center;
font-size: 30px;
padding-top: 20px;
}

.container-1{
margin-top: 100px;
padding: 3em;
height: 320px;
border-radius: 20px;
backdrop-filter: blur(10px);
text-align: center;
position: relative;
box-shadow: 4px 4px 60px rgba(0,0,0,0.2);
font-family: Montserrat, sans-serif;
font-weight: 500;
text-shadow: 2px 2px 4px rgba(0,0,0,0.2);
}

.container-2{
margin: 10px auto;
font-size: 18px;
text-align: left;
position: relative;
box-shadow: 4px 4px 60px rgba(0,0,0,0.2);
font-family: Montserrat, sans-serif;
font-weight: 500;

}

.form {
width: 500px;
margin: 5px;
padding: 10px;
border-radius: 10px;
}

.user {
font-family: inherit;
width: 100%;
border: 0;
outline: 0;
font-size: 1.3rem;
padding: 7px 0;
font-size: 22px;
border-radius: 40px;
text-align: center;
box-shadow: 0 6px 20px -5px rgba(0,0,0,0.4);
overflow: hidden;
cursor: pointer;
}

.followers{
margin-top: 20px;
display: flex;
flex-wrap: wrap;
justify-content: space-between;
}

.repositories {
background-color: rgba(248, 242, 242);
border-radius: 30px;
padding: 7px 0;
width: 300px;
margin: 5px;
}

#select{
margin-bottom: 20px;
font-family: inherit;
width: 100%;
border: 0;
outline: 0;
font-size: 1.3rem;
padding: 7px 0;
font-size: 22px;
border-radius: 40px;
text-align: center;
box-shadow: 0 6px 20px -5px rgba(0,0,0,0.4);
overflow: hidden;
cursor: pointer;

}




#submit{
margin-top: 20px;
width: 200px;
height: 40px;
border: none;
outline: none;
font-size: 22px;
border-radius: 40px;
text-align: center;
box-shadow: 0 6px 20px -5px rgba(0,0,0,0.4);
position: relative;
overflow: hidden;
cursor: pointer;


}