403Webshell
Server IP : 210.245.233.93  /  Your IP : 216.73.216.226
Web Server : Apache/2.2.15 (CentOS)
System : Linux webserver2.onesolution.com.hk 2.6.32-754.35.1.el6.x86_64 #1 SMP Sat Nov 7 12:42:14 UTC 2020 x86_64
User : apache ( 48)
PHP Version : 5.3.3
Disable Function : exec, shell_exec, system, passthru, popen, proc_open, pcntl_exec
MySQL : ON  |  cURL : ON  |  WGET : ON  |  Perl : ON  |  Python : ON  |  Sudo : ON  |  Pkexec : ON
Directory :  /var/www/onesolution.com.hk/onesupport/contract/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Command :


[ Back ]     

Current File : /var/www/onesolution.com.hk/onesupport/contract/add.php
<?php
	session_start();
//checking here
	$schedulecall = 0;
	if (!empty($_POST["schedule_call_3hrs"])) {
		$schedulecall++;
	}
	if (!empty($_POST["schedule_call_half_day"])) {
		$schedulecall++;
	}
	if (!empty($_POST["schedule_call_full_day"])) {
		$schedulecall++;
	}

	if($schedulecall > 1){  //only one type of schedule call is allowed
		echo "<script>alert('Only one option is allowed in Schedule Call!');history.back();</script>";
		exit;
	}

	if(strtotime($_POST["contract_from"]) > strtotime($_POST["contract_to"])){
		echo "<script>alert('Contract From Date should before the Contract To Date!');history.back();</script>";
		exit;
	}


	require_once(__DIR__ . '/../checkuser.php');
//-----------------------------------------------------------------------------
// Check permission
//-----------------------------------------------------------------------------
//if (!Util::isAdmin()) {
//	redirectAndExit('index.php?message=No permission!');
//}

