本文整理汇总了PHP中DBConnector::querySingle方法的典型用法代码示例。如果您正苦于以下问题:PHP DBConnector::querySingle方法的具体用法?PHP DBConnector::querySingle怎么用?PHP DBConnector::querySingle使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类DBConnector
的用法示例。
在下文中一共展示了DBConnector::querySingle方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: escapeshellcmd
$pin = '';
$posted_pin = '';
if (isset($_REQUEST['pin'])) {
$posted_pin = $_REQUEST['pin'];
}
if ($_SERVER['REQUEST_METHOD'] == 'POST') {
session_start();
$username = escapeshellcmd($_POST['username']);
$password = '';
if (CONFIG_PASSWORD) {
// The password must not be escaped.
$password = $_POST['userpassword'];
}
if (CONFIG_PIN) {
$posted_pin = escapeshellcmd($_POST['pin']);
$pin = $dbcon->querySingle("SELECT value FROM setting WHERE key = 'pin'");
}
if (CONFIG_PASSWORD && !checkCredentials($username, $password)) {
// Invalid username or password.
} else {
if (CONFIG_PIN && $pin != $posted_pin) {
trace("access denied for user '{$username}', wrong pin {$posted_pin}");
$errtext = _('Invalid PIN.');
} else {
// Successfully checked username, password and PIN.
trace("access granted for user '{$username}'");
$_SESSION['username'] = $username;
$_SESSION['address'] = $dbcon->ipAddress();
$_SESSION['pin'] = $pin;
$_SESSION['starturl'] = CONFIG_START_URL;
$_SESSION['monitor'] = CONFIG_STATIONNAME;
示例2: DBConnector
echo "Triggered callback\n";
}
//~ var_dump($_SERVER);
$db = new DBConnector('palma-test.db');
$db->resetTables();
//~ http://stackoverflow.com/questions/1964233/does-sqlite3-support-a-trigger-to-automatically-update-an-updated-on-datetime
//~ https://www.sqlite.org/lang_createtrigger.html
// TODO: Test database triggers (can be used in db.php).
//~ $db->createFunction('dbModifiedCallback', 'dbModifiedCallback', 0);
// {AFTER | BEFORE} {DELETE | INSERT | UPDATE } ON table
//~ $db->exec("CREATE TRIGGER dbchange AFTER UPDATE ON user
//~ BEGIN
//~ dbModifiedCallback();
//~ END");
//~ $db = new DBConnector('palma.db');
echo "Tables=" . $db->querySingle('SELECT count(*) FROM sqlite_master WHERE type="table"') . "\n";
var_dump($db->query("SELECT * from sqlite_master"));
$address = $db->ipAddress();
$db->addUser('testuser1', $address);
//~ $db->addUser('testuser2', $address);
//~ $db->addUser('testuser3', $address);
//~ $db->addUser('testuser4', $address);
$users = $db->getUsers();
$db->enableUser('testuser1');
var_dump($users);
$db->delUser('haenger', $address);
$db->delUser('ivwz', $address);
$db->delUser('skrieg', $address);
$db->delUser('testuser1', $address);
$db->delUser('testuser2', $address);
$db->delUser('testuser3', $address);
示例3: deleteInactiveVncWindow
protected function deleteInactiveVncWindow()
{
// print("\n[Daemon]: +++ TODO: deleteInactiveWindow() +++");
$db = new DBConnector();
// window_ids in db
$vnc_windows_in_db = array();
$client_info = $db->getVNC_ClientInfo();
foreach ($client_info as $info) {
$vnc_windows_in_db[] = $info["win_id"];
}
// window_ids on screen
$windows_on_screen = array();
$windows = explode("\n", shell_exec('wmctrl -l'));
foreach ($windows as $w) {
$field = explode(' ', $w);
$id = $field[0];
if ($id != '') {
$windows_on_screen[] = $id;
}
}
// print("[Daemon]: clients in db = " . serialize($vnc_windows_in_db));
// print("[Daemon]: client on screen = " . serialize($windows_on_screen));
// window_ids that are in the db, but not on the screen (window already closed)
$inactive_vnc_window_ids = array_diff($vnc_windows_in_db, $windows_on_screen);
foreach ($inactive_vnc_window_ids as $inactive_win_id) {
// define vnc-id
$inactive_vnc_id = $db->querySingle("SELECT file FROM window WHERE win_id='" . $inactive_win_id . "'");
// delete from database (send to control.php)
$curl = curl_init();
curl_setopt_array($curl, array(CURLOPT_RETURNTRANSFER => 1, CURLOPT_URL => CONFIG_CONTROL_FILE_URL . '?window=vncwin&delete=VNC&vncid=' . $inactive_win_id, CURLOPT_USERAGENT => 'PalMA cURL Request'));
$resp = curl_exec($curl);
curl_close($curl);
// print("[Daemon]: inactive vnc_id = $inactive_vnc_id >> add to list: " .serialize($this->_IGNORE_LIST));
}
}