コード例 #1
0
ファイル: edit_car_php.php プロジェクト: trullarn/php
function getCars($query)
{
    $db = new SQLite3('car.db');
    $results = $db->query($query);
    echo "<table class=\"search-results\">";
    echo "<th>Reg nummer</th>";
    echo "<th>Märke</th>";
    echo "<th>Modell</th>";
    echo "<th>Pris</th>";
    echo "<th>Antal mil</th>";
    echo "<th>Årsmodell</th>";
    echo "<th>Redigera</th>";
    $numRows = 0;
    while ($row = $results->fetchArray()) {
        $numRows++;
    }
    if ($numRows === 0) {
        echo "<tr><td colspan=\"8\">Inga resultat för: \"" . $_POST['search'] . "\"</td></tr>";
    } else {
        while ($row = $results->fetchArray()) {
            echo "<tr>\n                <td class=\"car-regnr\"><a data-id=\"{$row['id']}\" href=\"#\" class=\"car-info\">{$row['regnr']}</td>\n                <td class=\"car-brand\">{$row['brand']}</td>\n                <td class=\"car-model\">{$row['model']}</td>\n                <td class=\"car-price\">{$row['price']}</td>\n                <td class=\"car-milage\">{$row['milage']}</td>\n                <td class=\"car-year\">{$row['year']}</td>\n                <td class=\"car-edit-link\"><a data-id=\"{$row['id']}\" href=\"#\" class=\"car-info\">Redigera</a></td>\n                </tr>";
        }
        echo "</table>";
    }
    $db->close();
}
コード例 #2
0
 /**
  * create a new database
  *
  * @param string $name    name of the database that should be created
  * @param array  $options array with charset info
  *
  * @return mixed MDB2_OK on success, a MDB2 error on failure
  * @access public
  */
 function createDatabase($name, $options = array())
 {
     $datadir = OC_Config::getValue("datadirectory", OC::$SERVERROOT . "/data");
     $db = $this->getDBInstance();
     if (PEAR::isError($db)) {
         return $db;
     }
     $database_file = $db->_getDatabaseFile($name);
     if (file_exists($database_file)) {
         return $db->raiseError(MDB2_ERROR_ALREADY_EXISTS, null, null, 'database already exists', __FUNCTION__);
     }
     $php_errormsg = '';
     $database_file = "{$datadir}/{$database_file}.db";
     $handle = new SQLite3($database_file);
     if (!$handle) {
         return $db->raiseError(MDB2_ERROR_CANNOT_CREATE, null, null, isset($php_errormsg) ? $php_errormsg : 'could not create the database file', __FUNCTION__);
     }
     //sqlite doesn't support the latin1 we use
     //         if (!empty($options['charset'])) {
     //             $query = 'PRAGMA encoding = ' . $db->quote($options['charset'], 'text');
     //             $handle->exec($query);
     //         }
     $handle->close();
     return MDB2_OK;
 }
コード例 #3
0
/**
 * Get a list of venues which are whitin $distance of location ($lat, long)
 * and have a category similar to $keyword
 * 
 * returns list of venue information
 */
