function getData($moving_limit, $final_limit, $averages, $values, $max_height) { $data = array(); for ($index = $moving_limit; $index < $final_limit; $index++) { $data[$index] = getItem($index, $averages, $values, $max_height); } return $data; }
function getItems($rss) { $channel = getChannel($rss); $items = array(); foreach ($channel->getElementsByTagName('item') as $domItem) { $items[] = getItem($domItem); } return $items; }
function getSkillFromItemID($id) { if ($id == 0) { return SKILL_UNARMED; } $item = getItem($id); if ($item == 0) { return SKILL_UNARMED; } if ($item['class'] != 2) { return SKILL_UNARMED; } switch ($item['subclass']) { case 0: return SKILL_AXES; case 1: return SKILL_TWO_HANDED_AXE; case 2: return SKILL_BOWS; case 3: return SKILL_GUNS; case 4: return SKILL_MACES; case 5: return SKILL_TWO_HANDED_MACES; case 6: return SKILL_POLEARMS; case 7: return SKILL_SWORDS; case 8: return SKILL_TWO_HANDED_SWORDS; case 10: return SKILL_STAVES; // case 11: return ;//One-Handed Exotics // case 12: return ;//Two-Handed Exotics // case 11: return ;//One-Handed Exotics // case 12: return ;//Two-Handed Exotics case 13: return SKILL_FIST_WEAPONS; // case 14: return ;//Miscellaneous // case 14: return ;//Miscellaneous case 15: return SKILL_DAGGERS; case 16: return SKILL_THROWN; // case 17: return ;//Spears // case 17: return ;//Spears case 18: return SKILL_CROSSBOWS; case 19: return SKILL_WANDS; // case 20: return ;//Fishing Pole } return SKILL_UNARMED; }
public function getToken($userId, $itemId, $qty, $mobile) { $itemObj = getItem($itemId); $itemObj['qty'] = $qty; $dirRoot = sprintf("http://%s%s/", $_SERVER['SERVER_NAME'], dirname($_SERVER['PHP_SELF'])); $postDetails = array(USER => UID, PWD => PASSWORD, SIGNATURE => SIG, METHOD => "SetExpressCheckout", VERSION => VER, PAYMENTREQUEST_0_CURRENCYCODE => "USD", PAYMENTREQUEST_0_AMT => $itemObj['qty'] * $itemObj['amt'], PAYMENTREQUEST_0_TAXAMT => "0", PAYMENTREQUEST_0_DESC => "JS Wars", PAYMENTREQUEST_0_PAYMENTACTION => "Sale", L_PAYMENTREQUEST_0_ITEMCATEGORY0 => $itemObj['category'], L_PAYMENTREQUEST_0_NAME0 => $itemObj['name'], L_PAYMENTREQUEST_0_NUMBER0 => $itemObj['number'], L_PAYMENTREQUEST_0_QTY0 => $itemObj['qty'], L_PAYMENTREQUEST_0_TAXAMT0 => "0", L_PAYMENTREQUEST_0_AMT0 => $itemObj['amt'], L_PAYMENTREQUEST_0_DESC0 => $itemObj['desc'], PAYMENTREQUEST_0_SHIPPINGAMT => "0", PAYMENTREQUEST_0_SHIPDISCAMT => "0", PAYMENTREQUEST_0_TAXAMT => "0", PAYMENTREQUEST_0_INSURANCEAMT => "0", PAYMENTREQUEST_0_PAYMENTACTION => "sale", L_PAYMENTTYPE0 => "sale", PAYMENTREQUEST_0_CUSTOM => sprintf("%s,%s", $this->userId, $itemObj['number']), RETURNURL => "{$dirRoot}success.php?data=" . $itemObj['qty'] * $itemObj['amt'] . "|{$userId}|{$itemId}", CANCELURL => "{$dirRoot}cancel.php"); $arrPostVals = array_map(create_function('$key, $value', 'return $key."=".$value."&";'), array_keys($postDetails), array_values($postDetails)); $postVals = rtrim(implode($arrPostVals), "&"); $response = parseString(runCurl(URLBASE, $postVals)); //forward the user to login and accept transaction if ($mobile === "true") { $URL = URLREDIRECT; } else { $URL = URLREDIRECTINCONTEXT; } $redirect = sprintf("%s?&useraction=commit&token=%s", $URL, urldecode($response["TOKEN"])); $returnObj = array(success => true, redirecturl => $redirect); echo json_encode($returnObj); }
public function getToken($userId, $itemId, $qty, $mobile) { $itemObj = getItem($itemId); $itemObj['qty'] = $qty; $dirRoot = sprintf("http://%s%s/", $_SERVER['SERVER_NAME'], dirname($_SERVER['PHP_SELF'])); $tax = round(0.01 * $itemObj['taxamt'] * $itemObj['qty'] * $itemObj['amt'], 2); $postDetails = array('USER' => UID, 'PWD' => PASSWORD, 'SIGNATURE' => SIG, 'METHOD' => "SetExpressCheckout", 'VERSION' => VER, 'PAYMENTREQUEST_0_CURRENCYCODE' => $itemObj['currency'], 'PAYMENTREQUEST_0_AMT' => $itemObj['qty'] * $itemObj['amt'] + $tax, 'PAYMENTREQUEST_0_ITEMAMT' => $itemObj['qty'] * $itemObj['amt'], 'PAYMENTREQUEST_0_TAXAMT' => $tax, 'PAYMENTREQUEST_0_DESC' => $itemObj['name'], 'PAYMENTREQUEST_0_PAYMENTACTION' => "Sale", 'L_PAYMENTREQUEST_0_ITEMCATEGORY0' => $itemObj['category'], 'L_PAYMENTREQUEST_0_NAME0' => $itemObj['name'], 'L_PAYMENTREQUEST_0_NUMBER0' => $itemObj['number'], 'L_PAYMENTREQUEST_0_QTY0' => $itemObj['qty'], 'L_PAYMENTREQUEST_0_AMT0' => $itemObj['amt'], 'L_PAYMENTREQUEST_0_TAXAMT0' => round(0.01 * $itemObj['taxamt'] * $itemObj['amt'], 2), 'PAYMENTREQUEST_0_SHIPPINGAMT' => "0", 'PAYMENTREQUEST_0_SHIPDISCAMT' => "0", 'PAYMENTREQUEST_0_INSURANCEAMT' => "0", 'PAYMENTREQUEST_0_PAYMENTACTION' => "sale", 'L_PAYMENTTYPE0' => "sale", 'PAYMENTREQUEST_0_CUSTOM' => sprintf("%s,%s", $this->userId, $itemObj['number']), 'RETURNURL' => "{$dirRoot}success.php?data=" . round($itemObj['qty'] * $itemObj['amt'] * (1 + 0.01 * $itemObj['taxamt']), 2) . "|{$userId}|{$itemId}", 'CANCELURL' => "{$dirRoot}cancel.php"); $arrPostVals = array_map(create_function('$key, $value', 'return $key."=".$value."&";'), array_keys($postDetails), array_values($postDetails)); $postVals = rtrim(implode($arrPostVals), "&"); $response = parseString(runCurl(URLBASE, $postVals)); //forward the user to login and accept transaction if ($mobile === "true") { $URL = URLREDIRECT; } else { $URL = URLREDIRECTINCONTEXT; } $redirect = sprintf("%s?useraction=commit&token=%s", $URL, urldecode($response["TOKEN"])); $returnObj = array('success' => true, 'redirecturl' => $redirect); echo json_encode($returnObj); }
function getLowerItem($item) { $parent_id = $item["parentID"]; $cursort = $item["sort"]; print "cursort: " . $cursort . "<br>"; $galitems_q = mysql_query("SELECT * FROM newcms2_gallerypicture WHERE parentID = " . $parent_id . "") or die(mysql_error()); $nearestlow = 999999999999.0; while ($galitem = mysql_fetch_array($galitems_q)) { print "isort: " . $galitem["sort"] . "<br>"; if ($galitem["sort"] > $cursort && $galitem["sort"] < $nearestlow) { $nearestlow = $galitem["sort"]; $found = $galitem["ID"]; } } if (isset($found) && $found > 0) { return getItem($found); } else { return 0; } }
function allItems($field, $options = array()) { if ($options['data'] == 'option') { $items = get_option($field); } else { $items = get_post_meta(get_the_ID(), $field); } $i = 0; if ($items !== false && !empty($items)) { if ($options['data'] == 'option') { foreach ($items as $detail) { // set the count $options['i'] = $i; // set the value $options['value'] = $detail; getItem($field, $options); // getItem($field, $options['fields'], $options['i'], $options['value']); $i++; } } else { foreach ($items as $the_item => $details) { foreach ($details as $detail) { // set the count $options['i'] = $i; // set the value $options['value'] = $detail; getItem($field, $options); // getItem($field, $options['fields'], $options['i'], $options['value']); $i++; } } } } else { // there aren't any items, so let's add one blank one to start out // give value a value so it doesn't give us a notice $options['value'] = NULL; $options['i'] = $i; getItem($field, $options); // getItem($field, $options['fields'], $options['i']); } }
echo "<tr><td colspan=4 class=head>{$lang['item_set']}</td></tr>\n"; // Делаем ссылку для сортировки $SortRefrence = $FindRefrence; if ($page > 1) { $SortRefrence .= "&page={$page}"; } echo "<tr>"; echo "<th><a href=\"{$SortRefrence}\">{$lang['set_name']}</a></th>"; echo "<th width=260px>Items</th>"; echo "<th>Info</th>"; echo "</tr>\n"; foreach ($rows as $set) { $items = array(); $item = 0; if ($set['item_1']) { $item = getItem($set['item_1']); } else { $items = $dDB->select("SELECT `entry`, `AllowableClass`, `displayid` FROM `item_template` WHERE `itemset` = ?d", $set['id']); if ($items) { $item = $items[0]; } } echo "<tr>"; echo "<td>{$set['name']}</td>"; echo "<td>"; if ($set['item_1']) { for ($i = 1; $i < 18; $i++) { if ($itemid = $set['item_' . $i]) { show_item($itemid, 0, 'set'); } }
<?php require "inc/init.php"; $user = getItem('username', $_REQUEST, getItem('username', $_SESSION, '')); if (!getItem('user', $_REQUEST, false) && $user) { header("Location: {$contextpath}/run/{$user}/"); exit; } $result = mysql_queryf("SELECT name FROM clients, useragents WHERE clients.id=%u AND useragents.id=useragent_id LIMIT 1;", $client_id); if ($row = mysql_fetch_array($result)) { $useragent_name = $row[0]; } $title = "Run the Test Swarm"; $scripts = ""; if ($client_id) { $scripts = "<script type='text/javascript'>var client_id = {$client_id};</script>"; } $scripts .= '<script type="text/javascript" src="' . $GLOBALS['contextpath'] . '/js/jquery.js"></script>' . '<script type="text/javascript" src="' . $GLOBALS['contextpath'] . '/js/run.js?' . time() . '"></script>';
$id = abs(clrInt($_GET[id])); delItem('items', $id); header('Location: admin.php'); } if (isset($_GET[order_id])) { $id = clrStr($_GET[order_id]); delItem('orders', $id); header('Location: admin.php'); } if ($_SERVER[REQUEST_METHOD] == "POST") { $name = clrStr($_POST['name']); $price = clrInt($_POST['price']); $photo = $_FILES['f']['name']; $quantity = clrInt($_POST['quantity']); $tmp_name = $_FILES['f']['tmp_name']; if (getItem($name, $price, $photo, $quantity)) { if (move_uploaded_file($tmp_name, "{$upload_dir}/{$photo}")) { header('Location: admin.php'); echo "Товар успешно добавлен!</br>"; } } else { echo "произошла ошибка!"; } } ?> <!DOCTYPE html> <html> <head> <title>Админка сайта</title> <meta charset = "UTF-8"
function list_item($catalog) { global $host; global $user; global $password; global $database; global $limit; $arr = array(); // подключаемся к SQL серверу $link = mysqli_connect($host, $user, $password, $database) or die("Ошибка " . mysqli_error($link)); $query = 'select link, parent_id from bitrixshop.load_catalog where id_cat = "' . $catalog . '"' . $limit; //Не забыть убрать ЛИМИТ $result = mysqli_query($link, $query); while ($row = mysqli_fetch_array($result, MYSQLI_ASSOC)) { //echo $row['s3'] . "<br>"; $arr_art = getItem($row['link'], $catalog); $parent_id = $row['parent_id']; for ($j = 0; $j < count($arr_art); $j++) { $s1 = $arr_art[$j]["tovar_id"]; $s2 = $arr_art[$j]["catalog_id"]; $s3 = $arr_art[$j]["link"]; $s4 = $parent_id; $arr[] = array("tovar_id" => $s1, "catalog_id" => $s2, "link" => $s3, "parent_id" => $s4); } } //Закрываем соединение с БД mysqli_close($link); return $arr; }
$name = "Linux"; } } } } } } } } } } echo "<li><img src='" . swarmpath("/") . "images/{$engine}.sm.png' class='{$engine}'/> <strong class='name'>{$browser_name} {$name}</strong><br>Connected <span title='{$since}' class='pretty'>{$since}</span></li>"; } echo "</ul>"; } $job_search = preg_replace("/[^a-zA-Z ]/", "", getItem("job", $_REQUEST, "")); $job_search .= "%"; $search_result = mysql_queryf("SELECT jobs.name, jobs.status, jobs.id FROM jobs, users WHERE jobs.name LIKE %s AND users.name=%s AND jobs.user_id=users.id ORDER BY jobs.created DESC LIMIT 15;", $job_search, $search_user); if (mysql_num_rows($search_result) > 0) { echo '<br/><h3>Recent Jobs:</h3><table class="results"><tbody>'; $output = ""; $browsers = array(); $addBrowser = true; while ($row = mysql_fetch_array($search_result)) { $job_name = $row[0]; $job_status = get_status(intval($row[1])); $job_id = $row[2]; $output .= '<tr><th><a href="' . swarmpath("job/{$job_id}/") . '">' . strip_tags($job_name) . "</a></th>\n"; $results = array(); $states = array(); $result = mysql_queryf("SELECT runs.id as run_id, runs.url as run_url, runs.name as run_name, useragents.engine as browser, useragents.name as browsername, useragents.id as useragent_id, run_useragent.status as status FROM run_useragent, runs, useragents WHERE runs.job_id=%u AND run_useragent.run_id=runs.id AND run_useragent.useragent_id=useragents.id ORDER BY run_id, browsername;", $job_id);
<?php require_once 'DataAccess.php'; require_once 'includes/functions.php'; $star = $_POST['star']; $data = new DataAccess('photo'); $userID = rand(1, 10); $itemID = $_POST['id']; $table = $_POST['table']; $newtime = getCurrentDateTime(); $theItem = getItem($itemID, $table); $totStar = $theItem['stars'] + $star; $total = $theItem['like_count'] + 1; $rating = (int) $totStar / $total; $table2 = $table . "_votes"; $sql = "UPDATE {$table} SET like_count='{$total}', stars='{$star}', last_liked='{$newtime}', rating={$rating} WHERE id={$itemID}"; $result = $data->executeQuery($sql); if ($result) { $sql = "INSERT INTO {$table2} VALUES ({$userID}, {$star}, '{$newtime}',{$itemID} )"; $result2 = $data->executeQuery($sql); if ($result2) { echo "success"; } else { echo "fail3"; } } else { echo "fail2"; } $data->dispose();
function delete($item_id, $item_table, $table = false) { global $CFG; $table = $table ? $table : 'cart'; $item = DB::getRecord($item_table, $item_id, false, true); $item_name = $item['name']; if (User::isLoggedIn()) { $result = getItem($item_id, $item_table, $table); if ($result) { DB::delete($result['id']); $messages[$item_name] = $CFG->cart_delete_message; Messages::merge($messages); } } else { unset($_SESSION['cart'][$item_table . '_' . $item_id]); $messages[$item_name] = $CFG->cart_delete_message; Messages::merge($messages); } }
<?php if ($cartCount == 0) { echo '<h1>Ваша корзина пуста</h1>'; } else { echo '<table align="center" border="1" style="margin-top: 50px;" > <tr> <td style="padding: 0 30px 0 30px;">Наименование</td> <td style="padding: 0 30px 0 30px;">Кол-во</td> <td style="padding: 0 30px 0 30px;">Цена</td> <td style="padding: 0 30px 0 30px;">Больше</td> <td style="padding: 0 30px 0 30px;">Меньше</td> <td style="padding: 0 30px 0 30px;">Удалить</td> </tr>'; foreach ($_SESSION['cart'] as $itemId => $count) { echo '<tr>'; $item = getItem($itemId)[0]; echo '<td style="padding: 0 30px 0 30px;">' . $item['name'] . '</td>'; echo '<td style="padding: 0 30px 0 30px;">' . $count . '</td>'; echo '<td style="padding: 0 30px 0 30px;">' . $item['price'] . '</td>'; echo '<td style="padding: 0 30px 0 30px;"><a href="?type=4&id=' . $itemId . '">' . 'Больше' . '</td>'; echo '<td style="padding: 0 30px 0 30px;"><a href="?type=7&id=' . $itemId . '">' . 'Меньше' . '</td>'; echo '<td style="padding: 0 30px 0 30px;"><a href="?type=8&id=' . $itemId . '">' . 'Удалить' . '</td>'; echo '</tr>'; } echo ' </table> <p style="margin-top: 20px; font-size: 20px;">Итого: ' . $cartSum . ' рублей </p> <a class="search-submit" style="text-align: center; width: 200px;" href="?type=5">Очистить корзину</a>'; echo '<form action="/?type=6" method="post"> <p>
function getSuggestions() { $id = $_POST['id']; $recent = _getRecentlyBoughtItems($id); $arr = array(); for ($i = 0; $i < sizeof($recent); $i++) { $obj = getItem($recent[$i]); $obj["suggestions"] = _getItemSuggestions($recent[$i]); $arr[] = $obj; } echo json_encode($arr); }
<?php require "inc/init.php"; $run_id = preg_replace("/[^0-9]/", "", getItem("run_id", $_POST, "")); $fail = preg_replace("/[^0-9-]/", "", getItem("fail", $_POST, "")); $error = preg_replace("/[^0-9-]/", "", getItem("error", $_POST, "")); $total = preg_replace("/[^0-9-]/", "",getItem("total", $_POST, "")); $results = gzencode(getItem("results", $_POST, "")); # Make sure we've received some results from the client if ( $results ) { mysql_queryf("UPDATE run_client SET status=2, fail=%u, error=%u, total=%u, results=%s WHERE client_id=%u AND run_id=%u LIMIT 1;", $fail, $error, $total, $results, $client_id, $run_id); if ( mysql_affected_rows() > 0 ) { # If we're 100% passing we don't need any more runs if ( $total > 0 && $fail == 0 && $error == 0 ) { # Clear out old runs that were bad, since we now have a good one $result = mysql_queryf("SELECT client_id FROM run_client, clients WHERE run_id=%u AND client_id!=%u AND (total <= 0 OR error > 0 OR fail > 0) AND clients.id=client_id AND clients.useragent_id=%u;", $run_id, $client_id, $useragent_id); while ( $row = mysql_fetch_array($result) ) { mysql_queryf("DELETE FROM run_client WHERE run_id=%u AND client_id=%u;", $run_id, $row[0]); } mysql_queryf("UPDATE run_useragent SET runs = max, completed = completed + 1, status = 2 WHERE useragent_id=%u AND run_id=%u LIMIT 1;", $useragent_id, $run_id); } else { if ( $total > 0 ) { # Clear out old runs that timed out. $result = mysql_queryf("SELECT client_id FROM run_client, clients WHERE run_id=%u AND client_id!=%u AND total <= 0 AND clients.id=client_id AND clients.useragent_id=%u;", $run_id, $client_id, $useragent_id); while ( $row = mysql_fetch_array($result) ) { mysql_queryf("DELETE FROM run_client WHERE run_id=%u AND client_id=%u;", $run_id, $row[0]);
<?php include "./inc/footer.php"; ?> <script> var GameInfo = <?php function ConnectToDB() { $dbh = new PDO('<host>', '<user>', '<password>'); return $dbh; } include "server/items.php"; $id = isset($_GET['id']) ? $_GET['id'] : "0"; $arr = getItem($id); echo json_encode($arr); ?> ; function renderGameDiv(obj){ $("#item_title").text(obj.title); $("#item_title_year").text("("+obj.publish_year+")"); $("#item_image").attr({src:obj.image_url,alt:obj.title}); $("#item_description").text(obj.description); $("#item_genre").text(obj.genre); $("#item_publisher").text(obj.publisher); var months = ["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"];
<?php $item = getItem($id)[0]; ?> <div class="products"> <div class="cl"> </div> <ul> <?php echo '<li>'; $catName = getCategoryById($item['id_category'])[0]['name']; $link = '?type=3&id=' . $item['id']; echo '<a href="' . $link . '"><img src="' . $item['photo'] . '" alt="" /></a> <div class="product-info"> <h3>' . $catName . '</h3> <div class="product-desc"> <h4>' . $item['name'] . '</h4> <strong class="price">' . $item['price'] . ' руб.</strong> </div> </div>'; echo '</li>'; echo $item['description']; ?> </ul> <div class="cl"> </div> <?php echo '<a class="search-submit" style="width: 150px; text-align: center" href="?type=4&id=' . trim($id) . '" >Добавить в корзину</a>'; ?> </div>
var_dump(getCurrentQuestion()); echo "<hr>ITEMS<hr>"; $items = getItems(76); var_dump($items); echo "<hr>ITEM index 2<hr>"; $item = $items[2]; var_dump($item); echo "<hr>ITEM MORE OF ITEMS<hr>"; $more = getItemMore($items); var_dump($more); echo "<hr>ITEM RATE<hr>"; $voteCount = getItemRate($item); var_dump($voteCount); echo "<hr>ITEM COMMENTS<hr>"; $voteCount = getItemComments($item); var_dump($voteCount); echo "<hr>SPECIFIC ITEM COMMENTS<hr>"; $item = getItem(79, 1367); var_dump($item); $comments = getItemComments($item); if (count($comments) < 1) { echo "Pas de coms"; } else { foreach ($comments as $com) { if (is_object($com)) { $com = (array) $com; } echo $com["content"] . "<br/>"; } } echo "<br/>Media Id = " . getItemMediaId($item);
<?php echo "<div style ='font:100px Arial,tahoma,sans-serif;color:#000000'> FIN </div>"; $myfile = fopen("newfile.txt", "w") or die("Unable to open file!"); $txt = localStorage . getItem('i_1'); fwrite($myfile, $txt); $txt = "Jane Doe\n"; fwrite($myfile, $txt); fclose($myfile);
} return $ret; } if (array_key_exists("type", $_GET)) { if ($_GET["type"] != "jsonp") { die; } } if (array_key_exists("mode", $_GET)) { if ($_GET["mode"] == "list") { //http://cathassist.org/vaticanacn/getarticle.php?type=jsonp&mode=list&callback=10&from=479&count=200 $from = -1; $count = 10; if (array_key_exists("from", $_GET)) { $from = (int) $_GET['from']; } if (array_key_exists("count", $_GET)) { $count = (int) $_GET['count']; } echo $_GET['callback'] . '(' . json_encode(getList($from, $count)) . ')'; } else { if ($_GET["mode"] == "item") { if (array_key_exists("id", $_GET)) { $id = $_GET["id"]; echo $_GET['callback'] . '(' . json_encode(getItem($id)) . ')'; } else { echo $_GET['callback'] . '()'; } } } }
<?php /** * Created by PhpStorm. * User: Ryan * Date: 11/9/2015 * Time: 2:46 PM */ require 'db_cn.inc'; require 'db_access.inc'; require 'update_item_ui.inc'; getItem(); function getItem() { connect_and_select_db(DB_SERVER, DB_UN, DB_PWD, DB_NAME); $itemNumber = $_REQUEST['itemNumber']; $sql = "SELECT ItemNumber, ItemDescription, Category, DepartmentName, PurchaseCost, FullRetailPrice\n FROM Item\n WHERE ItemNumber = '" . $itemNumber . "'"; $error_message = "Could not successfully run query to get item data ({$sql}) from DB: "; $not_found_message = "Item with Item Number ({$itemNumber}) not found in DB"; $row = get_unique_row($sql, $error_message, $not_found_message); $itemNumber = $row["ItemNumber"]; $itemDescription = $row["ItemDescription"]; $category = $row["Category"]; $deptName = $row["DepartmentName"]; $purchCost = $row["PurchaseCost"]; $retail = $row["FullRetailPrice"]; ui_show_update_item_form($itemNumber, $itemDescription, $category, $deptName, $purchCost, $retail); }
<?php define('OFFSET_PATH', 4); require_once dirname(dirname(dirname(__FILE__))) . '/admin-globals.php'; if (extensionEnabled('zenpage')) { require_once dirname(dirname(dirname(__FILE__))) . '/' . PLUGIN_FOLDER . '/zenpage/admin-functions.php'; } require_once dirname(__FILE__) . '/menu_manager-admin-functions.php'; admin_securityChecks(NULL, currentRelativeURL()); $page = 'edit'; $result = NULL; $reports = array(); if (isset($_GET['id'])) { $result = getItem(sanitize($_GET['id'])); } if (isset($_GET['save'])) { XSRFdefender('update_menu'); if ($_POST['update']) { $result = updateMenuItem($reports); } else { $result = addItem($reports); } } if (isset($_GET['del'])) { XSRFdefender('delete_menu'); deleteItem($reports); } printAdminHeader('menu', is_array($result) && $result['id'] ? gettext('edit') : gettext('add')); ?> <link rel="stylesheet" href="../zenpage/zenpage.css" type="text/css" /> <?php
break; default: throw new Exception("Invalid action specified: {$action}"); } } else { // No ID was specified; create a new item // Our initial properties and default values.. $item = array('created_at' => new DateTime(), 'priority' => 0, 'due_date' => null, 'completed' => null); // ...now add in whatever values came from the request.. $item = setItemProp($item); // ...and add it to the next index in the session // Tracking a "next id" separately from the array add some weird complexity, but helps ensure // the integrity of our data; a user can't just delete the last item, insert a new one, and take // its place. Further, storing the ID in as both the array index and in each item seems redundant // but it makes lookup trivial, while keeping all the data easily accessible to the user $id = $_SESSION['next_id']; $item['id'] = $id; $_SESSION['items'][$id] = $item; $_SESSION['next_id']++; // Status code indicates an entity was created http_response_code(201); // When sending a 201, you should include the URL for that new entity in Location // (http://www.restapitutorial.com/httpstatuscodes.html) header("Location: {$_SERVER['SCRIPT_NAME']}?id={$id}"); echo getItem($id); } } else { $msg = "Unknown request type {$_SERVER['REQUEST_METHOD']}."; $msg .= " This application only responds to GET and POST requests."; throw new Exception($msg, 501); }
<?php require_once "includes/connection.php"; require_once "includes/functions.php"; ?> <div id="coloumns" style="width:500px;height:400px; padding-top: 30px;padding-left: 30px;" > <span style="font-size:20px;"><center> সমস্যাটির জন্য সবার দেয়া সমাধান গুলো</center></span> <?php $re2 = getItem($_POST['id'], "problems"); echo "<div style='height:50px;width:730px;'><div style='float:right;font-size:25px;' class='problemRating'>Rating : " . $re2['rating'] . "</div>"; echo "<div style='width:730px;font-size:21px;float:left;position:absolute;clear:both;' class='problemName'>Problem : " . $re2['name'] . "</div></div>"; $result = getItems(10, "solutions", $_POST['id']); while ($row = mysql_fetch_array($result)) { ?> <div style="width: 730px; line-height: 20px; float: left;border-bottom:1px solid #585858;padding-bottom: 5px;margin-bottom: 3px;"> <div style="float: left;"> <div><b>Solution Name:<?php echo $row['name']; ?> </b></div> <div class="problemDesc">Details:<?php echo $row['description']; ?> </div> <div class="problemDesc">Cost:<?php echo $row['cost']; ?> </div> <div class="problemDesc">man power:<?php echo $row['man_power'];
} } $username = getItem('username', $_SESSION, getItem('user', $_REQUEST, '')); if (!$username) { $username = $_REQUEST['user']; } $username = preg_replace("/[^a-zA-Z0-9_ -]/", "", $username); if ($username) { $_SESSION['username'] = $username; } # We need a username to set up an account if (!$username) { # TODO: Improve error message quality. exit("Username required. ?user=USERNAME."); } $client_id = preg_replace("/[^0-9]/", "", getItem('client_id', $_REQUEST, '')); if ($client_id) { $result = mysql_queryf("SELECT user_id, useragent_id FROM clients WHERE id=%u LIMIT 1;", $client_id); if ($row = mysql_fetch_array($result)) { $user_id = $row[0]; $useragent_id = $row[1]; # If the client ID is already provided, update its record so # that we know that it's still alive mysql_queryf("UPDATE clients SET updated=NOW() WHERE id=%u LIMIT 1;", $client_id); # TODO: Improve error message quality. } else { echo "Client doesn't exist."; exit; } # The user is setting up a new client session } else {
function loadRAWData($from, $id_plan, $id_item, $to = null, $id_host = null) { $cacheAge = 60 * 60; $offset = getOffset(); setTimezone(); $cache = phpFastCache(); //$cache->clean(); $dt = getDates($from); $from = $dt[0]; if ($to == null) { $to = $dt[1]; } $from = str_replace("-", "/", $from); $to = str_replace("-", "/", $to); $phour = getPeakHours(); $unit = getUnit($id_item); $plan = getPlan($id_plan); $item = getItem($id_item); $div = 1; if (strtolower($unit) == 'bps') { $div = 1024 * 1024; $unit = 'Mbps'; } $rtag = ""; foreach ($_SESSION['tag'] as $key => $value) { if ($key != "" && $key != "None") { $rtag = $rtag . ',"' . $key . '"'; } } if ($rtag == '') { $rtag = 'bm_tags.tag like "%"'; } else { $rtag = 'bm_tags.tag in (' . substr($rtag, 1) . ')'; } if ($id_plan == 0) { $id_plan = '> 0'; } else { $id_plan = '=' . $id_plan; } if ($id_host == null) { $id_host = ""; } else { $id_host = " and bm_host.id_host=" . $id_host; } $hosts = 'select bm_host.id_host,bm_host.id_plan,bm_plan.plan,bm_plan.nacD,bm_plan.nacU,bm_threshold.critical,bm_threshold.warning,bm_threshold.nominal,bm_host.host from bm_host,bm_plan,bm_plan_groups,bm_threshold,bi_dashboard where bm_host.id_plan=bm_plan.id_plan and bm_host.groupid = ' . $_SESSION['groupid'] . ' and bm_plan.id_plan ' . $id_plan . ' and bm_plan_groups.id_plan = bm_plan.id_plan and bm_host.borrado=0 and bm_host.id_plan=bm_plan.id_plan and bm_plan_groups.groupid=bm_host.groupid and bm_threshold.id_item=bi_dashboard.id_item and bm_host.id_host in (select id from bm_tags where ' . $rtag . ') and bi_dashboard.id_item=' . $id_item . $id_host . ' order by bm_host.id_plan'; //var_dump($hosts); // Find Percentile 5 and 95 if (true) { $hostsr = mysql_query($hosts); while ($host = mysql_fetch_array($hostsr, MYSQL_ASSOC)) { $id_host = $host['id_host']; $hostName = $host['host']; $nominal = $host['nominal']; $critical = $host['critical']; $warning = $host['warning']; $nacD = $host['nacD'] * 1024; $nacU = $host['nacU'] * 1024; if ($nominal == -1) { $nominal = $nacD; } if ($nominal == -2) { $nominal = $nacU; } $hostList[] = array('host' => $hostName, 'id_host' => $id_host, 'nominal' => $nominal, 'critical' => $critical, 'warning' => $warning, 'nacD' => $nacD, 'nacU' => $nacU); $incache = true; unset($cachedData); $dfrom = $key = date('Y/m/d', strtotime($from . ' -1 days')); while ($dfrom != $to) { $dfrom = date('Y/m/d', strtotime($dfrom . ' +1 days')); $key = $dfrom . '-' . $id_host . '-' . $id_item; //if (isset($_SESSION['cache'][$key])) // $obj = $_SESSION['cache'][$key]; //else //echo $key . "<br>"; $obj = $cache->get($key); if ($obj == null) { $incache = false; $_SESSION['cacheFull'] = false; } else { $_SESSION['cachePartial'] = true; foreach ($obj as $key => $value) { if (isset($value['clock'])) { $cachedData[] = $value; } } } } if (!isset($cachedData)) { $incache = false; } if ($incache) { foreach ($cachedData as $key => $row) { $skip = false; if (isset($_SESSION['filter']['< 1.5x']) && $row['value'] > $nominal * 1.5) { $skip = true; } if (isset($_SESSION['filter']['< 2.0x']) && $row['value'] > $nominal * 2.0) { $skip = true; } if (isset($_SESSION['filter']['< 3.0x']) && $row['value'] > $nominal * 3.0) { $skip = true; } if (isset($_SESSION['filter']['> 0']) && $row['value'] <= 0) { $skip = true; } if (isset($_SESSION['filter']['Off Peak Hour']) && $row['t'] == 'P') { $skip = true; } if (isset($_SESSION['filter']['Peak Hour']) && $row['t'] == 'O') { $skip = true; } if (!$skip) { $allData[] = $row['value']; $historyList[$id_host][] = array('clock' => $row['clock'], 'value' => $row['value'], 'valid' => $row['valid'], 't' => $row['t']); } } } else { $table = 'xyz_' . str_pad($id_item, 10, "0", STR_PAD_LEFT); //var_dump($table); if (mysql_num_rows(mysql_query("SHOW TABLES LIKE '" . $table . "'")) == 1) { if ($phour['peak'] > $phour['offpeak']) { $q = 'select clock,value,valid,if((date_format(from_unixtime(clock),"%H")>=0 and date_format(from_unixtime(clock),"%H")<=' . $phour['offpeak'] . ') or date_format(from_unixtime(clock),"%H")>=' . $phour['peak'] . ',"P","O") as t from ' . $table . ' where clock between unix_timestamp("' . $from . ' 00:00:00") AND unix_timestamp("' . $to . ' 23:59:59") and id_host=' . $id_host; } else { $q = 'select clock,value,valid,if(date_format(from_unixtime(clock),"%H")>=' . $phour['peak'] . ' and date_format(from_unixtime(clock),"%H")<=' . $phour['offpeak'] . ',"P","O") as t from ' . $table . ' where clock between unix_timestamp("' . $from . ' 00:00:00") AND unix_timestamp("' . $to . ' 23:59:59") and id_host=' . $id_host; } //var_dump($q); $qr = mysql_query($q); while ($row = mysql_fetch_array($qr, MYSQL_ASSOC)) { $key = date('Y/m/d', $row['clock']); $data[$key][$id_host . '-' . $id_item][] = array('clock' => $row['clock'], 'value' => $row['value'], 'valid' => $row['valid'], 't' => $row['t']); $skip = false; if (isset($_SESSION['filter']['< 1.5x']) && $row['value'] > $nominal * 1.5) { $skip = true; } if (isset($_SESSION['filter']['< 2.0x']) && $row['value'] > $nominal * 2.0) { $skip = true; } if (isset($_SESSION['filter']['< 3.0x']) && $row['value'] > $nominal * 3.0) { $skip = true; } if (isset($_SESSION['filter']['> 0']) && $row['value'] <= 0) { $skip = true; } if (isset($_SESSION['filter']['Off Peak Hour']) && $row['t'] == 'P') { $skip = true; } if (isset($_SESSION['filter']['Peak Hour']) && $row['t'] == 'O') { $skip = true; } if (!$skip) { $allData[] = $row['value']; $historyList[$id_host][] = array('clock' => $row['clock'], 'value' => $row['value'], 'valid' => $row['valid'], 't' => $row['t']); } } } // check miising data $dfrom = $key = date('Y/m/d', strtotime($from . ' -1 days')); while ($dfrom != $to) { $dfrom = date('Y/m/d', strtotime($dfrom . ' +1 days')); $key = $dfrom . '-' . $id_host . '-' . $id_item; $obj = $cache->get($key); if ($obj == null) { $cache->set($key, array('clock' => 0, 'value' => 0, 'valid' => 0, 't' => ''), $cacheAge); //$_SESSION['cache'][$key]= array('clock'=>0,'value'=>0,'valid'=>0,'t'=>''); } } } } } if (isset($incache) && !$incache && isset($data)) { foreach ($data as $key => $value) { foreach ($value as $hkey => $hvalue) { $thekey = $key . '-' . $hkey; //echo $thekey . ' '; $cache->set($thekey, $hvalue, $cacheAge); //$_SESSION['cache'][$thekey] = $hvalue; } } } if (isset($allData)) { return array('allData' => $allData, 'historyList' => $historyList, 'hostList' => $hostList, 'offpeak' => $phour['offpeak'], 'peak' => $phour['peak'], 'unit' => $unit, 'div' => $div, 'plan' => $plan, 'item' => $item, 'from' => $from, 'to' => $to); } else { return array('allData' => null, 'historyList' => null, 'hostList' => null, 'offpeak' => $phour['offpeak'], 'peak' => $phour['peak'], 'unit' => $unit, 'div' => $div, 'plan' => $plan, 'item' => $item, 'from' => $from, 'to' => $to); } }
</head> <?php $question = getCurrentQuestion(); if (isset($_GET['page'])) { $page = addslashes($_GET["page"]); } else { $page = 0; } $itemId = 0; if (!isset($_GET["itemId"])) { displayError("pas d'item selectionné"); } $itemId = $_GET["itemId"]; $_SESSION["visited"][(int) $_GET["itemId"]] = 1; $item = getItem($question["id"], $itemId); //var_dump($item);var_dump($itemId); //GOT MEDIA $description = ""; $mediaPath = ""; $mediaType = "T"; // default = text $mediaPath = getItemMediaId($item); //echo "<p>mediaPath : ".$mediaPath."</p>"; if (strlen($mediaPath) > 1) { //récupérer le type du média à partir de l'objet qui vient de l'API (S = sound, P = picture, V = video) $temp = explode("-", $mediaPath); $mediaType = $temp[2]; //echo "Media-URL = ".$mediaPath; if (strlen($mediaType) < 1) { displayError("Le média n'a pas de format dans son url (mediaPath = " . $mediaPath . ")");
<?php require "inc/init.php"; $run_id = preg_replace("/[^0-9]/", "", getItem('run_id', $_POST, '')); $fail = preg_replace("/[^0-9-]/", "", getItem('fail', $_POST, '')); $error = preg_replace("/[^0-9-]/", "", getItem('error', $_POST, '')); $total = preg_replace("/[^0-9-]/", "", getItem('total', $_POST, '')); $results = gzencode(getItem('results', $_POST, '')); # Make sure we've received some results from the client if ($results) { $result = mysql_queryf("UPDATE run_client SET status=2, fail=%u, error=%u, total=%u, results=%s WHERE client_id=%u AND run_id=%u LIMIT 1;", $fail, $error, $total, $results, $client_id, $run_id); if (mysql_affected_rows($result) > 0) { # If we're 100% passing we don't need any more runs if ($total > 0 && $fail == 0 && $error == 0) { # Clear out old runs that were bad, since we now have a good one $result = mysql_queryf("SELECT client_id FROM run_client, clients WHERE run_id=%u AND client_id!=%u AND (total <= 0 OR error > 0 OR fail > 0) AND clients.id=client_id AND clients.useragent_id=%u;", $run_id, $client_id, $useragent_id); while ($row = mysql_fetch_array($result)) { mysql_queryf("DELETE FROM run_client WHERE run_id=%u AND client_id=%u;", $run_id, $row[0]); } $query = mysql_queryf("SELECT clients.id FROM users, clients, useragents WHERE clients.useragent_id=useragents.id AND DATE_ADD(clients.updated, INTERVAL 5 minute) > NOW() AND clients.user_id=users.id AND users.name=%s AND useragents.id=%u AND clients.id!=%u AND clients.id NOT IN (SELECT client_id FROM run_client WHERE run_id=%u)", $_SESSION['username'], $useragent_id, $client_id, $run_id); if ($row = mysql_fetch_array($result)) { # There is another client with the same useragent that did not run the test } else { mysql_queryf("UPDATE run_useragent SET runs = max, completed = completed + 1, status = 2 WHERE useragent_id=%u AND run_id=%u LIMIT 1;", $useragent_id, $run_id); } } else { if ($total > 0) { # Clear out old runs that timed out. $result = mysql_queryf("SELECT client_id FROM run_client, clients WHERE run_id=%u AND client_id!=%u AND total <= 0 AND clients.id=client_id AND clients.useragent_id=%u;", $run_id, $client_id, $useragent_id); while ($row = mysql_fetch_array($result)) { mysql_queryf("DELETE FROM run_client WHERE run_id=%u AND client_id=%u;", $run_id, $row[0]);