Your IP : 216.73.216.91


Current Path : /var/www/html/nadineandmiabeauty/admin/classes/
Upload File :
Current File : /var/www/html/nadineandmiabeauty/admin/classes/allfunctions.php

<?php
	require_once('../autoload.php');
	$config = config::getAppConfig();
	$user = new user();
	$user->checklogin($config['loginPath']);
	$db = new pdocrudhandler();
	extract($_POST);
	//print_r($_POST);
	//exit();


	// echo $_GET['id'];
	// $bimage = $_FILES['bimage']['name'];
	// $uploadfile=$_FILES["bimage"]["tmp_name"];
	// $folder ="blogimg/";
	// $target_file = $folder.$_FILES['bimage']['name'];
	// move_uploaded_file($_FILES["bimage"]["tmp_name"], "$folder".$_FILES["bimage"]["name"]);
	
	// TO ADD BLOG INTO DATABASE

	if ($action == 'addbloginfo') {
	$bimage = $_FILES['bimage']['name'];
	$uploadfile=$_FILES["bimage"]["tmp_name"];
	$folder ="blogimg/";
	$target_file = $folder.$_FILES['bimage']['name'];
	move_uploaded_file($_FILES["bimage"]["tmp_name"], "$folder".$_FILES["bimage"]["name"]);
	$userdata = [
	'bimage'=> $bimage,
	'btitle'=>$btitle,
	'bheading'=>$bheading,
	'bsummary'=>$bsummary,
	'bdescription'=>$bdescription,
	'youtubeurl'=>$youtubeurl,
	];
	$res = $db->insert($config['table']['blog'],$userdata);
	if($res['status'] == 'success'){
		header('location:../viewblog.php?addedblog=true');
	}
}
	// TO ADD BLOG INTO Update
	if ($action == 'updatebloginfo') {
		$bimage = (empty($_FILES['bimage']['name'])) ? $_POST['bimage'] : $_FILES['bimage']['name'];
		//echo "<pre>";print_r($_FILES); print_r($_POST);exit;
		$uploadfile=$_FILES["bimage"]["tmp_name"];
		$folder ="blogimg/";
		$target_file = $folder.$_FILES['bimage']['name'];
		move_uploaded_file($_FILES["bimage"]["tmp_name"], "$folder".$_FILES["bimage"]["name"]);
		$id = $_GET['id'];
		$userdata = [
		'bimage'=> $bimage,
		'btitle'=>$btitle,
		'bheading'=>$bheading,
		'bsummary'=>$bsummary,
		'bdescription'=>$bdescription,
		'youtubeurl'=>$youtubeurl,
		];
		$res = $db->update($config['table']['blog'],$userdata,'where id = ?',array($id));
		if($res['status'] == 'success'){
		header('location:../viewblog.php?updateblog=true');
	}
}

	// DELETE BLOG
	if ($action == 'deleteblog') {
		$res = $db->delete($config['table']['blog'],"where id = ?", array($id));
		if($res['status'] == 'success'){
		header('location:../viewblog.php?deletedblog=true');
	}
	}

	// DELETE Contact us msgs
	if ($action == 'deletecontactus') {
		$res = $db->delete($config['table']['contactus'],"where id = ?", array($id));
		if($res['status'] == 'success'){
			header('location:../contactus.php?deletedcontactus=true');
		}
	}

	// Delet  comments 
	if ($action == 'deletecomment') {
		$res = $db->delete($config['table']['comment'],"where id = ?", array($cmt_id));
		if($res['status'] == 'success'){
		header('location:../viewcomments.php?deletedcomment=true');
	}
	}

	//update the status

	if ($action == 'updatecommentstatus') {
		$userdata = [
		'active'=>'1'
		];
		$res = $db->update($config['table']['comment'],$userdata,'where id = ?',array($cmt_id));
		if($res['status'] == 'success'){
			//do something here
			header('location:../viewcomments.php?statusactive=true');
	}
	}

	// Deavtivate status
	if ($action == 'deactivatecommentstatus') {
		$userdata = [
		'active'=>'0'
		];
		$res = $db->update($config['table']['comment'],$userdata,'where id = ?',array($cmt_id));
		if($res['status'] == 'success'){
			//do something here
			header('location:../viewcomments.php?statusactive=true');
	}
	}


	//DELETE SUBSCRIBER
	if ($action == 'deletesubscriber') {
		$res = $db->delete($config['table']['subscriber'],"where email = ?", array($email));
		if($res['status'] == 'success'){
		header('location:../viewsubscriber.php?deletedsubscriber=true');
	}
	}

	// ABOUT US EDIT
	if ($action == 'aboutusadd') {
		echo $aboutustxt;
		$userdata = [
		'abouttxt'=> $aboutustxt,
		];
		$res = $db->update($config['table']['aboutus'],$userdata,'where id = 2');
			if($res['status'] == 'success'){
				//do something here
				header('location:../aboutusedit.php?statusactive=true');
		}
	}
	
?>
<?php	
	
	

	// extract($_POST);
	// print_r($_POST);

/*
//Insert Example
$userdata = [
	'username'=>'moiz',
	'password'=>'123',
	'email'=>'moiz@gmail.com',
	'cell'=>'013564'
];
$res = $db->insert($config['table']['user'],$userdata);
if($res['status'] == 'success'){
	//do something here
	print_r($res);
}
*/


//Udpate Example
// $userdata = [
// 	'username'=>'ammar',
// 	'cell'=>'99999'
// ];
// $res = $db->update($config['table']['user'],$userdata,'where id = ?',array(2));
// if($res['status'] == 'success'){
// 	//do something here
// 	print_r($res);
// }

// ,"where id = ?", array(*)

// //Select Example
// echo "he";
// $res = $db->select($config['table']['user'],array("*"));
// if($res['status'] == 'success'){
// 	//do something here
// 	echo $res['result'][0]->username;
// 	echo "<br>";
// 	echo $res['result'][0]->email;
// 	echo "<pre>";
// 	echo $res['result'][0]->cell;
// 	print_r($res);
// }


/*
$res = $db->delete($config['table']['user'],"where id = ?", array(2));
if($res['status'] == 'success'){
	//do something here
	print_r($res);
}
*/

/*
//Service Example
$res = $db->select($config['table']['user'],array("*"));
if($res['status'] == 'success'){
	//do something here;
	echo json_encode($res);
}
*/

?>