Beispiel #1
0
<?php

/* Reformatted 12.11.2015 */
// Helper functions and includes
include_once '/var/www/html/Lux/Core/Helper.php';
// Create database Connection
$db = new Db("Auth");
$OUTPUT = new Output();
// Get Request Data
$REQUEST = new Request();
// Admin priveleges needed
$RULES = new Rules(5, "providers");
// Selects Collection from Database Connection
$collectionName = Helper::getCollectionName($REQUEST, "Providers");
$collection = $db->selectCollection($collectionName);
$query = Helper::formatQuery($REQUEST, "provider_name");
// Used for Analytics
$LOG = new Logging("API.query");
$LOG->log($RULES->getId(), 12, $query, 100, "User Queried Provider");
// Format Query
$query = Helper::formatQuery($REQUEST, "provider_name", null, array("protocol" => "App"));
// Find Documents in Collection
$documents = $collection->find($query);
// Output
$OUTPUT->success(1, $documents);
?>

  
Beispiel #2
0
<?php

/* Reformatted 12.11.2015 */
// Helpers and includes
include_once '/var/www/html/Lux/Core/Helper.php';
// Create Database Connection
$DB = new Db("Inventory");
$OUTPUT = new Output();
// Get Request Data
$REQUEST = new Request();
// User needs to be logged in for access
$RULES = new Rules(1, "cart");
// Select Collection from Connection
$collectionName = Helper::getCollectionName($REQUEST, "Cart");
$collection = $DB->selectCollection($collectionName);
// Format Query
$query = array("user_id" => $RULES->getId());
// Used for anayltics
$LOG = new Logging("OAuth.query");
$LOG->log($RULES->getId(), 72, $query, 100, "OAuth Providers Queried");
// Format Limits (Skip, Limit)
$options = Helper::formatLimits($REQUEST);
// Find Documents
$documents = $collection->find($query, $options);
// Output
$OUTPUT->success(0, $documents);
?>

  
Beispiel #3
0
<?php

// Helper functions and includs
include_once '/var/www/html/Lux/Core/Helper.php';
$db = new Db("Inventory");
$OUTPUT = new Output();
$REQUEST = new Request();
$collection = $db->selectCollection("Cart");
$RULES = new Rules(1, "cart");
$REQUEST = new Request();
// get the asset, push it into the cart that is selected
$collectionName = $REQUEST->get("collection", "Standard");
$cartName = $REQUEST->get("wishlist", "Default");
$document = $collection->findAndModify(array("user_id" => $RULES->getId()), array('$push' => array("wishlist." . $cartName => MongoDBRef::create($collectionName, $REQUEST->get("id"), "Assets"))));
// Used for analytics
$LOG = new Logging("Cart.order");
$LOG->log($RULES->getId(), 43, $REQUEST->get("id"), 100, "User Wished for item");
$OUTPUT->success(0, $document, null);
Beispiel #4
0
<?php

include_once '/var/www/html/Lux/Core/Helper.php';
$db = new Db("Scoreboard");
$OUTPUT = new Output();
$REQUEST = new Request();
$collection = $db->selectCollection("Users");
$RULES = new Rules(1, "scoreboard");
$REQUEST = new Request();
$quantity = intval($REQUEST->get("quantity", "1"));
$asset_id = $REQUEST->get("asset_id");
$document = $collection->findAndModify(array("user_id" => $RULES->getId()), array('$inc' => array("assets." . $asset_id . ".quantity" => $quantity)));
$LOG = new Logging("Scoreboard.asset");
$LOG->log($RULES->getId(), 61, $REQUEST->get("asset_id"), $quantity, "User added item to scoreboard Possessions");
$OUTPUT->success(0, $document, null);
Beispiel #5
0
<?php

