ntities $chars = preg_replace( '/&(?!(#[0-9]+|[a-z]+);)/si', '&', $chars ); $chars = str_replace(">", ">", $chars); $chars = str_replace("<", "<", $chars); $chars = str_replace('"', """, $chars); return $chars; } //MOD SMF integration if (!function_exists('un_htmlspecialchars')) { function un_htmlspecialchars($chars) { //$chars = preg_replace("/(&#)([0-9]*)(;)/esiU", "chr(intval('\\2'))", $chars); $chars = str_replace(">", ">", $chars); $chars = str_replace("<", "<", $chars); $chars = str_replace(""", "\"", $chars); $chars = str_replace("&", "&", $chars); return $chars; } } //function un_htmlspecialchars($text) { // $text = str_replace( // array('<', '>', '"', '&'), // array('<', '>', '"', '&'), // $text // ); // return $text; //} //END SMF function get_lens_info($filename) { ob_start(); readfile($filename); $source = ob_get_contents(); ob_end_clean(); $xmpdata_start = strpos($source,""); $xmplenght = $xmpdata_end-$xmpdata_start; $xmpdata = substr($source,$xmpdata_start,$xmplenght+12); $xmp_parsed = array(); $regexps = array( array("name" => "AUX lens", "regexp" => "/Lens=\".+\"/") ); foreach ($regexps as $key => $k) { $name = $k["name"]; $regexp = $k["regexp"]; unset($r); preg_match ($regexp, $xmpdata, $r); $xmp_item = ""; $xmp_item = @$r[0]; array_push($xmp_parsed,array("item" => $name, "value" => $xmp_item)); } foreach ($xmp_parsed as $key => $k) { $item = $k["item"]; $value = $k["value"]; $myvalue = explode("\"", $value); /* print $myvalue[1];*/ } return $myvalue[1]; } function get_iptc_info($info) { $iptc_match = array(); $iptc_match['2#120'] = "caption"; $iptc_match['2#122'] = "caption_writer"; $iptc_match['2#105'] = "headline"; $iptc_match['2#040'] = "special_instructions"; $iptc_match['2#080'] = "byline"; $iptc_match['2#085'] = "byline_title"; $iptc_match['2#110'] = "credit"; $iptc_match['2#115'] = "source"; $iptc_match['2#005'] = "object_name"; $iptc_match['2#055'] = "date_created"; $iptc_match['2#090'] = "city"; $iptc_match['2#095'] = "state"; $iptc_match['2#101'] = "country"; $iptc_match['2#103'] = "original_transmission_reference"; $iptc_match['2#015'] = "category"; $iptc_match['2#020'] = "supplemental_category"; $iptc_match['2#025'] = "keyword"; $iptc_match['2#116'] = "copyright_notice"; $iptc = iptcparse($info); $iptc_array = array(); if (is_array($iptc)) { foreach ($iptc as $key => $val) { if (isset($iptc_match[$key])) { $iptc_info = ""; foreach ($val as $val2) { $iptc_info .= (($iptc_info != "" ) ? ", " : "").$val2; } if ($key == "2#055") { $iptc_array[$iptc_match[$key]] = preg_replace("/([0-9]{4})([0-9]{2})([0-9]{2})/", "\\3.\\2.\\1", $iptc_info); } else { $iptc_array[$iptc_match[$key]] = $iptc_info; } } } } return $iptc_array; } function get_exif_info($exif) { $exif_match = array(); $exif_match['UndefinedTag:0x0095'] = "UndefinedTag:0x0095"; $exif_match['Make'] = "Make"; $exif_match['Model'] = "Model"; $exif_match['DateTimeOriginal'] = "DateTimeOriginal"; $exif_match['ISOSpeedRatings'] = "ISOSpeedRatings"; $exif_match['ExposureTime'] = "ExposureTime"; $exif_match['FNumber'] = "FNumber"; $exif_match['FocalLength'] = "FocalLength"; $exif_match['ExposureBiasValue'] = "ExposureBiasValue"; $exif_match['ApertureValue'] = "ApertureValue"; $exif_match['MaxApertureValue'] = "MaxApertureValue"; $exif_match['MeteringMode'] = "MeteringMode"; $exif_match['Flash'] = "Flash"; $exif_match['ExposureProgram'] = "ExposureProgram"; $exif_match['ExposureMode'] = "ExposureMode"; $exif_match['WhiteBalance'] = "WhiteBalance"; $exif_match['GPSLatitude'] = "GPSLatitude"; $exif_match['GPSLatitudeRef'] = "GPSLatitudeRef"; $exif_match['GPSLongitude'] = "GPSLongitude"; $exif_match['GPSLongitudeRef'] = "GPSLongitudeRef"; $exif_match['GPSAltitude'] = "GPSAltitude"; $exif_match['GPSTrack'] = "GPSTrack"; $exif_array = array(); if (is_array($exif)) { foreach ($exif as $key => $val) { if (isset($exif_match[$key])) { $exif_info = $val; if ($key == "DateTimeOriginal") { $exif_array[$exif_match[$key]] = preg_replace("/([0-9]{4}):([0-9]{2}):([0-9]{2})/", "\\3.\\2.\\1", $exif_info); } elseif ($key == "ExposureTime") { $exposure = explode("/", $exif_info); $exif_array[$exif_match[$key]] = "1/" . ($exposure[1] / $exposure[0]); } elseif ($key == "FNumber") { $FNumber = explode("/", $exif_info); $exif_array[$exif_match[$key]] = "F/" . ($FNumber[0] / $FNumber[1]); } elseif ($key == "FocalLength") { $FocalLength = explode("/", $exif_info); $exif_array[$exif_match[$key]] = round(($FocalLength[0] / $FocalLength[1])) . " mm"; } elseif ($key == "ExposureBiasValue") { $ExposureBiasValue = explode("/", $exif_info); $exif_array[$exif_match[$key]] = round(($ExposureBiasValue[0] / $ExposureBiasValue[1]), 1) . " EV"; } elseif ($key == "ApertureValue") { $ApertureValue = explode("/", $exif_info); $exif_array[$exif_match[$key]] ="F/" . round(($ApertureValue[0] / $ApertureValue[1]), 1); } elseif ($key == "MaxApertureValue") { $MaxApertureValue = explode("/", $exif_info); $exif_array[$exif_match[$key]] ="F/" . round((pow(sqrt(2),$MaxApertureValue[0] / $MaxApertureValue[1])), 1); } elseif ($key == "MeteringMode") { if($exif_info == 0) {$MeteringMode = "Unbekannt";} if($exif_info == 1) {$MeteringMode = "Durchschnitt";} if($exif_info == 2) {$MeteringMode = "Mittenbetont";} if($exif_info == 3) {$MeteringMode = "Spot";} if($exif_info == 4) {$MeteringMode = "Multi-Spot";} if($exif_info == 5) {$MeteringMode = "Multi-Segment";} if($exif_info == 6) {$MeteringMode = "Selektiv";} if($exif_info == 255) {$MeteringMode = "Anders";} $exif_array[$exif_match[$key]] = ($MeteringMode); } elseif ($key == "Flash") { if($exif_info == 0) {$Flash = "Kein Blitz";} if($exif_info == 1) {$Flash = "Blitz ausgelöst";} if($exif_info == 5) {$Flash = "Blitz ausgelöst but strobe return light not detected";} if($exif_info == 7) {$Flash = "Blitz ausgelöst and strobe return light detected";} if($exif_info == 9) {$Flash = "Blitz ausgelöst, erzwungener Blitz";} if($exif_info == 13) {$Flash = "Blitz ausgelöst, erzwungener Blitz, return light not detected";} if($exif_info == 15) {$Flash = "Blitz ausgelöst, erzwungener Blitz, return light detected";} if($exif_info == 16) {$Flash = "Blitz nicht ausgelöst";} if($exif_info == 24) {$Flash = "Blitz nicht ausgelöst, Auto-mode";} if($exif_info == 25) {$Flash = "Blitz ausgelöst, Auto-mode";} if($exif_info == 29) {$Flash = "Blitz ausgelöst, Auto-mode, return light not detected";} if($exif_info == 31) {$Flash = "Blitz ausgelöst, Auto-mode, return light detected";} if($exif_info == 32) {$Flash = "keine Blitzfunktion";} if($exif_info == 65) {$Flash = "Blitz ausgelöst, Rote Augen Reduktion";} if($exif_info == 69) {$Flash = "Blitz ausgelöst, Rote Augen Reduktion, return light not detected";} if($exif_info == 71) {$Flash = "Blitz ausgelöst, Rote Augen Reduktion, return light detected";} if($exif_info == 73) {$Flash = "Blitz ausgelöst, erzwungener Blitz, Rote Augen Reduktion";} if($exif_info == 77) {$Flash = "Blitz ausgelöst, erzwungener Blitz, Rote Augen Reduktion, return light not detected";} if($exif_info == 79) {$Flash = "Blitz ausgelöst, erzwungener Blitz, Rote Augen Reduktion, red-eye reduction mode, return light detected";} if($exif_info == 89) {$Flash = "Blitz ausgelöst, Auto-mode, Rote Augen Reduktion";} if($exif_info == 93) {$Flash = "Blitz ausgelöst, Auto-mode, return light not detected, Rote Augen Reduktion";} if($exif_info == 95) {$Flash = "Blitz ausgelöst, Auto-mode, return light detected, Rote Augen Reduktion";} $exif_array[$exif_match[$key]] = ($Flash); } elseif ($key == "ExposureProgram") { if($exif_info == 1) {$ExposureProgram = "Manuell";} if($exif_info == 2) {$ExposureProgram = "Programmautomatik";} if($exif_info == 3) {$ExposureProgram = "Zeitautomatik";} if($exif_info == 4) {$ExposureProgram = "Blendenautomatik";} if($exif_info == 5) {$ExposureProgram = "Stilleben";} if($exif_info == 6) {$ExposureProgram = "Sport";} if($exif_info == 7) {$ExposureProgram = "Portrait";} if($exif_info == 8) {$ExposureProgram = "Landschaft";} $exif_array[$exif_match[$key]] = ($ExposureProgram); } elseif ($key == "ExposureMode") { if($exif_info == 0) {$ExposureMode = "Automatisch";} if($exif_info == 1) {$ExposureMode = "Manuell";} if($exif_info == 2) {$ExposureMode = "Auto Bracket";} if($exif_info == 255) {$ExposureMode = "Unbekannt";} $exif_array[$exif_match[$key]] = ($ExposureMode); } elseif ($key == "WhiteBalance") { if($exif_info == 0) {$WhiteBalance = "Automatisch";} if($exif_info == 1) {$WhiteBalance = "Manuell";} $exif_array[$exif_match[$key]] = ($WhiteBalance); } elseif ($key == "GPSLatitudeRef") { if ($exif_info == N) {$GPSLatitudeRef = "Nord";$GPSLatfaktor = 1;} if ($exif_info == S) {$GPSLatitudeRef = "Süd"; $GPSLatfaktor = -1;} $exif_array[$exif_match[$key]] = ($GPSLatitudeRef); } elseif ($key == "GPSLongitudeRef") { if ($exif_info == E) {$GPSLongitudeRef = "Ost";$GPSLongfaktor = 1;} if ($exif_info == W) {$GPSLongitudeRef = "West";$GPSLongfaktor = -1;} $exif_array[$exif_match[$key]] = ($GPSLongitudeRef); } elseif ($key == "GPSLatitude") { $GPSLatitude_h = explode("/", $exif_info[0]); $GPSLatitude_m = explode("/", $exif_info[1]); $GPSLatitude_s = explode("/", $exif_info[2]); $GPSLat_h = $GPSLatitude_h[0] / $GPSLatitude_h[1]; $GPSLat_m = $GPSLatitude_m[0] / $GPSLatitude_m[1]; $GPSLat_s = $GPSLatitude_s[0] / $GPSLatitude_s[1]; $GPSLatGrad = $GPSLatfaktor * ($GPSLat_h + ($GPSLat_m + ($GPSLat_s / 60))/60); $exif_array[$exif_match[$key]] = $GPSLatitudeRef . " " .$GPSLat_h . "° ". $GPSLat_m . "' " . $GPSLat_s . "'' ($GPSLatGrad)"; } elseif ($key == "GPSLongitude") { $GPSLongitude_h = explode("/", $exif_info[0]); $GPSLongitude_m = explode("/", $exif_info[1]); $GPSLongitude_s = explode("/", $exif_info[2]); $GPSLong_h = $GPSLongitude_h[0] / $GPSLongitude_h[1]; $GPSLong_m = $GPSLongitude_m[0] / $GPSLongitude_m[1]; $GPSLong_s = $GPSLongitude_s[0] / $GPSLongitude_s[1]; $GPSLongGrad = $GPSLongfaktor * ($GPSLong_h + ($GPSLong_m + ($GPSLong_s / 60))/60); $exif_array[$exif_match[$key]] = $GPSLongitudeRef . " " . $GPSLong_h . "° ". $GPSLong_m . "' " . $GPSLong_s . "'' ($GPSLongGrad)"; } elseif ($key == "GPSAltitude") { $GPSAltitude = explode("/", $exif_info); $exif_array[$exif_match[$key]] = ($GPSAltitude[0] / $GPSAltitude[1]) . " Meter über NN"; } elseif ($key == "GPSTrack") { $GPSTrack = explode("/", $exif_info); $exif_array[$exif_match[$key]] = ($GPSTrack[0] / $GPSTrack[1]) . "°"; } else { $exif_array[$exif_match[$key]] = $exif_info; } } } } return $exif_array; } function user_comments($image_id = 0, $user_id = 0) { global $site_db, $user_table_fields; if ($user_id != GUEST ) { $sql = "SELECT COUNT(comment_id) AS comments FROM ".COMMENTS_TABLE." WHERE image_id = $image_id AND user_id = $user_id"; $countcomments = $site_db->query_firstrow($sql); } return $countcomments['comments']; } function show_image($image_row, $mode = "", $show_link = 1, $detailed_view = 0) { global $self_url, $site_template, $site_sess, $user_info, $config, $cat_cache, $lang, $additional_image_fields, $user_table_fields, $url_show_profile; $is_new = ($image_row['image_date'] >= (time() - 60 * 60 * 24 * $config['new_cutoff'])) ? 1 : 0; $description = (!empty($image_row['image_description'])) ? format_text($image_row['image_description'], 1, 0, 1) : REPLACE_EMPTY; if (!empty($image_row['image_newfield'])) { $newfield .= "
\n"; $newfield .= "
\n"; $newfield .= "
"; $newfield .= "
\n"; $newfield .= (!empty($image_row['image_newfield'])) ? format_text($image_row['image_newfield'], 1, 0, 1) : REPLACE_EMPTY; $newfield .= "
\n"; $newfield .= "
\n"; $newfield .= "
"; } else { $newfield .= (!empty($image_row['image_newfield'])) ? format_text($image_row['image_newfield'], 1, 0, 1) : REPLACE_EMPTY; } if ($image_row ['image_gmap_show'] == 1) $is_image_gmap_show = "\"Google-Map"; else $is_image_gmap_show = ""; if ($image_row ['image_preistyp'] == 1) $is_image_preistyp = "\"Bild"; else $is_image_preistyp = ""; if ($image_row ['image_facebook'] == 1) $is_image_facebook = "\"Bild"; else $is_image_facebook = ""; if ($image_row ['image_handy'] == 1) $is_image_handy = "\"Handyfoto\""; else $is_image_handy = ""; if ($image_row ['image_scan'] == 1) $is_image_scan = "\"Scannerfoto\""; else $is_image_scan = ""; if ($image_row ['image_comments'] > ($config['good_comments'])) $is_image_auszeich = "\"Top"; else $is_image_auszeich = ""; if (!empty($image_row['image_keywords'])) { $split_keywords = explode(",", $image_row['image_keywords']); $keywords = ""; foreach ($split_keywords as $key => $val) { $url_val = $val; if (preg_match('/[^a-z0-9]+/i', $url_val)) { $url_val = '"' . $url_val . '"'; } $keywords .= (($keywords != "" ) ? ", " : "")."url(ROOT_PATH."search.php?search_keywords=".urlencode($url_val))."\">".format_text($val, 2).""; } } else { $keywords = REPLACE_EMPTY; } if (!check_permission("auth_readcomment", $image_row['cat_id'])) { $image_row['image_allow_comments'] = 0; } $num_comments = ($image_row['image_allow_comments'] == 1) ? $image_row['image_comments'] : ""; if ($user_info['user_level'] != GUEST) { $report_url = ($config['report_image_status'] == 0 && $user_info['user_level'] >= USER) ? $site_sess->url(ROOT_PATH."report_pic.php?".URL_CAT_ID."=".$image_row['cat_id']."&cat_name=".$image_row['cat_name']."&".URL_IMAGE_ID."=".$image_row['image_id']."&image_name=".$image_row['image_name']) : ""; $lightbox_url = $self_url; $lightbox_url .= (!empty($mode)) ? ((strpos($lightbox_url, '?') !== false) ? "&" : "?")."mode=".$mode : ""; $lightbox_url .= strpos($lightbox_url, '?') !== false ? "&" : "?"; if (check_lightbox($image_row['image_id'])) { $lightbox_url .= "action=removefromlightbox&id=".$image_row['image_id']; $lightbox_button = "url($lightbox_url)."\">\"\""; } else { $lightbox_url .= "action=addtolightbox&id=".$image_row['image_id']; $lightbox_button = "url($lightbox_url)."\">\"\""; } } else { $lightbox_button = "\"\""; } if (!check_permission("auth_download", $image_row['cat_id'])) { $download_button = "\"\""; $download_zip_button = (function_exists("gzcompress") && function_exists("crc32")) ? "\"\"" : ""; $allow_download = 0; clear_download_token($image_row['image_id']); } else { $target = (!empty($image_row['image_download_url']) && !is_remote_file($image_row['image_download_url']) && !is_local_file($image_row['image_download_url'])) ? "target=\"_blank\"" : ""; $download_button = "url(ROOT_PATH."download.php?".URL_IMAGE_ID."=".$image_row['image_id'])."\"".$target.">\"\""; $download_zip_button = ($target == "" && function_exists("gzcompress") && function_exists("crc32")) ? "url(ROOT_PATH."download.php?action=zip&".URL_IMAGE_ID."=".$image_row['image_id'])."\"".$target.">\"\"" : ""; $allow_download = 1; set_download_token($image_row['image_id']); } if (!check_permission("auth_sendpostcard", $image_row['cat_id'])) { $postcard_button = "\"\""; } else { $postcard_button = "url(ROOT_PATH."postcards.php?".URL_IMAGE_ID."=".$image_row['image_id'].((!empty($mode)) ? "&mode=".$mode : ""))."\">\"\""; } if (!check_permission("auth_viewimage", $image_row['cat_id']) || !check_permission("auth_viewcat", $image_row['cat_id'])) { $show_link = 0; } $file_size = "n/a"; if (!is_remote($image_row['image_media_file'])) { if ($file_size = @filesize(MEDIA_PATH."/".$image_row['cat_id']."/".$image_row['image_media_file'])) { $file_size = format_file_size($file_size); } } elseif ($detailed_view) { $file_size = get_remote_file_size($image_row['image_media_file']); } if (isset($image_row[$user_table_fields['user_name']]) && $image_row['user_id'] != GUEST) { $user_name = format_text($image_row[$user_table_fields['user_name']], 2); $user_profile_link = (!empty($url_show_profile)) ? str_replace("{user_id}", $image_row['user_id'], $url_show_profile) : ROOT_PATH."member.php?action=showprofile&".URL_USER_ID."=".$image_row['user_id']; $user_name_link = "url($user_profile_link)."\">".$user_name.""; } else { $user_name = format_text($lang['userlevel_guest'], 2); $user_name_link = $user_name; } $user_comments = user_comments($image_row['image_id'],$user_info['user_id']); $site_template->register_vars(array( "image_id" => $image_row['image_id'], "user_id" => $image_row['user_id'], "user_name" => $user_name, "user_name_link" => $user_name_link, "image_name" => format_text($image_row['image_name'], 2), "image_description" => $description, "image_newfield" => $newfield, "image_keywords" => $keywords, "image_is_image_gmap_show" => $is_image_gmap_show, "image_is_image_preistyp" => $is_image_preistyp, "image_is_image_handy" => $is_image_handy, "image_is_image_scan" => $is_image_scan, "image_is_image_facebook" => $is_image_facebook, "image_is_image_auszeich" => $is_image_auszeich, "image_date" => format_date($config['date_format']." ".$config['time_format'],$image_row['image_date']), "image_is_new" => $is_new, "lang_new" => $lang['new'], "image_active" => $image_row['image_active'], "cat_id" => $image_row['cat_id'], "cat_name" => format_text($image_row['cat_name'], 2), "cat_url" => $site_sess->url(ROOT_PATH."categories.php?".URL_CAT_ID."=".$image_row['cat_id']), "image_downloads" => $image_row['image_downloads'], "image_votes" => $image_row['image_votes'], "image_rating" => $image_row['image_rating'], "image_hits" => $image_row['image_hits'], "allow_comments" => $image_row['image_allow_comments'], "allow_color" => $image_row['image_allow_color'], "lang_comments" => $lang['comments'], "image_comments" => $num_comments, "user_comments"=> ($user_comments) ? $lang['count_user_comment']."".$user_comments."":"", //"user_comments"=> ($user_comments) ? $lang['count_user_comment']."".$user_comments."":"", "lang_user_fotoskill" => $lang['user_fotoskill'], "lang_user_mitglied" => $lang['user_mitglied'], "user_mitglied" => $image_row[$user_table_fields['user_mitglied']], "user_fotoskill" => $image_row[$user_table_fields['user_fotoskill']], "lang_user_erwart" => $lang['user_erwart'], "user_erwart" => $image_row[$user_table_fields['user_erwart']], "lang_image_bgcolor" => $lang['image_bgcolor'], "image_bgcolor" => $image_row['image_bgcolor'], "lightbox_button" => $lightbox_button, "postcard_button" => $postcard_button, "download_button" => $download_button, "download_zip_button" => $download_zip_button, "image_download_url" => $image_row['image_download_url'], "allow_download" => $allow_download, "url_download" => $site_sess->url(ROOT_PATH."download.php?".URL_IMAGE_ID."=".$image_row['image_id']), "image_file_size" => $file_size, "image_url" => ($show_link) ? $site_sess->url(ROOT_PATH."details.php?".URL_IMAGE_ID."=".$image_row['image_id'].((!empty($mode)) ? "&mode=".$mode : "")) : "", "thumbnail" => get_thumbnail_code($image_row['image_media_file'], $image_row['image_thumb_file'], $image_row['image_id'], $image_row['cat_id'], $image_row['image_name'], $mode, $show_link), "thumbnail_small" => get_thumbnail_resizer($image_row['image_media_file'], $image_row['image_thumb_file'], $image_row['image_id'], $image_row['cat_id'], $image_row['image_name'], $mode, $show_link,0, 60,60), // The last two values are "width, height" "thumbnail_medium" => get_thumbnail_resizer($image_row['image_media_file'], $image_row['image_thumb_file'], $image_row['image_id'], $image_row['cat_id'], $image_row['image_name'], $mode, $show_link,0, 110,110), // The last two values are "width, height" "thumbnail_large" => get_thumbnail_resizer($image_row['image_media_file'], $image_row['image_thumb_file'], $image_row['image_id'], $image_row['cat_id'], $image_row['image_name'], $mode, $show_link,0, 200,200), // The last two values are "width, height" "thumbnail_big" => get_thumbnail_resizer($image_row['image_media_file'], $image_row['image_thumb_file'], $image_row['image_id'], $image_row['cat_id'], $image_row['image_name'], $mode, $show_link,0, 400,400), // The last two values are "width, height" //e.t.c. "thumbnail_openwindow" => get_thumbnail_code($image_row['image_media_file'], $image_row['image_thumb_file'], $image_row['image_id'], $image_row['cat_id'], $image_row['image_name'], $mode, $show_link, 1), "image_file_name" => $image_row['image_media_file'], "report_image_url" => $report_url, "lang_report_pic" => $lang['report_pic_title'], "valid_thumbnail" => get_thumbnail_code_awaiting($image_row['image_media_file'], $image_row['image_thumb_file'], $image_row['image_id'], 0, $image_row['image_name'], $mode,1,1), "thumbnail_file_name" => $image_row['image_thumb_file'] )); if (!empty($additional_user_fields)) { $additional_field_array = array(); foreach ($additional_user_fields as $key => $val) { if ($key != "userpic" || ($key == "userpic" && $config['userpic'])) { $additional_field_array[$key] = (!empty($image_row[$key])) ? format_text($image_row[$key], 1) : REPLACE_EMPTY; $additional_field_array['lang_'.$key] = $val[0]; } } if (!empty($additional_field_array)) { $site_template->register_vars($additional_field_array); } } if (!empty($additional_image_fields)) { $additional_field_array = array(); foreach ($additional_image_fields as $key => $val) { $additional_field_array[$key] = (!empty($image_row[$key])) ? format_text($image_row[$key], 1) : REPLACE_EMPTY; $additional_field_array['lang_'.$key] = $val[0]; } if (!empty($additional_field_array)) { $site_template->register_vars($additional_field_array); } } $rate_form = ""; if (check_permission("auth_vote", $image_row['cat_id'])) { $site_template->register_vars("rate", $lang['rate']); $rate_form = $site_template->parse_template("rate_form"); } $site_template->register_vars("rate_form", $rate_form); $site_template->register_vars(array( "image" => get_media_code($image_row['image_media_file'], $image_row['image_id'], $image_row['cat_id'], $image_row['image_name'], $mode, $show_link, $detailed_view), )); return true; } // ----------------------------------------------- // --- Start Mod "my awaiting images" ------------ //------------------------------------------------ function get_thumbnail_code_awaiting($media_file_name, $thumb_file_name = "", $image_id, $cat_id, $image_name = "", $mode = "", $show_link = 1, $open_window = 0) { global $site_sess, $config; $max = 1; // Hier maximale Breite der Thumbnails in Pixel eingeben ! if (!check_media_type($media_file_name)) { $thumb = "\"\""; } else { if (!get_file_path($thumb_file_name, "thumb", $cat_id, 0, 0)) { $file_src = ICON_PATH."/".get_file_extension($media_file_name).".gif"; $image_info = @getimagesize($file_src); $thumb_width = $image_info[0]*$max; $thumb_height = $image_info[1]*$max; $thumb = "\"".format_text($image_name,"; } else { $file_src = get_file_path($thumb_file_name, "thumb", $cat_id, 0, 1); $image_info = @getimagesize($file_src); $thumb_width = $image_info[0]*$max; $thumb_height = $image_info[1]*$max; $thumb = "\"".$image_name."\""; } } if ($show_link) { if ($open_window) { $thumb = "".$thumb.""; } else { $thumb = "".$thumb.""; } } return $thumb; } // ----------------------------------------------- // --- End Mod "my awaiting images" -------------- //########### Start [Mod] Different Thumbnail sizes ############################ function get_thumbnail_resizer($media_file_name, $thumb_file_name = "", $image_id, $cat_id, $image_name = "", $mode = "", $show_link = 1, $open_window = 0, $new_width = "", $new_height = "", $contest = 0) { global $site_sess, $config, $site_template; $new_width = $new_width ? $new_width : $config['max_thumb_width']; $new_height = $new_height ? $new_height : $config['max_thumb_height']; $orig_file = ($new_width>$config['max_thumb_width'] || $new_height>$config['max_thumb_height']) ? "media" : "thumb"; if (!check_media_type($media_file_name)) { $new_image = "\"\""; } else { if (!get_file_path($thumb_file_name, "thumb", $cat_id, 0, 0)) { $file_src = ICON_PATH."/".get_file_extension($media_file_name).".gif"; $image_info = @getimagesize($file_src); $orig_width = $image_info[0]; $orig_height = $image_info[1]; $new_image = "\"".format_text($image_name,"; } else { $file_src = get_file_path($media_file_name, $orig_file, $cat_id, 0, 1); $orig_file = (check_thumb_type($file_src)) ? $orig_file : "thumb"; $file_src = get_file_path($thumb_file_name, $orig_file, $cat_id, 0, 1); $image_info = @getimagesize($file_src); $orig_width = $image_info[0]; $orig_height = $image_info[1]; if($new_width<$orig_width || $new_height<$orig_height){ $orig_ratio = $orig_width / $orig_height; if ($new_width / $new_height > $orig_ratio){ $new_width = round($new_height * $orig_ratio); } else{ $new_height = round($new_width/$orig_ratio); } } else{ $new_width = $orig_width; $new_height = $orig_height; } $new_image = "\"".format_text($image_name,"; } } if ($show_link) { if ($open_window) { $new_image = "url(ROOT_PATH."details.php?".URL_IMAGE_ID."=".$image_id.((!empty($mode)) ? "&mode=".$mode : ""))."\" onclick=\"opendetailwindow()\" target=\"detailwindow\">".$new_image.""; } else { $new_image = "url(ROOT_PATH."details.php?".URL_IMAGE_ID."=".$image_id.((!empty($mode)) ? "&mode=".$mode : ""))."\">".$new_image.""; } } return $new_image; } //########### End [Mod] Different Thumbnail sizes ############################ function get_thumbnail_code($media_file_name, $thumb_file_name = "", $image_id, $cat_id, $image_name = "", $mode = "", $show_link = 1, $open_window = 0) { global $site_sess, $config; if (!check_media_type($media_file_name)) { $thumb = "\"\""; } else { if (!get_file_path($thumb_file_name, "thumb", $cat_id, 0, 0)) { $file_src = ICON_PATH."/".get_file_extension($media_file_name).".gif"; $image_info = @getimagesize($file_src); $width_height = (!empty($image_info[3])) ? " ".$image_info[3] : ""; // $thumb = "\"".format_text($image_name,"; $thumb = "\"".format_text($image_name,"; } else { $file_src = get_file_path($thumb_file_name, "thumb", $cat_id, 0, 1); if (!$show_link) { $file_src = str_replace("/".$thumb_file_name, "//".$thumb_file_name, $file_src); if (file_exists($file_src_new)) $file_src = $file_src_new; } $image_info = @getimagesize($file_src); $width_height = (!empty($image_info[3])) ? " ".$image_info[3] : ""; // $thumb = "\"".format_text($image_name,"; $thumb = "\"".format_text($image_name,"; } } if ($show_link) { if ($open_window) { $thumb = "url(ROOT_PATH."details.php?".URL_IMAGE_ID."=".$image_id.((!empty($mode)) ? "&mode=".$mode : ""))."\" onclick=\"opendetailwindow()\" target=\"detailwindow\">".$thumb.""; } else { $thumb = "url(ROOT_PATH."details.php?".URL_IMAGE_ID."=".$image_id.((!empty($mode)) ? "&mode=".$mode : ""))."\">".$thumb.""; } } return $thumb; } function get_media_code($media_file_name, $image_id = 0, $cat_id = 0, $image_name = "", $mode = "", $show_link = 0, $detailed_view = 0) { global $site_template, $site_sess, $lang, $mode; if (!get_file_path($media_file_name, "media", $cat_id, 0, 0)) { $media = "\"\""; $site_template->register_vars("iptc_info", ""); $site_template->register_vars("exif_info", ""); } else { $media_src = get_file_path($media_file_name, "media", $cat_id, 0, 1); $file_extension = get_file_extension($media_file_name); $media_icon = "\"".format_text($image_name,"; if ($show_link) { $media_icon = "url(ROOT_PATH."details.php?".URL_IMAGE_ID."=".$image_id.((!empty($mode)) ? "&mode=".$mode : ""))."\">".$media_icon.""; } $width_height = ""; $width = ""; $height = ""; $iptc_info = ""; $exif_info = ""; $lens_info = ""; if (!is_remote($media_src)) { $src = (!file_exists($media_src) && file_exists(preg_replace("/\/{2,}/", "/", get_document_root()."/".$media_src))) ? preg_replace("/\/{2,}/", "/", get_document_root()."/".$media_src) : $media_src; if (in_array(strtolower($file_extension), array('gif','jpg','jpeg','png','swf')) && $image_info = @getimagesize($src, $info)) { $width_height = " ".$image_info[3]; $width = $image_info[0]; $height = $image_info[1]; if ($detailed_view && isset($info['APP13'])) { $iptc_array = get_iptc_info($info['APP13']); $bgcounter = 0; foreach ($iptc_array as $key => $val) { $row_bg_number = ($bgcounter++ % 2 == 0) ? 1 : 2; $site_template->register_vars(array( "iptc_value" => format_text($val), "iptc_name" => $lang['iptc_'.$key], "row_bg_number" => $row_bg_number )); $iptc_info .= $site_template->parse_template("iptc_bit"); } } if ($detailed_view && $image_info[2] == 2 && function_exists('exif_read_data') && $exif_data = @exif_read_data($src, 'EXIF')) { $lens_info = get_lens_info($src); $exif_array = get_exif_info($exif_data); $bgcounter = 0; foreach ($exif_array as $key => $val) { // GPS EXIF Modifikatio START if (($key != "GPSLongitudeRef") && ($key != "GPSLatitudeRef")) { if ($key == "GPSLongitude") { $GPSLongtude = substr (strrchr($val, "("), 1); $GPSLongtude = substr ($GPSLongtude,0, strlen($GPSLongtude)-1); } if ($key == "GPSLatitude") { $GPSLatitude = substr (strrchr($val, "("), 1); $GPSLatitude = substr ($GPSLatitude,0, strlen($GPSLatitude)-1); } // GPS EXIF Modifikatio ENDE $row_bg_number = ($bgcounter++ % 2 == 0) ? 1 : 2; $site_template->register_vars(array( "exif_value" => format_text($val), "exif_name" => $lang['exif_'.$key], "row_bg_number" => $row_bg_number )); $exif_info .= $site_template->parse_template("exif_bit"); // GPS EXIF Modifikatio START } } if (($GPSLongtude != "") && ($GPSLatitude != "")) { $row_bg_number = ($bgcounter++ % 2 == 0) ? 1 : 2; $site_template->register_vars(array( "exif_value" => $Karte, "exif_name" => $Beschreibung, "row_bg_number" => $row_bg_number )); $exif_info .= $site_template->parse_template("exif_bit"); } // GPS EXIF Modifikatio ENDE } } } $site_template->register_vars(array( // $row_bg_number = ($bgcounter++ % 2 == 0) ? 1 : 2; // $site_template->register_vars(array( // "exif_value" => format_text($val), // "exif_name" => $lang['exif_'.$key], // "row_bg_number" => $row_bg_number // )); // $exif_info .= $site_template->parse_template("exif_bit"); // } // } // } // } // $site_template->register_vars(array( "media_src" => $media_src, "big_image_id" => $image_id, "media_icon" => $media_icon, "image_name" => format_text($image_name, 2), "width_height" => $width_height, "width" => $width, "height" => $height, "iptc_info" => $iptc_info, "exif_info" => $exif_info, "lens_info" => $lens_info )); $media = $site_template->parse_template("media/".$file_extension); } return $media; } function get_random_image_cache() { global $site_db, $cat_cache, $total_images; $random_image_cache = array(); $cat_id_sql = get_auth_cat_sql("auth_viewcat", "NOTIN"); if (SHOW_RANDOM_CAT_IMAGE) { $sql = "SELECT DISTINCT i.image_id, i.cat_id, i.user_id, i.image_name, i.image_description, i.image_keywords, i.image_date, i.image_active, i.image_media_file, i.image_thumb_file, i.image_download_url, i.image_allow_comments, i.image_comments, i.image_downloads, i.image_votes, i.image_rating, i.image_hits, c.cat_name".get_user_table_field(", u.", "user_name")." FROM (".IMAGES_TABLE." i, ".CATEGORIES_TABLE." c) LEFT JOIN ".USERS_TABLE." u ON (".get_user_table_field("u.", "user_id")." = i.user_id) WHERE i.image_active = 1 AND i.cat_id NOT IN ($cat_id_sql) AND c.cat_id = i.cat_id ORDER BY RAND()"; $result = $site_db->query($sql); while ($row = $site_db->fetch_array($result)) { $random_image_cache[$row['cat_id']] = $row; } } else { if (empty($total_images)) { $sql = "SELECT COUNT(*) as total_images FROM ".IMAGES_TABLE." WHERE image_active = 1 AND cat_id NOT IN ($cat_id_sql)"; $row = $site_db->query_firstrow($sql); $total_images = $row['total_images']; } if (empty($total_images)) { return $random_image_cache; } mt_srand((double)microtime() * 1000000); $number = ($total_images > 1) ? mt_rand(0, $total_images - 1) : 0; $sql = "SELECT i.image_id, i.cat_id, i.user_id, i.image_name, i.image_description, i.image_keywords, i.image_date, i.image_active, i.image_media_file, i.image_thumb_file, i.image_download_url, i.image_allow_comments, i.image_comments, i.image_downloads, i.image_votes, i.image_rating, i.image_hits, c.cat_name".get_user_table_field(", u.", "user_name")." FROM (".IMAGES_TABLE." i, ".CATEGORIES_TABLE." c) LEFT JOIN ".USERS_TABLE." u ON (".get_user_table_field("u.", "user_id")." = i.user_id) WHERE i.image_active = 1 AND i.cat_id NOT IN ($cat_id_sql) AND c.cat_id = i.cat_id LIMIT $number, 1"; $random_image_cache[0] = $site_db->query_firstrow($sql); } return $random_image_cache; } function get_random_image($cat_id = 0, $show_link = 1, $return_file = 0) { global $site_template, $random_image_cache; if (!isset($random_image_cache)) { $random_image_cache = get_random_image_cache(); } if ($cat_id && SHOW_RANDOM_CAT_IMAGE) { $template = 'random_cat_image'; $category_id = $cat_id; } else { $template = 'random_image'; if (SHOW_RANDOM_CAT_IMAGE) { srand((float)microtime() * 1000000); $category_id = array_rand($random_image_cache); } else { $category_id = 0; } } if (!empty($random_image_cache[$category_id])) { if (!$return_file) { show_image($random_image_cache[$category_id], "", $show_link); $random_image = $site_template->parse_template($template); return $random_image; } else { return get_file_path($random_image_cache[$category_id]['image_thumb_file'], "thumb", $category_id, 0, 1); } } } 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, $user_info; $sql = "SELECT cat_id, user_id, image_votes, image_rating FROM ".IMAGES_TABLE." WHERE image_id = $image_id"; $image_row = $site_db->query_firstrow($sql); if ($image_row['user_id'] == $user_info['user_id']) { return 2; } 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); if ($user_info['user_id'] != GUEST) { $sql = "INSERT INTO ".VOTED_TABLE." (user_id, image_id, vote) VALUES (".$user_info['user_id'].", ".$image_id.", ".$rating.")"; $site_db->query($sql); }$sql = "UPDATE ".IMAGES_TABLE." SET image_votes = ($old_votes + 1), image_rating = '$new_rating' WHERE image_id = $image_id"; $site_db->query($sql); } return 1; } 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( "/\[schild=(.*?) (.*?) (.*?)\](.*?)\[\/schild\]/si", "/\[b\](.*?)\[\/b\]/si", "/\[i\](.*?)\[\/i\]/si", "/\[u\](.*?)\[\/u\]/si", "/\[email\](.*?)\[\/email\]/si", "/\[email=(.*?)\](.*?)\[\/email\]/si", "/\[code\](.*?)\[\/code\]/si", "/\[quote\](.*?)/si", "/\[\/quote\]/si", "/\[url=(.*?)\](.*?)\[\/url\]/si", "/\[url\](.*?)\[\/url\]/si", "/\[sub\](.*?)\[\/sub\]/si", "/\[sup\](.*?)\[\/sup\]/si", "/\[color=(.*?)\](.*?)\[\/color\]/si", "/\[size=(.*?)\](.*?)\[\/size\]/si", "/\[tt\](.*?)\[\/tt\]/si", "/\[s\](.*?)\[\/s\]/si", "/\[move\](.*?)\[\/move\]/si", // "/\[align=(.*?)\](.*?)\[\/align\]/si", "/\[align=(.*?)\](.*?)\[\/align\](.
)?/si", "/\[font=(.*?)\](.*?)\[\/font\]/si", "/\[shadow=(.*?)\,(.*?)\,(.*?)\](.*?)\[\/shadow\]/si", "/\[glow=(.*?)\,(.*?)\,(.*?)\](.*?)\[\/glow\]/si", "/\[quote=(.*?)\](.*?)/si", "/\[\/quote\]/si" ); $replace_array = array( "", "\\1", "\\1", "\\1", "\\1", "\\2", "
code:
\\1

", "
quote:
\\1", "
", "\\2", "\\1", "\\1", "\\1", "\\2", "\\2", "\\1", "\\1", "\\1", "
\\2
", "\\2", "\\4", "\\4", "

\\1 schreibt:
\\2", "
" ); $text = preg_replace($search_array, $replace_array, $text); if (!$bbcode_img) { // $text = preg_replace("/(\[)(img)(])(\r\n)*([^\"]*)(\[\/img\])/siU", "\\5", $text); $text = preg_replace("/\[img\](.*?)\[\/img\]/si", "\\1", $text); $text = preg_replace("/\[img=(.*?)\,(.*?)\](.*?)\[\/img\]/si","\\3",$text); $text = preg_replace("/\[img height=(.*?)\ width=(.*?)\](.*?)\[\/img\]/si","\\3",$text); $text = preg_replace("/\[img width=(.*?)\ height=(.*?)\](.*?)\[\/img\]/si","\\3",$text); $text = preg_replace("/\[flash=(.*?)\,(.*?)\](.*?)\[\/flash\]/si","\\3",$text); }else{ // $text = preg_replace("/(\[)(img)(])(\r\n)*([^\"]*)(\[\/img\])/siU", "", $text); $text = preg_replace("/\[img\](.*?)\[\/img\]/si", "", $text); $text = preg_replace("/\[img=(.*?)\,(.*?)\](.*?)\[\/img\]/si","",$text); $text = preg_replace("/\[img height=(.*?)\ width=(.*?)\](.*?)\[\/img\]/si","",$text); $text = preg_replace("/\[img width=(.*?)\ height=(.*?)\](.*?)\[\/img\]/si","",$text); $text = preg_replace("/\[flash=(.*?)\,(.*?)\](.*?)\[\/flash\]/si","",$text); } $text = replace_badwords($text); } $text = str_replace("\\'", "'", $text); // Smilie Mod $text = show_smilies($text); // End Smilie Mod 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)); } } // Smilie Mod function show_smilies($text) { $search_smilie = array(":)",":-)",":smile:", ":D",":-D",":grin:", ":(",":-(",":sad:", "8o","8-o",":shock",":eek:", ":?:", ":?",":-?",":???:", "8)","8-)",":cool:", ":x",":-x",":mad:", ":p",":P",":-p",":-P",":razz:", ":*",":-*",":oops:", ":'(",":'-(",":cry:", ">:(",">:-(",":evil:", ":roll:", ";)",";-)",":wink:", ":|",":-|",":neutral:", ":o",":-o", ">:)",">:-)",":twisted:", ":lol:","LOL", ":!:", ":idea:", ":arrow:", ":mrgreen:", ":guck:", ":daumen:", ":kratz:"); $replace_smilie = array("smile","smile","smile", "biggrin","biggrin","biggrin", "sad","sad","sad", "eek","eek","eek","eek", "question", "confused","confused","confused", "cool","cool","cool", "mad","mad","mad", "razz","razz","razz","razz","razz", "redface","redface","redface", "cry","cry","cry", "evil", "evil", "evil", "rolleyes", "wink","wink","wink", "neutral","neutral","neutral", "surprised","surprised", "twisted","twisted","twisted", "lol","lol", "exclaim", "idea", "arrow", "mrgreen", "guck", "daumen", "kratz"); for($smile=0;$smile",$text); } return $text; } // End Smilie Mod 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)) { //activity $sql = "SELECT cat_id,image_media_file,image_name, image_id, user_id FROM ".IMAGES_TABLE." WHERE image_active = 1 AND image_id = $id"; $result = $site_db->query_firstrow($sql); $cat = $result['cat_id']; $media = $result['image_media_file']; $name = $result['image_name']; $image_id = $result['image_id']; $user_id = $result['user_id']; $sql = "INSERT INTO " . NOTIFY_TABLE . " (id, from_id, to_id, from_username, to_username, what_pic, text1, text2, text3, content, content_link, date) VALUES(NULL, '".$user_info['user_id']."', '" . $user_id . "', '".$user_info['user_name']."', '', '".$cat."' '/' '".$media."', 'fügte', '".$name."', 'als Favorit ins Album', '', 'details.php?image_id=' '".$image_id."', '" . time() . "')"; $site_db->query($sql); $sql = "UPDATE ".USERS_TABLE." SET user_notify=user_notify+1 WHERE user_id = ".$user_id; $site_db->query($sql); //activity $lightbox_ids .= " ".$id; } $user_info['lightbox_image_ids'] = trim($lightbox_ids); $user_info['lightbox_lastaction'] = time(); /* MOD MULTI-LIGHTBOXES START REPLACE */ $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']." AND id = ".$user_info['user_lightbox']; if ($site_db->query($sql)) { $user_info['lightboxes'][$user_info['user_lightbox']]['count']++; $user_info['lightboxes_list'][$user_info['user_lightbox']] = lightbox_trim($user_info['lightboxes'][$user_info['user_lightbox']]['name'])." (".$user_info['lightboxes'][$user_info['user_lightbox']]['count'].")"; return true; } return false; /* MOD MULTI-LIGHTBOXES END REPLACE */ } 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(); /* MOD MULTI-LIGHTBOXES START REPLACE */ $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']." AND id = ".$user_info['user_lightbox']; if ($site_db->query($sql)) { $user_info['lightboxes'][$user_info['user_lightbox']]['count']--; $user_info['lightboxes_list'][$user_info['user_lightbox']] = lightbox_trim($user_info['lightboxes'][$user_info['user_lightbox']]['name'])." (".$user_info['lightboxes'][$user_info['user_lightbox']]['count'].")"; return true; } return false; /* MOD MULTI-LIGHTBOXES END REPLACE */ } function clear_lightbox() { global $user_info, $site_db; $current_time = time(); /* MOD MULTI-LIGHTBOXES START REPLACE */ $sql = "UPDATE ".LIGHTBOXES_TABLE." SET lightbox_lastaction = ".$current_time.", lightbox_image_ids = '' WHERE user_id = ".$user_info['user_id']." AND id = ".$user_info['user_lightbox']; if ($site_db->query($sql)) { $user_info['lightboxes'][$user_info['user_lightbox']]['count'] = 0; $user_info['lightboxes_list'][$user_info['user_lightbox']] = lightbox_trim($user_info['lightboxes'][$user_info['user_lightbox']]['name'])." (0)"; /* MOD MULTI-LIGHTBOXES END REPLACE */ $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); } //---------- [MOD] BUDDY V2 beta ---------- //---------- 2007 by eMagix ---------- //---------- 2010 by Sumale.nin ---------- //---------- Start Code ---------- function add_to_buddy($id,$msg) { global $user_info, $site_db; $id = intval($id); if (!$id) { return false; } $user_info['buddy_id'] = $id; $user_info['buddy_request_msg'] = $msg; if (check_buddy($id) != -1) return 1; $sql= "INSERT INTO ".USERS_FRIENDSHIP_TABLE." ( `user_id_primary` , `user_id_secondary` , `friendship_request_date` , `friendship_request_message` ) VALUES ( ".$user_info['user_id'].", ".$user_info['buddy_id'].", CURRENT_TIMESTAMP, '".$user_info['buddy_request_msg']."' );"; return ($site_db->query($sql)) ? 1 : 0; } function accept_buddy_request($id) { global $user_info, $site_db; if (!$id) { return false; } $user_info['buddy_id'] = $id; //Accept 1 , Reject -1 $sql = "UPDATE ".USERS_FRIENDSHIP_TABLE." SET friendship_status = 1, friendship_accept_date = CURRENT_TIMESTAMP WHERE friendship_id = ".$user_info['buddy_id']; return ($site_db->query($sql)) ? 1 : 0; } function reject_buddy_request($id) { global $user_info, $site_db; if (!$id) { return false; } $msg = $lang['buddy_reject_message']; $user_info['buddy_reject_msg'] = $msg; $user_info['buddy_id'] = $id; //Accept 1 , Reject -1 $sql = "UPDATE ".USERS_FRIENDSHIP_TABLE." SET friendship_status = -1, friendship_response_message = '".addslashes($user_info['buddy_reject_msg'])."' WHERE friendship_id = ".$user_info['buddy_id']; $sql = "DELETE FROM ".USERS_FRIENDSHIP_TABLE." WHERE friendship_id = ".$user_info['buddy_id']; return ($site_db->query($sql)) ? 1 : 0; } function remove_from_buddy($id) { global $user_info, $site_db; if (!$id) { return false; } $user_info['buddy_id'] = $id; $sql = "DELETE FROM ".USERS_FRIENDSHIP_TABLE." WHERE friendship_id = ".$user_info['buddy_id']; return ($site_db->query($sql)) ? 1 : 0; } function clear_buddy() { global $user_info, $site_db; $sql = "DELETE FROM ".USERS_FRIENDSHIP_TABLE." WHERE user_id_primary = ".$user_info['user_id']." OR user_id_secondary =".$user_info['user_id']; return ($site_db->query($sql)) ? 1 : 0; } function check_buddy($id) { global $user_info, $site_db; $user_info['buddy_id'] = $id; $return_value = ""; $sql = "SELECT friendship_status FROM ".USERS_FRIENDSHIP_TABLE." WHERE (user_id_primary = ".$user_info['user_id']." AND user_id_secondary =".$user_info['buddy_id'].") OR (user_id_primary = ".$user_info['buddy_id']." AND user_id_secondary =".$user_info['user_id'].")"; $result = $site_db->query_firstrow($sql); if (!$result) { $return_value = -1; } else { $return_value = $result['friendship_status']; } return $return_value; } function check_buddy_request() { global $user_info, $site_db; $sql = "SELECT COUNT(*) AS total_requests FROM ".USERS_FRIENDSHIP_TABLE." WHERE friendship_status = 0 AND user_id_secondary = ".$user_info['user_id']; $result = $site_db->query_firstrow($sql); $user_total_friends = $result['total_requests']; return $user_total_friends; } //----------- END CODE ----------------- 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 ($cat_id == 310) { $cattable_width = ceil((intval($config['cat_table_width'])) / $config['image_cells2']); 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']; } } } $cat_image = ""; if ($cat_cache[$category_id]['cat_image']) { $sql = "SELECT image_id, image_media_file, image_thumb_file, cat_id FROM ".IMAGES_TABLE." WHERE image_id = ".$cat_cache[$category_id]['cat_image']; if ($image_row = $site_db->query_firstrow($sql)) { if (!get_file_path($image_row['image_thumb_file'], "thumb", $image_row['cat_id'], 0, 0)) { $cat_image = ICON_PATH."/".get_file_extension($image_row['image_media_file']).".gif"; } else { $cat_image = get_file_path($image_row['image_thumb_file'], "thumb", $image_row['cat_id'], 0, 1); } } } $site_template->register_vars("cat_image", $cat_image); 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" => 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"); $cat_tpl = get_cat_template("category_bit", $category_id); $categories .= $site_template->parse_template($cat_tpl); $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", )); 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 check_birthday($birthday_day = "", $birthday_month = "", $birthday_year = "", $valid = 0) { $error = 0; if($birthday_day && $birthday_month && $birthday_year) { switch(strlen($birthday_year)) { case 2: $birthday_year = "19$birthday_year"; break; case 4: break; default: $birthday_year = "0000"; if ($valid) $error = 1; break; } $birthday = "$birthday_year-$birthday_month-$birthday_day"; } else { $birthday = "0000-00-00"; $error = 1; } if ($valid == 1 && ($error || (!ereg("([0-9]{4})-([0-9]{2})-([0-9]{2})", $birthday)))) return false; else return $birthday; } function calc_age ($birthday = "") { $user_birthday = explode("-",$birthday); if ($user_birthday[0]!= "0000" && $user_birthday) { $today = getdate (time()); $age = ($today['year'] - $user_birthday[0]); if ($age > 0 ) { $birthday_thisyear_var = mktime(0,0,0,$user_birthday[1],$user_birthday[2],$today['year']); $birthday_thisyear = getdate ($birthday_thisyear_var); if ($birthday_thisyear['yday']>$today['yday']) $age--; return $age; } else return false; } } function calc_countdown ($birthday = "") { $user_birthday = explode("-",$birthday); if ($user_birthday[1] != "00" && $user_birthday[2] != "00") { $today = getdate (time()); $birthday_thisyear_var = mktime(0,0,0,$user_birthday[1],$user_birthday[2],$today['year']); $birthday_thisyear = getdate ($birthday_thisyear_var); if ($birthday_thisyear['yday']<=$today['yday']) $birthday_thisyear_var = mktime(0,0,0,$user_birthday[1],$user_birthday[2],$today['year']+1); $difference = $birthday_thisyear_var - time(); if ($difference < 0) $difference = 0; $dleft = floor($difference/60/60/24); $hleft = floor(($difference - $dleft*60*60*24)/60/60); $mleft = floor(($difference - $dleft*60*60*24 - $hleft*60*60)/60); $return = array( 'days'=>$dleft, 'hours'=>$hleft, 'minutes'=>$mleft, ); return $return; } else return false; } /* MOD BAN START INSERT */ function check_ban() { global $user_info, $site_sess, $config, $lang, $site_db, $HTTP_GET_VARS; $types = array("ip", "hostname", "name", "user_id", "email"); if (!$config['ban_update']) { return false; } if ($user_info['user_level'] == ADMIN) { if (!isset($HTTP_GET_VARS['bantest'])) return false; $return = true; foreach ($types as $key) { if (isset($HTTP_GET_VARS[$key]) && $$key = $HTTP_GET_VARS[$key]) $return = false; else $$key = ""; } if ($return) return false; $force = true; } else { $ip = $site_sess->session_info['session_ip']; $email = $user_info['user_email']; $user_id = $user_info['user_id']; $name = $user_info['user_name']; $hostname = ""; $force = false; } $ban = false; $ban_checked = $site_sess->get_session_var("ban_checked"); $ban_userid = $site_sess->get_session_var("ban_userid"); $ban_banned = $site_sess->get_session_var("ban_banned"); if (get_magic_quotes_gpc() != 0) { $ban_banned = stripslashes($ban_banned); } // $ban_banned = stripslashes($ban_banned); //uncomment this line if magic_quotes_gpc is turned on on your server $ban_banned = ($ban_banned) ? unserialize($ban_banned) : ""; if ($force || (!$ban_checked || !$ban_userid || ($ban_userid && $ban_userid != $user_info['user_id']) || ($ban_checked && $ban_checked < $config['ban_update']) || ($ban_banned && $ban_banned['expire'] < time()))) { $query = array(); if (preg_match('/^(\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})$/', $ip, $ip_chop) == 1) { $query[] = "(type = ".BAN_IP." AND ($ip_chop[1] BETWEEN ip1_start AND ip1_end) AND ($ip_chop[2] BETWEEN ip2_start AND ip2_end) AND ($ip_chop[3] BETWEEN ip3_start AND ip3_end) AND ($ip_chop[4] BETWEEN ip4_start AND ip4_end))"; if ($config['look_hostname'] && !$hostname) { $hostname = @gethostbyaddr($ip); } } if ($hostname) { $query[] = "(type = ".BAN_HOSTNAME." AND ('$hostname' LIKE hostname))"; } if ($email) { $query[] = "(type = ".BAN_EMAIL." AND ('".addslashes($email)."' LIKE email))"; } if ($user_id && $user_id > GUEST) { $query[] = "(type = ".BAN_USERID." AND user_id = ".$user_id.")"; } if ($name) { $query[] = "(type = ".BAN_NAME." AND ('".addslashes($name)."' LIKE name))"; } if (!empty($query)) { $sql = "SELECT id, type, message, date, expire FROM ".BAN_TABLE." WHERE (".implode(' OR ', $query).")"; if ($result = $site_db->query($sql)) { while ($row = $site_db->fetch_array($result)) { $site_sess->set_session_var("ban_banned", addslashes(serialize($row))); if ($row['date'] <= time() && (!$row['expire'] || $row['expire'] > time())) { $ban = $row; break; } } } else { $site_sess->set_session_var("ban_banned", ""); } } $site_sess->set_session_var("ban_checked", time()); $site_sess->set_session_var("ban_userid", $user_info['user_id']); } elseif ($ban_banned && $ban_banned['date'] <= time() && (!$ban_banned['expire'] || $ban_banned['expire'] > time())) { $ban = $ban_banned; } return $ban; } /* MOD BAN END INSERT */ function get_dropdown_options($name, $options = array(), $value = "", $multi_dim = 1, $number = 0, $auto = 0, $keypress = 0, $extra = "", $class = "", $i_start = 0, $i_step = 1, $i_stop = 1) { $keypress = ($keypress) ? " onkeypress=\"if(window.event.keyCode==13)this.form.submit();\"" : ""; $auto = ($auto) ? " onchange=\"this.form.submit();\"" : ""; $dropdown = "\n"; return $dropdown; } function get_db_fields_dropdown($key, $val, $value) { return get_dropdown_options($key, $val[3], $value, $val[4], $val[5], $val[7], 1, "", "select", $val[6]); } function get_wiki($image_wiki) { global $user_info, $site_db, $session_info, $config; ini_set('user_agent', '(Windows; U; Windows NT 6.1; de; rv:1.9.2) Gecko/20100115 Firefox/3.6'); // $image_wiki = preg_replace('/\\W/', '',$image_wiki); $zeichen = array('#', '?', '§', '$', '%', '&', '/', '(', ')', '=', '^', '°', '*', '@'); $image_wiki = str_replace($zeichen,"",$image_wiki); if(!$image_wiki) return false; //Gesamten Text aus der Wiki-API nehmen $domain = "de.wikipedia.org"; $get = "/w/api.php?format=xml&action=parse&page=".$image_wiki; $fp = fsockopen($domain, 80, $errno, $errstr, 30); if (!$fp) { echo "$errstr ($errno)
\n"; } else { fputs($fp, "GET {$get} HTTP/1.0\r\nHost: {$domain}\r\n\r\n"); $text = ''; while (!feof($fp)) { $text .= fgets($fp, 128); } fclose($fp); } $text = html_entity_decode($text, ENT_QUOTES); if(!$text) return false; //Zusammenfassung suchen $reg_exp = '/

(.*?)<\/p>/s'; preg_match_all($reg_exp, $text, $match); $summary = $match[0][0]; $summary .= $match[0][1]; $summary .= $match[0][2]; $summary .= $match[0][3]; $summary .= $match[0][4]; $summary = utf8_decode($summary); $summary = str_replace('?','"',$summary); $image_wiki = str_replace(' ','_', $image_wiki); $summary .= "Quelle:Wikipedia"; //wenn Artikel nicht vorhanden if($summary == "

Artikel verschwunden?

") return false; //Links auf interne Seite ändern $summary = str_replace('href="#',"href=\"http://de.wikipedia.org/wiki/$image_wiki#", $summary); $summary = str_replace('href="/wiki/', 'href="http://de.wikipedia.org/wiki/', $summary); return $summary; } /* MOD UPLOAD CATEGORIES DROPDOWN BEGIN INSERT */ function get_category_dropdown_upload_bits($cat_id = 0, $cid = 0, $depth = 1) { global $site_db, $drop_down_cat_cache, $cat_cache, $config; 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)) { if (check_permission("auth_upload", $category_id)) { $disable = 0; } else { $disable = 1; } $category_list .= "\n"; $category_list .= get_category_dropdown_upload_bits($cat_id, $category_id, $depth + 1); } } unset($drop_down_cat_cache[$cid]); return $category_list; } function get_category_dropdown_upload($cat_id = 0) { global $lang, $drop_down_cat_cache, $cat_parent_cache; $category = "\n\n"; return $category; } /* MOD UPLOAD CATEGORIES DROPDOWN END INSERT */ //-------------------------------------------[ [Mod] Calendar with nav and search ] /*************************************************************************** calendrier.php - A calendar ------------------- begin : June 2002 Version : 2.1 (Jan 04) copyleft : (C) 2002-2003 PHPtools4U.com - Mathieu LESNIAK email : support@phptools4u.com website : http://www.phptools4u.com/scripts/calendrier/ ***************************************************************************/ function get_calendar($date = '', $class_table, $class_nav, $class_week_days, $class_noday, $class_eachday, $class_today,$class_linkday) { global $site_db; global $link_on_day, $PHP_SELF, $params; global $HTTP_POST_VARS, $HTTP_GET_VARS; $calendar_txt['french']['monthes'] = array('', 'Janvier', 'Février', 'Mars', 'Avril', 'Mai', 'Juin', 'Juillet', 'Août', 'Septembre', 'Octobre', 'Novembre', 'Décembre'); $calendar_txt['french']['days'] = array('Lundi', 'Mardi', 'Mercredi','Jeudi', 'Vendredi', 'Samedi', 'Dimanche'); $calendar_txt['french']['first_day'] = 0; $calendar_txt['french']['misc'] = array('Mois précédent', 'Mois suivant','Jour précédent', 'Jour suivant', 'Année précédente', 'Année suivante'); ### English version $calendar_txt['english']['monthes'] = array('', 'January', 'February', 'March', 'April', 'May', 'June', 'July', 'August', 'September', 'October','November', 'December'); $calendar_txt['english']['days'] = array('Monday', 'Tuesday', 'Wednesday','Thursday', 'Friday', 'Saturday','Sunday'); $calendar_txt['english']['first_day'] = -1; $calendar_txt['english']['misc'] = array('Previous month', 'Next month', 'Previous day', 'Next day', 'Next year', 'Previous year'); ### Spanish version $calendar_txt['spanish']['monthes'] = array('', 'Enero', 'Febrero', 'Marzo', 'Abril', 'Mayo', 'Junio', 'Julio', 'Agosto', 'Septiembre', 'Octubre', 'Noviembre', 'Diciembre'); $calendar_txt['spanish']['days'] = array('Lunes', 'Martes', 'Miércoles', 'Jueves', 'Viernes', 'Sábado', 'Domingo'); $calendar_txt['spanish']['first_day'] = 0; $calendar_txt['spanish']['misc'] = array('Mes anterior', 'Mes próximo', 'día anterior', 'día siguiente', 'Año anterior', 'Año siguiente'); ### German version $calendar_txt['german']['monthes'] = array('', 'Januar', 'Februar', 'März', 'April', 'Mai', 'Juni', 'Juli', 'August', 'September', 'Oktober','November', 'Dezember'); $calendar_txt['german']['days'] = array('Montag', 'Dienstag', 'Mittwoch', 'Donnerstag','Freitag','Samstag', 'Sonntag'); $calendar_txt['german']['first_day'] = 0; $calendar_txt['german']['misc'] = array('Vorhergehender Monat', 'Folgender Monat', 'Vorabend', 'Am nächsten Tag', 'Vorjahr', 'Folgendes Jahr'); ### Default Params $param_d['calendar_columns'] = 5; // Nb of columns $param_d['show_day'] = 1; // Show the day bar $param_d['show_month'] = 1; // Show the month bar $param_d['nav_link'] = 1; // Add a nav bar below $param_d['link_after_date'] = 0; // Enable link on days after the current day $param_d['link_before_date'] = 1; // Enable link on days before the current day $param_d['link_on_day'] = 'search.php?date=%%dd%%'; // Link to put on each day $param_d['use_img'] = 1; // Use gif for nav bar on the bottom ### New params V2 $param_d['lang'] = 'german'; // change to your language : french / english / spanish / german $param_d['day_mode'] = 0; // Set to 1 : Enable day view with hours (nothing to see) $param_d['time_step'] = 60; $param_d['time_start'] = '0:00'; $param_d['time_stop'] = '24:00'; $param_d['highlight'] = array(); // Can be 'highlight' or 'text' $param_d['highlight_type'] = 'highlight'; $param_d['cell_width'] = 20; $param_d['cell_height'] = 20; $param_d['short_day_name'] = 1; $param_d['link_on_hour'] = $PHP_SELF.'?hour=%%hh%%'; ### /Params ### Getting all params while (list($key, $val) = each($param_d)) { if (isset($params[$key])) { $param[$key] = $params[$key]; } else { $param[$key] = $param_d[$key]; } } $monthes_name = $calendar_txt[$param['lang']]['monthes']; $param['calendar_columns'] = ($param['show_day']) ? 7 : $param['calendar_columns']; $date = priv_reg_glob_calendar('date'); if ($date == '') { $timestamp = time(); } else { $month = substr($date, 4 ,2); $day = substr($date, 6, 2); $year = substr($date, 0 ,4); $timestamp = mktime(0, 0, 0, $month, $day, $year); } $current_day = date("d", $timestamp); $current_month = date('n', $timestamp); $current_month_2 = date('m', $timestamp); $current_year = date('Y', $timestamp); $first_decalage = date("w", mktime(0, 0, 0, $current_month, 1, $current_year)); ### Sunday is the _LAST_ day $first_decalage = ( $first_decalage == 0 ) ? 7 : $first_decalage; $current_day_index = date('w', $timestamp) + $calendar_txt[$param['lang']]['first_day'] - 1; $current_day_index = ($current_day_index == -1) ? 7 : $current_day_index; $current_day_name = $calendar_txt[$param['lang']]['days'][$current_day_index]; $current_month_name = $monthes_name[$current_month]; $nb_days_month = date("t", $timestamp); $current_timestamp = mktime(23,59,59,date("m"), date("d"), date("Y")); ### CSS $output = ''."\n"; $output .= ''."\n"; ### Displaying the current month/year if ($param['show_month'] == 1) { $output .= ''."\n"; $output .= ' '."\n"; $output .= ''."\n"; ### select all images for current month $date_start = mktime(0,0,0,$current_month_2,1,$current_year); $date_end = mktime(23,59,59,$current_month_2,$nb_days_month,$current_year); $user_access = get_permission(); $sql = "SELECT image_date, cat_id FROM ".IMAGES_TABLE." WHERE image_active = 1 AND image_date >= ".$date_start." AND image_date <= ".$date_end; $result = $site_db->query($sql); $date_img_month = array(); while ($row = $site_db->fetch_array($result)) { if (check_permission("auth_viewcat", $row['cat_id'])) { // check permissions on cat_id $new_date = date("Ymd",$row['image_date']); // convert the date $date_img_month[] = $new_date; // put the date in the array if permissions are OK } } // $site_db->free_result(); } ### Building the table row with the days if ($param['show_day'] == 1 && $param['day_mode'] == 0) { $output .= ''."\n"; $first_day = $calendar_txt[$param['lang']]['first_day']; for ($i = $first_day; $i < 7 + $first_day; $i++) { $index = ( $i >= 7) ? (7 + $i): $i; $index = ($i < 0) ? (7 + $i) : $i; $day_name = ( $param['short_day_name'] == 1 ) ? substr($calendar_txt[$param['lang']]['days'][$index], 0, 1) : $calendar_txt[$param['lang']]['days'][$index]; $output .= ' '."\n"; } $output .= ''."\n"; $first_decalage = $first_decalage - $calendar_txt[$param['lang']]['first_day']; $first_decalage = ( $first_decalage > 7 ) ? $first_decalage - 7 : $first_decalage; } else { $first_decalage = 0; } $output .= ''."\n"; $int_counter = 0; if ( $param['day_mode'] == 1 ) { list($hour_start, $min_start) = explode(':', $param['time_start']); list($hour_end, $min_end) = explode(':', $param['time_stop']); $ts_start = ( $hour_start * 60 ) + $min_start; $ts_end = ( $hour_end * 60 ) + $min_end; $nb_steps = ceil( ($ts_end - $ts_start) / $param['time_step'] ); for ( $i = 0; $i <= $nb_steps; $i++ ) { $current_ts = ($ts_start) + $i * $param['time_step']; $current_hour = floor($current_ts / 60); $current_min = $current_ts % 60; $current_hour = (strlen($current_hour) < 2) ? '0'.$current_hour : $current_hour; $current_min = (strlen($current_min) < 2) ? '0'.$current_min : $current_min; $highlight_current = ( isset($param['highlight'][date('Ymd', $timestamp).$current_hour.$current_min]) ); $css_2_use = ( $highlight_current ) ? 'HL' : 'Days'; $txt_2_use = ( $highlight_current && $param['highlight_type'] == 'text') ? $param['highlight'][date('Ymd', $timestamp).$current_hour.$current_min] : ''; $output .= ''."\n"; if ( $param['link_on_hour'] != '') { $output .= ' '."\n"; } else { $output .= ' '."\n"; } $output .= ' '."\n"; $output .= ''."\n"; } } else { # Filling with empty cells at the begining for ($i = 1; $i < $first_decalage; $i++) { $output .= ''."\n"; $int_counter++; } ### Building the table for ($i = 1; $i <= $nb_days_month; $i++) { ### Do we highlight the current day ? $i_2 = ($i < 10) ? '0'.$i : $i; $highlight_current = ( isset($param['highlight'][date('Ym', $timestamp).$i_2]) ); ### Row start if ( ($i + $first_decalage) % $param['calendar_columns'] == 2 && $i != 1) { $output .= ''."\n"; $int_counter = 0; } $css_2_use = ( $highlight_current ) ? 'HL' : 'Days'; $txt_2_use = ( $highlight_current && $param['highlight_type'] == 'text') ? '
'.$param['highlight'][date('Ym', $timestamp).$i_2] : ''; $current_date = $current_year.$current_month_2.$i_2 ; if ($i == $current_day) { if (in_array($current_date, $date_img_month)) { // $output .= ''."\n"; } else { $output .= ''."\n"; } } elseif ($param['link_on_day'] != '') { $loop_timestamp = mktime(0,0,0, $current_month, $i, $current_year); if (( ($param['link_after_date'] == 0) && ($current_timestamp < $loop_timestamp)) || (($param['link_before_date'] == 0) && ($current_timestamp >= $loop_timestamp)) ){ $output .= ''."\n"; } else { if (in_array($current_date, $date_img_month)) { $output .= ''."\n"; } else { $output .= ''."\n"; } } } else { $output .= ''."\n"; } $int_counter++; ### Row end if ( ($i + $first_decalage) % ($param['calendar_columns'] ) == 1 ) { $output .= ''."\n"; } } $cell_missing = $param['calendar_columns'] - $int_counter; for ($i = 0; $i < $cell_missing; $i++) { $output .= ''."\n"; } $output .= ''."\n"; } ### Display the nav links on the bottom of the table if ($param['nav_link'] == 1) { $previous_day = date("Ymd", mktime( 12, 0, 0, $current_month, $current_day - 1, $current_year ) ); $previous_month = date("Ymd", mktime( 12, 0, 0, ($current_month - 1), $current_day, $current_year ) ); $previous_year = date("Ymd", mktime( 12, 0, 0, $current_month, $current_day, ($current_year - 1) ) ); $next_day = date("Ymd", mktime( 1, 12, 0, $current_month, $current_day + 1, $current_year ) ); $next_month = date("Ymd", mktime( 1, 12, 0, $current_month + 1, $current_day, $current_year ) ); $next_year = date("Ymd", mktime( 12, 0, 0, $current_month, $current_day, ($current_year + 1) ) ); if ($param['use_img']) { $g = ''; $gg = ''; $ggg = ''; $d = ''; $dd = ''; $ddd = ''; } else { $g = '<'; $gg = '<<'; $ggg = '<<<'; $d = '>'; $dd = '>>'; $ddd = '>>>'; } // nav link for : next day if ( ($param['link_after_date'] == 0) && ($current_timestamp < mktime(0,0,0, $current_month, $current_day+1, $current_year)) ) { $next_day_link = ' '; } else { $next_day_link = ''.$d.''."\n"; } // nav link for : previous day if ( ($param['link_before_date'] == 0) && ($current_timestamp > mktime(0,0,0, $current_month, $current_day-1, $current_year)) ){ $previous_day_link = ' '; } else { $previous_day_link = ''.$g.''."\n"; } // nav link for : next month if ( ($param['link_after_date'] == 0) && ($current_timestamp < mktime(0,0,0, $current_month+1, $current_day, $current_year)) ) { $next_month_link = ' '; } else { $next_month_link = ''.$dd.''."\n"; } // nav link for : previous month if ( ($param['link_before_date'] == 0) && ($current_timestamp >= mktime(0,0,0, $current_month-1, $current_day, $current_year)) ){ $previous_month_link = ' '; } else { $previous_month_link = ''.$gg.''."\n"; } // nav link for : next year if ( ($param['link_after_date'] == 0) && ($current_timestamp < mktime(0,0,0, $current_month, $current_day, $current_year+1)) ) { $next_year_link = ' '; } else { $next_year_link = ''.$ddd.''."\n"; } // nav link for : previous year if ( ($param['link_before_date'] == 0) && ($current_timestamp >= mktime(0,0,0, $current_month, $current_day, $current_year-1)) ){ $previous_year_link = ' '; } else { $previous_year_link = ''.$ggg.''."\n"; } $output .= ''."\n"; $output .= ' '."\n"; $output .= ''."\n"; } $output .= '
'."\n"; ### Insert an img at will if ($param['use_img'] ) { $output .= '  '; } if ( $param['day_mode'] == 1 ) { $output .= ' '.$current_day_name.' '.$current_day.' '.$current_month_name.' '.$current_year."\n"; } else { $output .= ' '.$current_month_name.' '.$current_year."\n"; } $output .= '
'.$day_name.'
'.$current_hour.':'.$current_min.''.$current_hour.':'.$current_min.''.$txt_2_use.'
 
'.$i.''.$txt_2_use.''.$i.$txt_2_use.''.$i.$txt_2_use.''.$i.''.$txt_2_use.''.$i.$txt_2_use.''.$i.'
 
'."\n"; $output .= ' '; $output .= ' '."\n"; $output .= ' '."\n"; $output .= ' '."\n"; $output .= ' '."\n"; $output .= ' '."\n"; $output .= ' '."\n"; $output .= ' '."\n"; $output .= ' '; $output .= '
'."\n"; $output .= $previous_year_link; $output .= ' '."\n"; $output .= $previous_month_link; $output .= ' '."\n"; $output .= $previous_day_link; $output .= ' '."\n"; $output .= $next_day_link; $output .= ' '."\n"; $output .= $next_month_link; $output .= ' '."\n"; $output .= $next_year_link; $output .= '
'; $output .= '
'."\n"; return $output; } function priv_reg_glob_calendar($var) { Global $HTTP_GET_VARS, $HTTP_POST_VARS; if (isset($HTTP_GET_VARS[$var])) { return $HTTP_GET_VARS[$var]; } elseif (isset($HTTP_POST_VARS[$var])) { return $HTTP_POST_VARS[$var]; } else { return ''; } } //-------------------------------------------[/[Mod] Calendar with nav and search ] function get_rank($count, $mode) { global $lang; if ($count <= 0) { $rank_commentator = $lang['passive'].$lang['commentator']; $rank_photographer = $lang['passive'].$lang['photographer']; } elseif ($count >= 1 && $count < 50) { $rank_commentator = $lang['beginner'].$lang['commentator']; $rank_photographer = $lang['beginner'].$lang['photographer']; } elseif ($count >= 50 && $count < 200) { $rank_commentator = $lang['active'].$lang['commentator']; $rank_photographer = $lang['active'].$lang['photographer']; } elseif ($count >= 200 && $count < 500) { $rank_commentator = $lang['super'].$lang['commentator']; $rank_photographer = $lang['super'].$lang['photographer']; } else { $rank_commentator = $lang['mega'].$lang['commentator']; $rank_photographer = $lang['mega'].$lang['photographer']; } if ($mode == "commentator") { return $rank_commentator; } if ($mode == "photographer") { return $rank_photographer; } } if (!function_exists("date_default_timezone_set")) { function date_default_timezone_set($timezone) { return true; } } /* MOD MULTI-LIGHTBOXES START INSERT */function lightbox_trim($name) { $max = 10; if (strlen($name) > $max) { $name = substr($name, 0, $max)."..."; } return $name; } function fixhtml($text, $quote = 1, $amp = 0) { if ($amp) $text = str_replace("&", "&", $text); if ($quote) $text = str_replace("\"", """, $text); $text = str_replace("<", "<", str_replace(">", ">", $text)); return $text; } /* MOD MULTI-LIGHTBOXES END INSERT */ /* MOD MULTI-LIGHTBOXES START INSERT */ function get_msg($msg) { $txt = ""; if (is_array($msg)) { $error = implode($msg['error'], "
"); $good = implode($msg['good'], "
"); $plain = implode($msg['plain'], "
"); } else { $error = $msg; } if ($error) { $txt = "
".$error."
"; } if ($good) { $txt .= "
".$good."
"; } if ($plain) { $txt .= "
".$plain."
"; } return $txt; } /* MOD MULTI-LIGHTBOXES END INSERT */ function get_friendslist($friends_id) { global $site_db, $user_info; $sql = "SELECT COUNT(friends_id) as total_friends FROM " . FRIENDSLIST_TABLE . " WHERE user_id = " . $user_info['user_id'] . " AND friends_id = " . (int)$friends_id; $total_friends = $site_db->query_firstrow($sql); if ((int)$total_friends['total_friends'] > 0) { return false; } else { return true; } } function get_friendslist_approval($friends_id) { global $site_db, $user_info; $sql = "SELECT COUNT(friends_id) as total_friends FROM " . FRIENDSLIST_TABLE . " WHERE user_id = " . (int)$friends_id . " AND friends_id = " . $user_info['user_id'] . " AND friends_approved = 1"; $total_friends = $site_db->query_firstrow($sql); if ((int)$total_friends['total_friends'] > 0) { return false; } else { return true; } } 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; } //################## Start Automatic Banner change ################################ function banner_check(){ global $site_db; $time_current = time(); $sql = "SELECT b.image_id, b.cat_id, b.image_name,b.set_time,b.time_interval, i.image_id,i.image_active,i.image_media_file FROM (".BANNER_TABLE." b, ".IMAGES_TABLE." i) WHERE i.image_active =1 AND i.image_id = b.image_id AND b.set_time > ($time_current - (time_interval * 60*60)) "; $row = $site_db->query_firstrow($sql); if($row){ $banner = ""; return $banner; } } function banner_change(){ global $site_db; $time_current = time(); $banner_check = banner_check(); if($banner_check){ return $banner_check; } else{ $sql = "UPDATE ".BANNER_TABLE." set set_time = $time_current "; $site_db->query($sql); return banner_check(); } } //################## End Automatic Banner change ################################ //################## Start Shoutbox II ######### function shoutbox_setting(){ global $config,$site_db; $sql = "SELECT setting_name, setting_value FROM ".SHOUTBOX_SETTINGS_TABLE; $result = $site_db->query($sql); while ($row = $site_db->fetch_array($result)) { $config[$row['setting_name']] = $row['setting_value']; } return $config; } function show_smiley($text,$flip = 0) { $search_array = array( 'icon_biggrin' => ':y', 'icon_bad' => ':x', 'icon_cool' => '8)', 'icon_eek' => ':O', 'icon_evil' => ':@', 'icon_lol' => ':-)', 'icon_neutral' => ':|', 'icon_razz' => ':p', 'icon_rolleyes' => ':r', 'icon_rouge' => ':q', 'icon_sad' => ':(', 'icon_smile' => ':)', 'icon_wink' => ';)', 'icon_rolleyes2' => 'o-)' ); if($flip){ $search_array = array_flip($search_array); $imgsrc_regex = '/]+\>/i'; $count = preg_match_all($imgsrc_regex, $text, $result); }else{ $count = count($search_array); $array_values = array_values($search_array); $array_keys = array_keys($search_array); } for($i=0;$i<$count;$i++){ if($flip){ $blub = preg_match('/src=(["\'])(.*?)\1/i', $result[0][$i], $match); $filename = get_file_name($match[2]); $smiley = array_search($filename, $search_array); $text = str_replace($result[0][$i],$smiley,$text); }else{ $text = str_replace($array_values[$i]," ",$text); } } return $text; } //################## End Shoutbox II ########### function get_image_dropdown_field($cat_id, $image_id = "") { global $site_db, $lang; $sql = "SELECT image_id, cat_id, image_name, image_date, image_active FROM ".IMAGES_TABLE." WHERE image_active = 1 AND cat_id NOT IN (".get_auth_cat_sql("auth_viewcat", "NOTIN").") AND cat_id = $cat_id ORDER BY image_name ASC "; $result = $site_db->query($sql); $image_dropdown = ""; $image_dropdown .= "\n\n"; return $image_dropdown; } ?>
Fatal error: Call to undefined function get_basename() in /home/www/c29d9187e6be60f0399c96d24da903c6/web/global.php on line 395