Overview
Comment: | Utilisation de DATA_ROOT plutôt que ROOT pour stocker toutes les données de l'appli |
---|---|
Downloads: | Tarball | ZIP archive | SQL archive |
Timelines: | family | ancestors | descendants | both | trunk |
Files: | files | file ages | folders |
SHA1: |
1cd81eacbdf439a8bf4888cc020f81c2 |
User & Date: | bohwaz on 2013-02-11 17:38:57 |
Other Links: | manifest | tags |
Context
2013-02-11
| ||
18:26 | Les squelettes de base doivent être sourcés à partir de ROOT, pas DATA_ROOT check-in: 723dab9518 user: bohwaz tags: trunk | |
17:38 | Utilisation de DATA_ROOT plutôt que ROOT pour stocker toutes les données de l'appli check-in: 1cd81eacbd user: bohwaz tags: trunk | |
17:22 | Sauvegarde et restauration par fichier local OK check-in: 435b8438fc user: bohwaz tags: trunk | |
Changes
Modified include/class.sauvegarde.php from [1b29bf08f0] to [1e52e2ca98].
︙ | ︙ | |||
12 13 14 15 16 17 18 | * @return array Liste des fichiers */ public function getList($auto = false) { $ext = $auto ? '\d+' . preg_quote('.auto.sqlite') : 'sqlite'; $out = array(); | | | | | 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 | * @return array Liste des fichiers */ public function getList($auto = false) { $ext = $auto ? '\d+' . preg_quote('.auto.sqlite') : 'sqlite'; $out = array(); $dir = dir(GARRADIN_DATA_ROOT); while ($file = $dir->read()) { if ($file[0] != '.' && is_file(GARRADIN_DATA_ROOT . '/' . $file) && preg_match('![\w\d._-]+\.' . $ext . '$!i', $file) && $file != basename(GARRADIN_DB_FILE)) { $out[$file] = filemtime(GARRADIN_DATA_ROOT . '/' . $file); } } $dir->close(); ksort($out); |
︙ | ︙ | |||
68 69 70 71 72 73 74 | foreach ($list as $f=>$d) { $new = preg_replace_callback('/\.(\d+)\.auto\.sqlite$!', function ($m) { return (int) $m[1] + 1; }, $f); | | | 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 | foreach ($list as $f=>$d) { $new = preg_replace_callback('/\.(\d+)\.auto\.sqlite$!', function ($m) { return (int) $m[1] + 1; }, $f); rename(GARRADIN_DATA_ROOT . '/' . $f, GARRADIN_DATA_ROOT . '/' . $new); } return true; } /** * Crée une sauvegarde automatique si besoin est |
︙ | ︙ | |||
128 129 130 131 132 133 134 | { if (preg_match('!\.\.+!', $file) || !preg_match('!^[\w\d._-]+\.sqlite$!i', $file) || $file == basename(GARRADIN_DB_FILE)) { throw new UserException('Nom de fichier non valide.'); } | | | 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 | { if (preg_match('!\.\.+!', $file) || !preg_match('!^[\w\d._-]+\.sqlite$!i', $file) || $file == basename(GARRADIN_DB_FILE)) { throw new UserException('Nom de fichier non valide.'); } return unlink(GARRADIN_DATA_ROOT . '/' . $file); } /** * Renvoie sur la sortie courante le contenu du fichier de base de données courant * @return boolean true */ public function dump() |
︙ | ︙ | |||
162 163 164 165 166 167 168 | public function restoreFromLocal($file) { if (preg_match('!\.\.+!', $file) || !preg_match('!^[\w\d._-]+$!i', $file)) { throw new UserException('Nom de fichier non valide.'); } | | | | 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 | public function restoreFromLocal($file) { if (preg_match('!\.\.+!', $file) || !preg_match('!^[\w\d._-]+$!i', $file)) { throw new UserException('Nom de fichier non valide.'); } if (!file_exists(GARRADIN_DATA_ROOT . '/' . $file)) { throw new UserException('Le fichier fourni n\'existe pas.'); } return $this->restoreDB(GARRADIN_DATA_ROOT . '/' . $file); } /** * Restaure une copie distante (fichier envoyé) * @param array $file Tableau provenant de $_FILES * @return boolean true */ |
︙ | ︙ |
Modified include/class.squelette.php from [a85f914a56] to [70aece96a9].
︙ | ︙ | |||
496 497 498 499 500 501 502 | return $out; } public function fetch($template, $no_display = false) { $this->currentTemplate = $template; | | | | | 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 | return $out; } public function fetch($template, $no_display = false) { $this->currentTemplate = $template; $path = file_exists(GARRADIN_DATA_ROOT . '/squelettes/' . $template) ? GARRADIN_DATA_ROOT . '/squelettes/' . $template : GARRADIN_DATA_ROOT . '/squelettes-dist/' . $template; $tpl_id = basename(dirname($path)) . '/' . $template; if (!self::compile_check($tpl_id, $path)) { if (!file_exists($path)) { |
︙ | ︙ | |||
570 571 572 573 574 575 576 | throw new UserException('Cette page n\'existe pas.'); } else { $_GET['uri'] = $_REQUEST['uri'] = substr($uri, 1); if (preg_match('!^[\w\d_-]+$!i', $_GET['uri']) | | | | 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 | throw new UserException('Cette page n\'existe pas.'); } else { $_GET['uri'] = $_REQUEST['uri'] = substr($uri, 1); if (preg_match('!^[\w\d_-]+$!i', $_GET['uri']) && file_exists(GARRADIN_DATA_ROOT . '/squelettes/' . strtolower($_GET['uri']) . '.html')) { $skel = strtolower($_GET['uri']) . '.html'; } else { $skel = 'article.html'; } } $this->display($skel); } static private function compile_get_path($path) { $hash = sha1($path); return GARRADIN_DATA_ROOT . '/cache/compiled/s_' . $hash . '.php'; } static private function compile_check($tpl, $check) { if (!file_exists(self::compile_get_path($tpl))) return false; |
︙ | ︙ | |||
658 659 660 661 662 663 664 | } static public function getSource($template) { if (!preg_match('!^[\w\d_-]+(?:\.[\w\d_-]+)*$!', $template)) return false; | | | | | | | | | | 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 | } static public function getSource($template) { if (!preg_match('!^[\w\d_-]+(?:\.[\w\d_-]+)*$!', $template)) return false; $path = file_exists(GARRADIN_DATA_ROOT . '/squelettes/' . $template) ? GARRADIN_DATA_ROOT . '/squelettes/' . $template : GARRADIN_DATA_ROOT . '/squelettes-dist/' . $template; if (!file_exists($path)) return false; return file_get_contents($path); } static public function editSource($template, $content) { if (!preg_match('!^[\w\d_-]+(?:\.[\w\d_-]+)*$!', $template)) return false; $path = GARRADIN_DATA_ROOT . '/squelettes/' . $template; return file_put_contents($path, $content); } static public function resetSource($template) { if (!preg_match('!^[\w\d_-]+(?:\.[\w\d_-]+)*$!', $template)) return false; if (file_exists(GARRADIN_DATA_ROOT . '/squelettes/' . $template)) { unlink(GARRADIN_DATA_ROOT . '/squelettes/' . $template); } return true; } static public function listSources() { $sources = array(); $dir = dir(GARRADIN_DATA_ROOT . '/squelettes-dist'); while ($file = $dir->read()) { if ($file[0] != '.') $sources[] = $file; } $dir->close(); $dir = dir(GARRADIN_DATA_ROOT . '/squelettes'); while ($file = $dir->read()) { if ($file[0] != '.') $sources[] = $file; } |
︙ | ︙ |
Modified include/init.php from [861ecaf607] to [f061ffc7f9].
︙ | ︙ | |||
50 51 52 53 54 55 56 57 58 59 | require __DIR__ . '/../config.local.php'; } if (!defined('GARRADIN_ROOT')) { define('GARRADIN_ROOT', dirname(__DIR__)); } if (!defined('GARRADIN_DB_FILE')) { | > > > > > | | 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 | require __DIR__ . '/../config.local.php'; } if (!defined('GARRADIN_ROOT')) { define('GARRADIN_ROOT', dirname(__DIR__)); } if (!defined('GARRADIN_DATA_ROOT')) { define('GARRADIN_DATA_ROOT', GARRADIN_ROOT); } if (!defined('GARRADIN_DB_FILE')) { define('GARRADIN_DB_FILE', GARRADIN_DATA_ROOT . '/association.sqlite'); } if (!defined('GARRADIN_DB_SCHEMA')) { define('GARRADIN_DB_SCHEMA', GARRADIN_ROOT . '/include/data/schema.sql'); } |
︙ | ︙ |
Modified include/lib.template.php from [8e38845515] to [8b6b48ef7d].
︙ | ︙ | |||
19 20 21 22 23 24 25 | public function __construct() { parent::__construct(); $this->cache = false; | | | 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 | public function __construct() { parent::__construct(); $this->cache = false; $this->compile_dir = GARRADIN_DATA_ROOT . '/cache/compiled'; $this->template_dir = GARRADIN_ROOT . '/templates'; $this->compile_check = true; $this->reserved_template_varname = 'tpl'; $this->assign('www_url', WWW_URL); |
︙ | ︙ |