function format_file_size($file_size = 0) { //$file_size = intval($file_size); if (!$file_size) { return "n/a"; } if (strlen($file_size) <= 9 && strlen($file_size) >= 7) { $file_size = number_format($file_size / 1048576,1); return $file_size." MB"; } elseif (strlen($file_size) >= 10) { $file_size = number_format($file_size / 1073741824,1); return $file_size." GB"; } else { $file_size = number_format($file_size / 1024,1); return $file_size." KB"; } } function get_remote_file_size($file_path) { if (!CHECK_REMOTE_FILES) { return 'n/a'; } ob_start(); @readfile($file_path); $file_data = ob_get_contents(); ob_end_clean(); return format_file_size(strlen($file_data)); } function update_comment_count($image_id = 0, $user_id = 0) { global $site_db, $user_table_fields; if ($image_id) { $sql = "SELECT COUNT(comment_id) AS comments FROM ".COMMENTS_TABLE." WHERE image_id = $image_id"; $countcomments = $site_db->query_firstrow($sql); $sql = "UPDATE ".IMAGES_TABLE." SET image_comments = ".$countcomments['comments']." WHERE image_id = $image_id"; $site_db->query($sql); } if ($user_id != GUEST && $user_id && !empty($user_table_fields['user_comments'])) { $sql = "SELECT COUNT(comment_id) AS comments FROM ".COMMENTS_TABLE." WHERE user_id = $user_id"; $countcomments = $site_db->query_firstrow($sql); $sql = "UPDATE ".USERS_TABLE." SET ".get_user_table_field("", "user_comments")." = ".$countcomments['comments']." WHERE ".get_user_table_field("", "user_id")." = $user_id"; $site_db->query($sql); } } function update_image_rating($image_id, $rating) { global $site_db; $sql = "SELECT cat_id, image_votes, image_rating FROM ".IMAGES_TABLE." WHERE image_id = $image_id"; $image_row = $site_db->query_firstrow($sql); if (check_permission("auth_vote", $image_row['cat_id'])) { $old_votes = $image_row['image_votes']; $old_rating = $image_row['image_rating']; $new_rating = (($old_rating * $old_votes) + $rating) / ($old_votes + 1); $new_rating = sprintf("%.2f", $new_rating); $sql = "UPDATE ".IMAGES_TABLE." SET image_votes = ($old_votes + 1), image_rating = '$new_rating' WHERE image_id = $image_id"; $site_db->query($sql); } } function check_email($email) { return (preg_match('/^[-!#$%&\'*+\\.\/0-9=?A-Z^_`{|}~]+@([-0-9A-Z]+\.)+([0-9A-Z]){2,}$/i', $email)) ? 1 : 0; } function format_date($format, $timestamp) { global $user_info; $timezone_offset = (defined("TIME_OFFSET")) ? TIME_OFFSET : 0; return date($format, $timestamp + (3600 * $timezone_offset)); } function format_url($url) { if (empty($url)) { return ''; } if (!preg_match("/^https?:\/\//i", $url)) { $url = "http://".$url; } return htmlspecialchars($url); } function replace_url($text) { $text = " ".$text." "; $url_search_array = array( "#([^]_a-z0-9-=\"'\/])www\.([a-z0-9\-]+)\.([a-z0-9\-.\~]+)((?:/[^, \(\)<>\n\r]*)?)#si", "#([^]_a-z0-9-=\"'\/])([a-z]+?)://([^, \(\)<>\n\r]+)#si" ); $url_replace_array = array( "\\1www.\\2.\\3\\4", "\\1\\2://\\3", ); $text = preg_replace($url_search_array, $url_replace_array, $text); if (strpos($text, "@")) { $text = preg_replace("#([\n ])([a-z0-9\-_.]+?)@([\w\-]+\.([\w\-\.]+\.)?[\w]+)#i", "\\1\\2@\\3", $text); } return substr($text, 1, -1); } function replace_badwords($text) { global $config, $split_badwords; if ($config['badword_list'] != "") { if (!isset($split_badwords)) { $badwords = trim($config['badword_list']); $badwords = preg_replace("/[\n\r]/is", " ", $badwords); $badwords = str_replace(","," ",$badwords); $badwords = preg_quote($badwords); $badwords = str_replace('/', '\\/', $badwords); $split_badwords = preg_split("/\s+/", $badwords); } foreach ($split_badwords as $key => $val) { if ($val != "") { if (substr($val, 0, 2) == "\\{") { $val = substr($val, 2, -2); $text = trim(preg_replace("/([^A-Za-z])".$val."(?=[^A-Za-z])/si", "\\1".str_repeat($config['badword_replace_char'], strlen($val)), " $text ")); } else { $text = trim(preg_replace("/$val/si", str_repeat($config['badword_replace_char'], strlen($val)), " $text ")); } } } } return $text; } function format_text($text, $html = 0, $word_wrap = 0, $bbcode = 0, $bbcode_img = 0) { if ($word_wrap && $text != "") { $text = preg_replace("/([^\n\r ?&\.\/<>\"\\-]{".$word_wrap."})/i", " \\1\n", $text); } if ($html == 0 || $html == 2) { $text = safe_htmlspecialchars($text); } // Replace { to prevent parsing in templates global $site_template; $text = preg_replace( '='.preg_quote($site_template->start).'([A-Z0-9_]+)'.preg_quote($site_template->end).'=Usi', '{\1}', $text ); if ($html !== 2) { $text = nl2br(trim($text)); $text = replace_url($text); } if ($bbcode == 1) { $search_array = array( "/(\[)(list)(=)(['\"]?)([^\"']*)(\\4])(.*)(\[\/list)(((=)(\\4)([^\"']*)(\\4]))|(\]))/siU", "/(\[)(list)(])(.*)(\[\/list\])/siU", "/(\[\*\])/siU", "/(\[\/\*\])/siU", "/(\[)(url)(=)(['\"]?)(www\.)([^\"']*)(\\4])(.*)(\[\/url\])/siU", "/(\[)(url)(=)(['\"]?)([^\"']*)(\\4])(.*)(\[\/url\])/siU", "/(\[)(url)(])(www\.)([^\"]*)(\[\/url\])/siU", "/(\[)(url)(])([^\"]*)(\[\/url\])/siU", "/(\[)(code)(])(\r\n)*(.*)(\[\/code\])/siU", "/javascript:/si", "/about:/si" ); $replace_array = array( "
    \\7
", "", "
  • ", "
  • ", "\\8", "\\7", "www.\\5", "\\4", "
    Code:
    \\5
    ", "java script:", "about :" ); $text = preg_replace($search_array, $replace_array, $text); if (!$bbcode_img) { $text = preg_replace("/(\[)(img)(])(\r\n)*([^\"]*)(\[\/img\])/siU", "\\5", $text); } else { $text = preg_replace("/(\[)(img)(])(\r\n)*([^\"]*)(\[\/img\])/siU", "", $text); } $text = preg_replace("/(\[)(b)(])(\r\n)*([^\"]*)(\[\/b\])/siU", "\\5", $text); $text = preg_replace("/(\[)(i)(])(\r\n)*([^\"]*)(\[\/i\])/siU", "\\5", $text); $text = preg_replace("/(\[)(u)(])(\r\n)*([^\"]*)(\[\/u\])/siU", "\\5", $text); $text = replace_badwords($text); } $text = str_replace("\\'", "'", $text); return $text; } function utf8_to_htmlentities($source) { // array used to figure what number to decrement from character order // value // according to number of characters used to map unicode to ascii by // utf-8 $decrement = array(); $decrement[4] = 240; $decrement[3] = 224; $decrement[2] = 192; $decrement[1] = 0; // the number of bits to shift each charNum by $shift = array(); $shift[1][0] = 0; $shift[2][0] = 6; $shift[2][1] = 0; $shift[3][0] = 12; $shift[3][1] = 6; $shift[3][2] = 0; $shift[4][0] = 18; $shift[4][1] = 12; $shift[4][2] = 6; $shift[4][3] = 0; $pos = 0; $len = strlen($source); $str = ''; while ($pos < $len) { $asciiPos = ord(substr($source, $pos, 1)); if (($asciiPos >= 240) && ($asciiPos <= 255)) { // 4 chars representing one unicode character $thisLetter = substr($source, $pos, 4); $pos += 4; } elseif (($asciiPos >= 224) && ($asciiPos <= 239)) { // 3 chars representing one unicode character $thisLetter = substr($source, $pos, 3); $pos += 3; } else if (($asciiPos >= 192) && ($asciiPos <= 223)) { // 2 chars representing one unicode character $thisLetter = substr($source, $pos, 2); $pos += 2; } else { // 1 char (lower ascii) $thisLetter = substr($source, $pos, 1); $pos += 1; } // process the string representing the letter to a unicode entity $thisLen = strlen($thisLetter); $thisPos = 0; $decimalCode = 0; while ($thisPos < $thisLen) { $thisCharOrd = ord(substr($thisLetter, $thisPos, 1)); if ($thisPos == 0) { $charNum = intval($thisCharOrd - $decrement[$thisLen]); $decimalCode += ($charNum << $shift[$thisLen][$thisPos]); } else { $charNum = intval($thisCharOrd - 128); $decimalCode += ($charNum << $shift[$thisLen][$thisPos]); } $thisPos++; } if (($thisLen == 1) && ($decimalCode <= 128)) { $encodedLetter = $thisLetter; } else { $encodedLetter = '&#' . $decimalCode . ';'; } $str .= $encodedLetter; } return $str; } function uni_to_utf8($char) { $char = intval($char); switch ($char) { case ($char < 128) : // its an ASCII char no encoding needed return chr($char); case ($char < 1 << 11) : // its a 2 byte UTF-8 char return chr(192 + ($char >> 6)) . chr(128 + ($char & 63)); case ($char < 1 << 16) : // its a 3 byte UTF-8 char return chr(224 + ($char >> 12)) . chr(128 + (($char >> 6) & 63)) . chr(128 + ($char & 63)); case ($char < 1 << 21) : // its a 4 byte UTF-8 char return chr(240 + ($char >> 18)) . chr(128 + (($char >> 12) & 63)) . chr(128 + (($char >> 6) & 63)) . chr(128 + ($char & 63)); case ($char < 1 << 26) : // its a 5 byte UTF-8 char return chr(248 + ($char >> 24)) . chr(128 + (($char >> 18) & 63)) . chr(128 + (($char >> 12) & 63)) . chr(128 + (($char >> 6) & 63)) . chr(128 + ($char & 63)); default: // its a 6 byte UTF-8 char return chr(252 + ($char >> 30)) . chr(128 + (($char >> 24) & 63)) . chr(128 + (($char >> 18) & 63)) . chr(128 + (($char >> 12) & 63)) . chr(128 + (($char >> 6) & 63)) . chr(128 + ($char & 63)); } } function get_user_info($user_id = 0) { global $site_db, $user_table_fields; $user_info = 0; if ($user_id != 0 && $user_id != GUEST) { $sql = "SELECT * FROM ".USERS_TABLE." WHERE ".get_user_table_field("", "user_id")." = $user_id"; if ($user_info = $site_db->query_firstrow($sql)) { foreach ($user_table_fields as $key => $val) { if (isset($user_info[$val])) { $user_info[$key] = $user_info[$val]; } elseif (!isset($user_info[$key])) { $user_info[$key] = ""; } } } } return $user_info; } function get_icq_status($uin) { if (!is_numeric($uin)) return false; $fp = @fsockopen('status.icq.com', 80, $errno, $errstr, 8); if (!$fp) return false; $request = "HEAD /online.gif?icq=$uin&img=3 HTTP/1.0\r\n" ."Host: status.icq.com\r\n" ."Connection: close\r\n\r\n"; fputs($fp, $request); do { $response = fgets($fp, 1024); } while (!feof($fp) && !stristr($response, 'Location')); fclose($fp); if (strstr($response, 'online1')) return 'online'; if (strstr($response, 'online0')) return 'offline'; if (strstr($response, 'online2')) return 'disabled'; return FALSE; } function add_to_lightbox($id) { global $user_info, $site_db; $id = intval($id); if (!$id) { return false; } $lightbox_ids = $user_info['lightbox_image_ids']; $lightbox_array = explode(" ", $lightbox_ids); if (!in_array($id, $lightbox_array)) { $lightbox_ids .= " ".$id; } $user_info['lightbox_image_ids'] = trim($lightbox_ids); $user_info['lightbox_lastaction'] = time(); $sql = "UPDATE ".LIGHTBOXES_TABLE." SET lightbox_lastaction = ".$user_info['lightbox_lastaction'].", lightbox_image_ids = '".$user_info['lightbox_image_ids']."' WHERE user_id = ".$user_info['user_id']; return ($site_db->query($sql)) ? 1 : 0; } function remove_from_lightbox($id) { global $user_info, $site_db; $lightbox_array = explode(" ",$user_info['lightbox_image_ids']); foreach ($lightbox_array as $key => $val) { if ($val == $id) { unset($lightbox_array[$key]); } } $user_info['lightbox_image_ids'] = trim(implode(" ", $lightbox_array)); $user_info['lightbox_lastaction'] = time(); $sql = "UPDATE ".LIGHTBOXES_TABLE." SET lightbox_lastaction = ".$user_info['lightbox_lastaction'].", lightbox_image_ids = '".$user_info['lightbox_image_ids']."' WHERE user_id = ".$user_info['user_id']; return ($site_db->query($sql)) ? 1 : 0; } function clear_lightbox() { global $user_info, $site_db; $current_time = time(); $sql = "UPDATE ".LIGHTBOXES_TABLE." SET lightbox_image_ids = '', lightbox_lastaction = $current_time WHERE user_id = ".$user_info['user_id']; if ($site_db->query($sql)) { $user_info['lightbox_image_ids'] = ""; $user_info['lightbox_lastaction'] = $current_time; return true; } else { return false; } } function check_lightbox($id) { global $user_info; $lightbox_array = explode(" ", $user_info['lightbox_image_ids']); return in_array($id, $lightbox_array); } function get_random_key($db_table = "", $db_column = "") { global $site_db; $key = md5(uniqid(microtime())); if ($db_table != "" && $db_column != "") { $i = 0; while ($i == 0) { $sql = "SELECT ".$db_column." FROM ".$db_table." WHERE ".$db_column." = '$key'"; if ($site_db->is_empty($sql)) { $i = 1; } else { $i = 0; $key = md5(uniqid(microtime())); } } } return $key; } function get_subcat_ids($cid = 0, $cat_id = 0, $cat_parent_cache) { global $subcat_ids; if (!isset($cat_parent_cache[$cid])) { return false; } foreach ($cat_parent_cache[$cid] as $key => $val) { if (check_permission("auth_viewcat", $val)) { $subcat_ids[$cat_id][] = $val; get_subcat_ids($val, $cat_id, $cat_parent_cache); } } return $subcat_ids; } function get_subcategories($parent_id) { global $cat_parent_cache, $cat_cache, $site_sess, $config; if (!isset($cat_parent_cache[$parent_id]) || $config['num_subcats'] < 1) { return ""; } $visible_cat_cache = array(); foreach ($cat_parent_cache[$parent_id] as $key => $val) { if (check_permission("auth_viewcat", $val)) { $visible_cat_cache[$key] = $val; } } $num_subs = sizeof($visible_cat_cache); $sub_cat_list = ""; $i = 1; foreach ($visible_cat_cache as $subcat_id) { if ($i <= $num_subs && $i <= $config['num_subcats']) { $sub_url = $site_sess->url(ROOT_PATH."categories.php?".URL_CAT_ID."=".$subcat_id); $sub_cat_list .= "".format_text($cat_cache[$subcat_id]['cat_name'], 2).""; if ($i != $config['num_subcats'] && $i < $config['num_subcats'] && $i < $num_subs) { $sub_cat_list .= ", "; } if ($i == $config['num_subcats'] && $i < $num_subs) { $sub_cat_list .= " ...\n"; } } $i++; } return $sub_cat_list; } function get_categories($cat_id = 0) { global $site_template, $site_db, $site_sess, $config, $lang; global $cat_cache, $cat_parent_cache, $new_image_cache, $subcat_ids; $cattable_width = ceil((intval($config['cat_table_width'])) / $config['cat_cells']); if ((substr($config['cat_table_width'],-1)) == "%") { $cattable_width .= "%"; } if (!isset($cat_parent_cache[$cat_id])) { return ""; } $visible_cat_cache = array(); foreach ($cat_parent_cache[$cat_id] as $key => $val) { if (check_permission("auth_viewcat", $val)) { $visible_cat_cache[$key] = $val; } } if (empty($visible_cat_cache)) { return ""; } $total = sizeof($visible_cat_cache); $table_columns = (intval($config['cat_cells'])) ? intval($config['cat_cells']) : 2; if ($total <= $table_columns) { $table_rows = 1; } else { $table_rows = $total / $table_columns; if ($total >= $table_columns && !is_integer($table_rows)) { $table_rows = intval($table_rows) + 1; } } $categories = "\n\n\n\n"; $categories .= "\n\n
    \n"; $categories .= "\n"; $count = 0; $count2 = 0; foreach ($visible_cat_cache as $key => $category_id) { $categories .= "\n\n\n"; if ($count == $table_rows && $count2 < sizeof($visible_cat_cache)) { $categories .= "
    \n"; $is_new = (isset($new_image_cache[$category_id]) && $new_image_cache[$category_id] > 0) ? 1 : 0; $num_images = (isset($cat_cache[$category_id]['num_images'])) ? $cat_cache[$category_id]['num_images'] : 0; $subcat_ids = array(); get_subcat_ids($category_id, $category_id, $cat_parent_cache); if (isset($subcat_ids[$category_id])) { foreach ($subcat_ids[$category_id] as $val) { if (isset($new_image_cache[$val]) && $new_image_cache[$val] > 0) { $is_new = 1; } if (isset($cat_cache[$val]['num_images'])) { $num_images += $cat_cache[$val]['num_images']; } } } if (defined("SHOW_RANDOM_IMAGE") && SHOW_RANDOM_IMAGE == 0 || defined("SHOW_RANDOM_CAT_IMAGE") && SHOW_RANDOM_CAT_IMAGE == 0) { $random_cat_image_file = ""; } else { $random_cat_image_file = get_random_image($category_id, 0, 1); } $site_template->register_vars(array( "cat_id" => $category_id, "cat_name" => format_text($cat_cache[$category_id]['cat_name'], 2), "cat_description" => htmlspecialchars(format_text($cat_cache[$category_id]['cat_description'], 1)), "cat_hits" => $cat_cache[$category_id]['cat_hits'], "cat_is_new" => $is_new, "lang_new" => $lang['new'], "sub_cats" => get_subcategories($category_id), "cat_url" => $site_sess->url(ROOT_PATH."categories.php?".URL_CAT_ID."=".$category_id), "random_cat_image_file" => $random_cat_image_file, "num_images" => $num_images )); $categories .= $site_template->parse_template("category_bit"); $count++; $count2++; $categories .= "
    \n"; $categories .= "\n"; $total = $total - $count2; $table_columns = $table_columns - 1; /*if ($total <= $table_columns && $table_columns > 1) { $table_rows = 1; } else { $table_rows = $total / $table_columns; if ($total >= $table_columns && !is_integer($table_rows)) { $table_rows = intval($table_rows) + 1; } }*/ $count = 0; } } $categories .= "
    \n
    \n"; return $categories; } function get_category_path($cat_id = 0, $detail_path = 0) { global $site_sess, $config, $cat_cache, $url; $parent_id = 1; while ($parent_id) { if (!isset($cat_cache[$cat_id]['cat_parent_id'])) { return false; } $parent_id = $cat_cache[$cat_id]['cat_parent_id']; if (empty($path)) { if ($detail_path) { $cat_url = ROOT_PATH."categories.php?".URL_CAT_ID."=".$cat_id; if (preg_match("/".URL_PAGE."=([0-9]+)/", $url, $regs)) { if (!empty($regs[1]) && $regs[1] != 1) { $cat_url .= "&".URL_PAGE."=".$regs[1]; } } $path = "url($cat_url)."\" class=\"clickstream\">".format_text($cat_cache[$cat_id]['cat_name'], 2).""; } else { $path = format_text($cat_cache[$cat_id]['cat_name'], 2); } } else { $path = "url(ROOT_PATH."categories.php?".URL_CAT_ID."=".$cat_id)."\" class=\"clickstream\">".format_text($cat_cache[$cat_id]['cat_name'], 2)."".$config['category_separator'].$path; } $cat_id = $parent_id; } // end while return $path; } function get_category_dropdown_bits($cat_id, $cid = 0, $depth = 1) { global $site_db, $drop_down_cat_cache, $cat_cache; if (!isset($drop_down_cat_cache[$cid])) { return ""; } $category_list = ""; foreach ($drop_down_cat_cache[$cid] as $key => $category_id) { if (check_permission("auth_viewcat", $category_id)) { $category_list .= "\n"; } else { $category_list .= ">".format_text($cat_cache[$category_id]['cat_name'], 2)."\n"; } $category_list .= get_category_dropdown_bits($cat_id, $category_id, $depth + 1); } } unset($drop_down_cat_cache[$cid]); return $category_list; } function get_category_dropdown($cat_id, $jump = 0, $admin = 0, $i = 0) { global $lang, $drop_down_cat_cache, $cat_parent_cache; // $admin = 1 Main Cat (update/add cats) // $admin = 2 All Cats (find/validate images...) // $admin = 3 Select Cat (update/add image) // $admin = 4 No Cat (check new images) switch ($admin) { case 1: $category = "\n\n"; $category .= "\n"; $category .= "\n"; break; case 3: $i = ($i) ? "_".$i : ""; $category = "\n\n"; $category .= "\n"; $category .= "\n"; break; case 0: default: if ($jump) { $category = "\n\n"; } $category .= "\n"; $category .= "\n"; } // end switch $drop_down_cat_cache = array(); $drop_down_cat_cache = $cat_parent_cache; $category .= get_category_dropdown_bits($cat_id); $category .= "\n"; return $category; } function show_error_page($error_msg, $clickstream = "") { global $site_template, $site_sess, $lang, $config; if (empty($clickstream)) { $clickstream = "url(ROOT_PATH."index.php")."\">".$lang['home']."".$config['category_separator'].$lang['error']; } $site_template->register_vars(array( "error_msg" => $error_msg, "lang_error" => $lang['error'], "clickstream" => $clickstream, "random_image" => "" )); $site_template->print_template($site_template->parse_template("error")); exit; } function get_mysql_version() { global $global_info, $site_db; if (!empty($global_info['mysql_version'])) { return $global_info['mysql_version']; } $split_info = array(); if ($row = $site_db->query_firstrow("SELECT VERSION() AS version")) { $split_info = explode('.', $row['version']); } else { if ($row = $site_db->query_firstrow("SHOW VARIABLES LIKE 'version'")){ $split_info = explode('.', $row[1]); } } $first = (empty($split_info) || empty($split_info[0])) ? 3 : intval($split_info[0]); $second = (empty($split_info[1])) ? 21 : intval($split_info[1]); $third = (empty($split_info[2])) ? 0 : intval($split_info[2]); $global_info['mysql_version'] = sprintf('%d%02d%02d', $first, $second, $third); return $global_info['mysql_version']; } function get_php_version() { global $global_info; if (!empty($global_info['php_version'])) { return $global_info['php_version']; } $split_info = array(); preg_match("/([0-9]{1,2})\.([0-9]{1,2})(\.([0-9]{1,2}))?/", phpversion(), $split_info); $global_info['php_version'] = 0; if (!empty($split_info) && !empty($split_info[1])) { $first = intval($split_info[1]); $second = (empty($split_info[2])) ? 0 : intval($split_info[2]); $third = (empty($split_info[4])) ? 0 : intval($split_info[4]); $global_info['php_version'] = sprintf('%d%02d%02d', $first, $second, $third); } return $global_info['php_version']; } function get_user_os() { global $global_info, $HTTP_USER_AGENT, $HTTP_SERVER_VARS; if (!empty($global_info['user_os'])) { return $global_info['user_os']; } if (!empty($HTTP_SERVER_VARS['HTTP_USER_AGENT'])) { $HTTP_USER_AGENT = $HTTP_SERVER_VARS['HTTP_USER_AGENT']; } elseif (getenv("HTTP_USER_AGENT")) { $HTTP_USER_AGENT = getenv("HTTP_USER_AGENT"); } elseif (empty($HTTP_USER_AGENT)) { $HTTP_USER_AGENT = ""; } if (preg_match("#Win#i", $HTTP_USER_AGENT)) { $global_info['user_os'] = "WIN"; } elseif (preg_match("#Mac#i", $HTTP_USER_AGENT)) { $global_info['user_os'] = "MAC"; } else { $global_info['user_os'] = "OTHER"; } return $global_info['user_os']; } function get_browser_info() { global $global_info, $HTTP_USER_AGENT, $HTTP_SERVER_VARS; if (!empty($global_info['browser_agent'])) { return $global_info['browser_agent']; } if (!empty($HTTP_SERVER_VARS['HTTP_USER_AGENT'])) { $HTTP_USER_AGENT = $HTTP_SERVER_VARS['HTTP_USER_AGENT']; } elseif (getenv("HTTP_USER_AGENT")) { $HTTP_USER_AGENT = getenv("HTTP_USER_AGENT"); } elseif (empty($HTTP_USER_AGENT)) { $HTTP_USER_AGENT = ""; } if (preg_match("#MSIE ([0-9].[0-9]{1,2})#i", $HTTP_USER_AGENT, $regs)) { $global_info['browser_agent'] = "MSIE"; $global_info['browser_version'] = $regs[1]; } elseif (preg_match("#Mozilla/([0-9].[0-9]{1,2})#i", $HTTP_USER_AGENT, $regs)) { $global_info['browser_agent'] = "MOZILLA"; $global_info['browser_version'] = $regs[1]; } elseif (preg_match("#Opera(/| )([0-9].[0-9]{1,2})#i", $HTTP_USER_AGENT, $regs)) { $global_info['browser_agent'] = "OPERA"; $global_info['browser_version'] = $regs[2]; } else { $global_info['browser_agent'] = "OTHER"; $global_info['browser_version'] = 0; } return $global_info['browser_agent']; } function get_document_root() { global $global_info, $DOCUMENT_ROOT, $HTTP_SERVER_VARS; if (!empty($global_info['document_root'])) { return $global_info['document_root']; } if (!empty($HTTP_SERVER_VARS['DOCUMENT_ROOT'])) { $DOCUMENT_ROOT = $HTTP_SERVER_VARS['DOCUMENT_ROOT']; } elseif (getenv("DOCUMENT_ROOT")) { $DOCUMENT_ROOT = getenv("DOCUMENT_ROOT"); } elseif (empty($DOCUMENT_ROOT)) { $DOCUMENT_ROOT = ""; } return $global_info['document_root'] = $DOCUMENT_ROOT; } function remote_file_exists($url, $check_remote = CHECK_REMOTE_FILES) { // similar to file_exists(), checks existence of remote files if (!$check_remote || !CHECK_REMOTE_FILES) { return true; } $url = trim($url); if (!preg_match("=://=", $url)) $url = "http://$url"; if (!($url = @parse_url($url))) { return false; } if (!preg_match("#http#i", $url['scheme'])) { return false; } $url['port'] = (!isset($url['port'])) ? 80 : $url['port']; $url['path'] = (!isset($url['path'])) ? "/" : $url['path']; $fp = fsockopen($url['host'], $url['port'], $errno, $errstr, 30); if (!$fp) { return false; } else { $head = ""; $httpRequest = "HEAD ".$url['path']." HTTP/1.1\r\n" ."HOST: ".$url['host']."\r\n" ."Connection: close\r\n\r\n"; fputs($fp, $httpRequest); while (!feof($fp)) { $head .= fgets($fp, 1024); } fclose($fp); preg_match("=^(HTTP/\d+\.\d+) (\d{3}) ([^\r\n]*)=", $head, $matches); if ($matches[2] == 200) { return true; } } } if (!function_exists('is_executable')) { function is_executable($file) { return is_file($file); } } if (!function_exists('session_regenerate_id')) { function session_regenerate_id() { $id = md5(uniqid(microtime())); if (session_id($id)) { return true; } else { return false; } } } function get_mime_content_type($file) { if (function_exists('mime_content_type')) { $type = mime_content_type($file); if ($type) { return $type; } } $info = @getimagesize($file); if (isset($info['mime'])) { return $info['mime']; } $type = @exec(trim('file -bi '.escapeshellarg($file))); if (strpos($type, ';') !== false) { list($type) = explode(';', $type); } if ($type) { return $type; } static $types = array( 'ai' => 'application/postscript', 'aif' => 'audio/x-aiff', 'aifc' => 'audio/x-aiff', 'aiff' => 'audio/x-aiff', 'asc' => 'text/plain', 'au' => 'audio/basic', 'avi' => 'video/x-msvideo', 'bcpio' => 'application/x-bcpio', 'bin' => 'application/octet-stream', 'c' => 'text/plain', 'cc' => 'text/plain', 'ccad' => 'application/clariscad', 'cdf' => 'application/x-netcdf', 'class' => 'application/octet-stream', 'cpio' => 'application/x-cpio', 'cpt' => 'application/mac-compactpro', 'csh' => 'application/x-csh', 'css' => 'text/css', 'dcr' => 'application/x-director', 'dir' => 'application/x-director', 'dms' => 'application/octet-stream', 'doc' => 'application/msword', 'drw' => 'application/drafting', 'dvi' => 'application/x-dvi', 'dwg' => 'application/acad', 'dxf' => 'application/dxf', 'dxr' => 'application/x-director', 'eps' => 'application/postscript', 'etx' => 'text/x-setext', 'exe' => 'application/octet-stream', 'ez' => 'application/andrew-inset', 'f' => 'text/plain', 'f90' => 'text/plain', 'fli' => 'video/x-fli', 'gif' => 'image/gif', 'gtar' => 'application/x-gtar', 'gz' => 'application/x-gzip', 'h' => 'text/plain', 'hdf' => 'application/x-hdf', 'hh' => 'text/plain', 'hqx' => 'application/mac-binhex40', 'htm' => 'text/html', 'html' => 'text/html', 'ice' => 'x-conference/x-cooltalk', 'ief' => 'image/ief', 'iges' => 'model/iges', 'igs' => 'model/iges', 'ips' => 'application/x-ipscript', 'ipx' => 'application/x-ipix', 'jpe' => 'image/jpeg', 'jpeg' => 'image/jpeg', 'jpg' => 'image/jpeg', 'js' => 'application/x-javascript', 'kar' => 'audio/midi', 'latex' => 'application/x-latex', 'lha' => 'application/octet-stream', 'lsp' => 'application/x-lisp', 'lzh' => 'application/octet-stream', 'm' => 'text/plain', 'man' => 'application/x-troff-man', 'me' => 'application/x-troff-me', 'mesh' => 'model/mesh', 'mid' => 'audio/midi', 'midi' => 'audio/midi', 'mif' => 'application/vnd.mif', 'mime' => 'www/mime', 'mov' => 'video/quicktime', 'movie' => 'video/x-sgi-movie', 'mp2' => 'audio/mpeg', 'mp3' => 'audio/mpeg', 'mpe' => 'video/mpeg', 'mpeg' => 'video/mpeg', 'mpg' => 'video/mpeg', 'mpga' => 'audio/mpeg', 'ms' => 'application/x-troff-ms', 'msh' => 'model/mesh', 'nc' => 'application/x-netcdf', 'oda' => 'application/oda', 'pbm' => 'image/x-portable-bitmap', 'pdb' => 'chemical/x-pdb', 'pdf' => 'application/pdf', 'pgm' => 'image/x-portable-graymap', 'pgn' => 'application/x-chess-pgn', 'png' => 'image/png', 'pnm' => 'image/x-portable-anymap', 'pot' => 'application/mspowerpoint', 'ppm' => 'image/x-portable-pixmap', 'pps' => 'application/mspowerpoint', 'ppt' => 'application/mspowerpoint', 'ppz' => 'application/mspowerpoint', 'pre' => 'application/x-freelance', 'prt' => 'application/pro_eng', 'ps' => 'application/postscript', 'qt' => 'video/quicktime', 'ra' => 'audio/x-realaudio', 'ram' => 'audio/x-pn-realaudio', 'ras' => 'image/cmu-raster', 'rgb' => 'image/x-rgb', 'rm' => 'audio/x-pn-realaudio', 'roff' => 'application/x-troff', 'rpm' => 'audio/x-pn-realaudio-plugin', 'rtf' => 'text/rtf', 'rtx' => 'text/richtext', 'scm' => 'application/x-lotusscreencam', 'set' => 'application/set', 'sgm' => 'text/sgml', 'sgml' => 'text/sgml', 'sh' => 'application/x-sh', 'shar' => 'application/x-shar', 'silo' => 'model/mesh', 'sit' => 'application/x-stuffit', 'skd' => 'application/x-koan', 'skm' => 'application/x-koan', 'skp' => 'application/x-koan', 'skt' => 'application/x-koan', 'smi' => 'application/smil', 'smil' => 'application/smil', 'snd' => 'audio/basic', 'sol' => 'application/solids', 'spl' => 'application/x-futuresplash', 'src' => 'application/x-wais-source', 'step' => 'application/STEP', 'stl' => 'application/SLA', 'stp' => 'application/STEP', 'sv4cpio' => 'application/x-sv4cpio', 'sv4crc' => 'application/x-sv4crc', 'swf' => 'application/x-shockwave-flash', 't' => 'application/x-troff', 'tar' => 'application/x-tar', 'tcl' => 'application/x-tcl', 'tex' => 'application/x-tex', 'texi' => 'application/x-texinfo', 'texinfo - application/x-texinfo', 'tif' => 'image/tiff', 'tiff' => 'image/tiff', 'tr' => 'application/x-troff', 'tsi' => 'audio/TSP-audio', 'tsp' => 'application/dsptype', 'tsv' => 'text/tab-separated-values', 'txt' => 'text/plain', 'unv' => 'application/i-deas', 'ustar' => 'application/x-ustar', 'vcd' => 'application/x-cdlink', 'vda' => 'application/vda', 'viv' => 'video/vnd.vivo', 'vivo' => 'video/vnd.vivo', 'vrml' => 'model/vrml', 'wav' => 'audio/x-wav', 'wrl' => 'model/vrml', 'xbm' => 'image/x-xbitmap', 'xlc' => 'application/vnd.ms-excel', 'xll' => 'application/vnd.ms-excel', 'xlm' => 'application/vnd.ms-excel', 'xls' => 'application/vnd.ms-excel', 'xlw' => 'application/vnd.ms-excel', 'xml' => 'text/xml', 'xpm' => 'image/x-xpixmap', 'xwd' => 'image/x-xwindowdump', 'xyz' => 'chemical/x-pdb', 'zip' => 'application/zip', ); $ext = get_file_extension($file); if (isset($types[$ext])) { return $types[$ext]; } return 'application/octet-stream'; } function trim_value(&$value) { $value = trim($value); } /* create directory tree recursively backward compatibility for php4 */ function _mkdir($dir, $chmod = CHMOD_DIRS) { if (is_dir($dir) || @mkdir($dir, $chmod)) return true; if (!_mkdir(dirname($dir), $chmod)) return false; return @mkdir($dir, $chmod); } function filterFileName($text, $tolower = 1, $transl = null) { global $translit; $transl = ($transl !== null) ? $transl : @$translit; if ($transl) $text = strtr( $text, array( // russian Windows-1251 "\xc0" => "a", "\xc1" => "b", "\xc2" => "v", "\xc3" => "g", "\xc4" => "d", "\xc5" => "e", "\xa8" => "e", "\xc6" => "zh", "\xc7" => "z", "\xc8" => "i", "\xc9" => "j", "\xca" => "k", "\xcb" => "l", "\xcc" => "m", "\xcd" => "n", "\xce" => "o", "\xcf" => "p", "\xd0" => "r", "\xd1" => "s", "\xd2" => "t", "\xd3" => "u", "\xd4" => "f", "\xd5" => "h", "\xd6" => "c", "\xd7" => "ch", "\xd8" => "sh", "\xd9" => "sch", "\xda" => "", "\xdb" => "i", "\xdc" => "", "\xdd" => "e", "\xde" => "yu", "\xdf" => "ya", "\xe0" => "a", "\xe1" => "b", "\xe2" => "v", "\xe3" => "g", "\xe4" => "d", "\xe5" => "e", "\xb8" => "e", "\xe6" => "zh", "\xe7" => "z", "\xe8" => "i", "\xe9" => "j", "\xea" => "k", "\xeb" => "l", "\xec" => "m", "\xed" => "n", "\xee" => "o", "\xef" => "p", "\xf0" => "r", "\xf1" => "s", "\xf2" => "t", "\xf3" => "u", "\xf4" => "f", "\xf5" => "h", "\xf6" => "c", "\xf7" => "ch", "\xf8" => "sh", "\xf9" => "sch", "\xfa" => "", "\xfb" => "i", "\xfc" => "", "\xfd" => "e", "\xfe" => "yu", "\xff" => "ya", // russian KOI8 /* "\xe1" => "a", "\xe2" => "b", "\xf7" => "v", "\xe7" => "g", "\xe4" => "d", "\xe5" => "e", "\xb3" => "e", "\xf6" => "zh", "\xfa" => "z", "\xe9" => "i", "\xea" => "j", "\xeb" => "k", "\xec" => "l", "\xed" => "m", "\xee" => "n", "\xef" => "o", "\xf0" => "p", "\xf2" => "r", "\xf3" => "s", "\xf4" => "t", "\xf5" => "u", "\xe6" => "f", "\xe8" => "h", "\xe3" => "c", "\xfe" => "ch", "\xfb" => "sh", "\xfd" => "sch", "\xff" => "", "\xf9" => "i", "\xf8" => "", "\xfc" => "e", "\xe0" => "yu", "\xf1" => "ya", "\xc1" => "a", "\xc2" => "b", "\xd7" => "v", "\xc7" => "g", "\xc4" => "d", "\xc5" => "e", "\xa3" => "e", "\xd6" => "zh", "\xda" => "z", "\xc9" => "i", "\xca" => "j", "\xcb" => "k", "\xcc" => "l", "\xcd" => "m", "\xce" => "n", "\xcf" => "o", "\xd0" => "p", "\xd2" => "r", "\xd3" => "s", "\xd4" => "t", "\xd5" => "u", "\xc6" => "f", "\xc8" => "h", "\xc3" => "c", "\xde" => "ch", "\xdb" => "sh", "\xdd" => "sch", "\xdf" => "", "\xd9" => "i", "\xd8" => "", "\xdc" => "e", "\xc0" => "yu", "\xd1" => "ya", */ )); if ($tolower) $text = strtolower($text); $text = str_replace(" ", "_", $text); $text = str_replace("%20", "_", $text); $text = preg_replace("/[^\-\._a-z0-9]/i", "_", $text); return $text; } function create_unique_filename($base, $file) { $ext = get_file_extension($file); $name = get_file_name($file); $n = 2; $copy = ""; while (file_exists($base."/".$name.$copy.".".$ext)) { $copy = "_".$n; $n++; } return $name.$copy.".".$ext; } ?>
    Fatal error: Uncaught Error: Call to undefined function get_basename() in /home/trishstr/public_html/imgs/global.php:366 Stack trace: #0 /home/trishstr/public_html/imgs/categories.php(31): include() #1 {main} thrown in /home/trishstr/public_html/imgs/global.php on line 366