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(0, round($attrs[0] / 2 - ($width / 2) / $ratio));
$y = max(0, round($attrs[1] / 2 - ($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, $src, 0, 0, $x, $y, $width, $height,
round($width / $ratio, 0), 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!
