%PDF-1.5 %���� ºaâÚÎΞ-ÌE1ÍØÄ÷{òò2ÿ ÛÖ^ÔÀá TÎ{¦?§®¥kuµùÕ5sLOšuY
Server IP : 188.40.95.74 / Your IP : 216.73.216.124 Web Server : Apache System : Linux cp01.striminghost.net 3.10.0-1160.119.1.el7.tuxcare.els13.x86_64 #1 SMP Fri Nov 22 06:29:45 UTC 2024 x86_64 User : vlasotin ( 1054) PHP Version : 5.6.40 Disable Function : NONE MySQL : ON | cURL : ON | WGET : ON | Perl : ON | Python : ON | Sudo : ON | Pkexec : ON Directory : /home/vlasotin/public_html/library/ |
Upload File : |
<?php /** * ************************* * project WorkForMe * file functions.php * desc pomocne funkcije * version 1.3 * author Igor Stefanovic * mail striming@gmail.com * web http://www.igorstefanovic.rs * ************************** */ function Cut($string, $max_length){ if (strlen($string) > $max_length){ $string = substr($string, 0, $max_length); $pos = strrpos($string, " "); if($pos === false) { return substr($string, 0, $max_length)."..."; } return substr($string, 0, $pos)."..."; }else{ return $string; } } function utf8_bad_replace($str, $replace = '') { $UTF8_BAD = '([\x00-\x7F]'. '|[\xC2-\xDF][\x80-\xBF]'. '|\xE0[\xA0-\xBF][\x80-\xBF]'. '|[\xE1-\xEC\xEE\xEF][\x80-\xBF]{2}'. '|\xED[\x80-\x9F][\x80-\xBF]'. '|\xF0[\x90-\xBF][\x80-\xBF]{2}'. '|[\xF1-\xF3][\x80-\xBF]{3}'. '|\xF4[\x80-\x8F][\x80-\xBF]{2}'. '|(.{1}))'; ob_start(); while (preg_match('/'.$UTF8_BAD.'/S', $str, $matches)) { if ( !isset($matches[2])) { echo $matches[0]; } else { echo $replace; } $str = substr($str,strlen($matches[0])); } $result = ob_get_contents(); ob_end_clean(); return $result; } function preuzmiVimeoID($id) { $pieces = explode("/", $id); $id = end($pieces); return $id; } /* GRAB YOUTUBE SLIKU*/ function preuzmi_youtube_thumb( $video_id ) { // Did we get a URL? if ( FALSE !== filter_var( $video_id, FILTER_VALIDATE_URL ) ) { // http://www.youtube.com/v/abcxyz123 if ( FALSE !== strpos( $video_id, 'watch?v=' ) ) { list( , $video_id ) = explode( 'watch?v=', $video_id ); } // http://www.youtube.com/watch?v=abcxyz123 else { $video_query = parse_url( $video_id, PHP_URL_QUERY ); parse_str( $video_query, $video_params ); $video_id = $video_params['embed']; } } return 'http://img.youtube.com/vi/' . $video_id . '/0.jpg'; } /* GRAB YOUTUBE SLIKU*/ function preuzmi_youtube_id( $video_id ) { // Did we get a URL? if ( FALSE !== filter_var( $video_id, FILTER_VALIDATE_URL ) ) { // http://www.youtube.com/v/abcxyz123 if ( FALSE !== strpos( $video_id, 'watch?v=' ) ) { list( , $video_id ) = explode( 'watch?v=', $video_id ); } // http://www.youtube.com/watch?v=abcxyz123 else { $video_query = parse_url( $video_id, PHP_URL_QUERY ); parse_str( $video_query, $video_params ); $video_id = $video_params['embed']; } } return '' . $video_id . ','; } /* TAG CLOUD */ function generateTags($strText) { $strText = preg_replace('/[\[\]?!\.,\/\\"\'\(\)]/', ' ', $strText); $strText = preg_replace('/[ ]+/', ' ', $strText); $array = explode(" ", $strText); $tmpArray = array(); for($i = 0; $i < count($array); $i++) { if(strlen($array[$i]) > 4) { array_push($tmpArray, $array[$i]); } } return $tmpArray; } function tagCloud() { $query = mysql_query("SELECT seo, tag FROM tagovi ORDER BY id DESC LIMIT 16"); while ($data = mysql_fetch_array($query, MYSQL_ASSOC)) { echo "<a href=\"/tag/".$data['seo'].".html\">".$data['tag']."</a> "; } } function izvrsiUpit($sqlUpit) { global $link; $upit = mysql_query($sqlUpit, $link) or die("GRESKA: ".mysql_error($link)); $niz = split(" ", $sqlUpit); if($niz[0] == "INSERT") $_SESSION["insertID"] = mysql_insert_id(); return $upit; } //skrati text function skrati($str, $n, $end_char = ' …') { if (strlen($str) < $n) { return $str; } $str = preg_replace("/\s+/", ' ', str_replace(array("\r\n", "\r", "\n"), ' ', $str)); if (strlen($str) <= $n) { return $str; } $out = ""; foreach (explode(' ', trim($str)) as $val) { $out .= $val.' '; if (strlen($out) >= $n) { $out = trim($out); return (strlen($out) == strlen($str)) ? $out : $out.$end_char; } } } //skrati text u slideru thumb function skratiAktuelnost($str, $n = 120, $end_char = ' …') { if (strlen($str) < $n) { return $str; } $str = preg_replace("/\s+/", ' ', str_replace(array("\r\n", "\r", "\n"), ' ', $str)); if (strlen($str) <= $n) { return $str; } $out = ""; foreach (explode(' ', trim($str)) as $val) { $out .= $val.' '; if (strlen($out) >= $n) { $out = trim($out); return (strlen($out) == strlen($str)) ? $out : $out.$end_char; } } } //skrati text u slideru thumb function skratiTextSlider($str, $n = 100, $end_char = ' …') { if (strlen($str) < $n) { return $str; } $str = preg_replace("/\s+/", ' ', str_replace(array("\r\n", "\r", "\n"), ' ', $str)); if (strlen($str) <= $n) { return $str; } $out = ""; foreach (explode(' ', trim($str)) as $val) { $out .= $val.' '; if (strlen($out) >= $n) { $out = trim($out); return (strlen($out) == strlen($str)) ? $out : $out.$end_char; } } } //skrati text function skratiMagazin($str, $n = 120, $end_char = ' …') { if (strlen($str) < $n) { return $str; } $str = preg_replace("/\s+/", ' ', str_replace(array("\r\n", "\r", "\n"), ' ', $str)); if (strlen($str) <= $n) { return $str; } $out = ""; foreach (explode(' ', trim($str)) as $val) { $out .= $val.' '; if (strlen($out) >= $n) { $out = trim($out); return (strlen($out) == strlen($str)) ? $out : $out.$end_char; } } } function skratiPovezano($str, $n = 50, $end_char = '...') { if (strlen($str) < $n) { return $str; } $str = preg_replace("/\s+/", ' ', str_replace(array("\r\n", "\r", "\n"), ' ', $str)); if (strlen($str) <= $n) { return $str; } $out = ""; foreach (explode(' ', trim($str)) as $val) { $out .= $val.' '; if (strlen($out) >= $n) { $out = trim($out); return (strlen($out) == strlen($str)) ? $out : $out.$end_char; } } } function skratiNaslov($str, $n = 56, $end_char = '...') { if (strlen($str) < $n) { return $str; } $str = preg_replace("/\s+/", ' ', str_replace(array("\r\n", "\r", "\n"), ' ', $str)); if (strlen($str) <= $n) { return $str; } $out = ""; foreach (explode(' ', trim($str)) as $val) { $out .= $val.' '; if (strlen($out) >= $n) { $out = trim($out); return (strlen($out) == strlen($str)) ? $out : $out.$end_char; } } } //skrati text function skratiTekst($str, $n = 120, $end_char = ' …') { if (strlen($str) < $n) { return $str; } $str = preg_replace("/\s+/", ' ', str_replace(array("\r\n", "\r", "\n"), ' ', $str)); if (strlen($str) <= $n) { return $str; } $out = ""; foreach (explode(' ', trim($str)) as $val) { $out .= $val.' '; if (strlen($out) >= $n) { $out = trim($out); return (strlen($out) == strlen($str)) ? $out : $out.$end_char; } } } //skrati odabrano function skratiOdabrano($str, $n = 25, $end_char = ' …') { if (strlen($str) < $n) { return $str; } $str = preg_replace("/\s+/", ' ', str_replace(array("\r\n", "\r", "\n"), ' ', $str)); if (strlen($str) <= $n) { return $str; } $out = ""; foreach (explode(' ', trim($str)) as $val) { $out .= $val.' '; if (strlen($out) >= $n) { $out = trim($out); return (strlen($out) == strlen($str)) ? $out : $out.$end_char; } } } function napraviNasDatum($date) { list($y, $m, $d) = explode("-", $date); return $d.".".$m.".".$y."."; } //resizeImage function resizeImage($file_tmp, $file_type, $targetdir, $ThumbWidth, $name, $Sheight = "auto") { if($file_type == "image/pjpeg" || $file_type == "image/jpeg") { $new_img = imagecreatefromjpeg($file_tmp); } elseif($file_type == "image/x-png" || $file_type == "image/png") { $new_img = imagecreatefrompng($file_tmp); }elseif($file_type == "image/gif") { $new_img = imagecreatefromgif($file_tmp); } if($Sheight == "auto") { list($width, $height) = getimagesize($file_tmp); $imgratio=$width/$height; if ($imgratio>1) { $newwidth = $ThumbWidth; $newheight = $ThumbWidth/$imgratio; } else { $newheight = $ThumbWidth; $newwidth = $ThumbWidth*$imgratio; } } else { list($width, $height) = getimagesize($file_tmp); $imgratio=$width/$height; if ($imgratio>1) { $newwidth = $ThumbWidth; $newheight = $Sheight; } else { $newheight = $Sheight; $newwidth = $ThumbWidth*$imgratio; } } if (function_exists(imagecreatetruecolor)){ $resized_img = imagecreatetruecolor($newwidth,$newheight); } else { die("GRESKA: Uverite se da je verzija vase GD biblioteke 2+"); } imagecopyresized($resized_img, $new_img, 0, 0, 0, 0, $newwidth, $newheight, $width, $height); ImageJpeg ($resized_img, $targetdir.$name); ImageDestroy ($resized_img); ImageDestroy ($new_img); } //cropImage function cropImage($nw, $nh, $source, $stype, $dest) { $size = getimagesize($source); $w = $size[0]; $h = $size[1]; switch($stype) { case 'gif': $simg = imagecreatefromgif($source); break; case 'jpg': $simg = imagecreatefromjpeg($source); break; case 'png': $simg = imagecreatefrompng($source); break; case 'GIF': $simg = imagecreatefromgif($source); break; case 'JPG': $simg = imagecreatefromjpeg($source); break; case 'PNG': $simg = imagecreatefrompng($source); break; } $dimg = imagecreatetruecolor($nw, $nh); $wm = $w/$nw; $hm = $h/$nh; $h_height = $nh/2; $w_height = $nw/2; if($w> $h) { $adjusted_width = $w / $hm; $half_width = $adjusted_width / 2; $int_width = $half_width - $w_height; imagecopyresampled($dimg, $simg, -$int_width, 0, 0, 0, $adjusted_width, $nh, $w, $h); } elseif(($w <$h) || ($w == $h)) { $adjusted_height = $h / $wm; $half_height = $adjusted_height / 2; $int_height = $half_height - $h_height; imagecopyresampled($dimg, $simg, 0, -$int_height, 0, 0, $nw, $adjusted_height, $w, $h); } else { imagecopyresampled($dimg, $simg, 0, 0, 0, 0, $nw, $nh, $w, $h); } imagejpeg($dimg,$dest); } // kraj cropImage function kShuffle(&$array) { if(!is_array($array) || empty($array)) { return false; } $tmp = array(); foreach($array as $key => $value) { $tmp[] = array('k' => $key, 'v' => $value); } shuffle($tmp); $array = array(); foreach($tmp as $entry) { $array[$entry['k']] = $entry['v']; } return true; } function calculateDate($date) { global $j; $timeNow = time(); $time = strtotime($date); $difference = $timeNow - $time; if($difference < 60) { $seconds = $difference; return "pre ".$seconds." ".sekundi; } else if($difference < 3600) { $minutes = round($difference / 60); return "pre ".$minutes." ".minuta; } else if($difference < 86400) { $hours = round($difference / 3600); return "pre ".$hours." ".sati; } else if($difference < 2592000) { $days = round($difference / 86400); return "pre ".$days." ".dana; } else if($difference < 31104000){ $months = round($difference / 2592000); return "pre ".$months." ".meseci; } else { $years = round($difference / 31104000); return "pre ".$years." ".godine; } } function recognizeURL($text, $limit = "-1") { $regEx = "((www\.|http\.|(www|http|https|ftp|news|file)+\:\/\/)([_.a-z0-9-]+\.[a-zA-Z0-9\/_:@=.+?,##%&~-]*[^.|\'|\# |!|\(|?|,| |>|<|;|\)]))"; if($limit == "-1") { $text = preg_replace($regEx, "<a href='$0' target='_blank'>$0</a>", $text, $limit); $regEx = "(www\.|http://\.|http://www.)"; $text = preg_replace($regEx, "http://www.", $text); } else { $text = preg_match($regEx, $text, $matches); $text = $matches[0]; } return $text; } function recognizeURLLink($text) { $regEx = "((www\.|http\.|(www|http|https|ftp|news|file)+\:\/\/)([_.a-z0-9-]+\.[a-zA-Z0-9\/_:@=.+?,##%&~-]*[^.|\'|\# |!|\(|?|,| |>|<|;|\)]))"; $text = preg_replace($regEx, "$0", $text, $limit); $regEx = "(www\.|http://\.|http://www.)"; $text = preg_replace($regEx, "http://www.", $text); return "http://".$text; } function recognizeEmoticons($text) { $regEx = "((\:\))|(\;\))|(\:P)|(\:D)|(\:\*)|(\:\())"; $text = preg_replace($regEx, "<img class='smajli' src=\"/images/emoticons/smiley_$0.gif\" />", $text); $text = str_replace("/smiley_:).gif", "/smiley_1.gif", $text); $text = str_replace("/smiley_;).gif", "/smiley_2.gif", $text); $text = str_replace("/smiley_:P.gif", "/smiley_3.gif", $text); $text = str_replace("/smiley_:D.gif", "/smiley_4.gif", $text); $text = str_replace("/smiley_:*.gif", "/smiley_5.gif", $text); $text = str_replace("/smiley_:/.gif", "/smiley_6.gif", $text); $text = str_replace("/smiley_:\.gif", "/smiley_6.gif", $text); $text = str_replace("/smiley_:(.gif", "/smiley_7.gif", $text); return $text; } function _Download($f_location,$f_name) { header('Cache-Control: no-store, no-cache, no-transform, must-revalidate, private'); header('Content-Description: File Transfer'); header('Content-Type: application/octet-stream'); header('Content-Length: ' . filesize($f_location)); header('Content-Disposition: attachment; filename=' . basename($f_name)); header('Expires: 0'); readfile($f_location); } function createKeywords($text) { return str_replace("-", ", ", $text); } function get_tweets($url) { $json_string = file_get_contents('http://urls.api.twitter.com/1/urls/count.json?url=' . $url); $json = json_decode($json_string, true); return intval( $json['count'] ); } function get_likes($url) { $json_string = file_get_contents('http://graph.facebook.com/?ids=' . $url); $json = json_decode($json_string, true); return intval( $json[$url]['likes'] ); } function get_shares($url) { $json_string = file_get_contents('http://graph.facebook.com/?ids=' . $url); $json = json_decode($json_string, true); return intval( $json[$url]['shares'] ); } function get_plusones($url) { $curl = curl_init(); curl_setopt($curl, CURLOPT_URL, "https://clients6.google.com/rpc"); curl_setopt($curl, CURLOPT_POST, 1); curl_setopt($curl, CURLOPT_POSTFIELDS, '[{"method":"pos.plusones.get","id":"p","params":{"nolog":true,"id":"' . $url . '","source":"widget","userId":"@viewer","groupId":"@self"},"jsonrpc":"2.0","key":"p","apiVersion":"v1"}]'); curl_setopt($curl, CURLOPT_RETURNTRANSFER, true); curl_setopt($curl, CURLOPT_HTTPHEADER, array('Content-type: application/json')); $curl_results = curl_exec ($curl); curl_close ($curl); $json = json_decode($curl_results, true); return intval( $json[0]['result']['metadata']['globalCounts']['count'] ); } function createPagination($url_link, $page, $resultCount, $limit) { echo "<ul class=\"pagination\">"; $totalPages = ceil($resultCount / $limit); $firstPage = ($page == 1) ? 0 : 1; $lastPage = ($page == $totalPages) ? 0: $totalPages; $prevPage = ($page - 1 <= 0) ? 0 : $page - 1; $nextPage = ($page+1 <= $totalPages) ? $page+1 : 0; if($page < 4) { $i = 1; $countTill = ($totalPages > 6) ? 6 : $totalPages; } else { $i = $page - 3; $countTill = ($page + 3 <= $totalPages) ? $page+3 : $totalPages; } // printing first page link if($firstPage != 0) { echo "<li><a href=\"".$url_link."strana/".$firstPage."\"><span class=\"ti-angle-double-left\"></span></a></li>"; } else { echo "<li class=\"disabled\"><span class=\"ti-angle-double-left\"></span></li>"; } // printing previous page link if($prevPage != 0) { echo "<li><a href=\"".$url_link."strana/".$prevPage."\"><span class=\"ti-angle-left\"></span></li></li>"; } else { echo "<li class=\"disabled\"><span class=\"ti-angle-left\"></span></li>"; } // printing middle pages for($i; $i <= $countTill; $i++) { if($page == $i) $additionalClass = "active"; else $additionalClass = ""; echo "<li class=\"$additionalClass\"><a href=\"".$url_link."strana/".$i."\">".$i."</a></li>"; } // printing next page link if($nextPage != 0) { echo "<li><a href=\"".$url_link."strana/".$nextPage."\"><i class=\"ti-angle-right\"></i></a></li>"; } else { echo "<li class=\"disabled\"><span class=\"ti-angle-right\"></span></li>"; } // printing last page link if($lastPage != 0) { echo "<li><a href=\"".$url_link."strana/".$lastPage."\"><i class=\"ti-angle-double-right\"></i></a></li>"; } else { echo "<li class=\"disabled\"><span class=\"ti-angle-double-right\"></span></li>"; } echo "</ul>"; } ?>