-
Notifications
You must be signed in to change notification settings - Fork 0
/
post.php
126 lines (114 loc) · 3.22 KB
/
post.php
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
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
<?php
require 'libs/Smarty.class.php';
require_once('config.php');
require_once('data/class_data_res.php');
require_once('data/class_data_link.php');
require_once('include/class_com_fn.php');
use data\isa_res_info as isa_res_info;
use data\isa_res_link as isa_res_link;
use com\cfun as cfun;
$smarty = new Smarty;
$res = new isa_res_info;
$dlink = new isa_res_link;
$id = -1;
$info = $res->get();
$linkList[0] = $dlink->get();
$smarty->assign("desc", "发布一个新资源", true);
$smarty->assign("title", "新增", true);
if(!cfun::verifysess())
{
header ("Location:".LOCALHOST."/index.php") ;
}
// 删除资源
if(isset($_GET["del"]))
{
$info = array(
"id" => $_GET["del"],
"valid" => 0,
);
$res->update($info);
header ("Location:".LOCALHOST."/index.php");
die();
}
// 删除资源链接
if(isset($_GET["delink"]))
{
$link = array(
"id" => $_GET["delink"],
"valid" => 0,
);
$dlink->update($link);
echo "<script>opener.location.reload();window.close();</script>";
die();
}
// 加载资源信息
if(isset($_GET["id"]))
{
$id = $_GET["id"];
$query["res"] = $id;
$linkList = $dlink->select($query);
$query["id"] = $id;
$infos = $res->select($query);
if(count($infos) > 0)
{
$info = $infos[0];
$info["tags"] = join(",", $info["tags"]);
$smarty->assign("title", $info["name"], true);
$smarty->assign("desc", "编辑资源信息", true);
}
}
// 修改资源信息
if(isset($_POST["id"]))
{
$res->set($_POST);
if($_POST["id"] > 0)
{
$res->update();
$info = $res->get();
// 解析资源链接,格式 链接名,链接(提取码描述:提取码)
$linkPost = explode("\n", cfun::replacezh($_POST["links"]));
$id = $_POST["id"];
foreach($linkPost as $link)
{
$linkinfo = explode(",", $link);
if(count($linkinfo) <= 1) continue;
$linkext = explode("(", trim($linkinfo[1]));
$extDesc = "";
$link = trim($linkext[0]);
if(count($linkext) > 1){
$linkext = trim(trim($linkext[1], ")"));
$exts = explode(":", $linkext);
if (count($exts) > 1) $linkext = trim($exts[1]);
else $linkext = trim($exts[0]);
if (count($exts) > 1) $extDesc = trim($exts[0]);
else $extDesc = '提取码';
}
else {
$linkext = "";
}
$linkinfo = array(
'resId' => $id,
'source' => $linkinfo[0],
'resLink' => $link,
'extDesc' => $extDesc,
'extCode' => $linkext,
);
// 解析一条链接,存入资料库
$dlink->set($linkinfo);
$dlink->insert();
}
$query["res"] = $id;
unset($query["id"]);
$linkList = $dlink->select($query);
}
else
{
$id = $res->insert();
header("Location:".LOCALHOST."/post.php?id=".$id);
}
}
$smarty->assign("id", $id);
$smarty->assign("info", $info);
$smarty->assign("downloads", $linkList);
$smarty->assign("typelist", $TYPELIST);
$smarty->display('post.html');