From 21b23e51d28e38d81a96a529b5a3899e4e9e37a5 Mon Sep 17 00:00:00 2001 From: "vincent@cubedesigners.com" Date: Thu, 8 Nov 2012 13:05:40 +0000 Subject: [PATCH] --- inc/commons/class.common.core.php | 1 + inc/commons/class.common.url.php | 77 ++++++++++++++++- inc/ws/Controlleur/class.ws.ajax.php | 85 +++++++++++++------ inc/ws/Controlleur/class.ws.url.php | 6 +- inc/ws/DAO/class.ws.dao.book.php | 1 + inc/ws/Metier/class.ws.book.php | 1 + inc/ws/Util/html5/class.ws.html5.compiler.php | 3 + 7 files changed, 146 insertions(+), 28 deletions(-) diff --git a/inc/commons/class.common.core.php b/inc/commons/class.common.core.php index 9ce5c9055..28617c445 100644 --- a/inc/commons/class.common.core.php +++ b/inc/commons/class.common.core.php @@ -380,6 +380,7 @@ class commonCore extends cubeCore { $db->books->dir_references('varchar', 256, false); $db->books->dir_hosting('varchar', 256, false); $db->books->dir_macbook_phonegap_ios('varchar', 256, false); + $db->books->dir_external('varchar', 256, false); $db->books->lucene_time('integer', 0, false); // Clés $db->books->primary('pk_books', 'book_id'); diff --git a/inc/commons/class.common.url.php b/inc/commons/class.common.url.php index b8519c819..7eb914ddc 100644 --- a/inc/commons/class.common.url.php +++ b/inc/commons/class.common.url.php @@ -405,7 +405,7 @@ class commonUrl { } else { $res .= ''; } - $res .= '' . $core->typo->Telecharger('Télécharger') . ''; + $res .= '' . self::telechargerLink($fichier) . ''; $res .= '' . cubeMedia::image(IMG . '/delete.png') . ''; $res .= ''; $i++; @@ -421,6 +421,81 @@ class commonUrl { return $res; } + public static function telechargerLink($fichier) { + global $core; + $ext = files::getExtension($fichier->relPath); + + if ($ext == 'ipa' && (stristr($_SERVER['HTTP_USER_AGENT'], 'iphone') || stristr($_SERVER['HTTP_USER_AGENT'], 'ipad') || stristr($_SERVER['HTTP_USER_AGENT'], 'ipod') )) { + return '' . $core->typo->Telecharger('Installer') . ''; + } else { + return '' . $core->typo->Telecharger('Télécharger') . ''; + } + } + + public static function manifestFromIpa($fichier) { + $manifest = sha1($fichier->relPath) . '.plist'; + $res = 'http://' . $_SERVER['HTTP_HOST'] . '/cache/iosotamanifest/' . $manifest; + $file = ROOT . '/cache/iosotamanifest/' . $manifest; + $tmp = $file . '.info'; + $ipa = $fichier->chemin; + + if (true || !file_exists($file) || filemtime($ipa) > filemtime($file)) { + $zip = new ZipArchive(); + $zip->open($fichier->chemin); + $idx = $zip->locateName('Info.plist', ZIPARCHIVE::FL_NOCASE | ZIPARCHIVE::FL_NODIR); + $info = $zip->getFromIndex($idx); + + file_put_contents($tmp, $info); + + require_once(ROOT . '/inc/cube/externals/CFPropertyList/CFPropertyList.php'); + $plist = new CFPropertyList\CFPropertyList($tmp); + + $infos = $plist->toArray(); + fb($infos); + $bundle = $infos['CFBundleIdentifier']; + $appName = $infos['CFBundleDisplayName']; + $version = $infos['CFBundleVersion']; + $ipaURL = 'http://' . $_SERVER['HTTP_HOST'] . '/telecharger/' . $fichier->relPath; + + $xml = ' + + + + items + + + assets + + + kind + software-package + url + ' . $ipaURL . ' + + + metadata + + bundle-identifier + ' . $bundle . ' + bundle-version + ' . $version . ' + kind + software + title + ' . $appName . ' + + + + +'; + + file_put_contents($file, $xml); + + unlink($tmp); + } + return $res; + } + public static function telecharger($args) { commonDroits::min(array('extranet' => 0, 'ws' => 1)); diff --git a/inc/ws/Controlleur/class.ws.ajax.php b/inc/ws/Controlleur/class.ws.ajax.php index 514d1c9d4..485363fc2 100644 --- a/inc/ws/Controlleur/class.ws.ajax.php +++ b/inc/ws/Controlleur/class.ws.ajax.php @@ -266,47 +266,80 @@ class wsAjax extends cubeAjax { if ($server == 'references') { $root = '/home/fluidbook/dev/references'; $url = 'http://www.fluidbook.com/references/'; + $protocol = 'rsync'; } else if ($server == 'hosting') { $root = '/home/fluidbook/hosting'; $url = 'http://hosting.fluidbook.com/'; + $protocol = 'rsync'; } else if ($server == 'macbook_phonegap_ios') { $root = '/mnt/macbook/Phonegap/Projects/'; $url = null; + $protocol = 'rsync'; + } else if ($server == 'external') { + $protocol = 'ftp'; + $url = null; } - $e = explode('/', $_POST['dir']); - $f = array(); - foreach ($e as $d) { - if ($d == '..' || $d == '') { - continue; + if ($protocol == 'rsync') { + $e = explode('/', $_POST['dir']); + $f = array(); + foreach ($e as $d) { + if ($d == '..' || $d == '') { + continue; + } + $f[] = cubeText::str2URL($d); } - $f[] = cubeText::str2URL($d); + $dir = implode('/', $f); + } else { + $dir = $_POST['dir']; } - $dir = implode('/', $f); $dao->setInstallDir($book_id, $dir, $server); - $finalDir = $root . '/' . $dir; - if (!file_exists($finalDir)) { - mkdir($finalDir, 0777, true); - } + if ($protocol == 'rsync') { - /** --del -r -z -v * */ - $cp = new cubeCommandLine('rsync'); - $cp->setPath(CONVERTER_PATH); - $cp->setArg('del'); - $cp->setArg('t'); - $cp->setArg('r'); - $cp->setArg('z'); - $cp->setArg('v'); - $cp->setArg(null, $package . '*'); - $cp->setArg(null, $finalDir); - $cp->execute(); - - fb($cp->commande); - fb($cp->output); + $finalDir = $root . '/' . $dir; + if (!file_exists($finalDir)) { + mkdir($finalDir, 0777, true); + } - fb(time(), 'end transfert'); + /** --del -r -z -v * */ + $cp = new cubeCommandLine('rsync'); + $cp->setPath(CONVERTER_PATH); + $cp->setArg('del'); + $cp->setArg('t'); + $cp->setArg('r'); + $cp->setArg('z'); + $cp->setArg('v'); + $cp->setArg(null, $package . '*'); + $cp->setArg(null, $finalDir); + $cp->execute(); + + fb($cp->commande); + fb($cp->output); + + fb(time(), 'end transfert'); + } elseif ($protocol == 'ftp') { + + $u = parse_url('ftp://' . $dir); + + $commandes = array( + 'mkdir -p ' . $u['path'], + 'cd ' . $u['path'], + 'lcd ' . $package, + 'mirror -Rve' + ); + + //$lftp->setManualArg( . '> mirror -Rv ' . $package); + + $lftp = new cubeCommandLine('lftp'); + $lftp->setArg('u', $u['user'] . ',' . $u['pass']); + $lftp->setArg('e', implode(';', $commandes)); + $lftp->setArg(null, $u['host']); + $lftp->execute(); + fb($lftp->commande); + fb($lftp->output); + } $x->addClosePopup(); if (!is_null($url)) { diff --git a/inc/ws/Controlleur/class.ws.url.php b/inc/ws/Controlleur/class.ws.url.php index 76d07a189..0d86eb554 100644 --- a/inc/ws/Controlleur/class.ws.url.php +++ b/inc/ws/Controlleur/class.ws.url.php @@ -202,6 +202,7 @@ class wsUrl { $versions['hosting'] = array('title' => __("Le serveur d'hébergement"), 'icon' => cubeMedia::silk('server_go.png')); $versions['references'] = array('title' => __("L'espace références"), 'icon' => cubeMedia::silk('server_add.png')); $versions['macbook_phonegap_ios'] = array('title' => __("Projet Phonegap IOS"), 'icon' => cubeMedia::silk('server_add.png')); + $versions['external'] = array('title' => __("Serveur FTP"), 'icon' => cubeMedia::silk('server_add.png')); foreach ($versions as $k => $v) { $res .= '
  • ' . $v['icon'] . $v['title'] . '
  • '; @@ -1017,13 +1018,16 @@ html{height:100%}' . "\n"; } elseif ($server == 'macbook_phonegap_ios') { $s = __("Projet Phonegap iOS"); $dir = $book->dir_macbook_phonegap_ios; + } elseif ($server == 'external') { + $s = __('Serveur FTP externe') . ' : ftp://'; + $dir = $book->dir_external; } if ($dir == '') { $dir = cubeText::str2URL($book->parametres->title); } - $res = '' . __("Dossier d'installation") . '' . $s . ' / ' . form::field('dir', 50, 50, $dir) . ''; + $res = '' . __("Dossier d'installation") . '' . $s . ' ' . form::field('dir', 60, 128, $dir) . ''; $res.='' . __("A l'issue de l'installation, vous serez dirigé vers le serveur sur lequel la publication a été installée") . ''; return $res; } diff --git a/inc/ws/DAO/class.ws.dao.book.php b/inc/ws/DAO/class.ws.dao.book.php index aed944343..0a2c6672b 100644 --- a/inc/ws/DAO/class.ws.dao.book.php +++ b/inc/ws/DAO/class.ws.dao.book.php @@ -45,6 +45,7 @@ class wsDAOBook extends commonDAO { $book->dir_references = $r->dir_references; $book->dir_hosting = $r->dir_hosting; $book->dir_macbook_phonegap_ios = $r->dir_macbook_phonegap_ios; + $book->dir_external = $r->dir_external; return $book; } diff --git a/inc/ws/Metier/class.ws.book.php b/inc/ws/Metier/class.ws.book.php index 043c8f688..164ff7d4f 100644 --- a/inc/ws/Metier/class.ws.book.php +++ b/inc/ws/Metier/class.ws.book.php @@ -35,6 +35,7 @@ class wsBook extends cubeMetier { protected $dir_references; protected $dir_hosting; protected $dir_macbook_phonegap_ios; + protected $dir_external; public function __get($varname) { if (!property_exists($this, $varname)) { diff --git a/inc/ws/Util/html5/class.ws.html5.compiler.php b/inc/ws/Util/html5/class.ws.html5.compiler.php index d9b5fec8a..8bcbd734c 100644 --- a/inc/ws/Util/html5/class.ws.html5.compiler.php +++ b/inc/ws/Util/html5/class.ws.html5.compiler.php @@ -666,6 +666,9 @@ class wsHTML5Compiler { foreach ($this->additionalConfig as $k => $v) { $this->config->$k = $v; } + if($this->phonegap){ + $this->config->twitter=$this->config->facebook=false; + } return 'var DATAS=' . json_encode($this->config) . ';' . "\n"; } -- 2.39.5