Exemple #1
0
function registerUser()
{
    $userName = $_POST['userName'];
    # Verify that the user doesn't exist in the database
    $result = verifyUser($userName);
    if ($result['status'] == 'COMPLETE') {
        $email = $_POST['email'];
        $userFirstName = $_POST['userFirstName'];
        $userLastName = $_POST['userLastName'];
        $userPassword = encryptPassword();
        # Make the insertion of the new user to the Database
        $result = registerNewUser($userFirstName, $userLastName, $userName, $email, $userPassword);
        # Verify that the insertion was successful
        if ($result['status'] == 'COMPLETE') {
            # Starting the session
            startSession($userFirstName, $userLastName, $userName);
            echo json_encode($result);
        } else {
            # Something went wrong while inserting the new user
            die(json_encode($result));
        }
    } else {
        # Username already exists
        die(json_encode($result));
    }
}
 public function commitPayment($userId = 0, $payerId, $token, $amt, $itemId)
 {
     $returnObj = array();
     if (verifyUser($userId)) {
         $postDetails = array('USER' => UID, 'PWD' => PASSWORD, 'SIGNATURE' => SIG, 'METHOD' => "DoExpressCheckoutPayment", 'VERSION' => VER, 'AMT' => $amt, 'TOKEN' => $token, 'PAYERID' => $payerId, 'PAYMENTACTION' => "Sale");
         $arrPostVals = array_map(create_function('$key, $value', 'return $key."=".$value."&";'), array_keys($postDetails), array_values($postDetails));
         $postVals = rtrim(implode($arrPostVals), "&");
         $response = runCurl(URLBASE, $postVals);
         //HACK: On sandbox the first request will fail - we need to wait for 2 seconds and then try again
         if ($response == false) {
             sleep(2);
             $response = parseString(runCurl(URLBASE, $postVals));
         } else {
             $response = parseString($response);
         }
         //$returnObj['transactionId'] = $response["PAYMENTINFO_0_TRANSACTIONID"];
         //$returnObj['orderTime'] = $response["PAYMENTINFO_0_ORDERTIME"];
         $returnObj['paymentStatus'] = $response["PAYMENTINFO_0_PAYMENTSTATUS"];
         $returnObj['itemId'] = $itemId;
         $returnObj['userId'] = $userId;
         recordPayment($returnObj);
     }
     return json_encode($returnObj);
 }
<?php

require_once 'template/header.php';
require_once 'functions/productsFunctions.php';
require_once 'functions/categorysFunctions.php';
require_once 'functions/sessionFunctions.php';
verifyUser();
$categorys = retrieveCategorys($connection);
$productId = $_POST['productId'];
$selected = "";
$productData = searchProduct($connection, $productId);
$id = $_POST['id'];
$product = $_POST['product'];
$price = $_POST['price'];
$description = $_POST['description'];
$category = $_POST['category_id'];
if (updateProducts($connection, $id, $product, $price, $description, $category)) {
    $_SESSION['success'] = "Product was successfully updated!";
    header("Location: retrieve.php");
    die;
}
?>

	<div class="col-lg-3"></div>
	<div class="col-lg-6">
		<h1 align="center">Edit Product</h1>
		<hr />
		<form action="update.php" method="post" accept-charset="utf-8">
			<input type="hidden" name="id" value="<?php 
echo $productData['productId'];
?>
Exemple #4
0
<?php

require 'func.php';
session_start();
$errMsg = array();
if (isset($_POST['submit'])) {
    $username = trim($_POST['username']);
    $password = trim($_POST['password']);
    if (count($errMsg) == 0) {
        $userVerification = verifyUser($username, $password);
        if ($userVerification !== false) {
            $_SESSION['user'] = $userVerification;
            header('location:main.php');
            exit;
        } else {
            array_push($errMsg, 'Wrong username or password');
        }
    }
}
?>

