Beispiel #1
0
 public static function serializeRoutes($routes)
 {
     $results = [];
     foreach ($routes as $route) {
         $results[] = DbUtil::serializeRoute($route);
     }
     return $results;
 }
 public static function retrieveOrganizationName()
 {
     $db = DbUtil::accessFactory();
     $copname = Auth::getCopName();
     $copname = $db->escape($copname);
     $rs = $db->select("SELECT coplabel FROM cops WHERE copname = '{$copname}'");
     return $rs->coplabel;
 }
Beispiel #3
0
function get_records_to_print($lab_config, $test_type_id, $date_from, $date_to)
{
    $saved_db = DbUtil::switchToLabConfig($lab_config->id);
    $retval = array();
    $query_string = "SELECT * FROM test WHERE test_type_id={$test_type_id} " . "AND specimen_id IN ( " . "SELECT specimen_id FROM specimen " . "WHERE date_collected BETWEEN '{$date_from}' AND '{$date_to}' " . ")";
    $resultset = query_associative_all($query_string, $row_count);
    foreach ($resultset as $record) {
        $test = Test::getObject($record);
        $specimen = Specimen::getById($test->specimenId);
        $patient = Patient::getById($specimen->patientId);
        $retval[] = array($test, $specimen, $patient);
    }
    DbUtil::switchRestore($saved_db);
    return $retval;
}
Beispiel #4
0
 function getMailUsers()
 {
     $idAlbum = 1;
     $sql = "SELECT al.key as albumkey, ur.id as srcid, ur.email as srcemail, concat(ur.firstname, \" \", ur.lastname) as srcfullname, j.uid, j.email, j.fullname, j.idstickers \n \t\tFROM user ur, (SELECT m.idalbum, d.iduser as srcuser, m.iduser as uid, concat(u.firstname, \" \", u.lastname) as fullname,\n\t\t\t\t\t\t\t\t\tu.email, group_concat(d.stickernumber ORDER BY d.stickernumber SEPARATOR ', ') as idstickers \n\t\t\t\t\t\t\t\tFROM missing m \n\t\t\t\t\t\t\t\tJOIN duplicate d on m.stickernumber = d.stickernumber\n\t\t\t\t\t\t\t\t\tand m.idalbum = d.idalbum and d.copy > 0 \n\t\t\t\t\t\t\t\tJOIN user u on u.id = m.iduser and u.id != d.iduser\n\t\t\t\t\t\t\t\tWHERE u.active=1\n\t\t\t\t\t\t\t\tGROUP BY m.iduser, d.iduser) as j\n\t\tJOIN album al on al.id=j.idalbum\n\t\tWHERE j.srcuser = ur.id and ur.active=1\n\t\t";
     $connection = DbUtil::getConnection();
     $sql_result = mysqli_query($connection, $sql);
     $info = array();
     while ($sql_row = mysqli_fetch_array($sql_result)) {
         $srcId = $sql_row['srcid'];
         $albumKey = $sql_row['albumkey'];
         if (!isset($info[$srcId])) {
             $info[$srcId] = array();
             $info[$srcId]["email"] = $sql_row['srcemail'];
             $info[$srcId]["fullname"] = $sql_row['srcfullname'];
         }
         if (!isset($info[$srcId]["albums"])) {
             $info[$srcId]["albums"] = array();
         }
         if (!isset($info[$srcId]["albums"][$albumKey])) {
             $info[$srcId]["albums"][$albumKey] = array();
         }
         $info[$srcId]["albums"][$albumKey]["key"] = $albumKey;
         if (!isset($info[$srcId]["albums"][$albumKey]["neededBy"])) {
             $info[$srcId]["albums"][$albumKey]["neededBy"] = array();
         }
         $info[$srcId]["albums"][$albumKey]["neededBy"][] = array('id' => $sql_row['uid'], 'name' => $sql_row['fullname'], 'stickers' => $sql_row['idstickers']);
         $srcId = $sql_row['uid'];
         if (!isset($info[$srcId])) {
             $info[$srcId] = array();
             $info[$srcId]["email"] = $sql_row['email'];
             $info[$srcId]["fullname"] = $sql_row['fullname'];
         }
         if (!isset($info[$srcId]["albums"])) {
             $info[$srcId]["albums"] = array();
         }
         if (!isset($info[$srcId]["albums"][$albumKey])) {
             $info[$srcId]["albums"][$albumKey] = array();
             $info[$srcId]["albums"][$albumKey]["key"] = $albumKey;
         }
         if (!isset($info[$srcId]["albums"][$albumKey]["hasStickers4You"])) {
             $info[$srcId]["albums"][$albumKey]["hasStickers4You"] = array();
         }
         $info[$srcId]["albums"][$albumKey]["hasStickers4You"][] = array('id' => $sql_row['srcid'], 'name' => $sql_row['srcfullname'], 'stickers' => $sql_row['idstickers']);
     }
     return $info;
 }
