$core->url->registerDefault(array('commonUrl', 'hub'));\r
$core->url->register('ajax', 'ajax', '^ajax(.*)$', array('cubeAjax', 'ajax'));\r
$core->url->register('tools', 'tools', '^tools(.*)$', array('commonTools', 'hub'));\r
-\r
-?>
\ No newline at end of file
/** @var wsHTML5Compiler */
public static $lastHTML5Compiler = null;
+ protected $_compileLock = null;
+
/**
* wsDAOBook::singleton()
*
public function compile($book_id, $version = 'all', $complete = false, $force = false, $dev = false, $book = null, $delete = true)
{
+
if (is_null($book_id) || !$book_id) {
return;
}
- $compileLock = WS_BOOKS . '/locks/' . $book_id . '.lock';
+ $this->_compileLock = WS_BOOKS . '/locks/' . $book_id . '.lock';
+
- while (file_exists($compileLock) && filemtime($compileLock) > time() - 3600) {
+ while (file_exists($this->_compileLock) && filemtime($this->_compileLock) > (time() - 900)) {
sleep(10);
}
cubePHP::neverStop();
- touch($compileLock);
+ touch($this->_compileLock);
if (null === $book) {
$book = $this->selectById($book_id);
$pages = $this->getPagesOfBook($book_id);
$res = '';
- $this->compilePDF($book, $pages);
- $res .= $this->compileHTML5($book_id, $book, $dev, $delete);
- $this->touchCompile($book_id, 'html5');
+ try {
+ $this->compilePDF($book, $pages);
+ $res .= $this->compileHTML5($book_id, $book, $dev, $delete);
+ $this->touchCompile($book_id, 'html5');
+ } catch (Exception $e) {
+
+ }
- unlink($compileLock);
+ unlink($this->_compileLock);
return $res;
}
return $str;
}
+ public function __destruct()
+ {
+ if (null !== $this->_compileLock && file_exists($this->_compileLock)) {
+ unlink($this->_compileLock);
+ $this->_compileLock = null;
+ }
+ }
+
}