'; $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; $digits = 9; $nines = pow(10, $digits) - 1; $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) { $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 */ $css = $_POST["css"]; if ($css) { setcookie('rl_style', $css, time()+31536000, '/', $domain, '0'); header("Location: $path_relil_de/rl_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; $name = 0; $site = 0; $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["rl_style"]; /* Determine CSS-file */ if (!$css) $css = "rl_inwhiteandred"; $str .= '<>'; $str .= "<>'; $str .= '<>'; $str .= '<>'; $str .= '<>'; $str .= '<>'; $str .= '<>'; $str .= '<>'; $str .= "<>"; /* Determine size */ $row['width'] = floor($row['width']); $row['height'] = floor($row['height']); $width = 300; $height = 50; /* Build body */ $str .= '<>

' . $text0["Title"] . '

<>
<>
    <>'; /* Read levels for menu */ $sql = "SELECT * FROM `" . $language . "_level1` WHERE ID<>13 ORDER BY ID"; $l = 1; $rsult[$l] = $dbs->query($sql); while($sub[$l] = $rsult[$l]->fetch_assoc()) { /* Build menu as unordered list */ $site++; $lname[$site] = $sub[$l]['name']; $lsite[$site] = $sub[$l]['page']; $lhier[$site] = $l; if ($sub[$l]['page']) { $hier++; $lpage[$hier] = $sub[$l]['page']; $str .= '
  • ' . $sub[$l]['name'] . "<>"; if ($id == $sub[$l]['page']) { $level[$l] = $sub[$l]['page']; $link[$l] = $sub[$l]['name']; $lid = $hier; } } else { $str .= "
  • " . $sub[$l]['name'] . "<>"; } $sql = "SELECT * FROM `" . $language . "_level2` WHERE SUBSTR(ID, 1, 2)='" . $sub[$l]['ID'] . "' ORDER BY name"; $l = 2; $rsult[$l] = $dbs->query($sql); $stmt = mysqli_prepare($dbs, $sql); mysqli_stmt_execute($stmt); mysqli_stmt_store_result($stmt); if (mysqli_stmt_num_rows($stmt) > 0) { $str .= "
      <>"; while($sub[$l] = $rsult[$l]->fetch_assoc()) { $site++; $lname[$site] = $sub[$l]['name']; $lsite[$site] = $sub[$l]['page']; $lhier[$site] = $l; if ($sub[$l]['page']) { $hier++; $lpage[$hier] = $sub[$l]['page']; $str .= '
    • ' . $sub[$l]['name'] . "<>"; if ($id == $sub[$l]['page']) { for ($x=1;$x<=$l;$x++) { $level[$x] = $sub[$x]['page']; $link[$x] = $sub[$x]['name']; } $lid = $hier; } } else { $name++; $str .= '
    • ' . $sub[$l]['name'] . "<>"; } $sql = "SELECT * FROM `" . $language . "_level3` WHERE SUBSTR(ID, 1, 5)='" . $sub[$l]['ID'] . "' ORDER BY name"; $l = 3; $rsult[$l] = $dbs->query($sql); $stmt = mysqli_prepare($dbs, $sql); mysqli_stmt_execute($stmt); mysqli_stmt_store_result($stmt); if (mysqli_stmt_num_rows($stmt) > 0) { $str .= "
        <>"; while($sub[$l] = $rsult[$l]->fetch_assoc()) { $site++; $lname[$site] = $sub[$l]['name']; $lsite[$site] = $sub[$l]['page']; $lhier[$site] = $l; if ($sub[$l]['page']) { $hier++; $lpage[$hier] = $sub[$l]['page']; $str .= '
      • ' . $sub[$l]['name'] . "<>"; if ($id == $sub[$l]['page']) { for ($x=1;$x<=$l;$x++) { $level[$x] = $sub[$x]['page']; $link[$x] = $sub[$x]['name']; } $lid = $hier; } } else { $name++; $str .= '
      • ' . $sub[$l]['name'] . "<>"; } $sql = "SELECT * FROM `" . $language . "_level4` WHERE SUBSTR(ID, 1, 8)='" . $sub[$l]['ID'] . "' ORDER BY name"; $l = 4; $rsult[$l] = $dbs->query($sql); $stmt = mysqli_prepare($dbs, $sql); mysqli_stmt_execute($stmt); mysqli_stmt_store_result($stmt); if (mysqli_stmt_num_rows($stmt) > 0) { $str .= "
          <>"; while($sub[$l] = $rsult[$l]->fetch_assoc()) { $site++; $lname[$site] = $sub[$l]['name']; $lsite[$site] = $sub[$l]['page']; $lhier[$site] = $l; if ($sub[$l]['page']) { $hier++; $lpage[$hier] = $sub[$l]['page']; $str .= '
        • ' . $sub[$l]['name'] . "
        • <>"; if ($id == $sub[$l]['page']) { for ($x=1;$x<=$l;$x++) { $level[$x] = $sub[$x]['page']; $link[$x] = $sub[$x]['name']; } $lid = $hier; } } else { $name++; $str .= '
        • ' . $sub[$l]['name'] . "
        • <>"; } } $str .= "
        <>"; } $l = 3; $str .= "
      • <>"; } $str .= "
      <>"; } $l = 2; $str .= "
    • <>"; } $str .= "
    <>"; } $l = 1; $str .= "
  • <>"; } $str .= '
  • ' . $text0["Politics"] . "
  • <>"; $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 .= '
