get() public méthode

public get ( $table, $join = null, $column = null, $where = null )
Exemple #1
0
 /**
  * @param      $table
  * @param      $columns
  * @param null $where
  * @return bool|array
  */
 public function get($table, $columns, $where = NULL)
 {
     if (empty($this->_reader)) {
         return $this->_writer->get($table, $columns, $where);
     } else {
         return $this->_reader->get($table, $columns, $where);
     }
 }
 function login()
 {
     if (session_id() == '') {
         session_start();
     }
     if (isset($_POST["mail"]) & isset($_POST["password"]) & isset($_POST["cre"])) {
         if ($_POST["mail"] != "" and $_POST["password"] != "" and $_POST["cre"] != "") {
             $mail = $_POST["mail"];
             $password = $_POST["password"];
             $role = $_POST["cre"];
             require_once 'SessionManager.php';
             $session_manager = new SessionManager();
             require_once 'medoo.min.php';
             $database = new medoo();
             $count = $database->count("triotrack_users", ["email" => "{$mail}"]);
             if ($count > 0) {
                 $profile = $database->get("triotrack_users", ["username", "password", "salt", "client"], ["email" => "{$mail}"]);
                 if ($role === "admin") {
                     if ($profile["password"] === sha1($password . $profile["salt"])) {
                         $username = $profile["username"];
                         $client = $profile["client"];
                         $cookie = array("email" => "{$mail}", "username" => "{$username}", "password" => "{$password}", "client" => "{$client}", "role" => "{$role}");
                         $encoded_cookie = $session_manager->encode_session(json_encode($cookie));
                         $_SESSION["user_id"] = $encoded_cookie;
                         setcookie("user_id", $encoded_cookie, time() + 86400 * 1, "/");
                         // 86400 = 1 day
                         echo "admin";
                         exit;
                     } else {
                         echo "failed";
                         exit;
                     }
                 } else {
                     if ($profile["client"] === $password) {
                         $username = $profile["username"];
                         $client = $profile["client"];
                         $cookie = array("email" => "{$mail}", "username" => "{$username}", "password" => "{$password}", "client" => "{$client}", "role" => "{$role}");
                         $encoded_cookie = $session_manager->encode_session(json_encode($cookie));
                         $_SESSION["user_id"] = $encoded_cookie;
                         setcookie("user_id", $encoded_cookie, time() + 86400 * 1, "/");
                         // 86400 = 1 day
                         echo "client";
                         exit;
                     } else {
                         echo "failed";
                         exit;
                     }
                 }
             }
         } else {
             echo "failed";
         }
         exit;
     }
 }
Exemple #3
0
<?php

require_once 'meedoo.php';
require_once 'config.php';
$database = new medoo();
session_start();
ini_set('display_errors', 1);
ini_set('display_startup_errors', 1);
error_reporting(-1);
$email = $_POST["email"];
$name = $_POST["name"];
$password1 = $_POST["password"];
$password = md5($password1 . $salt);
//check if user exists
$profile = $database->get("users", ["email"], ["email" => $email]);
$profile_email = $profile['email'];
if ($profile_email) {
    echo 'emailTaken';
} else {
    //if not...
    $add = $database->insert('users', ['email' => $email, 'password' => $password, 'name' => $name]);
    if ($add) {
        $_SESSION['user'] = $email;
        echo 'good';
    } else {
        echo 'bad';
    }
}
Exemple #4
0
<?php

