Révision cf314c59
original.cpp | ||
---|---|---|
61 | 61 |
|
62 | 62 |
m_baseDir = QDir(QDir::homePath() + "/RyXeo-Applications/WebPhotoAlbum"); |
63 | 63 |
m_baseDir.setFilter(QDir::Dirs | QDir::NoSymLinks | QDir::NoDotAndDotDot); |
64 |
QFileInfoList list = m_baseDir .entryInfoList();
|
|
64 |
QFileInfoList list = m_baseDir.entryInfoList(); |
|
65 | 65 |
for(int i = 0; i < list.count(); i++) { |
66 | 66 |
QTreeWidgetItem *item = new QTreeWidgetItem(ui->treeWidget); |
67 | 67 |
item->setText(0, list.at(i).fileName()); |
... | ... | |
409 | 409 |
void original::on_btnUpload_clicked() |
410 | 410 |
{ |
411 | 411 |
qDebug() << "on_btnUpload_clicked : " << ui->treeWidget->currentItem()->data(1,0).toString(); |
412 |
|
|
413 |
makeZip(m_baseDir.absolutePath() + "/" + ui->treeWidget->currentItem()->text(0) + "/hq", |
|
414 |
m_baseDir.absolutePath() + "/" + ui->treeWidget->currentItem()->text(0) + "/zip/hq.zip"); |
|
415 |
|
|
416 |
makeZip(m_baseDir.absolutePath() + "/" + ui->treeWidget->currentItem()->text(0) + "/mq", |
|
417 |
m_baseDir.absolutePath() + "/" + ui->treeWidget->currentItem()->text(0) + "/zip/mq.zip"); |
|
418 |
|
|
419 |
makeZip(m_baseDir.absolutePath() + "/" + ui->treeWidget->currentItem()->text(0) + "/lq", |
|
420 |
m_baseDir.absolutePath() + "/" + ui->treeWidget->currentItem()->text(0) + "/zip/lq.zip"); |
|
421 |
|
|
422 |
makeZip(m_baseDir.absolutePath() + "/" + ui->treeWidget->currentItem()->text(0) + "/thumbs", |
|
423 |
m_baseDir.absolutePath() + "/" + ui->treeWidget->currentItem()->text(0) + "/zip/thumbs.zip"); |
|
424 |
|
|
412 | 425 |
m_tools->clear(); |
413 | 426 |
|
414 | 427 |
m_tools->ftpConnect(ui->leFTPServeur->text(), |
... | ... | |
448 | 461 |
ui->pbFTPProgress->setMaximum(total); |
449 | 462 |
ui->pbFTPProgress->setValue(current); |
450 | 463 |
} |
464 |
|
|
465 |
void original::makeZip(QString repSource, QString destFileName) |
|
466 |
{ |
|
467 |
QApplication::setOverrideCursor(QCursor(Qt::WaitCursor)); |
|
468 |
ui->statusBar->showMessage(QString::fromUtf8("Création du fichier ZIP %1 en cours").arg(destFileName), 5000); |
|
469 |
qApp->processEvents(); |
|
470 |
qDebug() << "original::makeZip " << repSource << " :: " << destFileName; |
|
471 |
//Creation d'une archive ZIP dans tous les cas |
|
472 |
QuaZip zipDestination(destFileName); |
|
473 |
if(zipDestination.open(QuaZip::mdCreate)) { |
|
474 |
//On sauvegarde tout dans ce fichier |
|
475 |
QuaZipFile fichierDehors(&zipDestination); |
|
476 |
|
|
477 |
//Les droits par defaut en 644 pour les fichiers contenus dans le .zip |
|
478 |
QuaZipNewInfo newInfo(""); |
|
479 |
int permission644 = 33188; |
|
480 |
newInfo.externalAttr = (permission644 << 16L); |
|
481 |
|
|
482 |
QDir dir(repSource); |
|
483 |
dir.setFilter(QDir::Files); |
|
484 |
QFileInfoList fileList = dir.entryInfoList(); |
|
485 |
qDebug() << "avant " << fileList.count(); |
|
486 |
for(int i = 0; i < fileList.count(); i++) { |
|
487 |
QString fileName = fileList.at(i).fileName(); |
|
488 |
QFile fic(fileList.at(i).absoluteFilePath()); |
|
489 |
qDebug() << "On ajoute le fichier " << fileName; |
|
490 |
newInfo.name = fileName; |
|
491 |
if(fic.open(QIODevice::ReadOnly) && fichierDehors.open(QIODevice::WriteOnly,newInfo)) { |
|
492 |
fichierDehors.write(fic.read(fic.size())); |
|
493 |
fichierDehors.close(); |
|
494 |
fic.close(); |
|
495 |
qDebug() << " ajout ok"; |
|
496 |
} |
|
497 |
} |
|
498 |
zipDestination.close(); |
|
499 |
} |
|
500 |
QApplication::restoreOverrideCursor(); |
|
501 |
} |
original.h | ||
---|---|---|
40 | 40 |
#include "tools.h" |
41 | 41 |
#include "assistant.h" |
42 | 42 |
#include "newalbumdialog.h" |
43 |
#include "quazip.h" |
|
44 |
#include "quazipfile.h" |
|
45 |
|
|
43 | 46 |
|
44 | 47 |
namespace Ui { |
45 | 48 |
class original; |
... | ... | |
71 | 74 |
void on_action_Assistant_d_installation_triggered(); |
72 | 75 |
void updateProgressFichier(int total, int current); |
73 | 76 |
void updateProgressData(int total, int current); |
77 |
void makeZip(QString repSource, QString destFileName); |
|
74 | 78 |
|
75 | 79 |
private: |
76 | 80 |
Ui::original *ui; |
original.ui | ||
---|---|---|
74 | 74 |
</widget> |
75 | 75 |
<widget class="QTabWidget" name="tabWidget"> |
76 | 76 |
<property name="currentIndex"> |
77 |
<number>0</number>
|
|
77 |
<number>2</number>
|
|
78 | 78 |
</property> |
79 | 79 |
<widget class="QWidget" name="tabProprietes"> |
80 | 80 |
<attribute name="title"> |
... | ... | |
304 | 304 |
</property> |
305 | 305 |
</widget> |
306 | 306 |
</item> |
307 |
<item row="7" column="0" colspan="2"> |
|
308 |
<widget class="QWebView" name="webView"> |
|
309 |
<property name="url"> |
|
310 |
<url> |
|
311 |
<string>about:blank</string> |
|
312 |
</url> |
|
313 |
</property> |
|
314 |
</widget> |
|
315 |
</item> |
|
307 | 316 |
</layout> |
308 | 317 |
</widget> |
309 | 318 |
</widget> |
... | ... | |
374 | 383 |
</action> |
375 | 384 |
</widget> |
376 | 385 |
<layoutdefault spacing="6" margin="11"/> |
386 |
<customwidgets> |
|
387 |
<customwidget> |
|
388 |
<class>QWebView</class> |
|
389 |
<extends>QWidget</extends> |
|
390 |
<header>QtWebKit/QWebView</header> |
|
391 |
</customwidget> |
|
392 |
</customwidgets> |
|
377 | 393 |
<tabstops> |
378 | 394 |
<tabstop>treeWidget</tabstop> |
379 | 395 |
</tabstops> |
ryxeo-webphotoalbum.pro | ||
---|---|---|
4 | 4 |
# |
5 | 5 |
#------------------------------------------------- |
6 | 6 |
|
7 |
QT += core gui network |
|
7 |
QT += core gui network webkit
|
|
8 | 8 |
|
9 | 9 |
TARGET = ryxeo-webphotoalbum |
10 | 10 |
TEMPLATE = app |
... | ... | |
33 | 33 |
} |
34 | 34 |
|
35 | 35 |
RESOURCES += resources.qrc |
36 |
|
|
37 |
# la lib quazip: les fichiers sont des archives zip |
|
38 |
include(lib/quazip/quazip/quazip.pri) |
tools.cpp | ||
---|---|---|
32 | 32 |
QObject(parent) |
33 | 33 |
{ |
34 | 34 |
m_baseDir = basedir; |
35 |
|
|
36 |
m_web = new QWebView(); |
|
37 |
connect(m_web,SIGNAL(loadFinished(bool)),this,SLOT(unzipFinished(bool))); |
|
35 | 38 |
} |
36 | 39 |
|
37 | 40 |
void tools::ftpConnect(QString serveur, QString login, QString passwd) |
... | ... | |
94 | 97 |
m_ftp->cd("/"); |
95 | 98 |
m_ftp->list("/"); |
96 | 99 |
m_ftp->clearPendingCommands(); |
97 |
AbulEduSleeperThread::msleep(2000);
|
|
100 |
AbulEduSleeperThread::msleep(800);
|
|
98 | 101 |
} |
99 | 102 |
qDebug() << "======================= END FTP INFO ======================= "; |
100 | 103 |
|
... | ... | |
154 | 157 |
{ |
155 | 158 |
if(!m_ftpCommands.isEmpty()) { |
156 | 159 |
QStringList cmd(m_ftpCommands.takeFirst().split(";")); |
160 |
//Commande speciale pour extraire un fichier ZIP sur le serveur |
|
161 |
//exemple: http://webopenphoto.free.fr/sagc/extract.php?src=galleries/Cala-Montjoi-2012_Christophe/zip/mq.zip |
|
162 |
if(cmd.at(0) == "unzip") { |
|
163 |
QUrl u("http://webopenphoto.free.fr/sagc/extract.php?src=" + cmd.at(1)); |
|
164 |
m_web->load(u); |
|
165 |
qDebug() << "Ouverture de " << u; |
|
166 |
} |
|
157 | 167 |
if(cmd.at(0) == "mkdir") { |
158 | 168 |
m_ftp->mkdir(cmd.at(1)); |
159 | 169 |
} |
... | ... | |
172 | 182 |
} |
173 | 183 |
} |
174 | 184 |
|
185 |
void tools::unzipFinished(bool status) |
|
186 |
{ |
|
187 |
ftpNextCommand(); |
|
188 |
} |
|
189 |
|
|
190 |
void tools::ftpUnzip(QString zipUrl) |
|
191 |
{ |
|
192 |
qDebug() << "tools::ftpUnzip " << zipUrl; |
|
193 |
m_ftpCommands << "unzip;" + zipUrl; |
|
194 |
} |
|
195 |
|
|
175 | 196 |
void tools::ftpMkdir(QString rep) |
176 | 197 |
{ |
177 | 198 |
//Avant de faire un mkdir il faut verifier si le repertoire n'existe pas deja |
... | ... | |
192 | 213 |
dir.setFilter(QDir::Hidden | QDir::Files | QDir::Dirs | QDir::NoSymLinks | QDir::NoDotAndDotDot); |
193 | 214 |
QFileInfoList list = dir.entryInfoList(); |
194 | 215 |
for(int i = 0; i < list.count(); i++) { |
195 |
qDebug() << "Ajout de " << list.at(i).absoluteFilePath() << " rep serveur : " << repertoireServeur; |
|
216 |
qDebug() << " Ajout de " << list.at(i).absoluteFilePath() << " rep serveur : " << repertoireServeur;
|
|
196 | 217 |
m_fileListToUpload.insert(list.at(i).absoluteFilePath(), repertoireServeur); |
197 | 218 |
m_fileListToUploadIndex << list.at(i).absoluteFilePath(); |
219 |
|
|
198 | 220 |
if(list.at(i).isDir()) { |
199 |
parcoursRecursif(list.at(i).absoluteFilePath(), list.at(i).absoluteFilePath().remove(m_baseDir.absolutePath()).remove("/www")); |
|
221 |
if(list.at(i).fileName() == "hq" || list.at(i).fileName() == "mq" || list.at(i).fileName() == "lq" || list.at(i).fileName() == "thumbs") { |
|
222 |
qDebug() << " On ne parcours pas " << list.at(i).absoluteFilePath(); |
|
223 |
} |
|
224 |
else { |
|
225 |
parcoursRecursif(list.at(i).absoluteFilePath(), list.at(i).absoluteFilePath().remove(m_baseDir.absolutePath()).remove("/www")); |
|
226 |
} |
|
200 | 227 |
} |
201 | 228 |
} |
202 | 229 |
} |
... | ... | |
219 | 246 |
else { |
220 | 247 |
QString ladest = m_destDirBase + "/galleries/" + m_fileListToUpload.value(fi.absoluteFilePath()) + "/" + fi.fileName(); |
221 | 248 |
ftpPut(fi.absoluteFilePath(),ladest); |
249 |
if(fi.absoluteFilePath().endsWith(".zip")) { |
|
250 |
ftpUnzip("galleries/" + m_fileListToUpload.value(fi.absoluteFilePath()) + "/" + fi.fileName()); |
|
251 |
} |
|
222 | 252 |
} |
223 | 253 |
} |
224 | 254 |
} |
tools.h | ||
---|---|---|
32 | 32 |
#include <QApplication> |
33 | 33 |
#include <QDir> |
34 | 34 |
#include <QThread> |
35 |
#include <QWebView> |
|
35 | 36 |
|
36 | 37 |
class tools : public QObject |
37 | 38 |
{ |
... | ... | |
59 | 60 |
int nbResteUpload(); |
60 | 61 |
void ftpMkdir(QString rep); |
61 | 62 |
void ftpPut(QString source, QString ladest); |
63 |
void ftpUnzip(QString zipUrl); |
|
62 | 64 |
void ftpNextCommand(); |
65 |
void unzipFinished(bool status); |
|
63 | 66 |
|
64 | 67 |
private: |
65 | 68 |
QFtp *m_ftp; |
... | ... | |
72 | 75 |
int m_currentProjectPictureNumber; |
73 | 76 |
int m_currentFTPFileUpload; |
74 | 77 |
QStringList m_ftpCommands; |
78 |
QWebView *m_web; |
|
75 | 79 |
}; |
76 | 80 |
|
77 | 81 |
#endif // TOOLS_H |
www/extract.php | ||
---|---|---|
3 | 3 |
//GNU/GPL |
4 | 4 |
print "<pre>"; |
5 | 5 |
require_once("zip/pclzip.lib.php"); |
6 |
if($_GET['src'] != "" && $_GET['dst'] != "") {
|
|
6 |
if($_GET['src'] != "") { |
|
7 | 7 |
$base = getcwd() . "/"; |
8 | 8 |
print "on est ici : " . getcwd() . "\n"; |
9 |
print "on essaye de decompresser " . $_GET['src'] . " vers " . $_GET['dst'] . "\n";
|
|
9 |
print "on essaye de decompresser " . $base . $_GET['src'];
|
|
10 | 10 |
if(file_exists($base . $_GET['src'])) { |
11 | 11 |
$archive = new PclZip($base . $_GET['src']); |
12 |
//src=galleries/Cala-Montjoi-2012_Christophe/zip/mq.zip |
|
13 |
//et nous on extrait dans galleries/Cala-Montjoi-2012_Christophe/mq |
|
14 |
$dstRep = basename($_GET['src'],".zip"); |
|
15 |
$dst = dirname(dirname($base . $_GET['src'])) . "/" . $dstRep; |
|
16 |
print " vers $dst\n"; |
|
17 |
|
|
12 | 18 |
//Extrait dans le repertoire courant. |
13 |
if(is_dir($base . $_GET['dst'])) {
|
|
14 |
chdir($base . $_GET['dst']);
|
|
19 |
if(is_dir($dst)) {
|
|
20 |
chdir($dst);
|
|
15 | 21 |
$list = $archive->extract(); |
16 | 22 |
if($list == 0) { |
17 | 23 |
die("Error : ".$archive->errorInfo(true)); |
Formats disponibles : Unified diff