Exemple #1
1
 protected function _exec($sql)
 {
     if (!$this->_db->exec($this->_sql($sql))) {
         // TODO send error message to out
         $this->_out->stop("Sqlite exec error");
     }
 }
 /**
  *
  * Constructor for RegisterVisitor class
  * @param \SQLite3 $db: SQLite3 Database object
  *
  */
 public function __construct($db)
 {
     $this->db = $db;
     $this->db->exec('CREATE TABLE IF NOT EXISTS visitor (vid TEXT, ip TEXT, httpUserAgent TEXT, dateVisited INTEGER, PRIMARY KEY(vid, ip))');
     $this->visitorID = $this->generateToken();
     $this->ip = $this->get_ip();
 }
 /**
  * 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;
 }
Exemple #4
0
 public function mainAction()
 {
     $this->dbconf = Phalcon\DI::getDefault()->getConfig()->database;
     $file = $this->getDI()->getConfig()->dirs->config . DIRECTORY_SEPARATOR . 'schema' . DIRECTORY_SEPARATOR . $this->dbconf->adapter . '.sql';
     $this->schema = realpath($file);
     if ($this->schema === false) {
         throw new \Exception('Unsupported database adapter: ' . $this->dbconf->adapter);
     }
     echo "{$this->dbconf->adapter}\n";
     echo $this->dropDatabase();
     switch ($this->dbconf->adapter) {
         case 'mysql':
             echo $this->createDatabase();
             echo $this->loadSchema();
             echo $this->loadFixtures();
             break;
         case 'sqlite':
             $dbfile = $this->di->getConfig()->dirs->data . DIRECTORY_SEPARATOR . $this->di->get('config')->database->dbname . '.sqlite';
             $db = new SQLite3($dbfile);
             chmod($dbfile, 0664);
             $db->createFunction('MD5', 'md5');
             $db->exec(file_get_contents($this->schema));
             $db->exec(file_get_contents(preg_replace('/sqlite.sql$/', 'fixtures.sql', $this->schema)));
             break;
         default:
             throw new \Exception('Unsupported database adapter: ' . $this->dbconf->adapter);
             break;
     }
 }
 public function __construct($namespace = null)
 {
     if (!extension_loaded('sqlite3')) {
         throw new Exception('sqlite3 extension not loaded');
     }
     // force an alphanumeric namespace
     if ($namespace and !preg_match('/^[a-z0-9]+$/i', $namespace)) {
         throw new Exception('$namespace must be alphanumeric');
     }
     // get a nice filepath for the database
     $file = VAR_DIR . '/index' . $namespace . '.sqlite';
     // create the database if needed
     if (!file_exists($file)) {
         $db = new SQLite3($file);
         // make the map of tags to ids -- forcing the relationship to be unique
         $db->exec("CREATE TABLE map (id TEXT,tag TEXT, PRIMARY KEY (id,tag))");
         // make the object store
         $db->exec("CREATE TABLE objects (id TEXT PRIMARY KEY,object BLOB)");
         // indicies are created on the destructor for performance reasons
     } else {
         $db = new SQLite3($file);
     }
     // not running a bank, so don't care if a power failure causes corruption
     $db->exec("PRAGMA journal_mode = OFF");
     $db->exec("PRAGMA synchronous = OFF");
     // do everything in a batch for speed
     // this is particularly useful for indexing
     $db->exec("BEGIN TRANSACTION");
     $this->db = $db;
     $this->file = $file;
     $this->namespace = $namespace;
 }
Exemple #6
0
 /**
  * Query
  * 
  * @param mixed $query
  */
 function sql_query($query)
 {
     if (empty($query)) {
         core::dprint('Empty sql_query call');
         return false;
     }
     if (is_array($query)) {
         $query = vsprintf($query[0], array_slice($query, 1));
     }
     $query = trim($query);
     if (empty($query)) {
         return false;
     }
     if (!$this->_connect()) {
         return false;
     }
     ++$this->_counter;
     $this->_sqlite_fixes($query);
     $this->_last_query = $query;
     $is_select = preg_match('@^(SELECT|PRAGMA)@i', $query);
     $microtime = microtime(1);
     // how the f**k to catch errors in query?
     $this->query_result = $is_select ? @$this->_connect_id->query($query) : @$this->_connect_id->exec($query);
     $this->_last_query_time = microtime(1) - $microtime;
     core::dprint(array('[SQL%0d|%.5f : %s', $this->_counter, $this->_last_query_time, $query), core::E_SQL);
     if (!$this->query_result) {
         $err = $this->sql_error();
         core::dprint('[SQL FAIL] ' . $err['message'] . ' : ' . $err['code'], core::E_SQL);
     }
     return $this->query_result;
 }
    public function OpenLogFile()
    {
        $db = null;
        $filename = $this->logdir . "/" . $this->logfile;
        if (!file_exists($this->logdir)) {
            mkdir($this->logdir, 0755, true);
        }
        $db = new SQLite3($filename);
        $sql = <<<SQL
CREATE TABLE IF NOT EXISTS account_attempt (
  time_attempted date not null default CURENT_TIMESTAMP,
  username text not null default '',
  email text not null default '',
  ip text not null default '',
  trigger text not null default '',
  confidence float not null default 0.0,
  accepted text default 'Y',
  verified text default 'N',
  primary key (time_attempted, username, email, ip)
)
SQL;
        $db->exec($sql);
        $sql = <<<IDXSQL
CREATE INDEX IF NOT EXISTS account_verification
ON account_attempt (accepted, verified)
IDXSQL;
        $db->exec($sql);
        return $db;
    }
