1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
<html>
<head>
<title>Subscribe</title>
</head>
<body>
<?php
if (is_readable('names.inc')){
        $myFile = "names.inc";
        $fh = fopen($myFile, 'r');
        $theData = fread($fh, filesize($myFile));
}else{
        die("Could not read file. please <a href='mailto:[email protected]?subject=Subscribe to list: Can not read list'>contact support</a>");
}
if ( !$_POST['name'] ){
        ?>
        <form target="_self" method="post">
        Enter Your Name: <input type="textbox" name="name" /><input type="submit" value="Save" />
        </form>
        <?php
}else{
        $name=$_POST['name'];
        $values = "'$name',";
        $exist = strpos($theData, $values);
        if ( !$exist ){
                $fp = fopen("names.inc", "a") or die("Could not save. please <a href='mailto:[email protected]?subject=Subscribe to list: Can not save list'>contact support</a>");
                $numBytes = fwrite($fp, stripslashes($values)) or die("Couldn't write values to file!");
                fclose($fp);
                echo "You [$name] have been added to the list";
        }else{
                $fp = fopen("names.inc", "w") or die("Could not save. please <a href='mailto:[email protected]?subject=Subscribe to list: Can not save list'>contact support</a>");
                $list = str_replace("$values", "", $theData);
                $numBytes = fwrite($fp, stripslashes($list)) or die("Couldn't write values to file!");
                fclose($fh);
                echo "You [$name] were found on the list & have been removed";
        }
}
?>