-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathadd.php
More file actions
47 lines (41 loc) · 1 KB
/
add.php
File metadata and controls
47 lines (41 loc) · 1 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
<?php
require 'include/init.php';
$check = CHECK;
if(!$check){
alert('你没有权限这样做', $indexPage);
die();
}
if(isset($_GET['t'])){
$t = $_GET['t'];
}else{
alert('数据传输错误', $indexPage);
die();
}
$types = (new Model())->table('favorites_type')->select();
if($_POST){
if($t == 'link'){
if(preg_match('/^(http:\/\/|https:\/\/)/',$_POST['f_url'])){
$data = array(
'f_name' => $_POST['f_name'],
'f_url' => $_POST['f_url'],
't_id' => $_POST['t_id'],
'f_addtime' => time()
);
$res = (new Model())->table('favorites')->insert($data);
}else{
alert('链接格式不对!记得带上http://或者https://!');
}
}elseif($t == 'type'){
$data = array(
't_name' => $_POST['t_name']
);
$res = (new Model())->table('favorites_type')->insert($data);
}
if($res){
alert('添加成功', $indexPage);
}else{
alert('数据出现错误');
}
}
//加载模板文件
include $view->load('add');