$max_length) { $link_text = substr($link_text, 0, $max_length); $link_text.="..."; } $text = "$link_text"; } } return $text; } function return_array_from_string($string) { $string_strlen = strlen($string); $string_strlen = $string_strlen - 2; $string_chopped = substr($string, 1, $string_strlen); $string_to_array = explode('-', $string_chopped); return $string_to_array; } function random_multidim_array($array) { $shuffled_array = array(); $randomize_array = array_keys($array); shuffle($randomize_array); foreach($randomize_array as $random_key) { $shuffled_array[$random_key] = $array[$random_key]; } return $shuffled_array; } function clear_new_lines($text) { //Convert Windows $text = ereg_replace("\r\n", "", $text); //Convert Macintosh $text = ereg_replace("\r", "", $text); return $text; } function replace_img_paths($text) { // upper level paths $text = str_replace("../", "", $text); // _cms_img paths $text = str_replace("_cms_img", "_img", $text); return $text; } function replace_img_paths_2($text) { // upper level paths $text = str_replace("_uploaded", "../_uploaded", $text); return $text; } function clean_post_info($input) { $input = stripslashes($input); $input = htmlentities($input, ENT_QUOTES); $input= convert_smart_quotes($input); return $input; } function get_post_vars_msg($attachment_url='') { $post_vars_msg = ''; unset($_POST['spam_check']); unset($_POST['x']); unset($_POST['y']); foreach($_POST as $field_name => $field_val) { $field_val = stripslashes($field_val); // $field_val = clean_post_info($field_val); // $field_val = nl2br($field_val); // $field_val = strip_white_space_from_html($field_val); $post_vars_msg.="$field_name: $field_val\n"; } // ATTACHMENT URL if($attachment_url!='') { $post_vars_msg.="cv_upload: $attachment_url\n"; } return $post_vars_msg; } function strip_white_space_from_html($html) { $pattern = '/\s\s+/'; $html = preg_replace( $pattern, '', $html); return $html; } function msg_mail_readable($string) { $search = array( ''', '&', 'é', 'ë', 'ï', 'è' ); $replace = array( "'", "&", '', '', '', '' ); return str_replace($search, $replace, $string); } function is_leap_year($year) { if ((($year % 4) == 0 and ($year % 100)!=0) or ($year % 400) == 0) { return 1; } else { return 0; } } function iso_week_days($yday, $wday) { return $yday - (($yday - $wday + 382) % 7) + 3; } function get_week_number($timestamp) { $d = getdate($timestamp); $days = iso_week_days($d["yday"], $d["wday"]); if ($days < 0) { $d[ "yday"] += 365 + is_leap_year(--$d["year"]); $days = iso_week_days($d["yday"], $d["wday"]); } else { $d["yday"] -= 365 + is_leap_year($d["year"]); $d2 = iso_week_days($d["yday"], $d["wday"]); if (0 <= $d2) $days = $d2; } return (int)($days / 7) + 1; } function GetMonthString($n) { $timestamp = mktime(0, 0, 0, $n, 1, 2005); return date("F", $timestamp); } function doLineBreaks($text) { // Paragraphs and line breaks *** VAN ONZICHTBAAR NAAR HTML IN TEXTBOX *** //Convert Windows $text = ereg_replace("\r\n", "\n", $text); //Convert Macintosh $text = ereg_replace("\r", "\n", $text); //HANDLE PARAGRAPHS $text = ereg_replace("\n\n", "

", $text); //HANDLE LINEBREAKS $text = ereg_replace("\n", "
", $text); return $text; } function removePtags($text) { // Filter out HTML code $text = str_replace(array('

', '

'), '', $text); $text = str_replace(array('

', '

'), '
', $text); return $text; } ////// FILE RENAME FUNCTIONS /////// function getExtension($document) { // Get the extension & name before the extension $extension = substr( $document, ( strrpos($document, '.') + 1 ) ) ; $extension = strtolower( $extension ); return $extension; } function getFileName($fileN) { $pieces = explode("_uploaded/", $fileN); $docName=$pieces[1]; return $docName; } function fileName ($title) { // komma's vervangen $title = str_replace("'", "", $title); $title = str_replace('"', '', $title); // Replace dots in the name with underscores (only one dot can be there... security issue). $title = preg_replace( '/\\.(?![^.]*$)/', '_', $title ) ; // Get the extension & name before the extension $sExtension = substr( $title, ( strrpos($title, '.') + 1 ) ) ; $sExtension = strtolower( $sExtension ) ; $pieces = explode(".$sExtension", $title); $title=$pieces[0]; $title = ereg_replace("[^A-Za-z0-9_\-\./, ]", "", $title); // remove special characters $title = str_replace(array('.','-','/',','), " ", $title); // replace legal characters with spaces $title = trim($title); // remove leading and trailing whitespace $title = ereg_replace(" {1,}", "_", $title); // convert one or more consecutive spaces to a single underscore $title = ereg_replace("_{2,}", "_", $title); // convert two or more consecutive underscores to a single underscore $title = stripslashes($title); return $title; } function clean_url($title, $preserve_case=false, $seperator='-') { $title = trim($title); $Raw=clear_special_chars($title); $RemoveChars = array( "([\40])" , "([^a-zA-Z0-9-_])", "($seperator{2,})" ); $ReplaceWith = array("$seperator", "", "$seperator"); $cleaned_up_title=preg_replace($RemoveChars, $ReplaceWith, $Raw); if($preserve_case==false) { $cleaned_up_title=strtolower($cleaned_up_title); } return $cleaned_up_title; } function clear_special_chars($string) { $find = array( 'ç','', 'ì', 'í','î','ï', 'ë','ê','é','è', 'à','á','â', 'ã','ä','å', 'ù','ú','û','ü', 'ý', 'þ','ÿ', 'ò','ó','ô','ö', 'Ç', 'Ì', 'Í','Î','Ï', 'Ë','Ê','É','È', 'À','Á','Â', 'Ã','Ä','Å', 'Ù','Ú','Û','Ü', 'Ò','Ó','Ô','Ö', 'š', ''', '&' ); $replace = array( 'c', 'c', 'i','i','i','i', 'e','e','e','e', 'a','a','a','a','a','a', 'u','u','u','u','u','u','u', 'o','o','o','o', 'C', 'I','I','I','I', 'E','E','E','E', 'A','A','A','A','A','A', 'U','U','U','U', 'O','O','O','O', 's', '', 'n' ); return str_replace($find, $replace, $string); } ////// UNIQUE FILENAME //////// function getUniqueFilename($fileName, $dir) { $i=0; $newName = ""; $fullPath=$dir.$fileName; if (file_exists($fullPath)) { // Get the extension & name before the extension $sExtension = substr( $fileName, ( strrpos($fileName, '.') + 1 ) ) ; $sExtension = strtolower( $sExtension ) ; $pieces = explode(".$sExtension", $fileName); $nameClean=$pieces[0]; $newName=$nameClean; while (file_exists($dir.$newName.'.'.$sExtension)) { $i++; $newName = $nameClean.'_'.$i; } $uniqFileName=$newName.'.'.$sExtension; } else { $uniqFileName=$fileName; } return $uniqFileName; } function getUniquePicNames($fileName, $extension, $dir) { $i=0; $newName = ""; $fullPath=$dir.$fileName.$extension; if (file_exists($fullPath)) { $newName=$fileName; while (file_exists($dir.$newName.$extension)) { $i++; $newName = $fileName.'_'.$i; } $uniqFileName=$newName; } else { $uniqFileName=$fileName; } return $uniqFileName; } ///////// GENERATE RANDOM PASSWORD ///////////// function generate_password ($length = 8) { // start with a blank password $password = ""; // define possible characters $possible = "0123456789bcdfghjkmnpqrstvwxyz"; // set up a counter $i = 0; // add random characters to $password until $length is reached while ($i < $length) { // pick a random character from the possible ones $char = substr($possible, mt_rand(0, strlen($possible)-1), 1); // we don't want this character if it's already in the password if (!strstr($password, $char)) { $password .= $char; $i++; } } // done! return $password; } function convert_smart_quotes($string) { /** * 8216 curly left single quote * 8217 apostrophe, curly right single quote * 8220 curly left double quote * 8221 curly right double quote * 8212 em dash * 8211 en dash * 8230 ellipsis * 227 low left double quote */ $search = array( chr(145), // chr(146), // chr(147), // chr(148), // chr(151), // chr(150), // chr(133), // chr(132), // chr(130) ); $replace = array( '‘', '’', '“', '”', '–', '—', '…', '“', '‘' ); return str_replace($search, $replace, $string); } // REMOVE LINEBREAKS
function stripEndBreaks($text) { $endIsBr=true; while($endIsBr==true) { $endBr = substr($text, -6); // returns "
" if($endBr=='
') { $endIsBr=true; $text=substr_replace($text, '', -6); $text=trim($text); } else { $endIsBr=false; } } return $text; } function indent_non_header_txt($string) { // clean up white space $string = trim($string); // clean up extra breaks $string = stripEndBreaks($string); // remove div tags... $string = str_replace('
', '', $string); $string = str_replace('
', '', $string); // Vind de eerste positie van de mogelijke headings $str_length = strlen($string); $start_h1 = strpos($string, "') || ($string_end=='')) { $end_with_heading=true; } else { $end_with_heading=false; } // als ie start met h1, dan de rest string pakken vanaf ... if((($start_h1!==false) && ($start_h1<10)) || (($start_h2!==false) && ($start_h2<10))) { $less_start_index = strpos($string, ">") +1; $string_start = substr($string, 0, $less_start_index); if($end_with_heading==true) { $start_less = substr($string, $less_start_index, ($str_length - 5 - $less_start_index)); } else { $start_less = substr($string, $less_start_index, $str_length); $string_end = ''; } $fresh_string = str_replace('', '
', $start_less); $fresh_string = str_replace('', '
', $fresh_string); $fresh_string = str_replace('"; $string_end='
'; $fresh_string = str_replace('', '
', $string); $fresh_string = str_replace('', '
', $fresh_string); $fresh_string = str_replace('

', '

', $fresh_string); } $indented_string = $string_start.$fresh_string.$string_end; return $indented_string; } function check_ul($string) { $ul_pos = strpos($string, "', "\n", $text); $text = str_replace('
', "\n", $text); return $text; } // Please acknowledge use of this code by including this header. function truncate_string($string, $limit, $break=" ", $pad="...") { // return with no change if string is shorter than $limit if(strlen($string) <= $limit) return $string; $string = substr($string, 0, $limit); if(false !== ($breakpoint = strrpos($string, $break))) { $string = substr($string, 0, $breakpoint); } return $string . $pad; } $maand_namen = array(); $maand_namen[1] = 'Januari'; $maand_namen[2] = 'Februari'; $maand_namen[3] = 'Maart'; $maand_namen[4] = 'April'; $maand_namen[5] = 'Mei'; $maand_namen[6] = 'Juni'; $maand_namen[7] = 'Juli'; $maand_namen[8] = 'Augustus'; $maand_namen[9] = 'September'; $maand_namen[10] = 'Oktober'; $maand_namen[11] = 'November'; $maand_namen[12] = 'December'; $dag_namen = array(); $dag_namen[0] = 'Zaterdag'; $dag_namen[1] = 'Zondag'; $dag_namen[2] = 'Maandag'; $dag_namen[3] = 'Dinsdag'; $dag_namen[4] = 'Woensdag'; $dag_namen[5] = 'Donderdag'; $dag_namen[6] = 'Vrijdag'; $dag_namen_short = array(); $dag_namen_short[0] = 'Zat'; $dag_namen_short[1] = 'Zon'; $dag_namen_short[2] = 'Ma'; $dag_namen_short[3] = 'Din'; $dag_namen_short[4] = 'Woe'; $dag_namen_short[5] = 'Don'; $dag_namen_short[6] = 'Vrij'; function translateDate_NL($kind, $digit) { if($kind=='dag') { if($digit=='Mon') { $date_nl='Maandag'; } else if($digit=='Tue') { $date_nl='Dinsdag'; } else if($digit=='Wed') { $date_nl='Woensdag'; } else if($digit=='Thu') { $date_nl='Donderdag'; } else if($digit=='Fri') { $date_nl='Vrijdag'; } else if($digit=='Sat') { $date_nl='Zaterdag'; } else if($digit=='Sun') { $date_nl='Zondag'; } } else if($kind=='maand') { if($digit=='01') { $date_nl='januari'; } else if($digit=='02') { $date_nl='februari'; } else if($digit=='03') { $date_nl='maart'; } else if($digit=='04') { $date_nl='april'; } else if($digit=='05') { $date_nl='mei'; } else if($digit=='06') { $date_nl='juni'; } else if($digit=='07') { $date_nl='juli'; } else if($digit=='08') { $date_nl='augustus'; } else if($digit=='09') { $date_nl='september'; } else if($digit=='10') { $date_nl='oktober'; } else if($digit=='11') { $date_nl='november'; } else if($digit=='12') { $date_nl='december'; } } return $date_nl; } function translateDate_NL_short($kind, $digit) { if($kind=='dag') { if($digit=='Mon') { $date_nl='Ma'; } else if($digit=='Tue') { $date_nl='Dins'; } else if($digit=='Wed') { $date_nl='Woe'; } else if($digit=='Thu') { $date_nl='Don'; } else if($digit=='Fri') { $date_nl='Vrij'; } else if($digit=='Sat') { $date_nl='Zat'; } else if($digit=='Sun') { $date_nl='Zon'; } } else if($kind=='maand') { if($digit=='01') { $date_nl='Januari'; } else if($digit=='02') { $date_nl='Februari'; } else if($digit=='03') { $date_nl='Maart'; } else if($digit=='04') { $date_nl='April'; } else if($digit=='05') { $date_nl='Mei'; } else if($digit=='06') { $date_nl='Juni'; } else if($digit=='07') { $date_nl='Juli'; } else if($digit=='08') { $date_nl='Augustus'; } else if($digit=='09') { $date_nl='September'; } else if($digit=='10') { $date_nl='Oktober'; } else if($digit=='11') { $date_nl='November'; } else if($digit=='12') { $date_nl='December'; } /* if($digit=='01') { $date_nl='Jan'; } else if($digit=='02') { $date_nl='Feb'; } else if($digit=='03') { $date_nl='Maa'; } else if($digit=='04') { $date_nl='Apr'; } else if($digit=='05') { $date_nl='Mei'; } else if($digit=='06') { $date_nl='Jun'; } else if($digit=='07') { $date_nl='Jul'; } else if($digit=='08') { $date_nl='Aug'; } else if($digit=='09') { $date_nl='Sep'; } else if($digit=='10') { $date_nl='Okt'; } else if($digit=='11') { $date_nl='Nov'; } else if($digit=='12') { $date_nl='Dec'; } */ } return $date_nl; } ?>