Server IP : 51.89.169.208 / Your IP : 18.216.230.65 Web Server : Apache System : Linux ns3209505.ip-198-244-202.eu 4.18.0-553.27.1.el8_10.x86_64 #1 SMP Tue Nov 5 04:50:16 EST 2024 x86_64 User : yellowleaf ( 1019) PHP Version : 7.4.33 Disable Function : exec,passthru,shell_exec,system MySQL : OFF | cURL : ON | WGET : ON | Perl : ON | Python : ON | Sudo : ON | Pkexec : ON Directory : /home/yellowleaf/public_html/members/ |
Upload File : |
<?php $path = $_SERVER['DOCUMENT_ROOT']; include_once $path . '/connect_db.php'; include 'accesscontrol.php'; header('Content-Type: text/html; charset=utf-8'); $adid = addslashes($_GET['adid']); if (advert_check($adid, $memberid) === false) { header('Location: index.html'); exit(); } if (isset($_POST['submit'])) { $vaild = true; $description = addslashes($_POST['description']); $services = addslashes($_POST['services']); $refund = addslashes($_POST['refund']); $establishment = addslashes($_POST['establishment']); $areas_cover = addslashes($_POST['areas_cover']); if (!$description ) { $vaild = false; $errordescription = 'error'; } $tags = ''; $tags_count = count($_POST['tags']); foreach ($_POST['tags'] as $key => $value) { $tags .= addslashes(trim($value)); if($tags_count != ($key+1)){ $tags .= " || "; } } $fieldname = 'image_upload_box'; if (is_uploaded_file($_FILES[$fieldname]['tmp_name'])) { $fieldname = 'image_upload_box'; $image_temp = $_FILES[$fieldname]["tmp_name"]; $allowed_ext = array('jpeg', 'jpg', 'png', 'gif'); $image_ext = strtolower(end(explode('.', $_FILES[$fieldname]['name']))); $destination = 'uploads/logo/'; $image_file = $adid . '.' . $image_ext; if (in_array($image_ext, $allowed_ext) === false) { $vaild = false; $errorimage = '<span class="error">- Your photo must be either a JPG, PNG or GIF file format. Other file types are not allowed.</span>'; } if ($_FILES[$fieldname]["size"] > 4000000) { $vaild = false; $errorimage = '<span class="error">- Image file size must be less than 4 MB.</span>'; } if (empty($errorimage)) { include "img_upload.class.php"; $image = new UploadImage(); $image->load($image_temp); $image->save($destination . $image_file); $imageExist = ", image = '{$image_file}'"; } } $connect->query("UPDATE ads SET services_products = '{$tags}', description='$description' {$imageExist} WHERE `adid` = '$adid' AND `memberid` = '{$memberid}'"); if ($vaild == true) { echo "<script>location.href='postbusiness3.php?adid={$adid}';</script>"; exit; } } $add_que_sql = $connect->query("SELECT * FROM ads WHERE memberid ='{$memberid}' AND adid ='{$adid}'"); $add_row = $add_que_sql->fetch_assoc(); $image_logo = $add_row["image"]; /** fetch 10 cats based on popularity */ $cats_que_sql = $connect->query("SELECT * FROM `cats` ORDER BY `pop` DESC LIMIT 15"); $selected_tags_que_sql = $connect->query("SELECT * FROM ads WHERE memberid ='{$memberid}' AND adid ='{$adid}'"); $selected_tag_rows = $selected_tags_que_sql->fetch_assoc(); $tags_explode = []; if(!empty($selected_tag_rows['services_products'])){ $tags_explode = explode(" || ", $selected_tag_rows['services_products']); } ?> <!DOCTYPE html> <html lang="en"> <head> <title>YellowLeaf - Homepage</title> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> <meta http-equiv="X-UA-Compatible" content="IE=edge"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <link href='https://unpkg.com/boxicons@2.0.9/css/boxicons.min.css' rel='stylesheet'> <link rel="stylesheet" href="/header-footer/global.css"> <link rel="stylesheet" href="index.css"> <link href="https://cdn.jsdelivr.net/npm/select2@4.1.0-rc.0/dist/css/select2.min.css" rel="stylesheet" /> <style> .form-group input { border-radius: 4px; padding: 0 16px; } .form-group textarea { border-radius: 4px; padding: 12px 16px; } .form-group { display: block; } .form-box-inline { position: relative; } hr { border: none; height: 1px; margin: 20px 0; background-color: #bbb; } .form-box { position: relative; } .form-product-group { padding: 16px; border: 1px solid var(--gray-200); border-radius: 6px; position: relative; margin-top: 16px; } .form-product-group .form-box:last-child { margin-bottom: 0; } .image-progress { position: absolute; top: 0; left: 0; width: 100%; height: 100%; background-color: rgba(0, 0, 0, .5); display: flex; align-items: center; justify-content: center; padding: 16px; z-index: 10; } .image-progress > * { width: 100%; height: 16px; border-radius: 2px; background-color: var(--white); border: 1px solid var(--white); position: relative; overflow: hidden; } .image-progress > ::before { content: ''; position: absolute; top: 0; left: 0; height: 100%; width: var(--progress, 10%); background-color: var(--yellow); } .image-progress > ::after { content: attr(data-progress); position: absolute; top: 50%; left: 50%; transform: translate(-50%, -50%); font-size: 12px; color: var(--black); } .selected-tag{ width: 100%; position: relative; } .tag-container{ display: flex; flex-wrap: wrap; } .tag-container .tag{ padding: 3px 5px; border: 1px solid #ccc; margin: 5px; display: flex; align-items: center; border-radius: 3px; background: #f2f2f2; cursor: default; } .tag .close{ font-size: 18px; margin-left: 10px; align: center; color: #e15252; font-weight: bold; cursor: pointer; } .warning-message{ color: red; padding: 15px; } .description-char{ font-weight: small; } .description-warning{ color: #F96B4B; } .description-perfect{ color: green; } .tag-selected{ background: lightgray; /* pointer-events: none; */ } </style> </head> <? include 'member_menu.php'; ?> <!-- NAVBAR --> <section id="content"> <!-- NAVBAR --> <nav> <i class='bx bx-menu toggle-sidebar'></i> <a href="/members/logout.html" class="logout"> <i class='bx bx-log-out'></i> Logout </a> </nav> <!-- NAVBAR --> <!-- MAIN --> <main> <div class="container"> <h1 class="title">Submit Advert</h1> <!-- <ul class="breadcrumbs"> <li><a href="#">Home</a></li> <li class="divider">/</li> <li><a href="#" class="active">Dashboard</a></li> </ul> --> <div class="main-content"> <div class="main-box"> <? include 'advert-tab.php'; ?> <form class="submit-advert-form" action="" method="POST" enctype="multipart/form-data"> <?= $postbusiness_error ?> <div class="form-box"> <div class="form-description">Please upload the logo of your business. (optional)</div> <div class="form-group"> <label for="image_upload_box" class="image-upload-wrapper" title="Click to upload/change image"> <input name="image_upload_box" id="image_upload_box" type="file" accept="image/*"> <?php if(!empty($image_logo)){ echo '<div class="image-upload-text">Click to change image</div> <img src="./uploads/logo/'.$image_logo.'" alt="">'; } ?> Click to upload/change image </label> <?= $errorimage ?> </div> </div> <div class="form-box"> <div class="form-description">Please enter a brief description about your business.</div> <div class="form-group"> <textarea id="description" name="description" cols="30" rows="5"><?= $add_row['description'] ?></textarea> <span class="description-char"></span> </div> </div> <div class="form-box" style="margin-bottom: 10px;"> <div class="form-description">Please input or select tags.</div> <div class="form-group"> <input type="text" name="tagInput" class="tagInput"> <select class="tags-select" name="tags[]" multiple="multiple" style="display: none"> <?php foreach ($tags_explode as $key => $value): ?> <option value="<?= $value?>" selected ><?= $value ?></option> <?php endforeach?> </select> </div> </div> <div class="form-box"> <div class="selected-tag"> <div class="tag-container"> <?php foreach ($tags_explode as $key => $value): ?> <div class="tag"> <span><?= $value ?></span> <span class="close" data-cat="<?= $value ?>">x</span> </div> <?php endforeach?> </div> </div> </div> <button type="submit" name="submit" class="button button-yellow" onclick="return check_description()">Next</button> </form> </div> </div> </div> </main> <!-- MAIN --> </section> <!-- NAVBAR --> <script> var adid = '<?= $adid ?>'; </script> <script src="https://code.jquery.com/jquery-3.6.0.min.js" integrity="sha256-/xUj+3OJU5yExlq6GSYGSHk7tPXikynS7ogEvDej/m4=" crossorigin="anonymous"></script> <script src="script.js"></script> <script> var count_select_cat = <?= count($tags_explode)?? 0 ?>; var des_check = false; $(document).ready(function(e){ let char_len = $("#description").val().length; if(char_len < 300){ let need_char = 300 - char_len; $(".description-char").removeClass("description-perfect"); $(".description-char").addClass("description-warning"); $(".description-char").html("Need <b>"+need_char+"</b> character more for description"); des_check = false; } else{ des_check = true; } }); function check_description(){ return des_check; } // check description charecter length $("#description").on('keyup', function(e){ let desciption_lenght = $("#description").val().length; if(desciption_lenght < 300){ let required_char = 300 - desciption_lenght; $(".description-char").removeClass("description-perfect"); $(".description-char").addClass("description-warning"); $(".description-char").html("Need <b>"+required_char+"</b> character more for description"); des_check = false; } else{ $(".description-char").removeClass("description-warning"); $(".description-char").addClass("description-perfect"); $(".description-char").html("Perfect description"); des_check = true; } }); $(".tagInput").on('keyup', function(e){ // let text = $(".tagInput").val(); // console.log(text); autocomplete($(".tagInput")); }); function autocomplete(inps) { let text = inps.val(); $.ajax({ url: '/ajax/ajax_select_cat.php?hint='+text, success: function (result) { removeAutocomplete(); selected = -1; var resp = JSON.parse(result); // console.log(resp) if(!resp) return var ul = $(document.createElement('ul')); ul.addClass('autocomplete'); resp.forEach(function (item) { var li = $(document.createElement('li')); li.html(item); let get_selected_tag = $(".tags-select").find("option[value='" + item + "']"); if(get_selected_tag.val() === item){ li.addClass("tag-selected"); } li.click(function () { var select = $(".tags-select"); if (select.find("option[value='" + item + "']").length) { $(".tagInput").val(''); $(".tagInput").focus(); } else { $(".tagInput").val(''); $(".tagInput").focus(); if(count_select_cat < 10){ option = $(document.createElement('option')); option.val(item); option.attr("selected", ""); option.html(item); select.append(option); // for display tag var display_tag_div = $(".tag-container"); var tag = $(document.createElement('div')); tag.addClass("tag"); display_tag_div.append(tag); var span = $(document.createElement('span')); span.html(item); tag.append(span); var close = $(document.createElement('span')); close.addClass("close"); close.attr("data-cat", item); close.html("x"); tag.append(close); count_select_cat++; display_tag_div.append(tag); } else{ let select_tag = $(".tags-select"); let span = $(document.createElement('span')); span.addClass("warning-message"); span.html("You cannot add tags more than 10"); select_tag.after(span); setTimeout(function(){ $('.warning-message').remove() }, 5000); } } removeAutocomplete(); }) ul.append(li); }) inps.after(ul); } }) } $(document).click(function (e) { if (!$(e.target).is('.autocomplete, .autocomplete li')) { removeAutocomplete(); } }) function removeAutocomplete() { $('.autocomplete').remove(); } $(document).on("click", ".close", function(){ let text = $(this).data("cat"); // console.log( text); let target_option = $(".tags-select").find("option[value='" + text + "']"); // console.log(target_option); $(this).parent('.tag').remove(); target_option.remove(); count_select_cat--; }); </script> </body> </html>