function generate_worksheet_config($lab_config_id)
{
    $lab_config = LabConfig::getById($lab_config_id);
    $test_ids = $lab_config->getTestTypeIds();
    $saved_db = DbUtil::switchToLabConfig($lab_config_id);
    foreach ($test_ids as $test_id) {
        $test_entry = TestType::getById($test_id);
        $query_string = "SELECT * FROM report_config WHERE test_type_id={$test_id} LIMIT 1";
        $record = query_associative_one($query_string);
        if ($record == null) {
            # Add new entry
            $query_string_add = "INSERT INTO report_config (" . "test_type_id, header, footer, margins, " . "p_fields, s_fields, t_fields, p_custom_fields, s_custom_fields " . ") VALUES (" . "'{$test_id}', 'Worksheet - " . $test_entry->name . "', '', '5,0,5,0', " . "'0,1,0,1,1,0,0', '0,0,1,1,0,0', '1,0,1,0,0,0,0,1', '', '' " . ")";
            query_insert_one($query_string_add);
        }
    }
    DbUtil::switchRestore($saved_db);
}
Beispiel #6
0
function mergedata()
{
    if (!isset($_SESSION['lab_config_id'])) {
        return false;
    }
    $workedID = "";
    $lab_config = $_SESSION['lab_config_id'];
    $saved_db = DbUtil::switchToLabConfig($importLabConfigId);
    $querySelect = "SELECT patient_id,name,surr_id,addl_id FROM patient order by surr_id asc";
    $resultset = query_associative_all($querySelect, $rowCount);
    $rowCount = 0;
    foreach ($resultset as $record) {
        if (strstr($workedID, $record['surr_id'])) {
            continue;
        } else {
            $workedID .= "," . $record['surr_id'];
        }
        $querySelect = "SELECT patient_id,name,surr_id,addl_id FROM patient where \n\t\tsurr_id='" . $record['surr_id'] . "' and \n\t\tpatient_id <> " . $record['patient_id'];
        $Dupresult = query_associative_all($querySelect, $rowCount);
        foreach ($Dupresult as $Duprecord) {
            $rowCount += 1;
            echo '<br> Working... ' . $record['surr_id'];
            //update spacimen
            $updateQuery = "update specimen set patient_id=" . $record['patient_id'] . "where patient_id=" . $Duprecord['patient_id'];
            query_blind($updateQuery);
            //update bills
            $updateQuery = "update bills set patient_id=" . $record['patient_id'] . "where patient_id=" . $Duprecord['patient_id'];
            query_blind($updateQuery);
            //now delete from custom_data and patients table
            $deleteQuery = "delete from patient_custom_data where patient_id=" . $Duprecord['patient_id'];
            query_blind($deleteQuery);
            $deleteQuery = "delete from patient where patient_id=" . $Duprecord['patient_id'];
            query_blind($deleteQuery);
        }
    }
    //var_dump ( $resultset);
    if ($rowCount > 0) {
        echo '<br>' . $rowCount . " Duplicate Records corrected.";
    } else {
        echo '<br>' . "No Duplicate Records found.";
    }
    return true;
}
Beispiel #7
0
function updateDatabase()
{
    global $labConfigId, $DB_HOST, $DB_USER, $DB_PASS;
    $country = strtolower(LabConfig::getUserCountry($labConfigId));
    $saved_db = DbUtil::switchToCountry($country);
    $currentDir = getcwd();
    $mainBlisDir = substr($currentDir, $length, strpos($currentDir, "htdocs"));
    //$blisLabBackupFilePath = "\"".$mainBlisDir.$backup_folder."\blis_".$lab_config_id."\blis_".$lab_config_id."_backup.sql\"";
    $sqlFilePath = "\"" . $mainBlisDir . "htdocs\\export\\temp.sql\"";
    $mysqlExePath = "\"" . $mainBlisDir . "server\\mysql\\bin\\mysql.exe\"";
    $dbname = "blis_" . $country;
    $command = $mysqlExePath . " -h {$DB_HOST} -P 7188 -u {$DB_USER} -p{$DB_PASS} {$dbname} < {$sqlFilePath}";
    $command = "C: &" . $command;
    //the C: is a useless command to prevent the original command from failing because of having more than 2 double quotes
    echo $command;
    system($command, $return_var);
    if ($return_var == 0) {
        echo "true";
    } else {
        echo "false";
    }
    DbUtil::switchRestore($saved_db);
}
Beispiel #8
0
<?php

#
# Deletes a test type from DB
# Sets disabled flag to true instead of deleting the record
# This maintains info for samples that were linked to this test type previously
#
include "../includes/db_lib.php";
$saved_session = SessionUtil::save();
$saved_db = DbUtil::switchToGlobal();
$test_type_id = $_REQUEST['id'];
TestType::deleteById($test_type_id);
DbUtil::switchRestore($saved_db);
SessionUtil::restore($saved_session);
header("Location: catalog.php?tdel");
Beispiel #9
0
<!DOCTYPE html>
<?php 
require_once '../db.php';
$Database = new DbUtil();
$userName = $Database->getUserName();
if ($userName == null) {
    header('Location: ../login.php', true, 303);
    exit;
}
$ID = $_GET['sid'];
$LINE = $_GET['lid'];
$stopData = $Database->getStop($ID);
$lineName = $Database->getLineName($LINE, $userName);
if ($lineName == null) {
    die('PERMISSION DENIED');
}
$timeData = $_GET['time'];
$typeData = $_GET['type'];
if ($Database->isExistTime($ID, $LINE, $timeData, $typeData)) {
    $Database->deleteTime($ID, $LINE, $timeData, $typeData);
}
header("Location: timetable.php?stopid={$ID}&lineid={$LINE}", true, 303);
 /**
  * Verifies if a Widget Category with a given name exists in the
  * persistent database of the portal.
  * 
  * @param string $name The name of the Widget Category you want to verify the existence.
  */
 public static function exists($name)
 {
     $db = DbUtil::accessFactory();
     $name = $db->escape($name);
     $toLowerName = strtolower($name);
     // Check if this category exists.
     $rs = $db->select("SELECT COUNT(*) AS 'catcount' FROM categories WHERE LOWER(category) = '{$toLowerName}'");
     return $rs->catcount;
 }
<?php 
//BLIR BRUKT I ADMIN
require_once 'inc/dbutil.php';
$obj = new DbUtil();
$tmpVal = $obj->getTable();
echo "<p class='text-center'>Guild Members</p>";
echo "<table class='table'>";
echo "<tr><th>Character name</th><th>Remove player</th></tr>";
foreach ($tmpVal as $row) {
    if ($row['guildmembership'] == 1 && $row['gamerID'] != $_SESSION['gamerID']) {
        echo "<tr>";
        echo "<td>" . $row['username'] . "</td>";
        echo "<td>";
        echo "<form action='inc/deleteuser.php' method='post'>";
        echo "<input type='hidden' name='deleteuser' value='" . $row['gamerID'] . "'>";
        echo "<button type='submit' class='btn btn-danger' >Delete</button>";
        echo "</form>";
        echo "</td>";
        echo "</tr>";
    }
}
echo "</table>";
Beispiel #12
0
<?php

