'; $db_name = ''; $db_user = ''; $db_passwort = ''; $dbs = new mysqli( $db_server, $db_user, $db_passwort, $db_name ); if ($dbs->connect_errno) { echo "Failed to connect to MySQL: (" . $dbs->connect_errno . ") " . $dbs->connect_error; } error_reporting(0); /* Define functions */ function datum($date) { return substr($date, 8, 2) . '.' . substr($date, 5, 2) . '.' . substr($date, 0, 4); } function outstat($period, &$result, &$text0, &$text1) { global $dbs, $digits, $language, $nines, $str, $sum; $str .= "

" . $period . '
<>

<><><><><><><>'; while($column = $result->fetch_assoc()) { $count[$column['title']]++; $sum++; } foreach($count as $title => $counts) { $count[$title] = sprintf("%" . $digits . "d", $nines - $counts) . ";$title"; } asort($count, SORT_STRING); foreach($count as $title => $counts) { if (substr($counts, 0, $digits) <> $nines) { $sql = "SELECT ID FROM `" . $language . "_sites` WHERE page='" . substr($counts, $digits) . "'"; $resu = $dbs->query($sql); $stmt = mysqli_prepare($dbs, $sql); mysqli_stmt_execute($stmt); mysqli_stmt_store_result($stmt); if (mysqli_stmt_num_rows($stmt) <> 0) { $colum = $resu->fetch_assoc(); $str .= "<><><><><>"; } else { $str .= "<><><><><>"; } } } $str .= "
" . ($nines - $counts) . "" . str_replace(".", $text0["Sign"], sprintf("% 2.1f", 100 * ($nines - $counts) / $sum)) . " %" . '' . substr($counts, $digits + 1) . "
" . ($nines - $counts) . "" . str_replace(".", $text0["Sign"], sprintf("% 2.1f", 100 * ($nines - $counts) / $sum)) . " %" . substr($counts, $digits + 1) . "
<>

" . sprintf("%'_35s", "") . '

<><><><><><><><><><><><>
' . "$sum" . $text1["Procent"] . "" . $text1["Sum"] . "
<>"; } function transfer($first, $second) { $search = array("ä", "ö", "ü", "ß", "Ä", "Ö", "Ü"); $replace = array("ae", "oe", "ue", "ss", "ae", "oe", "ue"); $first = str_replace($search, $replace, $first); $second = str_replace($search, $replace, $second); return strcasecmp($first, $second); } function transferd($first, $second) { $search = array("ä", "ö", "ü", "ß", "Ä", "Ö", "Ü"); $replace = array("ae", "oe", "ue", "ss", "ae", "oe", "ue"); $first = str_replace($search, $replace, $first); $second = str_replace($search, $replace, $second); return strcasecmp($second, $first); } /* Analyse query string */ parse_str($_SERVER['QUERY_STRING'], $values); if ($values["id"]) { $sql = "SELECT ID FROM `" . $language . "_sites` WHERE ID='" . $values["id"] . "'"; $error = $dbs->query($sql); $id = ($hold = $error->fetch_assoc()) ? $hold['ID'] : 1002; } else { $id = 1; } /* Read global texts */ $sql = "SELECT ident, text FROM `" . $language . "_texts` WHERE ID=0"; $rest = $dbs->query($sql); while($texts = $rest->fetch_assoc()) { $text0[$texts['ident']] = $texts['text']; } /* Set cookies */ if (!$_POST["css"]) { $css = ''; } else { $css = $_POST["css"]; setcookie('bm_style', $css, time()+31536000, '/', $domain, '0'); header("Location: $path_boris_haase_mus/bm_index.php?id=" . $values["id"]); } header('Content-Type: text/html; charset=iso-8859-1'); /* Build output */ $str = '<>'; $str .= '<>'; $str .= '<>'; $str .= "<>"; /* Read data */ $sql = "SELECT * FROM `" . $language . "_sites` WHERE ID='" . $id . "'"; $result = $dbs->query($sql); $row = $result->fetch_assoc(); $values["id"] = $id; $hier = 0; /* Build head*/ $str .= '<>"; $str .= "" . $row['page'] . "<>"; $str .= '<>'; $str .= '<>'; $str .= '<>'; $str .= '<>'; $str .= '<>'; $str .= '<>'; $str .= '<>'; $str .= '<>'; $str .= '<>'; $str .= '<>'; $str .= '<>'; $str .= '<>'; $str .= '<>'; /* Read cookies */ $css = $_COOKIE["bm_style"]; /* Determine CSS-file */ if (!$css) $css = "bm_inwhiteandgreen"; $str .= '<>'; $str .= "<>'; $str .= '<>'; $str .= '<>'; $str .= '<>'; $str .= '<>'; $str .= '<>'; $str .= '<>'; $str .= "<>"; /* Determine size */ $row['width'] = floor($row['width']); $row['height'] = floor($row['height']); $width = 383; $height = 50; /* Build body */ $str .= '<>

