Exemplo n.º 1
0
function processSavings()
{
    if (array_key_exists('media_item_id', $_POST)) {
        updateItem($_POST['media_item_id']);
    } else {
        if (array_key_exists('type', $_POST)) {
            saveNewItem();
        } else {
            if (array_key_exists('delete_id', $_GET)) {
                deleteItem($_GET['delete_id']);
            }
        }
    }
}
Exemplo n.º 2
0
function updateSettings()
{
    $fields = array("title" => "string", "title-font" => "string", "title-size" => "string", "subtitle" => "string", "footer" => "string", "caption-caps" => "boolean", "caption-italic" => "boolean", "cc-license" => "boolean", "bookmarks" => "boolean", "contact-email" => "string");
    $resource = readSettingsDb();
    if (isset($_GET["item"])) {
        updateItem($resource, $_GET["item"]);
    } else {
        foreach ($fields as $field => $type) {
            if (isset($_GET[$field])) {
                $resource->{$field} = fieldValue($_GET[$field], $type);
            }
        }
    }
    return saveSettingsDb($resource);
}
Exemplo n.º 3
0
/**
 * Main logic to handle updating an item
 * @return void
 */
function handleUpdate()
{
    try {
        if (updateItem()) {
            showMainMenu('Recipe successfully updated.', $_POST['token']);
        } else {
            showMainMenu('Recipe update failed.', $_POST['token']);
        }
    } catch (Zend_Gdata_App_Exception $e) {
        showMainMenu('Recipe update failed: ' . $e->getMessage(), $_POST['token']);
    }
}
Exemplo n.º 4
0
Arquivo: item-s3.php Projeto: rjha/sc
    $mysqli = MySQL\Connection::getInstance()->getHandle();
    $rows = MySQL\Helper::fetchRows($mysqli, $sql);
    foreach ($rows as $row) {
        printf("processing row id %d \n", $row['id']);
        $images = json_decode($row["images_json"]);
        $data = array();
        foreach ($images as $image) {
            printf("processing image id %d \n", $image->id);
            //load media DB row
            // update sc_post.id with new media DB Row
            $sql = " select * from sc_media where id = " . $image->id;
            $mediaDBRow = MySQL\Helper::fetchRow($mysqli, $sql);
            $mediaVO = \com\indigloo\media\Data::create($mediaDBRow);
            array_push($data, $mediaVO);
        }
        $strMediaVO = json_encode($data);
        updateItem($mysqli, $row['id'], $strMediaVO);
        sleep(1);
    }
    $count++;
}
function updateItem($mysqli, $postId, $strMediaVO)
{
    $updateSQL = " update sc_post set images_json = ? where id = ? ";
    $stmt = $mysqli->prepare($updateSQL);
    if ($stmt) {
        $stmt->bind_param("si", $strMediaVO, $postId);
        $stmt->execute();
        $stmt->close();
    }
}
function validate($dbObj)
{
    //get count
    $count = $dbObj->getSalesCount();
    $error = "";
    $id = $_POST['id'];
    //never manipulated
    $onsale = $_POST['onsale'];
    //validate onsale
    if ($onsale != 1 && $onsale != 0) {
        $error .= "On Sale must be a 0 or 1. 0 = false & 1 = true <br>";
    } else {
        $res = $dbObj->checkExists("SELECT t1.itemid FROM item t1 JOIN ON inventory t2 WHERE t2.onsale = :onsale AND itemId = :itemId", array(":onsale" => 1, ":itemId" => $id));
        if ($res != 0) {
            $error = "This item is already on sale <br>";
        }
        if (!($count >= 3 || $count <= 5)) {
            $error .= " You must have no more than 5 items on sale or no less than 3 items on sale <br>";
        }
    }
    $name = santitize($_POST['name']);
    $quantity = santitize($_POST['quantity']);
    if ($quantity < 0) {
        $error .= "Quantity cannot be less than zero <br>";
    }
    $description = santitize($_POST['description']);
    $saleprice = santitize($_POST['saleprice']);
    $price = santitize($_POST['price']);
    $image = santitize($_POST['image']);
    if ($error !== "") {
        return "<div class='container'><h3>" . $error . "</h3><br></div>";
    } else {
        $item = array($id, $name, $image, $price, $description, $quantity, $onsale, $saleprice);
        updateItem($dbObj, $item);
        return "<div class='container'><h3>Update was successful!</h3><br></div>";
    }
}
Exemplo n.º 6
0
     $listItem = array();
     foreach ($_REQUEST as $id => $value) {
         if ($value == "on" && is_numeric($id)) {
             $listItem[] = $id;
         }
     }
     if (delelteItemsList($listItem)) {
         $response = array("success" => true);
     } else {
         $response = array("success" => false, "data" => array("msg" => "Anything was wong in del case!"));
     }
     break;
 case "update":
     @($id = getRequest(PARAM_ID));
     @($result = getRequest(PARAM_RESULT));
     $color = updateItem($id, $result);
     if (is_numeric($color)) {
         $response = array("success" => true, "color" => $color);
     } else {
         $response = array("success" => false, "data" => array("msg" => "Anything was wong!"));
     }
     break;
 case "getList":
     @($category = getRequest(INPUT_CATEGORY));
     list($arrList, $direction) = getList($category);
     if ($arrList) {
         // group items in differents array in groups of 5 or according
         //  to their fails, shuffle elements after to provide a random order
         // 1. stores the position of the last items with the same
         // fails or group
         $failLastPosition = array();
Exemplo n.º 7
0
            header('Access-Control-Allow-Methods: GET,POST,DELETE,OPTIONS');
            break;
        default:
            throw new InvalidArgumentException('Unsupported HTTP verb: ' . $method);
    }
} else {
    // Item
    if (!array_key_exists($id, $data)) {
        throw new InvalidArgumentException('Unknown item: ' . $id);
    }
    switch ($method) {
        case 'GET':
            echo readItem($data, $id);
            break;
        case 'DELETE':
            $data = deleteItem($data, $id);
            saveData($data);
            break;
        case 'PATCH':
            $payload = getPayload();
            $data = updateItem($data, $id, $payload);
            saveData($data);
            echo readItem($data, $id);
            break;
        case 'OPTIONS':
            header('Access-Control-Allow-Methods: GET,DELETE,PATCH,OPTIONS');
            break;
        default:
            throw new InvalidArgumentException('Unsupported HTTP verb: ' . $method);
    }
}
            if (!($result = API::Item()->update($item))) {
                break;
            }
        }
    } catch (Exception $e) {
        $result = false;
    }
    $result = DBend($result);
    #######################################################################################
    # update racktables items
    require_once 'racktablesapi.php';
    if ($result) {
        foreach ($_REQUEST['group_itemid'] as $id) {
            $itemToUpdate = API::Item()->get(array('output' => 'extend', 'itemids' => $id));
            $itemToUpdate = reset($itemToUpdate);
            $response = updateItem($itemToUpdate);
            if (isset($response['error'])) {
                show_message(false, '', 'Updating racktable item is failed. ' . $response['error']);
            }
        }
    }
    #######################################################################################
    show_messages($result, _('Items updated'), _('Cannot update items'));
    if ($result) {
        unset($_REQUEST['group_itemid'], $_REQUEST['massupdate'], $_REQUEST['update'], $_REQUEST['form']);
        clearCookies($result, get_request('hostid'));
    }
} elseif (str_in_array(getRequest('go'), array('activate', 'disable')) && hasRequest('group_itemid')) {
    $groupItemId = getRequest('group_itemid');
    $enable = getRequest('go') == 'activate';
    DBstart();
Exemplo n.º 9
0
    mysql_query($sql_query);
}
//Checks method type passed and calls appropriate function
if ($method == "addItem") {
    addNewItem($invId, $serial, $item, $model, $cat, $man, $pdate, $value, $notes, $database);
} else {
    if ($method == "findItem") {
        $result = findItem($serial, $invId, $database);
        if (mysql_num_rows($result) == 1) {
            //Gathers table fields to insert into json response
            while ($row = mysql_fetch_array($result)) {
                echo '{"item":{';
                echo '"itemName":"' . $row['item_name'] . '",';
                echo '"value":"' . $row['value'] . '",';
                echo '"model":"' . $row['model'] . '",';
                echo '"man":"' . $row['manufacturer'] . '",';
                echo '"cat":"' . $row['category'] . '",';
                echo '"pdate":"' . $row['item_purchase_date'] . '",';
                echo '"notes":"' . $row['notes'] . '"';
                echo '}}';
            }
        } else {
            echo '{"error":"Item could not be found in inventory."}';
        }
    } else {
        if ($method == "modItem") {
        }
    }
}
updateItem($invId, $serial, $item, $model, $cat, $man, $pdate, $value, $notes, $database);
mysql_close($database);
Exemplo n.º 10
0
require_once $_SESSION['File_Root'] . '/Kernel/Include.php';
require_once $_SESSION['File_Root'] . '/HTML/Header.php';
require_once 'Functions/SQL.php';
redirectToLogin($accountID, $linkRoot);
redirectToBattle($verifyBattle, $linkRoot);
hasAdmin($accountAccess);
$itemPicture = htmlspecialchars(addslashes($_POST['itemPicture']));
$itemType = htmlspecialchars(addslashes($_POST['itemType']));
$itemLevel = htmlspecialchars(addslashes($_POST['itemLevel']));
$itemName = htmlspecialchars(addslashes($_POST['itemName']));
$itemDescription = htmlspecialchars(addslashes($_POST['itemDescription']));
$itemHP = htmlspecialchars(addslashes($_POST['itemHP']));
$itemMP = htmlspecialchars(addslashes($_POST['itemMP']));
$itemPurchase = htmlspecialchars(addslashes($_POST['itemPurchase']));
$itemSale = htmlspecialchars(addslashes($_POST['itemSale']));
$itemID = htmlspecialchars(addslashes($_POST['itemID']));
updateItem($bdd, $itemID, $itemPicture, $itemType, $itemLevel, $itemName, $itemDescription, $itemHP, $itemMP, $itemPurchase, $itemSale);
?>

