function create_item() { if (!is_admin() || !is_post_parameter_complete(GetFormInputNames($GLOBALS['itemForm']))) { Error('Invalid Access'); } $item = CleanFormInput($GLOBALS['itemForm'], $_POST); if (!$item) { Error('Erroneous Parameters'); } if (AddItem($item)) { echo 'success'; } else { echo 'create item unsuccessfull'; } }
// This function will generate an encrypted string and // will set it as a cookie using set_cookie. This will // also be used as the cookieId field in the cart table if (isset($_COOKIE["bookListId"])) { return $_COOKIE["bookListId"]; } else { // There is no cookie set. We will set the cookie // and return the value of the users session ID session_start(); setcookie("bookListId", session_id(), time() + 3600 * 24 * 30); return session_id(); } } switch ($_GET["action"]) { case "add_item": AddItem($_GET["id"], $_GET["con"]); ShowCart(); break; case "update_item": UpdateItem($_GET["id"], $_GET["con"]); ShowCart(); break; case "remove_item": RemoveItem($_GET["id"]); ShowCart(); break; case "remove_all": RemoveAll(); ShowCart(); break; default:
AddTemplate(); break; case "DelTemplate": DelTemplate(); break; case "AddInvoice": AddInvoice(); break; case "DelInvoice": DelInvoice(); break; case "EditInvoice": EditInvoice(); break; case "AddItem": AddItem(); break; case "DelItem": DelItem(); break; case "EditItem": EditItem(); break; case "Search": Search(); break; case "Settings": Settings(); break; default: ViewUnPaid();
$projectId = GetProjectIdForItem($_POST["item_id"]); } else { $tpl->setCurrentBlock("back_unit"); $tpl->setVariable("UNIT_ID", $_POST["unit_id"]); $tpl->parseCurrentBlock("back_unit"); $projectId = GetProjectIdForUnit($_POST["unit_id"]); } $isLogged = IsLogged(); // If user is logged in and had write access, we directly update the database if ($isLogged && IsWriter($projectId)) { $_POST["description"] = str_replace("\\\\", "\\", $_POST["description"]); // if we have an item_id, we update, else we add if (array_key_exists("item_id", $_POST) && $_POST["item_id"] != "") { $msg = ModifyItem($_POST["item_id"], $_POST["name"], $_POST["summary"], $_POST["description"], $_POST["return_value"], $_POST["see_also_list"], $_POST["parameters"], $_POST["extras"], $_POST["jvcl_info"], GetLoggedUserId()); } else { $msg = AddItem($_POST["unit_id"], $_POST["name"], $_POST["summary"], $_POST["description"], $_POST["return_value"], $_POST["see_also_list"], $_POST["parameters"], $_POST["extras"], $_POST["jvcl_info"], GetLoggedUserId()); } if (is_string($msg) && $msg != "") { $msg = "Error while submitting the Item: " . $msg; } else { $msg = "Item added/updated successfuly"; } $tpl->setCurrentBlock("thanks_logged_in"); $tpl->touchBlock("thanks_logged_in"); $tpl->parseCurrentBlock("thanks_logged_in"); } else { // if the user is not logged in or does not have write access, // we submit the item for review $msg = AddSubmittedItem($_POST["item_id"], $_POST["unit_id"], $_POST["name"], $_POST["summary"], $_POST["description"], $_POST["return_value"], $_POST["see_also_list"], $_POST["parameters"], $_POST["extras"], $_POST["jvcl_info"]); if ($msg != "") { $msg = "Error while submitting the Item: " . $msg;
GetTotal((int) $_GET["items"], (int) $_GET["categoryID"]); break; //xu ly lay danh sach san pham trong csdl //xu ly lay danh sach san pham trong csdl case 'list': PostList((int) $_POST["items"], (int) $_POST["currentPage"], (int) $_POST["categoryID"]); break; //xu ly lay mot san pham trong csdl //xu ly lay mot san pham trong csdl case 'element': GetElement((int) $_GET["id"]); break; //xu ly them san pham vao gio hang //xu ly them san pham vao gio hang case 'addcart': AddItem((int) $_POST['id'], $_POST['name_pro'], $_POST['name_cat'], $_POST['img'], $_POST['price_vnd'], $_POST['price_usd'], $_POST['price_off'], $_POST['amount'], $_POST['unit_name']); break; //xu ly yeu cau cap nhat so luong trong gio hang //xu ly yeu cau cap nhat so luong trong gio hang case 'updateitemcart': UpdateItem((int) $_GET['id'], (int) $_GET['amount']); echo "true"; break; //xu ly yeu cau xoa bo mot san pham trong gio hang //xu ly yeu cau xoa bo mot san pham trong gio hang case 'removeitemcart': DeleteItem((int) $_GET['id']); echo "true"; break; //xu ly yeu cau xoa bo mot san pham trong gio hang //xu ly yeu cau xoa bo mot san pham trong gio hang
function ProcessItem($lines, &$index, $unitId) { $Name = substr($lines[$index], 2); $Summary = ""; $Author = ""; $Description = ""; $ReturnValue = ""; $SeeAlso = ""; $Parameters = ""; $Extras = ""; $JVCLInfo = ""; $curSectionRef =& $Extras; // be careful with case of $curSectionRef $WrapCol = WrappingColumn; $curSectionContent = ''; do { $curLine = rtrim($lines[$index]); switch (strtolower($curLine)) { case 'summary': $curSectionRef = $curSectionContent; $curSectionContent = ''; $curSectionRef =& $Summary; break; case 'author': $curSectionRef = $curSectionContent; $curSectionContent = ''; $curSectionRef =& $Author; break; case 'description': $curSectionRef = $curSectionContent; $curSectionContent = ''; $curSectionRef =& $Description; break; case 'return value': $curSectionRef = $curSectionContent; $curSectionContent = ''; $curSectionRef =& $ReturnValue; break; case 'see also': $curSectionRef = $curSectionContent; $curSectionContent = ''; $curSectionRef =& $SeeAlso; break; case 'parameters': $curSectionRef = $curSectionContent; $curSectionContent = ''; $curSectionRef =& $Parameters; break; case 'jvclinfo': $curSectionRef = $curSectionContent; $curSectionContent = ''; $curSectionRef =& $JVCLInfo; break; default: if (!HasPrefix($curLine, '----------') && !HasPrefix(trim($curLine), "@@")) { $WrapCol = strlen(trim($curLine)); $curSectionContent .= $curLine . "\r\n"; } } $index++; } while ($index < count($lines) and !HasPrefix(trim($lines[$index]), '@@')); // As we got out, we need to set the value of the section that // got pointed to last. $curSectionRef = Unwrap($curSectionContent, WrappingColumn, IndentationSpaces); // go back one line $index--; $Name = rtrim($Name); $Summary = rtrim($Summary); $Author = rtrim($Author); $Description = rtrim($Description); $ReturnValue = rtrim($ReturnValue); $SeeAlso = rtrim($SeeAlso); $Parameters = rtrim($Parameters); $Extras = rtrim($Extras); $JVCLInfo = rtrim($JVCLInfo); // We can now insert in the database if (substr($Name, -4) == ".pas") { $Name = str_replace(".pas", ".dtx", $Name); $existTest = UnitExistsByName($Name); if (is_string($existTest)) { return "Error while looking for {$Name}: {$existTest}"; } if ($existTest) { if ($Summary != "") { $Description = $Summary . "\n" . $Description; } $updateResult = ModifyUnit($unitId, $Name, $Description, $Author, null, null, GetLoggedUserId()); if ($updateResult == "") { return "Unit details updated.<br>"; } else { return "Error while updating unit: " . $updateResult . "<br>"; } } else { return "Error while processing unit details, the unit {$Name} does not exist !!!!<br>"; } } else { $itemId = AddItem($unitId, $Name, Unwrap($Summary, $WrapCol, IndentationSpaces), Unwrap($Description, $WrapCol, IndentationSpaces), Unwrap($ReturnValue, $WrapCol, IndentationSpaces), Unwrap($SeeAlso, $WrapCol, IndentationSpaces), Unwrap($Parameters, $WrapCol, IndentationSpaces), Unwrap($Extras, $WrapCol, IndentationSpaces), Unwrap($JVCLInfo, $WrapCol, IndentationSpaces), GetLoggedUserId()); if (is_string($itemId)) { return "Error while adding the item: " . $itemId . "<br>"; } else { return "Added item with key <a href=\"item.php?Id={$itemId}\">{$itemId}</a><br>"; } } }
// This function will generate an encrypted string and // will set it as a cookie using set_cookie. This will // also be used as the cookieId field in the cart table if (isset($_COOKIE["cartId"])) { return $_COOKIE["cartId"]; } else { // There is no cookie set. We will set the cookie // and return the value of the users session ID session_start(); setcookie("cartId", session_id(), time() + 3600 * 24 * 30); return session_id(); } } switch ($_GET["action"]) { case "add_item": AddItem($_GET["id"], $_GET["qty"]); ShowCart(); break; case "update_item": UpdateItem($_GET["id"], $_GET["qty"]); ShowCart(); break; case "remove_item": RemoveItem($_GET["id"]); ShowCart(); break; default: ShowCart(); } function AddItem($itemId, $qty) {