' . $text0["Title"] . '

<>
<>
    <>'; /* Read ciphers for menu */ $sql = "SELECT text FROM `" . $language . "_sites` WHERE ID=1"; $result = $dbs->query($sql); $page = $result->fetch_assoc(); $ciphers = explode(';', $page['text']); /* Build menu as unordered list */ foreach($ciphers as $cipher) { $sql = "SELECT page, numbers FROM `" . $language . "_sites` WHERE ID=" . $cipher; $result = $dbs->query($sql); $pages = $result->fetch_assoc(); $str .= '
  • ' . $pages['page'] . ""; $hier++; $lpage[$hier] = $cipher; if ($lpage[$hier] == $values["id"]) $lid = $hier; if ($pages['numbers'] > '0') { $str .= "<>
      <>"; $subs[$cipher] = explode(';', $pages['numbers']); foreach($subs[$cipher] as $submenu) { $sql = "SELECT page FROM `" . $language . "_sites` WHERE ID=" . $submenu; $reult = $dbs->query($sql); $sub = $reult->fetch_assoc(); $hier++; $lpage[$hier] = $submenu; if ($lpage[$hier] == $values["id"]) $lid = $hier; $str .= '
    • ' . $sub['page'] . "
    • <>"; } $str .= "
    <>"; } $str .= "
  • <>"; } $str .= '
  • ' . $text0["Private"] . '
  • <>'; /* Consider language */ if ($language == "de") { $sql = "SELECT ID FROM `en_sites` WHERE ID='" . $id . "'"; $ref = $dbs->query($sql); $stmt = mysqli_prepare($dbs, $sql); mysqli_stmt_execute($stmt); mysqli_stmt_store_result($stmt); if (mysqli_stmt_num_rows($stmt) <> 0) { $refs = $ref->fetch_assoc(); if ($localhost) $str .= '
  • English
  • <>'; else $str .= '
  • English
  • <>'; } } else { $sql = "SELECT ID FROM `de_sites` WHERE ID='" . $id . "'"; $ref = $dbs->query($sql); $stmt = mysqli_prepare($dbs, $sql); mysqli_stmt_execute($stmt); mysqli_stmt_store_result($stmt); if (mysqli_stmt_num_rows($stmt) <> 0) { $refs = $ref->fetch_assoc(); if ($localhost) $str .= '
  • Deutsch
  • <>'; else $str .= '
  • Deutsch
  • <>'; } } $str .= '
<><>
'; /* Read texts for page */ $sql = "SELECT ident, text FROM `" . $language . "_texts` WHERE ID=" . $id; $reslt =$dbs->query($sql); while($texts = $reslt->fetch_assoc()) { $text1[$texts['ident']] = $texts['text']; } /* Build intermediate menu */ $str .= '<>




'; if($id >= 2000) { $sql = "SELECT numbers FROM `" . $language . "_sites` WHERE ID=2000"; $relt = $dbs->query($sql); $title = $relt->fetch_assoc(); $numbering = explode(';',$title['numbers']); for($x=0;$x' . $columns['page'] . ' • '; } /* Trail */ $sql = "SELECT page FROM `" . $language . "_sites` WHERE ID=" . $numbering[count($numbering)-1]; $result = $dbs->query($sql); $columns = $result->fetch_assoc(); $str .= '' . $columns['page'] . '  '; } $lpage[0] = 1; $lpage[$hier+1] = $lpage[$hier]; if ($lid) $str .= '(' . $text0["Previous"] . " | " . '' . $text0["Next"] . ")

"; else $str .= "

"; $head = $str; $str = ""; switch($id) { /* Main page */ case 1 : $entries = explode(';', $row['explanation']); $str .= '<>

' . $row['header'] . "

<>

