Beispiel #1
0
function main($title = "")
{
    $f = new FormLib();
    if (isset($_POST["submitTest"])) {
        require_once "includes/dbconvars.php";
        @($db = mysql_connect($dbhost, $dbuser, $dbpwd)) or die("Could not connect");
        @mysql_select_db($dbname, $db) or die("Could not select database");
        checkForm($f, $db);
        if (!$f->isError()) {
            // data is OK
            processData($f, $db);
            $refPage = DEFAULT_PAGE;
            if (isset($_SESSION["refPage"])) {
                $refPage = $_SESSION["refPage"];
                // Session var no longer needed
                unset($_SESSION["refPage"]);
            }
            redirect($refPage);
        }
        mysql_close($db);
    }
    include "includes/header.php";
    showContent($title, $f);
    include "includes/footer.php";
}
Beispiel #2
0
function main($title = "")
{
    $f = new FormVerifier();
    $errors = "";
    if (isset($_POST["submitTest"])) {
        $errors = checkForm($f);
        if (!$errors) {
            processData($f);
            echo "Thank you for your order<br />";
            print "Estimated delivery date is " . shipDate();
        }
    }
    include "includes/header.php";
    showContent($title, $f);
    include "includes/footer.php";
}
Beispiel #3
0
function main($title = "")
{
    $f = new FormVerifier();
    if (isset($_POST["submitTest"])) {
        checkForm($f);
        if (!$f->isError()) {
            // data is OK
            processData($f);
            $refPage = DEFAULT_PAGE;
            if (isset($_SESSION["refPage"])) {
                $refPage = $_SESSION["refPage"];
            }
            redirect($refPage);
            // return to sender
        }
    }
    include "includes/header.php";
    showContent($title, $f);
    include "includes/footer.php";
}
        <label>Fahrenheit</label>
        <input type="radio" name="type" value="Fahrenheit" checked><br>

        <label>Celsius</label>
        <input type="radio" name="type" value="Celsius"><br>

        <label>Kelvin</label>
        <input type="radio" name="type" value="Kelvin"><br>

        <input type="submit" name="submit" value="Convert!">
    </form>
    ');
//end-form
$formIsSet = isset($_POST['submit']);
display($formIsSet ? checkForm($_POST['user-input']) : '');
/**
 * check if input is valid. If so perform conversion
 * *if not, return error
 * @param $userInput
 * @return null|string
 */
function checkForm($userInput)
{
    return is_numeric($userInput) ? convert($userInput) : USER_ERROR;
}
/**
 * Display form + message content (error, table)
 * @param $message
 */
function display($message)
Beispiel #5
0
    }
} elseif (isset($_POST['off'])) {
    unset($_SESSION['user']);
    unset($_SESSION['pwd']);
    unset($_SESSION['counter']);
}
?>

 <html>
    <head><title>Access Control with Sessions</title></head>
    <body>
      <h1>Access Control with Sessions</h1>

      <?php 
if ($_POST['_check_']) {
    checkForm();
} else {
    printForm();
}
function checkForm()
{
    global $name, $pwd;
    if (isset($_POST['show'])) {
        echo "<h3>Session contains " . $_SESSION["user"] . " and " . $_SESSION["pwd"] . "</h3>";
        echo "<h3>You have logged on " . $_SESSION["counter"] . " times</h3>";
    } else {
        if (!$name || !$pwd) {
            echo "<h3>Please enter username and password</h3>";
        } else {
            echo "<h3>You submitted {$name} and {$pwd}</h3>";
        }
<?php

/**
  Allows an admin to make an announcement for the 
  club. Adds announcement to the database. 
**/
// configuration
require "../includes/config.php";
if (empty($_SESSION["id"])) {
    redirect("login.php?go=makeAnnouncement.php");
}
// if form was submitted
if ($_SERVER["REQUEST_METHOD"] == "POST") {
    //validate submission
    $fields = array("club", "name", "privacy", "info", "all");
    checkForm($fields);
    if ($_POST["all"] == 1) {
        $clubs = query("SELECT * FROM clubs WHERE id = ?", $_POST["club"]);
    } else {
        $clubs = query("SELECT * FROM clubs WHERE name = ?", $_POST["club"]);
    }
    if (empty($clubs)) {
        apologize("wtf");
    }
    $theclub = $clubs[0];
    $clubName = $clubs[0]["name"];
    $clubID = $clubs[0]["id"];
    //add announcement
    $result = query("INSERT INTO announcements (id, userID, text, title, privacy) VALUES(?, ?, ?, ?, ?)", $clubID, $_SESSION["id"], $_POST["info"], $_POST["name"], $_POST["privacy"]);
    if ($result === false) {
        apologize("The corresponding event announcement could not be added.");
function license_management_page()
{
    echo '<div class="wrap">';
    echo '<h2>License Manager</h2>';
    $site_url = network_site_url('/');
    $lic = new LicenseManager($site_url, YOUR_VERIFICATION_SECRET_KEY, CREATION_SECRET_KEY);
    handleButtonClicks($lic);
    echo activateForm();
    echo deactivateForm();
    echo checkForm();
    echo createForm();
    echo '<p>' . getSavedData() . '</p><hr/>';
    showServerInfo();
    echo '</div>';
}
Beispiel #8
0
        if ($secret != $_SESSION['secret']) {
            throw new Exception('Неверно указано число с картинки');
        }
    } catch (Exception $exc) {
        return $exc->getMessage();
    }
}
function createUser()
{
    global $topsecret, $last_name, $first_name, $login, $password1, $email;
    $pwd = md5($password1 . $topsecret);
    $query = "insert into users (last_name,first_name,login,pwd,email)\r\n                values('{$last_name}','{$first_name}','{$login}','{$pwd}','{$email}')";
    $result = mysql_query($query);
    if (!empty($err)) {
        return $err;
    }
    if (!$result || mysql_affected_rows() < 1) {
        return 'Ошибка при записи' . mysql_error();
    }
    $_SESSION['user_id'] = mysql_insert_id();
    $_SESSION['user_name'] = $last_name . ' ' . $first_name;
}
unset($_SESSION['message']);
$err = checkForm();
if (empty($err)) {
    $err = createUser();
}
if (!empty($err)) {
    $_SESSION['message'] = $err;
}
header('Location: ./');