示例#1
0
function getCurrentPlantStats($plantID)
{
    if ($GLOBALS['CONNECTION'] == null) {
        ConnectDB();
    }
    $info = array();
    // Temperature
    $tempSQL = "SELECT * FROM `user_plant_stats` WHERE `pid` = '" . $plantID . "' AND `key` LIKE 'temperature' ORDER BY `timestamp` DESC LIMIT 1 ";
    $tempQuery = mysql_query($tempSQL) or die("Error getting temperature: " . mysql_error());
    while ($tempResults = mysql_fetch_assoc($tempQuery)) {
        $key = $tempResults["key"];
        $val = $tempResults["value"];
        $info["temp"] = $val;
    }
    // Light
    $lightSQL = "SELECT * FROM `user_plant_stats` WHERE `pid` = '" . $plantID . "' AND `key` LIKE 'light' ORDER BY `timestamp` DESC LIMIT 1 ";
    $lightQuery = mysql_query($lightSQL) or die("Error getting light: " . mysql_error());
    while ($lightResults = mysql_fetch_assoc($lightQuery)) {
        $key = $lightResults["key"];
        $val = $lightResults["value"];
        $info["light"] = $val;
    }
    /*
    	// Moisture
    	$moistSQL = "SELECT * FROM `user_plant_stats` WHERE `pid` = 11 AND `key` LIKE 'moisture' LIMIT 1 ";
    	$moistQuery = mysql_query($moistSQL) or die("Error getting moisture: " . mysql_error());
    
    	while($moistResults = mysql_fetch_assoc($moistQuery)){
    		$key = $moistResults["key"];
    		$val = $moistResults["value"];
    		$info[$key] = $val;
    	}*/
    echo json_encode($info);
    //$sql = "SELECT * FROM `user_plant_stats` WHERE `pid` = 11 AND `key` LIKE \'temperature\' LIMIT 0, 30 ";
}
示例#2
0
function setAlertType($type)
{
    if ($GLOBALS['CONNECTION'] == null) {
        ConnectDB();
    }
    $pattern = "/[^(\\d)]/";
    $replacement = '';
    $userID = $_REQUEST['uid'];
    $pID = $_REQUEST['pid'];
    $query = mysql_query("SELECT * FROM `user_plant_settings` WHERE `key` = 'Alert' AND `uid` =  {$userID} AND `pid` = {$pID}");
    if (mysql_num_rows($query) == 0) {
        $insertSQL = mysql_query("INSERT INTO `user_plant_settings` (`uid`, `pid`, `key`, `value`) VALUES ('" . $userID . "', '" . $pID . "', 'Alert', '" . $type . "')");
        if ($type == 'text') {
            $carrier = $_REQUEST['carrier'];
            $phoneNum = preg_replace($pattern, $replacement, $_REQUEST['num']);
            $updateQuery = mysql_query('UPDATE `' . $GLOBALS['DB'] . '`.`uc_users` SET `phone_number` = ' . $phoneNum . ', `carrier` = "' . $carrier . '"WHERE `id` = ' . $userID);
        }
    } else {
        $updateQuery = mysql_query("UPDATE `user_plant_settings` SET `key` = 'Alert',`value` = '" . $type . "' WHERE `uid` = {$userID} AND `pid` = {$pID}");
        if ($type == 'text') {
            $carrier = $_REQUEST['carrier'];
            $phoneNum = preg_replace($pattern, $replacement, $_REQUEST['num']);
            $updateQuery = mysql_query('UPDATE `' . $GLOBALS['DB'] . '`.`uc_users` SET `phone_number` = ' . $phoneNum . ', `carrier` = "' . $carrier . '" WHERE `id` = ' . $userID);
        }
    }
}
示例#3
0
function getOptimalSettings($plantID)
{
    if ($GLOBALS['CONNECTION'] == null) {
        ConnectDB();
    }
    $info = array();
    // convert user plant id to plant type id
    $getQuery = "SELECT `type` FROM `" . $GLOBALS['DB'] . "`.`user_plants` WHERE `id` = '" . $plantID . "' LIMIT 1";
    $getSQL = mysql_query($getQuery) or die("Error getting plants: " . mysql_error());
    while ($result = mysql_fetch_assoc($getSQL)) {
        $plantType = $result["type"];
    }
    // light
    $optLightSQL = "SELECT `value` FROM `plants` WHERE `pid` = '" . $plantType . "' AND `key` LIKE 'shade' LIMIT 1 ";
    $optLightQuery = mysql_query($optLightSQL) or die("Error getting light: " . mysql_error());
    while ($optLightResults = mysql_fetch_assoc($optLightQuery)) {
        $info["light"] = $optLightResults["value"];
    }
    // Temp
    $optTempSQL = "SELECT `value` FROM `plants` WHERE `pid` = '" . $plantType . "' AND `key` LIKE 'hardyness' LIMIT 1 ";
    $optTempQuery = mysql_query($optTempSQL) or die("Error getting temp: " . mysql_error());
    while ($optTempResults = mysql_fetch_assoc($optTempQuery)) {
        $info["temp"] = $optTempResults["value"];
    }
    // Water
    $optMoistureSQL = "SELECT `value` FROM `plants` WHERE `pid` = '" . $plantType . "' AND `key` LIKE 'moisture' LIMIT 1 ";
    $optMoistureQuery = mysql_query($optMoistureSQL) or die("Error getting temp: " . mysql_error());
    while ($optMoistureResults = mysql_fetch_assoc($optMoistureQuery)) {
        $info["moisture"] = $optMoistureResults["value"];
    }
    echo json_encode($info);
}
示例#4
0
function init()
{
    session_name("VarnerCC");
    session_start();
    session_cache_limiter('none');
    if (!isset($_SESSION["AdminID"])) {
        $_SESSION["AdminID"] = "";
    }
    if (!isset($_SESSION["UserID"])) {
        $_SESSION["UserID"] = "";
    }
    ConnectDB();
}
示例#5
0
function getSettings($uid, $pid)
{
    if ($GLOBALS['CONNECTION'] == null) {
        ConnectDB();
    }
    $settingsSQL = "SELECT * FROM `" . $GLOBALS['DB'] . "`.`user_plant_settings` WHERE `pid` = '" . $pid . "' AND `uid` = '" . $uid . "'";
    $info = array();
    $setQuery = mysql_query($settingsSQL) or die('Error getting fun: ' . mysql_error());
    while ($setResults = mysql_fetch_assoc($setQuery)) {
        $key = $setResults["key"];
        $value = $setResults["value"];
        $info[$key] = $value;
    }
    return $info;
}
示例#6
0
function getPlantData($user, $id)
{
    if ($GLOBALS['CONNECTION'] == null) {
        ConnectDB();
    }
    $getQuery = "SELECT * FROM `" . $GLOBALS['DB'] . "`.`user_plants` WHERE `uid` = '" . $user . "' AND `id` = '" . $id . "' LIMIT 0, 50";
    $getSQL = mysql_query($getQuery) or die("Error getting plants: " . mysql_error());
    while ($result = mysql_fetch_assoc($getSQL)) {
        $info = array();
        $info["plantid"] = $result["id"];
        $info["typeid"] = $result["type"];
        $info["created"] = $result["timestamp"];
        $info["name"] = $result["name"];
        $deepSQL = "SELECT * FROM `" . $GLOBALS['DB'] . "`.`plants` WHERE `pid` = '" . $info["typeid"] . "' AND (`key` = 'common_name' OR `key` = 'latin_name')";
        $deepQuery = mysql_query($deepSQL) or die("Error getting deep plant info " . mysql_error());
        while ($deepResults = mysql_fetch_assoc($deepQuery)) {
            $key = $deepResults["key"];
            $val = $deepResults["value"];
            $info[$key] = $val;
        }
        $nextSQL = "SELECT id from `" . $GLOBALS['DB'] . "`.`user_plants` WHERE `id` = (SELECT min(`id`) FROM `" . $GLOBALS['DB'] . "`.`user_plants` WHERE `uid` = '" . $user . "' AND `id` > '" . $info["plantid"] . "') LIMIT 1";
        $nextQuery = mysql_query($nextSQL) or die("Error getting next: " . mysql_error());
        while ($nextResult = mysql_fetch_assoc($nextQuery)) {
            $info['next'] = $nextResult['id'];
        }
        $prevSQL = "SELECT id from `" . $GLOBALS['DB'] . "`.`user_plants` WHERE `id` = (SELECT max(`id`) FROM `" . $GLOBALS['DB'] . "`.`user_plants` WHERE `uid` = '" . $user . "' AND `id` < '" . $info["plantid"] . "') LIMIT 1";
        $prevQuery = mysql_query($prevSQL) or die("Error getting next: " . mysql_error());
        while ($prevResult = mysql_fetch_assoc($prevQuery)) {
            $info['prev'] = $prevResult['id'];
        }
        $deeperSQL = "SELECT * FROM `" . $GLOBALS['DB'] . "`.`user_plant_stuff` WHERE `pid` = '" . $info["plantid"] . "' AND `uid` = '" . $user . "'";
        $deeperQuery = mysql_query($deeperSQL) or die("Error getting deeper dashboard info " . mysql_error());
        while ($deeperResults = mysql_fetch_assoc($deeperQuery)) {
            $key = $deeperResults["key"];
            $val = $deeperResults["value"];
            $info[$key] = $val;
        }
        // printPlant($info);
        return $info;
    }
}
 public static function LoadSettings()
 {
     global $config, $db;
     if (!$db) {
         ConnectDB();
     }
     $result = mysql_query("SELECT `name`,`value` FROM `" . $config['table prefix'] . "Settings`", $db);
     if (!$result) {
         echo '<p>Failed to load settings from the database! The plugin may not have been loaded for the first time yet.</p>';
         exit;
     }
     if (mysql_num_rows($result) == 0) {
         return;
     }
     while (TRUE) {
         $row = mysql_fetch_assoc($result);
         if (!$row) {
             break;
         }
         $config['settings'][$row['name']] = array('value' => $row['value'], 'changed' => FALSE);
     }
 }