error_reporting(E_ALL);
require_once __DIR__ . '/../vendor/autoload.php';
$db = new \medoo(['database_type' => 'mysql', 'database_name' => 'dbal_wrap', 'server' => 'localhost', 'username' => 'root', 'password' => '', 'charset' => 'utf8']);
$data = $db->get('goods', '*', ['id' => 12]);
print_r($data);
Exemple #5
0
defined("LIBRARY_PATH") or define("LIBRARY_PATH", realpath(dirname(__FILE__) . '/lib'));
include LIBRARY_PATH . '/medoo.min.php';
if (isset($_GET['install']) and !file_exists(LIBRARY_PATH . '/database.db') and isset($_POST['username']) and isset($_POST['pwd']) and isset($_POST['rpt']) and $_POST['pwd'] == $_POST['rpt']) {
    $db = new medoo(LIBRARY_PATH . '/database.db');
    $db->query("CREATE TABLE users (username TEXT,password TEXT);");
    $db->query("CREATE TABLE settings (setting TEXT,value TEXT);");
    $db->query("CREATE TABLE hosts (domain TEXT,checkInTime TEXT,description TEXT);");
    $db->insert("users", ["username" => strtolower($_POST['username']), "password" => password_hash($_POST['pwd'], PASSWORD_DEFAULT)]);
    $db->insert("settings", ["setting" => "secretKey", "value" => rand()]);
    if (!$db->error()[0] == "00000") {
        unlink(LIBRARY_PATH . '/database.db');
        $noticeMessage = "An error occurred while saving the database.";
    } else {
        $noticeMessage = "Successfully installed DropPoint control. Please login.";
    }
}
if (!file_exists(LIBRARY_PATH . '/database.db')) {
    include TEMPLATES_PATH . '/setup.php';
    exit;
}
$db = new medoo(LIBRARY_PATH . '/database.db');
$secretCode = $db->get("settings", "value", ["setting" => "secretKey"]);
function dbHasError()
{
    global $db;
    if ($db->error()[0] == "00000") {
        return false;
    } else {
        return true;
    }
}
Exemple #6
0
<?php

