Example #1
0
function login()
{
    require_once 'DBConnect.php';
    require_once 'DBCalls.php';
    require_once 'secSession.php';
    sec_session_start();
    $username = isset($_SESSION['username']) ? $_SESSION['username'] : false;
    $userType = isset($_SESSION['userType']) ? $_SESSION['userType'] : false;
    if ($userType == "reader") {
        $con = new DBConnect('marketplace');
    } else {
        if ($userType == "author") {
            $con = new DBConnect('workbench');
        } else {
            $con = false;
        }
    }
    if ($con) {
        $calls = new DBCalls();
        $loggedIn = $calls->loginCheck($con);
    } else {
        $loggedIn = false;
    }
    $GLOBALS['username'] = $username;
    $GLOBALS['userType'] = $userType;
    return $loggedIn;
}
Example #2
0
require_once "HTMLTemplate.php";
sec_session_start();
$redirectURL = isset($_GET['redirectURL']) ? $_GET['redirectURL'] : false;
$username = isset($_SESSION['username']) ? $_SESSION['username'] : false;
$userType = isset($_SESSION['userType']) ? $_SESSION['userType'] : false;
if ($userType == "reader") {
    $con = new DBConnect('marketplace');
} else {
    if ($userType == "author") {
        $con = new DBConnect('workbench');
    } else {
        $con = false;
    }
}
if ($con) {
    $calls = new DBCalls();
    $loggedIn = $calls->loginCheck($con);
} else {
    $loggedIn = false;
}
if ($loggedIn) {
    // logged in
    if ($userType == "reader") {
        new HTMLTemplate('readerHomepage', array('{curUser}', '{curType}'), array($username, $userType));
    } else {
        if ($userType == "author") {
            new HTMLTemplate('authorHomepage', array('{curUser}', '{curType}'), array($username, $userType));
        }
    }
} else {
    new HTMLTemplate('readerHomepage', false, false);
Example #3
0
     if ($username) {
         $con = new DBConnect('marketplace');
         $calls = new DBCalls();
         $products = $calls->getReaderBooks($con, $username);
     } else {
         echo "Not logged in";
     }
 } else {
     if ($type == "new") {
         $con = new DBConnect('marketplace');
         $calls = new DBCalls();
         $products = $calls->getNewBooks($con, $username);
     } else {
         if ($type == "recommended") {
             $con = new DBConnect('marketplace');
             $calls = new DBCalls();
             $products = $calls->getRecommendedBooks($con);
         }
     }
 }
 if ($products && gettype($products) == "array" && count($products) > 0) {
     $returnStr = '';
     $lineDel = '|';
     // $products is now an array of book ids. So we need to fetch each book for construction.
     foreach ($products as $product) {
         $book = $calls->getBookInfoByID($con, $product);
         $returnStr = $returnStr . $book . $lineDel;
     }
     echo $returnStr;
 } else {
     echo "No products yet";
<?php

/**
 * Created by PhpStorm.
 * User: cristina
 * Date: 3/3/2016
 * Time: 2:58 PM
 */
require_once '../../includes/main.php';
set_include_path(getIncludePath());
require 'DBConnect.php';
require 'DBCalls.php';
require 'secSession.php';
sec_session_start();
$passcode = filter_input(INPUT_POST, 'passAct', FILTER_SANITIZE_STRING);
$bookID = filter_input(INPUT_POST, 'bookID', FILTER_SANITIZE_STRING);
$con = new DBConnect('marketplace');
$calls = new DBCalls();
$bookURL = $calls->getBookURLFromID($con, $bookID);
$passCorrect = $calls->checkBookPasscode($con, $bookID, $passcode);
if ($passCorrect && $bookURL) {
    // SESSION var, so cleared when you exit the browser.
    $_SESSION['lastPass'] = $passcode;
    header("location:../books/{$bookURL}/index.php?");
} else {
    header("location:../books/{$bookURL}/index.php?badPass=true");
}
require 'DBCalls.php';
require 'HTMLTemplate.php';
require 'secSession.php';
// Clear the URL get variables (buy);
$url = $_SERVER['REQUEST_URI'];
$newURL = strtok($url, '?');
if ($newURL !== $url) {
    header("location:{$newURL}");
}
sec_session_start();
$depVersion = 16;
// TODO: Call the function to return the latest version
$releaseVersion = 1;
$username = isset($_SESSION['username']) ? $_SESSION['username'] : false;
$con = new DBConnect('marketplace');
$calls = new DBCalls();
$url = $_SERVER['PHP_SELF'];
$urlArr = explode("/", $url);
$bookName = array_pop($urlArr);
if ($bookName == "index.php") {
    $bookName = array_pop($urlArr);
}
$bookID = $calls->getBookIDFromURLName($con, $bookName);
$readerID = $calls->getIDFromReaderName($con, $username);
$ownsBook = $calls->ownsBook($con, $readerID, $bookID);
if (isset($_SESSION['lastPass'])) {
    $lastPass = $_SESSION['lastPass'];
    $passCheck = $calls->checkBookPasscode($con, $bookID, $lastPass);
}
$passCheck = isset($passCheck) ? $passCheck : false;
if ($ownsBook || isset($bookIsFree) && $bookIsFree || $passCheck) {
 * User: cristina
 * Date: 2/22/2016
 * Time: 9:19 PM
 */
require_once '../../includes/main.php';
set_include_path(getIncludePath());
require_once "DBConnect.php";
require_once 'DBCalls.php';
require_once 'secSession.php';
sec_session_start();
$username = isset($_SESSION['username']) ? $_SESSION['username'] : false;
$call = false;
$products = false;
if ($username) {
    $con = new DBConnect('workbench');
    $calls = new DBCalls();
    $products = $calls->getAuthorProjects($con, $username);
} else {
    echo "Not logged in";
}
$publisherCon = new DBConnect('publishers');
$publisherID = $calls->getPublisherIDByAuthorName($con, $username);
$publisherName = $calls->getPublisherNameByID($publisherCon, $publisherID);
if ($products && gettype($products) == "array" && count($products) > 0) {
    // $products is now an array of book ids. So we need to fetch each book for construction.
    $ret = array();
    foreach ($products as $product) {
        $project = $calls->getProjectInfoByID($con, $product);
        // $project["publisherName"] => $publisherName;
        array_push($ret, $project);
    }
$password = filter_input(INPUT_POST, 'p', FILTER_SANITIZE_STRING);
$username = filter_input(INPUT_POST, 'username', FILTER_SANITIZE_STRING);
$usertype = filter_input(INPUT_POST, 'userType', FILTER_SANITIZE_STRING);
if (isset($username, $password, $usertype)) {
    if (strlen($password) != 128) {
        // The hashed pwd should be 128 characters long.
        // If it's not, something really odd has happened
        header("Location:../error.php?num=512");
    } else {
        if ($usertype == "reader") {
            $con = new DBConnect('marketplace');
            $calls = new DBCalls();
        } else {
            if ($usertype == "author") {
                $con = new DBConnect('workbench');
                $calls = new DBCalls();
            } else {
                echo "error: Bad usertype of {$usertype}";
            }
        }
        if ($con) {
            $loggedIn = $calls->login($con, $username, $password, $usertype);
            if ($loggedIn === true) {
                header("Location:../loggedIn.php");
            } else {
                $error = explode(":", $loggedIn);
                if ($error[0] == "dev error") {
                    $mesgForMe = $error[1];
                    // TODO: Handle development errors somehow...
                    header("Location:../error.php");
                } else {