<?php 
echo $aitem18;
?>

<br>
<form method="POST" action="index.php">
	<input class="btn btn-success" type="submit" value="Ok">
</form>
<br/>

<?php 
require_once $_SESSION['File_Root'] . '/HTML/Footer.php';
Exemplo n.º 11
0
<?php

//header("Location:cart_page.php");
header("Location:cart_page.php");
include "cart_add.php";
//include "cart_page.php";
//echo "sb";
updateItem($_POST["Cart_ID"], $_POST["Quantity"]);
echo $_POST["Cart_ID"];
echo $_POST["Quantity"];
//echo "successful delete";
//header("Location:cart_page.php");
Exemplo n.º 12
0
    setupLog("MySQL POST handling");
    $updatezp_config = true;
    if (isset($_POST['mysql_user'])) {
        updateItem('mysql_user', $_POST['mysql_user']);
    }
    if (isset($_POST['mysql_pass'])) {
        updateItem('mysql_pass', $_POST['mysql_pass']);
    }
    if (isset($_POST['mysql_host'])) {
        updateItem('mysql_host', $_POST['mysql_host']);
    }
    if (isset($_POST['mysql_database'])) {
        updateItem('mysql_database', $_POST['mysql_database']);
    }
    if (isset($_POST['mysql_prefix'])) {
        updateItem('mysql_prefix', $_POST['mysql_prefix']);
    }
}
if ($updatezp_config) {
    @chmod('zp-config.php', 0666 & CHMOD_VALUE);
    if (is_writeable('zp-config.php')) {
        if ($handle = fopen('zp-config.php', 'w')) {
            if (fwrite($handle, $zp_cfg)) {
                setupLog("Updated zp-config.php");
                $base = true;
            }
        }
        fclose($handle);
    }
}
$result = true;
Exemplo n.º 13
0
/**
 * Adds an item to the cart.
 *
 * @param $db A DB object for secure database queries
 * @param $pid The product ID
 */
