function getListComposersDb() { $db = new MysqliDb(HOST, USER, PASSWORD, DBNAME); $query = "SELECT * FROM composers"; $composers = $db->rawQuery($query); return $composers; }
function GET() { $db = new MysqliDb($this->config["host"], $this->config["user"], $this->config["pass"], $this->config["base"]); $results = $db->get('VIP'); if (!empty($results) && count($results) > 0) { SimplestView::render('index', array("results" => $results)); } }
echo json_encode(true); } else { echo json_encode(false); } } function update($item) { $db = new MysqliDb(); $decoded = json_decode($item); $db->where('revista_id', $decoded->revista_id); $data = array('nombre' => $decoded->nombre, 'link' => $decoded->link); if ($db->update('revistas', $data)) {
function GET($matches) { if ($matches[1]) { $db = new MysqliDb($this->config["host"], $this->config["user"], $this->config["pass"], $this->config["base"]); $results = $db->where('idphoto', $matches[1])->get('photo', 1); if (!empty($results) && count($results) > 0) { header("Content-Type: image/jpg"); header("Content-Length: " . strlen($results[0]["contenu"])); echo $results[0]["contenu"]; } } }
echo json_encode(true); } else { echo json_encode(false); } } /** * esta funcion me retorna un cliente filtrando x email * @param $email */ function update($item) { $db = new MysqliDb(); $decoded = json_decode($item);
function insertCompositionsOnDB() { $composers = getListComposers(); foreach ($composers as $index => $composer) { $slug = getSlugComposer($composer); $relevance = $index + 1; $db = new MysqliDb(HOST, USER, PASSWORD, DBNAME); $query = "INSERT INTO `composers`(`slug`,`name`,`relevance`)"; $query .= " VALUES ('" . $slug . "','" . $composer . "','" . $relevance . "');"; echo $query . PHP_EOL; $db->rawQuery($query); } }
function order_paid() { require_once './submodules/php-mysqli-database-class/MysqliDb.php'; require './includes/config.php'; $db = new MysqliDb($db_host, $db_user, $db_pass, $db_name); $payid = $_GET['out_trade_no']; $aPayId = explode('_', $payid); $mtrid = $aPayId[1]; $params = json_encode($_GET); //验证是否已经支付过 $db->where("mtr_id = '{$mtrid}'")->get('mark_trafficpolice_reward'); if ($db->count == 0) { $aNew = array('mtr_id' => $mtrid, 'pay_id' => $payid, 'pay_success' => 1, 'pay_money' => $_GET['total_fee'], 'pay_date' => $_GET['gmt_payment'], 'pay_params' => $params, 'created_date' => $db->now()); $id = $db->insert('mark_trafficpolice_reward', $aNew); //给用户增加余额 $sql = "SELECT mt.user_id,u.user_money FROM `mark_trafficpolice` mt\n LEFT JOIN mark_trafficpolice_received mtr ON mt.id=mtr.mt_id\n LEFT JOIN users u ON u.user_id=mt.user_id\n WHERE mtr.id= '{$mtrid}'"; $aUser = $db->rawQuery($sql); if ($db->count) { $aUpdate = array('user_money' => $aUser[0]['user_money'] + $_GET['total_fee'], 'updated_date' => $db->now()); $db->where('user_id', $aUser[0]['user_id']); $db->update('users', $aUpdate); } } else { echo "already rewarded"; } }
public static function getInstance($dbKey = 'DB') { if (array_key_exists($dbKey, self::$db)) { return self::$db[$dbKey]; } else { $newdb = new MysqliDb($dbKey); if ($newdb->connect()) { self::$db[$dbKey] = $newdb; return $newdb; } else { return false; } } }
function insertComposersOnDB() { $db = new MysqliDb(HOST, USER, PASSWORD, DBNAME); $composers = getListComposersDb(); foreach ($composers as $index => $composer) { $compositions = extractCompositionsFromSearchHtmls($composer['name']); foreach ($compositions as $composition) { echo "Inserting " . $composition . "..." . PHP_EOL; $relevance = $index + 1; $query = "INSERT INTO `compositions`(`composer_id`,`name`,`relevance`)"; $query .= " VALUES ('" . $composer['id'] . "','" . escapeSingleQuote($composition) . "','" . $relevance . "');"; $db->rawQuery($query); } } }
function showzx() { $zid = req('zid'); $start = req('start', 0); $perpage = req('perpage', 0); if ($start < 0) { $start = 0; } if (empty($perpage)) { $perpage = 30; } if (empty($zid)) { showjson('zid_not_exist'); } $db = MysqliDb::getInstance(); $data = $db->rawQueryOne("SELECT z.*, u.username FROM zixun z LEFT JOIN users u ON z.uid=u.uid WHERE z.zid='{$zid}'"); if ($db->count > 0) { $db->where("zid", $zid); $stats = $db->getOne("comment", "count(*) as cnt"); $data['total'] = $stats['cnt']; //if($start>=$data['total']) $start=0; $comment = $db->rawQuery("SELECT c.*,s.username FROM comment c LEFT JOIN users s ON c.uid=s.uid WHERE c.zid='{$zid}' ORDER BY c.cid LIMIT {$start},{$perpage}"); $data['count'] = $db->count; $data['comment'] = $comment; showjson('do_success', 0, array("zixun" => $data)); } showjson('show_error'); }
/** * Pagination wraper to get() * * @access public * @param int $page Page number * @param array|string $fields Array or coma separated list of fields to fetch * @return array */ private function paginate($page, $fields = null) { $offset = $this->pageLimit * ($page - 1); $this->db->withTotalCount(); $results = $this->get(array($this->pageLimit, $offset), $fields); $this->totalPages = round($this->db->totalCount / $this->pageLimit); return $results; }
/** * @param string $host * @param string $username * @param string $password * @param string $db * @param int $port */ public function __construct($host, $username, $password, $db, $port = NULL) { if ($port == NULL) { $port = ini_get('mysqli.default_port'); } $this->_mysqli = new mysqli($host, $username, $password, $db, $port) or die('There was a problem connecting to the database'); $this->_mysqli->set_charset('utf8'); self::$_instance = $this; }
function saveSlider($slider) { $db = new MysqliDb(); $item_decoded = $slider; // $fotos_decoded = json_decode($producto->fotos); $db->where('oferta_id', $item_decoded->slider_id); $data = array('producto_id' => $item_decoded->producto_id, 'precio' => $item_decoded->precio, 'descripcion' => $item_decoded->descripcion, 'imagen' => $item_decoded->imagen, 'titulo' => $item_decoded->titulo); $results = $db->update('ofertas', $data); $res = ['status' => 1, 'results' => 0]; echo json_encode($results); if ($results) { $res["results"] = $results; echo json_encode($res); } else { $res->status = 0; echo $res; } }
public function __construct() { /** @var array $db */ include_once 'config.php'; require_once 'PHP-MySQLi-Database-Class-master/MysqliDb.php'; new MysqliDb($db); $this->db_instance = MysqliDb::getInstance(); $this->db_config = $db; }
/** * constructor * * @param string $type tipo de datamanager a ser incializado * * inicializa o objeto de log e de bd * inicializa o vetor de dados nulo de acordo com o tipo */ function __construct($type) { $this->db = MysqliDb::getInstance(); $this->log = Log::getInstance(); //tipo de dado valido pra iniciar if (array_key_exists($type, $this->_validFields)) { $this->type = $type; foreach ($this->_validFields[$this->type] as $key => $value) { $this->setField($key, null); } } }
public function routeToCrm($host, $username, $password, $databaseName) { if (isset($_COOKIE['username'])) { $user = $_COOKIE['username']; } if (isset($_COOKIE['mdp'])) { //Récupération du mot de passe stocké $db = new MysqliDb($host, $username, $password, $databaseName); $db->where("user_name", $user); $users = $db->getOne("users"); $pwd = $users['user_hash']; // Création du mot de passe hashé // $mdp = crypt(strtolower($_COOKIE['mdp']),$pwd); $mdp = $_COOKIE['mdp']; } // Login au CRM $url = "http://localhost/mysite/crm74/service/v4_1/soap.php?wsdl"; require_once "../crm74/include/nusoap/lib/nusoap.php"; //retrieve WSDL $client = new nusoap_client($url, 'wsdl'); $proxy = $client->getProxy(); //Affichage des erreurs $err = $client->getError(); if ($err) { echo '<h2>Erreur du constructeur</h2><pre>' . $err . '</pre>'; echo '<h2>Debug</h2><pre>' . htmlspecialchars($client->getDebug(), ENT_QUOTES) . '</pre>'; exit; } // login ---------------------------------------------------- $login_parameters = array('user_auth' => array('user_name' => $user, 'password' => $mdp, 'version' => '1'), 'application_name' => 'SugarTest'); $login_result = $client->call('login', $login_parameters); echo '<pre>'; //get session id $session_id = $login_result['id']; $result = $proxy->seamless_login($session_id); // Ouverture de la session SuiteCRM header("Location: http://localhost/mysite/crm74/index.php?module=Administration&action=index&MSID={$session_id}"); }
/** * Created by PhpStorm. * User: André * Date: 01/04/2015 * Time: 13:57 */ function buildOutput($data, $debug = false) { $log = Log::getInstance(); $db = MysqliDb::getInstance(); $output = array(); if ($log->countErrors() > 0) { $errors = $log->getErrors(); } $output = $data; if (isset($errors) && sizeof($errors) > 0) { $output['_ERROR_'] = $errors; } if ($debug == 'true') { $output['_DEBUG_'] = $log->getLogs(); } echo json_encode($output, JSON_PRETTY_PRINT); }
function login() { $password = req('password'); $username = req('username'); $db = MysqliDb::getInstance(); if ($password && $username) { $db->where('username', $username); if ($user = $db->getOne('users')) { if ($user['password'] == $password) { $auth = authcode("{$user['password']}\t{$user['uid']}", 'ENCODE'); showjson('do_success', 0, array("auth" => rawurlencode($auth))); } showjson('password_error'); } } showjson('login_error'); }
private function processHasOneWith() { if (count($this->_with) == 0) { return; } foreach ($this->_with as $name => $opts) { $relationType = strtolower($opts[0]); $modelName = $opts[1]; $key = null; if (isset($opts[2])) { $key = $opts[2]; } if ($relationType == 'hasone') { $this->db->setQueryOption("MYSQLI_NESTJOIN"); $this->join($modelName, $key); } } }
function checkauth() { global $_SGLOBAL; $auth = req('auth'); if ($auth) { $db = MysqliDb::getInstance(); @(list($password, $uid) = explode("\t", authcode($auth, 'DECODE'))); $_SGLOBAL['uid'] = intval($uid); if ($password && $_SGLOBAL['uid']) { $db->where('uid', $_SGLOBAL['uid']); if ($user = $db->getOne('users')) { if ($user['password'] == $password) { $_SGLOBAL['usertype'] = $user['usertype']; $_SGLOBAL['username'] = $user['username']; return; } } } } showjson('to_login'); }
function comment() { global $_SGLOBAL; checkauth(); //验证登陆 $op = req('op'); $db = MysqliDb::getInstance(); if ($op == 'add') { $setarr = array('uid' => $_SGLOBAL['uid']); $setarr['message'] = req('message'); $setarr['zid'] = req('zid', 0); if ($setarr['message'] && $setarr['zid']) { $id = $db->insert('comment', $setarr); //插入数据 if ($id) { showjson('do_success', 0, array("cid" => $id)); } showjson('submit_comment_error'); } showjson('zid_or_message_can_not_empty'); } elseif ($op == 'del') { $cid = req('cid', 0); if (empty($cid)) { showjson('non_normal_operation'); } $db->where('cid', $cid); if ($_SGLOBAL['usertype'] == 1) { //是否管理员 } else { $db->where('uid', $_SGLOBAL['uid']); } $result = $db->delete('comment'); //删除评论 if ($result) { showjson('do_success', 0); } showjson('comment_not_exist'); } }
<?php require "../db.php"; $adminPage = true; require "../../src/secure.php"; $db = new MysqliDb(DB_HOST, DB_USERNAME, DB_PASSWORD, DB_DATABASE); if (empty($_POST['desc']) || empty($_POST['surface']) || empty($_POST['parking']) || empty($_POST['facilities'])) { header("Location: " . $baseurl . "admin/translate/?error=true&id=" . $_POST['id'] . "&lang=" . $_POST['lang']); exit; } $id = $_POST['id']; $lang = $_POST['lang']; $facilities = $_POST['facilities']; $lighting = $_POST['lighting']; $surface = $_POST['surface']; $transit = $_POST['transit']; $parking = $_POST['parking']; $desc = rawurlencode($_POST['desc']); $hours = $_POST['hours']; $loopcount = $_POST['loopcount']; $attractioncount = $_POST['attractioncount']; $postaction = $_POST['postaction']; $trans_id = $_POST['trans_id']; $attractions = array(); $i = 0; while ($i <= $attractioncount) { array_push($attractions, rawurlencode($_POST['attraction' . $i])); $i++; } $loops = array(); $i = 1;
/** * @param string $host * @param string $username * @param string $password * @param string $db * @param int $port */ public function __construct($port = NULL) { if ($port == NULL) { $this->port = ini_get('mysqli.default_port'); } else { $this->port = $port; } $this->connect(); $this->setPrefix(); self::$_instance = $this; }
/** * Method to set a prefix * * @param string $prefix Contains a tableprefix */ public function setPrefix($prefix = '') { self::$prefix = $prefix; return $this; }
<li> <a href="about.html">About</a> </li> </ul> </div> <!-- /#sidebar-wrapper --> <!-- Page Content --> <div id="page-content-wrapper"> <div class="container-fluid"> <div class="row"> <div class="col-lg-12"> <h1>Previous games</h1> <?php date_default_timezone_set('UTC'); $db = new MysqliDb('localhost', 'root', '', 'golf-cards'); $cols = array("friendly_name", "max_round", "game_id "); $result = $db->get("game_names", null, $cols); ?> <table class="table table-striped"> <thead> <tr> <th>Game Name</th> <th>Highest round played</th> <th>Date game was played</th> </tr> </thead> <tbody> <?php for ($i = 0; $i < count($result); $i++) { ?>
<?php require_once '/API/MysqliDb.php'; $db = new MysqliDb('localhost', 'root', '', 'dnd'); $db->rawQuery("\n\tCREATE TABLE IF NOT EXISTS Users \n\t(\n\t\tid INT NOT NULL AUTO_INCREMENT,\t\t\t\t\t\t\t# user id\n\t\tpasswod VARCHAR(60) NOT NULL,\t\t\t\t\t\t\t# user password\n\t\tadmin INT(1) NOT NULL DEFAULT 0,\t\t\t\t\t\t# rights(ie. admin, user, etc....)\n\t\tactive BOOLEAN,\t\t\t\t\t\t\t\t\t\t\t# activly logged in\n\t\tfName VARCHAR(255) CHARACTER SET utf8 NOT NULL,\t\t\t# first name\n\t\tlName VARCHAR(255) CHARACTER SET utf8 NOT NULL,\t\t\t# last name \n\t\tphone VARCHAR(16),\t\t\t\t\t\t\t\t\t\t# phone number\n\t\temail VARCHAR(128) CHARACTER SET utf8 NOT NULL UNIQUE,\t# email address\n\t\tintro VARCHAR(1024) CHARACTER SET utf8,\t\t\t\t\t# self-introduction\n\t\tpicture VARCHAR(256),\t\t\t\t\t\t\t\t\t# picture path\n\t\tcreatedAt DATETIME,\t\t\t\t\t\t\t\t\t\t# creation datetime\n\t\texpires DATETIME,\t\t\t\t\t\t\t\t\t\t# expiry datetime\n\t\tPRIMARY KEY (id),\n\t\tCONSTRAINT fullName UNIQUE (fName, lName)\n\t) ENGINE=InnoDB;\n\t"); $db->rawQuery("\n\tCREATE TABLE IF NOT EXISTS Posts \n\t(\n\t\tid INT NOT NULL AUTO_INCREMENT,\t\t\t\t\t\t\t# user id\n\t\tuID INT NOT NULL,\n\t\tmessage TEXT NOT NULL,\t\t\t\t\t\t\t\t\t# picture path\n\t\tpostedAt DATETIME,\t\t\t\t\t\t\t\t\t\t# creation datetime\n\t\teditedAt DATETIME,\t\t\t\t\t\t\t\t\t\t# expiry datetime\n\t\tPRIMARY KEY (id),\n\t\tFOREIGN KEY (uID) REFERENCES Users(id) \n\t) ENGINE=InnoDB;\n\t"); $db->rawQuery("\n\tCREATE TABLE IF NOT EXISTS CharTypes \n\t(\n\t\tcharID INT NOT NULL AUTO_INCREMENT,\t\t\t\t\t\t# character id\n\t\tcharType VARCHAR(255) NOT NULL,\t\t\t\t\t\t\t\t# character sheet type\n\t\tPRIMARY KEY (charID, charType) \n\t) ENGINE=InnoDB;\n\t"); $db->rawQuery("\n\tCREATE TABLE IF NOT EXISTS UserChars\n\t(\n\t\tchariD INT NOT NULL,\t\t\t\t\t\t\t\t\t# character id\n\t\tuID INT NOT NULL,\t\t\t\t\t\t\t\t\t\t# user id\n\t\tPRIMARY KEY (charID, uID),\n\t\tFOREIGN KEY (charID) REFERENCES CharTypes(charID),\n\t\tFOREIGN KEY (uID) REFERENCES Users(id) \n\t) ENGINE=InnoDB;\n\t");
<?php session_start(); require_once '/php/API/MysqliDb.php'; require_once '/php/Objects/User.class.php'; $db = new MysqliDb('localhost', 'root', '', 'dnd'); echo '<!DOCTYPE html>' . "\n"; echo '<html lang="en">' . "\n"; echo ' <head>' . "\n"; echo ' <meta charset="utf-8">' . "\n"; echo ' <title>Log In</title>' . "\n"; echo ' <link rel="stylesheet" type="text/css" href="css/login_form.css">' . "\n"; echo ' </head>' . "\n"; echo ' <body>' . "\n"; if (isset($_POST['submitted'])) { $submited = $_POST['submitted']; $name = explode(" ", $_POST['name']); $pass = $_POST['pass']; if (isset($pass) && !empty($pass)) { if (isset($name) && !empty($name[0])) { if (count($name) >= 1 && count($name) <= 2) { if (count($name) > 1) { $db->where('fName', $name[0]); $db->where('lName', $name[1]); } else { $db->where('fName', $name); $db->orWhere('lName', $name); } $user = $db->getOne("Users"); $hash = $user['password']; if (password_verify($pass, $hash)) {
<?php require_once 'MysqliDb.php'; require_once 'constantes.php'; $bd = new MysqliDb(SERVER_DB_URL, SERVER_DB_USUARIO, SERVER_DB_PASS, SERVER_DB_NOMBRE); if (!$bd->ping()) { $bd->connect(); } if ($_SERVER['REQUEST_METHOD'] == REQUEST_METODO_POST) { $postdata = json_decode(file_get_contents('php://input')); $usuario_form = $postdata->usuario; $pass_form = md5($postdata->pass); $bd->where(COLUMNA_EMAIL, $usuario_form); $bd->where(COLUMNA_PASS, $pass_form); if ($bd->has(TABLA_USUARIO)) { // CORRECTO $accion_form = $postdata->form_accion; if ($accion_form == ACCION_OBTENER) { $query = $bd->get(TABLA_CATEGORIA); $arr = array(RESPUESTA_DATA => $query, RESPUESTA_MENSAJE => MENSAJE_OK, RESPUESTA_ERROR => ERROR_NINGUNO); } else { if ($accion_form == ACCION_OBTERNER_POR_ID) { $parametros = $postdata->form_parametros; foreach ($parametros as $parametro_key => $parametro_valor) { // var_dump($parametro_key); // var_dump($parametro_valor); foreach ($parametro_valor as $key => $val) { // var_dump($key); // var_dump($val); switch ($key) { case PARAMETRO_ID:
/** * @Author: ananayarora * @Date: 2016-01-10 14:28:50 * @Last Modified by: ananayarora * @Last Modified time: 2016-01-10 21:22:46 */ session_start(); if (isset($_SESSION['loggedin'])) { header("Location: discover.php"); } if (isset($_POST['submit'])) { require 'conf.php'; require 'sql.php'; $c = new Conf(); $o = new MysqliDb($c->host, $c->username, $c->password, $c->db); $o->where("username", $_POST['username']); $o->where("password", md5($_POST['password'])); $o->get("users"); if ($o->count == 1 && !isset($_GET['next'])) { header("Location: discover.php"); $_SESSION['loggedin'] = true; $_SESSION['username'] = $_POST['username']; } elseif ($o->count == 1 && isset($_GET['next'])) { header("Location: " . $_GET['next']); $_SESSION['loggedin'] = true; $_SESSION['username'] = $_POST['username']; } elseif ($o->count == 0 && !isset($_GET['next'])) { header("Location: signin.php?wrong"); } elseif ($o->count == 0 && isset($_GET['next'])) { header("Location: signin.php?wrong&next=" . $_GET['next']);
/** * @param string $host * @param string $username * @param string $password * @param string $db * @param int $port */ public function __construct($host, $username, $password, $db, $port = NULL) { $this->host = $host; $this->username = $username; $this->password = $password; $this->db = $db; if ($port == NULL) { $this->port = ini_get('mysqli.default_port'); } else { $this->port = $port; } $this->connect(); $this->setPrefix(); self::$_instance = $this; }