parts using regex.... $result = preg_replace("/(]+)>)/is","",$s_txt); $result = preg_replace("/(<\/a>)/is","",$result); return $result; } //******************************************** function getContactInfo($nick) { if ($GLOBALS[$nick.'_email']) $email = $GLOBALS[$nick.'_email']; else $email=$GLOBALS['contact_email']; if ($GLOBALS[$nick.'_phone']) $phone = $GLOBALS[$nick.'_phone']; else $phone=$GLOBALS['contact_phone']; return array(1=>$email,2=>$phone); } //Removes all $seps from the given string //and returns string with lower case letters function stripit ($s) { $s=str_replace(array(" ", "_", "-", "%20"), "",$s); return strtolower($s); } // Parses the url parameter function parse_string($s) { $s=str_replace(array(" ", "-", "%20"), "_",$s); return strtolower($s); } //Tries to quess which name was given //and returns the correctly formatted product nickname //Changes e.g. Minarc MIG Evo to minarcmig_evo function find_name ($sourcename) { $source=stripit($sourcename); $qry = "SELECT nick FROM families;"; $nick_arr = mysql_query($qry) or die("Error in database query."); $result=$source; while ($rw = mysql_fetch_row($nick_arr)) { $nick = $rw[0]; $tmpnick = stripit($nick); if($source==$tmpnick) { $result=$nick; $found="OK"; break; } } mysql_data_seek($nick_arr,0); //(This could be done more cleverly with regular expression...) //first try if whole nick is included in the string while ($rw = mysql_fetch_row($nick_arr)and $found!="OK") { $nick = $rw[0]; $tmpnick = stripit($nick); if(stristr($source,$tmpnick)) { $result=$nick; break; } } //then try if string is included in the nick while ($rw = mysql_fetch_row($nick_arr)and $found!="OK") { $nick = $rw[0]; $tmpnick = stripit($nick); if(stristr($tmpnick,$source)) { $result=$nick; break; } } return $result; } function kemppi_website($l) { $urli = "http://www.kemppi.com"; switch ($l) { case 'fi': case 'no': case 'de': case 'es': case 'fr': case 'nl': case 'pl': $urli = "http://www.kemppi.".$l;break; case 'en': $urli = "http://www.kemppi.com";break; case 'sv': $urli = "http://www.kemppi.se";break; case 'da': $urli = "http://www.kemppi.dk";break; case 'ru': $urli = "http://www.kemppi.com/ru";break; case 'zh': $urli = "http://www.kemppichina.com";break; default: $urli = "http://www.kemppi.com"; } return $urli; } function product_image ($nick){ $path='/showroom/img/products/'; $bigpath=$_SERVER['DOCUMENT_ROOT'].$path; $img1=$bigpath.$nick.'_prodimg.png'; if (file_exists($img1)) { $prodimg = $path.$nick.'_prodimg.png'; } else { $qry="SELECT family_nick FROM products_in_families WHERE product_nick = '".$nick."'"; $results = mysql_query($qry); $rw=mysql_fetch_row($results); $img1=$bigpath.$rw[0].'_prodimg.png'; if (file_exists($img1)) $prodimg = $path.$rw[0].'_prodimg.png'; else $prodimg = $path.'dummy_prodimg.png'; } return $prodimg; } ?>