mirror of https://github.com/calzoneman/sync.git
Fixes
This commit is contained in:
parent
cc241da5cf
commit
5d9a8a1a3f
|
@ -8,6 +8,7 @@ var jade = require("jade");
|
||||||
var fs = require("fs");
|
var fs = require("fs");
|
||||||
var path = require("path");
|
var path = require("path");
|
||||||
var webserver = require("./webserver");
|
var webserver = require("./webserver");
|
||||||
|
var cookieall = webserver.cookieall;
|
||||||
var sendJade = require("./jade").sendJade;
|
var sendJade = require("./jade").sendJade;
|
||||||
var Logger = require("../logger");
|
var Logger = require("../logger");
|
||||||
var $util = require("../utilities");
|
var $util = require("../utilities");
|
||||||
|
@ -39,25 +40,16 @@ function handleLogin(req, res) {
|
||||||
loginError: err
|
loginError: err
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
res.cookie("auth", user.name + ":" + user.hash, {
|
cookieall(res, "auth", user.name + ":" + user.hash, {
|
||||||
expires: new Date(Date.now() + 7*24*60*60*1000),
|
expires: new Date(Date.now() + 7*24*60*60*1000),
|
||||||
httpOnly: true
|
httpOnly: true
|
||||||
});
|
});
|
||||||
|
|
||||||
res.cookie("auth", user.name + ":" + user.hash, {
|
cookieall(res, "rank", user.global_rank, {
|
||||||
domain: Config.get("http.domain"),
|
|
||||||
expires: new Date(Date.now() + 7*24*60*60*1000),
|
expires: new Date(Date.now() + 7*24*60*60*1000),
|
||||||
httpOnly: true
|
httpOnly: true
|
||||||
});
|
});
|
||||||
|
|
||||||
if (Config.get("https.enabled")) {
|
|
||||||
res.cookie("auth", user.name + ":" + user.hash, {
|
|
||||||
domain: Config.get("https.domain"),
|
|
||||||
expires: new Date(Date.now() + 7*24*60*60*1000),
|
|
||||||
httpOnly: true
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
// Try to find an appropriate redirect
|
// Try to find an appropriate redirect
|
||||||
var ref = req.header("referrer");
|
var ref = req.header("referrer");
|
||||||
if (!ref) {
|
if (!ref) {
|
||||||
|
|
|
@ -55,12 +55,22 @@ function logRequest(req, status) {
|
||||||
|
|
||||||
httplog.log([
|
httplog.log([
|
||||||
ipForRequest(req),
|
ipForRequest(req),
|
||||||
req.route.method.toUpperCase(),
|
req.method,
|
||||||
req.path,
|
req.path,
|
||||||
req.header("user-agent")
|
req.header("user-agent")
|
||||||
].join(" "));
|
].join(" "));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function cookieall(res, name, val, opts) {
|
||||||
|
res.cookie(name, val, opts);
|
||||||
|
opts.domain = Config.get("http.domain");
|
||||||
|
res.cookie(name, val, opts);
|
||||||
|
if (Config.get("https.enabled")) {
|
||||||
|
opts.domain = Config.get("https.domain");
|
||||||
|
res.cookie(name, val, opts);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Redirects a request to HTTPS if the server supports it
|
* Redirects a request to HTTPS if the server supports it
|
||||||
*/
|
*/
|
||||||
|
@ -87,7 +97,6 @@ function redirectHttp(req, res) {
|
||||||
if (port !== 80) {
|
if (port !== 80) {
|
||||||
domain += ":" + port;
|
domain += ":" + port;
|
||||||
}
|
}
|
||||||
console.log(domain);
|
|
||||||
res.redirect(domain + req.path);
|
res.redirect(domain + req.path);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -232,9 +241,25 @@ function handleContactPage(req, res) {
|
||||||
function static(dir) {
|
function static(dir) {
|
||||||
dir = path.join(__dirname, dir);
|
dir = path.join(__dirname, dir);
|
||||||
return function (req, res) {
|
return function (req, res) {
|
||||||
|
if (isSuspicious(req)) {
|
||||||
|
logRequest(req, 403);
|
||||||
|
res.status(403);
|
||||||
|
if (typeof req.header("user-agent") === "string" &&
|
||||||
|
req.header("user-agent").toLowerCase() === "zmeu") {
|
||||||
|
res.send("This server disallows requests from ZmEu.");
|
||||||
|
} else {
|
||||||
|
res.send("The request " + req.route.method.toUpperCase() + " " +
|
||||||
|
req.path + " looks pretty fishy to me. Double check that " +
|
||||||
|
"you typed it correctly.");
|
||||||
|
}
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
res.sendfile(req.path.replace(/^\//, ""), {
|
res.sendfile(req.path.replace(/^\//, ""), {
|
||||||
maxAge: Config.get("http.cache-ttl") * 1000,
|
maxAge: Config.get("http.cache-ttl") * 1000,
|
||||||
root: dir
|
root: dir
|
||||||
|
}, function (err) {
|
||||||
|
logRequest(req);
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
@ -266,24 +291,6 @@ module.exports = {
|
||||||
require("./auth").init(app);
|
require("./auth").init(app);
|
||||||
require("./account").init(app);
|
require("./account").init(app);
|
||||||
require("./acp").init(app);
|
require("./acp").init(app);
|
||||||
app.all("*", function (req, res, next) {
|
|
||||||
if (isSuspicious(req)) {
|
|
||||||
logRequest(req, 403);
|
|
||||||
res.status(403);
|
|
||||||
if (typeof req.header("user-agent") === "string" &&
|
|
||||||
req.header("user-agent").toLowerCase() === "zmeu") {
|
|
||||||
res.send("This server disallows requests from ZmEu.");
|
|
||||||
} else {
|
|
||||||
res.send("The request " + req.route.method.toUpperCase() + " " +
|
|
||||||
req.path + " looks pretty fishy to me. Double check that " +
|
|
||||||
"you typed it correctly.");
|
|
||||||
}
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
logRequest(req);
|
|
||||||
next();
|
|
||||||
});
|
|
||||||
//app.use(express.static("www"));
|
|
||||||
app.use(static(path.join("..", "..", "www")));
|
app.use(static(path.join("..", "..", "www")));
|
||||||
},
|
},
|
||||||
|
|
||||||
|
@ -293,5 +300,7 @@ module.exports = {
|
||||||
|
|
||||||
redirectHttps: redirectHttps,
|
redirectHttps: redirectHttps,
|
||||||
|
|
||||||
redirectHttp: redirectHttp
|
redirectHttp: redirectHttp,
|
||||||
|
|
||||||
|
cookieall: cookieall
|
||||||
};
|
};
|
||||||
|
|
|
@ -9,7 +9,7 @@ mixin head()
|
||||||
//link(href="/css/bootstrap-theme.min.css", rel="stylesheet")
|
//link(href="/css/bootstrap-theme.min.css", rel="stylesheet")
|
||||||
link(href="/css/sticky-footer-navbar.css", rel="stylesheet")
|
link(href="/css/sticky-footer-navbar.css", rel="stylesheet")
|
||||||
link(href="/css/cytube.css", rel="stylesheet")
|
link(href="/css/cytube.css", rel="stylesheet")
|
||||||
link(id="usertheme", href="/css/themes/default.css", rel="stylesheet")
|
link(id="usertheme", href="/css/themes/slate.css", rel="stylesheet")
|
||||||
script(src="/js/theme.js")
|
script(src="/js/theme.js")
|
||||||
//[if lt IE 9]
|
//[if lt IE 9]
|
||||||
<script src="https://oss.maxcdn.com/libs/html5shiv/3.7.0/html5shiv.js"></script>
|
<script src="https://oss.maxcdn.com/libs/html5shiv/3.7.0/html5shiv.js"></script>
|
||||||
|
|
|
@ -36,7 +36,6 @@ mixin navdefaultlinks(page)
|
||||||
li: a(href="/login") Login
|
li: a(href="/login") Login
|
||||||
li: a(href="/register") Register
|
li: a(href="/register") Register
|
||||||
|
|
||||||
|
|
||||||
mixin navloginlogout(redirect)
|
mixin navloginlogout(redirect)
|
||||||
if loggedIn
|
if loggedIn
|
||||||
mixin navlogoutform(redirect)
|
mixin navlogoutform(redirect)
|
||||||
|
|
|
@ -29,7 +29,7 @@ mixin us-general
|
||||||
label.control-label.col-sm-4(for="#us-theme") Theme
|
label.control-label.col-sm-4(for="#us-theme") Theme
|
||||||
.col-sm-8
|
.col-sm-8
|
||||||
select#us-theme.form-control
|
select#us-theme.form-control
|
||||||
option(value="default") Default
|
option(value="/css/themes/light.css") Light
|
||||||
option(value="/css/themes/bootstrap-theme.min.css") Bootstrap
|
option(value="/css/themes/bootstrap-theme.min.css") Bootstrap
|
||||||
option(value="/css/themes/slate.css") Slate
|
option(value="/css/themes/slate.css") Slate
|
||||||
option(value="/css/themes/cyborg.css") Cyborg
|
option(value="/css/themes/cyborg.css") Cyborg
|
||||||
|
|
|
@ -908,7 +908,7 @@ Callbacks = {
|
||||||
$(li).appendTo($("#library"));
|
$(li).appendTo($("#library"));
|
||||||
},
|
},
|
||||||
|
|
||||||
itemsPerPage: 10
|
itemsPerPage: 100
|
||||||
};
|
};
|
||||||
|
|
||||||
var p = Paginate(data.results, opts);
|
var p = Paginate(data.results, opts);
|
||||||
|
|
|
@ -9,7 +9,7 @@ The above copyright notice and this permission notice shall be included in all c
|
||||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
var CL_VERSION = "3.0.0";
|
var CL_VERSION = 3.0;
|
||||||
|
|
||||||
var CLIENT = {
|
var CLIENT = {
|
||||||
rank: -1,
|
rank: -1,
|
||||||
|
@ -99,9 +99,8 @@ function getOrDefault(k, def) {
|
||||||
}
|
}
|
||||||
|
|
||||||
var USEROPTS = {
|
var USEROPTS = {
|
||||||
theme : getOrDefault("theme", "default"),
|
theme : getOrDefault("theme", "/css/themes/slate.css"),
|
||||||
css : getOrDefault("css", ""),
|
layout : getOrDefault("layout", "fluid"),
|
||||||
layout : getOrDefault("layout", "default"),
|
|
||||||
synch : getOrDefault("synch", true),
|
synch : getOrDefault("synch", true),
|
||||||
hidevid : getOrDefault("hidevid", false),
|
hidevid : getOrDefault("hidevid", false),
|
||||||
show_timestamps : getOrDefault("show_timestamps", true),
|
show_timestamps : getOrDefault("show_timestamps", true),
|
||||||
|
@ -164,5 +163,16 @@ function eraseCookie(name) {
|
||||||
createCookie(name,"",-1);
|
createCookie(name,"",-1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
(function () {
|
||||||
|
var localVersion = parseFloat(getOpt("version"));
|
||||||
|
if (isNaN(localVersion)) {
|
||||||
|
USEROPTS.theme = "/css/themes/slate.css";
|
||||||
|
USEROPTS.layout = "fluid";
|
||||||
|
setOpt("theme", "/css/themes/slate.css");
|
||||||
|
setOpt("layout", "fluid");
|
||||||
|
setOpt("version", CL_VERSION);
|
||||||
|
}
|
||||||
|
})();
|
||||||
|
|
||||||
/* to be implemented in callbacks.js */
|
/* to be implemented in callbacks.js */
|
||||||
function setupCallbacks() { }
|
function setupCallbacks() { }
|
||||||
|
|
|
@ -3,7 +3,7 @@
|
||||||
return s.trim();
|
return s.trim();
|
||||||
});
|
});
|
||||||
|
|
||||||
var theme = "default";
|
var theme = "/css/themes/slate.css";
|
||||||
for (var i = 0; i < c.length; i++) {
|
for (var i = 0; i < c.length; i++) {
|
||||||
if (c[i].indexOf("cytube-theme=") === 0) {
|
if (c[i].indexOf("cytube-theme=") === 0) {
|
||||||
theme = c[i].split("=")[1];
|
theme = c[i].split("=")[1];
|
||||||
|
@ -11,7 +11,8 @@
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (theme !== "default") {
|
if (theme !== "/css/themes/slate.css") {
|
||||||
|
console.log("THEME COOKIE:", theme);
|
||||||
var cur = document.getElementById("usertheme");
|
var cur = document.getElementById("usertheme");
|
||||||
cur.parentNode.removeChild(cur);
|
cur.parentNode.removeChild(cur);
|
||||||
var css = document.createElement("link");
|
var css = document.createElement("link");
|
||||||
|
|
|
@ -662,7 +662,7 @@ function applyOpts() {
|
||||||
$("#usertheme").remove();
|
$("#usertheme").remove();
|
||||||
var theme = USEROPTS.theme;
|
var theme = USEROPTS.theme;
|
||||||
if (theme === "default") {
|
if (theme === "default") {
|
||||||
theme = "/css/themes/default.css";
|
theme = "/css/themes/slate.css";
|
||||||
}
|
}
|
||||||
$("<link/>").attr("rel", "stylesheet")
|
$("<link/>").attr("rel", "stylesheet")
|
||||||
.attr("type", "text/css")
|
.attr("type", "text/css")
|
||||||
|
|
Loading…
Reference in New Issue