Esempio n. 1
0
function checkStorySubmission()
{
    //make sure posted storyName is valid
    $num = htmlentities($_POST['storyNum'], ENT_QUOTES);
    if ($num < 1 || $num > 3) {
        showStoryChoice();
        return;
    }
    $filename = "story" . $num . ".txt";
    $subfilename = "story" . $num . "sub.txt";
    $contents = file_get_contents($filename);
    $contents2 = file_get_contents($subfilename);
    print "<div><h2>Original Story</h2>\n";
    print $contents;
    print "<h2> Modified Sub Story</h2>\n";
    print $contents2;
    print "<h2> Found Whole Matches </h2>\n";
    $pattern = "/\\[(.*?)\\]/";
    preg_match_all($pattern, $contents2, $matches);
    for ($i = 0; $i < count($matches[0]); $i++) {
        print $matches[0][$i] . "<br>";
    }
    print "<h2> Subgroup of Matches </h2>";
    for ($i = 0; $i < count($matches[0]); $i++) {
        print $matches[1][$i] . "<br>";
    }
    print "<br><br>\n";
    startOverLink();
    print "</div>\n";
}
Esempio n. 2
0
function checkForm()
{
    $name = htmlentities($_GET['theUser'], ENT_QUOTES);
    $area = htmlentities($_GET['areaCode'], ENT_QUOTES);
    $phone1 = htmlentities($_GET['phone1'], ENT_QUOTES);
    $phone2 = htmlentities($_GET['phone2'], ENT_QUOTES);
    $errorMessage = "";
    if ($name == "") {
        $name = "";
        $errorMessage .= "<h3> You must enter your name. </h3>\n";
    }
    if ($area == "" || !is_numeric($area)) {
        $area = "";
        $errorMessage .= "<h3> You must enter a valid area code.\n";
    }
    if ($phone1 == "" || !is_numeric($phone1)) {
        $phone1 = "";
        $errorMessage .= "<h3> You must enter a valid exchange number.\n";
    }
    if ($phone2 == "" || !is_numeric($phone2)) {
        $phone2 = "";
        $errorMessage .= "<h3> You must enter a valid subscriber (end) number.\n";
    }
    if ($errorMessage) {
        print $errorMessage;
        showForm($name, $area, $phone1, $phone2);
    } else {
        if ($area == 512) {
            $result = "<br /> is from the Austin area. \n";
        } elseif ($area == 830 || $area == 210) {
            $result = "<br /> is from the San Antonio Area. \n";
        } elseif ($area == 713 || $area == 832 || $area == 409) {
            $result = "<br /> is from the Houston Area. \n";
        } else {
            $result = "<br />  is from another galaxy, far , far away. \n";
        }
        print "<h2> Hello {$name}, The phone number ({$area}-{$phone1}-{$phone2})<br /> {$result} </h2> \n";
    }
    //end else
    startOverLink();
}
Esempio n. 3
0
function displayMadlib()
{
    $num = $_POST['storyNum'];
    $subs = $_POST['subs'];
    $error = "";
    for ($i = 0; $i < count($subs); $i++) {
        if ($subs[$i] == "") {
            $error = "<br /> Please fill out form entirely. Information is missing.";
        }
    }
    if ($error) {
        print $error;
        storySubmissionForm($subs);
    } else {
        $pattern = "/\\[(.*?)\\]/";
        $subfilename = "story" . $num . "sub.txt";
        $contents = file_get_contents($subfilename);
        preg_match_all($pattern, $contents, $matches);
        for ($i = 0; $i < count($matches[0]); $i++) {
            //create a replacements number
            $replace = " " . $subs[$i] . " ";
            $contents = str_replace($matches[0][$i], $replace, $contents);
        }
        print "<h2> Your story </h2>" . $contents;
        print "<br /><br />";
        startOverLink();
    }
}
Esempio n. 4
0
function doLogout()
{
    $self = $_SERVER['PHP_SELF'];
    $_SESSION['loginValid'] = 0;
    startOverLink();
}
Esempio n. 5
0
function showBoth()
{
    $image = "../images/myImage.png";
    $thumbnail = "../images/thumbnail.png";
    createThumb($image, $thumbnail, 90);
    print "\n<h3>Original image: </h3>\n" . "<img src='{$image}' alt='test picture' />";
    print "\n</h3> <br /> <br /> ";
    print "\n<h3>Thumbnail image: </h3> \n" . "<img src='{$thumbnail}' alt='thumbnail' />\n";
    print "<br /><br />";
    startOverLink();
}
Esempio n. 6
0
function checkSubSubmission()
{
    $self = $_SERVER['PHP_SELF'];
    $num = htmlentities($_POST['storyNum'], ENT_QUOTES);
    if ($num < 1 || $num > 3) {
        showStoryChoiceForm();
        return;
    }
    $filename = "story" . $num . "Sub.txt";
    $subcontents = file_get_contents($filename);
    $subcontents = nl2br($subcontents);
    $pattern = "/\\[(.+?)\\]/";
    $matches = array();
    preg_match_all($pattern, $subcontents, $matches);
    $subs = $_POST['subs'];
    //check if subs is empty, return to substitution form if so
    $error = "";
    for ($i = 0; $i < count($subs); $i++) {
        if ($subs[$i] == "") {
            $error .= "<br />Nothing entered. Please reenter input.";
        }
    }
    if ($error) {
        print $error;
        showSubChoiceForm($subs);
    } else {
        for ($i = 0; $i < count($subs); $i++) {
            $subcontents = str_replace($matches[0][$i], $subs[$i], $subcontents);
        }
        print "<h3> Here is the substituted story: </h3>\n";
        print $subcontents;
        startOverLink();
    }
}