示例#8
0
function InquryByID($_id)
{
    //echo "1.3-2";
    ConnectDB();
    $sql = "SELECT _content FROM `Soccer` WHERE _index='{$_id}'";
    $result = mysql_query($sql) or die('MySQL qsuery error');
    //echo $result;
    //echo "--: <br>";
    $_dataArray = array();
    while ($row = mysql_fetch_assoc($result)) {
        //mysql_fetch_array //assoc
        //echo "---<br>";
        //echo $row['_index']." : ".$row['_date']." : ".$row['_content'];
        //echo "<br>";
        $row['_content'] = htmlspecialchars($row['_content']);
        //restore HTML texts
        $row['_content'] = html_entity_decode($row['_content']);
        //reverse the process
        array_push($_dataArray, $row['_content']);
    }
    //echo "<br>";
    //return json_encode( $_dataArray );
    return $_dataArray;
}
示例#9
0
function VrDbFloors()
{
    // Modified to exclude the "corrected" URLs !!
    set_time_limit(0);
    $parents = array();
    $fl = array();
    $floors = array();
    //$sql = "TRUNCATE TABLE KHovFeed.nf_redirected_url_db";
    //$db = ConnectDB();
    //$db->query($sql);
    $db = ConnectDB();
    $parents = CollectOld($db);
    mysqli_close($db);
    $i = 0;
    $db = ConnectDB();
    $stmt = $db->prepare("UPDATE kHovFeed.nf_redirected_url_db SET new_url=? WHERE old_url=?");
    foreach ($parents as $x => $y) {
        if (stripos($y, "?") !== FALSE) {
            // contains a ?+id strip it store as floor[$i]
            //  $fl = split("=",$y);
            //$floors[$i] = $fl[0]."=";
            /*'do nothing' on 'if' statement to exclude corrections*/
        } else {
            //does not.. reformat it with GetRedir store as floor[$i]
            $floors[$i] = GetRedir($y);
            $g = AppenFl($floors[$i], $db);
            $p = (string) $y;
            $f = (string) $g[0];
            if ($f == "") {
                $f = $p;
            }
            echo $f . " ";
            echo $p . " ";
            $stmt->bind_param("ss", $f, $p);
            $stmt->execute();
        }
        $i++;
    }
}
示例#10
0
<?php