function locationKeywordSearch($lat, $long, $keyword, $distance, $limit = 25)
{
    $_SESSION['lat'] = $lat;
    $_SESSION['long'] = $long;
    $_SESSION['keyword'] = $keyword;
    global $databaseName;
    $db = new SQLite3($databaseName);
    // Attach methods haversineGreatCircleDistance,stringSimilarity to
    // Database engine so that we can use them in our query
    $db->createFunction("DISTANCE", "haversineGreatCircleDistance");
    $db->createFunction("SIMILARITY", "stringSimilarity");
    // Search query: get venue information for venues close to location, with categories most similar to the keyword/phrase
    $statement = $db->prepare('SELECT venueId, name, lat, long, categories, address, DISTANCE(lat, long) as distance, SIMILARITY(categories)' . " as similarity FROM Venues WHERE distance < :dist ORDER BY similarity DESC LIMIT :limit");
    // Bind some parameters to the query
    $statement->bindValue(':limit', $limit);
    $statement->bindValue(':dist', $distance, SQLITE3_INTEGER);
    // Obtain the venues from the db and put them in a list
    $qry = $statement->execute();
    $venues = [];
    while ($venue = $qry->fetchArray()) {
        $venues[] = $venue;
    }
    $db->close();
    return $venues;
}
コード例 #4
0
 public function read($params, AccountWriter $writer)
 {
     $args = new FormattedArgumentMap($params);
     $folder = $args->opt("i", "plugins/SimpleAuth");
     if (!is_dir($folder)) {
         throw new \InvalidArgumentException("Input database {$folder} not found or is not a directory");
     }
     $path = rtrim($folder, "/\\") . "/players.db";
     if (!is_file($path)) {
         return;
     }
     $this->setStatus("Opening database");
     $db = new \SQLite3($path);
     $result = $db->query("SELECT COUNT(*) AS cnt FROM players");
     $total = $result->fetchArray(SQLITE3_ASSOC)["cnt"];
     $result->finalize();
     $this->setStatus("Preparing data");
     $result = $db->query("SELECT name,registerdate,logindate,lastip,hash FROM players");
     $i = 0;
     while (is_array($row = $result->fetchArray(SQLITE3_ASSOC))) {
         $i++;
         $info = AccountInfo::defaultInstance($row["name"], $this->defaultOpts);
         $info->lastIp = $row["lastip"];
         $info->registerTime = $row["registerdate"];
         $info->lastLogin = $row["logindate"];
         $info->passwordHash = hex2bin($row["hash"]);
         $writer->write($info);
         $this->setProgress($i / $total);
     }
     $db->close();
 }
コード例 #5
0
function cleanup_listeners_othermounts($maxagelimitstamp_othermounts, $fingerprint, $mountpoint)
{
    $db = new SQLite3('load.db');
    $db->busyTimeout(100);
    $db->exec("DELETE FROM t_listeners WHERE timestamp < {$maxagelimitstamp_othermounts} AND fingerprint = '{$fingerprint}' AND mountpoint != '{$mountpoint}'");
    $db->close();
}
コード例 #6
0
/**
* 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
}
コード例 #7
0
function handle_admin()
{
    if (empty($_POST['admin_account']) == false && empty($_POST['admin_password']) == false) {
        $account = $_POST['admin_account'];
        $password = md5($_POST['admin_password']);
        //password: ccc95
        $file_path = "../sqlite/books_web.s3db";
        if (file_exists($file_path)) {
            $link = new SQLite3($file_path);
            $sql_cmd = "SELECT password FROM root_account WHERE password='******'";
            $result = $link->query($sql_cmd);
            $i = 0;
            $row = array();
            while ($res = $result->fetchArray(SQLITE3_ASSOC)) {
                $row[$i]['password'] = $res['password'];
                $i++;
            }
            if (count($row) != 0) {
                $_SESSION['root'] = "root";
                return "admin login success.";
            } else {
                return "admin login failed.";
            }
            $link->close();
        } else {
            return "cannot link database.";
        }
    } else {
        return "post error";
    }
}
コード例 #8
0
 /**
  * Zamknięcie połączenia z bazą danych
  *
  */
 public function close()
 {
     if (!empty($this->dbHandle)) {
         $this->dbHandle->close();
     }
     return true;
 }
