<?php
include('../includes/common.php');
if (isset($_COOKIE['adminlogin'])) {
$_SESSION['adminlogin'] = 1;
}
if ($_SESSION['adminlogin'] != 1) {
exit('<script language=\'javascript\'>window.location.href=\'./login.php\';</script>');
}
?>
<?php
$my = isset($_GET['my']) ? $_GET['my'] : null;
$title = '网址管理';
include('head.php');
?>
<section id="main-content">
<section class="wrapper">
<div class="modal fade" align="left" id="search" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal"><span aria-hidden="true">×</span><span class="sr-only">Close</span></button>
<h4 class="modal-title" id="myModalLabel">搜索网址</h4>
</div>
<div class="modal-body">
<input type="text" class="form-control" name="kw" placeholder="请输入网址"><br />
<button type="button" class="btn btn-primary btn-block" id="search_submit">搜索</button>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
</div>
</div>
</div>
</div>
<?php
$uid = $userrow['id'];
if ($my == 'add') {
?>
<div class="row">
<div class="col-lg-12">
<section class="panel">
<header class="panel-heading">
添加新网址
</header>
<div class="panel-body">
<form action="./urllist.php?my=add_submit" method="post" class="cmxform form-horizontal tasi-form" role="form">
<div class="form-group">
<label class="col-sm-2 control-label">uid:</label>
<div class="col-sm-10"><input type="text" name="uid" value="<?php echo $conf['uid'] ?>" class="form-control" required /></div>
</div><br />
<div class="form-group">
<label class="col-sm-2 control-label">默认跳转:</label>
<div class="col-sm-10"><input type="text" name="url" value="" class="form-control" required /></div>
</div><br />
<div class="form-group">
<label class="col-sm-2 control-label">备注:</label>
<div class="col-sm-10"><input type="text" name="remarks" value="" class="form-control" /></div>
</div><br />
<div class="form-group">
<label class="col-sm-2 control-label">访问密码:</label>
<div class="col-sm-10"><input type="text" name="pwd" value="" class="form-control" />
<p class="help-block">留空则不需要输入密码</p>
</div>
</div><br />
<div class="form-group">
<label class="col-sm-2 control-label">QQ跳转:</label>
<div class="col-sm-10"><input type="text" name="qqjump" value="" class="form-control" />
<p class="help-block">留空则为默认跳转</p>
</div>
</div><br />
<div class="form-group">
<label class="col-sm-2 control-label">微信跳转:</label>
<div class="col-sm-10"><input type="text" name="wxjump" value="" class="form-control" />
<p class="help-block">留空则为默认跳转</p>
</div>
</div><br />
<div class="form-group">
<label class="col-sm-2 control-label">支付宝跳转:</label>
<div class="col-sm-10"><input type="text" name="alijump" value="" class="form-control" />
<p class="help-block">留空则为默认跳转</p>
</div>
</div><br />
<div class="form-group">
<div class="col-lg-offset-2 col-lg-10">
<button class="btn btn-danger" type="submit">确认添加</button>
<a href="./urllist.php" class="btn btn-default" type="button">返回列表</a>
</div>
</div>
</form>
</div>
</section>
</div>
</div>
<?php
} elseif ($my == 'add_submit') {
$uid = trim($_POST['uid']);
$url = trim($_POST['url']);
$pwd = trim($_POST['pwd']);
$qqjump = trim($_POST['qqjump']);
$wxjump = trim($_POST['wxjump']);
$alijump = trim($_POST['alijump']);
$remarks = $_POST['remarks'];
$preg = "/^http(s)?:\\/\\/.+/";
if (!preg_match($preg, $url)) {
if ($conf['is_https'] == 1) {
$url = 'https://' . $url;
} else {
$url = 'http://' . $url;
}
}
if (($uid == NULL || $url == NULL)) {
showmsg('保存错误,请确保每项都不为空!', 3);
} else {
$id = getCode(7);
$ip = $_SERVER["REMOTE_ADDR"];
if ($conf['is_https'] == 1) {
$tzurl = 'https://' . $conf['domain'] . '/tz.php?id=' . $id;
} else {
$tzurl = 'http://' . $conf['domain'] . '/tz.php?id=' . $id;
}
$tcn = tcn($tzurl);
$urlcn = urlcn($tzurl);
$sql = "insert into url_list(id,uid,addtime,tcn,urlcn,url,pwd,qqjump,wxjump,alijump,setip,remarks) values('$id','$uid','$nowDate','$tcn','$urlcn','$url','$pwd','$qqjump','$wxjump','$alijump','$ip','$remarks')";
$rs = $conn->query($sql);
if ($rs) {
showmsg('添加网址成功!<br/>新浪 ' . $tcn . '<br/>腾讯 ' . $urlcn . '<br/><br/><a href="./urllist.php">>>返回网址列表</a>', 1);
} else {
showmsg('添加网址失败!', 4);
}
}
} elseif ($my == 'edit_submit') {
$id = $_GET['id'];
$rows = $conn->query("select * from url_list where id = '{$id}'");
if ($rows->num_rows == 0) {
showmsg('当前记录不存在!', 3);
} else {
$tcn = trim($_POST['tcn']);
$urlcn = trim($_POST['urlcn']);
$url = $_POST['url'];
$setip = $_POST['setip'];
$remarks = $_POST['remarks'];
$pwd = trim($_POST['pwd']);
$qqjump = trim($_POST['qqjump']);
$wxjump = trim($_POST['wxjump']);
$alijump = tr