@@ -92,86 +92,86 @@ discard block |
||
| 92 | 92 | |
| 93 | 93 | // http://doc.spip.org/@spip_nfslock |
| 94 | 94 | function spip_nfslock($fichier,$max_age=0) { |
| 95 | - $tries = 0; |
|
| 95 | + $tries = 0; |
|
| 96 | 96 | |
| 97 | - if (!$max_age) $max_age = _DEFAULT_LOCKTIME; |
|
| 98 | - $lock_file = _DIR_TMP . _NAME_LOCK . "-" . substr(md5($fichier),0,8); |
|
| 97 | + if (!$max_age) $max_age = _DEFAULT_LOCKTIME; |
|
| 98 | + $lock_file = _DIR_TMP . _NAME_LOCK . "-" . substr(md5($fichier),0,8); |
|
| 99 | 99 | |
| 100 | 100 | |
| 101 | - /* |
|
| 101 | + /* |
|
| 102 | 102 | * 1. create a tmp file with a psuedo random file name. we also make |
| 103 | 103 | * tpath which is a buffer to store the full pathname of the tmp file. |
| 104 | 104 | */ |
| 105 | 105 | |
| 106 | - $id = creer_uniqid(); |
|
| 107 | - $tpath = _DIR_TMP."slock.$id"; |
|
| 108 | - $tmpfd = @fopen($tpath, 'w'); // hum, le 'x' necessite php4,3,2 ... |
|
| 109 | - if (!$tmpfd) { /* open failed */ |
|
| 110 | - @fclose($tmpfd); |
|
| 111 | - spip_unlink($tpath); |
|
| 112 | - return false; //NFSL_SYSF |
|
| 113 | - } |
|
| 106 | + $id = creer_uniqid(); |
|
| 107 | + $tpath = _DIR_TMP."slock.$id"; |
|
| 108 | + $tmpfd = @fopen($tpath, 'w'); // hum, le 'x' necessite php4,3,2 ... |
|
| 109 | + if (!$tmpfd) { /* open failed */ |
|
| 110 | + @fclose($tmpfd); |
|
| 111 | + spip_unlink($tpath); |
|
| 112 | + return false; //NFSL_SYSF |
|
| 113 | + } |
|
| 114 | 114 | |
| 115 | - /* |
|
| 115 | + /* |
|
| 116 | 116 | * 2. make fullpath, a buffer for the full pathname of the lock file. |
| 117 | 117 | * then start looping trying to lock it |
| 118 | 118 | */ |
| 119 | 119 | |
| 120 | - while ($tries < 10) { |
|
| 121 | - /* |
|
| 120 | + while ($tries < 10) { |
|
| 121 | + /* |
|
| 122 | 122 | * 3. link tmp file to lock file. if it goes, we win and we clean |
| 123 | 123 | * up and return the st_ctime of the lock file. |
| 124 | 124 | */ |
| 125 | 125 | |
| 126 | - if (link($tpath, $lock_file) == 1) { |
|
| 127 | - spip_unlink($tpath); /* got it! */ |
|
| 128 | - @fclose($tmpfd); |
|
| 129 | - if (($our_tmp = lstat($lock_file))==false) { /* stat failed... shouldn't happen */ |
|
| 130 | - spip_unlink($lock_file); |
|
| 131 | - return false; // (NFSL_SYSF); |
|
| 132 | - } |
|
| 133 | - return($our_tmp['ctime']); |
|
| 134 | - } |
|
| 126 | + if (link($tpath, $lock_file) == 1) { |
|
| 127 | + spip_unlink($tpath); /* got it! */ |
|
| 128 | + @fclose($tmpfd); |
|
| 129 | + if (($our_tmp = lstat($lock_file))==false) { /* stat failed... shouldn't happen */ |
|
| 130 | + spip_unlink($lock_file); |
|
| 131 | + return false; // (NFSL_SYSF); |
|
| 132 | + } |
|
| 133 | + return($our_tmp['ctime']); |
|
| 134 | + } |
|
| 135 | 135 | |
| 136 | - /* |
|
| 136 | + /* |
|
| 137 | 137 | * 4. the lock failed. check for a stale lock file, being mindful |
| 138 | 138 | * of NFS and the fact the time is set from the NFS server. we |
| 139 | 139 | * do a write on the tmp file to update its time to the server's |
| 140 | 140 | * idea of "now." |
| 141 | 141 | */ |
| 142 | 142 | |
| 143 | - $old_stat = lstat($lock_file); |
|
| 144 | - if (@fputs($tmpfd, "zz", 2)!=2 || !$our_tmp=fstat($tmpfd)) |
|
| 145 | - break; /* something bogus is going on */ |
|
| 143 | + $old_stat = lstat($lock_file); |
|
| 144 | + if (@fputs($tmpfd, "zz", 2)!=2 || !$our_tmp=fstat($tmpfd)) |
|
| 145 | + break; /* something bogus is going on */ |
|
| 146 | 146 | |
| 147 | 147 | |
| 148 | - if ($old_stat!=false && (($old_stat['ctime'] + $max_age) < $our_tmp['ctime'])) { |
|
| 149 | - spip_unlink($lock_file); /* break the stale lock */ |
|
| 150 | - $tries++; |
|
| 151 | - /* It is CRITICAL that we sleep after breaking |
|
| 148 | + if ($old_stat!=false && (($old_stat['ctime'] + $max_age) < $our_tmp['ctime'])) { |
|
| 149 | + spip_unlink($lock_file); /* break the stale lock */ |
|
| 150 | + $tries++; |
|
| 151 | + /* It is CRITICAL that we sleep after breaking |
|
| 152 | 152 | * the lock. Otherwise, we could race with |
| 153 | 153 | * another process and unlink it's newly- |
| 154 | 154 | * created file. |
| 155 | 155 | */ |
| 156 | - sleep(1+rand(0,4)); |
|
| 157 | - continue; |
|
| 158 | - } |
|
| 156 | + sleep(1+rand(0,4)); |
|
| 157 | + continue; |
|
| 158 | + } |
|
| 159 | 159 | |
| 160 | - /* |
|
| 160 | + /* |
|
| 161 | 161 | * 5. try again |
| 162 | 162 | */ |
| 163 | 163 | |
| 164 | 164 | $tries++; |
| 165 | - sleep(1+rand(0,4)); |
|
| 166 | - } |
|
| 165 | + sleep(1+rand(0,4)); |
|
| 166 | + } |
|
| 167 | 167 | |
| 168 | - /* |
|
| 168 | + /* |
|
| 169 | 169 | * 6. give up, failure. |
| 170 | 170 | */ |
| 171 | 171 | |
| 172 | - spip_unlink($tpath); |
|
| 173 | - @fclose($tmpfd); |
|
| 174 | - return false; //(NFSL_LOCKED); |
|
| 172 | + spip_unlink($tpath); |
|
| 173 | + @fclose($tmpfd); |
|
| 174 | + return false; //(NFSL_LOCKED); |
|
| 175 | 175 | } |
| 176 | 176 | |
| 177 | 177 | /* |
@@ -212,63 +212,63 @@ discard block |
||
| 212 | 212 | |
| 213 | 213 | // http://doc.spip.org/@spip_nfsunlock |
| 214 | 214 | function spip_nfsunlock($fichier, $birth, $max_age=0, $test = false) { |
| 215 | - $id = creer_uniqid(); |
|
| 216 | - if (!$max_age) $max_age = _DEFAULT_LOCKTIME; |
|
| 215 | + $id = creer_uniqid(); |
|
| 216 | + if (!$max_age) $max_age = _DEFAULT_LOCKTIME; |
|
| 217 | 217 | |
| 218 | - /* |
|
| 218 | + /* |
|
| 219 | 219 | * 1. Build a temp file and stat that to get an idea of what the server |
| 220 | 220 | * thinks the current time is (our_tmp.st_ctime).. |
| 221 | 221 | */ |
| 222 | 222 | |
| 223 | - $tpath = _DIR_TMP."stime.$id"; |
|
| 224 | - $tmpfd = @fopen($tpath,'w'); |
|
| 225 | - if ((!$tmpfd) |
|
| 223 | + $tpath = _DIR_TMP."stime.$id"; |
|
| 224 | + $tmpfd = @fopen($tpath,'w'); |
|
| 225 | + if ((!$tmpfd) |
|
| 226 | 226 | OR (@fputs($tmpfd, "zz", 2) != 2) |
| 227 | - OR !($our_tmp = fstat($tmpfd))) { |
|
| 228 | - /* The open failed, or we can't write the file, or we can't stat it */ |
|
| 229 | - @fclose($tmpfd); |
|
| 230 | - spip_unlink($tpath); |
|
| 231 | - return false; //(NFSL_SYSF); |
|
| 232 | - } |
|
| 227 | + OR !($our_tmp = fstat($tmpfd))) { |
|
| 228 | + /* The open failed, or we can't write the file, or we can't stat it */ |
|
| 229 | + @fclose($tmpfd); |
|
| 230 | + spip_unlink($tpath); |
|
| 231 | + return false; //(NFSL_SYSF); |
|
| 232 | + } |
|
| 233 | 233 | |
| 234 | - @fclose($tmpfd); /* We don't need this once we have our_tmp.st_ctime. */ |
|
| 235 | - spip_unlink($tpath); |
|
| 234 | + @fclose($tmpfd); /* We don't need this once we have our_tmp.st_ctime. */ |
|
| 235 | + spip_unlink($tpath); |
|
| 236 | 236 | |
| 237 | - /* |
|
| 237 | + /* |
|
| 238 | 238 | * 2. make fullpath, a buffer for the full pathname of the lock file |
| 239 | 239 | */ |
| 240 | 240 | |
| 241 | - $lock_file = _DIR_TMP . _NAME_LOCK . "-" . substr(md5($fichier),0,8); |
|
| 241 | + $lock_file = _DIR_TMP . _NAME_LOCK . "-" . substr(md5($fichier),0,8); |
|
| 242 | 242 | |
| 243 | - /* |
|
| 243 | + /* |
|
| 244 | 244 | * 3. If the ctime hasn't been modified, unlink the file and return. If the |
| 245 | 245 | * lock has expired, sleep the usual random interval before returning. |
| 246 | 246 | * If we didn't sleep, there could be a race if the caller immediately |
| 247 | 247 | * tries to relock the file. |
| 248 | 248 | */ |
| 249 | 249 | |
| 250 | - if ( ($old_stat=@lstat($lock_file)) /* stat succeeds so file is there */ |
|
| 251 | - && ($old_stat['ctime'] == $birth)) { /* hasn't been modified since birth */ |
|
| 252 | - if (!$test) |
|
| 253 | - spip_unlink($lock_file); /* so the lock is ours to remove */ |
|
| 250 | + if ( ($old_stat=@lstat($lock_file)) /* stat succeeds so file is there */ |
|
| 251 | + && ($old_stat['ctime'] == $birth)) { /* hasn't been modified since birth */ |
|
| 252 | + if (!$test) |
|
| 253 | + spip_unlink($lock_file); /* so the lock is ours to remove */ |
|
| 254 | 254 | if ($our_tmp['ctime'] >= $birth + $max_age){ /* the lock has expired */ |
| 255 | - if (!$test) return false; //(NFSL_LOST); |
|
| 256 | - sleep(1+(random(0,4))); /* so sleep a bit */ |
|
| 255 | + if (!$test) return false; //(NFSL_LOST); |
|
| 256 | + sleep(1+(random(0,4))); /* so sleep a bit */ |
|
| 257 | + } |
|
| 258 | + return true;//(NFSL_OK); /* success */ |
|
| 257 | 259 | } |
| 258 | - return true;//(NFSL_OK); /* success */ |
|
| 259 | - } |
|
| 260 | 260 | |
| 261 | - /* |
|
| 261 | + /* |
|
| 262 | 262 | * 4. Either ctime has been modified, or the entire lock file is missing. |
| 263 | 263 | * If the lock should still be ours, based on the ctime of the temp |
| 264 | 264 | * file, return with NFSL_STOLEN. If not, then our lock is expired and |
| 265 | 265 | * someone else has grabbed the file, so return NFSL_LOST. |
| 266 | 266 | */ |
| 267 | 267 | |
| 268 | - if ($our_tmp['ctime'] < $birth + $max_age) /* lock was stolen */ |
|
| 269 | - return false; //(NFSL_STOLEN); |
|
| 268 | + if ($our_tmp['ctime'] < $birth + $max_age) /* lock was stolen */ |
|
| 269 | + return false; //(NFSL_STOLEN); |
|
| 270 | 270 | |
| 271 | - return false; //(NFSL_LOST); /* The lock must have expired first. */ |
|
| 271 | + return false; //(NFSL_LOST); /* The lock must have expired first. */ |
|
| 272 | 272 | } |
| 273 | 273 | |
| 274 | 274 | |
@@ -291,7 +291,7 @@ discard block |
||
| 291 | 291 | |
| 292 | 292 | // http://doc.spip.org/@spip_nfslock_test |
| 293 | 293 | function spip_nfslock_test($fichier, $birth, $max_age=0) { |
| 294 | - return spip_nfsunlock($fichier, $birth, $max_age, true); |
|
| 294 | + return spip_nfsunlock($fichier, $birth, $max_age, true); |
|
| 295 | 295 | } |
| 296 | 296 | |
| 297 | 297 | ?> |
@@ -87,15 +87,15 @@ discard block |
||
| 87 | 87 | if (!defined('_ECRIRE_INC_VERSION')) return; |
| 88 | 88 | |
| 89 | 89 | include_spip('inc/acces'); |
| 90 | -define('_DEFAULT_LOCKTIME',60); |
|
| 91 | -define('_NAME_LOCK','spip_nfs_lock'); |
|
| 90 | +define('_DEFAULT_LOCKTIME', 60); |
|
| 91 | +define('_NAME_LOCK', 'spip_nfs_lock'); |
|
| 92 | 92 | |
| 93 | 93 | // http://doc.spip.org/@spip_nfslock |
| 94 | -function spip_nfslock($fichier,$max_age=0) { |
|
| 94 | +function spip_nfslock($fichier, $max_age = 0) { |
|
| 95 | 95 | $tries = 0; |
| 96 | 96 | |
| 97 | 97 | if (!$max_age) $max_age = _DEFAULT_LOCKTIME; |
| 98 | - $lock_file = _DIR_TMP . _NAME_LOCK . "-" . substr(md5($fichier),0,8); |
|
| 98 | + $lock_file = _DIR_TMP._NAME_LOCK."-".substr(md5($fichier), 0, 8); |
|
| 99 | 99 | |
| 100 | 100 | |
| 101 | 101 | /* |
@@ -126,7 +126,7 @@ discard block |
||
| 126 | 126 | if (link($tpath, $lock_file) == 1) { |
| 127 | 127 | spip_unlink($tpath); /* got it! */ |
| 128 | 128 | @fclose($tmpfd); |
| 129 | - if (($our_tmp = lstat($lock_file))==false) { /* stat failed... shouldn't happen */ |
|
| 129 | + if (($our_tmp = lstat($lock_file)) == false) { /* stat failed... shouldn't happen */ |
|
| 130 | 130 | spip_unlink($lock_file); |
| 131 | 131 | return false; // (NFSL_SYSF); |
| 132 | 132 | } |
@@ -141,11 +141,11 @@ discard block |
||
| 141 | 141 | */ |
| 142 | 142 | |
| 143 | 143 | $old_stat = lstat($lock_file); |
| 144 | - if (@fputs($tmpfd, "zz", 2)!=2 || !$our_tmp=fstat($tmpfd)) |
|
| 144 | + if (@fputs($tmpfd, "zz", 2) != 2 || !$our_tmp = fstat($tmpfd)) |
|
| 145 | 145 | break; /* something bogus is going on */ |
| 146 | 146 | |
| 147 | 147 | |
| 148 | - if ($old_stat!=false && (($old_stat['ctime'] + $max_age) < $our_tmp['ctime'])) { |
|
| 148 | + if ($old_stat != false && (($old_stat['ctime'] + $max_age) < $our_tmp['ctime'])) { |
|
| 149 | 149 | spip_unlink($lock_file); /* break the stale lock */ |
| 150 | 150 | $tries++; |
| 151 | 151 | /* It is CRITICAL that we sleep after breaking |
@@ -153,7 +153,7 @@ discard block |
||
| 153 | 153 | * another process and unlink it's newly- |
| 154 | 154 | * created file. |
| 155 | 155 | */ |
| 156 | - sleep(1+rand(0,4)); |
|
| 156 | + sleep(1 + rand(0, 4)); |
|
| 157 | 157 | continue; |
| 158 | 158 | } |
| 159 | 159 | |
@@ -162,7 +162,7 @@ discard block |
||
| 162 | 162 | */ |
| 163 | 163 | |
| 164 | 164 | $tries++; |
| 165 | - sleep(1+rand(0,4)); |
|
| 165 | + sleep(1 + rand(0, 4)); |
|
| 166 | 166 | } |
| 167 | 167 | |
| 168 | 168 | /* |
@@ -211,7 +211,7 @@ discard block |
||
| 211 | 211 | */ |
| 212 | 212 | |
| 213 | 213 | // http://doc.spip.org/@spip_nfsunlock |
| 214 | -function spip_nfsunlock($fichier, $birth, $max_age=0, $test = false) { |
|
| 214 | +function spip_nfsunlock($fichier, $birth, $max_age = 0, $test = false) { |
|
| 215 | 215 | $id = creer_uniqid(); |
| 216 | 216 | if (!$max_age) $max_age = _DEFAULT_LOCKTIME; |
| 217 | 217 | |
@@ -221,7 +221,7 @@ discard block |
||
| 221 | 221 | */ |
| 222 | 222 | |
| 223 | 223 | $tpath = _DIR_TMP."stime.$id"; |
| 224 | - $tmpfd = @fopen($tpath,'w'); |
|
| 224 | + $tmpfd = @fopen($tpath, 'w'); |
|
| 225 | 225 | if ((!$tmpfd) |
| 226 | 226 | OR (@fputs($tmpfd, "zz", 2) != 2) |
| 227 | 227 | OR !($our_tmp = fstat($tmpfd))) { |
@@ -231,14 +231,14 @@ discard block |
||
| 231 | 231 | return false; //(NFSL_SYSF); |
| 232 | 232 | } |
| 233 | 233 | |
| 234 | - @fclose($tmpfd); /* We don't need this once we have our_tmp.st_ctime. */ |
|
| 234 | + @fclose($tmpfd); /* We don't need this once we have our_tmp.st_ctime. */ |
|
| 235 | 235 | spip_unlink($tpath); |
| 236 | 236 | |
| 237 | 237 | /* |
| 238 | 238 | * 2. make fullpath, a buffer for the full pathname of the lock file |
| 239 | 239 | */ |
| 240 | 240 | |
| 241 | - $lock_file = _DIR_TMP . _NAME_LOCK . "-" . substr(md5($fichier),0,8); |
|
| 241 | + $lock_file = _DIR_TMP._NAME_LOCK."-".substr(md5($fichier), 0, 8); |
|
| 242 | 242 | |
| 243 | 243 | /* |
| 244 | 244 | * 3. If the ctime hasn't been modified, unlink the file and return. If the |
@@ -247,15 +247,15 @@ discard block |
||
| 247 | 247 | * tries to relock the file. |
| 248 | 248 | */ |
| 249 | 249 | |
| 250 | - if ( ($old_stat=@lstat($lock_file)) /* stat succeeds so file is there */ |
|
| 250 | + if (($old_stat = @lstat($lock_file)) /* stat succeeds so file is there */ |
|
| 251 | 251 | && ($old_stat['ctime'] == $birth)) { /* hasn't been modified since birth */ |
| 252 | 252 | if (!$test) |
| 253 | - spip_unlink($lock_file); /* so the lock is ours to remove */ |
|
| 254 | - if ($our_tmp['ctime'] >= $birth + $max_age){ /* the lock has expired */ |
|
| 253 | + spip_unlink($lock_file); /* so the lock is ours to remove */ |
|
| 254 | + if ($our_tmp['ctime'] >= $birth + $max_age) { /* the lock has expired */ |
|
| 255 | 255 | if (!$test) return false; //(NFSL_LOST); |
| 256 | - sleep(1+(random(0,4))); /* so sleep a bit */ |
|
| 256 | + sleep(1 + (random(0, 4))); /* so sleep a bit */ |
|
| 257 | 257 | } |
| 258 | - return true;//(NFSL_OK); /* success */ |
|
| 258 | + return true; //(NFSL_OK); /* success */ |
|
| 259 | 259 | } |
| 260 | 260 | |
| 261 | 261 | /* |
@@ -290,7 +290,7 @@ discard block |
||
| 290 | 290 | */ |
| 291 | 291 | |
| 292 | 292 | // http://doc.spip.org/@spip_nfslock_test |
| 293 | -function spip_nfslock_test($fichier, $birth, $max_age=0) { |
|
| 293 | +function spip_nfslock_test($fichier, $birth, $max_age = 0) { |
|
| 294 | 294 | return spip_nfsunlock($fichier, $birth, $max_age, true); |
| 295 | 295 | } |
| 296 | 296 | |
@@ -84,7 +84,9 @@ discard block |
||
| 84 | 84 | * |
| 85 | 85 | */ |
| 86 | 86 | |
| 87 | -if (!defined('_ECRIRE_INC_VERSION')) return; |
|
| 87 | +if (!defined('_ECRIRE_INC_VERSION')) { |
|
| 88 | + return; |
|
| 89 | +} |
|
| 88 | 90 | |
| 89 | 91 | include_spip('inc/acces'); |
| 90 | 92 | define('_DEFAULT_LOCKTIME',60); |
@@ -94,7 +96,9 @@ discard block |
||
| 94 | 96 | function spip_nfslock($fichier,$max_age=0) { |
| 95 | 97 | $tries = 0; |
| 96 | 98 | |
| 97 | - if (!$max_age) $max_age = _DEFAULT_LOCKTIME; |
|
| 99 | + if (!$max_age) { |
|
| 100 | + $max_age = _DEFAULT_LOCKTIME; |
|
| 101 | + } |
|
| 98 | 102 | $lock_file = _DIR_TMP . _NAME_LOCK . "-" . substr(md5($fichier),0,8); |
| 99 | 103 | |
| 100 | 104 | |
@@ -141,8 +145,10 @@ discard block |
||
| 141 | 145 | */ |
| 142 | 146 | |
| 143 | 147 | $old_stat = lstat($lock_file); |
| 144 | - if (@fputs($tmpfd, "zz", 2)!=2 || !$our_tmp=fstat($tmpfd)) |
|
| 145 | - break; /* something bogus is going on */ |
|
| 148 | + if (@fputs($tmpfd, "zz", 2)!=2 || !$our_tmp=fstat($tmpfd)) { |
|
| 149 | + break; |
|
| 150 | + } |
|
| 151 | + /* something bogus is going on */ |
|
| 146 | 152 | |
| 147 | 153 | |
| 148 | 154 | if ($old_stat!=false && (($old_stat['ctime'] + $max_age) < $our_tmp['ctime'])) { |
@@ -213,7 +219,9 @@ discard block |
||
| 213 | 219 | // http://doc.spip.org/@spip_nfsunlock |
| 214 | 220 | function spip_nfsunlock($fichier, $birth, $max_age=0, $test = false) { |
| 215 | 221 | $id = creer_uniqid(); |
| 216 | - if (!$max_age) $max_age = _DEFAULT_LOCKTIME; |
|
| 222 | + if (!$max_age) { |
|
| 223 | + $max_age = _DEFAULT_LOCKTIME; |
|
| 224 | + } |
|
| 217 | 225 | |
| 218 | 226 | /* |
| 219 | 227 | * 1. Build a temp file and stat that to get an idea of what the server |
@@ -249,10 +257,15 @@ discard block |
||
| 249 | 257 | |
| 250 | 258 | if ( ($old_stat=@lstat($lock_file)) /* stat succeeds so file is there */ |
| 251 | 259 | && ($old_stat['ctime'] == $birth)) { /* hasn't been modified since birth */ |
| 252 | - if (!$test) |
|
| 253 | - spip_unlink($lock_file); /* so the lock is ours to remove */ |
|
| 260 | + if (!$test) { |
|
| 261 | + spip_unlink($lock_file); |
|
| 262 | + } |
|
| 263 | + /* so the lock is ours to remove */ |
|
| 254 | 264 | if ($our_tmp['ctime'] >= $birth + $max_age){ /* the lock has expired */ |
| 255 | - if (!$test) return false; //(NFSL_LOST); |
|
| 265 | + if (!$test) { |
|
| 266 | + return false; |
|
| 267 | + } |
|
| 268 | + //(NFSL_LOST); |
|
| 256 | 269 | sleep(1+(random(0,4))); /* so sleep a bit */ |
| 257 | 270 | } |
| 258 | 271 | return true;//(NFSL_OK); /* success */ |
@@ -265,8 +278,11 @@ discard block |
||
| 265 | 278 | * someone else has grabbed the file, so return NFSL_LOST. |
| 266 | 279 | */ |
| 267 | 280 | |
| 268 | - if ($our_tmp['ctime'] < $birth + $max_age) /* lock was stolen */ |
|
| 269 | - return false; //(NFSL_STOLEN); |
|
| 281 | + if ($our_tmp['ctime'] < $birth + $max_age) { |
|
| 282 | + /* lock was stolen */ |
|
| 283 | + return false; |
|
| 284 | + } |
|
| 285 | + //(NFSL_STOLEN); |
|
| 270 | 286 | |
| 271 | 287 | return false; //(NFSL_LOST); /* The lock must have expired first. */ |
| 272 | 288 | } |
@@ -16,95 +16,95 @@ |
||
| 16 | 16 | |
| 17 | 17 | // http://doc.spip.org/@inc_plonger_dist |
| 18 | 18 | function inc_plonger_dist($id_rubrique, $idom="", $list=array(), $col = 1, $exclu=0, $do='aff') { |
| 19 | - global $spip_lang_left; |
|
| 19 | + global $spip_lang_left; |
|
| 20 | 20 | |
| 21 | - if ($list) $id_rubrique = $list[$col-1]; |
|
| 21 | + if ($list) $id_rubrique = $list[$col-1]; |
|
| 22 | 22 | |
| 23 | - $ret = ''; |
|
| 23 | + $ret = ''; |
|
| 24 | 24 | |
| 25 | - # recherche les filles et petites-filles de la rubrique donnee |
|
| 26 | - # en excluant une eventuelle rubrique interdite (par exemple, lorsqu'on |
|
| 27 | - # deplace une rubrique, on peut la deplacer partout a partir de la |
|
| 28 | - # racine... sauf vers elle-meme ou sa propre branche) |
|
| 29 | - $ordre = array(); |
|
| 30 | - $rub = array(); |
|
| 25 | + # recherche les filles et petites-filles de la rubrique donnee |
|
| 26 | + # en excluant une eventuelle rubrique interdite (par exemple, lorsqu'on |
|
| 27 | + # deplace une rubrique, on peut la deplacer partout a partir de la |
|
| 28 | + # racine... sauf vers elle-meme ou sa propre branche) |
|
| 29 | + $ordre = array(); |
|
| 30 | + $rub = array(); |
|
| 31 | 31 | |
| 32 | - $res = sql_select("rub1.id_rubrique, rub1.titre, rub1.id_parent, rub1.lang, rub1.langue_choisie, rub2.id_rubrique AS id_enfant", |
|
| 33 | - "spip_rubriques AS rub1 LEFT JOIN spip_rubriques AS rub2 ON (rub1.id_rubrique = rub2.id_parent)", |
|
| 34 | - "rub1.id_parent = ".sql_quote($id_rubrique)." |
|
| 32 | + $res = sql_select("rub1.id_rubrique, rub1.titre, rub1.id_parent, rub1.lang, rub1.langue_choisie, rub2.id_rubrique AS id_enfant", |
|
| 33 | + "spip_rubriques AS rub1 LEFT JOIN spip_rubriques AS rub2 ON (rub1.id_rubrique = rub2.id_parent)", |
|
| 34 | + "rub1.id_parent = ".sql_quote($id_rubrique)." |
|
| 35 | 35 | AND rub1.id_rubrique!=".sql_quote($exclu)." |
| 36 | 36 | AND (rub2.id_rubrique IS NULL OR rub2.id_rubrique!=".sql_quote($exclu).")", "", "0+rub1.titre,rub1.titre"); |
| 37 | 37 | |
| 38 | - while ($row = sql_fetch($res)) { |
|
| 39 | - if (autoriser('voir','rubrique',$row['id_rubrique'])){ |
|
| 40 | - $rub[$row['id_rubrique']]['enfants'] = $row['id_enfant']; |
|
| 41 | - if ($row['id_parent'] == $id_rubrique) { |
|
| 42 | - $t = trim(typo(supprimer_numero($row['titre']))); |
|
| 43 | - if ($row['langue_choisie'] != 'oui') |
|
| 44 | - $t .= ' <small title="' |
|
| 45 | - .traduire_nom_langue($row['lang']) |
|
| 46 | - .'">[' . $row['lang'] . ']</small>'; |
|
| 47 | - $ordre[$row['id_rubrique']] = $t; |
|
| 48 | - } |
|
| 49 | - } |
|
| 50 | - } |
|
| 51 | - $next = isset($list[$col]) ? $list[$col] : 0; |
|
| 52 | - if ($ordre) { |
|
| 53 | - $rec = generer_url_ecrire('plonger',"rac=$idom&exclus=$exclu&do=$do&col=".($col+1)); |
|
| 54 | - $info = generer_url_ecrire('informer', "type=rubrique&rac=$idom&do=$do&id="); |
|
| 55 | - $args = "'$idom',this,$col,'$spip_lang_left','$info',event"; |
|
| 56 | - while (list($id, $titrebrut) = each($ordre)) { |
|
| 38 | + while ($row = sql_fetch($res)) { |
|
| 39 | + if (autoriser('voir','rubrique',$row['id_rubrique'])){ |
|
| 40 | + $rub[$row['id_rubrique']]['enfants'] = $row['id_enfant']; |
|
| 41 | + if ($row['id_parent'] == $id_rubrique) { |
|
| 42 | + $t = trim(typo(supprimer_numero($row['titre']))); |
|
| 43 | + if ($row['langue_choisie'] != 'oui') |
|
| 44 | + $t .= ' <small title="' |
|
| 45 | + .traduire_nom_langue($row['lang']) |
|
| 46 | + .'">[' . $row['lang'] . ']</small>'; |
|
| 47 | + $ordre[$row['id_rubrique']] = $t; |
|
| 48 | + } |
|
| 49 | + } |
|
| 50 | + } |
|
| 51 | + $next = isset($list[$col]) ? $list[$col] : 0; |
|
| 52 | + if ($ordre) { |
|
| 53 | + $rec = generer_url_ecrire('plonger',"rac=$idom&exclus=$exclu&do=$do&col=".($col+1)); |
|
| 54 | + $info = generer_url_ecrire('informer', "type=rubrique&rac=$idom&do=$do&id="); |
|
| 55 | + $args = "'$idom',this,$col,'$spip_lang_left','$info',event"; |
|
| 56 | + while (list($id, $titrebrut) = each($ordre)) { |
|
| 57 | 57 | |
| 58 | - $titre = supprimer_numero($titrebrut); |
|
| 58 | + $titre = supprimer_numero($titrebrut); |
|
| 59 | 59 | |
| 60 | - $classe1 = $id_rubrique ? 'petite-rubrique' : "petit-secteur"; |
|
| 61 | - if (isset($rub[$id]["enfants"])) { |
|
| 62 | - $classe2 = " class='rub-ouverte'"; |
|
| 63 | - $url = "\nhref='$rec&id=$id'" ; |
|
| 64 | - } else { $url = $classe2 = '' ; } |
|
| 60 | + $classe1 = $id_rubrique ? 'petite-rubrique' : "petit-secteur"; |
|
| 61 | + if (isset($rub[$id]["enfants"])) { |
|
| 62 | + $classe2 = " class='rub-ouverte'"; |
|
| 63 | + $url = "\nhref='$rec&id=$id'" ; |
|
| 64 | + } else { $url = $classe2 = '' ; } |
|
| 65 | 65 | |
| 66 | - $js_func = $do . '_selection_titre'; |
|
| 67 | - $click = "\nonclick=\"changerhighlight(this.parentNode.parentNode.parentNode);\nreturn " |
|
| 68 | - . (!is_array($list) ? ' false' |
|
| 69 | - : "aff_selection_provisoire($id,$args)") |
|
| 66 | + $js_func = $do . '_selection_titre'; |
|
| 67 | + $click = "\nonclick=\"changerhighlight(this.parentNode.parentNode.parentNode);\nreturn " |
|
| 68 | + . (!is_array($list) ? ' false' |
|
| 69 | + : "aff_selection_provisoire($id,$args)") |
|
| 70 | 70 | # ce lien provoque la selection (directe) de la rubrique cliquee |
| 71 | 71 | # et l'affichage de son titre dans le bandeau |
| 72 | - . "\"\nondblclick=\"" |
|
| 73 | - . "$js_func(this." |
|
| 74 | - . "firstChild.nodeValue," |
|
| 75 | - . $id |
|
| 76 | - . ",'selection_rubrique','id_parent');" |
|
| 77 | - . "\nreturn aff_selection_provisoire($id,$args);" |
|
| 78 | - . "\""; |
|
| 72 | + . "\"\nondblclick=\"" |
|
| 73 | + . "$js_func(this." |
|
| 74 | + . "firstChild.nodeValue," |
|
| 75 | + . $id |
|
| 76 | + . ",'selection_rubrique','id_parent');" |
|
| 77 | + . "\nreturn aff_selection_provisoire($id,$args);" |
|
| 78 | + . "\""; |
|
| 79 | 79 | |
| 80 | - $ret .= "<div class='" |
|
| 81 | - . (($id == $next) ? "item on" : "item") |
|
| 82 | - . "'><div class='" |
|
| 83 | - . $classe1 |
|
| 84 | - . "'><div$classe2><a" |
|
| 85 | - . $url |
|
| 86 | - . $click |
|
| 87 | - . ">" |
|
| 88 | - . $titre |
|
| 89 | - . "</a></div></div></div>"; |
|
| 90 | - } |
|
| 91 | - } |
|
| 80 | + $ret .= "<div class='" |
|
| 81 | + . (($id == $next) ? "item on" : "item") |
|
| 82 | + . "'><div class='" |
|
| 83 | + . $classe1 |
|
| 84 | + . "'><div$classe2><a" |
|
| 85 | + . $url |
|
| 86 | + . $click |
|
| 87 | + . ">" |
|
| 88 | + . $titre |
|
| 89 | + . "</a></div></div></div>"; |
|
| 90 | + } |
|
| 91 | + } |
|
| 92 | 92 | |
| 93 | - $idom2 = $idom . "_col_".($col+1); |
|
| 94 | - $left = ($col*150); |
|
| 93 | + $idom2 = $idom . "_col_".($col+1); |
|
| 94 | + $left = ($col*150); |
|
| 95 | 95 | |
| 96 | - return http_img_pack("searching.gif", "*", "style='visibility: hidden; position: absolute; $spip_lang_left: " |
|
| 97 | - . ($left-30) |
|
| 98 | - . "px; top: 2px; z-index: 2;' id='img_$idom2'") |
|
| 99 | - . "<div style='width: 150px; height: 100%; overflow: auto; position: absolute; top: 0px; $spip_lang_left: " |
|
| 100 | - .($left-150) |
|
| 101 | - ."px;'>" |
|
| 102 | - . $ret |
|
| 103 | - . "\n</div>\n<div id='$idom2'>" |
|
| 104 | - . ($next |
|
| 105 | - ? inc_plonger_dist($id_rubrique, $idom, $list, $col+1, $exclu) |
|
| 106 | - : "") |
|
| 107 | - . "\n</div>"; |
|
| 96 | + return http_img_pack("searching.gif", "*", "style='visibility: hidden; position: absolute; $spip_lang_left: " |
|
| 97 | + . ($left-30) |
|
| 98 | + . "px; top: 2px; z-index: 2;' id='img_$idom2'") |
|
| 99 | + . "<div style='width: 150px; height: 100%; overflow: auto; position: absolute; top: 0px; $spip_lang_left: " |
|
| 100 | + .($left-150) |
|
| 101 | + ."px;'>" |
|
| 102 | + . $ret |
|
| 103 | + . "\n</div>\n<div id='$idom2'>" |
|
| 104 | + . ($next |
|
| 105 | + ? inc_plonger_dist($id_rubrique, $idom, $list, $col+1, $exclu) |
|
| 106 | + : "") |
|
| 107 | + . "\n</div>"; |
|
| 108 | 108 | } |
| 109 | 109 | |
| 110 | 110 | ?> |
@@ -15,10 +15,10 @@ discard block |
||
| 15 | 15 | include_spip('inc/texte'); |
| 16 | 16 | |
| 17 | 17 | // http://doc.spip.org/@inc_plonger_dist |
| 18 | -function inc_plonger_dist($id_rubrique, $idom="", $list=array(), $col = 1, $exclu=0, $do='aff') { |
|
| 18 | +function inc_plonger_dist($id_rubrique, $idom = "", $list = array(), $col = 1, $exclu = 0, $do = 'aff') { |
|
| 19 | 19 | global $spip_lang_left; |
| 20 | 20 | |
| 21 | - if ($list) $id_rubrique = $list[$col-1]; |
|
| 21 | + if ($list) $id_rubrique = $list[$col - 1]; |
|
| 22 | 22 | |
| 23 | 23 | $ret = ''; |
| 24 | 24 | |
@@ -33,24 +33,24 @@ discard block |
||
| 33 | 33 | "spip_rubriques AS rub1 LEFT JOIN spip_rubriques AS rub2 ON (rub1.id_rubrique = rub2.id_parent)", |
| 34 | 34 | "rub1.id_parent = ".sql_quote($id_rubrique)." |
| 35 | 35 | AND rub1.id_rubrique!=".sql_quote($exclu)." |
| 36 | - AND (rub2.id_rubrique IS NULL OR rub2.id_rubrique!=".sql_quote($exclu).")", "", "0+rub1.titre,rub1.titre"); |
|
| 36 | + AND (rub2.id_rubrique IS NULL OR rub2.id_rubrique!=".sql_quote($exclu).")", "", "0+rub1.titre,rub1.titre"); |
|
| 37 | 37 | |
| 38 | 38 | while ($row = sql_fetch($res)) { |
| 39 | - if (autoriser('voir','rubrique',$row['id_rubrique'])){ |
|
| 39 | + if (autoriser('voir', 'rubrique', $row['id_rubrique'])) { |
|
| 40 | 40 | $rub[$row['id_rubrique']]['enfants'] = $row['id_enfant']; |
| 41 | 41 | if ($row['id_parent'] == $id_rubrique) { |
| 42 | 42 | $t = trim(typo(supprimer_numero($row['titre']))); |
| 43 | 43 | if ($row['langue_choisie'] != 'oui') |
| 44 | 44 | $t .= ' <small title="' |
| 45 | 45 | .traduire_nom_langue($row['lang']) |
| 46 | - .'">[' . $row['lang'] . ']</small>'; |
|
| 46 | + .'">['.$row['lang'].']</small>'; |
|
| 47 | 47 | $ordre[$row['id_rubrique']] = $t; |
| 48 | 48 | } |
| 49 | 49 | } |
| 50 | 50 | } |
| 51 | 51 | $next = isset($list[$col]) ? $list[$col] : 0; |
| 52 | 52 | if ($ordre) { |
| 53 | - $rec = generer_url_ecrire('plonger',"rac=$idom&exclus=$exclu&do=$do&col=".($col+1)); |
|
| 53 | + $rec = generer_url_ecrire('plonger', "rac=$idom&exclus=$exclu&do=$do&col=".($col + 1)); |
|
| 54 | 54 | $info = generer_url_ecrire('informer', "type=rubrique&rac=$idom&do=$do&id="); |
| 55 | 55 | $args = "'$idom',this,$col,'$spip_lang_left','$info',event"; |
| 56 | 56 | while (list($id, $titrebrut) = each($ordre)) { |
@@ -60,10 +60,10 @@ discard block |
||
| 60 | 60 | $classe1 = $id_rubrique ? 'petite-rubrique' : "petit-secteur"; |
| 61 | 61 | if (isset($rub[$id]["enfants"])) { |
| 62 | 62 | $classe2 = " class='rub-ouverte'"; |
| 63 | - $url = "\nhref='$rec&id=$id'" ; |
|
| 64 | - } else { $url = $classe2 = '' ; } |
|
| 63 | + $url = "\nhref='$rec&id=$id'"; |
|
| 64 | + } else { $url = $classe2 = ''; } |
|
| 65 | 65 | |
| 66 | - $js_func = $do . '_selection_titre'; |
|
| 66 | + $js_func = $do.'_selection_titre'; |
|
| 67 | 67 | $click = "\nonclick=\"changerhighlight(this.parentNode.parentNode.parentNode);\nreturn " |
| 68 | 68 | . (!is_array($list) ? ' false' |
| 69 | 69 | : "aff_selection_provisoire($id,$args)") |
@@ -90,19 +90,19 @@ discard block |
||
| 90 | 90 | } |
| 91 | 91 | } |
| 92 | 92 | |
| 93 | - $idom2 = $idom . "_col_".($col+1); |
|
| 94 | - $left = ($col*150); |
|
| 93 | + $idom2 = $idom."_col_".($col + 1); |
|
| 94 | + $left = ($col * 150); |
|
| 95 | 95 | |
| 96 | 96 | return http_img_pack("searching.gif", "*", "style='visibility: hidden; position: absolute; $spip_lang_left: " |
| 97 | - . ($left-30) |
|
| 97 | + . ($left - 30) |
|
| 98 | 98 | . "px; top: 2px; z-index: 2;' id='img_$idom2'") |
| 99 | 99 | . "<div style='width: 150px; height: 100%; overflow: auto; position: absolute; top: 0px; $spip_lang_left: " |
| 100 | - .($left-150) |
|
| 100 | + .($left - 150) |
|
| 101 | 101 | ."px;'>" |
| 102 | 102 | . $ret |
| 103 | 103 | . "\n</div>\n<div id='$idom2'>" |
| 104 | 104 | . ($next |
| 105 | - ? inc_plonger_dist($id_rubrique, $idom, $list, $col+1, $exclu) |
|
| 105 | + ? inc_plonger_dist($id_rubrique, $idom, $list, $col + 1, $exclu) |
|
| 106 | 106 | : "") |
| 107 | 107 | . "\n</div>"; |
| 108 | 108 | } |
@@ -10,7 +10,9 @@ discard block |
||
| 10 | 10 | * Pour plus de details voir le fichier COPYING.txt ou l'aide en ligne. * |
| 11 | 11 | \***************************************************************************/ |
| 12 | 12 | |
| 13 | -if (!defined('_ECRIRE_INC_VERSION')) return; |
|
| 13 | +if (!defined('_ECRIRE_INC_VERSION')) { |
|
| 14 | + return; |
|
| 15 | +} |
|
| 14 | 16 | |
| 15 | 17 | include_spip('inc/texte'); |
| 16 | 18 | |
@@ -18,7 +20,9 @@ discard block |
||
| 18 | 20 | function inc_plonger_dist($id_rubrique, $idom="", $list=array(), $col = 1, $exclu=0, $do='aff') { |
| 19 | 21 | global $spip_lang_left; |
| 20 | 22 | |
| 21 | - if ($list) $id_rubrique = $list[$col-1]; |
|
| 23 | + if ($list) { |
|
| 24 | + $id_rubrique = $list[$col-1]; |
|
| 25 | + } |
|
| 22 | 26 | |
| 23 | 27 | $ret = ''; |
| 24 | 28 | |
@@ -40,10 +44,11 @@ discard block |
||
| 40 | 44 | $rub[$row['id_rubrique']]['enfants'] = $row['id_enfant']; |
| 41 | 45 | if ($row['id_parent'] == $id_rubrique) { |
| 42 | 46 | $t = trim(typo(supprimer_numero($row['titre']))); |
| 43 | - if ($row['langue_choisie'] != 'oui') |
|
| 44 | - $t .= ' <small title="' |
|
| 47 | + if ($row['langue_choisie'] != 'oui') { |
|
| 48 | + $t .= ' <small title="' |
|
| 45 | 49 | .traduire_nom_langue($row['lang']) |
| 46 | 50 | .'">[' . $row['lang'] . ']</small>'; |
| 51 | + } |
|
| 47 | 52 | $ordre[$row['id_rubrique']] = $t; |
| 48 | 53 | } |
| 49 | 54 | } |
@@ -16,10 +16,10 @@ |
||
| 16 | 16 | |
| 17 | 17 | // http://doc.spip.org/@inc_iconifier_dist |
| 18 | 18 | function inc_iconifier_dist($objet, $id, $script, $visible=false, $flag_modif=true) { |
| 19 | - // compat avec anciens appels |
|
| 20 | - $objet = objet_type($objet); |
|
| 19 | + // compat avec anciens appels |
|
| 20 | + $objet = objet_type($objet); |
|
| 21 | 21 | |
| 22 | - return recuperer_fond('prive/objets/editer/logo',array('objet'=>$objet,'id_objet'=>$id,'editable'=>$flag_modif)); |
|
| 22 | + return recuperer_fond('prive/objets/editer/logo',array('objet'=>$objet,'id_objet'=>$id,'editable'=>$flag_modif)); |
|
| 23 | 23 | } |
| 24 | 24 | |
| 25 | 25 | ?> |
@@ -15,11 +15,11 @@ |
||
| 15 | 15 | include_spip('inc/actions'); |
| 16 | 16 | |
| 17 | 17 | // http://doc.spip.org/@inc_iconifier_dist |
| 18 | -function inc_iconifier_dist($objet, $id, $script, $visible=false, $flag_modif=true) { |
|
| 18 | +function inc_iconifier_dist($objet, $id, $script, $visible = false, $flag_modif = true) { |
|
| 19 | 19 | // compat avec anciens appels |
| 20 | 20 | $objet = objet_type($objet); |
| 21 | 21 | |
| 22 | - return recuperer_fond('prive/objets/editer/logo',array('objet'=>$objet,'id_objet'=>$id,'editable'=>$flag_modif)); |
|
| 22 | + return recuperer_fond('prive/objets/editer/logo', array('objet'=>$objet, 'id_objet'=>$id, 'editable'=>$flag_modif)); |
|
| 23 | 23 | } |
| 24 | 24 | |
| 25 | 25 | ?> |
@@ -10,7 +10,9 @@ |
||
| 10 | 10 | * Pour plus de details voir le fichier COPYING.txt ou l'aide en ligne. * |
| 11 | 11 | \***************************************************************************/ |
| 12 | 12 | |
| 13 | -if (!defined('_ECRIRE_INC_VERSION')) return; |
|
| 13 | +if (!defined('_ECRIRE_INC_VERSION')) { |
|
| 14 | + return; |
|
| 15 | +} |
|
| 14 | 16 | |
| 15 | 17 | include_spip('inc/actions'); |
| 16 | 18 | |
@@ -25,27 +25,27 @@ discard block |
||
| 25 | 25 | |
| 26 | 26 | // http://doc.spip.org/@filtre_text_txt_dist |
| 27 | 27 | function filtre_text_dist($t) { |
| 28 | - static $t1 = array('&', '<', '>'); |
|
| 29 | - static $t2 = array('&', '<', '>'); |
|
| 30 | - return '<pre>' . str_replace($t1, $t2, $t) . '</pre>'; |
|
| 28 | + static $t1 = array('&', '<', '>'); |
|
| 29 | + static $t2 = array('&', '<', '>'); |
|
| 30 | + return '<pre>' . str_replace($t1, $t2, $t) . '</pre>'; |
|
| 31 | 31 | } |
| 32 | 32 | |
| 33 | 33 | // http://doc.spip.org/@filtre_text_csv_dist |
| 34 | 34 | function filtre_text_csv_dist($t) { |
| 35 | - include_spip('inc/csv'); |
|
| 36 | - list($entete, $lignes) = analyse_csv($t); |
|
| 37 | - foreach ($lignes as &$l) |
|
| 38 | - $l = join('|', $l); |
|
| 39 | - $corps = join("\n", $lignes) . "\n"; |
|
| 40 | - $corps = $caption . |
|
| 41 | - "\n|{{" . |
|
| 42 | - join('}}|{{',$entete) . |
|
| 43 | - "}}|" . |
|
| 44 | - "\n|" . |
|
| 45 | - str_replace("\n", "|\n|",$corps); |
|
| 46 | - $corps = str_replace('"#','"',$corps); |
|
| 47 | - include_spip('inc/texte'); |
|
| 48 | - return propre($corps); |
|
| 35 | + include_spip('inc/csv'); |
|
| 36 | + list($entete, $lignes) = analyse_csv($t); |
|
| 37 | + foreach ($lignes as &$l) |
|
| 38 | + $l = join('|', $l); |
|
| 39 | + $corps = join("\n", $lignes) . "\n"; |
|
| 40 | + $corps = $caption . |
|
| 41 | + "\n|{{" . |
|
| 42 | + join('}}|{{',$entete) . |
|
| 43 | + "}}|" . |
|
| 44 | + "\n|" . |
|
| 45 | + str_replace("\n", "|\n|",$corps); |
|
| 46 | + $corps = str_replace('"#','"',$corps); |
|
| 47 | + include_spip('inc/texte'); |
|
| 48 | + return propre($corps); |
|
| 49 | 49 | } |
| 50 | 50 | |
| 51 | 51 | // Incrustation de HTML, si on est capable de le securiser |
@@ -53,33 +53,33 @@ discard block |
||
| 53 | 53 | // http://doc.spip.org/@filtre_text_html_dist |
| 54 | 54 | function filtre_text_html_dist($t) |
| 55 | 55 | { |
| 56 | - if (!preg_match(',^(.*?)<body[^>]*>(.*)</body>,is', $t, $r)) |
|
| 57 | - return appliquer_filtre($t,'text/plain'); |
|
| 56 | + if (!preg_match(',^(.*?)<body[^>]*>(.*)</body>,is', $t, $r)) |
|
| 57 | + return appliquer_filtre($t,'text/plain'); |
|
| 58 | 58 | |
| 59 | - list(,$h,$t) = $r; |
|
| 59 | + list(,$h,$t) = $r; |
|
| 60 | 60 | |
| 61 | - $style = ''; |
|
| 62 | - // recuperer les styles internes |
|
| 63 | - if (preg_match_all(',<style>(.*?)</style>,is', $h, $r, PREG_PATTERN_ORDER)) |
|
| 64 | - $style = join("\n",$r[1]); |
|
| 65 | - // ... et externes |
|
| 61 | + $style = ''; |
|
| 62 | + // recuperer les styles internes |
|
| 63 | + if (preg_match_all(',<style>(.*?)</style>,is', $h, $r, PREG_PATTERN_ORDER)) |
|
| 64 | + $style = join("\n",$r[1]); |
|
| 65 | + // ... et externes |
|
| 66 | 66 | |
| 67 | - include_spip('inc/distant'); |
|
| 68 | - if (preg_match_all(',<link[^>]+type=.text/css[^>]*>,is', $h, $r, PREG_PATTERN_ORDER)) |
|
| 69 | - foreach($r[0] as $l) { |
|
| 70 | - preg_match("/href='([^']*)'/", str_replace('"',"'",$l), $m); |
|
| 71 | - $style .= "\n/* $l */\n" |
|
| 72 | - . str_replace('<','',recuperer_page($m[1])); |
|
| 73 | - } |
|
| 74 | - // Pourquoi SafeHtml transforme-t-il en texte les scripts dans Body ? |
|
| 75 | - $t = safehtml(preg_replace(',<script'.'.*?</script>,is','',$t)); |
|
| 76 | - return (!$style ? '' : "\n<style>".$style."</style>") . $t; |
|
| 67 | + include_spip('inc/distant'); |
|
| 68 | + if (preg_match_all(',<link[^>]+type=.text/css[^>]*>,is', $h, $r, PREG_PATTERN_ORDER)) |
|
| 69 | + foreach($r[0] as $l) { |
|
| 70 | + preg_match("/href='([^']*)'/", str_replace('"',"'",$l), $m); |
|
| 71 | + $style .= "\n/* $l */\n" |
|
| 72 | + . str_replace('<','',recuperer_page($m[1])); |
|
| 73 | + } |
|
| 74 | + // Pourquoi SafeHtml transforme-t-il en texte les scripts dans Body ? |
|
| 75 | + $t = safehtml(preg_replace(',<script'.'.*?</script>,is','',$t)); |
|
| 76 | + return (!$style ? '' : "\n<style>".$style."</style>") . $t; |
|
| 77 | 77 | } |
| 78 | 78 | |
| 79 | 79 | // http://doc.spip.org/@filtre_audio_x_pn_realaudio |
| 80 | 80 | function filtre_audio_x_pn_realaudio($id) |
| 81 | 81 | { |
| 82 | - return " |
|
| 82 | + return " |
|
| 83 | 83 | <param name='controls' value='PositionSlider' /> |
| 84 | 84 | <param name='controls' value='ImageWindow' /> |
| 85 | 85 | <param name='controls' value='PlayButton' /> |
@@ -16,18 +16,18 @@ discard block |
||
| 16 | 16 | // Fichier des filtres d'incrustation d'un document selon son type MIME |
| 17 | 17 | // Les 7 familles de base ne font rien sauf celle des textes |
| 18 | 18 | |
| 19 | -function filtre_image_dist($t) {return '';} |
|
| 20 | -function filtre_audio_dist($t) {return '';} |
|
| 21 | -function filtre_video_dist($t) {return '';} |
|
| 22 | -function filtre_application_dist($t) {return '';} |
|
| 23 | -function filtre_message_dist($t) {return '';} |
|
| 24 | -function filtre_multipart_dist($t) {return '';} |
|
| 19 | +function filtre_image_dist($t) {return ''; } |
|
| 20 | +function filtre_audio_dist($t) {return ''; } |
|
| 21 | +function filtre_video_dist($t) {return ''; } |
|
| 22 | +function filtre_application_dist($t) {return ''; } |
|
| 23 | +function filtre_message_dist($t) {return ''; } |
|
| 24 | +function filtre_multipart_dist($t) {return ''; } |
|
| 25 | 25 | |
| 26 | 26 | // http://doc.spip.org/@filtre_text_txt_dist |
| 27 | 27 | function filtre_text_dist($t) { |
| 28 | 28 | static $t1 = array('&', '<', '>'); |
| 29 | 29 | static $t2 = array('&', '<', '>'); |
| 30 | - return '<pre>' . str_replace($t1, $t2, $t) . '</pre>'; |
|
| 30 | + return '<pre>'.str_replace($t1, $t2, $t).'</pre>'; |
|
| 31 | 31 | } |
| 32 | 32 | |
| 33 | 33 | // http://doc.spip.org/@filtre_text_csv_dist |
@@ -36,14 +36,14 @@ discard block |
||
| 36 | 36 | list($entete, $lignes) = analyse_csv($t); |
| 37 | 37 | foreach ($lignes as &$l) |
| 38 | 38 | $l = join('|', $l); |
| 39 | - $corps = join("\n", $lignes) . "\n"; |
|
| 40 | - $corps = $caption . |
|
| 41 | - "\n|{{" . |
|
| 42 | - join('}}|{{',$entete) . |
|
| 43 | - "}}|" . |
|
| 44 | - "\n|" . |
|
| 45 | - str_replace("\n", "|\n|",$corps); |
|
| 46 | - $corps = str_replace('"#','"',$corps); |
|
| 39 | + $corps = join("\n", $lignes)."\n"; |
|
| 40 | + $corps = $caption. |
|
| 41 | + "\n|{{". |
|
| 42 | + join('}}|{{', $entete). |
|
| 43 | + "}}|". |
|
| 44 | + "\n|". |
|
| 45 | + str_replace("\n", "|\n|", $corps); |
|
| 46 | + $corps = str_replace('"#', '"', $corps); |
|
| 47 | 47 | include_spip('inc/texte'); |
| 48 | 48 | return propre($corps); |
| 49 | 49 | } |
@@ -54,26 +54,26 @@ discard block |
||
| 54 | 54 | function filtre_text_html_dist($t) |
| 55 | 55 | { |
| 56 | 56 | if (!preg_match(',^(.*?)<body[^>]*>(.*)</body>,is', $t, $r)) |
| 57 | - return appliquer_filtre($t,'text/plain'); |
|
| 57 | + return appliquer_filtre($t, 'text/plain'); |
|
| 58 | 58 | |
| 59 | - list(,$h,$t) = $r; |
|
| 59 | + list(,$h, $t) = $r; |
|
| 60 | 60 | |
| 61 | 61 | $style = ''; |
| 62 | 62 | // recuperer les styles internes |
| 63 | 63 | if (preg_match_all(',<style>(.*?)</style>,is', $h, $r, PREG_PATTERN_ORDER)) |
| 64 | - $style = join("\n",$r[1]); |
|
| 64 | + $style = join("\n", $r[1]); |
|
| 65 | 65 | // ... et externes |
| 66 | 66 | |
| 67 | 67 | include_spip('inc/distant'); |
| 68 | 68 | if (preg_match_all(',<link[^>]+type=.text/css[^>]*>,is', $h, $r, PREG_PATTERN_ORDER)) |
| 69 | - foreach($r[0] as $l) { |
|
| 70 | - preg_match("/href='([^']*)'/", str_replace('"',"'",$l), $m); |
|
| 69 | + foreach ($r[0] as $l) { |
|
| 70 | + preg_match("/href='([^']*)'/", str_replace('"', "'", $l), $m); |
|
| 71 | 71 | $style .= "\n/* $l */\n" |
| 72 | - . str_replace('<','',recuperer_page($m[1])); |
|
| 72 | + . str_replace('<', '', recuperer_page($m[1])); |
|
| 73 | 73 | } |
| 74 | 74 | // Pourquoi SafeHtml transforme-t-il en texte les scripts dans Body ? |
| 75 | - $t = safehtml(preg_replace(',<script'.'.*?</script>,is','',$t)); |
|
| 76 | - return (!$style ? '' : "\n<style>".$style."</style>") . $t; |
|
| 75 | + $t = safehtml(preg_replace(',<script'.'.*?</script>,is', '', $t)); |
|
| 76 | + return (!$style ? '' : "\n<style>".$style."</style>").$t; |
|
| 77 | 77 | } |
| 78 | 78 | |
| 79 | 79 | // http://doc.spip.org/@filtre_audio_x_pn_realaudio |
@@ -10,7 +10,9 @@ discard block |
||
| 10 | 10 | * Pour plus de details voir le fichier COPYING.txt ou l'aide en ligne. * |
| 11 | 11 | \***************************************************************************/ |
| 12 | 12 | |
| 13 | -if (!defined('_ECRIRE_INC_VERSION')) return; |
|
| 13 | +if (!defined('_ECRIRE_INC_VERSION')) { |
|
| 14 | + return; |
|
| 15 | +} |
|
| 14 | 16 | include_spip('inc/filtres'); |
| 15 | 17 | |
| 16 | 18 | // Fichier des filtres d'incrustation d'un document selon son type MIME |
@@ -34,8 +36,9 @@ discard block |
||
| 34 | 36 | function filtre_text_csv_dist($t) { |
| 35 | 37 | include_spip('inc/csv'); |
| 36 | 38 | list($entete, $lignes) = analyse_csv($t); |
| 37 | - foreach ($lignes as &$l) |
|
| 38 | - $l = join('|', $l); |
|
| 39 | + foreach ($lignes as &$l) { |
|
| 40 | + $l = join('|', $l); |
|
| 41 | + } |
|
| 39 | 42 | $corps = join("\n", $lignes) . "\n"; |
| 40 | 43 | $corps = $caption . |
| 41 | 44 | "\n|{{" . |
@@ -53,21 +56,24 @@ discard block |
||
| 53 | 56 | // http://doc.spip.org/@filtre_text_html_dist |
| 54 | 57 | function filtre_text_html_dist($t) |
| 55 | 58 | { |
| 56 | - if (!preg_match(',^(.*?)<body[^>]*>(.*)</body>,is', $t, $r)) |
|
| 57 | - return appliquer_filtre($t,'text/plain'); |
|
| 59 | + if (!preg_match(',^(.*?)<body[^>]*>(.*)</body>,is', $t, $r)) { |
|
| 60 | + return appliquer_filtre($t,'text/plain'); |
|
| 61 | + } |
|
| 58 | 62 | |
| 59 | 63 | list(,$h,$t) = $r; |
| 60 | 64 | |
| 61 | 65 | $style = ''; |
| 62 | 66 | // recuperer les styles internes |
| 63 | - if (preg_match_all(',<style>(.*?)</style>,is', $h, $r, PREG_PATTERN_ORDER)) |
|
| 64 | - $style = join("\n",$r[1]); |
|
| 67 | + if (preg_match_all(',<style>(.*?)</style>,is', $h, $r, PREG_PATTERN_ORDER)) { |
|
| 68 | + $style = join("\n",$r[1]); |
|
| 69 | + } |
|
| 65 | 70 | // ... et externes |
| 66 | 71 | |
| 67 | 72 | include_spip('inc/distant'); |
| 68 | - if (preg_match_all(',<link[^>]+type=.text/css[^>]*>,is', $h, $r, PREG_PATTERN_ORDER)) |
|
| 69 | - foreach($r[0] as $l) { |
|
| 73 | + if (preg_match_all(',<link[^>]+type=.text/css[^>]*>,is', $h, $r, PREG_PATTERN_ORDER)) { |
|
| 74 | + foreach($r[0] as $l) { |
|
| 70 | 75 | preg_match("/href='([^']*)'/", str_replace('"',"'",$l), $m); |
| 76 | + } |
|
| 71 | 77 | $style .= "\n/* $l */\n" |
| 72 | 78 | . str_replace('<','',recuperer_page($m[1])); |
| 73 | 79 | } |
@@ -23,59 +23,59 @@ |
||
| 23 | 23 | |
| 24 | 24 | // http://doc.spip.org/@var2js |
| 25 | 25 | function var2js($var) { |
| 26 | - $asso = false; |
|
| 27 | - switch (true) { |
|
| 28 | - case is_null($var) : |
|
| 29 | - return 'null'; |
|
| 30 | - case is_string($var) : |
|
| 31 | - return '"' .addcslashes($var, "\"\\\n\r/") . '"'; |
|
| 32 | - case is_bool($var) : |
|
| 33 | - return $var ? 'true' : 'false'; |
|
| 34 | - case is_scalar($var) : |
|
| 35 | - return (string)$var; |
|
| 36 | - case is_object( $var) : |
|
| 37 | - $var = get_object_vars($var); |
|
| 38 | - $asso = true; |
|
| 39 | - case is_array($var) : |
|
| 40 | - $keys = array_keys($var); |
|
| 41 | - $ikey = count($keys); |
|
| 42 | - while (!$asso && $ikey--) { |
|
| 43 | - $asso = $ikey !== $keys[$ikey]; |
|
| 44 | - } |
|
| 45 | - $sep = ''; |
|
| 46 | - if ($asso) { |
|
| 47 | - $ret = '{'; |
|
| 48 | - foreach ($var as $key => $elt) { |
|
| 49 | - $ret .= $sep . '"' . $key . '":' . var2js($elt); |
|
| 50 | - $sep = ','; |
|
| 51 | - } |
|
| 52 | - return $ret ."}"; |
|
| 53 | - } else { |
|
| 54 | - $ret = '['; |
|
| 55 | - foreach ($var as $elt) { |
|
| 56 | - $ret .= $sep . var2js($elt); |
|
| 57 | - $sep = ','; |
|
| 58 | - } |
|
| 59 | - return $ret ."]"; |
|
| 60 | - } |
|
| 61 | - } |
|
| 62 | - return false; |
|
| 26 | + $asso = false; |
|
| 27 | + switch (true) { |
|
| 28 | + case is_null($var) : |
|
| 29 | + return 'null'; |
|
| 30 | + case is_string($var) : |
|
| 31 | + return '"' .addcslashes($var, "\"\\\n\r/") . '"'; |
|
| 32 | + case is_bool($var) : |
|
| 33 | + return $var ? 'true' : 'false'; |
|
| 34 | + case is_scalar($var) : |
|
| 35 | + return (string)$var; |
|
| 36 | + case is_object( $var) : |
|
| 37 | + $var = get_object_vars($var); |
|
| 38 | + $asso = true; |
|
| 39 | + case is_array($var) : |
|
| 40 | + $keys = array_keys($var); |
|
| 41 | + $ikey = count($keys); |
|
| 42 | + while (!$asso && $ikey--) { |
|
| 43 | + $asso = $ikey !== $keys[$ikey]; |
|
| 44 | + } |
|
| 45 | + $sep = ''; |
|
| 46 | + if ($asso) { |
|
| 47 | + $ret = '{'; |
|
| 48 | + foreach ($var as $key => $elt) { |
|
| 49 | + $ret .= $sep . '"' . $key . '":' . var2js($elt); |
|
| 50 | + $sep = ','; |
|
| 51 | + } |
|
| 52 | + return $ret ."}"; |
|
| 53 | + } else { |
|
| 54 | + $ret = '['; |
|
| 55 | + foreach ($var as $elt) { |
|
| 56 | + $ret .= $sep . var2js($elt); |
|
| 57 | + $sep = ','; |
|
| 58 | + } |
|
| 59 | + return $ret ."]"; |
|
| 60 | + } |
|
| 61 | + } |
|
| 62 | + return false; |
|
| 63 | 63 | } |
| 64 | 64 | |
| 65 | 65 | if(!function_exists('json_encode')) { |
| 66 | - function json_encode($v) { return var2js($v); } |
|
| 66 | + function json_encode($v) { return var2js($v); } |
|
| 67 | 67 | } |
| 68 | 68 | |
| 69 | 69 | // http://doc.spip.org/@json_export |
| 70 | 70 | function json_export($var) { |
| 71 | - $var = json_encode($var); |
|
| 71 | + $var = json_encode($var); |
|
| 72 | 72 | |
| 73 | - // flag indiquant qu'on est en iframe et qu'il faut proteger nos |
|
| 74 | - // donnees dans un <textarea> ; attention $_FILES a ete vide par array_pop |
|
| 75 | - if (defined('FILE_UPLOAD')) |
|
| 76 | - return "<textarea>".spip_htmlspecialchars($var)."</textarea>"; |
|
| 77 | - else |
|
| 78 | - return $var; |
|
| 73 | + // flag indiquant qu'on est en iframe et qu'il faut proteger nos |
|
| 74 | + // donnees dans un <textarea> ; attention $_FILES a ete vide par array_pop |
|
| 75 | + if (defined('FILE_UPLOAD')) |
|
| 76 | + return "<textarea>".spip_htmlspecialchars($var)."</textarea>"; |
|
| 77 | + else |
|
| 78 | + return $var; |
|
| 79 | 79 | } |
| 80 | 80 | |
| 81 | 81 | |
@@ -28,12 +28,12 @@ discard block |
||
| 28 | 28 | case is_null($var) : |
| 29 | 29 | return 'null'; |
| 30 | 30 | case is_string($var) : |
| 31 | - return '"' .addcslashes($var, "\"\\\n\r/") . '"'; |
|
| 31 | + return '"'.addcslashes($var, "\"\\\n\r/").'"'; |
|
| 32 | 32 | case is_bool($var) : |
| 33 | 33 | return $var ? 'true' : 'false'; |
| 34 | 34 | case is_scalar($var) : |
| 35 | - return (string)$var; |
|
| 36 | - case is_object( $var) : |
|
| 35 | + return (string) $var; |
|
| 36 | + case is_object($var) : |
|
| 37 | 37 | $var = get_object_vars($var); |
| 38 | 38 | $asso = true; |
| 39 | 39 | case is_array($var) : |
@@ -46,23 +46,23 @@ discard block |
||
| 46 | 46 | if ($asso) { |
| 47 | 47 | $ret = '{'; |
| 48 | 48 | foreach ($var as $key => $elt) { |
| 49 | - $ret .= $sep . '"' . $key . '":' . var2js($elt); |
|
| 49 | + $ret .= $sep.'"'.$key.'":'.var2js($elt); |
|
| 50 | 50 | $sep = ','; |
| 51 | 51 | } |
| 52 | - return $ret ."}"; |
|
| 52 | + return $ret."}"; |
|
| 53 | 53 | } else { |
| 54 | 54 | $ret = '['; |
| 55 | 55 | foreach ($var as $elt) { |
| 56 | - $ret .= $sep . var2js($elt); |
|
| 56 | + $ret .= $sep.var2js($elt); |
|
| 57 | 57 | $sep = ','; |
| 58 | 58 | } |
| 59 | - return $ret ."]"; |
|
| 59 | + return $ret."]"; |
|
| 60 | 60 | } |
| 61 | 61 | } |
| 62 | 62 | return false; |
| 63 | 63 | } |
| 64 | 64 | |
| 65 | -if(!function_exists('json_encode')) { |
|
| 65 | +if (!function_exists('json_encode')) { |
|
| 66 | 66 | function json_encode($v) { return var2js($v); } |
| 67 | 67 | } |
| 68 | 68 | |
@@ -10,7 +10,9 @@ discard block |
||
| 10 | 10 | * Pour plus de details voir le fichier COPYING.txt ou l'aide en ligne. * |
| 11 | 11 | \***************************************************************************/ |
| 12 | 12 | |
| 13 | -if (!defined('_ECRIRE_INC_VERSION')) return; |
|
| 13 | +if (!defined('_ECRIRE_INC_VERSION')) { |
|
| 14 | + return; |
|
| 15 | +} |
|
| 14 | 16 | |
| 15 | 17 | // Les fonctions de toggg pour faire du JSON |
| 16 | 18 | |
@@ -72,11 +74,12 @@ discard block |
||
| 72 | 74 | |
| 73 | 75 | // flag indiquant qu'on est en iframe et qu'il faut proteger nos |
| 74 | 76 | // donnees dans un <textarea> ; attention $_FILES a ete vide par array_pop |
| 75 | - if (defined('FILE_UPLOAD')) |
|
| 76 | - return "<textarea>".spip_htmlspecialchars($var)."</textarea>"; |
|
| 77 | - else |
|
| 78 | - return $var; |
|
| 79 | -} |
|
| 77 | + if (defined('FILE_UPLOAD')) { |
|
| 78 | + return "<textarea>".spip_htmlspecialchars($var)."</textarea>"; |
|
| 79 | + } else { |
|
| 80 | + return $var; |
|
| 81 | + } |
|
| 82 | + } |
|
| 80 | 83 | |
| 81 | 84 | |
| 82 | 85 | |
@@ -37,28 +37,28 @@ discard block |
||
| 37 | 37 | * Tableau des champs et valeurs collectées |
| 38 | 38 | */ |
| 39 | 39 | function collecter_requests($white_list, $black_list, $set=null, $tous=false){ |
| 40 | - $c = $set; |
|
| 41 | - if (!$c){ |
|
| 42 | - $c = array(); |
|
| 43 | - foreach($white_list as $champ) { |
|
| 44 | - // on ne collecte que les champs reellement envoyes par defaut. |
|
| 45 | - // le cas d'un envoi de valeur NULL peut du coup poser probleme. |
|
| 46 | - $val = _request($champ); |
|
| 47 | - if ($tous OR $val !== NULL) { |
|
| 48 | - $c[$champ] = $val; |
|
| 49 | - } |
|
| 50 | - } |
|
| 51 | - // on ajoute toujours la lang en saisie possible |
|
| 52 | - // meme si pas prevu au depart pour l'objet concerne |
|
| 53 | - if ($l = _request('changer_lang')){ |
|
| 54 | - $c['lang'] = $l; |
|
| 55 | - } |
|
| 56 | - } |
|
| 57 | - foreach($black_list as $champ) { |
|
| 58 | - unset($c[$champ]); |
|
| 59 | - } |
|
| 40 | + $c = $set; |
|
| 41 | + if (!$c){ |
|
| 42 | + $c = array(); |
|
| 43 | + foreach($white_list as $champ) { |
|
| 44 | + // on ne collecte que les champs reellement envoyes par defaut. |
|
| 45 | + // le cas d'un envoi de valeur NULL peut du coup poser probleme. |
|
| 46 | + $val = _request($champ); |
|
| 47 | + if ($tous OR $val !== NULL) { |
|
| 48 | + $c[$champ] = $val; |
|
| 49 | + } |
|
| 50 | + } |
|
| 51 | + // on ajoute toujours la lang en saisie possible |
|
| 52 | + // meme si pas prevu au depart pour l'objet concerne |
|
| 53 | + if ($l = _request('changer_lang')){ |
|
| 54 | + $c['lang'] = $l; |
|
| 55 | + } |
|
| 56 | + } |
|
| 57 | + foreach($black_list as $champ) { |
|
| 58 | + unset($c[$champ]); |
|
| 59 | + } |
|
| 60 | 60 | |
| 61 | - return $c; |
|
| 61 | + return $c; |
|
| 62 | 62 | } |
| 63 | 63 | |
| 64 | 64 | /** |
@@ -95,183 +95,183 @@ discard block |
||
| 95 | 95 | * - chaîne : Texte d'un message d'erreur |
| 96 | 96 | */ |
| 97 | 97 | function objet_modifier_champs($objet, $id_objet, $options, $c=null, $serveur='') { |
| 98 | - if (!$id_objet = intval($id_objet)) { |
|
| 99 | - spip_log('Erreur $id_objet non defini', 'warn'); |
|
| 100 | - return _T('erreur_technique_enregistrement_impossible'); |
|
| 101 | - } |
|
| 98 | + if (!$id_objet = intval($id_objet)) { |
|
| 99 | + spip_log('Erreur $id_objet non defini', 'warn'); |
|
| 100 | + return _T('erreur_technique_enregistrement_impossible'); |
|
| 101 | + } |
|
| 102 | 102 | |
| 103 | - include_spip('inc/filtres'); |
|
| 103 | + include_spip('inc/filtres'); |
|
| 104 | 104 | |
| 105 | - $table_objet = table_objet($objet,$serveur); |
|
| 106 | - $spip_table_objet = table_objet_sql($objet,$serveur); |
|
| 107 | - $id_table_objet = id_table_objet($objet,$serveur); |
|
| 108 | - $trouver_table = charger_fonction('trouver_table', 'base'); |
|
| 109 | - $desc = $trouver_table($spip_table_objet, $serveur); |
|
| 105 | + $table_objet = table_objet($objet,$serveur); |
|
| 106 | + $spip_table_objet = table_objet_sql($objet,$serveur); |
|
| 107 | + $id_table_objet = id_table_objet($objet,$serveur); |
|
| 108 | + $trouver_table = charger_fonction('trouver_table', 'base'); |
|
| 109 | + $desc = $trouver_table($spip_table_objet, $serveur); |
|
| 110 | 110 | |
| 111 | - // Appels incomplets (sans $c) |
|
| 112 | - if (!is_array($c)) { |
|
| 113 | - spip_log('erreur appel objet_modifier_champs('.$objet.'), manque $c'); |
|
| 114 | - return _T('erreur_technique_enregistrement_impossible'); |
|
| 115 | - } |
|
| 111 | + // Appels incomplets (sans $c) |
|
| 112 | + if (!is_array($c)) { |
|
| 113 | + spip_log('erreur appel objet_modifier_champs('.$objet.'), manque $c'); |
|
| 114 | + return _T('erreur_technique_enregistrement_impossible'); |
|
| 115 | + } |
|
| 116 | 116 | |
| 117 | - // Securite : certaines variables ne sont jamais acceptees ici |
|
| 118 | - // car elles ne relevent pas de autoriser(xxx, modifier) ; |
|
| 119 | - // il faut passer par instituer_XX() |
|
| 120 | - // TODO: faut-il passer ces variables interdites |
|
| 121 | - // dans un fichier de description separe ? |
|
| 122 | - unset($c['statut']); |
|
| 123 | - unset($c['id_parent']); |
|
| 124 | - unset($c['id_rubrique']); |
|
| 125 | - unset($c['id_secteur']); |
|
| 117 | + // Securite : certaines variables ne sont jamais acceptees ici |
|
| 118 | + // car elles ne relevent pas de autoriser(xxx, modifier) ; |
|
| 119 | + // il faut passer par instituer_XX() |
|
| 120 | + // TODO: faut-il passer ces variables interdites |
|
| 121 | + // dans un fichier de description separe ? |
|
| 122 | + unset($c['statut']); |
|
| 123 | + unset($c['id_parent']); |
|
| 124 | + unset($c['id_rubrique']); |
|
| 125 | + unset($c['id_secteur']); |
|
| 126 | 126 | |
| 127 | - // Gerer les champs non vides |
|
| 128 | - if (isset($options['nonvide']) AND is_array($options['nonvide'])) { |
|
| 129 | - foreach ($options['nonvide'] as $champ => $sinon) { |
|
| 130 | - if ($c[$champ] === '') { |
|
| 131 | - $c[$champ] = $sinon; |
|
| 132 | - } |
|
| 133 | - } |
|
| 134 | - } |
|
| 127 | + // Gerer les champs non vides |
|
| 128 | + if (isset($options['nonvide']) AND is_array($options['nonvide'])) { |
|
| 129 | + foreach ($options['nonvide'] as $champ => $sinon) { |
|
| 130 | + if ($c[$champ] === '') { |
|
| 131 | + $c[$champ] = $sinon; |
|
| 132 | + } |
|
| 133 | + } |
|
| 134 | + } |
|
| 135 | 135 | |
| 136 | 136 | |
| 137 | - // N'accepter que les champs qui existent |
|
| 138 | - // TODO: ici aussi on peut valider les contenus |
|
| 139 | - // en fonction du type |
|
| 140 | - $champs = array(); |
|
| 141 | - foreach($desc['field'] as $champ => $ignore) |
|
| 142 | - if (isset($c[$champ])) |
|
| 143 | - $champs[$champ] = $c[$champ]; |
|
| 137 | + // N'accepter que les champs qui existent |
|
| 138 | + // TODO: ici aussi on peut valider les contenus |
|
| 139 | + // en fonction du type |
|
| 140 | + $champs = array(); |
|
| 141 | + foreach($desc['field'] as $champ => $ignore) |
|
| 142 | + if (isset($c[$champ])) |
|
| 143 | + $champs[$champ] = $c[$champ]; |
|
| 144 | 144 | |
| 145 | - // Nettoyer les valeurs |
|
| 146 | - $champs = array_map('corriger_caracteres', $champs); |
|
| 145 | + // Nettoyer les valeurs |
|
| 146 | + $champs = array_map('corriger_caracteres', $champs); |
|
| 147 | 147 | |
| 148 | - // Envoyer aux plugins |
|
| 149 | - $champs = pipeline('pre_edition', |
|
| 150 | - array( |
|
| 151 | - 'args' => array( |
|
| 152 | - 'table' => $spip_table_objet, // compatibilite |
|
| 153 | - 'table_objet' => $table_objet, |
|
| 154 | - 'spip_table_objet' => $spip_table_objet, |
|
| 155 | - 'type' =>$objet, |
|
| 156 | - 'id_objet' => $id_objet, |
|
| 157 | - 'champs' => isset($options['champs']) ? $options['champs'] : array(), // [doc] c'est quoi ? |
|
| 158 | - 'serveur' => $serveur, |
|
| 159 | - 'action' => isset($options['action']) ? $options['action'] : 'modifier' |
|
| 160 | - ), |
|
| 161 | - 'data' => $champs |
|
| 162 | - ) |
|
| 163 | - ); |
|
| 148 | + // Envoyer aux plugins |
|
| 149 | + $champs = pipeline('pre_edition', |
|
| 150 | + array( |
|
| 151 | + 'args' => array( |
|
| 152 | + 'table' => $spip_table_objet, // compatibilite |
|
| 153 | + 'table_objet' => $table_objet, |
|
| 154 | + 'spip_table_objet' => $spip_table_objet, |
|
| 155 | + 'type' =>$objet, |
|
| 156 | + 'id_objet' => $id_objet, |
|
| 157 | + 'champs' => isset($options['champs']) ? $options['champs'] : array(), // [doc] c'est quoi ? |
|
| 158 | + 'serveur' => $serveur, |
|
| 159 | + 'action' => isset($options['action']) ? $options['action'] : 'modifier' |
|
| 160 | + ), |
|
| 161 | + 'data' => $champs |
|
| 162 | + ) |
|
| 163 | + ); |
|
| 164 | 164 | |
| 165 | - if (!$champs) return false; |
|
| 165 | + if (!$champs) return false; |
|
| 166 | 166 | |
| 167 | 167 | |
| 168 | - // marquer le fait que l'objet est travaille par toto a telle date |
|
| 169 | - if ($GLOBALS['meta']['articles_modif'] != 'non') { |
|
| 170 | - include_spip('inc/drapeau_edition'); |
|
| 171 | - signale_edition ($id_objet, $GLOBALS['visiteur_session'], $objet); |
|
| 172 | - } |
|
| 168 | + // marquer le fait que l'objet est travaille par toto a telle date |
|
| 169 | + if ($GLOBALS['meta']['articles_modif'] != 'non') { |
|
| 170 | + include_spip('inc/drapeau_edition'); |
|
| 171 | + signale_edition ($id_objet, $GLOBALS['visiteur_session'], $objet); |
|
| 172 | + } |
|
| 173 | 173 | |
| 174 | - // Verifier si les mises a jour sont pertinentes, datees, en conflit etc |
|
| 175 | - include_spip('inc/editer'); |
|
| 176 | - if (!isset($options['data']) OR is_null($options['data'])){ |
|
| 177 | - $options['data'] = &$_POST; |
|
| 178 | - } |
|
| 179 | - $conflits = controler_md5($champs, $options['data'], $objet, $id_objet, $serveur); |
|
| 180 | - // cas hypothetique : normalement inc/editer verifie en amont le conflit edition |
|
| 181 | - // et gere l'interface |
|
| 182 | - // ici on ne renvoie donc qu'un messsage d'erreur, au cas ou on y arrive quand meme |
|
| 183 | - if ($conflits) |
|
| 184 | - return _T('titre_conflit_edition'); |
|
| 174 | + // Verifier si les mises a jour sont pertinentes, datees, en conflit etc |
|
| 175 | + include_spip('inc/editer'); |
|
| 176 | + if (!isset($options['data']) OR is_null($options['data'])){ |
|
| 177 | + $options['data'] = &$_POST; |
|
| 178 | + } |
|
| 179 | + $conflits = controler_md5($champs, $options['data'], $objet, $id_objet, $serveur); |
|
| 180 | + // cas hypothetique : normalement inc/editer verifie en amont le conflit edition |
|
| 181 | + // et gere l'interface |
|
| 182 | + // ici on ne renvoie donc qu'un messsage d'erreur, au cas ou on y arrive quand meme |
|
| 183 | + if ($conflits) |
|
| 184 | + return _T('titre_conflit_edition'); |
|
| 185 | 185 | |
| 186 | - if ($champs) { |
|
| 187 | - // cas particulier de la langue : passer par instituer_langue_objet |
|
| 188 | - if (isset($champs['lang'])){ |
|
| 189 | - if ($changer_lang=$champs['lang']){ |
|
| 190 | - $id_rubrique = 0; |
|
| 191 | - if ($desc['field']['id_rubrique']){ |
|
| 192 | - $parent = ($objet=='rubrique')?'id_parent':'id_rubrique'; |
|
| 193 | - $id_rubrique = sql_getfetsel($parent, $spip_table_objet, "$id_table_objet=".intval($id_objet)); |
|
| 194 | - } |
|
| 195 | - $instituer_langue_objet = charger_fonction('instituer_langue_objet', 'action'); |
|
| 196 | - $champs['lang'] = $instituer_langue_objet($objet, $id_objet, $id_rubrique, $changer_lang, $serveur); |
|
| 197 | - } |
|
| 198 | - // on laisse 'lang' dans $champs, |
|
| 199 | - // ca permet de passer dans le pipeline post_edition et de journaliser |
|
| 200 | - // et ca ne gene pas qu'on refasse un sql_updateq dessus apres l'avoir |
|
| 201 | - // deja pris en compte |
|
| 202 | - } |
|
| 186 | + if ($champs) { |
|
| 187 | + // cas particulier de la langue : passer par instituer_langue_objet |
|
| 188 | + if (isset($champs['lang'])){ |
|
| 189 | + if ($changer_lang=$champs['lang']){ |
|
| 190 | + $id_rubrique = 0; |
|
| 191 | + if ($desc['field']['id_rubrique']){ |
|
| 192 | + $parent = ($objet=='rubrique')?'id_parent':'id_rubrique'; |
|
| 193 | + $id_rubrique = sql_getfetsel($parent, $spip_table_objet, "$id_table_objet=".intval($id_objet)); |
|
| 194 | + } |
|
| 195 | + $instituer_langue_objet = charger_fonction('instituer_langue_objet', 'action'); |
|
| 196 | + $champs['lang'] = $instituer_langue_objet($objet, $id_objet, $id_rubrique, $changer_lang, $serveur); |
|
| 197 | + } |
|
| 198 | + // on laisse 'lang' dans $champs, |
|
| 199 | + // ca permet de passer dans le pipeline post_edition et de journaliser |
|
| 200 | + // et ca ne gene pas qu'on refasse un sql_updateq dessus apres l'avoir |
|
| 201 | + // deja pris en compte |
|
| 202 | + } |
|
| 203 | 203 | |
| 204 | - // la modif peut avoir lieu |
|
| 204 | + // la modif peut avoir lieu |
|
| 205 | 205 | |
| 206 | - // faut-il ajouter date_modif ? |
|
| 207 | - if (isset($options['date_modif']) AND $options['date_modif'] |
|
| 208 | - AND !isset($champs[$options['date_modif']])) |
|
| 209 | - $champs[$options['date_modif']] = date('Y-m-d H:i:s'); |
|
| 206 | + // faut-il ajouter date_modif ? |
|
| 207 | + if (isset($options['date_modif']) AND $options['date_modif'] |
|
| 208 | + AND !isset($champs[$options['date_modif']])) |
|
| 209 | + $champs[$options['date_modif']] = date('Y-m-d H:i:s'); |
|
| 210 | 210 | |
| 211 | - // allez on commit la modif |
|
| 212 | - sql_updateq($spip_table_objet, $champs, "$id_table_objet=".intval($id_objet), $serveur); |
|
| 211 | + // allez on commit la modif |
|
| 212 | + sql_updateq($spip_table_objet, $champs, "$id_table_objet=".intval($id_objet), $serveur); |
|
| 213 | 213 | |
| 214 | - // on verifie si elle est bien passee |
|
| 215 | - $moof = sql_fetsel(array_keys($champs), $spip_table_objet, "$id_table_objet=".intval($id_objet), array(), array(), '', array(), $serveur); |
|
| 216 | - // si difference entre les champs, reperer les champs mal enregistres |
|
| 217 | - if ($moof != $champs) { |
|
| 218 | - $liste = array(); |
|
| 219 | - foreach($moof as $k=>$v) |
|
| 220 | - if ($v !== $champs[$k] |
|
| 221 | - // ne pas alerter si le champ est numerique est que les valeurs sont equivalentes |
|
| 222 | - AND (!is_numeric($v) OR intval($v)!=intval($champs[$k])) |
|
| 223 | - ) { |
|
| 224 | - $liste[] = $k; |
|
| 225 | - $conflits[$k]['post'] = $champs[$k]; |
|
| 226 | - $conflits[$k]['save'] = $v; |
|
| 227 | - } |
|
| 228 | - // si un champ n'a pas ete correctement enregistre, loger et retourner une erreur |
|
| 229 | - // c'est un cas exceptionnel |
|
| 230 | - if (count($liste)){ |
|
| 231 | - spip_log("Erreur enregistrement en base $objet/$id_objet champs :".var_export($conflits,true),'modifier.'._LOG_CRITIQUE); |
|
| 232 | - return _T('erreur_technique_enregistrement_champs',array('champs'=>"<i>'".implode("'</i>,<i>'",$liste)."'</i>")); |
|
| 233 | - } |
|
| 234 | - } |
|
| 214 | + // on verifie si elle est bien passee |
|
| 215 | + $moof = sql_fetsel(array_keys($champs), $spip_table_objet, "$id_table_objet=".intval($id_objet), array(), array(), '', array(), $serveur); |
|
| 216 | + // si difference entre les champs, reperer les champs mal enregistres |
|
| 217 | + if ($moof != $champs) { |
|
| 218 | + $liste = array(); |
|
| 219 | + foreach($moof as $k=>$v) |
|
| 220 | + if ($v !== $champs[$k] |
|
| 221 | + // ne pas alerter si le champ est numerique est que les valeurs sont equivalentes |
|
| 222 | + AND (!is_numeric($v) OR intval($v)!=intval($champs[$k])) |
|
| 223 | + ) { |
|
| 224 | + $liste[] = $k; |
|
| 225 | + $conflits[$k]['post'] = $champs[$k]; |
|
| 226 | + $conflits[$k]['save'] = $v; |
|
| 227 | + } |
|
| 228 | + // si un champ n'a pas ete correctement enregistre, loger et retourner une erreur |
|
| 229 | + // c'est un cas exceptionnel |
|
| 230 | + if (count($liste)){ |
|
| 231 | + spip_log("Erreur enregistrement en base $objet/$id_objet champs :".var_export($conflits,true),'modifier.'._LOG_CRITIQUE); |
|
| 232 | + return _T('erreur_technique_enregistrement_champs',array('champs'=>"<i>'".implode("'</i>,<i>'",$liste)."'</i>")); |
|
| 233 | + } |
|
| 234 | + } |
|
| 235 | 235 | |
| 236 | - // Invalider les caches |
|
| 237 | - if (isset($options['invalideur']) and $options['invalideur']) { |
|
| 238 | - include_spip('inc/invalideur'); |
|
| 239 | - if (is_array($options['invalideur'])) |
|
| 240 | - array_map('suivre_invalideur',$options['invalideur']); |
|
| 241 | - else |
|
| 242 | - suivre_invalideur($options['invalideur']); |
|
| 243 | - } |
|
| 236 | + // Invalider les caches |
|
| 237 | + if (isset($options['invalideur']) and $options['invalideur']) { |
|
| 238 | + include_spip('inc/invalideur'); |
|
| 239 | + if (is_array($options['invalideur'])) |
|
| 240 | + array_map('suivre_invalideur',$options['invalideur']); |
|
| 241 | + else |
|
| 242 | + suivre_invalideur($options['invalideur']); |
|
| 243 | + } |
|
| 244 | 244 | |
| 245 | - // Notifications, gestion des revisions... |
|
| 246 | - // en standard, appelle |nouvelle_revision ci-dessous |
|
| 247 | - pipeline('post_edition', |
|
| 248 | - array( |
|
| 249 | - 'args' => array( |
|
| 250 | - 'table' => $spip_table_objet, |
|
| 251 | - 'table_objet' => $table_objet, |
|
| 252 | - 'spip_table_objet' => $spip_table_objet, |
|
| 253 | - 'type' =>$objet, |
|
| 254 | - 'id_objet' => $id_objet, |
|
| 255 | - 'champs' => isset($options['champs']) ? $options['champs'] : array(), // [doc] kesako ? |
|
| 256 | - 'serveur' => $serveur, |
|
| 257 | - 'action' => isset($options['action']) ? $options['action'] : 'modifier' |
|
| 258 | - ), |
|
| 259 | - 'data' => $champs |
|
| 260 | - ) |
|
| 261 | - ); |
|
| 262 | - } |
|
| 245 | + // Notifications, gestion des revisions... |
|
| 246 | + // en standard, appelle |nouvelle_revision ci-dessous |
|
| 247 | + pipeline('post_edition', |
|
| 248 | + array( |
|
| 249 | + 'args' => array( |
|
| 250 | + 'table' => $spip_table_objet, |
|
| 251 | + 'table_objet' => $table_objet, |
|
| 252 | + 'spip_table_objet' => $spip_table_objet, |
|
| 253 | + 'type' =>$objet, |
|
| 254 | + 'id_objet' => $id_objet, |
|
| 255 | + 'champs' => isset($options['champs']) ? $options['champs'] : array(), // [doc] kesako ? |
|
| 256 | + 'serveur' => $serveur, |
|
| 257 | + 'action' => isset($options['action']) ? $options['action'] : 'modifier' |
|
| 258 | + ), |
|
| 259 | + 'data' => $champs |
|
| 260 | + ) |
|
| 261 | + ); |
|
| 262 | + } |
|
| 263 | 263 | |
| 264 | - // journaliser l'affaire |
|
| 265 | - // message a affiner :-) |
|
| 266 | - include_spip('inc/filtres_mini'); |
|
| 267 | - $qui = ((isset($GLOBALS['visiteur_session']['nom']) AND $GLOBALS['visiteur_session']['nom'])?$GLOBALS['visiteur_session']['nom']:$GLOBALS['ip']); |
|
| 268 | - journal(_L($qui.' a édité l’'.$objet.' '.$id_objet.' ('.join('+',array_diff(array_keys($champs), array('date_modif'))).')'), array( |
|
| 269 | - 'faire' => 'modifier', |
|
| 270 | - 'quoi' => $objet, |
|
| 271 | - 'id' => $id_objet |
|
| 272 | - )); |
|
| 264 | + // journaliser l'affaire |
|
| 265 | + // message a affiner :-) |
|
| 266 | + include_spip('inc/filtres_mini'); |
|
| 267 | + $qui = ((isset($GLOBALS['visiteur_session']['nom']) AND $GLOBALS['visiteur_session']['nom'])?$GLOBALS['visiteur_session']['nom']:$GLOBALS['ip']); |
|
| 268 | + journal(_L($qui.' a édité l’'.$objet.' '.$id_objet.' ('.join('+',array_diff(array_keys($champs), array('date_modif'))).')'), array( |
|
| 269 | + 'faire' => 'modifier', |
|
| 270 | + 'quoi' => $objet, |
|
| 271 | + 'id' => $id_objet |
|
| 272 | + )); |
|
| 273 | 273 | |
| 274 | - return ''; |
|
| 274 | + return ''; |
|
| 275 | 275 | } |
| 276 | 276 | |
| 277 | 277 | /** |
@@ -296,8 +296,8 @@ discard block |
||
| 296 | 296 | * false sinon (erreur ou aucun champ modifié) |
| 297 | 297 | */ |
| 298 | 298 | function modifier_contenu($type, $id, $options, $c=null, $serveur='') { |
| 299 | - $res = objet_modifier_champs($type, $id, $options, $c, $serveur); |
|
| 300 | - return ($res===''?true:false); |
|
| 299 | + $res = objet_modifier_champs($type, $id, $options, $c, $serveur); |
|
| 300 | + return ($res===''?true:false); |
|
| 301 | 301 | } |
| 302 | 302 | |
| 303 | 303 | /** |
@@ -318,9 +318,9 @@ discard block |
||
| 318 | 318 | * @return mixed|string |
| 319 | 319 | */ |
| 320 | 320 | function revision_objet($objet,$id_objet,$c=null){ |
| 321 | - $objet = objet_type($objet); // securite |
|
| 322 | - include_spip('action/editer_objet'); |
|
| 323 | - return objet_modifier($objet,$id_objet,$c); |
|
| 321 | + $objet = objet_type($objet); // securite |
|
| 322 | + include_spip('action/editer_objet'); |
|
| 323 | + return objet_modifier($objet,$id_objet,$c); |
|
| 324 | 324 | } |
| 325 | 325 | |
| 326 | 326 | |
@@ -16,7 +16,9 @@ discard block |
||
| 16 | 16 | * @package SPIP\Objets\Modifications |
| 17 | 17 | **/ |
| 18 | 18 | |
| 19 | -if (!defined('_ECRIRE_INC_VERSION')) return; |
|
| 19 | +if (!defined('_ECRIRE_INC_VERSION')) { |
|
| 20 | + return; |
|
| 21 | +} |
|
| 20 | 22 | |
| 21 | 23 | /** |
| 22 | 24 | * Collecte des champs postés |
@@ -138,9 +140,10 @@ discard block |
||
| 138 | 140 | // TODO: ici aussi on peut valider les contenus |
| 139 | 141 | // en fonction du type |
| 140 | 142 | $champs = array(); |
| 141 | - foreach($desc['field'] as $champ => $ignore) |
|
| 142 | - if (isset($c[$champ])) |
|
| 143 | + foreach($desc['field'] as $champ => $ignore) { |
|
| 144 | + if (isset($c[$champ])) |
|
| 143 | 145 | $champs[$champ] = $c[$champ]; |
| 146 | + } |
|
| 144 | 147 | |
| 145 | 148 | // Nettoyer les valeurs |
| 146 | 149 | $champs = array_map('corriger_caracteres', $champs); |
@@ -162,7 +165,9 @@ discard block |
||
| 162 | 165 | ) |
| 163 | 166 | ); |
| 164 | 167 | |
| 165 | - if (!$champs) return false; |
|
| 168 | + if (!$champs) { |
|
| 169 | + return false; |
|
| 170 | + } |
|
| 166 | 171 | |
| 167 | 172 | |
| 168 | 173 | // marquer le fait que l'objet est travaille par toto a telle date |
@@ -180,8 +185,9 @@ discard block |
||
| 180 | 185 | // cas hypothetique : normalement inc/editer verifie en amont le conflit edition |
| 181 | 186 | // et gere l'interface |
| 182 | 187 | // ici on ne renvoie donc qu'un messsage d'erreur, au cas ou on y arrive quand meme |
| 183 | - if ($conflits) |
|
| 184 | - return _T('titre_conflit_edition'); |
|
| 188 | + if ($conflits) { |
|
| 189 | + return _T('titre_conflit_edition'); |
|
| 190 | + } |
|
| 185 | 191 | |
| 186 | 192 | if ($champs) { |
| 187 | 193 | // cas particulier de la langue : passer par instituer_langue_objet |
@@ -205,8 +211,9 @@ discard block |
||
| 205 | 211 | |
| 206 | 212 | // faut-il ajouter date_modif ? |
| 207 | 213 | if (isset($options['date_modif']) AND $options['date_modif'] |
| 208 | - AND !isset($champs[$options['date_modif']])) |
|
| 209 | - $champs[$options['date_modif']] = date('Y-m-d H:i:s'); |
|
| 214 | + AND !isset($champs[$options['date_modif']])) { |
|
| 215 | + $champs[$options['date_modif']] = date('Y-m-d H:i:s'); |
|
| 216 | + } |
|
| 210 | 217 | |
| 211 | 218 | // allez on commit la modif |
| 212 | 219 | sql_updateq($spip_table_objet, $champs, "$id_table_objet=".intval($id_objet), $serveur); |
@@ -216,12 +223,13 @@ discard block |
||
| 216 | 223 | // si difference entre les champs, reperer les champs mal enregistres |
| 217 | 224 | if ($moof != $champs) { |
| 218 | 225 | $liste = array(); |
| 219 | - foreach($moof as $k=>$v) |
|
| 220 | - if ($v !== $champs[$k] |
|
| 226 | + foreach($moof as $k=>$v) { |
|
| 227 | + if ($v !== $champs[$k] |
|
| 221 | 228 | // ne pas alerter si le champ est numerique est que les valeurs sont equivalentes |
| 222 | 229 | AND (!is_numeric($v) OR intval($v)!=intval($champs[$k])) |
| 223 | 230 | ) { |
| 224 | 231 | $liste[] = $k; |
| 232 | + } |
|
| 225 | 233 | $conflits[$k]['post'] = $champs[$k]; |
| 226 | 234 | $conflits[$k]['save'] = $v; |
| 227 | 235 | } |
@@ -236,10 +244,11 @@ discard block |
||
| 236 | 244 | // Invalider les caches |
| 237 | 245 | if (isset($options['invalideur']) and $options['invalideur']) { |
| 238 | 246 | include_spip('inc/invalideur'); |
| 239 | - if (is_array($options['invalideur'])) |
|
| 240 | - array_map('suivre_invalideur',$options['invalideur']); |
|
| 241 | - else |
|
| 242 | - suivre_invalideur($options['invalideur']); |
|
| 247 | + if (is_array($options['invalideur'])) { |
|
| 248 | + array_map('suivre_invalideur',$options['invalideur']); |
|
| 249 | + } else { |
|
| 250 | + suivre_invalideur($options['invalideur']); |
|
| 251 | + } |
|
| 243 | 252 | } |
| 244 | 253 | |
| 245 | 254 | // Notifications, gestion des revisions... |
@@ -36,11 +36,11 @@ discard block |
||
| 36 | 36 | * @return array |
| 37 | 37 | * Tableau des champs et valeurs collectées |
| 38 | 38 | */ |
| 39 | -function collecter_requests($white_list, $black_list, $set=null, $tous=false){ |
|
| 39 | +function collecter_requests($white_list, $black_list, $set = null, $tous = false) { |
|
| 40 | 40 | $c = $set; |
| 41 | - if (!$c){ |
|
| 41 | + if (!$c) { |
|
| 42 | 42 | $c = array(); |
| 43 | - foreach($white_list as $champ) { |
|
| 43 | + foreach ($white_list as $champ) { |
|
| 44 | 44 | // on ne collecte que les champs reellement envoyes par defaut. |
| 45 | 45 | // le cas d'un envoi de valeur NULL peut du coup poser probleme. |
| 46 | 46 | $val = _request($champ); |
@@ -50,11 +50,11 @@ discard block |
||
| 50 | 50 | } |
| 51 | 51 | // on ajoute toujours la lang en saisie possible |
| 52 | 52 | // meme si pas prevu au depart pour l'objet concerne |
| 53 | - if ($l = _request('changer_lang')){ |
|
| 53 | + if ($l = _request('changer_lang')) { |
|
| 54 | 54 | $c['lang'] = $l; |
| 55 | 55 | } |
| 56 | 56 | } |
| 57 | - foreach($black_list as $champ) { |
|
| 57 | + foreach ($black_list as $champ) { |
|
| 58 | 58 | unset($c[$champ]); |
| 59 | 59 | } |
| 60 | 60 | |
@@ -94,7 +94,7 @@ discard block |
||
| 94 | 94 | * - chaîne vide : Vide si tout s'est bien passé |
| 95 | 95 | * - chaîne : Texte d'un message d'erreur |
| 96 | 96 | */ |
| 97 | -function objet_modifier_champs($objet, $id_objet, $options, $c=null, $serveur='') { |
|
| 97 | +function objet_modifier_champs($objet, $id_objet, $options, $c = null, $serveur = '') { |
|
| 98 | 98 | if (!$id_objet = intval($id_objet)) { |
| 99 | 99 | spip_log('Erreur $id_objet non defini', 'warn'); |
| 100 | 100 | return _T('erreur_technique_enregistrement_impossible'); |
@@ -102,9 +102,9 @@ discard block |
||
| 102 | 102 | |
| 103 | 103 | include_spip('inc/filtres'); |
| 104 | 104 | |
| 105 | - $table_objet = table_objet($objet,$serveur); |
|
| 106 | - $spip_table_objet = table_objet_sql($objet,$serveur); |
|
| 107 | - $id_table_objet = id_table_objet($objet,$serveur); |
|
| 105 | + $table_objet = table_objet($objet, $serveur); |
|
| 106 | + $spip_table_objet = table_objet_sql($objet, $serveur); |
|
| 107 | + $id_table_objet = id_table_objet($objet, $serveur); |
|
| 108 | 108 | $trouver_table = charger_fonction('trouver_table', 'base'); |
| 109 | 109 | $desc = $trouver_table($spip_table_objet, $serveur); |
| 110 | 110 | |
@@ -138,7 +138,7 @@ discard block |
||
| 138 | 138 | // TODO: ici aussi on peut valider les contenus |
| 139 | 139 | // en fonction du type |
| 140 | 140 | $champs = array(); |
| 141 | - foreach($desc['field'] as $champ => $ignore) |
|
| 141 | + foreach ($desc['field'] as $champ => $ignore) |
|
| 142 | 142 | if (isset($c[$champ])) |
| 143 | 143 | $champs[$champ] = $c[$champ]; |
| 144 | 144 | |
@@ -168,12 +168,12 @@ discard block |
||
| 168 | 168 | // marquer le fait que l'objet est travaille par toto a telle date |
| 169 | 169 | if ($GLOBALS['meta']['articles_modif'] != 'non') { |
| 170 | 170 | include_spip('inc/drapeau_edition'); |
| 171 | - signale_edition ($id_objet, $GLOBALS['visiteur_session'], $objet); |
|
| 171 | + signale_edition($id_objet, $GLOBALS['visiteur_session'], $objet); |
|
| 172 | 172 | } |
| 173 | 173 | |
| 174 | 174 | // Verifier si les mises a jour sont pertinentes, datees, en conflit etc |
| 175 | 175 | include_spip('inc/editer'); |
| 176 | - if (!isset($options['data']) OR is_null($options['data'])){ |
|
| 176 | + if (!isset($options['data']) OR is_null($options['data'])) { |
|
| 177 | 177 | $options['data'] = &$_POST; |
| 178 | 178 | } |
| 179 | 179 | $conflits = controler_md5($champs, $options['data'], $objet, $id_objet, $serveur); |
@@ -185,11 +185,11 @@ discard block |
||
| 185 | 185 | |
| 186 | 186 | if ($champs) { |
| 187 | 187 | // cas particulier de la langue : passer par instituer_langue_objet |
| 188 | - if (isset($champs['lang'])){ |
|
| 189 | - if ($changer_lang=$champs['lang']){ |
|
| 188 | + if (isset($champs['lang'])) { |
|
| 189 | + if ($changer_lang = $champs['lang']) { |
|
| 190 | 190 | $id_rubrique = 0; |
| 191 | - if ($desc['field']['id_rubrique']){ |
|
| 192 | - $parent = ($objet=='rubrique')?'id_parent':'id_rubrique'; |
|
| 191 | + if ($desc['field']['id_rubrique']) { |
|
| 192 | + $parent = ($objet == 'rubrique') ? 'id_parent' : 'id_rubrique'; |
|
| 193 | 193 | $id_rubrique = sql_getfetsel($parent, $spip_table_objet, "$id_table_objet=".intval($id_objet)); |
| 194 | 194 | } |
| 195 | 195 | $instituer_langue_objet = charger_fonction('instituer_langue_objet', 'action'); |
@@ -216,10 +216,10 @@ discard block |
||
| 216 | 216 | // si difference entre les champs, reperer les champs mal enregistres |
| 217 | 217 | if ($moof != $champs) { |
| 218 | 218 | $liste = array(); |
| 219 | - foreach($moof as $k=>$v) |
|
| 219 | + foreach ($moof as $k=>$v) |
|
| 220 | 220 | if ($v !== $champs[$k] |
| 221 | 221 | // ne pas alerter si le champ est numerique est que les valeurs sont equivalentes |
| 222 | - AND (!is_numeric($v) OR intval($v)!=intval($champs[$k])) |
|
| 222 | + AND (!is_numeric($v) OR intval($v) != intval($champs[$k])) |
|
| 223 | 223 | ) { |
| 224 | 224 | $liste[] = $k; |
| 225 | 225 | $conflits[$k]['post'] = $champs[$k]; |
@@ -227,9 +227,9 @@ discard block |
||
| 227 | 227 | } |
| 228 | 228 | // si un champ n'a pas ete correctement enregistre, loger et retourner une erreur |
| 229 | 229 | // c'est un cas exceptionnel |
| 230 | - if (count($liste)){ |
|
| 231 | - spip_log("Erreur enregistrement en base $objet/$id_objet champs :".var_export($conflits,true),'modifier.'._LOG_CRITIQUE); |
|
| 232 | - return _T('erreur_technique_enregistrement_champs',array('champs'=>"<i>'".implode("'</i>,<i>'",$liste)."'</i>")); |
|
| 230 | + if (count($liste)) { |
|
| 231 | + spip_log("Erreur enregistrement en base $objet/$id_objet champs :".var_export($conflits, true), 'modifier.'._LOG_CRITIQUE); |
|
| 232 | + return _T('erreur_technique_enregistrement_champs', array('champs'=>"<i>'".implode("'</i>,<i>'", $liste)."'</i>")); |
|
| 233 | 233 | } |
| 234 | 234 | } |
| 235 | 235 | |
@@ -237,7 +237,7 @@ discard block |
||
| 237 | 237 | if (isset($options['invalideur']) and $options['invalideur']) { |
| 238 | 238 | include_spip('inc/invalideur'); |
| 239 | 239 | if (is_array($options['invalideur'])) |
| 240 | - array_map('suivre_invalideur',$options['invalideur']); |
|
| 240 | + array_map('suivre_invalideur', $options['invalideur']); |
|
| 241 | 241 | else |
| 242 | 242 | suivre_invalideur($options['invalideur']); |
| 243 | 243 | } |
@@ -264,8 +264,8 @@ discard block |
||
| 264 | 264 | // journaliser l'affaire |
| 265 | 265 | // message a affiner :-) |
| 266 | 266 | include_spip('inc/filtres_mini'); |
| 267 | - $qui = ((isset($GLOBALS['visiteur_session']['nom']) AND $GLOBALS['visiteur_session']['nom'])?$GLOBALS['visiteur_session']['nom']:$GLOBALS['ip']); |
|
| 268 | - journal(_L($qui.' a édité l’'.$objet.' '.$id_objet.' ('.join('+',array_diff(array_keys($champs), array('date_modif'))).')'), array( |
|
| 267 | + $qui = ((isset($GLOBALS['visiteur_session']['nom']) AND $GLOBALS['visiteur_session']['nom']) ? $GLOBALS['visiteur_session']['nom'] : $GLOBALS['ip']); |
|
| 268 | + journal(_L($qui.' a édité l’'.$objet.' '.$id_objet.' ('.join('+', array_diff(array_keys($champs), array('date_modif'))).')'), array( |
|
| 269 | 269 | 'faire' => 'modifier', |
| 270 | 270 | 'quoi' => $objet, |
| 271 | 271 | 'id' => $id_objet |
@@ -295,9 +295,9 @@ discard block |
||
| 295 | 295 | * true si quelque chose est modifié correctement |
| 296 | 296 | * false sinon (erreur ou aucun champ modifié) |
| 297 | 297 | */ |
| 298 | -function modifier_contenu($type, $id, $options, $c=null, $serveur='') { |
|
| 298 | +function modifier_contenu($type, $id, $options, $c = null, $serveur = '') { |
|
| 299 | 299 | $res = objet_modifier_champs($type, $id, $options, $c, $serveur); |
| 300 | - return ($res===''?true:false); |
|
| 300 | + return ($res === '' ?true:false); |
|
| 301 | 301 | } |
| 302 | 302 | |
| 303 | 303 | /** |
@@ -317,10 +317,10 @@ discard block |
||
| 317 | 317 | * Couples des champs/valeurs modifiées |
| 318 | 318 | * @return mixed|string |
| 319 | 319 | */ |
| 320 | -function revision_objet($objet,$id_objet,$c=null){ |
|
| 320 | +function revision_objet($objet, $id_objet, $c = null) { |
|
| 321 | 321 | $objet = objet_type($objet); // securite |
| 322 | 322 | include_spip('action/editer_objet'); |
| 323 | - return objet_modifier($objet,$id_objet,$c); |
|
| 323 | + return objet_modifier($objet, $id_objet, $c); |
|
| 324 | 324 | } |
| 325 | 325 | |
| 326 | 326 | |
@@ -34,18 +34,18 @@ discard block |
||
| 34 | 34 | */ |
| 35 | 35 | function inc_securiser_action_dist($action='', $arg='', $redirect="", $mode=false, $att='', $public=false) |
| 36 | 36 | { |
| 37 | - if ($action) |
|
| 38 | - return securiser_action_auteur($action, $arg, $redirect, $mode, $att, $public); |
|
| 39 | - else { |
|
| 40 | - $arg = _request('arg'); |
|
| 41 | - $hash = _request('hash'); |
|
| 42 | - $action = _request('action')?_request('action'):_request('formulaire_action'); |
|
| 43 | - if ($a = verifier_action_auteur("$action-$arg", $hash)) |
|
| 44 | - return $arg; |
|
| 45 | - include_spip('inc/minipres'); |
|
| 46 | - echo minipres(); |
|
| 47 | - exit; |
|
| 48 | - } |
|
| 37 | + if ($action) |
|
| 38 | + return securiser_action_auteur($action, $arg, $redirect, $mode, $att, $public); |
|
| 39 | + else { |
|
| 40 | + $arg = _request('arg'); |
|
| 41 | + $hash = _request('hash'); |
|
| 42 | + $action = _request('action')?_request('action'):_request('formulaire_action'); |
|
| 43 | + if ($a = verifier_action_auteur("$action-$arg", $hash)) |
|
| 44 | + return $arg; |
|
| 45 | + include_spip('inc/minipres'); |
|
| 46 | + echo minipres(); |
|
| 47 | + exit; |
|
| 48 | + } |
|
| 49 | 49 | } |
| 50 | 50 | |
| 51 | 51 | /** |
@@ -68,27 +68,27 @@ discard block |
||
| 68 | 68 | */ |
| 69 | 69 | function securiser_action_auteur($action, $arg, $redirect="", $mode=false, $att='', $public=false) { |
| 70 | 70 | |
| 71 | - // mode URL ou array |
|
| 72 | - if (!is_string($mode)){ |
|
| 73 | - $hash = calculer_action_auteur("$action-$arg",is_numeric($att)?$att:null); |
|
| 71 | + // mode URL ou array |
|
| 72 | + if (!is_string($mode)){ |
|
| 73 | + $hash = calculer_action_auteur("$action-$arg",is_numeric($att)?$att:null); |
|
| 74 | 74 | |
| 75 | - $r = rawurlencode($redirect); |
|
| 76 | - if ($mode===-1) |
|
| 77 | - return array('action'=>$action,'arg'=>$arg,'hash'=>$hash); |
|
| 78 | - else |
|
| 79 | - return generer_url_action($action, "arg=$arg&hash=$hash" . (!$r ? '' : "&redirect=$r"), $mode, $public); |
|
| 80 | - } |
|
| 75 | + $r = rawurlencode($redirect); |
|
| 76 | + if ($mode===-1) |
|
| 77 | + return array('action'=>$action,'arg'=>$arg,'hash'=>$hash); |
|
| 78 | + else |
|
| 79 | + return generer_url_action($action, "arg=$arg&hash=$hash" . (!$r ? '' : "&redirect=$r"), $mode, $public); |
|
| 80 | + } |
|
| 81 | 81 | |
| 82 | - // mode formulaire |
|
| 83 | - $hash = calculer_action_auteur("$action-$arg"); |
|
| 84 | - $att .= " style='margin: 0px; border: 0px'"; |
|
| 85 | - if ($redirect) |
|
| 86 | - $redirect = "\n\t\t<input name='redirect' type='hidden' value='". str_replace("'", ''', $redirect) ."' />"; |
|
| 87 | - $mode .= $redirect . " |
|
| 82 | + // mode formulaire |
|
| 83 | + $hash = calculer_action_auteur("$action-$arg"); |
|
| 84 | + $att .= " style='margin: 0px; border: 0px'"; |
|
| 85 | + if ($redirect) |
|
| 86 | + $redirect = "\n\t\t<input name='redirect' type='hidden' value='". str_replace("'", ''', $redirect) ."' />"; |
|
| 87 | + $mode .= $redirect . " |
|
| 88 | 88 | <input name='hash' type='hidden' value='$hash' /> |
| 89 | 89 | <input name='arg' type='hidden' value='$arg' />"; |
| 90 | 90 | |
| 91 | - return generer_form_action($action, $mode, $att, $public); |
|
| 91 | + return generer_form_action($action, $mode, $att, $public); |
|
| 92 | 92 | } |
| 93 | 93 | |
| 94 | 94 | /** |
@@ -100,41 +100,41 @@ discard block |
||
| 100 | 100 | * @return array |
| 101 | 101 | */ |
| 102 | 102 | function caracteriser_auteur($id_auteur=null) { |
| 103 | - static $caracterisation = array(); |
|
| 103 | + static $caracterisation = array(); |
|
| 104 | 104 | |
| 105 | - if (is_null($id_auteur) AND !isset($GLOBALS['visiteur_session']['id_auteur'])) { |
|
| 106 | - // si l'auteur courant n'est pas connu alors qu'il peut demander une action |
|
| 107 | - // c'est une connexion par php_auth ou 1 instal, on se rabat sur le cookie. |
|
| 108 | - // S'il n'avait pas le droit de realiser cette action, le hash sera faux. |
|
| 109 | - if (isset($_COOKIE['spip_session']) |
|
| 110 | - AND (preg_match('/^(\d+)/',$_COOKIE['spip_session'],$r))) { |
|
| 111 | - return array($r[1], ''); |
|
| 112 | - // Necessaire aux forums anonymes. |
|
| 113 | - // Pour le reste, ca echouera. |
|
| 114 | - } else return array('0',''); |
|
| 115 | - } |
|
| 116 | - // Eviter l'acces SQL si le pass est connu de PHP |
|
| 117 | - if (is_null($id_auteur)){ |
|
| 118 | - $id_auteur = isset($GLOBALS['visiteur_session']['id_auteur'])?$GLOBALS['visiteur_session']['id_auteur']:0; |
|
| 119 | - if (isset($GLOBALS['visiteur_session']['pass']) AND $GLOBALS['visiteur_session']['pass']) |
|
| 120 | - return $caracterisation[$id_auteur] = array($id_auteur, $GLOBALS['visiteur_session']['pass']); |
|
| 121 | - } |
|
| 105 | + if (is_null($id_auteur) AND !isset($GLOBALS['visiteur_session']['id_auteur'])) { |
|
| 106 | + // si l'auteur courant n'est pas connu alors qu'il peut demander une action |
|
| 107 | + // c'est une connexion par php_auth ou 1 instal, on se rabat sur le cookie. |
|
| 108 | + // S'il n'avait pas le droit de realiser cette action, le hash sera faux. |
|
| 109 | + if (isset($_COOKIE['spip_session']) |
|
| 110 | + AND (preg_match('/^(\d+)/',$_COOKIE['spip_session'],$r))) { |
|
| 111 | + return array($r[1], ''); |
|
| 112 | + // Necessaire aux forums anonymes. |
|
| 113 | + // Pour le reste, ca echouera. |
|
| 114 | + } else return array('0',''); |
|
| 115 | + } |
|
| 116 | + // Eviter l'acces SQL si le pass est connu de PHP |
|
| 117 | + if (is_null($id_auteur)){ |
|
| 118 | + $id_auteur = isset($GLOBALS['visiteur_session']['id_auteur'])?$GLOBALS['visiteur_session']['id_auteur']:0; |
|
| 119 | + if (isset($GLOBALS['visiteur_session']['pass']) AND $GLOBALS['visiteur_session']['pass']) |
|
| 120 | + return $caracterisation[$id_auteur] = array($id_auteur, $GLOBALS['visiteur_session']['pass']); |
|
| 121 | + } |
|
| 122 | 122 | |
| 123 | - if (isset($caracterisation[$id_auteur])) return $caracterisation[$id_auteur]; |
|
| 123 | + if (isset($caracterisation[$id_auteur])) return $caracterisation[$id_auteur]; |
|
| 124 | 124 | |
| 125 | - if ($id_auteur) { |
|
| 126 | - include_spip('base/abstract_sql'); |
|
| 127 | - $t = sql_fetsel("id_auteur, pass", "spip_auteurs", "id_auteur=$id_auteur"); |
|
| 128 | - if ($t) |
|
| 129 | - return $caracterisation[$id_auteur] = array($t['id_auteur'], $t['pass']); |
|
| 130 | - include_spip('inc/minipres'); |
|
| 131 | - echo minipres(); |
|
| 132 | - exit; |
|
| 133 | - } |
|
| 134 | - // Visiteur anonyme, pour ls forums par exemple |
|
| 135 | - else { |
|
| 136 | - return array('0',''); |
|
| 137 | - } |
|
| 125 | + if ($id_auteur) { |
|
| 126 | + include_spip('base/abstract_sql'); |
|
| 127 | + $t = sql_fetsel("id_auteur, pass", "spip_auteurs", "id_auteur=$id_auteur"); |
|
| 128 | + if ($t) |
|
| 129 | + return $caracterisation[$id_auteur] = array($t['id_auteur'], $t['pass']); |
|
| 130 | + include_spip('inc/minipres'); |
|
| 131 | + echo minipres(); |
|
| 132 | + exit; |
|
| 133 | + } |
|
| 134 | + // Visiteur anonyme, pour ls forums par exemple |
|
| 135 | + else { |
|
| 136 | + return array('0',''); |
|
| 137 | + } |
|
| 138 | 138 | } |
| 139 | 139 | |
| 140 | 140 | /** |
@@ -151,25 +151,25 @@ discard block |
||
| 151 | 151 | * @return string |
| 152 | 152 | */ |
| 153 | 153 | function _action_auteur($action, $id_auteur, $pass, $alea) { |
| 154 | - static $sha = array(); |
|
| 155 | - if (!isset($sha[$id_auteur.$pass.$alea])){ |
|
| 156 | - if (!isset($GLOBALS['meta'][$alea]) AND _request('exec')!=='install') { |
|
| 157 | - include_spip('base/abstract_sql'); |
|
| 158 | - $GLOBALS['meta'][$alea] = sql_getfetsel('valeur', 'spip_meta', "nom=" . sql_quote($alea)); |
|
| 159 | - if (!($GLOBALS['meta'][$alea])) { |
|
| 160 | - include_spip('inc/minipres'); |
|
| 161 | - echo minipres(); |
|
| 162 | - spip_log("$alea indisponible"); |
|
| 163 | - exit; |
|
| 164 | - } |
|
| 165 | - } |
|
| 166 | - include_spip('auth/sha256.inc'); |
|
| 167 | - $sha[$id_auteur.$pass.$alea] = _nano_sha256($id_auteur.$pass.@$GLOBALS['meta'][$alea]); |
|
| 168 | - } |
|
| 169 | - if (function_exists('sha1')) |
|
| 170 | - return sha1($action.$sha[$id_auteur.$pass.$alea]); |
|
| 171 | - else |
|
| 172 | - return md5($action.$sha[$id_auteur.$pass.$alea]); |
|
| 154 | + static $sha = array(); |
|
| 155 | + if (!isset($sha[$id_auteur.$pass.$alea])){ |
|
| 156 | + if (!isset($GLOBALS['meta'][$alea]) AND _request('exec')!=='install') { |
|
| 157 | + include_spip('base/abstract_sql'); |
|
| 158 | + $GLOBALS['meta'][$alea] = sql_getfetsel('valeur', 'spip_meta', "nom=" . sql_quote($alea)); |
|
| 159 | + if (!($GLOBALS['meta'][$alea])) { |
|
| 160 | + include_spip('inc/minipres'); |
|
| 161 | + echo minipres(); |
|
| 162 | + spip_log("$alea indisponible"); |
|
| 163 | + exit; |
|
| 164 | + } |
|
| 165 | + } |
|
| 166 | + include_spip('auth/sha256.inc'); |
|
| 167 | + $sha[$id_auteur.$pass.$alea] = _nano_sha256($id_auteur.$pass.@$GLOBALS['meta'][$alea]); |
|
| 168 | + } |
|
| 169 | + if (function_exists('sha1')) |
|
| 170 | + return sha1($action.$sha[$id_auteur.$pass.$alea]); |
|
| 171 | + else |
|
| 172 | + return md5($action.$sha[$id_auteur.$pass.$alea]); |
|
| 173 | 173 | } |
| 174 | 174 | |
| 175 | 175 | /** |
@@ -181,8 +181,8 @@ discard block |
||
| 181 | 181 | * @return string |
| 182 | 182 | */ |
| 183 | 183 | function calculer_action_auteur($action, $id_auteur=null) { |
| 184 | - list($id_auteur, $pass) = caracteriser_auteur($id_auteur); |
|
| 185 | - return _action_auteur($action, $id_auteur, $pass, 'alea_ephemere'); |
|
| 184 | + list($id_auteur, $pass) = caracteriser_auteur($id_auteur); |
|
| 185 | + return _action_auteur($action, $id_auteur, $pass, 'alea_ephemere'); |
|
| 186 | 186 | } |
| 187 | 187 | |
| 188 | 188 | |
@@ -196,12 +196,12 @@ discard block |
||
| 196 | 196 | * @return bool |
| 197 | 197 | */ |
| 198 | 198 | function verifier_action_auteur($action, $hash) { |
| 199 | - list($id_auteur, $pass) = caracteriser_auteur(); |
|
| 200 | - if ($hash == _action_auteur($action, $id_auteur, $pass, 'alea_ephemere')) |
|
| 201 | - return true; |
|
| 202 | - if ($hash == _action_auteur($action, $id_auteur, $pass, 'alea_ephemere_ancien')) |
|
| 203 | - return true; |
|
| 204 | - return false; |
|
| 199 | + list($id_auteur, $pass) = caracteriser_auteur(); |
|
| 200 | + if ($hash == _action_auteur($action, $id_auteur, $pass, 'alea_ephemere')) |
|
| 201 | + return true; |
|
| 202 | + if ($hash == _action_auteur($action, $id_auteur, $pass, 'alea_ephemere_ancien')) |
|
| 203 | + return true; |
|
| 204 | + return false; |
|
| 205 | 205 | } |
| 206 | 206 | |
| 207 | 207 | // |
@@ -219,18 +219,18 @@ discard block |
||
| 219 | 219 | * @return string |
| 220 | 220 | */ |
| 221 | 221 | function secret_du_site() { |
| 222 | - if (!isset($GLOBALS['meta']['secret_du_site'])){ |
|
| 223 | - include_spip('base/abstract_sql'); |
|
| 224 | - $GLOBALS['meta']['secret_du_site'] = sql_getfetsel('valeur', 'spip_meta', "nom='secret_du_site'"); |
|
| 225 | - } |
|
| 226 | - if (!isset($GLOBALS['meta']['secret_du_site']) |
|
| 227 | - OR (strlen($GLOBALS['meta']['secret_du_site'])<64)) { |
|
| 228 | - include_spip('inc/acces'); |
|
| 229 | - include_spip('auth/sha256.inc'); |
|
| 230 | - ecrire_meta('secret_du_site', _nano_sha256($_SERVER["DOCUMENT_ROOT"] . $_SERVER["SERVER_SIGNATURE"] . creer_uniqid()), 'non'); |
|
| 231 | - lire_metas(); // au cas ou ecrire_meta() ne fonctionne pas |
|
| 232 | - } |
|
| 233 | - return $GLOBALS['meta']['secret_du_site']; |
|
| 222 | + if (!isset($GLOBALS['meta']['secret_du_site'])){ |
|
| 223 | + include_spip('base/abstract_sql'); |
|
| 224 | + $GLOBALS['meta']['secret_du_site'] = sql_getfetsel('valeur', 'spip_meta', "nom='secret_du_site'"); |
|
| 225 | + } |
|
| 226 | + if (!isset($GLOBALS['meta']['secret_du_site']) |
|
| 227 | + OR (strlen($GLOBALS['meta']['secret_du_site'])<64)) { |
|
| 228 | + include_spip('inc/acces'); |
|
| 229 | + include_spip('auth/sha256.inc'); |
|
| 230 | + ecrire_meta('secret_du_site', _nano_sha256($_SERVER["DOCUMENT_ROOT"] . $_SERVER["SERVER_SIGNATURE"] . creer_uniqid()), 'non'); |
|
| 231 | + lire_metas(); // au cas ou ecrire_meta() ne fonctionne pas |
|
| 232 | + } |
|
| 233 | + return $GLOBALS['meta']['secret_du_site']; |
|
| 234 | 234 | } |
| 235 | 235 | |
| 236 | 236 | /** |
@@ -241,10 +241,10 @@ discard block |
||
| 241 | 241 | * @return string |
| 242 | 242 | */ |
| 243 | 243 | function calculer_cle_action($action) { |
| 244 | - if (function_exists('sha1')) |
|
| 245 | - return sha1($action . secret_du_site()); |
|
| 246 | - else |
|
| 247 | - return md5($action . secret_du_site()); |
|
| 244 | + if (function_exists('sha1')) |
|
| 245 | + return sha1($action . secret_du_site()); |
|
| 246 | + else |
|
| 247 | + return md5($action . secret_du_site()); |
|
| 248 | 248 | } |
| 249 | 249 | |
| 250 | 250 | /** |
@@ -256,7 +256,7 @@ discard block |
||
| 256 | 256 | * @return bool |
| 257 | 257 | */ |
| 258 | 258 | function verifier_cle_action($action, $cle) { |
| 259 | - return ($cle == calculer_cle_action($action)); |
|
| 259 | + return ($cle == calculer_cle_action($action)); |
|
| 260 | 260 | } |
| 261 | 261 | |
| 262 | 262 | ?> |
@@ -10,7 +10,9 @@ discard block |
||
| 10 | 10 | * Pour plus de details voir le fichier COPYING.txt ou l'aide en ligne. * |
| 11 | 11 | \***************************************************************************/ |
| 12 | 12 | |
| 13 | -if (!defined('_ECRIRE_INC_VERSION')) return; |
|
| 13 | +if (!defined('_ECRIRE_INC_VERSION')) { |
|
| 14 | + return; |
|
| 15 | +} |
|
| 14 | 16 | |
| 15 | 17 | /** |
| 16 | 18 | * interface d'appel: |
@@ -34,14 +36,15 @@ discard block |
||
| 34 | 36 | */ |
| 35 | 37 | function inc_securiser_action_dist($action='', $arg='', $redirect="", $mode=false, $att='', $public=false) |
| 36 | 38 | { |
| 37 | - if ($action) |
|
| 38 | - return securiser_action_auteur($action, $arg, $redirect, $mode, $att, $public); |
|
| 39 | - else { |
|
| 39 | + if ($action) { |
|
| 40 | + return securiser_action_auteur($action, $arg, $redirect, $mode, $att, $public); |
|
| 41 | + } else { |
|
| 40 | 42 | $arg = _request('arg'); |
| 41 | 43 | $hash = _request('hash'); |
| 42 | 44 | $action = _request('action')?_request('action'):_request('formulaire_action'); |
| 43 | - if ($a = verifier_action_auteur("$action-$arg", $hash)) |
|
| 44 | - return $arg; |
|
| 45 | + if ($a = verifier_action_auteur("$action-$arg", $hash)) { |
|
| 46 | + return $arg; |
|
| 47 | + } |
|
| 45 | 48 | include_spip('inc/minipres'); |
| 46 | 49 | echo minipres(); |
| 47 | 50 | exit; |
@@ -73,17 +76,19 @@ discard block |
||
| 73 | 76 | $hash = calculer_action_auteur("$action-$arg",is_numeric($att)?$att:null); |
| 74 | 77 | |
| 75 | 78 | $r = rawurlencode($redirect); |
| 76 | - if ($mode===-1) |
|
| 77 | - return array('action'=>$action,'arg'=>$arg,'hash'=>$hash); |
|
| 78 | - else |
|
| 79 | - return generer_url_action($action, "arg=$arg&hash=$hash" . (!$r ? '' : "&redirect=$r"), $mode, $public); |
|
| 79 | + if ($mode===-1) { |
|
| 80 | + return array('action'=>$action,'arg'=>$arg,'hash'=>$hash); |
|
| 81 | + } else { |
|
| 82 | + return generer_url_action($action, "arg=$arg&hash=$hash" . (!$r ? '' : "&redirect=$r"), $mode, $public); |
|
| 83 | + } |
|
| 80 | 84 | } |
| 81 | 85 | |
| 82 | 86 | // mode formulaire |
| 83 | 87 | $hash = calculer_action_auteur("$action-$arg"); |
| 84 | 88 | $att .= " style='margin: 0px; border: 0px'"; |
| 85 | - if ($redirect) |
|
| 86 | - $redirect = "\n\t\t<input name='redirect' type='hidden' value='". str_replace("'", ''', $redirect) ."' />"; |
|
| 89 | + if ($redirect) { |
|
| 90 | + $redirect = "\n\t\t<input name='redirect' type='hidden' value='". str_replace("'", ''', $redirect) ."' />"; |
|
| 91 | + } |
|
| 87 | 92 | $mode .= $redirect . " |
| 88 | 93 | <input name='hash' type='hidden' value='$hash' /> |
| 89 | 94 | <input name='arg' type='hidden' value='$arg' />"; |
@@ -111,22 +116,28 @@ discard block |
||
| 111 | 116 | return array($r[1], ''); |
| 112 | 117 | // Necessaire aux forums anonymes. |
| 113 | 118 | // Pour le reste, ca echouera. |
| 114 | - } else return array('0',''); |
|
| 119 | + } else { |
|
| 120 | + return array('0',''); |
|
| 121 | + } |
|
| 115 | 122 | } |
| 116 | 123 | // Eviter l'acces SQL si le pass est connu de PHP |
| 117 | 124 | if (is_null($id_auteur)){ |
| 118 | 125 | $id_auteur = isset($GLOBALS['visiteur_session']['id_auteur'])?$GLOBALS['visiteur_session']['id_auteur']:0; |
| 119 | - if (isset($GLOBALS['visiteur_session']['pass']) AND $GLOBALS['visiteur_session']['pass']) |
|
| 120 | - return $caracterisation[$id_auteur] = array($id_auteur, $GLOBALS['visiteur_session']['pass']); |
|
| 126 | + if (isset($GLOBALS['visiteur_session']['pass']) AND $GLOBALS['visiteur_session']['pass']) { |
|
| 127 | + return $caracterisation[$id_auteur] = array($id_auteur, $GLOBALS['visiteur_session']['pass']); |
|
| 128 | + } |
|
| 121 | 129 | } |
| 122 | 130 | |
| 123 | - if (isset($caracterisation[$id_auteur])) return $caracterisation[$id_auteur]; |
|
| 131 | + if (isset($caracterisation[$id_auteur])) { |
|
| 132 | + return $caracterisation[$id_auteur]; |
|
| 133 | + } |
|
| 124 | 134 | |
| 125 | 135 | if ($id_auteur) { |
| 126 | 136 | include_spip('base/abstract_sql'); |
| 127 | 137 | $t = sql_fetsel("id_auteur, pass", "spip_auteurs", "id_auteur=$id_auteur"); |
| 128 | - if ($t) |
|
| 129 | - return $caracterisation[$id_auteur] = array($t['id_auteur'], $t['pass']); |
|
| 138 | + if ($t) { |
|
| 139 | + return $caracterisation[$id_auteur] = array($t['id_auteur'], $t['pass']); |
|
| 140 | + } |
|
| 130 | 141 | include_spip('inc/minipres'); |
| 131 | 142 | echo minipres(); |
| 132 | 143 | exit; |
@@ -166,11 +177,12 @@ discard block |
||
| 166 | 177 | include_spip('auth/sha256.inc'); |
| 167 | 178 | $sha[$id_auteur.$pass.$alea] = _nano_sha256($id_auteur.$pass.@$GLOBALS['meta'][$alea]); |
| 168 | 179 | } |
| 169 | - if (function_exists('sha1')) |
|
| 170 | - return sha1($action.$sha[$id_auteur.$pass.$alea]); |
|
| 171 | - else |
|
| 172 | - return md5($action.$sha[$id_auteur.$pass.$alea]); |
|
| 173 | -} |
|
| 180 | + if (function_exists('sha1')) { |
|
| 181 | + return sha1($action.$sha[$id_auteur.$pass.$alea]); |
|
| 182 | + } else { |
|
| 183 | + return md5($action.$sha[$id_auteur.$pass.$alea]); |
|
| 184 | + } |
|
| 185 | + } |
|
| 174 | 186 | |
| 175 | 187 | /** |
| 176 | 188 | * Calculer le hash qui signe une action pour un auteur |
@@ -197,10 +209,12 @@ discard block |
||
| 197 | 209 | */ |
| 198 | 210 | function verifier_action_auteur($action, $hash) { |
| 199 | 211 | list($id_auteur, $pass) = caracteriser_auteur(); |
| 200 | - if ($hash == _action_auteur($action, $id_auteur, $pass, 'alea_ephemere')) |
|
| 201 | - return true; |
|
| 202 | - if ($hash == _action_auteur($action, $id_auteur, $pass, 'alea_ephemere_ancien')) |
|
| 203 | - return true; |
|
| 212 | + if ($hash == _action_auteur($action, $id_auteur, $pass, 'alea_ephemere')) { |
|
| 213 | + return true; |
|
| 214 | + } |
|
| 215 | + if ($hash == _action_auteur($action, $id_auteur, $pass, 'alea_ephemere_ancien')) { |
|
| 216 | + return true; |
|
| 217 | + } |
|
| 204 | 218 | return false; |
| 205 | 219 | } |
| 206 | 220 | |
@@ -241,11 +255,12 @@ discard block |
||
| 241 | 255 | * @return string |
| 242 | 256 | */ |
| 243 | 257 | function calculer_cle_action($action) { |
| 244 | - if (function_exists('sha1')) |
|
| 245 | - return sha1($action . secret_du_site()); |
|
| 246 | - else |
|
| 247 | - return md5($action . secret_du_site()); |
|
| 248 | -} |
|
| 258 | + if (function_exists('sha1')) { |
|
| 259 | + return sha1($action . secret_du_site()); |
|
| 260 | + } else { |
|
| 261 | + return md5($action . secret_du_site()); |
|
| 262 | + } |
|
| 263 | + } |
|
| 249 | 264 | |
| 250 | 265 | /** |
| 251 | 266 | * Verifier la cle de signature d'une action valable pour le site |
@@ -32,14 +32,14 @@ discard block |
||
| 32 | 32 | * @param bool $public |
| 33 | 33 | * @return array|string |
| 34 | 34 | */ |
| 35 | -function inc_securiser_action_dist($action='', $arg='', $redirect="", $mode=false, $att='', $public=false) |
|
| 35 | +function inc_securiser_action_dist($action = '', $arg = '', $redirect = "", $mode = false, $att = '', $public = false) |
|
| 36 | 36 | { |
| 37 | 37 | if ($action) |
| 38 | 38 | return securiser_action_auteur($action, $arg, $redirect, $mode, $att, $public); |
| 39 | 39 | else { |
| 40 | 40 | $arg = _request('arg'); |
| 41 | 41 | $hash = _request('hash'); |
| 42 | - $action = _request('action')?_request('action'):_request('formulaire_action'); |
|
| 42 | + $action = _request('action') ?_request('action') : _request('formulaire_action'); |
|
| 43 | 43 | if ($a = verifier_action_auteur("$action-$arg", $hash)) |
| 44 | 44 | return $arg; |
| 45 | 45 | include_spip('inc/minipres'); |
@@ -66,25 +66,25 @@ discard block |
||
| 66 | 66 | * @param bool $public |
| 67 | 67 | * @return array|string |
| 68 | 68 | */ |
| 69 | -function securiser_action_auteur($action, $arg, $redirect="", $mode=false, $att='', $public=false) { |
|
| 69 | +function securiser_action_auteur($action, $arg, $redirect = "", $mode = false, $att = '', $public = false) { |
|
| 70 | 70 | |
| 71 | 71 | // mode URL ou array |
| 72 | - if (!is_string($mode)){ |
|
| 73 | - $hash = calculer_action_auteur("$action-$arg",is_numeric($att)?$att:null); |
|
| 72 | + if (!is_string($mode)) { |
|
| 73 | + $hash = calculer_action_auteur("$action-$arg", is_numeric($att) ? $att : null); |
|
| 74 | 74 | |
| 75 | 75 | $r = rawurlencode($redirect); |
| 76 | - if ($mode===-1) |
|
| 77 | - return array('action'=>$action,'arg'=>$arg,'hash'=>$hash); |
|
| 76 | + if ($mode === -1) |
|
| 77 | + return array('action'=>$action, 'arg'=>$arg, 'hash'=>$hash); |
|
| 78 | 78 | else |
| 79 | - return generer_url_action($action, "arg=$arg&hash=$hash" . (!$r ? '' : "&redirect=$r"), $mode, $public); |
|
| 79 | + return generer_url_action($action, "arg=$arg&hash=$hash".(!$r ? '' : "&redirect=$r"), $mode, $public); |
|
| 80 | 80 | } |
| 81 | 81 | |
| 82 | 82 | // mode formulaire |
| 83 | 83 | $hash = calculer_action_auteur("$action-$arg"); |
| 84 | 84 | $att .= " style='margin: 0px; border: 0px'"; |
| 85 | 85 | if ($redirect) |
| 86 | - $redirect = "\n\t\t<input name='redirect' type='hidden' value='". str_replace("'", ''', $redirect) ."' />"; |
|
| 87 | - $mode .= $redirect . " |
|
| 86 | + $redirect = "\n\t\t<input name='redirect' type='hidden' value='".str_replace("'", ''', $redirect)."' />"; |
|
| 87 | + $mode .= $redirect." |
|
| 88 | 88 | <input name='hash' type='hidden' value='$hash' /> |
| 89 | 89 | <input name='arg' type='hidden' value='$arg' />"; |
| 90 | 90 | |
@@ -99,7 +99,7 @@ discard block |
||
| 99 | 99 | * @param int|null $id_auteur |
| 100 | 100 | * @return array |
| 101 | 101 | */ |
| 102 | -function caracteriser_auteur($id_auteur=null) { |
|
| 102 | +function caracteriser_auteur($id_auteur = null) { |
|
| 103 | 103 | static $caracterisation = array(); |
| 104 | 104 | |
| 105 | 105 | if (is_null($id_auteur) AND !isset($GLOBALS['visiteur_session']['id_auteur'])) { |
@@ -107,15 +107,15 @@ discard block |
||
| 107 | 107 | // c'est une connexion par php_auth ou 1 instal, on se rabat sur le cookie. |
| 108 | 108 | // S'il n'avait pas le droit de realiser cette action, le hash sera faux. |
| 109 | 109 | if (isset($_COOKIE['spip_session']) |
| 110 | - AND (preg_match('/^(\d+)/',$_COOKIE['spip_session'],$r))) { |
|
| 110 | + AND (preg_match('/^(\d+)/', $_COOKIE['spip_session'], $r))) { |
|
| 111 | 111 | return array($r[1], ''); |
| 112 | 112 | // Necessaire aux forums anonymes. |
| 113 | 113 | // Pour le reste, ca echouera. |
| 114 | - } else return array('0',''); |
|
| 114 | + } else return array('0', ''); |
|
| 115 | 115 | } |
| 116 | 116 | // Eviter l'acces SQL si le pass est connu de PHP |
| 117 | - if (is_null($id_auteur)){ |
|
| 118 | - $id_auteur = isset($GLOBALS['visiteur_session']['id_auteur'])?$GLOBALS['visiteur_session']['id_auteur']:0; |
|
| 117 | + if (is_null($id_auteur)) { |
|
| 118 | + $id_auteur = isset($GLOBALS['visiteur_session']['id_auteur']) ? $GLOBALS['visiteur_session']['id_auteur'] : 0; |
|
| 119 | 119 | if (isset($GLOBALS['visiteur_session']['pass']) AND $GLOBALS['visiteur_session']['pass']) |
| 120 | 120 | return $caracterisation[$id_auteur] = array($id_auteur, $GLOBALS['visiteur_session']['pass']); |
| 121 | 121 | } |
@@ -133,7 +133,7 @@ discard block |
||
| 133 | 133 | } |
| 134 | 134 | // Visiteur anonyme, pour ls forums par exemple |
| 135 | 135 | else { |
| 136 | - return array('0',''); |
|
| 136 | + return array('0', ''); |
|
| 137 | 137 | } |
| 138 | 138 | } |
| 139 | 139 | |
@@ -152,10 +152,10 @@ discard block |
||
| 152 | 152 | */ |
| 153 | 153 | function _action_auteur($action, $id_auteur, $pass, $alea) { |
| 154 | 154 | static $sha = array(); |
| 155 | - if (!isset($sha[$id_auteur.$pass.$alea])){ |
|
| 156 | - if (!isset($GLOBALS['meta'][$alea]) AND _request('exec')!=='install') { |
|
| 155 | + if (!isset($sha[$id_auteur.$pass.$alea])) { |
|
| 156 | + if (!isset($GLOBALS['meta'][$alea]) AND _request('exec') !== 'install') { |
|
| 157 | 157 | include_spip('base/abstract_sql'); |
| 158 | - $GLOBALS['meta'][$alea] = sql_getfetsel('valeur', 'spip_meta', "nom=" . sql_quote($alea)); |
|
| 158 | + $GLOBALS['meta'][$alea] = sql_getfetsel('valeur', 'spip_meta', "nom=".sql_quote($alea)); |
|
| 159 | 159 | if (!($GLOBALS['meta'][$alea])) { |
| 160 | 160 | include_spip('inc/minipres'); |
| 161 | 161 | echo minipres(); |
@@ -180,7 +180,7 @@ discard block |
||
| 180 | 180 | * @param int|null $id_auteur |
| 181 | 181 | * @return string |
| 182 | 182 | */ |
| 183 | -function calculer_action_auteur($action, $id_auteur=null) { |
|
| 183 | +function calculer_action_auteur($action, $id_auteur = null) { |
|
| 184 | 184 | list($id_auteur, $pass) = caracteriser_auteur($id_auteur); |
| 185 | 185 | return _action_auteur($action, $id_auteur, $pass, 'alea_ephemere'); |
| 186 | 186 | } |
@@ -219,15 +219,15 @@ discard block |
||
| 219 | 219 | * @return string |
| 220 | 220 | */ |
| 221 | 221 | function secret_du_site() { |
| 222 | - if (!isset($GLOBALS['meta']['secret_du_site'])){ |
|
| 222 | + if (!isset($GLOBALS['meta']['secret_du_site'])) { |
|
| 223 | 223 | include_spip('base/abstract_sql'); |
| 224 | 224 | $GLOBALS['meta']['secret_du_site'] = sql_getfetsel('valeur', 'spip_meta', "nom='secret_du_site'"); |
| 225 | 225 | } |
| 226 | 226 | if (!isset($GLOBALS['meta']['secret_du_site']) |
| 227 | - OR (strlen($GLOBALS['meta']['secret_du_site'])<64)) { |
|
| 227 | + OR (strlen($GLOBALS['meta']['secret_du_site']) < 64)) { |
|
| 228 | 228 | include_spip('inc/acces'); |
| 229 | 229 | include_spip('auth/sha256.inc'); |
| 230 | - ecrire_meta('secret_du_site', _nano_sha256($_SERVER["DOCUMENT_ROOT"] . $_SERVER["SERVER_SIGNATURE"] . creer_uniqid()), 'non'); |
|
| 230 | + ecrire_meta('secret_du_site', _nano_sha256($_SERVER["DOCUMENT_ROOT"].$_SERVER["SERVER_SIGNATURE"].creer_uniqid()), 'non'); |
|
| 231 | 231 | lire_metas(); // au cas ou ecrire_meta() ne fonctionne pas |
| 232 | 232 | } |
| 233 | 233 | return $GLOBALS['meta']['secret_du_site']; |
@@ -242,9 +242,9 @@ discard block |
||
| 242 | 242 | */ |
| 243 | 243 | function calculer_cle_action($action) { |
| 244 | 244 | if (function_exists('sha1')) |
| 245 | - return sha1($action . secret_du_site()); |
|
| 245 | + return sha1($action.secret_du_site()); |
|
| 246 | 246 | else |
| 247 | - return md5($action . secret_du_site()); |
|
| 247 | + return md5($action.secret_du_site()); |
|
| 248 | 248 | } |
| 249 | 249 | |
| 250 | 250 | /** |
@@ -14,69 +14,69 @@ discard block |
||
| 14 | 14 | |
| 15 | 15 | // http://doc.spip.org/@cadre_depliable |
| 16 | 16 | function cadre_depliable($icone,$titre,$deplie,$contenu,$ids='',$style_cadre='r'){ |
| 17 | - $bouton = bouton_block_depliable($titre,$deplie,$ids); |
|
| 18 | - return |
|
| 19 | - debut_cadre($style_cadre,$icone,'',$bouton, '', '', false) |
|
| 20 | - . debut_block_depliable($deplie,$ids) |
|
| 21 | - . "<div class='cadre_padding'>\n" |
|
| 22 | - . $contenu |
|
| 23 | - . "</div>\n" |
|
| 24 | - . fin_block() |
|
| 25 | - . fin_cadre(); |
|
| 17 | + $bouton = bouton_block_depliable($titre,$deplie,$ids); |
|
| 18 | + return |
|
| 19 | + debut_cadre($style_cadre,$icone,'',$bouton, '', '', false) |
|
| 20 | + . debut_block_depliable($deplie,$ids) |
|
| 21 | + . "<div class='cadre_padding'>\n" |
|
| 22 | + . $contenu |
|
| 23 | + . "</div>\n" |
|
| 24 | + . fin_block() |
|
| 25 | + . fin_cadre(); |
|
| 26 | 26 | } |
| 27 | 27 | |
| 28 | 28 | // http://doc.spip.org/@block_parfois_visible |
| 29 | 29 | function block_parfois_visible($nom, $invite, $masque, $style='', $visible=false){ |
| 30 | - return "\n" |
|
| 31 | - . bouton_block_depliable($invite,$visible,$nom) |
|
| 32 | - . debut_block_depliable($visible,$nom) |
|
| 33 | - . $masque |
|
| 34 | - . fin_block(); |
|
| 30 | + return "\n" |
|
| 31 | + . bouton_block_depliable($invite,$visible,$nom) |
|
| 32 | + . debut_block_depliable($visible,$nom) |
|
| 33 | + . $masque |
|
| 34 | + . fin_block(); |
|
| 35 | 35 | } |
| 36 | 36 | |
| 37 | 37 | // http://doc.spip.org/@debut_block_depliable |
| 38 | 38 | function debut_block_depliable($deplie,$id=""){ |
| 39 | - $class=' blocdeplie'; |
|
| 40 | - // si on n'accepte pas js, ne pas fermer |
|
| 41 | - if (!$deplie) |
|
| 42 | - $class=" blocreplie"; |
|
| 43 | - return "<div ".($id?"id='$id' ":"")."class='bloc_depliable$class'>"; |
|
| 39 | + $class=' blocdeplie'; |
|
| 40 | + // si on n'accepte pas js, ne pas fermer |
|
| 41 | + if (!$deplie) |
|
| 42 | + $class=" blocreplie"; |
|
| 43 | + return "<div ".($id?"id='$id' ":"")."class='bloc_depliable$class'>"; |
|
| 44 | 44 | } |
| 45 | 45 | // http://doc.spip.org/@fin_block |
| 46 | 46 | function fin_block() { |
| 47 | - return "<div class='nettoyeur'></div>\n</div>"; |
|
| 47 | + return "<div class='nettoyeur'></div>\n</div>"; |
|
| 48 | 48 | } |
| 49 | 49 | // $texte : texte du bouton |
| 50 | 50 | // $deplie : true (deplie) ou false (plie) ou -1 (inactif) ou 'incertain' pour que le bouton s'auto init au chargement de la page |
| 51 | 51 | // $ids : id des div lies au bouton (facultatif, par defaut c'est le div.bloc_depliable qui suit) |
| 52 | 52 | // http://doc.spip.org/@bouton_block_depliable |
| 53 | 53 | function bouton_block_depliable($texte,$deplie,$ids=""){ |
| 54 | - $bouton_id = 'b'.substr(md5($texte.microtime()),0,8); |
|
| 54 | + $bouton_id = 'b'.substr(md5($texte.microtime()),0,8); |
|
| 55 | 55 | |
| 56 | - $class = ($deplie===true)?" deplie":(($deplie==-1)?" impliable":" replie"); |
|
| 57 | - if (strlen($ids)){ |
|
| 58 | - $cible = explode(',',$ids); |
|
| 59 | - $cible = '#'.implode(",#",$cible); |
|
| 60 | - } |
|
| 61 | - else{ |
|
| 62 | - $cible = "#$bouton_id + div.bloc_depliable"; |
|
| 63 | - } |
|
| 56 | + $class = ($deplie===true)?" deplie":(($deplie==-1)?" impliable":" replie"); |
|
| 57 | + if (strlen($ids)){ |
|
| 58 | + $cible = explode(',',$ids); |
|
| 59 | + $cible = '#'.implode(",#",$cible); |
|
| 60 | + } |
|
| 61 | + else{ |
|
| 62 | + $cible = "#$bouton_id + div.bloc_depliable"; |
|
| 63 | + } |
|
| 64 | 64 | |
| 65 | - $b = (strpos($texte,"<h")===false?'h3':'div'); |
|
| 66 | - return "<$b " |
|
| 67 | - .($bouton_id?"id='$bouton_id' ":"") |
|
| 68 | - ."class='titrem$class'" |
|
| 69 | - . (($deplie===-1) |
|
| 70 | - ?"" |
|
| 71 | - :" onmouseover=\"jQuery(this).depliant('$cible');\"" |
|
| 72 | - ) |
|
| 73 | - .">" |
|
| 74 | - // une ancre pour rendre accessible au clavier le depliage du sous bloc |
|
| 75 | - . "<a href='#' onclick=\"return jQuery(this).depliant_clicancre('$cible');\" class='titremancre'></a>" |
|
| 76 | - . "$texte</$b>" |
|
| 77 | - . http_script( ($deplie==='incertain') |
|
| 78 | - ? "jQuery(document).ready(function(){if (jQuery('$cible').is(':visible')) $('#$bouton_id').addClass('deplie').removeClass('replie');});" |
|
| 79 | - : ''); |
|
| 65 | + $b = (strpos($texte,"<h")===false?'h3':'div'); |
|
| 66 | + return "<$b " |
|
| 67 | + .($bouton_id?"id='$bouton_id' ":"") |
|
| 68 | + ."class='titrem$class'" |
|
| 69 | + . (($deplie===-1) |
|
| 70 | + ?"" |
|
| 71 | + :" onmouseover=\"jQuery(this).depliant('$cible');\"" |
|
| 72 | + ) |
|
| 73 | + .">" |
|
| 74 | + // une ancre pour rendre accessible au clavier le depliage du sous bloc |
|
| 75 | + . "<a href='#' onclick=\"return jQuery(this).depliant_clicancre('$cible');\" class='titremancre'></a>" |
|
| 76 | + . "$texte</$b>" |
|
| 77 | + . http_script( ($deplie==='incertain') |
|
| 78 | + ? "jQuery(document).ready(function(){if (jQuery('$cible').is(':visible')) $('#$bouton_id').addClass('deplie').removeClass('replie');});" |
|
| 79 | + : ''); |
|
| 80 | 80 | } |
| 81 | 81 | |
| 82 | 82 | // |
@@ -85,51 +85,51 @@ discard block |
||
| 85 | 85 | // http://doc.spip.org/@verif_butineur |
| 86 | 86 | function verif_butineur() { |
| 87 | 87 | |
| 88 | - global $browser_name, $browser_version; |
|
| 89 | - global $browser_description, $browser_rev, $browser_barre; |
|
| 90 | - preg_match(",^([A-Za-z]+)/([0-9]+\.[0-9]+) (.*)$,", $_SERVER['HTTP_USER_AGENT'], $match); |
|
| 91 | - $browser_name = $match[1]; |
|
| 92 | - $browser_version = $match[2]; |
|
| 93 | - $browser_description = $match[3]; |
|
| 94 | - $GLOBALS['browser_layer'] = ' '; // compat avec vieux scripts qui testent la valeur |
|
| 95 | - $browser_barre = ''; |
|
| 88 | + global $browser_name, $browser_version; |
|
| 89 | + global $browser_description, $browser_rev, $browser_barre; |
|
| 90 | + preg_match(",^([A-Za-z]+)/([0-9]+\.[0-9]+) (.*)$,", $_SERVER['HTTP_USER_AGENT'], $match); |
|
| 91 | + $browser_name = $match[1]; |
|
| 92 | + $browser_version = $match[2]; |
|
| 93 | + $browser_description = $match[3]; |
|
| 94 | + $GLOBALS['browser_layer'] = ' '; // compat avec vieux scripts qui testent la valeur |
|
| 95 | + $browser_barre = ''; |
|
| 96 | 96 | |
| 97 | - if (!preg_match(",opera,i", $browser_description)&&preg_match(",opera,i", $browser_name)) { |
|
| 98 | - $browser_name = "Opera"; |
|
| 99 | - $browser_version = $match[2]; |
|
| 100 | - $browser_barre = ($browser_version >= 8.5); |
|
| 101 | - } |
|
| 102 | - else if (preg_match(",opera,i", $browser_description)) { |
|
| 103 | - preg_match(",Opera ([^\ ]*),i", $browser_description, $match); |
|
| 104 | - $browser_name = "Opera"; |
|
| 105 | - $browser_version = $match[1]; |
|
| 106 | - $browser_barre = ($browser_version >= 8.5); |
|
| 107 | - } |
|
| 108 | - else if (preg_match(",msie,i", $browser_description)) { |
|
| 109 | - preg_match(",MSIE ([^;]*),i", $browser_description, $match); |
|
| 110 | - $browser_name = "MSIE"; |
|
| 111 | - $browser_version = $match[1]; |
|
| 112 | - $browser_barre = ($browser_version >= 5.5); |
|
| 113 | - } |
|
| 114 | - else if (preg_match(",KHTML,i", $browser_description) && |
|
| 115 | - preg_match(",Safari/([^;]*),", $browser_description, $match)) { |
|
| 116 | - $browser_name = "Safari"; |
|
| 117 | - $browser_version = $match[1]; |
|
| 118 | - $browser_barre = ($browser_version >= 5.0); |
|
| 119 | - } |
|
| 120 | - else if (preg_match(",mozilla,i", $browser_name) AND $browser_version >= 5) { |
|
| 121 | - // Numero de version pour Mozilla "authentique" |
|
| 122 | - if (preg_match(",rv:([0-9]+\.[0-9]+),", $browser_description, $match)) |
|
| 123 | - $browser_rev = doubleval($match[1]); |
|
| 124 | - // Autres Gecko => equivalents 1.4 par defaut (Galeon, etc.) |
|
| 125 | - else if (strpos($browser_description, "Gecko") and !strpos($browser_description, "KHTML")) |
|
| 126 | - $browser_rev = 1.4; |
|
| 127 | - // Machins quelconques => equivalents 1.0 par defaut (Konqueror, etc.) |
|
| 128 | - else $browser_rev = 1.0; |
|
| 129 | - $browser_barre = $browser_rev >= 1.3; |
|
| 130 | - } |
|
| 97 | + if (!preg_match(",opera,i", $browser_description)&&preg_match(",opera,i", $browser_name)) { |
|
| 98 | + $browser_name = "Opera"; |
|
| 99 | + $browser_version = $match[2]; |
|
| 100 | + $browser_barre = ($browser_version >= 8.5); |
|
| 101 | + } |
|
| 102 | + else if (preg_match(",opera,i", $browser_description)) { |
|
| 103 | + preg_match(",Opera ([^\ ]*),i", $browser_description, $match); |
|
| 104 | + $browser_name = "Opera"; |
|
| 105 | + $browser_version = $match[1]; |
|
| 106 | + $browser_barre = ($browser_version >= 8.5); |
|
| 107 | + } |
|
| 108 | + else if (preg_match(",msie,i", $browser_description)) { |
|
| 109 | + preg_match(",MSIE ([^;]*),i", $browser_description, $match); |
|
| 110 | + $browser_name = "MSIE"; |
|
| 111 | + $browser_version = $match[1]; |
|
| 112 | + $browser_barre = ($browser_version >= 5.5); |
|
| 113 | + } |
|
| 114 | + else if (preg_match(",KHTML,i", $browser_description) && |
|
| 115 | + preg_match(",Safari/([^;]*),", $browser_description, $match)) { |
|
| 116 | + $browser_name = "Safari"; |
|
| 117 | + $browser_version = $match[1]; |
|
| 118 | + $browser_barre = ($browser_version >= 5.0); |
|
| 119 | + } |
|
| 120 | + else if (preg_match(",mozilla,i", $browser_name) AND $browser_version >= 5) { |
|
| 121 | + // Numero de version pour Mozilla "authentique" |
|
| 122 | + if (preg_match(",rv:([0-9]+\.[0-9]+),", $browser_description, $match)) |
|
| 123 | + $browser_rev = doubleval($match[1]); |
|
| 124 | + // Autres Gecko => equivalents 1.4 par defaut (Galeon, etc.) |
|
| 125 | + else if (strpos($browser_description, "Gecko") and !strpos($browser_description, "KHTML")) |
|
| 126 | + $browser_rev = 1.4; |
|
| 127 | + // Machins quelconques => equivalents 1.0 par defaut (Konqueror, etc.) |
|
| 128 | + else $browser_rev = 1.0; |
|
| 129 | + $browser_barre = $browser_rev >= 1.3; |
|
| 130 | + } |
|
| 131 | 131 | |
| 132 | - if (!$browser_name) $browser_name = "Mozilla"; |
|
| 132 | + if (!$browser_name) $browser_name = "Mozilla"; |
|
| 133 | 133 | } |
| 134 | 134 | |
| 135 | 135 | verif_butineur(); |
@@ -13,11 +13,11 @@ discard block |
||
| 13 | 13 | if (!defined('_ECRIRE_INC_VERSION')) return; |
| 14 | 14 | |
| 15 | 15 | // http://doc.spip.org/@cadre_depliable |
| 16 | -function cadre_depliable($icone,$titre,$deplie,$contenu,$ids='',$style_cadre='r'){ |
|
| 17 | - $bouton = bouton_block_depliable($titre,$deplie,$ids); |
|
| 16 | +function cadre_depliable($icone, $titre, $deplie, $contenu, $ids = '', $style_cadre = 'r') { |
|
| 17 | + $bouton = bouton_block_depliable($titre, $deplie, $ids); |
|
| 18 | 18 | return |
| 19 | - debut_cadre($style_cadre,$icone,'',$bouton, '', '', false) |
|
| 20 | - . debut_block_depliable($deplie,$ids) |
|
| 19 | + debut_cadre($style_cadre, $icone, '', $bouton, '', '', false) |
|
| 20 | + . debut_block_depliable($deplie, $ids) |
|
| 21 | 21 | . "<div class='cadre_padding'>\n" |
| 22 | 22 | . $contenu |
| 23 | 23 | . "</div>\n" |
@@ -26,21 +26,21 @@ discard block |
||
| 26 | 26 | } |
| 27 | 27 | |
| 28 | 28 | // http://doc.spip.org/@block_parfois_visible |
| 29 | -function block_parfois_visible($nom, $invite, $masque, $style='', $visible=false){ |
|
| 29 | +function block_parfois_visible($nom, $invite, $masque, $style = '', $visible = false) { |
|
| 30 | 30 | return "\n" |
| 31 | - . bouton_block_depliable($invite,$visible,$nom) |
|
| 32 | - . debut_block_depliable($visible,$nom) |
|
| 31 | + . bouton_block_depliable($invite, $visible, $nom) |
|
| 32 | + . debut_block_depliable($visible, $nom) |
|
| 33 | 33 | . $masque |
| 34 | 34 | . fin_block(); |
| 35 | 35 | } |
| 36 | 36 | |
| 37 | 37 | // http://doc.spip.org/@debut_block_depliable |
| 38 | -function debut_block_depliable($deplie,$id=""){ |
|
| 39 | - $class=' blocdeplie'; |
|
| 38 | +function debut_block_depliable($deplie, $id = "") { |
|
| 39 | + $class = ' blocdeplie'; |
|
| 40 | 40 | // si on n'accepte pas js, ne pas fermer |
| 41 | 41 | if (!$deplie) |
| 42 | - $class=" blocreplie"; |
|
| 43 | - return "<div ".($id?"id='$id' ":"")."class='bloc_depliable$class'>"; |
|
| 42 | + $class = " blocreplie"; |
|
| 43 | + return "<div ".($id ? "id='$id' " : "")."class='bloc_depliable$class'>"; |
|
| 44 | 44 | } |
| 45 | 45 | // http://doc.spip.org/@fin_block |
| 46 | 46 | function fin_block() { |
@@ -50,31 +50,31 @@ discard block |
||
| 50 | 50 | // $deplie : true (deplie) ou false (plie) ou -1 (inactif) ou 'incertain' pour que le bouton s'auto init au chargement de la page |
| 51 | 51 | // $ids : id des div lies au bouton (facultatif, par defaut c'est le div.bloc_depliable qui suit) |
| 52 | 52 | // http://doc.spip.org/@bouton_block_depliable |
| 53 | -function bouton_block_depliable($texte,$deplie,$ids=""){ |
|
| 54 | - $bouton_id = 'b'.substr(md5($texte.microtime()),0,8); |
|
| 53 | +function bouton_block_depliable($texte, $deplie, $ids = "") { |
|
| 54 | + $bouton_id = 'b'.substr(md5($texte.microtime()), 0, 8); |
|
| 55 | 55 | |
| 56 | - $class = ($deplie===true)?" deplie":(($deplie==-1)?" impliable":" replie"); |
|
| 57 | - if (strlen($ids)){ |
|
| 58 | - $cible = explode(',',$ids); |
|
| 59 | - $cible = '#'.implode(",#",$cible); |
|
| 56 | + $class = ($deplie === true) ? " deplie" : (($deplie == -1) ? " impliable" : " replie"); |
|
| 57 | + if (strlen($ids)) { |
|
| 58 | + $cible = explode(',', $ids); |
|
| 59 | + $cible = '#'.implode(",#", $cible); |
|
| 60 | 60 | } |
| 61 | - else{ |
|
| 61 | + else { |
|
| 62 | 62 | $cible = "#$bouton_id + div.bloc_depliable"; |
| 63 | 63 | } |
| 64 | 64 | |
| 65 | - $b = (strpos($texte,"<h")===false?'h3':'div'); |
|
| 65 | + $b = (strpos($texte, "<h") === false ? 'h3' : 'div'); |
|
| 66 | 66 | return "<$b " |
| 67 | - .($bouton_id?"id='$bouton_id' ":"") |
|
| 67 | + .($bouton_id ? "id='$bouton_id' " : "") |
|
| 68 | 68 | ."class='titrem$class'" |
| 69 | - . (($deplie===-1) |
|
| 70 | - ?"" |
|
| 69 | + . (($deplie === -1) |
|
| 70 | + ? "" |
|
| 71 | 71 | :" onmouseover=\"jQuery(this).depliant('$cible');\"" |
| 72 | 72 | ) |
| 73 | 73 | .">" |
| 74 | 74 | // une ancre pour rendre accessible au clavier le depliage du sous bloc |
| 75 | 75 | . "<a href='#' onclick=\"return jQuery(this).depliant_clicancre('$cible');\" class='titremancre'></a>" |
| 76 | 76 | . "$texte</$b>" |
| 77 | - . http_script( ($deplie==='incertain') |
|
| 77 | + . http_script(($deplie === 'incertain') |
|
| 78 | 78 | ? "jQuery(document).ready(function(){if (jQuery('$cible').is(':visible')) $('#$bouton_id').addClass('deplie').removeClass('replie');});" |
| 79 | 79 | : ''); |
| 80 | 80 | } |
@@ -94,7 +94,7 @@ discard block |
||
| 94 | 94 | $GLOBALS['browser_layer'] = ' '; // compat avec vieux scripts qui testent la valeur |
| 95 | 95 | $browser_barre = ''; |
| 96 | 96 | |
| 97 | - if (!preg_match(",opera,i", $browser_description)&&preg_match(",opera,i", $browser_name)) { |
|
| 97 | + if (!preg_match(",opera,i", $browser_description) && preg_match(",opera,i", $browser_name)) { |
|
| 98 | 98 | $browser_name = "Opera"; |
| 99 | 99 | $browser_version = $match[2]; |
| 100 | 100 | $browser_barre = ($browser_version >= 8.5); |
@@ -10,7 +10,9 @@ discard block |
||
| 10 | 10 | * Pour plus de details voir le fichier COPYING.txt ou l'aide en ligne. * |
| 11 | 11 | \***************************************************************************/ |
| 12 | 12 | |
| 13 | -if (!defined('_ECRIRE_INC_VERSION')) return; |
|
| 13 | +if (!defined('_ECRIRE_INC_VERSION')) { |
|
| 14 | + return; |
|
| 15 | +} |
|
| 14 | 16 | |
| 15 | 17 | // http://doc.spip.org/@cadre_depliable |
| 16 | 18 | function cadre_depliable($icone,$titre,$deplie,$contenu,$ids='',$style_cadre='r'){ |
@@ -38,8 +40,9 @@ discard block |
||
| 38 | 40 | function debut_block_depliable($deplie,$id=""){ |
| 39 | 41 | $class=' blocdeplie'; |
| 40 | 42 | // si on n'accepte pas js, ne pas fermer |
| 41 | - if (!$deplie) |
|
| 42 | - $class=" blocreplie"; |
|
| 43 | + if (!$deplie) { |
|
| 44 | + $class=" blocreplie"; |
|
| 45 | + } |
|
| 43 | 46 | return "<div ".($id?"id='$id' ":"")."class='bloc_depliable$class'>"; |
| 44 | 47 | } |
| 45 | 48 | // http://doc.spip.org/@fin_block |
@@ -57,8 +60,7 @@ discard block |
||
| 57 | 60 | if (strlen($ids)){ |
| 58 | 61 | $cible = explode(',',$ids); |
| 59 | 62 | $cible = '#'.implode(",#",$cible); |
| 60 | - } |
|
| 61 | - else{ |
|
| 63 | + } else{ |
|
| 62 | 64 | $cible = "#$bouton_id + div.bloc_depliable"; |
| 63 | 65 | } |
| 64 | 66 | |
@@ -98,39 +100,41 @@ discard block |
||
| 98 | 100 | $browser_name = "Opera"; |
| 99 | 101 | $browser_version = $match[2]; |
| 100 | 102 | $browser_barre = ($browser_version >= 8.5); |
| 101 | - } |
|
| 102 | - else if (preg_match(",opera,i", $browser_description)) { |
|
| 103 | + } else if (preg_match(",opera,i", $browser_description)) { |
|
| 103 | 104 | preg_match(",Opera ([^\ ]*),i", $browser_description, $match); |
| 104 | 105 | $browser_name = "Opera"; |
| 105 | 106 | $browser_version = $match[1]; |
| 106 | 107 | $browser_barre = ($browser_version >= 8.5); |
| 107 | - } |
|
| 108 | - else if (preg_match(",msie,i", $browser_description)) { |
|
| 108 | + } else if (preg_match(",msie,i", $browser_description)) { |
|
| 109 | 109 | preg_match(",MSIE ([^;]*),i", $browser_description, $match); |
| 110 | 110 | $browser_name = "MSIE"; |
| 111 | 111 | $browser_version = $match[1]; |
| 112 | 112 | $browser_barre = ($browser_version >= 5.5); |
| 113 | - } |
|
| 114 | - else if (preg_match(",KHTML,i", $browser_description) && |
|
| 113 | + } else if (preg_match(",KHTML,i", $browser_description) && |
|
| 115 | 114 | preg_match(",Safari/([^;]*),", $browser_description, $match)) { |
| 116 | 115 | $browser_name = "Safari"; |
| 117 | 116 | $browser_version = $match[1]; |
| 118 | 117 | $browser_barre = ($browser_version >= 5.0); |
| 119 | - } |
|
| 120 | - else if (preg_match(",mozilla,i", $browser_name) AND $browser_version >= 5) { |
|
| 118 | + } else if (preg_match(",mozilla,i", $browser_name) AND $browser_version >= 5) { |
|
| 121 | 119 | // Numero de version pour Mozilla "authentique" |
| 122 | - if (preg_match(",rv:([0-9]+\.[0-9]+),", $browser_description, $match)) |
|
| 123 | - $browser_rev = doubleval($match[1]); |
|
| 120 | + if (preg_match(",rv:([0-9]+\.[0-9]+),", $browser_description, $match)) { |
|
| 121 | + $browser_rev = doubleval($match[1]); |
|
| 122 | + } |
|
| 124 | 123 | // Autres Gecko => equivalents 1.4 par defaut (Galeon, etc.) |
| 125 | - else if (strpos($browser_description, "Gecko") and !strpos($browser_description, "KHTML")) |
|
| 126 | - $browser_rev = 1.4; |
|
| 124 | + else if (strpos($browser_description, "Gecko") and !strpos($browser_description, "KHTML")) { |
|
| 125 | + $browser_rev = 1.4; |
|
| 126 | + } |
|
| 127 | 127 | // Machins quelconques => equivalents 1.0 par defaut (Konqueror, etc.) |
| 128 | - else $browser_rev = 1.0; |
|
| 128 | + else { |
|
| 129 | + $browser_rev = 1.0; |
|
| 130 | + } |
|
| 129 | 131 | $browser_barre = $browser_rev >= 1.3; |
| 130 | 132 | } |
| 131 | 133 | |
| 132 | - if (!$browser_name) $browser_name = "Mozilla"; |
|
| 133 | -} |
|
| 134 | + if (!$browser_name) { |
|
| 135 | + $browser_name = "Mozilla"; |
|
| 136 | + } |
|
| 137 | + } |
|
| 134 | 138 | |
| 135 | 139 | verif_butineur(); |
| 136 | 140 | ?> |
@@ -16,53 +16,53 @@ |
||
| 16 | 16 | // |
| 17 | 17 | // http://doc.spip.org/@inc_charger_php_extension_dist |
| 18 | 18 | function inc_charger_php_extension_dist($module){ |
| 19 | - if (extension_loaded($module)) { |
|
| 20 | - return true; |
|
| 21 | - } |
|
| 19 | + if (extension_loaded($module)) { |
|
| 20 | + return true; |
|
| 21 | + } |
|
| 22 | 22 | |
| 23 | - // A-t-on le droit de faire un dl() ; si on peut, on memorise la reponse, |
|
| 24 | - // lourde a calculer, dans les meta |
|
| 25 | - if (!isset($GLOBALS['meta']['dl_allowed'])) { |
|
| 26 | - if (!@ini_get('safe_mode') |
|
| 27 | - && @ini_get('enable_dl') |
|
| 28 | - && @function_exists('dl')) { |
|
| 29 | - ob_start(); |
|
| 30 | - phpinfo(INFO_GENERAL); /* Only general info */ |
|
| 31 | - $a = strip_tags(ob_get_contents()); |
|
| 32 | - ob_end_clean(); |
|
| 33 | - if (preg_match('@Thread Safety[[:space:]]*enabled@', $a)) { |
|
| 34 | - if (preg_match('@Server API[[:space:]]*\(CGI\|CLI\)@', $a)) { |
|
| 35 | - $GLOBALS['meta']['dl_allowed'] = true; |
|
| 36 | - } else { |
|
| 37 | - $GLOBALS['meta']['dl_allowed'] = false; |
|
| 38 | - } |
|
| 39 | - } else { |
|
| 40 | - $GLOBALS['meta']['dl_allowed'] = true; |
|
| 41 | - } |
|
| 42 | - } else { |
|
| 43 | - $GLOBALS['meta']['dl_allowed'] = false; |
|
| 44 | - } |
|
| 23 | + // A-t-on le droit de faire un dl() ; si on peut, on memorise la reponse, |
|
| 24 | + // lourde a calculer, dans les meta |
|
| 25 | + if (!isset($GLOBALS['meta']['dl_allowed'])) { |
|
| 26 | + if (!@ini_get('safe_mode') |
|
| 27 | + && @ini_get('enable_dl') |
|
| 28 | + && @function_exists('dl')) { |
|
| 29 | + ob_start(); |
|
| 30 | + phpinfo(INFO_GENERAL); /* Only general info */ |
|
| 31 | + $a = strip_tags(ob_get_contents()); |
|
| 32 | + ob_end_clean(); |
|
| 33 | + if (preg_match('@Thread Safety[[:space:]]*enabled@', $a)) { |
|
| 34 | + if (preg_match('@Server API[[:space:]]*\(CGI\|CLI\)@', $a)) { |
|
| 35 | + $GLOBALS['meta']['dl_allowed'] = true; |
|
| 36 | + } else { |
|
| 37 | + $GLOBALS['meta']['dl_allowed'] = false; |
|
| 38 | + } |
|
| 39 | + } else { |
|
| 40 | + $GLOBALS['meta']['dl_allowed'] = true; |
|
| 41 | + } |
|
| 42 | + } else { |
|
| 43 | + $GLOBALS['meta']['dl_allowed'] = false; |
|
| 44 | + } |
|
| 45 | 45 | |
| 46 | - // Attention, le ecrire_meta() echouera si on le tente ici ; |
|
| 47 | - // donc on ne fait rien, et on attend qu'un prochain ecrire_meta() |
|
| 48 | - // se produisant apres cette sequence enregistre sa valeur. |
|
| 49 | - #include_spip('inc/meta'); |
|
| 50 | - #ecrire_meta('dl_allowed', $GLOBALS['meta']['dl_allowed'], 'non'); |
|
| 51 | - } |
|
| 46 | + // Attention, le ecrire_meta() echouera si on le tente ici ; |
|
| 47 | + // donc on ne fait rien, et on attend qu'un prochain ecrire_meta() |
|
| 48 | + // se produisant apres cette sequence enregistre sa valeur. |
|
| 49 | + #include_spip('inc/meta'); |
|
| 50 | + #ecrire_meta('dl_allowed', $GLOBALS['meta']['dl_allowed'], 'non'); |
|
| 51 | + } |
|
| 52 | 52 | |
| 53 | - if (!$GLOBALS['meta']['dl_allowed']) { |
|
| 54 | - return false; |
|
| 55 | - } |
|
| 53 | + if (!$GLOBALS['meta']['dl_allowed']) { |
|
| 54 | + return false; |
|
| 55 | + } |
|
| 56 | 56 | |
| 57 | - /* Once we require PHP >= 4.3, we might use PHP_SHLIB_SUFFIX here */ |
|
| 58 | - if (strtoupper(substr(PHP_OS, 0, 3)) === 'WIN') { |
|
| 59 | - $module_file = 'php_' . $module . '.dll'; |
|
| 60 | - } elseif (PHP_OS=='HP-UX') { |
|
| 61 | - $module_file = $module . '.sl'; |
|
| 62 | - } else { |
|
| 63 | - $module_file = $module . '.so'; |
|
| 64 | - } |
|
| 57 | + /* Once we require PHP >= 4.3, we might use PHP_SHLIB_SUFFIX here */ |
|
| 58 | + if (strtoupper(substr(PHP_OS, 0, 3)) === 'WIN') { |
|
| 59 | + $module_file = 'php_' . $module . '.dll'; |
|
| 60 | + } elseif (PHP_OS=='HP-UX') { |
|
| 61 | + $module_file = $module . '.sl'; |
|
| 62 | + } else { |
|
| 63 | + $module_file = $module . '.so'; |
|
| 64 | + } |
|
| 65 | 65 | |
| 66 | - return @dl($module_file); |
|
| 66 | + return @dl($module_file); |
|
| 67 | 67 | } |
| 68 | 68 | ?> |
@@ -15,7 +15,7 @@ discard block |
||
| 15 | 15 | // - 3) si l'on peut, on charge le module par la fonction dl() |
| 16 | 16 | // |
| 17 | 17 | // http://doc.spip.org/@inc_charger_php_extension_dist |
| 18 | -function inc_charger_php_extension_dist($module){ |
|
| 18 | +function inc_charger_php_extension_dist($module) { |
|
| 19 | 19 | if (extension_loaded($module)) { |
| 20 | 20 | return true; |
| 21 | 21 | } |
@@ -56,11 +56,11 @@ discard block |
||
| 56 | 56 | |
| 57 | 57 | /* Once we require PHP >= 4.3, we might use PHP_SHLIB_SUFFIX here */ |
| 58 | 58 | if (strtoupper(substr(PHP_OS, 0, 3)) === 'WIN') { |
| 59 | - $module_file = 'php_' . $module . '.dll'; |
|
| 60 | - } elseif (PHP_OS=='HP-UX') { |
|
| 61 | - $module_file = $module . '.sl'; |
|
| 59 | + $module_file = 'php_'.$module.'.dll'; |
|
| 60 | + } elseif (PHP_OS == 'HP-UX') { |
|
| 61 | + $module_file = $module.'.sl'; |
|
| 62 | 62 | } else { |
| 63 | - $module_file = $module . '.so'; |
|
| 63 | + $module_file = $module.'.so'; |
|
| 64 | 64 | } |
| 65 | 65 | |
| 66 | 66 | return @dl($module_file); |
@@ -1,6 +1,8 @@ |
||
| 1 | 1 | <?php |
| 2 | 2 | |
| 3 | -if (!defined('_ECRIRE_INC_VERSION')) return; |
|
| 3 | +if (!defined('_ECRIRE_INC_VERSION')) { |
|
| 4 | + return; |
|
| 5 | +} |
|
| 4 | 6 | |
| 5 | 7 | // cette fonction (adaptee de phpMyAdmin) |
| 6 | 8 | // permet de charger un module php |