Updated profile

This commit is contained in:
Nik Topler 2020-10-05 23:45:07 +02:00
parent 8f9489407d
commit 999858f79a
24 changed files with 671 additions and 300 deletions

View file

@ -87,7 +87,9 @@ body{
.article-other-info .test:hover + .tooltiptext, .article-other-info .test:hover + .tooltiptext,
.article-extra-option-icon:hover + .tooltiptext, .article-extra-option-icon:hover + .tooltiptext,
.company-date:hover .tooltiptext, .company-date:hover .tooltiptext,
.outter-container:hover .tooltiptext{ .outter-container:hover .tooltiptext,
.plus-icon-container:hover .tooltiptext,
.trash-icon-container:hover .tooltiptext{
visibility: visible; visibility: visible;
opacity: 1; opacity: 1;
font-size: 0.7em; font-size: 0.7em;
@ -115,6 +117,9 @@ body{
.tooltiptextTop150 { .tooltiptextTop150 {
top: 150%; top: 150%;
} }
.tooltiptextTop130 {
top: 130%;
}
.tooltiptextTop120 { .tooltiptextTop120 {
top: 120%; top: 120%;
} }

View file

@ -658,18 +658,99 @@ body {
display: flex; display: flex;
flex-direction: column; flex-direction: column;
} }
.admin-panel section {
display: grid; table {
grid-template-columns: 1fr 1fr 1fr 1fr 60px; border-collapse: collapse;
padding: 0.5rem; margin: 0;
padding: 0;
table-layout: fixed;
margin-top: 1rem;
} }
.admin-panel section div {
padding: 20px; table caption {
font-size: 1.5rem;
margin: .5rem 0 .75rem;
}
table tr {
background-color: var(--bg);
border: 1px solid var(--border-medium);
padding: .35rem;
}
table th,
table td {
padding: 1rem;
text-align: center;
}
table th {
font-size: .85rem;
letter-spacing: .1rem;
text-transform: uppercase;
}
@media screen and (max-width: 600px) {
table {
border: 0;
}
table caption {
font-size: 1.3em;
}
table thead {
border: none;
clip: rect(0 0 0 0);
height: 1px;
margin: -1px;
overflow: hidden;
padding: 0;
position: absolute;
width: 1px;
}
table tr {
display: block;
margin-bottom: .625em;
}
table td {
display: block;
font-size: 0.8rem;
text-align: center;
}
table td::before {
content: attr(data-label);
float: left;
font-weight: bold;
text-transform: uppercase;
}
table td:last-child {
border-bottom: 0;
}
}
.plus-icon-container,
.trash-icon-container {
min-height: 2rem;
width: 2rem;
margin: auto; margin: auto;
display: flex;
align-items: center;
justify-content: center;
border-radius: 50%;
transition: all ease-in-out .12s;
cursor: pointer;
position: relative;
} }
.admin-panel i { .plus-icon-container i { color: var(--green-light); }
color: green; .plus-icon-container:hover { background-color: var(--hover-light); }
.trash-icon-container i {
color: var(--font-dark);
transition: all ease-in-out .22s;
} }
.trash-icon-container:hover i { color: var(--red-medium);}
/* Change */ /* Change */

View file

@ -691,6 +691,12 @@ body{
grid-template-columns: repeat(12,minmax(0, 1fr)); grid-template-columns: repeat(12,minmax(0, 1fr));
grid-gap: 1rem 2rem; grid-gap: 1rem 2rem;
} }
.main-content-section.headlines .main-content-container {
grid-template-columns: minmax(0,1fr) minmax(0,1fr) minmax(0,1fr) minmax(0,1fr) minmax(0,1fr) minmax(0,1fr) minmax(0,1fr) minmax(0,1fr) minmax(0,1fr) 220px;
}
.main-content-section.headlines .main-content-container .article-container { grid-column: 1/9; }
.main-content-section.headlines .main-content-container .main-side-content-container { grid-column: 9/13 ; }
.article-container { grid-column: 1/9; } .article-container { grid-column: 1/9; }
#main-side-content-container { grid-column: 9/13; } #main-side-content-container { grid-column: 9/13; }
article.aside { border: none; } article.aside { border: none; }

View file

@ -4,7 +4,6 @@
top: 50%; top: 50%;
left: 50%; left: 50%;
transform: translate(-50%,-50%) scale(0.9); transform: translate(-50%,-50%) scale(0.9);
/* transition: all ease-in-out .1s; */
border: 1px solid var(--hover-medium); border: 1px solid var(--hover-medium);
border-radius: 5px; border-radius: 5px;
background-color: var(--bg); background-color: var(--bg);
@ -16,10 +15,12 @@
z-index: 1000; z-index: 1000;
visibility: visible; visibility: visible;
transform: translate(-50%,-50%) scale(1); transform: translate(-50%,-50%) scale(1);
min-width: 340px; min-width: 320px;
max-width: 370px;
height: auto; height: auto;
} }
.main-img-container .container { .main-img-container .container {
margin-top: 0.75rem;
margin-bottom: 0.75rem; margin-bottom: 0.75rem;
display: flex; display: flex;
} }
@ -28,7 +29,7 @@
.color-img.active { margin-top: 1rem; } .color-img.active { margin-top: 1rem; }
.main-img-container section { .main-img-container section {
margin-top: 1rem; margin: 1rem 0 2rem 0;
padding: 0 5px; padding: 0 5px;
} }
.main-img-container.active section:nth-of-type(2) { margin-top: 0; } .main-img-container.active section:nth-of-type(2) { margin-top: 0; }
@ -129,5 +130,43 @@
.insert-photo-container + section { margin-top: 0; } .insert-photo-container + section { margin-top: 0; }
.main-insert-photo-container .footer { .main-insert-photo-container .footer {
height: 3rem; height: 3rem;
margin: auto; display: flex;
align-items: center;
width: 100%;
} }
.main-insert-photo-container .footer div:first-of-type {
display: flex;
align-items: center;
justify-self: flex-start;
flex-grow: 1;
}
.main-insert-photo-container .footer div:first-of-type span {
color: var(--font-dark);
font-size: 0.8rem;
}
.main-insert-photo-container .footer .button {
display: flex;
padding: 2px 5px;
align-items: center;
justify-content: center;
height: 50%;
background-color: var(--bg);
border: 1px solid var(--border-light);
border-radius: 3px;
cursor: pointer;
transition: all ease-in-out .15s;
color: var(--font-dark);
}
.main-insert-photo-container .footer .button:hover { background-color: var(--hover-light); }
.color-container {
min-height: 4rem;
align-items: center;
justify-content: center;
}
.color-container .box-container {
display: inline-flex;
padding: 0.5rem 0.5rem;
/* margin: auto 1rem 1rem auto; */
}
.color-container div:last-of-type { margin-right: 0;}

Binary file not shown.

After

Width:  |  Height:  |  Size: 47 KiB

View file

