<?php
/**
 * Main index page for guestbook. 
 * 
 * This application is designed for website generated by RVSiteBuilder.
 * Unauthorized copy of the script is prohibited.
 * 
 * @version 1.00
 * @author pairote@rvglobalsoft.com
 * @copyright Copyright &copy; http://www.rvglobalsoft.com/index.php/rvsitebuilder/sitebuilderbilling/action/terms
 * @package rvsitebuilder
 */
 require_once('include.php');
 $comfirmPassword = $_POST['comfirmPassword'];
 $key = (isset($_GET['key']))? $_GET['key'] : $_POST['key'];
 $error = 0;
 
 if( md5($comfirmPassword) != $aConfig['apass'] ) {
 	// Try again
    $error = 1;
    include_once('delete.php');
 }
 else {
 	// delete msg
    $dataFile = file(SCRIPT_PATH . 'data/dataAsRaw.txt');  
    $file = fopen(SCRIPT_PATH . 'data/dataAsRaw.txt', 'w');
    foreach ($dataFile as $line) { 
        if (ereg("^$key", $line)) {
        	continue;
        }
        
        fwrite($file, $line);
    }
    fclose($file);        
    
    showMessage($aConfig, $aLang);  
 }
 
 // End script; don't exit'
 function showMessage($aConfig, $aLang)
 {
  $name = (isset($_GET['name']))? $_GET['name'] : $_POST['name'];
   echo "<table cellpadding=\"0\" cellspacing=\"0\" class=\"borderoutside\" width=\"90%\" align=\"center\">\n" . 
            "    <tr>\n" . 
            "        <td align=\"right\">" .
//            "        <img src=\"" . SCRIPT_URL . $aConfig['theme'] . "/images/admin.gif\" alt=\"\" width=\"12\" height=\"12\" /> \n" . 
//            "        <a href=\"?page=admin\" class=\"signlink\">Administration</a> | \n" .
            "        <img src=\"" . SCRIPT_URL . $aConfig['theme'] . "/images/signicn.gif\" alt=\"\" width=\"12\" height=\"12\" /> \n" . 
            "        <a href=\"?page=list\" class=\"signlink\">View the Guestbook</a>\n" . 
            "        </td>\n" . 
            "    </tr>\n" . 
            "    <tr>\n" . 
            "        <td><b>" . strftime($aConfig['date_format']) . "</b><br />\n" . 
            "        </td>\n" . 
            "    </tr>\n" . 
            "    <tr>\n" . 
            "        <td height=\"10\"></td>\n" . 
            "    </tr>\n" .
            "    <tr>\n" . 
            "        <td>\n" . 

            "        <table cellpadding=\"1\" cellspacing=\"1\" width=\"100%\">\n" . 
            "            <tr>\n" . 
            "                 <td class=\"bgtabcolor\" height=\"2\"><img src=\"" . SCRIPT_URL . $aConfig['theme'] . "/images/spacer.gif\" alt=\"\" width=\"1\" height=\"2\" /></td>\n" . 
            "            </tr>\n" .             
            "            <tr>\n" . 
            "                <td class=\"txtheadb\">" . $aLang['Deleted comment'] . ":</td>\n" .
            "            </tr>\n" . 
            "            <tr>\n" . 
            "                <td class=\"bgtabcolor\" height=\"4\"></td>\n" . 
            "            </tr>\n" . 
            "            <tr>\n" . 
            "                <td class=\"bglinecolor\" height=\"1\"></td>\n" . 
            "            </tr>\n" . 
            "            <tr>\n" . 
            "                <td></td>\n" . 
            "            </tr>" .
            "        </table>";       
         
        echo '<div align="center"><br /><br /><br />';        
        echo $aLang['Comment from'] . ' ' . $name . ' ' . $aLang['was successfully deleted.'];
        echo '<br /><a href="?page=list">' . $aLang['delete message notify1'] . ' ' . $aLang['delete message notify2'] . '</a>';
        echo '<br /><br /><br /></div>';
        
        echo '   </td>';
        echo '  </tr>'; 
        echo '</table>'; 	
 }
    
?>