&load=image&size=small"> </a> </div> <?php } ?> </div> </div> </div> </div> <div class="uk-width-small-4-5"> <?php //Finds the latest item that has an image $item_obj = new Item(array("action" => "get", "sort" => "adddate", "order" => "DESC")); $item_array = $item_obj->run(true); if (count($item_array) != 0) { $data_url = ""; $count = 0; while (trim($item_array[$count]["image"]) == "") { if ($count + 1 > count($item_array) - 1) { break; } else { $count++; } } if (trim($item_array[$count]["image"]) != "") { $feat_item = $item_array[$count]; ?> <div class="uk-width-1-1 uk-hidden-small"> <div style="background:url('/imageviewer/?id=<?php
<div id="exchange_menu" class="menu"> <div class="tip"></div> <h1>My Exchanges</h1> <div id="container"> <?php if (count($exchange_array) == 0) { ?> <h6>You have no current exchanges</h6> <?php } else { foreach ($exchange_array as $exchange) { $item1_obj = new Item(array("action" => "get", "filter" => array("id" => $exchange["item1"]))); $item1_info = $item1_obj->run(true); $item1_info = $item1_info[0]; $item2_obj = new Item(array("action" => "get", "filter" => array("id" => $exchange["item2"]))); $item2_info = $item2_obj->run(true); $item2_info = $item2_info[0]; //Make sure item 1 is the item the current user owns if ($item2_info["usr"] == $_SESSION["userid"]) { $temp_array = $item1_info; $item1_info = $item2_info; $item2_info = $temp_array; } $exchange_status = "Waiting for you to review your partner"; $exchange_status_icon = "uk-icon-check"; ?> <div onclick="window.location='/exchange.php?offerid=<?php echo $exchange["id"]; ?> '" class="exchange"> <div class="content">
function print_header($ctrl) { check_version(); //Check to make sure the browser is supported /* * * MOBILE FORMATTING AND FAVICON * * */ $additional = ""; //Additional things we'll be adding to the header //If the device is mobile... if (is_mobile()) { //...use a mobile stylesheet $additional .= "<link rel=\"stylesheet\" type=\"text/css\" media=\"screen\" href=\"/scripts/css/mob/mobile.css\">"; } //Changes favicon URL based on browser if (strpos(strtolower($_SERVER["HTTP_USER_AGENT"]), "safari")) { $additional .= "<link rel=\"SHORTCUT ICON\" href=\"/favicon.ico?v=2\" />"; } else { $additional .= "<link rel=\"SHORTCUT ICON\" href=\"/favicon.ico\" />"; } /* * * MAIN BANNER CONTENTS * * */ $banner_contents = ""; //If we aren't on the homepage.. if (getcwd() !== $_SERVER["DOC_ROOT"]) { //Create a 'return home' or 'return to feed' button $text = "Return Home"; //If we're logged in... if (isset($_SESSION["userid"])) { //...it'll be 'return to feed' $text = "Return to Feed"; } //Add this to our banner $banner_contents .= "<div onclick=\"window.location='/';\" class=\"backbtn\">{$text}</div>"; } else { //Make it the logo $banner_contents .= "<div id=\"logo\"><a href=\"/\"><img src=\"/img/logo.png\"></a></div>"; //If we aren't logged in... if (!isset($_SESSION["userid"])) { //Display that text that shows how many members we have //Connect to MySQL $con = mysqli_connect(host(), username(), password(), mainDb()); //Get the user count (not possible through API) $query = mysqli_query($con, "SELECT COUNT(*) AS count FROM `usr`"); //Get the number of users $user_count = mysqli_fetch_array($query); $user_count = $user_count[0]; $all_items = new Item(array("action" => "get")); $items_array = $all_items->run(true); $item_count = count($items_array); //...add it to the banner $banner_contents .= "<div id=\"subtxt\">Now with {$user_count} members worldwide.</div>"; //Close the connection mysqli_close($con); } } $add_box = ""; //If we are going to show the login/profile panel... if ($ctrl) { //If the user is logged in if (isset($_SESSION["userid"])) { //Print their control panel and search box $banner_contents .= get_search_box(); $banner_contents .= get_profile_box($_SESSION["userid"]); //$add_box .= get_add_box(); } else { //Print the login box $banner_contents .= get_login_box(); } } $user_menu = get_user_menu(); /* * * MAIN HEADER * * */ $header = <<<HEAD \t\t\t\t\t<meta http-equiv="X-UA-Compatible" content="IE=edge" /> \t\t\t\t\t<meta name="viewport" content="width=device-width, initial-scale=1.0" /> \t\t\t\t\t<meta name="description" content="eDart is a first-of-its-kind, completely web-based, universal trading application for WPI students." /> \t\t\t\t\t<meta name="keywords" content="edart,beta,bartering,tradegrouper,trade,trading,tradby,college,worcester,polytechnic,institute,wpi,2013,free,online,database" /> \t\t\t\t\t<meta name="robots" content="index, follow" /> \t\t\t\t\t<meta name="Headline" content="Welcome to eDart!"> \t\t\t\t\t<meta name="CPS_SITE_NAME" content="Welcome to eDart!"> \t\t\t\t\t<meta property="og:title" content="eDart is a first-of-its-kind, completely web-based, universal trading application for WPI students."> \t\t\t\t\t<meta property="og:type" content="website"> \t\t\t\t\t<meta property="og:description" content="eDart is a first-of-its-kind, completely web-based, universal trading application for WPI students."> \t\t\t\t\t<meta property="og:site_name" content="eDart"> \t\t\t\t\t<meta charset="UTF-8"> \t\t\t\t\t<noscript> \t\t\t\t\t\t<meta http-equiv="refresh" content="0;URL=/noscript.php"> \t\t\t\t\t</noscript> \t\t\t\t\t<link rel="stylesheet" type="text/css" media="screen" href="/files/fonts/Vegur/stylesheet.css"> \t\t\t\t\t<link rel="stylesheet" type="text/css" media="screen" href="/files/fonts/Titillium/stylesheet.css"> \t\t\t\t\t<link rel="stylesheet" type="text/css" media="screen" href="/lib/min/?g=css"> \t\t\t\t\t<script> \t\t\t\t\t\tdocument.cookie=''; \t\t\t\t\t\t(function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){ \t\t\t\t\t\t(i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o), \t\t\t\t\t\tm=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m) \t\t\t\t\t\t})(window,document,'script','//www.google-analytics.com/analytics.js','ga'); \t\t\t\t\t\tga('create', 'UA-44057002-1', 'wewanttotrade.com'); \t\t\t\t\t\tga('send', 'pageview'); \t\t\t\t\t</script> \t\t\t\t\t{$additional} \t\t\t\t\t{$add_box} \t\t\t\t\t{$user_menu} \t\t\t\t\t<div id="bpho" style="height:60px;width:100%;"> \t\t\t\t\t\t<div id="banner"> \t\t\t\t\t\t\t{$banner_contents} \t\t\t\t\t\t</div> \t\t\t\t\t</div> HEAD; echo $header; //Print the header }
//who_ranked keeps info about who has ranked the other thus far. It is stored in an array in the database. //If the array is null, then just make it empty. If it isn't, store it in the variable. $who_ranked = is_array(json_decode($getExchange[0]["who_ranked"], true)) ? json_decode($getExchange[0]["who_ranked"], true) : array(); //If the user has already ranked the other user, the exchange (for them) is over //Take them to a "special page" if (in_array($_SESSION["userid"], $who_ranked)) { include_once $_SERVER["DOC_ROOT"] . "/gameover.php"; die; } /* * * GET OUR INFO * * */ //Retrieve info about the first item and store it in an array $item1 = new Item(array("action" => "get", "filter" => array("id" => $getExchange[0]["item1"]))); $item1_info = $item1->run(); //Retrieve info about the second item and store it in an array $item2 = new Item(array("action" => "get", "filter" => array("id" => $getExchange[0]["item2"]))); $item2_info = $item2->run(); //Using session info, figure out whether the user ID of the other user (not the one logged in) $other_id = $item1_info[0]["usr"] == $_SESSION["userid"] ? $item2_info[0]["usr"] : $item1_info[0]["usr"]; //Get info about the other user and store it into an array $otherUser = new User(array("action" => "get", "id" => $other_id)); $otherInfo = $otherUser->run(true); /* * * END GET INFO * * */ /* * * DECLARE A SHIT-TON OF VARIABLES * * */ /* --- MEETING UP --- */ // The meeting place is that of the first item (the user who accepted the offer) $meetdt = $getExchange[0]["date"]; //The meeting date (timestamp) $stadd1 = $item1_info[0]["stadd1"]; //Street address 1 $stadd2 = $item1_info[0]["stadd2"]; //Street address 2
private function find() { global $con; $query = "SELECT * FROM exchange"; $return_array = sqlToArray($con, $query, array()); $continue = true; $exchange_array = array(); if (is_array($return_array) && count($return_array) != 0) { for ($i = 0; $i < count($return_array); $i++) { $item1id = $return_array[$i]["item1"]; $item2id = $return_array[$i]["item2"]; $item1_obj = new Item(array("action" => "get", "filter" => array("id" => $item1id))); $item1_ret = $item1_obj->run(); $item2_obj = new Item(array("action" => "get", "filter" => array("id" => $item2id))); $item2_ret = $item2_obj->run(); if ($item1_ret[0]["usr"] == trim($_SESSION["userid"]) || $item2_ret[0]["usr"] == trim($_SESSION["userid"])) { $who_ranked = is_array(json_decode($return_array[$i]["who_ranked"], true)) ? json_decode($return_array[$i]["who_ranked"], true) : array(); if (!in_array($_SESSION["userid"], $who_ranked)) { array_push($exchange_array, $return_array[$i]); } } } } return $exchange_array; }
<?php include_once $_SERVER["DOC_ROOT"] . "/scripts/php/core.php"; if (!isset($_GET["item"])) { echo "No item ID specified"; die; } $id = $_GET["item"]; $item_obj = new Item(array("action" => "get", "filter" => array("id" => $id))); $item_info = $item_obj->run(true); if (count($item_info) == 0) { echo "Item does not exist"; die; } $item_info = $item_info[0]; ?> <!DOCTYPE html> <html> <head> <link rel="stylesheet" type="text/css" media="screen" href="/fonts/Vegur/stylesheet.css"> <link rel="stylesheet" type="text/css" media="screen" href="/lib/min/?g=css"> </head> <body> <div id="embed_parent" onclick="window.open('/view.php?itemid=<?php echo $item_info['id']; ?> &userid=<?php echo $item_info['usr']; ?> ', '_blank');" > <div id="header"><img src="/img/edartlogo2.png"></div>
[ <?php include_once $_SERVER["DOC_ROOT"] . "/scripts/php/core.php"; $all_items = new Item(array("action" => "get")); $all_item_info = $all_items->run(true); for ($i = 0; $i < count($all_item_info); $i++) { $item = $all_item_info[$i]; ?> {"value":"<?php echo $item["name"]; ?> ", "title":"<?php echo $item["name"]; ?> ", "url":"/view.php?&itemid=<?php echo $item["id"]; ?> &userid=<?php echo $item["usr"]; ?> ", "text":"<?php $short_desc = explode($item["description"], '.'); echo $short_desc[0]; ?> "} <?php if ($i != count($all_item_info) - 1) { echo ","; } } ?>
function getRecentActivity($uid) { //Declare the primary log for this user $log = array(); $posse = "his/her"; //User possessive $prono = "he/she"; //User pronoun /* * * * * * * * * * * * * * * * * * CHECK #1 * * Join date of user * * * * * * * * * * * * * * * * * */ // 1) Pull the user info from the database $curUser = new User(array("action" => "get", "id" => $uid)); $userInfo = $curUser->run(true); //The 'true' gives us extra permissions // 2) If the user doesn't exists... if (count($userInfo) == 0) { return array(); //Exit } // 3) But if they do, add them to the log //Get the first and last name of the user $fname = $userInfo[0]["fname"]; $lname = $userInfo[0]["lname"]; $ulog_str = "{$fname} joined eDart"; //User log string $ulog_dte = $userInfo[0]["join_date"]; //User log date $ulog_lnk = "/profile.php?id=" . $uid; //User log link //Create a log to append $user_log = array("id" => $uid, "name" => "{$fname} {$lname}", "string" => $ulog_str, "date" => $ulog_dte, "link" => $ulog_lnk); //Append the log array_push($log, $user_log); //Set the pronoun different if it's a girl if (intval($userInfo[0]["gender"]) == 2) { $posse = "her"; $prono = "she"; } else { if (intval($userInfo[0]["gender"]) == 1) { $posse = "his"; $prono = "he"; } } /* * * * * * * * * * * * * * * * * * CHECK #2 * * Any added items * * * * * * * * * * * * * * * * * */ // 1) Return an array of every item in the database $itemsCall = new Item(array("action" => "get")); $allItems = $itemsCall->run(true); foreach ($allItems as $item) { // 2) Check to see if the user posted the item if ($item["usr"] == $uid) { //If they did, add it to the log $plog_str = "{$fname} posted {$posse} item: " . $item["name"]; $plog_dte = $item["adddate"]; $plog_lnk = "/view.php?itemid=" . $item["id"] . "&userid=" . $item["usr"]; $post_log = array("id" => $uid, "name" => "{$fname} {$lname}", "string" => $plog_str, "date" => $plog_dte, "link" => $plog_lnk); array_push($log, $post_log); } else { //If they didn't, see if they made an offer on it $offers = json_decode($item["offers"], true); if (is_array($offers)) { foreach ($offers as $user => $offer) { if (trim($user) == trim($uid)) { //Turns 'a' to 'an' if item starts with a vowel $vowarr = array('a', 'e', 'i', 'o', 'u'); $name = $item["name"]; $itemname_start = $name[0]; $a = "a"; if (in_array(strtolower($itemname_start), $vowarr)) { $a .= "n"; } //Get info about the item $offer_item = new Item(array("action" => "get", "filter" => array("id" => $offer[0]))); $offer_info = $offer_item->run(true); //Add it to the log $olog_str = "{$fname} offered {$posse} {$offer_info[0]["name"]} for {$a} {$name}"; $olog_dte = $offer[1]; $olog_lnk = "/view.php?itemid=" . $item["id"] . "&userid=" . $item["usr"]; $offer_log = array("id" => $uid, "name" => "{$fname} {$lname}", "string" => $olog_str, "date" => $olog_dte, "link" => $olog_lnk); array_push($log, $offer_log); } } } } } //Now sort it usort($log, "syncedSort"); //Return it return $log; }
<?php include_once $_SERVER["DOC_ROOT"] . "/scripts/php/core.php"; if (isset($_SESSION["userid"]) && isset($_POST["confirm"]) && $_POST["confirm"] == "del") { $item_call = new Item(array("action" => "get", "filter" => array("usr" => $_SESSION["userid"]))); $user_items = $item_call->run(true); $continue = true; foreach ($user_items as $item) { if ($item["status"] != 1) { $continue = false; } } if ($continue) { $this_user = new User(); $result = $this_user->delete(); if ($result == 200) { $logout = new Login(array("action" => "logout")); $logout->run(); header("Location:/"); exit; } } else { header("Location:/"); exit; } }
* */ include_once $_SERVER["DOC_ROOT"] . "/scripts/php/core.php"; //Include core functionality //If an item ID is not in the GET parameters or it's blank... if (!isset($_GET["id"]) || trim($_GET["id"]) == "") { echo 401; //Throw a 401 error code exit; //Exit } else { //Set a JPG image page header header("Content-type: image/jpg"); //Get info given the item ID $item = new Item(array("action" => "get", "filter" => array("id" => $_GET["id"]))); $retItem = $item->run(true); //If the item is found... if (count($retItem) != 0) { //Get the first item returned given the ID $topIndex = $retItem[0]; //Get it's image $img_contents = $topIndex["image"]; //If the image isn't set... if (trim($img_contents) == "") { //...use the default image $img_contents = file_get_contents($_SERVER["DOC_ROOT"] . "/img/default.png"); } //If a filter is specified... if (isset($_GET["filter"])) { //Apply it accordingly switch (strtolower(trim($_GET["filter"]))) {
<?php } ?> <input type="hidden" value="" name="withdraw" id="withdraw_item" /> </form> <?php if (count($offers) == 0) { ?> <h6>No offers yet!</h6> <?php } else { if (is_array($offers)) { foreach ($offers as $offer) { $item_call = new Item(array("action" => "get", "filter" => array("id" => $offer["id"]))); $item_info = $item_call->run(true); $item_info = $item_info[0]; $owner_call = new User(array("action" => "get", "id" => $item_info["usr"])); $owner_info = $owner_call->run(true); $owner_info = $owner_info[0]; ?> <div class="offer" > <div class="uk-grid uk_grid_preserve reset_padding"> <div onclick="window.location='./view.php?itemid=<?php echo $offer["id"]; ?> &userid=<?php echo $item_info["usr"]; ?> ';"
function printItem($itemid) { //Get the item info $item = new Item(array("action" => "get", "filter" => array("id" => $itemid))); $item_info = $item->run(true); //Load them into variables $item_img_url = "/imageviewer/?id=" . $itemid; $item_name = $item_info[0]["name"]; $item_desc = $item_info[0]["description"]; $item_price = $item_info[0]["emv"]; $item_adddate = $item_info[0]["adddate"]; $item_duedate = $item_info[0]["duedate"]; $item_dodue = $item_duedate != 0; $item_expires = $item_info[0]["expiration"]; $item_owner = $item_info[0]["usr"]; //Format the due date //If the due date isn't this year, include the year if (date("Y", $item_duedate) == date("Y")) { $item_duedate = date("F jS", $item_duedate); } else { $item_duedate = date("n/j/Y", $item_duedate); } //Format the add date //Follow the same year rule as the due date if (date("Y", $item_adddate) == date("Y")) { $item_adddate = date("F jS", $item_adddate); } else { $item_adddate = date("n/j/Y", $item_adddate); } //Format the expiration date //Again, follow the year rule if (date("Y", $item_expires) == date("Y")) { $item_expires = date("F jS", $item_expires); } else { $item_expires = date("n/j/Y", $item_expires); } //Get the owner's info $owner = new User(array("action" => "get", "id" => $item_owner)); $owner_info = $owner->run(true); $owner_name = $owner_info[0]["fname"] . " " . $owner_info[0]["lname"]; $item_offer_count = is_array(json_encode($item_info[0]["offers"], true)) ? count(json_encode($item_info[0]["offers"])) : 0; $item_emv = strlen($item_info[0]["emv"]) != 0 ? $item_info[0]["emv"] : 0; $item_html = <<<ITEM1 \t\t\t\t\t\t\t \t\t<div class="uk-width-1-1 uk-align-center"> \t\t\t\t\t\t\t\t\t\t<div class="item" onclick="window.location='/view.php?itemid={$itemid}&userid={$item_owner}';"> \t\t\t\t\t\t\t\t\t\t\t<div class="uk-grid uk-grid-preserve reset_padding"> \t\t\t\t\t\t\t\t\t\t\t\t<div class="uk-width-4-6 info"> \t\t\t\t\t\t\t\t\t\t\t\t\t<div class="header">{$item_name} </div> \t\t\t\t\t\t\t\t\t\t\t\t\t\t<div class="description">{$item_desc}</div> \t\t\t\t\t\t\t\t\t\t\t\t\t\t<div class="overview uk-grid"> \t\t\t\t\t\t\t\t\t\t\t\t\t\t\t<div class="uk-width-1-3" title="Number of Offers"> \t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t<span class="uk-icon-cube"></span> {$item_offer_count} \t\t\t\t\t\t\t\t\t\t\t\t\t\t\t</div> \t\t\t\t\t\t\t\t\t\t\t\t\t\t\t<div class="uk-width-1-3" title="View Count"> \t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t<span class="uk-icon-eye"></span> {$item_info[0]["views"]} \t\t\t\t\t\t\t\t\t\t\t\t\t\t\t</div> \t\t\t\t\t\t\t\t\t\t\t\t\t\t\t<div class="uk-width-1-3" title="Estimated Market Value (EMV)"> \t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t<span class="uk-icon-usd"></span> {$item_emv} \t\t\t\t\t\t\t\t\t\t\t\t\t\t\t</div> \t\t\t\t\t\t\t\t\t\t\t\t\t\t</div> \t\t\t\t\t\t\t\t\t\t\t\t</div> \t\t\t\t\t\t\t\t\t\t\t\t<div class="uk-width-2-6"> \t\t\t\t\t\t\t\t\t\t\t\t\t<div style="background:url('/imageviewer/?id={$itemid}&size=medium') no-repeat center center;" class="thumbnail"> \t\t\t\t\t\t\t\t\t\t\t\t\t\t<div class="gradient"></div> \t\t\t\t\t\t\t\t\t\t\t\t\t</div> \t\t\t\t\t\t\t\t\t\t\t\t</div> \t\t\t\t\t\t\t\t\t\t\t</div> \t\t\t\t\t\t\t\t\t\t</div> \t\t\t\t\t\t\t\t\t</div>\t\t\t\t\t ITEM1; //Print the HTML echo $item_html; }
//Then remove it from the array unset($post_array["id"]); //If there is no item image if (isset($post_array["image"]) && trim($post_array["image"]) == "") { //Don't modify the image. Remove it from the update array. unset($post_array["image"]); } //Run an update API call using the item ID $newItem = new Item(array("action" => "update", "id" => $item_id, "fields" => $post_array)); $code = $newItem->run(true); $redirect_url = "/view.php?itemid={$item_id}&userid={$_SESSION["userid"]}"; } else { //remove any ID attribute from the array unset($post_array["id"]); //And use the rest of the info to create a new item $newItem = new Item(array("action" => "create", "fields" => $post_array)); $new_item_id = $newItem->run(true); $redirect_url = "/view.php?itemid={$new_item_id}&userid={$_SESSION["userid"]}"; } $redirect_script = <<<SCRIPT \t\t<script type="text/javascript"> \t\t\tfunction redirect() { \t\t\t\tparent.location = "{$redirect_url}"; \t\t\t} \t\t</script> \t\t<script type="text/javascript" src="/lib/jquery-1.10.2/jquery-1.10.2.min.js"></script> SCRIPT; echo $redirect_script; ?> </body></html>
<?php include_once $_SERVER["DOC_ROOT"] . "/api/api_lib/call.php"; $lib = strtolower(trim($_GET["lib"])); $library; $return; switch ($lib) { case "item": $library = new Item($_GET); $return = $library->run(); break; case "user": $library = new User($_GET); $return = $library->run(false); break; case "login": $library = new Login($_GET); $return = $library->run(); break; case "listener": $library = new Listener($_GET); $return = $library->listen(); break; case "messenger": $library = new Messenger($_GET); $return = $library->run(); break; case "exchange": $library = new Exchange($_GET); $return = $library->run(); break;
private function canModify($id) { global $con; $curItem = new Item(array("action" => "get", "filter" => array("id" => $id))); $itemInfo = $curItem->run(true); $curUser = new User(array("action" => "get", "id" => $_SESSION["userid"])); $userInfo = $curUser->run(true); return $itemInfo[0]["status"] != "0" && $userInfo[0]["status"] == "2"; }