<?php require_once "header.php"; if (isset($_GET['id'])) { $object = FeaturedItem::get_by_id($_GET['id']); } else { header("location: index.php?negative"); } if (!$session->is_logged_in()) { header("location: index.php?negative"); } else { $loggeduser = User::get_by_id($session->userid); if ($loggeduser->enabled == DISABLED) { header("location: index.php?disabled"); } } $pathinfo = pathinfo($_SERVER["PHP_SELF"]); $basename = $pathinfo["basename"]; $currentFile = str_replace(".php", "", $basename); ?> <div class="container-fluid"> <div class="row-fluid"> <div class="span1"></div> <div class="span9"> <form id="theform" class="form-horizontal" action="#" method="post" enctype="multipart/form-data"> <fieldset> <legend> Update </legend>
<?php require_once "../initialize.php"; $message = ""; if (isset($_POST['itemid']) && $_POST['itemid'] != "" && isset($_POST['itemtype']) && $_POST['itemtype'] != "") { if (!FeaturedItem::exists($_POST['itemid'], $_POST['itemtype'])) { $object = new FeaturedItem(); $object->itemid = $_POST['itemid']; $object->itemtype = $_POST['itemtype']; $object->priority = $_POST['priority']; $object->override = $_POST['override']; $object->pending = $_POST['pending']; $object->enabled = $_POST['enabled']; if (isset($_FILES['picture'])) { $file = new File($_FILES['picture']); $object->picture = $file->data; } $object->create(); $log = new Log($session->userid, $clientip, "WEB", "CREATED FEATURED ITEM: " . $object->id); $log->create(); $message .= "success"; } else { $message .= "Cannot add a duplicate"; } } else { $message = "You have missed a required field."; } echo $message;
foreach ($items as $item) { $html .= "<tr>"; $html .= " <td>userid " . $item->userid . "</td>"; $html .= " <td>rating " . $item->rating . "</td>"; $html .= " <td>" . $item->review . "</td>"; $html .= " <td><a class='btn btn-primary' href='updatereview.php?id=" . $item->id . "'>Update</a></td>"; $html .= " <td><button class='btn btn-danger btndelete'>Delete <span hidden>" . $item->id . "</span></button></td>"; $html .= "</tr>"; } echo $html; } else { echo "no data"; } } else { if ($_GET['itemtype'] == "featureditem") { $items = FeaturedItem::get_all(); if (count($items) > 0) { foreach ($items as $item) { $theitem = new Product(); $thedesc = ""; $thepicture = ""; if ($item->itemtype == "store") { $theitem = Store::get_by_id($item->itemid); $thedesc = $theitem->branchname; } else { if ($item->itemtype == "product") { $theitem = Product::get_by_id($item->itemid); $thedesc = $theitem->description; } } if ($item->override == 1) {
<?php require_once "../initialize.php"; $message = ""; if (isset($_GET['itemid']) && isset($_GET['itemtype'])) { $message = "success"; if ($_GET['itemtype'] == "user") { User::get_by_id($_GET['itemid'])->delete(); } else { if ($_GET['itemtype'] == "featureditem") { FeaturedItem::get_by_id($_GET['itemid'])->delete(); } else { $message = "unknown parameter passed"; } } } else { $message = "missing required parameter"; } echo $message;
$where .= " AND " . C_FEATUREDITEM_ENABLED . equallike($_GET['enabled'], "int"); } //====================================================== if (isset($_GET['limit'])) { $limit = " LIMIT " . $_GET['limit'] . " "; } if (isset($_GET['sortby']) && isset($_GET['sortorder'])) { $sort = " ORDER BY " . $_GET['sortby'] . " " . $_GET['sortorder'] . " "; } if (isset($_GET['sortby']) && !isset($_GET['sortorder'])) { $sort = " ORDER BY " . $_GET['sortby'] . $sortorder . " "; } //====================================================== $sql = "SELECT * FROM " . T_FEATUREDITEMS . " WHERE " . $where . $sort . $limit; //echo $sql."<br />"; $items = FeaturedItem::get_by_sql($sql); $filename = 0; $stores = array(); if (!isset($_GET['blob'])) { foreach ($items as $item) { $store = Store::get_by_id($item->itemid); if ($item->override == 1) { $store->picture = $item->picture; } $filename++; $random = rand(0, 1); file_put_contents("images/" . $filename . "xx" . $random . ".jpg", base64_decode($store->picture)); $store->picture = HOST . "includes/webservices/images/" . $filename . "x" . $random . ".jpg"; array_push($stores, $store); // if($item->override == 1) // {
<?php require_once "../initialize.php"; $message = ""; if (isset($_POST['itemid']) && $_POST['itemid'] != "" && isset($_POST['itemtype']) && $_POST['itemtype'] != "") { $object = FeaturedItem::get_by_id($_POST['featureditemid']); $object->itemid = $_POST['itemid']; $object->itemtype = $_POST['itemtype']; $object->priority = $_POST['priority']; $object->override = $_POST['override']; $object->pending = $_POST['pending']; $object->enabled = $_POST['enabled']; $file = new File($_FILES['picture']); if ($file->valid) { $object->picture = $file->data; } else { $object->picture = base64_decode($object->picture); } $object->update(); $log = new Log($session->userid, $clientip, "WEB", "UPDATED FEATURED ITEM: " . $object->id); $log->create(); $message .= "success"; } else { $message = "You have missed a required field."; } echo $message;