添加图片上传和功能开关

This commit is contained in:
LyLme 2022-02-22 03:02:24 +08:00
parent 2618486b97
commit 63700aac3c
1 changed files with 75 additions and 34 deletions

View File

@ -1,6 +1,20 @@
<?php
$title = '基本设置';
include './head.php';
function uploadimg($arr,$uppath,$uptype)
{
if((($arr["type"]=="image/jpeg") ||($arr["type"]=="image/jpg") ||($arr["type"]=="image/png")) && $arr["size"] < 10485760 ){
copy($arr["tmp_name"],ROOT.$uppath);
saveSetting($uptype,'/'.$uppath);
}
else if ($arr["size"]==0) {}
else
{
echo '<script>alert("上传的图片大小超过10MB或类型不符");history.go(-1);</script>';
}
}
$set=isset($_GET['set'])?$_GET['set']:null;
if($set=='save'){
@ -11,8 +25,10 @@ if($set=='save'){
$description=$_POST['description'];
$copyright=$_POST['copyright'];
$icp=$_POST['icp'];
$yan = $_POST['yan'];
$tq = $_POST['tq'];
if($yan=='true'){saveSetting('yan','true');}else{saveSetting('yan','false');}
if($tq=='true'){saveSetting('tq','true');}else{saveSetting('tq','false');}
saveSetting('title',$title);
saveSetting('logo',$logo);
saveSetting('background',$background);
@ -20,13 +36,19 @@ if($set=='save'){
saveSetting('description',$description);
saveSetting('copyright',$copyright);
saveSetting('icp',$icp);
uploadimg($_FILES["logoimg"],'assets/img/logo.png','logo');
uploadimg($_FILES["backgroundimg"],'assets/img/background.jpg','background');
echo '<script>alert("修改成功!");history.go(-1);</script>';
echo '<script>alert("修改成功!");window.location.href="/admin/set.php";</script>';
}
else{
?>
<script>
function updatetext(check){
document.getElementById(check).innerHTML="重新选择";
}
</script>
<!--页面主要内容-->
<main class="lyear-layout-content">
@ -39,28 +61,37 @@ else{
<div class="tab-content">
<div class="tab-pane active">
<form action="set.php?set=save" method="post" name="edit-form" class="edit-form">
<form action="set.php?set=save" method="post" name="edit-form" class="edit-form" enctype="multipart/form-data">
<div class="form-group">
<label for="web_site_title">网站标题</label>
<input class="form-control" type="text" id="web_site_title" name="title" value="<?php echo $conf['title']?>" placeholder="请输入站点标题" required >
<!--<small class="help-block">调用方式:<code>config('web_site_title')</code></small>-->
</div>
</div>
<div class="form-group">
<label for="web_site_logo">网站LOGO</label>
<!--<div class="input-group">-->
<div class="input-group">
<input type="text" class="form-control" name="logo" id="web_site_logo" value="<?php echo $conf['logo']?>" />
<small class="help-block">填写相对于网站根目录的绝对地址或http开头的url</small>
<!--<div class="input-group-btn"><button class="btn btn-default" type="button">上传图片</button></div>-->
<div class="input-group-btn">
<label class="btn btn-default" for="logoimg" id="checklogo" type="button">选择图片</label >
<input type="file" style="display:none" accept=".png,.jpeg,.jpg" id="logoimg" name="logoimg" onclick = "updatetext('checklogo');"/>
</div>
</div>
<small class="help-block">填写图片的URL<code>/img/logo.png</code><code>http://www.xxx.com/img/logo.png</code>或从<code>本地上传</code></small>
</div>
<div class="form-group">
<label for="web_site_logo">网站背景</label>
<!--<div class="input-group">-->
<input type="text" class="form-control" name="background" id="web_site_background" value="<?php echo $conf['background']?>" />
<small class="help-block">填写相对于网站根目录的绝对地址或http开头的url</small>
<!--<div class="input-group-btn"><button class="btn btn-default" type="button">上传图片</button></div>-->
</div>
</div>
<label for="web_site_background">网站背景</label>
<div class="input-group">
<input type="text" class="form-control" name="background" accept="image/png,image/jpeg" id="web_site_background" value="<?php echo $conf['background']?>" />
<div class="input-group-btn">
<label class="btn btn-default" id="checkbackground" for="backgroundimg" type="button">选择图片</label >
<input type="file" style="display:none" accept="image/png,image/jpeg" id="backgroundimg" name="backgroundimg" onclick = "updatetext('checkbackground');"/>
</div></div>
<small class="help-block">填写图片的URL<code>/img/logo.png</code><code>http://www.xxx.com/img/logo.png</code>或从<code>本地上传</code></small>
</div>
<div class="form-group">
<label for="web_site_keywords">站点关键词</label>
<input class="form-control" type="text" id="web_site_keywords" name="keywords" value="<?php echo $conf['keywords']?>" placeholder="请输入站点关键词" >
@ -73,22 +104,33 @@ else{
</div>
<div class="form-group">
<label for="web_site_copyright">版权所有</label>
<input class="form-control" type="text" id="web_site_copyright" name="copyright" value="<?php echo $conf['copyright']?>" placeholder="请输入版权信息" >
<label for="web_site_copyright">底部版权</label>
<textarea type="text" class="form-control" name="copyright" placeholder="请输入版权信息支持HTML代码"><?php echo $conf['copyright']?></textarea>
<small class="help-block">显示在首页底部的版权提示,<code>支持HTML代码</code>,可填写网站统计代码</small>
</div>
<div class="form-group">
<label for="web_site_icp">备案信息</label>
<input class="form-control" type="text" id="web_site_icp" name="icp" value="<?php echo $conf['icp']?>" placeholder="请输入备案信息" >
<label for="web_site_icp">备案</label>
<input class="form-control" type="text" id="web_site_icp" name="icp" value="<?php echo $conf['icp']?>" placeholder="请输入备案号,留空首页不显示备案信息" >
</div>
<!--<div class="form-group">-->
<!-- <label class="btn-block" for="web_site_status">站点开关</label>-->
<!-- <label class="lyear-switch switch-solid switch-primary">-->
<!-- <input type="checkbox" checked="">-->
<!-- <span></span>-->
<!-- </label>-->
<!-- <small class="help-block">站点关闭后将不能访问,后台可正常登录</small>-->
<!--</div>-->
<div class="form-group">
<label class="btn-block" for="web_yan_status">随机一言开关</label>
<label class="lyear-switch switch-solid switch-cyan">
<input type="checkbox" <?php if($conf['yan']!='false'){ echo 'checked="checked"'; }?> name="yan" value="true">
<span></span>
</label>
</div>
<div class="form-group">
<label class="btn-block" for="web_tq_status">天气显示开关</label>
<label class="lyear-switch switch-solid switch-primary">
<input type="checkbox" <?php if($conf['tq']!='false'){ echo 'checked="checked"'; }?> name="tq" value="true">
<span></span>
</label>
</div>
<div class="form-group">
<button type="submit" class="btn btn-primary m-r-5"> </button>
@ -107,11 +149,10 @@ else{
</main>
<!--End 页面主要内容-->
</div>
</div>
<?php
include './footer.php';
}
}
include './footer.php';
?>