<?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 getOrganizerVarFromOrganizerVar ($FieldName, $FieldValue, $Var)
{
  global $DB_PREFIX;
  $SQL = "SELECT ".$Var." FROM ".DB_PREFIX."organizers WHERE ".$FieldName."='".$FieldValue."' LIMIT 1";
  $result = mysql_query($SQL);
  if ( mysql_num_rows($result)==1)
  {
    $temp=mysql_fetch_assoc($result);
    //echo $temp[$Var].'<br />';
    return $temp[$Var];
  }
  else return false;
}

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

function isOrganizerInDatabase($OrganizerName)
{
  global $DB_PREFIX;
  $string = strtolower($OrganizerName);
  $doppelteVorhanden = false;
  $sql = 'SELECT * FROM ' .$prefix."organizers";
  $result = mysql_query($sql);
  $menge = mysql_num_rows($result);
  while($row = mysql_fetch_row($result))
    if (strtolower($row[1]) == $string) $doppelteVorhanden = true;
  if ($doppelteVorhanden) return true;
    else return false;
}

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

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