示例#1
0
 public function gettweetsAdmin($verify)
 {
     $dbh = new dbHandler();
     $sim = new simulator();
     $twts = $dbh->returnTweets($verify);
     $sim->showTweets($twts);
 }
示例#2
0
 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();
 }
示例#4
0
 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();
     }
 }
示例#5
0
 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;
 }
示例#7
0
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();
    }
}
示例#8
0
 public function dbDisconnect()
 {
     global $system;
     if (!empty(self::$con)) {
         if (mysql_close(self::$con)) {
             self::$con = false;
             $system->unregisterDbConnection();
         }
     }
 }
示例#9
0
 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);
 }
示例#10
0
 /**
  * @param string $url
  * @return int
  */
 public function getServerStatus($url)
 {
     return $this->dbHandler->getServerStatus($url);
 }
示例#11
0
});
$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();
示例#12
0
        $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();
示例#13
0
 public function updatePerusahaan(array $post)
 {
     $dbConn = new DBConnection();
     $perusahaan = new dbHandler($dbConn, 'perusahaan');
     $perusahaan->updateDatabaseWhere($post, 'where id=' . $post['id']);
 }
示例#14
0
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();
}
示例#15
0
 /**
  * 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;
 }
示例#16
0
 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);
 }
示例#17
0
 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));
 }