function OpenApp($title) { $_retval = false; if (!OpenDB()) { return $_retval; } if (!empty($title)) { AppHeader($GLOBALS['appName'] . "-" . $title); } $GLOBALS['accessRights'] = "rw"; // CHECK APPLICATION SECURITY HERE (in this example, "r" gives read-only access and "rw" gives read/write access) if (empty($GLOBALS['accessRights']) || !isset($GLOBALS['accessRights']) || substr($GLOBALS['accessRights'], 0, 1) != "r") { echo "<p class='error'>You do not have permission to access this application"; } else { $_retval = true; } return $_retval; }
#detail { height:100%; width:70%; float:left; border: 1px solid #EEE; } </style> </head> <body> <div id='tablist'> <p><strong>Rico Raw Data Viewer</strong> <?php require "applib.php"; OpenDB(); DisplaysObjects("TABLE"); DisplaysObjects("VIEW"); CloseApp(); function DisplaysObjects($ObjType) { global $oDB; $arTables = $oDB->GetTableList($ObjType); echo "<p><strong>" . $ObjType . "S</strong>"; if (!is_array($arTables)) { return; } echo "<ul>"; foreach ($arTables as $tabName) { echo "<li><a href='RicoDbViewerDetail.php?id=" . $tabName . "' target='detail'>" . $tabName . "</a>"; }
<html> <head> <title>Rico-Table Detail</title> <script src="../../src/min.rico.js" type="text/javascript"></script> <link href="../../src/css/min.rico.css" type="text/css" rel="stylesheet" /> <link href="../../src/css/greenHdg.css" type="text/css" rel="stylesheet" /> <link href="../client/css/demo.css" type="text/css" rel="stylesheet" /> <?php require "applib.php"; require "chklang2.php"; $arColumns = array(); $columnlist = ""; $colspecs = ""; if (isset($_GET["id"]) && OpenDB()) { $id = trim($_GET["id"]); $arColumns = $oDB->GetColumnInfo($id); for ($i = 0; $i < count($arColumns); $i++) { if (!empty($columnlist)) { $columnlist .= ","; $colspecs .= ","; } $columnlist .= $arColumns[$i]->ColName; $colspecs .= "{Hdg:'" . $arColumns[$i]->ColName . "'"; if ($arColumns[$i]->ColType == "DATETIME") { $colspecs .= ",type:'datetime'"; } $colspecs .= "}"; } $_SESSION[$id] = "select " . $columnlist . " from " . $id . "";
header("Cache-Control: no-cache"); header("Pragma: no-cache"); header("Expires: " . gmdate("D, d M Y H:i:s", time() + -1 * 60) . " GMT"); header("Content-type: text/xml"); echo "<?xml version='1.0' encoding='iso-8859-1'?>\n"; require "applib.php"; require "../../plugins/php/ricoXmlResponse.php"; $id = isset($_GET["id"]) ? $_GET["id"] : ""; $parent = isset($_GET["Parent"]) ? $_GET["Parent"] : ""; echo "\n<ajax-response><response type='object' id='" . $id . "_updater'>"; if ($id == "") { echo "\n<rows update_ui='false' /><error>"; echo "\nNo ID provided!"; echo "\n</error>"; } elseif (!OpenDB()) { echo "\n<rows update_ui='false' /><error>"; echo "\n" . htmlspecialchars($oDB->LastErrorMsg); echo "\n</error>"; } else { $oDB->DisplayErrors = false; $oDB->ErrMsgFmt = "MULTILINE"; $oXmlResp = new ricoXmlResponse(); echo "\n<rows update_ui='true' offset='0'>"; if ($parent) { $oXmlResp->Query2xmlRaw("SELECT '{$parent}',CustomerID,CompanyName,'L',1 FROM customers where CompanyName like '{$parent}%'", 0, 99); } else { $oXmlResp->WriteTreeRow("", "root", "Customer names starting with...", "C", 0); $oXmlResp->Query2xmlRaw("SELECT distinct 'root',left(CompanyName,1),left(CompanyName,1),'C',0 FROM customers", 0, 99); } print "\n" . "</rows>";
$grid->AddHeadingRow(false); $grid->AddCell("ID"); $grid->AddCell("ID"); $grid->AddCell("Shipment"); $grid->SetCellAttr("colspan", 3); $grid->AddCell("Date"); $grid->SetCellAttr("colspan", 2); $grid->AddHeadingRow(true); $grid->AddCell("Order"); $grid->AddCell("Customer"); $grid->AddCell("Name"); $grid->AddCell("City"); $grid->AddCell("Country"); $grid->AddCell("Order"); $grid->AddCell("Ship"); if (OpenDB()) { $sqltext = "select OrderID,CustomerID,ShipName,ShipCity,ShipCountry,OrderDate,ShippedDate from orders order by OrderID"; $rsMain = $oDB->RunQuery($sqltext); $colcnt = $oDB->db->NumFields($rsMain); while ($oDB->db->FetchRow($rsMain, $row)) { $grid->AddDataRow(); for ($i = 0; $i < $colcnt; $i++) { $v = utf8_encode($row[$i]); $v = htmlspecialchars($v, ENT_COMPAT, 'UTF-8'); $grid->AddCell($v); } } $oDB->rsClose($rsMain); } $grid->Render("ex3", 1); // output html
function getLastStoredDateTime() { OpenDB(); global $DEBUG; $lDate_time = date('i'); //retrun only minutes $dateTimeNow = date('Y-m-d H:i:00'); if ($DEBUG) { echo "\n<p>" . $lDate_time . "</p>\n"; } //fetch minutes and full datetime $query = "Select DATE_FORMAT(date_time, '%i') as dt, date_time FROM `avrtemp` ORDER by date_time DESC LIMIT 1;"; $result = mysql_query($query); if ($result) { while ($row = mysql_fetch_array($result)) { //should only be one row $mValDB = $row['dt']; if ($DEBUG) { echo "\n<p>Minutes stored last: " . $row['dt'] . "</p>\n"; } if (intval($mValDB) - intval($lDate_time) != 0) { $diffVal = abs(intval($mValDB) - intval($lDate_time)); if ($diffVal <= 2) { if ($DEBUG) { echo "\n<p>Data found and Diff <=2: date(now)=" . $dateTimeNow . ", last stored=" . $row['date_time'] . "</p>\n"; } return $row['date_time']; //return db last datetime } else { if ($DEBUG) { echo "\n<p>Diff > 2: date(now)=" . $dateTimeNow . ", last stored=" . $row['date_time'] . "</p>\n"; } } } else { if ($DEBUG) { echo "\n<p>Data found and Diff = 0: date(now)=" . $dateTimeNow . ", last stored=" . $row['date_time'] . "</p>\n"; } } } } else { if ($DEBUG) { echo "\n<p>getLastStoredDateTime(): query did not return result</p>\n"; } } if ($DEBUG) { echo "\n<p>Data not found or Diff to large: " . $dateTimeNow . "</p>\n"; } return $dateTimeNow; //return current datetime }
function connection_close() { OpenDB(); global $DBLink; mysqli_close($DBLink); }