Server : LiteSpeed System : Linux us-phx-web1202.main-hosting.eu 4.18.0-553.84.1.lve.el8.x86_64 #1 SMP Tue Nov 25 18:33:03 UTC 2025 x86_64 User : u615232177 ( 615232177) PHP Version : 8.1.33 Disable Function : NONE Directory : /home/u615232177/domains/adesmiley.com/public_html/admin41345/ |
<?php session_start();
$page_name = basename($_SERVER['PHP_SELF']);
include("headerstrict.php"); ?>
<link href="https://stackpath.bootstrapcdn.com/bootstrap/3.4.1/css/bootstrap.min.css" rel="stylesheet">
<script src="https://code.jquery.com/jquery-3.5.1.min.js"></script>
<script src="https://stackpath.bootstrapcdn.com/bootstrap/3.4.1/js/bootstrap.min.js"></script>
<link href="https://cdn.jsdelivr.net/npm/summernote@0.8.18/dist/summernote.min.css" rel="stylesheet">
<script src="https://cdn.jsdelivr.net/npm/summernote@0.8.18/dist/summernote.min.js"></script>
<script src="https://cdn.jsdelivr.net/gh/perevoshchikov/summernote-grid@1.0.0/summernote-grid.min.js"></script>
<script>
$(document).ready(function() {
$('#summernote').summernote({
toolbar:[
['style', ['style']],
['font', ['bold', 'underline', 'clear']],
['color', ['color']],
['para', ['ul', 'ol', 'paragraph']],
['table', ['table']],
['insert', ['link', 'picture', 'video']],
['view', ['fullscreen', 'codeview', 'help']],
['insert', ['grid']]
],
grid: {
wrapper: "row",
columns: [
"col-md-12",
"col-md-6",
"col-md-4",
"col-md-3",
]
},
callbacks: {
onGridInsert: null
},
icons: {
grid: "glyphicon glyphicon-th"
}
});
});
</script>
<title><?php echo $company_name; ?>, Admin, Articles</title>
<?php
if (isset($_GET['u'])){
$id = mysqli_real_escape_string($con,$_GET['u']);
$stmt = $con -> prepare('SELECT * FROM articles WHERE id=?');
$stmt -> bind_param('s',$id);
$stmt -> execute();
$stmt -> store_result();
$stmt -> bind_result($id,$article_id,$title,$category_id,$preamble,$paragraph,$picture,$featured,$date,$keywordss,$comments_allowed);
$numrows = $stmt -> num_rows();
if($numrows > 0){
while ($stmt -> fetch()) { }
}
$stmtt = $con -> prepare('SELECT * FROM categories WHERE id=?');
$stmtt -> bind_param('s',$category_id);
$stmtt -> execute();
$stmtt -> store_result();
$stmtt -> bind_result($category_id_db,$category_name_db);
while ($stmtt -> fetch()){
}
}
else{echo "<meta http-equiv=\"refresh\" content=\"0; url=adminhome.php\">";exit();}
if (isset($_POST['add_gallery'])) {
if( ($_FILES["file"]["type"]=="") == false ){
$random_id = substr(md5(rand()), 0, 20);
$extension = pathinfo($_FILES["file"]["name"], PATHINFO_EXTENSION);
move_uploaded_file( $_FILES['file']['tmp_name'], "assets/img/gallery/$random_id.$extension");
$picturegall ="$random_id.$extension";
}
$db_id=0;
$stmt = $con -> prepare('INSERT INTO gallery VALUES (?,?,?)');
$stmt -> bind_param('iss', $db_id,$article_id,$picturegall);
$stmt -> execute();
//create a session to verify it's coming from here
$_SESSION["action"] = "true";
$message="Picture successfully added.";
echo "<meta http-equiv=\"refresh\" content=\"0; url=success.php?u=$page_name?u=$id&m=$message\">";
}
?>
<!-- ======= Breadcrumbs ======= -->
<section id="breadcrumbs" class="breadcrumbs">
<div class="container"> </div>
</section>
<!-- End Breadcrumbs -->
<!-- ======= Contact Section ======= -->
<section id="contact" class="contact inner-page">
<div class="container" data-aos="fade-up">
<div class="section-title">
<h2><?php echo $title; ?></h2>
<p></p>
</div>
<div class="row">
<div class='col-md-2'></div>
<?php
echo"
<div class='col-md-8'>
<form action='article_details.php?u=$id' method='post' enctype='multipart/form-data' class='php-email-form1'>
<h2>Article Details</h2>
<div class='form-row'>
<div class='form-group col-md-12'>
<input type='text' name='title' class='form-control' placeholder='Title' value='$title' required />
</div>
<div class='form-group col-md-12'>
<select name='category' class='form-control' required>
<option value='$category_id_db'>$category_name_db</option>";
$stmt = $con -> prepare('SELECT * FROM categories');
$stmt -> execute();
$stmt -> store_result();
$stmt -> bind_result($category_id,$category_name);
$numrows = $stmt -> num_rows();
if($numrows > 0){
while ($stmt -> fetch()) {
echo"
<option value='$category_id'>$category_name</option>
";
}
}
else{echo"<option value=''>Please add a <a href='categories.php'>category</a> first</option>";}
echo"
</select>
</div>
<div class='form-group col-md-12'>
<textarea style='' name='preamble' class='form-control' placeholder='Preamble'>$preamble</textarea>
</div>
<div class='form-group col-md-12'>
<textarea style='' name='paragraph' class='form-control' id='summernote' >$paragraph</textarea>
</div>
</div>
<div class='form-row'>
<div class='form-group col-md-12'>
<label>Featured</label>
<select class='form-control' name='featured' required>
<option selected value='$featured'>$featured</option>
<option value='Yes'>Yes</option>
<option value='No'>No</option>
</select>
</div>
</div>
<div class='form-row'>
<div class='form-group col-md-12'>
<label>Comments Allowed</label>
<select class='form-control' name='comments_allowed' required>
<option selected value='$comments_allowed'>$comments_allowed</option>
<option value='Yes'>Yes</option>
<option value='No'>No</option>
</select>
</div>
</div>
<div class='form-row'>
<div class='form-group col-md-12'>
<img style='width:100%;border-radius:5px;'src='assets/img/articles/$picture' class='img-fluid' alt=''>
<input type='file' name='fileField' class='form-control'/>
</div>
</div>
<div class='form-group col-md-12'>
<div class='text-center' style='position:relative;top:-19px;'>
<button type='submit' name='update$id'>Update</button>
<button type='submit' name='delete$id'>Delete</button>
</div>
</div>
</form>
</div>
";
if (isset($_POST["update$id"])) {
$title = mysqli_real_escape_string($con,$_POST['title']);
$category = mysqli_real_escape_string($con,$_POST['category']);
$paragraph = $_POST['paragraph'];
$preamble = mysqli_real_escape_string($con,$_POST['preamble']);
$featured = mysqli_real_escape_string($con,$_POST['featured']);
$comments_allowed = mysqli_real_escape_string($con,$_POST['comments_allowed']);
$keywords ="$title $category";
if( ($_FILES["fileField"]["type"]=="") == false ){
unlink("assets/img/articles/$picture");
$random_id = substr(md5(rand()), 0, 20);
$extension = pathinfo($_FILES["fileField"]["name"], PATHINFO_EXTENSION);
move_uploaded_file( $_FILES['fileField']['tmp_name'], "assets/img/articles/$random_id.$extension");
$picture ="$random_id.$extension";
}
$stmt = $con -> prepare('UPDATE articles SET title = ?,category =?,preamble=?,paragraph=?,picture=?,featured=?,comments_allowed=?,keywords=? WHERE id = ?');
$stmt -> bind_param('ssssssssi', $title,$category,$preamble,$paragraph,$picture,$featured,$comments_allowed,$keywords,$id);
$stmt -> execute();
//create a session to verify it's coming from here
$_SESSION["action"] = "true";
$message="Update was successfully done.";
echo "<meta http-equiv=\"refresh\" content=\"0; url=success.php?u=$page_name?u=$id&m=$message\">";
}
if (isset($_POST["delete$id"])) {
$stmt = $con -> prepare('DELETE FROM articles WHERE id = ?');
$stmt -> bind_param('i', $id);
$stmt -> execute();
unlink("assets/img/articles/$picture");
//create a session to verify it's coming from here
$_SESSION["action"] = "true";
$message="Item successfully deleted.";
echo "<meta http-equiv=\"refresh\" content=\"0; url=success.php?u=articles.php&m=$message\">";
}
?>
<!--<div class='col-md-3'></div>
<div class="col-lg-6 mt-5 mt-lg-0 d-flex align-items-stretch">
<form action="<?php echo htmlspecialchars($_SERVER["PHP_SELF"]);?><?php echo"?u=$id"; ?>" method="post" class="php-email-form1" enctype='multipart/form-data'>
<h2>Add a picture</h2>
<div class="form-row">
<div class="form-group col-md-12">
<input type='file' name='file' class="form-control" required />
</div>
</div>
<div class="text-center">
<button type="submit" name='add_gallery'>Save</button>
</div>
</form>
</div>
<div class='col-md-3'></div>-->
</div><!-- end row -->
<h2><!--Uploaded Pictures--></h2>
<div class='row'>
<?php
$sql = "SELECT COUNT(id) FROM gallery WHERE article_id='$article_id' ORDER BY id DESC";
$query = mysqli_query($con, $sql);
$row = mysqli_fetch_row($query);
//here we have the total row count
$rows = $row[0];
//number of results we want per page
$page_rows = 128;
//tells us the page number of our last page
$last = ceil($rows/$page_rows);
//this makes sure last cannot be less than 1
if($last < 1){$last = 1;}
//establish the page num variable
$pagenum = 1;
//Get pageum from $GET if it is present, else its 1
if(isset($_GET['pn'])){
$pagenum = preg_replace('#[^0-9]#', '', $_GET['pn']);
}
//below 1 or more than last page
if($pagenum < 1){
$pagenum = 1;
}else if ($pagenum > $last) {
$pagenum = $last;
}
//this sets the range of rows to query for the chosen pagenum
$limit = 'LIMIT ' .($pagenum - 1) * $page_rows .',' .$page_rows;
//grabs one page worth of rows
$sql = "SELECT * FROM gallery WHERE article_id='$article_id' ORDER BY id DESC $limit ";
$query = mysqli_query($con, $sql);
//this shows the user what page they on and total number
$textline1 = "Messages $rows";
$textline2 = "Page $pagenum of $last";
//establish the pagination controls
$paginationCtrls = "";
//if there is more than one page worth of results
if($last != 1){
if($pagenum > 1){
$previous = $pagenum - 1;
//$paginationCtrls .='<a href="'.$_SERVER['PHP_SELF'].'?pn='.$previous.'">Previous</a>  ';
$paginationCtrls .="
<a href=".$_SERVER['PHP_SELF']."?pn=$previous> Prev </a>";
//render clickable links to the left of target page number
for($i = $pagenum-4; $i < $pagenum; $i++){
if($i > 0){
//$paginationCtrls .= '<a href="'.$_SERVER['PHP_SELF'].'?pn='.$i.'"></a> ';
$paginationCtrls .= "<a href='".$_SERVER['PHP_SELF']."'?pn=$i> $i </a>";
}
}
}
//render target number bt not link
//$paginationCtrls .= ''.$pagenum.' ';
$paginationCtrls .= "<a href='#'>$pagenum</a>";
//render clickable number links to the right of target number
for($i = $pagenum+1; $i <= $last; $i++){
//$paginationCtrls .= '<a href="'.$_SERVER['PHP_SELF'].'?pn='.$i.'">'.$i.'</a> ';
$paginationCtrls .= "<a href='".$_SERVER['PHP_SELF']."'?pn=$i> $i </a>";
if($i >= $pagenum+4){
break;
}
}
//this does the same as above, only checking if we are on the last page
if($pagenum != $last) {
$next = $pagenum + 1;
$paginationCtrls .= "<a href='".$_SERVER['PHP_SELF']."'?pn=$next> Next </a> ";
}
}
if(mysqli_num_rows($query) > 0 ){
while ($row_ads = mysqli_fetch_array($query, MYSQLI_ASSOC)) {
$picid = $row_ads['id'];
$picture = $row_ads['picture'];
echo"
<div class='col-md-4'>
<form action='";?><?php echo htmlspecialchars($_SERVER["PHP_SELF"]);?><?php echo"?u=$id' method='post'class='php-email-form1'enctype='multipart/form-data'>
<div class='form-row'>
<div class='form-group col-md-12'>
<img style='width:100%;border-radius:5px;'src='assets/img/gallery/$picture' class='img-fluid' alt=''>
<input type='file' name='file' class='form-control'/>
</div>
</div>
<input type='text' id='myInput$picid' style='opacity:0;' class='form-control' value='$link/$admin_no/assets/img/gallery/$picture' readonly='readonly'>
<div class='text-center'><br/>
<button type='submit' name='updatepic$picid'>Update</button>
<button type='submit' name='deletepic$picid'>Delete</button>
</div>
</form>
<div class='text-center outside_button'>
<button onclick='copy$picid()'>Copy Link</button>
</div>
</div>
";
if (isset($_POST["updatepic$picid"])) {
$heading = mysqli_real_escape_string($con,$_POST['heading']);
$galparagraph = mysqli_real_escape_string($con,$_POST['galparagraph']);
if( ($_FILES["file"]["type"]=="") == false ){
unlink("assets/img/gallery/$picture");
$random_id = substr(md5(rand()), 0, 20);
$extension = pathinfo($_FILES["file"]["name"], PATHINFO_EXTENSION);
move_uploaded_file( $_FILES['file']['tmp_name'], "assets/img/gallery/$random_id.$extension");
$picturegall ="$random_id.$extension";
}
$stmt = $con -> prepare('UPDATE gallery SET picture=? WHERE id = ?');
$stmt -> bind_param('si',$picturegall,$picid);
$stmt -> execute();
//create a session to verify it's coming from here
$_SESSION["action"] = "true";
$message="Update was successfully done.";
echo "<meta http-equiv=\"refresh\" content=\"0; url=success.php?u=$page_name?u=$id&m=$message\">";
}
if (isset($_POST["deletepic$picid"])) {
$stmt = $con -> prepare('DELETE FROM gallery WHERE id = ?');
$stmt -> bind_param('i', $picid);
$stmt -> execute();
unlink("assets/img/gallery/$picture");
//create a session to verify it's coming from here
$_SESSION["action"] = "true";
$message="Picture successfully deleted.";
echo "<meta http-equiv=\"refresh\" content=\"0; url=success.php?u=$page_name?u=$id&m=$message\">";
}
?>
<!-- each picture gets its own copy link javascript snippet-->
<script>
function copy<?php echo $picid; ?>() {
var copyText = document.getElementById('myInput<?php echo $picid; ?>');
copyText.select();
copyText.setSelectionRange(0, 99999)
document.execCommand("copy");
alert("Link Copied: " + copyText.value);
}
</script>
<?php
}//end of while
}
else{//echo"No pictures are available at this time.";
}
?>
</div>
<br/></br>
<h2>Comments</h2>
<div class='row'>
<?php
$sql = "SELECT COUNT(id) FROM comments WHERE article_id='$article_id' ORDER BY id DESC";
$query = mysqli_query($con, $sql);
$row = mysqli_fetch_row($query);
//here we have the total row count
$rows = $row[0];
//number of results we want per page
$page_rows = 128;
//tells us the page number of our last page
$last = ceil($rows/$page_rows);
//this makes sure last cannot be less than 1
if($last < 1){$last = 1;}
//establish the page num variable
$pagenum = 1;
//Get pageum from $GET if it is present, else its 1
if(isset($_GET['pn'])){
$pagenum = preg_replace('#[^0-9]#', '', $_GET['pn']);
}
//below 1 or more than last page
if($pagenum < 1){
$pagenum = 1;
}else if ($pagenum > $last) {
$pagenum = $last;
}
//this sets the range of rows to query for the chosen pagenum
$limit = 'LIMIT ' .($pagenum - 1) * $page_rows .',' .$page_rows;
//grabs one page worth of rows
$sql = "SELECT * FROM comments WHERE article_id='$article_id' ORDER BY id DESC $limit ";
$query = mysqli_query($con, $sql);
//this shows the user what page they on and total number
$textline1 = "Messages $rows";
$textline2 = "Page $pagenum of $last";
//establish the pagination controls
$paginationCtrls = "";
//if there is more than one page worth of results
if($last != 1){
if($pagenum > 1){
$previous = $pagenum - 1;
//$paginationCtrls .='<a href="'.$_SERVER['PHP_SELF'].'?pn='.$previous.'">Previous</a>  ';
$paginationCtrls .="
<a href=".$_SERVER['PHP_SELF']."?pn=$previous> Prev </a>";
//render clickable links to the left of target page number
for($i = $pagenum-4; $i < $pagenum; $i++){
if($i > 0){
//$paginationCtrls .= '<a href="'.$_SERVER['PHP_SELF'].'?pn='.$i.'"></a> ';
$paginationCtrls .= "<a href='".$_SERVER['PHP_SELF']."'?pn=$i> $i </a>";
}
}
}
//render target number bt not link
//$paginationCtrls .= ''.$pagenum.' ';
$paginationCtrls .= "<a href='#'>$pagenum</a>";
//render clickable number links to the right of target number
for($i = $pagenum+1; $i <= $last; $i++){
//$paginationCtrls .= '<a href="'.$_SERVER['PHP_SELF'].'?pn='.$i.'">'.$i.'</a> ';
$paginationCtrls .= "<a href='".$_SERVER['PHP_SELF']."'?pn=$i> $i </a>";
if($i >= $pagenum+4){
break;
}
}
//this does the same as above, only checking if we are on the last page
if($pagenum != $last) {
$next = $pagenum + 1;
$paginationCtrls .= "<a href='".$_SERVER['PHP_SELF']."'?pn=$next> Next </a> ";
}
}
if(mysqli_num_rows($query) > 0 ){
while ($row_ads1 = mysqli_fetch_array($query, MYSQLI_ASSOC)) {
$commentid = $row_ads1['id'];
$name = $row_ads1['name'];
$email = $row_ads1['email'];
$comment = $row_ads1['comment'];
$display = $row_ads1['display'];
$date = $row_ads1['date'];
echo"
<div class='col-md-4'>
<form action='";?><?php echo htmlspecialchars($_SERVER["PHP_SELF"]);?><?php echo"?u=$id' method='post'class='php-email-form1'enctype='multipart/form-data'>
<div class='form-row'>
<div class='form-group'>
Name - $name<br/>
Email - $email<br/>
Date - $date
</div>
<div class='form-group col-md-12'>
<textarea style='' name='' class='form-control' id='' readonly >$comment</textarea>
</div>
</div>
<div class='form-row'>
<div class='form-group col-md-12'>
<label>Display Comment</label>
<select class='form-control' name='display' required>
<option selected value='$display'>$display</option>
<option value='Yes'>Show</option>
<option value='No'>Hide</option>
</select>
</div>
</div>
<div class='text-center'><br/>
<button type='submit' name='updatecom$commentid'>Update</button>
<button type='submit' name='deletecom$commentid'>Delete</button>
</div>
</form>
</div>
";
if (isset($_POST["updatecom$commentid"])) {
$display = mysqli_real_escape_string($con,$_POST['display']);
$stmt = $con -> prepare('UPDATE comments SET display=? WHERE id = ?');
$stmt -> bind_param('si',$display,$commentid);
$stmt -> execute();
//create a session to verify it's coming from here
$_SESSION["action"] = "true";
$message="Update was successfully done.";
echo "<meta http-equiv=\"refresh\" content=\"0; url=success.php?u=$page_name?u=$id&m=$message\">";
}
if (isset($_POST["deletecom$commentid"])) {
$stmt = $con -> prepare('DELETE FROM comments WHERE id = ?');
$stmt -> bind_param('i', $commentid);
$stmt -> execute();
//create a session to verify it's coming from here
$_SESSION["action"] = "true";
$message="Item successfully deleted.";
echo "<meta http-equiv=\"refresh\" content=\"0; url=success.php?u=$page_name?u=$id&m=$message\">";
}
}//end of while
}
else{echo"No comments are available at this time.";}
?>
</div>
</div>
</section><!-- End Contact Section -->
<!-- ======= Footer ======= -->
<footer id="footer" style='background:;'>
<div class="container footer-bottom clearfix">
<div class="copyright">
© Copyright <script>document.write(new Date().getFullYear());</script> <strong><span><?php echo $company_name; ?></span></strong>. All Rights Reserved
</div>
<div class="credits">
</div>
</div>
</footer><!-- End Footer -->
<a href="#" class="back-to-top"><i class="ri-arrow-up-line"></i></a>
<div id="preloader"style='background:<?php echo $t_cr; ?>;'></div>
<!-- Vendor JS Files -->
<script src="assets/vendor/bootstrap/js/bootstrap.bundle.min.js"></script>
<script src="assets/vendor/jquery.easing/jquery.easing.min.js"></script>
<script src="assets/vendor/php-email-form/validate.js"></script>
<script src="assets/vendor/waypoints/jquery.waypoints.min.js"></script>
<script src="assets/vendor/isotope-layout/isotope.pkgd.min.js"></script>
<script src="assets/vendor/venobox/venobox.min.js"></script>
<script src="assets/vendor/owl.carousel/owl.carousel.min.js"></script>
<script src="assets/vendor/aos/aos.js"></script>
<!-- Template Main JS File -->
<script src="assets/js/main.js"></script>
</body>
</html>