function addItem($db, $pid)
{
    $cartID = getCartId();
    $qty = getQuantity();
    $sql = "SELECT * FROM shoppingcarts \n         WHERE CartID='{$cartID}' AND ProductID={$pid}";
    $result = $db->query($sql);
    $numRows = mysql_num_rows($result);
    if ($numRows != 0) {
        $qty = mysql_result($result, 0, 'Quantity');
        $_REQUEST['qty'] = $qty + 1;
        updateItem($db, $pid);
    } else {
        $sql = "SELECT price FROM products WHERE ID={$pid}";
        $result = $db->query($sql);
        if (mysql_num_rows($result) == 0) {
            return;
        }
        $price = mysql_result($result, 0, 0);
        $sql = "INSERT INTO shoppingcarts \n            VALUES('{$cartID}', {$pid}, NOW(), {$price}, {$qty})";
        $db->query($sql);
    }
}
Exemplo n.º 14
0
    case "delete":
        deleteItem($table, $idColumn, $id);
        listing($userID, $table);
        break;
    case "new":
        showNew($table, $idColumn, $nameColumn, $userID);
        break;
    case "add":
        addItem($newValue, $table, $nameColumn, $idColumn);
        listing($userID, $table);
        break;
    case "select":
        getItem($table, $idColumn, $ID, $nameColumn, $userID);
        break;
    case "edit":
        updateItem($newValue, $table, $nameColumn, $idColumn, $ID);
        listing($userID, $table);
        break;
    case "":
        listing($userID, $table);
        break;
}
function filterDropDown($fields)
{
    dropdownFields($fields, "Filter By", "filterBy", $filterBy);
}
function orderDropDown($fields)
{
    dropdownFields($fields, "Order By", "orderBy", $orderBy);
}
function listData($listQuery, $userID)
Exemplo n.º 15
0
/**
 * Processes loading of this sample code through a web browser.  Uses AuthSub
 * authentication and outputs a list of a user's base items if succesfully 
 * authenticated.
 *
 * @return void
 */
