无忧启动论坛

标题: Xrea免费空间去广告谁有经验? [打印本页]

作者: 邪恶海盗    时间: 2024-3-1 10:11
标题: Xrea免费空间去广告谁有经验?
RT,十几年前注册的免费虚拟主机,至今还活着,有两个限制:
1.数据库phpmyadmin要JP IP访问
2.网页顶部会添加广告

IP的问题打代理能解决,现在想知道如何去广告,先说说广告是怎么添加的:
1.网页加载时会自动下载一个xrea_header.js

JS内容:
  1. (function(){
  2.   //add css
  3.   // var newStyle = document.createElement("link");
  4.   // newStyle.href = 'https://cache1.value-domain.com/xrea_header.css?5';
  5.   // newStyle.type = 'text/css';
  6.   // newStyle.rel = 'stylesheet';
  7.   // document.getElementsByTagName('head')[0].insertBefore(newStyle, null);

  8.   var func = function(){
  9.     // var body = document.body;
  10.     // if (body == undefined) {return false;}
  11.     var parent = document.getElementsByTagName("body")[0];
  12.     if (parent === null) {return false;}
  13.     //console.log(body,parent);

  14.     var elements = [
  15.         '<a href="https://www.value-domain.com/guide/setregist/?adref=xrea_ad&utm_source=xrea&utm_medium=banner&utm_campaign=xrea_ad" target="_blank" rel="nofollow" style="display:inline-block!important;position:relative!important;top:0!important;left:0!important;margin:0!important;padding:0!important;"><img src="https://www.value-domain.com/assets/img/guide/setregist/bnr_xrea.png" alt="コアサーバーV2プランご契約でドメイン更新費用が永久無料" style="display:inline-block!important;position:relative!important;top:0!important;left:0!important;margin:0!important;padding:0!important;width:100%!important;max-width:468px;max-height:60px;vertical-align:bottom;"></a>'
  16.     ];
  17.     var randElm = elements[Math.floor(Math.random() * elements.length)];

  18.     var newBox = document.createElement("div");
  19.     newBox.setAttribute('id', 'vdbanner');
  20.     newBox.setAttribute("style","display:block!important;position:relative!important;top:0!important;left:0!important;margin:10px 0 !important;padding:0!important;text-align:center!important;");
  21.     newBox.innerHTML = randElm;
  22.     parent.insertBefore(newBox, parent.firstChild);
  23.   };

  24.   try {
  25.     window.addEventListener("load", func, false);
  26.   }
  27.   catch(e) {
  28.     window.attachEvent("onload", func);
  29.   }
  30. })();
复制代码
2.执行JS后会向网页<body>里添加广告,div id是vdbanner


根据网上查到的资料,在header.php里添加<!--nonanner-->可以直接禁止广告(好像说是去广告的官方方法),不过官方明确说明了隐藏广告会被停用,所以需要变通,尝试过以下代码,广告能去除,不过是<!--nobanner-->起的作用,跟是否判断无关:
  1. <?php $language = substr($_SERVER['HTTP_ACCEPT_LANGUAGE'],0,2);
  2. if ($language='zh')
  3. echo '<!--nobanner-->;
  4. ?>
复制代码
哪个玩PHP HTML的指导一下?



作者: sunlenghua    时间: 2024-3-1 10:53
换个无广告空间: google search : "no ads php free web host"
作者: 紧急追踪    时间: 2024-3-1 10:57
进来学习一下,谢谢
作者: 515031    时间: 2024-3-1 11:10
进来学习一下,谢谢
作者: 邪恶海盗    时间: 2024-3-1 11:57
好像成功了,中文环境不显示广告了,谁有其它非中文系统测试下,地址http://hidao.org
  1. <?php $language = substr($_SERVER['HTTP_ACCEPT_LANGUAGE'],0,2);
  2. if ($language == 'zh') {
  3. echo '<!--nobanner-->';}
  4. ?>
复制代码

作者: softwarezheng    时间: 2024-3-1 12:30
HAO RUANJIAN
作者: zlq_hysy    时间: 2024-3-1 12:58
学习经验来了
作者: nathan6498    时间: 2024-3-1 16:17
学习学习
作者: hehuiying    时间: 2024-3-17 16:33
谢谢分享
作者: hehuiying    时间: 2024-4-1 15:02
谢谢分享
作者: 无犹启动    时间: 2024-5-10 15:36
谢谢分享




欢迎光临 无忧启动论坛 (http://bbs.wuyou.net/) Powered by Discuz! X3.3