本文整理汇总了PHP中SQLite3::escapeString方法的典型用法代码示例。如果您正苦于以下问题:PHP SQLite3::escapeString方法的具体用法?PHP SQLite3::escapeString怎么用?PHP SQLite3::escapeString使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类SQLite3
的用法示例。
在下文中一共展示了SQLite3::escapeString方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: formSubmit
function formSubmit($_POST)
{
$formSubmit = array();
$url = $_POST['url'];
$ticket = $_POST['ticket'];
$ticket = strtolower($ticket);
$ticket = ltrim($ticket, 'inc0');
$notes = htmlentities($_POST['notes'], ENT_QUOTES);
$db = new SQLite3('./urls/urls.db');
$result = $db->query('SELECT * FROM urls WHERE url = "' . $url . '"');
$arrayDump = $result->fetchArray();
if (!isset($arrayDump['id'])) {
$formSubmit['old'] = FALSE;
$formSubmit['url'] = $url;
$formSubmit['notes'] = $notes;
$formSubmit['ticket'] = $ticket;
$time = time();
$url = $db->escapeString($url);
$notes = $db->escapeString($notes);
$ticket = $db->escapeString($ticket);
$time = $db->escapeString($time);
$subip = $db->escapeString($_SERVER['REMOTE_ADDR']);
$command = 'INSERT INTO urls (notes, ticket, url, time, ip) VALUES ("' . $notes . '","' . $ticket . '","' . $url . '","' . $time . '","' . $subip . '")';
$query = $db->exec($command);
} else {
$formSubmit['ticket'] = $arrayDump['ticket'];
$formSubmit['notes'] = $arrayDump['notes'];
$formSubmit['url'] = $arrayDump['url'];
$formSubmit['old'] = TRUE;
}
return $formSubmit;
}
示例2: clean
/**
* Cleans entries from journal.
* @param array $conditions
* @return array of removed items or NULL when performing a full cleanup
*/
public function clean(array $conditions)
{
if (!empty($conditions[Cache::ALL])) {
$this->database->exec('DELETE FROM CACHE;');
return;
}
$query = array();
if (!empty($conditions[Cache::TAGS])) {
$tags = array();
foreach ((array) $conditions[Cache::TAGS] as $tag) {
$tags[] = "'" . $this->database->escapeString($tag) . "'";
}
$query[] = 'tag IN(' . implode(', ', $tags) . ')';
}
if (isset($conditions[Cache::PRIORITY])) {
$query[] = 'priority <= ' . (int) $conditions[Cache::PRIORITY];
}
$entries = array();
if (!empty($query)) {
$query = implode(' OR ', $query);
$result = $this->database->query("SELECT entry FROM cache WHERE {$query}");
if ($result instanceof SQLiteResult) {
while ($entry = $result->fetchSingle()) {
$entries[] = $entry;
}
} else {
while ($entry = $result->fetchArray(SQLITE3_NUM)) {
$entries[] = $entry[0];
}
}
$this->database->exec("DELETE FROM cache WHERE {$query}");
}
return $entries;
}
示例3: quote
/**
* {@inheritdoc}
*/
public function quote($input, $type = \PDO::PARAM_STR)
{
if (is_int($input) || is_float($input)) {
return $input;
}
return "'" . $this->_conn->escapeString($input) . "'";
}
示例4: quote
public function quote($string)
{
if (!$this->connected) {
$this->connect();
}
return $this->dbHandle->escapeString($string);
}
示例5: acctstart
function acctstart($input)
{
require_once "settings.php";
$input = $input;
$delimiter1 = "The new session";
$delimiter2 = "has been created";
$pos1 = strpos($input, $delimiter1) + strlen($delimiter1) + 2;
$pos2 = strpos($input, $delimiter2) - 2;
$sstrlen = $pos2 - $pos1;
$sessid = substr($input, $pos1, $sstrlen);
exec($vpncmd . " " . $softetherip . " /SERVER /HUB:" . $hubname . " /PASSWORD:" . $apipass . " /CSV /CMD SessionGet " . $sessid, $SessionGet);
if (strpos($SessionGet[0], "rror occurred") != FALSE) {
die("Error - SessionGet resulted in error");
}
foreach ($SessionGet as $line) {
list($key, $val) = explode(",", $line, 2);
$result[$key] = $val;
}
$recheck = 0;
dhcptest:
sleep(2);
exec($vpncmd . " " . $softetherip . " /SERVER /HUB:" . $hubname . " /PASSWORD:" . $apipass . " /CSV /CMD IpTable", $IpTable);
$ok = 0;
foreach ($IpTable as $line) {
if (strpos($line, $sessid)) {
if (strpos($line, "DHCP")) {
list(, $key, $val) = explode(",", $line);
list($framedip) = explode(" ", $val);
#$result2[$key] = $val;
$ok = 1;
}
}
}
if ($ok == 0) {
if ($recheck == 4) {
die("Error - could not find session in retrived IpTable data");
}
sleep(2);
$recheck = $recheck + 1;
goto dhcptest;
}
$db = new SQLite3($database);
$db->exec('CREATE TABLE IF NOT EXISTS sessions (sessionid varchar(255), username varchar (255), clientip varchar (255), inputoctets varchar (255), ' . 'outputoctets varchar (255), framedip varchar (255), nasip varchar (255), nasport varchar (255), acctstarttime varchar (255), ' . 'acctsessiontime varchar (255), PRIMARY KEY(sessionid))');
$query = $db->escapeString('INSERT OR REPLACE INTO sessions (sessionid, username, clientip, inputoctets, outputoctets, framedip, nasip, nasport, acctstarttime, acctsessiontime) VALUES ("' . $sessid . '","' . $result["User Name (Authentication)"] . '","' . $result["Client IP Address"] . '",NULL,NULL,"' . $framedip . '","' . $result["Server IP Address (Reported)"] . '","' . $result["Server Port (Reported)"] . '","' . $result["Connection Started at"] . '",NULL)');
$db->exec($query);
$sessid = $db->escapeString($sessid);
$results = $db->querySingle("SELECT * FROM sessions WHERE sessionid = '" . $sessid . "'", true);
$tmpfname = tempnam($tmpdir, "acctstarttmp_");
$handle = fopen($tmpfname, "w");
$packet = "Service-Type = Framed-User" . "\n" . "Framed-Protocol = PPP" . "\n" . "NAS-Port = " . $results['nasport'] . "\n" . "NAS-Port-Type = Async" . "\n" . "User-Name = '" . $results['username'] . "'" . "\n" . "Calling-Station-Id = '" . $results['clientip'] . "'" . "\n" . "Called-Station-Id = '" . $results['nasip'] . "'" . "\n" . "Acct-Session-Id = '" . $sessid . "'" . "\n" . "Framed-IP-Address = " . $results['framedip'] . "\n" . "Acct-Authentic = RADIUS" . "\n" . "Event-Timestamp = " . time() . "\n" . "Acct-Status-Type = Start" . "\n" . "NAS-Identifier = '" . $results['nasip'] . "'" . "\n" . "Acct-Delay-Time = 0" . "\n" . "NAS-IP-Address = " . $results['nasip'] . "\n";
fwrite($handle, $packet);
fclose($handle);
exec("radclient " . $radiussrv . ":" . $radiusport . " acct " . $radiuspass . " -f " . $tmpfname);
unlink($tmpfname);
$db->close();
}
示例6: getStats
public function getStats($playerName)
{
$playerName = $this->db->escapeString(trim(strtolower($playerName)));
$result = $this->db->query("SELECT * FROM tntstats WHERE name = '" . $playerName . "'");
if ($result instanceof \SQLiteResult) {
$assoc = $result->fetch(SQLITE_ASSOC);
if (isset($assoc["name"]) and $assoc["name"] === $playerName) {
return $assoc;
}
}
return null;
}
示例7: missing_files_from_directory
/**
* Checks which files of a directory are missing in a SQLite3 database and returns a list of them.
*
* @arg dir The directory for which to check
* @arg dbfile The file containing the database
* @arg table The table name of the database
* @arg col The column containing the filenames
* @arg enckey The encryption key used for the database
* @returns A list of files missing from the database, or an empty list
*/
function missing_files_from_directory($dir, $dbfile, $table, $col, $enckey = NULL)
{
$missing = array();
$dirscan = scandir($dir, SCANDIR_SORT_ASCENDING);
if ($dirscan == false) {
// Either $dir is not a directory or scandir had no success
return $missing;
}
try {
if (is_string($enckey)) {
$db = new SQLite3($dbfile, SQLITE3_OPEN_READONLY, $enckey);
} else {
$db = new SQLite3($dbfile, SQLITE3_OPEN_READONLY);
}
} catch (Exception $e) {
// Database could not be opened; return empty array
return $missing;
}
foreach ($dirscan as $file) {
if (is_dir($file) || is_link($file)) {
// Filtering out directories (. and ..) and links {
continue;
}
if ($db->querySingle("SELECT EXISTS(SELECT * FROM " . $table . " WHERE " . $col . " = '" . SQLite3::escapeString($file) . "');")) {
// if an entry exists, returns TRUE, otherwise FALSE; invalid or failing queries return FALSE
continue;
}
// entry does not exist; add to array
$missing[] = $file;
}
$db->close();
sort($missing, SORT_LOCALE_STRING | SORT_FLAG_CASE);
return $missing;
// sort based on the locale, case-insensitive
}
示例8: test_input
function test_input($data)
{
$data = trim($data);
$data = stripslashes($data);
$data = htmlspecialchars($data);
return SQLite3::escapeString($data);
}
示例9: writeEvent
function writeEvent($timestamp, $device, $latitude, $longitude, $message)
{
$this->checkValues($timestamp, $device, $latitude, $longitude, $message);
$this->open();
$query = "INSERT INTO " . AzimutDatabase::TABLE_EVENTS . "('" . AzimutDatabase::FIELD_TIMESTAMP . "', '" . AzimutDatabase::FIELD_DEVICE . "', '" . AzimutDatabase::FIELD_LATITUDE . "', '" . AzimutDatabase::FIELD_LONGITUDE . "', '" . AzimutDatabase::FIELD_MESSAGE . "') " . "VALUES(" . $timestamp . ", '" . SQLite3::escapeString($device) . "', " . $latitude . ", " . $longitude . ", '" . SQLite3::escapeString($message) . "')";
return $this->database->exec($query);
}
示例10: cleanup
/**
* Cleanup cache
*
* Check if the current cache size exceeds the given requested cache size.
* If this is the case purge all cache items from the cache until the cache
* is only filled up to $rate percentage.
*
* @param int $size
* @param flaot $rate
* @return void
*/
public function cleanup($size, $rate)
{
// Check if overall cache size exceeds cache limit
$result = $this->db->query('SELECT SUM( size ) as size FROM metadata');
$cacheSize = $result->fetchArray(SQLITE3_NUM);
$cacheSize = $cacheSize[0];
$result->finalize();
if ($cacheSize <= $size) {
// Cache size does not exceed cache value, so we can exit
// immediately.
return false;
}
// Otherwise clear cache values, until we pass the lower size border
$maxSize = $size * $rate;
$result = $this->db->query('SELECT path, size FROM metadata ORDER BY accessed ASC');
$removed = array();
do {
$row = $result->fetchArray(SQLITE3_ASSOC);
$cacheSize -= $row['size'];
unlink($this->root . ($removed[] = $row['path']));
} while ($cacheSize > $maxSize);
$result->finalize();
// Remove entries from database
foreach ($removed as $nr => $value) {
$removed[$nr] = "'" . $this->db->escapeString($value) . "'";
}
$this->db->query('DELETE FROM metadata WHERE path IN ( ' . implode(', ', $removed) . ' )');
}
示例11: upsert
public function upsert($target, $filename, $content)
{
if ($this->noop) {
return;
}
$hash = $this->calculateHash($content);
$this->db->exec('REPLACE INTO cache VALUES ("' . SQLite3::escapeString($target) . '","' . SQLite3::escapeString($filename) . '", "' . SQLite3::escapeString($hash) . '")');
}
示例12: gvar
function gvar($ar)
{
if (isset($_POST[$ar]) && $_POST[$ar] !== '') {
return "'" . SQLite3::escapeString($_POST[$ar]) . "'";
} else {
return 'NULL';
}
}
示例13: query
/**
* Run a query on the database;
* @param string $query
* @return boolean TRUE on success
*/
public function query($query)
{
$sqlite = new SQLite3($this->path);
// escape query
$query = $sqlite->escapeString($query);
// run it and return result
return $sqlite->query($query);
}
示例14: get_credentials
function get_credentials($user_id)
{
$db = init_db();
$user_id = SQLite3::escapeString(strip_tags($user_id));
$query = $db->query("select * from credentials where userid = '{$user_id}'");
$row = $query->fetchArray(SQLITE3_ASSOC);
return $row['credentials'];
}
示例15: clearData
function clearData($data)
{
$data = stripslashes($data);
//видаляє екранування символів, повертає рядок з вирізаними зворотніми слешами
$data = strip_tags($data);
//видаляє HTML і PHP-теги з рядка
$data = trim($data);
//видаляє пробіли (або інші символи) з початку і кінця рядка
$data = SQLite3::escapeString($data);
//екранує спецсимволи в рядку для використання в запиті
return $data;
}