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 path = require("path");
|
||||
var webserver = require("./webserver");
|
||||
var cookieall = webserver.cookieall;
|
||||
var sendJade = require("./jade").sendJade;
|
||||
var Logger = require("../logger");
|
||||
var $util = require("../utilities");
|
||||
|
@ -39,25 +40,16 @@ function handleLogin(req, res) {
|
|||
loginError: err
|
||||
});
|
||||
} 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),
|
||||
httpOnly: true
|
||||
});
|
||||
|
||||
res.cookie("auth", user.name + ":" + user.hash, {
|
||||
domain: Config.get("http.domain"),
|
||||
cookieall(res, "rank", user.global_rank, {
|
||||
expires: new Date(Date.now() + 7*24*60*60*1000),
|
||||
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
|
||||
var ref = req.header("referrer");
|
||||
if (!ref) {
|
||||
|
|
|
@ -55,12 +55,22 @@ function logRequest(req, status) {
|
|||
|
||||
httplog.log([
|
||||
ipForRequest(req),
|
||||
req.route.method.toUpperCase(),
|
||||
req.method,
|
||||
req.path,
|
||||
req.header("user-agent")
|
||||
].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
|
||||
*/
|
||||
|
@ -87,7 +97,6 @@ function redirectHttp(req, res) {
|
|||
if (port !== 80) {
|
||||
domain += ":" + port;
|
||||
}
|
||||
console.log(domain);
|
||||
res.redirect(domain + req.path);
|
||||
return true;
|
||||
}
|
||||
|
@ -232,9 +241,25 @@ function handleContactPage(req, res) {
|
|||
function static(dir) {
|
||||
dir = path.join(__dirname, dir);
|
||||
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(/^\//, ""), {
|
||||
maxAge: Config.get("http.cache-ttl") * 1000,
|
||||
root: dir
|
||||
}, function (err) {
|
||||
logRequest(req);
|
||||
});
|
||||
};
|
||||
}
|
||||
|
@ -266,24 +291,6 @@ module.exports = {
|
|||
require("./auth").init(app);
|
||||
require("./account").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")));
|
||||
},
|
||||
|
||||
|
@ -293,5 +300,7 @@ module.exports = {
|
|||
|
||||
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/sticky-footer-navbar.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")
|
||||
//[if lt IE 9]
|
||||
<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="/register") Register
|
||||
|
||||
|
||||
mixin navloginlogout(redirect)
|
||||
if loggedIn
|
||||
mixin navlogoutform(redirect)
|
||||
|
|
|
@ -29,7 +29,7 @@ mixin us-general
|
|||
label.control-label.col-sm-4(for="#us-theme") Theme
|
||||
.col-sm-8
|
||||
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/slate.css") Slate
|
||||
option(value="/css/themes/cyborg.css") Cyborg
|
||||
|
|
|
@ -908,7 +908,7 @@ Callbacks = {
|
|||
$(li).appendTo($("#library"));
|
||||
},
|
||||
|
||||
itemsPerPage: 10
|
||||
itemsPerPage: 100
|
||||
};
|
||||
|
||||
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.
|
||||
*/
|
||||
|
||||
var CL_VERSION = "3.0.0";
|
||||
var CL_VERSION = 3.0;
|
||||
|
||||
var CLIENT = {
|
||||
rank: -1,
|
||||
|
@ -99,9 +99,8 @@ function getOrDefault(k, def) {
|
|||
}
|
||||
|
||||
var USEROPTS = {
|
||||
theme : getOrDefault("theme", "default"),
|
||||
css : getOrDefault("css", ""),
|
||||
layout : getOrDefault("layout", "default"),
|
||||
theme : getOrDefault("theme", "/css/themes/slate.css"),
|
||||
layout : getOrDefault("layout", "fluid"),
|
||||
synch : getOrDefault("synch", true),
|
||||
hidevid : getOrDefault("hidevid", false),
|
||||
show_timestamps : getOrDefault("show_timestamps", true),
|
||||
|
@ -164,5 +163,16 @@ function eraseCookie(name) {
|
|||
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 */
|
||||
function setupCallbacks() { }
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
return s.trim();
|
||||
});
|
||||
|
||||
var theme = "default";
|
||||
var theme = "/css/themes/slate.css";
|
||||
for (var i = 0; i < c.length; i++) {
|
||||
if (c[i].indexOf("cytube-theme=") === 0) {
|
||||
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");
|
||||
cur.parentNode.removeChild(cur);
|
||||
var css = document.createElement("link");
|
||||
|
|
|
@ -662,7 +662,7 @@ function applyOpts() {
|
|||
$("#usertheme").remove();
|
||||
var theme = USEROPTS.theme;
|
||||
if (theme === "default") {
|
||||
theme = "/css/themes/default.css";
|
||||
theme = "/css/themes/slate.css";
|
||||
}
|
||||
$("<link/>").attr("rel", "stylesheet")
|
||||
.attr("type", "text/css")
|
||||
|
|
Loading…
Reference in New Issue