Exemple #8
0
 public function gc($maxlifetime)
 {
     $stmt = $this->sdb->prepare('DELETE FROM dalmp_sessions WHERE expiry < :expiry');
     $stmt->bindValue(':expiry', time(), SQLITE3_INTEGER);
     $stmt->execute();
     return $this->sdb->exec('VACUUM');
 }
function main()
{
    global $G;
    message("PHP testing sandbox (%s) version %s", $G['ME'], VERSION);
    try {
        $db = new SQLite3(DATABASE);
        $db->exec('DROP TABLE IF EXISTS t');
        $db->exec('CREATE TABLE t (a, b, c)');
        message('Table t sucessfully created');
        $sth = $db->prepare('INSERT INTO t VALUES (?, ?, ?)');
        $sth->bindValue(1, 'a');
        $sth->bindValue(2, 'b');
        $sth->bindValue(3, 'c');
        $sth->execute();
        $sth->bindValue(1, 1);
        $sth->bindValue(2, 2);
        $sth->bindValue(3, 3);
        $sth->execute();
        $sth->bindValue(1, 'one');
        $sth->bindValue(2, 'two');
        $sth->bindValue(3, 'three');
        $sth->execute();
        $sth = $db->prepare('SELECT * FROM t');
        $result = $sth->execute();
        while ($row = $result->fetchArray(SQLITE3_ASSOC)) {
            message('%s, %s, %s', $row['a'], $row['b'], $row['c']);
        }
    } catch (Exception $e) {
        message($e->getMessage());
    }
}
 public static function setUpBeforeClass()
 {
     // Create the test DB.
     self::$dbConnection = Database::getConnection();
     $schemaPath = APPLICATION_PATH . '/../data/' . MerchantApplication::app()->getConfig()->db->schema;
     self::$dbConnection->exec(file_get_contents($schemaPath));
 }