コード例 #9
0
function save_pois($jsonStr, $dbname)
{
    //create or open the channel database
    $db = new SQLite3($dbname, SQLITE3_OPEN_READWRITE | SQLITE3_OPEN_CREATE);
    //create the POIs table
    $db->query("CREATE TABLE IF NOT EXISTS POIsM (id INTEGER PRIMARY KEY AUTOINCREMENT, title TEXT, description TEXT, phoneNumber TEXT, homepage TEXT, iconURL TEXT, thumbnailURL TEXT, imageURL TEXT,\n                videoURL TEXT, soundURL TEXT, modelURL TEXT, latitude REAL, longitude REAL, altitude REAL) ;");
    $db->query("DELETE FROM POIsM;");
    //required because we bulk-replace all POIs on updates to the channel
    $db->query("UPDATE SQLITE_SEQUENCE SET seq='0' WHERE name='POIsM';");
    //reset the id count to start from 1 again; Else, the id count starts from the previously used highest id for the table
    //Decode the json string to UTF-8 encoding as "json_decode" only works for UTF-8 encoding
    $poisJson = json_decode(utf8_decode($jsonStr));
    $objects = $poisJson->pois;
    //parse the input json for POI information
    foreach ($objects as $obj) {
        $description = "";
        $phoneNumber = "";
        $icon = "";
        $thumbnail = "";
        print_r($obj);
        $homepage = "";
        $imageUrl = "";
        $movieUrl = "";
        $soundUrl = "";
        //Check if attributes needed for POI are present in JSON
        if (isset($obj->description)) {
            $description = $obj->description;
        }
        if (isset($obj->phoneNumber)) {
            $phoneNumber = $obj->phoneNumber;
        }
        if (isset($obj->iconURL)) {
            $icon = $obj->iconURL;
        } else {
            $icon = "http://channels.excel.junaio.com/resources/icon_thumbnail.png";
        }
        if (isset($obj->thumbnailURL)) {
            $thumbnail = $obj->thumbnailURL;
        } else {
            $thumbnail = "http://channels.excel.junaio.com/resources/icon_thumbnail.png";
        }
        if (isset($obj->homepage)) {
            $homepage = $obj->homepage;
        }
        if (isset($obj->imageURL)) {
            $imageUrl = $obj->imageURL;
        }
        if (isset($obj->video)) {
            $movieUrl = $obj->video;
        }
        if (isset($obj->sound)) {
            $soundUrl = $obj->sound;
        }
        //insert each POI to the db
        $query = "INSERT INTO POIsM (title, description, phoneNumber, homepage, iconURL, thumbnailURL, imageURL, videoURL,\n        soundURL, modelURL, latitude, longitude, altitude) VALUES ('" . $obj->title . "', '" . $description . "',\n        '" . $phoneNumber . "', '" . $homepage . "', '" . $icon . "', '" . $thumbnail . "', '" . $imageUrl . "', '" . $movieUrl . "', '" . $soundUrl . "', '', '" . $obj->latitude . "', '" . $obj->longitude . "', '" . $obj->altitude . "');";
        $db->query($query);
    }
    $db->close();
}
コード例 #10
0
ファイル: SQLite3Connection.php プロジェクト: rubendgr/lunr
 /**
  * Disconnects from database.
  *
  * @return void
  */
 public function disconnect()
 {
     if ($this->connected !== TRUE) {
         return;
     }
     $this->sqlite3->close();
     $this->connected = FALSE;
 }
コード例 #11
0
ファイル: dbhelper.php プロジェクト: blckshrk/DressYourself
 public function findClotheById($id)
 {
     $db = new SQLite3($this->dbFileName);
     $data = $db->query(self::QUERY_BASE . ' WHERE ID_clothes = ' . $id);
     $arrayData = $this->SQLite2JSON($data);
     $db->close();
     return json_encode($arrayData);
 }
コード例 #12
0
function updateUserMeetingWithPoints($userlogin, $meetingname, $points)
{
    $db = new SQLite3("db/db.sqlite3");
    if (!$db) {
        echo $db->lastErrorMsg();
        return false;
    }
    $sql = "UPDATE userscurves SET points=\"{$points}\" WHERE userlogin='******' AND meetingname='{$meetingname}'";
    $ret = $db->exec($sql);
    if ($ret > 0) {
        $db->close();
        return true;
    } else {
        $db->close();
        return false;
    }
}
コード例 #13
0
ファイル: getinfo.php プロジェクト: sc4brain/ManageInventory
function getAll()
{
    $db = new SQLite3(DB_FILENAME);
    $result = $db->query("SELECT * FROM iventory");
    while ($record = $result->fetchArray()) {
        print $record['number'] . "<br />";
    }
    $db->close();
}
コード例 #14
0
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:"******" /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:"******" /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();
}
コード例 #15
0
function select($query)
{
    $db = new SQLite3(DB);
    $results = $db->query($query);
    if (!$results) {
        $db->close();
        return false;
    }
    $data = array();
    $count = 0;
    while ($row = $results->fetchArray(SQLITE3_ASSOC)) {
        foreach ($row as $column => $r) {
            $data[$count][$column] = $r;
        }
        $count++;
    }
    $db->close();
    return $data;
}
コード例 #16
0
 public function excutePreparedStatement($Text)
 {
     $db = new \SQLite3($this->sqliteFile);
     if ($Text) {
         $success = $db->exec($Text);
         $db->close();
         return SUCCESS;
     }
     return NOT_FOUND;
 }