function processPageLoad()
{
    global $_SESSION, $_GET;
    if (!isset($_SESSION['sessionToken']) && !isset($_GET['token'])) {
        requestUserLogin('Please login to your Google Account.');
    } else {
        startHTML();
        $client = getAuthSubHttpClient();
        $itemUrl = insertItem($client, false);
        updateItem($client, $itemUrl, false);
        listAllMyItems($client);
        deleteItem($client, $itemUrl, true);
        querySnippetFeed();
        endHTML();
    }
}
Exemplo n.º 16
0
    $response = Unirest\Request::put($connectHost . '/v1/me/items/' . $itemId, $requestHeaders, json_encode($request_body));
    if ($response->code == 200) {
        error_log('Successfully updated item:');
        error_log(json_encode($response->body, JSON_PRETTY_PRINT));
        return $response->body;
    } else {
        error_log('Item update failed');
        return NULL;
    }
}
# Deletes the Malted Milkshake item.
function deleteItem($itemId)
{
    global $accessToken, $connectHost, $requestHeaders;
    $response = Unirest\Request::delete($connectHost . '/v1/me/items/' . $itemId, $requestHeaders);
    if ($response->code == 200) {
        error_log('Successfully deleted item');
        return $response->body;
    } else {
        error_log('Item deletion failed');
        return NULL;
    }
}
$myItem = createItem();
# Update and delete the item only if it was successfully created
if ($myItem) {
    updateItem($myItem->id);
    deleteItem($myItem->id);
} else {
    error_log("Aborting");
}
Exemplo n.º 17
0
DEFINE('DBNAME', 'datasaver');
$conn = mysql_connect(DBHOST, DBUSER, DBPW);
if (!$conn) {
    die('Could not connect: ' . mysql_error());
}
$db = mysql_select_db(DBNAME, $conn) or die(mysql_error());
include "gen.php";
$cmd = get_datan("cmd");
switch ($cmd) {
    case 1:
        //get one file based n id
        get_user();
        break;
    case 2:
        //update file record and return
        updateItem();
        break;
    case 3:
        //delete file records and return as array
        deleteItem();
        break;
    case 4:
        //add file records and return
        addItem();
        break;
    default:
        echo "{";
        echo jsonn("result", 0) . ",";
        echo jsons("message", "unknown command");
        echo "}";
}
Exemplo n.º 18
0
        die('Could not connect: ' . mysql_error());
    }
}
//print $_GET['method'];
$m = $_GET['method'];
if ($m == 'update') {
    $offset = $_GET['pg'];
    $myIndex = rawurldecode($_GET['idx']);
    $newJI = rawurldecode($_GET['ji']);
    $newDF = rawurldecode($_GET['df']);
    $newDS = rawurldecode($_GET['ds']);
    $newCT = rawurldecode($_GET['ct']);
    $newSM = rawurldecode($_GET['sm']);
    $newCO = rawurldecode($_GET['co']);
    $newTY = rawurldecode($_GET['ty']);
    updateItem($offset, $myIndex, $newJI, $newDF, $newDS, $newCT, $newSM, $newCO, $newTY);
} elseif ($m == "remove") {
    $myPage = rawurldecode($_GET['pg']);
    $myIndex = rawurldecode($_GET['idx']);
    deleteItem($myIndex);
}
function deleteItem($myIndex)
{
    global $link, $thisTable;
    //Old method, deleted actual row
    //$query2 = "DELETE FROM `$thisTable` WHERE ID = $myIndex";
    //New method, just set 'Active' Col to 0
    $query2 = "UPDATE `{$thisTable}` SET Active = '0' WHERE ID = {$myIndex}";
    $result2 = mysql_query($query2, $link);
    if (!result2) {
        $message = 'Invalid query: ' . mysql_error() . "\n";
function updateObjectItems()
{
    if (isset($_REQUEST['Save'])) {
        # parameters check
        assertStringArg('name', false);
        assertUIntArg('type', true);
        assertStringArg('key_', false);
        assertUIntArg('value_type', true);
        $delay_flexStr = '';
        foreach ($_REQUEST['delay_flex'] as $delay_flex) {
            $delay_flexStr .= $delay_flex['delay'] . '/' . $delay_flex['period'] . ';';
        }
        $item = array('itemid' => $_REQUEST['item_id'], 'objectid' => $_REQUEST['objectid'], 'hostid' => $_REQUEST['hostid'], 'name' => $_REQUEST['name'], 'description' => $_REQUEST['description'], 'key_' => $_REQUEST['key_'], 'interfaceid' => $_REQUEST['interfaceid'], 'delay' => isset($_REQUEST['delay']) ? $_REQUEST['delay'] : 0, 'history' => isset($_REQUEST['history']) ? $_REQUEST['history'] : 90, 'status' => isset($_REQUEST['status']) ? $_REQUEST['status'] : 0, 'type' => isset($_REQUEST['type']) ? $_REQUEST['type'] : null, 'snmp_community' => $_REQUEST['snmp_community'], 'snmp_oid' => $_REQUEST['snmp_oid'], 'value_type' => isset($_REQUEST['value_type']) ? $_REQUEST['value_type'] : 0, 'trapper_hosts' => $_REQUEST['trapper_hosts'], 'port' => isset($_REQUEST['port']) ? $_REQUEST['port'] : null, 'units' => $_REQUEST['units'], 'multiplier' => isset($_REQUEST['multiplier']) ? $_REQUEST['multiplier'] : 0, 'delta' => isset($_REQUEST['delta']) ? $_REQUEST['delta'] : 0, 'snmpv3_contextname' => $_REQUEST['snmpv3_contextname'], 'snmpv3_securityname' => $_REQUEST['snmpv3_securityname'], 'snmpv3_securitylevel' => isset($_REQUEST['snmpv3_securitylevel']) ? $_REQUEST['snmpv3_securitylevel'] : 0, 'snmpv3_authprotocol' => isset($_REQUEST['snmpv3_authprotocol']) ? $_REQUEST['snmpv3_authprotocol'] : 0, 'snmpv3_authpassphrase' => $_REQUEST['snmpv3_authpassphrase'], 'snmpv3_privprotocol' => isset($_REQUEST['snmpv3_privprotocol']) ? $_REQUEST['snmpv3_privprotocol'] : 0, 'snmpv3_privpassphrase' => $_REQUEST['snmpv3_privpassphrase'], 'formula' => isset($_REQUEST['formula']) ? $_REQUEST['formula'] : 0, 'trends' => isset($_REQUEST['trends']) ? $_REQUEST['trends'] : 365, 'logtimefmt' => $_REQUEST['logtimefmt'], 'delay_flex' => $delay_flexStr, 'authtype' => isset($_REQUEST['authtype']) ? $_REQUEST['authtype'] : 0, 'username' => $_REQUEST['username'], 'password' => $_REQUEST['password'], 'publickey' => $_REQUEST['publickey'], 'privatekey' => $_REQUEST['privatekey'], 'params' => $_REQUEST['params'], 'ipmi_sensor' => $_REQUEST['ipmi_sensor'], 'data_type' => isset($_REQUEST['data_type']) ? $_REQUEST['data_type'] : 0, 'inventory_link' => isset($_REQUEST['inventory_link']) ? $_REQUEST['inventory_link'] : 0);
        if ($item['itemid'] < 0) {
            # add zabbix item
            $response = addItem($item);
            # if failed, return
            if (isset($response['error'])) {
                showError('Adding zabbix item is failed. Error message:' . $response['error']);
                return;
            }
            # insert item information into DB
            $item['itemid'] = $response['result']['itemids'][0];
            usePreparedInsertBlade('item_information', $item);
            $_REQUEST['item_id'] = $item['itemid'];
            showSuccess('added item ' . $_REQUEST['name'] . '.');
        } else {
            # update zabbix item
            unset($item['objectid']);
            unset($item['hostid']);
            $response = updateItem($item);
            if (isset($response['error'])) {
                showError('Updating zabbix item is failed. Error message:' . $response['error']);
                return buildRedirectURL(NULL, NULL, $_REQUEST);
            }
            # update item information in DB
            $item_id = $item['itemid'];
            unset($item['itemid']);
            usePreparedUpdateBlade('item_information', $item, array('itemid' => $item_id));
            showSuccess('updated item ' . $_REQUEST['name'] . '.');
        }
    } else {
        if (isset($_REQUEST['Delete'])) {
            $item_id = $_REQUEST['item_id'];
            if ($item_id > 0) {
                # delete zabbix item
                $response = deleteItem($item_id);
                if (isset($response['error'])) {
                    showError('Deleting zabbix item is failed. Error message:' . $response['error']);
                }
                # delete item information from DB
                usePreparedDeleteBlade('item_information', array('itemid' => $item_id));
                showSuccess('deleted item ' . $_REQUEST['name'] . '.');
                $_REQUEST['tab'] = 'default';
            }
        } else {
            return buildRedirectURL(NULL, NULL, $_REQUEST);
        }
    }
    $left_params = array('page', 'tab', 'op', 'objectid', 'item_id');
    foreach ($_REQUEST as $key => $value) {
        if (!in_array($key, $left_params)) {
            unset($_REQUEST[$key]);
        }
    }
    return buildRedirectURL(NULL, NULL, $_REQUEST);
}
<?php

echo "<table>";
$file_handle = fopen($filepath, "r");
$i = 0;
//while loop
while (!feof($file_handle)) {
    echo "<tr>";
    $line_of_text = fgetcsv($file_handle, 1024);
    echo "<td>";
    //echo $i.$line_of_text[5];
    echo "</td>";
    if (!empty($line_of_text)) {
        updateItem($line_of_text);
    }
    $i++;
    echo "</tr>";
}
////end of while (!feof($file_handle) )
fclose($file_handle);
echo "</table>";
function updateItem($line_of_text)
{
    $model = new Items();
    $model->item_id = $line_of_text[0];
    $model->company_id = $line_of_text[1];
    $model->part_number = $line_of_text[2];
    if (empty($model->part_number)) {
        $model->part_number = 'Not Available';
    }
    $model->name = $line_of_text[3];