<?php $conn; if (isset($_POST["operation"])) { if ($_POST["operation"] == 'edit') { editdata(); } if ($_POST["operation"] == 'delete') { deletedata(); } } else { fetchdata(); } function editdata() { if (connectdb()) { $conn = connectdb(); } $editquery = "UPDATE formdata SET name='{$_POST['name']}',sex='{$_POST['sex']}',email='{$_POST['email']}',country='{$_POST['country']}',\n\t\t\t\t\t\t\t\t\t\tstate='{$_POST['state']}',address='{$_POST['address']}',mobileno='{$_POST['mobileno']}',interest='{$_POST['interests']}',favorites='{$_POST['favorites']}' where email='{$_POST['email']}'"; if (mysqli_query($conn, $editquery)) { echo '{"message":"Successfully updated"}'; } else { echo "Error"; } mysqli_close($conn); } function connectdb() { $GLOBALS['conn'] = new mysqli("localhost", "root", "", "subscription"); // Check connection
<?php //libxml_use_internal_errors(true); error_reporting(E_ALL); $uuid = uuid(); $key1 = 'http://bems.ee.eng.chula.ac.th/eng4/fl13/north/room_server/z1/sensor1/monitor/temperature'; $key2 = 'http://bems.ee.eng.chula.ac.th/eng4/fl13/north/room_server/z1/sensor1/monitor/humidity'; $temp = fetchdata($key1, $uuid); var_dump($temp); function fetchdata($keyid, $uuid) { $mydata = "<?xml version='1.0' encoding='UTF-8'?>\n<soapenv:Envelope xmlns:soapenv='http://schemas.xmlsoap.org/soap/envelope/'>\n<soapenv:Body>\n<ns2:queryRQ xmlns:ns2='http://soap.fiap.org/'>\n<transport xmlns='http://gutp.jp/fiap/2009/11/'>\n<header>\n<query id='" . $uuid . "' type='storage'>\n<key id='{$keyid}' attrName='time' select='maximum' />\n</query>\n</header>\n</transport>\n</ns2:queryRQ>\n</soapenv:Body>\n</soapenv:Envelope>"; $url = "http://161.200.90.122/axis2/services/FIAPStorage"; $headers = array("Content-type: text/xml", "Content-length: " . strlen($mydata), "SOAPAction: http://soap.fiap.org/query"); $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, $url); curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0); curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0); curl_setopt($ch, CURLOPT_POSTFIELDS, $mydata); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); curl_setopt($ch, CURLOPT_HTTPHEADER, $headers); curl_setopt($ch, CURLOPT_VERBOSE, 0); $data = curl_exec($ch); if ($data === false) { $error = curl_error($ch); echo $error; die('error occured'); } else { $xml = simplexml_load_string($data); $ns = $xml->getNamespaces(true); $child = (string) $xml->children($ns['soapenv'])->Body->children($ns['ns2'])->queryRS->children($ns[''])->transport->body->point->value;
$data = stristr($data, $start); // Stripping all data from before $start $data = substr($data, strlen($start)); // Stripping $start $stop = stripos($data, $end); // Getting the position of the $end of the data to scrape $data = substr($data, 0, $stop); // Stripping all data from after and including the $end of the data to scrape return $data; // Returning the scraped data from the function } if (isset($_GET['url'])) { $beg = "<div class=\"productSpecs specSection\">"; $link = $_GET['url']; $page = scrape($link); $spec = fetchdata($page, $beg, "</div>"); echo $spec; } if (isset($_GET["amz"])) { $name = $_GET["amz"]; $name = str_replace(" ", "+", $name); $price = 0; $link = "#"; $amzlink = "http://www.amazon.in/s/ref=nb_sb_noss_2?field-keywords=" . $name; $adata = scrape($amzlink); echo $adata; /**$uldata=fetchdata($adata,'<ul id="s-results-list-atf"','</ul>'); $product=fetchdata($uldata,'<li id="result_1"','</li>'); if($product){ $link=fetchdata($product,'<a class="a-link-normal a-text-normal" href="','">');
$dayscount = floor($datediff / (60 * 60 * 24)); $fromdate = $startdate; $todate = $enddate; $current = 0; for ($x = 0; $x < $dayscount; $x++) { if ($dayscount - $current > $interval) { $todate = date('Ymd', strtotime($fromdate . ' + 31 days')); //print_r($fromdate); $current = $current + $interval; $fromdate = date('Ymd', strtotime($fromdate . ' + 31 days')); fetchdata($fromdate, $todate); } else { $x = $dayscount - $current; $todate = date('Ymd', strtotime($fromdate . ' + ' . $x . ' days')); $current = $dayscount; fetchdata($fromdate, $todate); break; } } // fetch data from moves api function fetchdata($fromdate, $todate) { $user = fetch('GET', '/user/profile'); $user2 = fetch('GET', '/user/summary/daily?from=' . $fromdate . '&to=' . $todate . ''); print_r($user2); $userid = $user->userId; insertindatabase($user2, $userid); } //get data from api before insert it function insertindatabase($user, $userid) {
<link rel="stylesheet" href="assets/mobirise-slider/style.css"> <link rel="stylesheet" href="assets/mobirise/css/mbr-additional.css" type="text/css"> </head> <?php //libxml_use_internal_errors(true); error_reporting(E_ALL); $uuid1 = uuid(); $key1 = 'http://bems.ee.eng.chula.ac.th/eng4/fl13/north/room_server/z1/sensor1/monitor/temperature'; $key2 = 'http://bems.ee.eng.chula.ac.th/eng4/fl13/north/room_server/z1/sensor1/monitor/humidity'; $temp = fetchdata($key1, $uuid1); //var_dump($temp); $uuid2 = uuid(); $humid = fetchdata($key2, $uuid2); function fetchdata($keyid, $uuid) { $mydata = "<?xml version='1.0' encoding='UTF-8'?>\n<soapenv:Envelope xmlns:soapenv='http://schemas.xmlsoap.org/soap/envelope/'>\n<soapenv:Body>\n<ns2:queryRQ xmlns:ns2='http://soap.fiap.org/'>\n<transport xmlns='http://gutp.jp/fiap/2009/11/'>\n<header>\n<query id='" . $uuid . "' type='storage'>\n<key id='{$keyid}' attrName='time' select='maximum' />\n</query>\n</header>\n</transport>\n</ns2:queryRQ>\n</soapenv:Body>\n</soapenv:Envelope>"; $url = "http://161.200.90.122/axis2/services/FIAPStorage"; $headers = array("Content-type: text/xml", "Content-length: " . strlen($mydata), "SOAPAction: http://soap.fiap.org/query"); $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, $url); curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0); curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0); curl_setopt($ch, CURLOPT_POSTFIELDS, $mydata); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); curl_setopt($ch, CURLOPT_HTTPHEADER, $headers); curl_setopt($ch, CURLOPT_VERBOSE, 0); $data = curl_exec($ch); if ($data === false) {
$aprice = str_replace(",", "", $aprice); preg_match_all('/(?:([0-9]{1,}))/', $aprice, $matches); $aprice = $matches[0][0]; if (!$alink && !$aprice) { $amz_avi = 0; } else { $amz_avi = 1; } $elink = "#"; $eprice = 0; $ebaylink = "http://www.ebay.in/sch/i.html?_nkw=" . $name; $edata = scrape($ebaylink); $uldata = fetchdata($edata, '<ul id="ListViewInner">', '</ul>'); $elink = fetchdata($uldata, 'href="', '"'); $eli = fetchdata($uldata, '<li class="lvprice prc">', '</li>'); $eprice = fetchdata($eli, '<span class="bold">', '</span>'); preg_match_all('/(?:([0-9,]{1,}))/', $eli, $matches); $eprice = $matches[0][0]; $eprice = str_replace(",", "", $eprice); if (!$elink && !$eprice) { $ebay_avi = 0; } else { $ebay_avi = 1; } } $query = "update product set amz_price=" . $aprice . ",amz_url='" . $alink . "',ebay_price=" . $eprice . " ,ebay_url='" . $elink . "'"; } function scrape($url) { $opts = array('http' => array('header' => "User-Agent:Chrome/1.0\r\n")); $context = stream_context_create($opts);
} if (isset($_GET['url'])) { $beg = "<div class=\"productSpecs specSection\">"; $link = $_GET['url']; $page = scrape($link); $spec = fetchdata($page, $beg, "</div>"); echo $spec; } if (isset($_GET["amz"])) { $name = $_GET["amz"]; $name = str_replace(" ", "+", $name); $price = 0; $link = "#"; $amzlink = "http://www.amazon.in/s/ref=nb_sb_noss_2?field-keywords=" . $name; $adata = scrape($amzlink); $uldata = fetchdata($adata, '<ul id="s-results-list-atf"', '</ul>'); $product = fetchdata($uldata, '<li id="result_1"', '</li>'); if ($product) { $link = fetchdata($product, '<a class="a-link-normal a-text-normal" href="', '">'); $price = fetchdata($product, '<span class="a-size-base a-color-price s-price a-text-bold"><span class="currencyINR"> </span>', '</span>'); } else { $link - fetchdata($product, 'href="', '"'); $price = fetchdata($adata, '<span class="a-size-base a-color-price s-price a-text-bold"><span class="currencyINR"> </span>', '</span>'); } $product_details = array('price' => $price, 'url' => $link); echo json_encode($product_details); } ?>