db.php 22 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719
  1. <?php
  2. /**
  3. * PrivateBin
  4. *
  5. * a zero-knowledge paste bin
  6. *
  7. * @link https://github.com/PrivateBin/PrivateBin
  8. * @copyright 2012 Sébastien SAUVAGE (sebsauvage.net)
  9. * @license https://www.opensource.org/licenses/zlib-license.php The zlib/libpng License
  10. * @version 0.22
  11. */
  12. namespace PrivateBin\data;
  13. use Exception;
  14. use PDO;
  15. use PDOException;
  16. use PrivateBin\privatebin;
  17. use stdClass;
  18. /**
  19. * privatebin_db
  20. *
  21. * Model for DB access, implemented as a singleton.
  22. */
  23. class db extends AbstractData
  24. {
  25. /**
  26. * cache for select queries
  27. *
  28. * @var array
  29. */
  30. private static $_cache = array();
  31. /**
  32. * instance of database connection
  33. *
  34. * @access private
  35. * @static
  36. * @var PDO
  37. */
  38. private static $_db;
  39. /**
  40. * table prefix
  41. *
  42. * @access private
  43. * @static
  44. * @var string
  45. */
  46. private static $_prefix = '';
  47. /**
  48. * database type
  49. *
  50. * @access private
  51. * @static
  52. * @var string
  53. */
  54. private static $_type = '';
  55. /**
  56. * get instance of singleton
  57. *
  58. * @access public
  59. * @static
  60. * @param array $options
  61. * @throws Exception
  62. * @return privatebin_db
  63. */
  64. public static function getInstance($options = null)
  65. {
  66. // if needed initialize the singleton
  67. if(!(self::$_instance instanceof privatebin_db)) {
  68. self::$_instance = new self;
  69. }
  70. if (is_array($options))
  71. {
  72. // set table prefix if given
  73. if (array_key_exists('tbl', $options)) self::$_prefix = $options['tbl'];
  74. // initialize the db connection with new options
  75. if (
  76. array_key_exists('dsn', $options) &&
  77. array_key_exists('usr', $options) &&
  78. array_key_exists('pwd', $options) &&
  79. array_key_exists('opt', $options)
  80. )
  81. {
  82. // set default options
  83. $options['opt'][PDO::ATTR_ERRMODE] = PDO::ERRMODE_EXCEPTION;
  84. $options['opt'][PDO::ATTR_EMULATE_PREPARES] = false;
  85. $options['opt'][PDO::ATTR_PERSISTENT] = true;
  86. $db_tables_exist = true;
  87. // setup type and dabase connection
  88. self::$_type = strtolower(
  89. substr($options['dsn'], 0, strpos($options['dsn'], ':'))
  90. );
  91. $tableQuery = self::_getTableQuery(self::$_type);
  92. self::$_db = new PDO(
  93. $options['dsn'],
  94. $options['usr'],
  95. $options['pwd'],
  96. $options['opt']
  97. );
  98. // check if the database contains the required tables
  99. $tables = self::$_db->query($tableQuery)->fetchAll(PDO::FETCH_COLUMN, 0);
  100. // create paste table if necessary
  101. if (!in_array(self::_sanitizeIdentifier('paste'), $tables))
  102. {
  103. self::_createPasteTable();
  104. $db_tables_exist = false;
  105. }
  106. // create comment table if necessary
  107. if (!in_array(self::_sanitizeIdentifier('comment'), $tables))
  108. {
  109. self::_createCommentTable();
  110. $db_tables_exist = false;
  111. }
  112. // create config table if necessary
  113. $db_version = privatebin::VERSION;
  114. if (!in_array(self::_sanitizeIdentifier('config'), $tables))
  115. {
  116. self::_createConfigTable();
  117. // if we only needed to create the config table, the DB is older then 0.22
  118. if ($db_tables_exist) $db_version = '0.21';
  119. }
  120. else
  121. {
  122. $db_version = self::_getConfig('VERSION');
  123. }
  124. // update database structure if necessary
  125. if (version_compare($db_version, privatebin::VERSION, '<'))
  126. {
  127. self::_upgradeDatabase($db_version);
  128. }
  129. }
  130. else
  131. {
  132. throw new Exception(
  133. 'Missing configuration for key dsn, usr, pwd or opt in the section model_options, please check your configuration file', 6
  134. );
  135. }
  136. }
  137. return self::$_instance;
  138. }
  139. /**
  140. * Create a paste.
  141. *
  142. * @access public
  143. * @param string $pasteid
  144. * @param array $paste
  145. * @return bool
  146. */
  147. public function create($pasteid, $paste)
  148. {
  149. if (
  150. array_key_exists($pasteid, self::$_cache)
  151. ) {
  152. if(false !== self::$_cache[$pasteid]) {
  153. return false;
  154. } else {
  155. unset(self::$_cache[$pasteid]);
  156. }
  157. }
  158. $opendiscussion = $burnafterreading = false;
  159. $attachment = $attachmentname = '';
  160. $meta = $paste['meta'];
  161. unset($meta['postdate']);
  162. $expire_date = 0;
  163. if (array_key_exists('expire_date', $paste['meta']))
  164. {
  165. $expire_date = (int) $paste['meta']['expire_date'];
  166. unset($meta['expire_date']);
  167. }
  168. if (array_key_exists('opendiscussion', $paste['meta']))
  169. {
  170. $opendiscussion = (bool) $paste['meta']['opendiscussion'];
  171. unset($meta['opendiscussion']);
  172. }
  173. if (array_key_exists('burnafterreading', $paste['meta']))
  174. {
  175. $burnafterreading = (bool) $paste['meta']['burnafterreading'];
  176. unset($meta['burnafterreading']);
  177. }
  178. if (array_key_exists('attachment', $paste['meta']))
  179. {
  180. $attachment = $paste['meta']['attachment'];
  181. unset($meta['attachment']);
  182. }
  183. if (array_key_exists('attachmentname', $paste['meta']))
  184. {
  185. $attachmentname = $paste['meta']['attachmentname'];
  186. unset($meta['attachmentname']);
  187. }
  188. return self::_exec(
  189. 'INSERT INTO ' . self::_sanitizeIdentifier('paste') .
  190. ' VALUES(?,?,?,?,?,?,?,?,?)',
  191. array(
  192. $pasteid,
  193. $paste['data'],
  194. $paste['meta']['postdate'],
  195. $expire_date,
  196. (int) $opendiscussion,
  197. (int) $burnafterreading,
  198. json_encode($meta),
  199. $attachment,
  200. $attachmentname,
  201. )
  202. );
  203. }
  204. /**
  205. * Read a paste.
  206. *
  207. * @access public
  208. * @param string $pasteid
  209. * @return stdClass|false
  210. */
  211. public function read($pasteid)
  212. {
  213. if (
  214. !array_key_exists($pasteid, self::$_cache)
  215. ) {
  216. self::$_cache[$pasteid] = false;
  217. $paste = self::_select(
  218. 'SELECT * FROM ' . self::_sanitizeIdentifier('paste') .
  219. ' WHERE dataid = ?', array($pasteid), true
  220. );
  221. if(false !== $paste) {
  222. // create object
  223. self::$_cache[$pasteid] = new stdClass;
  224. self::$_cache[$pasteid]->data = $paste['data'];
  225. $meta = json_decode($paste['meta']);
  226. if (!is_object($meta)) $meta = new stdClass;
  227. // support older attachments
  228. if (property_exists($meta, 'attachment'))
  229. {
  230. self::$_cache[$pasteid]->attachment = $meta->attachment;
  231. unset($meta->attachment);
  232. if (property_exists($meta, 'attachmentname'))
  233. {
  234. self::$_cache[$pasteid]->attachmentname = $meta->attachmentname;
  235. unset($meta->attachmentname);
  236. }
  237. }
  238. // support current attachments
  239. elseif (array_key_exists('attachment', $paste) && strlen($paste['attachment']))
  240. {
  241. self::$_cache[$pasteid]->attachment = $paste['attachment'];
  242. if (array_key_exists('attachmentname', $paste) && strlen($paste['attachmentname']))
  243. {
  244. self::$_cache[$pasteid]->attachmentname = $paste['attachmentname'];
  245. }
  246. }
  247. self::$_cache[$pasteid]->meta = $meta;
  248. self::$_cache[$pasteid]->meta->postdate = (int) $paste['postdate'];
  249. $expire_date = (int) $paste['expiredate'];
  250. if (
  251. $expire_date > 0
  252. ) self::$_cache[$pasteid]->meta->expire_date = $expire_date;
  253. if (
  254. $paste['opendiscussion']
  255. ) self::$_cache[$pasteid]->meta->opendiscussion = true;
  256. if (
  257. $paste['burnafterreading']
  258. ) self::$_cache[$pasteid]->meta->burnafterreading = true;
  259. }
  260. }
  261. return self::$_cache[$pasteid];
  262. }
  263. /**
  264. * Delete a paste and its discussion.
  265. *
  266. * @access public
  267. * @param string $pasteid
  268. * @return void
  269. */
  270. public function delete($pasteid)
  271. {
  272. self::_exec(
  273. 'DELETE FROM ' . self::_sanitizeIdentifier('paste') .
  274. ' WHERE dataid = ?', array($pasteid)
  275. );
  276. self::_exec(
  277. 'DELETE FROM ' . self::_sanitizeIdentifier('comment') .
  278. ' WHERE pasteid = ?', array($pasteid)
  279. );
  280. if (
  281. array_key_exists($pasteid, self::$_cache)
  282. ) unset(self::$_cache[$pasteid]);
  283. }
  284. /**
  285. * Test if a paste exists.
  286. *
  287. * @access public
  288. * @param string $pasteid
  289. * @return void
  290. */
  291. public function exists($pasteid)
  292. {
  293. if (
  294. !array_key_exists($pasteid, self::$_cache)
  295. ) self::$_cache[$pasteid] = $this->read($pasteid);
  296. return (bool) self::$_cache[$pasteid];
  297. }
  298. /**
  299. * Create a comment in a paste.
  300. *
  301. * @access public
  302. * @param string $pasteid
  303. * @param string $parentid
  304. * @param string $commentid
  305. * @param array $comment
  306. * @return bool
  307. */
  308. public function createComment($pasteid, $parentid, $commentid, $comment)
  309. {
  310. foreach (array('nickname', 'vizhash') as $key)
  311. {
  312. if (!array_key_exists($key, $comment['meta']))
  313. {
  314. $comment['meta'][$key] = null;
  315. }
  316. }
  317. return self::_exec(
  318. 'INSERT INTO ' . self::_sanitizeIdentifier('comment') .
  319. ' VALUES(?,?,?,?,?,?,?)',
  320. array(
  321. $commentid,
  322. $pasteid,
  323. $parentid,
  324. $comment['data'],
  325. $comment['meta']['nickname'],
  326. $comment['meta']['vizhash'],
  327. $comment['meta']['postdate'],
  328. )
  329. );
  330. }
  331. /**
  332. * Read all comments of paste.
  333. *
  334. * @access public
  335. * @param string $pasteid
  336. * @return array
  337. */
  338. public function readComments($pasteid)
  339. {
  340. $rows = self::_select(
  341. 'SELECT * FROM ' . self::_sanitizeIdentifier('comment') .
  342. ' WHERE pasteid = ?', array($pasteid)
  343. );
  344. // create comment list
  345. $comments = array();
  346. if (count($rows))
  347. {
  348. foreach ($rows as $row)
  349. {
  350. $i = $this->getOpenSlot($comments, (int) $row['postdate']);
  351. $comments[$i] = new stdClass;
  352. $comments[$i]->id = $row['dataid'];
  353. $comments[$i]->parentid = $row['parentid'];
  354. $comments[$i]->data = $row['data'];
  355. $comments[$i]->meta = new stdClass;
  356. $comments[$i]->meta->postdate = (int) $row['postdate'];
  357. if (array_key_exists('nickname', $row) && !empty($row['nickname']))
  358. $comments[$i]->meta->nickname = $row['nickname'];
  359. if (array_key_exists('vizhash', $row) && !empty($row['vizhash']))
  360. $comments[$i]->meta->vizhash = $row['vizhash'];
  361. }
  362. ksort($comments);
  363. }
  364. return $comments;
  365. }
  366. /**
  367. * Test if a comment exists.
  368. *
  369. * @access public
  370. * @param string $pasteid
  371. * @param string $parentid
  372. * @param string $commentid
  373. * @return void
  374. */
  375. public function existsComment($pasteid, $parentid, $commentid)
  376. {
  377. return (bool) self::_select(
  378. 'SELECT dataid FROM ' . self::_sanitizeIdentifier('comment') .
  379. ' WHERE pasteid = ? AND parentid = ? AND dataid = ?',
  380. array($pasteid, $parentid, $commentid), true
  381. );
  382. }
  383. /**
  384. * Returns up to batch size number of paste ids that have expired
  385. *
  386. * @access private
  387. * @param int $batchsize
  388. * @return array
  389. */
  390. protected function _getExpiredPastes($batchsize)
  391. {
  392. $pastes = array();
  393. $rows = self::_select(
  394. 'SELECT dataid FROM ' . self::_sanitizeIdentifier('paste') .
  395. ' WHERE expiredate < ? LIMIT ?', array(time(), $batchsize)
  396. );
  397. if (count($rows))
  398. {
  399. foreach ($rows as $row)
  400. {
  401. $pastes[] = $row['dataid'];
  402. }
  403. }
  404. return $pastes;
  405. }
  406. /**
  407. * execute a statement
  408. *
  409. * @access private
  410. * @static
  411. * @param string $sql
  412. * @param array $params
  413. * @throws PDOException
  414. * @return bool
  415. */
  416. private static function _exec($sql, array $params)
  417. {
  418. $statement = self::$_db->prepare($sql);
  419. $result = $statement->execute($params);
  420. $statement->closeCursor();
  421. return $result;
  422. }
  423. /**
  424. * run a select statement
  425. *
  426. * @access private
  427. * @static
  428. * @param string $sql
  429. * @param array $params
  430. * @param bool $firstOnly if only the first row should be returned
  431. * @throws PDOException
  432. * @return array
  433. */
  434. private static function _select($sql, array $params, $firstOnly = false)
  435. {
  436. $statement = self::$_db->prepare($sql);
  437. $statement->execute($params);
  438. $result = $firstOnly ?
  439. $statement->fetch(PDO::FETCH_ASSOC) :
  440. $statement->fetchAll(PDO::FETCH_ASSOC);
  441. $statement->closeCursor();
  442. return $result;
  443. }
  444. /**
  445. * get table list query, depending on the database type
  446. *
  447. * @access private
  448. * @static
  449. * @param string $type
  450. * @throws Exception
  451. * @return string
  452. */
  453. private static function _getTableQuery($type)
  454. {
  455. switch($type)
  456. {
  457. case 'ibm':
  458. $sql = 'SELECT tabname FROM SYSCAT.TABLES ';
  459. break;
  460. case 'informix':
  461. $sql = 'SELECT tabname FROM systables ';
  462. break;
  463. case 'mssql':
  464. $sql = "SELECT name FROM sysobjects "
  465. . "WHERE type = 'U' ORDER BY name";
  466. break;
  467. case 'mysql':
  468. $sql = 'SHOW TABLES';
  469. break;
  470. case 'oci':
  471. $sql = 'SELECT table_name FROM all_tables';
  472. break;
  473. case 'pgsql':
  474. $sql = "SELECT c.relname AS table_name "
  475. . "FROM pg_class c, pg_user u "
  476. . "WHERE c.relowner = u.usesysid AND c.relkind = 'r' "
  477. . "AND NOT EXISTS (SELECT 1 FROM pg_views WHERE viewname = c.relname) "
  478. . "AND c.relname !~ '^(pg_|sql_)' "
  479. . "UNION "
  480. . "SELECT c.relname AS table_name "
  481. . "FROM pg_class c "
  482. . "WHERE c.relkind = 'r' "
  483. . "AND NOT EXISTS (SELECT 1 FROM pg_views WHERE viewname = c.relname) "
  484. . "AND NOT EXISTS (SELECT 1 FROM pg_user WHERE usesysid = c.relowner) "
  485. . "AND c.relname !~ '^pg_'";
  486. break;
  487. case 'sqlite':
  488. $sql = "SELECT name FROM sqlite_master WHERE type='table' "
  489. . "UNION ALL SELECT name FROM sqlite_temp_master "
  490. . "WHERE type='table' ORDER BY name";
  491. break;
  492. default:
  493. throw new Exception(
  494. "PDO type $type is currently not supported.", 5
  495. );
  496. }
  497. return $sql;
  498. }
  499. /**
  500. * get a value by key from the config table
  501. *
  502. * @access private
  503. * @static
  504. * @param string $key
  505. * @throws PDOException
  506. * @return string
  507. */
  508. private static function _getConfig($key)
  509. {
  510. $row = self::_select(
  511. 'SELECT value FROM ' . self::_sanitizeIdentifier('config') .
  512. ' WHERE id = ?', array($key), true
  513. );
  514. return $row['value'];
  515. }
  516. /**
  517. * get the primary key clauses, depending on the database driver
  518. *
  519. * @access private
  520. * @static
  521. * @param string $key
  522. * @return array
  523. */
  524. private static function _getPrimaryKeyClauses($key = 'dataid')
  525. {
  526. $main_key = $after_key = '';
  527. if (self::$_type === 'mysql')
  528. {
  529. $after_key = ", PRIMARY KEY ($key)";
  530. }
  531. else
  532. {
  533. $main_key = ' PRIMARY KEY';
  534. }
  535. return array($main_key, $after_key);
  536. }
  537. /**
  538. * create the paste table
  539. *
  540. * @access private
  541. * @static
  542. * @return void
  543. */
  544. private static function _createPasteTable()
  545. {
  546. list($main_key, $after_key) = self::_getPrimaryKeyClauses();
  547. $dataType = self::$_type === 'pgsql' ? 'TEXT' : 'BLOB';
  548. self::$_db->exec(
  549. 'CREATE TABLE ' . self::_sanitizeIdentifier('paste') . ' ( ' .
  550. "dataid CHAR(16) NOT NULL$main_key, " .
  551. "data $dataType, " .
  552. 'postdate INT, ' .
  553. 'expiredate INT, ' .
  554. 'opendiscussion INT, ' .
  555. 'burnafterreading INT, ' .
  556. 'meta TEXT, ' .
  557. 'attachment ' . (self::$_type === 'pgsql' ? 'TEXT' : 'MEDIUMBLOB') . ', ' .
  558. "attachmentname $dataType$after_key );"
  559. );
  560. }
  561. /**
  562. * create the paste table
  563. *
  564. * @access private
  565. * @static
  566. * @return void
  567. */
  568. private static function _createCommentTable()
  569. {
  570. list($main_key, $after_key) = self::_getPrimaryKeyClauses();
  571. $dataType = self::$_type === 'pgsql' ? 'text' : 'BLOB';
  572. self::$_db->exec(
  573. 'CREATE TABLE ' . self::_sanitizeIdentifier('comment') . ' ( ' .
  574. "dataid CHAR(16) NOT NULL$main_key, " .
  575. 'pasteid CHAR(16), ' .
  576. 'parentid CHAR(16), ' .
  577. "data $dataType, " .
  578. "nickname $dataType, " .
  579. "vizhash $dataType, " .
  580. "postdate INT$after_key );"
  581. );
  582. self::$_db->exec(
  583. 'CREATE INDEX IF NOT EXISTS comment_parent ON ' .
  584. self::_sanitizeIdentifier('comment') . '(pasteid);'
  585. );
  586. }
  587. /**
  588. * create the paste table
  589. *
  590. * @access private
  591. * @static
  592. * @return void
  593. */
  594. private static function _createConfigTable()
  595. {
  596. list($main_key, $after_key) = self::_getPrimaryKeyClauses('id');
  597. self::$_db->exec(
  598. 'CREATE TABLE ' . self::_sanitizeIdentifier('config') .
  599. " ( id CHAR(16) NOT NULL$main_key, value TEXT$after_key );"
  600. );
  601. self::_exec(
  602. 'INSERT INTO ' . self::_sanitizeIdentifier('config') .
  603. ' VALUES(?,?)',
  604. array('VERSION', privatebin::VERSION)
  605. );
  606. }
  607. /**
  608. * sanitizes identifiers
  609. *
  610. * @access private
  611. * @static
  612. * @param string $identifier
  613. * @return string
  614. */
  615. private static function _sanitizeIdentifier($identifier)
  616. {
  617. return preg_replace('/[^A-Za-z0-9_]+/', '', self::$_prefix . $identifier);
  618. }
  619. /**
  620. * upgrade the database schema from an old version
  621. *
  622. * @access private
  623. * @static
  624. * @param string $oldversion
  625. * @return void
  626. */
  627. private static function _upgradeDatabase($oldversion)
  628. {
  629. $dataType = self::$_type === 'pgsql' ? 'TEXT' : 'BLOB';
  630. switch ($oldversion)
  631. {
  632. case '0.21':
  633. // create the meta column if necessary (pre 0.21 change)
  634. try {
  635. self::$_db->exec('SELECT meta FROM ' . self::_sanitizeIdentifier('paste') . ' LIMIT 1;');
  636. } catch (PDOException $e) {
  637. self::$_db->exec('ALTER TABLE ' . self::_sanitizeIdentifier('paste') . ' ADD COLUMN meta TEXT;');
  638. }
  639. // SQLite only allows one ALTER statement at a time...
  640. self::$_db->exec(
  641. 'ALTER TABLE ' . self::_sanitizeIdentifier('paste') .
  642. ' ADD COLUMN attachment ' .
  643. (self::$_type === 'pgsql' ? 'TEXT' : 'MEDIUMBLOB') . ';'
  644. );
  645. self::$_db->exec(
  646. 'ALTER TABLE ' . self::_sanitizeIdentifier('paste') . " ADD COLUMN attachmentname $dataType;"
  647. );
  648. // SQLite doesn't support MODIFY, but it allows TEXT of similar
  649. // size as BLOB, so there is no need to change it there
  650. if (self::$_type !== 'sqlite')
  651. {
  652. self::$_db->exec(
  653. 'ALTER TABLE ' . self::_sanitizeIdentifier('paste') .
  654. ' ADD PRIMARY KEY (dataid), MODIFY COLUMN data $dataType;'
  655. );
  656. self::$_db->exec(
  657. 'ALTER TABLE ' . self::_sanitizeIdentifier('comment') .
  658. " ADD PRIMARY KEY (dataid), MODIFY COLUMN data $dataType, " .
  659. "MODIFY COLUMN nickname $dataType, MODIFY COLUMN vizhash $dataType;"
  660. );
  661. }
  662. else
  663. {
  664. self::$_db->exec(
  665. 'CREATE UNIQUE INDEX IF NOT EXISTS paste_dataid ON ' .
  666. self::_sanitizeIdentifier('paste') . '(dataid);'
  667. );
  668. self::$_db->exec(
  669. 'CREATE UNIQUE INDEX IF NOT EXISTS comment_dataid ON ' .
  670. self::_sanitizeIdentifier('comment') . '(dataid);'
  671. );
  672. }
  673. self::$_db->exec(
  674. 'CREATE INDEX IF NOT EXISTS comment_parent ON ' .
  675. self::_sanitizeIdentifier('comment') . '(pasteid);'
  676. );
  677. }
  678. }
  679. }