<?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.
*/
header("content-type: text/html; charset=utf-8");
echo '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
        <html xmlns="http://www.w3.org/1999/xhtml">
          <head>
            <meta http-equiv="content-type"	content="text/html;charset=utf-8" />
            <link rel="stylesheet" type="text/css" media="screen, print" href="../styles/gigkalender.css" />
            <title></title>
          </head>
          <body>';
// Pfad definieren
  $Path = str_replace('\\','/', __FILE__);
  $Path = str_replace('guestbook/guestbook_delete.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");
  include($language);

if (isset($_REQUEST['http-equiv'])) $http_equiv = $_REQUEST['http-equiv'];
  else $http_equiv = '';
//echo $_REQUEST['http-equiv'].'<br>';
// Variablen definieren
  foreach ($_POST as $key => $value) {
    if (!is_array($value))
      $$key = stripslashes($value);
    else
      $$key = $value; }
echo '<div class="GigKalender"><div class="Guestbook">';
// Inhalt-Anfang
  if ( $_REQUEST['code']!="" )
  {
    if ( isGuestbookEntryPresent( $_REQUEST['code']) )
    {
      if ( isset($_POST['delete']))
      {
        $Code = $_REQUEST['code'];
        // Get IP from Guestbook entry
          $SQLQuery="SELECT IP FROM ".$prefix."guestbook WHERE CODE = '".$Code."' LIMIT 1";
          $Result = mysqli_query($db, $SQLQuery);
          if ($Result)
          {
            if ( mysqli_num_rows($Result)==1)
            {
              $temp = mysqli_fetch_assoc($Result);
              $IP = $temp['IP'];
            }
            else echo 'Error 52<br />';
          }
        $SQLQuery = "DELETE FROM ".$prefix."guestbook WHERE Code = '$Code'";
        $Result = mysqli_query($db, $SQLQuery);
        if ($Result)
        {
          echo $L_129.'<br />';
          // Block IP adress
          if (isset($blockIP)) {
            blockIP($IP); }
        }
        else { echo $L_130; }
      }
      if ( isset($_POST['cancel']) )
      {
        echo $L_131;
      }
      if ( isset($_POST['delete']) OR isset($_POST['cancel']) )
      {
        // URL bestimmen
          // URL when deleting as admin from the guestbook
          $URL = $_POST['http-equiv'];
          // get GB-URL if accessed from Email
          if ($URL=='') {
            //echo 'get URL from Setup<br>';
            //$URL = getFrontendURL('SetupGuestbookURL');
            $URL = $SetupGuestbookURL;
            }
          //echo $URL.'<br>';
        echo '<br /><br />';
        if ($URL!="")
          echo '<a href="'.$URL.'">'.$L_155.'</a>';
        else // can not set link back to GB
          echo '<span class="ErrorMessage">NOTICE: Variable $SetupGuestbookURL in gigkalender.ini.php NOT set.</span>';
      }
      //if ( !isset($_POST['delete']) AND !isset($_POST['cancel'] ))
      else
      {
        $SCRIPT_URI = str_replace("&","&amp;",$_SERVER['HTTP_REFERER']);
        //echo $SCRIPT_URI.'<br>';
        echo $L_132.'<br /><br />
        <form method="post" action="'.$_SERVER['PHP_SELF'].'?page=delete&amp;code='.$_REQUEST['code'].'" accept-charset="UTF-8">
          <fieldset>
            This guestbook entry is spam?<br />
            &nbsp;<input type="checkbox" name="blockIP" value="1" class="checkbox" />
             &nbsp;Block the IP address!<br />
            <br />
            <input name="delete" type="submit" value="'.$L_Button02.'" class="button" />
            <input name="cancel" type="submit" value="'.$L_Button03.'" class="button" />
            <input type="hidden" name="http-equiv" value="'.$SCRIPT_URI.'" />
          </fieldset>
        </form>';
      }
    }
    else echo '<span class="ErrorMessage">'.$L_217.' (Code: '.$_REQUEST['code'].')</span><br />';
  }
  else { echo '<span class="ErrorMessage">'.$L_133.'</span>'; }
  echo '</div></div>';
  echo '</body>
      </html>';
?>