GoFuckYourself.com - Adult Webmaster Forum

GoFuckYourself.com - Adult Webmaster Forum (https://gfy.com/index.php)
-   Webmaster Q & Fuckin' A (https://gfy.com/forumdisplay.php?f=27)
-   -   PHP and Jquery Utilities (https://gfy.com/showthread.php?t=1169666)

sylvain86 07-05-2015 09:38 PM

PHP and Jquery Utilities
 
For person who wants PHP functions :

Crop JPG image :

PHP Code:

<?php
function resize($imgFile,$output$width$height, &$error null) {
       
$attrs = @getimagesize($imgFile);
       if(
$attrs == false or $attrs[2] != IMG_JPEG)
       {
          
$error "Uploaded image is not JPEG or is not readable by this page.";
          return 
false;
       }
       if(
$attrs[0] * $attrs[1] > 3000000)
       {
          
$error "Max pixels allowed is 3,000,000. Your {$attrs[0]} x " .
                   
"{$attrs[1]} image has " $attrs[0] * $attrs[1] . " pixels.";
          return 
false;
       }
       
$ratio = (($attrs[0] / $attrs[1]) < ($width $height)) ?
                
$width $attrs[0] : $height $attrs[1];
       
$x max(0round($attrs[0] / - ($width 2) / $ratio));
       
$y max(0round($attrs[1] / - ($height 2) / $ratio));
       
$src imagecreatefromjpeg($imgFile);
       if(
$src == false)
       {
          
$error "Unknown problem trying to open uploaded image.";
          return 
false;
       }
       
$resized imagecreatetruecolor($width$height);
       
$result imagecopyresampled($resized$src00$x$y$width$height,
                 
round($width $ratio0), round($height $ratio));
       if(
$result == false)
       {
          
$error "Error trying to resize and crop image.";
          return 
false;
       }
       else
       {
          
imagejpeg($resized,$output,100);
       }
    }
?>

For Adblock detection:

Here's the code:

Code:

document.write('<div id="checker">an advertisement</div>');
Now, if Adblock check this, detection will be ready.

Add a CSS:

Code:

#checker {
    display:none;
}

If you use JQUERY, let's see the code to display something :

Code:

var REGISTER = '{YOUR_SITE_URL}';
var REQUEST = location.href;
function message(type,message,timeval,redirect) {
    if(type == 1) {
        var myclass = 'alert alert-success';
        var title = 'OK';
    }
    else {
        var myclass = 'alert-danger alert-error';
        var title = 'ERREUR';
    }
    bootbox.alert('<div class="'+myclass+'" style="padding:10px;"><h2>'+title+'</h2><p>'+message+'</p></div>');
    setTimeout(function() {
        bootbox.hideAll();
        if(redirect) {
            if(redirect=='back')
                history.back();
            else
                location.href = redirect;
        }
    }, timeval*1000);
}
$(document).ready(function() {
    if(document.getElementById("checker") == undefined && !REQUEST.match('inscription')) {
        message(0,"<u>It seems that <b>ADBLOCK</b> is activated on your browser</u>. Just deactivate it or <a href='"+REGISTER+"'>Subescrive</a>. You're going to be redirected... ",10,REGISTER);
    }
});

In this case I use jquery, bootstrap et bootbox.

If you wanna simplier:

Code:

$(document).ready(function() {
    if(document.getElementById("checker") == undefined ) {
        location.href = 'anti-adblock.php'
    }
});

Or display a message.

If you want much more, check me on Skype : sylvain.garcia1

Bye! :)


All times are GMT -7. The time now is 09:36 AM.

Powered by vBulletin® Version 3.8.8
Copyright ©2000 - 2025, vBulletin Solutions, Inc.
©2000-, AI Media Network Inc123