define("ctlid_datatype_id", "dtid");
define("ctlid_scaling_factor_figures", "sff");
$includeRelPath = ".";
require_once "{$includeRelPath}/conndb/conndb.php";
require_once "{$includeRelPath}/lib/libhttp.php";
require_once "{$includeRelPath}/lib/htmldbutils.php";
$datatype_id = get_or_post_numeric(ctlid_datatype_id);
$scaling_factor_figures = cNull(get_or_post_numeric(ctlid_scaling_factor_figures), 15);
$connDB = ConnectDB();
?>
<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="utf-8">
    <title>Health data visualization</title>
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta name="description" content="Visualisation des chiffres-clés des hôpitaux suisses">
    <meta name="author" content="Renaud Hirsch">

    <!-- Le styles -->
    <link href="css/bootstrap.css" rel="stylesheet">
    <style>
      body {
        padding-top: 60px; /* 60px to make the container go all the way to the bottom of the topbar */
      }
    </style>
    <link href="css/bootstrap-responsive.css" rel="stylesheet">

    <!-- Le HTML5 shim, for IE6-8 support of HTML5 elements -->
示例#11
0
function getKnownHazards($pid)
{
    if ($GLOBALS['CONNECTION'] == null) {
        ConnectDB();
    }
    $value = "";
    $query = mysql_query("SELECT `value` FROM `" . $GLOBALS['DB'] . "`.`plants` WHERE `pid` = {$pid} AND `key` = 'known_hazards'");
    while ($results = mysql_fetch_assoc($query)) {
        $value = $results["value"];
    }
    $value = stripBrackets($value);
    return "<p>{$value}</p>";
}
示例#12
0
    $db = ConnectDB();
    $sql = "TRUNCATE TABLE KHovFeed.cb_community_hd_db";
    $db->query($sql);
}
if (isset($_POST['clean_bqmi'])) {
    $db = ConnectDB();
    $sql = "TRUNCATE TABLE KHovFeed.boyl_qmi";
    $db->query($sql);
}
if (isset($_POST['clean_cbqmi'])) {
    $db = ConnectDB();
    $sql = "TRUNCATE TABLE KHovFeed.cb_community_qmi_db";
    $db->query($sql);
}
if (isset($_POST['init'])) {
    $db = ConnectDB();
    $sql = "TRUNCATE TABLE KHovFeed.nf_redirected_url_db";
    $db->query($sql);
}
if (isset($_POST['eval'])) {
    $url = "http://nochrome.fusionatthemeadows.khov.ml3ds-cloud.com/resources/data/CommunityData/fusionatthemeadows.khov.ml3ds-cloud.com";
    //$url = "http://www.khov.com/find-new-homes/arizona/peoria/85383/k-hovnanian-homes/fusion-at-the-meadows";
    //$rawDat = file_get_contents($url);
    //print_r($rawDat);
    EvalSource($url);
}
?>


