From: vincent@cubedesigners.com Date: Tue, 13 Nov 2012 19:00:24 +0000 (+0000) Subject: (no commit message) X-Git-Url: http://git.cubedesigners.com/?a=commitdiff_plain;h=4b937b4dd593c50330c1deadfd2d9a2caa53d1dc;p=cubeextranet.git --- diff --git a/.htaccess b/.htaccess index 32dcb4bc4..05044698f 100644 --- a/.htaccess +++ b/.htaccess @@ -31,7 +31,7 @@ AddCharset UTF-8 log #RewriteRule ^docs - [L] RewriteRule ^ajax/supprimeFichier/([0-9]+)/(.*)$ index.php/ajax/supprimeFichier/$1/$2 [L] - RewriteRule ^telecharger/([0-9]+)/(.*)$ index.php/telecharger/$1/$2 [L] + RewriteRule ^telecharger/([0-9a-fA-F]+)/([0-9]+)/(.*)$ index.php/telecharger/$1/$2/$3 [L] RewriteRule ^([-_a-zA-Z0-9/]+)$ index.php/$1 [L] RewriteRule ^viewer/([0-9]+)_([0-9a-fA-F]+)_([0-9]+)/index.html$ viewer/$1_$2_$3/index [L] diff --git a/inc/commons/class.common.tools.php b/inc/commons/class.common.tools.php index f7b816c44..dce745e8e 100644 --- a/inc/commons/class.common.tools.php +++ b/inc/commons/class.common.tools.php @@ -297,8 +297,8 @@ class commonTools { $icotool->setArg('c'); $icotool->setArg('o', $tmp . '/favicon.ico'); - $sizes = array(16, 32, 57, 64, 72, 114, 128, 256); - $apple = array(114, 72, 57); + $sizes = array(16, 32, 57, 64, 72, 114, 128, 144, 256); + $apple = array(144, 114, 72, 57); foreach ($sizes as $s) { diff --git a/inc/commons/class.common.url.php b/inc/commons/class.common.url.php index 7eb914ddc..05e972468 100644 --- a/inc/commons/class.common.url.php +++ b/inc/commons/class.common.url.php @@ -425,11 +425,12 @@ class commonUrl { 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') . ''; + $res = ''; + if ($ext == 'ipa') { + $res.='' . $core->typo->Telecharger('Installer') . ' '; } + $res.= '' . $core->typo->Telecharger('Télécharger') . ''; + return $res; } public static function manifestFromIpa($fichier) { @@ -451,11 +452,12 @@ class commonUrl { $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; + $ipaURL = 'http://' . $_SERVER['HTTP_HOST'] . '/telecharger/' . self::hashFile($fichier->relPath . '//') . '/' . $fichier->relPath; $xml = ' @@ -496,15 +498,28 @@ class commonUrl { return $res; } + public static function hashFile($path) { + $path = trim($path, '/'); + fb($path); + return sha1('!!//' . $path . '||--'); + } + public static function telecharger($args) { - commonDroits::min(array('extranet' => 0, 'ws' => 1)); + array_shift($args); + $hash = array_shift($args); $path = implode('/', $args); $utilisateur_id = array_shift($args); - commonDroits::telecharger($utilisateur_id); - $dir = md5($path . (rand(1, 235548684) * 50.5)); $nom = array_pop($args); + + $verihash = self::hashFile($path); + if ($hash != $verihash) { + return; + } + + $dir = md5($path . (rand(1, 235548684) * 50.5)); + @mkdir(ROOT . '/cache/download/' . $dir, 0755, true); copy(FTPROOT . $path, ROOT . '/cache/download/' . $dir . '/' . $nom); @@ -573,7 +588,7 @@ class commonUrl { $body = 'Tous les fichiers de ' . $client->prenom . ' ' . $client->nom . ' : http://' . $_SERVER['HTTP_HOST'] . '/fichiers/' . $client->utilisateur_id . "\n\n"; $body .= 'Fichiers chargés : ' . "\n"; foreach ($_SESSION['files_uploaded'] as $f) { - $body .= ' - http://' . $_SERVER['HTTP_HOST'] . '/telecharger/' . $f . "\n"; + $body .= ' - http://' . $_SERVER['HTTP_HOST'] . '/telecharger/' . commonUrl::hashFile($f) . '/' . $f . "\n"; } $body .= "\n" . RAPPEL . " : \n"; $body .= ' - Adresse : http://' . $_SERVER['HTTP_HOST'] . '/' . "\n"; diff --git a/inc/ws/Metier/class.ws.theme.parametres.php b/inc/ws/Metier/class.ws.theme.parametres.php index a41f265f9..2df61748a 100644 --- a/inc/ws/Metier/class.ws.theme.parametres.php +++ b/inc/ws/Metier/class.ws.theme.parametres.php @@ -210,9 +210,21 @@ class wsThemeParametres extends wsParametres { 'fileFilter' => $imageFilter, 'uploadURL' => SITE_PATH . 'flash/uploadThemeFile/?theme_id=' . $this->parent->theme_id . '&type=ico', 'hint' => __('Image PNG de 256x256')); + $this->fields['iosicon'] = array('type' => 'file', 'default' => '', 'editable' => true, + 'label' => __('Icone (pour application iOS)'), + 'path' => $themeRoot, + 'fileFilter' => $imageFilter, + 'uploadURL' => SITE_PATH . 'flash/uploadThemeFile/?theme_id=' . $this->parent->theme_id . '&type=ico', + 'hint' => __('Image PNG de 1024x1024')); + $this->fields['androidicon'] = array('type' => 'file', 'default' => '', 'editable' => true, + 'label' => __('Icone (pour application Android)'), + 'path' => $themeRoot, + 'fileFilter' => $imageFilter, + 'uploadURL' => SITE_PATH . 'flash/uploadThemeFile/?theme_id=' . $this->parent->theme_id . '&type=ico', + 'hint' => __('Image PNG de 1024x1024')); $this->forms['logo'] = array('label' => __('Personnalisation du logo'), - 'fieldsnames' => array('logo', 'favicon')); + 'fieldsnames' => array('logo', '|', 'favicon', 'iosicon', 'androidicon')); /* Loader */ $this->fields['logoLoader'] = array('type' => 'file', 'default' => 'logoLoader.png', 'editable' => true, 'label' => __('Logo affiché au chargement'), diff --git a/inc/ws/Util/packager/class.ws.packager.phonegap.php b/inc/ws/Util/packager/class.ws.packager.phonegap.php index c99c43131..41711cb9e 100644 --- a/inc/ws/Util/packager/class.ws.packager.phonegap.php +++ b/inc/ws/Util/packager/class.ws.packager.phonegap.php @@ -39,18 +39,16 @@ class wsPackagerPhonegap extends wsPackager { if ($this->makeResources) { - if ($this->os == 'ios') { - $this->resources = $vdir . '/Resources'; - $this->makeIOSResources(); - } elseif ($this->os == 'android') { - $this->resources = $vdir . '/Resources'; - $this->makeAndroidResources(); + if ($os == 'ios') { + $this->makeIOSResources($vdir . '/Resources'); + } elseif ($os == 'android') { + $this->makeAndroidResources($vdir . '/Resources'); } } } } - protected function makeAndroidResources() { + protected function makeAndroidResources($resources) { $icons = array('drawable' => 96, 'drawable-hdpi' => 72, 'drawable-ldpi' => 36, @@ -66,16 +64,16 @@ class wsPackagerPhonegap extends wsPackager { 'drawable-xhdpi' => '1280x1920'); foreach ($icons as $dir => $size) { - $d = $this->resources . '/' . $dir; + $d = $resources . '/' . $dir; if (!file_exists($d)) { mkdir($d, 0777, true); } - $this->_makeIcon($size, 'icon', $d); + $this->_makeIcon($size, 'icon', $d, 'android'); } foreach ($splashs as $dir => $size) { - $d = $this->resources . '/' . $dir; + $d = $resources . '/' . $dir; if (!file_exists($d)) { mkdir($d, 0777, true); } @@ -92,55 +90,54 @@ class wsPackagerPhonegap extends wsPackager { } } - protected function makeIOSResources() { + protected function makeIOSResources($resources) { $splashs = array('320x480' => 'Default~iphone', '640x960' => 'Default@2x~iphone', '1024x748' => 'Default-Landscape~ipad', '768x1004' => 'Default-Portrait~ipad', '2048x1496' => 'Default-Landscape@2x~ipad', '1536x2008' => 'Default-Portrait@2x~ipad', '640x1136' => 'Default-568h@2x~iphone'); $icons = array(57 => 'icon', 72 => 'icon-72', 114 => 'icon@2x', 144 => 'icon-72@2x'); - if (!file_exists($this->resources . '/splash')) { - mkdir($this->resources . '/splash', 0777, true); + if (!file_exists($resources . '/splash')) { + mkdir($resources . '/splash', 0777, true); } if (!file_exists($this->resources . '/icons')) { - mkdir($this->resources . '/icons', 0777, true); + mkdir($resources . '/icons', 0777, true); } foreach ($splashs as $size => $name) { list($width, $height) = explode('x', $size); - $this->_makeSplash($width, $height, $name); + $this->_makeSplash($width, $height, $name, $resources . '/icons'); } foreach ($icons as $size => $name) { - $this->_makeIcon($size, $name); + $this->_makeIcon($size, $name, $resources . '/icons', 'ios'); } } - protected function _makeSplash($width, $height, $name, $dir = null) { + protected function _makeSplash($width, $height, $name, $dir) { $im = imagecreatetruecolor($width, $height); // Draw Background $back = imagecolorhexallocate($im, $this->theme->parametres->backgroundColor); imagefill($im, 0, 0, $back); // Draw image - if (is_null($dir)) { - $dir = $this->resources . '/splash'; - } $this->_drawBackImage($im, $width, $height); imagepng($im, $dir . '/' . $name . '.png'); } - protected function _makeIcon($size, $name, $dir = null) { - if ($this->theme->parametres->favicon != '') { + protected function _makeIcon($size, $name, $dir, $os = '') { + + $os = strtolower($os); + $icoos = $os.'icon'; + + if (isset($this->theme->parametres->$icoos) && $this->theme->parametres->$icoos != '') { + $base = $this->themeRoot . '/' . $this->theme->parametres->$icoos; + } elseif ($this->theme->parametres->favicon != '') { $base = $this->themeRoot . '/' . $this->theme->parametres->favicon; } else { $base = WS_COMPILE_ASSETS . '/_ico/phonegap.png'; } - if (is_null($dir)) { - $dir = $this->resources . '/icons'; - } - - $it = new imageTools(); + $it = new cubeImageTools(); $it->loadImage($base); - $it->resize($size, $size, 'ratio'); + $it->resize($size, $size, 'ratio',false,'C','M','transparent'); $it->output('png', $dir . '/' . $name . '.png'); }