<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <title>TEPDM</title>
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <link rel="stylesheet" href="bootstrap-3.3.5-dist/css/bootstrap.min.css">
    <!-- Optional Bootstrap theme -->
    <link rel="stylesheet" href="bootstrap-3.3.5-dist/css/bootstrap-theme.min.css">
    <link rel="stylesheet" href="style/custom.css">
            } else {
                echo json_encode(array('status' => false, 'Message' => 'Pin is not correct'));
            }
        } else {
            echo json_encode(array('status' => false, 'Message' => 'User is not Correct'));
        }
    } else {
        echo json_encode(array('status' => false, 'Message' => 'Login not Successfull'));
    }
});
// Get a single car
$app->get('/ministatement/:name/:password/:user_id/:pin', function ($name, $password, $user_id, $pin) use($app) {
    $app->response()->header("Content-Type", "application/json");
    $status = login($name, $password);
    if ($status) {
        $status = verifyUser($user_id);
        if ($status) {
            $status = VerifyPin($user_id, $pin);
            if ($status) {
                $miniStatement = miniStatement('2007');
                if ($miniStatement != null) {
                    echo json_encode(array('status' => true, 'ministatement' => $miniStatement));
                } else {
                    echo json_encode(array('status' => false, 'Message' => 'No mini statement or file not exist'));
                }
            } else {
                echo json_encode(array('status' => false, 'Message' => 'Pin is not correct'));
            }
        } else {
            echo json_encode(array('status' => false, 'Message' => 'User is not Correct'));
        }
Exemple #6
0
<?php

include "mailFunction.php";
if (isset($_GET['verifyStr'])) {
    $verifyStr = trim($_GET['verifyStr']);
    if (verifyUser($verifyStr) == 1) {
        echo "恭喜,您的账户已经激活成功,感谢您使用我们的服务!";
    } else {
        echo "链接失效!如果您已经激活账户,请直接登录。";
    }
} else {
    echo "链接错误,请点击邮件中的链接";
}
Exemple #7
0
<?php

//register a new user. Makes plenty of checks against duplicate users and common emails
require "../common.php";
if (!empty($_GET["code"])) {
    verifyUser($_GET['email'], $_GET["code"], $DATABASE);
    die;
}
//TODO: Refactor this section
//if any of these are not set, the page will die
if (empty($_POST["email"]) || empty($_POST["password"]) || empty($_POST["password2"]) || empty($_POST["first-name"]) || empty($_POST["last-name"]) || empty($_POST["zip"]) || empty($_POST["phone"])) {
    error("Missing Field", "You tried to register without completing a required field");
}
if ($_POST["password"] !== $_POST["password2"]) {
    error("Passwords Don't Match", "Your passwords did not match");
}
if (!validEmail($_POST["email"])) {
    error("Invalid Email", "Your email " . $_POST["email"] . " is invalid");
}
if (!validPassword($_POST["password"])) {
    error("Invalid Password", "Your password must be longer than 8 characters in length");
}
//evaluate mailing preferences
$mailing = 1;
if (!isset($_POST["mailing"])) {
    $mailing = 0;
}
//cryptify the password
$password = $_POST["password"];
$hash = password_hash($password, PASSWORD_BCRYPT);
$veriRaw = randomString();
session_start();
?>
<style type='text/css'>
	.container {
		margin-left:30%;
		float:left;
		width:60%;
	}
</style>	
<?php 
if (isset($_POST['records_username'])) {
    $message = "";
    if ($_POST['records_username'] == $_SESSION["username"]) {
        $message = "";
        $db2 = retrieveUsersDb();
        $message = verifyUser($db2, $_POST['records_username'], $_POST['records_password']);
        if ($message == "Okay for access.") {
            echo '<meta http-equiv="refresh" content="0;url=end of the month report.php" />';
        } else {
            echo $message;
        }
    } else {
        $message = "Error.  This is not your ID!";
        echo $message;
    }
} else {
    ?>
<div class="container" >

<div class="col-lg-6" >
<div class="well">
<?php

require "label.php";
dbConnect();
if (!verifyUser()) {
    header("Location: index.php");
}
$result = mysql_query("SELECT * FROM member where username_upline='{$username}'") or error(mysql_error());
$memnum = mysql_num_rows($result);
displayHeader("Member Area > Genealogy View");
echo "<p align=\"center\"><font size=\"4\">Jumlah Downline langsung anda = ({$memnum}) Orang</font></p>\n";
if ($memnum != 0) {
    echo "<div align=\"center\">\n";
    echo "  <center>\n";
    echo "  <table border=\"0\" cellspacing=\"0\" width=\"700\" cellpadding=\"0\"><font size=\"1\" face=\"Tahoma\" >\n";
    echo "    <tr class=\"frame\">\n";
    echo "      <td width=\"15%\" height=\"25\" align=\"center\"><font face=\"Tahoma\" size=\"1\" color=\"#FFFFFF\"><b>Nama</b></font></td>\n";
    echo "      <td width=\"15%\" height=\"25\" align=\"center\"><font face=\"Tahoma\" size=\"1\" color=\"#FFFFFF\"><b>E-mail</b></font></td>\n";
    echo "      <td width=\"15%\" height=\"25\" align=\"center\"><font face=\"Tahoma\" size=\"1\" color=\"#FFFFFF\"><b>Alamat</b></font></td>\n";
    echo "      <td width=\"10%\" height=\"25\" align=\"center\"><font face=\"Tahoma\" size=\"1\" color=\"#FFFFFF\"><b>Nomor ID</b></font></td>\n";
    echo "      <td width=\"10%\" height=\"25\" align=\"center\"><font face=\"Tahoma\" size=\"1\" color=\"#FFFFFF\"><b>Username</b></font></td>\n";
    echo "      <td width=\"10%\" height=\"25\" align=\"center\"><font face=\"Tahoma\" size=\"1\" color=\"#FFFFFF\"><b>Status</b></font></td>\n";
    echo "      <td width=\"10%\" height=\"25\" align=\"center\"><font face=\"Tahoma\" size=\"1\" color=\"#FFFFFF\"><b>Kota</b></font></td>\n";
    echo "      <td width=\"10%\" height=\"25\" align=\"center\"><font face=\"Tahoma\" size=\"1\" color=\"#FFFFFF\"><b>Next level</b></font></td>\n";
    echo "    </tr>\n";
    $i = 1;
    while ($row = mysql_fetch_array($result)) {
        $i % 2 == 0 ? $bgColor = "#FFFFFF" : ($bgColor = "#E6E6E6");
        echo "    <tr>\n";
        echo "      <td width=\"15%\" height=\"25\" align=\"center\" bgcolor=\"{$bgColor}\"><font face=\"Tahoma\" size=\"1\" color=\"#000080\">{$row['nama']}</td>\n";
        echo "      <td width=\"15%\" height=\"25\" align=\"center\" bgcolor=\"{$bgColor}\"><font face=\"Tahoma\" size=\"1\" color=\"#000080\">{$row['email']}</a></td>\n";
Exemple #10
0
    $result = mysqli_multi_query($con, $sql);
    if ($result) {
        sendPackage($con, $package, true, "", "ATTENDANCE ADDED");
    } else {
        queryFailed($con, 2.1);
    }
} else {
    if (isset($_POST["PostComment"], $_POST["LoginID"], $_POST["LoginPass"], $_POST["Data"], $_POST["To"]) && $_POST["PostComment"] != "" && $_POST["LoginID"] != "" && $_POST["LoginPass"] != "" && $_POST["Data"] != "" && $_POST["To"] != "") {
        #Connect to database
        $con = dbConnect();
        #Get clean variables from POST
        $EventID = mysqli_real_escape_string($con, $_POST["PostComment"]);
        $CommentText = mysqli_real_escape_string($con, $_POST["Data"]);
        $To = mysqli_real_escape_string($con, $_POST["To"]);
        $LoginID = mysqli_real_escape_string($con, $_POST["LoginID"]);
        $LoginPass = mysqli_real_escape_string($con, $_POST["LoginPass"]);
        #Verify User
        verifyUser($con, $LoginID, $LoginPass);
        $CommentDate = currentDate();
        $package = array();
        $sql = "UPDATE comments SET commenttext = '{$CommentText}', commentdate = '{$CommentDate}' WHERE author = '{$LoginID}' AND username = '******' AND eventid = '{$EventID}'";
        $result = mysqli_multi_query($con, $sql);
        if ($result) {
            sendPackage($con, $package, true, "", "COMMENT TEXT ADDED");
        } else {
            queryFailed($con, 2.1);
        }
    } else {
        missingParams();
    }
}
<?php

include 'include_config.php';
verifyUser(9);
?>
<!DOCTYPE html>
<html lang="en">
  <head>
    <?php 
include 'include_head.php';
?>
    <title><?php 
echo SITE_TITLE;
?>
</title>
    <?php 
include 'include_css.php';
?>
        <!-- bootstrap carosel -->
    <link href="css/bootstrap-carousel.css" rel="stylesheet">
  </head>
  <body>
    <?php 
include 'include_nav.php';
?>
    <!-- START Page Content -->
    <div class="container">
      <div class="row">
        <div class="col-lg-4 text-center">
          <div class="panel panel-default">
            <div class="panel-heading"><strong>Coordinators</strong></div>
Exemple #12
0
        $response = addLink($_REQUEST['from_url'], $_REQUEST['from_url_param'], $_REQUEST['to_url'], $_REQUEST['to_url_param'], $_REQUEST['note']);
        break;
    case "delete_link":
        $response = deleteLink($_REQUEST['from_url'], $_REQUEST['from_url_param'], $_REQUEST['to_url'], $_REQUEST['to_url_param']);
        break;
    case "get_links":
        $response = getLinks($_REQUEST['url'], $_REQUEST['url_param']);
        break;
    case "rate_link":
        $response = rateLink($_REQUEST['from_url'], $_REQUEST['from_url_param'], $_REQUEST['to_url'], $_REQUEST['to_url_param'], $_REQUEST['up']);
        break;
    case "get_link_comment":
        $response = getLinkComment($_REQUEST['from_url'], $_REQUEST['from_url_param'], $_REQUEST['to_url'], $_REQUEST['to_url_param']);
        break;
    case "verify_user":
        $response = verifyUser($_REQUEST['confirm_code']);
        break;
    case "invite_user":
        $response = inviteUser($_REQUEST['email']);
        break;
    case "get_title":
        $response = getTitle($_REQUEST['url'], $_REQUEST['url_param']);
        break;
    case "update_title":
        $response = updateTitle($_REQUEST['url'], $_REQUEST['url_param'], $_REQUEST['title']);
        break;
}
mysql_close($connection);
if ($_REQUEST['command'] == "verify_user") {
    echo "<html>";
    echo "<head> <title> User verification </title></head>";
Exemple #13
0
<?php

session_start();
include "messagesFns.php";
//获得用户登录的信息
$username = $_POST['username'];
$password = $_POST['password'];
//验证用户信息
$res = verifyUser($username, $password);
if ($res) {
    $_SESSION['validUser'] = $res['username'];
    $_SESSION['validUid'] = $res['uid'];
    $uid = $res['uid'];
    $sid = md5($uid);
    header("Location: http://1.softyun.sinaapp.com/messages/list.php");
} else {
    header("Location: http://1.softyun.sinaapp.com/messages/login.php");
}
exit;
Exemple #14
0
global $logTxt;
file_put_contents($logTxt, "NEW TRANSMISSION START\n", FILE_APPEND | LOCK_EX);
foreach ($_POST as $param_name => $param_val) {
    file_put_contents($logTxt, '**$_POST** [' . $timestamp . ']' . " Param: {$param_name}; Value: {$param_val}\n", FILE_APPEND | LOCK_EX);
}
#######END OF LOGGING
####CREATE GROUP####
if (isset($_POST["CreateGroup"], $_POST["AdminID"], $_POST["AdminPass"], $_POST["GroupName"], $_POST["GroupDescription"]) && $_POST["AdminID"] != "" && $_POST["AdminPass"] != "" && $_POST["GroupName"] != "" & $_POST["GroupDescription"] != "") {
    #Connect to database
    $con = dbConnect();
    #Get clean variables from POST
    $GroupName = mysqli_real_escape_string($con, $_POST["GroupName"]);
    $GroupDescription = mysqli_real_escape_string($con, $_POST["GroupDescription"]);
    $AdminID = mysqli_real_escape_string($con, $_POST["AdminID"]);
    $AdminPass = mysqli_real_escape_string($con, $_POST["AdminPass"]);
    #Verify User
    verifyUser($con, $AdminID, $AdminPass);
    $package = array();
    $sql = "INSERT INTO groups (description, name) VALUES ('{$GroupDescription}', '{$GroupName}')";
    $result = mysqli_query($con, $sql);
    if (!$result) {
        queryFailed($con, 2.1);
    }
    $result = mysqli_query($con, "SELECT LAST_INSERT_ID()");
    $ChatID = mysqli_fetch_row($result)[0];
    $chatFile = $chatDir . "Group_{$ChatID}.txt";
    file_put_contents($chatFile, "[" . date('Y-m-d H:i:s') . "] {$GroupName} group created!\n", FILE_APPEND | LOCK_EX);
    sendPackage($con, $package, true, "", "GROUP ADDED");
} else {
    missingParams();
}
Exemple #15
0
<?php 
include "common.php";
//remember to set cookie
if (isset($_COOKIE['user'])) {
    $user = $_COOKIE['user'];
    $id = $_COOKIE['id'];
    $db = newPDO();
    if (verifyUser($id, $db)) {
        header('Location: home.php');
    } else {
        header('Location: userinfo.php');
    }
} else {
    header('Location: index.php');
}
// check user exists in our database, if so, redirect to home.php
//if not, store the user, ask its university, class standing...
Exemple #16
0
<?php

require_once '../c_config.php';
$session = new Sessions();
$i = null;
// just a helper for error checking
if (isset($_POST["submit"])) {
    $username = $_POST["username"];
    $password = $_POST["password"];
    if (verifyUser($username, $password)) {
        $id = Users::getIdByUsername($username);
        Cookies::setLoginCookies($id, 30);
        // remember for 30 dayz!
        $session->setSession($id, $username);
        $i = false;
    } else {
        $i = true;
    }
}
?>
<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <script src="js/jquery.min.js"></script>
    <link href="css/login.css" rel='stylesheet' type='text/css' />
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <script type="application/x-javascript"> addEventListener("load", function() { setTimeout(hideURLbar, 0); }, false); function hideURLbar(){ window.scrollTo(0,1); } </script>
    <title>ccms Admin Login</title>
</head>
Exemple #17
0
 case 'login':
     if ($_POST['type'] == 'signup') {
         $userCreated = addUser($_POST['form-first-name'], $_POST['form-last-name'], $_POST['form-email'], $_POST['form-password']);
         if ($userCreated) {
             $message = 'User Successfully Created';
             $_SESSION['message'] = $message;
             $title = 'Login';
             include 'view/profile.php';
             exit;
         } else {
             $_SESSION['message'] = 'Email is already in use. Please select another.';
             include 'view/signUp.php';
             exit;
         }
     } else {
         $exists = verifyUser($_POST['form-username'], $_POST['form-password']);
         if ($exists) {
             $reviews = getReviewInfo($_SESSION['logged_in_user']);
             $userProfile = getProfileInfo($_SESSION['logged_in_user']);
             include 'view/profile.php';
             exit;
         } else {
             $_SESSION['message'] = 'Invalid Credentials';
             include 'view/signUp.php';
             exit;
         }
     }
     exit;
 case 'profile':
     if (isset($_SESSION['logged_in_user'])) {
         $reviews = getReviewInfo($_SESSION['logged_in_user']);
Exemple #18
0
<div class="maindiv">
<?php 
session_start();
require_once "php/database.php";
require_once "php/storedprocedures.php";
require_once "php/error.php";
require_once "php/constants.php";
if (is_array($_FILES['newavatar'])) {
    $file = $_FILES['newavatar'];
    if ($file['error'] == UPLOAD_ERR_OK) {
        if ($file['size'] <= AVATAR_MAX_SIZE) {
            $dimensions = getimagesize($file['tmp_name']);
            if ($dimensions) {
                if ($dimensions[0] <= AVATAR_WIDTH && $dimensions[1] <= AVATAR_HEIGHT) {
                    $db = connectToDatabase();
                    $results = verifyUser($db, 1, $_SESSION['id'], $_SESSION['token']);
                    switch ($results[SP::ERROR]) {
                        case ERR::OK:
                            //$_SESSION['token'] = $results[SP::TOKEN];
                            $success = move_uploaded_file($file['tmp_name'], "avatar/" . $_SESSION['id'] . ".jpg");
                            if ($success) {
                                echo "<p>File successfully uploaded!</p>";
                            } else {
                                echo "<p>File not uploaded successfully. Please try again later, or contact the web master.</p>";
                            }
                            break;
                        case ERR::TOKEN_EXPIRED:
                            echo "<p>Your session has expired; please <a href='login.php'>log in</a> again</p>";
                            break;
                        case ERR::PERMIS_FAIL:
                            echo "<p>You do not have the required permissions to do that.</p>";
function pretendUser()
{
    //the session_status function is only available from php 5.4 on. We just suppress the possible warning on
    //double started sessions. In fact this is harmless and php will just start the session it already had (if this is
    //the case, but still fires a warning. This function will and should nver be called in production, so it is not
    //an issue there.
    //if (session_status() == PHP_SESSION_NONE) {
    @session_start();
    //}
    $user_id = getRequestVar('pretend', altSubValue($_SESSION, 'pretend_user', 0));
    if ($user_id) {
        if (!(isset($_SESSION['pretend_user']) && ($_SESSION['pretend_user'] && $_SESSION['pretend_user'] == $user_id) || verifyUser($user_id))) {
            return array(0, 0);
        }
        $same_pretend = $_SESSION['pretend_user'] == $user_id;
        $_SESSION['pretend_user'] = $user_id;
        $original_user = $GLOBALS['user'];
        $old_state = drupal_save_session();
        //drupal_save_session(FALSE);
        if (isset($_SESSION['pretend_user_obj']) && $_SESSION['pretend_user_obj'] && $same_pretend) {
            $GLOBALS['user'] = $_SESSION['pretend_user_obj'];
        } else {
            $GLOBALS['user'] = user_load($user_id);
            $GLOBALS['user']->roles = repairRoles($GLOBALS['user']->roles);
            $_SESSION['pretend_user_obj'] = $GLOBALS['user'];
        }
        return array($original_user, $old_state);
    } else {
        $_SESSION['pretend_user_obj'] = $_SESSION['pretend_user'] = 0;
        return array(0, 0);
    }
}
function getDatabaseSessions($strDB, $strDBName, $blnShowSQL = false)
{
    global $arrDBConns;
    $intSessions = 0;
    $intDatabases = 0;
    $strInfo = '';
    $strTableHeader = '';
    $strTable = '';
    if (testPort($arrDBConns[$strDB]['DBIP'], $arrDBConns[$strDB]['DBPort'], 0.5)) {
        $objConn = pg_connect('host=' . $arrDBConns[$strDB]['DBIP'] . ' port=' . $arrDBConns[$strDB]['DBPort'] . ' dbname=' . $strDBName . ' user='******'DBUser'] . ' password='******'DBPass']);
        if (!$objConn) {
            return '<div class="alert alert-error">Error connecting to <strong>' . $strDB . '</strong>!</div>';
        }
        $strSubSQL = '';
        if ($arrDBConns[$strDB]['DBVersion'] == '9.2xl') {
            $strSubSQL = "SELECT b.datname\n                          ,a.pid AS procpid\n                          ,a.usesysid\n                          ,u.usename\n                          ,a.client_addr\n                          ,a.client_port\n                          ,a.backend_start\n                          ,a.query_start\n                          ,a.waiting\n                          ,CASE\n                            WHEN a.state = 'idle' THEN '<IDLE>'\n                            ELSE a.query\n                           END AS current_query\n                    FROM pg_stat_activity AS a\n                      LEFT JOIN pg_user AS u\n                        ON a.usesysid = u.usesysid\n          JOIN pg_database as b on a.datid = b.oid";
        }
        if ($strSubSQL == '') {
            $strSubSQL = "SELECT 'We' AS datname\n                          ,'have' AS procpid\n                          ,'a' AS usename\n                          ,'problam' AS client_addr\n                          ,'with' AS client_port\n                          ,CURRENT_TIMESTAMP AS backend_start\n                          ,'' AS waiting\n                          ,'Problem getting activity from " . $strDB . "." . $strDBName . " AS current_query";
        }
        // use the sub query and stick it into the FROM clause
        // this is designed to allow us to expand to other versions of postgres with slightly diffrent pg_stat_activity queries
        $strSQL = "SELECT datname\n                     ,procpid\n                     ,usesysid\n                     ,usename\n                     ,client_addr\n                     ,client_port\n                     ,TO_CHAR(backend_start, 'YYYY-MM-DD HH12:MIam') AS backend_start\n                     ,TO_CHAR((extract(epoch from(now() - backend_start)) || ' second')::interval, 'HH24:MI:SS') AS strConnectionDuration\n                     ,query_start\n                     ,CASE\n                       WHEN current_query != '<IDLE>' THEN TO_CHAR((extract(epoch from(now() - query_start)) || ' second')::interval, 'HH24:MI:SS')\n                       ELSE ''\n                      END AS strQueryDuration\n                     ,CASE\n                       WHEN current_query != '<IDLE>' THEN CAST(extract(epoch from(now() - query_start)) AS int)\n                       ELSE 0\n                      END AS dblQueryDuration\n                     ,waiting\n                     ,current_query\n               FROM (" . $strSubSQL . ") AS t\n               ORDER BY query_start desc";
        #echo $strSQL;
        $objDBResults = pg_exec($objConn, $strSQL);
        if (!$objDBResults) {
            return '<div class="alert alert-error">Error will robinson! Had an issue pulling activity for <strong>' . $strDBName . '</strong></div>';
        }
        // All good lets loop through the activity for this database
        $intDBRows = pg_numrows($objDBResults);
        if ($intDBRows == '') {
            $intDBRows = 0;
        }
        // Loop on rows in the result set.
        for ($ri = 0; $ri < $intDBRows; $ri++) {
            $dbrow = pg_fetch_array($objDBResults, $ri);
            // add one to the sessions count
            $intSessions++;
            if (substr($dbrow["current_query"], 0, 30) != substr($strSQL, 0, 30)) {
                $strTableRow = '<tr>' . "\n";
                // flag rows with connections not idle that have been running for a while (not good!)
                if ($dbrow["current_query"] != '<IDLE>') {
                    if ((int) $dbrow['dblqueryduration'] < 600) {
                        $strTableRow = '<tr class="success">' . "\n";
                    }
                    if ((int) $dbrow['dblqueryduration'] >= 600 && (int) $dbrow['dblqueryduration'] < 1800) {
                        $strTableRow = '<tr class="warning">' . "\n";
                    }
                    if ((int) $dbrow['dblqueryduration'] >= 1800) {
                        $strTableRow = '<tr class="danger">' . "\n";
                    }
                }
                if ($dbrow['current_query'] == '<IDLE> in transaction') {
                    $strTableRow = '<tr class="info">' . "\n";
                }
                $strTable .= $strTableRow;
                // if the user is an admin, lets give them the option to kill processes
                if (verifyUser(9)) {
                    $strKillPID = '  <a href=\'sessions.php?n=' . $strDB . '&pid=' . $dbrow['procpid'] . '\' class=\'btn btn-default btn-sm\'>Yes. Kill the process now!</a>' . "\n";
                    $strKillPID .= '  <br><br>' . "\n";
                    $strKillPID .= '  <a href=\'#\' class=\'btn btn-default btn-sm\'>No Thanks. I\'ve changed my mind!</a>' . "\n";
                    $strTable .= '  <td>' . "\n";
                    #          $strTable .= '    <a class="btn btn-mini" href="db_activity.php?db=' . $_GET['db'] . '&pid=' . $dbrow['procpid'] . '"><i class="icon-trash"></i></a><br>' . "\n";
                    if (isset($_GET['n'])) {
                        $strTable .= '<a href="#" rel="popover" class="btn btn-default btn-xs popup-marker" data-placement="right" data-html="true" title="Are you sure you want to kill PID ' . $dbrow['procpid'] . ' running on ' . $_GET['n'] . '?" data-content="' . $strKillPID . '">' . "\n";
                        $strTable .= '<i class="fa fa-trash-o"></i>' . "\n";
                        $strTable .= '</a>' . "\n";
                    }
                    $strTable .= '    <small>' . $dbrow['procpid'] . '</small>' . "\n";
                    $strTable .= '  </td>' . "\n";
                } else {
                    $strTable .= '  <td><small>' . $dbrow['procpid'] . '</small></td>';
                }
                $strTable .= '  <td>' . $dbrow["datname"] . '</td>' . "\n";
                $strTable .= '  <td>' . $dbrow["usename"] . '</td>' . "\n";
                $strTable .= '  <td>' . $dbrow["client_addr"] . '</td>' . "\n";
                $strTable .= '  <td>' . $dbrow["backend_start"] . '</td>' . "\n";
                $strTable .= '  <td align="center">' . $dbrow["strqueryduration"] . '</td>' . "\n";
                // if the session is not idle lets show the current query
                if ($dbrow["current_query"] != '<IDLE>') {
                    $strTable .= '  <td>' . $dbrow["current_query"] . '</td>' . "\n";
                } else {
                    $strTable .= '  <td>&nbsp;</td>' . "\n";
                }
                $strTable .= '</tr>' . "\n";
            }
        }
        return $strTable;
    } else {
        return '<div>Could not validate port is active on database server:' . $strDB . '</div>';
    }
}