<?php require_once('Connections/radler_db.php'); ?>
<?php
function links($text) {
  $suchmuster[] = '"(( |^)((ftp|http|https){1}://)[-a-zA-Z0-9@:%_+.~#?&//=]+)"i';
  $ersetzen[] = '<a href="\1" target="_blank">\1</a>';
  $suchmuster[] = '"( |^)(www.[-a-zA-Z0-9@:%_+.~#?&//=]+)"i';
  $ersetzen[] = '\1<a href="http://\2" target="_blank">\\2</a>';
  $suchmuster[] = '"([_.0-9a-z-]+@([0-9a-z][0-9a-z-]+.)+[a-z]{2,3})"i';
  $ersetzen[] = '<a href="mailto:\1">\\1</a>';
  $text = preg_replace($suchmuster, $ersetzen, $text);
  return $text;
}?>
<?php
if (!function_exists("GetSQLValueString")) {
function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "") 
{
  $theValue = get_magic_quotes_gpc() ? stripslashes($theValue) : $theValue;

  $theValue = function_exists("mysql_real_escape_string") ? mysql_real_escape_string($theValue) : mysql_escape_string($theValue);

  switch ($theType) {
    case "text":
      $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
      break;    
    case "long":
    case "int":
      $theValue = ($theValue != "") ? intval($theValue) : "NULL";
      break;
    case "double":
      $theValue = ($theValue != "") ? "'" . doubleval($theValue) . "'" : "NULL";
      break;
    case "date":
      $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
      break;
    case "defined":
      $theValue = ($theValue != "") ? $theDefinedValue : $theNotDefinedValue;
      break;
  }
  return $theValue;
}
}

$currentPage = $_SERVER["PHP_SELF"];

$maxRows_radler_tipps = 5;
$pageNum_radler_tipps = 0;
if (isset($_GET['pageNum_radler_tipps'])) {
  $pageNum_radler_tipps = $_GET['pageNum_radler_tipps'];
}
$startRow_radler_tipps = $pageNum_radler_tipps * $maxRows_radler_tipps;

mysql_select_db($database_radler_db, $radler_db);
$query_radler_tipps = "SELECT * FROM radler_tipps ORDER BY id DESC";
$query_limit_radler_tipps = sprintf("%s LIMIT %d, %d", $query_radler_tipps, $startRow_radler_tipps, $maxRows_radler_tipps);
$radler_tipps = mysql_query($query_limit_radler_tipps, $radler_db) or die(mysql_error());
$row_radler_tipps = mysql_fetch_assoc($radler_tipps);

if (isset($_GET['totalRows_radler_tipps'])) {
  $totalRows_radler_tipps = $_GET['totalRows_radler_tipps'];
} else {
  $all_radler_tipps = mysql_query($query_radler_tipps);
  $totalRows_radler_tipps = mysql_num_rows($all_radler_tipps);
}
$totalPages_radler_tipps = ceil($totalRows_radler_tipps/$maxRows_radler_tipps)-1;

$queryString_radler_tipps = "";
if (!empty($_SERVER['QUERY_STRING'])) {
  $params = explode("&", $_SERVER['QUERY_STRING']);
  $newParams = array();
  foreach ($params as $param) {
    if (stristr($param, "pageNum_radler_tipps") == false && 
        stristr($param, "totalRows_radler_tipps") == false) {
      array_push($newParams, $param);
    }
  }
  if (count($newParams) != 0) {
    $queryString_radler_tipps = "&" . htmlentities(implode("&", $newParams));
  }
}
$queryString_radler_tipps = sprintf("&totalRows_radler_tipps=%d%s", $totalRows_radler_tipps, $queryString_radler_tipps);
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<!--
Radsportgruppe Ochsenfurt
Start: 26.02.2008
Letzte Aenderung: 16.07.2008
Autor: Matthias Grimm
Design: Konrad Grimm/Matthias Grimm
-->
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Radsportgruppe Ochsenfurt</title>
<meta http-equiv="content-language" content="de" />
<meta http-equiv="content-style-type" content="text/css" />
<meta name="language" content="de" />
<meta name="description" content="Die Webseite der Radsportgruppe des TVOchsenfurt." />
<meta name="robots" content="index, follow" />
<meta name="revisit-after" content="1 days" />
<meta name="author" content="Radsportgruppe Ochsenfurt" />
<meta name="keywords" content="Radsportgruppe Ochsenfurt, Rad, Fahrrad, Radsport, Ochsenfurt, TVO" />
<link href="css/screen.css" rel="stylesheet" type="text/css" />
<link rel="Shortcut Icon" href="/images/favicon.ico" />
</head>
<body>
<div id="container">
  <div id="header">
    <h1>Radsportabteilung im TVOchsenfurt</h1>
  </div>
  <div id="navigation">
    <ul>
      <li id="startbt"><a href="index.html">Start</a></li>
      <li><a href="ueberuns.html">Über uns</a></li>
      <li><a href="termine.html">Termine</a></li>
      <li><a href="news.php">News</a></li>
      <li><a href="bilder.html">Bilder</a></li>
      <li><a href="tipps.php">- Tipps</a></li>
      <li><a href="kontakt.html">Kontakt</a></li>
      <li><a href="links.html">Links</a></li>
    </ul>
  </div>
  <div id="mainContent">
    <h2>Tipps</h2>
    <p>&nbsp;</p>
    <?php if ($totalRows_radler_tipps == 0) { // Show if recordset empty ?>
      <p>Noch kein Eintrag</p>
      <?php } // Show if recordset empty ?>
    <?php if ($totalRows_radler_tipps > 0) { // Show if recordset not empty ?>
      <?php do { ?>
        <h4><?php echo $row_radler_tipps['tipps_titel']; ?> (Eingetragen am <?php echo $row_radler_tipps['tipps_datum']; ?>)</h4>
        <h5>von <?php echo $row_radler_tipps['tipps_name']; ?></h5>
        <p>
          <?php 
			$text = $row_radler_tipps['tipps_text'];
			echo links($text);
		?>
        </p>
        <p>&nbsp;</p>
        <?php } while ($row_radler_tipps = mysql_fetch_assoc($radler_tipps)); ?>
      <p class="browse">
        <?php if ($pageNum_radler_tipps > 0) { // Show if not first page ?>
          <a href="<?php printf("%s?pageNum_radler_tipps=%d%s", $currentPage, max(0, $pageNum_radler_tipps - 1), $queryString_radler_tipps); ?>">neuere Einträge</a>
          <?php } // Show if not first page ?>
        <?php if ($pageNum_radler_tipps < $totalPages_radler_tipps) { // Show if not last page ?>
          <a href="<?php printf("%s?pageNum_radler_tipps=%d%s", $currentPage, min($totalPages_radler_tipps, $pageNum_radler_tipps + 1), $queryString_radler_tipps); ?>">ältere Einträge</a>
          <?php } // Show if not last page ?>
      </p>
      <?php } // Show if recordset not empty ?>
  </div>
  <div id="footer">
    <h5>Radsportabteilung im TVOchsenfurt | <a href="impressum.html">Impressum</a></h5>
  </div>
  <div id="tvo_img"><a target="_blank" href="http://www.tvochsenfurt.de/"><img src="images/logo_tvorot.jpg" alt="TVO" name="tvo_img" /></a></div>
</div>
</body>
</html>
<?php
mysql_free_result($radler_tipps);
?>
