$dl_kategs=array(
1 => array(
"hu" => "Engedélyokiratok",
"en" => "Engedélyokiratok",
"ru" => "Engedélyokiratok"),
2 => array(
"hu" => "Biztonsági adatlapok, használati útmutatók",
"en" => "Biztonsági adatlapok, használati útmutatók",
"ru" => "Biztonsági adatlapok, használati útmutatók"),
3 => array(
"hu" => "Egyéb tanúsítványok",
"en" => "Egyéb tanúsítványok",
"ru" => "Egyéb tanúsítványok"),
4 => array(
"hu" => "Prospektusok, termékismertetők",
"en" => "Prospektusok, termékismertetők",
"ru" => "Prospektusok, termékismertetők"),
5 => array(
"hu" => "Szakmai cikkek, információk",
"en" => "Szakmai cikkek, információk",
"ru" => "Szakmai cikkek, információk")
);
?>
function DB_connect()
{
global $database;
#$GLOBALS["db_link"]=@mysqli_connect($GLOBALS["db_host"], $GLOBALS["db_user"], $GLOBALS["db_pass"], $GLOBALS["db_name"]);
$GLOBALS["db_link"]=@mysqli_connect($database["server"], $database["user"], $database["password"], $database["database"]);
if (mysqli_connect_errno())
exit("Connect failed: ".mysqli_connect_error());
mysqli_query($GLOBALS["db_link"], "SET NAMES UTF8");
mysqli_set_charset($GLOBALS["db_link"], "utf8");
}
function DoSQL($sqlstr, $debug=0)
{
global $_config, $base_dir;
if ($GLOBALS['errors'])
{
$result=mysqli_query($GLOBALS["db_link"], $sqlstr) or die ("MYSQL ERROR: ".mysqli_error($GLOBALS["db_link"])."
SQL: $sqlstr");
}
else
{
$result=mysqli_query($GLOBALS["db_link"], $sqlstr);
if (mysqli_error($GLOBALS['db_link']))
{
file_put_contents($base_dir."sqldebug.txt", $_SERVER['REQUEST_URI']."\n".mysqli_error($GLOBALS['db_link'])."\n$sqlstr\n".print_r(debug_backtrace(), true));
mail('nand@item.hu', "{$_config['site_name']} SQL error", $_SERVER['REQUEST_URI']."\n".mysqli_error($GLOBALS['db_link'])."\n$sqlstr\n".print_r(debug_backtrace(), true));
die ("REQUEST ERROR");
}
}
if ($debug==1)
{
echo "
SQL debug: $sqlstr";
}
return $result;
}
function OneObject($str, $debug=0)
{
$sqlres=DoSQL($str, $debug);
$obj=mysqli_fetch_object($sqlres);
return($obj);
}
function OneData($str, $debug=0)
{
$sqlres=DoSQL($str, $debug);
$arr=mysqli_fetch_array($sqlres);
return($arr[0]);
}
function OneArray($str, $debug=0)
{
$sqlres=DoSQL($str, $debug);
$obj=mysqli_fetch_array($sqlres);
return($obj);
}
function mres($string)
{
return mysqli_real_escape_string($GLOBALS["db_link"], $string);
}
function DB_fetch_array($result)
{
if (is_object($result)){
return mysqli_fetch_array($result);
}
else{
echo 'DB_fetch_array : hibás argumentum!
';
return false;
}
}
function DB_fetch_assoc($result)
{
if (is_object($result)){
return mysqli_fetch_assoc($result);
}
else{
echo 'DB_fetch_assoc: hibás argumentum!
';
return false;
}
}
function DB_num_rows($result){
return mysqli_num_rows($result);
}
function DB_affected_rows(){
return mysqli_affected_rows($GLOBALS["db_link"]);
}
function DB_insert_id(){
return mysqli_insert_id($GLOBALS["db_link"]);
}
function n_imgresize($inputfile, $outputfile, $width, $height, $force_resize_if_smaller=FALSE)
{
$filename = $inputfile;
// Get new dimensions
list($width_orig, $height_orig) = getimagesize($filename);
if ((($width_orig>$width) || ($height_orig>$height)) || ($force_resize_if_smaller))
{
$ratio_orig = $width_orig/$height_orig;
if ($width/$height > $ratio_orig) {
$width = $height*$ratio_orig;
} else {
$height = $width/$ratio_orig;
}
/*
// Resample
$image_p = imagecreatetruecolor($width, $height);
$picsize=GetImageSize($filename);
switch($picsize[2])
{
case '1': $image = imagecreatefromgif($filename); break;
case '2': $image = imagecreatefromjpeg($filename); break;
case '3': $image = imagecreatefrompng($filename); break;
}
imagecopyresampled($image_p, $image, 0, 0, 0, 0, $width, $height, $width_orig, $height_orig);
*/
// Resample
$image_p = imagecreatetruecolor($width, $height);
$picsize=GetImageSize($filename);
switch($picsize[2])
{
case '1': $image = imagecreatefromgif($filename); break;
case '2': $image = imagecreatefromjpeg($filename); break;
case '3': $image = imagecreatefrompng($filename);
imageAlphaBlending($image, true);
imageSaveAlpha($image, true);
imagesavealpha($image_p, true);
$trans_colour = imagecolorallocatealpha($image_p, 0, 0, 0, 127);
imagefill($image_p, 0, 0, $trans_colour);
break;
}
imagecopyresampled($image_p, $image, 0, 0, 0, 0, $width, $height, $width_orig, $height_orig);
// Output
#imagejpeg($image_p, null, 100);
switch($picsize[2])
{
case '1': imagegif($image_p, $outputfile); break;
case '2': imagejpeg($image_p, $outputfile); break;
case '3': imagepng($image_p, $outputfile); break;
}
// Output
if ($outputfile)
imagejpeg($image_p, $outputfile);
else
imagejpeg($image_p);
}
}
function n_imgcrop($inputfile, $outputfile, $tnw, $tnh)
{
$image = imagecreatefromjpeg($inputfile);
$thumb_width = $tnw;
$thumb_height = $tnh;
$width = imagesx($image);
$height = imagesy($image);
$original_aspect = $width / $height;
$thumb_aspect = $thumb_width / $thumb_height;
if ( $original_aspect >= $thumb_aspect )
{
// If image is wider than thumbnail (in aspect ratio sense)
$new_height = $thumb_height;
$new_width = $width / ($height / $thumb_height);
}
else
{
// If the thumbnail is wider than the image
$new_width = $thumb_width;
$new_height = $height / ($width / $thumb_width);
}
$thumb = imagecreatetruecolor( $thumb_width, $thumb_height );
// Resize and crop
imagecopyresampled($thumb,
$image,
0 - ($new_width - $thumb_width) / 2, // Center the image horizontally
0 - ($new_height - $thumb_height) / 2, // Center the image vertically
0, 0,
$new_width, $new_height,
$width, $height);
imagejpeg($thumb, $outputfile);
}
function n_imgfill($inputfile, $thumb_width, $thumb_height)
{
$thumb = imagecreatetruecolor( $thumb_width, $thumb_height );
$picsize=GetImageSize($inputfile);
switch($picsize[2])
{
case '2':
$image = imagecreatefromjpeg($inputfile);
$white = imagecolorallocate($thumb, 255, 255, 255);
imagefilledrectangle($thumb, 0, 0, $thumb_width, $thumb_height, $white);
break;
case '3':
$image = imagecreatefrompng($inputfile);
imageAlphaBlending($image, true);
imageSaveAlpha($image, true);
imagesavealpha($thumb, true);
$trans_colour = imagecolorallocatealpha($thumb, 0, 0, 0, 127);
imagefill($thumb, 0, 0, $trans_colour);
break;
}
#debug($picsize);
#n_imgresize($inputfile, "tmpimg.jpg", $thumb_width, $thumb_height, false);
#$image = imagecreatefromjpeg("tmpimg.jpg");
$width_copy=imagesx($image);
$height_copy=imagesy($image);
$x=round($thumb_width/2)-round($width_copy/2);
$y=round($thumb_height/2)-round($height_copy/2);
imagecopy($thumb, $image, $x, $y, 0, 0, $width_copy, $height_copy);
switch($picsize[2])
{
case '2': imagejpeg($thumb, $inputfile); break;
case '3': imagepng($thumb, $inputfile); break;
}
#imagejpeg($thumb, $outputfile);
imagedestroy($thumb);
imagedestroy($image);
#@unlink("tmpimg.jpg");
}
function lid()
{
return OneData("SELECT LAST_INSERT_ID()");
}
function debug($var)
{
echo "
"; print_r($var); echo ""; } function uzenet($szoveg) { if (is_array($szoveg)) $sz=implode("
".sprintf($lng['utmutato_letoltes'], $row['utmutato_hu'])."
"; } if (strlen($row['utmutato_en']) && ($_SESSION['lang']=='en')) { $text.="".sprintf($lng['utmutato_letoltes'], $row['utmutato_en'])."
"; } if (strlen($row['utmutato_ru']) && ($_SESSION['lang']=='ru')) { $text.="".sprintf($lng['utmutato_letoltes'], $row['utmutato_ru'])."
"; } # youtube link csere preg_match_all( '/https:\/\/(?:www\.)?youtu(?:be\.com\/watch\?v=|\.be\/)([\w\-\_]*)?/i', #'/http(?:s?):\/\/(?:www\.)?youtu(?:be\.com\/watch\?v=|\.be\/)([\w\-\_]*)(&(amp;)?[\w\?=]*)?/i', $text, $matches ); #$text.=print_r($matches, true); foreach($matches[0] AS $key => $value) { if (strpos($value, ' ')>0) $value=substr($value, 0, strpos($value, ' ')); if (strpos($value, '<')>0) $value=substr($value, 0, strpos($value, '<')); $text=str_replace( array($value), #array("$value"), '', $text); } # /youtube link csere if (strstr($row['css_classes'], "leafWrapper")) { $html[] = "{$title} | |||
{$lng['kontroll_tonna']} | {$lng['kezelt_terulet_tonna']} | {$lng['novekmeny']} | {$lng['szazalek']} |
{$row['kontroll_tonna']} | {$row['kezelt_terulet_tonna']} | {$row['novekmeny']} | {$row['szazalek']} % |