<?php $orz = $_POST['orz']; ?> <form method="post" action="update.php"> <b>ID:</b> <input type="text" size="40" name="id" value="<?php echo $orz; ?> " readonly="value"> <br> <?php require "dbconnect.php"; $aa = "select * from testtable where id='{$orz}'"; $result = pg_query(utf8_encode($aa)) or die(pg_error()); if (($row = pg_fetch_array($result)) != 0) { $bb = $row['name']; $cc = $row['age']; $dd = $row['memo']; } else { $bb = ' '; $cc = ' '; $dd = ' '; } ?> <b>Name:</b> <input type="text" size="40" name="name" value="<?php echo $bb; ?> ">
<?php require_once "config.php"; $auth_host = $GLOBALS['auth_host']; $auth_user = $GLOBALS['auth_user']; $auth_pass = $GLOBALS['auth_pass']; $auth_port = $GLOBALS['auth_port']; $strConn = "host={$auth_host} port={$auth_port} dbname={$auth_dbase} user={$auth_user} password={$auth_pass}"; $db = pg_connect($strConn) or die("Error connection: " . pg_last_error()); $user_name = $_POST['name']; $user_password = $_POST['password']; $sql = pg_query($db, "SELECT * FROM account WHERE user_id = '{$user_name}' AND password = MD5('" . $user_password . "') ") or die(pg_error()); $rows = pg_num_rows($sql); if ($rows > 0) { echo "true"; } else { echo "false"; } pg_close($db); ?>
function conectar($server = IP_SERVER, $user = USER_DB, $pass = PASSWORD_DB, $based = DB, $puerto = PORT, $tipo_conexion = "N") { try { switch ($tipo_conexion) { case "N": // Conexion a B.D no persistente $this->id_conexion = @pg_connect("host={$server} port={$puerto} dbname={$based} user={$user} password={$pass}"); break; case "P": // Conexion a B.D persistente $this->id_conexion = @pg_pconnect("host={$server} port={$puerto} dbname={$based} user={$user} password={$pass}"); break; default: // Otros casos $this->id_conexion = @pg_connect("host={$server} port={$puerto} dbname={$based} user={$user} password={$pass}"); break; } if ($this->id_conexion) { //$this->id_conexion->set_charset(CODEC); return $this->id_conexion; } else { throw new Exception("Error 01: " . ($this->id_conexion ? pg_error($this->id_conexion) : 'Servidor o B.D. no disponible')); } } catch (Exception $e) { $this->error1 = $e->getMessage(); return null; } }
public static function getUsers($id) { $id = MyUtil::parseInt($id); if (!$id) { $id = 0; } $stm = "SELECT id, " . " creation_dt," . " email," . " facebook_id," . " first_name," . " google_id," . " img_file_path," . " img_url," . " instagram_id," . " last_name," . " phone_nbr," . " tumblr_id," . " twitter_id," . " updated_ts," . " user_type_nbr," . " username " . " FROM " . self::$table_name . " WHERE id = {$id} OR 0 = {$id}"; $result = ConnDB::query_db($stm); if (!$result) { return MyUtil::fnOk(false, pg_error(), null); } $retArray = []; while ($row = pg_fetch_assoc($result)) { array_push($retArray, $row); } if (sizeof($retArray) > 0) { return MyUtil::fnOk(true, "Found Users", $retArray); } else { return MyUtil::fnOk(false, "No Results", $retArray); } }
<?php // Lecture du fichier de conf $config = parse_ini_file("/etc/house-on-wire/house-on-wire.ini", true); $db = pg_connect("host=" . $config['bdd']['host'] . " port=" . $config['bdd']['port'] . " dbname=" . $config['bdd']['dbname'] . " user="******" password="******" options='--client_encoding=UTF8'") or die("Erreur de connexion au serveur SQL"); $nb_points = $_GET['nb']; $query = "SELECT ROUND(1000*EXTRACT(EPOCH from date)) AS when, papp FROM teleinfo ORDER BY date DESC LIMIT {$nb_points};"; $result = pg_query($db, $query) or die("Erreur SQL : " . pg_error()); $points = array(); while ($row = pg_fetch_array($result)) { $point = array($row['when'], $row['papp']); $points[] = $point; } header("Content-type: text/json"); echo json_encode(array_reverse($points), JSON_NUMERIC_CHECK);
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <?php require "dbconnect.php"; if ($_POST['submit']) { $query = "select * from testtable where id=" . $_POST['id']; $result = pg_query(utf8_encode($query)) or die(pg_error()); if (($row = pg_fetch_array($result)) == 0) { $qq = "update testtable set name = '" . $_POST['name'] . "', age = '" . $_POST['age'] . "',memo = '" . $_POST['memo'] . "'WHERE id ='" . $_POST['id'] . "'"; pg_query(utf8_encode($qq)) or die(pg_error()); } }
public function listtable($field, $sql, $link1, $link2, $par = "all") { $sColumns[0] = 'to_char(id,\'999999\')'; $qColumns[0] = 'id'; $x = 1; foreach ($field as $vs) { $sColumns[$x] = 'upper(' . $vs . ')'; if ($vs[0] == '#') { $vs = substr($vs, 1); $sColumns[$x] = 'to_char(' . $vs . ',\'999999999999\')'; } $aColumns[$x] = $vs; $qColumns[$x] = $vs; $x++; } $aColumns[$x] = 'id'; $qColumns[$x] = 'id'; /* $aColumns = array( 'nik', 'nama_pegawai', 'id' ); $sColumns = array( 'to_char(id,\'999\')','upper(nik)', 'upper(nama_pegawai)'); $qColumns = array( 'id', 'nik','nama_pegawai', 'id' ); */ $sIndexColumn = "id"; $sOrder = ""; $sql1 = ""; /* DB table to use */ $sTable = "tb_pegawai"; $sLimit = ""; if (isset($_GET['iDisplayStart']) && $_GET['iDisplayLength'] != '-1') { $sLimit = "LIMIT " . pg_escape_string($_GET['iDisplayLength']) . " OFFSET " . pg_escape_string($_GET['iDisplayStart']); } if (isset($_GET['iSortCol_0'])) { $sOrder = "ORDER BY "; for ($i = 0; $i < intval($_GET['iSortingCols']); $i++) { if ($_GET['bSortable_' . intval($_GET['iSortCol_' . $i])] == "true") { $sOrder .= $qColumns[intval($_GET['iSortCol_' . $i])] . "\n\n\t\t\t\t\t\t" . pg_escape_string($_GET['sSortDir_' . $i]) . ", "; } } $sOrder = substr_replace($sOrder, "", -2); if ($sOrder == "ORDER BY") { $sOrder = ""; } } $sWhere = ""; if (isset($_GET['sSearch'])) { $sWhere = "WHERE ("; for ($i = 0; $i < count($sColumns); $i++) { $sWhere .= $sColumns[$i] . " LIKE '%" . pg_escape_string(strtoupper($_GET['sSearch'])) . "%' OR "; } $sWhere = substr_replace($sWhere, "", -3); $sWhere .= ')'; } for ($i = 0; $i < count($sColumns); $i++) { if (isset($_GET['bSearchable_' . $i]) || isset($_GET['sSearch_' . $i])) { if ($_GET['bSearchable_' . $i] == "true" && $_GET['sSearch_' . $i] != '') { if ($sWhere == "") { $sWhere = "WHERE "; } else { $sWhere .= " AND "; } $sWhere .= $sColumns[$i] . " LIKE '%" . pg_escape_string(strtoupper($_GET['sSearch_' . $i])) . "%' "; } } } $sQuery = "\n\n\t\t\tSELECT * FROM(\n\t\t\t" . $sql . ") as tbx\n\t\t\t{$sWhere}\n\n\t\t\t{$sOrder}\n\t\t\t{$sLimit}\n\n\t\t\t"; $rResult = $this->db->query($sQuery) or die(pg_error()); /* Data set length after filtering */ $sQuery = "\n\n\t\t\tSELECT count(*) as jml FROM(\n\t\t\t" . $sql . ") as tbx\n\t\t\t{$sWhere}\n\n\t\t\t\t\n\n\t\t"; #exit($sQuery); $rResultFilterTotal = $query = $this->db->query($sQuery) or die("Gagal"); foreach ($query->result() as $row) { $iFilteredTotal = $row->jml; } /* Total data set length */ $sQuery = "\n\n\t\t\tSELECT count(*) as jml FROM(\n\t\t\t" . $sql . ") as tbx"; $rResultTotal = $query = $this->db->query($sQuery) or die("Gagal"); foreach ($query->result() as $row) { $iTotal = $row->jml; } $sEcho = ""; if (isset($_GET['sEcho'])) { $sEcho = $_GET['sEcho']; } $output = array("sEcho" => intval($sEcho), "iTotalRecords" => $iTotal, "iTotalDisplayRecords" => $iFilteredTotal, "aaData" => array()); foreach ($rResult->result() as $r) { $row = array(); $jd = count($qColumns) - 1; $i = 0; foreach ($qColumns as $v) { if ($i == $jd) { $act = ''; if ($par == 'all') { $act .= '<a href="' . base_url() . $link1 . '/' . $r->{$v} . '"> <img src="' . base_url() . 'img/edit.gif" alt="Edit Data"></a>'; $act .= '<a href="#" onClick="confirmationDel(' . $r->{$v} . ',\'' . base_url() . $link2 . '\');"> <img src="' . base_url() . 'img/del.gif" alt="Delete Data"></a>'; } if ($par == 'edit') { $act .= '<a href="' . base_url() . $link1 . '/' . $r->{$v} . '"> <img src="' . base_url() . 'img/edit.gif" alt="Edit Data"></a>'; } if ($par == 'delete') { $act .= '<a href="#" onClick="confirmationDel(' . $r->{$v} . ',\'' . base_url() . $link2 . '\');"> <img src="' . base_url() . 'img/del.gif" alt="Delete Data"></a>'; } if ($par != 'report') { $row[] = $act; } } else { $row[] = $r->{$v}; } $i++; } $output['aaData'][] = $row; } echo json_encode($output); }
<script type="text/javascript" src="/js/dygraph-combined.js"></script> <style type='text/css'> #labels > span.highlight { border: 1px solid grey; } </style> </head> <body> <div id="graphdiv" style="width:800px; height:600px; float:left;"></div> <div id="labels"></div> <p> <b>Sondes : </b> <?php // Lecture du fichier de conf $config = parse_ini_file("/etc/house-on-wire/house-on-wire.ini", true); $db = pg_connect("host=" . $config['bdd']['host'] . " port=" . $config['bdd']['port'] . " dbname=" . $config['bdd']['dbname'] . " user="******" password="******" options='--client_encoding=UTF8'") or die("Erreur de connexion au serveur SQL"); $result = pg_query($db, "SELECT * from onewire where type ='temperature' and id in ('10.22E465020800', '10.28BD65020800', '10.380166020800', '10.A8EB65020800', '10.D6F865020800', '10.EDFA65020800', '28.BB1A53030000') order by id") or die("Erreur SQL sur recuperation des valeurs: " . pg_error()); $i = 0; $labels = array(); array_push($labels, '"Date"'); while ($row = pg_fetch_array($result)) { echo '<input id="' . $i . '" type="checkbox" checked="" onclick="change(this)">'; echo '<label for="' . $i . '"> ' . $row['name'] . '</label>'; array_push($labels, '"' . $row['name'] . '"'); $i++; } ?> </p> <script type="text/javascript"> g = new Dygraph(
<?php require_once "config.php"; $auth_host = $GLOBALS['auth_host']; $auth_user = $GLOBALS['auth_user']; $auth_pass = $GLOBALS['auth_pass']; $auth_dbase = $GLOBALS['auth_dbase']; $db = pg_connect($auth_host, $auth_user, $auth_pass) or die(pg_error()); pg_select_db($auth_dbase, $db); $username = pg_real_escape_string($_POST['name']); $password = pg_real_escape_string($_POST['password']); $email = pg_real_escape_string($_POST['email']); $sql = pg_query("SELECT * FROM account WHERE user = '******'"); $rows = pg_num_rows($sql); if ($rows > 0) { echo "false"; } else { $activation = md5(uniqid(rand(), true)); pg_query("INSERT INTO account(user,password,email) VALUES ('{$username}',MD5('" . $password . "'),'{$email}')"); echo "true"; } pg_close($db); ?>
<?php // Lecture du fichier de conf $config = parse_ini_file("/etc/house-on-wire/house-on-wire.ini", true); $db = pg_connect("host=" . $config['bdd']['host'] . " port=" . $config['bdd']['port'] . " dbname=" . $config['bdd']['dbname'] . " user="******" password="******" options='--client_encoding=UTF8'") or die("Erreur de connexion au serveur SQL"); $query = "SELECT\n 220 * isousc as papp_max\n FROM\n teleinfo\n\torder by date desc\nlimit 1\n "; $result = pg_query($db, $query) or die("Erreur SQL sur recuperation des valeurs: " . pg_error()); // On prend les infos de la premiere sonde $papp = pg_fetch_array($result); $result = pg_query($db, "SELECT date, papp from teleinfo where date > current_timestamp - interval '1 minute' order by date asc") or die("Erreur SQL sur recuperation des valeurs: " . pg_error()); ?> <script type="text/javascript"> var data = []; <?php while ($row = pg_fetch_array($result)) { echo "data.push([new Date(\"" . $row["date"] . "\"), " . $row["papp"] . "]);\n"; } ?> var g = new Dygraph( document.getElementById("div_g"), data, { stepPlot: true, fillGraph: true, stackedGraph: true, valueRange: [0, <?php echo $papp['papp_max']; ?> ], // includeZero: true,
<?php ini_set('display_errors', 1); //database login info $host = 'localhost'; $port = '5432'; $dbname = 'ward'; $user = '******'; $password = '******'; $conn = pg_connect("host={$host} port={$port} dbname={$dbname} user={$user} password={$password}"); if (!$conn) { echo "Not connected : " . pg_error(); exit; } //if a query, add those to the sql statement if (isset($_GET['nx'])) { $nx = $_GET['nx']; $ny = $_GET['ny']; $ts = $_GET['ts']; $alfa = $_GET['alfa']; $sql = "UPDATE not_spatial_param SET\n nx = {$nx},\n ny = {$ny},\n ts = {$ts},\n alfa = {$alfa};"; } $calculus = "DROP TABLE tempo;\nCREATE TABLE tempo (res float[][]);\nINSERT INTO tempo(res) values (interpol());\nDELETE FROM rasters WHERE rid = 1;\nSELECT DROPRasterConstraints ('rasters'::name, 'rast'::name);\nINSERT INTO rasters (rid, rast) VALUES (1, st_setvalues(st_addband(st_makeemptyraster((SELECT nx FROM not_spatial_param),(SELECT ny FROM not_spatial_param),(select st_xmin(geometry) from bounding_box),(select st_ymax(geometry) from bounding_box),\n(((select st_xmax(geometry) from bounding_box)-(select st_xmin(geometry) from bounding_box))/(SELECT nx FROM not_spatial_param)),(((select st_ymin(geometry) from bounding_box)-(select st_ymax(geometry) from bounding_box))/(SELECT ny FROM not_spatial_param)),0,0,3857), 1, '32BF', 1, 0), 1,1,1,(select compound_array(array[res]) from tempo)));\n SELECT ADDRasterConstraints ('rasters'::name, 'rast'::name);\nselect * from not_spatial_param;\nselect (st_summarystats(rast)).* FROM rasters where rid = 1;"; if (!($response = pg_query($conn, $sql))) { echo "A query error occured.\n"; exit; } if (!($response = pg_query($conn, $calculus))) { echo "A query error occured.\n"; exit; }
while ($row = pg_fetch_array($result)) { ncurses_mvwaddstr($bl, $ligne, 2, sprintf("%-18s", $row['name'] . " : ")); if ($row['last_value'] == 1) { ncurses_wcolor_set($bl, 2); ncurses_mvwaddstr($bl, $ligne, 24, sprintf("%15s", "Fermée")); ncurses_wcolor_set($bl, 0); } else { ncurses_wattron($bl, NCURSES_A_BOLD); ncurses_wcolor_set($bl, 1); ncurses_mvwaddstr($bl, $ligne, 24, sprintf("%15s", "Ouverte")); ncurses_wattroff($bl, NCURSES_A_BOLD); ncurses_wcolor_set($bl, 0); } $ligne++; } $result = pg_query($db, "select count(*) as nb_sonde, sum(case when date_trunc('minute', last_update) = (select date_trunc('minute', max(last_update)) from onewire) then 1 else 0 end ) as nb_sonde_ok, sum(case when date_trunc('minute', last_update) != (select date_trunc('minute', max(last_update)) from onewire) then 1 else 0 end ) as nb_sonde_ko, date_trunc('minute', max(last_update)) as last_update, case when (select date_trunc('minute', max(last_update)) from onewire) < current_timestamp - interval '1 min' then 1 else 0 end as alerte, current_timestamp - interval '1 min' from onewire;") or die('Erreur SQL sur recuperation des valeurs: ' . pg_error()); $maj = pg_fetch_array($result); if ($maj['nb_sonde_ok'] == $maj['nb_sonde']) { ncurses_mvwaddstr($bl, 13, 2, "Maj : "); ncurses_wcolor_set($bl, 2); ncurses_mvwaddstr($bl, 13, 8, $maj['last_update'] . " " . $maj['nb_sonde_ok'] . "/" . $maj['nb_sonde'] . " sondes"); ncurses_wcolor_set($bl, 0); } else { ncurses_mvwaddstr($bl, 13, 2, "Maj : "); ncurses_wattron($bl, NCURSES_A_BOLD); ncurses_wcolor_set($bl, 1); ncurses_mvwaddstr($bl, 13, 8, $maj['last_update'] . " " . $maj['nb_sonde_ok'] . "/" . $maj['nb_sonde'] . " sondes"); ncurses_wattroff($bl, NCURSES_A_BOLD); ncurses_wcolor_set($bl, 0); } // nb_sonde | nb_sonde_ok | nb_sonde_ko | last_update | alerte | ?column?
<?php session_start(); require "dbconnect.php"; // Connect to server and select databse. $connection = pg_connect("dbname={$database} user={$user} password={$password} host={$host}"); if (!$connection) { die("Not connected : " . pg_error()); } // username and password sent from form $username = $_POST['username']; $password = $_POST['password']; $hashpass = md5($mypassword); // To protect against SQL injection $username = stripslashes($username); $password = stripslashes($password); $query = "SELECT * FROM public.\"Registered_Users\" WHERE username = '******' AND password = '******'"; $result = pg_exec($connection, $query); // Count matching rows returned $count = pg_numrows($result); // If result matched $username and $password, table row must be 1 row if ($count == 1) { // Register $username session and redirect to file "index.php" $_SESSION["username"] = $username; header("location:index.php"); } else { header("location:login_fail.php"); }
$cari2 = "{$d}-{$b}"; $storeinit = pg_fetch_array(pg_query("select inisial_store from master_store where id={$_SESSION['id_storeee']}")); $rowid = pg_fetch_array(pg_query("select max(cast(substr(id_bongkar,1,5) as integer)) as id from trans_bongkar where id_bongkar like '%{$cari}%'")); $idbaru = $rowid[0] + 1; $init_jenis = pg_fetch_array(pg_query("select init_jenis from master_artikel_jenis where id=35")); if ($idbaru < 10) { $idbongkar = "0000{$idbaru}/{$storeinit['0']}-{$init_jenis['0']}/{$cari2}"; } elseif ($idbaru >= 10 && $idbaru < 100) { $idbongkar = "000{$idbaru}/{$storeinit['0']}-{$init_jenis['0']}/{$cari2}"; } elseif ($idbaru >= 100 && $idbaru < 1000) { $idbongkar = "00{$idbaru}/{$storeinit['0']}-{$init_jenis['0']}/{$cari2}"; } elseif ($idbaru >= 1000 && $idbaru < 10000) { $idbongkar = "0{$idbaru}/{$storeinit['0']}-{$init_jenis['0']}/{$cari2}"; } $qry1 = "INSERT INTO trans_bongkar(id_bongkar, id_store, id_item, tgl_bongkar,type_bongkar,created_date,created_by) VALUES ('{$idbongkar}', '{$id_store}','{$id_item}', '{$tgl_rongsok}', '{$type_bongkar}','{$created_date}','{$created_by}')"; $rslt = pg_query($qry1) or die(pg_error()); $row2 = pg_fetch_array(pg_query("select id from trans_bongkar where id_bongkar='{$idbongkar}'")); for ($i = 0; $i < count($data_building_bongkar); $i++) { "</br>"; $q2 = pg_query("INSERT INTO trans_bongkar_detail(id_bongkar, data_building_bongkar, data_exception_bongkar, jumlah_building_bongkar) VALUES ('{$row2['0']}','{$data_building_bongkar[$i]}','{$data_exception_bongkar[$i]}','{$jumlah_building_bongkar[$i]}')"); } echo '<script language="javascript">'; echo 'alert("Tambah Data Berhasil");'; echo 'document.location="trans_destruction.php"'; echo '</script>'; } ?> <div class="row"> <div class="col-lg-12"> <div class="panel panel-default"> <div class="span12">
</head> <body> <div id="graphdiv" style="width:800px; height:300px;"></div> <div id="graphdiv2" style="width:800px; height:300px;"></div> <?php // Lecture du fichier de conf $config = parse_ini_file("/etc/house-on-wire/house-on-wire.ini", true); $db = pg_connect("host=" . $config['bdd']['host'] . " port=" . $config['bdd']['port'] . " dbname=" . $config['bdd']['dbname'] . " user="******" password="******" options='--client_encoding=UTF8'") or die("Erreur de connexion au serveur SQL"); $query = "SELECT\n *\n FROM\n onewire\n WHERE\n id = ANY ( case\n when exists(select 1 from onewire where id = '" . $_GET['id'] . "')\n then (select array_agg(id) from onewire where id = '" . $_GET['id'] . "')\n else (select array_agg(id) from onewire_meta where regroupement = '" . $_GET['id'] . "' )\n end )"; $result = pg_query($db, $query) or die("Erreur SQL sur recuperation des valeurs: " . pg_error()); // On prend les infos de la premiere sonde $info_sonde = pg_fetch_array($result); if (pg_num_rows($result) > 1) { $info_sonde['name'] = $_GET['id']; } $result = pg_query($db, "SELECT extract(epoch from current_timestamp)*1000 as finish_date, extract( epoch from current_date - interval '10 days')*1000 as start_date") or die("Erreur SQL sur recuperation des valeurs: " . pg_error()); $date = pg_fetch_array($result); ?> <script type="text/javascript"> g = new Dygraph( // containing div document.getElementById("graphdiv"), '/php/get_data_csv.php?type=last_days&sonde=<?php echo $_GET['id']; ?> ', { customBars: true, title: '<?php
//取得上傳檔案資訊 $filename = $_FILES['image']['name']; $tmpname = $_FILES['image']['tmp_name']; $filetype = $_FILES['image']['type']; $filesize = $_FILES['image']['size']; $file = NULL; if (isset($_FILES['image']['error'])) { if ($_FILES['image']['error'] == 0) { $instr = fopen($tmpname, "rb"); $file = addslashes(fread($instr, filesize($tmpname))); } } //新增圖片到資料庫 pg_query("insert into testtable (id,name,age,memo, img) values ('{$id}','{$name}','{$age}','{$memo}', '{$file}')"); } ?> <?php $result = pg_query("select * from testtable ") or die(pg_error()); $xx = pg_fetch_all($result); foreach ($xx as $row) { echo "<b>ID:</b>" . $row['id'] . "<br><b>Name:</b>" . $row['name'] . "<br><b>Age:</b>" . $row['age'] . "<br><b>Memo:</b>" . $row['memo'] . "<br><br><br>"; } pg_free_result($result); ?> <h2><a href="search.php">修改</a></h2> <h2><a href="delete.php">刪除</a></h2> <h2><a href="insert.php">新增</a></h2> </form>
</li> <?php } ?> <li data-role="list-divider" role="heading"> Energie </li> <li data-theme="c"> EDF <span class="ui-li-count"> <?php $result = pg_query($db, " select * from (select extract(EPOCH FROM date) as ts, (hchp+hchc) as conso from teleinfo where date >= (current_timestamp - interval '5min') order by date asc) a limit 1; ") or die("Erreur SQL sur recuperation des valeurs: " . pg_error()); $row = pg_fetch_array($result); $ts_prec = $row["ts"]; $conso_prec = $row["conso"]; $result = pg_query($db, " select extract(EPOCH FROM date) as ts, (hchp+hchc) as conso from teleinfo order by date desc limit 1; ") or die("Erreur SQL sur recuperation des valeurs: " . pg_error()); $row = pg_fetch_array($result); $ts_now = $row["ts"]; $conso_now = $row["conso"]; echo round(3600 * ($conso_now - $conso_prec) / ($ts_now - $ts_prec)); ?> W </span> </li> </ul> </div> </div> </body> </html>
} else { $selected = ""; $hidden = "hidden"; } $tabsbuttons .= "<div class=\"tab " . $row['level'] . " {$selected}\" data-tab-name=\"" . $row['level'] . "\">\n"; $tabsbuttons .= $row['name'] . "\n"; $tabsbuttons .= "</div>\n"; $tabscontainers .= "<div class=\"tabBody " . $row['level'] . " {$hidden}\">\n"; $tabscontainers .= "<div id=\"" . $row['level'] . "\" class=\"widgets\"></div>\n"; if ($row['level'] == "meteo") { $tabscontainers .= "<a href='http://house.vitre.info/php/chart_rain_total.php?year=2013-01-01'>Graph pluviometrie</a><br/>"; } $tabscontainers .= "</div>\n"; } // Récupération des sondes $result = pg_query($db, 'select id, coalesce(o.name, om.name) as name, coalesce(o.unity, om.unity) as unity , top, "left", level, coalesce(o.type, om.type) as type from onewire_meta om left join onewire o using (id)') or die('Erreur SQL sur recuperation des valeurs: ' . pg_error()); $widgetsData = array(); while ($row = pg_fetch_array($result)) { $widgetsData[] = array('id' => $row['id'], 'title' => $row['name'], 'unit' => $row['unity'], 'top' => $row['top'], 'left' => $row['left'], 'level' => $row['level'], 'type' => $row['type']); } ?> <!DOCTYPE html> <html> <head> <!--[if IE]> <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1" /> <![endif]--> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <link rel="shortcut icon" type="image/x-icon" href="/favicon.ico" /> <link rel="stylesheet" type="text/css" href="/css/main.css" />
<?php // Lecture du fichier de conf $config = parse_ini_file("/etc/house-on-wire/house-on-wire.ini", true); $db = pg_connect("host=" . $config['bdd']['host'] . " port=" . $config['bdd']['port'] . " dbname=" . $config['bdd']['dbname'] . " user="******" password="******" options='--client_encoding=UTF8'") or die("Erreur de connexion au serveur SQL"); $query = "SELECT MIN(papp) as min FROM teleinfo WHERE date >= ( current_timestamp - interval '24h' );"; $result = pg_query($db, $query) or die("Erreur SQL sur selection MIN() et MAX() de PAPP: " . pg_error()); $row = pg_fetch_array($result); $papp_min_24h = $row['min']; // Recuperation du plus vieux timestamp auquel le MIN des dernieres 24h a ete atteint $query = "SELECT ROUND( 1000*EXTRACT( EPOCH FROM date ) ) AS when FROM teleinfo WHERE papp = " . $papp_min_24h . " AND date >= ( current_timestamp - interval '24h' ) ORDER BY date ASC LIMIT 1"; $result = pg_query($db, $query) or die("Erreur SQL sur selection MIN() et MAX() de PAPP: " . pg_error()); $row = pg_fetch_array($result); $when_papp_min_24h = $row['when']; echo $_GET["jqueryCallback"] . "("; echo "{ x: {$when_papp_min_24h}, title: 'Mini 24h', text: 'Mini des dernieres 24h : {$papp_min_24h} W' })";
public static function error($err = null) { if ($err === null) { return pg_error(); } else { return pg_error($err); } }
<?php include "header.php"; extract($_GET); extract($_POST); if ($posting == 1) { $sql = "insert into master_user\r\n(id_user,nama_user,password,id_store,userho,id_role) values \r\n('{$id_user}','{$nama_user}','{$password}',{$id_store},'{$userho}','{$id_role}') "; $rslt = pg_query($sql) or die(pg_error()); echo pg_fetch_array($rslt); echo '<script language="javascript">'; echo 'alert("Tambah Data Berhasil");'; echo 'document.location="master_users.php"'; echo '</script>'; } ?> <div class="row"> <div class="col-lg-12"> <div class="panel panel-default"> <div class="span12"> <!-- BEGIN PAGE TITLE & BREADCRUMB--> <ul class="breadcrumb"> <li> <i class="glyphicon glyphicon-home"></i> <a href="inside.php">Home</a> <i class="icon-angle-right"></i> </li> <li> <a href="master_users.php" onClick="ShowListDiv();">Master Users</a> </li>
<?php // Lecture du fichier de conf $config = parse_ini_file("/etc/house-on-wire/house-on-wire.ini", true); $db = pg_connect("host=" . $config['bdd']['host'] . " port=" . $config['bdd']['port'] . " dbname=" . $config['bdd']['dbname'] . " user="******" password="******" options='--client_encoding=UTF8'") or die("Erreur de connexion au serveur SQL"); $query = "SELECT ROUND( EXTRACT(EPOCH FROM date) ), papp FROM teleinfo WHERE ptec='HC';"; $result = pg_query($db, $query) or die("Erreur SQL " . pg_error()); if (!$result) { echo "Erreur SQL: " . pg_error(); exit; } echo $_GET["callback"] . "("; $first = TRUE; echo "["; while ($row = pg_fetch_row($result)) { echo '[' . $row[0] . ',' . $row[1] . ']'; if ($first == FALSE) { echo ','; $first = FALSE; } } echo "]);";
<?php function validaValor($cadena) { // Funcion utilizada para validar el dato a ingresar recibido por GET if (eregi('^[a-zA-Z0-9._αινσϊρ‘!Ώ? -]{1,40}$', $cadena)) { return TRUE; } else { return FALSE; } } $valor = trim($_GET['dato']); $campo = trim($_GET['actualizar']); if (validaValor($valor) && validaValor($campo)) { // Si los campos son validos, se procede a actualizar los valores en la DB include 'conexion.php'; conectar(); // Actualizo el campo recibido por GET con la informacion que tambien hemos recibido pg_query("UPDATE cliente SET valor='{$valor}' WHERE id='{$campo}'") or die(pg_error()); desconectar(); } // No retorno ninguna respuesta
</tr> <tr class="entete"> <td>H. Pleines</td><td>H. Creuses</td><td>Total</td><td>Cout</td> </tr> </thead> <?php foreach ($months as $month) { $result = pg_query($db, 'select to_char(\'' . $month . '\'::timestamptz, \'Month YYYY\') as month_string;') or die('Erreur SQL sur recuperation des valeurs: ' . pg_error()); $row = pg_fetch_array($result); echo " <tr class=\"content\">\n <td class=\"libelle\">" . $row['month_string'] . "</td>"; foreach ($stats_ids as $id => $name) { $result = pg_query($db, 'select round(min_value::numeric, 1) as min_value, round(avg_value::numeric, 1) as avg_value, round(max_value::numeric, 1) as max_value from statistiques where id = \'' . $id . '\' and mois = \'' . $month . '\'') or die('Erreur SQL sur recuperation des valeurs: ' . pg_error()); $row = pg_fetch_array($result); echo " <td><div class=\"moy\">" . $row['avg_value'] . " °C</div><div class=\"delta\"><div class=\"max\">" . $row['max_value'] . " °C</div><div class=\"min\">" . $row['min_value'] . " °C</div></div></td>"; } $result = pg_query($db, 'select sum(hchc)/1000 as hchc, sum(hchp)/1000 as hchp, sum(hchc+hchp)/1000 as hc, round(sum(cout_hc+cout_hp+cout_abo)::numeric, 2) as cout from teleinfo_cout where date_trunc(\'month\', date) = \'' . $month . '\' group by date_trunc(\'month\', date)') or die('Erreur SQL sur recuperation des valeurs: ' . pg_error()); $row = pg_fetch_array($result); echo " <td>" . $row['hchc'] . "</td>\n <td>" . $row['hchp'] . "</td>\n <td>" . $row['hc'] . "</td>\n <td>" . $row['cout'] . "</td>\n\n </tr>"; } ?> </table> </div> <script type="text/javascript"> g = new Dygraph( // containing div document.getElementById("graphdiv"), '/php/get_data_csv.php?type=temp_full&sonde=all', {
public function _error() { return pg_error($this->link); }
public static function deleteVote($session_id, $user_id) { //id must be an integer $orig_sess_id = $session_id; $orig_user_id = $user_id; //get parsed integers $session_id = MyUtil::parseInt($session_id); $user_id = MyUtil::parseInt($user_id); //check if ($session_id == null || $user_id == null) { return MyUtil::fnOk(false, "Must be valid ids - session:{$orig_sess_id}, user:{$orig_user_id}", null); } $stm = "DELETE FROM " . self::$table_name . " WHERE session_id = {$session_id} AND user_id = {$user_id}"; $result = ConnDB::query_db($stm); if (!$result) { return MyUtil::fnOk(false, pg_error(), null); } return MyUtil::fnOk(true, "", $result); }
function db_query($rlt) { global $base, $debug, $sql_query, $conn; $sql_query = $rlt; //echo $rlt; // if (strlen($debug) > 0) { echo '<HR>'.$rlt; } ////////////////////////////// PostGre if ($base == 'pgsql') { if (strlen($debug) > 0) { $xxx = pg_query($rlt) or die($rlt . pg_email_erro($rlt)); } else { $xxx = pg_query($rlt) or die('Erro de base <BR>' . pg_email_erro($rlt)); } } ////////////////////////////// MySQL if ($base == 'mysqlPDO') { $xxx = $conn->query($rlt); //if (strlen($debug) > 0) { $xxx = mysql_query($rlt) or die(mysql_error() . '<BR>'.$rlt); } //else { $xxx = mysql_query($rlt) or die('Erro de base'); } } if ($base == 'mysql') { if (strlen($debug) > 0) { $xxx = mysql_query($rlt) or die(mysql_error() . '<BR>' . $rlt); } else { $xxx = mysql_query($rlt) or die('Erro de base'); } } if ($base == 'mssql') { $rlt = sql_convert($rlt); $sql_query = $rlt; if (strlen($debug) > 0) { $xxx = mssql_query($rlt) or die(pg_error() . '<BR>' . $rlt); } else { $xxx = mssql_query($rlt); } } if ($base == 'sybase') { $xxx = sybase_query($rlt) or die(pg_error() . '<BR>' . $rlt); } return $xxx; }