"; /* Build sitemap */ foreach($entries as $entry) { $sql = "SELECT page, explanation, date FROM `" . $language . "_sites` WHERE ID=" . $entry; $result = $dbs->query($sql); $columns = $result->fetch_assoc(); switch($entry) { /* Current */ case 2 : $sql = "SELECT * FROM `" . $language . "_current` ORDER BY date DESC"; $result = $dbs->query($sql); $column = $result->fetch_assoc(); $str .= '' . $columns['page'] . '
' . $columns['explanation'] . ' ' . datum($column['date']) . ': ' . $column['text'] . "

<>"; break; /* All other main themes */ default : $str .= '

' . $columns['page'] . ' (' . $text1["Revised"] . ': ' . datum($columns['date']) . ')
' . $columns['explanation'] . "

<>"; break; } } $str .= "

" . $text1["Revisional history"] . ":

<>

"; /* Descendent sorted revisional history */ $sql = "SELECT COUNT(*) AS count FROM `" . $language . "_index`"; $resuc = $dbs->query($sql); $count = $resuc->fetch_assoc(); $sql = "SELECT * FROM `" . $language . "_index` ORDER BY date DESC"; if (!$values["subject"]) { if ($values["limit"]) $sql .= " LIMIT " . abs((int) $values["limit"]); else $sql .= " LIMIT 10"; } $result = $dbs->query($sql); while($rows = $result->fetch_assoc()) { $position = strrpos($rows['text'], "#"); if ($position === false) $str .= datum($rows['date']) . ': ' . $rows['text'] . "
<>"; else $str .= datum($rows['date']) . ': ' . substr($rows['text'], 0, $position) . '#' . substr($rows['text'], $position + 1, strlen($rows['text']) - $position) . "
<>"; } if (abs((int) $values["limit"]) >= $count['count'] || $values["subject"]) $str .= "

"; else $str .= '
' . $text0["Show complete site"] . "

"; break; /* Current */ case 2 : $str .= '<>



' . $row['name'] . '

<>

' . $row['header'] . "

<>

"; /* Descendent sorted current data */ $sql = "SELECT COUNT(*) AS count FROM `" . $language . "_current`"; $resuc = $dbs->query($sql); $count = $resuc->fetch_assoc(); $sql = "SELECT * FROM `" . $language . "_current` ORDER BY date DESC"; if (!$values["subject"]) { if ($values["limit"]) $sql .= " LIMIT " . abs((int) $values["limit"]); else $sql .= " LIMIT 20"; } $result = $dbs->query($sql); while($rows = $result->fetch_assoc()) { $str .= datum($rows['date']) . ': ' . $rows['text'] . "
<>"; } if (abs((int) $values["limit"]) >= $count['count'] || $values["subject"]) $str .= "

"; else $str .= '
' . $text0["Show complete site"] . "

"; break; /* Bibliography */ case 3 : $str .= '<>



' . $row['name'] . '

<>

' . $row['header'] . "

<>"; /* By default sort by ascendent numbers */ $field = $_POST["field"]; if (!$field) $field = "id"; $sort = $_POST["sort"]; if (!$sort) $sort = "asc"; /* Define and initialise form */ $str .= '
<>
<>' . $text1["Sorted by"] . ':<>'; $str .= '<>'; if ($field == "id") $str .= '<>'; else $str .= '<>'; if ($field == "author") $str .= '<>'; else $str .= '<>'; if ($field == "title") $str .= '<>'; else $str .= '<>'; if ($field == "edition") $str .= '<>'; else $str .= '<>'; if ($field == "year") $str .= '<>'; else $str .= '<>'; if ($field == "publisher") $str .= '<>'; else $str .= '<>'; if ($field == "location") $str .= '<>'; else $str .= '<>'; if ($field == "isbn") $str .= '<>'; else $str .= '<>'; if ($field == "comment") $str .= '<>'; else $str .= '<>'; $str .= '
<>
<>' . $text1["Order"]. ':<>'; if ($sort == "asc") $str .= '<>'; else $str .= '<>'; if ($sort == "desc") $str .= '<>'; else $str .= '<>'; $str .= '
<>
<>
<>
<>

