/* Decoded by unphp.net */
?>';
print_r($array);
echo '';
}
function showMessage($message, $color = 'success', $echo = true)
{
$str = '
' . $message . '
';
if($echo)
echo $str;
else
return $str;
}
function auto_version($file = '')
{
if (!file_exists(WG_PATH . $file))
return $file;
$mtime = @filemtime(WG_PATH . $file);
if (!$mtime)
$mtime = WG_VERSION;
return $file . '?v=' . $mtime;
}
function addslashes_array($data)
{
if (is_array($data)) {
foreach ($data as $key => $value) {
$data[$key] = addslashes_array($value);
}
return $data;
} else {
$data = mysql_real_escape_string($data);
return $data;
}
}
function stripslashes_array($data)
{
if (is_array($data)) {
foreach ($data as $key => $value) {
$data[$key] = stripslashes_array($value);
}
return $data;
} else {
return stripslashes($data);
}
}
function addNotify($title, $desc, $params)
{
global $main;
$url = WG_URL . 'wg7.php?' . $params;
$main->mq("insert into `".DB_PREFIX."notify` (`title`, `desc`, `url`) values ('".$title."', '".$desc."', '".$url."')");
}
function writeLog($logfile, $event)
{
$dir = WG_PATH . 'files/logs/' . $logfile;
if (!file_exists($dir)) {
mkdir($dir, 0755, true);
touch($dir.'/index.html');
}
$logfile .= '-'.hash('md5', date('Y-m-d'), false);
$file = fopen($dir . '/' . date('Y-m-d') . '-' . $logfile . '.log', 'a');
fwrite($file, date('Y-m-d H:i:s') . ' - ' . $event . PHP_EOL);
fclose($file);
}
function getDirContents($dir, &$results = array())
{
$files = scandir($dir);
foreach ($files as $key => $value) {
$path = realpath($dir . DIRECTORY_SEPARATOR . $value);
if (!is_dir($path)) {
$results[] = $path;
} else if ($value != "." && $value != "..") {
getDirContents($path, $results);
}
}
return $results;
}
function getDirs($dir)
{
$files = scandir($dir);
foreach ($files as $key => $value) {
$path = realpath($dir . DIRECTORY_SEPARATOR . $value);
if (is_dir($path) && $value != "." && $value != "..") {
$results[] = $value;
}
}
return $results;
}
function gzCompressFile($source, $level = 9)
{
$dest = $source . '.gz';
$mode = 'wb' . $level;
$error = false;
if ($fp_out = gzopen($dest, $mode)) {
if ($fp_in = fopen($source, 'rb')) {
while (!feof($fp_in))
gzwrite($fp_out, fread($fp_in, 1024 * 512));
fclose($fp_in);
} else {
$error = true;
}
gzclose($fp_out);
} else {
$error = true;
}
if ($error)
return false;
else
return $dest;
}
function renameFile($filename)
{
setlocale(LC_ALL, 'en_US.UTF8'); // by Nadov
$ext = extension($filename);
$filename = str_replace('.' . $ext, '', $filename);
$filename = iconv('UTF-8', 'ASCII//TRANSLIT', $filename); // by Nadov
$filename = trim($filename);
$filename = str_replace(' ', '-', $filename);
$filename = preg_replace('/[^_0-9a-zA-Z-]/', '', strtolower($filename));
$filename = preg_replace('/\s\s+/', ' ', $filename);
$filename = str_replace('----', '-', $filename);
$filename = str_replace('---', '-', $filename);
$filename = str_replace('--', '-', $filename);
$length = 6;
$filename .= '-' . substr(str_shuffle(str_repeat($x = '0123456789abcdefghijklmnopqrstuvwxyz', ceil($length / strlen($x)))), 1, $length);
return $filename . '.' . $ext;
}
function validateDate($date, $format = 'Y-m-d H:i:s')
{
$d = DateTime::createFromFormat($format, $date);
return $d && $d->format($format) == $date;
}
function picture_refresh($imgdir, $text)
{
if (!is_dir($imgdir)) {
mkdir($imgdir);
global $main;
$chd = (int)($main->conf_read("chmod_dir"));
if ($chd > 100 && $chd <= 777) {
$e = "chmod('$imgdir', 0" . (int)($chd) . ");";
eval($e);
}
}
if (!get_magic_quotes_gpc()) {
$text = stripslashes($text);
}
$str = str_replace("\r\n", " ", $text);
$imgdirr = $imgdir;
$kvt = opendir($imgdirr);
while (false !== ($fajl = readdir($kvt))) {
if ((is_file("$imgdirr$fajl")) && ($fajl != "..") && ($fajl != ".") && ($fajl != "index.php")) {
if (!strstr($str, $fajl)) unlink($imgdirr . $fajl);
}
}
}
function extension($str)
{
$str = implode("", explode("\\", $str));
$str = explode(".", $str);
$str = strtolower(end($str));
return $str;
}
function return_bytes($val)
{
$val = trim($val);
$last = strtolower($val[strlen($val) - 1]);
switch ($last) {
// The 'G' modifier is available since PHP 5.1.0
case 'g':
$val *= 1024;
case 'm':
$val *= 1024;
case 'k':
$val *= 1024;
}
return $val;
}
function getRemoteData($url, $explode = false)
{
$connect = '[[nothing]]';
if (function_exists('curl_init')) {
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_HEADER, 0);
curl_setopt($ch, CURLOPT_USERAGENT, 'Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.7.5) Gecko/20041107 Firefox/1.0');
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 5);
$content = curl_exec($ch);
curl_close($ch);
$connect = '[[curl]]';
}
if (!$content) {
$parse = parse_url($url);
$host = $parse['scheme'] . '://' . $parse['host'];
$query = $parse['path'] . '?' . $parse['query'];
if ($parse['scheme'] == 'https')
$port = 443;
else
$port = 80;
$fp = @fsockopen($parse['host'], $port, $errno, $errstr, 5);
if ($fp) {
$out = "GET $url HTTP/1.1\r\n";
$out .= "Host: $host\r\n";
$out .= 'User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:25.0) Gecko/20100101 Firefox/25.0' . "\r\n";
$out .= "Connection: Close\r\n\r\n";
fwrite($fp, $out);
while (!feof($fp)) {
$content .= fgets($fp, 128);
}
fclose($fp);
$out = '';
$connect = '[[fsockopen]]';
}
}
if (!$content && $fp = @fopen($url, 'r')) {
$content = '';
while ($line = fread($fp, 1024)) {
$content .= $line;
}
$connect = '[[fopen]]';
}
if (!$content) {
$content = @file_get_contents($url);
$connect = '[[file_get_contents]]';
}
if ($explode) {
$x = explode($explode, $content);
$content = $x[1];
}
if (!$content) {
$content = 'Connection error! ';
}
return $content;
}
function getTemplate($name)
{
$template = parse_ini_file(WG_PATH . 'files/templates/' . $name . '/template.ini', true);
$template['dir'] = $name;
if (!$template['template']['template_name']) {
return false;
}
return $template;
}
function getBounceText($bounce_code)
{
$bounce_codes1 = array(
'2.' => 'Sikeres parancs: A szerver a parancsot elfogadta, esetleg az al pontok változtatásokra hÃvhatják fel a figyelmet ahhoz, hogy sikeres legyen a küldés.',
'4.' => 'Pillanatnyi hiba: Valamilyen olyan pillanatnyi szerver hiba, vagy DNS probléma okozza a hibát mely kicsit késÅbb próbálva valószÃnűleg nem fog fent állni, esetleg domain szintű elgépelés történt...',
'5.' => 'Ãllandó hiba: Ezek olyan hibák melyek az e-mail újraküldésével sem oldhatóak meg. NagyvalószÃnűséggel változtatni kell valamit vagy az e-mailen, vagy a cél szerveren.',
);
$bounce_codes2 = array(
'.1.' => 'Feladó vagy cÃmzett e-mail cÃmével van valami probléma. Ãltalában valamely e-mail cÃm elgépelésérÅl van szó, mely kijavÃtása után az e-mail elküldÅdik.',
'.2.' => 'Ezen DSN (Delivery Status Notification) a cÃmzett e-mail fiókjával kapcsolatos, javÃtani a szerver oldalon lehet a hibát, általában.',
'.3.' => 'Hiba a fogadó szerver oldalán, javÃtani a szerver üzemeltetÅje tudja a hibát. Természetesen ez jelentheti akár azt is, hogy létre kell hozni az adott e-mail cÃmet... de pl. ilyenkor társul hozzá egy X.1.X es hibaüzenet is...',
'.4.' => 'Hálózati vagy routing problémák, esetleg könyvtár szolgáltatás problémák...',
'.5.' => 'Ãzent továbbÃtási protokoll hiba, mely lehet valamely szerver konfiguráció okából, de akár csatlakozási okokból is.',
'.6.' => 'Az üzenet tartalmaz hibát, hibás csatolmányt. JavÃtható ügyfél oldalon és szerver oldalon is, ugyanis ügyfél oldalon is korlátozható a küldendÅ file tÃpusa pl.',
'.7.' => 'Biztonsági szabályok megszegése esetén visszakapott hibakód...'
);
$bounce_codes3 = array(
'.0.0' => 'Ez az egyetlen hiba üzenet melybÅl csak az derÃthetÅ ki, hogy melyik osztályba tartozik a hiba...',
//a) E-mail cÃmmel kapcsolatos hiba üzenetek:
'.1.0' => 'A cÃm ami az üzenetben meg lett adva okozza a hiba üzenetet',
'.1.1' => 'A cÃmzett fiókja, e-mail cÃme nem létezik a megadott szerveztnél (@ elÅtti rész nem megfelelÅ).',
'.1.2' => 'A megadott âszolgáltatóâ nem létezik (@-utáni rész nem megfelelÅ)',
'.1.3' => 'A megadott e-mail cÃmben valahol hiba van...',
'.1.4' => 'A megadott e-mail cÃm több fiókhoz is hozzátartozik a szerveren.',
'.1.5' => 'A cÃmzett fiókja élÅ (KézbesÃtési riportok esetén hasznos)',
'.1.6' => 'A cÃmzett fiókja valaha létezett, de már nem elérhetÅ a szerveren',
'.1.7' => 'A cÃmzett cÃme nem megfelelÅ, az e-mail cÃm bármely részében lehet hiba.',
'.1.8' => 'Az e-mail cÃm domain része nem megfelelo (@-utáni rész) (Nincs reverse mondjuk)',
//b) Konkrétan e-mail fiókkal kapcsolatos hiba üzenetek::
'.2.0' => 'Annyi információt tudunk csak, hogy a fiókkal van valami probléma. (A fiók létezik)',
'.2.1' => 'A fiók él de nem fogad leveleket, ez lehet általános hiba de akár pillanatnyi is... (Korlátozás)',
'.2.2' => 'Fiók megtelt: Túllépte az ügyfél a megengedett e-mail tárhelyet...',
'.2.3' => 'Ãzete hossza túllépte a megengedett hosszt.',
'.2.4' => 'A fiók egy levelezési lista fiókja, mely nem volt tovább terjeszthetÅ...',
//c)Fogadó szerverrel kapcsolatos hibaüzenetek:
'.3.0' => 'A cÃmzett szervere elfogadja az e-maileket, de valami probléma van vele...',
'.3.1' => 'A mail-server háttértárolója megtelt.',
'.3.2' => 'A szerver melyiken a cÃmzett fiókja van nem fogad leveleket (éppen újraindÃtás alatt van, esetleg túlterhelt)',
'.3.3' => 'Az e-mail által âhasználtâ metódusok elvégzésére a rendszer nem alkalmas.',
'.3.4' => 'Az üzenet mérete meghaladja a rendszerben küldhetŠmaximális méretet.',
'.3.5' => 'A rendszer nincs a küldött üzenet elfogadására konfigurálva.',
//d) Hálózati esetleg routing problémák:
'.4.0' => 'Hálózati, routing probléma kategóriájába tartozó hiba, de pontosan nem behatárolható.',
'.4.1' => 'A cÃmzett szervere nem fogadja a kapcsolatokat, túlterhelt, vagy tényleg nem fogad levelezés irányú kapcsolatokat',
'.4.2' => 'A cÃmzett kiszolgálójával a csatlakozás létrejött, de valamilyen hiba folytán nem lehetett befejezni a megkezdett metódusokat, esetleg time out, vagy egyéb probléma miatt.',
'.4.3' => 'Az e-mailt nem lehetett a megadott cÃmzettek felé továbbÃtani, mert a âKönyvtár Szolgáltatásâ nem volt elérhetÅ (leggyakrabban DNS hiba)',
'.4.4' => 'Nem lehetett az útvonalat meghatározni. (Pl: dns lekérdezés csak SOA rekordot adott vissza)',
'.4.5' => 'A szerver nem volt képes az e-mail továbbÃtására, mert túl nagy volt a queue. (A várakozási sor nagysága meghaladta a maximumot)',
'.4.6' => 'Az üzenet útvonal hiba miatt nem továbbÃtható, túl sokszor lett továbbÃtva, esetleg saját magára van irányÃtva az e-mail cÃm.',
'.4.7' => 'Az e-mail továbbÃtási ideje lejárt,( minden szerveren be van állÃtva egy idÅ mely idÅn belül az e-mailt tovább kell adni, ha ez letelik ezt a hibaüzenetet kapja az ügyfél)',
//d) TovábbÃtási protokoll hiba:
'.5.0: Nem behatárolható hogy pontosan milyen továbbÃtási protokoll hiba lépett fel.',
'.5.1' => 'A parancs nem támogatott',
'.5.2' => 'A Parancs vagy elgépelt, vagy nem felismerhetÅ.',
'.5.3' => 'Túl sok cÃmzett',
'.5.4' => 'Nem elfogadható argumentumok',
'.5.5' => 'Rossz protokoll verzió',
//e) Ãzenet tartalma hibás:
'.6.0' => 'Nem behatárolható, hogy milyen hibát tartalmaz az üzenet.',
'.6.1' => 'Vagy a protokoll vagy a továbbÃtásra beállÃtott fogadó rendszer nem megfelelÅ.',
'.6.2' => 'Az üzenet tartalma nem megfelelÅ, (Spam szűrés esetén, ilyen mehet ki ha nem megfelelÅ szót, kifejezést tartalmaz a levél)',
'.6.3' => 'A továbbÃtandó e-mail 8-bit-es, de a fogadó szerver csak 7-bit en fogadja el... (A mail szervernek át kéne ezt forgatni)',
'.6.4' => 'Az üzenet sikeresen továbbÃtásra kerül, de az üzenet egy része elveszett...(csatolt állomány pl)',
'.6.5' => 'Kapcsolat felvétel nem volt sikeres',
//f) Biztonsági szabályok megsértése esetén kapható hiba üzenetek:
'.7.0' => 'A levél valamilyen biztonsági szerver beállÃtást sért, de nem tudni milyet.',
'.7.1' => 'A levél továbbÃtására nincs lehetÅség, vagy jogosultsági probléma, vagy az üzenet lett visszautasÃtva.',
'.7.2' => 'Nincs joga az adott levelezÅlistára e-mailt küldeni.',
'.7.3' => 'Biztonságos levélküldésre van szükség, de nem volt rá lehetÅség',
'.7.4' => 'Az üzenet Biztonságos jelszó hitelesÃtéssel küldÅdött, de ezen hitelesÃtés nem alkalmazható a szerveren.',
'.7.5' => 'TitkosÃtási probléma',
'.7.6' => 'TitkosÃtási forma nem támogatott.',
'.7.7' => 'A küldött e-mail nem elfogadható, mert hamisÃtott!'
);
$text = '';
foreach ($bounce_codes1 as $findme => $value) {
$pos = stripos($bounce_code, $findme);
if ($pos !== false && $pos == 0) {
$text .= $value . '
';
foreach ($bounce_codes2 as $findme2 => $value2) {
$pos2 = stripos($bounce_code, $findme2);
if ($pos2 !== false && $pos2 > 0) {
$text .= $value2 . '
';
foreach ($bounce_codes3 as $findme3 => $value3) {
$pos3 = stripos($bounce_code, $findme3);
if ($pos3 !== false) {
$text .= $value3 . '
';
break;
}
}
break;
}
}
break;
}
}
return $text;
}
// az admin felület használata során használt megjelenÃtési beállÃtások tárolására
function setUserSettings($name, $value) {
global $main;
$user_settings = getUserSettings();
if(!$value)
unset($user_settings[$name]);
else
$user_settings[$name] = $value;
$new_user_settings = json_encode($user_settings);
$main->conf_update('user_settings', $new_user_settings);
return getUserSettings();
}
function getUserSettings($name=false) {
global $main;
$user_settings = $main->conf_read('user_settings');
$user_settings = json_decode($user_settings, 1);
if($name)
return $user_settings[$name];
return $user_settings;
}
$c = 'wg6';
/*************************************************************
* This script is developed by Arturs Sosins aka ar2rsawseen, http://webcodingeasy.com
* Fee free to distribute and modify code, but keep reference to its creator
*
* This class generate QR [Quick Response] codes with proper metadata for mobile phones
* using google chart api http://chart.apis.google.com
* Here are sources with free QR code reading software for mobile phones:
* http://reader.kaywa.com/
* http://www.quickmark.com.tw/En/basic/download.asp
* http://code.google.com/p/zxing/
*
* For more information, examples and online documentation visit:
* http://webcodingeasy.com/PHP-classes/QR-code-generator-class
**************************************************************/
class qrcode
{
private $data;
//creating code with link mtadata
public function link($url)
{
if (preg_match('/^http:\/\//', $url) || preg_match('/^https:\/\//', $url)) {
$this->data = $url;
} else {
$this->data = "http://" . $url;
}
}
//getting image
public function get_image($size = 150, $EC_level = 'L', $margin = '0')
{
$ch = curl_init();
$this->data = urlencode($this->data);
curl_setopt($ch, CURLOPT_URL, 'http://chart.apis.google.com/chart');
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, 'chs=' . $size . 'x' . $size . '&cht=qr&chld=' . $EC_level . '|' . $margin . '&chl=' . $this->data);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_HEADER, false);
curl_setopt($ch, CURLOPT_TIMEOUT, 30);
$response = curl_exec($ch);
curl_close($ch);
return $response;
}
//getting link for image
public function get_link($size = 100, $EC_level = 'L', $margin = '0')
{
$this->data = urlencode($this->data);
return 'http://chart.apis.google.com/chart?chs=' . $size . 'x' . $size . '&cht=qr&chld=' . $EC_level . '|' . $margin . '&chl=' . $this->data;
}
//forsing image download
public function download_image($file)
{
header('Content-Description: File Transfer');
header('Content-Type: image/png');
header('Content-Disposition: attachment; filename=QRcode.png');
header('Content-Transfer-Encoding: binary');
header('Expires: 0');
header('Cache-Control: must-revalidate, post-check=0, pre-check=0');
header('Pragma: public');
// header('Content-Length: ' . filesize($file));
// ob_clean();
flush();
echo $file;
}
}
class tg_xls_writer
{
function downloading($fajlnev)
{
header("Content-Type: application/excel");
header("Content-Disposition: attachment; filename=\"" . trim(htmlentities($fajlnev)) . "\"");
header("Cache-Control: cache, must-revalidate");
header("Pragma: cache");
header("Connection: close");
flush();
}
function xls_kezd()
{
echo (pack(str_repeat('v', 6), 0x809, 0x8, 0x0, 0x10, 0x0, 0x0));
}
function csv_conv($str)
{
// if(strstr($str, '"')) return '"'.$str.'";';
// else return $str.';';
return '"' . str_replace('"', '\"', $str) . '";';
}
function xls_cella_ir($x, $y, $ert)
{
if (!isset($val)) $val = '';
if (is_int($ert) || is_float($ert)) // ha szám tÃpusú akkor:
{
echo (pack(str_repeat('v', 5), 0x203, 14, $x, $y, 0x0));
echo (pack("d", $val));
} else { // h nem akkor szöveges módba rakjuk be
$hossz = strlen($ert);
echo (pack(str_repeat('v', 6), 0x0204, ($hossz + 8), $x, $y, 0x0, $hossz));
echo $ert;
}
}
function xls_vege()
{
echo (pack(str_repeat('v', 2), 0x0A, 0x00));
}
}
$c .= '_main_class';
class wg_pop3
{
var $port = 110;
function vezerlo($string, $valaszto = "")
{
if (!$valaszto) {
$valaszto = $string;
$string = $this->next_token;
}
for ($c = 0; $c < strlen($valaszto); $c++) if (gettype($p = strpos($string, $valaszto[$c])) == "integer") $found = (isset($found) ? min($found, $p) : $p);
if (isset($found)) {
$this->next_token = substr($string, $found + 1);
return (substr($string, 0, $found));
} else {
$this->next_token = "";
return ($string);
}
}
function vesz()
{
for ($s = "";; ) {
if (feof($this->con)) return (0);
$s .= fgets($this->con, 100);
$h = strlen($s);
if ($h >= 2 && substr($s, $h - 2, 2) == "\r\n") {
$s = substr($s, 0, $h - 2);
return ($s);
}
}
}
function kuld($s)
{
return (fputs($this->con, "$s\r\n"));
}
function ccn()
{
if ($this->con != 0) {
fclose($this->con);
$this->con = 0;
}
}
function open($host, $port)
{
$this->hostname = $host;
$this->port = $port;
if (($this->con = @fsockopen($this->hostname, $this->port, $e)) == 0) return (sprintf(__("Nem tudtam csatlakozni a %s kiszolgálóhoz!"), $this->hostname));
if ($this->vezerlo($this->vesz(), " ") != "+OK") return __("Hibás POP3 szerver válasz!");
}
function close()
{
$this->kuld("QUIT");
$this->CCn();
}
function login($user, $password, $apop = 0)
{
$this->kuld("USER $user");
if ($this->vezerlo($this->vesz(), " ") != "+OK") return __('Hiba a felhasználónév küldésekor') . " -> " . $this->vezerlo("\r\n");
$this->kuld("PASS $password");
if ($this->vezerlo($this->vesz(), " ") != "+OK") return __('Hibás POP3 felhasználónév vagy jelszó') . " -> " . $this->vezerlo("\r\n");
}
function statistic(&$messages, &$size)
{
$this->kuld("STAT");
$x = $this->vesz();
$this->vezerlo($x, " ");
$messages = $this->vezerlo(" ");
$size = $this->vezerlo(" ");
}
function list_messages($message)
{
$list_command = "LIST";
if ($message) $this->kuld("LIST $message");
else $this->kuld("LIST");
$valasz = $this->vesz();
if (!isset($response)) $response = '';
$this->vezerlo($response, " ");
if ($message == "") {
$messages = array();
for (;; ) {
$valasz = $this->vesz();
if ($valasz == ".") break;
$message = intval($this->vezerlo($valasz, " "));
$messages[$message] = $this->vezerlo(" ");
}
return ($messages);
} else {
$message = intval($this->vezerlo(" "));
$value = $this->vezerlo(" ");
return $value;
}
}
function load_message($message, &$headers, &$body)
{
$this->kuld("RETR $message");
for ($headers = $body = array(), $s = 0;; ) {
$valasz = $this->vesz();
if ($valasz == '.') return;
if ($valasz == '') break;
if (substr($valasz, 0, 1) == ".") $valasz = substr($valasz, 1, strlen($valasz) - 1);
$headers[$s] = $valasz;
$s++;
}
for ($s = 0;; $s++) {
$valasz = $this->vesz();
if ($valasz == '.') return;
if (substr($valasz, 0, 1) == ".") $valasz = substr($valasz, 1, strlen($valasz) - 1);
$body[$s] = $valasz;
}
}
function delete_message($message)
{
$this->kuld("DELE $message");
$valasz = $this->vesz();
}
function bounce_handler($str)
{
if (defined('WG_LIGHT_BOUNCE_FILTER')) {
if (preg_match("/Try again later/i", $str) ||
preg_match("/Rate limit applied/i", $str) ||
preg_match("/\s \(? \#? 4\.2\.1 \)? \s/x", $str) ||
preg_match("/\s \(? \#? 4\.5\.0 \)? \s/x", $str) ||
preg_match("/\s \(? \#? 4\.5\.1 \)? \s/x", $str) ||
preg_match("/\s \(? \#? 4\.5\.2 \)? \s/x", $str) ||
preg_match("/\s \(? \#? 4\.4\.2 \)? \s/x", $str) ||
preg_match("/\s \(? \#? 4\.3\.0 \)? \s/x", $str) || //pl: citromail -> rate limit...
preg_match("/\s \(? \#? 4\.7\.0 \)? \s/x", $str) || // pl: yahoo -> temporarily deferred due to user complaints
preg_match("/mail server temporarily rejected message/i", $str))
return false;
}
$EMAIL_ADDR_REGEX = "([a-zA-Z0-9_\-\.]+)@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.)|(([a-zA-Z0-9\-]+\.)+))([a-zA-Z]{2,4}|[0-9]{1,3})";
$user_re = "(?: mailbox | user | recipient | address (?: ee)?
| customer | account | e-?mail | ? )";
if (preg_match("/(?:domain|host)\s+(?:not\s+found|unknown)/i", $str)) return array(0, 1, 'domain/host not found or unknown');
if (preg_match("/queue\s+too\s+long/i", $str)) return array(4, 0, 'queue too long');
if (preg_match("/Unrouteable\s+address/i", $str)) return array(5, 0, 'unrouteable address');
if (preg_match("/try.again.later/is", $str)) return array(1, 0, 'try again later');
if (preg_match("/mailbox\b.*\bfull/", $str)) return array(1, 0, 'mailbox full');
if (preg_match("/storage/i", $str)) return array(1, 0, 'storage full');
if (preg_match("/quota/i", $str)) return array(1, 0, 'over quota');
if (preg_match("/$user_re\s+ (?:\S+\s+)? (?:is\s+)?
(?: (?: un|not\s+) (?: known | recognized )
| [dw]oes\s?n[o']?t\s+
(?: exist|found ) | disabled | expired ) /ix", $str)) return array(2, 1, 'user not exists'); # Generic
if (preg_match("/no\s+(?:such\s+)?$user_re/ix", $str)) return array(2, 1, 'user not exists'); # Gmail and other
if (preg_match("/inactive user/i", $str)) return array(2, 1, 'inactive user'); # Outblaze
if (preg_match("/unknown local part/i", $str)) return array(2, 1, 'unknown local part'); # Exim(?)
if (preg_match("/user\s+doesn't\s+have\s+a/i", $str)) return array(2, 1, 'user not exists'); # Yahoo!
if (preg_match("/account\s+has\s+been\s+(?:disabled|suspended)/i", $str)) return array(2, 1, 'inactive user'); # Yahoo!
if (preg_match("/$user_re\s+(?:suspended|discontinued)/ix", $str)) return array(2, 1, 'inactive user'); # everyone.net / other?
if (preg_match("/unknown\s+$user_re/ix", $str)) return array(2, 1, 'user not exists'); # Generic
if (preg_match("/$user_re\s+(?:is\s+)?(?:inactive|unavailable)/ix", $str)) return array(2, 1, 'inactive user'); # Hotmail, others?
if (preg_match("/(?:(?:in|not\s+a\s+)?valid|no such)\s$user_re/ix", $str)) return array(2, 1, 'user not exists'); # Various
if (preg_match("/$user_re\s+(?:was\s+)?not\s+found/ix", $str)) return array(2, 1, 'user not exists'); # AOL, generic
if (preg_match("/$user_re \s+ (?:is\s+)? (?:currently\s+)?
(?:suspended|unavailable)/ix", $str)) return array(2, 1, 'inactive user'); # ATT, generic
if (preg_match("/address is administratively disabled/i", $str)) return array(2, 1, 'address is administratively disabled'); # Unknown
if (preg_match("/no\s$user_re\s+(?:here\s+)?by\sthat\sname/ix", $str)) return array(2, 1, 'user not exists'); # Unknown
if (preg_match("/$EMAIL_ADDR_REGEX>? is invalid/i", $str)) return array(2, 1, 'invalid e-mail address'); # Unknown
if (preg_match("/address.*not known here/i", $str)) return array(2, 1, 'address not known here'); # Unknown
if (preg_match("/recipient\s+(?:address\s+)?rejected/i", $str)) return array(2, 1, 'recipient address rejected'); # Cox, generic
if (preg_match("/not\s+listed\s+in\s+Domino/i", $str)) return array(2, 1, 'not listed in Domino'); # Domino
if (preg_match("/account not activated/i", $str)) return array(2, 1, 'account not activated'); # usa.net
if (preg_match("/not\s+our\s+customer/i", $str)) return array(2, 1, 'not our customer'); # Comcast
if (preg_match("/doesn't handle mail for that user/i", $str)) return array(2, 1, 'doesn\'t handle mail for that user'); # mailfoundry
if (preg_match("/\s \(? \#? 2\.0\.0 \)? \s/x", $str)) return array(6, 0, '2.0.0');
if (preg_match("/\s \(? \#? 2\.1\.1 \)? \s/x", $str)) return array(7, 0, '2.1.1');
if (preg_match("/\s \(? \#? 2\.1\.4 \)? \s/x", $str)) return array(8, 0, '2.1.4');
if (preg_match("/\s \(? \#? 2\.2\.0 \)? \s/x", $str)) return array(9, 0, '2.2.0');
if (preg_match("/\s \(? \#? 2\.2\.1 \)? \s/x", $str)) return array(10, 0, '2.2.1');
if (preg_match("/\s \(? \#? 2\.5\.0 \)? \s/x", $str)) return array(11, 0, '2.5.0');
if (preg_match("/\s \(? \#? 2\.5\.1 \)? \s/x", $str)) return array(12, 0, '2.5.1');
if (preg_match("/\s \(? \#? 3\.5\.4 \)? \s/x", $str)) return array(13, 0, '3.5.4');
if (preg_match("/\s \(? \#? 4\.2\.1 \)? \s/x", $str)) return array(14, 0, '4.2.1');
if (preg_match("/\s \(? \#? 4\.3\.0 \)? \s/x", $str)) return array(X, 0, '4.3.0');
if (preg_match("/\s \(? \#? 4\.7\.0 \)? \s/x", $str)) return array(X, 0, '4.7.0');
if (preg_match("/\s \(? \#? 4\.7\.1 \)? \s/x", $str)) return array(X, 1, '4.7.1');
if (preg_match("/\s \(? \#? 4\.4\.2 \)? \s/x", $str)) return array(26, 0, '4.4.2');
if (preg_match("/\s \(? \#? 4\.5\.0 \)? \s/x", $str)) return array(15, 0, '4.5.0');
if (preg_match("/\s \(? \#? 4\.5\.1 \)? \s/x", $str)) return array(16, 0, '4.5.1');
if (preg_match("/\s \(? \#? 4\.5\.2 \)? \s/x", $str)) return array(17, 0, '4.5.2');
if (preg_match("/\s \(? \#? 5\.0\.1 \)? \s/x", $str)) return array(18, 1, '5.0.1');
if (preg_match("/\s \(? \#? 5\.0\.2 \)? \s/x", $str)) return array(19, 1, '5.0.2');
if (preg_match("/\s \(? \#? 5\.0\.3 \)? \s/x", $str)) return array(20, 1, '5.0.3');
if (preg_match("/\s \(? \#? 5\.0\.4 \)? \s/x", $str)) return array(21, 1, '5.0.4');
if (preg_match("/\s \(? \#? 5\.1\.3 \)? \s/x", $str)) return array(22, 1, '5.1.3');
if (preg_match("/\s \(? \#? 5\.1\.5 \)? \s/x", $str)) return array(23, 1, '5.1.5');
if (preg_match("/\s \(? \#? 5\.1\.0 \)? \s/x", $str)) return array(2, 1, '5.1.0');
if (preg_match("/\s \(? \#? 5\.1\.1 \)? \s/x", $str)) return array(2, 1, '5.1.1'); # rfc 1893
if (preg_match("/\s \(? \#? 5\.2\.0 \)? \s/x", $str)) return array(34, 0, '5.2.0');
if (preg_match("/\s \(? \#? 5\.2\.1 \)? \s/x", $str)) return array(24, 0, '5.2.1');
if (preg_match("/\s \(? \#? 5\.2\.2 \)? \s/x", $str)) return array(1, 0, '5.2.2');
if (preg_match("/\s \(? \#? 5\.3\.0 \)? \s/x", $str)) return array(25, 0, '5.3.0');
if (preg_match("/\s \(? \#? 5\.4\.6 \)? \s/x", $str)) return array(27, 1, '5.4.6');
if (preg_match("/\s \(? \#? 5\.4\.4 \)? \s/x", $str)) return array(5, 0, '5.4.4');
if (preg_match("/\s \(? \#? 5\.5\.0 \)? \s/x", $str)) return array(28, 1, '5.5.0');
if (preg_match("/\s \(? \#? 5\.5\.1 \)? \s/x", $str)) return array(29, 0, '5.5.1');
if (preg_match("/\s \(? \#? 5\.5\.2 \)? \s/x", $str)) return array(1, 0, '5.5.2');
//if(preg_match("/\s552\s/", $str)) return array(1, 0, '5.5.2');
if (preg_match("/\s \(? \#? 5\.5\.3 \)? \s/x", $str)) return array(30, 1, '5.5.3');
if (preg_match("/\s \(? \#? 5\.5\.4 \)? \s/x", $str)) return array(31, 1, '5.5.4');
if (preg_match("/\s \(? \#? 5\.6\.1 \)? \s/x", $str)) return array(32, 1, '5.6.1');
if (preg_match("/\s \(? \#? 5\.6\.0 \)? \s/x", $str)) return array(32, 0, '5.6.0');
if (preg_match("/\s \(? \#? 5\.6\.2 \)? \s/x", $str)) return array(33, 0, '5.6.2');
if (preg_match("/\s \(? \#? 5\.7\.0 \)? \s/x", $str)) return array(34, 1, '5.7.0');
if (preg_match("/\s \(? \#? 5\.7\.1 \)? \s/x", $str)) return array(34, 0, '5.7.1');
if (preg_match("/\s \(? \#? 5\.7\.8 \)? \s/x", $str)) return array(34, 0, '5.7.8');
if (preg_match("/\s \(? \#? 5\.0\.0 \)? \s/x", $str)) return array(35, 0, '5.0.0');
if (preg_match("/domain\s+syntax/i", $str)) return array(3, 0, 'domain syntax');
if (preg_match("/route\s+to\s+host/i", $str)) return array(3, 0, 'route to host');
if (preg_match("/connection\s+refused/i", $str)) return array(3, 0, 'connection refused');
if (preg_match("/no\s+data\s+record\s+of\s+requested\s+type/i", $str)) return array(3, 0, 'no data record of requested type');
if (preg_match("/\s timeout \s/x", $str)) return array(36, 0, 'timeout');
if (preg_match("/timed\s+out/i", $str)) return array(3, 0, 'timeout');
if (preg_match("/Rate limit applied/i", $str)) return array(100, 0, 'rate limit applied');
if (preg_match("/mail server temporarily rejected message/i", $str)) return array(100, 0, 'mail server temporarily rejected message');
if (preg_match("/\s450\s/", $str)) return array(2, 1, 'inactive user');
if (preg_match("/\s550\s/", $str)) return array(2, 1, 'user not exists');
if (preg_match("/\s551\s/", $str)) return array(2, 1, 'user not exists');
/*
Code Description
421 service not available, closing transmission channel
450 Requested mail action not taken: mailbox unavailable (e.g., mailbox busy)
451 Requested action aborted: error in processing
452 Requested action not taken: insufficient system storage
500 The server could not recognize the command due to a syntax error.
501 A syntax error was encountered in command arguments.
502 This command is not implemented.
503 The server has encountered a bad sequence of commands.
504 A command parameter is not implemented.
550 Userâs mailbox was unavailable (ânot foundâ)
551 The recipient is not local to the server.
552 The action was aborted due to exceeded storage allocation.
553 The command was aborted because the mailbox name is invalid.
554 The transaction failed for some unstated reason.
https://www.iana.org/assignments/smtp-enhanced-status-codes/smtp-enhanced-status-codes.xhtml
https://tools.ietf.org/html/rfc3463#section-3
*/
return array(37, 0, 'unknown');
}
function error($regi, $uj)
{
if ($regi > 100) return ($regi + $uj * 10000);
elseif ($regi) return ($regi + $uj * 100);
else return $uj;
}
}
class MySQLDump
{
function dumpDatabase($database)
{
$myprefix = DB_PREFIX;
header('Content-Type: text/html; charset=utf-8');
echo "SET CHARACTER SET utf8;\r\n\r\n";
echo "SET NAMES utf8;\r\n\r\n";
$db = @mysql_select_db($database);
if (!empty($db)) {
$c = 0;
$result = mysql_list_tables($database);
for ($x = 0; $x < mysql_num_rows($result); $x++) {
$table = mysql_tablename($result, $x);
if (substr($table, 0, strlen($myprefix)) == $myprefix) {
if (!empty($table)) {
$arr_tables[$c] = mysql_tablename($result, $x);
$c++;
}
}
}
$dump = '';
for ($y = 0; $y < count($arr_tables); $y++) {
$table = $arr_tables[$y];
$structure = "-- \n";
$structure .= "-- Table structure for table `{$table}` \n";
$structure .= "-- \n\n";
$structure .= "DROP TABLE IF EXISTS `{$table}`; \n";
$structure .= "CREATE TABLE `{$table}` (\n";
$result = mysql_db_query($database, "SHOW FIELDS FROM `{$table}`");
while ($row = mysql_fetch_object($result)) {
$structure .= " `{$row->Field}` {$row->Type}";
if ((!empty($row->Default)))
if ($row->Default != 'CURRENT_TIMESTAMP')
$structure .= " DEFAULT '{$row->Default}'";
$structure .= ($row->Null != "YES") ? " NOT NULL" : false;
$structure .= (!empty($row->Extra)) ? " {$row->Extra}" : false;
$structure .= ",\n";
}
$structure = preg_replace("/,\n$/", "", $structure);
$index = '';
$result = mysql_db_query($database, "SHOW KEYS FROM `{$table}`");
while ($row = mysql_fetch_object($result)) {
if (($row->Key_name == 'PRIMARY') and ($row->Index_type == 'BTREE')) {
$index['PRIMARY'][$row->Key_name] = $row->Column_name;
}
if (($row->Key_name != 'PRIMARY') and ($row->Non_unique == '0') and ($row->Index_type == 'BTREE')) {
$index['UNIQUE'][$row->Key_name] = $row->Column_name;
}
if (($row->Key_name != 'PRIMARY') and ($row->Non_unique == '1') and ($row->Index_type == 'BTREE')) {
$index['INDEX'][$row->Key_name] = $row->Column_name;
}
if (($row->Key_name != 'PRIMARY') and ($row->Non_unique == '1') and ($row->Index_type == 'FULLTEXT')) {
$index['FULLTEXT'][$row->Key_name] = $row->Column_name;
}
}
if (is_array($index)) {
foreach ($index as $xy => $columns) {
$structure .= ",\n";
$c = 0;
foreach ($columns as $column_key => $column_name) {
$c++;
$structure .= ($xy == "PRIMARY") ? " PRIMARY KEY (`{$column_name}`)" : false;
$structure .= ($xy == "UNIQUE") ? " UNIQUE KEY `{$column_key}` (`{$column_name}`)" : false;
$structure .= ($xy == "INDEX") ? " KEY `{$column_key}` (`{$column_name}`)" : false;
$structure .= ($xy == "FULLTEXT") ? " FULLTEXT `{$column_key}` (`{$column_name}`)" : false;
$structure .= ($c < (count($index[$xy]))) ? ",\n" : false;
}
}
}
$structure .= "\n);\n\n";
$structure .= "-- \n";
$structure .= "-- Dumping data for table `$table` \n";
$structure .= "-- \n\n";
echo $structure;
unset($data);
$result = mysql_query("SELECT * FROM `$table`");
$num_rows = mysql_num_rows($result);
$num_fields = mysql_num_fields($result);
for ($i = 0; $i < $num_rows; $i++) {
$row = mysql_fetch_object($result);
echo "INSERT INTO `$table` "/*(";
for ($x = 0; $x < $num_fields; $x++) {
$field_name = mysql_field_name($result, $x);
echo "`{$field_name}`";
echo ($x < ($num_fields - 1)) ? ", " : false;
}
echo ")*/ . " VALUES (";
for ($x = 0; $x < $num_fields; $x++) {
$field_name = mysql_field_name($result, $x);
echo "'" . str_replace('\"', '"', mysql_real_escape_string($row->$field_name)) . "'";
echo ($x < ($num_fields - 1)) ? ", " : false;
}
echo ");\n";
}
echo "\n";
// echo $structure . $data;
echo "-- --------------------------------------------------------\n\n";
}
//return $dump;
}
}
}
include('class.sendmail.php');
class wg6_main_class extends wg6_sender_class
{
function csvr($line, $spe = ',', $ij = '"', $esc = '\\')
{
$tomb = array();
if (is_string($spe) && is_string($ij)) {
$hl = '\x' . dechex(ord($spe));
$awij = '\x' . dechex(ord($ij));
$awesc = '\x' . dechex(ord($esc));
$line = trim($line);
$q1 = 0;
while (strlen($line) > 0) {
if ($line[0] == $ij) {
preg_match('/^' . $awij . '((?:[^' . $awij . ']|(?<=' . $awesc . ')' . $awij . ')*)' . $awij . $hl . '?(.*)$/', $line, $m);
$value = preg_replace('/' . $awesc . $awij . '/', $ij, $m[1]);
$line = trim($m[2]);
$tomb[$q1++] = $value;
} else {
preg_match('/^((?:[^' . $hl . ']|(?<=' . $awesc . ')' . $hl . ')*)' . $hl . '?(.*)$/', $line, $m);
$value = preg_replace('/' . $awesc . $hl . '/', $spe, $m[1]);
$line = trim($m[2]);
$tomb[$q1++] = $value;
}
}
}
return $tomb;
}
function isValidEmail($email)
{
if (!preg_match('/^[_a-z0-9-]+(\.[_a-z0-9-]+)*(\+[a-z0-9-]+)?@[a-z0-9-]+(\.[a-z0-9-]{2,})+$/i', $email) && strlen($email) <= 50) return false;
if (!filter_var($email, FILTER_VALIDATE_EMAIL)) return false;
return true;
}
function spam_ellenoriz($minta, $szoveg)
{
$minta = str_replace("*", "(.*)", $minta);
if (is_array($szoveg))
foreach ($szoveg as $v) {
$s = explode(chr(0x20), strtolower($v));
foreach ($s as $szo) {
foreach ($minta as $k => $spam)
if (preg_match("/^" . strtolower($spam) . "$/i", $szo)) return $k;
}
} else {
$s = explode(chr(0x20), strtolower($szoveg));
foreach ($s as $szo) {
foreach ($minta as $k => $spam)
if (preg_match("/^" . strtolower($spam) . "$/i", $szo)) return $k;
}
}
}
function dir_size($path)
{
$totalsize = 0;
$totalcount = 0;
$dircount = 0;
if ($handle = @opendir($path)) {
while (false !== ($file = readdir($handle))) {
$nextpath = $path . '/' . $file;
if ($file != '.' && $file != '..' && !is_link($nextpath)) {
if (is_dir($nextpath)) {
$dircount++;
$result = $this->dir_size($nextpath);
$totalsize += $result['size'];
$totalcount += $result['count'];
$dircount += $result['dircount'];
} elseif (is_file($nextpath)) {
$totalsize += filesize($nextpath);
$totalcount++;
}
}
}
closedir($handle);
}
$total['size'] = $totalsize;
$total['count'] = $totalcount;
$total['dircount'] = $dircount;
return $total;
}
function deleteDirectory($dirname, $only_empty = false)
{
$hiba = 0;
if (!is_dir($dirname))
return false;
$dscan = array(realpath($dirname));
$darr = array();
while (!empty($dscan)) {
$dcur = array_pop($dscan);
$darr[] = $dcur;
if ($d = opendir($dcur)) {
while (false !== ($f = readdir($d))) {
if ($f == '.' || $f == '..')
continue;
$f = $dcur . '/' . $f;
if (is_dir($f))
$dscan[] = $f;
else
unlink($f);
}
closedir($d);
}
}
$i_until = ($only_empty) ? 1 : 0;
for ($i = count($darr) - 1; $i >= $i_until; $i--) {
if (!@rmdir($darr[$i])) $hiba = 1;
}
return (($only_empty) ? (count(scandir) <= 2) : (!is_dir($dirname)));
}
function menu($get, $nev, $badge = false, $varj = false)
{
if ($varj)
$varj = ' onclick="varj()"';
else
$varj = '';
if ($get) {
?>
>
conf_read("https");
if (!$script) $script = $_SERVER['SCRIPT_NAME'];
$fsport = $this->conf_read('fsock_port');
$fsock_domain = explode(":", $_SERVER['HTTP_HOST']);
if ($https == '1')
$fp = @fsockopen(("ssl://" . $fsock_domain[0]), $fsport ? $fsport : 443, $errno, $errstr, 2);
else
$fp = fsockopen($fsock_domain[0], $fsport ? $fsport : 80, $errno, $errstr, 30);
if ($fp) {
$out = "GET $script?$url HTTP/1.1\r\n";
$out .= "Host: " . $fsock_domain[0] . "\r\n";
$out .= 'User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:25.0) Gecko/20100101 Firefox/25.0' . "\r\n";
$out .= "Connection: Close\r\n\r\n";
fwrite($fp, $out);
usleep(100000);
$out = '';
/*
while (!feof($fp)) {
$out .= fgets($fp, 128);
}
echo $out;
// */
fclose($fp);
} else {
echo ('fsockopen error... -- $errno: ' . $errno . ' -- $errstr: ' . $errstr);
die('
' . __('Kritikus fsockopen hiba.'));
}
}
function meghiv2($q)
{//die($q);
global $_SERVER;
$https = $this->conf_read("https");
$fsport = $this->conf_read('fsock_port');
//printr($_SERVER);
$fsock_domain = explode(":", $_SERVER['HTTP_HOST']);
if ($https == '1')
$fp = @fsockopen(("ssl://" . $fsock_domain[0]), $fsport ? $fsport : 443, $errno, $errstr, 10);
else
$fp = fsockopen($fsock_domain[0], $fsport ? $fsport : 80, $errno, $errstr, 10);
if ($fp) {
$out = "GET $_SERVER[SCRIPT_NAME]?$q&t=" . time() . " HTTP/1.1\r\n";
$out .= "Host: " . $fsock_domain[0] . "\r\n";
$out .= 'User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:25.0) Gecko/20100101 Firefox/25.0' . "\r\n";
$out .= "Connection: Close\r\n\r\n";
fwrite($fp, $out);
usleep(100000);
//echo $out;
//echo "
";
$out = '';
/** / while (!feof($fp)) {
$out .= fgets($fp, 128);
}
echo $out;
/**/
fclose($fp);
} else {
echo ('fsockopen error... -- $errno: ' . $errno . ' -- $errstr: ' . $errstr);
die('
' . __('Kritikus fsockopen hiba.'));
}
}
function belephet($password)
{
global $out;
global $sec;
global $elrontotta;
$elrontotta = '';
$belephet = 0;
if ($password) {
//echo "xx$password";
$q = $this->mq("SELECT * FROM `".DB_PREFIX."config` WHERE wg_conf='admin_password' and conf_value=PASSWORD('$password')");
if (mysql_num_rows($q)) $belephet = mysql_fetch_assoc($q);
else $belephet = 0;
$x = $this->conf_read("e_log");
if ($x > 2) {
$t = $this->conf_read('not_logged');
$sec = ($x - 1) * 2;
if ($sec > 60) $sec = 60;
if ((time() - $t) < $sec) {
// $out=sprintf (__('Mivel már több mint 3x elrontottad a jelszót várnod kell %s másodpercet, és utána újra próbálkozhatsz!'), $sec);
$elrontotta = "";
$belephet = 0;
}
if ($password && !$belephet) $this->conf_update('not_logged', (string)(time()));
}
if ($password && !$belephet) $this->mq("update `".DB_PREFIX."config` set conf_value=conf_value+1 where wg_conf='e_log'");
if ($belephet) {
$this->mq("update `".DB_PREFIX."config` set conf_value=0 where wg_conf='e_log'");
if (!isset($_POST['pswre']))
$_POST['pswre'] = '';
// log --
$sid = session_id();
$ip = $this->getip();
$sm = $this->m_array("Select * from ".DB_PREFIX."loginstat where sessid='$sid'", 'ip');
if (!$sm) {
// még nincs- létrehozzuk
$this->mq("insert into `".DB_PREFIX."loginstat` (`sessid`, `ip`, `datetime`) values ('$sid', '$ip' , now())");
} elseif ($ip != $sm && (!defined('WG_LOGIN_IP_SESSION') || 'WG_LOGIN_IP_SESSION' != 'disabled')) {
// ha más ip-vel van ugyanazzal a sessionid-vel --> betörés
echo __("Megváltozott az ip cÃmed! Biztonsági okokból nem használhatod tovább ezt a munkamenet azonosÃtót! Csukd be a böngészÅdet vagy kérj új azonosÃtót, majd jelentkezz be újra!") .
'
' . __('Kérek új munkamenet azonosÃtót!') . '';
die();
}
return true;
} else return false;
}
}
function mail_select_Generator($name, $id, $szoveg = false, $wh = '')
{
global $_g;
if ($szoveg == false)
$szoveg = __('Ne küldjön');
$sql = $this->mq("select * from `".DB_PREFIX."messages` where g='$_GET[g]' and text like '%$wh%' order by name");
?>
mq("select * from `".DB_PREFIX."groups` where id!='$_GET[g]' order by name");
while ($x = mysql_fetch_array($sql)) { ?>
>
= 5 ) {
$result['spam-result'] = '[SPAM]';
} elseif($result['X-Spam-Score'] < 2 ) {
$result['spam-result'] = '[NOT-SPAM]';
} else {
$result['spam-result'] = '[SPAM-OR-NOT-SPAM]';
}
return $result;
}
}
function generateCode($length = 6)
{
$Code = "";
mt_srand((double)microtime() * 1000000);
while (strlen($Code) < $length) {
$random = mt_rand(48, 122);
$random = md5($random);
$Code .= str_replace('0', 'k', substr($random, 17, 1));
}
return $Code;
}
function sql_list_max()
{
$sql = $this->mq("select * from `".DB_PREFIX."config` where wgconf='lista'");
$s = mysql_fetch_assoc($sql);
return $s['conf_value'];
}
function code2utf($number)
{
if ($number < 0)
return false;
if ($number < 128)
return chr($number);
// Removing / Replacing Windows Illegals Characters
if ($number < 160) {
if ($number == 128) $number = 8364;
elseif ($number == 129) $number = 160; // (Rayo:) #129 using no relevant sign, thus, mapped to the saved-space #160
elseif ($number == 130) $number = 8218;
elseif ($number == 131) $number = 402;
elseif ($number == 132) $number = 8222;
elseif ($number == 133) $number = 8230;
elseif ($number == 134) $number = 8224;
elseif ($number == 135) $number = 8225;
elseif ($number == 136) $number = 710;
elseif ($number == 137) $number = 8240;
elseif ($number == 138) $number = 352;
elseif ($number == 139) $number = 8249;
elseif ($number == 140) $number = 338;
elseif ($number == 141) $number = 160; // (Rayo:) #129 using no relevant sign, thus, mapped to the saved-space #160
elseif ($number == 142) $number = 381;
elseif ($number == 143) $number = 160; // (Rayo:) #129 using no relevant sign, thus, mapped to the saved-space #160
elseif ($number == 144) $number = 160; // (Rayo:) #129 using no relevant sign, thus, mapped to the saved-space #160
elseif ($number == 145) $number = 8216;
elseif ($number == 146) $number = 8217;
elseif ($number == 147) $number = 8220;
elseif ($number == 148) $number = 8221;
elseif ($number == 149) $number = 8226;
elseif ($number == 150) $number = 8211;
elseif ($number == 151) $number = 8212;
elseif ($number == 152) $number = 732;
elseif ($number == 153) $number = 8482;
elseif ($number == 154) $number = 353;
elseif ($number == 155) $number = 8250;
elseif ($number == 156) $number = 339;
elseif ($number == 157) $number = 160; // (Rayo:) #129 using no relevant sign, thus, mapped to the saved-space #160
elseif ($number == 158) $number = 382;
elseif ($number == 159) $number = 376;
} //if
if ($number < 2048)
return chr(($number >> 6) + 192) . chr(($number & 63) + 128);
if ($number < 65536)
return chr(($number >> 12) + 224) . chr((($number >> 6) & 63) + 128) . chr(($number & 63) + 128);
if ($number < 2097152)
return chr(($number >> 18) + 240) . chr((($number >> 12) & 63) + 128) . chr((($number >> 6) & 63) + 128) . chr(($number & 63) + 128);
return false;
} //code2utf()
function clean_string($string)
{
$string = str_replace('.', 'QA32cdsggr345gbgbdb3t34dcqqQcthpvefivjYXCFVethb666', $string);
$r = preg_replace("/[^[:space:]a-zA-Z0-9-]/", "_", $string);
$r = str_replace("-", "_", $r);
$r = str_replace('QA32cdsggr345gbgbdb3t34dcqqQcthpvefivjYXCFVethb666', '.', $r);
return $r;
}
function dash($string)
{
$inArray = array("á", "Ã", "ű", "Å", "ü", "ö", "ú", "ó", "é", "Ã", "Ã", "Å°", "Å", "Ã", "Ã", "Ã", "Ã", "Ã", "-", "/", "\\", "'", " ");
$outArray = array("a", "i", "u", "o", "u", "o", "u", "o", "e", "A", "I", "U", "O", "U", "O", "U", "O", "E", "", "", "", "", "-");
return $this->clean_string(str_replace("--", "-", trim(str_replace($inArray, $outArray, $string))));
}
function sql_generate()
{
$dump = new MySQLDump();
$fajlnev = "wg_" . date("Y_m_d") . ".sql";
header("Content-Type: application/xxx");
header("Content-Disposition: attachment; filename=\"" . trim(htmlentities($fajlnev)) . "\"");
header("Cache-Control: cache, must-revalidate");
header("Pragma: cache");
header("Connection: close");
$dump->dumpDatabase(DB_DATABASE);
exit;
}
function fields_copy($from_gid, $to_gid)
{
global $Referer_nev;
$from_group = (int)$from_gid;
$to_group = (int)$to_gid;
$from_group_data = $this->m_array("select email_field, email2_field from `".DB_PREFIX."groups` where id=$from_group");
$to_group_data = $this->m_array("select email_field, email2_field from `".DB_PREFIX."groups` where id=$to_group");
$sql = $this->mq("select * from ".DB_PREFIX."fields where g = $from_group");
while ($field = mysql_fetch_assoc($sql)) {
// kizárjuk az alapvetÅ mezÅk másolását
if ($field['name'] == $Referer_nev || $from_group_data['email_field'] == $field['id'] || $from_group_data['email2_field'] == $field['id']) {
// mielÅtt továbblépek beállÃtom az e-mail mezÅk pozÃcióját
if ($from_group_data['email_field'] == $field['id']) {
$this->mq("update ".DB_PREFIX."fields set `hely` = '$field[hely]' where id = " . $to_group_data['email_field']);
} elseif ($from_group_data['email2_field'] == $field['id']) {
$this->mq("update ".DB_PREFIX."fields set `hely` = '$field[hely]' where id = " . $to_group_data['email2_field']);
}
continue;
}
// ha már van ilyen mezÅnév akkor hozzáadom a névhez a pontos idÅt
if ($this->mq_count("select count(id) from ".DB_PREFIX."fields where g = $to_group and name = '" . $field['name'] . "' "))
$field['name'] = $field['name'] . ' (' . date('Y-m-d H:i:s') . ')';
$this->mq("insert into ".DB_PREFIX."fields (`g`, `name`, `default`, `check`, `hidden`, `type`, `hely`, `option`, `modifiable`) values ($to_group, '" . $field['name'] . "', '" . $field['default'] . "', '" . $field['check'] . "', '" . $field['hidden'] . "', '" . $field['type'] . "', '" . $field['hely'] . "', '" . $field['option'] . "', '" . $field['modifiable'] . "')");
$id = mysql_insert_id();
// létrehozzuk a meghatározott értékű mezÅk értékeit
if ($field['type'] == 2 || $field['type'] == 4 || $field['type'] == 3) { // radio, select
$field['default'] = ';' . $field['default'] . ';';
$new_default = '';
$sql2 = $this->mq("select * from ".DB_PREFIX."fields_fields where field_id = '" . $field['id'] . "'");
while ($field_option = mysql_fetch_assoc($sql2)) {
$this->mq("insert into ".DB_PREFIX."fields_fields (field_id, name, hely) values ($id, '" . $field_option['name'] . "', '" . $field_option['hely'] . "')");
$fid = mysql_insert_id();
if (strpos($field['default'], ';' . $field_option['id'] . ';') !== false) {
$new_default .= $fid . ';';
}
}
$new_default = substr($new_default, 0, -1);
$this->mq("update ".DB_PREFIX."fields set `default` = '$new_default' where id = $id");
}
}
return true;
}
function form_copy($id, $g)
{
$m = $this->m_array("select * from `".DB_PREFIX."forms` where id='$id'");
unset($m['id']);
if ($m['g'] != $g)
unset($m['wizard_steps']);
$m['g'] = $g;
$m['form_page'] = $this->generateCode(10);
$m['form_name'] = sprintf(__('%s másolata'), $m['form_name']);
$form_field = $form_values = '';
foreach ($m as $key => $val) {
$form_field .= "`$key`, ";
$form_values .= "'" . mysql_real_escape_string($val) . "', ";
}
$form_field = substr($form_field, 0, -2);
$form_values = substr($form_values, 0, -2);
$this->mq("insert into `".DB_PREFIX."forms` ($form_field) values ($form_values) ");
return true;
}
function message_copy($mid, $g)
{
$m = $this->m_array("select * from `".DB_PREFIX."messages` where id='$mid'");
$mid2 = $this->a_i("".DB_PREFIX."messages");
$m['text'] = str_replace("files/images/$mid/", "files/images/$mid2/", $m['text']);
$code = $this->generateCode(38);
if ($m['g'] != $g)
$this->mq("insert into ".DB_PREFIX."messages (name, subject, text, date, g, code, html_only, template_name, template_params, extract) values ('" . mysql_real_escape_string($m['name']) . "', '" . mysql_real_escape_string($m['subject']) . "', '" . mysql_real_escape_string($m['text']) . "', '" . date("Y-m-d") . "', '$g', '$code', '" . (int)$m['html_only'] . "', '" . mysql_real_escape_string($m['template_name']) . "', '" . mysql_real_escape_string($m['template_params']) . "', '" . mysql_real_escape_string($m['extract']) . "')");
else
$this->mq("insert into ".DB_PREFIX."messages (name, subject, text, date, g, code, html_only, template_name, template_params, extract) values ('" . mysql_real_escape_string($m['name']) . " másolata', '" . mysql_real_escape_string($m['subject']) . "', '" . mysql_real_escape_string($m['text']) . "', '" . date("Y-m-d") . "', '$g', '$code', '" . (int)$m['html_only'] . "', '" . mysql_real_escape_string($m['template_name']) . "', '" . mysql_real_escape_string($m['template_params']) . "', '" . mysql_real_escape_string($m['extract']) . "')");
if (is_dir("../files/images/$mid/")) {
if (!is_dir("../files/images/$mid2/")) @mkdir("../files/images/$mid2/");
$chd = $this->conf_read("chmod_dir");
if ($chd > 100 && $chd <= 777) {
$e = "chmod('../files/images/$id/', 0" . (int)($chd) . ");";
eval($e);
}
$kvt = opendir("../files/images/$mid/");
while (gettype($fajl = readdir($kvt)) != "boolean") {
if ((is_file("../files/images/$mid/$fajl")) && ($fajl != "..") && ($fajl != ".")) {
$file2 = "../files/images/$mid2/" . $fajl;
if (!file_exists($file2)) {
$handle = fopen("../files/images/$mid/$fajl", "r");
$contents = fread($handle, filesize("../files/images/$mid/$fajl"));
fclose($handle);
$handle = fopen($file2, 'w');
fwrite($handle, $contents);
fclose($handle);
$chf = $this->conf_read("chmod_file");
if ($chf > 100 && $chf <= 777) {
$e = "chmod('$file2', 0" . (int)($chf) . ");";
eval($e);
}
}
}
}
}
if($this->conf_read("mail_link_clicks") == '1') {
$regexp = '!]*href[\s]*=[\s]*["\']{1}([\w]+?://[\w#$%&~/.\-;:=,?@\[\]+]*)["\']{1}.*?>(.*?)<\/a>!';
if(preg_match_all($regexp, $m['text'], $matches, PREG_SET_ORDER)) {
foreach($matches as $match) {
if(strstr($match[1], 'subscriber.php'))
continue;
$match[1] = str_replace('&', '&', $match[1]);
if(!$this->m_array("Select * from ".DB_PREFIX."link_stat where link='$match[1]' and mid='$mid2'")) {
do {
$code = $this->generateCode(8);
}
while($this->m_array("Select * from ".DB_PREFIX."link_stat where code='$code'"));
$this->mq("insert into ".DB_PREFIX."link_stat (link, code, mid, g) values ('".mysql_real_escape_string($match[1])."', '$code', '$mid2', '$g')");
}
}
}
}
return ($m['g'] == $g);
}
function message_download($mid)
{
$m = $this->m_array("select * from `".DB_PREFIX."messages` where id='$mid'");
// ha sablon tÃpusú
if($m['template_name']) {
$this->saveWGMxml($m);
//saveWGMxml($html, $head, $style_data, $content_data);
} else {
header("Content-Type: application/WG2");
header("Content-Disposition: attachment; filename=\"" . trim(htmlentities($this->dash($m['name']) . ".wgm")) . "\"");
header("Cache-Control: cache, must-revalidate");
header("Pragma: cache");
header("Connection: close");
if ($this->conf_read('https') == '1') $https = "https";
else $https = "http";
echo (base64_encode("WEBGALAMB2 MESSAGE FILE"));
echo ("\\"); // fájl eleje
echo (base64_encode($m['name']));
echo ("\\"); // levél neve
echo (base64_encode($m['subject']));
echo ("\\"); // levél tárgya
echo (base64_encode(preg_replace("#$https\://+[a-z0-9\./\-_%]+/images/$mid/#i", '{ELERES}/', $m['text'])));
echo ("\\"); // üzenet szövege
//echo(base64_encode(str_replace("images/$mid/", "images/{MID}/",$m['text'])));echo("\\"); // üzenet szövege
echo (base64_encode($m['date']));
echo ("\\"); // létrehozás dátuma
if (is_dir("files/images/$mid/")) {
$kvt = opendir("files/images/$mid/");
while (gettype($fajl = readdir($kvt)) != 'boolean') {
if ((is_file("files/images/$mid/$fajl")) && ($fajl != "..") && ($fajl != ".")) {
echo (base64_encode($fajl));
echo "|";
$handle = fopen("files/images/$mid/$fajl", "r");
$contents = fread($handle, filesize("files/images/$mid/$fajl"));
fclose($handle);
echo (base64_encode($contents));
echo ("\\");
}
}
}
}
exit;
}
//function saveWGMxml($html, $head, $style_data, $content_data, $name, $subject, $template_name) {
function saveWGMxml($message) {
include_once('class.ExSimpleXMLElement.php');
$file_name = trim(htmlentities($this->dash($message['name'])));
$dom = new domDocument;
$dom->loadHTML($message['text']);
$dom->preserveWhiteSpace = false;
$images = $dom->getElementsByTagName('img');
$template = new ExSimpleXMLElement('');
$template->addChild('version', '@WGX_template 0.1');
$data = $template->addChild('data');
$data->addChild('name', $message['name']);
$data->addChild('template_name', $message['template_name']);
$data->addChild('subject', $message['subject']);
$data->addChild('extract', $message['extract']);
$data->addChild('date', $message['date']);
$imgs = $template->addChild('images');
$i = 1;
foreach ($images as $image) {
$img_url = $image->getAttribute('src');
$imagetype = @exif_imagetype($img_url);
$file_info = pathinfo($img_url);
$image_name = basename($img_url);
if($imagetype == 1)
$image_name = $file_info['filename'].'.gif';
elseif($imagetype == 2)
$image_name = $file_info['filename'].'.jpg';
elseif($imagetype == 3)
$image_name = $file_info['filename'].'.png';
else
continue;
$file = file_get_contents($img_url);
// a 600px-nél szélesebb képek átméretezése 600px szélesre
$source = imagecreatefromstring($file);
$width = imagesx($source);
$height = imagesy($source);
$newwidth = 600;
if($width > $newwidth) {
$rate = 600 / $width;
$newheight = $height * $rate;
$thumb = imagecreatetruecolor($newwidth, $newheight);
// Resize
//imagecopyresized($thumb, $source, 0, 0, 0, 0, $newwidth, $newheight, $width, $height);
imagecopyresampled($thumb, $source, 0, 0, 0, 0,$newwidth, $newheight, $width, $height);
ob_start();
if($imagetype == 1)
imagegif($thumb);
elseif($imagetype == 2)
imagejpeg($thumb);
elseif($imagetype == 3)
imagepng($thumb);
$imgout = ob_get_contents();
ob_end_clean();
imagedestroy($thumb);
} else {
$imgout = $file;
}
$img = $imgs->addChild('image_'.$i);
//$img->addAttribute('id', $i);
$img->addChild('placeholder', 'image_'.$i);
$img->addChild('name', $image_name);
$img->addChild('file', base64_encode($imgout));
$img_url = str_replace('&', '&', $img_url);
$html = str_replace($img_url, '{image_'.$i.'}', $html);
$i++;
}
$data->addChildCData('head', '');//addChildCData('html', $message['text']);//addChild('editor');
/*
$style = $editor->addChild('style');
foreach($style_data as $key => $val) {
$$key = $style->addChild($key);// $val2) {
$$key->addChildCData($key2, $val2);//addChild('content');
$message['template_params'] = json_decode($message['template_params'], 1);
$template_params_css = explode('files/', $message['template_params']['css'][0]);
$message['template_params']['css'][0] = $template_params_css[1];
$content->addChildCData('template_params', json_encode($message['template_params']));
$dom = dom_import_simplexml($template)->ownerDocument;
$dom->formatOutput = true;
$xml = $dom->saveXML();
//_print_r(htmlspecialchars($xml));return;
//return '@WGMX '.base64_encode($xml);
header("Content-Type: application/WGX");
header("Content-Disposition: attachment; filename=\"".$file_name.".wgx\"");
header("Cache-Control: cache, must-revalidate");
header("Pragma: cache");
header("Connection: close");
echo $out = '@WGMX '.base64_encode($xml);
exit;
/**/
}
function decode_sc($a1)
{
$a1 = str_replace(chr(245), chr(197) . chr(145), $a1); //Å
$a1 = str_replace(chr(250), chr(195) . chr(186), $a1); //ú
$a1 = str_replace(chr(251), chr(197) . chr(177), $a1); //ű
$a1 = str_replace(chr(252), chr(195) . chr(188), $a1); //ü
$a1 = str_replace(chr(243), chr(195) . chr(179), $a1); //ó
$a1 = str_replace(chr(237), chr(195) . chr(173), $a1); //Ã
$a1 = str_replace(chr(233), chr(195) . chr(169), $a1); //é
$a1 = str_replace(chr(225), chr(195) . chr(161), $a1); //á
$a1 = str_replace(chr(246), chr(195) . chr(182), $a1); //ö
$a1 = str_replace(chr(213), chr(197) . chr(144), $a1); //Å
$a1 = str_replace(chr(218), chr(195) . chr(154), $a1); //Ã
$a1 = str_replace(chr(219), chr(197) . chr(176), $a1); //Å°
$a1 = str_replace(chr(220), chr(195) . chr(156), $a1); //Ã
$a1 = str_replace(chr(211), chr(195) . chr(147), $a1); //Ã
$a1 = str_replace(chr(205), chr(195) . chr(141), $a1); //Ã
$a1 = str_replace(chr(201), chr(195) . chr(137), $a1); //Ã
$a1 = str_replace(chr(193), chr(195) . chr(129), $a1); //Ã
$a1 = str_replace(chr(214), chr(195) . chr(150), $a1); //Ã
return $a1;
}
function XMLToArray($xml)
{
if ($xml instanceof SimpleXMLElement) {
$children = $xml->children();
$return = null;
}
foreach ($children as $element => $value) {
if ($value instanceof SimpleXMLElement) {
$values = (array)$value->children();
if (count($values) > 0) {
$return[$element] = $this->XMLToArray($value);
} else {
if (!isset($return[$element])) {
$return[$element] = (string)$value;
} else {
if (!is_array($return[$element])) {
$return[$element] = array($return[$element], (string)$value);
} else {
$return[$element][] = (string)$value;
}
}
}
}
}
if (is_array($return)) {
return $return;
} else {
return false;
}
}
function message_dump($file, $g)
{
global $out, $filesdir;
if (!isset($filesdir)) $filesdir = WG_PATH.'files/';
if (is_uploaded_file($_FILES[$file]['tmp_name'])) {
if (pathinfo($_FILES[$file]['name'], PATHINFO_EXTENSION) == 'wgx') {
// wgx fájl
$wgx = file_get_contents($_FILES[$file]["tmp_name"]);
if (substr($wgx, 0, 6) != '@WGMX ')
return false;
$wgm_xml = base64_decode(str_replace('@WGMX ', '', $wgx));
$xml = new SimpleXMLElement($wgm_xml);
$wgx_array = $this->XMLToArray($xml);
$chd = $this->conf_read("chmod_dir");
$chf = $this->conf_read("chmod_file");
$id = $this->a_i("".DB_PREFIX."messages");
$code = $this->generateCode(38);
if ($this->conf_read("https") == 1) $https = 'https://';
else $https = 'http://';
// létrehozzuk a képek mappáját
$url = $https . $_SERVER['HTTP_HOST'] . '/' . $this->conf_read("wg_dir") . 'files/images/' . $id . '/';
$dir = WG_PATH.'files/images/' . $id . '/';
if (!is_dir($dir))
mkdir($dir);
if ($chd > 100 && $chd <= 777)
chmod($dir, '0' . (int)($chd));
// helyre rekjuk a képeket a html-ben és a mappákban
foreach ($wgx_array['images'] as $key => $val) {
if(basename($val['name']) !== $val['name'])
die('Image name error!');
$image_url = $url . $val['name'];
$image_path = $dir . $val['name'];
$placeholder = '{' . $val['placeholder'] . '}';
$wgx_array['data']['html'] = str_replace($placeholder, $image_url, $wgx_array['data']['html']);
if (!file_exists($image_path)) {
$val['file'] = base64_decode($val['file']);
// ellenÅrzés
$verifyimg = getimagesizefromstring($val['file']);
/* Make sure the MIME type is an image */
$pattern = "#^(image/)[^\s\n<]+$#i";
// ha nem kép, hibával eldobjuk a feladatot
if(!preg_match($pattern, $verifyimg['mime'])) {
die("Only image files are allowed!");
}
$handle = fopen($image_path, 'w');
fwrite($handle, $val['file']);
fclose($handle);
}
if ($chf > 100 && $chf <= 777)
chmod($image_path, '0' . (int)($chf));
}
if($wgx_array['data']['template_name']) {
$template_params = json_decode($wgx_array['editor']['content']['template_params'], 1);
$template_params['css'][0] = WG_URL.'files/'.$template_params['css'][0];
$template_params = json_encode($template_params);
} else {
$template_params = '';
}
$this->mq("insert into `".DB_PREFIX."messages` set `name` = '" . mysql_real_escape_string($wgx_array['data']['name']) . "',
`subject` = '" . mysql_real_escape_string($wgx_array['data']['subject']) . "',
`text` = '" . mysql_real_escape_string($wgx_array['data']['html']) . "',
`extract` = '" . mysql_real_escape_string($wgx_array['data']['extract']) . "',
`template_name` = '" . mysql_real_escape_string($wgx_array['data']['template_name']) . "',
`template_params` = '" . mysql_real_escape_string($template_params) . "',
`tiny_head` = '" . mysql_real_escape_string($wgx_array['data']['head']) . "',
`date` = CURDATE(),
`g` = '$g',
`code` = '$code'");
$out = __('Sikeres sablon feltöltés');
} else {
$dir_s = $this->conf_read("wg_dir");
move_uploaded_file($_FILES[$file]['tmp_name'], WG_PATH . 'files/message.wgm');
$chf = $this->conf_read("chmod_file");
if ($chf > 100 && $chf <= 777) {
$e = "chmod('{$filesdir}files/message.wgm', 0" . (int)($chf) . ");";
eval($e);
}
if (@is_file(WG_PATH . 'files/message.wgm')) {
$handle = @fopen(WG_PATH . 'files/message.wgm', "r");
$contents = @fread($handle, @filesize(WG_PATH . 'files/message.wgm'));
@fclose($handle);
if (!$contents) {
$out = 'Hibás fájl!';
@unlink(WG_PATH . 'files/message.wgm');
return false;
}
$t = explode("\\", $contents);
if ($t[0] != base64_encode("WEBGALAMB2 MESSAGE FILE")) {
$out = __('Hibás fájl!');
@unlink(WG_PATH.'files/message.wgm');
return false;
}
$id = $this->a_i("".DB_PREFIX."messages");
$code = $this->generateCode(38);
$this->mq("insert into `".DB_PREFIX."messages` (text, name, subject,g,`date`, `code`) values ('" .
mysql_real_escape_string(str_replace("{ELERES}/", "http://" . $_SERVER['HTTP_HOST'] . '/' . $dir_s . "files/images/$id/", $this->decode_sc(base64_decode($t[3])))) .
"', '" . mysql_real_escape_string($this->decode_sc(base64_decode($t[1]))) . "', '" . mysql_real_escape_string($this->decode_sc(base64_decode($t[2]))) . "','$g', CURDATE(), '$code')");
@mkdir($filesdir . "files/images/$id");
$chd = $this->conf_read("chmod_dir");
if ($chd > 100 && $chd <= 777) {
$e = "chmod('".WG_PATH."files/images/$id/', 0" . (int)($chd) . ");";
eval($e);
}
reset($t);
$x = count($t) - 1;
for ($i = 5; $i < $x; $i++) {
$t2 = explode('|', $t[$i]);
$file = "{$filesdir}files/images/$id/" . base64_decode($t2[0]);
if (!file_exists($file)) {
//@touch ($file);
$handle = fopen($file, 'w');
fwrite($handle, base64_decode($t2[1]));
fclose($handle);
if ($chf > 100 && $chf <= 777) {
$e = "chmod('$file', 0" . (int)($chf) . ");";
eval($e);
}
}
}
@unlink(WG_PATH."files/message.wgm");
} else $out = __('Fájl feltöltés sikertelen!');
}
} else $out = __('Fájl feltöltés sikertelen!');
return $out;
}
function var_create()
{
global $_POST;
$num_para = func_num_args();
$num_para = $num_para - 2;
$v = func_get_arg(0);
for ($i = 1; $i <= $num_para + 1; $i++) {
$nev = func_get_arg($i);//echo $nev. " ";
if ($v == 'post') {
if (is_array($nev)) {
if (!isset($_POST[$nev[0]])) $_POST[$nev[0]] = $nev[1];
} else {
if (!isset($_POST[$nev])) $_POST[$nev] = '';
}
} elseif ($v[0] == 's') {
global $s;
if (is_array($nev)) {
if (!isset($$v2[$nev[0]])) $$v2[$nev[0]] = $nev[1];
} else {
if (!isset($s[$nev])) $s[$nev] = '';
}
} else {
if (is_array($nev)) {
if (!isset($$nev[0])) $$nev[0] = $nev[1];
} else {
if (!isset($$nev)) $$nev = '';
}
}
}
}
function location($loc){
?>
$s) $error .= "\r\n* " . func_get_arg(($i * 4) + 1);
if ($m2[0] == '>') if ($ertek == '' || strlen($ertek) < $s) $error .= "\r\n* " . func_get_arg(($i * 4) + 1);
if ($m2[0] == '=') if ($ertek == '' || strlen($ertek) == $s) $error .= "\r\n* " . func_get_arg(($i * 4) + 1);
}
}
if ($muv == '#m') if (!$this->isValidEmail($ertek)) $error .= "\r\n* " . func_get_arg(($i * 4) + 1);
if ($muv == 'm') if ((!$this->isValidEmail($ertek)) && $ertek) $error .= "\r\n* " . func_get_arg(($i * 4) + 1);
if ($muv == '#e') if (!preg_match($m2, $ertek)) $error .= "\r\n* " . func_get_arg(($i * 4) + 1);
if ($muv == 'e') if (!preg_match($m2, $ertek) && $ertek) $error .= "\r\n* " . func_get_arg(($i * 4) + 1);
if ($muv == 's') if ($ertek == '') $error .= "\r\n* " . func_get_arg(($i * 4) + 1);
if ($muv[0] == '=') // pl. jelszóellenörzés
{
$n = strlen($muv);
$s = substr($muv, 1, $n - 1);
$ert2 = ($v == 'post') ? $_POST["$s"] : $_GET["$s"];
if ($m2) {
if ($ertek != $ert2 || strlen($ertek) < $m2) $error .= "\r\n* " . func_get_arg(($i * 4) + 1);
} else {
if ($ertek != $ert2) $error .= "\r\n* " . func_get_arg(($i * 4) + 1);
}
}
if ($muv == 'n') //ha szám, de nem kötelezo megadni
{
if (!$m2) {
if ($ertek != '' && !preg_match("/^([(0-9]+)?$/", $ertek)) $error .= "\r\n* " . func_get_arg(($i * 4) + 1);
} else
if ($ertek) {
$q = strpos($m2, '-');
$a = substr($m2, 0, $q);
$b = substr($m2, $q + 1, strlen($m2) - $q);
if (!preg_match("/^([(0-9]+)?$/", $ertek) || $ertek < $a || $ertek > $b) $error .= "\r\n* " . func_get_arg(($i * 4) + 1);
}
}
if (($muv == 'd' && $ertek) || ($muv == '#d')) // dátum ellenörzés
{
$_POST["$nev"] = str_replace(array('/', '.'), array('-', '-'), $_POST["$nev"]);
if (preg_match('/^([0-9]{4})-*([0-9]{2})-*([0-9]{2})$/', $ertek, $x)) {
$d = date("Y-m-d");
if (!($x[1] > 2100 || $x[2] > 12 || $x[3] > 31)) {
if (($m2 && $m2 == '<') && ($d < $ertek)) $error .= "\r\n* " . func_get_arg(($i * 4) + 1);
if (($m2 && $m2 == '>') && ($d > $ertek)) $error .= "\r\n* " . func_get_arg(($i * 4) + 1);
if (($m2 && $m2 == '<=') && ($d <= $ertek)) $error .= "\r\n* " . func_get_arg(($i * 4) + 1);
if (($m2 && $m2 == '>=') && ($d >= $ertek)) $error .= "\r\n* " . func_get_arg(($i * 4) + 1);
} else {
$error .= "\r\n* " . func_get_arg(($i * 4) + 1);
}
} else $error .= "\r\n* " . func_get_arg(($i * 4) + 1);
}
if (($muv == 'ip' && $ertek) || ($muv == '#ip')) // dátum ellenörzés
{
$rIp = explode('.', $ertek);
if (count($rIp) == 4) {
foreach ($rIp as $p) {
if ($p > 255 || !preg_match("/^([(0-9]+)?$/", $p)) {
$error .= "\r\n* " . func_get_arg(($i * 4) + 1);
break;
}
}
} else $error .= "\r\n* " . func_get_arg(($i * 4) + 1);
} // ip cÃm ellenörzés
if ($muv == '#n') // ha szám és kötelezo megadni
{
if (!$m2) {
if ($ertek == '' || !preg_match("/^([(0-9]+)?$/", $ertek)) $error .= "\r\n* " . func_get_arg(($i * 4) + 1);
} else {
$q = strpos($m2, '-');
$a = substr($m2, 0, $q);
$b = substr($m2, $q + 1, strlen($m2) - $q);
if (!preg_match("/^([(0-9]+)?$/", $ertek) || $ertek < $a || $ertek > $b) $error .= "\r\n* " . func_get_arg(($i * 4) + 1);
}
}
} // ha php hibaellenorzés vót. ha nem akkor javascript tehát
else { // ha js ellenorzes 'torzs','#q','1'
if ($muv == 'm') $error .= "\r\n '$nev','$m2" . "S','2','" . func_get_arg(($i * 4) + 1) . "',";
if ($muv == 's') $error .= "\r\n '$nev','#q','1','" . func_get_arg(($i * 4) + 1) . "',";
if ($muv == '#' && $m2 == '') $error .= "\r\n '$nev','#q','0','" . func_get_arg(($i * 4) + 1) . "',";
if ($muv == '#' && $m2) $error .= "\r\n '$nev','$m2','1','" . func_get_arg(($i * 4) + 1) . "',";
if ($muv == '#n') {
$m2 = str_replace("-", "_", $m2);
$error .= "\r\n '$nev','#$m2','1','" . func_get_arg(($i * 4) + 1) . "',";
}
if ($muv == 'n') {
$m2 = str_replace("-", "_", $m2);
$error .= "\r\n '$nev','$m2','1','" . func_get_arg(($i * 4) + 1) . "',";
}
if ($muv[0] == '=') {
$n = strlen($muv);
$s = substr($muv, 1, $n - 1);
$error .= "\r\n '$nev','#$s','6','" . func_get_arg(($i * 4) + 1) . "',";
}
} // js elllenörzés
}
if ($error && $t != 'php') {
$error[strlen($error) - 1] = ')';
$error .= ';return document.MM_returnValue';
}
return $error;
}
function mail_id($mail)
{
$x = $this->m_array("SELECT mail_id FROM `".DB_PREFIX."users` where mail = '$mail' limit 0, 1", 'mail_id');
$x = $x ? $x : ($this->m_array("SELECT mail_id FROM `".DB_PREFIX."users` order by mail_id desc limit 0, 1", 'mail_id') + 1);
return $x;
}
function user_data($uid)
{
$s = $this->m_array("select * from `".DB_PREFIX."users` where id='$uid'");
$_g = $this->m_array("select * from `".DB_PREFIX."groups` where id='$s[g]'");
$x = $this->mq("Select * from `".DB_PREFIX."fields` where g='$s[g]'");
while ($y = mysql_fetch_assoc($x)) {
if ($_g['email2_field'] == $y['id'] || $_g['email_field'] == $y['id']) continue;
//if( //6:szám //5:dátum
$v = $this->m_array("select * from `".DB_PREFIX."fields_data` where un='$s[id]' and did='$y[id]'", ($y['type'] == 2 || $y['type'] == 4 || $y['type'] == 6) ? 'int_text' : (($y['type'] == 5) ? 'date' : 'text'));
if ($y['type'] < 2) $s[$y['name']] = $v;
elseif ($y['type'] > 4) $s[$y['name']] = $v;
elseif (!strstr($v, ';')) $s[$y['name']] = $this->m_array("select * from `".DB_PREFIX."fields_fields` where id='$v'", 'name');
else {
$array = explode(';', $v);
$s[$y['name']] = array();
foreach ($array as $vv) $s[$y['name']][] = $this->m_array("select * from `".DB_PREFIX."fields_fields` where id='$vv'", 'name');
}
}
return $s;
}
function writeStatusLog($id, $method, $status, $new = false)
{
$result = $this->m_array("select status_log, active from `".DB_PREFIX."users` where id='$id'");
$data = (array)json_decode($result['status_log'], true);
// ha ugyanaz a státusz akkor nem Ãrjuk be (pl csoportos aktiválásnál amikor eleve aktÃv a feliratkozó)
$end = end($data);
if ($end['status'] == $status)
return;
// ha nincs korábbi naplóbejegyzés akkor beÃrjuk ismeretlenként a korábbi státuszt az elsÅ helyre
// (a feliratkozó régebben jött mint a funkció bekerült a Webgalambba)
if (empty($result['status_log']) && $new == false) {
$data[] = array('date' => 'unknown', 'method' => 'unknown', 'status' => $result['active']);
}
$data[] = array('date' => date('Y-m-d H:i:s'), 'method' => $method, 'status' => $status);
$status_log = json_encode($data);
$this->mq("UPDATE `".DB_PREFIX."users` set status_log='{$status_log}' where id='$id'");
}
function writeModLog($id) {
$result = $this->m_array("select mod_log, mail from `".DB_PREFIX."users` where id='$id'");
$data = (array)json_decode($result['mod_log'], true);
$data[] = array('date'=>date('Y-m-d H:i:s'), 'email'=>$result['mail'], 'ip'=>$this->getip());
$mod_log = json_encode($data);
$this->mq("UPDATE `".DB_PREFIX."users` set mod_log='{$mod_log}' where id='$id'");
}
function unsubscribedDataBackup($subscriber_id) {
$user_data = $this->user_data($subscriber_id);
$meta_data = json_encode(
array('ipdatum'=>$user_data['ipdatum'],
'ip_orig'=>$user_data['ip_orig'],
'nmail'=>$user_data['nmail'],
'omail'=>$user_data['omail'],
'ip'=>$user_data['ip'],
'datum'=>$user_data['datum'],
'mdatum'=>$user_data['mdatum']
), JSON_UNESCAPED_UNICODE
);
$mail = $user_data['mail'];
$group_name = $this->m_array("select name from `".DB_PREFIX."groups` where id='$user_data[g]'", 'name');
$status_log = $user_data['status_log'];
// kitöröljük a tömbbÅl a nem feliratkozási mezÅbÅl érkezÅ adatokat
$sql = $this->mq("SHOW COLUMNS FROM `".DB_PREFIX."users`");
while($data = mysql_fetch_assoc($sql))
unset($user_data[$data['Field']]);
// átalakÃtjuk a sortöréseket mert a JSON Ãgy szeresse :)
foreach($user_data as $key => $value) {
$user_data[$key] = str_replace(array("\r\n", "\n", "\r", PHP_EOL), '
', $value);
}
$data = json_encode($user_data, JSON_UNESCAPED_UNICODE);
$this->mq("insert into `".DB_PREFIX."unsubscribed`
(`orig_id`, `mail`, `data`, `meta_data`, `group_id`, `group_name`, `status_log`, `record_time`)
values
('".$subscriber_id."', '".$mail."', '".$data."', '".$meta_data."', '".$user_data['g']."', '".$group_name."', '".$status_log."', CURRENT_TIMESTAMP)");
}
function new_user($array, $g = 0, $method = 'unkown')
{
if (!$g) return false;
$g_a = $this->m_array("select * from `".DB_PREFIX."groups` where id='$g'"); // megnézzüök létezik e a csoport
if ($g_a) {
if ($g_a['d_user'] || !$this->m_array("select * from `".DB_PREFIX."users` where mail='$array[mail]' and g='$g'")) // ha nincs benne a csoportba vagy lehet többször benne
{
$v_C = $this->generateCode(40);
if (!$array['mail_id']) $array['mail_id'] = $this->mail_id($array['mail']);
$this->mq("insert into `".DB_PREFIX."users` ( mail, mail_id, ip, ip_orig, datum, verify_code, active, g, ipdatum) values
( '$array[mail]', '$array[mail_id]', '" . $this->getip() . "', '".$this->getip()."', CURDATE(), '$v_C', $array[active], '$g', '$array[ipdatum]')");
$id = mysql_insert_id();
$this->writeStatusLog($id, $method, $array['active']);
if ($this->m_array("select * from `".DB_PREFIX."sub_stat` where date=CURDATE() and g=$g"))
$this->mq("update `".DB_PREFIX."sub_stat` set c=c+1 where date=CURDATE() and g=$g");
else
$this->mq("insert into `".DB_PREFIX."sub_stat` (date, g, c) values (CURDATE(), '$g', 1)");
$this->mq("update `".DB_PREFIX."groups` set stat_auto=stat_auto+1 where id='$g'");
reset($array);
$i = 0;
foreach ($array as $k => $v) {
$i++;
if ($i < 10) continue;
$mezo = $this->m_array("select * from `".DB_PREFIX."fields` where g='$g' and name='$k'");
if ($mezo) // létezik a mezŠhozzáadjuk.
{
if ($mezo['type'] < 2) {
if (is_array($v)) $v = implode(';', $v);
$this->mq("insert into `".DB_PREFIX."fields_data` (un, text, did) values ('$id', '" . mysql_real_escape_string($v) . "', '$mezo[id]')");
} elseif ($mezo['type'] == 5) // csak dátum
{
if ($v || $v === 0) $this->mq("insert into `".DB_PREFIX."fields_data` (un, date, did) values ('$id', '" . mysql_real_escape_string($v) . "', '$mezo[id]')");
} elseif ($mezo['type'] == 6) // csak szám
{
if ($v) $this->mq("insert into `".DB_PREFIX."fields_data` (un, int_text, did) values ('$id', '" . ($v) . "', '$mezo[id]')");
} elseif ($mezo['type'] == 2 || $mezo['type'] == 4) {
if (!is_array($v)) {
$mezo_x = $this->m_array("select * from `".DB_PREFIX."fields_fields` where field_id='$mezo[id]' and name='$v'");
if ($mezo_x) $this->mq("insert into `".DB_PREFIX."fields_data` (un, int_text, did) values ('$id', '$mezo_x[id]', '$mezo[id]')");
} else {
foreach ($v as $v2) {
$mezo_x = $this->m_array("select * from `".DB_PREFIX."fields_fields` where field_id='$mezo[id]' and name='$v2'");
if ($mezo_x) $data = $mezo_x['id'];
break;
}
if ($data) $this->mq("insert into `".DB_PREFIX."fields_data` (un, int_text, did) values ('$id', '$data', '$mezo[id]')");
} // ha tömb
} // rádió - select
//chx
elseif ($mezo['type'] == 3) {
$data = '';
if (is_array($v)) {
foreach ($v as $v2) {
$mezo_x = $this->m_array("select * from `".DB_PREFIX."fields_fields` where field_id='$mezo[id]' and name='$v2'");
if ($mezo_x) $data .= $mezo_x['id'] . ';';
}
if ($data) $this->mq("insert into `".DB_PREFIX."fields_data` (un, text, did) values ('$id', '$data', '$mezo[id]')");
} // ha tömb
else // ha nem tömb
{
$mezo_x = $this->m_array("select * from `".DB_PREFIX."fields_fields` where field_id='$mezo[id]' and name='$v'");
if ($mezo_x) $this->mq("insert into `".DB_PREFIX."fields_data` (un, text, did) values ('$id', '$mezo_x[id]', '$mezo[id]')");
}
} // cx
} // létezÅ mezÅ
}
} // if
} else return false; // if
}
//csak csoport adatokat másol
function group_copy($name, $gid)
{
$s = $this->m_array("Select * from `".DB_PREFIX."groups` where id='$gid'");
while ($this->m_array("select count(id) as db from `".DB_PREFIX."groups` where code='" . ($code = $this->generateCode(6)) . "'", 'db'));
$this->mq("insert into `".DB_PREFIX."groups` (
name, sender_name, sender_mail, h1,h2,h3,h4,h5,h6,h7, h1_text,h2_text,h3_text,h4_text,h5_text,h6_text,h7_text,
d_user, admin_mail,
a_up, a_down, auto_sc, auto_del, active, date, scr_inactivate,
inact, a_mod, op_s_d, uns_d, email_d, code) VALUES (
'$name', '$s[sender_name]', '$s[sender_mail]', '$s[h1]','$s[h2]','$s[h3]','$s[h4]','$s[h5]','$s[h6]','$s[h7]',
'$s[h1_text]','$s[h2_text]','$s[h3_text]','$s[h4_text]','$s[h5_text]','$s[h6_text]','$s[h7_text]',
'$s[d_user]', '$s[admin_mail]',
'0', '0', '', '', '$s[active]', CURDATE(), '$s[scr_inactivate]',
'$s[inact]', '$s[a_mod]', '$s[op_s_d]', '$s[uns_d]', '$s[email_d]', '$code')");
$id = mysql_insert_id();
$this->mq("update `".DB_PREFIX."groups` set
stext = '" . __('Mintaszöveg a form elÅtt
{form}
Mintaszöveg a form után') . "',
form_border = 'eeeeee',
form_text ='333333',
form_back ='cccccc',
form_button_back ='ff8500',
form_button_border = '888888',
form_button_text = '000000',
form_button_text_value = '" . __("Feliratkozás") . "',
form_title = '" . __('Feliratkozó űrlap') . "' where id = '$id'");
// $this->mq("insert into `".DB_PREFIX."fields` (name, g, hidden) values ('$Referer_nev', '$id', '1')");
//feliratkozási mezÅk másolása
$sql = $this->mq("select * from `".DB_PREFIX."fields` where g='$gid' order by hely");
while ($sx = mysql_fetch_assoc($sql)) {
$idx = $this->a_i("".DB_PREFIX."fields");
if ($sx['hely']) $this->mq("insert into `".DB_PREFIX."fields` (g, `name`, `check`, `hidden`, `type`, hely, `id`) values ('$id', '$sx[name]', '$sx[check]', '$sx[hidden]', '$sx[type]', '$idx', '$idx')");
else $this->mq("insert into `".DB_PREFIX."fields` (g, `name`, `check`, `hidden`, `type`, hely, `id`) values ('$id', '$sx[name]', '$sx[check]', '$sx[hidden]', '$sx[type]', '0', '$idx')");
if ($sx['id'] == $s['email_field']) $this->mq("update `".DB_PREFIX."groups` set email_field='$idx' where id=$id");
if ($sx['id'] == $s['email2_field']) $this->mq("update `".DB_PREFIX."groups` set email2_field='$idx' where id=$id");
$sql2 = $this->mq("select * from `".DB_PREFIX."fields_fields` where field_id='$sx[id]' order by hely");
while ($sx2 = mysql_fetch_assoc($sql2)) {
$idx_2 = $this->a_i("".DB_PREFIX."fields_fields");
$this->mq("insert into `".DB_PREFIX."fields_fields` (field_id, name, hely, id) values ('$idx', '$sx2[name]', '$idx_2', '$idx_2')");
}
}
return $id;
}
function user_copy($uid, $gs)
{
$user_array = $this->user_data($uid);
$a = @explode(';', $gs);
if ($a) foreach ($a as $_id) {
$g_a = $this->m_array("select id from `".DB_PREFIX."groups` where id='$_id'"); // megnézzüök létezik e a csoport
if ($g_a) {
$this->new_user($user_array, $_id, 'user_copy');
}
}
}
function user_inact($mail, $gs, $method = 'unknown')
{
$a = @explode(';', $gs);
if ($a) foreach ($a as $_id) {
$g_a = $this->m_array("select * from `".DB_PREFIX."groups` where id='$_id'"); // megnézzüök létezik e a csoport
if ($g_a) {
$y = $this->mq("update `".DB_PREFIX."users` set active=0 where g='$_id' and mail='$mail'");
$result = $this->mq("select id from `".DB_PREFIX."users` where g='$_id' and mail='$mail'");
while ($user = mysql_fetch_assoc($result)) {
$this->writeStatusLog($user['id'], $method, '0');
}
}
}
}
function user_delete($mail, $gs, $notify=true)
{
$a = @explode(';', $gs);
if ($a) foreach ($a as $_id) {
$g_a = $this->m_array("select * from `".DB_PREFIX."groups` where id='$_id'"); // megnézzüök létezik e a csoport
if ($g_a) {
$y = $this->mq("select * from `".DB_PREFIX."users` where g='$_id' and mail='$mail'");
while ($z = mysql_fetch_array($y)) {
$this->mq("delete from `".DB_PREFIX."users` where id='$z[id]'");
// $this->mq("delete from `".DB_PREFIX."stat` where uid='$z[id]'"); // statisztikából megfello sorok kitörlés
// $this->mq("delete from `".DB_PREFIX."act_stat` where uid='$z[id]'");
$this->mq("delete from `".DB_PREFIX."fields_data` where un='$z[id]'");
$this->mq("update `".DB_PREFIX."groups` set stat_autodel=stat_autodel+1 where id='$_id'");
$this->mq("insert into `".DB_PREFIX."unscr` (date, g, mid) values (CURDATE(), '$_id', '0')");
}
if($notify)
addNotify('Leiratkozás', 'Az alábbi csoportból leiratkozás történt:'.PHP_EOL.$g_a['name'], 'g_admin=1&g='.$g_a['id']);
}
}
}
function deleteSubscriber($id)
{
$group = $this->m_array("select g from `".DB_PREFIX."users` where id='$id'");
// feliratkozó adatainak törlése
$this->mq("delete from `".DB_PREFIX."users` where id='{$id}'");
$this->mq("delete from `".DB_PREFIX."fields_data` where un='{$id}'");
// statisztikai adatok rögzÃtése
$this->mq("update `".DB_PREFIX."groups` set stat_autodel=stat_autodel+1 where id='{$group['g']}'");
$this->mq("insert into `".DB_PREFIX."unscr` (date, g, mid) values (CURDATE(), '{$group['g']}', '0')");
}
function getip()
{
if (isset($_SERVER)) {
if (isset($_SERVER["HTTP_X_FORWARDED_FOR"])) {
preg_match("/\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}/", $_SERVER["HTTP_X_FORWARDED_FOR"], $matches);
$realip = $matches[0];
} elseif (isset($_SERVER["HTTP_CLIENT_IP"])) {
$realip = $_SERVER["HTTP_CLIENT_IP"];
} else {
$realip = $_SERVER["REMOTE_ADDR"];
}
} else {
if (getenv('HTTP_X_FORWARDED_FOR')) {
$realip = getenv('HTTP_X_FORWARDED_FOR');
} elseif (getenv('HTTP_CLIENT_IP')) {
$realip = getenv('HTTP_CLIENT_IP');
} else {
$realip = getenv('REMOTE_ADDR');
}
}
if(filter_var($realip, FILTER_VALIDATE_IP))
return $realip;
else
return "Unknown";
return mysql_real_escape_string($realip);
}
function limit($num_s = 0, $strn = '')
{
$s = $tu = $tu2 = '';
global $_SERVER, $querysql, $max, $_GET, $limited;
if (isset($_GET['pg']))
$p_g = $_GET['pg'];
else
$p_g = '';
if (!$querysql)
exit;
if (!$num_s) {
$sql = $this->mq($querysql);
$i = mysql_num_rows($sql);
} else {
$i = $num_s;
}
$num_rows = $i;
$qs = str_replace("&pg=" . $p_g, "", $_SERVER['QUERY_STRING']);
$page = (($i - ($i % $max)) / $max) + 1;
if (!($i % $max))
$page--;
$pga = $page;
$j = 0;
settype($p_g, "INT");
if ($page < $p_g)
$p_g = 1;
if ($p_g != "")
$pg = $p_g;
else $pg = "1";
$kezd = 0;
$kiirathato = 8;
if ($pg >= $kiirathato / 2)
$kezd = $pg - ($kiirathato / 2);
if ($kezd > $page - $kiirathato)
$kezd = $page - $kiirathato;
if ($kezd < 0)
$kezd = 0;
if ($page > $kiirathato)
$page = $kezd + $kiirathato;
$j = $kezd;
$last = ceil($num_rows / $max);
if ($page > 1) {
$s = '';
}
$l1 = ($pg - 1) * $max;
$querysql = $querysql . " LIMIT $l1 , $max";
return $s;
}
// egyéni részletes keresés mysql generátor
function reszletes_kereso($Keres_tomb, $kizarox = '')
{
if (!isset($_GET['g'])) $_GET['g'] = $_POST['g'];
//if (!isset($Keres_tomb['q_tp'])) $Keres_tomb['q_tp'] = '';
if (isset($Keres_tomb['q_tp']) && is_array($Keres_tomb['q_tp'])) {
$i = -1;
$qx = $q = '';
foreach ($Keres_tomb['q_tp'] as $qtp) {
$i++;
if ($Keres_tomb['mu'][$i] == 1) $muv = '=';
if ($Keres_tomb['mu'][$i] == 2) $muv = '!=';
if ($Keres_tomb['mu'][$i] == 3) $muv = '>';
if ($Keres_tomb['mu'][$i] == 4) $muv = '>=';
if ($Keres_tomb['mu'][$i] == 5) $muv = '<=';
if ($Keres_tomb['mu'][$i] == 6) $muv = '<';
if ($Keres_tomb['q_tp'][$i] == 'date') {
$qx .= "datum $muv '" . $Keres_tomb['q'][$i] . "'";
} // dátum szűrés ---
elseif ($Keres_tomb['q_tp'][$i] == 'mail') {
if ($muv == '=') $qx .= "mail like lower('" . str_replace(array('%', '*'), array('\%', '%'), $Keres_tomb['q'][$i]) . "')";
if ($muv == '!=') $qx .= "mail not like lower('" . str_replace(array('%', '*'), array('\%', '%'), $Keres_tomb['q'][$i]) . "')";
} // -emailba keresünk ---
elseif ($Keres_tomb['q_tp'][$i] == 'status') {
$a = explode(';', $Keres_tomb['qh'][$i]);
$qxx = '';
if ($a) foreach ($a as $b)
if ($b != '') $qxx .= "OR (active $muv $b) ";
$qx .= "(false $qxx )";
} // -státuszba ---
elseif ($Keres_tomb['q_tp'][$i] == 'mid' || $Keres_tomb['q_tp'][$i] == 'mid2') {
$a = explode(';', $Keres_tomb['qh'][$i]);
$qxx = '';
if ($a) foreach ($a as $b) if ($b) $qxx .= "OR (mid =$b) ";
if ($qxx) {
$qxx[0] = ' ';
$qxx[1] = ' ';
if ($muv == '=' && $Keres_tomb['q_tp'][$i] == 'mid') $qx .= "(select count(*) from ".DB_PREFIX."stat where uid=us.id and ($qxx) ) ";
if ($muv == '!=' && $Keres_tomb['q_tp'][$i] == 'mid') $qx .= "!(select count(*) from ".DB_PREFIX."stat where uid=us.id and ($qxx) ) ";
if ($muv == '=' && $Keres_tomb['q_tp'][$i] == 'mid2') $qx .= "(select count(*) from ".DB_PREFIX."stat where uid=us.id and ($qxx) and stat!='0000-00-00' ) ";
if ($muv == '!=' && $Keres_tomb['q_tp'][$i] == 'mid2') $qx .= "!(select count(*) from ".DB_PREFIX."stat where uid=us.id and ($qxx) and stat!='0000-00-00' ) ";
}
} // -levelekbe keresünk ---
elseif ($Keres_tomb['q_tp'][$i] == 'alink') {
$a = explode(';', $Keres_tomb['qh'][$i]);
$qxx = '';
if ($a) foreach ($a as $b) if ($b) $qxx .= "OR (aid =$b) ";
if ($qxx) {
$qxx[0] = ' ';
$qxx[1] = ' ';
if ($muv == '=') $qx .= "(select count(*) from ".DB_PREFIX."act_stat where uid=us.id and ($qxx) and stat!='0000-00-00') ";
if ($muv == '!=') $qx .= "(select count(*) from ".DB_PREFIX."act_stat where uid=us.id and ($qxx) and stat ='0000-00-00') ";
}
} // -akciólinkekbe keresünk ---
elseif ($Keres_tomb['q_tp'][$i] == 'afile') {
$a = explode(';', $Keres_tomb['qh'][$i]);
$qxx = '';
if ($a) foreach ($a as $b) if ($b) $qxx .= "OR (fid =$b) ";
if ($qxx) {
$qxx[0] = ' ';
$qxx[1] = ' '; //or kitörlése
if ($muv == '=') $qx .= "(select count(*) from ".DB_PREFIX."down_stat where uid=us.id and ($qxx) ) ";
if ($muv == '!=') $qx .= "!(select count(*) from ".DB_PREFIX."down_stat where uid=us.id and ($qxx) ) ";
}
} // -akciólinkekbe keresünk ---
elseif ($Keres_tomb['q_tp'][$i] == 'group') {
$a = explode(';', $Keres_tomb['qh'][$i]);
$qxx = '';
if ($a) foreach ($a as $b) if ($b) $qxx .= "OR (g=$b) ";
if ($qxx) {
$qxx[0] = ' ';
$qxx[1] = ' ';
if ($muv == '=') $qx .= " (SELECT count(id) from `".DB_PREFIX."users` where mail_id=us.mail_id and ($qxx)) ";
if ($muv == '!=') $qx .= " !(SELECT count(id) from `".DB_PREFIX."users` where (mail_id=us.mail_id and ($qxx))) ";
}
} // --- csoport szűrés ---
else // egyéb mezÅkbe keresünk
{
$sql2 = $this->mq("select * from `".DB_PREFIX."fields` where g='$_GET[g]'"); // meyik mezÅbe keresünk
$s2 = $this->m_array("select * from `".DB_PREFIX."fields` where id='" . $Keres_tomb['q_tp'][$i] . "'");
if ($s2['type'] < 2) //-- text vagy textarea
{
if ($muv == '=') {
if ($Keres_tomb['q'][$i]) $qx .= " ( select count(*) from ".DB_PREFIX."fields_data where did='$s2[id]' and un=us.id and (lower(".DB_PREFIX."fields_data.text) like lower('" . str_replace(array('%', '*'), array('\%', '%'), $Keres_tomb['q'][$i]) . "')))";
else // ha olyan mezÅben keres ami talán létre sincs hozva
$qx .= " ( ( select count(*) from ".DB_PREFIX."fields_data where did='$s2[id]' and un=us.id and (lower(".DB_PREFIX."fields_data.text) like lower('" . str_replace(array('%', '*'), array('\%', '%'), $Keres_tomb['q'][$i]) . "'))) OR !( select count(*) from ".DB_PREFIX."fields_data where (did='$s2[id]' and un=us.id )))";
} elseif ($muv == '!=') $qx .= " ( select count(*) from ".DB_PREFIX."fields_data where did='$s2[id]' and un=us.id and (lower(".DB_PREFIX."fields_data.text) not like lower('" . str_replace(array('%', '*'), array('\%', '%'), $Keres_tomb['q'][$i]) . "')))";
else $qx .= " ( select count(*) from ".DB_PREFIX."fields_data where did='$s2[id]' and un=us.id and ((".DB_PREFIX."fields_data.text) $muv ('" . str_replace(array('%', '*'), array('\%', '%'), $Keres_tomb['q'][$i]) . "')))";
$fd = ", ".DB_PREFIX."fields_data";
}
if ($s2['type'] == 6) //-- csak szám
{
$qx .= " ( select count(*) from ".DB_PREFIX."fields_data where did='$s2[id]' and un=us.id and (".DB_PREFIX."fields_data.int_text $muv '{$Keres_tomb['q'][$i]}'))";
$fd = ", ".DB_PREFIX."fields_data";
}
if ($s2['type'] == 5) //-- dátum
{
$qx .= " ( select count(*) from ".DB_PREFIX."fields_data where did='$s2[id]' and un=us.id and (".DB_PREFIX."fields_data.date $muv '{$Keres_tomb['q'][$i]}'))";
$fd = ", ".DB_PREFIX."fields_data";
}
if ($s2['type'] == 3) //checbox
{
if ($Keres_tomb['qh'][$i]) {
if (!$muv) $muv = '=';
$a = explode(';', $Keres_tomb['qh'][$i]);
$qxx = '';
if ($a) foreach ($a as $b) {
if ($muv == '=' && $b) $qxx .= "OR ((".DB_PREFIX."fields_data.text LIKE '$b;%') OR (".DB_PREFIX."fields_data.text LIKE '%;$b;%')) ";
//if($muv=='=' && $b) $qxx.="OR (".DB_PREFIX."fields_data.text LIKE '%$b;%') ";
if ($muv == '!=' && $b) $qxx .= "OR ((".DB_PREFIX."fields_data.text NOT LIKE '$b;%') AND (".DB_PREFIX."fields_data.text NOT LIKE '%;$b;%'))";
//if($muv=='!=' && $b) $qxx.="OR (".DB_PREFIX."fields_data.text NOT LIKE '%$b;%') ";
}
if ($qxx) {
$qxx[0] = ' ';
$qxx[1] = ' ';
$qx .= " ( select count(*) from ".DB_PREFIX."fields_data where did='$s2[id]' and un=us.id and ($qxx)) ";
$fd = ", ".DB_PREFIX."fields_data";
}
}
}
if ($s2['type'] == 4 || $s2['type'] == 2) //rádió - select
{
if ($Keres_tomb['qh'][$i]) {
if (!$muv) $muv = '=';
$a = explode(';', $Keres_tomb['qh'][$i]);
$qxx = '';
if ($a) foreach ($a as $b) {
if ($muv == '=' && $b) $qxx .= "OR (".DB_PREFIX."fields_data.int_text =$b) ";
if ($muv == '!=' && $b) $qxx .= "OR (".DB_PREFIX."fields_data.int_text != $b) ";
}
if ($qxx) {
$qxx[0] = ' ';
$qxx[1] = ' ';
$qx .= " ( select count(*) from ".DB_PREFIX."fields_data where did='$s2[id]' and un=us.id and ($qxx)) ";
$fd = ", ".DB_PREFIX."fields_data";
}
}
}
}
if ($qx) {
if ($i)
if ($Keres_tomb['mx'][$i - 1] == '1')
$q .= "\r\n" . ' AND ' . "\r\n$qx";
else $q .= ' OR ' . "\r\n$qx";
else $q .= "\r\n$qx";
}
$qx = '';
}
if (isset($Keres_tomb['kizaro'])) {
$kizaro = '!';
}
if ($kizarox == '!') {
$kizaro = '!';
}
if ($kizarox === 0) {
$kizaro = '';
}
if ($q) $q = " AND $kizaro($q)";
else $q = " AND FALSE ";
//$querysql="select active, mail, datum, id from `".DB_PREFIX."users` as us where $filter and g='$_GET[g]' AND ($q) order by $order";
}
if (!isset($fd)) $fd = '';
if (!isset($q)) $q = '';
return array('q' => $q, 'fd' => $fd);
}
# SQL DUMP
function sql_explode($orig)
{
$zv = 1;
$ujstring = '';
$exploded = array();
for ($i = 0; $i < strlen($orig); $i++) {
if ($orig[$i] == "'" && $orig[$i - 1] != '\\' && $zv == 1) {
$zv = 2;
} elseif ($orig[$i] == "'" && $orig[$i - 1] != '\\' && $zv == 2) {
$zv = 1;
}
if ($zv == 1 && $orig[$i] == ";") {
$zv = 1;
$exploded[] = $ujstring;
$ujstring = '';
} else
$ujstring .= $orig[$i];
}
return $exploded;
}
function convert_cp1250_to_utf8($string)
{
if (function_exists('iconv')) {
if (@iconv("CP1250", "UTF-8//TRANSLIT", 'ÃrvÃztűrÅ tükörfúrógép') != '')
return iconv("CP1250", "UTF-8//TRANSLIT", $string);
}
/* for($j=0; $j '. ord($string[$j]); echo "
"; } */
$string = str_replace(chr(81) . chr(1), "(keycode:x_431_245)", $string); // Å
$string = str_replace(chr(113) . chr(1), "(keycode:x_431_251)", $string); // ű
$string = str_replace(chr(13) . chr(1), "(keycode:x_431_232)", $string); // Ä
$string = str_replace(chr(15) . chr(1), "(keycode:x_431_239)", $string); // Ä
$string = str_replace(chr(58) . chr(1), "(keycode:x_431_229)", $string); // ĺ
$string = str_replace(chr(62) . chr(1), "(keycode:x_431_181)", $string); // ľ
$string = str_replace(chr(72) . chr(1), "(keycode:x_431_242)", $string); // Å
$string = str_replace(chr(244), "(keycode:x_431_244)", $string); // ô
$string = str_replace(chr(85) . chr(1), "(keycode:x_431_224)", $string); // Å
$string = str_replace(chr(97) . chr(1), "(keycode:x_431_185)", $string); // Å¡
$string = str_replace(chr(101) . chr(1), "(keycode:x_431_187)", $string); // ť
$string = str_replace(chr(253), "(keycode:x_431_253)", $string); // ý
$string = str_replace(chr(126) . chr(1), "(keycode:x_431_190)", $string); // ž
$string = str_replace(chr(27) . chr(1), "(keycode:x_431_236)", $string); // Ä
$string = str_replace(chr(89) . chr(1), "(keycode:x_431_248)", $string); // Å
$string = str_replace(chr(111) . chr(1), "(keycode:x_431_249)", $string); // ů
$string = str_replace(chr(80) . chr(1), "(keycode:x_431_213)", $string); // Å
$string = str_replace(chr(112) . chr(1), "(keycode:x_431_219)", $string); // Å°
$string = str_replace(chr(12) . chr(1), "(keycode:x_431_200)", $string); // Ä
$string = str_replace(chr(14) . chr(1), "(keycode:x_431_207)", $string); // Ä
$string = str_replace(chr(57) . chr(1), "(keycode:x_431_197)", $string); // Ĺ
$string = str_replace(chr(61) . chr(1), "(keycode:x_431_165)", $string); // Ľ
$string = str_replace(chr(71) . chr(1), "(keycode:x_431_210)", $string); // Å
$string = str_replace(chr(212), "(keycode:x_431_212)", $string); // Ã
$string = str_replace(chr(84) . chr(1), "(keycode:x_431_192)", $string); // Å
$string = str_replace(chr(96) . chr(1), "(keycode:x_431_169)", $string); // Å
$string = str_replace(chr(100) . chr(1), "(keycode:x_431_171)", $string); // Ť
$string = str_replace(chr(221), "(keycode:x_431_221)", $string); // Ã
$string = str_replace(chr(125) . chr(1), "(keycode:x_431_174)", $string); // Ž
$string = str_replace(chr(26) . chr(1), "(keycode:x_431_204)", $string); // Ä
$string = str_replace(chr(88) . chr(1), "(keycode:x_431_216)", $string); // Å
$string = str_replace(chr(110) . chr(1), "(keycode:x_431_217)", $string); // Å®
//$string=str_replace(chr(xxxx).chr(xxxx), "(keycode:x_431_xxxx)", $string); //
$string = str_replace(chr(245), "(keycode:x_431_245)", $string); // Å
$string = str_replace(chr(251), "(keycode:x_431_251)", $string); // ű
$string = str_replace(chr(213), "(keycode:x_431_213)", $string); // Å
$string = str_replace(chr(219), "(keycode:x_431_219)", $string); // Å°
$string = str_replace(chr(0), '', $string);
$string = str_replace('\0', '', $string);
$string = utf8_encode($string);
$string = str_replace("(keycode:x_431_245)", chr(197) . chr(145), $string); // Å
$string = str_replace("(keycode:x_431_251)", chr(197) . chr(177), $string); // ű
$string = str_replace("(keycode:x_431_232)", chr(196) . chr(141), $string); // Ä
$string = str_replace("(keycode:x_431_239)", chr(196) . chr(143), $string); // Ä
$string = str_replace("(keycode:x_431_229)", chr(196) . chr(186), $string); // ĺ
$string = str_replace("(keycode:x_431_181)", chr(196) . chr(190), $string); // ľ
$string = str_replace("(keycode:x_431_242)", chr(197) . chr(136), $string); // Å
$string = str_replace("(keycode:x_431_244)", chr(195) . chr(180), $string); // ô
$string = str_replace("(keycode:x_431_224)", chr(197) . chr(149), $string); // Å
$string = str_replace("(keycode:x_431_185)", chr(197) . chr(161), $string); // Å¡
$string = str_replace("(keycode:x_431_187)", chr(197) . chr(165), $string); // ť
$string = str_replace("(keycode:x_431_253)", chr(195) . chr(189), $string); // ý
$string = str_replace("(keycode:x_431_190)", chr(197) . chr(190), $string); // ž
$string = str_replace("(keycode:x_431_236)", chr(196) . chr(155), $string); // Ä
$string = str_replace("(keycode:x_431_248)", chr(197) . chr(153), $string); // Å
$string = str_replace("(keycode:x_431_249)", chr(197) . chr(175), $string); // ů
$string = str_replace("(keycode:x_431_213)", chr(197) . chr(144), $string); // Å
$string = str_replace("(keycode:x_431_219)", chr(197) . chr(176), $string); // Å°
$string = str_replace("(keycode:x_431_200)", chr(196) . chr(140), $string); // Ä
$string = str_replace("(keycode:x_431_207)", chr(196) . chr(142), $string); // Ä
$string = str_replace("(keycode:x_431_197)", chr(196) . chr(185), $string); // Ĺ
$string = str_replace("(keycode:x_431_165)", chr(196) . chr(189), $string); // Ľ
$string = str_replace("(keycode:x_431_210)", chr(197) . chr(135), $string); // Å
$string = str_replace("(keycode:x_431_212)", chr(195) . chr(148), $string); // Ã
$string = str_replace("(keycode:x_431_192)", chr(197) . chr(148), $string); // Å
$string = str_replace("(keycode:x_431_169)", chr(197) . chr(160), $string); // Å
$string = str_replace("(keycode:x_431_171)", chr(197) . chr(164), $string); // Ť
$string = str_replace("(keycode:x_431_221)", chr(195) . chr(157), $string); // Ã
$string = str_replace("(keycode:x_431_174)", chr(197) . chr(189), $string); // Ž
$string = str_replace("(keycode:x_431_204)", chr(196) . chr(154), $string); // Ä
$string = str_replace("(keycode:x_431_216)", chr(197) . chr(152), $string); // Å
$string = str_replace("(keycode:x_431_217)", chr(197) . chr(174), $string); // Å®
//$string=str_replace("(keycode:x_431_xxxx)", chr(xxxx).chr(xxxx), $string); //
return $string;
}
function convert_utf8_to_iso($string)
{
//return $string;
if (function_exists('iconv')) {
if (iconv("UTF-8", "CP1250//TRANSLIT", 'ÃrvÃztűrÅ tükörfúrógép') != '')
return iconv("UTF-8", "CP1250//TRANSLIT", $string);
}
$string = str_replace(chr(197) . chr(145), "(keycode:x_431_245)", $string); // Å
$string = str_replace(chr(197) . chr(177), "(keycode:x_431_251)", $string); // ű
$string = str_replace(chr(196) . chr(141), "(keycode:x_431_232)", $string); // Ä
$string = str_replace(chr(196) . chr(143), "(keycode:x_431_239)", $string); // Ä
$string = str_replace(chr(196) . chr(186), "(keycode:x_431_229)", $string); // ĺ
$string = str_replace(chr(196) . chr(190), "(keycode:x_431_181)", $string); // ľ
$string = str_replace(chr(197) . chr(136), "(keycode:x_431_242)", $string); // Å
$string = str_replace(chr(195) . chr(180), "(keycode:x_431_244)", $string); // ô
$string = str_replace(chr(197) . chr(149), "(keycode:x_431_224)", $string); // Å
$string = str_replace(chr(197) . chr(161), "(keycode:x_431_185)", $string); // Å¡
$string = str_replace(chr(197) . chr(165), "(keycode:x_431_187)", $string); // ť
$string = str_replace(chr(195) . chr(189), "(keycode:x_431_253)", $string); // ý
$string = str_replace(chr(197) . chr(190), "(keycode:x_431_190)", $string); // ž
$string = str_replace(chr(196) . chr(155), "(keycode:x_431_236)", $string); // Ä
$string = str_replace(chr(197) . chr(153), "(keycode:x_431_248)", $string); // Å
$string = str_replace(chr(197) . chr(175), "(keycode:x_431_249)", $string); // ů
$string = str_replace(chr(197) . chr(144), "(keycode:x_431_213)", $string); // Å
$string = str_replace(chr(197) . chr(176), "(keycode:x_431_219)", $string); // Å°
$string = str_replace(chr(196) . chr(140), "(keycode:x_431_200)", $string); // Ä
$string = str_replace(chr(196) . chr(142), "(keycode:x_431_207)", $string); // Ä
$string = str_replace(chr(196) . chr(185), "(keycode:x_431_197)", $string); // Ĺ
$string = str_replace(chr(196) . chr(189), "(keycode:x_431_165)", $string); // Ľ
$string = str_replace(chr(197) . chr(135), "(keycode:x_431_210)", $string); // Å
$string = str_replace(chr(195) . chr(148), "(keycode:x_431_212)", $string); // Ã
$string = str_replace(chr(197) . chr(148), "(keycode:x_431_192)", $string); // Å
$string = str_replace(chr(197) . chr(160), "(keycode:x_431_169)", $string); // Å
$string = str_replace(chr(197) . chr(164), "(keycode:x_431_171)", $string); // Ť
$string = str_replace(chr(195) . chr(157), "(keycode:x_431_221)", $string); // Ã
$string = str_replace(chr(197) . chr(189), "(keycode:x_431_174)", $string); // Ž
$string = str_replace(chr(196) . chr(154), "(keycode:x_431_204)", $string); // Ä
$string = str_replace(chr(197) . chr(152), "(keycode:x_431_216)", $string); // Å
$string = str_replace(chr(197) . chr(174), "(keycode:x_431_217)", $string); // Å®
$string = utf8_decode($string);
$string = str_replace("(keycode:x_431_245)", chr(245), $string); // Å
$string = str_replace("(keycode:x_431_251)", chr(251), $string); // ű
$string = str_replace("(keycode:x_431_232)", chr(232), $string); // Ä
$string = str_replace("(keycode:x_431_239)", chr(239), $string); // Ä
$string = str_replace("(keycode:x_431_229)", chr(229), $string); // ĺ
$string = str_replace("(keycode:x_431_181)", chr(190), $string); // ľ
$string = str_replace("(keycode:x_431_242)", chr(242), $string); // Å
$string = str_replace("(keycode:x_431_244)", chr(244), $string); // ô
$string = str_replace("(keycode:x_431_224)", chr(224), $string); // Å
$string = str_replace("(keycode:x_431_185)", chr(154), $string); // Å¡
$string = str_replace("(keycode:x_431_187)", chr(157), $string); // ť
$string = str_replace("(keycode:x_431_253)", chr(253), $string); // ý
$string = str_replace("(keycode:x_431_190)", chr(158), $string); // ž
$string = str_replace("(keycode:x_431_236)", chr(236), $string); // Ä
$string = str_replace("(keycode:x_431_248)", chr(248), $string); // Å
$string = str_replace("(keycode:x_431_249)", chr(249), $string); // ů
$string = str_replace("(keycode:x_431_213)", chr(213), $string); // Å
$string = str_replace("(keycode:x_431_219)", chr(219), $string); // Å°
$string = str_replace("(keycode:x_431_200)", chr(200), $string); // Ä
$string = str_replace("(keycode:x_431_207)", chr(207), $string); // Ä
$string = str_replace("(keycode:x_431_197)", chr(197), $string); // Ĺ
$string = str_replace("(keycode:x_431_165)", chr(188), $string); // Ľ
$string = str_replace("(keycode:x_431_210)", chr(210), $string); // Å
$string = str_replace("(keycode:x_431_212)", chr(212), $string); // Ã
$string = str_replace("(keycode:x_431_192)", chr(192), $string); // Å
$string = str_replace("(keycode:x_431_169)", chr(138), $string); // Å
$string = str_replace("(keycode:x_431_171)", chr(141), $string); // Ť
$string = str_replace("(keycode:x_431_221)", chr(221), $string); // Ã
$string = str_replace("(keycode:x_431_174)", chr(142), $string); // Ž
$string = str_replace("(keycode:x_431_204)", chr(204), $string); // Ä
$string = str_replace("(keycode:x_431_216)", chr(216), $string); // Å
$string = str_replace("(keycode:x_431_217)", chr(217), $string); // Å®
return $string;
}
function download($uri, $port = 80, $extra_headers = null)
{
if (!function_exists("stripos")) {
function stripos($str, $needle, $offset = 0)
{
return strpos(strtolower($str), strtolower($needle), $offset);
}/* endfunction stripos */
}/* endfunction exists stripos*/
if (!is_int($port)) $port = 80;
if (!is_array($extra_headers)) $extra_headers = array();
$uri = strtr(strval($uri), array("http://" => "", "https://" => "ssl://", "ssl://" => "ssl://", "\\" => "/", "//" => "/"));
if (($protocol = stripos($uri, "://")) !== false) {
if (($domain_pos = stripos($uri, "/", ($protocol + 3))) !== false) {
$domain = substr($uri, 0, $domain_pos);
$file = substr($uri, $domain_pos);
} else {
$domain = $uri;
$file = "/";
}
} else {
if (($domain_pos = stripos($uri, "/")) !== false) {
$domain = substr($uri, 0, $domain_pos);
$file = substr($uri, $domain_pos);
} else {
$domain = $uri;
$file = "/";
}
}
// echo $domain;
$fp = fsockopen($domain, $port, $errno, $errstr, 30);
if (!$fp) {
return false;
} else {
$out = "GET " . $file . " HTTP/1.1\r\n";
$out .= "Host: " . $domain . "\r\n";
foreach ($extra_headers as $nm => $vl) {
$out .= strtr(strval($nm), array("\r" => "", "\n" => "", ": " => "", ":" => "")) .
": " . strtr(strval($vl), array("\r" => "", "\n" => "", ": " => "", ":" => "")) . "\r\n";
}
$out .= "Connection: Close\r\n\r\n";
$response = "";
fwrite($fp, $out);
while (!feof($fp)) {
$response .= fgets($fp, 128);
}
fclose($fp);
global $http_response_header;
$http_response_header = array();
if (stripos($response, "\r\n\r\n") !== false) {
$response = str_replace(array("0\r\n\r\n", "00593\r\n"), '', $response);
$hc = explode("\r\n\r\n", $response);
$headers = explode("\r\n", $hc[0]);
if (!is_array($headers)) $headers = array();
foreach ($headers as $key => $header) {
$a = "";
$b = "";
if (stripos($header, ":") !== false) {
list($a, $b) = explode(":", $header);
$http_response_header[trim($a)] = trim($b);
}
}
// print_r($hc);
$ret = end($hc);
// echo "\r\nret:$ret\r\n";
return $ret;
} elseif (stripos($response, "\r\n") !== false) {
$headers = explode("\r\n", $response);
if (!is_array($headers)) $headers = array();
foreach ($headers as $key => $header) {
if ($key < (count($headers) - 1)) {
$a = "";
$b = "";
if (stripos($header, ":") !== false) {
list($a, $b) = explode(":", $header);
$http_response_header[trim($a)] = trim($b);
}
}
}
return end($headers);
} else {
return $response;
}
}
}/*endfunction download*/
function tp($tp)
{
if ($tp == 6) $tp = 'int';
elseif ($tp == 5) $tp = 'date';
elseif ($tp == 4) $tp = 'radio';
elseif ($tp == 3) $tp = 'checkbox';
elseif ($tp == 2) $tp = 'int_text';
elseif ($tp == 1) $tp = 'textarea';
else $tp = '';
return $tp;
}
function inv_tp($tp, $preg = 0)
{ // print_R( $main->inv_tp('valami mezÅ {{select}}',1)); //Array ( [tp] => 2 [str] => valami mezÅ )
//
if ($preg && preg_match('/(.*)\{\{(.*)\}\}/', $tp, $a)) {
$tp = $a[2];
} elseif ($preg) // ha nem talált emzÅrtéket, akkor 0
{
return array('tp' => 0, 'str' => $tp);
}
$tp = strtolower($tp);
if ($tp == 'int') $tp = 6;
elseif ($tp == 'date') $tp = 5;
elseif ($tp == 'radio') $tp = 4;
elseif ($tp == 'checkbox') $tp = 3;
elseif ($tp == 'select') $tp = 2;
elseif ($tp == 'textarea') $tp = 1;
else $tp = 0;
if (!$preg) return $tp;
else return array('tp' => $tp, 'str' => $a[1]);
}
function xls_generate($g, $mid = 0, $type = '', $read = '', $fn = '', $aid = '')
{
global $lang_wg2;
if ($g) {
// echo "---------------- $g, $mid, $type, $read, $fn, $aid----------------------\r\n";
@error_reporting(0);
@set_time_limit(0);
//error_reporting(E_ALL);
if (isset($_POST['limit'])) {
$a = explode('|', $_POST['limit']);
$_POST['limit'] = $a[0];
$xs = '_' . $a[1];
} else {
$_POST['limit'] = '';
$xs = '';
}
if ($mid) {
$sqlq = "Select * from `".DB_PREFIX."stat` where mid='$mid' " . ($type != '' ? " and type='$type'" : '') . ($read ? ($read == 2 ? " and `stat`='0000-00-00'" : " and `stat`!='0000-00-00'") : '') . ($_POST['limit'] ? " limit $_POST[limit]" : '');
$sql = $this->mq($sqlq);
} elseif ($aid) {
$sqlq = "Select * from `".DB_PREFIX."act_stat` where aid='$aid' and stat!='0000-00-00'" . ($_POST['limit'] ? " limit $_POST[limit]" : '');
$sql = $this->mq($sqlq);
} elseif ($_POST['filter']) {
$_GET['g'] = $g;
$filter = $this->m_array("select * from `".DB_PREFIX."filters` where id='$_POST[filter]'");
$t_x = $this->reszletes_kereso(unserialize($filter['data']));
$q = $t_x['q'];
$fd = $t_x['fd'];;
$sql = $this->mq("select * from `".DB_PREFIX."users` as us where a=1 and g='$_POST[g]'$q order by id" . ($_POST['limit'] ? " limit $_POST[limit]" : ''));
} else $sql = $this->mq("select * from `".DB_PREFIX."users` where `g`='$g' and a=1 order by id" . ($_POST['limit'] ? " limit $_POST[limit]" : ''));
$gr = $this->m_array("select * from `".DB_PREFIX."groups` where id='$g'");
$g_dashed = $this->dash($gr['name']);
if ($fn) $g_dashed = $fn . '_stat';
$group = $gr['name'];
$format_bold = 0;
$counter++;
$impt /* import type */ = @$_POST['impt'];
//$impt = 'csv';
if (!$impt) // xls
{
$XLS_TP_php = 'PHPExcel/Classes/PHPExcel/Writer/Excel5.php';
$XLS_save_eval = 'header("Content-Type: application/vnd.ms-excel");
header("Content-Disposition: attachment;filename=\"{$g_dashed}{$xs}.xls\"");
header("Cache-Control: max-age=0");
$objWriter = new PHPExcel_Writer_Excel5($objPHPExcel);';
}
if ($impt == 'xlsx') // xlsx
{
$XLS_TP_php = 'PHPExcel/Classes/PHPExcel/Writer/Excel2007.php';
$XLS_save_eval = 'header("Content-Type: application/vnd.ms-excel");
header("Content-Disposition: attachment;filename=\"{$g_dashed}{$xs}.xlsx\"");
header("Cache-Control: max-age=0");
$objWriter = new PHPExcel_Writer_Excel2007($objPHPExcel);';
}
if ($impt == 'csv') // xlsx
{
// $XLS_TP_php = 'PHPExcel/Classes/PHPExcel/Writer/Excel2007.php';
$XLS_save_eval = 'header("Content-type: text/csv");
header("Content-Disposition: attachment;filename=\"{$g_dashed}{$xs}.csv\"");
header("Cache-Control: max-age=0");
$objWriter = new PHPExcel_Writer_CSV($objPHPExcel);
$objWriter->setDelimiter(";");
$objWriter->setEnclosure(\'"\');
$objWriter->setLineEnding("\n");
$objWriter->setSheetIndex(0);';
}
/*;
->setInputEncoding('ISO-8859-2')
->setDelimiter(';')
->setEnclosure('"')
->setLineEnding("\n")
->setSheetIndex(0)
*/
include 'PHPExcel/Classes/PHPExcel.php';
if ($XLS_TP_php) include $XLS_TP_php;
// Create new PHPExcel object
$objPHPExcel = new PHPExcel();
$ver = $this->conf_read('ver');
// Set document properties
$ws_name = substr($gr['name'], 0, 31);
$objPHPExcel->getProperties()->setCreator("Webgalamb $ver")
->setTitle($ws_name)
->setSubject("Export file")
->setDescription("")
->setKeywords("")
->setCategory("");
$objPHPExcel->setActiveSheetIndex(0);
function xls($x, $y, $v = '')
{;
};
// küldés megkezdése
$dbx = 4;
$objPHPExcel->getActiveSheet()->setCellValueExplicitByColumnAndRow(0, 1, __('E-mail cÃm'));
$objPHPExcel->getActiveSheet()->setCellValueExplicitByColumnAndRow(1, 1, __('IP cÃm'));
$objPHPExcel->getActiveSheet()->setCellValueExplicitByColumnAndRow(2, 1, __('Feliratkozás ideje'));
$objPHPExcel->getActiveSheet()->setCellValueExplicitByColumnAndRow(3, 1, __('Státusz'));
$objPHPExcel->getActiveSheet()->setCellValueExplicitByColumnAndRow(4, 1, __('ID'));
if ($aid) {
$objPHPExcel->getActiveSheet()->setCellValueExplicitByColumnAndRow(5, 1, __('Kattintás idÅpontja'));
$dbx++;
}
if ($mid) {
$objPHPExcel->getActiveSheet()->setCellValueExplicitByColumnAndRow(5, 1, __('Kiküldve'));
$dbx++;
}
if ($read == 1 && $mid) {
$objPHPExcel->getActiveSheet()->setCellValueExplicitByColumnAndRow(6, 1, __('Elolvasva'));
$dbx++;
}
if ($aid) {
$objPHPExcel->getActiveSheet()->setCellValueExplicitByColumnAndRow(7, 1, __('Kattintva'));
$dbx++;
}
//xls(0, $dbx+1, 'ID'), $format_bold); $dbx++;
//xls(0, $dbx+1, 'Verify'), $format_bold); $dbx++;
$db = $c = $h = 0;
// plussz mezÅk felvitele:
$sql_fields = $this->mq("select * from `".DB_PREFIX."fields` where g='$g' order by hely");
$fields_array = array();
while ($s = mysql_fetch_array($sql_fields)) {
if (($gr['email_field'] == $s['id']) || ($gr['email2_field'] == $s['id'])) continue;
$db++;
$fields_array[$s['id']] = $db;
$tp = $s['type'];
$tp = $this->tp($tp);
//if($tp) $s['name'].='{{'.$tp.'}}';
$objPHPExcel->getActiveSheet()->setCellValueExplicitByColumnAndRow($db + $dbx, 1, $s["name"]);
}
$db = 0;
$f_a = array();
global $minta;
//$sql=$this->mq("select * from `".DB_PREFIX."users` where `g`='$g' and a=1 order by name".($_POST['limit']?" limit $_POST[limit]":''));
while ($s = $statxy = mysql_fetch_array($sql)) {
if ($minta) break;
if ($mid || $aid) $s = $this->m_array("select * from `".DB_PREFIX."users` where id='$s[uid]'");
if (!$s) $s = array('name' => __('leiratkozott olvasó'), 'mail' => '-', 'ip' => '-', 'datum' => '-', 'active' => '0');
$db++;
$dbh = 5;
$objPHPExcel->getActiveSheet()->setCellValueExplicitByColumnAndRow(0, $db + 1, $s["mail"]);
$objPHPExcel->getActiveSheet()->setCellValueExplicitByColumnAndRow(1, $db + 1, $s["ip"]);
$objPHPExcel->getActiveSheet()->setCellValueExplicitByColumnAndRow(2, $db + 1, $s["datum"]);
$objPHPExcel->getActiveSheet()->setCellValueExplicitByColumnAndRow(3, $db + 1, $s["active"] ? ($s["active"] == 2 ? __('Visszapattant') : __('AktÃv')) : __('InaktÃv'));
$objPHPExcel->getActiveSheet()->setCellValueExplicitByColumnAndRow(4, $db + 1, $s["id"]);
if ($mid) {
$objPHPExcel->getActiveSheet()->setCellValueExplicitByColumnAndRow(5, $db + 1, date('Y-m-d', $statxy['date']));
$dbh = 7;
}
if ($read == 1 && $mid) {
$objPHPExcel->getActiveSheet()->setCellValueExplicitByColumnAndRow(6, $db + 1, $statxy['stat']);
$dbh = 8;
}
if ($aid) {
$objPHPExcel->getActiveSheet()->setCellValueExplicitByColumnAndRow(5, $db + 1, $statxy['stat']);
}
//xls($db, $dbh-1, $s["id"]));
//xls($db, $dbh, $s["verify_code"]));
$id = $s['id'];
$s_q = "SELECT
".DB_PREFIX."users.g as g,
".DB_PREFIX."fields.id as vidid,
".DB_PREFIX."fields.type as type,
".DB_PREFIX."fields_data.text as text,
".DB_PREFIX."fields_data.int_text as int_text,
".DB_PREFIX."fields_data.`date` as `date`
FROM
".DB_PREFIX."fields_data,
".DB_PREFIX."users,
".DB_PREFIX."fields
WHERE
".DB_PREFIX."fields.id=".DB_PREFIX."fields_data.did and
".DB_PREFIX."fields_data.un='$id' and
".DB_PREFIX."users.id='$id' order by ".DB_PREFIX."fields.hely";
//die($s_q);
$sq2 = $this->mq($s_q);
if ($c) $h = 1;
while ($s2 = mysql_fetch_array($sq2)) {
if ($s2['g'] != $g) continue;
if ($s2['type'] > 1) {
if (!isset($f_a[$s2['vidid']])) {
$f_a[$s2['vidid']] = array();
$x = $this->mq("select * from `".DB_PREFIX."fields_fields` where field_id='$s2[vidid]'");
while ($x2 = mysql_fetch_assoc($x)) $f_a[$s2['vidid']][$x2['id']] = $x2['name'];
}
if (!isset($fields_array[$s2['vidid']])) $fields_array[$s2['vidid']] = '';
if (($s2['type'] == 2 || $s2['type'] == 4) && $s2['int_text']) {
if (!isset($f_a[$s2['vidid']][(int)($s2['int_text'])])) $f_a[$s2['vidid']][(int)($s2['int_text'])] = '';
$objPHPExcel->getActiveSheet()->setCellValueExplicitByColumnAndRow($fields_array[$s2['vidid']] + $dbx, $db + 1, $f_a[$s2['vidid']][(int)($s2['int_text'])]);
}
if ($s2['type'] == 5)
$objPHPExcel->getActiveSheet()->setCellValueExplicitByColumnAndRow($fields_array[$s2['vidid']] + $dbx, $db + 1, ($s2['date']));
if ($s2['type'] == 6)
$objPHPExcel->getActiveSheet()->setCellValueExplicitByColumnAndRow($fields_array[$s2['vidid']] + $dbx, $db + 1, (int)($s2['int_text']));
if ($s2['type'] == 3 && $s2['text']) // chex -- többet is kijelölhet
{
$tomb = explode(';', $s2['text']);
$str = '';
foreach ($tomb as $v) if ((int)($v)) $str .= $f_a[$s2['vidid']][(int)($v)] . '; ';
$objPHPExcel->getActiveSheet()->setCellValueExplicitByColumnAndRow($fields_array[$s2['vidid']] + $dbx, $db + 1, $str);
}
} elseif ($s2['text']) $objPHPExcel->getActiveSheet()->setCellValueExplicitByColumnAndRow($fields_array[$s2['vidid']] + $dbx, $db + 1, str_replace(array("\r\n", "\n"), array(' ', ' '), $s2['text']));
}
// if($db > 50) break;
}
//$xls->xls_vege();
$ws_name = substr($g_dashed, 0, 31);
eval($XLS_save_eval);
$objWriter->save('php://output');
exit;
}
}
function csv_generate($g, $mid = 0, $type = '', $read = '', $fn = '', $aid = 0)
{
global $lang_wg2;
if ($g) {
@error_reporting(0);
@set_time_limit(0);
if (isset($_POST['limit'])) {
$a = explode('|', $_POST['limit']);
$_POST['limit'] = $a[0];
$xs = '_' . $a[1];
} else {
$_POST['limit'] = '';
$xs = '';
}
if ($mid) {
$sqlq = "Select * from `".DB_PREFIX."stat` where mid='$mid' " . ($type != '' ? " and type='$type'" : '') . ($read ? ($read == 2 ? " and `stat`='0000-00-00'" : " and `stat`!='0000-00-00'") : '') . ($_POST['limit'] ? " limit $_POST[limit]" : '');
$sql = $this->mq($sqlq);
} elseif ($aid) {
$sqlq = "Select * from `".DB_PREFIX."act_stat` where aid='$aid' and stat!='0000-00-00'" . ($_POST['limit'] ? " limit $_POST[limit]" : '');
$sql = $this->mq($sqlq);
} elseif ($_POST['filter']) {
$_GET['g'] = $g;
$filter = $this->m_array("select * from `".DB_PREFIX."filters` where id='$_POST[filter]'");
$t_x = $this->reszletes_kereso(unserialize($filter['data']));
$q = $t_x['q'];
$fd = $t_x['fd'];;
$sql = $this->mq("select * from `".DB_PREFIX."users` as us where a=1 and g='$_POST[g]'$q order by id" . ($_POST['limit'] ? " limit $_POST[limit]" : ''));
} else {
$sql = $this->mq("select * from `".DB_PREFIX."users` where `g`='$g' and a=1 order by id" . ($_POST['limit'] ? " limit $_POST[limit]" : ''));
//echo"select * from `".DB_PREFIX."users` where `g`='$g' and a=1 order by id".($_POST['limit']?" limit $_POST[limit]":'');
//die();
}
$gr = $this->m_array("select * from `".DB_PREFIX."groups` where id='$g'");
$g_dashed = $this->dash($gr['name']);
if ($fn) $g_dashed = $fn . '_stat';
$group = $gr['name'];
$xls = new tg_xls_writer();
$xls->downloading("{$g_dashed}{$xs}.csv");
// küldés megkezdése
$data = '';
//$data.= $xls->csv_conv(('Név'));
$data .= $xls->csv_conv($this->convert_utf8_to_iso(__('E-mail cÃm')));
$data .= $xls->csv_conv($this->convert_utf8_to_iso(__('IP cÃm')));
$data .= $xls->csv_conv($this->convert_utf8_to_iso(__('Feliratkozás ideje')));
$data .= $xls->csv_conv($this->convert_utf8_to_iso(__('Státusz')));
$data .= $xls->csv_conv($this->convert_utf8_to_iso(__('ID')));
if ($aid) {
$data .= $xls->csv_conv($this->convert_utf8_to_iso(__('Kattintás idÅpontja')));
}
if ($mid) $data .= $xls->csv_conv($this->convert_utf8_to_iso(__('Kiküldve')));
if ($read == 1 && $mid) $data .= $xls->csv_conv($this->convert_utf8_to_iso(__('Elolvasva')));
if ($aid) $data .= $xls->csv_conv($this->convert_utf8_to_iso(__('Kattintva')));
$db = $c = $h = 0;
// plussz mezÅk felvitele:
$sql_fields = $this->mq("select * from `".DB_PREFIX."fields` where g='$g' order by hely");
$fields_array = array();
while ($s = mysql_fetch_array($sql_fields)) {
if (($gr['email_field'] == $s['id']) || ($gr['email2_field'] == $s['id'])) continue;
$db++;
$fields_array[] = $s;
$tp = $s['type'];
$tp = $this->tp($tp);
//if($tp) $s['name'].='{{'.$tp.'}}';
$data .= $xls->csv_conv($this->convert_utf8_to_iso($s["name"]));
}
$db = 0;
$f_a = array();
while ($s = $statxy = mysql_fetch_array($sql)) {
if ($mid || $aid) $s = $this->m_array("select * from `".DB_PREFIX."users` where id='$s[uid]'");
if (!$s) $s = array('name' => __('leiratkozott olvasó'), 'mail' => '-', 'ip' => '-', 'datum' => '-', 'active' => '0');
$db++;
if ($data) {
echo substr($data, 0, strlen($data) - 1);
echo "\n";
}
$data = '';
//$data.= $xls->csv_conv($this->convert_utf8_to_iso($s["name"]));
$data .= $xls->csv_conv($this->convert_utf8_to_iso($s["mail"]));
$data .= $xls->csv_conv($this->convert_utf8_to_iso($s["ip"]));
$data .= $xls->csv_conv($this->convert_utf8_to_iso($s["datum"]));
$data .= $xls->csv_conv($this->convert_utf8_to_iso($s["active"] ? ($s["active"] == 2 ? __('Visszapattant') : __('AktÃv')) : __('InaktÃv')));
$data .= $xls->csv_conv($this->convert_utf8_to_iso($s["id"]));
if ($mid) {
$data .= $xls->csv_conv($this->convert_utf8_to_iso(date('Y-m-d', $statxy['date'])));
}
if ($read == 1 && $mid) $data .= $xls->csv_conv($this->convert_utf8_to_iso($statxy['stat']));
if ($aid) $data .= $xls->csv_conv($this->convert_utf8_to_iso($statxy['stat']));
$id = $s['id'];
if ($c) $h = 1;
foreach ($fields_array as $s2) {
$fd = $this->m_array("select * from ".DB_PREFIX."fields_data where un='$s[id]' and did='$s2[id]'");
if ($s2['type'] > 1) {
if (!isset($f_a[$s2['id']])) {
$f_a[$s2['id']] = array();
$x = $this->mq("select * from `".DB_PREFIX."fields_fields` where field_id='$s2[id]'");
while ($x2 = mysql_fetch_assoc($x)) $f_a[$s2['id']][$x2['id']] = $x2['name'];
}
if (($s2['type'] == 2 || $s2['type'] == 4)) {
if ($fd['int_text']) $data .= $xls->csv_conv($this->convert_utf8_to_iso($f_a[$s2['id']][(int)($fd['int_text'])]));
else $data .= ';';
}
if ($s2['type'] == 5)
$data .= $xls->csv_conv($this->convert_utf8_to_iso(($fd['date'])));
if ($s2['type'] == 6)
$data .= $xls->csv_conv($this->convert_utf8_to_iso((int)($fd['int_text'])));
if ($s2['type'] == 3) // chex -- többet is kijelölhet
{
$tomb = explode(';', $fd['text']);
$str = '';
foreach ($tomb as $v) if ((int)($v)) $str .= $f_a[$s2['id']][(int)($v)] . '; ';
$data .= $xls->csv_conv($this->convert_utf8_to_iso($str));
//if(!$str) $data.=';';
}
} else//if($fd['text'])
{
$data .= $xls->csv_conv($this->convert_utf8_to_iso(str_replace(array("\r\n", "\n"), array(' ', ' '), $fd['text'])));
//if(!$fd['text']) $data.= ';';
}
}
}
}
echo $data;
echo "\n";
/*if($data)
{
echo substr($data, 0, strlen($data)-1);
echo "\n";
}
*/
exit;
}
function videoimage($tp, $id, $file)
{
if ($tp == 'youtube')
$image_url = "http://img.youtube.com/vi/{$id}/0.jpg";
if ($tp == 'vimeo') {
$tisztareturn = @file_get_contents("http://vimeo.com/api/v2/video/$id.json");
$tisztareturn = substr($tisztareturn, strpos($tisztareturn, '[{'));
$image_url = json_decode($tisztareturn, true);
if (!$image_url)
echo __("Hibás a megadott vimeo link, vagy a linken nem található videó");
$image_url = $image_url[0]['thumbnail_large'];
}
if (!$image_url || !$file) return false;
$image = @file_get_contents($image_url);
// $this->download($image_url);
//http://vimeo.com/15887012
if (!$image) {
echo __('Nem sikerült az elÅnézeti kép letöltése, ellenÅrizd a linket.');
return false;
}
$image = imagecreatefromstring($image);
$destination_x = (imagesx($image) / 2) - 100;
$destination_y = (imagesy($image) / 2) - 80;
// Load the play button image.
$play_button_image = imagecreatefrompng('../static/img/play-button-overlay.png');
imagealphablending($play_button_image, true); // Preserve transparency.
imagealphablending($image, true); // Preserve transparency.
// Use imagecopy() to place the play button over the image.
imagecopy(
$image, // Destination image.
$play_button_image, // Source image.
$destination_x, // Destination x coordinate.
$destination_y, // Destination y coordinate.
0, // Source x coordinate.
0, // Source y coordinate.
200, // Source width.
160 // Source height.
);
imagejpeg($image, $file);
imagedestroy($image);
/*
$fp = fopen($file, 'w');
fwrite($fp,$image);
fclose($fp);*/
return true;
}
// XLS import rész
function datafile_upl($file, $oszlop)
{
global $txt_processing_start;
$tp = $_FILES[$file]['type'];
$knyvt = is_dir('files/') ? 'files/feltolt' : '../files/feltolt';
if (!$_POST['g']) return __('Nincs csoport kiválasztva!');
$kit = '.' . pathinfo($_FILES[$file]['name'], PATHINFO_EXTENSION); /*strtolower(substr($_FILES[$file]['name'], strlen($_FILES[$file]['name'])-4));*/
//if (!($kit=='.csv' || $kit == '.xls' || $kit == '.ods' || $kit == '.ots' || $kit == '.xlsx')) return __('Hibás fájlformátum!').'
'.__('Kizárólag .xls, .xlsx, és .csv kiterjesztésű fájl tölthetŠfel!');
if (!($kit == '.csv' || $kit == '.xls')) return __('Hibás fájlformátum!') . '
' . __('Kizárólag a következÅ kiterjesztésű fájlok tölthetÅek fel:') . '
.xls, .csv';
if (!$_FILES[$file]['size'] > 16024000) return __("Maximum 16MB-os fájl tölhetŠfel!");
if (is_uploaded_file($_FILES[$file]['tmp_name']) && $_POST['g']) @move_uploaded_file($_FILES[$file]['tmp_name'], $knyvt . $kit);
else return __("Valami probléma adódott a fájl feltöltése közben!");
if (!is_file($knyvt . $kit)) return __("Nem érem el a feltöltött fájlt. ValószÃnűleg nem megfelelÅek a mappa jogosultságai");
/* if($kit=='.csv' || $kit == '.xls' || $kit == '.ods' || $kit == '.ots' || $kit == '.xlsx' || $kit=='.xml')
$txt_processing_start = "
";
*/
if ($kit == '.csv' || $kit == '.xls' || $kit == '.ods' || $kit == '.ots' || $kit == '.xlsx') {
$txt_processing_start = "
";
}
}
function is_utf8($str)
{
return (preg_match(
"/^([\x09\x0A\x0D\x20-\x7E]|[\xC2-\xDF][\x80-\xBF]|\xE0[\xA0-\xBF][\x80-\xBF]|[\xE1-\xEC\xEE\xEF][\x80-\xBF]{2}|\xED[\x80-\x9F][\x80-\xBF]|\xF0[\x90-\xBF][\x80-\xBF]{2}|[\xF1-\xF3][\x80-\xBF]{3}|\xF4[\x80-\x8F][\x80-\xBF]{2})*$/",
$str
)) ? true : false;
}
function _json_decode($str)
{
return explode('|||||;;;S3P4R47OR;;|||||', $str);
}
function _json_encode($array)
{
return implode('|||||;;;S3P4R47OR;;|||||', $array);
}
function getcsv($file, $sp)
{
global $file_pointer;
if (feof($file)) return false;
$sor = '';
while (!feof($file)) {
$ch = fread($file, 1);
if ($ch == "\n") break;
$sor .= $ch;
}
$_SESSION['file_pointer'] = ftell($file);
if (!$sor) return false;
return $this->csvr(($sor), $sp);
}
function utf8_encode_array($arr)
{
foreach ($arr as $k => $v)
$arr[$k] = utf8_encode($v);
return $arr;
}
function xls_to_csv($g, $pid, $kit)
{
$inputFileName = WG_PATH."files/feltolt$kit";
if (!$g || !$pid) return __('Hibás függvény használat.');
$chf = $this->conf_read("chmod_file");
if ($chf > 100 && $chf <= 777) {
$e = "chmod('$inputFileName', 0" . (int)($chf) . ");";
eval($e);
}
if ($kit == ".csv") {
$handle = fopen($inputFileName, "r");
$row = 0;
while (($data = $this->getcsv($handle, ";")) !== false) // 2. sortól nézzük }
{
$row++;
$temp_s = $this->_json_encode($data);
$utf8 = $this->is_utf8($temp_s);
if (!$utf8 && !isset($utf8set)) {
$utf8set = 1;
mysql_query("set character set latin2");
mysql_query("SET NAMES latin2");
}
$temp_s = mysql_real_escape_string($temp_s);
$this->mq("insert into `".DB_PREFIX."import` (`g`, `pid`, `row`, `x`) values ('$g', '$pid', '$temp_s', '$row')");
}
fclose($handle);
unlink($inputFileName);
return;
}
if (!is_file($inputFileName))
return __('Valami hiba történt a fájl feltöltése közben. EllenÅrizd a files mappa jogosultságát! (' . ($inputFileName) . ')');
if (is_file($inputFileName) && $g) {
// echo 'fáj létezik';
require('ExcelReader/php-excel-reader/excel_reader2.php');
require('ExcelReader/SpreadsheetReader.php');
date_default_timezone_set('UTC');
$StartMem = memory_get_usage();
$Spreadsheet = new SpreadsheetReader($inputFileName);
$BaseMem = memory_get_usage();
$Sheets = $Spreadsheet->Sheets();
$tmp_sql = '';
$i = 1;
foreach ($Sheets as $Index => $Name) {
$Spreadsheet->ChangeSheet($Index);
foreach ($Spreadsheet as $Key => $Row) {
if (!implode('', $Row)) continue;
$temp_s = $this->_json_encode($Row);
$utf8 = $this->is_utf8($temp_s);
if (!$utf8 && !isset($utf8set)) {
$utf8set = 1;
mysql_query("set character set latin2");
mysql_query("SET NAMES latin2");
}
$temp_s = mysql_real_escape_string($temp_s);
$tmp_sql .= ($tmp_sql ? ",\r\n" : '') . "('$g', '$pid', '$temp_s', '$Key')";
if (!($i++ % 500)) {
$this->mq("insert into `".DB_PREFIX."import` (`g`, `pid`, `row`, `x`) VALUES $tmp_sql");
$tmp_sql = '';
}
}
}
if ($tmp_sql) {
$this->mq("insert into `".DB_PREFIX."import` (`g`, `pid`, `row`, `x`) VALUES $tmp_sql");
}
unlink($inputFileName);
}
}
function txt_check($now_time, $kit)
{
global $file_pointer;
$t_1 = time();
$out = '';
$g = $_POST['g'];
$pid = $_POST['pid'];
$highestRow = $this->m_array("select count(`id`) as c from `".DB_PREFIX."import` where g='$g' and pid = '$pid'", 'c');
$row = $this->m_array("select * from `".DB_PREFIX."import` where g='$g' and pid = '$pid' order by id", 'row');
$data = $this->_json_decode($row);
if (!$data) return __("Már az elsŠoszloppal baj van, vagy nincs is meg!");
foreach ($data as $cols) {
$j++;
$numcols++;
//echo $cols;
//echo "
\r\n";
$_NEV = mysql_real_escape_string(($cols));
$tp = $this->inv_tp($_NEV, 1);
$_NEV = $tp['str'];
$tp = $tp['tp'];
$sql = $this->mq("select * from ".DB_PREFIX."fields where g='$g' and name='" . $_NEV . "'");
$err_a[] = mysql_real_escape_string(($cols));
if ($cols == (__('Feliratkozás ideje'))) {
$c[$j] = 'datum';
$tim = $j;
} elseif ($cols == (__('IP cÃm'))) {
$c[$j] = 'ip';
$ip = $j;
} elseif ($cols == (__('E-mail cÃm')) ||
strtolower($cols) == (strtolower(__('E-mail'))) ||
strtolower($cols) == (strtolower(__('Email')))) {
$c[$j] = 'mail';
$mail = $j;
} elseif ($cols == (__('Státusz'))) {
$c[$j] = 'active';
$status_id = $j;
} elseif (mysql_num_rows($sql)) { // h ÃJ MezÅ, de már létezik akkor hozzáasduk a számát
$s = mysql_fetch_array($sql);
$c[$j] = intval($s['id']);
$tipus[$j] = $s['type'];
/* -------------- */ if ($tp) $tipus[$j] = $tp;
//megnézzük milyen tÃpus
if ($s['type'] > 1 && $s['type'] < 5) // beolvassuk a mezÅket.
{
$m_sql = $this->mq("select * from ".DB_PREFIX."fields_fields where field_id='$s[id]' order by CHAR_LENGTH(name) desc");
$fields[$s['id']] = array();
while ($m_s = mysql_fetch_assoc($m_sql)) $fields[$s['id']][$m_s['id']] = $m_s['name'];
}
} elseif ($cols) // ha viszont nem létezik benne, akkor kreálunk és persze van abba az oszlopba valami
{
$id = $this->a_i("".DB_PREFIX."fields");;
$c[$j] = intval($id);
if ($tp) $tipus[$j] = $tp;
}
}
$q = array_count_values($err_a);
$tobb = '';
foreach ($q as $k => $v) if ($v > 1) $tobb .= __('Ez az oszlop többször is szerepel: ') . $k . '
';
if ($tobb) $hiba = $tobb;
else $hiba = '';
$_g = $this->m_array("select * from ".DB_PREFIX."groups where id='$g'");
$e_data = $db_users = 0;
// megnézzük minden mezŠmegan e
//if(!$name) $hiba.='
#1. sor > Név mezŠhiányzik';
if (!$mail) $hiba .= "
" . __('E-mail cÃm') . __(' mezÅ hiányzik');
if ($hiba) {
$hiba .= '
' . __('Az ellenÅrzés nem folytatható.');
if (is_file($inputFileName))
unlink($inputFileName);
return $hiba;
}
$xrow = 2;
// most megnézzük az adatokat
if (isset($_POST['kezd'])) $j = $_POST['kezd'];
else $j = 1;
if (isset($_POST['fp'])) $xrow = $_POST['fp'];
for ($row = $xrow; $row <= $highestRow; $row++) // 2. sortól nézzük }
{
$data = $this->_json_decode($this->m_array("select * from `".DB_PREFIX."import` where x='$row' and g='$g' and pid = '$pid' order by id", 'row'));
$j++;
$m = str_replace(array(' ', chr(194), chr(160), "\r", "\n", "\n"), '', ($data[$mail - 1]));
$t = ($data[$tim - 1]);
$ip_v = ($data[$ip - 1]);
$s_x = ($data[$status_id - 1]);
if ($status_id) {
if ($s_x == __('Visszapattant')) $s_x = '2';
elseif ($s_x == __('InaktÃv')) $s_x = '0';
elseif ($s_x == __('AktÃv')) $s_x = '1';
elseif ($s_x == '') $s_x = '1';
else $hiba .= "
" . sprintf(__('#%1$s. sor %2$s. oszlop'), $j, $status_id) . " -> " . __("Ismeretlen státusz") . ": " . $s_x . "";
}
$t2 = $t;
$t = str_replace('.', '-', $t);
if ($a = preg_match("/^([0-9]{2})[\/]*([0-9]{2})[\/]*([0-9]{4})$/", $t, $b))
$t = "$b[3]-$b[1]-$b[2]";
//dátum ellenörzése
if (!$t) $t = date("Y-m-d");
if ($now_time && !preg_match("/^[0-9]{4}[-]*[0-9]{2}[-]*[0-9]{2}$/", $t)) {
if (!$tim) $tim = sprintf(__("ismeretlen vagy hiányzó %s oszlop"), "" . __('Feliratkozás ideje') . "");
$hiba .= "
" . sprintf(__('#%1$s. sor %2$s. oszlop'), $j, $tim) . " -> " . __("Hibás dátumformátum (helyes: 1985-05-02)") . ": " . $t2 . "";
}
//e-mail cÃm ellenörzés
if (!$this->isValidEmail($m)) {
$e_data++;
$error = 1;
$hiba .= "
" . sprintf(__('#%1$s. sor %2$s. oszlop'), $j, $mail) . " -> " . __("Hibás e-mail cÃm") . ": " . $m . "";
} else // nincs hiba
{
$db_users++;
$id = 0;
if (!$ip_v) $ip_v = $_ip;
$m = addslashes($m);
//egyéb adatok beszúrása
for ($i = 1; $i <= $numcols; $i++) {
if (is_int($c[$i]) && isset($data[$i - 1])) {
$cols_string = $cols_string2 = (addslashes($data[$i - 1]));
// dátum és szám ellenörzés
if ($tipus[$i] == 5 && $cols_string) {
//date('Y-m-d', (41381 - 25569) * 86400);
if (!$cols_string) $cols_string = '0000-00-00';
if ((!preg_match("/^[0-9]{4}[-]*[0-9]{2}[-]*[0-9]{2}$/", $cols_string)) && (!preg_match("/^([(0-9]+)?$/", $cols_string))) {// && !preg_match("/^([(0-9]+)?$/", $cols_string)) {
if (preg_match("/^([(0-9]+)?$/", $cols_string)) {
$exc_date = (int)($cols_string);
$cols_string = date('Y-m-d', ($exc_date - 25569) * 86400);
}
$hiba .= "
" . sprintf(__('#%1$s. sor %2$s. oszlop'), $j, $i) . " -> " . __("Hibás dátumformátum (pl: 2009-03-07)") . ": " . $cols_string . "";
}
} elseif ($tipus[$i] == 6 && $cols_string) {
if (!preg_match("/^([(0-9]+)?$/", $cols_string)) {
$hiba .= "
" . sprintf(__('#%1$s. sor %2$s. oszlop'), $j, $i) . " -> " . __("Hibás számformátum") . ": " . $cols_string . "";
}
} elseif ($tipus[$i] == 3 && $cols_string) // checkbox
{
$cols_string = str_replace('; ', ';', $cols_string);
$arr = explode(';', str_replace('; ;', ';', ($cols_string . ';')));
$field_id = $c[$i];
foreach ($arr as $v0) {
if (!$v0) continue;
$_van = 0;
if (is_array($fields[$field_id]))
foreach ($fields[$field_id] as $k => $v) {
if ($v == $v0) {
$_van = 1;
break;
}
}
if (!$_van) $hiba .= "
" . sprintf(__('#%1$s. sor %2$s. oszlop'), $j, $i) . " -> "
. __("Hibás checkbox érték") . ": " . $v0 . "";
}
continue;
}
//$fields[$s['id']]
$field_id = $c[$i];
if (!isset($fields[$field_id])) $fields[$field_id] = '';
if (is_array($fields[$field_id])) // ha az adott mezÅbe cuccok vanak:
{
reset($fields[$field_id]);
foreach ($fields[$field_id] as $k => $v) {
$cols_string = str_replace($v . ';', '', $cols_string);
$cols_string = str_replace($v, '', $cols_string);
}
if (str_replace(' ', '', $cols_string)) $hiba .= "
" . sprintf(__('#%1$s. sor %2$s. oszlop'), $j, $i) . " -> " . __("Hibás adat") . ": " . $cols_string2 . " -> " . __('hibás rész') . ": " . $cols_string;
}
}
}
}
if (time() - $t_1 > 8) {
// echo 'ki kellebne lépni';
if (!isset($_SESSION['hibapl'])) $_SESSION['hibapl'] = '';
$_SESSION['hibapl'] .= $hiba;
echo '
';
exit;
}
}
// fclose($handle);
$t_2 = time();
if (is_file($inputFileName) && $hiba) unlink($inputFileName);
if (isset($_SESSION['hibapl'])) $hiba = $_SESSION['hibapl'] . $hiba;
return $hiba ? $hiba . "
" . sprintf(__('Az ellenÅrzés %s másodpercet vett igénybe'), ($t_2 - $t_1)) : false;
}
function txt_processing($kit, $g_id)
{
global $Referer_nev;
$t_1 = time();
$out = '';
$g = $_POST['g'];
$_ip = $this->getip();
$updated = $j = $numcols = 0;
$g = $_POST['g'];
$pid = $_POST['pid'];
$ref_id = $this->m_array("select * from `".DB_PREFIX."fields` where name='$Referer_nev' and g='$g_id'", 'id');
// adatcsere:
$tim = $ip = $name = $mail = $status_id = '';
$inputFileName = "../files/feltolt$kit";
//return $inputFileName;
$highestRow = $this->m_array("select count(`id`) as c from `".DB_PREFIX."import` where g='$g' and pid = '$pid'", 'c');
$data = $this->_json_decode($this->m_array("select * from `".DB_PREFIX."import` where g='$g' and pid = '$pid' order by id", 'row'));
$c = array();
$fields = array();
$vanreferer = 0;
$feliratkozasideje = 0;
foreach ($data as $cols) {
$j++;
$numcols++;
$_NEV = mysql_real_escape_string(($cols));
$tp = $this->inv_tp($_NEV, 1);
$_NEV = $tp['str'];
$tp = $tp['tp'];
$sql = $this->mq("select * from ".DB_PREFIX."fields where g='$g' and name='" . $_NEV . "'");
if ($cols == (__('Feliratkozás ideje'))) {
$c[$j] = 'datum';
$tim = $j;
$feliratkozasideje = 1;
} elseif ($cols == (__('IP cÃm'))) {
$c[$j] = 'ip';
$ip = $j;
} elseif ($cols == (__('E-mail cÃm')) ||
strtolower($cols) == (strtolower(__('E-mail'))) ||
strtolower($cols) == (strtolower(__('Email')))) {
$c[$j] = 'mail';
$mail = $j;
} elseif ($cols == (__('Státusz'))) {
$c[$j] = 'active';
$status_id = $j;
} elseif (strtolower($cols) == (__('id'))) {
$c[$j] = 'id';
$_ID_id = $j;
} elseif (mysql_num_rows($sql)) { // h ÃJ MezÅ, de már létezik akkor hozzáasduk a számát
$s = mysql_fetch_array($sql);
$c[$j] = intval($s['id']);
$tipus[$j] = $s['type'];
$option[$j] = $s['option'];
if ($tp) $tipus[$j] = $tp;
if ($s['id'] == $ref_id) $vanreferer = 1;
//megnézzük milyen tÃpus
if ($s['type'] > 1) // beolvassuk a mezÅket.
{
$m_sql = $this->mq("select * from ".DB_PREFIX."fields_fields where field_id='$s[id]' order by CHAR_LENGTH(name) desc");
$fields[$s['id']] = array();
while ($m_s = mysql_fetch_assoc($m_sql)) $fields[$s['id']][$m_s['id']] = $m_s['name'];
}
} elseif ($cols) // ha viszont nem létezik benne, akkor kreálunk és persze van abba az oszlopba valami
{
$id = $this->a_i("".DB_PREFIX."fields");;
$c[$j] = intval($id);
if ($tp) $tipus[$j] = $tp;
$this->mq("insert into ".DB_PREFIX."fields (g, name, hely, type) values
('$g','" . $_NEV . "','$id', '$tp')");
}
}
$_g = $this->m_array("select * from ".DB_PREFIX."groups where id='$g'");
$now_time = $_POST['update_time'];
$e_data = 0;
// most feltöljük adatokkal
if (isset($_POST['kezd'])) $j = $_POST['kezd'];
else $j = 1;
if (!$this->m_array("select * from `".DB_PREFIX."sub_stat` where date=CURDATE() and g=$g"))
$this->mq("insert into `".DB_PREFIX."sub_stat` (date, g, c) values (CURDATE(), '$g', 0)");
$xrow = 2;
if (isset($_POST['fp'])) $xrow = $_POST['fp'] + 1;
for ($row = $xrow; $row <= $highestRow; $row++) // 2. sortól nézzük }
{
$data = $this->_json_decode($this->m_array("select * from `".DB_PREFIX."import` where x='$row' and g='$g' and pid = '$pid' order by id", 'row'));
$j++;
if (isset($_POST['kezd'])) if ($j <= $_POST['kezd']) continue;
//$n= ($data[$name-1]);
$m = strtolower(str_replace(array(' ', chr(194), chr(160), "\r", "\n", "\n"), '', ($data[$mail - 1])));
$t = ($data[$tim - 1]);
$ip_v = ($data[$ip - 1]);
if (!isset($data[$status_id - 1])) $data[$status_id - 1] = '';
$s_x = ($data[$status_id - 1]);
$___ID = ($data[$_ID_id - 1]); // xls-bern lévŠid, de ezzel nem foglalkozunk
$m = strtolower($m);
if ($status_id) {
if ($s_x == __('Visszapattant')) $s_x = '2';
elseif ($s_x == __('InaktÃv')) $s_x = '0';
elseif ($s_x == __('AktÃv')) $s_x = '1';
else $s_x = '4';
} else $s_x = '4';
if ($a = preg_match("/^([0-9]{2})[\/]*([0-9]{2})[\/]*([0-9]{4})$/", $t, $b))
$t = "$b[3]-$b[1]-$b[2]";
$t = str_replace('.', '-', $t);
$t = str_replace(' ', '', $t);
if (preg_match("/^[0-9]{4}[-]*[0-9]{2}[-]*[0-9]{2}$/", $t) && $now_time) $t = "'$t'";
else $t = 'CURDATE()';
// if ( !$this->isValidEmail($m) || !$n) { $e_data++ ; $error=1; }
if (!$this->isValidEmail($m)) {
$e_data++;
$error = 1;
} else // nincs hiba
{
$mail_id = '';
$_SESSION['db_users']++;
$id = 0;
$ipdatum = 'now()';
$v_C = $this->generateCode(40);
if (!$_g['d_user']) // ha nincs többszörös feliratkozás - frissÃtünk
{
if ($s = $this->m_array("select * from ".DB_PREFIX."users where `g`='$g' and mail='$m'")) {
$_SESSION['updated']++;
$id = $s['id'];
$ipdatum = "'$s[ipdatum]'";
$mail_id = $s['mail_id'];
if (!$feliratkozasideje) $t = "'$s[datum]'";
if ($t == "''" || $t == "'0000-00-00'") $t = "'$s[datum]'";
$_ip = $s['ip'];
$omx = $s['omail'];
$v_C = $s['verify_code'];
$bounce = $s['bounce'];
$u_id = $s['id'];
$status_log = $s['status_log'];
if ($s_x == '4') $s_x = $s['active'];
$referer = $this->m_array("select * from ".DB_PREFIX."fields_data where `un`='$s[un]' and did='$ref_id'", 'text');
$this->mq("delete from ".DB_PREFIX."users where `g`='$g' and mail='$m'");
if (!$vanreferer) $this->mq("delete from ".DB_PREFIX."fields_data where `un`='$id' and did!='$ref_id'");
else $this->mq("delete from ".DB_PREFIX."fields_data where `un`='$id'");
}
}
if ($s_x == '4') $s_x = '1';
$tg_vdvdvu_id = $id ? $id : $this->a_i("".DB_PREFIX."users");
if (!$ip_v) $ip_v = $_ip;
if (!isset($omx)) $omx = '';
if (!isset($bounce)) $bounce = '';
if (!isset($status_log)) $status_log = '';
//$n=addslashes($n);
$m = addslashes($m);
$mail_id = $mail_id ? $mail_id : $this->mail_id($m);
//$mail_id='0';
// am
$this->mq("insert into ".DB_PREFIX."users (`g`, mail, omail, mail_id, datum, ip, active, verify_code, id, ipdatum, bounce, status_log) values
('$g', '$m', '$omx', '$mail_id', $t, '$ip_v', $s_x , '$v_C', '$id', $ipdatum, '$bounce', '$status_log')");
$u_id = mysql_insert_id();
$this->writeStatusLog($u_id, 'import', $s_x);
$this->writeModLog($u_id);
if (!$id) $this->mq("update `".DB_PREFIX."sub_stat` set c=c+1 where date=CURDATE() and g=$g");
//egyéb adatok beszúrása
for ($i = 1; $i <= $numcols; $i++) {
if (!isset($c[$i])) $c[$i] = '';
if (is_int($c[$i])) {
if (!isset($data[$i - 1])) $data[$i - 1] = '';
$cols_string = (addslashes($data[$i - 1]));
$field_id = $c[$i];
$inttext = 0;
if ($tipus[$i] == 5) // dátum
{
$cols_string = str_replace(' ', '', $cols_string);
if (preg_match("/^([(0-9]+)?$/", $cols_string)) {
$exc_date = (int)($cols_string);
$cols_string = date('Y-m-d', ($exc_date - 25569) * 86400);
}
//
//echo "insert into ".DB_PREFIX."fields_data (un, date, did) values ('$u_id','$cols_string', '".$c[$i]."')";
//die();
//if(preg_match("/^([(0-9]+)?$/", $cols_string)) $cols_string = date('Y-m-d', (( (int)($cols_string) - 25569)*3600*24 ) + 10);
if ($cols_string) $this->mq("insert into ".DB_PREFIX."fields_data (un, date, did) values ('$u_id','$cols_string', '" . $c[$i] . "')");
continue;
} elseif ($tipus[$i] == 6) //szám
{
$cols_string = str_replace(' ', '', $cols_string);
if ($cols_string) $this->mq("insert into ".DB_PREFIX."fields_data (un, int_text, did) values ('$u_id','$cols_string', '" . $c[$i] . "')");
continue;
} elseif ($tipus[$i] == 3) // checkbox
{
$cols_string .= ';';//$cols_string);
$cols_string = str_replace('; ', ';', $cols_string);
$arr = explode(';', $cols_string);
$outt = array();
foreach ($arr as $v0) {
foreach ($fields[$field_id] as $k => $v)
if ($v && $v == $v0) {
$outt[] = $k;
break;
}
}
$cols_string = implode(';', $outt) . ';';
if ($cols_string) $this->mq("insert into ".DB_PREFIX."fields_data (un, text, did) values ('$u_id','$cols_string', '" . $c[$i] . "')");
continue;
} else {
if (isset($fields[$field_id])) if (is_array($fields[$field_id])) // ha az adott mezÅbe cuccok vanak:
{
reset($fields[$field_id]);
foreach ($fields[$field_id] as $k => $v) $cols_string = str_replace($v, $k, $cols_string);
$cols_string = str_replace(' ', '', $cols_string);
if (!strstr($cols_string, ';') && ($cols_string > 0 && $cols_string < 9223372036854775800)) $inttext = 1;
//echo "cols:|$cols_string| - $inttext
";
}
if ($inttext) $this->mq("insert into ".DB_PREFIX."fields_data (un, int_text, did) values ('$u_id','$cols_string', '" . $c[$i] . "')");
else {
if ($tipus[$i] == '0' && $option[$i] == '1') $cols_string = ucwords(mb_convert_case($cols_string, MB_CASE_TITLE, "UTF-8"));
$this->mq("insert into ".DB_PREFIX."fields_data (un, text, did) values ('$u_id','$cols_string', '" . $c[$i] . "')");
}
}
}
}
}
if (time() - $t_1 > 3) {
echo '';
exit;
}
}
//fclose($handle);
return " " . __('Sikeres importálás!') . "
" . sprintf(__('%s feliratkozó importálva.'), '' . $_SESSION['db_users'] . '') . "
" . sprintf(__('%s feliratkozó adata felülÃrva.'), '' . $_SESSION['updated'] . '') . "
" . sprintf(__('Az importálás %s másodpercig tartott!'), '' . (time() - $_SESSION['t1']) . '');
}
function txt_processing2($g, $pid, $_X, $_Y)
{
global $Referer_nev;
$t_1 = time();
$out = '';
$TXT_B = 'run_xlsimport' . $g . $pid . $_X . $_Y;
$TXT_A = 'run_xlsimport' . $g . $pid;
$run = $this->conf_read($TXT_B);
if (!$run) $this->conf_update($TXT_B, time());
if ((time() - $run) < (30)) {
echo "Now run....";
die();
} else {
$this->conf_update($TXT_B, time());
}
echo 'Start
';
$_ip = $this->getip();
$updated = $j = $numcols = 0;
$ref_id = $this->m_array("select * from `".DB_PREFIX."fields` where name='$Referer_nev' and g='$g_id'", 'id');
// adatcsere:
$tim = $ip = $name = $mail = $status_id = '';
$data = $this->_json_decode($this->m_array("select * from `".DB_PREFIX."import` where g='$g' and pid = '$pid' order by id", 'row'));
$c = array();
$fields = array();
$vanreferer = 0;
$feliratkozasideje = 0;
foreach ($data as $cols) {
$j++;
$numcols++;
$_NEV = mysql_real_escape_string(($cols));
$tp = $this->inv_tp($_NEV, 1);
$_NEV = $tp['str'];
$tp = $tp['tp'];
$sql = $this->mq("select * from ".DB_PREFIX."fields where g='$g' and name='" . $_NEV . "'");
if ($cols == (__('Feliratkozás ideje'))) {
$c[$j] = 'datum';
$tim = $j;
$feliratkozasideje = 1;
} elseif ($cols == (__('IP cÃm'))) {
$c[$j] = 'ip';
$ip = $j;
} elseif ($cols == (__('E-mail cÃm')) ||
strtolower($cols) == (strtolower(__('E-mail'))) ||
strtolower($cols) == (strtolower(__('Email')))) {
$c[$j] = 'mail';
$mail = $j;
} elseif ($cols == (__('Státusz'))) {
$c[$j] = 'active';
$status_id = $j;
} elseif (strtolower($cols) == (__('id'))) {
$c[$j] = 'id';
$_ID_id = $j;
} elseif (mysql_num_rows($sql)) { // h ÃJ MezÅ, de már létezik akkor hozzáasduk a számát
$s = mysql_fetch_array($sql);
$c[$j] = intval($s['id']);
$tipus[$j] = $s['type'];
$option[$j] = $s['option'];
if ($tp) $tipus[$j] = $tp;
if ($s['id'] == $ref_id) $vanreferer = 1;
//megnézzük milyen tÃpus
if ($s['type'] > 1) // beolvassuk a mezÅket.
{
$m_sql = $this->mq("select * from ".DB_PREFIX."fields_fields where field_id='$s[id]' order by CHAR_LENGTH(name) desc");
$fields[$s['id']] = array();
while ($m_s = mysql_fetch_assoc($m_sql)) $fields[$s['id']][$m_s['id']] = $m_s['name'];
}
} elseif ($cols) // ha viszont nem létezik benne, akkor kreálunk és persze van abba az oszlopba valami
{
$id = $this->a_i("".DB_PREFIX."fields");;
$c[$j] = intval($id);
if ($tp) $tipus[$j] = $tp;
$this->mq("insert into ".DB_PREFIX."fields (g, name, hely, type) values
('$g','" . $_NEV . "','$id', '$tp')");
}
}
$_g = $this->m_array("select * from ".DB_PREFIX."groups where id='$g'");
//$now_time=$_GET['update_time'];
$now_time = $_GET['update_time'];
$e_data = 0;
// most feltöljük adatokkal
if (isset($_POST['kezd'])) $j = $_POST['kezd'];
else $j = 1;
if (!$this->m_array("select * from `".DB_PREFIX."sub_stat` where date=CURDATE() and g=$g"))
$this->mq("insert into `".DB_PREFIX."sub_stat` (date, g, c) values (CURDATE(), '$g', 0)");
$xrow = 2;
if (isset($_POST['fp'])) $xrow = $_POST['fp'] + 1;
$XX__SQL = $this->mq("select * from `".DB_PREFIX."import` where pid='$pid' and g='$g' and mod(`id`,$_X)=$_Y and x!=1");
while ($tmp = mysql_fetch_assoc($XX__SQL)) {
$row = $tmp['x'];
$this->mq("delete from `".DB_PREFIX."import` where id='$tmp[id]'");
$data = $this->_json_decode($tmp['row']);
//echo 'data';
//printr($data);
$j++;
//$n= ($data[$name-1]);
$m = strtolower(str_replace(array(' ', chr(194), chr(160), "\r", "\n", "\n"), '', ($data[$mail - 1])));
$t = ($data[$tim - 1]);
$ip_v = ($data[$ip - 1]);
if (!isset($data[$status_id - 1])) $data[$status_id - 1] = '';
$s_x = ($data[$status_id - 1]);
$___ID = ($data[$_ID_id - 1]); // xls-bern lévŠid, de ezzel nem foglalkozunk
$m = strtolower($m);
if ($status_id) {
if ($s_x == __('Visszapattant')) $s_x = '2';
elseif ($s_x == __('InaktÃv')) $s_x = '0';
elseif ($s_x == __('AktÃv')) $s_x = '1';
else $s_x = '4';
} else $s_x = '4';
if ($a = preg_match("/^([0-9]{2})[\/]*([0-9]{2})[\/]*([0-9]{4})$/", $t, $b))
$t = "$b[3]-$b[1]-$b[2]";
$t = str_replace('.', '-', $t);
$t = str_replace(' ', '', $t);
if (preg_match("/^[0-9]{4}[-]*[0-9]{2}[-]*[0-9]{2}$/", $t) && $now_time) $t = "'$t'";
else $t = "CURDATE()";
// if ( !$this->isValidEmail($m) || !$n) { $e_data++ ; $error=1; }
if (!$this->isValidEmail($m)) {
$e_data++;
$error = 1;
} else // nincs hiba
{
$mail_id = '';
$this->conf_update($TXT_A . 'db' . $_Y, $this->conf_read($TXT_A . 'db' . $_Y) + 1);
$_SESSION['db_users']++;
$id = 0;
$ipdatum = 'now()';
$v_C = $this->generateCode(40);
if (!$_g['d_user']) // ha nincs többszörös feliratkozás - frissÃtünk
{
if ($s = $this->m_array("select * from ".DB_PREFIX."users where `g`='$g' and mail='$m'")) {
$this->conf_update($TXT_A . 'upd' . $_Y, $this->conf_read($TXT_A . 'upd' . $_Y) + 1);
$id = $s['id'];
$ipdatum = "'$s[ipdatum]'";
$mail_id = $s['mail_id'];
$bounce = $s['bounce'];
$_ip = $s['ip'];
$omx = $s['omail'];
if (!$feliratkozasideje) $t = "'$s[datum]'";
if ($t == "''" || $t == "'0000-00-00'") $t = "'$s[datum]'";
$v_C = $s['verify_code'];
$u_id = $s['id'];
$status_log = $s['status_log'];
//if (!preg_match("/^[0-9]{4}[-]*[0-9]{2}[-]*[0-9]{2}$/", $data[$tim-1])) $t="'$s[datum]'";
if ($s_x == '4') $s_x = $s['active'];
$referer = $this->m_array("select * from ".DB_PREFIX."fields_data where `un`='$s[un]' and did='$ref_id'", 'text');
$this->mq("delete from ".DB_PREFIX."users where `g`='$g' and mail='$m'");
// if(!$vanreferer) $this->mq("delete from ".DB_PREFIX."fields_data where `un`='$id' and did!='$ref_id'");
// else $this->mq("delete from ".DB_PREFIX."fields_data where `un`='$id'");
}
}
if ($s_x == '4') $s_x = '1';
$tg_vdvdvu_id = $id ? $id : $this->a_i("".DB_PREFIX."users");
if (!$ip_v) $ip_v = $_ip;
if (!isset($omx)) $omx = '';
if (!isset($bounce)) $bounce = '';
if (!isset($status_log)) $status_log = '';
$m = addslashes($m);
$mail_id = $mail_id ? $mail_id : $this->mail_id($m);
//$mail_id='0';
//
$this->mq("insert into ".DB_PREFIX."users (`g`, mail, omail, mail_id, datum, ip, active, verify_code, id, ipdatum, bounce, status_log) values
('$g', '$m', '$omx', '$mail_id', $t, '$ip_v', $s_x , '$v_C', '$id', $ipdatum, '$bounce', '$status_log')");
$u_id = mysql_insert_id();
$this->writeStatusLog($u_id, 'import', $s_x);
$this->writeModLog($u_id);
if (!$id) $this->mq("update `".DB_PREFIX."sub_stat` set c=c+1 where date=CURDATE() and g=$g");
//egyéb adatok beszúrása
for ($i = 1; $i <= $numcols; $i++) {
if (!isset($c[$i])) $c[$i] = '';
if (is_int($c[$i])) {
if (!isset($data[$i - 1])) $data[$i - 1] = '';
$cols_string = (addslashes($data[$i - 1]));
$field_id = $c[$i];
$inttext = 0;
if ($tipus[$i] == 5) // dátum
{
$cols_string = str_replace(array(' ', "'"), '', $cols_string);
$cols_string = str_replace('.', '-', $cols_string);
if (!$cols_string) $cols_string = '0000-00-00';
if (preg_match("/^[0-9]{4}[-]*[0-9]{2}[-]*[0-9]{2}$/", $cols_string) && $now_time);
else
if (preg_match("/^([(0-9]+)?$/", $cols_string)) {
$exc_date = (int)($cols_string);
$cols_string = date('Y-m-d', ($exc_date - 25569) * 86400);
}
//
//echo "insert into ".DB_PREFIX."fields_data (un, date, did) values ('$u_id','$cols_string', '".$c[$i]."')";
//die();
//if(preg_match("/^([(0-9]+)?$/", $cols_string)) $cols_string = date('Y-m-d', (( (int)($cols_string) - 25569)*3600*24 ) + 10);
if ($cols_string) {
$this->mq("delete from ".DB_PREFIX."fields_data where `un`='$u_id' and did='" . $c[$i] . "'");
$this->mq("insert into ".DB_PREFIX."fields_data (un, date, did) values ('$u_id','$cols_string', '" . $c[$i] . "')");
}
continue;
} elseif ($tipus[$i] == 6) //szám
{
$cols_string = str_replace(' ', '', $cols_string);
if ($cols_string) {
$this->mq("delete from ".DB_PREFIX."fields_data where `un`='$u_id' and did='" . $c[$i] . "'");
$this->mq("insert into ".DB_PREFIX."fields_data (un, int_text, did) values ('$u_id','$cols_string', '" . $c[$i] . "')");
}
continue;
} elseif ($tipus[$i] == 3) // checkbox
{
$cols_string .= ';';//$cols_string);
$cols_string = str_replace('; ', ';', $cols_string);
$arr = explode(';', $cols_string);
$outt = array();
foreach ($arr as $v0) {
foreach ($fields[$field_id] as $k => $v)
if ($v && $v == $v0) {
$outt[] = $k;
break;
}
}
$cols_string = implode(';', $outt) . ';';
if ($cols_string) {
$this->mq("delete from ".DB_PREFIX."fields_data where `un`='$u_id' and did='" . $c[$i] . "'");
$this->mq("insert into ".DB_PREFIX."fields_data (un, text, did) values ('$u_id','$cols_string', '" . $c[$i] . "')");
}
continue;
} else {
if (isset($fields[$field_id])) if (is_array($fields[$field_id])) // ha az adott mezÅbe cuccok vanak:
{
reset($fields[$field_id]);
foreach ($fields[$field_id] as $k => $v) $cols_string = str_replace($v, $k, $cols_string);
$cols_string = str_replace(' ', '', $cols_string);
if (!strstr($cols_string, ';') && ($cols_string > 0 && $cols_string < 9223372036854775800)) $inttext = 1;
//echo "cols:|$cols_string| - $inttext
";
}
if ($inttext) {
$this->mq("delete from ".DB_PREFIX."fields_data where `un`='$u_id' and did='" . $c[$i] . "'");
$this->mq("insert into ".DB_PREFIX."fields_data (un, int_text, did) values ('$u_id','$cols_string', '" . $c[$i] . "')");
} else {
if ($tipus[$i] == '0' && $option[$i] == '1') $cols_string = ucwords(mb_convert_case($cols_string, MB_CASE_TITLE, "UTF-8"));
$this->mq("delete from ".DB_PREFIX."fields_data where `un`='$u_id' and did='" . $c[$i] . "'");
$this->mq("insert into ".DB_PREFIX."fields_data (un, text, did) values ('$u_id','$cols_string', '" . $c[$i] . "')");
}
}
}
}
}
if (time() - $t_1 > 10) {
$this->conf_delete($TXT_B);
exit;
die();
}
}
//fclose($handle);
}
function str_replace_deep($search, $replace, $subject)
{
if (is_array($subject)) {
foreach ($subject as &$oneSubject)
$oneSubject = $this->str_replace_deep($search, $replace, $oneSubject);
unset($oneSubject);
return $subject;
} else {
return str_replace($search, $replace, $subject);
}
}
function ajax_send($v)
{
$v = str_replace("'", "\'", $v);
$v = str_replace("\n", '\n', $v);
return $v;
}
function tiny_clean($text)
{
$text = str_replace(array('\n', '\r'), array("\n", "\r"), $text);
$text = str_replace(chr(194) . chr(160), ' ', $text); // utf-8as szóköz lecsrélése rendes szóközre
$text = str_replace('&', '&', stripslashes($text));
$text = str_replace(array('%7D', '%7B'), array('}', '{'), $text);
$text = str_replace(array('http://{', 'https://{', '&a={', '%7D', '%7B'), array('{', '{', '&a={', '}', '{'), $text);
preg_match_all('/()/', $text, $matches, PREG_SET_ORDER);
foreach ($matches as $val) {
$orig_str = $val[1] . $val[2] . $val[3];
$new_str = $val[1] . str_replace('%20', ' ', $val[2]) . $val[3];
$text = str_replace($orig_str, $new_str, $text);
}
return $text;
}
function stat_cache($date, $g, $up = -1, $down = -1, $send = -1, $read = -1)
{
$sql = $this->mq("select * from `".DB_PREFIX."stat_cache` where `date`='$date' and `g`='$g'");
if (!mysql_num_rows($sql))
$this->mq("insert into `".DB_PREFIX."stat_cache` (`date`, `g`) values ('$date', '$g')");
$set = ($up > -1 ? " ups='$up'" : '');
$set .= ($down > -1 ? (($set ? ' ,' : '') . " `downs`='$down'") : '');
$set .= ($send > -1 ? (($set ? ' ,' : '') . " `sendm`='$send'") : '');
$set .= ($read > -1 ? (($set ? ' ,' : '') . " `rm`='$read'") : '');
if ($set) {
$this->mq("update `".DB_PREFIX."stat_cache` set $set where `date`='$date' and `g`='$g'");
return 1;
} else return 0;
}
function stat_cache_2($tp, $date, $mid, $sendout = -1, $read = -1, $link = -1)
{
if ($tp == 'mail') $tp2 = 'mid';
else $tp2 = 'act';
$sql = $this->mq("select * from `".DB_PREFIX."stat_cache_$tp` where `date`='$date' and $tp2='$mid'");
if (!mysql_num_rows($sql))
$this->mq("insert into `".DB_PREFIX."stat_cache_$tp` (`date`, `$tp2`) values ('$date', '$mid')");
$set = ($sendout > -1 ? " `sendout`='$sendout'" : '');
$set .= ($read > -1 ? (($set ? ' ,' : '') . " `read`='$read'") : '');
$set .= ($link > -1 ? (($set ? ' ,' : '') . " `link`='$link'") : '');
if ($set) {
$this->mq("update `".DB_PREFIX."stat_cache_$tp` set $set where `date`='$date' and `$tp2`='$mid'");
return 1;
} else return 0;
}
function kitolt_cache($date)
{
global $_g;
//echo 'hó: ', substr($date, 5,2), 'nap:',substr($date, 8,2), 'év',substr($date, 0,4);
$dmk = mktime(0, 0, 0, substr($date, 5, 2), substr($date, 8, 2), substr($date, 0, 4));
//die($dmk);
for ($j = $dmk; $j < time(); $j += 24 * 3600) {
$date = date('Y-m-d' . "\r\n", $j);
if (!$this->m_array("select * from `".DB_PREFIX."stat_cache` where `g` = '$_g[id]' and date='$date'"))
$this->mq("insert into `".DB_PREFIX."stat_cache` (g, date) values ('$_g[id]', '$date')");
}
}
function stat_cache_refresh()
{
$ustat_unix = $this->m_array("select UNIX_TIMESTAMP(date) as date from `".DB_PREFIX."stat_cache` order by `date` desc", 'date');
if (!$ustat_unix) $ustat_unix = 0;
$ustat_date = date("Y-m-d", $ustat_unix);
// feliratkozások számának átmentése:
$sql = $this->mq("SELECT count( `datum` ) as `date_db`, datum, `g` FROM `".DB_PREFIX."users` where datum>='$ustat_date' group by `datum`, `g`");
$i = 0;
while ($s = mysql_fetch_assoc($sql)) {
if (!$i) $this->kitolt_cache($s['datum']);
$i++;
$this->stat_cache($s['datum'], $s['g'], $s['date_db']);
//if($i>30) break;
}
// leiratkozások átmásolása a unscr táblából
$sql = $this->mq("select `date`, `g`, count(`mid`) as db from `".DB_PREFIX."unscr` where `date`>='$ustat_date' group by `date`, `g`");
while ($s = mysql_fetch_assoc($sql)) {
$this->stat_cache($s['date'], $s['g'], -1, $s['db']);
}
// kiküldött levelek számának átmentése:
//SELECT count( `g` ) as `db`, FROM_UNIXTIME(`date`, '%Y-%m-%d') as D, `g` FROM `".DB_PREFIX."stat` where stat!='0000-00-00' group by `D`, `g`
$sql = $this->mq("SELECT count( `g` ) as `db`, FROM_UNIXTIME(`date`, '%Y-%m-%d') as D0, `g` FROM `".DB_PREFIX."stat` where `date`>='$ustat_unix' group by `D0`, `g`");
$i = 0;
while ($s = mysql_fetch_assoc($sql)) {
if (!$i) $this->kitolt_cache($s['D0']);
$i++;
$this->stat_cache($s['D0'], $s['g'], -1, -1, $s['db']);
}
// olvasott levelek számának átmentése:
$sql = $this->mq("SELECT count( `g` ) as `db`,
FROM_UNIXTIME(`date`, '%Y-%m-%d') as D, `g`, `stat` FROM
`".DB_PREFIX."stat` where stat!='0000-00-00' and `date`>='$ustat_unix' group by `stat`, `g`");
$i = 0;
while ($s = mysql_fetch_assoc($sql)) {
$i++;
$this->stat_cache($s['stat'], $s['g'], -1, -1, -1, $s['db']);
//if($i>30) break;
}
}
function kitolt_mail_cache($date)
{
//global $_g;
//echo 'hó: ', substr($date, 5,2), 'nap:',substr($date, 8,2), 'év',substr($date, 0,4);
$dmk = mktime(0, 0, 0, substr($date, 5, 2), substr($date, 8, 2), substr($date, 0, 4));
for ($j = $dmk; $j < time(); $j += 24 * 3600) {
$date = date('Y-m-d', $j);
if (!$this->m_array("select * from `".DB_PREFIX."stat_cache_mail` where `mid` = '$_GET[mail_statid]' and date='$date'"))
$this->mq("insert into `".DB_PREFIX."stat_cache_mail` (mid, date) values ('$_GET[mail_statid]', '$date')");
}
}
function stat_cache_refresh_mail($mid)
{
$ustat_unix = $this->m_array("select UNIX_TIMESTAMP(date) as date from `".DB_PREFIX."stat_cache_mail` where `mid`='$mid' order by `date` desc", 'date');
if (!$ustat_unix) $ustat_unix = 1;
$ustat_date = date("Y-m-d", $ustat_unix);
// kiküldések számának átmentése
$sql = $this->mq("SELECT
count( `mid` ) as `db`,
FROM_UNIXTIME(`date`, '%Y-%m-%d') as Di, `mid`
FROM `".DB_PREFIX."stat`
where `date`>='$ustat_unix' and mid='$mid' group by `Di`, `mid`");
$i = 0;
while ($s = mysql_fetch_assoc($sql)) {
if (!$i) $this->kitolt_mail_cache($s['Di']);
$i++;
$this->stat_cache_2('mail', $s['Di'], $s['mid'], $s['db']);
//echo 'dátum:',$s['D'], ':',$s['db'],'
';
}
// olvasott levelek számának átmentése:
$sql = $this->mq("SELECT count( `g` ) as `db`,
FROM_UNIXTIME(`date`, '%Y-%m-%d') as Di, `mid`, `stat` FROM
`".DB_PREFIX."stat` where stat!='0000-00-00' and `date`>='$ustat_unix' and mid='$mid' group by `stat`, `mid`");
$i = 0;
while ($s = mysql_fetch_assoc($sql)) {
$i++;
// $this->stat_cache_2('mail', $s['Di'], $s['mid'], -1, $s['db']);
$this->stat_cache_2('mail', $s['stat'], $s['mid'], -1, $s['db']);
// $this->stat_cache($s['stat'], $s['g'], -1,-1, -1, $s['db']);
//if($i>30) break;
}
// akciólinkek
$sql = $this->mq("SELECT count( `mid` ) as `db`, FROM_UNIXTIME(`date`, '%Y-%m-%d') as Di, `mid` FROM `".DB_PREFIX."act_stat`
where stat!='0000-00-00 00:00:00' and `date`>='$ustat_unix' and mid='$mid' group by `Di`, `mid`");
$i = 0;
while ($s = mysql_fetch_assoc($sql)) {
$i++;
$this->stat_cache_2('mail', $s['Di'], $s['mid'], -1, -1, $s['db']);
}
}
function stat_cache_refresh_act($act, $g)
{
$t = microtime(true);
$this->mq("update `".DB_PREFIX."act_stat` set statid = (select id from `".DB_PREFIX."stat` where
`".DB_PREFIX."stat`.`uid`=`".DB_PREFIX."act_stat`.`uid` and
`".DB_PREFIX."stat`.`date`=`".DB_PREFIX."act_stat`.`date` limit 0,1) where statid=0");
$ustat_unix = $this->m_array("select UNIX_TIMESTAMP(date) as date from `".DB_PREFIX."stat_cache_act` where `act`='$act' order by `date` desc", 'date');
if (!$ustat_unix) $ustat_unix = 1;
$ustat_date = date("Y-m-d", $ustat_unix);
// kiküldések számának átmentése
$sql = $this->mq("SELECT count( * ) as `db`, FROM_UNIXTIME(`date`, '%Y-%m-%d') as D, '$act' as `aid` FROM `".DB_PREFIX."stat` as s1
where g='$g' and date>='$ustat_unix' and ( select count(*) from ".DB_PREFIX."act_stat where aid='$act' and statid=s1.id) group by `D`");
$i = 0;
while ($s = mysql_fetch_assoc($sql)) {
@set_time_limit(30);
$i++;
$this->stat_cache_2('act', $s['D'], $s['aid'], $s['db']);
}
$t2 = microtime(true);
// echo "kiküldött levelek: ", $t2-$t, '
';
// olvasott levelek számának átmentése:
/* $sql = $this->mq("SELECT count( `aid` ) as `db`, FROM_UNIXTIME(`".DB_PREFIX."stat`.`date`, '%Y-%m-%d') as D, `aid`
FROM `".DB_PREFIX."act_stat` inner join `".DB_PREFIX."stat` on (`".DB_PREFIX."stat`.id=`".DB_PREFIX."act_stat`.statid)
where `".DB_PREFIX."stat`.stat!='0000-00-00' and `".DB_PREFIX."stat`.date>='$ustat_unix' and `".DB_PREFIX."act_stat`.aid='$act' group by `D`");Â */
$sql = $this->mq("SELECT count( * ) as `db`, FROM_UNIXTIME(`date`, '%Y-%m-%d') as D, '$act' as `aid` FROM `".DB_PREFIX."stat` as s1
where g='$g' and date>='$ustat_unix' and stat!='0000-00-00' and ( select count(*) from ".DB_PREFIX."act_stat where aid='$act' and statid=s1.id) group by `D`");
$i = 0;
while ($s = mysql_fetch_assoc($sql)) {
@set_time_limit(30);
$i++;
$this->stat_cache_2('act', $s['D'], $s['aid'], -1, $s['db']);
}
$t3 = microtime(true);
// echo "olvasott levelek: ", $t3-$t2, '
';
// akciólinkek
$sql = $this->mq("SELECT count( `aid` ) as `db`, DATE(`stat`) as D, `aid` FROM `".DB_PREFIX."act_stat` where stat>='$ustat_date' and aid='$act' group by `D`");
$i = 0;
while ($s = mysql_fetch_assoc($sql)) {
@set_time_limit(30);
$i++;
$this->stat_cache_2('act', $s['D'], $s['aid'], -1, -1, $s['db']);
}
$t4 = microtime(true);
// echo "kattintott levelek: ", $t4-$t3, '
';
}
function get_real_size($size = 0)
{
/// átváltani megára a számokat
if (!$size) {
return 0;
}
$scan['MB'] = 1048576;
$scan['Mb'] = 1048576;
$scan['M'] = 1048576;
$scan['m'] = 1048576;
$scan['KB'] = 1024;
$scan['Kb'] = 1024;
$scan['K'] = 1024;
$scan['k'] = 1024;
while (list($key) = each($scan)) {
if ((strlen($size) > strlen($key)) && (substr($size, strlen($size) - strlen($key)) == $key)) {
$size = substr($size, 0, strlen($size) - strlen($key)) * $scan[$key];
break;
}
}
return $size;
} // end function
function table_e($max, $v)
{
if (strlen($v) <= $max) {
return $v;
} else {
if (function_exists('mb_substr')) {
return mb_substr($v, 0, $max - 1, 'UTF-8') . 'â¦';
} else {
return substr($v, 0, $max - 1) . 'â¦';
}
}
}
function formatbytes($val, $digits = 3, $mode = "SI", $bB = "B")
{ //$mode == "SI"|"IEC", $bB == "b"|"B"
$si = array("", "k", "M", "G", "T", "P", "E", "Z", "Y");
$iec = array("", "Ki", "Mi", "Gi", "Ti", "Pi", "Ei", "Zi", "Yi");
switch (strtoupper($mode)) {
case "SI":
$factor = 1000;
$symbols = $si;
break;
case "IEC":
$factor = 1024;
$symbols = $iec;
break;
default:
$factor = 1000;
$symbols = $si;
break;
}
switch ($bB) {
case "b":
$val *= 8;
break;
default:
$bB = "B";
break;
}
for ($i = 0; $i < count($symbols) - 1 && $val >= $factor; $i++)
$val /= $factor;
$p = strpos($val, ".");
if ($p !== false && $p > $digits) $val = round($val);
elseif ($p !== false) $val = round($val, $digits - $p);
return round($val, $digits) . " " . $symbols[$i] . $bB;
}
function de($enc_text, $p, $iv_len = 32)
{
$enc_text = base64_decode($enc_text);
$n = strlen($enc_text);
$i = $iv_len;
$plain_text = '';
$iv = substr($p ^ substr($enc_text, 0, $iv_len), 0, 512);
while ($i < $n) {
$block = substr($enc_text, $i, 16);
$plain_text .= $block ^ pack('H*', md5($iv));
$iv = substr($block . $iv, 0, 512) ^ $p;
$i += 16;
}
return preg_replace('/\\x13\\x00*$/', '', $plain_text);
}
function replace($out, $j, $jj, $tp)
{
// méret
$s = $out[$j]['filesize'];
$out[$j]['filesize'] = $out[$jj]['filesize'];
$out[$jj]['filesize'] = $s;
// név
$s = $out[$j][$tp];
$out[$j][$tp] = $out[$jj][$tp];
$out[$jj][$tp] = $s;
// dátum
$s = $out[$j]['ntime'];
$out[$j]['ntime'] = $out[$jj]['ntime'];
$out[$jj]['ntime'] = $s;
return $out;
}
function n_f($x)
{
if (!$x) return '0';
return number_format($x, 0, ',', '.');
}
function n_fsz($x)
{
if (!$x) return '0';
$sz = number_format($x, 1, ',', '.');
if ($sz == '100,0') $sz = '100';
if ($sz == '0,0' && $x > 0) $sz = '>0';
return $sz;
}
function init_dir($dir, $order, $tp)
{
global $sn;
$i = 0;
if ($kvt = opendir($dir)) {
while (gettype($fajl = readdir($kvt)) != 'boolean') {
if (((($tp == "dir") ? is_dir("$dir$fajl") : is_file("$dir$fajl"))) && ($fajl != "..") && ($fajl != ".") && !(strstr($sn, $fajl) && $tp != 'dir')) {
$i++;
$out[$i][$tp] = $fajl;
if ($tp != 'dir') $out[$i]['filesize'] = filesize("$dir$fajl");
$out[$i]['ntime'] = date("Y-m-d H:i", filemtime("$dir$fajl"));
}
}
closedir($kvt);
} else return false;
$out[0][$tp] = $i;
if ($order == "name") {
for ($jj = 1; $jj <= $i; $jj++)
for ($j = $jj; $j <= $i; $j++)
if (strtolower(($out[$jj][$tp])) > strtolower(($out[$j][$tp]))) $out = $this->replace($out, $j, $jj, $tp);
}
if ($order == "fname") {
for ($jj = 1; $jj <= $i; $jj++)
for ($j = $jj; $j <= $i; $j++)
if (strtolower(($out[$jj][$tp])) < strtolower(($out[$j][$tp]))) $out = $this->replace($out, $j, $jj, $tp);
}
if ($order == "size") {
for ($jj = 1; $jj <= $i; $jj++)
for ($j = $jj; $j <= $i; $j++)
if (($out[$jj]['filesize']) > ($out[$j]['filesize'])) $out = $this->replace($out, $j, $jj, $tp);
}
if ($order == "fsize") {
for ($jj = 1; $jj <= $i; $jj++)
for ($j = $jj; $j <= $i; $j++)
if (($out[$jj]['filesize']) < ($out[$j]['filesize'])) $out = $this->replace($out, $j, $jj, $tp);
}
if ($order == "time") {
for ($jj = 1; $jj <= $i; $jj++)
for ($j = $jj; $j <= $i; $j++)
if (($out[$jj][ntime]) > ($out[$j][ntime])) $out = $this->replace($out, $j, $jj, $tp);
}
if ($order == "ftime") {
for ($jj = 1; $jj <= $i; $jj++)
for ($j = $jj; $j <= $i; $j++)
if (($out[$jj][ntime]) < ($out[$j][ntime])) $out = $this->replace($out, $j, $jj, $tp);
}
return $out;
}
function get_rnd_iv($iv_len)
{
$iv = '';
while ($iv_len-- > 0) {
$iv .= chr(mt_rand() & 0xff);
}
return $iv;
}
function encoding($x)
{
$m = '';
$n = preg_replace("/[^[:space:]a-zA-Z0-9-]/", "", $this->_en(str_replace('www.', '', $_SERVER['HTTP_HOST']) . strrev(str_replace('www.', '', $_SERVER['HTTP_HOST'])), 'Sen!_wgSiEte_tsof', 1));
for ($i = 0; $i < strlen(preg_replace("/[^[:space:]a-zA-Z0-9-]/", "", $this->_en(str_replace('www.', '', $_SERVER['HTTP_HOST']) . strrev(str_replace('www.', '', $_SERVER['HTTP_HOST'])), 'Sen!_wgSiEte_tsof', 1))); $i++) {
if ($i > 0 && ($i % 5) == 0) $m .= "-";
$m .= $n[$i];
}
return strtoupper(substr($m, 0, 41));
}
function en($plain_text, $p, $iv_len = 32)
{
$plain_text .= "\x13";
$n = strlen($plain_text);
if ($n % 16) $plain_text .= str_repeat("\0", 16 - ($n % 16));
$i = 0;
$enc_text = $this->get_rnd_iv($iv_len);
$iv = substr($p ^ $enc_text, 0, 512);
while ($i < $n) {
$block = substr($plain_text, $i, 16) ^ pack('H*', md5($iv));
$enc_text .= $block;
$iv = substr($block . $iv, 0, 512) ^ $p;
$i += 16;
}
return base64_encode($enc_text);
}
function get_rnd_iv2($iv_len)
{
$iv = '';
while ($iv_len-- > 0) {
$iv .= 'h';
}
return $iv;
}
function e()
{
global $_y, $__v, $x___X, $__SUBSCRIBER, $ajax;
$K = 'c';
$c = $this->conf_read(strrev($K . 'neci' . 'l'));
if (!isset($ajax)) $ajax = $this->get_rnd_iv2('A_JAX');
else $_y = 1;
if (isset($_SESSION['password'])) $_C = $this->encoding($_SESSION['password']);
else $_C = 0;
if (strrev(base64_encode($this->_en(strrev(str_replace('www.', '', $_SERVER['HTTP_HOST'])), strrev('eteisGVV')))) != $x___X) {
$_y = 0;
eval(strrev(";1=rre_mod$"));
}
// if($_C && (strtolower($c)!=strtolower(strrev($_C)) && $_y<=0))
if ($_C && (($c && (strtolower($c) != strtolower(strrev($_C))) || (!$c && $_y <= 0)))) {
if ($__SUBSCRIBER) die(base64_decode("PGh0bWw+PGhlYWQ+PHRpdGxlPldlYmdhbGFtYiAyPC90aXRsZT48L2hlYWQ+PGJvZHk+QSBo7XJsZXbpbGv8bGT1IHJlbmRzemVyIGplbGVubGVnIGluYWt07XYhPC9ib2R5PjwvaHRtbD4="));
require strrev('php.noitartsiger.ludom');
exit();
}
return ((strtolower($c) != strtolower(strrev($_C))) ? 0 : 1);
}
function _en($plain_text, $p, $iv_len = 32)
{
$plain_text .= "\x13";
$n = strlen($plain_text);
if ($n % 16) $plain_text .= str_repeat("\0", 16 - ($n % 16));
$i = 0;
$enc_text = $this->get_rnd_iv2($iv_len);
$iv = substr($p ^ $enc_text, 0, 512);
while ($i < $n) {
$block = substr($plain_text, $i, 16) ^ pack('H*', md5($iv));
$enc_text .= $block;
$iv = substr($block . $iv, 0, 512) ^ $p;
$i += 16;
}
return base64_encode($enc_text);
}
function sql_dump($file)
{ //echo 'valami';
global $out;
$i = 0;
if (is_uploaded_file($_FILES[$file]['tmp_name'])) {
$tp = $_FILES[$file]['type'];
$n = explode('.', $_FILES[$file]['name']);
reset($n);
if (strtolower($n[count($n) - 1]) != 'sql') {
$out = __('Hibás a feltöltött fájl formátuma! Csak a WEBGALAMB által lementett fájl tölthetŠide fel!');
return false;
}
if (strtolower($n[count($n) - 1]) == 'sql') {
move_uploaded_file($_FILES[$file]['tmp_name'], 'sql.sql');
$chf = $this->conf_read("chmod_file");
if ($chf > 100 && $chf <= 777) {
$e = "chmod('sql.sql', 0" . (int)($chf) . ");";
eval($e);
}
if (is_file('sql.sql')) {
$t1 = time();
$bufferSize = 5120;
$fajl = fopen('sql.sql', "rb");
$fstring = '';
while (!feof($fajl)) {
$fstring .= fread($fajl, $bufferSize);
}
if (substr($fstring, 0, 22) != 'SET CHARACTER SET utf8') {
$out = __('Hibás fájl! Csak a WEBGALAMB által lementett fájl tölthetŠide fel!');
return false;
}
$tmp = array();
$tmp = $this->sql_explode($fstring);
while ($x = each($tmp)) {
$i++;
//echo $x[1].'
';;
$this->mq($x[1]);
}
fclose($fajl);
$t2 = time();
$out = sprintf(__("A teljes frissÃtés %s másodpercet vett igénybe!"), ($t2 - $t1)) . "\n" . __("Adatbázis feltöltés sikeres!");
}
}
// adatbázis jelszó visszaállÃtása a mostanira
$this->mq("UPDATE `".DB_PREFIX."config` set conf_value=PASSWORD('$_SESSION[password]') where wg_conf='admin_password'");
@unlink('sql.sql');
}
}
function do_post_request($url, $data, $optional_headers = null)
{
$start = strpos($url, '//') + 2;
$end = strpos($url, '/', $start);
$host = substr($url, $start, $end - $start);
$domain = substr($url, $end);
$fp = fsockopen($host, 80);
if (!$fp) return null;
fputs($fp, "POST $domain HTTP/1.1\n");
fputs($fp, "Host: $host\n");
if ($optional_headers) {
fputs($fp, $optional_headers);
}
fputs($fp, "Content-type: application/x-www-form-urlencoded\n");
fputs($fp, "Content-length: " . strlen($data) . "\n\n");
fputs($fp, "$data\n\n");
$response = "";
while (!feof($fp)) {
$response .= fgets($fp, 1024);
}
fclose($fp);
return $response;
}
function error($str)
{
$x = strlen($str);
if ($x) {
if ($x <= 2) return array($str);
elseif ($x > 4) {
$elso = $str % 100;
$masodik = (int)(substr((string)($str % 10000), 0, strlen((string)($str % 10000)) - 2));
$harmadik = (int)(substr((string)($str), 0, $x == 6 ? 2 : 1));
return array($elso, $masodik, $harmadik);
} else {
$elso = $str % 100;
$masodik = (int)(substr((string)($str), 0, $x == 4 ? 2 : 1));
return array($elso, $masodik);
}
} else return '';
}
}//mainclass
// Képek mappájának létrehozása és a nem használt képek törlése a mappából ha az már létezik
function updatingPicturesFolders($imgdir, $text)
{
if (!file_exists($imgdir)) {
global $main;
$chd = (int)($main->conf_read("chmod_dir"));
mkdir($imgdir);
if ($chd > 100 && $chd <= 777) {
$e = "chmod('{$imgdir}/', 0" . (int)($chd) . ");";
eval($e);
}
}
if (!get_magic_quotes_gpc()) {
$text = stripslashes($text);
}
$str = str_replace("\r\n", " ", $text);
$kvt = opendir($imgdir);
while (false !== ($fajl = readdir($kvt))) {
if (file_exists($imgdir . '/' . $fajl) && $fajl != ".." && $fajl != "." && $fajl != "index.php") {
if (!strstr($str, $fajl))
unlink($imgdir . '/' . $fajl);
}
}
}
@ini_set('session.cookie_httponly', 1);
@session_name("webgalamb6");
@session_start();
if (isset($_POST['loginpassword'])) session_regenerate_id();
$bounce = array(
0 => 'domain error: nem létezŠdomain',
1 => "#5.2.2: over quota: betelt postafiók",
2 => "#5.1.1: user unknown: nem létezŠfelhasználó",
3 => "domain error: elérhetetlen domain",
4 => "Túl hosszú üzenet, cÃmzett nem tudja fogadni",
5 => "#5.4.4: Unable to route: Malformed or unexpected name server reply
továbbÃtás nem lehetséges: rosszul formázott vagy váratlan névszerver válasz",
6 => "#2.0.0: (nonstandard success response, see rfc876): nem szabványos, sikeres üzenet (lásd: rfc876)",
7 => "#2.1.1: System status, or system help reply: rendszer állapot vagy rendszer segÃtség válasz",
8 => "#2.1.4: Help message: segÃtŠüzenet",
9 => "#2.2.0: Service ready: szolgáltatás rendben",
10 => "#2.2.1: Service closing transmission channel: a szolgáltatás megszakÃtotta az átvitelt",
11 => "#2.5.0: Requested mail action okay, completed: kért akció elvégezve",
12 => "#2.5.1: User not local; will forward to : felhasználó nincs itthon továbbÃtva ide: ",
13 => "#3.5.4: Start mail input; end with .: mail bemenet végzÅdese: .",
14 => "#4.2.1: Service not available, closing transmission channel: szolgáltatás (domain) nem elérhetÅ",
15 => "#4.5.0: Requested mail action not taken: mailbox unavailable: elérhetetlen e-mail fiók",
16 => "#4.5.1: Requested action aborted: local error in processing: helyi hiba a feldolgozásban",
17 => "#4.5.1: Requested action not taken: insufficient system storage: a kért akció nincs elvégezve: kevés rendszer tárolókapacitás",
18 => "#5.0.1: Syntax error in parameters or arguments: formátumhiba a paraméterekben vagy a változókban",
19 => "#5.0.2: Command not implemented: nem megvalósÃtott parancs",
20 => "#5.0.3: Bad sequence of commands: rossz sorrendű utasÃtások",
21 => "#5.0.4: Command parameter not implemented: a paraméter nem megvalósÃtott",
22 => "#5.1.3: bad address syntax: Hibás szintaktikájú e-mail cÃm",
23 => "#5.1.5: Error on maildir delivery. Message blocked.: A level kézbesÃtése nem sikerült, a levelet a cÃmzett blokkolta",
24 => "#5.2.1: does not accept mail (see rfc1846): valamiért nem fogadja el az emailt",
25 => "#5.3.0: Access denied: A fogadó szerver elutasÃtotta a levelet",
26 => "#5.4.2: Bad connection: Hibás kapcsolat/adatátviteli hiba",
27 => "#5.4.6: Routing loop detected: routing hurok észlelve",
28 => "#5.5.1: Requested action not taken: mailbox unavailable: elérhetetlen e-mail fiók",
29 => "#5.5.1: User not local; please try : nincs itthon próbáld a cÃmet",
30 => "#5.5.3: Requested action not taken: mailbox name not allowed: nem engedélyezett e-mail fióknév",
31 => "#5.5.4: Transaction failed: a tranzakció nem sikerült",
32 => "#5.6.1: Body type not supported by Remote Host: levéltörzs tipusa nem támogatott a távoli hoston",
33 => "#5.6.2: SMTP cannot transfer messages with partial final lines: az smtp szerver nem tudja továbbÃtani az üzenetet részleges utolsó sorokkal",
34 => "#5.7.1: Relay access denied: közvetett hozzáférés elutasÃtva",
35 => "#5.0.0: Felismerhetetlen erÅs hiba (általában spam hiba)!",
36 => "#4.4.7 Timeout error: idÅtúllépési hiba",
37 => "ismeretlen hiba",
38 => 'E-mail cÃm szintaktikai hiba'
);
$out = '';
$out_alert2 = '';
require_once('class.wg7.php');
if (!extension_loaded('mysql')) {
require_once('mysqli/mysql2i.class.php');
}
if (is_file('files/wg7conf.php')) {
$wgconf = 'files/wg7conf.php';
} elseif (is_file('../files/wg7conf.php')) {
$wgconf = '../files/wg7conf.php';
} else {
$wgconf = str_replace(DIRECTORY_SEPARATOR . 'system', '', __DIR__ . DIRECTORY_SEPARATOR . 'files' . DIRECTORY_SEPARATOR . 'wg7conf.php');
}
//if (is_file($wgconf)) {
@include_once($wgconf);
try
{
if (!$connection = mysql_connect(DB_HOST, DB_USER, DB_PASSWORD)) {
throw new Exception('Nem sikerült a MySQL adatbázishoz kapcsolódni!
Hibás MySQL kiszolgáló vagy felhasználónév vagy jelszó!');
} elseif(!mysql_select_db( DB_DATABASE, $connection )) {
throw new Exception('MySQL adatbázis hiba!
A(z) "'.DB_USER.'" adatbázis felhasználónak nincs megfelelŠjogosultsága a(z) "'.DB_DATABASE.'" adatbázis használatához!');
} elseif(mysql_query('select 1 from `'.DB_PREFIX.'config` LIMIT 1') === FALSE) {
throw new Exception('Nem találom a Webgalambhoz tartozó MySQL adatbázis táblákat!');
} else {
mysql_query("SET SQL_MODE=''");
mysql_query("set character set utf8");
mysql_query("SET NAMES utf8");
}
}
catch(Exception $e)
{
echo 'MySQL hiba'.$e->getMessage().'
';
die();
}
/*
} else {
die('Could not find configuration file');
}
*/
if (!get_magic_quotes_gpc()) {
$_POST = addslashes_array($_POST);
$_GET = addslashes_array($_GET);
}
if (get_magic_quotes_gpc()) {
$_POST = stripslashes_array($_POST);
$_GET = stripslashes_array($_GET);
$_POST = addslashes_array($_POST);
$_GET = addslashes_array($_GET);
}
//eval(base64_decode($_sql));
$main = new $c();
//$_SERVER['ORIG_HTTP_HOST'] = $_SERVER['HTTP_HOST'];
$_SERVER['HTTP_HOST'] = $main->conf_read('domain');
$d = explode('-', base64_decode($main->de(base64_decode($$x), 'WU_wTENg____=')));
date_default_timezone_set('Europe/Budapest');
$x = (mktime(23, 59, 59, $d[1], $d[2], $d[0]) - time()) / 3600 / 24;
$_y = (ceil($x * 10) / 10);
$y = mt_rand();
$y = substr(sha1($y), 0, 6);
$__v = $main->e();
$string = str_replace(array('0', 'O', 'o'), rand(1, 9), $y);
$_prg_dir = $main->conf_read("wg_dir");
$wg_port = $main->conf_read("fsock_port");
if ($wg_port == 80 || $wg_port == 443)
$wg_port = '';
define('WG_PROTOCOL', ($main->conf_read("https") ? 'https' : 'http'));
define('WG_VERSION', $main->conf_read("ver"));
define('WG_URL', WG_PROTOCOL . '://' . $main->conf_read("domain") . ($wg_port ? ':' . $wg_port : '') . '/' . $main->conf_read("wg_dir"));
//die();
$Referer_nev = __('Feliratkozási URL');
if (isset($_GET['newsessid'])) // új munkamenet azonosÃtó generálása, régi eldobása
{
session_start();
session_regenerate_id();
session_destroy();
unset($_SESSION);
session_start();
header('Location: wg7.php');
die();
}
?>