From 5ebcfca91eef505fbc183603755c413277513b1b Mon Sep 17 00:00:00 2001 From: Olivier PEREZ Date: Fri, 10 Apr 2015 00:44:54 +0200 Subject: [PATCH 1/3] Delete deprecated scripts --- scripts/migration_date.php | 56 ---------- scripts/phpVar2getText.php | 153 ---------------------------- scripts/recherche_adresse.pl | 46 --------- scripts/recherche_adresse_admin.php | 29 ------ 4 files changed, 284 deletions(-) delete mode 100644 scripts/migration_date.php delete mode 100644 scripts/phpVar2getText.php delete mode 100644 scripts/recherche_adresse.pl delete mode 100644 scripts/recherche_adresse_admin.php diff --git a/scripts/migration_date.php b/scripts/migration_date.php deleted file mode 100644 index b6b5c77..0000000 --- a/scripts/migration_date.php +++ /dev/null @@ -1,56 +0,0 @@ -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 '.$nouvelledate.'@'.$ancientsujet[1].'
'; - $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.'
'; - $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'"); -} diff --git a/scripts/phpVar2getText.php b/scripts/phpVar2getText.php deleted file mode 100644 index 597735c..0000000 --- a/scripts/phpVar2getText.php +++ /dev/null @@ -1,153 +0,0 @@ -.inc - build un assoc array - preg_replace les appels wrappés dans gettext() dans le php principal - generate un .po - - ( - echo -e "\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 \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 .inc is included in the context */ - 'msgstr "' . stripN(addDQ(${$k})) . '"' . "\n\n"; - } - } - file_put_contents('locale/' . $f . '_' . $g . '/LC_MESSAGES/Studs.po', $header . $a); -} diff --git a/scripts/recherche_adresse.pl b/scripts/recherche_adresse.pl deleted file mode 100644 index 0c5886d..0000000 --- a/scripts/recherche_adresse.pl +++ /dev/null @@ -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 () { - /.*\t(.*u-strasbg.fr)\t.*/; - print $1."\n"; -} diff --git a/scripts/recherche_adresse_admin.php b/scripts/recherche_adresse_admin.php deleted file mode 100644 index 17be229..0000000 --- a/scripts/recherche_adresse_admin.php +++ /dev/null @@ -1,29 +0,0 @@ -mail_admin, "; - // print "$dsondage->mail_admin\n"; -} From db5e9d886238bb4a2eea4f850e959f4ba63766c2 Mon Sep 17 00:00:00 2001 From: Olivier PEREZ Date: Fri, 10 Apr 2015 00:45:31 +0200 Subject: [PATCH 2/3] Add scripts/packaging.php that create a ZIP of the Framadate --- scripts/.htaccess | 1 + scripts/packaging.php | 199 ++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 200 insertions(+) create mode 100644 scripts/packaging.php diff --git a/scripts/.htaccess b/scripts/.htaccess index 3418e55..d30cea2 100644 --- a/scripts/.htaccess +++ b/scripts/.htaccess @@ -1 +1,2 @@ +allow from 127.0.0.1 deny from all \ No newline at end of file diff --git a/scripts/packaging.php b/scripts/packaging.php new file mode 100644 index 0000000..fb29561 --- /dev/null +++ b/scripts/packaging.php @@ -0,0 +1,199 @@ +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 '
';
+
+// 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');
+
+$assets = array('css', 'fonts', 'images', 'js');
+
+foreach ($assets as $asset) {
+    $result->$asset = @rcopy(ROOT . '/' . $asset, BUILD . '/' . $asset);
+    i($result->$asset, $asset);
+}
+
+// Copy sources
+
+d('# Source directories');
+
+$dirs = array('admin', 'app', 'locale', 'tpl');
+
+foreach ($dirs as $dir) {
+    $result->$dir = @rcopy(ROOT . '/' . $dir, BUILD . '/' . $dir);
+    i($result->$dir, $dir);
+}
+
+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'
+);
+
+foreach ($files as $file) {
+    $result->$file = @copy(ROOT . '/' . $file, BUILD . '/' . $file);
+    i($result->$file, $file);
+}
+
+// Zip Dist
+$output = DIST . '/framadate-' . VERSION . '-' . date('Ymd') . '.zip';
+zip(BUILD, $output);
+rrmdir(BUILD);
+
+d('--------');
+d('Distribution file: ' . realpath($output));
+
+$generatedIn = round((microtime(true) - $_SERVER['REQUEST_TIME_FLOAT']), 4);
+d('========');
+d('Generated in: ' . $generatedIn . ' secondes');
+echo '
'; From 362f08cd4ce1839bb1d99cf4b322315c0c44c370 Mon Sep 17 00:00:00 2001 From: Olivier Perez Date: Fri, 10 Apr 2015 14:00:28 +0200 Subject: [PATCH 3/3] Refactor the packaging script --- scripts/packaging.php | 45 +++++++++++++++++++++++-------------------- 1 file changed, 24 insertions(+), 21 deletions(-) diff --git a/scripts/packaging.php b/scripts/packaging.php index fb29561..f851c31 100644 --- a/scripts/packaging.php +++ b/scripts/packaging.php @@ -43,7 +43,7 @@ function rcopy($src, $dst) { } } closedir($dir); - return $copied; + return !!$copied; } function rrmdir($dir) { @@ -58,6 +58,22 @@ 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)) { @@ -139,27 +155,14 @@ i($result->autoload, 'autoload'); // Copy assets d('# Assets'); - -$assets = array('css', 'fonts', 'images', 'js'); - -foreach ($assets as $asset) { - $result->$asset = @rcopy(ROOT . '/' . $asset, BUILD . '/' . $asset); - i($result->$asset, $asset); -} +copyFiles(array('css', 'fonts', 'images', 'js'), $result); // Copy sources d('# Source directories'); - -$dirs = array('admin', 'app', 'locale', 'tpl'); - -foreach ($dirs as $dir) { - $result->$dir = @rcopy(ROOT . '/' . $dir, BUILD . '/' . $dir); - i($result->$dir, $dir); -} +copyFiles(array('admin', 'app', 'locale', 'tpl'), $result); d('# Source files'); - $files = array( 'adminstuds.php', 'bandeaux.php', @@ -179,17 +182,17 @@ $files = array( 'robots.txt', 'studs.php' ); - -foreach ($files as $file) { - $result->$file = @copy(ROOT . '/' . $file, BUILD . '/' . $file); - i($result->$file, $file); -} +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));