@@ -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 | ?> |
@@ -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 | ?> |
@@ -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 | ?> |
@@ -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 | ?> |
@@ -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 | |
@@ -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 | ?> |
@@ -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 | |
@@ -20,52 +20,52 @@ |
||
| 20 | 20 | // http://doc.spip.org/@action_converser_dist |
| 21 | 21 | function action_converser_dist() |
| 22 | 22 | { |
| 23 | - $update_session = false; |
|
| 24 | - if ( _request('arg') AND spip_connect()) { |
|
| 25 | - $securiser_action = charger_fonction('securiser_action', 'inc'); |
|
| 26 | - $securiser_action(); |
|
| 27 | - $update_session = true; |
|
| 28 | - } |
|
| 23 | + $update_session = false; |
|
| 24 | + if ( _request('arg') AND spip_connect()) { |
|
| 25 | + $securiser_action = charger_fonction('securiser_action', 'inc'); |
|
| 26 | + $securiser_action(); |
|
| 27 | + $update_session = true; |
|
| 28 | + } |
|
| 29 | 29 | |
| 30 | - $lang = action_converser_changer_langue($update_session); |
|
| 31 | - $redirect = rawurldecode(_request('redirect')); |
|
| 30 | + $lang = action_converser_changer_langue($update_session); |
|
| 31 | + $redirect = rawurldecode(_request('redirect')); |
|
| 32 | 32 | |
| 33 | - if (!$redirect) $redirect = _DIR_RESTREINT_ABS; |
|
| 34 | - $redirect = parametre_url($redirect,'lang',$lang,'&'); |
|
| 35 | - redirige_par_entete($redirect, true); |
|
| 33 | + if (!$redirect) $redirect = _DIR_RESTREINT_ABS; |
|
| 34 | + $redirect = parametre_url($redirect,'lang',$lang,'&'); |
|
| 35 | + redirige_par_entete($redirect, true); |
|
| 36 | 36 | } |
| 37 | 37 | |
| 38 | 38 | function action_converser_changer_langue($update_session){ |
| 39 | - if ($lang = _request('var_lang')) |
|
| 40 | - action_converser_post($lang); |
|
| 41 | - elseif ($lang = _request('var_lang_ecrire')) { |
|
| 42 | - if ($update_session) { |
|
| 43 | - sql_updateq("spip_auteurs", array("lang" => $lang), "id_auteur = " . $GLOBALS['visiteur_session']['id_auteur']); |
|
| 44 | - $GLOBALS['visiteur_session']['lang'] = $lang; |
|
| 45 | - $session = charger_fonction('session', 'inc'); |
|
| 46 | - if ($spip_session = $session($GLOBALS['visiteur_session'])) { |
|
| 47 | - spip_setcookie( |
|
| 48 | - 'spip_session', |
|
| 49 | - $spip_session, |
|
| 50 | - time() + 3600 * 24 * 14 |
|
| 51 | - ); |
|
| 52 | - } |
|
| 53 | - } |
|
| 54 | - action_converser_post($lang, 'spip_lang_ecrire'); |
|
| 55 | - } |
|
| 56 | - return $lang; |
|
| 39 | + if ($lang = _request('var_lang')) |
|
| 40 | + action_converser_post($lang); |
|
| 41 | + elseif ($lang = _request('var_lang_ecrire')) { |
|
| 42 | + if ($update_session) { |
|
| 43 | + sql_updateq("spip_auteurs", array("lang" => $lang), "id_auteur = " . $GLOBALS['visiteur_session']['id_auteur']); |
|
| 44 | + $GLOBALS['visiteur_session']['lang'] = $lang; |
|
| 45 | + $session = charger_fonction('session', 'inc'); |
|
| 46 | + if ($spip_session = $session($GLOBALS['visiteur_session'])) { |
|
| 47 | + spip_setcookie( |
|
| 48 | + 'spip_session', |
|
| 49 | + $spip_session, |
|
| 50 | + time() + 3600 * 24 * 14 |
|
| 51 | + ); |
|
| 52 | + } |
|
| 53 | + } |
|
| 54 | + action_converser_post($lang, 'spip_lang_ecrire'); |
|
| 55 | + } |
|
| 56 | + return $lang; |
|
| 57 | 57 | } |
| 58 | 58 | |
| 59 | 59 | // http://doc.spip.org/@action_converser_post |
| 60 | 60 | function action_converser_post($lang, $ecrire=false) |
| 61 | 61 | { |
| 62 | - if ($lang) { |
|
| 63 | - include_spip('inc/lang'); |
|
| 64 | - if (changer_langue($lang)) { |
|
| 65 | - spip_setcookie('spip_lang', $_COOKIE['spip_lang'] = $lang, time() + 365 * 24 * 3600); |
|
| 66 | - if ($ecrire) |
|
| 67 | - spip_setcookie('spip_lang_ecrire', $_COOKIE['spip_lang_ecrire'] = $lang, time() + 365 * 24 * 3600); |
|
| 68 | - } |
|
| 69 | - } |
|
| 62 | + if ($lang) { |
|
| 63 | + include_spip('inc/lang'); |
|
| 64 | + if (changer_langue($lang)) { |
|
| 65 | + spip_setcookie('spip_lang', $_COOKIE['spip_lang'] = $lang, time() + 365 * 24 * 3600); |
|
| 66 | + if ($ecrire) |
|
| 67 | + spip_setcookie('spip_lang_ecrire', $_COOKIE['spip_lang_ecrire'] = $lang, time() + 365 * 24 * 3600); |
|
| 68 | + } |
|
| 69 | + } |
|
| 70 | 70 | } |
| 71 | 71 | ?> |
@@ -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 |