<?php
ini_set('display_errors', 1);
ini_set('display_startup_errors', 1);
error_reporting(E_ERROR);
if ($user != 'admin') {
exit("<script>$.alert({title: '警告',content: '你无权访问此页面。',type: 'orange',buttons: {confirm: {text: '确定',btnClass: 'btn-primary',action: function(){history.go(-1);}}}});</script>");
}
?>
<?php
// 修改密码操作
if (isset($_POST['submit']) && isset($_POST['newpassword'])) {
if (empty($_POST['oldpassword']) || empty($_POST['newpassword'])) {
echo"<script>showindex=3;lightyear.notify('密码不能为空!', 'danger', 3000);</script>";
} else {
$username = $_POST['username'];
$oldpassword = md5(PANEL_MD5_KEY . $_POST['oldpassword']);
$newpassword = md5(PANEL_MD5_KEY . $_POST['newpassword']);
$result = $db->mGetRow("luo2888_admin", "*", "where name='$username' and psw='$oldpassword'");
if ($result) {
$db->mSet("luo2888_admin", "psw='$newpassword'", "where name='$username'");
echo"<script>showindex=3;lightyear.notify('密码修改成功!', 'success', 3000);</script>";
} else {
echo"<script>showindex=3;lightyear.notify('原始密码不匹配!', 'danger', 3000);</script>";
}
}
}
// 修改安全码操作
if (isset($_POST['submit']) && isset($_POST['newsecret_key'])) {
if (empty($_POST['newsecret_key']) || empty($_POST['newsecret_key_confirm'])) {
echo"<script>showindex=3;lightyear.notify('安全码不能为空!', 'danger', 3000);</script>";
} else {
$newsecret_key_input = $_POST['newsecret_key'];
$newsecret_key_confirm = $_POST['newsecret_key_confirm'];
if ($newsecret_key_input == $newsecret_key_confirm) {
$newsecret_key = md5($_POST['newsecret_key']);
$db->mSet("luo2888_config", "value='$newsecret_key'", "where name='secret_key'");
echo"<script>showindex=3;lightyear.notify('安全码修改成功!', 'success', 3000);</script>";
} else {
echo"<script>showindex=3;lightyear.notify('两次输入不匹配!', 'danger', 3000);</script>";
}
}
}
if (isset($_POST['closesecret_key'])) {
$db->mSet("luo2888_config", "value=NULL", "where name='secret_key'");
echo"<script>showindex=3;lightyear.notify('安全码验证已关闭!', 'success', 3000);</script>";
}
// 添加管理员操作
if (isset($_POST['adminadd'])) {
if (empty($_POST['addadminname']) || empty($_POST['addadminpsw'])) {
echo"<script>showindex=5;lightyear.notify('管理员的账号或是密码不能为空!', 'danger', 3000);</script>";
} else {
$adminname = $_POST['addadminname'];
$adminpsw = md5(PANEL_MD5_KEY . $_POST['addadminpsw']);
if ($row = $db->mGetRow("luo2888_admin", "*")) {
if ($row[0] > 5) {
echo"<script>showindex=5;lightyear.notify('管理员数量已达上限!', 'danger', 3000);</script>";
} else {
if ($db->mGetRow("luo2888_admin", "*", "where name='$adminname'")) {
echo"<script>showindex=5;lightyear.notify('管理员[$adminname]已存在!', 'danger', 3000);</script>";
} else {
$db->mInt("luo2888_admin", "name,psw", "'$adminname','$adminpsw'");
echo"<script>showindex=5;lightyear.notify('管理员[$adminname]添加成功!', 'success', 3000);</script>";
}
}
}
unset($row);
}
}
// 删除账号操作
if (isset($_POST['deleteadmin'])) {
if (empty($_POST['adminname'])) {
echo"<script>showindex=5;lightyear.notify('请选择要删除的帐号!', 'danger', 3000);</script>";
} else {
foreach ($_POST['adminname'] as $name) {
if ($name <> 'admin') {
$db->mDel("luo2888_admin", "where name='$name'");
echo"<script>showindex=5;lightyear.notify('管理员[$name]已删除!', 'success', 3000);</script>";
} else {
echo"<script>showindex=5;lightyear.notify('管理员[$name]删除失败!', 'danger', 3000);</script>";
}
}
}
}
// 设置管理员权限
if (isset($_POST['saveauthorinfo'])) {
if (!empty($_POST['adminname'])) {
$db->mSet("luo2888_admin", "author=0,useradmin=0,ipcheck=0,epgadmin=0,mealsadmin=0,channeladmin=0", "where name<>'admin'");
if (!empty($_POST['author'])) {
foreach ($_POST['author'] as $adminname) {
$db->mSet("luo2888_admin", "author=1", "where name='$adminname'");
}
}
if (!empty($_POST['useradmin'])) {
foreach ($_POST['useradmin'] as $adminname) {
$db->mSet("luo2888_admin", "useradmin=1", "where name='$adminname'");
}
}
if (!empty($_POST['ipcheck'])) {
foreach ($_POST['ipcheck'] as $adminname) {
$db->mSet("luo2888_admin", "ipcheck=1", "where name='$adminname'");
}
}
if (!empty($_POST['epgadmin'])) {
foreach ($_POST['epgadmin'] as $adminname) {
$db->mSet("luo2888_admin", "epgadmin=1", "where name='$adminname'");
}
}
if (!empty($_POST['mealsadmin'])) {
foreach ($_POST['mealsadmin'] as $adminname) {
$db->mSet("luo2888_admin", "mealsadmin=1", "where name='$adminname'");
}
}
if (!empty($_POST['channeladmin'])) {
foreach ($_POST['channeladmin'] as $adminname) {
$db->mSet("luo2888_admin", "channeladmin=1", "where name='$adminname'");
}
}
echo"<script>showindex=5;lightyear.notify('管理员权限设定已保存!', 'success', 3000);</script>";
} else {
echo"<script>showindex=5;lightyear.notify('请选择管理员!', 'danger', 3000);</script>";
}
}
// 设置APP升级信息
if (isset($_POST['submit']) && isset($_POST['appver'])) {
$versionname = $_POST['appver'];
$appurl = $_POST['appurl'];
$up_size = $_POST["up_size"];
$up_text = $_POST["up_text"];
if (isset($_POST['up_sets'])) {
$up_sets = 1;
} else {
$up_sets = 0;
}
$db->mSet("luo2888_config", "value='$versionname'", "where name='appver'");
$db->mSet("luo2888_config", "value='$appurl'", "where name='appurl'");
$db->mSet("luo2888_config", "value='$up_size'", "where name='up_size'");
$db->mSet("luo2888_config", "value='$up_sets'", "where name='up_sets'");
$db->mSet("luo2888_config", "value='$up_text'", "where name='up_text'");
echo"<script>showindex=4;lightyear.notify('通用版APP升级设置成功!', 'success', 3000);</script>";
}
// 设置APP升级信息
if (isset($_POST['submit']) && isset($_POST['appver_sdk14'])) {
$versionname = $_POST['appver_sdk14'];
$appurl = $_POST['appurl_sdk14'];
$db->mSet("luo2888_config", "value='$versionname'", "where name='appver_sdk14'");
$db->mSet("luo2888_config", "value='$appurl'", "where name='appurl_sdk14'");
echo"<script>showindex=4;lightyear.notify('盒子版APP升级设置成功!', 'success', 3000);</script>";
}
if (isset($_POST['decodersel']) && isset($_POST['buffTimeOut'])) {
$decoder = $_POST['decodersel'];
$buffTimeOut = $_POST['buffTimeOut'];
$trialdays = $_POST['trialdays'];
if ($trialdays == 0) {
$db->mSet("luo2888_users", "exp=0", "where status=-1");
}
$db->mSet("luo2888_config", "value='$decoder'", "where name='decoder'");
$db->mSet("luo2888_config", "value='$trialdays'", "where name='trialdays'");
$db->mSet("luo2888_config", "value='$buffTimeOut'", "where name='buffTimeOut'");
echo"<script>showindex=4;lightyear.notify('设置成功!', 'success', 3000);</script>";
}
if (isset($_POST['submitsetver'])) {
$db->mSet("luo2888_config", "value=value+1", "where name='setver'");
echo"<script>showindex=4;lightyear.notify('推送成功,用户下次启动将恢复