@@ -48,7 +48,7 @@ discard block |
||
| 48 | 48 | include_spip('inc/texte'); // pour aide, couper, lang |
| 49 | 49 | $info = ''; |
| 50 | 50 | if (!need_proxy($t['host'], $http_proxy, $http_noproxy)) { |
| 51 | - $info = '<strong>' . _T('page_pas_proxy') . '</strong><br />'; |
|
| 51 | + $info = '<strong>'._T('page_pas_proxy').'</strong><br />'; |
|
| 52 | 52 | } |
| 53 | 53 | |
| 54 | 54 | // il faut fausser le proxy actuel pour faire le test ! |
@@ -61,14 +61,14 @@ discard block |
||
| 61 | 61 | $GLOBALS['meta']['http_proxy'] = $cur_http_proxy; |
| 62 | 62 | $GLOBALS['meta']['http_noproxy'] = $cur_http_noproxy; |
| 63 | 63 | if ($page) { |
| 64 | - $erreurs['message_ok'] = _T('info_proxy_ok') . "<br />$info\n<tt>" . couper(entites_html($page), 300) . '</tt>'; |
|
| 64 | + $erreurs['message_ok'] = _T('info_proxy_ok')."<br />$info\n<tt>".couper(entites_html($page), 300).'</tt>'; |
|
| 65 | 65 | $erreurs['message_erreur'] = ''; |
| 66 | 66 | } else { |
| 67 | - $erreurs['message_erreur'] = $info . _T( |
|
| 67 | + $erreurs['message_erreur'] = $info._T( |
|
| 68 | 68 | 'info_impossible_lire_page', |
| 69 | 69 | ['test_proxy' => "<tt>$test_proxy</tt>"] |
| 70 | 70 | ) |
| 71 | - . ' <b><tt>' . no_password_proxy_url($http_proxy) . '</tt></b>.' |
|
| 71 | + . ' <b><tt>'.no_password_proxy_url($http_proxy).'</tt></b>.' |
|
| 72 | 72 | . aider('confhttpproxy'); |
| 73 | 73 | } |
| 74 | 74 | } |
@@ -112,23 +112,23 @@ discard block |
||
| 112 | 112 | return false; |
| 113 | 113 | } |
| 114 | 114 | // scheme |
| 115 | - $uri = (!empty($url['scheme'])) ? $url['scheme'] . '://' : ''; |
|
| 115 | + $uri = (!empty($url['scheme'])) ? $url['scheme'].'://' : ''; |
|
| 116 | 116 | // user & pass |
| 117 | 117 | if (!empty($url['user'])) { |
| 118 | - $uri .= $url['user'] . ':' . $url['pass'] . '@'; |
|
| 118 | + $uri .= $url['user'].':'.$url['pass'].'@'; |
|
| 119 | 119 | } |
| 120 | 120 | // host |
| 121 | 121 | $uri .= $url['host']; |
| 122 | 122 | // port |
| 123 | - $port = (!empty($url['port'])) ? ':' . $url['port'] : ''; |
|
| 123 | + $port = (!empty($url['port'])) ? ':'.$url['port'] : ''; |
|
| 124 | 124 | $uri .= $port; |
| 125 | 125 | // path |
| 126 | 126 | $uri .= $url['path']; |
| 127 | 127 | // fragment or query |
| 128 | 128 | if (isset($url['fragment'])) { |
| 129 | - $uri .= '#' . $url['fragment']; |
|
| 129 | + $uri .= '#'.$url['fragment']; |
|
| 130 | 130 | } elseif (isset($url['query'])) { |
| 131 | - $uri .= '?' . $url['query']; |
|
| 131 | + $uri .= '?'.$url['query']; |
|
| 132 | 132 | } |
| 133 | 133 | |
| 134 | 134 | return $uri; |
@@ -11,140 +11,140 @@ |
||
| 11 | 11 | \***************************************************************************/ |
| 12 | 12 | |
| 13 | 13 | if (!defined('_ECRIRE_INC_VERSION')) { |
| 14 | - return; |
|
| 14 | + return; |
|
| 15 | 15 | } |
| 16 | 16 | include_spip('inc/presentation'); |
| 17 | 17 | include_spip('inc/config'); |
| 18 | 18 | |
| 19 | 19 | function formulaires_configurer_relayeur_charger_dist() { |
| 20 | - $valeurs = [ |
|
| 21 | - 'http_proxy' => no_password_proxy_url(lire_config('http_proxy', '')), |
|
| 22 | - 'http_noproxy' => lire_config('http_noproxy', ''), |
|
| 23 | - 'test_proxy' => 'https://www.spip.net/', |
|
| 24 | - ]; |
|
| 20 | + $valeurs = [ |
|
| 21 | + 'http_proxy' => no_password_proxy_url(lire_config('http_proxy', '')), |
|
| 22 | + 'http_noproxy' => lire_config('http_noproxy', ''), |
|
| 23 | + 'test_proxy' => 'https://www.spip.net/', |
|
| 24 | + ]; |
|
| 25 | 25 | |
| 26 | - return $valeurs; |
|
| 26 | + return $valeurs; |
|
| 27 | 27 | } |
| 28 | 28 | |
| 29 | 29 | function formulaires_configurer_relayeur_verifier_dist() { |
| 30 | - $erreurs = []; |
|
| 31 | - $http_proxy = relayeur_saisie_ou_config(_request('http_proxy'), lire_config('http_proxy', '')); |
|
| 32 | - $http_noproxy = _request('http_noproxy'); |
|
| 33 | - |
|
| 34 | - if ($http_proxy and !tester_url_absolue($http_proxy)) { |
|
| 35 | - $erreurs['http_proxy'] = _T('info_url_proxy_pas_conforme'); |
|
| 36 | - } |
|
| 37 | - |
|
| 38 | - if (!isset($erreurs['http_proxy']) and _request('tester_proxy')) { |
|
| 39 | - if (!$http_proxy) { |
|
| 40 | - $erreurs['http_proxy'] = _T('info_obligatoire'); |
|
| 41 | - } else { |
|
| 42 | - include_spip('inc/distant'); |
|
| 43 | - $test_proxy = _request('test_proxy'); |
|
| 44 | - $t = parse_url($test_proxy); |
|
| 45 | - if (!@$t['host']) { |
|
| 46 | - $erreurs['test_proxy'] = _T('info_adresse_non_indiquee'); |
|
| 47 | - } else { |
|
| 48 | - include_spip('inc/texte'); // pour aide, couper, lang |
|
| 49 | - $info = ''; |
|
| 50 | - if (!need_proxy($t['host'], $http_proxy, $http_noproxy)) { |
|
| 51 | - $info = '<strong>' . _T('page_pas_proxy') . '</strong><br />'; |
|
| 52 | - } |
|
| 53 | - |
|
| 54 | - // il faut fausser le proxy actuel pour faire le test ! |
|
| 55 | - $cur_http_proxy = $GLOBALS['meta']['http_proxy']; |
|
| 56 | - $cur_http_noproxy = $GLOBALS['meta']['http_noproxy']; |
|
| 57 | - $GLOBALS['meta']['http_proxy'] = $http_proxy; |
|
| 58 | - $GLOBALS['meta']['http_noproxy'] = $http_noproxy; |
|
| 59 | - $page = recuperer_url($test_proxy, ['transcoder' => true]); |
|
| 60 | - $page = $page['page'] ?? ''; |
|
| 61 | - $GLOBALS['meta']['http_proxy'] = $cur_http_proxy; |
|
| 62 | - $GLOBALS['meta']['http_noproxy'] = $cur_http_noproxy; |
|
| 63 | - if ($page) { |
|
| 64 | - $erreurs['message_ok'] = _T('info_proxy_ok') . "<br />$info\n<tt>" . couper(entites_html($page), 300) . '</tt>'; |
|
| 65 | - $erreurs['message_erreur'] = ''; |
|
| 66 | - } else { |
|
| 67 | - $erreurs['message_erreur'] = $info . _T( |
|
| 68 | - 'info_impossible_lire_page', |
|
| 69 | - ['test_proxy' => "<tt>$test_proxy</tt>"] |
|
| 70 | - ) |
|
| 71 | - . ' <b><tt>' . no_password_proxy_url($http_proxy) . '</tt></b>.' |
|
| 72 | - . aider('confhttpproxy'); |
|
| 73 | - } |
|
| 74 | - } |
|
| 75 | - } |
|
| 76 | - } |
|
| 77 | - |
|
| 78 | - return $erreurs; |
|
| 30 | + $erreurs = []; |
|
| 31 | + $http_proxy = relayeur_saisie_ou_config(_request('http_proxy'), lire_config('http_proxy', '')); |
|
| 32 | + $http_noproxy = _request('http_noproxy'); |
|
| 33 | + |
|
| 34 | + if ($http_proxy and !tester_url_absolue($http_proxy)) { |
|
| 35 | + $erreurs['http_proxy'] = _T('info_url_proxy_pas_conforme'); |
|
| 36 | + } |
|
| 37 | + |
|
| 38 | + if (!isset($erreurs['http_proxy']) and _request('tester_proxy')) { |
|
| 39 | + if (!$http_proxy) { |
|
| 40 | + $erreurs['http_proxy'] = _T('info_obligatoire'); |
|
| 41 | + } else { |
|
| 42 | + include_spip('inc/distant'); |
|
| 43 | + $test_proxy = _request('test_proxy'); |
|
| 44 | + $t = parse_url($test_proxy); |
|
| 45 | + if (!@$t['host']) { |
|
| 46 | + $erreurs['test_proxy'] = _T('info_adresse_non_indiquee'); |
|
| 47 | + } else { |
|
| 48 | + include_spip('inc/texte'); // pour aide, couper, lang |
|
| 49 | + $info = ''; |
|
| 50 | + if (!need_proxy($t['host'], $http_proxy, $http_noproxy)) { |
|
| 51 | + $info = '<strong>' . _T('page_pas_proxy') . '</strong><br />'; |
|
| 52 | + } |
|
| 53 | + |
|
| 54 | + // il faut fausser le proxy actuel pour faire le test ! |
|
| 55 | + $cur_http_proxy = $GLOBALS['meta']['http_proxy']; |
|
| 56 | + $cur_http_noproxy = $GLOBALS['meta']['http_noproxy']; |
|
| 57 | + $GLOBALS['meta']['http_proxy'] = $http_proxy; |
|
| 58 | + $GLOBALS['meta']['http_noproxy'] = $http_noproxy; |
|
| 59 | + $page = recuperer_url($test_proxy, ['transcoder' => true]); |
|
| 60 | + $page = $page['page'] ?? ''; |
|
| 61 | + $GLOBALS['meta']['http_proxy'] = $cur_http_proxy; |
|
| 62 | + $GLOBALS['meta']['http_noproxy'] = $cur_http_noproxy; |
|
| 63 | + if ($page) { |
|
| 64 | + $erreurs['message_ok'] = _T('info_proxy_ok') . "<br />$info\n<tt>" . couper(entites_html($page), 300) . '</tt>'; |
|
| 65 | + $erreurs['message_erreur'] = ''; |
|
| 66 | + } else { |
|
| 67 | + $erreurs['message_erreur'] = $info . _T( |
|
| 68 | + 'info_impossible_lire_page', |
|
| 69 | + ['test_proxy' => "<tt>$test_proxy</tt>"] |
|
| 70 | + ) |
|
| 71 | + . ' <b><tt>' . no_password_proxy_url($http_proxy) . '</tt></b>.' |
|
| 72 | + . aider('confhttpproxy'); |
|
| 73 | + } |
|
| 74 | + } |
|
| 75 | + } |
|
| 76 | + } |
|
| 77 | + |
|
| 78 | + return $erreurs; |
|
| 79 | 79 | } |
| 80 | 80 | |
| 81 | 81 | function formulaires_configurer_relayeur_traiter_dist() { |
| 82 | - $res = ['editable' => true]; |
|
| 82 | + $res = ['editable' => true]; |
|
| 83 | 83 | |
| 84 | - $http_proxy = relayeur_saisie_ou_config(_request('http_proxy'), lire_config('http_proxy', '')); |
|
| 85 | - $http_noproxy = _request('http_noproxy'); |
|
| 86 | - if ($http_proxy !== null) { |
|
| 87 | - ecrire_meta('http_proxy', $http_proxy); |
|
| 88 | - } |
|
| 84 | + $http_proxy = relayeur_saisie_ou_config(_request('http_proxy'), lire_config('http_proxy', '')); |
|
| 85 | + $http_noproxy = _request('http_noproxy'); |
|
| 86 | + if ($http_proxy !== null) { |
|
| 87 | + ecrire_meta('http_proxy', $http_proxy); |
|
| 88 | + } |
|
| 89 | 89 | |
| 90 | - if ($http_noproxy !== null) { |
|
| 91 | - ecrire_meta('http_noproxy', $http_noproxy); |
|
| 92 | - } |
|
| 90 | + if ($http_noproxy !== null) { |
|
| 91 | + ecrire_meta('http_noproxy', $http_noproxy); |
|
| 92 | + } |
|
| 93 | 93 | |
| 94 | - $res['message_ok'] = _T('config_info_enregistree'); |
|
| 94 | + $res['message_ok'] = _T('config_info_enregistree'); |
|
| 95 | 95 | |
| 96 | - return $res; |
|
| 96 | + return $res; |
|
| 97 | 97 | } |
| 98 | 98 | |
| 99 | 99 | function relayeur_saisie_ou_config($http_proxy, $default) { |
| 100 | - // http_proxy : ne pas prendre en compte la modif si le password est '****' |
|
| 101 | - if (preg_match(',:\*\*\*\*@,', $http_proxy)) { |
|
| 102 | - $http_proxy = $default; |
|
| 103 | - } |
|
| 100 | + // http_proxy : ne pas prendre en compte la modif si le password est '****' |
|
| 101 | + if (preg_match(',:\*\*\*\*@,', $http_proxy)) { |
|
| 102 | + $http_proxy = $default; |
|
| 103 | + } |
|
| 104 | 104 | |
| 105 | - return $http_proxy; |
|
| 105 | + return $http_proxy; |
|
| 106 | 106 | } |
| 107 | 107 | |
| 108 | 108 | // Function glue_url : le pendant de parse_url |
| 109 | 109 | function glue_url($url) { |
| 110 | - if (!is_array($url)) { |
|
| 111 | - return false; |
|
| 112 | - } |
|
| 113 | - // scheme |
|
| 114 | - $uri = (!empty($url['scheme'])) ? $url['scheme'] . '://' : ''; |
|
| 115 | - // user & pass |
|
| 116 | - if (!empty($url['user'])) { |
|
| 117 | - $uri .= $url['user'] . ':' . $url['pass'] . '@'; |
|
| 118 | - } |
|
| 119 | - // host |
|
| 120 | - $uri .= $url['host']; |
|
| 121 | - // port |
|
| 122 | - $port = (!empty($url['port'])) ? ':' . $url['port'] : ''; |
|
| 123 | - $uri .= $port; |
|
| 124 | - // path |
|
| 125 | - $uri .= $url['path']; |
|
| 110 | + if (!is_array($url)) { |
|
| 111 | + return false; |
|
| 112 | + } |
|
| 113 | + // scheme |
|
| 114 | + $uri = (!empty($url['scheme'])) ? $url['scheme'] . '://' : ''; |
|
| 115 | + // user & pass |
|
| 116 | + if (!empty($url['user'])) { |
|
| 117 | + $uri .= $url['user'] . ':' . $url['pass'] . '@'; |
|
| 118 | + } |
|
| 119 | + // host |
|
| 120 | + $uri .= $url['host']; |
|
| 121 | + // port |
|
| 122 | + $port = (!empty($url['port'])) ? ':' . $url['port'] : ''; |
|
| 123 | + $uri .= $port; |
|
| 124 | + // path |
|
| 125 | + $uri .= $url['path']; |
|
| 126 | 126 | // fragment or query |
| 127 | - if (isset($url['fragment'])) { |
|
| 128 | - $uri .= '#' . $url['fragment']; |
|
| 129 | - } elseif (isset($url['query'])) { |
|
| 130 | - $uri .= '?' . $url['query']; |
|
| 131 | - } |
|
| 127 | + if (isset($url['fragment'])) { |
|
| 128 | + $uri .= '#' . $url['fragment']; |
|
| 129 | + } elseif (isset($url['query'])) { |
|
| 130 | + $uri .= '?' . $url['query']; |
|
| 131 | + } |
|
| 132 | 132 | |
| 133 | - return $uri; |
|
| 133 | + return $uri; |
|
| 134 | 134 | } |
| 135 | 135 | |
| 136 | 136 | |
| 137 | 137 | // Ne pas afficher la partie 'password' du proxy |
| 138 | 138 | function no_password_proxy_url($http_proxy) { |
| 139 | - if ( |
|
| 140 | - $http_proxy |
|
| 141 | - and $p = @parse_url($http_proxy) |
|
| 142 | - and isset($p['pass']) |
|
| 143 | - and $p['pass'] |
|
| 144 | - ) { |
|
| 145 | - $p['pass'] = '****'; |
|
| 146 | - $http_proxy = glue_url($p); |
|
| 147 | - } |
|
| 148 | - |
|
| 149 | - return $http_proxy; |
|
| 139 | + if ( |
|
| 140 | + $http_proxy |
|
| 141 | + and $p = @parse_url($http_proxy) |
|
| 142 | + and isset($p['pass']) |
|
| 143 | + and $p['pass'] |
|
| 144 | + ) { |
|
| 145 | + $p['pass'] = '****'; |
|
| 146 | + $http_proxy = glue_url($p); |
|
| 147 | + } |
|
| 148 | + |
|
| 149 | + return $http_proxy; |
|
| 150 | 150 | } |
@@ -96,7 +96,7 @@ |
||
| 96 | 96 | $id_job = job_queue_add('mail', 'Test Envoi des nouveautes', [0], 'genie/'); |
| 97 | 97 | include_spip('inc/queue'); |
| 98 | 98 | queue_schedule([$id_job]); |
| 99 | - $res['message_ok'] .= '<br />' . _T('info_liste_nouveautes_envoyee'); |
|
| 99 | + $res['message_ok'] .= '<br />'._T('info_liste_nouveautes_envoyee'); |
|
| 100 | 100 | } |
| 101 | 101 | |
| 102 | 102 | return $res; |
@@ -11,93 +11,93 @@ |
||
| 11 | 11 | \***************************************************************************/ |
| 12 | 12 | |
| 13 | 13 | if (!defined('_ECRIRE_INC_VERSION')) { |
| 14 | - return; |
|
| 14 | + return; |
|
| 15 | 15 | } |
| 16 | 16 | |
| 17 | 17 | function formulaires_configurer_annonces_charger_dist() { |
| 18 | - $valeurs = []; |
|
| 19 | - foreach ( |
|
| 20 | - [ |
|
| 21 | - 'suivi_edito', |
|
| 22 | - 'adresse_suivi', |
|
| 23 | - 'adresse_suivi_inscription', |
|
| 24 | - 'quoi_de_neuf', |
|
| 25 | - 'adresse_neuf', |
|
| 26 | - 'jours_neuf', |
|
| 27 | - 'email_envoi', |
|
| 28 | - ] as $m |
|
| 29 | - ) { |
|
| 30 | - $valeurs[$m] = $GLOBALS['meta'][$m]; |
|
| 31 | - } |
|
| 18 | + $valeurs = []; |
|
| 19 | + foreach ( |
|
| 20 | + [ |
|
| 21 | + 'suivi_edito', |
|
| 22 | + 'adresse_suivi', |
|
| 23 | + 'adresse_suivi_inscription', |
|
| 24 | + 'quoi_de_neuf', |
|
| 25 | + 'adresse_neuf', |
|
| 26 | + 'jours_neuf', |
|
| 27 | + 'email_envoi', |
|
| 28 | + ] as $m |
|
| 29 | + ) { |
|
| 30 | + $valeurs[$m] = $GLOBALS['meta'][$m]; |
|
| 31 | + } |
|
| 32 | 32 | |
| 33 | - return $valeurs; |
|
| 33 | + return $valeurs; |
|
| 34 | 34 | } |
| 35 | 35 | |
| 36 | 36 | function formulaires_configurer_annonces_verifier_dist() { |
| 37 | - $erreurs = []; |
|
| 38 | - if (_request('suivi_edito') == 'oui') { |
|
| 39 | - if (!$email = _request('adresse_suivi')) { |
|
| 40 | - $erreurs['adresse_suivi'] = _T('info_obligatoire'); |
|
| 41 | - } else { |
|
| 42 | - include_spip('inc/filtres'); |
|
| 43 | - if (!email_valide($email)) { |
|
| 44 | - $erreurs['adresse_suivi'] = _T('form_prop_indiquer_email'); |
|
| 45 | - } |
|
| 46 | - } |
|
| 47 | - } |
|
| 48 | - if (_request('quoi_de_neuf') == 'oui') { |
|
| 49 | - if (!$email = _request('adresse_neuf')) { |
|
| 50 | - $erreurs['adresse_neuf'] = _T('info_obligatoire'); |
|
| 51 | - } else { |
|
| 52 | - include_spip('inc/filtres'); |
|
| 53 | - if (!email_valide($email)) { |
|
| 54 | - $erreurs['adresse_neuf'] = _T('form_prop_indiquer_email'); |
|
| 55 | - } |
|
| 56 | - } |
|
| 57 | - if (!$email = _request('jours_neuf')) { |
|
| 58 | - $erreurs['jours_neuf'] = _T('info_obligatoire'); |
|
| 59 | - } |
|
| 60 | - } |
|
| 37 | + $erreurs = []; |
|
| 38 | + if (_request('suivi_edito') == 'oui') { |
|
| 39 | + if (!$email = _request('adresse_suivi')) { |
|
| 40 | + $erreurs['adresse_suivi'] = _T('info_obligatoire'); |
|
| 41 | + } else { |
|
| 42 | + include_spip('inc/filtres'); |
|
| 43 | + if (!email_valide($email)) { |
|
| 44 | + $erreurs['adresse_suivi'] = _T('form_prop_indiquer_email'); |
|
| 45 | + } |
|
| 46 | + } |
|
| 47 | + } |
|
| 48 | + if (_request('quoi_de_neuf') == 'oui') { |
|
| 49 | + if (!$email = _request('adresse_neuf')) { |
|
| 50 | + $erreurs['adresse_neuf'] = _T('info_obligatoire'); |
|
| 51 | + } else { |
|
| 52 | + include_spip('inc/filtres'); |
|
| 53 | + if (!email_valide($email)) { |
|
| 54 | + $erreurs['adresse_neuf'] = _T('form_prop_indiquer_email'); |
|
| 55 | + } |
|
| 56 | + } |
|
| 57 | + if (!$email = _request('jours_neuf')) { |
|
| 58 | + $erreurs['jours_neuf'] = _T('info_obligatoire'); |
|
| 59 | + } |
|
| 60 | + } |
|
| 61 | 61 | |
| 62 | - return $erreurs; |
|
| 62 | + return $erreurs; |
|
| 63 | 63 | } |
| 64 | 64 | |
| 65 | 65 | function formulaires_configurer_annonces_traiter_dist() { |
| 66 | - $res = ['editable' => true]; |
|
| 67 | - foreach ( |
|
| 68 | - [ |
|
| 69 | - 'suivi_edito', |
|
| 70 | - 'quoi_de_neuf', |
|
| 71 | - ] as $m |
|
| 72 | - ) { |
|
| 73 | - if (!is_null($v = _request($m))) { |
|
| 74 | - ecrire_meta($m, $v == 'oui' ? 'oui' : 'non'); |
|
| 75 | - } |
|
| 76 | - } |
|
| 66 | + $res = ['editable' => true]; |
|
| 67 | + foreach ( |
|
| 68 | + [ |
|
| 69 | + 'suivi_edito', |
|
| 70 | + 'quoi_de_neuf', |
|
| 71 | + ] as $m |
|
| 72 | + ) { |
|
| 73 | + if (!is_null($v = _request($m))) { |
|
| 74 | + ecrire_meta($m, $v == 'oui' ? 'oui' : 'non'); |
|
| 75 | + } |
|
| 76 | + } |
|
| 77 | 77 | |
| 78 | - foreach ( |
|
| 79 | - [ |
|
| 80 | - 'adresse_suivi', |
|
| 81 | - 'adresse_suivi_inscription', |
|
| 82 | - 'adresse_neuf', |
|
| 83 | - 'jours_neuf', |
|
| 84 | - 'email_envoi', |
|
| 85 | - ] as $m |
|
| 86 | - ) { |
|
| 87 | - if (!is_null($v = _request($m))) { |
|
| 88 | - ecrire_meta($m, $v); |
|
| 89 | - } |
|
| 90 | - } |
|
| 78 | + foreach ( |
|
| 79 | + [ |
|
| 80 | + 'adresse_suivi', |
|
| 81 | + 'adresse_suivi_inscription', |
|
| 82 | + 'adresse_neuf', |
|
| 83 | + 'jours_neuf', |
|
| 84 | + 'email_envoi', |
|
| 85 | + ] as $m |
|
| 86 | + ) { |
|
| 87 | + if (!is_null($v = _request($m))) { |
|
| 88 | + ecrire_meta($m, $v); |
|
| 89 | + } |
|
| 90 | + } |
|
| 91 | 91 | |
| 92 | - $res['message_ok'] = _T('config_info_enregistree'); |
|
| 93 | - // provoquer l'envoi des nouveautes en supprimant le fichier lock |
|
| 94 | - if (_request('envoi_now')) { |
|
| 95 | - effacer_meta('dernier_envoi_neuf'); |
|
| 96 | - $id_job = job_queue_add('mail', 'Test Envoi des nouveautes', [0], 'genie/'); |
|
| 97 | - include_spip('inc/queue'); |
|
| 98 | - queue_schedule([$id_job]); |
|
| 99 | - $res['message_ok'] .= '<br />' . _T('info_liste_nouveautes_envoyee'); |
|
| 100 | - } |
|
| 92 | + $res['message_ok'] = _T('config_info_enregistree'); |
|
| 93 | + // provoquer l'envoi des nouveautes en supprimant le fichier lock |
|
| 94 | + if (_request('envoi_now')) { |
|
| 95 | + effacer_meta('dernier_envoi_neuf'); |
|
| 96 | + $id_job = job_queue_add('mail', 'Test Envoi des nouveautes', [0], 'genie/'); |
|
| 97 | + include_spip('inc/queue'); |
|
| 98 | + queue_schedule([$id_job]); |
|
| 99 | + $res['message_ok'] .= '<br />' . _T('info_liste_nouveautes_envoyee'); |
|
| 100 | + } |
|
| 101 | 101 | |
| 102 | - return $res; |
|
| 102 | + return $res; |
|
| 103 | 103 | } |
@@ -145,7 +145,7 @@ discard block |
||
| 145 | 145 | # preparer un lien pour quand redirige_formulaire ne fonctionne pas |
| 146 | 146 | $m = redirige_formulaire($res['redirect']); |
| 147 | 147 | $valeurs['_deja_loge'] = inserer_attribut( |
| 148 | - '<a>' . _T('login_par_ici') . "</a>$m", |
|
| 148 | + '<a>'._T('login_par_ici')."</a>$m", |
|
| 149 | 149 | 'href', |
| 150 | 150 | $res['redirect'] |
| 151 | 151 | ); |
@@ -292,7 +292,7 @@ discard block |
||
| 292 | 292 | function login_autoriser() { |
| 293 | 293 | include_spip('inc/autoriser'); |
| 294 | 294 | if (!autoriser('ecrire')) { |
| 295 | - $h = generer_url_action('logout', 'logout=prive&url=' . urlencode(self())); |
|
| 295 | + $h = generer_url_action('logout', 'logout=prive&url='.urlencode(self())); |
|
| 296 | 296 | |
| 297 | 297 | return [ |
| 298 | 298 | 'message_erreur' => '<h1>' |
@@ -300,7 +300,7 @@ discard block |
||
| 300 | 300 | . '</h1><p>' |
| 301 | 301 | . _T('texte_erreur_visiteur') |
| 302 | 302 | . "</p><p class='retour'>[<a href='$h'>" |
| 303 | - . _T('icone_deconnecter') . '</a>]</p>' |
|
| 303 | + . _T('icone_deconnecter').'</a>]</p>' |
|
| 304 | 304 | ]; |
| 305 | 305 | } |
| 306 | 306 | |
@@ -352,7 +352,7 @@ discard block |
||
| 352 | 352 | // transformer la cible absolue en cible relative |
| 353 | 353 | // pour pas echouer quand la meta adresse_site est foireuse |
| 354 | 354 | if (strncmp($cible, $u = url_de_base(), strlen($u)) == 0) { |
| 355 | - $cible = './' . substr($cible, strlen($u)); |
|
| 355 | + $cible = './'.substr($cible, strlen($u)); |
|
| 356 | 356 | } elseif (tester_url_absolue($cible) and !defined('_AUTORISER_LOGIN_ABS_REDIRECT')) { |
| 357 | 357 | // si c'est une url absolue, refuser la redirection |
| 358 | 358 | // sauf si cette securite est levee volontairement par le webmestre |
@@ -364,7 +364,7 @@ discard block |
||
| 364 | 364 | if ($cible and ($cible != self('&')) and ($cible != self())) { |
| 365 | 365 | $res['redirect'] = $cible; |
| 366 | 366 | $res['message_ok'] = inserer_attribut( |
| 367 | - '<a>' . _T('login_par_ici') . '</a>', |
|
| 367 | + '<a>'._T('login_par_ici').'</a>', |
|
| 368 | 368 | 'href', |
| 369 | 369 | $cible |
| 370 | 370 | ); |
@@ -17,7 +17,7 @@ discard block |
||
| 17 | 17 | **/ |
| 18 | 18 | |
| 19 | 19 | if (!defined('_ECRIRE_INC_VERSION')) { |
| 20 | - return; |
|
| 20 | + return; |
|
| 21 | 21 | } |
| 22 | 22 | |
| 23 | 23 | include_spip('base/abstract_sql'); |
@@ -31,11 +31,11 @@ discard block |
||
| 31 | 31 | * true si espace privé, false sinon. |
| 32 | 32 | **/ |
| 33 | 33 | function is_url_prive($cible) { |
| 34 | - include_spip('inc/filtres_mini'); |
|
| 35 | - $path = parse_url(tester_url_absolue($cible) ? $cible : url_absolue($cible)); |
|
| 36 | - $path = ($path['path'] ?? ''); |
|
| 34 | + include_spip('inc/filtres_mini'); |
|
| 35 | + $path = parse_url(tester_url_absolue($cible) ? $cible : url_absolue($cible)); |
|
| 36 | + $path = ($path['path'] ?? ''); |
|
| 37 | 37 | |
| 38 | - return strncmp(substr($path, -strlen(_DIR_RESTREINT_ABS)), _DIR_RESTREINT_ABS, strlen(_DIR_RESTREINT_ABS)) == 0; |
|
| 38 | + return strncmp(substr($path, -strlen(_DIR_RESTREINT_ABS)), _DIR_RESTREINT_ABS, strlen(_DIR_RESTREINT_ABS)) == 0; |
|
| 39 | 39 | } |
| 40 | 40 | |
| 41 | 41 | /** |
@@ -60,111 +60,111 @@ discard block |
||
| 60 | 60 | * Environnement du formulaire |
| 61 | 61 | **/ |
| 62 | 62 | function formulaires_login_charger_dist($cible = '', $options = [], $deprecated = null) { |
| 63 | - $erreur = _request('var_erreur'); |
|
| 64 | - |
|
| 65 | - if (!is_array($options)) { |
|
| 66 | - $options = [ |
|
| 67 | - 'login' => $options, |
|
| 68 | - 'prive' => $deprecated |
|
| 69 | - ]; |
|
| 70 | - } |
|
| 71 | - |
|
| 72 | - $login = (empty($options['login']) ? '' : $options['login']); |
|
| 73 | - $prive = (empty($options['prive']) ? null : $options['prive']); |
|
| 74 | - // conserver le fonctionnement historique |
|
| 75 | - if (!isset($options['autofocus'])) { |
|
| 76 | - $options['autofocus'] = true; |
|
| 77 | - } |
|
| 78 | - |
|
| 79 | - if (!$login) { |
|
| 80 | - $login = strval(_request('var_login')); |
|
| 81 | - } |
|
| 82 | - // si on est deja identifie |
|
| 83 | - if (!$login and isset($GLOBALS['visiteur_session']['email'])) { |
|
| 84 | - $login = $GLOBALS['visiteur_session']['email']; |
|
| 85 | - } |
|
| 86 | - if (!$login and isset($GLOBALS['visiteur_session']['login'])) { |
|
| 87 | - $login = $GLOBALS['visiteur_session']['login']; |
|
| 88 | - } |
|
| 89 | - // ou si on a un cookie admin |
|
| 90 | - if (!$login) { |
|
| 91 | - if ( |
|
| 92 | - isset($_COOKIE['spip_admin']) |
|
| 93 | - and preg_match(',^@(.*)$,', $_COOKIE['spip_admin'], $regs) |
|
| 94 | - ) { |
|
| 95 | - $login = $regs[1]; |
|
| 96 | - } |
|
| 97 | - } |
|
| 98 | - |
|
| 99 | - $lang = $GLOBALS['spip_lang']; |
|
| 100 | - include_spip('inc/auth'); |
|
| 101 | - $row = auth_informer_login($login); |
|
| 102 | - |
|
| 103 | - // retablir la langue de l'URL si forcee (on ignore la langue de l'auteur dans ce cas) |
|
| 104 | - if (_request('lang') === $lang and $GLOBALS['spip_lang'] !== $lang) { |
|
| 105 | - changer_langue($lang); |
|
| 106 | - } |
|
| 107 | - |
|
| 108 | - // Construire l'environnement du squelette |
|
| 109 | - // Ne pas proposer de "rester connecte quelques jours" |
|
| 110 | - // si la duree de l'alea est inferieure a 12 h (valeur par defaut) |
|
| 111 | - |
|
| 112 | - $valeurs = [ |
|
| 113 | - 'var_login' => $login, |
|
| 114 | - 'editable' => !$row, |
|
| 115 | - 'cnx' => $row['cnx'] ?? '0', |
|
| 116 | - 'auth_http' => login_auth_http(), |
|
| 117 | - 'rester_connecte' => ((_RENOUVELLE_ALEA < 12 * 3600) ? '' : ' '), |
|
| 118 | - '_logo' => $row['logo'] ?? '', |
|
| 119 | - '_alea_actuel' => $row['alea_actuel'] ?? '', |
|
| 120 | - '_alea_futur' => $row['alea_futur'] ?? '', |
|
| 121 | - '_pipeline' => 'affiche_formulaire_login', // faire passer le formulaire dans un pipe dedie pour les methodes auth |
|
| 122 | - '_autofocus' => ($options['autofocus'] and $options['autofocus'] !== 'non') ? ' ' : '', |
|
| 123 | - ]; |
|
| 124 | - |
|
| 125 | - if ($erreur or !isset($GLOBALS['visiteur_session']['id_auteur']) or !$GLOBALS['visiteur_session']['id_auteur']) { |
|
| 126 | - $valeurs['editable'] = true; |
|
| 127 | - } |
|
| 128 | - |
|
| 129 | - if (is_null($prive) ? is_url_prive($cible) : $prive) { |
|
| 130 | - include_spip('inc/autoriser'); |
|
| 131 | - $loge = autoriser('ecrire'); |
|
| 132 | - } else { |
|
| 133 | - $loge = (isset($GLOBALS['visiteur_session']['auth']) and $GLOBALS['visiteur_session']['auth'] != ''); |
|
| 134 | - } |
|
| 135 | - |
|
| 136 | - // Si on est connecte, appeler traiter() |
|
| 137 | - // et lancer la redirection si besoin |
|
| 138 | - if (!$valeurs['editable'] and $loge and _request('formulaire_action') !== 'login') { |
|
| 139 | - $traiter = charger_fonction('traiter', 'formulaires/login'); |
|
| 140 | - $res = $traiter($cible, $login, $prive); |
|
| 141 | - $valeurs = array_merge($valeurs, $res); |
|
| 142 | - |
|
| 143 | - if (isset($res['redirect']) and $res['redirect']) { |
|
| 144 | - include_spip('inc/headers'); |
|
| 145 | - # preparer un lien pour quand redirige_formulaire ne fonctionne pas |
|
| 146 | - $m = redirige_formulaire($res['redirect']); |
|
| 147 | - $valeurs['_deja_loge'] = inserer_attribut( |
|
| 148 | - '<a>' . _T('login_par_ici') . "</a>$m", |
|
| 149 | - 'href', |
|
| 150 | - $res['redirect'] |
|
| 151 | - ); |
|
| 152 | - } |
|
| 153 | - } |
|
| 154 | - // en cas d'echec de cookie, inc_auth a renvoye vers le script de |
|
| 155 | - // pose de cookie ; s'il n'est pas la, c'est echec cookie |
|
| 156 | - // s'il est la, c'est probablement un bookmark sur bonjour=oui, |
|
| 157 | - // et pas un echec cookie. |
|
| 158 | - if ($erreur == 'cookie') { |
|
| 159 | - $valeurs['echec_cookie'] = ' '; |
|
| 160 | - } elseif ($erreur) { |
|
| 161 | - // une erreur d'un SSO indique dans la redirection vers ici |
|
| 162 | - // mais il faut se proteger de toute tentative d'injection malveilante |
|
| 163 | - include_spip('inc/filtres'); |
|
| 164 | - $valeurs['message_erreur'] = textebrut($erreur); |
|
| 165 | - } |
|
| 166 | - |
|
| 167 | - return $valeurs; |
|
| 63 | + $erreur = _request('var_erreur'); |
|
| 64 | + |
|
| 65 | + if (!is_array($options)) { |
|
| 66 | + $options = [ |
|
| 67 | + 'login' => $options, |
|
| 68 | + 'prive' => $deprecated |
|
| 69 | + ]; |
|
| 70 | + } |
|
| 71 | + |
|
| 72 | + $login = (empty($options['login']) ? '' : $options['login']); |
|
| 73 | + $prive = (empty($options['prive']) ? null : $options['prive']); |
|
| 74 | + // conserver le fonctionnement historique |
|
| 75 | + if (!isset($options['autofocus'])) { |
|
| 76 | + $options['autofocus'] = true; |
|
| 77 | + } |
|
| 78 | + |
|
| 79 | + if (!$login) { |
|
| 80 | + $login = strval(_request('var_login')); |
|
| 81 | + } |
|
| 82 | + // si on est deja identifie |
|
| 83 | + if (!$login and isset($GLOBALS['visiteur_session']['email'])) { |
|
| 84 | + $login = $GLOBALS['visiteur_session']['email']; |
|
| 85 | + } |
|
| 86 | + if (!$login and isset($GLOBALS['visiteur_session']['login'])) { |
|
| 87 | + $login = $GLOBALS['visiteur_session']['login']; |
|
| 88 | + } |
|
| 89 | + // ou si on a un cookie admin |
|
| 90 | + if (!$login) { |
|
| 91 | + if ( |
|
| 92 | + isset($_COOKIE['spip_admin']) |
|
| 93 | + and preg_match(',^@(.*)$,', $_COOKIE['spip_admin'], $regs) |
|
| 94 | + ) { |
|
| 95 | + $login = $regs[1]; |
|
| 96 | + } |
|
| 97 | + } |
|
| 98 | + |
|
| 99 | + $lang = $GLOBALS['spip_lang']; |
|
| 100 | + include_spip('inc/auth'); |
|
| 101 | + $row = auth_informer_login($login); |
|
| 102 | + |
|
| 103 | + // retablir la langue de l'URL si forcee (on ignore la langue de l'auteur dans ce cas) |
|
| 104 | + if (_request('lang') === $lang and $GLOBALS['spip_lang'] !== $lang) { |
|
| 105 | + changer_langue($lang); |
|
| 106 | + } |
|
| 107 | + |
|
| 108 | + // Construire l'environnement du squelette |
|
| 109 | + // Ne pas proposer de "rester connecte quelques jours" |
|
| 110 | + // si la duree de l'alea est inferieure a 12 h (valeur par defaut) |
|
| 111 | + |
|
| 112 | + $valeurs = [ |
|
| 113 | + 'var_login' => $login, |
|
| 114 | + 'editable' => !$row, |
|
| 115 | + 'cnx' => $row['cnx'] ?? '0', |
|
| 116 | + 'auth_http' => login_auth_http(), |
|
| 117 | + 'rester_connecte' => ((_RENOUVELLE_ALEA < 12 * 3600) ? '' : ' '), |
|
| 118 | + '_logo' => $row['logo'] ?? '', |
|
| 119 | + '_alea_actuel' => $row['alea_actuel'] ?? '', |
|
| 120 | + '_alea_futur' => $row['alea_futur'] ?? '', |
|
| 121 | + '_pipeline' => 'affiche_formulaire_login', // faire passer le formulaire dans un pipe dedie pour les methodes auth |
|
| 122 | + '_autofocus' => ($options['autofocus'] and $options['autofocus'] !== 'non') ? ' ' : '', |
|
| 123 | + ]; |
|
| 124 | + |
|
| 125 | + if ($erreur or !isset($GLOBALS['visiteur_session']['id_auteur']) or !$GLOBALS['visiteur_session']['id_auteur']) { |
|
| 126 | + $valeurs['editable'] = true; |
|
| 127 | + } |
|
| 128 | + |
|
| 129 | + if (is_null($prive) ? is_url_prive($cible) : $prive) { |
|
| 130 | + include_spip('inc/autoriser'); |
|
| 131 | + $loge = autoriser('ecrire'); |
|
| 132 | + } else { |
|
| 133 | + $loge = (isset($GLOBALS['visiteur_session']['auth']) and $GLOBALS['visiteur_session']['auth'] != ''); |
|
| 134 | + } |
|
| 135 | + |
|
| 136 | + // Si on est connecte, appeler traiter() |
|
| 137 | + // et lancer la redirection si besoin |
|
| 138 | + if (!$valeurs['editable'] and $loge and _request('formulaire_action') !== 'login') { |
|
| 139 | + $traiter = charger_fonction('traiter', 'formulaires/login'); |
|
| 140 | + $res = $traiter($cible, $login, $prive); |
|
| 141 | + $valeurs = array_merge($valeurs, $res); |
|
| 142 | + |
|
| 143 | + if (isset($res['redirect']) and $res['redirect']) { |
|
| 144 | + include_spip('inc/headers'); |
|
| 145 | + # preparer un lien pour quand redirige_formulaire ne fonctionne pas |
|
| 146 | + $m = redirige_formulaire($res['redirect']); |
|
| 147 | + $valeurs['_deja_loge'] = inserer_attribut( |
|
| 148 | + '<a>' . _T('login_par_ici') . "</a>$m", |
|
| 149 | + 'href', |
|
| 150 | + $res['redirect'] |
|
| 151 | + ); |
|
| 152 | + } |
|
| 153 | + } |
|
| 154 | + // en cas d'echec de cookie, inc_auth a renvoye vers le script de |
|
| 155 | + // pose de cookie ; s'il n'est pas la, c'est echec cookie |
|
| 156 | + // s'il est la, c'est probablement un bookmark sur bonjour=oui, |
|
| 157 | + // et pas un echec cookie. |
|
| 158 | + if ($erreur == 'cookie') { |
|
| 159 | + $valeurs['echec_cookie'] = ' '; |
|
| 160 | + } elseif ($erreur) { |
|
| 161 | + // une erreur d'un SSO indique dans la redirection vers ici |
|
| 162 | + // mais il faut se proteger de toute tentative d'injection malveilante |
|
| 163 | + include_spip('inc/filtres'); |
|
| 164 | + $valeurs['message_erreur'] = textebrut($erreur); |
|
| 165 | + } |
|
| 166 | + |
|
| 167 | + return $valeurs; |
|
| 168 | 168 | } |
| 169 | 169 | |
| 170 | 170 | |
@@ -179,20 +179,20 @@ discard block |
||
| 179 | 179 | * - chaîne vide sinon. |
| 180 | 180 | **/ |
| 181 | 181 | function login_auth_http() { |
| 182 | - if ( |
|
| 183 | - !$GLOBALS['ignore_auth_http'] |
|
| 184 | - and _request('var_erreur') == 'cookie' |
|
| 185 | - and (!isset($_COOKIE['spip_session']) or $_COOKIE['spip_session'] != 'test_echec_cookie') |
|
| 186 | - and (preg_match(',apache,', \PHP_SAPI) |
|
| 187 | - or preg_match(',^Apache.* PHP,', $_SERVER['SERVER_SOFTWARE'])) |
|
| 188 | - // Attention dans le cas 'intranet' la proposition de se loger |
|
| 189 | - // par auth_http peut conduire a l'echec. |
|
| 190 | - and !(isset($_SERVER['PHP_AUTH_USER']) and isset($_SERVER['PHP_AUTH_PW'])) |
|
| 191 | - ) { |
|
| 192 | - return generer_url_action('cookie', '', false, true); |
|
| 193 | - } else { |
|
| 194 | - return ''; |
|
| 195 | - } |
|
| 182 | + if ( |
|
| 183 | + !$GLOBALS['ignore_auth_http'] |
|
| 184 | + and _request('var_erreur') == 'cookie' |
|
| 185 | + and (!isset($_COOKIE['spip_session']) or $_COOKIE['spip_session'] != 'test_echec_cookie') |
|
| 186 | + and (preg_match(',apache,', \PHP_SAPI) |
|
| 187 | + or preg_match(',^Apache.* PHP,', $_SERVER['SERVER_SOFTWARE'])) |
|
| 188 | + // Attention dans le cas 'intranet' la proposition de se loger |
|
| 189 | + // par auth_http peut conduire a l'echec. |
|
| 190 | + and !(isset($_SERVER['PHP_AUTH_USER']) and isset($_SERVER['PHP_AUTH_PW'])) |
|
| 191 | + ) { |
|
| 192 | + return generer_url_action('cookie', '', false, true); |
|
| 193 | + } else { |
|
| 194 | + return ''; |
|
| 195 | + } |
|
| 196 | 196 | } |
| 197 | 197 | |
| 198 | 198 | |
@@ -218,65 +218,65 @@ discard block |
||
| 218 | 218 | **/ |
| 219 | 219 | function formulaires_login_verifier_dist($cible = '', $options = [], $deprecated = null) { |
| 220 | 220 | |
| 221 | - $erreurs = []; |
|
| 222 | - if (!is_array($options)) { |
|
| 223 | - $options = [ |
|
| 224 | - 'login' => $options, |
|
| 225 | - 'prive' => $deprecated |
|
| 226 | - ]; |
|
| 227 | - } |
|
| 228 | - |
|
| 229 | - $prive = (empty($options['prive']) ? null : $options['prive']); |
|
| 230 | - |
|
| 231 | - $session_login = _request('var_login'); |
|
| 232 | - $session_password = _request('password'); |
|
| 233 | - $session_remember = _request('session_remember'); |
|
| 234 | - |
|
| 235 | - if (!$session_login) { |
|
| 236 | - # pas de login saisi ! |
|
| 237 | - return ['var_login' => _T('info_obligatoire')]; |
|
| 238 | - } |
|
| 239 | - |
|
| 240 | - // appeler auth_identifier_login qui va : |
|
| 241 | - // - renvoyer un string si echec (message d'erreur) |
|
| 242 | - // - un array decrivant l'auteur identifie si possible |
|
| 243 | - // - rediriger vers un SSO qui renverra in fine sur action/auth qui finira l'authentification |
|
| 244 | - include_spip('inc/auth'); |
|
| 245 | - $auteur = auth_identifier_login($session_login, $session_password); |
|
| 246 | - // on arrive ici si on ne s'est pas identifie avec un SSO |
|
| 247 | - if (!is_array($auteur)) { |
|
| 248 | - $erreurs = []; |
|
| 249 | - if (is_string($auteur) and strlen($auteur)) { |
|
| 250 | - $erreurs['var_login'] = $auteur; |
|
| 251 | - } |
|
| 252 | - include_spip('inc/cookie'); |
|
| 253 | - spip_setcookie('spip_admin', '', time() - 3600); |
|
| 254 | - if (strlen($session_password)) { |
|
| 255 | - $erreurs['password'] = _T('login_erreur_pass'); |
|
| 256 | - } else { |
|
| 257 | - // sinon c'est un login en deux passe old style (ou js en panne) |
|
| 258 | - // pas de message d'erreur |
|
| 259 | - $erreurs['password'] = ' '; |
|
| 260 | - $erreurs['message_erreur'] = ''; |
|
| 261 | - } |
|
| 262 | - |
|
| 263 | - return |
|
| 264 | - $erreurs; |
|
| 265 | - } |
|
| 266 | - // on a ete authentifie, construire la session |
|
| 267 | - // en gerant la duree demandee pour son cookie |
|
| 268 | - if ($session_remember !== null) { |
|
| 269 | - $auteur['cookie'] = $session_remember; |
|
| 270 | - } |
|
| 271 | - // si la connexion est refusee on renvoi un message erreur de mot de passe |
|
| 272 | - // car en donnant plus de detail on renseignerait un assaillant sur l'existence d'un compte |
|
| 273 | - if (auth_loger($auteur) === false) { |
|
| 274 | - $erreurs['message_erreur'] = _T('login_erreur_pass'); |
|
| 275 | - return $erreurs; |
|
| 276 | - } |
|
| 277 | - |
|
| 278 | - return (is_null($prive) ? is_url_prive($cible) : $prive) |
|
| 279 | - ? login_autoriser() : []; |
|
| 221 | + $erreurs = []; |
|
| 222 | + if (!is_array($options)) { |
|
| 223 | + $options = [ |
|
| 224 | + 'login' => $options, |
|
| 225 | + 'prive' => $deprecated |
|
| 226 | + ]; |
|
| 227 | + } |
|
| 228 | + |
|
| 229 | + $prive = (empty($options['prive']) ? null : $options['prive']); |
|
| 230 | + |
|
| 231 | + $session_login = _request('var_login'); |
|
| 232 | + $session_password = _request('password'); |
|
| 233 | + $session_remember = _request('session_remember'); |
|
| 234 | + |
|
| 235 | + if (!$session_login) { |
|
| 236 | + # pas de login saisi ! |
|
| 237 | + return ['var_login' => _T('info_obligatoire')]; |
|
| 238 | + } |
|
| 239 | + |
|
| 240 | + // appeler auth_identifier_login qui va : |
|
| 241 | + // - renvoyer un string si echec (message d'erreur) |
|
| 242 | + // - un array decrivant l'auteur identifie si possible |
|
| 243 | + // - rediriger vers un SSO qui renverra in fine sur action/auth qui finira l'authentification |
|
| 244 | + include_spip('inc/auth'); |
|
| 245 | + $auteur = auth_identifier_login($session_login, $session_password); |
|
| 246 | + // on arrive ici si on ne s'est pas identifie avec un SSO |
|
| 247 | + if (!is_array($auteur)) { |
|
| 248 | + $erreurs = []; |
|
| 249 | + if (is_string($auteur) and strlen($auteur)) { |
|
| 250 | + $erreurs['var_login'] = $auteur; |
|
| 251 | + } |
|
| 252 | + include_spip('inc/cookie'); |
|
| 253 | + spip_setcookie('spip_admin', '', time() - 3600); |
|
| 254 | + if (strlen($session_password)) { |
|
| 255 | + $erreurs['password'] = _T('login_erreur_pass'); |
|
| 256 | + } else { |
|
| 257 | + // sinon c'est un login en deux passe old style (ou js en panne) |
|
| 258 | + // pas de message d'erreur |
|
| 259 | + $erreurs['password'] = ' '; |
|
| 260 | + $erreurs['message_erreur'] = ''; |
|
| 261 | + } |
|
| 262 | + |
|
| 263 | + return |
|
| 264 | + $erreurs; |
|
| 265 | + } |
|
| 266 | + // on a ete authentifie, construire la session |
|
| 267 | + // en gerant la duree demandee pour son cookie |
|
| 268 | + if ($session_remember !== null) { |
|
| 269 | + $auteur['cookie'] = $session_remember; |
|
| 270 | + } |
|
| 271 | + // si la connexion est refusee on renvoi un message erreur de mot de passe |
|
| 272 | + // car en donnant plus de detail on renseignerait un assaillant sur l'existence d'un compte |
|
| 273 | + if (auth_loger($auteur) === false) { |
|
| 274 | + $erreurs['message_erreur'] = _T('login_erreur_pass'); |
|
| 275 | + return $erreurs; |
|
| 276 | + } |
|
| 277 | + |
|
| 278 | + return (is_null($prive) ? is_url_prive($cible) : $prive) |
|
| 279 | + ? login_autoriser() : []; |
|
| 280 | 280 | } |
| 281 | 281 | |
| 282 | 282 | /** |
@@ -291,21 +291,21 @@ discard block |
||
| 291 | 291 | * - tableau vide sinon. |
| 292 | 292 | **/ |
| 293 | 293 | function login_autoriser() { |
| 294 | - include_spip('inc/autoriser'); |
|
| 295 | - if (!autoriser('ecrire')) { |
|
| 296 | - $h = generer_url_action('logout', 'logout=prive&url=' . urlencode(self())); |
|
| 297 | - |
|
| 298 | - return [ |
|
| 299 | - 'message_erreur' => '<h1>' |
|
| 300 | - . _T('avis_erreur_visiteur') |
|
| 301 | - . '</h1><p>' |
|
| 302 | - . _T('texte_erreur_visiteur') |
|
| 303 | - . "</p><p class='retour'>[<a href='$h'>" |
|
| 304 | - . _T('icone_deconnecter') . '</a>]</p>' |
|
| 305 | - ]; |
|
| 306 | - } |
|
| 307 | - |
|
| 308 | - return []; |
|
| 294 | + include_spip('inc/autoriser'); |
|
| 295 | + if (!autoriser('ecrire')) { |
|
| 296 | + $h = generer_url_action('logout', 'logout=prive&url=' . urlencode(self())); |
|
| 297 | + |
|
| 298 | + return [ |
|
| 299 | + 'message_erreur' => '<h1>' |
|
| 300 | + . _T('avis_erreur_visiteur') |
|
| 301 | + . '</h1><p>' |
|
| 302 | + . _T('texte_erreur_visiteur') |
|
| 303 | + . "</p><p class='retour'>[<a href='$h'>" |
|
| 304 | + . _T('icone_deconnecter') . '</a>]</p>' |
|
| 305 | + ]; |
|
| 306 | + } |
|
| 307 | + |
|
| 308 | + return []; |
|
| 309 | 309 | } |
| 310 | 310 | |
| 311 | 311 | /** |
@@ -326,55 +326,55 @@ discard block |
||
| 326 | 326 | * Retours du traitement |
| 327 | 327 | **/ |
| 328 | 328 | function formulaires_login_traiter_dist($cible = '', $options = [], $deprecated = null) { |
| 329 | - $res = []; |
|
| 330 | - |
|
| 331 | - if (!is_array($options)) { |
|
| 332 | - $options = [ |
|
| 333 | - 'login' => $options, |
|
| 334 | - 'prive' => $deprecated |
|
| 335 | - ]; |
|
| 336 | - } |
|
| 337 | - |
|
| 338 | - $login = (empty($options['login']) ? '' : $options['login']); |
|
| 339 | - $prive = (empty($options['prive']) ? null : $options['prive']); |
|
| 340 | - |
|
| 341 | - // Si on se connecte dans l'espace prive, |
|
| 342 | - // ajouter "bonjour" (repere a peu pres les cookies desactives) |
|
| 343 | - if (is_null($prive) ? is_url_prive($cible) : $prive) { |
|
| 344 | - $cible = parametre_url($cible, 'bonjour', 'oui', '&'); |
|
| 345 | - } |
|
| 346 | - if ($cible == '@page_auteur') { |
|
| 347 | - $cible = generer_objet_url($GLOBALS['auteur_session']['id_auteur'], 'auteur'); |
|
| 348 | - } |
|
| 349 | - |
|
| 350 | - if ($cible) { |
|
| 351 | - $cible = parametre_url($cible, 'var_login', '', '&'); |
|
| 352 | - |
|
| 353 | - // transformer la cible absolue en cible relative |
|
| 354 | - // pour pas echouer quand la meta adresse_site est foireuse |
|
| 355 | - if (strncmp($cible, $u = url_de_base(), strlen($u)) == 0) { |
|
| 356 | - $cible = './' . substr($cible, strlen($u)); |
|
| 357 | - } elseif (tester_url_absolue($cible) and !defined('_AUTORISER_LOGIN_ABS_REDIRECT')) { |
|
| 358 | - // si c'est une url absolue, refuser la redirection |
|
| 359 | - // sauf si cette securite est levee volontairement par le webmestre |
|
| 360 | - $cible = ''; |
|
| 361 | - } |
|
| 362 | - } |
|
| 363 | - |
|
| 364 | - // Si on est connecte, envoyer vers la destination |
|
| 365 | - if ($cible and ($cible != self('&')) and ($cible != self())) { |
|
| 366 | - $res['redirect'] = $cible; |
|
| 367 | - $res['message_ok'] = inserer_attribut( |
|
| 368 | - '<a>' . _T('login_par_ici') . '</a>', |
|
| 369 | - 'href', |
|
| 370 | - $cible |
|
| 371 | - ); |
|
| 372 | - } |
|
| 373 | - |
|
| 374 | - // avant de rediriger il faut mettre a jour les sessions sur le disque si on a charge une session |
|
| 375 | - if (function_exists('terminer_actualiser_sessions')) { |
|
| 376 | - terminer_actualiser_sessions(); |
|
| 377 | - } |
|
| 378 | - |
|
| 379 | - return $res; |
|
| 329 | + $res = []; |
|
| 330 | + |
|
| 331 | + if (!is_array($options)) { |
|
| 332 | + $options = [ |
|
| 333 | + 'login' => $options, |
|
| 334 | + 'prive' => $deprecated |
|
| 335 | + ]; |
|
| 336 | + } |
|
| 337 | + |
|
| 338 | + $login = (empty($options['login']) ? '' : $options['login']); |
|
| 339 | + $prive = (empty($options['prive']) ? null : $options['prive']); |
|
| 340 | + |
|
| 341 | + // Si on se connecte dans l'espace prive, |
|
| 342 | + // ajouter "bonjour" (repere a peu pres les cookies desactives) |
|
| 343 | + if (is_null($prive) ? is_url_prive($cible) : $prive) { |
|
| 344 | + $cible = parametre_url($cible, 'bonjour', 'oui', '&'); |
|
| 345 | + } |
|
| 346 | + if ($cible == '@page_auteur') { |
|
| 347 | + $cible = generer_objet_url($GLOBALS['auteur_session']['id_auteur'], 'auteur'); |
|
| 348 | + } |
|
| 349 | + |
|
| 350 | + if ($cible) { |
|
| 351 | + $cible = parametre_url($cible, 'var_login', '', '&'); |
|
| 352 | + |
|
| 353 | + // transformer la cible absolue en cible relative |
|
| 354 | + // pour pas echouer quand la meta adresse_site est foireuse |
|
| 355 | + if (strncmp($cible, $u = url_de_base(), strlen($u)) == 0) { |
|
| 356 | + $cible = './' . substr($cible, strlen($u)); |
|
| 357 | + } elseif (tester_url_absolue($cible) and !defined('_AUTORISER_LOGIN_ABS_REDIRECT')) { |
|
| 358 | + // si c'est une url absolue, refuser la redirection |
|
| 359 | + // sauf si cette securite est levee volontairement par le webmestre |
|
| 360 | + $cible = ''; |
|
| 361 | + } |
|
| 362 | + } |
|
| 363 | + |
|
| 364 | + // Si on est connecte, envoyer vers la destination |
|
| 365 | + if ($cible and ($cible != self('&')) and ($cible != self())) { |
|
| 366 | + $res['redirect'] = $cible; |
|
| 367 | + $res['message_ok'] = inserer_attribut( |
|
| 368 | + '<a>' . _T('login_par_ici') . '</a>', |
|
| 369 | + 'href', |
|
| 370 | + $cible |
|
| 371 | + ); |
|
| 372 | + } |
|
| 373 | + |
|
| 374 | + // avant de rediriger il faut mettre a jour les sessions sur le disque si on a charge une session |
|
| 375 | + if (function_exists('terminer_actualiser_sessions')) { |
|
| 376 | + terminer_actualiser_sessions(); |
|
| 377 | + } |
|
| 378 | + |
|
| 379 | + return $res; |
|
| 380 | 380 | } |
@@ -25,10 +25,10 @@ discard block |
||
| 25 | 25 | if (defined('_DECLARER_CHOIX_DB')) { |
| 26 | 26 | $nom_connect = _DECLARER_CHOIX_DB; |
| 27 | 27 | $n = ''; |
| 28 | - while (in_array($nom_connect . $n, $deja)) { |
|
| 28 | + while (in_array($nom_connect.$n, $deja)) { |
|
| 29 | 29 | $n = ($n ? $n + 1 : 1); |
| 30 | 30 | } |
| 31 | - $nom_connect = $nom_connect . $n; |
|
| 31 | + $nom_connect = $nom_connect.$n; |
|
| 32 | 32 | } |
| 33 | 33 | |
| 34 | 34 | $valeurs = [ |
@@ -55,7 +55,7 @@ discard block |
||
| 55 | 55 | |
| 56 | 56 | function liste_serveurs() { |
| 57 | 57 | $options = []; |
| 58 | - $dir = _DIR_RESTREINT . 'req/'; |
|
| 58 | + $dir = _DIR_RESTREINT.'req/'; |
|
| 59 | 59 | $d = opendir($dir); |
| 60 | 60 | if (!$d) { |
| 61 | 61 | return []; |
@@ -63,11 +63,11 @@ discard block |
||
| 63 | 63 | while ($f = readdir($d)) { |
| 64 | 64 | if ( |
| 65 | 65 | (preg_match('/^(.*)[.]php$/', $f, $s)) |
| 66 | - and is_readable($f = $dir . $f) |
|
| 66 | + and is_readable($f = $dir.$f) |
|
| 67 | 67 | ) { |
| 68 | 68 | require_once($f); |
| 69 | 69 | $s = $s[1]; |
| 70 | - $v = 'spip_versions_' . $s; |
|
| 70 | + $v = 'spip_versions_'.$s; |
|
| 71 | 71 | if (function_exists($v) and $v()) { |
| 72 | 72 | $options[$s] = "install_select_type_$s"; |
| 73 | 73 | } else { |
@@ -141,7 +141,7 @@ discard block |
||
| 141 | 141 | |
| 142 | 142 | $link = spip_connect_db($adresse_db, '', $login_db, $pass_db, '@test@', $serveur_db); |
| 143 | 143 | if ($link) { |
| 144 | - $GLOBALS['connexions'][$serveur_db][$GLOBALS['spip_sql_version']] = $GLOBALS['spip_' . $serveur_db . '_functions_' . $GLOBALS['spip_sql_version']]; |
|
| 144 | + $GLOBALS['connexions'][$serveur_db][$GLOBALS['spip_sql_version']] = $GLOBALS['spip_'.$serveur_db.'_functions_'.$GLOBALS['spip_sql_version']]; |
|
| 145 | 145 | $GLOBALS['connexions'][$serveur_db] = $link; |
| 146 | 146 | define('_DECLARER_SERVEUR_DB', $serveur_db); |
| 147 | 147 | define('_DECLARER_ADRESSE_DB', $adresse_db); |
@@ -191,7 +191,7 @@ discard block |
||
| 191 | 191 | $f = preg_replace(',[^\w],', '', $nom_connect); |
| 192 | 192 | if ($f !== $nom_connect) { |
| 193 | 193 | $erreurs['nom_connect'] = _T('erreur_nom_connect_incorrect'); |
| 194 | - } elseif (file_exists(_DIR_CONNECT . $nom_connect . '.php')) { |
|
| 194 | + } elseif (file_exists(_DIR_CONNECT.$nom_connect.'.php')) { |
|
| 195 | 195 | $erreurs['nom_connect'] = _T('erreur_connect_deja_existant'); |
| 196 | 196 | } else { |
| 197 | 197 | define('_DECLARER_NOM_CONNECT', $nom_connect); |
@@ -225,9 +225,9 @@ discard block |
||
| 225 | 225 | '' |
| 226 | 226 | ); |
| 227 | 227 | |
| 228 | - install_fichier_connexion(_DIR_CONNECT . _DECLARER_NOM_CONNECT . '.php', $conn); |
|
| 228 | + install_fichier_connexion(_DIR_CONNECT._DECLARER_NOM_CONNECT.'.php', $conn); |
|
| 229 | 229 | |
| 230 | 230 | return [ |
| 231 | - 'message_ok' => _T('install_connect_ok', ['connect' => '<strong>' . _DECLARER_NOM_CONNECT . '</strong>']) |
|
| 231 | + 'message_ok' => _T('install_connect_ok', ['connect' => '<strong>'._DECLARER_NOM_CONNECT.'</strong>']) |
|
| 232 | 232 | ]; |
| 233 | 233 | } |
@@ -10,228 +10,228 @@ |
||
| 10 | 10 | \***************************************************************************/ |
| 11 | 11 | |
| 12 | 12 | if (!defined('_ECRIRE_INC_VERSION')) { |
| 13 | - return; |
|
| 13 | + return; |
|
| 14 | 14 | } |
| 15 | 15 | |
| 16 | 16 | include_spip('inc/install'); |
| 17 | 17 | |
| 18 | 18 | function formulaires_declarer_bases_charger_dist() { |
| 19 | 19 | |
| 20 | - if (!autoriser('detruire')) { |
|
| 21 | - return false; |
|
| 22 | - } |
|
| 23 | - |
|
| 24 | - [$adresse_db, $login_db, $pass_db, $sel, $server_db] = analyse_fichier_connection(_FILE_CONNECT); |
|
| 25 | - |
|
| 26 | - $deja = bases_referencees(_FILE_CONNECT); |
|
| 27 | - // proposer un nom de connect si pas encore saisi |
|
| 28 | - $nom_connect = ''; |
|
| 29 | - if (defined('_DECLARER_CHOIX_DB')) { |
|
| 30 | - $nom_connect = _DECLARER_CHOIX_DB; |
|
| 31 | - $n = ''; |
|
| 32 | - while (in_array($nom_connect . $n, $deja)) { |
|
| 33 | - $n = ($n ? $n + 1 : 1); |
|
| 34 | - } |
|
| 35 | - $nom_connect = $nom_connect . $n; |
|
| 36 | - } |
|
| 37 | - |
|
| 38 | - $valeurs = [ |
|
| 39 | - '_etapes' => 3, |
|
| 40 | - '_bases_deja' => $deja, |
|
| 41 | - '_bases_prop' => defined('_DECLARER_SERVEUR_DB') ? liste_bases(_DECLARER_SERVEUR_DB) : '', |
|
| 42 | - '_tables' => (defined('_DECLARER_SERVEUR_DB') and defined('_DECLARER_CHOIX_DB')) ? |
|
| 43 | - $tables = sql_alltable('%', _DECLARER_SERVEUR_DB) |
|
| 44 | - : |
|
| 45 | - [], |
|
| 46 | - 'main_db' => '', |
|
| 47 | - '_serveurs' => liste_serveurs(), |
|
| 48 | - 'sql_serveur_db' => 'sqlite3', // valeur par defaut |
|
| 49 | - 'adresse_db' => $adresse_db, |
|
| 50 | - 'login_db' => '', |
|
| 51 | - 'pass_db' => '', |
|
| 52 | - 'choix_db' => '', |
|
| 53 | - 'table_new' => '', |
|
| 54 | - 'nom_connect' => $nom_connect, |
|
| 55 | - ]; |
|
| 56 | - |
|
| 57 | - return $valeurs; |
|
| 20 | + if (!autoriser('detruire')) { |
|
| 21 | + return false; |
|
| 22 | + } |
|
| 23 | + |
|
| 24 | + [$adresse_db, $login_db, $pass_db, $sel, $server_db] = analyse_fichier_connection(_FILE_CONNECT); |
|
| 25 | + |
|
| 26 | + $deja = bases_referencees(_FILE_CONNECT); |
|
| 27 | + // proposer un nom de connect si pas encore saisi |
|
| 28 | + $nom_connect = ''; |
|
| 29 | + if (defined('_DECLARER_CHOIX_DB')) { |
|
| 30 | + $nom_connect = _DECLARER_CHOIX_DB; |
|
| 31 | + $n = ''; |
|
| 32 | + while (in_array($nom_connect . $n, $deja)) { |
|
| 33 | + $n = ($n ? $n + 1 : 1); |
|
| 34 | + } |
|
| 35 | + $nom_connect = $nom_connect . $n; |
|
| 36 | + } |
|
| 37 | + |
|
| 38 | + $valeurs = [ |
|
| 39 | + '_etapes' => 3, |
|
| 40 | + '_bases_deja' => $deja, |
|
| 41 | + '_bases_prop' => defined('_DECLARER_SERVEUR_DB') ? liste_bases(_DECLARER_SERVEUR_DB) : '', |
|
| 42 | + '_tables' => (defined('_DECLARER_SERVEUR_DB') and defined('_DECLARER_CHOIX_DB')) ? |
|
| 43 | + $tables = sql_alltable('%', _DECLARER_SERVEUR_DB) |
|
| 44 | + : |
|
| 45 | + [], |
|
| 46 | + 'main_db' => '', |
|
| 47 | + '_serveurs' => liste_serveurs(), |
|
| 48 | + 'sql_serveur_db' => 'sqlite3', // valeur par defaut |
|
| 49 | + 'adresse_db' => $adresse_db, |
|
| 50 | + 'login_db' => '', |
|
| 51 | + 'pass_db' => '', |
|
| 52 | + 'choix_db' => '', |
|
| 53 | + 'table_new' => '', |
|
| 54 | + 'nom_connect' => $nom_connect, |
|
| 55 | + ]; |
|
| 56 | + |
|
| 57 | + return $valeurs; |
|
| 58 | 58 | } |
| 59 | 59 | |
| 60 | 60 | function liste_serveurs() { |
| 61 | - $options = []; |
|
| 62 | - $dir = _DIR_RESTREINT . 'req/'; |
|
| 63 | - $d = opendir($dir); |
|
| 64 | - if (!$d) { |
|
| 65 | - return []; |
|
| 66 | - } |
|
| 67 | - while ($f = readdir($d)) { |
|
| 68 | - if ( |
|
| 69 | - (preg_match('/^(.*)[.]php$/', $f, $s)) |
|
| 70 | - and is_readable($f = $dir . $f) |
|
| 71 | - ) { |
|
| 72 | - require_once($f); |
|
| 73 | - $s = $s[1]; |
|
| 74 | - $v = 'spip_versions_' . $s; |
|
| 75 | - if (function_exists($v) and $v()) { |
|
| 76 | - $options[$s] = "install_select_type_$s"; |
|
| 77 | - } else { |
|
| 78 | - spip_log("$s: portage indisponible"); |
|
| 79 | - } |
|
| 80 | - } |
|
| 81 | - } |
|
| 82 | - ksort($options); |
|
| 83 | - |
|
| 84 | - return $options; |
|
| 61 | + $options = []; |
|
| 62 | + $dir = _DIR_RESTREINT . 'req/'; |
|
| 63 | + $d = opendir($dir); |
|
| 64 | + if (!$d) { |
|
| 65 | + return []; |
|
| 66 | + } |
|
| 67 | + while ($f = readdir($d)) { |
|
| 68 | + if ( |
|
| 69 | + (preg_match('/^(.*)[.]php$/', $f, $s)) |
|
| 70 | + and is_readable($f = $dir . $f) |
|
| 71 | + ) { |
|
| 72 | + require_once($f); |
|
| 73 | + $s = $s[1]; |
|
| 74 | + $v = 'spip_versions_' . $s; |
|
| 75 | + if (function_exists($v) and $v()) { |
|
| 76 | + $options[$s] = "install_select_type_$s"; |
|
| 77 | + } else { |
|
| 78 | + spip_log("$s: portage indisponible"); |
|
| 79 | + } |
|
| 80 | + } |
|
| 81 | + } |
|
| 82 | + ksort($options); |
|
| 83 | + |
|
| 84 | + return $options; |
|
| 85 | 85 | } |
| 86 | 86 | |
| 87 | 87 | function liste_bases($server_db) { |
| 88 | - if ( |
|
| 89 | - is_null($server_db) |
|
| 90 | - or !$result = sql_listdbs($server_db) |
|
| 91 | - ) { |
|
| 92 | - return ''; |
|
| 93 | - } |
|
| 94 | - |
|
| 95 | - $noms = []; |
|
| 96 | - |
|
| 97 | - // si sqlite : result est deja un tableau |
|
| 98 | - if (is_array($result)) { |
|
| 99 | - $noms = $result; |
|
| 100 | - } else { |
|
| 101 | - while ($row = sql_fetch($result, $server_db)) { |
|
| 102 | - $noms[] = reset($row); |
|
| 103 | - } |
|
| 104 | - } |
|
| 105 | - |
|
| 106 | - return $noms; |
|
| 88 | + if ( |
|
| 89 | + is_null($server_db) |
|
| 90 | + or !$result = sql_listdbs($server_db) |
|
| 91 | + ) { |
|
| 92 | + return ''; |
|
| 93 | + } |
|
| 94 | + |
|
| 95 | + $noms = []; |
|
| 96 | + |
|
| 97 | + // si sqlite : result est deja un tableau |
|
| 98 | + if (is_array($result)) { |
|
| 99 | + $noms = $result; |
|
| 100 | + } else { |
|
| 101 | + while ($row = sql_fetch($result, $server_db)) { |
|
| 102 | + $noms[] = reset($row); |
|
| 103 | + } |
|
| 104 | + } |
|
| 105 | + |
|
| 106 | + return $noms; |
|
| 107 | 107 | } |
| 108 | 108 | |
| 109 | 109 | function formulaires_declarer_bases_verifier_1_dist() { |
| 110 | - $erreurs = []; |
|
| 111 | - [$def_adresse_db, $def_login_db, $def_pass_db, $sel_db, $def_serveur_db] = analyse_fichier_connection(_FILE_CONNECT); |
|
| 112 | - |
|
| 113 | - if (!$adresse_db = _request('adresse_db')) { |
|
| 114 | - if (defined('_INSTALL_HOST_DB')) { |
|
| 115 | - $adresse_db = _INSTALL_HOST_DB; |
|
| 116 | - } else { |
|
| 117 | - $adresse_db = $def_adresse_db; |
|
| 118 | - } |
|
| 119 | - } |
|
| 120 | - if (!$serveur_db = _request('sql_serveur_db')) { |
|
| 121 | - if (defined('_INSTALL_SERVER_DB')) { |
|
| 122 | - $serveur_db = _INSTALL_SERVER_DB; |
|
| 123 | - } else { |
|
| 124 | - $serveur_db = $def_serveur_db; |
|
| 125 | - } |
|
| 126 | - } |
|
| 127 | - |
|
| 128 | - $login_db = $pass_db = ''; |
|
| 129 | - if (!preg_match(',^sqlite,i', $serveur_db)) { |
|
| 130 | - if (!$login_db = _request('login_db')) { |
|
| 131 | - if (defined('_INSTALL_USER_DB')) { |
|
| 132 | - $login_db = _INSTALL_USER_DB; |
|
| 133 | - } else { |
|
| 134 | - $login_db = $def_login_db; |
|
| 135 | - } |
|
| 136 | - } |
|
| 137 | - if (!$pass_db = _request('pass_db')) { |
|
| 138 | - if (defined('_INSTALL_PASS_DB')) { |
|
| 139 | - $pass_db = _INSTALL_PASS_DB; |
|
| 140 | - } else { |
|
| 141 | - $pass_db = $def_pass_db; |
|
| 142 | - } |
|
| 143 | - } |
|
| 144 | - } |
|
| 145 | - |
|
| 146 | - $link = spip_connect_db($adresse_db, '', $login_db, $pass_db, '@test@', $serveur_db); |
|
| 147 | - if ($link) { |
|
| 148 | - $GLOBALS['connexions'][$serveur_db][$GLOBALS['spip_sql_version']] = $GLOBALS['spip_' . $serveur_db . '_functions_' . $GLOBALS['spip_sql_version']]; |
|
| 149 | - $GLOBALS['connexions'][$serveur_db] = $link; |
|
| 150 | - define('_DECLARER_SERVEUR_DB', $serveur_db); |
|
| 151 | - define('_DECLARER_ADRESSE_DB', $adresse_db); |
|
| 152 | - define('_DECLARER_LOGIN_DB', $login_db); |
|
| 153 | - define('_DECLARER_PASS_DB', $pass_db); |
|
| 154 | - // si on est sur le meme serveur que connect.php |
|
| 155 | - // indiquer quelle est la db utilisee pour l'exclure des choix possibles |
|
| 156 | - if ($serveur_db == $def_serveur_db and $adresse_db == $def_adresse_db) { |
|
| 157 | - set_request('main_db', $sel_db); |
|
| 158 | - } else { |
|
| 159 | - set_request('main_db', ''); |
|
| 160 | - } |
|
| 161 | - } else { |
|
| 162 | - $erreurs['message_erreur'] = _T('avis_connexion_echec_1'); |
|
| 163 | - } |
|
| 164 | - |
|
| 165 | - return $erreurs; |
|
| 110 | + $erreurs = []; |
|
| 111 | + [$def_adresse_db, $def_login_db, $def_pass_db, $sel_db, $def_serveur_db] = analyse_fichier_connection(_FILE_CONNECT); |
|
| 112 | + |
|
| 113 | + if (!$adresse_db = _request('adresse_db')) { |
|
| 114 | + if (defined('_INSTALL_HOST_DB')) { |
|
| 115 | + $adresse_db = _INSTALL_HOST_DB; |
|
| 116 | + } else { |
|
| 117 | + $adresse_db = $def_adresse_db; |
|
| 118 | + } |
|
| 119 | + } |
|
| 120 | + if (!$serveur_db = _request('sql_serveur_db')) { |
|
| 121 | + if (defined('_INSTALL_SERVER_DB')) { |
|
| 122 | + $serveur_db = _INSTALL_SERVER_DB; |
|
| 123 | + } else { |
|
| 124 | + $serveur_db = $def_serveur_db; |
|
| 125 | + } |
|
| 126 | + } |
|
| 127 | + |
|
| 128 | + $login_db = $pass_db = ''; |
|
| 129 | + if (!preg_match(',^sqlite,i', $serveur_db)) { |
|
| 130 | + if (!$login_db = _request('login_db')) { |
|
| 131 | + if (defined('_INSTALL_USER_DB')) { |
|
| 132 | + $login_db = _INSTALL_USER_DB; |
|
| 133 | + } else { |
|
| 134 | + $login_db = $def_login_db; |
|
| 135 | + } |
|
| 136 | + } |
|
| 137 | + if (!$pass_db = _request('pass_db')) { |
|
| 138 | + if (defined('_INSTALL_PASS_DB')) { |
|
| 139 | + $pass_db = _INSTALL_PASS_DB; |
|
| 140 | + } else { |
|
| 141 | + $pass_db = $def_pass_db; |
|
| 142 | + } |
|
| 143 | + } |
|
| 144 | + } |
|
| 145 | + |
|
| 146 | + $link = spip_connect_db($adresse_db, '', $login_db, $pass_db, '@test@', $serveur_db); |
|
| 147 | + if ($link) { |
|
| 148 | + $GLOBALS['connexions'][$serveur_db][$GLOBALS['spip_sql_version']] = $GLOBALS['spip_' . $serveur_db . '_functions_' . $GLOBALS['spip_sql_version']]; |
|
| 149 | + $GLOBALS['connexions'][$serveur_db] = $link; |
|
| 150 | + define('_DECLARER_SERVEUR_DB', $serveur_db); |
|
| 151 | + define('_DECLARER_ADRESSE_DB', $adresse_db); |
|
| 152 | + define('_DECLARER_LOGIN_DB', $login_db); |
|
| 153 | + define('_DECLARER_PASS_DB', $pass_db); |
|
| 154 | + // si on est sur le meme serveur que connect.php |
|
| 155 | + // indiquer quelle est la db utilisee pour l'exclure des choix possibles |
|
| 156 | + if ($serveur_db == $def_serveur_db and $adresse_db == $def_adresse_db) { |
|
| 157 | + set_request('main_db', $sel_db); |
|
| 158 | + } else { |
|
| 159 | + set_request('main_db', ''); |
|
| 160 | + } |
|
| 161 | + } else { |
|
| 162 | + $erreurs['message_erreur'] = _T('avis_connexion_echec_1'); |
|
| 163 | + } |
|
| 164 | + |
|
| 165 | + return $erreurs; |
|
| 166 | 166 | } |
| 167 | 167 | |
| 168 | 168 | function formulaires_declarer_bases_verifier_2_dist() { |
| 169 | - $erreurs = []; |
|
| 170 | - $choix_db = _request('choix_db'); |
|
| 171 | - if ($choix_db == '-1') { |
|
| 172 | - $choix_db = _request('table_new'); |
|
| 173 | - } |
|
| 174 | - if (!$choix_db) { |
|
| 175 | - $erreurs['choix_db'] = _T('info_obligatoire'); |
|
| 176 | - } else { |
|
| 177 | - define('_ECRIRE_INSTALL', 1); // hackons sqlite |
|
| 178 | - if (!sql_selectdb($choix_db, _DECLARER_SERVEUR_DB)) { |
|
| 179 | - $erreurs['choix_db'] = _T('avis_base_inaccessible', ['base' => $choix_db]); |
|
| 180 | - } else { |
|
| 181 | - define('_DECLARER_CHOIX_DB', $choix_db); |
|
| 182 | - } |
|
| 183 | - } |
|
| 184 | - |
|
| 185 | - return $erreurs; |
|
| 169 | + $erreurs = []; |
|
| 170 | + $choix_db = _request('choix_db'); |
|
| 171 | + if ($choix_db == '-1') { |
|
| 172 | + $choix_db = _request('table_new'); |
|
| 173 | + } |
|
| 174 | + if (!$choix_db) { |
|
| 175 | + $erreurs['choix_db'] = _T('info_obligatoire'); |
|
| 176 | + } else { |
|
| 177 | + define('_ECRIRE_INSTALL', 1); // hackons sqlite |
|
| 178 | + if (!sql_selectdb($choix_db, _DECLARER_SERVEUR_DB)) { |
|
| 179 | + $erreurs['choix_db'] = _T('avis_base_inaccessible', ['base' => $choix_db]); |
|
| 180 | + } else { |
|
| 181 | + define('_DECLARER_CHOIX_DB', $choix_db); |
|
| 182 | + } |
|
| 183 | + } |
|
| 184 | + |
|
| 185 | + return $erreurs; |
|
| 186 | 186 | } |
| 187 | 187 | |
| 188 | 188 | function formulaires_declarer_bases_verifier_3_dist() { |
| 189 | - $erreurs = []; |
|
| 190 | - $nom_connect = _request('nom_connect'); |
|
| 191 | - if (!$nom_connect) { |
|
| 192 | - $erreurs['nom_connect'] = _T('info_obligatoire'); |
|
| 193 | - } else { |
|
| 194 | - // securite : le nom doit etre un mot sans caracteres speciaux |
|
| 195 | - $f = preg_replace(',[^\w],', '', $nom_connect); |
|
| 196 | - if ($f !== $nom_connect) { |
|
| 197 | - $erreurs['nom_connect'] = _T('erreur_nom_connect_incorrect'); |
|
| 198 | - } elseif (file_exists(_DIR_CONNECT . $nom_connect . '.php')) { |
|
| 199 | - $erreurs['nom_connect'] = _T('erreur_connect_deja_existant'); |
|
| 200 | - } else { |
|
| 201 | - define('_DECLARER_NOM_CONNECT', $nom_connect); |
|
| 202 | - } |
|
| 203 | - } |
|
| 204 | - |
|
| 205 | - return $erreurs; |
|
| 189 | + $erreurs = []; |
|
| 190 | + $nom_connect = _request('nom_connect'); |
|
| 191 | + if (!$nom_connect) { |
|
| 192 | + $erreurs['nom_connect'] = _T('info_obligatoire'); |
|
| 193 | + } else { |
|
| 194 | + // securite : le nom doit etre un mot sans caracteres speciaux |
|
| 195 | + $f = preg_replace(',[^\w],', '', $nom_connect); |
|
| 196 | + if ($f !== $nom_connect) { |
|
| 197 | + $erreurs['nom_connect'] = _T('erreur_nom_connect_incorrect'); |
|
| 198 | + } elseif (file_exists(_DIR_CONNECT . $nom_connect . '.php')) { |
|
| 199 | + $erreurs['nom_connect'] = _T('erreur_connect_deja_existant'); |
|
| 200 | + } else { |
|
| 201 | + define('_DECLARER_NOM_CONNECT', $nom_connect); |
|
| 202 | + } |
|
| 203 | + } |
|
| 204 | + |
|
| 205 | + return $erreurs; |
|
| 206 | 206 | } |
| 207 | 207 | |
| 208 | 208 | function formulaires_declarer_bases_traiter_dist() { |
| 209 | 209 | |
| 210 | - $adresse_db = _DECLARER_ADRESSE_DB; |
|
| 211 | - if (preg_match(',(.*):(.*),', $adresse_db, $r)) { |
|
| 212 | - [, $adresse_db, $port] = $r; |
|
| 213 | - } else { |
|
| 214 | - $port = ''; |
|
| 215 | - } |
|
| 216 | - |
|
| 217 | - $server_db = addcslashes(_DECLARER_SERVEUR_DB, "'\\"); |
|
| 218 | - |
|
| 219 | - $conn = install_mode_appel($server_db) |
|
| 220 | - . install_connexion( |
|
| 221 | - $adresse_db, |
|
| 222 | - $port, |
|
| 223 | - _DECLARER_LOGIN_DB, |
|
| 224 | - _DECLARER_PASS_DB, |
|
| 225 | - _DECLARER_CHOIX_DB, |
|
| 226 | - _DECLARER_SERVEUR_DB, |
|
| 227 | - '', |
|
| 228 | - '', |
|
| 229 | - '' |
|
| 230 | - ); |
|
| 231 | - |
|
| 232 | - install_fichier_connexion(_DIR_CONNECT . _DECLARER_NOM_CONNECT . '.php', $conn); |
|
| 233 | - |
|
| 234 | - return [ |
|
| 235 | - 'message_ok' => _T('install_connect_ok', ['connect' => '<strong>' . _DECLARER_NOM_CONNECT . '</strong>']) |
|
| 236 | - ]; |
|
| 210 | + $adresse_db = _DECLARER_ADRESSE_DB; |
|
| 211 | + if (preg_match(',(.*):(.*),', $adresse_db, $r)) { |
|
| 212 | + [, $adresse_db, $port] = $r; |
|
| 213 | + } else { |
|
| 214 | + $port = ''; |
|
| 215 | + } |
|
| 216 | + |
|
| 217 | + $server_db = addcslashes(_DECLARER_SERVEUR_DB, "'\\"); |
|
| 218 | + |
|
| 219 | + $conn = install_mode_appel($server_db) |
|
| 220 | + . install_connexion( |
|
| 221 | + $adresse_db, |
|
| 222 | + $port, |
|
| 223 | + _DECLARER_LOGIN_DB, |
|
| 224 | + _DECLARER_PASS_DB, |
|
| 225 | + _DECLARER_CHOIX_DB, |
|
| 226 | + _DECLARER_SERVEUR_DB, |
|
| 227 | + '', |
|
| 228 | + '', |
|
| 229 | + '' |
|
| 230 | + ); |
|
| 231 | + |
|
| 232 | + install_fichier_connexion(_DIR_CONNECT . _DECLARER_NOM_CONNECT . '.php', $conn); |
|
| 233 | + |
|
| 234 | + return [ |
|
| 235 | + 'message_ok' => _T('install_connect_ok', ['connect' => '<strong>' . _DECLARER_NOM_CONNECT . '</strong>']) |
|
| 236 | + ]; |
|
| 237 | 237 | } |
@@ -40,7 +40,7 @@ discard block |
||
| 40 | 40 | // un checkbox seul de name X non coche n'est pas poste. |
| 41 | 41 | // on verifie le champ X_check qui indique que la checkbox etait presente dans le formulaire. |
| 42 | 42 | foreach (['multi_secteurs'] as $m) { |
| 43 | - if (!is_null(_request($m . '_check'))) { |
|
| 43 | + if (!is_null(_request($m.'_check'))) { |
|
| 44 | 44 | ecrire_meta($m, _request($m) ? 'oui' : 'non'); |
| 45 | 45 | } |
| 46 | 46 | } |
@@ -113,12 +113,12 @@ discard block |
||
| 113 | 113 | . "'>" |
| 114 | 114 | . "<input type='hidden' name='{$name}[]' value='$code_langue'>" // necessaire ... |
| 115 | 115 | . "<input type='checkbox' name='{$name}[]' id='{$name}_$code_langue' value='$code_langue' checked='checked' disabled='disabled' />" |
| 116 | - . "<label for='{$name}_$code_langue'>" . $nom_langue . " <span class='code_langue'>[$code_langue]</span></label>" |
|
| 116 | + . "<label for='{$name}_$code_langue'>".$nom_langue." <span class='code_langue'>[$code_langue]</span></label>" |
|
| 117 | 117 | . '</li>'; |
| 118 | 118 | } |
| 119 | 119 | |
| 120 | 120 | if ($res) { |
| 121 | - $res = "<ul id='langues_bloquees'>" . $res . "</ul><div class='nettoyeur'></div>"; |
|
| 121 | + $res = "<ul id='langues_bloquees'>".$res."</ul><div class='nettoyeur'></div>"; |
|
| 122 | 122 | } |
| 123 | 123 | |
| 124 | 124 | $res .= "<ul id='langues_proposees'>"; |
@@ -138,7 +138,7 @@ discard block |
||
| 138 | 138 | . "<label for='{$name}_$code_langue'" |
| 139 | 139 | . ($checked ? " class='on'" : '') |
| 140 | 140 | . '>' |
| 141 | - . $nom_langue . " <span class='code_langue'>[$code_langue]</span></label>" |
|
| 141 | + . $nom_langue." <span class='code_langue'>[$code_langue]</span></label>" |
|
| 142 | 142 | . '</li>'; |
| 143 | 143 | } |
| 144 | 144 | } |
@@ -11,53 +11,53 @@ discard block |
||
| 11 | 11 | \***************************************************************************/ |
| 12 | 12 | |
| 13 | 13 | if (!defined('_ECRIRE_INC_VERSION')) { |
| 14 | - return; |
|
| 14 | + return; |
|
| 15 | 15 | } |
| 16 | 16 | |
| 17 | 17 | function formulaires_configurer_multilinguisme_charger_dist() { |
| 18 | - $valeurs = []; |
|
| 19 | - $valeurs['multi_secteurs'] = $GLOBALS['meta']['multi_secteurs']; |
|
| 20 | - foreach (['multi_objets', 'gerer_trad_objets'] as $m) { |
|
| 21 | - $valeurs[$m] = explode(',', $GLOBALS['meta'][$m] ?? ''); |
|
| 22 | - } |
|
| 23 | - |
|
| 24 | - if ( |
|
| 25 | - is_countable($valeurs['multi_objets']) ? count($valeurs['multi_objets']) : 0 |
|
| 26 | - or count(explode(',', $GLOBALS['meta']['langues_utilisees'])) > 1 |
|
| 27 | - ) { |
|
| 28 | - $selection = (is_null(_request('multi_objets')) ? |
|
| 29 | - explode(',', $GLOBALS['meta']['langues_multilingue']) : _request('langues_auth')); |
|
| 30 | - $valeurs['_langues'] = saisie_langues_utiles('langues_auth', $selection ?: []); |
|
| 31 | - $valeurs['_nb_langues_selection'] = is_countable($selection) ? count($selection) : 0; |
|
| 32 | - } |
|
| 33 | - |
|
| 34 | - return $valeurs; |
|
| 18 | + $valeurs = []; |
|
| 19 | + $valeurs['multi_secteurs'] = $GLOBALS['meta']['multi_secteurs']; |
|
| 20 | + foreach (['multi_objets', 'gerer_trad_objets'] as $m) { |
|
| 21 | + $valeurs[$m] = explode(',', $GLOBALS['meta'][$m] ?? ''); |
|
| 22 | + } |
|
| 23 | + |
|
| 24 | + if ( |
|
| 25 | + is_countable($valeurs['multi_objets']) ? count($valeurs['multi_objets']) : 0 |
|
| 26 | + or count(explode(',', $GLOBALS['meta']['langues_utilisees'])) > 1 |
|
| 27 | + ) { |
|
| 28 | + $selection = (is_null(_request('multi_objets')) ? |
|
| 29 | + explode(',', $GLOBALS['meta']['langues_multilingue']) : _request('langues_auth')); |
|
| 30 | + $valeurs['_langues'] = saisie_langues_utiles('langues_auth', $selection ?: []); |
|
| 31 | + $valeurs['_nb_langues_selection'] = is_countable($selection) ? count($selection) : 0; |
|
| 32 | + } |
|
| 33 | + |
|
| 34 | + return $valeurs; |
|
| 35 | 35 | } |
| 36 | 36 | |
| 37 | 37 | |
| 38 | 38 | function formulaires_configurer_multilinguisme_traiter_dist() { |
| 39 | - $res = ['editable' => true]; |
|
| 40 | - // un checkbox seul de name X non coche n'est pas poste. |
|
| 41 | - // on verifie le champ X_check qui indique que la checkbox etait presente dans le formulaire. |
|
| 42 | - foreach (['multi_secteurs'] as $m) { |
|
| 43 | - if (!is_null(_request($m . '_check'))) { |
|
| 44 | - ecrire_meta($m, _request($m) ? 'oui' : 'non'); |
|
| 45 | - } |
|
| 46 | - } |
|
| 47 | - foreach (['multi_objets', 'gerer_trad_objets'] as $m) { |
|
| 48 | - if (!is_null($v = _request($m))) { |
|
| 49 | - // join et enlever la valeur vide '' |
|
| 50 | - ecrire_meta($m, implode(',', array_diff($v, ['']))); |
|
| 51 | - } |
|
| 52 | - } |
|
| 53 | - |
|
| 54 | - if ($i = _request('langues_auth') and is_array($i)) { |
|
| 55 | - $i = array_unique(array_merge($i, explode(',', $GLOBALS['meta']['langues_utilisees']))); |
|
| 56 | - ecrire_meta('langues_multilingue', implode(',', $i)); |
|
| 57 | - } |
|
| 58 | - $res['message_ok'] = _T('config_info_enregistree'); |
|
| 59 | - |
|
| 60 | - return $res; |
|
| 39 | + $res = ['editable' => true]; |
|
| 40 | + // un checkbox seul de name X non coche n'est pas poste. |
|
| 41 | + // on verifie le champ X_check qui indique que la checkbox etait presente dans le formulaire. |
|
| 42 | + foreach (['multi_secteurs'] as $m) { |
|
| 43 | + if (!is_null(_request($m . '_check'))) { |
|
| 44 | + ecrire_meta($m, _request($m) ? 'oui' : 'non'); |
|
| 45 | + } |
|
| 46 | + } |
|
| 47 | + foreach (['multi_objets', 'gerer_trad_objets'] as $m) { |
|
| 48 | + if (!is_null($v = _request($m))) { |
|
| 49 | + // join et enlever la valeur vide '' |
|
| 50 | + ecrire_meta($m, implode(',', array_diff($v, ['']))); |
|
| 51 | + } |
|
| 52 | + } |
|
| 53 | + |
|
| 54 | + if ($i = _request('langues_auth') and is_array($i)) { |
|
| 55 | + $i = array_unique(array_merge($i, explode(',', $GLOBALS['meta']['langues_utilisees']))); |
|
| 56 | + ecrire_meta('langues_multilingue', implode(',', $i)); |
|
| 57 | + } |
|
| 58 | + $res['message_ok'] = _T('config_info_enregistree'); |
|
| 59 | + |
|
| 60 | + return $res; |
|
| 61 | 61 | } |
| 62 | 62 | |
| 63 | 63 | /** |
@@ -67,13 +67,13 @@ discard block |
||
| 67 | 67 | * @return string |
| 68 | 68 | */ |
| 69 | 69 | function table_supporte_lang($table_sql) { |
| 70 | - $trouver_table = charger_fonction('trouver_table', 'base'); |
|
| 71 | - $desc = $trouver_table($table_sql); |
|
| 72 | - if (!$desc or !isset($desc['field']['lang'])) { |
|
| 73 | - return ''; |
|
| 74 | - } |
|
| 70 | + $trouver_table = charger_fonction('trouver_table', 'base'); |
|
| 71 | + $desc = $trouver_table($table_sql); |
|
| 72 | + if (!$desc or !isset($desc['field']['lang'])) { |
|
| 73 | + return ''; |
|
| 74 | + } |
|
| 75 | 75 | |
| 76 | - return ' '; |
|
| 76 | + return ' '; |
|
| 77 | 77 | } |
| 78 | 78 | |
| 79 | 79 | /** |
@@ -83,67 +83,67 @@ discard block |
||
| 83 | 83 | * @return string |
| 84 | 84 | */ |
| 85 | 85 | function table_supporte_trad($table_sql) { |
| 86 | - $trouver_table = charger_fonction('trouver_table', 'base'); |
|
| 87 | - $desc = $trouver_table($table_sql); |
|
| 88 | - if (!$desc or !isset($desc['field']['id_trad'])) { |
|
| 89 | - return ''; |
|
| 90 | - } |
|
| 86 | + $trouver_table = charger_fonction('trouver_table', 'base'); |
|
| 87 | + $desc = $trouver_table($table_sql); |
|
| 88 | + if (!$desc or !isset($desc['field']['id_trad'])) { |
|
| 89 | + return ''; |
|
| 90 | + } |
|
| 91 | 91 | |
| 92 | - return ' '; |
|
| 92 | + return ' '; |
|
| 93 | 93 | } |
| 94 | 94 | |
| 95 | 95 | |
| 96 | 96 | function saisie_langues_utiles($name, $selection) { |
| 97 | - include_spip('inc/lang_liste'); |
|
| 98 | - $langues = $GLOBALS['codes_langues']; |
|
| 99 | - |
|
| 100 | - $langues_installees = explode(',', $GLOBALS['meta']['langues_proposees']); |
|
| 101 | - $langues_trad = array_flip($langues_installees); |
|
| 102 | - |
|
| 103 | - $langues_bloquees = explode(',', $GLOBALS['meta']['langues_utilisees']); |
|
| 104 | - |
|
| 105 | - $res = ''; |
|
| 106 | - |
|
| 107 | - $i = 0; |
|
| 108 | - foreach ($langues_bloquees as $code_langue) { |
|
| 109 | - $nom_langue = $langues[$code_langue]; |
|
| 110 | - $res .= "<li class='choix " |
|
| 111 | - . alterner(++$i, 'odd', 'even') |
|
| 112 | - . (isset($langues_trad[$code_langue]) ? ' traduite' : '') |
|
| 113 | - . "'>" |
|
| 114 | - . "<input type='hidden' name='{$name}[]' value='$code_langue'>" // necessaire ... |
|
| 115 | - . "<input type='checkbox' name='{$name}[]' id='{$name}_$code_langue' value='$code_langue' checked='checked' disabled='disabled' />" |
|
| 116 | - . "<label for='{$name}_$code_langue'>" . $nom_langue . " <span class='code_langue'>[$code_langue]</span></label>" |
|
| 117 | - . '</li>'; |
|
| 118 | - } |
|
| 119 | - |
|
| 120 | - if ($res) { |
|
| 121 | - $res = "<ul id='langues_bloquees'>" . $res . "</ul><div class='nettoyeur'></div>"; |
|
| 122 | - } |
|
| 123 | - |
|
| 124 | - $res .= "<ul id='langues_proposees'>"; |
|
| 125 | - |
|
| 126 | - $i = 0; |
|
| 127 | - $langues_bloquees = array_flip($langues_bloquees); |
|
| 128 | - foreach ($langues as $code_langue => $nom_langue) { |
|
| 129 | - if (!isset($langues_bloquees[$code_langue])) { |
|
| 130 | - $checked = (in_array($code_langue, $selection) ? ' checked="checked"' : ''); |
|
| 131 | - $res .= "<li class='choix " |
|
| 132 | - . alterner(++$i, 'odd', 'even') |
|
| 133 | - . (isset($langues_trad[$code_langue]) ? ' traduite' : '') |
|
| 134 | - . "'>" |
|
| 135 | - . "<input type='checkbox' name='{$name}[]' id='{$name}_$code_langue' value='$code_langue'" |
|
| 136 | - . $checked |
|
| 137 | - . '/>' |
|
| 138 | - . "<label for='{$name}_$code_langue'" |
|
| 139 | - . ($checked ? " class='on'" : '') |
|
| 140 | - . '>' |
|
| 141 | - . $nom_langue . " <span class='code_langue'>[$code_langue]</span></label>" |
|
| 142 | - . '</li>'; |
|
| 143 | - } |
|
| 144 | - } |
|
| 145 | - |
|
| 146 | - $res .= "</ul><div class='nettoyeur'></div>"; |
|
| 147 | - |
|
| 148 | - return $res; |
|
| 97 | + include_spip('inc/lang_liste'); |
|
| 98 | + $langues = $GLOBALS['codes_langues']; |
|
| 99 | + |
|
| 100 | + $langues_installees = explode(',', $GLOBALS['meta']['langues_proposees']); |
|
| 101 | + $langues_trad = array_flip($langues_installees); |
|
| 102 | + |
|
| 103 | + $langues_bloquees = explode(',', $GLOBALS['meta']['langues_utilisees']); |
|
| 104 | + |
|
| 105 | + $res = ''; |
|
| 106 | + |
|
| 107 | + $i = 0; |
|
| 108 | + foreach ($langues_bloquees as $code_langue) { |
|
| 109 | + $nom_langue = $langues[$code_langue]; |
|
| 110 | + $res .= "<li class='choix " |
|
| 111 | + . alterner(++$i, 'odd', 'even') |
|
| 112 | + . (isset($langues_trad[$code_langue]) ? ' traduite' : '') |
|
| 113 | + . "'>" |
|
| 114 | + . "<input type='hidden' name='{$name}[]' value='$code_langue'>" // necessaire ... |
|
| 115 | + . "<input type='checkbox' name='{$name}[]' id='{$name}_$code_langue' value='$code_langue' checked='checked' disabled='disabled' />" |
|
| 116 | + . "<label for='{$name}_$code_langue'>" . $nom_langue . " <span class='code_langue'>[$code_langue]</span></label>" |
|
| 117 | + . '</li>'; |
|
| 118 | + } |
|
| 119 | + |
|
| 120 | + if ($res) { |
|
| 121 | + $res = "<ul id='langues_bloquees'>" . $res . "</ul><div class='nettoyeur'></div>"; |
|
| 122 | + } |
|
| 123 | + |
|
| 124 | + $res .= "<ul id='langues_proposees'>"; |
|
| 125 | + |
|
| 126 | + $i = 0; |
|
| 127 | + $langues_bloquees = array_flip($langues_bloquees); |
|
| 128 | + foreach ($langues as $code_langue => $nom_langue) { |
|
| 129 | + if (!isset($langues_bloquees[$code_langue])) { |
|
| 130 | + $checked = (in_array($code_langue, $selection) ? ' checked="checked"' : ''); |
|
| 131 | + $res .= "<li class='choix " |
|
| 132 | + . alterner(++$i, 'odd', 'even') |
|
| 133 | + . (isset($langues_trad[$code_langue]) ? ' traduite' : '') |
|
| 134 | + . "'>" |
|
| 135 | + . "<input type='checkbox' name='{$name}[]' id='{$name}_$code_langue' value='$code_langue'" |
|
| 136 | + . $checked |
|
| 137 | + . '/>' |
|
| 138 | + . "<label for='{$name}_$code_langue'" |
|
| 139 | + . ($checked ? " class='on'" : '') |
|
| 140 | + . '>' |
|
| 141 | + . $nom_langue . " <span class='code_langue'>[$code_langue]</span></label>" |
|
| 142 | + . '</li>'; |
|
| 143 | + } |
|
| 144 | + } |
|
| 145 | + |
|
| 146 | + $res .= "</ul><div class='nettoyeur'></div>"; |
|
| 147 | + |
|
| 148 | + return $res; |
|
| 149 | 149 | } |
@@ -62,5 +62,5 @@ |
||
| 62 | 62 | $reload = texte_script(couper(_request('nom_site'), 35)); |
| 63 | 63 | $reload = "<script type='text/javascript'>if (window.jQuery) jQuery('#bando_identite .nom_site_spip .nom').html('$reload');</script>"; |
| 64 | 64 | |
| 65 | - return ['message_ok' => _T('config_info_enregistree') . $reload, 'editable' => true]; |
|
| 65 | + return ['message_ok' => _T('config_info_enregistree').$reload, 'editable' => true]; |
|
| 66 | 66 | } |
@@ -11,56 +11,56 @@ |
||
| 11 | 11 | \***************************************************************************/ |
| 12 | 12 | |
| 13 | 13 | if (!defined('_ECRIRE_INC_VERSION')) { |
| 14 | - return; |
|
| 14 | + return; |
|
| 15 | 15 | } |
| 16 | 16 | |
| 17 | 17 | function formulaires_configurer_identite_charger_dist() { |
| 18 | - // travailler sur des meta fraiches |
|
| 19 | - include_spip('inc/meta'); |
|
| 20 | - lire_metas(); |
|
| 18 | + // travailler sur des meta fraiches |
|
| 19 | + include_spip('inc/meta'); |
|
| 20 | + lire_metas(); |
|
| 21 | 21 | |
| 22 | - $valeurs = []; |
|
| 23 | - foreach (['nom_site', 'adresse_site', 'slogan_site', 'descriptif_site', 'email_webmaster'] as $k) { |
|
| 24 | - $valeurs[$k] = $GLOBALS['meta'][$k] ?? ''; |
|
| 25 | - } |
|
| 22 | + $valeurs = []; |
|
| 23 | + foreach (['nom_site', 'adresse_site', 'slogan_site', 'descriptif_site', 'email_webmaster'] as $k) { |
|
| 24 | + $valeurs[$k] = $GLOBALS['meta'][$k] ?? ''; |
|
| 25 | + } |
|
| 26 | 26 | |
| 27 | - return $valeurs; |
|
| 27 | + return $valeurs; |
|
| 28 | 28 | } |
| 29 | 29 | |
| 30 | 30 | function formulaires_configurer_identite_verifier_dist() { |
| 31 | - $erreurs = []; |
|
| 31 | + $erreurs = []; |
|
| 32 | 32 | |
| 33 | - // adresse_site est obligatoire mais rempli automatiquement si absent ! |
|
| 34 | - foreach (['nom_site'/*,'adresse_site'*/] as $obli) { |
|
| 35 | - if (!_request($obli)) { |
|
| 36 | - $erreurs[$obli] = _T('info_obligatoire'); |
|
| 37 | - } |
|
| 38 | - } |
|
| 33 | + // adresse_site est obligatoire mais rempli automatiquement si absent ! |
|
| 34 | + foreach (['nom_site'/*,'adresse_site'*/] as $obli) { |
|
| 35 | + if (!_request($obli)) { |
|
| 36 | + $erreurs[$obli] = _T('info_obligatoire'); |
|
| 37 | + } |
|
| 38 | + } |
|
| 39 | 39 | |
| 40 | - if ($email = _request('email_webmaster') and !email_valide($email)) { |
|
| 41 | - $erreurs['email_webmaster'] = _T('info_email_invalide'); |
|
| 42 | - } |
|
| 40 | + if ($email = _request('email_webmaster') and !email_valide($email)) { |
|
| 41 | + $erreurs['email_webmaster'] = _T('info_email_invalide'); |
|
| 42 | + } |
|
| 43 | 43 | |
| 44 | - return $erreurs; |
|
| 44 | + return $erreurs; |
|
| 45 | 45 | } |
| 46 | 46 | |
| 47 | 47 | function formulaires_configurer_identite_traiter_dist() { |
| 48 | - include_spip('inc/config'); |
|
| 49 | - $adresse_site = $GLOBALS['meta']['adresse_site'] ?? ''; |
|
| 50 | - if (_request('adresse_site') != $adresse_site) { |
|
| 51 | - refuser_traiter_formulaire_ajax(); |
|
| 52 | - } |
|
| 48 | + include_spip('inc/config'); |
|
| 49 | + $adresse_site = $GLOBALS['meta']['adresse_site'] ?? ''; |
|
| 50 | + if (_request('adresse_site') != $adresse_site) { |
|
| 51 | + refuser_traiter_formulaire_ajax(); |
|
| 52 | + } |
|
| 53 | 53 | |
| 54 | - set_request('adresse_site', appliquer_adresse_site(_request('adresse_site'))); |
|
| 54 | + set_request('adresse_site', appliquer_adresse_site(_request('adresse_site'))); |
|
| 55 | 55 | |
| 56 | - include_spip('inc/meta'); |
|
| 57 | - foreach (['nom_site', 'slogan_site', 'descriptif_site', 'email_webmaster'] as $k) { |
|
| 58 | - ecrire_meta($k, _request($k)); |
|
| 59 | - } |
|
| 56 | + include_spip('inc/meta'); |
|
| 57 | + foreach (['nom_site', 'slogan_site', 'descriptif_site', 'email_webmaster'] as $k) { |
|
| 58 | + ecrire_meta($k, _request($k)); |
|
| 59 | + } |
|
| 60 | 60 | |
| 61 | - include_spip('inc/texte_mini'); |
|
| 62 | - $reload = texte_script(couper(_request('nom_site'), 35)); |
|
| 63 | - $reload = "<script type='text/javascript'>if (window.jQuery) jQuery('#bando_identite .nom_site_spip .nom').html('$reload');</script>"; |
|
| 61 | + include_spip('inc/texte_mini'); |
|
| 62 | + $reload = texte_script(couper(_request('nom_site'), 35)); |
|
| 63 | + $reload = "<script type='text/javascript'>if (window.jQuery) jQuery('#bando_identite .nom_site_spip .nom').html('$reload');</script>"; |
|
| 64 | 64 | |
| 65 | - return ['message_ok' => _T('config_info_enregistree') . $reload, 'editable' => true]; |
|
| 65 | + return ['message_ok' => _T('config_info_enregistree') . $reload, 'editable' => true]; |
|
| 66 | 66 | } |
@@ -7,7 +7,7 @@ discard block |
||
| 7 | 7 | **/ |
| 8 | 8 | |
| 9 | 9 | if (!defined('_ECRIRE_INC_VERSION')) { |
| 10 | - return; |
|
| 10 | + return; |
|
| 11 | 11 | } |
| 12 | 12 | |
| 13 | 13 | /** |
@@ -24,32 +24,32 @@ discard block |
||
| 24 | 24 | * Code HTML et javascript |
| 25 | 25 | */ |
| 26 | 26 | function choisir_rubriques_admin_restreint( |
| 27 | - $id_auteur, |
|
| 28 | - $label = '', |
|
| 29 | - $sel_css = '#liste_rubriques_restreintes', |
|
| 30 | - $img_remove = '' |
|
| 27 | + $id_auteur, |
|
| 28 | + $label = '', |
|
| 29 | + $sel_css = '#liste_rubriques_restreintes', |
|
| 30 | + $img_remove = '' |
|
| 31 | 31 | ) { |
| 32 | - global $spip_lang; |
|
| 33 | - $res = ''; |
|
| 34 | - // Ajouter une rubrique a un administrateur restreint |
|
| 35 | - if ( |
|
| 36 | - $chercher_rubrique = charger_fonction('chercher_rubrique', 'inc') |
|
| 37 | - and $a = $chercher_rubrique(0, 'auteur', false) |
|
| 38 | - ) { |
|
| 39 | - if ($img_remove) { |
|
| 40 | - $img_remove = addslashes("<a href=\"#\" onclick=\"jQuery(this).parent().remove();return false;\" class=\"removelink\">$img_remove</a>"); |
|
| 41 | - } |
|
| 32 | + global $spip_lang; |
|
| 33 | + $res = ''; |
|
| 34 | + // Ajouter une rubrique a un administrateur restreint |
|
| 35 | + if ( |
|
| 36 | + $chercher_rubrique = charger_fonction('chercher_rubrique', 'inc') |
|
| 37 | + and $a = $chercher_rubrique(0, 'auteur', false) |
|
| 38 | + ) { |
|
| 39 | + if ($img_remove) { |
|
| 40 | + $img_remove = addslashes("<a href=\"#\" onclick=\"jQuery(this).parent().remove();return false;\" class=\"removelink\">$img_remove</a>"); |
|
| 41 | + } |
|
| 42 | 42 | |
| 43 | - $res = |
|
| 44 | - "\n<div id='ajax_rubrique'>\n" |
|
| 45 | - . "<label>$label</label>\n" |
|
| 46 | - . "<input name='id_auteur' value='$id_auteur' type='hidden' />\n" |
|
| 47 | - . $a |
|
| 48 | - . "</div>\n" |
|
| 43 | + $res = |
|
| 44 | + "\n<div id='ajax_rubrique'>\n" |
|
| 45 | + . "<label>$label</label>\n" |
|
| 46 | + . "<input name='id_auteur' value='$id_auteur' type='hidden' />\n" |
|
| 47 | + . $a |
|
| 48 | + . "</div>\n" |
|
| 49 | 49 | |
| 50 | - // onchange = pour le menu |
|
| 51 | - // l'evenement doit etre provoque a la main par le selecteur ajax |
|
| 52 | - . "<script type='text/javascript'>/*<![CDATA[*/ |
|
| 50 | + // onchange = pour le menu |
|
| 51 | + // l'evenement doit etre provoque a la main par le selecteur ajax |
|
| 52 | + . "<script type='text/javascript'>/*<![CDATA[*/ |
|
| 53 | 53 | jQuery(function($){ |
| 54 | 54 | $('#id_parent').on('change', function(){ |
| 55 | 55 | var id_parent = parseInt(this.value); |
@@ -68,7 +68,7 @@ discard block |
||
| 68 | 68 | .attr('name','noname'); |
| 69 | 69 | }); |
| 70 | 70 | /*]]>*/</script>"; |
| 71 | - } |
|
| 71 | + } |
|
| 72 | 72 | |
| 73 | - return $res; |
|
| 73 | + return $res; |
|
| 74 | 74 | } |
@@ -17,7 +17,7 @@ discard block |
||
| 17 | 17 | **/ |
| 18 | 18 | |
| 19 | 19 | if (!defined('_ECRIRE_INC_VERSION')) { |
| 20 | - return; |
|
| 20 | + return; |
|
| 21 | 21 | } |
| 22 | 22 | |
| 23 | 23 | include_spip('inc/actions'); |
@@ -39,65 +39,65 @@ discard block |
||
| 39 | 39 | * Contexte à transmettre au squelette du formulaire sinon |
| 40 | 40 | */ |
| 41 | 41 | function formulaires_traduire_charger_dist($objet, $id_objet, $retour = '', $traduire = true) { |
| 42 | - if (!intval($id_objet)) { |
|
| 43 | - return false; |
|
| 44 | - } |
|
| 45 | - $valeurs = formulaires_editer_objet_charger($objet, $id_objet, null, 0, $retour, ''); |
|
| 46 | - // verifier que l'objet indique possede bien des champs id_trad et lang |
|
| 47 | - // attention, charger renomme lang => langue pour ne pas perturber la langue d'affichage du squelette |
|
| 48 | - if (!isset($valeurs['langue'])) { |
|
| 49 | - return false; |
|
| 50 | - } |
|
| 51 | - |
|
| 52 | - $valeurs['editable'] = autoriser('changerlangue', $objet, $id_objet); |
|
| 53 | - $valeurs['_langue'] = ''; |
|
| 54 | - $langue_parent = ''; |
|
| 55 | - $id_parent = ''; |
|
| 56 | - if (isset($valeurs['id_rubrique'])) { |
|
| 57 | - $id_parent = $valeurs['id_rubrique']; |
|
| 58 | - } |
|
| 59 | - if (isset($valeurs['id_parent'])) { |
|
| 60 | - $id_parent = $valeurs['id_parent']; |
|
| 61 | - } |
|
| 62 | - if ($id_parent) { |
|
| 63 | - $langue_parent = sql_getfetsel('lang', 'spip_rubriques', 'id_rubrique=' . intval($id_parent)); |
|
| 64 | - } |
|
| 65 | - |
|
| 66 | - if (!$langue_parent) { |
|
| 67 | - $langue_parent = $GLOBALS['meta']['langue_site']; |
|
| 68 | - } |
|
| 69 | - if ( |
|
| 70 | - $valeurs['editable'] |
|
| 71 | - and in_array(table_objet_sql($objet), explode(',', $GLOBALS['meta']['multi_objets'])) |
|
| 72 | - ) { |
|
| 73 | - $valeurs['_langue'] = $valeurs['langue']; |
|
| 74 | - } |
|
| 75 | - $valeurs['langue_parent'] = $langue_parent; |
|
| 76 | - |
|
| 77 | - $valeurs['_objet'] = $objet; |
|
| 78 | - $valeurs['_id_objet'] = $id_objet; |
|
| 79 | - $valeurs['changer_lang'] = ''; |
|
| 80 | - |
|
| 81 | - |
|
| 82 | - $valeurs['_traduisible'] = autoriser('changertraduction', $objet, $id_objet); |
|
| 83 | - $valeurs['_traduire'] = ''; |
|
| 84 | - if (isset($valeurs['id_trad'])) { |
|
| 85 | - $valeurs['_traduire'] = ($traduire ? ' ' : ''); |
|
| 86 | - $valeurs['_vue_traductions'] = 'prive/objets/liste/' . (trouver_fond( |
|
| 87 | - $f = table_objet($objet) . '-trad', |
|
| 88 | - 'prive/objets/liste' |
|
| 89 | - ) ? $f : 'objets-trad'); |
|
| 90 | - // pour afficher la liste des trad sur la base de l'id_trad en base |
|
| 91 | - // independamment d'une saisie en cours sur id_trad |
|
| 92 | - $valeurs['_lister_id_trad'] = $valeurs['id_trad']; |
|
| 93 | - $valeurs['_id_parent'] = $id_parent; |
|
| 94 | - } |
|
| 95 | - |
|
| 96 | - $valeurs['_saisie_en_cours'] = (!_request('annuler') and (_request('changer_lang') !== null |
|
| 97 | - or _request('changer_id_trad') !== null)); |
|
| 98 | - $valeurs['_pipeline'] = ['traduire', ['type' => $objet, 'id' => $id_objet]]; |
|
| 99 | - |
|
| 100 | - return $valeurs; |
|
| 42 | + if (!intval($id_objet)) { |
|
| 43 | + return false; |
|
| 44 | + } |
|
| 45 | + $valeurs = formulaires_editer_objet_charger($objet, $id_objet, null, 0, $retour, ''); |
|
| 46 | + // verifier que l'objet indique possede bien des champs id_trad et lang |
|
| 47 | + // attention, charger renomme lang => langue pour ne pas perturber la langue d'affichage du squelette |
|
| 48 | + if (!isset($valeurs['langue'])) { |
|
| 49 | + return false; |
|
| 50 | + } |
|
| 51 | + |
|
| 52 | + $valeurs['editable'] = autoriser('changerlangue', $objet, $id_objet); |
|
| 53 | + $valeurs['_langue'] = ''; |
|
| 54 | + $langue_parent = ''; |
|
| 55 | + $id_parent = ''; |
|
| 56 | + if (isset($valeurs['id_rubrique'])) { |
|
| 57 | + $id_parent = $valeurs['id_rubrique']; |
|
| 58 | + } |
|
| 59 | + if (isset($valeurs['id_parent'])) { |
|
| 60 | + $id_parent = $valeurs['id_parent']; |
|
| 61 | + } |
|
| 62 | + if ($id_parent) { |
|
| 63 | + $langue_parent = sql_getfetsel('lang', 'spip_rubriques', 'id_rubrique=' . intval($id_parent)); |
|
| 64 | + } |
|
| 65 | + |
|
| 66 | + if (!$langue_parent) { |
|
| 67 | + $langue_parent = $GLOBALS['meta']['langue_site']; |
|
| 68 | + } |
|
| 69 | + if ( |
|
| 70 | + $valeurs['editable'] |
|
| 71 | + and in_array(table_objet_sql($objet), explode(',', $GLOBALS['meta']['multi_objets'])) |
|
| 72 | + ) { |
|
| 73 | + $valeurs['_langue'] = $valeurs['langue']; |
|
| 74 | + } |
|
| 75 | + $valeurs['langue_parent'] = $langue_parent; |
|
| 76 | + |
|
| 77 | + $valeurs['_objet'] = $objet; |
|
| 78 | + $valeurs['_id_objet'] = $id_objet; |
|
| 79 | + $valeurs['changer_lang'] = ''; |
|
| 80 | + |
|
| 81 | + |
|
| 82 | + $valeurs['_traduisible'] = autoriser('changertraduction', $objet, $id_objet); |
|
| 83 | + $valeurs['_traduire'] = ''; |
|
| 84 | + if (isset($valeurs['id_trad'])) { |
|
| 85 | + $valeurs['_traduire'] = ($traduire ? ' ' : ''); |
|
| 86 | + $valeurs['_vue_traductions'] = 'prive/objets/liste/' . (trouver_fond( |
|
| 87 | + $f = table_objet($objet) . '-trad', |
|
| 88 | + 'prive/objets/liste' |
|
| 89 | + ) ? $f : 'objets-trad'); |
|
| 90 | + // pour afficher la liste des trad sur la base de l'id_trad en base |
|
| 91 | + // independamment d'une saisie en cours sur id_trad |
|
| 92 | + $valeurs['_lister_id_trad'] = $valeurs['id_trad']; |
|
| 93 | + $valeurs['_id_parent'] = $id_parent; |
|
| 94 | + } |
|
| 95 | + |
|
| 96 | + $valeurs['_saisie_en_cours'] = (!_request('annuler') and (_request('changer_lang') !== null |
|
| 97 | + or _request('changer_id_trad') !== null)); |
|
| 98 | + $valeurs['_pipeline'] = ['traduire', ['type' => $objet, 'id' => $id_objet]]; |
|
| 99 | + |
|
| 100 | + return $valeurs; |
|
| 101 | 101 | } |
| 102 | 102 | |
| 103 | 103 | /** |
@@ -115,32 +115,32 @@ discard block |
||
| 115 | 115 | * Erreurs des saisies |
| 116 | 116 | */ |
| 117 | 117 | function formulaires_traduire_verifier_dist($objet, $id_objet, $retour = '', $traduire = true) { |
| 118 | - $erreurs = []; |
|
| 119 | - |
|
| 120 | - if (null !== _request('changer_lang')) { |
|
| 121 | - $erreurs = formulaires_editer_objet_verifier($objet, $id_objet, ['changer_lang']); |
|
| 122 | - } |
|
| 123 | - |
|
| 124 | - // si id_trad fourni, verifier que cela ne conflicte pas avec un id_trad existant |
|
| 125 | - // et que ca reference bien un objet existant |
|
| 126 | - if ($id_trad = _request('id_trad')) { |
|
| 127 | - $table_objet_sql = table_objet_sql($objet); |
|
| 128 | - $_id_table_objet = id_table_objet($objet); |
|
| 129 | - if ( |
|
| 130 | - sql_getfetsel( |
|
| 131 | - 'id_trad', |
|
| 132 | - $table_objet_sql, |
|
| 133 | - "$_id_table_objet=" . intval($id_objet) |
|
| 134 | - ) |
|
| 135 | - ) { |
|
| 136 | - // ne devrait jamais arriver sauf concurence de saisie |
|
| 137 | - $erreurs['id_trad'] = _L('Une traduction est deja referencee'); |
|
| 138 | - } elseif (!sql_getfetsel($_id_table_objet, $table_objet_sql, "$_id_table_objet=" . intval($id_trad))) { |
|
| 139 | - $erreurs['id_trad'] = _L('Indiquez un contenu existant'); |
|
| 140 | - } |
|
| 141 | - } |
|
| 142 | - |
|
| 143 | - return $erreurs; |
|
| 118 | + $erreurs = []; |
|
| 119 | + |
|
| 120 | + if (null !== _request('changer_lang')) { |
|
| 121 | + $erreurs = formulaires_editer_objet_verifier($objet, $id_objet, ['changer_lang']); |
|
| 122 | + } |
|
| 123 | + |
|
| 124 | + // si id_trad fourni, verifier que cela ne conflicte pas avec un id_trad existant |
|
| 125 | + // et que ca reference bien un objet existant |
|
| 126 | + if ($id_trad = _request('id_trad')) { |
|
| 127 | + $table_objet_sql = table_objet_sql($objet); |
|
| 128 | + $_id_table_objet = id_table_objet($objet); |
|
| 129 | + if ( |
|
| 130 | + sql_getfetsel( |
|
| 131 | + 'id_trad', |
|
| 132 | + $table_objet_sql, |
|
| 133 | + "$_id_table_objet=" . intval($id_objet) |
|
| 134 | + ) |
|
| 135 | + ) { |
|
| 136 | + // ne devrait jamais arriver sauf concurence de saisie |
|
| 137 | + $erreurs['id_trad'] = _L('Une traduction est deja referencee'); |
|
| 138 | + } elseif (!sql_getfetsel($_id_table_objet, $table_objet_sql, "$_id_table_objet=" . intval($id_trad))) { |
|
| 139 | + $erreurs['id_trad'] = _L('Indiquez un contenu existant'); |
|
| 140 | + } |
|
| 141 | + } |
|
| 142 | + |
|
| 143 | + return $erreurs; |
|
| 144 | 144 | } |
| 145 | 145 | |
| 146 | 146 | |
@@ -159,32 +159,32 @@ discard block |
||
| 159 | 159 | * Retour des traitements |
| 160 | 160 | */ |
| 161 | 161 | function formulaires_traduire_traiter_dist($objet, $id_objet, $retour = '', $traduire = true) { |
| 162 | - $res = []; |
|
| 163 | - if (!_request('annuler') and autoriser('changerlangue', $objet, $id_objet)) { |
|
| 164 | - // action/editer_xxx doit traiter la modif de changer_lang |
|
| 165 | - $res = formulaires_editer_objet_traiter($objet, $id_objet, 0, 0, $retour); |
|
| 166 | - } |
|
| 167 | - if (!_request('annuler') and autoriser('changertraduction', $objet, $id_objet)) { |
|
| 168 | - if ($id_trad = _request('id_trad') or _request('supprimer_trad')) { |
|
| 169 | - $referencer_traduction = charger_fonction('referencer_traduction', 'action'); |
|
| 170 | - $referencer_traduction($objet, $id_objet, intval($id_trad)); // 0 si supprimer_trad |
|
| 171 | - } elseif ( |
|
| 172 | - $new_id_trad = _request('changer_reference_trad') |
|
| 173 | - and $new_id_trad = array_keys($new_id_trad) |
|
| 174 | - and $new_id_trad = reset($new_id_trad) |
|
| 175 | - ) { |
|
| 176 | - $table_objet_sql = table_objet_sql($objet); |
|
| 177 | - $_id_table_objet = id_table_objet($objet); |
|
| 178 | - if ($id_trad = sql_getfetsel('id_trad', $table_objet_sql, "$_id_table_objet=" . intval($id_objet))) { |
|
| 179 | - $referencer_traduction = charger_fonction('referencer_traduction', 'action'); |
|
| 180 | - $referencer_traduction($objet, $id_trad, $new_id_trad); |
|
| 181 | - } |
|
| 182 | - } |
|
| 183 | - } |
|
| 184 | - $res['editable'] = true; |
|
| 185 | - if (!isset($res['message_erreur'])) { |
|
| 186 | - set_request('annuler', 'annuler'); |
|
| 187 | - } // provoquer la fermeture du forumlaire |
|
| 188 | - |
|
| 189 | - return $res; |
|
| 162 | + $res = []; |
|
| 163 | + if (!_request('annuler') and autoriser('changerlangue', $objet, $id_objet)) { |
|
| 164 | + // action/editer_xxx doit traiter la modif de changer_lang |
|
| 165 | + $res = formulaires_editer_objet_traiter($objet, $id_objet, 0, 0, $retour); |
|
| 166 | + } |
|
| 167 | + if (!_request('annuler') and autoriser('changertraduction', $objet, $id_objet)) { |
|
| 168 | + if ($id_trad = _request('id_trad') or _request('supprimer_trad')) { |
|
| 169 | + $referencer_traduction = charger_fonction('referencer_traduction', 'action'); |
|
| 170 | + $referencer_traduction($objet, $id_objet, intval($id_trad)); // 0 si supprimer_trad |
|
| 171 | + } elseif ( |
|
| 172 | + $new_id_trad = _request('changer_reference_trad') |
|
| 173 | + and $new_id_trad = array_keys($new_id_trad) |
|
| 174 | + and $new_id_trad = reset($new_id_trad) |
|
| 175 | + ) { |
|
| 176 | + $table_objet_sql = table_objet_sql($objet); |
|
| 177 | + $_id_table_objet = id_table_objet($objet); |
|
| 178 | + if ($id_trad = sql_getfetsel('id_trad', $table_objet_sql, "$_id_table_objet=" . intval($id_objet))) { |
|
| 179 | + $referencer_traduction = charger_fonction('referencer_traduction', 'action'); |
|
| 180 | + $referencer_traduction($objet, $id_trad, $new_id_trad); |
|
| 181 | + } |
|
| 182 | + } |
|
| 183 | + } |
|
| 184 | + $res['editable'] = true; |
|
| 185 | + if (!isset($res['message_erreur'])) { |
|
| 186 | + set_request('annuler', 'annuler'); |
|
| 187 | + } // provoquer la fermeture du forumlaire |
|
| 188 | + |
|
| 189 | + return $res; |
|
| 190 | 190 | } |
@@ -60,7 +60,7 @@ discard block |
||
| 60 | 60 | $id_parent = $valeurs['id_parent']; |
| 61 | 61 | } |
| 62 | 62 | if ($id_parent) { |
| 63 | - $langue_parent = sql_getfetsel('lang', 'spip_rubriques', 'id_rubrique=' . intval($id_parent)); |
|
| 63 | + $langue_parent = sql_getfetsel('lang', 'spip_rubriques', 'id_rubrique='.intval($id_parent)); |
|
| 64 | 64 | } |
| 65 | 65 | |
| 66 | 66 | if (!$langue_parent) { |
@@ -83,8 +83,8 @@ discard block |
||
| 83 | 83 | $valeurs['_traduire'] = ''; |
| 84 | 84 | if (isset($valeurs['id_trad'])) { |
| 85 | 85 | $valeurs['_traduire'] = ($traduire ? ' ' : ''); |
| 86 | - $valeurs['_vue_traductions'] = 'prive/objets/liste/' . (trouver_fond( |
|
| 87 | - $f = table_objet($objet) . '-trad', |
|
| 86 | + $valeurs['_vue_traductions'] = 'prive/objets/liste/'.(trouver_fond( |
|
| 87 | + $f = table_objet($objet).'-trad', |
|
| 88 | 88 | 'prive/objets/liste' |
| 89 | 89 | ) ? $f : 'objets-trad'); |
| 90 | 90 | // pour afficher la liste des trad sur la base de l'id_trad en base |
@@ -130,12 +130,12 @@ discard block |
||
| 130 | 130 | sql_getfetsel( |
| 131 | 131 | 'id_trad', |
| 132 | 132 | $table_objet_sql, |
| 133 | - "$_id_table_objet=" . intval($id_objet) |
|
| 133 | + "$_id_table_objet=".intval($id_objet) |
|
| 134 | 134 | ) |
| 135 | 135 | ) { |
| 136 | 136 | // ne devrait jamais arriver sauf concurence de saisie |
| 137 | 137 | $erreurs['id_trad'] = _L('Une traduction est deja referencee'); |
| 138 | - } elseif (!sql_getfetsel($_id_table_objet, $table_objet_sql, "$_id_table_objet=" . intval($id_trad))) { |
|
| 138 | + } elseif (!sql_getfetsel($_id_table_objet, $table_objet_sql, "$_id_table_objet=".intval($id_trad))) { |
|
| 139 | 139 | $erreurs['id_trad'] = _L('Indiquez un contenu existant'); |
| 140 | 140 | } |
| 141 | 141 | } |
@@ -175,7 +175,7 @@ discard block |
||
| 175 | 175 | ) { |
| 176 | 176 | $table_objet_sql = table_objet_sql($objet); |
| 177 | 177 | $_id_table_objet = id_table_objet($objet); |
| 178 | - if ($id_trad = sql_getfetsel('id_trad', $table_objet_sql, "$_id_table_objet=" . intval($id_objet))) { |
|
| 178 | + if ($id_trad = sql_getfetsel('id_trad', $table_objet_sql, "$_id_table_objet=".intval($id_objet))) { |
|
| 179 | 179 | $referencer_traduction = charger_fonction('referencer_traduction', 'action'); |
| 180 | 180 | $referencer_traduction($objet, $id_trad, $new_id_trad); |
| 181 | 181 | } |
@@ -46,6 +46,6 @@ |
||
| 46 | 46 | 'recherche' => _request('recherche'), |
| 47 | 47 | 'lang' => $lang, |
| 48 | 48 | 'class' => $class, |
| 49 | - '_id_champ' => 'rechercher_' . substr(md5($action . $class), 0, 4), |
|
| 49 | + '_id_champ' => 'rechercher_'.substr(md5($action.$class), 0, 4), |
|
| 50 | 50 | ]; |
| 51 | 51 | } |
@@ -17,7 +17,7 @@ discard block |
||
| 17 | 17 | **/ |
| 18 | 18 | |
| 19 | 19 | if (!defined('_ECRIRE_INC_VERSION')) { |
| 20 | - return; |
|
| 20 | + return; |
|
| 21 | 21 | } |
| 22 | 22 | |
| 23 | 23 | /** |
@@ -33,19 +33,19 @@ discard block |
||
| 33 | 33 | * @return array Environnement du formulaire |
| 34 | 34 | **/ |
| 35 | 35 | function formulaires_recherche_ecrire_charger_dist($action = '', $class = '') { |
| 36 | - if ($GLOBALS['spip_lang'] != $GLOBALS['meta']['langue_site']) { |
|
| 37 | - $lang = $GLOBALS['spip_lang']; |
|
| 38 | - } else { |
|
| 39 | - $lang = ''; |
|
| 40 | - } |
|
| 36 | + if ($GLOBALS['spip_lang'] != $GLOBALS['meta']['langue_site']) { |
|
| 37 | + $lang = $GLOBALS['spip_lang']; |
|
| 38 | + } else { |
|
| 39 | + $lang = ''; |
|
| 40 | + } |
|
| 41 | 41 | |
| 42 | - return |
|
| 43 | - [ |
|
| 44 | - 'action' => ($action ?: generer_url_ecrire('recherche')), |
|
| 45 | - # action specifique, ne passe pas par Verifier, ni Traiter |
|
| 46 | - 'recherche' => _request('recherche'), |
|
| 47 | - 'lang' => $lang, |
|
| 48 | - 'class' => $class, |
|
| 49 | - '_id_champ' => 'rechercher_' . substr(md5($action . $class), 0, 4), |
|
| 50 | - ]; |
|
| 42 | + return |
|
| 43 | + [ |
|
| 44 | + 'action' => ($action ?: generer_url_ecrire('recherche')), |
|
| 45 | + # action specifique, ne passe pas par Verifier, ni Traiter |
|
| 46 | + 'recherche' => _request('recherche'), |
|
| 47 | + 'lang' => $lang, |
|
| 48 | + 'class' => $class, |
|
| 49 | + '_id_champ' => 'rechercher_' . substr(md5($action . $class), 0, 4), |
|
| 50 | + ]; |
|
| 51 | 51 | } |