@@ -13,16 +13,16 @@ |
||
| 13 | 13 | if (!defined('_ECRIRE_INC_VERSION')) return; |
| 14 | 14 | |
| 15 | 15 | function action_supprimer_lien_dist($arg=null){ |
| 16 | - if (is_null($arg)){ |
|
| 17 | - $securiser_action = charger_fonction('securiser_action','inc'); |
|
| 18 | - $arg = $securiser_action(); |
|
| 19 | - } |
|
| 16 | + if (is_null($arg)){ |
|
| 17 | + $securiser_action = charger_fonction('securiser_action','inc'); |
|
| 18 | + $arg = $securiser_action(); |
|
| 19 | + } |
|
| 20 | 20 | |
| 21 | - $arg = explode("-",$arg); |
|
| 22 | - list($objet_source,$ids,$objet_lie,$idl) = $arg; |
|
| 21 | + $arg = explode("-",$arg); |
|
| 22 | + list($objet_source,$ids,$objet_lie,$idl) = $arg; |
|
| 23 | 23 | |
| 24 | - include_spip('action/editer_liens'); |
|
| 25 | - objet_dissocier(array($objet_source=>$ids), array($objet_lie=>$idl)); |
|
| 24 | + include_spip('action/editer_liens'); |
|
| 25 | + objet_dissocier(array($objet_source=>$ids), array($objet_lie=>$idl)); |
|
| 26 | 26 | } |
| 27 | 27 | |
| 28 | 28 | |
@@ -12,14 +12,14 @@ |
||
| 12 | 12 | |
| 13 | 13 | if (!defined('_ECRIRE_INC_VERSION')) return; |
| 14 | 14 | |
| 15 | -function action_supprimer_lien_dist($arg=null){ |
|
| 16 | - if (is_null($arg)){ |
|
| 17 | - $securiser_action = charger_fonction('securiser_action','inc'); |
|
| 15 | +function action_supprimer_lien_dist($arg = null) { |
|
| 16 | + if (is_null($arg)) { |
|
| 17 | + $securiser_action = charger_fonction('securiser_action', 'inc'); |
|
| 18 | 18 | $arg = $securiser_action(); |
| 19 | 19 | } |
| 20 | 20 | |
| 21 | - $arg = explode("-",$arg); |
|
| 22 | - list($objet_source,$ids,$objet_lie,$idl) = $arg; |
|
| 21 | + $arg = explode("-", $arg); |
|
| 22 | + list($objet_source, $ids, $objet_lie, $idl) = $arg; |
|
| 23 | 23 | |
| 24 | 24 | include_spip('action/editer_liens'); |
| 25 | 25 | objet_dissocier(array($objet_source=>$ids), array($objet_lie=>$idl)); |
@@ -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 | function action_supprimer_lien_dist($arg=null){ |
| 16 | 18 | if (is_null($arg)){ |
@@ -15,11 +15,11 @@ discard block |
||
| 15 | 15 | |
| 16 | 16 | function action_tester_taille_error_handler($output) |
| 17 | 17 | { |
| 18 | - // on est ici, donc echec lors de la creation de l'image |
|
| 19 | - if ($GLOBALS['redirect']){ |
|
| 20 | - return redirige_formulaire($GLOBALS['redirect']); |
|
| 21 | - } |
|
| 22 | - return $output; |
|
| 18 | + // on est ici, donc echec lors de la creation de l'image |
|
| 19 | + if ($GLOBALS['redirect']){ |
|
| 20 | + return redirige_formulaire($GLOBALS['redirect']); |
|
| 21 | + } |
|
| 22 | + return $output; |
|
| 23 | 23 | } |
| 24 | 24 | |
| 25 | 25 | |
@@ -27,61 +27,61 @@ discard block |
||
| 27 | 27 | // http://doc.spip.org/@action_tester_taille_dist |
| 28 | 28 | function action_tester_taille_dist() { |
| 29 | 29 | |
| 30 | - if (!autoriser('configurer')) |
|
| 31 | - return; |
|
| 30 | + if (!autoriser('configurer')) |
|
| 31 | + return; |
|
| 32 | 32 | |
| 33 | - $taille = _request('arg'); |
|
| 34 | - $taille = explode('-',$taille); |
|
| 33 | + $taille = _request('arg'); |
|
| 34 | + $taille = explode('-',$taille); |
|
| 35 | 35 | |
| 36 | - $GLOBALS['taille_max'] = end($taille); |
|
| 37 | - $GLOBALS['taille_min'] = 0; |
|
| 38 | - if (count($taille)>1) |
|
| 39 | - $GLOBALS['taille_min'] = reset($taille); |
|
| 36 | + $GLOBALS['taille_max'] = end($taille); |
|
| 37 | + $GLOBALS['taille_min'] = 0; |
|
| 38 | + if (count($taille)>1) |
|
| 39 | + $GLOBALS['taille_min'] = reset($taille); |
|
| 40 | 40 | |
| 41 | - // si l'intervalle est assez petit, on garde la valeur min |
|
| 42 | - if ($GLOBALS['taille_max']*$GLOBALS['taille_max']-$GLOBALS['taille_min']*$GLOBALS['taille_min']<50000){ |
|
| 43 | - ecrire_meta('max_taille_vignettes',$t=($GLOBALS['taille_min']*$GLOBALS['taille_min'])*0.9,'non'); |
|
| 44 | - echo round($t/1000000,3).' Mpx'; |
|
| 45 | - die(); |
|
| 46 | - } |
|
| 41 | + // si l'intervalle est assez petit, on garde la valeur min |
|
| 42 | + if ($GLOBALS['taille_max']*$GLOBALS['taille_max']-$GLOBALS['taille_min']*$GLOBALS['taille_min']<50000){ |
|
| 43 | + ecrire_meta('max_taille_vignettes',$t=($GLOBALS['taille_min']*$GLOBALS['taille_min'])*0.9,'non'); |
|
| 44 | + echo round($t/1000000,3).' Mpx'; |
|
| 45 | + die(); |
|
| 46 | + } |
|
| 47 | 47 | |
| 48 | - $taille = $GLOBALS['taille_test'] = round(($GLOBALS['taille_max']+$GLOBALS['taille_min'])/2); |
|
| 48 | + $taille = $GLOBALS['taille_test'] = round(($GLOBALS['taille_max']+$GLOBALS['taille_min'])/2); |
|
| 49 | 49 | |
| 50 | - include_spip('inc/filtres'); |
|
| 51 | - // des inclusions representatives d'un hit prive et/ou public pour la conso memoire |
|
| 52 | - include_spip('public/assembler'); |
|
| 53 | - include_spip('public/balises'); |
|
| 54 | - include_spip('public/boucles'); |
|
| 55 | - include_spip('public/cacher'); |
|
| 56 | - include_spip('public/compiler'); |
|
| 57 | - include_spip('public/composer'); |
|
| 58 | - include_spip('public/criteres'); |
|
| 59 | - include_spip('public/interfaces'); |
|
| 60 | - include_spip('public/parametrer'); |
|
| 61 | - include_spip('public/phraser_html'); |
|
| 62 | - include_spip('public/references'); |
|
| 50 | + include_spip('inc/filtres'); |
|
| 51 | + // des inclusions representatives d'un hit prive et/ou public pour la conso memoire |
|
| 52 | + include_spip('public/assembler'); |
|
| 53 | + include_spip('public/balises'); |
|
| 54 | + include_spip('public/boucles'); |
|
| 55 | + include_spip('public/cacher'); |
|
| 56 | + include_spip('public/compiler'); |
|
| 57 | + include_spip('public/composer'); |
|
| 58 | + include_spip('public/criteres'); |
|
| 59 | + include_spip('public/interfaces'); |
|
| 60 | + include_spip('public/parametrer'); |
|
| 61 | + include_spip('public/phraser_html'); |
|
| 62 | + include_spip('public/references'); |
|
| 63 | 63 | |
| 64 | - include_spip('inc/presentation'); |
|
| 65 | - include_spip('inc/charsets'); |
|
| 66 | - include_spip('inc/documents'); |
|
| 67 | - include_spip('inc/header'); |
|
| 68 | - propre("<doc1>"); // charger propre avec le trairement d'un modele |
|
| 64 | + include_spip('inc/presentation'); |
|
| 65 | + include_spip('inc/charsets'); |
|
| 66 | + include_spip('inc/documents'); |
|
| 67 | + include_spip('inc/header'); |
|
| 68 | + propre("<doc1>"); // charger propre avec le trairement d'un modele |
|
| 69 | 69 | |
| 70 | - $i = _request('i')+1; |
|
| 71 | - $image_source = chemin_image("test.png"); |
|
| 72 | - $GLOBALS['redirect'] = generer_url_action("tester_taille", "i=$i&arg=".$GLOBALS['taille_min']."-".$GLOBALS['taille_test']); |
|
| 70 | + $i = _request('i')+1; |
|
| 71 | + $image_source = chemin_image("test.png"); |
|
| 72 | + $GLOBALS['redirect'] = generer_url_action("tester_taille", "i=$i&arg=".$GLOBALS['taille_min']."-".$GLOBALS['taille_test']); |
|
| 73 | 73 | |
| 74 | - ob_start('action_tester_taille_error_handler'); |
|
| 75 | - filtrer('image_recadre',$image_source,$taille,$taille); |
|
| 76 | - $GLOBALS['redirect'] = generer_url_action("tester_taille", "i=$i&arg=$taille-".$GLOBALS['taille_max']); |
|
| 77 | - // si la valeur intermediaire a reussi, on teste la valeur maxi qui est peut etre sous estimee |
|
| 78 | - $taille = $GLOBALS['taille_max']; |
|
| 79 | - filtrer('image_recadre',$image_source,$taille,$taille); |
|
| 80 | - $GLOBALS['redirect'] = generer_url_action("tester_taille", "i=$i&arg=$taille-".$GLOBALS['taille_max']); |
|
| 81 | - ob_end_clean(); |
|
| 74 | + ob_start('action_tester_taille_error_handler'); |
|
| 75 | + filtrer('image_recadre',$image_source,$taille,$taille); |
|
| 76 | + $GLOBALS['redirect'] = generer_url_action("tester_taille", "i=$i&arg=$taille-".$GLOBALS['taille_max']); |
|
| 77 | + // si la valeur intermediaire a reussi, on teste la valeur maxi qui est peut etre sous estimee |
|
| 78 | + $taille = $GLOBALS['taille_max']; |
|
| 79 | + filtrer('image_recadre',$image_source,$taille,$taille); |
|
| 80 | + $GLOBALS['redirect'] = generer_url_action("tester_taille", "i=$i&arg=$taille-".$GLOBALS['taille_max']); |
|
| 81 | + ob_end_clean(); |
|
| 82 | 82 | |
| 83 | - // on est ici, donc pas de plantage |
|
| 84 | - echo redirige_formulaire($GLOBALS['redirect']); |
|
| 83 | + // on est ici, donc pas de plantage |
|
| 84 | + echo redirige_formulaire($GLOBALS['redirect']); |
|
| 85 | 85 | } |
| 86 | 86 | |
| 87 | 87 | ?> |
@@ -16,7 +16,7 @@ discard block |
||
| 16 | 16 | function action_tester_taille_error_handler($output) |
| 17 | 17 | { |
| 18 | 18 | // on est ici, donc echec lors de la creation de l'image |
| 19 | - if ($GLOBALS['redirect']){ |
|
| 19 | + if ($GLOBALS['redirect']) { |
|
| 20 | 20 | return redirige_formulaire($GLOBALS['redirect']); |
| 21 | 21 | } |
| 22 | 22 | return $output; |
@@ -31,21 +31,21 @@ discard block |
||
| 31 | 31 | return; |
| 32 | 32 | |
| 33 | 33 | $taille = _request('arg'); |
| 34 | - $taille = explode('-',$taille); |
|
| 34 | + $taille = explode('-', $taille); |
|
| 35 | 35 | |
| 36 | 36 | $GLOBALS['taille_max'] = end($taille); |
| 37 | 37 | $GLOBALS['taille_min'] = 0; |
| 38 | - if (count($taille)>1) |
|
| 38 | + if (count($taille) > 1) |
|
| 39 | 39 | $GLOBALS['taille_min'] = reset($taille); |
| 40 | 40 | |
| 41 | 41 | // si l'intervalle est assez petit, on garde la valeur min |
| 42 | - if ($GLOBALS['taille_max']*$GLOBALS['taille_max']-$GLOBALS['taille_min']*$GLOBALS['taille_min']<50000){ |
|
| 43 | - ecrire_meta('max_taille_vignettes',$t=($GLOBALS['taille_min']*$GLOBALS['taille_min'])*0.9,'non'); |
|
| 44 | - echo round($t/1000000,3).' Mpx'; |
|
| 42 | + if ($GLOBALS['taille_max'] * $GLOBALS['taille_max'] - $GLOBALS['taille_min'] * $GLOBALS['taille_min'] < 50000) { |
|
| 43 | + ecrire_meta('max_taille_vignettes', $t = ($GLOBALS['taille_min'] * $GLOBALS['taille_min']) * 0.9, 'non'); |
|
| 44 | + echo round($t / 1000000, 3).' Mpx'; |
|
| 45 | 45 | die(); |
| 46 | 46 | } |
| 47 | 47 | |
| 48 | - $taille = $GLOBALS['taille_test'] = round(($GLOBALS['taille_max']+$GLOBALS['taille_min'])/2); |
|
| 48 | + $taille = $GLOBALS['taille_test'] = round(($GLOBALS['taille_max'] + $GLOBALS['taille_min']) / 2); |
|
| 49 | 49 | |
| 50 | 50 | include_spip('inc/filtres'); |
| 51 | 51 | // des inclusions representatives d'un hit prive et/ou public pour la conso memoire |
@@ -67,16 +67,16 @@ discard block |
||
| 67 | 67 | include_spip('inc/header'); |
| 68 | 68 | propre("<doc1>"); // charger propre avec le trairement d'un modele |
| 69 | 69 | |
| 70 | - $i = _request('i')+1; |
|
| 70 | + $i = _request('i') + 1; |
|
| 71 | 71 | $image_source = chemin_image("test.png"); |
| 72 | 72 | $GLOBALS['redirect'] = generer_url_action("tester_taille", "i=$i&arg=".$GLOBALS['taille_min']."-".$GLOBALS['taille_test']); |
| 73 | 73 | |
| 74 | 74 | ob_start('action_tester_taille_error_handler'); |
| 75 | - filtrer('image_recadre',$image_source,$taille,$taille); |
|
| 75 | + filtrer('image_recadre', $image_source, $taille, $taille); |
|
| 76 | 76 | $GLOBALS['redirect'] = generer_url_action("tester_taille", "i=$i&arg=$taille-".$GLOBALS['taille_max']); |
| 77 | 77 | // si la valeur intermediaire a reussi, on teste la valeur maxi qui est peut etre sous estimee |
| 78 | 78 | $taille = $GLOBALS['taille_max']; |
| 79 | - filtrer('image_recadre',$image_source,$taille,$taille); |
|
| 79 | + filtrer('image_recadre', $image_source, $taille, $taille); |
|
| 80 | 80 | $GLOBALS['redirect'] = generer_url_action("tester_taille", "i=$i&arg=$taille-".$GLOBALS['taille_max']); |
| 81 | 81 | ob_end_clean(); |
| 82 | 82 | |
@@ -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/headers'); |
| 15 | 17 | |
| 16 | 18 | function action_tester_taille_error_handler($output) |
@@ -27,16 +29,18 @@ discard block |
||
| 27 | 29 | // http://doc.spip.org/@action_tester_taille_dist |
| 28 | 30 | function action_tester_taille_dist() { |
| 29 | 31 | |
| 30 | - if (!autoriser('configurer')) |
|
| 31 | - return; |
|
| 32 | + if (!autoriser('configurer')) { |
|
| 33 | + return; |
|
| 34 | + } |
|
| 32 | 35 | |
| 33 | 36 | $taille = _request('arg'); |
| 34 | 37 | $taille = explode('-',$taille); |
| 35 | 38 | |
| 36 | 39 | $GLOBALS['taille_max'] = end($taille); |
| 37 | 40 | $GLOBALS['taille_min'] = 0; |
| 38 | - if (count($taille)>1) |
|
| 39 | - $GLOBALS['taille_min'] = reset($taille); |
|
| 41 | + if (count($taille)>1) { |
|
| 42 | + $GLOBALS['taille_min'] = reset($taille); |
|
| 43 | + } |
|
| 40 | 44 | |
| 41 | 45 | // si l'intervalle est assez petit, on garde la valeur min |
| 42 | 46 | if ($GLOBALS['taille_max']*$GLOBALS['taille_max']-$GLOBALS['taille_min']*$GLOBALS['taille_min']<50000){ |
@@ -20,28 +20,28 @@ |
||
| 20 | 20 | * @return void |
| 21 | 21 | */ |
| 22 | 22 | function action_etre_webmestre_dist() { |
| 23 | - $securiser_action = charger_fonction('securiser_action', 'inc'); |
|
| 24 | - $time = $securiser_action(); |
|
| 23 | + $securiser_action = charger_fonction('securiser_action', 'inc'); |
|
| 24 | + $time = $securiser_action(); |
|
| 25 | 25 | |
| 26 | - if (time()-$time<15*60 |
|
| 27 | - AND $GLOBALS['visiteur_session']['statut']=='0minirezo' |
|
| 28 | - AND $GLOBALS['visiteur_session']['webmestre']!=='oui') { |
|
| 29 | - $action = _T('info_admin_etre_webmestre'); |
|
| 30 | - $admin = charger_fonction('admin', 'inc'); |
|
| 31 | - // lance la verif par ftp et l'appel |
|
| 32 | - // a base_etre_webmestre_dist quand c'est OK |
|
| 33 | - if ($r = $admin('etre_webmestre', $action)) { |
|
| 34 | - echo $r; |
|
| 35 | - exit; |
|
| 36 | - } |
|
| 37 | - } |
|
| 26 | + if (time()-$time<15*60 |
|
| 27 | + AND $GLOBALS['visiteur_session']['statut']=='0minirezo' |
|
| 28 | + AND $GLOBALS['visiteur_session']['webmestre']!=='oui') { |
|
| 29 | + $action = _T('info_admin_etre_webmestre'); |
|
| 30 | + $admin = charger_fonction('admin', 'inc'); |
|
| 31 | + // lance la verif par ftp et l'appel |
|
| 32 | + // a base_etre_webmestre_dist quand c'est OK |
|
| 33 | + if ($r = $admin('etre_webmestre', $action)) { |
|
| 34 | + echo $r; |
|
| 35 | + exit; |
|
| 36 | + } |
|
| 37 | + } |
|
| 38 | 38 | |
| 39 | 39 | } |
| 40 | 40 | |
| 41 | 41 | function base_etre_webmestre_dist() { |
| 42 | - if ($GLOBALS['visiteur_session']['statut']=='0minirezo' AND $GLOBALS['visiteur_session']['webmestre']!=='oui') { |
|
| 43 | - include_spip('action/editer_auteur'); |
|
| 44 | - instituer_auteur($GLOBALS['visiteur_session']['id_auteur'], array('webmestre'=>'oui'), true); |
|
| 45 | - } |
|
| 42 | + if ($GLOBALS['visiteur_session']['statut']=='0minirezo' AND $GLOBALS['visiteur_session']['webmestre']!=='oui') { |
|
| 43 | + include_spip('action/editer_auteur'); |
|
| 44 | + instituer_auteur($GLOBALS['visiteur_session']['id_auteur'], array('webmestre'=>'oui'), true); |
|
| 45 | + } |
|
| 46 | 46 | } |
| 47 | 47 | ?> |
@@ -23,9 +23,9 @@ discard block |
||
| 23 | 23 | $securiser_action = charger_fonction('securiser_action', 'inc'); |
| 24 | 24 | $time = $securiser_action(); |
| 25 | 25 | |
| 26 | - if (time()-$time<15*60 |
|
| 27 | - AND $GLOBALS['visiteur_session']['statut']=='0minirezo' |
|
| 28 | - AND $GLOBALS['visiteur_session']['webmestre']!=='oui') { |
|
| 26 | + if (time() - $time < 15 * 60 |
|
| 27 | + AND $GLOBALS['visiteur_session']['statut'] == '0minirezo' |
|
| 28 | + AND $GLOBALS['visiteur_session']['webmestre'] !== 'oui') { |
|
| 29 | 29 | $action = _T('info_admin_etre_webmestre'); |
| 30 | 30 | $admin = charger_fonction('admin', 'inc'); |
| 31 | 31 | // lance la verif par ftp et l'appel |
@@ -39,7 +39,7 @@ discard block |
||
| 39 | 39 | } |
| 40 | 40 | |
| 41 | 41 | function base_etre_webmestre_dist() { |
| 42 | - if ($GLOBALS['visiteur_session']['statut']=='0minirezo' AND $GLOBALS['visiteur_session']['webmestre']!=='oui') { |
|
| 42 | + if ($GLOBALS['visiteur_session']['statut'] == '0minirezo' AND $GLOBALS['visiteur_session']['webmestre'] !== 'oui') { |
|
| 43 | 43 | include_spip('action/editer_auteur'); |
| 44 | 44 | instituer_auteur($GLOBALS['visiteur_session']['id_auteur'], array('webmestre'=>'oui'), true); |
| 45 | 45 | } |
@@ -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 | |
@@ -15,129 +15,129 @@ |
||
| 15 | 15 | // Tester nos capacites |
| 16 | 16 | // http://doc.spip.org/@action_tester_dist |
| 17 | 17 | function action_tester_dist() { |
| 18 | - $arg = _request('arg'); |
|
| 19 | - |
|
| 20 | - $gd_formats = $gd_formats_read_gif = ""; |
|
| 21 | - // verifier les formats acceptes par GD |
|
| 22 | - if ($arg == "gd1") { |
|
| 23 | - // Si GD est installe et php >= 4.0.2 |
|
| 24 | - if (function_exists('imagetypes')) { |
|
| 25 | - |
|
| 26 | - if (imagetypes() & IMG_GIF) { |
|
| 27 | - $gd_formats[] = "gif"; |
|
| 28 | - } else { |
|
| 29 | - # Attention GD sait lire le gif mais pas forcement l'ecrire |
|
| 30 | - if (function_exists('ImageCreateFromGIF')) { |
|
| 31 | - $srcImage = @ImageCreateFromGIF(_ROOT_IMG_PACK."test.gif"); |
|
| 32 | - if ($srcImage) { |
|
| 33 | - $gd_formats_read_gif = ",gif"; |
|
| 34 | - ImageDestroy( $srcImage ); |
|
| 35 | - } |
|
| 36 | - } |
|
| 37 | - } |
|
| 38 | - |
|
| 39 | - if (imagetypes() & IMG_JPG) |
|
| 40 | - $gd_formats[] = "jpg"; |
|
| 41 | - if (imagetypes() & IMG_PNG) |
|
| 42 | - $gd_formats[] = "png"; |
|
| 43 | - } |
|
| 44 | - |
|
| 45 | - else { # ancienne methode de detection des formats, qui en plus |
|
| 46 | - # est bugguee car elle teste les formats en lecture |
|
| 47 | - # alors que la valeur deduite sert a identifier |
|
| 48 | - # les formats disponibles en ecriture... (cf. inc_logos) |
|
| 49 | - |
|
| 50 | - $gd_formats = Array(); |
|
| 51 | - if (function_exists('ImageCreateFromJPEG')) { |
|
| 52 | - $srcImage = @ImageCreateFromJPEG(_ROOT_IMG_PACK."test.jpg"); |
|
| 53 | - if ($srcImage) { |
|
| 54 | - $gd_formats[] = "jpg"; |
|
| 55 | - ImageDestroy( $srcImage ); |
|
| 56 | - } |
|
| 57 | - } |
|
| 58 | - if (function_exists('ImageCreateFromGIF')) { |
|
| 59 | - $srcImage = @ImageCreateFromGIF(_ROOT_IMG_PACK."test.gif"); |
|
| 60 | - if ($srcImage) { |
|
| 61 | - $gd_formats[] = "gif"; |
|
| 62 | - ImageDestroy( $srcImage ); |
|
| 63 | - } |
|
| 64 | - } |
|
| 65 | - if (function_exists('ImageCreateFromPNG')) { |
|
| 66 | - $srcImage = @ImageCreateFromPNG(_ROOT_IMG_PACK."test.png"); |
|
| 67 | - if ($srcImage) { |
|
| 68 | - $gd_formats[] = "png"; |
|
| 69 | - ImageDestroy( $srcImage ); |
|
| 70 | - } |
|
| 71 | - } |
|
| 72 | - } |
|
| 73 | - |
|
| 74 | - if ($gd_formats) $gd_formats = join(",", $gd_formats); |
|
| 75 | - ecrire_meta("gd_formats_read", $gd_formats.$gd_formats_read_gif); |
|
| 76 | - ecrire_meta("gd_formats", $gd_formats); |
|
| 77 | - } |
|
| 78 | - |
|
| 79 | - // verifier les formats netpbm |
|
| 80 | - else if ($arg == "netpbm") { |
|
| 81 | - define('_PNMSCALE_COMMAND', 'pnmscale'); // chemin a changer dans mes_options |
|
| 82 | - if (_PNMSCALE_COMMAND == '') return; |
|
| 83 | - $netpbm_formats= Array(); |
|
| 84 | - |
|
| 85 | - $jpegtopnm_command = str_replace("pnmscale", |
|
| 86 | - "jpegtopnm", _PNMSCALE_COMMAND); |
|
| 87 | - $pnmtojpeg_command = str_replace("pnmscale", |
|
| 88 | - "pnmtojpeg", _PNMSCALE_COMMAND); |
|
| 89 | - |
|
| 90 | - $vignette = _ROOT_IMG_PACK."test.jpg"; |
|
| 91 | - $dest = _DIR_VAR . "test-jpg.jpg"; |
|
| 92 | - $commande = "$jpegtopnm_command $vignette | "._PNMSCALE_COMMAND." -width 10 | $pnmtojpeg_command > $dest"; |
|
| 93 | - spip_log($commande); |
|
| 94 | - exec($commande); |
|
| 95 | - if ($taille = @getimagesize($dest)) { |
|
| 96 | - if ($taille[1] == 10) $netpbm_formats[] = "jpg"; |
|
| 97 | - } |
|
| 98 | - $giftopnm_command = str_replace("pnmscale", "giftopnm", _PNMSCALE_COMMAND); |
|
| 99 | - $pnmtojpeg_command = str_replace("pnmscale", "pnmtojpeg", _PNMSCALE_COMMAND); |
|
| 100 | - $vignette = _ROOT_IMG_PACK."test.gif"; |
|
| 101 | - $dest = _DIR_VAR . "test-gif.jpg"; |
|
| 102 | - $commande = "$giftopnm_command $vignette | "._PNMSCALE_COMMAND." -width 10 | $pnmtojpeg_command > $dest"; |
|
| 103 | - spip_log($commande); |
|
| 104 | - exec($commande); |
|
| 105 | - if ($taille = @getimagesize($dest)) { |
|
| 106 | - if ($taille[1] == 10) $netpbm_formats[] = "gif"; |
|
| 107 | - } |
|
| 108 | - |
|
| 109 | - $pngtopnm_command = str_replace("pnmscale", "pngtopnm", _PNMSCALE_COMMAND); |
|
| 110 | - $vignette = _ROOT_IMG_PACK."test.png"; |
|
| 111 | - $dest = _DIR_VAR . "test-gif.jpg"; |
|
| 112 | - $commande = "$pngtopnm_command $vignette | "._PNMSCALE_COMMAND." -width 10 | $pnmtojpeg_command > $dest"; |
|
| 113 | - spip_log($commande); |
|
| 114 | - exec($commande); |
|
| 115 | - if ($taille = @getimagesize($dest)) { |
|
| 116 | - if ($taille[1] == 10) $netpbm_formats[] = "png"; |
|
| 117 | - } |
|
| 118 | - |
|
| 119 | - |
|
| 120 | - if ($netpbm_formats) |
|
| 121 | - $netpbm_formats = join(",", $netpbm_formats); |
|
| 122 | - else |
|
| 123 | - $netpbm_formats = ''; |
|
| 124 | - ecrire_meta("netpbm_formats", $netpbm_formats); |
|
| 125 | - } |
|
| 126 | - |
|
| 127 | - // et maintenant envoyer la vignette de tests |
|
| 128 | - if (in_array($arg,array("gd1","gd2","imagick","convert","netpbm"))) { |
|
| 129 | - include_spip('inc/filtres'); |
|
| 130 | - include_spip('inc/filtres_images_mini'); |
|
| 131 | - $taille_preview = 150; |
|
| 132 | - $image = _image_valeurs_trans(_DIR_IMG_PACK.'test_image.jpg',"reduire-$taille_preview-$taille_preview",'jpg'); |
|
| 133 | - |
|
| 134 | - $image['fichier_dest']=_DIR_VAR."test_$arg"; |
|
| 135 | - if ($preview = _image_creer_vignette($image, $taille_preview, $taille_preview, $arg, true) |
|
| 136 | - AND ($preview['width'] * $preview['height'] > 0)) |
|
| 137 | - redirige_par_entete($preview['fichier']); |
|
| 138 | - } |
|
| 139 | - |
|
| 140 | - # image echec |
|
| 141 | - redirige_par_entete(chemin_image('puce-rouge-anim.gif')); |
|
| 18 | + $arg = _request('arg'); |
|
| 19 | + |
|
| 20 | + $gd_formats = $gd_formats_read_gif = ""; |
|
| 21 | + // verifier les formats acceptes par GD |
|
| 22 | + if ($arg == "gd1") { |
|
| 23 | + // Si GD est installe et php >= 4.0.2 |
|
| 24 | + if (function_exists('imagetypes')) { |
|
| 25 | + |
|
| 26 | + if (imagetypes() & IMG_GIF) { |
|
| 27 | + $gd_formats[] = "gif"; |
|
| 28 | + } else { |
|
| 29 | + # Attention GD sait lire le gif mais pas forcement l'ecrire |
|
| 30 | + if (function_exists('ImageCreateFromGIF')) { |
|
| 31 | + $srcImage = @ImageCreateFromGIF(_ROOT_IMG_PACK."test.gif"); |
|
| 32 | + if ($srcImage) { |
|
| 33 | + $gd_formats_read_gif = ",gif"; |
|
| 34 | + ImageDestroy( $srcImage ); |
|
| 35 | + } |
|
| 36 | + } |
|
| 37 | + } |
|
| 38 | + |
|
| 39 | + if (imagetypes() & IMG_JPG) |
|
| 40 | + $gd_formats[] = "jpg"; |
|
| 41 | + if (imagetypes() & IMG_PNG) |
|
| 42 | + $gd_formats[] = "png"; |
|
| 43 | + } |
|
| 44 | + |
|
| 45 | + else { # ancienne methode de detection des formats, qui en plus |
|
| 46 | + # est bugguee car elle teste les formats en lecture |
|
| 47 | + # alors que la valeur deduite sert a identifier |
|
| 48 | + # les formats disponibles en ecriture... (cf. inc_logos) |
|
| 49 | + |
|
| 50 | + $gd_formats = Array(); |
|
| 51 | + if (function_exists('ImageCreateFromJPEG')) { |
|
| 52 | + $srcImage = @ImageCreateFromJPEG(_ROOT_IMG_PACK."test.jpg"); |
|
| 53 | + if ($srcImage) { |
|
| 54 | + $gd_formats[] = "jpg"; |
|
| 55 | + ImageDestroy( $srcImage ); |
|
| 56 | + } |
|
| 57 | + } |
|
| 58 | + if (function_exists('ImageCreateFromGIF')) { |
|
| 59 | + $srcImage = @ImageCreateFromGIF(_ROOT_IMG_PACK."test.gif"); |
|
| 60 | + if ($srcImage) { |
|
| 61 | + $gd_formats[] = "gif"; |
|
| 62 | + ImageDestroy( $srcImage ); |
|
| 63 | + } |
|
| 64 | + } |
|
| 65 | + if (function_exists('ImageCreateFromPNG')) { |
|
| 66 | + $srcImage = @ImageCreateFromPNG(_ROOT_IMG_PACK."test.png"); |
|
| 67 | + if ($srcImage) { |
|
| 68 | + $gd_formats[] = "png"; |
|
| 69 | + ImageDestroy( $srcImage ); |
|
| 70 | + } |
|
| 71 | + } |
|
| 72 | + } |
|
| 73 | + |
|
| 74 | + if ($gd_formats) $gd_formats = join(",", $gd_formats); |
|
| 75 | + ecrire_meta("gd_formats_read", $gd_formats.$gd_formats_read_gif); |
|
| 76 | + ecrire_meta("gd_formats", $gd_formats); |
|
| 77 | + } |
|
| 78 | + |
|
| 79 | + // verifier les formats netpbm |
|
| 80 | + else if ($arg == "netpbm") { |
|
| 81 | + define('_PNMSCALE_COMMAND', 'pnmscale'); // chemin a changer dans mes_options |
|
| 82 | + if (_PNMSCALE_COMMAND == '') return; |
|
| 83 | + $netpbm_formats= Array(); |
|
| 84 | + |
|
| 85 | + $jpegtopnm_command = str_replace("pnmscale", |
|
| 86 | + "jpegtopnm", _PNMSCALE_COMMAND); |
|
| 87 | + $pnmtojpeg_command = str_replace("pnmscale", |
|
| 88 | + "pnmtojpeg", _PNMSCALE_COMMAND); |
|
| 89 | + |
|
| 90 | + $vignette = _ROOT_IMG_PACK."test.jpg"; |
|
| 91 | + $dest = _DIR_VAR . "test-jpg.jpg"; |
|
| 92 | + $commande = "$jpegtopnm_command $vignette | "._PNMSCALE_COMMAND." -width 10 | $pnmtojpeg_command > $dest"; |
|
| 93 | + spip_log($commande); |
|
| 94 | + exec($commande); |
|
| 95 | + if ($taille = @getimagesize($dest)) { |
|
| 96 | + if ($taille[1] == 10) $netpbm_formats[] = "jpg"; |
|
| 97 | + } |
|
| 98 | + $giftopnm_command = str_replace("pnmscale", "giftopnm", _PNMSCALE_COMMAND); |
|
| 99 | + $pnmtojpeg_command = str_replace("pnmscale", "pnmtojpeg", _PNMSCALE_COMMAND); |
|
| 100 | + $vignette = _ROOT_IMG_PACK."test.gif"; |
|
| 101 | + $dest = _DIR_VAR . "test-gif.jpg"; |
|
| 102 | + $commande = "$giftopnm_command $vignette | "._PNMSCALE_COMMAND." -width 10 | $pnmtojpeg_command > $dest"; |
|
| 103 | + spip_log($commande); |
|
| 104 | + exec($commande); |
|
| 105 | + if ($taille = @getimagesize($dest)) { |
|
| 106 | + if ($taille[1] == 10) $netpbm_formats[] = "gif"; |
|
| 107 | + } |
|
| 108 | + |
|
| 109 | + $pngtopnm_command = str_replace("pnmscale", "pngtopnm", _PNMSCALE_COMMAND); |
|
| 110 | + $vignette = _ROOT_IMG_PACK."test.png"; |
|
| 111 | + $dest = _DIR_VAR . "test-gif.jpg"; |
|
| 112 | + $commande = "$pngtopnm_command $vignette | "._PNMSCALE_COMMAND." -width 10 | $pnmtojpeg_command > $dest"; |
|
| 113 | + spip_log($commande); |
|
| 114 | + exec($commande); |
|
| 115 | + if ($taille = @getimagesize($dest)) { |
|
| 116 | + if ($taille[1] == 10) $netpbm_formats[] = "png"; |
|
| 117 | + } |
|
| 118 | + |
|
| 119 | + |
|
| 120 | + if ($netpbm_formats) |
|
| 121 | + $netpbm_formats = join(",", $netpbm_formats); |
|
| 122 | + else |
|
| 123 | + $netpbm_formats = ''; |
|
| 124 | + ecrire_meta("netpbm_formats", $netpbm_formats); |
|
| 125 | + } |
|
| 126 | + |
|
| 127 | + // et maintenant envoyer la vignette de tests |
|
| 128 | + if (in_array($arg,array("gd1","gd2","imagick","convert","netpbm"))) { |
|
| 129 | + include_spip('inc/filtres'); |
|
| 130 | + include_spip('inc/filtres_images_mini'); |
|
| 131 | + $taille_preview = 150; |
|
| 132 | + $image = _image_valeurs_trans(_DIR_IMG_PACK.'test_image.jpg',"reduire-$taille_preview-$taille_preview",'jpg'); |
|
| 133 | + |
|
| 134 | + $image['fichier_dest']=_DIR_VAR."test_$arg"; |
|
| 135 | + if ($preview = _image_creer_vignette($image, $taille_preview, $taille_preview, $arg, true) |
|
| 136 | + AND ($preview['width'] * $preview['height'] > 0)) |
|
| 137 | + redirige_par_entete($preview['fichier']); |
|
| 138 | + } |
|
| 139 | + |
|
| 140 | + # image echec |
|
| 141 | + redirige_par_entete(chemin_image('puce-rouge-anim.gif')); |
|
| 142 | 142 | } |
| 143 | 143 | ?> |
@@ -31,7 +31,7 @@ discard block |
||
| 31 | 31 | $srcImage = @ImageCreateFromGIF(_ROOT_IMG_PACK."test.gif"); |
| 32 | 32 | if ($srcImage) { |
| 33 | 33 | $gd_formats_read_gif = ",gif"; |
| 34 | - ImageDestroy( $srcImage ); |
|
| 34 | + ImageDestroy($srcImage); |
|
| 35 | 35 | } |
| 36 | 36 | } |
| 37 | 37 | } |
@@ -52,21 +52,21 @@ discard block |
||
| 52 | 52 | $srcImage = @ImageCreateFromJPEG(_ROOT_IMG_PACK."test.jpg"); |
| 53 | 53 | if ($srcImage) { |
| 54 | 54 | $gd_formats[] = "jpg"; |
| 55 | - ImageDestroy( $srcImage ); |
|
| 55 | + ImageDestroy($srcImage); |
|
| 56 | 56 | } |
| 57 | 57 | } |
| 58 | 58 | if (function_exists('ImageCreateFromGIF')) { |
| 59 | 59 | $srcImage = @ImageCreateFromGIF(_ROOT_IMG_PACK."test.gif"); |
| 60 | 60 | if ($srcImage) { |
| 61 | 61 | $gd_formats[] = "gif"; |
| 62 | - ImageDestroy( $srcImage ); |
|
| 62 | + ImageDestroy($srcImage); |
|
| 63 | 63 | } |
| 64 | 64 | } |
| 65 | 65 | if (function_exists('ImageCreateFromPNG')) { |
| 66 | 66 | $srcImage = @ImageCreateFromPNG(_ROOT_IMG_PACK."test.png"); |
| 67 | 67 | if ($srcImage) { |
| 68 | 68 | $gd_formats[] = "png"; |
| 69 | - ImageDestroy( $srcImage ); |
|
| 69 | + ImageDestroy($srcImage); |
|
| 70 | 70 | } |
| 71 | 71 | } |
| 72 | 72 | } |
@@ -80,7 +80,7 @@ discard block |
||
| 80 | 80 | else if ($arg == "netpbm") { |
| 81 | 81 | define('_PNMSCALE_COMMAND', 'pnmscale'); // chemin a changer dans mes_options |
| 82 | 82 | if (_PNMSCALE_COMMAND == '') return; |
| 83 | - $netpbm_formats= Array(); |
|
| 83 | + $netpbm_formats = Array(); |
|
| 84 | 84 | |
| 85 | 85 | $jpegtopnm_command = str_replace("pnmscale", |
| 86 | 86 | "jpegtopnm", _PNMSCALE_COMMAND); |
@@ -88,7 +88,7 @@ discard block |
||
| 88 | 88 | "pnmtojpeg", _PNMSCALE_COMMAND); |
| 89 | 89 | |
| 90 | 90 | $vignette = _ROOT_IMG_PACK."test.jpg"; |
| 91 | - $dest = _DIR_VAR . "test-jpg.jpg"; |
|
| 91 | + $dest = _DIR_VAR."test-jpg.jpg"; |
|
| 92 | 92 | $commande = "$jpegtopnm_command $vignette | "._PNMSCALE_COMMAND." -width 10 | $pnmtojpeg_command > $dest"; |
| 93 | 93 | spip_log($commande); |
| 94 | 94 | exec($commande); |
@@ -98,7 +98,7 @@ discard block |
||
| 98 | 98 | $giftopnm_command = str_replace("pnmscale", "giftopnm", _PNMSCALE_COMMAND); |
| 99 | 99 | $pnmtojpeg_command = str_replace("pnmscale", "pnmtojpeg", _PNMSCALE_COMMAND); |
| 100 | 100 | $vignette = _ROOT_IMG_PACK."test.gif"; |
| 101 | - $dest = _DIR_VAR . "test-gif.jpg"; |
|
| 101 | + $dest = _DIR_VAR."test-gif.jpg"; |
|
| 102 | 102 | $commande = "$giftopnm_command $vignette | "._PNMSCALE_COMMAND." -width 10 | $pnmtojpeg_command > $dest"; |
| 103 | 103 | spip_log($commande); |
| 104 | 104 | exec($commande); |
@@ -108,7 +108,7 @@ discard block |
||
| 108 | 108 | |
| 109 | 109 | $pngtopnm_command = str_replace("pnmscale", "pngtopnm", _PNMSCALE_COMMAND); |
| 110 | 110 | $vignette = _ROOT_IMG_PACK."test.png"; |
| 111 | - $dest = _DIR_VAR . "test-gif.jpg"; |
|
| 111 | + $dest = _DIR_VAR."test-gif.jpg"; |
|
| 112 | 112 | $commande = "$pngtopnm_command $vignette | "._PNMSCALE_COMMAND." -width 10 | $pnmtojpeg_command > $dest"; |
| 113 | 113 | spip_log($commande); |
| 114 | 114 | exec($commande); |
@@ -125,13 +125,13 @@ discard block |
||
| 125 | 125 | } |
| 126 | 126 | |
| 127 | 127 | // et maintenant envoyer la vignette de tests |
| 128 | - if (in_array($arg,array("gd1","gd2","imagick","convert","netpbm"))) { |
|
| 128 | + if (in_array($arg, array("gd1", "gd2", "imagick", "convert", "netpbm"))) { |
|
| 129 | 129 | include_spip('inc/filtres'); |
| 130 | 130 | include_spip('inc/filtres_images_mini'); |
| 131 | 131 | $taille_preview = 150; |
| 132 | - $image = _image_valeurs_trans(_DIR_IMG_PACK.'test_image.jpg',"reduire-$taille_preview-$taille_preview",'jpg'); |
|
| 132 | + $image = _image_valeurs_trans(_DIR_IMG_PACK.'test_image.jpg', "reduire-$taille_preview-$taille_preview", 'jpg'); |
|
| 133 | 133 | |
| 134 | - $image['fichier_dest']=_DIR_VAR."test_$arg"; |
|
| 134 | + $image['fichier_dest'] = _DIR_VAR."test_$arg"; |
|
| 135 | 135 | if ($preview = _image_creer_vignette($image, $taille_preview, $taille_preview, $arg, true) |
| 136 | 136 | AND ($preview['width'] * $preview['height'] > 0)) |
| 137 | 137 | redirige_par_entete($preview['fichier']); |
@@ -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 | // Tester nos capacites |
| 16 | 18 | // http://doc.spip.org/@action_tester_dist |
@@ -36,13 +38,13 @@ discard block |
||
| 36 | 38 | } |
| 37 | 39 | } |
| 38 | 40 | |
| 39 | - if (imagetypes() & IMG_JPG) |
|
| 40 | - $gd_formats[] = "jpg"; |
|
| 41 | - if (imagetypes() & IMG_PNG) |
|
| 42 | - $gd_formats[] = "png"; |
|
| 43 | - } |
|
| 44 | - |
|
| 45 | - else { # ancienne methode de detection des formats, qui en plus |
|
| 41 | + if (imagetypes() & IMG_JPG) { |
|
| 42 | + $gd_formats[] = "jpg"; |
|
| 43 | + } |
|
| 44 | + if (imagetypes() & IMG_PNG) { |
|
| 45 | + $gd_formats[] = "png"; |
|
| 46 | + } |
|
| 47 | + } else { # ancienne methode de detection des formats, qui en plus |
|
| 46 | 48 | # est bugguee car elle teste les formats en lecture |
| 47 | 49 | # alors que la valeur deduite sert a identifier |
| 48 | 50 | # les formats disponibles en ecriture... (cf. inc_logos) |
@@ -71,7 +73,9 @@ discard block |
||
| 71 | 73 | } |
| 72 | 74 | } |
| 73 | 75 | |
| 74 | - if ($gd_formats) $gd_formats = join(",", $gd_formats); |
|
| 76 | + if ($gd_formats) { |
|
| 77 | + $gd_formats = join(",", $gd_formats); |
|
| 78 | + } |
|
| 75 | 79 | ecrire_meta("gd_formats_read", $gd_formats.$gd_formats_read_gif); |
| 76 | 80 | ecrire_meta("gd_formats", $gd_formats); |
| 77 | 81 | } |
@@ -79,7 +83,9 @@ discard block |
||
| 79 | 83 | // verifier les formats netpbm |
| 80 | 84 | else if ($arg == "netpbm") { |
| 81 | 85 | define('_PNMSCALE_COMMAND', 'pnmscale'); // chemin a changer dans mes_options |
| 82 | - if (_PNMSCALE_COMMAND == '') return; |
|
| 86 | + if (_PNMSCALE_COMMAND == '') { |
|
| 87 | + return; |
|
| 88 | + } |
|
| 83 | 89 | $netpbm_formats= Array(); |
| 84 | 90 | |
| 85 | 91 | $jpegtopnm_command = str_replace("pnmscale", |
@@ -93,7 +99,9 @@ discard block |
||
| 93 | 99 | spip_log($commande); |
| 94 | 100 | exec($commande); |
| 95 | 101 | if ($taille = @getimagesize($dest)) { |
| 96 | - if ($taille[1] == 10) $netpbm_formats[] = "jpg"; |
|
| 102 | + if ($taille[1] == 10) { |
|
| 103 | + $netpbm_formats[] = "jpg"; |
|
| 104 | + } |
|
| 97 | 105 | } |
| 98 | 106 | $giftopnm_command = str_replace("pnmscale", "giftopnm", _PNMSCALE_COMMAND); |
| 99 | 107 | $pnmtojpeg_command = str_replace("pnmscale", "pnmtojpeg", _PNMSCALE_COMMAND); |
@@ -103,7 +111,9 @@ discard block |
||
| 103 | 111 | spip_log($commande); |
| 104 | 112 | exec($commande); |
| 105 | 113 | if ($taille = @getimagesize($dest)) { |
| 106 | - if ($taille[1] == 10) $netpbm_formats[] = "gif"; |
|
| 114 | + if ($taille[1] == 10) { |
|
| 115 | + $netpbm_formats[] = "gif"; |
|
| 116 | + } |
|
| 107 | 117 | } |
| 108 | 118 | |
| 109 | 119 | $pngtopnm_command = str_replace("pnmscale", "pngtopnm", _PNMSCALE_COMMAND); |
@@ -113,14 +123,17 @@ discard block |
||
| 113 | 123 | spip_log($commande); |
| 114 | 124 | exec($commande); |
| 115 | 125 | if ($taille = @getimagesize($dest)) { |
| 116 | - if ($taille[1] == 10) $netpbm_formats[] = "png"; |
|
| 126 | + if ($taille[1] == 10) { |
|
| 127 | + $netpbm_formats[] = "png"; |
|
| 128 | + } |
|
| 117 | 129 | } |
| 118 | 130 | |
| 119 | 131 | |
| 120 | - if ($netpbm_formats) |
|
| 121 | - $netpbm_formats = join(",", $netpbm_formats); |
|
| 122 | - else |
|
| 123 | - $netpbm_formats = ''; |
|
| 132 | + if ($netpbm_formats) { |
|
| 133 | + $netpbm_formats = join(",", $netpbm_formats); |
|
| 134 | + } else { |
|
| 135 | + $netpbm_formats = ''; |
|
| 136 | + } |
|
| 124 | 137 | ecrire_meta("netpbm_formats", $netpbm_formats); |
| 125 | 138 | } |
| 126 | 139 | |
@@ -133,8 +146,9 @@ discard block |
||
| 133 | 146 | |
| 134 | 147 | $image['fichier_dest']=_DIR_VAR."test_$arg"; |
| 135 | 148 | if ($preview = _image_creer_vignette($image, $taille_preview, $taille_preview, $arg, true) |
| 136 | - AND ($preview['width'] * $preview['height'] > 0)) |
|
| 137 | - redirige_par_entete($preview['fichier']); |
|
| 149 | + AND ($preview['width'] * $preview['height'] > 0)) { |
|
| 150 | + redirige_par_entete($preview['fichier']); |
|
| 151 | + } |
|
| 138 | 152 | } |
| 139 | 153 | |
| 140 | 154 | # image echec |
@@ -24,42 +24,42 @@ |
||
| 24 | 24 | */ |
| 25 | 25 | function action_supprimer_rubrique_dist($id_rubrique=null) { |
| 26 | 26 | |
| 27 | - if (is_null($id_rubrique)){ |
|
| 28 | - $securiser_action = charger_fonction('securiser_action', 'inc'); |
|
| 29 | - $id_rubrique = $securiser_action(); |
|
| 30 | - } |
|
| 27 | + if (is_null($id_rubrique)){ |
|
| 28 | + $securiser_action = charger_fonction('securiser_action', 'inc'); |
|
| 29 | + $id_rubrique = $securiser_action(); |
|
| 30 | + } |
|
| 31 | 31 | |
| 32 | - if (intval($id_rubrique)){ |
|
| 32 | + if (intval($id_rubrique)){ |
|
| 33 | 33 | |
| 34 | - sql_delete("spip_rubriques", "id_rubrique=".intval($id_rubrique)); |
|
| 35 | - // Les admin restreints qui n'administraient que cette rubrique |
|
| 36 | - // deviennent redacteurs |
|
| 37 | - // (il y a sans doute moyen de faire ca avec un having) |
|
| 34 | + sql_delete("spip_rubriques", "id_rubrique=".intval($id_rubrique)); |
|
| 35 | + // Les admin restreints qui n'administraient que cette rubrique |
|
| 36 | + // deviennent redacteurs |
|
| 37 | + // (il y a sans doute moyen de faire ca avec un having) |
|
| 38 | 38 | |
| 39 | - $q = sql_select("id_auteur", "spip_auteurs_liens", "objet='rubrique' AND id_objet=".intval($id_rubrique)); |
|
| 40 | - while ($r = sql_fetch($q)) { |
|
| 41 | - $id_auteur = $r['id_auteur']; |
|
| 42 | - // degrader avant de supprimer la restriction d'admin |
|
| 43 | - // section critique sur les droits |
|
| 44 | - $n = sql_countsel("spip_auteurs_liens", "objet='rubrique' AND id_objet!=".intval($id_rubrique)." AND id_auteur=".intval($id_auteur)); |
|
| 45 | - if (!$n) { |
|
| 46 | - include_spip('action/editer_auteur'); |
|
| 47 | - auteurs_set($id_auteur,array("statut" => '1comite')); |
|
| 48 | - } |
|
| 49 | - sql_delete("spip_auteurs_liens", "objet='rubrique' AND id_objet=".intval($id_rubrique)." AND id_auteur=".intval($id_auteur)); |
|
| 50 | - } |
|
| 51 | - // menu_rubriques devra recalculer |
|
| 52 | - effacer_meta("date_calcul_rubriques"); |
|
| 39 | + $q = sql_select("id_auteur", "spip_auteurs_liens", "objet='rubrique' AND id_objet=".intval($id_rubrique)); |
|
| 40 | + while ($r = sql_fetch($q)) { |
|
| 41 | + $id_auteur = $r['id_auteur']; |
|
| 42 | + // degrader avant de supprimer la restriction d'admin |
|
| 43 | + // section critique sur les droits |
|
| 44 | + $n = sql_countsel("spip_auteurs_liens", "objet='rubrique' AND id_objet!=".intval($id_rubrique)." AND id_auteur=".intval($id_auteur)); |
|
| 45 | + if (!$n) { |
|
| 46 | + include_spip('action/editer_auteur'); |
|
| 47 | + auteurs_set($id_auteur,array("statut" => '1comite')); |
|
| 48 | + } |
|
| 49 | + sql_delete("spip_auteurs_liens", "objet='rubrique' AND id_objet=".intval($id_rubrique)." AND id_auteur=".intval($id_auteur)); |
|
| 50 | + } |
|
| 51 | + // menu_rubriques devra recalculer |
|
| 52 | + effacer_meta("date_calcul_rubriques"); |
|
| 53 | 53 | |
| 54 | - // Une rubrique supprimable n'avait pas le statut "publie" |
|
| 55 | - // donc rien de neuf pour la rubrique parente |
|
| 56 | - include_spip('inc/rubriques'); |
|
| 57 | - calculer_langues_rubriques(); |
|
| 54 | + // Une rubrique supprimable n'avait pas le statut "publie" |
|
| 55 | + // donc rien de neuf pour la rubrique parente |
|
| 56 | + include_spip('inc/rubriques'); |
|
| 57 | + calculer_langues_rubriques(); |
|
| 58 | 58 | |
| 59 | - // invalider les caches marques de cette rubrique |
|
| 60 | - include_spip('inc/invalideur'); |
|
| 61 | - suivre_invalideur("id='rubrique/$id_rubrique'"); |
|
| 62 | - } |
|
| 59 | + // invalider les caches marques de cette rubrique |
|
| 60 | + include_spip('inc/invalideur'); |
|
| 61 | + suivre_invalideur("id='rubrique/$id_rubrique'"); |
|
| 62 | + } |
|
| 63 | 63 | } |
| 64 | 64 | |
| 65 | 65 | ?> |
@@ -12,7 +12,7 @@ discard block |
||
| 12 | 12 | |
| 13 | 13 | if (!defined('_ECRIRE_INC_VERSION')) return; |
| 14 | 14 | |
| 15 | -include_spip('inc/charsets'); # pour le nom de fichier |
|
| 15 | +include_spip('inc/charsets'); # pour le nom de fichier |
|
| 16 | 16 | |
| 17 | 17 | /** |
| 18 | 18 | * Effacer une rubrique |
@@ -22,14 +22,14 @@ discard block |
||
| 22 | 22 | * @param null $id_rubrique |
| 23 | 23 | * @return void |
| 24 | 24 | */ |
| 25 | -function action_supprimer_rubrique_dist($id_rubrique=null) { |
|
| 25 | +function action_supprimer_rubrique_dist($id_rubrique = null) { |
|
| 26 | 26 | |
| 27 | - if (is_null($id_rubrique)){ |
|
| 27 | + if (is_null($id_rubrique)) { |
|
| 28 | 28 | $securiser_action = charger_fonction('securiser_action', 'inc'); |
| 29 | 29 | $id_rubrique = $securiser_action(); |
| 30 | 30 | } |
| 31 | 31 | |
| 32 | - if (intval($id_rubrique)){ |
|
| 32 | + if (intval($id_rubrique)) { |
|
| 33 | 33 | |
| 34 | 34 | sql_delete("spip_rubriques", "id_rubrique=".intval($id_rubrique)); |
| 35 | 35 | // Les admin restreints qui n'administraient que cette rubrique |
@@ -44,7 +44,7 @@ discard block |
||
| 44 | 44 | $n = sql_countsel("spip_auteurs_liens", "objet='rubrique' AND id_objet!=".intval($id_rubrique)." AND id_auteur=".intval($id_auteur)); |
| 45 | 45 | if (!$n) { |
| 46 | 46 | include_spip('action/editer_auteur'); |
| 47 | - auteurs_set($id_auteur,array("statut" => '1comite')); |
|
| 47 | + auteurs_set($id_auteur, array("statut" => '1comite')); |
|
| 48 | 48 | } |
| 49 | 49 | sql_delete("spip_auteurs_liens", "objet='rubrique' AND id_objet=".intval($id_rubrique)." AND id_auteur=".intval($id_auteur)); |
| 50 | 50 | } |
@@ -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/charsets'); # pour le nom de fichier |
| 16 | 18 | |
@@ -18,18 +18,18 @@ |
||
| 18 | 18 | // http://doc.spip.org/@action_session_dist |
| 19 | 19 | function action_session_dist() |
| 20 | 20 | { |
| 21 | - if ($var = _request('var') |
|
| 22 | - AND preg_match(',^[a-z_0-9-]+$,i', $var) |
|
| 23 | - ) { |
|
| 24 | - if ($_SERVER['REQUEST_METHOD'] == 'POST'){ |
|
| 25 | - include_spip('inc/session'); |
|
| 26 | - session_set('session_'.$var, $val=_request('val')); |
|
| 27 | - #spip_log("autosave:$var:$val",'autosave'); |
|
| 28 | - } |
|
| 29 | - } |
|
| 21 | + if ($var = _request('var') |
|
| 22 | + AND preg_match(',^[a-z_0-9-]+$,i', $var) |
|
| 23 | + ) { |
|
| 24 | + if ($_SERVER['REQUEST_METHOD'] == 'POST'){ |
|
| 25 | + include_spip('inc/session'); |
|
| 26 | + session_set('session_'.$var, $val=_request('val')); |
|
| 27 | + #spip_log("autosave:$var:$val",'autosave'); |
|
| 28 | + } |
|
| 29 | + } |
|
| 30 | 30 | |
| 31 | - # TODO: mode lecture de session ; n'afficher que ce qu'il faut |
|
| 32 | - #echo json_encode($GLOBALS['visiteur_session']); |
|
| 31 | + # TODO: mode lecture de session ; n'afficher que ce qu'il faut |
|
| 32 | + #echo json_encode($GLOBALS['visiteur_session']); |
|
| 33 | 33 | } |
| 34 | 34 | |
| 35 | 35 | |
@@ -21,9 +21,9 @@ |
||
| 21 | 21 | if ($var = _request('var') |
| 22 | 22 | AND preg_match(',^[a-z_0-9-]+$,i', $var) |
| 23 | 23 | ) { |
| 24 | - if ($_SERVER['REQUEST_METHOD'] == 'POST'){ |
|
| 24 | + if ($_SERVER['REQUEST_METHOD'] == 'POST') { |
|
| 25 | 25 | include_spip('inc/session'); |
| 26 | - session_set('session_'.$var, $val=_request('val')); |
|
| 26 | + session_set('session_'.$var, $val = _request('val')); |
|
| 27 | 27 | #spip_log("autosave:$var:$val",'autosave'); |
| 28 | 28 | } |
| 29 | 29 | } |
@@ -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 | // Pour poser une variable de session |
| 16 | 18 | // poster sur cette action en indiquant var/val |
@@ -14,32 +14,32 @@ discard block |
||
| 14 | 14 | |
| 15 | 15 | // http://doc.spip.org/@action_editer_article_dist |
| 16 | 16 | function action_editer_article_dist($arg=null) { |
| 17 | - include_spip('inc/autoriser'); |
|
| 18 | - $err=""; |
|
| 19 | - if (is_null($arg)){ |
|
| 20 | - $securiser_action = charger_fonction('securiser_action', 'inc'); |
|
| 21 | - $arg = $securiser_action(); |
|
| 22 | - } |
|
| 23 | - |
|
| 24 | - // si id_article n'est pas un nombre, c'est une creation |
|
| 25 | - // mais on verifie qu'on a toutes les donnees qu'il faut. |
|
| 26 | - if (!$id_article = intval($arg)) { |
|
| 27 | - $id_parent = _request('id_parent'); |
|
| 28 | - if (!$id_parent) |
|
| 29 | - $err = _L("creation interdite d'un article sans rubrique"); |
|
| 30 | - elseif(!autoriser('creerarticledans','rubrique',$id_parent)) |
|
| 31 | - $err = _T("info_creerdansrubrique_non_autorise"); |
|
| 32 | - else |
|
| 33 | - $id_article = article_inserer($id_parent); |
|
| 34 | - } |
|
| 35 | - |
|
| 36 | - // Enregistre l'envoi dans la BD |
|
| 37 | - if ($id_article > 0) $err = article_modifier($id_article); |
|
| 38 | - |
|
| 39 | - if ($err) |
|
| 40 | - spip_log("echec editeur article: $err",_LOG_ERREUR); |
|
| 41 | - |
|
| 42 | - return array($id_article,$err); |
|
| 17 | + include_spip('inc/autoriser'); |
|
| 18 | + $err=""; |
|
| 19 | + if (is_null($arg)){ |
|
| 20 | + $securiser_action = charger_fonction('securiser_action', 'inc'); |
|
| 21 | + $arg = $securiser_action(); |
|
| 22 | + } |
|
| 23 | + |
|
| 24 | + // si id_article n'est pas un nombre, c'est une creation |
|
| 25 | + // mais on verifie qu'on a toutes les donnees qu'il faut. |
|
| 26 | + if (!$id_article = intval($arg)) { |
|
| 27 | + $id_parent = _request('id_parent'); |
|
| 28 | + if (!$id_parent) |
|
| 29 | + $err = _L("creation interdite d'un article sans rubrique"); |
|
| 30 | + elseif(!autoriser('creerarticledans','rubrique',$id_parent)) |
|
| 31 | + $err = _T("info_creerdansrubrique_non_autorise"); |
|
| 32 | + else |
|
| 33 | + $id_article = article_inserer($id_parent); |
|
| 34 | + } |
|
| 35 | + |
|
| 36 | + // Enregistre l'envoi dans la BD |
|
| 37 | + if ($id_article > 0) $err = article_modifier($id_article); |
|
| 38 | + |
|
| 39 | + if ($err) |
|
| 40 | + spip_log("echec editeur article: $err",_LOG_ERREUR); |
|
| 41 | + |
|
| 42 | + return array($id_article,$err); |
|
| 43 | 43 | } |
| 44 | 44 | |
| 45 | 45 | /** |
@@ -53,44 +53,44 @@ discard block |
||
| 53 | 53 | */ |
| 54 | 54 | function article_modifier($id_article, $set=null) { |
| 55 | 55 | |
| 56 | - // unifier $texte en cas de texte trop long |
|
| 57 | - trop_longs_articles(); |
|
| 58 | - |
|
| 59 | - include_spip('inc/modifier'); |
|
| 60 | - include_spip('inc/filtres'); |
|
| 61 | - $c = collecter_requests( |
|
| 62 | - // white list |
|
| 63 | - objet_info('article','champs_editables'), |
|
| 64 | - // black list |
|
| 65 | - array('date','statut','id_parent'), |
|
| 66 | - // donnees eventuellement fournies |
|
| 67 | - $set |
|
| 68 | - ); |
|
| 69 | - |
|
| 70 | - // Si l'article est publie, invalider les caches et demander sa reindexation |
|
| 71 | - $t = sql_getfetsel("statut", "spip_articles", "id_article=".intval($id_article)); |
|
| 72 | - $invalideur = $indexation = false; |
|
| 73 | - if ($t == 'publie') { |
|
| 74 | - $invalideur = "id='article/$id_article'"; |
|
| 75 | - $indexation = true; |
|
| 76 | - } |
|
| 77 | - |
|
| 78 | - if ($err = objet_modifier_champs('article', $id_article, |
|
| 79 | - array( |
|
| 80 | - 'data' => $set, |
|
| 81 | - 'nonvide' => array('titre' => _T('info_nouvel_article')." "._T('info_numero_abbreviation').$id_article), |
|
| 82 | - 'invalideur' => $invalideur, |
|
| 83 | - 'indexation' => $indexation, |
|
| 84 | - 'date_modif' => 'date_modif' // champ a mettre a date('Y-m-d H:i:s') s'il y a modif |
|
| 85 | - ), |
|
| 86 | - $c)) |
|
| 87 | - return $err; |
|
| 88 | - |
|
| 89 | - // Modification de statut, changement de rubrique ? |
|
| 90 | - $c = collecter_requests(array('date', 'statut', 'id_parent'),array(),$set); |
|
| 91 | - $err = article_instituer($id_article, $c); |
|
| 92 | - |
|
| 93 | - return $err; |
|
| 56 | + // unifier $texte en cas de texte trop long |
|
| 57 | + trop_longs_articles(); |
|
| 58 | + |
|
| 59 | + include_spip('inc/modifier'); |
|
| 60 | + include_spip('inc/filtres'); |
|
| 61 | + $c = collecter_requests( |
|
| 62 | + // white list |
|
| 63 | + objet_info('article','champs_editables'), |
|
| 64 | + // black list |
|
| 65 | + array('date','statut','id_parent'), |
|
| 66 | + // donnees eventuellement fournies |
|
| 67 | + $set |
|
| 68 | + ); |
|
| 69 | + |
|
| 70 | + // Si l'article est publie, invalider les caches et demander sa reindexation |
|
| 71 | + $t = sql_getfetsel("statut", "spip_articles", "id_article=".intval($id_article)); |
|
| 72 | + $invalideur = $indexation = false; |
|
| 73 | + if ($t == 'publie') { |
|
| 74 | + $invalideur = "id='article/$id_article'"; |
|
| 75 | + $indexation = true; |
|
| 76 | + } |
|
| 77 | + |
|
| 78 | + if ($err = objet_modifier_champs('article', $id_article, |
|
| 79 | + array( |
|
| 80 | + 'data' => $set, |
|
| 81 | + 'nonvide' => array('titre' => _T('info_nouvel_article')." "._T('info_numero_abbreviation').$id_article), |
|
| 82 | + 'invalideur' => $invalideur, |
|
| 83 | + 'indexation' => $indexation, |
|
| 84 | + 'date_modif' => 'date_modif' // champ a mettre a date('Y-m-d H:i:s') s'il y a modif |
|
| 85 | + ), |
|
| 86 | + $c)) |
|
| 87 | + return $err; |
|
| 88 | + |
|
| 89 | + // Modification de statut, changement de rubrique ? |
|
| 90 | + $c = collecter_requests(array('date', 'statut', 'id_parent'),array(),$set); |
|
| 91 | + $err = article_instituer($id_article, $c); |
|
| 92 | + |
|
| 93 | + return $err; |
|
| 94 | 94 | } |
| 95 | 95 | |
| 96 | 96 | /** |
@@ -103,81 +103,81 @@ discard block |
||
| 103 | 103 | function article_inserer($id_rubrique) { |
| 104 | 104 | |
| 105 | 105 | |
| 106 | - // Si id_rubrique vaut 0 ou n'est pas definie, creer l'article |
|
| 107 | - // dans la premiere rubrique racine |
|
| 108 | - if (!$id_rubrique = intval($id_rubrique)) { |
|
| 109 | - $row = sql_fetsel("id_rubrique, id_secteur, lang", "spip_rubriques", "id_parent=0",'', '0+titre,titre', "1"); |
|
| 110 | - $id_rubrique = $row['id_rubrique']; |
|
| 111 | - } else $row = sql_fetsel("lang, id_secteur", "spip_rubriques", "id_rubrique=$id_rubrique"); |
|
| 106 | + // Si id_rubrique vaut 0 ou n'est pas definie, creer l'article |
|
| 107 | + // dans la premiere rubrique racine |
|
| 108 | + if (!$id_rubrique = intval($id_rubrique)) { |
|
| 109 | + $row = sql_fetsel("id_rubrique, id_secteur, lang", "spip_rubriques", "id_parent=0",'', '0+titre,titre', "1"); |
|
| 110 | + $id_rubrique = $row['id_rubrique']; |
|
| 111 | + } else $row = sql_fetsel("lang, id_secteur", "spip_rubriques", "id_rubrique=$id_rubrique"); |
|
| 112 | 112 | |
| 113 | - // eviter $id_secteur = NULL (erreur sqlite) si la requete precedente echoue |
|
| 114 | - // cas de id_rubrique = -1 par exemple avec plugin "pages" |
|
| 115 | - $id_secteur = isset($row['id_secteur']) ? $row['id_secteur'] : 0; |
|
| 113 | + // eviter $id_secteur = NULL (erreur sqlite) si la requete precedente echoue |
|
| 114 | + // cas de id_rubrique = -1 par exemple avec plugin "pages" |
|
| 115 | + $id_secteur = isset($row['id_secteur']) ? $row['id_secteur'] : 0; |
|
| 116 | 116 | |
| 117 | - $lang_rub = $row['lang']; |
|
| 118 | - |
|
| 119 | - $lang = ""; |
|
| 120 | - $choisie = 'non'; |
|
| 121 | - // La langue a la creation : si les liens de traduction sont autorises |
|
| 122 | - // dans les rubriques, on essaie avec la langue de l'auteur, |
|
| 123 | - // ou a defaut celle de la rubrique |
|
| 124 | - // Sinon c'est la langue de la rubrique qui est choisie + heritee |
|
| 125 | - if (in_array('spip_articles',explode(',',$GLOBALS['meta']['multi_objets']))) { |
|
| 126 | - lang_select($GLOBALS['visiteur_session']['lang']); |
|
| 127 | - if (in_array($GLOBALS['spip_lang'], |
|
| 128 | - explode(',', $GLOBALS['meta']['langues_multilingue']))) { |
|
| 129 | - $lang = $GLOBALS['spip_lang']; |
|
| 130 | - $choisie = 'oui'; |
|
| 131 | - } |
|
| 132 | - } |
|
| 133 | - |
|
| 134 | - if (!$lang) { |
|
| 135 | - $choisie = 'non'; |
|
| 136 | - $lang = $lang_rub ? $lang_rub : $GLOBALS['meta']['langue_site']; |
|
| 137 | - } |
|
| 138 | - |
|
| 139 | - $champs = array( |
|
| 140 | - 'id_rubrique' => $id_rubrique, |
|
| 141 | - 'id_secteur' => $id_secteur, |
|
| 142 | - 'statut' => 'prepa', |
|
| 143 | - 'date' => date('Y-m-d H:i:s'), |
|
| 144 | - 'lang' => $lang, |
|
| 145 | - 'langue_choisie' =>$choisie); |
|
| 146 | - |
|
| 147 | - // Envoyer aux plugins |
|
| 148 | - $champs = pipeline('pre_insertion', |
|
| 149 | - array( |
|
| 150 | - 'args' => array( |
|
| 151 | - 'table' => 'spip_articles', |
|
| 152 | - ), |
|
| 153 | - 'data' => $champs |
|
| 154 | - ) |
|
| 155 | - ); |
|
| 156 | - |
|
| 157 | - $id_article = sql_insertq("spip_articles", $champs); |
|
| 158 | - |
|
| 159 | - pipeline('post_insertion', |
|
| 160 | - array( |
|
| 161 | - 'args' => array( |
|
| 162 | - 'table' => 'spip_articles', |
|
| 163 | - 'id_objet' => $id_article |
|
| 164 | - ), |
|
| 165 | - 'data' => $champs |
|
| 166 | - ) |
|
| 167 | - ); |
|
| 168 | - |
|
| 169 | - // controler si le serveur n'a pas renvoye une erreur |
|
| 170 | - if ($id_article > 0){ |
|
| 171 | - $id_auteur = ((is_null(_request('id_auteur')) AND isset($GLOBALS['visiteur_session']['id_auteur']))? |
|
| 172 | - $GLOBALS['visiteur_session']['id_auteur'] |
|
| 173 | - :_request('id_auteur')); |
|
| 174 | - if ($id_auteur){ |
|
| 175 | - include_spip('action/editer_auteur'); |
|
| 176 | - auteur_associer($id_auteur, array('article'=>$id_article)); |
|
| 177 | - } |
|
| 178 | - } |
|
| 179 | - |
|
| 180 | - return $id_article; |
|
| 117 | + $lang_rub = $row['lang']; |
|
| 118 | + |
|
| 119 | + $lang = ""; |
|
| 120 | + $choisie = 'non'; |
|
| 121 | + // La langue a la creation : si les liens de traduction sont autorises |
|
| 122 | + // dans les rubriques, on essaie avec la langue de l'auteur, |
|
| 123 | + // ou a defaut celle de la rubrique |
|
| 124 | + // Sinon c'est la langue de la rubrique qui est choisie + heritee |
|
| 125 | + if (in_array('spip_articles',explode(',',$GLOBALS['meta']['multi_objets']))) { |
|
| 126 | + lang_select($GLOBALS['visiteur_session']['lang']); |
|
| 127 | + if (in_array($GLOBALS['spip_lang'], |
|
| 128 | + explode(',', $GLOBALS['meta']['langues_multilingue']))) { |
|
| 129 | + $lang = $GLOBALS['spip_lang']; |
|
| 130 | + $choisie = 'oui'; |
|
| 131 | + } |
|
| 132 | + } |
|
| 133 | + |
|
| 134 | + if (!$lang) { |
|
| 135 | + $choisie = 'non'; |
|
| 136 | + $lang = $lang_rub ? $lang_rub : $GLOBALS['meta']['langue_site']; |
|
| 137 | + } |
|
| 138 | + |
|
| 139 | + $champs = array( |
|
| 140 | + 'id_rubrique' => $id_rubrique, |
|
| 141 | + 'id_secteur' => $id_secteur, |
|
| 142 | + 'statut' => 'prepa', |
|
| 143 | + 'date' => date('Y-m-d H:i:s'), |
|
| 144 | + 'lang' => $lang, |
|
| 145 | + 'langue_choisie' =>$choisie); |
|
| 146 | + |
|
| 147 | + // Envoyer aux plugins |
|
| 148 | + $champs = pipeline('pre_insertion', |
|
| 149 | + array( |
|
| 150 | + 'args' => array( |
|
| 151 | + 'table' => 'spip_articles', |
|
| 152 | + ), |
|
| 153 | + 'data' => $champs |
|
| 154 | + ) |
|
| 155 | + ); |
|
| 156 | + |
|
| 157 | + $id_article = sql_insertq("spip_articles", $champs); |
|
| 158 | + |
|
| 159 | + pipeline('post_insertion', |
|
| 160 | + array( |
|
| 161 | + 'args' => array( |
|
| 162 | + 'table' => 'spip_articles', |
|
| 163 | + 'id_objet' => $id_article |
|
| 164 | + ), |
|
| 165 | + 'data' => $champs |
|
| 166 | + ) |
|
| 167 | + ); |
|
| 168 | + |
|
| 169 | + // controler si le serveur n'a pas renvoye une erreur |
|
| 170 | + if ($id_article > 0){ |
|
| 171 | + $id_auteur = ((is_null(_request('id_auteur')) AND isset($GLOBALS['visiteur_session']['id_auteur']))? |
|
| 172 | + $GLOBALS['visiteur_session']['id_auteur'] |
|
| 173 | + :_request('id_auteur')); |
|
| 174 | + if ($id_auteur){ |
|
| 175 | + include_spip('action/editer_auteur'); |
|
| 176 | + auteur_associer($id_auteur, array('article'=>$id_article)); |
|
| 177 | + } |
|
| 178 | + } |
|
| 179 | + |
|
| 180 | + return $id_article; |
|
| 181 | 181 | } |
| 182 | 182 | |
| 183 | 183 | |
@@ -188,111 +188,111 @@ discard block |
||
| 188 | 188 | // http://doc.spip.org/@instituer_article |
| 189 | 189 | function article_instituer($id_article, $c, $calcul_rub=true) { |
| 190 | 190 | |
| 191 | - include_spip('inc/autoriser'); |
|
| 192 | - include_spip('inc/rubriques'); |
|
| 193 | - include_spip('inc/modifier'); |
|
| 194 | - |
|
| 195 | - $row = sql_fetsel("statut, date, id_rubrique", "spip_articles", "id_article=$id_article"); |
|
| 196 | - $id_rubrique = $row['id_rubrique']; |
|
| 197 | - $statut_ancien = $statut = $row['statut']; |
|
| 198 | - $date_ancienne = $date = $row['date']; |
|
| 199 | - $champs = array(); |
|
| 200 | - |
|
| 201 | - $d = isset($c['date'])?$c['date']:null; |
|
| 202 | - $s = isset($c['statut'])?$c['statut']:$statut; |
|
| 203 | - |
|
| 204 | - // cf autorisations dans inc/instituer_article |
|
| 205 | - if ($s != $statut OR ($d AND $d != $date)) { |
|
| 206 | - if (autoriser('publierdans', 'rubrique', $id_rubrique)) |
|
| 207 | - $statut = $champs['statut'] = $s; |
|
| 208 | - else if (autoriser('modifier', 'article', $id_article) AND $s != 'publie') |
|
| 209 | - $statut = $champs['statut'] = $s; |
|
| 210 | - else |
|
| 211 | - spip_log("editer_article $id_article refus " . join(' ', $c)); |
|
| 212 | - |
|
| 213 | - // En cas de publication, fixer la date a "maintenant" |
|
| 214 | - // sauf si $c commande autre chose |
|
| 215 | - // ou si l'article est deja date dans le futur |
|
| 216 | - // En cas de proposition d'un article (mais pas depublication), idem |
|
| 217 | - if ($champs['statut'] == 'publie' |
|
| 218 | - OR ($champs['statut'] == 'prop' AND ($d OR !in_array($statut_ancien, array('publie', 'prop')))) |
|
| 219 | - ) { |
|
| 220 | - if ($d OR strtotime($d=$date)>time()) |
|
| 221 | - $champs['date'] = $date = $d; |
|
| 222 | - else |
|
| 223 | - $champs['date'] = $date = date('Y-m-d H:i:s'); |
|
| 224 | - } |
|
| 225 | - } |
|
| 226 | - |
|
| 227 | - // Verifier que la rubrique demandee existe et est differente |
|
| 228 | - // de la rubrique actuelle |
|
| 229 | - if ($id_parent = $c['id_parent'] |
|
| 230 | - AND $id_parent != $id_rubrique |
|
| 231 | - AND (sql_fetsel('1', "spip_rubriques", "id_rubrique=$id_parent"))) { |
|
| 232 | - $champs['id_rubrique'] = $id_parent; |
|
| 233 | - |
|
| 234 | - // si l'article etait publie |
|
| 235 | - // et que le demandeur n'est pas admin de la rubrique de destination |
|
| 236 | - // repasser l'article en statut 'propose'. |
|
| 237 | - if ($statut == 'publie' |
|
| 238 | - AND !autoriser('publierdans', 'rubrique', $id_parent)) |
|
| 239 | - $champs['statut'] = 'prop'; |
|
| 240 | - } |
|
| 241 | - |
|
| 242 | - // Envoyer aux plugins |
|
| 243 | - $champs = pipeline('pre_edition', |
|
| 244 | - array( |
|
| 245 | - 'args' => array( |
|
| 246 | - 'table' => 'spip_articles', |
|
| 247 | - 'id_objet' => $id_article, |
|
| 248 | - 'action'=>'instituer', |
|
| 249 | - 'statut_ancien' => $statut_ancien, |
|
| 250 | - 'date_ancienne' => $date_ancienne, |
|
| 251 | - ), |
|
| 252 | - 'data' => $champs |
|
| 253 | - ) |
|
| 254 | - ); |
|
| 255 | - |
|
| 256 | - if (!count($champs)) return ''; |
|
| 257 | - |
|
| 258 | - // Envoyer les modifs. |
|
| 259 | - |
|
| 260 | - editer_article_heritage($id_article, $id_rubrique, $statut_ancien, $champs, $calcul_rub); |
|
| 261 | - |
|
| 262 | - // Invalider les caches |
|
| 263 | - include_spip('inc/invalideur'); |
|
| 264 | - suivre_invalideur("id='article/$id_article'"); |
|
| 265 | - |
|
| 266 | - if ($date) { |
|
| 267 | - $t = strtotime($date); |
|
| 268 | - $p = @$GLOBALS['meta']['date_prochain_postdate']; |
|
| 269 | - if ($t > time() AND (!$p OR ($t < $p))) { |
|
| 270 | - ecrire_meta('date_prochain_postdate', $t); |
|
| 271 | - } |
|
| 272 | - } |
|
| 273 | - |
|
| 274 | - // Pipeline |
|
| 275 | - pipeline('post_edition', |
|
| 276 | - array( |
|
| 277 | - 'args' => array( |
|
| 278 | - 'table' => 'spip_articles', |
|
| 279 | - 'id_objet' => $id_article, |
|
| 280 | - 'action'=>'instituer', |
|
| 281 | - 'statut_ancien' => $statut_ancien, |
|
| 282 | - 'date_ancienne' => $date_ancienne, |
|
| 283 | - ), |
|
| 284 | - 'data' => $champs |
|
| 285 | - ) |
|
| 286 | - ); |
|
| 287 | - |
|
| 288 | - // Notifications |
|
| 289 | - if ($notifications = charger_fonction('notifications', 'inc')) { |
|
| 290 | - $notifications('instituerarticle', $id_article, |
|
| 291 | - array('statut' => $statut, 'statut_ancien' => $statut_ancien, 'date'=>$date, 'date_ancienne' => $date_ancienne) |
|
| 292 | - ); |
|
| 293 | - } |
|
| 294 | - |
|
| 295 | - return ''; // pas d'erreur |
|
| 191 | + include_spip('inc/autoriser'); |
|
| 192 | + include_spip('inc/rubriques'); |
|
| 193 | + include_spip('inc/modifier'); |
|
| 194 | + |
|
| 195 | + $row = sql_fetsel("statut, date, id_rubrique", "spip_articles", "id_article=$id_article"); |
|
| 196 | + $id_rubrique = $row['id_rubrique']; |
|
| 197 | + $statut_ancien = $statut = $row['statut']; |
|
| 198 | + $date_ancienne = $date = $row['date']; |
|
| 199 | + $champs = array(); |
|
| 200 | + |
|
| 201 | + $d = isset($c['date'])?$c['date']:null; |
|
| 202 | + $s = isset($c['statut'])?$c['statut']:$statut; |
|
| 203 | + |
|
| 204 | + // cf autorisations dans inc/instituer_article |
|
| 205 | + if ($s != $statut OR ($d AND $d != $date)) { |
|
| 206 | + if (autoriser('publierdans', 'rubrique', $id_rubrique)) |
|
| 207 | + $statut = $champs['statut'] = $s; |
|
| 208 | + else if (autoriser('modifier', 'article', $id_article) AND $s != 'publie') |
|
| 209 | + $statut = $champs['statut'] = $s; |
|
| 210 | + else |
|
| 211 | + spip_log("editer_article $id_article refus " . join(' ', $c)); |
|
| 212 | + |
|
| 213 | + // En cas de publication, fixer la date a "maintenant" |
|
| 214 | + // sauf si $c commande autre chose |
|
| 215 | + // ou si l'article est deja date dans le futur |
|
| 216 | + // En cas de proposition d'un article (mais pas depublication), idem |
|
| 217 | + if ($champs['statut'] == 'publie' |
|
| 218 | + OR ($champs['statut'] == 'prop' AND ($d OR !in_array($statut_ancien, array('publie', 'prop')))) |
|
| 219 | + ) { |
|
| 220 | + if ($d OR strtotime($d=$date)>time()) |
|
| 221 | + $champs['date'] = $date = $d; |
|
| 222 | + else |
|
| 223 | + $champs['date'] = $date = date('Y-m-d H:i:s'); |
|
| 224 | + } |
|
| 225 | + } |
|
| 226 | + |
|
| 227 | + // Verifier que la rubrique demandee existe et est differente |
|
| 228 | + // de la rubrique actuelle |
|
| 229 | + if ($id_parent = $c['id_parent'] |
|
| 230 | + AND $id_parent != $id_rubrique |
|
| 231 | + AND (sql_fetsel('1', "spip_rubriques", "id_rubrique=$id_parent"))) { |
|
| 232 | + $champs['id_rubrique'] = $id_parent; |
|
| 233 | + |
|
| 234 | + // si l'article etait publie |
|
| 235 | + // et que le demandeur n'est pas admin de la rubrique de destination |
|
| 236 | + // repasser l'article en statut 'propose'. |
|
| 237 | + if ($statut == 'publie' |
|
| 238 | + AND !autoriser('publierdans', 'rubrique', $id_parent)) |
|
| 239 | + $champs['statut'] = 'prop'; |
|
| 240 | + } |
|
| 241 | + |
|
| 242 | + // Envoyer aux plugins |
|
| 243 | + $champs = pipeline('pre_edition', |
|
| 244 | + array( |
|
| 245 | + 'args' => array( |
|
| 246 | + 'table' => 'spip_articles', |
|
| 247 | + 'id_objet' => $id_article, |
|
| 248 | + 'action'=>'instituer', |
|
| 249 | + 'statut_ancien' => $statut_ancien, |
|
| 250 | + 'date_ancienne' => $date_ancienne, |
|
| 251 | + ), |
|
| 252 | + 'data' => $champs |
|
| 253 | + ) |
|
| 254 | + ); |
|
| 255 | + |
|
| 256 | + if (!count($champs)) return ''; |
|
| 257 | + |
|
| 258 | + // Envoyer les modifs. |
|
| 259 | + |
|
| 260 | + editer_article_heritage($id_article, $id_rubrique, $statut_ancien, $champs, $calcul_rub); |
|
| 261 | + |
|
| 262 | + // Invalider les caches |
|
| 263 | + include_spip('inc/invalideur'); |
|
| 264 | + suivre_invalideur("id='article/$id_article'"); |
|
| 265 | + |
|
| 266 | + if ($date) { |
|
| 267 | + $t = strtotime($date); |
|
| 268 | + $p = @$GLOBALS['meta']['date_prochain_postdate']; |
|
| 269 | + if ($t > time() AND (!$p OR ($t < $p))) { |
|
| 270 | + ecrire_meta('date_prochain_postdate', $t); |
|
| 271 | + } |
|
| 272 | + } |
|
| 273 | + |
|
| 274 | + // Pipeline |
|
| 275 | + pipeline('post_edition', |
|
| 276 | + array( |
|
| 277 | + 'args' => array( |
|
| 278 | + 'table' => 'spip_articles', |
|
| 279 | + 'id_objet' => $id_article, |
|
| 280 | + 'action'=>'instituer', |
|
| 281 | + 'statut_ancien' => $statut_ancien, |
|
| 282 | + 'date_ancienne' => $date_ancienne, |
|
| 283 | + ), |
|
| 284 | + 'data' => $champs |
|
| 285 | + ) |
|
| 286 | + ); |
|
| 287 | + |
|
| 288 | + // Notifications |
|
| 289 | + if ($notifications = charger_fonction('notifications', 'inc')) { |
|
| 290 | + $notifications('instituerarticle', $id_article, |
|
| 291 | + array('statut' => $statut, 'statut_ancien' => $statut_ancien, 'date'=>$date, 'date_ancienne' => $date_ancienne) |
|
| 292 | + ); |
|
| 293 | + } |
|
| 294 | + |
|
| 295 | + return ''; // pas d'erreur |
|
| 296 | 296 | } |
| 297 | 297 | |
| 298 | 298 | // fabrique la requete de modification de l'article, avec champs herites |
@@ -300,30 +300,30 @@ discard block |
||
| 300 | 300 | // http://doc.spip.org/@editer_article_heritage |
| 301 | 301 | function editer_article_heritage($id_article, $id_rubrique, $statut, $champs, $cond=true) { |
| 302 | 302 | |
| 303 | - // Si on deplace l'article |
|
| 304 | - // changer aussi son secteur et sa langue (si heritee) |
|
| 305 | - if (isset($champs['id_rubrique'])) { |
|
| 303 | + // Si on deplace l'article |
|
| 304 | + // changer aussi son secteur et sa langue (si heritee) |
|
| 305 | + if (isset($champs['id_rubrique'])) { |
|
| 306 | 306 | |
| 307 | - $row_rub = sql_fetsel("id_secteur, lang", "spip_rubriques", "id_rubrique=".sql_quote($champs['id_rubrique'])); |
|
| 307 | + $row_rub = sql_fetsel("id_secteur, lang", "spip_rubriques", "id_rubrique=".sql_quote($champs['id_rubrique'])); |
|
| 308 | 308 | |
| 309 | - $langue = $row_rub['lang']; |
|
| 310 | - $champs['id_secteur'] = $row_rub['id_secteur']; |
|
| 311 | - if (sql_fetsel('1', 'spip_articles', "id_article=$id_article AND langue_choisie<>'oui' AND lang<>" . sql_quote($langue))) { |
|
| 312 | - $champs['lang'] = $langue; |
|
| 313 | - } |
|
| 314 | - } |
|
| 309 | + $langue = $row_rub['lang']; |
|
| 310 | + $champs['id_secteur'] = $row_rub['id_secteur']; |
|
| 311 | + if (sql_fetsel('1', 'spip_articles', "id_article=$id_article AND langue_choisie<>'oui' AND lang<>" . sql_quote($langue))) { |
|
| 312 | + $champs['lang'] = $langue; |
|
| 313 | + } |
|
| 314 | + } |
|
| 315 | 315 | |
| 316 | - if (!$champs) return; |
|
| 316 | + if (!$champs) return; |
|
| 317 | 317 | |
| 318 | - sql_updateq('spip_articles', $champs, "id_article=$id_article"); |
|
| 318 | + sql_updateq('spip_articles', $champs, "id_article=$id_article"); |
|
| 319 | 319 | |
| 320 | - // Changer le statut des rubriques concernees |
|
| 320 | + // Changer le statut des rubriques concernees |
|
| 321 | 321 | |
| 322 | - if ($cond) { |
|
| 323 | - include_spip('inc/rubriques'); |
|
| 324 | - $postdate = ($GLOBALS['meta']["post_dates"] == "non" AND isset($champs['date']) AND (strtotime($champs['date']) < time()))?$champs['date']:false; |
|
| 325 | - calculer_rubriques_if($id_rubrique, $champs, $statut, $postdate); |
|
| 326 | - } |
|
| 322 | + if ($cond) { |
|
| 323 | + include_spip('inc/rubriques'); |
|
| 324 | + $postdate = ($GLOBALS['meta']["post_dates"] == "non" AND isset($champs['date']) AND (strtotime($champs['date']) < time()))?$champs['date']:false; |
|
| 325 | + calculer_rubriques_if($id_rubrique, $champs, $statut, $postdate); |
|
| 326 | + } |
|
| 327 | 327 | } |
| 328 | 328 | |
| 329 | 329 | // |
@@ -332,29 +332,29 @@ discard block |
||
| 332 | 332 | |
| 333 | 333 | // http://doc.spip.org/@trop_longs_articles |
| 334 | 334 | function trop_longs_articles() { |
| 335 | - if (is_array($plus = _request('texte_plus'))) { |
|
| 336 | - foreach ($plus as $n=>$t) { |
|
| 337 | - $plus[$n] = preg_replace(",<!--SPIP-->[\n\r]*,","", $t); |
|
| 338 | - } |
|
| 339 | - set_request('texte', join('',$plus) . _request('texte')); |
|
| 340 | - } |
|
| 335 | + if (is_array($plus = _request('texte_plus'))) { |
|
| 336 | + foreach ($plus as $n=>$t) { |
|
| 337 | + $plus[$n] = preg_replace(",<!--SPIP-->[\n\r]*,","", $t); |
|
| 338 | + } |
|
| 339 | + set_request('texte', join('',$plus) . _request('texte')); |
|
| 340 | + } |
|
| 341 | 341 | } |
| 342 | 342 | |
| 343 | 343 | |
| 344 | 344 | // obsoletes |
| 345 | 345 | function revisions_articles ($id_article, $c=false) { |
| 346 | - return article_modifier($id_article,$c); |
|
| 346 | + return article_modifier($id_article,$c); |
|
| 347 | 347 | } |
| 348 | 348 | function revision_article ($id_article, $c=false) { |
| 349 | - return article_modifier($id_article,$c); |
|
| 349 | + return article_modifier($id_article,$c); |
|
| 350 | 350 | } |
| 351 | 351 | function articles_set($id_article, $set=null) { |
| 352 | - return article_modifier($id_article,$set); |
|
| 352 | + return article_modifier($id_article,$set); |
|
| 353 | 353 | } |
| 354 | 354 | function insert_article($id_rubrique) { |
| 355 | - return article_inserer($id_rubrique); |
|
| 355 | + return article_inserer($id_rubrique); |
|
| 356 | 356 | } |
| 357 | 357 | function instituer_article($id_article, $c, $calcul_rub=true) { |
| 358 | - return article_instituer($id_article,$c,$calcul_rub); |
|
| 358 | + return article_instituer($id_article,$c,$calcul_rub); |
|
| 359 | 359 | } |
| 360 | 360 | ?> |
@@ -13,10 +13,10 @@ discard block |
||
| 13 | 13 | if (!defined('_ECRIRE_INC_VERSION')) return; |
| 14 | 14 | |
| 15 | 15 | // http://doc.spip.org/@action_editer_article_dist |
| 16 | -function action_editer_article_dist($arg=null) { |
|
| 16 | +function action_editer_article_dist($arg = null) { |
|
| 17 | 17 | include_spip('inc/autoriser'); |
| 18 | - $err=""; |
|
| 19 | - if (is_null($arg)){ |
|
| 18 | + $err = ""; |
|
| 19 | + if (is_null($arg)) { |
|
| 20 | 20 | $securiser_action = charger_fonction('securiser_action', 'inc'); |
| 21 | 21 | $arg = $securiser_action(); |
| 22 | 22 | } |
@@ -27,7 +27,7 @@ discard block |
||
| 27 | 27 | $id_parent = _request('id_parent'); |
| 28 | 28 | if (!$id_parent) |
| 29 | 29 | $err = _L("creation interdite d'un article sans rubrique"); |
| 30 | - elseif(!autoriser('creerarticledans','rubrique',$id_parent)) |
|
| 30 | + elseif (!autoriser('creerarticledans', 'rubrique', $id_parent)) |
|
| 31 | 31 | $err = _T("info_creerdansrubrique_non_autorise"); |
| 32 | 32 | else |
| 33 | 33 | $id_article = article_inserer($id_parent); |
@@ -37,9 +37,9 @@ discard block |
||
| 37 | 37 | if ($id_article > 0) $err = article_modifier($id_article); |
| 38 | 38 | |
| 39 | 39 | if ($err) |
| 40 | - spip_log("echec editeur article: $err",_LOG_ERREUR); |
|
| 40 | + spip_log("echec editeur article: $err", _LOG_ERREUR); |
|
| 41 | 41 | |
| 42 | - return array($id_article,$err); |
|
| 42 | + return array($id_article, $err); |
|
| 43 | 43 | } |
| 44 | 44 | |
| 45 | 45 | /** |
@@ -51,7 +51,7 @@ discard block |
||
| 51 | 51 | * @param null $set |
| 52 | 52 | * @return string |
| 53 | 53 | */ |
| 54 | -function article_modifier($id_article, $set=null) { |
|
| 54 | +function article_modifier($id_article, $set = null) { |
|
| 55 | 55 | |
| 56 | 56 | // unifier $texte en cas de texte trop long |
| 57 | 57 | trop_longs_articles(); |
@@ -60,9 +60,9 @@ discard block |
||
| 60 | 60 | include_spip('inc/filtres'); |
| 61 | 61 | $c = collecter_requests( |
| 62 | 62 | // white list |
| 63 | - objet_info('article','champs_editables'), |
|
| 63 | + objet_info('article', 'champs_editables'), |
|
| 64 | 64 | // black list |
| 65 | - array('date','statut','id_parent'), |
|
| 65 | + array('date', 'statut', 'id_parent'), |
|
| 66 | 66 | // donnees eventuellement fournies |
| 67 | 67 | $set |
| 68 | 68 | ); |
@@ -87,7 +87,7 @@ discard block |
||
| 87 | 87 | return $err; |
| 88 | 88 | |
| 89 | 89 | // Modification de statut, changement de rubrique ? |
| 90 | - $c = collecter_requests(array('date', 'statut', 'id_parent'),array(),$set); |
|
| 90 | + $c = collecter_requests(array('date', 'statut', 'id_parent'), array(), $set); |
|
| 91 | 91 | $err = article_instituer($id_article, $c); |
| 92 | 92 | |
| 93 | 93 | return $err; |
@@ -106,7 +106,7 @@ discard block |
||
| 106 | 106 | // Si id_rubrique vaut 0 ou n'est pas definie, creer l'article |
| 107 | 107 | // dans la premiere rubrique racine |
| 108 | 108 | if (!$id_rubrique = intval($id_rubrique)) { |
| 109 | - $row = sql_fetsel("id_rubrique, id_secteur, lang", "spip_rubriques", "id_parent=0",'', '0+titre,titre', "1"); |
|
| 109 | + $row = sql_fetsel("id_rubrique, id_secteur, lang", "spip_rubriques", "id_parent=0", '', '0+titre,titre', "1"); |
|
| 110 | 110 | $id_rubrique = $row['id_rubrique']; |
| 111 | 111 | } else $row = sql_fetsel("lang, id_secteur", "spip_rubriques", "id_rubrique=$id_rubrique"); |
| 112 | 112 | |
@@ -122,7 +122,7 @@ discard block |
||
| 122 | 122 | // dans les rubriques, on essaie avec la langue de l'auteur, |
| 123 | 123 | // ou a defaut celle de la rubrique |
| 124 | 124 | // Sinon c'est la langue de la rubrique qui est choisie + heritee |
| 125 | - if (in_array('spip_articles',explode(',',$GLOBALS['meta']['multi_objets']))) { |
|
| 125 | + if (in_array('spip_articles', explode(',', $GLOBALS['meta']['multi_objets']))) { |
|
| 126 | 126 | lang_select($GLOBALS['visiteur_session']['lang']); |
| 127 | 127 | if (in_array($GLOBALS['spip_lang'], |
| 128 | 128 | explode(',', $GLOBALS['meta']['langues_multilingue']))) { |
@@ -167,11 +167,11 @@ discard block |
||
| 167 | 167 | ); |
| 168 | 168 | |
| 169 | 169 | // controler si le serveur n'a pas renvoye une erreur |
| 170 | - if ($id_article > 0){ |
|
| 171 | - $id_auteur = ((is_null(_request('id_auteur')) AND isset($GLOBALS['visiteur_session']['id_auteur']))? |
|
| 170 | + if ($id_article > 0) { |
|
| 171 | + $id_auteur = ((is_null(_request('id_auteur')) AND isset($GLOBALS['visiteur_session']['id_auteur'])) ? |
|
| 172 | 172 | $GLOBALS['visiteur_session']['id_auteur'] |
| 173 | 173 | :_request('id_auteur')); |
| 174 | - if ($id_auteur){ |
|
| 174 | + if ($id_auteur) { |
|
| 175 | 175 | include_spip('action/editer_auteur'); |
| 176 | 176 | auteur_associer($id_auteur, array('article'=>$id_article)); |
| 177 | 177 | } |
@@ -186,7 +186,7 @@ discard block |
||
| 186 | 186 | // statut et rubrique sont lies, car un admin restreint peut deplacer |
| 187 | 187 | // un article publie vers une rubrique qu'il n'administre pas |
| 188 | 188 | // http://doc.spip.org/@instituer_article |
| 189 | -function article_instituer($id_article, $c, $calcul_rub=true) { |
|
| 189 | +function article_instituer($id_article, $c, $calcul_rub = true) { |
|
| 190 | 190 | |
| 191 | 191 | include_spip('inc/autoriser'); |
| 192 | 192 | include_spip('inc/rubriques'); |
@@ -198,8 +198,8 @@ discard block |
||
| 198 | 198 | $date_ancienne = $date = $row['date']; |
| 199 | 199 | $champs = array(); |
| 200 | 200 | |
| 201 | - $d = isset($c['date'])?$c['date']:null; |
|
| 202 | - $s = isset($c['statut'])?$c['statut']:$statut; |
|
| 201 | + $d = isset($c['date']) ? $c['date'] : null; |
|
| 202 | + $s = isset($c['statut']) ? $c['statut'] : $statut; |
|
| 203 | 203 | |
| 204 | 204 | // cf autorisations dans inc/instituer_article |
| 205 | 205 | if ($s != $statut OR ($d AND $d != $date)) { |
@@ -208,7 +208,7 @@ discard block |
||
| 208 | 208 | else if (autoriser('modifier', 'article', $id_article) AND $s != 'publie') |
| 209 | 209 | $statut = $champs['statut'] = $s; |
| 210 | 210 | else |
| 211 | - spip_log("editer_article $id_article refus " . join(' ', $c)); |
|
| 211 | + spip_log("editer_article $id_article refus ".join(' ', $c)); |
|
| 212 | 212 | |
| 213 | 213 | // En cas de publication, fixer la date a "maintenant" |
| 214 | 214 | // sauf si $c commande autre chose |
@@ -217,7 +217,7 @@ discard block |
||
| 217 | 217 | if ($champs['statut'] == 'publie' |
| 218 | 218 | OR ($champs['statut'] == 'prop' AND ($d OR !in_array($statut_ancien, array('publie', 'prop')))) |
| 219 | 219 | ) { |
| 220 | - if ($d OR strtotime($d=$date)>time()) |
|
| 220 | + if ($d OR strtotime($d = $date) > time()) |
|
| 221 | 221 | $champs['date'] = $date = $d; |
| 222 | 222 | else |
| 223 | 223 | $champs['date'] = $date = date('Y-m-d H:i:s'); |
@@ -298,7 +298,7 @@ discard block |
||
| 298 | 298 | // fabrique la requete de modification de l'article, avec champs herites |
| 299 | 299 | |
| 300 | 300 | // http://doc.spip.org/@editer_article_heritage |
| 301 | -function editer_article_heritage($id_article, $id_rubrique, $statut, $champs, $cond=true) { |
|
| 301 | +function editer_article_heritage($id_article, $id_rubrique, $statut, $champs, $cond = true) { |
|
| 302 | 302 | |
| 303 | 303 | // Si on deplace l'article |
| 304 | 304 | // changer aussi son secteur et sa langue (si heritee) |
@@ -308,7 +308,7 @@ discard block |
||
| 308 | 308 | |
| 309 | 309 | $langue = $row_rub['lang']; |
| 310 | 310 | $champs['id_secteur'] = $row_rub['id_secteur']; |
| 311 | - if (sql_fetsel('1', 'spip_articles', "id_article=$id_article AND langue_choisie<>'oui' AND lang<>" . sql_quote($langue))) { |
|
| 311 | + if (sql_fetsel('1', 'spip_articles', "id_article=$id_article AND langue_choisie<>'oui' AND lang<>".sql_quote($langue))) { |
|
| 312 | 312 | $champs['lang'] = $langue; |
| 313 | 313 | } |
| 314 | 314 | } |
@@ -321,7 +321,7 @@ discard block |
||
| 321 | 321 | |
| 322 | 322 | if ($cond) { |
| 323 | 323 | include_spip('inc/rubriques'); |
| 324 | - $postdate = ($GLOBALS['meta']["post_dates"] == "non" AND isset($champs['date']) AND (strtotime($champs['date']) < time()))?$champs['date']:false; |
|
| 324 | + $postdate = ($GLOBALS['meta']["post_dates"] == "non" AND isset($champs['date']) AND (strtotime($champs['date']) < time())) ? $champs['date'] : false; |
|
| 325 | 325 | calculer_rubriques_if($id_rubrique, $champs, $statut, $postdate); |
| 326 | 326 | } |
| 327 | 327 | } |
@@ -334,27 +334,27 @@ discard block |
||
| 334 | 334 | function trop_longs_articles() { |
| 335 | 335 | if (is_array($plus = _request('texte_plus'))) { |
| 336 | 336 | foreach ($plus as $n=>$t) { |
| 337 | - $plus[$n] = preg_replace(",<!--SPIP-->[\n\r]*,","", $t); |
|
| 337 | + $plus[$n] = preg_replace(",<!--SPIP-->[\n\r]*,", "", $t); |
|
| 338 | 338 | } |
| 339 | - set_request('texte', join('',$plus) . _request('texte')); |
|
| 339 | + set_request('texte', join('', $plus)._request('texte')); |
|
| 340 | 340 | } |
| 341 | 341 | } |
| 342 | 342 | |
| 343 | 343 | |
| 344 | 344 | // obsoletes |
| 345 | -function revisions_articles ($id_article, $c=false) { |
|
| 346 | - return article_modifier($id_article,$c); |
|
| 345 | +function revisions_articles($id_article, $c = false) { |
|
| 346 | + return article_modifier($id_article, $c); |
|
| 347 | 347 | } |
| 348 | -function revision_article ($id_article, $c=false) { |
|
| 349 | - return article_modifier($id_article,$c); |
|
| 348 | +function revision_article($id_article, $c = false) { |
|
| 349 | + return article_modifier($id_article, $c); |
|
| 350 | 350 | } |
| 351 | -function articles_set($id_article, $set=null) { |
|
| 352 | - return article_modifier($id_article,$set); |
|
| 351 | +function articles_set($id_article, $set = null) { |
|
| 352 | + return article_modifier($id_article, $set); |
|
| 353 | 353 | } |
| 354 | 354 | function insert_article($id_rubrique) { |
| 355 | 355 | return article_inserer($id_rubrique); |
| 356 | 356 | } |
| 357 | -function instituer_article($id_article, $c, $calcul_rub=true) { |
|
| 358 | - return article_instituer($id_article,$c,$calcul_rub); |
|
| 357 | +function instituer_article($id_article, $c, $calcul_rub = true) { |
|
| 358 | + return article_instituer($id_article, $c, $calcul_rub); |
|
| 359 | 359 | } |
| 360 | 360 | ?> |
@@ -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/@action_editer_article_dist |
| 16 | 18 | function action_editer_article_dist($arg=null) { |
@@ -25,19 +27,23 @@ discard block |
||
| 25 | 27 | // mais on verifie qu'on a toutes les donnees qu'il faut. |
| 26 | 28 | if (!$id_article = intval($arg)) { |
| 27 | 29 | $id_parent = _request('id_parent'); |
| 28 | - if (!$id_parent) |
|
| 29 | - $err = _L("creation interdite d'un article sans rubrique"); |
|
| 30 | - elseif(!autoriser('creerarticledans','rubrique',$id_parent)) |
|
| 31 | - $err = _T("info_creerdansrubrique_non_autorise"); |
|
| 32 | - else |
|
| 33 | - $id_article = article_inserer($id_parent); |
|
| 30 | + if (!$id_parent) { |
|
| 31 | + $err = _L("creation interdite d'un article sans rubrique"); |
|
| 32 | + } elseif(!autoriser('creerarticledans','rubrique',$id_parent)) { |
|
| 33 | + $err = _T("info_creerdansrubrique_non_autorise"); |
|
| 34 | + } else { |
|
| 35 | + $id_article = article_inserer($id_parent); |
|
| 36 | + } |
|
| 34 | 37 | } |
| 35 | 38 | |
| 36 | 39 | // Enregistre l'envoi dans la BD |
| 37 | - if ($id_article > 0) $err = article_modifier($id_article); |
|
| 40 | + if ($id_article > 0) { |
|
| 41 | + $err = article_modifier($id_article); |
|
| 42 | + } |
|
| 38 | 43 | |
| 39 | - if ($err) |
|
| 40 | - spip_log("echec editeur article: $err",_LOG_ERREUR); |
|
| 44 | + if ($err) { |
|
| 45 | + spip_log("echec editeur article: $err",_LOG_ERREUR); |
|
| 46 | + } |
|
| 41 | 47 | |
| 42 | 48 | return array($id_article,$err); |
| 43 | 49 | } |
@@ -83,8 +89,9 @@ discard block |
||
| 83 | 89 | 'indexation' => $indexation, |
| 84 | 90 | 'date_modif' => 'date_modif' // champ a mettre a date('Y-m-d H:i:s') s'il y a modif |
| 85 | 91 | ), |
| 86 | - $c)) |
|
| 87 | - return $err; |
|
| 92 | + $c)) { |
|
| 93 | + return $err; |
|
| 94 | + } |
|
| 88 | 95 | |
| 89 | 96 | // Modification de statut, changement de rubrique ? |
| 90 | 97 | $c = collecter_requests(array('date', 'statut', 'id_parent'),array(),$set); |
@@ -108,7 +115,9 @@ discard block |
||
| 108 | 115 | if (!$id_rubrique = intval($id_rubrique)) { |
| 109 | 116 | $row = sql_fetsel("id_rubrique, id_secteur, lang", "spip_rubriques", "id_parent=0",'', '0+titre,titre', "1"); |
| 110 | 117 | $id_rubrique = $row['id_rubrique']; |
| 111 | - } else $row = sql_fetsel("lang, id_secteur", "spip_rubriques", "id_rubrique=$id_rubrique"); |
|
| 118 | + } else { |
|
| 119 | + $row = sql_fetsel("lang, id_secteur", "spip_rubriques", "id_rubrique=$id_rubrique"); |
|
| 120 | + } |
|
| 112 | 121 | |
| 113 | 122 | // eviter $id_secteur = NULL (erreur sqlite) si la requete precedente echoue |
| 114 | 123 | // cas de id_rubrique = -1 par exemple avec plugin "pages" |
@@ -203,12 +212,13 @@ discard block |
||
| 203 | 212 | |
| 204 | 213 | // cf autorisations dans inc/instituer_article |
| 205 | 214 | if ($s != $statut OR ($d AND $d != $date)) { |
| 206 | - if (autoriser('publierdans', 'rubrique', $id_rubrique)) |
|
| 207 | - $statut = $champs['statut'] = $s; |
|
| 208 | - else if (autoriser('modifier', 'article', $id_article) AND $s != 'publie') |
|
| 209 | - $statut = $champs['statut'] = $s; |
|
| 210 | - else |
|
| 211 | - spip_log("editer_article $id_article refus " . join(' ', $c)); |
|
| 215 | + if (autoriser('publierdans', 'rubrique', $id_rubrique)) { |
|
| 216 | + $statut = $champs['statut'] = $s; |
|
| 217 | + } else if (autoriser('modifier', 'article', $id_article) AND $s != 'publie') { |
|
| 218 | + $statut = $champs['statut'] = $s; |
|
| 219 | + } else { |
|
| 220 | + spip_log("editer_article $id_article refus " . join(' ', $c)); |
|
| 221 | + } |
|
| 212 | 222 | |
| 213 | 223 | // En cas de publication, fixer la date a "maintenant" |
| 214 | 224 | // sauf si $c commande autre chose |
@@ -217,10 +227,11 @@ discard block |
||
| 217 | 227 | if ($champs['statut'] == 'publie' |
| 218 | 228 | OR ($champs['statut'] == 'prop' AND ($d OR !in_array($statut_ancien, array('publie', 'prop')))) |
| 219 | 229 | ) { |
| 220 | - if ($d OR strtotime($d=$date)>time()) |
|
| 221 | - $champs['date'] = $date = $d; |
|
| 222 | - else |
|
| 223 | - $champs['date'] = $date = date('Y-m-d H:i:s'); |
|
| 230 | + if ($d OR strtotime($d=$date)>time()) { |
|
| 231 | + $champs['date'] = $date = $d; |
|
| 232 | + } else { |
|
| 233 | + $champs['date'] = $date = date('Y-m-d H:i:s'); |
|
| 234 | + } |
|
| 224 | 235 | } |
| 225 | 236 | } |
| 226 | 237 | |
@@ -235,8 +246,9 @@ discard block |
||
| 235 | 246 | // et que le demandeur n'est pas admin de la rubrique de destination |
| 236 | 247 | // repasser l'article en statut 'propose'. |
| 237 | 248 | if ($statut == 'publie' |
| 238 | - AND !autoriser('publierdans', 'rubrique', $id_parent)) |
|
| 239 | - $champs['statut'] = 'prop'; |
|
| 249 | + AND !autoriser('publierdans', 'rubrique', $id_parent)) { |
|
| 250 | + $champs['statut'] = 'prop'; |
|
| 251 | + } |
|
| 240 | 252 | } |
| 241 | 253 | |
| 242 | 254 | // Envoyer aux plugins |
@@ -253,7 +265,9 @@ discard block |
||
| 253 | 265 | ) |
| 254 | 266 | ); |
| 255 | 267 | |
| 256 | - if (!count($champs)) return ''; |
|
| 268 | + if (!count($champs)) { |
|
| 269 | + return ''; |
|
| 270 | + } |
|
| 257 | 271 | |
| 258 | 272 | // Envoyer les modifs. |
| 259 | 273 | |
@@ -313,7 +327,9 @@ discard block |
||
| 313 | 327 | } |
| 314 | 328 | } |
| 315 | 329 | |
| 316 | - if (!$champs) return; |
|
| 330 | + if (!$champs) { |
|
| 331 | + return; |
|
| 332 | + } |
|
| 317 | 333 | |
| 318 | 334 | sql_updateq('spip_articles', $champs, "id_article=$id_article"); |
| 319 | 335 | |
@@ -19,21 +19,21 @@ |
||
| 19 | 19 | */ |
| 20 | 20 | function action_instituer_objet_dist($arg=null) { |
| 21 | 21 | |
| 22 | - if (is_null($arg)){ |
|
| 23 | - $securiser_action = charger_fonction('securiser_action', 'inc'); |
|
| 24 | - $arg = $securiser_action(); |
|
| 25 | - } |
|
| 22 | + if (is_null($arg)){ |
|
| 23 | + $securiser_action = charger_fonction('securiser_action', 'inc'); |
|
| 24 | + $arg = $securiser_action(); |
|
| 25 | + } |
|
| 26 | 26 | |
| 27 | - list($objet, $id_objet, $statut) = preg_split('/\W/', $arg); |
|
| 28 | - if (!$statut) $statut = _request('statut_nouv'); // cas POST |
|
| 29 | - if (!$statut) return; // impossible mais sait-on jamais |
|
| 27 | + list($objet, $id_objet, $statut) = preg_split('/\W/', $arg); |
|
| 28 | + if (!$statut) $statut = _request('statut_nouv'); // cas POST |
|
| 29 | + if (!$statut) return; // impossible mais sait-on jamais |
|
| 30 | 30 | |
| 31 | - if ($id_objet = intval($id_objet) |
|
| 32 | - AND autoriser('instituer',$objet,$id_objet,'',array('statut'=>$statut))){ |
|
| 31 | + if ($id_objet = intval($id_objet) |
|
| 32 | + AND autoriser('instituer',$objet,$id_objet,'',array('statut'=>$statut))){ |
|
| 33 | 33 | |
| 34 | - include_spip('action/editer_objet'); |
|
| 35 | - objet_modifier($objet,$id_objet,array('statut' => $statut)); |
|
| 36 | - } |
|
| 34 | + include_spip('action/editer_objet'); |
|
| 35 | + objet_modifier($objet,$id_objet,array('statut' => $statut)); |
|
| 36 | + } |
|
| 37 | 37 | |
| 38 | 38 | } |
| 39 | 39 | |
@@ -17,9 +17,9 @@ discard block |
||
| 17 | 17 | * @param null|string $arg |
| 18 | 18 | * @return |
| 19 | 19 | */ |
| 20 | -function action_instituer_objet_dist($arg=null) { |
|
| 20 | +function action_instituer_objet_dist($arg = null) { |
|
| 21 | 21 | |
| 22 | - if (is_null($arg)){ |
|
| 22 | + if (is_null($arg)) { |
|
| 23 | 23 | $securiser_action = charger_fonction('securiser_action', 'inc'); |
| 24 | 24 | $arg = $securiser_action(); |
| 25 | 25 | } |
@@ -29,10 +29,10 @@ discard block |
||
| 29 | 29 | if (!$statut) return; // impossible mais sait-on jamais |
| 30 | 30 | |
| 31 | 31 | if ($id_objet = intval($id_objet) |
| 32 | - AND autoriser('instituer',$objet,$id_objet,'',array('statut'=>$statut))){ |
|
| 32 | + AND autoriser('instituer', $objet, $id_objet, '', array('statut'=>$statut))) { |
|
| 33 | 33 | |
| 34 | 34 | include_spip('action/editer_objet'); |
| 35 | - objet_modifier($objet,$id_objet,array('statut' => $statut)); |
|
| 35 | + objet_modifier($objet, $id_objet, array('statut' => $statut)); |
|
| 36 | 36 | } |
| 37 | 37 | |
| 38 | 38 | } |
@@ -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 | * Instituer un objet avec les puces rapides |
@@ -25,8 +27,14 @@ discard block |
||
| 25 | 27 | } |
| 26 | 28 | |
| 27 | 29 | list($objet, $id_objet, $statut) = preg_split('/\W/', $arg); |
| 28 | - if (!$statut) $statut = _request('statut_nouv'); // cas POST |
|
| 29 | - if (!$statut) return; // impossible mais sait-on jamais |
|
| 30 | + if (!$statut) { |
|
| 31 | + $statut = _request('statut_nouv'); |
|
| 32 | + } |
|
| 33 | + // cas POST |
|
| 34 | + if (!$statut) { |
|
| 35 | + return; |
|
| 36 | + } |
|
| 37 | + // impossible mais sait-on jamais |
|
| 30 | 38 | |
| 31 | 39 | if ($id_objet = intval($id_objet) |
| 32 | 40 | AND autoriser('instituer',$objet,$id_objet,'',array('statut'=>$statut))){ |
@@ -25,63 +25,63 @@ discard block |
||
| 25 | 25 | */ |
| 26 | 26 | function action_logout_dist() |
| 27 | 27 | { |
| 28 | - $logout =_request('logout'); |
|
| 29 | - $url = securiser_redirect_action(_request('url')); |
|
| 30 | - // cas particulier, logout dans l'espace public |
|
| 31 | - if ($logout == 'public' AND !$url) |
|
| 32 | - $url = url_de_base(); |
|
| 28 | + $logout =_request('logout'); |
|
| 29 | + $url = securiser_redirect_action(_request('url')); |
|
| 30 | + // cas particulier, logout dans l'espace public |
|
| 31 | + if ($logout == 'public' AND !$url) |
|
| 32 | + $url = url_de_base(); |
|
| 33 | 33 | |
| 34 | - // seul le loge peut se deloger (mais id_auteur peut valoir 0 apres une restauration avortee) |
|
| 35 | - if (isset($GLOBALS['visiteur_session']['id_auteur']) |
|
| 36 | - AND is_numeric($GLOBALS['visiteur_session']['id_auteur']) |
|
| 37 | - // des sessions anonymes avec id_auteur=0 existent, mais elle n'ont pas de statut : double check |
|
| 38 | - AND isset($GLOBALS['visiteur_session']['statut'])) { |
|
| 34 | + // seul le loge peut se deloger (mais id_auteur peut valoir 0 apres une restauration avortee) |
|
| 35 | + if (isset($GLOBALS['visiteur_session']['id_auteur']) |
|
| 36 | + AND is_numeric($GLOBALS['visiteur_session']['id_auteur']) |
|
| 37 | + // des sessions anonymes avec id_auteur=0 existent, mais elle n'ont pas de statut : double check |
|
| 38 | + AND isset($GLOBALS['visiteur_session']['statut'])) { |
|
| 39 | 39 | |
| 40 | - // il faut un jeton pour fermer la session (eviter les CSRF) |
|
| 41 | - if (!$jeton = _request('jeton') |
|
| 42 | - OR !verifier_jeton_logout($jeton,$GLOBALS['visiteur_session'])){ |
|
| 43 | - $jeton = generer_jeton_logout($GLOBALS['visiteur_session']); |
|
| 44 | - $action = generer_url_action("logout","jeton=$jeton"); |
|
| 45 | - $action = parametre_url($action,'logout',_request('logout')); |
|
| 46 | - $action = parametre_url($action,'url',_request('url')); |
|
| 47 | - include_spip("inc/minipres"); |
|
| 48 | - include_spip("inc/filtres"); |
|
| 49 | - $texte = bouton_action(_T('spip:icone_deconnecter'),$action); |
|
| 50 | - $texte = "<div class='boutons'>$texte</div>"; |
|
| 51 | - $texte .= '<script type="text/javascript">document.write("<style>body{visibility:hidden;}</style>");window.document.forms[0].submit();</script>'; |
|
| 52 | - $res = minipres(_T('spip:icone_deconnecter'),$texte,'',true); |
|
| 53 | - echo $res; |
|
| 54 | - return; |
|
| 55 | - } |
|
| 40 | + // il faut un jeton pour fermer la session (eviter les CSRF) |
|
| 41 | + if (!$jeton = _request('jeton') |
|
| 42 | + OR !verifier_jeton_logout($jeton,$GLOBALS['visiteur_session'])){ |
|
| 43 | + $jeton = generer_jeton_logout($GLOBALS['visiteur_session']); |
|
| 44 | + $action = generer_url_action("logout","jeton=$jeton"); |
|
| 45 | + $action = parametre_url($action,'logout',_request('logout')); |
|
| 46 | + $action = parametre_url($action,'url',_request('url')); |
|
| 47 | + include_spip("inc/minipres"); |
|
| 48 | + include_spip("inc/filtres"); |
|
| 49 | + $texte = bouton_action(_T('spip:icone_deconnecter'),$action); |
|
| 50 | + $texte = "<div class='boutons'>$texte</div>"; |
|
| 51 | + $texte .= '<script type="text/javascript">document.write("<style>body{visibility:hidden;}</style>");window.document.forms[0].submit();</script>'; |
|
| 52 | + $res = minipres(_T('spip:icone_deconnecter'),$texte,'',true); |
|
| 53 | + echo $res; |
|
| 54 | + return; |
|
| 55 | + } |
|
| 56 | 56 | |
| 57 | - include_spip('inc/auth'); |
|
| 58 | - auth_trace($GLOBALS['visiteur_session'], '0000-00-00 00:00:00'); |
|
| 59 | - // le logout explicite vaut destruction de toutes les sessions |
|
| 60 | - if (isset($_COOKIE['spip_session'])) { |
|
| 61 | - $session = charger_fonction('session', 'inc'); |
|
| 62 | - $session($GLOBALS['visiteur_session']['id_auteur']); |
|
| 63 | - spip_setcookie('spip_session', $_COOKIE['spip_session'], time()-3600); |
|
| 64 | - } |
|
| 65 | - // si authentification http, et que la personne est loge, |
|
| 66 | - // pour se deconnecter, il faut proposer un nouveau formulaire de connexion http |
|
| 67 | - if (isset($_SERVER['PHP_AUTH_USER']) |
|
| 68 | - AND !$GLOBALS['ignore_auth_http'] |
|
| 69 | - AND $GLOBALS['auth_can_disconnect']) { |
|
| 70 | - ask_php_auth(_T('login_deconnexion_ok'), |
|
| 71 | - _T('login_verifiez_navigateur'), |
|
| 72 | - _T('login_retour_public'), |
|
| 73 | - "redirect=". _DIR_RESTREINT_ABS, |
|
| 74 | - _T('login_test_navigateur'), |
|
| 75 | - true); |
|
| 57 | + include_spip('inc/auth'); |
|
| 58 | + auth_trace($GLOBALS['visiteur_session'], '0000-00-00 00:00:00'); |
|
| 59 | + // le logout explicite vaut destruction de toutes les sessions |
|
| 60 | + if (isset($_COOKIE['spip_session'])) { |
|
| 61 | + $session = charger_fonction('session', 'inc'); |
|
| 62 | + $session($GLOBALS['visiteur_session']['id_auteur']); |
|
| 63 | + spip_setcookie('spip_session', $_COOKIE['spip_session'], time()-3600); |
|
| 64 | + } |
|
| 65 | + // si authentification http, et que la personne est loge, |
|
| 66 | + // pour se deconnecter, il faut proposer un nouveau formulaire de connexion http |
|
| 67 | + if (isset($_SERVER['PHP_AUTH_USER']) |
|
| 68 | + AND !$GLOBALS['ignore_auth_http'] |
|
| 69 | + AND $GLOBALS['auth_can_disconnect']) { |
|
| 70 | + ask_php_auth(_T('login_deconnexion_ok'), |
|
| 71 | + _T('login_verifiez_navigateur'), |
|
| 72 | + _T('login_retour_public'), |
|
| 73 | + "redirect=". _DIR_RESTREINT_ABS, |
|
| 74 | + _T('login_test_navigateur'), |
|
| 75 | + true); |
|
| 76 | 76 | |
| 77 | - } |
|
| 78 | - } |
|
| 77 | + } |
|
| 78 | + } |
|
| 79 | 79 | |
| 80 | - // Rediriger en contrant le cache navigateur (Safari3) |
|
| 81 | - include_spip('inc/headers'); |
|
| 82 | - redirige_par_entete($url |
|
| 83 | - ? parametre_url($url, 'var_hasard', uniqid(rand()), '&') |
|
| 84 | - : generer_url_public('login')); |
|
| 80 | + // Rediriger en contrant le cache navigateur (Safari3) |
|
| 81 | + include_spip('inc/headers'); |
|
| 82 | + redirige_par_entete($url |
|
| 83 | + ? parametre_url($url, 'var_hasard', uniqid(rand()), '&') |
|
| 84 | + : generer_url_public('login')); |
|
| 85 | 85 | } |
| 86 | 86 | |
| 87 | 87 | /** |
@@ -91,20 +91,20 @@ discard block |
||
| 91 | 91 | * @return string |
| 92 | 92 | */ |
| 93 | 93 | function generer_jeton_logout($session,$alea=null){ |
| 94 | - if (is_null($alea)){ |
|
| 95 | - if (!isset($GLOBALS['meta']['alea_ephemere'])){ |
|
| 96 | - include_spip('base/abstract_sql'); |
|
| 97 | - $GLOBALS['meta']['alea_ephemere'] = sql_getfetsel('valeur', 'spip_meta', "nom='alea_ephemere'"); |
|
| 98 | - } |
|
| 99 | - $alea = $GLOBALS['meta']['alea_ephemere']; |
|
| 100 | - } |
|
| 94 | + if (is_null($alea)){ |
|
| 95 | + if (!isset($GLOBALS['meta']['alea_ephemere'])){ |
|
| 96 | + include_spip('base/abstract_sql'); |
|
| 97 | + $GLOBALS['meta']['alea_ephemere'] = sql_getfetsel('valeur', 'spip_meta', "nom='alea_ephemere'"); |
|
| 98 | + } |
|
| 99 | + $alea = $GLOBALS['meta']['alea_ephemere']; |
|
| 100 | + } |
|
| 101 | 101 | |
| 102 | - $jeton = md5($session['date_session'] |
|
| 103 | - .$session['id_auteur'] |
|
| 104 | - .$session['statut'] |
|
| 105 | - .$alea |
|
| 106 | - ); |
|
| 107 | - return $jeton; |
|
| 102 | + $jeton = md5($session['date_session'] |
|
| 103 | + .$session['id_auteur'] |
|
| 104 | + .$session['statut'] |
|
| 105 | + .$alea |
|
| 106 | + ); |
|
| 107 | + return $jeton; |
|
| 108 | 108 | } |
| 109 | 109 | |
| 110 | 110 | /** |
@@ -116,15 +116,15 @@ discard block |
||
| 116 | 116 | * @return bool |
| 117 | 117 | */ |
| 118 | 118 | function verifier_jeton_logout($jeton,$session){ |
| 119 | - if (generer_jeton_logout($session)===$jeton) |
|
| 120 | - return true; |
|
| 121 | - if (!isset($GLOBALS['meta']['alea_ephemere_ancien'])){ |
|
| 122 | - include_spip('base/abstract_sql'); |
|
| 123 | - $GLOBALS['meta']['alea_ephemere_ancien'] = sql_getfetsel('valeur', 'spip_meta', "nom='alea_ephemere_ancien'"); |
|
| 124 | - } |
|
| 125 | - if (generer_jeton_logout($session,$GLOBALS['meta']['alea_ephemere_ancien'])===$jeton) |
|
| 126 | - return true; |
|
| 127 | - return false; |
|
| 119 | + if (generer_jeton_logout($session)===$jeton) |
|
| 120 | + return true; |
|
| 121 | + if (!isset($GLOBALS['meta']['alea_ephemere_ancien'])){ |
|
| 122 | + include_spip('base/abstract_sql'); |
|
| 123 | + $GLOBALS['meta']['alea_ephemere_ancien'] = sql_getfetsel('valeur', 'spip_meta', "nom='alea_ephemere_ancien'"); |
|
| 124 | + } |
|
| 125 | + if (generer_jeton_logout($session,$GLOBALS['meta']['alea_ephemere_ancien'])===$jeton) |
|
| 126 | + return true; |
|
| 127 | + return false; |
|
| 128 | 128 | } |
| 129 | 129 | |
| 130 | 130 | ?> |
| 131 | 131 | \ No newline at end of file |
@@ -25,7 +25,7 @@ discard block |
||
| 25 | 25 | */ |
| 26 | 26 | function action_logout_dist() |
| 27 | 27 | { |
| 28 | - $logout =_request('logout'); |
|
| 28 | + $logout = _request('logout'); |
|
| 29 | 29 | $url = securiser_redirect_action(_request('url')); |
| 30 | 30 | // cas particulier, logout dans l'espace public |
| 31 | 31 | if ($logout == 'public' AND !$url) |
@@ -39,17 +39,17 @@ discard block |
||
| 39 | 39 | |
| 40 | 40 | // il faut un jeton pour fermer la session (eviter les CSRF) |
| 41 | 41 | if (!$jeton = _request('jeton') |
| 42 | - OR !verifier_jeton_logout($jeton,$GLOBALS['visiteur_session'])){ |
|
| 42 | + OR !verifier_jeton_logout($jeton, $GLOBALS['visiteur_session'])) { |
|
| 43 | 43 | $jeton = generer_jeton_logout($GLOBALS['visiteur_session']); |
| 44 | - $action = generer_url_action("logout","jeton=$jeton"); |
|
| 45 | - $action = parametre_url($action,'logout',_request('logout')); |
|
| 46 | - $action = parametre_url($action,'url',_request('url')); |
|
| 44 | + $action = generer_url_action("logout", "jeton=$jeton"); |
|
| 45 | + $action = parametre_url($action, 'logout', _request('logout')); |
|
| 46 | + $action = parametre_url($action, 'url', _request('url')); |
|
| 47 | 47 | include_spip("inc/minipres"); |
| 48 | 48 | include_spip("inc/filtres"); |
| 49 | - $texte = bouton_action(_T('spip:icone_deconnecter'),$action); |
|
| 49 | + $texte = bouton_action(_T('spip:icone_deconnecter'), $action); |
|
| 50 | 50 | $texte = "<div class='boutons'>$texte</div>"; |
| 51 | 51 | $texte .= '<script type="text/javascript">document.write("<style>body{visibility:hidden;}</style>");window.document.forms[0].submit();</script>'; |
| 52 | - $res = minipres(_T('spip:icone_deconnecter'),$texte,'',true); |
|
| 52 | + $res = minipres(_T('spip:icone_deconnecter'), $texte, '', true); |
|
| 53 | 53 | echo $res; |
| 54 | 54 | return; |
| 55 | 55 | } |
@@ -60,7 +60,7 @@ discard block |
||
| 60 | 60 | if (isset($_COOKIE['spip_session'])) { |
| 61 | 61 | $session = charger_fonction('session', 'inc'); |
| 62 | 62 | $session($GLOBALS['visiteur_session']['id_auteur']); |
| 63 | - spip_setcookie('spip_session', $_COOKIE['spip_session'], time()-3600); |
|
| 63 | + spip_setcookie('spip_session', $_COOKIE['spip_session'], time() - 3600); |
|
| 64 | 64 | } |
| 65 | 65 | // si authentification http, et que la personne est loge, |
| 66 | 66 | // pour se deconnecter, il faut proposer un nouveau formulaire de connexion http |
@@ -70,7 +70,7 @@ discard block |
||
| 70 | 70 | ask_php_auth(_T('login_deconnexion_ok'), |
| 71 | 71 | _T('login_verifiez_navigateur'), |
| 72 | 72 | _T('login_retour_public'), |
| 73 | - "redirect=". _DIR_RESTREINT_ABS, |
|
| 73 | + "redirect="._DIR_RESTREINT_ABS, |
|
| 74 | 74 | _T('login_test_navigateur'), |
| 75 | 75 | true); |
| 76 | 76 | |
@@ -90,9 +90,9 @@ discard block |
||
| 90 | 90 | * @param null|string $alea |
| 91 | 91 | * @return string |
| 92 | 92 | */ |
| 93 | -function generer_jeton_logout($session,$alea=null){ |
|
| 94 | - if (is_null($alea)){ |
|
| 95 | - if (!isset($GLOBALS['meta']['alea_ephemere'])){ |
|
| 93 | +function generer_jeton_logout($session, $alea = null) { |
|
| 94 | + if (is_null($alea)) { |
|
| 95 | + if (!isset($GLOBALS['meta']['alea_ephemere'])) { |
|
| 96 | 96 | include_spip('base/abstract_sql'); |
| 97 | 97 | $GLOBALS['meta']['alea_ephemere'] = sql_getfetsel('valeur', 'spip_meta', "nom='alea_ephemere'"); |
| 98 | 98 | } |
@@ -115,14 +115,14 @@ discard block |
||
| 115 | 115 | * @param array $session |
| 116 | 116 | * @return bool |
| 117 | 117 | */ |
| 118 | -function verifier_jeton_logout($jeton,$session){ |
|
| 119 | - if (generer_jeton_logout($session)===$jeton) |
|
| 118 | +function verifier_jeton_logout($jeton, $session) { |
|
| 119 | + if (generer_jeton_logout($session) === $jeton) |
|
| 120 | 120 | return true; |
| 121 | - if (!isset($GLOBALS['meta']['alea_ephemere_ancien'])){ |
|
| 121 | + if (!isset($GLOBALS['meta']['alea_ephemere_ancien'])) { |
|
| 122 | 122 | include_spip('base/abstract_sql'); |
| 123 | 123 | $GLOBALS['meta']['alea_ephemere_ancien'] = sql_getfetsel('valeur', 'spip_meta', "nom='alea_ephemere_ancien'"); |
| 124 | 124 | } |
| 125 | - if (generer_jeton_logout($session,$GLOBALS['meta']['alea_ephemere_ancien'])===$jeton) |
|
| 125 | + if (generer_jeton_logout($session, $GLOBALS['meta']['alea_ephemere_ancien']) === $jeton) |
|
| 126 | 126 | return true; |
| 127 | 127 | return false; |
| 128 | 128 | } |
@@ -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/cookie'); |
| 16 | 18 | |
@@ -28,8 +30,9 @@ discard block |
||
| 28 | 30 | $logout =_request('logout'); |
| 29 | 31 | $url = securiser_redirect_action(_request('url')); |
| 30 | 32 | // cas particulier, logout dans l'espace public |
| 31 | - if ($logout == 'public' AND !$url) |
|
| 32 | - $url = url_de_base(); |
|
| 33 | + if ($logout == 'public' AND !$url) { |
|
| 34 | + $url = url_de_base(); |
|
| 35 | + } |
|
| 33 | 36 | |
| 34 | 37 | // seul le loge peut se deloger (mais id_auteur peut valoir 0 apres une restauration avortee) |
| 35 | 38 | if (isset($GLOBALS['visiteur_session']['id_auteur']) |
@@ -116,14 +119,16 @@ discard block |
||
| 116 | 119 | * @return bool |
| 117 | 120 | */ |
| 118 | 121 | function verifier_jeton_logout($jeton,$session){ |
| 119 | - if (generer_jeton_logout($session)===$jeton) |
|
| 120 | - return true; |
|
| 122 | + if (generer_jeton_logout($session)===$jeton) { |
|
| 123 | + return true; |
|
| 124 | + } |
|
| 121 | 125 | if (!isset($GLOBALS['meta']['alea_ephemere_ancien'])){ |
| 122 | 126 | include_spip('base/abstract_sql'); |
| 123 | 127 | $GLOBALS['meta']['alea_ephemere_ancien'] = sql_getfetsel('valeur', 'spip_meta', "nom='alea_ephemere_ancien'"); |
| 124 | 128 | } |
| 125 | - if (generer_jeton_logout($session,$GLOBALS['meta']['alea_ephemere_ancien'])===$jeton) |
|
| 126 | - return true; |
|
| 129 | + if (generer_jeton_logout($session,$GLOBALS['meta']['alea_ephemere_ancien'])===$jeton) { |
|
| 130 | + return true; |
|
| 131 | + } |
|
| 127 | 132 | return false; |
| 128 | 133 | } |
| 129 | 134 | |