<?php
/*
    CREATIVE COMMONS - Attribution-No Derivative Works 3.0 Germany:
    - You may not alter, transform, or build upon this work.
    - Dieses Werk darf nicht bearbeitet oder in anderer Weise verändert werden.
*/
function getVenueVarFromVenueVar ($FieldName, $FieldValue, $Var)
{
  global $DB_PREFIX;
  $SQL = "SELECT ".$Var." FROM ".DB_PREFIX."venues WHERE ".$FieldName."='".$FieldValue."' LIMIT 1";
  $result = mysql_query($SQL);
  if ( mysql_num_rows($result)==1)
  {
    $temp=mysql_fetch_assoc($result);
    return $temp[$Var];
  }
  else return false;
}

function getVenueVarFromVenueID ($VenueID, $Var)
{
  global $DB_PREFIX;
  $SQL = "SELECT ".$Var." FROM ".DB_PREFIX."venues WHERE VenueID='".$VenueID."' LIMIT 1";
  $result = mysql_query($SQL);
  if ( mysql_num_rows($result)==1)
  {
    $temp=mysql_fetch_assoc($result);
    return $temp[$Var];
  }
  else return false;
}

function isVenueInDatabase($VenueName)
{
  global $DB_PREFIX;
  $string = strtolower($VenueName);
  $doppelteVorhanden = false;
  $sql = 'SELECT * FROM ' .$prefix."venues";
  $result = mysql_query($sql);
  $menge = mysql_num_rows($result);
  while($row = mysql_fetch_row($result))
    if (strtolower($row[5]) == $string) $doppelteVorhanden = true;
  if ($VenueName!='' && $doppelteVorhanden) return true;
    else return false;
}

function addVenue ( $Venue, $Job )
{
  global $DB_PREFIX;
  global $L_042;
  $amountVenues = count($Venue);
  for ($i=0; $i<$amountVenues; $i++)
  {
    // Entfernt HTML- und PHP-Tags aus einer Zeichenkette
      $Venue[$i]=strip_tags($Venue[$i]);
    // Maskieren spezieller Zeichen für die Verwendung in einer SQL-Anweisung
      $Venue[$i] = mysql_real_escape_string($Venue[$i]);
  }
  list ($VenueID, $VenueName, $VenueURL, $VenueCountry, $VenueDistrict, $VenuePostalCode, $VenueCity)
    = $Venue;
  if ( $VenueURL=='http://' ) $VenueURL='';
  if ( $VenueURL!="" AND !stristr( $VenueURL, 'http://' ) ) $VenueURL = 'http://'.$VenueURL;
  // Abschließendes Slash bei URLs entfernen
    $VenueURL = getURLWithoutFinalSlash ($VenueURL);
  if ( $Job=="add" )
  {
    $SQL = "INSERT INTO ".DB_PREFIX."venues ( VenueName, VenueURL, VenueCountry, VenueDistrict, VenuePostalCode,
    VenueCity ) VALUES ( '$VenueName', '$VenueURL', '$VenueCountry', '$VenueDistrict', '$VenuePostalCode',
    '$VenueCity')";
    $resultat = mysql_query($SQL);
    if ($resultat) return true;
      else return false;
  }
  elseif ( $Job=="edit" )
  {
    $SQL = "UPDATE ".DB_PREFIX."venues SET VenueName = '$VenueName', VenueURL = '$VenueURL',
      VenueCountry = '$VenueCountry', VenueDistrict = '$VenueDistrict', VenuePostalCode = '$VenuePostalCode',
      VenueCity = '$VenueCity' WHERE VenueID = '$VenueID' LIMIT 1";
    $resultat = mysql_query($SQL);
    if ($resultat) return true;
      else return false;
  }
}

function AmountOfVenuesInDatabase ()
  {
    global $DB_PREFIX;
    $sql = "SELECT count(*) as zahl  FROM ".DB_PREFIX."venues";
    $result = mysql_query($sql);
    $row = mysql_fetch_array($result);
    return $row['zahl'];
  }
?>