Exemple #11
0
function ConvertDB($fname)
{
    //	echo "=> {$fname}\n";
    if (!file_exists($fname)) {
        exit(10);
    }
    $db = new SQLite3('base.sqlite');
    $db->exec("pragma synchronous = off;");
    $tablename = pathinfo($fname, PATHINFO_FILENAME);
    $pdx = new Paradox();
    $pdx->Open($fname);
    $db->exec(createdb_schema($tablename, $pdx->GetSchema()));
    $db->exec('DELETE FROM ' . $tablename);
    if ($records = $pdx->GetNumRows()) {
        $schema = $pdx->GetSchema();
        //		print_r($schema);
        for ($rec = 0; $rec < $records; $rec++) {
            $pdx->GetRow($rec);
            //			if ($rec > 2) break;
            $query = 'INSERT INTO `' . $tablename . '` VALUES (';
            $values = '';
            foreach ($pdx->row as $fieldName => $value) {
                switch ($schema[$fieldName]['type']) {
                    case 1:
                        $value = brackets(iconv('windows-1251', 'UTF-8', $value));
                        break;
                    case 2:
                        $value = brackets($pdx->GetStringfromDate($value));
                        break;
                    case 21:
                        $value = brackets($pdx->GetStringfromTimestamp($value));
                        break;
                    case 4:
                        $value = (int) $value;
                        break;
                    case 6:
                        $value = (double) $value;
                        break;
                    case 9:
                        $value = (int) $value;
                        break;
                    case 13:
                        $value = "X" . brackets(bin2hex($value));
                        break;
                    default:
                        $value;
                        break;
                }
                $values .= $value . ', ';
                //				print "{$schema[$fieldName]['type']}\t{$fieldName}\t{$value}\n";
            }
            $values = rtrim($values, ', ');
            $query .= $values . ");\n";
            //			print trim($query).PHP_EOL;
            $db->exec($query);
        }
        return true;
    }
    $pdx->Close();
}
 protected function InitDB()
 {
     $handle = new SQLite3($this->filename);
     $handle->exec("PRAGMA synchronous = OFF");
     $handle->exec("PRAGMA journal_mode = OFF");
     $handle->exec("PRAGMA cache_size = 1");
     return $handle;
 }
Exemple #13
0
 public function setUp()
 {
     $app = (require __DIR__ . '/../../../../src/app.php');
     $this->path = sys_get_temp_dir() . '/sismo.db';
     @unlink($this->path);
     $this->db = new \SQLite3($this->path);
     $this->db->busyTimeout(1000);
     $this->db->exec($app['db.schema']);
 }
Exemple #14
0
function createSqliteTestTable($tmp_sqlite)
{
    unlink($tmp_sqlite);
    $db = new SQLite3($tmp_sqlite);
    $db->exec("CREATE TABLE foo (bar STRING)");
    $db->exec("INSERT INTO foo VALUES ('ABC')");
    $db->exec("INSERT INTO foo VALUES ('DEF')");
    VS($db->lasterrorcode(), 0);
}
 public function deleteEntity($uniqueName)
 {
     list($type, $name) = explode("/", $uniqueName);
     if ($this->existsEntity($type, $name)) {
         $this->db->exec("DELETE FROM ents WHERE ent_type = '{$this->db->escapeString($type)}'\n\t\t\t\tAND ent_name = '{$this->db->escapeString($name)}';");
         $this->db->exec("DELETE FROM ent_accounts WHERE ent_type = '{$this->db->escapeString($type)}'\n\t\t\t\tAND ent_name = '{$this->db->escapeString($name)}';");
         $this->db->exec("DELETE FROM ent_loans WHERE ent_type = '{$this->db->escapeString($type)}'\n\t\t\t\tAND ent_name = '{$this->db->escapeString($name)}';");
     }
 }
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();
}
 public function __construct(EmailAuth $plugin)
 {
     $this->plugin = $plugin;
     if (!file_exists($this->plugin->getDataFolder() . "players.db")) {
         $this->database = new \SQLite3($this->plugin->getDataFolder() . "players.db", SQLITE3_OPEN_READWRITE | SQLITE3_OPEN_CREATE);
         $resource = $this->plugin->getResource("sqlite3.sql");
         $this->database->exec(stream_get_contents($resource));
         fclose($resource);
     } else {
         $this->database = new \SQLite3($this->plugin->getDataFolder() . "players.db", SQLITE3_OPEN_READWRITE);
     }
 }
 /**
  * @param string          $dbname database name
  * @param OutputInterface $output standard verbode output
  * @param boolean         $renew  if true delete and recreate database
  *
  * @throws \Exception
  */
 public function __construct($dbname, OutputInterface $output, $renew = false)
 {
     $this->fs = new Filesystem();
     $this->output = $output;
     $this->dbname = $dbname;
     if ($renew) {
         if ($this->fs->exists($this->dbname)) {
             $this->fs->remove($this->dbname);
         }
     }
     $this->db = new \SQLite3($this->dbname);
     if ($this->db->exec('PRAGMA encoding = "UTF-8";') === false) {
         $this->output->writeln($this->db->lastErrorCode() . " : " . $this->db->lastErrorMsg());
         throw new \Exception("cannot set encoding UTF-8");
     }
 }