コード例 #17
0
ファイル: config.php プロジェクト: bhargavz/WIPSTER
 function getSettings()
 {
     $db = new SQLite3('/var/www/admin/admin.db');
     $result = $db->query('SELECT * FROM admin WHERE id = 1');
     if (isset($result)) {
         while ($res = $result->fetchArray()) {
             #$_SESSION['size']=$res['size'];
             #$malwrRes['uuid']=$res['uuid'];
             $settingRes = array();
             $settingRes = $res;
             /*	remver
              * 	mastiffconf
              * 	mastiffpy
              * 	tridloc
              * 	malwrPlugin
              * 	malwrAPI
              *  critsPlugin
              *  critsPage
              *  critsLogin
              * 	threatanalyzerplugin
              * 	threatapi
              * 	threatbase
              * 	threatpage
              * 	threatargs
              * 	tasubpriority
              * 	tasubsandbox
              * 	tasubreanalyze
              * 	anubisuser
              * 	anubispass
              * 	wotapi
              * 	vtapi
              * 	googapi
              * 	gcsekey
              * 	gcsesig
              * 	gcsecx
              * 	gcsequery
              * 	autopbua
              * 	twitterapi
              * 	twittertoken
              * 	twitterquery
              * 	twitterconsec
              * 	twitteroauthsec
              */
         }
     }
     if (!$result) {
         $settingRes['db'] = $db->lastErrorMsg();
     } else {
         $settingRes['db'] = $db->changes() . ' Record updated successfully.';
     }
     $db->close();
     return $settingRes;
 }
コード例 #18
0
ファイル: checkupgrade.php プロジェクト: horald/phpmysync
function getactvers($pfad)
{
    $db = new SQLite3($pfad . 'joorgsqlite.db');
    $sql = "SELECT * FROM tblversion ORDER BY fldversion";
    $results = $db->query($sql);
    while ($row = $results->fetchArray()) {
        $arr = $row;
    }
    $versnr = $arr['fldversion'];
    $db->close();
    //  $versnr="0.0";
    return $versnr;
}
コード例 #19
0
ファイル: connectDB.php プロジェクト: scotthind/old-projects
/**
 *This function attempts to verify a user's priveleges and connect them to
 * the database.
 * @param type $db_path The path to the database.
 * @param type $privelege The user's access rights.
 * @return SQLite3 A handle to the database if priveleges are sufficient or false otherwise.
 */
function connect($db_path, $privelege)
{
    // Check to see that all parameters have been set
    if (!(isset($db_path, $privelege) && is_string($db_path) && is_string($privelege))) {
        die('Invalid parameters.');
    }
    $dbh = new SQLite3($db_path);
    // Check that the database was accessed succesffuly
    if (!$dbh) {
        die('Database cannot be accessed.');
    }
    // Query the database for the permissions of the current user
    $statement = $dbh->prepare('SELECT UserType FROM User WHERE Username=:name');
    if (!$statement) {
        $dbh->close();
        die('Query not recognized.');
    }
    $statement->bindParam(':name', $_SESSION['name'], SQLITE3_TEXT);
    $result = $statement->execute();
    if (!$result) {
        $statement->close();
        $dbh->close();
        die("Invalid query.");
    }
    $row = $result->fetchArray(SQLITE3_ASSOC);
    // If the user's account type does not have the priveleges required...
    if ($row['UserType'] != $privelege) {
        //If session not registered
        header("location:login.php?msg=You must have {$privelege} priveleges to access this page.");
        // Redirect to login.php page
        return false;
    } else {
        //Continue to current page
        header('Content-Type: text/html; charset=utf-8');
    }
    $result->finalize();
    $statement->close();
    return $dbh;
}
コード例 #20
0
ファイル: SqliteTable.php プロジェクト: Vibeosys/RorderWeb
 public function excutePreparedStatement($Text)
 {
     $db = new \SQLite3($this->sqliteFile);
     if ($Text) {
         try {
             $success = $db->exec($Text);
             $db->close();
             return $success;
         } catch (Exception $ex) {
             throw "sqlite database error";
         }
     }
     \Cake\Log\Log::error('Table insert script is not valid');
     return false;
 }