/* Reformatted 12.11.2015 */
// Helpers and inludes
include_once '/var/www/html/Lux/Core/Helper.php';
// Create Database Connection
$DB = new Db("SocialNetwork");
$OUTPUT = new Output();
// get Request Variables
$REQUEST = new Request();
// Select Collection From Databse Connection
$collectionName = Helper::getCollectionName($REQUEST, "Users");
$collection = $DB->selectCollection($collectionName);
// Values which are accepted by the adjustment script
$permitted = array("profile_name", "profile_picture", "bio", "images[]");
// Foramt Update and Options
$update = Helper::updatePermitted($REQUEST, $permitted);
$update = Helper::subDocUpdate($update, "providers.system");
$options = Helper::formatOptions($REQUEST);
// Any profile can be changed by an admin, a normal user
// can only change their own profile.
if ($REQUEST->avail("id")) {
    $RULES = new Rules(5, "profile");
    $document = $collection->findAndModify($REQUEST->get("id"), $update, $options);
} else {
    $RULES = new Rules(1, "profile");
    $document = $collection->findAndModify($RULES->getId(), $update, $options);
}
// Output
$OUTPUT->success(0, $document, null);
Beispiel #6
0
<?php

include_once '/var/www/html/Lux/Core/Helper.php';
$DB = new Db("SocialNetwork");
$OUTPUT = new Output();
$collection = $DB->selectCollection("Posts");
$REQUEST = new Request();
$RULES = new Rules(1, "social");
if ($REQUEST->avail("id")) {
    $id = $REQUEST->get("id");
} else {
    $id = $RULES->getId();
}
$query = array("owner" => $id);
$options = Helper::formatLimits($REQUEST);
$document = $collection->find($query, $options);
$OUTPUT->success(0, $document);
?>

