Пример #1
0
 /**
  * Load resource from the given table name
  * @param string $tableName
  */
 public static function loadFromDB($tableName = "resource")
 {
     $resources = TableGateway::loadAll($tableName, null, null, array(), "Resource");
     foreach ($resources as $resource) {
         Dispatcher::addResource($resource);
     }
 }
require_once 'CatManager.php';
//Connecting to the Manager class
require_once 'TableGateway.php';
//Connecting to the TableGateway
require_once 'Connection.php';
//Connecting to the Connection class
//=============================================================================
//Gets the the values from the post array of the edit manager form
$ID = $_GET['id'];
$authorName = $_POST['categoryManager'];
$bookName = $_GET['emailAddress'];
$sellPrice = $_POST['phone'];
$costPrice = $_POST['date'];
$productCatID = $_POST['location'];
//==============================================================================
echo '<pre>';
print_r($_POST);
echo '</pre>';
//Creates a new manager object to be passed into the databse
$authorName = new CatManager($ID, $authorName, $bookName, $sellPrice, $costPrice, $productCatID);
//as you're editing an already existing object in the database, the ID is required unlike the create form
$connection = Connection::getInstance();
$gateway = new TableGateway($connection);
$gateway->update($authorName);
header('location: Home.php');
//returns to the home page and prevents multiple subimssions if the user reloads the page
//Getting weird Errors here
//Keeps saying undefined variables for each value in the POST array
//No values are being passed into the POST array on the edit Manager form
//If I change the ID to the GET array it shows up in the Manager object
//However changing this for the rest of the values proved to be no help
Пример #3
0
 /**
  * @return array of type $this->className
  */
 public function load()
 {
     return TableGateway::loadMatching($this->tableName, $this->condition, $this->start, $this->num, $this->orderBy, $this->className, $this->methodName)->getArray();
 }
<?php

require_once 'CatManager.php';
require_once 'Connection.php';
require_once 'TableGateway.php';
require_once 'validateManager.php';
if ($_SERVER['REQUEST_METHOD'] === 'GET') {
    if (!isset($_GET['id'])) {
        die("Illegal request");
    }
    $id = $_GET['id'];
    $connection = Connection::getInstance();
    $gateway = new TableGateway($connection);
    $statement = $gateway->getManagerById($id);
    $row = $statement->fetch(PDO::FETCH_ASSOC);
    if (!$row) {
        die("Illegal request");
    }
} else {
    if ($_SERVER['REQUEST_METHOD'] === 'POST') {
        if (!isset($_POST['id'])) {
            die("Illegal request");
        }
        $id = $_POST['id'];
        $row = $formdata;
    } else {
        die("Illegal request");
    }
}
?>
<!DOCTYPE html>
<?php

require_once 'CatManager.php';
//Connecting to the Manager class
require_once 'TableGateway.php';
//Connecting to the TableGateway
require_once 'Classes/Connection.php';
//Connecting to the Connection class
//initializing variables and setting their value to the values in the post array from the CreateManagerForm
//=========================================================================================================
$authorName = $_POST['UserName'];
$bookName = $_POST['mail'];
$costPrice = $_POST['date'];
$sellPrice = $_POST['phone'];
$productCatID = $_POST['location'];
//=========================================================================================================
//Making a new manager object using the variable initialized above
$authorName = new CatManager(-1, $authorName, $sellPrice, $bookName, $costPrice, $productCatID);
//The ID value is -1 as the database will AUTO INCRIMENT the ID when it is passed into the database
//therefore no id is required from the user
$connection = Connection::getInstance();
$gateway = new TableGateway($connection);
$id = $gateway->insert($authorName);
header('location: Home.php');
//returns to the home page and prevents multiple subimssions if the user reloads the page
Пример #6
0
<?php

require "../libs/table_gateway.class.php";
require "../connections/main.php";
session_start();
//var_dump($_REQUEST);
//exit();
$_SESSION['query'] = $_REQUEST['query'];
$redir = "dashboard.php";
$data = array('ip' => $_SERVER['REMOTE_ADDR'], 'server' => $_SESSION['server'], 'nrp' => $_SESSION['nrp'], 'no' => $_SESSION['no'], 'query' => $_SESSION['query'], 'waktu' => date('Y-m-d H:i:s'), 'final' => 0);
if (isset($_REQUEST['save'])) {
    $redir = "confirmation.php";
} else {
    $t_qr = new TableGateway('quiz_result', $conf);
    $t_qr->push($data);
}
header('Location: ../' . $redir);
<?php

