//Первое добавление
if($myFile = fopen("text.txt", "r")){
$lines = array();
while(!feof($myFile)){
$myLine = fgets($myFile);
$lines[] = $myLine;
}
fclose($myFile);
}
//Конец
if( strpos( $tpl->copy_template, "[xfvalue_" ) !== false OR strpos( $tpl->copy_template, "[xfgiven_" ) !== false ) {
$xfieldsdata = xfieldsdataload( $row['xfields'] );
foreach ( $xfields as $value ) {
$preg_safe_name = preg_quote( $value[0], "'" );
if ( $value[6] AND !empty( $xfieldsdata[$value[0]] ) ) {
$temp_array = explode( ",", $xfieldsdata[$value[0]] );
$value3 = array();
foreach ($temp_array as $value2) {
$value2 = trim($value2);
$value2 = str_replace("'", "'", $value2);
//Второе добавление
foreach ($lines as $value) {
$str_num = explode('|', $value);
if($str_num[0] == $value2){
$url_form_file = $str_num[1];
}
}
//Конец
if( $config['allow_alt_url'] ) $value3[] = "<a class=\"thumbnail\" href=\"" . $config['http_home_url'] . "".$preg_safe_name."/" . urlencode( $value2 ) . "/\">" . $value2 . "<span>" . $value2 . "<img src=\" . $url_form_file . \" width=\"100\"/></span></a>";
else $value3[] = "<a href=\"$PHP_SELF?do=xfsearch&xf=" . urlencode( $value2 ) . "\">" . $value2 . "</a>";
}
$xfieldsdata[$value[0]] = implode(" / ", $value3);
unset($temp_array);
unset($value2);
unset($value3);
}
if( empty( $xfieldsdata[$value[0]] ) ) {
$tpl->copy_template = preg_replace( "'\\[xfgiven_{$preg_safe_name}\\](.*?)\\[/xfgiven_{$preg_safe_name}\\]'is", "", $tpl->copy_template );
$tpl->copy_template = str_replace( "[xfnotgiven_{$value[0]}]", "", $tpl->copy_template );
$tpl->copy_template = str_replace( "[/xfnotgiven_{$value[0]}]", "", $tpl->copy_template );
} else {
$tpl->copy_template = preg_replace( "'\\[xfnotgiven_{$preg_safe_name}\\](.*?)\\[/xfnotgiven_{$preg_safe_name}\\]'is", "", $tpl->copy_template );
$tpl->copy_template = str_replace( "[xfgiven_{$value[0]}]", "", $tpl->copy_template );
$tpl->copy_template = str_replace( "[/xfgiven_{$value[0]}]", "", $tpl->copy_template );
}
$xfieldsdata[$value[0]] = stripslashes( $xfieldsdata[$value[0]] );
if ($config['allow_links'] AND $value[3] == "textarea" AND function_exists('replace_links')) $xfieldsdata[$value[0]] = replace_links ( $xfieldsdata[$value[0]], $replace_links['news'] );
$tpl->copy_template = str_replace( "[xfvalue_{$value[0]}]", $xfieldsdata[$value[0]], $tpl->copy_template );
if ( preg_match( "#\\[xfvalue_{$preg_safe_name} limit=['\"](.+?)['\"]\\]#i", $tpl->copy_template, $matches ) ) {
$count= intval($matches[1]);
$xfieldsdata[$value[0]] = str_replace( "</p><p>", " ", $xfieldsdata[$value[0]] );
$xfieldsdata[$value[0]] = strip_tags( $xfieldsdata[$value[0]], "<br>" );
$xfieldsdata[$value[0]] = trim(str_replace( "<br>", " ", str_replace( "<br />", " ", str_replace( "\n", " ", str_replace( "\r", "", $xfieldsdata[$value[0]] ) ) ) ));
if( $count AND dle_strlen( $xfieldsdata[$value[0]], $config['charset'] ) > $count ) {
$xfieldsdata[$value[0]] = dle_substr( $xfieldsdata[$value[0]], 0, $count, $config['charset'] );
if( ($temp_dmax = dle_strrpos( $xfieldsdata[$value[0]], ' ', $config['charset'] )) ) $xfieldsdata[$value[0]] = dle_substr( $xfieldsdata[$value[0]], 0, $temp_dmax, $config['charset'] );
}
$tpl->set( $matches[0], $xfieldsdata[$value[0]] );
}
}
}