<?php
session_start();
include __DIR__ . '/config/connect.php';
include __DIR__ . '/function.php';
if(isset($_POST['beichtid'])) :
if(is_numeric($_POST['beichtid'])) :
$id = filter_var($_POST['beichtid'], FILTER_SANITIZE_NUMBER_INT);
$counter = filter_var($_POST['counter'], FILTER_SANITIZE_NUMBER_INT);
if(!isset($counter)) {
$counter = 5;
}
if($stmt = $pdo->prepare("
SELECT
`user`.`id` AS user_ident,
`user`.`username`,
`user`.`name`,
`user`.`nachname`,
`user`.`image`,
`user`.`private`,
`comments`.`k_id`,
`comments`.`p_id`,
`comments`.`u_id`,
`comments`.`comment`,
`comments`.`date_comment`,
`u_post_likes_comment`.`id`,
`u_post_likes_comment`.`user` AS users,
`u_post_likes_comment`.`post_id`,
`u_post_likes_comment`.`date`
FROM `u_post_likes_comment`
LEFT JOIN `user`
ON `u_post_likes_comment`.`user` = `user`.`id`
LEFT JOIN `comments`
ON `u_post_likes_comment`.`post_id` = `comments`.`p_id`
WHERE `u_post_likes_comment`.`post_id` = :id LIMIT $counter;")) {
$stmt->BindParam(':id', $id);
if(!$stmt->execute()) {
print_r($stmt->errorInfo());
} else {
$count = $stmt->rowCount();
?>
<div class="header-flex">
<?php
while($row = $stmt->fetch(PDO::FETCH_ASSOC)) :
<?php
if($check_if_follow = $pdo->prepare("
SELECT
`follow`.`id`,
`follow`.`user_id`,
`follow`.`follow_id`
FROM `follow`
WHERE `follow`.`follow_id` = :user AND `follow`.`user_id` = :sid LIMIT 1;")) {
$check_if_follow->BindParam(':user', $row['user_ident']);
$check_if_follow->BindParam(':sid', $_SESSION['id']);
if(!$check_if_follow->execute()) {
print_r($check_if_follow->errorInfo());
}
$if_followed = $check_if_follow->rowCount();
}
?>
<?php
if($private = $pdo->prepare("
SELECT
`user`.`id`,
`user`.`username`,
`follow`.`user_id`,
`follow`.`follow_id`,
`follow`.`process`
FROM `follow`
LEFT JOIN `user`
ON `follow`.`user_id` = `user`.`id`
WHERE `follow`.`user_id` = :user_id AND `follow`.`follow_id` = :foll AND `process` = 0;")) {
$private->BindParam(':user_id', $_SESSION['id']);
$private->BindParam(':foll', $row['user_ident']);
if(!$private->execute()) {
print_r($private->errorInfo());
}
$countprivate = $private->rowCount();
}
?>
<?php
if($private2 = $pdo->prepare("
SELECT
`user`.`id`,
`user`.`username`,
`follow`.`user_id`,
`follow`.`follow_id`
FROM `follow`
LEFT JOIN `user`
ON `follow`.`user_id` = `user`.`id`
WHERE `follow`.`user_id` = :user_id AND `follow`.`follow_id` = :foll;")) {
$private2->BindParam(':user_id', $_SESSION['id']);
$private2->BindParam(':foll', $row['user_ident']);
if(!$private2->execute()) {
print_r($private2->errorInfo());
}
$countprivate2 = $private2->rowCount();
}
?>
<div class="box-auf">
<div class="top">
<p class="left-aufrufe">
<img class="aufrufe-img" src="<?php if($row['image'] != '') { echo htmlspecialchars($row['image'], ENT_QUOTES, 'UTF-8'); } else { echo 'img/no.png'; } ?>" alt="">
<span>
<a href="user.php?u=<?= $row['user_ident']; ?>" class="uname"><?= htmlspecialchars($row['username'], ENT_QUOTES, 'UTF-8'); ?></a> </span>
</p>
<p class="right-aufrufe">
<?php if($_SESSION['id'] !== $row['user_ident']): ?>
<?php if($if_followed > 0) { ?>
<?php if($countprivate > 0 && $row['private'] == '1' || $countprivate2 === 0 && $row['private'] == '1') { ?>
<a href="like.php?type=do_not_follow_anymore&id=<?php echo htmlspecialchars($row['user_ident'], ENT_QUOTES, 'UTF-8'); ?>" name="follow" class="follow_me_private is_antrag">Anfrage löschen</a>
<?php } else { ?>
<a href="like.php?type=do_not_follow_anymore&id=<?php echo htmlspecialchars($row['user_ident'], ENT_QUOTES, 'UTF-8'); ?>" name="follow" class="follow_me is_abo">Abboniert</a>
<?php } ?>
<?php } else { ?>
<?php if($countprivate > 0 && $row['private'] == '1' || $countprivate2 === 0 && $row['private'] == '1') { ?>
<a href="like.php?type=follow_by_private&id=<?php echo htmlspecialchars($row['user_ident'], ENT_QUOTES, 'UTF-8'); ?>" name="follow" class="follow_me_private">Folgen</a>
<?php } else { ?>
<a href="like.php?type=folg_user_by_comment&id=<?php echo htmlspecialchars($row['user_ident'], ENT_QUOTES, 'UTF-8'); ?>" name="follow" class="follow_me">Folgen</a>
<?php } ?>
<?php } ?>
<?php endif; ?>
</p>
</div>
</div>
<?php
endwhile;
?>
</div>
<?php
}
}
?>
<script>
$(document).ready(function() {
$('.follow_me').on('click', follow)
$('.follow_me_private').on('click', follow_private)
function follow(e) {
e.preventDefault()
var link = $(this)
var href = $(this).attr('href')
var isabo = $(this).hasClass('is_abo')
$.get(href, function(data) {
if(isabo) {
link.removeClass('is_abo')
link.html('Folgen')
href = href.replace('do_not_follow_anymore', 'folg_user_by_comment')
} else {
link.addClass('is_abo')
link.html('Abboniert')
href = href.replace('folg_user_by_comment', 'do_not_follow_anymore')
}
link.attr('href', href)
})
}
function follow_private(e) {
e.preventDefault()
var link = $(this)
var href = $(this).attr('href')
var is_antrag = $(this).hasClass('is_antrag')
$.get(href, function(data) {
if(is_antrag) {
link.removeClass('is_antrag')
link.html('Folgen')
href = href.replace('do_not_follow_anymore', 'follow_by_private')
} else {
link.addClass('is_antrag')
link.html('Antrag löschen')
href = href.replace('follow_by_private', 'do_not_follow_anymore')
}
link.attr('href', href)
})
}
})
</script>
<?php
if($counter > 5) {
if($counter >= $count) {
?>
<section class="info-aufrufe" style="opacity:0.2;">
<p><strong>Info:</strong> Das waren alle User.</p>
</section>
<script>
$('.info-aufrufe').animate({"opacity":"+=0.8"});
$('.info-aufrufe').delay(1000).fadeOut(2000);
</script>
<?php
}
}
endif;
endif;
?>
Alles anzeigen