Example #1
0
 public function getUpdateschema()
 {
     //$itemschema = SteamApi::itemschema();
     $doc = new DOMDocument();
     $start = 0;
     $count = 100;
     $gid = 730;
     $max = 999;
     $i = 0;
     $marketlist = SteamApi::getMarket($start, $count, $gid);
     //$listutf8 = htmlentities($marketlist->results_html, NULL, 'UTF-8');
     $max = $marketlist->total_count;
     $doc->loadHTML($marketlist->results_html);
     $xpath = new DOMXPath($doc);
     $marketitems = $xpath->query("//*[contains(concat(' ', normalize-space(@class), ' '), 'market_listing_row_link')]");
     //var_dump($itemlist);
     foreach ($marketitems as $marketitem) {
         $item["marketlink"] = $marketitem->getAttribute("href");
         $item["markethash"] = substr($item["marketlink"], strrpos($item["marketlink"], '/') + 1);
         $item["marketname"] = urldecode($item["markethash"]);
         $getitemname = explode("%28", $item["markethash"]);
         $item["itemname"] = urldecode($getitemname[0]);
         $itemvalue = SteamApi::getItemValue($item["markethash"], $gid);
         if ($itemvalue == null) {
             $item["value"] = 0;
         } else {
             $item["value"] = substr($itemvalue->lowest_price, 5);
         }
         preg_match_all("/\\(([^)]+)\\)/", $item["marketname"], $matches);
         if ($matches[1][0]) {
             $item["exterior"] = $matches[1][0];
         } else {
             $item["exterior"] = "";
         }
         /*$getvalue = $xpath->query("//*[contains(concat(' ', normalize-space(@class), ' '), 'market_table_value')]", $marketitem);
         		$values = $xpath->query("//*[contains(concat(' ', normalize-space(@style), ' '), 'color:white')]", $getvalue->item(0));
         		foreach($values as $value)
         		{						
         			//var_dump($value);
         		}*/
         $items[] = $item;
     }
     //print_r($items);
     foreach ($items as $item) {
         $item_row = ItemSchema::where('markethashname', '=', $item["markethash"])->first();
         if ($item_row == false) {
             $item_row = new ItemSchema();
             $item_row->itemname = $item["itemname"];
             $item_row->marketname = $item["marketname"];
             $item_row->markethashname = $item["markethash"];
             $item_row->marketlink = $item["marketlink"];
             $item_row->minvalue = $item["value"];
             $item_row->exterior = $item["exterior"];
             //$item_row->imagenormal       = $item["imagenormal"];
             $item_row->save();
         } else {
             $item_row->itemname = $item["itemname"];
             $item_row->marketname = $item["marketname"];
             $item_row->markethashname = $item["markethash"];
             $item_row->marketlink = $item["marketlink"];
             $item_row->minvalue = $item["value"];
             $item_row->exterior = $item["exterior"];
             //$item_row->imagenormal       = $item["imagenormal"];
             $item_row->save();
         }
     }
     return $view = View::make('default.admin.edit.itemschema');
 }