HEX
Server: Apache/2.4.18 (Ubuntu)
System: Linux ubuntu 7.0.5-x86_64-linode173 #1 SMP PREEMPT_DYNAMIC Fri May 8 10:12:05 EDT 2026 x86_64
User: root (0)
PHP: 7.2.28-1+ubuntu16.04.1+deb.sury.org+1
Disabled: pcntl_alarm,pcntl_fork,pcntl_waitpid,pcntl_wait,pcntl_wifexited,pcntl_wifstopped,pcntl_wifsignaled,pcntl_wifcontinued,pcntl_wexitstatus,pcntl_wtermsig,pcntl_wstopsig,pcntl_signal,pcntl_signal_get_handler,pcntl_signal_dispatch,pcntl_get_last_error,pcntl_strerror,pcntl_sigprocmask,pcntl_sigwaitinfo,pcntl_sigtimedwait,pcntl_exec,pcntl_getpriority,pcntl_setpriority,pcntl_async_signals,
Upload Files
File: //opt/code/static/api/grid/save_oil.php
<?php 
$dir = dirname(__FILE__);
include_once($dir.'/../util.php');
include_once($dir.'/../db.php');
include_once($dir.'/../token.php');

$stm_history = $_SERVER['DB']->prepare('INSERT INTO oil_user(user_id,datum,turnarounds,exports,extra_exports,padd_demand,padd_hdd,us_hdd,us_hdd_norm)
  VALUES(?,?,?,?,?,?,?,?,?) ON DUPLICATE KEY UPDATE turnarounds = VALUES(turnarounds), exports = VALUES(exports), extra_exports = VALUES(extra_exports), 
  padd_demand = VALUES(padd_demand), padd_hdd = VALUES(padd_hdd), us_hdd = VALUES(us_hdd), us_hdd_norm = VALUES(us_hdd_norm)');
$stm_forecast = $_SERVER['DB']->prepare('INSERT INTO oil_user(user_id,datum,turnarounds,yield,imports,exports,extra_exports,shipments,padd_demand,reported_us_demand,us_hdd,us_hdd_norm,atl_stocks_over_padd)
  VALUES(?,?,?,?,?,?,?,?,?,?,?,?,?) ON DUPLICATE KEY UPDATE turnarounds = VALUES(turnarounds), yield = VALUES(yield), imports = VALUES(imports), exports = VALUES(exports),
  extra_exports = VALUES(extra_exports), shipments = VALUES(shipments), padd_demand = VALUES(padd_demand), reported_us_demand = VALUES(reported_us_demand),
  us_hdd = VALUES(us_hdd), us_hdd_norm = VALUES(us_hdd_norm), atl_stocks_over_padd = VALUES(atl_stocks_over_padd)');
$data = json_decode(file_get_contents('php://input'),TRUE,100,JSON_PARTIAL_OUTPUT_ON_ERROR);
if(is_array($data['history'])) foreach($data['history'] as &$row)
{
  $_SERVER['DB']->bind($stm_history,Array($_SESSION['uid'],substr($row['datum'],0,10),$row['turnarounds'],$row['exports'],$row['extra_exports'],$row['padd_demand'],
    $row['padd_hdd'],$row['us_hdd'],$row['us_hdd_norm']));
  $_SERVER['DB']->exec($stm_history);
}
if(is_array($data['forecast'])) foreach($data['forecast'] as &$row)
{
  $_SERVER['DB']->bind($stm_forecast,Array($_SESSION['uid'],substr($row['datum'],0,10),$row['turnarounds'],$row['yield'],$row['imports'],$row['exports'],
    $row['extra_exports'],$row['shipments'],$row['padd_demand'],$row['reported_us_demand'],$row['us_hdd'],$row['us_hdd_norm'],$row['atl_stocks_over_padd']));
  $_SERVER['DB']->exec($stm_forecast);
}

echo '{"saved":true}';

?>