'; /* Query by sort field and direction */ $sql = 'SELECT * FROM `books` ORDER BY ' . $field . ' ' . $sort; $result = $dbs->query($sql); $line = 0; while($rows = $result->fetch_assoc()) { /* Sort authors separately */ if ($field == "author") { $author = $rows['author']; $count = substr_count($author, ';'); $lines[$line++] = $author . ': ' . $rows['title'] . '; ' . $rows['edition'] . '; ' . $rows['year'] . '; ' . $rows['publisher'] . '; ' . $rows['location'] . '; ' . $rows['isbn'] . '; ' . $rows['comment'] . ".
<>" . sprintf("%04d", $rows['id']); for($aline = 0; $aline < $count; $aline++) { $position = strpos($author, '; '); $author = substr($author, $position + 2) . '; ' . substr($author, 0, $position); $lines[$line++] = $author . ': ' . $rows['title'] . '; ' . $rows['edition'] . '; ' . $rows['year'] . '; ' . $rows['publisher'] . '; ' . $rows['location'] . '; ' . $rows['isbn'] . '; ' . $rows['comment'] . ".
<>" . sprintf("%04d", $rows['id']); } } else { $str .= '[' . $rows['id'] . '] ' . $rows['author'] . ': ' . $rows['title'] . '; ' . $rows['edition'] . '; ' . $rows['year'] . '; ' . $rows['publisher'] . '; ' . $rows['location'] . '; ' . $rows['isbn'] . '; ' . $rows['comment'] . ".
<>"; } } if ($field == "author") { $str .= $text1["Hint"] . "!

<>"; if ($sort == "asc") usort($lines, "transfer"); else usort($lines, "transferd"); for($aline = 0; $aline < $line; $aline++) { $str .= '[' . sprintf("%d", substr($lines[$aline], strlen($lines[$aline]) - 4, 4)) . "] " . substr($lines[$aline], 0, strlen($lines[$aline]) - 4); } } $str .= "

"; break; /* Subject Catalogue */ case 4 : $str .= '<>



' . $row['name'] . '

<>

' . $row['header'] . "

<>

"; $sql = "SELECT ID, page FROM `" . $language . "_sites`"; $result = $dbs->query($sql); while($column = $result->fetch_assoc()) { $site[$column['ID']] = $column['page']; } $chars = explode(',', 'A,B,C,D,E,F,G,H,I,J,K,L,M,N,O,P,Q,R,S,T,U,V,W,X,Y'); foreach($chars as $char) { $str .= '' . $char . " • "; } $str .= 'Z

<>'; $sql = "SELECT * FROM `" . $language . "_subs` ORDER BY word"; $res = $dbs->query($sql); $letter = '0'; $str .= '<>'; while($rows = $res->fetch_assoc()) { $char = substr(ucfirst($rows['word']),0,1); if ($letter <> $char) { switch($char) { case 'A': case 'Ä': $do = ($letter <> 'A'); $letter = 'A'; break; case 'O': case 'Ö': $do = ($letter <> 'O'); $letter = 'O'; break; case 'U': case 'Ü': $do = ($letter <> 'U'); $letter = 'U'; break; default : $do = true; $letter = $char; break; } if ($do) $str .= '<><>"; } $str .= "<>"; } $str .= "

' . $letter . "

" . ucfirst($rows['word']) . ""; $links = explode(',', $rows['links']); $count = count($links)-1; $posit = strpos($rows['word'], ","); if (!($posit === false)) $rows['word'] = ucfirst(substr($rows['word'], $posit + 2)) . " " . substr($rows['word'], 0, $posit); $rows['word'] = str_replace(" ", "_", $rows['word']); for($x=0;$x<$count;$x++) { $str .= '' . $site[$links[$x]] . ", "; } $str .= '' . $site[$links[$count]] . "
"; break; /* Definitions and glossary*/ case 5 : $str .= '<>



' . $row['name'] . '

<>

' . $row['header'] . "

<>

"; $chars = explode(',', 'A,B,C,D,E,F,G,H,I,J,K,L,M,N,O,P,Q,R,S,T,U,V,W,X,Y'); foreach($chars as $char) { $str .= '' . $char . " • "; } $str .= 'Z

<>'; $sql = "SELECT * FROM `" . $language . "_defs` ORDER BY term"; $res = $dbs->query($sql); $letter = '0'; $str .= '<>'; while($rows = $res->fetch_assoc()) { $char = substr(ucfirst($rows['term']),0,1); if ($letter <> $char) { switch($char) { case 'A': case 'Ä': $do = ($letter <> 'A'); $letter = 'A'; break; case 'O': case 'Ö': $do = ($letter <> 'O'); $letter = 'O'; break; case 'U': case 'Ü': $do = ($letter <> 'U'); $letter = 'U'; break; default : $do = true; $letter = $char; break; } if ($do) $str .= '<><>"; } $str .= "<>"; } $str .= "

' . $letter . "

