From: vincent@cubedesigners.com Date: Tue, 14 Dec 2010 14:52:26 +0000 (+0000) Subject: (no commit message) X-Git-Url: http://git.cubedesigners.com/?a=commitdiff_plain;h=9f70dfc4b13da12513ebb8f6f0a7286047337d10;p=cubeextranet.git --- diff --git a/inc/extranet/Controlleur/class.extranet.core.php b/inc/extranet/Controlleur/class.extranet.core.php index 769f20780..e43a1764a 100644 --- a/inc/extranet/Controlleur/class.extranet.core.php +++ b/inc/extranet/Controlleur/class.extranet.core.php @@ -367,6 +367,13 @@ class extranetCore extends cubeCore { $db->book_pages->reference('fk_book_pages_book_id', 'book_id', 'books', 'book_id'); $db->book_pages->reference('fk_book_pages_document_id', 'document_id', 'documents', 'document_id'); // . + // Table de cache des urls courtes + $db->book_short_url->long_url('varchar', 255, false); + $db->book_short_url->short_url('varchar', 64, false); + $db->book_short_url->book_id('integer', 0, false); + // Clés + $db->book_short_url->index('index_book_short_url_long_url', 'BTREE', 'long_url'); + $db->book_short_url->index('index_book_short_url_book_id', 'BTREE', 'book_id'); try { $dbi = new CubeDbStruct($this->con); $dbi->synchronize($db); diff --git a/inc/prepend.php b/inc/prepend.php index 006e28b2b..6894bfc2d 100644 --- a/inc/prepend.php +++ b/inc/prepend.php @@ -21,6 +21,7 @@ $core->url->register('ajax', 'ajax', '^ajax(.*)$', array('cubeAjax', 'ajax')); $core->url->register('cleanDownload', 'cleanDownload', '^cleanDownload$', array('extranetUrl', 'cleanDownload')); // Fluidbook Workshop $core->url->register('flash', 'flash', '^flash(.*)$', array('wsFlash', 'in')); +$core->url->register('services', 'services', '^services(.*)$', array('wsServices', 'in')); $core->url->register('editor', 'editor', '^editor/(.*)$', array('wsUrl', 'editor')); $core->url->register('viewer', 'viewer', '^viewer/(.*)$', array('wsUrl', 'viewer')); diff --git a/inc/ws/Controlleur/_common.php b/inc/ws/Controlleur/_common.php index 69818bdf8..f77f4f978 100644 --- a/inc/ws/Controlleur/_common.php +++ b/inc/ws/Controlleur/_common.php @@ -6,4 +6,5 @@ $__autoload['wsUrl'] = dirname(__FILE__) . '/class.ws.url.php'; $__autoload['wsDroits'] = dirname(__FILE__) . '/class.ws.droits.php'; $__autoload['wsConversionSession'] = dirname(__FILE__) . '/class.ws.conversion.session.php'; $__autoload['wsStats']=dirname(__FILE__).'/class.ws.stats.php'; +$__autoload['wsServices']=dirname(__FILE__).'/class.ws.services.php'; ?> \ No newline at end of file diff --git a/inc/ws/Controlleur/class.ws.services.php b/inc/ws/Controlleur/class.ws.services.php new file mode 100644 index 000000000..d4d177d75 --- /dev/null +++ b/inc/ws/Controlleur/class.ws.services.php @@ -0,0 +1,47 @@ +con, $args); + } + + public function sendEmail() + { + } + + public function shortenURL() + { + $bitLyUser = 'fluidbook'; + $bitLyKey = 'R_3858dd1c9884d5c6a5fe386d7e95cf1d'; + // Recherche dans le cache + $r = $this->con->select('SELECT * FROM book_short_url WHERE long_url=\'' . $this->con->escape($this->args['url']) . '\' LIMIT 1'); + if ($r->count() > 0) { + $this->xml->addChild('shortURL', $r->short_url); + return; + } + // Si pas dans le cache, on le recherche + $short_url = cubeURLShortener::bitLy($this->args['url'], $bitLyUser, $bitLyKey); + if (is_null($short_url) || empty($short_url) || !$short_url) { + $short_url = cubeURLShortener::tinyURL($this->args['url']); + } + $short_url = trim($short_url); + + $c = $this->con->openCursor('book_short_url'); + $c->long_url = $this->args['url']; + $c->book_id = $this->args['id']; + $c->short_url = $short_url; + $c->insert(); + + $this->xml->addChild('shortURL', $short_url); + } + + public function getPDF() + { + } +} + +?> \ No newline at end of file