Exemple #19
0
function get_db()
{
    global $authdb;
    $db = new SQLite3($authdb, SQLITE3_OPEN_READWRITE);
    $db->exec('PRAGMA foreign_keys = 1');
    return $db;
}
Exemple #20
0
 public static function getDB()
 {
     $con = new SQLite3('db/newsdb.db');
     $con->exec('PRAGMA foreign_keys = ON;');
     return $con;
     #return new SQLite3('../sqlite/newsdb.db.new');
 }
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();
}
function resetHighscore()
{
    $db = new SQLite3('pacman.db');
    $date = date('Y-m-d h:i:s', time());
    $db->exec('DROP TABLE IF EXISTS highscore');
    createDataBase($db);
}
Exemple #23
0
 /**
  * @return SQLite3
  */
 protected function db()
 {
     global $mudoco_conf;
     if (!$this->_db) {
         $this->_db = new SQLite3($mudoco_conf['MUDOCO_STORAGE_NONCE_SQLITE_FILE']);
         if ($this->_db) {
             if ($this->_db->busyTimeout(2000)) {
                 $this->_db->exec('CREATE TABLE IF NOT EXISTS nonce (cnonce VARCHAR(32) PRIMARY KEY, nonce VARCHAR(32), expire INTEGER, fingerprint VARCHAR(32));');
                 $this->_db->exec('CREATE INDEX IF NOT EXISTS idx_expire ON nonce(expire);');
                 $this->_db->exec('CREATE INDEX IF NOT EXISTS idx_nonce ON nonce(nonce);');
             }
             // !important : do not release busyTimeout()
         }
     }
     return $this->_db;
 }
