diff --git a/res/template/file_viewer.html b/res/template/file_viewer.html index c5c62a4..1493010 100644 --- a/res/template/file_viewer.html +++ b/res/template/file_viewer.html @@ -132,6 +132,21 @@ + {{else if eq .Other.AdType 2}} +
+
+ Pixeldrain needs money to survive!
+ + Support me on Patreon and get some neat perks + +
+
+ No ads when viewing files
+ No ads on your uploaded files
+ Longer file retention
+
+
+ {{end}}
{{end}} diff --git a/webcontroller/file_viewer.go b/webcontroller/file_viewer.go index ee9d1fd..a0a717f 100644 --- a/webcontroller/file_viewer.go +++ b/webcontroller/file_viewer.go @@ -3,6 +3,7 @@ package webcontroller import ( "fmt" "io/ioutil" + "math/rand" "mime" "net/http" "strconv" @@ -32,14 +33,19 @@ func adType() (i int) { // Intn returns a number up to n, but never n itself. So it get a random 0 // or 1 we need to give it n=2. We can use this function to make other // splits like 1/3 1/4, etc - // i = rand.Intn(2) + i = rand.Intn(2) - // switch { - // case i == 1: // 50% of the traffic - return 1 // Amarula - // default: - // return 0 // A-Ads - // } + // The return value correstonds to the type of ad shown: + // 0: A-ads + // 1: Amarulasolutions + // 2: Patreon + + switch i { + case 0: // 50% of the traffic + return 1 + default: + return 2 + } } type viewerData struct {