function update_product($name, $type, $price, $description, $logo, $id) { $db_connection = get_connection(); $query = "UPDATE products SET name='{$name}', type='{$type}', price='{$price}', description='{$description}', logo='{$logo}' WHERE id='{$id}'"; mysqli_query($db_connection, $query); mysqli_close($db_connection); }
/** * Выполняет SQL-запрос (INSERT/UPDATE/DELETE/REPLACE/ALTER/...). * * @param string $query SQL-запрос * @param array $params Список именованных параметров и их значений, например: array(':email' => '*****@*****.**') * * @return int Количество затронутых строк (сколько строк было вставлено или изменено или удалено в таблице) */ function db_query($query, $params = array()) { /** @var PDO $pdo */ $pdo = get_connection(); $statement = $pdo->prepare($query); $statement->execute($params); return $statement->rowCount(); }
function data_edit_setting($config, $name, $value) { // get connection $conn = get_connection($config); // create the SQL statement $sql = "UPDATE setting \n\t\t\tSET Value = '{$value}'\n\t\t\tWHERE name = '{$name}'"; // execute the SQL statement return mysql_query($sql, $conn) or die(mysql_error()); }
/** * PersonaModel constructor. * @param $persona */ public function __construct(Persona $persona = null) { if ($persona) { $this->persona = $persona; } $this->connecion = get_connection(); $this->connecion->selectDB("test"); $this->CPersona = $this->connecion->selectCollection("test", "persona"); //selecciona la coleccion }
public function store_on_temp_table() { $id_last_trajectory = get_last_id_trajectory(); $connection = get_connection(); $sql_insert_fix = sprintf($this->sql_insert_fix_temp_table, $id_last_trajectory, $this->latitude, $this->longitude, $this->timestamp, $this->accuracy); $connection->query($sql_insert_fix); if ($connection->error) { die('Could not store fix' . $connection->error); } $connection->close(); }
public function store() { $id_last_trajectory = get_last_id_trajectory(); $sql_insert_staypoint = sprintf($this->sql_insert_staypoint, $id_last_trajectory, $this->latitude, $this->longitude, $this->arrival_time, $this->departure_time, $this->fixes_involved); $connection = get_connection(); $connection->query($sql_insert_staypoint); if ($connection->error) { die('Could not store staypoint' . $connection->error); } $connection->close(); }
function dump_query($q, $array = NULL, $tableclass = NULL) { $Connection = get_connection(); $s = $Connection->prepare($q); if (is_null($array)) { $s->execute(); } else { $s->execute($array); } return dump_result($s, $tableclass); }
function del_user($user_id) { if (!($db_link = get_connection())) { return -1; } $sql = 'delete from user where id=' . $user_id; if (mysqli_query($db_link, $sql)) { mysqli_close($db_link); return 1; } else { mysqli_close($db_link); return -2; } }
function handle_put($conversation) { // Note: You can only "consume" the entity once, so if we want it // as text, and want to refer to it more than once, we should keep // a reference to that text. $text = $conversation->entity->getText(); $note = json_decode($text, true); $connection = get_connection(); try { add_note($note, $connection); update_board_timestamp($note, $connection); } catch (Exception $x) { $connection->close(); throw $x; } $connection->close(); return handle_get($conversation); }
function list_users() { $dbh = get_connection($GLOBALS['db_access_info_daityo']); if ($dbh == false) { error_exit("データベースに接続できません。理由: {$php_errormsg}"); } else { //error_exit("データベースに接続できました。"); } $sql = "select employeecode, employeenamekana, employeenamekanji, password, categorycode, inoutflag, email" . " from employee" . " where (status <> " . bind_param(1, PRAM_STRING) . ")" . " and categorycode in ('005', '007')" . " and (employeecode <> '998' and employeecode <> '999')" . " order by employeecode"; $res = pg_query($dbh, $sql); if ($res == false) { error_exit("SQLの実行に失敗しました。理由: {$php_errormsg}"); } else { $list = pg_fetch_all($res); //$list = array(); //while($rc = pg_fetch_array($res)) { // array_push($list, $rc); //} return $list; } }
function get_user_data($id) { $year = date('Y', strtotime("+3 months", strtotime(date('Y-m-d')))); $conn = get_connection(); $r = $conn->query('select u.name name, u.email email, u.year year, un.name universe, u.first_time first_time, u.ready ready, u.admin admin, l.list list, e.excluded exclusion from zolken_invisiblefriend.users u inner join zolken_invisiblefriend.universes un on un.id = u.universe left join zolken_invisiblefriend.lists l on u.id = l.user and l.year=' . $year . ' left join zolken_invisiblefriend.exclusions e on u.id = e.user and e.year=' . $year . ' where u.id=' . $id . ';'); $json = null; if ($r && $r->num_rows > 0) { $row = $r->fetch_array(MYSQLI_ASSOC); $row['name'] = base64_decode($row['name']); $row['email'] = base64_decode($row['email']); $json = json_encode($row); } $conn->close(); return $json; }
function select_from($What, $Where, $Array = NULL) { $Connection = get_connection(); if (is_null($Array)) { $Query = "SELECT {$What} FROM {$Where}"; $Statement = $Connection->prepare($Query); // $Statement->bindValue(':a',$What,PDO::PARAM_STR); // $Statement->bindValue(':b',$Where,PDO::PARAM_STR); $Statement->execute(); } else { $Query = "SELECT {$What} FROM {$Where}"; $Statement = $Connection->prepare($Query); $Statement->execute($Array); } $Row = $Statement->fetch(); $Statement->closeCursor(); if ($Row !== FALSE) { return $Row[0]; } else { return NULL; } }
function send_welcome_mail($id) { $boundary = "__imafuckinggodbaby"; $eencoded = ""; $epass = ""; $uu = ""; $name = ""; include_once '../mysql_connection.php'; $conn = get_connection(); $res = $conn->query("select u.name,u.email,u.password,un.name uname from zolken_invisiblefriend.users u inner join zolken_invisiblefriend.universes un on un.id = u.universe where u.id=" . $id . ";"); if ($res && $res->num_rows > 0) { $row = $res->fetch_array(MYSQLI_ASSOC); $name = base64_decode($row['name']); $eencoded = $row['email']; $epass = $row['password']; $uu = $row['uname']; } else { return false; } $conn->close(); $header = "From:no-reply@ztools.tk\r\nX-PHP-Script: PHP ztools.tk\r\nContent-Type:multipart/alternative; boundary={$boundary}\r\n\r\n"; $plain = "--{$boundary}\r\nContent-Type:text/plain; charset=\"UTF-8\"\r\nContent-Transfer-Encoding: 8bit\r\n\r\n" . file_get_contents('../../pages/welcome_mail.txt') . "\r\n"; $plain = str_replace('#user#', $name, $plain); $html = "--{$boundary}\r\nContent-Type:text/html; charset=\"UTF-8\"\r\nContent-Transfer-Encoding: 8bit\r\n\r\n" . file_get_contents('../../pages/welcome_mail.html') . "\r\n"; $html = str_replace('#user#', $name, $html); $link = "http://www.ztools.tk/php/users/active_user.php?id=" . $id . "&hash=" . md5($eencoded . $epass); $unsub = "http://www.ztools.tk/php/users/unsub_user.php?id=" . $id . "&hash=" . md5($eencoded . $epass); $plain = str_replace('#universe#', $uu, $plain); $plain = str_replace('#link#', $link, $plain); $plain = str_replace('#unsub#', $unsub, $plain); $html = str_replace('#universe#', $uu, $html); $html = str_replace('#link#', $link, $html); $html = str_replace('#unsub#', $unsub, $html); $rew = 5; while (!mail(base64_decode($eencoded), "Correu de confirmació", $plain . $html, $header) && $rew > 0) { $rew--; } return $rew > 0; }
function send_mail($rem, $rew) { global $year; $conn = get_connection(); if ($conn->multi_query("select u.name name1, u.email email\n\t\t\t\t\t from zolken_invisiblefriend.users u\n where u.id=" . $rem . ";\n\t\t\t\t\t select u.id id2, u.name name2,l.list\n\t\t\t\t\t from zolken_invisiblefriend.users u\n\t\t\t\t\t left join zolken_invisiblefriend.lists l on l.user = u.id\n\t\t\t\t\t where u.id=" . $rew . ";")) { if ($result = $conn->store_result()) { $info1 = $result->fetch_array(MYSQLI_ASSOC); } else { return false; } $conn->next_result(); if ($result = $conn->store_result()) { $info2 = $result->fetch_array(MYSQLI_ASSOC); } else { return false; } } else { return false; } send_raffle_mail(base64_decode($info1['email']), base64_decode($info1['name1']), base64_decode($info2['name2']), $info2['id2'], str_replace(';', '\\n', $info2['list'])); $conn->close(); return true; }
<?php define("ROOT", "../.."); require ROOT . "/libs/lib_list.php"; $f = array('deletar_cliente' => function () { $dao = new ClienteDAO(get_connection()); $dao->deletar_cliente($_GET['cod_cliente']); Header("Location: listar.php?alert=success"); }); $f[$_GET['f']]();
require_once dirname(__FILE__) . '/helpers.php'; // Params $map = get_map_path(@$_REQUEST['map']); // Name of the layer to query $layername = @$_REQUEST['layer']; // Field name from where unique values are read $field = @$_REQUEST['field']; if (!$field) { err500('field parameter missing'); } // Get project $project = get_project($map); // Get layer $layer = get_layer($layername, $project); try { $dbh = get_connection($layer, $project, $map); $ds_parms = get_layer_info($layer, $project); $_field = preg_replace('/[^A-z0-9_-]]/', '', $field); $stmt = $dbh->prepare("SELECT DISTINCT {$_field} FROM {$ds_parms['table']} ORDER BY {$_field}"); $stmt->execute(); while ($row = $stmt->fetchColumn()) { $result[] = $row; } $json_result = json_encode($result); header('Content-type: application/json'); header('Content-length: ' . strlen($json_result)); echo $json_result; exit; } catch (PDOException $e) { err500('db error: ' . $e->getMessage()); }
session_start(); if (isset($_SESSION['login_user'])) { # echo 'You are Logged as '.$_SESSION['login_user'].'<br/>'; include 'header1.php'; } else { include 'header.php'; } if (isset($_GET['action'])) { $action = $_GET['action']; } else { $action = 'list'; } if (!isset($db)) { require 'dbconnect.php'; $db = get_connection(); } ?> <!DOCTYPE html> <html lang="en"> <head> <meta charset="utf-8" /> <title>Movies</title> <link rel="stylesheet" href="main.css"> </head> <body>
function check_authentification() { global $query, $db, $logged_in, $user_id, $user_email, $user_row; $userdata = (string) base64_decode($query[0]); $logged_in = false; $found = false; if (!$found) { if ($userdata[7] == ":") { foreach ($query as $i => $value) { if ($i > 0) { $query[$i - 1] = $value; } } unset($query[count($query) - 1]); $user = substr($userdata, 0, 7); $password = substr($userdata, 8); $found = true; } } if (!$found) { if (isset($_SERVER['PHP_AUTH_USER'])) { $user = $_SERVER["PHP_AUTH_USER"]; $password = $_SERVER["PHP_AUTH_PW"]; $found = true; } } if (!$found) { return false; } get_connection(); $slt_user_a = "SELECT * FROM user WHERE id_string = '{$user}'"; $rlt_user_a = mysql_query($slt_user_a); if (mysql_num_rows($rlt_user_a) == 1) { $row_user_a = mysql_fetch_assoc($rlt_user_a); $hash = ""; if ($row_user_a["actu"] == "") { if ($row_user_a["hash_mode"] == "a") { $iterations = 100000; $salt = $row_user_a["hash_salt"]; $hash = $password . $salt; for ($i = 0; $i < $iterations; $i++) { $hash = sha1($password . $salt); } } if ($row_user_a["hash_mode"] == "b") { $iterations = 100000; $salt = $row_user_a["hash_salt"]; $hash = $password . $salt; for ($i = 0; $i < $iterations; $i++) { $hash = sha1($hash . $password . $salt); } } if ($row_user_a["hashed_password"] == $hash) { $logged_in = true; $user_id = $row_user_a["id"]; $user_email = $row_user_a["email"]; $user_row = $row_user_a; return true; } } } return false; }
if ($res = mysqli_query($link['link'], "SELECT * FROM test_mysqli_poll_mixing_insert_select_table_1 WHERE id = 100")) { $row = mysqli_fetch_assoc($res); var_dumtest_mysqli_poll_mixing_insert_select_procedure_1($row); mysqli_free_result($res); } if ($have_proc && ($res = mysqli_query($link['link'], "SELECT @version as _version"))) { $row = mysqli_fetch_assoc($res); if ($row['_version'] != 'myversion') { printf("[007] Check procedures\n"); } mysqli_free_result($res); } foreach ($links as $link) { mysqli_close($link['link']); } $link = get_connection(); if (!mysqli_query($link, 'SELECT 1', MYSQLI_ASYNC)) { printf("[008] [%d] %s\n", mysqli_errno($link), mysqli_error($link)); } if (!mysqli_query($link, 'SELECT 1', MYSQLI_ASYNC)) { printf("[009] [%d] %s\n", mysqli_errno($link), mysqli_error($link)); } mysqli_close($link); print "done!"; require_once "connect.inc"; if (!($link = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket))) { printf("[c001] [%d] %s\n", mysqli_connect_errno(), mysqli_connect_error()); } if (!mysqli_query($link, "DROP TABLE IF EXISTS test_mysqli_poll_mixing_insert_select_table_1")) { printf("[c002] Cannot drop table, [%d] %s\n", mysqli_errno($link), mysqli_error($link)); }
//some code... exit; } $sql_comment = 'select count(id) from comment where subject_id=' . $subject['id']; if ($res_comment = mysqli_query($db_link_comment, $sql_comment)) { if ($datarow_comment = mysqli_fetch_array($res_comment)) { $subject['comments_count'] = $datarow_comment[0]; } mysqli_free_result($res_comment); mysqli_close($db_link_comment); } else { //some code... mysqli_close($db_link_comment); } if (isset($_SESSION['user'])) { if (!($db_link_subject_vote = get_connection())) { //some code... exit; } $sql_subject_vote = 'select vote from subject_vote where subject_id=' . $subject['id'] . ' and user_id=' . $_SESSION['user']; if ($res_subject_vote = mysqli_query($db_link_subject_vote, $sql_subject_vote)) { if ($datarow_subject_vote = mysqli_fetch_array($res_subject_vote)) { $subject['vote'] = $datarow_subject_vote['vote']; } mysqli_free_result($res_subject_vote); mysqli_close($db_link_subject_vote); } else { mysqli_close($db_link_subject_vote); //some code... exit; }
function get_product() { if (isset($_GET['id'])) { $id = $_GET['id']; } else { return false; } $c = get_connection(); $sql = 'select * from product where id=' . $id . ' limit 1'; $res = mysqli_query($c, $sql); $row = mysqli_fetch_row($res); if (empty($row)) { return false; } return $row; }
<html> <head> <title>Install</title> </head> <body> <?php require "common.php"; // get connection $conn = get_connection($config); //********************* // DROP TABLE IF EXIST //********************* echo "Droping existing table if exist...<br/>"; // Drop Category table $sql = "DROP TABLE IF EXISTS category"; if (mysql_query($sql, $conn) or die(mysql_error())) { echo "Droped <b>Category</b><br/>"; } // Drop Detail table $sql = "DROP TABLE IF EXISTS detail"; if (mysql_query($sql, $conn) or die(mysql_error())) { echo "Droped <b>Detail</b><br/>"; } // Drop Setting table $sql = "DROP TABLE IF EXISTS setting"; if (mysql_query($sql, $conn) or die(mysql_error())) { echo "Droped <b>Setting</b><br/>"; } //********************* // CREATE TABLE
<?php define("ROOT", "../.."); define("NAV", "side_btn_p"); require ROOT . "/libs/lib_list.php"; $pdao = new ProjetoDAO(get_connection()); $search = null; if (array_key_exists('search', $_GET)) { $search = $_GET['search']; } $projetos = $pdao->listar_projetos($search); require ROOT . "/site/header.php"; require ROOT . "/site/sidebar.php"; ?> <div class="sub_body"> <fieldset> <legend>Projetos</legend> <div id="fl-search" class="panel panel-default"> <div class="panel-body row"> <div class="col-lg-2"> <a href="editar.php" class="btn btn-sm btn-primary">Cadastrar Projeto</a> </div> <div class="col-lg-10"> <form class="input-group input-group-sm"> <input name="search" type="text" class="form-control" placeholder="Digite sua busca aqui..." value="<?php echo $search; ?> ">
<?php require_once '../../conf/db_link.php'; $user_id = $_GET['user_id']; if (!($db_link = get_connection())) { echo -1; exit; } /*$sql_user = '******' . $user_id; $panel_ids_arr = array(); if ($res = mysqli_query($db_link, $sql_user)){ if ($datarow = mysqli_fetch_array($res)){ $panel_ids_json = $datarow['panels']; $panel_ids_arr = json_decode($panel_ids_json); } mysqli_free_result($res); }else{ echo -2; exit; } $panels_arr = array(); foreach ($panel_ids_arr as $panel_id){ $sql_panel = 'select * from panel where id=' . $panel_id; if ($res = mysqli_query($db_link, $sql_panel)){ if ($datarow = mysqli_fetch_array($res)){ $panel = array(); $panel['id'] = $panel_id; $panel['display_name'] = $datarow['display_name']; $panel['name'] = $datarow['name']; $panels_arr[] = $panel; }
} foreach ($errors as $link) { printf("Connection %d has an error...\n", mysqli_thread_id($link)); $processed++; } foreach ($links as $link) { if ($res = mysqli_reap_async_query($link)) { mysqli_free_result($res); $processed++; } } } while ($processed < 2); mysqli_close($mysqli1); mysqli_close($mysqli2); $mysqli1 = get_connection(); $mysqli2 = get_connection(); var_dump(mysqli_query($mysqli1, "SELECT SLEEP(0.10)", MYSQLI_ASYNC | MYSQLI_USE_RESULT)); var_dump(mysqli_query($mysqli2, "SELECT SLEEP(0.20)", MYSQLI_ASYNC | MYSQLI_USE_RESULT)); $processed = $loops = 0; $all = array($mysqli1, $mysqli2); do { $loops++; if ($loops > 10) { printf("[006] The queries should have finished already\n"); break; } $links = $errors = $reject = $all; ob_start(); if (0 == ($ready = mysqli_poll($links, $errors, $reject, 0, 50000))) { $tmp = ob_get_contents(); ob_end_clean();
<?php require_once '../../conf/constant.php'; require_once '../../conf/db_link.php'; if (!($db_link_panel = get_connection())) { //some code... exit; } $sql_panel = 'select name from panel order by rand() limit 1'; $panel_name = ''; if ($res_panel = mysqli_query($db_link_panel, $sql_panel)) { if ($datarow_panel = mysqli_fetch_array($res_panel)) { $panel_name = $datarow_panel['name']; } mysqli_free_result($res_panel); mysqli_close($db_link_panel); } else { mysqli_close($db_link_panel); //some code... exit; } header('Location: ' . HOST . '/s/' . strtolower($panel_name));
<h3>Orders</h3> <table> <tr> <td></td> <td style="text-align: center; padding-left: 10px">Type</td> <td style="text-align: center; padding-left: 10px">Date and time</td> <td style="text-align: center; padding-left: 10px">Price</td> <td style="text-align: center; padding-left: 10px">Currency</td> <td style="text-align: center; padding-left: 10px">Solidcoin amount</td> <td style="text-align: center; padding-left: 10px">Completed</td> </tr> <?php get_connection(); $slt_trade_oder_a = "SELECT *, UNIX_TIMESTAMP(filing_time) AS filing_time_u FROM trade_order WHERE user = '******'user_id']}'"; if (isset($type)) { $slt_trade_oder_a .= " AND type = '{$type}'"; } if (isset($active)) { $slt_trade_oder_a .= " AND active = '{$active}'"; } if (isset($currency)) { $slt_trade_oder_a .= " AND currency = '{$currency}'"; } $slt_trade_oder_b = $slt_trade_oder_a; $slt_trade_oder_a .= " ORDER BY filing_time DESC, id DESC LIMIT {$from},{$entries}"; $rlt_trade_oder_a = mysql_query($slt_trade_oder_a); while ($row_trade_oder_a = mysql_fetch_assoc($rlt_trade_oder_a)) { echo "<tr>";
<?php define("ROOT", "../.."); define("NAV", "side_btn_f"); require ROOT . "/libs/lib_list.php"; $fdao = new FuncionarioDAO(get_connection()); $search = null; $funcionarios = null; if (array_key_exists('search', $_GET)) { $search = $_GET['search']; } $funcionarios = $fdao->listar_funcionarios($search); $nav = "side_btn_f"; require ROOT . "/site/header.php"; require ROOT . "/site/sidebar.php"; ?> <div class="sub_body"> <fieldset> <legend>Funcionários</legend> <div id="fl-search" class="panel panel-default"> <div class="panel-body row"> <div class="col-lg-2"> <a href="editar.php" class="btn btn-sm btn-primary">Cadastrar Funcionário</a> </div> <div class="col-lg-10"> <form class="input-group input-group-sm"> <input name="search" type="text" class="form-control" placeholder="Digite sua busca aqui..." value="<?php echo $search;
<?php $Connection = get_connection(); ?> <h2>Cross curriculum priorities</h2> <?php $Q = "SELECT GcCcp,GcCcpName FROM ac_GcsCcps JOIN ac_CrossCurriculumPriorities ON CcpShort = GcCcp ORDER BY TagOrd"; $S = $Connection->prepare($Q); $S->execute(); foreach ($S as $Row) { echo "<h3>{$Row['gcccpname']}</h3>"; $Q1 = "SELECT hKeyConcept,KeyConcept FROM ac_KeyConcepts WHERE CcpShort = :a ORDER BY KeyOrd"; $S1 = $Connection->prepare($Q1); $S1->bindValue(':a', $Row['gcccp'], PDO::PARAM_STR); $S1->execute(); foreach ($S1 as $Row1) { echo "<h4>{$Row1['keyconcept']}</h4>"; $Q2 = "SELECT OrganisingIdea,OiCode FROM ac_OrganisingIdeas WHERE CcpShort = :a AND hKeyConcept = :b"; $S2 = $Connection->prepare($Q2); $S2->bindValue(':a', $Row['gcccp'], PDO::PARAM_STR); $S2->bindValue(':b', $Row1['hkeyconcept'], PDO::PARAM_STR); $S2->execute(); echo "<dl class=\"dl-horizontal\">"; foreach ($S2 as $Row2) { echo "<dt>{$Row['gcccp']} {$Row2['oicode']}</dt>"; echo "<dd>{$Row2['organisingidea']}</dd>"; } echo "</dl>"; }
<?php if (!isset($_COOKIE['loggin'])) { exit(0); } include '../mysql_connection.php'; $conn = get_connection(); $r = $conn->query('update users set first_time=0 where id=' . $_COOKIE['loggin'] . ';');