Exemple #24
0
function anubisFILE($idmd5, $fileName)
{
    #Execute the Python Script
    #python /var/www/anubis/submit_to_anubis.py /var/www/mastiff/MD5/filename.VIR
    $command = 'python /var/www/anubis/submit_to_anubis.py -u ' . $anubisUser . ' -p ' . $anubisPass . ' "/var/www/mastiff/' . $idmd5 . '/' . $fileName . '"';
    $output = shell_exec($command);
    $anubisRes['out'] = $output;
    $pattern = '/https?\\:\\/\\/[^\\" ]+/i';
    preg_match($pattern, $output, $matches);
    #echo '<pre>';
    #	echo '$matches: ';
    #	var_dump($matches);
    #echo '</pre>';
    $anubisLink = $matches[0];
    $anubisLink = strstr($anubisLink, "\n", true);
    $anubisRes['link'] = $anubisLink;
    #Update the Database
    $db = new SQLite3('../mastiff/mastiff.db');
    $result = $db->exec('UPDATE mastiff SET anubis = "' . $anubisLink . '" WHERE md5 = "' . $idmd5 . '"');
    if (!$result) {
        $anubisRes['db'] = $db->lastErrorMsg();
    } else {
        $anubisRes['db'] = $db->changes() . ' Record updated successfully.';
    }
    return $anubisRes;
}
function caching($comics_id, $zip_path, $image_ext)
{
    $comic = zip_open($zip_path);
    if (!is_resource($comic)) {
        die("[ERR]ZIP_OPEN : " . $zip_path);
    }
    $inzip_path = "";
    $count = 0;
    $files = null;
    $db = new SQLite3(DB);
    $db->exec("BEGIN DEFERRED;");
    while (($entry = zip_read($comic)) !== false) {
        $inzip_path = zip_entry_name($entry);
        $cache_name = md5($zip_path . "/" . $inzip_path) . '.' . get_ext($inzip_path);
        // 画像か否か
        if (!is_image($inzip_path, $image_ext)) {
            continue;
        }
        $data = zip_entry_read($entry, zip_entry_filesize($entry));
        $filepath = CACHE . '/' . $cache_name;
        file_put_contents($filepath, $data);
        $count++;
        query("INSERT INTO images (comics_id, page, filepath) VALUES (" . $comics_id . ", " . $count . ", '" . $filepath . "')", $db);
    }
    zip_close($comic);
    query("UPDATE comics SET pages = " . $count . " WHERE id = " . $comics_id, $db);
    $db->exec("COMMIT;");
}
Exemple #26
0
 /**
  * Ends a transaction.
  *
  * @return Boolean
  */
 public function end_transaction()
 {
     $this->connect();
     if ($this->connected === TRUE) {
         return $this->sqlite3->exec('END TRANSACTION');
     }
     return FALSE;
 }
 /**
  * Execute several queries
  *
  * @param string $queries queries to run
  *
  * @throws Ruckusing_Exception
  * @return boolean
  */
 public function multi_query($queries)
 {
     $res = $this->sqlite3->exec($queries);
     if ($this->isError($res)) {
         throw new Ruckusing_Exception(sprintf("Error executing 'query' with:\n%s\n\nReason: %s\n\n", $queries, $this->lastErrorMsg()), Ruckusing_Exception::QUERY_ERROR);
     }
     return true;
 }
Exemple #28
0
 public function registerArea($first, $sec, $level, $price, $expectedY = 64, $rentTime = null, $expectedYaw = 0)
 {
     if (!$level instanceof Level) {
         $level = $this->getServer()->getLevelByName($level);
         if (!$level instanceof Level) {
             return false;
         }
     }
     $expectedY = round($expectedY);
     if ($first[0] > $sec[0]) {
         $tmp = $first[0];
         $first[0] = $sec[0];
         $sec[0] = $tmp;
     }
     if ($first[1] > $sec[1]) {
         $tmp = $first[1];
         $first[1] = $sec[1];
         $sec[1] = $tmp;
     }
     if ($this->checkOverlapping($first, $sec, $level)) {
         return false;
     }
     $price = round($price, 2);
     $centerx = (int) ($first[0] + round(($sec[0] - $first[0]) / 2));
     $centerz = (int) ($first[1] + round(($sec[1] - $first[1]) / 2));
     $x = (int) round($sec[0] - $first[0]);
     $z = (int) round($sec[1] - $first[1]);
     $y = 0;
     $diff = 256;
     $tmpY = 0;
     $lastBlock = 0;
     for (; $y < 127; $y++) {
         $b = $level->getBlock(new Vector3($centerx, $y, $centerz));
         $id = $b->getID();
         $difference = abs($expectedY - $y);
         if ($difference > $diff) {
             // Finding the closest location with player or something
             $y = $tmpY;
             break;
         } else {
             if ($id === 0 and $lastBlock !== 0 or $b->canBeReplaced()) {
                 $tmpY = $y;
                 $diff = $difference;
             }
         }
         $lastBlock = $id;
     }
     if ($y >= 126) {
         $y = $expectedY;
     }
     $meta = floor(($expectedYaw + 180) * 16 / 360 + 0.5) & 0xf;
     $level->setBlock(new Position($centerx, $y, $centerz, $level), Block::get(Item::SIGN_POST, $meta));
     $info = $this->property->query("SELECT seq FROM sqlite_sequence")->fetchArray(SQLITE3_ASSOC);
     $tile = new Sign($level->getChunk($centerx >> 4, $centerz >> 4, false), new CompoundTag(false, ["id" => new StringTag("id", Tile::SIGN), "x" => new IntTag("x", $centerx), "y" => new IntTag("y", $y), "z" => new IntTag("z", $centerz), "Text1" => new StringTag("Text1", ""), "Text2" => new StringTag("Text2", ""), "Text3" => new StringTag("Text3", ""), "Text4" => new StringTag("Text4", "")]));
     $tile->setText($rentTime === null ? "[PROPERTY]" : "[RENT]", "Price : {$price}", "Blocks : " . $x * $z * 128, $rentTime === null ? "Property #" . $info["seq"] : "Time : " . $rentTime . "min");
     $this->property->exec("INSERT INTO Property (price, x, y, z, level, startX, startZ, landX, landZ" . ($rentTime === null ? "" : ", rentTime") . ") VALUES ({$price}, {$centerx}, {$y}, {$centerz}, '{$level->getName()}', {$first['0']}, {$first['1']}, {$sec['0']}, {$sec['1']}" . ($rentTime === null ? "" : ", {$rentTime}") . ")");
     return [$centerx, $y, $centerz];
 }