<><>
'; /* Build breadcrumbs */ $levels = count($level); $lpage[0] = 0; $lpage[$hier+1] = $lpage[$hier]; if ($levels == 1) { $str .= '<>




(' . $text0["Previous"] . ' | ' . $text0["Next"] . ")

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




"; for($x=1;$x' . $link[$x] . " »<>"; else $str .= '' . $link[$x] . " »<>"; } if ($level[$levels]) { $str .= '' . $link[$levels] . '  (' . $text0["Previous"] . ' | ' . $text0["Next"] . ")

"; } else { $str .= '' . $link[$levels] . "

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

' . $row['header'] . "

<>

"; /* Build sitemap */ foreach($entries as $entry) { $sql = "SELECT * 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; /* Sitemap */ case 11 : $sql = "SELECT MAX(date) AS date FROM `" . $language . "_sites`"; $resud = $dbs->query($sql); $date = $resud->fetch_assoc(); $str .= '

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

<>"; 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['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['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['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 . "_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 .= '<><>"; } if ($rows['wiki']) $str .= '<>"; } $str .= "

' . $letter . "

' . ucfirst($rows['word']) . ""; else $str .= "
" . 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 .= '' . $links[$x] . ", "; } $str .= '' . $links[$count] . "
"; break; /* Definitions and glossary */ case 5 : $str .= '<>



<>

' . $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 after alphabet */ case 6: $str .= '<>



<>

' . $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 . "_words` ORDER BY word"; $res = $dbs->query($sql); $letter = '0'; $str .= '<>"; while($rows = $res->fetch_assoc()) { $char = substr($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 .= "
' . $text1["Word"] . "" . $text1["Rank"] . "" . $text1["Frequency"] . "

" . '' . $letter . "

" . $rows['word'] . ":" . $rows['rank'] . "" . $rows['freq'] . "
"; break; /* Statistics after word frequency */ case 7 : $str .= '<>



<>

' . $row['header'] . "

<>

"; for($freq=1;$freq<20;$freq++) { $str .= '' . $freq . " • "; } $str .= '20

<>'; $freq = 20; $sql = "SELECT * FROM `" . $language . "_words` ORDER BY rank"; $res = $dbs->query($sql); $str .= '<><>"; while($rows = $res->fetch_assoc()) { if ($rows['freq'] == $freq) { $str .= "<><>"; $freq--; } $str .= "<>"; } $str .= "
' . $text1["Rank"] . "" . $text1["Word"] . "" . $text1["Frequency"] . "

" . '' . $freq . "

" . $rows['rank'] . ":" . $rows['word'] . "" . $rows['freq'] . "
"; break; /* Statistics after periods */ case 8 : $str .= '<>



<>

' . $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 = 600; $height = 300; $grht = 250; $fontsize = 5; $image = imageCreate($width, $height); $bckgr = imageColorAllocate($image, 85, 0, 0); $yellow = imageColorAllocate($image, 255, 255, 0); $green = imageColorAllocate($image, 0, 128, 0); $white = imageColorAllocate($image, 255, 255, 255); $blue = imageColorAllocate($image, 0, 128, 255); $step = floor($width / 12); $colour = $yellow; /* Monthly statistics */ for($months=0; $months < 12; $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[11-$months] = $sum; $mname[11-$months] = $names[$month-1]; } } $max = max($sums); /* Draw images */ for ($months=0;$months<12;$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], $blue); imageString($image, $fontsize, 10 + $months * $step, 280, substr($mname[$months], 0, 3), $white); $colour = ($colour == $yellow) ? $green : $yellow; } imageJPEG($image, "./" . $row['picture'], 90); imageDestroy($image); $str .= "

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

