Overview
Comment: | Modernisation/corrections du code |
---|---|
Downloads: | Tarball | ZIP archive | SQL archive |
Timelines: | family | ancestors | descendants | both | dev |
Files: | files | file ages | folders |
SHA1: |
abedb2727c3ace474fb28a45b6201a4b |
User & Date: | bohwaz on 2017-05-04 07:38:14 |
Other Links: | branch diff | manifest | tags |
Context
2017-05-05
| ||
07:35 | Amélioration de la vérification de hash pour l'import de DB check-in: 42d8fe5ab5 user: bohwaz tags: dev | |
2017-05-04
| ||
07:38 | Modernisation/corrections du code check-in: abedb2727c user: bohwaz tags: dev | |
07:37 | Vérification de signature à l'import de DB check-in: 4066ce8971 user: bohwaz tags: dev | |
Changes
Modified src/include/lib/Garradin/DB.php from [e113f77c7c] to [8264aea346].
︙ | ︙ | |||
581 582 583 584 585 586 587 | } /** * @deprecated */ public function simpleStatement($query, Array $args = []) { | | | 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 | } /** * @deprecated */ public function simpleStatement($query, Array $args = []) { return $this->query($query, $args); } /** * @deprecated */ public function simpleStatementFetch($query, $mode = null) { |
︙ | ︙ |
Modified src/include/lib/Garradin/Membres.php from [d9c5990d64] to [ad31ed57c8].
︙ | ︙ | |||
52 53 54 55 56 57 58 | public function _checkFields(&$data, $check_editable = true, $check_password = true) { $champs = Config::getInstance()->get('champs_membres'); foreach ($champs->getAll() as $key=>$config) { | | | | | | | | | | | | | | | | | | | | | | | 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 | public function _checkFields(&$data, $check_editable = true, $check_password = true) { $champs = Config::getInstance()->get('champs_membres'); foreach ($champs->getAll() as $key=>$config) { if (!$check_editable && (!empty($config->private) || empty($config->editable))) { unset($data[$key]); continue; } if (!isset($data[$key]) || (!is_array($data[$key]) && trim($data[$key]) === '') || (is_array($data[$key]) && empty($data[$key]))) { if (!empty($config->mandatory) && ($check_password || $key != 'passe')) { throw new UserException('Le champ "' . $config->title . '" doit obligatoirement être renseigné.'); } elseif (!empty($config->mandatory)) { continue; } } if (isset($data[$key])) { if ($config->type == 'email' && trim($data[$key]) !== '' && !filter_var($data[$key], FILTER_VALIDATE_EMAIL)) { throw new UserException('Adresse e-mail invalide dans le champ "' . $config->title . '".'); } elseif ($config->type == 'url' && trim($data[$key]) !== '' && !filter_var($data[$key], FILTER_VALIDATE_URL)) { throw new UserException('Adresse URL invalide dans le champ "' . $config->title . '".'); } elseif ($config->type == 'date' && trim($data[$key]) !== '' && !Utils::checkDate($data[$key])) { throw new UserException('Date invalide "' . $config->title . '", format attendu : AAAA-MM-JJ.'); } elseif ($config->type == 'datetime' && trim($data[$key]) !== '') { if (!Utils::checkDateTime($data[$key]) || !($dt = new DateTime($data[$key]))) { throw new UserException('Date invalide "' . $config->title . '", format attendu : AAAA-MM-JJ HH:mm.'); } $data[$key] = $dt->format('Y-m-d H:i'); } elseif ($config->type == 'tel') { $data[$key] = Utils::normalizePhoneNumber($data[$key]); } elseif ($config->type == 'country') { $data[$key] = strtoupper(substr($data[$key], 0, 2)); } elseif ($config->type == 'checkbox') { $data[$key] = empty($data[$key]) ? 0 : 1; } elseif ($config->type == 'number' && trim($data[$key]) !== '') { if (empty($data[$key])) { $data[$key] = 0; } if (!is_numeric($data[$key])) throw new UserException('Le champ "' . $config->title . '" doit contenir un chiffre.'); } elseif ($config->type == 'select' && !in_array($data[$key], $config->options)) { throw new UserException('Le champ "' . $config->title . '" ne correspond pas à un des choix proposés.'); } elseif ($config->type == 'multiple') { if (empty($data[$key]) || !is_array($data[$key])) { $data[$key] = 0; continue; } $binary = 0; foreach ($data[$key] as $k => $v) { if (array_key_exists($k, $config->options) && !empty($v)) { $binary |= 0x01 << $k; } } $data[$key] = $binary; } |
︙ | ︙ |
Modified src/include/lib/Garradin/Membres/Import.php from [9377162a4a] to [1629f5904f].
︙ | ︙ | |||
164 165 166 167 168 169 170 | $db = DB::getInstance(); $db->begin(); $membres = new Membres; // On récupère les champs qu'on peut importer $champs = Config::getInstance()->get('champs_membres')->getAll(); | | | 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 | $db = DB::getInstance(); $db->begin(); $membres = new Membres; // On récupère les champs qu'on peut importer $champs = Config::getInstance()->get('champs_membres')->getAll(); $champs = array_keys((array)$champs); $champs[] = 'date_inscription'; //$champs[] = 'date_connexion'; $champs[] = 'id'; //$champs[] = 'id_categorie'; $line = 0; $delim = Utils::find_csv_delim($fp); |
︙ | ︙ |
Modified src/www/admin/config/donnees.php from [f33ac12b59] to [695392fbd6].
︙ | ︙ | |||
93 94 95 96 97 98 99 | if (!Utils::CSRF_check('backup_restore')) { $error = 'Une erreur est survenue, merci de renvoyer le formulaire.'; } else { try { | | | 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 | if (!Utils::CSRF_check('backup_restore')) { $error = 'Une erreur est survenue, merci de renvoyer le formulaire.'; } else { try { $s->restoreFromUpload($_FILES['file'], $user->id); Utils::redirect('/admin/config/donnees.php?ok=restore'); } catch (UserException $e) { $error = $e->getMessage(); } } } |
︙ | ︙ |
Modified src/www/admin/membres/import.php from [213e3d1431] to [af2f9a0078].
︙ | ︙ | |||
13 14 15 16 17 18 19 | header('Content-Disposition: attachment; filename="Export membres - ' . $config->get('nom_asso') . ' - ' . date('Y-m-d') . '.csv"'); $import->toCSV(); exit; } $error = false; $champs = $config->get('champs_membres')->getAll(); | | | 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 | header('Content-Disposition: attachment; filename="Export membres - ' . $config->get('nom_asso') . ' - ' . date('Y-m-d') . '.csv"'); $import->toCSV(); exit; } $error = false; $champs = $config->get('champs_membres')->getAll(); $champs->date_inscription = (object) ['title' => 'Date inscription', 'type' => 'date']; if (Utils::post('import')) { // FIXME if (false && !Utils::CSRF_check('membres_import')) { $error = 'Une erreur est survenue, merci de renvoyer le formulaire.'; |
︙ | ︙ |