<?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.
*/
  // Pfad definieren
    $Path = str_replace('\\','/', __FILE__);
    $Path = str_replace('guestbook/guestbook_add.php', '', $Path);
  // Funktionen inkludieren
    include_once ($Path."gigkalender.ini.php");
    include_once ($Path."functions/standard.php");
    include_once ("functions.php");
    include_once ($Path."includes/frontend_language_selector.php");
  // Inhalt-Anfang
    // Variablen definieren
      foreach ($_POST as $key => $value)
      {
        if (get_magic_quotes_gpc()) $$key = stripslashes($value);
        else $$key = $value;
      }
      if (!isset($gb_text)) $gb_text = '';
      if (!isset($gb_EchteURL)) $gb_EchteURL = '';
      if (!isset($url)) $url = '';
      if (!isset($gb_name)) $gb_name = '';
      if (!isset($gb_ort)) $gb_ort = '';
      if (!isset($gb_email)) $gb_email = '';
      if (!isset($gb_icq)) $gb_icq = '';
      
      $gb_ip = $_SERVER['REMOTE_ADDR'];
      if (isset($_POST['senden'])) {$senden = $_POST['senden'];} else {$senden = '';}
      $Token = md5(uniqid('Token'));
      if (isset($_REQUEST['http-equiv'])) $http_equiv = $_REQUEST['http-equiv'];
        else $http_equiv = '';
      $messageIsSpam = messageIsSpam ($gb_text, $gb_ip, $gb_EchteURL, $url);
      
  echo '<div class="GigKalender"><div class="Guestbook">';
  if ($messageIsSpam!='') writeSpamLog ( $gb_name, $gb_ort, $gb_email, $gb_EchteURL, $url, $gb_icq, $gb_text, $gb_ip, $messageIsSpam, 'guestbook_add' );
    // Formular auf Fehler überprüfen
      if
      (
           ($senden!="")
        && ($gb_name!="")
        && ($gb_text!="")
        &&
        (
          ( ($gb_email!="") && checkEmail ($gb_email) )
          OR
          ( ($gb_email=="") )
        )
        &&
        (
          ( ($gb_EchteURL!="") && checkURL ($gb_EchteURL) )
          OR
          ( ($gb_EchteURL=="http://") )
          OR
          ( ($gb_EchteURL=="") )
        )
        &&
        (
          ( ($gb_icq!="") && checkICQNumber ($gb_icq) )
          OR
          ( ($gb_icq=="") )
        )
        && $messageIsSpam==''
      )
      {  
        if (!isFormReload( $gb_name, $gb_text, $gb_ip ))
        {
          if (EintragHinzufuegen ($gb_name, $gb_email, $gb_EchteURL, $gb_icq, $gb_text, $gb_ip, $gb_ort))
          { echo $L_126.'<br />'; }
          else
          { echo $L_127.'<br />'; }
        }
        else echo '<span class="ErrorMessage">'.$L_ERROR_Entry_already_exists.'</span>';
        // URL bestimmen
          if ( $SetupGuestbookURL=='' ) $URL = $http_equiv;
            else $URL = $SetupGuestbookURL;
          $URL = str_replace("&","&amp;",$URL);
        echo '<br /><br /><br /><a href="'.$URL.'">'.$L_155.'</a>';
      }
      else
      {
        $REQUEST_URI = str_replace("&","&amp;",$_SERVER['REQUEST_URI']);
        echo '<div id="GuestbookEntryForm">
                <form method="post" action="'.$REQUEST_URI.'" accept-charset="UTF-8" accept-charset="UTF-8">
                  <table summary="Formular">';
        // IP
          // Spamtest
            if ($senden!="" && $messageIsSpam=='ip')
            { echo '<tr><td></td><td class="ErrorMessage">'.$L_120.'<br /><br /></td><td></td></tr>'; }
        // Name
          if ($senden!="" && $gb_name=="")
          { echo '<tr><td></td><td class="ErrorMessage">'.$L_121.'</td><td></td></tr>'; }
          $gb_name = htmlspecialchars(stripslashes($gb_name));
          echo '<tr>
                  <td align="right" valign="top">'.$L_114.':</td>
                  <td><input type="text" name="gb_name" value="'.$gb_name.'" /></td>
                  <td valign="top">*</td>
                </tr>';
        // Ort
          $gb_ort = htmlspecialchars(stripslashes($gb_ort));
          echo '<tr>
                  <td align="right" valign="top">'.$L_GuestbookLocation.':</td>
                  <td><input type="text" name="gb_ort" value="'.$gb_ort.'" /></td>
                  <td valign="top">&nbsp;</td>
                </tr>';    
        // Email
          if ($senden!="" && $_POST['gb_email']!="" && !checkEmail ($gb_email))
          { echo '<tr><td></td><td class="ErrorMessage">'.$L_122.'</td><td></td></tr>'; }
          echo '<tr>
                  <td align="right" valign="top">'.$L_115.':</td>
                  <td><input type="text" name="gb_email" value="'.$gb_email.'" /></td>
                  <td valign="top">&nbsp;</td>
                </tr>';
        // Echte URL
          // Spamtest
            if ($senden!="" && $messageIsSpam=='domain')
            { echo '<tr><td></td><td class="ErrorMessage"><br />'.$L_128.'</td><td></td></tr>'; }
          if ( $gb_EchteURL == "") { $gb_EchteURL = "http://"; }
          if ( !stristr($gb_EchteURL, "http://" ) ) { $gb_EchteURL = "http://".$gb_EchteURL; }
          if ($senden!="" && $gb_EchteURL!="" && !checkURL ($gb_EchteURL))
          { echo '<tr><td></td><td class="ErrorMessage">'.$L_123.'</td></tr>'; }
          echo '<tr>
                  <td align="right" valign="top">'.$L_116.':</td>
                  <td><input type="text" name="gb_EchteURL" value="'.$gb_EchteURL.'" /></td>
                  <td valign="top">&nbsp;</td>
                </tr>';
        // Falsche URL um Spam abzufangen!
          echo '<tr style="display:none;">
                  <td align="right" valign="top">'.$L_117.':</td>
                  <td><input type="text" name="url" value="'.$url.'" /></td>
                  <td valign="top">&nbsp;</td>
                </tr>';
        // ICQ
          // ICQ-Nummer überprüfen
            if ($senden!="" && $_POST['gb_icq']!="" && !checkICQNumber($gb_icq) )
            { echo '<tr><td></td><td class="ErrorMessage">'.$L_164.'</td><td></td></tr>'; }
          echo '<tr>
                  <td align="right" valign="top">'.$L_118.':</td>
                  <td><input type="text" name="gb_icq" value="'.$gb_icq.'" /></td>
                  <td valign="top">&nbsp;</td>
                </tr>';
        // Nachricht
          // Spamtest
            if ($senden!="" && preg_match ( '|word:|', $messageIsSpam ) )
            { echo '<tr><td></td><td class="ErrorMessage">'.$L_124.'</td><td></td></tr>'; }
            if ($senden!="" && $messageIsSpam=='code')
            { echo '<tr><td></td><td class="ErrorMessage">'.$L_ERROR_Message_contains_invalide_characters.'</td><td></td></tr>'; }
          if ($senden!="" && ($_POST['gb_text']==""))
          { echo '<tr><td></td><td class="ErrorMessage">'.$L_125.'</td><td></td></tr>'; }
          $gb_text = htmlspecialchars(stripslashes($gb_text));
          echo '<tr>
                  <td align="right" valign="top">'.$L_119.':</td>
                  <td><textarea name="gb_text" rows="5" cols="">'.$gb_text.'</textarea></td>
                  <td valign="top">*</td>
                </tr>';
        // Button
          $SCRIPT_URI = str_replace("&","&amp;",$_SERVER['HTTP_REFERER']);
             echo '<tr>
                  <td>&nbsp;</td>
                  <td>
                    <input type="submit" value="'.$L_Button30.'" name="senden" class="button submitButton" />
                    <input type="button" value="'.$L_Button03.'" onclick="self.location.href=\''.$SCRIPT_URI.'\'" class="button"/>
                    <input type="hidden" name="http-equiv" value="'.$SCRIPT_URI.'" />
                    <input type="hidden" name="page" value="add" />
                  </td>
                  <td>&nbsp;</td>
                </tr>
              </table>
       	    </form>
          </div>';
      }
   echo '</div></div>';
?>