function() {
if(!form().nick) return { err: "请提供 nick" };
form().username = me().nick;
// dbg().trace("测试接口1");
return form();
// return ajax("http://www.konishi.net/", toxml(par), "text/xml");
// return ajax("http://www.konishi.net/", tojson(par), "application/json");
}
function() {
return this.sms.smsleft();
}
function() {
var timestamp, key
timestamp = Math.round(sys.sTime / 1000) // 时间戳 Math.round(sys.sTime / 1000), 另外格式化是: sys.sTime.getVarDate().ToString("yyMMddHHmmss")
key = md5("#duiing-" + timestamp + "^api&token#", 32) // 接口token按时间戳来验证,有效期2分钟
var par = {
url: form("url"), // 视频地址
type: "m3u8_tv",
token: btoa(tojson({ time: timestamp, key: key })) // 加密方式(包含时间戳和key值)
}
var res = ajax("https://jx.duiing.com/api.php", par);
return res;
}
function() {
var username = (form("username") || "").toLowerCase(); // toUpperCase()
var password = (form("password") || "").toLowerCase(); // toUpperCase()
if (!username) return { err: "用户名不可为空。" };
if (!password) return { err: "密码不可为空。" };
var User = db().fetch("select * from manager where user=@username and pass=@password and state=1", { username: username, password: md5(password, 16) });
if(!User) return { err: "用户不存在或尚未绑定。" };
// User.ext = fromjson(User.ext || "{}");
dbg().trace(User.nick + "从 " + env("REMOTE_ADDR") + " 登录");
me().bind(User); // 登录成功,写入session
return { msg: "用户【" + User.user + "】登录成功。" };
}
function() {
if(!me().isLogin) return { err: "需要登录" };
if(me().role != 1) return { err: "没有权限" };
var data = fromjson(tojson(form())); var id = ~~data.id; delete data.id;
if(!data.user) return { err: "用户名必填" };
// data.state = !data.state ? 0 : 1; // 将 on 转为 1,不存在转为 0
data.state = 1;
if(!id) data.pass = md5("666666", 16); // 新用户默认密码为 666666
if(!id) return db().insert("manager", data), { msg: "用户添加成功" };
return db().update("manager", data, { id: id }), { msg: "用户编辑成功" };
}
function() {
if(!me().isLogin) return { err: "需要登录" };
if(me().role != 1) return { err: "没有权限" };
//var data = db().table("manager a").join("clinic b on b.cid=a.cid").
//page("a.wid desc", form("limit") || 20, form("page") || 1).
//select("a.*, b.nick as shop").query();
//return { data: data, count: db().pager.rownum, code: 0 };
var data = dbx().table("manager").page("id desc", form("limit") || 20, form("page") || 1).
select("user, nick as shop").query();
return { data: data, count: dbx().pager.rownum, code: 0 };
}
function() {
if(!me().isLogin) return { err: "需要登录。" };
var User = dbx(0).table("manager").where("id=@id").fetch({ id: me().id });
if(!User) return { err: "用户不存在。" };
// delete User.HeadImageUrl;
// 获取用户其他信息
return User;
}
function() {
if(!me().isLogin) return { err: "需要登录。" };
// 校验旧密码
if(!db().fetch("select * from manager where id=@id and pass=@pass", {
id: me().id, pass: md5(form("pass0"), 16)
})) return { err: "原密码错误" };
var pass = form("pass1") || "";
if(pass.length < 5) return { err: "新密码长度不够" };
db().update("manager", { pass: md5(pass, 16) }, { id: me().id });
return { msg: "密码修改成功,请牢记新密码" };
}
function() {
if(!me().isLogin) return { err: "需要登录。" };
if(me().role != 1) return { err: "没有权限" };
db().update("manager", { pass: md5("666666", 16) }, { id: me().id });
return { msg: "密码重置成功" };
}
function() {
// var data = fromjson(tojson(form()));
var data = {
name: form().name, content: form().content, cid: 27
};
if(!data.content) return { err: "缺少评论内容" };
db().insert("comment", data);
// dbg().trace(this.smssend("1388888888", "感谢您对我们的信任。"), "13888888");
return { id: db().scalar("select @@identity") };
}
function() {
// return db().table("payment a").join("gbook b on b.gbid=a.gbid").where("a.orderno=@ordernum").select("a.*, b.msg, b.addtime").fetch({ orderno: form("orderno") }) || "null";
// return db().table("comment").where("name=@username").select("*").fetch({ username: form("username")}) || "null"; // 调用1条
// db().insert("payment", { gbid: 1, orderno: "1234567890", tradeno: "430124202106180839", fee: 100, paytype: 0 });
if(!form("username")) {
return {
rows: db().table("comment").page("id desc", form("size") || 3, form("page") || 1).query(), pager: db().pager
};
}
var Comments = db().table("comment").where("name=@username").query({ username: form("username")});
if(Comments.length == 0) return { err: "评论记录不存在。" };
return Comments;
}
function() {
// return wxjsapisign(form("url"));
}
function() {
if(me().isLogin) me().lose();
return { msg: "登录已注销。" };
}
function() {
return sys.sTime.getVarDate().ToString("yyMMddHHmmss");
}
function() {
// var wc = new System.Net.WebClient;
// wc.Encoding = System.Text.Encoding.UTF8;
// wc.Headers.Add("Authorization", "APPCODE 8b4ef3a501e349b2b82e48004c18c997");
// return wc.DownloadString("https://ips.market.alicloudapi.com/iplocaltion?ip=222.92.62.12");
// 下载组件
// System.Net.WebClient.DownloadFile(url, Server.MapPath("savePath"));
var wc = new System.Net.WebClient;
// wc.Encoding = System.Text.Encoding.UTF8;
var bin = wc.DownloadData(form("picurl"));
// return { src: "data:image/jpeg;base64," + Convert.ToBase64String(bin) };
return Convert.ToBase64String(bin);
}