public function save() { $q = []; $id = Connector::query('SELECT MAX(id) FROM projects'); $id = $id[0]['MAX(id)'] > 0 ? $id[0]['MAX(id)'] + 1 : 1; //echo $id; array_push($q, "INSERT INTO projects (id, name, description, insertBy) VALUES(" . $id . ",'" . $this->name . "','" . $this->description . "'," . $this->insertBy . ")"); array_push($q, "INSERT INTO users_projects VALUES('" . $this->insertBy . "','" . $id . "')"); $res = Connector::queryTran($q); //print_r($res); }
public static function hCheck($hash) { $query = "SELECT id,logged, password FROM users"; $res = Connector::query($query); foreach ($res as $r) { if (in_array($hash, $r, false)) { $hash1 = hash_hmac('ripemd160', $_SERVER['HTTP_USER_AGENT'] . $_SERVER['REMOTE_ADDR'], $r['password']); if ($hash1 === $hash) { return $r['id']; } } } return false; }
<?php require_once "classes/db.php"; if (!empty($_POST)) { $object = $_POST['object']; $value = $_POST['value']; $type = $_POST['type']; $speed = $_POST['speed']; $al = $_POST['al']; $db = new Connector(); if (strcmp($al, "asset") == 0) { $db->query("insert into assets(object, value, type, speed) values (:object, :value, :type, :speed)"); $db->bind(":object", $object); $db->bind(":value", $value); $db->bind(":type", $type); $db->bind(":speed", $speed); $db->execute(); } else { if (strcmp($al, "liability") == 0) { $db->query("insert into liabilities(object, value, type, speed) values (:object, :value, :type, :speed)"); $db->bind(":object", $object); $db->bind(":value", $value); $db->bind(":type", $type); $db->bind(":speed", $speed); $db->execute(); } } } header("Location: ../");
</ul> <div class="tab-content" style="border: 1px solid lightgray; border-top: none;"> <div role="tabpanel" class="tab-pane active" id="al" > <br> <div class="col-md-12"> <button class="btn btn-default" data-toggle="modal" data-target="#register_al"><span class="glyphicon glyphicon-plus"></span> Register new</button> </div> <div class="col-md-6"> <h3 class="text-success">Assets <small class="text-success"><span class="glyphicon glyphicon-arrow-up"></span></small></h3> <table class="table table-hover"> <tr> <th>Object</th> <th>Speed</th> </tr> <?php $db->query("select * from assets order by id desc;"); foreach ($db->resultset() as $asset) { $id = $asset['id']; $object = $asset['object']; $value = $asset['value']; $type = $asset['type']; $speed = $asset['speed']; $sign = "\$"; if (strcmp($type, "tugrug") == 0) { $sign = "₮"; $type = "t"; } else { if (strcmp($type, "dollar") == 0) { $sign = "\$"; $type = "d"; }
// Copyright (C) 2016 Allard van Altena // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU Affero General Public License as published by // the Free Software Foundation, either version 3 of the License, or // (at your option) any later version. // This program is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU Affero General Public License for more details. // You should have received a copy of the GNU Affero General Public License // along with this program. If not, see <http://www.gnu.org/licenses/>. header("Content-disposition: attachment; filename=articles.csv"); header("Content-Type: text/csv"); require_once "config.php"; require_once "database.php"; $db = new Connector(); $db->connect($config); // Get articles from DB $articles = $db->query("SELECT * FROM Articles"); $output = array(); while ($article = $articles->fetch_array()) { // Filter articles with an empty abstract if ($article["abstract"] != "") { // Filter any non characters, retain a-z, - and spaces // Merge title and abstract into one CSV row $text = preg_replace("/[^a-zA-Z'\\-\\ ]/", "", $article["title"] . " " . $article["abstract"]); array_push($output, $text); } } // Echo output as CSV echo implode(",\n", $output) . "\n";
public static function logout($key) { $res = Connector::query("UPDATE users SET logged = NULL where logged ='" . $key . "'"); //echo var_dump($res); return $res === true ? "true" : "false"; }