@ -3,6 +3,7 @@ const sideBarResAccount = document.querySelector('.side-bar-responsive')
const sideBarAccount = document.getElementById('side-bar-account') const sideBarAccount = document.getElementById('side-bar-account')
window.onload = () => { window.onload = () => {
generateColors()
if(window.location.pathname.includes('changeName')) change.name() if(window.location.pathname.includes('changeName')) change.name()
else if(window.location.pathname.includes('changeCountry')) change.country() else if(window.location.pathname.includes('changeCountry')) change.country()
else if(window.location.pathname.includes('changePassword')) change.password() else if(window.location.pathname.includes('changePassword')) change.password()
@ -26,11 +27,13 @@ function responsive() {
sideBarResAccount.classList.add('disable') sideBarResAccount.classList.add('disable')
} }
} }
if(mainImgContainer)
if(mainImgContainer.classList.contains('disable')) mainImgContainer.classList.remove('disable')
async function logout(string) { async function logout(string) {
await fetch(`../include/logout.inc.php`) await fetch(`../include/logout.inc.php`)
openLinks(filePath.headlines + string); openLinks('/'+filePath.headlines+string);
} }
function openLinks(string) { window.location.replace(websiteURL + string) } function openLinks(string) { window.location.replace(websiteURL + string) }
@ -181,7 +184,7 @@ const check = {
body: createFormData('name', array) body: createFormData('name', array)
}) })
const data = await res.text() const data = await res.text()
if(data === 'success') openLinks('account/personal.php') if(data === 'success') openLinks('/account/personal.php')
}, },
gender : async() => { gender : async() => {
if(!document.querySelector('.gender-container .active')) { if(!document.querySelector('.gender-container .active')) {
@ -194,7 +197,7 @@ const check = {
body: createFormData('gender', array) body: createFormData('gender', array)
}) })
const data = await res.text() const data = await res.text()
if(data === 'success') openLinks('account/personal.php') if(data === 'success') openLinks('/account/personal.php')
}, },
country : async() => { country : async() => {
if(!document.querySelector('.country-container .active')) { if(!document.querySelector('.country-container .active')) {
@ -207,7 +210,7 @@ const check = {
body: createFormData('country', array) body: createFormData('country', array)
}) })
const data = await res.text() const data = await res.text()
if(data === 'success') openLinks('account/personal.php') if(data === 'success') openLinks('/account/personal.php')
}, },
psw : async() => { psw : async() => {
@ -227,7 +230,7 @@ const check = {
}) })
const data = await res.text() const data = await res.text()
console.log(data) console.log(data)
if(data === 'success') openLinks('account/personal.php') if(data === 'success') openLinks('/account/personal.php')
else error.passwordOldAfter() else error.passwordOldAfter()
} }
} }
@ -361,3 +364,74 @@ function managePasswordVisibility(element) {
else if(element.parentElement.firstElementChild.lastElementChild === pswOldInput) pswOldInput.type = 'password' else if(element.parentElement.firstElementChild.lastElementChild === pswOldInput) pswOldInput.type = 'password'
} }
} }
function addAdmin(element) {
element.parentElement.firstElementChild.classList.add('disable')
element.parentElement.lastElementChild.classList.remove('disable')
admin('addAdmin', element.parentElement.parentElement.children[1].innerHTML.trim())
}
function removeAdmin(element) {
element.parentElement.firstElementChild.classList.remove('disable')
element.parentElement.lastElementChild.classList.add('disable')
admin('removeAdmin', element.parentElement.parentElement.children[1].innerHTML.trim())
}
async function admin(action, email) {
const res = await fetch('../include/update.inc.php', {
method: "POST",
body: createFormData(action, email)
})
const data = await res.text()
console.log(data)
}
let imageUploadActive = false
let currentImageUploadLocation
async function submitProfileImageUploadForm() {
if(document.getElementById('file-upload').value) {
let photo = document.getElementById("file-upload").files[0]
let formData = new FormData()
formData.append('file', photo)
const response = await fetch('../include/uploadFile.inc.php', {
method: "POST",
body: formData
})
const text = await response.text()
if(text === 'too big') errorSpanUploadImage.innerHTML = `${icon} Max file size is 1MB`
else if(text === 'error') errorSpanUploadImage.innerHTML = `${icon} There have been some sort of an error`
else if(text === 'extension not allowed') errorSpanUploadImage.innerHTML = `${icon} Only jpeg, jpg, png are allowed`
else {
imageUploadActive = true
errorSpanUploadImage.classList.remove('red-color')
errorSpanUploadImage.classList.add('light-green-color')
errorSpanUploadImage.innerHTML = 'Image has been successfully added'
currentImageUploadLocation = text.split(' ')[1]
array = JSON.stringify(['0', currentImageUploadLocation])
const res = await fetch('../include/update.inc.php', {
method: "POST",
body: createFormData('imageUpload', array)
})
const data = await res.text()
console.log(data)
}
document.getElementById('file-upload').value = ''
} else imageNameLabel.innerHTML = 'No file selected'
}
function fileChange() {
console.log(document.querySelector('.insert-photo-container .footer'))
document.querySelector('.insert-photo-container .footer .footer').classList.remove('disable')
let a = document.getElementById('file-upload').value.split(`fakepath`).pop().replace(/\\/g, '')
a = a.substring(0, 20)+'...'
imageNameLabel.innerHTML = a
}

View file

