Psss, want some terrible IT stories?

Are you afraid of the dark? Maybe a zombie apocalypse or monsters under the bed? We know not. We, IT specialists, have their own sources of horror: crooked users, far from IT bosses, crashed servers, missing or not made backups, went down code and Agile-rallies, when in fact the whole development is controlled by screaming “just yesterday”, “the customer is throwing” , "There criticized the prod." On the eve of Halloween, we decided to find the most terrible stories, tell a couple of ours, and at the same time hear yours. Well, are you ready to tell the stories chilling soul?









Easy warm up to goosebumps



Let's start with one very simple function. In theory, she should check whether the number is prime.



bool primeCheckUgly(unsigned long long int n){//good luck     ...
      
      





Well, if the comment wished us good luck, then you are definitely ready to see a screenshot of the full code for this function. Ready? Well?



Boo!








Full size



And what does the code snippet do in the following screenshot?









Boo!
Checks if the number is odd. What did you think?


Scary Stories Time With Reddit



Story 1



Very long and scary listing - we warned!
Data hosted with ♥ by Pastebin.com - Download Raw - See Original
  1. <? php
  2. function get_string_between($string, $start, $end){
  3.     $string = ' ' . $string;
  4.     $ini = strpos($string, $start);
  5.     if ($ini == 0) return '';
  6.     $ini += strlen($start);
  7.     $len = strpos($string, $end, $ini) - $ini;
  8.     return substr($string, $ini, $len);
  9. }
  10. function html2plain($html, $numchars) {
  11.         // Remove the HTML tag
  12.  
  13.         $html = strip_tags($html);
  14.         // Convert HTML entities to single characters
  15.         $html = html_entity_decode($html, ENT_QUOTES, 'UTF-8');
  16.         // Make the string the desired number of characters
  17.         // Note that substr is not good as it counts by bytes and not characters
  18.         $html = mb_substr($html, 0, $numchars, 'UTF-8');
  19.         // Add an elipsis
  20.         $html .= "…";
  21.         return $html;
  22.     }
  23. function filtriraj($value,$tit="")
  24. {
  25. $value=strip_tags($value);
  26. $value=preg_replace('/<[^>]*>/', '',$value);
  27. if($tit==1)
  28. $value=str_replace("'","",$value);
  29. $value=htmlspecialchars($value, ENT_QUOTES, 'UTF-8');
  30. return $value;
  31. }
  32.  
  33. function confirmUsers($email, $password){
  34. global $conn;
  35.    $resulta=mysqli_query($conn,"SELECT * FROM users_admin WHERE email=".safe($email)." AND akt='Y'");
  36.    if(mysqli_num_rows($resulta)==0){
  37.       return 1; //Pogresan email
  38.    }
  39. $dbarray = mysqli_fetch_array($resulta);
  40.     $dbarray['password']  = stripslashes($dbarray['password']);
  41.    $password = stripslashes($password);
  42. $cek=tep_validate_password($password, $dbarray['password']);
  43.  
  44.    //if($password == $dbarray['password']){
  45.    if($cek==1){
  46.       return 0; //Uspesan login
  47.    }
  48.    else{
  49.       return 2; //Pogresna Sifra
  50.    }
  51. }
  52.  
  53.  
  54. function checkLogins(){
  55. global $conn;
  56.  
  57.   if(isset($_COOKIE['ipcooknames']) && isset($_COOKIE['ipcookpasss'])){
  58.     $_SESSION['emails'] = $_COOKIE['ipcooknames'];
  59.     $_SESSION['passwords'] = $_COOKIE['ipcookpasss'];
  60.     $_SESSION['userid'] = $_COOKIE['ipcookids'];
  61.    }
  62.    if(isset($_SESSION['emails']) && isset($_SESSION['passwords']) and mysqli_num_rows(mysqli_query($conn,"SELECT email FROM users_admin WHERE email='$_SESSION[emails]'"))>0)
  63.    {
  64.  
  65.     return true;
  66.     }
  67.     else
  68.     {
  69.          unset($_SESSION['emails']);
  70.          unset($_SESSION['passwords']);
  71.          unset($_SESSION['userids']);
  72.          unset($_SESSION['korisniks']);
  73.          return false;
  74.  
  75.      }
  76.  
  77. }
  78.  
  79. if(isset($_POST['sublogins'])){
  80.  
  81.    if(!$_POST['email'] || !$_POST['pass']){
  82.       $msls=$langa['logins7'];
  83.  
  84.    }else{
  85.  
  86.    $_POST['email'] = trim($_POST['email']);
  87.  
  88.  
  89.    //$md5pass = md5($_POST['pass']);
  90.    $md5pass = trim($_POST['pass']);
  91.  
  92.    $result = confirmUsers($_POST['email'], $md5pass);
  93.  
  94.  
  95.    if($result == 1){
  96.       $msls=$langa['logins8'];
  97.  
  98.    }
  99.    else if($result == 2){
  100.       $msls=$langa['logins8'];
  101.    } else {
  102.  
  103.    $_POST['emails'] = stripslashes($_POST['email']);
  104.    $_SESSION['emails'] = $_POST['email'];
  105.    $_SESSION['panels'] = $_POST['panel'];
  106.    $_SESSION['passwords'] = tep_encrypt_password($md5pass);
  107.    $resulti = mysqli_query($conn,"select * from users_admin where email = '".$_SESSION['emails']."'");
  108.    $dbarrayi = mysqli_fetch_assoc($resulti);
  109.    $_SESSION['userids'] = $dbarrayi['user_id'];
  110.     $_SESSION['usernames'] = $dbarrayi['adm_username'];
  111.    $_SESSION['korisniks'] = $dbarrayi['name']." ".$dbarrayi['surname'];
  112.  
  113.  
  114.    if(isset($_POST['remember'])){
  115.       setcookie("ipcooknames", $_SESSION['emails'], time()+60*60*24*100, "/");
  116.     setcookie("ipcookpasss", $_SESSION['passwords'], time()+60*60*24*100, "/");
  117.       setcookie("ipcookids", $_SESSION['userids'], time()+60*60*24*100, "/");
  118.    }
  119.  
  120.  
  121.  
  122.  echo header("Location: $patH/admin/index.php");
  123.  
  124.  
  125.    }
  126.    }
  127. }
  128.  
  129.  
  130. /* podesavanje logged_in promenljive */
  131. if(preg_match("/admin/",curPageURL()))
  132.  $logged_ins = checkLogins();
  133.  
  134. function check_admins(){
  135. global $conn;
  136. global $logged_ins;
  137. if($logged_ins){
  138.    $qa = "select active from users_admin where email = '".$_SESSION['emails']."'";
  139.     $resultadmin = mysqli_query($conn,$qa);
  140.    $addb = mysqli_fetch_assoc($resultadmin);
  141.  
  142.     return $addb['active'];
  143.  
  144.     }
  145. }
  146. if(preg_match("/admin/",curPageURL()))
  147. $admins = check_admins();
  148.  
  149.  //include($page_path2."/language/$lang.php");
  150. //include($page_path2."/funkc.php");
  151. function replace_slug($all){
  152.  
  153. $all=trim($all);
  154.  
  155. $nid_pr=str_replace("Ć","c",$all);
  156.  
  157.  
  158.  
  159. $nid_pr=str_replace("ć","c",$nid_pr);
  160.  
  161. $nid_pr=str_replace("ä","a",$nid_pr);
  162. $nid_pr=str_replace("ö","o",$nid_pr);
  163. $nid_pr=str_replace("ü","u",$nid_pr);
  164. $nid_pr=str_replace("Ä","a",$nid_pr);
  165. $nid_pr=str_replace("Ö","o",$nid_pr);
  166. $nid_pr=str_replace("ß","s",$nid_pr);
  167.  
  168. $nid_pr=str_replace("Č","c",$nid_pr);
  169.  
  170.  
  171.  
  172. $nid_pr=str_replace("č","c",$nid_pr);
  173.  
  174.  
  175.  
  176. $nid_pr=str_replace("Š","s",$nid_pr);
  177.  
  178.  
  179.  
  180. $nid_pr=str_replace("š","s",$nid_pr);
  181.  
  182.  
  183.  
  184. $nid_pr=str_replace("ž","z",$nid_pr);
  185.  
  186.  
  187.  
  188. $nid_pr=str_replace("Ž","z",$nid_pr);
  189.  
  190.  
  191.  
  192. $nid_pr=str_replace("đ","dj",$nid_pr);
  193.  
  194.  
  195.  
  196. $nid_pr=str_replace("Đ","dj",$nid_pr);
  197.  
  198.  
  199.  
  200. $nid_pr=str_replace('"','',$nid_pr);
  201.  
  202.  
  203.  
  204. $nid_pr=str_replace("'","",$nid_pr);
  205.  
  206.  
  207.  
  208. $nid_pr=str_replace("?","",$nid_pr);
  209.  
  210.  
  211.  
  212. $nid_pr=str_replace("!","",$nid_pr);
  213.  
  214.  
  215.  
  216. $nid_pr=str_replace(".","",$nid_pr);
  217.  
  218.  
  219.  
  220. $nid_pr=str_replace(":","",$nid_pr);
  221.  
  222.  
  223.  
  224. $nid_pr=str_replace(";","",$nid_pr);
  225.  
  226.  
  227.  
  228. $nid_pr=str_replace("/","",$nid_pr);
  229.  
  230. $nid_pr=str_replace("   ","-",$nid_pr);
  231. $nid_pr=str_replace("  ","-",$nid_pr);
  232. $nid_pr=str_replace(" ","-",$nid_pr);
  233. //$nid_pr=str_replace("-","",$nid_pr);
  234.  
  235. $nid_pr=str_replace("+","-",$nid_pr);
  236. $nid_pr=str_replace("*","-",$nid_pr);
  237. $nid_pr=str_replace("(","-",$nid_pr);
  238. $nid_pr=str_replace(")","-",$nid_pr);
  239. $nid_pr=str_replace("=","-",$nid_pr);
  240. $nid_pr=str_replace("^","-",$nid_pr);
  241.  
  242. $nid_pr=str_replace("&","",$nid_pr);
  243.  
  244.  
  245.  
  246. $nid_pr=str_replace("[[:punct:]]","",$nid_pr);
  247.  
  248.  
  249.  
  250. $nid_pr1=strtolower($nid_pr);
  251.  
  252.  
  253.  
  254. $nid_pr2=trim($nid_pr1);
  255.  
  256. $nid_pr2=implode("-",explode(" ",$nid_pr2));
  257. $nid_pr2=str_replace("--","-",$nid_pr2);
  258.  
  259. return $nid_pr2;
  260.  
  261.  
  262.  
  263. }
  264.  
  265.  
  266. //include($page_path2."/language/$lang.php");
  267. //include($page_path2."/funkc.php");
  268. function replace($all){
  269.  
  270.  
  271.  
  272. $nid_pr=str_replace("Ć","C",$all);
  273.  
  274.  
  275.  
  276. $nid_pr=str_replace("ć","c",$nid_pr);
  277.  
  278.  
  279.  
  280. $nid_pr=str_replace("Č","C",$nid_pr);
  281.  
  282.  
  283.  
  284. $nid_pr=str_replace("č","c",$nid_pr);
  285.  
  286.  
  287.  
  288. $nid_pr=str_replace("Š","S",$nid_pr);
  289.  
  290.  
  291.  
  292. $nid_pr=str_replace("š","s",$nid_pr);
  293.  
  294.  
  295.  
  296. $nid_pr=str_replace("ž","z",$nid_pr);
  297.  
  298.  
  299.  
  300. $nid_pr=str_replace("Ž","Z",$nid_pr);
  301.  
  302.  
  303.  
  304. $nid_pr=str_replace("đ","dj",$nid_pr);
  305.  
  306.  
  307.  
  308. $nid_pr=str_replace("Đ","Dj",$nid_pr);
  309.  
  310.  
  311.  
  312. $nid_pr=str_replace('"','',$nid_pr);
  313.  
  314.  
  315.  
  316. $nid_pr=str_replace("'","",$nid_pr);
  317.  
  318.  
  319.  
  320. $nid_pr=str_replace("?","",$nid_pr);
  321.  
  322.  
  323.  
  324. $nid_pr=str_replace("!","",$nid_pr);
  325.  
  326.  
  327.  
  328. $nid_pr=str_replace(".","",$nid_pr);
  329.  
  330.  
  331.  
  332. $nid_pr=str_replace(":","",$nid_pr);
  333.  
  334.  
  335.  
  336. $nid_pr=str_replace(";","",$nid_pr);
  337.  
  338.  
  339.  
  340. $nid_pr=str_replace("/","",$nid_pr);
  341.  
  342.  
  343.  
  344. $nid_pr=str_replace("-","",$nid_pr);
  345.  
  346. $nid_pr=str_replace("+","-",$nid_pr);
  347. $nid_pr=str_replace("*","-",$nid_pr);
  348. $nid_pr=str_replace("(","-",$nid_pr);
  349. $nid_pr=str_replace(")","-",$nid_pr);
  350. $nid_pr=str_replace("=","-",$nid_pr);
  351. $nid_pr=str_replace("^","-",$nid_pr);
  352.  
  353. $nid_pr=str_replace("&","",$nid_pr);
  354.  
  355.  
  356.  
  357. $nid_pr=str_replace("[[:punct:]]","",$nid_pr);
  358.  
  359.  
  360.  
  361. $nid_pr1=strtolower($nid_pr);
  362.  
  363.  
  364.  
  365. $nid_pr2=trim($nid_pr1);
  366.  
  367.  
  368.  
  369. return $nid_pr2;
  370.  
  371.  
  372.  
  373. }
  374.  
  375. function replaceZZ($all){
  376. $nid_pr=str_replace("Ć","C",$all);
  377. $nid_pr=str_replace("ć","c",$nid_pr);
  378. $nid_pr=str_replace("Č","C",$nid_pr);
  379. $nid_pr=str_replace("č","c",$nid_pr);
  380. $nid_pr=str_replace("Š","S",$nid_pr);
  381. $nid_pr=str_replace("š","s",$nid_pr);
  382. $nid_pr=str_replace("ž","z",$nid_pr);
  383. $nid_pr=str_replace("Ž","Z",$nid_pr);
  384. $nid_pr=str_replace("đ","dj",$nid_pr);
  385. $nid_pr=str_replace("Đ","Dj",$nid_pr);
  386. $nid_pr=preg_replace("/[[:punct:]]/","",$nid_pr);
  387. $nid_pr1=strtolower($nid_pr);
  388. $nid_pr2=trim($nid_pr1);
  389. return $nid_pr2;
  390. }
  391. function replace1($all){
  392. $nid_pr=str_replace("Ć","C",$all);
  393. $nid_pr=str_replace("ć","c",$nid_pr);
  394. $nid_pr=str_replace("Č","C",$nid_pr);
  395. $nid_pr=str_replace("č","c",$nid_pr);
  396. $nid_pr=str_replace("Š","S",$nid_pr);
  397. $nid_pr=str_replace("š","s",$nid_pr);
  398. $nid_pr=str_replace("ž","z",$nid_pr);
  399. $nid_pr=str_replace("Ž","Z",$nid_pr);
  400. $nid_pr=str_replace("đ","dj",$nid_pr);
  401. $nid_pr=str_replace("Đ","Dj",$nid_pr);
  402. $nid_pr=str_replace("?","",$nid_pr);
  403. $nid_pr=str_replace("!","",$nid_pr);
  404. $nid_pr=preg_replace("/[[:punct:]]/","",$nid_pr);
  405. $nid_pr2=trim($nid_pr);
  406. return $nid_pr2;
  407. }
  408. function replace2($all){
  409. $nid_pr=str_replace("Ć","C",$all);
  410. $nid_pr=str_replace("ć","c",$nid_pr);
  411. $nid_pr=str_replace("Č","C",$nid_pr);
  412. $nid_pr=str_replace("č","c",$nid_pr);
  413. $nid_pr=str_replace("Š","S",$nid_pr);
  414. $nid_pr=str_replace("š","s",$nid_pr);
  415. $nid_pr=str_replace("ž","z",$nid_pr);
  416. $nid_pr=str_replace("Ž","Z",$nid_pr);
  417. $nid_pr=str_replace("đ","dj",$nid_pr);
  418. $nid_pr=str_replace("Đ","Dj",$nid_pr);
  419. return $nid_pr;
  420. }
  421. function replace_implode($all){
  422. $nid_pr=str_replace("Ć","C",$all);
  423. $nid_pr=str_replace("ć","c",$nid_pr);
  424. $nid_pr=str_replace("Č","C",$nid_pr);
  425. $nid_pr=str_replace("č","c",$nid_pr);
  426. $nid_pr=str_replace("Š","S",$nid_pr);
  427. $nid_pr=str_replace("š","s",$nid_pr);
  428. $nid_pr=str_replace("ž","z",$nid_pr);
  429. $nid_pr=str_replace("Ž","Z",$nid_pr);
  430. $nid_pr=str_replace("đ","dj",$nid_pr);
  431. $nid_pr=str_replace("Đ","Dj",$nid_pr);
  432. $nid_pr=str_replace("?","",$nid_pr);
  433. $nid_pr=str_replace("!","",$nid_pr);
  434. $nid_pr=preg_replace("/[[:punct:]]/","",$nid_pr);
  435. $nid_pr1=strtolower($nid_pr);
  436. $nid_pr2=implode("_",explode(" ",trim($nid_pr1)));
  437.  
  438. return $nid_pr2;
  439. }
  440. function replace_implode1($all){
  441. $nid_pr=str_replace("Ć","C",$all);
  442. $nid_pr=str_replace("ć","c",$nid_pr);
  443. $nid_pr=str_replace("Č","C",$nid_pr);
  444. $nid_pr=str_replace("č","c",$nid_pr);
  445. $nid_pr=str_replace("Š","S",$nid_pr);
  446. $nid_pr=str_replace("š","s",$nid_pr);
  447. $nid_pr=str_replace("ž","z",$nid_pr);
  448. $nid_pr=str_replace("Ž","Z",$nid_pr);
  449. $nid_pr=str_replace("đ","dj",$nid_pr);
  450. $nid_pr=str_replace("Đ","Dj",$nid_pr);
  451. $nid_pr=str_replace('"','',$nid_pr);
  452. $nid_pr=str_replace("'","",$nid_pr);
  453. $nid_pr=str_replace("?","",$nid_pr);
  454. $nid_pr=str_replace("!","",$nid_pr);
  455. $nid_pr=str_replace(".","",$nid_pr);
  456. $nid_pr=str_replace(":","",$nid_pr);
  457. $nid_pr=str_replace(";","",$nid_pr);
  458. $nid_pr=str_replace("/","",$nid_pr);
  459. $nid_pr=str_replace("(","",$nid_pr);
  460. $nid_pr=str_replace(")","",$nid_pr);
  461. $nid_pr=str_replace("^","",$nid_pr);
  462. $nid_pr=str_replace(",","",$nid_pr);
  463. $nid_pr=str_replace("  "," ",$nid_pr);
  464. $nid_pr=str_replace("$","",$nid_pr);
  465. $nid_pr=str_replace("#","",$nid_pr);
  466. $nid_pr=str_replace("&","",$nid_pr);
  467. $nid_pr=str_replace("*","",$nid_pr);
  468. $nid_pr=str_replace("=","",$nid_pr);
  469. $nid_pr=str_replace("+","",$nid_pr);
  470. //$nid_pr=preg_replace("/[[:punct:]]/","",$nid_pr);
  471. $nid_pr2=strtolower($nid_pr);
  472. $nid_pr2=str_replace("--","-",$nid_pr2);
  473. $nid_pr2=implode("-",explode(" ",trim($nid_pr2)));
  474.  
  475. return $nid_pr2;
  476. }
  477. function replace_implode2($nid_pr,$nosrb="", $norazm=""){
  478. if($nosrb=="")
  479. {
  480. $nid_pr=str_replace("Ć","C",$nid_pr);
  481. $nid_pr=str_replace("ć","c",$nid_pr);
  482. $nid_pr=str_replace("Č","C",$nid_pr);
  483. $nid_pr=str_replace("č","c",$nid_pr);
  484. $nid_pr=str_replace("Š","S",$nid_pr);
  485. $nid_pr=str_replace("š","s",$nid_pr);
  486. $nid_pr=str_replace("ž","z",$nid_pr);
  487. $nid_pr=str_replace("Ž","Z",$nid_pr);
  488. $nid_pr=str_replace("đ","dj",$nid_pr);
  489. $nid_pr=str_replace("Đ","Dj",$nid_pr);
  490. }
  491. $nid_pr=str_replace('"','',$nid_pr);
  492. $nid_pr=str_replace("'","",$nid_pr);
  493. $nid_pr=str_replace("?","",$nid_pr);
  494. $nid_pr=str_replace("!","",$nid_pr);
  495. $nid_pr=str_replace(".","",$nid_pr);
  496. $nid_pr=str_replace(":","",$nid_pr);
  497. $nid_pr=str_replace(";","",$nid_pr);
  498. $nid_pr=str_replace("/","",$nid_pr);
  499. $nid_pr=str_replace("(","",$nid_pr);
  500. $nid_pr=str_replace(")","",$nid_pr);
  501. $nid_pr=str_replace("^","",$nid_pr);
  502. $nid_pr=str_replace(",","",$nid_pr);
  503. $nid_pr=str_replace("  "," ",$nid_pr);
  504. $nid_pr=str_replace("$","",$nid_pr);
  505. $nid_pr=str_replace("#","",$nid_pr);
  506. $nid_pr=str_replace("&","",$nid_pr);
  507. $nid_pr=str_replace("*","",$nid_pr);
  508. $nid_pr=str_replace("=","",$nid_pr);
  509. $nid_pr=str_replace("+","",$nid_pr);
  510. $nid_pr=str_replace("-","",$nid_pr);
  511. //$nid_pr=preg_replace("/[[:punct:]]/","",$nid_pr);
  512. $nid_pr1=strtolower($nid_pr);
  513. if($norazm=="")
  514. $nid_pr=implode("",explode(" ",trim($nid_pr)));
  515.  
  516. return $nid_pr;
  517. }
  518. function addslash($theValue){
  519.  $theValue = (!get_magic_quotes_gpc()) ? addslashes($theValue) : $theValue;
  520.  return $theValue;
  521.  }
  522. function safed($str, $using_like=false) {
  523. global $conn;
  524.     if( get_magic_quotes_gpc() )  // if already escaped
  525.             $str = stripslashes($str);
  526.     $str = mysqli_real_escape_string($conn,$str);
  527.  
  528.     return ( $using_like? addcslashes($str, '%_') : $str );
  529. }
  530.  function safe($value,$sp="") {
  531.  global $conn;
  532.   if (get_magic_quotes_gpc()) //dali je magic quptes ukljucen
  533.      $value = stripslashes($value); //ako je, ponisti sta je napravio
  534.   //if (!is_numeric($value)) //dali nije numericka vrjednost (dali je string?)
  535.     $value = "'" . mysqli_real_escape_string($conn,$value) . "'"; //ako je string, escapaj ga kako spada
  536.   if($sp==1)
  537.   $value=strip_tags(trim($value));
  538.   return $value;
  539. }
  540. /*
  541. function flash($path1,$fajl,$wid,$heig)
  542. {
  543. echo "<object style='visibility: visible;z-index:-1000;'  type='application/x-shockwave-flash' data='$path1/$fajl' width='$wid' height='$heig'>
  544.  
  545. <param name='movie' value='$path1/$fajl' />
  546.   <param name='quality' value='high' />
  547.   <param name='wmode' value='transparent' />
  548. </object>
  549. ";
  550. }*/
  551. ################ RAND ##################
  552. function gen_rand_string($ime)
  553. {
  554.     $chars = array( 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w',  'x', 'y', 'z', '1', '2', '3', '4', '5', '6', '7', '8', '9', '0');
  555.  
  556.     $max_chars = count($chars) - 1;
  557.     srand( (double) microtime()*1000000);
  558.  
  559.     $rand_str = '';
  560.     for($i = 0; $i < 5; $i++)
  561.     {
  562.         $rand_str = ( $i == 0 ) ? $chars[rand(0, $max_chars)] : $rand_str . $chars[rand(0, $max_chars)];
  563.     }
  564. $rep=str_replace(".jpg","-",$ime);
  565. $rep=str_replace(".JPG","-",$rep);
  566. $rep=str_replace(".JPEG","-",$rep);
  567. $rep=str_replace(".jpeg","-",$rep);
  568. $rep=str_replace(".gif","-",$rep);
  569. $rep=str_replace(".GIF","-",$rep);
  570. $rep=str_replace(".png","-",$rep);
  571. $rep=str_replace(".PNG","-",$rep);
  572. $rep=str_replace(".swf","-",$rep);
  573. $rep=str_replace(".SWF","-",$rep);
  574. $rep=str_replace(".doc","-",$rep);
  575. $rep=str_replace(".DOC","-",$rep);
  576. $rep=str_replace(".pdf","-",$rep);
  577. $rep=str_replace(".PDF","-",$rep);
  578.     return $rep.$rand_str;
  579. }
  580. function gen_rand6()
  581.  
  582. {
  583.  
  584.     $chars = array( 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w',  'x', 'y', 'z', '1', '2', '3', '4', '5', '6', '7', '8', '9', '0');
  585.  
  586.  
  587.  
  588.     $max_chars = count($chars) - 1;
  589.  
  590.     srand( (double) microtime()*1000000);
  591.  
  592.  
  593.  
  594.     $rand_str = '';
  595.  
  596.     for($i = 0; $i < 6; $i++)
  597.  
  598.     {
  599.  
  600.         $rand_str = ( $i == 0 ) ? $chars[rand(0, $max_chars)] : $rand_str . $chars[rand(0, $max_chars)];
  601.  
  602.     }
  603.  
  604.     return strtoupper($rand_str);
  605.  
  606. }
  607. function gen_rand()
  608. {
  609.     $chars = array( 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w',  'x', 'y', 'z', '1', '2', '3', '4', '5', '6', '7', '8', '9', '0');
  610.  
  611.     $max_chars = count($chars) - 1;
  612.     srand( (double) microtime()*1000000);
  613.  
  614.     $rand_str = '';
  615.     for($i = 0; $i < 15; $i++)
  616.     {
  617.         $rand_str = ( $i == 0 ) ? $chars[rand(0, $max_chars)] : $rand_str . $chars[rand(0, $max_chars)];
  618.     }
  619.     return $rand_str;
  620. }
  621. ############################### UPLOAD IMAGE ##############
  622. function UploadSlika($imesl,$tmp_name,$ext,$lokacija,$da="",$crop="",$resizep="",$forname="") {
  623.  
  624. $slika2="";
  625. $iimesl=explode('.', $imesl);
  626. $ext= ".".end($iimesl);
  627. $ext=str_replace("JPEG", "jpg", $ext);
  628. $ext=str_replace("jpeg", "jpg", $ext);
  629.  
  630. $imesl=str_replace(" ","_",$imesl);
  631. $imesl=str_replace("&","_",$imesl);
  632. $imesl=str_replace($ext,"",$imesl);
  633.  
  634. if(strlen($forname)>0) $forname1="-".$forname; else $forname1="";
  635.  
  636. $slika2 = date("Y-m-d-H-i")."-".replace2($imesl).$forname1.$ext;
  637. //} else $slika2 = $imesl;
  638.  
  639.  
  640. $fold=$lokacija;
  641. $uploadfile = $lokacija . $slika2;
  642.  
  643.  
  644. @copy($tmp_name, $uploadfile);
  645. if(preg_match("/galerija/",$lokacija) or preg_match("/images/",$lokacija) or ($da==1 or $da==2))
  646. if($ext==".jpg" or $ext==".JPG" or $ext==".gif" or $ext==".GIF" or $ext==".png" or $ext==".PNG")
  647. {
  648. //resizerv_watermark($slika2,$fold);
  649.  
  650. if($resizep!="")
  651. {
  652. resize($slika2,$fold,$resizep);
  653. }
  654.  
  655. if($_GET['tip']!=13 or $da==2)
  656. resizerv($slika2,$fold,1000);
  657.  
  658. if($da==2) {
  659. resize($slika2,$fold,"360-360-thumb360");
  660. resize($slika2,$fold,"150-150-thumb150");
  661. }
  662.  
  663. if(mb_eregi("-",$crop))
  664. {
  665. if(mb_eregi("#",$crop))
  666. {
  667. $crop=explode("#",$crop);
  668. create_square_image2($slika2,$fold,$crop[0]);
  669. create_square_image2($slika2,$fold,$crop[1]);
  670. }else
  671. create_square_image2($slika2,$fold,$crop);
  672. }
  673. else
  674. if($crop==100) //$crop=100; else $crop="";
  675. create_square_image($slika2,$fold,$crop);
  676. //else create_square_image1($slika2,$fold,320);
  677.  
  678.  
  679. }
  680.  
  681. //chmod($uploadfile, 0644);
  682. if($imesl!="")
  683. return $slika2;
  684.  
  685. }
  686.  
  687. ########################## RESIZE IMAGE create thumb ###################
  688. function resize($slika,$folder,$resizep){
  689. $image = "$folder$slika";//ovo je slika koju ces da resajzujes
  690. //$newHeight = '200';//u pixelima postavim visinu i sirinu
  691.  
  692. $kvalitet = '100';
  693. $resi=explode("-",$resizep);
  694. if($slika!="")
  695. {
  696.  
  697. $size = GetImageSize($image);//u pixelima uzima stvarnu visinu i sirinu slike
  698. $width = $size[0];
  699. $height = $size[1];
  700.  
  701. $imgratio=$width/$height;
  702. $wid=$resi[0];
  703. if($resi[1]==0)
  704. $heig=$resi[0];
  705. else
  706. $heig=$resi[1];
  707.  
  708. if($width>$height){
  709. $wd=$width/$height;
  710. $newWidth=$wid;
  711. $newHeight=$wid/$wd;
  712. }elseif($width<=$height){
  713. $hd=$height/$width;
  714. $newHeight=$heig;
  715. $newWidth=$heig/$hd;
  716. }
  717. $x = 0;//ovde u pixelima stavi odakle da krene sa crop-ovanjem
  718. $y = 0;
  719.  
  720. //ako je slika gif onda ovako, ako je jpg onda ImageCreateFromJpg a ako je png ImageCreateFromPng
  721. $exstension = substr($image,-3);
  722.  if($exstension == "jpeg" || $exstension == "jpg" || $exstension == "JPG"){
  723.                $src = imagecreatefromjpeg($image);
  724.            }elseif($exstension == "x-png" || $exstension == "png"  || $exstension == "PNG"){
  725.                $src = imagecreatefrompng($image);
  726.            }elseif($exstension == "gif" || $exstension == "GIF"){
  727.                $src = imagecreatefromgif($image);
  728.            }
  729.  
  730.  
  731. $tmb = ImageCreateTrueColor($newWidth,$newHeight);//pravi praznu lsiku sa zadatim velicinama
  732. //// eliminisanje pozadine PNG slike///
  733. if($exstension == "x-png" || $exstension == "png"  || $exstension == "PNG"){
  734. imagealphablending($tmb, false);
  735. imagesavealpha($tmb,true);
  736. $transparent = imagecolorallocatealpha($tmb, 255, 255, 255, 127);
  737. imagefilledrectangle($tmb, 0, 0, $newWidth, $newHeight, $transparent);
  738. }
  739. //////////
  740. ImageCopyresampled($tmb, $src, 0, 0, $x, $y, $newWidth, $newHeight, $width, $height);
  741. //opet menjaj u zavisnosti kakva je slika u pitanju (gif,jpg,png)
  742.  
  743.  
  744.  
  745. $destJpeg=$folder."$resi[2]/$slika";
  746. if($exstension == "jpg" || $exstension == "JPG")
  747. imageJpeg($tmb, $destJpeg,$kvalitet);
  748. elseif($exstension == "gif" || $exstension == "GIF")
  749. imageGif($tmb, $destJpeg,$kvalitet);
  750. elseif($exstension == "png" || $exstension == "PNG")
  751. imagePng($tmb, $destJpeg,5);
  752. ImageDestroy($src);
  753. ImageDestroy($tmb);
  754.  
  755. }
  756. }
  757. function resizervE($slika,$folder, $isto=0){
  758. $image = "$folder$slika";//ovo je slika koju ces da resajzujes
  759. //$newHeight = '200';//u pixelima postavim visinu i sirinu
  760.  
  761. $kvalitet = '100';
  762. $size = GetImageSize($image);//u pixelima uzima stvarnu visinu i sirinu slike
  763. $newWidth=$width = $size[0];
  764. $newHeight=$height = $size[1];
  765.  
  766. if($width>=520 or $height>=520 or $isto>0){
  767. if($isto=0)
  768. {
  769. $imgratio=$width/$height;
  770. $wid=$heig=520;
  771. if($width>$height){
  772. $wd=$width/$height;
  773. $newWidth=$wid*$wd;
  774. $newHeight=$heig;
  775. }elseif($width<=$height){
  776. $hd=$height/$width;
  777. $newHeight=$hd*$wid;
  778. $newWidth=$wid;
  779. }
  780. }
  781.  
  782.  
  783. $x = 0;//ovde u pixelima stavi odakle da krene sa crop-ovanjem
  784. $y = 0;
  785.  
  786. //ako je slika gif onda ovako, ako je jpg onda ImageCreateFromJpg a ako je png ImageCreateFromPng
  787. $exstension = substr($image,-3);
  788.  if($exstension == "jpeg" || $exstension == "jpg" || $exstension == "JPG"){
  789.                $src = imagecreatefromjpeg($image);
  790.            }elseif($exstension == "x-png" || $exstension == "png"  || $exstension == "PNG"){
  791.                $src = imagecreatefrompng($image);
  792.            }elseif($exstension == "gif" || $exstension == "GIF"){
  793.                $src = imagecreatefromgif($image);
  794.            }
  795.  
  796.  
  797. $tmb = ImageCreateTrueColor($newWidth,$newHeight);//pravi praznu lsiku sa zadatim velicinama
  798. //// eliminisanje pozadine PNG slike///
  799. if($exstension == "x-png" || $exstension == "png"){
  800. imagealphablending($tmb, false);
  801. imagesavealpha($tmb,true);
  802. $transparent = imagecolorallocatealpha($tmb, 255, 255, 255, 127);
  803. imagefilledrectangle($tmb, 0, 0, $newWidth, $newHeight, $transparent);
  804. }
  805. //////////
  806. ImageCopyresampled($tmb, $src, 0, 0, $x, $y, $newWidth, $newHeight, $width, $height);
  807. //opet menjaj u zavisnosti kakva je slika u pitanju (gif,jpg,png)
  808.  
  809.  
  810.  
  811. $destJpeg=$folder."thumb/$slika";
  812. if($exstension == "jpg" || $exstension == "JPG")
  813. imageJpeg($tmb, $destJpeg,$kvalitet);
  814. elseif($exstension == "gif" || $exstension == "GIF")
  815. imageGif($tmb, $destJpeg,$kvalitet);
  816. elseif($exstension == "png" || $exstension == "PNG")
  817. imagePng($tmb, $destJpeg,5);
  818. ImageDestroy($src);
  819. ImageDestroy($tmb);
  820. }
  821. }
  822. function resizerv($slika,$folder,$tip=0){
  823. $image = "$folder$slika";//ovo je slika koju ces da resajzujes
  824. //$newHeight = '200';//u pixelima postavim visinu i sirinu
  825.  
  826. $kvalitet = '100';
  827. $size = GetImageSize($image);//u pixelima uzima stvarnu visinu i sirinu slike
  828. $width = $size[0];
  829. $height = $size[1];
  830.  
  831. if($tip>0)
  832. $WH=$tip;
  833. else
  834. $WH=800;
  835.  
  836. if($width>$WH or $height>$WH){
  837. $imgratio=$width/$height;
  838. $wid=$WH;
  839. $heig=$WH;
  840. if($width>$height){
  841. $wd=$width/$height;
  842. $newWidth=$wid;
  843. $newHeight=$wid/$wd;
  844. }elseif($width<=$height){
  845. $hd=$height/$width;
  846. $newHeight=$heig;
  847. $newWidth=$heig/$hd;
  848. }
  849. $x = 0;//ovde u pixelima stavi odakle da krene sa crop-ovanjem
  850. $y = 0;
  851.  
  852. //ako je slika gif onda ovako, ako je jpg onda ImageCreateFromJpg a ako je png ImageCreateFromPng
  853. $exstension = substr($image,-3);
  854.  if($exstension == "jpeg" || $exstension == "jpg" || $exstension == "JPG"){
  855.                $src = imagecreatefromjpeg($image);
  856.            }elseif($exstension == "x-png" || $exstension == "png"  || $exstension == "PNG"){
  857.                $src = imagecreatefrompng($image);
  858.            }elseif($exstension == "gif" || $exstension == "GIF"){
  859.                $src = imagecreatefromgif($image);
  860.            }
  861.  
  862.  
  863. $tmb = ImageCreateTrueColor($newWidth,$newHeight);//pravi praznu lsiku sa zadatim velicinama
  864. //// eliminisanje pozadine PNG slike///
  865. if($exstension == "x-png" || $exstension == "png"){
  866. imagealphablending($tmb, false);
  867. imagesavealpha($tmb,true);
  868. $transparent = imagecolorallocatealpha($tmb, 255, 255, 255, 127);
  869. imagefilledrectangle($tmb, 0, 0, $newWidth, $newHeight, $transparent);
  870. }
  871. //////////
  872. ImageCopyresampled($tmb, $src, 0, 0, $x, $y, $newWidth, $newHeight, $width, $height);
  873. //opet menjaj u zavisnosti kakva je slika u pitanju (gif,jpg,png)
  874.  
  875.  //unlink($folder."$slika");
  876.  
  877. $destJpeg=$folder."$slika";
  878. if($exstension == "jpg" || $exstension == "JPG")
  879. imageJpeg($tmb, $destJpeg,$kvalitet);
  880. elseif($exstension == "gif" || $exstension == "GIF")
  881. imageGif($tmb, $destJpeg,$kvalitet);
  882. elseif($exstension == "png" || $exstension == "PNG")
  883. imagePng($tmb, $destJpeg,5);
  884. ImageDestroy($src);
  885. ImageDestroy($tmb);
  886. }
  887. }
  888.  
  889.     function create_square_image1($original_file, $destination_file, $sq=520){
  890. $square_size=$sq;
  891. if($square_size=="") $square_size=520;
  892.  
  893. $imagez = $destination_file."".$original_file;
  894.  
  895.         // get width and height of original image
  896.         $imagedata = getimagesize($imagez);
  897.         $original_width = $imagedata[0];
  898.         $original_height = $imagedata[1];
  899.  
  900.         if($original_width > $original_height){
  901.             $new_height = $square_size;
  902.             $new_width = $new_height*($original_width/$original_height);
  903.         }
  904.         if($original_height > $original_width){
  905.             $new_width = $square_size;
  906.             $new_height = $new_width*($original_height/$original_width);
  907.         }
  908.         if($original_height == $original_width){
  909.             $new_width = $square_size;
  910.             $new_height = $square_size;
  911.         }
  912.  
  913.         $new_width = round($new_width);
  914.         $new_height = round($new_height);
  915.  
  916.         // load the image
  917.         if(substr_count(strtolower($original_file), ".jpg") or substr_count(strtolower($original_file), ".jpeg")){
  918.             $original_image = imagecreatefromjpeg($imagez);
  919.         }
  920.         if(substr_count(strtolower($original_file), ".gif")){
  921.             $original_image = imagecreatefromgif($imagez);
  922.         }
  923.         if(substr_count(strtolower($original_file), ".png")){
  924.             $original_image = imagecreatefrompng($imagez);
  925.         }
  926.  
  927.         $smaller_image = imagecreatetruecolor($new_width, $new_height);
  928.         $square_image = imagecreatetruecolor($square_size, $square_size);
  929.  
  930.   /*if(substr_count(strtolower($original_file), ".png")){
  931. imagealphablending($square_image, false);
  932. imagesavealpha($square_image,true);
  933. $transparent = imagecolorallocatealpha($square_image, 255, 255, 255, 127);
  934. imagefilledrectangle($square_image, 0, 0, $new_width, $new_height, $transparent);
  935. } */
  936.  
  937. if(substr_count(strtolower($original_file), ".png")){
  938.  
  939.  
  940.             imagecolortransparent($square_image, imagecolorallocatealpha($square_image, 0, 0, 0, 127));
  941.             imagealphablending($square_image, false);
  942.             imagesavealpha($square_image, true);
  943.  
  944.         }
  945.  
  946.  
  947.         imagecopyresampled($smaller_image, $original_image, 0, 0, 0, 0, $new_width, $new_height, $original_width, $original_height);
  948.  
  949.         if($new_width>$new_height){
  950.             $difference = $new_width-$new_height;
  951.             $half_difference =  round($difference/2);
  952.             imagecopyresampled($square_image, $smaller_image, 0-$half_difference+1, 0, 0, 0, $square_size+$difference, $square_size, $new_width, $new_height);
  953.         }
  954.         if($new_height>$new_width){
  955.             $difference = $new_height-$new_width;
  956.             $half_difference =  round($difference/2);
  957.             imagecopyresampled($square_image, $smaller_image, 0, 0-$half_difference+1, 0, 0, $square_size, $square_size+$difference, $new_width, $new_height);
  958.         }
  959.         if($new_height == $new_width){
  960.             imagecopyresampled($square_image, $smaller_image, 0, 0, 0, 0, $square_size, $square_size, $new_width, $new_height);
  961.         }
  962.  
  963.  
  964.         // if no destination file was given then display a png
  965.         if(!$destination_file){
  966.             imagepng($square_image,NULL,9);
  967.         }
  968. $destJpeg=$destination_file."thumb/$original_file";
  969.         // save the smaller image FILE if destination file given
  970.  
  971.         if(substr_count(strtolower($original_file), ".jpg")){
  972.             imagejpeg($square_image,$destJpeg,100);
  973.         }
  974.         if(substr_count(strtolower($original_file), ".gif")){
  975.             imagegif($square_image,$destJpeg);
  976.         }
  977.         if(substr_count(strtolower($original_file), ".png")){
  978.             imagepng($square_image,$destJpeg,9);
  979.         }
  980.  
  981.         imagedestroy($original_image);
  982.         imagedestroy($smaller_image);
  983.         imagedestroy($square_image);
  984.  
  985.     }
  986. function create_square_image2($original_file, $destination_file, $sq="300-300"){
  987.  
  988. $squ=explode("-",$sq);
  989.  
  990.  $folder_save=$squ[2];
  991.  
  992. $imagez = $destination_file."".$original_file;
  993.  
  994. $thumb_width=$squ[0];
  995. $thumb_height = $squ[1];
  996.  
  997. $destJpeg=$destination_file."$folder_save/$original_file";
  998.  
  999.         // load the image
  1000.         if(substr_count(strtolower($original_file), ".jpg") or substr_count(strtolower($original_file), ".jpeg")){
  1001.             $original_image = imagecreatefromjpeg($imagez);
  1002.         }
  1003.         if(substr_count(strtolower($original_file), ".gif")){
  1004.             $original_image = imagecreatefromgif($imagez);
  1005.         }
  1006.         if(substr_count(strtolower($original_file), ".png")){
  1007.             $original_image = imagecreatefrompng($imagez);
  1008.         }
  1009.  
  1010.  
  1011.  
  1012. $width = imagesx($original_image);
  1013. $height = imagesy($original_image);
  1014. $original_aspect = $width / $height;
  1015. $thumb_aspect = $thumb_width / $thumb_height;
  1016. if ( $original_aspect >= $thumb_aspect )
  1017. {
  1018.    // If image is wider than thumbnail (in aspect ratio sense)
  1019.    $new_height = $thumb_height;
  1020.    $new_width = $width / ($height / $thumb_height);
  1021. }
  1022. else
  1023. {
  1024.    // If the thumbnail is wider than the image
  1025.    $new_width = $thumb_width;
  1026.    $new_height = $height / ($width / $thumb_width);
  1027. }
  1028.     //  $smaller_image = imagecreatetruecolor($new_width, $new_height);
  1029.         $thumb_image = imagecreatetruecolor($thumb_width, $thumb_height);
  1030.  
  1031.  
  1032. if(substr_count(strtolower($original_file), ".png")){
  1033.  
  1034.  
  1035.             imagecolortransparent($thumb_image, imagecolorallocatealpha($thumb_image, 0, 0, 0, 127));
  1036.             imagealphablending($thumb_image, false);
  1037.             imagesavealpha($thumb_image, true);
  1038.  
  1039.         }
  1040.  
  1041.  
  1042. imagecopyresampled($thumb_image,
  1043.                   $original_image,
  1044.                    0 - ($new_width - $thumb_width) / 2, // Center the image horizontally
  1045.                    0 - ($new_height - $thumb_height) / 2, // Center the image vertically
  1046.                    0, 0,
  1047.                    $new_width, $new_height,
  1048.                    $width, $height);
  1049.  
  1050.         // if no destination file was given then display a png
  1051.         /*if(!$destination_file){
  1052.             imagepng($thumb_image,NULL,9);
  1053.         }*/
  1054.  
  1055.         // save the smaller image FILE if destination file given
  1056.  
  1057.         if(substr_count(strtolower($original_file), ".jpg")){
  1058.             imagejpeg($thumb_image,$destJpeg,100);
  1059.         }
  1060.         if(substr_count(strtolower($original_file), ".gif")){
  1061.             imagegif($thumb_image,$destJpeg);
  1062.         }
  1063.         if(substr_count(strtolower($original_file), ".png")){
  1064.             imagepng($thumb_image,$destJpeg,9);
  1065.         }
  1066.  
  1067.         imagedestroy($original_image);
  1068.     //  imagedestroy($smaller_image);
  1069.         imagedestroy($thumb_image);
  1070.  
  1071.     }
  1072.  // create_square_image($original_file, $destination_file, $sq=520)
  1073.  function create_square_image($source, $destination, $sq=520) {
  1074. $quality=90;
  1075. $square_size=$sq;
  1076. if($square_size=="") $square_size=520;
  1077. $iimesl=explode('.', $source);
  1078. $extension= strtolower(end($iimesl));
  1079. $slika = $destination."thumb/".$source;
  1080.         $status  = false;
  1081.         list($width, $height, $type, $attr) = getimagesize($slika);
  1082.  
  1083.         if($width> $height) {
  1084.            $width_t =  $square_size;
  1085.            $height_t    =   round($height/$width*$square_size);
  1086.            $off_y       =   ceil(($width_t-$height_t)/2);
  1087.            $off_x       =   0;
  1088.  
  1089.           $difference = $width_t-$new_height_t;
  1090.                 $half_difference =  round($difference/2);
  1091.  
  1092.  
  1093.         } elseif($height> $width) {
  1094.  
  1095.            $height_t    =   $square_size;
  1096.            $width_t =   round($width/$height*$square_size);
  1097.            $off_x       =   ceil(($height_t-$width_t)/2);
  1098.            $off_y       =   0;
  1099.            $difference = $height_t-$width_t;
  1100.                  $half_difference =  round($difference/2);
  1101.  
  1102.         } else {
  1103.  
  1104.             $width_t    =   $height_t   =   $square_size;
  1105.             $off_x      =   $off_y      =   0;
  1106.         }
  1107.  
  1108.         $thumb_p    = imagecreatetruecolor($square_size, $square_size);
  1109.  
  1110.     //   $extension  = self::get_file_extension($source);
  1111.  
  1112.         if($extension == "gif" or $extension == "png"){
  1113.  
  1114.             imagecolortransparent($thumb_p, imagecolorallocatealpha($thumb_p, 0, 0, 0, 127));
  1115.             imagealphablending($thumb_p, false);
  1116.             imagesavealpha($thumb_p, true);
  1117.         }
  1118.  
  1119.         if ($extension == 'jpg' || $extension == 'jpeg')
  1120.             $thumb = imagecreatefromjpeg($slika);
  1121.         if ($extension == 'gif')
  1122.             $thumb = imagecreatefromgif($slika);
  1123.         if ($extension == 'png')
  1124.             $thumb = imagecreatefrompng($slika);
  1125.  
  1126.         $bg = imagecolorallocate ( $thumb_p, 255, 255, 255 );
  1127.         imagefill ($thumb_p, 0, 0, $bg);
  1128.  
  1129. if($width_t>$height_t)
  1130. imagecopyresampled($thumb_p, $thumb, 0-$half_difference+1, 0, 0, 0, $square_size+$difference, $square_size, $width, $height);
  1131. else
  1132. if($width_t>$height_t)
  1133. imagecopyresampled($thumb_p, $thumb, 0-$half_difference+1, 0, 0, 0, $square_size, $square_size+$difference,  $width, $height);
  1134. else
  1135. if($width_t==$height_t)
  1136.         imagecopyresampled($thumb_p, $thumb, 0, 0, 0, 0, $square_size, $square_size, $width, $height);
  1137.  
  1138.  
  1139.     $destinationa=$destination."thumb/$source";
  1140.         if ($extension == 'jpg' || $extension == 'jpeg')
  1141.             $status = @imagejpeg($thumb_p,$destinationa,$quality);
  1142.         if ($extension == 'gif')
  1143.             $status = @imagegif($thumb_p,$destinationa,$quality);
  1144.         if ($extension == 'png')
  1145.             $status = @imagepng($thumb_p,$destinationa,9);
  1146.  
  1147.         imagedestroy($thumb);
  1148.         imagedestroy($thumb_p);
  1149.  
  1150.         return $status;
  1151.     }
  1152. function resizerv_watermark($slika,$folder,$tip=""){
  1153. global $page_path2;
  1154.  
  1155.  
  1156. $image = "$folder$slika";//ovo je slika koju ces da resajzujes
  1157. //$newHeight = '200';//u pixelima postavim visinu i sirinu
  1158.  
  1159. $kvalitet = '95';
  1160. $size = GetImageSize($image);//u pixelima uzima stvarnu visinu i sirinu slike
  1161. $width = $newWidth = $size[0];
  1162. $height = $newHeight = $size[1];
  1163.  
  1164. if($width<300) $wat=220; else $wat="";
  1165.   $watermark = imagecreatefrompng($page_path2."/css/watermark$wat.png");
  1166.     imagealphablending($watermark, false);
  1167.     imagesavealpha($watermark, true);
  1168.  
  1169.    $wtrmrk_w = imagesx($watermark);
  1170.     $wtrmrk_h = imagesy($watermark);
  1171.     $dst_x = ($width / 2) - ($wtrmrk_w / 2); // For centering the watermark on any image
  1172.     $dst_y = ($height / 2) - ($wtrmrk_h / 2); // For centering the watermark on any image
  1173.  
  1174. $x = 0;//ovde u pixelima stavi odakle da krene sa crop-ovanjem
  1175. $y = 0;
  1176.  
  1177. //ako je slika gif onda ovako, ako je jpg onda ImageCreateFromJpg a ako je png ImageCreateFromPng
  1178. $exstension = substr($image,-3);
  1179.  if($exstension == "jpeg" || $exstension == "jpg" || $exstension == "JPG"){
  1180.                $src = imagecreatefromjpeg($image);
  1181.            }elseif($exstension == "x-png" || $exstension == "png"  || $exstension == "PNG"){
  1182.                $src = imagecreatefrompng($image);
  1183.            }elseif($exstension == "gif" || $exstension == "GIF"){
  1184.                $src = imagecreatefromgif($image);
  1185.            }
  1186.  
  1187.  
  1188. $tmb = ImageCreateTrueColor($newWidth,$newHeight);//pravi praznu lsiku sa zadatim velicinama
  1189. //// eliminisanje pozadine PNG slike///
  1190. if($exstension == "x-png" || $exstension == "png"){
  1191. imagealphablending($tmb, false);
  1192. imagesavealpha($tmb,true);
  1193. $transparent = imagecolorallocatealpha($tmb, 255, 255, 255, 127);
  1194. imagefilledrectangle($tmb, 0, 0, $newWidth, $newHeight, $transparent);
  1195. }
  1196. //////////
  1197. ImageCopyresampled($tmb, $src, 0, 0, $x, $y, $newWidth, $newHeight, $width, $height);
  1198. //opet menjaj u zavisnosti kakva je slika u pitanju (gif,jpg,png)
  1199.  imagecopy($tmb, $watermark, $dst_x, $dst_y, 0, 0, $wtrmrk_w, $wtrmrk_h);
  1200. unlink($folder."$slika");
  1201.  
  1202. $destJpeg=$folder."$slika";
  1203. if($exstension == "jpg" || $exstension == "JPG")
  1204. imageJpeg($tmb, $destJpeg,$kvalitet);
  1205. elseif($exstension == "gif" || $exstension == "GIF")
  1206. imageGif($tmb, $destJpeg,$kvalitet);
  1207. elseif($exstension == "png" || $exstension == "PNG")
  1208. imagePng($tmb, $destJpeg,5);
  1209. ImageDestroy($src);
  1210. ImageDestroy($tmb);
  1211.  
  1212. }
  1213. function opist($opis)
  1214. {
  1215. return str_replace("diframe", "iframe",$opis);
  1216. }
  1217. ################### for page site ###################
  1218. function opis($duz,$opis,$id,$fajl,$podrob){
  1219. global $patH;
  1220. global $path1;
  1221.  
  1222.  
  1223. echo "<div class='opis'>";
  1224. if($duz>1){
  1225. $op=strip_tags(stripslashes($opis));
  1226. echo substr($op,0,$duz)."...";
  1227. echo "<div class='link'>
  1228. <a href='$path1/$fajl?id=$id'>$podrob</a>
  1229. </div>";
  1230. }else{
  1231. $opis=str_replace("IMG", "img alt='digitalni_print'", $opis);
  1232. $opis=str_replace("<P>", "<p>", $opis);
  1233. $opis=str_replace("</P>", "</p>", $opis);
  1234. $opis=str_replace("<ul>", "<ul>", $opis);
  1235. $opis=str_replace("</ul>", "</ul>", $opis);
  1236. $opis=str_replace("<LI>", "<li>", $opis);
  1237. $opis=str_replace("</LI>", "</li>", $opis);
  1238. $opis=str_replace("<BR>", "<br />", $opis);
  1239. $opis=str_replace("<br>", "<br />", $opis);
  1240. $opis=str_replace("<STRONG>", "<strong>", $opis);
  1241. $opis=str_replace("</STRONG>", "</strong>", $opis);
  1242. //$opis=str_replace("size=\"1\"","style=\"font-size:10px;\"",$opis);
  1243. //$opis=str_replace("size=\"2\"","style=\"font-size:11px;\"",$opis);
  1244. //$opis=str_replace("size=1","style=\"font-size:10px;\"",$opis);
  1245. //$opis=str_replace("size=2","style=\"font-size:11px;\"",$opis);
  1246. //$opis=str_replace("size=3","style=\"font-size:11px;\"",$opis);
  1247. /*$opis=str_replace("face=\"Times New Roman\"","",$opis);
  1248. //$opis=str_replace("align=middle","align=center",$opis);
  1249. $opis=str_replace("src=\"../../../../","src=\"$patH/",$opis);
  1250. $opis=str_replace("src=\"../../","src=\"$patH/",$opis);
  1251. $opis=str_replace("src=\"../","src=\"$patH/",$opis);
  1252. $opis=str_replace("id=\"_mcePaste\"","",$opis);*/
  1253. $opis=str_replace("&lt;","<",$opis);
  1254. $opis=str_replace("&gt;",">",$opis);
  1255.  
  1256. echo stripslashes($opis);
  1257. }
  1258. echo "</div>";
  1259. }
  1260. function opis1($duz,$opis,$id,$fajl,$podrob){
  1261. global $patH;
  1262. global $path1;
  1263. echo "<div class='opis1'>";
  1264. if($duz>1){
  1265. $op=strip_tags(stripslashes($opis));
  1266. echo substr($op,0,$duz)."...";
  1267. echo "<div class='link'>
  1268. <a href='$path1/$fajl/$id/'>$podrob</a>
  1269. </div>";
  1270. }else{
  1271. $opis=str_replace("IMG", "img alt='digitalni_print'", $opis);
  1272. $opis=str_replace("<P>", "<p>", $opis);
  1273. $opis=str_replace("</P>", "</p>", $opis);
  1274. $opis=str_replace("<ul>", "<ul>", $opis);
  1275. $opis=str_replace("</ul>", "</ul>", $opis);
  1276. $opis=str_replace("<LI>", "<li>", $opis);
  1277. $opis=str_replace("</LI>", "</li>", $opis);
  1278. $opis=str_replace("<BR>", "<br />", $opis);
  1279. $opis=str_replace("<STRONG>", "<strong>", $opis);
  1280. $opis=str_replace("</STRONG>", "</strong>", $opis);
  1281. $opis=str_replace("size=\"1\"","style=\"font-size:10px;\"",$opis);
  1282. $opis=str_replace("size=\"2\"","style=\"font-size:11px;\"",$opis);
  1283. $opis=str_replace("size=1","style=\"font-size:10px;\"",$opis);
  1284. $opis=str_replace("size=2","style=\"font-size:11px;\"",$opis);
  1285. $opis=str_replace("size=3","style=\"font-size:11px;\"",$opis);
  1286. $opis=str_replace("face=\"Times New Roman\"","",$opis);
  1287. $opis=str_replace("<img ","<img class='magnify' ",$opis);
  1288. $opis=str_replace("align=middle","align=center",$opis);
  1289. $opis=str_replace("align=center","style='text-align:center;'",$opis);
  1290.  
  1291.  
  1292. echo stripslashes($opis);
  1293. }
  1294. echo "</div>";
  1295. }
  1296. function opis2($duz,$opis,$id,$fajl,$podrob){
  1297. global $patH;
  1298. global $path1;
  1299. echo "<div class='opis2'>";
  1300. if($duz>1){
  1301. $op=strip_tags(stripslashes($opis));
  1302. echo substr($op,0,$duz)."...";
  1303. echo "<div class='link'>
  1304. <a href='$patH/$fajl?id=$id'>$podrob</a>
  1305. </div>";
  1306. }else{
  1307. $opis=str_replace("IMG", "img alt='digitalni_print'", $opis);
  1308. $opis=str_replace("<P>", "<p>", $opis);
  1309. $opis=str_replace("</P>", "</p>", $opis);
  1310. $opis=str_replace("<ul>", "<ul>", $opis);
  1311. $opis=str_replace("</ul>", "</ul>", $opis);
  1312. $opis=str_replace("<LI>", "<li>", $opis);
  1313. $opis=str_replace("</LI>", "</li>", $opis);
  1314. $opis=str_replace("<BR>", "<br />", $opis);
  1315. $opis=str_replace("<STRONG>", "<strong>", $opis);
  1316. $opis=str_replace("</STRONG>", "</strong>", $opis);
  1317. $opis=str_replace("size=\"1\"","style=\"font-size:10px;\"",$opis);
  1318. $opis=str_replace("size=\"2\"","style=\"font-size:11px;\"",$opis);
  1319. $opis=str_replace("size=1","style=\"font-size:10px;\"",$opis);
  1320. $opis=str_replace("size=2","style=\"font-size:11px;\"",$opis);
  1321. echo stripslashes($opis);
  1322. }
  1323. echo "</div>";
  1324. }
  1325. function opis3($duz,$opis,$id,$fajl,$podrob){
  1326. global $patH;
  1327. global $path1;
  1328.  
  1329. echo "<div class='opis1'>";
  1330. if($duz>1){
  1331. $op=strip_tags(stripslashes($opis));
  1332. echo substr($op,0,$duz)."...";
  1333. echo "<div class='link'>
  1334. <a href='$path1/$fajl/$id/'>$podrob</a>
  1335. </div>";
  1336. }else{
  1337. $opis=str_replace("IMG", "img alt='digitalni_print'", $opis);
  1338. $opis=str_replace("<P>", "<p>", $opis);
  1339. $opis=str_replace("</P>", "</p>", $opis);
  1340. $opis=str_replace("<ul>", "<ul>", $opis);
  1341. $opis=str_replace("</ul>", "</ul>", $opis);
  1342. $opis=str_replace("<LI>", "<li>", $opis);
  1343. $opis=str_replace("</LI>", "</li>", $opis);
  1344. $opis=str_replace("<BR>", "<br />", $opis);
  1345. $opis=str_replace("<STRONG>", "<strong>", $opis);
  1346. $opis=str_replace("</STRONG>", "</strong>", $opis);
  1347. $opis=str_replace("size=\"1\"","style=\"font-size:10px;\"",$opis);
  1348. $opis=str_replace("size=\"2\"","style=\"font-size:11px;\"",$opis);
  1349. $opis=str_replace("size=1","style=\"font-size:10px;\"",$opis);
  1350. $opis=str_replace("size=2","style=\"font-size:11px;\"",$opis);
  1351. $opis=str_replace("size=3","style=\"font-size:11px;\"",$opis);
  1352. $opis=str_replace("face=\"Times New Roman\"","",$opis);
  1353. $opis=str_replace("align=middle","align=center",$opis);
  1354. return stripslashes($opis);
  1355. }
  1356. echo "</div>";
  1357. }
  1358. /////////// convert DATE ////////////
  1359. function datum($datum)
  1360.         {
  1361.         $exp=$ivreme=explode(" ",$datum);
  1362.         if(strlen($exp[1])>2)
  1363.         $exp=explode("-",$exp[0]);
  1364.         else
  1365.         $exp=explode("-",$datum);
  1366.         $exp_rev=array_reverse($exp);
  1367.         $imp=implode(".",$exp_rev);
  1368.         if(strlen($ivreme[1])>2)
  1369.         return $imp.". ".$ivreme[1];
  1370.         else
  1371.         return $imp;
  1372.         }
  1373. function datum1($datum)
  1374.         {
  1375.         $exp=explode("-",$datum);
  1376.         $exp_rev=array_reverse($exp);
  1377.         $imp=implode("-",$exp_rev);
  1378.         return $imp;
  1379.         }
  1380. //////////////////// return idpage //////////////
  1381. function idpages($strana,$lang)
  1382. {
  1383. $pp=mysqli_query($conn,"SELECT * FROM page WHERE file='$strana' AND jezik='$lang'");
  1384. $pp1=mysqli_fetch_array($pp);
  1385. return $pp1[id_grupe];
  1386. }
  1387. function read_files($kol,$i,$idpage,$patH,$page_path2,$download=0)
  1388. {
  1389. global $lang;
  1390. global $conn;
  1391. $pp = mysqli_query($conn,"SELECT p.*, pt.*
  1392.        FROM files p
  1393.        INNER JOIN files_lang pt ON p.id = pt.id_fajla
  1394.        WHERE pt.lang='$lang'  AND p.akt='Y' AND p.$kol=$i ORDER BY -p.pozicija DESC");
  1395.  
  1396. if (mysqli_num_rows($pp)>0) {
  1397. $g=0;
  1398. echo "<div  class='files'><ul>";
  1399. while(@$pp1=mysqli_fetch_array($pp)){
  1400. //if($g%2==0)
  1401. //$fr=" class='iright'"; else $fr="";
  1402. $nazi=$pp1["naslov"];
  1403. if(substr($pp1['slika'],-3)=="pdf") $tip="<i class='far fa-file-pdf'></i>";
  1404. if(substr($pp1['slika'],-3)=="xls") $tip="<i class='far fa-file-excel'></i>";
  1405. if(substr($pp1['slika'],-4)=="xlsx") $tip="<i class='far fa-file-excel'></i>";
  1406. if(substr($pp1['slika'],-3)=="doc") $tip="<i class='far fa-file-word'></i>";
  1407. if(substr($pp1['slika'],-4)=="docx") $tip="<i class='far fa-file-word'></i>";
  1408. if(substr($pp1['slika'],-3)=="zip") $tip="<i class='far fa-file-archive'></i>";
  1409. if(substr($pp1['slika'],-3)=="avi") $tip="<i class='far fa-file-video'></i>";
  1410. if(substr($pp1['slika'],-3)=="mpg") $tip="<i class='far fa-file-video'></i>";
  1411. if(substr($pp1['slika'],-3)=="wmv") $tip="<i class='far fa-file-video'></i>";
  1412. if(substr($pp1['slika'],-3)=="mp3") $tip="<i class='far fa-file-audio'></i>";
  1413. if(file_exists("$page_path2".SUBFOLDER."/files/".$pp1['slika'].""))
  1414. $size=ceil(filesize("$page_path2".SUBFOLDER."/files/".$pp1['slika']."")/1024);
  1415. if(strlen($pp1['slika'])>0){
  1416. if($download==0)
  1417. {//($size Kb)
  1418. echo "
  1419. <li$fr><a href='".$patH."/files/".$pp1['slika']."' target='_blank'>$tip &nbsp;&nbsp;$nazi</a></li>";
  1420. }elseif($download==1)
  1421. {
  1422. echo "
  1423. <li$fr><a href='".$patH."/download.php?f=".$pp1['slika']."'>$tip &nbsp;&nbsp;$nazi</a></li>";
  1424. }
  1425. }
  1426. $g++;
  1427. }
  1428. echo "</ul></div>";
  1429. }
  1430. }
  1431. function read_files_pdf($kol,$i,$idpage,$patH,$page_path2,$download=0)
  1432. {
  1433. global $lang;
  1434.  
  1435. $pp=mysqli_query($conn,"SELECT * FROM files WHERE $kol='$i' AND akt='Y' ORDER BY -pozicija DESC");
  1436. if (mysqli_num_rows($pp)>0) {
  1437. $g=0;
  1438. echo "<ul class='pdf'>";
  1439. while(@$pp1=mysqli_fetch_array($pp)){
  1440. //if($g%2==0)
  1441. //$fr=" class='iright'"; else $fr="";
  1442. $nazi=$pp1["naslov$lang"];
  1443. if(substr($pp1['slika'],-3)=="pdf") $tip="pdf.png";
  1444. if(substr($pp1['slika'],-3)=="xls") $tip="excel.png";
  1445. if(substr($pp1['slika'],-4)=="xlsx") $tip="excel.png";
  1446. if(substr($pp1['slika'],-3)=="doc") $tip="word.png";
  1447. if(substr($pp1['slika'],-4)=="docx") $tip="word.png";
  1448. if(substr($pp1['slika'],-3)=="zip") $tip="zip.png";
  1449. if(substr($pp1['slika'],-3)=="swf") $tip="swf.png";
  1450. if(substr($pp1['slika'],-3)=="avi") $tip="video.png";
  1451. if(substr($pp1['slika'],-3)=="mpg") $tip="video.png";
  1452. if(substr($pp1['slika'],-3)=="wmv") $tip="video.png";
  1453. if(file_exists("$page_path2".SUBFOLDER."/files/".$pp1['slika'].""))
  1454. $size=ceil(filesize("$page_path2".SUBFOLDER."/files/".$pp1['slika']."")/1024);
  1455. if(strlen($pp1['slika'])>0){
  1456. if($download==0)
  1457. {//($size Kb)
  1458. echo "
  1459. <li$fr><a href='".$patH."/files/".$pp1['slika']."' target='_blank'>$nazi
  1460. </a></li>";
  1461. }elseif($download==1)
  1462. {
  1463. echo "
  1464. <li$fr><a href='".$patH."/download.php?f=".$pp1['slika']."'>$nazi</a></li>";
  1465. }
  1466. }
  1467. $g++;
  1468. }
  1469. echo "</ul>";
  1470. }
  1471. }
  1472. function read_files_left($kol,$i,$idpage,$patH,$page_path2)
  1473. {
  1474. global $lang;
  1475. $pp=mysqli_query($conn,"SELECT * FROM files WHERE idstrane='$i' AND id_page=$idpage AND akt='Y'");
  1476. $g=0;
  1477. while(@$pp1=mysqli_fetch_array($pp)){
  1478. if($g%2==0)
  1479. echo "<div style='width:100%;height:5px;float:left;'></div>";
  1480. preg_match("/::$lang::(.*)::$lang::/", $pp1[naslov], $matches);
  1481. $nazi=$matches[1];
  1482. if(substr($pp1['opis'],-3)=="pdf") $tip="pdf.png";
  1483. if(substr($pp1['opis'],-3)=="xls") $tip="excel.png";
  1484. if(substr($pp1['opis'],-3)=="doc") $tip="word.png";
  1485. if(substr($pp1['opis'],-3)=="zip") $tip="zip.png";
  1486. if(substr($pp1['opis'],-3)=="swf") $tip="swf.png";
  1487. if(substr($pp1['opis'],-3)=="avi") $tip="video.png";
  1488. if(substr($pp1['opis'],-3)=="mpg") $tip="video.png";
  1489. if(substr($pp1['opis'],-3)=="wmv") $tip="video.png";
  1490.  
  1491. if(file_exists("$page_path2/private/files/".$pp1['opis'].""))
  1492. $size=ceil(filesize("$page_path2/private/files/".$pp1['opis']."")/1024);
  1493. if(strlen($pp1['opis'])>0){
  1494. echo "<table style='float:left;width:100%;' class='files' cellspacing='0'>
  1495. <tr ><td style='width:30px;'><img src='".$patH."images/$tip' alt='' width='40' /></td><td><a href='".$patH."download.php?down=".$pp1['opis']."'  style='text-align:left;font-size:11px;'>
  1496. &raquo; $nazi
  1497. </a></td></tr></table>";
  1498. }
  1499. $g++;
  1500. }
  1501. }
  1502. function read_galery($id,$idp,$wi,$he,$ur)
  1503. {
  1504. global $patH;
  1505. global $path1;
  1506. global $lang;
  1507. global $page_path2;
  1508. $page_path2=$page_path2."/private";
  1509. if(empty($wi)) $wid=90; else $wid=$wi;
  1510. if(empty($he)) $heig=80; else $heig=$he;
  1511. if($id)
  1512. $im=mysqli_query($conn,"SELECT * FROM galerija WHERE katid='$id'  AND akt='Y' AND id_page='$idp' ORDER BY pozicija, id ASC");
  1513. else
  1514. $im=mysqli_query($conn,"SELECT * FROM galerija WHERE id_page='$idp' AND akt='Y' ORDER BY pozicija, id ASC");
  1515. $l=0;
  1516. while($p1=mysqli_fetch_array($im))
  1517. {
  1518. $sl="slika1";
  1519. $b=$l%$ur;
  1520. if($b==0 and $l>0)
  1521. echo "<div style='float:left;width:100%;height:4px;'></div>";
  1522. if(strlen($p1[$sl])>3){
  1523.  
  1524. $pic=$page_path2."/private/galerija/$p1[slika1]";
  1525. $size = GetImageSize($pic);
  1526. $width  = $size[0];
  1527. $height = $size[1];
  1528. if($width>$height){
  1529. $wd=$width/$height;
  1530. $width1=$wid;
  1531. $height1=$wid/$wd;
  1532. }elseif($width<=$height){
  1533. $hd=$height/$width;
  1534. $height1=$heig;
  1535. $width1=$heig/$hd;
  1536. }
  1537. if(empty($p1[naslov])) $title="Cvetlicarna GARDENIA"; else $title="$p1[naslov]";
  1538. echo "<div style='float:left;'><div style='margin-left:5px;margin-top:10px;'>
  1539. <a href='$patH/galerija/$p1[$sl]'  class='pirobox_gall' title='$title'><img src='$patH/galerija/thumb/$p1[$sl]' width='$width1' height='$height1' style='border:1px solid #fff;'  alt='paintball club' /></a></div></div>";
  1540. }
  1541. $l++;
  1542. }
  1543. }
  1544. //////////////////// read images///////////
  1545. function read_images($id,$idp,$kol,$wi,$he,$title)
  1546. {
  1547. global $patH;
  1548. global $path1;
  1549. global $lang;
  1550. global $page_path2;
  1551. $page_path2=$page_path2."/private";
  1552. if(empty($wi)) $wid=90; else $wid=$wi;
  1553. if(empty($he)) $heig=80; else $heig=$he;
  1554. $im=mysqli_query($conn,"SELECT * FROM slike_paintb WHERE $kol='$id' AND akt='Y' AND id_page='$idp' ORDER BY pozicija, id ASC");
  1555. $l=0;
  1556. $num=mysqli_num_rows($im);
  1557. while($p1=mysqli_fetch_array($im))
  1558. {
  1559. $sl="slika";
  1560. $b=$l%3;
  1561. if($b==0 and $l>0)
  1562. echo "<div style='float:left;width:100%;height:4px;'></div>";
  1563. if(strlen($p1[$sl])>3){
  1564.  
  1565. $pic=$page_path2."/private/galerija/$p1[slika]";
  1566. $size = GetImageSize($pic);
  1567. $width  = $size[0];
  1568. $height = $size[1];
  1569. if($width>$height){
  1570. $wd=$width/$height;
  1571. $width1=$wid;
  1572. $height1=$wid/$wd;
  1573. }elseif($width<=$height){
  1574. $hd=$height/$width;
  1575. $height1=$heig;
  1576. $width1=$heig/$hd;
  1577. }
  1578. /*echo "<div style='float:left;'><div style='margin-left:5px;margin-top:10px;'>
  1579. <a href='$patH/galerija/$p1[$sl]' rel='lightbox[slide]' title='paintball club airsoft'><img src='$patH/galerija/thumb/$p1[$sl]' width='$width1' height='$height1' style='border:1px solid #99999;'  alt='paintball club' /></a></div></div>";*/
  1580. if($num==1) $pi="pirobox"; else $pi="pirobox_gall";
  1581. echo "<div style='float:left;'><div style='margin-left:5px;margin-top:10px;'>
  1582. <a href='$patH/galerija/$p1[$sl]'   class=\"highslide\" onclick=\"return hs.expand(this)\" title='$title' ><img src='$patH/galerija/thumb/$p1[$sl]' width='$width1' height='$height1' style='border:1px solid #111;'  alt='paintball club' /></a></div></div>";
  1583. }
  1584. $l++;
  1585. }
  1586. }
  1587. function read_images1($id,$idp,$kol,$bruredu,$wi,$he)
  1588. {
  1589. global $patH;
  1590. global $path1;
  1591. global $lang;
  1592. global $page_path2;
  1593. $page_path2=$page_path2."/private";
  1594. if(empty($wi)) $wid=74; else $wid=$wi;
  1595. if(empty($he)) $heig=50; else $heig=$he;
  1596. $im=mysqli_query($conn,"SELECT * FROM slike_paintb WHERE $kol='$id' AND id_page='$idp' ORDER BY pozicija, id ASC");
  1597. $i=1;
  1598. $widd=$wid+10;
  1599. $widd1=$wid+2;
  1600. while($p1=mysqli_fetch_array($im))
  1601. {
  1602. $b=$i%$bruredu;
  1603.  
  1604. ?>
  1605. <div style='float:left;width:<?=$widd?>px;text-align:center;font-size:1px;'>
  1606. <div style='border:1px solid #999;width:<?=$widd1?>px;'>
  1607. <?
  1608. if(strlen($p1[slika])>3){
  1609. $page_path2=$page_path2."/private";
  1610. $pic=$page_path2."/galerija/$p1[slika]";
  1611. //$pic="galerija/$p1[slika]";
  1612. $size = GetImageSize($pic);
  1613. $width  = $size[0];
  1614. $height = $size[1];
  1615. if($width>$height){
  1616. $wd=$width/$height;
  1617. $width1=$wid;
  1618. $height1=$wid/$wd;
  1619. }elseif($width<=$height){
  1620. $hd=$height/$width;
  1621. $height1=$heig;
  1622. $width1=$heig/$hd;
  1623. }
  1624.  
  1625. //echo "<a href='$patH/galerija/$p1[slika]'  rel='lightbox[slide]' alt='airsoft paintball club'>";
  1626. echo "<a href='$patH/galerija/$p1[slika]' rel='thumbnail'><img src='$patH/galerija/$p1[slika]' width='$width1' height='$height1' alt='paintbal club airsoft' title='paintbal airsoft club'  class='magnify' /></a>";
  1627. }
  1628. ?>
  1629. </div>
  1630. </div>
  1631. <?
  1632. if($b==0)
  1633. echo "<div style='width:100%;height:10px;float:left;font-size:1px;'>&nbsp;</div>";
  1634. $i++;
  1635. }
  1636. }
  1637. function image_size($wid,$heig,$slika){
  1638. global $patH;
  1639. global $path1;
  1640. global $lang;
  1641. global $page_path2;
  1642. $page_path2=$page_path2.SUBFOLDER;
  1643. $pic=$page_path2.GALFOLDER.$slika;
  1644. if(strlen($slika)>2){
  1645. $size = GetImageSize($pic);
  1646. $width  = $size[0];
  1647. $height = $size[1];
  1648. if($width>$height){
  1649. $wd=$width/$height;
  1650. $width1=$wid;
  1651. $height1=$width1/$wd;
  1652. }elseif($width<=$height){
  1653. $hd=$height/$width;
  1654. $height1=$heig;
  1655. $width1=$heig/$hd;
  1656. }
  1657. return $width1."-".$height1;
  1658.  }
  1659. }
  1660. function image_size1($wid,$heig,$slika,$fold=""){
  1661. global $patH;
  1662. global $path1;
  1663. global $lang;
  1664.  
  1665. $pic=".".SUBFOLDER.GALFOLDER."/".$slika;
  1666. if(strlen($slika)>0 and is_file($pic)){
  1667. $size = GetImageSize($pic);
  1668. $width  = $size[0];
  1669. $height = $size[1];
  1670.  
  1671. if($height>$width){
  1672. $hd=$height/$width;
  1673. $width1=$heig/$hd;
  1674. $height1=$heig;
  1675. }
  1676.  
  1677. if($width>=$height){
  1678. $wd=$width/$height;
  1679. $width1=$wid;
  1680. $height1=$wid/$wd;
  1681. }
  1682.  
  1683. if($height1>$heig)
  1684. {
  1685.  
  1686. $height1=$heig;
  1687. if($height>=$width){
  1688. $hd=$height/$width;
  1689. $width1=$height1/$hd;
  1690. }
  1691. if($height<=$width){
  1692. $wd=$width/$height;
  1693. $width1=$height1*$wd;
  1694. }
  1695. }
  1696.  
  1697. return $width1."-".$height1;
  1698.  
  1699. }
  1700. }
  1701. function image_size2($wid,$heig,$slika,$fold){
  1702. global $patH;
  1703. global $page_path2;
  1704.  
  1705. if(strlen($slika)>2 and file_exists($page_path2."/$fold/$slika")){
  1706.  
  1707. $pic=$page_path2."/$fold/$slika";
  1708. $size = GetImageSize($pic);
  1709. $width  = $size[0];
  1710. $height = $size[1];
  1711.  
  1712. if($heig>0){
  1713. if($width>$height){
  1714. $wd=$width/$height;
  1715. $height1=$heig;
  1716. $width1=$wd*$height1;
  1717. }elseif($width<=$height){
  1718. $hd=$height/$width;
  1719. $height1=$heig;
  1720. $width1=$heig/$hd;
  1721. }
  1722. return $width1."-".$height1;
  1723.  }elseif($width>0){
  1724. if($width>$height){
  1725. $wd=$width/$height;
  1726. $width1=$wid;
  1727. $height1=$width1/$wd;
  1728. }elseif($width<=$height){
  1729. $hd=$height/$width;
  1730. $width1=$wid;
  1731. $height1=$width1*$hd;
  1732. }
  1733. return $width1."-".$height1;
  1734.  }
  1735.  }
  1736. }
  1737. function image_size3($wid,$heig,$slika,$fold=""){
  1738.  
  1739. $pic=".".SUBFOLDER.GALFOLDER."/".$slika;
  1740. if(strlen($slika)>0 and is_file($pic)){
  1741.  
  1742.  
  1743. $size = GetImageSize($pic);
  1744. $width  = $size[0];
  1745. $height = $size[1];
  1746. if($heig>0){
  1747. if($height>$width){
  1748. $hd=$height/$width;
  1749. $width1=$heig/$hd;
  1750. $height1=$heig;
  1751. }
  1752. if($height<$width){
  1753. $hd=$width/$height;
  1754. $width1=$heig*$hd;
  1755. $height1=$heig;
  1756. }
  1757. return $width1."-".$heig;
  1758.  }elseif($wid>0){
  1759. if($height>=$width){
  1760. $hd=$height/$width;
  1761. if($height>=150){
  1762.  
  1763. $width1=150/$hd;
  1764. $height1=150;
  1765.  
  1766. }else{
  1767.  
  1768. $width1=$wid;
  1769. $height1=$wid*$hd;
  1770. }
  1771. }
  1772. if($height<$width){
  1773. $hd=$width/$height;
  1774. $width1=$wid;
  1775. $height1=$wid/$hd;
  1776. }
  1777. return $width1."-".$height1;
  1778.  }
  1779. }
  1780. }
  1781. function image_size33($wid,$heig,$slika,$fold){
  1782.  
  1783.  
  1784. $pic="$fold/$slika";
  1785. if(strlen($slika)>0  and file_exists("$fold/$slika")){
  1786.  
  1787. $size = GetImageSize($pic);
  1788. $width  = $size[0];
  1789. $height = $size[1];
  1790. if($heig>0){
  1791. if($height>$width){
  1792. $hd=$height/$width;
  1793. $width1=$heig/$hd;
  1794. $height1=$heig;
  1795. }
  1796. if($height<$width){
  1797. $hd=$width/$height;
  1798. $width1=$heig*$hd;
  1799. $height1=$heig;
  1800. }
  1801. return $width1."-".$heig;
  1802.  }elseif($wid>0){
  1803. if($height>=$width){
  1804. $hd=$height/$width;
  1805. if($height>=80){
  1806.  
  1807. $width1=80/$hd;
  1808. $height1=80;
  1809.  
  1810. }else{
  1811.  
  1812. $width1=$wid;
  1813. $height1=$wid*$hd;
  1814. }
  1815. }
  1816. if($height<$width){
  1817. $hd=$width/$height;
  1818. $width1=$wid;
  1819. $height1=$wid/$hd;
  1820. }
  1821. return $width1."-".$height1;
  1822.  }
  1823. }
  1824. }
  1825. function ukupno_art($nd){
  1826. $ku=mysqli_query($conn,"SELECT * FROM kateg_proizvoda_new WHERE id_parent='$nd'");
  1827.  
  1828.   while($ku1=mysqli_fetch_array($ku)){
  1829. $nn2 .=", ".$ku1[id];
  1830. $num=mysqli_query($conn,"SELECT * FROM proizvodi_new WHERE katid = '$ku1[id]'");
  1831. $num1=mysqli_num_rows($num);
  1832. $nums .=",".$num1;
  1833.  
  1834. //////// ispis podkategorija /////////
  1835. //echo $ku1[ime];
  1836. $kd=mysqli_query($conn,"SELECT * FROM kateg_proizvoda_new WHERE id_parent='$ku1[id]'");
  1837. $br1 =mysqli_num_rows($kd);
  1838.   while($kd1=mysqli_fetch_array($kd)){
  1839. // echo $kd1[id]."--";
  1840.  $nn3 .=", ".$kd1[id];
  1841.  $num=mysqli_query($conn,"SELECT * FROM proizvodi_new WHERE katid='$kd1[id]'");
  1842. $numi1 =mysqli_num_rows($num);
  1843.  
  1844. //echo "--".$numi1;
  1845. $numi11 .=", ".$numi1;
  1846.  
  1847.   }
  1848.   }
  1849.   $numg=mysqli_query($conn,"SELECT * FROM proizvodi_new WHERE katid='$nd'");
  1850. $numg1 =mysqli_num_rows($numg);
  1851. $nums_exp=explode(",",$nums);
  1852. $nums_exp1=explode(",",$numi11);
  1853. $num1=array_sum($nums_exp);
  1854. $vuv=array_sum($nums_exp1);
  1855. echo $vuv+$num1+$numg1;
  1856. }
  1857.  
  1858. function find($nn1,$v,$v1,$v2){
  1859.  
  1860.   global $nn;
  1861.   global $num2;
  1862.  
  1863. $ku=mysqli_query($conn,"SELECT * FROM kateg_proizvoda_new WHERE id_parent='$nn1'");
  1864.  
  1865.   while($ku1=mysqli_fetch_array($ku)){
  1866.  
  1867.  
  1868. $nn2 .=", ".$ku1[id];
  1869. $num=mysqli_query($conn,"SELECT * FROM proizvodi_new WHERE katid = '$ku1[id]'");
  1870. $num1=mysqli_num_rows($num);
  1871. //////// ispis podkategorija /////////
  1872. //echo $ku1[ime];
  1873. $kd=mysqli_query($conn,"SELECT * FROM kateg_proizvoda_new WHERE id_parent='$ku1[id]'");
  1874. $br1 =mysqli_num_rows($kd);
  1875.   while($kd1=mysqli_fetch_array($kd)){
  1876. // echo $kd1[id]."--";
  1877.  $nn3 .=", ".$kd1[id];
  1878.  $num=mysqli_query($conn,"SELECT * FROM proizvodi_new WHERE katid='$kd1[id]'");
  1879. $numi1 =mysqli_num_rows($num);
  1880. //echo "--".$numi1;
  1881. $numi11 .=", ".$numi1;
  1882. $vuv +=$numi1;
  1883.   }
  1884. //echo $vuv;
  1885.   $numi111=explode(", ",$numi11);
  1886.  
  1887.   array_shift($numi111);
  1888.   $numi111=array_reverse($numi111);
  1889.    $nuv=array_slice($numi111,0,$br1);
  1890.  $gg= array_sum($nuv);
  1891.  
  1892.   $num2=$num1+$gg;
  1893.  
  1894.  if($v2==1 and $nn1>0)
  1895.  {
  1896.  echo "<option  style='color:black;font-weight:normal;' $su value=$ku1[id]>$ku1[ime] ($num2)</option>";
  1897.  }
  1898. if($v==1){
  1899. echo "<div style='float:left;width:50%;'>";
  1900. echo "
  1901. <img src='images/B2.jpg'>
  1902. <a href=$PHP_SELF?id_kat=$ku1[id] class='link11'>$ku1[ime]</a> <span style='font-size:11px;color:#999;'>($num2)</span>";
  1903. echo "</div>";
  1904. }
  1905.  
  1906.   }
  1907.  
  1908.   if($v1==1){
  1909.   $nn=$nn1.$nn2.$nn3;
  1910.   return $nn;
  1911.   }
  1912.   }
  1913.  
  1914.   ##################### PORUDZBINE @##############
  1915. function toma()
  1916. {
  1917.  
  1918. }
  1919.  
  1920.  
  1921.  
  1922.   function poruceno($poruceno,$nnt,$cene,$ddv,$jezik,$nacin_placanja){
  1923. //$cmsniz=cmsniz($cmsniz);
  1924. //$nacin_placanja= nacin($nacin_placanja);
  1925. global $niz;
  1926.  
  1927.  
  1928. $exa=explode(",",$poruceno);
  1929. $ce=explode(",",$cene);
  1930. $send= "<table style='width:670px;'>";
  1931. if($jezik) $tab=$jezik."_proizvodi_new"; else $tab="proizvodi_new";
  1932. for($g=0; $g<count($exa); $g++)
  1933. {
  1934. $nim=explode("-",$exa[$g]);
  1935. $cec=explode("-",$ce[$g]);
  1936. $key=$nim[0];
  1937. $val=$nim[1];
  1938. $kor=mysqli_query($conn,"SELECT * FROM $tab WHERE id='$key'");
  1939. $kor1=mysqli_fetch_array($kor);
  1940. //$num=mysqli_num_rows($kor);
  1941. //if($admin==1 or $admin==2)
  1942.  $cc=$cec[1];
  1943.   //elseif($admin==0) $cc=$kor1[cena]+($kor1[cena]*(30/100));
  1944. //$vrzapr=$cc*$val;
  1945. //if($admin==0) $cc=$kor1[cena];
  1946. //elseif($admin==1) $cc=$kor1[cena1];
  1947.  
  1948. $cc1=sprintf("%4.2f",$cc);
  1949. $cc2=number_format ($cc1, 2, ",", ".");
  1950. $sddv1=sprintf("%4.2f",($cc1+($cc1*($ddv/100))));
  1951. $sddv2=number_format ($sddv1, 2, ",", ".");
  1952. $ubrez=$cc1*$val;
  1953. $ubrez1=number_format ($ubrez, 2, ",", ".");
  1954.  
  1955. $uzddv=$sddv1*$val;
  1956.  
  1957.   $uzddv1=number_format ($uzddv, 2, ",", ".");
  1958.   $val1=explode("-",$val);
  1959. $send .= "<tr>
  1960. <td><a href='$PHP_SELF?idpro=$kor1[id]' class='reg2' style='color:white;'>".stripslashes($kor1[naslov])."</a></td>
  1961. <td>$cc2 </td>
  1962. <td>";
  1963. $send .= "<form method=post action='$PHP_SELF?izmeni=izmeni&prikazi=$_GET[prikazi]' style='margin:0px;'>";
  1964. $send .= "<input type='text' name='kolicina' value='$val' size='1' style='font-size:9px;margin:0px;'>
  1965. <input type='hidden' name='kol' value='$val'>
  1966. <input type='hidden' name='tabela' value='$_GET[tabela]'>
  1967. <input type='hidden' name='vred' value='$key'>
  1968. ";
  1969. $send .= "</form>";
  1970. $send .= "</td>
  1971. <td align='right'>$ubrez1 </td>
  1972. </tr>";
  1973. $ukupno+=$ubrez;
  1974. $ukupno1+=$uzddv;
  1975.  
  1976. }
  1977.  $ukupno=number_format ($ukupno, 2, ",", ".");
  1978.   $ukupno1=number_format ($ukupno1, 2, ",", ".");
  1979. //$ukupno1=$ukupno+($ukupno*($ddv/100));
  1980. //$ukupno=str_replace(".",",",sprintf("%4.2f",$ukupno)) ;
  1981.  
  1982. //$ukupno1=str_replace(".",",",sprintf("%4.2f",$ukupno1)) ;
  1983. $send .= "<tr><td colspan='5'>&nbsp;</td></tr>";
  1984. $send .= "<tr style='font-size:13px;font-weight:bold;background:#f1f1f1;height:20px;'><td colspan='2'>".$niz[kupovina][8]."</td><td></td>
  1985. <td align='right' colspan='3'>
  1986. <div style='width:100%;text-align:right;float:left;'>
  1987. <span style='font-weight:bold;font-size:13px;'>$ukupno $din</span></div>
  1988. </td>
  1989. </tr>";
  1990. $send .= "<tr><td colspan='5' style='padding-bottom:10px;'>
  1991. <strong>Način plaćanja:</strong> ";
  1992.  
  1993.  $send .= $nacin_placanja[$nnt];
  1994.  
  1995. $send .= "</td></tr>";
  1996. $send .= "</table>";
  1997. return $send;
  1998. }
  1999.  
  2000.  
  2001.  function poruceno1($poruceno,$nnt,$cene,$ddv,$jezik,$nacin_placanja){
  2002. //$cmsniz=cmsniz($cmsniz);
  2003. //$nacin_placanja= nacin($nacin_placanja);
  2004. global $niz;
  2005.  
  2006.  
  2007. $exa=explode(",",$poruceno);
  2008. $ce=explode(",",$cene);
  2009. $send= "<table style='width:520px;'>";
  2010. if($jezik) $tab=$jezik."_proizvodi_new"; else $tab="proizvodi_new";
  2011. for($g=0; $g<count($exa); $g++)
  2012. {
  2013. $nim=explode("-",$exa[$g]);
  2014. $cec=explode("-",$ce[$g]);
  2015. $key=$nim[0];
  2016. $val=$nim[1];
  2017. $kor=mysqli_query($conn,"SELECT * FROM $tab WHERE id='$key'");
  2018. $kor1=mysqli_fetch_array($kor);
  2019. //$num=mysqli_num_rows($kor);
  2020. //if($admin==1 or $admin==2)
  2021.  $cc=$cec[1];
  2022.   //elseif($admin==0) $cc=$kor1[cena]+($kor1[cena]*(30/100));
  2023. //$vrzapr=$cc*$val;
  2024. //if($admin==0) $cc=$kor1[cena];
  2025. //elseif($admin==1) $cc=$kor1[cena1];
  2026.  
  2027. $cc1=sprintf("%4.2f",$cc);
  2028. $cc2=number_format ($cc1, 2, ",", ".");
  2029. $sddv1=sprintf("%4.2f",($cc1+($cc1*($ddv/100))));
  2030. $sddv2=number_format ($sddv1, 2, ",", ".");
  2031. $ubrez=$cc1*$val;
  2032. $ubrez1=number_format ($ubrez, 2, ",", ".");
  2033.  
  2034. $uzddv=$sddv1*$val;
  2035.  
  2036.   $uzddv1=number_format ($uzddv, 2, ",", ".");
  2037.   $val1=explode("-",$val);
  2038. $send .= "<tr>
  2039. <td><span style='color:red;'>".stripslashes($kor1[naslov])."</span></td>
  2040. <td>$cc2 </td>
  2041. <td>";
  2042. $send .= "<form method=post action='$PHP_SELF?izmeni=izmeni&prikazi=$_GET[prikazi]' style='margin:0px;'>";
  2043. $send .= "<input type='text' name='kolicina' value='$val' size='1' style='font-size:9px;margin:0px;'>
  2044. <input type='hidden' name='kol' value='$val'>
  2045. <input type='hidden' name='tabela' value='$_GET[tabela]'>
  2046. <input type='hidden' name='vred' value='$key'>
  2047. ";
  2048. $send .= "</form>";
  2049. $send .= "</td>
  2050. <td align='right'>$ubrez1 </td>
  2051. </tr>";
  2052. $ukupno+=$ubrez;
  2053. $ukupno1+=$uzddv;
  2054.  
  2055. }
  2056.  $ukupno=number_format ($ukupno, 2, ",", ".");
  2057.   $ukupno1=number_format ($ukupno1, 2, ",", ".");
  2058. //$ukupno1=$ukupno+($ukupno*($ddv/100));
  2059. //$ukupno=str_replace(".",",",sprintf("%4.2f",$ukupno)) ;
  2060.  
  2061. //$ukupno1=str_replace(".",",",sprintf("%4.2f",$ukupno1)) ;
  2062. $send .= "<tr><td colspan='5'>&nbsp;</td></tr>";
  2063. $send .= "<tr style='font-size:13px;font-weight:bold;background:#f1f1f1;height:20px;'><td colspan='2'>".$niz[kupovina][8]."</td><td></td>
  2064. <td align='right' colspan='3'>
  2065. <span style='font-weight:bold;font-size:13px;'>$ukupno $din</span>
  2066. </td>
  2067. </tr>";
  2068. $send .= "<tr><td colspan='5' style='padding-bottom:10px;'>
  2069. <strong>Način plaćanja:</strong> ";
  2070.  
  2071.  $send .= $nacin_placanja[$nnt];
  2072.  
  2073. $send .= "</td></tr>";
  2074. $send .= "</table>";
  2075. return $send;
  2076. }
  2077.  
  2078. function kategorije($idkat,$tab,$podkat)
  2079. {
  2080. global $conn;
  2081. $ss=mysqli_query($conn,"SELECT * FROM $tab WHERE id='$idkat'");
  2082. $ss1=mysqli_fetch_array($ss);
  2083. $in=$ss1['id'];
  2084. if($podkat==1){
  2085. $sa=mysqli_query($conn,"SELECT * FROM $tab WHERE id_parent='".$ss1['id']."'");
  2086. while($sa1=mysqli_fetch_array($sa)){
  2087. $in .=",".$sa1['id'];
  2088. $sg=mysqli_query($conn,"SELECT * FROM $tab WHERE id_parent='".$sa1['id']."'");
  2089. while($sg1=mysqli_fetch_array($sg)){
  2090. $in .=",".$sg1['id'];
  2091. $st=mysqli_query($conn,"SELECT * FROM $tab WHERE id_parent='".$sg1['id']."'");
  2092. while($sg1=mysqli_fetch_array($st)){
  2093. $in .=",".$st1['id'];
  2094. }
  2095. }
  2096. }
  2097. }
  2098. return $in;
  2099. }
  2100.  
  2101. function kategorije1($idkat,$tabela)
  2102. {
  2103. global $conn;
  2104.  
  2105.  
  2106. $sa=mysqli_query($conn,"SELECT * FROM $tabela WHERE id_parent='$idkat'");
  2107. $c=0;
  2108. while($sa1=mysqli_fetch_array($sa)){
  2109. if($c==0) $za=""; else $za=",";
  2110. $in .="$za".$sa1['id'];
  2111. $sg=mysqli_query($conn,"SELECT * FROM $tabela WHERE id_parent='$sa1[id]'");
  2112. while($sg1=mysqli_fetch_array($sg)){
  2113. $in .=",".$sg1['id'];
  2114. $st=mysqli_query($conn,"SELECT * FROM $tabela WHERE id_parent='$sg1[id]'");
  2115. while($sg1=mysqli_fetch_array($st)){
  2116. $in .=",".$st1['id'];
  2117. }
  2118. }
  2119. $c++;
  2120. }
  2121. if(empty($in)) $za=""; else $za=",";
  2122. return $idkat."$za".$in;
  2123. }
  2124. function kategorije2($idkat)
  2125. {
  2126. global $conn;
  2127. $ss=mysqli_query($conn,"SELECT * FROM kateg_proizvoda_new WHERE id='$idkat'");
  2128. $ss1=mysqli_fetch_array($ss);
  2129. $ins=$ss1['id'];
  2130.  
  2131. $sa=mysqli_query($conn,"SELECT * FROM kateg_proizvoda_new WHERE id='$ss1[id_parent]'");
  2132. while($sa1=mysqli_fetch_array($sa)){
  2133. $ins .=",".$sa1['id'];
  2134. $sg=mysqli_query($conn,"SELECT * FROM kateg_proizvoda_new WHERE id='$sa1[id_parent]'");
  2135. while($sg1=mysqli_fetch_array($sg)){
  2136. $ins .=",".$sg1['id'];
  2137. $st=mysqli_query($conn,"SELECT * FROM kateg_proizvoda_new WHERE id='$sg1[id_parent]'");
  2138. while($sg1=mysqli_fetch_array($st)){
  2139. $ins .=",".$st1['id'];
  2140. }
  2141. }
  2142. }
  2143. return $ins;
  2144. }
  2145.  
  2146. function kategorije3($idkat,$patH)
  2147. {
  2148. global $conn;
  2149. $sa=mysqli_query($conn,"SELECT * FROM kateg_proizvoda_new WHERE id='$idkat'");
  2150. $sa1=mysqli_fetch_array($sa);
  2151. if($sa1[nivo]==1)
  2152. $insa= "<a href='$patH/videos/$sa1[ime1]__$sa1[id]/' class='sc1'>$sa1[ime]</a>&raquo; ";
  2153. elseif($sa1[nivo]==2)
  2154. {
  2155. $sg=mysqli_query($conn,"SELECT * FROM kateg_proizvoda_new WHERE id='$sa1[id_parent]'");
  2156. $sg1=mysqli_fetch_array($sg);
  2157. $insa= "<a href='$patH/videos/$sg1[ime1]__$sg1[id]/' class='sc1'>$sg1[ime]</a>&raquo; <a href='$patH/videos/$sg1[ime1]__$sg1[id]/$sa1[ime1]__$sa1[id]/' class='sc1'>$sa1[ime]</a>&raquo; ";
  2158. }
  2159. elseif($sa1[nivo]==3)
  2160. {
  2161. $sg=mysqli_query($conn,"SELECT * FROM kateg_proizvoda_new WHERE id='$sa1[id_parent]'");
  2162. $sg1=mysqli_fetch_array($sg);
  2163. $sb=mysqli_query($conn,"SELECT * FROM kateg_proizvoda_new WHERE id='$sg1[id_parent]'");
  2164. $sb1=mysqli_fetch_array($sb);
  2165. $insa= "<a href='$patH/videos/$sb1[ime1]__$sb1[id]/' class='sc1'>$sb1[ime]</a>&raquo; <a href='$patH/videos/$sb1[ime1]__$sb1[id]/$sg1[ime1]__$sg1[id]/' class='sc1'>$sg1[ime]</a>&raquo; <a href='$patH/videos/$sb1[ime1]__$sb1[id]/$sg1[ime1]__$sg1[id]/$sa1[ime1]__$sa1[id]/' class='sc1'>$sa1[ime]</a>&raquo; ";
  2166. }
  2167.  
  2168.  
  2169. return $insa;
  2170. }
  2171. function kategorije4($idkat)
  2172. {
  2173. global $conn;
  2174. $sa=mysqli_query($conn,"SELECT * FROM kateg_proizvoda_new WHERE id='$idkat'");
  2175. $sa1=mysqli_fetch_array($sa);
  2176. if($sa1[nivo]==1)
  2177. $insak= " $sa1[ime] ";
  2178. elseif($sa1[nivo]==2)
  2179. {
  2180. $sg=mysqli_query($conn,"SELECT * FROM kateg_proizvoda_new WHERE id='$sa1[id_parent]'");
  2181. $sg1=mysqli_fetch_array($sg);
  2182. $insak= " $sg1[ime], $sa1[ime], ";
  2183. }
  2184. elseif($sa1[nivo]==3)
  2185. {
  2186. $sg=mysqli_query($conn,"SELECT * FROM kateg_proizvoda_new WHERE id='$sa1[id_parent]'");
  2187. $sg1=mysqli_fetch_array($sg);
  2188. $sb=mysqli_query($conn,"SELECT * FROM kateg_proizvoda_new WHERE id='$sg1[id_parent]'");
  2189. $sb1=mysqli_fetch_array($sb);
  2190. $insak= " $sb1[ime], $sg1[ime], $sa1[ime], ";
  2191. }
  2192.  
  2193.  
  2194. return $insak;
  2195. }
  2196. function kategorije5($idkat)
  2197. {
  2198. global $conn;
  2199. $in="";
  2200. //echo kategorije1($likat1['id'], "kateg_proizvoda_new")."<br>";
  2201. $sa=mysqli_query($conn,"SELECT * FROM kateg_proizvoda_new WHERE id_parent='$idkat'");
  2202. $c=0;
  2203. while($sa1=mysqli_fetch_array($sa)){
  2204. if($c==0) $za=""; else $za=",";
  2205. $in .="$za".$sa1['id'];
  2206. $c++;
  2207. }
  2208. if(empty($in)) $za=""; else $za=",";
  2209. return $idkat."$za".$in;
  2210. }
  2211. function back_category($kateg, $tabela)
  2212. {
  2213. global $patH;
  2214. global $conn;
  2215. $niz=array();
  2216. $ar=mysqli_query($conn,"SELECT * FROM $tabela WHERE id=$kateg");
  2217. $ar1=mysqli_fetch_array($ar);
  2218. //$niz[0]=$kateg;
  2219. $niz[1]="<a href='$patH/videos/$ar1[ime1]/' title='$ar1[ime]'>$ar1[ime]</a>";
  2220. if($ar1[id_parent]>0)
  2221. {
  2222. $zr=mysqli_query($conn,"SELECT * FROM $tabela WHERE id=$ar1[id_parent]");
  2223. $zr1=mysqli_fetch_array($zr);
  2224. $niz[2]="<a href='$patH/videos/$zr1[ime1]/' title='$zr1[ime]'>$zr1[ime]</a>";
  2225. }
  2226. if($zr1[id_parent]>0)
  2227. {
  2228. $cr=mysqli_query($conn,"SELECT * FROM $tabela WHERE id=$zr1[id_parent]");
  2229. $cr1=mysqli_fetch_array($cr);
  2230. $niz[3]="<a href='$patH/videos/$cr1[ime1]/' title='$cr1[ime]'>$cr1[ime]</a>";
  2231. }
  2232. $fir_kateg=array_reverse($niz);
  2233. $fkateg=implode(" &raquo; ",$fir_kateg)." &raquo;";
  2234. /*foreach($fir_kateg as $key => $val)
  2235. {
  2236.  
  2237. $fkateg[]=$fir_kateg[$key];
  2238. }*/
  2239. return $fkateg;
  2240. }
  2241.  
  2242. function cena_u_EVR($cc, $valuta)
  2243. {
  2244. global $settings;
  2245. if($valuta=="rsd")
  2246. $cc=$cc/$settings['evro_iznos'];
  2247. $cc1=sprintf("%4.2f",$cc);
  2248. return $cc1;
  2249. }
  2250.  
  2251. function format_ceneSES($cc,$valuta,$idv)
  2252. {
  2253. global $settings;
  2254. global $conn;
  2255. if($idv==1)
  2256. $cc=$cc*$settings['evro_iznos'];
  2257. else
  2258. if($idv==2)
  2259. $cc=$cc/$settings['evro_iznos'];
  2260.  
  2261. $cc1=sprintf("%4.2f",$cc);
  2262. $cc2=number_format ($cc1, 2, ".", ",");
  2263. return $cc2." ".$valuta;
  2264. }
  2265. function format_ceneSES1($cc,$valuta)
  2266. {
  2267. global $settings;
  2268. global $conn;
  2269. if($valuta=="rsd")
  2270. $cc=$cc*$settings['evro_iznos'];
  2271.  
  2272. return $cc;
  2273. }
  2274.  
  2275. function format_ceneEU($cc,$vas,$nn="")
  2276. {
  2277. global $conn;
  2278. $cc1=sprintf("%4.2f",$cc);
  2279. $cc2=number_format ($cc1, 2, ",", ".");
  2280. if($nn=="n")
  2281. return $cc2;
  2282. else
  2283. return $cc2." ".$vas;
  2284. }
  2285.  
  2286. function format_ceneED($cc,$idv)
  2287. {
  2288. global $settings;
  2289. $cc=$cc*$idv;
  2290. $vas=" RSD";
  2291. $cc1=sprintf("%4.2f",$cc);
  2292. $cc2=number_format ($cc1, 2, ".", ",");
  2293. return $cc2.$vas;
  2294. }
  2295. function format_ceneS($cc,$idv)
  2296. {
  2297. global $settings;
  2298. if($idv>0)
  2299. $cc=$cc*$settings['evro_iznos'];
  2300. if($idv>0) $vas=" RSD"; else $vas=" &euro;";
  2301. $cc1=sprintf("%4.2f",$cc);
  2302. $cc2=number_format ($cc1, 2, ".", ",");
  2303. return $cc2.$vas;
  2304. }
  2305. function format_ceneS1($cc,$idv)
  2306. {
  2307. global $settings;
  2308. if($idv>0)
  2309. $cc=$cc*$settings['evro_iznos'];
  2310.  
  2311. $cc1=sprintf("%4.2f",$cc);
  2312. $cc2=number_format ($cc1, 2, ".", "");
  2313. return $cc2;
  2314. }
  2315. function format_ceneSS($cc,$idv)
  2316. {
  2317. global $settings;
  2318. if($idv>0)
  2319. $cc=$cc*$settings['evro_iznos'];
  2320.  
  2321. return $cc;
  2322. }
  2323. function format_ceneS2($cc,$idv)
  2324. {
  2325. global $settings;
  2326. if($idv>0)
  2327. $cc=$cc*$settings['evro_iznos'];
  2328.  $vas=" RSD";
  2329. $cc1=sprintf("%4.2f",$cc);
  2330. $cc2=number_format ($cc1, 2, ".", ",");
  2331. return $cc2.$vas;
  2332. }
  2333. ############### CENE format ###############
  2334. function format_cenec($id)
  2335. {
  2336.  
  2337. $cc=$id;
  2338. $cc1=sprintf("%4.2f",$cc);
  2339. $cc2=number_format ($cc1, 2, ",", ".");
  2340. $sddv1=sprintf("%4.2f",($cc1+($cc1*($ddv/100))));
  2341. $sddv2=number_format ($sddv1, 2, ",", ".");
  2342. //$ubrez=$cc1;
  2343. //$ubrez1=number_format ($ubrez, 2, ",", ".");
  2344. $uzddv=$sddv1;
  2345. $uzddv1=number_format ($uzddv, 2, ",", ".");
  2346. return $uzddv1;
  2347. }
  2348.  
  2349. function format_cene($cena1,$cena,$ddv)
  2350. {
  2351. //$kor=mysqli_query($conn,"SELECT * FROM proizvodi_new WHERE id='$id'");
  2352. //$kor1=mysqli_fetch_array($kor);
  2353.  
  2354. if($cena1>0){
  2355.  
  2356. $cc=$cena1;
  2357. $cc1=sprintf("%4.2f",$cc);
  2358. $cc2=number_format ($cc1, 2, ",", ".");
  2359. $sddv1=sprintf("%4.2f",($cc1+($cc1*($ddv/100))));
  2360. $sddv2=number_format ($sddv1, 2, ",", ".");
  2361. //$ubrez=$cc1;
  2362. //$ubrez1=number_format ($ubrez, 2, ",", ".");
  2363. $uzddv=$sddv1;
  2364. $uzddvA1=number_format ($uzddv, 2, ",", ".");
  2365. }else $uzddvA1=0;
  2366.  
  2367. $cc=$cena;
  2368. $cc1=sprintf("%4.2f",$cc);
  2369. $cc2=number_format ($cc1, 2, ",", ".");
  2370. $sddv1=sprintf("%4.2f",($cc1+($cc1*($ddv/100))));
  2371. $sddv2=number_format ($sddv1, 2, ",", ".");
  2372. //$ubrez=$cc1;
  2373. //$ubrez1=number_format ($ubrez, 2, ",", ".");
  2374. $uzddv=$sddv1;
  2375. $uzddv1=number_format ($uzddv, 2, ",", ".");
  2376. return $uzddv1."-".$uzddvA1;
  2377. }
  2378.  
  2379.  
  2380.  
  2381.  
  2382.  
  2383.  function tep_rand($min = null, $max = null) {
  2384.     static $seeded;
  2385.  
  2386.     if (!$seeded) {
  2387.       mt_srand((double)microtime()*1000000);
  2388.       $seeded = true;
  2389.     }
  2390.  
  2391.     if (isset($min) && isset($max)) {
  2392.       if ($min >= $max) {
  2393.         return $min;
  2394.       } else {
  2395.         return mt_rand($min, $max);
  2396.       }
  2397.     } else {
  2398.       return mt_rand();
  2399.     }
  2400.   }
  2401.    function tep_not_null($value) {
  2402.     if (is_array($value)) {
  2403.       if (sizeof($value) > 0) {
  2404.         return true;
  2405.       } else {
  2406.         return false;
  2407.       }
  2408.     } else {
  2409.       if ( (is_string($value) || is_int($value)) && ($value != '') && ($value != 'NULL') && (strlen(trim($value)) > 0)) {
  2410.         return true;
  2411.       } else {
  2412.         return false;
  2413.       }
  2414.     }
  2415.   }
  2416.  
  2417.   function tep_validate_password($plain, $encrypted) {
  2418.     if (tep_not_null($plain) && tep_not_null($encrypted)) {
  2419. // split apart the hash / salt
  2420.       $stack = explode(':', $encrypted);
  2421.  
  2422.       if (sizeof($stack) != 2) return false;
  2423.  
  2424.       if (md5($stack[1] . $plain) == $stack[0]) {
  2425.         return true;
  2426.       }
  2427.     }
  2428.  
  2429.     return false;
  2430.   }
  2431.  
  2432.  
  2433.  
  2434.   function tep_encrypt_password($plain) {
  2435.     $password = '';
  2436.  
  2437.     for ($i=0; $i<10; $i++) {
  2438.       $password .= tep_rand();
  2439.     }
  2440.  
  2441.     $salt = substr(md5($password), 0, 2);
  2442.  
  2443.     $password = md5($salt . $plain) . ':' . $salt;
  2444.  
  2445.     return $password;
  2446.   }
  2447.  
  2448.  
  2449.  
  2450. function create_table($table,$fix,$database_conn)
  2451. {
  2452. global $conn;
  2453. $structure = "CREATE TABLE IF NOT EXISTS  `".$table."` (\n";
  2454.         $records = @mysqli_query($conn,'SHOW FIELDS FROM `'.$table.'`');
  2455.         if ( @mysqli_num_rows($records) == 0 )
  2456.             return false;
  2457.             $n=0;
  2458.         while ( $record = mysqli_fetch_assoc($records) ) {
  2459.         if(n==0) $prim=$record['Field'];
  2460.             $structure .= '`'.$record['Field'].'` '.$record['Type'];
  2461.             if ( !empty($record['Default']) )
  2462.                 $structure .= ' DEFAULT \''.$record['Default'].'\'';
  2463.             if ( @strcmp($record['Null'],'YES') != 0 )
  2464.                 $structure .= ' NOT NULL';
  2465.             //if ( !empty($record['Extra']) )
  2466.             //  $structure .= ' '.$record['Extra'];
  2467.             $structure .= ",\n";
  2468.             $n++;
  2469.         }
  2470.         $x = mysql_list_fields($database_conn, $table);
  2471.  
  2472.  
  2473. for ($i = 0; $i < 1; $i++) {
  2474.   $prim ="(`".mysql_field_name($x, $i)."`)";
  2475. }
  2476.  
  2477.         $structure .= "PRIMARY KEY". $prim."\n";
  2478.         $structure = @str_replace(",\n$", null, $structure);
  2479.  
  2480.         // Save all Column Indexes
  2481.     //  $structure .= $this->getSqlKeysTable($table);
  2482.         $structure .= "\n)";
  2483.  
  2484.         //Save table engine
  2485.         $records = @mysqli_query($conn,"SHOW TABLE STATUS LIKE '".$table."'");
  2486.  
  2487.         if ( $record = @mysqli_fetch_assoc($records) ) {
  2488.             if ( !empty($record['Engine']) )
  2489.                 $structure .= ' ENGINE='.$record['Engine'];
  2490.             if ( !empty($record['Auto_increment']) )
  2491.                 $structure .= ' DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci
  2492.        AUTO_INCREMENT='.$record['Auto_increment'];
  2493.         }
  2494.  
  2495.         $structure .= ";";
  2496.  
  2497. $structure .= "";
  2498.         $tab=$fix."_".$table;
  2499.         $str=str_replace("$table","$tab",$structure);
  2500.     mysqli_query($conn,"$str");
  2501.  
  2502. }
  2503. function isTextValue($field_type) {
  2504.         switch ($field_type) {
  2505.             case "tinytext":
  2506.             case "text":
  2507.             case "mediumtext":
  2508.             case "longtext":
  2509.             case "binary":
  2510.             case "varbinary":
  2511.             case "tinyblob":
  2512.             case "blob":
  2513.             case "mediumblob":
  2514.             case "longblob":
  2515.                 return True;
  2516.                 break;
  2517.             default:
  2518.                 return False;
  2519.         }
  2520.     }
  2521.     function getTableData($table,$fix,$hexValue = false) {
  2522.  
  2523.         // Header
  2524.  
  2525.  
  2526.         $records = mysqli_query($conn,'SHOW FIELDS FROM `'.$table.'`');
  2527.         $num_fields = @mysqli_num_rows($records);
  2528.         if ( $num_fields == 0 )
  2529.             return false;
  2530.         // Field names
  2531.         $selectStatement = "SELECT ";
  2532.         $insertStatement = "INSERT INTO `$fix$table` (";
  2533.         $hexField = array();
  2534.         for ($x = 0; $x < $num_fields; $x++) {
  2535.             $record = @mysqli_fetch_assoc($records);
  2536.             if ( ($hexValue) && (isTextValue($record['Type'])) ) {
  2537.                 $selectStatement .= 'HEX(`'.$record['Field'].'`)';
  2538.                 $hexField [$x] = true;
  2539.             }
  2540.             else
  2541.                 $selectStatement .= '`'.$record['Field'].'`';
  2542.             $insertStatement .= '`'.$record['Field'].'`';
  2543.             $insertStatement .= ", ";
  2544.             $selectStatement .= ", ";
  2545.         }
  2546.         $insertStatement = @substr($insertStatement,0,-2).') VALUES';
  2547.         $selectStatement = @substr($selectStatement,0,-2).' FROM `'.$table.'`';
  2548.  
  2549.         $records = @mysqli_query($conn,$selectStatement);
  2550.         $num_rows = @mysqli_num_rows($records);
  2551.         $num_fields = @mysql_num_fields($records);
  2552.         // Dump data
  2553.         if ( $num_rows > 0 ) {
  2554.             $data .= $insertStatement;
  2555.             for ($i = 0; $i < $num_rows; $i++) {
  2556.                 $record = @mysqli_fetch_assoc($records);
  2557.                 $data .= ' (';
  2558.                 for ($j = 0; $j < $num_fields; $j++) {
  2559.                     $field_name = @mysql_field_name($records, $j);
  2560.                     if ( $hexField[$j] && (@strlen($record[$field_name]) > 0) )
  2561.                         $data .= "0x".$record[$field_name];
  2562.                     else
  2563.                         $data .= "'".@str_replace('\"','"',@mysql_escape_string($record[$field_name]))."'";
  2564.                     $data .= ',';
  2565.                 }
  2566.                 $data = @substr($data,0,-1).")";
  2567.                 $data .= ( $i < ($num_rows-1) ) ? ',' : ';';
  2568.  
  2569.                 //if data in greather than 1MB save
  2570.  
  2571.             }
  2572.              mysqli_query($conn,$data);
  2573.  
  2574.         }
  2575.     }
  2576.         function getTableData1($table,$fix,$idpage,$hexValue = false) {
  2577. global $conn;
  2578.         $records = mysqli_query($conn,'SHOW FIELDS FROM `'.$table.'`');
  2579.         $num_fields = @mysqli_num_rows($records);
  2580.         if ( $num_fields == 0 )
  2581.             return false;
  2582.         // Field names
  2583.         $selectStatement = "SELECT ";
  2584.         $insertStatement = "INSERT INTO `$table` (";
  2585.         $hexField = array();
  2586.         for ($x = 0; $x < $num_fields; $x++) {
  2587.             $record = @mysqli_fetch_assoc($records);
  2588.             if ( ($hexValue) && (isTextValue($record['Type'])) ) {
  2589.                 $selectStatement .= 'HEX(`'.$record['Field'].'`)';
  2590.                 $hexField [$x] = true;
  2591.             }
  2592.             else
  2593.                 $selectStatement .= '`'.$record['Field'].'`';
  2594.             if($x>0){
  2595.             $insertStatement .= '`'.$record['Field'].'`';
  2596.             $insertStatement .= ", ";
  2597.             }
  2598.             $selectStatement .= ", ";
  2599.         }
  2600.         $insertStatement = @substr($insertStatement,0,-2).') VALUES';
  2601.         $selectStatement = @substr($selectStatement,0,-2).' FROM `'.$table.'` WHERE id_page='.$idpage.'';
  2602.  
  2603.         $records = @mysqli_query($conn,$selectStatement);
  2604.         $num_rows = @mysqli_num_rows($records);
  2605.         $num_fields = @mysql_num_fields($records);
  2606.         // Dump data
  2607.         if ( $num_rows > 0 ) {
  2608.             $data .= $insertStatement;
  2609.             for ($i = 0; $i < $num_rows; $i++) {
  2610.                 $record = @mysqli_fetch_assoc($records);
  2611.                 $data .= ' (';
  2612.                 for ($j = 0; $j < $num_fields; $j++) {
  2613.                     $field_name = @mysql_field_name($records, $j);
  2614.                     if ( $hexField[$j] && (@strlen($record[$field_name]) > 0) )
  2615.                         $data .= "".$record[$field_name];
  2616.                         else
  2617.                     {
  2618.  
  2619.                     if($j>0 and $j!=$num_fields-1)
  2620.                     {
  2621.                         $data .= "'".@str_replace('\"','"',@mysql_escape_string($record[$field_name]))."'";
  2622.                     $data .= ',';
  2623.                     }
  2624.                         if($j==$num_fields-1)
  2625.                     {
  2626.  
  2627.                         $data .= "'".@str_replace('\"','"',$fix)."'";
  2628.                     $data .= "'";
  2629.                     }
  2630.                 }
  2631.                     $data .= '';
  2632.                 }
  2633.                 $data = @substr($data,0,-1).")";
  2634.                 $data .= ( $i < ($num_rows-1) ) ? ',' : ';';
  2635.  
  2636.                 //if data in greather than 1MB save
  2637.  
  2638.             }
  2639.  
  2640.              mysqli_query($conn,$data);
  2641.  
  2642.         }
  2643.     }
  2644.         function getTableData2($table,$fix,$idpage,$hexValue = false) {
  2645.     global $conn;
  2646. $fix1 .=$fix."_";
  2647.         $records = mysqli_query($conn,'SHOW FIELDS FROM `'.$table.'`');
  2648.         $num_fields = @mysqli_num_rows($records);
  2649.         if ( $num_fields == 0 )
  2650.             return false;
  2651.         // Field names
  2652.         $selectStatement = "SELECT ";
  2653.         $insertStatement = "INSERT INTO `$fix1$table` (";
  2654.         $hexField = array();
  2655.         for ($x = 0; $x < $num_fields; $x++) {
  2656.             $record = @mysqli_fetch_assoc($records);
  2657.             if ( ($hexValue) && (isTextValue($record['Type'])) ) {
  2658.                 $selectStatement .= 'HEX(`'.$record['Field'].'`)';
  2659.                 $hexField [$x] = true;
  2660.             }
  2661.             else
  2662.                 $selectStatement .= '`'.$record['Field'].'`';
  2663.  
  2664.             $insertStatement .= '`'.$record['Field'].'`';
  2665.             $insertStatement .= ", ";
  2666.  
  2667.             $selectStatement .= ", ";
  2668.         }
  2669.         $insertStatement = @substr($insertStatement,0,-2).') VALUES';
  2670.         $selectStatement = @substr($selectStatement,0,-2).' FROM `'.$table.'` WHERE id_page='.$idpage.'';
  2671.  
  2672.         $records = @mysqli_query($conn,$selectStatement);
  2673.         $num_rows = @mysqli_num_rows($records);
  2674.         $num_fields = @mysql_num_fields($records);
  2675.         // Dump data
  2676.         if ( $num_rows > 0 ) {
  2677.             $data .= $insertStatement;
  2678.             for ($i = 0; $i < $num_rows; $i++) {
  2679.                 $record = @mysqli_fetch_assoc($records);
  2680.                 $data .= ' (';
  2681.                 for ($j = 0; $j < $num_fields; $j++) {
  2682.                     $field_name = @mysql_field_name($records, $j);
  2683.                     if ( $hexField[$j] && (@strlen($record[$field_name]) > 0) )
  2684.                         $data .= "".$record[$field_name];
  2685.                         else
  2686.                     {
  2687.  
  2688.                     if($j!=$num_fields-1)
  2689.                     {
  2690.                         $data .= "'".@str_replace('\"','"',@mysql_escape_string($record[$field_name]))."'";
  2691.                     $data .= ',';
  2692.                     }
  2693.                         if($j==$num_fields-1)
  2694.                     {
  2695.  
  2696.                         $data .= "'".@str_replace('\"','"',$fix)."'";
  2697.                     $data .= "'";
  2698.                     }
  2699.                 }
  2700.                     $data .= '';
  2701.                 }
  2702.                 $data = @substr($data,0,-1).")";
  2703.                 $data .= ( $i < ($num_rows-1) ) ? ',' : ';';
  2704.  
  2705.                 //if data in greather than 1MB save
  2706.  
  2707.             }
  2708.  
  2709.  
  2710.  
  2711.         }    mysqli_query($conn,$data);
  2712.     }
  2713.  
  2714.  
  2715. function del_slike($kolona,$idupisa,$jezik){
  2716. global $patH;
  2717. global $page_path2;
  2718. global $conn;
  2719.  
  2720. $pic=$page_path2."/galerija/$slika";
  2721.     $sel=mysqli_query($conn,"SELECT * FROM slike_paintb WHERE $kolona='$idupisa' AND jezik='$jezik'");
  2722. while($sel1=@mysqli_fetch_array($sel)){
  2723. $sl="slika";
  2724. $el=mysqli_query($conn,"SELECT * FROM slike_paintb WHERE slika='$sel1[$sl]'");
  2725. if(strlen($sel1[$sl])>2 and mysqli_num_rows($el)==1){
  2726. unlink("$page_path2/galerija/$sel1[$sl]");
  2727. unlink("$page_path2/galerija/thumb/$sel1[$sl]");
  2728. }
  2729. }
  2730. }
  2731. function del_files($kolona,$idupisa,$jezik){
  2732. global $conn;
  2733. $sel=mysqli_query($conn,"SELECT * FROM files WHERE $kolona='$idupisa' AND jezik='$jezik'");
  2734. while($sel1=@mysqli_fetch_array($sel)){
  2735. $sl="opis";
  2736. $el=mysqli_query($conn,"SELECT * FROM files WHERE opis='$sel1[opis]'");
  2737. if(strlen($sel1[opis])>2 and mysqli_num_rows($el)==1){
  2738. unlink("$page_path2/files/$sel1[$sl]");
  2739. }
  2740. }
  2741. }
  2742. function del_galerije($id_page,$tabela){
  2743. global $patH;
  2744. global $page_path2;
  2745. global $conn;
  2746. $pic=$page_path2."/galerija/$slika";
  2747.     $sel=mysqli_query($conn,"SELECT * FROM $tabela WHERE id_page='$id_page'");
  2748. while($sel1=mysqli_fetch_array($sel)){
  2749. $sl="slika1";
  2750. $el=mysqli_query($conn,"SELECT * FROM $tabela WHERE slika1='$sel1[$sl]'");
  2751. if(strlen($sel1[$sl])>2 and mysqli_num_rows($el)==1){
  2752. unlink("$page_path2/galerija/$sel1[$sl]");
  2753. unlink("$page_path2/galerija/thumb/$sel1[$sl]");
  2754. }
  2755. }
  2756. }
  2757. function freeRTE_Preload($content) {
  2758.     // Strip newline characters.
  2759.     $content = str_replace(chr(10), " ", $content);
  2760.     $content = str_replace(chr(13), " ", $content);
  2761.     // Replace single quotes.
  2762.     $content = str_replace(chr(145), chr(39), $content);
  2763.     $content = str_replace(chr(146), chr(39), $content);
  2764.     // Return the result.
  2765.     return $content;
  2766. }
  2767.  function curPageURL() {
  2768.  $pageURL = 'http';
  2769.  if ($_SERVER["HTTPS"] == "on") {$pageURL .= "s";}
  2770.  $pageURL .= "://";
  2771.  if ($_SERVER["SERVER_PORT"] != "80") {
  2772.   $pageURL .= $_SERVER["SERVER_NAME"].$_SERVER["REQUEST_URI"];
  2773.  } else {
  2774.   $pageURL .= $_SERVER["SERVER_NAME"].$_SERVER["REQUEST_URI"];
  2775.  }
  2776.  return urldecode(str_replace(":443","",$pageURL));
  2777. }
  2778. function iframeYT($ytcode, $width, $height, $autopl="") {
  2779. if($autopl==1) $autoplay="?autoplay=1";
  2780. if($ytcode!="")
  2781.  $text= '<iframe src="http://www.youtube.com/embed/'.$ytcode.$autoplay.'" width="'.$width.'" height="'.$height.'" style="padding-right:5px;padding-bottom:5px;padding-top:5px;" frameborder="0"></iframe>';
  2782.  else $text="No video";
  2783.     return $text;
  2784.  
  2785. }
  2786. function youtubeVideo($text, $width, $height) {
  2787. if(mb_eregi("vimeo.com",$text) or mb_eregi("www.youtu",$text) or  mb_eregi("http://youtu.be",$text)){
  2788.  if(mb_eregi("vimeo",$text)){
  2789.  $idv = preg_replace ( '/[^0-9]/', '', $text );
  2790.  $text='<iframe src="http://player.vimeo.com/video/'.$idv.'?byline=0&amp;portrait=0" width="'.$width.'" height="'.$height.'" frameborder="0" webkitAllowFullScreen mozallowfullscreen allowFullScreen></iframe>';
  2791.  }else{
  2792.     $text = preg_replace('~
  2793.        # Match non-linked youtube URL in the wild. (Rev:20111012)
  2794.        https?://         # Required scheme. Either http or https.
  2795.        (?:[0-9A-Z-]+\.)? # Optional subdomain.
  2796.        (?:               # Group host alternatives.
  2797.          youtu\.be/      # Either youtu.be,
  2798.        | youtube\.com    # or youtube.com followed by
  2799.          \S*             # Allow anything up to VIDEO_ID,
  2800.          [^\w\-\s]       # but char before ID is non-ID char.
  2801.        )                 # End host alternatives.
  2802.        ([\w\-]{11})      # $1: VIDEO_ID is exactly 11 chars.
  2803.        (?=[^\w\-]|$)     # Assert next char is non-ID or EOS.
  2804.        (?!               # Assert URL is not pre-linked.
  2805.          [?=&+%\w]*      # Allow URL (query) remainder.
  2806.          (?:             # Group pre-linked alternatives.
  2807.            [\'"][^<>]*>  # Either inside a start tag,
  2808.          | </a>          # or inside <a> element text contents.
  2809.          )               # End recognized pre-linked alts.
  2810.        )                 # End negative lookahead assertion.
  2811.        [?=&+%\w]*        # Consume any URL (query) remainder.
  2812.        ~ix',
  2813.         '<iframe src="http://www.youtube.com/embed/$1" width="'.$width.'" height="'.$height.'" style="padding-right:5px;padding-bottom:5px;padding-top:5px;" frameborder="0"></iframe><br />',
  2814.         $text);
  2815.         }
  2816.     return $text;
  2817.     }else return "";
  2818. }
  2819. function youtubeURL($text) {
  2820. if(mb_eregi("vimeo.com",$text) or mb_eregi("www.youtu",$text) or  mb_eregi("http://youtu.be",$text)){
  2821.  if(mb_eregi("vimeo",$text)){
  2822.  $idv = preg_replace ( '/[^0-9]/', '', $text );
  2823.  $text='http://player.vimeo.com/video/'.$idv.'';
  2824.  }else{
  2825.     $text = preg_replace('~
  2826.        # Match non-linked youtube URL in the wild. (Rev:20111012)
  2827.        https?://         # Required scheme. Either http or https.
  2828.        (?:[0-9A-Z-]+\.)? # Optional subdomain.
  2829.        (?:               # Group host alternatives.
  2830.          youtu\.be/      # Either youtu.be,
  2831.        | youtube\.com    # or youtube.com followed by
  2832.          \S*             # Allow anything up to VIDEO_ID,
  2833.          [^\w\-\s]       # but char before ID is non-ID char.
  2834.        )                 # End host alternatives.
  2835.        ([\w\-]{11})      # $1: VIDEO_ID is exactly 11 chars.
  2836.        (?=[^\w\-]|$)     # Assert next char is non-ID or EOS.
  2837.        (?!               # Assert URL is not pre-linked.
  2838.          [?=&+%\w]*      # Allow URL (query) remainder.
  2839.          (?:             # Group pre-linked alternatives.
  2840.            [\'"][^<>]*>  # Either inside a start tag,
  2841.          | </a>          # or inside <a> element text contents.
  2842.          )               # End recognized pre-linked alts.
  2843.        )                 # End negative lookahead assertion.
  2844.        [?=&+%\w]*        # Consume any URL (query) remainder.
  2845.        ~ix',
  2846.         'http://www.youtube.com/embed/$1',
  2847.         $text);
  2848.         }
  2849.     return $text;
  2850.     }else return "";
  2851. }
  2852.  
  2853. function youtube_id_from_url($url) {
  2854.     $pattern =
  2855.         '%^# Match any youtube URL
  2856.        (?:https?://)?  # Optional scheme. Either http or https
  2857.        (?:www\.)?      # Optional www subdomain
  2858.        (?:             # Group host alternatives
  2859.          youtu\.be/    # Either youtu.be,
  2860.        | youtube\.com  # or youtube.com
  2861.          (?:           # Group path alternatives
  2862.            /embed/     # Either /embed/
  2863.          | /v/         # or /v/
  2864.          | /watch\?v=  # or /watch\?v=
  2865.          )             # End path alternatives.
  2866.        )               # End host alternatives.
  2867.        ([\w-]{10,12})  # Allow 10-12 for 11 char youtube id.
  2868.        $%x'
  2869.         ;
  2870.     $result = preg_match($pattern, $url, $matches);
  2871.     if (false !== $result) {
  2872.         return @$matches[1];
  2873.     }
  2874.     return false;
  2875. }
  2876.  
  2877. function isValidYoutubeURL($yid) {
  2878. $url = "http://www.youtube.com/watch?v=$yid";
  2879.  
  2880.     // Let's check the host first
  2881.     $parse = parse_url($url);
  2882.     $host = $parse['host'];
  2883.     if (!in_array($host, array('youtube.com', 'www.youtube.com'))) {
  2884.         return false;
  2885.     }
  2886.  
  2887.     $ch = curl_init();
  2888.     $oembedURL = 'www.youtube.com/oembed?url=' . urlencode($url).'&format=json';
  2889.     curl_setopt($ch, CURLOPT_URL, $oembedURL);
  2890.     curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
  2891.  
  2892.     // Silent CURL execution
  2893.     $output = curl_exec($ch);
  2894.     unset($output);
  2895.  
  2896.     $info = curl_getinfo($ch);
  2897.     curl_close($ch);
  2898.  
  2899.     if ($info['https_code'] !== 404)
  2900.         return true;
  2901.     else
  2902.         return false;
  2903. }
  2904.  
  2905. function isEmbeddableYoutubeURL($url) {
  2906.  
  2907.     // Let's check the host first
  2908.     $parse = parse_url($url);
  2909.     $host = $parse['host'];
  2910.     if (!in_array($host, array('youtube.com', 'www.youtube.com'))) {
  2911.         return false;
  2912.     }
  2913.  
  2914.     $ch = curl_init();
  2915.     $oembedURL = 'www.youtube.com/oembed?url=' . urlencode($url).'&format=json';
  2916.     curl_setopt($ch, CURLOPT_URL, $oembedURL);
  2917.     curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
  2918.     $output = curl_exec($ch);
  2919.     curl_close($ch);
  2920.  
  2921.     $data = json_decode($output);
  2922.  
  2923.     if (!$data) return false; // Either 404 or 401 (Unauthorized)
  2924.     if (!$data->{'html'}) return false; // Embeddable video MUST have 'html' provided
  2925.  
  2926.     return true;
  2927. }
  2928. function getVimeoThumb($id) {
  2929. if($id!="")
  2930. {
  2931.     $data = @file_get_contents("http://vimeo.com/api/v2/video/$id.json");
  2932.     $data = json_decode($data);
  2933.     return $data[0]->thumbnail_medium;
  2934. }
  2935. }
  2936. function VimeoDuration($id) {
  2937. if($id!="")
  2938. {
  2939.     $data = @file_get_contents("http://vimeo.com/api/v2/video/$id.json");
  2940.     $data = json_decode($data);
  2941.     return $data[0]->duration;
  2942. }
  2943. }
  2944. function parse_vimeo($link){
  2945.  
  2946.         $regexstr = '~
  2947.            # Match Vimeo link and embed code
  2948.            (?:<iframe [^>]*src=")?       # If iframe match up to first quote of src
  2949.            (?:                         # Group vimeo url
  2950.                https?:\/\/             # Either http or https
  2951.                (?:[\w]+\.)*            # Optional subdomains
  2952.                vimeo\.com              # Match vimeo.com
  2953.                (?:[\/\w]*\/videos?)?   # Optional video sub directory this handles groups links also
  2954.                \/                      # Slash before Id
  2955.                ([0-9]+)                # $1: VIDEO_ID is numeric
  2956.                [^\s]*                  # Not a space
  2957.            )                           # End group
  2958.            "?                          # Match end quote if part of src
  2959.            (?:[^>]*></iframe>)?        # Match the end of the iframe
  2960.            (?:<p>.*</p>)?              # Match any title information stuff
  2961.            ~ix';
  2962.  
  2963.         preg_match($regexstr, $link, $matches);
  2964.  if($matches[1]=="")
  2965.  {
  2966.  $must=explode("/",$link);
  2967.  $must1=array_reverse($must);
  2968.  if($must1[0]>0)
  2969.  $matches[1]=$must1[0];
  2970.  else
  2971.  $matches[1]=$must1[1];
  2972.  }
  2973.         return $matches[1];
  2974.  
  2975.     }
  2976.  function iframeVI($ytcode, $width, $height, $autopl="") {
  2977.  
  2978. if($autopl==1) $autoplay="?autoplay=1";
  2979. if($ytcode!="")
  2980.  $text= '<iframe src="//player.vimeo.com/video/'.$ytcode.$autoplay.'" width="'.$width.'" height="'.$height.'" style="padding-right:5px;padding-bottom:5px;padding-top:5px;" frameborder="0"></iframe>';
  2981.  else $text="No video";
  2982.     return $text;
  2983.  
  2984. }
  2985. function getDuration($yid){
  2986.  $url = "http://www.youtube.com/watch?v=$yid";
  2987.         parse_str(parse_url($url,PHP_URL_QUERY),$arr);
  2988.         $video_id=$arr['v'];
  2989.  
  2990.  
  2991.         $data=@file_get_contents('http://gdata.youtube.com/feeds/api/videos/'.$video_id.'?v=2&alt=jsonc');
  2992.         if (false===$data) return false;
  2993.  
  2994.         $obj=json_decode($data);
  2995.  
  2996.         return @$obj->data->duration;
  2997.     }
  2998.  
  2999. function getVimeoInfo($link)
  3000.  {
  3001.     if (preg_match('~^http://(?:www\.)?vimeo\.com/(?:clip:)?(\d+)~', $link, $match))
  3002.     {
  3003.         $id = $match[1];
  3004.     }
  3005.     else
  3006.     {
  3007.         $id = substr($link,10,strlen($link));
  3008.     }
  3009.  
  3010.     if (!function_exists('curl_init')) die('CURL is not installed!');
  3011.     $ch = curl_init();
  3012.     curl_setopt($ch, CURLOPT_URL, "http://vimeo.com/api/v2/video/$id.php");
  3013.     curl_setopt($ch, CURLOPT_HEADER, 0);
  3014.     curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
  3015.     curl_setopt($ch, CURLOPT_TIMEOUT, 10);
  3016.     $output = unserialize(curl_exec($ch));
  3017.     $output = $output[0];
  3018.     curl_close($ch);
  3019.     return $output;
  3020. }
  3021. function save_image_local($thumbnail_url)
  3022.     {
  3023.  
  3024.          //for save image at local server
  3025.          $filename = time().'_hbk.jpg';
  3026.          $fullpath = '../../app/webroot/img/videos/image/'.$filename;
  3027.  
  3028.          file_put_contents ($fullpath,file_get_contents($thumbnail_url));
  3029.  
  3030.         return $filename;
  3031.     }
  3032.  function header_404()
  3033. {
  3034. global $page_path2;
  3035.  
  3036.   header("Status: 404 Not Found");
  3037.   @include("404.html");
  3038.   echo "<title>Izbrana stranica ne postoji</title>";
  3039.   exit();
  3040. }
  3041. function ae_detect_ie()
  3042. {
  3043.     if (isset($_SERVER['HTTP_USER_AGENT']) &&
  3044.     (strpos($_SERVER['HTTP_USER_AGENT'], 'MSIE') !== false))
  3045.         return true;
  3046.     else
  3047.         return false;
  3048. }
  3049. function base_ret($base)
  3050. {
  3051. $baser=explode("/", strip_tags($base));
  3052. $baser=array_filter($baser);
  3053. //$baser=implode("/",$baser);
  3054. return $baser;
  3055. }
  3056. function base_ret_rev($base)
  3057. {
  3058. $baser=explode("/", strip_tags($base));
  3059. $baser=array_filter($baser);
  3060. $baser=array_reverse($baser);
  3061. //$baser=implode("/",$baser);
  3062. return $baser;
  3063. }
  3064. function check_image($slika)
  3065. {
  3066. $form_slika=array("jpg","jpeg","JPG","JPEG","gif","GIF","png","PNG");
  3067. if(!in_array(substr($slika,-3),$form_slika))
  3068. return 0;
  3069. else return 1;
  3070. }
  3071. function check_file($slika,$ext="")
  3072. {
  3073. $af=array_reverse(explode(".",$slika));
  3074.  
  3075. $form_slika=array("doc","pdf","DOC","PDF","docx","DOCX","jpg","jpeg","gif","png", "zip", "ZIP", "rar", "RAR");
  3076. if($ext!="")
  3077. $form_slika=array("$ext", strtoupper($ext));
  3078. if(!in_array($af[0],$form_slika))
  3079. return 0;
  3080. else return 1;
  3081. }
  3082. function ifempty($val,$ns="")
  3083. {
  3084. if($val!="") $val=$val; else
  3085. if($ns==1)
  3086. $val=0;
  3087. else
  3088. $val="";
  3089. return trim($val);
  3090. }
  3091. function datef($tip="",$hi="")
  3092. {
  3093. if($hi==1) $his=" H:i";
  3094. else
  3095. if($hi==2) $his=" H:i:s";
  3096. else
  3097. $his="";
  3098. if($tip=="us")
  3099. $datume=date("Y-m-d$his");
  3100. else
  3101. if($tip=="")
  3102. $datume=date("d-m-Y$his");
  3103. }
  3104.  
  3105. function send_email($tip="",$to, $from_email, $replyto_email, $subject, $from_name, $html_text, $alt_text, $fajl="")
  3106. {
  3107. global $host_smtp;
  3108. global $port_smtp;
  3109. global $password_smtp;
  3110. global $username_smtp;
  3111. $mail = new PHPMailer;
  3112. if($tip=="smtp")
  3113. {
  3114. $host_smpt="94.130.154.232";
  3115. $port_smtp=587;
  3116. $password_smtp="ovojesifra";
  3117. $username_smtp="kontakt@greenlancer.com";
  3118. $mail->isSMTP();
  3119. $mail->SMTPDebug = 0;
  3120. $mail->SMTPAuth   = true;   // enable SMTP authentication
  3121. $mail->SMTPAuth = true;
  3122. $mail->Host       = "$host_smtp"; // sets the SMTP server
  3123. $mail->Port       = "$port_smtp";  // set the SMTP port for the GMAIL server
  3124. $mail->Username   = "";       // SMTP account username
  3125. $mail->Password   = $pass_smtp;        // SMTP account password
  3126. }
  3127. elseif($tip=="mail" or $tip=="")
  3128. $mail->Mailer   = "mail";
  3129.  
  3130. $mail->Debugoutput = 'html';
  3131. $mail->CharSet = 'UTF-8';
  3132. //Set who the message is to be sent from
  3133. $mail->setFrom($from_email, $from_name);
  3134. //Set an alternative reply-to address
  3135. $mail->addReplyTo($replyto_email, '');
  3136. //Set who the message is to be sent to
  3137. $mail->addAddress($to, '');
  3138. //Set the subject line
  3139. $mail->Subject = $subject;
  3140. //Read an HTML message body from an external file, convert referenced images to embedded,
  3141. //convert HTML into a basic plain-text alternative body
  3142. $mail->msgHTML($html_text);
  3143. //Replace the plain text body with one created manually
  3144. $mail->AltBody = $alt_text;
  3145. if(strlen($fajl)>3)
  3146. $mail->AddAttachment($fajl);
  3147.  
  3148. if($_SERVER["SERVER_NAME"]!="localhost")
  3149. {
  3150.  if($mail->Send()) return 1; else return 0;
  3151. }
  3152. }
  3153.  
  3154. /************************ login funcition **************/
  3155.  
  3156.  
  3157. function meta_tags_new($title, $desc, $key)
  3158. {
  3159. $vrati .=PHP_EOL.'<title>'.strip_tags($title).'</title>'.PHP_EOL.'
  3160. <meta name="description" content="'.strip_tags($desc).'" />'.PHP_EOL.'
  3161. <meta name="Keywords" content="'.strip_tags($key).'" />'.PHP_EOL.'';
  3162. return $vrati;
  3163. }
  3164. /******************* end login function ******************/
  3165. function tagovi($tag)
  3166. {
  3167. $tagovi=explode(",", $tag);
  3168. return $tagovi;
  3169. }
  3170. function sharebutton()
  3171. {
  3172. ?>
  3173. <div   style="float:right;margin-bottom:2px;">
  3174.  
  3175. <span class='st_facebook_hcount' displayText='Facebook'></span>
  3176. <span class='st_googleplus_hcount' displayText='Google +'></span>
  3177. <span class='st_twitter_hcount' displayText='Tweet'></span>
  3178. <span class='st_pinterest_hcount' displayText='Pinterest'></span>
  3179. <?php
  3180. if($kdkd>0)
  3181. {
  3182. ?>
  3183. <span class='st_instagram_hcount' displayText='Instagram Badge' st_username='saleksandrou'></span>
  3184. <?php
  3185. }
  3186. ?>
  3187. </div>
  3188. <?php
  3189. }
  3190. function sharebuttons()
  3191. {
  3192. ?>
  3193. <div class="social-likes" data-url="<?php echo curPageURL()?>" data-title="fany video" style="float:right;margin-bottom:-2px;">
  3194.  
  3195.     <div class="facebook" title="Share link on Facebook">Facebook</div>
  3196.     <div class="twitter" title="Share link on Twitter">Twitter</div>
  3197.     <div class="plusone" title="Share link on Google+">Google+</div>
  3198.     <div class="pinterest" title="Share image on Pinterest" data-media="">Pinterest</div>
  3199.  
  3200. </div>
  3201. <?php
  3202. }
  3203. function sharebuttonl()
  3204. {
  3205. ?>
  3206. <div   style="float:right;margin:2px 0px 0px 0px;">
  3207.  
  3208. <span class='st_facebook_hcount' displayText='Facebook'></span>
  3209. <span class='st_googleplus_hcount' displayText='Google +'></span>
  3210. <span class='st_twitter_hcount' displayText='Tweet'></span>
  3211. <span class='st_pinterest_hcount' displayText='Pinterest'></span>
  3212. <?php
  3213. if($kdkd>0)
  3214. {
  3215. ?>
  3216. <span class='st_instagram_hcount' displayText='Instagram Badge' st_username='saleksandrou'></span>
  3217. <?php
  3218. }
  3219. ?>
  3220. </div>
  3221. <?php
  3222. }
  3223. function sharebutton1()
  3224. {
  3225. ?>
  3226. <!-- Go to www.addthis.com/dashboard to customize your tools -->
  3227. <div class="addthis_sharing_toolbox"></div>
  3228. <!-- Go to www.addthis.com/dashboard to customize your tools -->
  3229. <script type="text/javascript" src="//s7.addthis.com/js/300/addthis_widget.js#pubid=ra-4e6e52ce4fc756a1"></script>
  3230.  
  3231. <?php
  3232. }
  3233. function num_years($birth)
  3234. {
  3235. $birthdate = new DateTime($birth);
  3236. $today     = new DateTime();
  3237. $interval  = $today->diff($birthdate);
  3238. $interval->format('%y years');
  3239. return $interval;
  3240. }
  3241.  
  3242.  
  3243. /************ add del column in table *******************/
  3244. function checkFieldExists($tableName,$columnName)
  3245. {
  3246. global $conn;
  3247.  
  3248.    $sql = "show columns from $tableName";
  3249.    $data = mysqli_query($conn,$sql);
  3250.    while($data_row=mysqli_fetch_array($data)){
  3251.       $column = $data_row['Field'];
  3252.       if($column== $columnName)
  3253.       {
  3254.          return true;
  3255.       }
  3256.    }
  3257.    return false;
  3258.  
  3259. } //end of function
  3260.  
  3261.  
  3262. function alter($lang,$page_add_array,$tips,$lang_old="")
  3263. {
  3264. global $conn;
  3265. foreach($page_add_array as $key=>$value)
  3266. {
  3267. $row="";
  3268. $drop="";
  3269. $field_name=array("");
  3270. $resulta = mysqli_query($conn,"SELECT * FROM $key limit 1");
  3271.   while($row=mysqli_fetch_array($resulta))
  3272.    {
  3273.     $field_name=array_keys($row);
  3274.  
  3275.    }
  3276.  //array_shift($field_name);
  3277. $gova=mysqli_num_rows($resulta);
  3278. $p=0;
  3279.  foreach($value as $keys=>$values)
  3280. {
  3281.  
  3282. if($p==0)  $zap=""; else $zap=", ";
  3283.  
  3284.  
  3285. if($values=="varchar") $tip="VARCHAR(150)"; else $tip="TEXT";
  3286.  
  3287. /*if($gova>0)
  3288. {
  3289. if($tips=="add")
  3290. {
  3291. if(!in_array($keys.$lang, $field_name))
  3292. {
  3293. $row .=$zap."ADD COLUMN $keys$lang $tip NULL";
  3294.  
  3295. $p++;
  3296. }
  3297. }
  3298. if($tips=="del")
  3299. {
  3300. if(in_array($keys.$lang, $field_name))
  3301. {
  3302. $drop .=$zap."DROP  `$keys$lang`";
  3303. $p++;
  3304. }
  3305. }
  3306. }
  3307. else
  3308. {
  3309. */
  3310. if($tips=="add")
  3311. {
  3312. if(!checkFieldExists($key,$keys.$lang))
  3313. {
  3314. $row .=$zap."ADD COLUMN $keys$lang $tip NULL";
  3315.  
  3316. $p++;
  3317. }
  3318. }
  3319. if($tips=="del")
  3320. {
  3321. if(checkFieldExists($key,$keys.$lang))
  3322. {
  3323.  
  3324. $drop .=$zap."DROP  `$keys$lang`";
  3325. $p++;
  3326. }
  3327. }
  3328. if($tips=="ren" and $lang!=$lang_old)
  3329. {
  3330. if(checkFieldExists($key,$keys.$lang_old))
  3331. {
  3332.  
  3333. $ren .=$zap."CHANGE `$keys$lang_old` `$keys$lang` $tip NULL";
  3334. $p++;
  3335. }
  3336. }
  3337.  
  3338.  
  3339. }
  3340. echo $row;
  3341.  
  3342. if($drop!="" and $tips=="del")
  3343. {
  3344. //echo $key."===".$drop."<br>";
  3345. if(!mysqli_query($conn,"ALTER TABLE `$key` $drop")) echo $conn->error;
  3346. }
  3347. if($row!="" and $tips=="add")
  3348. {
  3349. if(!mysqli_query($conn,"ALTER TABLE $key $row AFTER id")) echo $conn->error;
  3350. }
  3351. if($ren!="" and $tips=="ren")
  3352. {
  3353. if(!mysqli_query($conn,"ALTER TABLE `$key` $ren")) echo $conn->error;
  3354. }
  3355.  
  3356. }
  3357. }
  3358. $cur_link=curPageURL();
  3359.  
  3360. function fajlovi($ul, $boja, $dirk, $col, $zz1, $id_page,$lod="",$load_name="",$nono="")
  3361. {
  3362. global $conn;
  3363. ?>
  3364. <ul  class='ul divu <?php echo $boja ?>' id="polje<?php echo $ul?>"><? //echo $zz1[include_file_vrh]?>
  3365. <?php
  3366. $dir="../include-pages/$dirk";
  3367. $exo=explode(",",$zz1["include_file_$col"]);
  3368. //$files = scandir($dir);
  3369. //$count_dir=count($files)-2;
  3370.  
  3371. if(isset($_POST["include_$col"]))
  3372. $exo=$_POST["include_$col"];
  3373.  
  3374.  
  3375. if(implode("",$exo)!="")
  3376. {
  3377. foreach($exo as $key => $value)
  3378. {
  3379. /*$teva=preg_replace("/text[1-9]+.php/","text.php",$value);
  3380. if($teva=="text.php")
  3381. {
  3382. $ima=mysqli_num_rows(mysqli_query($conn,"SELECT * FROM pages_text_include WHERE  id_page='$id_page' AND include_file_$col='$value'"));
  3383. $imas="($ima)";
  3384. }else $imas="";*/
  3385.  
  3386. if(mb_eregi("text-",$value))
  3387. {
  3388. $la=mysqli_query($conn,"SELECT * FROM language WHERE akt='Y' order by pozicija ASC");
  3389.  while($la1=mysqli_fetch_array($la))
  3390.  {
  3391. $jezici[]=$la1['jezik'];
  3392.  }
  3393. $firstlang=$jezici[0];
  3394. $id_text=preg_replace('#[^0-9]#i', '', $value);
  3395. $ima=mysqli_query($conn,"SELECT * FROM pages_text_lang WHERE  id_text='$id_text' AND lang='$firstlang'");
  3396. $ima1=mysqli_fetch_assoc($ima);
  3397.  
  3398. if($id_get>0) $id_get=$id_get; else $id_get=$id_text;
  3399. $value="<a href='index.php?base=admin&page=page_edit_content&id=$id_text' target='_blank'>".$ima1['naslov']."</a>";
  3400. echo "<li$zakla><label style='display:block'><input type='checkbox' name='include_".$col."[]' value='text-$id_get' checked /> $value</label></li>";
  3401. }else
  3402. {
  3403. //if($nono==1) $disme="disabled"; else $disme="";
  3404.  
  3405. echo "<li$zakla><label style='display:block'><input type='checkbox' name='include_".$col."[]' value='$value' checked /> $value</label></li>";
  3406. }
  3407.  
  3408.  
  3409. }
  3410. }
  3411.  
  3412. if ($handle = opendir($dir) and $nono!=1) {
  3413.  
  3414.     while (false !== ($entry = readdir($handle))) {
  3415.  
  3416.         if ($entry != "." && $entry != "..") {
  3417.  
  3418. if(!in_array($entry,$exo) and $entry!="text.php")
  3419. {
  3420.  
  3421. echo "<li><label style='display:block'><input type='checkbox' name='include_".$col."[]' value='$entry' /> $entry</label></li>";
  3422. }
  3423.  
  3424.         }
  3425.     }
  3426.  
  3427.     closedir($handle);
  3428. }
  3429. if($lod!="" and !in_array($lod,$exo))
  3430. {
  3431. $mikis=explode("-",$lod);
  3432.  
  3433. echo "<li><label style='display:block'><input type='checkbox' name='include_".$col."[]' value='$lod' /> <a href='index.php?base=admin&page=page_edit_content&id=$mikis[1]' target='_blank'>$load_name</a></label></li>";
  3434. }
  3435. ?>
  3436. </ul>
  3437. <?php
  3438. }
  3439.  
  3440. function fajlovi_tekst($id, $id_page,  $zz1, $col, $ie_page=0)
  3441. {
  3442. global $conn;
  3443. ?>
  3444. <ul  class='divu' id="polje<?php echo $ul?>"><? //echo $zz1[include_file_vrh]?>
  3445. <?php
  3446.  
  3447. $exo=explode(",",$zz1);
  3448.  
  3449.  
  3450.  
  3451. if(implode("",$exo)!="")
  3452. {
  3453. foreach($exo as $key => $value)
  3454. {
  3455. $teva=preg_replace("/text[1-9]+.php/","text.php",$value);
  3456. if($teva!="text.php")
  3457. {
  3458. $disab="disabled";
  3459. $boja=' style="color:#999;"';
  3460. }
  3461. else{
  3462. $disab="";
  3463. $boja="";
  3464. }
  3465.  
  3466. $ima=mysqli_num_rows(mysqli_query($conn,"SELECT * FROM pages_text_include WHERE id_tekst='$id' AND id_page='$id_page' AND include_file_$col='$value'"));
  3467. if($ima>0) $sel="checked"; else $sel="";
  3468. echo "<li><label style='display:block'><input type='checkbox' name='include_".$col."[]' value='$value' $disab $sel /> <span$boja>$value</span></label></li>";
  3469.  
  3470.  
  3471. }
  3472. }
  3473.  
  3474.  
  3475.  
  3476. ?>
  3477. </ul>
  3478. <?php
  3479. }
  3480. function hashlink($id,$niza="",$k,$filt)
  3481. {
  3482. global $conn;
  3483. $giza=$niza;
  3484. if(isset($niza) and $niza!="")
  3485. {
  3486. if($niza[$filt]!="")
  3487. {
  3488. $niz=explode("-",$niza[$filt]);
  3489. if(in_array($id,$niz))
  3490. {
  3491. $na=array_search($id,$niz);
  3492. unset($niz[$na]);
  3493. $niza[$filt] =implode("-",$niz);
  3494. } else
  3495. {
  3496. $niz[]=$id;
  3497. $niza[$filt] =implode("-",$niz);
  3498. }
  3499.  
  3500. }
  3501. if($niza["p"]!="" and mb_eregi("-",$niza["p"]))
  3502. {
  3503. $fus=explode("-",$niza["p"]);
  3504. $niza["p"]=$fus[1];
  3505. }
  3506. $niza=array_filter($niza);
  3507. $ret ="&".http_build_query($niza);
  3508.  
  3509.  
  3510.  
  3511. }
  3512. else
  3513. $ret ="&$filt=$id";
  3514.  
  3515. if(!isset($niza[$filt]) and isset($niza) and $giza[$filt]!=$id)
  3516. $ret ="&".http_build_query($niza)."&$filt=$id";
  3517.  
  3518. return $ret;
  3519. }
  3520.  function hashlink1($id,$niz="", $niz1="", $k)
  3521. {
  3522. if(isset($niz) and $niz!="" and $k==1)
  3523. {
  3524. if(in_array($id,$niz))
  3525. {
  3526. $na=array_search($id,$niz);
  3527. unset($niz[$na]);
  3528. $vrati =implode("-",$niz);
  3529. } else
  3530. {
  3531. $niz[]=$id;
  3532. $vrati =implode("-",$niz);
  3533. }
  3534. }elseif($k==1)
  3535. $vrati =$id;
  3536.  
  3537. if($vrati!="")
  3538. $ret="&brend=$vrati";
  3539. else
  3540. $ret="";
  3541.  
  3542.  
  3543. if(isset($niz1) and $niz1!="" and $k==2)
  3544. {
  3545. if(in_array($id,$niz1))
  3546. {
  3547. $na=array_search($id,$niz1);
  3548. unset($niz1[$na]);
  3549. $vrati1 =implode("-",$niz1);
  3550. } else
  3551. {
  3552. $niz1[]=$id;
  3553. $vrati1 =implode("-",$niz1);
  3554. }
  3555. }elseif($k==2)
  3556. $vrati1 =$id;
  3557.  
  3558. if($vrati1!="")
  3559. $ret1="&filt=$vrati1";
  3560. else
  3561. $ret1="";
  3562.  
  3563.  
  3564.  
  3565. if($k==2 and count($niz)>0)
  3566. $ret ="&brend=".implode("-",$niz);
  3567.  
  3568. if($k==1 and count($niz1)>0)
  3569. $ret1 ="&filt=".implode("-",$niz1);
  3570.  
  3571. return $ret.$ret1;
  3572. }
  3573. function klase($tip,$data)
  3574. {
  3575. echo "<ul  class='divu' style='margin-top:0px;padding-top:0px;'>";
  3576. echo "<li><label style='display:block'><input type='radio' name='klasa_$tip' value='' /> Nijedna</label></li>";
  3577. for($i=1;$i<9;$i++)
  3578. {
  3579. if($data["class_$tip"]=="$tip$i") $che="checked"; else $che="";
  3580. echo "<li><label style='display:block'><input type='radio' name='klasa_$tip' value='$tip$i' $che id='$tip$i' /> ".$tip."$i</label></li>";
  3581. }
  3582. echo "</ul>";
  3583. }
  3584. function get_client_ip_env() {
  3585.     $ipaddress = '';
  3586.     if (getenv('HTTP_CLIENT_IP'))
  3587.         $ipaddress = getenv('HTTP_CLIENT_IP');
  3588.     else if(getenv('HTTP_X_FORWARDED_FOR'))
  3589.         $ipaddress = getenv('HTTP_X_FORWARDED_FOR');
  3590.     else if(getenv('HTTP_X_FORWARDED'))
  3591.         $ipaddress = getenv('HTTP_X_FORWARDED');
  3592.     else if(getenv('HTTP_FORWARDED_FOR'))
  3593.         $ipaddress = getenv('HTTP_FORWARDED_FOR');
  3594.     else if(getenv('HTTP_FORWARDED'))
  3595.         $ipaddress = getenv('HTTP_FORWARDED');
  3596.     else if(getenv('REMOTE_ADDR'))
  3597.         $ipaddress = getenv('REMOTE_ADDR');
  3598.     else
  3599.         $ipaddress = 'UNKNOWN';
  3600.  
  3601.     return $ipaddress;
  3602. }
  3603. function ip_infoSA(){
  3604.     if (filter_var($ip, FILTER_VALIDATE_IP) === FALSE) {
  3605.         $ip = $_SERVER["REMOTE_ADDR"];
  3606.         if ($deep_detect) {
  3607.             if (filter_var(@$_SERVER['HTTP_X_FORWARDED_FOR'], FILTER_VALIDATE_IP))
  3608.                 $ip = $_SERVER['HTTP_X_FORWARDED_FOR'];
  3609.             if (filter_var(@$_SERVER['HTTP_CLIENT_IP'], FILTER_VALIDATE_IP))
  3610.                 $ip = $_SERVER['HTTP_CLIENT_IP'];
  3611.         }
  3612.     }
  3613.     echo file_get_contents("http://www.geoplugin.net/json.gp?ip=" . $ip);
  3614. }
  3615. function ip_info($ip = NULL, $purpose = "location", $deep_detect = TRUE) {
  3616.     $output = NULL;
  3617.     if (filter_var($ip, FILTER_VALIDATE_IP) === FALSE) {
  3618.         $ip = $_SERVER["REMOTE_ADDR"];
  3619.         if ($deep_detect) {
  3620.             if (filter_var(@$_SERVER['HTTP_X_FORWARDED_FOR'], FILTER_VALIDATE_IP))
  3621.                 $ip = $_SERVER['HTTP_X_FORWARDED_FOR'];
  3622.             if (filter_var(@$_SERVER['HTTP_CLIENT_IP'], FILTER_VALIDATE_IP))
  3623.                 $ip = $_SERVER['HTTP_CLIENT_IP'];
  3624.         }
  3625.     }
  3626.     $purpose    = str_replace(array("name", "\n", "\t", " ", "-", "_"), NULL, strtolower(trim($purpose)));
  3627.     $support    = array("country", "countrycode", "state", "region", "city", "location", "address");
  3628.     $continents = array(
  3629.         "AF" => "Africa",
  3630.         "AN" => "Antarctica",
  3631.         "AS" => "Asia",
  3632.         "EU" => "Europe",
  3633.         "OC" => "Australia (Oceania)",
  3634.         "NA" => "North America",
  3635.         "SA" => "South America"
  3636.     );
  3637.     if (filter_var($ip, FILTER_VALIDATE_IP) && in_array($purpose, $support)) {
  3638.         $ipdat = @json_decode(file_get_contents("http://www.geoplugin.net/json.gp?ip=" . $ip));
  3639.         if (@strlen(trim($ipdat->geoplugin_countryCode)) == 2) {
  3640.             switch ($purpose) {
  3641.                 case "location":
  3642.                     $output = array(
  3643.                         "city"           => @$ipdat->geoplugin_city,
  3644.                         "state"          => @$ipdat->geoplugin_regionName,
  3645.                         "country"        => @$ipdat->geoplugin_countryName,
  3646.                         "country_code"   => @$ipdat->geoplugin_countryCode,
  3647.                         "continent"      => @$continents[strtoupper($ipdat->geoplugin_continentCode)],
  3648.                         "continent_code" => @$ipdat->geoplugin_continentCode
  3649.                     );
  3650.                     break;
  3651.                 case "address":
  3652.                     $address = array($ipdat->geoplugin_countryName);
  3653.                     if (@strlen($ipdat->geoplugin_regionName) >= 1)
  3654.                         $address[] = $ipdat->geoplugin_regionName;
  3655.                     if (@strlen($ipdat->geoplugin_city) >= 1)
  3656.                         $address[] = $ipdat->geoplugin_city;
  3657.                     $output = implode(", ", array_reverse($address));
  3658.                     break;
  3659.                 case "city":
  3660.                     $output = @$ipdat->geoplugin_city;
  3661.                     break;
  3662.                 case "state":
  3663.                     $output = @$ipdat->geoplugin_regionName;
  3664.                     break;
  3665.                 case "region":
  3666.                     $output = @$ipdat->geoplugin_regionName;
  3667.                     break;
  3668.                 case "country":
  3669.                     $output = @$ipdat->geoplugin_countryName;
  3670.                     break;
  3671.                 case "countrycode":
  3672.                     $output = @$ipdat->geoplugin_countryCode;
  3673.                     break;
  3674.             }
  3675.         }
  3676.     }
  3677.     return $output;
  3678. }
  3679.  
  3680. function strip_html_tags( $text )
  3681. {
  3682. // Remove invisible content
  3683.     $text = preg_replace(
  3684.         array(
  3685.             //ADD a (') before @<head ON NEXT LINE. Why? see below
  3686.             '@<head[^>]*?>.*?</head>@siu',
  3687.             '@<style[^>]*?>.*?</style>@siu',
  3688.             '@<script[^>]*?.*?</script>@siu',
  3689.             '@<object[^>]*?.*?</object>@siu',
  3690.             '@<embed[^>]*?.*?</embed>@siu',
  3691.             '@<applet[^>]*?.*?</applet>@siu',
  3692.             '@<noframes[^>]*?.*?</noframes>@siu',
  3693.             '@<noscript[^>]*?.*?</noscript>@siu',
  3694.             '@<noembed[^>]*?.*?</noembed>@siu',
  3695.           // Add line breaks before and after blocks
  3696.             '@</?((address)|(blockquote)|(center)|(del))@iu',
  3697.             '@</?((div)|(h[1-9])|(ins)|(isindex)|(p)|(pre))@iu',
  3698.             '@</?((dir)|(dl)|(dt)|(dd)|(li)|(menu)|(ol)|(ul))@iu',
  3699.             '@</?((table)|(th)|(td)|(caption))@iu',
  3700.             '@</?((form)|(button)|(fieldset)|(legend)|(input))@iu',
  3701.             '@</?((label)|(select)|(optgroup)|(option)|(textarea))@iu',
  3702.             '@</?((frameset)|(frame)|(iframe))@iu',
  3703.         ),
  3704.         array(
  3705.             ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ',
  3706.             "\n$0", "\n$0", "\n$0", "\n$0", "\n$0", "\n$0",
  3707.             "\n$0", "\n$0",
  3708.         ),
  3709.         $text );
  3710.     return strip_tags( $text );
  3711. }
  3712. function file_get_contents_curl($url) {
  3713.     $ch = curl_init();
  3714.  
  3715.     curl_setopt($ch, CURLOPT_AUTOREFERER, TRUE);
  3716.     curl_setopt($ch, CURLOPT_HEADER, 0);
  3717.     curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
  3718.     curl_setopt($ch, CURLOPT_URL, $url);
  3719.  
  3720.     curl_setopt($ch, CURLOPT_FOLLOWLOCATION, TRUE);
  3721.  
  3722.     $data = curl_exec($ch);
  3723.     curl_close($ch);
  3724.  
  3725.     return $data;
  3726. }
  3727. function curl_get($url){
  3728.  
  3729.   $ch = curl_init();
  3730.     curl_setopt($ch, CURLOPT_URL,$url);
  3731.     curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
  3732.     curl_setopt($ch, CURLOPT_COOKIEFILE, 1);
  3733.  
  3734.     return curl_exec($ch);
  3735.     curl_close ($ch);




The user came to discuss whether this code is suitable ... for a business application. Commentators were at least in shock and found a lot of problems:





Severe readers advised to leave as is and learn a lesson for business (yes, we, as a hosting provider, also know what kind of poor clients come from "free" providers from plow). Well, the best comment has dotted i: “If not for alcohol, most code I see would keep me up too” (If it weren’t for alcohol, most of the code I saw would not let me fall asleep either).



Story 2



An online tutorial treats each word as a separate HTML element, so copying and pasting more than 10 words per paragraph is not possible. However, in some places Reddit is almost like Habr, therefore, in the comments, only a few users commented on the author of the code as mu ** ke, the rest gave a lot of advice on how to get around this feature and get all the text in the best possible way. If someone needs methods, you can read about them in the thread itself .









Story 3



This guy was paid $ 50 an hour for such a code, and he created (nagovnokodil) a whole file with a length of more than 3000 lines.



The customer is to blame, the community decided, because $ 50 is a penny, which means that you can only rely on hiring a "monkey." Some decided that this was just a bad joke and the guy was setting his watch. Well, a detailed analysis of what is wrong in the code in the thread .









Story 4



This, of course, is a story bordering on science fiction, but who at the dawn of a beautiful youth did not do something like that.



The guy was too lazy to select all the files in the directory and did not come up with anything better than to use the utility



 rm -rf /*
      
      





But something, apparently, skipped a beat in his soul and he turned to his service station, whether the correct train of thought was chosen, the guy received confirmation and ... well, you understand. Comments deliver one hundred percent: “how tasty your tears are”, “it makes no sense to ask a technical manager how to delete files on Linux”, “you must not be very comfortable with Linux” (we think there’s still a bit of trouble with Google and common sense) , "Fail!". We think that the story is more like a bike, but it was from it that an unfortunate chill passed from the back and somehow I immediately wanted to get out of root. By the way, there are some useful tips there too .



Story 5



A bike similar to the previous one. One team :-)



 sudo rm –fr /
      
      





Boo!
But there is nothing terrible here.


The story of our friend from his past experience



"2008 year. Our site has been hacked. It was a normal, secure site, which was visited by more than 5,000 people a day. And now the main text appeared with errors about the Pentagon and the threat to take one hundred million from us (by the way, this was only part of the company's revenue). Sat-shniki on the ears, the director in a panic, STO washed the rope, the developers ran for Vaseline. Nothing. They closed the site, hung 404, received a flurry of calls. The next day, mom a la Anfisa Chekhov came in the best juice and brought a completely tortured kid of 16 years in glasses. Says: "This is my son, he is a hacker, take him to work." The service station got out of the loop, took the small one by the shoulder and forced it to show the small bauble (we haven’t announced the details), they told their mother about the Criminal Code of the Russian Federation, but they presented something to the guy. ”



In general, the human factor is the reason that each of us can have a personal Halloween on any working day.



How not to become a hero of such stories for your colleagues



Programmer Tips





Tips for system administrators





Obviously, isn't it? But compliance with these simple principles will close more than ⅔ possible problems that risk turning into chilling stories on Habré, Reddit and other resources where your fierce fakap is ready to discuss.



Friends, today, on Halloween, we crave chilling stories and your IT practice. What made your palms sweat, dark in your eyes, and cool inside? For the best story (with the highest comment rating), we will give prizes. For first place - an autographed hoodie by thelevelord , creator of Duke Nukem:





For second place - stock of socks for the whole year :)



All Articles