//str_check 0 if (!function_exists("str_check")) { function str_check($value){ $value = addslashes(sprintf("%s",$value)); $value = str_replace("_", "\_", $value); $value = str_replace("%", "\%", $value); $value = nl2br($value); $value = htmlspecialchars($value); $value=substr($value,0,50); return $value; } } //str_check 1 $temp_filename = 'error.html'; $url=""; $brand=str_replace("-"," ",str_check($_GET['b'])); $model=$_GET['m']; $url_o=""; $query1=sprintf("SELECT * FROM search_ma_all WHERE e_mamodel = %s or e_link = %s and e_mabrand = %s LIMIT 0,1", GetSQLValueString($conn,$model), GetSQLValueString($conn,$model), GetSQLValueString($conn,$brand)); $all_ma = mysqli_query($conn,$query1); //$row_rts = mysqli_fetch_assoc($all_ma); $totalRows_ma = mysqli_num_rows($all_ma); while ($row_rts=mysqli_fetch_array($all_ma)) { $url=$row_rts["e_url"]; $model=$row_rts["e_mamodel"]; $url_o='/batteries-'.formatstr($brand).'/'.formatstr($brand).'-'.formatstr($url).'-battery.htm'; } if($totalRows_ma>0){$temp_filename='batteries-'.formatstr($brand).'/'.formatstr($brand).'-'.formatstr($url).'-battery.htm';}else{$temp_filename = 'error.html'; } if (file_exists($temp_filename)) { //echo "The file $filename exists"; } else { //echo "The file $filename does not exist"; $temp_filename = 'error.html'; } $context = stream_context_create(array('http'=>array('ignore_errors'=>true))); $string = file_get_contents($temp_filename, FALSE, $context); if(trim($url)==""){ echo $string ;}else{ $str_re=strtolower(trim($url)); $re = "/( ".$str_re. "| ".$str_re."|".$str_re." )/i"; $subst = ' '.$model." "; $result = preg_replace($re, $subst, $string); $re1 = '/('.$str_re.')-battery.htm/i'; $subst1 = formatstr($_GET['m']).'-battery.htm'; $result1=preg_replace($re1, $subst1, $result); echo $result1 ; } mysqli_close($conn); ?>