コード例 #21
0
function addPrintURL($printURL)
{
    $db = new SQLite3('data.db');
    if (!$db) {
        die;
    }
    $command = "INSERT INTO Queue VALUES(NULL,'{$printURL}')";
    $response = $db->exec($command);
    if (!$response) {
        die("Cannot add print to queue.");
    } else {
        echo "Print added to queue.";
    }
    $db->close();
}
コード例 #22
0
 public function actionAddProfile()
 {
     $session = \Yii::$app->session;
     $user = \Yii::$app->user->identity;
     $accountId = $user->getId();
     $newProfile = $session->get('newProfile');
     $db = new \SQLite3('flair');
     $tablename = "userProfiles";
     //$db->exec("DROP TABLE IF EXISTS $tablename");
     //CREATE TABLE userProfiles (ID INTEGER PRIMARY KEY AUTOINCREMENT, accountID VARCHAR(20), name VARCHAR(30), age INT(3), height VARCHAR(10), gender VARCHAR(10), sexuality VARCHAR(10), summary VARCHAR(300));
     $db->exec("INSERT INTO {$tablename}\n\t\t(accountID, name, age, height, gender, sexuality, summary)\n\t\t\tVALUES (\n\t\t\t'{$accountId}',\n\t\t\t'{$newProfile["name"]}',\n\t\t\t {$newProfile["age"]},\n\t\t\t'{$newProfile["height"]}',\n\t\t\t'{$newProfile["gender"]}',\n\t\t\t'{$newProfile["sexuality"]}',\n\t\t\t'{$newProfile["summary"]}'\n\t\t\t)");
     $db->close();
     unset($db);
     return $this->redirect('@web/index.php/profile/view-profile');
 }
コード例 #23
0
function squid_cp_read_db($file)
{
    $cpdb = array();
    $DB = new SQLite3($file);
    if ($DB) {
        $response = $DB->query("SELECT * FROM captiveportal");
        if ($response != FALSE) {
            while ($row = $response->fetchArray()) {
                $cpdb[] = $row;
            }
        }
        $DB->close();
    }
    return $cpdb;
}
コード例 #24
0
function addUserToMeeting($userlogin, $meetingName)
{
    global $errMsg;
    $db = new SQLite3("db/db.sqlite3");
    if (!$db) {
        echo $db->lastErrorMsg();
        return false;
    }
    $sql = "SELECT * FROM userscurves WHERE userlogin = \"{$userlogin}\" and meetingname=\"{$meetingName}\"";
    $ret = $db->query($sql);
    if ($row = $ret->fetchArray(SQLITE3_ASSOC)) {
        $errMsg = "There is already a meeting with this name.";
        return false;
    }
    $sql = "INSERT INTO userscurves VALUES (\"{$userlogin}\", \"{$meetingName}\", \"\")";
    $ret = $db->exec($sql);
    if ($ret > 0) {
        $db->close();
        return true;
    } else {
        $db->close();
        return false;
    }
}
コード例 #25
0
 public function actionNewUser()
 {
     $session = \Yii::$app->session;
     $newUser = $session->get('newUser');
     $db = new \SQLite3('flair');
     $tablename = "userAccounts";
     $alreadyExists = ProfileController::getUsername(0, $newUser["username"]);
     if ($alreadyExists) {
         $session->set("alreadyExists", true);
         return $this->redirect('@web/index.php/account');
     }
     //CREATE TABLE userAccounts (ID INTEGER PRIMARY KEY AUTOINCREMENT, username VARCHAR(30), password VARCHAR(20));
     $db->exec("INSERT INTO {$tablename}\n\t\t(username, password)\n\t\tVALUES ('{$newUser["username"]}', '{$newUser["password"]}')");
     $db->close();
     unset($db);
     return $this->redirect('@web/index.php/login/from-account');
 }
