Merge branch 'feature/Package_the_application' into 'develop'

Package the application

**Add package creation script (Issue #43)**

To package the application into a zip file, you will need to go to `/scripts/packaging.php`, and wait for 2 seconds.

The script copy all needed files/directories into `build` directory, then generate the file `dist/framadate-version-date.zip`, then delete directory `build`.

See merge request !48
This commit is contained in:
Olivier Perez 2015-04-14 09:01:58 +02:00
commit fc01fe6986
6 changed files with 203 additions and 284 deletions

View File

@ -1 +1,2 @@
allow from 127.0.0.1
deny from all

View File

@ -1,56 +0,0 @@
<?php
/**
* This software is governed by the CeCILL-B license. If a copy of this license
* is not distributed with this file, you can obtain one at
* http://www.cecill.info/licences/Licence_CeCILL-B_V1-en.txt
*
* Authors of STUdS (initial project): Guilhem BORGHESI (borghesi@unistra.fr) and Raphaël DROZ
* Authors of Framadate/OpenSondate: Framasoft (https://github.com/framasoft)
*
* =============================
*
* Ce logiciel est régi par la licence CeCILL-B. Si une copie de cette licence
* ne se trouve pas avec ce fichier vous pouvez l'obtenir sur
* http://www.cecill.info/licences/Licence_CeCILL-B_V1-fr.txt
*
* Auteurs de STUdS (projet initial) : Guilhem BORGHESI (borghesi@unistra.fr) et Raphaël DROZ
* Auteurs de Framadate/OpenSondage : Framasoft (https://github.com/framasoft)
*/
//ouverture de la connection avec la base SQL
$connect = pg_connect("host= dbname= user=");
$sondage=pg_exec($connect, "select * from sondage where format='D' or format='D+'");
for ($i=0;$i<pg_numrows($sondage);$i++) {
$dsondage=pg_fetch_object($sondage,$i);
// print "Pour le sondage ".$dsondage->id_sondage." ";
$sujets=pg_exec($connect, "select sujet from sujet_studs where id_sondage='$dsondage->id_sondage'");
$dsujets=pg_fetch_object($sujets,0);
$nouvelledateaffiche="";
$anciensujethoraires=explode(",",$dsujets->sujet);
for ($j=0;$j<count($anciensujethoraires);$j++) {
if (strpos('@',$anciensujethoraires[$j]) !== false) {
$ancientsujet=explode("@",$anciensujethoraires[$j]);
//;([0-2]\d)/([0-2]\d)/(\d{4});
if (preg_match(";(\d{1,2})/(\d{1,2})/(\d{4});",$ancientsujet[0],$registredate)) {
$nouvelledate=mktime(0,0,0,$registredate[2],$registredate[1],$registredate[3]);
// echo $ancientsujet[0].'@'.$ancientsujet[1].' ---> '.$nouvelledate.'@'.$ancientsujet[1].'<br> ';
$nouvelledateaffiche.=$nouvelledate.'@'.$ancientsujet[1].',';
}
} else {
if (preg_match(";(\d{1,2})/(\d{1,2})/(\d{4});",$anciensujethoraires[$j],$registredate)) {
$nouvelledate=mktime(0,0,0,$registredate[2],$registredate[1],$registredate[3]);
// echo $anciensujethoraires[$j].' ---- > '.$nouvelledate.'<br>';
$nouvelledateaffiche.=$nouvelledate.',';
}
}
}
$nouvelledateaffiche=substr($nouvelledateaffiche,0,-1);
print $dsujets->sujet.' donne '.$nouvelledateaffiche.'\n\n';
// pg_exec($connect,"update sujet_studs set sujet='$nouvelledateaffiche' where id_sondage='$dsondage->id_sondage'");
}

202
scripts/packaging.php Normal file
View File

@ -0,0 +1,202 @@
<?php
/**
* This software is governed by the CeCILL-B license. If a copy of this license
* is not distributed with this file, you can obtain one at
* http://www.cecill.info/licences/Licence_CeCILL-B_V1-en.txt
*
* Authors of STUdS (initial project): Guilhem BORGHESI (borghesi@unistra.fr) and Rapha?l DROZ
* Authors of Framadate/OpenSondate: Framasoft (https://github.com/framasoft)
*
* =============================
*
* Ce logiciel est r?gi par la licence CeCILL-B. Si une copie de cette licence
* ne se trouve pas avec ce fichier vous pouvez l'obtenir sur
* http://www.cecill.info/licences/Licence_CeCILL-B_V1-fr.txt
*
* Auteurs de STUdS (projet initial) : Guilhem BORGHESI (borghesi@unistra.fr) et Rapha?l DROZ
* Auteurs de Framadate/OpenSondage : Framasoft (https://github.com/framasoft)
*/
function d($thing) {
echo $thing . "\n";
}
function i($if, $thing, $copied = ' copied') {
if ($if) {
echo $thing . $copied . "\n";
} else {
echo '[fail] ' . $thing . "\n";
}
}
function rcopy($src, $dst) {
$dir = opendir($src);
@mkdir($dst);
$copied = true;
while (false !== ($file = readdir($dir))) {
if (($file != '.') && ($file != '..')) {
if (is_dir($src . '/' . $file)) {
$copied &= rcopy($src . '/' . $file, $dst . '/' . $file);
} else {
$copied &= copy($src . '/' . $file, $dst . '/' . $file);
}
}
}
closedir($dir);
return !!$copied;
}
function rrmdir($dir) {
$files = array_diff(scandir($dir), array('.', '..'));
foreach ($files as $file) {
(is_dir("$dir/$file")) ? rrmdir("$dir/$file") : unlink("$dir/$file");
}
return rmdir($dir);
}
function copyDependencyToBuild($dirname) {
return @mkdir(BUILD_VENDOR . $dirname, 755, true) && @rcopy(VENDOR . $dirname, BUILD_VENDOR . $dirname);
}
function copyFiles($files, &$result) {
foreach ($files as $key => $file) {
if (is_int($key)) {
$key = $file;
}
if (is_dir(ROOT . '/' . $key)) {
$result->$key = @rcopy(ROOT . '/' . $key, BUILD . '/' . $file);
} elseif (is_file(ROOT . '/' . $key)) {
$result->$key = @copy(ROOT . '/' . $key, BUILD . '/' . $file);
}
i($result->$key, $key);
}
}
function zip($source, $destination) {
if (extension_loaded('zip')) {
if (file_exists($source)) {
$zip = new ZipArchive();
if ($zip->open($destination, ZIPARCHIVE::CREATE)) {
$source = realpath($source);
if (is_dir($source)) {
$files = new RecursiveIteratorIterator(new RecursiveDirectoryIterator($source), RecursiveIteratorIterator::SELF_FIRST);
foreach ($files as $file) {
if (in_array(basename($file), array('.', '..'))) {
continue;
}
$file = realpath($file);
if ($file !== $source && is_dir($file)) {
$zip->addEmptyDir(str_replace($source . '\\', '', str_replace($source . '/', '', $file)));
} else if (is_file($file)) {
$zip->addFromString(str_replace($source . '\\', '', str_replace($source . '/', '', $file)), file_get_contents($file));
}
}
} else if (is_file($source)) {
$zip->addFromString(basename($source), file_get_contents($source));
}
}
return $zip->close();
}
}
return false;
}
ini_set('max_execution_time', 600);
ini_set('memory_limit', '1024M');
define('ROOT', realpath(__DIR__ . '/..'));
define('VENDOR', ROOT . '/vendor');
define('DIST', ROOT . '/dist');
define('BUILD', ROOT . '/build');
define('BUILD_VENDOR', BUILD . '/vendor');
include ROOT . '/app/inc/constants.php';
$result = new stdClass();
echo '<pre>';
// Delete old dist>build directories
if (file_exists(DIST)) {
$result->rmdirDist = rrmdir(DIST);
i($result->rmdirDist, 'Dist', ' deleted');
}
if (file_exists(BUILD)) {
$result->rmdirBuild = rrmdir(BUILD);
i($result->rmdirBuild, 'Build', ' deleted');
}
// Create dist>build directories
$result->mkdirDist = mkdir(DIST, 755);
i($result->mkdirDist, 'Dist', ' created');
$result->mkdirBuild = mkdir(BUILD, 755);
i($result->mkdirBuild, 'Build', ' created');
// Copy dependencies files
d('# Dependencies');
$result->composer = copyDependencyToBuild('/composer');
i($result->composer, 'composer');
$result->o80 = copyDependencyToBuild('/o80/i18n/src');
i($result->o80, 'o80-i18n');
$result->smarty = copyDependencyToBuild('/smarty/smarty/libs');
i($result->smarty, 'smarty');
$result->autoload = @copy(VENDOR . '/autoload.php', BUILD_VENDOR . '/autoload.php');
i($result->autoload, 'autoload');
// Copy assets
d('# Assets');
copyFiles(array('css', 'fonts', 'images', 'js'), $result);
// Copy sources
d('# Source directories');
copyFiles(array('admin', 'app', 'locale', 'tpl'), $result);
d('# Source files');
$files = array(
'adminstuds.php',
'bandeaux.php',
'create_classic_poll.php',
'create_date_poll.php',
'create_poll.php',
'exportcsv.php',
'favicon.ico',
'htaccess.txt',
'index.php',
'INSTALL.md',
'LICENCE.fr.txt',
'LICENSE.en.txt',
'maintenance.php',
'php.ini',
'README.md',
'robots.txt',
'studs.php'
);
copyFiles($files, $result);
// Zip Dist
$output = DIST . '/framadate-' . VERSION . '-' . date('Ymd') . '.zip';
zip(BUILD, $output);
rrmdir(BUILD);
if (isset($_GET['verbose'])) {
var_dump($result);
}
d('--------');
d('Distribution file: ' . realpath($output));
$generatedIn = round((microtime(true) - $_SERVER['REQUEST_TIME_FLOAT']), 4);
d('========');
d('Generated in: ' . $generatedIn . ' secondes');
echo '</pre>';

View File

@ -1,153 +0,0 @@
<?php
/**
* This software is governed by the CeCILL-B license. If a copy of this license
* is not distributed with this file, you can obtain one at
* http://www.cecill.info/licences/Licence_CeCILL-B_V1-en.txt
*
* Authors of STUdS (initial project): Guilhem BORGHESI (borghesi@unistra.fr) and Raphaël DROZ
* Authors of Framadate/OpenSondate: Framasoft (https://github.com/framasoft)
*
* =============================
*
* Ce logiciel est régi par la licence CeCILL-B. Si une copie de cette licence
* ne se trouve pas avec ce fichier vous pouvez l'obtenir sur
* http://www.cecill.info/licences/Licence_CeCILL-B_V1-fr.txt
*
* Auteurs de STUdS (projet initial) : Guilhem BORGHESI (borghesi@unistra.fr) et Raphaël DROZ
* Auteurs de Framadate/OpenSondage : Framasoft (https://github.com/framasoft)
*/
/*
raphael.droz@gmail.com, dwtfywwi licence , 2010 :
choppe un fichier $vara="traduction"; dans <lang>.inc
build un assoc array
preg_replace les appels wrappés dans gettext() dans le php principal
generate un .po
(
echo -e "<?php\n\$l = array (";
sed -n '/^$.*$/s/^$\([^=]\+\)=.\(.*\).;/"\1"=>\x27\2\x27,/p' lang/en.inc;
echo '); ?>'
) > /tmp/lang.mod
(manually tweak 2 double quotes)
*/
// drop a $l which contain the array
if(isset($_SERVER['PHP_SELF'])) {
die(); // die if not run with php-cli
}
require_once('/tmp/lang.mod');
$mypath = '/var/www/studs';
/* Language, country need to be adapted */
$header = 'msgid ""
msgstr ""
"Project-Id-Version: Studs 0.6.4\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2010-05-01 18:32+0100\n"
"PO-Revision-Date: 2010-05-01 18:32+0100\n"
"Last-Translator: Raphaël Droz <raphael.droz@gmail.com>\n"
"Language-Team: Guilhem Borghesi, Raphaël Droz\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n"
"X-Poedit-Language: FR\n"
"X-Poedit-Country: FRANCE\n"
"X-Poedit-SourceCharset: utf-8\n"
"X-Poedit-KeywordsList: _\n"
"X-Poedit-Basepath: /var/www/studs\n"
"X-Poedit-SearchPath-0: .\n"
';
/* helpers */
function stripN($a)
{
return preg_replace("/\n/","\\n", $a);
}
function addDQ($a)
{
return addcslashes($a,'"');
}
/* low priority for weak regexps (small variable length) at the end, please */
function cmp($a, $b)
{
return (mb_strlen($a) < mb_strlen($b));
}
uksort($l, 'cmp');
/*
0: surely direct, like in: echo 'text ' . $var;
1: wrap in, like in: echo "$var";
2: direct, like in: echo $var . "text";
*/
$match0 = $repl0 = $match1 = $repl1 = $match2 = $repl2 = $match3 = $repl3 = array();
foreach($l as $k => $v) {
$match0[] = ';([\'"][ \.]|echo|print) *\$' . $k . ' *([\. ][\'"]|\;);' ;
$repl0[] = '\1 _("' . stripN(stripcslashes($v)) . '") \2' ;
$match1[] = ';(["\'])(.*?)\$' . $k . ';' ;
$repl1[] = '\1\2" . _("' . stripN(addcslashes(stripcslashes($v),'"')) . '") . \1' ;
$match2[] = ';\$' . $k . ';' ;
$repl2[] = '_("' . stripN(stripcslashes($v)) . '")' ;
$match3[] = ';\. *\$GLOBALS\["' . $k . '"\] *\.;' ;
$repl3[] = '. _("' . stripN(stripcslashes($v)) . '") .' ;
}
foreach (new DirectoryIterator('.') as $fileInfo) {
if($fileInfo->isDot()) {
continue;
}
$name = $fileInfo->getFilename();
// process php files
if(!preg_match('/\.php$/' , $name) || preg_match('/phpVar2getText/', $name)) {
continue;
}
$orig = file_get_contents($name);
$a = preg_replace($match0, $repl0, $orig, -1, $b);
$a = preg_replace($match1, $repl1, $a, -1, $c);
$a = preg_replace($match2, $repl2, $a, -1, $d);
$a = preg_replace($match3, $repl3, $a, -1, $e);
$tot = $b + $c + $e;
echo $name . ' --- ' . $tot . " (match1: $c)" . "\n";
if($tot > 0) {
file_put_contents($name . '.save', $orig);
file_put_contents($name, $a);
}
}
foreach(array('fr_FR','es_ES','de_DE', 'en_GB') as $i) {
$ii = explode('_', $i);
$f = $ii[0]; $g = $ii[1];
// de.inc corrupted the whole process !
unset($tt_adminstuds_mail_corps_changemail);
// now define each of the strings with a new langague
require_once($mypath . '/lang/' . $f . '.inc');
$a = '';
/* duplicates are fatal to poedit */
foreach(array_unique($l) as $k => $v) {
/* poedit is strict with its syntax */
$po_ready_v = stripN(addDQ($v));
if($f == 'en') {
$a .= 'msgid "' . $po_ready_v . '"' . "\n" . 'msgstr "' . $po_ready_v . '"' . "\n\n";
} else {
$a .= 'msgid "' . $po_ready_v . '"' . "\n" .
/* ${$k} the key (var name) in the orig (EN) array
to look for as a raw $var while the <lang>.inc is included in the context */
'msgstr "' . stripN(addDQ(${$k})) . '"' . "\n\n";
}
}
file_put_contents('locale/' . $f . '_' . $g . '/LC_MESSAGES/Studs.po', $header . $a);
}

View File

@ -1,46 +0,0 @@
#/==========================================================================
#/
#/Université de Strasbourg - Direction Informatique
#/Auteur : Guilhem BORGHESI
#/Création : Février 2008
#/
#/borghesi@unistra.fr
#/
#/Ce logiciel est régi par la licence CeCILL-B soumise au droit français et
#/respectant les principes de diffusion des logiciels libres. Vous pouvez
#/utiliser, modifier et/ou redistribuer ce programme sous les conditions
#/de la licence CeCILL-B telle que diffusée par le CEA, le CNRS et l'INRIA
#/sur le site "http://www.cecill.info".
#/
#/Le fait que vous puissiez accéder à cet en-tête signifie que vous avez
#/pris connaissance de la licence CeCILL-B, et que vous en avez accepté les
#/termes. Vous pouvez trouver une copie de la licence dans le fichier LICENCE.
#/
#/==========================================================================
#/
#/Université de Strasbourg - Direction Informatique
#/Author : Guilhem BORGHESI
#/Creation : Feb 2008
#/
#/borghesi@unistra.fr
#/
#/This software is governed by the CeCILL-B license under French law and
#/abiding by the rules of distribution of free software. You can use,
#/modify and/ or redistribute the software under the terms of the CeCILL-B
#/license as circulated by CEA, CNRS and INRIA at the following URL
#/"http://www.cecill.info".
#/
#/The fact that you are presently reading this means that you have had
#/knowledge of the CeCILL-B license and that you accept its terms. You can
#/find a copy of this license in the file LICENSE.
#/
#/==========================================================================
#!/usr/bin/perl
open (FILE,"../admin/logs_studs.txt");
while (<FILE>) {
/.*\t(.*u-strasbg.fr)\t.*/;
print $1."\n";
}

View File

@ -1,29 +0,0 @@
<?php
/**
* This software is governed by the CeCILL-B license. If a copy of this license
* is not distributed with this file, you can obtain one at
* http://www.cecill.info/licences/Licence_CeCILL-B_V1-en.txt
*
* Authors of STUdS (initial project): Guilhem BORGHESI (borghesi@unistra.fr) and Raphaël DROZ
* Authors of Framadate/OpenSondate: Framasoft (https://github.com/framasoft)
*
* =============================
*
* Ce logiciel est régi par la licence CeCILL-B. Si une copie de cette licence
* ne se trouve pas avec ce fichier vous pouvez l'obtenir sur
* http://www.cecill.info/licences/Licence_CeCILL-B_V1-fr.txt
*
* Auteurs de STUdS (projet initial) : Guilhem BORGHESI (borghesi@unistra.fr) et Raphaël DROZ
* Auteurs de Framadate/OpenSondage : Framasoft (https://github.com/framasoft)
*/
//ouverture de la connection avec la base SQL
$connect = pg_connect("host= dbname= user=");
$sondage=pg_exec($connect, "select distinct mail_admin from sondage ");
for ($i=0;$i<pg_numrows($sondage);$i++){
$dsondage=pg_fetch_object($sondage,$i);
print "$dsondage->mail_admin, ";
// print "$dsondage->mail_admin\n";
}