$row) { $sort_col[$key] = $row[$col]; } array_multisort($sort_col, $dir, $arr); } function getUrlData($url) { $result = false; $contents = \S::getUrlContents($url); if (isset($contents) && is_string($contents)) { $title = null; $metaTags = null; preg_match('/
' . $text . '
'; if ($print) echo $info; return $info; } public function my_array_diff($a, $b) { $map = $out = array(); if (is_array($a)) foreach ($a as $val) $map[trim($val)] = 1; if (is_array($b)) foreach ($b as $val) unset($map[trim($val)]); return array_keys($map); } public function pre($data, $type = '') { $data = str_replace('Array (', '', $data); $data = str_replace(')', '', $data); echo '' . print_r($data, true) . ''; } public function deleteSessionVar($var) { unset($_SESSION[$var]); } public function deleteCache($str = '../temp/') { if (is_file($str)) { return @unlink($str); } else if (is_dir($str)) { $scan = glob(rtrim($str, '/') . '/*'); if (is_array($scan)) foreach ($scan as $index => $path) { \S::deleteCache($path); } if ($str != '../temp/' && $str != 'temp/') return @rmdir($str); } } public function saveString($val, $tolower = false) { if ($tolower) $val = strtolower($val); return trim(strip_tags($val)); } public function deleteCacheAdmin($str = 'temp/') { if (is_file($str)) { return @unlink($str); } else if (is_dir($str)) { $scan = glob(rtrim($str, '/') . '/*'); if (is_array($scan)) foreach ($scan as $index => $path) self::deleteCache($path); if ($str != 'temp/' && $str != 'admin/temp/') return @rmdir($str); } } public function getHash($val) { $val = base64_encode($val); $val = \S::get($val); return base64_decode($val); } public function deleteAction() { $akcja = "function mycallbackform(v,m,f){ if( v == true ) document.location.href='./?rw=del&id=[param]'; }"; $akcja .= "$.prompt('Potwierdz usunięcie',{ callback: mycallbackform, buttons: { tak: true, nie: false }, focus: 1 })"; $akcja = 'onClick="' . $akcja . '"'; return $akcja; } public function seo($val, $nopl = true) { $array_rep1 = array('*', '_', ' ', '/', '+', '.', '"', "'", '?', '-', ',', '!', '~', '<', '>', '@', '#', '$', '%', '^', '&', '*' . '(', ')' . '-', '=', '\\', '|', '[', ']', '/', ':'); $array_rep2 = array('-', '-', '-', '-', '-', '-', '', '', '', '-', '-', '', '-', '-', '-', '-', '-', '-', '-', '-', '-', '-', '-', '-', '', '-', '-', '=', '-', '-', '-', '-'); if ($nopl) $val = self::noPl($val); $val = str_replace($array_rep1, $array_rep2, $val); return strtolower(trim($val)); } public function noPL($val) { $table = array( //WIN "\xb9" => "a", "\xa5" => "A", "\xe6" => "c", "\xc6" => "C", "\xea" => "e", "\xca" => "E", "\xb3" => "l", "\xa3" => "L", "\xf3" => "o", "\xd3" => "O", "\x9c" => "s", "\x8c" => "S", "\x9f" => "z", "\xaf" => "Z", "\xbf" => "z", "\xac" => "Z", "\xf1" => "n", "\xd1" => "N", //UTF "\xc4\x85" => "a", "\xc4\x84" => "A", "\xc4\x87" => "c", "\xc4\x86" => "C", "\xc4\x99" => "e", "\xc4\x98" => "E", "\xc5\x82" => "l", "\xc5\x81" => "L", "\xc3\xb3" => "o", "\xc3\x93" => "O", "\xc5\x9b" => "s", "\xc5\x9a" => "S", "\xc5\xbc" => "z", "\xc5\xbb" => "Z", "\xc5\xba" => "z", "\xc5\xb9" => "Z", "\xc5\x84" => "n", "\xc5\x83" => "N", //ISO "\xb1" => "a", "\xa1" => "A", "\xe6" => "c", "\xc6" => "C", "\xea" => "e", "\xca" => "E", "\xb3" => "l", "\xa3" => "L", "\xf3" => "o", "\xd3" => "O", "\xb6" => "s", "\xa6" => "S", "\xbc" => "z", "\xac" => "Z", "\xbf" => "z", "\xaf" => "Z", "\xf1" => "n", "\xd1" => "N" ); $array_de = array('Ü'); $array_de_pl = array('U'); $val = str_replace($array_de, $array_de_pl, $val); $array_uk = array('А', 'а', 'Б', 'б', 'В', 'в', 'Г', 'г', 'ґ', 'Д', 'д', 'Е', 'е', 'Є', 'є', 'Ж', 'ж', 'З' . 'з', 'И', 'и', 'І', 'і', 'Ї', 'ї', 'Й', 'й', 'К', 'к', 'Л', 'л', 'М', 'м', 'Н', 'н', 'О', 'о', 'П', 'п', 'Р', 'р', 'С', 'с', 'Т', 'т', 'У', 'у', 'Ф', 'ф', 'Х', 'х', 'Ц' - 'ц', 'Ч', 'ч', 'Ш', 'ш', 'Щ', 'щ', 'Ю', 'ю', 'Я', 'я', 'ь'); $array_uk_pl = array('А', 'a', 'B', 'b', 'V', 'v', 'Gg', 'gh', 'Gg', 'D', 'd', 'E', 'e', 'Ye', 'yr', 'Zh', 'zh', 'Z', 'z', 'Y', 'y', 'I', 'i', 'Yi', 'yi', 'J', 'j', 'K', 'k', 'L', 'l', 'M', 'm', 'N', 'n', 'O', 'o', 'P', 'p', 'R', 'r', 'S', 's', 'T', 't', 'U', 'u', 'F', 'f', 'Kh', 'kh', 'Ts', 'ts', 'Ch', 'ch', 'Sh', 'sh', 'Shch', 'shch', 'Yu', 'yu', 'Ya', 'ya', ''); $val = str_replace($array_uk, $array_uk_pl, $val); return strtr($val, $table); } public function getDateDiff($data1, $data2, $rodz = '60') { $d1_t = explode(' ', $data1); $d1_tt = explode('-', $d1_t[0]); $rok1 = $d1_tt[0]; $mc1 = $d1_tt[1]; $d1 = $d1_tt[2]; $d1_tt = explode(':', $d1_t[1]); $g1 = $d1_tt[0]; $m1 = $d1_tt[1]; $s1 = $d1_tt[2]; $d2_t = explode(' ', $data2); $d2_tt = explode('-', $d2_t[0]); $rok2 = $d2_tt[0]; $mc2 = $d2_tt[1]; $d2 = $d2_tt[2]; $d2_tt = explode(':', $d2_t[1]); $g2 = $d2_tt[0]; $m2 = $d2_tt[1]; $s2 = $d2_tt[2]; $lt = mktime($g2, $m2, $s2, $mc2, $d2, $rok2); $st = mktime($g1, $m1, $s1, $mc1, $d1, $rok1); return round(($lt - $st) / $rodz); } public function parseRSS($xml, $cat_id) { $cnt = count($xml->channel->item); for ($i = 0; $i < $cnt; $i++) { $row['link'] = $xml->channel->item[$i]->link; $row['date'] = $xml->channel->item[$i]->pubDate; $row['title'] = $xml->channel->item[$i]->title; $row['cat_id'] = $cat_id; $links[] = $row; } return $links; } public function synonyms($word) { global $db, $cache, $config; if (!$word) return $word; $key = 'synonyms:' . $word; if (!$synonim = $cache->fetch($key, 'temp_t')) { $query = $db->prepare('SELECT synonim FROM pro_thesaurus WHERE synonim LIKE "%;' . addslashes($word) . ';%" ORDER BY LENGTH(synonim) DESC LIMIT 1'); $query->execute(); if ($query->rowCount()) { while ($row = $query->fetch()) $synonim = $row['synonim']; $synonim = substr($synonim, 1); $synonim = substr($synonim, 0, -1); } else $synonim = $word; $query->closeCursor(); if (strpos($synonim, ';') !== false) $synonim = '{' . str_replace(';', '|', $synonim) . '}'; $cache->store($key, $synonim, $config['cxll'], 'temp_t'); } return $synonim; } public function getHost($page, $www = false) { $page = str_replace('https://', 'http://', $page); preg_match('@^(?:http://)?([^/]+)@i', $page, $matches); if (!$www) $matches[1] = str_replace("www.", "", $matches[1]); return $matches[1]; } public function preparRequest($query) { if (is_array($query) && !empty($query)) { foreach ($query as $key => $value) $query[$key] = urlencode($key) . '=' . urlencode($value); return implode('&', $query); } else return false; } public function getDate() { return date('Y-m-d H:i:s'); } public function getComboYesNo() { global $lang; $tab[0] = 'nie'; $tab[1] = 'tak'; return $tab; } public function getPagingVar($var, $bs, $ls) { if ($var == 'a') { if ($bs == 1) return 6; else if ($bs == 2) return 5; else if ($bs == 3) return 4; else return 3; } else if ($var == 'b') { if ($bs == $ls) return 6; else if ($bs == $ls - 1) return 5; else if ($bs == $ls - 2) return 4; else return 3; } } public static function alert($val) { \S::set_session('alert', $val); } public static function get($var) { if (isset($_POST[$var])) { if (is_string($_POST[$var])) return trim($_POST[$var]); else return $_POST[$var]; } else { if (isset($_GET[$var])) { if (is_string($_GET[$var])) return trim($_GET[$var]); else return $_GET[$var]; } } } public static function set_session($var, $val) { $_SESSION[$var] = $val; } public static function get_session($var) { return $_SESSION[$var]; } }