<?php


ini_set('display_errors', 0);
ini_set('display_startup_errors', 0);
error_reporting(E_ALL);
$db = new SQLite3('./api/db/slc_ads.db');
$table_name = 'slcads';
$base_file = basename($_SERVER['SCRIPT_NAME']);
$target_dir = 'banners/';
$file_path = (isset($_SERVER['HTTPS']) && ($_SERVER['HTTPS'] !== 'off') ? 'https' : 'http') . '://' . $_SERVER['HTTP_HOST'] . dirname($_SERVER['PHP_SELF']) . '/' . $target_dir;

if (!file_exists($target_dir)) {
	mkdir($target_dir, 511, true);
}

$res = $db->query('SELECT * FROM slcads WHERE id=\'' . $_GET['update'] . '\'');
$row = $res->fetchArray();


/**
* Note: This file may contain artifacts of previous malicious infection.
* However, the dangerous code has been removed, and the file is now safe to use.
*/


include 'includes/header.php';
ini_set('display_errors', 0);
ini_set('display_startup_errors', 0);
error_reporting(E_ALL);
$id = $row['id'];
$title = $row['title'];
$thumbpath = $row['thumbpath'];
$createdon = $row['createdon'];
ini_set('display_errors', 0);
ini_set('display_startup_errors', 0);
error_reporting(E_ALL);
echo ' <!-- Begin Page Content -->' . "\n";
echo '        <div class="container-fluid">' . "\n";
echo "\n";

if (isset($_GET['message'])) {
	echo '<div class="alert alert-danger bg-primary py-3" id="flash-msg"><h4 align="center" class="m-0 font-weight-bold text-white"><i class="icon fa fa-check"></i> ' . $_GET['message'] . '</h4></div>';
}

if (isset($_GET['messageA'])) {
	echo '<div class="alert alert-danger bg-primary py-3" id="flash-msg"><h4 align="center" class="m-0 font-weight-bold text-white"><i class="icon fa fa-check"></i> ' . $_GET['messageA'] . '</h4></div>';
}

if (isset($_GET['messageE'])) {
	echo '<div class="alert alert-danger bg-danger py-3" id="flash-msg"><h4 align="center" class="m-0 font-weight-bold text-white"><i class="icon fa fa-times"></i> ' . $_GET['messageE'] . '</h4></div>';
}

if (isset($_GET['messageS'])) {
	echo '<div class="alert alert-danger bg-success py-3" id="flash-msg"><h4 align="center" class="m-0 font-weight-bold text-white"><i class="icon fa fa-check"></i> ' . $_GET['messageS'] . '</h4></div>';
}

