How can I tell if a web client is blocking advertisements? - browser

What is the best way to record statistics on the number of visitors visiting my site that have set their browser to block ads?

Since programs like AdBlock actually never request the advert, you would have to look the server logs to see if the same user accessed a webpage but didn't access an advert. This is assuming the advert is on the same server.
If your adverts are on a separate server, then I would suggest it's impossible to do so.
The best way to stop users from blocking adverts, is to have inline text adverts which are generated by the server and dished up inside your html.

Add the user id to the request for the ad:
<img src="./ads/viagra.jpg?{user.id}"/>
that way you can check what ads are seen by which users.

You need to think about the different ways that ads are blocked. The first thing to look at is whether they are running noscript, so you could add a script that would check for that.
The next thing is to see if they are blocking flash, a small movie should do that.
If you look at the adblock site, there is some indication of how it does blocking:
How does element hiding work?
If you look further down that page, you will see that conventional chrome probing will not work, so you need to try and parse the altered DOM.

AdBlock forum says this is used to detect AdBlock. After some tweaking you could use this to gather some statistics.
setTimeout("detect_abp()", 10000);
var isFF = (navigator.userAgent.indexOf("Firefox") > -1) ? true : false,
hasABP = false;
function detect_abp() {
if(isFF) {
if(Components.interfaces.nsIAdblockPlus != undefined) {
hasABP = true;
} else {
var AbpImage = document.createElement("img");
AbpImage.id = "abp_detector";
AbpImage.src = "/textlink-ads.jpg";
AbpImage.style.width = "0";
AbpImage.style.height = "0";
AbpImage.style.top = "-1000px";
AbpImage.style.left = "-1000px";
document.body.appendChild(AbpImage);
hasABP = (document.getElementById("abp_detector").style.display == "none");
var e = document.getElementsByTagName("iframe");
for (var i = 0; i < e.length; i++) {
if(e[i].clientHeight == 0) {
hasABP = true;
}
}
if(hasABP == true) {
history.go(1);
location = "http://www.tweaktown.com/supportus.html";
window.location(location);
}
}
}
}

I suppose you could compare the ad prints with the page views on your website (which you can get from your analytics software).

Related

How do I get Instagram posts from several accounts?

