From: vincent@cubedesigners.com Date: Wed, 8 Dec 2010 18:15:29 +0000 (+0000) Subject: (no commit message) X-Git-Url: http://git.cubedesigners.com/?a=commitdiff_plain;h=dfaa64ebc0ebb1f5db5c01d6136a4e9efb22224b;p=cubeextranet.git --- diff --git a/inc/extranet/Controlleur/class.extranet.core.php b/inc/extranet/Controlleur/class.extranet.core.php index 0306be5a3..769f20780 100644 --- a/inc/extranet/Controlleur/class.extranet.core.php +++ b/inc/extranet/Controlleur/class.extranet.core.php @@ -348,6 +348,8 @@ class extranetCore extends cubeCore { $db->books->traductions('text', 0, false); $db->books->date('integer', 0, false); $db->books->numerotation('text', 0, false); + $db->books->changedate('integer', 0, false); + $db->books->compiledate('integer', 0, false); // Clés $db->books->primary('pk_books', 'book_id'); $db->books->index('index_books_nom', 'BTREE', 'nom'); diff --git a/inc/ws/Controlleur/class.ws.flash.php b/inc/ws/Controlleur/class.ws.flash.php index ad34eec1b..84cee528e 100644 --- a/inc/ws/Controlleur/class.ws.flash.php +++ b/inc/ws/Controlleur/class.ws.flash.php @@ -487,7 +487,9 @@ class wsFlash extends cubeFlashGateway { { global $core; $dao = new wsDAOBook($core->con); - $dao->compile($this->args['book_id'], 3); + if (!$dao->isUpToDate($this->args['book_id'])) { + $dao->compile($this->args['book_id'], 3); + } $absoluteURL = 'http://' . $_SERVER['HTTP_HOST'] . '/fluidbook/books/final/' . $this->args['book_id'] . '/'; $this->xml->addChild('compiledBook', $absoluteURL . 'index.swf?base=' . $absoluteURL); diff --git a/inc/ws/Controlleur/class.ws.url.php b/inc/ws/Controlleur/class.ws.url.php index 6cd4cf50c..07fa62919 100644 --- a/inc/ws/Controlleur/class.ws.url.php +++ b/inc/ws/Controlleur/class.ws.url.php @@ -121,6 +121,9 @@ html{height:100%}' . "\n"; public static function viewer($args) { + global $core; + global $css; + global $js; $args = cubePage::getArgs($args); $e = explode('_', $args[0]); @@ -129,6 +132,13 @@ html{height:100%}' . "\n"; http::redirect(SITE_PATH . '/viewer/' . implode('_', $e)); exit; } + + $dao = new wsDAOBook($core->con); + $book = $dao->selectById($e[0]); + if ($book->hash != $e[1]) { + http::head(401); + exit; + } } public static function statsxls($args) diff --git a/inc/ws/DAO/class.ws.dao.book.php b/inc/ws/DAO/class.ws.dao.book.php index c2c215ed3..f298cb4b5 100644 --- a/inc/ws/DAO/class.ws.dao.book.php +++ b/inc/ws/DAO/class.ws.dao.book.php @@ -22,6 +22,8 @@ class wsDAOBook extends extranetDAO { $book->parametres = $r->parametres; $book->extras = $r->extras; $book->numerotation = $r->numerotation; + $book->changedate = $r->changedate; + $book->compiledate = $r->compiledate; return $book; } @@ -90,10 +92,12 @@ class wsDAOBook extends extranetDAO { $c->hash = md5(rand(0, 1234567893)); $c->compteur_visites = 20; $c->parametres = serialize(new wsParametres()); + $c->changedate = TIME; $book_id = $c->book_id = $this->getNextId(); $c->insert(); } else { + $c->changedate = TIME; $book_id = $data['book_id']; $c->update('WHERE book_id=\'' . $this->con->escape($data['book_id']) . '\''); } @@ -115,6 +119,8 @@ class wsDAOBook extends extranetDAO { $c->parametres = $r->parametres; $c->nom = $r->nom; $c->theme = $r->theme; + $c->changedate = TIME; + $c->compiledate = 0; $book_id = $c->book_id = $this->getNextId(); $c->insert(); @@ -133,6 +139,8 @@ class wsDAOBook extends extranetDAO { $c->parametres = serialize(new wsParametres()); $c->theme = 1; $c->lang = $lang; + $c->changedate = TIME; + $c->compiledate = TIME; $book_id = $c->book_id = $this->getNextId(); $c->insert(); return $this->selectById($book_id); @@ -269,6 +277,7 @@ class wsDAOBook extends extranetDAO { { $c = $this->con->openCursor('books'); $c->chapters = json_encode(json_decode($json, false)); + $c->changedate = TIME; $c->update('WHERE book_id=\'' . $this->con->escape($book_id) . '\''); } @@ -277,6 +286,7 @@ class wsDAOBook extends extranetDAO { $c = $this->con->openCursor('books'); $c->links = json_encode(json_decode($links, false)); $c->rulers = json_encode(json_decode($rulers, false)); + $c->changedate = TIME; $c->update('WHERE book_id=\'' . $this->con->escape($book_id) . '\''); } @@ -297,6 +307,7 @@ class wsDAOBook extends extranetDAO { $c = $this->con->openCursor('books'); $c->extras = $extras; + $c->changedate = TIME; $c->update('WHERE book_id=\'' . $this->con->escape($book_id) . '\''); return true; } @@ -306,6 +317,7 @@ class wsDAOBook extends extranetDAO { $c = $this->con->openCursor('books'); $c->lang = $base; $c->traductions = json_encode(json_decode($traductions, false)); + $c->changedate = TIME; $c->update('WHERE book_id=\'' . $this->con->escape($book_id) . '\''); } @@ -320,6 +332,7 @@ class wsDAOBook extends extranetDAO { $c = $this->con->openCursor('books'); $c->nom = $parametres->title; $c->parametres = serialize($parametres); + $c->changedate = TIME; $c->update('WHERE book_id=\'' . $this->con->escape($book_id) . '\''); } @@ -330,6 +343,26 @@ class wsDAOBook extends extranetDAO { $c->update('WHERE book_id=\'' . $this->con->escape($book_id) . '\''); } + public function touch($book_id) + { + $c = $this->con->openCursor('books'); + $c->changedate = TIME; + $c->update('WHERE book_id=\'' . $this->con->escape($book_id) . '\''); + } + + public function touchCompile($book_id) + { + $c = $this->con->openCursor('books'); + $c->compiledate = TIME; + $c->update('WHERE book_id=\'' . $this->con->escape($book_id) . '\''); + } + + public function isUpToDate($book_id) + { + $r = $this->con->select('SELECT changedate,compiledate FROM books WHERE book_id=\'' . $this->con->escape($book_id) . '\''); + return $r->compiledate > $r->updatedate; + } + public function setComposition($book_id, $pages) { $numerotation = array(); @@ -346,6 +379,7 @@ class wsDAOBook extends extranetDAO { $c = $this->con->openCursor('books'); $c->parametres = serialize($parametres); $c->numerotation = implode(',', $numerotation); + $c->changedate = TIME; $c->update('WHERE book_id=\'' . $this->con->escape($book_id) . '\''); $this->con->execute('DELETE FROM book_pages WHERE book_id=\'' . $this->con->escape($book_id) . '\''); @@ -449,6 +483,7 @@ class wsDAOBook extends extranetDAO { if ($version == 3) { return $this->compile3($book_id, $complete); } + $this->touchCompile($book_id); } /** @@ -574,6 +609,8 @@ class wsDAOBook extends extranetDAO { } } + $this->touchCompile($book_id); + return $res; } } diff --git a/inc/ws/Metier/class.ws.book.php b/inc/ws/Metier/class.ws.book.php index 851f341df..93df8706e 100644 --- a/inc/ws/Metier/class.ws.book.php +++ b/inc/ws/Metier/class.ws.book.php @@ -32,6 +32,9 @@ class wsBook extends cubeMetier { protected $traductions; protected $numerotation; + protected $changedate; + protected $compiledate; + public function __get($varname) { if (!property_exists($this, $varname)) {