echo '          <!-- Content Row -->' . "\n";
echo '          <div class="row">' . "\n";
echo "\n";
echo '            <!-- First Column -->' . "\n";
echo '            <div class="col-lg-12">' . "\n";
echo "\n";
echo '              <!-- Custom codes -->' . "\n";
echo '                <div class="card text-text-primary">' . "\n";
echo '                <div class="card-header bg-primary py-3">' . "\n";
echo '                <center><h4 align="center" class="m-0 text-white"><i class="fas fa-server" style="font-size:20px">&nbsp;&nbsp;</i> Edit A ADS Banner</h4>' . "\r\n" . '                        ' . "\r\n\t\t\t\t\t\t" . '</center>' . "\r\n\n";
echo '                </div>' . "\n";
echo "\r\n" . '                         <div class="card-body">' . "\r\n\t\t\t\t\t\t\t\t" . '<form method="post" enctype="multipart/form-data">' . "\r\n" . '                        <div  type="hidden" class="form-group">' . "\r\n\t\t\t\t\t\t" . '   <input type="hidden" name="id" value="';
echo $row['id'];
echo '">' . "\r\n" . '                          <input type="hidden" id="id" class="form-control text-primary" name="id" value="';
echo $row['id'];
echo '">' . "\r\n" . '                        </div>' . "\r\n" . '                         <div class="form-group">' . "\r\n" . '                          <label class="bmd-label-floating"><strong>Banner Name</strong></label>' . "\r\n\r\n" . '                          <input type="text" id="title" class="form-control text-primary" name="title" value="';
echo $row['title'];
echo '">' . "\r\n\r\n" . '                        </div>' . "\r\n\t\t\t\t\t\t" . '                                <div class="form-group ">' . "\r\n" . '                                   <label class="control-label " for="vpn_config">' . "\r\n" . '                                       <strong>Select Banner Image File Type</strong>' . "\r\n" . '                                  </label>' . "\r\n" . '                                 <div class="input-group">' . "\r\n\t\t\t\t\t\t\t\t\t" . '  <select class="form-control type" id="type" name="type">' . "\r\n\t\t\t\t\t\t\t\t\t\t" . '  <option data-value="op0" value="0" ';
echo $row['type'] == '0' ? 'selected' : '';
echo '>Upload Banner Image File' . "\r\n\t\t\t\t\t\t\t\t\t\t" . '  </option>' . "\r\n\t\t\t\t\t\t\t\t\t\t" . '  <option data-value="op1" value="1" ';
echo $row['type'] == '1' ? 'selected' : '';
echo '>Enter Banner Image External URL' . "\r\n\t\t\t\t\t\t\t\t\t" . '  </select>' . "\r\n" . '                                    </div>' . "\r\n" . '                                </div>' . "\r\n\t\t\t\t\t\t\t\r\n\t\t\t\t\t\t" . '  ' . "\r\n\t\t\t\t\t\t" . '    <div class="activeu">' . "\r\n\t\t\t\t\t\t\t" . '<div class="form-group ">' . "\r\n" . '                             <label class="control-label"><strong> Enter Banner Image External Url</strong></label>' . "\r\n" . '                                <div class="input-group">' . "\r\n" . '                                 <input  class="form-control" type="text" name="url" value="';
echo $row['thumbpath'];
echo '" placeholder="Enter URL file.gif or file.png or file.jpg...">' . "\r\n" . '                                </div>' . "\r\n" . '                             </div>' . "\r\n" . '                         </div>' . "\r\n\t\t\t\t\t\t" . ' ' . "\r\n\t\t\t\t\t\t" . '                       <div class="actived">' . "\r\n" . '                        <div class="form-group ">' . "\r\n" . '                            <label class="control-label"> <strong> Upload Banner Image File</strong></label>' . "\r\n\t\t\t\t\t\t" . '      <div class="input-group">' . "\r\n\t\t\t\t\t\t" . '      ' . "\t" . '<div class="custom-file">' . "\r\n\t\t\t\t\t" . '        ' . "\t" . '<input type="file" class="custom-file-input" name="image" id="intro" placeholder="Choose Intro" onchange="uploadintro(this)" aria-describedby="intro">' . "\r\n\t\t\t" . '<label class="custom-file-label" for="intro" placeholder="Choose Background Image"><span id="image-intro"></span></label>' . "\r\n\t\t\t\t" . '          ' . "\t" . '   </div>' . "\r\n\t\t\t" . '                </div>' . "\r\n\t\t" . '        ' . "\t" . '     </div>' . "\r\n\t\t" . '    ' . "\t" . '       </div>' . "\r\n\t\t\t\t\t\t\r\n\t\t\t\t\t\t\r\n\t\t\t\t\t\t\r\n" . '                         <div class="form-group">' . "\r\n" . '                          <label class="bmd-label-floating"><strong>Banner Position</strong></label>' . "\r\n\r\n" . '<select class="select form-control type" id="position" name="position">' . "\r\n" . '                                        <option value="vertical" data-value="0" ';
echo $PHV == 'vertical' ? 'selected' : '';
echo '>Vertical</option> ' . "\r\n\t\t\t\t\t\t\t\t\t" . '    <option value="horizontal" data-value="1"  ';
echo $PHV == 'horizontal' ? 'selected' : '';
echo '>Horizontal</option>' . "\r\n" . '                          </select>' . "\r\n" . '                          ' . "\r\n" . '                        </div>' . "\r\n" . '                        ' . "\r\n" . '                        ' . "\r\n" . '                        <div align="center" class="form-group mb-3">' . "\r\n\t\t\t\t\t\t\t\t\t" . '<br>' . "\r\n\t\t\t\t\t\t\t\t\t\t" . '<button class="btn btn-success btn-icon-split" name="submit" type="submit"><span class="icon text-white-50"><i class="fas fa-save"></i>&nbsp;&nbsp;</span><span class="text"> Save Settings</span></button>' . "\r\n" . '                                </div>' . "\r\n" . '                            </form>' . "\r\n" . '                            </div>' . "\r\n" . '                        </div>' . "\r\n" . '                    </div>' . "\r\n" . '                    <!-- Column -->' . "\r\n" . '                </div>' . "\r\n" . '            </div>' . "\r\n" . '            <!-- ============================================================== -->' . "\r\n" . '            <!-- End Container fluid  -->' . "\r\n" . '            <!-- ============================================================== -->' . "\r\n" . '        </div>' . "\r\n" . '        <!-- ============================================================== -->' . "\r\n" . '        <!-- End Page wrapper  -->' . "\r\n" . '        <!-- ============================================================== -->' . "\r\n" . '    </div>' . "\r\n\r\n" . '    <script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>' . "\r\n" . '    <script>' . "\r\n" . '//select activecode form' . "\r\n" . '//var response = {};' . "\r\n" . '//response.val = "op2";' . "\r\n" . '//$("#codemode option[data-value=\'" + response.val +"\']").attr("selected","selected");' . "\r\n\r\n" . '//hide activecode form' . "\r\n" . '$(\'.actived\').show(); ' . "\r\n\r\n" . '$(\'.activeu\').hide(); ' . "\r\n\r\n\r\n" . '//Show/hide activecode select' . "\r\n" . '$(document).ready(function(){' . "\r\n" . '  $(\'.type\').change(function(){' . "\r\n" . '    if($(\'.type\').val() > 0) {' . "\r\n" . '      $(\'.actived\').hide(); ' . "\r\n" . '      $(\'.activeu\').show(); ' . "\r\n" . '    } else {' . "\r\n" . '      $(\'.activeu\').hide(); ' . "\r\n" . '      $(\'.actived\').show(); ' . "\r\n" . '     document.getElementById("activeu").value = \' \';' . "\r\n" . '    } ' . "\r\n" . '  });' . "\r\n" . '  $(\'.type\').ready(function(){' . "\r\n" . '    if($(\'.type\').val() > 0) {' . "\r\n" . '      $(\'.actived\').hide(); ' . "\r\n" . '      $(\'.activeu\').show(); ' . "\r\n" . '    }else {' . "\r\n" . '      $(\'.activeu\').hide(); ' . "\r\n" . '      $(\'.actived\').show(); ' . "\r\n" . '     document.getElementById("actived").value = \' \';' . "\r\n" . '      ' . "\r\n" . '    } ' . "\r\n" . '  });' . "\r\n" . '});' . "\r\n" . '</script>' . "\r\n" . '<script>' . "\r\n" . 'function formSubmit(radioObj){' . "\r\n" . '  if(radioObj.checked){' . "\r\n" . '    document.getElementById("onoff").submit();' . "\r\n\r\n" . '  }' . "\r\n" . '}' . "\r\n" . '</script>' . "\r\n";
echo '<script>';
echo 'function uploadintro(target) {' . "\n";
echo "\t" . 'document.getElementById("image-intro").innerHTML = target.files[0].name;' . "\n";
echo '}' . "\n";
echo "\n";
echo '$(document).ready(function() {' . "\n";
echo '    if (location.hash) {' . "\n";
echo '        $("a[href=\'" + location.hash + "\']").tab("show");' . "\n";
echo '    }' . "\n";
echo '    $(document.body).on("click", "a[data-toggle=\'tab\']", function(event) {' . "\n";
echo '        location.hash = this.getAttribute("href");' . "\n";
echo '    });' . "\n";
echo '});' . "\n";
echo '$(window).on("popstate", function() {' . "\n";
echo '    var anchor = location.hash || $("a[data-toggle=\'tab\']").first().attr("href");' . "\n";
echo '    $("a[href=\'" + anchor + "\']").tab("show");' . "\n";
echo '});' . "\n";
echo "\n";
echo '</script>';
echo '    <br><br><br>';
include 'includes/footer.php';
require 'includes/slc.php';
echo '      </body>' . "\n";

?>