コード例 #26
0
ファイル: SQLite.php プロジェクト: nbari/DALMP
 /**
  * enqueue
  *
  * @param string $value
  * @return boolean
  */
 public function enqueue($value)
 {
     $sdb = new \SQLite3($this->filename);
     $sdb->busyTimeout(2000);
     if ($this->enc_key) {
         $sdb->exec(sprintf("PRAGMA key='%s'", $enc_key));
     }
     $stmt = $sdb->prepare('INSERT INTO queues VALUES (null, ?, ?, ?)');
     $stmt->bindValue(1, $this->queue_name, SQLITE3_TEXT);
     $stmt->bindValue(2, base64_encode($value), SQLITE3_TEXT);
     $stmt->bindValue(3, @date('Y-m-d H:i:s'), SQLITE3_BLOB);
     if (!$stmt->execute()) {
         throw new \ErrorException(sprintf('Could not save: [ %s ] on queue [ %s ] in [ %s ]', $value, $this->queue_name, $this->filename));
     }
     $sdb->busyTimeout(0);
     $sdb->close();
     return true;
 }
コード例 #27
0
ファイル: User.php プロジェクト: bishabosha/flair
 /**
  * Finds user by username
  *
  * @param  string      $username
  * @return static|null
  */
 public static function findByUsername($username)
 {
     $session = \Yii::$app->session;
     $db = new \SQLite3('flair');
     $tablename = "userAccounts";
     $result = array();
     $rowData = $db->query("SELECT * FROM userAccounts WHERE username='******'");
     $result = $rowData->fetchArray(SQLITE3_NUM);
     $accessToken = 'QWERTY6789!';
     $authKey = 'YUIOP34645654?';
     $id = $result[0];
     $username = $result[1];
     $password = $result[2];
     $user = array('id' => (string) $id, 'username' => $username, 'password' => $password, 'authKey' => $authKey, 'accessToken' => $accessToken);
     $db->close();
     unset($db);
     return new static($user);
 }
コード例 #28
0
function init_fixtures($temp)
{
    $queries = array('CREATE TABLE catalogue (cat_id INTEGER PRIMARY KEY, name VARCHAR NOT NULL, source_lang VARCHAR, target_lang VARCHAR, date_created INT, date_modified INT, author VARCHAR);', 'CREATE TABLE trans_unit (msg_id INTEGER PRIMARY KEY, cat_id INTEGER NOT NULL DEFAULT \'1\', id VARCHAR, source TEXT, target TEXT, comments TEXT, date_added INT, date_modified INT, author VARCHAR, translated INT(1) NOT NULL DEFAULT \'0\');', "INSERT INTO catalogue (cat_id, name) VALUES (1, 'messages.fr_FR')", "INSERT INTO catalogue (cat_id, name) VALUES (2, 'messages.it')", "INSERT INTO trans_unit (msg_id, cat_id, id, source, target, translated) VALUES (1, 1, 1, 'an english sentence', 'une phrase en français', 1)", "INSERT INTO trans_unit (msg_id, cat_id, id, source, target, translated) VALUES (2, 1, 2, 'another english sentence', 'une autre phrase en français', 1)");
    if (version_compare(PHP_VERSION, '5.3', '>')) {
        $db = new SQLite3($temp);
        foreach ($queries as $query) {
            $db->exec($query);
        }
        $db->close();
    } else {
        $db = sqlite_open($temp);
        foreach ($queries as $query) {
            sqlite_query($query, $db);
        }
        sqlite_close($db);
    }
    return sfMessageSource::factory('SQLite', 'sqlite://localhost/' . $temp);
}
コード例 #29
0
function verify_sqlite_file ($file) {
	// this function checks whether the file is OK. 
	// there might be better function for this task and this can be replaced later... 
	
//	error_log ( "checking file " . $file . "<br />");
	$db = new SQLite3($file,SQLITE3_OPEN_READONLY);
	
	// try to get table list 
	$results = $db->query("SELECT * FROM sqlite_master WHERE type='table';");
	$db->close();
	if ($results == false) {
		//print "This file is no good!<br />";
		return false;
	}
	else return true;
	//else while ($row = $results->fetchArray())     var_dump($row);
	
}
コード例 #30
0
function deleteQuestionnaires($ids)
{
    $db = new SQLite3("db/db.sqlite3");
    if (!$db) {
        echo $db->lastErrorMsg();
        return false;
    }
    foreach ($ids as $id) {
        $sql = "DELETE FROM questionnaires WHERE id={$id}";
        $ret = $db->query($sql);
    }
    foreach ($ids as $id) {
        $sql = "DELETE FROM comparisons WHERE questionnaireid={$id}";
        $ret = $db->query($sql);
    }
    $db->close();
    return $ret;
}