$USER = @$_POST['username'];
$PASS = @$_POST['pass'];
$DO = @$_GET['do'];
$ERROR = "";
$USERHAS = "";
$PASSHAS = "";
$showForm = true;
require_once 'db.php';
$Database = new DbUtil();
if ($Database->getUserName() != null) {
    header('Location: personal/my.php', true, 303);
}
function login()
{
    global $DO, $PASS, $USER, $ERROR, $USERHAS, $PASSHAS, $Database;
    if ($DO != "") {
        if ($USER == "" || $PASS == "") {
            $ERROR = '<div class="alert alert-danger" role="alert">一部または全ての項目が入力されていません</div>';
            if ($USER == "") {
                $USERHAS = "has-error";
            }
            if ($PASS == "") {
                $PASSHAS = "has-error";
            }
        } else {
            if (!$Database->login($USER, $PASS)) {
                $ERROR = '<div class="alert alert-danger" role="alert">ユーザ名またはパスワードが違います</div>';
            } else {
                $showForm = false;
Beispiel #13
0
<!DOCTYPE html>
<?php 
require_once '../nav.php';
require_once '../db.php';
require_once 'sidemenu.php';
$DO = @$_GET['do'];
$EDIT = @$_GET['edit'];
$DELETE = @$_GET['delete'];
$Database = new DbUtil();
$userName = $Database->getUserName();
if ($DO != "") {
    $stopName = $_POST['stopName'];
    if ($_POST['stopSelect'] == 'new') {
        $lineName = $_POST['newName'];
    } else {
        $lineName = $_POST['existSelect'];
    }
    $lat = @$_POST['lat'];
    $long = @$_POST['long'];
    $lineId = $Database->getLineId($lineName, $userName);
    if ($lineId == null) {
        $Database->registerLine($lineName, $userName);
        $lineId = $Database->getLineId($lineName, $userName);
    }
    if ($lat == '') {
        $lat = '0';
        $long = '0';
    }
    if ($EDIT == "") {
        $Database->registerStop($stopName, $userName, $long, $lat);
    } else {
Beispiel #14
0
<?php

require dirname(__FILE__) . '/__init__.php';
Rhaco::import('tag.HtmlParser');
$db = new DbUtil(Event::connection());
$p = new HtmlParser('index.html');
$p->setVariable('event', $db->get(new Event(), new C(Q::depend(), Q::eq(Event::columnId(), Rhaco::constant('CURRENT_EVENT', 1)))));
$p->setVariable('hatena', Rhaco::obj('HatenaSyntax', array('headlevel' => 4, 'id' => 'event_description')));
$p->write();
Beispiel #15
0
Datei: my.php Projekt: Amfys/BST
<!DOCTYPE html>
<?php 
require_once '../nav.php';
require_once '../db.php';
require_once 'sidemenu.php';
require_once 'funcs.php';
$Database = new DbUtil();
$userName = $Database->getUserName();
$sideMenu = getSideMenu('my');
$NAV = nav($userName);
if ($userName == null) {
    header('Location: ../login.php', true, 303);
    exit;
}
if ($_GET['type'] == 'close') {
    $closeList = true;
    $lat = $_GET['lat'];
    $long = $_GET['long'];
    $noPos = false;
    if ($lat == "" || $long == "") {
        $noPos = true;
    }
} else {
    $closeList = false;
}
if (!$closeList) {
    $myData = $Database->getMyTime($userName, get4Time() - 5, getTodayType());
} else {
    $myStopList = $Database->getCloseStopList($userName, $lat, $long);
}
?>
Beispiel #16
0
 public static function checkNameExists($name, $country)
 {
     # Checks if the given patient name (or similar match) already exists
     $saved_db = DbUtil::switchToCountry($country);
     $query_string = "SELECT COUNT(patient_id) AS val FROM patient WHERE name LIKE '%{$name}%'";
     $resultset = query_associative_one($query_string);
     DbUtil::switchRestore($saved_db);
     if ($resultset == null || $resultset['val'] == 0) {
         return false;
     } else {
         return true;
     }
 }
Beispiel #17
0
 public static function userCanChangeHisPassword($login, $lostKey, $lostTime)
 {
     # Verify if the login exists
     $db = DbUtil::accessFactory();
     $login = urldecode($login);
     $login = $db->db_escape_string($login);
     $lostKey = $db->db_escape_string($lostKey);
     $lostTime = $db->db_escape_string($lostTime);
     $userId = UsersManagement::getUserIdByLogin($login);
     # If login exists fill db with lost key and timestamp
     if ($userId !== null) {
         $currentTime = time();
         $thresholdHour = VALIDE_LOST_KEY_PERIOD;
         # 2h
         $threshold = 3600 * $thresholdHour;
         # number of seconde
         # Store the state
         $rs = $db->select('SELECT * FROM `users` WHERE `id` = \'' . $userId . '\' AND `lostKey` = \'' . $lostKey . '\' AND `lostTime` = \'' . $lostTime . '\'');
         //			var_dump($rs->count());
         //			var_dump($threshold);
         //			var_dump($currentTime - $lostTime);
         if ($rs->count() == 1) {
             if ($currentTime - $lostTime < $threshold) {
                 return true;
             } else {
                 return -1;
             }
             # -1 means that the time is over
         } else {
             return false;
         }
     } else {
         return false;
     }
 }
<?php

include 'dbutil.php';
$obj = new DbUtil();
$email = $_POST['email'];
$username = $_POST['username'];
$password = SHA1($_POST['password']);
$class = $_POST['class'];
$race = $_POST['race'];
if (isset($email) && isset($username) && isset($password) && isset($class) && isset($race)) {
    $obj->addUserApplication($email, $username, $password, $class, $race);
    header('Location: ../guildApp.php?success');
} else {
    header('Location: ../guildApp.php?appfailed');
}
Beispiel #19
0
         $i++;
     }
     DbUtil::switchRestore($saved_db);
     return $retval;
 }
 public static function getRangeInfectionStats($lab_config, $date_from, $date_to)
 {
     $test_type_list = get_range_value_test_types($lab_config);
     # For each test type, fetch all measures
     # For each measure, create distribution based on range
     foreach ($test_type_list as $test_type_id) {
         # Collect measure(s) information
         $measure_list = get_test_type_measures($test_type_id);
         $measure_meta_list = array();
         foreach ($measure_list as $measure_id) {
             $measure = get_measure_by_id($measure_id);
             $measure_meta = new MeasureMeta();
             $measure_meta->name = $measure->getName();
             $measure_meta->countParts = array();
             $range = $measure->range;
             if (strpos($range, ":") === false) {
                 # Discrete value range
                 $range_options = explode("#", $range);
                 $measure_meta->rangeType = MeasureMeta::$DISCRETE;
                 $measure_meta->rangeValues = $range_options;
             } else {
                 # Continuous value range
                 $range_bounds = explode(":", $range);
                 $measure_meta->rangeType = MeasureMeta::$CONTINUOUS;
                 $measure_meta->rangeValues = $range_bounds;
             }
             $measure_meta_list[] = $measure_meta;
         }
         # Calculate stats
         $query_string = "SELECT COUNT(*) AS count_val FROM test t, specimen s " . "WHERE t.test_type_id={$test_type_id} " . "AND t.specimen_id=s.specimen_id " . "AND ( s.date_collected BETWEEN '{$date_from}' AND '{$date_to}' ) " . "AND t.result <> ''";
         $record = query_associative_one($query_string);
         $count_all = $record['count_val'];
         # Fetch result values
         $query_string = "SELECT t.result FROM test t, specimen s " . "WHERE t.test_type_id={$test_type_id} " . "AND t.specimen_id=s.specimen_id " . "AND ( s.date_collected BETWEEN '{$date_from}' AND '{$date_to}' ) " . "AND t.result <> ''";
         $resultset = query_associative_all($query_string, $row_count);
         foreach ($resultset as $record) {
             $result_string = substr($record['result'], 0, -1);
             $result_list = explode(",", $result_string);
             for ($i = 0; $i < count($result_list); $i++) {
                 $measure_meta = $measure_meta_list[$i];
                 if ($measure_meta->rangeType == MeasureMeta::$CONTINUOUS) {
                     $range_bounds = $measure_meta->rangeValues;
                     $interval = $range_bounds[1] - $range_bounds[0];
                     $base = $interval / 10;
                     $offset = $result_list[$i] - $range_bounds[0];
                     $bucket = $offset / $base;
                     echo $bucket;
                     break;
Beispiel #20
0
 public function logBoomr($boomData, $logTime, $ip, $userAgent)
 {
     if ($this->loadTimeOutOfBounds($boomData)) {
         return false;
     }
     $boomData = $this->fixMissingData($boomData);
     if (!$logTime) {
         $logTime = date('Y-m-d H:i:s');
     }
     if (!$ip) {
         $ip = ip2long(\CDNHeaders::getInstance()->getRemoteIP());
     }
     if (!$userAgent) {
         $userAgent = $_SERVER['HTTP_USER_AGENT'];
     }
     $deviceDetails = $this->deviceDetector->getDeviceDetails($userAgent);
     $osName = $deviceDetails['osDetails']["name"] . " " . $deviceDetails['osDetails']["version"];
     $browserName = $deviceDetails['browserDetails']["name"] ? $deviceDetails['browserDetails']["name"] : "Unknown";
     $browserVersion = $deviceDetails['browserDetails']["version"] ? $deviceDetails['browserDetails']["version"] : 0;
     $deviceType = $deviceDetails['type'];
     try {
         $dbNames = \DbUtil::getDbNames($boomData['appId']);
         $db = \ncDatabaseManager::getInstance()->getDatabase('nLogger')->getConnection();
         $db->setAttribute(\PDO::ATTR_ERRMODE, \PDO::ERRMODE_EXCEPTION);
         $db->setAttribute(\PDO::ATTR_EMULATE_PREPARES, true);
         $sql = 'SELECT os_id FROM ' . $dbNames['common'] . '.os WHERE name = :name and device_type = :device_type';
         $st = $db->prepare($sql);
         $st->bindValue(':name', $osName, \PDO::PARAM_STR);
         $st->bindValue(':device_type', $deviceType, \PDO::PARAM_STR);
         $st->execute();
         $result = $st->fetch(\PDO::FETCH_ASSOC);
         $st->closeCursor();
         if ($result['os_id']) {
             $osId = $result['os_id'];
         } else {
             $sql = 'INSERT INTO ' . $dbNames['common'] . '.os (os_id, name,device_type) VALUES(NULL, :name, :device_type)';
             $st = $db->prepare($sql);
             $st->bindValue(':name', $osName, \PDO::PARAM_STR);
             $st->bindValue(':device_type', $deviceType, \PDO::PARAM_STR);
             $st->execute();
             $osId = $db->lastInsertId();
             $st->closeCursor();
         }
         $sql = 'SELECT browser_id FROM ' . $dbNames['common'] . '.browser WHERE name = :name AND version = :version';
         $st = $db->prepare($sql);
         $st->bindValue(':name', $browserName, \PDO::PARAM_STR);
         $st->bindValue(':version', $browserVersion, \PDO::PARAM_STR);
         $st->execute();
         $result = $st->fetch(\PDO::FETCH_ASSOC);
         $st->closeCursor();
         if ($result['browser_id']) {
             $browserId = $result['browser_id'];
         } else {
             $sql = 'INSERT INTO ' . $dbNames['common'] . '.browser (browser_id, name, version) VALUES(NULL, :name, :version)';
             $st = $db->prepare($sql);
             $st->bindValue(':name', $browserName, \PDO::PARAM_STR);
             $st->bindValue(':version', $browserVersion, \PDO::PARAM_STR);
             $st->execute();
             $browserId = $db->lastInsertId();
             $st->closeCursor();
         }
         $sql = 'SELECT env_id FROM ' . $dbNames['main'] . '.env WHERE os_id = :os_id AND browser_id = :browser_id';
         $st = $db->prepare($sql);
         $st->bindValue(':os_id', $osId, \PDO::PARAM_INT);
         $st->bindValue(':browser_id', $browserId, \PDO::PARAM_INT);
         $st->execute();
         $result = $st->fetch(\PDO::FETCH_ASSOC);
         $st->closeCursor();
         if ($result['env_id']) {
             $envId = $result['env_id'];
         } else {
             $sql = 'INSERT INTO ' . $dbNames['main'] . '.env (env_id, os_id, browser_id) VALUES(NULL, :os_id, :browser_id)';
             $st = $db->prepare($sql);
             $st->bindValue(':os_id', $osId, \PDO::PARAM_INT);
             $st->bindValue(':browser_id', $browserId, \PDO::PARAM_INT);
             $st->execute();
             $envId = $db->lastInsertId();
             $st->closeCursor();
         }
         $isUrlATag = !empty($boomData['tag']);
         if ($isUrlATag) {
             $boomData['u'] = $boomData['tag'];
         }
         $urlIds = $this->insertUrl($dbNames, $db, $boomData['u'], $isUrlATag);
         $urlStaticId = $urlIds['urlStaticId'];
         $urlDynamicId = $urlIds['urlDynamicId'];
         $sql = 'SELECT url_id FROM ' . $dbNames['main'] . '.url WHERE url_static_id = :url_static_id AND url_dynamic_id = :url_dynamic_id';
         $st = $db->prepare($sql);
         $st->bindValue(':url_static_id', $urlStaticId, \PDO::PARAM_INT);
         $st->bindValue(':url_dynamic_id', $urlDynamicId, \PDO::PARAM_INT);
         // $st->bindValue(':referrer_static_id', $referrerStaticId, \PDO::PARAM_INT);
         // $st->bindValue(':referrer_dynamic_id', $referrerDynamicId, \PDO::PARAM_INT);
         $st->execute();
         $result = $st->fetch(\PDO::FETCH_ASSOC);
         $st->closeCursor();
         if ($result['url_id']) {
             $urlId = $result['url_id'];
         } else {
             $sql = 'INSERT INTO ' . $dbNames['main'] . '.url (url_id, url_static_id, url_dynamic_id) VALUES(NULL, :url_static_id, :url_dynamic_id)';
             $st = $db->prepare($sql);
             $st->bindValue(':url_static_id', $urlStaticId, \PDO::PARAM_INT);
             $st->bindValue(':url_dynamic_id', $urlDynamicId, \PDO::PARAM_INT);
             $st->execute();
             $urlId = $db->lastInsertId();
             $st->closeCursor();
         }
         $sql = 'INSERT INTO ' . $dbNames['main'] . '.main (main_id, app_id, log_time, ip_address, env_id, url_id) VALUES(NULL, :app_id, :log_time, :ip_address, :env_id, :url_id)';
         $st = $db->prepare($sql);
         $st->bindValue(':app_id', $boomData['appId'], \PDO::PARAM_INT);
         $st->bindValue(':log_time', $logTime, \PDO::PARAM_STR);
         $st->bindValue(':ip_address', $ip, \PDO::PARAM_INT);
         $st->bindValue(':env_id', $envId, \PDO::PARAM_INT);
         $st->bindValue(':url_id', $urlId, \PDO::PARAM_INT);
         $st->execute();
         $mainId = $db->lastInsertId();
         $st->closeCursor();
         $sql = 'INSERT INTO ' . $dbNames['main'] . '.load_time (main_id, dns, response, page, done, ready) VALUES(:main_id, :dns, :response, :page, :done, :ready)';
         $st = $db->prepare($sql);
         $st->bindValue(':main_id', $mainId, \PDO::PARAM_INT);
         $st->bindValue(':dns', $boomData['nt_dns'], \PDO::PARAM_STR);
         $st->bindValue(':response', $boomData['t_resp'], \PDO::PARAM_STR);
         $st->bindValue(':page', $boomData['t_page'], \PDO::PARAM_STR);
         $st->bindValue(':done', $boomData['t_done'], \PDO::PARAM_STR);
         $st->bindValue(':ready', $boomData['t_resr']['t_domloaded'] ? $boomData['t_resr']['t_domloaded'] : $boomData['t_done'], \PDO::PARAM_STR);
         $st->execute();
         $st->closeCursor();
         $sql = 'INSERT INTO ' . $dbNames['main'] . '.bandwidth_latency (main_id, bandwidth, bandwidth_error, latency, latency_error, round_trip_type) VALUES(:main_id, :bandwidth, :bandwidth_error, :latency, :latency_error, :round_trip_type)';
         $st = $db->prepare($sql);
         $st->bindValue(':main_id', $mainId, \PDO::PARAM_INT);
         $st->bindValue(':bandwidth', $boomData['bw'], \PDO::PARAM_STR);
         $st->bindValue(':bandwidth_error', $boomData['bw_err'], \PDO::PARAM_STR);
         $st->bindValue(':latency', $boomData['lat'], \PDO::PARAM_STR);
         $st->bindValue(':latency_error', $boomData['lat_err'], \PDO::PARAM_STR);
         $st->bindValue(':round_trip_type', $boomData['rt.start'], \PDO::PARAM_STR);
         $st->execute();
         $st->closeCursor();
         foreach ($boomData['t_resr'] as $customTimerName => $customTimerTime) {
             if ($customTimerName == 't_domloaded') {
                 continue;
             }
             $sql = 'SELECT custom_timer_id FROM ' . $dbNames['common'] . '.custom_timer WHERE name = :name';
             $st = $db->prepare($sql);
             $st->bindValue(':name', $customTimerName, \PDO::PARAM_STR);
             $st->execute();
             $result = $st->fetch(\PDO::FETCH_ASSOC);
             $st->closeCursor();
             if ($result['custom_timer_id']) {
                 $customTimerId = $result['custom_timer_id'];
             } else {
                 $sql = 'INSERT INTO ' . $dbNames['common'] . '.custom_timer (custom_timer_id, name) VALUES(NULL, :name)';
                 $st = $db->prepare($sql);
                 $st->bindValue(':name', $customTimerName, \PDO::PARAM_STR);
                 $st->execute();
                 $customTimerId = $db->lastInsertId();
                 $st->closeCursor();
             }
             $sql = 'INSERT INTO ' . $dbNames['main'] . '.custom_time (main_id, custom_timer_id, time) VALUE (:main_id, :custom_timer_id, :time)';
             $st = $db->prepare($sql);
             $st->bindValue(':main_id', $mainId, \PDO::PARAM_INT);
             $st->bindValue(':custom_timer_id', $customTimerId, \PDO::PARAM_INT);
             $st->bindValue(':time', $customTimerTime, \PDO::PARAM_STR);
             $st->execute();
             $st->closeCursor();
         }
     } catch (Exception $e) {
         die('Error: ' . $e->getMessage() . "<br />\n");
     }
     return true;
 }
$db->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
$db->setAttribute(PDO::ATTR_EMULATE_PREPARES, true);
$appId = $_REQUEST['appId'];
$urlId = $_REQUEST['urlId'];
$startDate = $_REQUEST['startDate'];
$endDate = $_REQUEST['endDate'];
if (!$_REQUEST['startDate'] || !$_REQUEST['endDate']) {
    $startDate = $endDate = date('Y-m-d', time() - 86400);
}
$startTime = $startDate . ' 00:00:00';
$endTime = $endDate . ' 23:59:59';
$lastEvenYear = date('Y') % 2 === 0 ? date('Y') : date('Y') - 1;
$lastEvenYearTimestamp = mktime(0, 0, 0, 1, 1, $lastEvenYear);
$startHoursElapsedSinceLastEvenYear = floor((strtotime($startTime) - $lastEvenYearTimestamp) / 3600);
$endHoursElapsedSinceLastEvenYear = floor((strtotime($endTime) - $lastEvenYearTimestamp) / 3600);
$dbNames = DbUtil::getDbNames($appId);
$response = array();
try {
    $sql = 'SELECT ROUND(AVG(avg_network_time), 2) AS networkTime, ROUND(AVG(avg_backend_time), 2) AS backendTime, ROUND(AVG(avg_frontend_time), 2) AS frontendTime, ROUND(AVG(avg_dom_ready_time), 2) AS domReadyTime, ROUND(AVG(avg_done_time), 2) AS doneTime
        FROM ' . $dbNames['summary'] . '.load_time_summary
        WHERE hours_elapsed_since_last_even_year >= :start_hours_elapsed_since_last_even_year
        AND hours_elapsed_since_last_even_year <= :end_hours_elapsed_since_last_even_year
        AND page_id = :page_id';
    $st = $db->prepare($sql);
    $st->bindValue(':start_hours_elapsed_since_last_even_year', $startHoursElapsedSinceLastEvenYear, PDO::PARAM_INT);
    $st->bindValue(':end_hours_elapsed_since_last_even_year', $endHoursElapsedSinceLastEvenYear, PDO::PARAM_INT);
    $st->bindValue(':page_id', $urlId, PDO::PARAM_INT);
    $st->execute();
    $row = $st->fetchAll(PDO::FETCH_ASSOC);
    $response = $row[0];
    $st->closeCursor();
<?php

include 'dbutil.php';
$obj = new DbUtil();
if (isset($_POST['deleteuser'])) {
    $obj->deleteuser($_POST['deleteuser']);
}
header('Location: ../manageuser.php?deleted');
Beispiel #23
0
<!DOCTYPE html>
<?php 
require_once '../db.php';
$Database = new DbUtil();
$userName = $Database->getUserName();
if ($userName == null) {
    header('Location: ../login.php', true, 303);
    exit;
}
$ID = $_GET['id'];
$LINE = $_GET['line'];
$stopData = $Database->getStop($ID);
$lineId = $Database->getLineId($LINE, $userName);
if ($lineId == null) {
    $Database->registerLine($LINE, $userName);
}
$lineId = $Database->getLineId($LINE, $userName);
$Database->registerLineToStop($ID, $lineId);
header("Location: stopdata.php?id={$ID}", true, 303);
Beispiel #24
0
<?php

require_once '../db.php';
$Database = new DbUtil();
$ACTION = @$_GET['action'];
$userName = $Database->getUserName();
switch ($ACTION) {
    case 'userline':
        userLine();
        break;
}
function userLine()
{
    global $Database, $userName;
    $line = $Database->getMyLine($userName);
    if ($line == "") {
        echo 'null';
        return;
    }
    foreach ($line as $key => $value) {
        echo "<data><id>{$key}</id><name>{$value}</name></data>\n";
    }
}
<?php

require_once 'dbutil.php';
$db = new DbUtil();
$articles = $db->getNews();
foreach ($articles as $article) {
    echo "<div class='container'>";
    echo "<table class='page-header col-md-6'>";
    echo "<thead>";
    echo "<tr>";
    echo "<th><h2>" . $article['articlename'] . "</h2></th>";
    echo "</tr>";
    echo "<thead>";
    echo "<tbody>";
    echo "<tr>";
    echo "<td><h3>" . $article['article'] . "</h3></td>";
    echo "</tr>";
    echo "<tr>";
    echo "<td><h5><i> By: " . $db->getUser($article['author']) . "<br><p id='p'>" . $article['timestamp'] . "</p>";
    if (isset($_SESSION['rank']) && $_SESSION['rank'] == 1) {
        echo "<div class='deletearticle text-right'> <a onclick='return confirmAction()' href='inc/deletearticle.php?art=" . $article['id'] . "'><i class='material-icons md-dark md-24'>delete</i></a></div>";
    }
    echo "</i></h5></td>";
    echo "</tr>";
    echo "</tbody>";
    echo "</table>";
    echo "</div>";
    echo "<br />";
}
}
if ($byAge == 1 && $byGender == 1) {
    echo "<th ></th>";
}
if ($byAge == 1 || $byGender == 1) {
    echo "<th ></th>";
}
?>
		<tr>
	</thead>
	<tbody>
        <?php 
# Fetching specimen IDs but keeping the variables similar to reports_testcount_grouped.php
$test_type_list = get_lab_config_specimen_types($lab_config->id);
//$test_type_list = get_lab_config_test_types($lab_config->id); // to get test type ids
$saved_db = DbUtil::switchToLabConfig($lab_config->id);
$tests_done_list = array();
$tests_list = array();
$summ = 0;
foreach ($test_type_list as $test_type_id) {
    $test_name = get_specimen_name_by_id($test_type_id);
    echo "<tr valign='top'>";
    echo "<td>";
    echo $test_name;
    echo "</td>";
    if ($byGender == 1) {
        echo "<td>";
        echo "M";
        echo "<br>";
        echo "F";
        echo "</td>";
<?php

require_once 'dbutil.php';
$db = new DbUtil();
$items = $db->getItems();
foreach ($items as $item) {
    unset($item[0]);
    unset($item[1]);
    echo json_encode($item) . ",\n";
}
Beispiel #28
0
	public function getEditCustomWorksheetForm($worksheet_id, $lab_config)
	{
		if($lab_config == null)
		{
			echo LangUtil::$generalTerms['MSG_NOTFOUND'];
			return;
		}
		$worksheet = CustomWorksheet::getById($worksheet_id, $lab_config);
		if($worksheet == null)
		{
			echo LangUtil::$generalTerms['MSG_NOTFOUND'];
			return;
		}
		?>
		<input type='hidden' name='location' value='<?php echo $lab_config->id; ?>'></input>
		<input type='hidden' name='wid' value='<?php echo $worksheet_id; ?>'></input>
		<table class='hor-minimalist-b' style='width:auto;'>
			<tbody>
			<tr valign='top'>
				<td><?php echo LangUtil::$generalTerms['NAME']; ?></td>
				<td><input type='text' name='wname' id='wname' value='<?php echo $worksheet->name; ?>' class='uniform_width_more'></input></td>
			</tr>
			<tr valign='top'>
				<td>Header</td>
				<td><input type='text' name='header' id='header' value='<?php echo $worksheet->headerText; ?>' class='uniform_width_more'></td>
			</tr>
			<tr valign='top'>
				<td>Title</td>
				<td><input type='text' name='title' id='title' value='<?php echo $worksheet->titleText; ?>' class='uniform_width_more'></td>
			</tr>
			<tr valign='top'>
				<td>Footer</td>
				<td><input type='text' name='footer' id='footer' value='<?php echo $worksheet->footerText; ?>' class='uniform_width_more'></td>
			</tr>
			<tr valign='top'>
				<td><?php echo LangUtil::$pageTerms['MARGINS']; ?> (%)</td>
				<td>
					<?php echo LangUtil::$pageTerms['TOP'];?>
					&nbsp;
					<input type='text' name='margin_top' id='margin_top' value='<?php echo $worksheet->margins[ReportConfig::$TOP]; ?>' size='2'></input>
					&nbsp;&nbsp;&nbsp;
					<?php echo LangUtil::$pageTerms['BOTTOM'];?>
					&nbsp;
					<input type='text' name='margin_bottom' id='margin_bottom' value='<?php echo $worksheet->margins[ReportConfig::$BOTTOM]; ?>' size='2'></input>
					&nbsp;&nbsp;&nbsp;
					<?php echo LangUtil::$pageTerms['LEFT'];?>
					&nbsp;
					<input type='text' name='margin_left' id='margin_left' value='<?php echo $worksheet->margins[ReportConfig::$LEFT]; ?>' size='2'></input>
					&nbsp;&nbsp;&nbsp;
					<?php echo LangUtil::$pageTerms['RIGHT'];?>
					&nbsp;
					<input type='text' name='margin_right' id='margin_right' value='<?php echo $worksheet->margins[ReportConfig::$RIGHT]; ?>' size='2'></input>
				</td>
			</tr>
			<tr valign='top'>
				<td><?php echo LangUtil::$generalTerms['PATIENT_ID']; ?></td>
				<td>
					<input type='radio' name='is_pid' value='Y' id='is_pid'<?php
					if($worksheet->idFields[CustomWorksheet::$OFFSET_PID] == 1)
					{
						echo " checked ";
					}?>><?php echo LangUtil::$generalTerms['YES']; ?></input>
					<input type='radio' name='is_pid' value='N'<?php
					if($worksheet->idFields[CustomWorksheet::$OFFSET_PID] == 0)
					{
						echo " checked ";
					}?>><?php echo LangUtil::$generalTerms['NO']; ?></input>
				</td>
			</tr>
			<tr valign='top'>
				<td><?php echo LangUtil::$generalTerms['PATIENT_DAILYNUM']; ?></td>
				<td>
					<input type='radio' name='is_dnum' value='Y' id='is_dnum'<?php
					if($worksheet->idFields[CustomWorksheet::$OFFSET_DNUM] == 1)
					{
						echo " checked ";
					}?>><?php echo LangUtil::$generalTerms['YES']; ?></input>
					<input type='radio' name='is_dnum' value='N'<?php
					if($worksheet->idFields[CustomWorksheet::$OFFSET_DNUM] == 0)
					{
						echo " checked ";
					}?>><?php echo LangUtil::$generalTerms['NO']; ?></input>
				</td>
			</tr>
			<tr valign='top'>
				<td><?php echo LangUtil::$generalTerms['ADDL_ID']; ?></td>
				<td>
					<input type='radio' name='is_addlid' value='Y' id='is_addlid'<?php
					if($worksheet->idFields[CustomWorksheet::$OFFSET_ADDLID] == 1)
					{
						echo " checked ";
					}?>><?php echo LangUtil::$generalTerms['YES']; ?></input>
					<input type='radio' name='is_addlid' value='N'<?php
					if($worksheet->idFields[CustomWorksheet::$OFFSET_ADDLID] == 0)
					{
						echo " checked ";
					}?>><?php echo LangUtil::$generalTerms['NO']; ?></input>
				</td>
			</tr>
			<tr valign='top'>
				<td><?php echo LangUtil::$pageTerms['CUSTOMFIELDS']; ?></td>
				<td>
					<span id='uf_list_box'>
					<?php echo LangUtil::$generalTerms['NAME']; ?>
					&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
					&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
					&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
					&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
					<?php echo LangUtil::$pageTerms['COLUMN_WIDTH']; ?>
					<br>
					<?php
					if($worksheet->userFields == null || count($worksheet->userFields) == 0)
					{
						//echo LangUtil::$generalTerms['NO']."<br>";
					}
					foreach($worksheet->userFields as $field_entry)
					{
						$field_id = $field_entry[0];
						$field_name = $field_entry[1];
						$field_width = $field_entry[2];
						?>
						<input type='hidden' name='existing_uf_id[]' value='<?php echo $field_id; ?>'></input>
						<input type='text' name='existing_uf_name[]' value='<?php echo $field_name; ?>' class='uniform_width'></input>
						<input type='text' name='existing_uf_width[]' size='2' value='<?php echo $field_width; ?>'></input>
						<br>
						<?php
					}
					?>
					</span>
					<small><a href='javascript:add_another_uf();'><?php echo LangUtil::$generalTerms['ADDNEW']; ?>&raquo;</a></small>
				</td>
			</tr>
			<tr valign='top'>
				<td><?php echo LangUtil::$generalTerms['LAB_SECTION']; ?></td>
				<td>
					<?php
					$test_type_id = $worksheet->testTypes[0];
					$saved_db = DbUtil::switchToGlobal();
					$query_string = "SELECT test_category_id FROM test_type WHERE test_type_id=$test_type_id";
					$record = query_associative_one($query_string);
					$cat_code = $record['test_category_id'];
					$cat_name = get_test_category_name_by_id($cat_code);
					DbUtil::switchRestore($saved_db);				
					echo $cat_name;
					?>
				</td>
			</tr>
		</table>
		<br>
		<div id='test_boxes' class='smaller_font' style='width:auto;'>
		<?php
		$test_type_list = get_test_types_by_site_category($lab_config->id, $cat_code);
		foreach($test_type_list as $test_type)
		{
			$measure_list = $test_type->getMeasures();
			?>
			<div>
			<input type='checkbox' class='test_type_checkbox' name='ttype_<?php echo $test_type->testTypeId; ?>' id='ttype_<?php echo $test_type->testTypeId; ?>' <?php
			if(in_array($test_type->testTypeId, $worksheet->testTypes))
				echo " checked ";
			?>>
			<?php echo $test_type->getName(); ?>
			</input>
			<br>
				<div id='ttype_<?php echo $test_type->testTypeId; ?>_mlist' style='position:relative; margin-left:15px;<?php
				if(in_array($test_type->testTypeId, $worksheet->testTypes) === false)
					echo "display:none;";
				?>'>
				<table class='hor-minimalist-b'>
					<thead>
					<tr>
						<th style='width:200px;'><?php echo LangUtil::$generalTerms['MEASURES']; ?></th>
						<th><?php echo LangUtil::$pageTerms['COLUMN_WIDTH']; ?> (%)</th>
					</tr>
					<?php
					foreach($measure_list as $measure)
					{
						if(in_array($test_type->testTypeId, $worksheet->testTypes))
							$width_val = $worksheet->columnWidths[$test_type->testTypeId][$measure->measureId];
						else
							$width_val = "";
						?>
						<tr>
							<td>
								<?php echo $measure->getName(); ?>
							</td>
							<td>
								<input type='text' value='<?php echo $width_val; ?>' size='2' name='width_<?php echo $test_type->testTypeId."_".$measure->measureId; ?>'>
								</input>
							</td>
						</tr>
						<?php
					}
					?>
					</thead>
					<tbody>
					</tbody>
				</table>
				</div>
			</div>
			<br>
			<?php
		}
		?>
		<input type='button' value='<?php echo LangUtil::$generalTerms['CMD_SUBMIT']; ?>' id='worksheet_submit_button' onclick='javascript:submit_worksheet_form();'>
		</input>
		&nbsp;&nbsp;&nbsp;
		<small>
		<a href='lab_config_home.php?id=<?php echo $lab_config->id; ?>'>
			<?php echo LangUtil::$generalTerms['CMD_CANCEL']; ?>
		</a>
		</small>
		&nbsp;&nbsp;&nbsp;
		<span id='worksheet_submit_progress' style='display:none;'>
			<?php $this->getProgressSpinner(LangUtil::$generalTerms['CMD_SUBMITTING']); ?>
		</span>
		<script type='text/javascript'>
		$(document).ready(function(){
			$('.test_type_checkbox').change( function() {
				toggle_mlist(this);
			});
		});
		
		function toggle_mlist(elem)
		{
			var target_div = elem.name+"_mlist";
			if(elem.checked == true)
			{
				$('#'+target_div).show();
			}
			else
			{
				$('#'+target_div).hide();
			}
		}
		</script>
		<?php
	}
Beispiel #29
0
        return $retval;
    }
    foreach ($resultset as $record) {
        $test = Test::getObject($record);
        $hide_patient_name = TestType::toHidePatientName($test->testTypeId);
        if ($hide_patient_name == 1) {
            $hidePatientName = 1;
        }
        $specimen = get_specimen_by_id($test->specimenId);
        $retval[] = array($test, $specimen, $hide_patient_name);
    }
    return $retval;
}
$lab_config_id = $_REQUEST['location'];
$patient_id = $_REQUEST['patient_id'];
DbUtil::switchToLabConfig($lab_config_id);
$lab_config = get_lab_config_by_id($lab_config_id);
$report_id = $REPORT_ID_ARRAY['reports_testhistory.php'];
$report_config = $lab_config->getReportConfig($report_id);
$margin_list = $report_config->margins;
for ($i = 0; $i < count($margin_list); $i++) {
    $margin_list[$i] = $SCREEN_WIDTH * $margin_list[$i] / 100;
}
?>
<html>
<head>

<style type="text/css"> 
	.btn {
		color:white; 
		background-color:#9fc748;/*#3B5998;*/ 
    $result_cap = $_REQUEST['result_cap'];
}
if (!isset($_REQUEST['result_counter'])) {
    $result_counter = 1;
} else {
    $result_counter = $_REQUEST['result_counter'];
}
$a = $_REQUEST['a'];
$saved_db = "";
$lab_config = null;
$q = $_REQUEST['q'];
$q = strip_tags($q);
if (isset($_REQUEST['l'])) {
    # Save context
    $lab_config = LabConfig::getById($_REQUEST['l']);
    $saved_db = DbUtil::switchToLabConfig($_REQUEST['l']);
} else {
    $lab_config = LabConfig::getById($_SESSION['lab_config_id']);
}
$patient_list = array();
# Fetch list from DB
if ($a == 0) {
    # Fetch by patient ID
    $patient_list = search_patients_by_id($q);
} else {
    if ($a == 1) {
        # Fetch by patient name
        if ($dynamic_fetch == 0) {
            $patient_list = search_patients_by_name($q);
        } else {
            $patient_list = search_patients_by_name_dyn($q, $result_cap, $result_counter);