<>"; /* Annual statistics */ for($year=date("Y"); $year > 2007; $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") > 2008) { $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; /* Results questionnaire */ case 9 : $str .= '<>



<>

' . $row['header'] . "

"; $height = 300; $grht = 250; $step = 50; $fontsize = 5; /* Get questions */ $sql = "SELECT ID, question FROM `" . $language . "_ques` ORDER BY ID"; $res = $dbs->query($sql); while($rows = $res->fetch_assoc()) { $count[0]++; $question[$rows['ID']] = $rows->question; /* Get answers */ $sql = "SELECT * FROM `" . $language . "_ans` WHERE ID=" . $rows['ID']; $resu = $dbs->query($sql); while($cols = $resu->fetch_assoc()) { $count[$rows['ID']]++; if ($max[$rows['ID']] < $cols['result']) $max[$rows['ID']] = $cols['result']; $ans[$rows['ID']][$cols['number']] = $cols['answer']; $val[$rows['ID']][$cols['number']] = $cols['result']; } } /* Draw images */ for ($i=1;$i<=$count[0];$i++) { $length[$i] = $count[$i] * 50; $image[$i] = imageCreate($length[$i], $height); $bckgr = imageColorAllocate($image[$i], 85, 0, 0); $yellow = imageColorAllocate($image[$i], 255, 255, 0); $green = imageColorAllocate($image[$i], 0, 128, 0); $white = imageColorAllocate($image[$i], 255, 255, 255); $blue = imageColorAllocate($image[$i], 0, 128, 255); $colour = $yellow; for ($j=1;$j<=$count[$i];$j++) { imageFilledRectangle($image[$i], ($j - 1) * $step, $grht - floor($val[$i][$j] * $grht / $max[$i]), $j * $step, $grht, $colour); imageString($image[$i], $fontsize, 10 + ($j - 1) * $step, 255, $val[$i][$j], $blue); imageString($image[$i], $fontsize, 10 + ($j - 1) * $step, 280, $j, $white); $colour = ($colour == $yellow) ? $green : $yellow; } imageJPEG($image[$i], "rl_" . $language . "_answer" . $i . ".jpg", 90); imageDestroy($image[$i]); } for ($i=1;$i<=$count[0];$i++) { $str .= '<>

' . $row['name'] . '' . "

"; $str .= "<>

" . $text0["Question"] . " $i: " . $question[$i] . "

<>

"; for ($j=1;$j<=$count[$i];$j++) { $str .= "$j: " . $ans[$i][$j] . "
<>"; } $str .= "

"; } break; /* Questionnaire */ case 10 : $str .= '<>



<>

' . $row['header'] . "

<>"; $submit = $_POST["questionnaire"]; $textarea = $_POST["textarea"]; /* Get questions */ $sql = "SELECT * FROM `" . $language . "_ques`"; $res = $dbs->query($sql); while($rows = $res->fetch_assoc()) { $count[0]++; $question[$rows['ID']] = $rows['question']; $expl[$rows['ID']] = $rows['expl']; $many[$rows['ID']] = $rows['many']; /* Get answers */ $sql = "SELECT * FROM `" . $language . "_ans` WHERE ID=" . $rows['ID'] . " ORDER BY number"; $resu = $dbs->query($sql); /* Radio or list */ if ($rows['many']) { $bool = null; while($cols = $resu->fetch_assoc()) { $count[$rows['ID']]++; $ans[$rows['ID']][$cols['number']] = $cols['answer']; $resul[$rows['ID']][$cols['number']] = $cols['result']; $answer[$rows['ID']][$cols['number']] = $_POST["answer" . $rows['ID'] . "_" . $cols['number']]; $bool = ($answer[$rows['ID']][$cols['number']] || $bool); } if (!$bool) $prompt .= $rows['ID'] . ", "; } else { $answer[$rows['ID']][0] = $_POST["answer" . $rows['ID']]; if (!$answer[$rows['ID']][0]) $prompt .= $rows['ID'] . ", "; while($cols = $resu->fetch_assoc()) { $count[$rows['ID']]++; $ans[$rows['ID']][$cols['number']] = $cols['answer']; if ($answer[$rows['ID']][0] == $cols['number']) $resul[$rows['ID']][0] = $cols['result']; } } } if (!$submit || $prompt) { $str .= "

" . $text1["Introduction"] . "

<>"; /* Define and initialise form */ if ($submit) { if (strpos(substr($prompt, 0, strlen($prompt) - 2), ",") > 0) { $str .= '

' . $text1["Prompt"] . " " . substr($prompt, 0, strlen($prompt) - 2) . "!

"; } else { $str .= '

' . substr($text1["Prompt"], 0, strlen($text1["Prompt"]) - 1) . " " . substr($prompt, 0, strlen($prompt) - 2) . "!

"; } } $str .= '
<>'; $str .= '<>'; for ($i=1;$i<=$count[0];$i++) { $str .= "
<>" . $text0["Question"] . " " . $i . ": " . $question[$i] . "<>"; for ($j=1;$j<=$count[$i];$j++) { if ($many[$i]) { if ($answer[$i][$j]) $str .= '<>"; else $str .= '<>"; } else { if ($answer[$i][0] == $j) $str .= '<>"; else $str .= '<>"; } } $str .= "
" . $text1["Explanation"] . ": " . $expl[$i] . "
<>


