@@ -15,11 +15,11 @@ discard block |
||
| 15 | 15 | * Test utilisateur |
| 16 | 16 | */ |
| 17 | 17 | if (isset($_GET['test_ecran_securite'])) { |
| 18 | - $ecran_securite_raison = 'test ' . _ECRAN_SECURITE; |
|
| 18 | + $ecran_securite_raison = 'test ' . _ECRAN_SECURITE; |
|
| 19 | 19 | } |
| 20 | 20 | |
| 21 | 21 | if (file_exists($f = __DIR__ . DIRECTORY_SEPARATOR . 'ecran_securite_options.php')) { |
| 22 | - include ($f); |
|
| 22 | + include ($f); |
|
| 23 | 23 | } |
| 24 | 24 | |
| 25 | 25 | /* |
@@ -29,222 +29,222 @@ discard block |
||
| 29 | 29 | * le load depasse ECRAN_SECURITE_LOAD) |
| 30 | 30 | */ |
| 31 | 31 | if (!defined('_IS_BOT') and isset($_GET['var_isbot'])) { |
| 32 | - define('_IS_BOT', $_GET['var_isbot'] ? true : false); |
|
| 32 | + define('_IS_BOT', $_GET['var_isbot'] ? true : false); |
|
| 33 | 33 | } |
| 34 | 34 | |
| 35 | 35 | /* |
| 36 | 36 | * Détecteur de robot d'indexation |
| 37 | 37 | */ |
| 38 | 38 | if (!defined('_IS_BOT')) { |
| 39 | - define( |
|
| 40 | - '_IS_BOT', |
|
| 41 | - isset($_SERVER['HTTP_USER_AGENT']) |
|
| 42 | - and preg_match( |
|
| 43 | - ',' |
|
| 44 | - . implode('|', array( |
|
| 45 | - // mots generiques |
|
| 46 | - 'bot', |
|
| 47 | - 'slurp', |
|
| 48 | - 'crawler', |
|
| 49 | - 'crwlr', |
|
| 50 | - 'java', |
|
| 51 | - 'monitoring', |
|
| 52 | - 'spider', |
|
| 53 | - 'webvac', |
|
| 54 | - 'yandex', |
|
| 55 | - 'MSIE 6\.0', // botnet 99,9% du temps |
|
| 56 | - // UA plus cibles |
|
| 57 | - '200please', |
|
| 58 | - '80legs', |
|
| 59 | - 'a6-indexer', |
|
| 60 | - 'aboundex', |
|
| 61 | - 'accoona', |
|
| 62 | - 'acrylicapps', |
|
| 63 | - 'addthis', |
|
| 64 | - 'adressendeutschland', |
|
| 65 | - 'alexa', |
|
| 66 | - 'altavista', |
|
| 67 | - 'analyticsseo', |
|
| 68 | - 'antennapod', |
|
| 69 | - 'arachnys', |
|
| 70 | - 'archive', |
|
| 71 | - 'argclrint', |
|
| 72 | - 'aspseek', |
|
| 73 | - 'baidu', |
|
| 74 | - 'begunadvertising', |
|
| 75 | - 'bing', |
|
| 76 | - 'bloglines', |
|
| 77 | - 'buck', |
|
| 78 | - 'browsershots', |
|
| 79 | - 'bubing', |
|
| 80 | - 'butterfly', |
|
| 81 | - 'changedetection', |
|
| 82 | - 'charlotte', |
|
| 83 | - 'chilkat', |
|
| 84 | - 'china', |
|
| 85 | - 'coccoc', |
|
| 86 | - 'crowsnest', |
|
| 87 | - 'dataminr', |
|
| 88 | - 'daumoa', |
|
| 89 | - 'dlvr\.it', |
|
| 90 | - 'dlweb', |
|
| 91 | - 'drupal', |
|
| 92 | - 'ec2linkfinder', |
|
| 93 | - 'eset\.com', |
|
| 94 | - 'estyle', |
|
| 95 | - 'exalead', |
|
| 96 | - 'ezooms', |
|
| 97 | - 'facebookexternalhit', |
|
| 98 | - 'facebookplatform', |
|
| 99 | - 'fairshare', |
|
| 100 | - 'feedfetcher', |
|
| 101 | - 'feedfetcher-google', |
|
| 102 | - 'feedly', |
|
| 103 | - 'fetch', |
|
| 104 | - 'flipboardproxy', |
|
| 105 | - 'genieo', |
|
| 106 | - 'google', |
|
| 107 | - 'go-http-client', |
|
| 108 | - 'grapeshot', |
|
| 109 | - 'hatena-useragent', |
|
| 110 | - 'head', |
|
| 111 | - 'hosttracker', |
|
| 112 | - 'hubspot', |
|
| 113 | - 'ia_archiver', |
|
| 114 | - 'ichiro', |
|
| 115 | - 'iltrovatore-setaccio', |
|
| 116 | - 'immediatenet', |
|
| 117 | - 'ina', |
|
| 118 | - 'inoreader', |
|
| 119 | - 'infegyatlas', |
|
| 120 | - 'infohelfer', |
|
| 121 | - 'instapaper', |
|
| 122 | - 'jabse', |
|
| 123 | - 'james', |
|
| 124 | - 'jersey', |
|
| 125 | - 'kumkie', |
|
| 126 | - 'linkdex', |
|
| 127 | - 'linkfluence', |
|
| 128 | - 'linkwalker', |
|
| 129 | - 'litefinder', |
|
| 130 | - 'loadimpactpageanalyzer', |
|
| 131 | - 'ltx71', |
|
| 132 | - 'luminate', |
|
| 133 | - 'lycos', |
|
| 134 | - 'lycosa', |
|
| 135 | - 'mediapartners-google', |
|
| 136 | - 'msai', |
|
| 137 | - 'myapp', |
|
| 138 | - 'nativehost', |
|
| 139 | - 'najdi', |
|
| 140 | - 'netcraftsurveyagent', |
|
| 141 | - 'netestate', |
|
| 142 | - 'netseer', |
|
| 143 | - 'netnewswire', |
|
| 144 | - 'newspaper', |
|
| 145 | - 'newsblur', |
|
| 146 | - 'nuhk', |
|
| 147 | - 'nuzzel', |
|
| 148 | - 'okhttp', |
|
| 149 | - 'otmedia', |
|
| 150 | - 'owlin', |
|
| 151 | - 'owncloud', |
|
| 152 | - 'panscient', |
|
| 153 | - 'paper\.li', |
|
| 154 | - 'parsijoo', |
|
| 155 | - 'protopage', |
|
| 156 | - 'plukkie', |
|
| 157 | - 'proximic', |
|
| 158 | - 'pubsub', |
|
| 159 | - 'python', |
|
| 160 | - 'qirina', |
|
| 161 | - 'qoshe', |
|
| 162 | - 'qualidator', |
|
| 163 | - 'qwantify', |
|
| 164 | - 'rambler', |
|
| 165 | - 'readability', |
|
| 166 | - 'ruby', |
|
| 167 | - 'sbsearch', |
|
| 168 | - 'scoop\.it', |
|
| 169 | - 'scooter', |
|
| 170 | - 'scoutjet', |
|
| 171 | - 'scrapy', |
|
| 172 | - 'scrubby', |
|
| 173 | - 'scrubbybloglines', |
|
| 174 | - 'shareaholic', |
|
| 175 | - 'shopwiki', |
|
| 176 | - 'simplepie', |
|
| 177 | - 'sistrix', |
|
| 178 | - 'sitechecker', |
|
| 179 | - 'siteexplorer', |
|
| 180 | - 'snapshot', |
|
| 181 | - 'sogou', |
|
| 182 | - 'special_archiver', |
|
| 183 | - 'speedy', |
|
| 184 | - 'spinn3r', |
|
| 185 | - 'spreadtrum', |
|
| 186 | - 'steeler', |
|
| 187 | - 'subscriber', |
|
| 188 | - 'suma', |
|
| 189 | - 'superdownloads', |
|
| 190 | - 'svenska-webbsido', |
|
| 191 | - 'teoma', |
|
| 192 | - 'the knowledge AI', |
|
| 193 | - 'thumbshots', |
|
| 194 | - 'tineye', |
|
| 195 | - 'traackr', |
|
| 196 | - 'trendiction', |
|
| 197 | - 'trendsmap', |
|
| 198 | - 'tweetedtimes', |
|
| 199 | - 'tweetmeme', |
|
| 200 | - 'universalfeedparser', |
|
| 201 | - 'uaslinkchecker', |
|
| 202 | - 'undrip', |
|
| 203 | - 'unwindfetchor', |
|
| 204 | - 'upday', |
|
| 205 | - 'vedma', |
|
| 206 | - 'vkshare', |
|
| 207 | - 'vm', |
|
| 208 | - 'wch', |
|
| 209 | - 'webalta', |
|
| 210 | - 'webcookies', |
|
| 211 | - 'webparser', |
|
| 212 | - 'webthumbnail', |
|
| 213 | - 'wesee', |
|
| 214 | - 'wise-guys', |
|
| 215 | - 'woko', |
|
| 216 | - 'wordpress', |
|
| 217 | - 'wotbox', |
|
| 218 | - 'y!j-bri', |
|
| 219 | - 'y!j-bro', |
|
| 220 | - 'y!j-brw', |
|
| 221 | - 'y!j-bsc', |
|
| 222 | - 'yahoo', |
|
| 223 | - 'yahoo!', |
|
| 224 | - 'yahooysmcm', |
|
| 225 | - 'ymobactus', |
|
| 226 | - 'yats', |
|
| 227 | - 'yeti', |
|
| 228 | - 'zeerch' |
|
| 229 | - )) . ',i', |
|
| 230 | - (string)$_SERVER['HTTP_USER_AGENT'] |
|
| 231 | - ) |
|
| 232 | - ); |
|
| 39 | + define( |
|
| 40 | + '_IS_BOT', |
|
| 41 | + isset($_SERVER['HTTP_USER_AGENT']) |
|
| 42 | + and preg_match( |
|
| 43 | + ',' |
|
| 44 | + . implode('|', array( |
|
| 45 | + // mots generiques |
|
| 46 | + 'bot', |
|
| 47 | + 'slurp', |
|
| 48 | + 'crawler', |
|
| 49 | + 'crwlr', |
|
| 50 | + 'java', |
|
| 51 | + 'monitoring', |
|
| 52 | + 'spider', |
|
| 53 | + 'webvac', |
|
| 54 | + 'yandex', |
|
| 55 | + 'MSIE 6\.0', // botnet 99,9% du temps |
|
| 56 | + // UA plus cibles |
|
| 57 | + '200please', |
|
| 58 | + '80legs', |
|
| 59 | + 'a6-indexer', |
|
| 60 | + 'aboundex', |
|
| 61 | + 'accoona', |
|
| 62 | + 'acrylicapps', |
|
| 63 | + 'addthis', |
|
| 64 | + 'adressendeutschland', |
|
| 65 | + 'alexa', |
|
| 66 | + 'altavista', |
|
| 67 | + 'analyticsseo', |
|
| 68 | + 'antennapod', |
|
| 69 | + 'arachnys', |
|
| 70 | + 'archive', |
|
| 71 | + 'argclrint', |
|
| 72 | + 'aspseek', |
|
| 73 | + 'baidu', |
|
| 74 | + 'begunadvertising', |
|
| 75 | + 'bing', |
|
| 76 | + 'bloglines', |
|
| 77 | + 'buck', |
|
| 78 | + 'browsershots', |
|
| 79 | + 'bubing', |
|
| 80 | + 'butterfly', |
|
| 81 | + 'changedetection', |
|
| 82 | + 'charlotte', |
|
| 83 | + 'chilkat', |
|
| 84 | + 'china', |
|
| 85 | + 'coccoc', |
|
| 86 | + 'crowsnest', |
|
| 87 | + 'dataminr', |
|
| 88 | + 'daumoa', |
|
| 89 | + 'dlvr\.it', |
|
| 90 | + 'dlweb', |
|
| 91 | + 'drupal', |
|
| 92 | + 'ec2linkfinder', |
|
| 93 | + 'eset\.com', |
|
| 94 | + 'estyle', |
|
| 95 | + 'exalead', |
|
| 96 | + 'ezooms', |
|
| 97 | + 'facebookexternalhit', |
|
| 98 | + 'facebookplatform', |
|
| 99 | + 'fairshare', |
|
| 100 | + 'feedfetcher', |
|
| 101 | + 'feedfetcher-google', |
|
| 102 | + 'feedly', |
|
| 103 | + 'fetch', |
|
| 104 | + 'flipboardproxy', |
|
| 105 | + 'genieo', |
|
| 106 | + 'google', |
|
| 107 | + 'go-http-client', |
|
| 108 | + 'grapeshot', |
|
| 109 | + 'hatena-useragent', |
|
| 110 | + 'head', |
|
| 111 | + 'hosttracker', |
|
| 112 | + 'hubspot', |
|
| 113 | + 'ia_archiver', |
|
| 114 | + 'ichiro', |
|
| 115 | + 'iltrovatore-setaccio', |
|
| 116 | + 'immediatenet', |
|
| 117 | + 'ina', |
|
| 118 | + 'inoreader', |
|
| 119 | + 'infegyatlas', |
|
| 120 | + 'infohelfer', |
|
| 121 | + 'instapaper', |
|
| 122 | + 'jabse', |
|
| 123 | + 'james', |
|
| 124 | + 'jersey', |
|
| 125 | + 'kumkie', |
|
| 126 | + 'linkdex', |
|
| 127 | + 'linkfluence', |
|
| 128 | + 'linkwalker', |
|
| 129 | + 'litefinder', |
|
| 130 | + 'loadimpactpageanalyzer', |
|
| 131 | + 'ltx71', |
|
| 132 | + 'luminate', |
|
| 133 | + 'lycos', |
|
| 134 | + 'lycosa', |
|
| 135 | + 'mediapartners-google', |
|
| 136 | + 'msai', |
|
| 137 | + 'myapp', |
|
| 138 | + 'nativehost', |
|
| 139 | + 'najdi', |
|
| 140 | + 'netcraftsurveyagent', |
|
| 141 | + 'netestate', |
|
| 142 | + 'netseer', |
|
| 143 | + 'netnewswire', |
|
| 144 | + 'newspaper', |
|
| 145 | + 'newsblur', |
|
| 146 | + 'nuhk', |
|
| 147 | + 'nuzzel', |
|
| 148 | + 'okhttp', |
|
| 149 | + 'otmedia', |
|
| 150 | + 'owlin', |
|
| 151 | + 'owncloud', |
|
| 152 | + 'panscient', |
|
| 153 | + 'paper\.li', |
|
| 154 | + 'parsijoo', |
|
| 155 | + 'protopage', |
|
| 156 | + 'plukkie', |
|
| 157 | + 'proximic', |
|
| 158 | + 'pubsub', |
|
| 159 | + 'python', |
|
| 160 | + 'qirina', |
|
| 161 | + 'qoshe', |
|
| 162 | + 'qualidator', |
|
| 163 | + 'qwantify', |
|
| 164 | + 'rambler', |
|
| 165 | + 'readability', |
|
| 166 | + 'ruby', |
|
| 167 | + 'sbsearch', |
|
| 168 | + 'scoop\.it', |
|
| 169 | + 'scooter', |
|
| 170 | + 'scoutjet', |
|
| 171 | + 'scrapy', |
|
| 172 | + 'scrubby', |
|
| 173 | + 'scrubbybloglines', |
|
| 174 | + 'shareaholic', |
|
| 175 | + 'shopwiki', |
|
| 176 | + 'simplepie', |
|
| 177 | + 'sistrix', |
|
| 178 | + 'sitechecker', |
|
| 179 | + 'siteexplorer', |
|
| 180 | + 'snapshot', |
|
| 181 | + 'sogou', |
|
| 182 | + 'special_archiver', |
|
| 183 | + 'speedy', |
|
| 184 | + 'spinn3r', |
|
| 185 | + 'spreadtrum', |
|
| 186 | + 'steeler', |
|
| 187 | + 'subscriber', |
|
| 188 | + 'suma', |
|
| 189 | + 'superdownloads', |
|
| 190 | + 'svenska-webbsido', |
|
| 191 | + 'teoma', |
|
| 192 | + 'the knowledge AI', |
|
| 193 | + 'thumbshots', |
|
| 194 | + 'tineye', |
|
| 195 | + 'traackr', |
|
| 196 | + 'trendiction', |
|
| 197 | + 'trendsmap', |
|
| 198 | + 'tweetedtimes', |
|
| 199 | + 'tweetmeme', |
|
| 200 | + 'universalfeedparser', |
|
| 201 | + 'uaslinkchecker', |
|
| 202 | + 'undrip', |
|
| 203 | + 'unwindfetchor', |
|
| 204 | + 'upday', |
|
| 205 | + 'vedma', |
|
| 206 | + 'vkshare', |
|
| 207 | + 'vm', |
|
| 208 | + 'wch', |
|
| 209 | + 'webalta', |
|
| 210 | + 'webcookies', |
|
| 211 | + 'webparser', |
|
| 212 | + 'webthumbnail', |
|
| 213 | + 'wesee', |
|
| 214 | + 'wise-guys', |
|
| 215 | + 'woko', |
|
| 216 | + 'wordpress', |
|
| 217 | + 'wotbox', |
|
| 218 | + 'y!j-bri', |
|
| 219 | + 'y!j-bro', |
|
| 220 | + 'y!j-brw', |
|
| 221 | + 'y!j-bsc', |
|
| 222 | + 'yahoo', |
|
| 223 | + 'yahoo!', |
|
| 224 | + 'yahooysmcm', |
|
| 225 | + 'ymobactus', |
|
| 226 | + 'yats', |
|
| 227 | + 'yeti', |
|
| 228 | + 'zeerch' |
|
| 229 | + )) . ',i', |
|
| 230 | + (string)$_SERVER['HTTP_USER_AGENT'] |
|
| 231 | + ) |
|
| 232 | + ); |
|
| 233 | 233 | } |
| 234 | 234 | if (!defined('_IS_BOT_FRIEND')) { |
| 235 | - define( |
|
| 236 | - '_IS_BOT_FRIEND', |
|
| 237 | - isset($_SERVER['HTTP_USER_AGENT']) |
|
| 238 | - and preg_match( |
|
| 239 | - ',' . implode('|', array( |
|
| 240 | - 'facebookexternalhit', |
|
| 241 | - 'twitterbot', |
|
| 242 | - 'flipboardproxy', |
|
| 243 | - 'wordpress' |
|
| 244 | - )) . ',i', |
|
| 245 | - (string)$_SERVER['HTTP_USER_AGENT'] |
|
| 246 | - ) |
|
| 247 | - ); |
|
| 235 | + define( |
|
| 236 | + '_IS_BOT_FRIEND', |
|
| 237 | + isset($_SERVER['HTTP_USER_AGENT']) |
|
| 238 | + and preg_match( |
|
| 239 | + ',' . implode('|', array( |
|
| 240 | + 'facebookexternalhit', |
|
| 241 | + 'twitterbot', |
|
| 242 | + 'flipboardproxy', |
|
| 243 | + 'wordpress' |
|
| 244 | + )) . ',i', |
|
| 245 | + (string)$_SERVER['HTTP_USER_AGENT'] |
|
| 246 | + ) |
|
| 247 | + ); |
|
| 248 | 248 | } |
| 249 | 249 | |
| 250 | 250 | /* |
@@ -256,28 +256,28 @@ discard block |
||
| 256 | 256 | */ |
| 257 | 257 | $_exceptions = array('id_table', 'id_base', 'id_parent', 'id_article_pdf'); |
| 258 | 258 | foreach ($_GET as $var => $val) { |
| 259 | - if ( |
|
| 260 | - $_GET[$var] and strncmp($var, "id_", 3) == 0 |
|
| 261 | - and !in_array($var, $_exceptions) |
|
| 262 | - ) { |
|
| 263 | - $_GET[$var] = is_array($_GET[$var]) ? @array_map('intval', $_GET[$var]) : intval($_GET[$var]); |
|
| 264 | - } |
|
| 259 | + if ( |
|
| 260 | + $_GET[$var] and strncmp($var, "id_", 3) == 0 |
|
| 261 | + and !in_array($var, $_exceptions) |
|
| 262 | + ) { |
|
| 263 | + $_GET[$var] = is_array($_GET[$var]) ? @array_map('intval', $_GET[$var]) : intval($_GET[$var]); |
|
| 264 | + } |
|
| 265 | 265 | } |
| 266 | 266 | foreach ($_POST as $var => $val) { |
| 267 | - if ( |
|
| 268 | - $_POST[$var] and strncmp($var, "id_", 3) == 0 |
|
| 269 | - and !in_array($var, $_exceptions) |
|
| 270 | - ) { |
|
| 271 | - $_POST[$var] = is_array($_POST[$var]) ? @array_map('intval', $_POST[$var]) : intval($_POST[$var]); |
|
| 272 | - } |
|
| 267 | + if ( |
|
| 268 | + $_POST[$var] and strncmp($var, "id_", 3) == 0 |
|
| 269 | + and !in_array($var, $_exceptions) |
|
| 270 | + ) { |
|
| 271 | + $_POST[$var] = is_array($_POST[$var]) ? @array_map('intval', $_POST[$var]) : intval($_POST[$var]); |
|
| 272 | + } |
|
| 273 | 273 | } |
| 274 | 274 | foreach ($GLOBALS as $var => $val) { |
| 275 | - if ( |
|
| 276 | - $GLOBALS[$var] and strncmp($var, "id_", 3) == 0 |
|
| 277 | - and !in_array($var, $_exceptions) |
|
| 278 | - ) { |
|
| 279 | - $GLOBALS[$var] = is_array($GLOBALS[$var]) ? @array_map('intval', $GLOBALS[$var]) : intval($GLOBALS[$var]); |
|
| 280 | - } |
|
| 275 | + if ( |
|
| 276 | + $GLOBALS[$var] and strncmp($var, "id_", 3) == 0 |
|
| 277 | + and !in_array($var, $_exceptions) |
|
| 278 | + ) { |
|
| 279 | + $GLOBALS[$var] = is_array($GLOBALS[$var]) ? @array_map('intval', $GLOBALS[$var]) : intval($GLOBALS[$var]); |
|
| 280 | + } |
|
| 281 | 281 | } |
| 282 | 282 | |
| 283 | 283 | /* |
@@ -290,116 +290,116 @@ discard block |
||
| 290 | 290 | * Contrôle de quelques variables (XSS) |
| 291 | 291 | */ |
| 292 | 292 | foreach (array('lang', 'var_recherche', 'aide', 'var_lang_r', 'lang_r', 'var_ajax_ancre', 'nom_fichier') as $var) { |
| 293 | - if (isset($_GET[$var])) { |
|
| 294 | - $_REQUEST[$var] = $GLOBALS[$var] = $_GET[$var] = preg_replace(',[^\w\,/#&;-]+,', ' ', (string)$_GET[$var]); |
|
| 295 | - } |
|
| 296 | - if (isset($_POST[$var])) { |
|
| 297 | - $_REQUEST[$var] = $GLOBALS[$var] = $_POST[$var] = preg_replace(',[^\w\,/#&;-]+,', ' ', (string)$_POST[$var]); |
|
| 298 | - } |
|
| 293 | + if (isset($_GET[$var])) { |
|
| 294 | + $_REQUEST[$var] = $GLOBALS[$var] = $_GET[$var] = preg_replace(',[^\w\,/#&;-]+,', ' ', (string)$_GET[$var]); |
|
| 295 | + } |
|
| 296 | + if (isset($_POST[$var])) { |
|
| 297 | + $_REQUEST[$var] = $GLOBALS[$var] = $_POST[$var] = preg_replace(',[^\w\,/#&;-]+,', ' ', (string)$_POST[$var]); |
|
| 298 | + } |
|
| 299 | 299 | } |
| 300 | 300 | |
| 301 | 301 | /* |
| 302 | 302 | * Filtre l'accès à spip_acces_doc (injection SQL en 1.8.2x) |
| 303 | 303 | */ |
| 304 | 304 | if (isset($_SERVER['REQUEST_URI'])) { |
| 305 | - if (preg_match(',^(.*/)?spip_acces_doc\.,', (string)$_SERVER['REQUEST_URI'])) { |
|
| 306 | - $file = addslashes((string)$_GET['file']); |
|
| 307 | - } |
|
| 305 | + if (preg_match(',^(.*/)?spip_acces_doc\.,', (string)$_SERVER['REQUEST_URI'])) { |
|
| 306 | + $file = addslashes((string)$_GET['file']); |
|
| 307 | + } |
|
| 308 | 308 | } |
| 309 | 309 | |
| 310 | 310 | /* |
| 311 | 311 | * Pas d'inscription abusive |
| 312 | 312 | */ |
| 313 | 313 | if ( |
| 314 | - isset($_REQUEST['mode']) and isset($_REQUEST['page']) |
|
| 315 | - and !in_array($_REQUEST['mode'], array("6forum", "1comite")) |
|
| 316 | - and $_REQUEST['page'] == "identifiants" |
|
| 314 | + isset($_REQUEST['mode']) and isset($_REQUEST['page']) |
|
| 315 | + and !in_array($_REQUEST['mode'], array("6forum", "1comite")) |
|
| 316 | + and $_REQUEST['page'] == "identifiants" |
|
| 317 | 317 | ) { |
| 318 | - $ecran_securite_raison = "identifiants"; |
|
| 318 | + $ecran_securite_raison = "identifiants"; |
|
| 319 | 319 | } |
| 320 | 320 | |
| 321 | 321 | /* |
| 322 | 322 | * Agenda joue à l'injection php |
| 323 | 323 | */ |
| 324 | 324 | if ( |
| 325 | - isset($_REQUEST['partie_cal']) |
|
| 326 | - and $_REQUEST['partie_cal'] !== htmlentities((string)$_REQUEST['partie_cal']) |
|
| 325 | + isset($_REQUEST['partie_cal']) |
|
| 326 | + and $_REQUEST['partie_cal'] !== htmlentities((string)$_REQUEST['partie_cal']) |
|
| 327 | 327 | ) { |
| 328 | - $ecran_securite_raison = "partie_cal"; |
|
| 328 | + $ecran_securite_raison = "partie_cal"; |
|
| 329 | 329 | } |
| 330 | 330 | if ( |
| 331 | - isset($_REQUEST['echelle']) |
|
| 332 | - and $_REQUEST['echelle'] !== htmlentities((string)$_REQUEST['echelle']) |
|
| 331 | + isset($_REQUEST['echelle']) |
|
| 332 | + and $_REQUEST['echelle'] !== htmlentities((string)$_REQUEST['echelle']) |
|
| 333 | 333 | ) { |
| 334 | - $ecran_securite_raison = "echelle"; |
|
| 334 | + $ecran_securite_raison = "echelle"; |
|
| 335 | 335 | } |
| 336 | 336 | |
| 337 | 337 | /* |
| 338 | 338 | * Espace privé |
| 339 | 339 | */ |
| 340 | 340 | if ( |
| 341 | - isset($_REQUEST['exec']) |
|
| 342 | - and !preg_match(',^[\w-]+$,', (string)$_REQUEST['exec']) |
|
| 341 | + isset($_REQUEST['exec']) |
|
| 342 | + and !preg_match(',^[\w-]+$,', (string)$_REQUEST['exec']) |
|
| 343 | 343 | ) { |
| 344 | - $ecran_securite_raison = "exec"; |
|
| 344 | + $ecran_securite_raison = "exec"; |
|
| 345 | 345 | } |
| 346 | 346 | if ( |
| 347 | - isset($_REQUEST['cherche_auteur']) |
|
| 348 | - and preg_match(',[<],', (string)$_REQUEST['cherche_auteur']) |
|
| 347 | + isset($_REQUEST['cherche_auteur']) |
|
| 348 | + and preg_match(',[<],', (string)$_REQUEST['cherche_auteur']) |
|
| 349 | 349 | ) { |
| 350 | - $ecran_securite_raison = "cherche_auteur"; |
|
| 350 | + $ecran_securite_raison = "cherche_auteur"; |
|
| 351 | 351 | } |
| 352 | 352 | if ( |
| 353 | - isset($_REQUEST['exec']) |
|
| 354 | - and $_REQUEST['exec'] == 'auteurs' |
|
| 355 | - and isset($_REQUEST['recherche']) |
|
| 356 | - and preg_match(',[<],', (string)$_REQUEST['recherche']) |
|
| 353 | + isset($_REQUEST['exec']) |
|
| 354 | + and $_REQUEST['exec'] == 'auteurs' |
|
| 355 | + and isset($_REQUEST['recherche']) |
|
| 356 | + and preg_match(',[<],', (string)$_REQUEST['recherche']) |
|
| 357 | 357 | ) { |
| 358 | - $ecran_securite_raison = "recherche"; |
|
| 358 | + $ecran_securite_raison = "recherche"; |
|
| 359 | 359 | } |
| 360 | 360 | if ( |
| 361 | - isset($_REQUEST['exec']) |
|
| 362 | - and $_REQUEST['exec'] == 'info_plugin' |
|
| 363 | - and isset($_REQUEST['plugin']) |
|
| 364 | - and preg_match(',[<],', (string)$_REQUEST['plugin']) |
|
| 361 | + isset($_REQUEST['exec']) |
|
| 362 | + and $_REQUEST['exec'] == 'info_plugin' |
|
| 363 | + and isset($_REQUEST['plugin']) |
|
| 364 | + and preg_match(',[<],', (string)$_REQUEST['plugin']) |
|
| 365 | 365 | ) { |
| 366 | - $ecran_securite_raison = "plugin"; |
|
| 366 | + $ecran_securite_raison = "plugin"; |
|
| 367 | 367 | } |
| 368 | 368 | if ( |
| 369 | - isset($_REQUEST['exec']) |
|
| 370 | - and $_REQUEST['exec'] == 'puce_statut' |
|
| 371 | - and isset($_REQUEST['id']) |
|
| 372 | - and !intval($_REQUEST['id']) |
|
| 369 | + isset($_REQUEST['exec']) |
|
| 370 | + and $_REQUEST['exec'] == 'puce_statut' |
|
| 371 | + and isset($_REQUEST['id']) |
|
| 372 | + and !intval($_REQUEST['id']) |
|
| 373 | 373 | ) { |
| 374 | - $ecran_securite_raison = "puce_statut"; |
|
| 374 | + $ecran_securite_raison = "puce_statut"; |
|
| 375 | 375 | } |
| 376 | 376 | if ( |
| 377 | - isset($_REQUEST['action']) |
|
| 378 | - and $_REQUEST['action'] == 'configurer' |
|
| 377 | + isset($_REQUEST['action']) |
|
| 378 | + and $_REQUEST['action'] == 'configurer' |
|
| 379 | 379 | ) { |
| 380 | - if ( |
|
| 381 | - @file_exists('inc_version.php') |
|
| 382 | - or @file_exists('ecrire/inc_version.php') |
|
| 383 | - ) { |
|
| 384 | - function action_configurer() { |
|
| 385 | - include_spip('inc/autoriser'); |
|
| 386 | - if (!autoriser('configurer', _request('configuration'))) { |
|
| 387 | - include_spip('inc/minipres'); |
|
| 388 | - echo minipres(_T('info_acces_interdit')); |
|
| 389 | - exit; |
|
| 390 | - } |
|
| 391 | - require _DIR_RESTREINT . 'action/configurer.php'; |
|
| 392 | - action_configurer_dist(); |
|
| 393 | - } |
|
| 394 | - } |
|
| 380 | + if ( |
|
| 381 | + @file_exists('inc_version.php') |
|
| 382 | + or @file_exists('ecrire/inc_version.php') |
|
| 383 | + ) { |
|
| 384 | + function action_configurer() { |
|
| 385 | + include_spip('inc/autoriser'); |
|
| 386 | + if (!autoriser('configurer', _request('configuration'))) { |
|
| 387 | + include_spip('inc/minipres'); |
|
| 388 | + echo minipres(_T('info_acces_interdit')); |
|
| 389 | + exit; |
|
| 390 | + } |
|
| 391 | + require _DIR_RESTREINT . 'action/configurer.php'; |
|
| 392 | + action_configurer_dist(); |
|
| 393 | + } |
|
| 394 | + } |
|
| 395 | 395 | } |
| 396 | 396 | if ( |
| 397 | - isset($_REQUEST['action']) |
|
| 398 | - and $_REQUEST['action'] == 'ordonner_liens_documents' |
|
| 399 | - and isset($_REQUEST['ordre']) |
|
| 400 | - and is_string($_REQUEST['ordre']) |
|
| 397 | + isset($_REQUEST['action']) |
|
| 398 | + and $_REQUEST['action'] == 'ordonner_liens_documents' |
|
| 399 | + and isset($_REQUEST['ordre']) |
|
| 400 | + and is_string($_REQUEST['ordre']) |
|
| 401 | 401 | ) { |
| 402 | - $ecran_securite_raison = "ordre a la chaine"; |
|
| 402 | + $ecran_securite_raison = "ordre a la chaine"; |
|
| 403 | 403 | } |
| 404 | 404 | |
| 405 | 405 | |
@@ -407,29 +407,29 @@ discard block |
||
| 407 | 407 | * Bloque les requêtes contenant %00 (manipulation d'include) |
| 408 | 408 | */ |
| 409 | 409 | if (strpos( |
| 410 | - (function_exists('get_magic_quotes_gpc') and @get_magic_quotes_gpc()) |
|
| 411 | - ? stripslashes(serialize($_REQUEST)) |
|
| 412 | - : serialize($_REQUEST), |
|
| 413 | - chr(0) |
|
| 410 | + (function_exists('get_magic_quotes_gpc') and @get_magic_quotes_gpc()) |
|
| 411 | + ? stripslashes(serialize($_REQUEST)) |
|
| 412 | + : serialize($_REQUEST), |
|
| 413 | + chr(0) |
|
| 414 | 414 | ) !== false) { |
| 415 | - $ecran_securite_raison = "%00"; |
|
| 415 | + $ecran_securite_raison = "%00"; |
|
| 416 | 416 | } |
| 417 | 417 | |
| 418 | 418 | /* |
| 419 | 419 | * Bloque les requêtes fond=formulaire_ |
| 420 | 420 | */ |
| 421 | 421 | if ( |
| 422 | - isset($_REQUEST['fond']) |
|
| 423 | - and preg_match(',^formulaire_,i', $_REQUEST['fond']) |
|
| 422 | + isset($_REQUEST['fond']) |
|
| 423 | + and preg_match(',^formulaire_,i', $_REQUEST['fond']) |
|
| 424 | 424 | ) { |
| 425 | - $ecran_securite_raison = "fond=formulaire_"; |
|
| 425 | + $ecran_securite_raison = "fond=formulaire_"; |
|
| 426 | 426 | } |
| 427 | 427 | |
| 428 | 428 | /* |
| 429 | 429 | * Bloque les requêtes du type ?GLOBALS[type_urls]=toto (bug vieux php) |
| 430 | 430 | */ |
| 431 | 431 | if (isset($_REQUEST['GLOBALS'])) { |
| 432 | - $ecran_securite_raison = "GLOBALS[GLOBALS]"; |
|
| 432 | + $ecran_securite_raison = "GLOBALS[GLOBALS]"; |
|
| 433 | 433 | } |
| 434 | 434 | |
| 435 | 435 | /* |
@@ -438,14 +438,14 @@ discard block |
||
| 438 | 438 | * les paginations entremélées |
| 439 | 439 | */ |
| 440 | 440 | if (_IS_BOT) { |
| 441 | - if ( |
|
| 442 | - (isset($_REQUEST['echelle']) and isset($_REQUEST['partie_cal']) and isset($_REQUEST['type'])) |
|
| 443 | - or (strpos((string)$_SERVER['REQUEST_URI'], 'debut_') and preg_match(',[?&]debut_.*&debut_,', (string)$_SERVER['REQUEST_URI'])) |
|
| 444 | - or (isset($_REQUEST['calendrier_annee']) and strpos((string)$_SERVER['REQUEST_URI'], 'debut_')) |
|
| 445 | - or (isset($_REQUEST['calendrier_annee']) and preg_match(',[?&]calendrier_annee=.*&calendrier_annee=,', (string)$_SERVER['REQUEST_URI'])) |
|
| 446 | - ) { |
|
| 447 | - $ecran_securite_raison = "robot agenda/double pagination"; |
|
| 448 | - } |
|
| 441 | + if ( |
|
| 442 | + (isset($_REQUEST['echelle']) and isset($_REQUEST['partie_cal']) and isset($_REQUEST['type'])) |
|
| 443 | + or (strpos((string)$_SERVER['REQUEST_URI'], 'debut_') and preg_match(',[?&]debut_.*&debut_,', (string)$_SERVER['REQUEST_URI'])) |
|
| 444 | + or (isset($_REQUEST['calendrier_annee']) and strpos((string)$_SERVER['REQUEST_URI'], 'debut_')) |
|
| 445 | + or (isset($_REQUEST['calendrier_annee']) and preg_match(',[?&]calendrier_annee=.*&calendrier_annee=,', (string)$_SERVER['REQUEST_URI'])) |
|
| 446 | + ) { |
|
| 447 | + $ecran_securite_raison = "robot agenda/double pagination"; |
|
| 448 | + } |
|
| 449 | 449 | } |
| 450 | 450 | |
| 451 | 451 | /* |
@@ -453,82 +453,82 @@ discard block |
||
| 453 | 453 | * Bloque un XSS sur une page inexistante |
| 454 | 454 | */ |
| 455 | 455 | if (isset($_REQUEST['page'])) { |
| 456 | - if ($_REQUEST['page'] == 'test_cfg') { |
|
| 457 | - $ecran_securite_raison = "test_cfg"; |
|
| 458 | - } |
|
| 459 | - if ($_REQUEST['page'] !== htmlspecialchars((string)$_REQUEST['page'])) { |
|
| 460 | - $ecran_securite_raison = "xsspage"; |
|
| 461 | - } |
|
| 462 | - if ( |
|
| 463 | - $_REQUEST['page'] == '404' |
|
| 464 | - and isset($_REQUEST['erreur']) |
|
| 465 | - ) { |
|
| 466 | - $ecran_securite_raison = "xss404"; |
|
| 467 | - } |
|
| 456 | + if ($_REQUEST['page'] == 'test_cfg') { |
|
| 457 | + $ecran_securite_raison = "test_cfg"; |
|
| 458 | + } |
|
| 459 | + if ($_REQUEST['page'] !== htmlspecialchars((string)$_REQUEST['page'])) { |
|
| 460 | + $ecran_securite_raison = "xsspage"; |
|
| 461 | + } |
|
| 462 | + if ( |
|
| 463 | + $_REQUEST['page'] == '404' |
|
| 464 | + and isset($_REQUEST['erreur']) |
|
| 465 | + ) { |
|
| 466 | + $ecran_securite_raison = "xss404"; |
|
| 467 | + } |
|
| 468 | 468 | } |
| 469 | 469 | |
| 470 | 470 | /* |
| 471 | 471 | * XSS par array |
| 472 | 472 | */ |
| 473 | 473 | foreach (array('var_login') as $var) { |
| 474 | - if (isset($_REQUEST[$var]) and is_array($_REQUEST[$var])) { |
|
| 475 | - $ecran_securite_raison = "xss " . $var; |
|
| 476 | - } |
|
| 474 | + if (isset($_REQUEST[$var]) and is_array($_REQUEST[$var])) { |
|
| 475 | + $ecran_securite_raison = "xss " . $var; |
|
| 476 | + } |
|
| 477 | 477 | } |
| 478 | 478 | |
| 479 | 479 | /* |
| 480 | 480 | * Parade antivirale contre un cheval de troie |
| 481 | 481 | */ |
| 482 | 482 | if (!function_exists('tmp_lkojfghx')) { |
| 483 | - function tmp_lkojfghx() {} |
|
| 484 | - function tmp_lkojfghx2($a = 0, $b = 0, $c = 0, $d = 0) { |
|
| 485 | - // si jamais on est arrivé ici sur une erreur php |
|
| 486 | - // et qu'un autre gestionnaire d'erreur est défini, l'appeller |
|
| 487 | - if ($b && $GLOBALS['tmp_xhgfjokl']) { |
|
| 488 | - call_user_func($GLOBALS['tmp_xhgfjokl'], $a, $b, $c, $d); |
|
| 489 | - } |
|
| 490 | - } |
|
| 483 | + function tmp_lkojfghx() {} |
|
| 484 | + function tmp_lkojfghx2($a = 0, $b = 0, $c = 0, $d = 0) { |
|
| 485 | + // si jamais on est arrivé ici sur une erreur php |
|
| 486 | + // et qu'un autre gestionnaire d'erreur est défini, l'appeller |
|
| 487 | + if ($b && $GLOBALS['tmp_xhgfjokl']) { |
|
| 488 | + call_user_func($GLOBALS['tmp_xhgfjokl'], $a, $b, $c, $d); |
|
| 489 | + } |
|
| 490 | + } |
|
| 491 | 491 | } |
| 492 | 492 | if (isset($_POST['tmp_lkojfghx3'])) { |
| 493 | - $ecran_securite_raison = "gumblar"; |
|
| 493 | + $ecran_securite_raison = "gumblar"; |
|
| 494 | 494 | } |
| 495 | 495 | |
| 496 | 496 | /* |
| 497 | 497 | * Outils XML mal sécurisés < 2.0.9 |
| 498 | 498 | */ |
| 499 | 499 | if (isset($_REQUEST['transformer_xml'])) { |
| 500 | - $ecran_securite_raison = "transformer_xml"; |
|
| 500 | + $ecran_securite_raison = "transformer_xml"; |
|
| 501 | 501 | } |
| 502 | 502 | |
| 503 | 503 | /* |
| 504 | 504 | * Outils XML mal sécurisés again |
| 505 | 505 | */ |
| 506 | 506 | if (isset($_REQUEST['var_url']) and $_REQUEST['var_url'] and isset($_REQUEST['exec']) and $_REQUEST['exec'] == 'valider_xml') { |
| 507 | - $url = trim($_REQUEST['var_url']); |
|
| 508 | - if ( |
|
| 509 | - strncmp($url, '/', 1) == 0 |
|
| 510 | - or (($p = strpos($url, '..')) !== false and strpos($url, '..', $p + 3) !== false) |
|
| 511 | - or (($p = strpos($url, '..')) !== false and strpos($url, 'IMG', $p + 3) !== false) |
|
| 512 | - or (strpos($url, '://') !== false or strpos($url, ':\\') !== false) |
|
| 513 | - ) { |
|
| 514 | - $ecran_securite_raison = 'URL interdite pour var_url'; |
|
| 515 | - } |
|
| 507 | + $url = trim($_REQUEST['var_url']); |
|
| 508 | + if ( |
|
| 509 | + strncmp($url, '/', 1) == 0 |
|
| 510 | + or (($p = strpos($url, '..')) !== false and strpos($url, '..', $p + 3) !== false) |
|
| 511 | + or (($p = strpos($url, '..')) !== false and strpos($url, 'IMG', $p + 3) !== false) |
|
| 512 | + or (strpos($url, '://') !== false or strpos($url, ':\\') !== false) |
|
| 513 | + ) { |
|
| 514 | + $ecran_securite_raison = 'URL interdite pour var_url'; |
|
| 515 | + } |
|
| 516 | 516 | } |
| 517 | 517 | |
| 518 | 518 | /* |
| 519 | 519 | * Sauvegarde mal securisée < 2.0.9 |
| 520 | 520 | */ |
| 521 | 521 | if ( |
| 522 | - isset($_REQUEST['nom_sauvegarde']) |
|
| 523 | - and strstr((string)$_REQUEST['nom_sauvegarde'], '/') |
|
| 522 | + isset($_REQUEST['nom_sauvegarde']) |
|
| 523 | + and strstr((string)$_REQUEST['nom_sauvegarde'], '/') |
|
| 524 | 524 | ) { |
| 525 | - $ecran_securite_raison = 'nom_sauvegarde manipulee'; |
|
| 525 | + $ecran_securite_raison = 'nom_sauvegarde manipulee'; |
|
| 526 | 526 | } |
| 527 | 527 | if ( |
| 528 | - isset($_REQUEST['znom_sauvegarde']) |
|
| 529 | - and strstr((string)$_REQUEST['znom_sauvegarde'], '/') |
|
| 528 | + isset($_REQUEST['znom_sauvegarde']) |
|
| 529 | + and strstr((string)$_REQUEST['znom_sauvegarde'], '/') |
|
| 530 | 530 | ) { |
| 531 | - $ecran_securite_raison = 'znom_sauvegarde manipulee'; |
|
| 531 | + $ecran_securite_raison = 'znom_sauvegarde manipulee'; |
|
| 532 | 532 | } |
| 533 | 533 | |
| 534 | 534 | |
@@ -537,57 +537,57 @@ discard block |
||
| 537 | 537 | * on vérifie 'page' pour ne pas bloquer ... drupal |
| 538 | 538 | */ |
| 539 | 539 | if ( |
| 540 | - isset($_REQUEST['op']) and isset($_REQUEST['page']) |
|
| 541 | - and $_REQUEST['op'] !== preg_replace('/[^\\-\w]/', '', $_REQUEST['op']) |
|
| 540 | + isset($_REQUEST['op']) and isset($_REQUEST['page']) |
|
| 541 | + and $_REQUEST['op'] !== preg_replace('/[^\\-\w]/', '', $_REQUEST['op']) |
|
| 542 | 542 | ) { |
| 543 | - $ecran_securite_raison = 'op'; |
|
| 543 | + $ecran_securite_raison = 'op'; |
|
| 544 | 544 | } |
| 545 | 545 | |
| 546 | 546 | /* |
| 547 | 547 | * Forms & Table ne se méfiait pas assez des uploads de fichiers |
| 548 | 548 | */ |
| 549 | 549 | if (count($_FILES)) { |
| 550 | - foreach ($_FILES as $k => $v) { |
|
| 551 | - if ( |
|
| 552 | - preg_match(',^fichier_\d+$,', $k) |
|
| 553 | - and preg_match(',\.php,i', $v['name']) |
|
| 554 | - ) { |
|
| 555 | - unset($_FILES[$k]); |
|
| 556 | - } |
|
| 557 | - } |
|
| 550 | + foreach ($_FILES as $k => $v) { |
|
| 551 | + if ( |
|
| 552 | + preg_match(',^fichier_\d+$,', $k) |
|
| 553 | + and preg_match(',\.php,i', $v['name']) |
|
| 554 | + ) { |
|
| 555 | + unset($_FILES[$k]); |
|
| 556 | + } |
|
| 557 | + } |
|
| 558 | 558 | } |
| 559 | 559 | /* |
| 560 | 560 | * et Contact trop laxiste avec une variable externe |
| 561 | 561 | * on bloque pas le post pour eviter de perdre des donnees mais on unset la variable et c'est tout |
| 562 | 562 | */ |
| 563 | 563 | if (isset($_REQUEST['pj_enregistrees_nom']) and $_REQUEST['pj_enregistrees_nom']) { |
| 564 | - unset($_REQUEST['pj_enregistrees_nom']); |
|
| 565 | - unset($_GET['pj_enregistrees_nom']); |
|
| 566 | - unset($_POST['pj_enregistrees_nom']); |
|
| 564 | + unset($_REQUEST['pj_enregistrees_nom']); |
|
| 565 | + unset($_GET['pj_enregistrees_nom']); |
|
| 566 | + unset($_POST['pj_enregistrees_nom']); |
|
| 567 | 567 | } |
| 568 | 568 | |
| 569 | 569 | /* |
| 570 | 570 | * reinstall=oui un peu trop permissif |
| 571 | 571 | */ |
| 572 | 572 | if ( |
| 573 | - isset($_REQUEST['reinstall']) |
|
| 574 | - and $_REQUEST['reinstall'] == 'oui' |
|
| 573 | + isset($_REQUEST['reinstall']) |
|
| 574 | + and $_REQUEST['reinstall'] == 'oui' |
|
| 575 | 575 | ) { |
| 576 | - $ecran_securite_raison = 'reinstall=oui'; |
|
| 576 | + $ecran_securite_raison = 'reinstall=oui'; |
|
| 577 | 577 | } |
| 578 | 578 | |
| 579 | 579 | /* |
| 580 | 580 | * Pas d'action pendant l'install |
| 581 | 581 | */ |
| 582 | 582 | if (isset($_REQUEST['exec']) and $_REQUEST['exec'] === 'install' and isset($_REQUEST['action'])) { |
| 583 | - $ecran_securite_raison = 'install&action impossibles'; |
|
| 583 | + $ecran_securite_raison = 'install&action impossibles'; |
|
| 584 | 584 | } |
| 585 | 585 | |
| 586 | 586 | /* |
| 587 | 587 | * Échappement xss referer |
| 588 | 588 | */ |
| 589 | 589 | if (isset($_SERVER['HTTP_REFERER'])) { |
| 590 | - $_SERVER['HTTP_REFERER'] = strtr($_SERVER['HTTP_REFERER'], '<>"\'', '[]##'); |
|
| 590 | + $_SERVER['HTTP_REFERER'] = strtr($_SERVER['HTTP_REFERER'], '<>"\'', '[]##'); |
|
| 591 | 591 | } |
| 592 | 592 | |
| 593 | 593 | |
@@ -595,7 +595,7 @@ discard block |
||
| 595 | 595 | * Echappement HTTP_X_FORWARDED_HOST |
| 596 | 596 | */ |
| 597 | 597 | if (isset($_SERVER['HTTP_X_FORWARDED_HOST'])) { |
| 598 | - $_SERVER['HTTP_X_FORWARDED_HOST'] = strtr($_SERVER['HTTP_X_FORWARDED_HOST'], "<>?\"\{\}\$'` \r\n", '____________'); |
|
| 598 | + $_SERVER['HTTP_X_FORWARDED_HOST'] = strtr($_SERVER['HTTP_X_FORWARDED_HOST'], "<>?\"\{\}\$'` \r\n", '____________'); |
|
| 599 | 599 | } |
| 600 | 600 | |
| 601 | 601 | |
@@ -603,9 +603,9 @@ discard block |
||
| 603 | 603 | * Pas d'erreur dans l'erreur |
| 604 | 604 | */ |
| 605 | 605 | if (isset($_REQUEST['var_erreur']) and isset($_REQUEST['page']) and $_REQUEST['page'] === 'login') { |
| 606 | - if (strlen($_REQUEST['var_erreur']) !== strcspn($_REQUEST['var_erreur'], '<>')) { |
|
| 607 | - $ecran_securite_raison = 'var_erreur incorrecte'; |
|
| 608 | - } |
|
| 606 | + if (strlen($_REQUEST['var_erreur']) !== strcspn($_REQUEST['var_erreur'], '<>')) { |
|
| 607 | + $ecran_securite_raison = 'var_erreur incorrecte'; |
|
| 608 | + } |
|
| 609 | 609 | } |
| 610 | 610 | |
| 611 | 611 | |
@@ -613,30 +613,30 @@ discard block |
||
| 613 | 613 | * Réinjection des clés en html dans l'admin r19561 |
| 614 | 614 | */ |
| 615 | 615 | if ( |
| 616 | - (isset($_SERVER['REQUEST_URI']) and strpos($_SERVER['REQUEST_URI'], "ecrire/") !== false) |
|
| 617 | - or isset($_REQUEST['var_memotri']) |
|
| 616 | + (isset($_SERVER['REQUEST_URI']) and strpos($_SERVER['REQUEST_URI'], "ecrire/") !== false) |
|
| 617 | + or isset($_REQUEST['var_memotri']) |
|
| 618 | 618 | ) { |
| 619 | - $zzzz = implode("", array_keys($_REQUEST)); |
|
| 620 | - if (strlen($zzzz) != strcspn($zzzz, '<>"\'')) { |
|
| 621 | - $ecran_securite_raison = 'Cle incorrecte en $_REQUEST'; |
|
| 622 | - } |
|
| 619 | + $zzzz = implode("", array_keys($_REQUEST)); |
|
| 620 | + if (strlen($zzzz) != strcspn($zzzz, '<>"\'')) { |
|
| 621 | + $ecran_securite_raison = 'Cle incorrecte en $_REQUEST'; |
|
| 622 | + } |
|
| 623 | 623 | } |
| 624 | 624 | |
| 625 | 625 | /* |
| 626 | 626 | * Injection par connect |
| 627 | 627 | */ |
| 628 | 628 | if ( |
| 629 | - isset($_REQUEST['connect']) |
|
| 630 | - // cas qui permettent de sortir d'un commentaire PHP |
|
| 631 | - and ( |
|
| 632 | - strpos($_REQUEST['connect'], "?") !== false |
|
| 633 | - or strpos($_REQUEST['connect'], "<") !== false |
|
| 634 | - or strpos($_REQUEST['connect'], ">") !== false |
|
| 635 | - or strpos($_REQUEST['connect'], "\n") !== false |
|
| 636 | - or strpos($_REQUEST['connect'], "\r") !== false |
|
| 637 | - ) |
|
| 629 | + isset($_REQUEST['connect']) |
|
| 630 | + // cas qui permettent de sortir d'un commentaire PHP |
|
| 631 | + and ( |
|
| 632 | + strpos($_REQUEST['connect'], "?") !== false |
|
| 633 | + or strpos($_REQUEST['connect'], "<") !== false |
|
| 634 | + or strpos($_REQUEST['connect'], ">") !== false |
|
| 635 | + or strpos($_REQUEST['connect'], "\n") !== false |
|
| 636 | + or strpos($_REQUEST['connect'], "\r") !== false |
|
| 637 | + ) |
|
| 638 | 638 | ) { |
| 639 | - $ecran_securite_raison = "malformed connect argument"; |
|
| 639 | + $ecran_securite_raison = "malformed connect argument"; |
|
| 640 | 640 | } |
| 641 | 641 | |
| 642 | 642 | |
@@ -644,73 +644,73 @@ discard block |
||
| 644 | 644 | * _oups donc |
| 645 | 645 | */ |
| 646 | 646 | if ( |
| 647 | - isset($_REQUEST['_oups']) |
|
| 648 | - and base64_decode($_REQUEST['_oups'], true) === false) { |
|
| 649 | - $ecran_securite_raison = "malformed _oups argument"; |
|
| 647 | + isset($_REQUEST['_oups']) |
|
| 648 | + and base64_decode($_REQUEST['_oups'], true) === false) { |
|
| 649 | + $ecran_securite_raison = "malformed _oups argument"; |
|
| 650 | 650 | } |
| 651 | 651 | |
| 652 | 652 | if ( |
| 653 | - isset($_REQUEST['formulaire_action_args']) |
|
| 653 | + isset($_REQUEST['formulaire_action_args']) |
|
| 654 | 654 | ) { |
| 655 | - foreach ($_REQUEST as $k => $v) { |
|
| 656 | - if (is_string($v) |
|
| 657 | - and strpbrk($v, "&\"'<>") !== false |
|
| 658 | - and preg_match(',^[abis]:\d+[:;],', $v) |
|
| 659 | - and __ecran_test_if_serialized($v) |
|
| 660 | - ) { |
|
| 661 | - $_REQUEST[$k] = htmlspecialchars($v, ENT_QUOTES); |
|
| 662 | - if (isset($_POST[$k])) $_POST[$k] = $_REQUEST[$k]; |
|
| 663 | - if (isset($_GET[$k])) $_GET[$k] = $_REQUEST[$k]; |
|
| 664 | - } |
|
| 665 | - } |
|
| 655 | + foreach ($_REQUEST as $k => $v) { |
|
| 656 | + if (is_string($v) |
|
| 657 | + and strpbrk($v, "&\"'<>") !== false |
|
| 658 | + and preg_match(',^[abis]:\d+[:;],', $v) |
|
| 659 | + and __ecran_test_if_serialized($v) |
|
| 660 | + ) { |
|
| 661 | + $_REQUEST[$k] = htmlspecialchars($v, ENT_QUOTES); |
|
| 662 | + if (isset($_POST[$k])) $_POST[$k] = $_REQUEST[$k]; |
|
| 663 | + if (isset($_GET[$k])) $_GET[$k] = $_REQUEST[$k]; |
|
| 664 | + } |
|
| 665 | + } |
|
| 666 | 666 | } |
| 667 | 667 | /** |
| 668 | 668 | * Version simplifiée de https://developer.wordpress.org/reference/functions/is_serialized/ |
| 669 | 669 | */ |
| 670 | 670 | function __ecran_test_if_serialized($data) { |
| 671 | - $data = trim($data); |
|
| 672 | - if ('N;' === $data) {return true;} |
|
| 673 | - if (strlen($data) < 4) {return false;} |
|
| 674 | - if (':' !== $data[1]) {return false;} |
|
| 675 | - $semicolon = strpos($data, ';'); |
|
| 676 | - $brace = strpos($data, '}'); |
|
| 677 | - // Either ; or } must exist. |
|
| 678 | - if (false === $semicolon && false === $brace) {return false;} |
|
| 679 | - // But neither must be in the first X characters. |
|
| 680 | - if (false !== $semicolon && $semicolon < 3) {return false;} |
|
| 681 | - if (false !== $brace && $brace < 4) {return false;} |
|
| 682 | - $token = $data[0]; |
|
| 683 | - if (in_array($token, array('s', 'S'))) { |
|
| 684 | - if (false === strpos($data, '"')) {return false;} |
|
| 685 | - } elseif (in_array($token, array('a', 'O', 'C', 'o', 'E'))) { |
|
| 686 | - return (bool)preg_match("/^{$token}:[0-9]+:/s", $data); |
|
| 687 | - } elseif (in_array($token, array('b', 'i', 'd'))) { |
|
| 688 | - return (bool)preg_match("/^{$token}:[0-9.E+-]+;/", $data); |
|
| 689 | - } |
|
| 690 | - return false; |
|
| 671 | + $data = trim($data); |
|
| 672 | + if ('N;' === $data) {return true;} |
|
| 673 | + if (strlen($data) < 4) {return false;} |
|
| 674 | + if (':' !== $data[1]) {return false;} |
|
| 675 | + $semicolon = strpos($data, ';'); |
|
| 676 | + $brace = strpos($data, '}'); |
|
| 677 | + // Either ; or } must exist. |
|
| 678 | + if (false === $semicolon && false === $brace) {return false;} |
|
| 679 | + // But neither must be in the first X characters. |
|
| 680 | + if (false !== $semicolon && $semicolon < 3) {return false;} |
|
| 681 | + if (false !== $brace && $brace < 4) {return false;} |
|
| 682 | + $token = $data[0]; |
|
| 683 | + if (in_array($token, array('s', 'S'))) { |
|
| 684 | + if (false === strpos($data, '"')) {return false;} |
|
| 685 | + } elseif (in_array($token, array('a', 'O', 'C', 'o', 'E'))) { |
|
| 686 | + return (bool)preg_match("/^{$token}:[0-9]+:/s", $data); |
|
| 687 | + } elseif (in_array($token, array('b', 'i', 'd'))) { |
|
| 688 | + return (bool)preg_match("/^{$token}:[0-9.E+-]+;/", $data); |
|
| 689 | + } |
|
| 690 | + return false; |
|
| 691 | 691 | } |
| 692 | 692 | |
| 693 | 693 | /* |
| 694 | 694 | * S'il y a une raison de mourir, mourons |
| 695 | 695 | */ |
| 696 | 696 | if (isset($ecran_securite_raison)) { |
| 697 | - header("HTTP/1.0 403 Forbidden"); |
|
| 698 | - header("Expires: Wed, 11 Jan 1984 05:00:00 GMT"); |
|
| 699 | - header("Cache-Control: no-cache, must-revalidate"); |
|
| 700 | - header("Pragma: no-cache"); |
|
| 701 | - header("Content-Type: text/html"); |
|
| 702 | - header("Connection: close"); |
|
| 703 | - die("<html><title>Error 403: Forbidden</title><body><h1>Error 403</h1><p>You are not authorized to view this page ($ecran_securite_raison)</p></body></html>"); |
|
| 697 | + header("HTTP/1.0 403 Forbidden"); |
|
| 698 | + header("Expires: Wed, 11 Jan 1984 05:00:00 GMT"); |
|
| 699 | + header("Cache-Control: no-cache, must-revalidate"); |
|
| 700 | + header("Pragma: no-cache"); |
|
| 701 | + header("Content-Type: text/html"); |
|
| 702 | + header("Connection: close"); |
|
| 703 | + die("<html><title>Error 403: Forbidden</title><body><h1>Error 403</h1><p>You are not authorized to view this page ($ecran_securite_raison)</p></body></html>"); |
|
| 704 | 704 | } |
| 705 | 705 | |
| 706 | 706 | /* |
| 707 | 707 | * Un filtre filtrer_entites securise |
| 708 | 708 | */ |
| 709 | 709 | if (!function_exists('filtre_filtrer_entites_dist')) { |
| 710 | - function filtre_filtrer_entites_dist($t) { |
|
| 711 | - include_spip('inc/texte'); |
|
| 712 | - return interdire_scripts(filtrer_entites($t)); |
|
| 713 | - } |
|
| 710 | + function filtre_filtrer_entites_dist($t) { |
|
| 711 | + include_spip('inc/texte'); |
|
| 712 | + return interdire_scripts(filtrer_entites($t)); |
|
| 713 | + } |
|
| 714 | 714 | } |
| 715 | 715 | |
| 716 | 716 | |
@@ -724,35 +724,35 @@ discard block |
||
| 724 | 724 | * Bloque les bots quand le load déborde |
| 725 | 725 | */ |
| 726 | 726 | if (!defined('_ECRAN_SECURITE_LOAD')) { |
| 727 | - define('_ECRAN_SECURITE_LOAD', 4); |
|
| 727 | + define('_ECRAN_SECURITE_LOAD', 4); |
|
| 728 | 728 | } |
| 729 | 729 | |
| 730 | 730 | if ( |
| 731 | - defined('_ECRAN_SECURITE_LOAD') |
|
| 732 | - and _ECRAN_SECURITE_LOAD > 0 |
|
| 733 | - and _IS_BOT |
|
| 734 | - and !_IS_BOT_FRIEND |
|
| 735 | - and $_SERVER['REQUEST_METHOD'] === 'GET' |
|
| 736 | - and ( |
|
| 737 | - (function_exists('sys_getloadavg') |
|
| 738 | - and $load = sys_getloadavg() |
|
| 739 | - and is_array($load) |
|
| 740 | - and $load = array_shift($load)) |
|
| 741 | - or |
|
| 742 | - (@is_readable('/proc/loadavg') |
|
| 743 | - and $load = file_get_contents('/proc/loadavg') |
|
| 744 | - and $load = floatval($load)) |
|
| 745 | - ) |
|
| 746 | - and $load > _ECRAN_SECURITE_LOAD // eviter l'evaluation suivante si de toute facon le load est inferieur a la limite |
|
| 747 | - and rand(0, (int) ($load * $load)) > _ECRAN_SECURITE_LOAD * _ECRAN_SECURITE_LOAD |
|
| 731 | + defined('_ECRAN_SECURITE_LOAD') |
|
| 732 | + and _ECRAN_SECURITE_LOAD > 0 |
|
| 733 | + and _IS_BOT |
|
| 734 | + and !_IS_BOT_FRIEND |
|
| 735 | + and $_SERVER['REQUEST_METHOD'] === 'GET' |
|
| 736 | + and ( |
|
| 737 | + (function_exists('sys_getloadavg') |
|
| 738 | + and $load = sys_getloadavg() |
|
| 739 | + and is_array($load) |
|
| 740 | + and $load = array_shift($load)) |
|
| 741 | + or |
|
| 742 | + (@is_readable('/proc/loadavg') |
|
| 743 | + and $load = file_get_contents('/proc/loadavg') |
|
| 744 | + and $load = floatval($load)) |
|
| 745 | + ) |
|
| 746 | + and $load > _ECRAN_SECURITE_LOAD // eviter l'evaluation suivante si de toute facon le load est inferieur a la limite |
|
| 747 | + and rand(0, (int) ($load * $load)) > _ECRAN_SECURITE_LOAD * _ECRAN_SECURITE_LOAD |
|
| 748 | 748 | ) { |
| 749 | - //https://webmasters.stackexchange.com/questions/65674/should-i-return-a-429-or-503-status-code-to-a-bot |
|
| 750 | - header("HTTP/1.0 429 Too Many Requests"); |
|
| 751 | - header("Retry-After: 300"); |
|
| 752 | - header("Expires: Wed, 11 Jan 1984 05:00:00 GMT"); |
|
| 753 | - header("Cache-Control: no-cache, must-revalidate"); |
|
| 754 | - header("Pragma: no-cache"); |
|
| 755 | - header("Content-Type: text/html"); |
|
| 756 | - header("Connection: close"); |
|
| 757 | - die("<html><title>Status 429: Too Many Requests</title><body><h1>Status 429</h1><p>Too Many Requests (try again soon)</p></body></html>"); |
|
| 749 | + //https://webmasters.stackexchange.com/questions/65674/should-i-return-a-429-or-503-status-code-to-a-bot |
|
| 750 | + header("HTTP/1.0 429 Too Many Requests"); |
|
| 751 | + header("Retry-After: 300"); |
|
| 752 | + header("Expires: Wed, 11 Jan 1984 05:00:00 GMT"); |
|
| 753 | + header("Cache-Control: no-cache, must-revalidate"); |
|
| 754 | + header("Pragma: no-cache"); |
|
| 755 | + header("Content-Type: text/html"); |
|
| 756 | + header("Connection: close"); |
|
| 757 | + die("<html><title>Status 429: Too Many Requests</title><body><h1>Status 429</h1><p>Too Many Requests (try again soon)</p></body></html>"); |
|
| 758 | 758 | } |
@@ -16,7 +16,7 @@ discard block |
||
| 16 | 16 | **/ |
| 17 | 17 | |
| 18 | 18 | if (defined('_ECRIRE_INC_VERSION')) { |
| 19 | - return; |
|
| 19 | + return; |
|
| 20 | 20 | } |
| 21 | 21 | |
| 22 | 22 | /** |
@@ -36,15 +36,15 @@ discard block |
||
| 36 | 36 | define('_PHP_MAX', '8.2.99'); |
| 37 | 37 | |
| 38 | 38 | if (!defined('_DIR_RESTREINT_ABS')) { |
| 39 | - /** le nom du repertoire ecrire/ */ |
|
| 40 | - define('_DIR_RESTREINT_ABS', 'ecrire/'); |
|
| 39 | + /** le nom du repertoire ecrire/ */ |
|
| 40 | + define('_DIR_RESTREINT_ABS', 'ecrire/'); |
|
| 41 | 41 | } |
| 42 | 42 | |
| 43 | 43 | /** Chemin relatif pour aller dans ecrire |
| 44 | 44 | * vide si on est dans ecrire, 'ecrire/' sinon */ |
| 45 | 45 | define( |
| 46 | - '_DIR_RESTREINT', |
|
| 47 | - (!is_dir(_DIR_RESTREINT_ABS) ? '' : _DIR_RESTREINT_ABS) |
|
| 46 | + '_DIR_RESTREINT', |
|
| 47 | + (!is_dir(_DIR_RESTREINT_ABS) ? '' : _DIR_RESTREINT_ABS) |
|
| 48 | 48 | ); |
| 49 | 49 | |
| 50 | 50 | /** Chemin relatif pour aller à la racine */ |
@@ -61,28 +61,28 @@ discard block |
||
| 61 | 61 | # Par defaut ces 4 noms seront suffixes par _DIR_RACINE (cf plus bas) |
| 62 | 62 | # mais on peut les mettre ailleurs et changer completement les noms |
| 63 | 63 | if (!defined('_NOM_TEMPORAIRES_INACCESSIBLES')) { |
| 64 | - /** Nom du repertoire des fichiers Temporaires Inaccessibles par http:// */ |
|
| 65 | - define('_NOM_TEMPORAIRES_INACCESSIBLES', 'tmp/'); |
|
| 64 | + /** Nom du repertoire des fichiers Temporaires Inaccessibles par http:// */ |
|
| 65 | + define('_NOM_TEMPORAIRES_INACCESSIBLES', 'tmp/'); |
|
| 66 | 66 | } |
| 67 | 67 | if (!defined('_NOM_TEMPORAIRES_ACCESSIBLES')) { |
| 68 | - /** Nom du repertoire des fichiers Temporaires Accessibles par http:// */ |
|
| 69 | - define('_NOM_TEMPORAIRES_ACCESSIBLES', 'local/'); |
|
| 68 | + /** Nom du repertoire des fichiers Temporaires Accessibles par http:// */ |
|
| 69 | + define('_NOM_TEMPORAIRES_ACCESSIBLES', 'local/'); |
|
| 70 | 70 | } |
| 71 | 71 | if (!defined('_NOM_PERMANENTS_INACCESSIBLES')) { |
| 72 | - /** Nom du repertoire des fichiers Permanents Inaccessibles par http:// */ |
|
| 73 | - define('_NOM_PERMANENTS_INACCESSIBLES', 'config/'); |
|
| 72 | + /** Nom du repertoire des fichiers Permanents Inaccessibles par http:// */ |
|
| 73 | + define('_NOM_PERMANENTS_INACCESSIBLES', 'config/'); |
|
| 74 | 74 | } |
| 75 | 75 | if (!defined('_NOM_PERMANENTS_ACCESSIBLES')) { |
| 76 | - /** Nom du repertoire des fichiers Permanents Accessibles par http:// */ |
|
| 77 | - define('_NOM_PERMANENTS_ACCESSIBLES', 'IMG/'); |
|
| 76 | + /** Nom du repertoire des fichiers Permanents Accessibles par http:// */ |
|
| 77 | + define('_NOM_PERMANENTS_ACCESSIBLES', 'IMG/'); |
|
| 78 | 78 | } |
| 79 | 79 | |
| 80 | 80 | // inclure l'ecran de securite si il n'a pas été inclus en prepend php |
| 81 | 81 | if ( |
| 82 | - !defined('_ECRAN_SECURITE') |
|
| 83 | - and @file_exists($f = _ROOT_RACINE . _NOM_PERMANENTS_INACCESSIBLES . 'ecran_securite.php') |
|
| 82 | + !defined('_ECRAN_SECURITE') |
|
| 83 | + and @file_exists($f = _ROOT_RACINE . _NOM_PERMANENTS_INACCESSIBLES . 'ecran_securite.php') |
|
| 84 | 84 | ) { |
| 85 | - include $f; |
|
| 85 | + include $f; |
|
| 86 | 86 | } |
| 87 | 87 | |
| 88 | 88 | // et on peut lancer l'autoloader |
@@ -90,8 +90,8 @@ discard block |
||
| 90 | 90 | |
| 91 | 91 | // Icones |
| 92 | 92 | if (!defined('_NOM_IMG_PACK')) { |
| 93 | - /** Nom du dossier images */ |
|
| 94 | - define('_NOM_IMG_PACK', 'images/'); |
|
| 93 | + /** Nom du dossier images */ |
|
| 94 | + define('_NOM_IMG_PACK', 'images/'); |
|
| 95 | 95 | } |
| 96 | 96 | /** le chemin http (relatif) vers les images standard */ |
| 97 | 97 | define('_DIR_IMG_PACK', (_DIR_RACINE . 'prive/' . _NOM_IMG_PACK)); |
@@ -100,8 +100,8 @@ discard block |
||
| 100 | 100 | define('_ROOT_IMG_PACK', dirname(__DIR__) . '/prive/' . _NOM_IMG_PACK); |
| 101 | 101 | |
| 102 | 102 | if (!defined('_JAVASCRIPT')) { |
| 103 | - /** Nom du repertoire des bibliotheques JavaScript */ |
|
| 104 | - define('_JAVASCRIPT', 'javascript/'); |
|
| 103 | + /** Nom du repertoire des bibliotheques JavaScript */ |
|
| 104 | + define('_JAVASCRIPT', 'javascript/'); |
|
| 105 | 105 | } // utilisable avec #CHEMIN et find_in_path |
| 106 | 106 | /** le nom du repertoire des bibliotheques JavaScript du prive */ |
| 107 | 107 | define('_DIR_JAVASCRIPT', (_DIR_RACINE . 'prive/' . _JAVASCRIPT)); |
@@ -109,28 +109,28 @@ discard block |
||
| 109 | 109 | |
| 110 | 110 | /** Le nom du fichier de personnalisation */ |
| 111 | 111 | if (!defined('_NOM_CONFIG')) { |
| 112 | - define('_NOM_CONFIG', 'mes_options'); |
|
| 112 | + define('_NOM_CONFIG', 'mes_options'); |
|
| 113 | 113 | } |
| 114 | 114 | |
| 115 | 115 | // Son emplacement absolu si on le trouve |
| 116 | 116 | if ( |
| 117 | - @file_exists($f = _ROOT_RACINE . _NOM_PERMANENTS_INACCESSIBLES . _NOM_CONFIG . '.php') |
|
| 118 | - or (@file_exists($f = _ROOT_RESTREINT . _NOM_CONFIG . '.php')) |
|
| 117 | + @file_exists($f = _ROOT_RACINE . _NOM_PERMANENTS_INACCESSIBLES . _NOM_CONFIG . '.php') |
|
| 118 | + or (@file_exists($f = _ROOT_RESTREINT . _NOM_CONFIG . '.php')) |
|
| 119 | 119 | ) { |
| 120 | - /** Emplacement absolu du fichier d'option */ |
|
| 121 | - define('_FILE_OPTIONS', $f); |
|
| 120 | + /** Emplacement absolu du fichier d'option */ |
|
| 121 | + define('_FILE_OPTIONS', $f); |
|
| 122 | 122 | } else { |
| 123 | - define('_FILE_OPTIONS', ''); |
|
| 123 | + define('_FILE_OPTIONS', ''); |
|
| 124 | 124 | } |
| 125 | 125 | |
| 126 | 126 | if (!defined('MODULES_IDIOMES')) { |
| 127 | - /** |
|
| 128 | - * Modules par défaut pour la traduction. |
|
| 129 | - * |
|
| 130 | - * Constante utilisée par le compilateur et le décompilateur |
|
| 131 | - * sa valeur etant traitée par inc_traduire_dist |
|
| 132 | - */ |
|
| 133 | - define('MODULES_IDIOMES', 'public|spip|ecrire'); |
|
| 127 | + /** |
|
| 128 | + * Modules par défaut pour la traduction. |
|
| 129 | + * |
|
| 130 | + * Constante utilisée par le compilateur et le décompilateur |
|
| 131 | + * sa valeur etant traitée par inc_traduire_dist |
|
| 132 | + */ |
|
| 133 | + define('MODULES_IDIOMES', 'public|spip|ecrire'); |
|
| 134 | 134 | } |
| 135 | 135 | |
| 136 | 136 | // *** Fin des define *** // |
@@ -140,30 +140,30 @@ discard block |
||
| 140 | 140 | * Détecteur de robot d'indexation |
| 141 | 141 | */ |
| 142 | 142 | if (!defined('_IS_BOT')) { |
| 143 | - define( |
|
| 144 | - '_IS_BOT', |
|
| 145 | - isset($_SERVER['HTTP_USER_AGENT']) |
|
| 146 | - and preg_match( |
|
| 147 | - // mots generiques |
|
| 148 | - ',bot|slurp|crawler|spider|webvac|yandex|' |
|
| 149 | - // MSIE 6.0 est un botnet 99,9% du temps, on traite donc ce USER_AGENT comme un bot |
|
| 150 | - . 'MSIE 6\.0|' |
|
| 151 | - // UA plus cibles |
|
| 152 | - . '80legs|accoona|AltaVista|ASPSeek|Baidu|Charlotte|EC2LinkFinder|eStyle|facebook|flipboard|hootsuite|FunWebProducts|Google|Genieo|INA dlweb|InfegyAtlas|Java VM|LiteFinder|Lycos|MetaURI|Moreover|Rambler|Scooter|ScrubbyBloglines|Yahoo|Yeti' |
|
| 153 | - . ',i', |
|
| 154 | - (string)$_SERVER['HTTP_USER_AGENT'] |
|
| 155 | - ) |
|
| 156 | - ); |
|
| 143 | + define( |
|
| 144 | + '_IS_BOT', |
|
| 145 | + isset($_SERVER['HTTP_USER_AGENT']) |
|
| 146 | + and preg_match( |
|
| 147 | + // mots generiques |
|
| 148 | + ',bot|slurp|crawler|spider|webvac|yandex|' |
|
| 149 | + // MSIE 6.0 est un botnet 99,9% du temps, on traite donc ce USER_AGENT comme un bot |
|
| 150 | + . 'MSIE 6\.0|' |
|
| 151 | + // UA plus cibles |
|
| 152 | + . '80legs|accoona|AltaVista|ASPSeek|Baidu|Charlotte|EC2LinkFinder|eStyle|facebook|flipboard|hootsuite|FunWebProducts|Google|Genieo|INA dlweb|InfegyAtlas|Java VM|LiteFinder|Lycos|MetaURI|Moreover|Rambler|Scooter|ScrubbyBloglines|Yahoo|Yeti' |
|
| 153 | + . ',i', |
|
| 154 | + (string)$_SERVER['HTTP_USER_AGENT'] |
|
| 155 | + ) |
|
| 156 | + ); |
|
| 157 | 157 | } |
| 158 | 158 | |
| 159 | 159 | if (!defined('_IS_CLI')) { |
| 160 | - define( |
|
| 161 | - '_IS_CLI', |
|
| 162 | - !isset($_SERVER['HTTP_HOST']) |
|
| 163 | - and !strlen($_SERVER['DOCUMENT_ROOT']) |
|
| 164 | - and !empty($_SERVER['argv']) |
|
| 165 | - and empty($_SERVER['REQUEST_METHOD']) |
|
| 166 | - ); |
|
| 160 | + define( |
|
| 161 | + '_IS_CLI', |
|
| 162 | + !isset($_SERVER['HTTP_HOST']) |
|
| 163 | + and !strlen($_SERVER['DOCUMENT_ROOT']) |
|
| 164 | + and !empty($_SERVER['argv']) |
|
| 165 | + and empty($_SERVER['REQUEST_METHOD']) |
|
| 166 | + ); |
|
| 167 | 167 | } |
| 168 | 168 | |
| 169 | 169 | // *** Parametrage par defaut de SPIP *** |
@@ -175,61 +175,61 @@ discard block |
||
| 175 | 175 | // Ne pas les rendre indefinies. |
| 176 | 176 | |
| 177 | 177 | global |
| 178 | - $nombre_de_logs, |
|
| 179 | - $taille_des_logs, |
|
| 180 | - $table_prefix, |
|
| 181 | - $cookie_prefix, |
|
| 182 | - $dossier_squelettes, |
|
| 183 | - $filtrer_javascript, |
|
| 184 | - $type_urls, |
|
| 185 | - $debut_date_publication, |
|
| 186 | - $ip, |
|
| 187 | - $mysql_rappel_connexion, |
|
| 188 | - $mysql_rappel_nom_base, |
|
| 189 | - $test_i18n, |
|
| 190 | - $ignore_auth_http, |
|
| 191 | - $ignore_remote_user, |
|
| 192 | - $derniere_modif_invalide, |
|
| 193 | - $home_server, |
|
| 194 | - $help_server, |
|
| 195 | - $url_glossaire_externe, |
|
| 196 | - $tex_server, |
|
| 197 | - $traiter_math, |
|
| 198 | - $xhtml, |
|
| 199 | - $xml_indent, |
|
| 200 | - $source_vignettes, |
|
| 201 | - $formats_logos, |
|
| 202 | - $controler_dates_rss, |
|
| 203 | - $spip_pipeline, |
|
| 204 | - $spip_matrice, |
|
| 205 | - $plugins, |
|
| 206 | - $surcharges, |
|
| 207 | - $exceptions_des_tables, |
|
| 208 | - $tables_principales, |
|
| 209 | - $table_des_tables, |
|
| 210 | - $tables_auxiliaires, |
|
| 211 | - $table_primary, |
|
| 212 | - $table_date, |
|
| 213 | - $table_titre, |
|
| 214 | - $tables_jointures, |
|
| 215 | - $liste_des_statuts, |
|
| 216 | - $liste_des_etats, |
|
| 217 | - $liste_des_authentifications, |
|
| 218 | - $spip_version_branche, |
|
| 219 | - $spip_version_code, |
|
| 220 | - $spip_version_base, |
|
| 221 | - $spip_sql_version, |
|
| 222 | - $spip_version_affichee, |
|
| 223 | - $visiteur_session, |
|
| 224 | - $auteur_session, |
|
| 225 | - $connect_statut, |
|
| 226 | - $connect_toutes_rubriques, |
|
| 227 | - $hash_recherche, |
|
| 228 | - $hash_recherche_strict, |
|
| 229 | - $ldap_present, |
|
| 230 | - $meta, |
|
| 231 | - $connect_id_rubrique, |
|
| 232 | - $puce; |
|
| 178 | + $nombre_de_logs, |
|
| 179 | + $taille_des_logs, |
|
| 180 | + $table_prefix, |
|
| 181 | + $cookie_prefix, |
|
| 182 | + $dossier_squelettes, |
|
| 183 | + $filtrer_javascript, |
|
| 184 | + $type_urls, |
|
| 185 | + $debut_date_publication, |
|
| 186 | + $ip, |
|
| 187 | + $mysql_rappel_connexion, |
|
| 188 | + $mysql_rappel_nom_base, |
|
| 189 | + $test_i18n, |
|
| 190 | + $ignore_auth_http, |
|
| 191 | + $ignore_remote_user, |
|
| 192 | + $derniere_modif_invalide, |
|
| 193 | + $home_server, |
|
| 194 | + $help_server, |
|
| 195 | + $url_glossaire_externe, |
|
| 196 | + $tex_server, |
|
| 197 | + $traiter_math, |
|
| 198 | + $xhtml, |
|
| 199 | + $xml_indent, |
|
| 200 | + $source_vignettes, |
|
| 201 | + $formats_logos, |
|
| 202 | + $controler_dates_rss, |
|
| 203 | + $spip_pipeline, |
|
| 204 | + $spip_matrice, |
|
| 205 | + $plugins, |
|
| 206 | + $surcharges, |
|
| 207 | + $exceptions_des_tables, |
|
| 208 | + $tables_principales, |
|
| 209 | + $table_des_tables, |
|
| 210 | + $tables_auxiliaires, |
|
| 211 | + $table_primary, |
|
| 212 | + $table_date, |
|
| 213 | + $table_titre, |
|
| 214 | + $tables_jointures, |
|
| 215 | + $liste_des_statuts, |
|
| 216 | + $liste_des_etats, |
|
| 217 | + $liste_des_authentifications, |
|
| 218 | + $spip_version_branche, |
|
| 219 | + $spip_version_code, |
|
| 220 | + $spip_version_base, |
|
| 221 | + $spip_sql_version, |
|
| 222 | + $spip_version_affichee, |
|
| 223 | + $visiteur_session, |
|
| 224 | + $auteur_session, |
|
| 225 | + $connect_statut, |
|
| 226 | + $connect_toutes_rubriques, |
|
| 227 | + $hash_recherche, |
|
| 228 | + $hash_recherche_strict, |
|
| 229 | + $ldap_present, |
|
| 230 | + $meta, |
|
| 231 | + $connect_id_rubrique, |
|
| 232 | + $puce; |
|
| 233 | 233 | |
| 234 | 234 | # comment on logge, defaut 4 tmp/spip.log de 100k, 0 ou 0 suppriment le log |
| 235 | 235 | $nombre_de_logs = 4; |
@@ -284,48 +284,48 @@ discard block |
||
| 284 | 284 | // Prendre en compte les entetes HTTP_X_FORWARDED_XX |
| 285 | 285 | // |
| 286 | 286 | if (isset($_SERVER['HTTP_X_FORWARDED_PROTO']) and $_SERVER['HTTP_X_FORWARDED_PROTO'] === 'https') { |
| 287 | - if (empty($_SERVER['HTTP_X_FORWARDED_HOST'])) { |
|
| 288 | - $_SERVER['HTTP_X_FORWARDED_HOST'] = $_SERVER['HTTP_HOST']; |
|
| 289 | - } |
|
| 290 | - if (empty($_SERVER['HTTP_X_FORWARDED_PORT'])) { |
|
| 291 | - $_SERVER['HTTP_X_FORWARDED_PORT'] = 443; |
|
| 292 | - } |
|
| 287 | + if (empty($_SERVER['HTTP_X_FORWARDED_HOST'])) { |
|
| 288 | + $_SERVER['HTTP_X_FORWARDED_HOST'] = $_SERVER['HTTP_HOST']; |
|
| 289 | + } |
|
| 290 | + if (empty($_SERVER['HTTP_X_FORWARDED_PORT'])) { |
|
| 291 | + $_SERVER['HTTP_X_FORWARDED_PORT'] = 443; |
|
| 292 | + } |
|
| 293 | 293 | } |
| 294 | 294 | if (isset($_SERVER['HTTP_X_FORWARDED_HOST'])) { |
| 295 | - if (isset($_SERVER['HTTP_X_FORWARDED_PORT']) and is_numeric($_SERVER['HTTP_X_FORWARDED_PORT'])) { |
|
| 296 | - $_SERVER['SERVER_PORT'] = $_SERVER['HTTP_X_FORWARDED_PORT']; |
|
| 297 | - if (isset($_SERVER['HTTP_X_FORWARDED_PROTO']) and $_SERVER['HTTP_X_FORWARDED_PROTO'] === 'https') { |
|
| 298 | - $_SERVER['HTTPS'] = 'on'; |
|
| 299 | - if (isset($_SERVER['REQUEST_SCHEME'])) { |
|
| 300 | - $_SERVER['REQUEST_SCHEME'] = 'https'; |
|
| 301 | - } |
|
| 302 | - } |
|
| 303 | - } |
|
| 304 | - $host = $_SERVER['HTTP_X_FORWARDED_HOST']; |
|
| 305 | - if (strpos($host, ',') !== false) { |
|
| 306 | - $h = explode(',', $host); |
|
| 307 | - $host = trim(reset($h)); |
|
| 308 | - } |
|
| 309 | - // securite sur le contenu de l'entete |
|
| 310 | - $host = strtr($host, "<>?\"\{\}\$'` \r\n", '____________'); |
|
| 311 | - $_SERVER['HTTP_HOST'] = $host; |
|
| 295 | + if (isset($_SERVER['HTTP_X_FORWARDED_PORT']) and is_numeric($_SERVER['HTTP_X_FORWARDED_PORT'])) { |
|
| 296 | + $_SERVER['SERVER_PORT'] = $_SERVER['HTTP_X_FORWARDED_PORT']; |
|
| 297 | + if (isset($_SERVER['HTTP_X_FORWARDED_PROTO']) and $_SERVER['HTTP_X_FORWARDED_PROTO'] === 'https') { |
|
| 298 | + $_SERVER['HTTPS'] = 'on'; |
|
| 299 | + if (isset($_SERVER['REQUEST_SCHEME'])) { |
|
| 300 | + $_SERVER['REQUEST_SCHEME'] = 'https'; |
|
| 301 | + } |
|
| 302 | + } |
|
| 303 | + } |
|
| 304 | + $host = $_SERVER['HTTP_X_FORWARDED_HOST']; |
|
| 305 | + if (strpos($host, ',') !== false) { |
|
| 306 | + $h = explode(',', $host); |
|
| 307 | + $host = trim(reset($h)); |
|
| 308 | + } |
|
| 309 | + // securite sur le contenu de l'entete |
|
| 310 | + $host = strtr($host, "<>?\"\{\}\$'` \r\n", '____________'); |
|
| 311 | + $_SERVER['HTTP_HOST'] = $host; |
|
| 312 | 312 | } |
| 313 | 313 | // |
| 314 | 314 | // On note le numero IP du client dans la variable $ip |
| 315 | 315 | // |
| 316 | 316 | if (isset($_SERVER['HTTP_X_FORWARDED_FOR'])) { |
| 317 | - $ip = $_SERVER['HTTP_X_FORWARDED_FOR']; |
|
| 318 | - if (strpos($ip, ',') !== false) { |
|
| 319 | - $ip = explode(',', $ip); |
|
| 320 | - $ip = reset($ip); |
|
| 321 | - } |
|
| 322 | - // ecraser $_SERVER['REMOTE_ADDR'] si elle est en localhost |
|
| 323 | - if (isset($_SERVER['REMOTE_ADDR']) and $_SERVER['REMOTE_ADDR'] === '127.0.0.1') { |
|
| 324 | - $_SERVER['REMOTE_ADDR'] = $ip; |
|
| 325 | - } |
|
| 317 | + $ip = $_SERVER['HTTP_X_FORWARDED_FOR']; |
|
| 318 | + if (strpos($ip, ',') !== false) { |
|
| 319 | + $ip = explode(',', $ip); |
|
| 320 | + $ip = reset($ip); |
|
| 321 | + } |
|
| 322 | + // ecraser $_SERVER['REMOTE_ADDR'] si elle est en localhost |
|
| 323 | + if (isset($_SERVER['REMOTE_ADDR']) and $_SERVER['REMOTE_ADDR'] === '127.0.0.1') { |
|
| 324 | + $_SERVER['REMOTE_ADDR'] = $ip; |
|
| 325 | + } |
|
| 326 | 326 | } |
| 327 | 327 | if (isset($_SERVER['REMOTE_ADDR'])) { |
| 328 | - $ip = $_SERVER['REMOTE_ADDR']; |
|
| 328 | + $ip = $_SERVER['REMOTE_ADDR']; |
|
| 329 | 329 | } |
| 330 | 330 | |
| 331 | 331 | // Pour renforcer la privacy, decommentez la ligne ci-dessous (ou recopiez-la |
@@ -410,24 +410,24 @@ discard block |
||
| 410 | 410 | |
| 411 | 411 | // Liste des statuts. |
| 412 | 412 | $liste_des_statuts = [ |
| 413 | - 'info_administrateurs' => '0minirezo', |
|
| 414 | - 'info_redacteurs' => '1comite', |
|
| 415 | - 'info_visiteurs' => '6forum', |
|
| 416 | - 'texte_statut_poubelle' => '5poubelle' |
|
| 413 | + 'info_administrateurs' => '0minirezo', |
|
| 414 | + 'info_redacteurs' => '1comite', |
|
| 415 | + 'info_visiteurs' => '6forum', |
|
| 416 | + 'texte_statut_poubelle' => '5poubelle' |
|
| 417 | 417 | ]; |
| 418 | 418 | |
| 419 | 419 | $liste_des_etats = [ |
| 420 | - 'texte_statut_en_cours_redaction' => 'prepa', |
|
| 421 | - 'texte_statut_propose_evaluation' => 'prop', |
|
| 422 | - 'texte_statut_publie' => 'publie', |
|
| 423 | - 'texte_statut_poubelle' => 'poubelle', |
|
| 424 | - 'texte_statut_refuse' => 'refuse' |
|
| 420 | + 'texte_statut_en_cours_redaction' => 'prepa', |
|
| 421 | + 'texte_statut_propose_evaluation' => 'prop', |
|
| 422 | + 'texte_statut_publie' => 'publie', |
|
| 423 | + 'texte_statut_poubelle' => 'poubelle', |
|
| 424 | + 'texte_statut_refuse' => 'refuse' |
|
| 425 | 425 | ]; |
| 426 | 426 | |
| 427 | 427 | // liste des methodes d'authentifications |
| 428 | 428 | $liste_des_authentifications = [ |
| 429 | - 'spip' => 'spip', |
|
| 430 | - 'ldap' => 'ldap' |
|
| 429 | + 'spip' => 'spip', |
|
| 430 | + 'ldap' => 'ldap' |
|
| 431 | 431 | ]; |
| 432 | 432 | |
| 433 | 433 | // Experimental : pour supprimer systematiquement l'affichage des numeros |
@@ -477,12 +477,12 @@ discard block |
||
| 477 | 477 | // Definition personnelles eventuelles |
| 478 | 478 | |
| 479 | 479 | if (_FILE_OPTIONS) { |
| 480 | - include_once _FILE_OPTIONS; |
|
| 480 | + include_once _FILE_OPTIONS; |
|
| 481 | 481 | } |
| 482 | 482 | |
| 483 | 483 | if (!defined('SPIP_ERREUR_REPORT')) { |
| 484 | - /** Masquer les warning */ |
|
| 485 | - define('SPIP_ERREUR_REPORT', E_ALL ^ E_NOTICE ^ E_DEPRECATED); |
|
| 484 | + /** Masquer les warning */ |
|
| 485 | + define('SPIP_ERREUR_REPORT', E_ALL ^ E_NOTICE ^ E_DEPRECATED); |
|
| 486 | 486 | } |
| 487 | 487 | error_reporting(SPIP_ERREUR_REPORT); |
| 488 | 488 | |
@@ -495,10 +495,10 @@ discard block |
||
| 495 | 495 | // ===> on execute en neutralisant les messages d'erreur |
| 496 | 496 | |
| 497 | 497 | spip_initialisation_core( |
| 498 | - (_DIR_RACINE . _NOM_PERMANENTS_INACCESSIBLES), |
|
| 499 | - (_DIR_RACINE . _NOM_PERMANENTS_ACCESSIBLES), |
|
| 500 | - (_DIR_RACINE . _NOM_TEMPORAIRES_INACCESSIBLES), |
|
| 501 | - (_DIR_RACINE . _NOM_TEMPORAIRES_ACCESSIBLES) |
|
| 498 | + (_DIR_RACINE . _NOM_PERMANENTS_INACCESSIBLES), |
|
| 499 | + (_DIR_RACINE . _NOM_PERMANENTS_ACCESSIBLES), |
|
| 500 | + (_DIR_RACINE . _NOM_TEMPORAIRES_INACCESSIBLES), |
|
| 501 | + (_DIR_RACINE . _NOM_TEMPORAIRES_ACCESSIBLES) |
|
| 502 | 502 | ); |
| 503 | 503 | |
| 504 | 504 | |
@@ -508,71 +508,71 @@ discard block |
||
| 508 | 508 | // donc il faut avoir tout fini ici avant de charger les plugins |
| 509 | 509 | |
| 510 | 510 | if (@is_readable(_CACHE_PLUGINS_OPT) and @is_readable(_CACHE_PLUGINS_PATH)) { |
| 511 | - // chargement optimise precompile |
|
| 512 | - include_once(_CACHE_PLUGINS_OPT); |
|
| 511 | + // chargement optimise precompile |
|
| 512 | + include_once(_CACHE_PLUGINS_OPT); |
|
| 513 | 513 | } else { |
| 514 | - spip_initialisation_suite(); |
|
| 515 | - include_spip('inc/plugin'); |
|
| 516 | - // generer les fichiers php precompiles |
|
| 517 | - // de chargement des plugins et des pipelines |
|
| 518 | - actualise_plugins_actifs(); |
|
| 514 | + spip_initialisation_suite(); |
|
| 515 | + include_spip('inc/plugin'); |
|
| 516 | + // generer les fichiers php precompiles |
|
| 517 | + // de chargement des plugins et des pipelines |
|
| 518 | + actualise_plugins_actifs(); |
|
| 519 | 519 | } |
| 520 | 520 | |
| 521 | 521 | // Initialisations non critiques surchargeables par les plugins |
| 522 | 522 | spip_initialisation_suite(); |
| 523 | 523 | |
| 524 | 524 | if (!defined('_LOG_FILTRE_GRAVITE')) { |
| 525 | - /** niveau maxi d'enregistrement des logs */ |
|
| 526 | - define('_LOG_FILTRE_GRAVITE', _LOG_INFO_IMPORTANTE); |
|
| 525 | + /** niveau maxi d'enregistrement des logs */ |
|
| 526 | + define('_LOG_FILTRE_GRAVITE', _LOG_INFO_IMPORTANTE); |
|
| 527 | 527 | } |
| 528 | 528 | |
| 529 | 529 | if (!defined('_OUTILS_DEVELOPPEURS')) { |
| 530 | - /** Activer des outils pour développeurs ? */ |
|
| 531 | - define('_OUTILS_DEVELOPPEURS', false); |
|
| 530 | + /** Activer des outils pour développeurs ? */ |
|
| 531 | + define('_OUTILS_DEVELOPPEURS', false); |
|
| 532 | 532 | } |
| 533 | 533 | |
| 534 | 534 | // charger systematiquement inc/autoriser dans l'espace restreint |
| 535 | 535 | if (test_espace_prive()) { |
| 536 | - include_spip('inc/autoriser'); |
|
| 536 | + include_spip('inc/autoriser'); |
|
| 537 | 537 | } |
| 538 | 538 | // |
| 539 | 539 | // Installer Spip si pas installe... sauf si justement on est en train |
| 540 | 540 | // |
| 541 | 541 | if ( |
| 542 | - !(_FILE_CONNECT |
|
| 543 | - or autoriser_sans_cookie(_request('exec')) |
|
| 544 | - or _request('action') == 'cookie' |
|
| 545 | - or _request('action') == 'converser' |
|
| 546 | - or _request('action') == 'test_dirs') |
|
| 542 | + !(_FILE_CONNECT |
|
| 543 | + or autoriser_sans_cookie(_request('exec')) |
|
| 544 | + or _request('action') == 'cookie' |
|
| 545 | + or _request('action') == 'converser' |
|
| 546 | + or _request('action') == 'test_dirs') |
|
| 547 | 547 | ) { |
| 548 | - // Si on peut installer, on lance illico |
|
| 549 | - if (test_espace_prive()) { |
|
| 550 | - include_spip('inc/headers'); |
|
| 551 | - redirige_url_ecrire('install'); |
|
| 552 | - } else { |
|
| 553 | - // Si on est dans le site public, dire que qq s'en occupe |
|
| 554 | - include_spip('inc/lang'); |
|
| 555 | - utiliser_langue_visiteur(); |
|
| 556 | - include_spip('inc/minipres'); |
|
| 557 | - echo minipres(_T('info_travaux_titre'), "<p style='text-align: center;'>" . _T('info_travaux_texte') . '</p>', ['status' => 503]); |
|
| 558 | - exit; |
|
| 559 | - } |
|
| 560 | - // autrement c'est une install ad hoc (spikini...), on sait pas faire |
|
| 548 | + // Si on peut installer, on lance illico |
|
| 549 | + if (test_espace_prive()) { |
|
| 550 | + include_spip('inc/headers'); |
|
| 551 | + redirige_url_ecrire('install'); |
|
| 552 | + } else { |
|
| 553 | + // Si on est dans le site public, dire que qq s'en occupe |
|
| 554 | + include_spip('inc/lang'); |
|
| 555 | + utiliser_langue_visiteur(); |
|
| 556 | + include_spip('inc/minipres'); |
|
| 557 | + echo minipres(_T('info_travaux_titre'), "<p style='text-align: center;'>" . _T('info_travaux_texte') . '</p>', ['status' => 503]); |
|
| 558 | + exit; |
|
| 559 | + } |
|
| 560 | + // autrement c'est une install ad hoc (spikini...), on sait pas faire |
|
| 561 | 561 | } |
| 562 | 562 | |
| 563 | 563 | // memoriser un tri sessionne eventuel |
| 564 | 564 | if ( |
| 565 | - isset($_REQUEST['var_memotri']) |
|
| 566 | - and $t = $_REQUEST['var_memotri'] |
|
| 567 | - and (strncmp($t, 'trisession', 10) == 0 or strncmp($t, 'senssession', 11) == 0) |
|
| 565 | + isset($_REQUEST['var_memotri']) |
|
| 566 | + and $t = $_REQUEST['var_memotri'] |
|
| 567 | + and (strncmp($t, 'trisession', 10) == 0 or strncmp($t, 'senssession', 11) == 0) |
|
| 568 | 568 | ) { |
| 569 | - if (!function_exists('session_set')) { |
|
| 570 | - include_spip('inc/session'); |
|
| 571 | - } |
|
| 572 | - $t = preg_replace(',\W,', '_', $t); |
|
| 573 | - if ($v = _request($t)) { |
|
| 574 | - session_set($t, $v); |
|
| 575 | - } |
|
| 569 | + if (!function_exists('session_set')) { |
|
| 570 | + include_spip('inc/session'); |
|
| 571 | + } |
|
| 572 | + $t = preg_replace(',\W,', '_', $t); |
|
| 573 | + if ($v = _request($t)) { |
|
| 574 | + session_set($t, $v); |
|
| 575 | + } |
|
| 576 | 576 | } |
| 577 | 577 | |
| 578 | 578 | /** |
@@ -582,22 +582,22 @@ discard block |
||
| 582 | 582 | * La globale $spip_header_silencieux permet de rendre le header minimal pour raisons de securite |
| 583 | 583 | */ |
| 584 | 584 | if (!defined('_HEADER_COMPOSED_BY')) { |
| 585 | - define('_HEADER_COMPOSED_BY', 'Composed-By: SPIP'); |
|
| 585 | + define('_HEADER_COMPOSED_BY', 'Composed-By: SPIP'); |
|
| 586 | 586 | } |
| 587 | 587 | if (!headers_sent() and _HEADER_COMPOSED_BY) { |
| 588 | - if (!defined('_HEADER_VARY')) { |
|
| 589 | - define('_HEADER_VARY', 'Vary: Cookie, Accept-Encoding'); |
|
| 590 | - } |
|
| 591 | - if (_HEADER_VARY) { |
|
| 592 | - header(_HEADER_VARY); |
|
| 593 | - } |
|
| 594 | - if (!isset($GLOBALS['spip_header_silencieux']) or !$GLOBALS['spip_header_silencieux']) { |
|
| 595 | - include_spip('inc/filtres_mini'); |
|
| 596 | - header(_HEADER_COMPOSED_BY . " $spip_version_affichee @ www.spip.net + " . url_absolue(_DIR_VAR . 'config.txt')); |
|
| 597 | - } else { |
|
| 598 | - // header minimal |
|
| 599 | - header(_HEADER_COMPOSED_BY . ' @ www.spip.net'); |
|
| 600 | - } |
|
| 588 | + if (!defined('_HEADER_VARY')) { |
|
| 589 | + define('_HEADER_VARY', 'Vary: Cookie, Accept-Encoding'); |
|
| 590 | + } |
|
| 591 | + if (_HEADER_VARY) { |
|
| 592 | + header(_HEADER_VARY); |
|
| 593 | + } |
|
| 594 | + if (!isset($GLOBALS['spip_header_silencieux']) or !$GLOBALS['spip_header_silencieux']) { |
|
| 595 | + include_spip('inc/filtres_mini'); |
|
| 596 | + header(_HEADER_COMPOSED_BY . " $spip_version_affichee @ www.spip.net + " . url_absolue(_DIR_VAR . 'config.txt')); |
|
| 597 | + } else { |
|
| 598 | + // header minimal |
|
| 599 | + header(_HEADER_COMPOSED_BY . ' @ www.spip.net'); |
|
| 600 | + } |
|
| 601 | 601 | } |
| 602 | 602 | |
| 603 | 603 | $methode = ($_SERVER['REQUEST_METHOD'] ?? ((php_sapi_name() == 'cli') ? 'cli' : '')); |
@@ -15,7 +15,7 @@ discard block |
||
| 15 | 15 | * @package SPIP\Core\Formulaires |
| 16 | 16 | **/ |
| 17 | 17 | if (!defined('_ECRIRE_INC_VERSION')) { |
| 18 | - return; |
|
| 18 | + return; |
|
| 19 | 19 | } |
| 20 | 20 | |
| 21 | 21 | include_spip('inc/filtres'); |
@@ -34,28 +34,28 @@ discard block |
||
| 34 | 34 | * @see spip_htmlspecialchars() |
| 35 | 35 | */ |
| 36 | 36 | function protege_champ($valeur, $max_prof = 128) { |
| 37 | - if (is_array($valeur)) { |
|
| 38 | - if ($max_prof > 0) { |
|
| 39 | - return array_map( |
|
| 40 | - function($v) use ($max_prof) { |
|
| 41 | - return protege_champ($v, $max_prof-1); |
|
| 42 | - }, |
|
| 43 | - $valeur |
|
| 44 | - ); |
|
| 45 | - } |
|
| 46 | - // si on dépasse la prof max on tronque |
|
| 47 | - return []; |
|
| 48 | - } elseif ($valeur === null) { |
|
| 49 | - return $valeur; |
|
| 50 | - } elseif (is_bool($valeur)) { |
|
| 51 | - return $valeur ? '1' : ''; |
|
| 52 | - } elseif (is_string($valeur) and $valeur) { |
|
| 53 | - if (strpbrk($valeur, "&\"'<>") !== false) { |
|
| 54 | - return spip_htmlspecialchars($valeur, ENT_QUOTES); |
|
| 55 | - } |
|
| 56 | - } |
|
| 57 | - |
|
| 58 | - return $valeur; |
|
| 37 | + if (is_array($valeur)) { |
|
| 38 | + if ($max_prof > 0) { |
|
| 39 | + return array_map( |
|
| 40 | + function($v) use ($max_prof) { |
|
| 41 | + return protege_champ($v, $max_prof-1); |
|
| 42 | + }, |
|
| 43 | + $valeur |
|
| 44 | + ); |
|
| 45 | + } |
|
| 46 | + // si on dépasse la prof max on tronque |
|
| 47 | + return []; |
|
| 48 | + } elseif ($valeur === null) { |
|
| 49 | + return $valeur; |
|
| 50 | + } elseif (is_bool($valeur)) { |
|
| 51 | + return $valeur ? '1' : ''; |
|
| 52 | + } elseif (is_string($valeur) and $valeur) { |
|
| 53 | + if (strpbrk($valeur, "&\"'<>") !== false) { |
|
| 54 | + return spip_htmlspecialchars($valeur, ENT_QUOTES); |
|
| 55 | + } |
|
| 56 | + } |
|
| 57 | + |
|
| 58 | + return $valeur; |
|
| 59 | 59 | } |
| 60 | 60 | |
| 61 | 61 | /** |
@@ -69,17 +69,17 @@ discard block |
||
| 69 | 69 | * - false : pas de squelette trouvé |
| 70 | 70 | **/ |
| 71 | 71 | function existe_formulaire($form) { |
| 72 | - if (substr($form, 0, 11) == 'FORMULAIRE_') { |
|
| 73 | - $form = strtolower(substr($form, 11)); |
|
| 74 | - } else { |
|
| 75 | - $form = strtolower($form); |
|
| 76 | - } |
|
| 72 | + if (substr($form, 0, 11) == 'FORMULAIRE_') { |
|
| 73 | + $form = strtolower(substr($form, 11)); |
|
| 74 | + } else { |
|
| 75 | + $form = strtolower($form); |
|
| 76 | + } |
|
| 77 | 77 | |
| 78 | - if (!$form) { |
|
| 79 | - return ''; |
|
| 80 | - } // on ne sait pas, le nom du formulaire n'est pas fourni ici |
|
| 78 | + if (!$form) { |
|
| 79 | + return ''; |
|
| 80 | + } // on ne sait pas, le nom du formulaire n'est pas fourni ici |
|
| 81 | 81 | |
| 82 | - return trouver_fond($form, 'formulaires/') ? $form : false; |
|
| 82 | + return trouver_fond($form, 'formulaires/') ? $form : false; |
|
| 83 | 83 | } |
| 84 | 84 | |
| 85 | 85 | /** |
@@ -88,31 +88,31 @@ discard block |
||
| 88 | 88 | * @return false|array |
| 89 | 89 | */ |
| 90 | 90 | function test_formulaire_inclus_par_modele() { |
| 91 | - $trace = debug_backtrace(0, 20); |
|
| 92 | - $trace_fonctions = array_column($trace, 'function'); |
|
| 93 | - $trace_fonctions = array_map('strtolower', $trace_fonctions); |
|
| 94 | - |
|
| 95 | - // regarder si un flag a ete leve juste avant l'appel de balise_FORMULAIRE_dyn |
|
| 96 | - if ( |
|
| 97 | - function_exists('arguments_balise_dyn_depuis_modele') |
|
| 98 | - and $form = arguments_balise_dyn_depuis_modele(null, 'read') |
|
| 99 | - ) { |
|
| 100 | - if (in_array('balise_formulaire__dyn', $trace_fonctions)) { |
|
| 101 | - $k = array_search('balise_formulaire__dyn', $trace_fonctions); |
|
| 102 | - if ($trace[$k]['args'][0] === $form) { |
|
| 103 | - return $trace[$k]['args']; |
|
| 104 | - } |
|
| 105 | - } |
|
| 106 | - } |
|
| 107 | - |
|
| 108 | - // fallback qui ne repose pas sur le flag lie a l'analyse de contexte_compil, |
|
| 109 | - // mais ne marche pas si executer_balise_dynamique est appelee via du php dans le squelette |
|
| 110 | - if (in_array('eval', $trace_fonctions) and in_array('inclure_modele', $trace_fonctions)) { |
|
| 111 | - $k = array_search('inclure_modele', $trace_fonctions); |
|
| 112 | - // les arguments de recuperer_fond() passes par inclure_modele() |
|
| 113 | - return $trace[$k - 1]['args'][1]['args']; |
|
| 114 | - } |
|
| 115 | - return false; |
|
| 91 | + $trace = debug_backtrace(0, 20); |
|
| 92 | + $trace_fonctions = array_column($trace, 'function'); |
|
| 93 | + $trace_fonctions = array_map('strtolower', $trace_fonctions); |
|
| 94 | + |
|
| 95 | + // regarder si un flag a ete leve juste avant l'appel de balise_FORMULAIRE_dyn |
|
| 96 | + if ( |
|
| 97 | + function_exists('arguments_balise_dyn_depuis_modele') |
|
| 98 | + and $form = arguments_balise_dyn_depuis_modele(null, 'read') |
|
| 99 | + ) { |
|
| 100 | + if (in_array('balise_formulaire__dyn', $trace_fonctions)) { |
|
| 101 | + $k = array_search('balise_formulaire__dyn', $trace_fonctions); |
|
| 102 | + if ($trace[$k]['args'][0] === $form) { |
|
| 103 | + return $trace[$k]['args']; |
|
| 104 | + } |
|
| 105 | + } |
|
| 106 | + } |
|
| 107 | + |
|
| 108 | + // fallback qui ne repose pas sur le flag lie a l'analyse de contexte_compil, |
|
| 109 | + // mais ne marche pas si executer_balise_dynamique est appelee via du php dans le squelette |
|
| 110 | + if (in_array('eval', $trace_fonctions) and in_array('inclure_modele', $trace_fonctions)) { |
|
| 111 | + $k = array_search('inclure_modele', $trace_fonctions); |
|
| 112 | + // les arguments de recuperer_fond() passes par inclure_modele() |
|
| 113 | + return $trace[$k - 1]['args'][1]['args']; |
|
| 114 | + } |
|
| 115 | + return false; |
|
| 116 | 116 | } |
| 117 | 117 | |
| 118 | 118 | /** |
@@ -127,19 +127,19 @@ discard block |
||
| 127 | 127 | **/ |
| 128 | 128 | function balise_FORMULAIRE__dist($p) { |
| 129 | 129 | |
| 130 | - // Cas d'un #FORMULAIRE_TOTO inexistant : renvoyer la chaine vide. |
|
| 131 | - // mais si #FORMULAIRE_{toto} on ne peut pas savoir a la compilation, continuer |
|
| 132 | - if (existe_formulaire($p->nom_champ) === false) { |
|
| 133 | - $p->code = "''"; |
|
| 134 | - $p->interdire_scripts = false; |
|
| 130 | + // Cas d'un #FORMULAIRE_TOTO inexistant : renvoyer la chaine vide. |
|
| 131 | + // mais si #FORMULAIRE_{toto} on ne peut pas savoir a la compilation, continuer |
|
| 132 | + if (existe_formulaire($p->nom_champ) === false) { |
|
| 133 | + $p->code = "''"; |
|
| 134 | + $p->interdire_scripts = false; |
|
| 135 | 135 | |
| 136 | - return $p; |
|
| 137 | - } |
|
| 136 | + return $p; |
|
| 137 | + } |
|
| 138 | 138 | |
| 139 | - // sinon renvoyer un code php dynamique |
|
| 140 | - $p = calculer_balise_dynamique($p, $p->nom_champ, []); |
|
| 139 | + // sinon renvoyer un code php dynamique |
|
| 140 | + $p = calculer_balise_dynamique($p, $p->nom_champ, []); |
|
| 141 | 141 | |
| 142 | - return $p; |
|
| 142 | + return $p; |
|
| 143 | 143 | } |
| 144 | 144 | |
| 145 | 145 | /** |
@@ -159,17 +159,17 @@ discard block |
||
| 159 | 159 | * - string : texte à afficher directement |
| 160 | 160 | */ |
| 161 | 161 | function balise_FORMULAIRE__dyn($form, ...$args) { |
| 162 | - $form = existe_formulaire($form); |
|
| 163 | - if (!$form) { |
|
| 164 | - return ''; |
|
| 165 | - } |
|
| 162 | + $form = existe_formulaire($form); |
|
| 163 | + if (!$form) { |
|
| 164 | + return ''; |
|
| 165 | + } |
|
| 166 | 166 | |
| 167 | - $contexte = balise_FORMULAIRE__contexte($form, $args); |
|
| 168 | - if (!is_array($contexte)) { |
|
| 169 | - return $contexte; |
|
| 170 | - } |
|
| 167 | + $contexte = balise_FORMULAIRE__contexte($form, $args); |
|
| 168 | + if (!is_array($contexte)) { |
|
| 169 | + return $contexte; |
|
| 170 | + } |
|
| 171 | 171 | |
| 172 | - return ["formulaires/$form", 3600, $contexte]; |
|
| 172 | + return ["formulaires/$form", 3600, $contexte]; |
|
| 173 | 173 | } |
| 174 | 174 | |
| 175 | 175 | /** |
@@ -184,85 +184,85 @@ discard block |
||
| 184 | 184 | * string: Formulaire non applicable (message d’explication) |
| 185 | 185 | **/ |
| 186 | 186 | function balise_FORMULAIRE__contexte($form, $args) { |
| 187 | - // tester si ce formulaire vient d'etre poste (memes arguments) |
|
| 188 | - // pour ne pas confondre 2 #FORMULAIRES_XX identiques sur une meme page |
|
| 189 | - // si poste, on recupere les erreurs |
|
| 190 | - |
|
| 191 | - $je_suis_poste = false; |
|
| 192 | - if ( |
|
| 193 | - $post_form = _request('formulaire_action') |
|
| 194 | - and $post_form == $form |
|
| 195 | - and $p = _request('formulaire_action_args') |
|
| 196 | - and is_array($p = decoder_contexte_ajax($p, $post_form)) |
|
| 197 | - ) { |
|
| 198 | - // enlever le faux attribut de langue masque |
|
| 199 | - array_shift($p); |
|
| 200 | - if (formulaire__identifier($form, $args, $p)) { |
|
| 201 | - $je_suis_poste = true; |
|
| 202 | - } |
|
| 203 | - } |
|
| 204 | - |
|
| 205 | - $editable = true; |
|
| 206 | - $erreurs = $post = []; |
|
| 207 | - if ($je_suis_poste) { |
|
| 208 | - $post = traiter_formulaires_dynamiques(true); |
|
| 209 | - $e = "erreurs_$form"; |
|
| 210 | - $erreurs = $post[$e] ?? []; |
|
| 211 | - $editable = "editable_$form"; |
|
| 212 | - $editable = (!isset($post[$e])) |
|
| 213 | - || (is_countable($erreurs) ? count($erreurs) : 0) |
|
| 214 | - || (isset($post[$editable]) && $post[$editable]); |
|
| 215 | - } |
|
| 216 | - |
|
| 217 | - $valeurs = formulaire__charger($form, $args, $je_suis_poste); |
|
| 218 | - |
|
| 219 | - // si $valeurs n'est pas un tableau, le formulaire n'est pas applicable |
|
| 220 | - // C'est plus fort qu'editable qui est gere par le squelette |
|
| 221 | - // Idealement $valeur doit etre alors un message explicatif. |
|
| 222 | - if (!is_array($valeurs)) { |
|
| 223 | - return is_string($valeurs) ? $valeurs : ''; |
|
| 224 | - } |
|
| 225 | - |
|
| 226 | - // charger peut passer une action si le formulaire ne tourne pas sur self() |
|
| 227 | - // ou une action vide si elle ne sert pas |
|
| 228 | - $action = $valeurs['action'] ?? self('&', true); |
|
| 229 | - // bug IEx : si action finit par / |
|
| 230 | - // IE croit que le <form ... action=../ > est autoferme |
|
| 231 | - if (substr($action, -1) == '/') { |
|
| 232 | - // on ajoute une ancre pour feinter IE, au pire ca tue l'ancre qui finit par un / |
|
| 233 | - $action .= '#'; |
|
| 234 | - } |
|
| 235 | - |
|
| 236 | - // recuperer la saisie en cours si erreurs |
|
| 237 | - // seulement si c'est ce formulaire qui est poste |
|
| 238 | - // ou si on le demande explicitement par le parametre _forcer_request = true |
|
| 239 | - $dispo = ($je_suis_poste || (isset($valeurs['_forcer_request']) && $valeurs['_forcer_request'])); |
|
| 240 | - foreach (array_keys($valeurs) as $champ) { |
|
| 241 | - if ($champ[0] !== '_' and !in_array($champ, ['message_ok', 'message_erreur', 'editable'])) { |
|
| 242 | - if ($dispo and (($v = _request($champ)) !== null)) { |
|
| 243 | - $valeurs[$champ] = $v; |
|
| 244 | - } |
|
| 245 | - // nettoyer l'url des champs qui vont etre saisis |
|
| 246 | - if ($action) { |
|
| 247 | - $action = parametre_url($action, $champ, ''); |
|
| 248 | - } |
|
| 249 | - // proteger les ' et les " dans les champs que l'on va injecter |
|
| 250 | - $valeurs[$champ] = protege_champ($valeurs[$champ]); |
|
| 251 | - } |
|
| 252 | - } |
|
| 253 | - |
|
| 254 | - if ($action) { |
|
| 255 | - // nettoyer l'url |
|
| 256 | - $action = parametre_url($action, 'formulaire_action', ''); |
|
| 257 | - $action = parametre_url($action, 'formulaire_action_args', ''); |
|
| 258 | - $action = parametre_url($action, 'formulaire_action_sign', ''); |
|
| 259 | - } |
|
| 260 | - |
|
| 261 | - /** |
|
| 262 | - * @deprecated 4.0 |
|
| 263 | - * servait pour poster sur les actions de type editer_xxx() qui ne prenaient pas d'argument autrement que par _request('arg') et pour lesquelles il fallait donc passer un hash valide |
|
| 264 | - */ |
|
| 265 | - /* |
|
| 187 | + // tester si ce formulaire vient d'etre poste (memes arguments) |
|
| 188 | + // pour ne pas confondre 2 #FORMULAIRES_XX identiques sur une meme page |
|
| 189 | + // si poste, on recupere les erreurs |
|
| 190 | + |
|
| 191 | + $je_suis_poste = false; |
|
| 192 | + if ( |
|
| 193 | + $post_form = _request('formulaire_action') |
|
| 194 | + and $post_form == $form |
|
| 195 | + and $p = _request('formulaire_action_args') |
|
| 196 | + and is_array($p = decoder_contexte_ajax($p, $post_form)) |
|
| 197 | + ) { |
|
| 198 | + // enlever le faux attribut de langue masque |
|
| 199 | + array_shift($p); |
|
| 200 | + if (formulaire__identifier($form, $args, $p)) { |
|
| 201 | + $je_suis_poste = true; |
|
| 202 | + } |
|
| 203 | + } |
|
| 204 | + |
|
| 205 | + $editable = true; |
|
| 206 | + $erreurs = $post = []; |
|
| 207 | + if ($je_suis_poste) { |
|
| 208 | + $post = traiter_formulaires_dynamiques(true); |
|
| 209 | + $e = "erreurs_$form"; |
|
| 210 | + $erreurs = $post[$e] ?? []; |
|
| 211 | + $editable = "editable_$form"; |
|
| 212 | + $editable = (!isset($post[$e])) |
|
| 213 | + || (is_countable($erreurs) ? count($erreurs) : 0) |
|
| 214 | + || (isset($post[$editable]) && $post[$editable]); |
|
| 215 | + } |
|
| 216 | + |
|
| 217 | + $valeurs = formulaire__charger($form, $args, $je_suis_poste); |
|
| 218 | + |
|
| 219 | + // si $valeurs n'est pas un tableau, le formulaire n'est pas applicable |
|
| 220 | + // C'est plus fort qu'editable qui est gere par le squelette |
|
| 221 | + // Idealement $valeur doit etre alors un message explicatif. |
|
| 222 | + if (!is_array($valeurs)) { |
|
| 223 | + return is_string($valeurs) ? $valeurs : ''; |
|
| 224 | + } |
|
| 225 | + |
|
| 226 | + // charger peut passer une action si le formulaire ne tourne pas sur self() |
|
| 227 | + // ou une action vide si elle ne sert pas |
|
| 228 | + $action = $valeurs['action'] ?? self('&', true); |
|
| 229 | + // bug IEx : si action finit par / |
|
| 230 | + // IE croit que le <form ... action=../ > est autoferme |
|
| 231 | + if (substr($action, -1) == '/') { |
|
| 232 | + // on ajoute une ancre pour feinter IE, au pire ca tue l'ancre qui finit par un / |
|
| 233 | + $action .= '#'; |
|
| 234 | + } |
|
| 235 | + |
|
| 236 | + // recuperer la saisie en cours si erreurs |
|
| 237 | + // seulement si c'est ce formulaire qui est poste |
|
| 238 | + // ou si on le demande explicitement par le parametre _forcer_request = true |
|
| 239 | + $dispo = ($je_suis_poste || (isset($valeurs['_forcer_request']) && $valeurs['_forcer_request'])); |
|
| 240 | + foreach (array_keys($valeurs) as $champ) { |
|
| 241 | + if ($champ[0] !== '_' and !in_array($champ, ['message_ok', 'message_erreur', 'editable'])) { |
|
| 242 | + if ($dispo and (($v = _request($champ)) !== null)) { |
|
| 243 | + $valeurs[$champ] = $v; |
|
| 244 | + } |
|
| 245 | + // nettoyer l'url des champs qui vont etre saisis |
|
| 246 | + if ($action) { |
|
| 247 | + $action = parametre_url($action, $champ, ''); |
|
| 248 | + } |
|
| 249 | + // proteger les ' et les " dans les champs que l'on va injecter |
|
| 250 | + $valeurs[$champ] = protege_champ($valeurs[$champ]); |
|
| 251 | + } |
|
| 252 | + } |
|
| 253 | + |
|
| 254 | + if ($action) { |
|
| 255 | + // nettoyer l'url |
|
| 256 | + $action = parametre_url($action, 'formulaire_action', ''); |
|
| 257 | + $action = parametre_url($action, 'formulaire_action_args', ''); |
|
| 258 | + $action = parametre_url($action, 'formulaire_action_sign', ''); |
|
| 259 | + } |
|
| 260 | + |
|
| 261 | + /** |
|
| 262 | + * @deprecated 4.0 |
|
| 263 | + * servait pour poster sur les actions de type editer_xxx() qui ne prenaient pas d'argument autrement que par _request('arg') et pour lesquelles il fallait donc passer un hash valide |
|
| 264 | + */ |
|
| 265 | + /* |
|
| 266 | 266 | if (isset($valeurs['_action'])) { |
| 267 | 267 | $securiser_action = charger_fonction('securiser_action', 'inc'); |
| 268 | 268 | $secu = $securiser_action(reset($valeurs['_action']), end($valeurs['_action']), '', -1); |
@@ -272,59 +272,59 @@ discard block |
||
| 272 | 272 | } |
| 273 | 273 | */ |
| 274 | 274 | |
| 275 | - // empiler la lang en tant que premier argument implicite du CVT |
|
| 276 | - // pour permettre de la restaurer au moment du Verifier et du Traiter |
|
| 277 | - array_unshift($args, $GLOBALS['spip_lang']); |
|
| 278 | - |
|
| 279 | - $valeurs['formulaire_args'] = encoder_contexte_ajax($args, $form); |
|
| 280 | - $valeurs['erreurs'] = $erreurs; |
|
| 281 | - $valeurs['action'] = $action; |
|
| 282 | - $valeurs['form'] = $form; |
|
| 283 | - |
|
| 284 | - $valeurs['formulaire_sign'] = ''; |
|
| 285 | - if (!empty($GLOBALS['visiteur_session']['id_auteur'])) { |
|
| 286 | - $securiser_action = charger_fonction('securiser_action', 'inc'); |
|
| 287 | - $secu = $securiser_action($valeurs['form'], $valeurs['formulaire_args'], '', -1); |
|
| 288 | - $valeurs['formulaire_sign'] = $secu['hash']; |
|
| 289 | - } |
|
| 290 | - |
|
| 291 | - if (!isset($valeurs['id'])) { |
|
| 292 | - $valeurs['id'] = 'new'; |
|
| 293 | - } |
|
| 294 | - // editable peut venir de charger() ou de traiter() sinon |
|
| 295 | - if (!isset($valeurs['editable'])) { |
|
| 296 | - $valeurs['editable'] = $editable; |
|
| 297 | - } |
|
| 298 | - // dans tous les cas, renvoyer un espace ou vide (et pas un booleen) |
|
| 299 | - $valeurs['editable'] = ($valeurs['editable'] ? ' ' : ''); |
|
| 300 | - |
|
| 301 | - if ($je_suis_poste) { |
|
| 302 | - $valeurs['message_erreur'] = ''; |
|
| 303 | - if (isset($erreurs['message_erreur'])) { |
|
| 304 | - $valeurs['message_erreur'] = $erreurs['message_erreur']; |
|
| 305 | - } |
|
| 306 | - |
|
| 307 | - $valeurs['message_ok'] = ''; |
|
| 308 | - if (isset($post["message_ok_$form"])) { |
|
| 309 | - $valeurs['message_ok'] = $post["message_ok_$form"]; |
|
| 310 | - } elseif (isset($erreurs['message_ok'])) { |
|
| 311 | - $valeurs['message_ok'] = $erreurs['message_ok']; |
|
| 312 | - } |
|
| 313 | - |
|
| 314 | - // accessibilite : encapsuler toutes les erreurs dans un role='alert' |
|
| 315 | - // uniquement si c'est une string et au premier niveau (on ne touche pas au tableaux) |
|
| 316 | - // et si $k ne commence pas par un _ (c'est bien une vrai erreur sur un vrai champ) |
|
| 317 | - if (html5_permis()) { |
|
| 318 | - foreach ($erreurs as $k => $v) { |
|
| 319 | - if (is_string($v) and strlen(trim($v)) and strpos($k, '_') !== 0) { |
|
| 320 | - // on encapsule dans un span car ces messages sont en general simple, juste du texte, et deja dans un span dans le form |
|
| 321 | - $valeurs['erreurs'][$k] = "<span role='alert'>" . $erreurs[$k] . '</span>'; |
|
| 322 | - } |
|
| 323 | - } |
|
| 324 | - } |
|
| 325 | - } |
|
| 326 | - |
|
| 327 | - return $valeurs; |
|
| 275 | + // empiler la lang en tant que premier argument implicite du CVT |
|
| 276 | + // pour permettre de la restaurer au moment du Verifier et du Traiter |
|
| 277 | + array_unshift($args, $GLOBALS['spip_lang']); |
|
| 278 | + |
|
| 279 | + $valeurs['formulaire_args'] = encoder_contexte_ajax($args, $form); |
|
| 280 | + $valeurs['erreurs'] = $erreurs; |
|
| 281 | + $valeurs['action'] = $action; |
|
| 282 | + $valeurs['form'] = $form; |
|
| 283 | + |
|
| 284 | + $valeurs['formulaire_sign'] = ''; |
|
| 285 | + if (!empty($GLOBALS['visiteur_session']['id_auteur'])) { |
|
| 286 | + $securiser_action = charger_fonction('securiser_action', 'inc'); |
|
| 287 | + $secu = $securiser_action($valeurs['form'], $valeurs['formulaire_args'], '', -1); |
|
| 288 | + $valeurs['formulaire_sign'] = $secu['hash']; |
|
| 289 | + } |
|
| 290 | + |
|
| 291 | + if (!isset($valeurs['id'])) { |
|
| 292 | + $valeurs['id'] = 'new'; |
|
| 293 | + } |
|
| 294 | + // editable peut venir de charger() ou de traiter() sinon |
|
| 295 | + if (!isset($valeurs['editable'])) { |
|
| 296 | + $valeurs['editable'] = $editable; |
|
| 297 | + } |
|
| 298 | + // dans tous les cas, renvoyer un espace ou vide (et pas un booleen) |
|
| 299 | + $valeurs['editable'] = ($valeurs['editable'] ? ' ' : ''); |
|
| 300 | + |
|
| 301 | + if ($je_suis_poste) { |
|
| 302 | + $valeurs['message_erreur'] = ''; |
|
| 303 | + if (isset($erreurs['message_erreur'])) { |
|
| 304 | + $valeurs['message_erreur'] = $erreurs['message_erreur']; |
|
| 305 | + } |
|
| 306 | + |
|
| 307 | + $valeurs['message_ok'] = ''; |
|
| 308 | + if (isset($post["message_ok_$form"])) { |
|
| 309 | + $valeurs['message_ok'] = $post["message_ok_$form"]; |
|
| 310 | + } elseif (isset($erreurs['message_ok'])) { |
|
| 311 | + $valeurs['message_ok'] = $erreurs['message_ok']; |
|
| 312 | + } |
|
| 313 | + |
|
| 314 | + // accessibilite : encapsuler toutes les erreurs dans un role='alert' |
|
| 315 | + // uniquement si c'est une string et au premier niveau (on ne touche pas au tableaux) |
|
| 316 | + // et si $k ne commence pas par un _ (c'est bien une vrai erreur sur un vrai champ) |
|
| 317 | + if (html5_permis()) { |
|
| 318 | + foreach ($erreurs as $k => $v) { |
|
| 319 | + if (is_string($v) and strlen(trim($v)) and strpos($k, '_') !== 0) { |
|
| 320 | + // on encapsule dans un span car ces messages sont en general simple, juste du texte, et deja dans un span dans le form |
|
| 321 | + $valeurs['erreurs'][$k] = "<span role='alert'>" . $erreurs[$k] . '</span>'; |
|
| 322 | + } |
|
| 323 | + } |
|
| 324 | + } |
|
| 325 | + } |
|
| 326 | + |
|
| 327 | + return $valeurs; |
|
| 328 | 328 | } |
| 329 | 329 | |
| 330 | 330 | /** |
@@ -336,51 +336,51 @@ discard block |
||
| 336 | 336 | * @return array |
| 337 | 337 | */ |
| 338 | 338 | function formulaire__charger($form, $args, $poste) { |
| 339 | - if ($charger_valeurs = charger_fonction('charger', "formulaires/$form", true)) { |
|
| 340 | - $valeurs = $charger_valeurs(...$args); |
|
| 341 | - } else { |
|
| 342 | - $valeurs = []; |
|
| 343 | - } |
|
| 344 | - |
|
| 345 | - $valeurs = pipeline( |
|
| 346 | - 'formulaire_charger', |
|
| 347 | - [ |
|
| 348 | - 'args' => ['form' => $form, 'args' => $args, 'je_suis_poste' => $poste], |
|
| 349 | - 'data' => $valeurs |
|
| 350 | - ] |
|
| 351 | - ); |
|
| 352 | - |
|
| 353 | - // prise en charge CVT multi etape |
|
| 354 | - if (is_array($valeurs) and isset($valeurs['_etapes'])) { |
|
| 355 | - include_spip('inc/cvt_multietapes'); |
|
| 356 | - $valeurs = cvtmulti_formulaire_charger_etapes( |
|
| 357 | - ['form' => $form, 'args' => $args, 'je_suis_poste' => $poste], |
|
| 358 | - $valeurs |
|
| 359 | - ); |
|
| 360 | - } |
|
| 361 | - |
|
| 362 | - // si $valeurs et false ou une chaine, pas de formulaire, donc pas de pipeline ! |
|
| 363 | - if (is_array($valeurs)) { |
|
| 364 | - if (!isset($valeurs['_pipelines'])) { |
|
| 365 | - $valeurs['_pipelines'] = []; |
|
| 366 | - } |
|
| 367 | - // l'ancien argument _pipeline devient maintenant _pipelines |
|
| 368 | - // reinjectons le vieux _pipeline au debut de _pipelines |
|
| 369 | - if (isset($valeurs['_pipeline'])) { |
|
| 370 | - $pipe = is_array($valeurs['_pipeline']) ? reset($valeurs['_pipeline']) : $valeurs['_pipeline']; |
|
| 371 | - $args = is_array($valeurs['_pipeline']) ? end($valeurs['_pipeline']) : []; |
|
| 372 | - |
|
| 373 | - $pipelines = [$pipe => $args]; |
|
| 374 | - $valeurs['_pipelines'] = array_merge($pipelines, $valeurs['_pipelines']); |
|
| 375 | - } |
|
| 376 | - |
|
| 377 | - // et enfin, ajoutons systematiquement un pipeline sur le squelette du formulaire |
|
| 378 | - // qui constitue le cas le plus courant d'utilisation du pipeline recuperer_fond |
|
| 379 | - // (performance, cela evite de s'injecter dans recuperer_fond utilise pour *tous* les squelettes) |
|
| 380 | - $valeurs['_pipelines']['formulaire_fond'] = ['form' => $form, 'args' => $args, 'je_suis_poste' => $poste]; |
|
| 381 | - } |
|
| 382 | - |
|
| 383 | - return $valeurs; |
|
| 339 | + if ($charger_valeurs = charger_fonction('charger', "formulaires/$form", true)) { |
|
| 340 | + $valeurs = $charger_valeurs(...$args); |
|
| 341 | + } else { |
|
| 342 | + $valeurs = []; |
|
| 343 | + } |
|
| 344 | + |
|
| 345 | + $valeurs = pipeline( |
|
| 346 | + 'formulaire_charger', |
|
| 347 | + [ |
|
| 348 | + 'args' => ['form' => $form, 'args' => $args, 'je_suis_poste' => $poste], |
|
| 349 | + 'data' => $valeurs |
|
| 350 | + ] |
|
| 351 | + ); |
|
| 352 | + |
|
| 353 | + // prise en charge CVT multi etape |
|
| 354 | + if (is_array($valeurs) and isset($valeurs['_etapes'])) { |
|
| 355 | + include_spip('inc/cvt_multietapes'); |
|
| 356 | + $valeurs = cvtmulti_formulaire_charger_etapes( |
|
| 357 | + ['form' => $form, 'args' => $args, 'je_suis_poste' => $poste], |
|
| 358 | + $valeurs |
|
| 359 | + ); |
|
| 360 | + } |
|
| 361 | + |
|
| 362 | + // si $valeurs et false ou une chaine, pas de formulaire, donc pas de pipeline ! |
|
| 363 | + if (is_array($valeurs)) { |
|
| 364 | + if (!isset($valeurs['_pipelines'])) { |
|
| 365 | + $valeurs['_pipelines'] = []; |
|
| 366 | + } |
|
| 367 | + // l'ancien argument _pipeline devient maintenant _pipelines |
|
| 368 | + // reinjectons le vieux _pipeline au debut de _pipelines |
|
| 369 | + if (isset($valeurs['_pipeline'])) { |
|
| 370 | + $pipe = is_array($valeurs['_pipeline']) ? reset($valeurs['_pipeline']) : $valeurs['_pipeline']; |
|
| 371 | + $args = is_array($valeurs['_pipeline']) ? end($valeurs['_pipeline']) : []; |
|
| 372 | + |
|
| 373 | + $pipelines = [$pipe => $args]; |
|
| 374 | + $valeurs['_pipelines'] = array_merge($pipelines, $valeurs['_pipelines']); |
|
| 375 | + } |
|
| 376 | + |
|
| 377 | + // et enfin, ajoutons systematiquement un pipeline sur le squelette du formulaire |
|
| 378 | + // qui constitue le cas le plus courant d'utilisation du pipeline recuperer_fond |
|
| 379 | + // (performance, cela evite de s'injecter dans recuperer_fond utilise pour *tous* les squelettes) |
|
| 380 | + $valeurs['_pipelines']['formulaire_fond'] = ['form' => $form, 'args' => $args, 'je_suis_poste' => $poste]; |
|
| 381 | + } |
|
| 382 | + |
|
| 383 | + return $valeurs; |
|
| 384 | 384 | } |
| 385 | 385 | |
| 386 | 386 | /** |
@@ -399,9 +399,9 @@ discard block |
||
| 399 | 399 | * @return bool |
| 400 | 400 | */ |
| 401 | 401 | function formulaire__identifier($form, $args, $p) { |
| 402 | - if ($identifier_args = charger_fonction('identifier', "formulaires/$form", true)) { |
|
| 403 | - return $identifier_args(...$args) === $identifier_args(...$p); |
|
| 404 | - } |
|
| 402 | + if ($identifier_args = charger_fonction('identifier', "formulaires/$form", true)) { |
|
| 403 | + return $identifier_args(...$args) === $identifier_args(...$p); |
|
| 404 | + } |
|
| 405 | 405 | |
| 406 | - return $args === $p; |
|
| 406 | + return $args === $p; |
|
| 407 | 407 | } |