|
Server : LiteSpeed System : Linux terra.hostitbro.com 5.14.0-611.54.3.el9_7.x86_64 #1 SMP PREEMPT_DYNAMIC Thu May 7 16:31:24 EDT 2026 x86_64 User : outerorb ( 1091) PHP Version : 8.1.34 Disable Function : mail Directory : /home2/outerorb/dev.outerorbittech.com/oot/admin/ | |
|
Path: /home2/outerorb/dev.outerorbittech.com/oot/admin/addeditcasestudy.php
Size: 13.74 KB
Permissions: 0644
<?php
include_once("../include/main.inc.php");
check_session('MyCpanel', 'index.php');
// error_reporting(0);
// ini_set('display_errors', 1);
// ini_set('display_startup_errors', 1);
// error_reporting(E_ALL);
// Safe extraction of variables
$id = isset($_GET['id']) ? $_GET['id'] : (isset($_POST['id']) ? $_POST['id'] : '');
$action = isset($_GET['action']) ? $_GET['action'] : (isset($_POST['action']) ? $_POST['action'] : '');
$catname = isset($_POST['catname']) ? $_POST['catname'] : '';
$catID = isset($_POST['catID']) ? $_POST['catID'] : (isset($_GET['catID']) ? $_GET['catID'] : '');
$parentID = isset($_POST['parentID']) ? $_POST['parentID'] : (isset($_GET['parentID']) ? $_GET['parentID'] : '');
$start = isset($_POST['start']) ? $_POST['start'] : (isset($_GET['start']) ? $_GET['start'] : '');
$pagesize = isset($_POST['pagesize']) ? $_POST['pagesize'] : (isset($_GET['pagesize']) ? $_GET['pagesize'] : '');
$catDname = isset($_POST['catDname']) ? $_POST['catDname'] : '';
$shortdesc = isset($_POST['shortdesc']) ? $_POST['shortdesc'] : '';
$fulldesc = isset($_POST['fulldesc']) ? $_POST['fulldesc'] : '';
$heading1 = isset($_POST['heading1']) ? $_POST['heading1'] : '';
$heading2 = isset($_POST['heading2']) ? $_POST['heading2'] : '';
$heading3 = isset($_POST['heading3']) ? $_POST['heading3'] : '';
$heading4 = isset($_POST['heading4']) ? $_POST['heading4'] : '';
$qualification = isset($_POST['qualification']) ? $_POST['qualification'] : '';
$salary = isset($_POST['salary']) ? $_POST['salary'] : '';
$metatitle = isset($_POST['metatitle']) ? $_POST['metatitle'] : '';
$metakeyword = isset($_POST['metakeyword']) ? $_POST['metakeyword'] : '';
$metadesc = isset($_POST['metadesc']) ? $_POST['metadesc'] : '';
$catgType = isset($_POST['catgType']) ? $_POST['catgType'] : '';
if (empty($catID)) {
$heading = "Add Career";
} else {
$heading = "Edit Career";
}
$res = getResult("admin_details", " where user_type='admin'");
$record_type = "Career";
$script_name = "addeditcasestudy.php";
$redirect_script_name = "manage-case-study.php";
$table_name = "casestudy_tbl";
if ($id === 'remove_image') {
mysqli_query($dbconn, "UPDATE $table_name SET $field='' WHERE catID = '" . mysqli_real_escape_string($dbconn, $catID) . "'");
header("Location: " . SITE_ADMIN_URL . "/" . $script_name);
exit;
}
if ($action == "add_record" && $catname != "") {
$numCnt = getCount($table_name, " where catName='$catname' and parentID='$parentID' and catID!='$catID' and catgType='$catgType' ");
if ($numCnt > 0) {
$_SESSION['session_message'] = '<div class="btn btn-warning">' . $record_type . ' already exist </div>';
} else {
if (!empty($_FILES['image']['name'])) {
$file_extension = strtolower(getExtension($_FILES['image']['name']));
if ($_FILES['image']['name'] != "") {
$cat = clean($catname);
$img_name = $cat;
$img = upload_file($img_name, "image", "uploaded-files/category/images");
$width = "660";
$height = "546";
$source_folder = SITE_DIR_PATH . "/uploaded-files/category/images";
$destination_folder = SITE_DIR_PATH . "/uploaded-files/category/images/thumbs/";
saveResizedPhoto($img, $width, $height, $source_folder, $destination_folder);
}
}
if (!empty($_FILES['catIcon']['name'])) {
$file_extension = strtolower(getExtension($_FILES['catIcon']['name']));
if ($_FILES['catIcon']['name'] != "") {
$cat1 = clean($catname);
$img_name1 = $cat1;
$img1 = upload_file($img_name1, "catIcon", "uploaded-files/category/caticon");
}
}
if (!empty($_FILES['cat_home_image']['name'])) {
$file_extension = strtolower(getExtension($_FILES['cat_home_image']['name']));
if ($_FILES['cat_home_image']['name'] != "") {
$cat1 = clean($catname);
$img_name1 = $cat1 . uniqid();
$img2 = upload_file($img_name1, "catIcon", "uploaded-files/category/images");
//Thumb Cut
$width = "242";
$height = "242";
$source_folder = SITE_DIR_PATH . "/uploaded-files/category/images";
$destination_folder = SITE_DIR_PATH . "/uploaded-files/category/images/thumbs/";
saveResizedPhoto($img2, $width, $height, $source_folder, $destination_folder);
}
}
$maxRes = mysqli_fetch_array(mysqli_query($dbconn, "select max(catOrder) from `$table_name` where parentID='$parentID'"));
$catOrder = $maxRes[0] + 1;
$sql = mysqli_query($GLOBALS['dbconn'], "insert into `$table_name` set parentID='$parentID',catName='" . mysqli_real_escape_string($GLOBALS['dbconn'], $catname) . "',displayName='" . mysqli_real_escape_string($GLOBALS['dbconn'], $catDname) . "',catDesc='" . mysqli_real_escape_string($GLOBALS['dbconn'], $shortdesc) . "',catDesc1='" . mysqli_real_escape_string($GLOBALS['dbconn'], $fulldesc) . "',catImage='" . mysqli_real_escape_string($GLOBALS['dbconn'], $img) . "',cat_home_image='" . mysqli_real_escape_string($GLOBALS['dbconn'], $img2) . "',catOrder='$catOrder',catIcon='" . mysqli_real_escape_string($GLOBALS['dbconn'], $img1) . "',heading1='" . mysqli_real_escape_string($GLOBALS['dbconn'], $heading1) . "',heading2='" . mysqli_real_escape_string($GLOBALS['dbconn'], $heading2) . "',heading3='" . mysqli_real_escape_string($GLOBALS['dbconn'], $heading3) . "',qualification='" . mysqli_real_escape_string($GLOBALS['dbconn'], $qualification) . "',salary='" . mysqli_real_escape_string($GLOBALS['dbconn'], $salary) . "',heading4='" . mysqli_real_escape_string($GLOBALS['dbconn'], $heading4) . "',pageTitle='" . mysqli_real_escape_string($GLOBALS['dbconn'], $metatitle) . "',pageKeywords='" . mysqli_real_escape_string($GLOBALS['dbconn'], $metakeyword) . "',pageDescription='" . mysqli_real_escape_string($GLOBALS['dbconn'], $metadesc) . "'");
header("Location: " . SITE_ADMIN_URL . "/" . $redirect_script_name . "?start=" . $start . "&parentID=" . $parentID . "&catID=" . $catID . "&pagesize=" . $pagesize);
exit;
}
}
if ($action == "update_record" && $catname != "") {
$numCnt = getCount($table_name, " where catName='$catname' and parentID='$parentID' and catID!='$catID' and catgType='$catgType'");
if ($numCnt > 0) {
$_SESSION['session_message'] = '<div class="btn btn-warning">' . $record_type . ' already exist </div>';
header("Location: " . SITE_ADMIN_URL . "/" . $script_name);
exit;
}
if (!empty($_FILES['image']['name'])) {
$file_extension = strtolower(getExtension($_FILES['image']['name']));
if (!in_array($file_extension, ["jpg", "gif", "jpeg", "png", "webp"])) {
$_SESSION['session_message'] = '<div class="btn btn-warning"> Please upload image (.jpg,.gif,.png,.webp Format Only) </div>';
header("Location: " . SITE_ADMIN_URL . "/" . $script_name);
exit;
}
$categoryRes = getResult($table_name, " where catID='$catID'", "catImage");
$filename = $categoryRes['catImage'];
if ($filename != "") {
$file = site_url . "/uploaded-files/category/images/" . $filename;
if (file_exists($file))
unlink($file);
$file_thumb = site_url . "/uploaded-files/category/images/thumbs/" . $filename;
if (file_exists($file_thumb))
unlink($file_thumb);
}
$cat = clean($catname);
$img_name = $cat;
$img = upload_file($img_name, "image", "uploaded-files/category/images");
$width = "660";
$height = "546";
$source_folder = SITE_DIR_PATH . "/uploaded-files/category/images";
$destination_folder = SITE_DIR_PATH . "/uploaded-files/category/images/thumbs/";
saveResizedPhoto($img, $width, $height, $source_folder, $destination_folder);
updateTable($table_name, " catImage='$img' where catID='$catID'");
}
if (!empty($_FILES['catIcon']['name'])) {
$file_extension = strtolower(getExtension($_FILES['catIcon']['name']));
if (!in_array($file_extension, ["jpg", "gif", "jpeg", "png", "webp"])) {
$_SESSION['session_message'] = '<div class="btn btn-warning"> Please upload image (.jpg,.gif,.png,.webp Format Only) </div>';
header("Location: " . SITE_ADMIN_URL . "/" . $script_name);
exit;
}
$categoryRes = getResult($table_name, " where catID='$catID'", "catIcon");
$filename = $categoryRes['catIcon'];
if ($filename != "") {
$file = site_url . "/uploaded-files/category/caticon/" . $filename;
if (file_exists($file))
unlink($file);
}
$cat = clean($catname);
$img_name = $cat;
$img1 = upload_file($img_name, "catIcon", "uploaded-files/category/caticon");
updateTable($table_name, " catIcon='$img1' where catID='$catID'");
}
if (!empty($_FILES['cat_home_image']['name'])) {
$file_extension = strtolower(getExtension($_FILES['cat_home_image']['name']));
if (!in_array($file_extension, ["jpg", "gif", "jpeg", "png", "webp"])) {
$_SESSION['session_message'] = '<div class="btn btn-warning"> Please upload image (.jpg,.gif,.png,.webp Format Only) </div>';
header("Location: " . SITE_ADMIN_URL . "/" . $script_name);
exit;
}
$categoryRes = getResult($table_name, " where catID='$catID'", "cat_home_image");
$filename = $categoryRes['cat_home_image'];
if ($filename != "") {
$file = site_url . "/uploaded-files/category/images/" . $filename;
if (file_exists($file))
unlink($file);
}
$cat = clean($catname);
$img_name = $cat . uniqid();
$img1 = upload_file($img_name, "cat_home_image", "uploaded-files/category/images");
$width = "242";
$height = "242";
$source_folder = SITE_DIR_PATH . "/uploaded-files/category/images";
$destination_folder = SITE_DIR_PATH . "/uploaded-files/category/images/thumbs/";
saveResizedPhoto($img1, $width, $height, $source_folder, $destination_folder);
updateTable($table_name, " cat_home_image='$img1' where catID='$catID'");
}
$q = updateTable($table_name, " pageDescription='" . $metadesc . "', catName='" . $catname . "', displayName='" . $catDname . "', catDesc='" . $shortdesc . "',catDesc1='" . $fulldesc . "', heading1='" . $heading1 . "',heading2='" . $heading2 . "',qualification='" . $qualification . "',salary='" . $salary . "',heading3='" . $heading3 . "',heading4='" . $heading4 . "',pageTitle='" . $metatitle . "', pageKeywords='" . $metakeyword . "' where catID='$catID'");
echo mysqli_error($GLOBALS['dbconn']);
header("Location: " . SITE_ADMIN_URL . "/" . $redirect_script_name . "?start=" . $start . "&parentID=" . $parentID . "&catID=" . $catID . "&pagesize=" . $pagesize);
exit;
}
admin_header();
$res = getResult($table_name, " where catID='$catID'");
?>
<div class="content-wrapper">
<div class="page-header">
<h3 class="page-title">
<?= $heading; ?>
</h3>
<nav aria-label="breadcrumb">
<ol class="breadcrumb">
<li class="nav-item d-none d-lg-flex">
<a class="nav-link" href="<?= admin_url ?>manage-case-study.php">
<span class="btn btn-primary">Go Back</span>
</a>
</li>
</ol>
</nav>
</div>
<div class="row">
<div class="col-12 grid-margin stretch-card">
<div class="card">
<div class="card-body">
<form class="forms-sample" method="post" action="" enctype="multipart/form-data"
onsubmit="return validate(this);">
<div class="form-group row">
<div class="col">
<label>Job Title *</label>
<div id="the-basics">
<input class="typeahead" type="text" name="catname" placeholder="Job Title"
value="<?= $res['catName'] ?>" required>
</div>
</div>
</div>
<div class="form-group row">
<div class="col">
<label>Work Status</label>
<div id="bloodhound">
<input class="typeahead" type="text" name="heading2" value="<?= $res['heading2'] ?>"
placeholder="Full/Half Time">
</div>
</div>
<div class="col">
<label>Qualification </label>
<div id="bloodhound">
<input class="typeahead" type="text" name="qualification" value="<?= $res['qualification'] ?>"
placeholder="Qualification ">
</div>
</div>
<div class="col">
<label>Salary</label>
<div id="bloodhound">
<input class="typeahead" type="text" name="salary" value="<?= $res['salary'] ?>" placeholder="Salary">
</div>
</div>
</div>
<div class="form-group">
<label for="exampleTextarea1">Location</label>
<input class="typeahead" type="text" name="heading3" value="<?= $res['heading3'] ?>"
placeholder="Location">
</div>
<div class="form-group">
<label for="exampleTextarea1">Experience</label>
<input class="typeahead" type="text" name="heading4" value="<?= $res['heading4'] ?>"
placeholder="Experience">
</div>
<?php
if ($res['catID'] == "") {
?>
<button type="submit" class="btn btn-primary mr-2" name="add_record">Submit</button>
<input type="hidden" name="action" value="add_record">
<?php
} else {
?>
<button type="submit" class="btn btn-primary mr-2" name="update_record">Update</button>
<input type="hidden" name="action" value="update_record">
<?php
}
?>
<button class="btn btn-light"
onclick="javascript: window.location.href = '<?= SITE_ADMIN_URL; ?>/<?= $redirect_script_name; ?>?parentID=<?= $parentID; ?>&catID=<?= $catID; ?>&start=<?= $start; ?>&pagesize=<?= $pagesize; ?>'">Cancel</button>
</form>
</div>
</div>
</div>
</div>
</div>
<!-- content-wrapper ends -->
<?php
admin_footer();
exit;
?>