" . ucfirst($rows['term']) . ":" . $rows['definition'] . "
"; break; /* Statistics */ case 6 : if (date("Y-m") > "2013-10") { $periods = 12; } else { $periods = date("n") - 1; if ($periods < 1) $periods += 12; $row['width'] *= $periods / 12; } $str .= '<>



' . $row['name'] . '

<>

' . $row['header'] . "

<>"; $names = Array($text1["January"],$text1["February"],$text1["March"],$text1["April"],$text1["May"],$text1["June"],$text1["July"],$text1["August"],$text1["September"],$text1["October"],$text1["November"],$text1["December"]); $digits = 9; $nines = pow(10, $digits) - 1; $width = 50 * $periods; $height = 300; $grht = 250; $fontsize = 5; $image = imageCreate($width, $height); $bckgr = imageColorAllocate($image, 0, 85, 0); $red = imageColorAllocate($image, 255, 0, 0); $green = imageColorAllocate($image, 0, 255, 0); $white = imageColorAllocate($image, 255, 255, 255); $yellow = imageColorAllocate($image, 255, 255, 0); $step = floor($width / $periods); $colour = $yellow; /* Monthly statistics */ for($months=0; $months < $periods; $months++) { $month = date("n") - $months; $year = date("Y"); $sum = 0; if ($month < 1) { $month += 12; $year--; } $sql = "SELECT title FROM `" . $language . "_stat` WHERE date LIKE '" . $year . "-" . sprintf("%02d", $month) . "%' AND NOT title LIKE 'RSS%'"; $result = $dbs->query($sql); $stmt = mysqli_prepare($dbs, $sql); mysqli_stmt_execute($stmt); mysqli_stmt_store_result($stmt); if (mysqli_stmt_num_rows($stmt) <> 0) { outstat($names[$month-1] . " " . $year, $result, $text0, $text1); $sums[$periods-1-$months] = $sum; $mname[$periods-1-$months] = $names[$month-1]; } } $max = max($sums); /* Draw images */ for ($months=0;$months<$periods;$months++) { imageFilledRectangle($image, $months * $step, $grht - floor($sums[$months] * $grht / $max), ($months + 1) * $step, $grht, $colour); imageString($image, $fontsize, 10 + $months * $step, 255, $sums[$months], $green); imageString($image, $fontsize, 10 + $months * $step, 280, substr($mname[$months], 0, 3), $white); $colour = ($colour == $yellow) ? $red : $yellow; } imageJPEG($image, "./" . $row['picture'], 90); imageDestroy($image); $str .= "

" . sprintf("%'=35s", "") . "

<>"; /* Annual statistics */ for($year=date("Y"); $year > 2009; $year--) { $sum = 0; $sql = "SELECT title FROM `" . $language . "_stat` WHERE date LIKE '" . $year . "%' AND NOT title LIKE 'RSS%'"; $result = $dbs->query($sql); $stmt = mysqli_prepare($dbs, $sql); mysqli_stmt_execute($stmt); mysqli_stmt_store_result($stmt); if (mysqli_stmt_num_rows($stmt) <> 0) outstat($text1["Year"] . " " . $year, $result, $text0, $text1); } /* Entire statistics */ if(date("Y") > 2010) { $sum = 0; $str .= "

" . sprintf("%'=35s", "") . "

<>"; $sql = "SELECT title FROM `" . $language . "_stat` WHERE NOT title LIKE 'RSS%'"; $result = $dbs->query($sql); $stmt = mysqli_prepare($dbs, $sql); mysqli_stmt_execute($stmt); mysqli_stmt_store_result($stmt); if (mysqli_stmt_num_rows($stmt) <> 0) outstat($text1["Entire"], $result, $text0, $text1); } break; /* Lectures */ case 2000 : $str .= '<>



' . $row['name'] . '

<>

' . $row['header'] . "

<>"; $sql = "SELECT * FROM `" . $language . "_music` WHERE id='" . $id . "' ORDER BY nr"; $res = $dbs->query($sql); while($rows = $res->fetch_assoc()) { $str .= '

#' . $rows['nr'] . " " . $text0["of"] . " ". datum($rows['date']) . ": " . $rows['title'] . " (" . $rows['length'] . " " . $text0["Length"] . ")

<>" . $rows['descr']; } break; /* Default page */ default: if ($row['audio']) { if ($row['picture']) { $pic = (int) substr($row['picture'], strlen($row['picture']) - 7, 3); if ($pic == 1) { $str .= '<>



' . $row['name'] . '

'; } else { $str .= '<>


