当前位置: 首页>>代码示例>>PHP>>正文


PHP SQLite3::escapeString方法代码示例

本文整理汇总了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;
}
开发者ID:bhargavz,项目名称:WIPSTER,代码行数:32,代码来源:urlFunctions.php

示例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;
 }
开发者ID:radypala,项目名称:maga-website,代码行数:39,代码来源:SqliteJournal.php

示例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) . "'";
 }
开发者ID:jsor,项目名称:dbal-sqlite3,代码行数:10,代码来源:Connection.php

示例4: quote

 public function quote($string)
 {
     if (!$this->connected) {
         $this->connect();
     }
     return $this->dbHandle->escapeString($string);
 }
开发者ID:PhanQuocTrung,项目名称:WeatherStation,代码行数:7,代码来源:SQLiteWrapper.php

示例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();
}
开发者ID:bytepoet,项目名称:softether-radacct,代码行数:56,代码来源:acctstart.php

示例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;
 }
开发者ID:EmreTr1,项目名称:TNTRun,代码行数:12,代码来源:SQLiteStatsProvider.php

示例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
}
开发者ID:jankohoener,项目名称:sqlite-scripts,代码行数:45,代码来源:missingfiles.php

示例8: test_input

function test_input($data)
{
    $data = trim($data);
    $data = stripslashes($data);
    $data = htmlspecialchars($data);
    return SQLite3::escapeString($data);
}
开发者ID:gerald30,项目名称:companybook,代码行数:7,代码来源:register1.php

示例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);
 }
开发者ID:essembeh,项目名称:azimut,代码行数:7,代码来源:AzimutDatabase.class.php

示例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) . ' )');
 }
开发者ID:johnkramlich,项目名称:php-change-coverage,代码行数:39,代码来源:sqlite.php

示例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) . '")');
 }
开发者ID:nipsongarrido,项目名称:php.tools,代码行数:8,代码来源:Cache.php

示例12: gvar

function gvar($ar)
{
    if (isset($_POST[$ar]) && $_POST[$ar] !== '') {
        return "'" . SQLite3::escapeString($_POST[$ar]) . "'";
    } else {
        return 'NULL';
    }
}
开发者ID:jamesthoughton,项目名称:web,代码行数:8,代码来源:submit.php

示例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);
 }
开发者ID:radekstepan,项目名称:Clubhouse,代码行数:13,代码来源:DbSqLite3.php

示例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'];
}
开发者ID:tis-innovation-park,项目名称:IoT-Integreen,代码行数:8,代码来源:util.php

示例15: clearData

 function clearData($data)
 {
     $data = stripslashes($data);
     //видаляє екранування символів, повертає рядок з вирізаними зворотніми слешами
     $data = strip_tags($data);
     //видаляє HTML і PHP-теги з рядка
     $data = trim($data);
     //видаляє пробіли (або інші символи) з початку і кінця рядка
     $data = SQLite3::escapeString($data);
     //екранує спецсимволи в рядку для використання в запиті
     return $data;
 }
开发者ID:nzhovniriv,项目名称:onlinestore,代码行数:12,代码来源:Comment.class.php


注:本文中的SQLite3::escapeString方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。