@@ -16,7 +16,7 @@ discard block |
||
| 16 | 16 | * @package SPIP\Core\Notifications |
| 17 | 17 | **/ |
| 18 | 18 | if (!defined('_ECRIRE_INC_VERSION')) { |
| 19 | - return; |
|
| 19 | + return; |
|
| 20 | 20 | } |
| 21 | 21 | |
| 22 | 22 | |
@@ -33,16 +33,16 @@ discard block |
||
| 33 | 33 | */ |
| 34 | 34 | function inc_notifications_dist($quoi, $id = 0, $options = []) { |
| 35 | 35 | |
| 36 | - // charger les fichiers qui veulent ajouter des definitions |
|
| 37 | - // ou faire des trucs aussi dans le pipeline, ca fait deux api pour le prix d'une ... |
|
| 38 | - pipeline('notifications', ['args' => ['quoi' => $quoi, 'id' => $id, 'options' => $options]]); |
|
| 36 | + // charger les fichiers qui veulent ajouter des definitions |
|
| 37 | + // ou faire des trucs aussi dans le pipeline, ca fait deux api pour le prix d'une ... |
|
| 38 | + pipeline('notifications', ['args' => ['quoi' => $quoi, 'id' => $id, 'options' => $options]]); |
|
| 39 | 39 | |
| 40 | - if ($notification = charger_fonction($quoi, 'notifications', true)) { |
|
| 41 | - spip_log("$notification($quoi,$id" |
|
| 42 | - . ($options ? ',' . serialize($options) : '') |
|
| 43 | - . ')', 'notifications'); |
|
| 44 | - $notification($quoi, $id, $options); |
|
| 45 | - } |
|
| 40 | + if ($notification = charger_fonction($quoi, 'notifications', true)) { |
|
| 41 | + spip_log("$notification($quoi,$id" |
|
| 42 | + . ($options ? ',' . serialize($options) : '') |
|
| 43 | + . ')', 'notifications'); |
|
| 44 | + $notification($quoi, $id, $options); |
|
| 45 | + } |
|
| 46 | 46 | } |
| 47 | 47 | |
| 48 | 48 | /** |
@@ -56,14 +56,14 @@ discard block |
||
| 56 | 56 | * @param array $exclure |
| 57 | 57 | */ |
| 58 | 58 | function notifications_nettoyer_emails(&$emails, $exclure = []) { |
| 59 | - // filtrer et unifier |
|
| 60 | - $emails = array_unique(array_filter(array_map('email_valide', array_map('trim', $emails)))); |
|
| 61 | - if ($exclure and count($exclure)) { |
|
| 62 | - // nettoyer les exclusions d'abord |
|
| 63 | - notifications_nettoyer_emails($exclure); |
|
| 64 | - // faire un diff |
|
| 65 | - $emails = array_diff($emails, $exclure); |
|
| 66 | - } |
|
| 59 | + // filtrer et unifier |
|
| 60 | + $emails = array_unique(array_filter(array_map('email_valide', array_map('trim', $emails)))); |
|
| 61 | + if ($exclure and count($exclure)) { |
|
| 62 | + // nettoyer les exclusions d'abord |
|
| 63 | + notifications_nettoyer_emails($exclure); |
|
| 64 | + // faire un diff |
|
| 65 | + $emails = array_diff($emails, $exclure); |
|
| 66 | + } |
|
| 67 | 67 | } |
| 68 | 68 | |
| 69 | 69 | /** |
@@ -78,90 +78,90 @@ discard block |
||
| 78 | 78 | * @param string $headers |
| 79 | 79 | */ |
| 80 | 80 | function notifications_envoyer_mails($emails, $texte, $sujet = '', $from = '', $headers = '') { |
| 81 | - // rien a faire si pas de texte ! |
|
| 82 | - if (!strlen($texte)) { |
|
| 83 | - return; |
|
| 84 | - } |
|
| 85 | - |
|
| 86 | - // si on ne specifie qu'un email, le mettre dans un tableau |
|
| 87 | - if (!is_array($emails)) { |
|
| 88 | - $emails = explode(',', $emails); |
|
| 89 | - } |
|
| 90 | - |
|
| 91 | - notifications_nettoyer_emails($emails); |
|
| 92 | - |
|
| 93 | - // tester si le mail est deja en html |
|
| 94 | - if ( |
|
| 95 | - strpos($texte, '<') !== false // eviter les tests suivants si possible |
|
| 96 | - and $ttrim = trim($texte) |
|
| 97 | - and substr($ttrim, 0, 1) == '<' |
|
| 98 | - and substr($ttrim, -1, 1) == '>' |
|
| 99 | - and stripos($ttrim, '</html>') !== false |
|
| 100 | - ) { |
|
| 101 | - if (!strlen($sujet)) { |
|
| 102 | - // dans ce cas on ruse un peu : extraire le sujet du title |
|
| 103 | - if (preg_match(',<title>(.*)</title>,Uims', $texte, $m)) { |
|
| 104 | - $sujet = $m[1]; |
|
| 105 | - } else { |
|
| 106 | - // fallback, on prend le body si on le trouve |
|
| 107 | - if (preg_match(',<body[^>]*>(.*)</body>,Uims', $texte, $m)) { |
|
| 108 | - $ttrim = $m[1]; |
|
| 109 | - } |
|
| 110 | - |
|
| 111 | - // et on extrait la premiere ligne de vrai texte... |
|
| 112 | - // nettoyer le html et les retours chariots |
|
| 113 | - $ttrim = textebrut($ttrim); |
|
| 114 | - $ttrim = str_replace("\r\n", "\r", $ttrim); |
|
| 115 | - $ttrim = str_replace("\r", "\n", $ttrim); |
|
| 116 | - // decouper |
|
| 117 | - $ttrim = explode("\n", trim($ttrim)); |
|
| 118 | - // extraire la premiere ligne de texte brut |
|
| 119 | - $sujet = array_shift($ttrim); |
|
| 120 | - } |
|
| 121 | - } |
|
| 122 | - |
|
| 123 | - // si besoin on ajoute le content-type dans les headers |
|
| 124 | - if (stripos($headers, 'Content-Type') === false) { |
|
| 125 | - $headers .= "Content-Type: text/html\n"; |
|
| 126 | - } |
|
| 127 | - } |
|
| 128 | - |
|
| 129 | - // si le sujet est vide, extraire la premiere ligne du corps |
|
| 130 | - // du mail qui est donc du texte |
|
| 131 | - if (!strlen($sujet)) { |
|
| 132 | - // nettoyer un peu les retours chariots |
|
| 133 | - $texte = str_replace("\r\n", "\r", $texte); |
|
| 134 | - $texte = str_replace("\r", "\n", $texte); |
|
| 135 | - // decouper |
|
| 136 | - $texte = explode("\n", trim($texte)); |
|
| 137 | - // extraire la premiere ligne |
|
| 138 | - $sujet = array_shift($texte); |
|
| 139 | - $texte = trim(implode("\n", $texte)); |
|
| 140 | - } |
|
| 141 | - |
|
| 142 | - $envoyer_mail = charger_fonction('envoyer_mail', 'inc'); |
|
| 143 | - foreach ($emails as $email) { |
|
| 144 | - // passer dans un pipeline qui permet un ajout eventuel |
|
| 145 | - // (url de suivi des notifications par exemple) |
|
| 146 | - $envoi = pipeline( |
|
| 147 | - 'notifications_envoyer_mails', |
|
| 148 | - [ |
|
| 149 | - 'email' => $email, |
|
| 150 | - 'sujet' => $sujet, |
|
| 151 | - 'texte' => $texte, |
|
| 152 | - 'from' => $from, |
|
| 153 | - 'headers' => $headers, |
|
| 154 | - ] |
|
| 155 | - ); |
|
| 156 | - $email = $envoi['email']; |
|
| 157 | - |
|
| 158 | - job_queue_add( |
|
| 159 | - 'envoyer_mail', |
|
| 160 | - ">$email : " . $envoi['sujet'], |
|
| 161 | - [$email, $envoi['sujet'], $envoi['texte'], $envoi['from'], $envoi['headers']], |
|
| 162 | - 'inc/' |
|
| 163 | - ); |
|
| 164 | - } |
|
| 81 | + // rien a faire si pas de texte ! |
|
| 82 | + if (!strlen($texte)) { |
|
| 83 | + return; |
|
| 84 | + } |
|
| 85 | + |
|
| 86 | + // si on ne specifie qu'un email, le mettre dans un tableau |
|
| 87 | + if (!is_array($emails)) { |
|
| 88 | + $emails = explode(',', $emails); |
|
| 89 | + } |
|
| 90 | + |
|
| 91 | + notifications_nettoyer_emails($emails); |
|
| 92 | + |
|
| 93 | + // tester si le mail est deja en html |
|
| 94 | + if ( |
|
| 95 | + strpos($texte, '<') !== false // eviter les tests suivants si possible |
|
| 96 | + and $ttrim = trim($texte) |
|
| 97 | + and substr($ttrim, 0, 1) == '<' |
|
| 98 | + and substr($ttrim, -1, 1) == '>' |
|
| 99 | + and stripos($ttrim, '</html>') !== false |
|
| 100 | + ) { |
|
| 101 | + if (!strlen($sujet)) { |
|
| 102 | + // dans ce cas on ruse un peu : extraire le sujet du title |
|
| 103 | + if (preg_match(',<title>(.*)</title>,Uims', $texte, $m)) { |
|
| 104 | + $sujet = $m[1]; |
|
| 105 | + } else { |
|
| 106 | + // fallback, on prend le body si on le trouve |
|
| 107 | + if (preg_match(',<body[^>]*>(.*)</body>,Uims', $texte, $m)) { |
|
| 108 | + $ttrim = $m[1]; |
|
| 109 | + } |
|
| 110 | + |
|
| 111 | + // et on extrait la premiere ligne de vrai texte... |
|
| 112 | + // nettoyer le html et les retours chariots |
|
| 113 | + $ttrim = textebrut($ttrim); |
|
| 114 | + $ttrim = str_replace("\r\n", "\r", $ttrim); |
|
| 115 | + $ttrim = str_replace("\r", "\n", $ttrim); |
|
| 116 | + // decouper |
|
| 117 | + $ttrim = explode("\n", trim($ttrim)); |
|
| 118 | + // extraire la premiere ligne de texte brut |
|
| 119 | + $sujet = array_shift($ttrim); |
|
| 120 | + } |
|
| 121 | + } |
|
| 122 | + |
|
| 123 | + // si besoin on ajoute le content-type dans les headers |
|
| 124 | + if (stripos($headers, 'Content-Type') === false) { |
|
| 125 | + $headers .= "Content-Type: text/html\n"; |
|
| 126 | + } |
|
| 127 | + } |
|
| 128 | + |
|
| 129 | + // si le sujet est vide, extraire la premiere ligne du corps |
|
| 130 | + // du mail qui est donc du texte |
|
| 131 | + if (!strlen($sujet)) { |
|
| 132 | + // nettoyer un peu les retours chariots |
|
| 133 | + $texte = str_replace("\r\n", "\r", $texte); |
|
| 134 | + $texte = str_replace("\r", "\n", $texte); |
|
| 135 | + // decouper |
|
| 136 | + $texte = explode("\n", trim($texte)); |
|
| 137 | + // extraire la premiere ligne |
|
| 138 | + $sujet = array_shift($texte); |
|
| 139 | + $texte = trim(implode("\n", $texte)); |
|
| 140 | + } |
|
| 141 | + |
|
| 142 | + $envoyer_mail = charger_fonction('envoyer_mail', 'inc'); |
|
| 143 | + foreach ($emails as $email) { |
|
| 144 | + // passer dans un pipeline qui permet un ajout eventuel |
|
| 145 | + // (url de suivi des notifications par exemple) |
|
| 146 | + $envoi = pipeline( |
|
| 147 | + 'notifications_envoyer_mails', |
|
| 148 | + [ |
|
| 149 | + 'email' => $email, |
|
| 150 | + 'sujet' => $sujet, |
|
| 151 | + 'texte' => $texte, |
|
| 152 | + 'from' => $from, |
|
| 153 | + 'headers' => $headers, |
|
| 154 | + ] |
|
| 155 | + ); |
|
| 156 | + $email = $envoi['email']; |
|
| 157 | + |
|
| 158 | + job_queue_add( |
|
| 159 | + 'envoyer_mail', |
|
| 160 | + ">$email : " . $envoi['sujet'], |
|
| 161 | + [$email, $envoi['sujet'], $envoi['texte'], $envoi['from'], $envoi['headers']], |
|
| 162 | + 'inc/' |
|
| 163 | + ); |
|
| 164 | + } |
|
| 165 | 165 | } |
| 166 | 166 | |
| 167 | 167 | /** |
@@ -177,10 +177,10 @@ discard block |
||
| 177 | 177 | * @return string |
| 178 | 178 | */ |
| 179 | 179 | function email_notification_objet($id_objet, $type_objet, $modele) { |
| 180 | - $envoyer_mail = charger_fonction('envoyer_mail', 'inc'); // pour nettoyer_titre_email |
|
| 181 | - $id_type = id_table_objet($type_objet); |
|
| 180 | + $envoyer_mail = charger_fonction('envoyer_mail', 'inc'); // pour nettoyer_titre_email |
|
| 181 | + $id_type = id_table_objet($type_objet); |
|
| 182 | 182 | |
| 183 | - return recuperer_fond($modele, [$id_type => $id_objet, 'id' => $id_objet]); |
|
| 183 | + return recuperer_fond($modele, [$id_type => $id_objet, 'id' => $id_objet]); |
|
| 184 | 184 | } |
| 185 | 185 | |
| 186 | 186 | /** |
@@ -195,7 +195,7 @@ discard block |
||
| 195 | 195 | * @return string |
| 196 | 196 | */ |
| 197 | 197 | function email_notification_article($id_article, $modele) { |
| 198 | - $envoyer_mail = charger_fonction('envoyer_mail', 'inc'); // pour nettoyer_titre_email |
|
| 198 | + $envoyer_mail = charger_fonction('envoyer_mail', 'inc'); // pour nettoyer_titre_email |
|
| 199 | 199 | |
| 200 | - return recuperer_fond($modele, ['id_article' => $id_article]); |
|
| 200 | + return recuperer_fond($modele, ['id_article' => $id_article]); |
|
| 201 | 201 | } |
@@ -39,7 +39,7 @@ discard block |
||
| 39 | 39 | |
| 40 | 40 | if ($notification = charger_fonction($quoi, 'notifications', true)) { |
| 41 | 41 | spip_log("$notification($quoi,$id" |
| 42 | - . ($options ? ',' . serialize($options) : '') |
|
| 42 | + . ($options ? ','.serialize($options) : '') |
|
| 43 | 43 | . ')', 'notifications'); |
| 44 | 44 | $notification($quoi, $id, $options); |
| 45 | 45 | } |
@@ -157,7 +157,7 @@ discard block |
||
| 157 | 157 | |
| 158 | 158 | job_queue_add( |
| 159 | 159 | 'envoyer_mail', |
| 160 | - ">$email : " . $envoi['sujet'], |
|
| 160 | + ">$email : ".$envoi['sujet'], |
|
| 161 | 161 | [$email, $envoi['sujet'], $envoi['texte'], $envoi['from'], $envoi['headers']], |
| 162 | 162 | 'inc/' |
| 163 | 163 | ); |
@@ -16,7 +16,7 @@ discard block |
||
| 16 | 16 | * @package SPIP\Core\Mail |
| 17 | 17 | **/ |
| 18 | 18 | if (!defined('_ECRIRE_INC_VERSION')) { |
| 19 | - return; |
|
| 19 | + return; |
|
| 20 | 20 | } |
| 21 | 21 | |
| 22 | 22 | |
@@ -31,27 +31,27 @@ discard block |
||
| 31 | 31 | * - la normalisation de la dernière adresse donnée sinon |
| 32 | 32 | **/ |
| 33 | 33 | function inc_email_valide_dist($adresses) { |
| 34 | - // eviter d'injecter n'importe quoi dans preg_match |
|
| 35 | - if (!is_string($adresses)) { |
|
| 36 | - return false; |
|
| 37 | - } |
|
| 38 | - |
|
| 39 | - // Si c'est un spammeur autant arreter tout de suite |
|
| 40 | - if (preg_match(",[\n\r].*(MIME|multipart|Content-),i", $adresses)) { |
|
| 41 | - spip_log("Tentative d'injection de mail : $adresses"); |
|
| 42 | - |
|
| 43 | - return false; |
|
| 44 | - } |
|
| 45 | - |
|
| 46 | - foreach (explode(',', $adresses) as $v) { |
|
| 47 | - // nettoyer certains formats |
|
| 48 | - // "Marie Toto <[email protected]>" |
|
| 49 | - $adresse = trim(preg_replace(',^[^<>"]*<([^<>"]+)>$,i', "\\1", $v)); |
|
| 50 | - // RFC 822 |
|
| 51 | - if (!preg_match('#^[^()<>@,;:\\"/[:space:]]+(@([-_0-9a-z]+\.)*[-_0-9a-z]+)$#i', $adresse)) { |
|
| 52 | - return false; |
|
| 53 | - } |
|
| 54 | - } |
|
| 55 | - |
|
| 56 | - return $adresse; |
|
| 34 | + // eviter d'injecter n'importe quoi dans preg_match |
|
| 35 | + if (!is_string($adresses)) { |
|
| 36 | + return false; |
|
| 37 | + } |
|
| 38 | + |
|
| 39 | + // Si c'est un spammeur autant arreter tout de suite |
|
| 40 | + if (preg_match(",[\n\r].*(MIME|multipart|Content-),i", $adresses)) { |
|
| 41 | + spip_log("Tentative d'injection de mail : $adresses"); |
|
| 42 | + |
|
| 43 | + return false; |
|
| 44 | + } |
|
| 45 | + |
|
| 46 | + foreach (explode(',', $adresses) as $v) { |
|
| 47 | + // nettoyer certains formats |
|
| 48 | + // "Marie Toto <[email protected]>" |
|
| 49 | + $adresse = trim(preg_replace(',^[^<>"]*<([^<>"]+)>$,i', "\\1", $v)); |
|
| 50 | + // RFC 822 |
|
| 51 | + if (!preg_match('#^[^()<>@,;:\\"/[:space:]]+(@([-_0-9a-z]+\.)*[-_0-9a-z]+)$#i', $adresse)) { |
|
| 52 | + return false; |
|
| 53 | + } |
|
| 54 | + } |
|
| 55 | + |
|
| 56 | + return $adresse; |
|
| 57 | 57 | } |
@@ -40,9 +40,9 @@ discard block |
||
| 40 | 40 | $mode = preg_replace(',\W,', '', $mode); |
| 41 | 41 | if ($mode) { |
| 42 | 42 | // chercher dans la base |
| 43 | - $mode_document = 'logo' . $mode; |
|
| 43 | + $mode_document = 'logo'.$mode; |
|
| 44 | 44 | $objet = objet_type($_id_objet); |
| 45 | - $doc = sql_fetsel('D.*', 'spip_documents AS D JOIN spip_documents_liens AS L ON L.id_document=D.id_document', 'D.mode=' . sql_quote($mode_document) . ' AND L.objet=' . sql_quote($objet) . ' AND id_objet=' . intval($id)); |
|
| 45 | + $doc = sql_fetsel('D.*', 'spip_documents AS D JOIN spip_documents_liens AS L ON L.id_document=D.id_document', 'D.mode='.sql_quote($mode_document).' AND L.objet='.sql_quote($objet).' AND id_objet='.intval($id)); |
|
| 46 | 46 | if ($doc) { |
| 47 | 47 | include_spip('inc/documents'); |
| 48 | 48 | $d = get_spip_doc($doc['fichier']); |
@@ -53,10 +53,10 @@ discard block |
||
| 53 | 53 | if ($compat_old_logos) { |
| 54 | 54 | # attention au cas $id = '0' pour LOGO_SITE_SPIP : utiliser intval() |
| 55 | 55 | $type = type_du_logo($_id_objet); |
| 56 | - $nom = $type . $mode . intval($id); |
|
| 56 | + $nom = $type.$mode.intval($id); |
|
| 57 | 57 | |
| 58 | 58 | foreach ($GLOBALS['formats_logos'] as $format) { |
| 59 | - if (@file_exists($d = (_DIR_LOGOS . $nom . '.' . $format))) { |
|
| 59 | + if (@file_exists($d = (_DIR_LOGOS.$nom.'.'.$format))) { |
|
| 60 | 60 | return [$d, _DIR_LOGOS, $nom, $format, @filemtime($d)]; |
| 61 | 61 | } |
| 62 | 62 | } |
@@ -16,7 +16,7 @@ discard block |
||
| 16 | 16 | * @package SPIP\Core\Logos |
| 17 | 17 | **/ |
| 18 | 18 | if (!defined('_ECRIRE_INC_VERSION')) { |
| 19 | - return; |
|
| 19 | + return; |
|
| 20 | 20 | } |
| 21 | 21 | |
| 22 | 22 | /** |
@@ -37,34 +37,34 @@ discard block |
||
| 37 | 37 | **/ |
| 38 | 38 | function inc_chercher_logo_dist($id, $_id_objet, $mode = 'on', $compat_old_logos = true) { |
| 39 | 39 | |
| 40 | - $mode = preg_replace(',\W,', '', $mode); |
|
| 41 | - if ($mode) { |
|
| 42 | - // chercher dans la base |
|
| 43 | - $mode_document = 'logo' . $mode; |
|
| 44 | - $objet = objet_type($_id_objet); |
|
| 45 | - $doc = sql_fetsel('D.*', 'spip_documents AS D JOIN spip_documents_liens AS L ON L.id_document=D.id_document', 'D.mode=' . sql_quote($mode_document) . ' AND L.objet=' . sql_quote($objet) . ' AND id_objet=' . intval($id)); |
|
| 46 | - if ($doc) { |
|
| 47 | - include_spip('inc/documents'); |
|
| 48 | - $d = get_spip_doc($doc['fichier']); |
|
| 49 | - return [$d, _DIR_IMG, basename($d), $doc['extension'], @filemtime($d), $doc]; |
|
| 50 | - } |
|
| 40 | + $mode = preg_replace(',\W,', '', $mode); |
|
| 41 | + if ($mode) { |
|
| 42 | + // chercher dans la base |
|
| 43 | + $mode_document = 'logo' . $mode; |
|
| 44 | + $objet = objet_type($_id_objet); |
|
| 45 | + $doc = sql_fetsel('D.*', 'spip_documents AS D JOIN spip_documents_liens AS L ON L.id_document=D.id_document', 'D.mode=' . sql_quote($mode_document) . ' AND L.objet=' . sql_quote($objet) . ' AND id_objet=' . intval($id)); |
|
| 46 | + if ($doc) { |
|
| 47 | + include_spip('inc/documents'); |
|
| 48 | + $d = get_spip_doc($doc['fichier']); |
|
| 49 | + return [$d, _DIR_IMG, basename($d), $doc['extension'], @filemtime($d), $doc]; |
|
| 50 | + } |
|
| 51 | 51 | |
| 52 | - # deprecated TODO remove |
|
| 53 | - if ($compat_old_logos) { |
|
| 54 | - # attention au cas $id = '0' pour LOGO_SITE_SPIP : utiliser intval() |
|
| 55 | - $type = type_du_logo($_id_objet); |
|
| 56 | - $nom = $type . $mode . intval($id); |
|
| 52 | + # deprecated TODO remove |
|
| 53 | + if ($compat_old_logos) { |
|
| 54 | + # attention au cas $id = '0' pour LOGO_SITE_SPIP : utiliser intval() |
|
| 55 | + $type = type_du_logo($_id_objet); |
|
| 56 | + $nom = $type . $mode . intval($id); |
|
| 57 | 57 | |
| 58 | - foreach ($GLOBALS['formats_logos'] as $format) { |
|
| 59 | - if (@file_exists($d = (_DIR_LOGOS . $nom . '.' . $format))) { |
|
| 60 | - return [$d, _DIR_LOGOS, $nom, $format, @filemtime($d)]; |
|
| 61 | - } |
|
| 62 | - } |
|
| 63 | - } |
|
| 64 | - } |
|
| 58 | + foreach ($GLOBALS['formats_logos'] as $format) { |
|
| 59 | + if (@file_exists($d = (_DIR_LOGOS . $nom . '.' . $format))) { |
|
| 60 | + return [$d, _DIR_LOGOS, $nom, $format, @filemtime($d)]; |
|
| 61 | + } |
|
| 62 | + } |
|
| 63 | + } |
|
| 64 | + } |
|
| 65 | 65 | |
| 66 | - # coherence de type pour servir comme filtre (formulaire_login) |
|
| 67 | - return []; |
|
| 66 | + # coherence de type pour servir comme filtre (formulaire_login) |
|
| 67 | + return []; |
|
| 68 | 68 | } |
| 69 | 69 | |
| 70 | 70 | /** |
@@ -83,13 +83,13 @@ discard block |
||
| 83 | 83 | * @deprecated 4.0 MAIS NE PAS SUPPRIMER CAR SERT POUR L'UPGRADE des logos et leur mise en base |
| 84 | 84 | **/ |
| 85 | 85 | function type_du_logo($_id_objet) { |
| 86 | - return $GLOBALS['table_logos'][$_id_objet] ?? objet_type(preg_replace(',^id_,', '', $_id_objet)); |
|
| 86 | + return $GLOBALS['table_logos'][$_id_objet] ?? objet_type(preg_replace(',^id_,', '', $_id_objet)); |
|
| 87 | 87 | } |
| 88 | 88 | |
| 89 | 89 | // Exceptions standards (historique) |
| 90 | 90 | $GLOBALS['table_logos'] = [ |
| 91 | - 'id_article' => 'art', |
|
| 92 | - 'id_auteur' => 'aut', |
|
| 93 | - 'id_rubrique' => 'rub', |
|
| 94 | - 'id_groupe' => 'groupe', |
|
| 91 | + 'id_article' => 'art', |
|
| 92 | + 'id_auteur' => 'aut', |
|
| 93 | + 'id_rubrique' => 'rub', |
|
| 94 | + 'id_groupe' => 'groupe', |
|
| 95 | 95 | ]; |
@@ -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 | /** |
@@ -29,51 +29,51 @@ discard block |
||
| 29 | 29 | * @return string Erreur éventuelle |
| 30 | 30 | */ |
| 31 | 31 | function inc_completer_traduction_dist($objet, $id_objet, $id_trad) { |
| 32 | - // dupliquer tous les liens sauf les auteurs : le nouvel auteur est celui qui traduit |
|
| 33 | - // cf API editer_liens |
|
| 34 | - include_spip('action/editer_liens'); |
|
| 35 | - objet_dupliquer_liens($objet, $id_trad, $id_objet, null, ['auteur']); |
|
| 36 | - $_id_table = id_table_objet($objet); |
|
| 32 | + // dupliquer tous les liens sauf les auteurs : le nouvel auteur est celui qui traduit |
|
| 33 | + // cf API editer_liens |
|
| 34 | + include_spip('action/editer_liens'); |
|
| 35 | + objet_dupliquer_liens($objet, $id_trad, $id_objet, null, ['auteur']); |
|
| 36 | + $_id_table = id_table_objet($objet); |
|
| 37 | 37 | |
| 38 | - // recuperer le logo |
|
| 39 | - $chercher_logo = charger_fonction('chercher_logo', 'inc'); |
|
| 40 | - include_spip('action/editer_logo'); |
|
| 41 | - foreach (['on', 'off'] as $etat) { |
|
| 42 | - $logo = $chercher_logo($id_trad, $_id_table, $etat); |
|
| 43 | - if ($logo and $file = reset($logo)) { |
|
| 44 | - logo_modifier($objet, $id_objet, $etat, $file); |
|
| 45 | - } |
|
| 46 | - } |
|
| 38 | + // recuperer le logo |
|
| 39 | + $chercher_logo = charger_fonction('chercher_logo', 'inc'); |
|
| 40 | + include_spip('action/editer_logo'); |
|
| 41 | + foreach (['on', 'off'] as $etat) { |
|
| 42 | + $logo = $chercher_logo($id_trad, $_id_table, $etat); |
|
| 43 | + if ($logo and $file = reset($logo)) { |
|
| 44 | + logo_modifier($objet, $id_objet, $etat, $file); |
|
| 45 | + } |
|
| 46 | + } |
|
| 47 | 47 | |
| 48 | - // dupliquer certains champs |
|
| 49 | - $trouver_table = charger_fonction('trouver_table', 'base'); |
|
| 50 | - $desc = $trouver_table(table_objet_sql($objet)); |
|
| 51 | - $champs = $set = []; |
|
| 48 | + // dupliquer certains champs |
|
| 49 | + $trouver_table = charger_fonction('trouver_table', 'base'); |
|
| 50 | + $desc = $trouver_table(table_objet_sql($objet)); |
|
| 51 | + $champs = $set = []; |
|
| 52 | 52 | |
| 53 | - // un éventuel champ 'virtuel' (redirections) |
|
| 54 | - if (!empty($desc['field']['virtuel'])) { |
|
| 55 | - $champs[] = 'virtuel'; |
|
| 56 | - } |
|
| 53 | + // un éventuel champ 'virtuel' (redirections) |
|
| 54 | + if (!empty($desc['field']['virtuel'])) { |
|
| 55 | + $champs[] = 'virtuel'; |
|
| 56 | + } |
|
| 57 | 57 | |
| 58 | - $data = sql_fetsel('*', $desc['table'], $_id_table . '=' . intval($id_trad)); |
|
| 58 | + $data = sql_fetsel('*', $desc['table'], $_id_table . '=' . intval($id_trad)); |
|
| 59 | 59 | |
| 60 | - foreach ($champs as $c) { |
|
| 61 | - $set[$c] = $data[$c]; |
|
| 62 | - } |
|
| 60 | + foreach ($champs as $c) { |
|
| 61 | + $set[$c] = $data[$c]; |
|
| 62 | + } |
|
| 63 | 63 | |
| 64 | - /* |
|
| 64 | + /* |
|
| 65 | 65 | * Le pipeline 'pre_edition' sera appelé avec l'action 'completer_traduction'. |
| 66 | 66 | * Des plugins pourront ainsi compléter les champs d'un objet traduit lors d'une nouvelle traduction. |
| 67 | 67 | */ |
| 68 | - $err = objet_modifier_champs( |
|
| 69 | - $objet, |
|
| 70 | - $id_objet, |
|
| 71 | - [ |
|
| 72 | - 'data' => $data, |
|
| 73 | - 'action' => 'completer_traduction', |
|
| 74 | - ], |
|
| 75 | - $set |
|
| 76 | - ); |
|
| 68 | + $err = objet_modifier_champs( |
|
| 69 | + $objet, |
|
| 70 | + $id_objet, |
|
| 71 | + [ |
|
| 72 | + 'data' => $data, |
|
| 73 | + 'action' => 'completer_traduction', |
|
| 74 | + ], |
|
| 75 | + $set |
|
| 76 | + ); |
|
| 77 | 77 | |
| 78 | - return $err; |
|
| 78 | + return $err; |
|
| 79 | 79 | } |
@@ -55,7 +55,7 @@ |
||
| 55 | 55 | $champs[] = 'virtuel'; |
| 56 | 56 | } |
| 57 | 57 | |
| 58 | - $data = sql_fetsel('*', $desc['table'], $_id_table . '=' . intval($id_trad)); |
|
| 58 | + $data = sql_fetsel('*', $desc['table'], $_id_table.'='.intval($id_trad)); |
|
| 59 | 59 | |
| 60 | 60 | foreach ($champs as $c) { |
| 61 | 61 | $set[$c] = $data[$c]; |
@@ -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 | /** |
@@ -27,7 +27,7 @@ discard block |
||
| 27 | 27 | * @return string |
| 28 | 28 | */ |
| 29 | 29 | function autosave_clean_value($val) { |
| 30 | - return stripslashes(urldecode($val)); |
|
| 30 | + return stripslashes(urldecode($val)); |
|
| 31 | 31 | } |
| 32 | 32 | |
| 33 | 33 | /** |
@@ -38,58 +38,58 @@ discard block |
||
| 38 | 38 | * @return array |
| 39 | 39 | */ |
| 40 | 40 | function cvtautosave_formulaire_charger($flux) { |
| 41 | - if ( |
|
| 42 | - is_array($flux['data']) |
|
| 43 | - and isset($flux['data']['_autosave_id']) |
|
| 44 | - and $cle_autosave = $flux['data']['_autosave_id'] |
|
| 45 | - ) { |
|
| 46 | - $form = $flux['args']['form']; |
|
| 47 | - $je_suis_poste = $flux['args']['je_suis_poste']; |
|
| 41 | + if ( |
|
| 42 | + is_array($flux['data']) |
|
| 43 | + and isset($flux['data']['_autosave_id']) |
|
| 44 | + and $cle_autosave = $flux['data']['_autosave_id'] |
|
| 45 | + ) { |
|
| 46 | + $form = $flux['args']['form']; |
|
| 47 | + $je_suis_poste = $flux['args']['je_suis_poste']; |
|
| 48 | 48 | |
| 49 | - $cle_autosave = serialize($cle_autosave); |
|
| 50 | - $cle_autosave = $form . '_' . md5($cle_autosave); |
|
| 49 | + $cle_autosave = serialize($cle_autosave); |
|
| 50 | + $cle_autosave = $form . '_' . md5($cle_autosave); |
|
| 51 | 51 | |
| 52 | - // si on a un backup en session et qu'on est au premier chargement, non poste |
|
| 53 | - // on restitue les donnees |
|
| 54 | - if ( |
|
| 55 | - isset($GLOBALS['visiteur_session']['session_autosave_' . $cle_autosave]) |
|
| 56 | - and !$je_suis_poste |
|
| 57 | - ) { |
|
| 58 | - parse_str($GLOBALS['visiteur_session']['session_autosave_' . $cle_autosave], $vars); |
|
| 59 | - foreach ($vars as $key => $val) { |
|
| 60 | - if (isset($flux['data'][$key])) { |
|
| 61 | - $flux['data'][$key] = (is_string($val) ? autosave_clean_value($val) : array_map( |
|
| 62 | - 'autosave_clean_value', |
|
| 63 | - $val |
|
| 64 | - )); |
|
| 65 | - } |
|
| 66 | - } |
|
| 67 | - } |
|
| 52 | + // si on a un backup en session et qu'on est au premier chargement, non poste |
|
| 53 | + // on restitue les donnees |
|
| 54 | + if ( |
|
| 55 | + isset($GLOBALS['visiteur_session']['session_autosave_' . $cle_autosave]) |
|
| 56 | + and !$je_suis_poste |
|
| 57 | + ) { |
|
| 58 | + parse_str($GLOBALS['visiteur_session']['session_autosave_' . $cle_autosave], $vars); |
|
| 59 | + foreach ($vars as $key => $val) { |
|
| 60 | + if (isset($flux['data'][$key])) { |
|
| 61 | + $flux['data'][$key] = (is_string($val) ? autosave_clean_value($val) : array_map( |
|
| 62 | + 'autosave_clean_value', |
|
| 63 | + $val |
|
| 64 | + )); |
|
| 65 | + } |
|
| 66 | + } |
|
| 67 | + } |
|
| 68 | 68 | |
| 69 | - // si on est dans le charger() qui suit le traiter(), l'autosave a normalement ete vide |
|
| 70 | - // mais si il y a plusieurs sessions il peut y avoir concurrence et un retour de l'autosave |
|
| 71 | - if ($je_suis_poste and _request('autosave') === $cle_autosave and function_exists('terminer_actualiser_sessions')) { |
|
| 72 | - terminer_actualiser_sessions(); |
|
| 73 | - // et verifions si jamais l'autosave a fait un come back, dans ce cas on le revide |
|
| 74 | - if (isset($GLOBALS['visiteur_session']['session_autosave_' . $cle_autosave])) { |
|
| 75 | - session_set('session_autosave_' . $cle_autosave, null); |
|
| 76 | - // en court sleep pour etre certain que la concurrence est finie |
|
| 77 | - sleep(1); |
|
| 78 | - terminer_actualiser_sessions(); |
|
| 79 | - } |
|
| 80 | - } |
|
| 69 | + // si on est dans le charger() qui suit le traiter(), l'autosave a normalement ete vide |
|
| 70 | + // mais si il y a plusieurs sessions il peut y avoir concurrence et un retour de l'autosave |
|
| 71 | + if ($je_suis_poste and _request('autosave') === $cle_autosave and function_exists('terminer_actualiser_sessions')) { |
|
| 72 | + terminer_actualiser_sessions(); |
|
| 73 | + // et verifions si jamais l'autosave a fait un come back, dans ce cas on le revide |
|
| 74 | + if (isset($GLOBALS['visiteur_session']['session_autosave_' . $cle_autosave])) { |
|
| 75 | + session_set('session_autosave_' . $cle_autosave, null); |
|
| 76 | + // en court sleep pour etre certain que la concurrence est finie |
|
| 77 | + sleep(1); |
|
| 78 | + terminer_actualiser_sessions(); |
|
| 79 | + } |
|
| 80 | + } |
|
| 81 | 81 | |
| 82 | 82 | |
| 83 | - /** |
|
| 84 | - * Envoyer le input hidden et le bout de js qui l'utilisera |
|
| 85 | - */ |
|
| 86 | - $flux['data']['_hidden'] .= "<input type='hidden' name='autosave' class='autosaveactive' value='$cle_autosave' />" |
|
| 87 | - . '<script type="text/javascript">/*<![CDATA[*/if (window.jQuery) jQuery(function(){ |
|
| 83 | + /** |
|
| 84 | + * Envoyer le input hidden et le bout de js qui l'utilisera |
|
| 85 | + */ |
|
| 86 | + $flux['data']['_hidden'] .= "<input type='hidden' name='autosave' class='autosaveactive' value='$cle_autosave' />" |
|
| 87 | + . '<script type="text/javascript">/*<![CDATA[*/if (window.jQuery) jQuery(function(){ |
|
| 88 | 88 | $("input.autosaveactive").closest("form:not(.autosaveon)").autosave({url:"' . $GLOBALS['meta']['adresse_site'] . '/"}).addClass("autosaveon"); |
| 89 | 89 | });/*]]>*/</script>'; |
| 90 | - } |
|
| 90 | + } |
|
| 91 | 91 | |
| 92 | - return $flux; |
|
| 92 | + return $flux; |
|
| 93 | 93 | } |
| 94 | 94 | |
| 95 | 95 | /** |
@@ -103,33 +103,33 @@ discard block |
||
| 103 | 103 | * @return array |
| 104 | 104 | */ |
| 105 | 105 | function cvtautosave_formulaire_traiter($flux) { |
| 106 | - // si on poste 'autosave' c'est qu'on n'a plus besoin de sauvegarder : |
|
| 107 | - // on elimine les donnees de la session |
|
| 108 | - if ($cle_autosave = _request('autosave')) { |
|
| 109 | - include_spip('inc/session'); |
|
| 110 | - session_set('session_autosave_' . $cle_autosave, null); |
|
| 111 | - } |
|
| 106 | + // si on poste 'autosave' c'est qu'on n'a plus besoin de sauvegarder : |
|
| 107 | + // on elimine les donnees de la session |
|
| 108 | + if ($cle_autosave = _request('autosave')) { |
|
| 109 | + include_spip('inc/session'); |
|
| 110 | + session_set('session_autosave_' . $cle_autosave, null); |
|
| 111 | + } |
|
| 112 | 112 | |
| 113 | - if (isset($GLOBALS['visiteur_session']) and $GLOBALS['visiteur_session']) { |
|
| 114 | - // delai par defaut avant purge d'un backup de form : 72H |
|
| 115 | - if (!defined('_AUTOSAVE_GB_DELAY')) { |
|
| 116 | - define('_AUTOSAVE_GB_DELAY', 72 * 3600); |
|
| 117 | - } |
|
| 118 | - $time_too_old = time() - _AUTOSAVE_GB_DELAY; |
|
| 119 | - // purger aussi toutes les vieilles autosave |
|
| 120 | - $session = $GLOBALS['visiteur_session']; |
|
| 121 | - foreach ($session as $k => $v) { |
|
| 122 | - if (strncmp($k, 'session_autosave_', 17) == 0) { |
|
| 123 | - $timestamp = 0; |
|
| 124 | - if (preg_match(',&__timestamp=(\d+)$,', $v, $m)) { |
|
| 125 | - $timestamp = intval($m[1]); |
|
| 126 | - } |
|
| 127 | - if ($timestamp < $time_too_old) { |
|
| 128 | - session_set($k, null); |
|
| 129 | - } |
|
| 130 | - } |
|
| 131 | - } |
|
| 132 | - } |
|
| 113 | + if (isset($GLOBALS['visiteur_session']) and $GLOBALS['visiteur_session']) { |
|
| 114 | + // delai par defaut avant purge d'un backup de form : 72H |
|
| 115 | + if (!defined('_AUTOSAVE_GB_DELAY')) { |
|
| 116 | + define('_AUTOSAVE_GB_DELAY', 72 * 3600); |
|
| 117 | + } |
|
| 118 | + $time_too_old = time() - _AUTOSAVE_GB_DELAY; |
|
| 119 | + // purger aussi toutes les vieilles autosave |
|
| 120 | + $session = $GLOBALS['visiteur_session']; |
|
| 121 | + foreach ($session as $k => $v) { |
|
| 122 | + if (strncmp($k, 'session_autosave_', 17) == 0) { |
|
| 123 | + $timestamp = 0; |
|
| 124 | + if (preg_match(',&__timestamp=(\d+)$,', $v, $m)) { |
|
| 125 | + $timestamp = intval($m[1]); |
|
| 126 | + } |
|
| 127 | + if ($timestamp < $time_too_old) { |
|
| 128 | + session_set($k, null); |
|
| 129 | + } |
|
| 130 | + } |
|
| 131 | + } |
|
| 132 | + } |
|
| 133 | 133 | |
| 134 | - return $flux; |
|
| 134 | + return $flux; |
|
| 135 | 135 | } |
@@ -47,15 +47,15 @@ discard block |
||
| 47 | 47 | $je_suis_poste = $flux['args']['je_suis_poste']; |
| 48 | 48 | |
| 49 | 49 | $cle_autosave = serialize($cle_autosave); |
| 50 | - $cle_autosave = $form . '_' . md5($cle_autosave); |
|
| 50 | + $cle_autosave = $form.'_'.md5($cle_autosave); |
|
| 51 | 51 | |
| 52 | 52 | // si on a un backup en session et qu'on est au premier chargement, non poste |
| 53 | 53 | // on restitue les donnees |
| 54 | 54 | if ( |
| 55 | - isset($GLOBALS['visiteur_session']['session_autosave_' . $cle_autosave]) |
|
| 55 | + isset($GLOBALS['visiteur_session']['session_autosave_'.$cle_autosave]) |
|
| 56 | 56 | and !$je_suis_poste |
| 57 | 57 | ) { |
| 58 | - parse_str($GLOBALS['visiteur_session']['session_autosave_' . $cle_autosave], $vars); |
|
| 58 | + parse_str($GLOBALS['visiteur_session']['session_autosave_'.$cle_autosave], $vars); |
|
| 59 | 59 | foreach ($vars as $key => $val) { |
| 60 | 60 | if (isset($flux['data'][$key])) { |
| 61 | 61 | $flux['data'][$key] = (is_string($val) ? autosave_clean_value($val) : array_map( |
@@ -71,8 +71,8 @@ discard block |
||
| 71 | 71 | if ($je_suis_poste and _request('autosave') === $cle_autosave and function_exists('terminer_actualiser_sessions')) { |
| 72 | 72 | terminer_actualiser_sessions(); |
| 73 | 73 | // et verifions si jamais l'autosave a fait un come back, dans ce cas on le revide |
| 74 | - if (isset($GLOBALS['visiteur_session']['session_autosave_' . $cle_autosave])) { |
|
| 75 | - session_set('session_autosave_' . $cle_autosave, null); |
|
| 74 | + if (isset($GLOBALS['visiteur_session']['session_autosave_'.$cle_autosave])) { |
|
| 75 | + session_set('session_autosave_'.$cle_autosave, null); |
|
| 76 | 76 | // en court sleep pour etre certain que la concurrence est finie |
| 77 | 77 | sleep(1); |
| 78 | 78 | terminer_actualiser_sessions(); |
@@ -85,7 +85,7 @@ discard block |
||
| 85 | 85 | */ |
| 86 | 86 | $flux['data']['_hidden'] .= "<input type='hidden' name='autosave' class='autosaveactive' value='$cle_autosave' />" |
| 87 | 87 | . '<script type="text/javascript">/*<![CDATA[*/if (window.jQuery) jQuery(function(){ |
| 88 | - $("input.autosaveactive").closest("form:not(.autosaveon)").autosave({url:"' . $GLOBALS['meta']['adresse_site'] . '/"}).addClass("autosaveon"); |
|
| 88 | + $("input.autosaveactive").closest("form:not(.autosaveon)").autosave({url:"' . $GLOBALS['meta']['adresse_site'].'/"}).addClass("autosaveon"); |
|
| 89 | 89 | });/*]]>*/</script>'; |
| 90 | 90 | } |
| 91 | 91 | |
@@ -107,7 +107,7 @@ discard block |
||
| 107 | 107 | // on elimine les donnees de la session |
| 108 | 108 | if ($cle_autosave = _request('autosave')) { |
| 109 | 109 | include_spip('inc/session'); |
| 110 | - session_set('session_autosave_' . $cle_autosave, null); |
|
| 110 | + session_set('session_autosave_'.$cle_autosave, null); |
|
| 111 | 111 | } |
| 112 | 112 | |
| 113 | 113 | if (isset($GLOBALS['visiteur_session']) and $GLOBALS['visiteur_session']) { |
@@ -150,7 +150,7 @@ discard block |
||
| 150 | 150 | $role = $roles['roles']['defaut']; |
| 151 | 151 | } |
| 152 | 152 | // where |
| 153 | - $cond = ["$colonne_role=" . sql_quote($role)]; |
|
| 153 | + $cond = ["$colonne_role=".sql_quote($role)]; |
|
| 154 | 154 | } |
| 155 | 155 | |
| 156 | 156 | return [$role, $colonne_role, $cond]; |
@@ -185,7 +185,7 @@ discard block |
||
| 185 | 185 | if ($colonne_role) { |
| 186 | 186 | // on ajoute la condition du role aux autres conditions. |
| 187 | 187 | if ($role != '*') { |
| 188 | - $cond[] = "$colonne_role=" . sql_quote($role); |
|
| 188 | + $cond[] = "$colonne_role=".sql_quote($role); |
|
| 189 | 189 | } |
| 190 | 190 | } |
| 191 | 191 | |
@@ -369,7 +369,7 @@ discard block |
||
| 369 | 369 | $all = sql_allfetsel( |
| 370 | 370 | "DISTINCT $colone_role", |
| 371 | 371 | $l, |
| 372 | - 'objet=' . sql_quote(($objet_source == $objet_lien) ? $objet : $objet_source) |
|
| 372 | + 'objet='.sql_quote(($objet_source == $objet_lien) ? $objet : $objet_source) |
|
| 373 | 373 | ); |
| 374 | 374 | $done[$hash] = array_map('reset', $all); |
| 375 | 375 | |
@@ -28,7 +28,7 @@ discard block |
||
| 28 | 28 | */ |
| 29 | 29 | |
| 30 | 30 | if (!defined('_ECRIRE_INC_VERSION')) { |
| 31 | - return; |
|
| 31 | + return; |
|
| 32 | 32 | } |
| 33 | 33 | |
| 34 | 34 | |
@@ -48,55 +48,55 @@ discard block |
||
| 48 | 48 | * array : description des roles applicables dans 3 index : colonne, titres, roles |
| 49 | 49 | **/ |
| 50 | 50 | function roles_presents($objet, $objet_destination = '') { |
| 51 | - $desc = lister_tables_objets_sql(table_objet_sql($objet)); |
|
| 52 | - |
|
| 53 | - // pas de liste de roles, on sort |
|
| 54 | - if (!isset($desc['roles_titres']) or !($titres = $desc['roles_titres'])) { |
|
| 55 | - return false; |
|
| 56 | - } |
|
| 57 | - |
|
| 58 | - // on vérifie que la table de liaison existe |
|
| 59 | - include_spip('action/editer_liens'); |
|
| 60 | - if (!$lien = objet_associable($objet)) { |
|
| 61 | - return false; |
|
| 62 | - } |
|
| 63 | - |
|
| 64 | - // on cherche ensuite si la colonne existe bien dans la table de liaison (par défaut 'role') |
|
| 65 | - $colonne = $desc['roles_colonne'] ?? 'role'; |
|
| 66 | - $trouver_table = charger_fonction('trouver_table', 'base'); |
|
| 67 | - [, $table_lien] = $lien; |
|
| 68 | - $desc_lien = $trouver_table($table_lien); |
|
| 69 | - if (!isset($desc_lien['field'][$colonne])) { |
|
| 70 | - return false; |
|
| 71 | - } |
|
| 72 | - |
|
| 73 | - // sur quoi peuvent s'appliquer nos rôles |
|
| 74 | - if (!$application = $desc['roles_objets']) { |
|
| 75 | - return false; |
|
| 76 | - } |
|
| 77 | - |
|
| 78 | - // destination presente, on restreint si possible |
|
| 79 | - if ($objet_destination) { |
|
| 80 | - $objet_destination = table_objet($objet_destination); |
|
| 81 | - |
|
| 82 | - // pour l'objet |
|
| 83 | - if (isset($application[$objet_destination])) { |
|
| 84 | - $application = $application[$objet_destination]; |
|
| 85 | - // sinon pour tous les objets |
|
| 86 | - } elseif (isset($application['*'])) { |
|
| 87 | - $application = $application['*']; |
|
| 88 | - } // sinon tant pis |
|
| 89 | - else { |
|
| 90 | - return false; |
|
| 91 | - } |
|
| 92 | - } |
|
| 93 | - |
|
| 94 | - // tout est ok |
|
| 95 | - return [ |
|
| 96 | - 'titres' => $titres, |
|
| 97 | - 'roles' => $application, |
|
| 98 | - 'colonne' => $colonne |
|
| 99 | - ]; |
|
| 51 | + $desc = lister_tables_objets_sql(table_objet_sql($objet)); |
|
| 52 | + |
|
| 53 | + // pas de liste de roles, on sort |
|
| 54 | + if (!isset($desc['roles_titres']) or !($titres = $desc['roles_titres'])) { |
|
| 55 | + return false; |
|
| 56 | + } |
|
| 57 | + |
|
| 58 | + // on vérifie que la table de liaison existe |
|
| 59 | + include_spip('action/editer_liens'); |
|
| 60 | + if (!$lien = objet_associable($objet)) { |
|
| 61 | + return false; |
|
| 62 | + } |
|
| 63 | + |
|
| 64 | + // on cherche ensuite si la colonne existe bien dans la table de liaison (par défaut 'role') |
|
| 65 | + $colonne = $desc['roles_colonne'] ?? 'role'; |
|
| 66 | + $trouver_table = charger_fonction('trouver_table', 'base'); |
|
| 67 | + [, $table_lien] = $lien; |
|
| 68 | + $desc_lien = $trouver_table($table_lien); |
|
| 69 | + if (!isset($desc_lien['field'][$colonne])) { |
|
| 70 | + return false; |
|
| 71 | + } |
|
| 72 | + |
|
| 73 | + // sur quoi peuvent s'appliquer nos rôles |
|
| 74 | + if (!$application = $desc['roles_objets']) { |
|
| 75 | + return false; |
|
| 76 | + } |
|
| 77 | + |
|
| 78 | + // destination presente, on restreint si possible |
|
| 79 | + if ($objet_destination) { |
|
| 80 | + $objet_destination = table_objet($objet_destination); |
|
| 81 | + |
|
| 82 | + // pour l'objet |
|
| 83 | + if (isset($application[$objet_destination])) { |
|
| 84 | + $application = $application[$objet_destination]; |
|
| 85 | + // sinon pour tous les objets |
|
| 86 | + } elseif (isset($application['*'])) { |
|
| 87 | + $application = $application['*']; |
|
| 88 | + } // sinon tant pis |
|
| 89 | + else { |
|
| 90 | + return false; |
|
| 91 | + } |
|
| 92 | + } |
|
| 93 | + |
|
| 94 | + // tout est ok |
|
| 95 | + return [ |
|
| 96 | + 'titres' => $titres, |
|
| 97 | + 'roles' => $application, |
|
| 98 | + 'colonne' => $colonne |
|
| 99 | + ]; |
|
| 100 | 100 | } |
| 101 | 101 | |
| 102 | 102 | /** |
@@ -110,11 +110,11 @@ discard block |
||
| 110 | 110 | * Nom de la colonne, sinon vide |
| 111 | 111 | **/ |
| 112 | 112 | function roles_colonne($objet, $objet_destination) { |
| 113 | - if ($roles = roles_presents($objet, $objet_destination)) { |
|
| 114 | - return $roles['colonne']; |
|
| 115 | - } |
|
| 113 | + if ($roles = roles_presents($objet, $objet_destination)) { |
|
| 114 | + return $roles['colonne']; |
|
| 115 | + } |
|
| 116 | 116 | |
| 117 | - return ''; |
|
| 117 | + return ''; |
|
| 118 | 118 | } |
| 119 | 119 | |
| 120 | 120 | |
@@ -136,24 +136,24 @@ discard block |
||
| 136 | 136 | * Liste ('', '', array()) sinon. |
| 137 | 137 | **/ |
| 138 | 138 | function roles_trouver_dans_qualif($objet, $objet_destination, $qualif = []) { |
| 139 | - // si des rôles sont possibles, on les utilise |
|
| 140 | - $role = $colonne_role = ''; # role défini |
|
| 141 | - // condition du where par defaut |
|
| 142 | - $cond = []; |
|
| 143 | - if ($roles = roles_presents($objet, $objet_destination)) { |
|
| 144 | - $colonne_role = $roles['colonne']; |
|
| 145 | - // qu'il n'est pas défini |
|
| 146 | - if ( |
|
| 147 | - !isset($qualif[$colonne_role]) |
|
| 148 | - or !($role = $qualif[$colonne_role]) |
|
| 149 | - ) { |
|
| 150 | - $role = $roles['roles']['defaut']; |
|
| 151 | - } |
|
| 152 | - // where |
|
| 153 | - $cond = ["$colonne_role=" . sql_quote($role)]; |
|
| 154 | - } |
|
| 155 | - |
|
| 156 | - return [$role, $colonne_role, $cond]; |
|
| 139 | + // si des rôles sont possibles, on les utilise |
|
| 140 | + $role = $colonne_role = ''; # role défini |
|
| 141 | + // condition du where par defaut |
|
| 142 | + $cond = []; |
|
| 143 | + if ($roles = roles_presents($objet, $objet_destination)) { |
|
| 144 | + $colonne_role = $roles['colonne']; |
|
| 145 | + // qu'il n'est pas défini |
|
| 146 | + if ( |
|
| 147 | + !isset($qualif[$colonne_role]) |
|
| 148 | + or !($role = $qualif[$colonne_role]) |
|
| 149 | + ) { |
|
| 150 | + $role = $roles['roles']['defaut']; |
|
| 151 | + } |
|
| 152 | + // where |
|
| 153 | + $cond = ["$colonne_role=" . sql_quote($role)]; |
|
| 154 | + } |
|
| 155 | + |
|
| 156 | + return [$role, $colonne_role, $cond]; |
|
| 157 | 157 | } |
| 158 | 158 | |
| 159 | 159 | /** |
@@ -175,21 +175,21 @@ discard block |
||
| 175 | 175 | * Liste (Tableau de conditions where complété du role, Colonne du role, role utilisé) |
| 176 | 176 | **/ |
| 177 | 177 | function roles_creer_condition_role($objet_source, $objet, $cond, $tous_si_absent = false) { |
| 178 | - // role par défaut, colonne |
|
| 179 | - [$role_defaut, $colonne_role] = roles_trouver_dans_qualif($objet_source, $objet); |
|
| 178 | + // role par défaut, colonne |
|
| 179 | + [$role_defaut, $colonne_role] = roles_trouver_dans_qualif($objet_source, $objet); |
|
| 180 | 180 | |
| 181 | - // chercher d'eventuels rôles transmis |
|
| 182 | - $role = ($cond['role'] ?? ($tous_si_absent ? '*' : $role_defaut)); |
|
| 183 | - unset($cond['role']); // cette condition est particuliere... |
|
| 181 | + // chercher d'eventuels rôles transmis |
|
| 182 | + $role = ($cond['role'] ?? ($tous_si_absent ? '*' : $role_defaut)); |
|
| 183 | + unset($cond['role']); // cette condition est particuliere... |
|
| 184 | 184 | |
| 185 | - if ($colonne_role) { |
|
| 186 | - // on ajoute la condition du role aux autres conditions. |
|
| 187 | - if ($role != '*') { |
|
| 188 | - $cond[] = "$colonne_role=" . sql_quote($role); |
|
| 189 | - } |
|
| 190 | - } |
|
| 185 | + if ($colonne_role) { |
|
| 186 | + // on ajoute la condition du role aux autres conditions. |
|
| 187 | + if ($role != '*') { |
|
| 188 | + $cond[] = "$colonne_role=" . sql_quote($role); |
|
| 189 | + } |
|
| 190 | + } |
|
| 191 | 191 | |
| 192 | - return [$cond, $colonne_role, $role]; |
|
| 192 | + return [$cond, $colonne_role, $role]; |
|
| 193 | 193 | } |
| 194 | 194 | |
| 195 | 195 | /** |
@@ -211,28 +211,28 @@ discard block |
||
| 211 | 211 | */ |
| 212 | 212 | function roles_complets($objet_source, $objet, $id_objet, $objet_lien) { |
| 213 | 213 | |
| 214 | - $presents = roles_presents_liaisons($objet_source, $objet, $id_objet, $objet_lien); |
|
| 215 | - // pas de roles sur ces objets => la liste par defaut, comme sans role |
|
| 216 | - if ($presents === false) { |
|
| 217 | - return lister_objets_lies($objet_source, $objet, $id_objet, $objet_lien); |
|
| 218 | - } |
|
| 219 | - |
|
| 220 | - // types de roles possibles |
|
| 221 | - $roles_possibles = $presents['roles']['roles']['choix']; |
|
| 222 | - // couples id / roles |
|
| 223 | - $ids = $presents['ids']; |
|
| 224 | - |
|
| 225 | - // pour chaque groupe, on fait le diff entre tous les roles possibles |
|
| 226 | - // et les roles attribués à l'élément : s'il en reste, c'est que l'élément |
|
| 227 | - // n'est pas complet |
|
| 228 | - $complets = []; |
|
| 229 | - foreach ($ids as $id => $roles_presents) { |
|
| 230 | - if (!array_diff($roles_possibles, $roles_presents)) { |
|
| 231 | - $complets[] = $id; |
|
| 232 | - } |
|
| 233 | - } |
|
| 234 | - |
|
| 235 | - return $complets; |
|
| 214 | + $presents = roles_presents_liaisons($objet_source, $objet, $id_objet, $objet_lien); |
|
| 215 | + // pas de roles sur ces objets => la liste par defaut, comme sans role |
|
| 216 | + if ($presents === false) { |
|
| 217 | + return lister_objets_lies($objet_source, $objet, $id_objet, $objet_lien); |
|
| 218 | + } |
|
| 219 | + |
|
| 220 | + // types de roles possibles |
|
| 221 | + $roles_possibles = $presents['roles']['roles']['choix']; |
|
| 222 | + // couples id / roles |
|
| 223 | + $ids = $presents['ids']; |
|
| 224 | + |
|
| 225 | + // pour chaque groupe, on fait le diff entre tous les roles possibles |
|
| 226 | + // et les roles attribués à l'élément : s'il en reste, c'est que l'élément |
|
| 227 | + // n'est pas complet |
|
| 228 | + $complets = []; |
|
| 229 | + foreach ($ids as $id => $roles_presents) { |
|
| 230 | + if (!array_diff($roles_possibles, $roles_presents)) { |
|
| 231 | + $complets[] = $id; |
|
| 232 | + } |
|
| 233 | + } |
|
| 234 | + |
|
| 235 | + return $complets; |
|
| 236 | 236 | } |
| 237 | 237 | |
| 238 | 238 | |
@@ -249,17 +249,17 @@ discard block |
||
| 249 | 249 | */ |
| 250 | 250 | function roles_presents_sur_id($id_objet_source, $objet_source, $objet, $id_objet, $objet_lien) { |
| 251 | 251 | |
| 252 | - $presents = roles_presents_liaisons($objet_source, $objet, $id_objet, $objet_lien); |
|
| 253 | - // pas de roles sur ces objets => la liste par defaut, comme sans role |
|
| 254 | - if ($presents === false) { |
|
| 255 | - return []; |
|
| 256 | - } |
|
| 252 | + $presents = roles_presents_liaisons($objet_source, $objet, $id_objet, $objet_lien); |
|
| 253 | + // pas de roles sur ces objets => la liste par defaut, comme sans role |
|
| 254 | + if ($presents === false) { |
|
| 255 | + return []; |
|
| 256 | + } |
|
| 257 | 257 | |
| 258 | - if (!isset($presents['ids'][$id_objet_source])) { |
|
| 259 | - return []; |
|
| 260 | - } |
|
| 258 | + if (!isset($presents['ids'][$id_objet_source])) { |
|
| 259 | + return []; |
|
| 260 | + } |
|
| 261 | 261 | |
| 262 | - return $presents['ids'][$id_objet_source]; |
|
| 262 | + return $presents['ids'][$id_objet_source]; |
|
| 263 | 263 | } |
| 264 | 264 | |
| 265 | 265 | |
@@ -287,47 +287,47 @@ discard block |
||
| 287 | 287 | * - False si pas de role déclarés |
| 288 | 288 | */ |
| 289 | 289 | function roles_presents_liaisons($objet_source, $objet, $id_objet, $objet_lien) { |
| 290 | - static $done = []; |
|
| 291 | - |
|
| 292 | - // stocker le résultat |
|
| 293 | - $hash = "$objet_source-$objet-$id_objet-$objet_lien"; |
|
| 294 | - if (isset($done[$hash])) { |
|
| 295 | - return $done[$hash]; |
|
| 296 | - } |
|
| 297 | - |
|
| 298 | - // pas de roles sur ces objets, on sort |
|
| 299 | - $roles = roles_presents($objet_lien, ($objet_lien == $objet) ? $objet_source : $objet); |
|
| 300 | - if (!$roles) { |
|
| 301 | - return $done[$hash] = false; |
|
| 302 | - } |
|
| 303 | - |
|
| 304 | - // inspiré de lister_objets_lies() |
|
| 305 | - if ($objet_lien == $objet) { |
|
| 306 | - $res = objet_trouver_liens([$objet => $id_objet], [$objet_source => '*']); |
|
| 307 | - } else { |
|
| 308 | - $res = objet_trouver_liens([$objet_source => '*'], [$objet => $id_objet]); |
|
| 309 | - } |
|
| 310 | - |
|
| 311 | - // types de roles possibles |
|
| 312 | - $roles_possibles = $roles['roles']['choix']; |
|
| 313 | - // colonne du role |
|
| 314 | - $colonne = $roles['colonne']; |
|
| 315 | - |
|
| 316 | - // on recupere par id, et role existant |
|
| 317 | - $ids = []; |
|
| 318 | - while ($row = array_shift($res)) { |
|
| 319 | - $id = $row[$objet_source]; |
|
| 320 | - if (!isset($ids[$id])) { |
|
| 321 | - $ids[$id] = []; |
|
| 322 | - } |
|
| 323 | - // tableau des roles présents |
|
| 324 | - $ids[$id][] = $row[$colonne]; |
|
| 325 | - } |
|
| 326 | - |
|
| 327 | - return $done[$hash] = [ |
|
| 328 | - 'roles' => $roles, |
|
| 329 | - 'ids' => $ids |
|
| 330 | - ]; |
|
| 290 | + static $done = []; |
|
| 291 | + |
|
| 292 | + // stocker le résultat |
|
| 293 | + $hash = "$objet_source-$objet-$id_objet-$objet_lien"; |
|
| 294 | + if (isset($done[$hash])) { |
|
| 295 | + return $done[$hash]; |
|
| 296 | + } |
|
| 297 | + |
|
| 298 | + // pas de roles sur ces objets, on sort |
|
| 299 | + $roles = roles_presents($objet_lien, ($objet_lien == $objet) ? $objet_source : $objet); |
|
| 300 | + if (!$roles) { |
|
| 301 | + return $done[$hash] = false; |
|
| 302 | + } |
|
| 303 | + |
|
| 304 | + // inspiré de lister_objets_lies() |
|
| 305 | + if ($objet_lien == $objet) { |
|
| 306 | + $res = objet_trouver_liens([$objet => $id_objet], [$objet_source => '*']); |
|
| 307 | + } else { |
|
| 308 | + $res = objet_trouver_liens([$objet_source => '*'], [$objet => $id_objet]); |
|
| 309 | + } |
|
| 310 | + |
|
| 311 | + // types de roles possibles |
|
| 312 | + $roles_possibles = $roles['roles']['choix']; |
|
| 313 | + // colonne du role |
|
| 314 | + $colonne = $roles['colonne']; |
|
| 315 | + |
|
| 316 | + // on recupere par id, et role existant |
|
| 317 | + $ids = []; |
|
| 318 | + while ($row = array_shift($res)) { |
|
| 319 | + $id = $row[$objet_source]; |
|
| 320 | + if (!isset($ids[$id])) { |
|
| 321 | + $ids[$id] = []; |
|
| 322 | + } |
|
| 323 | + // tableau des roles présents |
|
| 324 | + $ids[$id][] = $row[$colonne]; |
|
| 325 | + } |
|
| 326 | + |
|
| 327 | + return $done[$hash] = [ |
|
| 328 | + 'roles' => $roles, |
|
| 329 | + 'ids' => $ids |
|
| 330 | + ]; |
|
| 331 | 331 | } |
| 332 | 332 | |
| 333 | 333 | |
@@ -345,33 +345,33 @@ discard block |
||
| 345 | 345 | * - false si pas de role déclarés |
| 346 | 346 | */ |
| 347 | 347 | function roles_connus_en_base($objet_source, $objet, $objet_lien) { |
| 348 | - static $done = []; |
|
| 349 | - |
|
| 350 | - // stocker le résultat |
|
| 351 | - $hash = "$objet_source-$objet-$objet_lien"; |
|
| 352 | - if (isset($done[$hash])) { |
|
| 353 | - return $done[$hash]; |
|
| 354 | - } |
|
| 355 | - |
|
| 356 | - if (!$lien = objet_associable($objet_lien)) { |
|
| 357 | - return $done[$hash] = false; |
|
| 358 | - } |
|
| 359 | - |
|
| 360 | - // pas de roles sur ces objets, on sort |
|
| 361 | - $roles = roles_presents($objet_lien, ($objet_lien == $objet) ? $objet_source : $objet); |
|
| 362 | - if (!$roles) { |
|
| 363 | - return $done[$hash] = false; |
|
| 364 | - } |
|
| 365 | - |
|
| 366 | - [$primary, $l] = $lien; |
|
| 367 | - $colone_role = $roles['colonne']; |
|
| 368 | - |
|
| 369 | - $all = sql_allfetsel( |
|
| 370 | - "DISTINCT $colone_role", |
|
| 371 | - $l, |
|
| 372 | - 'objet=' . sql_quote(($objet_source == $objet_lien) ? $objet : $objet_source) |
|
| 373 | - ); |
|
| 374 | - $done[$hash] = array_map('reset', $all); |
|
| 375 | - |
|
| 376 | - return $done[$hash]; |
|
| 348 | + static $done = []; |
|
| 349 | + |
|
| 350 | + // stocker le résultat |
|
| 351 | + $hash = "$objet_source-$objet-$objet_lien"; |
|
| 352 | + if (isset($done[$hash])) { |
|
| 353 | + return $done[$hash]; |
|
| 354 | + } |
|
| 355 | + |
|
| 356 | + if (!$lien = objet_associable($objet_lien)) { |
|
| 357 | + return $done[$hash] = false; |
|
| 358 | + } |
|
| 359 | + |
|
| 360 | + // pas de roles sur ces objets, on sort |
|
| 361 | + $roles = roles_presents($objet_lien, ($objet_lien == $objet) ? $objet_source : $objet); |
|
| 362 | + if (!$roles) { |
|
| 363 | + return $done[$hash] = false; |
|
| 364 | + } |
|
| 365 | + |
|
| 366 | + [$primary, $l] = $lien; |
|
| 367 | + $colone_role = $roles['colonne']; |
|
| 368 | + |
|
| 369 | + $all = sql_allfetsel( |
|
| 370 | + "DISTINCT $colone_role", |
|
| 371 | + $l, |
|
| 372 | + 'objet=' . sql_quote(($objet_source == $objet_lien) ? $objet : $objet_source) |
|
| 373 | + ); |
|
| 374 | + $done[$hash] = array_map('reset', $all); |
|
| 375 | + |
|
| 376 | + return $done[$hash]; |
|
| 377 | 377 | } |
@@ -364,8 +364,7 @@ discard block |
||
| 364 | 364 | } |
| 365 | 365 | if (!isset($regs[2])) { |
| 366 | 366 | $niveau = _LOG_INFO; |
| 367 | - } |
|
| 368 | - else { |
|
| 367 | + } else { |
|
| 369 | 368 | $niveau = intval($regs[2]); |
| 370 | 369 | } |
| 371 | 370 | |
@@ -1475,8 +1474,7 @@ discard block |
||
| 1475 | 1474 | ) { |
| 1476 | 1475 | if ($fsize = substr($f, 0, -6) . $m[1] . '.svg' and file_exists($fsize)) { |
| 1477 | 1476 | return $themefiles["$subdir$file"] = $fsize; |
| 1478 | - } |
|
| 1479 | - else { |
|
| 1477 | + } else { |
|
| 1480 | 1478 | return $themefiles["$subdir$file"] = "$f?" . $m[1] . 'px'; |
| 1481 | 1479 | } |
| 1482 | 1480 | } |
@@ -3496,8 +3494,7 @@ discard block |
||
| 3496 | 3494 | if (!in_array('svg', $formats)) { |
| 3497 | 3495 | $formats[] = 'svg'; |
| 3498 | 3496 | } |
| 3499 | - } |
|
| 3500 | - else { |
|
| 3497 | + } else { |
|
| 3501 | 3498 | $formats = array_diff($formats, ['svg']); |
| 3502 | 3499 | } |
| 3503 | 3500 | return $formats; |
@@ -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 | |
@@ -48,66 +48,66 @@ discard block |
||
| 48 | 48 | * Nom de la fonction, ou false. |
| 49 | 49 | */ |
| 50 | 50 | function charger_fonction($nom, $dossier = 'exec', $continue = false) { |
| 51 | - static $echecs = []; |
|
| 52 | - |
|
| 53 | - if (strlen($dossier) and substr($dossier, -1) != '/') { |
|
| 54 | - $dossier .= '/'; |
|
| 55 | - } |
|
| 56 | - $f = str_replace('/', '_', $dossier) . $nom; |
|
| 57 | - |
|
| 58 | - if (function_exists($f)) { |
|
| 59 | - return $f; |
|
| 60 | - } |
|
| 61 | - if (function_exists($g = $f . '_dist')) { |
|
| 62 | - return $g; |
|
| 63 | - } |
|
| 64 | - |
|
| 65 | - if (isset($echecs[$f])) { |
|
| 66 | - return $echecs[$f]; |
|
| 67 | - } |
|
| 68 | - // Sinon charger le fichier de declaration si plausible |
|
| 69 | - |
|
| 70 | - if (!preg_match(',^\w+$,', $f)) { |
|
| 71 | - if ($continue) { |
|
| 72 | - return false; |
|
| 73 | - } //appel interne, on passe |
|
| 74 | - include_spip('inc/minipres'); |
|
| 75 | - echo minipres(); |
|
| 76 | - exit; |
|
| 77 | - } |
|
| 78 | - |
|
| 79 | - // passer en minuscules (cf les balises de formulaires) |
|
| 80 | - // et inclure le fichier |
|
| 81 | - if ( |
|
| 82 | - !$inc = include_spip($dossier . ($d = strtolower($nom))) |
|
| 83 | - // si le fichier truc/machin/nom.php n'existe pas, |
|
| 84 | - // la fonction peut etre definie dans truc/machin.php qui regroupe plusieurs petites fonctions |
|
| 85 | - and strlen(dirname($dossier)) and dirname($dossier) != '.' |
|
| 86 | - ) { |
|
| 87 | - include_spip(substr($dossier, 0, -1)); |
|
| 88 | - } |
|
| 89 | - if (function_exists($f)) { |
|
| 90 | - return $f; |
|
| 91 | - } |
|
| 92 | - if (function_exists($g)) { |
|
| 93 | - return $g; |
|
| 94 | - } |
|
| 95 | - |
|
| 96 | - if ($continue) { |
|
| 97 | - return $echecs[$f] = false; |
|
| 98 | - } |
|
| 99 | - |
|
| 100 | - // Echec : message d'erreur |
|
| 101 | - spip_log("fonction $nom ($f ou $g) indisponible" . |
|
| 102 | - ($inc ? '' : " (fichier $d absent de $dossier)")); |
|
| 103 | - |
|
| 104 | - include_spip('inc/minipres'); |
|
| 105 | - echo minipres( |
|
| 106 | - _T('forum_titre_erreur'), |
|
| 107 | - _T('fichier_introuvable', ['fichier' => '<b>' . spip_htmlentities($d) . '</b>']), |
|
| 108 | - ['all_inline' => true,'status' => 404] |
|
| 109 | - ); |
|
| 110 | - exit; |
|
| 51 | + static $echecs = []; |
|
| 52 | + |
|
| 53 | + if (strlen($dossier) and substr($dossier, -1) != '/') { |
|
| 54 | + $dossier .= '/'; |
|
| 55 | + } |
|
| 56 | + $f = str_replace('/', '_', $dossier) . $nom; |
|
| 57 | + |
|
| 58 | + if (function_exists($f)) { |
|
| 59 | + return $f; |
|
| 60 | + } |
|
| 61 | + if (function_exists($g = $f . '_dist')) { |
|
| 62 | + return $g; |
|
| 63 | + } |
|
| 64 | + |
|
| 65 | + if (isset($echecs[$f])) { |
|
| 66 | + return $echecs[$f]; |
|
| 67 | + } |
|
| 68 | + // Sinon charger le fichier de declaration si plausible |
|
| 69 | + |
|
| 70 | + if (!preg_match(',^\w+$,', $f)) { |
|
| 71 | + if ($continue) { |
|
| 72 | + return false; |
|
| 73 | + } //appel interne, on passe |
|
| 74 | + include_spip('inc/minipres'); |
|
| 75 | + echo minipres(); |
|
| 76 | + exit; |
|
| 77 | + } |
|
| 78 | + |
|
| 79 | + // passer en minuscules (cf les balises de formulaires) |
|
| 80 | + // et inclure le fichier |
|
| 81 | + if ( |
|
| 82 | + !$inc = include_spip($dossier . ($d = strtolower($nom))) |
|
| 83 | + // si le fichier truc/machin/nom.php n'existe pas, |
|
| 84 | + // la fonction peut etre definie dans truc/machin.php qui regroupe plusieurs petites fonctions |
|
| 85 | + and strlen(dirname($dossier)) and dirname($dossier) != '.' |
|
| 86 | + ) { |
|
| 87 | + include_spip(substr($dossier, 0, -1)); |
|
| 88 | + } |
|
| 89 | + if (function_exists($f)) { |
|
| 90 | + return $f; |
|
| 91 | + } |
|
| 92 | + if (function_exists($g)) { |
|
| 93 | + return $g; |
|
| 94 | + } |
|
| 95 | + |
|
| 96 | + if ($continue) { |
|
| 97 | + return $echecs[$f] = false; |
|
| 98 | + } |
|
| 99 | + |
|
| 100 | + // Echec : message d'erreur |
|
| 101 | + spip_log("fonction $nom ($f ou $g) indisponible" . |
|
| 102 | + ($inc ? '' : " (fichier $d absent de $dossier)")); |
|
| 103 | + |
|
| 104 | + include_spip('inc/minipres'); |
|
| 105 | + echo minipres( |
|
| 106 | + _T('forum_titre_erreur'), |
|
| 107 | + _T('fichier_introuvable', ['fichier' => '<b>' . spip_htmlentities($d) . '</b>']), |
|
| 108 | + ['all_inline' => true,'status' => 404] |
|
| 109 | + ); |
|
| 110 | + exit; |
|
| 111 | 111 | } |
| 112 | 112 | |
| 113 | 113 | /** |
@@ -117,17 +117,17 @@ discard block |
||
| 117 | 117 | * @return bool |
| 118 | 118 | */ |
| 119 | 119 | function include_once_check($file) { |
| 120 | - if (file_exists($file)) { |
|
| 121 | - include_once $file; |
|
| 120 | + if (file_exists($file)) { |
|
| 121 | + include_once $file; |
|
| 122 | 122 | |
| 123 | - return true; |
|
| 124 | - } |
|
| 125 | - $crash = (isset($GLOBALS['meta']['message_crash_plugins']) ? unserialize($GLOBALS['meta']['message_crash_plugins']) : ''); |
|
| 126 | - $crash = ($crash ?: []); |
|
| 127 | - $crash[$file] = true; |
|
| 128 | - ecrire_meta('message_crash_plugins', serialize($crash)); |
|
| 123 | + return true; |
|
| 124 | + } |
|
| 125 | + $crash = (isset($GLOBALS['meta']['message_crash_plugins']) ? unserialize($GLOBALS['meta']['message_crash_plugins']) : ''); |
|
| 126 | + $crash = ($crash ?: []); |
|
| 127 | + $crash[$file] = true; |
|
| 128 | + ecrire_meta('message_crash_plugins', serialize($crash)); |
|
| 129 | 129 | |
| 130 | - return false; |
|
| 130 | + return false; |
|
| 131 | 131 | } |
| 132 | 132 | |
| 133 | 133 | |
@@ -151,7 +151,7 @@ discard block |
||
| 151 | 151 | * - string : chemin du fichier trouvé |
| 152 | 152 | **/ |
| 153 | 153 | function include_spip($f, $include = true) { |
| 154 | - return find_in_path($f . '.php', '', $include); |
|
| 154 | + return find_in_path($f . '.php', '', $include); |
|
| 155 | 155 | } |
| 156 | 156 | |
| 157 | 157 | /** |
@@ -171,7 +171,7 @@ discard block |
||
| 171 | 171 | * - string : chemin du fichier trouvé |
| 172 | 172 | **/ |
| 173 | 173 | function require_spip($f) { |
| 174 | - return find_in_path($f . '.php', '', 'required'); |
|
| 174 | + return find_in_path($f . '.php', '', 'required'); |
|
| 175 | 175 | } |
| 176 | 176 | |
| 177 | 177 | |
@@ -180,27 +180,27 @@ discard block |
||
| 180 | 180 | * quand on a besoin dans le PHP de filtres/fonctions qui y sont definis |
| 181 | 181 | */ |
| 182 | 182 | function include_fichiers_fonctions() { |
| 183 | - static $done = false; |
|
| 184 | - if (!$done) { |
|
| 185 | - include_spip('inc/lang'); |
|
| 186 | - |
|
| 187 | - // NB: mes_fonctions peut initialiser $dossier_squelettes (old-style) |
|
| 188 | - // donc il faut l'inclure "en globals" |
|
| 189 | - if ($f = find_in_path('mes_fonctions.php')) { |
|
| 190 | - global $dossier_squelettes; |
|
| 191 | - include_once(_ROOT_CWD . $f); |
|
| 192 | - } |
|
| 193 | - |
|
| 194 | - if (@is_readable(_CACHE_PLUGINS_FCT)) { |
|
| 195 | - // chargement optimise precompile |
|
| 196 | - include_once(_CACHE_PLUGINS_FCT); |
|
| 197 | - } |
|
| 198 | - if (test_espace_prive()) { |
|
| 199 | - include_spip('inc/filtres_ecrire'); |
|
| 200 | - } |
|
| 201 | - include_spip('public/fonctions'); // charger les fichiers fonctions associes aux criteres, balises.. |
|
| 202 | - $done = true; |
|
| 203 | - } |
|
| 183 | + static $done = false; |
|
| 184 | + if (!$done) { |
|
| 185 | + include_spip('inc/lang'); |
|
| 186 | + |
|
| 187 | + // NB: mes_fonctions peut initialiser $dossier_squelettes (old-style) |
|
| 188 | + // donc il faut l'inclure "en globals" |
|
| 189 | + if ($f = find_in_path('mes_fonctions.php')) { |
|
| 190 | + global $dossier_squelettes; |
|
| 191 | + include_once(_ROOT_CWD . $f); |
|
| 192 | + } |
|
| 193 | + |
|
| 194 | + if (@is_readable(_CACHE_PLUGINS_FCT)) { |
|
| 195 | + // chargement optimise precompile |
|
| 196 | + include_once(_CACHE_PLUGINS_FCT); |
|
| 197 | + } |
|
| 198 | + if (test_espace_prive()) { |
|
| 199 | + include_spip('inc/filtres_ecrire'); |
|
| 200 | + } |
|
| 201 | + include_spip('public/fonctions'); // charger les fichiers fonctions associes aux criteres, balises.. |
|
| 202 | + $done = true; |
|
| 203 | + } |
|
| 204 | 204 | } |
| 205 | 205 | |
| 206 | 206 | /** |
@@ -226,23 +226,23 @@ discard block |
||
| 226 | 226 | * Les paramètres du pipeline modifiés |
| 227 | 227 | **/ |
| 228 | 228 | function minipipe($fonc, &$val) { |
| 229 | - // fonction |
|
| 230 | - if (function_exists($fonc)) { |
|
| 231 | - $val = call_user_func($fonc, $val); |
|
| 232 | - } // Class::Methode |
|
| 233 | - else { |
|
| 234 | - if ( |
|
| 235 | - preg_match('/^(\w*)::(\w*)$/S', $fonc, $regs) |
|
| 236 | - and $methode = [$regs[1], $regs[2]] |
|
| 237 | - and is_callable($methode) |
|
| 238 | - ) { |
|
| 239 | - $val = call_user_func($methode, $val); |
|
| 240 | - } else { |
|
| 241 | - spip_log("Erreur - '$fonc' non definie !"); |
|
| 242 | - } |
|
| 243 | - } |
|
| 244 | - |
|
| 245 | - return $val; |
|
| 229 | + // fonction |
|
| 230 | + if (function_exists($fonc)) { |
|
| 231 | + $val = call_user_func($fonc, $val); |
|
| 232 | + } // Class::Methode |
|
| 233 | + else { |
|
| 234 | + if ( |
|
| 235 | + preg_match('/^(\w*)::(\w*)$/S', $fonc, $regs) |
|
| 236 | + and $methode = [$regs[1], $regs[2]] |
|
| 237 | + and is_callable($methode) |
|
| 238 | + ) { |
|
| 239 | + $val = call_user_func($methode, $val); |
|
| 240 | + } else { |
|
| 241 | + spip_log("Erreur - '$fonc' non definie !"); |
|
| 242 | + } |
|
| 243 | + } |
|
| 244 | + |
|
| 245 | + return $val; |
|
| 246 | 246 | } |
| 247 | 247 | |
| 248 | 248 | /** |
@@ -273,46 +273,46 @@ discard block |
||
| 273 | 273 | * Résultat |
| 274 | 274 | */ |
| 275 | 275 | function pipeline($action, $val = null) { |
| 276 | - static $charger; |
|
| 277 | - |
|
| 278 | - // chargement initial des fonctions mises en cache, ou generation du cache |
|
| 279 | - if (!$charger) { |
|
| 280 | - if (!($ok = @is_readable($charger = _CACHE_PIPELINES))) { |
|
| 281 | - include_spip('inc/plugin'); |
|
| 282 | - // generer les fichiers php precompiles |
|
| 283 | - // de chargement des plugins et des pipelines |
|
| 284 | - actualise_plugins_actifs(); |
|
| 285 | - if (!($ok = @is_readable($charger))) { |
|
| 286 | - spip_log("fichier $charger pas cree"); |
|
| 287 | - } |
|
| 288 | - } |
|
| 289 | - |
|
| 290 | - if ($ok) { |
|
| 291 | - include_once $charger; |
|
| 292 | - } |
|
| 293 | - } |
|
| 294 | - |
|
| 295 | - // appliquer notre fonction si elle existe |
|
| 296 | - $fonc = 'execute_pipeline_' . strtolower($action); |
|
| 297 | - if (function_exists($fonc)) { |
|
| 298 | - $val = $fonc($val); |
|
| 299 | - } // plantage ? |
|
| 300 | - else { |
|
| 301 | - spip_log("fonction $fonc absente : pipeline desactive", _LOG_ERREUR); |
|
| 302 | - } |
|
| 303 | - |
|
| 304 | - // si le flux est une table avec 2 cle args&data |
|
| 305 | - // on ne ressort du pipe que les donnees dans 'data' |
|
| 306 | - // array_key_exists pour php 4.1.0 |
|
| 307 | - if ( |
|
| 308 | - is_array($val) |
|
| 309 | - and count($val) == 2 |
|
| 310 | - and (array_key_exists('data', $val)) |
|
| 311 | - ) { |
|
| 312 | - $val = $val['data']; |
|
| 313 | - } |
|
| 314 | - |
|
| 315 | - return $val; |
|
| 276 | + static $charger; |
|
| 277 | + |
|
| 278 | + // chargement initial des fonctions mises en cache, ou generation du cache |
|
| 279 | + if (!$charger) { |
|
| 280 | + if (!($ok = @is_readable($charger = _CACHE_PIPELINES))) { |
|
| 281 | + include_spip('inc/plugin'); |
|
| 282 | + // generer les fichiers php precompiles |
|
| 283 | + // de chargement des plugins et des pipelines |
|
| 284 | + actualise_plugins_actifs(); |
|
| 285 | + if (!($ok = @is_readable($charger))) { |
|
| 286 | + spip_log("fichier $charger pas cree"); |
|
| 287 | + } |
|
| 288 | + } |
|
| 289 | + |
|
| 290 | + if ($ok) { |
|
| 291 | + include_once $charger; |
|
| 292 | + } |
|
| 293 | + } |
|
| 294 | + |
|
| 295 | + // appliquer notre fonction si elle existe |
|
| 296 | + $fonc = 'execute_pipeline_' . strtolower($action); |
|
| 297 | + if (function_exists($fonc)) { |
|
| 298 | + $val = $fonc($val); |
|
| 299 | + } // plantage ? |
|
| 300 | + else { |
|
| 301 | + spip_log("fonction $fonc absente : pipeline desactive", _LOG_ERREUR); |
|
| 302 | + } |
|
| 303 | + |
|
| 304 | + // si le flux est une table avec 2 cle args&data |
|
| 305 | + // on ne ressort du pipe que les donnees dans 'data' |
|
| 306 | + // array_key_exists pour php 4.1.0 |
|
| 307 | + if ( |
|
| 308 | + is_array($val) |
|
| 309 | + and count($val) == 2 |
|
| 310 | + and (array_key_exists('data', $val)) |
|
| 311 | + ) { |
|
| 312 | + $val = $val['data']; |
|
| 313 | + } |
|
| 314 | + |
|
| 315 | + return $val; |
|
| 316 | 316 | } |
| 317 | 317 | |
| 318 | 318 | /** |
@@ -356,38 +356,38 @@ discard block |
||
| 356 | 356 | * paramètre est planté pour cause de compatibilité ascendante. |
| 357 | 357 | */ |
| 358 | 358 | function spip_log($message = null, $name = null) { |
| 359 | - static $pre = []; |
|
| 360 | - static $log; |
|
| 361 | - preg_match('/^([a-z_]*)\.?(\d)?$/iS', (string)$name, $regs); |
|
| 362 | - if (!isset($regs[1]) or !$logname = $regs[1]) { |
|
| 363 | - $logname = null; |
|
| 364 | - } |
|
| 365 | - if (!isset($regs[2])) { |
|
| 366 | - $niveau = _LOG_INFO; |
|
| 367 | - } |
|
| 368 | - else { |
|
| 369 | - $niveau = intval($regs[2]); |
|
| 370 | - } |
|
| 371 | - |
|
| 372 | - if ($niveau <= (defined('_LOG_FILTRE_GRAVITE') ? _LOG_FILTRE_GRAVITE : _LOG_INFO_IMPORTANTE)) { |
|
| 373 | - if (!$pre) { |
|
| 374 | - $pre = [ |
|
| 375 | - _LOG_HS => 'HS:', |
|
| 376 | - _LOG_ALERTE_ROUGE => 'ALERTE:', |
|
| 377 | - _LOG_CRITIQUE => 'CRITIQUE:', |
|
| 378 | - _LOG_ERREUR => 'ERREUR:', |
|
| 379 | - _LOG_AVERTISSEMENT => 'WARNING:', |
|
| 380 | - _LOG_INFO_IMPORTANTE => '!INFO:', |
|
| 381 | - _LOG_INFO => 'info:', |
|
| 382 | - _LOG_DEBUG => 'debug:' |
|
| 383 | - ]; |
|
| 384 | - $log = charger_fonction('log', 'inc'); |
|
| 385 | - } |
|
| 386 | - if (!is_string($message)) { |
|
| 387 | - $message = print_r($message, true); |
|
| 388 | - } |
|
| 389 | - $log($pre[$niveau] . ' ' . $message, $logname); |
|
| 390 | - } |
|
| 359 | + static $pre = []; |
|
| 360 | + static $log; |
|
| 361 | + preg_match('/^([a-z_]*)\.?(\d)?$/iS', (string)$name, $regs); |
|
| 362 | + if (!isset($regs[1]) or !$logname = $regs[1]) { |
|
| 363 | + $logname = null; |
|
| 364 | + } |
|
| 365 | + if (!isset($regs[2])) { |
|
| 366 | + $niveau = _LOG_INFO; |
|
| 367 | + } |
|
| 368 | + else { |
|
| 369 | + $niveau = intval($regs[2]); |
|
| 370 | + } |
|
| 371 | + |
|
| 372 | + if ($niveau <= (defined('_LOG_FILTRE_GRAVITE') ? _LOG_FILTRE_GRAVITE : _LOG_INFO_IMPORTANTE)) { |
|
| 373 | + if (!$pre) { |
|
| 374 | + $pre = [ |
|
| 375 | + _LOG_HS => 'HS:', |
|
| 376 | + _LOG_ALERTE_ROUGE => 'ALERTE:', |
|
| 377 | + _LOG_CRITIQUE => 'CRITIQUE:', |
|
| 378 | + _LOG_ERREUR => 'ERREUR:', |
|
| 379 | + _LOG_AVERTISSEMENT => 'WARNING:', |
|
| 380 | + _LOG_INFO_IMPORTANTE => '!INFO:', |
|
| 381 | + _LOG_INFO => 'info:', |
|
| 382 | + _LOG_DEBUG => 'debug:' |
|
| 383 | + ]; |
|
| 384 | + $log = charger_fonction('log', 'inc'); |
|
| 385 | + } |
|
| 386 | + if (!is_string($message)) { |
|
| 387 | + $message = print_r($message, true); |
|
| 388 | + } |
|
| 389 | + $log($pre[$niveau] . ' ' . $message, $logname); |
|
| 390 | + } |
|
| 391 | 391 | } |
| 392 | 392 | |
| 393 | 393 | /** |
@@ -398,8 +398,8 @@ discard block |
||
| 398 | 398 | * @param array $opt Tableau d'options |
| 399 | 399 | **/ |
| 400 | 400 | function journal($phrase, $opt = []) { |
| 401 | - $journal = charger_fonction('journal', 'inc'); |
|
| 402 | - $journal($phrase, $opt); |
|
| 401 | + $journal = charger_fonction('journal', 'inc'); |
|
| 402 | + $journal($phrase, $opt); |
|
| 403 | 403 | } |
| 404 | 404 | |
| 405 | 405 | |
@@ -418,37 +418,37 @@ discard block |
||
| 418 | 418 | **/ |
| 419 | 419 | function _request($var, $c = false) { |
| 420 | 420 | |
| 421 | - if (is_array($c)) { |
|
| 422 | - return $c[$var] ?? null; |
|
| 423 | - } |
|
| 424 | - |
|
| 425 | - if (isset($_GET[$var])) { |
|
| 426 | - $a = $_GET[$var]; |
|
| 427 | - } elseif (isset($_POST[$var])) { |
|
| 428 | - $a = $_POST[$var]; |
|
| 429 | - } else { |
|
| 430 | - return null; |
|
| 431 | - } |
|
| 432 | - |
|
| 433 | - // Si on est en ajax et en POST tout a ete encode |
|
| 434 | - // via encodeURIComponent, il faut donc repasser |
|
| 435 | - // dans le charset local... |
|
| 436 | - if ( |
|
| 437 | - defined('_AJAX') |
|
| 438 | - and _AJAX |
|
| 439 | - and isset($GLOBALS['meta']['charset']) |
|
| 440 | - and $GLOBALS['meta']['charset'] != 'utf-8' |
|
| 441 | - and is_string($a) |
|
| 442 | - // check rapide mais pas fiable |
|
| 443 | - and preg_match(',[\x80-\xFF],', $a) |
|
| 444 | - // check fiable |
|
| 445 | - and include_spip('inc/charsets') |
|
| 446 | - and is_utf8($a) |
|
| 447 | - ) { |
|
| 448 | - return importer_charset($a, 'utf-8'); |
|
| 449 | - } |
|
| 450 | - |
|
| 451 | - return $a; |
|
| 421 | + if (is_array($c)) { |
|
| 422 | + return $c[$var] ?? null; |
|
| 423 | + } |
|
| 424 | + |
|
| 425 | + if (isset($_GET[$var])) { |
|
| 426 | + $a = $_GET[$var]; |
|
| 427 | + } elseif (isset($_POST[$var])) { |
|
| 428 | + $a = $_POST[$var]; |
|
| 429 | + } else { |
|
| 430 | + return null; |
|
| 431 | + } |
|
| 432 | + |
|
| 433 | + // Si on est en ajax et en POST tout a ete encode |
|
| 434 | + // via encodeURIComponent, il faut donc repasser |
|
| 435 | + // dans le charset local... |
|
| 436 | + if ( |
|
| 437 | + defined('_AJAX') |
|
| 438 | + and _AJAX |
|
| 439 | + and isset($GLOBALS['meta']['charset']) |
|
| 440 | + and $GLOBALS['meta']['charset'] != 'utf-8' |
|
| 441 | + and is_string($a) |
|
| 442 | + // check rapide mais pas fiable |
|
| 443 | + and preg_match(',[\x80-\xFF],', $a) |
|
| 444 | + // check fiable |
|
| 445 | + and include_spip('inc/charsets') |
|
| 446 | + and is_utf8($a) |
|
| 447 | + ) { |
|
| 448 | + return importer_charset($a, 'utf-8'); |
|
| 449 | + } |
|
| 450 | + |
|
| 451 | + return $a; |
|
| 452 | 452 | } |
| 453 | 453 | |
| 454 | 454 | |
@@ -466,22 +466,22 @@ discard block |
||
| 466 | 466 | * - false sinon |
| 467 | 467 | **/ |
| 468 | 468 | function set_request($var, $val = null, $c = false) { |
| 469 | - if (is_array($c)) { |
|
| 470 | - unset($c[$var]); |
|
| 471 | - if ($val !== null) { |
|
| 472 | - $c[$var] = $val; |
|
| 473 | - } |
|
| 469 | + if (is_array($c)) { |
|
| 470 | + unset($c[$var]); |
|
| 471 | + if ($val !== null) { |
|
| 472 | + $c[$var] = $val; |
|
| 473 | + } |
|
| 474 | 474 | |
| 475 | - return $c; |
|
| 476 | - } |
|
| 475 | + return $c; |
|
| 476 | + } |
|
| 477 | 477 | |
| 478 | - unset($_GET[$var]); |
|
| 479 | - unset($_POST[$var]); |
|
| 480 | - if ($val !== null) { |
|
| 481 | - $_GET[$var] = $val; |
|
| 482 | - } |
|
| 478 | + unset($_GET[$var]); |
|
| 479 | + unset($_POST[$var]); |
|
| 480 | + if ($val !== null) { |
|
| 481 | + $_GET[$var] = $val; |
|
| 482 | + } |
|
| 483 | 483 | |
| 484 | - return false; # n'affecte pas $c |
|
| 484 | + return false; # n'affecte pas $c |
|
| 485 | 485 | } |
| 486 | 486 | |
| 487 | 487 | /** |
@@ -501,25 +501,25 @@ discard block |
||
| 501 | 501 | * @return array|mixed|string |
| 502 | 502 | */ |
| 503 | 503 | function spip_sanitize_from_request($value, $key, $sanitize_function = 'entites_html') { |
| 504 | - if (is_array($value)) { |
|
| 505 | - if ($key == '*') { |
|
| 506 | - $key = array_keys($value); |
|
| 507 | - } |
|
| 508 | - if (!is_array($key)) { |
|
| 509 | - $key = [$key]; |
|
| 510 | - } |
|
| 511 | - foreach ($key as $k) { |
|
| 512 | - if (!empty($value[$k])) { |
|
| 513 | - $value[$k] = spip_sanitize_from_request($value[$k], $k, $sanitize_function); |
|
| 514 | - } |
|
| 515 | - } |
|
| 516 | - return $value; |
|
| 517 | - } |
|
| 518 | - // si la valeur vient des GET ou POST on la sanitize |
|
| 519 | - if (!empty($value) and $value == _request($key)) { |
|
| 520 | - $value = $sanitize_function($value); |
|
| 521 | - } |
|
| 522 | - return $value; |
|
| 504 | + if (is_array($value)) { |
|
| 505 | + if ($key == '*') { |
|
| 506 | + $key = array_keys($value); |
|
| 507 | + } |
|
| 508 | + if (!is_array($key)) { |
|
| 509 | + $key = [$key]; |
|
| 510 | + } |
|
| 511 | + foreach ($key as $k) { |
|
| 512 | + if (!empty($value[$k])) { |
|
| 513 | + $value[$k] = spip_sanitize_from_request($value[$k], $k, $sanitize_function); |
|
| 514 | + } |
|
| 515 | + } |
|
| 516 | + return $value; |
|
| 517 | + } |
|
| 518 | + // si la valeur vient des GET ou POST on la sanitize |
|
| 519 | + if (!empty($value) and $value == _request($key)) { |
|
| 520 | + $value = $sanitize_function($value); |
|
| 521 | + } |
|
| 522 | + return $value; |
|
| 523 | 523 | } |
| 524 | 524 | |
| 525 | 525 | /** |
@@ -527,23 +527,22 @@ discard block |
||
| 527 | 527 | * |
| 528 | 528 | * On est sur le web, on exclut certains protocoles, |
| 529 | 529 | * notamment 'file://', 'php://' et d'autres… |
| 530 | - |
|
| 531 | 530 | * @param string $url |
| 532 | 531 | * @return bool |
| 533 | 532 | */ |
| 534 | 533 | function tester_url_absolue($url) { |
| 535 | - $url = trim($url); |
|
| 536 | - if (preg_match(';^([a-z]{3,7}:)?//;Uims', $url, $m)) { |
|
| 537 | - if ( |
|
| 538 | - isset($m[1]) |
|
| 539 | - and $p = strtolower(rtrim($m[1], ':')) |
|
| 540 | - and in_array($p, ['file', 'php', 'zlib', 'glob', 'phar', 'ssh2', 'rar', 'ogg', 'expect', 'zip']) |
|
| 541 | - ) { |
|
| 542 | - return false; |
|
| 543 | - } |
|
| 544 | - return true; |
|
| 545 | - } |
|
| 546 | - return false; |
|
| 534 | + $url = trim($url); |
|
| 535 | + if (preg_match(';^([a-z]{3,7}:)?//;Uims', $url, $m)) { |
|
| 536 | + if ( |
|
| 537 | + isset($m[1]) |
|
| 538 | + and $p = strtolower(rtrim($m[1], ':')) |
|
| 539 | + and in_array($p, ['file', 'php', 'zlib', 'glob', 'phar', 'ssh2', 'rar', 'ogg', 'expect', 'zip']) |
|
| 540 | + ) { |
|
| 541 | + return false; |
|
| 542 | + } |
|
| 543 | + return true; |
|
| 544 | + } |
|
| 545 | + return false; |
|
| 547 | 546 | } |
| 548 | 547 | |
| 549 | 548 | /** |
@@ -565,95 +564,95 @@ discard block |
||
| 565 | 564 | * @return string URL |
| 566 | 565 | */ |
| 567 | 566 | function parametre_url($url, $c, $v = null, $sep = '&') { |
| 568 | - // requete erronnee : plusieurs variable dans $c et aucun $v |
|
| 569 | - if (strpos($c, '|') !== false and is_null($v)) { |
|
| 570 | - return null; |
|
| 571 | - } |
|
| 572 | - |
|
| 573 | - // lever l'#ancre |
|
| 574 | - if (preg_match(',^([^#]*)(#.*)$,', $url, $r)) { |
|
| 575 | - $url = $r[1]; |
|
| 576 | - $ancre = $r[2]; |
|
| 577 | - } else { |
|
| 578 | - $ancre = ''; |
|
| 579 | - } |
|
| 580 | - |
|
| 581 | - // eclater |
|
| 582 | - $url = preg_split(',[?]|&|&,', $url); |
|
| 583 | - |
|
| 584 | - // recuperer la base |
|
| 585 | - $a = array_shift($url); |
|
| 586 | - if (!$a) { |
|
| 587 | - $a = './'; |
|
| 588 | - } |
|
| 589 | - |
|
| 590 | - $regexp = ',^(' . str_replace('[]', '\[\]', $c) . '[[]?[]]?)(=.*)?$,'; |
|
| 591 | - $ajouts = array_flip(explode('|', $c)); |
|
| 592 | - $u = is_array($v) ? $v : rawurlencode((string) $v); |
|
| 593 | - $testv = (is_array($v) ? count($v) : strlen((string) $v)); |
|
| 594 | - $v_read = null; |
|
| 595 | - // lire les variables et agir |
|
| 596 | - foreach ($url as $n => $val) { |
|
| 597 | - if (preg_match($regexp, urldecode($val), $r)) { |
|
| 598 | - $r = array_pad($r, 3, null); |
|
| 599 | - if ($v === null) { |
|
| 600 | - // c'est un tableau, on memorise les valeurs |
|
| 601 | - if (substr($r[1], -2) == '[]') { |
|
| 602 | - if (!$v_read) { |
|
| 603 | - $v_read = []; |
|
| 604 | - } |
|
| 605 | - $v_read[] = $r[2] ? substr($r[2], 1) : ''; |
|
| 606 | - } // c'est un scalaire, on retourne direct |
|
| 607 | - else { |
|
| 608 | - return $r[2] ? substr($r[2], 1) : ''; |
|
| 609 | - } |
|
| 610 | - } // suppression |
|
| 611 | - elseif (!$testv) { |
|
| 612 | - unset($url[$n]); |
|
| 613 | - } |
|
| 614 | - // Ajout. Pour une variable, remplacer au meme endroit, |
|
| 615 | - // pour un tableau ce sera fait dans la prochaine boucle |
|
| 616 | - elseif (substr($r[1], -2) != '[]') { |
|
| 617 | - $url[$n] = $r[1] . '=' . $u; |
|
| 618 | - unset($ajouts[$r[1]]); |
|
| 619 | - } |
|
| 620 | - // Pour les tableaux on laisse tomber les valeurs de |
|
| 621 | - // départ, on remplira à l'étape suivante |
|
| 622 | - else { |
|
| 623 | - unset($url[$n]); |
|
| 624 | - } |
|
| 625 | - } |
|
| 626 | - } |
|
| 627 | - |
|
| 628 | - // traiter les parametres pas encore trouves |
|
| 629 | - if ( |
|
| 630 | - $v === null |
|
| 631 | - and $args = func_get_args() |
|
| 632 | - and count($args) == 2 |
|
| 633 | - ) { |
|
| 634 | - return $v_read; // rien trouve ou un tableau |
|
| 635 | - } elseif ($testv) { |
|
| 636 | - foreach ($ajouts as $k => $n) { |
|
| 637 | - if (!is_array($v)) { |
|
| 638 | - $url[] = $k . '=' . $u; |
|
| 639 | - } else { |
|
| 640 | - $id = (substr($k, -2) == '[]') ? $k : ($k . '[]'); |
|
| 641 | - foreach ($v as $w) { |
|
| 642 | - $url[] = $id . '=' . (is_array($w) ? 'Array' : rawurlencode($w)); |
|
| 643 | - } |
|
| 644 | - } |
|
| 645 | - } |
|
| 646 | - } |
|
| 647 | - |
|
| 648 | - // eliminer les vides |
|
| 649 | - $url = array_filter($url); |
|
| 650 | - |
|
| 651 | - // recomposer l'adresse |
|
| 652 | - if ($url) { |
|
| 653 | - $a .= '?' . join($sep, $url); |
|
| 654 | - } |
|
| 655 | - |
|
| 656 | - return $a . $ancre; |
|
| 567 | + // requete erronnee : plusieurs variable dans $c et aucun $v |
|
| 568 | + if (strpos($c, '|') !== false and is_null($v)) { |
|
| 569 | + return null; |
|
| 570 | + } |
|
| 571 | + |
|
| 572 | + // lever l'#ancre |
|
| 573 | + if (preg_match(',^([^#]*)(#.*)$,', $url, $r)) { |
|
| 574 | + $url = $r[1]; |
|
| 575 | + $ancre = $r[2]; |
|
| 576 | + } else { |
|
| 577 | + $ancre = ''; |
|
| 578 | + } |
|
| 579 | + |
|
| 580 | + // eclater |
|
| 581 | + $url = preg_split(',[?]|&|&,', $url); |
|
| 582 | + |
|
| 583 | + // recuperer la base |
|
| 584 | + $a = array_shift($url); |
|
| 585 | + if (!$a) { |
|
| 586 | + $a = './'; |
|
| 587 | + } |
|
| 588 | + |
|
| 589 | + $regexp = ',^(' . str_replace('[]', '\[\]', $c) . '[[]?[]]?)(=.*)?$,'; |
|
| 590 | + $ajouts = array_flip(explode('|', $c)); |
|
| 591 | + $u = is_array($v) ? $v : rawurlencode((string) $v); |
|
| 592 | + $testv = (is_array($v) ? count($v) : strlen((string) $v)); |
|
| 593 | + $v_read = null; |
|
| 594 | + // lire les variables et agir |
|
| 595 | + foreach ($url as $n => $val) { |
|
| 596 | + if (preg_match($regexp, urldecode($val), $r)) { |
|
| 597 | + $r = array_pad($r, 3, null); |
|
| 598 | + if ($v === null) { |
|
| 599 | + // c'est un tableau, on memorise les valeurs |
|
| 600 | + if (substr($r[1], -2) == '[]') { |
|
| 601 | + if (!$v_read) { |
|
| 602 | + $v_read = []; |
|
| 603 | + } |
|
| 604 | + $v_read[] = $r[2] ? substr($r[2], 1) : ''; |
|
| 605 | + } // c'est un scalaire, on retourne direct |
|
| 606 | + else { |
|
| 607 | + return $r[2] ? substr($r[2], 1) : ''; |
|
| 608 | + } |
|
| 609 | + } // suppression |
|
| 610 | + elseif (!$testv) { |
|
| 611 | + unset($url[$n]); |
|
| 612 | + } |
|
| 613 | + // Ajout. Pour une variable, remplacer au meme endroit, |
|
| 614 | + // pour un tableau ce sera fait dans la prochaine boucle |
|
| 615 | + elseif (substr($r[1], -2) != '[]') { |
|
| 616 | + $url[$n] = $r[1] . '=' . $u; |
|
| 617 | + unset($ajouts[$r[1]]); |
|
| 618 | + } |
|
| 619 | + // Pour les tableaux on laisse tomber les valeurs de |
|
| 620 | + // départ, on remplira à l'étape suivante |
|
| 621 | + else { |
|
| 622 | + unset($url[$n]); |
|
| 623 | + } |
|
| 624 | + } |
|
| 625 | + } |
|
| 626 | + |
|
| 627 | + // traiter les parametres pas encore trouves |
|
| 628 | + if ( |
|
| 629 | + $v === null |
|
| 630 | + and $args = func_get_args() |
|
| 631 | + and count($args) == 2 |
|
| 632 | + ) { |
|
| 633 | + return $v_read; // rien trouve ou un tableau |
|
| 634 | + } elseif ($testv) { |
|
| 635 | + foreach ($ajouts as $k => $n) { |
|
| 636 | + if (!is_array($v)) { |
|
| 637 | + $url[] = $k . '=' . $u; |
|
| 638 | + } else { |
|
| 639 | + $id = (substr($k, -2) == '[]') ? $k : ($k . '[]'); |
|
| 640 | + foreach ($v as $w) { |
|
| 641 | + $url[] = $id . '=' . (is_array($w) ? 'Array' : rawurlencode($w)); |
|
| 642 | + } |
|
| 643 | + } |
|
| 644 | + } |
|
| 645 | + } |
|
| 646 | + |
|
| 647 | + // eliminer les vides |
|
| 648 | + $url = array_filter($url); |
|
| 649 | + |
|
| 650 | + // recomposer l'adresse |
|
| 651 | + if ($url) { |
|
| 652 | + $a .= '?' . join($sep, $url); |
|
| 653 | + } |
|
| 654 | + |
|
| 655 | + return $a . $ancre; |
|
| 657 | 656 | } |
| 658 | 657 | |
| 659 | 658 | /** |
@@ -671,21 +670,21 @@ discard block |
||
| 671 | 670 | * @return string |
| 672 | 671 | */ |
| 673 | 672 | function ancre_url($url, $ancre) { |
| 674 | - // lever l'#ancre |
|
| 675 | - if (preg_match(',^([^#]*)(#.*)$,', $url, $r)) { |
|
| 676 | - $url = $r[1]; |
|
| 677 | - } |
|
| 678 | - if (preg_match('/[^-_a-zA-Z0-9]+/S', $ancre)) { |
|
| 679 | - if (!function_exists('translitteration')) { |
|
| 680 | - include_spip('inc/charsets'); |
|
| 681 | - } |
|
| 682 | - $ancre = preg_replace( |
|
| 683 | - ['/^[^-_a-zA-Z0-9]+/', '/[^-_a-zA-Z0-9]/'], |
|
| 684 | - ['', '-'], |
|
| 685 | - translitteration($ancre) |
|
| 686 | - ); |
|
| 687 | - } |
|
| 688 | - return $url . (strlen($ancre) ? '#' . $ancre : ''); |
|
| 673 | + // lever l'#ancre |
|
| 674 | + if (preg_match(',^([^#]*)(#.*)$,', $url, $r)) { |
|
| 675 | + $url = $r[1]; |
|
| 676 | + } |
|
| 677 | + if (preg_match('/[^-_a-zA-Z0-9]+/S', $ancre)) { |
|
| 678 | + if (!function_exists('translitteration')) { |
|
| 679 | + include_spip('inc/charsets'); |
|
| 680 | + } |
|
| 681 | + $ancre = preg_replace( |
|
| 682 | + ['/^[^-_a-zA-Z0-9]+/', '/[^-_a-zA-Z0-9]/'], |
|
| 683 | + ['', '-'], |
|
| 684 | + translitteration($ancre) |
|
| 685 | + ); |
|
| 686 | + } |
|
| 687 | + return $url . (strlen($ancre) ? '#' . $ancre : ''); |
|
| 689 | 688 | } |
| 690 | 689 | |
| 691 | 690 | /** |
@@ -695,16 +694,16 @@ discard block |
||
| 695 | 694 | * @return string |
| 696 | 695 | */ |
| 697 | 696 | function nettoyer_uri($reset = null) { |
| 698 | - static $done = false; |
|
| 699 | - static $propre = ''; |
|
| 700 | - if (!is_null($reset)) { |
|
| 701 | - return $propre = $reset; |
|
| 702 | - } |
|
| 703 | - if ($done) { |
|
| 704 | - return $propre; |
|
| 705 | - } |
|
| 706 | - $done = true; |
|
| 707 | - return $propre = nettoyer_uri_var($GLOBALS['REQUEST_URI']); |
|
| 697 | + static $done = false; |
|
| 698 | + static $propre = ''; |
|
| 699 | + if (!is_null($reset)) { |
|
| 700 | + return $propre = $reset; |
|
| 701 | + } |
|
| 702 | + if ($done) { |
|
| 703 | + return $propre; |
|
| 704 | + } |
|
| 705 | + $done = true; |
|
| 706 | + return $propre = nettoyer_uri_var($GLOBALS['REQUEST_URI']); |
|
| 708 | 707 | } |
| 709 | 708 | |
| 710 | 709 | /** |
@@ -716,16 +715,16 @@ discard block |
||
| 716 | 715 | * @return string |
| 717 | 716 | */ |
| 718 | 717 | function nettoyer_uri_var($request_uri) { |
| 719 | - $uri1 = $request_uri; |
|
| 720 | - do { |
|
| 721 | - $uri = $uri1; |
|
| 722 | - $uri1 = preg_replace( |
|
| 723 | - ',([?&])(var_[^=&]*|PHPSESSID|fbclid|utm_[^=&]*)=[^&]*(&|$),i', |
|
| 724 | - '\1', |
|
| 725 | - $uri |
|
| 726 | - ); |
|
| 727 | - } while ($uri <> $uri1); |
|
| 728 | - return preg_replace(',[?&]$,', '', $uri1); |
|
| 718 | + $uri1 = $request_uri; |
|
| 719 | + do { |
|
| 720 | + $uri = $uri1; |
|
| 721 | + $uri1 = preg_replace( |
|
| 722 | + ',([?&])(var_[^=&]*|PHPSESSID|fbclid|utm_[^=&]*)=[^&]*(&|$),i', |
|
| 723 | + '\1', |
|
| 724 | + $uri |
|
| 725 | + ); |
|
| 726 | + } while ($uri <> $uri1); |
|
| 727 | + return preg_replace(',[?&]$,', '', $uri1); |
|
| 729 | 728 | } |
| 730 | 729 | |
| 731 | 730 | |
@@ -739,48 +738,48 @@ discard block |
||
| 739 | 738 | * URL vers soi-même |
| 740 | 739 | **/ |
| 741 | 740 | function self($amp = '&', $root = false) { |
| 742 | - $url = nettoyer_uri(); |
|
| 743 | - if ( |
|
| 744 | - !$root |
|
| 745 | - and ( |
|
| 746 | - // si pas de profondeur on peut tronquer |
|
| 747 | - $GLOBALS['profondeur_url'] < (_DIR_RESTREINT ? 1 : 2) |
|
| 748 | - // sinon c'est OK si _SET_HTML_BASE a ete force a false |
|
| 749 | - or (defined('_SET_HTML_BASE') and !_SET_HTML_BASE)) |
|
| 750 | - ) { |
|
| 751 | - $url = preg_replace(',^[^?]*/,', '', $url); |
|
| 752 | - } |
|
| 753 | - // ajouter le cas echeant les variables _POST['id_...'] |
|
| 754 | - foreach ($_POST as $v => $c) { |
|
| 755 | - if (substr($v, 0, 3) == 'id_') { |
|
| 756 | - $url = parametre_url($url, $v, $c, '&'); |
|
| 757 | - } |
|
| 758 | - } |
|
| 759 | - |
|
| 760 | - // supprimer les variables sans interet |
|
| 761 | - if (test_espace_prive()) { |
|
| 762 | - $url = preg_replace(',([?&])(' |
|
| 763 | - . 'lang|show_docs|' |
|
| 764 | - . 'changer_lang|var_lang|action)=[^&]*,i', '\1', $url); |
|
| 765 | - $url = preg_replace(',([?&])[&]+,', '\1', $url); |
|
| 766 | - $url = preg_replace(',[&]$,', '\1', $url); |
|
| 767 | - } |
|
| 768 | - |
|
| 769 | - // eviter les hacks |
|
| 770 | - include_spip('inc/filtres_mini'); |
|
| 771 | - $url = spip_htmlspecialchars($url); |
|
| 772 | - |
|
| 773 | - $url = str_replace(["'", '"', '<', '[', ']', ':'], ['%27', '%22', '%3C', '%5B', '%5D', '%3A'], $url); |
|
| 774 | - |
|
| 775 | - // & ? |
|
| 776 | - if ($amp != '&') { |
|
| 777 | - $url = str_replace('&', $amp, $url); |
|
| 778 | - } |
|
| 779 | - |
|
| 780 | - // Si ca demarre par ? ou vide, donner './' |
|
| 781 | - $url = preg_replace(',^([?].*)?$,', './\1', $url); |
|
| 782 | - |
|
| 783 | - return $url; |
|
| 741 | + $url = nettoyer_uri(); |
|
| 742 | + if ( |
|
| 743 | + !$root |
|
| 744 | + and ( |
|
| 745 | + // si pas de profondeur on peut tronquer |
|
| 746 | + $GLOBALS['profondeur_url'] < (_DIR_RESTREINT ? 1 : 2) |
|
| 747 | + // sinon c'est OK si _SET_HTML_BASE a ete force a false |
|
| 748 | + or (defined('_SET_HTML_BASE') and !_SET_HTML_BASE)) |
|
| 749 | + ) { |
|
| 750 | + $url = preg_replace(',^[^?]*/,', '', $url); |
|
| 751 | + } |
|
| 752 | + // ajouter le cas echeant les variables _POST['id_...'] |
|
| 753 | + foreach ($_POST as $v => $c) { |
|
| 754 | + if (substr($v, 0, 3) == 'id_') { |
|
| 755 | + $url = parametre_url($url, $v, $c, '&'); |
|
| 756 | + } |
|
| 757 | + } |
|
| 758 | + |
|
| 759 | + // supprimer les variables sans interet |
|
| 760 | + if (test_espace_prive()) { |
|
| 761 | + $url = preg_replace(',([?&])(' |
|
| 762 | + . 'lang|show_docs|' |
|
| 763 | + . 'changer_lang|var_lang|action)=[^&]*,i', '\1', $url); |
|
| 764 | + $url = preg_replace(',([?&])[&]+,', '\1', $url); |
|
| 765 | + $url = preg_replace(',[&]$,', '\1', $url); |
|
| 766 | + } |
|
| 767 | + |
|
| 768 | + // eviter les hacks |
|
| 769 | + include_spip('inc/filtres_mini'); |
|
| 770 | + $url = spip_htmlspecialchars($url); |
|
| 771 | + |
|
| 772 | + $url = str_replace(["'", '"', '<', '[', ']', ':'], ['%27', '%22', '%3C', '%5B', '%5D', '%3A'], $url); |
|
| 773 | + |
|
| 774 | + // & ? |
|
| 775 | + if ($amp != '&') { |
|
| 776 | + $url = str_replace('&', $amp, $url); |
|
| 777 | + } |
|
| 778 | + |
|
| 779 | + // Si ca demarre par ? ou vide, donner './' |
|
| 780 | + $url = preg_replace(',^([?].*)?$,', './\1', $url); |
|
| 781 | + |
|
| 782 | + return $url; |
|
| 784 | 783 | } |
| 785 | 784 | |
| 786 | 785 | |
@@ -791,7 +790,7 @@ discard block |
||
| 791 | 790 | * true si c'est le cas, false sinon. |
| 792 | 791 | */ |
| 793 | 792 | function test_espace_prive() { |
| 794 | - return defined('_ESPACE_PRIVE') ? _ESPACE_PRIVE : false; |
|
| 793 | + return defined('_ESPACE_PRIVE') ? _ESPACE_PRIVE : false; |
|
| 795 | 794 | } |
| 796 | 795 | |
| 797 | 796 | /** |
@@ -801,7 +800,7 @@ discard block |
||
| 801 | 800 | * @return bool |
| 802 | 801 | */ |
| 803 | 802 | function test_plugin_actif($plugin) { |
| 804 | - return ($plugin and defined('_DIR_PLUGIN_' . strtoupper($plugin))) ? true : false; |
|
| 803 | + return ($plugin and defined('_DIR_PLUGIN_' . strtoupper($plugin))) ? true : false; |
|
| 805 | 804 | } |
| 806 | 805 | |
| 807 | 806 | /** |
@@ -832,52 +831,52 @@ discard block |
||
| 832 | 831 | * Texte |
| 833 | 832 | */ |
| 834 | 833 | function _T($texte, $args = [], $options = []) { |
| 835 | - static $traduire = false; |
|
| 836 | - $o = ['class' => '', 'force' => true, 'sanitize' => true]; |
|
| 837 | - if ($options) { |
|
| 838 | - // support de l'ancien argument $class |
|
| 839 | - if (is_string($options)) { |
|
| 840 | - $options = ['class' => $options]; |
|
| 841 | - } |
|
| 842 | - $o = array_merge($o, $options); |
|
| 843 | - } |
|
| 844 | - |
|
| 845 | - if (!$traduire) { |
|
| 846 | - $traduire = charger_fonction('traduire', 'inc'); |
|
| 847 | - include_spip('inc/lang'); |
|
| 848 | - } |
|
| 849 | - |
|
| 850 | - // On peut passer explicitement la langue dans le tableau |
|
| 851 | - // On utilise le même nom de variable que la globale |
|
| 852 | - if (isset($args['spip_lang'])) { |
|
| 853 | - $lang = $args['spip_lang']; |
|
| 854 | - // On l'enleve pour ne pas le passer au remplacement |
|
| 855 | - unset($args['spip_lang']); |
|
| 856 | - } // Sinon on prend la langue du contexte |
|
| 857 | - else { |
|
| 858 | - $lang = $GLOBALS['spip_lang']; |
|
| 859 | - } |
|
| 860 | - $text = $traduire($texte, $lang); |
|
| 861 | - |
|
| 862 | - if ($text === null || !strlen($text)) { |
|
| 863 | - if (!$o['force']) { |
|
| 864 | - return ''; |
|
| 865 | - } |
|
| 866 | - |
|
| 867 | - $text = $texte; |
|
| 868 | - |
|
| 869 | - // pour les chaines non traduites, assurer un service minimum |
|
| 870 | - if (!$GLOBALS['test_i18n'] and (_request('var_mode') != 'traduction')) { |
|
| 871 | - $n = strpos($text, ':'); |
|
| 872 | - if ($n !== false) { |
|
| 873 | - $text = substr($text, $n + 1); |
|
| 874 | - } |
|
| 875 | - $text = str_replace('_', ' ', $text); |
|
| 876 | - } |
|
| 877 | - $o['class'] = null; |
|
| 878 | - } |
|
| 879 | - |
|
| 880 | - return _L($text, $args, $o); |
|
| 834 | + static $traduire = false; |
|
| 835 | + $o = ['class' => '', 'force' => true, 'sanitize' => true]; |
|
| 836 | + if ($options) { |
|
| 837 | + // support de l'ancien argument $class |
|
| 838 | + if (is_string($options)) { |
|
| 839 | + $options = ['class' => $options]; |
|
| 840 | + } |
|
| 841 | + $o = array_merge($o, $options); |
|
| 842 | + } |
|
| 843 | + |
|
| 844 | + if (!$traduire) { |
|
| 845 | + $traduire = charger_fonction('traduire', 'inc'); |
|
| 846 | + include_spip('inc/lang'); |
|
| 847 | + } |
|
| 848 | + |
|
| 849 | + // On peut passer explicitement la langue dans le tableau |
|
| 850 | + // On utilise le même nom de variable que la globale |
|
| 851 | + if (isset($args['spip_lang'])) { |
|
| 852 | + $lang = $args['spip_lang']; |
|
| 853 | + // On l'enleve pour ne pas le passer au remplacement |
|
| 854 | + unset($args['spip_lang']); |
|
| 855 | + } // Sinon on prend la langue du contexte |
|
| 856 | + else { |
|
| 857 | + $lang = $GLOBALS['spip_lang']; |
|
| 858 | + } |
|
| 859 | + $text = $traduire($texte, $lang); |
|
| 860 | + |
|
| 861 | + if ($text === null || !strlen($text)) { |
|
| 862 | + if (!$o['force']) { |
|
| 863 | + return ''; |
|
| 864 | + } |
|
| 865 | + |
|
| 866 | + $text = $texte; |
|
| 867 | + |
|
| 868 | + // pour les chaines non traduites, assurer un service minimum |
|
| 869 | + if (!$GLOBALS['test_i18n'] and (_request('var_mode') != 'traduction')) { |
|
| 870 | + $n = strpos($text, ':'); |
|
| 871 | + if ($n !== false) { |
|
| 872 | + $text = substr($text, $n + 1); |
|
| 873 | + } |
|
| 874 | + $text = str_replace('_', ' ', $text); |
|
| 875 | + } |
|
| 876 | + $o['class'] = null; |
|
| 877 | + } |
|
| 878 | + |
|
| 879 | + return _L($text, $args, $o); |
|
| 881 | 880 | } |
| 882 | 881 | |
| 883 | 882 | |
@@ -904,53 +903,53 @@ discard block |
||
| 904 | 903 | * Texte |
| 905 | 904 | */ |
| 906 | 905 | function _L($text, $args = [], $options = []) { |
| 907 | - $f = $text; |
|
| 908 | - $defaut_options = [ |
|
| 909 | - 'class' => null, |
|
| 910 | - 'sanitize' => true, |
|
| 911 | - ]; |
|
| 912 | - // support de l'ancien argument $class |
|
| 913 | - if ($options and is_string($options)) { |
|
| 914 | - $options = ['class' => $options]; |
|
| 915 | - } |
|
| 916 | - if (is_array($options)) { |
|
| 917 | - $options += $defaut_options; |
|
| 918 | - } else { |
|
| 919 | - $options = $defaut_options; |
|
| 920 | - } |
|
| 921 | - |
|
| 922 | - if (is_array($args) and count($args)) { |
|
| 923 | - if (!function_exists('interdire_scripts')) { |
|
| 924 | - include_spip('inc/texte'); |
|
| 925 | - } |
|
| 926 | - if (!function_exists('echapper_html_suspect')) { |
|
| 927 | - include_spip('inc/texte_mini'); |
|
| 928 | - } |
|
| 929 | - foreach ($args as $name => $value) { |
|
| 930 | - if (strpos($text, (string) "@$name@") !== false) { |
|
| 931 | - if ($options['sanitize']) { |
|
| 932 | - $value = echapper_html_suspect($value); |
|
| 933 | - $value = interdire_scripts($value, -1); |
|
| 934 | - } |
|
| 935 | - if (!empty($options['class'])) { |
|
| 936 | - $value = "<span class='" . $options['class'] . "'>$value</span>"; |
|
| 937 | - } |
|
| 938 | - $text = str_replace("@$name@", $value, $text); |
|
| 939 | - unset($args[$name]); |
|
| 940 | - } |
|
| 941 | - } |
|
| 942 | - // Si des variables n'ont pas ete inserees, le signaler |
|
| 943 | - // (chaines de langues pas a jour) |
|
| 944 | - if ($args) { |
|
| 945 | - spip_log("$f: variables inutilisees " . join(', ', array_keys($args)), _LOG_DEBUG); |
|
| 946 | - } |
|
| 947 | - } |
|
| 948 | - |
|
| 949 | - if (($GLOBALS['test_i18n'] or (_request('var_mode') == 'traduction')) and is_null($options['class'])) { |
|
| 950 | - return "<span class='debug-traduction-erreur'>$text</span>"; |
|
| 951 | - } else { |
|
| 952 | - return $text; |
|
| 953 | - } |
|
| 906 | + $f = $text; |
|
| 907 | + $defaut_options = [ |
|
| 908 | + 'class' => null, |
|
| 909 | + 'sanitize' => true, |
|
| 910 | + ]; |
|
| 911 | + // support de l'ancien argument $class |
|
| 912 | + if ($options and is_string($options)) { |
|
| 913 | + $options = ['class' => $options]; |
|
| 914 | + } |
|
| 915 | + if (is_array($options)) { |
|
| 916 | + $options += $defaut_options; |
|
| 917 | + } else { |
|
| 918 | + $options = $defaut_options; |
|
| 919 | + } |
|
| 920 | + |
|
| 921 | + if (is_array($args) and count($args)) { |
|
| 922 | + if (!function_exists('interdire_scripts')) { |
|
| 923 | + include_spip('inc/texte'); |
|
| 924 | + } |
|
| 925 | + if (!function_exists('echapper_html_suspect')) { |
|
| 926 | + include_spip('inc/texte_mini'); |
|
| 927 | + } |
|
| 928 | + foreach ($args as $name => $value) { |
|
| 929 | + if (strpos($text, (string) "@$name@") !== false) { |
|
| 930 | + if ($options['sanitize']) { |
|
| 931 | + $value = echapper_html_suspect($value); |
|
| 932 | + $value = interdire_scripts($value, -1); |
|
| 933 | + } |
|
| 934 | + if (!empty($options['class'])) { |
|
| 935 | + $value = "<span class='" . $options['class'] . "'>$value</span>"; |
|
| 936 | + } |
|
| 937 | + $text = str_replace("@$name@", $value, $text); |
|
| 938 | + unset($args[$name]); |
|
| 939 | + } |
|
| 940 | + } |
|
| 941 | + // Si des variables n'ont pas ete inserees, le signaler |
|
| 942 | + // (chaines de langues pas a jour) |
|
| 943 | + if ($args) { |
|
| 944 | + spip_log("$f: variables inutilisees " . join(', ', array_keys($args)), _LOG_DEBUG); |
|
| 945 | + } |
|
| 946 | + } |
|
| 947 | + |
|
| 948 | + if (($GLOBALS['test_i18n'] or (_request('var_mode') == 'traduction')) and is_null($options['class'])) { |
|
| 949 | + return "<span class='debug-traduction-erreur'>$text</span>"; |
|
| 950 | + } else { |
|
| 951 | + return $text; |
|
| 952 | + } |
|
| 954 | 953 | } |
| 955 | 954 | |
| 956 | 955 | |
@@ -964,13 +963,13 @@ discard block |
||
| 964 | 963 | * @return string |
| 965 | 964 | */ |
| 966 | 965 | function joli_repertoire($rep) { |
| 967 | - $a = substr($rep, 0, 1); |
|
| 968 | - if ($a <> '.' and $a <> '/') { |
|
| 969 | - $rep = (_DIR_RESTREINT ? '' : _DIR_RESTREINT_ABS) . $rep; |
|
| 970 | - } |
|
| 971 | - $rep = preg_replace(',(^\.\.\/),', '', $rep); |
|
| 966 | + $a = substr($rep, 0, 1); |
|
| 967 | + if ($a <> '.' and $a <> '/') { |
|
| 968 | + $rep = (_DIR_RESTREINT ? '' : _DIR_RESTREINT_ABS) . $rep; |
|
| 969 | + } |
|
| 970 | + $rep = preg_replace(',(^\.\.\/),', '', $rep); |
|
| 972 | 971 | |
| 973 | - return $rep; |
|
| 972 | + return $rep; |
|
| 974 | 973 | } |
| 975 | 974 | |
| 976 | 975 | |
@@ -995,54 +994,54 @@ discard block |
||
| 995 | 994 | * @return float|int|string|void |
| 996 | 995 | */ |
| 997 | 996 | function spip_timer($t = 'rien', $raw = false) { |
| 998 | - static $time; |
|
| 999 | - $a = time(); |
|
| 1000 | - $b = microtime(); |
|
| 1001 | - // microtime peut contenir les microsecondes et le temps |
|
| 1002 | - $b = explode(' ', $b); |
|
| 1003 | - if (count($b) == 2) { |
|
| 1004 | - $a = end($b); |
|
| 1005 | - } // plus precis ! |
|
| 1006 | - $b = reset($b); |
|
| 1007 | - if (!isset($time[$t])) { |
|
| 1008 | - $time[$t] = $a + $b; |
|
| 1009 | - } else { |
|
| 1010 | - $p = ($a + $b - $time[$t]) * 1000; |
|
| 1011 | - unset($time[$t]); |
|
| 997 | + static $time; |
|
| 998 | + $a = time(); |
|
| 999 | + $b = microtime(); |
|
| 1000 | + // microtime peut contenir les microsecondes et le temps |
|
| 1001 | + $b = explode(' ', $b); |
|
| 1002 | + if (count($b) == 2) { |
|
| 1003 | + $a = end($b); |
|
| 1004 | + } // plus precis ! |
|
| 1005 | + $b = reset($b); |
|
| 1006 | + if (!isset($time[$t])) { |
|
| 1007 | + $time[$t] = $a + $b; |
|
| 1008 | + } else { |
|
| 1009 | + $p = ($a + $b - $time[$t]) * 1000; |
|
| 1010 | + unset($time[$t]); |
|
| 1012 | 1011 | # echo "'$p'";exit; |
| 1013 | - if ($raw) { |
|
| 1014 | - return $p; |
|
| 1015 | - } |
|
| 1016 | - if ($p < 1000) { |
|
| 1017 | - $s = ''; |
|
| 1018 | - } else { |
|
| 1019 | - $s = sprintf('%d ', $x = floor($p / 1000)); |
|
| 1020 | - $p -= ($x * 1000); |
|
| 1021 | - } |
|
| 1012 | + if ($raw) { |
|
| 1013 | + return $p; |
|
| 1014 | + } |
|
| 1015 | + if ($p < 1000) { |
|
| 1016 | + $s = ''; |
|
| 1017 | + } else { |
|
| 1018 | + $s = sprintf('%d ', $x = floor($p / 1000)); |
|
| 1019 | + $p -= ($x * 1000); |
|
| 1020 | + } |
|
| 1022 | 1021 | |
| 1023 | - return $s . sprintf($s ? '%07.3f ms' : '%.3f ms', $p); |
|
| 1024 | - } |
|
| 1022 | + return $s . sprintf($s ? '%07.3f ms' : '%.3f ms', $p); |
|
| 1023 | + } |
|
| 1025 | 1024 | } |
| 1026 | 1025 | |
| 1027 | 1026 | |
| 1028 | 1027 | // Renvoie False si un fichier n'est pas plus vieux que $duree secondes, |
| 1029 | 1028 | // sinon renvoie True et le date sauf si ca n'est pas souhaite |
| 1030 | 1029 | function spip_touch($fichier, $duree = 0, $touch = true) { |
| 1031 | - if ($duree) { |
|
| 1032 | - clearstatcache(); |
|
| 1033 | - if ((@$f = filemtime($fichier)) and ($f >= time() - $duree)) { |
|
| 1034 | - return false; |
|
| 1035 | - } |
|
| 1036 | - } |
|
| 1037 | - if ($touch !== false) { |
|
| 1038 | - if (!@touch($fichier)) { |
|
| 1039 | - spip_unlink($fichier); |
|
| 1040 | - @touch($fichier); |
|
| 1041 | - }; |
|
| 1042 | - @chmod($fichier, _SPIP_CHMOD & ~0111); |
|
| 1043 | - } |
|
| 1030 | + if ($duree) { |
|
| 1031 | + clearstatcache(); |
|
| 1032 | + if ((@$f = filemtime($fichier)) and ($f >= time() - $duree)) { |
|
| 1033 | + return false; |
|
| 1034 | + } |
|
| 1035 | + } |
|
| 1036 | + if ($touch !== false) { |
|
| 1037 | + if (!@touch($fichier)) { |
|
| 1038 | + spip_unlink($fichier); |
|
| 1039 | + @touch($fichier); |
|
| 1040 | + }; |
|
| 1041 | + @chmod($fichier, _SPIP_CHMOD & ~0111); |
|
| 1042 | + } |
|
| 1044 | 1043 | |
| 1045 | - return true; |
|
| 1044 | + return true; |
|
| 1046 | 1045 | } |
| 1047 | 1046 | |
| 1048 | 1047 | |
@@ -1053,11 +1052,11 @@ discard block |
||
| 1053 | 1052 | * @uses cron() |
| 1054 | 1053 | **/ |
| 1055 | 1054 | function action_cron() { |
| 1056 | - include_spip('inc/headers'); |
|
| 1057 | - http_response_code(204); // No Content |
|
| 1058 | - header('Connection: close'); |
|
| 1059 | - define('_DIRECT_CRON_FORCE', true); |
|
| 1060 | - cron(); |
|
| 1055 | + include_spip('inc/headers'); |
|
| 1056 | + http_response_code(204); // No Content |
|
| 1057 | + header('Connection: close'); |
|
| 1058 | + define('_DIRECT_CRON_FORCE', true); |
|
| 1059 | + cron(); |
|
| 1061 | 1060 | } |
| 1062 | 1061 | |
| 1063 | 1062 | /** |
@@ -1073,26 +1072,26 @@ discard block |
||
| 1073 | 1072 | * True si la tache a pu être effectuée |
| 1074 | 1073 | */ |
| 1075 | 1074 | function cron($taches = [], $taches_old = []) { |
| 1076 | - // si pas en mode cron force, laisser tomber. |
|
| 1077 | - if (!defined('_DIRECT_CRON_FORCE')) { |
|
| 1078 | - return false; |
|
| 1079 | - } |
|
| 1080 | - if (!is_array($taches)) { |
|
| 1081 | - $taches = $taches_old; |
|
| 1082 | - } // compat anciens appels |
|
| 1083 | - // si taches a inserer en base et base inaccessible, laisser tomber |
|
| 1084 | - // sinon on ne verifie pas la connexion tout de suite, car si ca se trouve |
|
| 1085 | - // queue_sleep_time_to_next_job() dira qu'il n'y a rien a faire |
|
| 1086 | - // et on evite d'ouvrir une connexion pour rien (utilisation de _DIRECT_CRON_FORCE dans mes_options.php) |
|
| 1087 | - if ($taches and count($taches) and !spip_connect()) { |
|
| 1088 | - return false; |
|
| 1089 | - } |
|
| 1090 | - spip_log('cron !', 'jq' . _LOG_DEBUG); |
|
| 1091 | - if ($genie = charger_fonction('genie', 'inc', true)) { |
|
| 1092 | - return $genie($taches); |
|
| 1093 | - } |
|
| 1094 | - |
|
| 1095 | - return false; |
|
| 1075 | + // si pas en mode cron force, laisser tomber. |
|
| 1076 | + if (!defined('_DIRECT_CRON_FORCE')) { |
|
| 1077 | + return false; |
|
| 1078 | + } |
|
| 1079 | + if (!is_array($taches)) { |
|
| 1080 | + $taches = $taches_old; |
|
| 1081 | + } // compat anciens appels |
|
| 1082 | + // si taches a inserer en base et base inaccessible, laisser tomber |
|
| 1083 | + // sinon on ne verifie pas la connexion tout de suite, car si ca se trouve |
|
| 1084 | + // queue_sleep_time_to_next_job() dira qu'il n'y a rien a faire |
|
| 1085 | + // et on evite d'ouvrir une connexion pour rien (utilisation de _DIRECT_CRON_FORCE dans mes_options.php) |
|
| 1086 | + if ($taches and count($taches) and !spip_connect()) { |
|
| 1087 | + return false; |
|
| 1088 | + } |
|
| 1089 | + spip_log('cron !', 'jq' . _LOG_DEBUG); |
|
| 1090 | + if ($genie = charger_fonction('genie', 'inc', true)) { |
|
| 1091 | + return $genie($taches); |
|
| 1092 | + } |
|
| 1093 | + |
|
| 1094 | + return false; |
|
| 1096 | 1095 | } |
| 1097 | 1096 | |
| 1098 | 1097 | /** |
@@ -1124,17 +1123,17 @@ discard block |
||
| 1124 | 1123 | * Le numéro de travail ajouté ou `0` si aucun travail n’a été ajouté. |
| 1125 | 1124 | */ |
| 1126 | 1125 | function job_queue_add( |
| 1127 | - $function, |
|
| 1128 | - $description, |
|
| 1129 | - $arguments = [], |
|
| 1130 | - $file = '', |
|
| 1131 | - $no_duplicate = false, |
|
| 1132 | - $time = 0, |
|
| 1133 | - $priority = 0 |
|
| 1126 | + $function, |
|
| 1127 | + $description, |
|
| 1128 | + $arguments = [], |
|
| 1129 | + $file = '', |
|
| 1130 | + $no_duplicate = false, |
|
| 1131 | + $time = 0, |
|
| 1132 | + $priority = 0 |
|
| 1134 | 1133 | ) { |
| 1135 | - include_spip('inc/queue'); |
|
| 1134 | + include_spip('inc/queue'); |
|
| 1136 | 1135 | |
| 1137 | - return queue_add_job($function, $description, $arguments, $file, $no_duplicate, $time, $priority); |
|
| 1136 | + return queue_add_job($function, $description, $arguments, $file, $no_duplicate, $time, $priority); |
|
| 1138 | 1137 | } |
| 1139 | 1138 | |
| 1140 | 1139 | /** |
@@ -1145,9 +1144,9 @@ discard block |
||
| 1145 | 1144 | * @return bool |
| 1146 | 1145 | */ |
| 1147 | 1146 | function job_queue_remove($id_job) { |
| 1148 | - include_spip('inc/queue'); |
|
| 1147 | + include_spip('inc/queue'); |
|
| 1149 | 1148 | |
| 1150 | - return queue_remove_job($id_job); |
|
| 1149 | + return queue_remove_job($id_job); |
|
| 1151 | 1150 | } |
| 1152 | 1151 | |
| 1153 | 1152 | /** |
@@ -1160,9 +1159,9 @@ discard block |
||
| 1160 | 1159 | * or an array of simple array to link multiples objet in one time |
| 1161 | 1160 | */ |
| 1162 | 1161 | function job_queue_link($id_job, $objets) { |
| 1163 | - include_spip('inc/queue'); |
|
| 1162 | + include_spip('inc/queue'); |
|
| 1164 | 1163 | |
| 1165 | - return queue_link_job($id_job, $objets); |
|
| 1164 | + return queue_link_job($id_job, $objets); |
|
| 1166 | 1165 | } |
| 1167 | 1166 | |
| 1168 | 1167 | |
@@ -1182,36 +1181,36 @@ discard block |
||
| 1182 | 1181 | * - `null` si la queue n'est pas encore initialisée |
| 1183 | 1182 | */ |
| 1184 | 1183 | function queue_sleep_time_to_next_job($force = null) { |
| 1185 | - static $queue_next_job_time = -1; |
|
| 1186 | - if ($force === true) { |
|
| 1187 | - $queue_next_job_time = -1; |
|
| 1188 | - } elseif ($force) { |
|
| 1189 | - $queue_next_job_time = $force; |
|
| 1190 | - } |
|
| 1191 | - |
|
| 1192 | - if ($queue_next_job_time == -1) { |
|
| 1193 | - if (!defined('_JQ_NEXT_JOB_TIME_FILENAME')) { |
|
| 1194 | - define('_JQ_NEXT_JOB_TIME_FILENAME', _DIR_TMP . 'job_queue_next.txt'); |
|
| 1195 | - } |
|
| 1196 | - // utiliser un cache memoire si dispo |
|
| 1197 | - if (function_exists('cache_get') and defined('_MEMOIZE_MEMORY') and _MEMOIZE_MEMORY) { |
|
| 1198 | - $queue_next_job_time = cache_get(_JQ_NEXT_JOB_TIME_FILENAME); |
|
| 1199 | - } else { |
|
| 1200 | - $queue_next_job_time = null; |
|
| 1201 | - if (lire_fichier(_JQ_NEXT_JOB_TIME_FILENAME, $contenu)) { |
|
| 1202 | - $queue_next_job_time = intval($contenu); |
|
| 1203 | - } |
|
| 1204 | - } |
|
| 1205 | - } |
|
| 1206 | - |
|
| 1207 | - if (is_null($queue_next_job_time)) { |
|
| 1208 | - return null; |
|
| 1209 | - } |
|
| 1210 | - if (!$_SERVER['REQUEST_TIME']) { |
|
| 1211 | - $_SERVER['REQUEST_TIME'] = time(); |
|
| 1212 | - } |
|
| 1213 | - |
|
| 1214 | - return $queue_next_job_time - $_SERVER['REQUEST_TIME']; |
|
| 1184 | + static $queue_next_job_time = -1; |
|
| 1185 | + if ($force === true) { |
|
| 1186 | + $queue_next_job_time = -1; |
|
| 1187 | + } elseif ($force) { |
|
| 1188 | + $queue_next_job_time = $force; |
|
| 1189 | + } |
|
| 1190 | + |
|
| 1191 | + if ($queue_next_job_time == -1) { |
|
| 1192 | + if (!defined('_JQ_NEXT_JOB_TIME_FILENAME')) { |
|
| 1193 | + define('_JQ_NEXT_JOB_TIME_FILENAME', _DIR_TMP . 'job_queue_next.txt'); |
|
| 1194 | + } |
|
| 1195 | + // utiliser un cache memoire si dispo |
|
| 1196 | + if (function_exists('cache_get') and defined('_MEMOIZE_MEMORY') and _MEMOIZE_MEMORY) { |
|
| 1197 | + $queue_next_job_time = cache_get(_JQ_NEXT_JOB_TIME_FILENAME); |
|
| 1198 | + } else { |
|
| 1199 | + $queue_next_job_time = null; |
|
| 1200 | + if (lire_fichier(_JQ_NEXT_JOB_TIME_FILENAME, $contenu)) { |
|
| 1201 | + $queue_next_job_time = intval($contenu); |
|
| 1202 | + } |
|
| 1203 | + } |
|
| 1204 | + } |
|
| 1205 | + |
|
| 1206 | + if (is_null($queue_next_job_time)) { |
|
| 1207 | + return null; |
|
| 1208 | + } |
|
| 1209 | + if (!$_SERVER['REQUEST_TIME']) { |
|
| 1210 | + $_SERVER['REQUEST_TIME'] = time(); |
|
| 1211 | + } |
|
| 1212 | + |
|
| 1213 | + return $queue_next_job_time - $_SERVER['REQUEST_TIME']; |
|
| 1215 | 1214 | } |
| 1216 | 1215 | |
| 1217 | 1216 | |
@@ -1223,11 +1222,11 @@ discard block |
||
| 1223 | 1222 | * @return string |
| 1224 | 1223 | */ |
| 1225 | 1224 | function quote_amp($u) { |
| 1226 | - return preg_replace( |
|
| 1227 | - '/&(?![a-z]{0,4}\w{2,3};|#x?[0-9a-f]{2,6};)/i', |
|
| 1228 | - '&', |
|
| 1229 | - $u |
|
| 1230 | - ); |
|
| 1225 | + return preg_replace( |
|
| 1226 | + '/&(?![a-z]{0,4}\w{2,3};|#x?[0-9a-f]{2,6};)/i', |
|
| 1227 | + '&', |
|
| 1228 | + $u |
|
| 1229 | + ); |
|
| 1231 | 1230 | } |
| 1232 | 1231 | |
| 1233 | 1232 | |
@@ -1250,27 +1249,27 @@ discard block |
||
| 1250 | 1249 | * Balise HTML `<script>` et son contenu |
| 1251 | 1250 | **/ |
| 1252 | 1251 | function http_script($script, $src = '', $noscript = '') { |
| 1253 | - static $done = []; |
|
| 1252 | + static $done = []; |
|
| 1254 | 1253 | |
| 1255 | - if ($src && !isset($done[$src])) { |
|
| 1256 | - $done[$src] = true; |
|
| 1257 | - $src = find_in_path($src, _JAVASCRIPT); |
|
| 1258 | - $src = " src='$src'"; |
|
| 1259 | - } else { |
|
| 1260 | - $src = ''; |
|
| 1261 | - } |
|
| 1262 | - if ($script) { |
|
| 1263 | - $script = ("/*<![CDATA[*/\n" . |
|
| 1264 | - preg_replace(',</([^>]*)>,', '<\/\1>', $script) . |
|
| 1265 | - '/*]]>*/'); |
|
| 1266 | - } |
|
| 1267 | - if ($noscript) { |
|
| 1268 | - $noscript = "<noscript>\n\t$noscript\n</noscript>\n"; |
|
| 1269 | - } |
|
| 1254 | + if ($src && !isset($done[$src])) { |
|
| 1255 | + $done[$src] = true; |
|
| 1256 | + $src = find_in_path($src, _JAVASCRIPT); |
|
| 1257 | + $src = " src='$src'"; |
|
| 1258 | + } else { |
|
| 1259 | + $src = ''; |
|
| 1260 | + } |
|
| 1261 | + if ($script) { |
|
| 1262 | + $script = ("/*<![CDATA[*/\n" . |
|
| 1263 | + preg_replace(',</([^>]*)>,', '<\/\1>', $script) . |
|
| 1264 | + '/*]]>*/'); |
|
| 1265 | + } |
|
| 1266 | + if ($noscript) { |
|
| 1267 | + $noscript = "<noscript>\n\t$noscript\n</noscript>\n"; |
|
| 1268 | + } |
|
| 1270 | 1269 | |
| 1271 | - return ($src or $script or $noscript) |
|
| 1272 | - ? "<script type='text/javascript'$src>$script</script>$noscript" |
|
| 1273 | - : ''; |
|
| 1270 | + return ($src or $script or $noscript) |
|
| 1271 | + ? "<script type='text/javascript'$src>$script</script>$noscript" |
|
| 1272 | + : ''; |
|
| 1274 | 1273 | } |
| 1275 | 1274 | |
| 1276 | 1275 | |
@@ -1305,7 +1304,7 @@ discard block |
||
| 1305 | 1304 | * Texte échappé |
| 1306 | 1305 | **/ |
| 1307 | 1306 | function texte_script(string $texte): string { |
| 1308 | - return str_replace('\'', '\\\'', str_replace('\\', '\\\\', $texte)); |
|
| 1307 | + return str_replace('\'', '\\\'', str_replace('\\', '\\\\', $texte)); |
|
| 1309 | 1308 | } |
| 1310 | 1309 | |
| 1311 | 1310 | |
@@ -1342,68 +1341,68 @@ discard block |
||
| 1342 | 1341 | * Liste des chemins, par ordre de priorité. |
| 1343 | 1342 | **/ |
| 1344 | 1343 | function _chemin($dir_path = null) { |
| 1345 | - static $path_base = null; |
|
| 1346 | - static $path_full = null; |
|
| 1347 | - if ($path_base == null) { |
|
| 1348 | - // Chemin standard depuis l'espace public |
|
| 1349 | - $path = defined('_SPIP_PATH') ? _SPIP_PATH : |
|
| 1350 | - _DIR_RACINE . ':' . |
|
| 1351 | - _DIR_RACINE . 'squelettes-dist/:' . |
|
| 1352 | - _DIR_RACINE . 'prive/:' . |
|
| 1353 | - _DIR_RESTREINT; |
|
| 1354 | - // Ajouter squelettes/ |
|
| 1355 | - if (@is_dir(_DIR_RACINE . 'squelettes')) { |
|
| 1356 | - $path = _DIR_RACINE . 'squelettes/:' . $path; |
|
| 1357 | - } |
|
| 1358 | - foreach (explode(':', $path) as $dir) { |
|
| 1359 | - if (strlen($dir) and substr($dir, -1) != '/') { |
|
| 1360 | - $dir .= '/'; |
|
| 1361 | - } |
|
| 1362 | - $path_base[] = $dir; |
|
| 1363 | - } |
|
| 1364 | - $path_full = $path_base; |
|
| 1365 | - // Et le(s) dossier(s) des squelettes nommes |
|
| 1366 | - if (strlen($GLOBALS['dossier_squelettes'])) { |
|
| 1367 | - foreach (array_reverse(explode(':', $GLOBALS['dossier_squelettes'])) as $d) { |
|
| 1368 | - array_unshift($path_full, ($d[0] == '/' ? '' : _DIR_RACINE) . $d . '/'); |
|
| 1369 | - } |
|
| 1370 | - } |
|
| 1371 | - $GLOBALS['path_sig'] = md5(serialize($path_full)); |
|
| 1372 | - } |
|
| 1373 | - if ($dir_path === null) { |
|
| 1374 | - return $path_full; |
|
| 1375 | - } |
|
| 1376 | - |
|
| 1377 | - if (is_array($dir_path) or strlen($dir_path)) { |
|
| 1378 | - $tete = ''; |
|
| 1379 | - if (reset($path_base) == _DIR_RACINE . 'squelettes/') { |
|
| 1380 | - $tete = array_shift($path_base); |
|
| 1381 | - } |
|
| 1382 | - $dirs = (is_array($dir_path) ? $dir_path : explode(':', $dir_path)); |
|
| 1383 | - $dirs = array_reverse($dirs); |
|
| 1384 | - foreach ($dirs as $dir_path) { |
|
| 1385 | - if (substr($dir_path, -1) != '/') { |
|
| 1386 | - $dir_path .= '/'; |
|
| 1387 | - } |
|
| 1388 | - if (!in_array($dir_path, $path_base)) { |
|
| 1389 | - array_unshift($path_base, $dir_path); |
|
| 1390 | - } |
|
| 1391 | - } |
|
| 1392 | - if (strlen($tete)) { |
|
| 1393 | - array_unshift($path_base, $tete); |
|
| 1394 | - } |
|
| 1395 | - } |
|
| 1396 | - $path_full = $path_base; |
|
| 1397 | - // Et le(s) dossier(s) des squelettes nommes |
|
| 1398 | - if (strlen($GLOBALS['dossier_squelettes'])) { |
|
| 1399 | - foreach (array_reverse(explode(':', $GLOBALS['dossier_squelettes'])) as $d) { |
|
| 1400 | - array_unshift($path_full, ((isset($d[0]) and $d[0] == '/') ? '' : _DIR_RACINE) . $d . '/'); |
|
| 1401 | - } |
|
| 1402 | - } |
|
| 1403 | - |
|
| 1404 | - $GLOBALS['path_sig'] = md5(serialize($path_full)); |
|
| 1405 | - |
|
| 1406 | - return $path_full; |
|
| 1344 | + static $path_base = null; |
|
| 1345 | + static $path_full = null; |
|
| 1346 | + if ($path_base == null) { |
|
| 1347 | + // Chemin standard depuis l'espace public |
|
| 1348 | + $path = defined('_SPIP_PATH') ? _SPIP_PATH : |
|
| 1349 | + _DIR_RACINE . ':' . |
|
| 1350 | + _DIR_RACINE . 'squelettes-dist/:' . |
|
| 1351 | + _DIR_RACINE . 'prive/:' . |
|
| 1352 | + _DIR_RESTREINT; |
|
| 1353 | + // Ajouter squelettes/ |
|
| 1354 | + if (@is_dir(_DIR_RACINE . 'squelettes')) { |
|
| 1355 | + $path = _DIR_RACINE . 'squelettes/:' . $path; |
|
| 1356 | + } |
|
| 1357 | + foreach (explode(':', $path) as $dir) { |
|
| 1358 | + if (strlen($dir) and substr($dir, -1) != '/') { |
|
| 1359 | + $dir .= '/'; |
|
| 1360 | + } |
|
| 1361 | + $path_base[] = $dir; |
|
| 1362 | + } |
|
| 1363 | + $path_full = $path_base; |
|
| 1364 | + // Et le(s) dossier(s) des squelettes nommes |
|
| 1365 | + if (strlen($GLOBALS['dossier_squelettes'])) { |
|
| 1366 | + foreach (array_reverse(explode(':', $GLOBALS['dossier_squelettes'])) as $d) { |
|
| 1367 | + array_unshift($path_full, ($d[0] == '/' ? '' : _DIR_RACINE) . $d . '/'); |
|
| 1368 | + } |
|
| 1369 | + } |
|
| 1370 | + $GLOBALS['path_sig'] = md5(serialize($path_full)); |
|
| 1371 | + } |
|
| 1372 | + if ($dir_path === null) { |
|
| 1373 | + return $path_full; |
|
| 1374 | + } |
|
| 1375 | + |
|
| 1376 | + if (is_array($dir_path) or strlen($dir_path)) { |
|
| 1377 | + $tete = ''; |
|
| 1378 | + if (reset($path_base) == _DIR_RACINE . 'squelettes/') { |
|
| 1379 | + $tete = array_shift($path_base); |
|
| 1380 | + } |
|
| 1381 | + $dirs = (is_array($dir_path) ? $dir_path : explode(':', $dir_path)); |
|
| 1382 | + $dirs = array_reverse($dirs); |
|
| 1383 | + foreach ($dirs as $dir_path) { |
|
| 1384 | + if (substr($dir_path, -1) != '/') { |
|
| 1385 | + $dir_path .= '/'; |
|
| 1386 | + } |
|
| 1387 | + if (!in_array($dir_path, $path_base)) { |
|
| 1388 | + array_unshift($path_base, $dir_path); |
|
| 1389 | + } |
|
| 1390 | + } |
|
| 1391 | + if (strlen($tete)) { |
|
| 1392 | + array_unshift($path_base, $tete); |
|
| 1393 | + } |
|
| 1394 | + } |
|
| 1395 | + $path_full = $path_base; |
|
| 1396 | + // Et le(s) dossier(s) des squelettes nommes |
|
| 1397 | + if (strlen($GLOBALS['dossier_squelettes'])) { |
|
| 1398 | + foreach (array_reverse(explode(':', $GLOBALS['dossier_squelettes'])) as $d) { |
|
| 1399 | + array_unshift($path_full, ((isset($d[0]) and $d[0] == '/') ? '' : _DIR_RACINE) . $d . '/'); |
|
| 1400 | + } |
|
| 1401 | + } |
|
| 1402 | + |
|
| 1403 | + $GLOBALS['path_sig'] = md5(serialize($path_full)); |
|
| 1404 | + |
|
| 1405 | + return $path_full; |
|
| 1407 | 1406 | } |
| 1408 | 1407 | |
| 1409 | 1408 | /** |
@@ -1416,78 +1415,78 @@ discard block |
||
| 1416 | 1415 | * @return array Liste de chemins |
| 1417 | 1416 | **/ |
| 1418 | 1417 | function creer_chemin() { |
| 1419 | - $path_a = _chemin(); |
|
| 1420 | - static $c = ''; |
|
| 1418 | + $path_a = _chemin(); |
|
| 1419 | + static $c = ''; |
|
| 1421 | 1420 | |
| 1422 | - // on calcule le chemin si le dossier skel a change |
|
| 1423 | - if ($c != $GLOBALS['dossier_squelettes']) { |
|
| 1424 | - // assurer le non plantage lors de la montee de version : |
|
| 1425 | - $c = $GLOBALS['dossier_squelettes']; |
|
| 1426 | - $path_a = _chemin(''); // forcer un recalcul du chemin |
|
| 1427 | - } |
|
| 1421 | + // on calcule le chemin si le dossier skel a change |
|
| 1422 | + if ($c != $GLOBALS['dossier_squelettes']) { |
|
| 1423 | + // assurer le non plantage lors de la montee de version : |
|
| 1424 | + $c = $GLOBALS['dossier_squelettes']; |
|
| 1425 | + $path_a = _chemin(''); // forcer un recalcul du chemin |
|
| 1426 | + } |
|
| 1428 | 1427 | |
| 1429 | - return $path_a; |
|
| 1428 | + return $path_a; |
|
| 1430 | 1429 | } |
| 1431 | 1430 | |
| 1432 | 1431 | |
| 1433 | 1432 | function lister_themes_prives() { |
| 1434 | - static $themes = null; |
|
| 1435 | - if (is_null($themes)) { |
|
| 1436 | - // si pas encore definie |
|
| 1437 | - if (!defined('_SPIP_THEME_PRIVE')) { |
|
| 1438 | - define('_SPIP_THEME_PRIVE', 'spip'); |
|
| 1439 | - } |
|
| 1440 | - $themes = [_SPIP_THEME_PRIVE]; |
|
| 1441 | - // lors d'une installation neuve, prefs n'est pas definie. |
|
| 1442 | - if (isset($GLOBALS['visiteur_session']['prefs'])) { |
|
| 1443 | - $prefs = $GLOBALS['visiteur_session']['prefs']; |
|
| 1444 | - } else { |
|
| 1445 | - $prefs = []; |
|
| 1446 | - } |
|
| 1447 | - if (is_string($prefs)) { |
|
| 1448 | - $prefs = unserialize($GLOBALS['visiteur_session']['prefs']); |
|
| 1449 | - } |
|
| 1450 | - if ( |
|
| 1451 | - ((isset($prefs['theme']) and $theme = $prefs['theme']) |
|
| 1452 | - or (isset($GLOBALS['theme_prive_defaut']) and $theme = $GLOBALS['theme_prive_defaut'])) |
|
| 1453 | - and $theme != _SPIP_THEME_PRIVE |
|
| 1454 | - ) { |
|
| 1455 | - array_unshift($themes, $theme); |
|
| 1456 | - } // placer le theme choisi en tete |
|
| 1457 | - } |
|
| 1458 | - |
|
| 1459 | - return $themes; |
|
| 1433 | + static $themes = null; |
|
| 1434 | + if (is_null($themes)) { |
|
| 1435 | + // si pas encore definie |
|
| 1436 | + if (!defined('_SPIP_THEME_PRIVE')) { |
|
| 1437 | + define('_SPIP_THEME_PRIVE', 'spip'); |
|
| 1438 | + } |
|
| 1439 | + $themes = [_SPIP_THEME_PRIVE]; |
|
| 1440 | + // lors d'une installation neuve, prefs n'est pas definie. |
|
| 1441 | + if (isset($GLOBALS['visiteur_session']['prefs'])) { |
|
| 1442 | + $prefs = $GLOBALS['visiteur_session']['prefs']; |
|
| 1443 | + } else { |
|
| 1444 | + $prefs = []; |
|
| 1445 | + } |
|
| 1446 | + if (is_string($prefs)) { |
|
| 1447 | + $prefs = unserialize($GLOBALS['visiteur_session']['prefs']); |
|
| 1448 | + } |
|
| 1449 | + if ( |
|
| 1450 | + ((isset($prefs['theme']) and $theme = $prefs['theme']) |
|
| 1451 | + or (isset($GLOBALS['theme_prive_defaut']) and $theme = $GLOBALS['theme_prive_defaut'])) |
|
| 1452 | + and $theme != _SPIP_THEME_PRIVE |
|
| 1453 | + ) { |
|
| 1454 | + array_unshift($themes, $theme); |
|
| 1455 | + } // placer le theme choisi en tete |
|
| 1456 | + } |
|
| 1457 | + |
|
| 1458 | + return $themes; |
|
| 1460 | 1459 | } |
| 1461 | 1460 | |
| 1462 | 1461 | function find_in_theme($file, $subdir = '', $include = false) { |
| 1463 | - static $themefiles = []; |
|
| 1464 | - if (isset($themefiles["$subdir$file"])) { |
|
| 1465 | - return $themefiles["$subdir$file"]; |
|
| 1466 | - } |
|
| 1467 | - // on peut fournir une icone generique -xx.svg qui fera le job dans toutes les tailles, et qui est prioritaire sur le png |
|
| 1468 | - // si il y a un .svg a la bonne taille (-16.svg) a cote, on l'utilise en remplacement du -16.png |
|
| 1469 | - if ( |
|
| 1470 | - preg_match(',-(\d+)[.](png|gif|svg)$,', $file, $m) |
|
| 1471 | - and $file_svg_generique = substr($file, 0, -strlen($m[0])) . '-xx.svg' |
|
| 1472 | - and $f = find_in_theme("$file_svg_generique") |
|
| 1473 | - ) { |
|
| 1474 | - if ($fsize = substr($f, 0, -6) . $m[1] . '.svg' and file_exists($fsize)) { |
|
| 1475 | - return $themefiles["$subdir$file"] = $fsize; |
|
| 1476 | - } |
|
| 1477 | - else { |
|
| 1478 | - return $themefiles["$subdir$file"] = "$f?" . $m[1] . 'px'; |
|
| 1479 | - } |
|
| 1480 | - } |
|
| 1481 | - |
|
| 1482 | - $themes = lister_themes_prives(); |
|
| 1483 | - foreach ($themes as $theme) { |
|
| 1484 | - if ($f = find_in_path($file, "prive/themes/$theme/$subdir", $include)) { |
|
| 1485 | - return $themefiles["$subdir$file"] = $f; |
|
| 1486 | - } |
|
| 1487 | - } |
|
| 1488 | - spip_log("$file introuvable dans le theme prive " . reset($themes), 'theme'); |
|
| 1489 | - |
|
| 1490 | - return $themefiles["$subdir$file"] = ''; |
|
| 1462 | + static $themefiles = []; |
|
| 1463 | + if (isset($themefiles["$subdir$file"])) { |
|
| 1464 | + return $themefiles["$subdir$file"]; |
|
| 1465 | + } |
|
| 1466 | + // on peut fournir une icone generique -xx.svg qui fera le job dans toutes les tailles, et qui est prioritaire sur le png |
|
| 1467 | + // si il y a un .svg a la bonne taille (-16.svg) a cote, on l'utilise en remplacement du -16.png |
|
| 1468 | + if ( |
|
| 1469 | + preg_match(',-(\d+)[.](png|gif|svg)$,', $file, $m) |
|
| 1470 | + and $file_svg_generique = substr($file, 0, -strlen($m[0])) . '-xx.svg' |
|
| 1471 | + and $f = find_in_theme("$file_svg_generique") |
|
| 1472 | + ) { |
|
| 1473 | + if ($fsize = substr($f, 0, -6) . $m[1] . '.svg' and file_exists($fsize)) { |
|
| 1474 | + return $themefiles["$subdir$file"] = $fsize; |
|
| 1475 | + } |
|
| 1476 | + else { |
|
| 1477 | + return $themefiles["$subdir$file"] = "$f?" . $m[1] . 'px'; |
|
| 1478 | + } |
|
| 1479 | + } |
|
| 1480 | + |
|
| 1481 | + $themes = lister_themes_prives(); |
|
| 1482 | + foreach ($themes as $theme) { |
|
| 1483 | + if ($f = find_in_path($file, "prive/themes/$theme/$subdir", $include)) { |
|
| 1484 | + return $themefiles["$subdir$file"] = $f; |
|
| 1485 | + } |
|
| 1486 | + } |
|
| 1487 | + spip_log("$file introuvable dans le theme prive " . reset($themes), 'theme'); |
|
| 1488 | + |
|
| 1489 | + return $themefiles["$subdir$file"] = ''; |
|
| 1491 | 1490 | } |
| 1492 | 1491 | |
| 1493 | 1492 | |
@@ -1511,31 +1510,31 @@ discard block |
||
| 1511 | 1510 | * sinon chaîne vide. |
| 1512 | 1511 | **/ |
| 1513 | 1512 | function chemin_image($icone) { |
| 1514 | - static $icone_renommer; |
|
| 1515 | - if ($p = strpos($icone, '?')) { |
|
| 1516 | - $icone = substr($icone, 0, $p); |
|
| 1517 | - } |
|
| 1518 | - // gerer le cas d'un double appel en evitant de refaire le travail inutilement |
|
| 1519 | - if (strpos($icone, '/') !== false and file_exists($icone)) { |
|
| 1520 | - return $icone; |
|
| 1521 | - } |
|
| 1522 | - |
|
| 1523 | - // si c'est un nom d'image complet (article-24.png) essayer de le renvoyer direct |
|
| 1524 | - if (preg_match(',[.](png|gif|jpg|webp|svg)$,', $icone) and $f = find_in_theme("images/$icone")) { |
|
| 1525 | - return $f; |
|
| 1526 | - } |
|
| 1527 | - // sinon passer par le module de renommage |
|
| 1528 | - if (is_null($icone_renommer)) { |
|
| 1529 | - $icone_renommer = charger_fonction('icone_renommer', 'inc', true); |
|
| 1530 | - } |
|
| 1531 | - if ($icone_renommer) { |
|
| 1532 | - [$icone, $fonction] = $icone_renommer($icone, ''); |
|
| 1533 | - if (file_exists($icone)) { |
|
| 1534 | - return $icone; |
|
| 1535 | - } |
|
| 1536 | - } |
|
| 1537 | - |
|
| 1538 | - return find_in_path($icone, _NOM_IMG_PACK); |
|
| 1513 | + static $icone_renommer; |
|
| 1514 | + if ($p = strpos($icone, '?')) { |
|
| 1515 | + $icone = substr($icone, 0, $p); |
|
| 1516 | + } |
|
| 1517 | + // gerer le cas d'un double appel en evitant de refaire le travail inutilement |
|
| 1518 | + if (strpos($icone, '/') !== false and file_exists($icone)) { |
|
| 1519 | + return $icone; |
|
| 1520 | + } |
|
| 1521 | + |
|
| 1522 | + // si c'est un nom d'image complet (article-24.png) essayer de le renvoyer direct |
|
| 1523 | + if (preg_match(',[.](png|gif|jpg|webp|svg)$,', $icone) and $f = find_in_theme("images/$icone")) { |
|
| 1524 | + return $f; |
|
| 1525 | + } |
|
| 1526 | + // sinon passer par le module de renommage |
|
| 1527 | + if (is_null($icone_renommer)) { |
|
| 1528 | + $icone_renommer = charger_fonction('icone_renommer', 'inc', true); |
|
| 1529 | + } |
|
| 1530 | + if ($icone_renommer) { |
|
| 1531 | + [$icone, $fonction] = $icone_renommer($icone, ''); |
|
| 1532 | + if (file_exists($icone)) { |
|
| 1533 | + return $icone; |
|
| 1534 | + } |
|
| 1535 | + } |
|
| 1536 | + |
|
| 1537 | + return find_in_path($icone, _NOM_IMG_PACK); |
|
| 1539 | 1538 | } |
| 1540 | 1539 | |
| 1541 | 1540 | // |
@@ -1573,128 +1572,128 @@ discard block |
||
| 1573 | 1572 | * - false : fichier introuvable |
| 1574 | 1573 | **/ |
| 1575 | 1574 | function find_in_path($file, $dirname = '', $include = false) { |
| 1576 | - static $dirs = []; |
|
| 1577 | - static $inc = []; # cf https://git.spip.net/spip/spip/commit/42e4e028e38c839121efaee84308d08aee307eec |
|
| 1578 | - static $c = ''; |
|
| 1579 | - |
|
| 1580 | - if (!$file and !strlen($file)) { |
|
| 1581 | - return false; |
|
| 1582 | - } |
|
| 1583 | - |
|
| 1584 | - // on calcule le chemin si le dossier skel a change |
|
| 1585 | - if ($c != $GLOBALS['dossier_squelettes']) { |
|
| 1586 | - // assurer le non plantage lors de la montee de version : |
|
| 1587 | - $c = $GLOBALS['dossier_squelettes']; |
|
| 1588 | - creer_chemin(); // forcer un recalcul du chemin et la mise a jour de path_sig |
|
| 1589 | - } |
|
| 1590 | - |
|
| 1591 | - if (isset($GLOBALS['path_files'][$GLOBALS['path_sig']][$dirname][$file])) { |
|
| 1592 | - if (!$GLOBALS['path_files'][$GLOBALS['path_sig']][$dirname][$file]) { |
|
| 1593 | - return false; |
|
| 1594 | - } |
|
| 1595 | - if ($include and !isset($inc[$dirname][$file])) { |
|
| 1596 | - include_once _ROOT_CWD . $GLOBALS['path_files'][$GLOBALS['path_sig']][$dirname][$file]; |
|
| 1597 | - $inc[$dirname][$file] = $inc[''][$dirname . $file] = true; |
|
| 1598 | - } |
|
| 1599 | - |
|
| 1600 | - return $GLOBALS['path_files'][$GLOBALS['path_sig']][$dirname][$file]; |
|
| 1601 | - } |
|
| 1602 | - |
|
| 1603 | - $a = strrpos($file, '/'); |
|
| 1604 | - if ($a !== false) { |
|
| 1605 | - $dirname .= substr($file, 0, ++$a); |
|
| 1606 | - $file = substr($file, $a); |
|
| 1607 | - } |
|
| 1608 | - |
|
| 1609 | - foreach (creer_chemin() as $dir) { |
|
| 1610 | - if (!isset($dirs[$a = $dir . $dirname])) { |
|
| 1611 | - $dirs[$a] = (is_dir(_ROOT_CWD . $a) || !$a); |
|
| 1612 | - } |
|
| 1613 | - if ($dirs[$a]) { |
|
| 1614 | - if (file_exists(_ROOT_CWD . ($a .= $file))) { |
|
| 1615 | - if ($include and !isset($inc[$dirname][$file])) { |
|
| 1616 | - include_once _ROOT_CWD . $a; |
|
| 1617 | - $inc[$dirname][$file] = $inc[''][$dirname . $file] = true; |
|
| 1618 | - } |
|
| 1619 | - if (!defined('_SAUVER_CHEMIN')) { |
|
| 1620 | - // si le chemin n'a pas encore ete charge, ne pas lever le flag, ne pas cacher |
|
| 1621 | - if (is_null($GLOBALS['path_files'])) { |
|
| 1622 | - return $a; |
|
| 1623 | - } |
|
| 1624 | - define('_SAUVER_CHEMIN', true); |
|
| 1625 | - } |
|
| 1626 | - |
|
| 1627 | - return $GLOBALS['path_files'][$GLOBALS['path_sig']][$dirname][$file] = $GLOBALS['path_files'][$GLOBALS['path_sig']][''][$dirname . $file] = $a; |
|
| 1628 | - } |
|
| 1629 | - } |
|
| 1630 | - } |
|
| 1631 | - |
|
| 1632 | - if ($include) { |
|
| 1633 | - spip_log("include_spip $dirname$file non trouve"); |
|
| 1634 | - if ($include === 'required') { |
|
| 1635 | - echo '<pre>', |
|
| 1636 | - '<strong>Erreur Fatale</strong><br />'; |
|
| 1637 | - if (function_exists('debug_print_backtrace')) { |
|
| 1638 | - echo debug_print_backtrace(); |
|
| 1639 | - } |
|
| 1640 | - echo '</pre>'; |
|
| 1641 | - die("Erreur interne: ne peut inclure $dirname$file"); |
|
| 1642 | - } |
|
| 1643 | - } |
|
| 1644 | - |
|
| 1645 | - if (!defined('_SAUVER_CHEMIN')) { |
|
| 1646 | - // si le chemin n'a pas encore ete charge, ne pas lever le flag, ne pas cacher |
|
| 1647 | - if (is_null($GLOBALS['path_files'])) { |
|
| 1648 | - return false; |
|
| 1649 | - } |
|
| 1650 | - define('_SAUVER_CHEMIN', true); |
|
| 1651 | - } |
|
| 1652 | - |
|
| 1653 | - return $GLOBALS['path_files'][$GLOBALS['path_sig']][$dirname][$file] = $GLOBALS['path_files'][$GLOBALS['path_sig']][''][$dirname . $file] = false; |
|
| 1575 | + static $dirs = []; |
|
| 1576 | + static $inc = []; # cf https://git.spip.net/spip/spip/commit/42e4e028e38c839121efaee84308d08aee307eec |
|
| 1577 | + static $c = ''; |
|
| 1578 | + |
|
| 1579 | + if (!$file and !strlen($file)) { |
|
| 1580 | + return false; |
|
| 1581 | + } |
|
| 1582 | + |
|
| 1583 | + // on calcule le chemin si le dossier skel a change |
|
| 1584 | + if ($c != $GLOBALS['dossier_squelettes']) { |
|
| 1585 | + // assurer le non plantage lors de la montee de version : |
|
| 1586 | + $c = $GLOBALS['dossier_squelettes']; |
|
| 1587 | + creer_chemin(); // forcer un recalcul du chemin et la mise a jour de path_sig |
|
| 1588 | + } |
|
| 1589 | + |
|
| 1590 | + if (isset($GLOBALS['path_files'][$GLOBALS['path_sig']][$dirname][$file])) { |
|
| 1591 | + if (!$GLOBALS['path_files'][$GLOBALS['path_sig']][$dirname][$file]) { |
|
| 1592 | + return false; |
|
| 1593 | + } |
|
| 1594 | + if ($include and !isset($inc[$dirname][$file])) { |
|
| 1595 | + include_once _ROOT_CWD . $GLOBALS['path_files'][$GLOBALS['path_sig']][$dirname][$file]; |
|
| 1596 | + $inc[$dirname][$file] = $inc[''][$dirname . $file] = true; |
|
| 1597 | + } |
|
| 1598 | + |
|
| 1599 | + return $GLOBALS['path_files'][$GLOBALS['path_sig']][$dirname][$file]; |
|
| 1600 | + } |
|
| 1601 | + |
|
| 1602 | + $a = strrpos($file, '/'); |
|
| 1603 | + if ($a !== false) { |
|
| 1604 | + $dirname .= substr($file, 0, ++$a); |
|
| 1605 | + $file = substr($file, $a); |
|
| 1606 | + } |
|
| 1607 | + |
|
| 1608 | + foreach (creer_chemin() as $dir) { |
|
| 1609 | + if (!isset($dirs[$a = $dir . $dirname])) { |
|
| 1610 | + $dirs[$a] = (is_dir(_ROOT_CWD . $a) || !$a); |
|
| 1611 | + } |
|
| 1612 | + if ($dirs[$a]) { |
|
| 1613 | + if (file_exists(_ROOT_CWD . ($a .= $file))) { |
|
| 1614 | + if ($include and !isset($inc[$dirname][$file])) { |
|
| 1615 | + include_once _ROOT_CWD . $a; |
|
| 1616 | + $inc[$dirname][$file] = $inc[''][$dirname . $file] = true; |
|
| 1617 | + } |
|
| 1618 | + if (!defined('_SAUVER_CHEMIN')) { |
|
| 1619 | + // si le chemin n'a pas encore ete charge, ne pas lever le flag, ne pas cacher |
|
| 1620 | + if (is_null($GLOBALS['path_files'])) { |
|
| 1621 | + return $a; |
|
| 1622 | + } |
|
| 1623 | + define('_SAUVER_CHEMIN', true); |
|
| 1624 | + } |
|
| 1625 | + |
|
| 1626 | + return $GLOBALS['path_files'][$GLOBALS['path_sig']][$dirname][$file] = $GLOBALS['path_files'][$GLOBALS['path_sig']][''][$dirname . $file] = $a; |
|
| 1627 | + } |
|
| 1628 | + } |
|
| 1629 | + } |
|
| 1630 | + |
|
| 1631 | + if ($include) { |
|
| 1632 | + spip_log("include_spip $dirname$file non trouve"); |
|
| 1633 | + if ($include === 'required') { |
|
| 1634 | + echo '<pre>', |
|
| 1635 | + '<strong>Erreur Fatale</strong><br />'; |
|
| 1636 | + if (function_exists('debug_print_backtrace')) { |
|
| 1637 | + echo debug_print_backtrace(); |
|
| 1638 | + } |
|
| 1639 | + echo '</pre>'; |
|
| 1640 | + die("Erreur interne: ne peut inclure $dirname$file"); |
|
| 1641 | + } |
|
| 1642 | + } |
|
| 1643 | + |
|
| 1644 | + if (!defined('_SAUVER_CHEMIN')) { |
|
| 1645 | + // si le chemin n'a pas encore ete charge, ne pas lever le flag, ne pas cacher |
|
| 1646 | + if (is_null($GLOBALS['path_files'])) { |
|
| 1647 | + return false; |
|
| 1648 | + } |
|
| 1649 | + define('_SAUVER_CHEMIN', true); |
|
| 1650 | + } |
|
| 1651 | + |
|
| 1652 | + return $GLOBALS['path_files'][$GLOBALS['path_sig']][$dirname][$file] = $GLOBALS['path_files'][$GLOBALS['path_sig']][''][$dirname . $file] = false; |
|
| 1654 | 1653 | } |
| 1655 | 1654 | |
| 1656 | 1655 | function clear_path_cache() { |
| 1657 | - $GLOBALS['path_files'] = []; |
|
| 1658 | - spip_unlink(_CACHE_CHEMIN); |
|
| 1656 | + $GLOBALS['path_files'] = []; |
|
| 1657 | + spip_unlink(_CACHE_CHEMIN); |
|
| 1659 | 1658 | } |
| 1660 | 1659 | |
| 1661 | 1660 | function load_path_cache() { |
| 1662 | - // charger le path des plugins |
|
| 1663 | - if (@is_readable(_CACHE_PLUGINS_PATH)) { |
|
| 1664 | - include_once(_CACHE_PLUGINS_PATH); |
|
| 1665 | - } |
|
| 1666 | - $GLOBALS['path_files'] = []; |
|
| 1667 | - // si le visiteur est admin, |
|
| 1668 | - // on ne recharge pas le cache pour forcer sa mise a jour |
|
| 1669 | - if ( |
|
| 1670 | - // la session n'est pas encore chargee a ce moment, on ne peut donc pas s'y fier |
|
| 1671 | - //AND (!isset($GLOBALS['visiteur_session']['statut']) OR $GLOBALS['visiteur_session']['statut']!='0minirezo') |
|
| 1672 | - // utiliser le cookie est un pis aller qui marche 'en general' |
|
| 1673 | - // on blinde par un second test au moment de la lecture de la session |
|
| 1674 | - // !isset($_COOKIE[$GLOBALS['cookie_prefix'].'_admin']) |
|
| 1675 | - // et en ignorant ce cache en cas de recalcul explicite |
|
| 1676 | - !_request('var_mode') |
|
| 1677 | - ) { |
|
| 1678 | - // on essaye de lire directement sans verrou pour aller plus vite |
|
| 1679 | - if ($contenu = spip_file_get_contents(_CACHE_CHEMIN)) { |
|
| 1680 | - // mais si semble corrompu on relit avec un verrou |
|
| 1681 | - if (!$GLOBALS['path_files'] = unserialize($contenu)) { |
|
| 1682 | - lire_fichier(_CACHE_CHEMIN, $contenu); |
|
| 1683 | - if (!$GLOBALS['path_files'] = unserialize($contenu)) { |
|
| 1684 | - $GLOBALS['path_files'] = []; |
|
| 1685 | - } |
|
| 1686 | - } |
|
| 1687 | - } |
|
| 1688 | - } |
|
| 1661 | + // charger le path des plugins |
|
| 1662 | + if (@is_readable(_CACHE_PLUGINS_PATH)) { |
|
| 1663 | + include_once(_CACHE_PLUGINS_PATH); |
|
| 1664 | + } |
|
| 1665 | + $GLOBALS['path_files'] = []; |
|
| 1666 | + // si le visiteur est admin, |
|
| 1667 | + // on ne recharge pas le cache pour forcer sa mise a jour |
|
| 1668 | + if ( |
|
| 1669 | + // la session n'est pas encore chargee a ce moment, on ne peut donc pas s'y fier |
|
| 1670 | + //AND (!isset($GLOBALS['visiteur_session']['statut']) OR $GLOBALS['visiteur_session']['statut']!='0minirezo') |
|
| 1671 | + // utiliser le cookie est un pis aller qui marche 'en general' |
|
| 1672 | + // on blinde par un second test au moment de la lecture de la session |
|
| 1673 | + // !isset($_COOKIE[$GLOBALS['cookie_prefix'].'_admin']) |
|
| 1674 | + // et en ignorant ce cache en cas de recalcul explicite |
|
| 1675 | + !_request('var_mode') |
|
| 1676 | + ) { |
|
| 1677 | + // on essaye de lire directement sans verrou pour aller plus vite |
|
| 1678 | + if ($contenu = spip_file_get_contents(_CACHE_CHEMIN)) { |
|
| 1679 | + // mais si semble corrompu on relit avec un verrou |
|
| 1680 | + if (!$GLOBALS['path_files'] = unserialize($contenu)) { |
|
| 1681 | + lire_fichier(_CACHE_CHEMIN, $contenu); |
|
| 1682 | + if (!$GLOBALS['path_files'] = unserialize($contenu)) { |
|
| 1683 | + $GLOBALS['path_files'] = []; |
|
| 1684 | + } |
|
| 1685 | + } |
|
| 1686 | + } |
|
| 1687 | + } |
|
| 1689 | 1688 | } |
| 1690 | 1689 | |
| 1691 | 1690 | function save_path_cache() { |
| 1692 | - if ( |
|
| 1693 | - defined('_SAUVER_CHEMIN') |
|
| 1694 | - and _SAUVER_CHEMIN |
|
| 1695 | - ) { |
|
| 1696 | - ecrire_fichier(_CACHE_CHEMIN, serialize($GLOBALS['path_files'])); |
|
| 1697 | - } |
|
| 1691 | + if ( |
|
| 1692 | + defined('_SAUVER_CHEMIN') |
|
| 1693 | + and _SAUVER_CHEMIN |
|
| 1694 | + ) { |
|
| 1695 | + ecrire_fichier(_CACHE_CHEMIN, serialize($GLOBALS['path_files'])); |
|
| 1696 | + } |
|
| 1698 | 1697 | } |
| 1699 | 1698 | |
| 1700 | 1699 | |
@@ -1714,33 +1713,33 @@ discard block |
||
| 1714 | 1713 | * @return array |
| 1715 | 1714 | */ |
| 1716 | 1715 | function find_all_in_path($dir, $pattern, $recurs = false) { |
| 1717 | - $liste_fichiers = []; |
|
| 1718 | - $maxfiles = 10000; |
|
| 1719 | - |
|
| 1720 | - // cas borderline si dans mes_options on appelle redirige_par_entete qui utilise _T et charge un fichier de langue |
|
| 1721 | - // on a pas encore inclus flock.php |
|
| 1722 | - if (!function_exists('preg_files')) { |
|
| 1723 | - include_once _ROOT_RESTREINT . 'inc/flock.php'; |
|
| 1724 | - } |
|
| 1725 | - |
|
| 1726 | - // Parcourir le chemin |
|
| 1727 | - foreach (creer_chemin() as $d) { |
|
| 1728 | - $f = $d . $dir; |
|
| 1729 | - if (@is_dir($f)) { |
|
| 1730 | - $liste = preg_files($f, $pattern, $maxfiles - count($liste_fichiers), $recurs === true ? [] : $recurs); |
|
| 1731 | - foreach ($liste as $chemin) { |
|
| 1732 | - $nom = basename($chemin); |
|
| 1733 | - // ne prendre que les fichiers pas deja trouves |
|
| 1734 | - // car find_in_path prend le premier qu'il trouve, |
|
| 1735 | - // les autres sont donc masques |
|
| 1736 | - if (!isset($liste_fichiers[$nom])) { |
|
| 1737 | - $liste_fichiers[$nom] = $chemin; |
|
| 1738 | - } |
|
| 1739 | - } |
|
| 1740 | - } |
|
| 1741 | - } |
|
| 1742 | - |
|
| 1743 | - return $liste_fichiers; |
|
| 1716 | + $liste_fichiers = []; |
|
| 1717 | + $maxfiles = 10000; |
|
| 1718 | + |
|
| 1719 | + // cas borderline si dans mes_options on appelle redirige_par_entete qui utilise _T et charge un fichier de langue |
|
| 1720 | + // on a pas encore inclus flock.php |
|
| 1721 | + if (!function_exists('preg_files')) { |
|
| 1722 | + include_once _ROOT_RESTREINT . 'inc/flock.php'; |
|
| 1723 | + } |
|
| 1724 | + |
|
| 1725 | + // Parcourir le chemin |
|
| 1726 | + foreach (creer_chemin() as $d) { |
|
| 1727 | + $f = $d . $dir; |
|
| 1728 | + if (@is_dir($f)) { |
|
| 1729 | + $liste = preg_files($f, $pattern, $maxfiles - count($liste_fichiers), $recurs === true ? [] : $recurs); |
|
| 1730 | + foreach ($liste as $chemin) { |
|
| 1731 | + $nom = basename($chemin); |
|
| 1732 | + // ne prendre que les fichiers pas deja trouves |
|
| 1733 | + // car find_in_path prend le premier qu'il trouve, |
|
| 1734 | + // les autres sont donc masques |
|
| 1735 | + if (!isset($liste_fichiers[$nom])) { |
|
| 1736 | + $liste_fichiers[$nom] = $chemin; |
|
| 1737 | + } |
|
| 1738 | + } |
|
| 1739 | + } |
|
| 1740 | + } |
|
| 1741 | + |
|
| 1742 | + return $liste_fichiers; |
|
| 1744 | 1743 | } |
| 1745 | 1744 | |
| 1746 | 1745 | /** |
@@ -1752,17 +1751,17 @@ discard block |
||
| 1752 | 1751 | * @return bool |
| 1753 | 1752 | */ |
| 1754 | 1753 | function autoriser_sans_cookie($nom, $strict = false) { |
| 1755 | - static $autsanscookie = ['install', 'base_repair']; |
|
| 1754 | + static $autsanscookie = ['install', 'base_repair']; |
|
| 1756 | 1755 | |
| 1757 | - if (in_array($nom, $autsanscookie)) { |
|
| 1758 | - if (test_espace_prive()) { |
|
| 1759 | - include_spip('base/connect_sql'); |
|
| 1760 | - if (!$strict or !spip_connect()) { |
|
| 1761 | - return true; |
|
| 1762 | - } |
|
| 1763 | - } |
|
| 1764 | - } |
|
| 1765 | - return false; |
|
| 1756 | + if (in_array($nom, $autsanscookie)) { |
|
| 1757 | + if (test_espace_prive()) { |
|
| 1758 | + include_spip('base/connect_sql'); |
|
| 1759 | + if (!$strict or !spip_connect()) { |
|
| 1760 | + return true; |
|
| 1761 | + } |
|
| 1762 | + } |
|
| 1763 | + } |
|
| 1764 | + return false; |
|
| 1766 | 1765 | } |
| 1767 | 1766 | |
| 1768 | 1767 | /** |
@@ -1772,56 +1771,56 @@ discard block |
||
| 1772 | 1771 | * @return string |
| 1773 | 1772 | */ |
| 1774 | 1773 | function charger_fonction_url(string $quoi, string $type = '') { |
| 1775 | - if ($type === 'defaut') { |
|
| 1776 | - $objet = objet_type($quoi); |
|
| 1777 | - if ($f = charger_fonction('generer_' . $objet . '_url', 'urls', true) |
|
| 1778 | - // deprecated |
|
| 1779 | - or $f = charger_fonction('generer_url_' . $objet, 'urls', true) |
|
| 1780 | - ) { |
|
| 1781 | - return $f; |
|
| 1782 | - } |
|
| 1783 | - return ''; |
|
| 1784 | - } |
|
| 1785 | - |
|
| 1786 | - if (!$type) { |
|
| 1787 | - $type = $GLOBALS['type_urls'] ?? $GLOBALS['meta']['type_urls'] ?? 'page'; // sinon type "page" par défaut |
|
| 1788 | - } |
|
| 1789 | - |
|
| 1790 | - // inclure le module d'url |
|
| 1791 | - include_spip('urls/'.$type); |
|
| 1792 | - |
|
| 1793 | - switch ($quoi) { |
|
| 1794 | - case 'page': |
|
| 1795 | - if ( |
|
| 1796 | - function_exists($f = "urls_{$type}_generer_url_page") |
|
| 1797 | - or function_exists($f .= "_dist") |
|
| 1798 | - // ou une fonction custom utilisateur independante du type d'url |
|
| 1799 | - or function_exists($f = "generer_url_page") |
|
| 1800 | - or function_exists($f .= "_dist") |
|
| 1801 | - ) { |
|
| 1802 | - return $f; |
|
| 1803 | - } |
|
| 1804 | - // pas de compat ancienne version ici, c'est une nouvelle feature |
|
| 1805 | - return ''; |
|
| 1806 | - case 'objet': |
|
| 1807 | - case 'decoder': |
|
| 1808 | - default: |
|
| 1809 | - $fquoi = ($quoi === 'objet' ? 'generer_url_objet' : 'decoder_url'); |
|
| 1810 | - if (function_exists($f = "urls_{$type}_{$fquoi}") |
|
| 1811 | - or function_exists($f .= "_dist")) { |
|
| 1812 | - return $f; |
|
| 1813 | - } |
|
| 1814 | - // est-ce qu'on a une ancienne fonction urls_xxx_dist() ? |
|
| 1815 | - // c'est un ancien module d'url, on appelle l'ancienne fonction qui fait tout |
|
| 1816 | - if ($f = charger_fonction($type, 'urls', true)) { |
|
| 1817 | - return $f; |
|
| 1818 | - } |
|
| 1819 | - // sinon on se rabat sur les urls page |
|
| 1820 | - if ($type !== 'page') { |
|
| 1821 | - return charger_fonction_url($quoi, 'page'); |
|
| 1822 | - } |
|
| 1823 | - return ''; |
|
| 1824 | - } |
|
| 1774 | + if ($type === 'defaut') { |
|
| 1775 | + $objet = objet_type($quoi); |
|
| 1776 | + if ($f = charger_fonction('generer_' . $objet . '_url', 'urls', true) |
|
| 1777 | + // deprecated |
|
| 1778 | + or $f = charger_fonction('generer_url_' . $objet, 'urls', true) |
|
| 1779 | + ) { |
|
| 1780 | + return $f; |
|
| 1781 | + } |
|
| 1782 | + return ''; |
|
| 1783 | + } |
|
| 1784 | + |
|
| 1785 | + if (!$type) { |
|
| 1786 | + $type = $GLOBALS['type_urls'] ?? $GLOBALS['meta']['type_urls'] ?? 'page'; // sinon type "page" par défaut |
|
| 1787 | + } |
|
| 1788 | + |
|
| 1789 | + // inclure le module d'url |
|
| 1790 | + include_spip('urls/'.$type); |
|
| 1791 | + |
|
| 1792 | + switch ($quoi) { |
|
| 1793 | + case 'page': |
|
| 1794 | + if ( |
|
| 1795 | + function_exists($f = "urls_{$type}_generer_url_page") |
|
| 1796 | + or function_exists($f .= "_dist") |
|
| 1797 | + // ou une fonction custom utilisateur independante du type d'url |
|
| 1798 | + or function_exists($f = "generer_url_page") |
|
| 1799 | + or function_exists($f .= "_dist") |
|
| 1800 | + ) { |
|
| 1801 | + return $f; |
|
| 1802 | + } |
|
| 1803 | + // pas de compat ancienne version ici, c'est une nouvelle feature |
|
| 1804 | + return ''; |
|
| 1805 | + case 'objet': |
|
| 1806 | + case 'decoder': |
|
| 1807 | + default: |
|
| 1808 | + $fquoi = ($quoi === 'objet' ? 'generer_url_objet' : 'decoder_url'); |
|
| 1809 | + if (function_exists($f = "urls_{$type}_{$fquoi}") |
|
| 1810 | + or function_exists($f .= "_dist")) { |
|
| 1811 | + return $f; |
|
| 1812 | + } |
|
| 1813 | + // est-ce qu'on a une ancienne fonction urls_xxx_dist() ? |
|
| 1814 | + // c'est un ancien module d'url, on appelle l'ancienne fonction qui fait tout |
|
| 1815 | + if ($f = charger_fonction($type, 'urls', true)) { |
|
| 1816 | + return $f; |
|
| 1817 | + } |
|
| 1818 | + // sinon on se rabat sur les urls page |
|
| 1819 | + if ($type !== 'page') { |
|
| 1820 | + return charger_fonction_url($quoi, 'page'); |
|
| 1821 | + } |
|
| 1822 | + return ''; |
|
| 1823 | + } |
|
| 1825 | 1824 | } |
| 1826 | 1825 | |
| 1827 | 1826 | |
@@ -1850,47 +1849,47 @@ discard block |
||
| 1850 | 1849 | * (cas des raccourcis personalises [->spip20] : il faut implementer une fonction generer_spip_url et une fonction generer_spip_url_ecrire) |
| 1851 | 1850 | */ |
| 1852 | 1851 | function generer_objet_url($id, string $entite, string $args = '', string $ancre = '', ?bool $public = null, string $type = '', string $connect = ''): string { |
| 1853 | - if ($public === null) { |
|
| 1854 | - $public = !test_espace_prive(); |
|
| 1855 | - } |
|
| 1856 | - $id = intval($id); |
|
| 1857 | - $entite = objet_type($entite); // cas particulier d'appels sur objet/id_objet... |
|
| 1858 | - |
|
| 1859 | - if (!$public) { |
|
| 1860 | - if (!$entite) { |
|
| 1861 | - return ''; |
|
| 1862 | - } |
|
| 1863 | - if (!function_exists('generer_objet_url_ecrire')) { |
|
| 1864 | - include_spip('inc/urls'); |
|
| 1865 | - } |
|
| 1866 | - $res = generer_objet_url_ecrire($id, $entite, $args, $ancre, false, $connect); |
|
| 1867 | - } else { |
|
| 1868 | - $f = charger_fonction_url('objet', $type ?? ''); |
|
| 1869 | - |
|
| 1870 | - // @deprecated si $entite='', on veut la fonction de passage URL ==> id |
|
| 1871 | - // @see charger_fonction_url |
|
| 1872 | - if (!$entite) { |
|
| 1873 | - return $f; |
|
| 1874 | - } |
|
| 1875 | - |
|
| 1876 | - // mais d'abord il faut tester le cas des urls sur une |
|
| 1877 | - // base distante |
|
| 1878 | - if ($connect |
|
| 1879 | - and $g = charger_fonction('connect', 'urls', true) |
|
| 1880 | - ) { |
|
| 1881 | - $f = $g; |
|
| 1882 | - } |
|
| 1883 | - |
|
| 1884 | - $res = $f(intval($id), $entite, $args ?: '', $ancre ?: '', $connect); |
|
| 1885 | - } |
|
| 1886 | - if ($res) { |
|
| 1887 | - return $res; |
|
| 1888 | - } |
|
| 1889 | - |
|
| 1890 | - // On a ete gentil mais la .... |
|
| 1891 | - spip_log("generer_objet_url: entite $entite ($f) inconnue $type $public $connect", _LOG_ERREUR); |
|
| 1892 | - |
|
| 1893 | - return ''; |
|
| 1852 | + if ($public === null) { |
|
| 1853 | + $public = !test_espace_prive(); |
|
| 1854 | + } |
|
| 1855 | + $id = intval($id); |
|
| 1856 | + $entite = objet_type($entite); // cas particulier d'appels sur objet/id_objet... |
|
| 1857 | + |
|
| 1858 | + if (!$public) { |
|
| 1859 | + if (!$entite) { |
|
| 1860 | + return ''; |
|
| 1861 | + } |
|
| 1862 | + if (!function_exists('generer_objet_url_ecrire')) { |
|
| 1863 | + include_spip('inc/urls'); |
|
| 1864 | + } |
|
| 1865 | + $res = generer_objet_url_ecrire($id, $entite, $args, $ancre, false, $connect); |
|
| 1866 | + } else { |
|
| 1867 | + $f = charger_fonction_url('objet', $type ?? ''); |
|
| 1868 | + |
|
| 1869 | + // @deprecated si $entite='', on veut la fonction de passage URL ==> id |
|
| 1870 | + // @see charger_fonction_url |
|
| 1871 | + if (!$entite) { |
|
| 1872 | + return $f; |
|
| 1873 | + } |
|
| 1874 | + |
|
| 1875 | + // mais d'abord il faut tester le cas des urls sur une |
|
| 1876 | + // base distante |
|
| 1877 | + if ($connect |
|
| 1878 | + and $g = charger_fonction('connect', 'urls', true) |
|
| 1879 | + ) { |
|
| 1880 | + $f = $g; |
|
| 1881 | + } |
|
| 1882 | + |
|
| 1883 | + $res = $f(intval($id), $entite, $args ?: '', $ancre ?: '', $connect); |
|
| 1884 | + } |
|
| 1885 | + if ($res) { |
|
| 1886 | + return $res; |
|
| 1887 | + } |
|
| 1888 | + |
|
| 1889 | + // On a ete gentil mais la .... |
|
| 1890 | + spip_log("generer_objet_url: entite $entite ($f) inconnue $type $public $connect", _LOG_ERREUR); |
|
| 1891 | + |
|
| 1892 | + return ''; |
|
| 1894 | 1893 | } |
| 1895 | 1894 | |
| 1896 | 1895 | /** |
@@ -1898,10 +1897,10 @@ discard block |
||
| 1898 | 1897 | * @see generer_objet_url |
| 1899 | 1898 | */ |
| 1900 | 1899 | function generer_url_entite($id = 0, $entite = '', $args = '', $ancre = '', $public = null, $type = null){ |
| 1901 | - if ($public and is_string($public)) { |
|
| 1902 | - return generer_objet_url(intval($id), $entite, $args ?: '', $ancre ?: '', true, $type ?? '', $public); |
|
| 1903 | - } |
|
| 1904 | - return generer_objet_url(intval($id), $entite, $args ?: '', $ancre ?: '', $public, $type ?? ''); |
|
| 1900 | + if ($public and is_string($public)) { |
|
| 1901 | + return generer_objet_url(intval($id), $entite, $args ?: '', $ancre ?: '', true, $type ?? '', $public); |
|
| 1902 | + } |
|
| 1903 | + return generer_objet_url(intval($id), $entite, $args ?: '', $ancre ?: '', $public, $type ?? ''); |
|
| 1905 | 1904 | } |
| 1906 | 1905 | |
| 1907 | 1906 | /** |
@@ -1913,19 +1912,19 @@ discard block |
||
| 1913 | 1912 | * @return string |
| 1914 | 1913 | */ |
| 1915 | 1914 | function generer_objet_url_ecrire_edit($id, string $entite, string $args = '', string $ancre = ''): string { |
| 1916 | - $id = intval($id); |
|
| 1917 | - $exec = objet_info($entite, 'url_edit'); |
|
| 1918 | - $url = generer_url_ecrire($exec, $args); |
|
| 1919 | - if (intval($id)) { |
|
| 1920 | - $url = parametre_url($url, id_table_objet($entite), $id); |
|
| 1921 | - } else { |
|
| 1922 | - $url = parametre_url($url, 'new', 'oui'); |
|
| 1923 | - } |
|
| 1924 | - if ($ancre) { |
|
| 1925 | - $url = ancre_url($url, $ancre); |
|
| 1926 | - } |
|
| 1915 | + $id = intval($id); |
|
| 1916 | + $exec = objet_info($entite, 'url_edit'); |
|
| 1917 | + $url = generer_url_ecrire($exec, $args); |
|
| 1918 | + if (intval($id)) { |
|
| 1919 | + $url = parametre_url($url, id_table_objet($entite), $id); |
|
| 1920 | + } else { |
|
| 1921 | + $url = parametre_url($url, 'new', 'oui'); |
|
| 1922 | + } |
|
| 1923 | + if ($ancre) { |
|
| 1924 | + $url = ancre_url($url, $ancre); |
|
| 1925 | + } |
|
| 1927 | 1926 | |
| 1928 | - return $url; |
|
| 1927 | + return $url; |
|
| 1929 | 1928 | } |
| 1930 | 1929 | |
| 1931 | 1930 | /** |
@@ -1933,18 +1932,18 @@ discard block |
||
| 1933 | 1932 | * @see generer_objet_url_ecrire_edit |
| 1934 | 1933 | */ |
| 1935 | 1934 | function generer_url_ecrire_entite_edit($id, $entite, $args = '', $ancre = ''){ |
| 1936 | - return generer_objet_url_ecrire_edit(intval($id), $entite, $args, $ancre); |
|
| 1935 | + return generer_objet_url_ecrire_edit(intval($id), $entite, $args, $ancre); |
|
| 1937 | 1936 | } |
| 1938 | 1937 | |
| 1939 | 1938 | |
| 1940 | 1939 | function urls_connect_dist($i, &$entite, $args = '', $ancre = '', $public = null) { |
| 1941 | - include_spip('base/connect_sql'); |
|
| 1942 | - $id_type = id_table_objet($entite, $public); |
|
| 1940 | + include_spip('base/connect_sql'); |
|
| 1941 | + $id_type = id_table_objet($entite, $public); |
|
| 1943 | 1942 | |
| 1944 | - return _DIR_RACINE . get_spip_script('./') |
|
| 1945 | - . '?' . _SPIP_PAGE . "=$entite&$id_type=$i&connect=$public" |
|
| 1946 | - . (!$args ? '' : "&$args") |
|
| 1947 | - . (!$ancre ? '' : "#$ancre"); |
|
| 1943 | + return _DIR_RACINE . get_spip_script('./') |
|
| 1944 | + . '?' . _SPIP_PAGE . "=$entite&$id_type=$i&connect=$public" |
|
| 1945 | + . (!$args ? '' : "&$args") |
|
| 1946 | + . (!$ancre ? '' : "#$ancre"); |
|
| 1948 | 1947 | } |
| 1949 | 1948 | |
| 1950 | 1949 | |
@@ -1955,18 +1954,18 @@ discard block |
||
| 1955 | 1954 | * @return string |
| 1956 | 1955 | */ |
| 1957 | 1956 | function urlencode_1738($url) { |
| 1958 | - if (preg_match(',[^\x00-\x7E],sS', $url)) { |
|
| 1959 | - $uri = ''; |
|
| 1960 | - for ($i = 0; $i < strlen($url); $i++) { |
|
| 1961 | - if (ord($a = $url[$i]) > 127) { |
|
| 1962 | - $a = rawurlencode($a); |
|
| 1963 | - } |
|
| 1964 | - $uri .= $a; |
|
| 1965 | - } |
|
| 1966 | - $url = $uri; |
|
| 1967 | - } |
|
| 1957 | + if (preg_match(',[^\x00-\x7E],sS', $url)) { |
|
| 1958 | + $uri = ''; |
|
| 1959 | + for ($i = 0; $i < strlen($url); $i++) { |
|
| 1960 | + if (ord($a = $url[$i]) > 127) { |
|
| 1961 | + $a = rawurlencode($a); |
|
| 1962 | + } |
|
| 1963 | + $uri .= $a; |
|
| 1964 | + } |
|
| 1965 | + $url = $uri; |
|
| 1966 | + } |
|
| 1968 | 1967 | |
| 1969 | - return quote_amp($url); |
|
| 1968 | + return quote_amp($url); |
|
| 1970 | 1969 | } |
| 1971 | 1970 | |
| 1972 | 1971 | /** |
@@ -1982,14 +1981,14 @@ discard block |
||
| 1982 | 1981 | * @return string |
| 1983 | 1982 | */ |
| 1984 | 1983 | function generer_objet_url_absolue($id = 0, string $entite = '', string $args = '', string $ancre = '', ?bool $public = null, string $type = '', string $connect = ''): string { |
| 1985 | - $id = intval($id); |
|
| 1986 | - $h = generer_objet_url($id, $entite, $args, $ancre, $public, $type, $connect); |
|
| 1987 | - if (!preg_match(',^\w+:,', $h)) { |
|
| 1988 | - include_spip('inc/filtres_mini'); |
|
| 1989 | - $h = url_absolue($h); |
|
| 1990 | - } |
|
| 1984 | + $id = intval($id); |
|
| 1985 | + $h = generer_objet_url($id, $entite, $args, $ancre, $public, $type, $connect); |
|
| 1986 | + if (!preg_match(',^\w+:,', $h)) { |
|
| 1987 | + include_spip('inc/filtres_mini'); |
|
| 1988 | + $h = url_absolue($h); |
|
| 1989 | + } |
|
| 1991 | 1990 | |
| 1992 | - return $h; |
|
| 1991 | + return $h; |
|
| 1993 | 1992 | } |
| 1994 | 1993 | |
| 1995 | 1994 | /** |
@@ -1997,7 +1996,7 @@ discard block |
||
| 1997 | 1996 | * @see generer_objet_url_absolue |
| 1998 | 1997 | */ |
| 1999 | 1998 | function generer_url_entite_absolue($id = 0, $entite = '', $args = '', $ancre = '', $connect = null){ |
| 2000 | - return generer_objet_url_absolue(intval($id), $entite, $args, $ancre, true, '', $connect); |
|
| 1999 | + return generer_objet_url_absolue(intval($id), $entite, $args, $ancre, true, '', $connect); |
|
| 2001 | 2000 | } |
| 2002 | 2001 | |
| 2003 | 2002 | |
@@ -2013,11 +2012,11 @@ discard block |
||
| 2013 | 2012 | * true si la valeur est considérée active ; false sinon. |
| 2014 | 2013 | **/ |
| 2015 | 2014 | function test_valeur_serveur($truc) { |
| 2016 | - if (!$truc) { |
|
| 2017 | - return false; |
|
| 2018 | - } |
|
| 2015 | + if (!$truc) { |
|
| 2016 | + return false; |
|
| 2017 | + } |
|
| 2019 | 2018 | |
| 2020 | - return (strtolower($truc) !== 'off'); |
|
| 2019 | + return (strtolower($truc) !== 'off'); |
|
| 2021 | 2020 | } |
| 2022 | 2021 | |
| 2023 | 2022 | // |
@@ -2045,82 +2044,82 @@ discard block |
||
| 2045 | 2044 | */ |
| 2046 | 2045 | function url_de_base($profondeur = null) { |
| 2047 | 2046 | |
| 2048 | - static $url = []; |
|
| 2049 | - if (is_array($profondeur)) { |
|
| 2050 | - return $url = $profondeur; |
|
| 2051 | - } |
|
| 2052 | - if ($profondeur === false) { |
|
| 2053 | - return $url; |
|
| 2054 | - } |
|
| 2055 | - |
|
| 2056 | - if (is_null($profondeur)) { |
|
| 2057 | - $profondeur = $GLOBALS['profondeur_url'] ?? (_DIR_RESTREINT ? 0 : 1); |
|
| 2058 | - } |
|
| 2059 | - |
|
| 2060 | - if (isset($url[$profondeur])) { |
|
| 2061 | - return $url[$profondeur]; |
|
| 2062 | - } |
|
| 2063 | - |
|
| 2064 | - $http = 'http'; |
|
| 2065 | - |
|
| 2066 | - if ( |
|
| 2067 | - isset($_SERVER['SCRIPT_URI']) |
|
| 2068 | - and substr($_SERVER['SCRIPT_URI'], 0, 5) == 'https' |
|
| 2069 | - ) { |
|
| 2070 | - $http = 'https'; |
|
| 2071 | - } elseif ( |
|
| 2072 | - isset($_SERVER['HTTPS']) |
|
| 2073 | - and test_valeur_serveur($_SERVER['HTTPS']) |
|
| 2074 | - ) { |
|
| 2075 | - $http = 'https'; |
|
| 2076 | - } |
|
| 2077 | - |
|
| 2078 | - // note : HTTP_HOST contient le :port si necessaire |
|
| 2079 | - $host = $_SERVER['HTTP_HOST'] ?? null; |
|
| 2080 | - // si on n'a pas trouvé d'hôte du tout, en dernier recours on utilise adresse_site comme fallback |
|
| 2081 | - if (is_null($host) and isset($GLOBALS['meta']['adresse_site'])) { |
|
| 2082 | - $host = $GLOBALS['meta']['adresse_site']; |
|
| 2083 | - if ($scheme = parse_url($host, PHP_URL_SCHEME)) { |
|
| 2084 | - $http = $scheme; |
|
| 2085 | - $host = str_replace("{$scheme}://", '', $host); |
|
| 2086 | - } |
|
| 2087 | - } |
|
| 2088 | - if ( |
|
| 2089 | - isset($_SERVER['SERVER_PORT']) |
|
| 2090 | - and $port = $_SERVER['SERVER_PORT'] |
|
| 2091 | - and strpos($host, ':') == false |
|
| 2092 | - ) { |
|
| 2093 | - if (!defined('_PORT_HTTP_STANDARD')) { |
|
| 2094 | - define('_PORT_HTTP_STANDARD', '80'); |
|
| 2095 | - } |
|
| 2096 | - if (!defined('_PORT_HTTPS_STANDARD')) { |
|
| 2097 | - define('_PORT_HTTPS_STANDARD', '443'); |
|
| 2098 | - } |
|
| 2099 | - if ($http == 'http' and !in_array($port, explode(',', _PORT_HTTP_STANDARD))) { |
|
| 2100 | - $host .= ":$port"; |
|
| 2101 | - } |
|
| 2102 | - if ($http == 'https' and !in_array($port, explode(',', _PORT_HTTPS_STANDARD))) { |
|
| 2103 | - $host .= ":$port"; |
|
| 2104 | - } |
|
| 2105 | - } |
|
| 2106 | - |
|
| 2107 | - if (!$GLOBALS['REQUEST_URI']) { |
|
| 2108 | - if (isset($_SERVER['REQUEST_URI'])) { |
|
| 2109 | - $GLOBALS['REQUEST_URI'] = $_SERVER['REQUEST_URI']; |
|
| 2110 | - } else { |
|
| 2111 | - $GLOBALS['REQUEST_URI'] = (php_sapi_name() !== 'cli') ? $_SERVER['PHP_SELF'] : ''; |
|
| 2112 | - if ( |
|
| 2113 | - !empty($_SERVER['QUERY_STRING']) |
|
| 2114 | - and !strpos($_SERVER['REQUEST_URI'], '?') |
|
| 2115 | - ) { |
|
| 2116 | - $GLOBALS['REQUEST_URI'] .= '?' . $_SERVER['QUERY_STRING']; |
|
| 2117 | - } |
|
| 2118 | - } |
|
| 2119 | - } |
|
| 2120 | - |
|
| 2121 | - $url[$profondeur] = url_de_($http, $host, $GLOBALS['REQUEST_URI'], $profondeur); |
|
| 2122 | - |
|
| 2123 | - return $url[$profondeur]; |
|
| 2047 | + static $url = []; |
|
| 2048 | + if (is_array($profondeur)) { |
|
| 2049 | + return $url = $profondeur; |
|
| 2050 | + } |
|
| 2051 | + if ($profondeur === false) { |
|
| 2052 | + return $url; |
|
| 2053 | + } |
|
| 2054 | + |
|
| 2055 | + if (is_null($profondeur)) { |
|
| 2056 | + $profondeur = $GLOBALS['profondeur_url'] ?? (_DIR_RESTREINT ? 0 : 1); |
|
| 2057 | + } |
|
| 2058 | + |
|
| 2059 | + if (isset($url[$profondeur])) { |
|
| 2060 | + return $url[$profondeur]; |
|
| 2061 | + } |
|
| 2062 | + |
|
| 2063 | + $http = 'http'; |
|
| 2064 | + |
|
| 2065 | + if ( |
|
| 2066 | + isset($_SERVER['SCRIPT_URI']) |
|
| 2067 | + and substr($_SERVER['SCRIPT_URI'], 0, 5) == 'https' |
|
| 2068 | + ) { |
|
| 2069 | + $http = 'https'; |
|
| 2070 | + } elseif ( |
|
| 2071 | + isset($_SERVER['HTTPS']) |
|
| 2072 | + and test_valeur_serveur($_SERVER['HTTPS']) |
|
| 2073 | + ) { |
|
| 2074 | + $http = 'https'; |
|
| 2075 | + } |
|
| 2076 | + |
|
| 2077 | + // note : HTTP_HOST contient le :port si necessaire |
|
| 2078 | + $host = $_SERVER['HTTP_HOST'] ?? null; |
|
| 2079 | + // si on n'a pas trouvé d'hôte du tout, en dernier recours on utilise adresse_site comme fallback |
|
| 2080 | + if (is_null($host) and isset($GLOBALS['meta']['adresse_site'])) { |
|
| 2081 | + $host = $GLOBALS['meta']['adresse_site']; |
|
| 2082 | + if ($scheme = parse_url($host, PHP_URL_SCHEME)) { |
|
| 2083 | + $http = $scheme; |
|
| 2084 | + $host = str_replace("{$scheme}://", '', $host); |
|
| 2085 | + } |
|
| 2086 | + } |
|
| 2087 | + if ( |
|
| 2088 | + isset($_SERVER['SERVER_PORT']) |
|
| 2089 | + and $port = $_SERVER['SERVER_PORT'] |
|
| 2090 | + and strpos($host, ':') == false |
|
| 2091 | + ) { |
|
| 2092 | + if (!defined('_PORT_HTTP_STANDARD')) { |
|
| 2093 | + define('_PORT_HTTP_STANDARD', '80'); |
|
| 2094 | + } |
|
| 2095 | + if (!defined('_PORT_HTTPS_STANDARD')) { |
|
| 2096 | + define('_PORT_HTTPS_STANDARD', '443'); |
|
| 2097 | + } |
|
| 2098 | + if ($http == 'http' and !in_array($port, explode(',', _PORT_HTTP_STANDARD))) { |
|
| 2099 | + $host .= ":$port"; |
|
| 2100 | + } |
|
| 2101 | + if ($http == 'https' and !in_array($port, explode(',', _PORT_HTTPS_STANDARD))) { |
|
| 2102 | + $host .= ":$port"; |
|
| 2103 | + } |
|
| 2104 | + } |
|
| 2105 | + |
|
| 2106 | + if (!$GLOBALS['REQUEST_URI']) { |
|
| 2107 | + if (isset($_SERVER['REQUEST_URI'])) { |
|
| 2108 | + $GLOBALS['REQUEST_URI'] = $_SERVER['REQUEST_URI']; |
|
| 2109 | + } else { |
|
| 2110 | + $GLOBALS['REQUEST_URI'] = (php_sapi_name() !== 'cli') ? $_SERVER['PHP_SELF'] : ''; |
|
| 2111 | + if ( |
|
| 2112 | + !empty($_SERVER['QUERY_STRING']) |
|
| 2113 | + and !strpos($_SERVER['REQUEST_URI'], '?') |
|
| 2114 | + ) { |
|
| 2115 | + $GLOBALS['REQUEST_URI'] .= '?' . $_SERVER['QUERY_STRING']; |
|
| 2116 | + } |
|
| 2117 | + } |
|
| 2118 | + } |
|
| 2119 | + |
|
| 2120 | + $url[$profondeur] = url_de_($http, $host, $GLOBALS['REQUEST_URI'], $profondeur); |
|
| 2121 | + |
|
| 2122 | + return $url[$profondeur]; |
|
| 2124 | 2123 | } |
| 2125 | 2124 | |
| 2126 | 2125 | /** |
@@ -2133,26 +2132,26 @@ discard block |
||
| 2133 | 2132 | * @return string |
| 2134 | 2133 | */ |
| 2135 | 2134 | function url_de_($http, $host, $request, $prof = 0) { |
| 2136 | - $prof = max($prof, 0); |
|
| 2135 | + $prof = max($prof, 0); |
|
| 2137 | 2136 | |
| 2138 | - $myself = ltrim($request, '/'); |
|
| 2139 | - # supprimer la chaine de GET |
|
| 2140 | - [$myself] = explode('?', $myself); |
|
| 2141 | - // vieux mode HTTP qui envoie après le nom de la methode l'URL compléte |
|
| 2142 | - // protocole, "://", nom du serveur avant le path dans _SERVER["REQUEST_URI"] |
|
| 2143 | - if (strpos($myself, '://') !== false) { |
|
| 2144 | - $myself = explode('://', $myself); |
|
| 2145 | - array_shift($myself); |
|
| 2146 | - $myself = implode('://', $myself); |
|
| 2147 | - $myself = explode('/', $myself); |
|
| 2148 | - array_shift($myself); |
|
| 2149 | - $myself = implode('/', $myself); |
|
| 2150 | - } |
|
| 2151 | - $url = join('/', array_slice(explode('/', $myself), 0, -1 - $prof)) . '/'; |
|
| 2137 | + $myself = ltrim($request, '/'); |
|
| 2138 | + # supprimer la chaine de GET |
|
| 2139 | + [$myself] = explode('?', $myself); |
|
| 2140 | + // vieux mode HTTP qui envoie après le nom de la methode l'URL compléte |
|
| 2141 | + // protocole, "://", nom du serveur avant le path dans _SERVER["REQUEST_URI"] |
|
| 2142 | + if (strpos($myself, '://') !== false) { |
|
| 2143 | + $myself = explode('://', $myself); |
|
| 2144 | + array_shift($myself); |
|
| 2145 | + $myself = implode('://', $myself); |
|
| 2146 | + $myself = explode('/', $myself); |
|
| 2147 | + array_shift($myself); |
|
| 2148 | + $myself = implode('/', $myself); |
|
| 2149 | + } |
|
| 2150 | + $url = join('/', array_slice(explode('/', $myself), 0, -1 - $prof)) . '/'; |
|
| 2152 | 2151 | |
| 2153 | - $url = $http . '://' . rtrim($host, '/') . '/' . ltrim($url, '/'); |
|
| 2152 | + $url = $http . '://' . rtrim($host, '/') . '/' . ltrim($url, '/'); |
|
| 2154 | 2153 | |
| 2155 | - return $url; |
|
| 2154 | + return $url; |
|
| 2156 | 2155 | } |
| 2157 | 2156 | |
| 2158 | 2157 | |
@@ -2187,25 +2186,25 @@ discard block |
||
| 2187 | 2186 | * @return string URL |
| 2188 | 2187 | **/ |
| 2189 | 2188 | function generer_url_ecrire($script = '', $args = '', $no_entities = false, $rel = false) { |
| 2190 | - if (!$rel) { |
|
| 2191 | - $rel = url_de_base() . _DIR_RESTREINT_ABS . _SPIP_ECRIRE_SCRIPT; |
|
| 2192 | - } else { |
|
| 2193 | - if (!is_string($rel)) { |
|
| 2194 | - $rel = _DIR_RESTREINT ?: './' . _SPIP_ECRIRE_SCRIPT; |
|
| 2195 | - } |
|
| 2196 | - } |
|
| 2197 | - |
|
| 2198 | - [$script, $ancre] = array_pad(explode('#', $script), 2, null); |
|
| 2199 | - if ($script and ($script <> 'accueil' or $rel)) { |
|
| 2200 | - $args = "?exec=$script" . (!$args ? '' : "&$args"); |
|
| 2201 | - } elseif ($args) { |
|
| 2202 | - $args = "?$args"; |
|
| 2203 | - } |
|
| 2204 | - if ($ancre) { |
|
| 2205 | - $args .= "#$ancre"; |
|
| 2206 | - } |
|
| 2207 | - |
|
| 2208 | - return $rel . ($no_entities ? $args : str_replace('&', '&', $args)); |
|
| 2189 | + if (!$rel) { |
|
| 2190 | + $rel = url_de_base() . _DIR_RESTREINT_ABS . _SPIP_ECRIRE_SCRIPT; |
|
| 2191 | + } else { |
|
| 2192 | + if (!is_string($rel)) { |
|
| 2193 | + $rel = _DIR_RESTREINT ?: './' . _SPIP_ECRIRE_SCRIPT; |
|
| 2194 | + } |
|
| 2195 | + } |
|
| 2196 | + |
|
| 2197 | + [$script, $ancre] = array_pad(explode('#', $script), 2, null); |
|
| 2198 | + if ($script and ($script <> 'accueil' or $rel)) { |
|
| 2199 | + $args = "?exec=$script" . (!$args ? '' : "&$args"); |
|
| 2200 | + } elseif ($args) { |
|
| 2201 | + $args = "?$args"; |
|
| 2202 | + } |
|
| 2203 | + if ($ancre) { |
|
| 2204 | + $args .= "#$ancre"; |
|
| 2205 | + } |
|
| 2206 | + |
|
| 2207 | + return $rel . ($no_entities ? $args : str_replace('&', '&', $args)); |
|
| 2209 | 2208 | } |
| 2210 | 2209 | |
| 2211 | 2210 | // |
@@ -2227,15 +2226,15 @@ discard block |
||
| 2227 | 2226 | * Nom du fichier (constante _SPIP_SCRIPT), sinon nom par défaut |
| 2228 | 2227 | **/ |
| 2229 | 2228 | function get_spip_script($default = '') { |
| 2230 | - if (!defined('_SPIP_SCRIPT')) { |
|
| 2231 | - return 'spip.php'; |
|
| 2232 | - } |
|
| 2233 | - # cas define('_SPIP_SCRIPT', ''); |
|
| 2234 | - if (_SPIP_SCRIPT) { |
|
| 2235 | - return _SPIP_SCRIPT; |
|
| 2236 | - } else { |
|
| 2237 | - return $default; |
|
| 2238 | - } |
|
| 2229 | + if (!defined('_SPIP_SCRIPT')) { |
|
| 2230 | + return 'spip.php'; |
|
| 2231 | + } |
|
| 2232 | + # cas define('_SPIP_SCRIPT', ''); |
|
| 2233 | + if (_SPIP_SCRIPT) { |
|
| 2234 | + return _SPIP_SCRIPT; |
|
| 2235 | + } else { |
|
| 2236 | + return $default; |
|
| 2237 | + } |
|
| 2239 | 2238 | } |
| 2240 | 2239 | |
| 2241 | 2240 | /** |
@@ -2264,45 +2263,45 @@ discard block |
||
| 2264 | 2263 | * @return string URL |
| 2265 | 2264 | **/ |
| 2266 | 2265 | function generer_url_public($script = '', $args = '', $no_entities = false, $rel = true, $action = '') { |
| 2267 | - // si le script est une action (spip_pass, spip_inscription), |
|
| 2268 | - // standardiser vers la nouvelle API |
|
| 2269 | - |
|
| 2270 | - if (is_array($args)) { |
|
| 2271 | - $args = http_build_query($args); |
|
| 2272 | - } |
|
| 2273 | - |
|
| 2274 | - $url = ''; |
|
| 2275 | - if ($f = charger_fonction_url('page')) { |
|
| 2276 | - $url = $f($script, $args); |
|
| 2277 | - if ($url and !$rel) { |
|
| 2278 | - include_spip('inc/filtres_mini'); |
|
| 2279 | - $url = url_absolue($url); |
|
| 2280 | - } |
|
| 2281 | - } |
|
| 2282 | - if (!$url) { |
|
| 2283 | - if (!$action) { |
|
| 2284 | - $action = get_spip_script(); |
|
| 2285 | - } |
|
| 2286 | - if ($script) { |
|
| 2287 | - $action = parametre_url($action, _SPIP_PAGE, $script, '&'); |
|
| 2288 | - } |
|
| 2289 | - if ($args) { |
|
| 2290 | - $action .= (strpos($action, '?') !== false ? '&' : '?') . $args; |
|
| 2291 | - } |
|
| 2292 | - // ne pas generer une url avec /./?page= en cas d'url absolue et de _SPIP_SCRIPT vide |
|
| 2293 | - $url = ($rel ? _DIR_RACINE . $action : rtrim(url_de_base(), '/') . preg_replace(',^/[.]/,', '/', "/$action")); |
|
| 2294 | - } |
|
| 2295 | - |
|
| 2296 | - if (!$no_entities) { |
|
| 2297 | - $url = quote_amp($url); |
|
| 2298 | - } |
|
| 2299 | - |
|
| 2300 | - return $url; |
|
| 2266 | + // si le script est une action (spip_pass, spip_inscription), |
|
| 2267 | + // standardiser vers la nouvelle API |
|
| 2268 | + |
|
| 2269 | + if (is_array($args)) { |
|
| 2270 | + $args = http_build_query($args); |
|
| 2271 | + } |
|
| 2272 | + |
|
| 2273 | + $url = ''; |
|
| 2274 | + if ($f = charger_fonction_url('page')) { |
|
| 2275 | + $url = $f($script, $args); |
|
| 2276 | + if ($url and !$rel) { |
|
| 2277 | + include_spip('inc/filtres_mini'); |
|
| 2278 | + $url = url_absolue($url); |
|
| 2279 | + } |
|
| 2280 | + } |
|
| 2281 | + if (!$url) { |
|
| 2282 | + if (!$action) { |
|
| 2283 | + $action = get_spip_script(); |
|
| 2284 | + } |
|
| 2285 | + if ($script) { |
|
| 2286 | + $action = parametre_url($action, _SPIP_PAGE, $script, '&'); |
|
| 2287 | + } |
|
| 2288 | + if ($args) { |
|
| 2289 | + $action .= (strpos($action, '?') !== false ? '&' : '?') . $args; |
|
| 2290 | + } |
|
| 2291 | + // ne pas generer une url avec /./?page= en cas d'url absolue et de _SPIP_SCRIPT vide |
|
| 2292 | + $url = ($rel ? _DIR_RACINE . $action : rtrim(url_de_base(), '/') . preg_replace(',^/[.]/,', '/', "/$action")); |
|
| 2293 | + } |
|
| 2294 | + |
|
| 2295 | + if (!$no_entities) { |
|
| 2296 | + $url = quote_amp($url); |
|
| 2297 | + } |
|
| 2298 | + |
|
| 2299 | + return $url; |
|
| 2301 | 2300 | } |
| 2302 | 2301 | |
| 2303 | 2302 | function generer_url_prive($script, $args = '', $no_entities = false) { |
| 2304 | 2303 | |
| 2305 | - return generer_url_public($script, $args, $no_entities, false, _DIR_RESTREINT_ABS . 'prive.php'); |
|
| 2304 | + return generer_url_public($script, $args, $no_entities, false, _DIR_RESTREINT_ABS . 'prive.php'); |
|
| 2306 | 2305 | } |
| 2307 | 2306 | |
| 2308 | 2307 | // Pour les formulaires en methode POST, |
@@ -2327,19 +2326,19 @@ discard block |
||
| 2327 | 2326 | **/ |
| 2328 | 2327 | function generer_form_ecrire($script, $corps, $atts = '', $submit = '') { |
| 2329 | 2328 | |
| 2330 | - $script1 = explode('&', $script); |
|
| 2331 | - $script1 = reset($script1); |
|
| 2329 | + $script1 = explode('&', $script); |
|
| 2330 | + $script1 = reset($script1); |
|
| 2332 | 2331 | |
| 2333 | - return "<form action='" |
|
| 2334 | - . ($script ? generer_url_ecrire($script) : '') |
|
| 2335 | - . "' " |
|
| 2336 | - . ($atts ?: " method='post'") |
|
| 2337 | - . "><div>\n" |
|
| 2338 | - . "<input type='hidden' name='exec' value='$script1' />" |
|
| 2339 | - . $corps |
|
| 2340 | - . (!$submit ? '' : |
|
| 2341 | - ("<div style='text-align: " . $GLOBALS['spip_lang_right'] . "'><input class='fondo submit btn' type='submit' value=\"" . entites_html($submit) . '" /></div>')) |
|
| 2342 | - . "</div></form>\n"; |
|
| 2332 | + return "<form action='" |
|
| 2333 | + . ($script ? generer_url_ecrire($script) : '') |
|
| 2334 | + . "' " |
|
| 2335 | + . ($atts ?: " method='post'") |
|
| 2336 | + . "><div>\n" |
|
| 2337 | + . "<input type='hidden' name='exec' value='$script1' />" |
|
| 2338 | + . $corps |
|
| 2339 | + . (!$submit ? '' : |
|
| 2340 | + ("<div style='text-align: " . $GLOBALS['spip_lang_right'] . "'><input class='fondo submit btn' type='submit' value=\"" . entites_html($submit) . '" /></div>')) |
|
| 2341 | + . "</div></form>\n"; |
|
| 2343 | 2342 | } |
| 2344 | 2343 | |
| 2345 | 2344 | /** |
@@ -2356,22 +2355,22 @@ discard block |
||
| 2356 | 2355 | * @return string |
| 2357 | 2356 | */ |
| 2358 | 2357 | function generer_form_action($script, $corps, $atts = '', $public = false) { |
| 2359 | - // si l'on est dans l'espace prive, on garde dans l'url |
|
| 2360 | - // l'exec a l'origine de l'action, qui permet de savoir si il est necessaire |
|
| 2361 | - // ou non de proceder a l'authentification (cas typique de l'install par exemple) |
|
| 2362 | - $h = (_DIR_RACINE and !$public) |
|
| 2363 | - ? generer_url_ecrire(_request('exec')) |
|
| 2364 | - : generer_url_public(); |
|
| 2358 | + // si l'on est dans l'espace prive, on garde dans l'url |
|
| 2359 | + // l'exec a l'origine de l'action, qui permet de savoir si il est necessaire |
|
| 2360 | + // ou non de proceder a l'authentification (cas typique de l'install par exemple) |
|
| 2361 | + $h = (_DIR_RACINE and !$public) |
|
| 2362 | + ? generer_url_ecrire(_request('exec')) |
|
| 2363 | + : generer_url_public(); |
|
| 2365 | 2364 | |
| 2366 | - return "\n<form action='" . |
|
| 2367 | - $h . |
|
| 2368 | - "'" . |
|
| 2369 | - $atts . |
|
| 2370 | - ">\n" . |
|
| 2371 | - '<div>' . |
|
| 2372 | - "\n<input type='hidden' name='action' value='$script' />" . |
|
| 2373 | - $corps . |
|
| 2374 | - '</div></form>'; |
|
| 2365 | + return "\n<form action='" . |
|
| 2366 | + $h . |
|
| 2367 | + "'" . |
|
| 2368 | + $atts . |
|
| 2369 | + ">\n" . |
|
| 2370 | + '<div>' . |
|
| 2371 | + "\n<input type='hidden' name='action' value='$script' />" . |
|
| 2372 | + $corps . |
|
| 2373 | + '</div></form>'; |
|
| 2375 | 2374 | } |
| 2376 | 2375 | |
| 2377 | 2376 | /** |
@@ -2390,22 +2389,22 @@ discard block |
||
| 2390 | 2389 | * URL |
| 2391 | 2390 | */ |
| 2392 | 2391 | function generer_url_action($script, $args = '', $no_entities = false, $public = false) { |
| 2393 | - // si l'on est dans l'espace prive, on garde dans l'url |
|
| 2394 | - // l'exec a l'origine de l'action, qui permet de savoir si il est necessaire |
|
| 2395 | - // ou non de proceder a l'authentification (cas typique de l'install par exemple) |
|
| 2396 | - $url = (_DIR_RACINE and !$public) |
|
| 2397 | - ? generer_url_ecrire(_request('exec')) |
|
| 2398 | - : generer_url_public('', '', false, false); |
|
| 2399 | - $url = parametre_url($url, 'action', $script); |
|
| 2400 | - if ($args) { |
|
| 2401 | - $url .= quote_amp('&' . $args); |
|
| 2402 | - } |
|
| 2392 | + // si l'on est dans l'espace prive, on garde dans l'url |
|
| 2393 | + // l'exec a l'origine de l'action, qui permet de savoir si il est necessaire |
|
| 2394 | + // ou non de proceder a l'authentification (cas typique de l'install par exemple) |
|
| 2395 | + $url = (_DIR_RACINE and !$public) |
|
| 2396 | + ? generer_url_ecrire(_request('exec')) |
|
| 2397 | + : generer_url_public('', '', false, false); |
|
| 2398 | + $url = parametre_url($url, 'action', $script); |
|
| 2399 | + if ($args) { |
|
| 2400 | + $url .= quote_amp('&' . $args); |
|
| 2401 | + } |
|
| 2403 | 2402 | |
| 2404 | - if ($no_entities) { |
|
| 2405 | - $url = str_replace('&', '&', $url); |
|
| 2406 | - } |
|
| 2403 | + if ($no_entities) { |
|
| 2404 | + $url = str_replace('&', '&', $url); |
|
| 2405 | + } |
|
| 2407 | 2406 | |
| 2408 | - return $url; |
|
| 2407 | + return $url; |
|
| 2409 | 2408 | } |
| 2410 | 2409 | |
| 2411 | 2410 | |
@@ -2424,23 +2423,23 @@ discard block |
||
| 2424 | 2423 | * URL |
| 2425 | 2424 | */ |
| 2426 | 2425 | function generer_url_api(string $script, string $path, string $args, bool $no_entities = false, ?bool $public = null) { |
| 2427 | - if (is_null($public)) { |
|
| 2428 | - $public = (_DIR_RACINE ? false : ''); |
|
| 2429 | - } |
|
| 2430 | - if (substr($script, -4) !== '.api') { |
|
| 2431 | - $script .= '.api'; |
|
| 2432 | - } |
|
| 2433 | - $url = |
|
| 2434 | - (($public ? _DIR_RACINE : _DIR_RESTREINT) ?: './') |
|
| 2435 | - . $script . '/' |
|
| 2436 | - . ($path ? trim($path, '/') : '') |
|
| 2437 | - . ($args ? "?" . quote_amp($args) : ''); |
|
| 2426 | + if (is_null($public)) { |
|
| 2427 | + $public = (_DIR_RACINE ? false : ''); |
|
| 2428 | + } |
|
| 2429 | + if (substr($script, -4) !== '.api') { |
|
| 2430 | + $script .= '.api'; |
|
| 2431 | + } |
|
| 2432 | + $url = |
|
| 2433 | + (($public ? _DIR_RACINE : _DIR_RESTREINT) ?: './') |
|
| 2434 | + . $script . '/' |
|
| 2435 | + . ($path ? trim($path, '/') : '') |
|
| 2436 | + . ($args ? "?" . quote_amp($args) : ''); |
|
| 2438 | 2437 | |
| 2439 | - if ($no_entities) { |
|
| 2440 | - $url = str_replace('&', '&', $url); |
|
| 2441 | - } |
|
| 2438 | + if ($no_entities) { |
|
| 2439 | + $url = str_replace('&', '&', $url); |
|
| 2440 | + } |
|
| 2442 | 2441 | |
| 2443 | - return $url; |
|
| 2442 | + return $url; |
|
| 2444 | 2443 | } |
| 2445 | 2444 | |
| 2446 | 2445 | |
@@ -2453,8 +2452,8 @@ discard block |
||
| 2453 | 2452 | * @param string $ta Répertoire temporaire accessible |
| 2454 | 2453 | */ |
| 2455 | 2454 | function spip_initialisation($pi = null, $pa = null, $ti = null, $ta = null) { |
| 2456 | - spip_initialisation_core($pi, $pa, $ti, $ta); |
|
| 2457 | - spip_initialisation_suite(); |
|
| 2455 | + spip_initialisation_core($pi, $pa, $ti, $ta); |
|
| 2456 | + spip_initialisation_suite(); |
|
| 2458 | 2457 | } |
| 2459 | 2458 | |
| 2460 | 2459 | /** |
@@ -2474,322 +2473,322 @@ discard block |
||
| 2474 | 2473 | * @param string $ta Répertoire temporaire accessible |
| 2475 | 2474 | */ |
| 2476 | 2475 | function spip_initialisation_core($pi = null, $pa = null, $ti = null, $ta = null) { |
| 2477 | - static $too_late = 0; |
|
| 2478 | - if ($too_late++) { |
|
| 2479 | - return; |
|
| 2480 | - } |
|
| 2481 | - |
|
| 2482 | - // Declaration des repertoires |
|
| 2483 | - |
|
| 2484 | - // le nom du repertoire plugins/ activables/desactivables |
|
| 2485 | - if (!defined('_DIR_PLUGINS')) { |
|
| 2486 | - define('_DIR_PLUGINS', _DIR_RACINE . 'plugins/'); |
|
| 2487 | - } |
|
| 2488 | - |
|
| 2489 | - // le nom du repertoire des extensions/ permanentes du core, toujours actives |
|
| 2490 | - if (!defined('_DIR_PLUGINS_DIST')) { |
|
| 2491 | - define('_DIR_PLUGINS_DIST', _DIR_RACINE . 'plugins-dist/'); |
|
| 2492 | - } |
|
| 2493 | - |
|
| 2494 | - // le nom du repertoire des librairies |
|
| 2495 | - if (!defined('_DIR_LIB')) { |
|
| 2496 | - define('_DIR_LIB', _DIR_RACINE . 'lib/'); |
|
| 2497 | - } |
|
| 2498 | - |
|
| 2499 | - if (!defined('_DIR_IMG')) { |
|
| 2500 | - define('_DIR_IMG', $pa); |
|
| 2501 | - } |
|
| 2502 | - if (!defined('_DIR_LOGOS')) { |
|
| 2503 | - define('_DIR_LOGOS', $pa); |
|
| 2504 | - } |
|
| 2505 | - if (!defined('_DIR_IMG_ICONES')) { |
|
| 2506 | - define('_DIR_IMG_ICONES', _DIR_LOGOS . 'icones/'); |
|
| 2507 | - } |
|
| 2508 | - |
|
| 2509 | - if (!defined('_DIR_DUMP')) { |
|
| 2510 | - define('_DIR_DUMP', $ti . 'dump/'); |
|
| 2511 | - } |
|
| 2512 | - if (!defined('_DIR_SESSIONS')) { |
|
| 2513 | - define('_DIR_SESSIONS', $ti . 'sessions/'); |
|
| 2514 | - } |
|
| 2515 | - if (!defined('_DIR_TRANSFERT')) { |
|
| 2516 | - define('_DIR_TRANSFERT', $ti . 'upload/'); |
|
| 2517 | - } |
|
| 2518 | - if (!defined('_DIR_CACHE')) { |
|
| 2519 | - define('_DIR_CACHE', $ti . 'cache/'); |
|
| 2520 | - } |
|
| 2521 | - if (!defined('_DIR_CACHE_XML')) { |
|
| 2522 | - define('_DIR_CACHE_XML', _DIR_CACHE . 'xml/'); |
|
| 2523 | - } |
|
| 2524 | - if (!defined('_DIR_SKELS')) { |
|
| 2525 | - define('_DIR_SKELS', _DIR_CACHE . 'skel/'); |
|
| 2526 | - } |
|
| 2527 | - if (!defined('_DIR_AIDE')) { |
|
| 2528 | - define('_DIR_AIDE', _DIR_CACHE . 'aide/'); |
|
| 2529 | - } |
|
| 2530 | - if (!defined('_DIR_TMP')) { |
|
| 2531 | - define('_DIR_TMP', $ti); |
|
| 2532 | - } |
|
| 2533 | - |
|
| 2534 | - if (!defined('_DIR_VAR')) { |
|
| 2535 | - define('_DIR_VAR', $ta); |
|
| 2536 | - } |
|
| 2537 | - |
|
| 2538 | - if (!defined('_DIR_ETC')) { |
|
| 2539 | - define('_DIR_ETC', $pi); |
|
| 2540 | - } |
|
| 2541 | - if (!defined('_DIR_CONNECT')) { |
|
| 2542 | - define('_DIR_CONNECT', $pi); |
|
| 2543 | - } |
|
| 2544 | - if (!defined('_DIR_CHMOD')) { |
|
| 2545 | - define('_DIR_CHMOD', $pi); |
|
| 2546 | - } |
|
| 2547 | - |
|
| 2548 | - if (!isset($GLOBALS['test_dirs'])) { |
|
| 2549 | - // Pas $pi car il est bon de le mettre hors ecriture apres intstall |
|
| 2550 | - // il sera rajoute automatiquement si besoin a l'etape 2 de l'install |
|
| 2551 | - $GLOBALS['test_dirs'] = [$pa, $ti, $ta]; |
|
| 2552 | - } |
|
| 2553 | - |
|
| 2554 | - // Declaration des fichiers |
|
| 2555 | - |
|
| 2556 | - if (!defined('_CACHE_PLUGINS_PATH')) { |
|
| 2557 | - define('_CACHE_PLUGINS_PATH', _DIR_CACHE . 'charger_plugins_chemins.php'); |
|
| 2558 | - } |
|
| 2559 | - if (!defined('_CACHE_PLUGINS_OPT')) { |
|
| 2560 | - define('_CACHE_PLUGINS_OPT', _DIR_CACHE . 'charger_plugins_options.php'); |
|
| 2561 | - } |
|
| 2562 | - if (!defined('_CACHE_PLUGINS_FCT')) { |
|
| 2563 | - define('_CACHE_PLUGINS_FCT', _DIR_CACHE . 'charger_plugins_fonctions.php'); |
|
| 2564 | - } |
|
| 2565 | - if (!defined('_CACHE_PIPELINES')) { |
|
| 2566 | - define('_CACHE_PIPELINES', _DIR_CACHE . 'charger_pipelines.php'); |
|
| 2567 | - } |
|
| 2568 | - if (!defined('_CACHE_CHEMIN')) { |
|
| 2569 | - define('_CACHE_CHEMIN', _DIR_CACHE . 'chemin.txt'); |
|
| 2570 | - } |
|
| 2571 | - |
|
| 2572 | - # attention .php obligatoire pour ecrire_fichier_securise |
|
| 2573 | - if (!defined('_FILE_META')) { |
|
| 2574 | - define('_FILE_META', $ti . 'meta_cache.php'); |
|
| 2575 | - } |
|
| 2576 | - if (!defined('_DIR_LOG')) { |
|
| 2577 | - define('_DIR_LOG', _DIR_TMP . 'log/'); |
|
| 2578 | - } |
|
| 2579 | - if (!defined('_FILE_LOG')) { |
|
| 2580 | - define('_FILE_LOG', 'spip'); |
|
| 2581 | - } |
|
| 2582 | - if (!defined('_FILE_LOG_SUFFIX')) { |
|
| 2583 | - define('_FILE_LOG_SUFFIX', '.log'); |
|
| 2584 | - } |
|
| 2585 | - |
|
| 2586 | - // Le fichier de connexion a la base de donnees |
|
| 2587 | - // tient compte des anciennes versions (inc_connect...) |
|
| 2588 | - if (!defined('_FILE_CONNECT_INS')) { |
|
| 2589 | - define('_FILE_CONNECT_INS', 'connect'); |
|
| 2590 | - } |
|
| 2591 | - if (!defined('_FILE_CONNECT')) { |
|
| 2592 | - define( |
|
| 2593 | - '_FILE_CONNECT', |
|
| 2594 | - (@is_readable($f = _DIR_CONNECT . _FILE_CONNECT_INS . '.php') ? $f |
|
| 2595 | - : (@is_readable($f = _DIR_RESTREINT . 'inc_connect.php') ? $f |
|
| 2596 | - : false)) |
|
| 2597 | - ); |
|
| 2598 | - } |
|
| 2599 | - |
|
| 2600 | - // Le fichier de reglages des droits |
|
| 2601 | - if (!defined('_FILE_CHMOD_INS')) { |
|
| 2602 | - define('_FILE_CHMOD_INS', 'chmod'); |
|
| 2603 | - } |
|
| 2604 | - if (!defined('_FILE_CHMOD')) { |
|
| 2605 | - define( |
|
| 2606 | - '_FILE_CHMOD', |
|
| 2607 | - (@is_readable($f = _DIR_CHMOD . _FILE_CHMOD_INS . '.php') ? $f |
|
| 2608 | - : false) |
|
| 2609 | - ); |
|
| 2610 | - } |
|
| 2611 | - |
|
| 2612 | - if (!defined('_FILE_LDAP')) { |
|
| 2613 | - define('_FILE_LDAP', 'ldap.php'); |
|
| 2614 | - } |
|
| 2615 | - |
|
| 2616 | - if (!defined('_FILE_TMP_SUFFIX')) { |
|
| 2617 | - define('_FILE_TMP_SUFFIX', '.tmp.php'); |
|
| 2618 | - } |
|
| 2619 | - if (!defined('_FILE_CONNECT_TMP')) { |
|
| 2620 | - define('_FILE_CONNECT_TMP', _DIR_CONNECT . _FILE_CONNECT_INS . _FILE_TMP_SUFFIX); |
|
| 2621 | - } |
|
| 2622 | - if (!defined('_FILE_CHMOD_TMP')) { |
|
| 2623 | - define('_FILE_CHMOD_TMP', _DIR_CHMOD . _FILE_CHMOD_INS . _FILE_TMP_SUFFIX); |
|
| 2624 | - } |
|
| 2625 | - |
|
| 2626 | - // Definition des droits d'acces en ecriture |
|
| 2627 | - if (!defined('_SPIP_CHMOD') and _FILE_CHMOD) { |
|
| 2628 | - include_once _FILE_CHMOD; |
|
| 2629 | - } |
|
| 2630 | - |
|
| 2631 | - // Se mefier des fichiers mal remplis! |
|
| 2632 | - if (!defined('_SPIP_CHMOD')) { |
|
| 2633 | - define('_SPIP_CHMOD', 0777); |
|
| 2634 | - } |
|
| 2635 | - |
|
| 2636 | - if (!defined('_DEFAULT_CHARSET')) { |
|
| 2637 | - /** Le charset par défaut lors de l'installation */ |
|
| 2638 | - define('_DEFAULT_CHARSET', 'utf-8'); |
|
| 2639 | - } |
|
| 2640 | - if (!defined('_ROOT_PLUGINS')) { |
|
| 2641 | - define('_ROOT_PLUGINS', _ROOT_RACINE . 'plugins/'); |
|
| 2642 | - } |
|
| 2643 | - if (!defined('_ROOT_PLUGINS_DIST')) { |
|
| 2644 | - define('_ROOT_PLUGINS_DIST', _ROOT_RACINE . 'plugins-dist/'); |
|
| 2645 | - } |
|
| 2646 | - if (!defined('_ROOT_PLUGINS_SUPPL') && defined('_DIR_PLUGINS_SUPPL') && _DIR_PLUGINS_SUPPL) { |
|
| 2647 | - define('_ROOT_PLUGINS_SUPPL', _ROOT_RACINE . str_replace(_DIR_RACINE, '', _DIR_PLUGINS_SUPPL)); |
|
| 2648 | - } |
|
| 2649 | - |
|
| 2650 | - // La taille des Log |
|
| 2651 | - if (!defined('_MAX_LOG')) { |
|
| 2652 | - define('_MAX_LOG', 100); |
|
| 2653 | - } |
|
| 2654 | - |
|
| 2655 | - // Sommes-nous dans l'empire du Mal ? |
|
| 2656 | - // (ou sous le signe du Pingouin, ascendant GNU ?) |
|
| 2657 | - if (isset($_SERVER['SERVER_SOFTWARE']) and strpos($_SERVER['SERVER_SOFTWARE'], '(Win') !== false) { |
|
| 2658 | - if (!defined('_OS_SERVEUR')) { |
|
| 2659 | - define('_OS_SERVEUR', 'windows'); |
|
| 2660 | - } |
|
| 2661 | - if (!defined('_SPIP_LOCK_MODE')) { |
|
| 2662 | - define('_SPIP_LOCK_MODE', 1); |
|
| 2663 | - } // utiliser le flock php |
|
| 2664 | - } else { |
|
| 2665 | - if (!defined('_OS_SERVEUR')) { |
|
| 2666 | - define('_OS_SERVEUR', ''); |
|
| 2667 | - } |
|
| 2668 | - if (!defined('_SPIP_LOCK_MODE')) { |
|
| 2669 | - define('_SPIP_LOCK_MODE', 1); |
|
| 2670 | - } // utiliser le flock php |
|
| 2671 | - #if (!defined('_SPIP_LOCK_MODE')) define('_SPIP_LOCK_MODE',2); // utiliser le nfslock de spip mais link() est tres souvent interdite |
|
| 2672 | - } |
|
| 2673 | - |
|
| 2674 | - // Langue par defaut |
|
| 2675 | - if (!defined('_LANGUE_PAR_DEFAUT')) { |
|
| 2676 | - define('_LANGUE_PAR_DEFAUT', 'fr'); |
|
| 2677 | - } |
|
| 2678 | - |
|
| 2679 | - // |
|
| 2680 | - // Module de lecture/ecriture/suppression de fichiers utilisant flock() |
|
| 2681 | - // (non surchargeable en l'etat ; attention si on utilise include_spip() |
|
| 2682 | - // pour le rendre surchargeable, on va provoquer un reecriture |
|
| 2683 | - // systematique du noyau ou une baisse de perfs => a etudier) |
|
| 2684 | - include_once _ROOT_RESTREINT . 'inc/flock.php'; |
|
| 2685 | - |
|
| 2686 | - // charger tout de suite le path et son cache |
|
| 2687 | - load_path_cache(); |
|
| 2688 | - |
|
| 2689 | - // *********** traiter les variables ************ |
|
| 2690 | - |
|
| 2691 | - // |
|
| 2692 | - // Securite |
|
| 2693 | - // |
|
| 2694 | - |
|
| 2695 | - // Ne pas se faire manger par un bug php qui accepte ?GLOBALS[truc]=toto |
|
| 2696 | - if (isset($_REQUEST['GLOBALS'])) { |
|
| 2697 | - die(); |
|
| 2698 | - } |
|
| 2699 | - // nettoyer les magic quotes \' et les caracteres nuls %00 |
|
| 2700 | - spip_desinfecte($_GET); |
|
| 2701 | - spip_desinfecte($_POST); |
|
| 2702 | - spip_desinfecte($_COOKIE); |
|
| 2703 | - spip_desinfecte($_REQUEST); |
|
| 2704 | - |
|
| 2705 | - // appliquer le cookie_prefix |
|
| 2706 | - if ($GLOBALS['cookie_prefix'] != 'spip') { |
|
| 2707 | - include_spip('inc/cookie'); |
|
| 2708 | - recuperer_cookies_spip($GLOBALS['cookie_prefix']); |
|
| 2709 | - } |
|
| 2710 | - |
|
| 2711 | - // |
|
| 2712 | - // Capacites php (en fonction de la version) |
|
| 2713 | - // |
|
| 2714 | - $GLOBALS['flag_ob'] = (function_exists('ob_start') |
|
| 2715 | - && function_exists('ini_get') |
|
| 2716 | - && !strstr(@ini_get('disable_functions'), 'ob_')); |
|
| 2717 | - $GLOBALS['flag_sapi_name'] = function_exists('php_sapi_name'); |
|
| 2718 | - $GLOBALS['flag_get_cfg_var'] = (@get_cfg_var('error_reporting') != ''); |
|
| 2719 | - $GLOBALS['flag_upload'] = (!$GLOBALS['flag_get_cfg_var'] || |
|
| 2720 | - (get_cfg_var('upload_max_filesize') > 0)); |
|
| 2721 | - |
|
| 2722 | - |
|
| 2723 | - // Compatibilite avec serveurs ne fournissant pas $REQUEST_URI |
|
| 2724 | - if (isset($_SERVER['REQUEST_URI'])) { |
|
| 2725 | - $GLOBALS['REQUEST_URI'] = $_SERVER['REQUEST_URI']; |
|
| 2726 | - } else { |
|
| 2727 | - $GLOBALS['REQUEST_URI'] = (php_sapi_name() !== 'cli') ? $_SERVER['PHP_SELF'] : ''; |
|
| 2728 | - if ( |
|
| 2729 | - !empty($_SERVER['QUERY_STRING']) |
|
| 2730 | - and !strpos($_SERVER['REQUEST_URI'], '?') |
|
| 2731 | - ) { |
|
| 2732 | - $GLOBALS['REQUEST_URI'] .= '?' . $_SERVER['QUERY_STRING']; |
|
| 2733 | - } |
|
| 2734 | - } |
|
| 2735 | - |
|
| 2736 | - // Duree de validite de l'alea pour les cookies et ce qui s'ensuit. |
|
| 2737 | - if (!defined('_RENOUVELLE_ALEA')) { |
|
| 2738 | - define('_RENOUVELLE_ALEA', 12 * 3600); |
|
| 2739 | - } |
|
| 2740 | - if (!defined('_DUREE_COOKIE_ADMIN')) { |
|
| 2741 | - define('_DUREE_COOKIE_ADMIN', 14 * 24 * 3600); |
|
| 2742 | - } |
|
| 2743 | - |
|
| 2744 | - // charger les meta si possible et renouveller l'alea au besoin |
|
| 2745 | - // charge aussi effacer_meta et ecrire_meta |
|
| 2746 | - $inc_meta = charger_fonction('meta', 'inc'); |
|
| 2747 | - $inc_meta(); |
|
| 2748 | - |
|
| 2749 | - // nombre de repertoires depuis la racine |
|
| 2750 | - // on compare a l'adresse de spip.php : $_SERVER["SCRIPT_NAME"] |
|
| 2751 | - // ou a defaut celle donnee en meta ; (mais si celle-ci est fausse |
|
| 2752 | - // le calcul est faux) |
|
| 2753 | - if (!_DIR_RESTREINT) { |
|
| 2754 | - $GLOBALS['profondeur_url'] = 1; |
|
| 2755 | - } else { |
|
| 2756 | - $uri = isset($_SERVER['REQUEST_URI']) ? explode('?', $_SERVER['REQUEST_URI']) : ''; |
|
| 2757 | - $uri_ref = $_SERVER['SCRIPT_NAME']; |
|
| 2758 | - if ( |
|
| 2759 | - !$uri_ref |
|
| 2760 | - // si on est appele avec un autre ti, on est sans doute en mutu |
|
| 2761 | - // si jamais c'est de la mutu avec sous rep, on est perdu si on se fie |
|
| 2762 | - // a spip.php qui est a la racine du spip, et vue qu'on sait pas se reperer |
|
| 2763 | - // s'en remettre a l'adresse du site. alea jacta est. |
|
| 2764 | - or $ti !== _NOM_TEMPORAIRES_INACCESSIBLES |
|
| 2765 | - ) { |
|
| 2766 | - if (isset($GLOBALS['meta']['adresse_site'])) { |
|
| 2767 | - $uri_ref = parse_url($GLOBALS['meta']['adresse_site']); |
|
| 2768 | - $uri_ref = ($uri_ref['path'] ?? '') . '/'; |
|
| 2769 | - } else { |
|
| 2770 | - $uri_ref = ''; |
|
| 2771 | - } |
|
| 2772 | - } |
|
| 2773 | - if (!$uri or !$uri_ref) { |
|
| 2774 | - $GLOBALS['profondeur_url'] = 0; |
|
| 2775 | - } else { |
|
| 2776 | - $GLOBALS['profondeur_url'] = max( |
|
| 2777 | - 0, |
|
| 2778 | - substr_count($uri[0], '/') |
|
| 2779 | - - substr_count($uri_ref, '/') |
|
| 2780 | - ); |
|
| 2781 | - } |
|
| 2782 | - } |
|
| 2783 | - // s'il y a un cookie ou PHP_AUTH, initialiser visiteur_session |
|
| 2784 | - if (_FILE_CONNECT) { |
|
| 2785 | - if ( |
|
| 2786 | - verifier_visiteur() == '0minirezo' |
|
| 2787 | - // si c'est un admin sans cookie admin, il faut ignorer le cache chemin ! |
|
| 2788 | - and !isset($_COOKIE['spip_admin']) |
|
| 2789 | - ) { |
|
| 2790 | - clear_path_cache(); |
|
| 2791 | - } |
|
| 2792 | - } |
|
| 2476 | + static $too_late = 0; |
|
| 2477 | + if ($too_late++) { |
|
| 2478 | + return; |
|
| 2479 | + } |
|
| 2480 | + |
|
| 2481 | + // Declaration des repertoires |
|
| 2482 | + |
|
| 2483 | + // le nom du repertoire plugins/ activables/desactivables |
|
| 2484 | + if (!defined('_DIR_PLUGINS')) { |
|
| 2485 | + define('_DIR_PLUGINS', _DIR_RACINE . 'plugins/'); |
|
| 2486 | + } |
|
| 2487 | + |
|
| 2488 | + // le nom du repertoire des extensions/ permanentes du core, toujours actives |
|
| 2489 | + if (!defined('_DIR_PLUGINS_DIST')) { |
|
| 2490 | + define('_DIR_PLUGINS_DIST', _DIR_RACINE . 'plugins-dist/'); |
|
| 2491 | + } |
|
| 2492 | + |
|
| 2493 | + // le nom du repertoire des librairies |
|
| 2494 | + if (!defined('_DIR_LIB')) { |
|
| 2495 | + define('_DIR_LIB', _DIR_RACINE . 'lib/'); |
|
| 2496 | + } |
|
| 2497 | + |
|
| 2498 | + if (!defined('_DIR_IMG')) { |
|
| 2499 | + define('_DIR_IMG', $pa); |
|
| 2500 | + } |
|
| 2501 | + if (!defined('_DIR_LOGOS')) { |
|
| 2502 | + define('_DIR_LOGOS', $pa); |
|
| 2503 | + } |
|
| 2504 | + if (!defined('_DIR_IMG_ICONES')) { |
|
| 2505 | + define('_DIR_IMG_ICONES', _DIR_LOGOS . 'icones/'); |
|
| 2506 | + } |
|
| 2507 | + |
|
| 2508 | + if (!defined('_DIR_DUMP')) { |
|
| 2509 | + define('_DIR_DUMP', $ti . 'dump/'); |
|
| 2510 | + } |
|
| 2511 | + if (!defined('_DIR_SESSIONS')) { |
|
| 2512 | + define('_DIR_SESSIONS', $ti . 'sessions/'); |
|
| 2513 | + } |
|
| 2514 | + if (!defined('_DIR_TRANSFERT')) { |
|
| 2515 | + define('_DIR_TRANSFERT', $ti . 'upload/'); |
|
| 2516 | + } |
|
| 2517 | + if (!defined('_DIR_CACHE')) { |
|
| 2518 | + define('_DIR_CACHE', $ti . 'cache/'); |
|
| 2519 | + } |
|
| 2520 | + if (!defined('_DIR_CACHE_XML')) { |
|
| 2521 | + define('_DIR_CACHE_XML', _DIR_CACHE . 'xml/'); |
|
| 2522 | + } |
|
| 2523 | + if (!defined('_DIR_SKELS')) { |
|
| 2524 | + define('_DIR_SKELS', _DIR_CACHE . 'skel/'); |
|
| 2525 | + } |
|
| 2526 | + if (!defined('_DIR_AIDE')) { |
|
| 2527 | + define('_DIR_AIDE', _DIR_CACHE . 'aide/'); |
|
| 2528 | + } |
|
| 2529 | + if (!defined('_DIR_TMP')) { |
|
| 2530 | + define('_DIR_TMP', $ti); |
|
| 2531 | + } |
|
| 2532 | + |
|
| 2533 | + if (!defined('_DIR_VAR')) { |
|
| 2534 | + define('_DIR_VAR', $ta); |
|
| 2535 | + } |
|
| 2536 | + |
|
| 2537 | + if (!defined('_DIR_ETC')) { |
|
| 2538 | + define('_DIR_ETC', $pi); |
|
| 2539 | + } |
|
| 2540 | + if (!defined('_DIR_CONNECT')) { |
|
| 2541 | + define('_DIR_CONNECT', $pi); |
|
| 2542 | + } |
|
| 2543 | + if (!defined('_DIR_CHMOD')) { |
|
| 2544 | + define('_DIR_CHMOD', $pi); |
|
| 2545 | + } |
|
| 2546 | + |
|
| 2547 | + if (!isset($GLOBALS['test_dirs'])) { |
|
| 2548 | + // Pas $pi car il est bon de le mettre hors ecriture apres intstall |
|
| 2549 | + // il sera rajoute automatiquement si besoin a l'etape 2 de l'install |
|
| 2550 | + $GLOBALS['test_dirs'] = [$pa, $ti, $ta]; |
|
| 2551 | + } |
|
| 2552 | + |
|
| 2553 | + // Declaration des fichiers |
|
| 2554 | + |
|
| 2555 | + if (!defined('_CACHE_PLUGINS_PATH')) { |
|
| 2556 | + define('_CACHE_PLUGINS_PATH', _DIR_CACHE . 'charger_plugins_chemins.php'); |
|
| 2557 | + } |
|
| 2558 | + if (!defined('_CACHE_PLUGINS_OPT')) { |
|
| 2559 | + define('_CACHE_PLUGINS_OPT', _DIR_CACHE . 'charger_plugins_options.php'); |
|
| 2560 | + } |
|
| 2561 | + if (!defined('_CACHE_PLUGINS_FCT')) { |
|
| 2562 | + define('_CACHE_PLUGINS_FCT', _DIR_CACHE . 'charger_plugins_fonctions.php'); |
|
| 2563 | + } |
|
| 2564 | + if (!defined('_CACHE_PIPELINES')) { |
|
| 2565 | + define('_CACHE_PIPELINES', _DIR_CACHE . 'charger_pipelines.php'); |
|
| 2566 | + } |
|
| 2567 | + if (!defined('_CACHE_CHEMIN')) { |
|
| 2568 | + define('_CACHE_CHEMIN', _DIR_CACHE . 'chemin.txt'); |
|
| 2569 | + } |
|
| 2570 | + |
|
| 2571 | + # attention .php obligatoire pour ecrire_fichier_securise |
|
| 2572 | + if (!defined('_FILE_META')) { |
|
| 2573 | + define('_FILE_META', $ti . 'meta_cache.php'); |
|
| 2574 | + } |
|
| 2575 | + if (!defined('_DIR_LOG')) { |
|
| 2576 | + define('_DIR_LOG', _DIR_TMP . 'log/'); |
|
| 2577 | + } |
|
| 2578 | + if (!defined('_FILE_LOG')) { |
|
| 2579 | + define('_FILE_LOG', 'spip'); |
|
| 2580 | + } |
|
| 2581 | + if (!defined('_FILE_LOG_SUFFIX')) { |
|
| 2582 | + define('_FILE_LOG_SUFFIX', '.log'); |
|
| 2583 | + } |
|
| 2584 | + |
|
| 2585 | + // Le fichier de connexion a la base de donnees |
|
| 2586 | + // tient compte des anciennes versions (inc_connect...) |
|
| 2587 | + if (!defined('_FILE_CONNECT_INS')) { |
|
| 2588 | + define('_FILE_CONNECT_INS', 'connect'); |
|
| 2589 | + } |
|
| 2590 | + if (!defined('_FILE_CONNECT')) { |
|
| 2591 | + define( |
|
| 2592 | + '_FILE_CONNECT', |
|
| 2593 | + (@is_readable($f = _DIR_CONNECT . _FILE_CONNECT_INS . '.php') ? $f |
|
| 2594 | + : (@is_readable($f = _DIR_RESTREINT . 'inc_connect.php') ? $f |
|
| 2595 | + : false)) |
|
| 2596 | + ); |
|
| 2597 | + } |
|
| 2598 | + |
|
| 2599 | + // Le fichier de reglages des droits |
|
| 2600 | + if (!defined('_FILE_CHMOD_INS')) { |
|
| 2601 | + define('_FILE_CHMOD_INS', 'chmod'); |
|
| 2602 | + } |
|
| 2603 | + if (!defined('_FILE_CHMOD')) { |
|
| 2604 | + define( |
|
| 2605 | + '_FILE_CHMOD', |
|
| 2606 | + (@is_readable($f = _DIR_CHMOD . _FILE_CHMOD_INS . '.php') ? $f |
|
| 2607 | + : false) |
|
| 2608 | + ); |
|
| 2609 | + } |
|
| 2610 | + |
|
| 2611 | + if (!defined('_FILE_LDAP')) { |
|
| 2612 | + define('_FILE_LDAP', 'ldap.php'); |
|
| 2613 | + } |
|
| 2614 | + |
|
| 2615 | + if (!defined('_FILE_TMP_SUFFIX')) { |
|
| 2616 | + define('_FILE_TMP_SUFFIX', '.tmp.php'); |
|
| 2617 | + } |
|
| 2618 | + if (!defined('_FILE_CONNECT_TMP')) { |
|
| 2619 | + define('_FILE_CONNECT_TMP', _DIR_CONNECT . _FILE_CONNECT_INS . _FILE_TMP_SUFFIX); |
|
| 2620 | + } |
|
| 2621 | + if (!defined('_FILE_CHMOD_TMP')) { |
|
| 2622 | + define('_FILE_CHMOD_TMP', _DIR_CHMOD . _FILE_CHMOD_INS . _FILE_TMP_SUFFIX); |
|
| 2623 | + } |
|
| 2624 | + |
|
| 2625 | + // Definition des droits d'acces en ecriture |
|
| 2626 | + if (!defined('_SPIP_CHMOD') and _FILE_CHMOD) { |
|
| 2627 | + include_once _FILE_CHMOD; |
|
| 2628 | + } |
|
| 2629 | + |
|
| 2630 | + // Se mefier des fichiers mal remplis! |
|
| 2631 | + if (!defined('_SPIP_CHMOD')) { |
|
| 2632 | + define('_SPIP_CHMOD', 0777); |
|
| 2633 | + } |
|
| 2634 | + |
|
| 2635 | + if (!defined('_DEFAULT_CHARSET')) { |
|
| 2636 | + /** Le charset par défaut lors de l'installation */ |
|
| 2637 | + define('_DEFAULT_CHARSET', 'utf-8'); |
|
| 2638 | + } |
|
| 2639 | + if (!defined('_ROOT_PLUGINS')) { |
|
| 2640 | + define('_ROOT_PLUGINS', _ROOT_RACINE . 'plugins/'); |
|
| 2641 | + } |
|
| 2642 | + if (!defined('_ROOT_PLUGINS_DIST')) { |
|
| 2643 | + define('_ROOT_PLUGINS_DIST', _ROOT_RACINE . 'plugins-dist/'); |
|
| 2644 | + } |
|
| 2645 | + if (!defined('_ROOT_PLUGINS_SUPPL') && defined('_DIR_PLUGINS_SUPPL') && _DIR_PLUGINS_SUPPL) { |
|
| 2646 | + define('_ROOT_PLUGINS_SUPPL', _ROOT_RACINE . str_replace(_DIR_RACINE, '', _DIR_PLUGINS_SUPPL)); |
|
| 2647 | + } |
|
| 2648 | + |
|
| 2649 | + // La taille des Log |
|
| 2650 | + if (!defined('_MAX_LOG')) { |
|
| 2651 | + define('_MAX_LOG', 100); |
|
| 2652 | + } |
|
| 2653 | + |
|
| 2654 | + // Sommes-nous dans l'empire du Mal ? |
|
| 2655 | + // (ou sous le signe du Pingouin, ascendant GNU ?) |
|
| 2656 | + if (isset($_SERVER['SERVER_SOFTWARE']) and strpos($_SERVER['SERVER_SOFTWARE'], '(Win') !== false) { |
|
| 2657 | + if (!defined('_OS_SERVEUR')) { |
|
| 2658 | + define('_OS_SERVEUR', 'windows'); |
|
| 2659 | + } |
|
| 2660 | + if (!defined('_SPIP_LOCK_MODE')) { |
|
| 2661 | + define('_SPIP_LOCK_MODE', 1); |
|
| 2662 | + } // utiliser le flock php |
|
| 2663 | + } else { |
|
| 2664 | + if (!defined('_OS_SERVEUR')) { |
|
| 2665 | + define('_OS_SERVEUR', ''); |
|
| 2666 | + } |
|
| 2667 | + if (!defined('_SPIP_LOCK_MODE')) { |
|
| 2668 | + define('_SPIP_LOCK_MODE', 1); |
|
| 2669 | + } // utiliser le flock php |
|
| 2670 | + #if (!defined('_SPIP_LOCK_MODE')) define('_SPIP_LOCK_MODE',2); // utiliser le nfslock de spip mais link() est tres souvent interdite |
|
| 2671 | + } |
|
| 2672 | + |
|
| 2673 | + // Langue par defaut |
|
| 2674 | + if (!defined('_LANGUE_PAR_DEFAUT')) { |
|
| 2675 | + define('_LANGUE_PAR_DEFAUT', 'fr'); |
|
| 2676 | + } |
|
| 2677 | + |
|
| 2678 | + // |
|
| 2679 | + // Module de lecture/ecriture/suppression de fichiers utilisant flock() |
|
| 2680 | + // (non surchargeable en l'etat ; attention si on utilise include_spip() |
|
| 2681 | + // pour le rendre surchargeable, on va provoquer un reecriture |
|
| 2682 | + // systematique du noyau ou une baisse de perfs => a etudier) |
|
| 2683 | + include_once _ROOT_RESTREINT . 'inc/flock.php'; |
|
| 2684 | + |
|
| 2685 | + // charger tout de suite le path et son cache |
|
| 2686 | + load_path_cache(); |
|
| 2687 | + |
|
| 2688 | + // *********** traiter les variables ************ |
|
| 2689 | + |
|
| 2690 | + // |
|
| 2691 | + // Securite |
|
| 2692 | + // |
|
| 2693 | + |
|
| 2694 | + // Ne pas se faire manger par un bug php qui accepte ?GLOBALS[truc]=toto |
|
| 2695 | + if (isset($_REQUEST['GLOBALS'])) { |
|
| 2696 | + die(); |
|
| 2697 | + } |
|
| 2698 | + // nettoyer les magic quotes \' et les caracteres nuls %00 |
|
| 2699 | + spip_desinfecte($_GET); |
|
| 2700 | + spip_desinfecte($_POST); |
|
| 2701 | + spip_desinfecte($_COOKIE); |
|
| 2702 | + spip_desinfecte($_REQUEST); |
|
| 2703 | + |
|
| 2704 | + // appliquer le cookie_prefix |
|
| 2705 | + if ($GLOBALS['cookie_prefix'] != 'spip') { |
|
| 2706 | + include_spip('inc/cookie'); |
|
| 2707 | + recuperer_cookies_spip($GLOBALS['cookie_prefix']); |
|
| 2708 | + } |
|
| 2709 | + |
|
| 2710 | + // |
|
| 2711 | + // Capacites php (en fonction de la version) |
|
| 2712 | + // |
|
| 2713 | + $GLOBALS['flag_ob'] = (function_exists('ob_start') |
|
| 2714 | + && function_exists('ini_get') |
|
| 2715 | + && !strstr(@ini_get('disable_functions'), 'ob_')); |
|
| 2716 | + $GLOBALS['flag_sapi_name'] = function_exists('php_sapi_name'); |
|
| 2717 | + $GLOBALS['flag_get_cfg_var'] = (@get_cfg_var('error_reporting') != ''); |
|
| 2718 | + $GLOBALS['flag_upload'] = (!$GLOBALS['flag_get_cfg_var'] || |
|
| 2719 | + (get_cfg_var('upload_max_filesize') > 0)); |
|
| 2720 | + |
|
| 2721 | + |
|
| 2722 | + // Compatibilite avec serveurs ne fournissant pas $REQUEST_URI |
|
| 2723 | + if (isset($_SERVER['REQUEST_URI'])) { |
|
| 2724 | + $GLOBALS['REQUEST_URI'] = $_SERVER['REQUEST_URI']; |
|
| 2725 | + } else { |
|
| 2726 | + $GLOBALS['REQUEST_URI'] = (php_sapi_name() !== 'cli') ? $_SERVER['PHP_SELF'] : ''; |
|
| 2727 | + if ( |
|
| 2728 | + !empty($_SERVER['QUERY_STRING']) |
|
| 2729 | + and !strpos($_SERVER['REQUEST_URI'], '?') |
|
| 2730 | + ) { |
|
| 2731 | + $GLOBALS['REQUEST_URI'] .= '?' . $_SERVER['QUERY_STRING']; |
|
| 2732 | + } |
|
| 2733 | + } |
|
| 2734 | + |
|
| 2735 | + // Duree de validite de l'alea pour les cookies et ce qui s'ensuit. |
|
| 2736 | + if (!defined('_RENOUVELLE_ALEA')) { |
|
| 2737 | + define('_RENOUVELLE_ALEA', 12 * 3600); |
|
| 2738 | + } |
|
| 2739 | + if (!defined('_DUREE_COOKIE_ADMIN')) { |
|
| 2740 | + define('_DUREE_COOKIE_ADMIN', 14 * 24 * 3600); |
|
| 2741 | + } |
|
| 2742 | + |
|
| 2743 | + // charger les meta si possible et renouveller l'alea au besoin |
|
| 2744 | + // charge aussi effacer_meta et ecrire_meta |
|
| 2745 | + $inc_meta = charger_fonction('meta', 'inc'); |
|
| 2746 | + $inc_meta(); |
|
| 2747 | + |
|
| 2748 | + // nombre de repertoires depuis la racine |
|
| 2749 | + // on compare a l'adresse de spip.php : $_SERVER["SCRIPT_NAME"] |
|
| 2750 | + // ou a defaut celle donnee en meta ; (mais si celle-ci est fausse |
|
| 2751 | + // le calcul est faux) |
|
| 2752 | + if (!_DIR_RESTREINT) { |
|
| 2753 | + $GLOBALS['profondeur_url'] = 1; |
|
| 2754 | + } else { |
|
| 2755 | + $uri = isset($_SERVER['REQUEST_URI']) ? explode('?', $_SERVER['REQUEST_URI']) : ''; |
|
| 2756 | + $uri_ref = $_SERVER['SCRIPT_NAME']; |
|
| 2757 | + if ( |
|
| 2758 | + !$uri_ref |
|
| 2759 | + // si on est appele avec un autre ti, on est sans doute en mutu |
|
| 2760 | + // si jamais c'est de la mutu avec sous rep, on est perdu si on se fie |
|
| 2761 | + // a spip.php qui est a la racine du spip, et vue qu'on sait pas se reperer |
|
| 2762 | + // s'en remettre a l'adresse du site. alea jacta est. |
|
| 2763 | + or $ti !== _NOM_TEMPORAIRES_INACCESSIBLES |
|
| 2764 | + ) { |
|
| 2765 | + if (isset($GLOBALS['meta']['adresse_site'])) { |
|
| 2766 | + $uri_ref = parse_url($GLOBALS['meta']['adresse_site']); |
|
| 2767 | + $uri_ref = ($uri_ref['path'] ?? '') . '/'; |
|
| 2768 | + } else { |
|
| 2769 | + $uri_ref = ''; |
|
| 2770 | + } |
|
| 2771 | + } |
|
| 2772 | + if (!$uri or !$uri_ref) { |
|
| 2773 | + $GLOBALS['profondeur_url'] = 0; |
|
| 2774 | + } else { |
|
| 2775 | + $GLOBALS['profondeur_url'] = max( |
|
| 2776 | + 0, |
|
| 2777 | + substr_count($uri[0], '/') |
|
| 2778 | + - substr_count($uri_ref, '/') |
|
| 2779 | + ); |
|
| 2780 | + } |
|
| 2781 | + } |
|
| 2782 | + // s'il y a un cookie ou PHP_AUTH, initialiser visiteur_session |
|
| 2783 | + if (_FILE_CONNECT) { |
|
| 2784 | + if ( |
|
| 2785 | + verifier_visiteur() == '0minirezo' |
|
| 2786 | + // si c'est un admin sans cookie admin, il faut ignorer le cache chemin ! |
|
| 2787 | + and !isset($_COOKIE['spip_admin']) |
|
| 2788 | + ) { |
|
| 2789 | + clear_path_cache(); |
|
| 2790 | + } |
|
| 2791 | + } |
|
| 2793 | 2792 | } |
| 2794 | 2793 | |
| 2795 | 2794 | /** |
@@ -2798,190 +2797,190 @@ discard block |
||
| 2798 | 2797 | * |
| 2799 | 2798 | */ |
| 2800 | 2799 | function spip_initialisation_suite() { |
| 2801 | - static $too_late = 0; |
|
| 2802 | - if ($too_late++) { |
|
| 2803 | - return; |
|
| 2804 | - } |
|
| 2805 | - |
|
| 2806 | - // taille mini des login |
|
| 2807 | - if (!defined('_LOGIN_TROP_COURT')) { |
|
| 2808 | - define('_LOGIN_TROP_COURT', 4); |
|
| 2809 | - } |
|
| 2810 | - |
|
| 2811 | - // la taille maxi des logos (0 : pas de limite) (pas de define par defaut, ce n'est pas utile) |
|
| 2812 | - #if (!defined('_LOGO_MAX_SIZE')) define('_LOGO_MAX_SIZE', 0); # poids en ko |
|
| 2813 | - #if (!defined('_LOGO_MAX_WIDTH')) define('_LOGO_MAX_WIDTH', 0); # largeur en pixels |
|
| 2814 | - #if (!defined('_LOGO_MAX_HEIGHT')) define('_LOGO_MAX_HEIGHT', 0); # hauteur en pixels |
|
| 2815 | - |
|
| 2816 | - // la taille maxi des images (0 : pas de limite) (pas de define par defaut, ce n'est pas utile) |
|
| 2817 | - #if (!defined('_DOC_MAX_SIZE')) define('_DOC_MAX_SIZE', 0); # poids en ko |
|
| 2818 | - #if (!defined('_IMG_MAX_SIZE')) define('_IMG_MAX_SIZE', 0); # poids en ko |
|
| 2819 | - #if (!defined('_IMG_MAX_WIDTH')) define('_IMG_MAX_WIDTH', 0); # largeur en pixels |
|
| 2820 | - #if (!defined('_IMG_MAX_HEIGHT')) define('_IMG_MAX_HEIGHT', 0); # hauteur en pixels |
|
| 2821 | - |
|
| 2822 | - if (!defined('_PASS_LONGUEUR_MINI')) { |
|
| 2823 | - define('_PASS_LONGUEUR_MINI', 6); |
|
| 2824 | - } |
|
| 2825 | - |
|
| 2826 | - // largeur maximale des images dans l'administration |
|
| 2827 | - if (!defined('_IMG_ADMIN_MAX_WIDTH')) { |
|
| 2828 | - define('_IMG_ADMIN_MAX_WIDTH', 768); |
|
| 2829 | - } |
|
| 2830 | - |
|
| 2831 | - // Qualite des images calculees automatiquement. C'est un nombre entre 0 et 100, meme pour imagick (on ramene a 0..1 par la suite) |
|
| 2832 | - if (!defined('_IMG_QUALITE')) { |
|
| 2833 | - define('_IMG_QUALITE', 85); |
|
| 2834 | - } # valeur par defaut |
|
| 2835 | - if (!defined('_IMG_GD_QUALITE')) { |
|
| 2836 | - define('_IMG_GD_QUALITE', _IMG_QUALITE); |
|
| 2837 | - } # surcharge pour la lib GD |
|
| 2838 | - if (!defined('_IMG_CONVERT_QUALITE')) { |
|
| 2839 | - define('_IMG_CONVERT_QUALITE', _IMG_QUALITE); |
|
| 2840 | - } # surcharge pour imagick en ligne de commande |
|
| 2841 | - // Historiquement la valeur pour imagick semble differente. Si ca n'est pas necessaire, il serait preferable de garder _IMG_QUALITE |
|
| 2842 | - if (!defined('_IMG_IMAGICK_QUALITE')) { |
|
| 2843 | - define('_IMG_IMAGICK_QUALITE', 75); |
|
| 2844 | - } # surcharge pour imagick en PHP |
|
| 2845 | - |
|
| 2846 | - if (!defined('_COPIE_LOCALE_MAX_SIZE')) { |
|
| 2847 | - define('_COPIE_LOCALE_MAX_SIZE', 33_554_432); |
|
| 2848 | - } // poids en octet |
|
| 2849 | - |
|
| 2850 | - // qq chaines standard |
|
| 2851 | - if (!defined('_ACCESS_FILE_NAME')) { |
|
| 2852 | - define('_ACCESS_FILE_NAME', '.htaccess'); |
|
| 2853 | - } |
|
| 2854 | - if (!defined('_AUTH_USER_FILE')) { |
|
| 2855 | - define('_AUTH_USER_FILE', '.htpasswd'); |
|
| 2856 | - } |
|
| 2857 | - if (!defined('_SPIP_DUMP')) { |
|
| 2858 | - define('_SPIP_DUMP', 'dump@nom_site@@[email protected]'); |
|
| 2859 | - } |
|
| 2860 | - if (!defined('_CACHE_RUBRIQUES')) { |
|
| 2861 | - /** Fichier cache pour le navigateur de rubrique du bandeau */ |
|
| 2862 | - define('_CACHE_RUBRIQUES', _DIR_TMP . 'menu-rubriques-cache.txt'); |
|
| 2863 | - } |
|
| 2864 | - if (!defined('_CACHE_RUBRIQUES_MAX')) { |
|
| 2865 | - /** Nombre maxi de rubriques enfants affichées pour chaque rubrique du navigateur de rubrique du bandeau */ |
|
| 2866 | - define('_CACHE_RUBRIQUES_MAX', 500); |
|
| 2867 | - } |
|
| 2868 | - |
|
| 2869 | - if (!defined('_CACHE_CONTEXTES_AJAX_SUR_LONGUEUR')) { |
|
| 2870 | - /** |
|
| 2871 | - * Basculer les contextes ajax en fichier si la longueur d’url est trop grande |
|
| 2872 | - * @var int Nombre de caractères */ |
|
| 2873 | - define('_CACHE_CONTEXTES_AJAX_SUR_LONGUEUR', 2000); |
|
| 2874 | - } |
|
| 2875 | - |
|
| 2876 | - if (!defined('_EXTENSION_SQUELETTES')) { |
|
| 2877 | - define('_EXTENSION_SQUELETTES', 'html'); |
|
| 2878 | - } |
|
| 2879 | - |
|
| 2880 | - if (!defined('_DOCTYPE_ECRIRE')) { |
|
| 2881 | - /** Définit le doctype de l’espace privé */ |
|
| 2882 | - define('_DOCTYPE_ECRIRE', "<!DOCTYPE html>\n"); |
|
| 2883 | - } |
|
| 2884 | - if (!defined('_DOCTYPE_AIDE')) { |
|
| 2885 | - /** Définit le doctype de l’aide en ligne */ |
|
| 2886 | - define( |
|
| 2887 | - '_DOCTYPE_AIDE', |
|
| 2888 | - "<!DOCTYPE html PUBLIC '-//W3C//DTD HTML 4.01 Frameset//EN' 'http://www.w3.org/TR/1999/REC-html401-19991224/frameset.dtd'>" |
|
| 2889 | - ); |
|
| 2890 | - } |
|
| 2891 | - |
|
| 2892 | - if (!defined('_SPIP_SCRIPT')) { |
|
| 2893 | - /** L'adresse de base du site ; on peut mettre '' si la racine est gerée par |
|
| 2894 | - * le script de l'espace public, alias index.php */ |
|
| 2895 | - define('_SPIP_SCRIPT', 'spip.php'); |
|
| 2896 | - } |
|
| 2897 | - if (!defined('_SPIP_PAGE')) { |
|
| 2898 | - /** Argument page, personalisable en cas de conflit avec un autre script */ |
|
| 2899 | - define('_SPIP_PAGE', 'page'); |
|
| 2900 | - } |
|
| 2901 | - |
|
| 2902 | - // le script de l'espace prive |
|
| 2903 | - // Mettre a "index.php" si DirectoryIndex ne le fait pas ou pb connexes: |
|
| 2904 | - // les anciens IIS n'acceptent pas les POST sur ecrire/ (#419) |
|
| 2905 | - // meme pb sur thttpd cf. https://forum.spip.net/fr_184153.html |
|
| 2906 | - if (!defined('_SPIP_ECRIRE_SCRIPT')) { |
|
| 2907 | - if (!empty($_SERVER['SERVER_SOFTWARE']) and preg_match(',IIS|thttpd,', $_SERVER['SERVER_SOFTWARE'])) { |
|
| 2908 | - define('_SPIP_ECRIRE_SCRIPT', 'index.php'); |
|
| 2909 | - } else { |
|
| 2910 | - define('_SPIP_ECRIRE_SCRIPT', ''); |
|
| 2911 | - } |
|
| 2912 | - } |
|
| 2913 | - |
|
| 2914 | - |
|
| 2915 | - if (!defined('_SPIP_AJAX')) { |
|
| 2916 | - define('_SPIP_AJAX', ((!isset($_COOKIE['spip_accepte_ajax'])) |
|
| 2917 | - ? 1 |
|
| 2918 | - : (($_COOKIE['spip_accepte_ajax'] != -1) ? 1 : 0))); |
|
| 2919 | - } |
|
| 2920 | - |
|
| 2921 | - // La requete est-elle en ajax ? |
|
| 2922 | - if (!defined('_AJAX')) { |
|
| 2923 | - define( |
|
| 2924 | - '_AJAX', |
|
| 2925 | - (isset($_SERVER['HTTP_X_REQUESTED_WITH']) # ajax jQuery |
|
| 2926 | - or !empty($_REQUEST['var_ajax_redir']) # redirection 302 apres ajax jQuery |
|
| 2927 | - or !empty($_REQUEST['var_ajaxcharset']) # compat ascendante pour plugins |
|
| 2928 | - or !empty($_REQUEST['var_ajax']) # forms ajax & inclure ajax de spip |
|
| 2929 | - ) |
|
| 2930 | - and empty($_REQUEST['var_noajax']) # horrible exception, car c'est pas parce que la requete est ajax jquery qu'il faut tuer tous les formulaires ajax qu'elle contient |
|
| 2931 | - ); |
|
| 2932 | - } |
|
| 2933 | - |
|
| 2934 | - # nombre de pixels maxi pour calcul de la vignette avec gd |
|
| 2935 | - # au dela de 5500000 on considere que php n'est pas limite en memoire pour cette operation |
|
| 2936 | - # les configurations limitees en memoire ont un seuil plutot vers 1MPixel |
|
| 2937 | - if (!defined('_IMG_GD_MAX_PIXELS')) { |
|
| 2938 | - define( |
|
| 2939 | - '_IMG_GD_MAX_PIXELS', |
|
| 2940 | - (isset($GLOBALS['meta']['max_taille_vignettes']) and $GLOBALS['meta']['max_taille_vignettes']) |
|
| 2941 | - ? $GLOBALS['meta']['max_taille_vignettes'] |
|
| 2942 | - : 0 |
|
| 2943 | - ); |
|
| 2944 | - } |
|
| 2945 | - |
|
| 2946 | - if (!defined('_MEMORY_LIMIT_MIN')) { |
|
| 2947 | - define('_MEMORY_LIMIT_MIN', 16); |
|
| 2948 | - } // en Mo |
|
| 2949 | - // si on est dans l'espace prive et si le besoin est superieur a 8Mo (qui est vraiment le standard) |
|
| 2950 | - // on verifie que la memoire est suffisante pour le compactage css+js pour eviter la page blanche |
|
| 2951 | - // il y aura d'autres problemes et l'utilisateur n'ira pas tres loin, mais ce sera plus comprehensible qu'une page blanche |
|
| 2952 | - if (test_espace_prive() and _MEMORY_LIMIT_MIN > 8) { |
|
| 2953 | - if ($memory = trim(ini_get('memory_limit')) and $memory != -1) { |
|
| 2954 | - $unit = strtolower(substr($memory, -1)); |
|
| 2955 | - $memory = substr($memory, 0, -1); |
|
| 2956 | - switch ($unit) { |
|
| 2957 | - // Le modifieur 'G' est disponible depuis PHP 5.1.0 |
|
| 2958 | - case 'g': |
|
| 2959 | - $memory *= 1024; |
|
| 2960 | - case 'm': |
|
| 2961 | - $memory *= 1024; |
|
| 2962 | - case 'k': |
|
| 2963 | - $memory *= 1024; |
|
| 2964 | - } |
|
| 2965 | - if ($memory < _MEMORY_LIMIT_MIN * 1024 * 1024) { |
|
| 2966 | - @ini_set('memory_limit', $m = _MEMORY_LIMIT_MIN . 'M'); |
|
| 2967 | - if (trim(ini_get('memory_limit')) != $m) { |
|
| 2968 | - if (!defined('_INTERDIRE_COMPACTE_HEAD_ECRIRE')) { |
|
| 2969 | - define('_INTERDIRE_COMPACTE_HEAD_ECRIRE', true); |
|
| 2970 | - } // evite une page blanche car on ne saura pas calculer la css dans ce hit |
|
| 2971 | - } |
|
| 2972 | - } |
|
| 2973 | - } else { |
|
| 2974 | - if (!defined('_INTERDIRE_COMPACTE_HEAD_ECRIRE')) { |
|
| 2975 | - define('_INTERDIRE_COMPACTE_HEAD_ECRIRE', true); |
|
| 2976 | - } |
|
| 2977 | - } // evite une page blanche car on ne saura pas calculer la css dans ce hit |
|
| 2978 | - } |
|
| 2979 | - // Protocoles a normaliser dans les chaines de langues |
|
| 2980 | - if (!defined('_PROTOCOLES_STD')) { |
|
| 2981 | - define('_PROTOCOLES_STD', 'http|https|ftp|mailto|webcal'); |
|
| 2982 | - } |
|
| 2983 | - |
|
| 2984 | - init_var_mode(); |
|
| 2800 | + static $too_late = 0; |
|
| 2801 | + if ($too_late++) { |
|
| 2802 | + return; |
|
| 2803 | + } |
|
| 2804 | + |
|
| 2805 | + // taille mini des login |
|
| 2806 | + if (!defined('_LOGIN_TROP_COURT')) { |
|
| 2807 | + define('_LOGIN_TROP_COURT', 4); |
|
| 2808 | + } |
|
| 2809 | + |
|
| 2810 | + // la taille maxi des logos (0 : pas de limite) (pas de define par defaut, ce n'est pas utile) |
|
| 2811 | + #if (!defined('_LOGO_MAX_SIZE')) define('_LOGO_MAX_SIZE', 0); # poids en ko |
|
| 2812 | + #if (!defined('_LOGO_MAX_WIDTH')) define('_LOGO_MAX_WIDTH', 0); # largeur en pixels |
|
| 2813 | + #if (!defined('_LOGO_MAX_HEIGHT')) define('_LOGO_MAX_HEIGHT', 0); # hauteur en pixels |
|
| 2814 | + |
|
| 2815 | + // la taille maxi des images (0 : pas de limite) (pas de define par defaut, ce n'est pas utile) |
|
| 2816 | + #if (!defined('_DOC_MAX_SIZE')) define('_DOC_MAX_SIZE', 0); # poids en ko |
|
| 2817 | + #if (!defined('_IMG_MAX_SIZE')) define('_IMG_MAX_SIZE', 0); # poids en ko |
|
| 2818 | + #if (!defined('_IMG_MAX_WIDTH')) define('_IMG_MAX_WIDTH', 0); # largeur en pixels |
|
| 2819 | + #if (!defined('_IMG_MAX_HEIGHT')) define('_IMG_MAX_HEIGHT', 0); # hauteur en pixels |
|
| 2820 | + |
|
| 2821 | + if (!defined('_PASS_LONGUEUR_MINI')) { |
|
| 2822 | + define('_PASS_LONGUEUR_MINI', 6); |
|
| 2823 | + } |
|
| 2824 | + |
|
| 2825 | + // largeur maximale des images dans l'administration |
|
| 2826 | + if (!defined('_IMG_ADMIN_MAX_WIDTH')) { |
|
| 2827 | + define('_IMG_ADMIN_MAX_WIDTH', 768); |
|
| 2828 | + } |
|
| 2829 | + |
|
| 2830 | + // Qualite des images calculees automatiquement. C'est un nombre entre 0 et 100, meme pour imagick (on ramene a 0..1 par la suite) |
|
| 2831 | + if (!defined('_IMG_QUALITE')) { |
|
| 2832 | + define('_IMG_QUALITE', 85); |
|
| 2833 | + } # valeur par defaut |
|
| 2834 | + if (!defined('_IMG_GD_QUALITE')) { |
|
| 2835 | + define('_IMG_GD_QUALITE', _IMG_QUALITE); |
|
| 2836 | + } # surcharge pour la lib GD |
|
| 2837 | + if (!defined('_IMG_CONVERT_QUALITE')) { |
|
| 2838 | + define('_IMG_CONVERT_QUALITE', _IMG_QUALITE); |
|
| 2839 | + } # surcharge pour imagick en ligne de commande |
|
| 2840 | + // Historiquement la valeur pour imagick semble differente. Si ca n'est pas necessaire, il serait preferable de garder _IMG_QUALITE |
|
| 2841 | + if (!defined('_IMG_IMAGICK_QUALITE')) { |
|
| 2842 | + define('_IMG_IMAGICK_QUALITE', 75); |
|
| 2843 | + } # surcharge pour imagick en PHP |
|
| 2844 | + |
|
| 2845 | + if (!defined('_COPIE_LOCALE_MAX_SIZE')) { |
|
| 2846 | + define('_COPIE_LOCALE_MAX_SIZE', 33_554_432); |
|
| 2847 | + } // poids en octet |
|
| 2848 | + |
|
| 2849 | + // qq chaines standard |
|
| 2850 | + if (!defined('_ACCESS_FILE_NAME')) { |
|
| 2851 | + define('_ACCESS_FILE_NAME', '.htaccess'); |
|
| 2852 | + } |
|
| 2853 | + if (!defined('_AUTH_USER_FILE')) { |
|
| 2854 | + define('_AUTH_USER_FILE', '.htpasswd'); |
|
| 2855 | + } |
|
| 2856 | + if (!defined('_SPIP_DUMP')) { |
|
| 2857 | + define('_SPIP_DUMP', 'dump@nom_site@@[email protected]'); |
|
| 2858 | + } |
|
| 2859 | + if (!defined('_CACHE_RUBRIQUES')) { |
|
| 2860 | + /** Fichier cache pour le navigateur de rubrique du bandeau */ |
|
| 2861 | + define('_CACHE_RUBRIQUES', _DIR_TMP . 'menu-rubriques-cache.txt'); |
|
| 2862 | + } |
|
| 2863 | + if (!defined('_CACHE_RUBRIQUES_MAX')) { |
|
| 2864 | + /** Nombre maxi de rubriques enfants affichées pour chaque rubrique du navigateur de rubrique du bandeau */ |
|
| 2865 | + define('_CACHE_RUBRIQUES_MAX', 500); |
|
| 2866 | + } |
|
| 2867 | + |
|
| 2868 | + if (!defined('_CACHE_CONTEXTES_AJAX_SUR_LONGUEUR')) { |
|
| 2869 | + /** |
|
| 2870 | + * Basculer les contextes ajax en fichier si la longueur d’url est trop grande |
|
| 2871 | + * @var int Nombre de caractères */ |
|
| 2872 | + define('_CACHE_CONTEXTES_AJAX_SUR_LONGUEUR', 2000); |
|
| 2873 | + } |
|
| 2874 | + |
|
| 2875 | + if (!defined('_EXTENSION_SQUELETTES')) { |
|
| 2876 | + define('_EXTENSION_SQUELETTES', 'html'); |
|
| 2877 | + } |
|
| 2878 | + |
|
| 2879 | + if (!defined('_DOCTYPE_ECRIRE')) { |
|
| 2880 | + /** Définit le doctype de l’espace privé */ |
|
| 2881 | + define('_DOCTYPE_ECRIRE', "<!DOCTYPE html>\n"); |
|
| 2882 | + } |
|
| 2883 | + if (!defined('_DOCTYPE_AIDE')) { |
|
| 2884 | + /** Définit le doctype de l’aide en ligne */ |
|
| 2885 | + define( |
|
| 2886 | + '_DOCTYPE_AIDE', |
|
| 2887 | + "<!DOCTYPE html PUBLIC '-//W3C//DTD HTML 4.01 Frameset//EN' 'http://www.w3.org/TR/1999/REC-html401-19991224/frameset.dtd'>" |
|
| 2888 | + ); |
|
| 2889 | + } |
|
| 2890 | + |
|
| 2891 | + if (!defined('_SPIP_SCRIPT')) { |
|
| 2892 | + /** L'adresse de base du site ; on peut mettre '' si la racine est gerée par |
|
| 2893 | + * le script de l'espace public, alias index.php */ |
|
| 2894 | + define('_SPIP_SCRIPT', 'spip.php'); |
|
| 2895 | + } |
|
| 2896 | + if (!defined('_SPIP_PAGE')) { |
|
| 2897 | + /** Argument page, personalisable en cas de conflit avec un autre script */ |
|
| 2898 | + define('_SPIP_PAGE', 'page'); |
|
| 2899 | + } |
|
| 2900 | + |
|
| 2901 | + // le script de l'espace prive |
|
| 2902 | + // Mettre a "index.php" si DirectoryIndex ne le fait pas ou pb connexes: |
|
| 2903 | + // les anciens IIS n'acceptent pas les POST sur ecrire/ (#419) |
|
| 2904 | + // meme pb sur thttpd cf. https://forum.spip.net/fr_184153.html |
|
| 2905 | + if (!defined('_SPIP_ECRIRE_SCRIPT')) { |
|
| 2906 | + if (!empty($_SERVER['SERVER_SOFTWARE']) and preg_match(',IIS|thttpd,', $_SERVER['SERVER_SOFTWARE'])) { |
|
| 2907 | + define('_SPIP_ECRIRE_SCRIPT', 'index.php'); |
|
| 2908 | + } else { |
|
| 2909 | + define('_SPIP_ECRIRE_SCRIPT', ''); |
|
| 2910 | + } |
|
| 2911 | + } |
|
| 2912 | + |
|
| 2913 | + |
|
| 2914 | + if (!defined('_SPIP_AJAX')) { |
|
| 2915 | + define('_SPIP_AJAX', ((!isset($_COOKIE['spip_accepte_ajax'])) |
|
| 2916 | + ? 1 |
|
| 2917 | + : (($_COOKIE['spip_accepte_ajax'] != -1) ? 1 : 0))); |
|
| 2918 | + } |
|
| 2919 | + |
|
| 2920 | + // La requete est-elle en ajax ? |
|
| 2921 | + if (!defined('_AJAX')) { |
|
| 2922 | + define( |
|
| 2923 | + '_AJAX', |
|
| 2924 | + (isset($_SERVER['HTTP_X_REQUESTED_WITH']) # ajax jQuery |
|
| 2925 | + or !empty($_REQUEST['var_ajax_redir']) # redirection 302 apres ajax jQuery |
|
| 2926 | + or !empty($_REQUEST['var_ajaxcharset']) # compat ascendante pour plugins |
|
| 2927 | + or !empty($_REQUEST['var_ajax']) # forms ajax & inclure ajax de spip |
|
| 2928 | + ) |
|
| 2929 | + and empty($_REQUEST['var_noajax']) # horrible exception, car c'est pas parce que la requete est ajax jquery qu'il faut tuer tous les formulaires ajax qu'elle contient |
|
| 2930 | + ); |
|
| 2931 | + } |
|
| 2932 | + |
|
| 2933 | + # nombre de pixels maxi pour calcul de la vignette avec gd |
|
| 2934 | + # au dela de 5500000 on considere que php n'est pas limite en memoire pour cette operation |
|
| 2935 | + # les configurations limitees en memoire ont un seuil plutot vers 1MPixel |
|
| 2936 | + if (!defined('_IMG_GD_MAX_PIXELS')) { |
|
| 2937 | + define( |
|
| 2938 | + '_IMG_GD_MAX_PIXELS', |
|
| 2939 | + (isset($GLOBALS['meta']['max_taille_vignettes']) and $GLOBALS['meta']['max_taille_vignettes']) |
|
| 2940 | + ? $GLOBALS['meta']['max_taille_vignettes'] |
|
| 2941 | + : 0 |
|
| 2942 | + ); |
|
| 2943 | + } |
|
| 2944 | + |
|
| 2945 | + if (!defined('_MEMORY_LIMIT_MIN')) { |
|
| 2946 | + define('_MEMORY_LIMIT_MIN', 16); |
|
| 2947 | + } // en Mo |
|
| 2948 | + // si on est dans l'espace prive et si le besoin est superieur a 8Mo (qui est vraiment le standard) |
|
| 2949 | + // on verifie que la memoire est suffisante pour le compactage css+js pour eviter la page blanche |
|
| 2950 | + // il y aura d'autres problemes et l'utilisateur n'ira pas tres loin, mais ce sera plus comprehensible qu'une page blanche |
|
| 2951 | + if (test_espace_prive() and _MEMORY_LIMIT_MIN > 8) { |
|
| 2952 | + if ($memory = trim(ini_get('memory_limit')) and $memory != -1) { |
|
| 2953 | + $unit = strtolower(substr($memory, -1)); |
|
| 2954 | + $memory = substr($memory, 0, -1); |
|
| 2955 | + switch ($unit) { |
|
| 2956 | + // Le modifieur 'G' est disponible depuis PHP 5.1.0 |
|
| 2957 | + case 'g': |
|
| 2958 | + $memory *= 1024; |
|
| 2959 | + case 'm': |
|
| 2960 | + $memory *= 1024; |
|
| 2961 | + case 'k': |
|
| 2962 | + $memory *= 1024; |
|
| 2963 | + } |
|
| 2964 | + if ($memory < _MEMORY_LIMIT_MIN * 1024 * 1024) { |
|
| 2965 | + @ini_set('memory_limit', $m = _MEMORY_LIMIT_MIN . 'M'); |
|
| 2966 | + if (trim(ini_get('memory_limit')) != $m) { |
|
| 2967 | + if (!defined('_INTERDIRE_COMPACTE_HEAD_ECRIRE')) { |
|
| 2968 | + define('_INTERDIRE_COMPACTE_HEAD_ECRIRE', true); |
|
| 2969 | + } // evite une page blanche car on ne saura pas calculer la css dans ce hit |
|
| 2970 | + } |
|
| 2971 | + } |
|
| 2972 | + } else { |
|
| 2973 | + if (!defined('_INTERDIRE_COMPACTE_HEAD_ECRIRE')) { |
|
| 2974 | + define('_INTERDIRE_COMPACTE_HEAD_ECRIRE', true); |
|
| 2975 | + } |
|
| 2976 | + } // evite une page blanche car on ne saura pas calculer la css dans ce hit |
|
| 2977 | + } |
|
| 2978 | + // Protocoles a normaliser dans les chaines de langues |
|
| 2979 | + if (!defined('_PROTOCOLES_STD')) { |
|
| 2980 | + define('_PROTOCOLES_STD', 'http|https|ftp|mailto|webcal'); |
|
| 2981 | + } |
|
| 2982 | + |
|
| 2983 | + init_var_mode(); |
|
| 2985 | 2984 | } |
| 2986 | 2985 | |
| 2987 | 2986 | /** |
@@ -3015,219 +3014,219 @@ discard block |
||
| 3015 | 3014 | * ` var_mode` (calcul ou recalcul). |
| 3016 | 3015 | */ |
| 3017 | 3016 | function init_var_mode() { |
| 3018 | - static $done = false; |
|
| 3019 | - if (!$done) { |
|
| 3020 | - if (isset($_GET['var_mode'])) { |
|
| 3021 | - $var_mode = explode(',', $_GET['var_mode']); |
|
| 3022 | - // tout le monde peut calcul/recalcul |
|
| 3023 | - if (!defined('_VAR_MODE')) { |
|
| 3024 | - if (in_array('recalcul', $var_mode)) { |
|
| 3025 | - define('_VAR_MODE', 'recalcul'); |
|
| 3026 | - } elseif (in_array('calcul', $var_mode)) { |
|
| 3027 | - define('_VAR_MODE', 'calcul'); |
|
| 3028 | - } |
|
| 3029 | - } |
|
| 3030 | - $var_mode = array_diff($var_mode, ['calcul', 'recalcul']); |
|
| 3031 | - if ($var_mode) { |
|
| 3032 | - include_spip('inc/autoriser'); |
|
| 3033 | - // autoriser preview si preview seulement, et sinon autoriser debug |
|
| 3034 | - if ( |
|
| 3035 | - autoriser( |
|
| 3036 | - ($_GET['var_mode'] == 'preview') |
|
| 3037 | - ? 'previsualiser' |
|
| 3038 | - : 'debug' |
|
| 3039 | - ) |
|
| 3040 | - ) { |
|
| 3041 | - if (in_array('traduction', $var_mode)) { |
|
| 3042 | - // forcer le calcul pour passer dans traduire |
|
| 3043 | - if (!defined('_VAR_MODE')) { |
|
| 3044 | - define('_VAR_MODE', 'calcul'); |
|
| 3045 | - } |
|
| 3046 | - // et ne pas enregistrer de cache pour ne pas trainer les surlignages sur d'autres pages |
|
| 3047 | - if (!defined('_VAR_NOCACHE')) { |
|
| 3048 | - define('_VAR_NOCACHE', true); |
|
| 3049 | - } |
|
| 3050 | - $var_mode = array_diff($var_mode, ['traduction']); |
|
| 3051 | - } |
|
| 3052 | - if (in_array('preview', $var_mode)) { |
|
| 3053 | - // basculer sur les criteres de preview dans les boucles |
|
| 3054 | - if (!defined('_VAR_PREVIEW')) { |
|
| 3055 | - define('_VAR_PREVIEW', true); |
|
| 3056 | - } |
|
| 3057 | - // forcer le calcul |
|
| 3058 | - if (!defined('_VAR_MODE')) { |
|
| 3059 | - define('_VAR_MODE', 'calcul'); |
|
| 3060 | - } |
|
| 3061 | - // et ne pas enregistrer de cache |
|
| 3062 | - if (!defined('_VAR_NOCACHE')) { |
|
| 3063 | - define('_VAR_NOCACHE', true); |
|
| 3064 | - } |
|
| 3065 | - $var_mode = array_diff($var_mode, ['preview']); |
|
| 3066 | - } |
|
| 3067 | - if (in_array('inclure', $var_mode)) { |
|
| 3068 | - // forcer le compilo et ignorer les caches existants |
|
| 3069 | - if (!defined('_VAR_MODE')) { |
|
| 3070 | - define('_VAR_MODE', 'calcul'); |
|
| 3071 | - } |
|
| 3072 | - if (!defined('_VAR_INCLURE')) { |
|
| 3073 | - define('_VAR_INCLURE', true); |
|
| 3074 | - } |
|
| 3075 | - // et ne pas enregistrer de cache |
|
| 3076 | - if (!defined('_VAR_NOCACHE')) { |
|
| 3077 | - define('_VAR_NOCACHE', true); |
|
| 3078 | - } |
|
| 3079 | - $var_mode = array_diff($var_mode, ['inclure']); |
|
| 3080 | - } |
|
| 3081 | - if (in_array('urls', $var_mode)) { |
|
| 3082 | - // forcer le compilo et ignorer les caches existants |
|
| 3083 | - if (!defined('_VAR_MODE')) { |
|
| 3084 | - define('_VAR_MODE', 'calcul'); |
|
| 3085 | - } |
|
| 3086 | - if (!defined('_VAR_URLS')) { |
|
| 3087 | - define('_VAR_URLS', true); |
|
| 3088 | - } |
|
| 3089 | - $var_mode = array_diff($var_mode, ['urls']); |
|
| 3090 | - } |
|
| 3091 | - if (in_array('images', $var_mode)) { |
|
| 3092 | - // forcer le compilo et ignorer les caches existants |
|
| 3093 | - if (!defined('_VAR_MODE')) { |
|
| 3094 | - define('_VAR_MODE', 'calcul'); |
|
| 3095 | - } |
|
| 3096 | - // indiquer qu'on doit recalculer les images |
|
| 3097 | - if (!defined('_VAR_IMAGES')) { |
|
| 3098 | - define('_VAR_IMAGES', true); |
|
| 3099 | - } |
|
| 3100 | - $var_mode = array_diff($var_mode, ['images']); |
|
| 3101 | - } |
|
| 3102 | - if (in_array('debug', $var_mode)) { |
|
| 3103 | - if (!defined('_VAR_MODE')) { |
|
| 3104 | - define('_VAR_MODE', 'debug'); |
|
| 3105 | - } |
|
| 3106 | - // et ne pas enregistrer de cache |
|
| 3107 | - if (!defined('_VAR_NOCACHE')) { |
|
| 3108 | - define('_VAR_NOCACHE', true); |
|
| 3109 | - } |
|
| 3110 | - $var_mode = array_diff($var_mode, ['debug']); |
|
| 3111 | - } |
|
| 3112 | - if (count($var_mode) and !defined('_VAR_MODE')) { |
|
| 3113 | - define('_VAR_MODE', reset($var_mode)); |
|
| 3114 | - } |
|
| 3115 | - if (isset($GLOBALS['visiteur_session']['nom'])) { |
|
| 3116 | - spip_log($GLOBALS['visiteur_session']['nom'] |
|
| 3117 | - . ' ' . _VAR_MODE); |
|
| 3118 | - } |
|
| 3119 | - } // pas autorise ? |
|
| 3120 | - else { |
|
| 3121 | - // si on n'est pas connecte on se redirige, si on est pas en cli et pas deja en train de se loger |
|
| 3122 | - if ( |
|
| 3123 | - !$GLOBALS['visiteur_session'] |
|
| 3124 | - and !empty($_SERVER['HTTP_HOST']) |
|
| 3125 | - and !empty($_SERVER['REQUEST_METHOD']) |
|
| 3126 | - and $_SERVER['REQUEST_METHOD'] === 'GET' |
|
| 3127 | - ) { |
|
| 3128 | - $self = self('&', true); |
|
| 3129 | - if (strpos($self, 'page=login') === false) { |
|
| 3130 | - include_spip('inc/headers'); |
|
| 3131 | - $redirect = parametre_url(self('&', true), 'var_mode', $_GET['var_mode'], '&'); |
|
| 3132 | - redirige_par_entete(generer_url_public('login', 'url=' . rawurlencode($redirect), true)); |
|
| 3133 | - } |
|
| 3134 | - } |
|
| 3135 | - // sinon tant pis |
|
| 3136 | - } |
|
| 3137 | - } |
|
| 3138 | - } |
|
| 3139 | - if (!defined('_VAR_MODE')) { |
|
| 3140 | - /** |
|
| 3141 | - * Indique le mode de calcul ou d'affichage de la page. |
|
| 3142 | - * @see init_var_mode() |
|
| 3143 | - */ |
|
| 3144 | - define('_VAR_MODE', false); |
|
| 3145 | - } |
|
| 3146 | - $done = true; |
|
| 3147 | - } |
|
| 3017 | + static $done = false; |
|
| 3018 | + if (!$done) { |
|
| 3019 | + if (isset($_GET['var_mode'])) { |
|
| 3020 | + $var_mode = explode(',', $_GET['var_mode']); |
|
| 3021 | + // tout le monde peut calcul/recalcul |
|
| 3022 | + if (!defined('_VAR_MODE')) { |
|
| 3023 | + if (in_array('recalcul', $var_mode)) { |
|
| 3024 | + define('_VAR_MODE', 'recalcul'); |
|
| 3025 | + } elseif (in_array('calcul', $var_mode)) { |
|
| 3026 | + define('_VAR_MODE', 'calcul'); |
|
| 3027 | + } |
|
| 3028 | + } |
|
| 3029 | + $var_mode = array_diff($var_mode, ['calcul', 'recalcul']); |
|
| 3030 | + if ($var_mode) { |
|
| 3031 | + include_spip('inc/autoriser'); |
|
| 3032 | + // autoriser preview si preview seulement, et sinon autoriser debug |
|
| 3033 | + if ( |
|
| 3034 | + autoriser( |
|
| 3035 | + ($_GET['var_mode'] == 'preview') |
|
| 3036 | + ? 'previsualiser' |
|
| 3037 | + : 'debug' |
|
| 3038 | + ) |
|
| 3039 | + ) { |
|
| 3040 | + if (in_array('traduction', $var_mode)) { |
|
| 3041 | + // forcer le calcul pour passer dans traduire |
|
| 3042 | + if (!defined('_VAR_MODE')) { |
|
| 3043 | + define('_VAR_MODE', 'calcul'); |
|
| 3044 | + } |
|
| 3045 | + // et ne pas enregistrer de cache pour ne pas trainer les surlignages sur d'autres pages |
|
| 3046 | + if (!defined('_VAR_NOCACHE')) { |
|
| 3047 | + define('_VAR_NOCACHE', true); |
|
| 3048 | + } |
|
| 3049 | + $var_mode = array_diff($var_mode, ['traduction']); |
|
| 3050 | + } |
|
| 3051 | + if (in_array('preview', $var_mode)) { |
|
| 3052 | + // basculer sur les criteres de preview dans les boucles |
|
| 3053 | + if (!defined('_VAR_PREVIEW')) { |
|
| 3054 | + define('_VAR_PREVIEW', true); |
|
| 3055 | + } |
|
| 3056 | + // forcer le calcul |
|
| 3057 | + if (!defined('_VAR_MODE')) { |
|
| 3058 | + define('_VAR_MODE', 'calcul'); |
|
| 3059 | + } |
|
| 3060 | + // et ne pas enregistrer de cache |
|
| 3061 | + if (!defined('_VAR_NOCACHE')) { |
|
| 3062 | + define('_VAR_NOCACHE', true); |
|
| 3063 | + } |
|
| 3064 | + $var_mode = array_diff($var_mode, ['preview']); |
|
| 3065 | + } |
|
| 3066 | + if (in_array('inclure', $var_mode)) { |
|
| 3067 | + // forcer le compilo et ignorer les caches existants |
|
| 3068 | + if (!defined('_VAR_MODE')) { |
|
| 3069 | + define('_VAR_MODE', 'calcul'); |
|
| 3070 | + } |
|
| 3071 | + if (!defined('_VAR_INCLURE')) { |
|
| 3072 | + define('_VAR_INCLURE', true); |
|
| 3073 | + } |
|
| 3074 | + // et ne pas enregistrer de cache |
|
| 3075 | + if (!defined('_VAR_NOCACHE')) { |
|
| 3076 | + define('_VAR_NOCACHE', true); |
|
| 3077 | + } |
|
| 3078 | + $var_mode = array_diff($var_mode, ['inclure']); |
|
| 3079 | + } |
|
| 3080 | + if (in_array('urls', $var_mode)) { |
|
| 3081 | + // forcer le compilo et ignorer les caches existants |
|
| 3082 | + if (!defined('_VAR_MODE')) { |
|
| 3083 | + define('_VAR_MODE', 'calcul'); |
|
| 3084 | + } |
|
| 3085 | + if (!defined('_VAR_URLS')) { |
|
| 3086 | + define('_VAR_URLS', true); |
|
| 3087 | + } |
|
| 3088 | + $var_mode = array_diff($var_mode, ['urls']); |
|
| 3089 | + } |
|
| 3090 | + if (in_array('images', $var_mode)) { |
|
| 3091 | + // forcer le compilo et ignorer les caches existants |
|
| 3092 | + if (!defined('_VAR_MODE')) { |
|
| 3093 | + define('_VAR_MODE', 'calcul'); |
|
| 3094 | + } |
|
| 3095 | + // indiquer qu'on doit recalculer les images |
|
| 3096 | + if (!defined('_VAR_IMAGES')) { |
|
| 3097 | + define('_VAR_IMAGES', true); |
|
| 3098 | + } |
|
| 3099 | + $var_mode = array_diff($var_mode, ['images']); |
|
| 3100 | + } |
|
| 3101 | + if (in_array('debug', $var_mode)) { |
|
| 3102 | + if (!defined('_VAR_MODE')) { |
|
| 3103 | + define('_VAR_MODE', 'debug'); |
|
| 3104 | + } |
|
| 3105 | + // et ne pas enregistrer de cache |
|
| 3106 | + if (!defined('_VAR_NOCACHE')) { |
|
| 3107 | + define('_VAR_NOCACHE', true); |
|
| 3108 | + } |
|
| 3109 | + $var_mode = array_diff($var_mode, ['debug']); |
|
| 3110 | + } |
|
| 3111 | + if (count($var_mode) and !defined('_VAR_MODE')) { |
|
| 3112 | + define('_VAR_MODE', reset($var_mode)); |
|
| 3113 | + } |
|
| 3114 | + if (isset($GLOBALS['visiteur_session']['nom'])) { |
|
| 3115 | + spip_log($GLOBALS['visiteur_session']['nom'] |
|
| 3116 | + . ' ' . _VAR_MODE); |
|
| 3117 | + } |
|
| 3118 | + } // pas autorise ? |
|
| 3119 | + else { |
|
| 3120 | + // si on n'est pas connecte on se redirige, si on est pas en cli et pas deja en train de se loger |
|
| 3121 | + if ( |
|
| 3122 | + !$GLOBALS['visiteur_session'] |
|
| 3123 | + and !empty($_SERVER['HTTP_HOST']) |
|
| 3124 | + and !empty($_SERVER['REQUEST_METHOD']) |
|
| 3125 | + and $_SERVER['REQUEST_METHOD'] === 'GET' |
|
| 3126 | + ) { |
|
| 3127 | + $self = self('&', true); |
|
| 3128 | + if (strpos($self, 'page=login') === false) { |
|
| 3129 | + include_spip('inc/headers'); |
|
| 3130 | + $redirect = parametre_url(self('&', true), 'var_mode', $_GET['var_mode'], '&'); |
|
| 3131 | + redirige_par_entete(generer_url_public('login', 'url=' . rawurlencode($redirect), true)); |
|
| 3132 | + } |
|
| 3133 | + } |
|
| 3134 | + // sinon tant pis |
|
| 3135 | + } |
|
| 3136 | + } |
|
| 3137 | + } |
|
| 3138 | + if (!defined('_VAR_MODE')) { |
|
| 3139 | + /** |
|
| 3140 | + * Indique le mode de calcul ou d'affichage de la page. |
|
| 3141 | + * @see init_var_mode() |
|
| 3142 | + */ |
|
| 3143 | + define('_VAR_MODE', false); |
|
| 3144 | + } |
|
| 3145 | + $done = true; |
|
| 3146 | + } |
|
| 3148 | 3147 | } |
| 3149 | 3148 | |
| 3150 | 3149 | // Annuler les magic quotes \' sur GET POST COOKIE et GLOBALS ; |
| 3151 | 3150 | // supprimer aussi les eventuels caracteres nuls %00, qui peuvent tromper |
| 3152 | 3151 | // la commande is_readable('chemin/vers/fichier/interdit%00truc_normal') |
| 3153 | 3152 | function spip_desinfecte(&$t, $deep = true) { |
| 3154 | - foreach ($t as $key => $val) { |
|
| 3155 | - if (is_string($t[$key])) { |
|
| 3156 | - $t[$key] = str_replace(chr(0), '-', $t[$key]); |
|
| 3157 | - } // traiter aussi les "texte_plus" de article_edit |
|
| 3158 | - else { |
|
| 3159 | - if ($deep and is_array($t[$key]) and $key !== 'GLOBALS') { |
|
| 3160 | - spip_desinfecte($t[$key], $deep); |
|
| 3161 | - } |
|
| 3162 | - } |
|
| 3163 | - } |
|
| 3153 | + foreach ($t as $key => $val) { |
|
| 3154 | + if (is_string($t[$key])) { |
|
| 3155 | + $t[$key] = str_replace(chr(0), '-', $t[$key]); |
|
| 3156 | + } // traiter aussi les "texte_plus" de article_edit |
|
| 3157 | + else { |
|
| 3158 | + if ($deep and is_array($t[$key]) and $key !== 'GLOBALS') { |
|
| 3159 | + spip_desinfecte($t[$key], $deep); |
|
| 3160 | + } |
|
| 3161 | + } |
|
| 3162 | + } |
|
| 3164 | 3163 | } |
| 3165 | 3164 | |
| 3166 | 3165 | // retourne le statut du visiteur s'il s'annonce |
| 3167 | 3166 | |
| 3168 | 3167 | function verifier_visiteur() { |
| 3169 | - // Rq: pour que cette fonction marche depuis mes_options |
|
| 3170 | - // il faut forcer l'init si ce n'est fait |
|
| 3171 | - // mais on risque de perturber des plugins en initialisant trop tot |
|
| 3172 | - // certaines constantes |
|
| 3173 | - @spip_initialisation_core( |
|
| 3174 | - (_DIR_RACINE . _NOM_PERMANENTS_INACCESSIBLES), |
|
| 3175 | - (_DIR_RACINE . _NOM_PERMANENTS_ACCESSIBLES), |
|
| 3176 | - (_DIR_RACINE . _NOM_TEMPORAIRES_INACCESSIBLES), |
|
| 3177 | - (_DIR_RACINE . _NOM_TEMPORAIRES_ACCESSIBLES) |
|
| 3178 | - ); |
|
| 3179 | - |
|
| 3180 | - // Demarrer une session NON AUTHENTIFIEE si on donne son nom |
|
| 3181 | - // dans un formulaire sans login (ex: #FORMULAIRE_FORUM) |
|
| 3182 | - // Attention on separe bien session_nom et nom, pour eviter |
|
| 3183 | - // les melanges entre donnees SQL et variables plus aleatoires |
|
| 3184 | - $variables_session = ['session_nom', 'session_email']; |
|
| 3185 | - foreach ($variables_session as $var) { |
|
| 3186 | - if (_request($var) !== null) { |
|
| 3187 | - $init = true; |
|
| 3188 | - break; |
|
| 3189 | - } |
|
| 3190 | - } |
|
| 3191 | - if (isset($init)) { |
|
| 3192 | - #@spip_initialisation_suite(); |
|
| 3193 | - $session = charger_fonction('session', 'inc'); |
|
| 3194 | - $session(); |
|
| 3195 | - include_spip('inc/texte'); |
|
| 3196 | - foreach ($variables_session as $var) { |
|
| 3197 | - if (($a = _request($var)) !== null) { |
|
| 3198 | - $GLOBALS['visiteur_session'][$var] = safehtml($a); |
|
| 3199 | - } |
|
| 3200 | - } |
|
| 3201 | - if (!isset($GLOBALS['visiteur_session']['id_auteur'])) { |
|
| 3202 | - $GLOBALS['visiteur_session']['id_auteur'] = 0; |
|
| 3203 | - } |
|
| 3204 | - $session($GLOBALS['visiteur_session']); |
|
| 3205 | - |
|
| 3206 | - return 0; |
|
| 3207 | - } |
|
| 3208 | - |
|
| 3209 | - $h = (isset($_SERVER['PHP_AUTH_USER']) and !$GLOBALS['ignore_auth_http']); |
|
| 3210 | - if ($h or isset($_COOKIE['spip_session']) or isset($_COOKIE[$GLOBALS['cookie_prefix'] . '_session'])) { |
|
| 3211 | - $session = charger_fonction('session', 'inc'); |
|
| 3212 | - if ($session()) { |
|
| 3213 | - return $GLOBALS['visiteur_session']['statut']; |
|
| 3214 | - } |
|
| 3215 | - if ($h and isset($_SERVER['PHP_AUTH_PW'])) { |
|
| 3216 | - include_spip('inc/auth'); |
|
| 3217 | - $h = lire_php_auth($_SERVER['PHP_AUTH_USER'], $_SERVER['PHP_AUTH_PW']); |
|
| 3218 | - } |
|
| 3219 | - if ($h) { |
|
| 3220 | - $GLOBALS['visiteur_session'] = $h; |
|
| 3221 | - |
|
| 3222 | - return $GLOBALS['visiteur_session']['statut']; |
|
| 3223 | - } |
|
| 3224 | - } |
|
| 3225 | - |
|
| 3226 | - // au moins son navigateur nous dit la langue preferee de cet inconnu |
|
| 3227 | - include_spip('inc/lang'); |
|
| 3228 | - utiliser_langue_visiteur(); |
|
| 3229 | - |
|
| 3230 | - return false; |
|
| 3168 | + // Rq: pour que cette fonction marche depuis mes_options |
|
| 3169 | + // il faut forcer l'init si ce n'est fait |
|
| 3170 | + // mais on risque de perturber des plugins en initialisant trop tot |
|
| 3171 | + // certaines constantes |
|
| 3172 | + @spip_initialisation_core( |
|
| 3173 | + (_DIR_RACINE . _NOM_PERMANENTS_INACCESSIBLES), |
|
| 3174 | + (_DIR_RACINE . _NOM_PERMANENTS_ACCESSIBLES), |
|
| 3175 | + (_DIR_RACINE . _NOM_TEMPORAIRES_INACCESSIBLES), |
|
| 3176 | + (_DIR_RACINE . _NOM_TEMPORAIRES_ACCESSIBLES) |
|
| 3177 | + ); |
|
| 3178 | + |
|
| 3179 | + // Demarrer une session NON AUTHENTIFIEE si on donne son nom |
|
| 3180 | + // dans un formulaire sans login (ex: #FORMULAIRE_FORUM) |
|
| 3181 | + // Attention on separe bien session_nom et nom, pour eviter |
|
| 3182 | + // les melanges entre donnees SQL et variables plus aleatoires |
|
| 3183 | + $variables_session = ['session_nom', 'session_email']; |
|
| 3184 | + foreach ($variables_session as $var) { |
|
| 3185 | + if (_request($var) !== null) { |
|
| 3186 | + $init = true; |
|
| 3187 | + break; |
|
| 3188 | + } |
|
| 3189 | + } |
|
| 3190 | + if (isset($init)) { |
|
| 3191 | + #@spip_initialisation_suite(); |
|
| 3192 | + $session = charger_fonction('session', 'inc'); |
|
| 3193 | + $session(); |
|
| 3194 | + include_spip('inc/texte'); |
|
| 3195 | + foreach ($variables_session as $var) { |
|
| 3196 | + if (($a = _request($var)) !== null) { |
|
| 3197 | + $GLOBALS['visiteur_session'][$var] = safehtml($a); |
|
| 3198 | + } |
|
| 3199 | + } |
|
| 3200 | + if (!isset($GLOBALS['visiteur_session']['id_auteur'])) { |
|
| 3201 | + $GLOBALS['visiteur_session']['id_auteur'] = 0; |
|
| 3202 | + } |
|
| 3203 | + $session($GLOBALS['visiteur_session']); |
|
| 3204 | + |
|
| 3205 | + return 0; |
|
| 3206 | + } |
|
| 3207 | + |
|
| 3208 | + $h = (isset($_SERVER['PHP_AUTH_USER']) and !$GLOBALS['ignore_auth_http']); |
|
| 3209 | + if ($h or isset($_COOKIE['spip_session']) or isset($_COOKIE[$GLOBALS['cookie_prefix'] . '_session'])) { |
|
| 3210 | + $session = charger_fonction('session', 'inc'); |
|
| 3211 | + if ($session()) { |
|
| 3212 | + return $GLOBALS['visiteur_session']['statut']; |
|
| 3213 | + } |
|
| 3214 | + if ($h and isset($_SERVER['PHP_AUTH_PW'])) { |
|
| 3215 | + include_spip('inc/auth'); |
|
| 3216 | + $h = lire_php_auth($_SERVER['PHP_AUTH_USER'], $_SERVER['PHP_AUTH_PW']); |
|
| 3217 | + } |
|
| 3218 | + if ($h) { |
|
| 3219 | + $GLOBALS['visiteur_session'] = $h; |
|
| 3220 | + |
|
| 3221 | + return $GLOBALS['visiteur_session']['statut']; |
|
| 3222 | + } |
|
| 3223 | + } |
|
| 3224 | + |
|
| 3225 | + // au moins son navigateur nous dit la langue preferee de cet inconnu |
|
| 3226 | + include_spip('inc/lang'); |
|
| 3227 | + utiliser_langue_visiteur(); |
|
| 3228 | + |
|
| 3229 | + return false; |
|
| 3231 | 3230 | } |
| 3232 | 3231 | |
| 3233 | 3232 | |
@@ -3250,21 +3249,21 @@ discard block |
||
| 3250 | 3249 | * - string Langue utilisée. |
| 3251 | 3250 | **/ |
| 3252 | 3251 | function lang_select($lang = null) { |
| 3253 | - static $pile_langues = []; |
|
| 3254 | - if (!function_exists('changer_langue')) { |
|
| 3255 | - include_spip('inc/lang'); |
|
| 3256 | - } |
|
| 3257 | - if ($lang === null) { |
|
| 3258 | - $lang = array_pop($pile_langues); |
|
| 3259 | - } else { |
|
| 3260 | - array_push($pile_langues, $GLOBALS['spip_lang']); |
|
| 3261 | - } |
|
| 3262 | - if (isset($GLOBALS['spip_lang']) and $lang == $GLOBALS['spip_lang']) { |
|
| 3263 | - return $lang; |
|
| 3264 | - } |
|
| 3265 | - changer_langue($lang); |
|
| 3252 | + static $pile_langues = []; |
|
| 3253 | + if (!function_exists('changer_langue')) { |
|
| 3254 | + include_spip('inc/lang'); |
|
| 3255 | + } |
|
| 3256 | + if ($lang === null) { |
|
| 3257 | + $lang = array_pop($pile_langues); |
|
| 3258 | + } else { |
|
| 3259 | + array_push($pile_langues, $GLOBALS['spip_lang']); |
|
| 3260 | + } |
|
| 3261 | + if (isset($GLOBALS['spip_lang']) and $lang == $GLOBALS['spip_lang']) { |
|
| 3262 | + return $lang; |
|
| 3263 | + } |
|
| 3264 | + changer_langue($lang); |
|
| 3266 | 3265 | |
| 3267 | - return $lang; |
|
| 3266 | + return $lang; |
|
| 3268 | 3267 | } |
| 3269 | 3268 | |
| 3270 | 3269 | /** |
@@ -3281,20 +3280,20 @@ discard block |
||
| 3281 | 3280 | * Identifiant de la session |
| 3282 | 3281 | **/ |
| 3283 | 3282 | function spip_session($force = false) { |
| 3284 | - static $session; |
|
| 3285 | - if ($force or !isset($session)) { |
|
| 3286 | - $s = pipeline( |
|
| 3287 | - 'definir_session', |
|
| 3288 | - $GLOBALS['visiteur_session'] |
|
| 3289 | - ? serialize($GLOBALS['visiteur_session']) |
|
| 3290 | - . '_' . @$_COOKIE['spip_session'] |
|
| 3291 | - : '' |
|
| 3292 | - ); |
|
| 3293 | - $session = $s ? substr(md5($s), 0, 8) : ''; |
|
| 3294 | - } |
|
| 3283 | + static $session; |
|
| 3284 | + if ($force or !isset($session)) { |
|
| 3285 | + $s = pipeline( |
|
| 3286 | + 'definir_session', |
|
| 3287 | + $GLOBALS['visiteur_session'] |
|
| 3288 | + ? serialize($GLOBALS['visiteur_session']) |
|
| 3289 | + . '_' . @$_COOKIE['spip_session'] |
|
| 3290 | + : '' |
|
| 3291 | + ); |
|
| 3292 | + $session = $s ? substr(md5($s), 0, 8) : ''; |
|
| 3293 | + } |
|
| 3295 | 3294 | |
| 3296 | - #spip_log('session: '.$session); |
|
| 3297 | - return $session; |
|
| 3295 | + #spip_log('session: '.$session); |
|
| 3296 | + return $session; |
|
| 3298 | 3297 | } |
| 3299 | 3298 | |
| 3300 | 3299 | |
@@ -3313,9 +3312,9 @@ discard block |
||
| 3313 | 3312 | * Lien sur une icone d'aide |
| 3314 | 3313 | **/ |
| 3315 | 3314 | function aider($aide = '', $distante = false) { |
| 3316 | - $aider = charger_fonction('aide', 'inc', true); |
|
| 3315 | + $aider = charger_fonction('aide', 'inc', true); |
|
| 3317 | 3316 | |
| 3318 | - return $aider ? $aider($aide, '', [], $distante) : ''; |
|
| 3317 | + return $aider ? $aider($aide, '', [], $distante) : ''; |
|
| 3319 | 3318 | } |
| 3320 | 3319 | |
| 3321 | 3320 | /** |
@@ -3325,24 +3324,24 @@ discard block |
||
| 3325 | 3324 | */ |
| 3326 | 3325 | function exec_info_dist() { |
| 3327 | 3326 | |
| 3328 | - include_spip('inc/autoriser'); |
|
| 3329 | - if (autoriser('phpinfos')) { |
|
| 3330 | - $cookies_masques = ['spip_session', 'PHPSESSID']; |
|
| 3331 | - $cookies_backup = []; |
|
| 3332 | - foreach ($cookies_masques as $k) { |
|
| 3333 | - if (!empty($_COOKIE[$k])) { |
|
| 3334 | - $cookies_backup[$k] = $_COOKIE[$k]; |
|
| 3335 | - $_COOKIE[$k] = '******************************'; |
|
| 3336 | - } |
|
| 3337 | - } |
|
| 3338 | - phpinfo(); |
|
| 3339 | - foreach ($cookies_backup as $k => $v) { |
|
| 3340 | - $_COOKIE[$k] = $v; |
|
| 3341 | - } |
|
| 3342 | - } else { |
|
| 3343 | - include_spip('inc/filtres'); |
|
| 3344 | - sinon_interdire_acces(); |
|
| 3345 | - } |
|
| 3327 | + include_spip('inc/autoriser'); |
|
| 3328 | + if (autoriser('phpinfos')) { |
|
| 3329 | + $cookies_masques = ['spip_session', 'PHPSESSID']; |
|
| 3330 | + $cookies_backup = []; |
|
| 3331 | + foreach ($cookies_masques as $k) { |
|
| 3332 | + if (!empty($_COOKIE[$k])) { |
|
| 3333 | + $cookies_backup[$k] = $_COOKIE[$k]; |
|
| 3334 | + $_COOKIE[$k] = '******************************'; |
|
| 3335 | + } |
|
| 3336 | + } |
|
| 3337 | + phpinfo(); |
|
| 3338 | + foreach ($cookies_backup as $k => $v) { |
|
| 3339 | + $_COOKIE[$k] = $v; |
|
| 3340 | + } |
|
| 3341 | + } else { |
|
| 3342 | + include_spip('inc/filtres'); |
|
| 3343 | + sinon_interdire_acces(); |
|
| 3344 | + } |
|
| 3346 | 3345 | } |
| 3347 | 3346 | |
| 3348 | 3347 | /** |
@@ -3362,13 +3361,13 @@ discard block |
||
| 3362 | 3361 | * - string si $message à false. |
| 3363 | 3362 | **/ |
| 3364 | 3363 | function erreur_squelette($message = '', $lieu = '') { |
| 3365 | - $debusquer = charger_fonction('debusquer', 'public'); |
|
| 3366 | - if (is_array($lieu)) { |
|
| 3367 | - include_spip('public/compiler'); |
|
| 3368 | - $lieu = reconstruire_contexte_compil($lieu); |
|
| 3369 | - } |
|
| 3364 | + $debusquer = charger_fonction('debusquer', 'public'); |
|
| 3365 | + if (is_array($lieu)) { |
|
| 3366 | + include_spip('public/compiler'); |
|
| 3367 | + $lieu = reconstruire_contexte_compil($lieu); |
|
| 3368 | + } |
|
| 3370 | 3369 | |
| 3371 | - return $debusquer($message, $lieu); |
|
| 3370 | + return $debusquer($message, $lieu); |
|
| 3372 | 3371 | } |
| 3373 | 3372 | |
| 3374 | 3373 | /** |
@@ -3405,108 +3404,108 @@ discard block |
||
| 3405 | 3404 | * - ou tableau d'information sur le squelette. |
| 3406 | 3405 | */ |
| 3407 | 3406 | function recuperer_fond($fond, $contexte = [], $options = [], string $connect = '') { |
| 3408 | - if (!function_exists('evaluer_fond')) { |
|
| 3409 | - include_spip('public/assembler'); |
|
| 3410 | - } |
|
| 3411 | - // assurer la compat avec l'ancienne syntaxe |
|
| 3412 | - // (trim etait le 3eme argument, par defaut a true) |
|
| 3413 | - if (!is_array($options)) { |
|
| 3414 | - $options = ['trim' => $options]; |
|
| 3415 | - } |
|
| 3416 | - if (!isset($options['trim'])) { |
|
| 3417 | - $options['trim'] = true; |
|
| 3418 | - } |
|
| 3419 | - |
|
| 3420 | - if (isset($contexte['connect'])) { |
|
| 3421 | - $connect = $contexte['connect']; |
|
| 3422 | - unset($contexte['connect']); |
|
| 3423 | - } |
|
| 3424 | - |
|
| 3425 | - $texte = ''; |
|
| 3426 | - $pages = []; |
|
| 3427 | - $lang_select = ''; |
|
| 3428 | - if (!isset($options['etoile']) or !$options['etoile']) { |
|
| 3429 | - // Si on a inclus sans fixer le critere de lang, on prend la langue courante |
|
| 3430 | - if (!isset($contexte['lang'])) { |
|
| 3431 | - $contexte['lang'] = $GLOBALS['spip_lang']; |
|
| 3432 | - } |
|
| 3433 | - |
|
| 3434 | - if ($contexte['lang'] != $GLOBALS['meta']['langue_site']) { |
|
| 3435 | - $lang_select = lang_select($contexte['lang']); |
|
| 3436 | - } |
|
| 3437 | - } |
|
| 3438 | - |
|
| 3439 | - if (!isset($GLOBALS['_INC_PUBLIC'])) { |
|
| 3440 | - $GLOBALS['_INC_PUBLIC'] = 0; |
|
| 3441 | - } |
|
| 3442 | - |
|
| 3443 | - $GLOBALS['_INC_PUBLIC']++; |
|
| 3444 | - |
|
| 3445 | - // fix #4235 |
|
| 3446 | - $cache_utilise_session_appelant = ($GLOBALS['cache_utilise_session'] ?? null); |
|
| 3447 | - |
|
| 3448 | - |
|
| 3449 | - foreach (is_array($fond) ? $fond : [$fond] as $f) { |
|
| 3450 | - unset($GLOBALS['cache_utilise_session']); // fix #4235 |
|
| 3451 | - |
|
| 3452 | - $page = evaluer_fond($f, $contexte, $connect); |
|
| 3453 | - if ($page === '') { |
|
| 3454 | - $c = $options['compil'] ?? ''; |
|
| 3455 | - $a = ['fichier' => $f]; |
|
| 3456 | - $erreur = _T('info_erreur_squelette2', $a); // squelette introuvable |
|
| 3457 | - erreur_squelette($erreur, $c); |
|
| 3458 | - // eviter des erreurs strictes ensuite sur $page['cle'] en PHP >= 5.4 |
|
| 3459 | - $page = ['texte' => '', 'erreur' => $erreur]; |
|
| 3460 | - } |
|
| 3461 | - |
|
| 3462 | - $page = pipeline('recuperer_fond', [ |
|
| 3463 | - 'args' => ['fond' => $f, 'contexte' => $contexte, 'options' => $options, 'connect' => $connect], |
|
| 3464 | - 'data' => $page |
|
| 3465 | - ]); |
|
| 3466 | - if (isset($options['ajax']) and $options['ajax']) { |
|
| 3467 | - if (!function_exists('encoder_contexte_ajax')) { |
|
| 3468 | - include_spip('inc/filtres'); |
|
| 3469 | - } |
|
| 3470 | - $page['texte'] = encoder_contexte_ajax( |
|
| 3471 | - array_merge( |
|
| 3472 | - $contexte, |
|
| 3473 | - ['fond' => $f], |
|
| 3474 | - ($connect ? ['connect' => $connect] : []) |
|
| 3475 | - ), |
|
| 3476 | - '', |
|
| 3477 | - $page['texte'], |
|
| 3478 | - $options['ajax'] |
|
| 3479 | - ); |
|
| 3480 | - } |
|
| 3481 | - |
|
| 3482 | - if (isset($options['raw']) and $options['raw']) { |
|
| 3483 | - $pages[] = $page; |
|
| 3484 | - } else { |
|
| 3485 | - $texte .= $options['trim'] ? rtrim($page['texte']) : $page['texte']; |
|
| 3486 | - } |
|
| 3487 | - |
|
| 3488 | - // contamination de la session appelante, pour les inclusions statiques |
|
| 3489 | - if (isset($page['invalideurs']['session'])) { |
|
| 3490 | - $cache_utilise_session_appelant = $page['invalideurs']['session']; |
|
| 3491 | - } |
|
| 3492 | - } |
|
| 3493 | - |
|
| 3494 | - // restaurer le sessionnement du contexte appelant, |
|
| 3495 | - // éventuellement contaminé si on vient de récupérer une inclusion statique sessionnée |
|
| 3496 | - if (isset($cache_utilise_session_appelant)) { |
|
| 3497 | - $GLOBALS['cache_utilise_session'] = $cache_utilise_session_appelant; |
|
| 3498 | - } |
|
| 3499 | - |
|
| 3500 | - $GLOBALS['_INC_PUBLIC']--; |
|
| 3501 | - |
|
| 3502 | - if ($lang_select) { |
|
| 3503 | - lang_select(); |
|
| 3504 | - } |
|
| 3505 | - if (isset($options['raw']) and $options['raw']) { |
|
| 3506 | - return is_array($fond) ? $pages : reset($pages); |
|
| 3507 | - } else { |
|
| 3508 | - return $options['trim'] ? ltrim($texte) : $texte; |
|
| 3509 | - } |
|
| 3407 | + if (!function_exists('evaluer_fond')) { |
|
| 3408 | + include_spip('public/assembler'); |
|
| 3409 | + } |
|
| 3410 | + // assurer la compat avec l'ancienne syntaxe |
|
| 3411 | + // (trim etait le 3eme argument, par defaut a true) |
|
| 3412 | + if (!is_array($options)) { |
|
| 3413 | + $options = ['trim' => $options]; |
|
| 3414 | + } |
|
| 3415 | + if (!isset($options['trim'])) { |
|
| 3416 | + $options['trim'] = true; |
|
| 3417 | + } |
|
| 3418 | + |
|
| 3419 | + if (isset($contexte['connect'])) { |
|
| 3420 | + $connect = $contexte['connect']; |
|
| 3421 | + unset($contexte['connect']); |
|
| 3422 | + } |
|
| 3423 | + |
|
| 3424 | + $texte = ''; |
|
| 3425 | + $pages = []; |
|
| 3426 | + $lang_select = ''; |
|
| 3427 | + if (!isset($options['etoile']) or !$options['etoile']) { |
|
| 3428 | + // Si on a inclus sans fixer le critere de lang, on prend la langue courante |
|
| 3429 | + if (!isset($contexte['lang'])) { |
|
| 3430 | + $contexte['lang'] = $GLOBALS['spip_lang']; |
|
| 3431 | + } |
|
| 3432 | + |
|
| 3433 | + if ($contexte['lang'] != $GLOBALS['meta']['langue_site']) { |
|
| 3434 | + $lang_select = lang_select($contexte['lang']); |
|
| 3435 | + } |
|
| 3436 | + } |
|
| 3437 | + |
|
| 3438 | + if (!isset($GLOBALS['_INC_PUBLIC'])) { |
|
| 3439 | + $GLOBALS['_INC_PUBLIC'] = 0; |
|
| 3440 | + } |
|
| 3441 | + |
|
| 3442 | + $GLOBALS['_INC_PUBLIC']++; |
|
| 3443 | + |
|
| 3444 | + // fix #4235 |
|
| 3445 | + $cache_utilise_session_appelant = ($GLOBALS['cache_utilise_session'] ?? null); |
|
| 3446 | + |
|
| 3447 | + |
|
| 3448 | + foreach (is_array($fond) ? $fond : [$fond] as $f) { |
|
| 3449 | + unset($GLOBALS['cache_utilise_session']); // fix #4235 |
|
| 3450 | + |
|
| 3451 | + $page = evaluer_fond($f, $contexte, $connect); |
|
| 3452 | + if ($page === '') { |
|
| 3453 | + $c = $options['compil'] ?? ''; |
|
| 3454 | + $a = ['fichier' => $f]; |
|
| 3455 | + $erreur = _T('info_erreur_squelette2', $a); // squelette introuvable |
|
| 3456 | + erreur_squelette($erreur, $c); |
|
| 3457 | + // eviter des erreurs strictes ensuite sur $page['cle'] en PHP >= 5.4 |
|
| 3458 | + $page = ['texte' => '', 'erreur' => $erreur]; |
|
| 3459 | + } |
|
| 3460 | + |
|
| 3461 | + $page = pipeline('recuperer_fond', [ |
|
| 3462 | + 'args' => ['fond' => $f, 'contexte' => $contexte, 'options' => $options, 'connect' => $connect], |
|
| 3463 | + 'data' => $page |
|
| 3464 | + ]); |
|
| 3465 | + if (isset($options['ajax']) and $options['ajax']) { |
|
| 3466 | + if (!function_exists('encoder_contexte_ajax')) { |
|
| 3467 | + include_spip('inc/filtres'); |
|
| 3468 | + } |
|
| 3469 | + $page['texte'] = encoder_contexte_ajax( |
|
| 3470 | + array_merge( |
|
| 3471 | + $contexte, |
|
| 3472 | + ['fond' => $f], |
|
| 3473 | + ($connect ? ['connect' => $connect] : []) |
|
| 3474 | + ), |
|
| 3475 | + '', |
|
| 3476 | + $page['texte'], |
|
| 3477 | + $options['ajax'] |
|
| 3478 | + ); |
|
| 3479 | + } |
|
| 3480 | + |
|
| 3481 | + if (isset($options['raw']) and $options['raw']) { |
|
| 3482 | + $pages[] = $page; |
|
| 3483 | + } else { |
|
| 3484 | + $texte .= $options['trim'] ? rtrim($page['texte']) : $page['texte']; |
|
| 3485 | + } |
|
| 3486 | + |
|
| 3487 | + // contamination de la session appelante, pour les inclusions statiques |
|
| 3488 | + if (isset($page['invalideurs']['session'])) { |
|
| 3489 | + $cache_utilise_session_appelant = $page['invalideurs']['session']; |
|
| 3490 | + } |
|
| 3491 | + } |
|
| 3492 | + |
|
| 3493 | + // restaurer le sessionnement du contexte appelant, |
|
| 3494 | + // éventuellement contaminé si on vient de récupérer une inclusion statique sessionnée |
|
| 3495 | + if (isset($cache_utilise_session_appelant)) { |
|
| 3496 | + $GLOBALS['cache_utilise_session'] = $cache_utilise_session_appelant; |
|
| 3497 | + } |
|
| 3498 | + |
|
| 3499 | + $GLOBALS['_INC_PUBLIC']--; |
|
| 3500 | + |
|
| 3501 | + if ($lang_select) { |
|
| 3502 | + lang_select(); |
|
| 3503 | + } |
|
| 3504 | + if (isset($options['raw']) and $options['raw']) { |
|
| 3505 | + return is_array($fond) ? $pages : reset($pages); |
|
| 3506 | + } else { |
|
| 3507 | + return $options['trim'] ? ltrim($texte) : $texte; |
|
| 3508 | + } |
|
| 3510 | 3509 | } |
| 3511 | 3510 | |
| 3512 | 3511 | /** |
@@ -3516,7 +3515,7 @@ discard block |
||
| 3516 | 3515 | * @return string |
| 3517 | 3516 | */ |
| 3518 | 3517 | function trouve_modele($nom) { |
| 3519 | - return trouver_fond($nom, 'modeles/'); |
|
| 3518 | + return trouver_fond($nom, 'modeles/'); |
|
| 3520 | 3519 | } |
| 3521 | 3520 | |
| 3522 | 3521 | /** |
@@ -3532,21 +3531,21 @@ discard block |
||
| 3532 | 3531 | * @return array|string |
| 3533 | 3532 | */ |
| 3534 | 3533 | function trouver_fond($nom, $dir = '', $pathinfo = false) { |
| 3535 | - $f = find_in_path($nom . '.' . _EXTENSION_SQUELETTES, $dir ? rtrim($dir, '/') . '/' : ''); |
|
| 3536 | - if (!$pathinfo) { |
|
| 3537 | - return $f; |
|
| 3538 | - } |
|
| 3539 | - // renvoyer un tableau detaille si $pathinfo==true |
|
| 3540 | - $p = pathinfo($f); |
|
| 3541 | - if (!isset($p['extension']) or !$p['extension']) { |
|
| 3542 | - $p['extension'] = _EXTENSION_SQUELETTES; |
|
| 3543 | - } |
|
| 3544 | - if (!isset($p['extension']) or !$p['filename']) { |
|
| 3545 | - $p['filename'] = ($p['basename'] ? substr($p['basename'], 0, -strlen($p['extension']) - 1) : ''); |
|
| 3546 | - } |
|
| 3547 | - $p['fond'] = ($f ? substr($f, 0, -strlen($p['extension']) - 1) : ''); |
|
| 3534 | + $f = find_in_path($nom . '.' . _EXTENSION_SQUELETTES, $dir ? rtrim($dir, '/') . '/' : ''); |
|
| 3535 | + if (!$pathinfo) { |
|
| 3536 | + return $f; |
|
| 3537 | + } |
|
| 3538 | + // renvoyer un tableau detaille si $pathinfo==true |
|
| 3539 | + $p = pathinfo($f); |
|
| 3540 | + if (!isset($p['extension']) or !$p['extension']) { |
|
| 3541 | + $p['extension'] = _EXTENSION_SQUELETTES; |
|
| 3542 | + } |
|
| 3543 | + if (!isset($p['extension']) or !$p['filename']) { |
|
| 3544 | + $p['filename'] = ($p['basename'] ? substr($p['basename'], 0, -strlen($p['extension']) - 1) : ''); |
|
| 3545 | + } |
|
| 3546 | + $p['fond'] = ($f ? substr($f, 0, -strlen($p['extension']) - 1) : ''); |
|
| 3548 | 3547 | |
| 3549 | - return $p; |
|
| 3548 | + return $p; |
|
| 3550 | 3549 | } |
| 3551 | 3550 | |
| 3552 | 3551 | /** |
@@ -3566,21 +3565,21 @@ discard block |
||
| 3566 | 3565 | * Nom de l'exec, sinon chaîne vide. |
| 3567 | 3566 | **/ |
| 3568 | 3567 | function tester_url_ecrire($nom) { |
| 3569 | - static $exec = []; |
|
| 3570 | - if (isset($exec[$nom])) { |
|
| 3571 | - return $exec[$nom]; |
|
| 3572 | - } |
|
| 3573 | - // tester si c'est une page en squelette |
|
| 3574 | - if (trouver_fond($nom, 'prive/squelettes/contenu/')) { |
|
| 3575 | - return $exec[$nom] = 'fond'; |
|
| 3576 | - } // echafaudage d'un fond ! |
|
| 3577 | - elseif (include_spip('public/styliser_par_z') and z_echafaudable($nom)) { |
|
| 3578 | - return $exec[$nom] = 'fond'; |
|
| 3579 | - } |
|
| 3580 | - // attention, il ne faut pas inclure l'exec ici |
|
| 3581 | - // car sinon #URL_ECRIRE provoque des inclusions |
|
| 3582 | - // et des define intrusifs potentiels |
|
| 3583 | - return $exec[$nom] = ((find_in_path("{$nom}.php", 'exec/') or charger_fonction($nom, 'exec', true)) ? $nom : ''); |
|
| 3568 | + static $exec = []; |
|
| 3569 | + if (isset($exec[$nom])) { |
|
| 3570 | + return $exec[$nom]; |
|
| 3571 | + } |
|
| 3572 | + // tester si c'est une page en squelette |
|
| 3573 | + if (trouver_fond($nom, 'prive/squelettes/contenu/')) { |
|
| 3574 | + return $exec[$nom] = 'fond'; |
|
| 3575 | + } // echafaudage d'un fond ! |
|
| 3576 | + elseif (include_spip('public/styliser_par_z') and z_echafaudable($nom)) { |
|
| 3577 | + return $exec[$nom] = 'fond'; |
|
| 3578 | + } |
|
| 3579 | + // attention, il ne faut pas inclure l'exec ici |
|
| 3580 | + // car sinon #URL_ECRIRE provoque des inclusions |
|
| 3581 | + // et des define intrusifs potentiels |
|
| 3582 | + return $exec[$nom] = ((find_in_path("{$nom}.php", 'exec/') or charger_fonction($nom, 'exec', true)) ? $nom : ''); |
|
| 3584 | 3583 | } |
| 3585 | 3584 | |
| 3586 | 3585 | /** |
@@ -3590,8 +3589,8 @@ discard block |
||
| 3590 | 3589 | * true si la constante _VERSION_HTML n'est pas définie ou égale à html5 |
| 3591 | 3590 | **/ |
| 3592 | 3591 | function html5_permis() { |
| 3593 | - return (!defined('_VERSION_HTML') |
|
| 3594 | - or _VERSION_HTML !== 'html4'); |
|
| 3592 | + return (!defined('_VERSION_HTML') |
|
| 3593 | + or _VERSION_HTML !== 'html4'); |
|
| 3595 | 3594 | } |
| 3596 | 3595 | |
| 3597 | 3596 | /** |
@@ -3601,30 +3600,30 @@ discard block |
||
| 3601 | 3600 | * @return array |
| 3602 | 3601 | */ |
| 3603 | 3602 | function formats_image_acceptables($gd = null, $svg_allowed = true) { |
| 3604 | - $formats = null; |
|
| 3605 | - if (!is_null($gd)) { |
|
| 3606 | - $config = ($gd ? 'gd_formats' : 'formats_graphiques'); |
|
| 3607 | - if (isset($GLOBALS['meta'][$config])) { |
|
| 3608 | - $formats = $GLOBALS['meta'][$config]; |
|
| 3609 | - $formats = explode(',', $formats); |
|
| 3610 | - $formats = array_filter($formats); |
|
| 3611 | - $formats = array_map('trim', $formats); |
|
| 3612 | - } |
|
| 3613 | - } |
|
| 3614 | - if (is_null($formats)) { |
|
| 3615 | - include_spip('inc/filtres_images_lib_mini'); |
|
| 3616 | - $formats = _image_extensions_acceptees_en_entree(); |
|
| 3617 | - } |
|
| 3618 | - |
|
| 3619 | - if ($svg_allowed) { |
|
| 3620 | - if (!in_array('svg', $formats)) { |
|
| 3621 | - $formats[] = 'svg'; |
|
| 3622 | - } |
|
| 3623 | - } |
|
| 3624 | - else { |
|
| 3625 | - $formats = array_diff($formats, ['svg']); |
|
| 3626 | - } |
|
| 3627 | - return $formats; |
|
| 3603 | + $formats = null; |
|
| 3604 | + if (!is_null($gd)) { |
|
| 3605 | + $config = ($gd ? 'gd_formats' : 'formats_graphiques'); |
|
| 3606 | + if (isset($GLOBALS['meta'][$config])) { |
|
| 3607 | + $formats = $GLOBALS['meta'][$config]; |
|
| 3608 | + $formats = explode(',', $formats); |
|
| 3609 | + $formats = array_filter($formats); |
|
| 3610 | + $formats = array_map('trim', $formats); |
|
| 3611 | + } |
|
| 3612 | + } |
|
| 3613 | + if (is_null($formats)) { |
|
| 3614 | + include_spip('inc/filtres_images_lib_mini'); |
|
| 3615 | + $formats = _image_extensions_acceptees_en_entree(); |
|
| 3616 | + } |
|
| 3617 | + |
|
| 3618 | + if ($svg_allowed) { |
|
| 3619 | + if (!in_array('svg', $formats)) { |
|
| 3620 | + $formats[] = 'svg'; |
|
| 3621 | + } |
|
| 3622 | + } |
|
| 3623 | + else { |
|
| 3624 | + $formats = array_diff($formats, ['svg']); |
|
| 3625 | + } |
|
| 3626 | + return $formats; |
|
| 3628 | 3627 | } |
| 3629 | 3628 | |
| 3630 | 3629 | /** |
@@ -3633,20 +3632,20 @@ discard block |
||
| 3633 | 3632 | * @return array|bool |
| 3634 | 3633 | */ |
| 3635 | 3634 | function spip_getimagesize($fichier) { |
| 3636 | - if (!$imagesize = @getimagesize($fichier)) { |
|
| 3637 | - include_spip('inc/svg'); |
|
| 3638 | - if ($attrs = svg_lire_attributs($fichier)) { |
|
| 3639 | - [$width, $height, $viewbox] = svg_getimagesize_from_attr($attrs); |
|
| 3640 | - $imagesize = [ |
|
| 3641 | - $width, |
|
| 3642 | - $height, |
|
| 3643 | - IMAGETYPE_SVG, |
|
| 3644 | - "width=\"{$width}\" height=\"{$height}\"", |
|
| 3645 | - 'mime' => 'image/svg+xml' |
|
| 3646 | - ]; |
|
| 3647 | - } |
|
| 3648 | - } |
|
| 3649 | - return $imagesize; |
|
| 3635 | + if (!$imagesize = @getimagesize($fichier)) { |
|
| 3636 | + include_spip('inc/svg'); |
|
| 3637 | + if ($attrs = svg_lire_attributs($fichier)) { |
|
| 3638 | + [$width, $height, $viewbox] = svg_getimagesize_from_attr($attrs); |
|
| 3639 | + $imagesize = [ |
|
| 3640 | + $width, |
|
| 3641 | + $height, |
|
| 3642 | + IMAGETYPE_SVG, |
|
| 3643 | + "width=\"{$width}\" height=\"{$height}\"", |
|
| 3644 | + 'mime' => 'image/svg+xml' |
|
| 3645 | + ]; |
|
| 3646 | + } |
|
| 3647 | + } |
|
| 3648 | + return $imagesize; |
|
| 3650 | 3649 | } |
| 3651 | 3650 | |
| 3652 | 3651 | /** |
@@ -3660,19 +3659,19 @@ discard block |
||
| 3660 | 3659 | * @param string $statut |
| 3661 | 3660 | */ |
| 3662 | 3661 | function avertir_auteurs($nom, $message, $statut = '') { |
| 3663 | - $alertes = $GLOBALS['meta']['message_alertes_auteurs']; |
|
| 3664 | - if ( |
|
| 3665 | - !$alertes |
|
| 3666 | - or !is_array($alertes = unserialize($alertes)) |
|
| 3667 | - ) { |
|
| 3668 | - $alertes = []; |
|
| 3669 | - } |
|
| 3662 | + $alertes = $GLOBALS['meta']['message_alertes_auteurs']; |
|
| 3663 | + if ( |
|
| 3664 | + !$alertes |
|
| 3665 | + or !is_array($alertes = unserialize($alertes)) |
|
| 3666 | + ) { |
|
| 3667 | + $alertes = []; |
|
| 3668 | + } |
|
| 3670 | 3669 | |
| 3671 | - if (!isset($alertes[$statut])) { |
|
| 3672 | - $alertes[$statut] = []; |
|
| 3673 | - } |
|
| 3674 | - $alertes[$statut][$nom] = $message; |
|
| 3675 | - ecrire_meta('message_alertes_auteurs', serialize($alertes)); |
|
| 3670 | + if (!isset($alertes[$statut])) { |
|
| 3671 | + $alertes[$statut] = []; |
|
| 3672 | + } |
|
| 3673 | + $alertes[$statut][$nom] = $message; |
|
| 3674 | + ecrire_meta('message_alertes_auteurs', serialize($alertes)); |
|
| 3676 | 3675 | } |
| 3677 | 3676 | |
| 3678 | 3677 | /** |
@@ -3686,10 +3685,10 @@ discard block |
||
| 3686 | 3685 | * @return string|string[] |
| 3687 | 3686 | */ |
| 3688 | 3687 | function spip_sanitize_classname($classes) { |
| 3689 | - if (is_array($classes)) { |
|
| 3690 | - return array_map('spip_sanitize_classname', $classes); |
|
| 3691 | - } |
|
| 3692 | - return preg_replace('/[^ 0-9a-z_\-+@]/i', '', $classes); |
|
| 3688 | + if (is_array($classes)) { |
|
| 3689 | + return array_map('spip_sanitize_classname', $classes); |
|
| 3690 | + } |
|
| 3691 | + return preg_replace('/[^ 0-9a-z_\-+@]/i', '', $classes); |
|
| 3693 | 3692 | } |
| 3694 | 3693 | |
| 3695 | 3694 | |
@@ -3714,32 +3713,32 @@ discard block |
||
| 3714 | 3713 | * Avec operateur : bool. |
| 3715 | 3714 | **/ |
| 3716 | 3715 | function spip_version_compare($v1, $v2, $op = null) { |
| 3717 | - $v1 = strtolower(preg_replace(',([0-9])[\s.-]?(dev|alpha|a|beta|b|rc|pl|p),i', '\\1.\\2', $v1)); |
|
| 3718 | - $v2 = strtolower(preg_replace(',([0-9])[\s.-]?(dev|alpha|a|beta|b|rc|pl|p),i', '\\1.\\2', $v2)); |
|
| 3719 | - $v1 = str_replace('rc', 'RC', $v1); // certaines versions de PHP ne comprennent RC qu'en majuscule |
|
| 3720 | - $v2 = str_replace('rc', 'RC', $v2); // certaines versions de PHP ne comprennent RC qu'en majuscule |
|
| 3721 | - |
|
| 3722 | - $v1 = explode('.', $v1); |
|
| 3723 | - $v2 = explode('.', $v2); |
|
| 3724 | - // $v1 est toujours une version, donc sans etoile |
|
| 3725 | - while (count($v1) < count($v2)) { |
|
| 3726 | - $v1[] = '0'; |
|
| 3727 | - } |
|
| 3728 | - |
|
| 3729 | - // $v2 peut etre une borne, donc accepte l'etoile |
|
| 3730 | - $etoile = false; |
|
| 3731 | - foreach ($v1 as $k => $v) { |
|
| 3732 | - if (!isset($v2[$k])) { |
|
| 3733 | - $v2[] = ($etoile and (is_numeric($v) or $v == 'pl' or $v == 'p')) ? $v : '0'; |
|
| 3734 | - } else { |
|
| 3735 | - if ($v2[$k] == '*') { |
|
| 3736 | - $etoile = true; |
|
| 3737 | - $v2[$k] = $v; |
|
| 3738 | - } |
|
| 3739 | - } |
|
| 3740 | - } |
|
| 3741 | - $v1 = implode('.', $v1); |
|
| 3742 | - $v2 = implode('.', $v2); |
|
| 3743 | - |
|
| 3744 | - return $op ? version_compare($v1, $v2, $op) : version_compare($v1, $v2); |
|
| 3716 | + $v1 = strtolower(preg_replace(',([0-9])[\s.-]?(dev|alpha|a|beta|b|rc|pl|p),i', '\\1.\\2', $v1)); |
|
| 3717 | + $v2 = strtolower(preg_replace(',([0-9])[\s.-]?(dev|alpha|a|beta|b|rc|pl|p),i', '\\1.\\2', $v2)); |
|
| 3718 | + $v1 = str_replace('rc', 'RC', $v1); // certaines versions de PHP ne comprennent RC qu'en majuscule |
|
| 3719 | + $v2 = str_replace('rc', 'RC', $v2); // certaines versions de PHP ne comprennent RC qu'en majuscule |
|
| 3720 | + |
|
| 3721 | + $v1 = explode('.', $v1); |
|
| 3722 | + $v2 = explode('.', $v2); |
|
| 3723 | + // $v1 est toujours une version, donc sans etoile |
|
| 3724 | + while (count($v1) < count($v2)) { |
|
| 3725 | + $v1[] = '0'; |
|
| 3726 | + } |
|
| 3727 | + |
|
| 3728 | + // $v2 peut etre une borne, donc accepte l'etoile |
|
| 3729 | + $etoile = false; |
|
| 3730 | + foreach ($v1 as $k => $v) { |
|
| 3731 | + if (!isset($v2[$k])) { |
|
| 3732 | + $v2[] = ($etoile and (is_numeric($v) or $v == 'pl' or $v == 'p')) ? $v : '0'; |
|
| 3733 | + } else { |
|
| 3734 | + if ($v2[$k] == '*') { |
|
| 3735 | + $etoile = true; |
|
| 3736 | + $v2[$k] = $v; |
|
| 3737 | + } |
|
| 3738 | + } |
|
| 3739 | + } |
|
| 3740 | + $v1 = implode('.', $v1); |
|
| 3741 | + $v2 = implode('.', $v2); |
|
| 3742 | + |
|
| 3743 | + return $op ? version_compare($v1, $v2, $op) : version_compare($v1, $v2); |
|
| 3745 | 3744 | } |
@@ -53,12 +53,12 @@ discard block |
||
| 53 | 53 | if (strlen($dossier) and substr($dossier, -1) != '/') { |
| 54 | 54 | $dossier .= '/'; |
| 55 | 55 | } |
| 56 | - $f = str_replace('/', '_', $dossier) . $nom; |
|
| 56 | + $f = str_replace('/', '_', $dossier).$nom; |
|
| 57 | 57 | |
| 58 | 58 | if (function_exists($f)) { |
| 59 | 59 | return $f; |
| 60 | 60 | } |
| 61 | - if (function_exists($g = $f . '_dist')) { |
|
| 61 | + if (function_exists($g = $f.'_dist')) { |
|
| 62 | 62 | return $g; |
| 63 | 63 | } |
| 64 | 64 | |
@@ -79,7 +79,7 @@ discard block |
||
| 79 | 79 | // passer en minuscules (cf les balises de formulaires) |
| 80 | 80 | // et inclure le fichier |
| 81 | 81 | if ( |
| 82 | - !$inc = include_spip($dossier . ($d = strtolower($nom))) |
|
| 82 | + !$inc = include_spip($dossier.($d = strtolower($nom))) |
|
| 83 | 83 | // si le fichier truc/machin/nom.php n'existe pas, |
| 84 | 84 | // la fonction peut etre definie dans truc/machin.php qui regroupe plusieurs petites fonctions |
| 85 | 85 | and strlen(dirname($dossier)) and dirname($dossier) != '.' |
@@ -98,14 +98,14 @@ discard block |
||
| 98 | 98 | } |
| 99 | 99 | |
| 100 | 100 | // Echec : message d'erreur |
| 101 | - spip_log("fonction $nom ($f ou $g) indisponible" . |
|
| 101 | + spip_log("fonction $nom ($f ou $g) indisponible". |
|
| 102 | 102 | ($inc ? '' : " (fichier $d absent de $dossier)")); |
| 103 | 103 | |
| 104 | 104 | include_spip('inc/minipres'); |
| 105 | 105 | echo minipres( |
| 106 | 106 | _T('forum_titre_erreur'), |
| 107 | - _T('fichier_introuvable', ['fichier' => '<b>' . spip_htmlentities($d) . '</b>']), |
|
| 108 | - ['all_inline' => true,'status' => 404] |
|
| 107 | + _T('fichier_introuvable', ['fichier' => '<b>'.spip_htmlentities($d).'</b>']), |
|
| 108 | + ['all_inline' => true, 'status' => 404] |
|
| 109 | 109 | ); |
| 110 | 110 | exit; |
| 111 | 111 | } |
@@ -151,7 +151,7 @@ discard block |
||
| 151 | 151 | * - string : chemin du fichier trouvé |
| 152 | 152 | **/ |
| 153 | 153 | function include_spip($f, $include = true) { |
| 154 | - return find_in_path($f . '.php', '', $include); |
|
| 154 | + return find_in_path($f.'.php', '', $include); |
|
| 155 | 155 | } |
| 156 | 156 | |
| 157 | 157 | /** |
@@ -171,7 +171,7 @@ discard block |
||
| 171 | 171 | * - string : chemin du fichier trouvé |
| 172 | 172 | **/ |
| 173 | 173 | function require_spip($f) { |
| 174 | - return find_in_path($f . '.php', '', 'required'); |
|
| 174 | + return find_in_path($f.'.php', '', 'required'); |
|
| 175 | 175 | } |
| 176 | 176 | |
| 177 | 177 | |
@@ -188,7 +188,7 @@ discard block |
||
| 188 | 188 | // donc il faut l'inclure "en globals" |
| 189 | 189 | if ($f = find_in_path('mes_fonctions.php')) { |
| 190 | 190 | global $dossier_squelettes; |
| 191 | - include_once(_ROOT_CWD . $f); |
|
| 191 | + include_once(_ROOT_CWD.$f); |
|
| 192 | 192 | } |
| 193 | 193 | |
| 194 | 194 | if (@is_readable(_CACHE_PLUGINS_FCT)) { |
@@ -293,7 +293,7 @@ discard block |
||
| 293 | 293 | } |
| 294 | 294 | |
| 295 | 295 | // appliquer notre fonction si elle existe |
| 296 | - $fonc = 'execute_pipeline_' . strtolower($action); |
|
| 296 | + $fonc = 'execute_pipeline_'.strtolower($action); |
|
| 297 | 297 | if (function_exists($fonc)) { |
| 298 | 298 | $val = $fonc($val); |
| 299 | 299 | } // plantage ? |
@@ -358,7 +358,7 @@ discard block |
||
| 358 | 358 | function spip_log($message = null, $name = null) { |
| 359 | 359 | static $pre = []; |
| 360 | 360 | static $log; |
| 361 | - preg_match('/^([a-z_]*)\.?(\d)?$/iS', (string)$name, $regs); |
|
| 361 | + preg_match('/^([a-z_]*)\.?(\d)?$/iS', (string) $name, $regs); |
|
| 362 | 362 | if (!isset($regs[1]) or !$logname = $regs[1]) { |
| 363 | 363 | $logname = null; |
| 364 | 364 | } |
@@ -386,7 +386,7 @@ discard block |
||
| 386 | 386 | if (!is_string($message)) { |
| 387 | 387 | $message = print_r($message, true); |
| 388 | 388 | } |
| 389 | - $log($pre[$niveau] . ' ' . $message, $logname); |
|
| 389 | + $log($pre[$niveau].' '.$message, $logname); |
|
| 390 | 390 | } |
| 391 | 391 | } |
| 392 | 392 | |
@@ -587,7 +587,7 @@ discard block |
||
| 587 | 587 | $a = './'; |
| 588 | 588 | } |
| 589 | 589 | |
| 590 | - $regexp = ',^(' . str_replace('[]', '\[\]', $c) . '[[]?[]]?)(=.*)?$,'; |
|
| 590 | + $regexp = ',^('.str_replace('[]', '\[\]', $c).'[[]?[]]?)(=.*)?$,'; |
|
| 591 | 591 | $ajouts = array_flip(explode('|', $c)); |
| 592 | 592 | $u = is_array($v) ? $v : rawurlencode((string) $v); |
| 593 | 593 | $testv = (is_array($v) ? count($v) : strlen((string) $v)); |
@@ -614,7 +614,7 @@ discard block |
||
| 614 | 614 | // Ajout. Pour une variable, remplacer au meme endroit, |
| 615 | 615 | // pour un tableau ce sera fait dans la prochaine boucle |
| 616 | 616 | elseif (substr($r[1], -2) != '[]') { |
| 617 | - $url[$n] = $r[1] . '=' . $u; |
|
| 617 | + $url[$n] = $r[1].'='.$u; |
|
| 618 | 618 | unset($ajouts[$r[1]]); |
| 619 | 619 | } |
| 620 | 620 | // Pour les tableaux on laisse tomber les valeurs de |
@@ -635,11 +635,11 @@ discard block |
||
| 635 | 635 | } elseif ($testv) { |
| 636 | 636 | foreach ($ajouts as $k => $n) { |
| 637 | 637 | if (!is_array($v)) { |
| 638 | - $url[] = $k . '=' . $u; |
|
| 638 | + $url[] = $k.'='.$u; |
|
| 639 | 639 | } else { |
| 640 | - $id = (substr($k, -2) == '[]') ? $k : ($k . '[]'); |
|
| 640 | + $id = (substr($k, -2) == '[]') ? $k : ($k.'[]'); |
|
| 641 | 641 | foreach ($v as $w) { |
| 642 | - $url[] = $id . '=' . (is_array($w) ? 'Array' : rawurlencode($w)); |
|
| 642 | + $url[] = $id.'='.(is_array($w) ? 'Array' : rawurlencode($w)); |
|
| 643 | 643 | } |
| 644 | 644 | } |
| 645 | 645 | } |
@@ -650,10 +650,10 @@ discard block |
||
| 650 | 650 | |
| 651 | 651 | // recomposer l'adresse |
| 652 | 652 | if ($url) { |
| 653 | - $a .= '?' . join($sep, $url); |
|
| 653 | + $a .= '?'.join($sep, $url); |
|
| 654 | 654 | } |
| 655 | 655 | |
| 656 | - return $a . $ancre; |
|
| 656 | + return $a.$ancre; |
|
| 657 | 657 | } |
| 658 | 658 | |
| 659 | 659 | /** |
@@ -685,7 +685,7 @@ discard block |
||
| 685 | 685 | translitteration($ancre) |
| 686 | 686 | ); |
| 687 | 687 | } |
| 688 | - return $url . (strlen($ancre) ? '#' . $ancre : ''); |
|
| 688 | + return $url.(strlen($ancre) ? '#'.$ancre : ''); |
|
| 689 | 689 | } |
| 690 | 690 | |
| 691 | 691 | /** |
@@ -801,7 +801,7 @@ discard block |
||
| 801 | 801 | * @return bool |
| 802 | 802 | */ |
| 803 | 803 | function test_plugin_actif($plugin) { |
| 804 | - return ($plugin and defined('_DIR_PLUGIN_' . strtoupper($plugin))) ? true : false; |
|
| 804 | + return ($plugin and defined('_DIR_PLUGIN_'.strtoupper($plugin))) ? true : false; |
|
| 805 | 805 | } |
| 806 | 806 | |
| 807 | 807 | /** |
@@ -933,7 +933,7 @@ discard block |
||
| 933 | 933 | $value = interdire_scripts($value, -1); |
| 934 | 934 | } |
| 935 | 935 | if (!empty($options['class'])) { |
| 936 | - $value = "<span class='" . $options['class'] . "'>$value</span>"; |
|
| 936 | + $value = "<span class='".$options['class']."'>$value</span>"; |
|
| 937 | 937 | } |
| 938 | 938 | $text = str_replace("@$name@", $value, $text); |
| 939 | 939 | unset($args[$name]); |
@@ -942,7 +942,7 @@ discard block |
||
| 942 | 942 | // Si des variables n'ont pas ete inserees, le signaler |
| 943 | 943 | // (chaines de langues pas a jour) |
| 944 | 944 | if ($args) { |
| 945 | - spip_log("$f: variables inutilisees " . join(', ', array_keys($args)), _LOG_DEBUG); |
|
| 945 | + spip_log("$f: variables inutilisees ".join(', ', array_keys($args)), _LOG_DEBUG); |
|
| 946 | 946 | } |
| 947 | 947 | } |
| 948 | 948 | |
@@ -966,7 +966,7 @@ discard block |
||
| 966 | 966 | function joli_repertoire($rep) { |
| 967 | 967 | $a = substr($rep, 0, 1); |
| 968 | 968 | if ($a <> '.' and $a <> '/') { |
| 969 | - $rep = (_DIR_RESTREINT ? '' : _DIR_RESTREINT_ABS) . $rep; |
|
| 969 | + $rep = (_DIR_RESTREINT ? '' : _DIR_RESTREINT_ABS).$rep; |
|
| 970 | 970 | } |
| 971 | 971 | $rep = preg_replace(',(^\.\.\/),', '', $rep); |
| 972 | 972 | |
@@ -1020,7 +1020,7 @@ discard block |
||
| 1020 | 1020 | $p -= ($x * 1000); |
| 1021 | 1021 | } |
| 1022 | 1022 | |
| 1023 | - return $s . sprintf($s ? '%07.3f ms' : '%.3f ms', $p); |
|
| 1023 | + return $s.sprintf($s ? '%07.3f ms' : '%.3f ms', $p); |
|
| 1024 | 1024 | } |
| 1025 | 1025 | } |
| 1026 | 1026 | |
@@ -1087,7 +1087,7 @@ discard block |
||
| 1087 | 1087 | if ($taches and count($taches) and !spip_connect()) { |
| 1088 | 1088 | return false; |
| 1089 | 1089 | } |
| 1090 | - spip_log('cron !', 'jq' . _LOG_DEBUG); |
|
| 1090 | + spip_log('cron !', 'jq'._LOG_DEBUG); |
|
| 1091 | 1091 | if ($genie = charger_fonction('genie', 'inc', true)) { |
| 1092 | 1092 | return $genie($taches); |
| 1093 | 1093 | } |
@@ -1191,7 +1191,7 @@ discard block |
||
| 1191 | 1191 | |
| 1192 | 1192 | if ($queue_next_job_time == -1) { |
| 1193 | 1193 | if (!defined('_JQ_NEXT_JOB_TIME_FILENAME')) { |
| 1194 | - define('_JQ_NEXT_JOB_TIME_FILENAME', _DIR_TMP . 'job_queue_next.txt'); |
|
| 1194 | + define('_JQ_NEXT_JOB_TIME_FILENAME', _DIR_TMP.'job_queue_next.txt'); |
|
| 1195 | 1195 | } |
| 1196 | 1196 | // utiliser un cache memoire si dispo |
| 1197 | 1197 | if (function_exists('cache_get') and defined('_MEMOIZE_MEMORY') and _MEMOIZE_MEMORY) { |
@@ -1260,8 +1260,8 @@ discard block |
||
| 1260 | 1260 | $src = ''; |
| 1261 | 1261 | } |
| 1262 | 1262 | if ($script) { |
| 1263 | - $script = ("/*<![CDATA[*/\n" . |
|
| 1264 | - preg_replace(',</([^>]*)>,', '<\/\1>', $script) . |
|
| 1263 | + $script = ("/*<![CDATA[*/\n". |
|
| 1264 | + preg_replace(',</([^>]*)>,', '<\/\1>', $script). |
|
| 1265 | 1265 | '/*]]>*/'); |
| 1266 | 1266 | } |
| 1267 | 1267 | if ($noscript) { |
@@ -1347,13 +1347,13 @@ discard block |
||
| 1347 | 1347 | if ($path_base == null) { |
| 1348 | 1348 | // Chemin standard depuis l'espace public |
| 1349 | 1349 | $path = defined('_SPIP_PATH') ? _SPIP_PATH : |
| 1350 | - _DIR_RACINE . ':' . |
|
| 1351 | - _DIR_RACINE . 'squelettes-dist/:' . |
|
| 1352 | - _DIR_RACINE . 'prive/:' . |
|
| 1350 | + _DIR_RACINE.':'. |
|
| 1351 | + _DIR_RACINE.'squelettes-dist/:'. |
|
| 1352 | + _DIR_RACINE.'prive/:'. |
|
| 1353 | 1353 | _DIR_RESTREINT; |
| 1354 | 1354 | // Ajouter squelettes/ |
| 1355 | - if (@is_dir(_DIR_RACINE . 'squelettes')) { |
|
| 1356 | - $path = _DIR_RACINE . 'squelettes/:' . $path; |
|
| 1355 | + if (@is_dir(_DIR_RACINE.'squelettes')) { |
|
| 1356 | + $path = _DIR_RACINE.'squelettes/:'.$path; |
|
| 1357 | 1357 | } |
| 1358 | 1358 | foreach (explode(':', $path) as $dir) { |
| 1359 | 1359 | if (strlen($dir) and substr($dir, -1) != '/') { |
@@ -1365,7 +1365,7 @@ discard block |
||
| 1365 | 1365 | // Et le(s) dossier(s) des squelettes nommes |
| 1366 | 1366 | if (strlen($GLOBALS['dossier_squelettes'])) { |
| 1367 | 1367 | foreach (array_reverse(explode(':', $GLOBALS['dossier_squelettes'])) as $d) { |
| 1368 | - array_unshift($path_full, ($d[0] == '/' ? '' : _DIR_RACINE) . $d . '/'); |
|
| 1368 | + array_unshift($path_full, ($d[0] == '/' ? '' : _DIR_RACINE).$d.'/'); |
|
| 1369 | 1369 | } |
| 1370 | 1370 | } |
| 1371 | 1371 | $GLOBALS['path_sig'] = md5(serialize($path_full)); |
@@ -1376,7 +1376,7 @@ discard block |
||
| 1376 | 1376 | |
| 1377 | 1377 | if (is_array($dir_path) or strlen($dir_path)) { |
| 1378 | 1378 | $tete = ''; |
| 1379 | - if (reset($path_base) == _DIR_RACINE . 'squelettes/') { |
|
| 1379 | + if (reset($path_base) == _DIR_RACINE.'squelettes/') { |
|
| 1380 | 1380 | $tete = array_shift($path_base); |
| 1381 | 1381 | } |
| 1382 | 1382 | $dirs = (is_array($dir_path) ? $dir_path : explode(':', $dir_path)); |
@@ -1397,7 +1397,7 @@ discard block |
||
| 1397 | 1397 | // Et le(s) dossier(s) des squelettes nommes |
| 1398 | 1398 | if (strlen($GLOBALS['dossier_squelettes'])) { |
| 1399 | 1399 | foreach (array_reverse(explode(':', $GLOBALS['dossier_squelettes'])) as $d) { |
| 1400 | - array_unshift($path_full, ((isset($d[0]) and $d[0] == '/') ? '' : _DIR_RACINE) . $d . '/'); |
|
| 1400 | + array_unshift($path_full, ((isset($d[0]) and $d[0] == '/') ? '' : _DIR_RACINE).$d.'/'); |
|
| 1401 | 1401 | } |
| 1402 | 1402 | } |
| 1403 | 1403 | |
@@ -1468,14 +1468,14 @@ discard block |
||
| 1468 | 1468 | // si il y a un .svg a la bonne taille (-16.svg) a cote, on l'utilise en remplacement du -16.png |
| 1469 | 1469 | if ( |
| 1470 | 1470 | preg_match(',-(\d+)[.](png|gif|svg)$,', $file, $m) |
| 1471 | - and $file_svg_generique = substr($file, 0, -strlen($m[0])) . '-xx.svg' |
|
| 1471 | + and $file_svg_generique = substr($file, 0, -strlen($m[0])).'-xx.svg' |
|
| 1472 | 1472 | and $f = find_in_theme("$file_svg_generique") |
| 1473 | 1473 | ) { |
| 1474 | - if ($fsize = substr($f, 0, -6) . $m[1] . '.svg' and file_exists($fsize)) { |
|
| 1474 | + if ($fsize = substr($f, 0, -6).$m[1].'.svg' and file_exists($fsize)) { |
|
| 1475 | 1475 | return $themefiles["$subdir$file"] = $fsize; |
| 1476 | 1476 | } |
| 1477 | 1477 | else { |
| 1478 | - return $themefiles["$subdir$file"] = "$f?" . $m[1] . 'px'; |
|
| 1478 | + return $themefiles["$subdir$file"] = "$f?".$m[1].'px'; |
|
| 1479 | 1479 | } |
| 1480 | 1480 | } |
| 1481 | 1481 | |
@@ -1485,7 +1485,7 @@ discard block |
||
| 1485 | 1485 | return $themefiles["$subdir$file"] = $f; |
| 1486 | 1486 | } |
| 1487 | 1487 | } |
| 1488 | - spip_log("$file introuvable dans le theme prive " . reset($themes), 'theme'); |
|
| 1488 | + spip_log("$file introuvable dans le theme prive ".reset($themes), 'theme'); |
|
| 1489 | 1489 | |
| 1490 | 1490 | return $themefiles["$subdir$file"] = ''; |
| 1491 | 1491 | } |
@@ -1593,8 +1593,8 @@ discard block |
||
| 1593 | 1593 | return false; |
| 1594 | 1594 | } |
| 1595 | 1595 | if ($include and !isset($inc[$dirname][$file])) { |
| 1596 | - include_once _ROOT_CWD . $GLOBALS['path_files'][$GLOBALS['path_sig']][$dirname][$file]; |
|
| 1597 | - $inc[$dirname][$file] = $inc[''][$dirname . $file] = true; |
|
| 1596 | + include_once _ROOT_CWD.$GLOBALS['path_files'][$GLOBALS['path_sig']][$dirname][$file]; |
|
| 1597 | + $inc[$dirname][$file] = $inc[''][$dirname.$file] = true; |
|
| 1598 | 1598 | } |
| 1599 | 1599 | |
| 1600 | 1600 | return $GLOBALS['path_files'][$GLOBALS['path_sig']][$dirname][$file]; |
@@ -1607,14 +1607,14 @@ discard block |
||
| 1607 | 1607 | } |
| 1608 | 1608 | |
| 1609 | 1609 | foreach (creer_chemin() as $dir) { |
| 1610 | - if (!isset($dirs[$a = $dir . $dirname])) { |
|
| 1611 | - $dirs[$a] = (is_dir(_ROOT_CWD . $a) || !$a); |
|
| 1610 | + if (!isset($dirs[$a = $dir.$dirname])) { |
|
| 1611 | + $dirs[$a] = (is_dir(_ROOT_CWD.$a) || !$a); |
|
| 1612 | 1612 | } |
| 1613 | 1613 | if ($dirs[$a]) { |
| 1614 | - if (file_exists(_ROOT_CWD . ($a .= $file))) { |
|
| 1614 | + if (file_exists(_ROOT_CWD.($a .= $file))) { |
|
| 1615 | 1615 | if ($include and !isset($inc[$dirname][$file])) { |
| 1616 | - include_once _ROOT_CWD . $a; |
|
| 1617 | - $inc[$dirname][$file] = $inc[''][$dirname . $file] = true; |
|
| 1616 | + include_once _ROOT_CWD.$a; |
|
| 1617 | + $inc[$dirname][$file] = $inc[''][$dirname.$file] = true; |
|
| 1618 | 1618 | } |
| 1619 | 1619 | if (!defined('_SAUVER_CHEMIN')) { |
| 1620 | 1620 | // si le chemin n'a pas encore ete charge, ne pas lever le flag, ne pas cacher |
@@ -1624,7 +1624,7 @@ discard block |
||
| 1624 | 1624 | define('_SAUVER_CHEMIN', true); |
| 1625 | 1625 | } |
| 1626 | 1626 | |
| 1627 | - return $GLOBALS['path_files'][$GLOBALS['path_sig']][$dirname][$file] = $GLOBALS['path_files'][$GLOBALS['path_sig']][''][$dirname . $file] = $a; |
|
| 1627 | + return $GLOBALS['path_files'][$GLOBALS['path_sig']][$dirname][$file] = $GLOBALS['path_files'][$GLOBALS['path_sig']][''][$dirname.$file] = $a; |
|
| 1628 | 1628 | } |
| 1629 | 1629 | } |
| 1630 | 1630 | } |
@@ -1650,7 +1650,7 @@ discard block |
||
| 1650 | 1650 | define('_SAUVER_CHEMIN', true); |
| 1651 | 1651 | } |
| 1652 | 1652 | |
| 1653 | - return $GLOBALS['path_files'][$GLOBALS['path_sig']][$dirname][$file] = $GLOBALS['path_files'][$GLOBALS['path_sig']][''][$dirname . $file] = false; |
|
| 1653 | + return $GLOBALS['path_files'][$GLOBALS['path_sig']][$dirname][$file] = $GLOBALS['path_files'][$GLOBALS['path_sig']][''][$dirname.$file] = false; |
|
| 1654 | 1654 | } |
| 1655 | 1655 | |
| 1656 | 1656 | function clear_path_cache() { |
@@ -1720,12 +1720,12 @@ discard block |
||
| 1720 | 1720 | // cas borderline si dans mes_options on appelle redirige_par_entete qui utilise _T et charge un fichier de langue |
| 1721 | 1721 | // on a pas encore inclus flock.php |
| 1722 | 1722 | if (!function_exists('preg_files')) { |
| 1723 | - include_once _ROOT_RESTREINT . 'inc/flock.php'; |
|
| 1723 | + include_once _ROOT_RESTREINT.'inc/flock.php'; |
|
| 1724 | 1724 | } |
| 1725 | 1725 | |
| 1726 | 1726 | // Parcourir le chemin |
| 1727 | 1727 | foreach (creer_chemin() as $d) { |
| 1728 | - $f = $d . $dir; |
|
| 1728 | + $f = $d.$dir; |
|
| 1729 | 1729 | if (@is_dir($f)) { |
| 1730 | 1730 | $liste = preg_files($f, $pattern, $maxfiles - count($liste_fichiers), $recurs === true ? [] : $recurs); |
| 1731 | 1731 | foreach ($liste as $chemin) { |
@@ -1774,9 +1774,9 @@ discard block |
||
| 1774 | 1774 | function charger_fonction_url(string $quoi, string $type = '') { |
| 1775 | 1775 | if ($type === 'defaut') { |
| 1776 | 1776 | $objet = objet_type($quoi); |
| 1777 | - if ($f = charger_fonction('generer_' . $objet . '_url', 'urls', true) |
|
| 1777 | + if ($f = charger_fonction('generer_'.$objet.'_url', 'urls', true) |
|
| 1778 | 1778 | // deprecated |
| 1779 | - or $f = charger_fonction('generer_url_' . $objet, 'urls', true) |
|
| 1779 | + or $f = charger_fonction('generer_url_'.$objet, 'urls', true) |
|
| 1780 | 1780 | ) { |
| 1781 | 1781 | return $f; |
| 1782 | 1782 | } |
@@ -1897,7 +1897,7 @@ discard block |
||
| 1897 | 1897 | * @deprecated 4.1 |
| 1898 | 1898 | * @see generer_objet_url |
| 1899 | 1899 | */ |
| 1900 | -function generer_url_entite($id = 0, $entite = '', $args = '', $ancre = '', $public = null, $type = null){ |
|
| 1900 | +function generer_url_entite($id = 0, $entite = '', $args = '', $ancre = '', $public = null, $type = null) { |
|
| 1901 | 1901 | if ($public and is_string($public)) { |
| 1902 | 1902 | return generer_objet_url(intval($id), $entite, $args ?: '', $ancre ?: '', true, $type ?? '', $public); |
| 1903 | 1903 | } |
@@ -1932,7 +1932,7 @@ discard block |
||
| 1932 | 1932 | * @deprecated 4.1 |
| 1933 | 1933 | * @see generer_objet_url_ecrire_edit |
| 1934 | 1934 | */ |
| 1935 | -function generer_url_ecrire_entite_edit($id, $entite, $args = '', $ancre = ''){ |
|
| 1935 | +function generer_url_ecrire_entite_edit($id, $entite, $args = '', $ancre = '') { |
|
| 1936 | 1936 | return generer_objet_url_ecrire_edit(intval($id), $entite, $args, $ancre); |
| 1937 | 1937 | } |
| 1938 | 1938 | |
@@ -1941,8 +1941,8 @@ discard block |
||
| 1941 | 1941 | include_spip('base/connect_sql'); |
| 1942 | 1942 | $id_type = id_table_objet($entite, $public); |
| 1943 | 1943 | |
| 1944 | - return _DIR_RACINE . get_spip_script('./') |
|
| 1945 | - . '?' . _SPIP_PAGE . "=$entite&$id_type=$i&connect=$public" |
|
| 1944 | + return _DIR_RACINE.get_spip_script('./') |
|
| 1945 | + . '?'._SPIP_PAGE."=$entite&$id_type=$i&connect=$public" |
|
| 1946 | 1946 | . (!$args ? '' : "&$args") |
| 1947 | 1947 | . (!$ancre ? '' : "#$ancre"); |
| 1948 | 1948 | } |
@@ -1996,7 +1996,7 @@ discard block |
||
| 1996 | 1996 | * @deprecated 4.1 |
| 1997 | 1997 | * @see generer_objet_url_absolue |
| 1998 | 1998 | */ |
| 1999 | -function generer_url_entite_absolue($id = 0, $entite = '', $args = '', $ancre = '', $connect = null){ |
|
| 1999 | +function generer_url_entite_absolue($id = 0, $entite = '', $args = '', $ancre = '', $connect = null) { |
|
| 2000 | 2000 | return generer_objet_url_absolue(intval($id), $entite, $args, $ancre, true, '', $connect); |
| 2001 | 2001 | } |
| 2002 | 2002 | |
@@ -2113,7 +2113,7 @@ discard block |
||
| 2113 | 2113 | !empty($_SERVER['QUERY_STRING']) |
| 2114 | 2114 | and !strpos($_SERVER['REQUEST_URI'], '?') |
| 2115 | 2115 | ) { |
| 2116 | - $GLOBALS['REQUEST_URI'] .= '?' . $_SERVER['QUERY_STRING']; |
|
| 2116 | + $GLOBALS['REQUEST_URI'] .= '?'.$_SERVER['QUERY_STRING']; |
|
| 2117 | 2117 | } |
| 2118 | 2118 | } |
| 2119 | 2119 | } |
@@ -2148,9 +2148,9 @@ discard block |
||
| 2148 | 2148 | array_shift($myself); |
| 2149 | 2149 | $myself = implode('/', $myself); |
| 2150 | 2150 | } |
| 2151 | - $url = join('/', array_slice(explode('/', $myself), 0, -1 - $prof)) . '/'; |
|
| 2151 | + $url = join('/', array_slice(explode('/', $myself), 0, -1 - $prof)).'/'; |
|
| 2152 | 2152 | |
| 2153 | - $url = $http . '://' . rtrim($host, '/') . '/' . ltrim($url, '/'); |
|
| 2153 | + $url = $http.'://'.rtrim($host, '/').'/'.ltrim($url, '/'); |
|
| 2154 | 2154 | |
| 2155 | 2155 | return $url; |
| 2156 | 2156 | } |
@@ -2188,16 +2188,16 @@ discard block |
||
| 2188 | 2188 | **/ |
| 2189 | 2189 | function generer_url_ecrire($script = '', $args = '', $no_entities = false, $rel = false) { |
| 2190 | 2190 | if (!$rel) { |
| 2191 | - $rel = url_de_base() . _DIR_RESTREINT_ABS . _SPIP_ECRIRE_SCRIPT; |
|
| 2191 | + $rel = url_de_base()._DIR_RESTREINT_ABS._SPIP_ECRIRE_SCRIPT; |
|
| 2192 | 2192 | } else { |
| 2193 | 2193 | if (!is_string($rel)) { |
| 2194 | - $rel = _DIR_RESTREINT ?: './' . _SPIP_ECRIRE_SCRIPT; |
|
| 2194 | + $rel = _DIR_RESTREINT ?: './'._SPIP_ECRIRE_SCRIPT; |
|
| 2195 | 2195 | } |
| 2196 | 2196 | } |
| 2197 | 2197 | |
| 2198 | 2198 | [$script, $ancre] = array_pad(explode('#', $script), 2, null); |
| 2199 | 2199 | if ($script and ($script <> 'accueil' or $rel)) { |
| 2200 | - $args = "?exec=$script" . (!$args ? '' : "&$args"); |
|
| 2200 | + $args = "?exec=$script".(!$args ? '' : "&$args"); |
|
| 2201 | 2201 | } elseif ($args) { |
| 2202 | 2202 | $args = "?$args"; |
| 2203 | 2203 | } |
@@ -2205,7 +2205,7 @@ discard block |
||
| 2205 | 2205 | $args .= "#$ancre"; |
| 2206 | 2206 | } |
| 2207 | 2207 | |
| 2208 | - return $rel . ($no_entities ? $args : str_replace('&', '&', $args)); |
|
| 2208 | + return $rel.($no_entities ? $args : str_replace('&', '&', $args)); |
|
| 2209 | 2209 | } |
| 2210 | 2210 | |
| 2211 | 2211 | // |
@@ -2287,10 +2287,10 @@ discard block |
||
| 2287 | 2287 | $action = parametre_url($action, _SPIP_PAGE, $script, '&'); |
| 2288 | 2288 | } |
| 2289 | 2289 | if ($args) { |
| 2290 | - $action .= (strpos($action, '?') !== false ? '&' : '?') . $args; |
|
| 2290 | + $action .= (strpos($action, '?') !== false ? '&' : '?').$args; |
|
| 2291 | 2291 | } |
| 2292 | 2292 | // ne pas generer une url avec /./?page= en cas d'url absolue et de _SPIP_SCRIPT vide |
| 2293 | - $url = ($rel ? _DIR_RACINE . $action : rtrim(url_de_base(), '/') . preg_replace(',^/[.]/,', '/', "/$action")); |
|
| 2293 | + $url = ($rel ? _DIR_RACINE . $action : rtrim(url_de_base(), '/').preg_replace(',^/[.]/,', '/', "/$action")); |
|
| 2294 | 2294 | } |
| 2295 | 2295 | |
| 2296 | 2296 | if (!$no_entities) { |
@@ -2302,7 +2302,7 @@ discard block |
||
| 2302 | 2302 | |
| 2303 | 2303 | function generer_url_prive($script, $args = '', $no_entities = false) { |
| 2304 | 2304 | |
| 2305 | - return generer_url_public($script, $args, $no_entities, false, _DIR_RESTREINT_ABS . 'prive.php'); |
|
| 2305 | + return generer_url_public($script, $args, $no_entities, false, _DIR_RESTREINT_ABS.'prive.php'); |
|
| 2306 | 2306 | } |
| 2307 | 2307 | |
| 2308 | 2308 | // Pour les formulaires en methode POST, |
@@ -2337,8 +2337,7 @@ discard block |
||
| 2337 | 2337 | . "><div>\n" |
| 2338 | 2338 | . "<input type='hidden' name='exec' value='$script1' />" |
| 2339 | 2339 | . $corps |
| 2340 | - . (!$submit ? '' : |
|
| 2341 | - ("<div style='text-align: " . $GLOBALS['spip_lang_right'] . "'><input class='fondo submit btn' type='submit' value=\"" . entites_html($submit) . '" /></div>')) |
|
| 2340 | + . (!$submit ? '' : ("<div style='text-align: ".$GLOBALS['spip_lang_right']."'><input class='fondo submit btn' type='submit' value=\"".entites_html($submit).'" /></div>')) |
|
| 2342 | 2341 | . "</div></form>\n"; |
| 2343 | 2342 | } |
| 2344 | 2343 | |
@@ -2363,14 +2362,14 @@ discard block |
||
| 2363 | 2362 | ? generer_url_ecrire(_request('exec')) |
| 2364 | 2363 | : generer_url_public(); |
| 2365 | 2364 | |
| 2366 | - return "\n<form action='" . |
|
| 2367 | - $h . |
|
| 2368 | - "'" . |
|
| 2369 | - $atts . |
|
| 2370 | - ">\n" . |
|
| 2371 | - '<div>' . |
|
| 2372 | - "\n<input type='hidden' name='action' value='$script' />" . |
|
| 2373 | - $corps . |
|
| 2365 | + return "\n<form action='". |
|
| 2366 | + $h. |
|
| 2367 | + "'". |
|
| 2368 | + $atts. |
|
| 2369 | + ">\n". |
|
| 2370 | + '<div>'. |
|
| 2371 | + "\n<input type='hidden' name='action' value='$script' />". |
|
| 2372 | + $corps. |
|
| 2374 | 2373 | '</div></form>'; |
| 2375 | 2374 | } |
| 2376 | 2375 | |
@@ -2398,7 +2397,7 @@ discard block |
||
| 2398 | 2397 | : generer_url_public('', '', false, false); |
| 2399 | 2398 | $url = parametre_url($url, 'action', $script); |
| 2400 | 2399 | if ($args) { |
| 2401 | - $url .= quote_amp('&' . $args); |
|
| 2400 | + $url .= quote_amp('&'.$args); |
|
| 2402 | 2401 | } |
| 2403 | 2402 | |
| 2404 | 2403 | if ($no_entities) { |
@@ -2432,9 +2431,9 @@ discard block |
||
| 2432 | 2431 | } |
| 2433 | 2432 | $url = |
| 2434 | 2433 | (($public ? _DIR_RACINE : _DIR_RESTREINT) ?: './') |
| 2435 | - . $script . '/' |
|
| 2434 | + . $script.'/' |
|
| 2436 | 2435 | . ($path ? trim($path, '/') : '') |
| 2437 | - . ($args ? "?" . quote_amp($args) : ''); |
|
| 2436 | + . ($args ? "?".quote_amp($args) : ''); |
|
| 2438 | 2437 | |
| 2439 | 2438 | if ($no_entities) { |
| 2440 | 2439 | $url = str_replace('&', '&', $url); |
@@ -2483,17 +2482,17 @@ discard block |
||
| 2483 | 2482 | |
| 2484 | 2483 | // le nom du repertoire plugins/ activables/desactivables |
| 2485 | 2484 | if (!defined('_DIR_PLUGINS')) { |
| 2486 | - define('_DIR_PLUGINS', _DIR_RACINE . 'plugins/'); |
|
| 2485 | + define('_DIR_PLUGINS', _DIR_RACINE.'plugins/'); |
|
| 2487 | 2486 | } |
| 2488 | 2487 | |
| 2489 | 2488 | // le nom du repertoire des extensions/ permanentes du core, toujours actives |
| 2490 | 2489 | if (!defined('_DIR_PLUGINS_DIST')) { |
| 2491 | - define('_DIR_PLUGINS_DIST', _DIR_RACINE . 'plugins-dist/'); |
|
| 2490 | + define('_DIR_PLUGINS_DIST', _DIR_RACINE.'plugins-dist/'); |
|
| 2492 | 2491 | } |
| 2493 | 2492 | |
| 2494 | 2493 | // le nom du repertoire des librairies |
| 2495 | 2494 | if (!defined('_DIR_LIB')) { |
| 2496 | - define('_DIR_LIB', _DIR_RACINE . 'lib/'); |
|
| 2495 | + define('_DIR_LIB', _DIR_RACINE.'lib/'); |
|
| 2497 | 2496 | } |
| 2498 | 2497 | |
| 2499 | 2498 | if (!defined('_DIR_IMG')) { |
@@ -2503,29 +2502,29 @@ discard block |
||
| 2503 | 2502 | define('_DIR_LOGOS', $pa); |
| 2504 | 2503 | } |
| 2505 | 2504 | if (!defined('_DIR_IMG_ICONES')) { |
| 2506 | - define('_DIR_IMG_ICONES', _DIR_LOGOS . 'icones/'); |
|
| 2505 | + define('_DIR_IMG_ICONES', _DIR_LOGOS.'icones/'); |
|
| 2507 | 2506 | } |
| 2508 | 2507 | |
| 2509 | 2508 | if (!defined('_DIR_DUMP')) { |
| 2510 | - define('_DIR_DUMP', $ti . 'dump/'); |
|
| 2509 | + define('_DIR_DUMP', $ti.'dump/'); |
|
| 2511 | 2510 | } |
| 2512 | 2511 | if (!defined('_DIR_SESSIONS')) { |
| 2513 | - define('_DIR_SESSIONS', $ti . 'sessions/'); |
|
| 2512 | + define('_DIR_SESSIONS', $ti.'sessions/'); |
|
| 2514 | 2513 | } |
| 2515 | 2514 | if (!defined('_DIR_TRANSFERT')) { |
| 2516 | - define('_DIR_TRANSFERT', $ti . 'upload/'); |
|
| 2515 | + define('_DIR_TRANSFERT', $ti.'upload/'); |
|
| 2517 | 2516 | } |
| 2518 | 2517 | if (!defined('_DIR_CACHE')) { |
| 2519 | - define('_DIR_CACHE', $ti . 'cache/'); |
|
| 2518 | + define('_DIR_CACHE', $ti.'cache/'); |
|
| 2520 | 2519 | } |
| 2521 | 2520 | if (!defined('_DIR_CACHE_XML')) { |
| 2522 | - define('_DIR_CACHE_XML', _DIR_CACHE . 'xml/'); |
|
| 2521 | + define('_DIR_CACHE_XML', _DIR_CACHE.'xml/'); |
|
| 2523 | 2522 | } |
| 2524 | 2523 | if (!defined('_DIR_SKELS')) { |
| 2525 | - define('_DIR_SKELS', _DIR_CACHE . 'skel/'); |
|
| 2524 | + define('_DIR_SKELS', _DIR_CACHE.'skel/'); |
|
| 2526 | 2525 | } |
| 2527 | 2526 | if (!defined('_DIR_AIDE')) { |
| 2528 | - define('_DIR_AIDE', _DIR_CACHE . 'aide/'); |
|
| 2527 | + define('_DIR_AIDE', _DIR_CACHE.'aide/'); |
|
| 2529 | 2528 | } |
| 2530 | 2529 | if (!defined('_DIR_TMP')) { |
| 2531 | 2530 | define('_DIR_TMP', $ti); |
@@ -2554,27 +2553,27 @@ discard block |
||
| 2554 | 2553 | // Declaration des fichiers |
| 2555 | 2554 | |
| 2556 | 2555 | if (!defined('_CACHE_PLUGINS_PATH')) { |
| 2557 | - define('_CACHE_PLUGINS_PATH', _DIR_CACHE . 'charger_plugins_chemins.php'); |
|
| 2556 | + define('_CACHE_PLUGINS_PATH', _DIR_CACHE.'charger_plugins_chemins.php'); |
|
| 2558 | 2557 | } |
| 2559 | 2558 | if (!defined('_CACHE_PLUGINS_OPT')) { |
| 2560 | - define('_CACHE_PLUGINS_OPT', _DIR_CACHE . 'charger_plugins_options.php'); |
|
| 2559 | + define('_CACHE_PLUGINS_OPT', _DIR_CACHE.'charger_plugins_options.php'); |
|
| 2561 | 2560 | } |
| 2562 | 2561 | if (!defined('_CACHE_PLUGINS_FCT')) { |
| 2563 | - define('_CACHE_PLUGINS_FCT', _DIR_CACHE . 'charger_plugins_fonctions.php'); |
|
| 2562 | + define('_CACHE_PLUGINS_FCT', _DIR_CACHE.'charger_plugins_fonctions.php'); |
|
| 2564 | 2563 | } |
| 2565 | 2564 | if (!defined('_CACHE_PIPELINES')) { |
| 2566 | - define('_CACHE_PIPELINES', _DIR_CACHE . 'charger_pipelines.php'); |
|
| 2565 | + define('_CACHE_PIPELINES', _DIR_CACHE.'charger_pipelines.php'); |
|
| 2567 | 2566 | } |
| 2568 | 2567 | if (!defined('_CACHE_CHEMIN')) { |
| 2569 | - define('_CACHE_CHEMIN', _DIR_CACHE . 'chemin.txt'); |
|
| 2568 | + define('_CACHE_CHEMIN', _DIR_CACHE.'chemin.txt'); |
|
| 2570 | 2569 | } |
| 2571 | 2570 | |
| 2572 | 2571 | # attention .php obligatoire pour ecrire_fichier_securise |
| 2573 | 2572 | if (!defined('_FILE_META')) { |
| 2574 | - define('_FILE_META', $ti . 'meta_cache.php'); |
|
| 2573 | + define('_FILE_META', $ti.'meta_cache.php'); |
|
| 2575 | 2574 | } |
| 2576 | 2575 | if (!defined('_DIR_LOG')) { |
| 2577 | - define('_DIR_LOG', _DIR_TMP . 'log/'); |
|
| 2576 | + define('_DIR_LOG', _DIR_TMP.'log/'); |
|
| 2578 | 2577 | } |
| 2579 | 2578 | if (!defined('_FILE_LOG')) { |
| 2580 | 2579 | define('_FILE_LOG', 'spip'); |
@@ -2591,8 +2590,8 @@ discard block |
||
| 2591 | 2590 | if (!defined('_FILE_CONNECT')) { |
| 2592 | 2591 | define( |
| 2593 | 2592 | '_FILE_CONNECT', |
| 2594 | - (@is_readable($f = _DIR_CONNECT . _FILE_CONNECT_INS . '.php') ? $f |
|
| 2595 | - : (@is_readable($f = _DIR_RESTREINT . 'inc_connect.php') ? $f |
|
| 2593 | + (@is_readable($f = _DIR_CONNECT._FILE_CONNECT_INS.'.php') ? $f |
|
| 2594 | + : (@is_readable($f = _DIR_RESTREINT.'inc_connect.php') ? $f |
|
| 2596 | 2595 | : false)) |
| 2597 | 2596 | ); |
| 2598 | 2597 | } |
@@ -2604,7 +2603,7 @@ discard block |
||
| 2604 | 2603 | if (!defined('_FILE_CHMOD')) { |
| 2605 | 2604 | define( |
| 2606 | 2605 | '_FILE_CHMOD', |
| 2607 | - (@is_readable($f = _DIR_CHMOD . _FILE_CHMOD_INS . '.php') ? $f |
|
| 2606 | + (@is_readable($f = _DIR_CHMOD._FILE_CHMOD_INS.'.php') ? $f |
|
| 2608 | 2607 | : false) |
| 2609 | 2608 | ); |
| 2610 | 2609 | } |
@@ -2617,10 +2616,10 @@ discard block |
||
| 2617 | 2616 | define('_FILE_TMP_SUFFIX', '.tmp.php'); |
| 2618 | 2617 | } |
| 2619 | 2618 | if (!defined('_FILE_CONNECT_TMP')) { |
| 2620 | - define('_FILE_CONNECT_TMP', _DIR_CONNECT . _FILE_CONNECT_INS . _FILE_TMP_SUFFIX); |
|
| 2619 | + define('_FILE_CONNECT_TMP', _DIR_CONNECT._FILE_CONNECT_INS._FILE_TMP_SUFFIX); |
|
| 2621 | 2620 | } |
| 2622 | 2621 | if (!defined('_FILE_CHMOD_TMP')) { |
| 2623 | - define('_FILE_CHMOD_TMP', _DIR_CHMOD . _FILE_CHMOD_INS . _FILE_TMP_SUFFIX); |
|
| 2622 | + define('_FILE_CHMOD_TMP', _DIR_CHMOD._FILE_CHMOD_INS._FILE_TMP_SUFFIX); |
|
| 2624 | 2623 | } |
| 2625 | 2624 | |
| 2626 | 2625 | // Definition des droits d'acces en ecriture |
@@ -2638,13 +2637,13 @@ discard block |
||
| 2638 | 2637 | define('_DEFAULT_CHARSET', 'utf-8'); |
| 2639 | 2638 | } |
| 2640 | 2639 | if (!defined('_ROOT_PLUGINS')) { |
| 2641 | - define('_ROOT_PLUGINS', _ROOT_RACINE . 'plugins/'); |
|
| 2640 | + define('_ROOT_PLUGINS', _ROOT_RACINE.'plugins/'); |
|
| 2642 | 2641 | } |
| 2643 | 2642 | if (!defined('_ROOT_PLUGINS_DIST')) { |
| 2644 | - define('_ROOT_PLUGINS_DIST', _ROOT_RACINE . 'plugins-dist/'); |
|
| 2643 | + define('_ROOT_PLUGINS_DIST', _ROOT_RACINE.'plugins-dist/'); |
|
| 2645 | 2644 | } |
| 2646 | 2645 | if (!defined('_ROOT_PLUGINS_SUPPL') && defined('_DIR_PLUGINS_SUPPL') && _DIR_PLUGINS_SUPPL) { |
| 2647 | - define('_ROOT_PLUGINS_SUPPL', _ROOT_RACINE . str_replace(_DIR_RACINE, '', _DIR_PLUGINS_SUPPL)); |
|
| 2646 | + define('_ROOT_PLUGINS_SUPPL', _ROOT_RACINE.str_replace(_DIR_RACINE, '', _DIR_PLUGINS_SUPPL)); |
|
| 2648 | 2647 | } |
| 2649 | 2648 | |
| 2650 | 2649 | // La taille des Log |
@@ -2681,7 +2680,7 @@ discard block |
||
| 2681 | 2680 | // (non surchargeable en l'etat ; attention si on utilise include_spip() |
| 2682 | 2681 | // pour le rendre surchargeable, on va provoquer un reecriture |
| 2683 | 2682 | // systematique du noyau ou une baisse de perfs => a etudier) |
| 2684 | - include_once _ROOT_RESTREINT . 'inc/flock.php'; |
|
| 2683 | + include_once _ROOT_RESTREINT.'inc/flock.php'; |
|
| 2685 | 2684 | |
| 2686 | 2685 | // charger tout de suite le path et son cache |
| 2687 | 2686 | load_path_cache(); |
@@ -2729,7 +2728,7 @@ discard block |
||
| 2729 | 2728 | !empty($_SERVER['QUERY_STRING']) |
| 2730 | 2729 | and !strpos($_SERVER['REQUEST_URI'], '?') |
| 2731 | 2730 | ) { |
| 2732 | - $GLOBALS['REQUEST_URI'] .= '?' . $_SERVER['QUERY_STRING']; |
|
| 2731 | + $GLOBALS['REQUEST_URI'] .= '?'.$_SERVER['QUERY_STRING']; |
|
| 2733 | 2732 | } |
| 2734 | 2733 | } |
| 2735 | 2734 | |
@@ -2765,7 +2764,7 @@ discard block |
||
| 2765 | 2764 | ) { |
| 2766 | 2765 | if (isset($GLOBALS['meta']['adresse_site'])) { |
| 2767 | 2766 | $uri_ref = parse_url($GLOBALS['meta']['adresse_site']); |
| 2768 | - $uri_ref = ($uri_ref['path'] ?? '') . '/'; |
|
| 2767 | + $uri_ref = ($uri_ref['path'] ?? '').'/'; |
|
| 2769 | 2768 | } else { |
| 2770 | 2769 | $uri_ref = ''; |
| 2771 | 2770 | } |
@@ -2859,7 +2858,7 @@ discard block |
||
| 2859 | 2858 | } |
| 2860 | 2859 | if (!defined('_CACHE_RUBRIQUES')) { |
| 2861 | 2860 | /** Fichier cache pour le navigateur de rubrique du bandeau */ |
| 2862 | - define('_CACHE_RUBRIQUES', _DIR_TMP . 'menu-rubriques-cache.txt'); |
|
| 2861 | + define('_CACHE_RUBRIQUES', _DIR_TMP.'menu-rubriques-cache.txt'); |
|
| 2863 | 2862 | } |
| 2864 | 2863 | if (!defined('_CACHE_RUBRIQUES_MAX')) { |
| 2865 | 2864 | /** Nombre maxi de rubriques enfants affichées pour chaque rubrique du navigateur de rubrique du bandeau */ |
@@ -2963,7 +2962,7 @@ discard block |
||
| 2963 | 2962 | $memory *= 1024; |
| 2964 | 2963 | } |
| 2965 | 2964 | if ($memory < _MEMORY_LIMIT_MIN * 1024 * 1024) { |
| 2966 | - @ini_set('memory_limit', $m = _MEMORY_LIMIT_MIN . 'M'); |
|
| 2965 | + @ini_set('memory_limit', $m = _MEMORY_LIMIT_MIN.'M'); |
|
| 2967 | 2966 | if (trim(ini_get('memory_limit')) != $m) { |
| 2968 | 2967 | if (!defined('_INTERDIRE_COMPACTE_HEAD_ECRIRE')) { |
| 2969 | 2968 | define('_INTERDIRE_COMPACTE_HEAD_ECRIRE', true); |
@@ -3114,7 +3113,7 @@ discard block |
||
| 3114 | 3113 | } |
| 3115 | 3114 | if (isset($GLOBALS['visiteur_session']['nom'])) { |
| 3116 | 3115 | spip_log($GLOBALS['visiteur_session']['nom'] |
| 3117 | - . ' ' . _VAR_MODE); |
|
| 3116 | + . ' '._VAR_MODE); |
|
| 3118 | 3117 | } |
| 3119 | 3118 | } // pas autorise ? |
| 3120 | 3119 | else { |
@@ -3129,7 +3128,7 @@ discard block |
||
| 3129 | 3128 | if (strpos($self, 'page=login') === false) { |
| 3130 | 3129 | include_spip('inc/headers'); |
| 3131 | 3130 | $redirect = parametre_url(self('&', true), 'var_mode', $_GET['var_mode'], '&'); |
| 3132 | - redirige_par_entete(generer_url_public('login', 'url=' . rawurlencode($redirect), true)); |
|
| 3131 | + redirige_par_entete(generer_url_public('login', 'url='.rawurlencode($redirect), true)); |
|
| 3133 | 3132 | } |
| 3134 | 3133 | } |
| 3135 | 3134 | // sinon tant pis |
@@ -3171,10 +3170,10 @@ discard block |
||
| 3171 | 3170 | // mais on risque de perturber des plugins en initialisant trop tot |
| 3172 | 3171 | // certaines constantes |
| 3173 | 3172 | @spip_initialisation_core( |
| 3174 | - (_DIR_RACINE . _NOM_PERMANENTS_INACCESSIBLES), |
|
| 3175 | - (_DIR_RACINE . _NOM_PERMANENTS_ACCESSIBLES), |
|
| 3176 | - (_DIR_RACINE . _NOM_TEMPORAIRES_INACCESSIBLES), |
|
| 3177 | - (_DIR_RACINE . _NOM_TEMPORAIRES_ACCESSIBLES) |
|
| 3173 | + (_DIR_RACINE._NOM_PERMANENTS_INACCESSIBLES), |
|
| 3174 | + (_DIR_RACINE._NOM_PERMANENTS_ACCESSIBLES), |
|
| 3175 | + (_DIR_RACINE._NOM_TEMPORAIRES_INACCESSIBLES), |
|
| 3176 | + (_DIR_RACINE._NOM_TEMPORAIRES_ACCESSIBLES) |
|
| 3178 | 3177 | ); |
| 3179 | 3178 | |
| 3180 | 3179 | // Demarrer une session NON AUTHENTIFIEE si on donne son nom |
@@ -3207,7 +3206,7 @@ discard block |
||
| 3207 | 3206 | } |
| 3208 | 3207 | |
| 3209 | 3208 | $h = (isset($_SERVER['PHP_AUTH_USER']) and !$GLOBALS['ignore_auth_http']); |
| 3210 | - if ($h or isset($_COOKIE['spip_session']) or isset($_COOKIE[$GLOBALS['cookie_prefix'] . '_session'])) { |
|
| 3209 | + if ($h or isset($_COOKIE['spip_session']) or isset($_COOKIE[$GLOBALS['cookie_prefix'].'_session'])) { |
|
| 3211 | 3210 | $session = charger_fonction('session', 'inc'); |
| 3212 | 3211 | if ($session()) { |
| 3213 | 3212 | return $GLOBALS['visiteur_session']['statut']; |
@@ -3287,7 +3286,7 @@ discard block |
||
| 3287 | 3286 | 'definir_session', |
| 3288 | 3287 | $GLOBALS['visiteur_session'] |
| 3289 | 3288 | ? serialize($GLOBALS['visiteur_session']) |
| 3290 | - . '_' . @$_COOKIE['spip_session'] |
|
| 3289 | + . '_'.@$_COOKIE['spip_session'] |
|
| 3291 | 3290 | : '' |
| 3292 | 3291 | ); |
| 3293 | 3292 | $session = $s ? substr(md5($s), 0, 8) : ''; |
@@ -3443,11 +3442,11 @@ discard block |
||
| 3443 | 3442 | $GLOBALS['_INC_PUBLIC']++; |
| 3444 | 3443 | |
| 3445 | 3444 | // fix #4235 |
| 3446 | - $cache_utilise_session_appelant = ($GLOBALS['cache_utilise_session'] ?? null); |
|
| 3445 | + $cache_utilise_session_appelant = ($GLOBALS['cache_utilise_session'] ?? null); |
|
| 3447 | 3446 | |
| 3448 | 3447 | |
| 3449 | 3448 | foreach (is_array($fond) ? $fond : [$fond] as $f) { |
| 3450 | - unset($GLOBALS['cache_utilise_session']); // fix #4235 |
|
| 3449 | + unset($GLOBALS['cache_utilise_session']); // fix #4235 |
|
| 3451 | 3450 | |
| 3452 | 3451 | $page = evaluer_fond($f, $contexte, $connect); |
| 3453 | 3452 | if ($page === '') { |
@@ -3532,7 +3531,7 @@ discard block |
||
| 3532 | 3531 | * @return array|string |
| 3533 | 3532 | */ |
| 3534 | 3533 | function trouver_fond($nom, $dir = '', $pathinfo = false) { |
| 3535 | - $f = find_in_path($nom . '.' . _EXTENSION_SQUELETTES, $dir ? rtrim($dir, '/') . '/' : ''); |
|
| 3534 | + $f = find_in_path($nom.'.'._EXTENSION_SQUELETTES, $dir ? rtrim($dir, '/').'/' : ''); |
|
| 3536 | 3535 | if (!$pathinfo) { |
| 3537 | 3536 | return $f; |
| 3538 | 3537 | } |
@@ -146,7 +146,7 @@ discard block |
||
| 146 | 146 | if (isset($data[$root])) { # pas de racine sauf pour les rubriques |
| 147 | 147 | $r = "<option$selected value='$root' class='$class' style='$style'>$espace" |
| 148 | 148 | . $data[$root] |
| 149 | - . '</option>' . "\n"; |
|
| 149 | + . '</option>'."\n"; |
|
| 150 | 150 | } else { |
| 151 | 151 | $r = ''; |
| 152 | 152 | } |
@@ -174,7 +174,7 @@ discard block |
||
| 174 | 174 | } |
| 175 | 175 | |
| 176 | 176 | // et voila le travail |
| 177 | - return $r . $sous; |
|
| 177 | + return $r.$sous; |
|
| 178 | 178 | } |
| 179 | 179 | |
| 180 | 180 | /** |
@@ -221,12 +221,12 @@ discard block |
||
| 221 | 221 | while ($r = sql_fetch($q)) { |
| 222 | 222 | if (autoriser('voir', 'rubrique', $r['id_rubrique'])) { |
| 223 | 223 | // titre largeur maxi a 50 |
| 224 | - $titre = couper(supprimer_tags(typo($r['titre'])) . ' ', 50); |
|
| 224 | + $titre = couper(supprimer_tags(typo($r['titre'])).' ', 50); |
|
| 225 | 225 | if ( |
| 226 | 226 | $GLOBALS['meta']['multi_rubriques'] == 'oui' |
| 227 | 227 | and ($r['langue_choisie'] == 'oui' or $r['id_parent'] == 0) |
| 228 | 228 | ) { |
| 229 | - $titre .= ' [' . traduire_nom_langue($r['lang']) . ']'; |
|
| 229 | + $titre .= ' ['.traduire_nom_langue($r['lang']).']'; |
|
| 230 | 230 | } |
| 231 | 231 | $data[$r['id_rubrique']] = $titre; |
| 232 | 232 | $enfants[$r['id_parent']][] = $r['id_rubrique']; |
@@ -253,9 +253,9 @@ discard block |
||
| 253 | 253 | $att = " id='id_parent' name='id_parent'\nclass='selecteur_parent verdana1'"; |
| 254 | 254 | |
| 255 | 255 | if (preg_match(',^<option[^<>]*value=.(\d*).[^<>]*>([^<]*)</option>$,', $opt, $r)) { |
| 256 | - $r = "<input$att type='hidden' value='" . $r[1] . "' />" . $r[2]; |
|
| 256 | + $r = "<input$att type='hidden' value='".$r[1]."' />".$r[2]; |
|
| 257 | 257 | } else { |
| 258 | - $r = '<select' . $att . " size='1'>\n$opt</select>\n"; |
|
| 258 | + $r = '<select'.$att." size='1'>\n$opt</select>\n"; |
|
| 259 | 259 | } |
| 260 | 260 | |
| 261 | 261 | # message pour neuneus (a supprimer ?) |
@@ -297,7 +297,7 @@ discard block |
||
| 297 | 297 | function selecteur_rubrique_ajax($id_rubrique, $type, $restreint, $idem = 0, $do = 'aff') { |
| 298 | 298 | |
| 299 | 299 | if ($id_rubrique) { |
| 300 | - $titre = sql_getfetsel('titre', 'spip_rubriques', 'id_rubrique=' . intval($id_rubrique)); |
|
| 300 | + $titre = sql_getfetsel('titre', 'spip_rubriques', 'id_rubrique='.intval($id_rubrique)); |
|
| 301 | 301 | } else { |
| 302 | 302 | if ($type == 'auteur') { |
| 303 | 303 | $titre = ' '; |
@@ -307,7 +307,7 @@ discard block |
||
| 307 | 307 | } |
| 308 | 308 | |
| 309 | 309 | $titre = str_replace('&', '&', entites_html(textebrut(typo($titre)))); |
| 310 | - $init = " disabled='disabled' type='text' value=\"" . $titre . "\"\nstyle='width:300px;'"; |
|
| 310 | + $init = " disabled='disabled' type='text' value=\"".$titre."\"\nstyle='width:300px;'"; |
|
| 311 | 311 | |
| 312 | 312 | $url = generer_url_ecrire('selectionner', "id=$id_rubrique&type=$type&do=$do" |
| 313 | 313 | . (!$idem ? '' : "&exclus=$idem") |
@@ -356,7 +356,7 @@ discard block |
||
| 356 | 356 | . " jQuery(this).toggleClass('toggled'); " |
| 357 | 357 | . "return charger_node_url_si_vide('" |
| 358 | 358 | . $url |
| 359 | - . "', this.parentNode.nextSibling, this.nextSibling,'',event)\" title='" . attribut_html(_T('titre_image_selecteur')) . "'>" |
|
| 359 | + . "', this.parentNode.nextSibling, this.nextSibling,'',event)\" title='".attribut_html(_T('titre_image_selecteur'))."'>" |
|
| 360 | 360 | . $img_icone |
| 361 | 361 | . "</a><img src='" |
| 362 | 362 | . chemin_image('loader.svg') |
@@ -18,16 +18,16 @@ discard block |
||
| 18 | 18 | **/ |
| 19 | 19 | |
| 20 | 20 | if (!defined('_ECRIRE_INC_VERSION')) { |
| 21 | - return; |
|
| 21 | + return; |
|
| 22 | 22 | } |
| 23 | 23 | |
| 24 | 24 | if (!defined('_SPIP_SELECT_RUBRIQUES')) { |
| 25 | - /** |
|
| 26 | - * @var int Nombre de rubriques maximum du sélecteur de rubriques. |
|
| 27 | - * Au delà, on bascule sur un sélecteur ajax. |
|
| 28 | - * mettre 100000 pour desactiver ajax |
|
| 29 | - */ |
|
| 30 | - define('_SPIP_SELECT_RUBRIQUES', 20); |
|
| 25 | + /** |
|
| 26 | + * @var int Nombre de rubriques maximum du sélecteur de rubriques. |
|
| 27 | + * Au delà, on bascule sur un sélecteur ajax. |
|
| 28 | + * mettre 100000 pour desactiver ajax |
|
| 29 | + */ |
|
| 30 | + define('_SPIP_SELECT_RUBRIQUES', 20); |
|
| 31 | 31 | } |
| 32 | 32 | |
| 33 | 33 | /** |
@@ -55,22 +55,22 @@ discard block |
||
| 55 | 55 | * Code HTML du sélecteur |
| 56 | 56 | **/ |
| 57 | 57 | function inc_chercher_rubrique_dist($id_rubrique, $type, $restreint, $idem = 0, $do = 'aff') { |
| 58 | - if (sql_countsel('spip_rubriques') < 1) { |
|
| 59 | - return ''; |
|
| 60 | - } |
|
| 61 | - |
|
| 62 | - // Mode sans Ajax : |
|
| 63 | - // - soit parce que le cookie ajax n'est pas la |
|
| 64 | - // - soit parce qu'il y a peu de rubriques |
|
| 65 | - if ( |
|
| 66 | - _SPIP_AJAX < 1 |
|
| 67 | - or $type == 'breve' |
|
| 68 | - or sql_countsel('spip_rubriques') < _SPIP_SELECT_RUBRIQUES |
|
| 69 | - ) { |
|
| 70 | - return selecteur_rubrique_html($id_rubrique, $type, $restreint, $idem); |
|
| 71 | - } else { |
|
| 72 | - return selecteur_rubrique_ajax($id_rubrique, $type, $restreint, $idem, $do); |
|
| 73 | - } |
|
| 58 | + if (sql_countsel('spip_rubriques') < 1) { |
|
| 59 | + return ''; |
|
| 60 | + } |
|
| 61 | + |
|
| 62 | + // Mode sans Ajax : |
|
| 63 | + // - soit parce que le cookie ajax n'est pas la |
|
| 64 | + // - soit parce qu'il y a peu de rubriques |
|
| 65 | + if ( |
|
| 66 | + _SPIP_AJAX < 1 |
|
| 67 | + or $type == 'breve' |
|
| 68 | + or sql_countsel('spip_rubriques') < _SPIP_SELECT_RUBRIQUES |
|
| 69 | + ) { |
|
| 70 | + return selecteur_rubrique_html($id_rubrique, $type, $restreint, $idem); |
|
| 71 | + } else { |
|
| 72 | + return selecteur_rubrique_ajax($id_rubrique, $type, $restreint, $idem, $do); |
|
| 73 | + } |
|
| 74 | 74 | } |
| 75 | 75 | |
| 76 | 76 | // compatibilite pour extensions qui utilisaient l'ancien nom |
@@ -87,17 +87,17 @@ discard block |
||
| 87 | 87 | **/ |
| 88 | 88 | function style_menu_rubriques($i) { |
| 89 | 89 | |
| 90 | - $espace = ''; |
|
| 91 | - $style = ''; |
|
| 92 | - for ($count = 1; $count <= $i; $count++) { |
|
| 93 | - $espace .= ' '; |
|
| 94 | - } |
|
| 95 | - if ($i == 1) { |
|
| 96 | - $espace = ''; |
|
| 97 | - } |
|
| 98 | - $class = "niveau_$i"; |
|
| 99 | - |
|
| 100 | - return [$class, $style, $espace]; |
|
| 90 | + $espace = ''; |
|
| 91 | + $style = ''; |
|
| 92 | + for ($count = 1; $count <= $i; $count++) { |
|
| 93 | + $espace .= ' '; |
|
| 94 | + } |
|
| 95 | + if ($i == 1) { |
|
| 96 | + $espace = ''; |
|
| 97 | + } |
|
| 98 | + $class = "niveau_$i"; |
|
| 99 | + |
|
| 100 | + return [$class, $style, $espace]; |
|
| 101 | 101 | } |
| 102 | 102 | |
| 103 | 103 | /** |
@@ -121,60 +121,60 @@ discard block |
||
| 121 | 121 | * Code HTML du sélecteur |
| 122 | 122 | **/ |
| 123 | 123 | function sous_menu_rubriques($id_rubrique, $root, $niv, &$data, &$enfants, $exclus, $restreint, $type) { |
| 124 | - static $decalage_secteur; |
|
| 125 | - |
|
| 126 | - // Si on a demande l'exclusion ne pas descendre dans la rubrique courante |
|
| 127 | - if ( |
|
| 128 | - $exclus > 0 |
|
| 129 | - and $root == $exclus |
|
| 130 | - ) { |
|
| 131 | - return ''; |
|
| 132 | - } |
|
| 133 | - |
|
| 134 | - // en fonction du niveau faire un affichage plus ou moins kikoo |
|
| 135 | - |
|
| 136 | - // selected ? |
|
| 137 | - $selected = ($root == $id_rubrique) ? ' selected="selected"' : ''; |
|
| 138 | - |
|
| 139 | - // le style en fonction de la profondeur |
|
| 140 | - [$class, $style, $espace] = style_menu_rubriques($niv); |
|
| 141 | - |
|
| 142 | - $class .= ' selec_rub'; |
|
| 143 | - |
|
| 144 | - // creer l'<option> pour la rubrique $root |
|
| 145 | - |
|
| 146 | - if (isset($data[$root])) { # pas de racine sauf pour les rubriques |
|
| 147 | - $r = "<option$selected value='$root' class='$class' style='$style'>$espace" |
|
| 148 | - . $data[$root] |
|
| 149 | - . '</option>' . "\n"; |
|
| 150 | - } else { |
|
| 151 | - $r = ''; |
|
| 152 | - } |
|
| 153 | - |
|
| 154 | - // et le sous-menu pour ses enfants |
|
| 155 | - $sous = ''; |
|
| 156 | - if (isset($enfants[$root])) { |
|
| 157 | - foreach ($enfants[$root] as $sousrub) { |
|
| 158 | - $sous .= sous_menu_rubriques( |
|
| 159 | - $id_rubrique, |
|
| 160 | - $sousrub, |
|
| 161 | - $niv + 1, |
|
| 162 | - $data, |
|
| 163 | - $enfants, |
|
| 164 | - $exclus, |
|
| 165 | - $restreint, |
|
| 166 | - $type |
|
| 167 | - ); |
|
| 168 | - } |
|
| 169 | - } |
|
| 170 | - |
|
| 171 | - // si l'objet a deplacer est publie, verifier qu'on a acces aux rubriques |
|
| 172 | - if ($restreint and $root != $id_rubrique and !autoriser('publierdans', 'rubrique', $root)) { |
|
| 173 | - return $sous; |
|
| 174 | - } |
|
| 175 | - |
|
| 176 | - // et voila le travail |
|
| 177 | - return $r . $sous; |
|
| 124 | + static $decalage_secteur; |
|
| 125 | + |
|
| 126 | + // Si on a demande l'exclusion ne pas descendre dans la rubrique courante |
|
| 127 | + if ( |
|
| 128 | + $exclus > 0 |
|
| 129 | + and $root == $exclus |
|
| 130 | + ) { |
|
| 131 | + return ''; |
|
| 132 | + } |
|
| 133 | + |
|
| 134 | + // en fonction du niveau faire un affichage plus ou moins kikoo |
|
| 135 | + |
|
| 136 | + // selected ? |
|
| 137 | + $selected = ($root == $id_rubrique) ? ' selected="selected"' : ''; |
|
| 138 | + |
|
| 139 | + // le style en fonction de la profondeur |
|
| 140 | + [$class, $style, $espace] = style_menu_rubriques($niv); |
|
| 141 | + |
|
| 142 | + $class .= ' selec_rub'; |
|
| 143 | + |
|
| 144 | + // creer l'<option> pour la rubrique $root |
|
| 145 | + |
|
| 146 | + if (isset($data[$root])) { # pas de racine sauf pour les rubriques |
|
| 147 | + $r = "<option$selected value='$root' class='$class' style='$style'>$espace" |
|
| 148 | + . $data[$root] |
|
| 149 | + . '</option>' . "\n"; |
|
| 150 | + } else { |
|
| 151 | + $r = ''; |
|
| 152 | + } |
|
| 153 | + |
|
| 154 | + // et le sous-menu pour ses enfants |
|
| 155 | + $sous = ''; |
|
| 156 | + if (isset($enfants[$root])) { |
|
| 157 | + foreach ($enfants[$root] as $sousrub) { |
|
| 158 | + $sous .= sous_menu_rubriques( |
|
| 159 | + $id_rubrique, |
|
| 160 | + $sousrub, |
|
| 161 | + $niv + 1, |
|
| 162 | + $data, |
|
| 163 | + $enfants, |
|
| 164 | + $exclus, |
|
| 165 | + $restreint, |
|
| 166 | + $type |
|
| 167 | + ); |
|
| 168 | + } |
|
| 169 | + } |
|
| 170 | + |
|
| 171 | + // si l'objet a deplacer est publie, verifier qu'on a acces aux rubriques |
|
| 172 | + if ($restreint and $root != $id_rubrique and !autoriser('publierdans', 'rubrique', $root)) { |
|
| 173 | + return $sous; |
|
| 174 | + } |
|
| 175 | + |
|
| 176 | + // et voila le travail |
|
| 177 | + return $r . $sous; |
|
| 178 | 178 | } |
| 179 | 179 | |
| 180 | 180 | /** |
@@ -195,75 +195,75 @@ discard block |
||
| 195 | 195 | * Code HTML du sélecteur |
| 196 | 196 | **/ |
| 197 | 197 | function selecteur_rubrique_html($id_rubrique, $type, $restreint, $idem = 0) { |
| 198 | - $enfants = []; |
|
| 199 | - $data = []; |
|
| 200 | - if ($type == 'rubrique' and autoriser('publierdans', 'rubrique', 0)) { |
|
| 201 | - $data[0] = _T('info_racine_site'); |
|
| 202 | - } |
|
| 203 | - # premier choix = neant |
|
| 204 | - # si auteur (rubriques restreintes) |
|
| 205 | - # ou si creation avec id_rubrique=0 |
|
| 206 | - elseif ($type == 'auteur' or !$id_rubrique) { |
|
| 207 | - $data[0] = ' '; |
|
| 208 | - } |
|
| 209 | - |
|
| 210 | - // |
|
| 211 | - // creer une structure contenant toute l'arborescence |
|
| 212 | - // |
|
| 213 | - |
|
| 214 | - include_spip('base/abstract_sql'); |
|
| 215 | - $q = sql_select( |
|
| 216 | - 'id_rubrique, id_parent, titre, statut, lang, langue_choisie', |
|
| 217 | - 'spip_rubriques', |
|
| 218 | - ($type == 'breve' ? ' id_parent=0 ' : ''), |
|
| 219 | - '', |
|
| 220 | - '0+titre,titre' |
|
| 221 | - ); |
|
| 222 | - while ($r = sql_fetch($q)) { |
|
| 223 | - if (autoriser('voir', 'rubrique', $r['id_rubrique'])) { |
|
| 224 | - // titre largeur maxi a 50 |
|
| 225 | - $titre = couper(supprimer_tags(typo($r['titre'])) . ' ', 50); |
|
| 226 | - if ( |
|
| 227 | - $GLOBALS['meta']['multi_rubriques'] == 'oui' |
|
| 228 | - and ($r['langue_choisie'] == 'oui' or $r['id_parent'] == 0) |
|
| 229 | - ) { |
|
| 230 | - $titre .= ' [' . traduire_nom_langue($r['lang']) . ']'; |
|
| 231 | - } |
|
| 232 | - $data[$r['id_rubrique']] = $titre; |
|
| 233 | - $enfants[$r['id_parent']][] = $r['id_rubrique']; |
|
| 234 | - if ($id_rubrique == $r['id_rubrique']) { |
|
| 235 | - $id_parent = $r['id_parent']; |
|
| 236 | - } |
|
| 237 | - } |
|
| 238 | - } |
|
| 239 | - |
|
| 240 | - // si une seule rubrique comme choix possible, |
|
| 241 | - // inutile de mettre le selecteur sur un choix vide par defaut |
|
| 242 | - // sauf si le selecteur s'adresse a une rubrique puisque on peut la mettre a la racine dans ce cas |
|
| 243 | - if ( |
|
| 244 | - count($data) == 2 |
|
| 245 | - and isset($data[0]) |
|
| 246 | - and !in_array($type, ['auteur', 'rubrique']) |
|
| 247 | - and !$id_rubrique |
|
| 248 | - ) { |
|
| 249 | - unset($data[0]); |
|
| 250 | - } |
|
| 251 | - |
|
| 252 | - |
|
| 253 | - $opt = sous_menu_rubriques($id_rubrique, 0, 0, $data, $enfants, $idem, $restreint, $type); |
|
| 254 | - $att = " id='id_parent' name='id_parent'\nclass='selecteur_parent verdana1'"; |
|
| 255 | - |
|
| 256 | - if (preg_match(',^<option[^<>]*value=.(\d*).[^<>]*>([^<]*)</option>$,', $opt, $r)) { |
|
| 257 | - $r = "<input$att type='hidden' value='" . $r[1] . "' />" . $r[2]; |
|
| 258 | - } else { |
|
| 259 | - $r = '<select' . $att . " size='1'>\n$opt</select>\n"; |
|
| 260 | - } |
|
| 261 | - |
|
| 262 | - # message pour neuneus (a supprimer ?) |
|
| 198 | + $enfants = []; |
|
| 199 | + $data = []; |
|
| 200 | + if ($type == 'rubrique' and autoriser('publierdans', 'rubrique', 0)) { |
|
| 201 | + $data[0] = _T('info_racine_site'); |
|
| 202 | + } |
|
| 203 | + # premier choix = neant |
|
| 204 | + # si auteur (rubriques restreintes) |
|
| 205 | + # ou si creation avec id_rubrique=0 |
|
| 206 | + elseif ($type == 'auteur' or !$id_rubrique) { |
|
| 207 | + $data[0] = ' '; |
|
| 208 | + } |
|
| 209 | + |
|
| 210 | + // |
|
| 211 | + // creer une structure contenant toute l'arborescence |
|
| 212 | + // |
|
| 213 | + |
|
| 214 | + include_spip('base/abstract_sql'); |
|
| 215 | + $q = sql_select( |
|
| 216 | + 'id_rubrique, id_parent, titre, statut, lang, langue_choisie', |
|
| 217 | + 'spip_rubriques', |
|
| 218 | + ($type == 'breve' ? ' id_parent=0 ' : ''), |
|
| 219 | + '', |
|
| 220 | + '0+titre,titre' |
|
| 221 | + ); |
|
| 222 | + while ($r = sql_fetch($q)) { |
|
| 223 | + if (autoriser('voir', 'rubrique', $r['id_rubrique'])) { |
|
| 224 | + // titre largeur maxi a 50 |
|
| 225 | + $titre = couper(supprimer_tags(typo($r['titre'])) . ' ', 50); |
|
| 226 | + if ( |
|
| 227 | + $GLOBALS['meta']['multi_rubriques'] == 'oui' |
|
| 228 | + and ($r['langue_choisie'] == 'oui' or $r['id_parent'] == 0) |
|
| 229 | + ) { |
|
| 230 | + $titre .= ' [' . traduire_nom_langue($r['lang']) . ']'; |
|
| 231 | + } |
|
| 232 | + $data[$r['id_rubrique']] = $titre; |
|
| 233 | + $enfants[$r['id_parent']][] = $r['id_rubrique']; |
|
| 234 | + if ($id_rubrique == $r['id_rubrique']) { |
|
| 235 | + $id_parent = $r['id_parent']; |
|
| 236 | + } |
|
| 237 | + } |
|
| 238 | + } |
|
| 239 | + |
|
| 240 | + // si une seule rubrique comme choix possible, |
|
| 241 | + // inutile de mettre le selecteur sur un choix vide par defaut |
|
| 242 | + // sauf si le selecteur s'adresse a une rubrique puisque on peut la mettre a la racine dans ce cas |
|
| 243 | + if ( |
|
| 244 | + count($data) == 2 |
|
| 245 | + and isset($data[0]) |
|
| 246 | + and !in_array($type, ['auteur', 'rubrique']) |
|
| 247 | + and !$id_rubrique |
|
| 248 | + ) { |
|
| 249 | + unset($data[0]); |
|
| 250 | + } |
|
| 251 | + |
|
| 252 | + |
|
| 253 | + $opt = sous_menu_rubriques($id_rubrique, 0, 0, $data, $enfants, $idem, $restreint, $type); |
|
| 254 | + $att = " id='id_parent' name='id_parent'\nclass='selecteur_parent verdana1'"; |
|
| 255 | + |
|
| 256 | + if (preg_match(',^<option[^<>]*value=.(\d*).[^<>]*>([^<]*)</option>$,', $opt, $r)) { |
|
| 257 | + $r = "<input$att type='hidden' value='" . $r[1] . "' />" . $r[2]; |
|
| 258 | + } else { |
|
| 259 | + $r = '<select' . $att . " size='1'>\n$opt</select>\n"; |
|
| 260 | + } |
|
| 261 | + |
|
| 262 | + # message pour neuneus (a supprimer ?) |
|
| 263 | 263 | # if ($type != 'auteur' AND $type != 'breve') |
| 264 | 264 | # $r .= "\n<br />"._T('texte_rappel_selection_champs'); |
| 265 | 265 | |
| 266 | - return $r; |
|
| 266 | + return $r; |
|
| 267 | 267 | } |
| 268 | 268 | |
| 269 | 269 | /** |
@@ -297,26 +297,26 @@ discard block |
||
| 297 | 297 | */ |
| 298 | 298 | function selecteur_rubrique_ajax($id_rubrique, $type, $restreint, $idem = 0, $do = 'aff') { |
| 299 | 299 | |
| 300 | - if ($id_rubrique) { |
|
| 301 | - $titre = sql_getfetsel('titre', 'spip_rubriques', 'id_rubrique=' . intval($id_rubrique)); |
|
| 302 | - } else { |
|
| 303 | - if ($type == 'auteur') { |
|
| 304 | - $titre = ' '; |
|
| 305 | - } else { |
|
| 306 | - $titre = _T('info_racine_site'); |
|
| 307 | - } |
|
| 308 | - } |
|
| 300 | + if ($id_rubrique) { |
|
| 301 | + $titre = sql_getfetsel('titre', 'spip_rubriques', 'id_rubrique=' . intval($id_rubrique)); |
|
| 302 | + } else { |
|
| 303 | + if ($type == 'auteur') { |
|
| 304 | + $titre = ' '; |
|
| 305 | + } else { |
|
| 306 | + $titre = _T('info_racine_site'); |
|
| 307 | + } |
|
| 308 | + } |
|
| 309 | 309 | |
| 310 | - $titre = str_replace('&', '&', entites_html(textebrut(typo($titre)))); |
|
| 311 | - $init = " disabled='disabled' type='text' value=\"" . $titre . "\"\nstyle='width:300px;'"; |
|
| 310 | + $titre = str_replace('&', '&', entites_html(textebrut(typo($titre)))); |
|
| 311 | + $init = " disabled='disabled' type='text' value=\"" . $titre . "\"\nstyle='width:300px;'"; |
|
| 312 | 312 | |
| 313 | - $url = generer_url_ecrire('selectionner', "id=$id_rubrique&type=$type&do=$do" |
|
| 314 | - . (!$idem ? '' : "&exclus=$idem") |
|
| 315 | - . ($restreint ? '' : '&racine=oui') |
|
| 316 | - . (isset($GLOBALS['var_profile']) ? '&var_profile=1' : '')); |
|
| 313 | + $url = generer_url_ecrire('selectionner', "id=$id_rubrique&type=$type&do=$do" |
|
| 314 | + . (!$idem ? '' : "&exclus=$idem") |
|
| 315 | + . ($restreint ? '' : '&racine=oui') |
|
| 316 | + . (isset($GLOBALS['var_profile']) ? '&var_profile=1' : '')); |
|
| 317 | 317 | |
| 318 | 318 | |
| 319 | - return construire_selecteur($url, '', 'selection_rubrique', 'id_parent', $init, $id_rubrique); |
|
| 319 | + return construire_selecteur($url, '', 'selection_rubrique', 'id_parent', $init, $id_rubrique); |
|
| 320 | 320 | } |
| 321 | 321 | |
| 322 | 322 | /** |
@@ -346,30 +346,30 @@ discard block |
||
| 346 | 346 | * Code HTML du sélecteur de rubrique AJAX |
| 347 | 347 | **/ |
| 348 | 348 | function construire_selecteur($url, $js, $idom, $name, $init = '', $id = 0) { |
| 349 | - $icone = (strpos($idom, 'auteur') !== false) ? 'auteur-24.png' : 'rechercher-20.png'; |
|
| 350 | - // si icone de recherche on embed le svg |
|
| 351 | - $balise = ($icone === 'rechercher-20.png' ? chercher_filtre('balise_svg') : chercher_filtre('balise_img')); |
|
| 352 | - $img_icone = $balise(chemin_image($icone), _T('titre_image_selecteur')); |
|
| 353 | - |
|
| 354 | - return |
|
| 355 | - "<div class='rubrique_actuelle'><a href='#' class='rubrique-search' role='button' style='display:inline-flex;vertical-align:middle;' onclick=\"" |
|
| 356 | - . $js |
|
| 357 | - . " jQuery(this).toggleClass('toggled'); " |
|
| 358 | - . "return charger_node_url_si_vide('" |
|
| 359 | - . $url |
|
| 360 | - . "', this.parentNode.nextSibling, this.nextSibling,'',event)\" title='" . attribut_html(_T('titre_image_selecteur')) . "'>" |
|
| 361 | - . $img_icone |
|
| 362 | - . "</a><img src='" |
|
| 363 | - . chemin_image('loader.svg') |
|
| 364 | - . "' class='loader' id='img_" |
|
| 365 | - . $idom |
|
| 366 | - . "'\nstyle='visibility: hidden;' alt='*' />" |
|
| 367 | - . "<input id='titreparent' name='titreparent' class='text'" |
|
| 368 | - . $init |
|
| 369 | - . ' />' |
|
| 370 | - . "<input type='hidden' id='$name' name='$name' value='" |
|
| 371 | - . $id |
|
| 372 | - . "' /><div class='nettoyeur'></div></div><div id='" |
|
| 373 | - . $idom |
|
| 374 | - . "'\nstyle='display: none;'></div>"; |
|
| 349 | + $icone = (strpos($idom, 'auteur') !== false) ? 'auteur-24.png' : 'rechercher-20.png'; |
|
| 350 | + // si icone de recherche on embed le svg |
|
| 351 | + $balise = ($icone === 'rechercher-20.png' ? chercher_filtre('balise_svg') : chercher_filtre('balise_img')); |
|
| 352 | + $img_icone = $balise(chemin_image($icone), _T('titre_image_selecteur')); |
|
| 353 | + |
|
| 354 | + return |
|
| 355 | + "<div class='rubrique_actuelle'><a href='#' class='rubrique-search' role='button' style='display:inline-flex;vertical-align:middle;' onclick=\"" |
|
| 356 | + . $js |
|
| 357 | + . " jQuery(this).toggleClass('toggled'); " |
|
| 358 | + . "return charger_node_url_si_vide('" |
|
| 359 | + . $url |
|
| 360 | + . "', this.parentNode.nextSibling, this.nextSibling,'',event)\" title='" . attribut_html(_T('titre_image_selecteur')) . "'>" |
|
| 361 | + . $img_icone |
|
| 362 | + . "</a><img src='" |
|
| 363 | + . chemin_image('loader.svg') |
|
| 364 | + . "' class='loader' id='img_" |
|
| 365 | + . $idom |
|
| 366 | + . "'\nstyle='visibility: hidden;' alt='*' />" |
|
| 367 | + . "<input id='titreparent' name='titreparent' class='text'" |
|
| 368 | + . $init |
|
| 369 | + . ' />' |
|
| 370 | + . "<input type='hidden' id='$name' name='$name' value='" |
|
| 371 | + . $id |
|
| 372 | + . "' /><div class='nettoyeur'></div></div><div id='" |
|
| 373 | + . $idom |
|
| 374 | + . "'\nstyle='display: none;'></div>"; |
|
| 375 | 375 | } |
@@ -65,7 +65,7 @@ discard block |
||
| 65 | 65 | renouvelle_alea(); |
| 66 | 66 | $new = false; |
| 67 | 67 | } else { |
| 68 | - spip_log("impossible d'ecrire dans " . $cache); |
|
| 68 | + spip_log("impossible d'ecrire dans ".$cache); |
|
| 69 | 69 | } |
| 70 | 70 | } |
| 71 | 71 | // et refaire le cache si on a du lire en base |
@@ -166,7 +166,7 @@ discard block |
||
| 166 | 166 | if (!isset($touch[$table])) { |
| 167 | 167 | touch_meta($antidate, $table); |
| 168 | 168 | } |
| 169 | - sql_delete('spip_' . $table, "nom='$nom'", '', 'continue'); |
|
| 169 | + sql_delete('spip_'.$table, "nom='$nom'", '', 'continue'); |
|
| 170 | 170 | unset($GLOBALS[$table][$nom]); |
| 171 | 171 | if (!isset($touch[$table])) { |
| 172 | 172 | touch_meta($antidate, $table); |
@@ -197,7 +197,7 @@ discard block |
||
| 197 | 197 | return; |
| 198 | 198 | } |
| 199 | 199 | include_spip('base/abstract_sql'); |
| 200 | - $res = sql_select('*', 'spip_' . $table, 'nom=' . sql_quote($nom), '', '', '', '', '', 'continue'); |
|
| 200 | + $res = sql_select('*', 'spip_'.$table, 'nom='.sql_quote($nom), '', '', '', '', '', 'continue'); |
|
| 201 | 201 | // table pas encore installee, travailler en php seulement |
| 202 | 202 | if (!$res) { |
| 203 | 203 | $GLOBALS[$table][$nom] = $valeur; |
@@ -231,9 +231,9 @@ discard block |
||
| 231 | 231 | $r['impt'] = sql_quote($importable, '', 'text'); |
| 232 | 232 | } |
| 233 | 233 | if ($row) { |
| 234 | - sql_update('spip_' . $table, $r, 'nom=' . sql_quote($nom)); |
|
| 234 | + sql_update('spip_'.$table, $r, 'nom='.sql_quote($nom)); |
|
| 235 | 235 | } else { |
| 236 | - sql_insert('spip_' . $table, '(' . join(',', array_keys($r)) . ')', '(' . join(',', array_values($r)) . ')'); |
|
| 236 | + sql_insert('spip_'.$table, '('.join(',', array_keys($r)).')', '('.join(',', array_values($r)).')'); |
|
| 237 | 237 | } |
| 238 | 238 | if (!isset($touch[$table])) { |
| 239 | 239 | touch_meta($antidate, $table); |
@@ -250,7 +250,7 @@ discard block |
||
| 250 | 250 | * Nom du fichier cache |
| 251 | 251 | **/ |
| 252 | 252 | function cache_meta($table = 'meta') { |
| 253 | - return ($table == 'meta') ? _FILE_META : (_DIR_CACHE . $table . '.php'); |
|
| 253 | + return ($table == 'meta') ? _FILE_META : (_DIR_CACHE.$table.'.php'); |
|
| 254 | 254 | } |
| 255 | 255 | |
| 256 | 256 | /** |
@@ -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 | // Les parametres generaux du site sont dans une table SQL; |
@@ -27,51 +27,51 @@ discard block |
||
| 27 | 27 | define('_META_CACHE_TIME', 1 << 24); |
| 28 | 28 | |
| 29 | 29 | function inc_meta_dist($table = 'meta') { |
| 30 | - $new = null; |
|
| 31 | - // Lire les meta, en cache si present, valide et lisible |
|
| 32 | - // en cas d'install ne pas faire confiance au meta_cache eventuel |
|
| 33 | - $cache = cache_meta($table); |
|
| 30 | + $new = null; |
|
| 31 | + // Lire les meta, en cache si present, valide et lisible |
|
| 32 | + // en cas d'install ne pas faire confiance au meta_cache eventuel |
|
| 33 | + $cache = cache_meta($table); |
|
| 34 | 34 | |
| 35 | - if ( |
|
| 36 | - (!$exec = _request('exec') or !autoriser_sans_cookie($exec)) |
|
| 37 | - and $new = jeune_fichier($cache, _META_CACHE_TIME) |
|
| 38 | - and lire_fichier_securise($cache, $meta) |
|
| 39 | - and $meta = @unserialize($meta) |
|
| 40 | - ) { |
|
| 41 | - $GLOBALS[$table] = $meta; |
|
| 42 | - } |
|
| 35 | + if ( |
|
| 36 | + (!$exec = _request('exec') or !autoriser_sans_cookie($exec)) |
|
| 37 | + and $new = jeune_fichier($cache, _META_CACHE_TIME) |
|
| 38 | + and lire_fichier_securise($cache, $meta) |
|
| 39 | + and $meta = @unserialize($meta) |
|
| 40 | + ) { |
|
| 41 | + $GLOBALS[$table] = $meta; |
|
| 42 | + } |
|
| 43 | 43 | |
| 44 | - if ( |
|
| 45 | - isset($GLOBALS[$table]['touch']) |
|
| 46 | - and ($GLOBALS[$table]['touch'] < time() - _META_CACHE_TIME) |
|
| 47 | - ) { |
|
| 48 | - $GLOBALS[$table] = []; |
|
| 49 | - } |
|
| 50 | - // sinon lire en base |
|
| 51 | - if (!$GLOBALS[$table]) { |
|
| 52 | - $new = !lire_metas($table); |
|
| 53 | - } |
|
| 44 | + if ( |
|
| 45 | + isset($GLOBALS[$table]['touch']) |
|
| 46 | + and ($GLOBALS[$table]['touch'] < time() - _META_CACHE_TIME) |
|
| 47 | + ) { |
|
| 48 | + $GLOBALS[$table] = []; |
|
| 49 | + } |
|
| 50 | + // sinon lire en base |
|
| 51 | + if (!$GLOBALS[$table]) { |
|
| 52 | + $new = !lire_metas($table); |
|
| 53 | + } |
|
| 54 | 54 | |
| 55 | - // renouveller l'alea general si trop vieux ou sur demande explicite |
|
| 56 | - if ( |
|
| 57 | - (test_espace_prive() || isset($_GET['renouvelle_alea'])) |
|
| 58 | - and $GLOBALS[$table] |
|
| 59 | - and (time() > _RENOUVELLE_ALEA + ($GLOBALS['meta']['alea_ephemere_date'] ?? 0)) |
|
| 60 | - ) { |
|
| 61 | - // si on n'a pas l'acces en ecriture sur le cache, |
|
| 62 | - // ne pas renouveller l'alea sinon le cache devient faux |
|
| 63 | - if (supprimer_fichier($cache)) { |
|
| 64 | - include_spip('inc/acces'); |
|
| 65 | - renouvelle_alea(); |
|
| 66 | - $new = false; |
|
| 67 | - } else { |
|
| 68 | - spip_log("impossible d'ecrire dans " . $cache); |
|
| 69 | - } |
|
| 70 | - } |
|
| 71 | - // et refaire le cache si on a du lire en base |
|
| 72 | - if (!$new) { |
|
| 73 | - touch_meta(false, $table); |
|
| 74 | - } |
|
| 55 | + // renouveller l'alea general si trop vieux ou sur demande explicite |
|
| 56 | + if ( |
|
| 57 | + (test_espace_prive() || isset($_GET['renouvelle_alea'])) |
|
| 58 | + and $GLOBALS[$table] |
|
| 59 | + and (time() > _RENOUVELLE_ALEA + ($GLOBALS['meta']['alea_ephemere_date'] ?? 0)) |
|
| 60 | + ) { |
|
| 61 | + // si on n'a pas l'acces en ecriture sur le cache, |
|
| 62 | + // ne pas renouveller l'alea sinon le cache devient faux |
|
| 63 | + if (supprimer_fichier($cache)) { |
|
| 64 | + include_spip('inc/acces'); |
|
| 65 | + renouvelle_alea(); |
|
| 66 | + $new = false; |
|
| 67 | + } else { |
|
| 68 | + spip_log("impossible d'ecrire dans " . $cache); |
|
| 69 | + } |
|
| 70 | + } |
|
| 71 | + // et refaire le cache si on a du lire en base |
|
| 72 | + if (!$new) { |
|
| 73 | + touch_meta(false, $table); |
|
| 74 | + } |
|
| 75 | 75 | } |
| 76 | 76 | |
| 77 | 77 | // fonctions aussi appelees a l'install ==> spip_query en premiere requete |
@@ -79,39 +79,39 @@ discard block |
||
| 79 | 79 | |
| 80 | 80 | function lire_metas($table = 'meta') { |
| 81 | 81 | |
| 82 | - if ($result = spip_query("SELECT nom,valeur FROM spip_$table")) { |
|
| 83 | - include_spip('base/abstract_sql'); |
|
| 84 | - $GLOBALS[$table] = []; |
|
| 85 | - while ($row = sql_fetch($result)) { |
|
| 86 | - $GLOBALS[$table][$row['nom']] = $row['valeur']; |
|
| 87 | - } |
|
| 88 | - sql_free($result); |
|
| 82 | + if ($result = spip_query("SELECT nom,valeur FROM spip_$table")) { |
|
| 83 | + include_spip('base/abstract_sql'); |
|
| 84 | + $GLOBALS[$table] = []; |
|
| 85 | + while ($row = sql_fetch($result)) { |
|
| 86 | + $GLOBALS[$table][$row['nom']] = $row['valeur']; |
|
| 87 | + } |
|
| 88 | + sql_free($result); |
|
| 89 | 89 | |
| 90 | - if ( |
|
| 91 | - !isset($GLOBALS[$table]['charset']) |
|
| 92 | - or !$GLOBALS[$table]['charset'] |
|
| 93 | - or $GLOBALS[$table]['charset'] == '_DEFAULT_CHARSET' // hum, correction d'un bug ayant abime quelques install |
|
| 94 | - ) { |
|
| 95 | - ecrire_meta('charset', _DEFAULT_CHARSET, null, $table); |
|
| 96 | - } |
|
| 90 | + if ( |
|
| 91 | + !isset($GLOBALS[$table]['charset']) |
|
| 92 | + or !$GLOBALS[$table]['charset'] |
|
| 93 | + or $GLOBALS[$table]['charset'] == '_DEFAULT_CHARSET' // hum, correction d'un bug ayant abime quelques install |
|
| 94 | + ) { |
|
| 95 | + ecrire_meta('charset', _DEFAULT_CHARSET, null, $table); |
|
| 96 | + } |
|
| 97 | 97 | |
| 98 | - // noter cette table de configuration dans les meta de SPIP |
|
| 99 | - if ($table !== 'meta') { |
|
| 100 | - $liste = []; |
|
| 101 | - if (isset($GLOBALS['meta']['tables_config'])) { |
|
| 102 | - $liste = unserialize($GLOBALS['meta']['tables_config']); |
|
| 103 | - } |
|
| 104 | - if (!$liste) { |
|
| 105 | - $liste = []; |
|
| 106 | - } |
|
| 107 | - if (!in_array($table, $liste)) { |
|
| 108 | - $liste[] = $table; |
|
| 109 | - ecrire_meta('tables_config', serialize($liste)); |
|
| 110 | - } |
|
| 111 | - } |
|
| 112 | - } |
|
| 98 | + // noter cette table de configuration dans les meta de SPIP |
|
| 99 | + if ($table !== 'meta') { |
|
| 100 | + $liste = []; |
|
| 101 | + if (isset($GLOBALS['meta']['tables_config'])) { |
|
| 102 | + $liste = unserialize($GLOBALS['meta']['tables_config']); |
|
| 103 | + } |
|
| 104 | + if (!$liste) { |
|
| 105 | + $liste = []; |
|
| 106 | + } |
|
| 107 | + if (!in_array($table, $liste)) { |
|
| 108 | + $liste[] = $table; |
|
| 109 | + ecrire_meta('tables_config', serialize($liste)); |
|
| 110 | + } |
|
| 111 | + } |
|
| 112 | + } |
|
| 113 | 113 | |
| 114 | - return $GLOBALS[$table] ?? null; |
|
| 114 | + return $GLOBALS[$table] ?? null; |
|
| 115 | 115 | } |
| 116 | 116 | |
| 117 | 117 | |
@@ -125,22 +125,22 @@ discard block |
||
| 125 | 125 | * Table SQL d'enregistrement des meta. |
| 126 | 126 | **/ |
| 127 | 127 | function touch_meta($antidate = false, $table = 'meta') { |
| 128 | - $file = cache_meta($table); |
|
| 129 | - if (!$antidate or !@touch($file, $antidate)) { |
|
| 130 | - $r = $GLOBALS[$table] ?? []; |
|
| 131 | - if ($table == 'meta') { |
|
| 132 | - unset($r['alea_ephemere']); |
|
| 133 | - unset($r['alea_ephemere_ancien']); |
|
| 134 | - // le secret du site est utilise pour encoder les contextes ajax que l'on considere fiables |
|
| 135 | - // mais le sortir deu cache meta implique une requete sql des qu'on a un form dynamique |
|
| 136 | - // meme si son squelette est en cache |
|
| 137 | - //unset($r['secret_du_site']); |
|
| 138 | - if ($antidate) { |
|
| 139 | - $r['touch'] = $antidate; |
|
| 140 | - } |
|
| 141 | - } |
|
| 142 | - ecrire_fichier_securise($file, serialize($r)); |
|
| 143 | - } |
|
| 128 | + $file = cache_meta($table); |
|
| 129 | + if (!$antidate or !@touch($file, $antidate)) { |
|
| 130 | + $r = $GLOBALS[$table] ?? []; |
|
| 131 | + if ($table == 'meta') { |
|
| 132 | + unset($r['alea_ephemere']); |
|
| 133 | + unset($r['alea_ephemere_ancien']); |
|
| 134 | + // le secret du site est utilise pour encoder les contextes ajax que l'on considere fiables |
|
| 135 | + // mais le sortir deu cache meta implique une requete sql des qu'on a un form dynamique |
|
| 136 | + // meme si son squelette est en cache |
|
| 137 | + //unset($r['secret_du_site']); |
|
| 138 | + if ($antidate) { |
|
| 139 | + $r['touch'] = $antidate; |
|
| 140 | + } |
|
| 141 | + } |
|
| 142 | + ecrire_fichier_securise($file, serialize($r)); |
|
| 143 | + } |
|
| 144 | 144 | } |
| 145 | 145 | |
| 146 | 146 | /** |
@@ -156,21 +156,21 @@ discard block |
||
| 156 | 156 | * Table SQL d'enregistrement de la meta. |
| 157 | 157 | **/ |
| 158 | 158 | function effacer_meta($nom, $table = 'meta') { |
| 159 | - // section critique sur le cache: |
|
| 160 | - // l'invalider avant et apres la MAJ de la BD |
|
| 161 | - // c'est un peu moins bien qu'un vrai verrou mais ca suffira |
|
| 162 | - // et utiliser une statique pour eviter des acces disques a repetition |
|
| 163 | - static $touch = []; |
|
| 164 | - $antidate = time() - (_META_CACHE_TIME << 4); |
|
| 165 | - if (!isset($touch[$table])) { |
|
| 166 | - touch_meta($antidate, $table); |
|
| 167 | - } |
|
| 168 | - sql_delete('spip_' . $table, "nom='$nom'", '', 'continue'); |
|
| 169 | - unset($GLOBALS[$table][$nom]); |
|
| 170 | - if (!isset($touch[$table])) { |
|
| 171 | - touch_meta($antidate, $table); |
|
| 172 | - $touch[$table] = false; |
|
| 173 | - } |
|
| 159 | + // section critique sur le cache: |
|
| 160 | + // l'invalider avant et apres la MAJ de la BD |
|
| 161 | + // c'est un peu moins bien qu'un vrai verrou mais ca suffira |
|
| 162 | + // et utiliser une statique pour eviter des acces disques a repetition |
|
| 163 | + static $touch = []; |
|
| 164 | + $antidate = time() - (_META_CACHE_TIME << 4); |
|
| 165 | + if (!isset($touch[$table])) { |
|
| 166 | + touch_meta($antidate, $table); |
|
| 167 | + } |
|
| 168 | + sql_delete('spip_' . $table, "nom='$nom'", '', 'continue'); |
|
| 169 | + unset($GLOBALS[$table][$nom]); |
|
| 170 | + if (!isset($touch[$table])) { |
|
| 171 | + touch_meta($antidate, $table); |
|
| 172 | + $touch[$table] = false; |
|
| 173 | + } |
|
| 174 | 174 | } |
| 175 | 175 | |
| 176 | 176 | /** |
@@ -191,53 +191,53 @@ discard block |
||
| 191 | 191 | **/ |
| 192 | 192 | function ecrire_meta($nom, $valeur, $importable = null, $table = 'meta') { |
| 193 | 193 | |
| 194 | - static $touch = []; |
|
| 195 | - if (!$nom) { |
|
| 196 | - return; |
|
| 197 | - } |
|
| 198 | - include_spip('base/abstract_sql'); |
|
| 199 | - $res = sql_select('*', 'spip_' . $table, 'nom=' . sql_quote($nom), '', '', '', '', '', 'continue'); |
|
| 200 | - // table pas encore installee, travailler en php seulement |
|
| 201 | - if (!$res) { |
|
| 202 | - $GLOBALS[$table][$nom] = $valeur; |
|
| 194 | + static $touch = []; |
|
| 195 | + if (!$nom) { |
|
| 196 | + return; |
|
| 197 | + } |
|
| 198 | + include_spip('base/abstract_sql'); |
|
| 199 | + $res = sql_select('*', 'spip_' . $table, 'nom=' . sql_quote($nom), '', '', '', '', '', 'continue'); |
|
| 200 | + // table pas encore installee, travailler en php seulement |
|
| 201 | + if (!$res) { |
|
| 202 | + $GLOBALS[$table][$nom] = $valeur; |
|
| 203 | 203 | |
| 204 | - return; |
|
| 205 | - } |
|
| 206 | - $row = sql_fetch($res); |
|
| 207 | - sql_free($res); |
|
| 204 | + return; |
|
| 205 | + } |
|
| 206 | + $row = sql_fetch($res); |
|
| 207 | + sql_free($res); |
|
| 208 | 208 | |
| 209 | - // ne pas invalider le cache si affectation a l'identique |
|
| 210 | - // (tant pis si impt aurait du changer) |
|
| 211 | - if ( |
|
| 212 | - $row and $valeur == $row['valeur'] |
|
| 213 | - and isset($GLOBALS[$table][$nom]) |
|
| 214 | - and $GLOBALS[$table][$nom] == $valeur |
|
| 215 | - ) { |
|
| 216 | - return; |
|
| 217 | - } |
|
| 209 | + // ne pas invalider le cache si affectation a l'identique |
|
| 210 | + // (tant pis si impt aurait du changer) |
|
| 211 | + if ( |
|
| 212 | + $row and $valeur == $row['valeur'] |
|
| 213 | + and isset($GLOBALS[$table][$nom]) |
|
| 214 | + and $GLOBALS[$table][$nom] == $valeur |
|
| 215 | + ) { |
|
| 216 | + return; |
|
| 217 | + } |
|
| 218 | 218 | |
| 219 | - $GLOBALS[$table][$nom] = $valeur; |
|
| 220 | - // cf effacer pour comprendre le double touch |
|
| 221 | - $antidate = time() - (_META_CACHE_TIME << 1); |
|
| 222 | - if (!isset($touch[$table])) { |
|
| 223 | - touch_meta($antidate, $table); |
|
| 224 | - } |
|
| 225 | - $r = ['nom' => sql_quote($nom, '', 'text'), 'valeur' => sql_quote($valeur, '', 'text')]; |
|
| 226 | - // Gaffe aux tables sans impt (vieilles versions de SPIP notamment) |
|
| 227 | - // ici on utilise pas sql_updateq et sql_insertq pour ne pas provoquer trop tot |
|
| 228 | - // de lecture des descriptions des tables |
|
| 229 | - if ($importable and isset($row['impt'])) { |
|
| 230 | - $r['impt'] = sql_quote($importable, '', 'text'); |
|
| 231 | - } |
|
| 232 | - if ($row) { |
|
| 233 | - sql_update('spip_' . $table, $r, 'nom=' . sql_quote($nom)); |
|
| 234 | - } else { |
|
| 235 | - sql_insert('spip_' . $table, '(' . join(',', array_keys($r)) . ')', '(' . join(',', array_values($r)) . ')'); |
|
| 236 | - } |
|
| 237 | - if (!isset($touch[$table])) { |
|
| 238 | - touch_meta($antidate, $table); |
|
| 239 | - $touch[$table] = false; |
|
| 240 | - } |
|
| 219 | + $GLOBALS[$table][$nom] = $valeur; |
|
| 220 | + // cf effacer pour comprendre le double touch |
|
| 221 | + $antidate = time() - (_META_CACHE_TIME << 1); |
|
| 222 | + if (!isset($touch[$table])) { |
|
| 223 | + touch_meta($antidate, $table); |
|
| 224 | + } |
|
| 225 | + $r = ['nom' => sql_quote($nom, '', 'text'), 'valeur' => sql_quote($valeur, '', 'text')]; |
|
| 226 | + // Gaffe aux tables sans impt (vieilles versions de SPIP notamment) |
|
| 227 | + // ici on utilise pas sql_updateq et sql_insertq pour ne pas provoquer trop tot |
|
| 228 | + // de lecture des descriptions des tables |
|
| 229 | + if ($importable and isset($row['impt'])) { |
|
| 230 | + $r['impt'] = sql_quote($importable, '', 'text'); |
|
| 231 | + } |
|
| 232 | + if ($row) { |
|
| 233 | + sql_update('spip_' . $table, $r, 'nom=' . sql_quote($nom)); |
|
| 234 | + } else { |
|
| 235 | + sql_insert('spip_' . $table, '(' . join(',', array_keys($r)) . ')', '(' . join(',', array_values($r)) . ')'); |
|
| 236 | + } |
|
| 237 | + if (!isset($touch[$table])) { |
|
| 238 | + touch_meta($antidate, $table); |
|
| 239 | + $touch[$table] = false; |
|
| 240 | + } |
|
| 241 | 241 | } |
| 242 | 242 | |
| 243 | 243 | /** |
@@ -249,7 +249,7 @@ discard block |
||
| 249 | 249 | * Nom du fichier cache |
| 250 | 250 | **/ |
| 251 | 251 | function cache_meta($table = 'meta') { |
| 252 | - return ($table == 'meta') ? _FILE_META : (_DIR_CACHE . $table . '.php'); |
|
| 252 | + return ($table == 'meta') ? _FILE_META : (_DIR_CACHE . $table . '.php'); |
|
| 253 | 253 | } |
| 254 | 254 | |
| 255 | 255 | /** |
@@ -258,14 +258,14 @@ discard block |
||
| 258 | 258 | * @param string $table |
| 259 | 259 | */ |
| 260 | 260 | function installer_table_meta($table) { |
| 261 | - $trouver_table = charger_fonction('trouver_table', 'base'); |
|
| 262 | - if (!$trouver_table("spip_$table")) { |
|
| 263 | - include_spip('base/auxiliaires'); |
|
| 264 | - include_spip('base/create'); |
|
| 265 | - creer_ou_upgrader_table("spip_$table", $GLOBALS['tables_auxiliaires']['spip_meta'], false, false); |
|
| 266 | - $trouver_table(''); |
|
| 267 | - } |
|
| 268 | - lire_metas($table); |
|
| 261 | + $trouver_table = charger_fonction('trouver_table', 'base'); |
|
| 262 | + if (!$trouver_table("spip_$table")) { |
|
| 263 | + include_spip('base/auxiliaires'); |
|
| 264 | + include_spip('base/create'); |
|
| 265 | + creer_ou_upgrader_table("spip_$table", $GLOBALS['tables_auxiliaires']['spip_meta'], false, false); |
|
| 266 | + $trouver_table(''); |
|
| 267 | + } |
|
| 268 | + lire_metas($table); |
|
| 269 | 269 | } |
| 270 | 270 | |
| 271 | 271 | /** |
@@ -277,47 +277,47 @@ discard block |
||
| 277 | 277 | * @param bool $force |
| 278 | 278 | */ |
| 279 | 279 | function supprimer_table_meta($table, $force = false) { |
| 280 | - if ($table !== 'meta') { |
|
| 281 | - // Vérifier le contenu restant de la table |
|
| 282 | - $nb_variables = sql_countsel("spip_$table"); |
|
| 280 | + if ($table !== 'meta') { |
|
| 281 | + // Vérifier le contenu restant de la table |
|
| 282 | + $nb_variables = sql_countsel("spip_$table"); |
|
| 283 | 283 | |
| 284 | - // Supprimer si : |
|
| 285 | - // - la table est vide |
|
| 286 | - // - ou limitée à la variable charset |
|
| 287 | - // - ou qu'on force la suppression |
|
| 288 | - if ( |
|
| 289 | - $force |
|
| 290 | - or !$nb_variables |
|
| 291 | - or ( |
|
| 292 | - ($nb_variables == 1) |
|
| 293 | - and isset($GLOBALS[$table]['charset']) |
|
| 294 | - ) |
|
| 295 | - ) { |
|
| 296 | - // Supprimer la table des globaleset de la base |
|
| 297 | - unset($GLOBALS[$table]); |
|
| 298 | - sql_drop_table("spip_$table"); |
|
| 299 | - // Supprimer le fichier cache |
|
| 300 | - include_spip('inc/flock'); |
|
| 301 | - $cache = cache_meta($table); |
|
| 302 | - supprimer_fichier($cache); |
|
| 284 | + // Supprimer si : |
|
| 285 | + // - la table est vide |
|
| 286 | + // - ou limitée à la variable charset |
|
| 287 | + // - ou qu'on force la suppression |
|
| 288 | + if ( |
|
| 289 | + $force |
|
| 290 | + or !$nb_variables |
|
| 291 | + or ( |
|
| 292 | + ($nb_variables == 1) |
|
| 293 | + and isset($GLOBALS[$table]['charset']) |
|
| 294 | + ) |
|
| 295 | + ) { |
|
| 296 | + // Supprimer la table des globaleset de la base |
|
| 297 | + unset($GLOBALS[$table]); |
|
| 298 | + sql_drop_table("spip_$table"); |
|
| 299 | + // Supprimer le fichier cache |
|
| 300 | + include_spip('inc/flock'); |
|
| 301 | + $cache = cache_meta($table); |
|
| 302 | + supprimer_fichier($cache); |
|
| 303 | 303 | |
| 304 | - // vider le cache des tables |
|
| 305 | - $trouver_table = charger_fonction('trouver_table', 'base'); |
|
| 306 | - $trouver_table(''); |
|
| 304 | + // vider le cache des tables |
|
| 305 | + $trouver_table = charger_fonction('trouver_table', 'base'); |
|
| 306 | + $trouver_table(''); |
|
| 307 | 307 | |
| 308 | - // Supprimer la table de la liste des tables de configuration autres que spip_meta |
|
| 309 | - if (isset($GLOBALS['meta']['tables_config'])) { |
|
| 310 | - $liste = unserialize($GLOBALS['meta']['tables_config']); |
|
| 311 | - $cle = array_search($table, $liste); |
|
| 312 | - if ($cle !== false) { |
|
| 313 | - unset($liste[$cle]); |
|
| 314 | - if ($liste) { |
|
| 315 | - ecrire_meta('tables_config', serialize($liste)); |
|
| 316 | - } else { |
|
| 317 | - effacer_meta('tables_config'); |
|
| 318 | - } |
|
| 319 | - } |
|
| 320 | - } |
|
| 321 | - } |
|
| 322 | - } |
|
| 308 | + // Supprimer la table de la liste des tables de configuration autres que spip_meta |
|
| 309 | + if (isset($GLOBALS['meta']['tables_config'])) { |
|
| 310 | + $liste = unserialize($GLOBALS['meta']['tables_config']); |
|
| 311 | + $cle = array_search($table, $liste); |
|
| 312 | + if ($cle !== false) { |
|
| 313 | + unset($liste[$cle]); |
|
| 314 | + if ($liste) { |
|
| 315 | + ecrire_meta('tables_config', serialize($liste)); |
|
| 316 | + } else { |
|
| 317 | + effacer_meta('tables_config'); |
|
| 318 | + } |
|
| 319 | + } |
|
| 320 | + } |
|
| 321 | + } |
|
| 322 | + } |
|
| 323 | 323 | } |