<>"; } $last = $count[0] + 1; $str .= "
<>" . $text0["Question"] . " " . $last . ": " . $text1["Last Question"] . "<>"; $str .= '<>


<>"; $str .= '<>
'; } else /* Write results */ { $sql = "SELECT * FROM `" . $language . "_tester` WHERE ip='" . $_SERVER['REMOTE_ADDR'] . "'"; $resut = $dbs->query($sql); $tester = $resut->fetch_assoc(); $stmt = mysqli_prepare($dbs, $sql); mysqli_stmt_execute($stmt); mysqli_stmt_store_result($stmt); if (mysqli_stmt_num_rows($stmt) == 0 || date("Y-m-d H:i:s", strtotime("-10 days")) > $tester['date']) { for ($i=1;$i<=$count[0];$i++) { if ($many[$i]) { for ($j=1;$j<=$count[$i];$j++) { if ($answer[$i][$j]) { $resul[$i][$j]++; $sql = "UPDATE `" . $language . "_ans` SET result=" . $resul[$i][$j] . " WHERE ID=" . $i . " AND number=" . $j; $re = $dbs->query($sql); } } } else { $resul[$i][0]++; $sql = "UPDATE `" . $language . "_ans` SET result=" . $resul[$i][0] . " WHERE ID=" . $i . " AND number=" . $answer[$i][0]; $re = $dbs->query($sql); } } $str .= $row['text'] . '<>' . $text1["Results questions text"] . ""; $sql = "INSERT INTO `" . $language . "_tester` (ip, date, textarea) VALUES ('" . $_SERVER['REMOTE_ADDR'] . "', '" . date("Y-m-d H:i:s") . "', '" . $textarea . "')"; $reslt = $dbs->query($sql); } else { $str .= "

" . $text1["Already"] . "!

"; } } break; /* Sitemap */ case 11 : $str .= '<>



<>

' . $row['header'] . "

<>"; $str .= '<>'; for ($x=1;$x<=$site;$x++) { $str .= ""; for ($i=1;$i<$lhier[$x];$i++) { $str .= ""; } if ($lsite[$x]) $str .= ''; else $str .= ''; for ($i=$lhier[$x]+1;$i<=4;$i++) { $str .= ""; } $str .= "<>"; } $str .= "
' . $lname[$x] . '' . $lname[$x] . '
"; break; /* Default page */ default: if ($row['audio']) { if (substr($row['audio'], strlen($row['audio']) - 5, 1) == "s") $str .= '<>



' . $row['name'] . '

<>



<>

' . $row['header'] . '

<>

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

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



<>

' . $row['header'] . '

<>

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

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



<>

' . $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 == "rl_inwhiteandred") { $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["Questionnaire text"] . " • "; $str .= '' . $text0["Bibliography text"] . " • "; $str .= '' . $text0["Subject catalogue text"] . " • "; $str .= '' . $text0["Definitions text"] . " • "; $str .= '' . $text0["PHP-Code"] . " • "; $str .= '' . $text0["Sitemap"] . " • "; $str .= '' . $text0["RSS-Feed"] . " • "; $str .= '' . $text0["MWiki"] . " • "; $str .= '' . $text0["Top"] . "







<>"; /* Create record for statistics */ $sql = "SELECT title FROM `" . $language . "_stat` WHERE title='" . $row['stat'] . "' 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['stat'] . "', '" . $_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 ""; ?>