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/

📁 Create New:
⬆️ Upload File:
Current Dir [ Writable ] Root [ Writable ]


OR Upload from URL:
URL: Save as:

📄 File: addeditclient.php

Path: /home2/outerorb/dev.outerorbittech.com/oot/admin/addeditclient.php

Size: 6.91 KB

Permissions: 0644

<?php
include_once("../include/main.inc.php");
check_session('MyCpanel', 'index.php');

@extract($_REQUEST);
if (empty($catID)) {
  $heading = "Add New Client";
} else {
  $heading = "Edit Client";
}
$res = getResult("admin_details", " where user_type='admin'");

$record_type = "Add New Client";
$script_name = "addeditclient.php";
$redirect_script_name = "manage-clients.php";
$table_name = "client_tbl";
#################### Add Record ##################
if ($action == "add_record" && $name != "") {
  $numCnt = getCount($table_name, " where name='$name'");
  if ($numCnt > 0) {
    $_SESSION['session_message'] = '<div class="btn btn-warning">' . $record_type . ' already exist  </div>';
  } else {

    if ($_FILES['clientimg']['name'] != " ") {
      $file_extension = strtolower(getExtension($_FILES['clientimg']['name']));
      if ($_FILES['clientimg']['name'] != "") {
        $Client = str_replace(" ", "-", $name);
        $img_name = $Client;
        $img = upload_file($img_name, "clientimg", "uploaded-files/client-image");

        $width = "119";
        $height = "33";
        $source_folder = SITE_DIR_PATH . "/uploaded-files/client-image/";
        $destination_folder = SITE_DIR_PATH . "/uploaded-files/client-image/thumbs/";
        saveResizedPhoto($img, $width, $height, $source_folder, $destination_folder);


      }
    }

    // echo "insert into `$table_name` set name='$name',caption='$caption',logo_image='$img'";
    // exit;

    $sql = mysqli_query($GLOBALS['dbconn'], "insert into `$table_name` set name='$name',caption='$caption',logo_image='$img'");
    //$_SESSION['session_message'] ='<div class="btn btn-success">' . $name . ' has been added successfully  </div> ';

    header("Location: " . SITE_ADMIN_URL . "/" . $redirect_script_name);
    exit;
  }

}
################ Update Record ##################

if ($action == "update_record") {

  $numCnt = getCount($table_name, " where name='$name' and id!='$catID'");
  if ($numCnt > 0) {
    $_SESSION['session_message'] = '<div class="btn btn-warning">' . $record_type . ' already exist  </div>';
    header("Location: " . SITE_ADMIN_URL . "/" . $script_name . "?start=" . $start . "&parentID=" . $parentID . "&catID=" . $catID . "&pagesize=" . $pagesize);
    exit;
  }

  if ($_FILES['clientimg']['name'] != "") {

    $file_extension = strtolower(getExtension($_FILES['clientimg']['name']));
    if ($file_extension != "jpg" && $file_extension != "gif" && $file_extension != "jpeg" && $file_extension != "png" && $file_extension != "webp") {
      $_SESSION['session_message'] = '<div class="btn btn-warning"> Please upload image (.jpg,.gif,.png Format Only) </div>';
      header("Location: " . SITE_ADMIN_URL . "/" . $script_name . "?start=" . $start . "&parentID=" . $parentID . "&catID=" . $catID . "&pagesize=" . $pagesize);
      exit;
    }
    if ($_FILES['clientimg']['name'] != "") {
      $categoryRes = getResult($table_name, " where id='$catID'", "logo_image");

      $filename = $categoryRes['logo_image'];
      if ($filename != "") {
        $file = site_url . "/uploaded-files/client-image/" . $filename;
        if (file_exists($file)) {
          unlink($file);
        }

        $Client = str_replace(" ", "-", $name);
        $img_name = $Client;

        $img = upload_file($img_name, "clientimg", "uploaded-files/client-image");

        $width = "922";
        $height = "517";
        $source_folder = SITE_DIR_PATH . "/uploaded-files/client-image/";
        $destination_folder = SITE_DIR_PATH . "/uploaded-files/client-image/thumbs/";
        saveResizedPhoto($img, $width, $height, $source_folder, $destination_folder);

        updateTable($table_name, " logo_image='$img' where id='$catID'");
      }


    }
  }

  updateTable($table_name, " name='$name',caption='$caption' where id='$catID'");
  $_SESSION['session_message'] = '<div class="btn btn-success">' . $record_type . ' has been added successfully  </div>';

  header("Location: " . SITE_ADMIN_URL . "/" . $redirect_script_name);
  exit;
}
########################################################
admin_header();
$res = getResult($table_name, " where id='$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="<?= $redirect_script_name ?>">
            <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">
            <div class="form-group row">
              <div class="col">
                <label>Name *</label>
                <div id="the-basics">
                  <input class="typeahead" type="text" name="name" value="<?= $res['name'] ?>"
                    placeholder="Enter Name here" required>
                </div>
              </div>
              <div class="col">
                <label>Description</label>
                <div id="bloodhound">
                  <textarea rows="4" cols="50" class="typeahead" type="text" name="caption" value="<?= $res['caption'] ?>"
                    placeholder="Enter Description here"></textarea>
                </div>
              </div>
            </div>
            <?php
            if ($res['id'] == "") { ?>
              <div class="form-group">
                <label for="exampleTextarea1">Image *</label>
                <input type="file" class="dropify" name="clientimg">
              </div>
            <?php } else { ?>
              <div class="form-group row">
                <div class="col">
                  <label>Image</label>
                  <input type="file" class="dropify" name="clientimg">
                </div>
                <div class="col">
                  <img src="<?= site_url . "/uploaded-files/client-image/" . $res['logo_image'] ?>" alt="image"
                    style="width: 60%;">
                </div>
              </div>
            <?php } ?>
            <?php
            if ($res['id'] == "") {
              ?>
              <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; ?>'">Cancel</button>
          </form>
        </div>
      </div>
    </div>
  </div>
</div>
<!-- content-wrapper ends -->
<?php
admin_footer();
exit;
?>

← Back to Directory Edit File 🔒 Chmod

WP File Manager