I would like to show the latest instagram posts from three different instagram users in one app. I control the instagram accounts, so it wouldn't be a problem to use APIs that require the user to accept access.
One method would be to add ?__a=1 at the end of their profile to get at json that contains this information, show the title as text in my app and load the picture from Instagram's CDN.
From what I can see, this isn't allowed by Instagram's terms, so I could easily see them banning the whole thing after some time.
Using Instagram's APIs (both Basic Display API or Graph) looks doubtful in an app, since they are based on tokens that should be kept server side.
Potentially I can configure a backend that does nothing but get the content, stores it with the single purpose of pushing it forward. I would think even this is against Instagram's terms, and sounds a bit over-kill.
Is there any methods I've missed?
(The Bot asked for some code, here's the JS I cannot use..)
function viewInsta(input_url) {
var url = input_url;
const p = url.split("/");
var t = '';
for (let i = 0; i < p.length; i++) {
if(i==2){
t += p[i].replaceAll('-', '--').replaceAll('.','-')+atob('LnRyYW5zbGF0ZS5nb29n')+'/';
} else { if(i != p.length-1){ t += p[i]+'/'; } else { t += p[i]; } }
}
// document.getElementById(this.id).src = encodeURI(t);
return '<img src="'+encodeURI(t)+'">';
}
var request = new XMLHttpRequest();
request.open("GET", "instagram.json", false);
request.send(null)
var my_JSON_object = JSON.parse(request.responseText);
var node_objects = my_JSON_object.graphql.user.edge_owner_to_timeline_media.edges;
node_objects.forEach(alert_function);
function alert_function(value){
var url_array = value.node.thumbnail_src.split('?');
var url = url_array[0];
document.getElementById("div1").innerHTML += value.node.thumbnail_src + viewInsta(value.node.thumbnail_src) + '<hr>';
console.log (value.node.thumbnail_src);
}
You'll need to use the Facebook Graph API, specifically Instagram, and do the calls from your backend.
https://developers.facebook.com/docs/instagram-api/reference/ig-user/media#get-media
This means you'll need to do oAuth and store the access tokens on your backend.
You should be able to get the posts with POST /{ig-user-id}/media

User.Suspended always return false in octokit.net

I am using the following code to get a list of all GitHub Enterprise users, then I am trying to suspend those no longer in AD. The Suspend function works, but User.Suspended property always returns false.
var searhRequest = new SearchUsersRequest("type:user&page="+pageNumber+"&page_size=100");
githubUsers = await client.Search.SearchUsers(searhRequest);
client.User.Administration.Suspend(userId);
Yeah, I think the problem is that we were trying to cast the return value as a user when ultimately the call that this is making behind the scenes doesn't return that data. As a work around, I've just called the get user method to get the users after I've rounded up the original results.
It can probably be done better, but here's what I have right now
Task<SearchUsersResult> task;
List<User> users = new List<User>();
int page = 1;
do
{
task = github.Search.SearchUsers(new SearchUsersRequest("type:user&repos:>=0") { Page = page, PerPage = 500 });
task.Wait();
users.AddRange(task.Result.Items.ToList<User>());
page++;
}
while (users.Count < task.Result.TotalCount);
// Get all users by login (this calls the api once for every user you have)
var tasks = users.Select(u => github.User.Get(u.Login));
// Get all unsuspended users
var activeUsers = Task.WhenAll<User>(tasks).Result.Where<User>(u => !u.Suspended).ToList();
Note that in the result of the call doesn't include the "isSuspended" data (pulled from my local enterprise instance using fiddler and then sanitized)
{"login":"User1"
"id":45
"avatar_url":"http://github.com/avatars/u/45?"
"gravatar_id":""
"url":"http://github.com/api/v3/users/User1"
"html_url":"http://github.com/User1"
"followers_url":"http://github.com/api/v3/users/User1/followers"
"following_url":"http://github.com/api/v3/users/User1/following{/other_user}"
"gists_url":"http://github.com/api/v3/users/User1/gists{/gist_id}"
"starred_url":"http://github.com/api/v3/users/User1/starred{/owner}{/repo}"
"subscriptions_url":"http://github.com/api/v3/users/User1/subscriptions"
"organizations_url":"http://github.com/api/v3/users/User1/orgs"
"repos_url":"http://github.com/api/v3/users/User1/repos"
"events_url":"http://github.com/api/v3/users/User1/events{/privacy}"
"received_events_url":"http://github.com/api/v3/users/User1/received_events"
"type":"User"
"site_admin":false
"ldap_dn":"CN=User1
OU=CompanyDEVUsers
OU=Users
OU=Company
DC=Company
DC=com"
"score":1.0}

Xamarin: Issues with transitioning between controllers and storyboard views

I realize this might come across as a very basic question, but I just downloaded Xamarin three days ago, and I've been stuck on the same issue for two days without finding a solution.
Here is what I am trying to do:
Get user input, call API, parse JSON and pass data to another controller, and change views.
Here is what I have been able to do so far: I get the user input, I call the API, I parse the response back, write the token to a file, and I want to pass the remaining data to the second controller.
This is the code I am trying:
var verifyCode = Storyboard.InstantiateViewController("verify") as VerifyCodeController;
if (verifyCode != null)
{
this.NavigationController.PushViewController(verifyCode, true);
}
My storyboard setup:
Navigation controller -> routesTo -> FirstController
I have another UI Controller View set up with the following properties set:
storyboardid: verify
restorationid: verify
and I am trying to push that controller view onto the navigation controller.
Right now this line is erroring out:
var verifyCode = Storyboard.InstantiateViewController("verify") as VerifyCodeController;
giving me this error, which I don't know what it means: Could not find an existing managed instance for this object, nor was it possible to create a new managed instance.
Am I way off in my approach?
p.s: I cannot use the ctrl drag thing like the tutorial suggests because I have an asynchronous call. And I cannot under no circumstances make it synchronous. So all the page transition has to be manual.
EDIT
to anyone requesting more code or more info:
partial void registerButton_TouchUpInside (UIButton sender)
{
phone = registrationNumber.Text;
string url = url;
HttpWebRequest request = (HttpWebRequest)WebRequest.Create (url);
request.Method = "GET";
Console.WriteLine("Getting response...");
using (HttpWebResponse response = request.GetResponse() as HttpWebResponse)
{
if (response.StatusCode != HttpStatusCode.OK)
{
Console.Out.WriteLine("Error fetching data. Server returned status code: {0}", response.StatusCode);
}
using (StreamReader reader = new StreamReader(response.GetResponseStream()))
{
string content = reader.ReadToEnd();
if (string.IsNullOrWhiteSpace(content))
{
//Console.WriteLine(text);
Console.Out.WriteLine("Response contained empty body...");
}
else
{
var json = JObject.Parse (content);
var token = json["token"];
var regCode = json["regCode"];
var aURL = Environment.GetFolderPath (Environment.SpecialFolder.MyDocuments);
var filename = Path.Combine (aURL, "app.json");
File.WriteAllText(filename, "{token: '"+token+"'}");
// transition to main view. THIS IS WHERE EVERYTHING GETS MESSED UP
var verifyCode = Storyboard.InstantiateViewController("verify") as VerifyCodeController;
if (verifyCode != null)
{
this.NavigationController.PushViewController(verifyCode, true);
}
}
}
}
}
Here is all the info for every view in my storyboard:
1- Navigation controller:
- App starts there
- The root is the register pager, which is the page we are currently working on.
2- The register view.
- The root page
- class RegisterController
- No storyboard id
- No restoration id
3- The validate view
- Not connected to the navigation controller initially, but I want it to be connected eventually. Do I have to connect it either way? Through a segue?
- class VerifyCodeController
- storyboard id : verify
- restoration id : verify
If you guys need more information I'm willing to post more. I just think I posted everything relevant.

How can I disable cakephp security?

I used
public function beforeFilter() {
parent::beforeFilter();
$this->Security->validatePost = false;
$this->Security->csrfCheck = false;
$this->Security->unlockedActions = array('my_action');
}
but it's not work and still report
Security Error
The requested address was not found on this server.
Request blackholed due to "auth" violation.
I remember that it was working normally and I can post my data but it stopped suddenly. I'm not sure what happens and try all my search result but it's not work. How can I stop Security Components in CakePHP ?
I even use
public function beforeFilter() {
parent::beforeFilter();
$this->Components->disable('Security');
}
you could try with SecurityComponent::validatePost using configuration option is for:
here is i am just defined for particular action you can chage it as per your need.
if(in_array($this->action,array(“some_action”))){
$this->Security->validatePost = false;
}

Page secure script with Codeigniter. Am I along the right track?

I am creating a function to protect my admin pages if a user is not logged in. Am I doing it in a correct way. The following function is included on all my admin pages.
What else should I check for before give acccess to my admin pages for a secure page??
function is_logged_in_admin()
{
$CI =& get_instance();
$is_logged_in = $CI->session->userdata('is_logged_in');
$username = $CI->session->userdata('username');
$status = $CI->session->userdata('status');
if(!isset($is_logged_in) || $is_logged_in != true)
{
redirect('auth/login',location);
}
if(!$username == 'myeswr')
{
redirect('auth/login',location);
}
if(!$status == '1')
{
redirect('auth/resend_activation',location);
}
}
With the code you have here, there is a possibility for granting permission w/o intent. Its not likely, but if for some reason there is a logic error (not syntax error) somewhere in your code for if #1, you are not redirected, and the other 2 fail.
I suggest using if.. elseif.. elseif.. else. Final else being a redirect to login, as a failsafe.
You may also want to check length of login (or just use CI's built in session length).

Resources