<?php
require_once('../database/header.php');
?>
<div class="main-panel">
<div class="content-wrapper">

<?php if($userdata['usertype']=="mainadmin" || $userdata['usertype']=="wluser" ) {?>
<!-- DataTales Example -->
<div class="card shadow mb-4">
<div class="card-header py-3 bg-primary">
<h6 class="m-0 font-weight-bold text-white">上传 Logo（3000x100 PX - 最佳显示）</h6>
</div>
<div class="card-body">
<?php
if(isset($_POST['submit']) ){
$allowed_extensions = array("jpg","jpeg","png","gif");	
$logo_ext = strtolower(pathinfo($_FILES['weblogo']['name'], PATHINFO_EXTENSION));

if(in_array($logo_ext, $allowed_extensions) ) {

$web_logo_encode = 'data:image/' . $logo_ext . ';base64,' . base64_encode(file_get_contents($_FILES['weblogo']['tmp_name']));

$sql = "UPDATE `settings` SET `weblogo`=:weblogo WHERE users=:users";
$stmt = $conn->prepare($sql);
$stmt->bindParam(":weblogo", $web_logo_encode);
$stmt->bindParam(":users", $userdata['id']);
if($stmt->execute()){
echo '<div class="alert alert-success" role="alert">
<strong>Logo！</strong> 添加成功！</div>';
} else {
echo '<div class="alert alert-danger" role="alert">
<strong>无效！</strong> 数据未插入！</div>';
}

}else {
echo '<div class="alert alert-danger" role="alert">
<strong>无效！</strong> 文件！</div>';
}
	

	
	
}

?>
	
			
 <form class="user" action="" method="POST" enctype="multipart/form-data">

<div class="form-group row">
<div class="col-sm-12 mb-3 mb-sm-0">
<input type="file" id="weblogo" name="weblogo" class="form-control">
</div>
				 
<div class="col-sm-12 mb-3 mt-5">
<input required="required" type="submit" name="submit" class="btn btn-info btn-block" value="提交">
</div>
</div> 
							
</form>

<img class="img-fluid" src="<?php echo $webdata['weblogo'];?>" width="200"> 

</div>
</div>
<?php

}else{
?>
<img class="img-fluid" src="../bootstrap/img/cloud.png">
<?php
}
?>
</div>
<!-- /.container-fluid -->
<!-- End of Main Content -->
<?php
require_once('../database/footer.php');
?>