Add popunder ads based on file size
This commit is contained in:
@@ -113,7 +113,20 @@
|
|||||||
</script>
|
</script>
|
||||||
{{ end }}
|
{{ end }}
|
||||||
|
|
||||||
{{ if eq .Other.AdUnderType 1}}
|
{{ if eq .Other.AdPopupType 1 }}
|
||||||
<script data-cfasync="false" type="text/javascript" async src="//depirsmandk5.com/t/9/fret/meow4/1846775/brt.js"></script>
|
<script data-cfasync="false" type="text/javascript" async src="//depirsmandk5.com/t/9/fret/meow4/1846775/brt.js"></script>
|
||||||
|
{{ else if eq .Other.AdPopupType 2 }}
|
||||||
|
<script>
|
||||||
|
window.addEventListener("load", () => {
|
||||||
|
(function(s,u,z,p){
|
||||||
|
s.src=u,s.setAttribute('data-zone',z),p.appendChild(s);
|
||||||
|
})(
|
||||||
|
document.createElement('script'),
|
||||||
|
'https://iclickcdn.com/tag.min.js',
|
||||||
|
3750089,
|
||||||
|
document.body||document.documentElement,
|
||||||
|
)
|
||||||
|
})
|
||||||
|
</script>
|
||||||
{{ end }}
|
{{ end }}
|
||||||
{{ end }}
|
{{ end }}
|
||||||
|
@@ -143,13 +143,13 @@
|
|||||||
{{ if and .Other.FileAdsEnabled .Other.UserAdsEnabled }}
|
{{ if and .Other.FileAdsEnabled .Other.UserAdsEnabled }}
|
||||||
{{ template "banner_ads" . }}
|
{{ template "banner_ads" . }}
|
||||||
{{ else if not .Other.UserAdsEnabled }}
|
{{ else if not .Other.UserAdsEnabled }}
|
||||||
<div style="text-align: center; line-height: 1.3em; font-size: 13px;">
|
<div style="text-align: center; line-height: 1.3em; font-size: 13px;">
|
||||||
Thank you for supporting pixeldrain!
|
Thank you for supporting pixeldrain!
|
||||||
</div>
|
</div>
|
||||||
{{ else if not .Other.FileAdsEnabled }}
|
{{ else if not .Other.FileAdsEnabled }}
|
||||||
<div style="text-align: center; line-height: 1.3em; font-size: 13px;">
|
<div style="text-align: center; line-height: 1.3em; font-size: 13px;">
|
||||||
The uploader of this file disabled advertisements. You can do the same for <a href="/#pro">only €2 per month</a>!
|
The uploader of this file disabled advertisements. You can do the same for <a href="/#pro">only €2 per month</a>!
|
||||||
</div>
|
</div>
|
||||||
{{ end }}
|
{{ end }}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
@@ -30,7 +30,7 @@ type viewerData struct {
|
|||||||
ViewToken string
|
ViewToken string
|
||||||
AdBannerType int
|
AdBannerType int
|
||||||
AdFloaterType int
|
AdFloaterType int
|
||||||
AdUnderType int
|
AdPopupType int
|
||||||
FileAdsEnabled bool
|
FileAdsEnabled bool
|
||||||
UserAdsEnabled bool
|
UserAdsEnabled bool
|
||||||
Embedded bool
|
Embedded bool
|
||||||
@@ -38,6 +38,10 @@ type viewerData struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (vd *viewerData) adType(files []pixelapi.ListFile) {
|
func (vd *viewerData) adType(files []pixelapi.ListFile) {
|
||||||
|
if len(files) == 0 {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
var avgSize int64
|
var avgSize int64
|
||||||
for _, v := range files {
|
for _, v := range files {
|
||||||
avgSize += v.Size
|
avgSize += v.Size
|
||||||
@@ -67,31 +71,31 @@ func (vd *viewerData) adType(files []pixelapi.ListFile) {
|
|||||||
adMavenFloat = 3
|
adMavenFloat = 3
|
||||||
|
|
||||||
// Popunders
|
// Popunders
|
||||||
clickAduPopunder = 1
|
clickAduPopup = 1
|
||||||
|
propellerPopup = 2
|
||||||
)
|
)
|
||||||
|
|
||||||
// Intn returns a number up to n, but never n itself. So to get a random 0
|
// Intn returns a number up to n, but never n itself. So to get a random 0
|
||||||
// or 1 we need to give it n=2. We can use this function to make other
|
// or 1 we need to give it n=2. We can use this function to make other
|
||||||
// splits like 1/3 1/4, etc
|
// splits like 1/3 1/4, etc
|
||||||
switch i := rand.Intn(3); i {
|
switch i := rand.Intn(4); i {
|
||||||
case 0: // 33%
|
case 0: // 25%
|
||||||
vd.AdBannerType = clickAduBanner
|
vd.AdBannerType = clickAduBanner
|
||||||
case 1: // 33%
|
case 1: // 25%
|
||||||
vd.AdBannerType = brave
|
vd.AdBannerType = brave
|
||||||
case 2: // 33%
|
case 2, 3: // 50%
|
||||||
vd.AdBannerType = aAds
|
vd.AdBannerType = aAds
|
||||||
default:
|
default:
|
||||||
panic(fmt.Errorf("random number generator returned unrecognised number: %d", i))
|
panic(fmt.Errorf("random number generator returned unrecognised number: %d", i))
|
||||||
}
|
}
|
||||||
|
|
||||||
// If the file is larger than 10 MB we enable popups
|
// If the file is larger than 10 MB we enable floating popups
|
||||||
if avgSize > 10e6 {
|
if avgSize > 10e6 {
|
||||||
vd.AdFloaterType = propellerFloat
|
vd.AdFloaterType = propellerFloat
|
||||||
}
|
}
|
||||||
|
|
||||||
// If the file is larger than 250 MB we enable popunders
|
|
||||||
if avgSize > 250e6 {
|
if avgSize > 250e6 {
|
||||||
vd.AdUnderType = clickAduPopunder
|
vd.AdPopupType = clickAduPopup
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -181,6 +181,7 @@ func New(
|
|||||||
|
|
||||||
// Admin settings
|
// Admin settings
|
||||||
{GET, "admin" /* */, wc.serveTemplate("admin", handlerOpts{Auth: true})},
|
{GET, "admin" /* */, wc.serveTemplate("admin", handlerOpts{Auth: true})},
|
||||||
|
{GET, "admin/status" /* */, wc.serveTemplate("admin", handlerOpts{Auth: true})},
|
||||||
{GET, "admin/abuse_reporters" /**/, wc.serveTemplate("admin", handlerOpts{Auth: true})},
|
{GET, "admin/abuse_reporters" /**/, wc.serveTemplate("admin", handlerOpts{Auth: true})},
|
||||||
{GET, "admin/abuse_reports" /* */, wc.serveTemplate("admin", handlerOpts{Auth: true})},
|
{GET, "admin/abuse_reports" /* */, wc.serveTemplate("admin", handlerOpts{Auth: true})},
|
||||||
{GET, "admin/ip_bans" /* */, wc.serveTemplate("admin", handlerOpts{Auth: true})},
|
{GET, "admin/ip_bans" /* */, wc.serveTemplate("admin", handlerOpts{Auth: true})},
|
||||||
|
Reference in New Issue
Block a user