<!DOCTYPE html>
<html>
示例#13
0
define("FB_API_KEY" , "148451281843294");
define("FB_SECRET" , "69de471eb988025ca0b7a23a4bf632fc");

function ConnectDB() {
	$host="localhost"; // Host name.
	$db_user="******"; // MySQL username.
	$db_password="******"; // MySQL password.
	$database="wroupon"; // Database name.
	if (mysql_connect( $host, $db_user, $db_password ) && mysql_select_db($database)) return 1;	else return 0;
}

//
// the php facebook api downloaded at step 3
include("facebook-client/facebook.php");

if(!ConnectDB()) die;

//
// start facebook api with the codes defined in step 1.
$fb=new Facebook( FB_API_KEY , FB_SECRET );
$fb_user=$fb->get_loggedin_user();
$out="";

if($fb_user) {
	// if we already have a user ID cookie than we link
	// in the database this user with his facebook account
	// using the fb_userid field.
	// this code assumes that when a user login in your
	// community you set up a value in a cookie called "myid".
	// this cookie is the one that you use when you want
	// to remember the user:
示例#14
0
    print "Malloc scribbling enabled.\n";
    putenv("MallocLogFile=/dev/null");
    putenv("MallocScribble=1");
    putenv("MallocPreScribble=1");
    putenv("MallocGuardEdges=1");
}
require_once "helpers.inc";
/////////////
// run tests
/////////////
if (IsModelGenMode()) {
    print "GENERATING REFERENCE TEST RESULTS\n\n";
} else {
    print "PERFORMING AUTOMATED TESTING\n\n";
}
$testconn = ConnectDB();
if (mysqli_connect_error()) {
    print "ERROR: failed to connect to MySQL: " . mysqli_connect_error() . "\n";
    exit(1);
} else {
    $testconn->close();
}
$t = MyMicrotime();
// build test lists
$tests = array();
$dh = opendir(".");
$user_skipped = 0;
while ($entry = readdir($dh)) {
    if (substr($entry, 0, 5) != "test_") {
        continue;
    }
示例#15
0
                <td colspan="2" height="40">&nbsp;<td>
          </tr>
        </table>
</form>



<?php 
function real_htmlspecialchars($string)
{
    return htmlspecialchars($string, ENT_QUOTES, "UTF-8");
}
$submit = $_REQUEST['submit'];
if ($submit) {
    include "inc.functions.php";
    @ConnectDB();
    @session_start();
    $username = real_htmlspecialchars($_REQUEST['username']);
    $passwort = real_htmlspecialchars($_REQUEST['passwort']);
    $sql = "SELECT username, passwort FROM {$user_table} WHERE username = '******' AND passwort = '{$passwort}' LIMIT 1";
    $result = mysql_query($sql);
    $row = mysql_fetch_row($result);
    if ($row[0] == "") {
        echo "<span class='text'><font color='#FF0000'>Benutzername und/oder Passwort waren falsch.</font></span>";
    } else {
        //$HTTP_SESSION_VARS["username"] = $username;
        $_SESSION['username'] = $username;
        //echo "<span class=text>Login erfolgreich.</span>";
        echo "<meta http-equiv=\"refresh\" content=\"0; URL=show.php?AuflistungsArt=alles\">";
    }
    //end if
示例#16
0
function mysql_san($text)
{
    global $db;
    if (!$db) {
        ConnectDB();
        if (!$db) {
            echo '<p>Database not connected..</p>';
            exit;
        }
    }
    // san an array
    if (is_array($text)) {
        return array_map(__METHOD__, $text);
    }
    if (empty($text)) {
        return '';
    }
    return mysql_real_escape_string($text);
}
示例#17
0
function AfficherQuartier()
{
    $bdd = ConnectDB();
    $sql = 'SELECT idQuartier,NomQuartier FROM quartier';
    $requete = $bdd->prepare($sql);
    $requete->execute();
    return $requete->fetchAll();
}
示例#18
0
<?php

require "config_db.php";
require_once 'bbb-api-php/includes/bbb-api.php';
if (!isset($_SESSION["user_name"])) {
    header('Location: ' . $url_login);
    exit;
}
$conn = ConnectDB();
$sql = "select personal_fname_tha, personal_lname_tha from view_user_ad where user_name = '" . $_SESSION["user_name"] . "'";
$res = mssql_query($sql);
$user = mssql_fetch_array($res, MSSQL_ASSOC);
mssql_close($conn);
$bbb = new BigBlueButton();
$joinParams = array('meetingId' => $_GET["room_id"], 'username' => iconv('ISO-8859-11', 'UTF-8', $user["personal_fname_tha"] . " " . $user["personal_lname_tha"]), 'password' => 'mp', 'createTime' => '', 'userId' => '', 'webVoiceConf' => '');
// Get the URL to join meeting:
$itsAllGood = true;
try {
    $result = $bbb->getJoinMeetingURL($joinParams);
} catch (Exception $e) {
    echo 'Caught exception: ', $e->getMessage(), "\n";
    $itsAllGood = false;
}
if ($itsAllGood == true) {
    header('Location: ' . $result);
}
示例#19
0
文件: index3.php 项目: subrock/emc
<?php

require_once 'functions.php';
$recperpage = 5;
// Customize this var.
$dbname = 'your-db-name';
$dbhost = 'localhost';
$dbuser = '******';
$dbpwd = 'your-db-password';
$dbname = 'emc_v2';
$dbhost = 'localhost';
$dbuser = '******';
$dbpwd = 'testme';
ConnectDB($dbhost, $dbuser, $dbpwd, $dbname);
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>A Simple PHP / MySQL Data Browser</title>
<link href="style.css" rel="stylesheet" type="text/css" />
</head>
<body>
<h1>PHP Tutorial : A Simple MySQL Data Browser</h1>
<h2>Part 3</h2>
<p><a href="http://www.thewebmasterscafe.net/web-development/basic-php-data-browser-pt3.html"><em>You can read this PHP tutorial here.</em></a></p>
<table width="400" cellspacing="0" cellpadding="3" border="0">
<?php 
// SET THE NUMBER OF PAGES AVAILABLE
$nbpages = ceil(GetNbRec() / $recperpage);
// READ PARAMETER VALUES PASSED THROUGH 'GET'
示例#20
0
<?php

session_start();
?>

<?php 
require_once "../connect_safer.php";
$dbh = ConnectDB();
if (!empty($_GET['id'])) {
    try {
        $post_id = $_GET['id'];
        $query = "DELETE FROM posts WHERE post_id=:postid;";
        $stmt = $dbh->prepare($query);
        $stmt->bindParam(':postid', $post_id, PDO::PARAM_INT);
        $stmt->execute();
        echo "<pre>";
        print_r($stmt->errorInfo());
        echo "</pre>";
        header('Location: ./section.php?id=' . $_SESSION['section_id']);
    } catch (PDOException $e) {
        die("PDO error when fetching post content for postID=" . $_GET['id'] . ": " . $e->getMessage());
    }
}
?>

<pre style="color: #fff">
$_SESSION
<?php 
print_r($_SESSION);
?>
$_POST
示例#21
0
文件: index.php 项目: Stixs/tovuti
<?php

session_start();
require './Modules/functies.php';
$pdo = ConnectDB();
?>

<!DOCTYPE html>

<html>
	<head>
		<link href="./docs/icon.ico" type="icon/x-icon" rel="icon">
		<link rel="stylesheet" type="text/css" href="style.css">
		<title>FC Iorn</title>
	</head>
	<body>
	<div id="site">
		<div id="page">
			<?php 
require './Modules/Menu.php';
?>
			<div id="content">
				
					<?php 
if (isset($_GET['Page'])) {
    $page = $_GET['Page'];
} else {
    $page = 1;
}
switch ($page) {
    case 0:
示例#22
-1
function checkToken($token)
{
    global $url_login, $url_authenn, $sys_code;
    if (isset($token)) {
        $data = getAuthen($token);
        if (isset($data->BappGetSessionResult->Username)) {
            $_SESSION["user_name"] = sprintf("%08s", $data->BappGetSessionResult->Username);
            $_SESSION["name"] = $data->BappGetSessionResult->FullNameTH;
            $_SESSION['token'] = $token;
            $_SESSION['image_url'] = $data->BappGetSessionResult->ImageUrl;
            // Role
            $conn = ConnectDB();
            $sql = "select ROLE_CODE from DB_DS.DBO.GET_ROLE_BY_PER_SYSID ('" . sprintf("%08s", $_SESSION["user_name"]) . "', '" . $sys_code . "')";
            $query = mssql_query($sql);
            $row = mssql_fetch_array($query, MSSQL_ASSOC);
            $_SESSION["role"] = $row['ROLE_CODE'];
            mssql_free_result($query);
            mssql_close($conn);
            header('Location: /meeting/index.php');
        } else {
            header('Location: ' . $url_login);
        }
    } else {
        header('Location: ' . $url_login);
    }
}