File "misc.inc.php"
Full Path: /srv/www/www.cadoro.it/src/includes/misc.inc.php
File size: 34.36 KB
MIME-type: text/x-php
Charset: utf-8
<?php
function _a($a, $k, $d=null) {
return isset($a[$k]) ? $a[$k] : $d;
}
function _u($v) {
return urlencode(strtolower($v));
}
function _from_array($v) {
if ($v) {
$v = array_unique($v);
sort($v);
return _text(";" . implode(";", $v) . ";");
}
return "null";
}
function _from_sorted_array($v) {
if ($v) {
$v = array_unique($v);
return _text(";" . implode(";", $v) . ";");
}
return "null";
}
function _to_array($v) {
$v = trim($v, ";");
$result = array();
if ($v != "") {
foreach (explode(";", $v) as $key) {
array_push($result, $key);
}
}
$result = array_unique($result);
sort($result);
return $result;
}
function _to_sorted_array($v) {
$v = trim($v, ";");
$result = array();
if ($v != "") {
foreach (explode(";", $v) as $key) {
array_push($result, $key);
}
}
$result = array_unique($result);
return $result;
}
function _unquote($v) {
return (get_magic_quotes_gpc() && is_string($v) ? trim(stripslashes($v)) : (is_string($v) ? trim($v) : $v));
}
function _get($k, $d=null) {
return array_key_exists($k, $_GET) ? _unquote($_GET[$k]) : $d;
}
function _post($k, $d=null) {
return array_key_exists($k, $_POST) ? _unquote($_POST[$k]) : $d;
}
function _request($k, $d=null) {
return array_key_exists($k, $_REQUEST) ? _unquote($_REQUEST[$k]) : $d;
}
function _post_date($k) {
$day = array_key_exists($k . "_day", $_POST) ? intval($_POST[$k . "_day"]) : null;
$month = array_key_exists($k . "_month", $_POST) ? intval($_POST[$k . "_month"]) : null;
$year = array_key_exists($k . "_year", $_POST) ? intval($_POST[$k . "_year"]) : null;
if ($day && $month && $year) {
return sprintf("%02d", $day) . "/" . sprintf("%02d", $month) . "/" . sprintf("%04d", $year);
}
return null;
}
function _post_datetime($k) {
$value = _post_date($k);
if (!$value) {
return null;
}
$hour = array_key_exists($k . "_hour", $_POST) ? intval($_POST[$k . "_hour"]) : null;
$minute = array_key_exists($k . "_minute", $_POST) ? intval($_POST[$k . "_minute"]) : null;
return $value . " " . sprintf("%02d", $hour) . ":" . sprintf("%02d", $minute) . ":00";
}
function _post_fileupload($k) {
$v = _post($k);
$v_title = _post($k . "_title");
$v_description = _post($k . "_description");
if (is_array($v)) {
$data = array();
foreach ($v as $i => $f) {
$v = json_decode(_unquote($f), true);
if (is_array($v_title) && isset($v_title[$i])) {
$v['title'] = $v_title[$i];
}
if (is_array($v_description) && isset($v_description[$i])) {
$v['description'] = $v_description[$i];
}
array_push($data, $v);
}
return $data;
}
return null;
}
function _post_tags($k) {
$v = _post($k);
return ($v ? explode(",", $v) : null);
}
function _image($k, $category, $w=null, $h=null) {
$image = _file($k, $category);
if ($image) {
if ($w && $h) {
$image['asset'] = _thumbnail($image['path'], $w, $h, $category);
} else if ($w) {
$image['asset'] = _resize($image['path'], $w, $category);
}
} else {
$image = _post($k);
if ($image) {
$image = _image_local($image, $category, array());
$image = array(
"asset" => $image
);
}
}
return $image;
}
function _image_local($image, $category, $params=array()) {
if (!$image || !preg_match('/^http/i', $image)) {
return $image;
}
$filename = tempnam(sys_get_temp_dir(), 'download-');
$curl = curl_init($image);
curl_setopt_array($curl, array(
CURLOPT_URL => $image,
CURLOPT_BINARYTRANSFER => 1,
CURLOPT_RETURNTRANSFER => 1,
CURLOPT_FILE => fopen($filename, 'wb+'),
CURLOPT_TIMEOUT => 60,
CURLOPT_USERAGENT => 'Mozilla/4.0 (compatible; MSIE 5.01; Windows NT 5.0)'
));
$response = curl_exec($curl);
if ($response === false) {
unlink($file);
return $image;
}
$md5 = md5_file($filename);
$asset = _asset($category, $md5, preg_replace('/.*\./', '', $image));
$asset_path = _asset_path($asset);
rename($filename, $asset_path);
return $asset;
}
function _file($k, $category) {
if (!array_key_exists($k, $_FILES)) {
return array();
}
$result = array();
$files = $_FILES[$k];
if ($files['error'] == 0) {
$ext = null;
$type = $files['type'];
$name = $files['name'];
if ($type == "image/jpeg" || preg_match('/.*\.jpg$/i', $name)) {
$ext = "jpg";
} else if ($type == "image/png" || preg_match('/.*\.png$/i', $name)) {
$ext = "png";
} else if ($type == "image/gif" || preg_match('/.*\.gif$/i', $name)) {
$ext = "gif";
} else if ($type == "application/pdf" || preg_match('/.*\.pdf$/i', $name)) {
$ext = "pdf";
} else if ($type == "application/doc" || preg_match('/.*\.doc$/i', $name)) {
$ext = "doc";
} else if ($type == "application/docx" || preg_match('/.*\.docx$/i', $name)) {
$ext = "docx";
} else if ($type == "application/rtf" || preg_match('/.*\.rtf$/i', $name)) {
$ext = "rtf";
} else if ($type == "application/osd" || preg_match('/.*\.osd$/i', $name)) {
$ext = "osd";
} else if ($type == "text/plain" || preg_match('/.*\.txt$/i', $name)) {
$ext = "txt";
} else if ($type == "application/zip" || preg_match('/.*\.zip$/i', $name)) {
$ext = "zip";
}
if ($ext) {
$md5 = md5_file($files['tmp_name']);
$asset = _asset($category, $md5, $ext);
$asset_path = _asset_path($asset);
move_uploaded_file($files['tmp_name'], $asset_path);
return array(
"asset" => $asset,
"path" => $asset_path,
"ext" => $ext,
"md5" => $md5,
"name" => $files['name']
);
}
}
return null;
}
function _file_media($k, $category) {
if (!array_key_exists($k, $_FILES)) {
return array();
}
$result = array();
$files = $_FILES[$k];
if ($files['error'] == 0) {
$md5 = md5_file($files['tmp_name']);
$asset = $category . "/" . _slug(_unac(preg_replace('/\.[a-zA-Z0-9]+$/', '', $files['name'])), 10) . (strpos($files['name'], ".") !== FALSE ? "." . _unac(preg_replace('/^.*\./', '', $files['name'])) : "");
$asset_path = _asset_path($asset);
move_uploaded_file($files['tmp_name'], $asset_path);
return array(
"asset" => $asset,
"path" => $asset_path,
"md5" => $md5,
"name" => $files['name'],
"size" => $files['size']
);
}
return null;
}
function _files($k, $category) {
if (!array_key_exists($k, $_FILES)) {
return array();
}
$result = array();
$files = $_FILES[$k];
foreach($files['error'] as $key => $error) {
if ($files['error'][$key] == 0) {
$ext = null;
$type = $files['type'][$key];
$name = $files['name'][$key];
if ($type == "application/zip" || preg_match('/.*\.zip$/i', $name)) {
$zip = zip_open($files['tmp_name'][$key]);
if (is_resource($zip)) {
while ($entry = zip_read($zip)) {
$name = zip_entry_name($entry);
$content = zip_entry_read($entry, zip_entry_filesize($entry));
$path = tempnam(DIR_ASSETS, "zip-");
$f = fopen($path, 'wb'); fwrite($f, $content); fclose($f);
$type = mime_content_type($path);
if ($type == "image/jpeg") {
$ext = "jpg";
} else if ($type == "image/png") {
$ext = "png";
} else if ($type == "image/gif") {
$ext = "gif";
} else {
unlink($path);
continue;
}
$md5 = md5_file($path);
$asset = _asset($category, $md5, $ext);
$asset_path = _asset_path($asset);
rename($path, $asset_path);
array_push($result, array(
"asset" => $asset,
"path" => $asset_path,
"ext" => $ext,
"md5" => $md5,
"name" => $name
));
}
}
continue;
} else if ($type == "image/jpeg" || preg_match('/.*\.jpg$/i', $name)) {
$ext = "jpg";
} else if ($type == "image/png" || preg_match('/.*\.png$/i', $name)) {
$ext = "png";
} else if ($type == "image/gif" || preg_match('/.*\.gif$/i', $name)) {
$ext = "gif";
} else if ($type == "application/pdf" || preg_match('/.*\.pdf$/i', $name)) {
$ext = "pdf";
}
if ($ext) {
$md5 = md5_file($files['tmp_name'][$key]);
$asset = _asset($category, $md5, $ext);
$asset_path = _asset_path($asset);
move_uploaded_file($files['tmp_name'][$key], $asset_path);
array_push($result, array(
"asset" => $asset,
"path" => $asset_path,
"ext" => $ext,
"md5" => $md5,
"name" => $files['name'][$key]
));
}
}
}
return $result;
}
function _crop($path, $w, $h, $crop, $category=null) {
$type = mime_content_type($path);
if ($type == "image/jpeg") {
$img = imagecreatefromjpeg($path);
} else if ($type == "image/png") {
$img = imagecreatefrompng($path);
} else if ($type == "image/gif") {
$img = imagecreatefromgif($path);
}
$thumb = imagecreatetruecolor($w, $h);
$white = imagecolorallocate($thumb, 255, 255, 255);
imagefill($thumb, 0, 0, $white);
imagecopyresampled($thumb, $img, 0, 0, $crop[0], $crop[1], $w, $h, $crop[2], $crop[3]);
$path = tempnam(DIR_ASSETS, "thumbnail-");
imagejpeg($thumb, $path, 95);
$md5 = md5_file($path);
$asset = _asset(($category ? $category : "thumbnails"), $md5, "jpg");
$asset_path = _asset_path($asset);
rename($path, $asset_path);
return $asset;
}
function _resize_c($path, $w, $h, $category) {
$type = mime_content_type($path);
if ($type == "image/jpeg") {
$img = imagecreatefromjpeg($path);
} else if ($type == "image/png") {
$img = imagecreatefrompng($path);
} else if ($type == "image/gif") {
$img = imagecreatefromgif($path);
}
$width = imagesx($img);
$height = imagesy($img);
$ratio = min((float)$h/(float)$height, (float)$w/(float)$width);
$ratio = $ratio > 1 ? 1 : $ratio;
$thumb = imagecreatetruecolor($w, $h);
$white = imagecolorallocate($thumb, 255, 255, 255);
imagefill($thumb, 0, 0, $white);
imagecopyresampled($thumb, $img, ($w-($width*$ratio))/2, ($h-($height*$ratio))/2, 0, 0, $width*$ratio, $height*$ratio, $width, $height);
$path = tempnam(DIR_ASSETS, "thumbnail-");
imagejpeg($thumb, $path, 95);
$md5 = md5_file($path);
$asset = _asset($category, $md5, "jpg");
$asset_path = _asset_path($asset);
rename($path, $asset_path);
return $asset;
}
function _resize($path, $w, $category, $output=null) {
$type = mime_content_type($path);
if ($type == "image/jpeg") {
$img = imagecreatefromjpeg($path);
} else if ($type == "image/png") {
$img = imagecreatefrompng($path);
} else if ($type == "image/gif") {
$img = imagecreatefromgif($path);
}
$width = imagesx($img);
$height = imagesy($img);
$h = $w/$width*1.0*$height;
if ($width < $w) {
$thumb = imagecreatetruecolor($w, $height);
$white = imagecolorallocate($thumb, 255, 255, 255);
imagefill($thumb, 0, 0, $white);
imagecopyresampled($thumb, $img, ($w - $width) / 2, 0, 0, 0, $width, $height, $width, $height);
} else {
$thumb = imagecreatetruecolor($w, $h);
$white = imagecolorallocate($thumb, 255, 255, 255);
imagefill($thumb, 0, 0, $white);
imagecopyresampled($thumb, $img, 0, 0, 0, 0, $w, $h, $width, $height);
}
$path = $output ? $output : tempnam(DIR_ASSETS, "thumbnail-");
imagejpeg($thumb, $path, 95);
if ($output) {
return $output;
}
$md5 = md5_file($path);
$asset = _asset($category, $md5, "jpg");
$asset_path = _asset_path($asset);
rename($path, $asset_path);
return $asset;
}
function _resize_h($path, $w, $h, $category) {
$type = mime_content_type($path);
if ($type == "image/jpeg") {
$img = imagecreatefromjpeg($path);
} else if ($type == "image/png") {
$img = imagecreatefrompng($path);
} else if ($type == "image/gif") {
$img = imagecreatefromgif($path);
}
$width = imagesx($img);
$height = imagesy($img);
$ratio = (float)$h/(float)$height;
$ratio_w = $width*$ratio;
if ($ratio_w > $w) {
$r = (float)$w/(float)$h;
$c1 = array("x" => ($width / 2) - ($height * $r / 2), "y" => 0);
$c2 = array("x" => ($width / 2) + ($height * $r / 2), "y" => $height);
$thumb = imagecreatetruecolor($w, $h);
imagecopyresampled($thumb, $img, 0, 0, $c1['x'], $c1['y'], $w, $h, $c2['x'] - $c1['x'], $c2['y'] - $c1['y']);
} else {
$thumb = imagecreatetruecolor($ratio_w, $h);
imagecopyresampled($thumb, $img, 0, 0, 0, 0, $ratio_w, $h, $width, $height);
}
$path = $output ? $output : tempnam(DIR_ASSETS, "thumbnail-");
imagejpeg($thumb, $path, 95);
if ($output) {
return $output;
}
$md5 = md5_file($path);
$asset = _asset($category, $md5, "jpg");
$asset_path = _asset_path($asset);
rename($path, $asset_path);
return $asset;
}
function _thumbnail($path, $w, $h, $category=null, $ext="jpg", $output=null) {
$type = mime_content_type($path);
if ($type == "image/jpeg") {
$img = imagecreatefromjpeg($path);
} else if ($type == "image/png") {
$img = imagecreatefrompng($path);
} else if ($type == "image/gif") {
$img = imagecreatefromgif($path);
}
$r = (float)$w/(float)$h;
$width = imagesx($img);
$height = imagesy($img);
$ratio = (float)$width/(float)$height;
if ($ratio > $r) {
$c1 = array("x" => ($width / 2) - ($height * $r / 2), "y" => 0);
$c2 = array("x" => ($width / 2) + ($height * $r / 2), "y" => $height);
} else {
$c1 = array("x" => 0, "y" => 0);
$c2 = array("x" => $width, "y" => $width / $r);
}
$thumb = imagecreatetruecolor($w, $h);
imagecopyresampled($thumb, $img, 0, 0, $c1['x'], $c1['y'], $w, $h, $c2['x'] - $c1['x'], $c2['y'] - $c1['y']);
$path = $output ? $output : tempnam(DIR_ASSETS, "thumbnail-");
if ($ext == 'jpg') {
imagejpeg($thumb, $path, 95);
} else {
imagepng($thumb, $path);
}
if ($output) {
return $output;
}
$md5 = md5_file($path);
$asset = _asset(($category ? $category : "thumbnails"), $md5, $ext);
$asset_path = _asset_path($asset);
rename($path, $asset_path);
return $asset;
}
$_now_override = null;
function _now() {
global $_now_override;
return ($_now_override ? $_now_override : 'now()');
}
function _boolean($v) {
return ($v*1 ? "true" : "false");
}
function _validateDate($date) {
$d = DateTime::createFromFormat('d/m/Y', $date);
return $d && $d->format('d/m/Y') === $date && date('Y') - $d->format('Y') >= 18 && date('Y') - $d->format('Y') <= 100;
}
function _date($v) {
$v = date_parse_from_format("d/m/Y", $v);
return ($v && $v['year'] && $v['year'] != "0000" ? "'" . $v['year'] . "-" . sprintf("%02d", $v['month']) . "-" . sprintf("%02d", $v['day']) . "'" : 'null');
}
function _date_json($v) {
$v = date_parse_from_format("d/m/Y", $v);
return ($v && $v['year'] && $v['year'] != "0000" ? $v['year'] . "-" . sprintf("%02d", $v['month']) . "-" . sprintf("%02d", $v['day']) : null);
}
function _datetime($v) {
$v = date_parse_from_format("d/m/Y H:M:i", $v);
return ($v && $v['year'] && $v['year'] != "0000" ? "'" . $v['year'] . "-" . sprintf("%02d", $v['month']) . "-" . sprintf("%02d", $v['day']) . " ".
sprintf("%02d", $v['hour']) . ":" . sprintf("%02d", $v['minute']) . ":" . sprintf("%02d", $v['second']) . "'" : 'null');
}
function _datetime_json($v) {
$v = date_parse_from_format("d/m/Y H:M:i", $v);
return ($v && $v['year'] && $v['year'] != "0000" ? $v['year'] . "-" . sprintf("%02d", $v['month']) . "-" . sprintf("%02d", $v['day']) . " ".
sprintf("%02d", $v['hour']) . ":" . sprintf("%02d", $v['minute']) . ":" . sprintf("%02d", $v['second']) : null);
}
function _numeric($v) {
return ($v !== null ? str_replace(",", ".", floatval(str_replace(",", ".", str_replace(".", "", $v)))) : 'null');
}
function _integer($v) {
return intval(str_replace(".", "", $v));
}
function _integer_null($v) {
return ($v*1 ? $v*1 : 'null');
}
function _float($v) {
return number_format((float)str_replace(",", ".", str_replace(".", "", $v)), 12, ".", "");
}
function _password($v) {
return ($v ? _text(md5($v)) : "password");
}
function _password_sha256($v) {
return ($v ? _text(hash('sha256', $v)) : "password");
}
function _text($v) {
global $db;
return ($v ? "'" . mysqli_real_escape_string($db, $v) . "'" : "null");
}
function _text_json($v) {
if (is_array($v)) {
$v = json_encode($v);
}
return _text($v);
}
function _text_in($v) {
if (!$v || !is_array($v)) {
return "()";
}
return "(" . implode(", ", array_map("_text", $v)) . ")";
}
function _asset($category, $md5, $ext) {
$dir = $category . DIRECTORY_SEPARATOR . _asset_dir($md5);
return $dir . DIRECTORY_SEPARATOR . $md5 . "." . $ext;
}
function _asset_dir($v) {
return substr($v, 0, 2) . DIRECTORY_SEPARATOR .
substr($v, 2, 2) . DIRECTORY_SEPARATOR .
substr($v, 4, 4) . DIRECTORY_SEPARATOR .
substr($v, 8, 8);
}
function _asset_path($asset) {
$path = DIR_ASSETS . DIRECTORY_SEPARATOR . $asset;
$dir = dirname($path);
if (!file_exists($dir)) { mkdir($dir, 0770, true); }
return $path;
}
function _unac($v) {
return iconv('UTF-8', 'ASCII//TRANSLIT', $v);
}
function _slug($v) {
$v = trim(preg_replace('/[^a-z0-9]+/', '-', strtolower(_unac($v))), '-');
if (substr_count($v, "-") > 5) {
$v = implode("-", array_slice(explode("-", $v), 0, 5));
}
return $v;
}
function _unslug($v) {
return trim(preg_replace('/.*-/', '', $v));
}
function not_found() {
global $smarty;
header('HTTP/1.0 404 Not Found', true, 404);
$smarty->display("not-found.tmpl");
exit;
}
function not_found_json() {
header('HTTP/1.0 404 Not Found', true, 404);
header("Content-Type: application/json; charset=utf-8");
echo json_encode(array("error" => "not found"));
exit;
}
/*
function _email($email) {
return preg_match("/^[_a-z0-9-]+(\.[_a-z0-9-]+)*@[a-z0-9-]+(\.[a-z0-9-]+)*(\.[a-z]{2,5})$/", strtolower($email));
}
*/
function _email($email) {
$dominiBlackList = array('biojuris.com','biyac.com','cloud-mal.top','happy-new-yea.top','inscriptio.in','just4fun.me','mac-24.com','privacy-mil.top','the23app.com','yopmail.com','mailcatch.com','mytrashmail.com','mailinator.com','discard.email','hidemyass.com','armyspy.com','cuvox.de','dayrep.com','einrot.com','fleckens.hu','gustr.com','jourrapide.com','rhyta.com','superrito.com','teleworm.us','mvrht.com','imgof.com','mailstop.it','mytempemail.com','tempemail.net','20email.eu','jetable.org','yomail.info','sharklasers.com','guerrillamail.info','grr.la','guerrillamail.biz','guerrillamail.com','guerrillamail.de','guerrillamail.net','guerrillamail.org','guerrillamailblock.com','pokemail.net','spam4.me ','incognitomail.org','mailinator.com','imgof.com','filzmail.com','contbay.com','damnthespam.com','trashmail.com','maildrop.cc','cd.mintemail.com','teleosaurs.xyz','spamgourmet.com','discard.email','discardmail.com','discardmail.de','spambog.com','spambog.de','spambog.ru','0815.ru','hulapla.de','s0ny.net','teewars.org','pfui.ru','0815.su','sweetxxx.de','jobbikszimpatizans.hu','zaktouni.fr','freelance-france.eu','webcontact-france.eu','fast-mail.fr','mail-easy.fr','instantmail.fr','btcmail.pw','knol-power.nl','everytg.ml','freemeil.gq','info-radio.ml','liveradio.tk','resgedvgfed.tk','muehlacker.tk','hartbot.de','lovefall.ml','savelife.ml','blutig.me','freundin.ru','breadtimes.press','cyber-phone.eu','premium-mail.fr','disign-concept.eu','ecolo-online.fr','photo-impact.eu','web-ideal.fr','wazabi.club','used-product.fr','cyber-innovation.club','reality-concept.club','last-chance.pro','disign-revelation.com','art-en-ligne.pro','solar-impact.pro','smashmail.de','social-mailer.tk','phus8kajuspa.cu.cc','zhouemail.510520.org','contrasto.cu.cc','shockinmytown.cu.cc','jet-renovation.fr','estate-invest.fr','mailspam.xyz','7ddf32e.info','myneocards.cz','top9appz.info','lajoska.pe.hu','yandere.cu.cc','paller.cf','horvathurtablahoz.ml','mrblacklist.gq','bloxter.cu.cc','viroleni.cu.cc','225522.ml','colafanta.cf','password.colafanta.cf','colorweb.cf','bungabunga.cf','s.bungabunga.cf','golidi.net','marmercake.com','meltedbrownies.com','naturalious.com','semut-kecil.com','indonesianherbalmedicine.com','semutkecil.com','personal-email.ml','rr-0.cu.cc','rr-1.cu.cc','rr-2.cu.cc','rr-3.cu.cc','trebusinde.cf','trebusinde.ml','mail707.com','peapz.com','lovesea.gq','u14269.ml','asiarap.usa.cc','ay33rs.flu.cc','44556677.igg.biz','retkesbusz.nut.cc','466453.usa.cc','a0.igg.biz','a1.usa.cc','a2.flu.cc','b0.nut.cc','c4utar.ml','spam.usa.cc','spam.flu.cc','spam.nut.cc','spam.igg.biz','hunrap.usa.cc','kachadresp.tk','browniesgoreng.com','de-fake.webfly.cf','de-fake.instafly.cf','secureserver.usa.cc','vaffanculo.gq','youporn.usa.cc','youporn.flu.cc','youporn.igg.biz','discard.kozow.com','r0.igg.biz','games4free.flu.cc','housat.com','spamarrest.com','spamarrest.cc','spamarrest.cn','spamarrest.ru','spamarrest.tk','33mail.com','e4ward.com','emailtmp.com','mezimages.net','mintemail.com','otherinbox.com','yourdomain.com','0clickemail.com','10minutemail.com','10minutemail.de','123-m.com','126.com','139.com','163.com','1pad.de','20minutemail.com','21cn.com','2prong.com','33mail.com','3d-painting.com','4warding.com','4warding.net','4warding.org','6paq.com','60minutemail.com','7days-printing.com','7tags.com','99experts.com','agedmail.com','amilegit.com','ano-mail.net','anonbox.net','anonymbox.com','antispam.de','armyspy.com','beefmilk.com','bigstring.com','binkmail.com','bio-muesli.net','bobmail.info','bofthew.com','boxformail.in','brefmail.com','brennendesreich.de','broadbandninja.com','bsnow.net','buffemail.com','bugmenot.com','bumpymail.com','bund.us','cellurl.com','chammy.info','cheatmail.de','chogmail.com','chong-mail.com','chong-mail.net','chong-mail.org','clixser.com','cmail.com','cmail.net','cmail.org','consumerriot.com','cool.fr.nf','courriel.fr.nf','courrieltemporaire.com','c2.hu','curryworld.de','cust.in','cuvox.de','dacoolest.com','dandikmail.com','dayrep.com','dbunker.com','dcemail.com','deadaddress.com','deagot.com','dealja.com','despam.it','devnullmail.com','digitalsanctuary.com','dingbone.com','discardmail.com','discardmail.de','dispose.it','disposableinbox.com','disposeamail.com','dispostable.com','dodgeit.com','dodgit.com','dodgit.org','domozmail.com','dontreg.com','dontsendmespam.de','drdrb.com','drdrb.net','dudmail.com','dump-email.info','dumpyemail.com','duskmail.com','e-mail.com','e-mail.org','e4ward.com','easytrashmail.com','einrot.de','emailgo.de','emailias.com','email60.com','emailinfive.com','emaillime.com','emailmiser.com','emailtemporario.com.br','emailtemporar.ro','emailthe.net','emailtmp.com','emailwarden.com','example.com','explodemail.com ','fakeinbox.com','fakeinformation.com','fakemail.fr','fantasymail.de','fastacura.com','fatflap.com ','fdfdsfds.com','fightallspam.com','filzmail.com','fizmail.com','flyspam.com','fr33mail.info','frapmail.com','friendlymail.co.uk','fuckingduh.com','fudgerub.com','garliclife.com','get1mail.com','get2mail.fr','getairmail.com','getmails.eu','getonemail.com','getonemail.net','gishpuppy.com','goemailgo.com','gotmail.com','gotmail.net','gotmail.org','gotti.otherinbox.com','great-host.in','guerillamail.org','guerrillamail.biz','guerrillamail.com','guerrillamail.de','guerrillamail.net','guerrillamail.org','guerrillamailblock.com','hacccc.com','haltospam.com','herp.in','hidzz.com','hochsitze.com','hotpop.com','hulapla.de','hushmail.com','ieatspam.eu','ieatspam.info','imails.info','incognitomail.com','incognitomail.net','incognitomail.org','instant-mail.de','ipoo.org','irish2me.com','jetable.com','jetable.fr.nf','jetable.net','jetable.org','jsrsolutions.com','junk1e.com','jnxjn.com','kasmail.com','klassmaster.com','klzlk.com','kulturbetrieb.info','kurzepost.de','lavabit.com','letthemeatspam.com','lhsdv.com','lifebyfood.com','litedrop.com','lookugly.com','lr78.com','lroid.com','m4ilweb.info','mail.by','mail114.net','mail4trash.com','mailbucket.org','mailcatch.com','maileater.com','mailexpire.com','mailguard.me','mail-filter.com','mailin8r.com','mailinator.com','mailinator.net','mailinator.org','mailinator.us','mailinator2.com','mailme.lv','mailmetrash.com','mailmoat.com','mailnator.com','mailnesia.com','mailnull.com','mailquack.com','mailscrap.com','mailzilla.org','makemetheking.com','manybrain.com','mega.zik.dj','meltmail.com','mierdamail.com','migumail.com','mintemail.com','mbx.cc','mobileninja.co.uk','moburl.com','moncourrier.fr.nf','monemail.fr.nf','monmail.fr.nf','mt2009.com','myemailboxy.com','mymail-in.net','mypacks.net','mypartyclip.de','mytempemail.com','mytrashmail.com','nepwk.com','nervmich.net','nervtmich.net','nice-4u.com','no-spam.ws','nobulk.com','noclickemail.com','nogmailspam.info','nomail.xl.cx','nomail2me.com','nospam.ze.tc','nospam4.us','nospamfor.us','nospamthanks.info','notmailinator.com','nowhere.org','nowmymail.com','nwldx.com','objectmail.com','obobbo.com','onewaymail.com','otherinbox.com','owlpic.com','pcusers.otherinbox.com','pepbot.com','poczta.onet.pl','politikerclub.de','pookmail.com','privy-mail.com','proxymail.eu','prtnx.com','putthisinyourspamdatabase.com','qq.com','quickinbox.com','rcpt.at','recode.me','regbypass.com','rmqkr.net','royal.net','rppkn.com','rtrtr.com','s0ny.net','safe-mail.net','safetymail.info','safetypost.de','saynotospams.com','sandelf.de','schafmail.de ','selfdestructingmail.com','sendspamhere.com','sharklasers.com','shitmail.me','shitware.nl','sinnlos-mail.de','siteposter.net','skeefmail.com','slopsbox.com','smellfear.com','snakemail.com','sneakemail.com','snkmail.com','sofort-mail.de','sogetthis.com','spam.la','spam.su','spam4.me','spamavert.com','spambob.net','spambob.org','spambog.com','spambog.de','spambox.info','spambog.ru','spambox.us','spamcero.com','spamday.com','spamex.com','spamfree24.com','spamfree24.de','spamfree24.eu','spamfree24.info','spamfree24.net','spamfree24.org','spamfree.eu','spamgourmet.com','spamherelots.com','spamhereplease.com','spamhole.com','spamify.com','spaminator.de','spamkill.info','spaml.com','spaml.de','spammotel.com','spamobox.com','spamsalad.in','spamspot.com','spamthis.co.uk','spamthisplease.com','spamtroll.net','speed.1s.fr','spoofmail.de','squizzy.de','stinkefinger.net','stuffmail.de','supergreatmail.com','superstachel.de','suremail.info','tagyourself.com','talkinator.com','tapchicuoihoi.com','teewars.org','teleworm.com','teleworm.us','temp.emeraldwebmail.com','tempalias.com','tempe-mail.com','tempemail.biz','tempemail.co.za','tempemail.com','tempemail.net','tempinbox.co.uk','tempinbox.com','tempmaildemo.com','tempmail.it','tempomail.fr','temporaryemail.net','temporaryemail.us','temporaryinbox.com','tempthe.net','thanksnospam.info','thankyou2010.com','thisisnotmyrealemail.com','throwawayemailaddress.com','tittbit.in','tmailinator.com','tradermail.info','trash2009.com','trash2010.com','trash2011.com','trash-amil.com','trash-mail.at','trash-mail.com','trash-mail.de','trashmail.at','trashmail.com','trashmail.me','trashmail.net','trashmail.ws','trashymail.com','trashymail.net','tyldd.com','umail.net','uggsrock.com','uroid.com','veryrealemail.com','vidchart.com','vubby.com','webemail.me','webm4il.info','weg-werf-email.de','wegwerf-email-addressen.de ','wegwerf-emails.de ','wegwerfadresse.de','wegwerfemail.de','wegwerfmail.de','wegwerfmail.info','wegwerfmail.net','wegwerfmail.org','whatiaas.com','whatsaas.com','wh4f.org','whyspam.me','willselfdestruct.com','winemaven.info','wuzupmail.net','yahoo.com.ph','yahoo.com.vn','yeah.net','yogamaven.com','yopmail.com','yopmail.fr','yopmail.net','yuurok.com','xoxy.net','xyzfree.net','za.com','zippymail.info','zoemail.net','zomg.info');
$email_str=explode("@", strtolower(trim($email)));
$email_dominio= $email_str[1];
if (!in_array($email_dominio, $dominiBlackList) and preg_match("/^[_a-z0-9-]+(\.[_a-z0-9-]+)*@[a-z0-9-]+(\.[a-z0-9-]+)*(\.[a-z]{2,10})$/", strtolower(trim($email))))
return true;
else
return false;
}
function _codicefiscale($cf) {
if($cf=='')
return false;
if(strlen($cf)!= 16)
return false;
$cf=strtoupper($cf);
if(!preg_match("/[A-Z0-9]+$/", $cf))
return false;
$s = 0;
for($i=1; $i<=13; $i+=2){
$c=$cf[$i];
if('0'<=$c and $c<='9')
$s+=ord($c)-ord('0');
else
$s+=ord($c)-ord('A');
}
for($i=0; $i<=14; $i+=2){
$c=$cf[$i];
switch($c){
case '0': $s += 1; break;
case '1': $s += 0; break;
case '2': $s += 5; break;
case '3': $s += 7; break;
case '4': $s += 9; break;
case '5': $s += 13; break;
case '6': $s += 15; break;
case '7': $s += 17; break;
case '8': $s += 19; break;
case '9': $s += 21; break;
case 'A': $s += 1; break;
case 'B': $s += 0; break;
case 'C': $s += 5; break;
case 'D': $s += 7; break;
case 'E': $s += 9; break;
case 'F': $s += 13; break;
case 'G': $s += 15; break;
case 'H': $s += 17; break;
case 'I': $s += 19; break;
case 'J': $s += 21; break;
case 'K': $s += 2; break;
case 'L': $s += 4; break;
case 'M': $s += 18; break;
case 'N': $s += 20; break;
case 'O': $s += 11; break;
case 'P': $s += 3; break;
case 'Q': $s += 6; break;
case 'R': $s += 8; break;
case 'S': $s += 12; break;
case 'T': $s += 14; break;
case 'U': $s += 16; break;
case 'V': $s += 10; break;
case 'W': $s += 22; break;
case 'X': $s += 25; break;
case 'Y': $s += 24; break;
case 'Z': $s += 23; break;
}
}
if( chr($s%26+ord('A'))!=$cf[15] )
return false;
return true;
}
function _newsletter($contact=array()) {
$url = "http://mailing.megadesk.it/api/1/accounts/57e398d19d099a1e128b456c/lists/57e399449d099a94118b456a/subscribers";
$token = "Vcan6Mi4KjOD1Ow08hasXqjHyLUtmRJ3";
$data = json_encode(array(
"subscribers" => array(
$contact,
),
));
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_USERPWD, "$token:1");
curl_setopt($ch, CURLOPT_HTTPAUTH, CURLAUTH_BASIC);
curl_setopt($ch, CURLOPT_USERAGENT, "api:cadoro.it");
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST");
curl_setopt($ch, CURLOPT_POSTFIELDS, $data);
curl_setopt($ch, CURLOPT_NOSIGNAL, 1);
curl_setopt($ch, CURLOPT_TIMEOUT_MS, 2000);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_HTTPHEADER, array(
'Content-Type: application/json; charset=utf-8',
'Content-Length: ' . strlen($data))
);
$result = curl_exec($ch);
curl_close($ch);
$result = json_decode($result, true);
return ($result && isset($result['id']) ? $result['id'] : null);
}
function _newsletter_check($contact=array()) {
$url = "http://mailing.megadesk.it/api/1/accounts/57e398d19d099a1e128b456c/lists/57e399449d099a94118b456a/subscribers?q=" . $contact['email'];
$token = "Vcan6Mi4KjOD1Ow08hasXqjHyLUtmRJ3";
$data = json_encode(array(
"subscribers" => array(
$contact,
),
));
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_USERPWD, "$token:1");
curl_setopt($ch, CURLOPT_HTTPAUTH, CURLAUTH_BASIC);
curl_setopt($ch, CURLOPT_USERAGENT, "api:cadoro.it");
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "GET");
curl_setopt($ch, CURLOPT_POSTFIELDS, $data);
curl_setopt($ch, CURLOPT_NOSIGNAL, 1);
curl_setopt($ch, CURLOPT_TIMEOUT_MS, 2000);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_HTTPHEADER, array(
'Content-Type: application/json; charset=utf-8',
'Content-Length: ' . strlen($data))
);
$result = curl_exec($ch);
curl_close($ch);
$result = json_decode($result, true);
return ($result['count'] > 0 ? 1 : 0);
}
function _json($v) {
$v = json_decode($v, true);
if (!$v) {
$e = json_last_error();
switch ($e) {
case JSON_ERROR_DEPTH:
$e = "JSON: the maximum stack depth has been exceeded"; break;
case JSON_ERROR_STATE_MISMATCH:
$e = "JSON: invalid or malformed JSON"; break;
case JSON_ERROR_CTRL_CHAR:
$e = "JSON: control character error, possibly incorrectly encoded"; break;
case JSON_ERROR_SYNTAX:
$e = "JSON: syntax error"; break;
case JSON_ERROR_UTF8:
$e = "JSON: malformed UTF-8 characters, possibly incorrectly encoded"; break;
default:
$e = "JSON: generic error"; break;
}
header('HTTP/1.0 400 Bad Request', true, 400);
header("Content-Type: application/json; charset=utf-8");
echo json_encode(array("error" => $e));
exit;
}
return $v;
}
?>