예제 #1
0
파일: admin.php 프로젝트: SirTekno/cfa_dev
            } else {
                $post_data[$value] = "";
            }
        }
        $conditions[$category] = substr($conditions[$category], 0, -4);
        if ($data) {
            $conditions[$category] = $conditions[$category] . ")";
        } else {
            $conditions[$category] = "";
        }
    }
    $filter = "";
    foreach ($conditions as $key => $value) {
        if (!empty($value)) {
            $filter = $filter . $value . " AND ";
        }
    }
    $filter = substr($filter, 0, -5);
} else {
    // If no post operation is set, don't load anything from DB.
    $filter = "nothing";
}
$farmer = new FarmerForm();
$landO = new LandownerForm();
$farmer->load_by_filter($filter);
$landO->load_by_filter($filter);
$logout = "logout_button.php";
$page_title = "Admin page";
$panel_heading = "Welcome back, " . $_SESSION['first_name'] . '!';
$page_body = "admin_template.php";
include "templates/template.php";
예제 #2
0
<?php

include "models/landowner_model.php";
include_once "models/model_form.php";
session_start();
//populate
if (isset($_SESSION['type'])) {
    if ($_SESSION['type'] == "Landowner") {
        $form = new LandownerForm();
        $form->load_by_pk($_SESSION['usr_id']);
    } elseif ($_SESSION['type'] == "Administrator") {
        if (isset($_POST['landowner_id'])) {
            $form = new LandownerForm();
            $form->load_by_pk($_POST['landowner_id']);
        } else {
            header('Location: admin.php');
        }
    } else {
        header('Location: index.php');
    }
    //handle post operation
    $saved = false;
    if (isset($_POST['submit'])) {
        $form->load_from_post();
        // Sets the "describe" fields to not required if the checkbox isn't set
        if (!$form->fields['to_other']->value) {
            $form->fields['terms_other']->set_required(false);
        }
        if (!$form->fields['housing']->value) {
            $form->fields['describe_housing']->set_required(false);
        }
예제 #3
0
<?php

session_set_cookie_params(0);
session_start();
if (!empty($_SESSION['email'])) {
    include "models/landowner_model.php";
    $form = new LandownerForm();
    $data = $form->load_from_post();
    $form = new LandownerForm();
    $data = $form->load_from_post();
    $form->fields['enabled']->set_value(true);
    if (!$form->fields['to_other']->value) {
        $form->fields['terms_other']->set_required(false);
    }
    if (!$form->fields['housing']->value) {
        $form->fields['describe_housing']->set_required(false);
    }
    if (!$form->fields['equipment']->value) {
        $form->fields['equipment_other']->set_required(false);
    }
    //store the data from the registraiton page to the fields array of the landowner object for later validation and insertion into the database
    $form->fields['first_name']->set_value($_SESSION['fname']);
    $form->fields['last_name']->set_value($_SESSION['lname']);
    $form->fields['email']->set_value($_SESSION['email']);
    $form->fields['first_name']->set_value($_SESSION['fname']);
    $form->fields['phone']->set_value($_SESSION['phone']);
    $form->fields['street']->set_value($_SESSION['street']);
    $form->fields['city']->set_value($_SESSION['city']);
    $form->fields['zip']->set_value($_SESSION['zip']);
    $form->fields['password']->new_password($_SESSION['password']);
    // If data is received, validate it.
예제 #4
0
파일: login.php 프로젝트: SirTekno/cfa_dev
 //if the fields are valid, do the login query
 //check if the typed password matches the one in the database, if so the user will be logged in and directed to the correct page, else redirect to login page
 $valid_password = false;
 $redirect = "";
 if ($login_fields['user_type'] == "Farmer") {
     $form = new FarmerForm();
     $checkQuery = $form->load_by_filter(array("email" => $_POST['email']));
     if ($checkQuery) {
         if ($form->fields['password']->authenticate($_POST['password'])) {
             $redirect = "Location: farmer_view.php";
             $valid_password = true;
         }
     }
 }
 if ($login_fields['user_type'] == "Landowner") {
     $form = new LandownerForm();
     $checkQuery = $form->load_by_filter(array("email" => $_POST['email']));
     if ($checkQuery) {
         if ($form->fields['password']->authenticate($_POST['password'])) {
             $redirect = "Location: landowner_view.php";
             $valid_password = true;
         }
     }
 }
 if ($login_fields['user_type'] == "Administrator") {
     $form = new AdminForm();
     $checkQuery = $form->load_by_filter(array("email" => $_POST['email']));
     if ($checkQuery) {
         if ($form->fields['password']->authenticate($_POST['password'])) {
             $redirect = "Location: admin.php";
             $valid_password = true;