Exemple #29
0
 public function createDatabase()
 {
     $db = new \SQLite3(Config::output_dir() . strtolower($this->getFormatName()) . $this->getExt());
     $db->exec('DROP TABLE IF EXISTS functions');
     $db->exec('DROP TABLE IF EXISTS params');
     $db->exec('DROP TABLE IF EXISTS notes');
     $db->exec('DROP TABLE IF EXISTS seealso');
     $db->exec('DROP TABLE IF EXISTS changelogs');
     $db->exec('PRAGMA default_synchronous=OFF');
     $db->exec('PRAGMA count_changes=OFF');
     $db->exec('PRAGMA cache_size=100000');
     $db->exec($this->createSQL());
     $this->db = $db;
 }
Exemple #30
-1
 public function doAuthenticication()
 {
     $LoginData = array(array('Username' => $this->SOAP_USERNAME, 'Userpass' => $this->SOAP_USERPASS));
     // Nun erfolgt der eigentliche Call der Funtion / GetAuthentificationToken
     try {
         $oResponse = $this->__soapCall('GetAuthentificationToken', $LoginData);
     } catch (SoapFault $sf) {
         print_r("Es kam zu einem Fehler beim Call GetAuthentificationToken<br>");
         print_r($sf->getMessage());
     }
     if ($oResponse->Success == true) {
         // Der Abruf hat erfolgreich UserID und Token zurückgeliefert.
         // Der Token ist bis 00:00:00 Uhr eines Tages gültig und muss daher nicht
         $UserID = $oResponse->UserID;
         $Token = $oResponse->Token;
         // Bei erfolg ab in die Datenbank
         $timestamp = time();
         $db = new SQLite3(APPLICATION_PATH . "/FRAMEWORK/STORAGE/soapdb.db");
         $db->exec("INSERT INTO token (id, token, timestamp, user) VALUES ('{$UserID}', '{$Token}', '{$timestamp}', '{$this->SOAP_USERNAME}')");
         // Mit diesen Daten kann nun der SOAP-Header erzeugt und hinzugefügt werden
         $this->createSoapHeader($UserID, $Token);
     } else {
         print_r("Es ist folgender Fehler aufgetreten : " . $oResponse->ErrorMessages->item[0]->Message);
     }
 }