require_once 'CatManager.php';
//Connecting to the Manager class
require_once 'TableGateway.php';
//Connecting to the TableGateway
require_once 'Classes/Connection.php';
//Connecting to the Connection class
//==============================================================================
//If there is no ID in the GET array then cancel the request
if (!isset($_GET['id'])) {
    die("Illegal request");
}
$id = $_GET['id'];
//making a variable called id to hold the value of the the 'id' in the GET array
//==============================================================================
$connection = Connection::getInstance();
$gateway = new TableGateway($connection);
$gateway->delete($id);
//passes the ID into the delete function in the tablegateway
header('location: Home.php');
//returns to the home page and prevents multiple subimssions if the user reloads the page
        <?php 
require_once 'C:\\Users\\jamie\\Desktop\\Work\\Second Year\\Web Programming 2\\NetBeansProjects\\PhpProject2\\Classes\\Connection.php';
require_once 'TableGateway.php';
$Connection = Connection::getInstance();
$gateway = new TableGateway($Connection);
$statement = $gateway->getCategory();
?>
<!DOCTYPE html>
<html>
    <head>
        <meta charset="UTF-8">
        <title></title>
                <link rel="stylesheet" type="text/css" href="reset.css">
		<link rel="stylesheet" type="text/css" href="text.css">
                <link rel="stylesheet" type="text/css" href="styles/bootstrap.css">
		<link rel="stylesheet" type="text/css" href="style.css">
    </head>
    <body>
        <h1>Hyland Bookstore</h1>
        <ul>
            <li><a href="ViewManager.php">View Manager</a></li>
        </ul>
    </body>
   

        
    
    
</html>
<?php

require_once 'Classes/Connection.php';
require_once 'TableGateway.php';
require_once 'Classes/productTable.php';
//
//if (!is_logged_in()) {
//    header("Location: login_form.php");
//}
if (!isset($_GET) || !isset($_GET['id'])) {
    die('Invalid request');
}
$id = $_GET['id'];
$connection = Connection::getInstance();
$categoryGateway = new TableGateway($connection);
$productGateway = new productTable($connection);
$Category = $categoryGateway->getManagerById($id);
$product = $productGateway->getProductsByCategoryID($id);
?>


<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Frameset//EN" "http://www.w3.org/TR/html4/frameset.dtd">

<html>
    <head>
        <meta charset="UTF-8">
        <title></title>
        <?php 
require 'utils/styles.php';
?>
        <?php 
Пример #10
0
 /**
  * Perform the authorisation request
  * @return DbAuth
  */
 public function authenticate()
 {
     $credential = $this->getCredential();
     Assert::isNotEmpty($credential, "You must set a password before authentication");
     $identity = $this->getIdentity();
     Assert::isNotEmpty($identity, "You must set an username before authentication");
     //We first get user from db if its exists
     $criteria = new Criteria(Restriction::is($this->identityColumn, $identity));
     $records = TableGateway::loadMatching($this->table, $criteria);
     if ($records->count() == 0) {
         return false;
     }
     /** @var $user Customer */
     $user = $records->current();
     //Yes we need to reassign this to variable.
     $credentialColumn = $this->credentialColumn;
     $credentialSaltColumn = $this->credentialSaltColumn;
     $slatedCredentialColumn = $this->slatedCredentialColumn;
     //We check if we should use salt checking
     if (!empty($credentialSaltColumn) && !empty($slatedCredentialColumn) && !empty($user->{$credentialSaltColumn}) && !empty($user->{$slatedCredentialColumn})) {
         //Fo salt we check if password is same like credential
         $authenticated = SaltPasswordManager::checkPasswordWithHash($user->{$slatedCredentialColumn}, $user->{$credentialSaltColumn}, $this->credential);
     } else {
         //If don't have salt we must check if we have hashed password
         if ($this->hash) {
             $credential = SaltPasswordManager::generateSimpleHash($this->credential);
         } else {
             $credential = $this->credential;
         }
         //We check if we are authenticated
         $authenticated = $credential == $user->{$credentialColumn};
         /**
          * If we are authenticated and have original password, we can create and add slated password for user and
          * we should do it. It means we are not Auto Login or something.
          */
         if ($authenticated && $this->hash) {
             if (!empty($credentialSaltColumn) && !empty($slatedCredentialColumn)) {
                 list($password, $hash) = SaltPasswordManager::generateSaltedPassword($this->credential);
                 $this->addSalt($user, $password, $hash);
             }
         }
     }
     if (empty($authenticated)) {
         return false;
     }
     return $this->authorisedId = $records->current()->__get($this->identityKey);
 }