$dni = array (1=>"Pondelok","Utorok","Streda","tvrtok","Piatok","Sobota","Nedea"); // dni v tyzdni
function head($title,$refresh='') // hlavicka strnky
{
Header("Pragma: No-cache");
Header("Cache-Control: no-cache");
Header("Expires: ".GMDate("D, d M Y H:i:s")." GMT");
printf('
%s
%s
',$title,$refresh);
}
function napojenie($_server = '') { // napojenie na DB
global $_DB, $_DBC;
$s = mysql_connect ($_DB['server'.$_server], $_DB['user'.$_server], $_DB['passw'.$_server]);
$v = mysql_select_db($_DB['db'.$_server]);
if (!$s || !$v) die("Database ERROR!");
return $s;
}
function FTPchmod($adr,$mode) {
global $_CFG;
$conn_id = ftp_connect($_CFG['ftp_server']);
$login_result = ftp_login($conn_id, $_CFG['ftp_user'], $_CFG['ftp_passw']);
if ((!$conn_id) || (!$login_result)) {
echo "error creating image";
exit;
}
/*
$upload = ftp_put($conn_id, $destination_file, $source_file, FTP_BINARY);
if (!$upload) echo "FTP upload has failed!";
else echo "Uploaded $source_file to $ftp_server as $destination_file";
*/
$chmod_cmd="CHMOD ".$mode." ".$adr;
$chmod=ftp_site($conn_id, $chmod_cmd);
ftp_close($conn_id);
}
function generate_thumb($pol) {
list($sizex, $sizey, $type, $attr) = GetImageSize($pol);
$im_in = ImageCreateFromJpeg($pol);
if ($sizex > 1024 || $sizey > 768) {
$im_outn_r = str_replace('.jpg', '-r.jpg', $pol);
//fwrite($f, "\nrenamed: $im_outn_r");
if ($sizey < $sizex) {
$ratio = $sizey / $sizex;
$sizex_out = 1024;
$sizey_out = round($ratio*$sizex_out);
}
else {
$ratio = $sizex / $sizey;
$sizey_out = 768;
$sizex_out = round($ratio*$sizey_out);
}
$im_out = ImageCreateTrueColor($sizex_out, $sizey_out);
ImageCopyResampled($im_out, $im_in, 0, 0, 0, 0, $sizex_out, $sizey_out, $sizex, $sizey);
$ok = ImageJpeg($im_out, $im_outn_r);
ImageDestroy($im_out);
if ($ok) {
ImageDestroy($im_in);
$sizex = $sizex_out;
$sizey = $sizey_out;
Unlink($pol);
rename($im_outn_r, $pol);
}
$im_in = ImageCreateFromJpeg($pol);
}
// urobime thumbnail
$sizex_out = 120;
$sizey_out = 90;
$im_outn_t = str_replace('.jpg', '_small.jpg', $pol);
$ratio_d = 1.333333333333;
$ratio = $sizex / $sizey;
$ratio_y = $sizey / $sizey_out;
$ratio_x = $sizex / $sizex_out;
if ($ratio >= 1.33) {
$starty_in = 0;
$startx_in = round(($sizex - $ratio_y * $sizex_out) / 2);
$sizex = round($ratio_y * 120);
}
else {
$startx_in = 0;
$starty_in = round(($sizey - $ratio_x * $sizey_out) / 2);
$sizey = round($ratio_x * 90);
}
// printf(' sizex: %s sizey: %s ratio: %s sizex_out: %s sizey_out: %s ', $sizex, $sizey, $ratio_x , $sizex_out, $sizey_out);
$im_out = ImageCreateTrueColor($sizex_out, $sizey_out);
ImageCopyResampled($im_out, $im_in, 0, 0, $startx_in, $starty_in, $sizex_out, $sizey_out, $sizex, $sizey);
ImageJpeg($im_out, $im_outn_t);
ImageDestroy($im_out);
ImageDestroy($im_in);
}
function generate_link($p, $adr, $index, $id_obr) {
$fil = explode("_",$p);
$obrazok=$adr.$p;
if (is_file($obrazok) && $fil[1] != "small.jpg") {
$bfile = explode(".",$p);
if (!is_file($adr.$bfile[0].'_small.jpg') && $bfile[count($bfile)-1]=="jpg")
generate_thumb($obrazok);
list($sizex, $sizey, $type, $attr) = GetImageSize($obrazok);
$java = sprintf("javascript: window.open('/obr.php?obrazok=%s','WC%s','toolbar=no,location=no,directories=no,status=no,left=0, top=0, scrollbars=no,resizable=no,copyhistory=no,width=%s,height=%s');", $id_obr, $index, $sizex+2, $sizey+32);
$output = sprintf(' ', $java, $adr.$bfile[0]);
return $output;
}
}
function gen_hs_link($p, $adr, $id_group = false) {
$fil = explode("_",$p);
$obrazok = $adr.$p;
if (is_file($obrazok) && $fil[1] != "small.jpg") {
$bfile = explode(".",$p);
if (!is_file($adr.$bfile[0].'_small.jpg') && $bfile[count($bfile)-1]=="jpg") {
generate_thumb($obrazok);
}
$group = $id_group ? ",{slideshowGroup: 'group".$id_group."'}" : '';
$output = ' ';
return $output;
}
}
function get_menu($level) {
switch ($level) {
case 'fotky':
$m1=sprintf('',$level,$level,$level);
break;
case 'linky':
$m2=sprintf('',$level,$level,$level);
break;
}
$result=sprintf('
Fotky %sLinky %s
',$m1,$m2);
return $result;
}
function generate_combo($pole, $post) {
foreach ($pole as $key => $val) $_sel .= sprintf('%s ', $key, $post==$key ? 'selected' : '', $val);
return $_sel;
}
function mysql_insert($required, $post, $table, $debug = false, $link = false) {
$fields = array();
$values = array();
if ($post == false) {
$post = $required;
$required = array_keys($required);
}
foreach ($required as $val) {
$fields[] = $val;
$values[] = sprintf("'%s'", addslashes(trim($post[$val])));
}
if ($debug) {
printf("[ INSERT INTO %s (%s) VALUES (%s) ] ", $table, implode(',', $fields), implode(',', $values));
}
if ($link)
$q = mysql_query(sprintf("INSERT INTO %s (%s) VALUES (%s)", $table, implode(',', $fields), implode(',', $values)), $link);
else
$q = mysql_query(sprintf("INSERT INTO %s (%s) VALUES (%s)", $table, implode(',', $fields), implode(',', $values)));
if (!$q) {
echo ''.($link ? mysql_error($link) : mysql_error()).'!!!
';
}
$iid = $link ? mysql_insert_id($link) : mysql_insert_id();
return $iid;
}
function mysql_update($required, $post, $table, $where = 1, $debug = false) {
$values = array();
if ($post == false) {
$post = $required;
$required = array_keys($required);
}
foreach ($required as $val)
$values[] = sprintf("%s = '%s'", $val, addslashes(trim($post[$val])));
if ($debug) {
printf("[ UPDATE %s SET %s WHERE %s LIMIT 1 ] ", $table, implode(',', $values), $where);
}
$q = mysql_query(sprintf("UPDATE %s SET %s WHERE %s LIMIT 1 ", $table, implode(',', $values), $where));
return($q);
}
function get_album_setup() {
napojenie();
$q = mysql_query("SELECT * FROM fotky_setup WHERE id = 1 LIMIT 1");
return mysql_fetch_array($q, MYSQL_ASSOC);
}
function do_login($_meno, $_heslo) {
napojenie();
$_heslo = md5($_heslo);
$q = mysql_query(sprintf("SELECT * FROM users WHERE login = %d && heslo = '%s'", $_meno, $_heslo)) or die(mysql_error());
if (mysql_num_rows($q) == 1) {
$z = mysql_fetch_array($q, MYSQL_ASSOC);
$_SESSION['name'] = $z['meno'];
$_SESSION['admin'] = (int)$z['admin'];
return (int)$z['id'];
}
else
return false;
}
function logout() {
unset($_SESSION['name']);
unset($_SESSION['user']);
unset($_SESSION['admin']);
}
function is_email($var) {
$tmp = explode('@', $var);
if (count($tmp == 2)) {
$tmp = explode('.', $tmp[1]);
if (count($tmp) < 2) return false;
}
else
return false;
return true;
}
function get_alt_name ($_dir, $_name, $_ext) {
$i = 0;
do {
$i++;
} while (file_exists($_dir.$_name.'-'.$i.'.'.$_ext));
return $_name.'-'.$i.'.'.$_ext;
}
function get_ext($name) {
$tmp = explode(".",$name);
$_result = array();
$_result['ext'] = $tmp[count($tmp)-1];
if (count($tmp) > 2) {
unset($tmp[count($tmp)-1]);
$_result['name'] = implode('.',$tmp);
}
else {
$_result['name'] = $tmp[0];
}
return $_result;
}
function r_diac($_input) {
return strtr($_input,"Aͼݎ",
"AAACDEEILLNOOORRSSTUUUYZaacdeeeillnooorrsstuuuyz");
}
function urlize($inp) {
$inp = strip_tags($inp);
$inp = strtolower(r_diac(trim($inp)));
$ret = str_replace(' ', '-', $inp);
$ret = preg_replace('#[^a-zA-Z0-9\-_]#', '', $ret);
$spec_chars = array(
array('_', '---', '--'),
array('-', '-' , '-')
);
$ret = str_replace($spec_chars[0], $spec_chars[1], $ret);
return $ret;
}
function fnlize($inp) {
$inp = strtolower(r_diac(trim($inp)));
$ret = str_replace(' ', '-', $inp);
$ret = preg_replace('#[^a-zA-Z0-9\-_\.\(\)]#', '', $ret);
$spec_chars = array(
array('---', '--'),
array('-' , '-')
);
$ret = str_replace($spec_chars[0], $spec_chars[1], $ret);
return $ret;
}
function stat_log($_pa, $_ka, $_id) {
napojenie();
$q = mysql_query(sprintf("INSERT INTO statistika VALUES (%d, '%s', '%s', %d, '%s')", time(), $_pa, $_ka, $_id, $_SERVER['REMOTE_ADDR'])) or die(mysql_error());
}
function curl_get_contents($URL) {
$c = curl_init();
curl_setopt($c, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($c, CURLOPT_URL, $URL);
$contents = curl_exec($c);
curl_close($c);
if ($contents) return $contents;
else return FALSE;
}
function logIt($str) {
global $_CFG;
if ($_CFG['log']) {
fwrite($_CFG['logLink'], $str."\r\n");
}
}
function startLog($logfile = false) {
global $_CFG;
if ($_CFG['log']) {
$_CFG['logLink'] = fopen($logfile ? $logfile : $_CFG['logFile'], 'a');
}
}
function endLog() {
global $_CFG;
if ($_CFG['logLink'])
fclose($_CFG['logLink']);
}
function resizeImgMagick($pol, $_sizex = 0, $_sizey = 0, $dest = false) {
if (!file_exists($pol))
return false;
if (!$dest)
$dest = $pol;
if (CMD) {
$cmd = array(IMGMAGICK, $pol, '-resize');
if ($_sizex > 0)
$cmd[] = "'".$_sizex.($_sizey > 0 ? 'x'.$_sizey.'>' : '')."'";
if ($dest)
$cmd[] = $dest;
$res = exec(implode(' ', $cmd));
}
else {
$image = new Imagick($pol);
// $image->resizeImage($_sizex, $_sizey, imagick::FILTER_LANCZOS, 1);
$res = $image->writeImage($dest);
}
return $res;
}
function thumb($pol) {
list($sizex, $sizey, $type, $attr) = GetImageSize($pol);
$im_in = ImageCreateFromJpeg($pol);
$sizex_out = 120;
$sizey_out = 90;
$im_outn_t = str_replace('.jpg', '_small.jpg', $pol);
$ratio_d = 1.333333333333;
$ratio = $sizex / $sizey;
$ratio_y = $sizey / $sizey_out;
$ratio_x = $sizex / $sizex_out;
if ($ratio >= 1.33) {
$starty_in = 0;
$startx_in = round(($sizex - $ratio_y * $sizex_out) / 2);
$sizex = round($ratio_y * 120);
}
else {
$startx_in = 0;
$starty_in = round(($sizey - $ratio_x * $sizey_out) / 2);
$sizey = round($ratio_x * 90);
}
// printf(' sizex: %s sizey: %s ratio: %s sizex_out: %s sizey_out: %s ', $sizex, $sizey, $ratio_x , $sizex_out, $sizey_out);
$im_out = ImageCreateTrueColor($sizex_out, $sizey_out);
ImageCopyResampled($im_out, $im_in, 0, 0, $startx_in, $starty_in, $sizex_out, $sizey_out, $sizex, $sizey);
ImageJpeg($im_out, $im_outn_t, 78);
ImageDestroy($im_out);
ImageDestroy($im_in);
}
?>
Fatal error : Uncaught Error: Call to undefined function startLog() in /var/www/clients/client36/web66/web/core.php:12
Stack trace:
#0 /var/www/clients/client36/web66/web/index.php(3): include()
#1 {main}
thrown in /var/www/clients/client36/web66/web/core.php on line 12