error_reporting(E_ALL);
ini_set("display_errors", 1);
require_once 'meedoo.php';
require_once 'config.php';
$database = new medoo();
// echo 'Request: ' . $_SERVER['REQUEST_METHOD'].'. ';
$mealID = $_GET['mealID'];
$meal = $database->get("meals", ["mealID", "id", "datecreated", "name", "type", "ingredients", "instructions", "status", "user"], ["mealID" => $mealID]);
$dataJSON = json_encode($meal);
if ($meal) {
    echo $dataJSON;
} else {
    echo 'bad';
}
?>


    include 'assets/html/login_success.html';
    include 'phpAPI/home.php';
    //header("Location: /wedstrijdplatform/#/spelpagina"); //dit mag hier niet, zorgt voor eindeloze redirect ( na post ziet hij dat er al een sessie is dus komt hij hier en gaat hij nogmaals doorverwijzen
    //naar spelpagina, en dit blijft zich herhalen, dit stond hier omdat je als je al ingelogd bent, dat je automatisch de spelpagina ziet en niet opnieuw moet inloggen)
    include "assets/html/footer.html";
    //session_destroy(); //moet weg, staat hier enkel voor test
} else {
    if (isset($_POST['inputEmail'], $_POST['inputPassword'])) {
        $database = new medoo();
        $email = trim($_POST['inputEmail']);
        /* Check for correct email and password */
        $emailExists = $database->count("gebruikers", ["AND" => ["email" => $email]]);
        /* If exectly one user has been found */
        if ($emailExists == 1) {
            $enteredPassword = trim($_POST['inputPassword']);
            $user = $database->get("gebruikers", "*", ["AND" => ["email" => $email]]);
            //print_r($user);
            $dbpassword = $user['wachtwoord'];
            if (password_verify($enteredPassword, $dbpassword)) {
                $_SESSION['email'] = $email;
                $_SESSION['isLoggedIn'] = "true";
                /*include 'html/nav.html';
                		echo "<h1>User was get from post!</h1>"; /////////////////////////////////delete
                		include 'html/login_success.html';
                		echo "<h1>Normal user logged in.</h1>";
                		include 'php/home.php';*/
                header("Location: /wedstrijdplatform/#/spelpagina");
            } else {
                include 'assets/html/nav.html';
                include 'assets/html/failed_login.html';
                include 'phpAPI/home.php';
}
// Logged in?
$user = isset($_SESSION["user_connected"]) ? $_SESSION["user_connected"] : '0';
$uid = isset($_SESSION["uid"]) ? $_SESSION["uid"] : '';
$email = isset($_SESSION["email"]) ? $_SESSION["email"] : '';
// Set variables
$user_exist = isset($user_exist) ? $user_exist : '';
$user_email = isset($user_email) ? $user_email : '';
$datas = isset($datas) ? $datas : '';
$user_id = isset($user_id) ? $user_id : '';
// DB
require_once 'lib/medoo/medoo.php';
$database = new medoo(['database_type' => 'mysql', 'database_name' => 'table_name', 'server' => 'localhost', 'username' => 'root', 'password' => '', 'charset' => 'utf8']);
// Get logged in user's name
if ($user) {
    $data = $database->get("users2", "*", ["email" => $email]);
    $name = $data["name"];
    $user_id = $data['id'];
} else {
    if ($uid) {
        $data = $database->get("users2", "*", ["hybridauth_provider_uid" => $uid]);
        $name = $data["name"];
        $user_id = $data['id'];
    }
}
// Forgotten password variables for email:
$headers = 'From: admin@yoursite.com' . "\r\n" . 'Reply-To: admin@yoursite.com' . "\r\n" . 'X-Mailer: PHP/' . phpversion();
// Main action for switcher.
$a = isset($_GET['a']) ? $_GET['a'] : '';
switch ($a) {
    // DASHBOARD
Exemple #9
0
 /**
  * @param string $table
  * @param array $join
  * @param string|array $column
  * @param array $where
  * @return bool|array
  *
  * Or,
  * @param string $table
  * @param string|array $column
  * @param array $where
  * @return bool|array
  */
 public function get($table, $join = null, $column = null, $where = null)
 {
     $re = parent::get($table, $join, $column, $where);
     $this->lastSql = $this->last_query();
     $this->lastError = $this->error();
     return $re;
 }
<?php

$app->get('/invoice/:id', function ($id) use($app) {
    global $billingInfo;
    global $dbCredentials;
    $database = new medoo($dbCredentials);
    $invoice = $database->get("invoice", ["id", "modified", "company", "name", "address", "type", "currency"], ["id" => $id]);
    if ($invoice) {
        $invoice['lines'] = $database->select("line", ["id", "description", "charge", "quantity", "is_hours"], ["invoice_id" => $invoice['id'], "ORDER" => "id ASC"]);
    } else {
        $app->response->setStatus(404);
    }
    $app->render('invoice.html.twig', ['invoice' => $invoice, 'billing' => $billingInfo]);
})->setName('invoice');
Exemple #11
0
<?php

/**
 * Created by IntelliJ IDEA.
 * User: nicko
 * Date: 02.02.2016
 * Time: 23:38
 */
require_once 'vendor/autoload.php';
//open database connection
$database = new medoo(['database_type' => 'mysql', 'database_name' => 'r8db', 'server' => '172.16.2.109', 'username' => 'admin', 'password' => 'admin', 'charset' => 'utf8']);
$user_id = $database->select("user", ["[>]entry" => "user_id"], ["entry.entry_id"], ["entry_id" => 10]);
$user = $database->get('user', ['[>]entry' => "user_id"], ['user_id', 'email', 'username', 'admin', 'nsfw'], ['entry_id' => 10]);
$html = '<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css"><div class="container"><div class="row">';
$html .= '<form class="clearfix" method="get">
<div class="form-group col-sm-4"><label for="action">Action</label><select class="form-control" name="action" id="action"><option value="show">show</option><option value="delete">delete</option><option value="add">add</option><option value="set">set</option></select></div>
<div class="form-group col-sm-4"><label for="amount">Amount</label><input class="form-control" type="number" name="amount" id="amount" value=""></div>
<div class="form-group col-sm-4"><label>Functions</label><div><button type="submit" class="btn btn-primary">Submit</button> <button type="reset" class="btn btn-warning">Reset</button></div></div>
</form>';
$html .= '</div><div class="row"><div class="col-sm-12">';
$count = $database->count('entry');
$database->query('ALTER TABLE "entry" AUTO_INCREMENT = ' . ($count + 1));
if (isset($_GET['action'])) {
    $amount = isset($_GET['amount']) && is_numeric($_GET['amount']) ? intval($_GET['amount']) : 100;
    if ($_GET['action'] == 'delete' && $count != 0) {
        $database->delete('entry', ['ORDER' => 'entry_id DESC', 'LIMIT' => $amount]);
    } elseif ($_GET['action'] == 'delete') {
        $html .= 'Where nothing is, nothing can be removed.';
    } elseif ($_GET['action'] == 'add') {
        for ($i = $count + 1; $i < $count + $amount + 1; ++$i) {
            $data = ['user_id' => 1, 'category_id' => 1, 'title' => 'Dummy #' . $i, 'desc' => 'Lorem Ipsum', 'image' => 'https://placehold.it/400x400'];
Exemple #12
0
/**
 * Controlla che l'aula studio non sia piena
 * 
 * @param medoo $database Connessione con il database
 * @param int $id
 * @return boolean
 */
function full($database, $id)
{
    return $database->count("pomeriggio", array("AND" => array("aula" => $id, "stato" => 0))) >= $database->get("aule", "max", array("id" => $id));
}
Exemple #13
0
 * Date: 2016/10/14
 * Time: 下午2:30
 * Desc: 获取用户的关注专题/文集、关注用户、粉丝、文章
 */
ini_set('display_errors', 'ON');
error_reporting(E_ALL);
header("Content-type:text/html;charset=utf-8");
defined('ROOT_PATH') or define('ROOT_PATH', dirname(__FILE__));
include ROOT_PATH . '/medoo.php';
include ROOT_PATH . '/Curl.php';
$db = new medoo(array('database_type' => 'mysql', 'database_name' => 'jianshu', 'server' => 'localhost', 'username' => 'root', 'password' => '123456', 'port' => 3306, 'charset' => 'utf8', 'option' => array(PDO::ATTR_CASE => PDO::CASE_NATURAL)));
$curl = new Curl();
$str = file_get_contents('user.txt');
$id = intval($str);
while (true) {
    $userArr = $db->get('user', '*', array('id[>]' => $id, 'LIMIT' => 1));
    if (!is_array($userArr) || empty($userArr)) {
        echo "Over!\r\n";
        break;
    }
    //关注专题/文集
    collection($userArr);
    //构造数据
    //    $userArr = array('id' => 7231, 'name' => 'f93e84d2e162');
    //关注用户
    following($userArr);
    //粉丝
    follower($userArr);
    //文章
    articles($userArr);
    $id = $userArr['id'];
Exemple #14
0
<?php

require '../vendor/autoload.php';
require '../secrets.php';
$data = json_decode(urldecode($_GET['data']), true);
$data['address'] = $_SERVER['REMOTE_ADDR'];
$output = array();
$disableDB = false;
if (!$disableDB) {
    try {
        $database = new medoo(['database_type' => 'mysql', 'database_name' => $dbname, 'server' => $dbhost, 'username' => $dbuser, 'password' => $dbpass, 'port' => $dbport, 'charset' => 'utf8']);
    } catch (Exception $e) {
        die("Failed to connect to the database\r\n");
    }
    $record = $database->get("server", "id", ["id" => $data['serverId']]);
    if (empty($record)) {
        $database->insert("server", ["id" => $data['serverId'], "address" => $data['address'], "port" => $data['port'], "providertoken" => $data['providerId'], "notlegacy" => 1, "lastupdate" => time()]);
        $database->insert("server_details", ["serverid" => $data['serverId'], "players" => $data['currentPlayers'], "slots" => $data['maxPlayers'], "memory" => $data['systemRam']]);
    } else {
        $database->update("server", ["id" => $data['serverId'], "address" => $data['address'], "port" => $data['port'], "providertoken" => $data['providerId'], "lastupdate" => time()], ["id" => $data['serverId']]);
        $database->update("server_details", ["serverid" => $data['serverId'], "players" => $data['currentPlayers'], "slots" => $data['maxPlayers'], "memory" => $data['systemRam']], ["serverid" => $data['serverId']]);
    }
}
$output["success"] = true;
echo json_encode($output);
Exemple #15
0
    $json = array('error' => false, 'message_id' => $message_id, 'message' => $message_list[$message_id]);
    if ($data) {
        $json['data'] = $data;
    }
    echo json_encode($json);
}
/* 统一输出函数 */
function message_error($message)
{
    echo json_encode(array('error' => true, 'message' => $message));
}
if (isset($_GET['application'], $_GET['method'], $_GET['apikey'])) {
    $appid = (int) $_GET['application'];
    $method = $_GET['method'];
    $apikey = $_GET['apikey'];
    $application = $database->get('application', array('id', 'apikey'), array('id' => $appid));
    if ($application) {
        if ($apikey === $application['apikey']) {
            $apikey = $application['apikey'];
            if ($method == 'new_order') {
                /* 方法 new_order 开始 */
                if (isset($_POST['sig'], $_POST['tradeNo'], $_POST['desc'], $_POST['time'], $_POST['username'], $_POST['userid'], $_POST['amount'], $_POST['status'])) {
                    /**
                     * 给软件的接口,将订单添加到数据库
                     * 这段代码采用 echo 而不是标准输出函数输出,因为是给别的程序看的
                     **/
                    $sig = $_POST['sig'];
                    //签名
                    $tradeNo = $_POST['tradeNo'];
                    //交易号
                    $payname = $_POST['desc'];
Exemple #16
0
<?php

require '../vendor/autoload.php';
require '../secrets.php';
$data = json_decode(urldecode($_GET['data']), true);
$data['address'] = $_SERVER['REMOTE_ADDR'];
$output = array();
$hash = md5($data['address'] . ":" . $data['port']);
$disableDB = false;
if (!$disableDB) {
    try {
        $database = new medoo(['database_type' => 'mysql', 'database_name' => $dbname, 'server' => $dbhost, 'username' => $dbuser, 'password' => $dbpass, 'port' => $dbport, 'charset' => 'utf8']);
    } catch (Exception $e) {
        die("Failed to connect to the database\r\n");
    }
    $record = $database->get("server", "id", ["id" => $hash]);
    if (empty($record)) {
        $database->insert("server", ["id" => $hash, "address" => $data['address'], "port" => $data['port'], "lastupdate" => time()]);
        $database->insert("server_details", ["serverid" => $hash, "players" => $data['currentPlayers'], "slots" => $data['maxPlayers'], "memory" => $data['systemRam']]);
    } else {
        $database->update("server", ["id" => $hash, "address" => $data['address'], "port" => $data['port'], "lastupdate" => time()], ["id" => $hash]);
        $database->update("server_details", ["serverid" => $hash, "players" => $data['currentPlayers'], "slots" => $data['maxPlayers'], "memory" => $data['systemRam']], ["serverid" => $hash]);
    }
}
$output["success"] = "Ok";
echo json_encode($output);
Exemple #17
0
<?php

ini_set('display_errors', 1);
ini_set('display_startup_errors', 1);
error_reporting(-1);
session_start();
require_once 'meedoo.php';
require_once 'config.php';
$root = (!empty($_SERVER['HTTPS']) ? 'https' : 'http') . '://' . $_SERVER['HTTP_HOST'] . '/';
$appHome = (!empty($_SERVER['HTTPS']) ? 'https' : 'http') . '://' . $_SERVER['HTTP_HOST'] . '/apps/meals/';
$database = new medoo();
$email = $_GET["email"];
$password1 = $_GET["password"];
$password = md5($password1 . $salt);
$profile = $database->get("users", ["name", "password"], ["email" => $email]);
$profile_pw = $profile['password'];
$profile_name = $profile['name'];
if ($password == $profile_pw) {
    $_SESSION['user'] = $email;
    $_SESSION['name'] = $profile_name;
    echo 'good';
} else {
    echo 'bad';
}
$user_exist = isset($user_exist) ? $user_exist : '';
$datas = isset($datas) ? $datas : '';
// If no connection previously made, show the below to allow a new user login via form submission or HybridAUTH via a social provider
$user_connect_check = isset($_SESSION["user_connected"]) ? $_SESSION["user_connected"] : '0';
if ($user_connect_check == false) {
    // Start a new connection; use the medoo framework for DB functions
    require_once 'lib/medoo/medoo.php';
    $database = new medoo(['database_type' => 'mysql', 'database_name' => 'admin_video', 'server' => 'localhost', 'username' => 'root', 'password' => '', 'charset' => 'utf8']);
    if (isset($_REQUEST["email"]) && isset($_REQUEST["password"])) {
        // Login locally (via form submission)
        /* $datas =  $database->select("users", ["email", "password", "name"], [
        				"AND" => [
        					"email" => $_REQUEST["email"] //, "password" => $_REQUEST["password"]
        				]
        			]); */
        $data = $database->get("users2", ["email", "password", "name"], ["email" => $_REQUEST["email"]]);
        $user_exist = $name = $data["name"];
        $user_password = $data['password'];
        // Saved, hashed PW
        if ($user_exist) {
            // Check the submitted password against the saved one from the DB (we know it exists)
            if (password_verify($_REQUEST["password"], $user_password)) {
                // echo 'Password is valid!';
                // Set the user as connected and redirect.
                $_SESSION["user_connected"] = true;
                $_SESSION["email"] = $_REQUEST["email"];
                header("Location: " . _HOME . "");
                // ?a=dash
            } else {
                echo 'Invalid password.';
            }