/** * 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(); } }
if ($idCountry = getId($args['idCountry'], 'countries')) { $post = $request->getParsedBody(); $name = clearStr($post['Name']); $id = insertItem('cities', $name); if (bindItems('ccities', 'Id_Country', 'Id_city', $idCountry['id'], $id)) { return $response->withJson(array("id" => $id, 'idcountry' => $idCountry)); } } return $response->withJson(array('status' => 0, 'message' => "Failed to insert city")); }); /* Add new language */ $app->post("/country/{idCountry}/city/{idCity}/language", function ($request, $response, $args) use($link) { if ($idCity = getId($args['idCity'], 'cities')) { $post = $request->getParsedBody(); $name = clearStr($post['Name']); $id = insertItem('languages', $name); if (bindItems('clanguages', 'Id_City', 'Id_Language', $idCity['id'], $id)) { return $response->withJson(array("id" => $id)); } } return $response->withJson(array('status' => 0, 'message' => "Failed to insert city")); }); /* Delete country by Id */ $app->delete("/country/{id}/", function ($request, $response, $args) use($link) { $id = getId($args['id'], 'countries'); if ($id) { deleteId($id['id'], 'ccities', 'Id_Country', 'i'); deleteId($id['id'], 'countries', 'Id', 'i'); return $response->withJson(array('status' => 1, 'message' => "Country deleted sucsesfully")); } else { return $response->withJson(array('status' => 0, 'message' => "Country ID {$args['id']} does not exists"));
/** * API insert new item via AJAX * * (called from presentation view) */ public function APIinsert(Request $request) { // find plan if (!$request->has('plan_id')) { return response()->json(['status' => 404, 'data' => 'APIinsert: plan_id missing!'], 404); } $plan = Plan::find($request->plan_id); // check user rights if (!checkRights($plan)) { return response()->json(['status' => 401, 'data' => 'Not authorized'], 401); } // insert item into plan $plan = insertItem($request); if ($plan) { return response()->json(['status' => 200, 'data' => $plan]); } // something went wrong! return response()->json(['status' => 405, 'data' => 'Error! Item not inserted!']); }
$smarty->assign('matches', $items); } else { //new $subdept = deptDropDowns(); $smarty->assign('items', ''); $smarty->assign_by_ref('subdept', $subdept); $smarty->assign('buttontext', 'Insert'); $smarty->assign('upc', $items); } break; case 'Update': //update database updateItem(); array2smarty($smarty, item2smartyvarmap(), $_POST); $smarty->assign('displayupdates', 1); $item_template = 'itemMaint.tpl'; break; case 'Insert': // insertItem(); array2smarty($smarty, item2smartyvarmap(), $_POST); $smarty->assign('displayupdates', 1); $item_template = 'itemMaint.tpl'; break; } } elseif (!$_GET['q']) { $item_template = 'itemMaint.tpl'; $smarty->assign('javascriptonload', "onLoad='putFocus(0,0);'"); } $smarty->assign('content', $item_template); $smarty->display('index.tpl');
$ind++; } } } #create starting from the one with the least amount of object_ids foreach ($subjectAsObjects as $subjectObject => $tmp) { $subjectAsObjectsCount[$subjectObject] = count(array_filter($tmp)); } asort($subjectAsObjectsCount, SORT_NUMERIC); #echo '<pre>';print_r($Info);exit; foreach ($Info as $line => $tmp) { foreach ($subjectAsObjectsCount as $subject_id => $count) { //echo '<pre>';print_r($Info[$subject_id]);exit; //create item if (count($Info[$line][$subject_id]) > 1) { $item_id = insertItem($url, $key, $subject_id, urlencode($Info[$line][$subject_id]['label']), $repeat = False); $Info[$line][$subject_id]['item_id'] = $item_id; //create the statements foreach ($Info[$line][$subject_id] as $rule_id => $value) { if ($rule_id != 'label') { $statement_id = insertStatement($url, $key, $item_id, $rule_id, urlencode($value)); if ($statement_id) { $Info[$line][$subject_id][$rule_id . '_statement_id'] = $statement_id; } } } //If this collection is used elsewhere as object, add the appropriate rule_id and value to each of the subject where she is used if ($subjectAsObjectsInverse[$subject_id]) { foreach ($subjectAsObjectsInverse[$subject_id] as $tmp => $collectionHolder) { $rule_id = $subjectAsObjectsInverseRule[$subject_id][$tmp]; $value = $item_id;
$pagesList = $_POST['pages']; $f_o_d = $_POST['food_drink']; $message = ""; $food_or_drink; $f_o_d == 0 ? $food_or_drink = "FOOD" : ($food_or_drink = "DRINK"); /* echo "item: " . $item_name . "\n" . "price: " . $price . "\n" . "quantity: " . $quantity . "\n" . "stock_count: " . $stock_count . "\n" . "age_check: " . $age_check . "\n" . "food or drink: " . $food_or_drink . "\n";*/ $validName = !empty($item_name); $validPrice = is_numeric($price) && $price > 0; $validQuantity = is_numeric($quantity) && $quantity >= 0; if ($validName && $validPrice && $validQuantity) { $insertedItem = insertItem($item_name, $price, $quantity, $stock_count, $age_check, $food_or_drink, $con); if ($insertedItem[0]) { $newItemID = getItemID($item_name, $con); foreach ($_POST['pages'] as $check) { insertItemPagePosition($newItemID, $check, $con); } } // isInserted $message .= "Successfully Added To Database!"; } else { $message .= "NOT VALID\n name " . $validName . "\n price " . $validPrice . "\n quantity " . $validQuantity . "\n"; } } // if post $array = selectPages($con); mysqli_close($con);
$config = parse_ini_file('tricklepost.ini'); $feeds = parse_ini_file('feeds.ini', true); $connection = mysql_connect($config['mysql_host'], $config['mysql_user'], $config['mysql_passwd']) or die('Could not connect: ' . mysql_error()); mysql_select_db('tricklepost') or die('Could not select database'); foreach ($feeds as $feed) { $feed_data = new SimplePie(); $feed_data->set_feed_url($feed['uri']); $feed_data->enable_cache(false); $feed_data->init(); $feed_data->handle_content_type(); print "Reading feed: {$feed['uri']} ...\n"; foreach ($feed_data->get_items() as $item) { // make sure the item's URL is good $plink = $item->get_permalink(); if (validUrl($plink)) { insertItem($item, $feed['uri'], $feed['username'], $feed['password'], $feed['endpoint']); } } } mysql_close($connection); print "Done.\n"; function insertItem($item, $feedsource, $username, $password, $endpoint) { global $connection; $title = $item->get_title(); $permalink = $item->get_permalink(); $itemdate = $item->get_date(); // Don't bother with incomplete items if (empty($title) || empty($permalink) || empty($itemdate)) { return; }
$itemSampleId = insertItem($url, $key, $splCollection, $cells[$line][$sampleCol]); ##Find the rule for date of sampling based on object $dateSamplingRuleId = $ruleIds[array_search('date of sampling', $ruleObjs)]; $dateSamplingValue = $cells[$line][$dateSamplingCol]; #Insert statement for Sample date of Sampling $dateSamplingInserted = insertStatement($url, $key, $itemSampleId, $dateSamplingRuleId, $cells[$line][$dateSamplingCol]); #Now find the rule for sample id $codeRuleId = $splRule[array_search('code', $splObj)]; $codeValue = $cells[$line][$sampleCol]; #Insert statement for Sample code of Sample $dateSamplingInserted = insertStatement($url, $key, $itemSampleId, $codeRuleId, $codeValue); ############################################################################## ##Sample Done ##Insert Isolate #Insert an Item for Isolate $itemIsolateId = insertItem($url, $key, $isoltCollection, $cells[$line][$isolateCol]); #Find the rule for isolate species $isltSpeciesRuleId = $isltRule[array_search('species', $isltObj)]; $isltSpeciesValue = $cells[$line][$speciesCol]; #Insert statement for isolate species $isltSpeciesInserted = insertStatement($url, $key, $itemIsolateId, $isltSpeciesRuleId, $isltSpeciesValue); #Find the rule for isolate PFGE Type $isltPFGERuleId = $isltRule[array_search('pfge type', $isltObj)]; $isltPFGEValue = $cells[$line][$pfgeCol]; #Insert statement for isolate pfge $isltPFGEInserted = insertStatement($url, $key, $itemIsolateId, $isltPFGERuleId, $isltPFGEValue); #Find the rule for isolate CC $isltCCRuleId = $isltRule[array_search('mlst cc', $isltObj)]; $isltCCValue = $cells[$line][$ccCol]; #Insert statement for isolate cc $isltCCInserted = insertStatement($url, $key, $itemIsolateId, $isltCCRuleId, $isltCCValue);