function errData($id) { db_con("cubit"); $sql = "SELECT errtime::date AS errtime, errdata\n\t\t\tFROM errordumps WHERE id='{$_GET['id']}'"; $rslt = db_exec($sql) or die("Unable to stream error dump"); if (pg_num_rows($rslt) < 1) { $data = array("errtime" => date("Y-m-d"), "errdata" => base64_encode("invalid error id.")); } else { $data = pg_fetch_array($rslt); } $data["errdata"] = bzcompress(base64_decode($data["errdata"]), 9); return $data; }
function recover() { db_con("cubit"); $sql = "SELECT * FROM companies WHERE status='active'"; $rslt = db_exec($sql); while ($r = pg_fetch_array($rslt)) { if (!exists_compdb($r["code"])) { db_con("cubit"); $sql = "UPDATE companies SET status='no database' WHERE code='{$r['code']}'"; db_exec($sql); } } db_con("cubit"); $sql = "SELECT * FROM companies WHERE status='active'"; $rslt = db_exec($sql); if (pg_num_rows($rslt) > 0) { session_destroy(); header("Location: complogin.php"); exit; } return newcomp(); }
<?php include "common.php"; //データベースに接続 $pdo = db_con(); ?> <!DOCTYPE html> <html lang="ja"> <head> <meta charset="utf-8"> <meta http-equiv="X-UA-Compatible" content="IE=edge"> <title>Photoruction -アルバム-</title> <link rel="stylesheet" type="text/css" href="css/jquery-ui.min.css"> <link rel="stylesheet" type="text/css" href="css/bootstrap.min.css"> <link rel="stylesheet" type="text/css" href="css/bootstrap-select.min.css"> <link rel="stylesheet" type="text/css" href="css/roboto.min.css"> <link rel="stylesheet" type="text/css" href="css/material-fullpalette.min.css"> <link rel="stylesheet" type="text/css" href="css/ripples.min.css"> <link rel="stylesheet" type="text/css" href="css/non-responsive.css"> <link rel="stylesheet" type="text/css" href="css/chat.css"> <link rel="stylesheet" type="text/css" href="css/common.css"> <link rel="stylesheet" href="css/album.css"> </head> <body> <!-- ナビゲーション--> <?php echo navigationSelect(ALBUM); ?>
function printAgeAge() { # Set up table to display in $printCust = "\n\t\t<h3>Debtors Age Analysis</h3>\n\t\t<table " . TMPL_tblDflts . ">\n\t\t\t<tr>\n\t\t\t\t<th>Acc no.</th>\n\t\t\t\t<th>Customer</th>\n\t\t\t\t<th>Sales Rep</th>\n\t\t\t\t<th>Contact Name</th>\n\t\t\t\t<th>Tel No.</th>\n\t\t\t\t<th>Current</th>\n\t\t\t\t<th>30 days</th>\n\t\t\t\t<th>60 days</th>\n\t\t\t\t<th>90 days</th>\n\t\t\t\t<th>120 days</th>\n\t\t\t\t<th>Total Outstanding</th>\n\t\t\t</tr>"; # Connect to database db_connect(); # Query server $i = 0; $sql = "SELECT * FROM customers WHERE div = '" . USER_DIV . "' ORDER BY accno ASC"; $custRslt = db_exec($sql) or errDie("Unable to retrieve Customers from database."); if (pg_numrows($custRslt) < 1) { return "<li>There are no Customers in Cubit.</li>"; } # Totals $totcurr = 0; $tot30 = 0; $tot60 = 0; $tot90 = 0; $tot120 = 0; $alltot = 0; while ($cust = pg_fetch_array($custRslt)) { # Get all ages $to_month = date("m"); $to_date = "now"; $from_date = date("Y-m-d", mktime(0, 0, 0, date("m"), "01", date("Y"))); $curr = cust_age($cust['cusnum'], 29, $cust['fcid'], $cust['location'], $to_month, $to_date, $from_date); $age30 = cust_age($cust['cusnum'], 59, $cust['fcid'], $cust['location'], $to_month, $to_date, $from_date); $age60 = cust_age($cust['cusnum'], 89, $cust['fcid'], $cust['location'], $to_month, $to_date, $from_date); $age90 = cust_age($cust['cusnum'], 119, $cust['fcid'], $cust['location'], $to_month, $to_date, $from_date); $age120 = cust_age($cust['cusnum'], 149, $cust['fcid'], $cust['location'], $to_month, $to_date, $from_date); # Customer total $custtot = sprint($curr + $age30 + $age60 + $age90 + $age120); db_con("exten"); # sales rep $get_salsp = "SELECT salesp FROM salespeople WHERE salespid = '{$cust['sales_rep']}' LIMIT 1"; $run_salsp = db_exec($get_salsp) or errDie("Unable to get sales person information."); if (pg_numrows($run_salsp) > 0) { $sarr = pg_fetch_array($run_salsp); $salesperson = $sarr['salesp']; } else { $salesperson = ""; } $printCust .= "\n\t\t\t<tr class='" . bg_class() . "'>\n\t\t\t\t<td>{$cust['accno']}</td>\n\t\t\t\t<td>{$cust['surname']}</td>\n\t\t\t\t<td>{$salesperson}</td>\n\t\t\t\t<td>{$cust['contname']}</td>\n\t\t\t\t<td>{$cust['tel']}</td>\n\t\t\t\t<td>" . CUR . " {$curr}</td>\n\t\t\t\t<td>" . CUR . " {$age30}</td>\n\t\t\t\t<td>" . CUR . " {$age60}</td>\n\t\t\t\t<td>" . CUR . " {$age90}</td>\n\t\t\t\t<td>" . CUR . " {$age120}</td>\n\t\t\t\t<td>" . CUR . " {$custtot}</td>\n\t\t\t</tr>"; # Hold totals $totcurr += $curr; $tot30 += $age30; $tot60 += $age60; $tot90 += $age90; $tot120 += $age120; $alltot += $custtot; $i++; } $totcurr = sprint($totcurr); $tot30 = sprint($tot30); $tot60 = sprint($tot60); $tot90 = sprint($tot90); $tot120 = sprint($tot120); $alltot = sprint($alltot); $printCust .= "\n\t\t\t" . TBL_BR . "\n\t\t\t<tr class='" . bg_class() . "'>\n\t\t\t\t<td colspan='4'><b>Totals</b></td>\n\t\t\t\t<td nowrap><b>" . CUR . " {$totcurr}</b></td>\n\t\t\t\t<td nowrap><b>" . CUR . " {$tot30}</b></td>\n\t\t\t\t<td nowrap><b>" . CUR . " {$tot60}</b></td>\n\t\t\t\t<td nowrap><b>" . CUR . " {$tot90}</b></td>\n\t\t\t\t<td nowrap><b>" . CUR . " {$tot120}</b></td>\n\t\t\t\t<td nowrap><b>" . CUR . " {$alltot}</b></td>\n\t\t\t</tr>\n\t\t\t" . TBL_BR . "\n\t\t\t<tr>\n\t\t\t\t<td align='center' colspan='10'><input type='submit' name='xls' value='Export to spreadsheet'></td>\n\t\t\t</tr>\n\t\t</table>\n\t <p>\n\t\t<table " . TMPL_tblDflts . " width='15%'>\n\t " . TBL_BR . "\n\t <tr>\n\t \t<th>Quick Links</th>\n\t </tr>\n\t\t\t<tr class='" . bg_class() . "'>\n\t\t\t\t<td><a href='index-reports.php'>Financials</a></td>\n\t\t\t</tr>\n\t\t\t<tr class='" . bg_class() . "'>\n\t\t\t\t<td><a href='index-reports-debtcred.php'>Debtors & Creditors Reports</a></td>\n\t\t\t</tr>\n\t\t\t<tr class='" . bg_class() . "'>\n\t\t\t\t<td><a href='../customers-new.php'>Add Customer</a></td>\n\t\t\t</tr>\n\t\t\t<tr class='" . bg_class() . "'>\n\t\t\t\t<td><a href='../customers-view.php'>View Customers</a></td>\n\t\t\t</tr>\n\t\t\t<tr class='" . bg_class() . "'>\n\t\t\t\t<td><a href='../main.php'>Main Menu</a></td>\n\t\t\t</tr>\n\t\t</table>"; return $printCust; }
function errorNetSave() { global $XMLNS; global $ERRNET_ERRORS; global $SQL_EXEC; global $CUBIT_MODULES; if (!defined("ERRORNET_OCCURED")) { return -1; } $xmlns = "xmlns=\"{$XMLNS['errornet']}\""; $OUT = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n"; $OUT .= "<cubiterror version=\"0.1\" time=\"" . date("l dS \\of F Y h:i:s A") . "\"/>\n"; /* cubit info */ $OUT .= "<cubit {$xmlns}\n>\n"; $OUT .= "<cdata {$xmlns} desc=\"version\">" . CUBIT_VERSION . "</cdata>\n"; $OUT .= "<cdata {$xmlns} desc=\"build\">" . CUBIT_BUILD . "</cdata>\n"; $OUT .= "<cdata {$xmlns} desc=\"platform\" value=\"" . PLATFORM . "\">" . xmldata(php_uname()) . "</cdata>\n"; $OUT .= "<cdata {$xmlns} desc=\"phpversion\">" . phpversion() . "</cdata>\n"; $OUT .= "<cdata {$xmlns} desc=\"cengineversion\">" . phpversion("cengine") . "</cdata>\n"; $OUT .= "<cdata {$xmlns} desc=\"debugmode\">" . (defined("DEBUG") && DEBUG == 1 ? "true" : "false") . "</cdata>\n"; $OUT .= "<cmodules {$xmlns}>\n"; $OUT .= array2xml("cdata", "num", "{$xmlns}", $CUBIT_MODULES); $OUT .= "</cmodules>\n"; $OUT .= "</cubit>"; /* sql queries */ $OUT .= "<sql {$xmlns}>\n"; $OUT .= array2xml("data", "num", "{$xmlns}", $SQL_EXEC); $OUT .= "</sql>"; /* php configuration */ $OUT .= "<phpconf {$xmlns}>\n"; $OUT .= array2xml("data", "name", "{$xmlns}", ini_get_all()); $OUT .= "</phpconf>\n"; /* error details */ $errnum = 1; foreach ($ERRNET_ERRORS as $k => $v) { $OUT .= "<error {$xmlns} num=\"{$errnum}\">\n"; $OUT .= "{$v}\n"; $OUT .= "</error>\n"; ++$errnum; } $errdata = base64_encode($OUT); db_con("cubit"); pglib_transact("ROLLBACK"); $sql = "INSERT INTO errordumps (errtime, errdata)\n\t\t\tVALUES(CURRENT_TIMESTAMP, '{$errdata}')"; $rslt = db_exec($sql) or errDie("Error storing error dump report."); return pglib_lastid("errordumps", "id"); }
function getCountryList() { $mysqli = db_con(); //$returnVal[] = array("asd","asd"); $result = $mysqli->query("SELECT code,name FROM `country`"); if ($result) { while ($row = $result->fetch_row()) { $returnVal[] = $row; } } else { print $mysqli->connect_error; } return $returnVal; }
/** * checks the db for the stored root docroot to cubit and returns the path * */ function locateRoot() { if (isset($_SESSION["code"])) { $ex = "_{$_SESSION['code']}"; } else { if (defined("CONSOLE")) { $ex = "_" . CONSOLE; } else { $ex = ""; } } db_con("cubit"); $sql = "SELECT value FROM globalset WHERE name='docroot{$ex}'"; $rslt = db_exec($sql) or die("Error reading document root."); if (pg_num_rows($rslt) > 0) { /** * document root of cubit (full path) */ db_conn("cubit"); return pg_fetch_result($rslt, 0); } else { if (defined("CONSOLE")) { /* loop until root is found */ $CWD = CUBIT_WD; $CP = preg_replace("/[\\\\]/", "/", $CWD); while (!is_file("{$CP}/_defineroot.php") && $CP != "/") { $CP = dirname($CP); } /* make sure the file really exists */ if (!is_file("{$CP}/_defineroot.php")) { return false; } /* save it */ $sql = "INSERT INTO globalset (name, value) VALUES('docroot{$ex}', '{$CP}')"; @db_exec($sql); return $CP; } else { $me = basename(getenv("SCRIPT_NAME")); if (is_file("_defineroot.php")) { header("Location: _defineroot.php?p={$me}"); } else { if (is_file("../_defineroot.php")) { header("Location: ../_defineroot.php?p={$me}"); } else { if (is_file("../../_defineroot.php")) { header("Location: ../../_defineroot.php?p={$me}"); } else { if (is_file("../../../_defineroot.php")) { header("Location: ../../../_defineroot.php?p={$me}"); } } } } exit; } } die("Unable to locate document root."); }
function edit($listid) { extract($_POST); if (!isset($offset) or $offset < 0) { $offset = 0; } if (isset($next)) { $offset += SHOW_LIMIT; } $listing = ""; # validate input require_lib("validate"); $v = new validate(); $v->isOk($listid, "num", 1, 50, "Invalid Price List id."); # display errors, if any if ($v->isError()) { $confirm = ""; $errors = $v->getErrors(); foreach ($errors as $e) { $confirm .= "<li class='err'>-" . $e["msg"] . "</li>"; } return $confirm; } $vattype = getSetting("SELAMT_VAT") == 'inc' ? "Including Vat" : "Excluding Vat"; # Select Stock db_conn("exten"); $sql = "SELECT * FROM spricelist WHERE listid = '{$listid}' AND div = '" . USER_DIV . "'"; $listRslt = db_exec($sql) or errDie("Unable to access databse.", SELF); if (pg_numrows($listRslt) < 1) { return "<li> Invalid Price List ID.</li>"; } else { $list = pg_fetch_array($listRslt); } db_connect(); $category_drop = "<select name='stockcat'>"; $sql = "SELECT catid, cat, catcod FROM stockcat WHERE div = '" . USER_DIV . "' ORDER BY cat ASC"; $catRslt = db_exec($sql); if (pg_numrows($catRslt) < 1) { return "<li>There are no stock categories in Cubit.</li>"; } else { while ($cat = pg_fetch_array($catRslt)) { if (isset($stockcat) and $stockcat == $cat['catid']) { $category_drop .= "<option value='{$cat['catid']}' selected>({$cat['catcod']}) {$cat['cat']}</option>"; } else { $category_drop .= "<option value='{$cat['catid']}'>({$cat['catcod']}) {$cat['cat']}</option>"; } } } $category_drop .= "</select>"; # Select classification $classification_drop = "<select name='stockclass'>"; $sql = "SELECT * FROM stockclass WHERE div = '" . USER_DIV . "' ORDER BY classname ASC"; $clasRslt = db_exec($sql); if (pg_numrows($clasRslt) < 1) { return "<li>There are no Classifications in Cubit.</li>"; } else { while ($clas = pg_fetch_array($clasRslt)) { if (isset($stockclass) and $stockclass == $clas['clasid']) { $classification_drop .= "<option value='{$clas['clasid']}' selected>{$clas['classname']}</option>"; } else { $classification_drop .= "<option value='{$clas['clasid']}'>{$clas['classname']}</option>"; } } } $classification_drop .= "</select>"; db_con("exten"); # Query server $i = 0; // $sql = "SELECT * FROM splist_prices WHERE listid = '$listid' AND div = '".USER_DIV."' ORDER BY stkid ASC"; $sql = "\r\n\t\tSELECT listid, stkid, catid, clasid, price, div, supstkcod \r\n\t\tFROM splist_prices \r\n\t\tWHERE listid = '{$listid}' AND div = '" . USER_DIV . "' {$searchsql} \r\n\t\tORDER BY stkid ASC OFFSET {$offset} \r\n\t\tLIMIT " . SHOW_LIMIT; $stkpRslt = db_exec($sql) or errDie("Unable to retrieve stock items from database."); if (pg_numrows($stkpRslt) < 1) { return "<li class='err'> There are no stock item on the selected pricelist.</li>"; } while ($stkp = pg_fetch_array($stkpRslt)) { db_connect(); # get stock details $sql = "SELECT stkid, stkcod, stkdes FROM stock WHERE stkid = '{$stkp['stkid']}' AND div = '" . USER_DIV . "'"; $stkRslt = db_exec($sql) or errDie("Unable to retrieve stocks from database."); if (pg_numrows($stkRslt) < 1) { db_conn("exten"); $Sl = "DELETE FROM plist_prices WHERE stkid='{$stkp['stkid']}' AND div = '" . USER_DIV . "'"; $Rs = db_exec($Sl) or errDie("Unable to retrieve stocks from database."); } else { $stk = pg_fetch_array($stkRslt); $listing .= "\r\n\t\t\t\t<tr class='" . bg_class() . "'>\r\n\t\t\t\t\t<td><input type='hidden' name='stkids[]' value='{$stk['stkid']}'>{$stk['stkcod']} - " . extlib_rstr($stk['stkdes'], 30) . "</td>\r\n\t\t\t\t\t<td align='right'>" . CUR . " <input type='text' name='prices[]' size='8' value='{$stkp['price']}'> {$vattype}</td>\r\n\t\t\t\t</tr>"; } } $buttons = ""; if ($offset != 0) { $buttons = "\r\n\t\t\t<tr>\r\n\t\t\t\t<td align='left'><input type='submit' name='prev' value='Previous'></td>\r\n\t\t\t\t<td><input type='submit' name='next' value='Next'></td>\r\n\t\t\t</tr>"; } $enter = "\r\n\t\t<h3>Edit Supplier Price list</h3>\r\n\t\t<form action='" . SELF . "' method='POST'>\r\n\t\t<table " . TMPL_tblDflts . ">\r\n\t\t\t<input type='hidden' name='key' value='confirm'>\r\n\t\t\t<input type='hidden' name='listid' value='{$list['listid']}'>\r\n\t\t\t<tr>\r\n\t\t\t\t<th>Field</th>\r\n\t\t\t\t<th>Value</th>\r\n\t\t\t</tr>\r\n\t\t\t<tr class='" . bg_class() . "'>\r\n\t\t\t\t<td>Supplier Price list</td>\r\n\t\t\t\t<td align='center'><input type='text' size='20' name='listname' value='{$list['listname']}'></td>\r\n\t\t\t</tr>\r\n\t\t\t<tr><td><br></td></tr>\r\n\t\t\t<tr>\r\n\t\t\t\t<th colspan='2'>Category</th>\r\n\t\t\t</tr>\r\n\t\t\t<tr class='" . bg_class() . "'>\r\n\t\t\t\t<td colspan='2' align='center'>{$category_drop}</td>\r\n\t\t\t</tr>\r\n\t\t\t<tr>\r\n\t\t\t\t<th colspan='2'>Classification</th>\r\n\t\t\t</tr>\r\n\t\t\t<tr bgcolor='" . bgcolor() . "'>\r\n\t\t\t\t<td colspan='2' align='center'>{$classification_drop}</td>\r\n\t\t\t</tr>\r\n\t\t\t<tr>\r\n\t\t\t\t<th colspan='2'>Stock Code</th>\r\n\t\t\t</tr>\r\n\t\t\t<tr class='" . bg_class() . "'>\r\n\t\t\t\t<td colspan='2' align='center'><input type='text' name='stockcode' value='{$stockcode}'></td>\r\n\t\t\t</tr>\r\n\t\t\t<tr>\r\n\t\t\t\t<td colspan='2' align='center'><input type='submit' name='search' value='Search'></td>\r\n\t\t\t</tr>\r\n\t\t\t<tr><td><br></td></tr>\r\n\t\t\t<tr>\r\n\t\t\t\t<td colspan='2' align='right'><input type='submit' name='continue' value='Confirm »'></td>\r\n\t\t\t</tr>\r\n\t\t</table>\r\n\t\t<table " . TMPL_tblDflts . ">\r\n\t\t\t<tr>\r\n\t\t\t\t<td colspan='2'><h3>Prices</h3></td>\r\n\t\t\t<tr>\r\n\t\t\t<tr>\r\n\t\t\t\t<th>Item</th>\r\n\t\t\t\t<th>Price Amount</th>\r\n\t\t\t</tr>\r\n\t\t\t{$listing}\r\n\t\t\t{$buttons}\r\n\t\t\t<tr><td><br></td></tr>\r\n\t\t\t<tr>\r\n\t\t\t\t<td colspan='2' align='right'><input type='submit' name='continue' value='Confirm »'></td>\r\n\t\t\t</tr>\r\n\t\t</table>\r\n\t\t</form>\r\n\t\t<p>\r\n\t\t<table border=0 cellpadding='2' cellspacing='1'>\r\n\t\t\t<tr>\r\n\t\t\t\t<th>Quick Links</th>\r\n\t\t\t</tr>\r\n\t\t\t<tr class='" . bg_class() . "'>\r\n\t\t\t\t<td><a href='sup-pricelist-view.php'>View Supplier Price Lists</a></td>\r\n\t\t\t</tr>\r\n\t\t\t<tr class='" . bg_class() . "'>\r\n\t\t\t\t<td><a href='../main.php'>Main Menu</a></td>\r\n\t\t\t</tr>\r\n\t\t</table>"; return $enter; }
function recover() { extract($_REQUEST); require_lib("validate"); $v = new validate(); $v->isOk($code, "string", 1, 5, "Invalid company code."); # Display errors, if any if ($v->isError()) { $confirm = ""; $errors = $v->getErrors(); foreach ($errors as $e) { $confirm .= "<li class='err'>" . $e["msg"] . "</li>"; } return slctcomp($confirm); } # Change code to lowercase $code = strtolower($code); # Get Company Name db_con("cubit"); $sql = "SELECT * FROM companies WHERE code = '{$code}'"; $compRslt = db_exec($sql) or errDie("Unable to access database.", SELF); if (pg_numrows($compRslt) < 1) { return "<li class='err'> Invalid Company Code</li>"; } else { $comp = pg_fetch_array($compRslt); } $sql = "UPDATE companies SET status='active' WHERE code = '{$code}'"; $delRslt = db_exec($sql) or errDie("Unable to access database.", SELF); $date = date("Y-m-d"); $Sl = "INSERT INTO ch(comp,code,des,f,t,date) VALUES ('{$comp['name']}','{$comp['code']}','Recover by " . USER_NAME . "','{$comp['ver']}','{$comp['ver']}','{$date}')"; $Ri = db_exec($Sl); $rem = "\n\t\t\t<h3>Recover Company</h3>\n\t\t\t<h4><li> Company : {$comp['name']} has been successfully been recovered and marked as active.</h4>"; return $rem; }
/** * @ignore */ function db_conn_maint($db) { db_con($db); }
function importFile() { global $_FILES, $_POST, $psql_exec; extract($_POST); $OUTPUT = "<h3>Import Company</h3>"; $v =& new Validate(); if (!$v->isOk($compname, "string", 1, 250, "")) { return "<li class='err'>Invalid Company Name</li>" . selectFile(); } // generate code $code = "aaaa"; // make sure it 4 chars long by padding with a's $code = str_replace(" ", "", $code); $code = str_pad($code, 4, 'a', STR_PAD_RIGHT); while (1) { // check if the code exists db_con("cubit"); $rslt = db_exec("SELECT * FROM companies WHERE code='{$code}'"); // not exist! YAY!! if (pg_numrows($rslt) < 1 && !exists_compdb($code)) { break; } // increase $code[3] = chr(ord($code[3]) + 1); for ($i = 3; $i >= 0; $i--) { if (ord($code[$i]) > ord('z')) { $code[$i] = 'a'; if ($i > 0) { $code[$i - 1] = chr(ord($code[$i - 1]) + 1); } if (substr($code, 0, 3) == "zzz") { $code = "aaaa"; } } } } require_lib("progress"); displayProgress("newtemplate.php"); # Change code to lowercase $code = strtolower($code); // parse the import file if (PLATFORM == "windows") { $importfile = cfs::tempnam("cubitimport_"); } else { $importfile = cfs::tempnam("cubitimport_"); } if (!ucfs::valid("compfile")) { return "<li class='err'>" . ucfs::ferror("compfile") . "</li>"; } $fd_in = ucfs::fopen("compfile", "r"); $fd_out = cfs::fopen($importfile, "w", true); if ($fd_in === false) { return "<li class='err'>Unable to open import file.</li>"; } if ($fd_out === false) { return "<li class='err'>Unable to open temporary file required to import company.</li>"; } $company_ver = ""; while (!cfs::feof($fd_in)) { $buf = cfs::fgets($fd_in, 4096); // get the version of imported company if on this line $pos = strpos($buf, "-- V'e'r's'i'o'n:"); if ($pos !== false && $pos == 0) { $company_ver = trim(substr($buf, 17)); } // check if it valid platform $pos = strpos($buf, "-- P'l'a't'f'o'r'm:"); if ($pos !== false && $pos == 0) { $comp_platform = trim(substr($buf, 19)); if (PLATFORM != $comp_platform) { $OUTPUT .= "You cannot import another platform's company!<br>\n\t\t\t\t\tOnly from Windows to Windows or Linux to Linux.<br><Br>\n\t\t\t\t\tYour platform: " . PLATFORM . "<Br>\n\t\t\t\t\tProposed Imported Company Platform: {$comp_platform}<br>"; return $OUTPUT; } } // parse the create database code variable if on this line $pos = strpos($buf, "CREATE DATABASE"); if ($pos !== false && strpos($buf, "%c'o'd'e%") > 0) { $buf = str_replace("%c'o'd'e%", $code, $buf); } // parse the company code variable if on this line $pos = strpos($buf, "\\c "); if ($pos !== false && strpos($buf, "%c'o'd'e%") > 0) { $buf = str_replace("%c'o'd'e%", $code, $buf); } fputs($fd_out, $buf); } fclose($fd_in); fclose($fd_out); // get the version of current cubit db_con("cubit"); $cubit_ver = CUBIT_VERSION; // check if versions are the same (TEMPORARY HACK, ai tog) if ($cubit_ver != $company_ver) { return $OUTPUT . "Versions do not match:<br>\n\t\t\tProposed Imported Company version is \"{$company_ver}\"<br>\n\t\t\tYour Cubit version is \"{$cubit_ver}\"<br>\n\t\t\t<br>\n\t\t\tCheck for updates for your Cubit to support the functionality of importing non matching versions."; } // import exec("{$psql_exec}/" . PSQL_EXE . " -U postgres template1 < {$importfile}"); // insert the company db_con("cubit"); db_exec("INSERT INTO companies (code,name,ver,status) VALUES('{$code}', '{$compname}', '{$company_ver}', 'active')"); // if only one company in list, we can safely assume this was the first company // and forward to the login screen $sql = "SELECT * FROM companies"; $rslt = db_exec($sql); if (!isset($_SESSION["USER_ID"]) && $rslt && pg_num_rows($rslt) > 0) { $_SESSION["code"] = $code; $_SESSION["comp"] = $compname; $OUTPUT = "<script>top.document.location.href='doc-index.php';</script>"; return $OUTPUT; header("Location: main.php"); exit; } $OUTPUT .= "\n\tCompany has been imported successfully.<br>\n\tCompany Name: {$compname}<br>\n\tCompany Code: {$code}<br>"; return $OUTPUT; }
function GenerateGraph($nodeID) { global $DBfile, $GRAPH, $DisplayDATE, $GetDATE; $i = 0; $db = db_con($DBfile); $query = $db->query("SELECT place,time,supplyV,temp,hum,date(time,'unixepoch') AS Date FROM werte WHERE Date='" . $GetDATE . "' AND nodeID='" . $nodeID . "'"); while ($result = $query->fetch(PDO::FETCH_ASSOC)) { $place = $result['place']; $TIME[$i] = $result['time']; $TEMP[$i] = $result['temp'] / 100; $HUM[$i] = $result['hum'] / 100; $SUPPLYV[$i] = $result['supplyV'] / 1000; $i++; } if ($i == 0) { return; } // Create the graph. These two calls are always required $graph = new Graph(1100, 350); $graph->SetScale("datlin"); $graph->SetShadow(); $graph->SetMargin(50, 50, 20, 100); $graph->title->Set('' . $place . ': ' . $DisplayDATE . ''); $graph->title->SetFont(FF_FONT1, FS_BOLD); //$graph->xaxis->title->Set("Zeit"); //$graph->xaxis->title->SetFont(FF_FONT1,FS_BOLD); $graph->yaxis->title->Set("Temperatur °C"); $graph->yaxis->SetTitlemargin(40); $graph->yaxis->title->SetFont(FF_FONT1, FS_BOLD); $graph->xaxis->SetLabelFormatCallback('TimeCallback'); $graph->xaxis->SetLabelAngle(90); $graph->xaxis->scale->SetTimeAlign(MINADJ_15); $lineplot = new LinePlot($TEMP, $TIME); $lineplot->SetColor("red"); $lineplot->SetLegend("Temperature "); $lineplotb = new LinePlot($HUM, $TIME); $lineplotb->SetColor("blue"); $lineplotb->SetWeight(2); $lineplotb->SetLegend("Humidity "); $graph->SetY2Scale("lin"); $graph->AddY2($lineplotb); $graph->y2axis->title->Set("Luftfeuchte % "); $graph->y2axis->title->SetColor("blue"); $graph->y2axis->SetTitlemargin(40); // Add the plot to the graph $graph->Add($lineplot); // Adjust the legend position $graph->legend->Pos(0.5, 0.98, "center", "bottom"); // Display the graph //$graph->Stroke(); // generate image file for HTML pages // Get the handler to prevent the library from sending the // image to the browser $gdImgHandler = $graph->Stroke(_IMG_HANDLER); $graph->img->SetImgFormat($GRAPH['SetImgFormat']); $fileName = "" . $GRAPH['DIR'] . "/" . $nodeID . "." . $GRAPH['SetImgFormat'] . ""; $graph->img->Stream($fileName); unset($TIME); unset($TEMP); unset($HUM); unset($SUPPLYV); }
// Pressure (Luftdruck) if ($arg == "he") { $DATA["height"] = $var; $Found = 1; } // Height (Höhe) if ($Found == 0) { $DATA[$arg] = $var; } } if (!$ValidKey) { echo "Invalid Key!"; exit; } if (isset($DATA["nodeID"]) and !empty($DATA["nodeID"])) { $VALnames = ""; $VALUES = ""; foreach ($DATA as $NAME => $VAR) { $VALnames .= "" . $NAME . ","; $VALUES .= "'" . $VAR . "',"; } $VALnames = substr_replace($VALnames, "", strrpos($VALnames, ",")); $VALUES = substr_replace($VALUES, "", strrpos($VALUES, ",")); $SQL = "INSERT INTO werte (place,time,"; $SQL .= "" . $VALnames . ")"; $SQL .= " VALUES ('" . $Sensor[$DATA["nodeID"]] . "','" . time() . "'," . $VALUES . ""; $SQL .= ");"; $db = db_con($DBfile); $insert = db_query($SQL); } }
# # # # # # # # if (defined("CUBIT_IMPORTCOMP")) { require_once "newsettings.php"; } else { require_once "settings.php"; } $OUTPUT = ""; // CHECK FOR PATH OF psql EXECUTABLE db_con("cubit"); if (isset($_POST["psql_location"]) && strlen($_POST["psql_location"]) > 0) { $psql_exec = $_POST['psql_location']; if (validpath($psql_exec)) { savepath($psql_exec); } else { $OUTPUT .= "<li class=err>Invalid Location.</li>"; } } $Rx = db_exec("SELECT locat FROM psql_location") or errDie("Unable to get " . PSQL_EXE . " location from db."); $selffind = false; if (pg_numrows($Rx) < 1 && ($selffind = tryfind()) === false) { enterlocation(); } else { if ($selffind) { $psql_exec = $selffind;
<?php /** * Created by PhpStorm. * User: USER * Date: 9/6/2015 * Time: 23:12 */ include_once '/../phpFn/db.php'; $con = db_con("sec"); $tim = (new DateTime())->format("Y-m-d H:i:s"); runsql($con, "update act set tim = '{$tim}' where act=1;"); $con->close();
/** * routine runner * * @param string $compa coda, $configa! */ function routine($code, $config) { global $oPOP, $oSMTP, $oMSG; extract($config); /* check if trh is enabled */ if (empty($POP3_SERVER) || empty($SMTP_SERVER)) { return false; } print "Company Routine: {$code}\n"; db_con("cubit_{$code}"); /* check for requests/responses */ $oPOP->reset(); $oPOP->retrieveMessages($POP3_SERVER, 110, $POP3_USER, $POP3_PASS, false); /* loop through each message */ while (($msg = $oPOP->enumGetMessage()) !== false) { /* process message, on failure continue with next message */ if (!$oMSG->processMessage($msg)) { continue; } /* check subject for message type */ if (!isset($oMSG->headers["Subject"])) { continue; } if (preg_match(REGEX_REQTYPE, $oMSG->headers["Subject"], $si)) { $key = $si[2]; $req = $si[1]; print "Key: {$key}\n"; print "Req Type: {$req}\n"; switch ($req) { /* new client request */ case "reqkey": print "entering request_new()\n"; $ret = request_new($key, $oMSG, $config); break; /* response to new request */ /* response to new request */ case "rspkey": print "entering response_new()\n"; $ret = response_new($key, $oMSG, $config); break; /* request order */ /* request order */ case "reqpur": print "entering request_order()\n"; $ret = request_order($key, $oMSG, $config); break; /* order response */ /* order response */ case "rsppur": print "entering response_purchase()\n"; $ret = response_order($key, $oMSG, $config); break; default: print "invalid request type\n"; return false; } } else { print "Not matching: " . $oMSG->headers["Subject"] . "\n"; } } return true; }