public function gettweetsAdmin($verify) { $dbh = new dbHandler(); $sim = new simulator(); $twts = $dbh->returnTweets($verify); $sim->showTweets($twts); }
function myLogin($a, $b) { $obj = new simulator(); $ojb = new dbHandler(); $verify = $ojb->checkUser($a, $b); if ($verify) { $obj->followUp($verify); } else { $obj->wrongLogin(); } }
function checkCredentials($userid, $password, Request $message) { $db = new dbHandler(); $link = $db->getDbHandler(); $query = "SELECT * FROM Security WHERE UserName = '******' and Password = '******'"; $result = sqlite_query($link, $query); if (sqlite_num_rows($result) < 1) { $db->close(); throw new WebORBAuthenticationException("invalid userid or password"); } $db->close(); }
public function AdminLogin($username, $password) { $ojb = new dbHandler(); $sim = new simulator(); $verify = $ojb->checkAdmin($username, $password); if ($verify) { $sim->afterAdminLogin($verify); } else { echo "Re-Enter Your Credentials Please"; $sim->adminLoginInfo(); } }
function addToList($list_name, $verify) { $db = new dbHandler(); $sim = new simulator(); $handle = fopen("php://stdin", "r"); echo "Press 1 to add people in {$list_name}"; $db->allUsersF($verify); echo "========Press the ID Number of the User to Add it to the list===========\n"; $b = fgets($handle); $member = $db->returnUser($b); array_push($list_name, $member); $sim->afterList($list_name, $verify); }
public function getProducts() { try { $db = new dbHandler(); $link = $db->getDbHandler(); /*String*/ $query = "SELECT Name, Price FROM Products"; $result = sqlite_array_query($link, $query, SQLITE_ASSOC); $db->close(); return $result; } catch (Exception $exception) { Log::log(LoggingConstants::EXCEPTION, $exception); } return null; }
function checkToken() { $app = \Slim\Slim::getInstance(); $token = $app->request->headers->get('token'); $app = \Slim\Slim::getInstance(); if ($token) { $db = new dbHandler(); if ($db->isValidToken($token)) { return true; } else { sendResponse(401, initBody(true, "Bad token"), null); $app->stop(); } } else { sendResponse(401, initBody(true, "Token is missing"), null); $app->stop(); } }
public function dbDisconnect() { global $system; if (!empty(self::$con)) { if (mysql_close(self::$con)) { self::$con = false; $system->unregisterDbConnection(); } } }
function sendMessage($sender) { $db = new dbHandler(); $sim = new simulator(); $handle = fopen("php://stdin", "r"); echo "Write Message"; $text = fgets($handle); $text = "Message:" . $text; echo "Enter Reciever "; $db->allUsers(); echo "========Press the ID Number of the User ===========\n"; $input = fgets($handle); $member = $db->returnUser($input); $tm = "Time:" . date("h:i:sa"); $dt = "Date:" . date("Y/m/d"); $myfile = fopen("{$member}" . "message", "a") or die("Unable to open file!"); fwrite($myfile, $sender . "\n" . $text . $tm . "\n" . $dt . "\n"); $sim->followUp($sender); }
/** * @param string $url * @return int */ public function getServerStatus($url) { return $this->dbHandler->getServerStatus($url); }
}); $app->get('/info', function () { $db = new dbHandler(); $cur = $db->getInfoPost(); $result = array(); foreach ($cur as $doc) { $tmp = array(); $tmp["title"] = $doc["title"]; $tmp["post"] = $doc["post"]; $tmp["date"] = date('Y-m-d', strtotime('+7 hours', $doc["date"]->sec)); array_push($result, $tmp); } response(200, $result); }); $app->get('/scholar', function () { $db = new dbHandler(); $cur = $db->getScholarPost(); $result = array(); foreach ($cur as $doc) { $tmp = array(); $tmp["title"] = $doc["title"]; $tmp["post"] = $doc["post"]; $tmp["date"] = date('Y-m-d', strtotime('+7 hours', $doc["date"]->sec)); array_push($result, $tmp); } response(200, $result); }); //rest response helper function response($status, $response) { $app = \Slim\Slim::getInstance();
$tmp = array(); //Set key and get value from document and store to temporary array $tmp["name"] = $doc["name"]; $tmp["age"] = $doc["age"]; //push temporary array to $result array_push($result, $tmp); } //show result response(200, $result); }); //Post Friends end point $app->post('/friends', function () use($app) { $res = array(); $name = $app->request()->post('name'); $age = $app->request()->post('age'); $db = new dbHandler(); $cur = $db->insertFriend($name, $age); if ($cur == INSERT_COL_SUCCESS) { $res["error"] = FALSE; $res["message"] = "Success to insert a new friend"; response(201, $res); } else { $res["error"] = TRUE; $res["message"] = "Failed to add a new friend"; response(200, $res); } }); //Delete friend end point /* $app->delete('/friends/:name', function($name){ $res = array();
public function updatePerusahaan(array $post) { $dbConn = new DBConnection(); $perusahaan = new dbHandler($dbConn, 'perusahaan'); $perusahaan->updateDatabaseWhere($post, 'where id=' . $post['id']); }
class dbHandler { private $database; private $server; private $username; private $password; public function __construct($server, $username, $password, $database) { $this->server = $server; $this->username = $server; $this->password = $password; $this->database = $database; } public function setConnection() { if (!mysqli_connect($this->server, $this->username, $this->password, $this->database)) { throw new DbConnectionExceptional(mysqli_connect_error()); } else { print "DB connection successfull"; } } } class DbConnectionExceptional extends Exception { } try { $con = new dbHandler("localhost", "root", "pass1234", "vdorr"); $con->setConnection(); } catch (DbConnectionExceptional $e) { print " Conncetion Authintication error " . $e->getMessage(); }
/** * Generates a sequential number for our invoices by getting the most recent invoice number in the database and adding 1 to it * @return string */ public function generateInvNumber() { $dbConn = new DBConnection(); $i = new dbHandler($dbConn, 'inv_details'); $iNumber = $i->getResultsWhere('order by number DESC LIMIT 0, 1 '); $pecahInv = explode("/", $iNumber[0]->number); $thsekarang = date('Y'); $thInv = $pecahInv[3]; // Get current invoice number so we can add one to it. // Do we have an invoice number to add 1 to? If not we are going to start at 0001 if (isset($iNumber[0]->number) != null or $thsekarang != $thInv) { // Add one to the invoice number if exists $newNumber = $pecahInv[0] + 1; } else { $newNumber = '1'; } return $newNumber; }
public function logging($ndbase, $idtable, $statuss) { $dbConn = new DBConnection(); $logging = new dbHandler($dbConn, "loging"); if (!isset($_SESSION['ID'])) { $session = "none"; } else { $session = $_SESSION['ID']; } $inputdata = array('namatabel' => $ndbase, 'iduser' => $session, 'tanggal' => date("Y-m-d H:i:s"), 'logtabel' => $idtable, 'statuss' => $statuss); //set update=false //$_POST['update'] = 'false'; //simpan data user ke db $logging->insertIntoDatabase($inputdata); }
public function afterAdminLogin($verify) { $db = new dbHandler(); $db->allUsers(); echo "Enter the User name to see all tweets\n"; $twt = new tweet(); $handle = fopen("php://stdin", "r"); $user = fgets($handle); $twt->gettweetsAdmin(trim($user)); }