Beispiel #7
0
/* Reformatted 12.11.2015 */
// Helper and includes
include_once '/var/www/html/Lux/Core/Helper.php';
// Create Database Connection
$DB = new Db("System");
$OUTPUT = new Output();
// Get Request Variables
$REQUEST = new Request();
// Admin Privleges needed
$RULES = new Rules(5, "cms");
// Select Collection From Database Connection
$collectionName = Helper::getCollectionName($REQUEST, "Content");
$collection = $DB->selectCollection($collectionName);
// Format Query
$query = Helper::formatQuery($REQUEST, "field_name");
// Values which are permitted by the Adjustment Script
$permitted = array("field_name", "content.full", "content.short", "header.text", "header.sub", "header.url_safe", "picture.banner", "picture.other[]", "picture.slideshow[]");
// Format Update and options
$update = Helper::updatePermitted($REQUEST, $permitted);
$options = Helper::formatOptions($REQUEST);
// Used for analytics
$LOG = new Logging("CMS.adjust");
$LOG->log($RULES->getId(), 51, $query, 100, "Content Updated");
// Find And Modify Documents in Collection
$document = $collection->findAndModify($query, $update, $options);
// Output
$OUTPUT->success(0, $document);
?>

  
Beispiel #8
0
$RULES = new Rules(1, "social");
// find in user or find in group
$query = $REQUEST->get("id");
$user = $Users->find($query);
if (is_null($user)) {
    $user = $Groups->find($query);
    if (is_null($user)) {
        $OUTPUT->error(1, "Could not find the specified User or Group");
    } else {
        // create dbRef
        $user2 = MongoDBRef::create("Groups", $query, "SocialNetwork");
    }
} else {
    $user2 = MongoDBRef::create("Users", $query, "SocialNetwork");
}
$user1 = MongoDBRef::create("Users", $RULES->getId(), "SocialNetwork");
// format update
$permitted = array("description", "connection_type");
$update = Helper::updatePermitted($REQUEST, $permitted);
$update = Helper::subDocUpdate($update, "information");
$subQuery1 = array('requestor' => $user1, 'requestee' => $user2);
$subQuery2 = array('requestor' => $user2, 'requestee' => $user1);
$query = array('$or' => array($subQuery1, $subQuery2));
$document_old = $collection->findOne($query);
if (is_null($document_old)) {
    // there is no existing document
    $query = $subQuery1;
    $update["status"]["pending"] = 1;
    $update["status"]["active"] = 0;
} else {
    // there is an existing document
Beispiel #9
0
<?php

/* Reformatted 12.11.2015 */
// Helper function's and includes
include_once '/var/www/html/Lux/Core/Helper.php';
// Create Database Connection
$db = new Db("Scoreboard");
$OUTPUT = new Output();
// Get Request Variables
$REQUEST = new Request();
// No Priveleges needed
$RULES = new Rules(0, "scoreboard");
// Select collection
$collectionName = Helper::getCollectionName($REQUEST, "Users");
$collection = $db->selectCollection($collectionName);
// Find Ownership Rules
$OWNERSHIP = new Ownership($RULES);
// Format a query from the request
$query = Helper::formatQuery($REQUEST, "user_id", "user_id");
// Used for analytics
$LOG = new Logging("Asset.query");
$LOG->log($RULES->getId(), 32, $query, 100, "User Queried Asset");
// Find Documents in Collection
$documents = $collection->find($query);
// Filter out unOwned Documents
$documents = $OWNERSHIP->query($documents);
// Output
$OUTPUT->success(1, $documents);
Beispiel #10
0
<?php

// Helper functions and includes
include_once '/var/www/html/Lux/Core/Helper.php';
$db = new Db("Inventory");
$OUTPUT = new Output();
$REQUEST = new Request();
$collection = $db->selectCollection("Cart");
// Must be logged in to use cart
$RULES = new Rules(1, "cart");
$REQUEST = new Request();
// get the asset, push it into the cart that is selected
$collectionName = $REQUEST->get("collection", "Standard");
$wishlistName = $REQUEST->get("wishlist", "Default");
$cartName = $REQUEST->get("cart", "Default");
$old = $collection->findOne(array("user_id" => $RULES->getId()));
$document = $collection->findAndModify(array("user_id" => $RULES->getId()), array('$push' => array("cart." . $cartName => array('$each' => $old["wishlist"][$wishlistName]))));
// Used for Analytics
$LOG = new Logging("Cart.move");
$LOG->log($RULES->getId(), 42, 1, 100, "User Moved wishlist to cart");
$OUTPUT->success(0, $document, null);
Beispiel #11
0
include_once '/var/www/html/Lux/Core/Helper.php';
$DB = new Db("SocialNetwork");
$OUTPUT = new Output();
$collection = $DB->selectCollection("Notifications");
$REQUEST = new Request();
$RULES = new Rules(1, "social");
$permitted = array("subject", "body", "attachment", "attachment[]");
// to || thread
$update = Helper::updatePermitted($REQUEST, $permitted);
$update = Helper::subDocUpdate($update, "message");
// if thread id is not set, query for the thread and create a new one if none exists
// get the thread id
// find the last message on that thread (if one exists)
// create a document that references the last document and the thread_id
if (!$REQUEST->avail("thread")) {
    $doc = $collection->findAndModify(array("reciepients" => $REQUEST->get("to"), "reciepients" => $RULES->getId(), "root" => true), array('$setOnInsert' => array("creator" => $RULES->getId())));
    $thread = $doc["_id"];
} else {
    $thread = $REQUEST->get("thread");
}
$root = $collection->find($thread);
if (is_null($root)) {
    $OUTPUT->error(1, "The thread_id provided appears to be invalid");
}
$last = $collection->findOne(array('$query' => array("root" => $thread), '$orderBy' => array('$natural' => -1)));
$update["root"] = $thread;
$update["previous"] = $last["_id"];
$new = $collection->insert($update);
$OUTPUT->success(1, $new);
?>
Beispiel #12
0
<?php

/* Reformatted 12.11.2015 */
// Helper script and includes
include_once '/var/www/html/Lux/Core/Helper.php';
// Create Database Connection
$DB = new Db("Auth");
$OUTPUT = new Output();
// Get Request Data
$REQUEST = new Request();
// Admin Privleges Required
$RULES = new Rules(5, "oauth");
// Selects Collection from Databse Connection
$collectionName = Helper::getCollectionName($REQUEST, "Clients");
$collection = $DB->selectCollection($collectionName);
// Format Query
$query = Helper::formatQuery($REQUEST, "client_name");
// Used for anayltics
$LOG = new Logging("OAuth.query");
$LOG->log($RULES->getId(), 72, $query, 100, "OAuth Providers Queried");
// Find Documents in Collection
$documents = $collection->find($query);
// Output
$OUTPUT->success(0, $documents);
?>

  
Beispiel #13
0
<?php

/* Reformatted 12.11.2015 */
// Helper functions and includes
include_once '/var/www/html/Lux/Core/Helper.php';
// Create Database connection
$DB = new Db("Inventory");
$OUTPUT = new Output();
// Get Request Data
$REQUEST = new Request();
// Admin Privleges needed
$RULES = new Rules(1, "cart");
// Selects Collection from database connection
$collectionName = Helper::getCollectionName($REQUEST, "Cart");
$collection = $DB->selectCollection($collectionName);
// Format Query
$query = Helper::formatQuery($REQUEST, "user_id");
// Used for analytics
$LOG = new Logging("Cart.query");
$LOG->log($RULES->getId(), 42, 3, 100, "User viewed items in cart/wishlist");
// Find Document in Collection
$document = $collection->findOne($query);
// Output
$OUTPUT->success(0, $document);
?>

  
Beispiel #14
0
<?php

include_once '/var/www/html/Lux/Core/Helper.php';
$db = new Db("Inventory");
$OUTPUT = new Output();
$REQUEST = new Request();
$orders = $db->selectCollection("Orders");
$RULES = new Rules(1, "orders");
$REQUEST = new Request();
// get the asset, push it into the cart that is selected
$document = $orders->findAndModify(Helper::formatQuery($REQUEST), array("shipper_id" => $RULES->getId(), "status.shipped" => true, "status.recieved" => true, "status.paid" => true, "status.modified" => true, "status.processed" => true, "status.finalized" => true));
$OUTPUT->success(0, $document, null);
Beispiel #15
0
// Selects Collection From Database Connection
$collectionName = Helper::getCollectionName($REQUEST, "Accounts");
$collection = $DB->selectCollection($collectionName);
// Format Query
$query = Helper::formatQuery($REQUEST, "user", "system_info.user");
// Value's which are accepted by the adjustment script
$permitted = array("user", "email", "role", "permissions[]");
// Format update and options
$update = Helper::updatePermitted($REQUEST, $permitted);
$update = Helper::subDocUpdate($update, "system_info");
$options = Helper::formatOptions($REQUEST);
// Get Old Document
$document_old = $collection->findOne($query);
// Used in Analytics
$LOG = new Logging("Accounts.adjust");
$LOG->log($RULES->getId(), 1, $RULES->getId(), 100, "User Modified Account");
// Find and Modify Documents in Collection
$results = $collection->findAndModify($query, $update, $options);
$document = $collection->findOne($query);
// Handle if an Admin is creating an account. Email is needed to notify Account Holder (with password).
if (is_null($document_old) && isset($document["system_info"]["email"])) {
    $password = bin2hex(openssl_random_pseudo_bytes(8));
    $hash = password_hash($password, PASSWORD_DEFAULT);
    // TODO: Change to $setOnInsert
    $collection->update($document["_id"], array('$set' => array("system_info.hash" => $hash)));
    // Send new Account holder an Email
    $user = $document["system_info"]["user"];
    $to = $document["system_info"]["email"];
    $subject = 'Email Verification';
    $message = "An account was created for you by an admistrator. Your user name is \n\n {$user} and password is \n\n {$password}";
    $headers = 'From: no-reply@' . $_SERVER["HTTP_HOST"] . "\r\n" . 'X-Mailer: PHP/' . phpversion();
Beispiel #16
0
// Helper function and includes
include_once '/var/www/html/Lux/Core/Helper.php';
// Create Database Connection
$DB = new Db("Auth");
$OUTPUT = new Output();
// Get Request Variables
$REQUEST = new Request();
// Admin privleges needed
$RULES = new Rules(5, "providers");
// Select Collection From Databse Connection
$collectionName = Helper::getCollectionName($REQUEST, "Providers");
$collection = $DB->selectCollection($collectionName);
// Format Query
$query = Helper::formatQuery($REQUEST, "provider_name");
// Value's which are accepted by the adjustment script
$permitted = array("key", "base_url", "key_name", "provider_name");
// Format update and options
$update = Helper::updatePermitted($REQUEST, $permitted);
$update['$set']["protocol"] = "App";
$options = Helper::formatOptions($REQUEST);
// Used for Analytics
$LOG = new Logging("API.adjust");
$LOG->log($RULES->getId(), 11, $REQUEST->get("provider_name"), 100, "User Modified Provider");
// Find And Modify Documents in Collection
$documents = $collection->findAndModify($query, $update, $options);
// Output
$OUTPUT->success(0, $documents);
?>

  
Beispiel #17
0
<?php

/* Reformatted 12.11.2015 */
// Helper script and includes
include_once '/var/www/html/Lux/Core/Helper.php';
// Create Database Connection
$DB = new Db("System");
$OUTPUT = new Output();
// Get Request Data
$REQUEST = new Request();
// Admin privleges needed
$RULES = new Rules(5, "accounts");
// Selects Collection from Databse Connection
$collectionName = Helper::getCollectionName($REQUEST, "Accounts", false);
$collection = $DB->selectCollection($collectionName);
// Format Query
$query = Helper::formatQuery($REQUEST, "user", "system_info.user");
// Used for Analytics
$LOG = new Logging("Accounts.query");
$LOG->log($RULES->getId(), 2, $RULES->getId(), 100, "User Account Queried");
// Find Documents in Collection
$documents = $collection->find($query);
// Output
$OUTPUT->success(0, $documents);
?>

  
Beispiel #18
0
<?php

include_once '/var/www/html/Lux/Core/Helper.php';
$DB = new Db("SocialNetwork");
$OUTPUT = new Output();
$collection = $DB->selectCollection("Notifications");
$REQUEST = new Request();
$RULES = new Rules(1, "social");
$query = array("user_id" => $RULES->getId(), "status.seen" => 0);
$document = $collection->count($query);
$OUTPUT->success(0, $document);
?>

Beispiel #19
0
<?php

/* Reformatted 12.11.2015 */
// Helper functions adn includes
include_once '/var/www/html/Lux/Core/Helper.php';
// Create Database Connection
$DB = new Db("Auth");
$OUTPUT = new Output();
// Get Request Data
$REQUEST = new Request();
// Admin Privleges required
$RULES = new Rules(5, "providers");
// Selects Collection From Database Connection
$collectionName = Helper::getCollectionName($REQUEST, "Providers");
$collection = $DB->selectCollection($collectionName);
// provider name required for specific query (otherwise all will be returned)
$query = Helper::formatQuery($REQUEST, "provider_name", null, array("protocol" => "OAuth2"));
// Used for analytics
$LOG = new Logging("Auth2.query");
$LOG->log($RULES->getId(), 112, $query, 100, "User viewed items in cart/wishlist");
// Find Documents in Collection
$documents = $collection->find($query);
// Output
$OUTPUT->success(1, $documents);
Beispiel #20
0
include_once '/var/www/html/Lux/Core/Helper.php';
// Create Database Connection
$DB = new Db("System");
$OUTPUT = new Output();
// Get Request Data
$REQUEST = new Request();
// No Privleges Needed
$RULES = new Rules(0, "session");
// Selects Collection From Database Connection
$collectionName = Helper::getCollectionName($REQUEST, "Sessions");
$collection = $DB->selectCollection($collectionName);
// Format Query
$query = Helper::formatQuery($REQUEST, "sid");
// Used for anayltics
$LOG = new Logging("Session.query");
$LOG->log($RULES->getId(), 102, $query, 100, "Session Variable Queried");
// Find Documents in Collection
$documents = $collection->find($query);
// Only Available for Sessions:
if ($REQUEST->avail("sid")) {
    $SESSION = new Session($REQUEST->get("sid"));
} else {
    $SESSION = new Session();
}
if ($REQUEST->avail("key")) {
    $OUTPUT->success(1, $SESSION->get($REQUEST->get("key")), $documents);
} else {
    $OUTPUT->success(1, $SESSION->get(), $documents);
}
?>
Beispiel #21
0
<?php

// Helper functions and includes
include_once '/var/www/html/Lux/Core/Helper.php';
$db = new Db("Inventory");
$OUTPUT = new Output();
$REQUEST = new Request();
$collection = $db->selectCollection("Cart");
$RULES = new Rules(1, "cart");
$REQUEST = new Request();
// get the asset, push it into the cart that is selected
$collectionName = $REQUEST->get("collection", "Standard");
$cartName = $REQUEST->get("cart", "Default");
$document = $collection->findAndModify(array("user_id" => $RULES->getId()), array('$push' => array("carts." . $cartName => MongoDBRef::create($collectionName, $REQUEST->get("id"), "Assets"))));
// Used for analytics
$LOG = new Logging("Cart.add");
$LOG->log($RULES->getId(), 41, $REQUEST->get("id"), 100, "User added item to cart");
$OUTPUT->success(0, $document, null);
Beispiel #22
0
<?php

include_once '/var/www/html/Lux/Core/Helper.php';
$db = new Db("Scoreboard");
$OUTPUT = new Output();
$REQUEST = new Request();
$collection = $db->selectCollection("Users");
$RULES = new Rules(1, "scoreboard");
$REQUEST = new Request();
$operator = $REQUEST->get("remove", false) ? '$pull' : '$push';
$document = $collection->findAndModify(array("user_id" => $RULES->getId()), array('$set' => array("Levels." . $REQUEST->get("level_id") . ".sub_levels." . $REQUEST->get("sub_level_id") . ".sub_level_id" => $REQUEST->get("sub_level_id"))));
$LOG = new Logging("Scoreboard.level");
$LOG->log($RULES->getId(), 62, $REQUEST->get("level_id"), 100, "User added level to scoreboard levels array");
$OUTPUT->success(0, $document, null);
Beispiel #23
0
<?php

include_once '/var/www/html/Lux/Core/Helper.php';
$DB = new Db("SocialNetwork");
$OUTPUT = new Output();
$collection = $DB->selectCollection("Messages");
$REQUEST = new Request();
$RULES = new Rules(1, "social");
$query = array('root' => '1', array('participants' => $RULES->getId()));
$options = Helper::formatLimits($REQUEST);
$document = $collection->find($query, $options);
$OUTPUT->success(0, $document);
?>

Beispiel #24
0
<?php

/* Reformatted 12.11.2015 */
// Helper script and includes
include_once '/var/www/html/Lux/Core/Helper.php';
// Create Database Connection
$db = new Db("SocialNetwork");
$OUTPUT = new Output();
// Get Request Data
$REQUEST = new Request();
// No Privleeges needed
$RULES = new Rules(0, "profile");
// Select Collection From Database Connection
$collectionName = Helper::getCollectionName($REQUEST, "Users");
$collection = $db->selectCollection($collectionName);
// Format Query
$query = Helper::formatQuery($REQUEST);
// Used for anayltics
$LOG = new Logging("Profile.query");
$LOG->log($RULES->getId(), 92, $query, 100, "Social Network Profile Queried");
// Find Documents
$documents = $collection->find($query);
// Output
$OUTPUT->success(1, $documents);
?>

  
Beispiel #25
0
<?php

include_once '/var/www/html/Lux/Core/Helper.php';
$DB = new Db("SocialNetwork");
$OUTPUT = new Output();
$collection = $DB->selectCollection("Notifications");
$REQUEST = new Request();
$RULES = new Rules(1, "social");
$query = array("user_id" => $RULES->getId());
$update = array("status.seen" => 1);
$options = Helper::formatLimits($REQUEST);
$options["upsert"] = false;
$document = $collection->findAndModify($query, $update, $options);
$OUTPUT->success(0, $document);
?>

Beispiel #26
0
/* Reformatted 12.11.2015 */
// helper functions and includes
include_once '/var/www/html/Lux/Core/Helper.php';
// Create Database Connection
$DB = new Db("Auth");
$OUTPUT = new Output();
// Get Request Variables
$REQUEST = new Request();
// Admin privleges needed
$RULES = new Rules(5, "providers");
// Select Collection From Database
$collectionName = Helper::getCollectionName($REQUEST, "Providers");
$collection = $DB->selectCollection($collectionName);
// Format Query
$query = Helper::formatQuery($REQUEST, "provider_name");
// Values which are accepted by the adjustment Script
$permitted = array("provider_name", "base1", "base2", "base3", "client_id", "client_secret", "default_scope");
// Used for Analytics
$LOG = new Logging("Auth1.adjust");
$LOG->log($RULES->getId(), 111, $query, 100, "User Modified Asset");
// Format Update and Options
$update = Helper::updatePermitted($REQUEST, $permitted);
$update["protocol"] = "OAuth2";
$options = Helper::formatOptions($REQUEST);
// Find and Modify Documents in Collection
$documents = $collection->findAndModify($query, $update, $options);
$OUTPUT->success(0, $documents);
?>

  
Beispiel #27
0
<?php

// Helper functions and includes
include_once '/var/www/html/Lux/Core/Helper.php';
$db = new Db("Inventory");
$OUTPUT = new Output();
$REQUEST = new Request();
$cart = $db->selectCollection("Cart");
$orders = $db->selectCollection("Orders");
// Must be logged in to place an order
$RULES = new Rules(1, "cart");
$REQUEST = new Request();
// get the asset, push it into the cart that is selected
$collectionName = $REQUEST->get("collection", "Standard");
$cartName = $REQUEST->get("cart", "Default");
$old = $cart->findAndModify(array("user_id" => $RULES->getId()), array("cart." . $cartName => []), array('new' => false));
// Criteria for an order
$document = $orders->insert(array("user_id" => $RULES->getId(), "items" => $old["cart"][$cartName], "status.shipped" => false, "status.recieved" => false, "status.paid" => false, "status.modified" => false, "status.processed" => false, "status.finalized" => false));
// Used for anayltics
$LOG = new Logging("Cart.order");
$LOG->log($RULES->getId(), 42, 2, 100, "User Ordered item");
$OUTPUT->success(0, $document, null);
Beispiel #28
0
<?php

include_once '/var/www/html/Lux/Core/Helper.php';
$db = new Db("Scoreboard");
$OUTPUT = new Output();
$REQUEST = new Request();
$collection = $db->selectCollection("Users");
$RULES = new Rules(1, "scoreboard");
$REQUEST = new Request();
$level_id = $REQUEST->get("level_id");
$sub_level_id = $REQUEST->get("level_id");
$quantity = $REQUEST->get("change", false) ? $REQUEST->get("change") : $REQUEST->get("value");
$operator = $REQUEST->get("change", false) ? '$inc' : '$set';
$metric = $REQUEST->get("metric");
$document = $collection->findAndModify(array("user_id" => $RULES->getId()), array($operator => array("Levels." . $REQUEST->get("level_id") . ".sub_levels." . $REQUEST->get("sub_level_id") . ".Metrics." . $metric => $quantity)));
$LOG = new Logging("Scoreboard.metric");
$LOG->log($RULES->getId(), 63, $REQUEST->get("metric"), $quantity, "User adjusted metric");
$OUTPUT->success(0, $document, null);
Beispiel #29
0
<?php

/* Reformatted 12.11.2015 */
// helpers nad includes
include_once '/var/www/html/Lux/Core/Helper.php';
// Create Database Connection
$db = new Db("SocialNetwork");
$OUTPUT = new Output();
// Get Request Data
$REQUEST = new Request();
// No privleges Required
$RULES = new Rules(0, "profile");
// Selects collection from Database Connection
$collectionName = Helper::getCollectionName($REQUEST, "Groups");
$collection = $db->selectCollection($collectionName);
// Format Query
$query = Helper::formatQuery($REQUEST, "group_id");
// Used for anayltics
$LOG = new Logging("Groups.query");
$LOG->log($RULES->getId(), 72, $query, 100, "Groups Queried");
// Find Documents in Collection
$documents = $collection->find($query);
// Output
$OUTPUT->success(1, $documents);
?>

  
Beispiel #30
0
 function metaData($update)
 {
     $RULES = new Rules(0);
     // save the update to the document to the document itself
     $update['$push']["mods"][0]["update"] = json_encode($update);
     // Add a timestamp for the modification
     $update['$push']["mods"][0]["time_modified"] = new MongoDate();
     // add a modifier for the modification
     $update['$push']["mods"][0]["modifier"] = $RULES->getId();
     $update['$push']["mods"][0]["modifier"] = $RULES->getId();
     return $update;
 }