$db->books->dir_references('varchar', 256, false);\r
$db->books->dir_hosting('varchar', 256, false);\r
$db->books->dir_macbook_phonegap_ios('varchar', 256, false);\r
+ $db->books->dir_external('varchar', 256, false);\r
$db->books->lucene_time('integer', 0, false);\r
// Clés\r
$db->books->primary('pk_books', 'book_id');\r
} else {\r
$res .= '<td></td>';\r
}\r
- $res .= '<td><a href="' . SITE_PATH . 'telecharger/' . $fichier->relPath . '">' . $core->typo->Telecharger('Télécharger') . '</a></td>';\r
+ $res .= '<td>' . self::telechargerLink($fichier) . '</td>';\r
$res .= '<td><a href="#" class="ajax" rel="supprimeFichier/' . $fichier->relPath . '" title="' . __('Êtes-vous certain de vouloir supprimer ce fichier ?') . '">' . cubeMedia::image(IMG . '/delete.png') . '</a></td>';\r
$res .= '</tr>';\r
$i++;\r
return $res;\r
}\r
\r
+ public static function telechargerLink($fichier) {\r
+ global $core;\r
+ $ext = files::getExtension($fichier->relPath);\r
+\r
+ if ($ext == 'ipa' && (stristr($_SERVER['HTTP_USER_AGENT'], 'iphone') || stristr($_SERVER['HTTP_USER_AGENT'], 'ipad') || stristr($_SERVER['HTTP_USER_AGENT'], 'ipod') )) {\r
+ return '<a href="itms-services://?action=download-manifest&url=' . self::manifestFromIpa($fichier) . '">' . $core->typo->Telecharger('Installer') . '</a>';\r
+ } else {\r
+ return '<a href="' . SITE_PATH . 'telecharger/' . $fichier->relPath . '">' . $core->typo->Telecharger('Télécharger') . '</a>';\r
+ }\r
+ }\r
+\r
+ public static function manifestFromIpa($fichier) {\r
+ $manifest = sha1($fichier->relPath) . '.plist';\r
+ $res = 'http://' . $_SERVER['HTTP_HOST'] . '/cache/iosotamanifest/' . $manifest;\r
+ $file = ROOT . '/cache/iosotamanifest/' . $manifest;\r
+ $tmp = $file . '.info';\r
+ $ipa = $fichier->chemin;\r
+\r
+ if (true || !file_exists($file) || filemtime($ipa) > filemtime($file)) {\r
+ $zip = new ZipArchive();\r
+ $zip->open($fichier->chemin);\r
+ $idx = $zip->locateName('Info.plist', ZIPARCHIVE::FL_NOCASE | ZIPARCHIVE::FL_NODIR);\r
+ $info = $zip->getFromIndex($idx);\r
+\r
+ file_put_contents($tmp, $info);\r
+\r
+ require_once(ROOT . '/inc/cube/externals/CFPropertyList/CFPropertyList.php');\r
+ $plist = new CFPropertyList\CFPropertyList($tmp);\r
+\r
+ $infos = $plist->toArray();\r
+ fb($infos);\r
+ $bundle = $infos['CFBundleIdentifier'];\r
+ $appName = $infos['CFBundleDisplayName'];\r
+ $version = $infos['CFBundleVersion'];\r
+ $ipaURL = 'http://' . $_SERVER['HTTP_HOST'] . '/telecharger/' . $fichier->relPath;\r
+\r
+ $xml = '<?xml version="1.0" encoding="UTF-8"?>\r
+<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">\r
+<plist version="1.0">\r
+<dict>\r
+ <key>items</key>\r
+ <array>\r
+ <dict>\r
+ <key>assets</key>\r
+ <array>\r
+ <dict>\r
+ <key>kind</key>\r
+ <string>software-package</string>\r
+ <key>url</key>\r
+ <string>' . $ipaURL . '</string>\r
+ </dict>\r
+ </array>\r
+ <key>metadata</key>\r
+ <dict>\r
+ <key>bundle-identifier</key>\r
+ <string>' . $bundle . '</string>\r
+ <key>bundle-version</key>\r
+ <string>' . $version . '</string>\r
+ <key>kind</key>\r
+ <string>software</string>\r
+ <key>title</key>\r
+ <string>' . $appName . '</string>\r
+ </dict>\r
+ </dict>\r
+ </array>\r
+</dict>\r
+</plist>';\r
+\r
+ file_put_contents($file, $xml);\r
+\r
+ unlink($tmp);\r
+ }\r
+ return $res;\r
+ }\r
+\r
public static function telecharger($args) {\r
commonDroits::min(array('extranet' => 0, 'ws' => 1));\r
\r
if ($server == 'references') {\r
$root = '/home/fluidbook/dev/references';\r
$url = 'http://www.fluidbook.com/references/';\r
+ $protocol = 'rsync';\r
} else if ($server == 'hosting') {\r
$root = '/home/fluidbook/hosting';\r
$url = 'http://hosting.fluidbook.com/';\r
+ $protocol = 'rsync';\r
} else if ($server == 'macbook_phonegap_ios') {\r
$root = '/mnt/macbook/Phonegap/Projects/';\r
$url = null;\r
+ $protocol = 'rsync';\r
+ } else if ($server == 'external') {\r
+ $protocol = 'ftp';\r
+ $url = null;\r
}\r
\r
- $e = explode('/', $_POST['dir']);\r
- $f = array();\r
- foreach ($e as $d) {\r
- if ($d == '..' || $d == '') {\r
- continue;\r
+ if ($protocol == 'rsync') {\r
+ $e = explode('/', $_POST['dir']);\r
+ $f = array();\r
+ foreach ($e as $d) {\r
+ if ($d == '..' || $d == '') {\r
+ continue;\r
+ }\r
+ $f[] = cubeText::str2URL($d);\r
}\r
- $f[] = cubeText::str2URL($d);\r
+ $dir = implode('/', $f);\r
+ } else {\r
+ $dir = $_POST['dir'];\r
}\r
- $dir = implode('/', $f);\r
\r
$dao->setInstallDir($book_id, $dir, $server);\r
\r
- $finalDir = $root . '/' . $dir;\r
- if (!file_exists($finalDir)) {\r
- mkdir($finalDir, 0777, true);\r
- }\r
+ if ($protocol == 'rsync') {\r
\r
- /** --del -r -z -v * */\r
- $cp = new cubeCommandLine('rsync');\r
- $cp->setPath(CONVERTER_PATH);\r
- $cp->setArg('del');\r
- $cp->setArg('t');\r
- $cp->setArg('r');\r
- $cp->setArg('z');\r
- $cp->setArg('v');\r
- $cp->setArg(null, $package . '*');\r
- $cp->setArg(null, $finalDir);\r
- $cp->execute();\r
-\r
- fb($cp->commande);\r
- fb($cp->output);\r
+ $finalDir = $root . '/' . $dir;\r
+ if (!file_exists($finalDir)) {\r
+ mkdir($finalDir, 0777, true);\r
+ }\r
\r
- fb(time(), 'end transfert');\r
+ /** --del -r -z -v * */\r
+ $cp = new cubeCommandLine('rsync');\r
+ $cp->setPath(CONVERTER_PATH);\r
+ $cp->setArg('del');\r
+ $cp->setArg('t');\r
+ $cp->setArg('r');\r
+ $cp->setArg('z');\r
+ $cp->setArg('v');\r
+ $cp->setArg(null, $package . '*');\r
+ $cp->setArg(null, $finalDir);\r
+ $cp->execute();\r
+\r
+ fb($cp->commande);\r
+ fb($cp->output);\r
+\r
+ fb(time(), 'end transfert');\r
+ } elseif ($protocol == 'ftp') {\r
+\r
+ $u = parse_url('ftp://' . $dir);\r
+\r
+ $commandes = array(\r
+ 'mkdir -p ' . $u['path'],\r
+ 'cd ' . $u['path'],\r
+ 'lcd ' . $package,\r
+ 'mirror -Rve'\r
+ );\r
+\r
+ //$lftp->setManualArg( . '> mirror -Rv ' . $package);\r
+\r
+ $lftp = new cubeCommandLine('lftp');\r
+ $lftp->setArg('u', $u['user'] . ',' . $u['pass']);\r
+ $lftp->setArg('e', implode(';', $commandes));\r
+ $lftp->setArg(null, $u['host']);\r
+ $lftp->execute();\r
+ fb($lftp->commande);\r
+ fb($lftp->output);\r
+ }\r
\r
$x->addClosePopup();\r
if (!is_null($url)) {\r
$versions['hosting'] = array('title' => __("Le serveur d'hébergement"), 'icon' => cubeMedia::silk('server_go.png'));\r
$versions['references'] = array('title' => __("L'espace références"), 'icon' => cubeMedia::silk('server_add.png'));\r
$versions['macbook_phonegap_ios'] = array('title' => __("Projet Phonegap IOS"), 'icon' => cubeMedia::silk('server_add.png'));\r
+ $versions['external'] = array('title' => __("Serveur FTP"), 'icon' => cubeMedia::silk('server_add.png'));\r
\r
foreach ($versions as $k => $v) {\r
$res .= '<li><a href="#" rel="instbook/$1/' . $k . '" class="ajax">' . $v['icon'] . $v['title'] . '</a></li>';\r
} elseif ($server == 'macbook_phonegap_ios') {\r
$s = __("Projet Phonegap iOS");\r
$dir = $book->dir_macbook_phonegap_ios;\r
+ } elseif ($server == 'external') {\r
+ $s = __('Serveur FTP externe') . ' : ftp://';\r
+ $dir = $book->dir_external;\r
}\r
\r
if ($dir == '') {\r
$dir = cubeText::str2URL($book->parametres->title);\r
}\r
\r
- $res = '<tr><td>' . __("Dossier d'installation") . '</td><td><em>' . $s . '</em> / ' . form::field('dir', 50, 50, $dir) . '</td></tr>';\r
+ $res = '<tr><td>' . __("Dossier d'installation") . '</td><td><em>' . $s . '</em> ' . form::field('dir', 60, 128, $dir) . '</td></tr>';\r
$res.='<tr><td colspan="2">' . __("A l'issue de l'installation, vous serez dirigé vers le serveur sur lequel la publication a été installée") . '</td></tr>';\r
return $res;\r
}\r
$book->dir_references = $r->dir_references;\r
$book->dir_hosting = $r->dir_hosting;\r
$book->dir_macbook_phonegap_ios = $r->dir_macbook_phonegap_ios;\r
+ $book->dir_external = $r->dir_external;\r
\r
return $book;\r
}\r
protected $dir_references;\r
protected $dir_hosting;\r
protected $dir_macbook_phonegap_ios;\r
+ protected $dir_external;\r
\r
public function __get($varname) {\r
if (!property_exists($this, $varname)) {\r
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";
}