//-----------------------------------------------------------------------------
// Save if POST method
//-----------------------------------------------------------------------------
	if (isPost()) {
		$sql        = "SELECT column_name FROM information_schema.columns WHERE table_schema = (SELECT DATABASE()) AND table_name = ?";
		$parameters = array('sup_contract');
		if (!($sth = $dbh->prepare($sql))) {
			throw new Exception("sql prepare statement failure: $sql");
		}
		$sth->setFetchMode(PDO::FETCH_ASSOC);
		if (!$sth->execute($parameters)) {
			throw new Exception("sql execute statement failure: $sql");
		}
		$columns = $sth->fetchAll();

		foreach ($columns as $column) {
			$column = $column['column_name'];
			if (isset($_POST[$column])) {
				$contract[$column] = $_POST[$column];
			}
		}

		$sql        = "SELECT * FROM v_cm_customer_support V_CM_CUSTOMER_SUPPORT WHERE cust_id = ?";
		$parameters = array($contract['customer_id']);
		if (!($sth = $dbh->prepare($sql))) {
			throw new Exception("sql prepare statement failure: $sql");
		}
		$sth->setFetchMode(PDO::FETCH_ASSOC);
		if (!$sth->execute($parameters)) {
			throw new Exception("sql execute statement failure: $sql");
		}
		$customer = $sth->fetch(PDO::FETCH_ASSOC);

		//$contract['email1'] = $customer['email'];

		// Append record time
		$now      = date("Y-m-d H:i:s");
		$contract = array_merge($contract, array(
			'createdate' => $now,
			'createby'   => $_SESSION['webadmin']['id'],
			'lastupdate' => $now,
			'lastupby'   => $_SESSION['webadmin']['id'],
		));

		// Create contract
		$columns    = array();
		$values     = array();
		$parameters = array();
		foreach ($contract as $column => $value) {

			/*if($column == "date_from"){
				$column = "contract_from";
			}

			if($column == "date_to"){
				$column = "contract_to";
			}*/

			$columns[]    = $column;
			$parameters[] = !strlen($value) ? null : $value;
			$values[]     = '?';
		}


		$_contract_from = $_POST["date_from"];
		$_contract_to   = $_POST["date_to"];
		$_customer_id = $_POST["customer_id"];

		//check if that customer has exist contract
		$sql = "SELECT * FROM sup_contract WHERE contract_from <= ? and ? <= contract_to and customer_id = ? and status = ?";

		$parameters4 = array($_contract_to, $_contract_from, $_customer_id, "1");
		if (!($sth = $dbh->prepare($sql))) {
			throw new Exception("sql prepare statement failure: $sql");
		}
		$sth->setFetchMode(PDO::FETCH_ASSOC);
		if (!$sth->execute($parameters4)) {
			throw new Exception("sql execute statement failure: $sql");
		}
		$contract_customer = $sth->fetch(PDO::FETCH_ASSOC);

		if(!empty($contract_customer)){ //that customer has opened contract
			$_SESSION["exist_contract_id"] = $contract_customer['contract_id'];
			redirectAndExit('index.php?message=Unsuccess! This customer already has a opened contract!');

		}

		//contract does not exist
		$sql = "INSERT sup_contract (" . implode(', ', $columns) . ") VALUES (" . implode(', ', $values) . ")";

		if (!($sth = $dbh->prepare($sql))) {
			throw new Exception("sql prepare statement failure: $sql");
		}
		$sth->setFetchMode(PDO::FETCH_ASSOC);
		if (!$sth->execute($parameters)) {
			throw new Exception("sql execute statement failure: $sql");
		}
		$contract['contract_id'] = $dbh->lastInsertId();

		$_SESSION["remark_contract_id"] = $contract['contract_id'];

		$data = array(
			'contract_id' => $contract['contract_id'],
		);


		//update the previous record with correct time

		if (empty($_POST["location"])) {
			if (!empty($customer["billaddress"])) {
				$location = $customer["billaddress"];
			} else {
				$location = $customer["shipaddress"];
			}
		} else {
			$location = $_POST["location"];
		}

		$sql = "UPDATE sup_contract SET `contract_from` = ?, `contract_to` = ?, `location` = ? WHERE contract_id = ?";

		if (!($sth = $dbh->prepare($sql))) {
			throw new Exception("sql prepare statement failure: $sql");
		}
		$sth->setFetchMode(PDO::FETCH_ASSOC);
		if (!$sth->execute(array($_POST["date_from"], $_POST["date_to"],$location, $contract['contract_id']))) {
			throw new Exception("sql execute statement failure: $sql");
		}


		//check the type of contract, no need to do with type 2 (package)
		if($_POST["contract_type"] == 1){

			$remarks = $_POST["task_remarks"];
			$titles = $_POST["task_title"];
			$task_category_ids = $_POST["task_category_id"];


			$arraynum = $_POST["arraynum"];

				foreach($arraynum as $key2 => $rownum){
					$start_date_task = $_POST["start_date_".$rownum];
					$end_date_task = $_POST["end_date_".$rownum];

					foreach($titles as $key => $title){ //each task add the start date and end date

						$_remarks = $remarks[$key];
						$_task_category_id = $task_category_ids[$key];

						$sql = "insert into sup_period_task (contract_id, customer_id, task_title, task_remarks,task_category_id, createdate, createby, lastupdate, lastupby, start_date, end_date) values (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)";

						//echo $sql;
						$parameters = array($contract['contract_id'],$_customer_id, $title, $_remarks,$_task_category_id, $now, $_SESSION['webadmin']['id'], $now, $_SESSION['webadmin']['id'], $start_date_task, $end_date_task);

						if (!($sth = $dbh->prepare($sql))) {
							throw new Exception("sql prepare statement failure: $sql");
						}
						$sth->setFetchMode(PDO::FETCH_ASSOC);
						if (!$sth->execute($parameters)) {
							throw new Exception("sql execute statement failure: $sql");
						}

					}
					}




		}else if($_POST["contract_type"] == 2){

		}else{}



		redirectAndExit("index.php?message=New Contract Created.");
	}

Youez - 2016 - github.com/yon3zu
LinuXploit