function getTags($data) { $db = new SQLiteDatabase('sql/imgorg.db'); $image = $data->image; $q = $db->query('SELECT t.text as text, t.id as id FROM Tags t INNER JOIN Images_Tags it ON t.id = it.tag_id WHERE it.image_id = "' . $image . '"'); return $q->fetchAll(); }
function createMusicDB() { $dbFileName = "../db/musicDatabase.db"; if ($db = new SQLiteDatabase($dbFileName)) { // first let the engine check table, and create it eventualy $q = @$db->query('CREATE TABLE IF NOT EXISTS albums (id int PRIMARY KEY ASC, title TEXT, artist TEXT, cover TEXT, PRIMARY KEY (id))'); } }
function step_1() { if (file_exists(DB_FILE) == true) { echo DB_FILE . " already exists, deleted\n"; unlink(DB_FILE); } $db = new SQLiteDatabase(DB_FILE); return $db->query("CREATE TABLE fuu (" . "\t\t\t id INTEGER PRIMARY KEY," . "\t\t\t insult TEXT," . "\t\t\t audio_file CHAR(255)," . "\t\t\t nb_view INTEGER," . "\t\t\t nb_play INTEGER" . "\t );"); }
function getDB() { $dbFile = "filter-demo.db"; $hasDB = file_exists($dbFile); $db = new SQLiteDatabase($dbFile); if (!$hasDB) { $db->query(readCreateSql()); } return $db; }
function open_db() { $db = new SQLiteDatabase("labels.db"); $q = $db->query('PRAGMA table_info(product)'); if ($q->numRows() == 0) { $db->query('create table product( id integer primary key, title varchar(255), subtitle varchar(255), url varchar(255), sku varchar(32))'); } return $db; }
/** * @param string * @return void * @throws SQLiteException */ protected function run($sql) { #CDUtils::printError('SQLiteDatabaseLogFilter->run(): '.$sql."\n"); if (!$this->db->queryExec($sql)) { throw new SQLiteException(sqlite_error_string($this->db->lastError())); } }
/** * @return bool|SQLiteDatabase * @throws Exception */ public function getSqlite() { // return existing object if ($this->_sqlite) { return $this->_sqlite; } // get the database name if (!$this->database) { $this->database = dirname(dirname(__FILE__)) . '/data/' . get_class($this) . '.db'; } // create the folder if (!file_exists(dirname($this->database))) { if (!mkdir(dirname($this->database), $this->mode['folder'], true)) { return false; } } // connect to the database $this->_sqlite = new SQLiteDatabase($this->database, $this->mode['file']); if (!$this->_sqlite) { throw new Exception(strtr('Unable to create sqlite database for {className}', array('{className}' => get_class($this)))); } // create the table if needed if (!$this->_sqlite->query("SELECT name FROM sqlite_master WHERE type='table' AND name='config'")->numRows()) { $this->sqlite->queryExec("CREATE TABLE config(config_key text UNIQUE NOT NULL PRIMARY KEY, config_value text)"); } return $this->_sqlite; }
function getConnection() { if (!$this->connection) { $this->connection = $this->openDB(); // Nahraj databázi if (filesize(self::$databasePath) == 0) { //$this->beginTransaction(); $this->connection->queryExec(file_get_contents(dirname(__FILE__) . "/setupDB.sql"), $error); if ($error) { throw new InvalidStateException("Can't create SQLite database: " . $error); } //$this->endTransaction(); } } return $this->connection; }
/** * Gets object from database * @param integer $feedbackId * @return object $Feedback */ function Get($flightId) { try { /* $Database = new PDO($GLOBALS['configuration']['pdoDriver'].':'.$GLOBALS['configuration']['sqliteDatabase']); $stmt = $Database->prepare("select * from schedule where id= ? LIMIT 1"); if ($stmt->execute(array($flightId))) { while ($row = $stmt->fetch()) { $this->flightId = $row['id']; $this->fstatus = $row['status']; $this->fdate = $row['date']; $this->route = $row['route']; $this->pax = $row['pax']; $this->tail = $row['tail']; $this->pilot = $row['pilot']; $this->client = $row['client']; $this->leaves = $row['leaves']; $this->returns = $row['returns']; $this->fuel = $row['fuel']; $this->notes = $row['notes']; } } return $this; */ //$dbname='../data/flights.sqlite'; //$mytable = 'schedule'; $dbname = DB_NAME; $mytable = DB_TABLE; $base = new SQLiteDatabase($dbname, 0666, $err); if ($err) { exit($err); } //read data from database $query = "select * from schedule where id= %d LIMIT 1"; $query = sprintf($query, $flightId); $results = $base->arrayQuery($query, SQLITE_ASSOC); $size = count($results); foreach ($results as $row) { $this->flightId = $row['id']; $this->fstatus = $row['status']; $this->fdate = $row['date']; $this->route = $row['route']; $this->pax = $row['pax']; $this->tail = $row['tail']; $this->pilot = $row['pilot']; $this->client = $row['client']; $this->leaves = $row['leaves']; $this->returns = $row['returns']; $this->fuel = $row['fuel']; $this->notes = $row['notes']; } return $this; } catch (Exception $e) { print "Error!: " . $e->getMessage() . "<br/>"; die; } }
public function select($filter) { $sql = "SELECT * FROM {$this->name} WHERE " . $this->filterToSql($filter); $res = self::$conn->query($sql); if ($res === false) { $error = self::$conn->errorInfo(); switch ($error[0]) { case 'HY000': throw new DataStoreNoTableError("Table [{$this->name}] doesn't exists in [{$sql}]"); break; default: throw new DataStoreError("Error {$error[2]} ({$error[0]}/{$error[1]}) in query {$sql}"); } return false; } return $res->fetch(); }
function getAllInfo($data) { $db = new SQLiteDatabase('sql/imgorg.db'); $res = $db->query('select * from Albums'); $json = array(); while ($o = $res->fetchObject()) { $q = $db->query('SELECT * FROM Images WHERE album_id = "' . $o->id . '"'); $qres = $q->fetchObject(); if ($qres) { $path = $qres->url; $o->exif = exif_read_data('../' . $path); $o->filename = $qres->filename; } $o->size = sizeof($q->fetchAll()); array_push($json, $o); } return $json; }
function hitcounter($url) { //error_reporting(6143); $hits = 0; if ($db = new SQLiteDatabase('/home/a3253051/db/hitcounter.db')) { $q = @$db->query("SELECT counter FROM rsshits WHERE url = '" . $url . "'"); if ($q === false) { $db->queryExec('CREATE TABLE rsshits (url TEXT, counter int)'); //$hits = 1; } else { $result = $q->fetchSingle(); $hits = intval($result); //$db->queryExec("INSERT INTO rsshits VALUES ('".$_GET['url']."',".$hits.")"); //$db->queryExec("UPDATE rsshits SET counter=".$hits." WHERE url='".$_GET['url']."'"); } } else { die($err); } return $hits; }
private function action() { if ($db = new SQLiteDatabase(_MINDSRC_ . '/mind3rd/SQLite/mind')) { $result = $db->query("SELECT * FROM user where login='******' AND pwd='" . sha1($this->pwd) . "' AND status= 'A'"); $row = false; while ($result->valid()) { $row = $result->current(); $_SESSION['auth'] = JSON_encode($row); $_SESSION['login'] = $row['login']; break; } if (!$row) { Mind::write('auth_fail', true); return false; } } else { die('Database not found!'); } return $this; }
function sqlite() { try { //create or open the database $database = new SQLiteDatabase('db.sqlite', 0666, $error); } catch (Exception $e) { die($error); } echo 'connected. </br>'; //add Movie table to database $query = 'CREATE TABLE IF NOT EXISTS Cryptoxi' . '(Id TEXT, Time INTEGER, Message TEXT)'; if (!$database->queryExec($query, $error)) { die($error); } //insert data into database $a = 'Id'; $b = 'Time'; $c = 'Message'; $query = "INSERT INTO Movies ('{$a}', '{$b}', '{$c}') " . 'VALUES ("Interstella 5555", "Daft Punk", 2003); '; if (!$database->queryExec($query, $error)) { die($error); } function select($database) { //read data from database $query = "SELECT * FROM Movies"; $tit = 'Title'; if ($result = $database->query($query, SQLITE_BOTH, $error)) { while ($row = $result->fetch()) { print "Title: {$row[$tit]} <br />" . "Director: {$row['Director']} <br />" . "Year: {$row['Year']} <br /><br />"; } } else { die($error); } } select($database); }
protected function Exec($query) { switch ($this->_driver) { case 'SQLITE': try { $this->_db->queryExec($query); } catch (SQLiteException $x) { Sobi::Error('cache', sprintf('SQLite error: %s', $x->getMessage()), SPC::WARNING, 0, __LINE__, __FILE__); } break; case 'PDO': $this->_db->exec($query); break; } }
<?php $list = <<<EOF AD,Andorra;AE,United Arab Emirates;AF,Afghanistan;AG,Antigua & Barbuda;AI,Anguilla;AL,Albania;AM,Armenia;AN,Netherlands Antilles;AO,Angola;AQ,Antarctica;AR,Argentina;AS,American Samoa;AT,Austria;AU,Australia;AW,Aruba;AZ,Azerbaijan;BA,Bosnia and Herzegovina;BB,Barbados;BD,Bangladesh;BE,Belgium;BF,Burkina Faso;BG,Bulgaria;BH,Bahrain;BI,Burundi;BJ,Benin;BM,Bermuda;BN,Brunei Darussalam;BO,Bolivia;BR,Brazil;BS,Bahama;BT,Bhutan;BU,Burma (no longer exists);BV,Bouvet Island;BW,Botswana;BY,Belarus;BZ,Belize;CA,Canada;CC,Cocos (Keeling) Islands;CF,Central African Republic;CG,Congo;CH,Switzerland;CI,Côte D'ivoire (Ivory Coast);CK,Cook Iislands;CL,Chile;CM,Cameroon;CN,China;CO,Colombia;CR,Costa Rica;CS,Czechoslovakia (no longer exists);CU,Cuba;CV,Cape Verde;CX,Christmas Island;CY,Cyprus;CZ,Czech Republic;DD,German Democratic Republic (no longer exists);DE,Germany;DJ,Djibouti;DK,Denmark;DM,Dominica;DO,Dominican Republic;DZ,Algeria;EC,Ecuador;EE,Estonia;EG,Egypt;EH,Western Sahara;ER,Eritrea;ES,Spain;ET,Ethiopia;FI,Finland;FJ,Fiji;FK,Falkland Islands (Malvinas);FM,Micronesia;FO,Faroe Islands;FR,France;FX,France, Metropolitan;GA,Gabon;GB,United Kingdom (Great Britain);GD,Grenada;GE,Georgia;GF,French Guiana;GH,Ghana;GI,Gibraltar;GL,Greenland;GM,Gambia;GN,Guinea;GP,Guadeloupe;GQ,Equatorial Guinea;GR,Greece;GS,South Georgia and the South Sandwich Islands;GT,Guatemala;GU,Guam;GW,Guinea-Bissau;GY,Guyana;HK,Hong Kong;HM,Heard & McDonald Islands;HN,Honduras;HR,Croatia;HT,Haiti;HU,Hungary;ID,Indonesia;IE,Ireland;IL,Israel;IN,India;IO,British Indian Ocean Territory;IQ,Iraq;IR,Islamic Republic of Iran;IS,Iceland;IT,Italy;JM,Jamaica;JO,Jordan;JP,Japan;KE,Kenya;KG,Kyrgyzstan;KH,Cambodia;KI,Kiribati;KM,Comoros;KN,St. Kitts and Nevis;KP,Korea, Democratic People's Republic of;KR,Korea, Republic of;KW,Kuwait;KY,Cayman Islands;KZ,Kazakhstan;LA,Lao People's Democratic Republic;LB,Lebanon;LC,Saint Lucia;LI,Liechtenstein;LK,Sri Lanka;LR,Liberia;LS,Lesotho;LT,Lithuania;LU,Luxembourg;LV,Latvia;LY,Libyan Arab Jamahiriya;MA,Morocco;MC,Monaco;MD,Moldova, Republic of;MG,Madagascar;MH,Marshall Islands;ML,Mali;MN,Mongolia;MM,Myanmar;MO,Macau;MP,Northern Mariana Islands;MQ,Martinique;MR,Mauritania;MS,Monserrat;MT,Malta;MU,Mauritius;MV,Maldives;MW,Malawi;MX,Mexico;MY,Malaysia;MZ,Mozambique;NA,Namibia;NC,New Caledonia;NE,Niger;NF,Norfolk Island;NG,Nigeria;NI,Nicaragua;NL,Netherlands;NO,Norway;NP,Nepal;NR,Nauru;NT,Neutral Zone (no longer exists);NU,Niue;NZ,New Zealand;OM,Oman;PA,Panama;PE,Peru;PF,French Polynesia;PG,Papua New Guinea;PH,Philippines;PK,Pakistan;PL,Poland;PM,St. Pierre & Miquelon;PN,Pitcairn;PR,Puerto Rico;PT,Portugal;PW,Palau;PY,Paraguay;QA,Qatar;RE,Réunion;RO,Romania;RU,Russian Federation;RW,Rwanda;SA,Saudi Arabia;SB,Solomon Islands;SC,Seychelles;SD,Sudan;SE,Sweden;SG,Singapore;SH,St. Helena;SI,Slovenia;SJ,Svalbard & Jan Mayen Islands;SK,Slovakia;SL,Sierra Leone;SM,San Marino;SN,Senegal;SO,Somalia;SR,Suriname;ST,Sao Tome & Principe;SU,Union of Soviet Socialist Republics (no longer exists);SV,El Salvador;SY,Syrian Arab Republic;SZ,Swaziland;TC,Turks & Caicos Islands;TD,Chad;TF,French Southern Territories;TG,Togo;TH,Thailand;TJ,Tajikistan;TK,Tokelau;TM,Turkmenistan;TN,Tunisia;TO,Tonga;TP,East Timor;TR,Turkey;TT,Trinidad & Tobago;TV,Tuvalu;TW,Taiwan, Province of China;TZ,Tanzania, United Republic of;UA,Ukraine;UG,Uganda;UM,United States Minor Outlying Islands;US,United States of America;UY,Uruguay;UZ,Uzbekistan;VA,Vatican City State (Holy See);VC,St. Vincent & the Grenadines;VE,Venezuela;VG,British Virgin Islands;VI,United States Virgin Islands;VN,Viet Nam;VU,Vanuatu;WF,Wallis & Futuna Islands;WS,Samoa;YD,Democratic Yemen (no longer exists);YE,Yemen;YT,Mayotte;YU,Yugoslavia;ZA,South Africa;ZM,Zambia;ZR,Zaire;ZW,Zimbabwe;ZZ,Unknown or unspecified country EOF; if ($db = new SQLiteDatabase('test.db')) { $q = @$db->query('SELECT * FROM countries LIMIT 0,1;'); if ($q === false) { $l = split(';', $list); $db->queryExec('CREATE TABLE countries (id int, code char, name char, PRIMARY KEY (id));'); foreach ($l as $k => $v) { $tmp = split(',', $v); $db->queryExec(sprintf('INSERT INTO countries VALUES (%s, "%s", "%s");', $k, $tmp[0], $tmp[1])); } } } else { die($err); } define('_HYGRID_TABLE_', 'countries'); define('_HYGRID_ALLOWED_TABLES', 'countries'); class hygrid { static $page, $rpp, $rows; function __construct() { $this->total = 0; $this->table = $_REQUEST['table'] ? $_REQUEST['table'] : _HYGRID_TABLE_; $this->page = $_REQUEST['page'] ? $_REQUEST['page'] : 1; $this->rpp = $_REQUEST['rpp'] ? $_REQUEST['rpp'] : false; // total }
public static function setUpDbSqlLite() { // create new database (OO interface) $db = new SQLiteDatabase("data/db.sqlite"); // create table foo and insert sample data $db->query("BEGIN;\n\t\t\t\tCREATE TABLE IF NOT EXISTS short_urls(id INTEGER PRIMARY KEY AUTOINCRIMENT, long_url CHAR(255), short_url CHAR(100), date_created DATETIME);\n\t\t\t\tINSERT INTO short_urls (long_url, short_url, date_created) VALUES('http://example.com/long','http://example.com/short', '2009-10-20 00:00:00');\n\t\t\t\tCOMMIT;"); // execute a query $result = $db->query("SELECT * FROM short_urls"); // iterate through the retrieved rows while ($result->valid()) { // fetch current row $row = $result->current(); print_r($row); // proceed to next row $result->next(); } // not generally needed as PHP will destroy the connection unset($db); }
} if (!is_dir('stats')) { mkdir('stats'); } include 'config.inc.php'; // Check for compatibility if (!version_compare(PHP_VERSION, '5.0.0', '>=')) { die("I need PHP version 5 or greater!\n"); } if (!class_exists('SQLiteDatabase')) { die("Cannot find PHP-SQLite extension!\n"); } if (!file_exists(PWS_DATABASE)) { die("The database file was not found!\n"); } $db = new SQLiteDatabase(PWS_DATABASE); /////////////////////// ENCRYPTED $protected = $db->query('SELECT encrypted FROM accesspoints WHERE encrypted = 1')->numRows(); $unprotected = $db->query('SELECT encrypted FROM accesspoints WHERE encrypted = 0')->numRows(); $total = $protected + $unprotected; $part_p = $protected / $total; $part_u = $unprotected / $total; $arc_p = $part_p * 360; $arc_u = $part_u * 360; $image = imagecreatetruecolor(380, 202); // allocate some solors $white = imagecolorallocate($image, 0xff, 0xff, 0xff); $darkred = imagecolorallocate($image, 0x99, 0x0, 0x0); $darkgreen = imagecolorallocate($image, 0x0, 0x99, 0x0); imagefill($image, 0, 0, $white); imagefilledarc($image, 100, 100, 200, 200, 0, $arc_p, $darkred, IMG_ARC_PIE);
function getInfo($data) { $db = new SQLiteDatabase("sql/imgorg.db"); $image = $data->image; $q = $db->query('SELECT url FROM Images WHERE id = "' . $image . '"'); $path = $q->fetchObject()->url; $ret = exif_read_data('../' . $path); return $ret; }
} $sura = $argv[1]; $ayah = $argv[2]; if ($argv[3]) { $width = $argv[3]; } } else { if (isset($_GET['sura']) && is_numeric($_GET['sura']) && isset($_GET['ayah']) && is_numeric($_GET['ayah'])) { $sura = $_GET['sura']; $ayah = $_GET['ayah']; if (isset($_GET['width']) && is_numeric($_GET['width'])) { $width = $_GET['width']; } } } $db = new SQLiteDatabase('./data/sura_ayah_page_text.sqlite2.db'); if (!$db) { die("died"); } $q = @$db->query("select page, text from sura_ayah_page_text where sura = {$sura} and ayah = {$ayah}"); $result = $q->fetch(); $page = $result[page]; $text = $result[text]; if ($page == 1 || $page == 2) { $fontSize = 32; } else { $fontSize = 24; } //$fontSize = 1.6*$fontSize; // seems to overflow i.e. wrapping isn't perfect $font = './data/fonts/QCF_P' . sprintf('%03d', $page) . '.TTF'; $words = split(';', $text);
<?php $database = new SQLiteDatabase('c:/copy/library.sqlite'); $sql = "CREATE TABLE 'books' ('bookid' INTEGER PRIMARY KEY, \r\n\t\t'authorid' INTEGER,\r\n\t\t'title' TEXT,\r\n\t\t'ISBN' TEXT,\r\n\t\t'pub_year' INTEGER,\r\n\t\t'available' INTEGER)"; if ($database->queryExec($sql, $error) == FALSE) { echo "Create Failure - {$error} <br />"; } else { echo "Table Books was created <br />"; } $sql = <<<SQL INSERT INTO books ('authorid', 'title', 'ISBN', 'pub_year', 'available') VALUES (1, 'The Two Towers', '0-261-10236-2', 1954, 1); INSERT INTO books ('authorid', 'title', 'ISBN', 'pub_year', 'available') VALUES (1, 'The Return of The King', '0-261-10237-0', 1955, 1); INSERT INTO books ('authorid', 'title', 'ISBN', 'pub_year', 'available') VALUES (2, 'Roots', '0-440-17464-3', 1974, 1); \t\t INSERT INTO books ('authorid', 'title', 'ISBN', 'pub_year', 'available') VALUES (4, 'I, Robot', '0-553-29438-5', 1950, 1); \t\t\t\t INSERT INTO books ('authorid', 'title', 'ISBN', 'pub_year', 'available') VALUES (4, 'Foundation', '0-553-80371-9', 1951, 1); SQL; if ($database->queryExec($sql, $error) == FALSE) { echo "Insert Failure - {$error} <br />"; } else { echo "INSERT to Books - OK <br />"; }
<?php // open database $db = new SQLiteDatabase("./ip.db"); // begin transaction $db->query("BEGIN"); $fp = fopen("./ip-to-country.csv", "r"); $query_str = ''; while ($row = fgetcsv($fp, 4096)) { foreach ($row as $key => $val) { // secure data $row[$key] = sqlite_escape_string($val); } // check for existance of a country in db if (!($country_id = $db->singleQuery("SELECT id FROM country_data WHERE cc_code_2='{$row[2]}'"))) { // add new country if (!$db->query("INSERT INTO country_data \n\t\t\t(cc_code_2, cc_code_3, country_name) \n\t\t\tVALUES('{$row[2]}', '{$row[3]}', '{$row[4]}')")) { // fetch error $err_code = $db->lastError(); printf("Query Failed %d:%s\n", $err_code, sqlite_error_string($err_code)); exit; } // get ID for the last inserted row $country_id = $db->lastInsertRowid(); } $query_str .= "INSERT INTO ip_ranges \n\t\t\t(ip_start, ip_end, country_code)\n\t\t\tVALUES({$row[0]}, {$row[1]}, {$country_id});"; } // insert IP data via a chained query $db->query($query_str); // finalize transaction $db->query("COMMIT");
/** * Get log db * * @return SQLiteDatabase */ public function getPageLogDb() { $file = _BEAR_APP_HOME . '/logs/pagelog.sq3'; if (file_exists($file) === false) { $db = new SQLiteDatabase($file); $sql = <<<____SQL CREATE TABLE pagelog ( \t "log" text NOT NULL ); ____SQL; $db->queryExec($sql); } else { $db = new SQLiteDatabase($file); } if ($db === false) { throw new BEAR_Exception('sqlite error'); } return $db; }
$dbFile = 'db.sqlite'; error_log("\n\n" . '###### read from DB ' . $dbFile, 3, "demo-app.log"); // create table 'aloha' and insert sample data if SQLite dbFile does not exist if (!file_exists($dbFile)) { error_log("\n" . 'SQLite Database does not exist ' . $dbFile, 3, "demo-app.log"); try { $db = new SQLiteDatabase($dbFile, 0666, $error); $db->query("BEGIN;\n\t\t\tCREATE TABLE aloha (\n\t\t\t\tid INTEGER PRIMARY KEY,\n\t\t\t\tpageId CHAR(255),\n\t\t\t\tcontentId CHAR(255),\n\t\t\t\tcontent TEXT\n\t\t\t);\n\n\t\t\tINSERT INTO aloha \n\t\t\t\t(id, pageId, contentId, content)\n\t\t\tVALUES\n\t\t\t\t(NULL, NULL, NULL, 'Click to edit');\n\n\t\t\tCOMMIT;"); error_log("\n" . 'SQLite Database created ' . $dbFile, 3, "demo-app.log"); } catch (Exception $e) { die($error); } } else { // db already exists $db = new SQLiteDatabase($dbFile, 0666, $error); } // check if we have already a data set for this and save data // XSS handling required $pageId = sqlite_escape_string($_REQUEST['pageId']); $query = "SELECT * FROM aloha \n\tWHERE\n\t\tpageId = '" . $pageId . "';"; $result = $db->query($query, $error); $exists = false; $data = array(); while ($result->valid()) { $exists = true; $row = $result->current(); $data[] = $row; $result->next(); error_log("\n" . 'data available for page ' . $pageId, 3, "demo-app.log"); }
<!DOCTYPE html> <html> <?php $sqlitedb = new SQLiteDatabase('mydb.sqli'); $sqlReturn = $sqlitedb->query("SELECT * FROM members WHERE name = \"John\"");
# $curl_path = '/usr/bin/curl'; # Location of curl on your server. $per_page = 20; # Number of links to show per page. $codeset = 'abcdefghijklmnopqrstuvwxyz'; # Characters used to make up the short URL key. $domain = 'harm.es'; # # Administrator access, needed to save, edit and delete links. # You're on your own here; my solution so embarrassing that I'm not even going to include it. # Set this to true while you're playing around with it. # $is_admin = false; $links = array(); if ($db = new SQLiteDatabase('links')) { # # If a new link is being entered, insert it into the DB. # if ($_GET['save'] && $is_admin) { # # Insert the row. # $url = sqlite_escape_string($_GET['save']); $title = isset($_GET['title']) ? sqlite_escape_string($_GET['title']) : ''; $key = ''; $now = time(); $q = $db->query('INSERT INTO links (url, title, created, last_access) VALUES ("' . $url . '", "' . $title . '", ' . $now . ', ' . $now . ')'); if ($q === false) { create_table($db); $db->query('INSERT INTO links (url, title, created, last_access) VALUES ("' . $url . '", "' . $title . '", ' . $now . ', ' . $now . ')');
<?php $dbname = '../data/flights.sqlite'; $mytable = "schedule"; $base = new SQLiteDatabase($dbname, 0666, $err); if ($err) { exit($err); } $date = date("m/d/Y"); $query = "DELETE FROM {$mytable} WHERE date < '{$date}'"; $results = $base->queryexec($query); echo "Deleting the post with date lower than {$date}... <br><br>\n"; if ($results) { echo "<i>{$mytable}</i> updated.<br>\n"; header("Location: add.php"); } else { echo "Can't access {$mytable} table.<br>\n"; } echo "<hr>";
<?php /** * Инициализация структуры и данных БД. * * @author Sergey S. Nevmerzhitsky (http://koteg.moikrug.ru/), 25.01.2012 * @since 25.01.2012 */ $resource = new SQLiteDatabase(dirname(__FILE__) . '/../data/test.sqlite', 0666, $error); if (empty($resource)) { die("Cannot connect: {$error}"); } $sqls = array(); //$sqls[] = 'DROP TABLE foobar'; $sqls[] = <<<SQL CREATE TABLE foobar ( id INTEGER PRIMARY KEY ASC, name TEXT NOT NULL, foo TEXT NOT NULL, bar TEXT NOT NULL ) SQL; foreach ($sqls as $sql) { /* @var $result SQLiteResult */ $result = $resource->query($sql, SQLITE_ASSOC, $error); if (!$result) { die("Cannot execute query: {$error}"); } }
<?php /** * dG52 PHP SourceMod (SM) Plugin Updater * * @author Douglas Stridsberg * @url http://code.google.com/p/dg52-php-sm-plugin-updater/ * @email doggie52@gmail.com */ // Include the configuration include "config.php"; // Include the class include "class.php"; // Initiate database if ($preferredDatabase == "sqlite") { $db = new SQLiteDatabase("db.sqlite"); } elseif ($preferredDatabase == "mysql") { $socket = mysql_connect($mysqlHost, $mysqlUsername, $mysqlPassword) or die(mysql_error()); mysql_select_db($mysqlDatabase, $socket); } // If the form has not been submitted if (!isset($_GET['submit'])) { echo "<form method=\"GET\">\r\n\t\t\t\t<table>\r\n\t\t\t\t<tr><td>Plugin's exact name:</td><td><input type=\"text\" name=\"name\" value=\"" . $_GET['name'] . "\" /></td></tr>\r\n\t\t\t\t<tr><td>Plugin's forum URL:</td><td><input type=\"text\" name=\"url\" /></td></tr>\r\n\t\t\t\t<tr><td><input type=\"submit\" name=\"submit\" /></td></tr>\r\n\t\t\t\t</table>\r\n\t\t\t</form>"; } else { // Secure the input $name = secure_sql_input($_GET['name']); $url = secure_sql_input($_GET['url']); // Check whether the URL has the https protocol if (substr_count($url, "https", 0, 5) > 0) { // If it does have the https protocol we need to ensure it gets changed $url = preg_replace("/https/i", "http", $url);
<?php $invoice_id = intval($_GET['invoice_id']); $product_url = ''; $price_in_usd = 0; $price_in_btc = 0; $amount_paid_btc = 0; $amount_pending_btc = 0; try { //create or open the database $database = new SQLiteDatabase('db.sqlite', 0666, $error); } catch (Exception $e) { die($error); } //find the invoice form the database $query = "select price_in_usd, product_url, price_in_btc from Invoices where invoice_id = {$invoice_id}"; if ($result = $database->query($query, SQLITE_BOTH, $error)) { if ($row = $result->fetch()) { $product_url = $row['product_url']; $price_in_usd = $row['price_in_usd']; $price_in_btc = $row['price_in_btc']; } else { die('Invoice not found'); } } else { die($error); } //find the pending amount paid $query = "select SUM(value) as value from pending_invoice_payments where invoice_id = {$invoice_id}"; if ($result = $database->query($query, SQLITE_BOTH, $error)) { if ($row = $result->fetch()) {