'; for($x = 1;$x <= $pic;$x++) $str .= '<><><>'; $str .= '<>
' . $row['name'] . '
'; } } if (substr($row['audio'], strlen($row['audio']) - 5, 1) == "t") $str .= '<>



<>

' . $row['header'] . '

<>

' . $text0["MP3-version melody"] . "
" . '' . $text0["MP3-version text"] . "

" . $row['text']; else $str .= '<>



<>

' . $row['header'] . '

<>

' . $text0["MP3-version"] . "

" . $row['text']; } else { $str .= '<>



' . $row['name'] . '

<>

' . $row['header'] . "

" . $row['text']; } break; } $str .= "<>

© " . $row['copyright'] . " by Boris Haase

"; /* Build footer */ $height = 16; $str .= '<>
'; $str .= '<>
'; $str .= '<>
'; $str .= '<>'; $str .= '<>
<>
'; $str .= '<>
<>
'; /* Consider css */ if ($css == "bm_inwhiteandgreen") { $str .= '<>'; $str .= '<><>
<>
'; } else { $str .= '<>'; $str .= '<><><>'; } if (strlen($values["subject"]) > 0) { $str .= '<>


'; } else { $str .= '<>


'; } $width = 44; $str .= '<>Valid XHTML 1.0 • '; $str .= '' . $text0["Privacy Policy"] . " • "; $str .= '' . $text0["Disclaimer"] . " • "; $str .= '' . $text0["Imprint"] . " • "; $str .= '' . $text0["PDF version"] . " • "; $str .= '' . $text0["Bibliography text"] . " • "; $str .= '' . $text0["Subject catalogue text"] . " • "; $str .= '' . $text0["Definitions text"] . ' • '; $str .= '' . $text0["Statistics text"] . " • "; $str .= '' . $text0["PHP-Code"] . " • "; $str .= '' . $text0["RSS-Feed"] . " • "; $str .= '' . $text0["MWiki"] . " • "; $str .= '' . $text0["Top"] . "







<>"; /* Create record for statistics */ $sql = "SELECT title FROM `" . $language . "_stat` WHERE title='" . $row['page'] . "' AND ip='" . $_SERVER['REMOTE_ADDR'] . "' AND date LIKE '" . date("Y-m-d") . "%'"; $result = $dbs->query($sql); $stmt = mysqli_prepare($dbs, $sql); mysqli_stmt_execute($stmt); mysqli_stmt_store_result($stmt); if (mysqli_stmt_num_rows($stmt) == 0) { $sql = "INSERT INTO `" . $language . "_stat` (title, referer, ip, date) VALUES ('" . $row['page'] . "', '" . $_SERVER['HTTP_REFERER'] . "', '" . $_SERVER['REMOTE_ADDR'] . "', '" . date("Y-m-d H:i:s") . "')"; $query = $dbs->query($sql); } /* Consider subject */ if (preg_match("=^[^<>]+$=", $values["subject"])) { $search = ($localhost) ? str_replace("_", " ", str_replace('\"', '"', $values["subject"])) : str_replace("_", " ", $values["subject"]); $slen = strlen($search); $posit = stripos($str, $search . "

"); $next = $posit + $slen; $begtag = stripos($str, "<", $next); if (!($posit === false) && $begtag < stripos($str, ">", $next)) { if (substr($str, $begtag, 4) == "") $str = substr($str, 0, $begtag + 4) . '' . substr($str, $begtag + 4); else $str = substr($str, 0, $posit) . '' . substr($str, $posit); $anchor = true; } $posit = stripos($str, $search); while (!($posit === false)) { $next = $posit + $slen; $begtag = stripos($str, "<", $next); $endtag = stripos($str, ">", $next); if ($begtag < $endtag) { if ($anchor) { $str = substr($str, 0, $posit) . '' . substr($str, $posit, $slen) . '' . substr($str, $next); $posit = stripos($str, $search, $next + 29); } else { if (substr($str, $begtag, 4) == "") $str = substr($str, 0, $posit) . '' . substr($str, $posit, $slen) . '' . substr($str, $next, $begtag + 4 - $next) . '' . substr($str, $begtag + 4); else $str = substr($str, 0, $posit) . '' . substr($str, $posit, $slen) . '' . substr($str, $next); $posit = stripos($str, $search, $next + 49); $anchor = true; } } else { $posit = stripos($str, $search, $endtag); } } } /* Output */ $output = explode("<>", $head . $str . ""); foreach($output as $out) { echo $out . "\n"; } echo ""; ?>