Remove all advertising-related code
This commit is contained in:
@@ -1,37 +0,0 @@
|
||||
package webcontroller
|
||||
|
||||
import (
|
||||
"net/http"
|
||||
"time"
|
||||
|
||||
"fornaxian.tech/log"
|
||||
"fornaxian.tech/util"
|
||||
"github.com/julienschmidt/httprouter"
|
||||
)
|
||||
|
||||
func (wc *WebController) serveAdClick(w http.ResponseWriter, r *http.Request, p httprouter.Params) {
|
||||
// Redirect the user to the target page
|
||||
w.Header().Set("Referrer-Policy", "origin")
|
||||
http.Redirect(w, r, r.URL.Query().Get("target"), http.StatusTemporaryRedirect)
|
||||
|
||||
// The Real IP is used in the API server to determine that the view is not
|
||||
// fake
|
||||
var api = wc.api.RealIP(util.RemoteAddress(r)).RealAgent(r.UserAgent())
|
||||
|
||||
// Log a view on the file
|
||||
if err := api.PostFileView(p.ByName("id"), wc.viewTokenOrBust()); err != nil {
|
||||
log.Error("Failed to log view: %s", err)
|
||||
}
|
||||
}
|
||||
|
||||
func (wc *WebController) serveCampaignPartner(w http.ResponseWriter, r *http.Request, p httprouter.Params) {
|
||||
http.SetCookie(w, &http.Cookie{
|
||||
Name: "pd_campaign",
|
||||
Value: p.ByName("id"),
|
||||
Path: "/",
|
||||
Expires: time.Now().AddDate(0, 0, 7),
|
||||
})
|
||||
|
||||
// Redirect the user to the home page
|
||||
http.Redirect(w, r, "/", http.StatusTemporaryRedirect)
|
||||
}
|
@@ -125,7 +125,6 @@ func (tm *TemplateManager) ParseTemplates(silent bool) {
|
||||
// Import template functions
|
||||
tpl.Funcs(template.FuncMap{
|
||||
"cacheID": tm.cacheID,
|
||||
"isBrave": tm.isBrave,
|
||||
"debugMode": tm.debugMode,
|
||||
"apiUrl": tm.apiURL,
|
||||
"pageNr": tm.pageNr,
|
||||
@@ -218,10 +217,6 @@ var cacheID = time.Now().Unix() / 3600
|
||||
func (tm *TemplateManager) cacheID() int64 {
|
||||
return cacheID
|
||||
}
|
||||
|
||||
func (tm *TemplateManager) isBrave(useragent string) bool {
|
||||
return strings.Contains(useragent, "Brave")
|
||||
}
|
||||
func (tm *TemplateManager) debugMode() bool {
|
||||
return tm.debugModeEnabled
|
||||
}
|
||||
|
@@ -87,7 +87,6 @@ func New(r *httprouter.Router, prefix string, conf Config) (wc *WebController) {
|
||||
// Static assets
|
||||
r.GET(prefix+"/favicon.ico" /* */, wc.serveFile("/favicon.ico"))
|
||||
r.GET(prefix+"/robots.txt" /* */, wc.serveFile("/robots.txt"))
|
||||
r.GET(prefix+"/ads.txt" /* */, wc.serveFile("/ads.txt"))
|
||||
|
||||
if conf.MaintenanceMode {
|
||||
r.NotFound = http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
|
||||
@@ -143,12 +142,10 @@ func New(r *httprouter.Router, prefix string, conf Config) (wc *WebController) {
|
||||
{GET, "d/*path" /* */, wc.serveDirectory},
|
||||
{GET, "t" /* */, wc.serveTemplate("text_upload", handlerOpts{})},
|
||||
{GET, "donation" /* */, wc.serveMarkdown("donation.md", handlerOpts{})},
|
||||
{GET, "advertising" /* */, wc.serveMarkdown("advertising.md", handlerOpts{})},
|
||||
{GET, "widgets" /* */, wc.serveTemplate("widgets", handlerOpts{})},
|
||||
{GET, "about" /* */, wc.serveMarkdown("about.md", handlerOpts{})},
|
||||
{GET, "appearance" /* */, wc.serveTemplate("appearance", handlerOpts{})},
|
||||
{GET, "hosting" /* */, wc.serveMarkdown("hosting.md", handlerOpts{})},
|
||||
{GET, "brave" /* */, wc.serveMarkdown("brave.md", handlerOpts{})},
|
||||
{GET, "acknowledgements" /**/, wc.serveMarkdown("acknowledgements.md", handlerOpts{})},
|
||||
{GET, "business" /* */, wc.serveMarkdown("business.md", handlerOpts{})},
|
||||
{GET, "limits" /* */, wc.serveMarkdown("limits.md", handlerOpts{})},
|
||||
@@ -205,10 +202,6 @@ func New(r *httprouter.Router, prefix string, conf Config) (wc *WebController) {
|
||||
{GET, "admin/globals" /* */, wc.serveForm(wc.adminGlobalsForm, handlerOpts{Auth: true})},
|
||||
{PST, "admin/globals" /* */, wc.serveForm(wc.adminGlobalsForm, handlerOpts{Auth: true})},
|
||||
|
||||
// Advertising related
|
||||
{GET, "click/:id" /* */, wc.serveAdClick},
|
||||
{GET, "campaign/:id" /* */, wc.serveCampaignPartner},
|
||||
|
||||
// Misc
|
||||
{GET, "misc/sharex/pixeldrain.com.sxcu", wc.serveShareXConfig},
|
||||
{GET, "theme.css", wc.themeHandler},
|
||||
|
Reference in New Issue
Block a user