@ -4,16 +4,16 @@ let weatherArrayTommorow
let weatherArray2Days let weatherArray2Days
const weather = { const weather = {
async getweather() { getweather : async function () {
city = changeDiacritics(userLocationInformationValue[3]) city = removeDiacritics(userLocationInformationValue[3])
const key = php.info('weather') const key = await php.info('weather')
const response = await fetch(`https://cors-anywhere.herokuapp.com/https://api.weatherapi.com/v1/forecast.json?key=${key}&q=${city}&days=7`) const response = await fetch(`https://cors-anywhere.herokuapp.com/https://api.weatherapi.com/v1/forecast.json?key=${key}&q=${city}&days=7`)
const data = await response.json() const data = await response.json()
weatherArrayToday = data.forecast.forecastday[0] weatherArrayToday = data.forecast.forecastday[0]
weatherArrayTommorow = data.forecast.forecastday[1] weatherArrayTommorow = data.forecast.forecastday[1]
weatherArray2Days = data.forecast.forecastday[2] weatherArray2Days = data.forecast.forecastday[2]
}, },
updateWeather() { updateWeather : function () {
let header = document.querySelectorAll('.weather-main-header')[0] let header = document.querySelectorAll('.weather-main-header')[0]
header.children[0].src = weatherArrayToday.day.condition.icon header.children[0].src = weatherArrayToday.day.condition.icon
header.children[1].innerHTML = userLocationInformationValue[3] header.children[1].innerHTML = userLocationInformationValue[3]
@ -23,8 +23,10 @@ const weather = {
let tommorowNumber = weatherDate.getDay() let tommorowNumber = weatherDate.getDay()
let dayAfterTomorrow = weatherDate.getDay() let dayAfterTomorrow = weatherDate.getDay()
if(tommorowNumber == 6) tommorowNumber = tommorowNumber - 7 if (tommorowNumber == 6)
if(dayAfterTomorrow == 5 || dayAfterTomorrow == 6) dayAfterTomorrow = dayAfterTomorrow - 7 tommorowNumber = tommorowNumber - 7
if (dayAfterTomorrow == 5 || dayAfterTomorrow == 6)
dayAfterTomorrow = dayAfterTomorrow - 7
let dayAcronymTommorow = daysAcronyms[tommorowNumber + 1] let dayAcronymTommorow = daysAcronyms[tommorowNumber + 1]
let dayAcronymIn2Days = daysAcronyms[dayAfterTomorrow + 2] let dayAcronymIn2Days = daysAcronyms[dayAfterTomorrow + 2]
@ -273,9 +275,9 @@ window.onload = async () => {
// Close all open windows // Close all open windows
hideExtraSearchOptions() hideExtraSearchOptions()
hideSuggestWords() hideSuggestWords()
generateColors()
if(window.location.hash === '#login') manageLoginOptions() if(window.location.hash === '#login') manageLoginOptions()
document.querySelectorAll('input').forEach(input => { input.autocomplete = 'off' }) document.querySelectorAll('input').forEach(input => { input.autocomplete = 'off' })
error.window() error.window()
@ -388,10 +390,11 @@ function fahrenheitToKelvin(number) { return (number - 32) * 5/9 + 273 }
/* HEADLINES */ /* HEADLINES */
async function headlines() { async function headlines() {
// await weather.getWeather()
// weather.updateWeather()
pathLocation = '' pathLocation = ''
await user.location()
await weather.getweather()
weather.updateWeather()
sidebarCategorySelect(document.querySelector('.fa-newspaper').parentElement.parentElement) sidebarCategorySelect(document.querySelector('.fa-newspaper').parentElement.parentElement)
historyPushState(window.location.origin + window.location.pathname, '', `?cou=${getCountryAcronym(selectedCountry.innerHTML.trim())}`,`&bg=${backgroundColor}`) historyPushState(window.location.origin + window.location.pathname, '', `?cou=${getCountryAcronym(selectedCountry.innerHTML.trim())}`,`&bg=${backgroundColor}`)

View file

@ -143,7 +143,7 @@ function manageExtraProfileOptions() {
} }
} }
function openLinks(string) { window.location.replace(websiteURL + string) } function openLinks(string) { window.location.replace(websiteURL +'/'+ string) }
const insertContainer = document.getElementById('insert-photo-container') const insertContainer = document.getElementById('insert-photo-container')
function showProfileImg() { function showProfileImg() {
if(mainImgContainer.classList.contains('active')) { if(mainImgContainer.classList.contains('active')) {
@ -164,3 +164,17 @@ function manageInsertContainer() {
else insertContainer.classList.add('active') else insertContainer.classList.add('active')
} }
function openFolder() { document.getElementById('file-upload').click() } function openFolder() { document.getElementById('file-upload').click() }
function generateColors () {
let parent = document.querySelector('.color-container')
if(!parent) return
for(let i = 0; i < colors.length; i++) {
let divP = document.createElement('div')
divP.classList.add('box-container')
let div = document.createElement('div')
div.classList.add('img','medium')
div.style.backgroundColor = colors[i]
divP.appendChild(div)
parent.appendChild(divP)
}
}

View file

@ -8,7 +8,7 @@
const colors = ['rgb(211, 47, 47)','rgb(123, 31, 162)','rgb(81, 45, 168)','rgb(48, 63, 159)','rgb(25, 118, 210)','rgb(2, 136, 209)','rgb(0, 151, 167)','rgb(0, 121, 107)','rgb(56, 142, 60)','rgb(104, 159, 56)','rgb(175, 180, 43)','rgb(251, 192, 45)','rgb(255, 160, 0)','rgb(245, 124, 0)','rgb(230, 74, 25)','rgb(93, 64, 55)','rgb(97, 97, 97)'] const colors = ['rgb(211, 47, 47)','rgb(123, 31, 162)','rgb(81, 45, 168)','rgb(48, 63, 159)','rgb(25, 118, 210)','rgb(2, 136, 209)','rgb(0, 151, 167)','rgb(0, 121, 107)','rgb(56, 142, 60)','rgb(104, 159, 56)','rgb(175, 180, 43)','rgb(251, 192, 45)','rgb(255, 160, 0)','rgb(245, 124, 0)','rgb(230, 74, 25)','rgb(93, 64, 55)','rgb(97, 97, 97)']
const days = ['Sunday','Monday','Tuesday','Wednesday','Thursday','Friday','Saturday'] const days = ['Sunday','Monday','Tuesday','Wednesday','Thursday','Friday','Saturday']
const daysAcronyms = ['Sun','Mon','Tue','Wed','Thu','Fri','Sat'] const daysAcronyms = ['Sun','Mon','Tue','Wed','Thu','Fri','Sat']
const websiteURL = 'http://localhost:8080/News-website/' const websiteURL = 'http://localhost:8080/News-website'
// const websiteURL = 'https://news.niktopler.com' // const websiteURL = 'https://news.niktopler.com'
const topStoriesURL = '&t=topstories&' const topStoriesURL = '&t=topstories&'
@ -66,12 +66,15 @@
const showCountriesLink = document.getElementById('show-countries-button') const showCountriesLink = document.getElementById('show-countries-button')
let sclSpan let sclSpan
let sclStrong let sclStrong
const mainImgContainer = document.getElementById('main-img-container') const mainImgContainer = document.querySelector('#main-img-container.main-img-container')
if(showCountriesLink !== null) { if(showCountriesLink !== null) {
sclSpan = showCountriesLink.firstElementChild.firstElementChild sclSpan = showCountriesLink.firstElementChild.firstElementChild
sclStrong = showCountriesLink.firstElementChild.lastElementChild sclStrong = showCountriesLink.firstElementChild.lastElementChild
} }
const imageNameLabel = document.getElementById('image-name-label')
const errorSpanUploadImage = document.getElementById('error-span-upload-image')
const main = document.getElementById('main') const main = document.getElementById('main')
const overlay = document.getElementById('overlay') const overlay = document.getElementById('overlay')
const navigationBarProfileImageDiv = document.getElementById('outter-container') const navigationBarProfileImageDiv = document.getElementById('outter-container')

View file

@ -3,28 +3,31 @@
<div class="side-bar-container" id="side-bar-container"> <div class="side-bar-container" id="side-bar-container">
<div> <div>
<div class="side-bar-content" id="side-bar-content"> <div class="side-bar-content" id="side-bar-content">
<div class="sidebar-category <?php if(strpos($_SERVER['REQUEST_URI'], 'home')) echo 'active'; ?>" onclick="openLinks('account/home.php')"> <div class="sidebar-category <?php if(strpos($_SERVER['REQUEST_URI'], 'home')) echo 'active'; ?>" onclick="openLinks('/account/home.php')">
<div class="icon"><i class="fas fa-user-circle fa-lg"></i></div> <div class="icon"><i class="fas fa-user-circle fa-lg"></i></div>
<div><a href="#">Home</a></div> <div><a href="#">Home</a></div>
</div> </div>
<div class="sidebar-category <?php if(strpos($_SERVER['REQUEST_URI'], 'personal')) echo 'active'; ?>" onclick="openLinks('account/personal.php')"> <div class="sidebar-category <?php if(strpos($_SERVER['REQUEST_URI'], 'personal')) echo 'active'; ?>" onclick="openLinks('/account/personal.php')">
<div class="icon"><i class="far fa-id-card-alt fa-lg"></i></div> <div class="icon"><i class="far fa-id-card-alt fa-lg"></i></div>
<div><a href="#">Personal Information</a></div> <div><a href="#">Personal Information</a></div>
</div> </div>
<?php <?php
if($_SESSION['admin'] != 'no') if($_SESSION['admin'] != 'no')
echo '<div class="sidebar-category <?php if(strpos($_SERVER[\'REQUEST_URI\'], \'admin\')) echo \'active\'; ?>" onclick="openLinks(\'account/admin.php\')"> $admin = '';
$trending = '';
if(strpos($_SERVER['REQUEST_URI'], 'admin')) $admin = 'active';
if(strpos($_SERVER['REQUEST_URI'], 'trending')) $trending = 'active';
echo '<div class="sidebar-category '.$admin.'" onclick="openLinks(\'/account/admin.php\')">
<div class="icon"><i class="fas fa-users-crown fa-lg"></i></div> <div class="icon"><i class="fas fa-users-crown fa-lg"></i></div>
<div><a href="#" class="side-menu-categories">Admin</a></div> <div><a href="#" class="side-menu-categories">Admin</a></div>
</div> </div>
<div class="sidebar-category <?php if(strpos($_SERVER[\'REQUEST_URI\'], \'trending\')) echo \'active\'; ?>" onclick="openLinks(\'account/trending.php\')"> <div class="sidebar-category '.$trending.'" onclick="openLinks(\'/account/trending.php\')">
<div class="icon"><i class="far fa-chart-line fa-lg"></i></div> <div class="icon"><i class="far fa-chart-line fa-lg"></i></div>
<div><a href="#" class="side-menu-categories">Trending Section</a></div> <div><a href="#" class="side-menu-categories">Trending Section</a></div>
</div>'; </div>';
?> ?>
<div class="sidebar-category <?php if(strpos($_SERVER['REQUEST_URI'], 'settings')) echo 'active'; ?>" onclick="openLinks('account/settings.php')"> <div class="sidebar-category <?php if(strpos($_SERVER['REQUEST_URI'], 'settings')) echo 'active'; ?>" onclick="openLinks('/account/settings.php')">
<div class="icon"><i class="fas fa-user-cog fa-lg"></i></div> <div class="icon"><i class="fas fa-user-cog fa-lg"></i></div>
<div><a href="#" class="side-menu-categories">Settings</a></div> <div><a href="#" class="side-menu-categories">Settings</a></div>
</div> </div>
@ -36,13 +39,13 @@
<div class="side-bar-responsive disable"> <div class="side-bar-responsive disable">
<div class="slide"> <div class="slide">
<ul class="res-container"> <ul class="res-container">
<li class="content-container" onclick="openLinks('account/home.php')"> <li class="content-container" onclick="openLinks('/account/home.php')">
<div> <div>
<div class="<?php if(strpos($_SERVER['REQUEST_URI'], 'home')) echo 'active'; ?>"></div> <div class="<?php if(strpos($_SERVER['REQUEST_URI'], 'home')) echo 'active'; ?>"></div>
<span class="<?php if(strpos($_SERVER['REQUEST_URI'], 'home')) echo 'active'; ?>">Home</span> <span class="<?php if(strpos($_SERVER['REQUEST_URI'], 'home')) echo 'active'; ?>">Home</span>
</div> </div>
</li> </li>
<li class="content-container" onclick="openLinks('account/personal.php')"> <li class="content-container" onclick="openLinks('/account/personal.php')">
<div> <div>
<div class="<?php if(strpos($_SERVER['REQUEST_URI'], 'personal')) echo 'active'; ?>"></div> <div class="<?php if(strpos($_SERVER['REQUEST_URI'], 'personal')) echo 'active'; ?>"></div>
<span class="<?php if(strpos($_SERVER['REQUEST_URI'], 'personal')) echo 'active'; ?>">Personal Info</span> <span class="<?php if(strpos($_SERVER['REQUEST_URI'], 'personal')) echo 'active'; ?>">Personal Info</span>
@ -51,22 +54,27 @@
<?php <?php
if($_SESSION['admin'] != 'no') if($_SESSION['admin'] != 'no')
echo ' <li class="content-container" onclick="openLinks(\'account/admin.php\')"> $admin = '';
$trending = '';
if(strpos($_SERVER['REQUEST_URI'], 'admin')) $admin = 'active';
if(strpos($_SERVER['REQUEST_URI'], 'trending')) $trending = 'active';
echo ' <li class="content-container" onclick="openLinks(\'/account/admin.php\')">
<div> <div>
<div class="<?php if(strpos($_SERVER[\'REQUEST_URI\'], \'admin\')) echo \'active\'; ?>"></div> <div class="'.$admin.'"></div>
<span class="<?php if(strpos($_SERVER[\'REQUEST_URI\'], \'admin\')) echo \'active\'; ?>">Admin</span> <span class="'.$admin.'">Admin</span>
</div> </div>
</li> </li>
<li class="content-container" onclick="openLinks(\'account/trending.php\')"> <li class="content-container" onclick="openLinks(\'/account/trending.php\')">
<div> <div>
<div class="<?php if(strpos($_SERVER[\'REQUEST_URI\'], \'trending\')) echo \'active\'; ?>"></div> <div class="'.$trending.'"></div>
<span class="<?php if(strpos($_SERVER[\'REQUEST_URI\'], \'trending\')) echo \'active\'; ?>">Trending</span> <span class="'.$trending.'">Trending</span>
</div> </div>
</li>'; </li>';
?> ?>
<li class="content-container" onclick="openLinks('account/settings.php')"> <li class="content-container" onclick="openLinks('/account/settings.php')">
<div> <div>
<div class="<?php if(strpos($_SERVER['REQUEST_URI'], 'settings')) echo 'active'; ?>"></div> <div class="<?php if(strpos($_SERVER['REQUEST_URI'], 'settings')) echo 'active'; ?>"></div>
<span class="<?php if(strpos($_SERVER['REQUEST_URI'], 'settings')) echo 'active'; ?>">Settings</span> <span class="<?php if(strpos($_SERVER['REQUEST_URI'], 'settings')) echo 'active'; ?>">Settings</span>

View file

@ -36,96 +36,99 @@
Manage user privileges Manage user privileges
</p> </p>
</div> </div>
<article class="admin-panel"> <table>
<section> <thead>
<div class="ca"><span>Name</span></div> <tr>
<div class="ca"><span>Email</span></div> <th scope="col">Name</th>
<div class="ca"><span>Country</span></div> <th scope="col">Email</th>
<div class="ca"><span>Name</span></div> <th scope="col">Country</th>
<div class="ca"></div> <th scope="col">Status</th>
</section> <th scope="col">&nbsp;</th>
<section> </tr>
<div class="ca">Nik Topler</div> </thead>
<div class="ca">nik.topler21@gmail.com</div> <tbody>
<div class="ca">Slovenia</div> <?php
<div class="ca">Admin</div>
<div class="ca"><div class="icon"><i class="far fa-plus fa-lg"></i></div></i></div>
</section>
<section> include_once '../include/db.inc.php';
<div class="ca">Nik Topler</div>
<div class="ca">nik.topler21@gmail.com</div>
<div class="ca">Slovenia</div>
<div class="ca">Admin</div>
<div class="ca"><div class="icon"><i class="far fa-plus fa-lg"></i></div></i></div>
</section>
<section> class generateUsers extends Dbh {
<div class="ca">Nik Topler</div>
<div class="ca">nik.topler21@gmail.com</div>
<div class="ca">Slovenia</div>
<div class="ca">Admin</div>
<div class="ca"><div class="icon"><i class="far fa-plus fa-lg"></i></div></i></div>
</section>
<section> public function generate() {
<div class="ca">Nik Topler</div> $sql = "SELECT * FROM users";
<div class="ca">nik.topler21@gmail.com</div> $stmt = $this->connect()->prepare($sql);
<div class="ca">Slovenia</div> $stmt->execute();
<div class="ca">Admin</div> $row = $stmt->fetch();
<div class="ca"><div class="icon"><i class="far fa-plus fa-lg"></i></div></i></div> while($row = $stmt->fetch()) {
</section>
<section>
<div class="ca">Nik Topler</div>
<div class="ca">nik.topler21@gmail.com</div>
<div class="ca">Slovenia</div>
<div class="ca">Admin</div>
<div class="ca"><div class="icon"><i class="far fa-plus fa-lg"></i></div></i></div>
</section>
<section>
<div class="ca">Nik Topler</div>
<div class="ca">nik.topler21@gmail.com</div>
<div class="ca">Slovenia</div>
<div class="ca">Admin</div>
<div class="ca"><div class="icon"><i class="far fa-plus fa-lg"></i></div></i></div>
</section>
<section>
<div class="ca">Nik Topler</div>
<div class="ca">nik.topler21@gmail.com</div>
<div class="ca">Slovenia</div>
<div class="ca">Admin</div>
<div class="ca"><div class="icon"><i class="far fa-plus fa-lg"></i></div></i></div>
</section>
<section>
<div class="ca">Nik Topler</div>
<div class="ca">nik.topler21@gmail.com</div>
<div class="ca">Slovenia</div>
<div class="ca">Admin</div>
<div class="ca"><div class="icon"><i class="far fa-plus fa-lg"></i></div></i></div>
</section>
<section>
<div class="ca">Nik Topler</div>
<div class="ca">nik.topler21@gmail.com</div>
<div class="ca">Slovenia</div>
<div class="ca">Admin</div>
<div class="ca"><div class="icon"><i class="far fa-plus fa-lg"></i></div></i></div>
</section>
<section>
<div class="ca">Nik Topler</div>
<div class="ca">nik.topler21@gmail.com</div>
<div class="ca">Slovenia</div>
<div class="ca">Admin</div>
<div class="ca"><div class="icon"><i class="far fa-plus fa-lg"></i></div></i></div>
</section>
<section>
<div class="ca">Nik Topler</div>
<div class="ca">nik.topler21@gmail.com</div>
<div class="ca">Slovenia</div>
<div class="ca">Admin</div>
<div class="ca"><div class="icon"><i class="far fa-plus fa-lg"></i></div></i></div>
</section>
</article> if($_SESSION['email'] != $row['email']) {
echo '<tr>';
echo '<td>';
$name = 'No name set';
if(isset($row['name'])) $name = $row['name'];
if(isset($row['surname'])) $name = $name.' '.$row['surname'];
echo $name;
echo '</td>';
echo '<td>';
echo $row['email'];
echo '</td>';
echo '<td>';
echo $this->getCountryNameWithID($row['country_id']);
echo '</td>';
echo '<td>';
if($this->checkIfIsUserAdmin($row['id']) == 'yes' ) $admin = 'admin';
else $admin = 'user';
echo $admin;
echo '</td>';
echo '<td>';
if($admin == 'admin') {
$add = 'disable';
$remove = '';
} else {
$remove = 'disable';
$add = '';
}
echo '<div class="plus-icon-container '.$add.'" onclick="addAdmin(this)">
<div>
<i class="far fa-plus"></i>
</div>
<span class="tooltiptext tooltiptextTop130">Add</span>
</div>
<div class="trash-icon-container '.$remove.'" onclick="removeAdmin(this)">
<i class="fas fa-trash-alt"></i>
<span class="tooltiptext tooltiptextTop130">Remove</span>
</div>';
echo '</td>';
echo '</tr>';
}
}
}
public function getCountryNameWithID($id) {
$sql = "SELECT * FROM countries WHERE id = ?";
$stmt = $this->connect()->prepare($sql);
$stmt->execute([$id]);
$row = $stmt->fetch();
return $row['name'];
}
public function checkIfIsUserAdmin($id) {
$sql = "SELECT * FROM admins WHERE user_id = ?";
$stmt = $this->connect()->prepare($sql);
$stmt->execute([$id]);
$row = $stmt->fetch();
if($row) return 'yes';
else return 'no';
}
}
$generateObj = new generateUsers();
$generateObj->generate();
?>
</tbody>
</table>
</section> </section>
</div> </div>
@ -134,4 +137,5 @@
</main> </main>
</body> </body>
</html> </html>

View file

@ -24,8 +24,11 @@
<section class="header"> <section class="header">
<div class="img-container"> <div class="img-container">
<?php <?php
$path = '../';
if(strpos($_SERVER['REQUEST_URI'], 'search') || strpos($_SERVER['REQUEST_URI'], 'headlines')) $path = '';
if($_SESSION['profile_choice'] == 0) if($_SESSION['profile_choice'] == 0)
echo ('<div class="img xxl" onclick="changeProfileImg()" ><img src="'.$_SESSION['profile_img'].'" class="imga"></div>'); echo ('<div class="img xxl" onclick="changeProfileImg()" ><img src="'.$path.$_SESSION['profile_img'].'" class="imga"></div>');
else if($_SESSION['profile_choice'] == 1) else if($_SESSION['profile_choice'] == 1)
echo ('<div class="img xxl" onclick="changeProfileImg()" style="background-color: '.$_SESSION['profile_color'].';"> echo ('<div class="img xxl" onclick="changeProfileImg()" style="background-color: '.$_SESSION['profile_color'].';">
<div class="letter"> <div class="letter">
@ -68,7 +71,7 @@
<strong>Note: </strong>Some personal information can change the way website works. <strong>Note: </strong>Some personal information can change the way website works.
</p> </p>
</div> </div>
<div class="button" onclick="openLinks('account/personal.php')"> <div class="button" onclick="openLinks('/account/personal.php')">
<a href="#">Manage your Personal Information</a> <a href="#">Manage your Personal Information</a>
</div> </div>
</div> </div>
@ -79,7 +82,7 @@
Customize your account based on your prefrences. Customize your account based on your prefrences.
</p> </p>
</div> </div>
<div class="button" onclick="openLinks('account/settings.php')"> <div class="button" onclick="openLinks('/account/settings.php')">
<a href="#">Open Settings</a> <a href="#">Open Settings</a>
</div> </div>
</div> </div>
@ -96,7 +99,7 @@
<strong>Note: </strong> this page is only for website moderators. <strong>Note: </strong> this page is only for website moderators.
</p> </p>
</div> </div>
<div class="button" onclick="openLinks(\'account/admin.php\')"> <div class="button" onclick="openLinks(\'/account/admin.php\')">
<a href="#">Manage Admins</a> <a href="#">Manage Admins</a>
</div> </div>
</div> </div>
@ -107,7 +110,7 @@
Select news articles, that are going to be featured in the trending section. Select news articles, that are going to be featured in the trending section.
</p> </p>
</div> </div>
<div class="button" onclick="openLinks(\'account/trending.php\')"> <div class="button" onclick="openLinks(\'/account/trending.php\')">
<a href="#">Edit Trending section</a> <a href="#">Edit Trending section</a>
</div> </div>
</div> </div>

View file

@ -1,7 +1,6 @@
<?php include 'add-ons/head.php' ?> <?php include 'add-ons/head.php' ?>
<body> <body>
<?php include '../add-ons/profileImg.php' ?>
<nav class="account"> <nav class="account">
<div class="left"> <div class="left">
<div class="container"> <div class="container">
@ -16,6 +15,7 @@
</div> </div>
</div> </div>
</nav> </nav>
<main> <main>
<?php include 'add-ons/side-bar.php' ?> <?php include 'add-ons/side-bar.php' ?>
@ -44,7 +44,7 @@
<div class="image"> <div class="image">
<?php <?php
if($_SESSION['profile_choice'] == 0) if($_SESSION['profile_choice'] == 0)
echo ('<div class="img medium" ><img src="'.$_SESSION['profile_img'].'" class="imga"></div>'); echo ('<div class="img medium" ><img src="../'.$_SESSION['profile_img'].'" class="imga"></div>');
else if($_SESSION['profile_choice'] == 1) else if($_SESSION['profile_choice'] == 1)
echo ('<div class="img medium" style="background-color: '.$_SESSION['profile_color'].';"> echo ('<div class="img medium" style="background-color: '.$_SESSION['profile_color'].';">
<div class="letter"> <div class="letter">
@ -60,7 +60,7 @@
?> ?>
</div> </div>
</div> </div>
<div class="info" onclick="openLinks('account/changeName.php')"> <div class="info" onclick="openLinks('/account/changeName.php')">
<div class="line"></div> <div class="line"></div>
<div class="title"> <div class="title">
<h3>Name</h3> <h3>Name</h3>
@ -79,7 +79,7 @@
<i class="far fa-angle-right fa-lg"></i> <i class="far fa-angle-right fa-lg"></i>
</div> </div>
</div> </div>
<div class="info" onclick="openLinks('account/changeGender.php')"> <div class="info" onclick="openLinks('/account/changeGender.php')">
<div class="line"></div> <div class="line"></div>
<div class="title"> <div class="title">
<h3>Gender</h3> <h3>Gender</h3>
@ -96,7 +96,7 @@
<i class="far fa-angle-right fa-lg"></i> <i class="far fa-angle-right fa-lg"></i>
</div> </div>
</div> </div>
<div class="info" onclick="openLinks('account/changeCountry.php?cou=<?php if(isset($_SESSION['country'])) echo $_SESSION['country'][1]?>')"> <div class="info" onclick="openLinks('/account/changeCountry.php?cou=<?php if(isset($_SESSION['country'])) echo $_SESSION['country'][1]?>')">
<div class="line"></div> <div class="line"></div>
<div class="title"> <div class="title">
<h3>Country</h3> <h3>Country</h3>
@ -113,7 +113,7 @@
<i class="far fa-angle-right fa-lg"></i> <i class="far fa-angle-right fa-lg"></i>
</div> </div>
</div> </div>
<div class="info psw" onclick="openLinks('account/changePassword.php')"> <div class="info psw" onclick="openLinks('/account/changePassword.php')">
<div class="line"></div> <div class="line"></div>
<div class="title"> <div class="title">
<h3>Password</h3> <h3>Password</h3>
@ -164,6 +164,8 @@
</div> </div>
</main> </main>
<?php include '../add-ons/profileImg.php' ?>
<div class="fixed" id="overlay"></div> <div class="fixed" id="overlay"></div>
</body> </body>
</html> </html>

View file

@ -4,11 +4,15 @@
<div class="outter-container border-radius-50 pointer <?php if(!isset($_SESSION['id'])) echo 'disable'?>" id="outter-container"> <div class="outter-container border-radius-50 pointer <?php if(!isset($_SESSION['id'])) echo 'disable'?>" id="outter-container">
<div> <div>
<?php <?php
$path = '../';
if(strpos($_SERVER['REQUEST_URI'], 'search') || strpos($_SERVER['REQUEST_URI'], 'headlines')) $path = '';
if(!strpos($_SERVER['REQUEST_URI'], 'change')) $str = 'onclick="manageExtraProfileOptions()"'; if(!strpos($_SERVER['REQUEST_URI'], 'change')) $str = 'onclick="manageExtraProfileOptions()"';
else $str = ''; else $str = '';
if($_SESSION['profile_choice'] == 0) if($_SESSION['profile_choice'] == 0)
echo ('<div class="img small" '.$str.'><img src="'.$_SESSION['profile_img'].'" class="imga"></div>'); echo ('<div class="img small" '.$str.'><img src="'.$path.$_SESSION['profile_img'].'" class="imga"></div>');
else if($_SESSION['profile_choice'] == 1) else if($_SESSION['profile_choice'] == 1)
echo ('<div class="img small" '.$str.' style="background-color: '.$_SESSION['profile_color'].';"> echo ('<div class="img small" '.$str.' style="background-color: '.$_SESSION['profile_color'].';">
<div class="letter"> <div class="letter">
@ -47,20 +51,23 @@
<div class="img-middle"> <div class="img-middle">
<div> <div>
<?php <?php
$path = '../';
if(strpos($_SERVER['REQUEST_URI'], 'search') || strpos($_SERVER['REQUEST_URI'], 'headlines')) $path = '';
if($_SESSION['profile_choice'] == 0) if($_SESSION['profile_choice'] == 0)
echo ('<div class="img big" onclick="openLinks(\'account/home.php\')" ><img src="'.$_SESSION['profile_img'].'" class="imga"></div>'); echo ('<div class="img big" onclick="openLinks(\'/account/home.php\')" ><img src="'.$path.$_SESSION['profile_img'].'" class="imga"></div>');
else if($_SESSION['profile_choice'] == 1) else if($_SESSION['profile_choice'] == 1)
echo ('<div class="img big" onclick="openLinks(\'account/home.php\')" style="background-color: '.$_SESSION['profile_color'].';"> echo ('<div class="img big" onclick="openLinks(\'/account/home.php\')" style="background-color: '.$_SESSION['profile_color'].';">
<div class="letter"> <div class="letter">
<span>'.$_SESSION['letter'].'</span> <span>'.$_SESSION['letter'].'</span>
</div> </div>
</div>'); </div>');
else if($_SESSION['profile_choice'] == 2) else if($_SESSION['profile_choice'] == 2)
echo ('<div class="img big" onclick="openLinks(\'account/home.php\')"><img src="'.$_SESSION['google_profile_img'].'" class="imga"></div>'); echo ('<div class="img big" onclick="openLinks(\'/account/home.php\')"><img src="'.$_SESSION['google_profile_img'].'" class="imga"></div>');
else if($_SESSION['profile_choice'] == 3) else if($_SESSION['profile_choice'] == 3)
echo ('<div class="img big" onclick="openLinks(\'account/home.php\')"><img src="'.$_SESSION['facebook_profile_img'].'" class="imga"></div>'); echo ('<div class="img big" onclick="openLinks(\'/account/home.php\')"><img src="'.$_SESSION['facebook_profile_img'].'" class="imga"></div>');
else if($_SESSION['profile_choice'] == 4) else if($_SESSION['profile_choice'] == 4)
echo ('<div class="img big" onclick="openLinks(\'account/home.php\')"><img src="'.$_SESSION['github_profile_img'].'" class="imga"></div>'); echo ('<div class="img big" onclick="openLinks(\'/account/home.php\')"><img src="'.$_SESSION['github_profile_img'].'" class="imga"></div>');
?> ?>
</div> </div>
<div class="camera-container" onclick="showProfileImg()"> <div class="camera-container" onclick="showProfileImg()">
@ -80,13 +87,13 @@
<?php <?php
if(strpos($_SERVER['REQUEST_URI'], 'account')) if(strpos($_SERVER['REQUEST_URI'], 'account'))
echo '<div class="container" onclick="openLinks(\'headlines.php\')"> echo '<div class="container" onclick="openLinks(\'/headlines.php\')">
<span> <span>
Browse latest news articles Browse latest news articles
</span> </span>
</div>'; </div>';
else else
echo '<div class="container" onclick="openLinks(\'account/home.php\')"> echo '<div class="container" onclick="openLinks(\'/account/home.php\')">
<span> <span>
Manage your account Manage your account
</span> </span>

View file

@ -6,7 +6,7 @@
<div class="menu-burger-icon"> <div class="menu-burger-icon">
</div> </div>
</figure> </figure>
<a href="#" onclick="openLinks('headlines.php')" class="logo">Fews</a> <a href="#" onclick="openLinks('/headlines.php')" class="logo">Fews</a>
</div> </div>
<div class="nav-search flex align-center justify-center relative" id="navigation-bar-middle"> <div class="nav-search flex align-center justify-center relative" id="navigation-bar-middle">

View file

@ -1,5 +1,4 @@
<div class="main-img-container" id="main-img-container"> <div class="main-img-container disable" id="main-img-container">
<header> <header>
<h1>Change Profile Image</h1> <h1>Change Profile Image</h1>
</header> </header>
@ -20,23 +19,26 @@
</div> </div>
</div> </div>
</div> </div>
<section class="insert-photo-container" id="insert-photo-container" onclick="openFolder()"> <section class="insert-photo-container" id="insert-photo-container">
<div class="main-insert-photo-container"> <div class="main-insert-photo-container">
<div class="img-text"> <div class="img-text">
<p>Click on grey area and add image</p> <p>Click on grey area and add image</p>
</div> </div>
<div class="select-img"> <div><span class="error-span-upload-image red-color" id="error-span-upload-image"></span></div>
<div class="select-img" onclick="openFolder()">
<div class="icon"> <div class="icon">
<i class="fab fa-dropbox"></i> <i class="fab fa-dropbox"></i>
</div> </div>
</div> </div>
<div class="footer"> <div class="footer">
<div class="file-name"> <form action="include/uploadFile.inc.php" method="post" enctype="multipart/form-data" id="uploadProfileImageForm">
<span></span> <input type="file" hidden="hidden" id="file-upload" name="file" onChange='fileChange()'>
</div> </form>
<div class="button"> <div class="footer disable">
<div> <div class="name"><span class="image-name-label" id="image-name-label">Ime</span></div>
Upload <div class="button" onclick="submitProfileImageUploadForm()">
Submit
</div> </div>
</div> </div>
</div> </div>
@ -45,7 +47,9 @@
</section> </section>
<section class="color-img"> <section class="color-img">
<div class="img-text"> <div class="img-text">
<p>Select image from your computer or type in a link</p> <p>Select a color you like</p>
</div>
<div class="color-container">
</div> </div>
</section> </section>
<div class="x" onclick="showProfileImg()" > <div class="x" onclick="showProfileImg()" >

View file

@ -11,6 +11,7 @@
<link rel="stylesheet" href="CSS/*.css"> <link rel="stylesheet" href="CSS/*.css">
<link rel="stylesheet" href="CSS/index.css"> <link rel="stylesheet" href="CSS/index.css">
<link rel="stylesheet" href="CSS/responsive.css"> <link rel="stylesheet" href="CSS/responsive.css">
<link rel="shortcut icon" href="">
<script src="JS/variables.js" defer></script> <script src="JS/variables.js" defer></script>
<script src="JS/responsive.js" defer></script> <script src="JS/responsive.js" defer></script>
@ -32,36 +33,28 @@
<?php include 'add-ons/side-bar.php' ?> <?php include 'add-ons/side-bar.php' ?>
<section class="main-content-section grid" id="main-content-section">
<!-- <header id="main-content-header" class="header-main-content search">
<h1 class="search">Slovenia</h1>
<section>
<div>
<figure class="circle" onclick="saveSearchWord(this)">
<i class="fal fa-bookmark"></i>
</figure>
<figure class="rectangle" onclick="followSearchWord(this)">
<i class="fa fa-star"></i> Follow
</figure>
</div>
</section>
</header> -->
<!-- <figure id="main-content-container"> <section class="main-content-section single headlines" id="main-content-section">
<header id="main-content-header" class="section-main-header header-main-content"> <div class="main-content-container">
<h1>Headlines</h1> <div class="article-container">
<a href="#" class="blue-link flex" onclick="showCategoryNews()">Categories</a>
</header> <article class="news">
<article class="coronavirus-article grid article-other" id="coronavirus-article">
<a href="#" class="blue-link" id="coronavirus-article-a"> <div>
COVID-19 information: <h3>Hello World!</h3>
<span> See the lates coverage of coronavirus</span> <div>
</a>
<i class="fas fa-chevron-right corona-arrow pointer"></i> </div>
<div class="subtitle">
</div>
</div>
</article> </article>
</figure> --> </div>
<!-- <aside id="main-side-content-container">
<aside id="main-side-content-container">
<article class="weather-article grid relative"> <article class="weather-article grid relative">
<header class="weather-main-header grid"> <header class="weather-main-header grid">
<img src="" alt="" class="flex align-center justify-center"> <img src="" alt="" class="flex align-center justify-center">
@ -116,9 +109,31 @@
</section> </section>
</footer> </footer>
</article> </article>
</aside> --> </aside>
</div>
</section> </section>
<!-- <section class="main-content-section grid" id="main-content-section">
<header id="main-content-header" class="header-main-content search">
<h1 class="search">Headlines</h1>
</header> -->
<!-- <figure id="main-content-container">
<header id="main-content-header" class="section-main-header header-main-content">
<h1>Headlines</h1>
<a href="#" class="blue-link flex" onclick="showCategoryNews()">Categories</a>
</header>
<article class="coronavirus-article grid article-other" id="coronavirus-article">
<a href="#" class="blue-link" id="coronavirus-article-a">
COVID-19 information:
<span> See the lates coverage of coronavirus</span>
</a>
<i class="fas fa-chevron-right corona-arrow pointer"></i>
</article>
</figure> -->
</main> </main>
<?php include 'add-ons/navigation-bar.php' ?> <?php include 'add-ons/navigation-bar.php' ?>

View file

@ -15,3 +15,20 @@
} }
} }
// class Dbh {
// private $host = '';
// private $dbName = 'niktople_Fews';
// private $user = 'niktople_nik';
// private $pwd = 'niktopler2002';
// private $charset = 'utf8mb4';
// protected function connect() {
// $dsn = 'mysql:host=' .$this->host. ';dbname=' .$this->dbName. ';charset=' .$this->charset ;
// $pdo = new PDO($dsn, $this->user, $this->pwd);
// $pdo->setAttribute(PDO::ATTR_DEFAULT_FETCH_MODE, PDO::FETCH_ASSOC);
// return $pdo;
// }
// }

View file

@ -1,7 +0,0 @@
<?php session_start();
echo $_SERVER['REQUEST_URI'];
if(isset($_SESSION['user_id'])) {
}

View file

@ -98,6 +98,54 @@ class update extends Dbh {
} else return 'wrong password'; } else return 'wrong password';
} }
public function addAdmin($email) {
if($this->checkIfUserExists($email) == 0) die;
$sql = "INSERT INTO admins(user_id) VALUES((SELECT id FROM users WHERE email = ?))";
$stmt = $this->connect()->prepare($sql);
$stmt->execute([$email]);
echo 'success';
}
public function checkIfUserExists($email) {
$sql = "SELECT * FROM users WHERE email = ?";
$stmt = $this->connect()->prepare($sql);
$stmt->execute([$email]);
$row = $stmt->fetch();
if($row) return 1;
else return 0;
}
public function removeAdmin($email) {
if($this->checkIfUserExists($email) == 0) die;
$sql = "DELETE FROM admins WHERE user_id = (SELECT id FROM users WHERE email = ?)";
$stmt = $this->connect()->prepare($sql);
$stmt->execute([$email]);
echo 'success';
}
public function imageUpload($info) {
if($info[0] == '0') {
$name = "profile_img";
$num = 0;
}
$this->checkForImage();
$sql = "UPDATE users SET profile_choice = ? WHERE email = ?";
$stmt = $this->connect()->prepare($sql);
$stmt->execute([$num, $_SESSION['email']]);
$sql = "UPDATE users SET ".$name." = ? WHERE email = ?";
$stmt = $this->connect()->prepare($sql);
$stmt->execute([$info[1], $_SESSION['email']]);
$this->setSessionVariables($_SESSION['email']);
echo 'success';
}
public function checkForImage() {
$sql = 'SELECT * FROM users WHERE email = ?';
$stmt = $this->connect()->prepare($sql);
$stmt->execute([$_SESSION['email']]);
$row = $stmt->fetch();
if($row['profile_select'] == 0 && $row['profile_img'] != null) unlink('../'.$row['profile_img']);
}
} }
$updateObj = new Update(); $updateObj = new Update();
@ -108,3 +156,7 @@ else if(isset($_POST['gender'])) $updateObj->gender(json_decode($_POST['gender']
else if(isset($_POST['country'])) $updateObj->country(json_decode($_POST['country'])); else if(isset($_POST['country'])) $updateObj->country(json_decode($_POST['country']));
else if(isset($_POST['newPsw'])) $updateObj->newPsw(json_decode($_POST['newPsw'])); else if(isset($_POST['newPsw'])) $updateObj->newPsw(json_decode($_POST['newPsw']));
else if(isset($_POST['oldPsw'])) $updateObj->oldPsw(json_decode($_POST['oldPsw'])); else if(isset($_POST['oldPsw'])) $updateObj->oldPsw(json_decode($_POST['oldPsw']));
else if(isset($_POST['addAdmin'])) $updateObj->addAdmin($_POST['addAdmin']);
else if(isset($_POST['removeAdmin'])) $updateObj->removeAdmin($_POST['removeAdmin']);
else if(isset($_POST['imageUpload'])) $updateObj->imageUpload(json_decode($_POST['imageUpload']));

View file

@ -0,0 +1,38 @@
<?php
if($_SERVER['REQUEST_METHOD'] === 'POST') {
$file = $_FILES['file'];
$fileName = $_FILES['file']['name'];
$fileTmpName = $_FILES['file']['tmp_name'];
$fileSize = $_FILES['file']['size'];
$fileError = $_FILES['file']['error'];
$fileType = $_FILES['file']['type'];
$fileExt = explode('.', $fileName);
$fileActuallExt = strtolower(end($fileExt));
$allow = ['jpeg','jpg','png'];
if(in_array($fileActuallExt,$allow)){
if($fileError === 0){
if($fileSize <= 1000000){
$fileNewName = uniqid('',true).'.'.$fileActuallExt;
$fileDestination = 'Images/'.$fileNewName;
move_uploaded_file($fileTmpName,'../Images/'.$fileNewName);
$array = [$fileNewName, $fileDestination];
echo $array[0].' '.$array[1];
} else echo 'too big';
} else echo 'error';
} else echo 'extension not allowed';
} else header('location: ../index.php');

View file

@ -11,6 +11,7 @@
<link rel="stylesheet" href="CSS/*.css"> <link rel="stylesheet" href="CSS/*.css">
<link rel="stylesheet" href="CSS/index.css"> <link rel="stylesheet" href="CSS/index.css">
<link rel="stylesheet" href="CSS/responsive.css"> <link rel="stylesheet" href="CSS/responsive.css">
<link rel="shortcut icon" href="">
<script src="JS/variables.js" defer></script> <script src="JS/variables.js" defer></script>
<script src="JS/responsive.js" defer></script> <script src="JS/responsive.js" defer></script>

View file

@ -9,6 +9,7 @@
<link rel="stylesheet" href="CSS/*.css"> <link rel="stylesheet" href="CSS/*.css">
<link rel="stylesheet" href="CSS/signin.css"> <link rel="stylesheet" href="CSS/signin.css">
<link rel="stylesheet" href="CSS/responsive.css"> <link rel="stylesheet" href="CSS/responsive.css">
<link rel="shortcut icon" href="">
<script src="JS/responsive.js" defer></script> <script src="JS/responsive.js" defer></script>
<script src="JS/signIn/signin.js" defer></script> <script src="JS/signIn/signin.js" defer></script>

View file

@ -9,6 +9,7 @@
<link rel="stylesheet" href="CSS/*.css"> <link rel="stylesheet" href="CSS/*.css">
<link rel="stylesheet" href="CSS/signup.css"> <link rel="stylesheet" href="CSS/signup.css">
<link rel="stylesheet" href="CSS/responsive.css"> <link rel="stylesheet" href="CSS/responsive.css">
<link rel="shortcut icon" href="">
<script src="JS/responsive.js" defer></script> <script src="JS/responsive.js" defer></script>
<script src="JS/signIn/signup.js" defer></script> <script src="JS/signIn/signup.js" defer></script>