spip/0000777000000000000000000000000011277747713012740 5ustar adminadministratorsspip/inc/0000777000000000000000000000000011266542161013475 5ustar adminadministratorsspip/inc/cfg-spip.php0000766000000000000000000000135611271001301015702 0ustar adminadministrators
  • "._NPKG_LINK."
  • "; ?>spip/spip.sh0000766000000000000000000000565011330546231014234 0ustar adminadministrators#!/bin/sh ################################## # # ABSTRACT: NPKG script for NMP-1000 # # HISTORY: # 2009/09/17 Written by Laurent (Ad'Novea) # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. # See the GNU General Public License for more details. # ################################## # ################################## # INCLUDE HEADER ################################## # Load the header file and check if loaded . /share/OpenNMP/.onmp/header.sh [ ! -f $USB_BASE/.onmp/header.sh ] && /bin/echo "Header file is missing!" && exit 1 # ################################## # NPKG ################################## FILENAME=`$CMD_READLINK -f $0`; FILENAME="${FILENAME##*/}"; NPKG_NAME="${FILENAME%.*}" NPKG_DIR=$NPKG_INSTALL_PATH/$NPKG_NAME NPKG_VER="`${CMD_GETCFG} npkg Version -f ${NPKG_DIR}/${NPKG_NAME}.ini`" # ################################## # MAIN ################################## # $CMD_ECHO -e "> Entering ${FILENAME} ${1}" case $1 in # Preinstall is performed while the new NPKG is still in the temporary folder to handle pre-installation operations preinstall) # Install required IPKG modules IPKG_UTILITIES=`$CMD_GETCFG npkg Ipkg -f $USB_BASE/$NPKG_TEMP/$NPKG_NAME/$NPKG_NAME.ini` install_ipkg "'${IPKG_UTILITIES}'" # The command line below overwrite previous NPKG files $CMD_CP -Rf $USB_BASE/$NPKG_TEMP/$NPKG_NAME $NPKG_INSTALL_PATH/ NPKG_INSTALL_MSG="${NPKG_NAME} ${NPKG_VER} successfully preinstalled"; $CMD_ECHO $NPKG_INSTALL_MSG _exit 0 ;; # Upgrade is performed while the new NPKG is in its final folder upgrade) NPKG_INSTALL_MSG="${NPKG_NAME} ${NPKG_VER} successfully upgraded"; $CMD_ECHO $NPKG_INSTALL_MSG _exit 0 ;; # Install is performed once the NPKG files have been moved (1st install) or copied (upgrade) to their final location install) # Move SPIP to Web folder $CMD_MV -f $NPKG_DIR/$NPKG_NAME /share/Qweb/$NPKG_NAME NPKG_INSTALL_MSG="${NPKG_NAME} ${NPKG_VER} successfully installed"; $CMD_ECHO $NPKG_INSTALL_MSG _exit 0 ;; # Remove is performed when script invoke "install.sh remove" command remove) # Remove SPIP from Web folder $CMD_RM -Rf /share/Qweb/$NPKG_NAME NPKG_INSTALL_MSG="${NPKG_NAME} ${NPKG_VER} successfully removed"; $CMD_ECHO $NPKG_INSTALL_MSG _exit 0 ;; # Start the NPKG plugin start) NPKG_INSTALL_MSG="${NPKG_NAME} ${NPKG_VER} enabled"; $CMD_ECHO $NPKG_INSTALL_MSG _exit 0 ;; # Stop the NPKG plugin stop) NPKG_INSTALL_MSG="${NPKG_NAME} ${NPKG_VER} disabled"; $CMD_ECHO $NPKG_INSTALL_MSG _exit 0 ;; # Restart the NPKG plugin restart) ./$0 stop; $CMD_SLEEP 2; ./$0 start ;; # Usage or wrong parameters has been passed! *) $CMD_ECHO "USAGE: $0 {enable|disable|start|stop|restart}"; exit 1 ;; esac exit $?spip/spip.ini0000766000000000000000000000352211330551440014373 0ustar adminadministrators;################################# ; ; ABSTRACT: NPKG parameters ; ; HISTORY: ; 2009/09/28 Written by Laurent (Ad'Novea) ; ; This program is distributed in the hope that it will be useful, ; but WITHOUT ANY WARRANTY; without even the implied warranty of ; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. ; See the GNU General Public License for more details. ; ;################################# ; [npkg] ; NPKG Plugin name Name = SPIP ; ; NPKG Plugin version or software version for application Version = 2.0.9 ; ; Date of NPKG development of date of the application release Date = 2009-10-06 ; ; NPKG author /maintainer or application provider Author = SPIP community ; ; Hardware platform supported by the current NPKG (use space as list separator) Models = NMP-1000 ; ; Oldest OpenNMP installed version that could be used to run this NPKG Engine = "0.04.01" ; ; NPKG Category (please keep consistency with already deployed plugins) Category = Applications ; ; Dependencies from other NPKG. The NPKG dependencies will be installed before the current one in automatic mode (use space as list separator) Dependencies = Optware ; ; IPKG modules required in the order of installation (use space as list separator) Ipkg = gdbm libdb cyrus-sasl-libs openldap-libs php php-fcgi sqlite ; ; Script or program to Start/Stop. it will be linked in the /opt/etc/init.d directory for handling execution priority Service = ; ; Process priority (above 99 for none system NPKG) . There can be 2 different values: first is for Start and second for Kill if needed (use space as list separator) Priority = 100 ; ; Status of the NPKG. Normally UNKOWN after a first installation. Can be set to TRUE for NPKG that does not need to be Enabled/Disabled Enable = TRUE ; ; MD5 is managed by the NPKG installation procedure. Does not need to be given here MD5 = spip/spip/0000777000000000000000000000000011275530621013675 5ustar adminadministratorsspip/spip/squelettes-dist/0000777000000000000000000000000011275530620017033 5ustar adminadministratorsspip/spip/squelettes-dist/win_width.htc0000766000000000000000000000075511236524722021542 0ustar adminadministrators spip/spip/squelettes-dist/forum.html0000766000000000000000000001104211236524722021053 0ustar adminadministrators <:poster_message:> - [(#NOM_SITE_SPIP|textebrut)]
    [(#REM) Entete de la page + titre du site ] [(#REM) Contenu : poster un message dans le forum ]
    [(#REM) Fil d'Ariane ]

    <:poster_message:>

    #FORMULAIRE_FORUM
    [(#REM) Menu de navigation laterale ] [(#REM) Menu de navigation laterale ]
     
    [(#REM) Pied de page ]
    spip/spip/squelettes-dist/sitemap.xml.html0000766000000000000000000000237311236524722022173 0ustar adminadministrators[(#REM) Exemple tres simple de sitemap.xml accessible via URL_SITE_SPIP/sitemap.xml (copier htaccess.txt en .htaccess pour en beneficier) Ce sitemap affiche la liste des rubriques, breves et articles, en se limitant a 1000 rubriques, 1000 breves et 2000 articles pour des raisons de performances. Duree de reindexation et priorite ne sont pas precisees, sauf pour l'accueil. Mais si date_modif est recente (1 jour) on l'indique, pour que ce soit reindexe en priorite ]#HTTP_HEADER{Content-Type: text/xml; charset=utf-8} [(#REM) Accueil] #URL_SITE_SPIP/ hourly [(#REM) Rubriques ] [ (#URL_RUBRIQUE|url_absolue)] [(#REM) Articles ] [(#SET{recent,[(#VAL{'Y-m-d H:i:s'}|date{[(#DATE|affdate{U}|moins{86400})]})]})] [ (#URL_ARTICLE|url_absolue)[(#DATE_MODIF|>{#GET{recent}}|?{[(#DATE_MODIF|date_iso)]})]] [(#REM) Breves ] [ (#URL_BREVE|url_absolue)] spip/spip/squelettes-dist/404.html0000766000000000000000000000261611236524722020241 0ustar adminadministrators#HTTP_HEADER{"HTTP/1.0 404 Not Found"} #HTTP_HEADER{"Cache-Control: no-store, no-cache, must-revalidate"} #HTTP_HEADER{Pragma: no-cache} <:pass_erreur:> 404 - [(#NOM_SITE_SPIP|textebrut)]
    [(#REM) Entete de la page + titre du site ]
    [(#REM) Fil d'Ariane ]
    <:accueil_site:> > <:pass_erreur:> 404

    <:pass_erreur:> 404

    [
    (#ENV*{erreur}|propre)
    ]
    [(#REM) Menu de navigation laterale ] [(#REM) Menu de navigation laterale ]
     
    [(#REM) Pied de page ]
    spip/spip/squelettes-dist/spip.ico0000766000000000000000000000257611236524722020520 0ustar adminadministratorsh( {Ssi:`Wwf5\xPphea|hk [(#NOM_SITE_SPIP|texte_backend)] #URL_SITE_SPIP/ [(#DESCRIPTIF_SITE_SPIP|texte_backend)] #LANG SPIP - www.spip.net [ [(#NOM_SITE_SPIP|texte_backend)] (#LOGO_SITE_SPIP||image_reduire{150,150}|extraire_attribut{src}|url_absolue|texte_backend) #URL_SITE_SPIP/ [(#LOGO_SITE_SPIP||image_reduire{150,150}|extraire_attribut{height})] [(#LOGO_SITE_SPIP||image_reduire{150,150}|extraire_attribut{width})] ] [(#TITRE|supprimer_tags|texte_backend)] [(#URL_BREVE|url_absolue)] [(#URL_BREVE|url_absolue)] [(#DATE|date_iso)] text/html [(#LANG)] [(#REM) Le bloc qui suit diffuse diffuse les mots-cles a la mode RSS ][ (#TITRE|texte_backend)] [(#INTRODUCTION|texte_backend)] [(#REM) Le bloc qui suit diffuse la rubrique et les mots-cles sous forme de "microformats" ]- [<a href="[(#URL_RUBRIQUE|url_absolue)]" rel="directory">(#TITRE|texte_backend)</a>] / [<a href="[(#URL_MOT|url_absolue)]" rel="tag">(#TITRE|texte_backend)</a>] [(#REM) Le bloc qui suit diffuse aussi le texte integral de la breve, ce qui permet une syndication plus riche (mais plus "lourde"). Fonction desactivable depuis les reglages du site. ][ (#CONFIG{syndication_integrale}|=={oui}|?{' ',''})[(#LOGO_BREVE|right||image_reduire{150,150}|texte_backend) ][<div class='rss_texte'>(#TEXTE|texte_backend)</div> ][<hr /> <div class='rss_notes'>(#NOTES|texte_backend)</div>] ] spip/spip/squelettes-dist/spip.png0000766000000000000000000000341111236524722020517 0ustar adminadministratorsPNG  IHDR0PsBIT|d pHYs B(xtEXtSoftwarewww.inkscape.org<IDATHVmPSW~or/B0!afVYq.iٵ;:Jwש팝YlڝUڪ`AܕHT$p>䆄s=.2NlysDD.\O ?pOM>cL ŻvlߜBb==7559/fi0;^С2YBZJ2&/T@EE/XUO>fBzaT*Ex);ᓩ=t+#Sܪh>YChB "B755)4uێ*j-**rtvv-BĒ]U*ϲ>l6?dj]]Ő59Xx%%z/ 'm9r3 p2T7m]ζ,J%bCE3iۆƴd|&hBB=eY,DN71l6BZsCUygjAF[Z .rGwttr4==-9t`cff+Um OO@z+ɘxxI~zZ5WQwrS'π"!pwwwt Po \.oIj=zpzjǎ!@?{`0BTFp#GL$.^;*02Ư(X D p˝}~6; ! K|ݮ>X~Dْ衡!E~#BDQ¦?yF6:zT9%i9I݇;4Ej&|{.V|njNR_9kZXxCG3RZs8xw@I(QĢt.p"!Ι7ou=f7;7 ccc2 ..E"~qzz("tYTE(_ץ<Bd ҙb<!2Fn-˄g2tZ$WMnޭr?B;O~eRLOt0C$8>8}<)))!D`fFqGBpYe9].BVܹmBX/]+ ^YR><;]"+~9ˎ~tΆ-%BV5 (Lݷ!#/ .0 ^銊3?7߿U"y0 .(ȿxe议8!PǏ%333tFFŋΧ\呚" !z?ƃ}CJCr^ξnPznXTݩ%smz'\xyiᄏ9^X"'s騢hT#ԊǑZ7Jxw:ǜ:pn!"R0_4,b,BQzMز<ۭ(--7Lu֎ݷohkkKO~VӈQgqov!ASk5t*JF?}ӈ[ L !{Ѝ1,.pţ( t⵾8^XTY0Fq;^f~ Y}Iԓ9IENDB`spip/spip/squelettes-dist/rss_forum_article.html0000766000000000000000000000256011236524722023452 0ustar adminadministrators#CACHE{0}#HTTP_HEADER{Content-Type: text/xml; charset=#CHARSET} [[(#NOM_SITE_SPIP|texte_backend)] <:ecrire:titre_page_forum_suivi:> ]RSS[ (#TITRE|texte_backend)] [(#URL_ARTICLE|url_absolue|texte_backend)] [(#ENV{lang}|texte_backend)] [(#TITRE|texte_backend)][ ((#ENV{page}|=={publie}|?{#STATUT, "publie"}|=={publie}|?{'', #STATUT}))] [(#URL_FORUM|url_absolue|texte_backend)] [(#URL_FORUM|url_absolue|texte_backend)] [(#DATE|date_iso)] text/html [(#LANG|texte_backend)] ['; [(#AUTEUR|texte_backend)][ <(#EMAIL_AUTEUR|texte_backend)>] [ (#TEXTE|liens_absolus|texte_backend)]#NOTES spip/spip/squelettes-dist/rss_forum_syndic.html0000766000000000000000000000255411236524722023323 0ustar adminadministrators#CACHE{0}#HTTP_HEADER{Content-Type: text/xml; charset=#CHARSET} [[(#NOM_SITE_SPIP|texte_backend)] <:ecrire:titre_page_forum_suivi:> ]RSS[ (#NOM_SITE|texte_backend)] [(#URL_SITE|url_absolue|texte_backend)] [(#ENV{lang}|texte_backend)] [(#TITRE|texte_backend)][ ((#ENV{page}|=={publie}|?{#STATUT, "publie"}|=={publie}|?{'', #STATUT}))] [(#URL_FORUM|url_absolue|texte_backend)] [(#URL_FORUM|url_absolue|texte_backend)] [(#DATE|date_iso)] text/html [(#LANG|texte_backend)] ['; [(#AUTEUR|texte_backend)][ <(#EMAIL_AUTEUR|texte_backend)>] [ (#TEXTE|liens_absolus|texte_backend)]#NOTES spip/spip/squelettes-dist/puce_rtl.gif0000766000000000000000000000012411236524722021340 0ustar adminadministratorsGIF89a ===JJJqqqFFF!, xkXx"BDF;spip/spip/squelettes-dist/sommaire.html0000766000000000000000000000610211236524722021540 0ustar adminadministrators[(#REM) Un cache plus court, pour la boucle syndic_articles ]#CACHE{3600} [(#NOM_SITE_SPIP|textebrut)] []
    [(#REM) Entete de la page + titre du site ] [(#REM) Contenu principal : derniers articles publies ]
    [
    (#DESCRIPTIF_SITE_SPIP)
    ] [(#REM) Derniers articles ] [(#REM) Breves ] [(#REM) Liens des forums ] [(#REM) Sur le Web ]
    [(#REM) Menu de navigation laterale ] [(#REM) Menu de navigation laterale ]
    [(#REM) Inscription au site ] #FORMULAIRE_INSCRIPTION
    [(#REM) Pied de page ]
    spip/spip/squelettes-dist/breve.html0000766000000000000000000000630111236524722021030 0ustar adminadministrators [(#TITRE|textebrut) - ][(#NOM_SITE_SPIP|textebrut)] [] [(#REM) Lien vers le flux RSS des breves ]
    [(#REM) Entete de la page + titre du site ] [(#REM) Contenu : corps de la breve ]
    [(#REM) Fil d'Ariane ]
    <:accueil_site:> > [(#TITRE|couper{80})][ > (#TITRE|couper{80})]
    [(#LOGO_BREVE||image_reduire{200,200})]

    #TITRE

    [(#DATE|nom_jour) ][(#DATE|affdate)]

    [
    (#TEXTE)
    ] [

    <:voir_en_ligne:> : [(#NOM_SITE|sinon{[(#URL_SITE|couper{80})]})]

    ] [

    <:info_notes:>

    (#NOTES)
    ] [(#REM) Forum de la breve NB : pour desactiver les forums de breve, supprimez simplement les lignes ci-dessous ] [

    <:repondre_breve:>

    ]
    [(#REM) Menu de navigation laterale ] [(#REM) Menu de navigation laterale ]
    [(#REM) Breves dans la meme rubrique ] [(#REM) Menu de navigation mots-cles ]
    [(#REM) Pied de page ]
    spip/spip/squelettes-dist/impression.css0000766000000000000000000000633211236524722021745 0ustar adminadministrators/* ---------------------------------------------------------------- */ /* Feuille de style specifique a l'impression */ /* ---------------------------------------------------------------- */ /* Correction des styles HTML par defaut ---------------------------------------------- */ body { background: #FFF; margin: 15pt; text-align: left; font: 12pt "Luxi sans", "Lucida Grande", Lucida, "Lucida Sans Unicode", sans-serif; color: #000; } img, table { margin: 0; padding: 0; border: 0; } ul, ol, li { margin: 0; padding: 0; list-style: none; } h1, h2, h3, h4, h5, h6 { margin: 0; padding: 0; font-size: 1em; font-weight: normal; } /* Ne pas imprimer : on elimine les elements de navigation (display: none; ) ---------------------------------------------- */ #entete, #hierarchie, #navigation, #extra, #pied { display: none; } .repondre, .repondre, .formulaire_spip { display: none; } .spip-admin, .spip-admin-float, .invisible { display: none; } /* Disposition a l'ecran ---------------------------------------------- */ .nettoyeur { clear: both; } /* Pour les liens, on les souligne et /* on affiche l'URL cible a la suite des liens sortants (!) ---------------------------------------------- */ a { color: #520; text-decoration: underline; } a.spip_out:after, a.spip_glossaire:after, a.spip_mail:after { display: inline; content: " [" attr(href) "]"; } /* Un peu de coquetterie ---------------------------------------------- */ .cartouche { margin-bottom: 2em; } .cartouche small { font-size: 0.71em; } h1 { font-size: 1.27em; font-weight: bold; } .cartouche p { margin: 0; padding: 0; clear: left; } .cartouche .traductions { display: none; } .cartouche .surtitre, .cartouche .soustitre { font-size: 0.82em; font-variant: small-caps; } .spip_logos { float: right; margin-left: 0.80em; } .chapo { margin-bottom: 1.5em; font-size: 0.82em; font-weight: bold; line-height: 1.40em; } .hyperlien { font-size: 0.82em; font-weight: bold; } .texte { line-height: 1.40em; } .ps, .notes, #documents_portfolio, #documents_joints { clear: both; margin-top: 1.40em; padding-top: 0.20em; border-top: 2pt solid #CCC; font-size: 0.82em; } .ps h2, .notes h2, #documents_joints h2 { font-weight: bold; clear: both; } /* Citations, tableaux, etc... ---------------------------------------------- */ .hyperlien, .articles li .texte { background: #FFF; margin: 1em; padding: 1em; border: 1pt dotted #CCC; } /* Messages de forums ---------------------------------------------- */ .forum { margin: 2em 0; font-size: 0.82em; } .forum-fil ul { margin-left: 0.50em; } .forum-chapo .forum-titre { display: block; font-weight: bold; } ul .forum-message { background: #EEE; border: 1pt solid #CCC; padding: 1em; margin-bottom: 1em; } /* Listes d'articles ----------------------------------------------- */ .articles li { margin-bottom: 1em; padding-top: 0.30em; } .articles li .titre { font-size: 1.03em; font-weight: bold; } .articles li p { margin: 0; padding: 0; } .articles li small { display: block; font-size: 0.71em; } /* Plan du site ---------------------------------------------- */ .page_plan #contenu h2 { font-size: 1.15em; font-weight: bold; } .page_plan #contenu ul { margin-left: 1em; margin-bottom: 1em; } .page_plan #contenu li { list-style: square; }spip/spip/squelettes-dist/agenda_periode.html0000766000000000000000000000052111236524722022651 0ustar adminadministrators[ (#DATE|agenda_memo{#DESCRIPTIF, #TITRE, #URL_ARTICLE, 'calendrier-couleur6'}) ][(#TOTAL_BOUCLE| agenda_affiche{<:aucun_article:>, 'periode', 'calendrier-couleur6'} )]spip/spip/squelettes-dist/inc-documents.html0000766000000000000000000000357311236524722022505 0ustar adminadministrators[(#REM) Portfolio : album d'images ] [(#REM) Afficher en grand le document demande dans l'URL ] [(#MODELE{emb}|image_reduire{500,0})] [(#REM) Si un seul document est joint a l'article, et si le texte est vide, on incruste automatiquement ce document ] [ (#TOTAL_BOUCLE|=={1} |?{[(#INCLURE{fond=modeles/emb}{id_document} |trim)]})] [(#REM) Sinon, liste des autres documents joints ] spip/spip/squelettes-dist/ical.html0000766000000000000000000000200211236524722020627 0ustar adminadministrators#HTTP_HEADER{Content-Type: text/calendar; charset:#CHARSET} BEGIN:VCALENDAR CALSCALE:GREGORIAN PRODID: SPIP http://www.spip.net VERSION:2.0 X-WR-CALNAME;VALUE=TEXT:[(#NOM_SITE_SPIP|filtrer_ical)] X-WR-RELCALID:[(#URL_SITE_SPIP|filtrer_ical)] BEGIN:VEVENT SUMMARY:[(#TITRE|filtrer_ical)] [[(#NOM_SITE_SPIP|filtrer_ical)]] UID:article#ID_ARTICLE @ [(#URL_SITE_SPIP|filtrer_ical)] DTSTAMP:[(#DATE|date_ical)] DTSTART:[(#DATE|date_ical)] DTEND:[(#DATE|date_ical{60})] CATEGORIES:<:articles|filtrer_ical:> URL:[(#URL_ARTICLE|url_absolue)] STATUS:CONFIRMED END:VEVENT BEGIN:VEVENT SUMMARY:[(#TITRE|filtrer_ical)] [[(#NOM_SITE_SPIP|filtrer_ical)]] UID:breve#ID_BREVE @ [(#URL_SITE_SPIP|filtrer_ical)] DTSTAMP:[(#DATE|date_ical)] DTSTART:[(#DATE|date_ical)] DTEND:[(#DATE|date_ical{60})] CATEGORIES:<:breves|filtrer_ical:> URL:[(#URL_BREVE|url_absolue)] STATUS:CONFIRMED END:VEVENT END:VCALENDAR spip/spip/squelettes-dist/polices/0000777000000000000000000000000011266531327020476 5ustar adminadministratorsspip/spip/squelettes-dist/polices/dustismo-license.txt0000766000000000000000000004522711236524722024537 0ustar adminadministratorsDustismo is Copyright (C) 2002 Dustin Norlander Homepage: http://www.cheapskatefonts.com email: nutso@cheapskatefonts.com This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. ------------------------------------------------------------------------------- GNU GENERAL PUBLIC LICENSE Version 2, June 1991 Copyright (C) 1989, 1991 Free Software Foundation, Inc. 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA Everyone is permitted to copy and distribute verbatim copies of this license document, but changing it is not allowed. Preamble The licenses for most software are designed to take away your freedom to share and change it. By contrast, the GNU General Public License is intended to guarantee your freedom to share and change free software--to make sure the software is free for all its users. This General Public License applies to most of the Free Software Foundation's software and to any other program whose authors commit to using it. (Some other Free Software Foundation software is covered by the GNU Library General Public License instead.) You can apply it to your programs, too. When we speak of free software, we are referring to freedom, not price. Our General Public Licenses are designed to make sure that you have the freedom to distribute copies of free software (and charge for this service if you wish), that you receive source code or can get it if you want it, that you can change the software or use pieces of it in new free programs; and that you know you can do these things. To protect your rights, we need to make restrictions that forbid anyone to deny you these rights or to ask you to surrender the rights. These restrictions translate to certain responsibilities for you if you distribute copies of the software, or if you modify it. For example, if you distribute copies of such a program, whether gratis or for a fee, you must give the recipients all the rights that you have. You must make sure that they, too, receive or can get the source code. And you must show them these terms so they know their rights. We protect your rights with two steps: (1) copyright the software, and (2) offer you this license which gives you legal permission to copy, distribute and/or modify the software. Also, for each author's protection and ours, we want to make certain that everyone understands that there is no warranty for this free software. If the software is modified by someone else and passed on, we want its recipients to know that what they have is not the original, so that any problems introduced by others will not reflect on the original authors' reputations. Finally, any free program is threatened constantly by software patents. We wish to avoid the danger that redistributors of a free program will individually obtain patent licenses, in effect making the program proprietary. To prevent this, we have made it clear that any patent must be licensed for everyone's free use or not licensed at all. The precise terms and conditions for copying, distribution and modification follow. GNU GENERAL PUBLIC LICENSE TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION 0. This License applies to any program or other work which contains a notice placed by the copyright holder saying it may be distributed under the terms of this General Public License. The "Program", below, refers to any such program or work, and a "work based on the Program" means either the Program or any derivative work under copyright law: that is to say, a work containing the Program or a portion of it, either verbatim or with modifications and/or translated into another language. (Hereinafter, translation is included without limitation in the term "modification".) Each licensee is addressed as "you". Activities other than copying, distribution and modification are not covered by this License; they are outside its scope. The act of running the Program is not restricted, and the output from the Program is covered only if its contents constitute a work based on the Program (independent of having been made by running the Program). Whether that is true depends on what the Program does. 1. You may copy and distribute verbatim copies of the Program's source code as you receive it, in any medium, provided that you conspicuously and appropriately publish on each copy an appropriate copyright notice and disclaimer of warranty; keep intact all the notices that refer to this License and to the absence of any warranty; and give any other recipients of the Program a copy of this License along with the Program. You may charge a fee for the physical act of transferring a copy, and you may at your option offer warranty protection in exchange for a fee. 2. You may modify your copy or copies of the Program or any portion of it, thus forming a work based on the Program, and copy and distribute such modifications or work under the terms of Section 1 above, provided that you also meet all of these conditions: a) You must cause the modified files to carry prominent notices stating that you changed the files and the date of any change. b) You must cause any work that you distribute or publish, that in whole or in part contains or is derived from the Program or any part thereof, to be licensed as a whole at no charge to all third parties under the terms of this License. c) If the modified program normally reads commands interactively when run, you must cause it, when started running for such interactive use in the most ordinary way, to print or display an announcement including an appropriate copyright notice and a notice that there is no warranty (or else, saying that you provide a warranty) and that users may redistribute the program under these conditions, and telling the user how to view a copy of this License. (Exception: if the Program itself is interactive but does not normally print such an announcement, your work based on the Program is not required to print an announcement.) These requirements apply to the modified work as a whole. If identifiable sections of that work are not derived from the Program, and can be reasonably considered independent and separate works in themselves, then this License, and its terms, do not apply to those sections when you distribute them as separate works. But when you distribute the same sections as part of a whole which is a work based on the Program, the distribution of the whole must be on the terms of this License, whose permissions for other licensees extend to the entire whole, and thus to each and every part regardless of who wrote it. Thus, it is not the intent of this section to claim rights or contest your rights to work written entirely by you; rather, the intent is to exercise the right to control the distribution of derivative or collective works based on the Program. In addition, mere aggregation of another work not based on the Program with the Program (or with a work based on the Program) on a volume of a storage or distribution medium does not bring the other work under the scope of this License. 3. You may copy and distribute the Program (or a work based on it, under Section 2) in object code or executable form under the terms of Sections 1 and 2 above provided that you also do one of the following: a) Accompany it with the complete corresponding machine-readable source code, which must be distributed under the terms of Sections 1 and 2 above on a medium customarily used for software interchange; or, b) Accompany it with a written offer, valid for at least three years, to give any third party, for a charge no more than your cost of physically performing source distribution, a complete machine-readable copy of the corresponding source code, to be distributed under the terms of Sections 1 and 2 above on a medium customarily used for software interchange; or, c) Accompany it with the information you received as to the offer to distribute corresponding source code. (This alternative is allowed only for noncommercial distribution and only if you received the program in object code or executable form with such an offer, in accord with Subsection b above.) The source code for a work means the preferred form of the work for making modifications to it. For an executable work, complete source code means all the source code for all modules it contains, plus any associated interface definition files, plus the scripts used to control compilation and installation of the executable. However, as a special exception, the source code distributed need not include anything that is normally distributed (in either source or binary form) with the major components (compiler, kernel, and so on) of the operating system on which the executable runs, unless that component itself accompanies the executable. If distribution of executable or object code is made by offering access to copy from a designated place, then offering equivalent access to copy the source code from the same place counts as distribution of the source code, even though third parties are not compelled to copy the source along with the object code. 4. You may not copy, modify, sublicense, or distribute the Program except as expressly provided under this License. Any attempt otherwise to copy, modify, sublicense or distribute the Program is void, and will automatically terminate your rights under this License. However, parties who have received copies, or rights, from you under this License will not have their licenses terminated so long as such parties remain in full compliance. 5. You are not required to accept this License, since you have not signed it. However, nothing else grants you permission to modify or distribute the Program or its derivative works. These actions are prohibited by law if you do not accept this License. Therefore, by modifying or distributing the Program (or any work based on the Program), you indicate your acceptance of this License to do so, and all its terms and conditions for copying, distributing or modifying the Program or works based on it. 6. Each time you redistribute the Program (or any work based on the Program), the recipient automatically receives a license from the original licensor to copy, distribute or modify the Program subject to these terms and conditions. You may not impose any further restrictions on the recipients' exercise of the rights granted herein. You are not responsible for enforcing compliance by third parties to this License. 7. If, as a consequence of a court judgment or allegation of patent infringement or for any other reason (not limited to patent issues), conditions are imposed on you (whether by court order, agreement or otherwise) that contradict the conditions of this License, they do not excuse you from the conditions of this License. If you cannot distribute so as to satisfy simultaneously your obligations under this License and any other pertinent obligations, then as a consequence you may not distribute the Program at all. For example, if a patent license would not permit royalty-free redistribution of the Program by all those who receive copies directly or indirectly through you, then the only way you could satisfy both it and this License would be to refrain entirely from distribution of the Program. If any portion of this section is held invalid or unenforceable under any particular circumstance, the balance of the section is intended to apply and the section as a whole is intended to apply in other circumstances. It is not the purpose of this section to induce you to infringe any patents or other property right claims or to contest validity of any such claims; this section has the sole purpose of protecting the integrity of the free software distribution system, which is implemented by public license practices. Many people have made generous contributions to the wide range of software distributed through that system in reliance on consistent application of that system; it is up to the author/donor to decide if he or she is willing to distribute software through any other system and a licensee cannot impose that choice. This section is intended to make thoroughly clear what is believed to be a consequence of the rest of this License. 8. If the distribution and/or use of the Program is restricted in certain countries either by patents or by copyrighted interfaces, the original copyright holder who places the Program under this License may add an explicit geographical distribution limitation excluding those countries, so that distribution is permitted only in or among countries not thus excluded. In such case, this License incorporates the limitation as if written in the body of this License. 9. The Free Software Foundation may publish revised and/or new versions of the General Public License from time to time. Such new versions will be similar in spirit to the present version, but may differ in detail to address new problems or concerns. Each version is given a distinguishing version number. If the Program specifies a version number of this License which applies to it and "any later version", you have the option of following the terms and conditions either of that version or of any later version published by the Free Software Foundation. If the Program does not specify a version number of this License, you may choose any version ever published by the Free Software Foundation. 10. If you wish to incorporate parts of the Program into other free programs whose distribution conditions are different, write to the author to ask for permission. For software which is copyrighted by the Free Software Foundation, write to the Free Software Foundation; we sometimes make exceptions for this. Our decision will be guided by the two goals of preserving the free status of all derivatives of our free software and of promoting the sharing and reuse of software generally. NO WARRANTY 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION. 12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. END OF TERMS AND CONDITIONS How to Apply These Terms to Your New Programs If you develop a new program, and you want it to be of the greatest possible use to the public, the best way to achieve this is to make it free software which everyone can redistribute and change under these terms. To do so, attach the following notices to the program. It is safest to attach them to the start of each source file to most effectively convey the exclusion of warranty; and each file should have at least the "copyright" line and a pointer to where the full notice is found. Copyright (C) This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA Also add information on how to contact you by electronic and paper mail. If the program is interactive, make it output a short notice like this when it starts in an interactive mode: Gnomovision version 69, Copyright (C) year name of author Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'. This is free software, and you are welcome to redistribute it under certain conditions; type `show c' for details. The hypothetical commands `show w' and `show c' should show the appropriate parts of the General Public License. Of course, the commands you use may be called something other than `show w' and `show c'; they could even be mouse-clicks or menu items--whatever suits your program. You should also get your employer (if you work as a programmer) or your school, if any, to sign a "copyright disclaimer" for the program, if necessary. Here is a sample; alter the names: Yoyodyne, Inc., hereby disclaims all copyright interest in the program `Gnomovision' (which makes passes at compilers) written by James Hacker. , 1 April 1989 Ty Coon, President of Vice This General Public License does not permit incorporating your program into proprietary programs. If your program is a subroutine library, you may consider it more useful to permit linking proprietary applications with the library. If this is what you want to do, use the GNU Library General Public License instead of this License. spip/spip/squelettes-dist/polices/dustismo_bold.ttf0000766000000000000000000014766011236524722024101 0ustar adminadministrators@OS/2VOΤVPCLT"ڱ6cmapo0cvt io.fpgm3OglyfHi?`hdmxؼLheadx46hhea l$hmtxV2`kernG,loca&|dmaxpx-ϐ name postXc@prepبk& >d)"X% E ,     >d ) "  X%Copyright (c) Dustin Norlander, 2002. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or any later Copyright (c) Dustin Norlander, 2002. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or any later DustismoDustismo Bold BoldDustismo BoldDustismo BoldDustinNorlander: Dustismo: 2002DustinNorlander: Dustismo: 2002Version 1.06 2003Version 1.06 2003DustismoBoldDustismoBoldDustismo is a trademark of Dustin Norlander.Dustismo is a trademark of Dustin Norlander.@,vE %E#ah#h`D-~YiEfZbZb@ EhDEhDEhDEhDEhDEhDEhDEhDEhDEhDEhDEhDEhDEhDEhDF+F+EhDEhDV@ @ Fv/7?..@/* *-(' &%!+*(-%('&Fv/7?Mءrrvv(PMuuutNP%m42@:33@4%$ 2%$" .  '++ Fv/7?//////....................10Ih 3Iha@RX8738Y"654#32?6'3'#"&547&'&547632j_l24Lh@_)6jõ,-WQox1%`]I[6\oM2YR-/n&5tr5]D8ˈaB4emD?yc>0:\jM?@@Fv/7?@@Fv/7/9;@\rnmqqnns _ i@- @     Fv/7?/'^@$((@)'& '&Fv/7?IAK&V@ ''@( #" "Fv/7?////........10Ih'Iha@RX87'8Y"327#654&%632# '&576!"~RdOJ|wSPm}~q2@1BAndOVkrtmb|^@%@Fv/7?;ZZynOYXQmkRYYRkyxMxxMX64j;AjjC>?DhhBV-+Cڌqhd[1 ǧت۷[ GӮR澶ABXhQ+Hoݒprnn=%+ܧڤ0أ|AùǚM @>@          Fv/7? @     Fv/7?K Mnzob+d.[@#//@0-,*)*),#''Fv/7??/p<34ZߴocPbMY@#@   Fv/7?@@Fv/7?;^bf-0 Ml@1@     Fv/7?H\WM_njfIO [@$@      Fv/7?? @     Fv/7?54&57&4654&'7f','-SR-'*'fEHQbn,1]-dt2ӨKBE2DwMG@BHH@I /.D/.(9 F1 C *=7'('#DCA A#A,##A'Fv/7?/<</<<<[Mf.ON%G0)0xN8ZKH& s q 6@ @  Fv/7///10Ih Iha@RX87 8Y4632#"& ^]^_^\]~&a@(@    Fv/7?33@4*%$ $ &&%%&* 0 '&"-'-0Fv/7?//<<///<54'&#"3!53&5476$kD@c2mu||uBBl2c?E'ecʧ@wzAܧ%L@IMM@N@HFE? FE@76 8# )*17*)..!&%.87<3/.LCFv/7?< */LJ0*Zbju_D_b"vURiYT@gU$@6%%@&    ""Fv/7?< 6529/.  )%< ';0./+6567632&'&547650#"'&4JLNe a&H $K2LOQcw 9H4i]` , $2+',/DuEL2e_b .  /,#M %)5AO@PPP@Q-EDED(&&)&''())&(() 9-G#3?M6* &0'J 0<('B)& MFv/7??<?/.DFrssv!rst4tSSvt|>,,==,+?@+->,)B/://<=.+>MѠssvursss(PNtvtr&$h5]&(et&$yr5]w&(^]&(CkC&,lJ&,n0|&,&,Cn$&24e$&2t$&2Ck,&8o,&8n,U&8C5UN@@Fv/7?@@Fv/7?MF@@  Fv/7?///10IhIha@RX878Y"3254'2#"&54699>>JhgKGgg8888ucJJbeGGf' D@@  Fv/7?Cxu;2+NSݬuomtuk?iB&<h}M&\'e "@?##@$     Fv/7/@@Fv/7/&HgA5]M @8@      Fv/7?;^bf-0( @=t5]&(qM&H$&*{M&J$&*g>&J5A,&8p.2&XW, &8.C&XW$&2n2&R$1&2P&R3&10{5M&Q&7{?%&W q&,n2'M @>@       Fv/7?&QM&7_/&WmM&'"M&GW;M{@6@       Fv/7?\$<  !f"$"$$%&8&'h(B)8)*|*+n+,,-0.../0X1(123h445v567D789:;;?@@A(ABXBpBBBBBCCC.CFC^CvCCCCCDDD0DHD`DxDDDDDEEE4ELF.FGHJJK LZMhN2NOPQ.QRSTV WWXtXYZZ[X[p[[\]^ ^d_8`>`aPbbb0bcd,dddef\fgipiiiiijjj0jHj`jxjjjjkFkl^lmmnnoopnq8qPqfq~qr rtt(t@u4vvvwBwZwpwwwwwwwwwwwwwwwwwxyyyyyyzzzzzzzzzzzzzz{J{J{J{J{J{J{J{J{J{{{{|4|F|^|v|||||}}.}F}^}v}}}}}~~*BZr<Tl*BZr2Jbz ":R0F^t0H`x4Ld| ":Rjbzt0H^nVS%\5#(+8,33w& ./%12)F*6/3X<#~5n$g555$.5(533$B3$g3B,W6%3{B"N3!HK3( j95j3})5{5w56w3 !..W2n/2Z'J`$53|$,ududududududpppp8Tm5uuuuu . . . .+ E2[ $c%U< 0:}%U.\V! /|$P,/3N#(=`6$/?3pE9Rf(55tttt|$|$|$,,,5$m/' >64, &(%/M;6(`'/N$j !n$n$\  HKK@~53~53~53n$w3g3w3g3w3g3$B,.. ! !,..,..,..HKHKn$3{5^ 5}%/%/6nHKn$g5=55555$j$j,..,..$$3{5B$j.59PM/(j35$n5}5}3{59p.>Bgm ;z,,1.HK`$,..:~5<2  !"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklmnopqrstuvwxyz{|}~      !"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklmnopqrstuvwxyz{|}~uni00A0glyph218uni20ACglyph219uni00DFmiddotuni0192glyph224glyph226glyph227glyph228ch262ch263glyph232glyph233glyph234glyph235glyph236glyph237glyph238glyph239rcaronRcaronuni0157uni0156racuteRacuteomacronOmacronuni0162uni0163UogonekuogonekSacutesacute Scircumflex scircumflexUtildeutildeUmacronumacronUringuringAmacronamacronAogonekaogonek Ccircumflex ccircumflexNacutenacuteItildeitildeImacronimacronuni0130 Jcircumflex jcircumflexLacutelacuteZacutezacuteuni017Buni017C Wcircumflex wcircumflex Ycircumflex ycircumflexAbreveabreveuni010Auni010BDcarondcaronEmacronemacronEbreveebreveuni0116uni0117EogonekeogonekEcaronecaron Gcircumflex gcircumflexuni0120uni0121Ubreveubreveuni0170uni0171Obreveobreveuni0150uni0151NcaronncaronTcarontcaronIbreveibreveIogonekiogonekuni0122uni0123 Hcircumflex hcircumflexIJijuni0136uni0137uni013Buni013CLcaronlcaronLdotldotuni0145uni0146hbarHbaruni0149Tbartbaruni0110uni0111EngengUhornuhornuni01CDuni01CEuni01CFuni01D0uni01D1uni01D2uni01D3uni01D4Alphauni0390uni038FBetaGamma$$  !"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`aՆbcdefgݏhjikmlnoqprsutvwxzy{}|~۩ B@~7~     " & 0 : D !"!&""" 9     & 0 9 D !"!&"""B4$  !"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefgh jikmlnoqprsutvwxzy{}|~34LM5678NOPQRSTUVWXYZ[\]^_pqrs;<=>lmno?tu@AvwBCxyz{|}9:~hi$#defg"! )*+,%&jk-./0`a12bc'(HIJKDEFG$@$*$2$62$92DWD\HYHZKHLMNHQ pRZUDUHUJUQ8URUUVGAYHYRZR[H                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                           fJADBE Kqc `MuDustismo 7DUSR00Mo_<zz>Rk2>PL@ Nspip/spip/squelettes-dist/polices/dustismo.ttf0000766000000000000000000014620011236524722023066 0ustar adminadministrators@OS/2UNtVPCLT"ڤ6cmapmL0cvt oq 6fpgm3Oglyf"zdhdmxx,Hheadڦ 6hhea B<$hmtxCS`@kernG|locaDmaxpj&` name O@ postYeprep&>X)"X  9!,    >X ) "  X Copyright (c) Dustin Norlander, 2002. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or any later Copyright (c) Dustin Norlander, 2002. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or any later DustismoDustismoRegularRegularDustismoDustismoDustinNorlander: Dustismo: 2002DustinNorlander: Dustismo: 2002Version 1.06 2003Version 1.06 2003DustismoDustismoDustismo is a trademark of Dustin Norlander.Dustismo is a trademark of Dustin Norlander.@,vE %E#ah#h`D-sWK-nvWZbZb@' EhDEhDEhDEhDEhDEhDEhDEhDEhDEhDEhDEhDEhDEhDEhDEhDEhDEhDEhDF+F+EhDEhDV@ @ Fv/7?@@  Fv/7///....10IhIha@RX878Y56'5:VŻV:+mRRm+@1@Y@             Fv/7/FA,iU[ :/D?/2?HS>@@Fv/7/?..@m/@@/.??*KQ@@Fv/7? 9CJECIp$q^@%@Fv/7?;;>CJtsLFFLstJCxiosiheehisۯoi(o%N@&&@'#  Fv/7?///FU-@A,.BBA,iU[ :/D?/2?L'k@-@Fv/7?/.ć........10IhIha@RX878Y 5'q%osHBT@ @ Fv/7/FhiA7z @HroIBckokЦi_K9c#R@$$@% # Fv/7??/<<......10Ih$Iha@RX87$8Y47632#&'&#"327673#"'&59ӵ~!]`c``c`]!~ӋS֙{vQSrllrSQv{JK W@!@    Fv/7? @     Fv/7?m^W1K o@. @    Fv/7?@@Fv/7?M [@$@      Fv/7??:ru~%ZE\~}dE}6{<UQ/XT39{&$9j&$(9c&&""Ja&(!kH&19v&2Ar&8zK&DHzK&DCYzJ&Dz &Dz&Dzx&D.-3&F@0K&HA0K&HCS0K&H0&HwQ&fS&Cf`K&i&/rJ&Q4K&RA4K&RC!4K&R4 &R4&RCK&XCK&XCQCN&XC&Xx@\mF&n@-''@(     #%  Fv/7/"M!>tB#~PJJPd#8%%%&5.@DK D@@   Fv/7??///10Ih Iha@RX878Y2#"&546"32654&7ppnn6OM88RSKoonnK58JK76J!>g@- @!     Fv/7??))99)*>?))98tK@M@      Fv/7?GI#=4 Fv/7?<EAP@N JJ[9[T?sG K@@    Fv/7?KQ@@Fv/7?@@Fv/7?/......10IhIha@RX878Y J H*>@@Fv/7?/......10IhIha@RX878Y 5HL85YM&I8LMcK&I,Oh@@BAA@B@10 9810  @%5<+%  (->3# 980Fv/7?t t<<t " FF#2&&&&2 SLSFF 2&&&&24 6@ @  Fv/7///10Ih Iha@RX87 8Y4632#"&4?//>?..@%/@@/.??5K-:@@  Fv/7///..10IhIha@RX878Y72'67.546,C?Dfy/>FA,iU[ :/D?/2?9. {:TQ.VR1K>@@Fv/7?}H(yK @F @       Fv/7?}H<&6p@K&Vα1&=hDpT&]η Q}KO@@ Fv/7?l>@@Fv/7/+p1&=nDp@&]1&=3Dp&]'=5-&:Jn<-K&ZV&<n!qK&\9&$ta(&D9&&a3&FW=J&'sPyf&GR<Ja1&( dq4&H Ja&({4(&HJa&(4&HgAJaK x@4@        Fv/7?>@?.,$86#;1 ,+( 5 Fv/7???Iha@RX87>8Y%27654'&#""'&54763253#"&'7326="&54767\WV]`\[āwȪ TW{|,C?Dfy/>FlskkssllrɓɳԨzILȓ[WA,iU[ :/D?/2?J&+nx&K,z1K&,-o/qM&LMr=K&.HK&NJ K&/K&O>`J e&/`T&O>#~J K&/#WK&O>4HK&1TJ&QeK&K %S@G@      Fv/7?&`'l;&JK%R(J@@Fv/7?v??@@A@AXApAAAAABBB.BFB^BvBBBBBCCC0CHC`CxCCCCCDDD4EEFrGHIIJKLM>MNOPQRxSTTUVW^WXlXYZ>ZVZnZ[\\]J]^_0_`\`t``b"bbccdVde,eg`gxggggghh h8hPhhhhhhi6ijjljkfklJlmNnnnooo4opqqqrstNu:uRuhuuuuuuuuuvwwwwwwx|x|x|x|x|x|x|x|x|x|x|x|x|x|yDyDyDyDyDyDyDyDyDyyyyz.z@zXzpzzzzz{{({@{X{p{{{{{||}}}}~~*~B~Z~r~~~~.F^v4Ld| $<Tl,,D\t0H`v~ ":Rj(4Ld|<(@Xn *@Pwlil!k!(:hsJ8 @)hEHHY;5D( F)$ 1(\CLHn%~9`JP9IJJJs9Jd1=JsHHl9$Hs9IHe5$~A9!5i91H]X=0Ha*arH<3Ye4!L/J/ LHcV J]Je4YJLYH9dC9!<=P!DGq c,p9p9B9JH^9pAWzWzWzWzWzWz3R0R0R0R0`iOJW4W4W4W4W4CCCC@.!b[G=5p%..9v:7 !.1_:k%{s-826D~9p9^92ADH0.8<b$b0 B!!A!HRYMhH4h5<1p9Jp9JJV1V VV^9^9^9pApApAJL,ODT=T=a,(e<@1D/QL B!<Dyds9L/e59P93P93> ~9*aaU`JrH`JrH`JrHP93YHIHYHIHYHIHe4l9$d~ACe59e59~AC~AC~AC~9*a~9*aP93H]Jdd@!d1~-J1D1D5<P!~9*aP93IJPJe4Je4Je4Je4Je4s9L/s9L/~AC~ACl9e4l9e4H]J$ddd1/s9L/Jx/1/=LHJJJH]JW$dI0uQ\AAC~9*adBl9e4~AC9#`JR2  !"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklmnopqrstuvwxyz{|}~      !"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklmnopqrstuvwxyz{|}~uni00A0glyph218uni20ACglyph219uni00DFmiddotuni0192glyph224glyph226glyph227glyph228ch262ch263glyph232glyph233glyph234glyph235glyph236glyph237glyph238glyph239rcaronRcaronuni0157uni0156racuteRacuteomacronOmacronuni0162uni0163UogonekuogonekSacutesacute Scircumflex scircumflexUtildeutildeUmacronumacronUringuringAmacronamacronAogonekaogonek Ccircumflex ccircumflexNacutenacuteItildeitildeImacronimacronuni0130 Jcircumflex jcircumflexLacutelacuteZacutezacuteuni017Buni017C Wcircumflex wcircumflex Ycircumflex ycircumflexAbreveabreveuni010Auni010BDcarondcaronEmacronemacronEbreveebreveuni0116uni0117EogonekeogonekEcaronecaron Gcircumflex gcircumflexuni0120uni0121Ubreveubreveuni0170uni0171Obreveobreveuni0150uni0151NcaronncaronTcarontcaronIbreveibreveIogonekiogonekuni0122uni0123 Hcircumflex hcircumflexIJijuni0136uni0137uni013Buni013CLcaronlcaronLdotldotuni0145uni0146hbarHbaruni0149Tbartbaruni0110uni0111EngengUhornuhornuni01CDuni01CEuni01CFuni01D0uni01D1uni01D2uni01D3uni01D4Alphauni0390uni038FBetaGamma$$  !"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`aՆbcdefgݏhjikmlnoqprsutvwxzy{}|~۩ B@~7~     " & 0 : D !"!&""" 9     & 0 9 D !"!&"""B4$  !"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghjikmlnoqprsutvwxzy{}|~+,DE-./0FGHI}~JKLMNOPQRSTUVWhijkyx3456defg7lm89no:;pqrstu12vw`az\]^_!"#$bc{|%&'(XY)*Z[ @ABC<=>?   $@$*$2$62$92DWD\HYHZKHLMNHQ pRZUDUHUJUQ8URUUVGAYHYRZR[H                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                           fJADBE@ Kqc `KuDustismo 7DUSR00jg_<zzWnk2WRM@ Dspip/spip/squelettes-dist/agenda.css0000766000000000000000000001511711236524722020775 0ustar adminadministrators/* ------------------------------------------ */ /* Styles pour l'agenda de SPIP /* ------------------------------------------ */ .calendrier-arial9 { font-family: Arial, Sans, sans-serif; font-size: 9px; } .calendrier-arial10 { font-family: Arial, Sans, sans-serif; font-size: 10px; } .calendrier-arial11 { font-family: Arial, Sans, sans-serif; font-size: 11px; } .calendrier-verdana10 { font-family: Verdana, Geneva, Sans, sans-serif; font-size: 10px; } .calendrier-helvetica16 { font-family: arial, helvetica, sans-serif; font-size: 16px; color: #000; } div.navigation-calendrier { color: #FFF; background-color: #CCC; font-family: Verdana, Geneva, Sans, sans-serif; font-weight: bold; font-size: 14px; } div.navigation-calendrier img { border: 0; vertical-align: middle; margin: 1px; } .calendrier-annee { background: #AAA; padding: 3px; margin: 1px; font-family: Verdana, Geneva, Sans, sans-serif; font-size: 10px; font-weight: bold; color: #FFF; } .calendrier-annee:hover { color: #000; background-color: #FFF; } .calendrier-table-large { border: 0; width: 900px; } .calendrier-table-etroit { border: 0; width: 750px; } .calendrier-td-centre { width: 550px; padding-left: 25px; padding-right: 25px; vertical-align: top; } .calendrier-td { width: 14%; vertical-align: top; } .calendrier-th { width: 14%; padding: 5px; text-align: center; vertical-align: middle; font-size: 10px; font-weight: bold; font-family: Verdana, Geneva, Sans, sans-serif; } .calendrier-th a { color: #000; } .calendrier-table-etroit .calendrier-td-gauche { width: 0; vertical-align: top; } .calendrier-table-large .calendrier-td-gauche { width: 150px; vertical-align: top; } .calendrier-table-etroit .calendrier-td-droit { width: 150px; vertical-align: top; } .calendrier-table-large .calendrier-td-droit { width: 150px; vertical-align: top; } .calendrier-jour { position: relative; color: #999; /*background-color: #FFF;*/ border: 1px solid #AAA; } .calendrier-agenda { margin-left: 1px; margin-top: 1px; padding: 1px; text-align: center; background-color: #FFF; } .calendrier-demiagenda { margin-left: 1px; margin-top: 0; padding: 0; text-align: center; background-color: #FFF; } .calendrier-tripleagenda { vertical-align: top; width: 33%; } .calendrier-cadreagenda { visibility: hidden; width: 100%; position: absolute; padding-top: 5px; padding-bottom: 5px; border: 0; background-color: #FFF; } .calendrier-titre { padding: 5px; text-align: center; font-weight: bold; } .calendrier-evenement { padding: 2px; margin-top: 2px; } .calendrier-heurepile { position: absolute; margin-left: 2px; margin-right: 2px; border-top: 1px solid #CCC; font-weight: bold; } .calendrier-heureface { position: absolute; margin-left: 2px; margin-right: 2px; border-top: 1px solid #CCC; } .calendrier-mozleft {} .calendrier-mozright {} .calendrier-moztop8 {} .calendrier-mozbottom8 {} .calendrier-moztop6 {} .calendrier-mozbottom6 {} .calendrier-opacity { -moz-opacity: 0.3; filter: alpha(opacity=30); } .calendrier-png { width: 12px; height: 12px; } .calendrier-icone { width: 14px; height: 7px; border: 0; } .calendrier-noir { color: #000; } /* style anar */ .calendrier-nb { background-color: #FFF; border: 1px solid #000; color: #000; } /* style cinemat(yp)ographe */ .calendrier-couleur1 { background: #FDE5F2; border: 1px solid #CD006F; color: #CD006F; } /* Fushia */ .calendrier-couleur1i { background: #CD006F; border: 1px solid #FDE5F2; color: #FDE5F2; } /* Fushia */ .calendrier-couleur2 { background: #EDF3FE; border: 1px solid #5da7c5; color: #5da7c5; } /* Bleu */ .calendrier-couleur2i { background: #5da7c5; border: 1px solid #EDF3FE; color: #EDF3FE; } /* Bleu */ .calendrier-couleur3 { background: #EBE9FF; border: 1px solid #766CF6; color: #766CF6; } /* Bleu pastel */ .calendrier-couleur3i { background: #766CF6; border: 1px solid #EBE9FF; color: #EBE9FF; } /* Bleu pastel */ .calendrier-couleur4 { background: #FEC; border: 1px solid #FA9A00; color: #FA9A00; } /* Orange */ .calendrier-couleur4i { background: #FA9A00; border: 1px solid #FEC; color: #FEC; } /* Orange */ .calendrier-couleur5 { background: #FFEDED; border: 1px solid #F00; color: #F00; } /* Rouge (Vermillon) */ .calendrier-couleur5i { background: #F00; border: 1px solid #FFEDED; color: #FFEDED; } /* Rouge (Vermillon) */ .calendrier-couleur6 { background: #FFF2EB; border: 1px solid #E95503; color: #E95503; } /* Orange */ .calendrier-couleur6i { background: #E95503; border: 1px solid #FFF2EB; color: #FFF2EB; } /* Orange */ .calendrier-couleur7 { background: #FFE; border: 1px solid #ccaa00; color: #ccaa00; } /* Jaune */ .calendrier-couleur7i { background: #ccaa00; border: 1px solid #FFE; color: #FFE; } /* Jaune */ .calendrier-couleur8 { background: #E2FDEC; border: 1px solid #009F3C; color: #009F3C; } /* Vert pastel */ .calendrier-couleur8i { background: #009F3C; border: 1px solid #E2FDEC; color: #E2FDEC; } /* Vert pastel */ .calendrier-couleur9 { background: #e5fd63; border: 1px solid #9DBA00; color: #9DBA00; } /* Vert */ .calendrier-couleur9i { background: #9DBA00; border: 1px solid #e5fd63; color: #e5fd63; } /* Vert */ .calendrier-couleur10 { background: #FFE0E0; border: 1px solid #640707; color: #640707; } /* Rouge (Bordeaux) */ .calendrier-couleur10i { background: #640707; border: 1px solid #FFE0E0; color: #FFE0E0; } /* Rouge (Bordeaux) */ .calendrier-couleur11 { background: #F2F2F2; border: 1px solid #3F3F3F; color: #3F3F3F; } /* Gris */ .calendrier-couleur11i { background: #3F3F3F; border: 1px solid #F2F2F2; color: #F2F2F2; } /* Gris */ .calendrier-couleur12 { background: #AAA; border: 1px solid #000; color: #000; } .calendrier-couleur12i { background: #000; border: 1px solid #AAA; color: #AAA; } .calendrier-couleur13 { background: #FFFFE0; border: 1px solid #666500; color: #666500; } /* Caca d'oie */ .calendrier-couleur13i { background: #666500; border: 1px solid #FFFFE0; color: #FFFFE0; } /* Caca d'oie */ .calendrier-couleur14 { background: #F5EEE5; border: 1px solid #8C6635; color: #8C6635; } /* Marron */ .calendrier-couleur14i { background: #8C6635; border: 1px solid #F5EEE5; color: #F5EEE5; } /* Marron */ /* agenda */ .bandeau_agenda { background: #DDD; } .jour_dimanche { background: #eee;color: #000; } .jour_encours { background: #FFF;color: #000; } .jour_gris { background: #eee;color: #000; } .jour_pris { background: #FFF;color: #000; } .calendrier-cadreagenda { background: #eee; } /* grille du calendrier pour espace public */ /* (pour le prive, style_prive predomine */ .bordure_claire { border: 1px solid #666; } .bordure_foncee { border: 1px solid #000; } .bordure_claire_basse { border-bottom: 1px solid #666; } .bordure_claire_left { border-left: 1px solid #666; } .bordure_claire_right { border-right: 1px solid #666; }spip/spip/squelettes-dist/auteur.html0000766000000000000000000000613611236524722021240 0ustar adminadministrators [(#NOM|textebrut) - ][(#NOM_SITE_SPIP|textebrut)] [] [(#REM) Favicon personnalisee a partir du logo (si filtres d'image) ] [(#MODELE{favicon}{favicon=#LOGO_AUTEUR})] [(#REM) Lien vers le flux RSS des articles de l'auteur ]
    [(#REM) Entete de la page + titre du site ] [(#REM) Contenu principal : affichage de l'auteur ]
    [(#REM) Fil d'Ariane ]
    <:accueil_site:> > <:info_auteurs:>[ > (#NOM|couper{80})]
    [(#REM) microformat vcard]
    [(#LOGO_AUTEUR||image_reduire{200,200})]

    #NOM

    [
    (#BIO)
    ] [

    <:voir_en_ligne:> : [(#NOM_SITE|sinon{[(#URL_SITE|couper{80})]})]

    ]
    [(#REM) / vcard] [(#REM) Articles de l'auteur ] #FORMULAIRE_ECRIRE_AUTEUR [

    <:info_notes:>

    (#NOTES)
    ]
    [(#REM) Menu de navigation laterale ] [(#REM) Menu de navigation laterale ]
    [(#REM) Autres auteurs ]
    [(#REM) Pied de page ]
    spip/spip/squelettes-dist/inc-head.html0000766000000000000000000000326011236524722021376 0ustar adminadministrators[(#REM) Head standard de toutes les pages ; les elements specifiques (title, description) figurent dans le squelette article.html ] [(#REM) Preciser le charset ] [(#REM) Fierement fabrique avec SPIP ] [(#REM) Lien vers le flux RSS du site ] [] [(#REM) Feuille de style par defaut pour le code genere par SPIP ] [] [(#REM) Feuille de style par defaut pour les formulaires de SPIP ] [] [(#REM) Feuille de style CSS pour l'affichage du site a l'ecran ] [] [(#REM) Feuille de style CSS pour l'impression ] [] [(#REM) Feuille de style personnalisee pour surcharger les precedentes A noter par defaut cette css n'existe pas ] [] [(#REM) Balise permettant aux plugins d'inserer des appels javascript ou css ; C'est ici que SPIP va inserer l'appel de la librairie jQuery Et appeler a la fin compacte_head pour agreger et compacter tout le head dans des fichiers statiques si l'option est cochee dans Configuration ] #INSERT_HEADspip/spip/squelettes-dist/engines-list.txt0000766000000000000000000000640411236524722022205 0ustar adminadministrators# ----------------------------------------------------------------------------- # Les Visiteurs - Engines List # ----------------------------------------------------------------------------- # [Engine Name] # word= | word => query | directory # host 1 # host 2 # hots ... # ----------------------------------------------------------------------------- # sort the list according your visits (see your referrers). # ----------------------------------------------------------------------------- [IP] rien= [0-9]+\.[0-9]+\.[0-9]+\.[0-9]+ [Google] (^q|\&q|as_q)= (www\.|ww\.|maps\.)?(google|gogole)\.(.*) (web|www).toile.com www\.cegetel\.net search\.conduit\.com search\.sweetim\.com chello\.fr [Voila] (kw|rdata)= (search|moteur)(.*)\.voila\.(fr|com) [Yahoo!] p= (.*)(search|ink|dir|google)\.yahoo\.([a-z]+)$ [AltaVista] q= (.*)altavista\.com [Ask] q= (.*)\.ask\.com [HotBot] query= www\.hotbot\.com [Freeserve] q= search\.freeserve\.com [Skeech] query= skeech\.com [Dogpile] query= (.*)dogpile\.com [Metacrawler] query= metacrawler\.com [Mirago] qry= www.mirago\.([a-z]+)$ [Nomade] s= (.*)\.nomade\.fr (.*)\.nomade\.tiscali\.fr (.*)\.nomade\.aliceadsl\.fr [Alice] qs= \.aliceadsl\. [Lycos] query= search\.lycos\.com vachercher\.lycos\.fr [Francite] name= recherche\.francite\.com [MSN] (q|s)= search(.*)\.msn\.([a-z.]+)$ leguide(.*)\.msn\.([a-z]+)$ search\.ninemsn\.com\.au [Bing] q= (.*)\.bing\.com bing\.com search\.live\.com [Excite] search= www\.excite\.fr (.*)\.excite\.co\.jp [AOL France] (query|q|r)= (.*)recherchet?\.aol\.fr [AOLsearch] query= (.*)search\.aol\.(.*) [AllTheWeb] q= www\.alltheweb\.com [ixquick] query= ixquick\.com [Netscape] search= search-intl\.netscape\.com search\.netscape\.com www\.netscape\.fr [Free] q= search(.*)\.free\.fr [9online] query= www\.9online\.fr [Naver] query= search\.naver\.com [Club Internet] q= recherche\.club-internet\.fr [Sympatico] query= search\.sli\.sympatico\.ca [Overture] Keywords= www\.overture\.com [moteur-recherche.net] keyword= www\.moteur-recherche\.net [Reacteur.com] kw= www\.reacteur\.com [francesurf] q= www\.francesurf\.net [n9uf] ((K|k)eywords|query)= (www\.)?neuf\.fr [MozBot] q= www\.mozbot\.([a-z]+)$ [Cegetel] q= (www\.)?cegetel\.([a-z]+)$ [MyWay] searchfor= kf\.mysearch\.myway\.com www\.mywebsearch\.com (.*)\.mysearch\.com [MonGenie] Keywords= www\.mongenie\.com [Need2Find] searchfor= kx\.search\.need2find\.com [Exalead] q= www\.exalead\.fr www\.exalead\.com [Virgilio.it] qs= search\.virgilio\.it [Libero.it] query= arianna\.libero\.it [LemmeFind] t= www\.lemmefind\.fr [NovoNeo] q= www\.novoneo\.com [MyWebSearch] searchfor= search\.mywebsearch\.com [Copernic] query= find\.copernic\.com [Seek] qry_str= \.seek\.fr [Orange, le moteur] rdata= www\.lemoteur\.fr [alOt] q= search\.alot\.com # # Dmoz # [dmoz.org] rien= (.*\.)?dmoz\.org [FoxRef] key= www\.foxref\.org [OneBigWorld] Keywords= fr\.onebigworld\.com [BlueWin] query= search\.bluewin\.ch [EO] q= www\.eo\.st [HooSeek] recherche= (www\.)?hooseek\.com [Lost] x_query= (www\.)?lo\.st [Babylon] q= search\.babylon\.com # # Services de mail # [(email)] rien= imp(.*)\.free\.fr fc\.kayenta\.com courrielweb\.cmaisonneuve\.qc\.ca (.*)mail\.(.*)\.([a-z]+)$ webmail([0-9]*)\.wanadoo\.fr www\.laposte\.net mail([0-9]*)\.voila\.fr \/(web)?mail\/ spip/spip/squelettes-dist/robots.txt.html0000766000000000000000000000051211236524722022051 0ustar adminadministrators#HTTP_HEADER{Content-Type: text/plain; charset=#CHARSET} # robots.txt # @url: #URL_SITE_SPIP # @generator: SPIP #SPIP_VERSION # @template: #SQUELETTE User-agent: * Disallow: /local/ Disallow: /ecrire/ Disallow: /plugins/ Disallow: /prive/ Disallow: /squelettes-dist/ Disallow: /squelettes/ Sitemap: #URL_SITE_SPIP/sitemap.xml spip/spip/squelettes-dist/distrib.html0000766000000000000000000000077311236524722021374 0ustar adminadministrators#HTTP_HEADER{Content-Type: application/x-javascript; charset=#CHARSET} document.write('
    '); document.write('

    [(#NOM_SITE_SPIP|addslashes)]

    ');spip/spip/squelettes-dist/rechercher.gif0000766000000000000000000000122411236524722021637 0ustar adminadministratorsGIF89aaᬮްϭ񴷷ū찲Ÿï갲ܫĭ꬯!a,aN7a` RWB'` -T< F `?53;9`I_KXC`Q`4JU`Y /Z(P> +$!@_1OP:"`6(膨 C)&*Ѐ(0) `A>°PNJ4O,8dW:q(hHO.AAT1.D< ;spip/spip/squelettes-dist/formulaires/0000777000000000000000000000000011266531337021371 5ustar adminadministratorsspip/spip/squelettes-dist/formulaires/administration.html0000766000000000000000000000305411236524722025304 0ustar adminadministrators [ <:analyse_xml:>[ ((#ENV{xhtml_error}))]][ <:admin_modifier_article:> ((#ENV{id_article}))][ <:admin_modifier_breve:> ((#ENV{id_breve}))][ <:admin_modifier_rubrique:> ((#ENV{id_rubrique}))][ <:admin_modifier_mot:> ((#ENV{id_mot}))][ <:icone_modifier_site:> ((#ENV{id_syndic}))][ <:admin_modifier_auteur:> ((#ENV{id_auteur}))][ <:espace_prive:>] <:admin_recalculer:>[(#ENV{use_cache})][ [<:info_visites:> (#ENV{visites})][; <:info_popularite_5:> (#ENV{popularite})]][ <:previsualisation:>][ <:admin_debug:>] spip/spip/squelettes-dist/formulaires/forum.html0000766000000000000000000001377411236524722023421 0ustar adminadministrators
    [(#REM) pour IE qui sinon se perd dans l'ajax !, ne pas retirer]
    [

    (#ENV*{message_ok})

    ] [

    (#ENV*{message_erreur})

    ] [(#ENV{login_forum_abo}) ] [(#ENV{editable}) [(#REM) Bloc de previsualisation du forum envoye Si on valide la previsu, on n'envoie pas en ajax car, si le post reussit il faudra certainement redessiner toute la page pour afficher le nouveau forum ][
    [(#ACTION_FORMULAIRE{#ENV{action}})] [] [(#INCLURE{fond=formulaires/inc-forum_ajouter_mot}{ajouter_mot})] (#ENV*{erreurs}|table_valeur{previsu})
    ]
    [(#ACTION_FORMULAIRE{#ENV{action}})] [] [
    <:bouton_radio_modere_priori:>

    (#ENV{modere})<:forum_info_modere:>

    ] [(#ENV**{afficher_texte}|choixsiegal{'non', ' ',''}) []

    ] [(#ENV**{afficher_texte}|choixsiegal{'non', '',' '})
    <:form_pet_message_commentaire:>[ (#CONFIG{forums_titre}|!={non}|non) ]
      [
    • (#INCLURE{fond=formulaires/inc-forum_bloc_choix_mots}{table=#ENV*{table}}{ajouter_mot})
    • ] [(#CONFIG{forums_titre}|!={non}|oui)
    • [(#ENV**{erreurs}|table_valeur{titre})]
    • ] [(#CONFIG{forums_texte}|!={non}|?{
    • [(#ENV**{erreurs}|table_valeur{texte})]

      <:info_creation_paragraphe:>

      [(#ENV**{config}|table_valeur{afficher_barre}|?{#VAL{texte}|barre_typo{#LANG,1}})]
    • })]
    [(#CONFIG{forums_urlref}|!={non}|?{
    <:forum_lien_hyper:>

    <:forum_page_url:>

    • [(#ENV**{erreurs}|table_valeur{nom_site})]
    • [(#ENV**{erreurs}|table_valeur{url_site})]
    })] [
    <:bouton_ajouter_document:>
    • [(#ENV**{erreurs}|table_valeur{document_forum})] [
      (#ENV{ajouter_document})
      ]
      []
    ] [(#REM) Piege a robots spammeurs ]

    ]
    [(#REM) Sauver les donnees du formulaire dans un cookie, si on quitte la page, et les remettre quand on revient (dans les limites de 4ko etc) ] ]
    spip/spip/squelettes-dist/formulaires/forum.php0000766000000000000000000002664711236524722023247 0ustar adminadministrators '', #ne sert pas dans ce cas, on la vide pour mutualiser le cache 'editable'=>false, 'login_forum_abo'=>' ', 'inscription' => generer_url_public('identifiants', 'lang='.$GLOBALS['spip_lang']), 'oubli' => generer_url_public('spip_pass','lang='.$GLOBALS['spip_lang'],true), ); } } // Tableau des valeurs servant au calcul d'une signature de securite. // Elles seront placees en Input Hidden pour que inc/forum_insert // recalcule la meme chose et verifie l'identite des resultats. // Donc ne pas changer la valeur de ce tableau entre le calcul de // la signature et la fabrication des Hidden // Faire attention aussi a 0 != '' // id_rubrique est parfois passee pour les articles, on n'en veut pas $ids = array(); if ($id_rubrique > 0 AND ($id_article OR $id_breve OR $id_syndic)) $id_rubrique = 0; foreach (array('id_article', 'id_breve', 'id_forum', 'id_rubrique', 'id_syndic') as $o) { $ids[$o] = ($x = intval($$o)) ? $x : ''; } // ne pas mettre '', sinon le squelette n'affichera rien. $previsu = ' '; // au premier appel (pas de Post-var nommee "retour_forum") // memoriser eventuellement l'URL de retour pour y revenir apres // envoi du message ; aux appels suivants, reconduire la valeur. // Initialiser aussi l'auteur if ($retour_forum = rawurldecode(_request('retour'))) $retour_forum = str_replace('&var_mode=recalcul','',$retour_forum); else { // par defaut, on veut prendre url_forum(), mais elle ne sera connue // qu'en sortie, on inscrit donc une valeur absurde ("!") $retour_forum = "!"; // sauf si on a passe un parametre en argument (exemple : {#SELF}) if ($url_param_retour) $retour_forum = str_replace('&', '&', $url_param_retour); $retour_forum = rawurlencode($retour_forum); } if (_request('retour_forum')){ $arg = forum_fichier_tmp(join('', $ids)); $securiser_action = charger_fonction('securiser_action', 'inc'); // on sait que cette fonction est dans le fichier associe $hash = calculer_action_auteur("ajout_forum-$arg"); } // pour les hidden $script_hidden = ""; foreach ($ids as $id => $v) $script_hidden .= ""; $script_hidden .= ""; $script_hidden .= ""; $script_hidden .= ""; $script_hidden .= ""; $script_hidden .= ""; // l'ajout de documents est-il autorise ? // cf. verifier.php if ($formats = forum_documents_acceptes()) { include_spip('inc/securiser_action'); $cle_ajouter_document = calculer_cle_action('ajouter-document-'.join('-',array_map('intval',$ids))); } return array( 'modere' => (($type != 'pri') ? '' : ' '), 'nom_site' => '', 'table' => $table, 'texte' => '', 'config' => array('afficher_barre' => ($GLOBALS['meta']['forums_afficher_barre']!='non'?' ':'')), 'titre' => str_replace('~', ' ', extraire_multi($titre)), 'action' => $script, # ce sur quoi on fait le action='...' '_hidden' => $script_hidden, # pour les variables hidden 'url_site' => "http://", 'cle_ajouter_document' => $cle_ajouter_document, 'formats_documents_forum' => $formats, 'ajouter_document' => $_FILES['ajouter_document']['name'], 'nobot' => _request('nobot'), 'ajouter_groupe' => $ajouter_groupe, 'ajouter_mot' => (is_array($ajouter_mot) ? $ajouter_mot : array($ajouter_mot)), 'id_forum' => $id_forum, // passer id_forum au formulaire pour lui permettre d'afficher a quoi l'internaute repond '_sign'=>implode('_',$ids) ); } // Une securite qui nous protege contre : // - les doubles validations de forums (derapages humains ou des brouteurs) // - les abus visant a mettre des forums malgre nous sur un article (??) // On installe un fichier temporaire dans _DIR_TMP (et pas _DIR_CACHE // afin de ne pas bugguer quand on vide le cache) // Le lock est leve au moment de l'insertion en base (inc-messforum) // Ce systeme n'est pas fonctionnel pour les forums sans previsu (notamment // si $afficher_texte = 'non') // http://doc.spip.org/@forum_fichier_tmp function forum_fichier_tmp($arg) { # astuce : mt_rand pour autoriser les hits simultanes while (($alea = time() + @mt_rand()) + intval($arg) AND @file_exists($f = _DIR_TMP."forum_$alea.lck")) {}; spip_touch ($f); # et maintenant on purge les locks de forums ouverts depuis > 4 h if ($dh = @opendir(_DIR_TMP)) while (($file = @readdir($dh)) !== false) if (preg_match('/^forum_([0-9]+)\.lck$/', $file) AND (time()-@filemtime(_DIR_TMP.$file) > 4*3600)) spip_unlink(_DIR_TMP.$file); return $alea; } function formulaires_forum_verifier_dist( $titre, $table, $type, $script, $id_rubrique, $id_forum, $id_article, $id_breve, $id_syndic, $ajouter_mot, $ajouter_groupe, $afficher_texte, $url_param_retour) { include_spip('inc/acces'); include_spip('inc/texte'); include_spip('inc/forum'); include_spip('inc/session'); include_spip('base/abstract_sql'); $erreurs = array(); // desactiver id_rubrique si un id_article ou autre existe dans le contexte if ($id_article OR $id_breve OR $id_forum OR $id_syndic) $id_rubrique = 0; // stocker un eventuel document dans un espace temporaire // portant la cle du formulaire ; et ses metadonnees avec if (!isset($GLOBALS['visiteur_session']['tmp_forum_document'])) session_set('tmp_forum_document', sous_repertoire(_DIR_TMP,'documents_forum').md5(uniqid(rand()))); $tmp = $GLOBALS['visiteur_session']['tmp_forum_document']; $doc = &$_FILES['ajouter_document']; if (isset($_FILES['ajouter_document']) AND $_FILES['ajouter_document']['tmp_name']) { // securite : // verifier si on possede la cle (ie on est autorise a poster) // (sinon tant pis) ; cf. charger.php pour la definition de la cle if (_request('cle_ajouter_document') != calculer_cle_action($a = "ajouter-document-$id_article-$id_breve-$id_forum-$id_rubrique-$id_syndic")) { $erreurs['document_forum'] = _T('public:documents_interdits_forum') . "ajouter-document-$id_article-$id_breve-$id_forum-$id_rubrique-$id_syndic" .", " ._request('cle_ajouter_document') ; unset($_FILES['ajouter_document']); } else { include_spip('inc/ajouter_documents'); list($extension,$doc['name']) = fixer_extension_document($doc); $acceptes = forum_documents_acceptes(); if (!in_array($extension, $acceptes)) { # normalement on n'arrive pas ici : pas d'upload si aucun format if (!$formats = join(', ',$acceptes)) $formats = '-'; //_L('aucun'); $erreurs['document_forum'] = _T('public:formats_acceptes', array('formats' => $formats)); } else { include_spip('inc/getdocument'); if (!deplacer_fichier_upload($doc['tmp_name'], $tmp.'.bin')) $erreurs['document_forum'] = _T('copie_document_impossible'); # else if (...) # verifier le type_document autorise # retailler eventuellement les photos } // si ok on stocke les meta donnees, sinon on efface if (isset($erreurs['document_forum'])) { spip_unlink($tmp.'.bin'); unset ($_FILES['ajouter_document']); } else { $doc['tmp_name'] = $tmp.'.bin'; ecrire_fichier($tmp.'.txt', serialize($doc)); } } } // restaurer le document uploade au tour precedent else if (file_exists($tmp.'.bin')) { if (_request('supprimer_document_ajoute')) { spip_unlink($tmp.'.bin'); spip_unlink($tmp.'.txt'); } else if (lire_fichier($tmp.'.txt', $meta)) $doc = @unserialize($meta); } if (strlen($texte = _request('texte')) < 10 AND !$ajouter_mot AND $GLOBALS['meta']['forums_texte'] == 'oui') $erreurs['texte'] = _T('forum_attention_dix_caracteres'); else if (defined('_FORUM_LONGUEUR_MAXI') AND _FORUM_LONGUEUR_MAXI > 0 AND strlen($texte) > _FORUM_LONGUEUR_MAXI) $erreurs['texte'] = _T('forum_attention_trop_caracteres', array( 'compte' => strlen($texte), 'max' => _FORUM_LONGUEUR_MAXI )); if (strlen($titre=_request('titre')) < 3 AND $GLOBALS['meta']['forums_titre'] == 'oui') $erreurs['titre'] = _T('forum_attention_trois_caracteres'); if (!count($erreurs) AND !_request('confirmer_previsu_forum')){ if ($afficher_texte != 'non') { $previsu = inclure_previsu($texte, $titre, _request('url_site'), _request('nom_site'), _request('ajouter_mot'), $doc, $id_rubrique, $id_forum, $id_article, $id_breve, $id_syndic); $erreurs['previsu'] = $previsu; } } return $erreurs; } function forum_documents_acceptes() { $formats = trim($GLOBALS['meta']['formats_documents_forum']); if (!$formats) return array(); if ($formats !== '*') $formats = array_filter(preg_split(',[^a-zA-Z0-9/+_],', $formats)); else { include_spip('base/typedoc'); $formats = array_keys($GLOBALS['tables_mime']); } sort($formats); return $formats; } // http://doc.spip.org/@inclure_previsu function inclure_previsu($texte,$titre, $url_site, $nom_site, $ajouter_mot, $doc, $id_rubrique, $id_forum, $id_article, $id_breve, $id_syndic) { global $table_des_traitements; $bouton = _T('forum_message_definitif'); include_spip('public/assembler'); include_spip('public/composer'); // appliquer les traitements de #TEXTE a la previsu // comme on voit c'est complique... y a peut-etre plus simple ? $evaltexte = isset($table_des_traitements['TEXTE']['forums']) ? $table_des_traitements['TEXTE']['forums'] : $table_des_traitements['TEXTE'][0]; $evaltexte = '$tmptexte = '.str_replace('%s', '$texte', $evaltexte).';'; eval($evaltexte); // supprimer les
    de la previsualisation // (sinon on ne peut pas faire ... dans les forums) return preg_replace("@<(/?)form\b@ism", '<\1div', inclure_balise_dynamique(array('formulaires/inc-forum_previsu', 0, array( 'titre' => safehtml(typo($titre)), 'texte' => $tmptexte, 'notes' => safehtml(calculer_notes()), 'url_site' => vider_url($url_site), 'nom_site' => safehtml(typo($nom_site)), 'ajouter_mot' => (is_array($ajouter_mot) ? $ajouter_mot : array($ajouter_mot)), 'ajouter_document' => $doc, 'erreur' => $erreur, 'bouton' => $bouton, 'id_rubrique' => $id_rubrique, 'id_forum' => $id_forum, 'id_article' => $id_article, 'id_breve' => $id_breve, 'id_syndic' => $id_syndic ) ), false)); } function formulaires_forum_traiter_dist() { $forum_insert = charger_fonction('forum_insert', 'inc'); list($redirect,$id_forum) = $forum_insert(); return array('redirect'=>$redirect,'id_forum'=>$id_forum); } ?> spip/spip/squelettes-dist/formulaires/ecrire_auteur.html0000766000000000000000000000530611236524722025117 0ustar adminadministrators

    [

    (#ENV*{message_ok})

    ] [

    (#ENV*{message_erreur})

    ] [(#ENV{editable}) [(#REM) declarer les hidden qui declencheront le service du formulaire parametre : url d'action ] #ACTION_FORMULAIRE{#ENV{action}} [(#REM) Previsualisation... ] [(#ENV*{erreurs}|table_valeur{previsu}|oui)
    <:previsualisation:>
    • #ENV{sujet_message_auteur} - #ENV{email_message_auteur}
    • [(#ENV{texte_message_auteur}|nl2br)]

    ] [(#REM) Sinon, formulaire normal ]
    <:envoyer_message:>
    • [(#ENV*{erreurs}|table_valeur{email_message_auteur})]
    • [(#ENV*{erreurs}|table_valeur{sujet_message_auteur})]
    • [(#ENV*{erreurs}|table_valeur{texte_message_auteur})]
    [(#REM) Piege a robots spammeurs ]

    ]
    spip/spip/squelettes-dist/formulaires/signature.php0000766000000000000000000003153111236524722024104 0ustar adminadministrators $id_article, 'session_nom' => sinon($GLOBALS['visiteur_session']['session_nom'], $GLOBALS['visiteur_session']['nom']), 'session_email'=> sinon($GLOBALS['visiteur_session']['session_email'], $GLOBALS['visiteur_session']['email']), 'signature_nom_site'=>'', 'signature_url_site'=>'http://', '_texte'=>$petition, '_message'=>$message, 'message'=>'', 'site_obli' => $site_obli, 'debut_signatures'=>'' // pour le nettoyer de l'url d'action ! ); if ($c = _request('var_confirm')) { $valeurs['_confirm'] = $c; $valeurs['editable'] = false; } return $valeurs; } function affiche_reponse_confirmation($confirm) { $reponse_confirmation = charger_fonction('reponse_confirmation','formulaires/signature/'); return $reponse_confirmation($confirm); # calculee plus tot: assembler.php } function formulaires_signature_verifier_dist($id_article, $petition, $texte, $site_obli, $message) { $erreurs = array(); $oblis = array('session_email','session_email'); if ($site_obli){ $oblis[] = 'signature_nom_site'; $oblis[] = 'signature_url_site'; set_request('signature_url_site', vider_url(_request('signature_url_site'))); } foreach ($oblis as $obli) if (!_request($obli)) $erreurs[$obli] = _T('info_obligatoire'); if ($nom = _request('session_nom') AND strlen($nom) < 2) $erreurs['nom_email'] = _T('form_indiquer_nom'); include_spip('inc/filtres'); if (($mail=_request('session_email')) == _T('info_mail_fournisseur')) $erreurs['adresse_email'] = _T('form_indiquer'); elseif ($mail AND !email_valide($mail)) $erreurs['adresse_email'] = _T('form_email_non_valide'); elseif (strlen(_request('nobot')) OR (@preg_match_all(',\bhref=[\'"]?http,i', // bug PHP $message # , PREG_PATTERN_ORDER ) >2)) { #$envoyer_mail = charger_fonction('envoyer_mail','inc'); #envoyer_mail('email_moderateur@example.tld', 'spam intercepte', var_export($_POST,1)); $erreurs['message_erreur'] = _T('form_pet_probleme_liens'); } if ($site_obli){ if (!vider_url($url_site = _request('signature_url_site'))) { $erreurs['signature_url_site'] = _T('form_indiquer_nom_site'); } elseif (!count($erreurs)) { include_spip('inc/distant'); if (!recuperer_page($url_site, false, true, 0)) $erreurs['signature_url_site'] = _T('form_pet_url_invalide'); } } if (!count($erreurs)){ // tout le monde est la. include_spip('base/abstract_sql'); $row = sql_fetsel('*', 'spip_petitions', "id_article=".intval($id_article)); if (!$row) $erreurs['message_erreur'] = _T('form_pet_probleme_technique'); else { $email_unique = $row['email_unique'] == "oui"; $site_unique = $row['site_unique'] == "oui"; // Refuser si deja signe par le mail ou le site quand demande // Il y a un acces concurrent potentiel, // mais ca n'est qu'un cas particulier de qq n'ayant jamais confirme'. // On traite donc le probleme a la confirmation. if ($email_unique) { $r = sql_countsel('spip_signatures', "id_article=$id_article AND ad_email=" . sql_quote($mail) . " AND statut='publie'"); if ($r) $erreurs['message_erreur'] = _T('form_pet_deja_signe'); } if ($site_unique) { $r = sql_countsel('spip_signatures', "id_article=$id_article AND url_site=" . sql_quote($url_site) . " AND (statut='publie' OR statut='poubelle')"); if ($r) $erreurs['message_erreur'] = _T('form_pet_site_deja_enregistre'); } } } return $erreurs; } function formulaires_signature_traiter_dist($id_article, $petition, $texte, $site_obli, $message) { $reponse = _T('form_pet_probleme_technique'); include_spip('base/abstract_sql'); if (spip_connect()) { $controler_signature = charger_fonction('controler_signature', 'inc'); $reponse = $controler_signature($id_article, _request('session_nom'), _request('session_email'), _request('message'), _request('signature_nom_site'), _request('signature_url_site'), _request('url_page')); } return array('message_ok'=>$reponse); } // Retour a l'ecran du lien de confirmation d'une signature de petition. // Si var_confirm est non vide, c'est l'appel dans public/assembler.php // pour vider le cache au demarrage afin que la nouvelle signature apparaisse. // Sinon, c'est l'execution du formulaire et on retourne le message // de confirmation ou d'erreur construit lors de l'appel par assembler.php // Le controle d'unicite du mail ou du site (si requis) refait ici correspond // au cas de mails de demande de confirmation laisses sans reponse // http://doc.spip.org/@reponse_confirmation_dist function formulaires_signature_reponse_confirmation_dist($var_confirm = '') { static $confirm = null; // reponse mise en cache dans la session ? $code_message = 'signature_message_'.strval($var_confirm); if (isset($GLOBALS['visiteur_session'][$code_message])) return $GLOBALS['visiteur_session'][$code_message]; // reponse deja calculee depuis public/assembler.php if (isset($confirm)) return $confirm; if ($var_confirm == 'publie' OR $var_confirm == 'poubelle') return ''; if (!spip_connect()) { $confirm = _T('form_pet_probleme_technique'); return ''; } include_spip('inc/texte'); include_spip('inc/filtres'); // Suppression d'une signature par un moderateur ? // Cf. plugin notifications if (isset($_GET['refus'])) { // verifier validite de la cle de suppression // l'id_signature est dans var_confirm include_spip('inc/securiser_action'); if ($id_signature = intval($var_confirm) AND ( $_GET['refus'] == _action_auteur("supprimer signature $id_signature", '', '', 'alea_ephemere') OR $_GET['refus'] == _action_auteur("supprimer signature $id_signature", '', '', 'alea_ephemere_ancien') )) { sql_updateq("spip_signatures", array("statut" => 'poubelle'), "id_signature=$id_signature"); $confirm = _T('info_signature_supprimee'); } else $confirm = _T('info_signature_supprimee_erreur'); return ''; } $row = sql_fetsel('*', 'spip_signatures', "statut=" . sql_quote($var_confirm), '', "1"); if (!$row) { $confirm = _T('form_pet_aucune_signature'); return ''; } $id_signature = $row['id_signature']; $id_article = $row['id_article']; $adresse_email = $row['ad_email']; $url_site = $row['url_site']; $row = sql_fetsel('email_unique, site_unique', 'spip_petitions', "id_article=$id_article"); $email_unique = $row['email_unique'] == "oui"; $site_unique = $row['site_unique'] == "oui"; sql_updateq('spip_signatures', array('statut' => 'publie', 'date_time' => date('Y-m-d H:i:s')), "id_signature=$id_signature"); if ($email_unique) { $r = "id_article=$id_article AND ad_email=" . sql_quote($adresse_email); if (signature_entrop($r)) $confirm = _T('form_pet_deja_signe'); } if ($site_unique) { $r = "id_article=$id_article AND url_site=" . sql_quote($url_site); if (signature_entrop($r)) $confirm = _T('form_pet_site_deja_enregistre'); } include_spip('inc/session'); if (!$confirm) { $confirm = _T('form_pet_signature_validee'); // noter dans la session que l'email est valide // de facon a permettre de signer les prochaines // petitions sans refaire un tour d'email session_set('email_confirme', $adresse_email); // invalider les pages ayant des boucles signatures include_spip('inc/invalideur'); suivre_invalideur("id='varia/pet$id_article'"); } // Conserver la reponse dans la session du visiteur if ($confirm) session_set($code_message, $confirm); } // // Recevabilite de la signature d'une petition // les controles devraient mantenant etre faits dans formulaires_signature_verifier() // // http://doc.spip.org/@inc_controler_signature_dist function inc_controler_signature_dist($id_article, $nom, $mail, $message, $site, $url_site, $url_page) { include_spip('inc/texte'); include_spip('inc/filtres'); // tout le monde est la. // cela a ete verifie en amont, dans formulaires_signature_verifier() if (!$row = sql_fetsel('*', 'spip_petitions', "id_article=$id_article")) return _T('form_pet_probleme_technique'); $statut = ""; if (!$ret = signature_a_confirmer($id_article, $url_page, $nom, $mail, $site, $url_site, $message, $lang, $statut)) return _T('form_pet_probleme_technique'); $id_signature = sql_insertq('spip_signatures', array( 'id_article' => $id_article, 'date_time' => date('Y-m-d H:i:s'), 'statut' => $statut, 'ad_email' => $mail, 'url_site' => $url_site)); if (!$id_signature) return _T('form_pet_probleme_technique'); include_spip('inc/modifier'); revision_signature($id_signature, array( 'nom_email' => $nom, 'ad_email' => $mail, 'message' => $message, 'nom_site' => $site, 'url_site' => $url_site )); return $ret; } // http://doc.spip.org/@signature_a_confirmer function signature_a_confirmer($id_article, $url_page, $nom, $mail, $site, $url, $msg, $lang, &$statut) { // Si on est deja connecte et que notre mail a ete valide d'une maniere // ou d'une autre, on entre directement la signature dans la base, sans // envoyer d'email. Sinon email de verification if ( // Cas 1: on est loge et on signe avec son vrai email ( isset($GLOBALS['visiteur_session']['statut']) AND $GLOBALS['visiteur_session']['session_email'] == $GLOBALS['visiteur_session']['email'] AND strlen($GLOBALS['visiteur_session']['email']) ) // Cas 2: on a deja signe une petition, et on conserve le meme email OR ( isset($GLOBALS['visiteur_session']['email_confirme']) AND $GLOBALS['visiteur_session']['session_email'] == $GLOBALS['visiteur_session']['email_confirme'] AND strlen($GLOBALS['visiteur_session']['session_email']) ) ) { // Si on est en ajax on demande a reposter sans ajax, car il faut // recharger toute la page pour afficher la signature refuser_traiter_formulaire_ajax(); $statut = 'publie'; // invalider le cache ! include_spip('inc/invalideur'); suivre_invalideur("id='varia/pet$id_article'"); // message de reussite : en ajax, preciser qu'il faut recharger la page // pour voir le resultat return _T('form_pet_signature_validee'); } // // Cas normal : envoi d'une demande de confirmation // $row = sql_fetsel('titre,lang', 'spip_articles', "id_article=$id_article"); $lang = lang_select($row['lang']); $titre = textebrut(typo($row['titre'])); if ($lang) lang_select(); if (!strlen($statut)) $statut = signature_test_pass(); if ($lang != $GLOBALS['meta']['langue_site']) $url_page = parametre_url($url_page, "lang", $lang,'&'); $url_page = parametre_url($url_page, 'var_confirm', $statut, '&') . "#sp$id_article"; $r = _T('form_pet_mail_confirmation', array('titre' => $titre, 'nom_email' => $nom, 'nom_site' => $site, 'url_site' => $url, 'url' => $url_page, 'message' => $msg)); $titre = _T('form_pet_confirmation')." ". $titre; $envoyer_mail = charger_fonction('envoyer_mail','inc'); if ($envoyer_mail($mail,$titre, $r)) return _T('form_pet_envoi_mail_confirmation',array('email'=>$mail)); return false; # erreur d'envoi de l'email } // Pour eviter le recours a un verrou (qui bloque l'acces a la base), // on commence par inserer systematiquement la signature // puis on demande toutes celles ayant la propriete devant etre unique // (mail ou site). S'il y en a plus qu'une on les retire sauf la premiere // En cas d'acces concurrents il y aura des requetes de retraits d'elements // deja detruits. Bizarre ? C'est mieux que de bloquer! // http://doc.spip.org/@signature_entrop function signature_entrop($where) { $where .= " AND statut='publie'"; $query = sql_select('id_signature', 'spip_signatures', $where,'',"date_time desc"); $n = sql_count($query); if ($n>1) { $entrop = array(); for ($i=$n-1;$i;$i--) { $r = sql_fetch($query); $entrop[]=$r['id_signature']; } sql_free($query); $where .= " OR " . sql_in('id_signature', $entrop); sql_delete('spip_signatures', $where); } return $entrop; } // Creer un mot de passe aleatoire et verifier qu'il est unique // dans la table des signatures // http://doc.spip.org/@signature_test_pass function signature_test_pass() { include_spip('inc/acces'); do { $passw = creer_pass_aleatoire(); } while (sql_countsel('spip_signatures', "statut='$passw'") > 0); return $passw; } ?> spip/spip/squelettes-dist/formulaires/mot_de_passe.php0000766000000000000000000000711711236524722024550 0ustar adminadministrators'5poubelle'","pass<>''")); } elseif ($p=_request('p')) { $p = preg_replace(',[^0-9a-f.],i','',$p); if ($p AND $id_auteur = sql_getfetsel('id_auteur','spip_auteurs',array('cookie_oubli='.sql_quote($p),"statut<>'5poubelle'","pass<>''"))) $valeurs['_hidden'] = ''; } if ($id_auteur){ $valeurs['id_auteur'] = $id_auteur; // a toutes fins utiles pour le formulaire } else { $valeurs['_hidden'] = _T('pass_erreur_code_inconnu'); $valeurs['editable'] = false; // pas de saisie } return $valeurs; } /** * Verification de la saisie du mot de passe. * On verifie qu'un mot de passe est saisi, et que sa longuer est suffisante * Ce serait le lieu pour verifier sa qualite (caracteres speciaux ...) * * @param int $id_auteur */ function formulaires_mot_de_passe_verifier_dist($id_auteur=null){ $erreurs = array(); if (!_request('oubli')) $erreurs['oubli'] = _T('info_obligatoire'); else if (strlen(_request('oubli')) < 6) $erreurs['oubli'] = _T('info_passe_trop_court'); return $erreurs; } /** * Modification du mot de passe d'un auteur. * Utilise le cookie d'oubli fourni en url ou l'argument du formulaire pour identifier l'auteur * * @param int $id_auteur */ function formulaires_mot_de_passe_traiter_dist($id_auteur=null){ $message = ''; include_spip('base/abstract_sql'); if ($id_auteur=intval($id_auteur)) { $row = sql_fetsel('id_auteur,login','spip_auteurs',array('id_auteur='.intval($id_auteur),"statut<>'5poubelle'","pass<>''")); } elseif ($p=_request('p')) { $p = preg_replace(',[^0-9a-f.],i','',$p); $row = sql_fetsel('id_auteur,login','spip_auteurs',array('cookie_oubli='.sql_quote($p),"statut<>'5poubelle'","pass<>''")); } if ($row && ($id_auteur = $row['id_auteur']) && ($oubli = _request('oubli'))) { include_spip('inc/acces'); $mdpass = md5($oubli); $htpass = generer_htpass($oubli); include_spip('base/abstract_sql'); sql_updateq('spip_auteurs', array('htpass' =>$htpass, 'pass'=>$mdpass, 'alea_actuel'=>'', 'cookie_oubli'=>''), "id_auteur=" . intval($id_auteur)); $login = $row['login']; $message = "" . _T('pass_nouveau_enregistre') . "". "

    " . _T('pass_rappel_login', array('login' => $login)); } return array('message_ok'=>$message); } ?> spip/spip/squelettes-dist/formulaires/inc-forum_bloc_choix_mots.html0000766000000000000000000000060311236524722027406 0ustar adminadministrators#SET{table,#VAL{'(^|,)('}|concat{#ENV{table,rienderien}}|concat{#CONFIG{mots_cles_forums}|choixsiegal{oui,'|forum',''},')(,|$)'} [(#ID_GROUPE|in_any{#ENV**{ajouter_groupe},' '})

    <:mots_clefs:> : #TITRE
    ]spip/spip/squelettes-dist/formulaires/inscription.html0000766000000000000000000000450211236524722024617 0ustar adminadministrators
    [

    (#ENV*{message_ok})

    ] [

    (#ENV*{message_erreur})

    ] [(#ENV{editable})
    #ACTION_FORMULAIRE{#ENV{action}}
    [(#REM) on affiche plus ce message en cas d'erreur pour eviter d'allonger trop le formulaire] [(#ENV*{message_erreur}|non) [<:pass_vousinscrire:>

    (#ENV*{_commentaire})

    ] ]<:form_forum_identifiants:>

    <:form_forum_indiquer_nom_email:>

    • [(#ENV*{erreurs}|table_valeur{nom_inscription})]
    • [(#ENV*{erreurs}|table_valeur{mail_inscription})]
    [(#REM) Piege a robots spammeurs ]

    [] ]
    [(#ENV{focus,''}|?{' '})
    ]spip/spip/squelettes-dist/formulaires/inc-choix_mots.html0000766000000000000000000000070011236524722025175 0ustar adminadministrators
    • []
    spip/spip/squelettes-dist/formulaires/inc-login_forum.html0000766000000000000000000000243411236524722025347 0ustar adminadministrators[(#REM) Formulaire d'identification sur le forum Si la session est authentifiee, on propose la deconnexion Si la session n'est pas authentifiee, on presente un formulaire nom/email Pour les forums sur abonnement, un squelette specifique presente les regles ]
    <:forum_qui_etes_vous:> [(#SESSION{auth}|?{' '}) [

    <:forum_votre_nom:> (#SESSION{nom}|typo) [<:icone_deconnecter:>]

    ] ] [(#SESSION{auth}|?{'',' '})
    • [(#CONFIG{accepter_inscriptions}|=={oui}|?{' '}) [<:lien_connecter:>] ]
    ]
    spip/spip/squelettes-dist/formulaires/site.php0000766000000000000000000000424011236524722023044 0ustar adminadministrators'','url_site'=>'http://','description_site'=>''); } function formulaires_site_verifier_dist($id_rubrique){ $erreurs = array(); if (!$nom = _request('nom_site')) $erreurs['nom_site'] = _T("info_obligatoire"); else { if((strlen ($nom) < 2) OR (strlen(_request('nobot'))>0)) $erreurs['email_message_auteur'] = _T('form_prop_indiquer_nom_site'); } if (!$url = _request('url_site')) $erreurs['url_site'] = _T("info_obligatoire"); if (!count($erreurs)) { // Tester l'URL du site include_spip('inc/distant'); if (!recuperer_page($url)) $erreurs['url_site'] = _T('form_pet_url_invalide'); } return $erreurs; } function formulaires_site_traiter_dist($id_rubrique){ $res = array('message_erreur'=>_T('titre_probleme_technique')); $nom = _request('nom_site'); $url = _request('url_site'); $desc = _request('description_site'); include_spip('base/abstract_sql'); if ($id_syndic = sql_insertq('spip_syndic', array( 'nom_site' => $nom, 'url_site' => $url, 'id_rubrique' => $id_rubrique, 'id_secteur' => sql_getfetsel('id_secteur','spip_rubriques','id_rubrique='.sql_quote($id_rubrique)), 'descriptif' => $desc, 'date' => date('Y-m-d H:i:s'), 'date_syndic' => date('Y-m-d H:i:s'), 'statut' => 'prop', 'syndication' => 'non'))) $res = array('message_ok' => _T('form_prop_enregistre'), 'id_syndic'=>$id_syndic); return $res; } ?> spip/spip/squelettes-dist/formulaires/site.html0000766000000000000000000000344711236524722023231 0ustar adminadministrators
    [

    (#ENV*{message_ok})

    ] [

    (#ENV*{message_erreur})

    ] [(#ENV{editable})
    #ACTION_FORMULAIRE{#ENV{action}}
    <:info_site:>

    <:proposer_site:>

    • [(#ENV*{erreurs}|table_valeur{nom_site})]
    • [(#ENV*{erreurs}|table_valeur{url_site})]
    • [(#ENV*{erreurs}|table_valeur{description_site})]
    [(#REM) Piege a robots spammeurs ]

    ]
    spip/spip/squelettes-dist/formulaires/inc-forum_ajouter_mot.html0000766000000000000000000000017011236524722026562 0ustar adminadministratorsspip/spip/squelettes-dist/formulaires/ecrire_auteur.php0000766000000000000000000000546611236524722024751 0ustar adminadministrators'', 'texte_message_auteur'=>'', 'email_message_auteur'=>$GLOBALS['visiteur_session']['email'] ); // id du formulaire (pour en avoir plusieurs sur une meme page) $valeurs['id'] = ($id_auteur ? '_'.$id_auteur : '_ar'.$id_article); // passer l'id_auteur au squelette $valeurs['id_auteur'] = $id_auteur; $valeurs['id_article'] = $id_article; return $valeurs; } function formulaires_ecrire_auteur_verifier_dist($id_auteur, $id_article, $mail){ $erreurs = array(); include_spip('inc/filtres'); if (!$adres = _request('email_message_auteur')) $erreurs['email_message_auteur'] = _T("info_obligatoire"); elseif(!email_valide($adres)) $erreurs['email_message_auteur'] = _T('form_prop_indiquer_email'); else { include_spip('inc/session'); session_set('email', $adres); } if (!$sujet=_request('sujet_message_auteur')) $erreurs['sujet_message_auteur'] = _T("info_obligatoire"); elseif(!(strlen($sujet)>3)) $erreurs['sujet_message_auteur'] = _T('forum_attention_trois_caracteres'); if (!$texte=_request('texte_message_auteur')) $erreurs['texte_message_auteur'] = _T("info_obligatoire"); elseif(!(strlen($texte)>10)) $erreurs['texte_message_auteur'] = _T('forum_attention_dix_caracteres'); if (!_request('confirmer') AND !count($erreurs)) $erreurs['previsu']=' '; return $erreurs; } function formulaires_ecrire_auteur_traiter_dist($id_auteur, $id_article, $mail){ $adres = _request('email_message_auteur'); $sujet=_request('sujet_message_auteur'); $texte=_request('texte_message_auteur'); $texte .= "\n\n-- "._T('envoi_via_le_site')." ".supprimer_tags(extraire_multi($GLOBALS['meta']['nom_site']))." (".$GLOBALS['meta']['adresse_site']."/) --\n"; $envoyer_mail = charger_fonction('envoyer_mail','inc'); if ($envoyer_mail($mail, $sujet, $texte, $adres, "X-Originating-IP: ".$GLOBALS['ip'])) $message = _T('form_prop_message_envoye'); else $message = _T('pass_erreur_probleme_technique'); return array('message_ok'=>$message); } ?> spip/spip/squelettes-dist/formulaires/inscription.php0000766000000000000000000001664511236524722024455 0ustar adminadministrators'','mail_inscription'=>'', 'id'=>$id); if ($mode=='1comite') $valeurs['_commentaire'] = _T('pass_espace_prive_bla'); else $valeurs['_commentaire'] = _T('pass_forum_bla'); if (!tester_config($id, $mode)) $valeurs['editable'] = false; return $valeurs; } // Si inscriptions pas autorisees, retourner une chaine d'avertissement function formulaires_inscription_verifier_dist($mode, $focus, $id=0) { $erreurs = array(); include_spip('inc/filtres'); if (!tester_config($id, $mode) OR (strlen(_request('nobot'))>0)) $erreurs['message_erreur'] = _T('rien_a_faire_ici'); if (!$nom = _request('nom_inscription')) $erreurs['nom_inscription'] = _T("info_obligatoire"); if (!$mail = _request('mail_inscription')) $erreurs['mail_inscription'] = _T("info_obligatoire"); // compatibilite avec anciennes fonction surchargeables // plus de definition par defaut if (!count($erreurs)){ if (function_exists('test_inscription')) $f = 'test_inscription'; else $f = 'test_inscription_dist'; $declaration = $f($mode, $mail, $nom, $id); if (is_string($declaration)) { $k = (strpos($declaration, 'mail') !== false) ? 'mail_inscription' : 'nom_inscription'; $erreurs[$k] = _T($declaration); } else { include_spip('base/abstract_sql'); if ($row = sql_fetsel("statut, id_auteur, login, email", "spip_auteurs", "email=" . sql_quote($declaration['email']))){ if (($row['statut'] == '5poubelle') AND !$declaration['pass']) // irrecuperable $erreurs['message_erreur'] = _T('form_forum_access_refuse'); if (($row['statut'] != 'nouveau') AND !$declaration['pass']) // deja inscrit $erreurs['message_erreur'] = _T('form_forum_email_deja_enregistre'); spip_log($row['id_auteur'] . " veut se resinscrire"); } } } return $erreurs; } function formulaires_inscription_traiter_dist($mode, $focus, $id=0) { $nom = _request('nom_inscription'); $mail = _request('mail_inscription'); if (function_exists('test_inscription')) $f = 'test_inscription'; else $f = 'test_inscription_dist'; $desc = $f($mode, $mail, $nom, $id); if (is_array($desc)) { $mail = $desc['email']; include_spip('base/abstract_sql'); $row = sql_fetsel("statut, id_auteur, login, email", "spip_auteurs", "email=" . sql_quote($mail)); // s'il n'existe pas deja, creer les identifiants $desc = $row ? $row : inscription_nouveau($desc); } else $desc = _T($desc); if (is_array($desc)) { // generer le mot de passe (ou le refaire si compte inutilise) $desc['pass'] = creer_pass_pour_auteur($desc['id_auteur']); // charger de suite cette fonction, pour ses utilitaires $envoyer_mail = charger_fonction('envoyer_mail','inc'); if (function_exists('envoyer_inscription')) $f = 'envoyer_inscription'; else $f = 'envoyer_inscription_dist'; list($sujet,$msg,$from,$head) = $f($desc, $nom, $mode, $id); if (!$envoyer_mail($mail, $sujet, $msg, $from, $head)) $desc = _T('form_forum_probleme_mail'); } return array('message_ok'=>is_string($desc) ? $desc : _T('form_forum_identifiant_mail')); } // fonction qu'on peut redefinir pour filtrer les adresses mail et les noms, // et donner des infos supplementaires // Std: controler que le nom (qui sert a calculer le login) est plausible // et que l'adresse est valide. On les normalise au passage (trim etc). // Retour: // - si ok un tableau avec au minimum email, nom, mode (redac / forum) // - si ko une chaine de langue servant d'argument a _T expliquant le refus // http://doc.spip.org/@test_inscription_dist function test_inscription_dist($mode, $mail, $nom, $id=0) { include_spip('inc/filtres'); $nom = trim(corriger_caracteres($nom)); if((strlen ($nom) < _LOGIN_TROP_COURT) OR (strlen($nom) > 64)) return 'ecrire:info_login_trop_court'; if (!$r = email_valide($mail)) return 'info_email_invalide'; return array('email' => $r, 'nom' => $nom, 'bio' => $mode); } // On enregistre le demandeur comme 'nouveau', en memorisant le statut final // provisoirement dans le champ Bio, afin de ne pas visualiser les inactifs // A sa premiere connexion il obtiendra son statut final. // http://doc.spip.org/@inscription_nouveau function inscription_nouveau($desc) { if (!isset($desc['login'])) $desc['login'] = test_login($desc['nom'], $desc['email']); $desc['statut'] = 'nouveau'; $n = sql_insertq('spip_auteurs', $desc); if (!$n) return _T('titre_probleme_technique'); $desc['id_auteur'] = $n; return $desc; } // construction du mail envoyant les identifiants // fonction redefinissable qui doit retourner un tableau // dont les elements seront les arguments de inc_envoyer_mail // http://doc.spip.org/@envoyer_inscription_dist function envoyer_inscription_dist($desc, $nom, $mode, $id) { $nom_site_spip = nettoyer_titre_email($GLOBALS['meta']["nom_site"]); $adresse_site = $GLOBALS['meta']["adresse_site"]; if ($mode == '6forum') { $adresse_login = generer_url_public('login'); $msg = 'form_forum_voici1'; } else { $adresse_login = $adresse_site .'/'. _DIR_RESTREINT_ABS; $msg = 'form_forum_voici2'; } $msg = _T('form_forum_message_auto')."\n\n" . _T('form_forum_bonjour', array('nom'=>$nom))."\n\n" . _T($msg, array('nom_site_spip' => $nom_site_spip, 'adresse_site' => $adresse_site . '/', 'adresse_login' => $adresse_login)) . "\n\n- " . _T('form_forum_login')." " . $desc['login'] . "\n- " . _T('form_forum_pass'). " " . $desc['pass'] . "\n\n"; return array("[$nom_site_spip] "._T('form_forum_identifiants'), $msg); } // http://doc.spip.org/@test_login function test_login($nom, $mail) { include_spip('inc/charsets'); $nom = strtolower(translitteration($nom)); $login_base = preg_replace("/[^\w\d_]/", "_", $nom); // il faut eviter que le login soit vraiment trop court if (strlen($login_base) < 3) { $mail = strtolower(translitteration(preg_replace('/@.*/', '', $mail))); $login_base = preg_replace("/[^\w\d]/", "_", $nom); } if (strlen($login_base) < 3) $login_base = 'user'; // eviter aussi qu'il soit trop long (essayer d'attraper le prenom) if (strlen($login_base) > 10) { $login_base = preg_replace("/^(.{4,}(_.{1,7})?)_.*/", '\1', $login_base); $login_base = substr($login_base, 0,13); } $login = $login_base; for ($i = 1; ; $i++) { if (!sql_countsel('spip_auteurs', "login='$login'")) return $login; $login = $login_base.$i; } } // http://doc.spip.org/@creer_pass_pour_auteur function creer_pass_pour_auteur($id_auteur) { include_spip('inc/acces'); $pass = creer_pass_aleatoire(8, $id_auteur); $mdpass = md5($pass); $htpass = generer_htpass($pass); sql_updateq('spip_auteurs', array('pass'=>$mdpass, 'htpass'=>$htpass),"id_auteur = ".intval($id_auteur)); ecrire_acces(); return $pass; } ?> spip/spip/squelettes-dist/formulaires/inc-forum_previsu.html0000766000000000000000000000243711236524722025737 0ustar adminadministrators
    <:previsualisation:>
    • [
    • (#ENV*{erreur})
    • ]
    [

    ]

    spip/spip/squelettes-dist/formulaires/oubli.html0000766000000000000000000000236111236524722023371 0ustar adminadministrators
    [

    (#ENV*{message_erreur})

    ] [

    (#ENV*{message_ok})

    ] [(#ENV*{editable}|?{' '})
    [(#REM) activer le traitement auto et dispatch sur charger/verifier/traiter] #ACTION_FORMULAIRE{#ENV{action}}
    <:pass_nouveau_pass:>
    • [(#ENV**{erreurs}|table_valeur{oubli})]
    [(#REM) Piege a robots spammeurs ]

    ]
    spip/spip/squelettes-dist/formulaires/inc-login_forum_abo.html0000766000000000000000000000161311236524722026166 0ustar adminadministrators[(#REM) Presenter les regles du jeu du forum sur abonnement avec un lien vers la connexion / l'inscription / le rappel ]
    <:Forum:> <:bouton_radio_modere_abonnement:>

    <:forum_vous_enregistrer:> <:forum_vous_inscrire:>

    [<:login:>] [[<:login_sinscrire:>]] [[<:login_motpasseoublie:>]]

    spip/spip/squelettes-dist/formulaires/signature.html0000766000000000000000000000610711236524722024262 0ustar adminadministrators
    [

    (#ENV*{message_ok,#ENV*{_confirm}|affiche_reponse_confirmation})

    ] [

    (#ENV*{message_erreur})

    ] [(#ENV{editable})
    #ACTION_FORMULAIRE{#ENV{action}} [
    <:info_descriptif:>
    (#ENV*{_texte}|propre)
    ]
    <:form_forum_identifiants:>
    • [(#ENV*{erreurs}|table_valeur{session_nom})]
    • [(#ENV*{erreurs}|table_valeur{session_email})]
    <:info_lien_hypertexte:> [

    (#ENV{site_obli})<:form_pet_votre_site:>

    ]
    • [(#ENV*{erreurs}|table_valeur{signature_nom_site})]
    • [(#ENV*{erreurs}|table_valeur{signature_url_site})]
    [(#REM) Piege a robots spammeurs ]

    [(#ENV{_message})
    <:form_pet_message_commentaire:>
    ]

    ]
    spip/spip/squelettes-dist/formulaires/mot_de_passe.html0000766000000000000000000000236711236524722024727 0ustar adminadministrators
    [

    (#ENV*{message_erreur})

    ] [

    (#ENV*{message_ok})

    ] [(#ENV*{editable}|?{' '})
    [(#REM) activer le traitement auto et dispatch sur charger/verifier/traiter] #ACTION_FORMULAIRE{#ENV{action}}
    <:pass_nouveau_pass:>
    • [(#ENV**{erreurs}|table_valeur{oubli})]
    [(#REM) Piege a robots spammeurs ]

    ]
    spip/spip/squelettes-dist/formulaires/recherche.php0000766000000000000000000000237111236524722024033 0ustar adminadministrators ($lien ? $lien : generer_url_public('recherche')), # action specifique, ne passe pas par Verifier, ni Traiter 'recherche' => _request('recherche'), 'lang' => $lang ); } ?> spip/spip/squelettes-dist/formulaires/oubli.php0000766000000000000000000000607511236524722023222 0ustar adminadministrators''); return $valeurs; } // http://doc.spip.org/@message_oubli function message_oubli($email, $param) { $r = formulaires_oubli_mail($email); if (is_array($r) AND $r[1]) { include_spip('inc/acces'); # pour creer_uniqid $cookie = creer_uniqid(); sql_updateq("spip_auteurs", array("cookie_oubli" => $cookie), "id_auteur=" . $r[1]['id_auteur']); $nom = $GLOBALS['meta']["nom_site"]; $envoyer_mail = charger_fonction('envoyer_mail','inc'); if ($envoyer_mail($email, ("[$nom] " . _T('pass_oubli_mot')), _T('pass_mail_passcookie', array('nom_site_spip' => $nom, 'adresse_site' => url_de_base(), 'sendcookie' => generer_url_public('spip_pass', "$param=$cookie", true)))) ) return _T('pass_recevoir_mail'); else return _T('pass_erreur_probleme_technique'); } return _T('pass_erreur_probleme_technique'); } // la saisie a ete validee, on peut agir function formulaires_oubli_traiter_dist(){ $message = message_oubli(_request('oubli'),'p'); return array('message_ok'=>$message); } // fonction qu'on peut redefinir pour filtrer les adresses mail // http://doc.spip.org/@test_oubli function test_oubli_dist($email) { include_spip('inc/filtres'); # pour email_valide() if (!email_valide($email) ) return _T('pass_erreur_non_valide', array('email_oubli' => htmlspecialchars($email))); return array('mail' => $email); } function formulaires_oubli_verifier_dist(){ $erreurs = array(); $email = _request('oubli'); $r = formulaires_oubli_mail($email); if (!is_array($r)) $erreurs['oubli'] = $r; else { if (!$r[1]) $erreurs['oubli'] = _T('pass_erreur_non_enregistre', array('email_oubli' => htmlspecialchars($email))); elseif ($r[1]['statut'] == '5poubelle' OR $r[1]['pass'] == '') $erreurs['oubli'] = _T('pass_erreur_acces_refuse'); } return $erreurs; } function formulaires_oubli_mail($email) { if (function_exists('test_oubli')) $f = 'test_oubli'; else $f = 'test_oubli_dist'; $declaration = $f($email); if (!is_array($declaration)) return $declaration; else { include_spip('base/abstract_sql'); return array($declaration, sql_fetsel("id_auteur,statut,pass", "spip_auteurs", "email =" . sql_quote($declaration['mail']))); } } ?> spip/spip/squelettes-dist/formulaires/recherche.html0000766000000000000000000000076311236524722024213 0ustar adminadministrators
    [(#ENV{action}|form_hidden)] []
    spip/spip/squelettes-dist/agenda_mois.html0000766000000000000000000000040611236524722022173 0ustar adminadministrators[(#DATE|agenda_memo{#DESCRIPTIF, #TITRE, #URL_ARTICLE, calendrier-couleur[(#ID_SECTEUR| modulo{14,1})]})][(#DATE| agenda_affiche{<:aucun_article:>, 'mois'} )]spip/spip/squelettes-dist/article.html0000766000000000000000000000756511236524722021365 0ustar adminadministrators [(#TITRE|textebrut) - ][(#NOM_SITE_SPIP|textebrut)] []
    [(#REM) Entete de la page + titre du site ] [(#REM) Contenu principal : contenu de l'article ]
    [(#REM) Fil d'Ariane ]
    <:accueil_site:> > [(#TITRE|couper{80})][ > (#TITRE|couper{80})]
    [(#LOGO_ARTICLE||image_reduire{200,200})] [

    (#SURTITRE)

    ]

    #TITRE

    [

    (#SOUSTITRE)

    ]

    [(#DATE|nom_jour) ][(#DATE|affdate)][, <:par_auteur:> (#LESAUTEURS)][ (<:texte_date_publication_anterieure:> (#DATE_REDAC|affdate)).]

    [(#REM) Inclure le modele des liens de traductions ] #MODELE{article_traductions}
    [
    (#CHAPO|image_reduire{500,0})
    ] [
    (#TEXTE|image_reduire{500,0})
    ]
    [

    <:voir_en_ligne:> : [(#NOM_SITE|sinon{[(#URL_SITE|couper{80})]})]

    ] [

    <:info_ps:>

    (#PS|image_reduire{500,0})
    ] [(#REM) Gestion du portfolio et des documents Le critere {env} permet de passer d'autres arguments de la page par exemple l'id_document choisi pour un affichage complet ] [(#INCLURE{fond=inc-documents}{id_article}{env})] [(#REM) Petition : La petition ayant une PAGINATION il faut absolument {env} et pourquoi pas ajax ][(#PETITION|?{' '})] [

    <:info_notes:>

    (#NOTES)
    ] [(#REM) Forum de l'article ] [

    <:repondre_article:>

    ]
    [(#REM) Menu de navigation laterale ] [(#REM) Menu de navigation laterale ]
    [(#REM) Articles dans la meme rubrique ] [(#REM) Menu de navigation mots-cles ] #MODELE{article_mots}
    [(#REM) Pied de page ]
    spip/spip/squelettes-dist/backend.html0000766000000000000000000000236011236524722021315 0ustar adminadministrators[(#HTTP_HEADER{Content-type: text/xml[; charset=(#CHARSET)]})] [(#NOM_SITE_SPIP|texte_backend)] #URL_SITE_SPIP/ [(#DESCRIPTIF_SITE_SPIP|supprimer_tags|texte_backend)] #LANG SPIP - www.spip.net [ [(#NOM_SITE_SPIP|texte_backend)] (#LOGO_SITE_SPIP||image_reduire{144,400}|extraire_attribut{src}|url_absolue|texte_backend) #URL_SITE_SPIP/ [(#LOGO_SITE_SPIP||image_reduire{144,400}|extraire_attribut{height})] [(#LOGO_SITE_SPIP||image_reduire{144,400}|extraire_attribut{width})] ] spip/spip/squelettes-dist/site.html0000766000000000000000000000767611236524722020711 0ustar adminadministrators[(#REM) Un cache plus court, pour la boucle syndic_articles ]#CACHE{3600} [(#REM) Les sites n'ont pas de "lang" a proprement parler ; on se base donc sur la langue de la rubrique qui les contient. Les articles syndiques, eux, ont une "lang". ] [(#NOM_SITE|textebrut) - ][(#NOM_SITE_SPIP|textebrut)] [] [(#REM) On demande aux moteurs de ne pas indexer cette page pour ne pas passer devant le site qu'on reference. ]
    [(#REM) Entete de la page + titre du site ] [(#REM) Contenu principal : affichage du site ]
    [(#REM) Fil d'Ariane ]
    <:accueil_site:> > [(#TITRE|couper{80})][ > (#NOM_SITE|couper{80})]
    [
    (#DESCRIPTIF)
    ] [

    (#URL_SITE|couper{80})

    ] [(#REM) Articles issus de la syndication ] [

    <:info_notes:>

    (#NOTES)
    ]
    [(#REM) Menu de navigation laterale ] [(#REM) Menu de navigation laterale ]
    [(#REM) Autres sites web ] [(#REM) Menu de navigation mots-cles ]
    [(#REM) Pied de page ]
    spip/spip/squelettes-dist/inc-rss-item.html0000766000000000000000000000411611236524722022241 0ustar adminadministrators [(#TITRE|supprimer_tags|texte_backend)] [(#URL_ARTICLE|url_absolue)] [(#URL_ARTICLE|url_absolue)] [(#DATE|date_iso)] text/html [(#LANG)] [(#LESAUTEURS|supprimer_tags|texte_backend)] [(#REM) Le bloc qui suit diffuse les mots-cles a la mode RSS ] [(#TITRE|texte_backend)] [(#INTRODUCTION|texte_backend)] [(#REM) Le bloc qui suit diffuse la rubrique et les mots-cles sous forme de "microformats" ]- [<a href="[(#URL_RUBRIQUE|url_absolue)]" rel="directory">(#TITRE|supprimer_tags|texte_backend)</a>] / [<a href="[(#URL_MOT|url_absolue)]" rel="tag">(#TITRE|texte_backend)</a>] [(#REM) Le bloc qui suit diffuse aussi le texte integral de l'article, ce qui permet une syndication plus riche (mais plus "lourde"). Fonction desactivable depuis les reglages du site. ][ (#CONFIG{syndication_integrale}|=={oui}|?{' ',''})[(#LOGO_ARTICLE|right||image_reduire{150,150}|texte_backend) ][<div class='rss_chapo'>(#CHAPO|texte_backend)</div> ][<div class='rss_texte'>(#TEXTE| image_reduire{500,0}|texte_backend)</div> ][<hr /> <div class='rss_notes'>(#NOTES|texte_backend)</div> ][<div class='rss_ps'>(#PS|texte_backend)</div>] ] [(#REM) Le bloc qui suit diffuse l'adresse des documents associes aux articles ; ajouter par ex. {extension=mp3} pour limiter a un certain type de document. ] [ ] spip/spip/squelettes-dist/rss_forum_thread.html0000766000000000000000000000260411236524722023275 0ustar adminadministrators#CACHE{0}#HTTP_HEADER{Content-Type: text/xml; charset=#CHARSET} [[(#NOM_SITE_SPIP|texte_backend)] <:ecrire:titre_page_forum_suivi:> ]RSS[ (#TITRE|texte_backend)] [(#URL_FORUM|url_absolue|texte_backend)] [(#ENV{lang}|texte_backend)] [(#TITRE|texte_backend)][ ((#ENV{page}|=={publie}|?{#STATUT, "publie"}|=={publie}|?{'', #STATUT}))] [(#URL_FORUM|url_absolue|texte_backend)] [(#URL_FORUM|url_absolue|texte_backend)] [(#DATE|date_iso)] text/html [(#LANG|texte_backend)] ['; [(#AUTEUR|texte_backend)][ <(#EMAIL_AUTEUR|texte_backend)>] [ (#TEXTE|liens_absolus|texte_backend)]#NOTES spip/spip/squelettes-dist/rubrique.html0000766000000000000000000001415011236524722021564 0ustar adminadministrators[(#REM) Un cache plus court, pour la boucle syndic_articles ]#CACHE{3600} [(#TITRE|textebrut) - ][(#NOM_SITE_SPIP|textebrut)] [] [(#REM) Lien vers le flux RSS des articles la rubrique ]
    [(#REM) Entete de la page + titre du site ] [(#REM) Contenu principal : contenu de la rubrique ]
    [(#REM) Fil d'Ariane ]
    <:accueil_site:> > [(#TITRE|couper{80})][ > (#TITRE|couper{80})]
    [(#LOGO_RUBRIQUE||image_reduire{200,200})]

    #TITRE

    [

    <:dernier_ajout:> : (#DATE|affdate_jourcourt).

    ]
    [
    (#TEXTE)
    ] [(#REM) Articles de la rubrique ] [(#REM) Si aucun article, affiche un plan de la rubrique ] [(#REM) supprimer pour toujours avoir le miniplan] [(#REM) Documents joints a la rubrique ] [(#REM) Breves du secteur ] [(#REM) Sites de la rubrique ] [(#REM) Proposer un site ] #FORMULAIRE_SITE [

    <:info_notes:>

    (#NOTES)
    ]
    [(#REM) Menu de navigation laterale ] [(#REM) Menu de navigation laterale ]
    [(#REM) Menu de navigation mots-cles ]
    [(#REM) Pied de page ]
    spip/spip/squelettes-dist/identifiants.html0000766000000000000000000000106411236524722022407 0ustar adminadministrators#CACHE{0} [(#HTTP_HEADER{Content-Type: text/html[; charset=(#CHARSET)]})] <:pass_vousinscrire:> [] #FORMULAIRE_INSCRIPTION{#ENV{mode},#ENV{focus},#ENV{id_rubrique}} spip/spip/squelettes-dist/puce.gif0000766000000000000000000000012311236524722020456 0ustar adminadministratorsGIF89a ===JJJqqqFFF!, xܾ؀ QguQ2 ;spip/spip/squelettes-dist/Thumbs.db0000677000000000000000000001600011275530611020603 0ustar adminadministratorsࡱ>   Root Entry sFj` 1Catalogp JFIF``C     C   ``" }!1AQa"q2#BR$3br %&'()*456789:CDEFGHIJSTUVWXYZcdefghijstuvwxyz w!1AQaq"2B #3Rbr $4%&'()*56789:CDEFGHIJSTUVWXYZcdefghijstuvwxyz ?Ϗ-=06t}Bʵ2V|NL|KpGY@9}эMԢJFYPZHz u3em+G$쮽FJΪͳ\MiarFqF}t{11.OU;&7|E~=i L٧)ip$ꥱ? 륆-&Wzrl,~I4'OiG4'Oi]}*_4ʼ/FܸIM3IM3OO?$IM3Ľ'Œ$ VVQUxdwm$VƇ}*浻XO<u娹kbieWD'㩮&}fjTRo}.'Nagf;Hm\o x;ۨxg* Ff8MI?qO'Mŏ Aw^lzLns<#]Z?tb2_%o}P{b22\O$9+zftͥG,VK},A%-;残xVo$v1X\ ֯Y/ƞ Es\9' CN!4#N3ke0xŲ. & zdYZU5rmsܟjdm2_Ek]w5wmTé5 Ttg& M8Z5-$h=??}tUk_^/<g$d=?ŸP[BC#c]VYipYBͰIq*ƥN2HW}uİȲ$"0ee' :_ĕj`Л\ͧz[祁j-4caceo,cVgt_I5⎃\MS܄ SZ!U},|"& okȰBƙh톹[=qڽ//id`6P# ޴T2))[ ?\WfYϤ¼*I( \5b2j^# 9KK񨒵/ɕ.o/E,`fgh8'_ĵ>8TMUO8i8kҵ]ٞ->M>!)0XO]oۭ|b"kWjvkyq7կO>4=y{Rq)l9acfx fx ɚ ٘_jY%<tad޺ieY~*mjEYNAeUП}v~_>"{}ͤp@A$ATG#ِ@V8;1ͱ8XTN 5 $vՖE<> JT]f```!Jj`{A42CD7B6-E9B9-4D02-B7A6-288B71AD28BA}spip/spip/squelettes-dist/inc-petition.html0000766000000000000000000000447611236524722022342 0ustar adminadministrators[(#REM) Signer la petition ] #FORMULAIRE_SIGNATURE [(#REM) Signatures de la petition ]
    [(#SELF|form_hidden)] #ANCRE_PAGINATION [(#REM) Afficher la colonne des messages si autorises ] [(#REM) Afficher la colonne des messages si autorises ]

    #GRAND_TOTAL <:signatures_petition:>

    <:date:> <:nom:><:message:>
    [(#DATE|affdate_jourcourt)] #NOM[ <:site_web:>][(#MESSAGE|PtoBR)]
    [

    (#PAGINATION)

    ] [(#REM) Afficher un moteur de recherche si plus de 30 signatures ou s'il etait deja present au coup d'avant] [(#ENV{recherche_signatures}|?{31,#_signatures:GRAND_TOTAL}|>{30}|oui)
    ]
    spip/spip/squelettes-dist/mot.html0000766000000000000000000001177111236524722020533 0ustar adminadministrators [(#TITRE|textebrut) - ][(#NOM_SITE_SPIP|textebrut)] [] [(#REM) Lien vers le flux RSS des articles du mot cle ]
    [(#REM) Entete de la page + titre du site ] [(#REM) Contenu principal : contenu du mot-cle ]
    [(#REM) Fil d'Ariane ]
    <:accueil_site:> > <:mots_clefs:> > [(#TITRE|couper{80})][ > (#TITRE|couper{80})]
    [(#LOGO_MOT||image_reduire{200,200})]

    #TITRE

    [
    (#TEXTE)
    ] [(#REM) Articles lies au mot-cle ] [(#REM) Rubriques liees au mot-cle ] [(#REM) Breves liees au mot-cle ] [(#REM) Liens des forums ] [(#REM) Sites web lies au mot-cle ] [

    <:info_notes:>

    (#NOTES)
    ]
    [(#REM) Menu de navigation laterale ] [(#REM) Menu de navigation laterale ]
    [(#REM) Menu de navigation mots-cles : les autres mots cles du meme groupe ] [(#REM) Menu de navigation mots-cles : les autres groupes avec un lien sur le premier mot du groupe ]
    [(#REM) Pied de page ]
    spip/spip/squelettes-dist/modeles/0000777000000000000000000000000011266531325020466 5ustar adminadministratorsspip/spip/squelettes-dist/modeles/favicon.html0000766000000000000000000000040611236524722023002 0ustar adminadministrators[] spip/spip/squelettes-dist/modeles/article_traductions.html0000766000000000000000000000140511236524722025417 0ustar adminadministrators[(#REM) Affiche les traductions disponibles d'un article. La langue de l'article courant s'affiche en gras, sans lien. ][(#REM) Note : le lien indique qu'il s'agit d'une traduction (version alternative dans la langue xx) ]

    <:trad_article_traduction:> [(#TOTAL_BOUCLE|>{1}|?{' '}) [[(#EXPOSE{'',})][(#LANG|traduire_nom_langue)]#EXPOSE{'',}] ]

    spip/spip/squelettes-dist/modeles/lesauteurs.html0000766000000000000000000000056511236524722023557 0ustar adminadministrators[(#REM) Affiche la liste des auteurs d'un article ][(#REM) Modele pour la balise #LESAUTEURS, dans le cas des auteurs d'un article (pour un article syndique, la balise affiche directement la valeur du champ) ] #NOMspip/spip/squelettes-dist/modeles/article_mots.html0000766000000000000000000000076011236524722024045 0ustar adminadministrators[(#REM) Liste des mots-cles d'un article ][(#REM) Modele : liste des mots-cles d'un article #MODELE{article_mots} Pour la notation rel="tag" voir ] spip/spip/squelettes-dist/modeles/foreach.html0000766000000000000000000000004611236524722022764 0ustar adminadministrators#PUCE #ENV{cle} => #ENV{valeur}
    spip/spip/squelettes-dist/agenda_jour.html0000766000000000000000000000451611236524722022211 0ustar adminadministrators[(#DATE|agenda_memo{#DESCRIPTIF, #TITRE, #URL_ARTICLE, calendrier-couleur[(#ENV{theme,0}|modulo{14,1})]})][(#DATE|agenda_affiche{<:aucun_article:>, 'jour', calendrier-couleur[(#ENV{theme,0}|modulo{14,1})]})][(#TOTAL_BOUCLE|?{' ',''}) ] spip/spip/squelettes-dist/inc-entete.html0000766000000000000000000000033311236524722021757 0ustar adminadministrators spip/spip/squelettes-dist/spip_formulaires.css0000766000000000000000000001127311236524722023140 0ustar adminadministrators/* ------------------------------------------ /* Habillage des formulaires /* ------------------------------------------ */ input, select, textarea { font-size: 100%; font-family: inherit; } /* Structure generale des formulaires ----------------------------------------------- */ .formulaire_spip { clear: both; margin-bottom: 2em; padding: 0; border: 0; text-align: left; font-size: 1em; } .formulaire_spip form { margin: 0; padding: 0; } /* Bug IE/Win */ /* Fieldset */ .formulaire_spip fieldset { clear: both; margin: 0 0 1em 0; padding: 0; border: 0; } .formulaire_spip fieldset legend { margin: 0; padding: 0; font-size: 1.05em; font-weight: bold; background-color: #fff; color: #333; } /* Preciser la couleur des legend et du fond pour IE/Win */ .formulaire_spip fieldset fieldset { margin-top: 1em; } .formulaire_spip fieldset fieldset legend { font-size: 1em; font-weight: normal; } /* Explications */ .formulaire_spip .explication { margin: 0.50em 0; color: #444; } /* Lignes */ .formulaire_spip ul { margin: 0; padding: 0; list-style: none; } .formulaire_spip ul li { clear: both; margin: 0; padding: 0.50em 0; } /* Labels */ .formulaire_spip label { display: block; text-align: left; color: #444; font-weight: bold; /* pour IE/Win */ position: relative; } .formulaire_spip li p { margin-top: 0; margin-bottom: 0; } .formulaire_spip .choix label{display:inline;font-weight:normal;} .formulaire_spip .choix input.radio, .formulaire_spip .choix input.checkbox {width:auto;} /* Champs de saisie */ .formulaire_spip input.text { width: 15em; border: 1px inset; } .formulaire_spip textarea { width: 99%; border: 1px inset; } .formulaire_spip select { width: 99%; } /* Boutons */ .formulaire_spip .boutons { clear: both; margin: 0; padding: 0; text-align: right; } .formulaire_spip .boutons input { margin-left: 1em; } .formulaire_spip .boutons input, input.submit {} /* Reponses, previsu et erreurs ----------------------------------------------- */ /* Champs obligatoires */ .formulaire_spip li.obligatoire {} .formulaire_spip li.obligatoire label {} /* Previsualisation du message */ .formulaire_spip fieldset.previsu { margin-bottom: 2em; padding: 1em; border: 2px dashed #F57900; } .formulaire_spip fieldset.previsu legend { padding: 0 0.50em; font-weight: bold; color: #F57900; } .formulaire_spip fieldset.previsu li { padding: 3px; border: none; } .formulaire_spip fieldset.previsu p { margin: 1em 0; } /* Reponse du formulaire */ .reponse_formulaire { font-weight: bold; color: #e86519; font-size: 1.20em; } fieldset.reponse_formulaire { border-color: #e86519; font-weight: normal; } fieldset.reponse_formulaire.reponse_formulaire legend { color: #F57900; } /* Preciser la couleur des legend et du fond pour IE/Win */ /* * Erreurs */ .formulaire_spip li.erreur .erreur_message { display: block; color: #C30; font-weight: bold; } .formulaire_spip li.erreur input.text, .formulaire_spip li.erreur textarea { background-color: #FCC; border-style: solid; border-color: #C30; } .reponse_formulaire_erreur { margin: 0; color: #C30; font-weight: bold; } /* * OK */ .reponse_formulaire_ok { margin: 0; color: #53AD20; font-weight: bold; } /* Variantes et cas particuliers ----------------------------------------------- */ /* Barre de raccourcis typographiques */ table.spip_barre { width: 100%; } table.spip_barre a img { background: #FDA; padding: 3px; border: 1px outset #CC9; } table.spip_barre a:focus img, table.spip_barre a:hover img, table.spip_barre a:active img { background: #FFF; border: 1px solid #CC9; } table.spip_barre input.barre { width: 99%; background: transparent; border: 0; } /* Formulaire de forum */ .formulaire_forum .saisie_titre input.text, .formulaire_forum .saisie_titre textarea { width: 98%; } /* Selection des langues */ .formulaire_menu_lang { margin: 0; padding: 0; background: none; } /* Formulaires de recherche (site / petitions) */ .formulaire_recherche { margin: 0; padding: 0; background: none; } .formulaire_recherche * { display: inline; vertical-align: middle; } .formulaire_recherche label {} .formulaire_recherche input.text { width: 10em; padding-left: 25px; background: #FFF url(rechercher.gif) no-repeat left center; } .formulaire_recherche input.submit {} .spip_surligne {} /* Cf.: spip_style.css */ /* Choix des mots-clefs */ ul.choix_mots { display: block; margin: 0; padding: 0; list-style: none; } ul.choix_mots li { clear: none; float: left; display: block; width: 30%; padding: 1%; } ul.choix_mots li label { display: inline; font-weight: normal; } .formulaire_spip .bugajaxie { display: none; } /* Bug IE/Win */ /* Formulaire de login dans une page */ .formulaire_login ul li {clear:left;} .formulaire_login .editer_password .details {display:block;} .formulaire_login #spip_logo_auteur {float:right;} spip/spip/squelettes-dist/nouveautes.html0000766000000000000000000000154311236524722022126 0ustar adminadministrators[[(#NOM_SITE_SPIP|textebrut)]] <:nouveautes:> <:bonjour:> <:texte_lettre_information:> "[(#NOM_SITE_SPIP|textebrut)]" (#URL_SITE_SPIP). <:texte_lettre_information_2:> [(#ENV{jours_neuf})] <:jours:>. <:nouveaux_articles:> -------------------------- [** (#TITRE|textebrut) **] [<:par_auteur:> (#LESAUTEURS|textebrut)] [- (#DATE|affdate)] [ (#INTRODUCTION|textebrut) ] -> [(#URL_ARTICLE|url_absolue)] <:nouvelles_breves:> -------------------------- [* (#TITRE|textebrut) *] [ - (#DATE|affdate)] [ (#INTRODUCTION|textebrut) ] -> [(#URL_BREVE|url_absolue)] spip/spip/squelettes-dist/favicon.ico.html0000766000000000000000000000014111236524722022117 0ustar adminadministrators#HTTP_HEADER{Content-Type: image/x-icon}[(#INCLURE{favicon.ico} |sinon{#INCLURE{spip.ico}})] spip/spip/squelettes-dist/agenda_semaine.html0000766000000000000000000000054711236524722022653 0ustar adminadministrators[(#DATE|agenda_memo{#DESCRIPTIF, #TITRE, #URL_ARTICLE, [(#COMPTEUR_BOUCLE| alterner{'calendrier-couleur2', 'calendrier-couleur4'})]})][(#DATE| agenda_affiche{<:aucun_article:>, 'semaine', 'calendrier-couleur2','calendrier-couleur4'} )] spip/spip/squelettes-dist/plan.html0000766000000000000000000000630211236524722020660 0ustar adminadministrators <:plan_site:> - [(#NOM_SITE_SPIP|textebrut)] []
    [(#REM) Entete de la page + titre du site ] [(#REM) Le plan de site ci-dessous est a adapter selon les besoins. En particulier, on n'aura pas necessairement besoin de tous les elements (sous-rubriques, articles, breves et sites) ]
    [(#REM) Fil d'Ariane ]
    <:accueil_site:> > <:plan_site:>

    <:plan_site:>

    #TITRE

    [(#REM) Articles et sous-rubriques ]

    <:articles:>

    [(#REM) Breves ]

    <:breves:>

    [(#REM) Sur le Web ]

    <:sites_web:>

    [(#REM) Menu de navigation laterale ] [(#REM) Menu de navigation laterale ]
     
    [(#REM) Pied de page ]
    spip/spip/squelettes-dist/agenda.html0000766000000000000000000000154511236524722021151 0ustar adminadministrators <:icone_agenda:> - [(#NOM_SITE_SPIP|textebrut)] [] [(#ENV{type, mois}|agenda_connu)] spip/spip/squelettes-dist/rss_forum_breve.html0000766000000000000000000000255011236524722023131 0ustar adminadministrators#CACHE{0}#HTTP_HEADER{Content-Type: text/xml; charset=#CHARSET} [[(#NOM_SITE_SPIP|texte_backend)] <:ecrire:titre_page_forum_suivi:> ]RSS[ (#TITRE|texte_backend)] [(#URL_BREVE|url_absolue|texte_backend)] [(#ENV{lang}|texte_backend)] [(#TITRE|texte_backend)][ ((#ENV{page}|=={publie}|?{#STATUT, "publie"}|=={publie}|?{'', #STATUT}))] [(#URL_FORUM|url_absolue|texte_backend)] [(#URL_FORUM|url_absolue|texte_backend)] [(#DATE|date_iso)] text/html [(#LANG|texte_backend)] ['; [(#AUTEUR|texte_backend)][ <(#EMAIL_AUTEUR|texte_backend)>] [ (#TEXTE|liens_absolus|texte_backend)]#NOTES spip/spip/squelettes-dist/feed.png0000766000000000000000000000132511236524722020451 0ustar adminadministratorsPNG  IHDRaIDAT8uAhTWsߛ7dĘĄ6m q *R)\:Ս !* (F身i(H.ąDJLb&޽x#^.sGF/ʝÅP5b1kq "2υrp{j_cB!0 &4@{Cwhhr-G܋1c$* H)CǤƯ"v={Nt6 &4H.N#uAo!~=iPEkBDD6n_>$DYI#&#D_| Q(zB'7v]MK<#&. R&{Ww`qYhqIV;*Й1V~4Hx ڶi$_"|ӦQ<>v, _I+?ࣝGi@Fс_ b4 [J%TނM V0}Hxol4gtU46ly,, L[7>$/?"* "/t ImFTV=i&y9E2;E!'ܷv%iFOoBGGcn/@3M4QR8NFPc  AKH,s2]Q>IENDB`spip/spip/squelettes-dist/inc-forum.html0000766000000000000000000000550311236524722021627 0ustar adminadministrators[(#REM) Cette balise (invisible) provoque le recalcul du forum la premiere fois qu'un message est poste (cf. inc/invalideur). ] [(#PARAMETRES_FORUM|?{''})] [(#REM) Nombre total de messages ] [

    (#TOTAL_BOUCLE|>{0}|?{#TOTAL_BOUCLE,''}) [(#TOTAL_BOUCLE|=={1}|?{<:message:>,<:messages_forum:>})]

    ] [(#REM) Messages du forum ]
    • #TITRE [(#DATE|affdate_jourcourt)][ (#DATE|heures)][:(#DATE|minutes)][, <:par_auteur:> (#NOM|couper{80})]
      [(#TEXTE|lignes_longues)] [
      (#NOTES|safehtml|lignes_longues)
      ] [

      <:voir_en_ligne:> : [(#NOM_SITE|sinon{[(#URL_SITE|couper{80})]})]

      ] [(#EXTENSION|match{'^(gif|jpg|png)$'}|?{ [(#MODELE{emb}|image_reduire{300})] , [(#LOGO_DOCUMENT|#URL_DOCUMENT)] })] [

      <:repondre_message:>

      ]
      • #TITRE [(#DATE|affdate_jourcourt)][ (#DATE|heures)][:(#DATE|minutes)][, <:par_auteur:> (#NOM|couper{80})]
        [(#TEXTE|lignes_longues)] [
        (#NOTES|safehtml|lignes_longues)
        ] [

        <:voir_en_ligne:> : [(#NOM_SITE|sinon{[(#URL_SITE|couper{80})]})]

        ] [(#EXTENSION|match{'^(gif|jpg|png)$'}|?{ [(#MODELE{emb}|image_reduire{300})] , [(#LOGO_DOCUMENT|#URL_DOCUMENT)] })] [

        <:repondre_message:>

        ]
    spip/spip/squelettes-dist/rss_forum_rubrique.html0000766000000000000000000000256411236524722023671 0ustar adminadministrators#CACHE{0}#HTTP_HEADER{Content-Type: text/xml; charset=#CHARSET} [[(#NOM_SITE_SPIP|texte_backend)] <:ecrire:titre_page_forum_suivi:> ]RSS[ (#TITRE|texte_backend)] [(#URL_RUBRIQUE|url_absolue|texte_backend)] [(#ENV{lang}|texte_backend)] [(#TITRE|texte_backend)][ ((#ENV{page}|=={publie}|?{#STATUT, "publie"}|=={publie}|?{'', #STATUT}))] [(#URL_FORUM|url_absolue|texte_backend)] [(#URL_FORUM|url_absolue|texte_backend)] [(#DATE|date_iso)] text/html [(#LANG|texte_backend)] ['; [(#AUTEUR|texte_backend)][ <(#EMAIL_AUTEUR|texte_backend)>] [ (#TEXTE|liens_absolus|texte_backend)]#NOTES spip/spip/squelettes-dist/habillage.css0000766000000000000000000002140211236524722021460 0ustar adminadministrators/* --------------------------------------------------------- */ /* Feuille de style des squelettes par defaut pour SPIP 2.0 */ /* --------------------------------------------------------- */ /* ------------------------------------------ /* Typographie generale (style transversaux) /* ------------------------------------------ */ html { font-size: 100%; } /* Cf.: http://pompage.net/pompe/definir-des-tailles-de-polices-en-CSS/ */ body { font-size: 0.8125em; font-family: "Luxi sans", "Lucida Grande", Lucida, "Lucida Sans Unicode", sans-serif; color: #333; } /* Titraille / Intertitres */ h1,h2,h3,h4,h5,h6 { margin: 0; padding: 0; font-weight: normal; font-size: 1em; font-family: Georgia, Times, serif; } h1 { font-size: 1.70em; color: #000; } h2 { font-size: 1.40em; font-weight: normal; } h2, h2 a, h2 a:focus, h2 a:hover, h2 a:active { color: #003; } h3 { font-size: 1.20em; font-weight: bold; } h3.spip {} /* Cf.: spip_style.css */ hr.spip {} /* Cf.: spip_style.css */ /* Autres enrichissements typo */ strong { font-weight: bold; } em { font-style: italic; } abbr, acronym { border-bottom: 1px dotted; cursor: help; } small { font-size: 0.90em; color: #666; } dfn { font-weight: bold; color: #666; } del { text-decoration: line-through; } ins { color: red !important; text-decoration: none; } sup, sub { font-size: .8em; font-variant: normal; } /* Listes */ ul.spip {} /* Cf.: spip_style.css */ ol.spip {} /* Cf.: spip_style.css */ dl {} dt {} dd {} /* Citations, code et poesie */ cite {} q {} blockquote {} blockquote.spip {} /* Cf.: spip_style.css */ blockquote.spip_poesie {} /* Cf.: spip_style.css */ .spip_code {} /* Cf.: spip_style.css */ .spip_cadre {} /* Cf.: spip_style.css */ address {} /* Tableaux */ table.spip {} /* Cf.: spip_style.css */ /* Logos, documents et images */ img { margin: 0; padding: 0; border: 0; } .spip_logos {} /* Cf.: spip_style.css */ .spip_documents {} /* Cf.: spip_style.css */ .spip_documents_center {} /* Cf.: spip_style.css */ .spip_documents_left {} /* Cf.: spip_style.css */ .spip_documents_right {} /* Cf.: spip_style.css */ .spip_doc_titre {} /* Cf.: spip_style.css */ .spip_doc_descriptif {} /* Cf.: spip_style.css */ /* ------------------------------------------ /* Disposition a l'ecran des blocs principaux /* ------------------------------------------ */ body { background: #FFF; margin: 0; padding: 0; text-align: center; } #page { position: relative; width: 58em; margin: 0 auto; text-align: left; } #entete { width: 58em; margin: 0; padding-top: 1.60em; border-bottom: 2px solid #8B6F92; } #entete a.accueil { display: block; width: 67%; } #entete a.accueil img.spip_logos { vertical-align: bottom; line-height: 1em; } #entete a.accueil #nom_site_spip { vertical-align: bottom; font-size: 2.2em; font-family: Georgia, Times, serif; font-weight: normal; } #entete .formulaire_menu_lang { position: absolute; right: 0; top: 0.90em; display: block; width: 30%; } /*Cf.: spip_formulaires.css*/ #conteneur { clear: both; float: left; width: 67%; overflow: hidden; } #contenu { padding-top: 0.30em; } #navigation { float: right; width: 30%; margin-top: 1em; overflow: hidden; } #extra { float: right; clear: right; width: 30%; margin-top: 1em; overflow: hidden; } #pied { clear: both; width: 100%; margin: 0; padding: 0.40em 0; border-top: 1px solid #8B6F92; text-align: center; font-size: 0.90em; } #pied img { vertical-align: middle; } /* Espaceur de blocs */ .nettoyeur { clear: both; height: 0; margin: 0; padding: 0; border: 0; line-height: 1px; font-size: 1px; } /* Non visible a l'ecran */ .invisible { position: absolute; top: -3000em; height: 1%; } /* ------------------------------------------ /* Habillage des elements du contenu /* ------------------------------------------ */ #hierarchie { clear: both; margin-bottom: 2em; font-size: 0.90em; } #hierarchie, #hierarchie a { color: #666; } .cartouche { margin-bottom: 2em; } .cartouche .spip_logos { float: right; margin-left: 16px; margin-bottom: 4px; } .cartouche p { margin: 0; padding: 0; clear: left; } .surtitre, .soustitre { font-size: 0.90em; color: #666; text-transform: uppercase; letter-spacing: 0.10em; } .cartouche .surtitre { margin-bottom: 0.30em; } .cartouche .soustitre { margin-top: 0.50em; margin-bottom: 0.30em; } .cartouche .traductions { font-size: 0.90em; } .chapo { margin-bottom: 1.50em; line-height: 1.40em; font-weight: bold; color: #669; } .texte { line-height: 1.60em; } .hyperlien { display: block; background: #EEE; padding: 0.50em 1em; font-weight: bold; color: #8B6F92; } .ps, .notes { margin-bottom: 2em; line-height: 1.40em; } .notes { clear: both; font-size: 0.90em; } abbr.published { border: 0; } /* Portfolio */ #documents_portfolio { clear: both; margin: 2em auto; text-align: center; } #documents_portfolio .spip_logos { margin: 6px 3px 0 3px; border: 4px solid #DDD; } #documents_portfolio a.on .spip_logos { border-color: #F57900; } #documents_portfolio a:focus .spip_logos, #documents_portfolio a:hover .spip_logos, #documents_portfolio a:active .spip_logos { border-color: #8B6F92; } /* Habillage des forums ---------------------------------------------- */ .repondre { clear: both; margin-top: 2.50em; margin-right: 1em; text-align: right; font-weight: bold; } /* Habillage des forums */ ul.forum { display: block; clear: both; margin: 0; padding: 0; } ul.forum, ul.forum ul { list-style: none; } .forum-fil { margin-top: 1.50em; } .forum-fil ul { display: block; margin: 0; padding: 0; margin-left: 1em; } .forum-chapo .forum-titre, .forum-chapo .forum-titre a { display: block; margin: 0; padding: 0; font-weight: bold; color: #333; } .forum-texte { margin: 0; padding: 0.50em 1em; color: #333; } .forum-texte .hyperlien {} .forum-texte .repondre { margin: 0; padding: 0.10em 0; text-align: right; } /* Boite d'un forum : eclaircissement progressif des bords */ ul .forum-message { border: 1px solid #666; margin: 0; padding: 0; margin-bottom: 1em; } ul ul .forum-message { border: 1px solid #A4A4A4; } ul ul ul .forum-message { border: 1px solid #B8B8B8; } ul ul ul ul .forum-message { border: 1px solid #CCC; } ul ul ul ul ul .forum-message { border: 1px solid #E0E0E0; } ul ul ul ul ul ul .forum-message { border: 1px dotted #E0E0E0; } /* Boite de titre d'un forum : mise en couleur selon la profondeur du forum */ ul .forum-chapo { border: 0; border-bottom: 1px dotted #B8B8B8; margin: 0; padding: 3px 6px 2px 6px; background: #C4E0E0; } ul ul .forum-chapo { background: #D4E8E8; } ul ul ul .forum-chapo { background: #E4F0F0; } ul ul ul ul .forum-chapo { background: #F4F8F8; border-bottom: 1px dotted #E0E0E0; } ul ul ul ul ul .forum-chapo { background: #FFF; } /* Habillage des petitions ---------------------------------------------- */ #signatures { clear: both; margin: 0 0 2em 0; padding: 0; background: none; } #signatures table { width: 100%; margin: 1em 0 0 0; } #signatures thead { text-align: center; color: #555; } #signatures td { padding: 0.50em; border: 2px solid #FEFEFE; vertical-align: top; } #signatures td.signature-date { background: #E4F0F0; text-align: center; white-space: nowrap; } #signatures td.signature-nom { background: #ECF4F4; text-align: center; } #signatures td.signature-nom small { display: block; } #signatures td.signature-message { background: #F4F8F8; } #signatures .formulaire_recherche { margin: 1em 0; text-align: right; } /*Cf.: spip_formulaires.css*/ #signatures .formulaire_recherche input.text { width: 10em; text-align: left; } /*Cf.: spip_formulaires.css*/ /* ------------------------------------------ /* Sous-navigation et autres menus /* ------------------------------------------ */ /* Habillage general des menus de navigation */ .menu { clear: both; margin-bottom: 2em; text-align: left; } .menu p { margin: 0.20em 0; padding: 0.20em 0.10em; } .menu ul { margin: 0; padding: 0; list-style: none; border-bottom: 1px solid #DDD; } .menu ul li { margin: 0.20em 0; padding: 0.20em; border-top: 1px solid #DDD; } .menu ul li ul { margin-left: 1em; border: 0; } .menu ul li li { padding: 0; border: 0; } /* Pagination */ .pagination { clear: both; text-align: right; font-size: 0.90em; color: #666; } .pagination .on { font-weight: bold; color: #666; } /* Rubriques */ .rubriques ul { border: 0; } .rubriques ul li { background: #EEE; border: 0; } .formulaire_recherche { margin-bottom: 2em; } /*Cf.: spip_formulaires.css*/ /* Listes d'articles et extraits introductifs */ .articles ul li { clear: both; padding: 0.40em 0.20em; } .articles ul li h3 { margin: 0.30em 0; } .articles .spip_logos { float: right; clear: right; margin: 0 0 4px 16px; } .articles ul li .enclosures { float: right; text-align: right; max-width: 60%; margin: 0; } .articles ul li .introduction { margin-top: 0.30em; line-height: 1.40em; } /* Couleurs des liens ---------------------------------------------- */ a { color: #604A7F; text-decoration: none; } a:focus,a:hover,a:active { color: #F57900; text-decoration: underline; }spip/spip/squelettes-dist/inc-rubriques.html0000766000000000000000000000152711236524722022522 0ustar adminadministrators[(#REM) Barre de navigation, ouverte sur la hierarchie courante On fait un plan, et, quand on avance vers une rubrique, on l'affiche si son parent est expose ou est la racine du site. ] spip/spip/squelettes-dist/recherche.html0000766000000000000000000000714511236524722021664 0ustar adminadministrators <:resultats_recherche:> - [(#NOM_SITE_SPIP|textebrut)]
    [(#REM) Entete de la page + titre du site ] [(#REM) Contenu principal : Resultats de la recherche ]
    [(#REM) Fil d'Ariane ]
    <:accueil_site:> > <:info_rechercher:>[ > (#RECHERCHE)]
    [

    <:resultats_recherche:>

    « (#RECHERCHE) »

    ] [(#REM) Articles trouves ] [(#REM) Rubriques trouvees ] [(#REM) Mots-cles trouves ] [(#REM) Breves trouvees ] [(#REM) Messages trouves ] [(#REM) Sites web trouves ]
    [(#REM) Menu de navigation laterale ] [(#REM) Menu de navigation laterale ]
     
    [(#REM) Pied de page ]
    spip/spip/squelettes-dist/inc-pied.html0000766000000000000000000000172511236524722021422 0ustar adminadministrators
    SPIP | <:squelette:>[ (#SESSION{id_auteur}|?{' '})| <:icone_deconnecter:> ][(#SESSION{id_auteur}|?{'',' '})| ][ (#AUTORISER{ecrire})| <:espace_prive:>] | <:plan_site:> | <:icone_suivi_activite:> RSS 2.0
    [(#REM) Cette balise permet de deporter les calculs lourds (indexation etc) dans une image cachee, ce qui evite de ralentir l'affichage des pages. ]#SPIP_CRON spip/spip/CHANGELOG.txt0000766000000000000000000005526111236524730015740 0ustar adminadministrators2.0.7 -> 2.0.8 (11 mai 2009) Revision: 13974 generer_action_auteur necessite au moins 2 arguments (eric) Revision: 13972 améliorations du débusqueur (report de [13917], [13941] et[13944] ) Revision: 13971 ne pas confondre le parent de l'id que l'on demande a #EXPOSE avec le parent du principal qui lui est extrait du contexte de reference. Le premier est passe en parametre mais ne sert en fait a rien, le second doit du coup etre trouve par une requete sql. La confusion entrainait des trous dans la liste des objets a exposer si au premier calcul le parent n'etait pas le meme (tetue) Revision: 13970 mise à jour de jquery.form.js pour éviter un bug sur IE8 et les formulaires ajax. ([13955], [13966] et [13967]) Revision: 13963 l'ecriture du tag en sortie des filtres images echouait si l'url initiale contenait des &. Un patch qui ne restera pas dans les annales mais fonctionne dans le cas des documents proteges Revision: 13962 copie_locale renvoie toujours un chemin relatif a la racine, pas au repertoire courant (cas des documents proteges) Revision: 13961 les filtres image appliques sur les images protegees par spip.php?action=acceder_document provoquent un appel a taille_image qui commet l'erreur de tronquer la chaine de get avant de faire copie_locale, et d'essayer vainement de copier spip.php en local. Si par malheur, la page d'accueil servie par spip.php dans ce cas contient une ou plusieurs images protegees retraitees, la boucle et bouclee, et le serveur par terre. Probablement donc, une cause serieuse de saturation serveur pour les utilisateurs du plugin acces_restreint Revision: 13959 Validité XHTML Un petit complément à [13957] pour parfaire la validité (Eric) Revision: 13954 Import des sauvegardes partielles: si le document est déjà distant, ne pas ajouter le _DIR_IMG local, ça ne rime à rien. Par ailleurs, pas d'état d'âme avec les vieilles tables: on ne peut insérer que des sauvegardes partielles de même constitution que la base d'accueil. Revision: 13952 report de [13950] date en nepalais Revision: 13951 correction du passage de langue dans les formulaires CVT : un formulaire dans un article différent de la langue du site () n'avait pas les bonnes traductions des fonctions _T() dans les fonctions verifier() et traiter(). (cerdic) Revision: 13946 Correction de [13939]: se protéger du bloc de compatibilité des url_propres que le nouveau form_hidden interprète de travers: autant ne pas passer par generer_url_entite si on a déjà le paramètre page, typiquement dans le cas du formulaire de recherche std (Eric). Revision: 13943 Correction de l'erreur de syntaxe PHP du code compilé lorsque le critère {{{par}}} contient un appel de fonction SQL. Un peu à l'arrach', mais ça permet déjà de retrouver la compatibilité avec ce que savait faire la 1.9 (Mathieu). Test {{{
    • #TITRE
    }}} Revision: 13942 Prendre en compte un nom et un mot de passe dans une URL de page distante à récupérer (Stéphane) Revision: 13940 Dans le squelette des pétitions, il faut afficher le moteur de recherche s'il vient d'y avoir une recherche, le nombre de signatures est faussement réduit dans ce cas. Et en profiter pour faire du XHTML strict. Revision: 13939 Compatibilité du filtre {{{form_hidden}}} avec les URL symboliques: il faut qu'il demande à generer_url_entite de lui fabriquer le contexte comme pour l'assemblage de la page. La modif de urls/page.php n'était finalement pas indispensable, mais éviter de resynthètiser les 3 RegExp à chaque appel ne fait pas de mal. Revision: 13938 le pipeline "styliser" n'était pas déclaré dans la stable ! Revision: 13936 permettre que le titre d'un document ait une extension differente de celle du fichier d'origine pour que le telechargement se fasse sous un nom&type different de celui sous lequel le fichier est heberge sur le serveur (ex envoyer en .php un fichier stocke en .txt pour raison de securite). Revision: 13931 etre un peu plus strict dans la verification du titre du document avant de s'en servir comme nom de fichier : - il faut qu'il ait la bonne extension - il faut qu'il ressemble a un nom de fichier (en particulier compose de caracteres licites) ( [13933] aussi) Revision: 13930 retablir un content-type indument supprime par [13924] Revision: 13928 double echappement provoquait la mort definitive des sites suspendus : ils devenaient {{{'su}}} au lieu de {{{sus}}} Revision: 13927 Ce n'est pas parce que certains systèmes d'exploitation que je ne nommerai pas pataugent avec certains noms de fichiers qu'il faut considérer [11243] comme une {{fausse bonne idée}} comme le dit [13760]. Je filtre le cas du titre de document n'ayant pas d'extension qui ne doit en effet pas être utilisé comme nom de fichier du {{{Content-Disposition}}} (et encore, {{{Makefile}}} est notoirement recevable), mais autrement je restaure le comportement d'avant qui est une fausse {{fausse bonne idée}}}, autrement dit une vraie bonné idée. Par contrecoup, report du renforcement de sécurité su secret du site [13866] dans la branche 2.0. Revision: 13924 seuls les types de document qui ne peuvent etre inclus doivent etre envoyes en "Content-Disposition : attachment". Les clip flash et autre types embed n'etais pas visualisable lorsque la protection des documents etait activee Revision: 13912 #1744 memoriser le bouton sumblit clique ou le x/y du bouton image clique quand on post un formulaire en ajax pour pouvoir les poster si jamais on resubmit en post classique suite a une demande du serveur refuser_traiter_formulaire_ajax() Revision: 13911 enlever la securite dans le message_ok au retour des formulaires, car sinon il n'est pas possible de faire la redirection apres un post ajax dans l'espace prive Revision: 13909 permettre au filtre |match de retourner la valeur 0 (zero) si elle est explicitement recherchee Revision: 13908 #1732 : bug a la verification lors de la creation d'un auteur ( plus [13910]) Revision: 13905 #1687 : ne pas perturber le filtre unique avec #INTRODUCTION Revision: 13901 corriger la recuperation d'arguments passes en url et le faux appel de syndic.html Revision: 13898 Oups. Faux départ de AS U ! (mea culpa) Revision: 13897 Les URLs ne se recalculaient pas dans un cas précis : changement de la casse sur une table insensible à la casse. Pour éviter cela, on réécrit aussi, en plus de la date de mise à jour de l'url son titre. Si la casse change, il sera ainsi pris en compte. Correction aussi d'un bug U.type inexistant sur les url arborescentes... Revision: 13893 [12134] avait casse la relance des signatures en recalculant un hash au lieu de renvoyer l'existant Revision: 13892 amelioration de la strategie de purge : - si le cache est trop gros on redemande la main - mais si il n'y a plus assez de vieux fichiers a purger, on la rend Ainsi, meme avec un reglage trop bas du quota, le cache se stabilisera autour du volume necessaire pour stocker une heure de traffic Revision: 13889 ne pas laisser le cache deborder lorsque les robots (ou les internautes) sont tres actifs - inc/invalideur renvoie le ratio taille cache/quota - le genie redemande la main lorsque le ratio est trop grand, sans attendre le prochain coup - les operations de vidange sont logees dans invalideur.log avec les details permettant de suivre les operations 2.0.6 -> 2.0.7 (13 avril 2009) Revision: 13887 Le datage des urls reecrites echouait pour cause de requette eronnee. Le suspens continue : y aura-t-il une version stable 2.0.x avec des urls reecrites non bugguees ? Revision: 13882 patch de vincent ramos pour #1703 + report des trucs modernes de inc/rechercher dans la branche 2.0 Revision: 13881 pas de . en dehors de celui separant l'extension, sinon il est possible d'injecter du php dans un toto.php.txt, qu'apache peut vouloir traiter comme un .php normal (attaque dite 'de vlad' ) Revision: 13880 session_set() lorsqu'on renseigne son email (suite de [13878]) Revision: 13879 report [13878] afficher l'email de l'auteur connecte si on le connait (session) Revision: 13877 report et nettoyage de ecrire_fichier_securise() Revision: 13876 report de ecrire_fichier_securise [13867] pour mieux masquer le contenu de tmp/meta_cache.txt(.php) en cas d'ouverture inopinee de tmp/ aux regards curieux Revision: 13873 retour de la pagination dans le controle des petitions (bug introduit en [13320]) Revision: 13872 Report de [13868] corrigeant l'aléa ancien. Revision: 13870 revert de [13846] qui casse le fonctionnement de la pagination AJAX Revision: 13865 il faut securiser les appels à propre et typo hors squelette (typiquement code php de l'espace privé), mais dans les squelettes, la sécurisation est intégrée, et il ne faut pas en rajouter. On utilise donc la presence du parametre connect pour distinguer les appels des squelettes qui le comportent tous, des appels historiques hors squelettes qui ne le mentionnent jamais. Corrolairement, en cas d'appel hors squelette avec un parametre connect, il convient d'appeler en plus interdire_script Revision: 13862 Nouvelle méthode pour l'authentification LDAP, qui devrait résoudre le bug dans certaines config d'Active Directory. Géraud Tardif remarque qu'il est idiot de risquer des bugs avec des champs absents pour trouver le login, puisqu'on l'a déjà. Il vaut donc mieux se rabattre sur lui, mais on modifie les signatures des fonctions auxilaires pour qu'il soit facile de surcharger {{{auth_ldap}}} de sorte qu'on réclame des champs supplémentaires et qu'on en tienne compte. Revision: 13859 Ignorer les lignes vides dans les CSV lorsque transformés en table HTML à la volée (Cyril). Revision: 13858 Ne pas utiliser intval quand on fabrique une requête SQL, celui-ci ayant des grands entiers en standard, contrairement à PHP (Camille). Vu son logo on aurait dû se méfier: un PHP, ça tronque énormément. Revision: 13857 Les distributions RedHat, Fedora et CentOS ont maintenant une installation d'Apache par défaut qui font que le AllowOverride est à None par défaut, avec comme conséquence que les {{{deny from all}}} installés par SPIP ne sont plus effectifs sur ces distributions non modifiées. En conséquence, report immédiat dans la branche stable de [13608], qui n'écrit plus dans tmp la valeur des aleas, qui sont des informations trop sensibles. A signaler à propos des aléas que l'alea_ancien n'est pas pris en compte pour les actions dont l'URL comporte ecrire/, il faut renoncer à ces URLs. Enfin, il faudrait insister dans la doc sur le fait que tmp/ et config/ doivent être interdits à la lecture publique, idéalement en les mettant à l'extérieur du DocumentRoot. Revision: 13856 Bug de puce 'meme-rubrique" des sites references Revision: 13853 un flag manquant pour preciser que l'on est dans l'espace prive Revision: 13852 pas d'exe´cution en public non plus ! Revision: 13850 il est temps de suivre la prévision des oracles proteger l'espace privé, donc... Revision: 13848 eviter le die intempestif "spip_urls AS U insertion sans description" lors de la creation de nouvelles urls ... (bug introduit au detour de http://zone.spip.org/trac/spip/changeset/13838#file22) Revision: 13846 indentation + meilleure verification sr onAjaxLoad(), pour compat crayons++ Revision: 13845 enieme correction des urls ... je vais peut-etre finir par y arriver Revision: 13844 report oublie de [13765] qui reparait les urls arbo avec types renommes Revision: 13843 permettre a la previsu de savoir ou elle se trouve (cf. http://www.spip-blog.net/forum-spip-org-comme-base-de.html ) Revision: 13841 log plus explicite Revision: 13839 erreur sql sur date Revision: 13838 NOW() disparait au profit de la date php (a verifier svp) Revision: 13836 la date d'un article c'est celle du php, pas celle du SQL 2.0.5 -> 2.0.6 (16 mars 2009) Revision: 13834 report http://trac.rezo.net/trac/spip/changeset/13833 ajout d'un index sur spip_documents_liens Revision: 13830 passer l'id_auteur et l'id_article au squelette du forumlaire ecrire_auteur l'id etait calculé mais pas passé, on l'ajoute donc aussi Revision: 13828 report de http://trac.rezo.net/trac/spip/changeset/13827 redirections anciennes urls Revision: 13826 report discret de exec=fond introduit dans http://trac.rezo.net/trac/spip/changeset/13800 afin de pouvoir utiliser un meme plugin en version stable et dev etant un ajout de fonctionnalité, cela ne devrait pas poser de problème... Revision: 13824 report de http://trac.rezo.net/trac/spip/changeset/13822 et http://trac.rezo.net/trac/spip/changeset/13823 -- correction erreur 404 sur les urls de type spip.php Revision: 13820 donner une PRIMARY KEY quand il n'y a rien (VIEW MySQL) Revision: 13818 toujours proteger les file_exists() Revision: 13812 ajout discret du pipeline styliser pour le futur 2.0.6, afin que les plugins comme SPIP Clear puissent s'appuyer dessus sans surcharger le fichier. Revision: 13809 coquille css (pi_r) Revision: 13808 Report de http://trac.rezo.net/trac/spip/changeset/13807 -- ne pas empecher le changement de mode image/document sur les images de rubriques... Revision: 13801 manque de quotes (denisb) Revision: 13798 un lien du type {{{ [->http://www.favicon.cc/?action=icon&file_id=29805] }}} doit se transformer proprement avec un {{{ & }}} Revision: 13797 Report de http://trac.rezo.net/trac/spip/changeset/10796 : #CHAPO doit enlever les redirections, mais pas #CHAPO* qui doit les laisser. Revision: 13795 report de http://trac.rezo.net/trac/spip/changeset/13794 : charger les autorisations au moment du traitement de #FORMULAIRE_EDITER_AUTEUR appellé depuis le public Revision: 13793 Le début des vertèbres n'est pas la vertèbre nommée début [http://archives.rezo.net/spip-dev.mbox/200902.mbox/raw/%3C49A3FF0F.8070102@yahoo.fr%3E/ YannX]. Revision: 13792 Ne pas tenter de réparer l'irréparable quand il faut prendre de la distance. Revision: 13791 Fallait savoir que {{{$x[$y]}}} convertit la chaîne {{{$y}}} en nombre quand elle est interprétable ainsi. PHP, le langage dont vous nous ne découvrirez jamais tous les pièges. Super argument publicitaire. 2.0.4 -> 2.0.5 - report de [13778] : l'installation sur les serveurs mysql avec un sql_mode par defaut etait cassee repare les installations sous easyphp 3.0 par defaut (13788) - closedir(d); avant de l'effacer (13787) - report de [13785] reparer la 404 des urls propres, et le mode urls propres_qs (13786) - report de htaccess (robots.txt, favicon.ico, sitemap.xml), correction des urls selon rfc 1738. references : [13769] et de [13779] a [13783] (13784) - noindex au lieu de none pour site.html (cf. [13773]) ( 13776 ) 2.0.3 -> 2.0.4 - Remettre jQuery 1.2.6 pour ne pas créer de problème de comptabilité. Ceux qui le souhaitent pourront mettre jQuery 1.3.2 dans leur répertoire squelettes dans un fichier : « javascript/jquery.js » (13774) - Enlever tous les arobases des sélecteurs jQuery pour autoriser jQuery 1.3.x(13772) - report de [13755] et [13763] introduit les valuers date_default et date_redac_default dans le contexte quand SPIP ajoute la date d'office / accepter un tableau pour le filtre alterner (13770) - report de [13621]Ajout de jQuery 1.3 ... Attention aux extensions qui utilisent encore [@param=value] dans les sélecteurs jQuery à passer en [param=value] . (13768) - Ajout de image_joindre (13766) - #1691 : une balise etant absurde, il s'agit forcement du nom de la note (13761) - #1711 : annuler [11243] qui etait une fausse bonne idee ; en l'absence d'extension dans le titre, les navigateurs sont perdus (13760) - #1695 produire un aplat quand la production d'image echoue pour la css privee (13759) - #1704 : reduire la taille de la vignette, y compris dans la colonne documents (13758) - la fonctionnalite cachee dans la dist {article sans texte+un document joint} -> affichage du document inline provoquait le masquage de tous les documents joints lorsque le texte etait vide et plusieurs document joint. il faudrait au moins documenter le code pour eviter de reintroduire le bug (13757) - jQuery 1.3.2 http://docs.jquery.com/Release:jQuery_1.3.2 (13756) - Complément sur les urls arbo (13753) - les balises CVT #FORMULAIRE_TRUC implementees par la balise generique #FORMULAIRE_ n'utilisent que le squelette formulaires/truc.html Inutile et trompeur de chercher a la racine le squelettre truc.html, donc (13751) - Bien tester tous les formulaires avant de les declarer inexistants * [13744] [13745] [13746] etaient incomplets on les fussionne (13749) - Complement a [13745] et [13746] * le findpath manquait de precision (13746) - report de [13744] #FORMULAIRE_INEXISTANT (13745) - report de [13741] gestion plus fine des urls (13742) - Amelioration traitement de l'arabe, notamment quand tiret a l'interieur d'un mot. (13739) - On place le contenu du js du login dans un cdata pour être valide ... On encapsule également la fonction jquery en passant... (13734) - report de [13732] bg d'affiche des sites syndiques dans l'espace prive (13733) - report de [13728] urls page (13729) - report de [13725] et [13726] (debug) (13727) - complement a [13720] : les fonctions url_xx($id,$entite) renvoient toujours une url valide donc commencant par ../ si on est dans ecrire/ (c'etait le cas auparavant pour les documents mais pas pour les autres entites) Corrolairement #URL_ARTICLE pointe toujours sur l'article, que le squelette soit evalue dans l'espace public ou prive, et [(#URL_ARTICLE|url_absolue)] est toujours correcte. Ceci est vrai pour toutes les entites (13722) - gerer les notes dans le suivi des forums (13721) - report de [13719] nouvelle API d'URLs (13720) - ne pas surligner dans la page de recherche elle-meme (report de [13717]) (13718) - integration des #NOTES dans les forums (13710) - lorsque generer_url_entite doit generer une url publique depuis l'espace prive, il semble logique de prefixer de _DIR_RACINE pour que l'url soit valide repare le calcul des nouveautes et de [(#URL_ARTICLE|url_absolue)] evalue depuis le prive (13708) - eviter les @include qui masquent les erreurs (13707) - un pas xhtml (13706) - report de [13689] #URL_ARTICLE et consort designent toujours l'url publique de l'objet depuis la racine, meme utilisee dans l'espace prive il faut donc les prefixer de #EVAL{_DIR_RACINE} dans le cas ou l'on affiche cette url dans l'espace prive pour que le lien soit correct (13705) - report de [13696] ne pas coller les paragraphes en previsu des forums (13701) - éviter d'avoir plusieurs id="nobot" sur la même page. Un div englobant le contenu du formulaire des signatures pour éviter des erreurs de validation (13699) - Le double clic du sélecteur d'auteur en Ajax ne fonctionnait pas. (13694) - puce_statut surchargeable (permet en particulier le plugin mots techniques) (13693) - fixer la taille des images pour que ca ne clignote pas (13692) - Complément de 13677 sur la mise à jour de la base lors d'un upgrade (13691) - prise en compte de Accept-Language pour tout le monde (pas seulement les personnes authentifiées) (13690) - Correction d'un bug sur la sauvegarde et la fusion (13661) - Meilleure gestion en cas de plantage de l'installation (13659) - Eviter un warning concernant les URL personnalisées (13654) - correctif version allemande (klaus) (13636) - la syntaxe recuperer_fond($fond,$contexte,array('ajax'=>true)) ne fonctionnait que si le fond etait defini dans le contexte (13615) - Il y a des versions de PHP où les imagegif etc sont absentes, on contrôle (13606) - Il est totalement inutile de compliquer les choses avec des {doublons}... {!id_groupe} enlève déjà le groupe en cours. (13604) - Gérer l'explicitation du nom des tables dans le critère Fusion (13603) - Respecter les 0 dans les urls propres (13602) - Les restaurations de DUMP anciens avec une version 10000 utilisée ne commençaient pas les mises à jour à la version qu'il faut (13598) 2.0.2 -> 2.0.3 - pouvoir tenir compte du hreflang lors de la construction de l'URL par calculer_url via inc_lien_dist (13595) - les entitee > et < etaint changee en < > apres une surligne (13593) - Accepter les - dans le nom des bases SQL (13591) - Bug sur changement d'auteur si le nom de l'auteur était trop court (13590) - Coquille dans les vieilles defs (manque un g pour generer !) (Charly Caulet) (13586) - Retour des recherches de mots associés aux documents (non utilisée dans le core) (13584) - Bug si erreur de frappe #URL_ MOT (espace avant MOT) (13582) - Pour un raccourci "[->25]" la fonction nettoyer_raccourcis_typo renvoie "Array"... (Pat). (13573) - Le numéro du jour manquait sur le libellé du survol conduisant au calendrier du jour. Quant au libellé du mois, il n'emmenait pas sur le calendrier du mois. (13569) - Une fonctionnalité de la 1.9.2 perdue: si id_rubrique est fournie à la création d'une traduction, il faut créer dans cette rubrique, pas ailleurs. (13560) - ne pas ecraser le hash de la boucle avec le critere {recherche} cela empeche tout plugin de l'utiliser (13555) - proteger la fonction recuperer_fond quand on ecrit recuperer_fond($fond,$_GET) dans les plugins meme si il semble que la variable soit protegee en amont dans tous les cas (13551) - Le cryptage du mot de passe avant envoi n'était plus assuré que si le cookie dession était toujours actif. (13544) - Fatal error a la suppression d'un document avec vignette. (13539) - Lorsqu'on pose ou retire les .htaccess des sous-répertoires de IMG, il ne faut pas oublier celui nommé "distant" qui ne figure pas dans la table des types de documents. (13538) - Deux balises A pour LOGO_DOCUMENT, c'est une de trop (Eric). (13536) 2.0.1 -> 2.0.2 - deux bugs au login (13529) - refuser les urls avec le pseudo protocole data (13521) - bonne année (13520) - Unifier la mise en page dans les 3 onglets de gestion des langues (13519) - encore quelques retouches sur l'agenda de l'espace publique (13517) - le champ type de la balise A d'un logo de document était toujours vide (13512) - la boucle DOCUMENTS ne donnait pas les documents attachés aux messages de forums (13511) - accepter les notes nommees <*> <+> <.> et autres caracteres significatifs (13510) - un peeling pour évacuer le point noir. (13508) - amélioration du calcul de popularité (13506) - lien incorrect dans le message à un visiteur venant de s'inscrire (13504) - support du png8 comme format de image_format (l'extension sera bien 'png') (13501) - authentification via LDAP/AD, lire le Samaccountname (13500) - proteger l'$id fournit a calcul_branche_in (13498) 2.0.0 -> 2.0.1 rapport de police (13469 ->13495) - réparation d'un bug sur les urls standard et autres anciennes implémentations (13489) - problème de création du répertoire cache à l'install (13487) - correction mineure sur le calcul des visites (13485) - Compilateur : défaut sur la prise en compte sur le champ statut dans le cas d'une requête sur une table principale (13484) - correction pour IE6/7 sur les formulaires de l'espace privé (13481) - il était impossible de déplacer SPIP dans un sous répertoire (13478 ) spip/spip/spip.php0000766000000000000000000000204611236524730015365 0ustar adminadministrators spip/spip/config/0000777000000000000000000000000011266531363015146 5ustar adminadministratorsspip/spip/config/remove.txt0000766000000000000000000000012311236524722017177 0ustar adminadministratorsVous pouvez effacer ce fichier sans dommages. You can safely remove this file. spip/spip/index.php0000766000000000000000000000005611236524730015520 0ustar adminadministrators spip/spip/INSTALL.txt0000766000000000000000000000075311236524730015553 0ustar adminadministrators ###### Installation de SPIP ##### Rendez-vous avec votre navigateur sur la page ecrire/ pour commencer l'installation de votre site SPIP. Votre serveur Web doit offrir php (version > 4.0.8) et MySQL. Pour permettre a SPIP de gerer de belles adresses (URL), vous devrez probablement renommer le fichier htaccess.txt en .htaccess a la racine du site (apres avoir, si necessaire, edite la ligne RewriteBase ; voir les commentaires). ################################# http://www.spip.net/ spip/spip/htaccess.txt0000766000000000000000000001023311236524730016234 0ustar adminadministrators############################################################## # Fichier .htaccess SPIP v 2.0 # # # # Permet de controler les URLs et la version de php utilisee # # Compatible avec les URLs 'html', 'propres' et 'propres2' # # Permet aussi d'effectuer la transition de .PHP 3 vers .PHP # # # # Pour utiliser ce fichier renommez-le '.htaccess' dans le # # repertoire racine du site, en veillant a ne pas ecraser un # # .htaccess personnalise qui s'y trouverait deja # # # # Attention certains hebergeurs desactivent tout ou partie # # des fonctions du fichier .htaccess ; celui-ci est donc # # indicatif - en cas de difficulte voir sur les forums SPIP # ############################################################## RewriteEngine On ################ CONFIGURATION ###################### ### Configuration sous-repertoire # Chez la plupart des hebergeurs il faut indiquer "RewriteBase /" # sinon modifiez cette ligne RewriteBase / # SPIP version 'php' - si vous avez d'anciennes adresses en '.php[3]', # supprimez le '#' sur les lignes qui suivent pour rediriger les acces # errones vers le .php correspondant #RewriteCond %{REQUEST_FILENAME} -f #RewriteRule ^(.+)\.php[3]$ $1.php [QSA,L] # Fin version ### ################ REGLAGES PERSONNALISES ###################### # Inscrivez ci-dessous vos reglages supplementaires ################ GESTIONS DES URLS SPIP ####################### # Deux pseudo-actions a present evacuees # N'y at-il pas moyen de REMPLACER un nom dans la QueryString ? RewriteCond %{QUERY_STRING} action=rss RewriteRule spip.php spip.php?page=rss [QSA,L] RewriteCond %{QUERY_STRING} action=ical RewriteRule spip.php spip.php?page=ical_prive [QSA,L] ### # Si le fichier ou repertoire demande existe # ignorer toutes les regles qui suivent RewriteCond %{REQUEST_FILENAME} -f RewriteRule "." - [skip=100] RewriteCond %{REQUEST_FILENAME} -d RewriteRule "." - [skip=100] # ### ### # Compatibilite avec les URLS "html" (pour transition sympa) # voir fichier ecrire/urls/html.php RewriteRule ^rubrique([0-9]+)(\.html)?$ spip.php?page=rubrique&id_rubrique=$1 [QSA,L] RewriteRule ^article([0-9]+)(\.html)?$ spip.php?page=article&id_article=$1 [QSA,L] RewriteRule ^breve([0-9]+)(\.html)?$ spip.php?page=breve&id_breve=$1 [QSA,L] RewriteRule ^mot([0-9]+)(\.html)?$ spip.php?page=mot&id_mot=$1 [QSA,L] RewriteRule ^auteur([0-9]+)(\.html)?$ spip.php?page=auteur&id_auteur=$1 [QSA,L] RewriteRule ^site([0-9]+)(\.html)?$ spip.php?page=site&id_syndic=$1 [QSA,L] # Compatibilite avec les anciennes URLS appelant directement des fichiers php RewriteRule ^(rubrique|article|breve|mot|auteur|site|agenda|backend|backend-breves|distrib|forum|ical|plan|recherche|sommaire|sommaire_texte)\.php3?$ spip.php?page=$1 [QSA,L] RewriteRule ^resume.php[3]? spip.php?page=sommaire [QSA,L] RewriteRule ^page.php[3]? spip.php [QSA,L] RewriteRule ^spip_cal\.php3?$ spip.php?page=ical_prive [QSA,L] RewriteRule ^spip_rss\.php3?$ spip.php?page=rss [QSA,L] # Fin compatibilite ### ### # URLs "propres", "propres2", "libres", "arbo" RewriteRule ^[^\.]+(\.html)?$ spip.php [QSA,E=url_propre:$0,L] # Fin URLs "propres" et "propres2" ### ### # Divers # bloquer les acces aux repertoires .svn/ (SPIP, plugins, squelettes...) RewriteRule ^(.*/)?\.svn/ - [F] ### # Fichiers "standards" (si absents de la racine) # RewriteRule ^robots[.]txt$ spip.php?page=robots.txt [QSA,L] RewriteRule ^favicon[.]ico$ spip.php?page=favicon.ico [QSA,L] RewriteRule ^sitemap[.]xml$ spip.php?page=sitemap.xml [QSA,L] ## # expirer les images (pour contourner gros bug MSIE sur le cache) # note : a decommenter si vous voulez tester # # ExpiresActive on # ExpiresByType image/gif A3600 # ExpiresByType image/jpeg A3600 # ExpiresByType image/png A3600 # ################################# # gestion des erreurs 404 # voir http://www.spip.net/fr_article3226.html # Pour que le serveur http renvoie les erreurs 404 vers SPIP, supprimer le '#' # ErrorDocument 404 /spip.php?page=404 # ### spip/spip/svn.revision0000766000000000000000000000045502263504740016270 0ustar adminadministrators Origine: svn://trac.rezo.net/spip/tags/spip-2.0.9 Revision: 14357 Dernier commit: 2009-08-06 11:22:54 +0200 svn://trac.rezo.net/spip/tags/spip-2.0.9 14357 2009-08-06 11:22:54 +0200 spip/spip/COPYING.txt0000766000000000000000000010451311236524730015554 0ustar adminadministrators GNU GENERAL PUBLIC LICENSE Version 3, 29 June 2007 Copyright (C) 2007 Free Software Foundation, Inc. Everyone is permitted to copy and distribute verbatim copies of this license document, but changing it is not allowed. Preamble The GNU General Public License is a free, copyleft license for software and other kinds of works. The licenses for most software and other practical works are designed to take away your freedom to share and change the works. By contrast, the GNU General Public License is intended to guarantee your freedom to share and change all versions of a program--to make sure it remains free software for all its users. We, the Free Software Foundation, use the GNU General Public License for most of our software; it applies also to any other work released this way by its authors. You can apply it to your programs, too. When we speak of free software, we are referring to freedom, not price. Our General Public Licenses are designed to make sure that you have the freedom to distribute copies of free software (and charge for them if you wish), that you receive source code or can get it if you want it, that you can change the software or use pieces of it in new free programs, and that you know you can do these things. To protect your rights, we need to prevent others from denying you these rights or asking you to surrender the rights. Therefore, you have certain responsibilities if you distribute copies of the software, or if you modify it: responsibilities to respect the freedom of others. For example, if you distribute copies of such a program, whether gratis or for a fee, you must pass on to the recipients the same freedoms that you received. You must make sure that they, too, receive or can get the source code. And you must show them these terms so they know their rights. Developers that use the GNU GPL protect your rights with two steps: (1) assert copyright on the software, and (2) offer you this License giving you legal permission to copy, distribute and/or modify it. For the developers' and authors' protection, the GPL clearly explains that there is no warranty for this free software. For both users' and authors' sake, the GPL requires that modified versions be marked as changed, so that their problems will not be attributed erroneously to authors of previous versions. Some devices are designed to deny users access to install or run modified versions of the software inside them, although the manufacturer can do so. This is fundamentally incompatible with the aim of protecting users' freedom to change the software. The systematic pattern of such abuse occurs in the area of products for individuals to use, which is precisely where it is most unacceptable. Therefore, we have designed this version of the GPL to prohibit the practice for those products. If such problems arise substantially in other domains, we stand ready to extend this provision to those domains in future versions of the GPL, as needed to protect the freedom of users. Finally, every program is threatened constantly by software patents. States should not allow patents to restrict development and use of software on general-purpose computers, but in those that do, we wish to avoid the special danger that patents applied to a free program could make it effectively proprietary. To prevent this, the GPL assures that patents cannot be used to render the program non-free. The precise terms and conditions for copying, distribution and modification follow. TERMS AND CONDITIONS 0. Definitions. "This License" refers to version 3 of the GNU General Public License. "Copyright" also means copyright-like laws that apply to other kinds of works, such as semiconductor masks. "The Program" refers to any copyrightable work licensed under this License. Each licensee is addressed as "you". "Licensees" and "recipients" may be individuals or organizations. To "modify" a work means to copy from or adapt all or part of the work in a fashion requiring copyright permission, other than the making of an exact copy. The resulting work is called a "modified version" of the earlier work or a work "based on" the earlier work. A "covered work" means either the unmodified Program or a work based on the Program. To "propagate" a work means to do anything with it that, without permission, would make you directly or secondarily liable for infringement under applicable copyright law, except executing it on a computer or modifying a private copy. Propagation includes copying, distribution (with or without modification), making available to the public, and in some countries other activities as well. To "convey" a work means any kind of propagation that enables other parties to make or receive copies. Mere interaction with a user through a computer network, with no transfer of a copy, is not conveying. An interactive user interface displays "Appropriate Legal Notices" to the extent that it includes a convenient and prominently visible feature that (1) displays an appropriate copyright notice, and (2) tells the user that there is no warranty for the work (except to the extent that warranties are provided), that licensees may convey the work under this License, and how to view a copy of this License. If the interface presents a list of user commands or options, such as a menu, a prominent item in the list meets this criterion. 1. Source Code. The "source code" for a work means the preferred form of the work for making modifications to it. "Object code" means any non-source form of a work. A "Standard Interface" means an interface that either is an official standard defined by a recognized standards body, or, in the case of interfaces specified for a particular programming language, one that is widely used among developers working in that language. The "System Libraries" of an executable work include anything, other than the work as a whole, that (a) is included in the normal form of packaging a Major Component, but which is not part of that Major Component, and (b) serves only to enable use of the work with that Major Component, or to implement a Standard Interface for which an implementation is available to the public in source code form. A "Major Component", in this context, means a major essential component (kernel, window system, and so on) of the specific operating system (if any) on which the executable work runs, or a compiler used to produce the work, or an object code interpreter used to run it. The "Corresponding Source" for a work in object code form means all the source code needed to generate, install, and (for an executable work) run the object code and to modify the work, including scripts to control those activities. However, it does not include the work's System Libraries, or general-purpose tools or generally available free programs which are used unmodified in performing those activities but which are not part of the work. For example, Corresponding Source includes interface definition files associated with source files for the work, and the source code for shared libraries and dynamically linked subprograms that the work is specifically designed to require, such as by intimate data communication or control flow between those subprograms and other parts of the work. The Corresponding Source need not include anything that users can regenerate automatically from other parts of the Corresponding Source. The Corresponding Source for a work in source code form is that same work. 2. Basic Permissions. All rights granted under this License are granted for the term of copyright on the Program, and are irrevocable provided the stated conditions are met. This License explicitly affirms your unlimited permission to run the unmodified Program. The output from running a covered work is covered by this License only if the output, given its content, constitutes a covered work. This License acknowledges your rights of fair use or other equivalent, as provided by copyright law. You may make, run and propagate covered works that you do not convey, without conditions so long as your license otherwise remains in force. You may convey covered works to others for the sole purpose of having them make modifications exclusively for you, or provide you with facilities for running those works, provided that you comply with the terms of this License in conveying all material for which you do not control copyright. Those thus making or running the covered works for you must do so exclusively on your behalf, under your direction and control, on terms that prohibit them from making any copies of your copyrighted material outside their relationship with you. Conveying under any other circumstances is permitted solely under the conditions stated below. Sublicensing is not allowed; section 10 makes it unnecessary. 3. Protecting Users' Legal Rights From Anti-Circumvention Law. No covered work shall be deemed part of an effective technological measure under any applicable law fulfilling obligations under article 11 of the WIPO copyright treaty adopted on 20 December 1996, or similar laws prohibiting or restricting circumvention of such measures. When you convey a covered work, you waive any legal power to forbid circumvention of technological measures to the extent such circumvention is effected by exercising rights under this License with respect to the covered work, and you disclaim any intention to limit operation or modification of the work as a means of enforcing, against the work's users, your or third parties' legal rights to forbid circumvention of technological measures. 4. Conveying Verbatim Copies. You may convey verbatim copies of the Program's source code as you receive it, in any medium, provided that you conspicuously and appropriately publish on each copy an appropriate copyright notice; keep intact all notices stating that this License and any non-permissive terms added in accord with section 7 apply to the code; keep intact all notices of the absence of any warranty; and give all recipients a copy of this License along with the Program. You may charge any price or no price for each copy that you convey, and you may offer support or warranty protection for a fee. 5. Conveying Modified Source Versions. You may convey a work based on the Program, or the modifications to produce it from the Program, in the form of source code under the terms of section 4, provided that you also meet all of these conditions: a) The work must carry prominent notices stating that you modified it, and giving a relevant date. b) The work must carry prominent notices stating that it is released under this License and any conditions added under section 7. This requirement modifies the requirement in section 4 to "keep intact all notices". c) You must license the entire work, as a whole, under this License to anyone who comes into possession of a copy. This License will therefore apply, along with any applicable section 7 additional terms, to the whole of the work, and all its parts, regardless of how they are packaged. This License gives no permission to license the work in any other way, but it does not invalidate such permission if you have separately received it. d) If the work has interactive user interfaces, each must display Appropriate Legal Notices; however, if the Program has interactive interfaces that do not display Appropriate Legal Notices, your work need not make them do so. A compilation of a covered work with other separate and independent works, which are not by their nature extensions of the covered work, and which are not combined with it such as to form a larger program, in or on a volume of a storage or distribution medium, is called an "aggregate" if the compilation and its resulting copyright are not used to limit the access or legal rights of the compilation's users beyond what the individual works permit. Inclusion of a covered work in an aggregate does not cause this License to apply to the other parts of the aggregate. 6. Conveying Non-Source Forms. You may convey a covered work in object code form under the terms of sections 4 and 5, provided that you also convey the machine-readable Corresponding Source under the terms of this License, in one of these ways: a) Convey the object code in, or embodied in, a physical product (including a physical distribution medium), accompanied by the Corresponding Source fixed on a durable physical medium customarily used for software interchange. b) Convey the object code in, or embodied in, a physical product (including a physical distribution medium), accompanied by a written offer, valid for at least three years and valid for as long as you offer spare parts or customer support for that product model, to give anyone who possesses the object code either (1) a copy of the Corresponding Source for all the software in the product that is covered by this License, on a durable physical medium customarily used for software interchange, for a price no more than your reasonable cost of physically performing this conveying of source, or (2) access to copy the Corresponding Source from a network server at no charge. c) Convey individual copies of the object code with a copy of the written offer to provide the Corresponding Source. This alternative is allowed only occasionally and noncommercially, and only if you received the object code with such an offer, in accord with subsection 6b. d) Convey the object code by offering access from a designated place (gratis or for a charge), and offer equivalent access to the Corresponding Source in the same way through the same place at no further charge. You need not require recipients to copy the Corresponding Source along with the object code. If the place to copy the object code is a network server, the Corresponding Source may be on a different server (operated by you or a third party) that supports equivalent copying facilities, provided you maintain clear directions next to the object code saying where to find the Corresponding Source. Regardless of what server hosts the Corresponding Source, you remain obligated to ensure that it is available for as long as needed to satisfy these requirements. e) Convey the object code using peer-to-peer transmission, provided you inform other peers where the object code and Corresponding Source of the work are being offered to the general public at no charge under subsection 6d. A separable portion of the object code, whose source code is excluded from the Corresponding Source as a System Library, need not be included in conveying the object code work. A "User Product" is either (1) a "consumer product", which means any tangible personal property which is normally used for personal, family, or household purposes, or (2) anything designed or sold for incorporation into a dwelling. In determining whether a product is a consumer product, doubtful cases shall be resolved in favor of coverage. For a particular product received by a particular user, "normally used" refers to a typical or common use of that class of product, regardless of the status of the particular user or of the way in which the particular user actually uses, or expects or is expected to use, the product. A product is a consumer product regardless of whether the product has substantial commercial, industrial or non-consumer uses, unless such uses represent the only significant mode of use of the product. "Installation Information" for a User Product means any methods, procedures, authorization keys, or other information required to install and execute modified versions of a covered work in that User Product from a modified version of its Corresponding Source. The information must suffice to ensure that the continued functioning of the modified object code is in no case prevented or interfered with solely because modification has been made. If you convey an object code work under this section in, or with, or specifically for use in, a User Product, and the conveying occurs as part of a transaction in which the right of possession and use of the User Product is transferred to the recipient in perpetuity or for a fixed term (regardless of how the transaction is characterized), the Corresponding Source conveyed under this section must be accompanied by the Installation Information. But this requirement does not apply if neither you nor any third party retains the ability to install modified object code on the User Product (for example, the work has been installed in ROM). The requirement to provide Installation Information does not include a requirement to continue to provide support service, warranty, or updates for a work that has been modified or installed by the recipient, or for the User Product in which it has been modified or installed. Access to a network may be denied when the modification itself materially and adversely affects the operation of the network or violates the rules and protocols for communication across the network. Corresponding Source conveyed, and Installation Information provided, in accord with this section must be in a format that is publicly documented (and with an implementation available to the public in source code form), and must require no special password or key for unpacking, reading or copying. 7. Additional Terms. "Additional permissions" are terms that supplement the terms of this License by making exceptions from one or more of its conditions. Additional permissions that are applicable to the entire Program shall be treated as though they were included in this License, to the extent that they are valid under applicable law. If additional permissions apply only to part of the Program, that part may be used separately under those permissions, but the entire Program remains governed by this License without regard to the additional permissions. When you convey a copy of a covered work, you may at your option remove any additional permissions from that copy, or from any part of it. (Additional permissions may be written to require their own removal in certain cases when you modify the work.) You may place additional permissions on material, added by you to a covered work, for which you have or can give appropriate copyright permission. Notwithstanding any other provision of this License, for material you add to a covered work, you may (if authorized by the copyright holders of that material) supplement the terms of this License with terms: a) Disclaiming warranty or limiting liability differently from the terms of sections 15 and 16 of this License; or b) Requiring preservation of specified reasonable legal notices or author attributions in that material or in the Appropriate Legal Notices displayed by works containing it; or c) Prohibiting misrepresentation of the origin of that material, or requiring that modified versions of such material be marked in reasonable ways as different from the original version; or d) Limiting the use for publicity purposes of names of licensors or authors of the material; or e) Declining to grant rights under trademark law for use of some trade names, trademarks, or service marks; or f) Requiring indemnification of licensors and authors of that material by anyone who conveys the material (or modified versions of it) with contractual assumptions of liability to the recipient, for any liability that these contractual assumptions directly impose on those licensors and authors. All other non-permissive additional terms are considered "further restrictions" within the meaning of section 10. If the Program as you received it, or any part of it, contains a notice stating that it is governed by this License along with a term that is a further restriction, you may remove that term. If a license document contains a further restriction but permits relicensing or conveying under this License, you may add to a covered work material governed by the terms of that license document, provided that the further restriction does not survive such relicensing or conveying. If you add terms to a covered work in accord with this section, you must place, in the relevant source files, a statement of the additional terms that apply to those files, or a notice indicating where to find the applicable terms. Additional terms, permissive or non-permissive, may be stated in the form of a separately written license, or stated as exceptions; the above requirements apply either way. 8. Termination. You may not propagate or modify a covered work except as expressly provided under this License. Any attempt otherwise to propagate or modify it is void, and will automatically terminate your rights under this License (including any patent licenses granted under the third paragraph of section 11). However, if you cease all violation of this License, then your license from a particular copyright holder is reinstated (a) provisionally, unless and until the copyright holder explicitly and finally terminates your license, and (b) permanently, if the copyright holder fails to notify you of the violation by some reasonable means prior to 60 days after the cessation. Moreover, your license from a particular copyright holder is reinstated permanently if the copyright holder notifies you of the violation by some reasonable means, this is the first time you have received notice of violation of this License (for any work) from that copyright holder, and you cure the violation prior to 30 days after your receipt of the notice. Termination of your rights under this section does not terminate the licenses of parties who have received copies or rights from you under this License. If your rights have been terminated and not permanently reinstated, you do not qualify to receive new licenses for the same material under section 10. 9. Acceptance Not Required for Having Copies. You are not required to accept this License in order to receive or run a copy of the Program. Ancillary propagation of a covered work occurring solely as a consequence of using peer-to-peer transmission to receive a copy likewise does not require acceptance. However, nothing other than this License grants you permission to propagate or modify any covered work. These actions infringe copyright if you do not accept this License. Therefore, by modifying or propagating a covered work, you indicate your acceptance of this License to do so. 10. Automatic Licensing of Downstream Recipients. Each time you convey a covered work, the recipient automatically receives a license from the original licensors, to run, modify and propagate that work, subject to this License. You are not responsible for enforcing compliance by third parties with this License. An "entity transaction" is a transaction transferring control of an organization, or substantially all assets of one, or subdividing an organization, or merging organizations. If propagation of a covered work results from an entity transaction, each party to that transaction who receives a copy of the work also receives whatever licenses to the work the party's predecessor in interest had or could give under the previous paragraph, plus a right to possession of the Corresponding Source of the work from the predecessor in interest, if the predecessor has it or can get it with reasonable efforts. You may not impose any further restrictions on the exercise of the rights granted or affirmed under this License. For example, you may not impose a license fee, royalty, or other charge for exercise of rights granted under this License, and you may not initiate litigation (including a cross-claim or counterclaim in a lawsuit) alleging that any patent claim is infringed by making, using, selling, offering for sale, or importing the Program or any portion of it. 11. Patents. A "contributor" is a copyright holder who authorizes use under this License of the Program or a work on which the Program is based. The work thus licensed is called the contributor's "contributor version". A contributor's "essential patent claims" are all patent claims owned or controlled by the contributor, whether already acquired or hereafter acquired, that would be infringed by some manner, permitted by this License, of making, using, or selling its contributor version, but do not include claims that would be infringed only as a consequence of further modification of the contributor version. For purposes of this definition, "control" includes the right to grant patent sublicenses in a manner consistent with the requirements of this License. Each contributor grants you a non-exclusive, worldwide, royalty-free patent license under the contributor's essential patent claims, to make, use, sell, offer for sale, import and otherwise run, modify and propagate the contents of its contributor version. In the following three paragraphs, a "patent license" is any express agreement or commitment, however denominated, not to enforce a patent (such as an express permission to practice a patent or covenant not to sue for patent infringement). To "grant" such a patent license to a party means to make such an agreement or commitment not to enforce a patent against the party. If you convey a covered work, knowingly relying on a patent license, and the Corresponding Source of the work is not available for anyone to copy, free of charge and under the terms of this License, through a publicly available network server or other readily accessible means, then you must either (1) cause the Corresponding Source to be so available, or (2) arrange to deprive yourself of the benefit of the patent license for this particular work, or (3) arrange, in a manner consistent with the requirements of this License, to extend the patent license to downstream recipients. "Knowingly relying" means you have actual knowledge that, but for the patent license, your conveying the covered work in a country, or your recipient's use of the covered work in a country, would infringe one or more identifiable patents in that country that you have reason to believe are valid. If, pursuant to or in connection with a single transaction or arrangement, you convey, or propagate by procuring conveyance of, a covered work, and grant a patent license to some of the parties receiving the covered work authorizing them to use, propagate, modify or convey a specific copy of the covered work, then the patent license you grant is automatically extended to all recipients of the covered work and works based on it. A patent license is "discriminatory" if it does not include within the scope of its coverage, prohibits the exercise of, or is conditioned on the non-exercise of one or more of the rights that are specifically granted under this License. You may not convey a covered work if you are a party to an arrangement with a third party that is in the business of distributing software, under which you make payment to the third party based on the extent of your activity of conveying the work, and under which the third party grants, to any of the parties who would receive the covered work from you, a discriminatory patent license (a) in connection with copies of the covered work conveyed by you (or copies made from those copies), or (b) primarily for and in connection with specific products or compilations that contain the covered work, unless you entered into that arrangement, or that patent license was granted, prior to 28 March 2007. Nothing in this License shall be construed as excluding or limiting any implied license or other defenses to infringement that may otherwise be available to you under applicable patent law. 12. No Surrender of Others' Freedom. If conditions are imposed on you (whether by court order, agreement or otherwise) that contradict the conditions of this License, they do not excuse you from the conditions of this License. If you cannot convey a covered work so as to satisfy simultaneously your obligations under this License and any other pertinent obligations, then as a consequence you may not convey it at all. For example, if you agree to terms that obligate you to collect a royalty for further conveying from those to whom you convey the Program, the only way you could satisfy both those terms and this License would be to refrain entirely from conveying the Program. 13. Use with the GNU Affero General Public License. Notwithstanding any other provision of this License, you have permission to link or combine any covered work with a work licensed under version 3 of the GNU Affero General Public License into a single combined work, and to convey the resulting work. The terms of this License will continue to apply to the part which is the covered work, but the special requirements of the GNU Affero General Public License, section 13, concerning interaction through a network will apply to the combination as such. 14. Revised Versions of this License. The Free Software Foundation may publish revised and/or new versions of the GNU General Public License from time to time. Such new versions will be similar in spirit to the present version, but may differ in detail to address new problems or concerns. Each version is given a distinguishing version number. If the Program specifies that a certain numbered version of the GNU General Public License "or any later version" applies to it, you have the option of following the terms and conditions either of that numbered version or of any later version published by the Free Software Foundation. If the Program does not specify a version number of the GNU General Public License, you may choose any version ever published by the Free Software Foundation. If the Program specifies that a proxy can decide which future versions of the GNU General Public License can be used, that proxy's public statement of acceptance of a version permanently authorizes you to choose that version for the Program. Later license versions may give you additional or different permissions. However, no additional obligations are imposed on any author or copyright holder as a result of your choosing to follow a later version. 15. Disclaimer of Warranty. THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION. 16. Limitation of Liability. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. 17. Interpretation of Sections 15 and 16. If the disclaimer of warranty and limitation of liability provided above cannot be given local legal effect according to their terms, reviewing courts shall apply local law that most closely approximates an absolute waiver of all civil liability in connection with the Program, unless a warranty or assumption of liability accompanies a copy of the Program in return for a fee. END OF TERMS AND CONDITIONS How to Apply These Terms to Your New Programs If you develop a new program, and you want it to be of the greatest possible use to the public, the best way to achieve this is to make it free software which everyone can redistribute and change under these terms. To do so, attach the following notices to the program. It is safest to attach them to the start of each source file to most effectively state the exclusion of warranty; and each file should have at least the "copyright" line and a pointer to where the full notice is found. Copyright (C) This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see . Also add information on how to contact you by electronic and paper mail. If the program does terminal interaction, make it output a short notice like this when it starts in an interactive mode: Copyright (C) This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'. This is free software, and you are welcome to redistribute it under certain conditions; type `show c' for details. The hypothetical commands `show w' and `show c' should show the appropriate parts of the General Public License. Of course, your program's commands might be different; for a GUI interface, you would use an "about box". You should also get your employer (if you work as a programmer) or school, if any, to sign a "copyright disclaimer" for the program, if necessary. For more information on this, and how to apply and follow the GNU GPL, see . The GNU General Public License does not permit incorporating your program into proprietary programs. If your program is a subroutine library, you may consider it more useful to permit linking proprietary applications with the library. If this is what you want to do, use the GNU Lesser General Public License instead of this License. But first, please read . spip/spip/ecrire/0000777000000000000000000000000011275530615015151 5ustar adminadministratorsspip/spip/ecrire/inc_version.php0000766000000000000000000004512111236524730020202 0ustar adminadministrators", sans les espaces) // Ne pas les rendre indefinies. # comment on logge, defaut 4 tmp/spip.log de 100k, 0 ou 0 suppriment le log $nombre_de_logs = 4; $taille_des_logs = 100; // Prefixe des tables dans la base de donnees // (a modifier pour avoir plusieurs sites SPIP dans une seule base) $table_prefix = "spip"; // Prefixe des cookies // (a modifier pour installer des sites SPIP dans des sous-repertoires) $cookie_prefix = "spip"; // Dossier des squelettes // (a modifier si l'on veut passer rapidement d'un jeu de squelettes a un autre) $dossier_squelettes = ""; // Pour le javascript, trois modes : parano (-1), prive (0), ok (1) // parano le refuse partout, ok l'accepte partout // le mode par defaut le signale en rouge dans l'espace prive // Si < 1, les fichiers SVG sont traites s'ils emanent d'un redacteur $filtrer_javascript = 0; // PS: dans les forums, petitions, flux syndiques... c'est *toujours* securise // Type d'URLs // 'page': spip.php?article123 [c'est la valeur par defaut pour SPIP 2.0] // 'html': article123.html // 'propres': Titre-de-l-article // 'propres2' : Titre-de-l-article.html (base sur 'propres') // 'arbo' : /article/Titre $type_urls = 'page'; // 'page' => surcharge possible par configuration #la premiere date dans le menu deroulant de date de publication # null: automatiquement (affiche les 8 dernieres annees) # 0: affiche un input libre # 1997: le menu commence a 1997 jusqu'a annee en cours $debut_date_publication = null; // // On note le numero IP du client dans la variable $ip // if (isset($_SERVER['HTTP_X_FORWARDED_FOR'])) $ip = $_SERVER['HTTP_X_FORWARDED_FOR']; if (isset($_SERVER['REMOTE_ADDR'])) $ip = $_SERVER['REMOTE_ADDR']; // Pour renforcer la privacy, decommentez la ligne ci-dessous (ou recopiez-la // dans le fichier config/mes_options) : SPIP ne pourra alors conserver aucun // numero IP, ni temporairement lors des visites (pour gerer les statistiques // ou dans spip.log), ni dans les forums (responsabilite) # $ip = substr(md5($ip),0,16); // faut-il passer les connexions MySQL en mode debug ? $mysql_debug = false; // faut-il faire des connexions completes rappelant le nom du serveur et/ou de // la base MySQL ? (utile si vos squelettes appellent d'autres bases MySQL) // (A desactiver en cas de soucis de connexion chez certains hebergeurs) // Note: un test a l'installation peut aussi avoir desactive // $mysql_rappel_nom_base directement dans le fichier inc_connect $mysql_rappel_connexion = true; $mysql_rappel_nom_base = true; // faut-il afficher en rouge les chaines non traduites ? $test_i18n = false; // faut-il ignorer l'authentification par auth http/remote_user ? $ignore_auth_http = false; $ignore_remote_user = true; # methode obsolete et risquee // Invalider les caches a chaque modification du contenu ? // Si votre site a des problemes de performance face a une charge tres elevee, // vous pouvez mettre cette globale a false (dans mes_options). $derniere_modif_invalide = true; // Quota : la variable $quota_cache, si elle est > 0, indique la taille // totale maximale desiree des fichiers contenus dans le cache ; ce quota n'est // pas "dur" : si le site necessite un espace plus important, il le prend $quota_cache = 10; // // Serveurs externes // # aide en ligne $home_server = 'http://www.spip.net'; $help_server = $home_server . '/aide'; # glossaire pour raccourci [?X]. Aussi: [?X#G] et definir glossaire_G $url_glossaire_externe = "http://@lang@.wikipedia.org/wiki/%s"; # TeX $tex_server = 'http://math.spip.org/tex.php'; # MathML (pas pour l'instant: manque un bon convertisseur) // $mathml_server = 'http://arno.rezo.net/tex2mathml/latex.php'; // Produire du TeX ou du MathML ? $traiter_math = 'tex'; // Appliquer un indenteur XHTML aux espaces public et/ou prive ? $xhtml = false; $xml_indent = false; // Vignettes de previsulation des referers // dans les statistiques // 3 de trouves, possibilite de switcher // - Thumbshots.org: le moins instrusif, quand il n'a pas, il renvoit un pixel vide // - Girafa semble le plus complet, bicoz renvoit toujours la page d'accueil; mais avertissement si pas de preview // - Alexa, equivalent Thumbshots, avec vignettes beaucoup plus grandes mais avertissement si pas de preview // Pour Alexa, penser a indiquer l'url du site dans l'id. // Dans Alexa, si on supprimer size=small, alors vignettes tres grandes $source_vignettes = "http://open.thumbshots.org/image.pxf?url=http://"; // $source_vignettes = "http://msnsearch.srv.girafa.com/srv/i?s=MSNSEARCH&r=http://"; // $source_vignettes = "http://pthumbnails.alexa.com/image_server.cgi?id=www.monsite.net&size=small&url=http://"; $formats_logos = array ('gif', 'jpg', 'png'); // Controler les dates des item dans les flux RSS ? $controler_dates_rss = true; // bardee de variables de personnalisation pour la typo (cf inc/texte) // class_spip : savoir si on veut class="spip" sur p i strong & li // class_spip_plus : class="spip" sur les ul ol h3 hr quote table... // la difference c'est que des css specifiques existent pour les seconds // $class_spip = ''; /*' class="spip"'*/ $class_spip_plus = ' class="spip"'; $toujours_paragrapher = true; $ligne_horizontale = "\n\n"; $debut_intertitre = "\n"; $fin_intertitre = "\n"; $debut_gras = ""; $fin_gras = ''; $debut_italique = ""; $fin_italique = ''; $ouvre_ref = ' ['; $ferme_ref = ']'; $ouvre_note = '['; $ferme_note = '] '; $les_notes = ''; $compt_note = 0; $notes_vues = array(); // // Pipelines & plugins // # les pipeline standards (traitements derivables aka points d'entree) # ils seront compiles par la suite # note: un pipeline non reference se compile aussi, mais uniquement # lorsqu'il est rencontre // http://doc.spip.org/@Tuto-Se-servir-des-points-d-entree $spip_pipeline = array( 'accueil_encours' => '', 'accueil_gadgets' => '', 'accueil_informations' => '', # cf. public/assembler 'affichage_final' => '|f_surligne|f_tidy|f_admin|f_msie', 'affiche_droite' => '', 'affiche_gauche' => '', 'affiche_milieu' => '', 'affiche_enfants' => '', 'affiche_hierarchie' => '', 'boite_infos' => 'f_boite_infos', 'ajouter_boutons' => '', 'ajouter_onglets' => '', 'body_prive' => '', 'declarer_tables_interfaces'=>'', 'declarer_tables_principales'=>'', 'declarer_tables_auxiliaires'=>'', 'declarer_tables_objets_surnoms' => '', 'definir_session' => '', 'delete_all' => '', 'delete_statistiques' => '', 'exec_init' => '', 'formulaire_charger' => '', 'formulaire_verifier' => '', 'formulaire_traiter' => '', 'header_prive' => '|f_jQuery||compacte_head', 'insert_head' => '|f_jQuery', 'jquery_plugins' => '', # 'insert_js' => '', 'lister_tables_noexport' => '', 'libelle_association_mots' => '', # 'verifie_js_necessaire' => '', 'mots_indexation' => '', 'nettoyer_raccourcis_typo' => '', 'pre_boucle' => '', 'post_boucle' => '', 'pre_propre' => '|extraire_multi|traiter_poesie|traiter_retours_chariots', 'pre_liens' => '|traiter_raccourci_liens|traiter_raccourci_glossaire |traiter_raccourci_ancre', 'post_propre' => '', 'pre_typo' => '|extraire_multi', 'post_typo' => '|quote_amp', 'pre_edition' => '|premiere_revision', 'post_edition' => '|nouvelle_revision', 'pre_syndication' => '', 'post_syndication' => '', 'pre_indexation' => '', 'requete_dico' => '', 'agenda_rendu_evenement' => '', 'taches_generales_cron' => '', 'calculer_rubriques' => '', 'autoriser' => '', 'notifications' => '', 'afficher_contenu_objet' => '', 'afficher_revision_objet'=>'', 'editer_contenu_objet' => '', 'creer_chaine_url' => '|creer_chaine_url', 'rechercher_liste_des_champs' => '', 'rechercher_liste_des_jointures' => '', 'recuperer_fond' => '', 'styliser' => '', 'trig_calculer_prochain_postdate' => '', 'trig_propager_les_secteurs' => '', ); # la matrice standard (fichiers definissant les fonctions a inclure) $spip_matrice = array (); # les plugins a activer $plugins = array(); // voir le contenu du repertoire /plugins/ # les surcharges de include_spip() $surcharges = array(); // format 'inc_truc' => '/plugins/chose/inc_truc2.php' // Variables du compilateur de squelettes $exceptions_des_tables = array(); $tables_principales = array(); $table_des_tables = array(); $tables_auxiliaires = array(); $table_primary = array(); $table_date = array(); $table_titre = array(); $tables_jointures = array(); // Liste des statuts. $liste_des_statuts = array( "info_administrateurs" => '0minirezo', "info_redacteurs" =>'1comite', "info_visiteurs" => '6forum', "info_statut_site_4" => '5poubelle' ); $liste_des_etats = array( 'texte_statut_en_cours_redaction' => 'prepa', 'texte_statut_propose_evaluation' => 'prop', 'texte_statut_publie' => 'publie', 'texte_statut_poubelle' => 'poubelle', 'texte_statut_refuse' => 'refuse' ); $liste_des_forums = array( 'bouton_radio_modere_posteriori' => 'pos', 'bouton_radio_modere_priori' => 'pri', 'bouton_radio_modere_abonnement' => 'abo', 'info_pas_de_forum' => 'non' ); // liste des methodes d'authentifications $liste_des_authentifications = array( 'spip'=>'spip', 'ldap'=>'ldap' ); // Experimental : pour supprimer systematiquement l'affichage des numeros // de classement des titres, recopier la ligne suivante dans mes_options : # $table_des_traitements['TITRE'][]= 'typo(supprimer_numero(%s))'; // Droits d'acces maximum par defaut @umask(0); // numero de branche, utilise par les plugins // pour specifier les versions de SPIP necessaire // il faut s'en tenir a un nombre de decimales fixe ex : 2.0.0, 2.0.0-dev, 2.0.0-beta, 2.0.0-beta2 $spip_version_branche = "2.0.9"; // version des signatures de fonctions PHP // (= numero SVN de leur derniere modif cassant la compatibilite et/ou necessitant un recalcul des squelettes) $spip_version_code = 12691; // version de la base SQL (= numero SVN de sa derniere modif, a verifier dans le fichier ecrire/maj/sv10000.php) $spip_version_base = 14272; // version de l'interface a la base $spip_sql_version = 1; // version de spip en chaine // 1.xxyy : xx00 versions stables publiees, xxyy versions de dev // (ce qui marche pour yy ne marchera pas forcement sur une version plus ancienne) $spip_version_affichee = "$spip_version_branche"; // ** Securite ** $visiteur_session = $auteur_session = $connect_statut = $connect_toutes_rubriques = $hash_recherche = $hash_recherche_strict = $ldap_present =''; $meta = $connect_id_rubrique = array(); // *** Fin des globales *** // // // Charger les fonctions liees aux serveurs Http et Sql. // require_once _DIR_RESTREINT . 'inc/utils.php'; require_once _DIR_RESTREINT . 'base/connect_sql.php'; // Definition personnelles eventuelles if (_FILE_OPTIONS) include_once _FILE_OPTIONS; // Masquer les warning define('SPIP_ERREUR_REPORT',E_ALL ^ E_NOTICE); define('SPIP_ERREUR_REPORT_INCLUDE_PLUGINS',0); error_reporting(SPIP_ERREUR_REPORT); // Initialisations critiques non surchargeables par les plugins // INITIALISER LES REPERTOIRES NON PARTAGEABLES ET LES CONSTANTES // (charge aussi inc/flock) // // mais l'inclusion precedente a peut-etre deja appele cette fonction // ou a defini certaines des constantes que cette fonction doit definir // ===> on execute en neutralisant les messages d'erreur @spip_initialisation_core( (_DIR_RACINE . _NOM_PERMANENTS_INACCESSIBLES), (_DIR_RACINE . _NOM_PERMANENTS_ACCESSIBLES), (_DIR_RACINE . _NOM_TEMPORAIRES_INACCESSIBLES), (_DIR_RACINE . _NOM_TEMPORAIRES_ACCESSIBLES) ); // chargement des plugins : doit arriver en dernier // car dans les plugins on peut inclure inc-version // qui ne sera pas execute car _ECRIRE_INC_VERSION est defini // donc il faut avoir tout fini ici avant de charger les plugins if (@is_readable(_DIR_TMP."charger_plugins_options.php")){ // chargement optimise precompile include_once(_DIR_TMP."charger_plugins_options.php"); } else { @spip_initialisation_suite(); include_spip('inc/plugin'); // generer les fichiers php precompiles // de chargement des plugins et des pipelines if (verif_plugin()) { if (@is_readable(_DIR_TMP."charger_plugins_options.php")) include_once(_DIR_TMP."charger_plugins_options.php"); else spip_log("generation de charger_plugins_options.php impossible; pipeline desactives"); } } // Initialisations non critiques surchargeables par les plugins @spip_initialisation_suite(); if (!defined('_OUTILS_DEVELOPPEURS')) define('_OUTILS_DEVELOPPEURS',false); // charger systematiquement inc/autoriser dans l'espace restreint if (test_espace_prive()) include_spip('inc/autoriser'); // // Installer Spip si pas installe... sauf si justement on est en train // if (!(_FILE_CONNECT OR autoriser_sans_cookie(_request('exec')) OR _request('action') == 'cookie' OR _request('action') == 'converser' OR _request('action') == 'test_dirs')) { // Si on peut installer, on lance illico if (test_espace_prive()) { include_spip('inc/headers'); redirige_url_ecrire("install"); } else { // Si on est dans le site public, dire que qq s'en occupe include_spip('inc/minipres'); utiliser_langue_visiteur(); echo minipres(_T('info_travaux_titre'), "

    "._T('info_travaux_texte')."

    "); exit; } // autrement c'est une install ad hoc (spikini...), on sait pas faire } // // Reglage de l'output buffering : si possible, generer une sortie // compressee pour economiser de la bande passante ; sauf dans l'espace // prive car sinon ca rame a l'affichage (a revoir...) // @header("Vary: Cookie, Accept-Encoding"); // si un buffer est deja ouvert, stop if (!test_espace_prive() AND $flag_ob AND strlen(ob_get_contents())==0 AND !headers_sent()) { if ( $GLOBALS['meta']['auto_compress_http'] == 'oui' // special bug de proxy AND !(isset($_SERVER['HTTP_VIA']) AND preg_match(",NetCache|Hasd_proxy,i", $_SERVER['HTTP_VIA'])) // special bug Netscape Win 4.0x AND (strpos($_SERVER['HTTP_USER_AGENT'], 'Mozilla/4.0') === false) // special bug Apache2x #&& !preg_match(",Apache(-[^ ]+)?/2,i", $_SERVER['SERVER_SOFTWARE']) // test suspendu: http://article.gmane.org/gmane.comp.web.spip.devel/32038/ #&& !($GLOBALS['flag_sapi_name'] AND preg_match(",^apache2,", @php_sapi_name())) // si la compression est deja commencee, stop # && !@ini_get("zlib.output_compression") AND !@ini_get("output_handler") AND !isset($_GET['var_mode']) # bug avec le debugueur qui appelle ob_end_clean() ) ob_start('ob_gzhandler'); } // Vanter notre art de la composition typographique // La globale $spip_header_silencieux permet de rendre le header minimal pour raisons de securite define('_HEADER_COMPOSED_BY', "Composed-By: SPIP"); if (!headers_sent()) if (!isset($GLOBALS['spip_header_silencieux']) OR !$GLOBALS['spip_header_silencieux']) @header(_HEADER_COMPOSED_BY . " $spip_version_affichee @ www.spip.net" . (isset($GLOBALS['meta']['plugin_header'])?(" + ".$GLOBALS['meta']['plugin_header']):"")); else // header minimal @header(_HEADER_COMPOSED_BY . " @ www.spip.net"); # spip_log($_SERVER['REQUEST_METHOD'].' '.self() . ' - '._FILE_CONNECT); ?> spip/spip/ecrire/charsets/0000777000000000000000000000000011266531714016766 5ustar adminadministratorsspip/spip/ecrire/charsets/iso-8859-6.php0000766000000000000000000000330211236524730021043 0ustar adminadministrators0x00A0, 0xA4=>0x00A4, 0xAC=>0x060C, 0xAD=>0x00AD, 0xBB=>0x061B, 0xBF=>0x061F, 0xC1=>0x0621, 0xC2=>0x0622, 0xC3=>0x0623, 0xC4=>0x0624, 0xC5=>0x0625, 0xC6=>0x0626, 0xC7=>0x0627, 0xC8=>0x0628, 0xC9=>0x0629, 0xCA=>0x062A, 0xCB=>0x062B, 0xCC=>0x062C, 0xCD=>0x062D, 0xCE=>0x062E, 0xCF=>0x062F, 0xD0=>0x0630, 0xD1=>0x0631, 0xD2=>0x0632, 0xD3=>0x0633, 0xD4=>0x0634, 0xD5=>0x0635, 0xD6=>0x0636, 0xD7=>0x0637, 0xD8=>0x0638, 0xD9=>0x0639, 0xDA=>0x063A, 0xE0=>0x0640, 0xE1=>0x0641, 0xE2=>0x0642, 0xE3=>0x0643, 0xE4=>0x0644, 0xE5=>0x0645, 0xE6=>0x0646, 0xE7=>0x0647, 0xE8=>0x0648, 0xE9=>0x0649, 0xEA=>0x064A, 0xEB=>0x064B, 0xEC=>0x064C, 0xED=>0x064D, 0xEE=>0x064E, 0xEF=>0x064F, 0xF0=>0x0650, 0xF1=>0x0651, 0xF2=>0x0652 ); foreach ($mod as $num=>$val) $trans[$num]=$val; $GLOBALS['CHARSET']['iso-8859-6'] = $trans; ?> spip/spip/ecrire/charsets/iso-8859-9.php0000766000000000000000000000205411236524730021051 0ustar adminadministrators load_charset('iso-8859-1'); $trans = $GLOBALS['CHARSET']['iso-8859-1']; $trans[240]=287; //gbreve $trans[208]=286; //Gbreve $trans[221]=304; //Idot $trans[253]=305; //inodot $trans[254]=351; //scedil $trans[222]=350; //Scedil $GLOBALS['CHARSET']['iso-8859-9'] = $trans; ?> spip/spip/ecrire/charsets/translit.php0000766000000000000000000001003211236524730021331 0ustar adminadministrators'EUR', 131=>'f', 140=>'OE', 147=>'\'\'', 148=>'\'\'', 153=>'(TM)', 156=>'oe', 159=>'Y', // latin [legal] 160=>' ', 161=>'!', 162=>'c', 163=>'L', 164=>'O', 165=>'yen',166=>'|', 167=>'p',169=>'(c)', 171=>'<<',172=>'-',173=>'-',174=>'(R)', 176=>'o',177=>'+-',181=>'mu',182=>'p',183=>'.',186=>'o ',187=>'>>', 191=>'?', 192=>'A', 193=>'A', 194=>'A', 195=>'A', 196=>'A', 197=>'A', 198=>'AE', 199=>'C', 200=>'E', 201=>'E', 202=>'E', 203=>'E', 204=>'I', 205=>'I', 206=>'I', 207=>'I', 209=>'N', 210=>'O', 211=>'O', 212=>'O', 213=>'O', 214=>'O', 216=>'O', 217=>'U', 218=>'U', 219=>'U', 220=>'U', 223=>'ss', 224=>'a', 225=>'a', 226=>'a', 227=>'a', 228=>'a', 229=>'a', 230=>'ae', 231=>'c', 232=>'e', 233=>'e', 234=>'e', 235=>'e', 236=>'i', 237=>'i', 238=>'i', 239=>'i', 241=>'n', 242=>'o', 243=>'o', 244=>'o', 245=>'o', 246=>'o', 248=>'o', 249=>'u', 250=>'u', 251=>'u', 252=>'u', 255=>'y', // turc 286=>'G', 287=>'g', 304=>'I', 305=>'i', 350=>'S', 351=>'s', // esperanto 264 => 'Cx',265 => 'cx', 284 => 'Gx',285 => 'gx', 292 => 'Hx',293 => 'hx', 308 => 'Jx',309 => 'jx', 348 => 'Sx',349 => 'sx', 364 => 'Ux',365 => 'ux', // latin2 [Czech] 283=>'e', 353=>'s', 269=>'c', 345=>'r', 382=>'z', 367=>'u', 328=>'n', 357=>'t', 271=>'d', 449=>'o', 282=>'E', 352=>'S', 268=>'C', 344=>'R', 381=>'Z', 366=>'U', 327=>'N', 356=>'T', 270=>'D', 467=>'O', // francais 338=>'OE', 339=>'oe', 376=>'Y', 402=>'f', //polskie 260=>'A', 261=>'a', 262=>'C', 263=>'c', 280=>'E', 281=>'e', 321=>'L', 322=>'l', 323=>'N', 324=>'n', 346=>'S', 347=>'s', 377=>'Z', 378=>'z', 379=>'Z', 380=>'z', //roumain 258=>'A', 259=>'a', 350=>'S', 351=>'s', 354=>'T', 355=>'t', // cyrillique 1026=>'D%', 1027=>'G%', 8218=>'\'', 1107=>'g%', 8222=>'"', 8230=>'...', 8224=>'/-', 8225=>'/=', 8364=>'EUR', 8240=>'0/00', 1033=>'LJ', 8249=>'<', 1034=>'NJ', 1036=>'KJ', 1035=>'Ts', 1039=>'DZ', 1106=>'d%', 8216=>'`', 8217=>'\'', 8220=>'"', 8221=>'"', 8226=>' o ', 8211=>'-', 8212=>'--', 8212=>'~', 8482=>'(TM)', 1113=>'lj', 8250=>'>', 1114=>'nj', 1116=>'kj', 1115=>'ts', 1119=>'dz', 1038=>'V%', 1118=>'v%', 1032=>'J%', 1168=>'G3', 1025=>'IO', 1028=>'IE', 1031=>'YI', 1030=>'II', 1110=>'ii', 1169=>'g3', 1105=>'io', 8470=>'No.', 1108=>'ie', 1112=>'j%', 1029=>'DS', 1109=>'ds', 1111=>'yi', 1040=>'A', 1041=>'B', 1042=>'V', 1043=>'G', 1044=>'D', 1045=>'E', 1046=>'ZH', 1047=>'Z', 1048=>'I', 1049=>'J', 1050=>'K', 1051=>'L', 1052=>'M', 1053=>'N', 1054=>'O', 1055=>'P', 1056=>'R', 1057=>'S', 1058=>'T', 1059=>'U', 1060=>'F', 1061=>'H', 1062=>'C', 1063=>'CH', 1064=>'SH', 1065=>'SCH', 1066=>'"', 1067=>'Y', 1068=>'\'', 1069=>'`E', 1070=>'YU', 1071=>'YA', 1072=>'a', 1073=>'b', 1074=>'v', 1075=>'g', 1076=>'d', 1077=>'e', 1078=>'zh', 1079=>'z', 1080=>'i', 1081=>'j', 1082=>'k', 1083=>'l', 1084=>'m', 1085=>'n', 1086=>'o', 1087=>'p', 1088=>'r', 1089=>'s', 1090=>'t', 1091=>'u', 1092=>'f', 1093=>'h', 1094=>'c', 1095=>'ch', 1096=>'sh', 1097=>'sch', 1098=>'"', 1099=>'y', 1100=>'\'', 1101=>'`e', 1102=>'yu', 1103=>'ya', // vietnamien en translitteration de base 7843=>"a",7841=>"a",7845=>"a",7847=>"a",7849=>"a",7851=>"a",7853=>"a", 7855=>"a",7857=>"a",7859=>"a",7861=>"a",7863=>"a", 7842=>"A",7840=>"A",7844=>"A",7846=>"A",7848=>"A", 7850=>"A",7852=>"A",7854=>"A",7856=>"A",7858=>"A",7860=>"A", 7862=>"A",7867=>"e",7869=>"e",7865=>"e", 7871=>"e",7873=>"e",7875=>"e",7877=>"e",7879=>"e", 7866=>"E",7868=>"E",7864=>"E",7870=>"E",7872=>"E",7874=>"E", 7876=>"E",7878=>"E",7881=>"i",7883=>"i", 7880=>"I",7882=>"I", 7887=>"o",7885=>"o",7889=>"o",7891=>"o",7893=>"o", 7895=>"o",7897=>"o",417=>"o",7899=>"o",7901=>"o",7903=>"o",7905=>"o", 7907=>"o",7886=>"O",7884=>"O", 7888=>"O",7890=>"O",7892=>"O",7894=>"O",7896=>"O",416=>"O",7898=>"O", 7900=>"O",7902=>"O",7904=>"O",7906=>"O",7911=>"u", 361=>"u",7909=>"u",432=>"u",7913=>"u",7915=>"u",7917=>"u",7919=>"u", 7921=>"u",7910=>"U",360=>"U",7908=>"U",431=>"U", 7912=>"U",7914=>"U",7916=>"U",7918=>"U",7920=>"U",253=>"y",7923=>"y", 7927=>"y",7929=>"y",7925=>"y",221=>"Y",7922=>"Y",7926=>"Y",7928=>"Y", 7924=>"Y",273=>"d" ); ?> spip/spip/ecrire/charsets/iso-8859-1.php0000766000000000000000000000311711236524730021042 0ustar adminadministrators8364, 129=>129 /* ?? */, 130=>8218, 131=>402, 132=>8222, 133=>8230, 134=>8224, 135=>8225, 136=>710, 137=>8240, 138=>352, 139=>8249, 140=>338, 141=>141 /* ?? */, 142=>381, 143=>143 /* ?? */, 144=>144 /* ?? */, 145=>8216, 146=>8217, 147=>8220, 148=>8221, 149=>8226, 150=>8211, 151=>8212, 152=>732, 153=>8482, 154=>353, 155=>8250, 156=>339, 157=>157 /* ?? */, 158=>382, 159=>376, 160=>160, 161=>161, 162=>162, 163=>163, 164=>164, 165=>165, 166=>166, 167=>167, 168=>168, 169=>169, 170=>170, 171=>171, 172=>172, 173=>173, 174=>174, 175=>175, 176=>176, 177=>177, 178=>178, 179=>179, 180=>180, 181=>181, 182=>182, 183=>183, 184=>184, 185=>185, 186=>186, 187=>187, 188=>188, 189=>189, 190=>190, 191=>191, 192=>192, 193=>193, 194=>194, 195=>195, 196=>196, 197=>197, 198=>198, 199=>199, 200=>200, 201=>201, 202=>202, 203=>203, 204=>204, 205=>205, 206=>206, 207=>207, 208=>208, 209=>209, 210=>210, 211=>211, 212=>212, 213=>213, 214=>214, 215=>215, 216=>216, 217=>217, 218=>218, 219=>219, 220=>220, 221=>221, 222=>222, 223=>223, 224=>224, 225=>225, 226=>226, 227=>227, 228=>228, 229=>229, 230=>230, 231=>231, 232=>232, 233=>233, 234=>234, 235=>235, 236=>236, 237=>237, 238=>238, 239=>239, 240=>240, 241=>241, 242=>242, 243=>243, 244=>244, 245=>245, 246=>246, 247=>247, 248=>248, 249=>249, 250=>250, 251=>251, 252=>252, 253=>253, 254=>254, 255=>255 ); ?> spip/spip/ecrire/charsets/cp1251.php0000766000000000000000000000354511236524730020417 0ustar adminadministrators0x0402, 0x81=>0x0403, 0x82=>0x201A, 0x83=>0x0453, 0x84=>0x201E, 0x85=>0x2026, 0x86=>0x2020, 0x87=>0x2021, 0x88=>0x20AC, 0x89=>0x2030, 0x8A=>0x0409, 0x8B=>0x2039, 0x8C=>0x040A, 0x8D=>0x040C, 0x8E=>0x040B, 0x8F=>0x040F, 0x90=>0x0452, 0x91=>0x2018, 0x92=>0x2019, 0x93=>0x201C, 0x94=>0x201D, 0x95=>0x2022, 0x96=>0x2013, 0x97=>0x2014, 0x99=>0x2122, 0x9A=>0x0459, 0x9B=>0x203A, 0x9C=>0x045A, 0x9D=>0x045C, 0x9E=>0x045B, 0x9F=>0x045F, 0xA0=>0x00A0, 0xA1=>0x040E, 0xA2=>0x045E, 0xA3=>0x0408, 0xA4=>0x00A4, 0xA5=>0x0490, 0xA6=>0x00A6, 0xA7=>0x00A7, 0xA8=>0x0401, 0xA9=>0x00A9, 0xAA=>0x0404, 0xAB=>0x00AB, 0xAC=>0x00AC, 0xAD=>0x00AD, 0xAE=>0x00AE, 0xAF=>0x0407, 0xB0=>0x00B0, 0xB1=>0x00B1, 0xB2=>0x0406, 0xB3=>0x0456, 0xB4=>0x0491, 0xB5=>0x00B5, 0xB6=>0x00B6, 0xB7=>0x00B7, 0xB8=>0x0451, 0xB9=>0x2116, 0xBA=>0x0454, 0xBB=>0x00BB, 0xBC=>0x0458, 0xBD=>0x0405, 0xBE=>0x0455, 0xBF=>0x0457, 0xC0=>0x0410, 0xC1=>0x0411, 0xC2=>0x0412, 0xC3=>0x0413, 0xC4=>0x0414, 0xC5=>0x0415, 0xC6=>0x0416, 0xC7=>0x0417, 0xC8=>0x0418, 0xC9=>0x0419, 0xCA=>0x041A, 0xCB=>0x041B, 0xCC=>0x041C, 0xCD=>0x041D, 0xCE=>0x041E, 0xCF=>0x041F, 0xD0=>0x0420, 0xD1=>0x0421, 0xD2=>0x0422, 0xD3=>0x0423, 0xD4=>0x0424, 0xD5=>0x0425, 0xD6=>0x0426, 0xD7=>0x0427, 0xD8=>0x0428, 0xD9=>0x0429, 0xDA=>0x042A, 0xDB=>0x042B, 0xDC=>0x042C, 0xDD=>0x042D, 0xDE=>0x042E, 0xDF=>0x042F, 0xE0=>0x0430, 0xE1=>0x0431, 0xE2=>0x0432, 0xE3=>0x0433, 0xE4=>0x0434, 0xE5=>0x0435, 0xE6=>0x0436, 0xE7=>0x0437, 0xE8=>0x0438, 0xE9=>0x0439, 0xEA=>0x043A, 0xEB=>0x043B, 0xEC=>0x043C, 0xED=>0x043D, 0xEE=>0x043E, 0xEF=>0x043F, 0xF0=>0x0440, 0xF1=>0x0441, 0xF2=>0x0442, 0xF3=>0x0443, 0xF4=>0x0444, 0xF5=>0x0445, 0xF6=>0x0446, 0xF7=>0x0447, 0xF8=>0x0448, 0xF9=>0x0449, 0xFA=>0x044A, 0xFB=>0x044B, 0xFC=>0x044C, 0xFD=>0x044D, 0xFE=>0x044E, 0xFF=>0x044F); ?> spip/spip/ecrire/charsets/index.php0000766000000000000000000000000211236524730020574 0ustar adminadministratorsX spip/spip/ecrire/charsets/translitcomplexe.php0000766000000000000000000000501711236524730023075 0ustar adminadministrators"a'", 224=>"a`",7843=>"a?",227=>"a~",7841=>"a.", 226=>"a^",7845=>"a^'",7847=>"a^`",7849=>"a^?",7851=>"a^~",7853=>"a^.",259=>"a(", 7855=>"a('",7857=>"a(`",7859=>"a(?",7861=>"a(~",7863=>"a(.",193=>"A'",192=>"A`", 7842=>"A?",195=>"A~",7840=>"A.",194=>"A^",7844=>"A^'",7846=>"A^`",7848=>"A^?", 7850=>"A^~",7852=>"A^.",258=>"A(",7854=>"A('",7856=>"A(`",7858=>"A(?",7860=>"A(~", 7862=>"A(.",233=>"e'",232=>"e`",7867=>"e?",7869=>"e~",7865=>"e.",234=>"e^", 7871=>"e^'",7873=>"e^`",7875=>"e^?",7877=>"e^~",7879=>"e^.",201=>"E'",200=>"E`", 7866=>"E?",7868=>"E~",7864=>"E.",202=>"E^",7870=>"E^'",7872=>"E^`",7874=>"E^?", 7876=>"E^~",7878=>"E^.",237=>"i'",236=>"i`",7881=>"i?",297=>"i~",7883=>"i.", 205=>"I'",204=>"I`",7880=>"I?",296=>"I~",7882=>"I.",243=>"o'",242=>"o`", 7887=>"o?",245=>"o~",7885=>"o.",244=>"o^",7889=>"o^'",7891=>"o^`",7893=>"o^?", 7895=>"o^~",7897=>"o^.",417=>"o+",7899=>"o+'",7901=>"o+`",7903=>"o+?",7905=>"o+~", 7907=>"o+.",211=>"O'",210=>"O`",7886=>"O?",213=>"O~",7884=>"O.",212=>"O^", 7888=>"O^'",7890=>"O^`",7892=>"O^?",7894=>"O^~",7896=>"O^.",416=>"O+",7898=>"O+'", 7900=>"O+`",7902=>"O+?",7904=>"O+~",7906=>"O+.",250=>"u'",249=>"u`",7911=>"u?", 361=>"u~",7909=>"u.",432=>"u+",7913=>"u+'",7915=>"u+`",7917=>"u+?",7919=>"u+~", 7921=>"u+.",218=>"U'",217=>"U`",7910=>"U?",360=>"U~",7908=>"U.",431=>"U+", 7912=>"U+'",7914=>"U+`",7916=>"U+?",7918=>"U+~",7920=>"U+.",253=>"y'",7923=>"y`", 7927=>"y?",7929=>"y~",7925=>"y.",221=>"Y'",7922=>"Y`",7926=>"Y?",7928=>"Y~", 7924=>"Y.",273=>"d-",208=>"D-", // allemand 228=>'ae',246=>'oe',252=>'ue',196=>'Ae',214=>'Oe',220=>'Ue' ); foreach($translit_c as $u=>$t) $trans[$u] = $t; $GLOBALS['CHARSET']['translitcomplexe'] = $trans; ?> spip/spip/ecrire/charsets/cp1250.php0000766000000000000000000000412311236524730020407 0ustar adminadministrators 0x20AC, 0x82 => 0x201A, 0x84 => 0x201E, 0x85 => 0x2026, 0x86 => 0x2020, 0x87 => 0x2021, 0x89 => 0x2030, 0x8A => 0x0160, 0x8B => 0x2039, 0x8C => 0x015A, 0x8D => 0x0164, 0x8E => 0x017D, 0x8F => 0x0179, 0x91 => 0x2018, 0x92 => 0x2019, 0x93 => 0x201C, 0x94 => 0x201D, 0x95 => 0x2022, 0x96 => 0x2013, 0x97 => 0x2014, 0x99 => 0x2122, 0x9A => 0x0161, 0x9B => 0x203A, 0x9C => 0x015B, 0x9D => 0x0165, 0x9E => 0x017E, 0x9F => 0x017A, 0xA0 => 0x00A0, 0xA1 => 0x02C7, 0xA2 => 0x02D8, 0xA3 => 0x0141, 0xA4 => 0x00A4, 0xA5 => 0x0104, 0xA6 => 0x00A6, 0xA7 => 0x00A7, 0xA8 => 0x00A8, 0xA9 => 0x00A9, 0xAA => 0x015E, 0xAB => 0x00AB, 0xAC => 0x00AC, 0xAD => 0x00AD, 0xAE => 0x00AE, 0xAF => 0x017B, 0xB0 => 0x00B0, 0xB1 => 0x00B1, 0xB2 => 0x02DB, 0xB3 => 0x0142, 0xB4 => 0x00B4, 0xB5 => 0x00B5, 0xB6 => 0x00B6, 0xB7 => 0x00B7, 0xB8 => 0x00B8, 0xB9 => 0x0105, 0xBA => 0x015F, 0xBB => 0x00BB, 0xBC => 0x013D, 0xBD => 0x02DD, 0xBE => 0x013E, 0xBF => 0x017C, 0xC0 => 0x0154, 0xC1 => 0x00C1, 0xC2 => 0x00C2, 0xC3 => 0x0102, 0xC4 => 0x00C4, 0xC5 => 0x0139, 0xC6 => 0x0106, 0xC7 => 0x00C7, 0xC8 => 0x010C, 0xC9 => 0x00C9, 0xCA => 0x0118, 0xCB => 0x00CB, 0xCC => 0x011A, 0xCD => 0x00CD, 0xCE => 0x00CE, 0xCF => 0x010E, 0xD0 => 0x0110, 0xD1 => 0x0143, 0xD2 => 0x0147, 0xD3 => 0x00D3, 0xD4 => 0x00D4, 0xD5 => 0x0150, 0xD6 => 0x00D6, 0xD7 => 0x00D7, 0xD8 => 0x0158, 0xD9 => 0x016E, 0xDA => 0x00DA, 0xDB => 0x0170, 0xDC => 0x00DC, 0xDD => 0x00DD, 0xDE => 0x0162, 0xDF => 0x00DF, 0xE0 => 0x0155, 0xE1 => 0x00E1, 0xE2 => 0x00E2, 0xE3 => 0x0103, 0xE4 => 0x00E4, 0xE5 => 0x013A, 0xE6 => 0x0107, 0xE7 => 0x00E7, 0xE8 => 0x010D, 0xE9 => 0x00E9, 0xEA => 0x0119, 0xEB => 0x00EB, 0xEC => 0x011B, 0xED => 0x00ED, 0xEE => 0x00EE, 0xEF => 0x010F, 0xF0 => 0x0111, 0xF1 => 0x0144, 0xF2 => 0x0148, 0xF3 => 0x00F3, 0xF4 => 0x00F4, 0xF5 => 0x0151, 0xF6 => 0x00F6, 0xF7 => 0x00F7, 0xF8 => 0x0159, 0xF9 => 0x016F, 0xFA => 0x00FA, 0xFB => 0x0171, 0xFC => 0x00FC, 0xFD => 0x00FD, 0xFE => 0x0163, 0xFF => 0x02D9 ); ?> spip/spip/ecrire/charsets/mathml.php0000766000000000000000000012124311236524730020762 0ustar adminadministrators '', 'acd' => '', 'acE' => '&E#290;', 'acute' => '́', 'Afr' => '', 'afr' => '', 'aleph' => 'ℵ', 'alpha' => 'α', 'amalg' => '', 'amp' => '&', 'And' => '∧', 'and' => '∧', 'andand' => '', 'andd' => '', 'andslope' => '', 'andv' => '', 'ang' => '∠', 'ange' => '', 'angle' => '∠', 'angmsd' => '∡', 'angmsdaa' => '', 'angmsdab' => '', 'angmsdac' => '', 'angmsdad' => '', 'angmsdae' => '', 'angmsdaf' => '', 'angmsdag' => '', 'angmsdah' => '', 'angrt' => '∟', 'angrtvb' => '', 'angrtvbd' => '', 'angsph' => '∢', 'angst' => 'Å', 'angzarr' => '', 'Aopf' => '', 'ap' => '≈', 'apacir' => '', 'apE' => '', 'ape' => '≊', 'apid' => '≋', 'apos' => ''', 'approx' => '≈', 'approxeq' => '≊', 'Ascr' => '', 'ascr' => '', 'ast' => '∗', 'asymp' => '≍', 'awconint' => '∳', 'awint' => '', 'backcong' => '≌', 'backepsilon' => '', 'backprime' => '‵', 'backsim' => '∽', 'backsimeq' => '⋍', 'Backslash' => '∖', 'Barv' => '', 'barvee' => '⊽', 'Barwed' => '⌆', 'barwed' => '⊼', 'barwedge' => '⊼', 'bbrk' => '', 'bbrktbrk' => '', 'bcong' => '≌', 'becaus' => '∵', 'Because' => '∵', 'because' => '∵', 'bemptyv' => '', 'benzen' => '', 'benzena' => '', 'benzenb' => '', 'benzenc' => '', 'benzend' => '', 'benzene' => '', 'benzenf' => '', 'benzeng' => '', 'benzenh' => '', 'benzeni' => '', 'benzenj' => '', 'benzenk' => '', 'benzenl' => '', 'benzenm' => '', 'benzenn' => '', 'benzeno' => '', 'benzenp' => '', 'benzenq' => '', 'benzenr' => '', 'bepsi' => '', 'bernou' => 'ℬ', 'beta' => 'β', 'beth' => 'ℶ', 'between' => '≬', 'Bfr' => '', 'bfr' => '', 'bigcap' => '⋂', 'bigcirc' => '○', 'bigcup' => '⋃', 'bigodot' => '⊙', 'bigoplus' => '⊕', 'bigotimes' => '⊗', 'bigsqcup' => '⊔', 'bigstar' => '★', 'bigtriangledown' => '▽', 'bigtriangleup' => '△', 'biguplus' => '⊎', 'bigvee' => '⋁', 'bigwedge' => '⋀', 'bkarow' => '', 'blacklozenge' => '', 'blacksquare' => '■', 'blacktriangle' => '▴', 'blacktriangledown' => '▾', 'blacktriangleleft' => '◂', 'blacktriangleright' => '▸', 'blank' => '', 'blk12' => '▒', 'blk14' => '░', 'blk34' => '▓', 'block' => '█', 'bne' => '', 'bnequiv' => '', 'bNot' => '', 'bnot' => '⌐', 'Bopf' => '', 'bot' => '⊥', 'bottom' => '⊥', 'bowtie' => '⋈', 'boxbox' => '', 'boxminus' => '⊟', 'boxplus' => '⊞', 'boxtimes' => '⊠', 'bprime' => '‵', 'Breve' => '̆', 'breve' => '̆', 'brvbar' => '¦', 'Bscr' => '', 'bscr' => '', 'bsemi' => '', 'bsim' => '∽', 'bsime' => '⋍', 'bsol' => '\', 'bsolb' => '', 'bsolhsub' => '', 'bull' => '•', 'bullet' => '•', 'bump' => '≎', 'bumpe' => '≏', 'Bumpeq' => '≎', 'bumpeq' => '≏', 'Cap' => '⋒', 'cap' => '∩', 'capand' => '', 'capbrcup' => '', 'capcap' => '', 'capcup' => '', 'capdot' => '', 'caps' => '', 'caret' => '‸', 'caron' => '̌', 'ccaps' => '', 'Cconint' => '∰', 'ccups' => '', 'ccupssm' => '', 'cdot' => '⋅', 'cedil' => '̧', 'Cedilla' => '̧', 'cemptyv' => '', 'cent' => '¢', 'CenterDot' => '·', 'centerdot' => '·', 'Cfr' => '', 'cfr' => '', 'check' => '✓', 'checkmark' => '✓', 'chi' => 'χ', 'cir' => '∘', 'circ' => '∘', 'circeq' => '≗', 'circle' => '', 'circlearrowleft' => '↺', 'circlearrowright' => '↻', 'circledast' => '⊛', 'circledcirc' => '⊚', 'circleddash' => '⊝', 'CircleDot' => '⊙', 'circledR' => '¯', 'circledS' => '', 'circlef' => '●', 'circlefb' => '◒', 'circlefl' => '◐', 'circlefr' => '◑', 'circleft' => '◓', 'CircleMinus' => '⊖', 'CirclePlus' => '⊕', 'CircleTimes' => '⊗', 'cirE' => '', 'cire' => '≗', 'cirfnint' => '', 'cirmid' => '', 'cirscir' => '', 'ClockwiseContourIntegral' => '∲', 'CloseCurlyDoubleQuote' => '”', 'CloseCurlyQuote' => '’', 'clubs' => '♣', 'clubsuit' => '♣', 'Colon' => '∷', 'colon' => ':', 'Colone' => '', 'colone' => '≔', 'coloneq' => '≔', 'comma' => ',', 'commat' => '@', 'comp' => '∁', 'compfn' => '∘', 'complement' => '∁', 'cong' => '≅', 'congdot' => '', 'Congruent' => '≡', 'Conint' => '∯', 'conint' => '∮', 'ContourIntegral' => '∮', 'Copf' => 'ℂ', 'coprod' => '∐', 'Coproduct' => '∐', 'copy' => '©', 'copysr' => '℗', 'CounterClockwiseContourIntegral' => '∳', 'cross' => '☒', 'Cscr' => '', 'cscr' => '', 'csub' => '', 'csube' => '', 'csup' => '', 'csupe' => '', 'ctdot' => '⋯', 'cudarrl' => '', 'cudarrr' => '', 'cuepr' => '⋞', 'cuesc' => '⋟', 'cularr' => '↶', 'cularrp' => '', 'Cup' => '⌣', 'cup' => '∪', 'cupbrcap' => '', 'CupCap' => '≍', 'cupcap' => '', 'cupcup' => '', 'cupdot' => '⊍', 'cupor' => '', 'cups' => '', 'curarr' => '↷', 'curarrm' => '', 'curlyeqprec' => '⋞', 'curlyeqsucc' => '⋟', 'curlyvee' => '⋎', 'curlywedge' => '⋏', 'curren' => '¤', 'curvearrowleft' => '↶', 'curvearrowright' => '↷', 'cuvee' => '⋎', 'cuwed' => '⋏', 'cwconint' => '∲', 'cwint' => '∱', 'cylcty' => '⌭', 'Dagger' => '‡', 'dagger' => '†', 'daleth' => 'ℸ', 'Darr' => '↡', 'dArr' => '⇓', 'darr' => '↓', 'dash' => '‐', 'Dashv' => '', 'dashv' => '⊣', 'dbkarow' => '', 'dblac' => '̋', 'ddagger' => '‡', 'ddarr' => '⇊', 'DDotrahd' => '', 'ddotseq' => '', 'deg' => '°', 'Del' => '∇', 'Delta' => 'Δ', 'delta' => 'δ', 'demptyv' => '', 'dfisht' => '', 'Dfr' => '', 'dfr' => '', 'dHar' => '', 'dharl' => '⇃', 'dharr' => '⇂', 'DiacriticalAcute' => '́', 'DiacriticalDot' => '̇', 'DiacriticalDoubleAcute' => '̋', 'DiacriticalGrave' => '̀', 'DiacriticalLeftArrow' => '⃖', 'DiacriticalLeftRightArrow' => '⃡', 'DiacriticalLeftRightVector' => '', 'DiacriticalLeftVector' => '⃐', 'DiacriticalRightArrow' => '⃗', 'DiacriticalRightVector' => '⃑', 'DiacriticalTilde' => '̃', 'diam' => '⋄', 'diamond' => '⋄', 'diamondf' => '', 'diamondsuit' => '♢', 'diamonfb' => '', 'diamonfl' => '', 'diamonfr' => '', 'diamonft' => '', 'diams' => '♢', 'die' => '̈', 'digamma' => 'Ϝ', 'disin' => '', 'div' => '÷', 'divide' => '÷', 'divideontimes' => '⋇', 'divonx' => '⋇', 'dlcorn' => '⌞', 'dlcrop' => '⌍', 'dollar' => '$', 'Dopf' => '', 'Dot' => '̈', 'dot' => '̇', 'DotDot' => '⃜', 'doteq' => '≐', 'doteqdot' => '≑', 'DotEqual' => '≐', 'dotminus' => '∸', 'dotplus' => '∔', 'dotsquare' => '⊡', 'doublebarwedge' => '⌆', 'DoubleContourIntegral' => '∯', 'DoubleDot' => '̈', 'DoubleDownArrow' => '⇓', 'DoubleLeftArrow' => '⇐', 'DoubleLeftRightArrow' => '⇔', 'DoubleLongLeftArrow' => '', 'DoubleLongLeftRightArrow' => '', 'DoubleLongRightArrow' => '', 'DoubleRightArrow' => '⇒', 'DoubleRightTee' => '⊨', 'DoubleUpArrow' => '⇑', 'DoubleUpDownArrow' => '⇕', 'DoubleVerticalBar' => '∥', 'DownArrow' => '↓', 'Downarrow' => '⇓', 'downarrow' => '↓', 'DownArrowUpArrow' => '', 'downdownarrows' => '⇊', 'downharpoonleft' => '⇃', 'downharpoonright' => '⇂', 'DownLeftVector' => '↽', 'DownRightVector' => '⇁', 'DownTee' => '⊤', 'drbkarow' => '', 'drcorn' => '⌟', 'drcrop' => '⌌', 'Dscr' => '', 'dscr' => '', 'dsol' => '', 'dtdot' => '⋱', 'dtri' => '▿', 'dtrif' => '▾', 'duarr' => '', 'duhar' => '', 'dwangle' => '', 'dzigrarr' => '⇝', 'easter' => '≛', 'ecir' => '≖', 'ecolon' => '≕', 'eDDot' => '', 'eDot' => '≑', 'efDot' => '≒', 'Efr' => '', 'efr' => '', 'eg' => '', 'egs' => '⋝', 'egsdot' => '', 'el' => '', 'Element' => '∈', 'elinters' => '', 'ell' => 'ℓ', 'els' => '⋜', 'elsdot' => '', 'empty' => '', 'emptyset' => '', 'emptyv' => '∅', 'emsp' => ' ', 'emsp13' => ' ', 'emsp14' => ' ', 'ensp' => ' ', 'Eopf' => '', 'epar' => '⋕', 'eparsl' => '', 'eplus' => '', 'epsi' => '∊', 'epsiv' => 'ε', 'eqcirc' => '≖', 'eqcolon' => '≕', 'eqsim' => '≂', 'eqslantgtr' => '⋝', 'eqslantless' => '⋜', 'equals' => '=', 'EqualTilde' => '≂', 'equest' => '≟', 'Equilibrium' => '⇌', 'equiv' => '≡', 'equivDD' => '', 'eqvparsl' => '', 'erarr' => '', 'erDot' => '≓', 'Escr' => '', 'escr' => '', 'esdot' => '≐', 'Esim' => '', 'esim' => '≂', 'eta' => 'η', 'excl' => '!', 'exist' => '∃', 'Exists' => '∃', 'fallingdotseq' => '≒', 'female' => '♀', 'ffilig' => 'ffi', 'fflig' => 'ff', 'ffllig' => 'ffl', 'Ffr' => '', 'ffr' => '', 'filig' => 'fi', 'fjlig' => '', 'flat' => '♭', 'fllig' => 'fl', 'fltns' => '', 'Fopf' => '', 'ForAll' => '∀', 'forall' => '∀', 'fork' => '⋔', 'forkv' => '', 'fpartint' => '', 'frac12' => '½', 'frac13' => '⅓', 'frac14' => '¼', 'frac15' => '⅕', 'frac16' => '⅙', 'frac18' => '⅛', 'frac23' => '≔', 'frac25' => '⅖', 'frac34' => '¾', 'frac35' => '⅗', 'frac38' => '⅜', 'frac45' => '⅘', 'frac56' => '⅚', 'frac58' => '⅝', 'frac78' => '⅞', 'frown' => '⌢', 'Fscr' => '', 'fscr' => '', 'Gamma' => 'Γ', 'gamma' => 'γ', 'Gammad' => 'Ϝ', 'gammad' => 'Ϝ', 'gap' => '≳', 'gE' => '≧', 'ge' => '≥', 'gEl' => '⋛', 'gel' => '⋛', 'geq' => '≥', 'geqq' => '≧', 'geqslant' => '', 'ges' => '', 'gescc' => '', 'gesdot' => '', 'gesdoto' => '', 'gesdotol' => '', 'gesl' => '', 'gesles' => '', 'Gfr' => '', 'gfr' => '', 'Gg' => '⋙', 'gg' => '≫', 'ggg' => '⋙', 'gimel' => 'ℷ', 'gl' => '≷', 'gla' => '', 'glE' => '', 'glj' => '', 'gnap' => '', 'gnapprox' => '', 'gnE' => '≩', 'gne' => '≩', 'gneq' => '≩', 'gneqq' => '≩', 'gnsim' => '⋧', 'Gopf' => '', 'grave' => '̀', 'GreaterEqual' => '≥', 'GreaterEqualLess' => '⋛', 'GreaterFullEqual' => '≧', 'GreaterLess' => '≷', 'GreaterSlantEqual' => '', 'GreaterTilde' => '≳', 'Gscr' => '', 'gscr' => '', 'gsim' => '≳', 'gsime' => '', 'gsiml' => '', 'Gt' => '≫', 'gt' => '>', 'gtcc' => '', 'gtcir' => '', 'gtdot' => '⋗', 'gtlPar' => '', 'gtquest' => '', 'gtrapprox' => '≳', 'gtrarr' => '', 'gtrdot' => '⋗', 'gtreqless' => '⋛', 'gtreqqless' => '⋛', 'gtrless' => '≷', 'gtrsim' => '≳', 'gvertneqq' => '', 'gvnE' => '', 'Hacek' => '̌', 'hairsp' => ' ', 'half' => '½', 'hamilt' => 'ℋ', 'hArr' => '⇔', 'harr' => '↔', 'harrcir' => '', 'harrw' => '↭', 'Hat' => '̂', 'hbar' => '', 'hbenzen' => '', 'hbenzena' => '', 'hbenzenb' => '', 'hbenzenc' => '', 'hbenzend' => '', 'hbenzene' => '', 'hbenzenf' => '', 'hbenzeng' => '', 'hbenzenh' => '', 'hbenzeni' => '', 'hbenzenj' => '', 'hbenzenk' => '', 'hbenzenl' => '', 'hbenzenm' => '', 'hbenzenn' => '', 'hbenzeno' => '', 'hbenzenp' => '', 'hbenzenq' => '', 'hbenzenr' => '', 'hearts' => '♡', 'heartsuit' => '♡', 'hellip' => '…', 'hercon' => '⊹', 'Hfr' => '', 'hfr' => '', 'hksearow' => '', 'hkswarow' => '', 'hoarr' => '', 'homtht' => '∻', 'hookleftarrow' => '↩', 'hookrightarrow' => '↪', 'Hopf' => '', 'horbar' => '―', 'Hscr' => '', 'hscr' => '', 'hslash' => 'ℏ', 'HumpDownHump' => '≎', 'HumpEqual' => '≏', 'hybull' => '⁃', 'hyphen' => '', 'iexcl' => '¡', 'iff' => '', 'Ifr' => '', 'ifr' => '', 'iiiint' => '', 'iiint' => '∭', 'iinfin' => '', 'iiota' => '℩', 'Im' => 'ℑ', 'image' => 'ℑ', 'imath' => 'ı', 'imof' => '⊷', 'imped' => '', 'Implies' => '⇒', 'in' => '∊', 'incare' => '℅', 'infin' => '∞', 'infintie' => '', 'Int' => '∬', 'int' => '∫', 'intcal' => '⊺', 'Integral' => '∫', 'intercal' => '⊺', 'Intersection' => '⋂', 'intlarhk' => '', 'intprod' => '', 'Iopf' => '', 'iota' => 'ι', 'iprod' => '', 'iquest' => '¿', 'Iscr' => '', 'iscr' => '', 'isin' => '∊', 'isindot' => '', 'isinE' => '', 'isins' => '', 'isinsv' => '', 'isinv' => '∈', 'Jfr' => '', 'jfr' => '', 'jmath' => '', 'Jopf' => '', 'Jscr' => '', 'jscr' => '', 'kappa' => 'κ', 'kappav' => 'ϰ', 'Kfr' => '', 'kfr' => '', 'Kopf' => '', 'Kscr' => '', 'kscr' => '', 'lAarr' => '⇚', 'laemptyv' => '', 'lagran' => 'ℒ', 'Lambda' => 'Λ', 'lambda' => 'λ', 'Lang' => '《', 'lang' => '〈', 'langd' => '', 'langle' => '〈', 'lap' => '≲', 'laquo' => '«', 'Larr' => '↞', 'lArr' => '⇐', 'larr' => '←', 'larrbfs' => '', 'larrfs' => '', 'larrhk' => '↩', 'larrlp' => '↫', 'larrpl' => '', 'larrsim' => '', 'larrtl' => '↢', 'lat' => '', 'lAtail' => '', 'latail' => '', 'late' => '', 'lates' => '', 'lBarr' => '', 'lbarr' => '', 'lbbrk' => '〔', 'lbrace' => '{', 'lbrack' => '[', 'lbrke' => '', 'lbrksld' => '', 'lbrkslu' => '', 'lceil' => '⌈', 'lcub' => '{', 'ldca' => '', 'ldquo' => '“', 'ldquor' => '„', 'ldrdhar' => '', 'ldrushar' => '', 'ldsh' => '↲', 'lE' => '≦', 'le' => '≤', 'LeftAngleBracket' => '〈', 'LeftArrow' => '←', 'Leftarrow' => '⇐', 'leftarrow' => '←', 'LeftArrowRightArrow' => '⇆', 'leftarrowtail' => '↢', 'LeftCeiling' => '⌈', 'LeftDownVector' => '⇃', 'LeftFloor' => '⌊', 'leftharpoondown' => '↽', 'leftharpoonup' => '↼', 'leftleftarrows' => '⇇', 'LeftRightArrow' => '↔', 'Leftrightarrow' => '⇔', 'leftrightarrow' => '↔', 'leftrightarrows' => '⇆', 'leftrightharpoons' => '⇋', 'leftrightsquigarrow' => '↭', 'LeftTee' => '⊣', 'leftthreetimes' => '⋋', 'LeftTriangle' => '⊲', 'LeftTriangleEqual' => '⊴', 'LeftUpVector' => '↿', 'LeftVector' => '↼', 'lEg' => '⋚', 'leg' => '⋚', 'leq' => '≤', 'leqq' => '≦', 'leqslant' => '', 'les' => '', 'lescc' => '', 'lesdot' => '', 'lesdoto' => '', 'lesdotor' => '', 'lesg' => '', 'lesges' => '', 'lessapprox' => '≲', 'lessdot' => '⋖', 'lesseqgtr' => '⋚', 'lesseqqgtr' => '⋚', 'LessEqualGreater' => '⋚', 'LessFullEqual' => '≦', 'LessGreater' => '≶', 'lessgtr' => '≶', 'lesssim' => '≲', 'LessSlantEqual' => '', 'LessTilde' => '≲', 'lfisht' => '', 'lfloor' => '⌊', 'Lfr' => '', 'lfr' => '', 'lg' => '≶', 'lgE' => '', 'lHar' => '', 'lhard' => '↽', 'lharu' => '↼', 'lharul' => '', 'lhblk' => '▄', 'Ll' => '⋘', 'll' => '≪', 'llarr' => '⇇', 'llcorner' => '⌞', 'Lleftarrow' => '⇚', 'llhard' => '', 'lltri' => '', 'lmoust' => '', 'lmoustache' => '', 'lnap' => '', 'lnapprox' => '', 'lnE' => '≨', 'lne' => '≨', 'lneq' => '≨', 'lneqq' => '≨', 'lnsim' => '⋦', 'loang' => '〘', 'loarr' => '', 'lobrk' => '〚', 'LongLeftArrow' => '', 'Longleftarrow' => '', 'longleftarrow' => '', 'LongLeftRightArrow' => '', 'Longleftrightarrow' => '', 'longleftrightarrow' => '', 'longmapsto' => '', 'LongRightArrow' => '', 'Longrightarrow' => '', 'longrightarrow' => '', 'looparrowleft' => '↫', 'looparrowright' => '↬', 'lopar' => '', 'Lopf' => '', 'loplus' => '', 'lotimes' => '', 'lowast' => '∗', 'lowbar' => '_', 'LowerLeftArrow' => '↙', 'LowerRightArrow' => '↘', 'loz' => '◊', 'lozenge' => '◊', 'lozf' => '', 'lpar' => '(', 'lparlt' => '', 'lrarr' => '⇆', 'lrcorner' => '⌟', 'lrhar' => '⇋', 'lrhard' => '', 'lrtri' => '', 'Lscr' => '', 'lscr' => '', 'Lsh' => '↰', 'lsh' => '↰', 'lsim' => '≲', 'lsime' => '', 'lsimg' => '', 'lsqb' => '[', 'lsquo' => '‘', 'lsquor' => '‚', 'Lt' => '≪', 'lt' => '<', 'ltcc' => '', 'ltcir' => '', 'ltdot' => '⋖', 'lthree' => '⋋', 'ltimes' => '⋉', 'ltlarr' => '', 'ltquest' => '', 'ltri' => '◃', 'ltrie' => '⊴', 'ltrif' => '◂', 'ltrPar' => '', 'lurdshar' => '', 'luruhar' => '', 'lvertneqq' => '', 'lvnE' => '', 'macr' => '̄', 'male' => '♂', 'malt' => '✠', 'maltese' => '✠', 'Map' => '', 'map' => '↦', 'mapsto' => '↦', 'marker' => '', 'mcomma' => '', 'mdash' => '—', 'mDDot' => '∺', 'measuredangle' => '∡', 'Mfr' => '', 'mfr' => '', 'mho' => '℧', 'micro' => 'µ', 'mid' => '∣', 'midast' => '∗', 'midcir' => '', 'middot' => '·', 'minus' => '−', 'minusb' => '⊟', 'minusd' => '∸', 'minusdu' => '', 'MinusPlus' => '∓', 'mlcp' => '', 'mldr' => '', 'mnplus' => '∓', 'models' => '⊧', 'Mopf' => '', 'mp' => '∓', 'Mscr' => '', 'mscr' => '', 'mstpos' => '∾', 'mu' => 'μ', 'multimap' => '⊸', 'mumap' => '⊸', 'nabla' => '∇', 'nang' => '', 'nap' => '≉', 'napE' => '', 'napid' => '', 'napprox' => '≉', 'natur' => '♮', 'natural' => '♮', 'nbsp' => ' ', 'ncap' => '', 'ncong' => '≇', 'ncongdot' => '', 'ncup' => '', 'ndash' => '–', 'ne' => '≠', 'nearhk' => '', 'neArr' => '⇗', 'nearr' => '↗', 'nearrow' => '↗', 'nedot' => '', 'nequiv' => '≢', 'nesear' => '', 'NestedGreaterGreater' => '≫', 'NestedLessLess' => '≪', 'nexist' => '∄', 'nexists' => '∄', 'Nfr' => '', 'nfr' => '', 'ngE' => '≱', 'nge' => '', 'ngeq' => '', 'ngeqq' => '≱', 'ngeqslant' => '≱', 'nges' => '≱', 'nGg' => '', 'ngsim' => '≵', 'nGt' => '', 'ngt' => '≯', 'ngtr' => '≯', 'nGtv' => '', 'nhArr' => '⇎', 'nharr' => '↮', 'nhpar' => '', 'ni' => '∍', 'nis' => '', 'nisd' => '', 'niv' => '∋', 'nlArr' => '⇍', 'nlarr' => '↚', 'nldr' => '‥', 'nlE' => '≰', 'nle' => '', 'nLeftarrow' => '⇍', 'nleftarrow' => '↚', 'nLeftrightarrow' => '⇎', 'nleftrightarrow' => '↮', 'nleq' => '', 'nleqq' => '≰', 'nleqslant' => '≰', 'nles' => '≰', 'nless' => '≮', 'nLl' => '', 'nlsim' => '≴', 'nLt' => '', 'nlt' => '≮', 'nltri' => '⋪', 'nltrie' => '⋬', 'nLtv' => '', 'nmid' => '∤', 'Nopf' => 'ℕ', 'Not' => '', 'not' => '¬', 'NotCongruent' => '≢', 'NotDoubleVerticalBar' => '∦', 'NotElement' => '∉', 'NotEqual' => '≠', 'NotExists' => '∄', 'NotGreater' => '≯', 'NotGreaterEqual' => '', 'NotGreaterFullEqual' => '≰', 'NotGreaterGreater' => '', 'NotGreaterLess' => '≹', 'NotGreaterSlantEqual' => '≱', 'NotGreaterTilde' => '≵', 'notin' => '∉', 'notindot' => '', 'notinE' => '', 'notinva' => '', 'notinvb' => '', 'notinvc' => '', 'NotLeftTriangle' => '⋪', 'NotLeftTriangleEqual' => '⋬', 'NotLess' => '≮', 'NotLessEqual' => '', 'NotLessFullEqual' => '≰', 'NotLessGreater' => '≸', 'NotLessLess' => '', 'NotLessSlantEqual' => '≰', 'NotLessTilde' => '≴', 'notni' => '∌', 'notniva' => '∌', 'notnivb' => '', 'notnivc' => '', 'NotPrecedes' => '⊀', 'NotPrecedesEqual' => '', 'NotPrecedesSlantEqual' => '⋠', 'NotReverseElement' => '∌', 'NotRightTriangle' => '⋫', 'NotRightTriangleEqual' => '⋭', 'NotSquareSubsetEqual' => '⋢', 'NotSquareSupersetEqual' => '⋣', 'NotSubset' => '⊄', 'NotSucceeds' => '⊁', 'NotSucceedsEqual' => '', 'NotSucceedsSlantEqual' => '⋡', 'NotSuperset' => '⊅', 'NotTilde' => '≁', 'NotTildeEqual' => '≄', 'NotTildeFullEqual' => '≇', 'NotTildeTilde' => '≉', 'NotVerticalBar' => '∤', 'npar' => '∦', 'nparallel' => '∦', 'nparsl' => '', 'npart' => '', 'npolint' => '', 'npr' => '⊀', 'nprcue' => '⋠', 'npre' => '', 'nprec' => '⊀', 'npreceq' => '', 'nrArr' => '⇏', 'nrarr' => '↛', 'nrarrc' => '', 'nrarrw' => '', 'nRightarrow' => '⇏', 'nrightarrow' => '↛', 'nrtri' => '⋫', 'nrtrie' => '⋭', 'nsc' => '⊁', 'nsccue' => '⋡', 'nsce' => '', 'Nscr' => '', 'nscr' => '', 'nshortmid' => '', 'nshortparallel' => '', 'nsim' => '≁', 'nsime' => '≄', 'nsimeq' => '≄', 'nsmid' => '', 'nspar' => '', 'nsqsube' => '⋢', 'nsqsupe' => '⋣', 'nsub' => '⊄', 'nsubE' => '⊈', 'nsube' => '⊈', 'nsubset' => '⊄', 'nsubseteq' => '⊈', 'nsubseteqq' => '⊈', 'nsucc' => '⊁', 'nsucceq' => '', 'nsup' => '⊅', 'nsupE' => '⊉', 'nsupe' => '⊉', 'nsupset' => '⊅', 'nsupseteq' => '⊉', 'nsupseteqq' => '⊉', 'ntgl' => '≹', 'ntlg' => '≸', 'ntriangleleft' => '⋪', 'ntrianglelefteq' => '⋬', 'ntriangleright' => '⋫', 'ntrianglerighteq' => '⋭', 'ntvgl' => '≹', 'ntvlg' => '≸', 'nu' => 'ν', 'num' => '#', 'numsp' => ' ', 'nvap' => '', 'nVDash' => '⊯', 'nVdash' => '⊮', 'nvDash' => '⊭', 'nvdash' => '⊬', 'nvge' => '≱', 'nvgt' => '≯', 'nvhArr*' => '⇎', 'nvinfin' => '', 'nvlArr' => '⇍', 'nvle' => '≰', 'nvlt' => '≮', 'nvltrie' => '', 'nvrArr' => '⇏', 'nvrtrie' => '', 'nvsim' => '', 'nwarhk' => '', 'nwArr' => '⇖', 'nwarr' => '↖', 'nwarrow' => '↖', 'nwnear' => '', 'oast' => '⊛', 'ocir' => '⊚', 'odash' => '⊝', 'odiv' => '', 'odot' => '⊙', 'odsold' => '', 'ofcir' => '', 'Ofr' => '', 'ofr' => '', 'ogon' => '̨', 'ogt' => '', 'ohbar' => '', 'ohm' => 'Ω', 'oint' => '∮', 'olarr' => '↺', 'olcir' => '', 'olcross' => '', 'olt' => '', 'Omega' => 'Ω', 'omega' => 'ω', 'omicron' => 'ξ', 'omid' => '', 'ominus' => '⊖', 'Oopf' => '', 'opar' => '', 'OpenCurlyDoubleQuote' => '“', 'OpenCurlyQuote' => '‘', 'operp' => '', 'oplus' => '⊕', 'Or' => '', 'or' => '∨', 'orarr' => '↻', 'ord' => '', 'order' => 'ℴ', 'ordf' => 'ª', 'ordm' => 'º', 'origof' => '⊶', 'oror' => '', 'orslope' => '', 'orv' => '', 'oS' => '', 'Oscr' => '', 'oscr' => '', 'oslash' => '⊘', 'osol' => '⊘', 'Otimes' => '', 'otimes' => '⊗', 'otimesas' => '', 'ovbar' => '', 'OverLine' => '̅', 'par' => '∥', 'para' => '¶', 'parallel' => '∥', 'parsim' => '', 'parsl' => '', 'part' => '∂', 'PartialD' => '∂', 'percnt' => '%', 'period' => '.', 'permil' => '‰', 'perp' => '⊥', 'pertenk' => '‱', 'Pfr' => '', 'pfr' => '', 'Phi' => 'Φ', 'phi' => 'φ', 'phiv' => 'ϕ', 'phmmat' => 'ℳ', 'phone' => '☎', 'Pi' => 'Π', 'pi' => 'π', 'pitchfork' => '⋔', 'piv' => 'ϖ', 'plank' => '', 'plankv' => 'ℏ', 'plus' => '+', 'plusacir' => '', 'plusb' => '⊞', 'pluscir' => '', 'plusdo' => '∔', 'plusdu' => '', 'pluse' => '', 'PlusMinus' => '±', 'plusmn' => '±', 'plussim' => '', 'plustwo' => '', 'pm' => '±', 'pointint' => '', 'Popf' => 'ℙ', 'pound' => '£', 'Pr' => '', 'pr' => '≺', 'prap' => '≾', 'prcue' => '≼', 'prE' => '≼', 'pre' => '≼', 'prec' => '≺', 'precapprox' => '≾', 'preccurlyeq' => '≼', 'Precedes' => '≺', 'PrecedesEqual' => '≼', 'PrecedesSlantEqual' => '≼', 'PrecedesTilde' => '≾', 'preceq' => '≼', 'precnapprox' => '⋨', 'precneqq' => '', 'precnsim' => '⋨', 'precsim' => '≾', 'Prime' => '″', 'prime' => '′', 'prnap' => '⋨', 'prnE' => '', 'prnsim' => '⋨', 'profalar' => '⌮', 'profline' => '⌒', 'profsurf' => '⌓', 'prop' => '∝', 'Proportion' => '∷', 'Proportional' => '∝', 'propto' => '∝', 'prsim' => '≾', 'prurel' => '⊰', 'Pscr' => '', 'pscr' => '', 'Psi' => 'Ψ', 'psi' => 'ψ', 'puncsp' => ' ', 'Qfr' => '', 'qfr' => '', 'qint' => '', 'Qopf' => 'ℚ', 'qprime' => '', 'Qscr' => '', 'qscr' => '', 'quatint' => '', 'quest' => '?', 'questeq' => '≟', 'quot' => '"', 'rAarr' => '⇛', 'race' => '', 'radic' => '√', 'raemptyv' => '', 'Rang' => '》', 'rang' => '〉', 'rangd' => '', 'range' => '', 'rangle' => '〉', 'raquo' => '»', 'Rarr' => '↠', 'rArr' => '⇒', 'rarr' => '→', 'rarrap' => '', 'rarrbfs' => '', 'rarrc' => '', 'rarrfs' => '', 'rarrhk' => '↪', 'rarrlp' => '↬', 'rarrpl' => '', 'rarrsim' => '', 'Rarrtl' => '', 'rarrtl' => '↣', 'rarrw' => '↝', 'rAtail' => '', 'ratail' => '↣', 'ratio' => '∶', 'RBarr' => '', 'rBarr' => '', 'rbarr' => '', 'rbbrk' => '〕', 'rbrace' => '}', 'rbrack' => ']', 'rbrke' => '', 'rbrksld' => '', 'rbrkslu' => '', 'rceil' => '⌉', 'rcub' => '}', 'rdca' => '', 'rdldhar' => '', 'rdquo' => '”', 'rdquor' => '‛', 'rdsh' => '↳', 'Re' => 'ℜ', 'real' => 'ℜ', 'rect' => '', 'reg' => '¯', 'ReverseElement' => '∋', 'ReverseEquilibrium' => '⇋', 'ReverseUpEquilibrium' => '', 'rfisht' => '', 'rfloor' => '⌋', 'Rfr' => '', 'rfr' => '', 'rHar' => '', 'rhard' => '⇁', 'rharu' => '⇀', 'rharul' => '', 'rho' => 'ρ', 'rhov' => 'ϱ', 'RightAngleBracket' => '〉', 'RightArrow' => '→', 'Rightarrow' => '⇒', 'rightarrow' => '→', 'RightArrowLeftArrow' => '⇄', 'rightarrowtail' => '↣', 'RightCeiling' => '⌉', 'RightDownVector' => '⇂', 'RightFloor' => '⌋', 'rightharpoondown' => '⇁', 'rightharpoonup' => '⇀', 'rightleftarrows' => '⇄', 'rightleftharpoons' => '⇌', 'rightrightarrows' => '⇉', 'rightsquigarrow' => '↝', 'RightTee' => '⊢', 'RightTeeArrow' => '↦', 'rightthreetimes' => '⋌', 'RightTriangle' => '⊳', 'RightTriangleEqual' => '⊵', 'RightUpVector' => '↾', 'RightVector' => '⇀', 'ring' => '̊', 'risingdotseq' => '≓', 'rlarr' => '⇄', 'rlhar' => '⇌', 'rmoust' => '', 'rmoustache' => '', 'rnmid' => '', 'roang' => '〙', 'roarr' => '', 'robrk' => '〛', 'ropar' => '', 'Ropf' => 'ℝ', 'roplus' => '', 'rotimes' => '', 'rpar' => ')', 'rpargt' => '', 'rppolint' => '', 'rrarr' => '⇉', 'Rrightarrow' => '⇛', 'Rscr' => '', 'rscr' => 'ℛ', 'Rsh' => '↱', 'rsh' => '↱', 'rsqb' => ']', 'rsquo' => '’', 'rsquor' => '‟', 'rthree' => '⋌', 'rtimes' => '⋊', 'rtri' => '▹', 'rtrie' => '⊵', 'rtrif' => '▸', 'rtriltri' => '', 'ruluhar' => '', 'rx' => '℞', 'Sc' => '', 'sc' => '≻', 'scap' => '≿', 'sccue' => '≽', 'scE' => '≾', 'sce' => '≽', 'scnap' => '⋩', 'scnE' => '', 'scnsim' => '⋩', 'scpolint' => '', 'scsim' => '≿', 'sdot' => '⋅', 'sdotb' => '⊡', 'sdote' => '', 'searhk' => '', 'seArr' => '⇘', 'searr' => '↘', 'searrow' => '↘', 'sect' => '§', 'semi' => ';', 'seswar' => '', 'setminus' => '∖', 'setmn' => '∖', 'sext' => '', 'Sfr' => '', 'sfr' => '', 'sfrown' => '', 'sharp' => '♯', 'ShortLeftArrow' => '', 'shortmid' => '', 'shortparallel' => '', 'ShortRightArrow' => '', 'shy' => '­', 'Sigma' => 'Σ', 'sigma' => 'σ', 'sigmav' => 'ς', 'sim' => '∼', 'simdot' => '', 'sime' => '≃', 'simeq' => '≃', 'simg' => '', 'simgE' => '', 'siml' => '', 'simlE' => '', 'simne' => '≆', 'simplus' => '', 'simrarr' => '', 'slarr' => '', 'SmallCircle' => '∘', 'smallfrown' => '', 'smallsetminus' => '', 'smallsmile' => '', 'smashp' => '', 'smeparsl' => '', 'smid' => '', 'smile' => '⌣', 'smt' => '', 'smte' => '', 'smtes' => '', 'sol' => '/', 'solb' => '', 'solbar' => '', 'Sopf' => '', 'spades' => '♠', 'spadesuit' => '♠', 'spar' => '', 'sqcap' => '⊓', 'sqcaps' => '', 'sqcup' => '⊔', 'sqcups' => '', 'Sqrt' => '√', 'sqsub' => '⊏', 'sqsube' => '⊑', 'sqsubset' => '⊏', 'sqsubseteq' => '⊑', 'sqsup' => '⊐', 'sqsupe' => '⊒', 'sqsupset' => '⊐', 'sqsupseteq' => '⊒', 'squ' => '□', 'square' => '□', 'SquareIntersection' => '⊓', 'SquareSubset' => '⊏', 'SquareSubsetEqual' => '⊑', 'SquareSuperset' => '⊐', 'SquareSupersetEqual' => '⊒', 'SquareUnion' => '⊔', 'squarf' => '■', 'squarfb' => '', 'squarfbl' => '', 'squarfbr' => '◪', 'squarfl' => '◧', 'squarfr' => '◨', 'squarft' => '', 'squarftl' => '◩', 'squarftr' => '', 'squf' => '▪', 'srarr' => '', 'Sscr' => '', 'sscr' => '', 'ssetmn' => '', 'ssmile' => '', 'sstarf' => '⋆', 'Star' => '⋆', 'star' => '⋆', 'starf' => '★', 'straightepsilon' => '∊', 'straightphi' => 'φ', 'strns' => '', 'Sub' => '⋐', 'sub' => '⊂', 'subdot' => '', 'subE' => '⊆', 'sube' => '⊆', 'subedot' => '', 'submult' => '', 'subnE' => '⊊', 'subne' => '⊊', 'subplus' => '', 'subrarr' => '', 'Subset' => '⋐', 'subset' => '⊂', 'subseteq' => '⊆', 'subseteqq' => '⊆', 'SubsetEqual' => '⊆', 'subsetneq' => '⊊', 'subsetneqq' => '⊊', 'subsim' => '', 'subsub' => '', 'subsup' => '', 'succ' => '≻', 'succapprox' => '≿', 'succcurlyeq' => '≽', 'Succeeds' => '≻', 'SucceedsEqual' => '≽', 'SucceedsSlantEqual' => '≽', 'SucceedsTilde' => '≿', 'succeq' => '≽', 'succnapprox' => '⋩', 'succneqq' => '', 'succnsim' => '⋩', 'succsim' => '≿', 'SuchThat' => '∍', 'Sum' => '∑', 'sum' => '∑', 'sung' => '♩', 'Sup' => '⋑', 'sup' => '⊃', 'sup1' => '¹', 'sup2' => '²', 'sup3' => '³', 'supdot' => '', 'supdsub' => '', 'supE' => '⊇', 'supe' => '⊇', 'supedot' => '', 'Superset' => '⊃', 'SupersetEqual' => '⊇', 'suphsol' => '', 'suphsub' => '', 'suplarr' => '', 'supmult' => '', 'supnE' => '⊋', 'supne' => '⊋', 'supplus' => '', 'Supset' => '⋑', 'supset' => '⊃', 'supseteq' => '⊇', 'supseteqq' => '⊇', 'supsetneq' => '⊋', 'supsetneqq' => '⊋', 'supsim' => '', 'supsub' => '', 'supsup' => '', 'swarhk' => '', 'swArr' => '⇙', 'swarr' => '↙', 'swarrow' => '↙', 'swnwar' => '', 'target' => '⌖', 'tau' => 'τ', 'tbrk' => '', 'tdot' => '⃛', 'telrec' => '⌕', 'Tfr' => '', 'tfr' => '', 'there4' => '∴', 'Therefore' => '∴', 'therefore' => '∴', 'Theta' => 'Θ', 'theta' => 'θ', 'thetav' => 'ϑ', 'thickapprox' => '', 'thicksim' => '', 'thinsp' => ' ', 'thkap' => '', 'thksim' => '', 'Tilde' => '∼', 'tilde' => '̃', 'TildeEqual' => '≃', 'TildeFullEqual' => '≅', 'TildeTilde' => '≈', 'times' => '×', 'timesb' => '⊠', 'timesbar' => '', 'timesd' => '', 'tint' => '∭', 'toea' => '', 'top' => '⊤', 'topbot' => '⌶', 'topcir' => '', 'Topf' => '', 'topfork' => '', 'tosa' => '', 'tprime' => '‴', 'trade' => '™', 'triangle' => '▵', 'triangledown' => '▿', 'triangleleft' => '◃', 'trianglelefteq' => '⊴', 'triangleq' => '≜', 'triangleright' => '▹', 'trianglerighteq' => '⊵', 'tridot' => '◬', 'trie' => '≜', 'triminus' => '', 'TripleDot' => '⃛', 'triplus' => '', 'trisb' => '', 'tritime' => '', 'trpezium' => '', 'Tscr' => '', 'tscr' => '', 'twixt' => '≬', 'twoheadleftarrow' => '↞', 'twoheadrightarrow' => '↠', 'Uarr' => '↟', 'uArr' => '⇑', 'uarr' => '↑', 'Uarrocir' => '', 'udarr' => '⇅', 'udhar' => '', 'ufisht' => '', 'Ufr' => '', 'ufr' => '', 'uHar' => '', 'uharl' => '↿', 'uharr' => '↾', 'uhblk' => '▀', 'ulcorn' => '⌜', 'ulcorner' => '⌜', 'ulcrop' => '⌏', 'ultri' => '', 'uml' => '̈', 'UnderLine' => '̲', 'Union' => '⋃', 'UnionPlus' => '⊎', 'Uopf' => '', 'UpArrow' => '↑', 'Uparrow' => '⇑', 'uparrow' => '↑', 'UpArrowDownArrow' => '⇅', 'UpDownArrow' => '↕', 'Updownarrow' => '⇕', 'updownarrow' => '↕', 'UpEquilibrium' => '', 'upharpoonleft' => '↿', 'upharpoonright' => '↾', 'uplus' => '⊎', 'UpperLeftArrow' => '↖', 'UpperRightArrow' => '↗', 'Upsi' => 'ϒ', 'upsi' => 'υ', 'Upsilon' => 'ϒ', 'upsilon' => 'υ', 'UpTee' => '⊥', 'upuparrows' => '⇈', 'urcorn' => '⌝', 'urcorner' => '⌝', 'urcrop' => '⌎', 'urtri' => '', 'Uscr' => '', 'uscr' => '', 'utdot' => '⋰', 'utri' => '▵', 'utrif' => '▴', 'uuarr' => '⇈', 'uwangle' => '', 'vangrt' => '⊾', 'varepsilon' => 'ε', 'varkappa' => 'ϰ', 'varnothing' => '∅', 'varphi' => 'ϕ', 'varpi' => 'ϖ', 'varpropto' => '∝', 'vArr' => '⇕', 'varr' => '↕', 'varrho' => 'ϱ', 'varsigma' => 'ς', 'varsubsetneq' => '', 'varsubsetneqq' => '', 'varsupsetneq' => '', 'varsupsetneqq' => '', 'vartheta' => 'ϑ', 'vartriangleleft' => '⊲', 'vartriangleright' => '⊳', 'Vbar' => '', 'vBar' => '', 'vBarv' => '', 'VDash' => '⊫', 'Vdash' => '⊩', 'vDash' => '⊨', 'vdash' => '⊢', 'Vdashl' => '', 'Vee' => '⋁', 'vee' => '∨', 'veebar' => '⊻', 'veeeq' => '≚', 'vellip' => '⋮', 'Verbar' => '‖', 'verbar' => '|', 'Vert' => '‖', 'vert' => '|', 'VerticalBar' => '∣', 'VerticalTilde' => '≀', 'Vfr' => '', 'vfr' => '', 'vltri' => '⊲', 'vnsub' => '⊄', 'vnsup' => '⊅', 'Vopf' => '', 'vprop' => '∝', 'vrtri' => '⊳', 'Vscr' => '', 'vscr' => '', 'vsubnE' => '', 'vsubne' => '', 'vsupnE' => '', 'vsupne' => '', 'Vvdash' => '⊪', 'vzigzag' => '', 'wedbar' => '', 'Wedge' => '⋀', 'wedge' => '∧', 'wedgeq' => '≙', 'weierp' => '℘', 'Wfr' => '', 'wfr' => '', 'Wopf' => '', 'wp' => '℘', 'wr' => '≀', 'wreath' => '≀', 'Wscr' => '', 'wscr' => '', 'xcap' => '⋂', 'xcirc' => '○', 'xcup' => '⋃', 'xdtri' => '▽', 'Xfr' => '', 'xfr' => '', 'xhArr' => '', 'xharr' => '', 'Xi' => 'Ξ', 'xi' => 'ξ', 'xlArr' => '', 'xlarr' => '', 'xmap' => '', 'xnis' => '', 'xodot' => '⊙', 'Xopf' => '', 'xoplus' => '⊕', 'xotime' => '⊗', 'xrArr' => '', 'xrarr' => '', 'Xscr' => '', 'xscr' => '', 'xsqcup' => '⊔', 'xuplus' => '⊎', 'xutri' => '△', 'xvee' => '⋁', 'xwedge' => '⋀', 'yen' => '¥', 'Yfr' => '', 'yfr' => '', 'Yopf' => '', 'Yscr' => '', 'yscr' => '', 'zeta' => 'ζ', 'Zfr' => 'ℤ', 'zfr' => '', 'zigrarr' => '', 'Zopf' => '', 'Zscr' => '', 'zscr' => '' ); ?> spip/spip/ecrire/charsets/iso-8859-15.php0000766000000000000000000000206111236524730021124 0ustar adminadministrators load_charset('iso-8859-1'); $trans = $GLOBALS['CHARSET']['iso-8859-1']; $trans[164]=8364; $trans[166]=352; $trans[168]=353; $trans[180]=381; $trans[184]=382; $trans[188]=338; $trans[189]=339; $trans[190]=376; $GLOBALS['CHARSET']['iso-8859-15'] = $trans; ?> spip/spip/ecrire/charsets/cp1256.php0000766000000000000000000000361211236524730020417 0ustar adminadministrators0x20AC, 0x81=>0x067E, 0x82=>0x201A, 0x83=>0x0192, 0x84=>0x201E, 0x85=>0x2026, 0x86=>0x2020, 0x87=>0x2021, 0x88=>0x02C6, 0x89=>0x2030, 0x8A=>0x0679, 0x8B=>0x2039, 0x8C=>0x0152, 0x8D=>0x0686, 0x8E=>0x0698, 0x8F=>0x0688, 0x90=>0x06AF, 0x91=>0x2018, 0x92=>0x2019, 0x93=>0x201C, 0x94=>0x201D, 0x95=>0x2022, 0x96=>0x2013, 0x97=>0x2014, 0x98=>0x06A9, 0x99=>0x2122, 0x9A=>0x0691, 0x9B=>0x203A, 0x9C=>0x0153, 0x9D=>0x200C, 0x9E=>0x200D, 0x9F=>0x06BA, 0xA0=>0x00A0, 0xA1=>0x060C, 0xA2=>0x00A2, 0xA3=>0x00A3, 0xA4=>0x00A4, 0xA5=>0x00A5, 0xA6=>0x00A6, 0xA7=>0x00A7, 0xA8=>0x00A8, 0xA9=>0x00A9, 0xAA=>0x06BE, 0xAB=>0x00AB, 0xAC=>0x00AC, 0xAD=>0x00AD, 0xAE=>0x00AE, 0xAF=>0x00AF, 0xB0=>0x00B0, 0xB1=>0x00B1, 0xB2=>0x00B2, 0xB3=>0x00B3, 0xB4=>0x00B4, 0xB5=>0x00B5, 0xB6=>0x00B6, 0xB7=>0x00B7, 0xB8=>0x00B8, 0xB9=>0x00B9, 0xBA=>0x061B, 0xBB=>0x00BB, 0xBC=>0x00BC, 0xBD=>0x00BD, 0xBE=>0x00BE, 0xBF=>0x061F, 0xC0=>0x06C1, 0xC1=>0x0621, 0xC2=>0x0622, 0xC3=>0x0623, 0xC4=>0x0624, 0xC5=>0x0625, 0xC6=>0x0626, 0xC7=>0x0627, 0xC8=>0x0628, 0xC9=>0x0629, 0xCA=>0x062A, 0xCB=>0x062B, 0xCC=>0x062C, 0xCD=>0x062D, 0xCE=>0x062E, 0xCF=>0x062F, 0xD0=>0x0630, 0xD1=>0x0631, 0xD2=>0x0632, 0xD3=>0x0633, 0xD4=>0x0634, 0xD5=>0x0635, 0xD6=>0x0636, 0xD7=>0x00D7, 0xD8=>0x0637, 0xD9=>0x0638, 0xDA=>0x0639, 0xDB=>0x063A, 0xDC=>0x0640, 0xDD=>0x0641, 0xDE=>0x0642, 0xDF=>0x0643, 0xE0=>0x00E0, 0xE1=>0x0644, 0xE2=>0x00E2, 0xE3=>0x0645, 0xE4=>0x0646, 0xE5=>0x0647, 0xE6=>0x0648, 0xE7=>0x00E7, 0xE8=>0x00E8, 0xE9=>0x00E9, 0xEA=>0x00EA, 0xEB=>0x00EB, 0xEC=>0x0649, 0xED=>0x064A, 0xEE=>0x00EE, 0xEF=>0x00EF, 0xF0=>0x064B, 0xF1=>0x064C, 0xF2=>0x064D, 0xF3=>0x064E, 0xF4=>0x00F4, 0xF5=>0x064F, 0xF6=>0x0650, 0xF7=>0x00F7, 0xF8=>0x0651, 0xF9=>0x00F9, 0xFA=>0x0652, 0xFB=>0x00FB, 0xFC=>0x00FC, 0xFD=>0x200E, 0xFE=>0x200F, 0xFF=>0x06D2); ?> spip/spip/ecrire/charsets/html.php0000766000000000000000000000453111236524730020444 0ustar adminadministrators'“', 'rdquo'=>'”', 'bdquo'=>'„', 'cent'=>'¢', 'pound'=>'£', 'curren'=>'¤', 'yen'=>'¥', 'brvbar'=>'¦', 'sect'=>'§', 'uml'=>'¨', 'ordf'=>'ª', 'laquo'=>'«', 'lsquo'=>'‘', 'rsquo'=>'’', 'not'=>'¬', 'shy'=>'­', 'macr'=>'¯', 'deg'=>'°', 'plusmn'=>'±', 'sup2'=>'²', 'sup3'=>'³', 'acute'=>'´', 'micro'=>'µ', 'para'=>'¶', 'middot'=>'·', 'cedil'=>'¸', 'sup1'=>'¹', 'ordm'=>'º', 'raquo'=>'»', 'iquest'=>'¿', 'Agrave'=>'À', 'Aacute'=>'Á', 'Acirc'=>'Â', 'Atilde'=>'Ã', 'Auml'=>'Ä', 'Aring'=>'Å', 'AElig'=>'Æ', 'Ccedil'=>'Ç', 'Egrave'=>'È', 'Eacute'=>'É', 'Ecirc'=>'Ê', 'Euml'=>'Ë', 'Igrave'=>'Ì', 'Iacute'=>'Í', 'Icirc'=>'Î', 'Iuml'=>'Ï', 'ETH'=>'Ð', 'Ntilde'=>'Ñ', 'Ograve'=>'Ò', 'Oacute'=>'Ó', 'Ocirc'=>'Ô', 'Otilde'=>'Õ', 'Ouml'=>'Ö', 'times'=>'×', 'Oslash'=>'Ø', 'Ugrave'=>'Ù', 'Uacute'=>'Ú', 'Ucirc'=>'Û', 'Uuml'=>'Ü', 'Yacute'=>'Ý', 'THORN'=>'Þ', 'szlig'=>'ß', 'agrave'=>'à', 'Scaron'=>'Š', 'scaron'=>'š', 'zcaron'=>'ž', 'Zcaron'=>'Ž', 'aacute'=>'á', 'acirc'=>'â', 'atilde'=>'ã', 'auml'=>'ä', 'aring'=>'å', 'aelig'=>'æ', 'ccedil'=>'ç', 'egrave'=>'è', 'eacute'=>'é', 'ecirc'=>'ê', 'euml'=>'ë', 'igrave'=>'ì', 'iacute'=>'í', 'icirc'=>'î', 'iuml'=>'ï', 'eth'=>'ð', 'ntilde'=>'ñ', 'ograve'=>'ò', 'oacute'=>'ó', 'ocirc'=>'ô', 'otilde'=>'õ', 'ouml'=>'ö', 'divide'=>'÷', 'oslash'=>'ø', 'ugrave'=>'ù', 'uacute'=>'ú', 'ucirc'=>'û', 'uuml'=>'ü', 'yacute'=>'ý', 'thorn'=>'þ', 'nbsp' => " ", 'thinsp' =>' ', 'ensp' =>' ', 'emsp' =>' ', 'copy' => "(c)", 'reg' => "(r)", 'frac14' => "1/4", 'frac12' => "1/2", 'frac34' => "3/4", 'apos' => "'", 'mdash' => '—', 'ndash' => '–', 'hellip' =>'…', 'euro' => '€', 'OElig' => 'Œ', 'oelig' => 'œ','iexcl' => '¡' ); ## caracteres tres speciaux a ne pas convertir #'amp' => '&', 'quot' => '"', 'lt' => '<', 'gt' => '>', ?> spip/spip/ecrire/public/0000777000000000000000000000000011266531641016427 5ustar adminadministratorsspip/spip/ecrire/public/composer.php0000766000000000000000000005265111236524730020777 0ustar adminadministrators 'oui', 'phpcheck' => 'oui'))) eval('?'.'>'.$skel_code); # spip_log($skel_code, 'comp') if (@file_exists($lib = $squelette . '_fonctions'.'.php')) include_once $lib; // tester si le eval ci-dessus a mis le squelette en memoire if (function_exists($nom)) return array($nom, $skel_code); // charger le source, si possible, et compiler if (lire_fichier ($source, $skel)) { $compiler = charger_fonction('compiler', 'public'); $skel_code = $compiler($skel, $nom, $gram, $source, $connect); } // Tester si le compilateur renvoie une erreur if (is_array($skel_code)) erreur_squelette($skel_code[0], $skel_code[1]); else { if (isset($GLOBALS['var_mode']) AND $GLOBALS['var_mode'] == 'debug') { debug_dumpfile ($skel_code, $nom, 'code'); } eval('?'.'>'.$skel_code); if (function_exists($nom)) { ecrire_fichier ($phpfile, $skel_code); return array($nom, $skel_code); } else { erreur_squelette(_T('zbug_erreur_compilation'), $source); } } } // Le squelette compile est-il trop vieux ? // http://doc.spip.org/@squelette_obsolete function squelette_obsolete($skel, $squelette) { return ( (isset($GLOBALS['var_mode']) AND in_array($GLOBALS['var_mode'], array('recalcul','preview','debug'))) OR !@file_exists($skel) OR ((@file_exists($squelette)?@filemtime($squelette):0) > ($date = @filemtime($skel))) OR ( (@file_exists($fonc = 'mes_fonctions.php') OR @file_exists($fonc = 'mes_fonctions.php3')) AND @filemtime($fonc) > $date) # compatibilite OR (defined('_FILE_OPTIONS') AND @filemtime(_FILE_OPTIONS) > $date) ); } // Activer l'invalideur de session // http://doc.spip.org/@invalideur_session function invalideur_session(&$Cache, $code=NULL) { $Cache['session']=spip_session(); return $code; } // // Des fonctions diverses utilisees lors du calcul d'une page ; ces fonctions // bien pratiques n'ont guere de logique organisationnelle ; elles sont // appelees par certaines balises au moment du calcul des pages. (Peut-on // trouver un modele de donnees qui les associe physiquement au fichier // definissant leur balise ??? // // http://doc.spip.org/@echapper_php_callback function echapper_php_callback($r) { static $src = array(); static $dst = array(); // si on recoit un tableau, on est en mode echappement // on enregistre le code a echapper dans dst, et le code echappe dans src if (is_array($r)) { $dst[] = $r[0]; return $src[] = '___'.md5($r[0]).'___'; } // si on recoit une chaine, on est en mode remplacement $r = str_replace($src, $dst, $r); $src = $dst = array(); // raz de la memoire return $r; } // http://doc.spip.org/@analyse_resultat_skel function analyse_resultat_skel($nom, $cache, $corps, $source='') { $headers = array(); // Recupere les < ?php header('Xx: y'); ? > pour $page['headers'] // note: on essaie d'attrapper aussi certains de ces entetes codes // "a la main" dans les squelettes, mais evidemment sans exhaustivite if (preg_match_all( '/(<[?]php\s+)@?header\s*\(\s*.([^:]*):\s*([^)]*)[^)]\s*\)\s*[;]?\s*[?]>/ims', $corps, $regs, PREG_SET_ORDER)) foreach ($regs as $r) { $corps = str_replace($r[0], '', $corps); # $j = Content-Type, et pas content-TYPE. $j = join('-', array_map('ucwords', explode('-', strtolower($r[2])))); $headers[$j] = $r[3]; } // S'agit-il d'un resultat constant ou contenant du code php $process_ins = ( strpos($corps,'<'.'?') === false OR strpos(str_replace('<'.'?xml', '', $corps),'<'.'?') === false ) ? 'html' : 'php'; // traiter #FILTRE{} ? if (isset($headers['X-Spip-Filtre']) AND strlen($headers['X-Spip-Filtre'])) { // proteger les et tous les morceaux de php if ($process_ins == 'php') $corps = preg_replace_callback(',<[?](\s|php|=).*[?]>,UimsS', 'echapper_php_callback', $corps); foreach (explode('|', $headers['X-Spip-Filtre']) as $filtre) { $corps = appliquer_filtre($corps, $filtre); } // restaurer les echappements $corps = echapper_php_callback($corps); unset($headers['X-Spip-Filtre']); } return array('texte' => $corps, 'squelette' => $nom, 'source' => $source, 'process_ins' => $process_ins, 'invalideurs' => $cache, 'entetes' => $headers, 'duree' => isset($headers['X-Spip-Cache']) ? intval($headers['X-Spip-Cache']) : 0 ); } // Pour les documents comme pour les logos, le filtre |fichier donne // le chemin du fichier apres 'IMG/' ; peut-etre pas d'une purete // remarquable, mais a conserver pour compatibilite ascendante. // -> http://www.spip.net/fr_article901.html // Renvoie le code html pour afficher un logo, avec ou sans survol, lien, etc. // http://doc.spip.org/@affiche_logos function affiche_logos($logos, $lien, $align) { list ($arton, $artoff) = $logos; if (!$arton) return $artoff; if ($taille = @getimagesize($arton)) { $taille = " ".$taille[3]; } if ($artoff) $artoff = " onmouseover=\"this.src='$artoff'\" " ."onmouseout=\"this.src='$arton'\""; $milieu = "\"\""'; return (!$lien ? $milieu : ('
    ' . $milieu . '')); } // // Retrouver le logo d'un objet (et son survol) // // http://doc.spip.org/@calcule_logo function calcule_logo($type, $onoff, $id, $id_rubrique, $flag_fichier) { $chercher_logo = charger_fonction('chercher_logo', 'inc'); $nom = strtolower($onoff); while (1) { $on = $chercher_logo($id, $type, $nom); if ($on) { if ($flag_fichier) return (array('', "$on[2].$on[3]")); else { $off = ($onoff != 'ON') ? '' : $chercher_logo($id, $type, 'off'); // on retourne une url du type IMG/artonXX?timestamp // qui permet de distinguer le changement de logo // et placer un expire sur le dossier IMG/ return array ($on[0] , ($off ? $off[0] : '')); } } else if ($id_rubrique) { $type = 'id_rubrique'; $id = $id_rubrique; $id_rubrique = 0; } else if ($id AND $type == 'id_rubrique') $id = quete_parent($id); else return array('',''); } } // // fonction standard de calcul de la balise #INTRODUCTION // on peut la surcharger en definissant dans mes_fonctions : // function filtre_introduction() // // http://doc.spip.org/@filtre_introduction_dist function filtre_introduction_dist($descriptif, $texte, $longueur, $connect) { // Si un descriptif est envoye, on l'utilise directement if (strlen($descriptif)) return propre($descriptif,$connect); // Prendre un extrait dans la bonne langue $texte = extraire_multi($texte); // De preference ce qui est marque ... $intro = ''; $texte = preg_replace(",(,i", "\\1intro>", $texte); // minuscules while ($fin = strpos($texte, "")) { $zone = substr($texte, 0, $fin); $texte = substr($texte, $fin + strlen("")); if ($deb = strpos($zone, "") OR substr($zone, 0, 7) == "") $zone = substr($zone, $deb + 7); $intro .= $zone; } $texte = $intro ? $intro : $texte; // On ne *PEUT* pas couper simplement ici car c'est du texte brut, qui inclus raccourcis et modeles // un simple peut etre ensuite transforme en 1000 lignes ... // par ailleurs le nettoyage des raccourcis ne tient pas compte des surcharges // et enrichissement de propre // couper doit se faire apres propre //$texte = nettoyer_raccourcis_typo($intro ? $intro : $texte, $connect); // ne pas tenir compte des notes ; // bug introduit en http://trac.rezo.net/trac/spip/changeset/12025 $mem = array($GLOBALS['les_notes'], $GLOBALS['compt_note'], $GLOBALS['marqueur_notes'], $GLOBALS['notes_vues']); // memoriser l'etat de la pile unique $mem_unique = unique('','_spip_raz_'); $texte = propre($texte,$connect); // restituer les notes comme elles etaient avant d'appeler propre() list($GLOBALS['les_notes'], $GLOBALS['compt_note'], $GLOBALS['marqueur_notes'], $GLOBALS['notes_vues']) = $mem; // restituer l'etat de la pile unique unique($mem_unique,'_spip_set_'); @define('_INTRODUCTION_SUITE', ' (...)'); $texte = couper($texte, $longueur, _INTRODUCTION_SUITE); return $texte; } // // Balises dynamiques // // elles sont traitees comme des inclusions // http://doc.spip.org/@synthetiser_balise_dynamique function synthetiser_balise_dynamique($nom, $args, $file, $lang, $ligne) { return ('<'.'?php $lang_select = lang_select("'.$lang.'"); include_once(_DIR_RACINE . "' . $file . '"); inclure_balise_dynamique(balise_' . $nom . '_dyn(' . join(", ", array_map('argumenter_squelette', $args)) . '),1, ' . $ligne . '); if ($lang_select) lang_select(); ?' .">"); } // http://doc.spip.org/@argumenter_squelette function argumenter_squelette($v) { if (!is_array($v)) return "'" . texte_script($v) . "'"; else { $out = array(); foreach($v as $k=>$val) $out [] = argumenter_squelette($k) . '=>' . argumenter_squelette($val); return 'array(' . join(", ", $out) . ')'; } } // verifier leurs arguments et filtres, et calculer le code a inclure // http://doc.spip.org/@executer_balise_dynamique function executer_balise_dynamique($nom, $args, $filtres, $lang, $ligne) { if (!$file = find_in_path(strtolower($nom) .'.php', 'balise/', true)) { // regarder si une fonction generique n'existe pas if (($p = strpos($nom,"_")) && ($file = find_in_path(strtolower(substr($nom,0,$p+1)) .'.php', 'balise/', true))) { // dans ce cas, on lui injecte en premier arg le nom de la balise qu'on doit traiter array_unshift($args,$nom); $nom = substr($nom,0,$p+1); } else die ("pas de balise dynamique pour #". strtolower($nom)." !"); } // Y a-t-il une fonction de traitement filtres-arguments ? $f = 'balise_' . $nom . '_stat'; if (function_exists($f)) $r = $f($args, $filtres); else $r = $args; if (!is_array($r)) return $r; else { // verifier que la fonction dyn est la, sinon se replier sur la generique si elle existe if (!function_exists('balise_' . $nom . '_dyn')){ // regarder si une fonction generique n'existe pas if (($p = strpos($nom,"_")) && ($file = find_in_path(strtolower(substr($nom,0,$p+1)) .'.php', 'balise/', true))) { // dans ce cas, on lui injecte en premier arg le nom de la balise qu'on doit traiter array_unshift($r,$nom); $nom = substr($nom,0,$p+1); } else die ("pas de balise dynamique pour #". strtolower($nom)." !"); } if (!_DIR_RESTREINT) $file = _DIR_RESTREINT_ABS . $file; return synthetiser_balise_dynamique($nom, $r, $file, $lang, $ligne); } } // http://doc.spip.org/@lister_objets_avec_logos function lister_objets_avec_logos ($type) { global $formats_logos; $logos = array(); $chercher_logo = charger_fonction('chercher_logo', 'inc'); $type = '/' . type_du_logo($type) . "on(\d+)\.(" . join('|',$formats_logos) . ")$/"; if ($d = @opendir(_DIR_LOGOS)) { while($f = readdir($d)) { if (preg_match($type, $f, $r)) $logos[] = $r[1]; } } @closedir($d); return join(',',$logos); } // fonction appelee par la balise #NOTES // http://doc.spip.org/@calculer_notes function calculer_notes() { if (!isset($GLOBALS["les_notes"])) return ''; if ($r = $GLOBALS["les_notes"]) { $GLOBALS["les_notes"] = ""; $GLOBALS["compt_note"] = 0; $GLOBALS["marqueur_notes"] ++; } return $r; } // Si un tableau &doublons[articles] est passe en parametre, // il faut le nettoyer car il pourrait etre injecte en SQL // http://doc.spip.org/@nettoyer_env_doublons function nettoyer_env_doublons($envd) { foreach ($envd as $table => $liste) { $n = ''; foreach(explode(',',$liste) as $val) { if ($a = intval($val) AND $val === strval($a)) $n.= ','.$val; } if (strlen($n)) $envd[$table] = $n; else unset($envd[$table]); } return $envd; } // http://doc.spip.org/@match_self function match_self($w){ if (is_string($w)) return false; if (is_array($w)) { if (reset($w)=="SELF") return $w; foreach($w as $sw) if ($m=match_self($sw)) return $m; } return false; } // http://doc.spip.org/@remplace_sous_requete function remplace_sous_requete($w,$sousrequete){ if (is_array($w)) { if (reset($w)=="SELF") return $sousrequete; foreach($w as $k=>$sw) $w[$k] = remplace_sous_requete($sw,$sousrequete); } return $w; } // http://doc.spip.org/@trouver_sous_requetes function trouver_sous_requetes($where){ $where_simples = array(); $where_sous = array(); foreach($where as $k=>$w){ if (match_self($w)) $where_sous[$k] = $w; else $where_simples[$k] = $w; } return array($where_simples,$where_sous); } // La fonction presente dans les squelettes compiles // http://doc.spip.org/@calculer_select function calculer_select ($select = array(), $from = array(), $from_type = array(), $where = array(), $join=array(), $groupby = array(), $orderby = array(), $limit = '', $having=array(), $table = '', $id = '', $serveur='', $requeter=true) { // retirer les criteres vides: // {X ?} avec X absent de l'URL // {par #ENV{X}} avec X absent de l'URL // IN sur collection vide (ce dernier devrait pouvoir etre fait a la compil) $menage = false; foreach($where as $k => $v) { if (is_array($v)){ if ((count($v)>=2) && ($v[0]=='REGEXP') && ($v[2]=="'.*'")) $op= false; elseif ((count($v)>=2) && ($v[0]=='LIKE') && ($v[2]=="'%'")) $op= false; else $op = $v[0] ? $v[0] : $v; } else $op = $v; if ((!$op) OR ($op==1) OR ($op=='0=0')) { unset($where[$k]); $menage = true; } } // remplacer les sous requetes recursives au calcul list($where_simples,$where_sous) = trouver_sous_requetes($where); //var_dump($where_sous); foreach($where_sous as $k=>$w) { $menage = true; // on recupere la sous requete $sous = match_self($w); array_push($where_simples,$sous[2]); $where[$k] = remplace_sous_requete($w,"(".calculer_select($sous[1],$from,$from_type,array($sous[2],'0=0'),$join,array(),array(),'',$having,$table,$id,$serveur,false).")"); array_pop($where_simples); } //var_dump($where); foreach($having as $k => $v) { if ((!$v) OR ($v==1) OR ($v=='0=0')) { unset($having[$k]); } } // Installer les jointures. // Retirer celles seulement utiles aux criteres finalement absents mais // parcourir de la plus recente a la moins recente pour pouvoir eliminer Ln // si elle est seulement utile a Ln+1 elle meme inutile $afrom = array(); $equiv = array(); $k = count($join); foreach(array_reverse($join,true) as $cledef=>$j) { $cle = $cledef; // le format de join est : // array(table depart, cle depart [,cle arrivee[,condition optionnelle and ...]]) list($t,$c,$carr,$and) = $join[$cle]; if (!$carr) $carr = $c; // si le nom de la jointure n'a pas ete specifiee, on prend Lx avec x sont rang dans la liste // pour compat avec ancienne convention if (is_numeric($cle)) $cle = "L$k"; if (!$menage OR isset($afrom[$cle]) OR calculer_jointnul($cle, $select) OR calculer_jointnul($cle, array_diff($join,array($cle=>$join[$cle]))) OR calculer_jointnul($cle, $having) OR calculer_jointnul($cle, $where_simples)) { // on garde une ecriture decomposee pour permettre une simplification ulterieure si besoin // sans recours a preg_match // un implode(' ',..) est fait dans reinjecte_joint un peu plus bas $afrom[$t][$cle] = array("\n" . (isset($from_type[$cle])?$from_type[$cle]:"INNER")." JOIN", $from[$cle], "AS $cle", "ON (", "$cle.$c", "=", "$t.$carr", ($and ? "AND ". $and:"") . ")"); if (isset($afrom[$cle])){ $afrom[$t] = $afrom[$t] + $afrom[$cle]; unset($afrom[$cle]); } $equiv[]= $carr; } else { unset($join[$cledef]);} unset($from[$cle]); $k--; } if (count($afrom)) { // Regarder si la table principale ne sert finalement a rien comme dans // class='on' //#TOTAL_BOUCLE //#TOTAL_BOUCLE // ou dans //#TOTAL_BOUCLE // qui comporte plusieurs jointures // ou dans // #TOTAL_BOUCLE // 0}{statut?} />#TOTAL_BOUCLE // penser a regarder aussi la clause orderby pour ne pas simplifier abusivement // #ID_ARTICLE // penser a regarder aussi la clause groubpy pour ne pas simplifier abusivement // #TOTAL_BOUCLE list($t,$c) = each($from); reset($from); $e = '/\b(' . "$t\\." . join("|" . $t . '\.', $equiv) . ')\b/'; if (!(strpos($t, ' ') OR // jointure des le depart cf boucle_doc calculer_jointnul($t, $select, $e) OR calculer_jointnul($t, $join, $e) OR calculer_jointnul($t, $where, $e) OR calculer_jointnul($t, $orderby, $e) OR calculer_jointnul($t, $groupby, $e) OR calculer_jointnul($t, $having, $e)) && count($afrom[$t])) { reset($afrom[$t]); list($nt,$nfrom) = each($afrom[$t]); unset($from[$t]); $from[$nt] = $nfrom[1]; unset($afrom[$t][$nt]); $afrom[$nt] = $afrom[$t]; unset($afrom[$t]); $e = '/\b'.preg_quote($nfrom[6]).'\b/'; $t = $nfrom[4]; $alias = ""; // verifier que les deux cles sont homonymes, sinon installer un alias dans le select $oldcle = explode('.',$nfrom[6]); $oldcle = end($oldcle); $newcle = explode('.',$nfrom[4]); $newcle = end($newcle); if ($newcle!=$oldcle){ $alias = ", ".$nfrom[4]." AS $oldcle"; } $select = remplacer_jointnul($t . $alias, $select, $e); $join = remplacer_jointnul($t, $join, $e); $where = remplacer_jointnul($t, $where, $e); $having = remplacer_jointnul($t, $having, $e); $groupby = remplacer_jointnul($t, $groupby, $e); $orderby = remplacer_jointnul($t, $orderby, $e); } $from = reinjecte_joint($afrom, $from); } $GLOBALS['debug']['aucasou'] = array ($table, $id, $serveur); $r = sql_select($select, $from, $where, $groupby, array_filter($orderby), $limit, $having, $serveur, $requeter); unset($GLOBALS['debug']['aucasou']); return $r; } //condition suffisante (mais non necessaire) pour qu'une table soit utile // http://doc.spip.org/@calculer_jointnul function calculer_jointnul($cle, $exp, $equiv='') { if (!is_array($exp)) { if ($equiv) $exp = preg_replace($equiv, '', $exp); return preg_match("/\\b$cle\\./", $exp); } else { foreach($exp as $v) { if (calculer_jointnul($cle, $v, $equiv)) return true; } return false; } } // http://doc.spip.org/@reinjecte_joint function reinjecte_joint($afrom, $from) { $from_synth = array(); foreach($from as $k=>$v){ $from_synth[$k]=$from[$k]; if (isset($afrom[$k])) { foreach($afrom[$k] as $kk=>$vv) $afrom[$k][$kk] = implode(' ',$afrom[$k][$kk]); $from_synth["$k@"]= implode(' ',$afrom[$k]); unset($afrom[$k]); } } return $from_synth; } // http://doc.spip.org/@remplacer_jointnul function remplacer_jointnul($cle, $exp, $equiv='') { if (!is_array($exp)) { return preg_replace($equiv, $cle, $exp); } else { foreach($exp as $k => $v) { $exp[$k] = remplacer_jointnul($cle, $v, $equiv); } return $exp; } } // calcul du nom du squelette // http://doc.spip.org/@calculer_nom_fonction_squel function calculer_nom_fonction_squel($skel, $mime_type='html', $connect='') { // ne pas doublonner les squelette selon qu'ils sont calcules depuis ecrire/ ou depuis la racine if (strlen(_DIR_RACINE) AND substr($skel,0,strlen(_DIR_RACINE))==_DIR_RACINE) $skel = substr($skel,strlen(_DIR_RACINE)); return $mime_type . (!$connect ? '' : preg_replace('/\W/',"_", $connect)) . '_' . md5($GLOBALS['spip_version_code'] . ' * ' . $skel); } ?> spip/spip/ecrire/public/criteres.php0000766000000000000000000011725511236524730020772 0ustar adminadministratorsnot; $boucle = &$boucles[$idb]; $id_parent = isset($exceptions_des_tables[$boucle->id_table]['id_parent']) ? $exceptions_des_tables[$boucle->id_table]['id_parent'] : 'id_parent'; if ($not) erreur_squelette(_T('zbug_info_erreur_squelette'), $crit->op); $boucle->where[]= array("'='", "'$boucle->id_table." . "$id_parent'", 0); } // {exclus} // http://www.spip.net/@exclus // http://doc.spip.org/@critere_exclus_dist function critere_exclus_dist($idb, &$boucles, $crit) { $param = $crit->op; $not = $crit->not; $boucle = &$boucles[$idb]; $id = $boucle->primary; if ($not OR !$id) erreur_squelette(_T('zbug_info_erreur_squelette'), $param); $arg = kwote(calculer_argument_precedent($idb, $id, $boucles)); $boucle->where[]= array("'!='", "'$boucle->id_table." . "$id'", $arg); } // {doublons} ou {unique} // http://www.spip.net/@doublons // attention: boucle->doublons designe une variable qu'on affecte // http://doc.spip.org/@critere_doublons_dist function critere_doublons_dist($idb, &$boucles, $crit) { $boucle = &$boucles[$idb]; $primary = $boucle->primary; if (!$primary OR strpos($primary,',')) { erreur_squelette(_T('zbug_doublon_sur_table_sans_cle_primaire'), "BOUCLE$idb"); return; } $not = ($crit->not ? '' : 'NOT'); $nom = !isset($crit->param[0]) ? "''" : calculer_liste($crit->param[0], array(), $boucles, $boucles[$idb]->id_parent); // mettre un tableau pour que ce ne soit pas vu comme une constante $nom = "'" . $boucle->type_requete . "'" . ($nom == "''" ? '' : " . $nom"); $debutdoub = '$doublons[' . (!$not ? '' : ($boucle->doublons . "[]= ")); $findoub = "($nom)]"; $debin = "sql_in('" . $boucle->id_table . '.' . $primary . "', "; $suitin = $debin . $debutdoub; // si autre critere doublon, fusionner pour avoir un seul In foreach ($boucle->where as $k => $w) { if (strpos($w[0], $suitin) ===0) { $boucle->where[$k][0] = $debin . $debutdoub . $findoub . ' . ' . substr($w[0],strlen($debin)); return; } } $boucle->where[]= array($suitin . $findoub . ", '" . $not . "')"); # la ligne suivante avait l'intention d'eviter une collecte deja faite # mais elle fait planter une boucle a 2 critere doublons: # {!doublons A}{doublons B} # (de http://article.gmane.org/gmane.comp.web.spip.devel/31034) # if ($crit->not) $boucle->doublons = ""; } // {lang_select} // http://www.spip.net/@lang_select // http://doc.spip.org/@critere_lang_select_dist function critere_lang_select_dist($idb, &$boucles, $crit) { if (!($param = $crit->param[1][0]->texte)) $param = 'oui'; if ($crit->not) $param = ($param=='oui') ? 'non' : 'oui'; $boucle = &$boucles[$idb]; $boucle->lang_select = $param; } // {debut_xxx} // http://www.spip.net/@debut_ // http://doc.spip.org/@critere_debut_dist function critere_debut_dist($idb, &$boucles, $crit) { list($un, $deux) = $crit->param; $un = $un[0]->texte; $deux = $deux[0]->texte; if ($deux) { $boucles[$idb]->limit = 'intval($Pile[0]["debut' . $un . '"]) . ",' . $deux . '"' ; } else calculer_critere_DEFAUT($idb, $boucles, $crit); } // {pagination} // {pagination 20} // {pagination #ENV{pages,5}} etc // {pagination 20 #ENV{truc,chose}} pour utiliser la variable debut_#ENV{truc,chose} // http://www.spip.net/@pagination // http://doc.spip.org/@critere_pagination_dist function critere_pagination_dist($idb, &$boucles, $crit) { // definition de la taille de la page $pas = !isset($crit->param[0][0]) ? "''" : calculer_liste(array($crit->param[0][0]), array(), $boucles, $boucles[$idb]->id_parent); if (!preg_match("/^'([^']*)'$/", $pas, $r)) { $pas = "((\$a = intval($pas)) ? \$a : 10)"; } else { $r = intval($r[1]); $pas = strval($r ? $r : 10); } $debut = !isset($crit->param[0][1]) ? "'$idb'" : calculer_liste(array($crit->param[0][1]), array(), $boucles, $boucles[$idb]->id_parent); $boucle = &$boucles[$idb]; $boucle->mode_partie = 'p+'; $boucle->partie = 'intval(isset($Pile[0][\'debut\'.'.$debut.']) ? $Pile[0][\'debut\'.'.$debut.'] : _request(\'debut\'.'.$debut.'))'; $boucle->modificateur['debut_nom'] = $debut; $boucle->total_parties = $pas; } // {recherche} ou {recherche susan} // http://www.spip.net/@recherche // http://doc.spip.org/@critere_recherche_dist function critere_recherche_dist($idb, &$boucles, $crit) { $boucle = &$boucles[$idb]; if (isset($crit->param[0])) $quoi = calculer_liste($crit->param[0], array(), $boucles, $boucles[$idb]->id_parent); else $quoi = '@$Pile[0]["recherche"]'; $boucle->hash .= ' // RECHERCHE $prepare_recherche = charger_fonction(\'prepare_recherche\', \'inc\'); list($rech_select, $rech_where) = $prepare_recherche('.$quoi.', "'.$boucle->id_table.'", "'.$crit->cond.'","' . $boucle->sql_serveur . '"); '; $t = $boucle->id_table . '.' . $boucle->primary; if (!in_array($t, $boucles[$idb]->select)) $boucle->select[]= $t; # pour postgres, neuneu ici $boucle->join['resultats']=array("'".$boucle->id_table."'","'id'","'".$boucle->primary."'"); $boucle->from['resultats']='spip_resultats'; $boucle->select[]= '$rech_select'; //$boucle->where[]= "\$rech_where?'resultats.id=".$boucle->id_table.".".$boucle->primary."':''"; // et la recherche trouve $boucle->where[]= '$rech_where?$rech_where:\'\''; } // {traduction} // http://www.spip.net/@traduction // (id_trad>0 AND id_trad=id_trad(precedent)) // OR id_article=id_article(precedent) // http://doc.spip.org/@critere_traduction_dist function critere_traduction_dist($idb, &$boucles, $crit) { $boucle = &$boucles[$idb]; $prim = $boucle->primary; $table = $boucle->id_table; $arg = kwote(calculer_argument_precedent($idb, 'id_trad', $boucles)); $dprim = kwote(calculer_argument_precedent($idb, $prim, $boucles)); $boucle->where[]= array("'OR'", array("'AND'", array("'='", "'$table.id_trad'", 0), array("'='", "'$table.$prim'", $dprim) ), array("'AND'", array("'>'", "'$table.id_trad'", 0), array("'='", "'$table.id_trad'", $arg) ) ); } // {origine_traduction} // (id_trad>0 AND id_article=id_trad) OR (id_trad=0) // http://www.spip.net/@origine_traduction // http://doc.spip.org/@critere_origine_traduction_dist function critere_origine_traduction_dist($idb, &$boucles, $crit) { $boucle = &$boucles[$idb]; $prim = $boucle->primary; $table = $boucle->id_table; $c = array("'OR'", array("'='", "'$table." . "id_trad'", "'$table.$prim'"), array("'='", "'$table.id_trad'", "'0'") ); $boucle->where[]= ($crit->not ? array("'NOT'", $c) : $c); } // {meme_parent} // http://www.spip.net/@meme_parent // http://doc.spip.org/@critere_meme_parent_dist function critere_meme_parent_dist($idb, &$boucles, $crit) { global $exceptions_des_tables; $boucle = &$boucles[$idb]; $arg = kwote(calculer_argument_precedent($idb, 'id_parent', $boucles)); $id_parent = isset($exceptions_des_tables[$boucle->id_table]['id_parent']) ? $exceptions_des_tables[$boucle->id_table]['id_parent'] : 'id_parent'; $mparent = $boucle->id_table . '.' . $id_parent; if ($boucle->type_requete == 'rubriques' OR isset($exceptions_des_tables[$boucle->id_table]['id_parent'])) { $boucle->where[]= array("'='", "'$mparent'", $arg); } else if ($boucle->type_requete == 'forums') { $boucle->where[]= array("'='", "'$mparent'", $arg); $boucle->where[]= array("'>'", "'$mparent'", 0); $boucle->modificateur['plat'] = true; } else erreur_squelette(_T('zbug_info_erreur_squelette'), "{meme_parent} BOUCLE$idb"); } // {branche ?} // http://www.spip.net/@branche // http://doc.spip.org/@critere_branche_dist function critere_branche_dist($idb, &$boucles, $crit) { $not = $crit->not; $boucle = &$boucles[$idb]; $arg = calculer_argument_precedent($idb, 'id_rubrique', $boucles); //Trouver une jointure $desc = $boucle->show; //Seulement si necessaire if (!array_key_exists('id_rubrique', $desc['field'])) { $cle = trouver_jointure_champ('id_rubrique', $boucle); } else $cle = $boucle->id_table; $c = "sql_in('$cle" . ".id_rubrique', calcul_branche_in($arg)" . ($not ? ", 'NOT'" : '') . ")"; $boucle->where[]= !$crit->cond ? $c : ("($arg ? $c : " . ($not ? "'0=1'" : "'1=1'") .')'); } // {logo} liste les objets qui ont un logo // http://doc.spip.org/@critere_logo_dist function critere_logo_dist($idb, &$boucles, $crit) { $not = $crit->not; $boucle = &$boucles[$idb]; $c = "sql_in('" . $boucle->id_table . '.' . $boucle->primary . "', lister_objets_avec_logos('". $boucle->primary ."'), '')"; if ($crit->cond) $c = "($arg ? $c : 1)"; if ($not) $boucle->where[]= array("'NOT'", $c); else $boucle->where[]= $c; } // c'est la commande SQL "GROUP BY" // par exemple // http://doc.spip.org/@critere_fusion_dist function critere_fusion_dist($idb,&$boucles, $crit) { if ($t = isset($crit->param[0])) { $t = $crit->param[0]; if ($t[0]->type == 'texte') { $t = $t[0]->texte; if (preg_match("/^(.*)\.(.*)$/", $t, $r)) { $t = table_objet_sql($r[1]); $t = array_search($t, $boucles[$idb]->from); if ($t) $t .= '.' . $r[2]; } } else { $t = '".' . calculer_critere_arg_dynamique($idb, $boucles, $t) . '."'; } } if ($t) { $boucles[$idb]->group[] = $t; if (!in_array($t, $boucles[$idb]->select)) $boucles[$idb]->select[] = $t; } else erreur_squelette(_T('zbug_info_erreur_squelette'), "{groupby ?} BOUCLE$idb"); } // c'est la commande SQL "COLLATE" // qui peut etre appliquee sur les order by, group by, where like ... // http://doc.spip.org/@critere_collecte_dist function critere_collecte_dist($idb,&$boucles, $crit) { if (isset($crit->param[0])) { $_coll = calculer_liste($crit->param[0], array(), $boucles, $boucles[$idb]->id_parent); $boucle = $boucles[$idb]; $boucle->modificateur['collate'] = "($_coll ?' COLLATE '.$_coll:'')"; $n = count($boucle->order); if ($n && (strpos($boucle->order[$n-1],'COLLATE')===false)) $boucle->order[$n-1] .= " . " . $boucle->modificateur['collate']; } else erreur_squelette(_T('zbug_info_erreur_squelette'), "{collecte ?} BOUCLE$idb"); } // http://doc.spip.org/@calculer_critere_arg_dynamique function calculer_critere_arg_dynamique($idb, &$boucles, $crit, $suffix='') { $boucle = $boucles[$idb]; $alt = "('" . $boucle->id_table . '.\' . $x' . $suffix . ')'; $var = '$champs_' . $idb; $desc = (strpos($boucle->in, "static $var =") !== false); if (!$desc) { $desc = $boucle->show['field']; $desc = implode(',',array_map('_q',array_keys($desc))); $boucles[$idb]->in .= "\n\tstatic $var = array(" . $desc .");"; } if ($desc) $alt = "(in_array(\$x, $var) ? $alt :(\$x$suffix))"; $arg = calculer_liste($crit, array(), $boucles, $boucle->id_parent); return "((\$x = preg_replace(\"/\\W/\",'', $arg)) ? $alt : '')"; } // Tri : {par xxxx} // http://www.spip.net/@par // http://doc.spip.org/@critere_par_dist function critere_par_dist($idb, &$boucles, $crit) { critere_parinverse($idb, $boucles, $crit) ; } // http://doc.spip.org/@critere_parinverse function critere_parinverse($idb, &$boucles, $crit, $sens='') { global $exceptions_des_jointures; $boucle = &$boucles[$idb]; if ($crit->not) $sens = $sens ? "" : " . ' DESC'"; $collecte = (isset($boucle->modificateur['collecte']))?" . ".$boucle->modificateur['collecte']:""; foreach ($crit->param as $tri) { $order = $fct = ""; // en cas de fonction SQL // tris specifies dynamiquement if ($tri[0]->type != 'texte') { // calculer le order dynamique qui verifie les champs $order = calculer_critere_arg_dynamique($idb, $boucles, $tri, $sens); // et si ce n'est fait, ajouter un champ 'hasard' // pour supporter 'hasard' comme tri dynamique $par = "rand()"; $parha = $par . " AS hasard"; if (!in_array($parha, $boucle->select)) $boucle->select[]= $parha; } else { $par = array_shift($tri); $par = $par->texte; // par multi champ if (preg_match(",^multi[\s]*(.*)$,",$par, $m)) { $texte = $boucle->id_table . '.' . trim($m[1]); $boucle->select[] = "\".sql_multi('".$texte."', \$GLOBALS['spip_lang']).\"" ; $order = "'multi'"; // par num champ(, suite) } else if (preg_match(",^num (.*)$,m",$par, $m)) { $texte = '0+' . $boucle->id_table . '.' . trim($m[1]); $suite = calculer_liste($tri, array(), $boucles, $boucle->id_parent); if ($suite !== "''") $texte = "\" . ((\$x = $suite) ? ('$texte' . \$x) : '0')" . " . \""; $as = 'num' .($boucle->order ? count($boucle->order) : ""); $boucle->select[] = $texte . " AS $as"; $order = "'$as'"; } else { if (!preg_match(",^" . CHAMP_SQL_PLUS_FONC . '$,is', $par, $match)) erreur_squelette(_T('zbug_info_erreur_squelette'), "{par $par} BOUCLE$idb"); else { if (count($match)>2) { $par = substr($match[2],1,-1); $fct = $match[1]; } // par hasard if ($par == 'hasard') { $par = "rand()"; $boucle->select[]= $par . " AS alea"; $order = "'alea'"; } // par titre_mot ou type_mot voire d'autres else if (isset($exceptions_des_jointures[$par])) { list($table, $champ) = $exceptions_des_jointures[$par]; $order = critere_par_joint($table, $champ, $boucle, $idb); } else if ($par == 'date' AND isset($GLOBALS['table_date'][$boucle->type_requete])) { $m = $GLOBALS['table_date'][$boucle->type_requete]; $order = "'".$boucle->id_table ."." . $m . "'"; } // par champ. Verifier qu'ils sont presents. elseif (preg_match("/^([^,]*)\.(.*)$/", $par, $r)) { // cas du tri sur champ de jointure explicite $t = array_search($r[1], $boucle->from); if (!$t) { $t = trouver_champ_exterieur($r[2], array($r[1]), $boucle); $t = array_search(@$t[0], $boucle->from); } if (!$t) { erreur_squelette(_T('zbug_info_erreur_squelette'), "{par $par } BOUCLE$idb"); $order = ''; } else $order = "'" . $t . '.' . $r[2] . "'"; } else { $desc = $boucle->show; if ($desc['field'][$par]) $par = $boucle->id_table.".".$par; // sinon tant pis, ca doit etre un champ synthetise (cf points) $order = "'$par'"; } } } } if (preg_match('/^\'([^"]*)\'$/', $order, $m)) { $t = $m[1]; if (strpos($t,'.') AND !in_array($t, $boucle->select)) { $boucle->select[] = $t; } } else $sens =''; if ($fct) { if (preg_match("/^\s*'(.*)'\s*$/", $order, $r)) $order = "'$fct(" . $r[1] . ")'"; else $order = "'$fct(' . $order . ')'"; } $t = $order . $collecte . $sens; if (preg_match("/^(.*)'\s*\.\s*'([^']*')$/", $t, $r)) $t = $r[1] . $r[2]; $boucle->order[] = $t; } } // http://doc.spip.org/@critere_par_joint function critere_par_joint($table, $champ, &$boucle, $idb) { $t = array_search($table, $boucle->from); if (!$t) $t = trouver_jointure_champ($champ, $boucle); if (!$t) erreur_squelette(_T('zbug_info_erreur_squelette'), "{par ?} BOUCLE$idb"); return "'" . $t . '.' . $champ . "'"; } // {inverse} // http://www.spip.net/@inverse // http://doc.spip.org/@critere_inverse_dist function critere_inverse_dist($idb, &$boucles, $crit) { $boucle = &$boucles[$idb]; // Classement par ordre inverse if ($crit->not) critere_parinverse($idb, $boucles, $crit); else { $order = "' DESC'"; // Classement par ordre inverse fonction eventuelle de #ENV{...} if (isset($crit->param[0])){ $critere = calculer_liste($crit->param[0], array(), $boucles, $boucles[$idb]->id_parent); $order = "(($critere)?' DESC':'')"; } $n = count($boucle->order); if (!$n) $boucle->default_order[] = ' DESC'; else { $t = $boucle->order[$n-1] . " . $order"; if (preg_match("/^(.*)'\s*\.\s*'([^']*')$/", $t, $r)) $t = $r[1] . $r[2]; $boucle->order[$n-1] = $t; } } } // http://doc.spip.org/@critere_agenda_dist function critere_agenda_dist($idb, &$boucles, $crit) { $params = $crit->param; if (count($params) < 1) erreur_squelette(_T('zbug_info_erreur_squelette'), "{agenda ?} BOUCLE$idb"); $parent = $boucles[$idb]->id_parent; // les valeurs $date et $type doivent etre connus a la compilation // autrement dit ne pas etre des champs $date = array_shift($params); $date = $date[0]->texte; $type = array_shift($params); $type = $type[0]->texte; $annee = $params ? array_shift($params) : ""; $annee = "\n" . 'sprintf("%04d", ($x = ' . calculer_liste($annee, array(), $boucles, $parent) . ') ? $x : date("Y"))'; $mois = $params ? array_shift($params) : ""; $mois = "\n" . 'sprintf("%02d", ($x = ' . calculer_liste($mois, array(), $boucles, $parent) . ') ? $x : date("m"))'; $jour = $params ? array_shift($params) : ""; $jour = "\n" . 'sprintf("%02d", ($x = ' . calculer_liste($jour, array(), $boucles, $parent) . ') ? $x : date("d"))'; $annee2 = $params ? array_shift($params) : ""; $annee2 = "\n" . 'sprintf("%04d", ($x = ' . calculer_liste($annee2, array(), $boucles, $parent) . ') ? $x : date("Y"))'; $mois2 = $params ? array_shift($params) : ""; $mois2 = "\n" . 'sprintf("%02d", ($x = ' . calculer_liste($mois2, array(), $boucles, $parent) . ') ? $x : date("m"))'; $jour2 = $params ? array_shift($params) : ""; $jour2 = "\n" . 'sprintf("%02d", ($x = ' . calculer_liste($jour2, array(), $boucles, $parent) . ') ? $x : date("d"))'; $boucle = &$boucles[$idb]; $date = $boucle->id_table . ".$date"; if ($type == 'jour') $boucle->where[]= array("'='", "'DATE_FORMAT($date, \'%Y%m%d\')'", ("$annee . $mois . $jour")); elseif ($type == 'mois') $boucle->where[]= array("'='", "'DATE_FORMAT($date, \'%Y%m\')'", ("$annee . $mois")); elseif ($type == 'semaine') $boucle->where[]= array("'AND'", array("'>='", "'DATE_FORMAT($date, \'%Y%m%d\')'", ("date_debut_semaine($annee, $mois, $jour)")), array("'<='", "'DATE_FORMAT($date, \'%Y%m%d\')'", ("date_fin_semaine($annee, $mois, $jour)"))); elseif (count($crit->param) > 2) $boucle->where[]= array("'AND'", array("'>='", "'DATE_FORMAT($date, \'%Y%m%d\')'", ("$annee . $mois . $jour")), array("'<='", "'DATE_FORMAT($date, \'%Y%m%d\')'", ("$annee2 . $mois2 . $jour2"))); // sinon on prend tout } // http://doc.spip.org/@calculer_critere_parties function calculer_critere_parties($idb, &$boucles, $crit) { $boucle = &$boucles[$idb]; $a1 = $crit->param[0]; $a2 = $crit->param[1]; $op = $crit->op; list($a11,$a12) = calculer_critere_parties_aux($idb, $boucles, $a1); list($a21,$a22) = calculer_critere_parties_aux($idb, $boucles, $a2); if (($op== ',')&&(is_numeric($a11) && (is_numeric($a21)))) $boucle->limit = $a11 .',' . $a21; else { $boucle->partie = ($a11 != 'n') ? $a11 : $a12; $boucle->total_parties = ($a21 != 'n') ? $a21 : $a22; $boucle->mode_partie = (($op == '/') ? '/' : (($a11=='n') ? '-' : '+').(($a21=='n') ? '-' : '+')); } } // http://doc.spip.org/@calculer_critere_parties_aux function calculer_critere_parties_aux($idb, &$boucles, $param) { if ($param[0]->type != 'texte') { $a1 = calculer_liste(array($param[0]), array('id_mere' => $idb), $boucles, $boucles[$idb]->id_parent); preg_match(',^ *(-([0-9]+))? *$,', $param[1]->texte, $m); return array("intval($a1)", ($m[2] ? $m[2] : 0)); } else { preg_match(',^ *(([0-9]+)|n) *(- *([0-9]+)? *)?$,', $param[0]->texte, $m); $a1 = $m[1]; if (!@$m[3]) return array($a1, 0); elseif ($m[4]) return array($a1, $m[4]); else return array($a1, calculer_liste(array($param[1]), array(), $boucles[$idb]->id_parent, $boucles)); } } // // La fonction d'aiguillage sur le nom du critere // // http://doc.spip.org/@calculer_criteres function calculer_criteres ($idb, &$boucles) { foreach($boucles[$idb]->criteres as $crit) { $critere = $crit->op; // critere personnalise ? if ( (!function_exists($f="critere_".strtoupper($boucles[$idb]->id_table)."_".$critere)) AND (!function_exists($f=$f."_dist")) AND (!function_exists($f="critere_".$critere)) AND (!function_exists($f=$f."_dist")) ) { // fonction critere standard ? // double cas particulier repere a l'analyse lexicale if (($critere == ",") OR ($critere == '/')) $f = 'calculer_critere_parties'; else $f = 'calculer_critere_DEFAUT'; } // Applique le critere $res = $f($idb, $boucles, $crit); // Gestion d'erreur if (is_array($res)) erreur_squelette($res); } } // Madeleine de Proust, revision MIT-1958 sqq, revision CERN-1989 // hum, c'est kwoi cette fonxion ? // http://doc.spip.org/@kwote function kwote($lisp) { if (preg_match(",^(\n//[^\n]*\n)? *'(.*)' *$,", $lisp, $r)) return $r[1] . "\"" . sql_quote(str_replace(array("\\'","\\\\"),array("'","\\"),$r[2])) . "\"" ; else return "sql_quote($lisp)"; } // Si on a une liste de valeurs dans #ENV{x}, utiliser la double etoile // pour faire par exemple {id_article IN #ENV**{liste_articles}} // http://doc.spip.org/@critere_IN_dist function critere_IN_dist ($idb, &$boucles, $crit) { list($arg, $op, $val, $col, $where_complement)= calculer_critere_infixe($idb, $boucles, $crit); $in = critere_IN_cas($idb, $boucles, $crit->not ? 'NOT' : '', $arg, $op, $val, $col); // inserer la condition; exemple: {id_mot ?IN (66, 62, 64)} $where = $in; if ($crit->cond) { $pred = calculer_argument_precedent($idb, $col, $boucles); $where = array("'?'",$pred, $where,"''"); if ($where_complement) // condition annexe du type "AND (objet='article')" $where_complement = array("'?'",$pred, $where_complement,"''"); } if ($crit->exclus) if (!preg_match(",^L[0-9]+[.],",$arg)) $where = array("'NOT'", $where); else // un not sur un critere de jointure se traduit comme un NOT IN avec une sous requete $where = array("'NOT'",array("'IN'","'".$boucles[$idb]->id_table.".".$boucles[$idb]->primary."'" ,array("'SELF'","'".$boucles[$idb]->id_table.".".$boucles[$idb]->primary."'",$where))); $boucles[$idb]->where[] = $where; if ($where_complement) // condition annexe du type "AND (objet='article')" $boucles[$idb]->where[]= $where_complement; } // http://doc.spip.org/@critere_IN_cas function critere_IN_cas ($idb, &$boucles, $crit2, $arg, $op, $val, $col) { static $cpt = 0; $var = '$in' . $cpt++; $x= "\n\t$var = array();"; foreach ($val as $k => $v) { if (preg_match(",^(\n//.*\n)?'(.*)'$,", $v, $r)) { // optimiser le traitement des constantes if (is_numeric($r[2])) $x .= "\n\t$var" . "[]= $r[2];"; else $x .= "\n\t$var" . "[]= " . sql_quote($r[2]) . ";"; } else { // Pour permettre de passer des tableaux de valeurs // on repere l'utilisation brute de #ENV**{X}, // c'est-a-dire sa traduction en ($PILE[0][X]). // et on deballe mais en rajoutant l'anti XSS $x .= "\n\tif (!(is_array(\$a = ($v))))\n\t\t$var" ."[]= \$a;\n\telse $var = array_merge($var, \$a);"; } } $boucles[$idb]->in .= $x; // inserer le tri par defaut selon les ordres du IN ... // avec une ecriture de type FIELD qui degrade les performances (du meme ordre qu'un rexgexp) // et que l'on limite donc strictement aux cas necessaires : // si ce n'est pas un !IN, et si il n'y a pas d'autre order dans la boucle if (!$crit2){ $boucles[$idb]->default_order[] = "((!sql_quote($var) OR sql_quote($var)===\"''\") ? 0 : ('FIELD($arg,' . sql_quote($var) . ')'))"; } return "sql_in('$arg',sql_quote($var)".($crit2=='NOT'?",'NOT'":"").")"; } # Criteres de comparaison // http://doc.spip.org/@calculer_critere_DEFAUT function calculer_critere_DEFAUT($idb, &$boucles, $crit) { list($arg, $op, $val, $col, $where_complement)= calculer_critere_infixe($idb, $boucles, $crit); $where = array("'$op'", "'$arg'", $val[0]); // inserer la negation (cf !...) if ($crit->not) $where = array("'NOT'", $where); if ($crit->exclus) if (!preg_match(",^L[0-9]+[.],",$arg)) $where = array("'NOT'", $where); else // un not sur un critere de jointure se traduit comme un NOT IN avec une sous requete $where = array("'NOT'",array("'IN'","'".$boucles[$idb]->id_table.".".$boucles[$idb]->primary."'" ,array("'SELF'","'".$boucles[$idb]->id_table.".".$boucles[$idb]->primary."'",$where))); // inserer la condition (cf {lang?}) // traiter a part la date, elle est mise d'office par SPIP, if ($crit->cond) { $pred = calculer_argument_precedent($idb, $col, $boucles); if ($col == "date" OR $col == "date_redac") { if($pred == "\$Pile[0]['".$col."']") { $pred = "(\$Pile[0]['{$col}_default']?'':$pred)"; } } if ($op == '=' AND !$crit->not) $where = array("'?'", "(is_array($pred))", critere_IN_cas ($idb, $boucles, 'COND', $arg, $op, array($pred), $col), $where); $where = array("'?'", "!$pred","''", $where); if ($where_complement) // condition annexe du type "AND (objet='article')" $where_complement = array("'?'", "!$pred","''", $where_complement); } $boucles[$idb]->where[]= $where; if ($where_complement) // condition annexe du type "AND (objet='article')" $boucles[$idb]->where[]= $where_complement; } // http://doc.spip.org/@calculer_critere_infixe function calculer_critere_infixe($idb, &$boucles, $crit) { global $table_criteres_infixes; global $exceptions_des_jointures, $exceptions_des_tables; $boucle = &$boucles[$idb]; $type = $boucle->type_requete; $table = $boucle->id_table; $desc = $boucle->show; $date = array(); list($fct, $col, $op, $val, $args_sql) = calculer_critere_infixe_ops($idb, $boucles, $crit); $col_alias = $col; $where_complement =false; //var_dump(array($fct, $col, $op, $val, $args_sql)); // Cas particulier : id_enfant => utiliser la colonne id_objet if ($col == 'id_enfant') $col = $boucle->primary; // Cas particulier : id_parent => verifier les exceptions de tables if ($col == 'id_parent') $col = isset($exceptions_des_tables[$table]['id_parent']) ? $exceptions_des_tables[$table]['id_parent'] : 'id_parent'; // Cas particulier : id_secteur pour certaines tables else if (($col == 'id_secteur')&&($type == 'breves')) { $col = 'id_rubrique'; } else if (($col == 'id_secteur')&& ($type == 'forums')) { $table = critere_secteur_forum($idb, $boucles, $val, $crit); } // cas id_article=xx qui se mappe en id_objet=xx AND objet=article else if (count(trouver_champs_decomposes($col,$desc))>1){ $e = decompose_champ_id_objet($col); $col = array_shift($e); $where_complement = primary_doublee($e, $table); } // Cas particulier : expressions de date else if ($date = tester_param_date($boucle->type_requete, $col)) { list($col, $table) = calculer_critere_infixe_date($idb, $boucles, $date); } else if (preg_match('/^(.*)\.(.*)$/', $col, $r)) { list(,$table, $col) = $r; $col_alias = $col; $table = calculer_critere_externe_init($boucle, array($table), $col, $desc, ($crit->cond OR $op !='='), true); } else { if (@!array_key_exists($col, $desc['field'])) { $calculer_critere_externe = 'calculer_critere_externe_init'; // gestion par les plugins des jointures tordues pas automatiques mais necessaires if (isset($exceptions_des_jointures[$table][$col])){ if (count($exceptions_des_jointures[$table][$col])==3) list($t, $col, $calculer_critere_externe) = $exceptions_des_jointures[$table][$col]; else list($t, $col) = $exceptions_des_jointures[$table][$col]; } else if (isset($exceptions_des_jointures[$col])) list($t, $col) = $exceptions_des_jointures[$col]; else $t =''; // jointure non declaree. La trouver. $table = $calculer_critere_externe($boucle, $boucle->jointures, $col, $desc, ($crit->cond OR $op !='='), $t); list($nom, $desc) = trouver_champ_exterieur($col, $boucle->jointures, $boucle); if (count(trouver_champs_decomposes($col,$desc))>1){ $col_alias = $col; // id_article devient juste le nom d'origine $e = decompose_champ_id_objet($col); $col = array_shift($e); $where_complement = primary_doublee($e, $table); } } } // Si la colonne SQL est numerique ou le critere est une date relative // forcer une conversion pour eviter un erreur au niveau SQL // Si la colonne SQL est numerique ou le critere est une date relative // virer les guillemets eventuels qui sont refuses par certains SQL // Ne pas utiliser intval, PHP tronquant les Bigint de SQL if (($op == '=' OR in_array($op, $table_criteres_infixes)) AND (($desc AND isset($desc['field'][$col]) AND sql_test_int($desc['field'][$col])) OR ($date AND strpos($date[0], '_relatif')))) { if (preg_match("/^\"'(-?\d+)'\"$/", $val[0], $r)) $val[0] = $r[1]; elseif (preg_match('/^sql_quote[(](.*?)(,.*)?[)]\s*$/', $val[0], $r)) { $r = $r[1] . ($r[2] ? $r[2] : ",''") . ",'int'"; $val[0] = "sql_quote($r)"; } } // Indicateur pour permettre aux fonctionx boucle_X de modifier // leurs requetes par defaut, notamment le champ statut // Ne pas confondre champs de la table principale et des jointures if ($table === $boucle->id_table) { $boucles[$idb]->modificateur['criteres'][$col] = true; if ($col_alias!=$col) $boucles[$idb]->modificateur['criteres'][$col_alias] = true; } // ajout pour le cas special d'une condition sur le champ statut: // il faut alors interdire a la fonction de boucle // de mettre ses propres criteres de statut // http://www.spip.net/@statut (a documenter) // garde pour compatibilite avec code des plugins anterieurs, mais redondant avec la ligne precedente if ($col == 'statut') $boucles[$idb]->statut = true; // ajout pour le cas special des forums // il faut alors interdire a la fonction de boucle sur forum // de selectionner uniquement les forums sans pere elseif ($boucles[$idb]->type_requete == 'forums' AND ($col == 'id_parent' OR $col == 'id_forum')) $boucles[$idb]->modificateur['plat'] = true; // inserer le nom de la table SQL devant le nom du champ if ($table) { if ($col[0] == "`") $arg = "$table." . substr($col,1,-1); else $arg = "$table.$col"; } else $arg = $col; // inserer la fonction SQL if ($fct) $arg = "$fct($arg$args_sql)"; return array($arg, $op, $val, $col_alias, $where_complement); } // Ne pas appliquer sql_quote lors de la compilation, // car on ne connait pas le serveur SQL, donc s'il faut \' ou '' // http://doc.spip.org/@primary_doublee function primary_doublee($decompose, $table) { $e1 = reset($decompose); $e2 = "sql_quote('" . end($decompose) ."')"; return array("'='","'$table.". $e1 ."'",$e2); } // Faute de copie du champ id_secteur dans la table des forums, // faut le retrouver par jointure // Pour chaque Row il faudrait tester si le forum est // d'article, de breve, de rubrique, ou de syndication. // Pour le moment on ne traite que les articles, // les 3 autres cas ne marcheront donc pas: ca ferait 4 jointures // qu'il faut traiter optimalement ou alors pas du tout. // http://doc.spip.org/@critere_secteur_forum function critere_secteur_forum($idb, &$boucles, $val, $crit) { static $trouver_table; if (!$trouver_table) $trouver_table = charger_fonction('trouver_table', 'base'); $desc = $trouver_table('articles', $boucles[$idb]->sql_serveur); return calculer_critere_externe_init($boucles[$idb], array($desc['table']), 'id_secteur', $desc, $crit->cond, true); } // Champ hors table, ca ne peut etre qu'une jointure. // On cherche la table du champ et on regarde si elle est deja jointe // Si oui et qu'on y cherche un champ nouveau, pas de jointure supplementaire // Exemple: criteres {titre_mot=...}{type_mot=...} // Dans les 2 autres cas ==> jointure // (Exemple: criteres {type_mot=...}{type_mot=...} donne 2 jointures // pour selectioner ce qui a exactement ces 2 mots-cles. // http://doc.spip.org/@calculer_critere_externe_init function calculer_critere_externe_init(&$boucle, $joints, $col, $desc, $eg, $checkarrivee = false) { $cle = trouver_champ_exterieur($col, $joints, $boucle, $checkarrivee); if ($cle) { $t = array_search($cle[0], $boucle->from); // transformer eventuellement id_xx en (id_objet,objet) $cols = trouver_champs_decomposes($col,$cle[1]); if ($t) { $joindre = false; foreach($cols as $col){ $c = '/\b' . $t . ".$col" . '\b/'; if (trouver_champ($c, $boucle->where)) $joindre = true; else { // mais ca peut etre dans le FIELD pour le Having $c = "/FIELD.$t" .".$col,/"; if (trouver_champ($c, $boucle->select)) $joindre = true; } } if (!$joindre) return $t; } $cle = calculer_jointure($boucle, array($boucle->id_table, $desc), $cle, $cols, $eg); if ($cle) return $cle; } erreur_squelette(_T('zbug_info_erreur_squelette'), _T('zbug_boucle') . " $idb " . _T('zbug_critere_inconnu', array('critere' => $col))); } // http://doc.spip.org/@trouver_champ function trouver_champ($champ, $where) { if (!is_array($where)) return preg_match($champ,$where); else { foreach ($where as $clause) { if (trouver_champ($champ, $clause)) return true; } return false; } } // determine l'operateur et les operandes // http://doc.spip.org/@calculer_critere_infixe_ops function calculer_critere_infixe_ops($idb, &$boucles, $crit) { // cas d'une valeur comparee a elle-meme ou son referent if (count($crit->param) == 0) { $op = '='; $col = $val = $crit->op; if (preg_match('/^(.*)\.(.*)$/', $col, $r)) $val = $r[2]; // Cas special {lang} : aller chercher $GLOBALS['spip_lang'] if ($val == 'lang') $val = array(kwote('$GLOBALS[\'spip_lang\']')); else { // Si id_parent, comparer l'id_parent avec l'id_objet // de la boucle superieure.... faudrait verifier qu'il existe // pour eviter l'erreur SQL if ($val == 'id_parent') $val = $boucles[$idb]->primary; // Si id_enfant, comparer l'id_objet avec l'id_parent // de la boucle superieure else if ($val == 'id_enfant') $val = 'id_parent'; // un critere conditionnel sur date est traite a part // car la date est mise d'office par SPIP, $val = calculer_argument_precedent($idb, $val, $boucles); if ($crit->cond AND ($col == "date" OR $col == "date_redac")) { if($val == "\$Pile[0]['".$col."']") { $val = "(\$Pile[0]['{$col}_default']?'':$val)"; } } $val = array(kwote($val)); } } else { // comparaison explicite // le phraseur impose que le premier param soit du texte $params = $crit->param; $op = $crit->op; if ($op == '==') $op = 'REGEXP'; $col = array_shift($params); $col = $col[0]->texte; $val = array(); $desc = array('id_mere' => $idb); $parent = $boucles[$idb]->id_parent; // Dans le cas {x=='#DATE'} etc, defaire le travail du phraseur, // celui ne sachant pas ce qu'est un critere infixe // et a fortiori son 2e operande qu'entoure " ou ' if (count($params)==1 AND count($params[0]==3) AND $params[0][0]->type == 'texte' AND @$params[0][2]->type == 'texte' AND ($p=$params[0][0]->texte) == $params[0][2]->texte AND (($p == "'") OR ($p == '"')) AND $params[0][1]->type == 'champ' ) { $val[]= "$p\\$p#" . $params[0][1]->nom_champ . "\\$p$p"; } else foreach ((($op != 'IN') ? $params : calculer_vieux_in($params)) as $p) { $a = calculer_liste($p, $desc, $boucles, $parent); if ($op == 'IN') $val[]= $a; else $val[]=kwote($a); } } $fct = $args_sql = ''; // fonction SQL ? if (preg_match('/^(.*)' . SQL_ARGS . '$/', $col, $m)) { $fct = $m[1]; preg_match('/^\(([^,]*)(.*)\)$/', $m[2], $a); $col = $a[1]; if (preg_match('/^(\S*)(\s+AS\s+.*)$/i', $col, $m)) { $col=$m[1]; $args_sql = $m[2]; } $args_sql .= $a[2];; } //var_dump(array($fct,$col,$op,$val,$args_sql)); return array($fct, $col, $op, $val, $args_sql); } // compatibilite ancienne version // http://doc.spip.org/@calculer_vieux_in function calculer_vieux_in($params) { $deb = $params[0][0]; $k = count($params)-1; $last = $params[$k]; $j = count($last)-1; $last = $last[$j]; $n = strlen($last->texte); if (!(($deb->texte[0] == '(') && ($last->texte[$n-1] == ')'))) return $params; $params[0][0]->texte = substr($deb->texte,1); // attention, on peut avoir k=0,j=0 ==> recalculer $last = $params[$k][$j]; $n = strlen($last->texte); $params[$k][$j]->texte = substr($last->texte,0,$n-1); $newp = array(); foreach($params as $v) { if ($v[0]->type != 'texte') $newp[] = $v; else { foreach(split(',', $v[0]->texte) as $x) { $t = new Texte; $t->texte = $x; $newp[] = array($t); } } } return $newp; } // http://doc.spip.org/@calculer_critere_infixe_date function calculer_critere_infixe_date($idb, &$boucles, $regs) { global $table_date; $boucle = $boucles[$idb]; list(,$col, $rel, $suite) = $regs; $date_orig = $pred = isset($table_date[$boucle->type_requete])?$table_date[$boucle->type_requete]:'date'; if ($suite) { # Recherche de l'existence du champ date_xxxx, # si oui choisir ce champ, sinon choisir xxxx $t = $boucle->show; if ($t['field']["date$suite"]) $date_orig = 'date'.$suite; else $date_orig = substr($suite, 1); $pred = $date_orig; } else if ($rel) $pred = 'date'; $date_compare = "\"' . normaliser_date(" . calculer_argument_precedent($idb, $pred, $boucles) . ") . '\""; $date_orig = $boucle->id_table . '.' . $date_orig; if ($col == 'date') { $col = $date_orig; $col_table = ''; } else if ($col == 'jour') { $col = "DAYOFMONTH($date_orig)"; $col_table = ''; } else if ($col == 'mois') { $col = "MONTH($date_orig)"; $col_table = ''; } else if ($col == 'annee') { $col = "YEAR($date_orig)"; $col_table = ''; } else if ($col == 'heure') { $col = "DATE_FORMAT($date_orig, '%H:%i')"; $col_table = ''; } else if ($col == 'age') { $col = calculer_param_date("now()", $date_orig); $col_table = ''; } else if ($col == 'age_relatif') { $col = calculer_param_date($date_compare, $date_orig); $col_table = ''; } else if ($col == 'jour_relatif') { $col = "LEAST(TO_DAYS(" .$date_compare . ")-TO_DAYS(" . $date_orig . "), DAYOFMONTH(" . $date_compare . ")-DAYOFMONTH(" . $date_orig . ")+30.4368*(MONTH(" . $date_compare . ")-MONTH(" . $date_orig . "))+365.2422*(YEAR(" . $date_compare . ")-YEAR(" . $date_orig . ")))"; $col_table = ''; } else if ($col == 'mois_relatif') { $col = "MONTH(" . $date_compare . ")-MONTH(" . $date_orig . ")+12*(YEAR(" . $date_compare . ")-YEAR(" . $date_orig . "))"; $col_table = ''; } else if ($col == 'annee_relatif') { $col = "YEAR(" . $date_compare . ")-YEAR(" . $date_orig . ")"; $col_table = ''; } return array($col, $col_table); } // http://doc.spip.org/@calculer_param_date function calculer_param_date($date_compare, $date_orig) { if (preg_match(",'\" *\.(.*)\. *\"',", $date_compare, $r)) { $init = "'\" . (\$x = $r[1]) . \"'"; $date_compare = '\'$x\''; } else $init = $date_compare; return "LEAST((UNIX_TIMESTAMP(" . $init . ")-UNIX_TIMESTAMP(" . $date_orig . "))/86400,\n\tTO_DAYS(" . $date_compare . ")-TO_DAYS(" . $date_orig . "),\n\tDAYOFMONTH(" . $date_compare . ")-DAYOFMONTH(" . $date_orig . ")+30.4368*(MONTH(" . $date_compare . ")-MONTH(" . $date_orig . "))+365.2422*(YEAR(" . $date_compare . ")-YEAR(" . $date_orig . ")))"; } // http://doc.spip.org/@tester_param_date function tester_param_date($type, $col) { global $table_date; if (isset($table_date[$type]) AND preg_match(",^((age|jour|mois|annee)_relatif|date|mois|annee|jour|heure|age)(_[a-z]+)?$,", $col, $regs)) return $regs; else return false; } ?> spip/spip/ecrire/public/stats.php0000766000000000000000000000617611236524730020307 0ustar adminadministrators'') AND strpos('-'.strtolower($referer), strtolower($url_site_spip)) AND strpos($referer,"recherche=")===false)) { $log_referer =$referer; } } // // stockage sous forme de fichier ecrire/data/stats/client_id // // 1. Chercher s'il existe deja une session pour ce numero IP. $content = array(); $fichier = sous_repertoire(_DIR_TMP, 'visites') . $client_id; if (lire_fichier($fichier, $content)) $content = @unserialize($content); // 2. Plafonner le nombre de hits pris en compte pour un IP (robots etc.) // et ecrire la session if (count($content) < 200) { // Identification de l'element if (isset($GLOBALS['contexte']['id_article'])) $log_type = "article"; else if (isset($GLOBALS['contexte']['id_breve'])) $log_type = "breve"; else if (isset($GLOBALS['contexte']['id_rubrique'])) $log_type = "rubrique"; else $log_type = ""; if ($log_type) $log_type .= "\t" . intval($GLOBALS['contexte']["id_$log_type"]); else $log_type = "autre\t0"; $log_type .= "\t" . trim($log_referer); if (isset($content[$log_type])) $content[$log_type]++; else $content[$log_type] = 1; // bienvenue au club ecrire_fichier($fichier, serialize($content)); } } ?> spip/spip/ecrire/public/cacher.php0000766000000000000000000002304311236524730020366 0ustar adminadministrators$val) { $val = is_array($val) ? var_export($val,true) : strval($val); $cache .= str_replace('-', '_', $val) . '-' ; } $cache = str_replace('/', '_', rawurlencode($cache)); if (strlen($cache) > 24) { $cache = preg_replace('/([a-zA-Z]{1,3})[^-_]*[-_]/', '\1-', $cache); $cache = substr($cache, 0, 24); } // Morceau de md5 selon HOST, $dossier_squelettes et $marqueur // permet de changer le nom du cache en changeant ceux-ci // donc, par exemple, de gerer differents dossiers de squelettes // en parallele, ou de la "personnalisation" via un marqueur (dont la // composition est totalement libre...) $md_cache = md5($page . ' ' . var_export($contexte,true) . $_SERVER['HTTP_HOST'] . ' ' . $GLOBALS['dossier_squelettes'] . ' ' . (isset($GLOBALS['marqueur']) ? $GLOBALS['marqueur'] : '') ); $cache .= '-'.substr($md_cache, 1, 32-strlen($cache)); // Sous-repertoires 0...9a..f ; ne pas prendre la base _DIR_CACHE $rep = _DIR_CACHE; if(!@file_exists($rep)) { $rep = preg_replace(','._DIR_TMP.',', '', $rep); $rep = sous_repertoire(_DIR_TMP, $rep, false,true); } $subdir = sous_repertoire($rep, substr($md_cache, 0, 1), true,true); return $subdir.$cache; } // Faut-il compresser ce cache ? A partir de 16ko ca vaut le coup // (pas de passage par reference car on veut conserver la version non compressee // pour l'afficher) // http://doc.spip.org/@gzip_page function gzip_page($page) { if ($GLOBALS['flag_gz'] AND strlen($page['texte']) > 16*1024) { $page['gz'] = true; $page['texte'] = gzcompress($page['texte']); } else { $page['gz'] = false; } return $page; } // Faut-il decompresser ce cache ? // (passage par reference pour alleger) // http://doc.spip.org/@gunzip_page function gunzip_page(&$page) { if ($page['gz']) $page['texte'] = gzuncompress($page['texte']); } /** * gestion des delais d'expiration du cache... * $page passee par reference pour accelerer * * La fonction retourne * 1 si il faut mettre le cache a jour * 0 si le cache est valide * -1 si il faut calculer sans stocker en cache * * @param array $page * @param int $date * @return -1/0/1 */ /// http://doc.spip.org/@cache_valide function cache_valide(&$page, $date) { if (isset($GLOBALS['var_nocache']) AND $GLOBALS['var_nocache']) return -1; if (defined('_NO_CACHE')) return (_NO_CACHE==0 AND !$page)?1:_NO_CACHE; if (!$page) return 1; // #CACHE{n,statique} => on n'invalide pas avec derniere_modif // cf. ecrire/public/balises.php, balise_CACHE_dist() if (!isset($page['entetes']['X-Spip-Statique']) OR $page['entetes']['X-Spip-Statique'] !== 'oui') { // Cache invalide par la meta 'derniere_modif' if ($GLOBALS['derniere_modif_invalide'] AND $date < $GLOBALS['meta']['derniere_modif']) return 1; // Apparition d'un nouvel article post-date ? if ($GLOBALS['meta']['post_dates'] == 'non' AND isset($GLOBALS['meta']['date_prochain_postdate']) AND time() > $GLOBALS['meta']['date_prochain_postdate']) { spip_log('Un article post-date invalide le cache'); include_spip('inc/rubriques'); ecrire_meta('derniere_modif', time()); calculer_prochain_postdate(); return 1; } } // Sinon comparer l'age du fichier a sa duree de cache $duree = intval($page['entetes']['X-Spip-Cache']); if ($duree == 0) #CACHE{0} return -1; else if ($date + $duree < time()) return 1; else return 0; } // Creer le fichier cache # Passage par reference de $page par souci d'economie // http://doc.spip.org/@creer_cache function creer_cache(&$page, &$chemin_cache) { // Si la page c1234 a un invalideur de session 'zz', sauver dans // 'tmp/cache/a/c1234-zz.gz' // en prenant soin de supprimer un eventuel cache non-sessionne // si l'ajout de #SESSION dans le squelette est recent if (isset($page['invalideurs']) AND isset($page['invalideurs']['session'])) { supprimer_fichier(_DIR_CACHE . $chemin_cache); $chemin_cache .= '-'.$page['invalideurs']['session']; } // l'enregistrer, compresse ou non... $ok = ecrire_fichier(_DIR_CACHE . $chemin_cache, serialize(gzip_page($page))); spip_log("Creation du cache $chemin_cache pour " . $page['entetes']['X-Spip-Cache']." secondes". ($ok?'':' (erreur!)')); // Inserer ses invalideurs include_spip('inc/invalideur'); maj_invalideurs($chemin_cache, $page); } // purger un petit cache (tidy ou recherche) qui ne doit pas contenir de // vieux fichiers // http://doc.spip.org/@nettoyer_petit_cache function nettoyer_petit_cache($prefix, $duree = 300) { // determiner le repertoire a purger : 'tmp/CACHE/rech/' $dircache = sous_repertoire(_DIR_CACHE,$prefix); if (spip_touch($dircache.'purger_'.$prefix, $duree, true)) { foreach (preg_files($dircache,'[.]txt$') as $f) { if (time() - (@file_exists($f)?@filemtime($f):0) > $duree) spip_unlink($f); } } } // Interface du gestionnaire de cache // Si son 3e argument est non vide, elle passe la main a creer_cache // Sinon, elle recoit un contexte (ou le construit a partir de REQUEST_URI) // et affecte les 4 autres parametres recus par reference: // - use_cache qui vaut // -1 s'il faut calculer la page sans la mettre en cache // 0 si on peut utiliser un cache existant // 1 s'il faut calculer la page et la mettre en cache // - chemin_cache qui est le chemin d'acces au fichier ou vide si pas cachable // - page qui est le tableau decrivant la page, si le cache la contenait // - lastmodified qui vaut la date de derniere modif du fichier. // Elle retourne '' si tout va bien // un message d'erreur si le calcul de la page est totalement impossible // http://doc.spip.org/@public_cacher_dist function public_cacher_dist($contexte, &$use_cache, &$chemin_cache, &$page, &$lastmodified) { // Second appel, destine a l'enregistrement du cache sur le disque if (isset($chemin_cache)) return creer_cache($page, $chemin_cache); // Toute la suite correspond au premier appel // Cas ignorant le cache car completement dynamique if ($_SERVER['REQUEST_METHOD'] == 'POST' OR (substr($page,0,8)=='modeles/') OR (_request('connect')) // Mode auteur authentifie appelant de ecrire/ : il ne faut rien lire du cache // et n'y ecrire que la compilation des squelettes (pas les pages produites) // car les references aux repertoires ne sont pas relatifs a l'espace public OR test_espace_prive()) { $use_cache = -1; $lastmodified = 0; $chemin_cache = ""; $page = array(); return; } // Controler l'existence d'un cache nous correspondant, dans les // quatre versions possibles : gzip ou non, session ou non $chemin_cache = generer_nom_fichier_cache($contexte, $page); if (@file_exists(_DIR_CACHE . ($f = $g = $chemin_cache)) OR (@file_exists(_DIR_CACHE . ($f = $chemin_cache.'-'.spip_session()))) ) { $lastmodified = @filemtime(_DIR_CACHE . $f); } else $lastmodified = 0; // HEAD : cas sans jamais de calcul pour raisons de performance if ($_SERVER['REQUEST_METHOD'] == 'HEAD') { $use_cache = 0; $page = array(); return; } // Faut-il effacer des pages invalidees (en particulier ce cache-ci) ? if (isset($GLOBALS['meta']['invalider'])) { // ne le faire que si la base est disponible if (spip_connect()) { include_spip('inc/invalideur'); retire_caches($f); } } // Si un calcul, recalcul [ou preview, mais c'est recalcul] est demande, // on supprime le cache, et ses voisins dans le cas des sessions if ($GLOBALS['var_mode'] && (isset($_COOKIE['spip_session']) || isset($_COOKIE['spip_admin']) || @file_exists(_ACCESS_FILE_NAME)) ) { supprimer_fichier(_DIR_CACHE . $f); if (in_array($GLOBALS['var_mode'], array('calcul', 'recalcul'))) array_map('supprimer_fichier', preg_files(_DIR_CACHE . $g)); } // $delais par defaut (pour toutes les pages sans #CACHE{}) if (!isset($GLOBALS['delais'])) { define('_DUREE_CACHE_DEFAUT', 24*3600); $GLOBALS['delais'] = _DUREE_CACHE_DEFAUT; } // Lire le fichier cache et determiner sa validite if ($lastmodified AND lire_fichier(_DIR_CACHE . $f, $page)) { $page = @unserialize($page); $use_cache = cache_valide($page, $lastmodified); if (!$use_cache) { // $page est un cache utilisable gunzip_page($page); return; } } else { $page = array(); $use_cache = cache_valide($page,0); // fichier cache absent : provoque le calcul } // Si pas valide mais pas de connexion a la base, le garder quand meme if (!spip_connect()) { if ($lastmodified) $use_cache = 0; else { spip_log("Erreur base de donnees, impossible utiliser $chemin_cache"); include_spip('inc/minipres'); return minipres(_T('info_travaux_titre'), _T('titre_probleme_technique')); } } if ($use_cache < 0) $chemin_cache = ''; return; } ?> spip/spip/ecrire/public/admin.php0000766000000000000000000000446111236524730020234 0ustar adminadministrators // puis les boutons // Feuilles de style admin : d'abord la CSS officielle, puis la perso // Compatibilite : on utilise stripos/strripos() qui n'existent pas en php4 if (!function_exists('strripos')) { // http://doc.spip.org/@strripos function strripos($botte, $aiguille) { if (preg_match('@^(.*)' . preg_quote($aiguille, '@') . '@is', $botte, $regs)) { return strlen($regs[1]); } return false; } } if (!function_exists('stripos')) { // http://doc.spip.org/@stripos function stripos($botte, $aiguille) { if (preg_match('@^(.*)' . preg_quote($aiguille, '@') . '@isU', $botte, $regs)) { return strlen($regs[1]); } return false; } } // http://doc.spip.org/@affiche_boutons_admin function affiche_boutons_admin($contenu) { include_spip('inc/filtres'); // Inserer le css d'admin $css = "\n"; if ($f = find_in_path('spip_admin_perso.css')) $css .= "\n"; ($pos = stripos($contenu, '')) || ($pos = stripos($contenu, '')) || ($pos = 0); $contenu = substr_replace($contenu, $css, $pos, 0); // Inserer la balise #FORMULAIRE_ADMIN, en float $boutons_admin = inclure_balise_dynamique( balise_FORMULAIRE_ADMIN_dyn('spip-admin-float'), false); ($pos = strripos($contenu, '')) || ($pos = strripos($contenu, '')) || ($pos = strlen($contenu)); $contenu = substr_replace($contenu, $boutons_admin, $pos, 0); return $contenu; } ?> spip/spip/ecrire/public/phraser_html.php0000766000000000000000000005256511236524730021644 0ustar adminadministrators(.*),Uims'); define('BALISE_IDIOMES',',<:(([a-z0-9_]+):)?([a-z0-9_]+)({([^\|=>]*=[^\|>]*)})?((\|[^>]*)?:>),iS'); define('SQL_ARGS', '(\([^)]*\))'); define('CHAMP_SQL_PLUS_FONC', '`?([A-Z_][A-Z_0-9.]*)' . SQL_ARGS . '?`?'); // http://doc.spip.org/@phraser_inclure function phraser_inclure($texte, $ligne, $result) { while (preg_match(BALISE_INCLURE, $texte, $match)) { $p = strpos($texte,$match[0]); $debut = substr($texte, 0, $p); if ($p) $result = phraser_idiomes($debut, $ligne, $result); $ligne += substr_count($debut, "\n"); $champ = new Inclure; $champ->ligne = $ligne; $ligne += substr_count($match[0], "\n"); $champ->texte = @$match[2]; $texte = substr($texte, $p+strlen($match[0])); // on assimile {var=val} a une liste de un argument sans fonction phraser_args($texte,"/>","",$result,$champ); $texte = substr($champ->apres, strpos($champ->apres, '>')+1); $champ->apres = ""; $texte = preg_replace(',^,', '', $texte); $result[] = $champ; } return (($texte==="") ? $result : phraser_idiomes($texte, $ligne, $result)); } // http://doc.spip.org/@phraser_polyglotte function phraser_polyglotte($texte,$ligne, $result) { if (preg_match_all(BALISE_POLYGLOTTE, $texte, $m, PREG_SET_ORDER)) foreach ($m as $match) { $p = strpos($texte, $match[0]); $debut = substr($texte, 0, $p); if ($p) { $champ = new Texte; $champ->texte = $debut; $champ->ligne = $ligne; $result[] = $champ; $ligne += substr_count($champ->texte, "\n"); } $champ = new Polyglotte; $champ->ligne = $ligne; $ligne += substr_count($match[0], "\n"); $lang = ''; $bloc = $match[1]; $texte = substr($texte,$p+strlen($match[0])); while (preg_match("/^[[:space:]]*([^[{]*)[[:space:]]*[[{]([a-z_]+)[]}](.*)$/si", $bloc, $regs)) { $trad = $regs[1]; if ($trad OR $lang) $champ->traductions[$lang] = $trad; $lang = $regs[2]; $bloc = $regs[3]; } $champ->traductions[$lang] = $bloc; $result[] = $champ; } if ($texte!=="") { $champ = new Texte; $champ->texte = $texte; $champ->ligne = $ligne; $result[] = $champ; } return $result; } // http://doc.spip.org/@phraser_idiomes function phraser_idiomes($texte,$ligne,$result) { // Reperer les balises de traduction <:module:chaine{argument1=texte,argument2=#BALISE}|filtre1{texte,#BALISE}|filtre2:> while (preg_match(BALISE_IDIOMES, $texte, $match)) { $p = strpos($texte, $match[0]); $debut = substr($texte, 0, $p); if ($p) $result = phraser_champs($debut, $ligne, $result); $champ = new Idiome; $ligne += substr_count($debut, "\n"); $champ->ligne = $ligne; $ligne += substr_count($match[0], "\n"); $texte = substr($texte,$p+strlen($match[0])); // Stocker les arguments de la balise de traduction $args=array(); $vals=explode(',',$match[5]); foreach ($vals as $val) { $arg=explode('=',$val); if ($arg[0]) $args[$arg[0]]=phraser_champs($arg[1], 0, $_arg); } $champ->arg=$args; $champ->nom_champ = strtolower($match[3]); $champ->module = $match[2] ? $match[2] : 'public/spip/ecrire'; // pas d'imbrication pour les filtres sur langue phraser_args(@$match[7], ":", '', array(), $champ); $result[] = $champ; } if ($texte!=="") $result = phraser_champs($texte,$ligne,$result); return $result; } // http://doc.spip.org/@phraser_champs function phraser_champs($texte,$ligne,$result) { while (preg_match("/".NOM_DE_CHAMP."/S", $texte, $match)) { $p = strpos($texte, $match[0]); $suite = substr($texte,$p+strlen($match[0])); if ($match[5] || (strpos($suite[0], "[0-9]") === false)) { $debut = substr($texte, 0, $p); if ($p) $result = phraser_polyglotte($debut, $ligne, $result); $ligne += substr_count($debut, "\n"); $champ = new Champ; $champ->ligne = $ligne; $ligne += substr_count($match[0], "\n"); $champ->nom_boucle = $match[2]; $champ->nom_champ = $match[3]; $champ->etoile = $match[5]; if ($suite[0] == '{') { phraser_arg($suite, '', array(), $champ); $texte = ltrim($suite); } else $texte = $suite; $result[] = $champ; } else { // faux champ $result = phraser_polyglotte (substr($texte, 0, $p+1), $ligne, $result); $texte = (substr($texte, $p+1)); } } if ($texte!=="") $result = phraser_polyglotte($texte, $ligne, $result); return $result; } // Gestion des imbrications: // on cherche les [..] les plus internes et on les remplace par une chaine // %###N@ ou N indexe un tableau comportant le resultat de leur analyse // on recommence tant qu'il y a des [...] en substituant a l'appel suivant // http://doc.spip.org/@phraser_champs_etendus function phraser_champs_etendus($texte, $ligne,$result) { if ($texte==="") return $result; $sep = '##'; while (strpos($texte,$sep)!== false) $sep .= '#'; return array_merge($result, phraser_champs_interieurs($texte, $ligne, $sep, array())); } // Analyse les filtres d'un champ etendu et affecte le resultat // renvoie la liste des lexemes d'origine augmentee // de ceux trouves dans les arguments des filtres (rare) // sert aussi aux arguments des includes et aux criteres de boucles // Tres chevelu // http://doc.spip.org/@phraser_args function phraser_args($texte, $fin, $sep, $result, &$pointeur_champ) { $texte = ltrim($texte); while (($texte!=="") && strpos($fin, $texte[0]) === false) { $result = phraser_arg($texte, $sep, $result, $pointeur_champ); $texte = ltrim($texte); } # mettre ici la suite du texte, # notamment pour que l'appelant vire le caractere fermant si besoin $pointeur_champ->apres = $texte; return $result; } // http://doc.spip.org/@phraser_arg function phraser_arg(&$texte, $sep, $result, &$pointeur_champ) { preg_match(",^(\|?[^}{)|]*)(.*)$,ms", $texte, $match); $suite = ltrim($match[2]); $fonc = trim($match[1]); if ($fonc && $fonc[0] == "|") $fonc = ltrim(substr($fonc,1)); $res = array($fonc); $args = $suite ; // cas du filtre sans argument ou du critere / if (($suite && ($suite[0] != '{')) || ($fonc && $fonc[0] == '/')) { // si pas d'argument, alors il faut une fonction ou un double | if (!$match[1]) erreur_squelette(_T('zbug_info_erreur_squelette'), $texte); } else { $args = ltrim(substr($suite,1)); $collecte = array(); while ($args && $args[0] != '}') { if ($args[0] == '"') preg_match ('/^(")([^"]*)(")(.*)$/ms', $args, $regs); else if ($args[0] == "'") preg_match ("/^(')([^']*)(')(.*)$/ms", $args, $regs); else { preg_match("/^([[:space:]]*)([^,([{}]*([(\[{][^])}]*[])}])?[^,}]*)([,}].*)$/ms", $args, $regs); if (!strlen($regs[2])) { erreur_squelette(_T('zbug_info_erreur_squelette'), $args); $champ->apres = $champ->avant = $args = ""; break; } } $arg = $regs[2]; if (trim($regs[1])) { $champ = new Texte; $champ->texte = $arg; $champ->apres = $champ->avant = $regs[1]; $result[] = $champ; $collecte[] = $champ; $args = ltrim($regs[count($regs)-1]); } else { if (!preg_match("/".NOM_DE_CHAMP ."[{|]/", $arg, $r)) { // 0 est un aveu d'impuissance. A completer $arg = phraser_champs_exterieurs($arg, 0, $sep, $result); $args = ltrim($regs[count($regs)-1]); $collecte = array_merge($collecte, $arg); $result = array_merge($result, $arg); } else { $n = strpos($args,$r[0]); $pred = substr($args, 0, $n); $par = ',}'; if (preg_match('/^(.*)\($/', $pred, $m)) {$pred = $m[1]; $par =')';} if ($pred) { $champ = new Texte; $champ->texte = $pred; $champ->apres = $champ->avant = ""; $result[] = $champ; $collecte[] = $champ; } $rec = substr($args, $n + strlen($r[0]) -1); $champ = new Champ; $champ->nom_boucle = $r[2]; $champ->nom_champ = $r[3]; $champ->etoile = $r[5]; phraser_args($rec, $par, $sep, array(), $champ); $args = $champ->apres ; $champ->apres = ''; if ($par==')') $args = substr($args,1); $collecte[] = $champ; $result[] = $champ; } } if ($args[0] == ',') { $args = ltrim(substr($args,1)); if ($collecte) {$res[] = $collecte; $collecte = array();} } } if ($collecte) {$res[] = $collecte; $collecte = array();} $args = substr($args,1); } $n = strlen($suite) - strlen($args); if ($fonc || count($res) > 1) $pointeur_champ->param[] = $res; // pour les balises avec faux filtres qui boudent ce dur larbeur $pointeur_champ->fonctions[] = array($fonc, substr($suite, 0, $n)); $texte = $args; return $result; } // http://doc.spip.org/@phraser_champs_exterieurs function phraser_champs_exterieurs($texte, $ligne, $sep, $nested) { $res = array(); while (($p=strpos($texte, "%$sep"))!==false) { if (!preg_match(',^%'.preg_quote($sep).'([0-9]+)@,', substr($texte,$p), $m)) break; $debut = substr($texte,0,$p); $texte = substr($texte, $p+strlen($m[0])); if ($p) $res = phraser_inclure($debut, $ligne, $res); $ligne += substr_count($debut, "\n"); $res[]= $nested[$m[1]]; } return (($texte==='') ? $res : phraser_inclure($texte, $ligne, $res)); } // http://doc.spip.org/@phraser_champs_interieurs function phraser_champs_interieurs($texte, $ligne, $sep, $result) { $i = 0; // en fait count($result) $x = ""; while (true) { $j=$i; $n = $ligne; while (preg_match(CHAMP_ETENDU, $texte, $match)) { $p = strpos($texte, $match[0]); $debut = substr($texte, 0, $p); if ($p) { $result[$i] = $debut; $i++; } $champ = new Champ; // ca ne marche pas encore en cas de champ imbrique $champ->ligne = $x ? 0 :($n+substr_count($debut, "\n")); $champ->nom_boucle = $match[3]; $champ->nom_champ = $match[4]; $champ->etoile = $match[6]; // phraser_args indiquera ou commence apres $result = phraser_args($match[7], ")", $sep, $result, $champ); $champ->avant = phraser_champs_exterieurs($match[1],$n,$sep,$result); $debut = substr($champ->apres,1); $n += substr_count(substr($texte, 0, strpos($texte, $debut)), "\n"); $champ->apres = phraser_champs_exterieurs($debut,$n,$sep,$result); $result[$i] = $champ; $i++; $texte = substr($texte,$p+strlen($match[0])); } if ($texte!=="") {$result[$i] = $texte; $i++;} $x =''; while($j < $i) { $z= $result[$j]; // j'aurais besoin de connaitre le nombre de lignes... if (is_object($z)) $x .= "%$sep$j@"; else $x.=$z; $j++; } if (preg_match(CHAMP_ETENDU, $x)) $texte = $x; else return phraser_champs_exterieurs($x, $ligne, $sep, $result); } } // analyse des criteres de boucle, // http://doc.spip.org/@phraser_criteres function phraser_criteres($params, &$result) { $args = array(); $type = $result->type_requete; $doublons = array(); foreach($params as $v) { $var = $v[1][0]; $param = ($var->type != 'texte') ? "" : $var->texte; if ((count($v) > 2) && (!preg_match(",[^A-Za-z]IN[^A-Za-z],i",$param))) { // plus d'un argument et pas le critere IN: // detecter comme on peut si c'est le critere implicite LIMIT debut, fin if (($var->type != 'texte') || (strpos("0123456789-", $param[strlen($param)-1]) !== false)) { $op = ','; $not = ""; } else { preg_match("/^([!]?)([a-zA-Z][a-zA-Z0-9]*)[[:space:]]*(.*)$/ms", $param, $m); $op = $m[2]; $not = $m[1]; if ($m[3]) $v[1][0]->texte = $m[3]; else array_shift($v[1]); } array_shift($v); $crit = new Critere; $crit->op = $op; $crit->not = $not; $crit->exclus =""; $crit->param = $v; $args[] = $crit; } else { if ($var->type != 'texte') { // cas 1 seul arg ne commencant pas par du texte brut: // erreur ou critere infixe "/" if (($v[1][1]->type != 'texte') || (trim($v[1][1]->texte) !='/')) erreur_squelette('criteres',$var->nom_champ); else { $crit = new Critere; $crit->op = '/'; $crit->not = ""; $crit->exclus =""; $crit->param = array(array($v[1][0]),array($v[1][2])); $args[] = $crit; } } else { // traiter qq lexemes particuliers pour faciliter la suite // les separateurs if ($var->apres) $result->separateur[] = $param; elseif (($param == 'tout') OR ($param == 'tous')) $result->modificateur['tout'] = true; elseif ($param == 'plat') $result->modificateur['plat'] = true; // Boucle hierarchie, analyser le critere id_article - id_rubrique // - id_syndic, afin, dans les cas autres que {id_rubrique}, de // forcer {tout} pour avoir la rubrique mere... elseif (($type == 'hierarchie') && ($param == 'id_article' OR $param == 'id_syndic')) $result->modificateur['tout'] = true; elseif (($type == 'hierarchie') && ($param == 'id_rubrique')) {;} else { // pas d'emplacement statique, faut un dynamique /// mais il y a 2 cas qui ont les 2 ! if (($param == 'unique') || (preg_match(',^!?doublons *,', $param))) { // cette variable sera inseree dans le code // et son nom sert d'indicateur des maintenant $result->doublons = '$doublons_index'; if ($param == 'unique') $param = 'doublons'; } elseif ($param == 'recherche') // meme chose (a cause de #nom_de_boucle:URL_*) $result->hash = ' '; if (preg_match(',^ *([0-9-]+) *(/) *(.+) *$,', $param, $m)) { $crit = phraser_critere_infixe($m[1], $m[3],$v, '/', '', ''); } elseif (preg_match(',^([!]?)(' . CHAMP_SQL_PLUS_FONC . ')[[:space:]]*(\??)(!?)(<=?|>=?|==?|\b(?:IN|LIKE)\b)(.*)$,is', $param, $m)) { $a2 = trim($m[8]); if ($a2 AND ($a2[0]=="'" OR $a2[0]=='"') AND ($a2[0]==substr($a2,-1))) $a2 = substr($a2,1,-1); $crit = phraser_critere_infixe($m[2], $a2, $v, (($m[2] == 'lang_select') ? $m[2] : $m[7]), $m[6], $m[5]); $crit->exclus = $m[1]; } elseif (preg_match("/^([!]?)\s*(" . CHAMP_SQL_PLUS_FONC . ")\s*(\??)(.*)$/is", $param, $m)) { // contient aussi les comparaisons implicites ! array_shift($v); if ($m[6]) $v[0][0]->texte = $m[6]; else { array_shift($v[0]); if (!$v[0]) array_shift($v); } $crit = new Critere; $crit->op = $m[2]; $crit->param = $v; $crit->not = $m[1]; $crit->cond = $m[5]; } else { erreur_squelette(_T('zbug_critere_inconnu', array('critere' => $param))); } if ((!preg_match(',^!?doublons *,', $param)) || $crit->not) $args[] = $crit; else $doublons[] = $crit; } } } } // les doublons non nies doivent etre le dernier critere // pour que la variable $doublon_index ait la bonne valeur // cf critere_doublon if ($doublons) $args= array_merge($args, $doublons); $result->criteres = $args; } // http://doc.spip.org/@phraser_critere_infixe function phraser_critere_infixe($arg1, $arg2, $args, $op, $not, $cond) { $args[0] = new Texte; $args[0]->texte = $arg1; $args[0] = array($args[0]); $args[1][0]->texte = $arg2; $crit = new Critere; $crit->op = $op; $crit->not = $not; $crit->cond = $cond; $crit->param = $args; return $crit; } function public_phraser_html_dist($texte, $id_parent, &$boucles, $nom, $ligne=1) { $all_res = array(); while (($p = strpos($texte, BALISE_BOUCLE)) !== false) { $result = new Boucle; $result->id_parent = $id_parent; # attention: reperer la premiere des 2 balises: pre_boucle ou boucle if (!preg_match(",".BALISE_PRE_BOUCLE . '[0-9_],', $texte, $r) OR ($n = strpos($texte, $r[0]))===false OR ($n > $p) ) { $debut = substr($texte, 0, $p); $milieu = substr($texte, $p); $k = strpos($milieu, '('); $id_boucle = trim(substr($milieu, strlen(BALISE_BOUCLE), $k - strlen(BALISE_BOUCLE))); $milieu = substr($milieu, $k); /* a adapter: si $n pointe sur $id_boucle ... if (strpos($milieu, $s)) { erreur_squelette(_T('zbug_erreur_boucle_syntaxe'), $id_boucle . _T('zbug_balise_b_aval')); } */ } else { $debut = substr($texte, 0, $n); $milieu = substr($texte, $n); $k = strpos($milieu, '>'); $id_boucle = substr($milieu, strlen(BALISE_PRE_BOUCLE), $k - strlen(BALISE_PRE_BOUCLE)); if (!preg_match(",".BALISE_BOUCLE . $id_boucle . "[[:space:]]*\(,", $milieu, $r)) erreur_squelette((_T('zbug_erreur_boucle_syntaxe')), $id_boucle); $p = strpos($milieu, $r[0]); $result->avant = substr($milieu, $k+1, $p-$k-1); $milieu = substr($milieu, $p+strlen($id_boucle)+strlen(BALISE_BOUCLE)); } $result->id_boucle = $id_boucle; preg_match(SPEC_BOUCLE, $milieu, $match); $milieu = substr($milieu, strlen($match[0])); $type = $match[1]; $jointures = trim($match[2]); $table_optionnelle = ($match[3]); if ($jointures) { $result->jointures = preg_split("/\s+/",$jointures); $result->jointures_explicites = $jointures; } if ($table_optionnelle){ $result->table_optionnelle = true; } if ($p = strpos($type, ':')) { $result->sql_serveur = substr($type,0,$p); $soustype = strtolower(substr($type,$p+1)); } else $soustype = strtolower($type); if ($soustype == 'sites') $soustype = 'syndication' ; # alias phraser_args($milieu,"/>","",$all_res,$result); $params = substr($milieu,0,@strpos($milieu,$result->apres)); $milieu = $result->apres; $result->apres = ""; // // analyser les criteres et distinguer la boucle recursive // if (strncmp($soustype, TYPE_RECURSIF, strlen(TYPE_RECURSIF)) == 0) { $result->type_requete = TYPE_RECURSIF; phraser_criteres($result->param, $result); $args = $result->param; array_unshift($args, substr($type, strlen(TYPE_RECURSIF))); $result->param = $args; } else { $result->type_requete = $soustype; phraser_criteres($result->param, $result); } // // Recuperer la fin : // if ($milieu[0] === '/') { $suite = substr($milieu,2); $milieu = ''; } else { $milieu = substr($milieu,1); $s = BALISE_FIN_BOUCLE . $id_boucle . ">"; $p = strpos($milieu, $s); if ($p === false) { erreur_squelette(_T('zbug_erreur_boucle_syntaxe'), _T('zbug_erreur_boucle_fermant', array('id'=>$id_boucle))); } $suite = substr($milieu, $p + strlen($s)); $milieu = substr($milieu, 0, $p); } // // 1. Recuperer la partie conditionnelle apres // $s = BALISE_POST_BOUCLE . $id_boucle . ">"; $p = strpos($suite, $s); if ($p !== false) { $result->apres = substr($suite, 0, $p); $suite = substr($suite, $p + strlen($s)); } // // 2. Recuperer la partie alternative // $s = BALISE_ALT_BOUCLE . $id_boucle . ">"; $p = strpos($suite, $s); if ($p !== false) { $result->altern = substr($suite, 0, $p); $suite = substr($suite, $p + strlen($s)); } $result->ligne = $ligne + substr_count($debut, "\n"); $m = substr_count($milieu, "\n"); $b = substr_count($result->avant, "\n"); $a = substr_count($result->apres, "\n"); // envoyer la boucle au debugueur if (isset($GLOBALS['var_mode']) AND $GLOBALS['var_mode']== 'debug') { boucle_debug ($nom, $id_parent, $id_boucle, $type . ($jointures ? ' '.$jointures : ''), $params, $result->avant, $milieu, $result->apres, $result->altern); } $result->avant = public_phraser_html_dist($result->avant, $id_parent,$boucles, $nom, $result->ligne); $result->apres = public_phraser_html_dist($result->apres, $id_parent,$boucles, $nom, $result->ligne+$b+$m); $result->altern = public_phraser_html_dist($result->altern,$id_parent,$boucles, $nom, $result->ligne+$a+$m+$b); $result->milieu = public_phraser_html_dist($milieu, $id_boucle,$boucles, $nom, $result->ligne+$b); if (isset($boucles[$id_boucle])) { erreur_squelette(_T('zbug_erreur_boucle_syntaxe'), _T('zbug_erreur_boucle_double', array('id'=>$id_boucle))); } else $boucles[$id_boucle] = $result; $all_res = phraser_champs_etendus($debut, $ligne, $all_res); $all_res[] = &$boucles[$id_boucle]; $ligne += substr_count(substr($texte, 0, strpos($texte, $suite)), "\n"); $texte = $suite; } return phraser_champs_etendus($texte, $ligne, $all_res); } ?> spip/spip/ecrire/public/index.php0000766000000000000000000000000211236524730020236 0ustar adminadministratorsX spip/spip/ecrire/public/references.php0000766000000000000000000004312111236524730021261 0ustar adminadministratorsid_parent; } } # spip_log("Cherche: $nom_champ a partir de '$idb'"); $nom_champ = strtolower($nom_champ); // attention: entre la boucle nommee 0, "" et le tableau vide, // il y a incoherences qu'il vaut mieux eviter while (isset($boucles[$idb])) { list ($t, $c) = index_tables_en_pile($idb, $nom_champ, $boucles); if ($t) { if (!in_array($t, $boucles[$idb]->select)) { $boucles[$idb]->select[] = $t; } return '$Pile[$SP' . ($i ? "-$i" : "") . '][\'' . $c . '\']'; } # spip_log("On remonte vers $i"); // Sinon on remonte d'un cran $idb = $boucles[$idb]->id_parent; $i++; } # spip_log("Pas vu $nom_champ"); // esperons qu'il y sera return('@$Pile[0][\''. strtolower($nom_champ) . '\']'); } // http://doc.spip.org/@index_tables_en_pile function index_tables_en_pile($idb, $nom_champ, &$boucles) { global $exceptions_des_tables; $r = $boucles[$idb]->type_requete; if ($r == 'boucle') return array(); if (!$r) { # continuer pour chercher l'erreur suivante return array("'#" . $r . ':' . $nom_champ . "'",''); } $desc = $boucles[$idb]->show; $excep = isset($exceptions_des_tables[$r]) ? $exceptions_des_tables[$r] : ''; if ($excep) $excep = isset($excep[$nom_champ]) ? $excep[$nom_champ] : ''; if ($excep) { return index_exception($boucles[$idb], $desc, $nom_champ, $excep); } else { if (isset($desc['field'][$nom_champ])) { $t = $boucles[$idb]->id_table; return array("$t.$nom_champ", $nom_champ); } else { if ($boucles[$idb]->jointures_explicites) { $t = trouver_champ_exterieur($nom_champ, $boucles[$idb]->jointures, $boucles[$idb]); if ($t) return index_exception($boucles[$idb], $desc, $nom_champ, array($t[1]['id_table'], $nom_champ)); } return array('',''); } } } // Reference a une entite SPIP alias d'un champ SQL // Ca peut meme etre d'un champ dans une jointure // qu'il faut provoquer si ce n'est fait // http://doc.spip.org/@index_exception function index_exception(&$boucle, $desc, $nom_champ, $excep) { static $trouver_table; if (!$trouver_table) $trouver_table = charger_fonction('trouver_table', 'base'); if (is_array($excep)) { // permettre aux plugins de gerer eux meme des jointures derogatoire ingerables $t = NULL; if (count($excep)==3){ $index_exception_derogatoire = array_pop($excep); $t = $index_exception_derogatoire($boucle, $desc, $nom_champ, $excep); } if ($t == NULL) { list($e, $x) = $excep; #PHP4 affecte de gauche a droite $excep = $x; #PHP5 de droite a gauche ! $j = $trouver_table($e, $boucle->sql_serveur); if (!$j) return array('',''); $e = $j['table']; if (!$t = array_search($e, $boucle->from)) { $k = $j['key']['PRIMARY KEY']; if (strpos($k,',')) { $l = (preg_split('/\s*,\s*/', $k)); $k = $desc['key']['PRIMARY KEY']; if (!in_array($k, $l)) { spip_log("jointure impossible $e " . join(',', $l)); return array('',''); } } $k = array($boucle->id_table, array($e), $k); fabrique_jointures($boucle, array($k)); $t = array_search($e, $boucle->from); } } } else $t = $boucle->id_table; // demander a SQL de gerer le synonyme // ca permet que excep soit dynamique (Cedric, 2/3/06) if ($excep != $nom_champ) $excep .= ' AS '. $nom_champ; return array("$t.$excep", $nom_champ); } // cette fonction sert d'API pour demander le champ '$champ' dans la pile // http://doc.spip.org/@champ_sql function champ_sql($champ, $p) { return index_pile($p->id_boucle, $champ, $p->boucles, $p->nom_boucle); } // cette fonction sert d'API pour demander une balise Spip avec filtres // http://doc.spip.org/@calculer_champ function calculer_champ($p) { $p = calculer_balise($p->nom_champ, $p); return applique_filtres($p); } // Cette fonction sert d'API pour demander une balise SPIP sans filtres. // Pour une balise nommmee NOM, elle demande a charger_fonction de chercher // s'il existe une fonction balise_NOM ou balise_NOM_dist // eventuellement en chargeant le fichier balise/NOM.php. // Si ce n'est pas le cas, hormis le cas historique des balise LOGO_*, // elle estime que c'est une reference a une colonne de table connue. // Les surcharges via charger_fonction sont donc possibles. // http://doc.spip.org/@calculer_balise function calculer_balise($nom, $p) { // S'agit-t-il d'une balise_XXXX[_dist]() ? if ($f = charger_fonction($nom, 'balise', true)) { $res = $f($p); if ($res !== NULL) return $res; } // Certaines des balises comportant un _ sont generiques if ($f = strpos($nom, '_') AND $f = charger_fonction(substr($nom,0,$f+1), 'balise', true)) { $res = $f($p); if ($res !== NULL) return $res; } // ca pourrait etre un champ SQL homonyme, $p->code = index_pile($p->id_boucle, $nom, $p->boucles, $p->nom_boucle); // compatibilite: depuis qu'on accepte #BALISE{ses_args} sans [(...)] autour // il faut recracher {...} quand ce n'est finalement pas des args if ($p->fonctions AND (!$p->fonctions[0][0]) AND $p->fonctions[0][1]) { $code = addslashes($p->fonctions[0][1]); $p->code .= " . '$code'"; } // ne pas passer le filtre securite sur les id_xxx if (strpos($nom, 'ID_') === 0) $p->interdire_scripts = false; // Compatibilite ascendante avec les couleurs html (#FEFEFE) : // SI le champ SQL n'est pas trouve // ET si la balise a une forme de couleur // ET s'il n'y a ni filtre ni etoile // ALORS retourner la couleur. // Ca permet si l'on veut vraiment de recuperer [(#ACCEDE*)] if (preg_match("/^[A-F]{1,6}$/i", $nom) AND !$p->etoile AND !$p->fonctions) { $p->code = "'#$nom'"; $p->interdire_scripts = false; } return $p; } // // Traduction des balises dynamiques, notamment les "formulaire_*" // Inclusion du fichier associe a son nom. // Ca donne les arguments a chercher dans la pile,on compile leur localisation // Ensuite on delegue a une fonction generale definie dans executer_squelette // qui recevra a l'execution la valeur des arguments, // ainsi que les pseudo filtres qui ne sont donc pas traites a la compil // mais on traite le vrai parametre si present. // http://doc.spip.org/@calculer_balise_dynamique function calculer_balise_dynamique($p, $nom, $l) { if (!balise_distante_interdite($p)) { $p->code = "''"; return $p; } $param = ""; if ($a = $p->param) { $c = array_shift($a); if (!array_shift($c)) { $p->fonctions = $a; array_shift( $p->param ); $param = compose_filtres_args($p, $c, ','); } } $collecte = join(',',collecter_balise_dynamique($l, $p, $nom)); $p->code = "executer_balise_dynamique('" . $nom . "',\n\tarray(" . $collecte . ($collecte ? $param : substr($param,1)) # virer la virgule . "),\n\tarray(" . argumenter_balise($p->param, "', '") . "), \$GLOBALS['spip_lang']," . $p->ligne . ')'; $p->interdire_scripts = false; $p->fonctions = array(); $p->param = array(); return $p; } // les balises dynamiques et EMBED ont des filtres sans arguments // car en fait ce sont des arguments pas des filtres. // Si le besoin s'en fait sentir, il faudra recuperer la 2e moitie du tableau // http://doc.spip.org/@argumenter_balise function argumenter_balise($fonctions, $sep) { $res = array(); if ($fonctions) foreach ($fonctions as $f) $res[] = str_replace('\'', '\\\'', str_replace('\\', '\\\\',$f[0])); return ("'" . join($sep, $res) . "'"); } // Construction du tableau des arguments d'une balise dynamique. // Ces arguments peuvent etre eux-meme des balises (cf FORMULAIRE_SIGNATURE) // mais gare au bouclage (on peut s'aider de $nom pour le reperer au besoin) // http://doc.spip.org/@collecter_balise_dynamique function collecter_balise_dynamique($l, &$p, $nom) { $args = array(); foreach($l as $c) { $x = calculer_balise($c, $p); $args[] = $x->code;} return $args; } // il faudrait savoir traiter les formulaires en local // tout en appelant le serveur SQL distant. // En attendant, cette fonction permet de refuser une authentification // sur qqch qui n'a rien a voir. // http://doc.spip.org/@balise_distante_interdite function balise_distante_interdite($p) { $nom = $p->id_boucle; if ($nom AND $p->boucles[$nom]->sql_serveur) { spip_log( $nom .':' . $p->nom_champ .' '._T('zbug_distant_interdit')); return false; } return true; } // // Traitements standard de divers champs // definis par $table_des_traitements, cf. ecrire/public/interfaces // // http://doc.spip.org/@champs_traitements function champs_traitements ($p) { global $table_des_traitements; static $test_doublons = array(); if (!isset($table_des_traitements[$p->nom_champ])) return $p->code; $ps = $table_des_traitements[$p->nom_champ]; if (is_array($ps)) { // new style if ($p->nom_boucle) $type = $p->boucles[$p->nom_boucle]->type_requete; else $type = $p->type_requete; $ps = $ps[isset($ps[$type]) ? $type : 0]; } if (!$ps) return $p->code; // Si une boucle DOCUMENTS{doublons} est presente dans le squelette, // ou si in INCLURE contient {doublons} // on insere une fonction de remplissage du tableau des doublons // dans les filtres propre() ou typo() // (qui traitent les raccourcis referencant les docs) // NB: le test permet d'eviter ce calcul quand on sait qu'il ne servira pas // un test plus complexe que la simple presence de {doublons ne peut etre realise par preg_match // mais necessite de parser le squelette // ex : =200}{hauteur>120} {par num titre, date} {doublons}> // peut etre faut il inserer ici la fonction betement, dans le compilateur lever un flag si elle est effectivement necessaire // et in fine, remplacer dansle squelette calcule 'traiter_doublons_documents' par 'ne_pas_traiter_doublons_documents' si elle n'est pas utile ? if (!isset($test_doublons[$p->descr['sourcefile']])) $test_doublons[$p->descr['sourcefile']] = (strpos($p->descr['squelette'],'{doublons')!==false); #preg_match(',([<#]INCLU[RD]E|DOCUMENTS)([^<>]*?{[^}]*})*{doublons,',$p->descr['squelette']); if ($test_doublons[$p->descr['sourcefile']] AND ( (strpos($ps,'propre') !== false) OR (strpos($ps,'typo') !== false) )) $ps = 'traiter_doublons_documents($doublons, '.$ps.')'; // Passer |safehtml sur les boucles "sensibles" // sauf sur les champs dont on est surs switch ($p->type_requete) { case 'forums': case 'signatures': case 'syndic_articles': $champs_surs = array( 'date', 'date_heure', 'statut', 'ip', 'url_article', 'maj', 'idx', 'parametres_forum'); if (!in_array(strtolower($p->nom_champ), $champs_surs) AND !preg_match(',^ID_,', $p->nom_champ)) $ps = 'safehtml('.$ps.')'; break; default: break; } // Remplacer enfin le placeholder %s par le vrai code de la balise return str_replace('%s', $p->code, $ps); } // // Appliquer les filtres a un champ [(#CHAMP|filtre1|filtre2)] // retourne un code php compile exprimant ce champ filtre et securise // - une etoile => pas de processeurs standards // - deux etoiles => pas de securite non plus ! // // http://doc.spip.org/@applique_filtres function applique_filtres($p) { // Traitements standards (cf. supra) if ($p->etoile == '') $code = champs_traitements($p); else $code = $p->code; // Appliquer les filtres perso if ($p->param) $code = compose_filtres($p, $code); // S'il y a un lien avec la session, ajouter un code qui levera // un drapeau dans la structure d'invalidation $Cache if (isset($p->descr['session'])) $code = "invalideur_session(\$Cache, $code)"; // Securite if ($p->interdire_scripts AND $p->etoile != '**') $code = "interdire_scripts($code)"; return $code; } // Cf. function pipeline dans ecrire/inc_utils.php // http://doc.spip.org/@compose_filtres function compose_filtres(&$p, $code) { global $table_criteres_infixes; $image_miette = false; foreach($p->param as $filtre) { $fonc = array_shift($filtre); if ($fonc) { $is_filtre_image = ((substr($fonc,0,6)=='image_') AND $fonc!='image_graver'); if ($image_miette AND !$is_filtre_image){ // il faut graver maintenant car apres le filtre en cours // on est pas sur d'avoir encore le nom du fichier dans le pipe $code = "filtrer('image_graver', $code)"; $image_miette = false; } // recuperer les arguments du filtre, les separer par des virgules // dans le cas du filtre "?{a,b}", on demande un ":" if ($fonc == '?') { // |?{a,b} *doit* avoir exactement 2 arguments ; on les force if (count($filtre) != 2) $filtre = array(isset($filtre[0])?$filtre[0]:"", isset($filtre[1])?$filtre[1]:""); $arglist = compose_filtres_args($p, $filtre, ':'); } else $arglist = compose_filtres_args($p, $filtre, ','); $arg = substr($arglist,1); // compiler le filtre switch (true) { // est-ce un test ? case in_array($fonc, $table_criteres_infixes): $code = "($code $fonc $arg)"; break; // cas de et,ou,oui,non,sinon,xou,xor,and,or,not,yes case ($fonc == 'and') OR ($fonc == 'et'): $code = "((($code) AND ($arg)) ?' ' :'')"; break; case ($fonc == 'or') OR ($fonc == 'ou'): $code = "((($code) OR ($arg)) ?' ' :'')"; break; case ($fonc == 'xor') OR ($fonc == 'xou'): $code = "((($code) XOR ($arg)) ?' ' :'')"; break; case ($fonc == 'sinon'): $code = "(strlen(\$a = $code) ? \$a : $arg)"; break; case ($fonc == 'not') OR ($fonc == 'non'): $code = "(($code) ?'' :' ')"; break; case ($fonc == 'yes') OR ($fonc == 'oui'): $code = "(($code) ?' ' :'')"; break; default: if (isset($GLOBALS['spip_matrice'][$fonc])) { $code = "filtrer('$fonc',$code$arglist)"; if ($is_filtre_image) $image_miette = true; } // le filtre est defini sous forme de fonction ou de methode // par ex. dans inc_texte, inc_filtres ou mes_fonctions else if ($f = chercher_filtre($fonc)) { $code = "$f($code$arglist)"; } // le filtre n'existe pas, on provoque une erreur else { $code .= ".erreur_squelette('" .texte_script(_T('zbug_erreur_filtre', array('filtre'=>$fonc))) ."','" . $p->id_boucle . "')"; } } } } // ramasser les images intermediaires inutiles et graver l'image finale if ($image_miette) $code = "filtrer('image_graver',$code)"; return $code; } // http://doc.spip.org/@compose_filtres_args function compose_filtres_args($p, $args, $sep) { $arglist = ""; foreach ($args as $arg) { $arglist .= $sep . calculer_liste($arg, $p->descr, $p->boucles, $p->id_boucle); } return $arglist; } // // Reserve les champs necessaires a la comparaison avec le contexte donne par // la boucle parente ; attention en recursif il faut les reserver chez soi-meme // ET chez sa maman // // http://doc.spip.org/@calculer_argument_precedent function calculer_argument_precedent($idb, $nom_champ, &$boucles) { // si recursif, forcer l'extraction du champ SQL mais ignorer le code if ($boucles[$idb]->externe) { index_pile ($idb, $nom_champ, $boucles); $zero = '$SP'; } else $zero = '0'; // retourner $Pile[$SP] et pas $Pile[0] si recursion en 1ere boucle $prec = $boucles[$idb]->id_parent; return (($prec === '') ? ('$Pile[' . $zero . "]['$nom_champ']") : index_pile($prec, $nom_champ, $boucles)); } // // Rechercher dans la pile des boucles actives celle ayant un critere // comportant un certain $motif, et construire alors une reference // a l'environnement de cette boucle, qu'on indexe avec $champ. // Sert a referencer une cellule non declaree dans la table et pourtant la. // Par exemple pour la balise #POINTS on produit $Pile[$SP-n]['points'] // si la n-ieme boucle a un critere "recherche", car on sait qu'il a produit // "SELECT XXXX AS points" // // http://doc.spip.org/@rindex_pile function rindex_pile($p, $champ, $motif) { $n = 0; $b = $p->id_boucle; $p->code = ''; while ($b != '') { foreach($p->boucles[$b]->criteres as $critere) { if ($critere->op == $motif) { $p->code = '$Pile[$SP' . (($n==0) ? "" : "-$n") . "]['$champ']"; $b = ''; break 2; } } $n++; $b = $p->boucles[$b]->id_parent; } // si on est hors d'une boucle de {recherche}, cette balise est vide if (!$p->code) $p->code = "''"; $p->interdire_scripts = false; return $p; } ?> spip/spip/ecrire/public/styliser.php0000766000000000000000000000605711236524730021025 0ustar adminadministrators array( 'id_rubrique' => $id_rubrique, 'ext' => $ext, 'fond' => $fond, 'lang' => $lang, 'contexte' => $GLOBALS['contexte'], // le style d'un objet peut dependre de lui meme 'connect' => $connect ), 'data' => $squelette, )); // Trouver un squelette de base dans le chemin if (!$squelette) { // Si pas de squelette regarder si c'est une table $trouver_table = charger_fonction('trouver_table', 'base'); if (preg_match('/^table:(.*)$/', $fond, $r) AND $table = $trouver_table($r[1], $connect) AND include_spip('inc/autoriser') AND autoriser('webmestre') ) { $fond = $r[1]; $squelette = _DIR_TMP . 'table_'.$fond; $base = $squelette . ".$ext"; if (!file_exists($base) OR $GLOBALS['var_mode']) { $vertebrer = charger_fonction('vertebrer', 'public'); ecrire_fichier($base, $vertebrer($table)); } } else { // Indiquer une erreur squelette include_spip('public/debug'); erreur_squelette(_T('info_erreur_squelette2', array('fichier'=>"'$fond.$ext'")), $GLOBALS['dossier_squelettes']); // provoquer 404 return array(null, $ext, $ext, null); } } // On selectionne, dans l'ordre : // fond=10 if ($id_rubrique) { $f = "$squelette=$id_rubrique"; if (@file_exists("$f.$ext")) $squelette = $f; else { // fond-10 fond- do { $f = "$squelette-$id_rubrique"; if (@file_exists("$f.$ext")) { $squelette = $f; break; } } while ($id_rubrique = quete_parent($id_rubrique)); } } // Affiner par lang if ($lang) { $l = lang_select($lang); $f = "$squelette.".$GLOBALS['spip_lang']; if ($l) lang_select(); if (@file_exists("$f.$ext")) $squelette = $f; } return array($squelette, $ext, $ext, "$squelette.$ext"); } ?> spip/spip/ecrire/public/jointures.php0000766000000000000000000002607211236524730021170 0ustar adminadministratorsdescr['nom']][$boucle->id_boucle]; foreach($res as $cle=>$r) { list($d, $a, $j) = $r; if (!$id_table) $id_table = $d; $n = ++$cpt; if (is_array($j)){ // c'est un lien sur un champ du type id_objet,objet,'article' list($j1,$j2,$obj,$type) = $j; // trouver de quel cote est (id_objet,objet) if ($j1=="id_$obj") $obj = "$id_table.$obj"; else $obj = "L$n.$obj"; // le where complementaire est envoye dans la jointure pour pouvoir etre elimine avec la jointure // en cas d'optimisation //$boucle->where[] = array("'='","'$obj'","sql_quote('$type')"); $boucle->join["L$n"]= array("'$id_table'","'$j2'","'$j1'","'$obj='.sql_quote('$type')"); } else $boucle->join["L$n"]= array("'$id_table'","'$j'"); $boucle->from[$id_table = "L$n"] = $a[0]; } // pas besoin de group by // (cf http://article.gmane.org/gmane.comp.web.spip.devel/30555) // si une seule jointure et sur une table avec primary key formee // de l'index principal et de l'index de jointure (non conditionnel! [6031]) // et operateur d'egalite (http://trac.rezo.net/trac/spip/ticket/477) if ($pk = ((count($boucle->from) == 2) && !$cond)) { $pk = nogroupby_if($desc, $a[1], $id_primary, $col); } // pas de group by // si une seule jointure // et si l'index de jointure est une primary key a l'arrivee ! if (!$pk AND (count($boucle->from) == 2) AND ($j == $a[1]['key']['PRIMARY KEY']) ) $pk = true; // la clause Group by est en conflit avec ORDER BY, a completer $groups = liste_champs_jointures($nom,$desc,true); if (!$pk) foreach($groups as $id_prim){ $id_field = $nom . '.' . $id_prim; if (!in_array($id_field, $boucle->group)) { $boucle->group[] = $id_field; } } $boucle->modificateur['lien'] = true; return "L$n"; } // condition suffisante pour qu'un Group-By ne soit pas necessaire // A ameliorer, notamment voir si calculer_select ne pourrait pas la reutiliser // lorsqu'on sait si le critere conditionnel est finalement present // http://doc.spip.org/@nogroupby_if function nogroupby_if($depart, $arrivee, $id_primary, $col) { $pk = $arrivee['key']['PRIMARY KEY']; if (!$pk) return false; $id_primary = $depart['key']['PRIMARY KEY']; if (is_array($col)) $col = implode(', *',$col); // cas id_objet, objet return (preg_match("/^$id_primary, *$col$/", $pk) OR preg_match("/^$col, *$id_primary$/", $pk)); } // http://doc.spip.org/@liste_champs_jointures function liste_champs_jointures($nom,$desc,$primary=false){ static $nojoin = array('idx','maj','date','statut'); // si cle primaire demandee, la privilegier if ($primary && isset($desc['key']['PRIMARY KEY'])) return split_key($desc['key']['PRIMARY KEY']); // les champs declares explicitement pour les jointures if (isset($desc['join'])) return $desc['join']; /*elseif (isset($GLOBALS['tables_principales'][$nom]['join'])) return $GLOBALS['tables_principales'][$nom]['join']; elseif (isset($GLOBALS['tables_auxiliaires'][$nom]['join'])) return $GLOBALS['tables_auxiliaires'][$nom]['join'];*/ // si pas de cle, c'est fichu if (!isset($desc['key'])) return array(); // si cle primaire if (isset($desc['key']['PRIMARY KEY'])) return split_key($desc['key']['PRIMARY KEY']); // ici on se rabat sur les cles secondaires, // en eliminant celles qui sont pas pertinentes (idx, maj) // si jamais le resultat n'est pas pertinent pour une table donnee, // il faut declarer explicitement le champ 'join' de sa description $join = array(); foreach($desc['key'] as $v) $join = split_key($v, $join); foreach($join as $k) if (in_array($k, $nojoin)) unset($join[$k]); return $join; } // http://doc.spip.org/@split_key function split_key($v, $join = array()) { foreach (preg_split('/,\s*/', $v) as $k) $join[$k] = $k; return $join; } // http://doc.spip.org/@calculer_chaine_jointures function calculer_chaine_jointures(&$boucle, $depart, $arrivee, $vu=array(), $milieu_exclus = array(), $max_liens = 5) { static $trouver_table; if (!$trouver_table) $trouver_table = charger_fonction('trouver_table', 'base'); if (is_string($milieu_exclus)) $milieu_exclus = array($milieu_exclus); list($dnom,$ddesc) = $depart; list($anom,$adesc) = $arrivee; if (!count($vu)) $vu[] = $dnom; // ne pas oublier la table de depart $akeys = $adesc['key']; if ($v = $akeys['PRIMARY KEY']) { unset($akeys['PRIMARY KEY']); $akeys = array_merge(preg_split('/,\s*/', $v), $akeys); } // enlever les cles d'arrivee exclues par l'appel $akeys = array_diff($akeys,$milieu_exclus); // cles candidates au depart $keys = liste_champs_jointures($dnom,$ddesc); // enlever les cles dde depart exclues par l'appel $keys = array_diff($keys,$milieu_exclus); $v = !$keys ? false : array_intersect(array_values($keys), $akeys); if ($v) return array(array($dnom, array($adesc['table'],$adesc), array_shift($v))); // regarder si l'on a (id_objet,objet) au depart et si on peut le mapper sur un id_xx if (count(array_intersect(array('id_objet','objet'),$keys))==2){ // regarder si l'une des cles d'arrivee peut se decomposer en // id_objet,objet // si oui on la prend foreach($akeys as $key){ $v = decompose_champ_id_objet($key); if (is_array($v)){ $objet = array_shift($v);// objet,'article' array_unshift($v,$key); // id_article,objet,'article' array_unshift($v,$objet); // id_objet,id_article,objet,'article' return array(array($dnom, array($adesc['table'],$adesc), $v)); } } } else { // regarder si l'une des cles de depart peut se decomposer en // id_objet,objet a l'arrivee // si oui on la prend foreach($keys as $key){ if (count($v = trouver_champs_decomposes($key,$adesc))>1){ if (count($v)==count(array_intersect($v, $akeys))) $v = decompose_champ_id_objet($key); // id_objet,objet,'article' array_unshift($v,$key); // id_article,id_objet,objet,'article' return array(array($dnom, array($adesc['table'],$adesc), $v)); } } } // si l'on voulait une jointure direct, c'est rate ! if ($max_liens<=1) return array(); // sinon essayer de passer par une autre table $new = $vu; foreach($boucle->jointures as $v) { if ($v && (!in_array($v,$vu)) && ($def = $trouver_table($v, $boucle->sql_serveur))) { // ne pas tester les cles qui sont exclues a l'appel // ie la cle de la jointure precedente $test_cles = $milieu_exclus; $new[] = $v; $max_iter = 50; // securite while (count($jointure_directe_possible = calculer_chaine_jointures($boucle,$depart,array($v, $def),$vu,$test_cles,1)) AND $max_iter--) { $jointure_directe_possible = reset($jointure_directe_possible); $milieu = end($jointure_directe_possible); if (is_string($milieu)) $test_cles[] = $milieu; else $test_cles = array_merge($test_cles,$milieu); // essayer de rejoindre l'arrivee a partir de cette etape intermediaire // sans repasser par la meme cle milieu $r = calculer_chaine_jointures($boucle, array($v, $def), $arrivee, $new, $milieu,$max_liens-1); if ($r) { array_unshift($r, $jointure_directe_possible); return $r; } } } } return array(); } // applatit les cles multiples // http://doc.spip.org/@trouver_cles_table function trouver_cles_table($keys) { $res =array(); foreach ($keys as $v) { if (!strpos($v,",")) $res[$v]=1; else { foreach (split(" *, *", $v) as $k) { $res[$k]=1; } } } return array_keys($res); } // http://doc.spip.org/@trouver_champ_exterieur function trouver_champ_exterieur($cle, $joints, &$boucle, $checkarrivee = false) { static $trouver_table; if (!$trouver_table) $trouver_table = charger_fonction('trouver_table', 'base'); // support de la recherche multi champ if (!is_array($cle)) $cle = array($cle); foreach($joints as $k => $join) { if ($join && $table = $trouver_table($join, $boucle->sql_serveur)) { if (isset($table['field']) // verifier que toutes les cles cherchees sont la AND (count(array_intersect($cle, array_keys($table['field'])))==count($cle)) // si on sait ou on veut arriver, il faut que ca colle AND ($checkarrivee==false || $checkarrivee==$table['table'])) return array($table['table'], $table); } } // une cle id_xx peut etre implementee par un couple (id_objet,objet) foreach($cle as $k=>$c) { if (is_array($decompose = decompose_champ_id_objet($c))){ unset($cle[$k]); $cle[] = array_shift($decompose); // id_objet $cle[] = array_shift($decompose); // objet return trouver_champ_exterieur($cle,$joints,$boucle,$checkarrivee); } } return ""; } // http://doc.spip.org/@trouver_jointure_champ function trouver_jointure_champ($champ, &$boucle) { $cle = trouver_champ_exterieur($champ, $boucle->jointures, $boucle); if ($cle) { $desc = $boucle->show; $cle = calculer_jointure($boucle, array($desc['id_table'], $desc), $cle, false); } if ($cle) return $cle; spip_log("trouver_jointure_champ: $champ inconnu"); return ''; } ?> spip/spip/ecrire/public/interfaces.php0000766000000000000000000003157211236524730021272 0ustar adminadministrators var $sql_serveur = ''; var $param = array(); var $criteres = array(); var $separateur = array(); var $jointures = array(); var $jointures_explicites = false; var $doublons; var $partie, $total_parties,$mode_partie; var $externe = ''; # appel a partir d'une autre boucle (recursion) // champs pour la construction de la requete SQL var $select = array(); var $from = array(); var $from_type = array(); var $where = array(); var $join = array(); var $having = array(); var $limit; var $group = array(); var $order = array(); var $default_order = array(); var $date = 'date' ; var $hash = "" ; var $in = "" ; var $sous_requete = false; var $hierarchie = ''; var $statut = false; # definition/surcharge du statut des elements retournes // champs pour la construction du corps PHP var $show = array(); var $id_table; var $primary; var $return; var $numrows = false; var $cptrows = false; var $ligne = 0; var $descr = array(); # noms des fichiers source et but etc var $modificateur = array(); // table pour stocker les modificateurs de boucle tels que tout, plat ..., utilisable par les plugins egalement // obsoletes, conserves provisoirement pour compatibilite var $tout = false; var $plat = false; var $lien = false; } // sous-noeud du precedent // http://doc.spip.org/@Critere class Critere { var $op; var $not; var $exclus; var $param = array(); var $ligne = 0; } // http://doc.spip.org/@Champ class Champ { var $type = 'champ'; var $nom_champ; var $nom_boucle= ''; // seulement si boucle explicite var $avant, $apres; // tableaux d'objets var $etoile; var $param = array(); // filtre explicites var $fonctions = array(); // source des filtres (compatibilite) // champs pour la production de code var $id_boucle; var $boucles; var $type_requete; var $code; // code du calcul var $interdire_scripts = true; // false si on est sur de cette balise // tableau pour la production de code dependant du contexte // id_mere; pour TOTAL_BOUCLE hors du corps // document; pour embed et img dans les textes // sourcefile; pour DOSSIER_SQUELETTE var $descr = array(); // pour localiser les erreurs var $ligne = 0; } // http://doc.spip.org/@Idiome class Idiome { var $type = 'idiome'; var $nom_champ = ""; // la chaine a traduire var $module = ""; // son module de definition var $arg = array(); // les arguments a passer a la chaine var $param = array(); // les filtres a appliquer au resultat var $fonctions = array(); // source des filtres (compatibilite) var $avant, $apres; // inutilises mais faut = ci-dessus // champs pour la production de code, cf ci-dessus var $id_boucle; var $boucles; var $type_requete; var $code; var $interdire_scripts = false; var $descr = array(); var $ligne = 0; } // http://doc.spip.org/@Polyglotte class Polyglotte { var $type = 'polyglotte'; var $traductions = array(); // les textes ou choisir var $ligne = 0; } global $table_criteres_infixes; $table_criteres_infixes = array('<', '>', '<=', '>=', '==', '===', '!=', '!==', '<>', '?'); global $exception_des_connect; $exception_des_connect[] = ''; // ne pas transmettre le connect='' par les inclure // // Globales de description de la base //ces variables ne sont pas initialisees par "$var = array()" // afin de permettre leur extension dans mes_options.php etc // http://doc.spip.org/@declarer_interfaces function declarer_interfaces(){ global $exceptions_des_tables, $table_des_tables, $table_date, $table_titre; $table_des_tables['articles']='articles'; $table_des_tables['auteurs']='auteurs'; $table_des_tables['breves']='breves'; $table_des_tables['forums']='forum'; $table_des_tables['signatures']='signatures'; $table_des_tables['documents']='documents'; $table_des_tables['types_documents']='types_documents'; $table_des_tables['mots']='mots'; $table_des_tables['groupes_mots']='groupes_mots'; $table_des_tables['rubriques']='rubriques'; $table_des_tables['syndication']='syndic'; $table_des_tables['syndic']='syndic'; $table_des_tables['syndic_articles']='syndic_articles'; $table_des_tables['hierarchie']='rubriques'; $table_des_tables['index']='index'; $table_des_tables['messages']='messages'; $table_des_tables['petitions']='petitions'; $exceptions_des_tables['breves']['id_secteur']='id_rubrique'; $exceptions_des_tables['breves']['date']='date_heure'; $exceptions_des_tables['breves']['nom_site']='lien_titre'; $exceptions_des_tables['breves']['url_site']='lien_url'; $exceptions_des_tables['forums']['date']='date_heure'; $exceptions_des_tables['forums']['nom']='auteur'; $exceptions_des_tables['forums']['email']='email_auteur'; $exceptions_des_tables['signatures']['date']='date_time'; $exceptions_des_tables['signatures']['nom']='nom_email'; $exceptions_des_tables['signatures']['email']='ad_email'; $exceptions_des_tables['documents']['type_document']=array('types_documents' , 'titre'); $exceptions_des_tables['documents']['extension_document']=array('types_documents', 'extension'); $exceptions_des_tables['documents']['mime_type']=array('types_documents' , 'mime_type'); # ne sert plus ? verifier balise_URL_ARTICLE $exceptions_des_tables['syndic_articles']['url_article']='url'; # ne sert plus ? verifier balise_LESAUTEURS $exceptions_des_tables['syndic_articles']['lesauteurs']='lesauteurs'; $exceptions_des_tables['syndic_articles']['url_site']=array('syndic', 'url_site'); $exceptions_des_tables['syndic_articles']['nom_site']=array('syndic', 'nom_site'); $table_titre['mots']= "titre, '' AS lang"; $table_titre['breves']= 'titre , lang'; $table_titre['articles']= 'titre, lang'; $table_titre['rubriques']= 'titre, lang'; $table_titre['forums']= "titre, '' AS lang"; $table_titre['messages']= "titre, '' AS lang"; $table_titre['auteurs']= "nom AS titre, '' AS lang"; $table_titre['site']= "nom_site AS titre, '' AS lang"; $table_titre['syndic']= "nom_site AS titre, '' AS lang"; $table_titre['documents']= "titre, fichier AS surnom, '' AS lang"; $table_date['articles']='date'; $table_date['auteurs']='date'; $table_date['breves']='date_heure'; $table_date['forums']='date_heure'; $table_date['signatures']='date_time'; $table_date['documents']='date'; $table_date['types_documents']='date'; $table_date['groupes_mots']='date'; $table_date['mots']='date'; $table_date['rubriques']='date'; $table_date['syndication']='date'; $table_date['syndic_articles']='date'; // // tableau des tables de jointures // Ex: gestion du critere {id_mot} dans la boucle(ARTICLES) global $tables_jointures; $tables_jointures['spip_articles'][]= 'mots_articles'; $tables_jointures['spip_articles']['id_auteur']= 'auteurs_articles'; $tables_jointures['spip_articles'][]= 'documents_liens'; $tables_jointures['spip_articles'][]= 'mots'; $tables_jointures['spip_articles'][]= 'signatures'; $tables_jointures['spip_articles'][]= 'petitions'; $tables_jointures['spip_auteurs'][]= 'auteurs_articles'; $tables_jointures['spip_breves'][]= 'mots_breves'; $tables_jointures['spip_breves'][]= 'documents_liens'; $tables_jointures['spip_breves'][]= 'mots'; $tables_jointures['spip_documents'][]= 'documents_liens'; $tables_jointures['spip_documents'][]= 'mots_documents'; $tables_jointures['spip_documents'][]= 'types_documents'; $tables_jointures['spip_documents'][]= 'mots'; $tables_jointures['spip_forum'][]= 'mots_forum'; $tables_jointures['spip_forum'][]= 'mots'; $tables_jointures['spip_forum'][]= 'documents_liens'; $tables_jointures['spip_rubriques'][]= 'mots_rubriques'; $tables_jointures['spip_rubriques'][]= 'documents_liens'; $tables_jointures['spip_rubriques'][]= 'mots'; $tables_jointures['spip_syndic'][]= 'mots_syndic'; $tables_jointures['spip_syndic'][]= 'mots'; $tables_jointures['spip_syndic_articles'][]= 'syndic'; $tables_jointures['spip_syndic_articles'][]= 'mots_syndic'; $tables_jointures['spip_syndic_articles'][]= 'mots'; $tables_jointures['spip_mots'][]= 'mots_articles'; $tables_jointures['spip_mots'][]= 'mots_breves'; $tables_jointures['spip_mots'][]= 'mots_forum'; $tables_jointures['spip_mots'][]= 'mots_rubriques'; $tables_jointures['spip_mots'][]= 'mots_syndic'; $tables_jointures['spip_mots'][]= 'mots_documents'; $tables_jointures['spip_groupes_mots'][]= 'mots'; global $exceptions_des_jointures; $exceptions_des_jointures['titre_mot'] = array('spip_mots', 'titre'); $exceptions_des_jointures['type_mot'] = array('spip_mots', 'type'); $exceptions_des_jointures['id_mot_syndic']= array('spip_mots_syndic','id_mot'); $exceptions_des_jointures['titre_mot_syndic']= array('spip_mots','titre'); $exceptions_des_jointures['type_mot_syndic']= array('spip_mots','type'); $exceptions_des_jointures['petition'] = array('spip_petitions', 'texte'); $exceptions_des_jointures['id_signature']= array('spip_signatures', 'id_signature'); global $table_des_traitements; define('_TRAITEMENT_TYPO', 'typo(%s, "TYPO", $connect)'); define('_TRAITEMENT_RACCOURCIS', 'propre(%s, $connect)'); $table_des_traitements['BIO'][]= _TRAITEMENT_RACCOURCIS; $table_des_traitements['CHAPO'][]= _TRAITEMENT_RACCOURCIS; $table_des_traitements['DATE'][]= 'normaliser_date(%s)'; $table_des_traitements['DATE_REDAC'][]= 'normaliser_date(%s)'; $table_des_traitements['DATE_MODIF'][]= 'normaliser_date(%s)'; $table_des_traitements['DATE_NOUVEAUTES'][]= 'normaliser_date(%s)'; $table_des_traitements['DESCRIPTIF'][]= _TRAITEMENT_RACCOURCIS; $table_des_traitements['FICHIER']['documents']= 'get_spip_doc(%s)'; $table_des_traitements['INTRODUCTION'][]= 'PtoBR('. _TRAITEMENT_RACCOURCIS .')'; $table_des_traitements['LIEN_TITRE'][]= _TRAITEMENT_TYPO; $table_des_traitements['LIEN_URL'][]= 'vider_url(%s)'; $table_des_traitements['MESSAGE'][]= _TRAITEMENT_RACCOURCIS; $table_des_traitements['NOM_SITE_SPIP'][]= _TRAITEMENT_TYPO; $table_des_traitements['NOM_SITE'][]= _TRAITEMENT_TYPO; $table_des_traitements['NOM'][]= _TRAITEMENT_TYPO; $table_des_traitements['PARAMETRES_FORUM'][]= 'htmlspecialchars(%s)'; $table_des_traitements['PS'][]= _TRAITEMENT_RACCOURCIS; $table_des_traitements['SOURCE'][]= _TRAITEMENT_TYPO; $table_des_traitements['SOUSTITRE'][]= _TRAITEMENT_TYPO; $table_des_traitements['SURTITRE'][]= _TRAITEMENT_TYPO; $table_des_traitements['TAGS'][]= '%s'; $table_des_traitements['TEXTE'][]= _TRAITEMENT_RACCOURCIS; $table_des_traitements['TITRE'][]= _TRAITEMENT_TYPO; $table_des_traitements['TYPE'][]= _TRAITEMENT_TYPO; $table_des_traitements['DESCRIPTIF_SITE_SPIP'][]= _TRAITEMENT_RACCOURCIS; $table_des_traitements['ENV'][]= 'entites_html(%s,true)'; // Articles syndiques : passage des donnees telles quelles, sans traitement typo // A noter, dans applique_filtres la securite et conformite XHTML de ces champs // est assuree par safehtml() foreach(array('TITRE','DESCRIPTIF','SOURCE') as $balise) if (!isset($table_des_traitements[$balise]['syndic_articles'])) $table_des_traitements[$balise]['syndic_articles'] = '%s'; // gerer l'affectation en 2 temps car si le pipe n'est pas encore declare, on ecrase les globales $interfaces = pipeline('declarer_tables_interfaces', array( 'table_des_tables'=>$table_des_tables, 'exceptions_des_tables'=>$exceptions_des_tables, 'table_date'=>$table_date, 'tables_jointures'=>$tables_jointures, 'exceptions_des_jointures'=>$exceptions_des_jointures, 'table_des_traitements'=>$table_des_traitements, )); if ($interfaces){ $table_des_tables = $interfaces['table_des_tables']; $exceptions_des_tables = $interfaces['exceptions_des_tables']; $table_date = $interfaces['table_date']; $tables_jointures = $interfaces['tables_jointures']; $exceptions_des_jointures = $interfaces['exceptions_des_jointures']; $table_des_traitements = $interfaces['table_des_traitements']; } } declarer_interfaces(); ?> spip/spip/ecrire/public/quete.php0000766000000000000000000002675011236524730020274 0ustar adminadministrators time()) ? date('Y-m-d H:i:s', $GLOBALS['meta']['date_prochain_postdate']) : '9999-12-31'; } # retourne le fichier d'un document // http://doc.spip.org/@quete_fichier function quete_fichier($id_document, $serveur) { return sql_getfetsel('fichier', 'spip_documents', ("id_document=" . intval($id_document)), '',array(), '', '', $serveur); } // http://doc.spip.org/@quete_petitions function quete_petitions($id_article, $table, $id_boucle, $serveur, &$cache) { $retour = sql_getfetsel('texte', 'spip_petitions',("id_article=".intval($id_article)),'',array(),'','', $serveur); if ($retour === NULL) return ''; # cette page est invalidee par toute petition $cache['varia']['pet'.$id_article] = 1; # ne pas retourner '' car le texte sert aussi de presence return $retour ? $retour : ' '; } # retourne le champ 'accepter_forum' d'un article // http://doc.spip.org/@quete_accepter_forum function quete_accepter_forum($id_article) { // si la fonction est appelee en dehors d'une boucle // article (forum de breves), $id_article est nul // mais il faut neanmoins accepter l'affichage du forum // d'ou le 0=>'' (et pas 0=>'non'). static $cache = array(0 => ''); $id_article = intval($id_article); if (isset($cache[$id_article])) return $cache[$id_article]; return $cache[$id_article] = sql_getfetsel('accepter_forum','spip_articles',"id_article=$id_article"); } // recuperer une meta sur un site distant (en local il y a plus simple) // http://doc.spip.org/@quete_meta function quete_meta($nom, $serveur) { return sql_getfetsel("valeur", "spip_meta", "nom=" . sql_quote($nom), '','','','',$serveur); } // http://doc.spip.org/@calcul_exposer function calcul_exposer ($id, $prim, $reference, $parent, $type, $connect='') { static $exposer = array(); static $ref_precedente =-1; // Que faut-il exposer ? Tous les elements de $reference // ainsi que leur hierarchie ; on ne fait donc ce calcul // qu'une fois (par squelette) et on conserve le resultat // en static. if (!isset($exposer[$m=md5(serialize($reference))][$prim])) { $principal = $reference[$type]; // le parent fournit en argument est le parent de $id, pas celui de $principal // il n'est donc pas utile $parent = 0; if (!$principal) { // regarder si un enfant est dans le contexte, auquel cas il expose peut etre le parent courant $enfants = array('id_rubrique'=>array('id_article'),'id_groupe'=>array('id_mot')); if (isset($enfants[$type])) foreach($enfants[$type] as $t) if (isset($reference[$t])) { $type = $t; $principal = $reference[$type]; continue; } } $exposer[$m][$type] = array(); if ($principal) { $principaux = is_array($principal)?$principal:array($principal); foreach($principaux as $principal){ $exposer[$m][$type][$principal] = true; if ($type == 'id_mot'){ if (!$parent) { $parent = sql_fetsel('id_groupe','spip_mots',"id_mot=" . $principal, '','','','',$connect); $parent = $parent['id_groupe']; } if ($parent) $exposer[$m]['id_groupe'][$parent] = true; } else if ($type != 'id_groupe') { if (!$parent) { if ($type == 'id_rubrique') $parent = $principal; if ($type == 'id_article') { $parent = sql_fetsel('id_rubrique','spip_articles',"id_article=" . $principal, '','','','',$connect); $parent = $parent['id_rubrique']; } } do { $exposer[$m]['id_rubrique'][$parent] = true; } while ($parent = quete_parent($parent, $connect)); } } } } // And the winner is... return isset($exposer[$m][$prim]) ? isset($exposer[$m][$prim][$id]) : ''; } // fonction appelee par la balise #LOGO_DOCUMENT // http://doc.spip.org/@calcule_logo_document function calcule_logo_document($id_document, $doubdoc, &$doublons, $flag_fichier, $lien, $align, $params='', $connect='') { include_spip('inc/documents'); if (!$id_document) return ''; if ($doubdoc) $doublons["documents"] .= ','.$id_document; if (!($row = sql_fetsel('titre, taille, extension, id_vignette, fichier, mode', 'spip_documents', ("id_document = $id_document"),'','','','',$connect))) { // pas de document. Ne devrait pas arriver spip_log("Erreur du compilateur doc $id_document inconnu"); return ''; } $extension = $row['extension']; $id_vignette = $row['id_vignette']; $fichier = $row['fichier']; $mode = $row['mode']; // taille maximum [(#LOGO_DOCUMENT{300,52})] // et/ou type de la vignette [(#LOGO_DOCUMENT{icone,300,52})] // parmi : // icone -> icone du type de document // apercu -> image reduite si possible (mais pas la vignette telechargee) ou logo_type sinon // vignette -> vignette telechargee uniquement, sinon rien // auto -> mode par defaut si pas indique : vignette, sinon image reduite, sinon logo_type $mode_logo = 'auto'; $params = explode(',',rtrim(ltrim($params,'{'),'}')); $params = array_map('trim',$params); if (in_array(reset($params),array('icone','apercu','auto','vignette'))) $mode_logo = array_shift($params); // ignorer un mode errone elseif (count($params)==3 AND !is_numeric($params[0])) array_shift($params); if (is_numeric($params[0]) AND is_numeric($params[1])){ $x = intval($params[0]); $y = intval($params[1]); } else $x = $y = 0; if ($mode_logo == 'vignette' AND !$id_vignette) return ''; if ($mode_logo == 'icone') $logo = img_logo_document($fichier, $extension, 0, 'icone', $x, $y, $connect); elseif ($mode_logo == 'apercu') $logo = img_logo_document($fichier, $extension, 0, $mode, $x, $y, $connect); else $logo = img_logo_document($fichier, $extension, $id_vignette, $mode, $x, $y, $connect); // flag_fichier : seul le fichier est demande if ($flag_fichier) return set_spip_doc(extraire_attribut($logo, 'src')); // Calculer le code html complet (cf. calcule_logo) $logo = inserer_attribut($logo, 'alt', ''); $logo = inserer_attribut($logo, 'class', 'spip_logos'); if ($align) $logo = inserer_attribut($logo, 'align', $align); if (!$lien) return $logo; $titre = supprimer_tags(typo($row['titre'])); $taille = taille_en_octets($row['taille']); $type = sql_fetsel('titre, mime_type','spip_types_documents', "extension = " . sql_quote($extension)); $mime = $type['mime_type']; $titre = $type['titre'] . " - $taille" . ($titre ? " - $titre" : ""); $titre = attribut_html(couper($titre, 80)); return "$logo"; } function img_logo_document($fichier, $extension, $id_vignette, $mode, $x, $y, $connect='') { if ($id_vignette) { $vignette = quete_fichier($id_vignette, $connect); if ($connect) { $site = quete_meta('adresse_site', $connect); $dir = quete_meta('dir_img', $connect); $logo = "$site/$dir$vignette"; } elseif (@file_exists(get_spip_doc($vignette))) $logo = generer_url_entite($id_vignette, 'document'); } else if ($mode == 'vignette') { $logo = generer_url_entite($id_vignette, 'document'); if (!@file_exists($logo)) $logo = ''; } else $logo = ''; if ($logo AND @file_exists($logo)) { if (!$x AND !$y) { $size = @getimagesize($logo); $logo = ""; } } else { // Pas de vignette, mais un fichier image -- creer la vignette // sauf si icone demandee explicitement if (strpos($GLOBALS['meta']['formats_graphiques'], $extension)!==false AND (!test_espace_prive() OR $GLOBALS['meta']['creer_preview']=='oui') AND $mode!=='icone') { if ($img = _DIR_RACINE.copie_locale(get_spip_doc($fichier)) AND @file_exists($img)) { if (!$x AND !$y) { $logo = reduire_image($img); } else { # eviter une double reduction $size = @getimagesize($img); $logo = ""; } } // cas de la vignette derriere un htaccess } elseif ($logo) $logo = ""; // Document sans vignette ni image : vignette par defaut if (!$logo) { $img = vignette_par_defaut($extension, false); $size = @getimagesize($img); $logo = ""; } } // Reduire si une taille precise est demandee return ($x OR $y) ? reduire_image($logo, $x, $y) : $logo; } // Ajouter "&lang=..." si la langue du forum n'est pas celle du site. // Si le 2e parametre n'est pas une chaine, c'est qu'on n'a pas pu // determiner la table a la compil, on le fait maintenant. // Il faudrait encore completer: on ne connait pas la langue // pour une boucle forum sans id_article ou id_rubrique donn� par le contexte // et c'est signale par un message d'erreur abscons: "table inconnue forum". // // http://doc.spip.org/@lang_parametres_forum function lang_parametres_forum($qs, $lang) { if (is_array($lang) AND preg_match(',id_(\w+)=([0-9]+),', $qs, $r)) { $id = 'id_' . $r[1]; if ($t = $lang[$id]) $lang = sql_getfetsel('lang', $t, "$id=" . $r[2]); } // Si ce n'est pas la meme que celle du site, l'ajouter aux parametres if ($lang AND $lang <> $GLOBALS['meta']['langue_site']) return $qs . "&lang=" . $lang; return $qs; } ?> spip/spip/ecrire/public/aiguiller.php0000766000000000000000000002004311236524730021113 0ustar adminadministratorsfalse)); $texte = $page; if ($ancre = _request('var_ajax_ancre')){ $texte = "anchor".$texte; } } else $texte = _L('signature ajax bloc incorrecte'); ajax_retour($texte); return true; // on a fini le hit } return false; } // au 1er appel, traite les formulaires dynamiques charger/verifier/traiter // au 2e se sachant 2e, retourne les messages et erreurs stockes au 1er // Le 1er renvoie True si il faut faire exit a la sortie // http://doc.spip.org/@traiter_formulaires_dynamiques function traiter_formulaires_dynamiques($get=false){ static $post = array(); static $done = false; if ($get) return $post; if ($done) return false; $done = true; if (!($form = _request('formulaire_action') AND $args = _request('formulaire_action_args'))) return false; // le hit peut continuer normalement include_spip('inc/filtres'); if (($args = decoder_contexte_ajax($args,$form))===false) { spip_log("signature ajax form incorrecte : $form"); return false; // continuons le hit comme si de rien etait } else { include_spip('inc/lang'); // sauvegarder la lang en cours $old_lang = $GLOBALS['spip_lang']; // changer la langue avec celle qui a cours dans le formulaire // on la depile de $args car c'est un argument implicite masque changer_langue(array_shift($args)); $verifier = charger_fonction("verifier","formulaires/$form/",true); $post["erreurs_$form"] = pipeline( 'formulaire_verifier', array( 'args'=>array('form'=>$form,'args'=>$args), 'data'=>$verifier?call_user_func_array($verifier,$args):array()) ); if ((count($post["erreurs_$form"])==0)){ $rev = ""; $retour = ""; if ($traiter = charger_fonction("traiter","formulaires/$form/",true)) $rev = call_user_func_array($traiter,$args); $rev = pipeline( 'formulaire_traiter', array( 'args'=>array('form'=>$form,'args'=>$args), 'data'=>$rev) ); // le retour de traiter peut avoir 3 formats // - simple message texte // - tableau a deux entrees ($editable,$message) // - tableau explicite ('editable'=>$editable,'message_ok'=>$message,'redirect'=>$redirect,'id_xx'=>$id_xx) // le dernier format est celui conseille car il permet le pipelinage, en particulier // en y passant l'id de l'objet cree/modifie // si message_erreur est present, on considere que le traitement a echoue // cas du message texte simple if (!is_array($rev)){ $post["message_ok_$form"] = $rev; } // cas du tableau deux valeurs simple (ancien format, deconseille) elseif (count($rev)==2 AND !array_key_exists('message_ok',$rev) AND !array_key_exists('message_erreur',$rev) AND !array_key_exists('redirect',$rev)) { $post["editable_$form"] = reset($rev); $post["message_ok_$form"] = end($rev); } // cas du tableau explicite (conseille) else { // verifier si traiter n'a pas echoue avec une erreur : if (isset($rev['message_erreur'])) { $post["erreurs_$form"]["message_erreur"] = $rev['message_erreur']; } else { // sinon faire ce qu'il faut : if (isset($rev['message_ok'])) $post["message_ok_$form"] = $rev['message_ok']; if (isset($rev['editable'])) $post["editable_$form"] = $rev['editable']; // si une redirection est demandee, appeler redirigae_formulaire qui choisira // le bon mode de redirection (302 et on ne revient pas ici, ou javascript et on continue) if (isset($rev['redirect']) AND $rev['redirect']){ include_spip('inc/headers'); list($masque,$message) = redirige_formulaire($rev['redirect'], '','ajaxform'); $post["message_ok_$form"] .= $message; $retour .= $masque; } } } } // si le formulaire a ete soumis en ajax, on le renvoie direct ! if (_request('var_ajax')){ if (find_in_path('formulaire_.php','balise/',true)) { include_spip('inc/actions'); include_spip('public/assembler'); array_unshift($args,$form); $retour .= inclure_balise_dynamique(call_user_func_array('balise_formulaire__dyn',$args),false); // on ajoute un br en display none en tete du retour ajax pour regler un bug dans IE6/7 // sans cela le formulaire n'est pas actif apres le hit ajax $retour = "".$retour; ajax_retour($retour,false); return true; // on a fini le hit } } // restaurer la lang en cours changer_langue($old_lang); } return false; // le hit peut continuer normalement } ?> spip/spip/ecrire/public/parametrer.php0000766000000000000000000001672411236524730021313 0ustar adminadministrators la page calculee # 'process_ins' => 'html' ou 'php' si presence d'un '< ?php' # 'invalideurs' => les invalideurs de ce cache # 'entetes' => headers http # 'duree' => duree de vie du cache # 'signal' => contexte (les id_* globales) # En cas d'erreur process_ins est absent et texte est un tableau de 2 chaines // http://doc.spip.org/@public_parametrer_dist function public_parametrer_dist($fond, $contexte='', $cache='', $connect='') { $page = tester_redirection($fond, $contexte, $connect); if ($page) return $page; // Choisir entre $fond-dist.html, $fond=7.html, etc? $id_rubrique_fond = 0; // Chercher le fond qui va servir de squelette if ($r = quete_rubrique_fond($contexte)) list($id_rubrique_fond, $lang) = $r; if (isset($contexte['lang'])) $lang = $contexte['lang']; elseif (!isset($lang)) $lang = $GLOBALS['meta']['langue_site']; $select = ((!isset($GLOBALS['forcer_lang']) OR !$GLOBALS['forcer_lang']) AND $lang <> $GLOBALS['spip_lang']); if ($select) $select = lang_select($lang); $styliser = charger_fonction('styliser', 'public'); list($skel,$mime_type, $gram, $sourcefile) = $styliser($fond, $id_rubrique_fond, $GLOBALS['spip_lang'], $connect); $debug = (isset($GLOBALS['var_mode']) && ($GLOBALS['var_mode'] == 'debug')); // sauver le nom de l'eventuel squelette en cours d'execution // (recursion possible a cause des modeles) if ($debug) { $courant = @$GLOBALS['debug_objets']['courant']; $GLOBALS['debug_objets']['contexte'][$sourcefile] = $contexte; } // charger le squelette en specifiant les langages cibles et source // au cas il faudrait le compiler (source posterieure au resultat) $composer = charger_fonction('composer', 'public'); $code = $composer($skel, $mime_type, $gram, $sourcefile, $connect); if (!$code) // squelette inconnu ou faux $page = array(); else { // Preparer l'appel de la fonction principale du squelette list($fonc) = $code; spip_timer($a = 'calcul page '.rand(0,1000)); $notes = calculer_notes(); // conserver les notes... // Rajouter d'office ces deux parametres // (mais vaudrait mieux que le compilateur sache le simuler // car ca interdit l'usage de criteres conditionnels dessus). if (!isset($contexte['date'])) { $contexte['date'] = date("Y-m-d H:i:s"); $contexte['date_default'] = true; } else $contexte['date'] = normaliser_date($contexte['date']); if (!isset($contexte['date_redac'])) { $contexte['date_redac'] = date("Y-m-d H:i:s"); $contexte['date_redac_default'] = true; } else $contexte['date_redac'] = normaliser_date($contexte['date_redac']); // Passer le nom du cache pour produire sa destruction automatique $page = $fonc(array('cache' => $cache), array($contexte)); // ... et les retablir if ($n = calculer_notes()) spip_log("notes ignorees par $fonc: $n"); $GLOBALS['les_notes'] = $notes; // spip_log: un joli contexte $infos = array(); foreach (array_filter($contexte) as $var => $val) { if (is_array($val)) $val = serialize($val); if (strlen("$val") > 30) $val = substr("$val", 0,27).'..'; if (strstr($val,' ')) $val = "'$val'"; $infos[] = $var.'='.$val; } $profile = spip_timer($a); spip_log("calcul ($profile) [$skel] " . join(', ', $infos) .' ('.strlen($page['texte']).' octets)'); if ($debug) { include_spip('public/debug'); debug_dumpfile (strlen($page['texte'])?$page['texte']:" ", $fonc, 'resultat'); $GLOBALS['debug_objets']['courant'] = $courant; $GLOBALS['debug_objets']['profile'][$sourcefile] = $profile; } // Si #CACHE{} n'etait pas la, le mettre a $delais if (!isset($page['entetes']['X-Spip-Cache'])) $page['entetes']['X-Spip-Cache'] = isset($GLOBALS['delais'])?$GLOBALS['delais']:36000; } $page['contexte'] = $contexte; // faire remonter le fichier source if ($GLOBALS['var_inclure']) $page['sourcefile'] = $sourcefile; if ($select) lang_select(); // Si un modele contenait #SESSION, on note l'info dans $page if (isset($GLOBALS['cache_utilise_session'])) { $page['invalideurs']['session'] = $GLOBALS['cache_utilise_session']; unset($GLOBALS['cache_utilise_session']); } return $page; } // Calcul de la rubrique associee a la requete // (selection de squelette specifique par id_rubrique & lang) // http://doc.spip.org/@quete_rubrique_fond function quete_rubrique_fond($contexte) { if (isset($contexte['id_rubrique']) AND $id = intval($contexte['id_rubrique']) AND $row = quete_parent_lang('spip_rubriques',$id)) { $lang = isset($row['lang']) ? $row['lang'] : ''; return array ($id, $lang); } if (isset($contexte['id_breve']) AND $id = intval($contexte['id_breve']) AND $row = quete_parent_lang('spip_breves',$id) AND $id_rubrique_fond = $row['id_rubrique']) { $lang = isset($row['lang']) ? $row['lang'] : ''; return array($id_rubrique_fond, $lang); } if (isset($contexte['id_syndic']) AND $id = intval($contexte['id_syndic']) AND $row = quete_parent_lang('spip_syndic',$id) AND $id_rubrique_fond = $row['id_rubrique'] AND $row = quete_parent_lang('spip_rubriques',$id_rubrique_fond)) { $lang = isset($row['lang']) ? $row['lang'] : ''; return array($id_rubrique_fond, $lang); } if (isset($contexte['id_article']) AND $id = intval($contexte['id_article']) AND $row = quete_parent_lang('spip_articles',$id) AND $id_rubrique_fond = $row['id_rubrique']) { $lang = isset($row['lang']) ? $row['lang'] : ''; return array($id_rubrique_fond, $lang); } } // si le champ chapo commence par '=' c'est une redirection. // avec un eventuel raccourci Spip // si le raccourci a un titre il sera pris comme corps du 302 // http://doc.spip.org/@tester_redirection function tester_redirection($fond, $contexte, $connect) { if ($fond == 'article' AND $id_article = intval($contexte['id_article'])) { $m = quete_chapo($id_article, $connect); if ($m[0]=='=') { include_spip('inc/texte'); // les navigateurs pataugent si l'URL est vide if ($url = chapo_redirige(substr($m,1), true)) return array('texte' => "<" . "?php header('Location: " . texte_script(str_replace('&', '&', $url)) . "'); echo '" . addslashes($m[1]) . "'?" . ">", 'process_ins' => 'php'); } } return false; } ?> spip/spip/ecrire/public/compiler.php0000766000000000000000000007477011236524730020770 0ustar adminadministrators $couple) { // la liste d'arguments d'inclusion peut se terminer par un filtre $filtre = array_shift($couple); if ($filtre) break; foreach($couple as $n => $val) { $var = $val[0]; if ($var->type != 'texte') { if ($n OR $k) erreur_squelette(_T('zbug_parametres_inclus_incorrects'), $id_boucle); else $l[1] = calculer_liste($val, $descr, $boucles, $id_boucle); break; } else { preg_match(",^([^=]*)(=?)(.*)$,", $var->texte,$m); $var = $m[1]; $auto = false;; if ($m[2]) { $v = $m[3]; if (preg_match(',^[\'"](.*)[\'"]$,', $v, $m)) $v = $m[1]; $val[0]->texte = $v; } elseif ($k OR $n) { $auto = true; } else $var = 1; if ($var == 'lang') { $lang = !$auto ? calculer_liste($val, $descr, $boucles, $id_boucle) : '$GLOBALS["spip_lang"]'; } else { $val = $auto ? index_pile($id_boucle, $var, $boucles) : calculer_liste($val, $descr, $boucles, $id_boucle); if ($var !== 1) $val = ($echap?"\'$var\' => ' . argumenter_squelette(":"'$var' => ") . $val . ($echap? ") . '":" "); else $val = $echap ? "'.$val.'" : $val; $l[$var] = $val; } } } } // Cas particulier de la langue : si {lang=xx} est definie, on // la passe, sinon on passe la langue courante au moment du calcul // sauf si on n'en veut pas if ($lang === false) return $l; if (!$lang) $lang = '$GLOBALS["spip_lang"]'; $l['lang'] = ($echap?"\'lang\' => ' . argumenter_squelette(":"'lang' => ") . $lang . ($echap?") . '":" "); return $l; } // // Calculer un // // http://doc.spip.org/@calculer_inclure function calculer_inclure($p, $descr, &$boucles, $id_boucle) { # Si pas raccourci # chercher le fichier, eventuellement en changeant.php3 => .php # et en gardant la compatibilite if ($fichier = $p->texte) { if (preg_match(',^(.*[.]php)3$,', $fichier, $r)) { $fichier = $r[1]; } if ($fichier == 'page.php') { $fichier = ''; } else { $path = find_in_path($fichier); if (!$path) { spip_log("ERREUR: impossible"); erreur_squelette(_T('zbug_info_erreur_squelette'), "<INCLURE($fichier)> - " ._T('fichier_introuvable', array('fichier' => $fichier))); return "''"; } } } $_contexte = argumenter_inclure($p->param, false, $descr, $boucles, $id_boucle); // Critere d'inclusion {env} (et {self} pour compatibilite ascendante) if ($env = (isset($_contexte['env'])|| isset($_contexte['self']))) { unset($_contexte['env']); } // if (isset($_contexte['doublons'])) { // noter les doublons dans l'appel a public.php $_contexte['doublons'] = "\\'doublons\\' => '.var_export(\$doublons,true).'"; } if ($ajax = isset($_contexte['ajax'])) unset($_contexte['ajax']); $contexte = 'array(' . join(",\n\t", $_contexte) .')'; if ($env) { $contexte = "array_merge('.var_export(\$Pile[0],1).',$contexte)"; } $code = "\tinclude " . ($fichier ? "\\'$path\\'" : ('_DIR_RESTREINT . "public.php"')). ";"; // Gerer ajax if ($ajax) { $code = ' echo "
    \\n";' ."\n" .$code ."\n" .' echo "
    \\n";'; } return "\n'<". "?php\n\t".'$contexte_inclus = '.$contexte.";\n" . $code . "\n?'." . "'>'"; } // // calculer_boucle() produit le corps PHP d'une boucle Spip. // ce corps remplit une variable $t0 retournee en valeur. // Ici on distingue boucles recursives et boucle a requete SQL // et on insere le code d'envoi au debusqueur du resultat de la fonction. // http://doc.spip.org/@calculer_boucle function calculer_boucle($id_boucle, &$boucles) { $boucles[$id_boucle] = pipeline('post_boucle', $boucles[$id_boucle]); if ($boucles[$id_boucle]->type_requete == 'boucle') { $corps = calculer_boucle_rec($id_boucle, $boucles); $req = ""; } else { $corps = calculer_boucle_nonrec($id_boucle, $boucles); // attention, ne calculer la requete que maintenant // car la fonction precedente appelle index_pile qui influe dessus $req = (($init = $boucles[$id_boucle]->doublons) ? ("\n\t$init = array();") : '') . calculer_requete_sql($boucles[$id_boucle]); } $notrace = (_request('var_mode_affiche') != 'resultat'); return $req . $corps . ($notrace ? "" : " boucle_debug_resultat('$id_boucle', 'resultat', \$t0);") . "\n return \$t0;"; } // compil d'une boucle recursive. // il suffit (ET IL FAUT) sauvegarder les valeurs des arguments passes par // reference, car par definition un tel passage ne les sauvegarde pas // http://doc.spip.org/@calculer_boucle_rec function calculer_boucle_rec($id_boucle, &$boucles) { $nom = $boucles[$id_boucle]->param[0]; return "\n\t\$save_numrows = (\$Numrows['$nom']);" . "\n\t\$t0 = " . $boucles[$id_boucle]->return . ";" . "\n\t\$Numrows['$nom'] = (\$save_numrows);"; } // compil d'une boucle non recursive. // c'est un "while (fetch_sql)" dans le cas general, // qu'on essaye d'optimiser un max. // http://doc.spip.org/@calculer_boucle_nonrec function calculer_boucle_nonrec($id_boucle, &$boucles) { $boucle = &$boucles[$id_boucle]; $return = $boucle->return; $type_boucle = $boucle->type_requete; $primary = $boucle->primary; $constant = preg_match(CODE_MONOTONE, str_replace("\\'",'', $return)); // Cas {1/3} {1,4} {n-2,1}... $flag_cpt = $boucle->mode_partie ||$boucle->cptrows; // // Creer le debut du corps de la boucle : // $corps = !$flag_cpt ? '' : "\n \$Numrows['$id_boucle']['compteur_boucle']++;"; if ($boucle->mode_partie) $corps .= " if (\$Numrows['$id_boucle']['compteur_boucle'] > \$debut_boucle) { if (\$Numrows['$id_boucle']['compteur_boucle']-1 > \$fin_boucle) break;\n"; // Calculer les invalideurs si c'est une boucle non constante et si on // souhaite invalider ces elements if (!$constant AND $primary) { include_spip('inc/invalideur'); if (function_exists($i = 'calcul_invalideurs')) $corps = $i($corps, $primary, $boucles, $id_boucle); } // faudrait expanser le foreach a la compil, car y en a souvent qu'un // et puis faire un [] plutot qu'un "','." if ($boucle->doublons) $corps .= "\n\t\t\tforeach(" . $boucle->doublons . ' as $k) $doublons[$k] .= "," . ' . index_pile($id_boucle, $primary, $boucles) . "; // doublons\n"; if (count($boucle->separateur)) $code_sep = ("'" . str_replace("'","\'",join('',$boucle->separateur)) . "'"); // La boucle doit-elle selectionner la langue ? // -. par defaut, les boucles suivantes le font // "peut-etre", c'est-a-dire si forcer_lang == false. // - . a moins d'une demande explicite if (!$constant && $boucle->lang_select != 'non' && (($boucle->lang_select == 'oui') || ( $type_boucle == 'articles' OR $type_boucle == 'rubriques' OR $type_boucle == 'hierarchie' OR $type_boucle == 'breves' ))) { // Memoriser la langue avant la boucle et la restituer apres // afin que le corps de boucle affecte la globale directement $init = "\n lang_select(\$GLOBALS['spip_lang']);"; $fin = "\n lang_select();"; $corps .= (($boucle->lang_select != 'oui') ? "\t\tif (!(isset(\$GLOBALS['forcer_lang']) AND \$GLOBALS['forcer_lang']))\n\t " : '') . "\t\tif (\$x = " . index_pile($id_boucle, 'lang', $boucles) . ') $GLOBALS["spip_lang"] = $x;'; } else { $init = ''; $fin = ''; // sortir les appels au traducteur (invariants de boucle) if (strpos($return, '?php') === false AND preg_match_all("/\W(_T[(]'[^']*'[)])/", $return, $r)) { $i = 1; foreach($r[1] as $t) { $init .= "\n\t\$l$i = $t;"; $return = str_replace($t, "\$l$i", $return); $i++; } } } // gestion optimale des separateurs et des boucles constantes $corps .= ((!$boucle->separateur) ? (($constant && !$corps) ? $return : (($return==="''") ? '' : ("\n\t\t" . '$t0 .= ' . $return . ";"))) : ("\n\t\t\$t1 " . ((strpos($return, '$t1.') === 0) ? (".=" . substr($return,4)) : ('= ' . $return)) . ";\n\t\t" . '$t0 .= (($t1 && $t0) ? ' . $code_sep . " : '') . \$t1;")); // Fin de parties if ($boucle->mode_partie) $corps .= "\n }\n"; $sql_args = '$result, ' . _q($boucle->sql_serveur); // si le corps est une constante, ne pas appeler le serveur N fois! if (preg_match(CODE_MONOTONE,str_replace("\\'",'',$corps), $r)) { if (!isset($r[2]) OR (!$r[2])) { if (!$boucle->numrows) return "\n\t\$t0 = '';"; else $corps = ""; } else { $boucle->numrows = true; $corps = "\n ".'for($x=$Numrows["'.$id_boucle.'"]["total"];$x>0;$x--) $t0 .= ' . $corps .';'; } } else { $corps = $init . ' $SP++; // RESULTATS while ($Pile[$SP] = @sql_fetch(' . $sql_args . ")) {\n$corps\n }\n" . $fin ; } $count = ''; if (!$boucle->select) { if (!$boucle->numrows OR $boucle->limit OR $boucle_mode_partie OR $boucle->group) $count = '1'; else $count = 'count(*)'; $boucles[$id_boucle]->select[]= $count; } if ($boucle->numrows OR $boucle->mode_partie) { if ($count == 'count(*)') $count = "array_shift(sql_fetch($sql_args))"; else $count = "sql_count($sql_args)"; $count = !$boucle->mode_partie ? "\n\t\$Numrows['$id_boucle']['total'] = @intval($count);" : calculer_parties($boucles, $id_boucle, $count); } else $count = ''; return $count . (!$flag_cpt ? "" : "\n\t\$Numrows['$id_boucle']['compteur_boucle'] = 0;") . ' $t0 = "";' . $corps . "\n\t@sql_free($sql_args);"; } // http://doc.spip.org/@calculer_requete_sql function calculer_requete_sql(&$boucle) { if (!$boucle->select) return ""; // l'optimiseur a fait fort return ($boucle->hierarchie ? "\n\t$boucle->hierarchie" : '') . $boucle->in . $boucle->hash . calculer_dec('$table', "'" . $boucle->id_table ."'") . calculer_dec('$id', "'" . $boucle->id_boucle ."'") # En absence de champ c'est un decompte : . calculer_dec('$from', calculer_from($boucle)) . calculer_dec('$type', calculer_from_type($boucle)) . calculer_dec('$groupby', 'array(' . (($g=join("\",\n\t\t\"",$boucle->group))?'"'.$g.'"':'') . ")") . calculer_dec('$select', 'array("' . join("\",\n\t\t\"", $boucle->select). "\")") . calculer_dec('$orderby', 'array(' . calculer_order($boucle) . ")") . calculer_dec('$where', calculer_dump_array($boucle->where)) . calculer_dec('$join', calculer_dump_join($boucle->join)) . calculer_dec('$limit', (strpos($boucle->limit, 'intval') === false ? "'".$boucle->limit."'" : $boucle->limit)) . calculer_dec('$having', calculer_dump_array($boucle->having)) . "\n\t// REQUETE\n\t" . '$result = calculer_select($select, $from, $type, $where, $join, $groupby, $orderby, $limit, $having, $table, $id, $connect);'; } // http://doc.spip.org/@calculer_dec function calculer_dec($nom, $val) { $static = "static "; if ( strpos($val, '$') !== false OR strpos($val, 'sql_') !== false OR ( $test = str_replace(array("array(",'\"',"\'"),array("","",""),$val) // supprimer les array( et les echappements de guillemets AND strpos($test,"(")!==FALSE // si pas de parenthese ouvrante, pas de fonction, on peut sortir AND $test = preg_replace(",'[^']*',UimsS","",$test) // supprimer les chaines qui peuvent contenir des fonctions SQL qui ne genent pas AND preg_match(",\w+\s*\(,UimsS",$test,$regs) // tester la presence de fonctions restantes ) ){ $static = ""; } return "\n\t" . $static . $nom . ' = ' . $val . ';'; } // http://doc.spip.org/@calculer_dump_array function calculer_dump_array($a) { if (!is_array($a)) return $a ; $res = ""; if ($a AND $a[0] == "'?'") return ("(" . calculer_dump_array($a[1]) . " ? " . calculer_dump_array($a[2]) . " : " . calculer_dump_array($a[3]) . ")"); else { foreach($a as $v) $res .= ", " . calculer_dump_array($v); return "\n\t\t\tarray(" . substr($res,2) . ')'; } } // http://doc.spip.org/@calculer_dump_join function calculer_dump_join($a) { $res = ""; foreach($a as $k => $v) $res .= ", '$k' => array(".implode(',',$v).")"; return 'array(' . substr($res,2) . ')'; } // http://doc.spip.org/@calculer_from function calculer_from(&$boucle) { $res = ""; foreach($boucle->from as $k => $v) $res .= ",'$k' => '$v'"; return 'array(' . substr($res,1) . ')'; } // http://doc.spip.org/@calculer_from_type function calculer_from_type(&$boucle) { $res = ""; foreach($boucle->from_type as $k => $v) $res .= ",'$k' => '$v'"; return 'array(' . substr($res,1) . ')'; } // http://doc.spip.org/@calculer_order function calculer_order(&$boucle) { if (!$order = $boucle->order AND !$order = $boucle->default_order) $order = array(); /*if (isset($boucle->modificateur['collate'])){ $col = "." . $boucle->modificateur['collate']; foreach($order as $k=>$o) if (strpos($order[$k],'COLLATE')===false) $order[$k].= $col; }*/ return join(', ', $order); } // // Code specifique aux criteres {1,n} {n/m} etc // // http://doc.spip.org/@calculer_parties function calculer_parties($boucles, $id_boucle, $count) { $boucle = &$boucles[$id_boucle]; $partie = $boucle->partie; $mode_partie = $boucle->mode_partie; $total_parties = $boucle->total_parties; // Notes : // $debut_boucle et $fin_boucle sont les indices SQL du premier // et du dernier demandes dans la boucle : 0 pour le premier, // n-1 pour le dernier ; donc total_boucle = 1 + debut - fin // nombre total avant partition $retour = "\n\n // PARTITION\n\t" . '$nombre_boucle = @' . $count .';'; preg_match(",([+-/p])([+-/])?,", $mode_partie, $regs); list(,$op1,$op2) = $regs; // {1/3} if ($op1 == '/') { $pmoins1 = is_numeric($partie) ? ($partie-1) : "($partie-1)"; $totpos = is_numeric($total_parties) ? ($total_parties) : "($total_parties ? $total_parties : 1)"; $retour .= "\n " .'$debut_boucle = ceil(($nombre_boucle * ' . $pmoins1 . ')/' . $totpos . ");"; $fin = 'ceil (($nombre_boucle * ' . $partie . ')/' . $totpos . ") - 1"; } // {1,x} elseif ($op1 == '+') { $retour .= "\n " . '$debut_boucle = ' . $partie . ';'; } // {n-1,x} elseif ($op1 == '-') { $retour .= "\n " . '$debut_boucle = $nombre_boucle - ' . $partie . ';'; } // {pagination} elseif ($op1 == 'p') { $retour .= "\n " . '$debut_boucle = ' . $partie . ';'; } // {x,1} if ($op2 == '+') { $fin = '$debut_boucle' . (is_numeric($total_parties) ? (($total_parties==1) ? "" :(' + ' . ($total_parties-1))): ('+' . $total_parties . ' - 1')); } // {x,n-1} elseif ($op2 == '-') { $fin = '$debut_boucle + $nombre_boucle - ' . (is_numeric($total_parties) ? ($total_parties+1) : ($total_parties . ' - 1')); } // Rabattre $fin_boucle sur le maximum $retour .= "\n " .'$fin_boucle = min(' . $fin . ', $nombre_boucle - 1);'; // calcul du total boucle final $retour .= "\n " .'$Numrows[\''.$id_boucle.'\']["grand_total"] = $nombre_boucle;' . "\n " .'$Numrows[\''.$id_boucle.'\']["total"] = max(0,$fin_boucle - $debut_boucle + 1);'; return $retour; } // Production du code PHP a partir de la sequence livree par le phraseur // $boucles est passe par reference pour affectation par index_pile. // Retourne une expression PHP, // (qui sera argument d'un Return ou la partie droite d'une affectation). // http://doc.spip.org/@calculer_liste function calculer_liste($tableau, $descr, &$boucles, $id_boucle='') { if (!$tableau) return "''"; if (!isset($descr['niv'])) $descr['niv'] = 0; $codes = compile_cas($tableau, $descr, $boucles, $id_boucle); $n = count($codes); if (!$n) return "''"; $tab = str_repeat("\t", $descr['niv']); if (_request('var_mode_affiche') != 'validation') { if ($n==1) return $codes[0]; else { $res = ''; foreach($codes as $code) { if (!preg_match("/^'[^']*'$/", $code) OR substr($res,-1,1)!=="'") $res .= " .\n$tab$code"; else { $res = substr($res,0,-1) . substr($code,1); } } return '(' . substr($res,2+$descr['niv']) . ')'; } } else return "@debug_sequence('$id_boucle', '" . ($descr['nom']) . "', " . $descr['niv'] . ", array(" . join(" ,\n$tab", $codes) . "))"; } define('_REGEXP_COND_VIDE_NONVIDE',"/^[(](.*)[?]\s*''\s*:\s*('[^']+')\s*[)]$/"); define('_REGEXP_COND_NONVIDE_VIDE',"/^[(](.*)[?]\s*('[^']+')\s*:\s*''\s*[)]$/"); define('_REGEXP_CONCAT_NON_VIDE', "/^(.*)[.]\s*'[^']+'\s*$/"); // http://doc.spip.org/@compile_cas function compile_cas($tableau, $descr, &$boucles, $id_boucle) { $codes = array(); // cas de la boucle recursive if (is_array($id_boucle)) $id_boucle = $id_boucle[0]; $type = !$id_boucle ? '' : $boucles[$id_boucle]->type_requete; $tab = str_repeat("\t", ++$descr['niv']); $mode = _request('var_mode_affiche'); // chaque commentaire introduit dans le code doit commencer // par un caractere distinguant le cas, pour exploitation par debug. foreach ($tableau as $p) { switch($p->type) { // texte seul case 'texte': $code = "'".str_replace(array("\\","'"),array("\\\\","\\'"), $p->texte)."'"; $commentaire= strlen($p->texte) . " signes"; $avant=''; $apres=''; $altern = "''"; break; case 'polyglotte': $code = ""; foreach($p->traductions as $k => $v) { $code .= ",'" . str_replace(array("\\","'"),array("\\\\","\\'"), $k) . "' => '" . str_replace(array("\\","'"),array("\\\\","\\'"), $v) . "'"; } $code = "multi_trad(array(" . substr($code,1) . "))"; $commentaire= '&'; $avant=''; $apres=''; $altern = "''"; break; // inclure case 'include': $code = calculer_inclure($p, $descr, $boucles, $id_boucle); $commentaire = ''; $avant=''; $apres=''; $altern = "''"; break; // boucle case 'boucle': $nom = $p->id_boucle; $newdescr = $descr; $newdescr['id_mere'] = $nom; $newdescr['niv']++; $code = 'BOUCLE' . str_replace("-","_", $nom) . $descr['nom'] . '($Cache, $Pile, $doublons, $Numrows, $SP)'; $commentaire= "?$nom"; $avant = calculer_liste($p->avant, $newdescr, $boucles, $id_boucle); $apres = calculer_liste($p->apres, $newdescr, $boucles, $id_boucle); $newdescr['niv']--; $altern = calculer_liste($p->altern, $newdescr, $boucles, $id_boucle); if (!$boucles[$nom]->milieu AND $boucles[$nom]->type_requete <> 'boucle') { if ($altern != "''") $code .= "\n. $altern"; if ($avant<>"''" OR $apres<>"''") spip_log("boucle $nom toujours vide, code superflu dans $id"); $avant = $apres = $altern = "''"; } else if ($altern != "''") $altern = "($altern)"; break; case 'idiome': $args=array(); foreach ($p->arg as $k => $v) { if ($k) $args[]=$k.' => '.calculer_liste($v,$p->descr,$boucles,$id_boucle); } $code = "_T('" . $p->module . ":" .$p->nom_champ . "',array(".implode(', ',$args)."))"; if ($p->param) { $p->id_boucle = $id_boucle; $p->boucles = &$boucles; $code = compose_filtres($p, $code); } $commentaire = ":"; $avant=''; $apres=''; $altern = "''"; break; case 'champ': // cette structure pourrait etre completee des le phrase' (a faire) $p->id_boucle = $id_boucle; $p->boucles = &$boucles; $p->descr = $descr; #$p->interdire_scripts = true; $p->type_requete = $type; $code = calculer_champ($p); $commentaire = '#' . $p->nom_champ . $p->etoile; $avant = calculer_liste($p->avant, $descr, $boucles, $id_boucle); $apres = calculer_liste($p->apres, $descr, $boucles, $id_boucle); $altern = "''"; // Si la valeur est destinee a une comparaison a '' // forcer la conversion en une chaine par strval // si ca peut etre autre chose qu'une chaine if (($avant != "''" OR $apres != "''") AND $code[0]!= "'" # AND (strpos($code,'interdire_scripts') !== 0) AND !preg_match(_REGEXP_COND_VIDE_NONVIDE, $code) AND !preg_match(_REGEXP_COND_NONVIDE_VIDE, $code) AND !preg_match(_REGEXP_CONCAT_NON_VIDE, $code)) { $code = "strval($code)"; } break; default: erreur_squelette(_T('zbug_info_erreur_squelette')); } // switch if ($code != "''") { $code = compile_retour($code, $avant, $apres, $altern, $tab, $descr['niv']); $codes[]= (($mode == 'validation') ? "array(" . $p->ligne . ", '$commentaire', $code)" : (($mode == 'code') ? "\n// $commentaire\n$code" : $code)); } } // foreach return $codes; } // production d'une expression conditionnelle ((v=EXP) ? (p . v .s) : a) // mais si EXP est de la forme (t ? 'C' : '') on produit (t ? (p . C . s) : a) // de meme si EXP est de la forme (t ? '' : 'C') // http://doc.spip.org/@compile_retour function compile_retour($code, $avant, $apres, $altern, $tab, $n) { if ($avant == "''") $avant = ''; if ($apres == "''") $apres = ''; if (!$avant AND !$apres AND ($altern==="''")) return $code; if (preg_match(_REGEXP_CONCAT_NON_VIDE, $code)) { $t = $code; $cond = ''; } elseif (preg_match(_REGEXP_COND_VIDE_NONVIDE,$code, $r)) { $t = $r[2]; $cond = '!' . $r[1]; } else if (preg_match(_REGEXP_COND_NONVIDE_VIDE,$code, $r)) { $t = $r[2]; $cond = $r[1]; } else { $t = '$t' . $n; $cond = "($t = $code)!==''"; } $res = (!$avant ? "" : "$avant . ") . $t . (!$apres ? "" : " . $apres"); if ($res !== $t) $res = "($res)"; return !$cond ? $res : "($cond ?\n\t$tab$res :\n\t$tab$altern)"; } // affichage du code produit // http://doc.spip.org/@code_boucle function code_boucle(&$boucles, $id, $nom) { $boucle = &$boucles[$id]; // Indiquer la boucle en commentaire $pretty = ''; if ($boucle->type_requete != 'boucle') { // Resynthetiser les criteres foreach ($boucle->param as $param) { $s = ""; $sep = ""; foreach ($param as $t) { if (is_array($t)) { // toujours vrai normalement $s .= $sep; $c = $t[0]; if ($c->apres) $s .= ($c->apres . $c->texte . $c->apres); else { // faudrait decompiler aussi les balises... foreach ($t as $c) $s .= ($c->type == 'texte') ? $c->texte : '#...'; } $sep = ", "; } } $pretty .= ' {' . $s . '}'; } } $pretty = "BOUCLE$id(".strtoupper($boucle->type_requete) . ")" . strtr($pretty,"\r\n", " "); return $pretty; } // Prend en argument le texte d'un squelette (et son fichier d'origine) // sa grammaire et un nom. // Retourne une fonction PHP/SQL portant ce nom et calculant une page. // Pour appeler la fonction produite, lui fournir 2 tableaux de 1 e'le'ment: // - 1er: element 'cache' => nom (du fichier ou` mettre la page) // - 2e: element 0 contenant un environnement ('id_article => $id_article, etc) // Elle retourne alors un tableau de 5 e'le'ments: // - 'texte' => page HTML, application du squelette a` l'environnement; // - 'squelette' => le nom du squelette // - 'process_ins' => 'html' ou 'php' selon la pre'sence de PHP dynamique // - 'invalideurs' => de'pendances de cette page, pour invalider son cache. // - 'entetes' => tableau des entetes http // En cas d'erreur, elle retourne un tableau des 2 premiers elements seulement // http://doc.spip.org/@public_compiler_dist function public_compiler_dist($squelette, $nom, $gram, $sourcefile, $connect=''){ global $tables_jointures; static $trouver_table; if (!$trouver_table) $trouver_table = charger_fonction('trouver_table', 'base'); // Pre-traitement : reperer le charset du squelette, et le convertir // Bonus : supprime le BOM include_spip('inc/charsets'); $descr = array('nom' => $nom, 'sourcefile' => $sourcefile, 'squelette' => transcoder_page($squelette)); // Phraser le squelette, selon sa grammaire // pour le moment: "html" seul connu (HTML+balises BOUCLE) $boucles = array(); spip_timer('calcul_skel'); $f = charger_fonction('phraser_'.$gram, 'public'); $racine = $f($descr['squelette'], '', $boucles, $nom); // Demander la description des tables une fois pour toutes foreach($boucles as $id => $boucle) { $type = $boucle->type_requete; if ($type != 'boucle') { if (!$boucles[$id]->sql_serveur AND $connect) $boucles[$id]->sql_serveur = $connect; $show = $trouver_table($type, $boucles[$id]->sql_serveur); // si la table n'existe pas avec le connecteur par defaut, // c'est peut etre une table qui necessite son connecteur dedie fourni // permet une ecriture allegee (GEO) -> (geo:GEO) if (!$show AND $show=$trouver_table($type, $type)) $boucles[$id]->sql_serveur = $type; if ($show) { $boucles[$id]->show = $show; // recopie les infos les plus importantes $boucles[$id]->primary = $show['key']["PRIMARY KEY"]; $boucles[$id]->id_table = $x = $show['id_table']; $boucles[$id]->from[$x] = $nom_table = $show['table']; $boucles[$id]->descr = &$descr; if ((!$boucles[$id]->jointures) AND (is_array($x = $tables_jointures[$nom_table]))) $boucles[$id]->jointures = $x; } else { $boucles[$id]->type_requete = ''; $x = $boucles[$id]->sql_serveur; $x = $x ? "$x:$type" : $type; // ne pas renvoyer d'erreur si la table est optionnelle // declare par ? avant ) dans if (!$boucles[$id]->table_optionnelle) { erreur_squelette(_T('zbug_table_inconnue', array('table' => $x )), $id); } } } } // Commencer par reperer les boucles appelees explicitement // car elles indexent les arguments de maniere derogatoire foreach($boucles as $id => $boucle) { if ($boucle->type_requete == 'boucle') { $boucles[$id]->descr = &$descr; $rec = &$boucles[$boucle->param[0]]; if (!$rec) { return array(_T('zbug_info_erreur_squelette'), ($boucle->param[0] . ' '. _T('zbug_boucle_recursive_undef'))); } else { $rec->externe = $id; $descr['id_mere'] = $id; $boucles[$id]->return = calculer_liste(array($rec), $descr, $boucles, $boucle->param); } } } foreach($boucles as $id => $boucle) { $id = strval($id); // attention au type dans index_pile $type = $boucle->type_requete; if ($type AND $type != 'boucle') { if ($boucle->param) { $res = calculer_criteres($id, $boucles); if (is_array($res)) return $res; # erreur } $descr['id_mere'] = $id; $boucles[$id]->return = calculer_liste($boucle->milieu, $descr, $boucles, $id); } } // idem pour la racine $descr['id_mere'] = ''; $corps = calculer_liste($racine, $descr, $boucles); // Calcul du corps de toutes les fonctions PHP, // en particulier les requetes SQL et TOTAL_BOUCLE // de'terminables seulement maintenant foreach($boucles as $id => $boucle) { $boucle = $boucles[$id] = pipeline('pre_boucle', $boucle); // appeler la fonction de definition de la boucle $req = $boucle->type_requete; if ($req) { $f = 'boucle_'.strtoupper($req); // si pas de definition perso, definition spip if (!function_exists($f)) $f = $f.'_dist'; // laquelle a une definition par defaut if (!function_exists($f)) $f = 'boucle_DEFAUT'; if (!function_exists($f)) $f = 'boucle_DEFAUT_dist'; $req = $f($id, $boucles); } else $req = "\n\treturn '';"; $boucles[$id]->return = "function BOUCLE" . strtr($id,"-","_") . $nom . '(&$Cache, &$Pile, &$doublons, &$Numrows, $SP) {' . "\n\n\tstatic \$connect = " . _q($boucles[$id]->sql_serveur) . ";" . $req . "\n}\n\n"; if (isset($GLOBALS['var_mode']) AND $GLOBALS['var_mode'] == 'debug') boucle_debug_compile ($id, $nom, $boucles[$id]->return); } $code = ""; foreach($boucles as $id => $boucle) { $code .= "\n//\n// type_requete . ">\n//\n" . $boucle->return; } $secondes = spip_timer('calcul_skel'); spip_log("COMPIL ($secondes) [" .preg_replace(',\.html$,', '', $sourcefile) ."] $nom.php"); $code = "<"."?php /* * Squelette : $sourcefile * Date : ".gmdate("D, d M Y H:i:s", @filemtime($sourcefile))." GMT * Compile : ".gmdate("D, d M Y H:i:s", time())." GMT ($secondes) * " . (!$boucles ? "Pas de boucle" : ("Boucles : " . join (', ', array_keys($boucles)))) ." */ " . $code . ' // // Fonction principale du squelette ' . $sourcefile . ($connect ? " pour $connect" : '') . ". // function " . $nom . '($Cache, $Pile, $doublons=array(), $Numrows=array(), $SP=0) { ' // reporter de maniere securisee les doublons inclus .' if (isset($Pile[0]["doublons"]) AND is_array($Pile[0]["doublons"])) $doublons = nettoyer_env_doublons($Pile[0]["doublons"]); $connect = ' . _q($connect) . '; $page = ' . // ATTENTION, le calcul de l'expression $corps affectera $Cache // c'est pourquoi on l'affecte a la variable auxiliaire $page. // avant de referencer $Cache $corps . "; return analyse_resultat_skel(".var_export($nom,true) .", \$Cache, \$page, ".var_export($sourcefile,true)."); } ?".">"; if (isset($GLOBALS['var_mode']) AND $GLOBALS['var_mode'] == 'debug') squelette_debug_compile($nom, $sourcefile, $code, $descr['squelette']); return $code; } ?> spip/spip/ecrire/public/assembler.php0000766000000000000000000005122311236524730021117 0ustar adminadministrators $res);} if (!$chemin_cache || !$lastmodified) $lastmodified = time(); $headers_only = ($_SERVER['REQUEST_METHOD'] == 'HEAD'); // Pour les pages non-dynamiques (indiquees par #CACHE{duree,cache-client}) // une perennite valide a meme reponse qu'une requete HEAD (par defaut les // pages sont dynamiques) if (isset($_SERVER['HTTP_IF_MODIFIED_SINCE']) AND !$GLOBALS['var_mode'] AND $chemin_cache AND isset($page['entetes']) AND isset($page['entetes']['Cache-Control']) AND strstr($page['entetes']['Cache-Control'],'max-age=') AND !strstr($_SERVER['SERVER_SOFTWARE'],'IIS/') ) { $since = preg_replace('/;.*/', '', $_SERVER['HTTP_IF_MODIFIED_SINCE']); $since = str_replace('GMT', '', $since); if (trim($since) == gmdate("D, d M Y H:i:s", $lastmodified)) { $page['status'] = 304; $headers_only = true; } } // Si requete HEAD ou Last-modified compatible, ignorer le texte // et pas de content-type (pour contrer le bouton admin de inc-public) if ($headers_only) { $page['entetes']["Connection"] = "close"; $page['texte'] = ""; } else { // si la page est prise dans le cache if (!$use_cache) { // Informer les boutons d'admin du contexte // (fourni par $renommer ci-dessous lors de la mise en cache) $contexte = $page['contexte']; } // ATTENTION, gestion des URLs transformee par le htaccess // $renommer = 'urls_propres_dist'; // renvoie array($contexte, $fond, $url_redirect) // Compat ascendante si le retour est null: // 1. $contexte est global car cette fonction le modifie. // 2. $fond est passe par reference, pour la meme raison // et calculer la page else { $renommer = generer_url_entite(); if ($renommer) { $url = nettoyer_uri(); $a = $renommer($url, $fond); if (is_array($a)) { list($ncontexte, $type, $url_redirect, $nfond) = $a; if (strlen($url_redirect) AND $url !== $url_redirect) { spip_log("Redirige $url vers $url_redirect"); include_spip('inc/headers'); http_status(301); redirige_par_entete($url_redirect); } if (isset($nfond)) $fond = $nfond; else if ($fond == '' OR $fond == 'type_urls' /* compat avec htaccess 2.0.0 */ ) $fond = ($type === 'syndic') ? 'site' : $type; if (isset($ncontexte)) $contexte = $ncontexte; } } // compatibilite <= 1.9.2 elseif (function_exists('recuperer_parametres_url')) recuperer_parametres_url($fond, nettoyer_uri()); // squelette par defaut if (!strlen($fond)) $fond = 'sommaire'; // preparer le contexte $parametrer = charger_fonction('parametrer', 'public'); $page = $parametrer($fond, $GLOBALS['contexte'], $chemin_cache, $connect); // Stocker le cache sur le disque if ($chemin_cache) $cacher(NULL, $use_cache, $chemin_cache, $page, $lastmodified); } if ($chemin_cache) $page['cache'] = $chemin_cache; auto_content_type($page); $flag_preserver |= headers_sent(); // Definir les entetes si ce n'est fait if (!$flag_preserver) { if ($GLOBALS['flag_ob']) { // Si la page est vide, produire l'erreur 404 ou message d'erreur pour les inclusions if (trim($page['texte']) === '' AND $GLOBALS['var_mode'] != 'debug' AND !isset($page['entetes']['Location']) // cette page realise une redirection, donc pas d'erreur ) { $page = message_erreur_404(); } // pas de cache client en mode 'observation' if ($GLOBALS['var_mode']) { $page['entetes']["Cache-Control"]= "no-cache,must-revalidate"; $page['entetes']["Pragma"] = "no-cache"; } } } } // Entete Last-Modified: // eviter d'etre incoherent en envoyant un lastmodified identique // a celui qu'on a refuse d'honorer plus haut (cf. #655) if ($lastmodified AND !isset($_SERVER['HTTP_IF_MODIFIED_SINCE']) AND !isset($page['entetes']["Last-Modified"])) $page['entetes']["Last-Modified"]=gmdate("D, d M Y H:i:s", $lastmodified)." GMT"; return $page; } // // Contexte : lors du calcul d'une page spip etablit le contexte a partir // des variables $_GET et $_POST, purgees des fausses variables var_* // Note : pour hacker le contexte depuis le fichier d'appel (page.php), // il est recommande de modifier $_GET['toto'] (meme si la page est // appelee avec la methode POST). // // http://doc.spip.org/@calculer_contexte function calculer_contexte() { $contexte = array(); foreach($_GET as $var => $val) { if (!preg_match(_CONTEXTE_IGNORE_VARIABLES,$var)) $contexte[$var] = $val; } foreach($_POST as $var => $val) { if (!preg_match(_CONTEXTE_IGNORE_VARIABLES,$var)) $contexte[$var] = $val; } return $contexte; } // // 2 fonctions pour compatibilite arriere. Sont probablement superflues // // http://doc.spip.org/@auto_content_type function auto_content_type($page) { global $flag_preserver; if (!isset($flag_preserver)) { $flag_preserver = preg_match("/header\s*\(\s*.content\-type:/isx",$page['texte']) || (isset($page['entetes']['Content-Type'])); } } // http://doc.spip.org/@inclure_page function inclure_page($fond, $contexte, $connect='') { global $lastmodified; // enlever le fond de contexte inclus car sinon il prend la main // dans les sous inclusions -> boucle infinie d'inclusion identique unset($contexte['fond']); // mais le donner pour le calcul du cache $page = $fond; $cacher = charger_fonction('cacher', 'public'); // Les quatre derniers parametres sont modifes par la fonction: // emplacement, validite, et, s'il est valide, contenu & age $res = $cacher($contexte, $use_cache, $chemin_cache, $page, $lastinclude); if ($res) {return array('texte' => $res);} // Si use_cache vaut 0, la page a ete tiree du cache et se trouve dans $page if (!$use_cache) { $lastmodified = max($lastmodified, $lastinclude); } else { $parametrer = charger_fonction('parametrer', 'public'); $page = $parametrer($fond, $contexte, $chemin_cache, $connect); $lastmodified = time(); // et on l'enregistre sur le disque if ($chemin_cache AND $page['entetes']['X-Spip-Cache'] > 0) $cacher($contexte, $use_cache, $chemin_cache, $page, $lastmodified); } return $page; } # Attention, un appel explicite a cette fonction suppose certains include # $echo = faut-il faire echo ou return // http://doc.spip.org/@inclure_balise_dynamique function inclure_balise_dynamique($texte, $echo=true, $ligne=0) { global $contexte_inclus; # provisoire : c'est pour le debuggueur if (is_array($texte)) { list($fond, $delainc, $contexte_inclus) = $texte; // delais a l'ancienne, c'est pratiquement mort $d = isset($GLOBALS['delais']) ? $GLOBALS['delais'] : NULL; $GLOBALS['delais'] = $delainc; // les balises dynamiques passent toujours leur $fond // si un 'fond' est present dans le contexte il vient d'autre part (de la bdd par exemple:p) // et c'est le crash assure $contexte_inclus['fond'] = $fond; $page = recuperer_fond($fond,$contexte_inclus,array('trim'=>false, 'raw' => true)); $texte = $page['texte']; // attention $contexte_inclus a pu changer pendant l'eval ci dessus $GLOBALS['delais'] = $d; // Faire remonter les entetes if (is_array($page['entetes'])) { // mais pas toutes unset($page['entetes']['X-Spip-Cache']); unset($page['entetes']['Content-Type']); if (isset($GLOBALS['page']) AND is_array($GLOBALS['page'])) { if (!is_array($GLOBALS['page']['entetes'])) $GLOBALS['page']['entetes'] = array(); $GLOBALS['page']['entetes'] = array_merge($GLOBALS['page']['entetes'],$page['entetes']); } } // on se refere a $page['contexte'] a la place if (isset($page['contexte']['_pipeline'])) { $pipe = is_array($page['contexte']['_pipeline'])?reset($page['contexte']['_pipeline']):$page['contexte']['_pipeline']; $args = is_array($page['contexte']['_pipeline'])?end($page['contexte']['_pipeline']):array(); $args['contexte'] = $page['contexte']; unset($args['contexte']['_pipeline']); // par precaution, meme si le risque de boucle infinie est a priori nul if (isset($GLOBALS['spip_pipeline'][$pipe])) $texte = pipeline($pipe,array( 'data'=>$texte, 'args'=>$args)); } } if ($GLOBALS['var_mode'] == 'debug') $GLOBALS['debug_objets']['resultat'][$ligne] = $texte; if ($echo) echo $texte; else return $texte; } // Traiter var_recherche ou le referrer pour surligner les mots // http://doc.spip.org/@f_surligne function f_surligne ($texte) { if ($GLOBALS['html'] AND (isset($_SERVER['HTTP_REFERER']) OR isset($_GET['var_recherche']))) { include_spip('inc/surligne'); $texte = surligner_mots($texte); } return $texte; } // Valider/indenter a la demande. // http://doc.spip.org/@f_tidy function f_tidy ($texte) { global $xhtml; if ($xhtml # tidy demande AND $GLOBALS['html'] # verifie que la page avait l'entete text/html AND strlen($texte) AND !headers_sent()) { # Compatibilite ascendante if (!is_string($xhtml)) $xhtml ='tidy'; if (!$f = charger_fonction($xhtml, 'inc', true)) { spip_log("tidy absent, l'indenteur SPIP le remplace"); $f = charger_fonction('sax', 'xml'); } return $f($texte); } return $texte; } // Offre #INSERT_HEAD sur tous les squelettes (bourrin) // a activer dans mes_options via : // $spip_pipeline['affichage_final'] .= '|f_insert_head'; // http://doc.spip.org/@f_insert_head function f_insert_head($texte) { if (!$GLOBALS['html']) return $texte; include_spip('public/admin'); // pour strripos ($pos = stripos($texte, '')) || ($pos = stripos($texte, '')) || ($pos = 0); if (false === strpos(substr($texte, 0,$pos), '')) { $insert = "\n".pipeline('insert_head','')."\n"; $texte = substr_replace($texte, $insert, $pos, 0); } return $texte; } // Inserer au besoin les boutons admins // http://doc.spip.org/@f_admin function f_admin ($texte) { if ($GLOBALS['affiche_boutons_admin']) { include_spip('public/admin'); $texte = affiche_boutons_admin($texte); } if (_request('var_mode')=='noajax'){ $texte = preg_replace(',(class=[\'"][^\'"]*)ajax([^\'"]*[\'"]),Uims',"\\1\\2",$texte); } return $texte; } // Ajoute ce qu'il faut pour les clients MSIE et leurs debilites notoires // * gestion du PNG transparent // * images background (TODO) // Cf. aussi inc/presentation, fonction fin_page(); // http://doc.spip.org/@f_msie function f_msie ($texte) { if (!$GLOBALS['html']) return $texte; if ($GLOBALS['flag_preserver']) return $texte; // test si MSIE et sinon quitte if ( strpos(strtolower($_SERVER['HTTP_USER_AGENT']), 'msie') AND preg_match('/MSIE /i', $_SERVER['HTTP_USER_AGENT']) AND $msiefix = charger_fonction('msiefix', 'inc') ) return $msiefix($texte); else return $texte; } // http://doc.spip.org/@message_erreur_404 function message_erreur_404 ($erreur= "") { static $deja = false; if ($deja) return "erreur"; $deja = true; if (!$erreur) { if (isset($GLOBALS['id_article'])) $erreur = 'public:aucun_article'; else if (isset($GLOBALS['id_rubrique'])) $erreur = 'public:aucune_rubrique'; else if (isset($GLOBALS['id_breve'])) $erreur = 'public:aucune_breve'; else if (isset($GLOBALS['id_auteur'])) $erreur = 'public:aucun_auteur'; else if (isset($GLOBALS['id_syndic'])) $erreur = 'public:aucun_site'; } $contexte_inclus = array( 'erreur' => _T($erreur), 'lang' => $GLOBALS['spip_lang'] ); $page = inclure_page('404', $contexte_inclus); $page['status'] = 404; return $page; } // temporairement ici : a mettre dans le futur inc/modeles // creer_contexte_de_modele('left', 'autostart=true', ...) renvoie un array() // http://doc.spip.org/@creer_contexte_de_modele function creer_contexte_de_modele($args) { $contexte = array(); $params = array(); foreach ($args as $var=>$val) { if (is_int($var)){ // argument pas formate if (in_array($val, array('left', 'right', 'center'))) { $var = 'align'; $contexte[$var] = $val; } else { $args = explode('=', $val); if (count($args)>=2) // Flashvars=arg1=machin&arg2=truc genere plus de deux args $contexte[trim($args[0])] = substr($val,strlen($args[0])+1); else // notation abregee $contexte[trim($val)] = trim($val); } } else $contexte[$var] = $val; } return $contexte; } // Calcule le modele et retourne la mini-page ainsi calculee // http://doc.spip.org/@inclure_modele function inclure_modele($type, $id, $params, $lien, $connect='') { static $compteur; if (++$compteur>10) return ''; # ne pas boucler indefiniment $type = strtolower($type); $fond = $class = ''; $params = array_filter(explode('|', $params)); if ($params) { list(,$soustype) = each($params); $soustype = strtolower($soustype); if (in_array($soustype, array('left', 'right', 'center', 'ajax'))) { list(,$soustype) = each($params); $soustype = strtolower($soustype); } if (preg_match(',^[a-z0-9_]+$,', $soustype)) { $fond = $type.'_'.$soustype; if (!find_in_path('modeles/'. $fond.'.html')) { $fond = ''; $class = $soustype; } // enlever le sous type des params $params = array_diff($params,array($soustype)); } } // Si ca marche pas en precisant le sous-type, prendre le type if (!$fond AND !find_in_path('modeles/'. ($fond = $type).'.html')) return false; // Creer le contexte $contexte = array( 'lang' => $GLOBALS['spip_lang'], 'fond' => 'modeles/'.$fond, 'dir_racine' => _DIR_RACINE # eviter de mixer un cache racine et un cache ecrire (meme si pour l'instant les modeles ne sont pas caches, le resultat etant different il faut que le contexte en tienne compte ); // Le numero du modele est mis dans l'environnement // d'une part sous l'identifiant "id" // et d'autre part sous l'identifiant de la cle primaire supposee // par la fonction table_objet, // qui ne marche vraiment que pour les tables std de SPIP // ( =>> site =>> id_syndic =>> id_syndic=1) $_id = 'id_' . table_objet($type); if (preg_match('/s$/',$_id)) $_id = substr($_id,0,-1); $contexte['id'] = $contexte[$_id] = $id; if (isset($class)) $contexte['class'] = $class; // Si un lien a ete passe en parametre, ex: [->url] if ($lien) { # un eventuel guillemet (") sera reechappe par #ENV $contexte['lien'] = str_replace(""",'"', $lien[0]); $contexte['lien_class'] = $lien[1]; } // Traiter les parametres // par exemple : , ou $arg_list = creer_contexte_de_modele($params); $contexte['args'] = $arg_list; // on passe la liste des arguments du modeles dans une variable args $contexte = array_merge($contexte,$arg_list); // On cree un marqueur de notes unique lie a ce modele // et on enregistre l'etat courant des globales de notes... $enregistre_marqueur_notes = $GLOBALS['marqueur_notes']; $enregistre_les_notes = $GLOBALS['les_notes']; $enregistre_compt_note = $GLOBALS['compt_note']; $GLOBALS['marqueur_notes'] = substr(md5(serialize($contexte)),0,8); $GLOBALS['les_notes'] = ''; $GLOBALS['compt_note'] = 0; // Appliquer le modele avec le contexte $retour = recuperer_fond($fond, $contexte); // On restitue les globales de notes telles qu'elles etaient avant l'appel // du modele. Si le modele n'a pas affiche ses notes, tant pis (elles *doivent* // etre dans le cache du modele, autrement elles ne seraient pas prises en // compte a chaque calcul d'un texte contenant un modele, mais seulement // quand le modele serait calcule, et on aurait des resultats incoherents) $GLOBALS['les_notes'] = $enregistre_les_notes; $GLOBALS['marqueur_notes'] = $enregistre_marqueur_notes; $GLOBALS['compt_note'] = $enregistre_compt_note; // Regarder si le modele tient compte des liens (il *doit* alors indiquer // spip_lien_ok dans les classes de son conteneur de premier niveau ; // sinon, s'il y a un lien, on l'ajoute classiquement if (strstr(' ' . ($classes = extraire_attribut($retour, 'class')).' ', 'spip_lien_ok')) { $retour = inserer_attribut($retour, 'class', trim(str_replace(' spip_lien_ok ', ' ', " $classes "))); } else if ($lien) $retour = "".$retour.""; $compteur--; return (isset($arg_list['ajax'])AND $arg_list['ajax']=='ajax') ? encoder_contexte_ajax($contexte,'',$retour) : $retour; } // Un inclure_page qui marche aussi pour l'espace prive // fonction interne a spip, ne pas appeler directement // pour recuperer $page complet, utiliser: // recuperer_fond($fond,$contexte,array('raw'=>true)) // http://doc.spip.org/@evaluer_fond function evaluer_fond ($fond, $contexte=array(), $connect=null) { if (isset($contexte['fond']) AND $fond === '') $fond = $contexte['fond']; $page = inclure_page($fond, $contexte, $connect); if ($GLOBALS['flag_ob'] AND ($page['process_ins'] != 'html')) { ob_start(); xml_hack($page, true); eval('?' . '>' . $page['texte']); $page['texte'] = ob_get_contents(); xml_hack($page); $page['process_ins'] = 'html'; ob_end_clean(); } page_base_href($page['texte']); // Lever un drapeau (global) si le fond utilise #SESSION // a destination de public/parametrer // pour remonter vers les inclusions appelantes // il faut bien lever ce drapeau apres avoir evalue le fond // pour ne pas faire descendre le flag vers les inclusions appelees if (isset($page['invalideurs']) AND isset($page['invalideurs']['session'])) $GLOBALS['cache_utilise_session'] = $page['invalideurs']['session']; return $page; } // Appeler avant et apres chaque eval() // http://doc.spip.org/@xml_hack function xml_hack(&$page, $echap = false) { if ($echap) $page['texte'] = str_replace('<'.'?xml', "<\1?xml", $page['texte']); else $page['texte'] = str_replace("<\1?xml", '<'.'?xml', $page['texte']); } // http://doc.spip.org/@page_base_href function page_base_href(&$texte){ if (!defined('_SET_HTML_BASE')) // si la profondeur est superieure a 1 // est que ce n'est pas une url page ni une url action // activer par defaut define('_SET_HTML_BASE', $GLOBALS['profondeur_url'] >= (_DIR_RESTREINT?1:2) AND _request(_SPIP_PAGE) !== 'login' AND !_request('action')); if (_SET_HTML_BASE AND $GLOBALS['html'] AND $GLOBALS['profondeur_url']>0){ list($head, $body) = explode('', $texte, 1); $insert = false; if (strpos($head, ' n'a de href c'est bon quand meme ! $insert = true; include_spip('inc/filtres'); $bases = extraire_balises($head,'base'); foreach ($bases as $base) if (extraire_attribut($base,'href')) $insert = false; } if ($insert) { include_spip('inc/filtres_mini'); // ajouter un base qui reglera tous les liens relatifs $base = url_absolue('./'); if (($pos = strpos($head, '')) !== false) $head = substr_replace($head, "\n", $pos+6, 0); $texte = $head . (isset($body) ? ''.$body : ''); // gerer les ancres $base = $_SERVER['REQUEST_URI']; if (strpos($texte,"href='#")!==false) $texte = str_replace("href='#","href='$base#",$texte); if (strpos($texte, "href=\"#")!==false) $texte = str_replace("href=\"#","href=\"$base#",$texte); } } } // Envoyer les entetes, en retenant ceux qui sont a usage interne // et demarrent par X-Spip-... // http://doc.spip.org/@envoyer_entetes function envoyer_entetes($entetes) { foreach ($entetes as $k => $v) # if (strncmp($k, 'X-Spip-', 7)) @header("$k: $v"); } ?> spip/spip/ecrire/public/balises.php0000766000000000000000000011557311236524730020575 0ustar adminadministratorsparam) && (!$p->param[0][0]) && (count($p->param[0])>$n)) return calculer_liste($p->param[0][$n], $p->descr, $p->boucles, $p->id_boucle); else return NULL; } // // Definition des balises // // http://doc.spip.org/@balise_NOM_SITE_SPIP_dist function balise_NOM_SITE_SPIP_dist($p) { $p->code = "\$GLOBALS['meta']['nom_site']"; #$p->interdire_scripts = true; return $p; } // http://doc.spip.org/@balise_EMAIL_WEBMASTER_dist function balise_EMAIL_WEBMASTER_dist($p) { $p->code = "\$GLOBALS['meta']['email_webmaster']"; #$p->interdire_scripts = true; return $p; } // http://doc.spip.org/@balise_DESCRIPTIF_SITE_SPIP_dist function balise_DESCRIPTIF_SITE_SPIP_dist($p) { $p->code = "\$GLOBALS['meta']['descriptif_site']"; #$p->interdire_scripts = true; return $p; } // http://doc.spip.org/@balise_CHARSET_dist function balise_CHARSET_dist($p) { $p->code = "\$GLOBALS['meta']['charset']"; #$p->interdire_scripts = true; return $p; } // http://doc.spip.org/@balise_LANG_LEFT_dist function balise_LANG_LEFT_dist($p) { $_lang = champ_sql('lang', $p); $p->code = "lang_dir($_lang, 'left','right')"; $p->interdire_scripts = false; return $p; } // http://doc.spip.org/@balise_LANG_RIGHT_dist function balise_LANG_RIGHT_dist($p) { $_lang = champ_sql('lang', $p); $p->code = "lang_dir($_lang, 'right','left')"; $p->interdire_scripts = false; return $p; } // http://doc.spip.org/@balise_LANG_DIR_dist function balise_LANG_DIR_dist($p) { $_lang = champ_sql('lang', $p); $p->code = "lang_dir($_lang, 'ltr','rtl')"; $p->interdire_scripts = false; return $p; } // http://doc.spip.org/@balise_PUCE_dist function balise_PUCE_dist($p) { $p->code = "definir_puce()"; $p->interdire_scripts = false; return $p; } // #DATE // Cette fonction sait aller chercher dans le contexte general // quand #DATE est en dehors des boucles // http://www.spip.net/fr_article1971.html // http://doc.spip.org/@balise_DATE_dist function balise_DATE_dist ($p) { $d = champ_sql('date', $p); # if ($d === "@\$Pile[0]['date']") # $d = "isset(\$Pile[0]['date']) ? $d : time()"; $p->code = $d; return $p; } // #DATE_REDAC // http://www.spip.net/fr_article1971.html // http://doc.spip.org/@balise_DATE_REDAC_dist function balise_DATE_REDAC_dist ($p) { $d = champ_sql('date_redac', $p); # if ($d === "@\$Pile[0]['date_redac']") # $d = "isset(\$Pile[0]['date_redac']) ? $d : time()"; $p->code = $d; $p->interdire_scripts = false; return $p; } // #DATE_MODIF // http://www.spip.net/fr_article1971.html // http://doc.spip.org/@balise_DATE_MODIF_dist function balise_DATE_MODIF_dist ($p) { $p->code = champ_sql('date_modif', $p); $p->interdire_scripts = false; return $p; } // #DATE_NOUVEAUTES // http://www.spip.net/fr_article1971.html // http://doc.spip.org/@balise_DATE_NOUVEAUTES_dist function balise_DATE_NOUVEAUTES_dist($p) { $p->code = "((\$GLOBALS['meta']['quoi_de_neuf'] == 'oui' AND @is_readable(_DIR_TMP . 'mail.lock')) ? @filemtime(_DIR_TMP . 'mail.lock') : \"'0000-00-00'\")"; $p->interdire_scripts = false; return $p; } // http://doc.spip.org/@balise_DOSSIER_SQUELETTE_dist function balise_DOSSIER_SQUELETTE_dist($p) { $code = substr(addslashes(dirname($p->descr['sourcefile'])), strlen(_DIR_RACINE)); $p->code = "_DIR_RACINE . '$code'" . $p->interdire_scripts = false; return $p; } // http://doc.spip.org/@balise_SQUELETTE_dist function balise_SQUELETTE_dist($p) { $code = addslashes($p->descr['sourcefile']); $p->code = "'$code'" . $p->interdire_scripts = false; return $p; } // http://doc.spip.org/@balise_SPIP_VERSION_dist function balise_SPIP_VERSION_dist($p) { $p->code = "spip_version()"; $p->interdire_scripts = false; return $p; } // #NOM_SITE affiche le nom du site, ou sinon l'URL ou le titre de l'objet // http://doc.spip.org/@balise_NOM_SITE_dist function balise_NOM_SITE_dist($p) { if (!$p->etoile) { $p->code = "supprimer_numero(calculer_url(" . champ_sql('url_site',$p) ."," . champ_sql('nom_site',$p) . ", 'titre', \$connect))"; } else $p->code = champ_sql('nom_site',$p); $p->interdire_scripts = true; return $p; } // http://doc.spip.org/@balise_NOTES_dist function balise_NOTES_dist($p) { // Recuperer les notes $p->code = 'calculer_notes()'; #$p->interdire_scripts = true; return $p; } // http://doc.spip.org/@balise_RECHERCHE_dist function balise_RECHERCHE_dist($p) { $p->code = 'entites_html(_request("recherche"))'; $p->interdire_scripts = false; return $p; } // http://doc.spip.org/@balise_COMPTEUR_BOUCLE_dist function balise_COMPTEUR_BOUCLE_dist($p) { $b = $p->nom_boucle ? $p->nom_boucle : $p->descr['id_mere']; if ($b === '') { erreur_squelette( _T('zbug_champ_hors_boucle', array('champ' => '#COMPTEUR_BOUCLE') ), $p->id_boucle); $p->code = "''"; } else { $p->code = "\$Numrows['$b']['compteur_boucle']"; $p->boucles[$b]->cptrows = true; $p->interdire_scripts = false; return $p; } } // http://doc.spip.org/@balise_TOTAL_BOUCLE_dist function balise_TOTAL_BOUCLE_dist($p) { $b = $p->nom_boucle ? $p->nom_boucle : $p->descr['id_mere']; if ($b === '' || !isset($p->boucles[$b])) { erreur_squelette( _T('zbug_champ_hors_boucle', array('champ' => "#$b" . 'TOTAL_BOUCLE') ), $p->id_boucle); $p->code = "''"; } else { $p->code = "\$Numrows['$b']['total']"; $p->boucles[$b]->numrows = true; $p->interdire_scripts = false; } return $p; } // Si on est hors d'une boucle {recherche}, ne pas "prendre" cette balise // http://doc.spip.org/@balise_POINTS_dist function balise_POINTS_dist($p) { return rindex_pile($p, 'points', 'recherche'); } // http://doc.spip.org/@balise_POPULARITE_ABSOLUE_dist function balise_POPULARITE_ABSOLUE_dist($p) { $p->code = 'ceil(' . champ_sql('popularite', $p) . ')'; $p->interdire_scripts = false; return $p; } // http://doc.spip.org/@balise_POPULARITE_SITE_dist function balise_POPULARITE_SITE_dist($p) { $p->code = 'ceil($GLOBALS["meta"][\'popularite_total\'])'; $p->interdire_scripts = false; return $p; } // http://doc.spip.org/@balise_POPULARITE_MAX_dist function balise_POPULARITE_MAX_dist($p) { $p->code = 'ceil($GLOBALS["meta"][\'popularite_max\'])'; $p->interdire_scripts = false; return $p; } // http://doc.spip.org/@balise_EXPOSE_dist function balise_EXPOSE_dist($p) { $on = "'on'"; $off= "''"; if (($v = interprete_argument_balise(1,$p))!==NULL){ $on = $v; if (($v = interprete_argument_balise(2,$p))!==NULL) $off = $v; // autres filtres array_shift($p->param); } return calculer_balise_expose($p, $on, $off); } // #EXPOSER est obsolete. utiliser #EXPOSE ci-dessus // http://doc.spip.org/@balise_EXPOSER_dist function balise_EXPOSER_dist($p) { $on = "'on'"; $off= "''"; if ($a = ($p->fonctions)) { // Gerer la notation [(#EXPOSER|on,off)] $onoff = array_shift($a); preg_match("#([^,]*)(,(.*))?#", $onoff[0], $regs); $on = "" . sql_quote($regs[1]); $off = "" . sql_quote($regs[3]) ; // autres filtres array_shift($p->param); } return calculer_balise_expose($p, $on, $off); } // http://doc.spip.org/@calculer_balise_expose function calculer_balise_expose($p, $on, $off) { $b = $p->nom_boucle ? $p->nom_boucle : $p->id_boucle; $key = $p->boucles[$b]->primary; $type = $p->boucles[$p->id_boucle]->primary; $desc = $p->boucles[$b]->show; $connect = sql_quote($p->boucles[$b]->sql_serveur); if (!$key) { erreur_squelette(_T('zbug_champ_hors_boucle', array('champ' => '#EXPOSER')), $b); } // Ne pas utiliser champ_sql, on jongle avec le nom boucle explicite $c = index_pile($p->id_boucle, $type, $p->boucles); if (isset($desc['field']['id_parent'])) { $parent = 0; // pour if (!$parent) dans calculer_expose } elseif (isset($desc['field']['id_rubrique'])) { $parent = index_pile($p->id_boucle, 'id_rubrique', $p->boucles, $b); } elseif (isset($desc['field']['id_groupe'])) { $parent = index_pile($p->id_boucle, 'id_groupe', $p->boucles, $b); } else $parent = "''"; $p->code = "(calcul_exposer($c, '$type', \$Pile[0], $parent, '$key', $connect) ? $on : $off)"; $p->interdire_scripts = false; return $p; } // // Inserer directement un document dans le squelette // devient un alias de #MODELE{emb} // // On insere simplement un argument {emb} en debut de liste // // Attention la syntaxe est derogatoire : il faut donc attraper // tous les faux-filtres "|autostart=true" et les transformer // en arguments "{autostart=true}" // // On s'arrete au premier filtre ne contenant pas de =, afin de // pouvoir filtrer le resultat // // http://doc.spip.org/@balise_EMBED_DOCUMENT_dist function balise_EMBED_DOCUMENT_dist($p) { if (!is_array($p->param)) $p->param=array(); // Produire le premier argument {emb} $texte = new Texte; $texte->type='texte'; $texte->texte='emb'; $param = array(0=>NULL, 1=>array(0=>$texte)); array_unshift($p->param, $param); // Transformer les filtres en arguments for ($i=1; $iparam); $i++) { if ($p->param[$i][0]) { if (!strstr($p->param[$i][0], '=')) break;# on a rencontre un vrai filtre, c'est fini $texte = new Texte; $texte->type='texte'; $texte->texte=$p->param[$i][0]; $param = array(0=>$texte); $p->param[$i][1] = $param; $p->param[$i][0] = NULL; } } // Appeler la balise #MODELE{emb}{arguments} if (!function_exists($f = 'balise_modele')) $f = 'balise_modele_dist'; return $f($p); } // Debut et fin de surlignage auto des mots de la recherche // on insere une balise Span avec une classe sans spec: // c'est transparent s'il n'y a pas de recherche, // sinon elles seront remplacees par les fontions de inc_surligne // http://doc.spip.org/@balise_DEBUT_SURLIGNE_dist function balise_DEBUT_SURLIGNE_dist($p) { include_spip('inc/surligne'); $p->code = "''"; return $p; } // http://doc.spip.org/@balise_FIN_SURLIGNE_dist function balise_FIN_SURLIGNE_dist($p) { include_spip('inc/surligne'); $p->code = "''"; return $p; } // #SPIP_CRON // a documenter // insere un
    avec un lien background-image vers les taches de fond. // Si cette balise est presente sur la page de sommaire, le site ne devrait // quasiment jamais se trouver ralenti par des taches de fond un peu lentes // http://doc.spip.org/@balise_SPIP_CRON_dist function balise_SPIP_CRON_dist ($p) { $p->code = '"
    "'; $p->interdire_scripts = false; return $p; } // #INTRODUCTION // #INTRODUCTION{longueur} // http://www.spip.net/@introduction // http://doc.spip.org/@balise_INTRODUCTION_dist function balise_INTRODUCTION_dist($p) { $type = $p->type_requete; $_texte = champ_sql('texte', $p); $_descriptif = "''"; if ($type == 'articles') { $_chapo = champ_sql('chapo', $p); $_descriptif = champ_sql('descriptif', $p); $_texte = "(strlen($_descriptif) OR chapo_redirigetil($_chapo)) ? '' : $_chapo . \"\\n\\n\" . $_texte"; } // longueur en parametre, ou valeur par defaut if (($v = interprete_argument_balise(1,$p))!==NULL) { $longueur = 'intval('.$v.')'; } else { switch ($type) { case 'articles': $longueur = '500'; break; case 'breves': $longueur = '300'; break; case 'forums': case 'rubriques': default: $longueur = '600'; break; } } $f = chercher_filtre('introduction'); $p->code = "$f($_descriptif, $_texte, $longueur, \$connect)"; #$p->interdire_scripts = true; $p->etoile = '*'; // propre est deja fait dans le calcul de l'intro return $p; } // #LANG // affiche la langue de l'objet (ou superieure), et a defaut la langue courante // (celle du site ou celle qui a ete passee dans l'URL par le visiteur) // #LANG* n'affiche rien si aucune langue n'est trouvee dans le sql/le contexte // http://doc.spip.org/@balise_LANG_dist function balise_LANG_dist ($p) { $_lang = champ_sql('lang', $p); if (!$p->etoile) $p->code = "htmlentities($_lang ? $_lang : \$GLOBALS['spip_lang'])"; else $p->code = "htmlentities($_lang)"; $p->interdire_scripts = false; return $p; } // http://doc.spip.org/@balise_CHAPO_dist function balise_CHAPO_dist ($p) { $_chapo = champ_sql('chapo', $p); if (($p->etoile) OR (strpos($_chapo, '$Pile[$SP') === false)) $p->code = $_chapo; else $p->code = "nettoyer_chapo($_chapo)"; $p->interdire_scripts = true; return $p; } // #LESAUTEURS // les auteurs d'un article (ou d'un article syndique) // http://www.spip.net/fr_article902.html // http://www.spip.net/fr_article911.html // http://doc.spip.org/@balise_LESAUTEURS_dist function balise_LESAUTEURS_dist ($p) { // Cherche le champ 'lesauteurs' dans la pile $_lesauteurs = champ_sql('lesauteurs', $p); // Si le champ n'existe pas (cas de spip_articles), on applique // le modele lesauteurs.html en passant id_article dans le contexte; // dans le cas contraire on prend le champ 'lesauteurs' (cas de // spip_syndic_articles) if ($_lesauteurs AND $_lesauteurs != '@$Pile[0][\'lesauteurs\']') { $p->code = "safehtml($_lesauteurs)"; // $p->interdire_scripts = true; } else { $connect = !$p->id_boucle ? '' : $p->boucles[$p->id_boucle]->sql_serveur; $p->code = "recuperer_fond('modeles/lesauteurs', array('id_article' => ".champ_sql('id_article', $p) ."), array('trim'=>true), " . _q($connect) .")"; $p->interdire_scripts = false; // securite apposee par recuperer_fond() } return $p; } // #RANG // affiche le "numero de l'article" quand on l'a titre '1. Premier article'; // ceci est transitoire afin de preparer une migration vers un vrai systeme de // tri des articles dans une rubrique (et plus si affinites) // http://doc.spip.org/@balise_RANG_dist function balise_RANG_dist ($p) { $_titre = champ_sql('titre', $p); $_rang = champ_sql('rang', $p); $p->code = "(($_rang)?($_rang):recuperer_numero($_titre))"; $p->interdire_scripts = false; return $p; } // #PETITION // retourne '' si l'article courant n'a pas de petition // le texte de celle-ci sinon (et ' ' si il est vide) // cf FORMULAIRE_PETITION // http://doc.spip.org/@balise_PETITION_dist function balise_PETITION_dist ($p) { $nom = $p->id_boucle; $p->code = "quete_petitions(" . champ_sql('id_article', $p) . ",'" . $p->boucles[$nom]->type_requete . "','" . $nom . "','" . $p->boucles[$nom]->sql_serveur . "', \$Cache)"; $p->interdire_scripts = false; return $p; } // #POPULARITE // http://www.spip.net/fr_article1846.html // http://doc.spip.org/@balise_POPULARITE_dist function balise_POPULARITE_dist ($p) { $_popularite = champ_sql('popularite', $p); $p->code = "(ceil(min(100, 100 * $_popularite / max(1 , 0 + \$GLOBALS['meta']['popularite_max']))))"; $p->interdire_scripts = false; return $p; } // #PAGINATION // http://www.spip.net/fr_articleXXXX.html // http://doc.spip.org/@balise_PAGINATION_dist function balise_PAGINATION_dist($p, $liste='true') { $b = $p->nom_boucle ? $p->nom_boucle : $p->descr['id_mere']; // s'il n'y a pas de nom de boucle, on ne peut pas paginer if ($b === '') { erreur_squelette( _T('zbug_champ_hors_boucle', array('champ' => '#PAGINATION') ), $p->id_boucle); $p->code = "''"; return $p; } // s'il n'y a pas de total_parties, c'est qu'on se trouve // dans un boucle recursive ou qu'on a oublie le critere {pagination} if (!$p->boucles[$b]->total_parties) { erreur_squelette( _T('zbug_pagination_sans_critere', array('champ' => '#PAGINATION') ), $p->id_boucle); $p->code = "''"; return $p; } // Transforme l'ecriture du deuxieme param {truc=chose,machin=chouette} en // {truc=chose}{machin=chouette}... histoire de simplifier l'ecriture pour // le webmestre : #MODELE{emb}{autostart=true,truc=1,chose=chouette} $params = array(); if (isset($p->param[0]) AND $p->param[0]) { while (count($p->param[0])>2){ array_unshift($params,array(0=>NULL,1=>array_pop($p->param[0]))); } } $__modele = interprete_argument_balise(1,$p); $__modele = $__modele?", $__modele":", ''"; array_shift($p->param); while(count($params)) array_unshift($p->param,array_pop($params)); // a priori true // si false, le compilo va bloquer sur des syntaxes avec un filtre sans argument qui suit la balise // si true, les arguments simples (sans truc=chose) vont degager $code_contexte = argumenter_inclure($p->param, true, $p->descr, $p->boucles, $p->id_boucle, false); $p->boucles[$b]->numrows = true; $connect = $p->boucles[$b]->sql_serveur; $f_pagination = chercher_filtre('pagination'); $type = $p->boucles[$b]->modificateur['debut_nom']; $modif = ($type[0]!=="'") ? "'debut'.$type" : ("'debut" .substr($type,1)); $p->code = $f_pagination."( (isset(\$Numrows['$b']['grand_total']) ? \$Numrows['$b']['grand_total'] : \$Numrows['$b']['total'] ), $type, isset(\$Pile[0][$modif])?\$Pile[0][$modif]:0," . $p->boucles[$b]->total_parties . ", $liste$__modele," . _q($connect) . ", array(" . implode(',',$code_contexte) . ")" . ")"; $p->interdire_scripts = false; return $p; } // N'afficher que l'ancre de la pagination (au-dessus, par exemple, alors // qu'on mettra les liens en-dessous de la liste paginee) // http://doc.spip.org/@balise_ANCRE_PAGINATION_dist function balise_ANCRE_PAGINATION_dist($p) { $p = balise_PAGINATION_dist($p, $liste='false'); return $p; } // equivalent a #TOTAL_BOUCLE sauf pour les boucles paginees, ou elle // indique le nombre total d'articles repondant aux criteres hors pagination // http://doc.spip.org/@balise_GRAND_TOTAL_dist function balise_GRAND_TOTAL_dist($p) { $b = $p->nom_boucle ? $p->nom_boucle : $p->descr['id_mere']; if ($b === '' || !isset($p->boucles[$b])) { erreur_squelette( _T('zbug_champ_hors_boucle', array('champ' => "#$b" . 'TOTAL_BOUCLE') ), $p->id_boucle); $p->code = "''"; } else { $p->code = "(isset(\$Numrows['$b']['grand_total']) ? \$Numrows['$b']['grand_total'] : \$Numrows['$b']['total'])"; $p->boucles[$b]->numrows = true; $p->interdire_scripts = false; } return $p; } // // Parametres de reponse a un forum // // http://doc.spip.org/@balise_PARAMETRES_FORUM_dist function balise_PARAMETRES_FORUM_dist($p) { $_id_article = champ_sql('id_article', $p); $p->code = ' // refus des forums ? (quete_accepter_forum('.$_id_article.')=="non" OR ($GLOBALS["meta"]["forums_publics"] == "non" AND quete_accepter_forum('.$_id_article.') == "")) ? "" : // sinon: '; // pas de calculs superflus si le site est monolingue $lang = strpos($GLOBALS['meta']['langues_utilisees'], ','); switch ($p->type_requete) { case 'articles': $c = '"id_article=".' . champ_sql('id_article', $p); if ($lang) $lang = champ_sql('lang', $p); break; case 'breves': $c = '"id_breve=".' . champ_sql('id_breve', $p); if ($lang) $lang = champ_sql('lang', $p); break; case 'rubriques': $c = '"id_rubrique=".' . champ_sql('id_rubrique', $p); if ($lang) $lang = champ_sql('lang', $p); break; case 'syndication': case 'syndic': // passer par la rubrique pour avoir un champ Lang // la table syndic n'en ayant pas $c = '"id_syndic=".' . champ_sql('id_syndic', $p); if ($lang) $lang = 'sql_getfetsel("lang", "spip_rubriques", ("id_rubrique=" . intval("' . champ_sql('id_rubrique', $p) . '")))'; break; case 'forums': default: // ATTENTION mettre 'id_rubrique' avant 'id_syndic': // a l'execution lang_parametres_forum // y cherchera l'identifiant donnant la langue // et pour id_syndic c'est id_rubrique car sa table n'en a pas $liste_table = array ("article","breve","rubrique","syndic","forum"); $c = ''; $tables = array(); foreach ($liste_table as $t) { $champ = 'id_' . $t; $x = champ_sql($champ, $p); $c .= (($c) ? ".\n" : "") . "((!$x) ? '' : ('&$champ='.$x))"; if ($lang AND $t!='forum') $tables[]= "'$champ' => '" . table_objet_sql($t) . "'"; } $c = "substr($c,1)"; if ($lang) $lang = "array(" . join(",",$tables) .")"; break; } if ($lang) $c = "lang_parametres_forum($c,$lang)"; // Syntaxe [(#PARAMETRES_FORUM{#SELF})] pour fixer le retour du forum # note : ce bloc qui sert a recuperer des arguments calcules pourrait # porter un nom et faire partie de l'API. $retour = interprete_argument_balise(1,$p); if ($retour===NULL) $retour = "''"; // Attention un eventuel &retour=xxx dans l'URL est prioritaire $c .= '. (($lien = (_request("retour") ? _request("retour") : str_replace("&", "&", '.$retour.'))) ? "&retour=".rawurlencode($lien) : "")'; // Ajouter le code d'invalideur specifique a cette balise include_spip('inc/invalideur'); if (function_exists($i = 'code_invalideur_forums')) $p->code .= $i($p, '('.$c.')'); $p->interdire_scripts = false; return $p; } // Reference a l'URL de la page courante // Attention dans un INCLURE() ou une balise dynamique on n'a pas le droit de // mettre en cache #SELF car il peut correspondre a une autre page (attaque XSS) // (Dans ce cas faire pour differencier les caches.) // http://www.spip.net/@self // http://doc.spip.org/@balise_SELF_dist function balise_SELF_dist($p) { $p->code = 'self()'; $p->interdire_scripts = false; return $p; } // // #CHEMIN{fichier} -> find_in_path(fichier) // // http://doc.spip.org/@balise_CHEMIN_dist function balise_CHEMIN_dist($p) { $arg = interprete_argument_balise(1,$p); if (!$arg) { erreur_squelette(_T('zbug_balise_sans_argument', array('balise' => ' CHEMIN')), $p->id_boucle); $p->code = "''"; } else $p->code = 'find_in_path(' . $arg .')'; #$p->interdire_scripts = true; return $p; } // // #ENV // l'"environnement", id est le $contexte (ou $contexte_inclus) // // en standard on applique |entites_html, mais si vous utilisez // [(#ENV*{toto})] il *faut* vous assurer vous-memes de la securite // anti-javascript (par exemple en filtrant avec |safehtml) // // La syntaxe #ENV{toto, rempl} renverra 'rempl' si $toto est vide // // Si le tableau est vide on renvoie '' (utile pour #SESSION) // // http://doc.spip.org/@balise_ENV_dist function balise_ENV_dist($p, $src = NULL) { // le tableau de base de la balise (cf #META ci-dessous) $_nom = interprete_argument_balise(1,$p); $_sinon = interprete_argument_balise(2,$p); if (!$_nom) { // cas de #ENV sans argument : on retourne le serialize() du tableau // une belle fonction [(#ENV|affiche_env)] serait pratique $p->code = $src ? ('(is_array($a = ('.$src.')) ? serialize($a) : "")') : '@serialize($Pile[0])'; } else { // admet deux arguments : nom de variable, valeur par defaut si vide $p->code = $src ? ('is_array($a = ('.$src.')) ? $a['.$_nom.'] : ""') : ('@$Pile[0][' . $_nom . ']'); if ($_sinon) $p->code = 'sinon('. $p->code.",$_sinon)"; else $p->code = '('.$p->code.')'; } #$p->interdire_scripts = true; return $p; } // // #CONFIG // les reglages du site // // Par exemple #CONFIG{gerer_trad} donne 'oui' ou 'non' selon le reglage // Attention c'est brut de decoffrage de la table spip_meta // // La balise fonctionne exactement comme #ENV (ci-dessus) // // http://doc.spip.org/@balise_CONFIG_dist function balise_CONFIG_dist($p) { if(function_exists('balise_ENV')) return balise_ENV($p, '$GLOBALS["meta"]'); else return balise_ENV_dist($p, '$GLOBALS["meta"]'); } // http://doc.spip.org/@balise_CONNECT_dist function balise_CONNECT_dist($p) { $p->code = '($connect ? $connect : NULL)'; $p->interdire_scripts = false; return $p; } // // #SESSION // Cette balise est un tableau des donnees du visiteur (nom, email etc) // Si elle est invoquee, elle leve un drapeau dans le fichier cache, qui // permet a public/cacher d'invalider le cache si le visiteur suivant n'a // pas la meme session // http://doc.spip.org/@balise_SESSION_dist function balise_SESSION_dist($p) { $p->descr['session'] = true; $f = function_exists('balise_ENV') ? 'balise_ENV' : 'balise_ENV_dist'; $p = $f($p, '$GLOBALS["visiteur_session"]'); return $p; } // // #SESSION_SET{x,y} // Ajoute x=y dans la session du visiteur // http://doc.spip.org/@balise_SESSION_SET_dist function balise_SESSION_SET_dist($p) { $_nom = interprete_argument_balise(1,$p); $_val = interprete_argument_balise(2,$p); $p->code = '(include_spip("inc/session") AND session_set('.$_nom.','.$_val.'))'; $p->interdire_scripts = false; return $p; } // // #EVAL{...} // evalue un code php ; a utiliser avec precaution :-) // // rq: #EVAL{code} produit eval('return code;') // mais si le code est une expression sans balise, on se dispense // de passer par une construction si compliquee, et le code est // passe tel quel (entre parentheses, et protege par interdire_scripts) // Exemples : #EVAL**{6+9} #EVAL**{_DIR_IMG_PACK} #EVAL{'date("Y-m-d")'} // #EVAL{'str_replace("r","z", "roger")'} (attention les "'" sont interdits) // http://doc.spip.org/@balise_EVAL_dist function balise_EVAL_dist($p) { $php = interprete_argument_balise(1,$p); if ($php) { # optimisation sur les #EVAL{une expression sans #BALISE} # attention au commentaire "// x signes" qui precede if (preg_match(",^([[:space:]]*//[^\n]*\n)'([^']+)'$,ms", $php,$r)) $p->code = /* $r[1]. */'('.$r[2].')'; else $p->code = "eval('return '.$php.';')"; } else $p->code = ''; #$p->interdire_scripts = true; return $p; } // #CHAMP_SQL{x} renvoie la valeur du champ sql 'x' // permet de recuperer par exemple un champ notes dans une table sql externe // (impossible via #NOTES qui est une balise calculee) // ne permet pas de passer une expression pour x qui ne peut etre qu'un texte statique ! // http://doc.spip.org/@balise_CHAMP_SQL_dist function balise_CHAMP_SQL_dist($p){ $p->code = ''; if (isset($p->param[0][1][0]) AND $champ = ($p->param[0][1][0]->texte)) $p->code = champ_sql($champ, $p); #$p->interdire_scripts = true; return $p; } // #VAL{x} renvoie 'x' (permet d'appliquer un filtre a une chaine) // Attention #VAL{1,2} renvoie '1', indiquer #VAL{'1,2'} // http://doc.spip.org/@balise_VAL_dist function balise_VAL_dist($p){ $p->code = interprete_argument_balise(1,$p); if (!strlen($p->code)) $p->code = "''"; $p->interdire_scripts = false; return $p; } // #NOOP est un alias pour regler #948, ne pas documenter // http://doc.spip.org/@balise_NOOP_dist function balise_NOOP_dist($p) { return balise_VAL_dist($p); } // // #REM // pour les remarques : renvoie toujours '' // // http://doc.spip.org/@balise_REM_dist function balise_REM_dist($p) { $p->code="''"; $p->interdire_scripts = false; return $p; } // // #HTTP_HEADER // pour les entetes de retour http // Ne fonctionne pas sur les INCLURE ! // #HTTP_HEADER{Content-Type: text/css} // // http://doc.spip.org/@balise_HTTP_HEADER_dist function balise_HTTP_HEADER_dist($p) { $header = interprete_argument_balise(1,$p); $p->code = "'<'.'?php header(\"' . " . $header . " . '\"); ?'.'>'"; $p->interdire_scripts = false; return $p; } // Filtre a appliquer a l'ensemble de la page une fois calculee // (filtrage fait au niveau du squelette, et sans s'appliquer aux ) // http://doc.spip.org/@balise_FILTRE_dist function balise_FILTRE_dist($p) { if ($p->param) { $args = array(); foreach ($p->param as $i => $ignore) $args[] = interprete_argument_balise($i+1,$p); $p->code = '\'<' .'?php header("X-Spip-Filtre: \'.' .join('.\'|\'.', $args) . " . '\"); ?'.'>'"; $p->interdire_scripts = false; return $p; } } // // #CACHE // definit la duree de vie ($delais) du squelette // #CACHE{24*3600} // parametre(s) supplementaire(s) : // #CACHE{24*3600, cache-client} autorise gestion du IF_MODIFIED_SINCE // #CACHE{24*3600, statique} ne respecte pas l'invalidation par modif de la base // (mais s'invalide tout de meme a l'expiration du delai) // par defaut cache-client => statique // cf. ecrire/public/cacher.php // http://doc.spip.org/@balise_CACHE_dist function balise_CACHE_dist($p) { $duree = valeur_numerique($p->param[0][1][0]->texte); // noter la duree du cache dans un entete proprietaire $p->code .= '\'<'.'?php header("X-Spip-Cache: ' . $duree . '"); ?'.'>\''; // Remplir le header Cache-Control // cas #CACHE{0} if ($duree == 0) $p->code .= '.\'<' .'?php header("Cache-Control: no-store, no-cache, must-revalidate"); ?' .'><' .'?php header("Pragma: no-cache"); ?' .'>\''; // recuperer les parametres suivants $i = 1; while (isset($p->param[0][++$i])) { $pa = ($p->param[0][$i][0]->texte); if ($pa == 'cache-client' AND $duree > 0) { $p->code .= '.\'<'.'?php header("Cache-Control: max-age=' . $duree . '"); ?'.'>\''; // il semble logique, si on cache-client, de ne pas invalider $pa = 'statique'; } if ($pa == 'statique' AND $duree > 0) $p->code .= '.\'<'.'?php header("X-Spip-Statique: oui"); ?'.'>\''; } $p->interdire_scripts = false; return $p; } // // #INSERT_HEAD // pour permettre aux plugins d'inserer des styles, js ou autre // dans l'entete sans modification du squelette // // http://doc.spip.org/@balise_INSERT_HEAD_dist function balise_INSERT_HEAD_dist($p) { $p->code = "pipeline('insert_head','')"; $p->code .= '. \'<' .'?php header("X-Spip-Filtre: \'.' .'\'compacte_head\'' . " . '\"); ?'.'>'"; $p->interdire_scripts = false; return $p; } // // #INCLURE statique // l'inclusion est realisee au calcul du squelette, pas au service // ainsi le produit du squelette peut etre utilise en entree de filtres a suivre // on peut faire un #INCLURE{fichier} sans squelette // (Incompatible avec les balises dynamiques) // http://doc.spip.org/@balise_INCLUDE_dist function balise_INCLUDE_dist($p) { if(function_exists('balise_INCLURE')) return balise_INCLURE($p); else return balise_INCLURE_dist($p); } // http://doc.spip.org/@balise_INCLURE_dist function balise_INCLURE_dist($p) { $id_boucle = $p->id_boucle; // la lang n'est pas passe de facon automatique par argumenter // mais le sera pas recuperer_fond, sauf si etoile=>true est passe // en option $_contexte = argumenter_inclure($p->param, true, $p->descr, $p->boucles, $id_boucle, false, false); if (isset($_contexte['fond'])) { // #INCLURE{doublons} if (isset($_contexte['doublons'])) { $_contexte['doublons'] = "'doublons' => \$doublons"; } // Critere d'inclusion {env} (et {self} pour compatibilite ascendante) if (isset($_contexte['env']) || isset($_contexte['self']) ) { $flag_env = true; unset($_contexte['env']); } else $flag_env = false; $_l = 'array(' . join(",\n\t", $_contexte) .')'; if ($flag_env) $_l = "array_merge(\$Pile[0],$_l)"; $_options = array(); if (isset($_contexte['ajax'])) $_options[] = "'ajax'=>true"; if ($p->etoile) $_options[] = "'etoile'=>true"; $_options = "array(" . join(',',$_options) . ")"; $p->code = "recuperer_fond('', $_l, $_options)"; } elseif (!isset($_contexte[1])) { erreur_squelette(_T('zbug_balise_sans_argument', array('balise' => ' INCLURE')), $p->id_boucle); $p->code = "''"; } else $p->code = '(($c = find_in_path(' . $_contexte[1] . ')) ? spip_file_get_contents($c) : "")'; $p->interdire_scripts = false; // la securite est assuree par recuperer_fond return $p; } // Inclure un modele : #MODELE{modele, params} // http://doc.spip.org/@balise_MODELE_dist function balise_MODELE_dist($p) { $_contexte = argumenter_inclure($p->param, true, $p->descr, $p->boucles, $p->id_boucle, false); if (!isset($_contexte[1])) { erreur_squelette(_T('zbug_balise_sans_argument', array('balise' => ' MODELE')), $p->id_boucle); $p->code = "''"; } else { $nom = $_contexte[1]; unset($_contexte[1]); // Incoherence dans la syntaxe du contexte. A revoir. // Reserver la cle primaire de la boucle courante si elle existe if ($idb = $p->id_boucle) { if ($primary = $p->boucles[$idb]->primary AND !strpos($primary,',')) { $id = champ_sql($primary, $p); $_contexte[] = "'$primary'=>".$id; $_contexte[] = "'id'=>".$id; } } $connect = ''; if (isset($p->boucles[$p->id_boucle])) $connect = $p->boucles[$p->id_boucle]->sql_serveur; $page = "recuperer_fond('modeles/' . $nom, array(".join(',', $_contexte).",'recurs'=>(++\$recurs)), array('trim'=>true, 'modele'=>true" . (isset($_contexte['ajax'])?", 'ajax'=>true":'') . "), " . _q($connect) . ")"; $p->code = "\n\t(((\$recurs=(isset(\$Pile[0]['recurs'])?\$Pile[0]['recurs']:0))>=5)? '' :\n\t$page)\n"; $p->interdire_scripts = false; // securite assuree par le squelette } return $p; } // // #SET // Affecte une variable locale au squelette // #SET{nom,valeur} // la balise renvoie la valeur // http://doc.spip.org/@balise_SET_dist function balise_SET_dist($p){ $_nom = interprete_argument_balise(1,$p); $_valeur = interprete_argument_balise(2,$p); if ($_nom AND $_valeur) $p->code = "vide(\$Pile['vars'][$_nom] = $_valeur)"; else $p->code = "''"; $p->interdire_scripts = false; // la balise ne renvoie rien return $p; } // // #GET // Recupere une variable locale au squelette // #GET{nom,defaut} renvoie defaut si la variable nom n'a pas ete affectee // // http://doc.spip.org/@balise_GET_dist function balise_GET_dist($p) { $p->interdire_scripts = false; // le contenu vient de #SET, donc il est de confiance if (function_exists('balise_ENV')) return balise_ENV($p, '$Pile["vars"]'); else return balise_ENV_dist($p, '$Pile["vars"]'); } // // #PIPELINE // pour permettre aux plugins d'inserer des sorties de pipeline dans un squelette // #PIPELINE{insert_body} // #PIPELINE{insert_body,flux} // // http://doc.spip.org/@balise_PIPELINE_dist function balise_PIPELINE_dist($p) { $_pipe = interprete_argument_balise(1,$p); $_flux = interprete_argument_balise(2,$p); $_flux = $_flux?$_flux:"''"; $p->code = "pipeline( $_pipe , $_flux )"; $p->interdire_scripts = false; return $p; } // // #EDIT // une balise qui ne fait rien, pour surcharge par le plugin widgets // // http://doc.spip.org/@balise_EDIT_dist function balise_EDIT_dist($p) { $p->code = "''"; $p->interdire_scripts = false; return $p; } // // #TOTAL_UNIQUE // pour recuperer le nombre d'elements affiches par l'intermediaire du filtre // |unique // usage: // #TOTAL_UNIQUE afiche le nombre de #BALISE|unique // #TOTAL_UNIQUE{famille} afiche le nombre de #BALISE|unique{famille} // // http://doc.spip.org/@balise_TOTAL_UNIQUE_dist function balise_TOTAL_UNIQUE_dist($p) { $_famille = interprete_argument_balise(1,$p); $_famille = $_famille ? $_famille : "''"; $p->code = "unique('', $_famille, true)"; return $p; } // // #ARRAY // pour creer un array php a partir d'arguments calcules // #ARRAY{key1,val1,key2,val2 ...} returne array(key1=>val1,...) // // http://doc.spip.org/@balise_ARRAY_dist function balise_ARRAY_dist($p) { $_code = array(); $n=1; do { $_key = interprete_argument_balise($n++,$p); $_val = interprete_argument_balise($n++,$p); if ($_key AND $_val) $_code[] = "$_key => $_val"; } while ($_key && $_val); $p->code = 'array(' . join(', ',$_code).')'; $p->interdire_scripts = false; return $p; } //#FOREACH // // http://doc.spip.org/@balise_FOREACH_dist function balise_FOREACH_dist($p) { $_tableau = interprete_argument_balise(1,$p); $_tableau = str_replace("'", "", strtoupper($_tableau)); $_tableau = sinon($_tableau, 'ENV'); $f = 'balise_'.$_tableau; $balise = function_exists($f) ? $f : (function_exists($g = $f.'_dist') ? $g : ''); if($balise) { $_modele = interprete_argument_balise(2,$p); $_modele = str_replace("'", "", strtolower($_modele)); $__modele = 'foreach_'.strtolower($_tableau); $_modele = (!$_modele AND find_in_path('modeles/'.$__modele.'.html')) ? $__modele : ($_modele ? $_modele : 'foreach'); // on passe a la balise seulement les parametres // mais on enleve les 2 deja utilise // [(#FOREACH{CONFIG,'',suivants}|filtre)] $p->param[0] = array_merge(array(""),array_slice($p->param[0],3)); $p = $balise($p); $filtre = chercher_filtre('foreach'); $p->code = $filtre . "(unserialize(" . $p->code . "), '" . $_modele . "')"; } //On a pas trouve la balise correspondant au tableau a traiter else { erreur_squelette( _T('zbug_balise_inexistante',array('from'=>'#FOREACH','balise'=>$_tableau)), $p->id_boucle ); $p->code = "''"; } return $p; } // Appelle la fonction autoriser et renvoie ' ' si OK, '' si niet // A noter : la priorite des operateurs exige && plutot que AND // Cette balise cree un cache par session // http://doc.spip.org/@balise_AUTORISER_dist function balise_AUTORISER_dist($p) { $_code = array(); $p->descr['session'] = true; // faire un cache par session $n=1; while ($_v = interprete_argument_balise($n++,$p)) $_code[] = $_v; $p->code = '(include_spip("inc/autoriser")&&autoriser(' . join(', ',$_code).')?" ":"")'; $p->interdire_scripts = false; return $p; } // Appelle la fonction info_plugin // Afficher des informations sur les plugins dans le site public // http://doc.spip.org/@balise_PLUGIN_dist function balise_PLUGIN_dist($p) { $plugin = interprete_argument_balise(1,$p); $plugin = isset($plugin) ? str_replace('\'', '"', $plugin) : '""'; $type_info = interprete_argument_balise(2,$p); $type_info = isset($type_info) ? str_replace('\'', '"', $type_info) : '"est_actif"'; $f = chercher_filtre('info_plugin'); $p->code = $f.'('.$plugin.', '.$type_info.')'; return $p; } // Appelle la fonction inc_aider_dist // http://doc.spip.org/@balise_AIDER_dist function balise_AIDER_dist($p) { $_motif = interprete_argument_balise(1,$p); $aider = charger_fonction('aider','inc'); $p->code = "((\$aider=charger_fonction('aider','inc'))?\$aider($_motif):'')"; return $p; } // creer le contexte de traitement des formulaires dynamiques en charger/valider/modifier // et les hidden de l'url d'action // http://doc.spip.org/@balise_ACTION_FORMULAIRE function balise_ACTION_FORMULAIRE($p){ $_url = interprete_argument_balise(1,$p); if (!$_form = interprete_argument_balise(2,$p)){ $_form = "'".addslashes(basename($p->descr['sourcefile'],'.html'))."'"; } $p->code = ""; if (strlen($_url)) $p->code .= " . (form_hidden($_url))"; if (strlen($_form)) $p->code .= // envoyer le nom du formulaire que l'on traite ". ''" // transmettre les eventuels args de la balise formulaire . ". ''" . ". (@\$Pile[0]['_hidden']?@\$Pile[0]['_hidden']:'')"; if (strlen($p->code)) $p->code = "'
    '" . $p->code . " . '
    '"; $p->interdire_scripts = false; return $p; } ?> spip/spip/ecrire/public/vertebrer.php0000766000000000000000000001265311236524730021146 0ustar adminadministrators $t) { $tri = $direction . ((sql_test_int($t) OR sql_test_date($r)) ? 'tri_n' : 'tri'); $url = vertebrer_sanstri($tri) . "|parametre_url{" . $tri . ",'" . $n . "'}"; $res .= "\n\t\t" . "\n\t\t\t$n" . "\n\t\t"; } return $res; } // http://doc.spip.org/@vertebrer_sanstri function vertebrer_sanstri($sauf='') { $url =""; foreach (array('tri', 'tri_n', '_tri', '_tri_n') as $c) { if ($sauf != $c) $url .= "|$c"; } return '|parametre_url{"' . substr($url,1) .'",""}'; } // Autant de formulaire que de champs (pour les criteres conditionnels) // http://doc.spip.org/@vertebrer_form function vertebrer_form($fields) { $res = ''; $url = join('|', array_keys($fields)); $url = "#SELF|\n\t\t\tparametre_url{'$url',''}"; foreach($fields as $n => $t) { $s = sql_test_int($t) ? 11 : (preg_match('/char\s*\((\d)\)/i', $t, $r) ? $r[1] : ''); $res .= "\n\t\t
    " . "
    " . "\n\t\t\t\n\t\t\t[($url|\n\t\t\tform_hidden)]" . "\n\t\t
    "; } return $res; } // Autant de criteres conditionnels que de champs // http://doc.spip.org/@vertebrer_crit function vertebrer_crit($v) { $res = ""; foreach($v as $n => $t) { $res .= "\n\t\t{" . $n . " ?}"; } return $res; } // Class CSS en fonction de la parite du numero de ligne. // Style text-align en fonction du type SQL (numerique ou non). // Filtre de belle date sur type SQL signalant une date ou une estampille. // Si une colonne reference une table, ajoute un href sur sa page dynamique // (il faudrait aller chercher sa def pour ilustrer les jointures en SPIP) // http://doc.spip.org/@vertebrer_cell function vertebrer_cell($fields) { $res = ""; foreach($fields as $n => $t) { $texte = "#" . strtoupper($n); if (preg_match('/\s+references\s+([\w_]+)/' , $t, $r)) { $url = "[(#SELF|parametre_url{page,'" . $r[1] . "'})]"; $texte = "" . $texte . ""; } if (sql_test_int($t)) $s = " style='text-align: right;'"; else { $s = ''; if (sql_test_date($t)) $texte = "[($texte|affdate_heure)]"; } $res .= "\n\t\t$texte"; } return $res; } // http://doc.spip.org/@public_vertebrer_dist function public_vertebrer_dist($desc) { $nom = $desc['table']; $surnom = $desc['id_table']; $connexion = $desc['connexion']; $field = $desc['field']; $key = $desc['key']; ksort($field); $form = vertebrer_form($field); $crit = vertebrer_crit($field); $cell = vertebrer_cell($field); $sort = vertebrer_sort($field,''); $tros = vertebrer_sort($field,'_'); $titre = "[(#ENV{page}|image_typo{police=dustismo_bold.ttf,taille=36,couleur=4433bb})]"; $distant = !$connexion ? '' : "&connect=$connexion"; $skel = "./?"._SPIP_PAGE."=table:$surnom$distant&var_mode=debug&var_mode_affiche=squelette#debug_boucle"; return "#CACHE{0} [(#NOM_SITE_SPIP|textebrut)] - #ENV{page}

    $titre


    [

    (#PAGINATION)

    ] $sort $form $cell $tros
    <:info_numero_abbreviation:>
    #COMPTEUR_BOUCLE
    <:info_numero_abbreviation:>
    \n

    <:texte_vide:>

    "; } ?> spip/spip/ecrire/public/debug.php0000766000000000000000000006217011236524730020233 0ustar adminadministrators0) { $env_texte="
    " . "
    #ENV\n" . "
    \n"; foreach ($env as $nom => $valeur) { $env_texte .= "\n"; if (is_array($valeur)) $valeur = '(' . count($valeur) .' items) [' . join(',', $valeur) . ']'; $env_texte .= "\n"; } $env_texte .= "\n
    ".nl2br(entites_html($nom)) . ": ".nl2br(entites_html($valeur)) . "
    \n"; $env_texte .= "
    \n"; } return $env_texte; } // Si le code php produit des erreurs, on les affiche en surimpression // sauf pour un visiteur non admin (lui ne voit rien de special) // et en mode validation (fausse erreur "double occurrence insert_head") // ajouter &var_mode=debug pour voir les erreurs et en parler sur spip@rezo.net // http://doc.spip.org/@affiche_erreurs_page function affiche_erreurs_page($tableau_des_erreurs, $message='') { if (_request('exec')=='valider_xml' OR !$tableau_des_erreurs) return ''; $GLOBALS['bouton_admin_debug'] = true; $res = ''; $anc = ''; $i = 1; foreach ($tableau_des_erreurs as $err) { $res .= "" . $i ." \n" .join("\n",$err) ."\n"; $i++; } $cols = 1+count($err); $style = _DIR_RESTREINT ? " position: absolute; top: 90px; left: 10px; width: 200px; z-index: 1000; filter:alpha(opacity=95); -moz-opacity:0.9; opacity: 0.95;" : ''; return "\n" . $res . "
    " . ($message ? $message : _T('zbug_erreur_squelette')) ## aide locale courte a ecrire, avec lien vers une grosse page de documentation # aide('erreur_compilation'), . "

    $anc

    "; } // http://doc.spip.org/@chrono_requete function chrono_requete($temps) { $total = 0; $hors = "" . _T('zbug_hors_compilation') . ""; $t = $q = $n = $d = array(); foreach ($temps as $key => $row) { list($dt, $nb, $boucle, $query, $explain, $res) = $row; $total += $dt; $d[$boucle]+= $dt; $t[$key] = $dt; $q[$key] = $nb; $e = "" . (!$boucle ? $hors : ($boucle . ' (' . @++$n[$boucle] . ")")) . "" . "Time$dt" . "Order$nb" . "Res$res" ; foreach($explain as $k => $v) { $e .= "$k" . str_replace(';','
    ',$v) . ""; } $e = "
    $e
    "; $temps[$key] = array($boucle, $e, $query); } array_multisort($t, SORT_DESC, $q, $temps); arsort($d); $i = 1; $t = array(); foreach($temps as $k => $v) { $boucle = array_shift($v); $temps[$k] = $v; $x = ",', "\n",$v[0])) . "' href='".quote_amp($GLOBALS['REQUEST_URI'])."#req$i'>" . str_replace(' ', ' ', sprintf("%5d",$i)) . ""; if (count($t[$boucle]) % 30 == 29) $x .= "
    "; $t[$boucle][] = $x; $i++; } if ($d['']) { $d[$hors] = $d['']; $n[$hors] = $n['']; $t[$hors] = $t['']; } unset($d['']); foreach ($d as $k => $v) { $d[$k] = $n[$k] . "$k$v" . join('',$t[$k]); } $titre = '
    ' . _T('zbug_statistiques') . '
    ' . "\n\n" . (_request('var_mode_objet') ? '' : ("")) . "
    " . join("
    ", $d) . "
    " . count($temps) . " " . _T('info_total') . '' . $total . "
    "; return (_DIR_RESTREINT ? '' : affiche_erreurs_page($GLOBALS['tableau_des_erreurs'])) . affiche_erreurs_page($temps, $titre); } // // Si une boucle cree des soucis, on peut afficher la requete fautive // avec son code d'erreur // // http://doc.spip.org/@erreur_requete_boucle function erreur_requete_boucle($query, $errno, $erreur) { $GLOBALS['bouton_admin_debug'] = true; if (preg_match(',err(no|code):?[[:space:]]*([0-9]+),i', $erreur, $regs)) { $errno = $regs[2]; } else if (($errno == 1030 OR $errno <= 1026) AND preg_match(',[^[:alnum:]]([0-9]+)[^[:alnum:]],', $erreur, $regs)) $errno = $regs[1]; // Erreur systeme if ($errno > 0 AND $errno < 200) { $retour .= "

    " . _T('info_erreur_systeme', array('errsys'=>$errno)) . "
    \n" . _T('info_erreur_systeme2', array('script' => generer_url_ecrire('admin_repair'))) . '
    '; spip_log("Erreur systeme $errno"); } // Requete erronee else { $err = ""._T('avis_erreur_mysql')."
    \n" . htmlspecialchars($query) . "\n
    " . htmlspecialchars($erreur) . "
    "; if (isset($GLOBALS['debug']['aucasou'])) { list($table, $id, $serveur) = $GLOBALS['debug']['aucasou']; $err = "<BOUCLE".$id.">($able)" . "
    \n" . $err . "</BOUCLE".$id.">\n"; } $retour .= "$err" . aide('erreur_mysql'); spip_log("Erreur requete $id (".$GLOBALS['fond'].".html)"); } erreur_squelette($retour); } /** * Definir le nombre maximal d'erreur possible dans les squelettes * au dela, l'affichage est arrete et les erreurs sont affichees. * Definir a zero permet de ne jamais bloquer, * mais il faut etre tres prudent avec cette utilisation * * Sert pour les tests unitaires */ define('_DEBUG_MAX_SQUELETTE_ERREURS', 4); // // Erreur de syntaxe des squelettes : memoriser le code fautif // // http://doc.spip.org/@erreur_squelette function erreur_squelette($message='', $lieu='') { global $tableau_des_erreurs; static $runs; if (is_array($message)) list($message, $lieu) = $message; spip_log("Erreur SQL: $message | $lieu (" . $GLOBALS['fond'] .")"); $GLOBALS['bouton_admin_debug'] = true; $tableau_des_erreurs[] = array($message, $lieu); // Eviter les boucles infernales if (++$runs > _DEBUG_MAX_SQUELETTE_ERREURS AND _DEBUG_MAX_SQUELETTE_ERREURS) { if ($_COOKIE['spip_admin'] OR ($GLOBALS['var_mode'] == 'debug')) { include_spip('inc/minipres'); $titre = 'SPIP ' . $GLOBALS['spip_version_affichee'] . ' ' . _T('admin_debug') . ' ' . supprimer_tags(extraire_multi($GLOBALS['meta']['nom_site'])); echo minipres($titre, affiche_erreurs_page($tableau_des_erreurs)); exit; } } } // appelee a chaque sortie de boucle // http://doc.spip.org/@boucle_debug_resultat function boucle_debug_resultat ($id, $type, $resultat) { global $debug_objets; $nom = $debug_objets['courant']; // ne pas memoriser plus de 3 tours d'une meme boucle if (count($debug_objets['resultat']["$nom$id"]) < 3) $debug_objets['resultat']["$nom$id"][] = $resultat; } // appelee a chaque requete // on n'a pas le nom du squelette, d'ailleurs ca n'en vient peut-etre pas // http://doc.spip.org/@boucle_debug_requete function boucle_debug_requete ($req) { global $debug_objets; if (isset($GLOBALS['debug']['aucasou'])) { list($table, $id, $serveur) = $GLOBALS['debug']['aucasou']; $nom = $debug_objets['courant']; $debug_objets['requete']["$nom$id"] = $req; } } // appelee a chaque sortie de sequence (compilo.php) // http://doc.spip.org/@debug_sequence function debug_sequence($id, $nom, $niv, $sequence) { global $debug_objets; if (!$niv) { $debug_objets['sequence'][$nom.$id] = $sequence; } $res = ""; foreach($sequence as $v) if (is_array($v)) $res .= $v[2]; return $res; } // appelee a chaque compilation de boucle (compilo.php) // http://doc.spip.org/@boucle_debug_compile function boucle_debug_compile ($id, $nom, $code) { global $debug_objets; $debug_objets['code'][$nom.$id] = $code; } // appelee a chaque compilation de squelette (compilo.php) // http://doc.spip.org/@squelette_debug_compile function squelette_debug_compile($nom, $sourcefile, $code, $squelette) { global $debug_objets; $debug_objets['squelette'][$nom] = $squelette; $debug_objets['sourcefile'][$nom] = $sourcefile; if (!isset($debug_objets['principal'])) $debug_objets['principal'] = $nom; } // appelee a chaque analyse syntaxique de squelette // http://doc.spip.org/@boucle_debug function boucle_debug ($nom, $id_parent, $id, $type, $crit, $avant, $milieu, $apres, $altern) { global $debug_objets; $debug_objets['parent'][$nom.$id] = $id_parent; $debug_objets['pretty'][$nom.$id] = "BOUCLE$id($type)" . htmlspecialchars( preg_replace(",[\r\n],", "\\n", $crit)); // on synthetise avec la syntaxe standard, mais "$avant") . "" . $milieu . "" . (!$apres ? "" : "$apres") . (!$altern ? "" : "$altern"); } // http://doc.spip.org/@trouve_boucle_debug function trouve_boucle_debug($n, $nom, $debut=0, $boucle = "") { global $debug_objets; $id = $nom . $boucle; if (is_array($debug_objets['sequence'][$id])) { foreach($debug_objets['sequence'][$id] as $v) { if (!preg_match('/^(.*)(<\?.*\?>)(.*)$/s', $v[2],$r)) $y = substr_count($v[2], "\n"); else { if ($v[1][0] == '#') // balise dynamique $incl = $debug_objets['resultat'][$v[0]]; else // inclusion $incl = $debug_objets['squelette'][trouve_squelette_inclus($v[2])]; $y = substr_count($incl, "\n") + substr_count($r[1], "\n") + substr_count($r[3], "\n"); } if ($n <= ($y + $debut)) { if ($v[1][0] == '?') return trouve_boucle_debug($n, $nom, $debut, substr($v[1],1)); elseif ($v[1][0] == '!') { if ($incl = trouve_squelette_inclus($v[1])) return trouve_boucle_debug($n, $incl, $debut); } return array($nom, $boucle, $v[0] -1 + $n - $debut ); } $debut += $y; } } return array($nom, $boucle, $n-$debut); } // http://doc.spip.org/@trouve_squelette_inclus function trouve_squelette_inclus($script) { global $debug_objets; preg_match('/include\(.(.*).php3?.\);/', $script, $reg); // si le script X.php n'est pas ecrire/public.php // on suppose qu'il prend le squelette X.html (pas sur, mais y a pas mieux) if ($reg[1] == 'ecrire/public') // si c'est bien ecrire/public on cherche le param 'fond' if (!preg_match("/'fond' => '([^']*)'/", $script, $reg)) // a defaut on cherche le param 'page' if (!preg_match("/'param' => '([^']*)'/", $script, $reg)) $reg[1] = "inconnu"; $incl = $reg[1] . '.html$'; foreach($debug_objets['sourcefile'] as $k => $v) { if (preg_match(",$incl,",$v)) return $k; } return ""; } // http://doc.spip.org/@reference_boucle_debug function reference_boucle_debug($n, $nom, $self) { list($skel, $boucle, $ligne) = trouve_boucle_debug($n, $nom); if (!$boucle) return !$ligne ? "" : (" (" . (($nom != $skel) ? _T('squelette_inclus_ligne') : _T('squelette_ligne')) . " $ligne)"); else { $self .= "&var_mode_objet=$skel$boucle&var_mode_affiche=boucle"; return !$ligne ? " (boucle\n$boucle)" : " (boucle $boucle ligne\n$ligne)"; } } // affiche un texte avec numero de ligne et ancre. // http://doc.spip.org/@ancre_texte function ancre_texte($texte, $fautifs=array(), $nocpt=false) { $var_mode_ligne = _request('var_mode_ligne'); if ($var_mode_ligne) $fautifs[]= array($var_mode_ligne); $res =''; $s = highlight_string(str_replace('','',$texte),true); $s = str_replace('/@@@@@','/script', // bug de highlight_string str_replace('','', str_replace('') { $s=substr($s,6); $res = '';} $s = preg_replace(',<(\w[^<>]*)>([^<]*)
    ([^<]*),', '<\1>\2
    ' . "\n" . '<\1>\3', $s); $tableau = explode("
    ", $s); $format = "%0" . strval(@strlen(count($tableau))). "d %s
    \n"; $format10=str_replace('white','lightgrey',$format); $formaterr="color: red;"; $i=1; $flignes = array(); $loc = array(0,0); foreach ($fautifs as $lc) if (is_array($lc)) { $l = array_shift($lc); $flignes[$l] = $lc; } else $flignes[$lc] = $loc; $ancre = md5($texte); foreach ($tableau as $ligne) { if (isset($flignes[$i])) { $ligne = str_replace(' ',' ', $ligne); $indexmesg = $flignes[$i][1]; $err = textebrut($flignes[$i][2]); // tentative de pointer sur la colonne fautive; // marche pas car highlight_string rajoute des entites. A revoir. // $m = $flignes[$i][0]; // $ligne = substr($ligne, 0, $m-1) . // sprintf($formaterr, substr($ligne,$m)); $bg = $formaterr; } else {$indexmesg = $ancre; $err= $bg='';} $res .= sprintf((($i%10) ? $format :$format10), $i, $bg, $indexmesg, $err, $i, $ligne); $i++; } return "
    " .'
    ' . _T('info_numero_abbreviation') . "
    ".$res."
    \n"; } // l'environnement graphique du debuggueur // http://doc.spip.org/@debug_dumpfile function debug_dumpfile ($texte, $fonc, $type) { global $debug_objets, $spip_lang_right; $var_mode_objet = _request('var_mode_objet'); $var_mode_affiche = _request('var_mode_affiche'); $debug_objets[$type][$fonc . 'tout'] = $texte; if (!$debug_objets['sourcefile']) return; if ($texte && ($var_mode_objet != $fonc || $var_mode_affiche != $type)) return; if (!$fonc) $fonc = $debug_objets['principal']; // en cas de squelette inclus, virer le code de l'incluant: // - il contient souvent une Div restreignant la largeur a 3 fois rien // - ca fait 2 headers ! if (ob_get_length()) ob_end_clean(); $self = str_replace("\\'", ''', self()); $self = parametre_url($self,'var_mode', 'debug'); echo debug_debut($fonc); if ($var_mode_affiche !== 'validation') { foreach ($debug_objets['sourcefile'] as $nom_skel => $sourcefile) { $self2 = parametre_url($self,'var_mode_objet', $nom_skel); echo "
    ",$sourcefile," : "; echo "\n"._T('squelette').""; echo "\n"._T('zbug_resultat').""; echo "\n"._T('zbug_code').""; echo "\n", _T('zbug_calcul').""; echo "\n"._T('zbug_profile',array('time'=>$debug_objets['profile'][$sourcefile])).""; if (is_array($contexte = $debug_objets['contexte'][$sourcefile])) echo afficher_debug_contexte($contexte); $i = 0; $res = ""; if (is_array($debug_objets['pretty'])) foreach ($debug_objets['pretty'] as $nom => $pretty) if (substr($nom, 0, strlen($nom_skel)) == $nom_skel) { $i++; $aff = "<".$pretty.">"; if ($var_mode_objet == $nom) $aff = "$aff"; $color = $i%2 ? '#e0e0f0' : '#f8f8ff'; $res .= debug_affiche_navig($aff, $nom_skel, $color, $self . "&var_mode_objet=" . $nom, $i); } if ($res) echo "\n",$res,"
    \n"; echo "
    \n"; } echo "
    \n\n"; echo debug_affiche($fonc, $debug_objets, $var_mode_objet, $var_mode_affiche); } if ($texte) { $err = ""; $titre = _request('var_mode_affiche'); if ($titre != 'validation') { $titre = 'zbug_' . $titre; $texte = ancre_texte($texte, array('','')); } else { $valider = charger_fonction('valider', 'xml'); $res = $valider($texte); // Si erreur, signaler leur nombre dans le formulaire admin $debug_objets['validation'] = $res[1] ? count($res[1]):''; list($texte, $err) = emboite_texte($res, $fonc, $self); if ($err === false) $err = _T('impossible'); elseif ($err === true) $err = _T('correcte'); else $err = ": $err"; } echo "
    ", _T($titre), ' ', $err, ""; echo $texte; echo "
    "; } debug_fin(); exit; } // http://doc.spip.org/@debug_affiche_navig function debug_affiche_navig($aff, $nom_skel, $color, $self, $i) { return "\n$i\n" . "" . _T('zbug_boucle') . "\n" . _T('zbug_resultat') . "\n" . _T('zbug_code') . "\n" . _T('zbug_calcul') . "\n" . $aff . ""; } // http://doc.spip.org/@debug_affiche function debug_affiche($fonc, $tout, $objet, $affiche) { if (!$objet) {if ($affiche == 'squelette') $objet = $fonc;} if (!$objet OR !$quoi = $tout[$affiche][$objet]) return; $res = "
    "; if ($affiche == 'resultat') { $res .= "" .$tout['pretty'][$objet] .""; $req = $tout['requete'][$objet]; if (function_exists('traite_query')) { $c = _request('connect'); $c = $GLOBALS['connexions'][$c ? $c : 0]['prefixe']; $req = traite_query($req,'', $c); } $res .= ancre_texte($req, array(), true); // formatage et affichage des resultats bruts de la requete $ress_req = spip_query($req); $brut_sql = ''; $num = 1; // eviter l'affichage de milliers de lignes // personnalisation possible dans mes_options $max_aff = defined('_MAX_DEBUG_AFF') ? _MAX_DEBUG_AFF : 50; while ($retours_sql = sql_fetch($ress_req)) { if ($num <= $max_aff) { $brut_sql .= "

    " .($num == 1 ? $num. " sur " .sql_count($ress_req):$num). "

    "; $brut_sql .= "

    "; foreach ($retours_sql as $key => $val) { $brut_sql .= "" .$key. " => " .htmlspecialchars(couper($val, 150)). "
    \n"; } $brut_sql .= "

    "; } $num++; } $res .= interdire_scripts($brut_sql); foreach ($quoi as $view) { // ne pas afficher les $contexte_inclus $view = preg_replace(",<\?php.+\?[>],Uims", "", $view); if ($view) { $res .= "\n
    " .interdire_scripts($view). "
    "; } } } else if ($affiche == 'code') { $res .= "" .$tout['pretty'][$objet] .""; $res .= ancre_texte("<"."?php\n".$quoi."\n?".">"); } else if ($affiche == 'boucle') { $res .= "" .$tout['pretty'][$objet] .""; $res .= ancre_texte($quoi); } else if ($affiche == 'squelette') { $res .= "" .$tout['sourcefile'][$objet] .""; $res .= ancre_texte($tout['squelette'][$objet]); } $res .= "
    "; return $res; } // http://doc.spip.org/@debug_debut function debug_debut($titre) { global $visiteur_session; include_spip('inc/headers'); include_spip('inc/filtres'); http_no_cache(); lang_select($visiteur_session['lang']); return _DOCTYPE_ECRIRE . html_lang_attributes() . "\n" . ('SPIP ' . $GLOBALS['spip_version_affichee'] . ' ' . _T('admin_debug') . ' ' . $titre . ' (' . supprimer_tags(extraire_multi($GLOBALS['meta']['nom_site']))) . ")\n" . "\n" . http_script('', 'jquery.js') . "" . "\n" . "\n
    \n"; } // http://doc.spip.org/@debug_fin function debug_fin() { global $debug_objets; echo "\n
    "; include_spip('balise/formulaire_admin'); echo inclure_balise_dynamique( balise_FORMULAIRE_ADMIN_dyn('spip-admin-float', $debug_objets) ); echo ''; } // http://doc.spip.org/@emboite_texte function emboite_texte($res, $fonc='',$self='') { list($texte, $errs) = $res; if (!$texte) return array(ancre_texte('', array('','')), false); if (!$errs) return array(ancre_texte($texte, array('', '')), true); if (!isset($GLOBALS['debug_objets'])) { $colors = array('#e0e0f0', '#f8f8ff'); $encore = count_occ($errs); $encore2 = array(); $fautifs = array(); $err = '' . _T('numero') . "" . _T('occurrence') . "" . _T('ligne') . "" . _T('colonne') . "" . _T('erreur') . ""; $i = 0; foreach($errs as $r) { $i++; list($msg, $ligne, $col) = $r; spip_log("$r = list($msg, $ligne, $col"); if (isset($encore2[$msg])) $ref = ++$encore2[$msg]; else {$encore2[$msg] = $ref = 1;} $err .= "" . $i . "" . "$ref/$encore[$msg]" . "" . $ligne . "" . $col . "$msg\n"; $fautifs[]= array($ligne, $col, $i, $msg); } $err = "

    " . $i . "" . " "._T('erreur_texte') . "

    " . $err . "
    "; return array(ancre_texte($texte, $fautifs), $err); } else { list($msg, $fermant, $ouvrant) = $errs[0]; $rf = reference_boucle_debug($fermant, $fonc, $self); $ro = reference_boucle_debug($ouvrant, $fonc, $self); $err = $msg . "$fermant$rf
    " . "$ouvrant$ro"; return array(ancre_texte($texte, array(array($ouvrant), array($fermant))), $err); } } // http://doc.spip.org/@count_occ function count_occ($regs) { $encore = array(); foreach($regs as $r) { if (isset($encore[$r[0]])) $encore[$r[0]]++; else $encore[$r[0]] = 1; } return $encore; } // http://doc.spip.org/@trace_query_start function trace_query_start() { static $trace = '?'; if ($trace === '?') { include_spip('inc/autoriser'); // gare au bouclage sur calcul de droits au premier appel // A fortiori quand on demande une trace $trace = isset($_GET['var_profile']) AND (autoriser('debug')); } return $trace ? microtime() : 0; } // http://doc.spip.org/@trace_query_end function trace_query_end($query, $start, $result, $err, $serveur='') { global $tableau_des_erreurs; if ($start) trace_query_chrono($start, microtime(), $query, $result, $serveur); if (!($err = sql_errno())) return $result; $err .= ' '.sql_error(); if (autoriser('voirstats')) { include_spip('public/debug'); $tableau_des_erreurs[] = array( _T('info_erreur_requete'). " " . htmlentities($query), "« " . htmlentities($err)," »"); } return $result; } // http://doc.spip.org/@trace_query_chrono function trace_query_chrono($m1, $m2, $query, $result, $serveur='') { static $tt = 0, $nb=0; global $tableau_des_temps; $x = _request('var_mode_objet'); if (isset($GLOBALS['debug']['aucasou'])) { list(, $boucle, $serveur) = $GLOBALS['debug']['aucasou']; if ($x AND !preg_match("/$boucle\$/", $x)) return; if ($serveur) $boucle .= " ($serveur)"; $boucle = "$boucle"; } else { if ($x) return; $boucle = ''; } list($usec, $sec) = explode(" ", $m1); list($usec2, $sec2) = explode(" ", $m2); $dt = $sec2 + $usec2 - $sec - $usec; $tt += $dt; $nb++; $q = preg_replace('/([a-z)`])\s+([A-Z])/', '$1
    $2',htmlentities($query)); $e = sql_explain($query, $serveur); $r = str_replace('Resource id ','',(is_object($result)?get_class($result):$result)); $tableau_des_temps[] = array($dt, $nb, $boucle, $q, $e, $r); } ?> spip/spip/ecrire/public/boucles.php0000766000000000000000000002475211236524730020605 0ustar adminadministrators boucle dite recursive // // http://doc.spip.org/@boucle_BOUCLE_dist function boucle_BOUCLE_dist($id_boucle, &$boucles) { return calculer_boucle($id_boucle, $boucles); } // // // // http://doc.spip.org/@boucle_ARTICLES_dist function boucle_ARTICLES_dist($id_boucle, &$boucles) { $boucle = &$boucles[$id_boucle]; $id_table = $boucle->id_table; $mstatut = $id_table .'.statut'; // Restreindre aux elements publies if (!isset($boucle->modificateur['criteres']['statut'])) { if (!$GLOBALS['var_preview']) { if ($GLOBALS['meta']["post_dates"] == 'non') array_unshift($boucle->where,array("'<'", "'$id_table" . ".date'", "sql_quote(quete_date_postdates())")); array_unshift($boucle->where,array("'='", "'$mstatut'", "'\\'publie\\''")); } else array_unshift($boucle->where,array("'IN'", "'$mstatut'", "'(\\'publie\\',\\'prop\\')'")); } return calculer_boucle($id_boucle, $boucles); } // // // // http://doc.spip.org/@boucle_AUTEURS_dist function boucle_AUTEURS_dist($id_boucle, &$boucles) { $boucle = &$boucles[$id_boucle]; $id_table = $boucle->id_table; $mstatut = $id_table .'.statut'; // Restreindre aux elements publies if (!isset($boucle->modificateur['criteres']['statut'])) { // Si pas de lien avec un article, selectionner // uniquement les auteurs d'un article publie if (!$GLOBALS['var_preview']) if (!isset($boucle->modificateur['lien']) AND !isset($boucle->modificateur['tout'])) { fabrique_jointures($boucle, array( array($id_table, array('spip_auteurs_articles'), 'id_auteur'), array('', array('spip_articles'), 'id_article')), true, $boucle->show, $id_table); $t = array_search('spip_articles', $boucle->from); array_unshift($boucle->where, array("'='", "'$t.statut'", "'\\'publie\\''")); if ($GLOBALS['meta']['post_dates'] == 'non') array_unshift($boucle->where, array("'<='", "'$t.date'", "sql_quote(quete_date_postdates())")); } // pas d'auteurs poubellises array_unshift($boucle->where,array("'!='", "'$mstatut'", "'\\'5poubelle\\''")); } return calculer_boucle($id_boucle, $boucles); } // // // // http://doc.spip.org/@boucle_BREVES_dist function boucle_BREVES_dist($id_boucle, &$boucles) { $boucle = &$boucles[$id_boucle]; $id_table = $boucle->id_table; $mstatut = $id_table .'.statut'; // Restreindre aux elements publies if (!isset($boucle->modificateur['criteres']['statut'])) { if (!$GLOBALS['var_preview']) array_unshift($boucle->where,array("'='", "'$mstatut'", "'\\'publie\\''")); else array_unshift($boucle->where,array("'IN'", "'$mstatut'", "'(\\'publie\\',\\'prop\\')'")); } return calculer_boucle($id_boucle, $boucles); } // // // // http://doc.spip.org/@boucle_FORUMS_dist function boucle_FORUMS_dist($id_boucle, &$boucles) { $boucle = &$boucles[$id_boucle]; $id_table = $boucle->id_table; $mstatut = $id_table .'.statut'; // Par defaut, selectionner uniquement les forums sans mere // Les criteres {tout} et {plat} inversent ce choix if (!isset($boucle->modificateur['tout']) AND !isset($boucle->modificateur['plat'])) { array_unshift($boucle->where,array("'='", "'$id_table." ."id_parent'", 0)); } // Restreindre aux elements publies if (!$boucle->modificateur['criteres']['statut']) { if ($GLOBALS['var_preview']) array_unshift($boucle->where,array("'IN'", "'$mstatut'", "'(\\'publie\\',\\'prive\\')'")); else array_unshift($boucle->where,array("'='", "'$mstatut'", "'\\'publie\\''")); } return calculer_boucle($id_boucle, $boucles); } // // // // http://doc.spip.org/@boucle_SIGNATURES_dist function boucle_SIGNATURES_dist($id_boucle, &$boucles) { $boucle = &$boucles[$id_boucle]; $id_table = $boucle->id_table; $mstatut = $id_table .'.statut'; // Restreindre aux elements publies if (!isset($boucle->modificateur['criteres']['statut']) AND !isset($boucle->modificateur['tout'])) { array_unshift($boucle->where,array("'='", "'$mstatut'", "'\\'publie\\''")); } return calculer_boucle($id_boucle, $boucles); } // // // // http://doc.spip.org/@boucle_DOCUMENTS_dist function boucle_DOCUMENTS_dist($id_boucle, &$boucles) { $boucle = &$boucles[$id_boucle]; $id_table = $boucle->id_table; // on ne veut pas des fichiers de taille nulle, // sauf s'ils sont distants (taille inconnue) array_unshift($boucle->where,array("'($id_table.taille > 0 OR $id_table.distant=\\'oui\\')'")); // Supprimer les vignettes if (!$boucle->modificateur['criteres']['mode'] AND !$boucle->modificateur['criteres']['tout']) { array_unshift($boucle->where,array("'!='", "'$id_table.mode'", "'\\'vignette\\''")); } // Pour une boucle generique (DOCUMENTS) sans critere de lien, verifier // qu notre document est lie a un element publie // (le critere {tout} permet de les afficher tous quand meme) // S'il y a un critere de lien {id_article} par exemple, on zappe // ces complications (et tant pis si la boucle n'a pas prevu de // verification du statut de l'article) if (!$boucle->modificateur['tout'] AND !$boucle->modificateur['criteres']['id_objet'] ) { # Espace avant LEFT JOIN indispensable pour insertion de AS # a refaire plus proprement ## la boucle par defaut ignore les documents de forum $boucle->from[$id_table] = "spip_documents LEFT JOIN spip_documents_liens AS l ON $id_table.id_document=l.id_document LEFT JOIN spip_articles AS aa ON (l.id_objet=aa.id_article AND l.objet=\'article\') LEFT JOIN spip_breves AS bb ON (l.id_objet=bb.id_breve AND l.objet=\'breve\') LEFT JOIN spip_rubriques AS rr ON (l.id_objet=rr.id_rubrique AND l.objet=\'rubrique\') LEFT JOIN spip_forum AS ff ON (l.id_objet=ff.id_forum AND l.objet=\'forum\') "; $boucle->group[] = "$id_table.id_document"; if ($GLOBALS['var_preview']) { array_unshift($boucle->where,"'(aa.statut IN (\'publie\',\'prop\') OR bb.statut IN (\'publie\',\'prop\') OR rr.statut IN (\'publie\',\'prive\') OR ff.statut IN (\'publie\',\'prop\'))'"); } else { $postdates = ($GLOBALS['meta']['post_dates'] == 'non') ? ' AND aa.date<=\'.sql_quote(quete_date_postdates()).\'' : ''; array_unshift($boucle->where,"'((aa.statut = \'publie\'$postdates) OR bb.statut = \'publie\' OR rr.statut = \'publie\' OR ff.statut=\'publie\')'"); } } return calculer_boucle($id_boucle, $boucles); } // // // // http://doc.spip.org/@boucle_RUBRIQUES_dist function boucle_RUBRIQUES_dist($id_boucle, &$boucles) { $boucle = &$boucles[$id_boucle]; $id_table = $boucle->id_table; $mstatut = $id_table .'.statut'; // Restreindre aux elements publies if (!isset($boucle->modificateur['criteres']['statut'])) { if (!$GLOBALS['var_preview']) if (!isset($boucle->modificateur['tout'])) array_unshift($boucle->where,array("'='", "'$mstatut'", "'\\'publie\\''")); } return calculer_boucle($id_boucle, $boucles); } // // // // http://doc.spip.org/@boucle_HIERARCHIE_dist function boucle_HIERARCHIE_dist($id_boucle, &$boucles) { $boucle = &$boucles[$id_boucle]; $id_table = $boucle->id_table . ".id_rubrique"; // Si la boucle mere est une boucle RUBRIQUES il faut ignorer la feuille // sauf en presence du critere {tout} (vu par phraser_html) $boucle->hierarchie = 'if (!($id_rubrique = intval(' . calculer_argument_precedent($boucle->id_boucle, 'id_rubrique', $boucles) . ")))\n\t\treturn '';\n\t" . '$hierarchie = ' . (isset($boucle->modificateur['tout']) ? '",$id_rubrique"' : "''") . ";\n\t" . 'while ($id_rubrique = sql_getfetsel("id_parent","spip_rubriques","id_rubrique=" . $id_rubrique,"","","", "", $connect)) { $hierarchie = ",$id_rubrique$hierarchie"; } if (!$hierarchie) return ""; $hierarchie = substr($hierarchie,1);'; $boucle->where[]= array("'IN'", "'$id_table'", '"($hierarchie)"'); $order = "FIELD($id_table, \$hierarchie)"; if ($boucle->default_order[0] != " DESC") $boucle->default_order[] = "\"$order\""; else $boucle->default_order[0] = "\"$order DESC\""; return calculer_boucle($id_boucle, $boucles); } // // // // http://doc.spip.org/@boucle_SYNDICATION_dist function boucle_SYNDICATION_dist($id_boucle, &$boucles) { $boucle = &$boucles[$id_boucle]; $id_table = $boucle->id_table; $mstatut = $id_table .'.statut'; // Restreindre aux elements publies if (!isset($boucle->modificateur['criteres']['statut'])) { if (!$GLOBALS['var_preview']) { array_unshift($boucle->where,array("'='", "'$mstatut'", "'\\'publie\\''")); } else array_unshift($boucle->where,array("'IN'", "'$mstatut'", "'(\\'publie\\',\\'prop\\')'")); } return calculer_boucle($id_boucle, $boucles); } // // // // http://doc.spip.org/@boucle_SYNDIC_ARTICLES_dist function boucle_SYNDIC_ARTICLES_dist($id_boucle, &$boucles) { $boucle = &$boucles[$id_boucle]; $id_table = $boucle->id_table; $mstatut = $id_table .'.statut'; // Restreindre aux elements publies, sauf critere contraire if ($boucle->modificateur['criteres']['statut']) {} else if ($GLOBALS['var_preview']) array_unshift($boucle->where,array("'IN'", "'$mstatut'", "'(\\'publie\\',\\'prop\\')'")); else { $jointure = array_search("spip_syndic", $boucle->from); if (!$jointure) { fabrique_jointures($boucle, array(array($id_table, array('spip_syndic'), 'id_syndic')), true, $boucle->show, $id_table); $jointure = array_search('spip_syndic', $boucle->from); } array_unshift($boucle->where,array("'='", "'$mstatut'", "'\\'publie\\''")); $boucle->where[]= array("'='", "'$jointure" . ".statut'", "'\\'publie\\''"); } return calculer_boucle($id_boucle, $boucles); } ?> spip/spip/ecrire/base/0000777000000000000000000000000011266531716016066 5ustar adminadministratorsspip/spip/ecrire/base/convert_utf8.php0000766000000000000000000001204711236524730021225 0ustar adminadministrators $champ) { spip_log("demande update charset table $table ($champ)"); spip_query("UPDATE $table SET $champ = CONCAT('', $champ) WHERE $champ NOT LIKE ' $v) { $v2 = unicode_to_utf_8(charset2unicode($v, $charset_source)); if ($v2 != $v) ecrire_meta($c, $v2); } } // http://doc.spip.org/@base_convert_utf8_dist function base_convert_utf8_dist($titre='', $reprise=false) { if (!$titre) return; // anti-testeur automatique // une liste des tables a convertir, avec le champ dans lequel on // indique '' ; on commence par les rubriques sinon // ca fait desordre dans l'interface privee $tables_a_convertir = array( 'spip_rubriques' => 'titre', 'spip_auteurs' => 'nom', 'spip_articles' => 'titre', 'spip_breves' => 'titre', 'spip_documents' => 'titre', 'spip_forum' => 'titre', 'spip_mots' => 'titre', 'spip_groupes_mots' => 'titre', 'spip_petitions' => 'texte', 'spip_signatures' => 'nom_email', 'spip_syndic' => 'nom_site', 'spip_syndic_articles' => 'titre', 'spip_messages' => 'titre' ); if (!$reprise) convert_utf8_init($tables_a_convertir); echo install_debut_html($titre); echo "

    ", _T('utf8_convert_timeout'), "


    \n"; // preparer un fichier de sauvegarde au cas ou // on met 'a' car ca peut demander plusieurs rechargements $f = @fopen(_DIR_TMP.'convert_utf8_backup.sql', 'a'); foreach ($tables_a_convertir as $table => $champ) { convert_table_utf8($f, $table, $champ); } if ($f) fclose($f); echo "

    "._T('utf8_convert_termine')."

    "; echo "

    ,"._T('utf8_convert_verifier', array('rep' => joli_repertoire(_DIR_TMP))), '

    '; // bouton "retour au site" + redirige_par_entete echo "

    ", " >> ", _T('icone_retour'),"

    ", install_fin_html(); } // http://doc.spip.org/@convert_table_utf8 function convert_table_utf8($f, $table, $champ) { echo "
    $table   "; $s = spip_query("SELECT * FROM $table WHERE $champ LIKE ' $v) { if ($c == $champ) { preg_match(',^,', $v, $reg); $v = substr($v, strlen($reg[0])); $charset_source = $reg[1]; $query[] = "$c=" . sql_quote($v); } else { if (!is_numeric($v) AND !is_ascii($v)) { // traitement special car donnees serializees if ($c == 'extra') { $query_no_convert .= ", $c=".sql_quote($v); $query_extra = convert_extra($v, $charset_source); } else $query[] = "$c=" . sql_quote($v); } else # pour le backup $query_no_convert .= ", $c=".sql_quote($v); } } $set = join(', ', $query); $where = "$id_champ = ".$t[$id_champ]; // On l'enregistre telle quelle sur le fichier de sauvegarde if ($f) fwrite($f, "UPDATE $table SET $set$query_no_convert" ." WHERE $where;\n" ); // Mais on la transcode // en evitant une double conversion if ($charset_source != 'utf-8') { $query = "UPDATE $table SET " . unicode_to_utf_8(charset2unicode($set, $charset_source)) . $query_extra . " WHERE $where AND $champ LIKE '$val) $extra[$key] = unicode_to_utf_8( charset2unicode($val, $charset_source)); return ", extra=".sql_quote(serialize($extra)); } } ?> spip/spip/ecrire/base/serial.php0000766000000000000000000003547611236524730020071 0ustar adminadministrators "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", "extra" => "longtext NULL", "id_version" => "int unsigned DEFAULT '0' NOT NULL", "nom_site" => "tinytext DEFAULT '' NOT NULL", "url_site" => "VARCHAR(255) DEFAULT '' NOT NULL", # "url_propre" => "VARCHAR(255) DEFAULT '' NOT NULL" ); $spip_articles_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", # "KEY url_propre" => "url_propre" ); $spip_articles_join = array( "id_article"=>"id_article", "id_rubrique"=>"id_rubrique"); $spip_auteurs = 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", "maj" => "TIMESTAMP", "pgp" => "TEXT DEFAULT '' NOT NULL", "htpass" => "tinytext DEFAULT '' NOT NULL", "en_ligne" => "datetime DEFAULT '0000-00-00 00:00:00' NOT NULL", "imessage" => "VARCHAR(3)", "messagerie" => "VARCHAR(3)", "alea_actuel" => "tinytext", "alea_futur" => "tinytext", "prefs" => "tinytext", "cookie_oubli" => "tinytext", "source" => "VARCHAR(10) DEFAULT 'spip' NOT NULL", "lang" => "VARCHAR(10) DEFAULT '' NOT NULL", # "url_propre" => "VARCHAR(255)", "extra" => "longtext NULL"); $spip_auteurs_key = array( "PRIMARY KEY" => "id_auteur", "KEY login" => "login", "KEY statut" => "statut", "KEY en_ligne" => "en_ligne", # "KEY url_propre" => "url_propre" ); $spip_auteurs_join = array( "id_auteur"=>"id_auteur", "login"=>"login"); $spip_breves = array( "id_breve" => "bigint(21) NOT NULL", "date_heure" => "datetime DEFAULT '0000-00-00 00:00:00' NOT NULL", "titre" => "text DEFAULT '' NOT NULL", "texte" => "longtext DEFAULT '' NOT NULL", "lien_titre" => "text DEFAULT '' NOT NULL", "lien_url" => "text DEFAULT '' NOT NULL", "statut" => "varchar(6) DEFAULT '0' NOT NULL", "id_rubrique" => "bigint(21) DEFAULT '0' NOT NULL", "lang" => "VARCHAR(10) DEFAULT '' NOT NULL", "langue_choisie" => "VARCHAR(3) DEFAULT 'non'", "maj" => "TIMESTAMP", "extra" => "longtext NULL", # "url_propre" => "VARCHAR(255) DEFAULT '' NOT NULL" ); $spip_breves_key = array( "PRIMARY KEY" => "id_breve", "KEY id_rubrique" => "id_rubrique", # "KEY url_propre" => "url_propre" ); $spip_breves_join = array( "id_breve"=>"id_breve", "id_rubrique"=>"id_rubrique"); $spip_messages = array( "id_message" => "bigint(21) NOT NULL", "titre" => "text DEFAULT '' NOT NULL", "texte" => "longtext DEFAULT '' NOT NULL", "type" => "varchar(6) DEFAULT '' NOT NULL", "date_heure" => "datetime DEFAULT '0000-00-00 00:00:00' NOT NULL", "date_fin" => "datetime DEFAULT '0000-00-00 00:00:00' NOT NULL", "rv" => "varchar(3) DEFAULT '' NOT NULL", "statut" => "varchar(6) DEFAULT '0' NOT NULL", "id_auteur" => "bigint(21) NOT NULL", "maj" => "TIMESTAMP"); $spip_messages_key = array( "PRIMARY KEY" => "id_message", "KEY id_auteur" => "id_auteur"); $spip_mots = array( "id_mot" => "bigint(21) NOT NULL", "titre" => "text DEFAULT '' NOT NULL", "descriptif" => "text DEFAULT '' NOT NULL", "texte" => "longtext DEFAULT '' NOT NULL", "id_groupe" => "bigint(21) DEFAULT 0 NOT NULL", "type" => "text DEFAULT '' NOT NULL", "extra" => "longtext NULL", # "url_propre" => "VARCHAR(255) DEFAULT '' NOT NULL", "maj" => "TIMESTAMP"); $spip_mots_key = array( "PRIMARY KEY" => "id_mot", # "KEY url_propre" => "url_propre" ); $spip_groupes_mots = array( "id_groupe" => "bigint(21) NOT NULL", "titre" => "text DEFAULT '' NOT NULL", "descriptif" => "text DEFAULT '' NOT NULL", "texte" => "longtext DEFAULT '' NOT NULL", "unseul" => "varchar(3) DEFAULT '' NOT NULL", "obligatoire" => "varchar(3) DEFAULT '' NOT NULL", "tables_liees" => "text DEFAULT '' NOT NULL", # suppression des champs a faire dans la maj #"articles" => "varchar(3) DEFAULT '' NOT NULL", #"breves" => "varchar(3) DEFAULT '' NOT NULL", #"rubriques" => "varchar(3) DEFAULT '' NOT NULL", #"syndic" => "varchar(3) DEFAULT '' NOT NULL", "minirezo" => "varchar(3) DEFAULT '' NOT NULL", "comite" => "varchar(3) DEFAULT '' NOT NULL", "forum" => "varchar(3) DEFAULT '' NOT NULL", "maj" => "TIMESTAMP"); $spip_groupes_mots_key = array( "PRIMARY KEY" => "id_groupe"); $spip_rubriques = 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", "export" => "VARCHAR(10) DEFAULT 'oui'", "id_import" => "bigint DEFAULT '0'", "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'", "extra" => "longtext NULL", # "url_propre" => "VARCHAR(255) DEFAULT '' NOT NULL", "statut_tmp" => "varchar(10) DEFAULT '0' NOT NULL", "date_tmp" => "datetime DEFAULT '0000-00-00 00:00:00' NOT NULL" ); $spip_rubriques_key = array( "PRIMARY KEY" => "id_rubrique", "KEY lang" => "lang", "KEY id_parent" => "id_parent", # "KEY url_propre" => "url_propre" ); $spip_documents = array( "id_document" => "bigint(21) NOT NULL", "id_vignette" => "bigint(21) DEFAULT '0' NOT NULL", "extension" => "VARCHAR(10) DEFAULT '' NOT NULL", "titre" => "text DEFAULT '' NOT NULL", "date" => "datetime DEFAULT '0000-00-00 00:00:00' NOT NULL", "descriptif" => "text DEFAULT '' NOT NULL", "fichier" => "varchar(255) DEFAULT '' NOT NULL", "taille" => "integer", "largeur" => "integer", "hauteur" => "integer", "mode" => "ENUM('vignette', 'image', 'document') DEFAULT 'document' NOT NULL", "distant" => "VARCHAR(3) DEFAULT 'non'", "maj" => "TIMESTAMP"); $spip_documents_key = array( "PRIMARY KEY" => "id_document", "KEY id_vignette" => "id_vignette", "KEY mode" => "mode", "KEY extension" => "extension"); $spip_documents_join = array( "id_document"=>"id_document", "extension"=>"extension"); $spip_types_documents = array( "extension" => "varchar(10) DEFAULT '' NOT NULL", "titre" => "text DEFAULT '' NOT NULL", "descriptif" => "text DEFAULT '' NOT NULL", "mime_type" => "varchar(100) DEFAULT '' NOT NULL", "inclus" => "ENUM('non', 'image', 'embed') NOT NULL DEFAULT 'non'", "upload" => "ENUM('oui', 'non') NOT NULL DEFAULT 'oui'", "maj" => "TIMESTAMP"); $spip_types_documents_key = array( "PRIMARY KEY" => "extension", "KEY inclus" => "inclus"); $spip_syndic = array( "id_syndic" => "bigint(21) NOT NULL", "id_rubrique" => "bigint(21) DEFAULT '0' NOT NULL", "id_secteur" => "bigint(21) DEFAULT '0' NOT NULL", "nom_site" => "text DEFAULT '' NOT NULL", "url_site" => "text DEFAULT '' NOT NULL", "url_syndic" => "text DEFAULT '' NOT NULL", "descriptif" => "text DEFAULT '' NOT NULL", # "url_propre" => "VARCHAR(255) DEFAULT '' NOT NULL", "maj" => "TIMESTAMP", "syndication" => "VARCHAR(3) DEFAULT '' NOT NULL", "statut" => "varchar(10) DEFAULT '0' NOT NULL", "date" => "datetime DEFAULT '0000-00-00 00:00:00' NOT NULL", "date_syndic" => "datetime DEFAULT '0000-00-00 00:00:00' NOT NULL", "date_index" => "datetime DEFAULT '0000-00-00 00:00:00' NOT NULL", "extra" => "longtext NULL", "moderation" => "VARCHAR(3) DEFAULT 'non'", "miroir" => "VARCHAR(3) DEFAULT 'non'", "oubli" => "VARCHAR(3) DEFAULT 'non'", "resume" => "VARCHAR(3) DEFAULT 'oui'" ); $spip_syndic_key = array( "PRIMARY KEY" => "id_syndic", "KEY id_rubrique" => "id_rubrique", "KEY id_secteur" => "id_secteur", "KEY statut" => "statut, date_syndic", # "KEY url_propre" => "url_propre" ); $spip_syndic_join = array( "id_syndic"=>"id_syndic", "id_rubrique"=>"id_rubrique"); $spip_syndic_articles = array( "id_syndic_article" => "bigint(21) NOT NULL", "id_syndic" => "bigint(21) DEFAULT '0' NOT NULL", "titre" => "text DEFAULT '' NOT NULL", "url" => "VARCHAR(255) DEFAULT '' NOT NULL", "date" => "datetime DEFAULT '0000-00-00 00:00:00' NOT NULL", "lesauteurs" => "text DEFAULT '' NOT NULL", "maj" => "TIMESTAMP", "statut" => "varchar(10) DEFAULT '0' NOT NULL", "descriptif" => "text DEFAULT '' NOT NULL", "lang" => "VARCHAR(10) DEFAULT '' NOT NULL", "url_source" => "TINYTEXT DEFAULT '' NOT NULL", "source" => "TINYTEXT DEFAULT '' NOT NULL", "tags" => "TEXT DEFAULT '' NOT NULL"); $spip_syndic_articles_key = array( "PRIMARY KEY" => "id_syndic_article", "KEY id_syndic" => "id_syndic", "KEY statut" => "statut", "KEY url" => "url"); $spip_syndic_articles_join = array( "id_syndic_article"=>"id_syndic_article", "id_syndic"=>"id_syndic"); $spip_forum = array( "id_forum" => "bigint(21) NOT NULL", "id_parent" => "bigint(21) DEFAULT '0' NOT NULL", "id_thread" => "bigint(21) DEFAULT '0' NOT NULL", "id_rubrique" => "bigint(21) DEFAULT '0' NOT NULL", "id_article" => "bigint(21) DEFAULT '0' NOT NULL", "id_breve" => "bigint(21) DEFAULT '0' NOT NULL", "date_heure" => "datetime DEFAULT '0000-00-00 00:00:00' NOT NULL", "date_thread" => "datetime DEFAULT '0000-00-00 00:00:00' NOT NULL", "titre" => "text DEFAULT '' NOT NULL", "texte" => "mediumtext DEFAULT '' NOT NULL", "auteur" => "text DEFAULT '' NOT NULL", "email_auteur" => "text DEFAULT '' NOT NULL", "nom_site" => "text DEFAULT '' NOT NULL", "url_site" => "text DEFAULT '' NOT NULL", "statut" => "varchar(8) DEFAULT '0' NOT NULL", "ip" => "varchar(16) DEFAULT '' NOT NULL", "maj" => "TIMESTAMP", "id_auteur" => "bigint DEFAULT '0' NOT NULL", "id_message" => "bigint(21) DEFAULT '0' NOT NULL", "id_syndic" => "bigint(21) DEFAULT '0' NOT NULL"); $spip_forum_key = array( "PRIMARY KEY" => "id_forum", "KEY id_auteur" => "id_auteur", "KEY id_parent" => "id_parent", "KEY id_thread" => "id_thread", "KEY optimal" => "statut,id_parent,id_article,date_heure,id_breve,id_syndic,id_rubrique"); $spip_forum_join = array( "id_forum"=>"id_forum", "id_parent"=>"id_parent", "id_article"=>"id_article", "id_breve"=>"id_breve", "id_message"=>"id_message", "id_syndic"=>"id_syndic", "id_rubrique"=>"id_rubrique"); $spip_signatures = array( "id_signature" => "bigint(21) NOT NULL", "id_article" => "bigint(21) DEFAULT '0' NOT NULL", "date_time" => "datetime DEFAULT '0000-00-00 00:00:00' NOT NULL", "nom_email" => "text DEFAULT '' NOT NULL", "ad_email" => "text DEFAULT '' NOT NULL", "nom_site" => "text DEFAULT '' NOT NULL", "url_site" => "text DEFAULT '' NOT NULL", "message" => "mediumtext DEFAULT '' NOT NULL", "statut" => "varchar(10) DEFAULT '0' NOT NULL", "maj" => "TIMESTAMP"); $spip_signatures_key = array( "PRIMARY KEY" => "id_signature", "KEY id_article" => "id_article", "KEY statut" => "statut"); $spip_signatures_join = array( "id_signature"=>"id_signature", "id_article"=>"id_article"); /// Attention: mes_fonctions peut avoir deja defini cette variable /// il faut donc rajouter, mais pas reinitialiser $tables_principales['spip_articles'] = array('field' => &$spip_articles, 'key' => &$spip_articles_key, 'join' => &$spip_articles_join); $tables_principales['spip_auteurs'] = array('field' => &$spip_auteurs, 'key' => &$spip_auteurs_key,'join' => &$spip_auteurs_join); $tables_principales['spip_breves'] = array('field' => &$spip_breves, 'key' => &$spip_breves_key,'join' => &$spip_breves_join); $tables_principales['spip_messages'] = array('field' => &$spip_messages, 'key' => &$spip_messages_key); $tables_principales['spip_mots'] = array('field' => &$spip_mots, 'key' => &$spip_mots_key); $tables_principales['spip_groupes_mots'] = array('field' => &$spip_groupes_mots, 'key' => &$spip_groupes_mots_key); $tables_principales['spip_rubriques'] = array('field' => &$spip_rubriques, 'key' => &$spip_rubriques_key); $tables_principales['spip_documents'] = array('field' => &$spip_documents, 'key' => &$spip_documents_key, 'join' => &$spip_documents_join); $tables_principales['spip_types_documents'] = array('field' => &$spip_types_documents, 'key' => &$spip_types_documents_key); $tables_principales['spip_syndic'] = array('field' => &$spip_syndic, 'key' => &$spip_syndic_key, 'join' => &$spip_syndic_join); $tables_principales['spip_syndic_articles'] = array('field' => &$spip_syndic_articles, 'key' => &$spip_syndic_articles_key, 'join' => &$spip_syndic_articles_join); $tables_principales['spip_forum'] = array('field' => &$spip_forum, 'key' => &$spip_forum_key, 'join' => &$spip_forum_join); $tables_principales['spip_signatures'] = array('field' => &$spip_signatures, 'key' => &$spip_signatures_key, 'join' => &$spip_signatures_join); $tables_principales = pipeline('declarer_tables_principales',$tables_principales); } global $tables_principales; base_serial($tables_principales); ?> spip/spip/ecrire/base/trouver_table.php0000766000000000000000000001126411236524730021454 0ustar adminadministrators spip/spip/ecrire/base/connect_sql.php0000766000000000000000000002614711236524730021115 0ustar adminadministrators $GLOBALS['ldap_link'], 'base' => $GLOBALS['ldap_base']); } return $connexion['ldap']; } // 1 interface de abstract_sql a demenager dans base/abstract_sql a terme // http://doc.spip.org/@_q function _q ($a) { return (is_numeric($a)) ? strval($a) : (!is_array($a) ? ("'" . addslashes($a) . "'") : join(",", array_map('_q', $a))); } // Nommage bizarre des tables d'objets // http://doc.spip.org/@table_objet function table_objet($type) { static $surnoms = null; if (!$surnoms){ // passer dans un pipeline qui permet aux plugins de declarer leurs exceptions $surnoms = pipeline('declarer_tables_objets_surnoms', array( 'article' => 'articles', 'auteur' => 'auteurs', 'breve' => 'breves', 'document' => 'documents', 'doc' => 'documents', # pour les modeles 'img' => 'documents', 'emb' => 'documents', 'forum' => 'forums', # hum hum redevient spip_forum par table_objet_sql mais casse par un bete "spip_".table_objet() 'groupe_mots' => 'groupes_mots', # hum 'groupe_mot' => 'groupes_mots', # hum 'groupe' => 'groupes_mots', # hum (EXPOSE) 'message' => 'messages', 'mot' => 'mots', 'petition' => 'petitions', 'rubrique' => 'rubriques', 'signature' => 'signatures', 'syndic' => 'syndic', 'site' => 'syndic', # hum hum 'syndic_article' => 'syndic_articles', 'type_document' => 'types_documents', # hum 'extension' => 'types_documents' # hum )); } return isset($surnoms[$type]) ? $surnoms[$type] : preg_replace(',ss$,', 's', $type."s"); } // http://doc.spip.org/@table_objet_sql function table_objet_sql($type) { global $table_des_tables; $nom = table_objet($type); include_spip('public/interfaces'); if (isset($table_des_tables[$nom])) { $t = $table_des_tables[$nom]; $nom = 'spip_' . $t; } return $nom ; } // http://doc.spip.org/@id_table_objet function id_table_objet($type,$serveur='') { $type = preg_replace(',^spip_|s$,', '', $type); if ($type == 'forum') return 'id_forum'; else if ($type == 'type') return 'extension'; else { if (!$type) return; $t = table_objet($type); $trouver_table = charger_fonction('trouver_table', 'base'); $desc = $trouver_table($t,$serveur); return @$desc['key']["PRIMARY KEY"]; } } // http://doc.spip.org/@objet_type function objet_type($table_objet){ // scenario de base // le type est decline a partir du nom de la table en enlevant le prefixe eventuel // et la marque du pluriel $type = preg_replace(',^spip_|s$,', '', $table_objet); // si le type redonne bien la table c'est bon if ( (table_objet($type)==$table_objet) OR (table_objet_sql($type)==$table_objet)) 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'); if ($desc = $trouver_table($table_objet) AND isset($desc['key']["PRIMARY KEY"])){ $primary = $desc['key']["PRIMARY KEY"]; $primary = explode(',',$primary); $primary = reset($primary); $type = preg_replace(',^id_,', '', $primary); } // on a fait ce qu'on a pu return $type; } // Recuperer le nom de la table de jointure xxxx sur l'objet yyyy // http://doc.spip.org/@table_jointure function table_jointure($x, $y) { $trouver_table = charger_fonction('trouver_table', 'base'); $xdesc = $trouver_table(table_objet($x)); $ydesc = $trouver_table(table_objet($y)); $tx = $xdesc['table']; $ty = $ydesc['table']; $ix = @$xdesc['key']["PRIMARY KEY"]; $iy = @$ydesc['key']["PRIMARY KEY"]; if ($table = $GLOBALS['tables_jointures'][$ty][$ix]) return $table; if ($table = $GLOBALS['tables_jointures'][$tx][$iy]) return $table; return ''; } // Pour compatibilite. Ne plus utiliser. // http://doc.spip.org/@spip_query function spip_query($query, $serveur='') { global $spip_sql_version; $f = spip_connect_sql($spip_sql_version, 'query', $serveur, true); return function_exists($f) ? $f($query, $serveur) : false; } ?> spip/spip/ecrire/base/abstract_sql.php0000766000000000000000000004435711236524730021272 0ustar adminadministrators false // http://doc.spip.org/@sql_serveur function sql_serveur($ins_sql='', $serveur='', $continue=false) { return spip_connect_sql(sql_ABSTRACT_VERSION, $ins_sql, $serveur, $continue); } // Demande si un charset est disponible. // http://doc.spip.org/@sql_get_charset function sql_get_charset($charset, $serveur='', $option=true){ // le nom http du charset differe parfois du nom SQL utf-8 ==> utf8 etc. $desc = sql_serveur('', $serveur, true,true); $desc = $desc[sql_ABSTRACT_VERSION]; $c = $desc['charsets'][$charset]; if ($c) { if (function_exists($f=@$desc['get_charset'])) if ($f($c, $serveur, $option!==false)) return $c; } spip_log("SPIP ne connait pas les Charsets disponibles sur le serveur $serveur. Le serveur choisira seul."); return false; } // Regler le codage de connexion // http://doc.spip.org/@sql_set_charset function sql_set_charset($charset,$serveur='', $option=true){ $f = sql_serveur('set_charset', $serveur, $option==='continue' OR $option===false); if (!is_string($f) OR !$f) return false; return $f($charset, $serveur, $option!==false); } // Fonction pour SELECT, retournant la ressource interrogeable par sql_fetch. // Recoit en argument: // - le tableau (ou cha�ne) des champs a` ramener (Select) // - le tableau (ou cha�ne) des tables a` consulter (From) // - le tableau (ou cha�ne) des conditions a` remplir (Where) // - le crite`re de regroupement (Group by) // - le tableau de classement (Order By) // - le crite`re de limite (Limit) // - le tableau des des post-conditions a remplir (Having) // - le serveur sollicite (pour retrouver la connexion) // - option peut avoir 3 valeurs : // true -> executer la requete, // false -> ne pas l'executer mais la retourner, // continue -> ne pas echouer en cas de serveur sql indisponible // http://doc.spip.org/@sql_select function sql_select ( $select = array(), $from = array(), $where = array(), $groupby = array(), $orderby = array(), $limit = '', $having = array(), $serveur='', $option=true) { $f = sql_serveur('select', $serveur, $option==='continue' OR $option===false); if (!is_string($f) OR !$f) return false; return $f($select, $from, $where, $groupby, $orderby, $limit, $having, $serveur, $option!==false); } // Recupere la syntaxe de la requete select sans l'executer // simplement $option = false au lieu de true // http://doc.spip.org/@sql_get_select function sql_get_select ( $select = array(), $from = array(), $where = array(), $groupby = array(), $orderby = array(), $limit = '', $having = array(), $serveur='') { return sql_select ($select, $from, $where, $groupby, $orderby, $limit, $having, $serveur, false); } // Comme ci-dessus, mais ramene seulement et tout de suite le nombre de lignes // Pas de colonne ni de tri a donner donc, et l'argument LIMIT est trompeur // http://doc.spip.org/@sql_countsel function sql_countsel($from = array(), $where = array(), $groupby = array(), $having = array(), $serveur='', $option=true) { $f = sql_serveur('countsel', $serveur, $option==='continue' OR $option===false); if (!is_string($f) OR !$f) return false; return $f($from, $where, $groupby, $having, $serveur, $option!==false); } // http://doc.spip.org/@sql_alter function sql_alter($q, $serveur='', $option=true) { $f = sql_serveur('alter', $serveur, $option==='continue' OR $option===false); if (!is_string($f) OR !$f) return false; return $f($q, $serveur, $option!==false); } // http://doc.spip.org/@sql_fetch function sql_fetch($res, $serveur='', $option=true) { $f = sql_serveur('fetch', $serveur, $option==='continue' OR $option===false); if (!is_string($f) OR !$f) return false; return $f($res, NULL, $serveur, $option!==false); } // http://doc.spip.org/@sql_listdbs function sql_listdbs($serveur='', $option=true) { $f = sql_serveur('listdbs', $serveur, $option==='continue' OR $option===false); if (!is_string($f) OR !$f) return false; return $f($serveur); } // http://doc.spip.org/@sql_selectdb function sql_selectdb($res, $serveur='', $option=true) { $f = sql_serveur('selectdb', $serveur, $option==='continue' OR $option===false); if (!is_string($f) OR !$f) return false; return $f($res, $serveur, $option!==false); } // http://doc.spip.org/@sql_count function sql_count($res, $serveur='', $option=true) { $f = sql_serveur('count', $serveur, $option==='continue' OR $option===false); if (!is_string($f) OR !$f) return false; return $f($res, $serveur, $option!==false); } // http://doc.spip.org/@sql_free function sql_free($res, $serveur='', $option=true) { $f = sql_serveur('free', $serveur, $option==='continue' OR $option===false); if (!is_string($f) OR !$f) return false; return $f($res); } // Cette fonction ne garantit pas une portabilite totale // ===> lui preferer la suivante. // Elle est fournie pour permettre l'actualisation de vieux codes // par un Sed brutal qui peut donner des resultats provisoirement acceptables // http://doc.spip.org/@sql_insert function sql_insert($table, $noms, $valeurs, $desc=array(), $serveur='', $option=true) { $f = sql_serveur('insert', $serveur, $option==='continue' OR $option===false); if (!is_string($f) OR !$f) return false; return $f($table, $noms, $valeurs, $desc, $serveur, $option!==false); } // http://doc.spip.org/@sql_insertq function sql_insertq($table, $couples=array(), $desc=array(), $serveur='', $option=true) { $f = sql_serveur('insertq', $serveur, $option==='continue' OR $option===false); if (!is_string($f) OR !$f) return false; return $f($table, $couples, $desc, $serveur, $option!==false); } // http://doc.spip.org/@sql_insertq_multi function sql_insertq_multi($table, $tab_couples=array(), $desc=array(), $serveur='', $option=true) { $f = sql_serveur('insertq_multi', $serveur, $option==='continue' OR $option===false); if (!is_string($f) OR !$f) return false; return $f($table, $tab_couples, $desc, $serveur, $option!==false); } // http://doc.spip.org/@sql_update function sql_update($table, $exp, $where='', $desc=array(), $serveur='', $option=true) { $f = sql_serveur('update', $serveur, $option==='continue' OR $option===false); if (!is_string($f) OR !$f) return false; return $f($table, $exp, $where, $desc, $serveur, $option!==false); } // Update est presque toujours appelee sur des constantes ou des dates // Cette fonction est donc plus utile que la precedente,d'autant qu'elle // permet de gerer les differences de representation des constantes. // http://doc.spip.org/@sql_updateq function sql_updateq($table, $exp, $where='', $desc=array(), $serveur='', $option=true) { $f = sql_serveur('updateq', $serveur, $option==='continue' OR $option===false); if (!is_string($f) OR !$f) return false; return $f($table, $exp, $where, $desc, $serveur, $option!==false); } // http://doc.spip.org/@sql_delete function sql_delete($table, $where='', $serveur='', $option=true) { $f = sql_serveur('delete', $serveur, $option==='continue' OR $option===false); if (!is_string($f) OR !$f) return false; return $f($table, $where, $serveur, $option!==false); } // http://doc.spip.org/@sql_replace function sql_replace($table, $couples, $desc=array(), $serveur='', $option=true) { $f = sql_serveur('replace', $serveur, $option==='continue' OR $option===false); if (!is_string($f) OR !$f) return false; return $f($table, $couples, $desc, $serveur, $option!==false); } // http://doc.spip.org/@sql_replace_multi function sql_replace_multi($table, $tab_couples, $desc=array(), $serveur='', $option=true) { $f = sql_serveur('replace_multi', $serveur, $option==='continue' OR $option===false); if (!is_string($f) OR !$f) return false; return $f($table, $tab_couples, $desc, $serveur, $option!==false); } // http://doc.spip.org/@sql_drop_table function sql_drop_table($table, $exist='', $serveur='', $option=true) { $f = sql_serveur('drop_table', $serveur, $option==='continue' OR $option===false); if (!is_string($f) OR !$f) return false; return $f($table, $exist, $serveur, $option!==false); } // supprimer une vue sql // http://doc.spip.org/@sql_drop_view function sql_drop_view($table, $exist='', $serveur='', $option=true) { $f = sql_serveur('drop_view', $serveur, $option==='continue' OR $option===false); if (!is_string($f) OR !$f) return false; return $f($table, $exist, $serveur, $option!==false); } // http://doc.spip.org/@sql_showbase function sql_showbase($spip=NULL, $serveur='', $option=true) { if ($spip == NULL){ $connexion = $GLOBALS['connexions'][$serveur ? $serveur : 0]; $spip = $connexion['prefixe'] . '%'; } $f = sql_serveur('showbase', $serveur, $option==='continue' OR $option===false); if (!is_string($f) OR !$f) return false; return $f($spip, $serveur, $option!==false); } function sql_alltable($spip=NULL, $serveur='', $option=true) { $q = sql_showbase($spip, $serveur, $option); $r = array(); if ($q) while ($t = sql_fetch($q)) { $r[] = array_shift($t);} return $r; } // http://doc.spip.org/@sql_showtable function sql_showtable($table, $table_spip = false, $serveur='', $option=true) { if ($table_spip){ $connexion = $GLOBALS['connexions'][$serveur ? $serveur : 0]; $prefixe = $connexion['prefixe']; $vraie_table = preg_replace('/^spip/', $prefixe, $table); } else $vraie_table = $table; $f = sql_serveur('showtable', $serveur, $option==='continue' OR $option===false); if (!is_string($f) OR !$f) return false; $f = $f($vraie_table, $serveur, $option!==false); if (!$f) return array(); if (isset($GLOBALS['tables_principales'][$table]['join'])) $f['join'] = $GLOBALS['tables_principales'][$table]['join']; elseif (isset($GLOBALS['tables_auxiliaires'][$table]['join'])) $f['join'] = $GLOBALS['tables_auxiliaires'][$table]['join']; return $f; } // http://doc.spip.org/@sql_create function sql_create($nom, $champs, $cles=array(), $autoinc=false, $temporary=false, $serveur='', $option=true) { $f = sql_serveur('create', $serveur, $option==='continue' OR $option===false); if (!is_string($f) OR !$f) return false; return $f($nom, $champs, $cles, $autoinc, $temporary, $serveur, $option!==false); } // Fonction pour creer une vue // nom : nom de la vue, // select_query : une requete select, idealement cree avec $req = sql_select() // (en mettant $option du sql_select a false pour recuperer la requete) // http://doc.spip.org/@sql_create_view function sql_create_view($nom, $select_query, $serveur='', $option=true) { $f = sql_serveur('create_view', $serveur, $option==='continue' OR $option===false); if (!is_string($f) OR !$f) return false; return $f($nom, $select_query, $serveur, $option!==false); } // http://doc.spip.org/@sql_multi function sql_multi($sel, $lang, $serveur='', $option=true) { $f = sql_serveur('multi', $serveur, $option==='continue' OR $option===false); if (!is_string($f) OR !$f) return false; return $f($sel, $lang); } // http://doc.spip.org/@sql_error function sql_error($query='requete inconnue', $serveur='', $option=true) { $f = sql_serveur('error', $serveur, $option==='continue' OR $option===false); if (!is_string($f) OR !$f) return false; return $f($query, $serveur, $option!==false); } // http://doc.spip.org/@sql_errno function sql_errno($serveur='', $option=true) { $f = sql_serveur('errno', $serveur, $option==='continue' OR $option===false); if (!is_string($f) OR !$f) return false; return $f($serveur); } // http://doc.spip.org/@sql_explain function sql_explain($q, $serveur='', $option=true) { $f = sql_serveur('explain', $serveur, $option==='continue' OR $option===false); if (!is_string($f) OR !$f) return false; return @function_exists($f) ? $f($q, $serveur, $option!==false) : false; } // http://doc.spip.org/@sql_optimize function sql_optimize($q, $serveur='', $option=true) { $f = sql_serveur('optimize', $serveur, $option==='continue' OR $option===false); if (!is_string($f) OR !$f) return false; return @function_exists($f) ? $f($q, $serveur, $option!==false) : false; } // http://doc.spip.org/@sql_repair function sql_repair($q, $serveur='', $option=true) { $f = sql_serveur('repair', $serveur, $option==='continue' OR $option===false); if (!is_string($f) OR !$f) return false; return @function_exists($f) ? $f($q, $serveur, $option!==false) : false; } // Fonction la plus generale ... et la moins portable // A n'utiliser qu'en derniere extremite // http://doc.spip.org/@sql_query function sql_query($ins, $serveur='', $option=true) { $f = sql_serveur('query', $serveur, $option==='continue' OR $option===false); if (!is_string($f) OR !$f) return false; return $f($ins, $serveur, $option!==false); } # une composition tellement frequente... // http://doc.spip.org/@sql_fetsel function sql_fetsel( $select = array(), $from = array(), $where = array(), $groupby = array(), $orderby = array(), $limit = '', $having = array(), $serveur='', $option=true) { $q = sql_select($select, $from, $where, $groupby, $orderby, $limit, $having, $serveur, $option); if ($option===false) return $q; if (!$q) return array(); $r = sql_fetch($q, $serveur, $option); sql_free($q, $serveur, $option); return $r; } // Retourne le tableau de toutes les lignes d'une requete Select // http://doc.spip.org/@sql_allfetsel function sql_allfetsel( $select = array(), $from = array(), $where = array(), $groupby = array(), $orderby = array(), $limit = '', $having = array(), $serveur='', $option=true) { $q = sql_select($select, $from, $where, $groupby, $orderby, $limit, $having, $serveur, $option); if ($option===false) return $q; if (!$q) return array(); $res = array(); while ($r = sql_fetch($q, $serveur)) $res[] = $r; sql_free($q, $serveur); return $res; } # Retourne l'unique champ demande dans une requete Select a resultat unique // http://doc.spip.org/@sql_getfetsel function sql_getfetsel( $select, $from = array(), $where = array(), $groupby = array(), $orderby = array(), $limit = '', $having = array(), $serveur='', $option=true) { if (preg_match('/\s+as\s+(\w+)$/i', $select, $c)) $id = $c[1]; elseif (!preg_match('/\W/', $select)) $id = $select; else {$id = 'n'; $select .= ' AS n';} $r = sql_fetsel($select, $from, $where, $groupby, $orderby, $limit, $having, $serveur, $option!==false); if (!$r) return NULL; return $r[$id]; } // http://doc.spip.org/@sql_version function sql_version($serveur='', $option=true) { $row = sql_fetsel("version() AS n", '','','','','','',$serveur); return ($row['n']); } // prend une chaine sur l'aphabet hexa // et retourne sa representation numerique: // FF ==> 0xFF en MySQL mais x'FF' en PG // http://doc.spip.org/@sql_hex function sql_hex($val, $serveur='', $option=true) { $f = sql_serveur('hex', $serveur, $option==='continue' OR $option===false); if (!is_string($f) OR !$f) return false; return $f($val); } function sql_quote($val, $serveur='', $type='') { $f = sql_serveur('quote', $serveur, true); if (!is_string($f) OR !$f) $f = '_q'; return $f($val, $type); } function sql_in($val, $valeurs, $not='', $serveur='', $option=true) { if (is_array($valeurs)) { $f = sql_serveur('quote', $serveur, true); if (!is_string($f) OR !$f) return false; $valeurs = join(',', array_map($f, array_unique($valeurs))); } elseif ($valeurs[0]===',') $valeurs = substr($valeurs,1); if (!strlen(trim($valeurs))) return ($not ? "0=0" : '0=1'); $f = sql_serveur('in', $serveur, $option==='continue' OR $option===false); if (!is_string($f) OR !$f) return false; return $f($val, $valeurs, $not, $serveur, $option!==false); } // Penser a dire dans la description du serveur // s'il accepte les requetes imbriquees afin d'optimiser ca // http://doc.spip.org/@sql_in_select function sql_in_select($in, $select, $from = array(), $where = array(), $groupby = array(), $orderby = array(), $limit = '', $having = array(), $serveur='') { $liste = array(); $res = sql_select($select, $from, $where, $groupby, $orderby, $limit, $having, $serveur); while ($r = sql_fetch($res)) {$liste[] = array_shift($r);} sql_free($res); return sql_in($in, $liste); } // http://doc.spip.org/@sql_test_int function sql_test_int($type, $serveur='', $option=true) { return (preg_match('/^bigint/i',$type) OR preg_match('/^int/i',$type) OR preg_match('/^tinyint/i',$type)); } // http://doc.spip.org/@sql_test_date function sql_test_date($type, $serveur='', $option=true) { return (preg_match('/^datetime/i',$type) OR preg_match('/^timestamp/i',$type)); } // Cette fonction devrait disparaitre // http://doc.spip.org/@description_table function description_table($nom){ global $tables_principales, $tables_auxiliaires; static $f; include_spip('base/serial'); if (isset($tables_principales[$nom])) return $tables_principales[$nom]; include_spip('base/auxiliaires'); if (isset($tables_auxiliaires[$nom])) return $tables_auxiliaires[$nom]; if (!$f) $f = charger_fonction('trouver_table', 'base'); return $f($nom); } if(!function_exists("ctype_xdigit")){ function ctype_xdigit($string = ""){ return !strlen( trim( $string, "1234567890abcdefABCDEF" ) ); }/* endfunction ctype_xdigit */ }/* endif not function_exists ctype_xdigit */ ?>spip/spip/ecrire/base/delete_statistiques.php0000766000000000000000000000305111236524730022656 0ustar adminadministrators0, 'referers'=>0, 'popularite'=>0)); // un pipeline pour detruire les tables de stats installees par les plugins pipeline('delete_statistiques', ''); spip_log("raz des stats operee redirige vers " . _request('redirect')); } ?> spip/spip/ecrire/base/import_all.php0000766000000000000000000001025511236524730020740 0ustar adminadministrators\n"; if ($charset = $GLOBALS['meta']['charset_restauration']) { ecrire_meta('charset', $charset); } detruit_restaurateur(); import_all_fin($request); include_spip('inc/rubriques'); calculer_rubriques(); if (!$res) ecrire_acces(); // Mise a jour du fichier htpasswd // revenir a l'accueil pour finir affiche_progression_javascript('100 %', 0); } // http://doc.spip.org/@import_all_milieu function import_all_milieu($request, $archive) { global $trans; if ($request['insertion'] == 'passe2') { include_spip('inc/import_insere'); $trans = translate_init($request); } else $trans = array(); return import_tables($request, $archive); } // http://doc.spip.org/@import_all_debut function import_all_debut() { ecrire_meta("restauration_status", "0",'non'); ecrire_meta("restauration_status_copie", "0",'non'); } // http://doc.spip.org/@import_all_fin function import_all_fin($request) { effacer_meta("charset_restauration"); effacer_meta("charset_insertion"); effacer_meta("restauration_status"); effacer_meta("date_optimisation"); effacer_meta('restauration_version_archive'); effacer_meta('restauration_tag_archive'); effacer_meta('restauration_charset_sql_connexion'); effacer_meta('restauration_attributs_archive'); effacer_meta('restauration_table_prefix'); effacer_meta('restauration_table_prefix_source'); effacer_meta('vieille_version_installee'); effacer_meta('restauration_status_tables'); effacer_meta('restauration_recopie_tables'); if ($request['insertion'] == 'passe2') sql_drop_table("spip_translate"); } ?> spip/spip/ecrire/base/convert_sql_utf8.php0000766000000000000000000001164011236524730022102 0ustar adminadministrators", _T('utf8_convert_timeout'), "


    \n"; convert_sql_utf8($titre); echo "

    "._T('utf8_convert_termine')."

    "; effacer_meta('convert_sql_utf8'); // bouton "retour au site" + redirige_par_entete echo "

    ", " >> ", _T('icone_retour'),"

    ", install_fin_html(); } // http://doc.spip.org/@convert_sql_utf8 function convert_sql_utf8($titre){ define(_DEBUG_CONVERT, false); $charset_spip = $GLOBALS['meta']['charset']; $charset_supporte = false; $utf8_supporte = false; // verifier que mysql gere le charset courant pour effectuer les conversions if ($c = sql_get_charset($charset_spip)){ $sql_charset = $c['charset']; $sql_collation = $c['collation']; $charset_supporte = true; } if (!$charset_supporte){ $res = spip_query("SHOW CHARACTER SET"); while ($row = sql_fetch($res)){ if ($row['Charset']=='utf8') $utf8_supporte = true; } echo install_debut_html($titre); echo _L("Le charset SPIP actuel $charset_spip n'est pas supporte par votre serveur MySQL
    "); # non traduit car complexe & obsolete if ($utf8_supporte) echo _L("Votre serveur supporte utf-8, vous devriez convertir votre site en utf-8 avant de recommencer cette operation"); echo install_fin_html(); } else { echo _L("Charset Actuel du site SPIP : $charset_spip
    "); echo _L("Conversion des champs des tables spip de type latin1 vers $sql_charset (collation $sql_collation)
    "); // lister les collations et leur charset correspondant $res = spip_query("SHOW COLLATION"); $charset2collations = array(); while ($row = sql_fetch($res)){ $charset2collations[$row['Collation']] = $row['Charset']; } $count = 0; // lister les tables spip include_spip('base/serial'); include_spip('base/auxiliaires'); $res = spip_query("SHOW TABLES"); while (($row = sql_fetch($res)) /*&& ($count<1)*/){ $nom = array_shift($row); if (preg_match(',^'.$GLOBALS['table_prefix'].'_(.*)$,',$nom,$regs)){ $count++; $nom = $regs[1]; echo "

    $nom

    "; // lister les champs de la table $res2 = spip_query("SHOW FULL COLUMNS FROM spip_$nom"); while ($row2 = sql_fetch($res2)){ $collation = $row2['Collation']; $champ = $row2['Field']; if ($collation!="NULL" && isset($charset2collations[$collation]) && $charset2collations[$collation]=='latin1'){ echo "Conversion de '$champ' depuis $collation (".$charset2collations[$collation]."):"; // conversion de latin1 vers le charset reel du contenu $type_texte= $row2['Type']; $type_blob = "blob"; if (strpos($type_texte,"text")!==FALSE) $type_blob = str_replace("text","blob",$type_texte); // sauf si blob expressement demande dans la description ! if (( $a = $GLOBALS['tables_principales']['spip_'.$nom]['field'][$champ] OR $a = $GLOBALS['tables_auxiliaires']['spip_'.$nom]['field'][$champ] ) AND preg_match(',blob,i', $a)) { echo "On ignore le champ blob $nom.$champ
    \n"; } else { $default = $row2['Default']?(" DEFAULT ".sql_quote($row2['Default'])):""; $notnull = ($row2['Null']=='YES')?"":" NOT NULL"; $q = "ALTER TABLE spip_$nom CHANGE $champ $champ $type_blob $default $notnull"; if (!_DEBUG_CONVERT) $b = spip_query($q); echo "
    $q
    $b\n"; $q = "ALTER TABLE spip_$nom CHANGE $champ $champ $type_texte CHARACTER SET $sql_charset COLLATE $sql_collation $default $notnull"; if (!_DEBUG_CONVERT) $b = spip_query($q); echo "
    $q
    \n"; } } } // on ne change le charset par defaut de la table que quand tous ses champs sont convertis $q = "ALTER TABLE spip_$nom DEFAULT CHARACTER SET $sql_charset COLLATE $sql_collation"; if (!_DEBUG_CONVERT) $b = spip_query($q); echo "
    $q
    $b\n"; } } ecrire_meta('charset_sql_base',$sql_charset,'non'); ecrire_meta('charset_sql_connexion',$sql_charset,'non'); } } ?> spip/spip/ecrire/base/index.php0000766000000000000000000000000211236524730017672 0ustar adminadministratorsX spip/spip/ecrire/base/typedoc.php0000766000000000000000000001740711236524730020253 0ustar adminadministrators 'JPEG', 'png' => 'PNG', 'gif' =>'GIF', // Autres images (peuvent utiliser le tag ) 'bmp' => 'BMP', 'tif' => 'TIFF' ); // Multimedia (peuvent utiliser le tag ) $tables_sequences = array( 'aiff' => 'AIFF', 'anx' => 'Annodex', 'axa' => 'Annodex Audio', 'axv' => 'Annodex Video', 'asf' => 'Windows Media', 'avi' => 'AVI', 'dv' => 'Digital Video', 'flac' => 'Free Lossless Audio Codec', 'flv' => 'Flash Video', 'm4v' => 'MPEG4 Video', 'm4a' => 'MPEG4 Audio', 'm4b' => 'MPEG4 Audio', 'm4p' => 'MPEG4 Audio', 'mid' => 'Midi', 'mng' => 'MNG', 'mka' => 'Matroska Audio', 'mkv' => 'Matroska Video', 'mov' => 'QuickTime', 'mp3' => 'MP3', 'mp4' => 'MPEG4', 'mpg' => 'MPEG', 'oga' => 'Ogg Audio', 'ogg' => 'Ogg Vorbis', 'ogv' => 'Ogg Video', 'ogx' => 'Ogg Multiplex', 'qt' => 'QuickTime', 'ra' => 'RealAudio', 'ram' => 'RealAudio', 'rm' => 'RealAudio', 'spx' => 'Ogg Speex', 'svg' => 'Scalable Vector Graphics', 'swf' => 'Flash', 'wav' => 'WAV', 'wmv' => 'Windows Media', '3gp' => '3rd Generation Partnership Project' ); // Documents varies $tables_documents = array( 'abw' => 'Abiword', 'ai' => 'Adobe Illustrator', 'bz2' => 'BZip', 'bin' => 'Binary Data', 'blend' => 'Blender', 'c' => 'C source', 'cls' => 'LaTeX Class', 'css' => 'Cascading Style Sheet', 'csv' => 'Comma Separated Values', 'deb' => 'Debian', 'doc' => 'Word', 'djvu' => 'DjVu', 'dvi' => 'LaTeX DVI', 'eps' => 'PostScript', 'gz' => 'GZ', 'h' => 'C header', 'html' => 'HTML', 'kml' => 'Keyhole Markup Language', 'kmz' => 'Google Earth Placemark File', 'm4u' => 'MPEG4 playliste', 'pas' => 'Pascal', 'pdf' => 'PDF', 'pgn' => 'Portable Game Notation', 'ppt' => 'PowerPoint', 'ps' => 'PostScript', 'psd' => 'Photoshop', 'rpm' => 'RedHat/Mandrake/SuSE', 'rtf' => 'RTF', 'sdd' => 'StarOffice', 'sdw' => 'StarOffice', 'sit' => 'Stuffit', 'sty' => 'LaTeX Style Sheet', 'sxc' => 'OpenOffice.org Calc', 'sxi' => 'OpenOffice.org Impress', 'sxw' => 'OpenOffice.org', 'tex' => 'LaTeX', 'tgz' => 'TGZ', 'torrent' => 'BitTorrent', 'ttf' => 'TTF Font', 'txt' => 'texte', 'xcf' => 'GIMP multi-layer', 'xspf' => 'XSPF', 'xls' => 'Excel', 'xml' => 'XML', 'zip' => 'Zip', // open document format 'odt' => 'opendocument text', 'ods' => 'opendocument spreadsheet', 'odp' => 'opendocument presentation', 'odg' => 'opendocument graphics', 'odc' => 'opendocument chart', 'odf' => 'opendocument formula', 'odb' => 'opendocument database', 'odi' => 'opendocument image', 'odm' => 'opendocument text-master', 'ott' => 'opendocument text-template', 'ots' => 'opendocument spreadsheet-template', 'otp' => 'opendocument presentation-template', 'otg' => 'opendocument graphics-template', ); $tables_mime = array( // Images reconnues par PHP 'jpg'=>'image/jpeg', 'png'=>'image/png', 'gif'=>'image/gif', // Autres images (peuvent utiliser le tag ) 'bmp'=>'image/x-ms-bmp', // pas enregistre par IANA, variante: image/bmp 'tif'=>'image/tiff', // Multimedia (peuvent utiliser le tag ) 'aiff'=>'audio/x-aiff', 'asf'=>'video/x-ms-asf', 'avi'=>'video/x-msvideo', 'anx'=>'application/annodex', 'axa'=>'audio/annodex', 'axv'=>'video/annodex', 'dv'=> 'video/x-dv', 'flac' => 'audio/x-flac', 'flv' => 'video/x-flv', 'm4a' => 'audio/mp4a-latm', 'm4b' => 'audio/mp4a-latm', 'm4p' => 'audio/mp4a-latm', 'm4u' => 'video/vnd.mpegurl', 'm4v' => 'video/x-m4v', 'mid'=>'audio/midi', 'mka' => 'audio/mka', 'mkv' => 'video/mkv', 'mng'=>'video/x-mng', 'mov'=>'video/quicktime', 'mp3'=>'audio/mpeg', 'mp4' => 'application/mp4', 'mpg'=>'video/mpeg', 'oga' => 'audio/ogg', 'ogg' => 'audio/ogg ', 'ogv' => 'video/ogg ', 'ogx' => 'application/ogg ', 'qt' =>'video/quicktime', 'ra' =>'audio/x-pn-realaudio', 'ram'=>'audio/x-pn-realaudio', 'rm' =>'audio/x-pn-realaudio', 'spx' => 'audio/ogg', 'svg'=>'image/svg+xml', 'swf'=>'application/x-shockwave-flash', 'wav'=>'audio/x-wav', 'wmv'=>'video/x-ms-wmv', '3gp'=>'video/3gpp', // Documents varies 'ai' =>'application/illustrator', 'abw' =>'application/abiword', 'bin' => 'application/octet-stream', # le tout-venant 'blend' => 'application/x-blender', 'bz2'=>'application/x-bzip2', 'c' =>'text/x-csrc', 'css'=>'text/css', 'csv'=>'text/csv', 'deb'=>'application/x-debian-package', 'doc'=>'application/msword', 'djvu'=>'image/vnd.djvu', 'dvi'=>'application/x-dvi', 'eps'=>'application/postscript', 'gz' =>'application/x-gzip', 'h' =>'text/x-chdr', 'html'=>'text/html', 'kml'=>'application/vnd.google-earth.kml+xml', 'kmz'=>'application/vnd.google-earth.kmz', 'pas'=>'text/x-pascal', 'pdf'=>'application/pdf', 'pgn' =>'application/x-chess-pgn', 'ppt'=>'application/vnd.ms-powerpoint', 'ps' =>'application/postscript', 'psd'=>'image/x-photoshop', // pas enregistre par IANA 'rpm'=>'application/x-redhat-package-manager', 'rtf'=>'application/rtf', 'sdd'=>'application/vnd.stardivision.impress', 'sdw'=>'application/vnd.stardivision.writer', 'sit'=>'application/x-stuffit', 'sxc'=>'application/vnd.sun.xml.calc', 'sxi'=>'application/vnd.sun.xml.impress', 'sxw'=>'application/vnd.sun.xml.writer', 'tex'=>'text/x-tex', 'tgz'=>'application/x-gtar', 'torrent' => 'application/x-bittorrent', 'ttf'=>'application/x-font-ttf', 'txt'=>'text/plain', 'xcf'=>'application/x-xcf', 'xls'=>'application/vnd.ms-excel', 'xspf'=>'application/xspf+xml', 'xml'=>'application/xml', 'zip'=>'application/zip', // open document format 'odt' => 'application/vnd.oasis.opendocument.text', 'ods' => 'application/vnd.oasis.opendocument.spreadsheet', 'odp' => 'application/vnd.oasis.opendocument.presentation', 'odg' => 'application/vnd.oasis.opendocument.graphics', 'odc' => 'application/vnd.oasis.opendocument.chart', 'odf' => 'application/vnd.oasis.opendocument.formula', 'odb' => 'application/vnd.oasis.opendocument.database', 'odi' => 'application/vnd.oasis.opendocument.image', 'odm' => 'application/vnd.oasis.opendocument.text-master', 'ott' => 'application/vnd.oasis.opendocument.text-template', 'ots' => 'application/vnd.oasis.opendocument.spreadsheet-template', 'otp' => 'application/vnd.oasis.opendocument.presentation-template', 'otg' => 'application/vnd.oasis.opendocument.graphics-template', 'cls'=>'text/x-tex', 'sty'=>'text/x-tex', ); $mime_alias = array ( 'audio/x-mpeg' => 'audio/mpeg', 'application/x-ogg' => 'application/ogg', 'video/mp4' => 'application/mp4', 'video/flv' => 'video/x-flv', 'audio/3gpp' => 'video/3gpp' ); ?> spip/spip/ecrire/base/create.php0000766000000000000000000000654611236524730020051 0ustar adminadministrators$type){ if (!isset($sql_desc['field'][$field])) sql_alter("TABLE $table ADD $field $type".($last?" AFTER $last":""),$serveur); $last = $field; } } } // http://doc.spip.org/@creer_base function creer_base($serveur='') { global $tables_principales, $tables_auxiliaires; // Note: les mises a jour reexecutent ce code pour s'assurer // de la conformite de la base // pas de panique sur "already exists" et "duplicate entry" donc. foreach($tables_principales as $k => $v) creer_ou_upgrader_table($k,$v,true,false,$serveur); foreach($tables_auxiliaires as $k => $v) creer_ou_upgrader_table($k,$v,false,false,$serveur); } // http://doc.spip.org/@maj_tables function maj_tables($upgrade_tables=array(),$serveur=''){ global $tables_principales, $tables_auxiliaires; foreach($tables_principales as $k => $v) if (($upgrade_tables==$k OR (is_array($upgrade_tables) && in_array($k,$upgrade_tables)))) creer_ou_upgrader_table($k,$v,true,true,$serveur); foreach($tables_auxiliaires as $k => $v) if (($upgrade_tables==$k OR (is_array($upgrade_tables) && in_array($k,$upgrade_tables)))) creer_ou_upgrader_table($k,$v,false,true,$serveur); } // http://doc.spip.org/@creer_base_types_doc function creer_base_types_doc($serveur='') { global $tables_images, $tables_sequences, $tables_documents, $tables_mime; // Init ou Re-init ==> replace pas insert $freplace = sql_serveur('replace', $serveur); foreach ($tables_mime as $extension => $type_mime) { if (isset($tables_images[$extension])) { $titre = $tables_images[$extension]; $inclus='image'; } else if (isset($tables_sequences[$extension])) { $titre = $tables_sequences[$extension]; $inclus='embed'; } else { $inclus='non'; if (isset($tables_documents[$extension])) $titre = $tables_documents[$extension]; else $titre = ''; } $freplace('spip_types_documents', array('mime_type' => $type_mime, 'titre' => $titre, 'inclus' => $inclus, 'extension' => $extension, 'upload' => 'oui' ), '', $serveur); } } ?> spip/spip/ecrire/base/admin_repair.php0000766000000000000000000000701611236524730021231 0ustar adminadministrators
    "._T('avis_erreur_mysql').' '.sql_errno().': '.sql_error() ."


    \n"; } else { include_spip('inc/rubriques'); calculer_rubriques(); propager_les_secteurs(); } include_spip('inc/minipres'); $res .= admin_repair_plat(); echo minipres(_T('texte_tentative_recuperation'), $res . generer_form_ecrire('accueil', '','',_T('public:accueil_site'))); } // http://doc.spip.org/@admin_repair_plat function admin_repair_plat(){ spip_log("verification des documents joints"); $out = ""; $repertoire = array(); include_spip('inc/getdocument'); $res = sql_select('*','spip_documents',"fichier REGEXP CONCAT('^',extension,'[^/\]') AND distant='non'"); while ($row=sql_fetch($res)){ $ext = $row['extension']; if (!$ext) { spip_log("document sans extension: " . $row['id_document']); continue; } if (!isset($repertoire[$ext])){ if (@file_exists($plat = _DIR_IMG. $ext .".plat")) spip_unlink($plat); $repertoire[$ext] = creer_repertoire_documents($ext); if (preg_match(',_$,',$repertoire[$ext])) $repertoire[$ext] = false; } if ($d=$repertoire[$ext]){ $d = substr($d,strlen(_DIR_IMG)); $src = $row['fichier']; $dest = $d . substr($src,strlen($d)); if (deplacer_fichier_upload(_DIR_IMG . $src, _DIR_IMG . $dest)) { sql_updateq('spip_documents',array('fichier'=>$dest),'id_document='.intval($row['id_document'])); spip_unlink(_DIR_IMG . $src); $out .= "$src => $dest
    "; } } } return $out; } // http://doc.spip.org/@admin_repair_tables function admin_repair_tables() { $connexion = $GLOBALS['connexions'][0]; $prefixe = $connexion['prefixe']; $res1 = sql_showbase(); $res = ""; if ($res1) { while ($r = sql_fetch($res1)) { $tab = array_shift($r); $res .= "
    $tab "; spip_log("Repare $tab"); $result_repair = sql_repair($tab); if (!$result_repair) return false; $count = sql_countsel($tab); if ($count>1) $res .= "("._T('texte_compte_elements', array('count' => $count)).")\n"; else if ($count==1) $res .= "("._T('texte_compte_element', array('count' => $count)).")\n"; else $res .= "("._T('texte_vide').")\n"; $msg = join(" ", sql_fetch($result_repair)) . ' '; $ok = strpos($msg, ' OK '); if (!$ok) $res .= "
    ".htmlentities($msg)."
    \n"; else $res .= " "._T('texte_table_ok')."
    \n"; } } return $res; } ?> spip/spip/ecrire/base/upgrade.php0000766000000000000000000001527611236524730020235 0ustar adminadministrators ne pas passer par le processus de mise a jour. // De meme en cas de version superieure: ca devait etre un test, // il y a eu le message d'avertissement il doit savoir ce qu'il fait // // version_installee = 1.702; quand on a besoin de forcer une MAJ spip_log("Version anterieure: $version_installee. Courante: $spip_version_base"); if (!$version_installee OR ($spip_version_base < $version_installee)) { sql_replace('spip_meta', array('nom' => 'version_installee', 'valeur' => $spip_version_base, 'impt' => 'non')); return; } if (!upgrade_test()) return; $cible = ($version_cible ? $version_cible : $spip_version_base); if ($version_installee <= 1.926) { $n = floor($version_installee * 10); while ($n < 19) { $nom = sprintf("v%03d",$n); $f = charger_fonction($nom, 'maj', true); if ($f) { spip_log("$f repercute les modifications de la version " . ($n/10)); $f($version_installee, $spip_version_base); } else spip_log("pas de fonction pour la maj $n $nom"); $n++; } include_spip('maj/v019_pre193'); v019_pre193($version_installee, $version_cible); } if ($version_installee < 2000) { if ($version_installee < 2) $version_installee = $version_installee*1000; include_spip('maj/v019'); } if ($cible < 2) $cible = $cible*1000; maj_while($version_installee, $cible); } // A partir des > 1.926 (i.e SPIP > 1.9.2), cette fonction gere les MAJ. // Se relancer soi-meme pour eviter l'interruption pendant une operation SQL // (qu'on espere pas trop longue chacune) // evidemment en ecrivant dans la meta a quel numero on en est. define('_UPGRADE_TIME_OUT', 20); // http://doc.spip.org/@maj_while function maj_while($installee, $cible) { include_spip('maj/svn10000'); $n = 0; $time = time(); while ($installee < $cible) { $installee++; if (isset($GLOBALS['maj'][$installee])) { serie_alter($installee, $GLOBALS['maj'][$installee]); $n = time() - $time; spip_log("MAJ vers $installee en $n secondes",'maj'); ecrire_meta('version_installee', $installee,'non'); } // rien pour SQL if ($n >= _UPGRADE_TIME_OUT) { redirige_url_ecrire('upgrade', "reinstall=$installee"); } } // indispensable pour les chgt de versions qui n'ecrivent pas en base // tant pis pour la redondance eventuelle avec ci-dessus ecrire_meta('version_installee', $installee,'non'); } // Appliquer une serie de chgt qui risquent de partir en timeout // (Alter cree une copie temporaire d'une table, c'est lourd) // http://doc.spip.org/@serie_alter function serie_alter($serie, $q = array()) { $etape = intval(@$GLOBALS['meta']['upgrade_etape_'.$serie]); foreach ($q as $i => $r) { if ($i >= $etape) { if (is_array($r) AND function_exists($f = array_shift($r))) { spip_log("$serie/$i: $f " . join(',',$r),'maj'); ecrire_meta('upgrade_etape_'.$serie, $i+1); // attention on enregistre le meta avant de lancer la fonction, de maniere a eviter de boucler sur timeout call_user_func_array($f, $r); spip_log("$serie/$i: ok", 'maj'); } else { echo "maj $serie etape $i incorrecte"; exit; } } } effacer_meta('upgrade_etape_'.$serie); } // La fonction a appeler dans le tableau global $maj // quand on rajoute des types MIME. cf par exemple la 1.953 // http://doc.spip.org/@upgrade_types_documents function upgrade_types_documents() { include_spip('base/create'); creer_base_types_doc(); } // http://doc.spip.org/@upgrade_test function upgrade_test() { sql_drop_table("spip_test", true); sql_create("spip_test", array('a' => 'int')); sql_alter("TABLE spip_test ADD b INT"); sql_insertq('spip_test', array('b' => 1), array('field'=>array('b' => 'int'))); $result = sql_select('b', "spip_test"); // ne pas garder le resultat de la requete sinon sqlite3 // ne peut pas supprimer la table spip_test lors du sql_alter qui suit // car cette table serait alors 'verouillee' $result = $result?true:false; sql_alter("TABLE spip_test DROP b"); return $result; } // pour versions <= 1.926 // http://doc.spip.org/@maj_version function maj_version ($version, $test = true) { if ($test) { if ($version>=1.922) ecrire_meta('version_installee', $version, 'non'); else { // on le fait manuellement, car ecrire_meta utilise le champs impt qui est absent sur les vieilles versions $GLOBALS['meta']['version_installee'] = $version; sql_updateq('spip_meta', array('valeur' => $version), "nom=" . sql_quote('version_installee') ); } spip_log("mise a jour de la base en $version"); } else { echo _T('alerte_maj_impossible', array('version' => $version)); exit; } } // pour versions <= 1.926 // http://doc.spip.org/@upgrade_vers function upgrade_vers($version, $version_installee, $version_cible = 0){ return ($version_installee<$version AND (($version_cible>=$version) OR ($version_cible==0)) ); } ?> spip/spip/ecrire/base/auxiliaires.php0000766000000000000000000002607111236524730021120 0ustar adminadministrators "bigint(21) DEFAULT '0' NOT NULL", "email_unique" => "CHAR (3) DEFAULT '' NOT NULL", "site_obli" => "CHAR (3) DEFAULT '' NOT NULL", "site_unique" => "CHAR (3) DEFAULT '' NOT NULL", "message" => "CHAR (3) DEFAULT '' NOT NULL", "texte" => "LONGTEXT DEFAULT '' NOT NULL", "maj" => "TIMESTAMP"); $spip_petitions_key = array( "PRIMARY KEY" => "id_article"); $spip_visites = array( "date" => "DATE NOT NULL", "visites" => "int UNSIGNED DEFAULT '0' NOT NULL", "maj" => "TIMESTAMP"); $spip_visites_key = array( "PRIMARY KEY" => "date"); $spip_visites_articles = array( "date" => "DATE NOT NULL", "id_article" => "int UNSIGNED NOT NULL", "visites" => "int UNSIGNED DEFAULT '0' NOT NULL", "maj" => "TIMESTAMP"); $spip_visites_articles_key = array( "PRIMARY KEY" => "date, id_article"); $spip_resultats = array( "recherche" => "char(16) not null default ''", "id" => "INT UNSIGNED NOT NULL", "points" => "INT UNSIGNED DEFAULT '0' NOT NULL", "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_referers = array( "referer_md5" => "bigint UNSIGNED NOT NULL", "date" => "DATE NOT NULL", "referer" => "VARCHAR (255)", "visites" => "int UNSIGNED NOT NULL", "visites_jour" => "int UNSIGNED NOT NULL", "visites_veille"=> "int UNSIGNED NOT NULL", "maj" => "TIMESTAMP"); $spip_referers_key = array( "PRIMARY KEY" => "referer_md5"); $spip_referers_articles = array( "id_article" => "int UNSIGNED NOT NULL", "referer_md5" => "bigint UNSIGNED NOT NULL", "referer" => "VARCHAR (255) DEFAULT '' NOT NULL", "visites" => "int UNSIGNED NOT NULL", "maj" => "TIMESTAMP"); $spip_referers_articles_key = array( "PRIMARY KEY" => "id_article, referer_md5", "KEY referer_md5" => "referer_md5"); $spip_auteurs_articles = array( "id_auteur" => "bigint(21) DEFAULT '0' NOT NULL", "id_article" => "bigint(21) DEFAULT '0' NOT NULL"); $spip_auteurs_articles_key = array( "PRIMARY KEY" => "id_auteur, id_article", "KEY id_article" => "id_article"); $spip_auteurs_rubriques = array( "id_auteur" => "bigint(21) DEFAULT '0' NOT NULL", "id_rubrique" => "bigint(21) DEFAULT '0' NOT NULL"); $spip_auteurs_rubriques_key = array( "PRIMARY KEY" => "id_auteur, id_rubrique", "KEY id_rubrique" => "id_rubrique"); $spip_auteurs_messages = array( "id_auteur" => "bigint(21) DEFAULT '0' NOT NULL", "id_message" => "bigint(21) DEFAULT '0' NOT NULL", "vu" => "CHAR (3)"); $spip_auteurs_messages_key = array( "PRIMARY KEY" => "id_auteur, id_message", "KEY id_message" => "id_message"); $spip_documents_liens = array( "id_document" => "bigint(21) DEFAULT '0' NOT NULL", "id_objet" => "bigint(21) DEFAULT '0' NOT NULL", "objet" => "VARCHAR (25) DEFAULT '' NOT NULL", "vu" => "ENUM('non', 'oui') DEFAULT 'non' NOT NULL"); $spip_documents_liens_key = array( "PRIMARY KEY" => "id_document,id_objet,objet", "KEY id_document" => "id_document"); /* $spip_documents_articles = array( "id_document" => "bigint(21) DEFAULT '0' NOT NULL", "id_article" => "bigint(21) DEFAULT '0' NOT NULL", "vu" => "ENUM('non', 'oui') DEFAULT 'non' NOT NULL"); $spip_documents_articles_key = array( "PRIMARY KEY" => "id_article, id_document", "KEY id_document" => "id_document"); $spip_documents_rubriques = array( "id_document" => "bigint(21) DEFAULT '0' NOT NULL", "id_rubrique" => "bigint(21) DEFAULT '0' NOT NULL", "vu" => "ENUM('non', 'oui') DEFAULT 'non' NOT NULL"); $spip_documents_rubriques_key = array( "PRIMARY KEY" => "id_rubrique, id_document", "KEY id_document" => "id_document"); $spip_documents_breves = array( "id_document" => "bigint(21) DEFAULT '0' NOT NULL", "id_breve" => "bigint(21) DEFAULT '0' NOT NULL", "vu" => "ENUM('non', 'oui') DEFAULT 'non' NOT NULL"); $spip_documents_breves_key = array( "PRIMARY KEY" => "id_breve, id_document", "KEY id_document" => "id_document"); $spip_documents_forum = array( "id_document" => "bigint(21) DEFAULT '0' NOT NULL", "id_forum" => "bigint(21) DEFAULT '0' NOT NULL", "vu" => "ENUM('non', 'oui') DEFAULT 'non' NOT NULL"); $spip_documents_forum_key = array( "PRIMARY KEY" => "id_forum, id_document", "KEY id_document" => "id_document"); */ $spip_mots_articles = array( "id_mot" => "bigint(21) DEFAULT '0' NOT NULL", "id_article" => "bigint(21) DEFAULT '0' NOT NULL"); $spip_mots_articles_key = array( "PRIMARY KEY" => "id_article, id_mot", "KEY id_mot" => "id_mot"); $spip_mots_breves = array( "id_mot" => "bigint(21) DEFAULT '0' NOT NULL", "id_breve" => "bigint(21) DEFAULT '0' NOT NULL"); $spip_mots_breves_key = array( "PRIMARY KEY" => "id_breve, id_mot", "KEY id_mot" => "id_mot"); $spip_mots_rubriques = array( "id_mot" => "bigint(21) DEFAULT '0' NOT NULL", "id_rubrique" => "bigint(21) DEFAULT '0' NOT NULL"); $spip_mots_rubriques_key = array( "PRIMARY KEY" => "id_rubrique, id_mot", "KEY id_mot" => "id_mot"); $spip_mots_syndic = array( "id_mot" => "bigint(21) DEFAULT '0' NOT NULL", "id_syndic" => "bigint(21) DEFAULT '0' NOT NULL"); $spip_mots_syndic_key = array( "PRIMARY KEY" => "id_syndic, id_mot", "KEY id_mot" => "id_mot"); $spip_mots_forum = array( "id_mot" => "bigint(21) DEFAULT '0' NOT NULL", "id_forum" => "bigint(21) DEFAULT '0' NOT NULL"); $spip_mots_forum_key = array( "PRIMARY KEY" => "id_forum, id_mot", "KEY id_mot" => "id_mot"); $spip_mots_documents = array( "id_mot" => "bigint(21) DEFAULT '0' NOT NULL", "id_document" => "bigint(21) DEFAULT '0' NOT NULL"); $spip_mots_documents_key = array( "PRIMARY KEY" => "id_document, id_mot", "KEY id_mot" => "id_mot"); $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_versions = array ( "id_article" => "bigint(21) NOT NULL", "id_version" => "bigint(21) DEFAULT 0 NOT NULL", "date" => "datetime DEFAULT '0000-00-00 00:00:00' NOT NULL", "id_auteur" => "VARCHAR(23) DEFAULT '' NOT NULL", # stocke aussi IP(v6) "titre_version" => "text DEFAULT '' NOT NULL", "permanent" => "char(3)", "champs" => "text"); $spip_versions_key = array ( "PRIMARY KEY" => "id_article, id_version"); $spip_versions_fragments = array( "id_fragment" => "int unsigned DEFAULT '0' NOT NULL", "version_min" => "int unsigned DEFAULT '0' NOT NULL", "version_max" => "int unsigned DEFAULT '0' NOT NULL", "id_article" => "bigint(21) NOT NULL", "compress" => "tinyint NOT NULL", "fragment" => "longblob" # ici c'est VRAIMENT un blob (on y stocke du gzip) ); $spip_versions_fragments_key = array( "PRIMARY KEY" => "id_article, id_fragment, version_min"); $spip_urls = array( "url" => "VARCHAR(255) NOT NULL", // la table cible "type" => "varchar(15) DEFAULT 'article' NOT NULL", // l'id dans la table "id_objet" => "bigint(21) NOT NULL", // pour connaitre la plus recente. // ATTENTION, pas on update CURRENT_TIMESTAMP implicite // et pas le nom maj, surinterprete par inc/import_1_3 "date" => "DATETIME DEFAULT '0000-00-00 00:00:00' NOT NULL"); $spip_urls_key = array( "PRIMARY KEY" => "url", "KEY type" => "type, id_objet"); $tables_auxiliaires['spip_petitions'] = array( 'field' => &$spip_petitions, 'key' => &$spip_petitions_key ); $tables_auxiliaires['spip_visites'] = array( 'field' => &$spip_visites, 'key' => &$spip_visites_key); $tables_auxiliaires['spip_visites_articles'] = array( 'field' => &$spip_visites_articles, 'key' => &$spip_visites_articles_key); $tables_auxiliaires['spip_referers'] = array( 'field' => &$spip_referers, 'key' => &$spip_referers_key); $tables_auxiliaires['spip_referers_articles'] = array( 'field' => &$spip_referers_articles, 'key' => &$spip_referers_articles_key); $tables_auxiliaires['spip_auteurs_articles'] = array( 'field' => &$spip_auteurs_articles, 'key' => &$spip_auteurs_articles_key); $tables_auxiliaires['spip_auteurs_rubriques'] = array( 'field' => &$spip_auteurs_rubriques, 'key' => &$spip_auteurs_rubriques_key); $tables_auxiliaires['spip_auteurs_messages'] = array( 'field' => &$spip_auteurs_messages, 'key' => &$spip_auteurs_messages_key); $tables_auxiliaires['spip_documents_liens'] = array( 'field' => &$spip_documents_liens, 'key' => &$spip_documents_liens_key); /* $tables_auxiliaires['spip_documents_articles'] = array( 'field' => &$spip_documents_articles, 'key' => &$spip_documents_articles_key); $tables_auxiliaires['spip_documents_rubriques'] = array( 'field' => &$spip_documents_rubriques, 'key' => &$spip_documents_rubriques_key); $tables_auxiliaires['spip_documents_breves'] = array( 'field' => &$spip_documents_breves, 'key' => &$spip_documents_breves_key); $tables_auxiliaires['spip_documents_forum'] = array( 'field' => &$spip_documents_forum, 'key' => &$spip_documents_forum_key); */ $tables_auxiliaires['spip_mots_articles'] = array( 'field' => &$spip_mots_articles, 'key' => &$spip_mots_articles_key); $tables_auxiliaires['spip_mots_breves'] = array( 'field' => &$spip_mots_breves, 'key' => &$spip_mots_breves_key); $tables_auxiliaires['spip_mots_rubriques'] = array( 'field' => &$spip_mots_rubriques, 'key' => &$spip_mots_rubriques_key); $tables_auxiliaires['spip_mots_syndic'] = array( 'field' => &$spip_mots_syndic, 'key' => &$spip_mots_syndic_key); $tables_auxiliaires['spip_mots_forum'] = array( 'field' => &$spip_mots_forum, 'key' => &$spip_mots_forum_key); $tables_auxiliaires['spip_mots_documents'] = array( 'field' => &$spip_mots_documents, 'key' => &$spip_mots_documents_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_versions'] = array( 'field' => &$spip_versions, 'key' => &$spip_versions_key); $tables_auxiliaires['spip_versions_fragments'] = array( 'field' => &$spip_versions_fragments, 'key' => &$spip_versions_fragments_key); $tables_auxiliaires['spip_urls'] = array( 'field' => &$spip_urls, 'key' => &$spip_urls_key); $tables_auxiliaires = pipeline('declarer_tables_auxiliaires',$tables_auxiliaires); } global $tables_auxiliaires; base_auxiliaires($tables_auxiliaires); ?> spip/spip/ecrire/base/delete_all.php0000766000000000000000000000261011236524730020664 0ustar adminadministrators spip/spip/ecrire/balise/0000777000000000000000000000000011266531717016414 5ustar adminadministratorsspip/spip/ecrire/balise/formulaire_.php0000766000000000000000000001402611236524726021434 0ustar adminadministratorsnom_champ; if (substr($form,0,11)=="FORMULAIRE_" AND $form = strtolower(substr($form,11)) AND (!find_in_path('formulaires/'.$form.'.html'))) { $p->code = "''"; $p->interdire_scripts = false; return $p; } // sinon renvoyer un code php dnamique return calculer_balise_dynamique($p, $p->nom_champ, array()); } /* prendre en charge par defaut les balises dynamiques formulaires simples */ // http://doc.spip.org/@balise_FORMULAIRE__dyn function balise_FORMULAIRE__dyn($form) { // recuperer les arguments passes a la balise $args = func_get_args(); // deux moyen d'arriver ici : soit #FORMULAIRE_XX reroute avec 'FORMULAIRE_XX' ajoute en premier arg // soit #FORMULAIRE_{xx} if (substr($form,0,11)=="FORMULAIRE_") $form = strtolower(substr($form,11)); else $form = strtolower($form); // on enleve le premier qui est le nom de la balise et deja recupere ci-dessus array_shift($args); if (!find_in_path("formulaires/$form.html")) return ''; // tester si ce formulaire vient d'etre poste (memes arguments) // pour ne pas confondre 2 #FORMULAIRES_XX identiques sur une meme page $je_suis_poste = false; if ($post_form = _request('formulaire_action') AND $post_args = _request('formulaire_action_args')) { $post_args = decoder_contexte_ajax($post_args,$post_form); // enlever le faux attribut de langue masque array_shift($post_args); if ($args === $post_args){ $je_suis_poste = true; } } // init $erreurs = $valeurs = array(); $message_ok = $message_erreur = ""; $editable = true; // si le formulaire vient d'etre poste, on recupere les erreurs if ($je_suis_poste){ $post = traiter_formulaires_dynamiques(true); $erreurs = isset($post["erreurs_$form"])?$post["erreurs_$form"]:array(); $message_ok = ""; if (isset($post["message_ok_$form"])) $message_ok = $post["message_ok_$form"]; elseif(isset($erreurs['message_ok'])) $message_ok = $erreurs["message_ok"]; $message_erreur = isset($erreurs['message_erreur'])?$erreurs['message_erreur']:""; $editable = (!isset($post["erreurs_$form"])) || count($erreurs) || (isset($post["editable_$form"]) && $post["editable_$form"]); } if ($charger_valeurs = charger_fonction("charger","formulaires/$form/",true)) $valeurs = call_user_func_array($charger_valeurs,$args); $valeurs = pipeline( 'formulaire_charger', array( 'args'=>array('form'=>$form,'args'=>$args), 'data'=>$valeurs) ); // si $valeurs===false, alors le formulaire n'est pas applicable // on n'affiche rien. C'est plus fort qu'editable qui est geree // par le squelette du forumaire lui meme if ($valeurs===false) return ''; // reperer les valeurs particulieres editable, message_ok et message_erreur if (isset($valeurs['editable'])){ $editable = $valeurs['editable']; unset($valeurs['editable']); } foreach(array('message_ok','message_erreur') as $k){ if (isset($valeurs[$k])){ if (!$je_suis_poste) $$k = $valeurs[$k]; unset($valeurs[$k]); } } // charger peut passer une action si le formulaire ne tourne pas sur self() // ou une action vide si elle ne sert pas $action = isset($valeurs['action'])?$valeurs['action']:self(); // recuperer la saisie en cours si erreurs // seulement si c'est ce formulaire qui est poste // ou si on le demande explicitement par le parametre _forcer_request = true foreach(array_keys($valeurs) as $champ){ if (substr($champ,0,1)!=='_'){ if ($je_suis_poste || (isset($valeurs['_forcer_request']) && $valeurs['_forcer_request'])) { if (($v = _request($champ))!==NULL) $valeurs[$champ] = $v; } if ($action) $action = parametre_url($action,$champ,''); // nettoyer l'url des champs qui vont etre saisis // proteger les ' et les " dans les champs que l'on va injecter if (is_string($valeurs[$champ])) $valeurs[$champ] = protege_champ($valeurs[$champ]); } } if ($action) { // nettoyer l'url $action = parametre_url($action,'formulaire_action',''); $action = parametre_url($action,'formulaire_action_args',''); } if (isset($valeurs['_action'])){ $securiser_action = charger_fonction('securiser_action','inc'); $secu = $securiser_action(reset($valeurs['_action']),end($valeurs['_action']),'',-1); $valeurs['_hidden'] = (isset($valeurs['_hidden'])?$valeurs['_hidden']:'') . "" . ""; } // empiler la lang en tant que premier argument implicite du CVT // pour permettre de la restaurer au moment du Verifier et du Traiter array_unshift($args, $GLOBALS['spip_lang']); return array("formulaires/$form", 3600, array_merge( $valeurs, array( 'form' => $form, 'action' => $action, 'formulaire_args' => encoder_contexte_ajax($args,$form), 'id' => isset($valeurs['id'])?$valeurs['id']:'new', 'erreurs' => $erreurs, 'message_ok' => $message_ok, 'message_erreur' => $message_erreur, 'editable' => $editable?' ':'', ) ) ); } ?> spip/spip/ecrire/balise/logo_.php0000766000000000000000000001030611236524726020224 0ustar adminadministratorsnom_champ, $regs); $type_objet = $regs[1]; $suite_logo = @$regs[2]; // cas de #LOGO_SITE_SPIP if (preg_match(",^_SPIP(.*)$,", $suite_logo, $regs)) { $type_objet = 'SITE'; $suite_logo = $regs[1]; $_id_objet = "\"'0'\""; $id_objet = 'id_syndic'; # parait faux mais donne bien "siteNN" } else { if ($type_objet == 'SITE') $id_objet = "id_syndic"; else $id_objet = "id_".strtolower($type_objet); $_id_objet = champ_sql($id_objet, $p); } // analyser les faux filtres $flag_fichier = $flag_stop = $flag_lien_auto = $code_lien = $filtres = $align = $lien = $params = ''; if (is_array($p->fonctions)) { foreach($p->fonctions as $couple) { if (!$flag_stop) { $nom = trim($couple[0]); // double || signifie "on passe aux vrais filtres" if ($nom == '') { if ($couple[1]) { $params = $couple[1]; // recuperer #LOGO_DOCUMENT{20,30} array_shift($p->param); } else $flag_stop = true; } else { // faux filtres array_shift($p->param); switch($nom) { case 'left': case 'right': case 'center': case 'top': case 'bottom': $align = $nom; break; case 'lien': $flag_lien_auto = 'oui'; $flag_stop = true; # apres |lien : vrais filtres break; case 'fichier': $flag_fichier = 1; $flag_stop = true; # apres |fichier : vrais filtres break; default: $lien = $nom; $flag_stop = true; # apres |#URL... : vrais filtres break; } } } } } // // Preparer le code du lien // // 1. filtre |lien if ($flag_lien_auto AND !$lien) $code_lien = '($lien = generer_url_entite('.$_id_objet . ',"' . $type_objet .'")) ? $lien : ""'; // 2. lien indique en clair (avec des balises : imprimer#ID_ARTICLE.html) else if ($lien) { $code_lien = "'".texte_script(trim($lien))."'"; while (preg_match(",^([^#]*)#([A-Za-z_]+)(.*)$,", $code_lien, $match)) { $c = new Champ(); $c->nom_champ = $match[2]; $c->id_boucle = $p->id_boucle; $c->boucles = &$p->boucles; $c->descr = $p->descr; $c = calculer_champ($c); $code_lien = str_replace('#'.$match[2], "'.".$c.".'", $code_lien); } // supprimer les '' disgracieux $code_lien = preg_replace("@^''\.|\.''$@", "", $code_lien); } if ($flag_fichier) $code_lien = "'',''" ; else { if (!$code_lien) $code_lien = "''"; $code_lien .= ", '". $align . "'"; } $connect = $p->id_boucle ?$p->boucles[$p->id_boucle]->sql_serveur :''; if ($type_objet == 'DOCUMENT') { $p->code = "calcule_logo_document($_id_objet, '" . $p->descr['documents'] . '\', $doublons, '. intval($flag_fichier).", $code_lien, '". // #LOGO_DOCUMENT{x,y} donne la taille maxi texte_script($params) ."'," . sql_quote($connect) .")"; } elseif ($connect) { $p->code = "''"; spip_log("Les logos distants ne sont pas prevus"); } else { $p->code = "affiche_logos(calcule_logo('$id_objet', '" . (($suite_logo == '_SURVOL') ? 'off' : (($suite_logo == '_NORMAL') ? 'on' : 'ON')) . "', $_id_objet," . (($suite_logo == '_RUBRIQUE') ? champ_sql("id_rubrique", $p) : (($type_objet == 'RUBRIQUE') ? "quete_parent($_id_objet)" : "''")) . ", '$flag_fichier'), $code_lien)"; } $p->interdire_scripts = false; return $p; } ?> spip/spip/ecrire/balise/formulaire_forum.php0000766000000000000000000000762211236524726022511 0ustar adminadministratorscode = $i($p, $p->code); return $p; } // // Chercher le titre et la configuration d'un forum // valeurs possibles : 'pos'teriori, 'pri'ori, 'abo'nnement // Donner aussi la table de reference pour afficher_groupes[] // http://doc.spip.org/@balise_FORMULAIRE_FORUM_stat function balise_FORMULAIRE_FORUM_stat($args, $filtres) { // Note : ceci n'est pas documente !! // $filtres[0] peut contenir l'url sur lequel faire tourner le formulaire // exemple dans un squelette article.html : [(#FORMULAIRE_FORUM|forum)] // ou encore [(#FORMULAIRE_FORUM|forumspip.php)] // le denier arg peut contenir l'url sur lequel faire le retour // exemple dans un squelette article.html : [(#FORMULAIRE_FORUM{#SELF})] // recuperer les donnees du forum auquel on repond. list ($idr, $idf, $ida, $idb, $ids, $am, $ag, $af, $url) = $args; $idr = intval($idr); $idf = intval($idf); $ida = intval($ida); $idb = intval($idb); $ids = intval($ids); $type = substr($GLOBALS['meta']["forums_publics"],0,3); if ($ida) { $titre = sql_fetsel('accepter_forum AS type, titre', 'spip_articles', "statut = 'publie' AND id_article = $ida"); if ($titre) { if ($titre['type']) $type = $titre['type']; $table = "articles"; } if ($type == 'non') return false; } else { if ($type == 'non') return false; if ($idb) { $titre = sql_fetsel('titre', 'spip_breves', "statut = 'publie' AND id_breve = $idb"); $table = "breves"; } else if ($ids) { $titre = sql_fetsel('nom_site AS titre', 'spip_syndic', "statut = 'publie' AND id_syndic = $ids"); $table = "syndic"; } else if ($idr) { $titre = sql_fetsel('titre', 'spip_rubriques', "statut = 'publie' AND id_rubrique = $idr"); $table = "rubriques"; } } if (!$titre) return false; // inexistant ou non public if ($idf>0) { $titre_m = sql_fetsel('titre', 'spip_forum', "id_forum = $idf"); if (!$titre_m) return false; // URL fabriquee $titre = $titre_m; } if ($GLOBALS['meta']["mots_cles_forums"] != "oui") $table = ''; $titre = supprimer_numero($titre['titre']); // Sur quelle adresse va-t-on "boucler" pour la previsualisation ? // si vide : self() if ($script = $filtres[0]) $script = preg_match(',[.]php3?$,', $script) ? $script : generer_url_public($script); else $script = ''; # sur soi-meme return array($titre, $table, $type, $script, $idr, $idf, $ida, $idb, $ids, $am, $ag, $af, $url); } ?> spip/spip/ecrire/balise/formulaire_ecrire_auteur.php0000766000000000000000000000412011236524726024205 0ustar adminadministrators '#FORMULAIRE_ECRIRE_AUTEUR', 'motif' => 'AUTEURS/ARTICLES')), ''); // Si on est dans un contexte article, // sortir tous les mails des auteurs de l'article if (!$args[0] AND $id) { $r = ''; $s = sql_allfetsel('email', 'spip_auteurs AS A LEFT JOIN spip_auteurs_articles AS L ON A.id_auteur=L.id_auteur', "A.email != '' AND L.id_article=$id"); foreach($s as $row) { if (email_valide($row['email'])) $r .= ','.$row['email']; } $args[2] = substr($r, 1); } // On ne peut pas ecrire a un auteur dont le mail n'est pas valide if (!$args[2] OR !email_valide($args[2])) return ''; // OK return $args; } ?> spip/spip/ecrire/balise/login_public.php0000766000000000000000000000332311236524726021574 0ustar adminadministrators[(#LOGIN_PUBLIC{#SELF, #LOGIN})] // http://doc.spip.org/@balise_LOGIN_PUBLIC_stat function balise_LOGIN_PUBLIC_stat ($args, $filtres) { return array(isset($args[1]) ? $args[1] : $args[0], (isset($args[2]) ? $args[2] : '')); } // http://doc.spip.org/@balise_LOGIN_PUBLIC_dyn function balise_LOGIN_PUBLIC_dyn($url, $login) { include_spip('balise/formulaire_'); if (!$url # pas d'url passee en filtre ou dans le contexte AND !$url = _request('url') # ni d'url passee par l'utilisateur ) $url = parametre_url(self(), '', '', '&'); return balise_FORMULAIRE__dyn('login',$url,$login,false); } ?> spip/spip/ecrire/balise/login_prive.php0000766000000000000000000000331411236524726021443 0ustar adminadministrators[(#LOGIN_PRIVE{#URL_ECRIRE, #LOGIN})] // http://doc.spip.org/@balise_LOGIN_PRIVE_stat function balise_LOGIN_PRIVE_stat ($args, $filtres) { return array(isset($args[1]) ? $args[1] : $args[0], (isset($args[2]) ? $args[2] : '')); } // http://doc.spip.org/@balise_LOGIN_PRIVE_dyn function balise_LOGIN_PRIVE_dyn($url, $login) { include_spip('balise/formulaire_'); if (!$url # pas d'url passee en filtre ou dans le contexte AND !$url = _request('url') # ni d'url passee par l'utilisateur ) $url = generer_url_ecrire('accueil','',true); return balise_FORMULAIRE__dyn('login',$url,$login,true); } ?> spip/spip/ecrire/balise/index.php0000766000000000000000000000000211236524726020224 0ustar adminadministratorsX spip/spip/ecrire/balise/formulaire_inscription.php0000766000000000000000000000272711236524726023723 0ustar adminadministrators spip/spip/ecrire/balise/formulaire_admin.php0000766000000000000000000001362511236524726022451 0ustar adminadministrators $v) { if (strpos($v,'administration.') !== false) return $debug['resultat'][$k . 'tout']; } return ''; } } $dejafait = true; // Preparer le #ENV des boutons $env = admin_objet(); // Pas de "modifier ce..." ? -> donner "acces a l'espace prive" if (!$env) $env['ecrire'] = _DIR_RESTREINT_ABS; $env['divclass'] = $float; $env['lang'] = admin_lang(); $env['calcul'] = (_request('var_mode') ? 'recalcul' : 'calcul'); $env['debug'] = $var_preview ? "" : admin_debug(); $env['analyser'] = (!$env['debug'] AND !$GLOBALS['xhtml']) ? '' : admin_valider(); if (!$use_cache) $env['use_cache'] = ' *'; if (isset($debug['validation'])) { $env['xhtml_error'] = $debug['validation']; } return array('formulaires/administration', 0, $env); } // Afficher le bouton 'Modifier ce...' // s'il y a un $id_XXX defini globalement par spip_register_globals // Attention a l'ordre dans la boucle: // on ne veut pas la rubrique si un autre bouton est possible // http://doc.spip.org/@admin_objet function admin_objet() { include_spip('inc/urls'); $env = array(); foreach (array('mot','auteur','rubrique','breve','article','syndic'=>'site') as $id => $obj) { if (is_int($id)) $id = $obj; $_id_type = id_table_objet($id); if ($id_type = $GLOBALS['contexte'][$_id_type]) { $id_type = sql_getfetsel($_id_type, table_objet_sql($id), "$_id_type=".intval($id_type)); if ($id_type) { $env[$_id_type] = $id_type; $g = 'generer_url_ecrire_'.$obj; $env['voir_'.$obj] = str_replace('&', '&', $g($id_type, '','', 'prop')); if ($id == 'article' OR $id == 'breve') { unset($env['id_rubrique']); unset($env['voir_rubrique']); if ($l = admin_stats($id, $id_type, $var_preview)) { $env['visites'] = $l[0]; $env['popularite'] = $l[1]; $env['statistiques'] = $l[2]; } if (admin_preview($id, $id_type)) $env['preview']=parametre_url(self(),'var_mode','preview','&'); } } } } return $env; } // http://doc.spip.org/@admin_preview function admin_preview($id, $id_type) { if ($GLOBALS['var_preview']) return ''; if (!($id == 'article' OR $id == 'breve' OR $id == 'rubrique' OR $id == 'syndic')) return ''; include_spip('inc/autoriser'); if (!autoriser('previsualiser')) return ''; $notpub = sql_in("statut", array('prop', 'prive')); if ($id == 'article' AND $GLOBALS['meta']['post_dates'] != 'oui') $notpub .= " OR (statut='publie' AND date>".sql_quote(date('Y-m-d H:i:s')).")"; return sql_fetsel('1', table_objet_sql($id), id_table_objet($id)."=".$id_type." AND ($notpub)"); } // // Regler les boutons dans la langue de l'admin (sinon tant pis) // // http://doc.spip.org/@admin_lang function admin_lang() { $alang = sql_getfetsel('lang', 'spip_auteurs', "login=" . sql_quote(preg_replace(',^@,','',@$_COOKIE['spip_admin']))); if (!$alang) return ''; $l = lang_select($alang); $alang = $GLOBALS['spip_lang']; if ($l) lang_select(); return $alang; } // http://doc.spip.org/@admin_valider function admin_valider() { global $xhtml; return ((@$xhtml !== 'true') ? (parametre_url(self(), 'var_mode', 'debug', '&') .'&var_mode_affiche=validation') : ('http://validator.w3.org/check?uri=' . rawurlencode("http://" . $_SERVER['HTTP_HOST'] . nettoyer_uri()))); } // http://doc.spip.org/@admin_debug function admin_debug() { return (($GLOBALS['forcer_debug'] OR $GLOBALS['bouton_admin_debug'] OR ( $GLOBALS['var_mode'] == 'debug' AND $_COOKIE['spip_debug'] ) ) AND autoriser('debug') ) ? parametre_url(self(),'var_mode', 'debug', '&'): ''; } // http://doc.spip.org/@admin_stats function admin_stats($id, $id_type, $var_preview) { if ($GLOBALS['meta']["activer_statistiques"] != "non" AND $id = 'article' AND !$var_preview AND autoriser('voirstats') ) { $row = sql_fetsel("visites, popularite", "spip_articles", "id_article=$id_type AND statut='publie'"); if ($row) { return array(intval($row['visites']), ceil($row['popularite']), str_replace('&', '&', generer_url_ecrire_statistiques($id_type))); } } return false; } ?> spip/spip/ecrire/balise/formulaire_recherche.php0000766000000000000000000000177611236524726023315 0ustar adminadministrators spip/spip/ecrire/balise/url_logout.php0000766000000000000000000000247511236524726021330 0ustar adminadministrators spip/spip/ecrire/balise/formulaire_site.php0000766000000000000000000000265511236524726022326 0ustar adminadministrators '#FORMULAIRE_SITE', 'motif' => 'RUBRIQUES')), ''); // Verifier que les visisteurs sont autorises a proposer un site return (($GLOBALS['meta']["proposer_sites"] != 2) ? '' : $args); } ?> spip/spip/ecrire/balise/menu_lang.php0000766000000000000000000000307011236524726021072 0ustar adminadministrators spip/spip/ecrire/balise/formulaire_signature.php0000766000000000000000000000415411236524726023357 0ustar adminadministrators erreur de squelette if (!$args[0]) return erreur_squelette( _T('zbug_champ_hors_motif', array ('champ' => '#FORMULAIRE_SIGNATURE', 'motif' => 'ARTICLES')), ''); // article sans petition => pas de balise else if (!$args[1]) return ''; else { // aller chercher dans la base la petition associee if ($r = sql_fetsel("texte, site_obli, message", 'spip_petitions', "id_article = ".intval($args[0]))) { $args[2] = $r['texte']; // le signataire doit-il donner un site ? $args[3] = ($r['site_obli'] == 'oui') ? ' ':''; // le signataire peut-il proposer un commentaire $args[4] = ($r['message'] == 'oui') ? ' ':''; } return $args; } } ?> spip/spip/ecrire/balise/menu_lang_ecrire.php0000766000000000000000000000444211236524726022427 0ustar adminadministrators $default) { $opt = lang_select($default); # et remplace if ($GLOBALS['spip_lang'] <> $default) { $default = ''; # annule tout choix par defaut if ($opt) lang_select(); } } $opt = liste_options_langues($nom, $default); if (!$opt) return ''; # lien a partir de / $cible = parametre_url(self(), 'lang' , '', '&'); $post = generer_url_action('converser', 'redirect='. rawurlencode($cible), '&'); return array('formulaires/menu_lang', 3600, array('nom' => $nom, 'url' => $post, 'langues' => $opt ) ); } ?> spip/spip/ecrire/balise/url_.php0000766000000000000000000001433611236524726020075 0ustar adminadministratorsid_boucle; if ($s !== '' AND $s = $p->boucles[$s]->sql_serveur) { // si une fonction de generation des url a ete definie pour ce connect l'utiliser if (function_exists($f = 'generer_generer_url_'.$s)){ return $f($type, $_id, $s); } if (!$GLOBALS['connexions'][$s]['spip_connect_version']) { return NULL; } $s = _q($s); if ($type == 'document') { return "quete_meta('adresse_site', $s) . '/' .\n\t" . "quete_meta('dir_img', $s) . \n\t" . "quete_fichier($_id,$s)"; } $s = ", '', '', $s, quete_meta('type_urls', $s)"; } else $s = ", '', '', true"; return "urlencode_1738(generer_url_entite($_id, '$type'$s))"; } // http://doc.spip.org/@balise_URL__dist function balise_URL__dist($p) { $nom = $p->nom_champ; if ($nom === 'URL_') { erreur_squelette(_T('zbug_info_erreur_squelette'), $nom); $p->code = "''"; $p->interdire_scripts = false; return $p; } elseif ($f = charger_fonction($nom, 'balise', true)) { return $f($p); }else { $code = champ_sql($nom, $p); if (strpos($code, '@$Pile[0]') !== false) { $nom = strtolower(substr($nom,4)); $code = generer_generer_url($nom, $p); if ($code === NULL) return NULL; } $p->code = "vider_url($code)"; $p->interdire_scripts = false; return $p; } } // http://doc.spip.org/@balise_URL_ARTICLE_dist function balise_URL_ARTICLE_dist($p) { // Cas particulier des boucles (SYNDIC_ARTICLES) if ($p->type_requete == 'syndic_articles') { $code = champ_sql('url', $p); } else $code = generer_generer_url('article', $p); $p->code = "vider_url($code)"; $p->interdire_scripts = false; return $p; } // http://doc.spip.org/@balise_URL_SITE_dist function balise_URL_SITE_dist($p) { $code = champ_sql('url_site', $p); if (strpos($code, '@$Pile[0]') !== false) { $code = generer_generer_url('site', $p); if ($code === NULL) return NULL; } else $code = "calculer_url($code,'','url', \$connect)"; $p->code = $code; $p->interdire_scripts = false; return $p; } // Autres balises URL_*, qui ne concernent pas une table // (historique) // http://doc.spip.org/@balise_URL_SITE_SPIP_dist function balise_URL_SITE_SPIP_dist($p) { $p->code = "sinon(\$GLOBALS['meta']['adresse_site'],'.')"; $p->code = "htmlspecialchars(".$p->code.")"; $p->interdire_scripts = false; return $p; } // // #URL_PAGE{backend} -> backend.php3 ou ?page=backend selon les cas // Pour les pages qui commencent par "spip_", il faut eventuellement // aller chercher spip_action.php?action=xxxx // // http://doc.spip.org/@balise_URL_PAGE_dist function balise_URL_PAGE_dist($p) { $p->code = interprete_argument_balise(1,$p); $args = interprete_argument_balise(2,$p); if ($args != "''" && $args!==NULL) $p->code .= ','.$args; // autres filtres (???) array_shift($p->param); if ($p->id_boucle AND $s = $p->boucles[$p->id_boucle]->sql_serveur) { if (!$GLOBALS['connexions'][$s]['spip_connect_version']) { $p->code = "404"; } else { // si une fonction de generation des url a ete definie pour ce connect l'utiliser // elle devra aussi traiter le cas derogatoire type=page if (function_exists($f = 'generer_generer_url_'.$s)){ $p->code = $f('page', $p->code, $s); return $p; } $p->code .= ", 'connect=" . addslashes($s) . "'"; } } $p->code = 'generer_url_public(' . $p->code .')'; #$p->interdire_scripts = true; return $p; } // // #URL_ECRIRE{naviguer} -> ecrire/?exec=naviguer // // http://doc.spip.org/@balise_URL_ECRIRE_dist function balise_URL_ECRIRE_dist($p) { if ($p->boucles[$p->id_boucle]->sql_serveur) { $p->code = 'generer_url_public("404")'; return $p; } $p->code = interprete_argument_balise(1,$p); $args = interprete_argument_balise(2,$p); if ($args != "''" && $args!==NULL) $p->code .= ','.$args; // autres filtres (???) array_shift($p->param); $p->code = 'generer_url_ecrire(' . $p->code .')'; #$p->interdire_scripts = true; return $p; } // // #URL_ACTION_AUTEUR{converser,arg,redirect} -> ecrire/?action=converser&arg=arg&hash=xxx&redirect=redirect // // http://doc.spip.org/@balise_URL_ACTION_AUTEUR_dist function balise_URL_ACTION_AUTEUR_dist($p) { $p->descr['session'] = true; if ($p->boucles[$p->id_boucle]->sql_serveur) { $p->code = 'generer_url_public("404")'; return $p; } $p->code = interprete_argument_balise(1,$p); $args = interprete_argument_balise(2,$p); if (!$args) $args = "''"; $p->code .= ",".$args; $redirect = interprete_argument_balise(3,$p); if ($redirect != "''" && $redirect!==NULL) $p->code .= ",".$redirect; $p->code = "generer_action_auteur(" . $p->code . ")"; $p->interdire_scripts = false; return $p; } ?> spip/spip/ecrire/install/0000777000000000000000000000000011266531664016624 5ustar adminadministratorsspip/spip/ecrire/install/etape_ldap3.php0000766000000000000000000000621111236524726021515 0ustar adminadministrators 0) { $res .= "

    "._T('info_selection_chemin_acces')."

    "; $res .= "
      "; $n = 0; for ($i = 0; $i < $info["count"]; $i++) { $names = $info[$i]["namingcontexts"]; if (is_array($names)) { for ($j = 0; $j < $names["count"]; $j++) { $n++; $res .= "
    • \n"; } } } $res .= "
    "; $res .= _T('info_ou')." "; } $res .= "
    \n"._T('entree_chemin_acces')." "; echo generer_form_ecrire('install', ($res . "\n" . "\n" . "\n" . "\n" . "\n" . "\n" . "\n" . "\n
    " . "" . "\n
    " . bouton_suivant())); echo install_fin_html(); } ?> spip/spip/ecrire/install/etape_4.php0000766000000000000000000000770611236524726020667 0ustar adminadministrators$echec\n". info_progression_etape(3,'etape_','install/', true). "

    "._T('avis_connexion_echec_2')."

    " ); exit; } } if (@file_exists(_FILE_CHMOD_TMP)) include(_FILE_CHMOD_TMP); else redirige_url_ecrire('install'); if (!@file_exists(_FILE_CONNECT_TMP)) redirige_url_ecrire('install'); echo install_debut_html('AUTO', ' onload="document.getElementById(\'suivant\').focus();return false;"'); echo info_progression_etape(4,'etape_','install/'); echo info_etape(_T('info_derniere_etape'), _T('info_utilisation_spip') ); # maintenant on connait le vrai charset du site s'il est deja configure # sinon par defaut lire_meta reglera _DEFAULT_CHARSET # (les donnees arrivent de toute facon postees en _DEFAULT_CHARSET) lire_metas(); if ($login) { include_spip('inc/charsets'); $nom = (importer_charset($nom, _DEFAULT_CHARSET)); $login = (importer_charset($login, _DEFAULT_CHARSET)); $email = (importer_charset($email, _DEFAULT_CHARSET)); # pour le passwd, bizarrement il faut le convertir comme s'il avait # ete tape en iso-8859-1 ; car c'est en fait ce que voit md5.js $pass = unicode2charset(utf_8_to_unicode($pass), 'iso-8859-1'); $mdpass = md5($pass); $htpass = generer_htpass($pass); $alea = creer_uniqid(); $id_auteur = sql_getfetsel("id_auteur", "spip_auteurs", "login=" . sql_quote($login)); if ($id_auteur !== NULL) { sql_updateq('spip_auteurs', array("nom"=> $nom, 'email'=> $email, 'login'=>$login, 'pass'=>$mdpass, 'alea_actuel'=>'', 'alea_futur'=> $alea, 'htpass'=>$htpass, 'statut'=>'0minirezo'), "id_auteur=$id_auteur"); } else { sql_insertq('spip_auteurs', array( 'nom' => $nom, 'email' => $email, 'login' => $login, 'pass' => $mdpass, 'htpass' => $htpass, 'alea_futur' => $alea, 'statut' =>'0minirezo')); } // inserer email comme email webmaster principal // (sauf s'il est vide: cas de la re-installation) if ($email) ecrire_meta('email_webmaster', $email); // Ici on va connecter directement celui qui vient de creer son login // on ne lui met ni cookie d'admin ni connexion longue if ($auth_spip = charger_fonction('auth_spip', 'inc', true) AND $row_auteur = $auth_spip($login, $pass) AND $session = charger_fonction('session', 'inc') AND $cookie_session = $session($row_auteur)) spip_setcookie('spip_session', $cookie_session); } $config = charger_fonction('config', 'inc'); $config(); $suite = "\n" . bouton_suivant(_T('login_espace_prive')); echo generer_form_ecrire('install', $suite); echo install_fin_html(); } ?> spip/spip/ecrire/install/etape_fin.php0000766000000000000000000000326111236524726021270 0ustar adminadministrators spip/spip/ecrire/install/etape_2.php0000766000000000000000000001331311236524726020654 0ustar adminadministrators\n"; if (($db_connect=="0") && $link) { echo "

    "._T('info_connexion_ok')."

    \n"; echo info_progression_etape(2,'etape_','install/'); echo info_etape(_T('menu_aide_installation_choix_base').aide ("install2")); spip_connect_db($adresse_db, 0, $login_db, $pass_db, '',$server_db); echo "\n", '' ; list($checked, $res) = install_etape_2_bases($login_db, $server_db); $hidden = (defined('_SPIP_CHMOD') ? '' : ("\n")) . predef_ou_cache($adresse_db,$login_db,$pass_db, $server_db); echo install_etape_2_form($hidden, $checked, $res, 3); } else { echo info_etape(_T('info_connexion_base')); echo info_progression_etape(1,'etape_','install/',true); echo "

    ", _T('avis_connexion_echec_1'), "

    "; echo "

    "._T('avis_connexion_echec_2')."

    "; echo "

    ", _T('avis_connexion_echec_3'), "

    "; } echo install_fin_html(); } // Liste les bases accessibles, // avec une heuristique pour preselectionner la plus probable // http://doc.spip.org/@install_etape_2_bases function install_etape_2_bases($login_db, $server_db) { $res = install_etape_liste_bases($server_db); if ($res) { list($checked, $bases) = $res; return array($checked, "" . "
      \n
    • " . join("
    • \n
    • ",$bases) . "
    • \n

    " . _T('info_ou') . " " ); } $res = ""._T('avis_lecture_noms_bases_1')." "._T('avis_lecture_noms_bases_2')."

    "; if ($login_db) { // Si un login comporte un point, le nom de la base est plus // probablement le login sans le point -- testons pour savoir $test_base = $login_db; $ok = sql_selectdb($test_base, $server_db); $test_base2 = str_replace('.', '_', $test_base); if (sql_selectdb($test_base2, $server_db)) { $test_base = $test_base2; $ok = true; } if ($ok) { $res .= _T('avis_lecture_noms_bases_3') . "

      " . "
    • " . "
    • \n" . "
    " . "

    "._T('info_ou')." "; $checked = true; } } return array($checked, $res); } // http://doc.spip.org/@install_etape_2_form function install_etape_2_form($hidden, $checked, $res, $etape) { return generer_form_ecrire('install', ( "\n" . $hidden . (defined('_INSTALL_NAME_DB') ? '

    '._T('install_nom_base_hebergeur'). ' '._INSTALL_NAME_DB.''.'

    ' : "\n
    "._T('texte_choix_base_1')."\n" . $res . "\n\n

    \n

    " . "\n

    \n" ) . ((defined('_INSTALL_TABLE_PREFIX') OR $GLOBALS['table_prefix'] != 'spip') ? '

    '._T('install_table_prefix_hebergeur').' '.$GLOBALS['table_prefix'].''.'

    ' : "
    "._T('texte_choix_table_prefix')."\n" . "

    " . "\n

    " ) . bouton_suivant())); } ?> spip/spip/ecrire/install/etape_ldap4.php0000766000000000000000000000706311236524726021524 0ustar adminadministrators"._T('avis_operation_echec')."

    "._T('avis_chemin_invalide_1'), " (".htmlspecialchars($base_ldap).") "._T('avis_chemin_invalide_2')."

    "; } else { info_etape(_T('info_reglage_ldap')); echo info_progression_etape(4,'etape_ldap','install/'); lire_fichier(_FILE_CONNECT_TMP, $conn); if ($p = strpos($conn, "'');")) { ecrire_fichier(_FILE_CONNECT_TMP, substr($conn, 0, $p+1) . _FILE_LDAP . substr($conn, $p+1)); } $conn = "\$GLOBALS['ldap_base'] = \"$base_ldap\";\n" . "\$GLOBALS['ldap_link'] = @ldap_connect(\"$adresse_ldap\",\"$port_ldap\");\n" . "@ldap_set_option(\$GLOBALS['ldap_link'],LDAP_OPT_PROTOCOL_VERSION,\"$protocole_ldap\");\n" . (($tls_ldap != 'oui') ? '' : "@ldap_start_tls(\$GLOBALS['ldap_link']);\n") . "@ldap_bind(\$GLOBALS['ldap_link'],\"$login_ldap\",\"$pass_ldap\");\n"; install_fichier_connexion(_DIR_CONNECT . _FILE_LDAP, $conn); $statuts = liste_statuts_ldap(); $statut_ldap = defined('_INSTALL_STATUT_LDAP') ? _INSTALL_STATUT_LDAP : $GLOBALS['liste_des_statuts']['info_redacteurs']; echo generer_form_ecrire('install', ( "" . fieldset(_T('info_statut_utilisateurs_1'), array( 'statut_ldap' => array( 'label' => _T('info_statut_utilisateurs_2').'
    ', 'valeur' => $statut_ldap, 'alternatives' => $statuts ) ) ) . bouton_suivant())); } echo install_fin_html(); } // http://doc.spip.org/@liste_statuts_ldap function liste_statuts_ldap() { $recom = array("info_administrateurs" => ("" ._T('info_administrateur_1')." "._T('info_administrateur_2')."
    "), "info_redacteurs" => (""._T('info_redacteur_1')." "._T('info_redacteur_2')."
    "), "info_visiteurs" => (""._T('info_visiteur_1')." "._T('info_visiteur_2')."
    ")); $res = array(); foreach($GLOBALS['liste_des_statuts'] as $k => $v) { if (isset($recom[$k])) $res[$v] = $recom[$k]; } return $res; } ?> spip/spip/ecrire/install/etape_3.php0000766000000000000000000002547511236524726020671 0ustar adminadministrators"; } } // on rejoue la connexion apres avoir teste si il faut lui indiquer // un sql_mode test_sql_mode_mysql($server_db); $GLOBALS['connexions'][$server_db] = spip_connect_db($adresse_db, $sel_db, $login_db, $pass_db, $sel_db, $server_db); $GLOBALS['connexions'][$server_db][$GLOBALS['spip_sql_version']] = $GLOBALS['spip_' . $server_db .'_functions_' . $GLOBALS['spip_sql_version']]; // Completer le tableau decrivant la connexion $GLOBALS['connexions'][$server_db]['prefixe'] = $table_prefix; $GLOBALS['connexions'][$server_db]['db'] = $sel_db; $old = sql_showbase($table_prefix . "_meta", $server_db); if ($old) $old = sql_fetch($old, $server_db); if (!$old) { // Si possible, demander au serveur d'envoyer les textes // dans le codage std de SPIP, $charset = sql_get_charset(_DEFAULT_CHARSET, $server_db); if ($charset) { sql_set_charset($charset['charset'], $server_db); $GLOBALS['meta']['charset_sql_base'] = $charset['charset']; $GLOBALS['meta']['charset_collation_sql_base'] = $charset['collation']; $GLOBALS['meta']['charset_sql_connexion'] = $charset['charset']; $charsetbase = $charset['charset']; } else { spip_log(_DEFAULT_CHARSET . " inconnu du serveur SQL"); $charsetbase = 'standard'; } spip_log("Creation des tables. Codage $charsetbase"); creer_base($server_db); // AT LAST creer_base_types_doc($server_db); // memoriser avec quel charset on l'a creee if ($charset) { $t = array('nom' => 'charset_sql_base', 'valeur' => $charset['charset'], 'impt' => 'non'); @sql_insertq('spip_meta', $t, '', $server_db); $t['nom'] = 'charset_collation_sql_base'; $t['valeur'] = $charset['collation']; @sql_insertq('spip_meta', $t, '', $server_db); $t['nom'] = 'charset_sql_connexion'; $t['valeur'] = $charset['charset']; @sql_insertq('spip_meta', $t, '', $server_db); } $t = array('nom' => 'version_installee', 'valeur' => $spip_version_base, 'impt' => 'non'); @sql_insertq('spip_meta', $t, '', $server_db); $t['nom'] = 'nouvelle_install'; $t['valeur'] = 1; @sql_insertq('spip_meta', $t, '', $server_db); // positionner la langue par defaut du site si un cookie de lang a ete mis if (isset($_COOKIE['spip_lang_ecrire'])){ @sql_insertq('spip_meta', array('nom'=>'langue_site','valeur'=>$_COOKIE['spip_lang_ecrire']), '', $server_db); } } else { // pour recreer les tables disparues au besoin spip_log("Table des Meta deja la. Verification des autres."); creer_base($server_db); $fupdateq = sql_serveur('updateq', $server_db); $r = $fquery("SELECT valeur FROM spip_meta WHERE nom='version_installee'", $server_db); if ($r) $r = sql_fetch($r, $server_db); $version_installee = !$r ? 0 : (double) $r['valeur']; if (!$version_installee OR ($spip_version_base < $version_installee)) { $fupdateq('spip_meta', array('valeur'=>$spip_version_base, 'impt'=>'non'), "nom='version_installee'", $server_db); spip_log("nouvelle version installee: $spip_version_base"); } // eliminer la derniere operation d'admin mal terminee // notamment la mise a jour @$fquery("DELETE FROM spip_meta WHERE nom='import_all' OR nom='admin'", $server_db); } $ligne_rappel = ($server_db != 'mysql') ? '' : (test_rappel_nom_base_mysql($server_db) .test_sql_mode_mysql($server_db) ); $result_ok = @$fquery("SELECT COUNT(*) FROM spip_meta", $server_db); if (!$result_ok) return ""; if ($chmod_db) { install_fichier_connexion(_FILE_CHMOD_TMP, "@define('_SPIP_CHMOD', ". sprintf('0%3o',$chmod_db).");\n"); } if (preg_match(',(.*):(.*),', $adresse_db, $r)) list(,$adresse_db, $port) = $r; else $port = ''; install_fichier_connexion(_FILE_CONNECT_TMP, $ligne_rappel . install_connexion($adresse_db, $port, $login_db, $pass_db, $sel_db, $server_db, $table_prefix)); return ''; } // http://doc.spip.org/@install_propose_ldap function install_propose_ldap() { return generer_form_ecrire('install', ( fieldset(_T('info_authentification_externe'), array( 'etape' => array( 'label' => _T('texte_annuaire_ldap_1'), 'valeur' => 'ldap1', 'hidden' => true )), bouton_suivant(_T('bouton_acces_ldap')) ))); } // http://doc.spip.org/@install_premier_auteur function install_premier_auteur($email, $login, $nom, $pass, $hidden) { return info_progression_etape(3,'etape_','install/') . info_etape(_T('info_informations_personnelles'), ""._T('texte_informations_personnelles_1')."" . aide ("install5") . "

    " . _T('texte_informations_personnelles_2') . " " . _T('info_laisser_champs_vides') ) . generer_form_ecrire('install', ( "\n" . $hidden . fieldset(_T('info_identification_publique'), array( 'nom' => array( 'label' => ""._T('entree_signature')."
    \n"._T('entree_nom_pseudo_1')."\n", 'valeur' => $nom ), 'email' => array( 'label' => ""._T('entree_adresse_email')."\n", 'valeur' => $email ) ) ) . fieldset(_T('entree_identifiants_connexion'), array( 'login' => array( 'label' => ""._T('entree_login')."
    \n"._T('info_plus_trois_car')."\n", 'valeur' => $login ), 'pass' => array( 'label' => ""._T('entree_mot_passe')."
    \n"._T('info_plus_cinq_car_2')."\n", 'valeur' => $pass ), 'pass_verif' => array( 'label' => ""._T('info_confirmer_passe')."
    \n", 'valeur' => $pass ) ) ) . bouton_suivant())); } // http://doc.spip.org/@install_etape_3_dist function install_etape_3_dist() { $ldap_present = _request('ldap_present'); if (!$ldap_present) { $adresse_db = defined('_INSTALL_HOST_DB') ? _INSTALL_HOST_DB : _request('adresse_db'); $login_db = defined('_INSTALL_USER_DB') ? _INSTALL_USER_DB : _request('login_db'); $pass_db = defined('_INSTALL_PASS_DB') ? _INSTALL_PASS_DB : _request('pass_db'); $server_db = defined('_INSTALL_SERVER_DB') ? _INSTALL_SERVER_DB : _request('server_db'); $chmod_db = defined('_SPIP_CHMOD') ? _SPIP_CHMOD : _request('chmod'); $choix_db = defined('_INSTALL_NAME_DB') ? _INSTALL_NAME_DB : _request('choix_db'); $sel_db = ($choix_db == "new_spip") ? _request('table_new') : $choix_db; $res = install_bases($adresse_db, $login_db, $pass_db, $server_db, $choix_db, $sel_db, $chmod_db); if ($res) { $res .= info_progression_etape(2,'etape_','install/', true); $res .= "

    "._T('avis_operation_echec')."

    "._T('texte_operation_echec'); } } else { $res = ''; list($adresse_db, $login_db, $pass_db, $sel_db, $server_db) = analyse_fichier_connection(_FILE_CONNECT_TMP); } if (!$res) { if (file_exists(_FILE_CONNECT_TMP)) include(_FILE_CONNECT_TMP); else redirige_url_ecrire('install'); if (file_exists(_FILE_CHMOD_TMP)) include(_FILE_CHMOD_TMP); else redirige_url_ecrire('install'); $hidden = predef_ou_cache($adresse_db, $login_db, $pass_db, $server_db) . (defined('_INSTALL_NAME_DB') ? '' : "\n"); $res = "

    " . _T('info_base_installee') . "

    " . install_premier_auteur(_request('email'), _request('login'), _request('nom'), _request('pass'), $hidden) . (($ldap_present OR !function_exists('ldap_connect')) ? '' : install_propose_ldap()); } echo install_debut_html(); echo $res; echo install_fin_html(); } // Tester si mysql ne veut pas du nom de la base dans les requetes // http://doc.spip.org/@test_rappel_nom_base_mysql function test_rappel_nom_base_mysql($server_db) { $GLOBALS['mysql_rappel_nom_base'] = true; sql_delete('spip_meta', "nom='mysql_rappel_nom_base'", $server_db); $ok = spip_query("INSERT INTO spip_meta (nom,valeur) VALUES ('mysql_rappel_nom_base', 'test')", $server_db); if ($ok) { sql_delete('spip_meta', "nom='mysql_rappel_nom_base'", $server_db); return ''; } else { $GLOBALS['mysql_rappel_nom_base'] = false; return "\$GLOBALS['mysql_rappel_nom_base'] = false; ". "/* echec de test_rappel_nom_base_mysql a l'installation. */\n"; } } // http://doc.spip.org/@test_sql_mode_mysql function test_sql_mode_mysql($server_db){ $res = sql_select("version() as v",'','','','','','',$server_db); $row = sql_fetch($res,$server_db); if (version_compare($row['v'],'5.0.0','>=')){ define('_MYSQL_SET_SQL_MODE',true); return "define('_MYSQL_SET_SQL_MODE',true);\n"; } return ''; } ?> spip/spip/ecrire/install/index.php0000766000000000000000000000000211236524726020433 0ustar adminadministratorsX spip/spip/ecrire/install/etape_sup1.php0000766000000000000000000000745411236524726021414 0ustar adminadministrators'; echo "\n\n

    "; echo _T('info_connexion_ok'),"

    \n"; echo '' ; $l = bases_referencees(); array_push($l, $sel_db); list(, $res) = install_etape_liste_bases($server_db, $l); $hidden = predef_ou_cache($adresse_db,$login_db,$pass_db, $server_db) . (defined('_INSTALL_NAME_DB') ? '' : ("\n\n")); echo install_etape_sup1_form($hidden, $checked, $res, 'sup2'); echo '
    '; } else { echo info_etape(_T('info_connexion_base')); echo "

    ", _T('avis_connexion_echec_1'), "

    "; } echo install_fin_html(); } // http://doc.spip.org/@install_etape_sup1_form function install_etape_sup1_form($hidden, $checked, $bases, $etape) { if ($bases) { $bases = "\n
    " . _T('config_titre_base_sup_choix') . "\n" . "
      \n
    • " . join("
    • \n
    • ",$bases) . "
    • \n

    " . _T('info_ou'); $type = " type='radio'" . ($checked ? '' : " checked='checked'"); } else { $bases = _T('config_erreur_base_sup') . '

    '; $type = " type='hidden'"; } return generer_form_ecrire('install', ( "\n" . $hidden . $bases . "\n\n" . "

    \n" . "\n

    \n" . bouton_suivant())); } ?> spip/spip/ecrire/install/etape_sup2.php0000766000000000000000000000721211236524726021405 0ustar adminadministrators"; $GLOBALS['connexions'][$server_db][$GLOBALS['spip_sql_version']] = $GLOBALS['spip_' . $server_db .'_functions_' . $GLOBALS['spip_sql_version']]; if (!sql_selectdb($sup_db, $server_db)) return ""; $q = sql_showbase('%', $server_db); $tables = ''; while($r = sql_fetch($q)) { $tables .= "
  • " . array_shift($r) . "
  • \n"; } if (!$tables) $res = _T('install_pas_table'); else { $res = _T('install_tables_base') . "
      " . $tables . "
    \n"; } if (preg_match(',(.*):(.*),', $adresse_db, $r)) list(,$adresse_db, $port) = $r; else $port = ''; $conn = "spip_connect_db(" . "'$adresse_db','$port','$login_db','" . addcslashes($pass_db, "'\\") . "','$sup_db'" . ",'$server_db', '');\n"; install_fichier_connexion(_DIR_CONNECT . $sup_db . '.php', $conn); return '
    ' . $res . '
    '; } // http://doc.spip.org/@install_etape_sup2_dist function install_etape_sup2_dist() { $adresse_db = _request('adresse_db'); if (!$adresse_db AND defined('_INSTALL_HOST_DB')) $adresse_db =_INSTALL_HOST_DB; $login_db = _request('login_db'); if (!$login_db AND defined('_INSTALL_USER_DB')) $login_db = _INSTALL_USER_DB; $pass_db = _request('pass_db'); if (!$pass_db AND defined('_INSTALL_PASS_DB')) $pass_db = _INSTALL_PASS_DB; $server_db =_request('server_db'); if (!$server_db AND defined('_INSTALL_SERVER_DB')) $server_db = _INSTALL_SERVER_DB; // Ceci indique la base principale (passe en hidden) // pour qu'on la refuse comme choix de base secondaire a chaque tour. $sel_db =_request('sel_db'); if (!$sel_db AND defined('_INSTALL_NAME_DB')) $sel_db = _INSTALL_NAME_DB; // le choix $choix_db = _request('choix_db'); if (is_numeric($choix_db)) $choix_db = _request('table_new'); if (!$choix_db) $res = ""; else { $res = install_bases_sup($adresse_db, $login_db, $pass_db, $server_db, $choix_db); if ($res[1]=='!') $res .= "

    "._T('avis_operation_echec')."

    "; else { $res = "

    " . _T('base_reconnue', array('base' => $choix_db)) . "

    " . $res; } } $res .= generer_form_ecrire('admin_declarer', (defined('_INSTALL_NAME_DB') ? '' : ("\n")) . predef_ou_cache($adresse_db,$login_db,$pass_db, $server_db) . bouton_suivant()); echo install_debut_html(_T('config_titre_base_sup')); echo $res; echo install_fin_html(); } ?> spip/spip/ecrire/install/etape_.php0000766000000000000000000000270311236524726020573 0ustar adminadministratorsSPIP\n" . "

    " .info_copyright() ."

    \n" . "

    " ._T('install_select_langue') ."

    " . "
    " .$menu_langues ."
    \n" . generer_form_ecrire('install', "" . bouton_suivant()); echo minipres('AUTO', $res); } } ?> spip/spip/ecrire/install/etape_ldap2.php0000766000000000000000000000555711236524726021530 0ustar adminadministrators" . "\n" . "\n" . "\n" . "\n" . "\n" . "\n" . bouton_suivant())); } else { echo info_etape(_T('titre_connexion_ldap')), info_progression_etape(1,'etape_ldap','install/', true), "

    "._T('avis_connexion_ldap_echec_1')."

    ", "

    "._T('avis_connexion_ldap_echec_2'). "
    \n"._T('avis_connexion_ldap_echec_3') . '

    '. $erreur. ' ?

    ' ; } echo install_fin_html(); } ?> spip/spip/ecrire/install/etape_1.php0000766000000000000000000000436611236524726020663 0ustar adminadministrators' . _T('texte_connexion_mysql') .'

    ' ); echo install_connexion_form($db, $login, $pass, $predef, "\n", 2); echo install_fin_html(); } ?> spip/spip/ecrire/install/etape_ldap1.php0000766000000000000000000000503111236524726021512 0ustar adminadministrators" . fieldset(_T('entree_adresse_annuaire'), array( 'adresse_ldap' => array( 'label' => _T('texte_adresse_annuaire_1'), 'valeur' => $adresse_ldap ), 'port_ldap' => array( 'label' => _T('entree_port_annuaire').'
    '._T('texte_port_annuaire'), 'valeur' => $port_ldap ), 'tls_ldap' => array( 'label' => ''._T('tls_ldap').'', 'valeur' => $tls_ldap, 'alternatives' => array( 'non' => _T('item_non'), 'oui' => _T('item_oui') ) ), 'protocole_ldap' => array( 'label' => _T('protocole_ldap'), 'valeur' => $protocole_ldap, 'alternatives' => array( '3' => '3', '2' => '2' ) ) ) ) . "\n

    "._T('texte_acces_ldap_anonyme_1').'

    ' . fieldset(_T('connexion_ldap'), array( 'login_ldap' => array( 'label' => _T('texte_login_ldap_1'), 'valeur' => '' ), 'pass_ldap' => array( 'label' => _T('entree_passe_ldap'), 'valeur' => '' ) ) ) . bouton_suivant())); echo install_fin_html(); } ?> spip/spip/ecrire/install/etape_chmod.php0000766000000000000000000001013111236524726021600 0ustar adminadministrators 0 && $uid == $uid2 && @fileowner('test') == $uid) $chmod = 0700; else if ($gid > 0 && $gid == $gid2 && @filegroup('test') == $gid) $chmod = 0770; else $chmod = 0777; // Appliquer de plus les droits d'acces du script if ($perms > 0) { $perms = ($perms & 0777) | (($perms & 0444) >> 2); $chmod |= $perms; } spip_unlink('test'); } // Verifier que les valeurs sont correctes $f = @fopen($my_dir.'test.php', 'w'); if ($f) { @fputs($f, '<'.'?php $ok = true; ?'.'>'); @fclose($f); @chmod($my_dir.'test.php', $chmod); include($my_dir.'test.php'); } spip_unlink($my_dir.'test.php'); return $ok?$chmod:false; } // // tester les droits en ecriture sur les repertoires // rajouter celui passe dans l'url ou celui du source (a l'installation) // // http://doc.spip.org/@install_etape_chmod_dist function install_etape_chmod_dist() { global $test_dirs; $test_dir = _request('test_dir'); $chmod = 0; if ($test_dir) { if (substr($test_dir,-1)!=='/') $test_dir .= '/'; if (!in_array($test_dir, $test_dirs)) $test_dirs[] = _DIR_RACINE . $test_dir; } else { if (!_FILE_CONNECT) { $test_dirs[] = _DIR_CONNECT; $test_dirs[] = _DIR_CHMOD; } } $bad_dirs = array(); $absent_dirs = array();; while (list(, $my_dir) = each($test_dirs)) { $test = test_ecrire($my_dir); if (!$test) { $m = preg_replace(',^' . _DIR_RACINE . ',', '',$my_dir); if (@file_exists($my_dir)) { $bad_dirs["
  • ".$m."
  • "] = 1; } else $absent_dirs["
  • ".$m."
  • "] = 1; } else $chmod = max($chmod, $test); } if ($bad_dirs OR $absent_dirs) { if (!_FILE_CONNECT) { $titre = _T('dirs_preliminaire'); $continuer = ' '._T('dirs_commencer') . '.'; } else $titre = _T('dirs_probleme_droits'); $res = "
    ". menu_langues('var_lang_ecrire')."
    \n"; if ($bad_dirs) { $res .= _T('dirs_repertoires_suivants', array('bad_dirs' => join("\n", array_keys($bad_dirs)))) . "". _T('login_recharger')."."; } if ($absent_dirs) { $res .= _T('dirs_repertoires_absents', array('bad_dirs' => join("\n", array_keys($absent_dirs)))) . "". _T('login_recharger')."."; } $res = "

    " . $continuer . $res . aide ("install0") . "

    "; $t = _T('login_recharger'); $t = (!$test_dir ? "" : "") . "" . "
    "; echo minipres($titre, $res . generer_form_ecrire('install', $t)); } else { if (!_FILE_CONNECT) redirige_url_ecrire("install", "etape=1&chmod=".$chmod); else redirige_url_ecrire(); } } ?> spip/spip/ecrire/install/etape_ldap5.php0000766000000000000000000000264311236524726021524 0ustar adminadministrators" . "" . bouton_suivant())); echo install_fin_html(); } ?> spip/spip/ecrire/configuration/0000777000000000000000000000000011266531713020020 5ustar adminadministratorsspip/spip/ecrire/configuration/visiteurs.php0000766000000000000000000000335611236524726022601 0ustar adminadministrators" . "\n" . _T('info_question_accepter_visiteurs') . "" . "\n" . afficher_choix('accepter_visiteurs', $GLOBALS['meta']['accepter_visiteurs'], array('oui' => _T('info_option_accepter_visiteurs'), 'non' => _T('info_option_ne_pas_accepter_visiteurs'))) . "\n"; $res = ajax_action_post('configurer', 'visiteurs', 'config_contenu','',$res); } else { $res = _T('info_forums_abo_invites'); } $res = debut_cadre_trait_couleur("redacteurs-24.gif", true, "", _T('info_visiteurs')) . $res . fin_cadre_trait_couleur(true); return ajax_action_greffe('configurer-visiteurs', '', $res); } ?> spip/spip/ecrire/configuration/langue.php0000766000000000000000000000334311236524726022013 0ustar adminadministrators$langue_site\n"; foreach (split(",",$GLOBALS['meta']['langues_proposees']) as $l) { if ($l <> $l_site) $res .= "\n"; } $res = ajax_action_post('configurer', 'langue', 'config_lang', '', "" . " : \n", '', " class='fondo'"); $res = debut_cadre_couleur("langues-24.gif", true, "", _T('info_langue_principale') . " : " . $langue_site) . _T('texte_selection_langue_principale') . $res . fin_cadre_couleur(true); return ajax_action_greffe("configurer-langue", '', $res); } ?> spip/spip/ecrire/configuration/compresseur.php0000766000000000000000000000557711236524726023122 0ustar adminadministrators" . _T('texte_compresseur_page') . "

    " . "

    " . _T('info_compresseur_gzip', array('testgzip' => propre('[->http://www.gidnetwork.com/tools/gzip-test.php]')) ) . "

    " . "
    " . "

    " . _T('info_question_activer_compresseur') . "

    " . afficher_choix('auto_compress_http', ($GLOBALS['meta']['auto_compress_http'] != 'non') ? 'oui' : 'non', array( 'oui' => _T('item_compresseur'), 'non' => _T('item_non_compresseur') ) ) . "
    " . fin_cadre_relief(true); } // Compression des scripts et css $res .= debut_cadre_relief("", true, "", _T('titre_compacter_script_css')) . "

    " . _T('texte_compacter_script_css') . " " . "

    " . "
    " . "

    " . _T('info_question_activer_compactage_js') . "

    " . afficher_choix('auto_compress_js', ($GLOBALS['meta']['auto_compress_js'] != 'non') ? 'oui' : 'non', array( 'oui' => _T('item_compresseur'), 'non' => _T('item_non_compresseur') ) ) . "
    " . "
    " . "

    " . _T('info_question_activer_compactage_css') . "

    " . afficher_choix('auto_compress_css', ($GLOBALS['meta']['auto_compress_css'] != 'non') ? 'oui' : 'non', array( 'oui' => _T('item_compresseur'), 'non' => _T('item_non_compresseur') ) ) . "
    " . "

    "._T('texte_compacter_avertissement')."

    " . fin_cadre_relief(true); $res = '
    '.debut_cadre_trait_couleur("", true, "", _T('info_compresseur_titre')) . ajax_action_post('configurer', 'compresseur', 'config_fonctions', '', $res) . fin_cadre_trait_couleur(true); return ajax_action_greffe("configurer-compresseur", '', $res); } ?> spip/spip/ecrire/configuration/messagerie_agenda.php0000766000000000000000000000261011236524726024157 0ustar adminadministrators" . _T('texte_messagerie_agenda') . "
    \n" . afficher_choix('messagerie_agenda', $GLOBALS['meta']['messagerie_agenda'], array('oui' => _T('item_messagerie_agenda'), 'non' => _T('item_non_messagerie_agenda'))) . ""; $res = debut_cadre_trait_couleur("messagerie-24.gif", true, "", _T('titre_messagerie_agenda')) . ajax_action_post('configurer', 'messagerie_agenda', 'config_contenu','',$res) . fin_cadre_trait_couleur(true); return ajax_action_greffe('configurer-messagerie_agenda', '', $res); } ?> spip/spip/ecrire/configuration/referenceur.php0000766000000000000000000000522111236524726023042 0ustar adminadministrators"._T('texte_multilinguisme')."

    " . "
    " . _T('info_multi_articles') . "
    " . afficher_choix('multi_articles', $GLOBALS['meta']['multi_articles'], array('oui' => _T('item_oui'), 'non' => _T('item_non')), "   ") . "
    " . "
    " . "
    " . _T('info_multi_rubriques') . "
    " . afficher_choix('multi_rubriques', $GLOBALS['meta']['multi_rubriques'], array('oui' => _T('item_oui'), 'non' => _T('item_non')), "   ") . "
    " . "
    "; if ($GLOBALS['meta']['multi_rubriques'] == 'oui') { $res .= "\n
    " . _T('info_multi_secteurs') . "
    " . afficher_choix('multi_secteurs', $GLOBALS['meta']['multi_secteurs'], array('oui' => _T('item_oui'), 'non' => _T('item_non')), "   ") . "
    " . "
    "; } else $res .= ""; if (($GLOBALS['meta']['multi_rubriques'] == 'oui') OR ($GLOBALS['meta']['multi_articles'] == 'oui')) { $res .= "
    " . "

    "._T('texte_multilinguisme_trad')."

    "; $res .= _T('info_gerer_trad') . "
    " . afficher_choix('gerer_trad', $GLOBALS['meta']['gerer_trad'], array('oui' => _T('item_oui'), 'non' => _T('item_non')), "   ") . "
    "; } else $res .= ""; $res = debut_cadre_couleur("traductions-24.gif", true, "", _T('info_multilinguisme')) . ajax_action_post('configurer', 'referenceur', 'config_multilang', '', $res) . fin_cadre_couleur(true); return ajax_action_greffe("configurer-referenceur", '', $res); } ?> spip/spip/ecrire/configuration/accueil.php0000766000000000000000000000462211236524726022146 0ustar adminadministrators"._T('info_nom_site')."".aide ("confnom")) . "" . fin_cadre_relief(true) . debut_cadre_relief("", true, "", "") . "" . fin_cadre_relief(true) . debut_cadre_relief("", true, "","") . "" . fin_cadre_relief(true) . "
     
    " . debut_cadre_relief("", true, "", "") . "" . fin_cadre_relief(true); } function configuration_accueil_dist() { $res = configuration_bloc_votre_site(); $res = debut_cadre_couleur("racine-site-24.gif", true). ajax_action_post('configurer', 'accueil', 'configuration','',$res) . fin_cadre_couleur(true) ; return ajax_action_greffe('configurer-accueil','', $res); } ?> spip/spip/ecrire/configuration/redacteurs.php0000766000000000000000000000316311236524726022701 0ustar adminadministrators" . "\n" # . "

    " . _T('info_question_inscription_nouveaux_redacteurs') # . "

    " . "" . "\n" . afficher_choix('accepter_inscriptions', $GLOBALS['meta']["accepter_inscriptions"], array('oui' => _T('item_accepter_inscriptions'), 'non' => _T('item_non_accepter_inscriptions')), "   ") . "\n" . "\n"; $res = debut_cadre_trait_couleur("redacteurs-24.gif", true, "", _T('info_inscription_automatique')) . ajax_action_post('configurer', 'redacteurs', 'config_contenu','',$res) . fin_cadre_trait_couleur(true); return ajax_action_greffe('configurer-redacteurs', '', $res); } ?> spip/spip/ecrire/configuration/relayeur.php0000766000000000000000000001137511236524726022374 0ustar adminadministrators" . "" . "

    " . "\n

    " . "" . "

    "; if($retour_proxy) { $res .= debut_boite_info(true) . $retour_proxy . fin_boite_info(true); } $submit = array('valider_proxy' => _T('bouton_valider'), 'tester_proxy' => _T('bouton_test_proxy')); } } $encours = "' ; $exemple = ""; $res = "\n
    " . propre(_T('texte_proxy', array('proxy_en_cours' => "$encours"))) . "
    " . "\n
    " . "" . "
    " . propre(_T('pas_de_proxy_pour', array('exemple' => "$exemple"))) . "" . $res . "
    "; $res = debut_cadre_trait_couleur("base-24.gif", true, "", _T('info_sites_proxy').aide ("confhttpproxy")) . ajax_action_post('configurer_relayeur', 0, 'config_fonctions', '', $res, $submit) . fin_cadre_trait_couleur(true); return ajax_action_greffe("configurer_relayeur", 0, $res); } function configuration_relayeur_post ($http_proxy, $http_noproxy, $test_proxy, $tester_proxy) { // http_proxy : ne pas prendre en compte la modif si le password est '****' if (preg_match(',:\*\*\*\*@,', $http_proxy)) $http_proxy = $GLOBALS['meta']['http_proxy']; $retour = ''; if ($tester_proxy AND preg_match(",https?://,", $http_proxy)) { include_spip('inc/distant'); $t = parse_url($test_proxy); if (!@$t['host']) { $retour = _T('info_adresse_non_indiquee'); } else { include_spip('inc/texte'); // pour aide, couper, lang if (!need_proxy($t['host'])) $page = "

    "._T('page_pas_proxy')."

    \n"; $page = recuperer_page($test_proxy, true); if ($page) $retour = "

    "._T('info_proxy_ok')."

    \n".couper(entites_html($page),300).""; else $retour = _T('info_impossible_lire_page', array('test_proxy' => $test_proxy)) . " ".no_password_proxy_url($http_proxy)."." . aide('confhttpproxy'); } } if ($http_proxy !== NULL) { ecrire_meta('http_proxy', $http_proxy); } if ($http_noproxy !== NULL) { ecrire_meta('http_noproxy', $http_noproxy); } return $retour; } // Function glue_url : le pendant de parse_url // http://doc.spip.org/@glue_url function glue_url ($url){ if (!is_array($url)){ return false; } // scheme $uri = (!empty($url['scheme'])) ? $url['scheme'].'://' : ''; // user & pass if (!empty($url['user'])){ $uri .= $url['user'].':'.$url['pass'].'@'; } // host $uri .= $url['host']; // port $port = (!empty($url['port'])) ? ':'.$url['port'] : ''; $uri .= $port; // path $uri .= $url['path']; // fragment or query if (isset($url['fragment'])){ $uri .= '#'.$url['fragment']; } elseif (isset($url['query'])){ $uri .= '?'.$url['query']; } return $uri; } // Ne pas afficher la partie 'password' du proxy // http://doc.spip.org/@no_password_proxy_url function no_password_proxy_url($http_proxy) { if ($p = @parse_url($http_proxy) AND $p['pass']) { $p['pass'] = '****'; $http_proxy = glue_url($p); } return $http_proxy; } ?> spip/spip/ecrire/configuration/versionneur.php0000766000000000000000000000270111236524726023114 0ustar adminadministrators" . _T('info_historique_texte') . "" . "
    " . afficher_choix('articles_versions', $GLOBALS['meta']["articles_versions"], array('oui' => _T('info_historique_activer'), 'non' => _T('info_historique_desactiver'))) . "
    "; $res = debut_cadre_trait_couleur("historique-24.gif", true, "", _T('info_historique_titre').aide("suivimodif")) . ajax_action_post('configurer', 'versionneur', 'config_fonctions', '', $res) . fin_cadre_trait_couleur(true); return ajax_action_greffe("configurer-versionneur", '', $res); } ?> spip/spip/ecrire/configuration/breves.php0000766000000000000000000000314011236524726022021 0ustar adminadministrators" . "" . _T('texte_breves')."
    \n" . _T('info_breves') . "" . "" . afficher_choix('activer_breves', $activer_breves, array('oui' => _T('item_utiliser_breves'), 'non' => _T('item_non_utiliser_breves')), "   ") . "\n" . "\n"; $res = debut_cadre_trait_couleur("breve-24.gif", true, "", _T('titre_breves').aide ("confbreves")) . ajax_action_post('configurer', 'breves', 'configuration','',$res) . fin_cadre_trait_couleur(true); return ajax_action_greffe('configurer-breves', '', $res); } ?> spip/spip/ecrire/configuration/indexeur.php0000766000000000000000000000275211236524726022366 0ustar adminadministrators" . _T('info_question_utilisation_moteur_recherche') . "" . "
    " . afficher_choix('activer_moteur', $GLOBALS['meta']["activer_moteur"], array('oui' => _T('item_utiliser_moteur_recherche'), 'non' => _T('item_non_utiliser_moteur_recherche')), '   ') . "
    "; $res = debut_cadre_trait_couleur("racine-site-24.gif", true, "", _T('info_moteur_recherche').aide ("confmoteur")) . ajax_action_post('configurer', 'indexeur', 'config_fonctions', '', $res) . fin_cadre_trait_couleur(true); return ajax_action_greffe("configurer-indexeur", '', $res); } ?> spip/spip/ecrire/configuration/articles.php0000766000000000000000000001013111236524726022337 0ustar adminadministrators" . "" . _T('texte_contenu_articles') . "" . "" . "" . _T('info_surtitre') . "" . "" . afficher_choix('articles_surtitre', $articles_surtitre, array('oui' => _T('item_oui'), 'non' => _T('item_non')), "   ") . "\n" . "" . "" . _T('info_sous_titre') . "" . "" . afficher_choix('articles_soustitre', $articles_soustitre, array('oui' => _T('item_oui'), 'non' => _T('item_non')), "   ") . "\n" . "" . "" . _T('info_descriptif') . "" . "" . afficher_choix('articles_descriptif', $articles_descriptif, array('oui' => _T('item_oui'), 'non' => _T('item_non')), "   ") . "\n" . "" . "" . _T('info_chapeau_2') . "" . "" . afficher_choix('articles_chapeau', $articles_chapeau, array('oui' => _T('item_oui'), 'non' => _T('item_non')), "   ") . "\n" . "" . "" . typo(_T('info_texte').':') . "" . "" . afficher_choix('articles_texte', $articles_texte, array('oui' => _T('item_oui'), 'non' => _T('item_non')), "   ") . "\n" . "" . "" . _T('info_post_scriptum_2') . "" . "" . afficher_choix('articles_ps', $articles_ps, array('oui' => _T('item_oui'), 'non' => _T('item_non')), "   ") . "\n" . "" . "" . _T('info_date_publication_anterieure') . "" . "" . afficher_choix('articles_redac', $articles_redac, array('oui' => _T('item_oui'), 'non' => _T('item_non')), "   ") . "\n" . "" . "" . _T('info_urlref') . "" . "" . afficher_choix('articles_urlref', $articles_urlref, array('oui' => _T('item_oui'), 'non' => _T('item_non')), "   ") . "\n" . ""; $res = debut_cadre_relief("", true, "", _T('info_contenu_articles').aide ("confart")) . ajax_action_post('configurer', 'articles', 'configuration','',$res) . fin_cadre_relief(true); return ajax_action_greffe('configurer-articles', '', $res); } ?> spip/spip/ecrire/configuration/transcodeur.php0000766000000000000000000000354411236524726023074 0ustar adminadministrators\n

    " . _T('texte_jeu_caractere_3') . "

    \n
    " .entites_html($charset) ."

    " ."" ."   " . "
    \n(". _T('texte_jeu_caractere_2').")" . "

    \n"; // faudrait dire si le charset est inconnu // ca eviterait l'erreur sur array_flip dans inc/charsets if ($charset != 'utf-8' AND load_charset($charset)) $res .= _T('texte_jeu_caractere_conversion', array('url' => generer_url_ecrire('convert_utf8')) ); $res = ajax_action_post('configurer', 'transcodeur', 'config_lang', '', $res); $res = debut_cadre_relief("breve-24.gif", true, "", _T('info_jeu_caractere')) . $res . fin_cadre_relief(true); return ajax_action_greffe("configurer-transcodeur", '', $res); } ?> spip/spip/ecrire/configuration/index.php0000766000000000000000000000000211236524726021634 0ustar adminadministratorsX spip/spip/ecrire/configuration/previsualiseur.php0000766000000000000000000000354211236524726023623 0ustar adminadministrators _T('info_preview_admin'), "info_redacteurs" => _T('info_preview_comite')); $voir = $GLOBALS['meta']["preview"]; $res = ''; foreach($GLOBALS['liste_des_statuts'] as $k => $v) { if (isset($recom[$k])) { $vu = strpos($voir,",$v,")!==false; $lib = _T($k); $res .= "
    "; } } $res = "
    " . _T('info_preview_texte') . "

    " . $res . "
    "; $res = debut_cadre_trait_couleur("naviguer-site.png", true, "", _T('previsualisation') . aide("previsu")) . ajax_action_post('configurer_previsualiseur', 0, 'config_fonctions', '', $res) . fin_cadre_trait_couleur(true); return ajax_action_greffe("configurer_previsualiseur", 0, $res); } ?> spip/spip/ecrire/configuration/redirection.php0000766000000000000000000000303211236524726023042 0ustar adminadministrators" . "" . _T('config_info_redirection') . "" . "" . afficher_choix('articles_redirection', $GLOBALS['meta']["articles_redirection"], array('oui' => _T('item_oui'), 'non' => _T('item_non'))) . "\n" . "\n"; $res = debut_cadre_relief("", true, "", _T('config_redirection').aide ("artvirt")) . ajax_action_post('configurer', 'redirection', 'configuration','',$res) . fin_cadre_relief(true); return ajax_action_greffe('configurer-redirection', '', $res); } ?> spip/spip/ecrire/configuration/rubriques.php0000766000000000000000000000405411236524726022561 0ustar adminadministrators" . "" . typo(_T('config_activer_champs').':') . "" . "" . "" . _T('info_descriptif') . "" . "" . afficher_choix('rubriques_descriptif', $rubriques_descriptif, array('oui' => _T('item_oui'), 'non' => _T('item_non')), "   ") . "\n" . "" . "" . typo(_T('info_texte').':') . "" . "" . afficher_choix('rubriques_texte', $rubriques_texte, array('oui' => _T('item_oui'), 'non' => _T('item_non')), "   ") . "\n" . ""; $res = debut_cadre_trait_couleur("rubrique-24.gif", true, "", _T('icone_rubriques')) . ajax_action_post('configurer', 'rubriques', 'configuration','',$res) . fin_cadre_trait_couleur(true); return ajax_action_greffe('configurer-rubriques', '', $res); } ?> spip/spip/ecrire/configuration/compteur.php0000766000000000000000000000364211236524726022400 0ustar adminadministrators" . _T('info_question_gerer_statistiques') . "" . "
    " . afficher_choix('activer_statistiques', $GLOBALS['meta']["activer_statistiques"], array('oui' => _T('item_gerer_statistiques'), 'non' => _T('item_non_gerer_statistiques')), '   ') . "
    "; if ($GLOBALS['meta']["activer_statistiques"]=='oui'){ $res .= "
    " . _T('info_question_vignettes_referer') . "
    " . "
    " . afficher_choix('activer_captures_referers', $GLOBALS['meta']["activer_captures_referers"], array('oui' => _T('info_question_vignettes_referer_oui'), 'non' => _T('info_question_vignettes_referer_non'))) . "
    "; } $res = debut_cadre_trait_couleur("statistiques-24.gif", true, "", _T('info_forum_statistiques').aide ("confstat")) . ajax_action_post('configurer', 'compteur', 'config_fonctions', '', $res) . fin_cadre_trait_couleur(true); return ajax_action_greffe("configurer-compteur", '', $res); } ?> spip/spip/ecrire/configuration/type_urls.php0000766000000000000000000000347011236524726022567 0ustar adminadministrators$r — " . $exemple . ''; } $res = "

    " . _T('texte_type_urls') . "

    " . "
    " . afficher_choix('type_urls', $GLOBALS['meta']['type_urls'], $dispo) . "
    " . "

    " . _T('texte_type_urls_attention', array('htaccess' => '.htaccess')) . "

    "; $res = '
    '.debut_cadre_trait_couleur("", true, "", _T('titre_type_urls')) . ajax_action_post('configurer', 'type_urls', 'config_fonctions', '', $res) . fin_cadre_trait_couleur(true); return ajax_action_greffe("configurer-type_urls", '', $res); } ?> spip/spip/ecrire/configuration/annonces.php0000766000000000000000000001250311236524726022342 0ustar adminadministrators" . "\n" . "

    "._T('info_hebergeur_desactiver_envoi_email')."

    " . ""; // // Suivi editorial (articles proposes & publies) // $suivi_edito=$GLOBALS['meta']["suivi_edito"]; $adresse_suivi=$GLOBALS['meta']["adresse_suivi"]; $adresse_suivi_inscription=$GLOBALS['meta']["adresse_suivi_inscription"]; $res .= "
    \n" . debut_cadre_relief("", true, "", _T('info_suivi_activite')) . ""; $res .= "\n
    " . _T('info_facilite_suivi_activite') . "
    "; $res .= "" . "\n
    "; $res .= bouton_radio("suivi_edito", "oui", _T('bouton_radio_envoi_annonces_adresse'), $suivi_edito == "oui", "changeVisible(this.checked, 'config-edito', 'block', 'none');"); if ($suivi_edito == "oui") $style = "display: block;"; else $style = "display: none;"; $res .= "
    " . "\n
    " . "\n

    "; if (!$adresse_suivi) $adresse_suivi = "mailing@monsite.net"; $res .= "" . "
    \n" . "

    " . "
    " . "
    \n" . bouton_radio("suivi_edito", "non", _T('bouton_radio_non_envoi_annonces_editoriales'), $suivi_edito == "non", "changeVisible(this.checked, 'config-edito', 'none', 'block');") . "
    \n" . fin_cadre_relief(true); // // Annonce des nouveautes // $quoi_de_neuf=$GLOBALS['meta']["quoi_de_neuf"]; $adresse_neuf=$GLOBALS['meta']["adresse_neuf"]; $jours_neuf=$GLOBALS['meta']["jours_neuf"]; $res .= "
    \n" . debut_cadre_relief("", true, "", _T('info_annonce_nouveautes')) . "" . "\n" . "\n
    " . _T('info_non_envoi_annonce_dernieres_nouveautes') . "
    " . bouton_radio("quoi_de_neuf", "oui", _T('bouton_radio_envoi_liste_nouveautes'), $quoi_de_neuf == "oui", "changeVisible(this.checked, 'config-neuf', 'block', 'none');"); if ($quoi_de_neuf == "oui") $style = "display: block;"; else $style = "display: none;"; $res .= "
    " . "
      " . "
    • " . "\n" . "
    • " . "\n\n" . _T('info_jours') . "      \n" . "
    " . "
    "; $res .= "
    \n" . bouton_radio("quoi_de_neuf", "non", _T('info_non_envoi_liste_nouveautes'), $quoi_de_neuf == "non", "changeVisible(this.checked, 'config-neuf', 'none', 'block');"); $res .= "
    \n" . fin_cadre_relief(true); $email_envoi = entites_html($GLOBALS['meta']["email_envoi"]); $titre = _T('info_email_envoi'); if ($email_envoi) $titre .= " : " . $email_envoi; $res .= "
    \n" . debut_cadre_relief("", true, "", $titre) . "" . "\n" . "\n
    " . "" . " " . "
     
    " . fin_cadre_relief(true); $res = debut_cadre_trait_couleur("mail-auto-24.gif", true, "", _T('info_envoi_email_automatique').aide ("confmails")) . ajax_action_post('configurer', 'annonces', 'config_contenu','',$res) . fin_cadre_trait_couleur(true); return ajax_action_greffe('configurer-annonces', '', $res); } ?> spip/spip/ecrire/configuration/forums_prives.php0000766000000000000000000000374411236524726023450 0ustar adminadministrators" . _T('info_config_forums_prive') . "
    \n" . "

    "._T('info_config_forums_prive_objets') . "
    \n" . afficher_choix('forum_prive_objets', $GLOBALS['meta']['forum_prive_objets'], array('oui' => _T('item_config_forums_prive_objets'), 'non' => _T('item_non_config_forums_prive_objets'))) ."

    \n" . "

    "._T('info_config_forums_prive_global') . "
    \n" . afficher_choix('forum_prive', $GLOBALS['meta']['forum_prive'], array('oui' => _T('item_config_forums_prive_global'), 'non' => _T('item_non_config_forums_prive_global'))) ."

    \n" . "

    "._T('info_config_forums_prive_admin') . "
    \n" . afficher_choix('forum_prive_admin', $GLOBALS['meta']['forum_prive_admin'], array('oui' => _T('item_activer_forum_administrateur'), 'non' => _T('item_desactiver_forum_administrateur'))) ."

    \n" . ""; $res = debut_cadre_trait_couleur("forum-interne-24.gif", true, "", _T('titre_config_forums_prive')) . ajax_action_post('configurer', 'forums_prives', 'config_contenu','',$res) . fin_cadre_trait_couleur(true); return ajax_action_greffe('configurer-forums_prives', '', $res); } ?> spip/spip/ecrire/configuration/participants.php0000766000000000000000000000774411236524726023252 0ustar adminadministrators"; $res .= "\n"; if ($forums_publics == "non") $block = "'none', 'block'"; else $block= "'block', 'none'"; $res .= bouton_radio("forums_publics", "non", _T('info_desactiver_forum_public'), $forums_publics == "non", "changeVisible(this.checked, 'config-options', $block);"); $res .= ""; $res .= "\n"; $res .= _T('info_activer_forum_public'); $res .= ""; $res .= "\n"; if ($forums_publics == "posteriori") $block = "'none', 'block'"; else $block= "'block', 'none'"; $res .= bouton_radio("forums_publics", "posteriori", _T('bouton_radio_publication_immediate'), $forums_publics == "posteriori", "changeVisible(this.checked, 'config-options', $block);"); $res .= "
    \n"; if ($forums_publics == "priori") $block = "'none', 'block'"; else $block= "'block', 'none'"; $res .= bouton_radio("forums_publics", "priori", _T('bouton_radio_moderation_priori'), $forums_publics == "priori", "changeVisible(this.checked, 'config-options', $block);"); $res .= "
    \n"; if ($forums_publics == "abo") $block = "'none', 'block'"; else $block= "'block', 'none'"; $res .= bouton_radio("forums_publics", "abo", _T('bouton_radio_enregistrement_obligatoire'), $forums_publics == "abo", "changeVisible(this.checked, 'config-options', $block);"); $res .= ""; $res .= "\n"; $res .= "
    "; $res .= debut_cadre_relief("", true, "", _T('info_options_avancees')); $res .= "\n"; $res .= "\n
    "; $res .= _T('info_appliquer_choix_moderation')."
    \n"; $res .= ""; $res .= "\n
    \n"; $res .= ""; $res .= "\n
    \n"; $res .= ""; $res .= "\n
    \n"; $res .= "
    "; $res .= fin_cadre_relief(true); $res .= "
    "; $res .= "\n"; $res = debut_cadre_trait_couleur("forum-interne-24.gif", true, "", _T('info_mode_fonctionnement_defaut_forum_public').aide ("confforums")) . ajax_action_post('configurer', 'participants', 'config_contenu','',$res) . fin_cadre_trait_couleur(true); return ajax_action_greffe('configurer-participants', '', $res); } ?> spip/spip/ecrire/configuration/documents.php0000766000000000000000000000432711236524726022544 0ustar adminadministrators"; $res .= ""; $res .= _T('texte_documents_joints'); $res .= _T('texte_documents_joints_2'); $res .= ""; $res .= ""; $res .= ""; $res .= afficher_choix('documents_article', $GLOBALS['meta']["documents_article"], array('oui' => _T('item_autoriser_documents_joints'), 'non' => _T('item_non_autoriser_documents_joints')), "
    \n"); $res .= "

    \n"; $res .= afficher_choix('documents_rubrique', $GLOBALS['meta']["documents_rubrique"], array('oui' => _T('item_autoriser_documents_joints_rubriques'), 'non' => _T('item_non_autoriser_documents_joints_rubriques')), "
    \n"); $res .= "

    \n"; $res .= afficher_choix('documents_date', $GLOBALS['meta']["documents_date"], array('oui' => _T('item_autoriser_selectionner_date_en_ligne'), 'non' => _T('item_non_autoriser_selectionner_date_en_ligne')), "
    \n"); $res .= ""; $res .= "\n"; $res = debut_cadre_trait_couleur("doc-24.gif", true, "", _T('titre_documents_joints')) . ajax_action_post('configurer', 'documents', 'configuration','',$res) . fin_cadre_trait_couleur(true); return ajax_action_greffe('configurer-documents', '', $res); } ?> spip/spip/ecrire/configuration/avertisseur.php0000766000000000000000000000273111236524726023114 0ustar adminadministrators" . _T('texte_travail_collaboratif') . "" . "
    " . afficher_choix('articles_modif',$GLOBALS['meta']["articles_modif"] , array('oui' => _T('item_activer_messages_avertissement'), 'non' => _T('item_non_activer_messages_avertissement'))) . "
    "; $res = debut_cadre_trait_couleur("article-24.gif", true, "", _T('info_travail_colaboratif').aide("artmodif")) . ajax_action_post('configurer', 'avertisseur', 'config_fonctions', '', $res) . fin_cadre_trait_couleur(true); return ajax_action_greffe("configurer-avertisseur", '', $res); } ?> spip/spip/ecrire/configuration/contenu_forums.php0000766000000000000000000000623511236524726023611 0ustar adminadministrators" . "" . typo(_T('config_activer_champs').':') . "" . "" . "" . _T('info_titre') . "" . "" . afficher_choix('forums_titre', $forums_titre, array('oui' => _T('item_oui'), 'non' => _T('item_non')), "   ") . "\n" . "" . "" . typo(_T('info_texte').':') . "" . "" . afficher_choix('forums_texte', $forums_texte, array('oui' => _T('item_oui'), 'non' => _T('item_non')), "   ") . "\n" . "" . "- " . _T('info_barre_outils') . "" . "" . afficher_choix('forums_afficher_barre', $forums_afficher_barre, array('oui' => _T('item_oui'), 'non' => _T('item_non')), "   ") . "\n" . "" . "" . _T('info_urlref') . "" . "" . afficher_choix('forums_urlref', $forums_urlref, array('oui' => _T('item_oui'), 'non' => _T('item_non')), "   ") . "\n" . "" . "" . _T('info_question_visiteur_ajout_document_forum') . "
    " . _T('info_question_visiteur_ajout_document_forum_format') . "

    " . "" . "\n" . ""; $res = debut_cadre_trait_couleur("forum-public-24.gif", true, "", _T('titre_forum')) . ajax_action_post('configurer', 'contenu_forums', 'configuration','',$res) . fin_cadre_trait_couleur(true); return ajax_action_greffe('configurer-contenu_forums', '', $res); } ?> spip/spip/ecrire/configuration/syndications.php0000766000000000000000000001210411236524726023242 0ustar adminadministrators"; $res .= ""; $res .= bouton_radio("activer_sites", "oui", _T('item_gerer_annuaire_site_web'), $activer_sites == "oui", "changeVisible(this.checked, 'config-site', 'block', 'none');"); $res .= "  "; $res .= bouton_radio("activer_sites", "non", _T('item_non_gerer_annuaire_site_web'), $activer_sites == "non", "changeVisible(this.checked, 'config-site', 'none', 'block');"); $res .= "\n"; if ($activer_sites != 'non') $style = "display: block;"; else $style = "display: none;"; $res .= "
    "; // Utilisateurs autorises a proposer des sites references // $res .= "
    \n"; $res .= debut_cadre_relief('',true); $res .= "\n"; $res .= "\n
    "; $res .= ""; $res .= "\n
    \n"; $res .= "
    \n"; $res .= fin_cadre_relief(true); $res .= debut_cadre_relief("", true, "", _T('titre_syndication').aide ("rubsyn")); $res .= "\n"; // // Reglage de la syndication // $res .= ""; $res .= "\n"; $res .= "
    "; $res .= _T('texte_syndication'); $res .= "
    "; $res .= bouton_radio("activer_syndic", "oui", _T('item_utiliser_syndication'), $activer_syndic == "oui", "changeVisible(this.checked, 'config-syndic', 'block', 'none');"); $res .= "
    \n"; $res .= bouton_radio("activer_syndic", "non", _T('item_non_utiliser_syndication'), $activer_syndic == "non", "changeVisible(this.checked, 'config-syndic', 'none', 'block');"); if ($activer_syndic != "non") $style = "display: block;"; else $style = "display: none;"; $res .= "
    "; // Moderation par defaut des sites syndiques $res .= "

    "; $res .= _T('texte_liens_sites_syndiques')."

    "; $res .= afficher_choix('moderation_sites', $moderation_sites, array('oui' => _T('item_bloquer_liens_syndiques'), 'non' => _T('item_non_bloquer_liens_syndiques'))); $res .= "
    "; $res .= "
    \n"; $res .= fin_cadre_relief(true); $res .= "
    "; // // Gestion des flux RSS // $res .= debut_cadre_relief("feed.png", true, "", _T('ical_titre_rss')); $res .= ""; $res .= ""; $res .= ""; $res .= ""; $res .= "
    "; $res .= _T('info_syndication_integrale_1', array('url' => generer_url_ecrire('synchro'), 'titre' => _T("icone_suivi_activite")) ). '

    ' . _T('info_syndication_integrale_2'). '

    '; $res .= "
    "; $res .= afficher_choix('syndication_integrale', $GLOBALS['meta']["syndication_integrale"], array('oui' => _T('item_autoriser_syndication_integrale'), 'non' => _T('item_non_autoriser_syndication_integrale')), "
    \n"); $res .= "
    \n"; $res .= fin_cadre_relief(true); $res = debut_cadre_trait_couleur("site-24.gif",true, "", _T('titre_referencement_sites').aide ("reference")) . ajax_action_post('configurer', 'syndications', 'configuration','',$res) . fin_cadre_trait_couleur(true); return ajax_action_greffe('configurer-syndications', '', $res); } ?> spip/spip/ecrire/configuration/futurs.php0000766000000000000000000000307011236524726022065 0ustar adminadministrators" . "" . _T('texte_publication_articles_post_dates') . "" . "" . afficher_choix('post_dates', $GLOBALS['meta']["post_dates"], array('oui' => _T('item_publier_articles'), 'non' => _T('item_non_publier_articles'))) . "\n" . "\n"; $res = debut_cadre_relief("", true, "", _T('titre_publication_articles_post_dates').aide ("confdates")) . ajax_action_post('configurer', 'futurs', 'configuration','',$res) . fin_cadre_relief(true); return ajax_action_greffe('configurer-futurs', '', $res); } ?> spip/spip/ecrire/configuration/notifications_forum.php0000766000000000000000000000330311236524726024615 0ustar adminadministrators $val) { $name = 'prevenir_auteurs_' . $val; $lib = _T($desc); $vu = (($m == 'oui') OR strpos($m,",$val,")!==false); $res .= "
    "; } $res = "
    " . _T('info_option_email') . "

    " . $res . "
    \n"; $res = debut_cadre_trait_couleur("mail-forum-24.gif", true, "", _T('info_envoi_forum')) . ajax_action_post('configurer_notifications_forum', 0, 'config_contenu','',$res) . fin_cadre_trait_couleur(true); return ajax_action_greffe('configurer_notifications_forum', 0, $res); } ?> spip/spip/ecrire/configuration/locuteur.php0000766000000000000000000000672411236524726022410 0ustar adminadministrators" . _T('info_multi_langues_choisies') . '

    ' . "\n
    "; $i=0; while (list($code_langue) = each($langues_bloquees)) { $i++; $nom_langue = $langues[$code_langue]; if ($langues_trad[$code_langue]) $nom_langue = "$nom_langue"; $res .= "\n
    "; $res .= "\n"; $res .= "\n"; $res .= ""; $res .= "
    "; if ($i == $cesure) $res .= "\n
    "; } $res .= "\n
     
    "; while (list($code_langue, $nom_langue) = each($langues)) { if ($langues_bloquees[$code_langue]) continue; $i++; $res .= "\n
    "; if ($langues_trad[$code_langue]) $nom_langue = "$nom_langue"; if ($langues_auth[$code_langue]) { $res .= ""; $nom_langue = "$nom_langue"; } else { $res .= ""; } $res .= "\n"; $res .= "
    "; if ($i == $cesure) $res .= "
    "; } $res .= "
    " . "
    "._T("info_multi_langues_soulignees")."
    "; $res = debut_cadre_relief("langues-24.gif", true) . ajax_action_post('configurer', 'locuteur', 'config_multilang', '', $res) . fin_cadre_relief(true); return ajax_action_greffe("configurer-locuteur", '', $res); } ?> spip/spip/ecrire/configuration/reducteur.php0000766000000000000000000001625411236524726022547 0ustar adminadministrators"._T('info_taille_maximale_images')."

    "; $test_out .= "
    "; $maxtest = 1740; // 3MPixels $test = array(); $time = time(); if ($max_size >= ($maxtest-20)*($maxtest-20)) $maxtest = 2380; // 6MPixels $top = 16; for ($j = 320;$j>=20;$j = $j/2){ $test_out .= "
    "; $l = round($j/10); $lok = 0; $lbad =0; $margin_left = 0; $top -= 8; for ($i = 480;$i*$i<$max_size && $i<=$maxtest;$i+=$j) $lok += $l; if ($lok-$l+2>0) $test_out .= ""; for (;(!$max_size_echec OR $i*$i<$max_size_echec) && $i<=$maxtest;$i+=$j){ if (!isset($test[$i])){ $url = generer_url_action("tester_taille", "arg=$i&time=$time"); $test_out .= ""; $test[$i] = 1; $margin_left = 0; } else $margin_left += $l; } for (;$i<=$maxtest;$i+=$j) $lbad += $l; if ($lbad) $test_out .= ""; $test_out .= "
    "; } $test_out .= "

    "; } } else { effacer_meta('max_taille_vignettes'); effacer_meta('max_taille_vignettes_echec'); effacer_meta('max_taille_vignettes_test'); } return ajax_action_greffe("configurer-reducteur", '', debut_cadre_trait_couleur("image-24.gif", true) . debut_cadre_relief("", true, "", _T("info_image_process_titre")) . "

    " . _T('info_image_process') . "

    " . $res . "
    " . "

    " . _T('info_image_process2') . "

    " . $test_out . fin_cadre_relief(true) . (!$formats_graphiques ? '' : format_choisi()) . fin_cadre_trait_couleur(true)); } function format_choisi() { global $spip_lang_left, $spip_lang_right; $creer_preview = $GLOBALS['meta']["creer_preview"]; $taille_preview = $GLOBALS['meta']["taille_preview"]; if ($taille_preview < 10) $taille_preview = 120; $res .= "

    "; $res .= _T('info_ajout_image'); $res .= "

    \n"; $res .= "
    "; $res .= bouton_radio("creer_preview", "oui", _T('item_choix_generation_miniature'), $creer_preview == "oui", "changeVisible(this.checked, 'config-preview', 'block', 'none');"); $res .= '
    '; if ($creer_preview == "oui") $style = "block;"; else $style = "none;"; $res .= "
    " . "" . "
    "; $res .= " "._T('info_pixels'); $res .= '

    '; $res .= "
    "; $res .= bouton_radio("creer_preview", "non", _T('item_choix_non_generation_miniature'), $creer_preview != "oui", "changeVisible(this.checked, 'config-preview', 'none', 'block');"); return debut_cadre_trait_couleur("", true, "", _T('info_generation_miniatures_images')) . ajax_action_post('configurer', 'reducteur', 'config_fonctions', '', $res) . fin_cadre_trait_couleur(true); } // http://doc.spip.org/@afficher_choix_vignette function afficher_choix_vignette($process) { //global $taille_preview; $taille_preview = 120; // Ici on va tester les capacites de GD independamment des tests realises // dans les images spip_image -- qui servent neanmoins pour la qualite /* if (function_exists('imageformats')) { } */ $class = ''; if ($process == $GLOBALS['meta']['image_process']) { $class = " selected"; } return "\n
    $process$process
    \n"; } ?> spip/spip/ecrire/configuration/logos.php0000766000000000000000000000451311236524726021663 0ustar adminadministrators"; $res .= ""; $res .= _T('config_info_logos').aide('logoart'); $res .= ""; $res .= ""; $res .= ""; $res .= bouton_radio("activer_logos", "oui", _T('config_info_logos_utiliser'), $activer_logos == "oui", "changeVisible(this.checked, 'logos_survol_config', 'block', 'none');") . "
    " . bouton_radio("activer_logos", "non", _T('config_info_logos_utiliser_non'), $activer_logos == "non", "changeVisible(this.checked, 'logos_survol_config', 'none', 'block');"); if ($activer_logos != "non") $style = "display: block;"; else $style = "display: none;"; $res .= "

    "; $res .= afficher_choix('activer_logos_survol', $activer_logos_survol, array('oui' => _T('config_info_logos_utiliser_survol'), 'non' => _T('config_info_logos_utiliser_survol_non')), "
    "); $res .= "
    "; $res .= ""; $res .= "\n"; $res = debut_cadre_trait_couleur("image-24.gif", true, "", _T('info_logos')) . ajax_action_post('configurer', 'logos', 'configuration','',$res) . fin_cadre_trait_couleur(true); return ajax_action_greffe('configurer-logos', '', $res); } ?> spip/spip/ecrire/configuration/mots.php0000766000000000000000000000657711236524726021536 0ustar adminadministrators" . "" . _T('texte_mots_cles')."
    \n" . _T('info_question_mots_cles') . "" . "" . "" . bouton_radio("articles_mots", "oui", _T('item_utiliser_mots_cles'), $articles_mots == "oui", "changeVisible(this.checked, 'mots-config', 'block', 'none');") . "  " . bouton_radio("articles_mots", "non", _T('item_non_utiliser_mots_cles'), $articles_mots == "non", "changeVisible(this.checked, 'mots-config', 'none', 'block');"); // $res .= afficher_choix('articles_mots', $articles_mots, // array('oui' => _T('item_utiliser_mots_cles'), // 'non' => _T('item_non_utiliser_mots_cles')), "
    "); $res .= ""; if ($articles_mots != "non") $style = "display: block;"; else $style = "display: none;"; $res .= "
    " . "
    \n" . debut_cadre_relief("", true, "", _T('titre_config_groupe_mots_cles')) . "" . "" . "" . "
    " . _T('texte_config_groupe_mots_cles') . "
    " . afficher_choix('config_precise_groupes', $config_precise_groupes, array('oui' => _T('item_utiliser_config_groupe_mots_cles'), 'non' => _T('item_non_utiliser_config_groupe_mots_cles'))) . "
    " . fin_cadre_relief(true); if ($forums_publics != "non"){ $res .= "
    \n" . debut_cadre_relief("", true, "", _T('titre_mots_cles_dans_forum')) . "" . "" . "" . "" . "
    " . _T('texte_mots_cles_dans_forum') . "
    " . afficher_choix('mots_cles_forums', $mots_cles_forums, array('oui' => _T('item_ajout_mots_cles'), 'non' => _T('item_non_ajout_mots_cles'))) . "
    " . fin_cadre_relief(true); } $res .= "
    "; $res = debut_cadre_trait_couleur("mot-cle-24.gif", true, "", _T('info_mots_cles')) . ajax_action_post('configurer', 'mots', 'configuration','',$res) . fin_cadre_trait_couleur(true); return ajax_action_greffe('configurer-mots', '', $res); } ?> spip/spip/ecrire/inc/0000777000000000000000000000000011266531677015733 5ustar adminadministratorsspip/spip/ecrire/inc/getdocument.php0000766000000000000000000001361711236524730020760 0ustar adminadministrators '.' AND $f <> '..' AND is_dir("$nom/$f")) effacer_repertoire_temporaire("$nom/$f"); } closedir($d); @rmdir($nom); } // http://doc.spip.org/@copier_document function copier_document($ext, $orig, $source) { $orig = preg_replace(',\.\.+,', '.', $orig); // pas de .. dans le nom du doc $dir = creer_repertoire_documents($ext); $dest = preg_replace("/[^._=-\w\d]+/", "_", translitteration(preg_replace("/\.([^.]+)$/", "", preg_replace("/<[^>]*>/", '', basename($orig))))); // ne pas accepter de noms de la forme -r90.jpg qui sont reserves // pour les images transformees par rotation (action/documenter) $dest = preg_replace(',-r(90|180|270)$,', '', $dest); // Si le document "source" est deja au bon endroit, ne rien faire if ($source == ($dir . $dest . '.' . $ext)) return $source; // sinon tourner jusqu'a trouver un numero correct $n = 0; while (@file_exists($newFile = $dir . $dest .($n++ ? ('-'.$n) : '').'.'.$ext)); return deplacer_fichier_upload($source, $newFile); } // // Deplacer un fichier // // http://doc.spip.org/@deplacer_fichier_upload function deplacer_fichier_upload($source, $dest, $move=false) { // Securite if (substr($dest,0,strlen(_DIR_RACINE))==_DIR_RACINE) $dest = _DIR_RACINE.preg_replace(',\.\.+,', '.', substr($dest,strlen(_DIR_RACINE))); else $dest = preg_replace(',\.\.+,', '.', $dest); if ($move) $ok = @rename($source, $dest); else $ok = @copy($source, $dest); if (!$ok) $ok = @move_uploaded_file($source, $dest); if ($ok) @chmod($dest, _SPIP_CHMOD & ~0111); else { $f = @fopen($dest,'w'); if ($f) { fclose ($f); } else { include_spip('inc/flock'); raler_fichier($dest); } spip_unlink($dest); } return $ok ? $dest : false; } // Erreurs d'upload // renvoie false si pas d'erreur // et true si erreur = pas de fichier // pour les autres erreurs affiche le message d'erreur et meurt // http://doc.spip.org/@check_upload_error function check_upload_error($error, $msg='') { global $spip_lang_right; if (!$error) return false; spip_log("Erreur upload $error -- cf. http://php.net/manual/fr/features.file-upload.errors.php"); switch ($error) { case 4: /* UPLOAD_ERR_NO_FILE */ return true; # on peut affiner les differents messages d'erreur case 1: /* UPLOAD_ERR_INI_SIZE */ $msg = _T('upload_limit', array('max' => ini_get('upload_max_filesize'))); break; case 2: /* UPLOAD_ERR_FORM_SIZE */ $msg = _T('upload_limit', array('max' => ini_get('upload_max_filesize'))); break; case 3: /* UPLOAD_ERR_PARTIAL */ $msg = _T('upload_limit', array('max' => ini_get('upload_max_filesize'))); break; default: /* autre */ if (!$msg) $msg = _T('pass_erreur').' '. $error . '
    ' . propre("[->http://php.net/manual/fr/features.file-upload.errors.php]"); break; } spip_log ("erreur upload $error"); if(_request("iframe")=="iframe") { echo "
    $msg
    "; exit; } echo minipres($msg, ""); exit; } // Erreur appelee depuis public.php (la precedente ne fonctionne plus // depuis qu'on est sortis de spip_image.php, apparemment). // http://doc.spip.org/@erreur_upload_trop_gros function erreur_upload_trop_gros() { include_spip('inc/filtres'); $msg = "

    " .taille_en_octets($_SERVER["CONTENT_LENGTH"]) .'
    ' ._T('upload_limit', array('max' => ini_get('upload_max_filesize'))) ."

    "; echo minipres(_T('pass_erreur'),"
    ".$msg."
    "); exit; } // // Gestion des fichiers ZIP // // http://doc.spip.org/@accepte_fichier_upload function accepte_fichier_upload ($f) { if (!preg_match(",.*__MACOSX/,", $f) AND !preg_match(",^\.,", basename($f))) { $ext = corriger_extension((strtolower(substr(strrchr($f, "."), 1)))); return sql_countsel('spip_types_documents', "extension=" . sql_quote($ext) . " AND upload='oui'"); } } # callback pour le deballage d'un zip telecharge # http://www.phpconcept.net/pclzip/man/en/?options-pclzip_cb_pre_extractfunction // http://doc.spip.org/@callback_deballe_fichier function callback_deballe_fichier($p_event, &$p_header) { if (accepte_fichier_upload($p_header['filename'])) { $p_header['filename'] = _tmp_dir . basename($p_header['filename']); return 1; } else { return 0; } } ?> spip/spip/ecrire/inc/article_select.php0000766000000000000000000001273211236524730021421 0ustar adminadministrators $contenu) $row[$champ] = $contenu; } } return $row; } // id_article non numerique, c'est une demande de creation. // Si c'est une demande de nouvelle traduction, init specifique if ($lier_trad){ $row = article_select_trad($lier_trad, $id_rubrique); $row['statut'] = ''; // le nouvel article n'a pas encore de statut ! } else { $row['titre'] = '';//filtrer_entites(_T('info_nouvel_article')); //$row['onfocus'] = " onfocus=\"if(!antifocus){this.value='';antifocus=true;}\""; $row['id_rubrique'] = $id_rubrique; } // appel du script a la racine, faut choisir // admin restreint ==> sa premiere rubrique // autre ==> la derniere rubrique cree if (!$row['id_rubrique']) { if ($connect_id_rubrique) $row['id_rubrique'] = $id_rubrique = $connect_id_rubrique[0]; else { $row_rub = sql_fetsel("id_rubrique", "spip_rubriques", "", "", "id_rubrique DESC", 1); $row['id_rubrique'] = $id_rubrique = $row_rub['id_rubrique']; } if (!autoriser('creerarticledans','rubrique',$row['id_rubrique'] )){ // manque de chance, la rubrique n'est pas autorisee, on cherche un des secteurs autorises $res = sql_select("id_rubrique", "spip_rubriques", "id_parent=0"); while (!autoriser('creerarticledans','rubrique',$row['id_rubrique'] ) && $row_rub = sql_fetch($res)){ $row['id_rubrique'] = $row_rub['id_rubrique']; } } } // recuperer le secteur, pour affecter les bons champs extras if (!$row['id_secteur']) { $row_rub = sql_getfetsel("id_secteur", "spip_rubriques", "id_rubrique=" . sql_quote($id_rubrique)); $row['id_secteur'] = $row_rub; } return $row; } // // Si un article est demande en creation (new=oui) avec un lien de trad, // on initialise les donnees de maniere specifique // // http://doc.spip.org/@article_select_trad function article_select_trad($lier_trad, $id_rubrique=0) { // Recuperer les donnees de l'article original $row = sql_fetsel("*", "spip_articles", "id_article=$lier_trad"); if ($row) { $row['titre'] = filtrer_entites(_T('info_nouvelle_traduction')).' '.$row["titre"]; } else $row = array(); if ($id_rubrique) { $row['id_rubrique'] = $id_rubrique; return $row; } $id_rubrique = $row['id_rubrique']; // Regler la langue, si possible, sur celle du redacteur // Cela implique souvent de choisir une rubrique ou un secteur if (in_array($GLOBALS['spip_lang'], explode(',', $GLOBALS['meta']['langues_multilingue']))) { // Si le menu de langues est autorise sur les articles, // on peut changer la langue quelle que soit la rubrique // donc on reste dans la meme rubrique if ($GLOBALS['meta']['multi_articles'] == 'oui') { $row['id_rubrique'] = $row['id_rubrique']; # explicite :-) } else if ($GLOBALS['meta']['multi_rubriques'] == 'oui') { // Sinon, chercher la rubrique la plus adaptee pour // accueillir l'article dans la langue du traducteur if ($GLOBALS['meta']['multi_secteurs'] == 'oui') { $id_parent = 0; } else { // on cherche une rubrique soeur dans la bonne langue $row_rub = sql_fetsel("id_parent", "spip_rubriques", "id_rubrique=$id_rubrique"); $id_parent = $row_rub['id_parent']; } $row_rub = sql_fetsel("id_rubrique", "spip_rubriques", "lang='".$GLOBALS['spip_lang']."' AND id_parent=$id_parent"); if ($row_rub) $row['id_rubrique'] = $row_rub['id_rubrique']; } } return $row; } ?> spip/spip/ecrire/inc/puce_statut.php0000766000000000000000000002702011236524730020773 0ustar adminadministrators"; } // http://doc.spip.org/@puce_statut_document_dist function puce_statut_document_dist($id, $statut, $id_rubrique, $type, $ajax='') { return ""; } // http://doc.spip.org/@puce_statut_auteur_dist // Hack de compatibilite: les appels directs ont un $type != 'auteur' // si l'auteur ne peut pas se connecter // http://doc.spip.org/@puce_statut_auteur_dist function puce_statut_auteur_dist($id, $statut, $id_rubrique, $type, $ajax='') { static $titre_des_statuts =''; static $images_des_statuts =''; // eviter de retraduire a chaque appel if (!$titre_des_statuts) { $titre_des_statuts = array( "info_administrateurs" => _T('titre_image_administrateur'), "info_redacteurs" => _T('titre_image_redacteur_02'), "info_visiteurs" => _T('titre_image_visiteur'), "info_statut_site_4" => _T('titre_image_auteur_supprime') ); $images_des_statuts = array( "info_administrateurs" => 'admin-12.gif', "info_redacteurs" =>'redac-12.gif', "info_visiteurs" => 'visit-12.gif', "info_statut_site_4" => 'poubelle.gif' ); } if ($statut == 'nouveau') return ''; $index = array_search($statut, $GLOBALS['liste_des_statuts']); if (!$index) $index = 'info_visiteurs'; $img = $images_des_statuts[$index]; $alt = $titre_des_statuts[$index]; if ($type != 'auteur') { $img2 = "croix-rouge.gif"; $titre = _T('titre_image_redacteur'); $fond = http_style_background($img2, 'top right no-repeat; padding-right: 4px'); } else {$fond = ''; $titre = $alt;} return http_img_pack($img, $alt, $fond, $titre); } // http://doc.spip.org/@bonhomme_statut function bonhomme_statut($row) { $puce_statut = charger_fonction('puce_statut', 'inc'); return $puce_statut(0, $row['statut'], 0, 'auteur'); } // http://doc.spip.org/@puce_statut_mot_dist function puce_statut_mot_dist($id, $statut, $id_rubrique, $type, $ajax='') { return ""; } // http://doc.spip.org/@puce_statut_rubrique_dist function puce_statut_rubrique_dist($id, $statut, $id_rubrique, $type, $ajax='') { return ""; } // http://doc.spip.org/@puce_statut_article_dist function puce_statut_article_dist($id, $statut, $id_rubrique, $type='article', $ajax = false) { global $lang_objet; static $coord = array('publie' => 2, 'prepa' => 0, 'prop' => 1, 'refuse' => 3, 'poubelle' => 4); $lang_dir = lang_dir($lang_objet); if (!$id) { $id = $id_rubrique; $ajax_node =''; } else $ajax_node = " id='imgstatut$type$id'"; $inser_puce = puce_statut($statut, " width='9' height='9' style='margin: 1px;'$ajax_node"); if (!autoriser('publierdans', 'rubrique', $id_rubrique) OR !_ACTIVER_PUCE_RAPIDE) return $inser_puce; $titles = array( "blanche" => _T('texte_statut_en_cours_redaction'), "orange" => _T('texte_statut_propose_evaluation'), "verte" => _T('texte_statut_publie'), "rouge" => _T('texte_statut_refuse'), "poubelle" => _T('texte_statut_poubelle')); $clip = 1+ (11*$coord[$statut]); if ($ajax){ return "" . $inser_puce . "" . "" . afficher_script_statut($id, $type, -1, 'puce-blanche.gif', 'prepa', $titles['blanche']) . afficher_script_statut($id, $type, -12, 'puce-orange.gif', 'prop', $titles['orange']) . afficher_script_statut($id, $type, -23, 'puce-verte.gif', 'publie', $titles['verte']) . afficher_script_statut($id, $type, -34, 'puce-rouge.gif', 'refuse', $titles['rouge']) . afficher_script_statut($id, $type, -45, 'puce-poubelle.gif', 'poubelle', $titles['poubelle']) . ""; } $nom = "puce_statut_"; if ((! _SPIP_AJAX) AND $type != 'article') $over =''; else { $action = generer_url_ecrire('puce_statut',"",true); $action = "if (!this.puce_loaded) { this.puce_loaded = true; prepare_selec_statut('$nom', '$type', '$id', '$action'); }"; $over = "\nonmouseover=\"$action\""; } return "" . $inser_puce . ''; } // http://doc.spip.org/@puce_statut_breve_dist function puce_statut_breve_dist($id, $statut, $id_rubrique, $type, $ajax='') { global $lang_objet; static $coord = array('publie' => 1, 'prop' => 0, 'refuse' => 2, 'poubelle' => 3); $lang_dir = lang_dir($lang_objet); $puces = array( 0 => 'puce-orange-breve.gif', 1 => 'puce-verte-breve.gif', 2 => 'puce-rouge-breve.gif', 3 => 'puce-blanche-breve.gif'); switch ($statut) { case 'prop': $clip = 0; $puce = $puces[0]; $title = _T('titre_breve_proposee'); break; case 'publie': $clip = 1; $puce = $puces[1]; $title = _T('titre_breve_publiee'); break; case 'refuse': $clip = 2; $puce = $puces[2]; $title = _T('titre_breve_refusee'); break; default: $clip = 0; $puce = $puces[3]; $title = ''; } $type1 = "statut$type$id"; $inser_puce = http_img_pack($puce, $title, "id='img$type1' style='margin: 1px;'"); if (!autoriser('publierdans','rubrique',$id_rubrique) OR !_ACTIVER_PUCE_RAPIDE) return $inser_puce; $titles = array( "blanche" => _T('texte_statut_en_cours_redaction'), "orange" => _T('texte_statut_propose_evaluation'), "verte" => _T('texte_statut_publie'), "rouge" => _T('texte_statut_refuse'), "poubelle" => _T('texte_statut_poubelle')); $clip = 1+ (11*$coord[$statut]); if ($ajax){ return "" . $inser_puce . "" . "" . afficher_script_statut($id, $type, -1, $puces[0], 'prop', $titles['orange']) . afficher_script_statut($id, $type, -10, $puces[1], 'publie', $titles['verte']) . afficher_script_statut($id, $type, -19, $puces[2], 'refuse', $titles['rouge']) . ""; } $nom = "puce_statut_"; if ((! _SPIP_AJAX) AND $type != 'breve') $over =''; else { $action = generer_url_ecrire('puce_statut',"",true); $action = "if (!this.puce_loaded) { this.puce_loaded = true; prepare_selec_statut('$nom', '$type', '$id', '$action'); }"; $over = "\nonmouseover=\"$action\""; } return "" . $inser_puce . ''; } // http://doc.spip.org/@puce_statut_site_dist function puce_statut_site_dist($id, $statut, $id_rubrique, $type, $ajax=''){ static $coord = array('publie' => 1, 'prop' => 0, 'refuse' => 2, 'poubelle' => 3); if ($type=='syndic') $type='site'; $lang_dir = lang_dir($lang_objet); $puces = array( 0 => 'puce-orange-breve.gif', 1 => 'puce-verte-breve.gif', 2 => 'puce-rouge-breve.gif', 3 => 'puce-blanche-breve.gif'); $t = sql_getfetsel("syndication", "spip_syndic", "id_syndic=".sql_quote($id)); if ($t == 'off' OR $t == 'sus') $anim = 'anim'; else $anim = 'breve'; switch ($statut) { case 'publie': $puce = 'puce-verte-' . $anim .'.gif'; $title = _T('info_site_reference'); break; case 'prop': $puce = 'puce-orange-' . $anim .'.gif'; $title = _T('info_site_attente'); break; case 'refuse': default: $puce = 'puce-poubelle-' . $anim .'.gif'; $title = _T('info_site_refuse'); break; } $type1 = "statut$type$id"; $inser_puce = http_img_pack($puce, $title, "id='img$type1' style='margin: 1px;'"); if ($anim!='breve' OR !autoriser('publierdans','rubrique',$id_rubrique) OR !_ACTIVER_PUCE_RAPIDE) return $inser_puce; // c'est comme les breves : $titles = array( "blanche" => _T('texte_statut_en_cours_redaction'), "orange" => _T('texte_statut_propose_evaluation'), "verte" => _T('texte_statut_publie'), "rouge" => _T('texte_statut_refuse'), "poubelle" => _T('texte_statut_poubelle')); $clip = 1+ (11*$coord[$statut]); if ($ajax){ return "" . $inser_puce . "" . "" . afficher_script_statut($id, $type, -1, $puces[0], 'prop', $titles['orange']) . afficher_script_statut($id, $type, -10, $puces[1], 'publie', $titles['verte']) . afficher_script_statut($id, $type, -19, $puces[2], 'refuse', $titles['rouge']) . ""; } $nom = "puce_statut_"; if ((! _SPIP_AJAX)) $over =''; else { $action = generer_url_ecrire('puce_statut',"",true); $action = "if (!this.puce_loaded) { this.puce_loaded = true; prepare_selec_statut('$nom', '$type', '$id', '$action'); }"; $over = "\nonmouseover=\"$action\""; } return "" . $inser_puce . ''; } // http://doc.spip.org/@puce_statut_syndic_article_dist function puce_statut_syndic_article_dist($id_syndic, $statut, $id_rubrique, $type, $ajax=''){ if ($statut=='publie') { $puce='puce-verte.gif'; } else if ($statut == "refuse") { $puce = 'puce-poubelle.gif'; } else if ($statut == "dispo") { // moderation : a valider $puce = 'puce-rouge.gif'; } else // i.e. $statut=="off" feed d'un site en mode "miroir" $puce = 'puce-rouge-anim.gif'; return http_img_pack($puce, $statut, "class='puce'"); } // La couleur du statut // http://doc.spip.org/@puce_statut function puce_statut($statut, $atts='') { switch ($statut) { case 'publie': $img = 'puce-verte.gif'; $alt = _T('info_article_publie'); return http_img_pack($img, $alt, $atts); case 'prepa': $img = 'puce-blanche.gif'; $alt = _T('info_article_redaction'); return http_img_pack($img, $alt, $atts); case 'prop': $img = 'puce-orange.gif'; $alt = _T('info_article_propose'); return http_img_pack($img, $alt, $atts); case 'refuse': $img = 'puce-rouge.gif'; $alt = _T('info_article_refuse'); return http_img_pack($img, $alt, $atts); case 'poubelle': $img = 'puce-poubelle.gif'; $alt = _T('info_article_supprime'); return http_img_pack($img, $alt, $atts); } return http_img_pack($img, $alt, $atts); } // http://doc.spip.org/@afficher_script_statut function afficher_script_statut($id, $type, $n, $img, $statut, $titre, $act='') { $i = http_wrapper($img); $h = generer_action_auteur("instituer_$type","$id-$statut"); $h = "javascript:selec_statut('$id', '$type', $n, '$i', '$h');"; $t = supprimer_tags($titre); return " "; } ?> spip/spip/ecrire/inc/signatures.php0000766000000000000000000001135011236524730020616 0ustar adminadministrators $pas) { $res = navigation_pagination($t, $pas, generer_url_ecrire($script, $args), $debut, 'debut', false); } else $res = ''; $limit = (!$pas AND !$debut) ? '' : (($debut ? "$debut," : "") . $pas); $arg = "debut=$debut&type=$type"; $res .= "
    \n"; include_spip('inc/urls'); $r = sql_allfetsel('*', 'spip_signatures', $where, '', $order, $limit); foreach($r as $k => $row) $r[$k] = signatures_edit($script, $id, $arg, $row); return $res."
    \n" . join("
    \n", $r); } // http://doc.spip.org/@signatures_edit function signatures_edit($script, $id, $arg, $row) { global $spip_lang_right, $spip_lang_left; $id_signature = $row['id_signature']; $id_article = $row['id_article']; $date_time = $row['date_time']; $nom_email= typo(echapper_tags($row['nom_email'])); $ad_email = echapper_tags($row['ad_email']); $nom_site = typo(echapper_tags($row['nom_site'])); $url_site = echapper_tags($row['url_site']); $statut = $row['statut']; $res = !autoriser('modererpetition', 'article', $id_article) ? '' : true; if ($res) { if ($id) $arg .= "&id_article=$id_article"; $arg .= "#signature$id_signature"; $retour_s = redirige_action_auteur('editer_signatures', $id_signature, $script, $arg); $retour_a = redirige_action_auteur('editer_signatures', "-$id_signature", $script, $arg); $res = ''; if ($statut=="poubelle"){ $res = icone_inline (_T('icone_valider_signature'), $retour_s, "forum-interne-24.gif", "creer.gif", "right", false); } else { $res = icone_inline (_T('icone_supprimer_signature'), $retour_a, "forum-interne-24.gif", "supprimer.gif", "right", false); if ($statut<>"publie") { $res .= icone_inline (_T('icone_relancer_signataire'), $retour_s, "forum-interne-24.gif", "creer.gif", "right", false); } } } $res .= "".date_interface($date_time)."
    \n"; if ($statut=="poubelle"){ $res .= ""._T('info_message_efface')."
    \n"; } if (strlen($url_site)>6) { if (!$nom_site) $nom_site = _T('info_site'); $res .= ""._T('info_site_web')." $nom_site
    \n"; } if (strlen($ad_email)>0){ $res .= ""._T('info_adresse_email')." $ad_email
    \n"; } $res .= message_de_signature($row); if (!$id) { if ($r = sql_fetsel("titre, id_rubrique", "spip_articles", "id_article=$id_article")) { $id_rubrique = $r['id_rubrique']; $titre_a = $r['titre']; $titre_r = supprimer_numero(sql_getfetsel("titre", "spip_rubriques", "id_rubrique=$id_rubrique")); $href = generer_url_ecrire('naviguer', "id_rubrique=" . $id_rubrique); $h2 = generer_url_ecrire_article($id_article); $res .= "
    " . typo($titre_a) . "" . typo($titre_r) . " "; } } $res = "\n" . "\n
    " . ($nom_site ? "$nom_site / " : "") . $nom_email . "
    " . $res . "
    \n"; if ($statut=="poubelle") { $res = "
    " . $res . "
    "; } return $res; } ?> spip/spip/ecrire/inc/notes.php0000766000000000000000000000672711236524730017576 0ustar adminadministrators\'"]*)>)?(.*?))\]\],msS'); function traiter_raccourci_notes($letexte) { global $compt_note, $marqueur_notes, $les_notes, $notes_vues; global $ouvre_ref, $ferme_ref; if (!preg_match_all(_RACCOURCI_NOTES, $letexte, $m, PREG_SET_ORDER)) return array($letexte, array()); // quand il y a plusieurs series de notes sur une meme page $mn = !$marqueur_notes ? '' : ($marqueur_notes.'-'); $mes_notes = array(); foreach ($m as $r) { list($note_source, $note_all, $ref, $nom, $note_texte) = $r; // reperer une note nommee, i.e. entre chevrons // On leve la Confusion avec une balise en regardant // si la balise fermante correspondante existe // Cas pathologique: [[ x]] if (!(isset($nom) AND $ref AND ((strpos($note_texte, '') === false) OR preg_match(",<$nom\W.*,", $note_texte)))) { $nom = ++$compt_note; $note_texte = $note_all; } // eliminer '%' pour l'attribut id $ancre = $mn . str_replace('%','_', rawurlencode($nom)); // ne mettre qu'une ancre par appel de note (XHTML) $att = ($notes_vues[$ancre]++) ? '' : " id='nh$ancre'"; // creer le popup 'title' sur l'appel de note if ($title = supprimer_tags(propre($note_texte))) { $title = " title='" . couper($title,80) . "'"; } // ajouter la note aux notes precedentes if ($note_texte) { $mes_notes[]= array($ancre, $nom, $note_texte); } // dans le texte, mettre l'appel de note a la place de la note if ($nom) $nom = "$ouvre_ref$nom$ferme_ref"; $pos = strpos($letexte, $note_source); $letexte = substr($letexte, 0, $pos) . code_echappement($nom) . substr($letexte, $pos + strlen($note_source)); } return array($letexte, $mes_notes); } // http://doc.spip.org/@traiter_les_notes function traiter_les_notes($notes) { global $ouvre_note, $ferme_note; $mes_notes = '

    '; $title = _T('info_notes'); foreach ($notes as $r) { list($ancre, $nom, $texte) = $r; $atts = " href='#nh$ancre' id='nb$ancre' class='spip_note' title='$title $ancre' rev='footnote'"; $mes_notes .= "\n\n" . code_echappement($nom ? "$ouvre_note$nom$ferme_note" : '') . $texte; } $mes_notes= propre($mes_notes); if ($GLOBALS['class_spip']) $mes_notes = str_replace('

    ', '

    ', $mes_notes); return ($GLOBALS['les_notes'] .= $mes_notes); } ?> spip/spip/ecrire/inc/instituer_auteur.php0000766000000000000000000001742511236524730022056 0ustar adminadministrators" . _T('info_statut_auteur')." " . $menu; // Prepare le bloc des rubriques pour les admins eventuellement restreints ; // si l'auteur n'est pas '0minirezo', on le cache, pour pouvoir le reveler // en jquery lorsque le menu de statut change $vis = in_array($statut, explode(',', _STATUT_AUTEUR_RUBRIQUE)) ? '' : " style='display: none'"; if ($menu_restreints = choix_rubriques_admin_restreint($auteur, $modif)) $res .= "

    " . $menu_restreints . "
    "; return $res; } // http://doc.spip.org/@traduire_statut_auteur function traduire_statut_auteur($statut){ $recom = array("info_administrateurs" => _T('item_administrateur_2'), "info_redacteurs" => _T('intem_redacteur'), "info_visiteurs" => _T('item_visiteur'), '5poubelle' => _T('texte_statut_poubelle'), // bouh ); if (isset($recom[$statut])) return $recom[$statut]; // retrouver directement par le statut sinon if ($t = array_search($statut, $GLOBALS['liste_des_statuts']) AND isset($recom[$t])) return $recom[$t]; return ''; } // Menu de choix d'un statut d'auteur // http://doc.spip.org/@choix_statut_auteur function choix_statut_auteur($statut, $id_auteur, $ancre) { // Le menu doit-il etre actif ? if (!autoriser('modifier', 'auteur', $id_auteur, null, array('statut' => '?'))) return ''; // A-t-on le droit de promouvoir cet auteur comme admin // et y a-t-il des visiteurs ? $droits = $GLOBALS['liste_des_statuts']; if (!autoriser('modifier', 'auteur', $id_auteur, null, array('statut' => '0minirezo'))) unset($droits["info_administrateurs"]); if (!avoir_visiteurs()) unset($droits['info_visiteurs']); $menu = ''; foreach($droits as $k => $v) { if ($k = traduire_statut_auteur($k)) $menu .= mySel($v, $statut, $k); } // Chercher les statuts non standards $l = $GLOBALS['liste_des_statuts']; $l[]= 'nouveau'; $q = sql_allfetsel("statut", 'spip_auteurs', sql_in('statut', $l, 'NOT'), "statut"); $hstatut = htmlentities($statut); foreach ($q as $r) { $nom = htmlentities($r['statut']); $t = traduire_statut_auteur($nom); $t = !$t ? (_T('info_statut_auteur_autre') . ' ' . $nom) : $t; $menu .= mySel($nom, $hstatut, $t); } // Ajouter l'option "nouveau" si l'auteur n'est pas confirme if ($statut == 'nouveau') $menu .= mySel('nouveau',$statut,_T('info_statut_auteur_a_confirmer')); $statut_rubrique = str_replace(',', '|', _STATUT_AUTEUR_RUBRIQUE); return "\n"; } // http://doc.spip.org/@afficher_rubriques_admin_restreintes function afficher_rubriques_admin_restreintes($auteur, $modif = true){ global $spip_lang; $id_auteur = intval($auteur['id_auteur']); $result = sql_select("rubriques.id_rubrique, " . sql_multi ("titre", $spip_lang) . "", "spip_auteurs_rubriques AS lien LEFT JOIN spip_rubriques AS rubriques ON lien.id_rubrique=rubriques.id_rubrique", "lien.id_auteur=$id_auteur", "", "multi"); $menu = $restreint = ''; // L'autorisation de modifier les rubriques restreintes // est egale a l'autorisation de passer en admin $modif &= autoriser('modifier', 'auteur', $id_auteur, null, array('statut' => '0minirezo')); while ($row_admin = sql_fetch($result)) { $id_rubrique = $row_admin["id_rubrique"]; $h = generer_url_ecrire('naviguer', "id_rubrique=$id_rubrique"); $restreint .= "\n
  • " . ($modif ? "\n" : '' ) . "" . typo($row_admin["multi"]) . "" . '
  • '; } if (!$restreint) { $phrase = _T('info_admin_gere_toutes_rubriques')."\n"; } else { $menu = "
      " . $restreint . "
    \n"; // Il faut un element zero pour montrer qu'on a l'interface // sinon il est impossible de deslectionner toutes les rubriques if ($modif) $menu .= "\n"; $phrase = _T('info_admin_gere_rubriques'); } if ($auteur['statut'] != '0minirezo') $phrase = ''; return "

    $phrase

    \n$menu"; } // http://doc.spip.org/@choix_rubriques_admin_restreint function choix_rubriques_admin_restreint($auteur, $modif=true) { global $spip_lang; $id_auteur = intval($auteur['id_auteur']); $res = afficher_rubriques_admin_restreintes($auteur, $modif); // Ajouter une rubrique a un administrateur restreint if ($modif AND autoriser('modifier', 'auteur', $id_auteur, NULL, array('restreintes' => true)) AND $chercher_rubrique = charger_fonction('chercher_rubrique', 'inc') AND $a = $chercher_rubrique(0, 'auteur', false)) { $label = $restreint ? _T('info_ajouter_rubrique') : _T('info_restreindre_rubrique'); $res .= debut_block_depliable(true,"statut$id_auteur") . "\n
    \n" . "" . $label . "" . "\n" . $a . "
    \n" // onchange = pour le menu // l'evenement doit etre provoque a la main par le selecteur ajax . "\n" . fin_block(); } return $res; } ?> spip/spip/ecrire/inc/afficher_objets.php0000766000000000000000000004453111236524730021556 0ustar adminadministrators 'doc-24.gif', 'mot'=>'mot-cle-24.gif','syndic_article'=>'site-24.gif', 'message' => 'messagerie-24.gif', 'groupes_mot'=>'mot-cle-24.gif'); if (isset($derog[$type])) return $derog[$type]; return "$type-24.gif"; } // http://doc.spip.org/@lien_editer_objet function lien_editer_objet($type,$key,$id){ return $type == 'document' ? '' : generer_url_ecrire($type . "s_edit","$key=$id"); } // http://doc.spip.org/@lien_voir_objet function lien_voir_objet($type,$key,$id){ if ($type == 'document') return generer_url_entite($id, 'document'); $exec = array('article'=>'articles','breve'=>'breves_voir','rubrique'=>'naviguer','mot'=>'mots_edit', 'signature'=>'controle_petition'); $exec = isset($exec[$type])?$exec[$type]:$type . "s"; return generer_url_ecrire($exec,"$key=$id"); } // http://doc.spip.org/@afficher_numero_edit function afficher_numero_edit($id, $key, $type,$row=NULL) { global $spip_lang_right, $spip_lang_left,$my_sites; static $numero , $style='' ; if ($type=='syndic_article') { $redirect = _request('id_syndic') ? 'id_syndic='._request('id_syndic') : ''; if (autoriser('modifier',$type,$id)) { if ($row['statut'] == "publie"){ $s = "["._T('info_bloquer_lien')."]"; } else if ($row['statut'] == "refuse"){ $s = "["._T('info_retablir_lien')."]"; } else if ($row['statut'] == "off" AND isset($my_sites[$id]['miroir']) AND $my_sites[$id]['miroir'] == 'oui') { $s = '('._T('syndic_lien_obsolete').')'; } else /* 'dispo' ou 'off' (dans le cas ancien site 'miroir') */ { $s = "["._T('info_valider_lien')."]"; } return $s; } } if (!$style) { $style = " class='spip_xx-small' style='float: $spip_lang_right; padding-$spip_lang_left: 4px; color: black; '"; $numero = _T('info_numero_abbreviation'); } if (!autoriser('modifier',$type,$id) OR !$href = lien_editer_objet($type,$key,$id)) { $bal ='span'; } else { $bal = 'a'; $href = "\nhref='" . $href . "' title='" . _T('bouton_modifier') . "'"; } return "<$bal$style$href>" . $numero . $id . ""; } // libelle du titre de l'objet : // la partie du titre a afficher dans un lien // puis la partie hors lien // http://doc.spip.org/@afficher_titre_objet function afficher_titre_objet($type,$row){ if (function_exists($f = "afficher_titre_$type")) return $f($row); $titre = isset($row['titre'])?sinon($row['titre'], "("._T('info_sans_titre_2').")"): (isset($row['nom'])?sinon($row['nom'], "("._T('info_sans_titre_2').")"): (isset($row['nom_email'])?sinon($row['nom_email'], "("._T('info_sans_titre_2').")"): "")); return array(typo(supprime_img($titre,'')),''); } // http://doc.spip.org/@afficher_titre_site function afficher_titre_site($row){ $nom = $row['nom_site']; $nom = $nom?(strlen($nom)>1?typo($nom):_T('info_sans_titre_2')):("("._T('info_sans_titre_2').")"); $s2 = "   ["._T('lien_visite_site')."]"; return array($nom,$s2); } // http://doc.spip.org/@afficher_titre_auteur function afficher_titre_auteur($row){ return array($row['nom'], ((isset($row['restreint']) AND $row['restreint']) ? ("  "._T('statut_admin_restreint')."") : '')); } // http://doc.spip.org/@afficher_titre_syndic_article function afficher_titre_syndic_article($row){ return array('', recuperer_fond( 'prive/contenu/syndic_article', array('id' => $row['id_syndic_article']) )); } // http://doc.spip.org/@afficher_complement_objet function afficher_complement_objet($type,$row){ if (function_exists($f = "afficher_complement_$type")) return $f($row); return ""; } // http://doc.spip.org/@afficher_complement_site function afficher_complement_site($row){ $syndication = $row['syndication']; $s = ""; if ($syndication == 'off' OR $syndication == 'sus') { $s .= "
    " . http_img_pack('puce-orange-anim.gif', $syndication, "class='puce'",_T('info_panne_site_syndique')) . " "._T('info_probleme_grave')."
    "; } if ($syndication == "oui" or $syndication == "off" OR $syndication == 'sus'){ $s .= "
    "._T('info_syndication')."
    "; } if ($syndication == "oui" OR $syndication == "off" OR $syndication == "sus") { $id_syndic = $row['id_syndic']; $total_art = sql_countsel("spip_syndic_articles", "id_syndic=$id_syndic"); $s .= " " . $total_art . " " . _T('info_syndication_articles'); } else { $s .= " "; } return $s; } // http://doc.spip.org/@afficher_complement_syndic_article function afficher_complement_syndic_article($row){ global $my_sites; if ($GLOBALS['exec'] != 'sites') { $id_syndic = $row['id_syndic']; // $my_sites cache les resultats des requetes sur les sites if (!isset($my_sites[$id_syndic])) $my_sites[$id_syndic] = sql_fetsel("nom_site, moderation, miroir", "spip_syndic", "id_syndic=$id_syndic"); $aff = $my_sites[$id_syndic]['nom_site']; if ($my_sites[$id_syndic]['moderation'] == 'oui') $aff = "$aff"; $s = "$aff"; return $s; } return ""; } // affichage des liste d'objets // Cas generique, utilise pour tout sauf article // http://doc.spip.org/@inc_afficher_objets_dist function inc_afficher_objets_dist($type, $titre,$requete,$formater='', $force=false){ if ($afficher = charger_fonction("afficher_{$type}s",'inc',true)){ return $afficher($titre,$requete,$formater); } if (($GLOBALS['meta']['multi_rubriques'] == 'oui' AND (!isset($GLOBALS['id_rubrique']))) OR $GLOBALS['meta']['multi_articles'] == 'oui') { $afficher_langue = true; if (isset($GLOBALS['langue_rubrique'])) $langue_defaut = $GLOBALS['langue_rubrique']; else $langue_defaut = $GLOBALS['meta']['langue_site']; } else $afficher_langue = $langue_defaut = ''; $arg = array($afficher_langue, false, $langue_defaut, $formater, $type,id_table_objet($type)); if (!function_exists($skel = "afficher_{$type}s_boucle")){ $skel = "afficher_objet_boucle"; } $presenter_liste = charger_fonction('presenter_liste', 'inc'); $tmp_var = 't_' . substr(md5(join('', $requete)), 0, 4); $styles = array(array('arial11', 7), array('arial11'), array('arial1'), array('arial1'), array('arial1 centered', 100), array('arial1', 38)); $tableau = array(); // ne sert pas ici return $presenter_liste($requete, $skel, $tableau, $arg, $force, $styles, $tmp_var, $titre, icone_table($type)); } // http://doc.spip.org/@charger_fonction_logo_if function charger_fonction_logo_if() { global $spip_display; if ($spip_display == 1 OR $spip_display == 4 OR !isset($GLOBALS['meta']['image_process'])) return false; if ($GLOBALS['meta']['image_process'] == "non") return false; return charger_fonction('chercher_logo', 'inc'); } // http://doc.spip.org/@afficher_objet_boucle function afficher_objet_boucle($row, $own) { global $connect_statut, $spip_lang_right; static $chercher_logo = true; list($afficher_langue, $affrub, $langue_defaut, $formater,$type,$primary) = $own; $vals = array(); $id_objet = $row[$primary]; if (autoriser('voir',$type,$id_objet)){ $date_heure = isset($row['date'])?$row['date']:(isset($row['date_heure'])?$row['date_heure']:""); $statut = isset($row['statut'])?$row['statut']:""; if (isset($row['lang'])) changer_typo($lang = $row['lang']); else $lang = $langue_defaut; $lang_dir = lang_dir($lang); $id_rubrique = isset($row['id_rubrique'])?$row['id_rubrique']:0; $puce_statut = charger_fonction('puce_statut', 'inc'); $vals[] = $puce_statut($id_objet, $statut, $id_rubrique, $type); list($titre,$suite) = afficher_titre_objet($type,$row); $flogo = ''; if ($chercher_logo) { if ($chercher_logo !== true OR $chercher_logo = charger_fonction_logo_if()) if ($logo = $chercher_logo($id_objet, $primary, 'on')) { list($fid, $dir, $nom, $format) = $logo; include_spip('inc/filtres_images'); $logo = image_reduire("", 26, 20); if ($logo) $flogo = "\n$logo"; } } if ($titre) { $titre = "" . $titre . ""; } $vals[] = "\n
    $flogo$titre$suite
    "; $s = ""; if ($afficher_langue){ if (isset($row['langue_choisie'])){ $s .= " "; if ($row['langue_choisie'] == "oui") $s .= "".traduire_nom_langue($lang).""; else $s .= "(".traduire_nom_langue($lang).")"; $s .= ""; } elseif ($lang != $langue_defaut) $s .= " ". ($lang ? "(".traduire_nom_langue($lang).")" : '' ) .""; } $vals[] = $s; $vals[] = afficher_complement_objet($type,$row); $s = ""; if ($affrub && $id_rubrique) { $rub = sql_fetsel("id_rubrique, titre", "spip_rubriques", "id_rubrique=$id_rubrique"); $id_rubrique = $rub['id_rubrique']; $s .= "".typo($rub['titre']).""; } else if ($statut){ if ($statut != "prop") $s = affdate_jourcourt($date_heure); else $s .= _T('info_a_valider'); } $vals[] = $s; $vals[] = afficher_numero_edit($id_objet, $primary, $type, $row); } return $vals; } // Cas particuliers ----------------------------------------------------------------- // // Afficher tableau d'articles // // http://doc.spip.org/@inc_afficher_articles_dist function inc_afficher_articles_dist($titre, $requete, $formater='') { if (!isset($requete['FROM'])) $requete['FROM'] = 'spip_articles AS articles'; if (!isset($requete['SELECT'])) { $requete['SELECT'] = "articles.id_article, articles.titre, articles.id_rubrique, articles.statut, articles.date, articles.lang, articles.id_trad, articles.descriptif"; } if (!isset($requete['GROUP BY'])) $requete['GROUP BY'] = ''; $cpt = sql_countsel($requete['FROM'], $requete['WHERE'], $requete['GROUP BY']); if (!$cpt) return '' ; $requete['FROM'] = preg_replace("/(spip_articles(\s+AS\s+\w+)?)/i", "\\1 LEFT JOIN spip_petitions AS petitions ON articles.id_article=petitions.id_article", $requete['FROM']); $requete['SELECT'] .= ", petitions.id_article AS petition "; // memorisation des arguments pour gerer l'affichage par tranche // et/ou par langues. $hash = sauver_requete($titre, $requete, $formater); if (isset($requete['LIMIT'])) $cpt = min($requete['LIMIT'], $cpt); return afficher_articles_trad($titre, $requete, $formater, $hash, $cpt); } // // Stocke la fonction ajax dans le fichier temp pour exec=memoriser // // http://doc.spip.org/@sauver_requete function sauver_requete($titre, $requete, $formater) { $r = $requete; unset($r['ORDER BY']); $hash = substr(md5(serialize($r) . $GLOBALS['meta']['gerer_trad'] . $titre), 0, 31); // on lit l'existant lire_fichier(_DIR_SESSIONS.'ajax_fonctions.txt', $ajax_fonctions); $ajax_fonctions = @unserialize($ajax_fonctions); // on ajoute notre fonction $v = array(time(), $titre, $requete, $formater); $ajax_fonctions[$hash] = $v; // supprime les fonctions trop vieilles foreach ($ajax_fonctions as $h => $fonc) if (time() - $fonc[0] > 48*3600) unset($ajax_fonctions[$h]); // enregistre ecrire_fichier(_DIR_SESSIONS.'ajax_fonctions.txt', serialize($ajax_fonctions)); return $hash; } // http://doc.spip.org/@afficher_articles_trad function afficher_articles_trad($titre_table, $requete, $formater, $hash, $cpt, $trad=0) { global $spip_lang_right; $tmp_var = 't' . substr($hash, 0, 7); if ($trad) { $formater = 'afficher_articles_trad_boucle'; $icone = "langues-off-12.gif"; $alt = _T('masquer_trad'); } else { if (!$formater) $formater = charger_fonction('formater_article', 'inc'); $icone = 'langues-12.gif'; $alt = _T('afficher_trad'); } $texte = '' . $titre_table . ''; // Le parametre o sert a empecher le navigateur de reutiliser // un cache de tranche issu d'un autre tri $arg = "hash=$hash&o=" . $requete['ORDER BY']; /* // DESACTIVE CAR AJOUTE UNE COMPLEXITE INUTILE -- A REVOIR // le micro "afficher les traductions" if (($GLOBALS['meta']['gerer_trad'] == "oui")) { $url = generer_url_ecrire('memoriser',"$arg&trad=" . (1-$trad)); $texte = "\n" . $texte; } */ /* // DESACTIVE CAR AJOUTE UNE COMPLEXITE INUTILE -- A REVOIR $url_t = generer_url_ecrire('memoriser',"hash=$hash&by=0%2Btitre,titre"); $url_t = afficher_boutons_tri($url_t, $tmp_var); $url_d = generer_url_ecrire('memoriser',"hash=$hash&by=date"); $url_d = afficher_boutons_tri($url_d, $tmp_var); */ $url_t = $url_d = ''; $presenter_liste = charger_fonction('presenter_liste', 'inc'); $styles = array(array('', 11), array('arial2','', $url_t), array('arial1', 80), array('arial1', 100, $url_d), array('arial1', 50)); $tableau = array(); $url = generer_url_ecrire('memoriser', "$arg&trad=$trad"); $res = $presenter_liste($requete, $formater, $tableau, array(), false, $styles, $tmp_var, $texte, "article-24.gif", $url, $cpt); return ajax_action_greffe($tmp_var, '', $res); } // http://doc.spip.org/@afficher_boutons_tri function afficher_boutons_tri($url, $tmp_var) { static $monter = ''; static $descendre = ''; if (!$monter) { $monter = http_img_pack('monter-16.png', '<'); $descendre = http_img_pack('descendre-16.png', '>'); } $url_d = generer_onclic_ajax($url ."&order=desc", $tmp_var, 0); $url_a = generer_onclic_ajax($url ."&order=asc", $tmp_var, 0); return "$monter$descendre"; } // http://doc.spip.org/@afficher_articles_trad_boucle function afficher_articles_trad_boucle($row, $own='') { global $spip_lang_right, $spip_display; $id_article = $row['id_article']; if (!autoriser('voir','article',$id_article)) return ''; $titre = $row['titre']; $id_rubrique = $row['id_rubrique']; $statut = $row['statut']; $id_trad = $row['id_trad']; $lang = $row['lang']; $lang_dir = lang_dir($GLOBALS['lang_objet']); $dates_art = $langues_art = array(); $ligne = ""; $res_trad = sql_select("id_article, lang, date_modif", "spip_articles", "id_trad = $id_trad AND id_trad > 0"); while ($row_trad = sql_fetch($res_trad)) { $id_article_trad = $row_trad["id_article"]; $lang_trad = $row_trad["lang"]; $date = $row_trad['date_modif']; $dates_art[$lang_trad] = $date; $langues_art[$lang_trad] = $id_article_trad; if ($id_article_trad == $id_trad) $date_ref = $date; } // faudrait sortir ces invariants de boucle if (($GLOBALS['meta']['multi_rubriques'] == 'oui' AND (!isset($GLOBALS['id_rubrique']))) OR $GLOBALS['meta']['multi_articles'] == 'oui') { $langue_defaut = isset($GLOBALS['langue_rubrique']) ? $GLOBALS['meta']['langue_site'] : $GLOBALS['langue_rubrique']; if ($lang != $langue_defaut) $afficher_langue = " (".traduire_nom_langue($lang).")"; } else $afficher_langue = ''; foreach(explode(',', $GLOBALS['meta']['langues_multilingue']) as $k){ if (isset($langues_art[$k]) AND $langues_art[$k]<> $id_trad){ $h = generer_url_ecrire("articles", "id_article=".$langues_art[$k]); $style = strtotime($dates_art[$k]) < strtotime($date_ref); $style = $style ? 'claire' : 'foncee'; $ligne .= "$k"; } } if (acces_restreint_rubrique($id_rubrique)) $img = http_img_pack("admin-12.gif", _T('titre_image_administrateur'), "width='12' height='12'", _T('titre_image_admin_article')); else $img = ''; if (!$titre) $titre = _T('ecrire:info_sans_titre'); if ($id_article == $id_trad) $titre = "$titre"; $h = generer_url_ecrire("articles", "id_article=$id_article"); $titre = "\n"; if ($spip_display == 4) return array($ligne); $ligne .= "$lang"; // La petite puce de changement de statut $puce_statut = charger_fonction('puce_statut', 'inc'); $puce = $puce_statut($id_article, $statut, $id_rubrique,'article'); return array($puce, $titre, $afficher_langue, "
    " . $ligne . "
    "); } // http://doc.spip.org/@afficher_auteurs_boucle function afficher_auteurs_boucle($row, $own){ $vals = array(); list($afficher_langue, $affrub, $langue_defaut, $formater,$type,$primary) = $own; $formater_auteur = $formater ? $formater : charger_fonction('formater_auteur', 'inc'); if ($row['statut'] == '0minirezo') $row['restreint'] = sql_countsel('spip_auteurs_rubriques', "id_auteur=".intval($row['id_auteur'])); list($s, $mail, $nom, $w, $p) = $formater_auteur($row['id_auteur'],$row); if ($w) { if (preg_match(',^([^>]*>)[^<]*(.*)$,', $w,$r)) { $w = $r[1] . substr($row['site'],0,20) . $r[2]; } } $vals[] = $s; $vals[] = $mail; $vals[] = $nom . ((isset($row['restreint']) AND $row['restreint']) ? ("  "._T('statut_admin_restreint')."") : ''); $vals[] = $w; $vals[] = $p; return $vals; } ?> spip/spip/ecrire/inc/drapeau_edition.php0000766000000000000000000001161711236524730021574 0ustar adminadministrators (id_auteur_modif, date_modif) // a chaque mise a jour de ce tableau on oublie les enregistrements datant // de plus d'une heure // Attention ce n'est pas un verrou "bloquant", juste un drapeau qui signale // que l'on bosse sur un article ; les autres peuvent passer outre // (en cas de communication orale c'est plus pratique) // http://doc.spip.org/@lire_tableau_edition function lire_tableau_edition () { $edition = @unserialize($GLOBALS['meta']['drapeau_edition']); if (!$edition) return array(); $changed = false; $bon_pour_le_service = time()-3600; // parcourir le tableau et virer les vieux foreach ($edition as $objet => $data) { if (!is_array($data)) unset ($edition[$objet]); // vieille version else foreach ($data as $id => $tab) { if (!is_array($tab)) unset ($edition[$objet][$tab]); // vieille version else foreach ($tab as $n => $duo) { if (current($duo) < $bon_pour_le_service) { unset($edition[$objet][$id][$n]); $changed = true; } } if (!$edition[$objet][$id]) unset($edition[$objet][$id]); } if (!$edition[$objet]) unset($edition[$objet]); } if ($changed) ecrire_tableau_edition($edition); return $edition; } // http://doc.spip.org/@ecrire_tableau_edition function ecrire_tableau_edition($edition) { ecrire_meta('drapeau_edition', serialize($edition)); } // J'edite tel objet // http://doc.spip.org/@signale_edition function signale_edition ($id, $auteur, $type='article') { $edition = lire_tableau_edition(); if ($id_a = $auteur['id_auteur']) $nom = $auteur['nom']; else $nom = $id_a = $GLOBALS['ip']; if (!is_array($edition[$type][$id])) $edition[$type][$id] = array(); $edition[$type][$id][$id_a][$nom] = time(); ecrire_tableau_edition($edition); } // Qui edite mon objet ? // http://doc.spip.org/@qui_edite function qui_edite ($id, $type='article') { $edition = lire_tableau_edition(); return $edition ? $edition[$type][$id] : array(); } // http://doc.spip.org/@mention_qui_edite function mention_qui_edite ($id, $type='article') { $modif = qui_edite($id, $type); unset($modif[$GLOBALS['visiteur_session']['id_auteur']]); if ($modif) { $quand = 0; foreach ($modif as $duo) { $auteurs[] = typo(extraire_multi(key($duo))); $quand = max($quand, current($duo)); } // format lie a la chaine de langue 'avis_article_modifie' return array( 'nom_auteur_modif' => join(' | ', $auteurs), 'date_diff' => ceil((time()-$quand) / 60) ); } } // Quels sont les articles en cours d'edition par X ? // http://doc.spip.org/@liste_drapeau_edition function liste_drapeau_edition ($id_auteur, $type = 'article') { $edition = lire_tableau_edition(); $articles_ouverts = array(); foreach ($edition as $objet => $data) if ($objet == 'article') foreach ($data as $id => $auteurs) { if (isset($auteurs[$id_auteur]) AND (array_pop($auteurs[$id_auteur]) > time()-3600)) { $row = sql_fetsel("titre, statut", "spip_articles", "id_article=".$id); $articles_ouverts[] = array( 'id_article' => $id, 'titre' => typo($row['titre']), 'statut' => typo($row['statut']) ); } } return $articles_ouverts; } // Quand l'auteur veut liberer tous ses articles // http://doc.spip.org/@debloquer_tous function debloquer_tous($id_auteur) { $edition = lire_tableau_edition(); foreach ($edition as $objet => $data) if ($objet == 'article') foreach ($data as $id => $auteurs) { if (isset($auteurs[$id_auteur])) { unset ($edition[$objet][$id][$id_auteur]); ecrire_tableau_edition($edition); } } } // quand l'auteur libere un article precis // http://doc.spip.org/@debloquer_edition function debloquer_edition($id_auteur, $debloquer_article, $type='article') { $edition = lire_tableau_edition(); foreach ($edition as $objet => $data) if ($objet == $type) foreach ($data as $id => $auteurs) { if ($id == $debloquer_article AND isset($auteurs[$id_auteur])) { unset ($edition[$objet][$id][$id_auteur]); ecrire_tableau_edition($edition); } } } ?> spip/spip/ecrire/inc/tourner.php0000766000000000000000000001365711236524730020144 0ustar adminadministratorsbasename($document['fichier']))); $res = ""; } else { if ($flag AND !$id_vignette) $res = boutons_rotateurs($document, $type, $id, $id_document,$script); } } else { $res = "\n
    "; // Signaler les documents distants par une icone de trombone $res .= "\n"; // Bouton permettant de copier en local le fichier $res .= bouton_copier_local($document, $type, $id, $id_document, $script); $res .= "
    \n"; } return tourner_greffe($id_document, $document, $url, $res); } // http://doc.spip.org/@tourner_greffe function tourner_greffe($id_document, $document, $url, $res) { $res .= "
    " .document_et_vignette($document, $url, true) ."
    \n" ."
    <doc" . $id_document . ">
    "; return ajax_action_greffe("tourner", $id_document, $res); } // http://doc.spip.org/@boutons_rotateurs function boutons_rotateurs($document, $type, $id, $id_document, $script) { global $spip_lang_right; $process = $GLOBALS['meta']['image_process']; // bloc rotation de l'image // si c'est une image, qu'on sait la faire tourner, qu'elle // n'est pas distante, qu'elle est bien presente dans IMG/ // qu'elle n'a pas de vignette perso ; et qu'on a la bibli ! if ($document['distant']!='oui' AND in_array($document['extension'], array('gif', 'jpg', 'png')) AND (strpos($GLOBALS['meta']['formats_graphiques'], $document['extension'])!==false) AND ($process == 'imagick' OR $process == 'gd2' OR $process == 'convert' OR $process == 'netpbm') AND @file_exists(get_spip_doc($document['fichier'])) ) { return "\n
    " . bouton_tourner_document($id, $id_document, $script, -90, $type, 'tourner-gauche.gif', _T('image_tourner_gauche')) . bouton_tourner_document($id, $id_document, $script, 90, $type, 'tourner-droite.gif', _T('image_tourner_droite')) . bouton_tourner_document($id, $id_document, $script, 180, $type, 'tourner-180.gif', _T('image_tourner_180')) . "
    \n"; } } // http://doc.spip.org/@bouton_tourner_document function bouton_tourner_document($id, $id_document, $script, $rot, $type, $img, $title) { return ajax_action_auteur("tourner", "$id_document-$rot", $script, "show_docs=$id_document&id_$type=$id#tourner-$id_document", array(http_img_pack($img, $title, ''), " class='bouton_rotation'"), "&id_document=$id_document&id=$id&type=$type"); } // Retourne le code HTML du bouton "copier en local". // http://doc.spip.org/@bouton_copier_local function bouton_copier_local($document, $type, $id, $id_document, $script) { global $spip_lang_right; // pour etre sur qu'il s'agit bien d'un doc distant // et qu'il existe $bouton_copier = ''; if ($document['distant'] == 'oui' /* on pourrait verifier l'existence du // fichier ici, mais ne risque pas-t-on de degrader les performances ? // il sera toujours temps de le verifier lorsque l'utilisateur cliquera // sur le bouton. */) { $bouton_copier = ajax_action_auteur("copier_local", "$id_document", $script, "show_docs=$id_document&id_$type=$id#tourner-$id_document", array(http_img_pack('telecharger.gif', _T('copier_en_local'), ''), " class='bouton_rotation'"), // on aurait pu faire un nouveau style 'bouton-telecharger', // mais pour l'instant on se contente de reutiliser celui-ci // afin de garder une homogeneite entre les differents boutons. "&id_document=$id_document&id=$id&type=$type"); // Hack ? // demander confirmation javascript $u = str_replace("'", "\\'", unicode_to_javascript(html2unicode(_T('copier_en_local') . ' ' . $document['fichier']))); $bouton_copier = str_replace('return AjaxSqueeze', "return (!confirm('$u'))?false:AjaxSqueeze", $bouton_copier); } return $bouton_copier; } ?> spip/spip/ecrire/inc/texte.php0000766000000000000000000007072711236524730017600 0ustar adminadministrators)?/S", /* 7 */ "/[{][{]/S", /* 8 */ "/[}][}]/S", /* 9 */ "/[{]/S", /* 10 */ "/[}]/S", /* 11 */ "/(?:){2,}/S", /* 12 */ "/

    \n*(?:\n*)*/S", /* 13 */ "//S", /* 14 */ "/<\/quote>/S", /* 15 */ "/<\/?intro>/S" ), array( /* 4 */ "\$1\n\n" . $debut_intertitre, /* 5 */ $fin_intertitre ."\n\n\$1", /* 6 */ "

    ", /* 7 */ $debut_gras, /* 8 */ $fin_gras, /* 9 */ $debut_italique, /* 10 */ $fin_italique, /* 11 */ "

    ", /* 12 */ "

    ", /* 13 */ "

    ", /* 14 */ "

    ", /* 15 */ "" ) ); // Raccourcis dependant du sens de la langue function definir_raccourcis_alineas() { global $ligne_horizontale; static $alineas = array(); $x = _DIR_RESTREINT ? lang_dir() : lang_dir($GLOBALS['spip_lang']); if (!isset($alineas[$x])) { $alineas[$x] = array( array( /* 0 */ "/\n(----+|____+)/S", /* 1 */ "/\n-- */S", /* 2 */ "/\n- */S", /* DOIT rester a cette position */ /* 3 */ "/\n_ +/S" ), array( /* 0 */ "\n\n" . $ligne_horizontale . "\n\n", /* 1 */ "\n
    — ", /* 2 */ "\n
    ".definir_puce()." ", /* 3 */ "\n
    " ) ); } return $alineas[$x]; } // On initialise la puce pour eviter find_in_path() a chaque rencontre de \n- // Mais attention elle depend de la direction et de X_fonctions.php, ainsi que // de l'espace choisi (public/prive) // http://doc.spip.org/@definir_puce function definir_puce() { // Attention au sens, qui n'est pas defini de la meme facon dans // l'espace prive (spip_lang est la langue de l'interface, lang_dir // celle du texte) et public (spip_lang est la langue du texte) $dir = _DIR_RESTREINT ? lang_dir() : lang_dir($GLOBALS['spip_lang']); $p = 'puce' . (test_espace_prive() ? '_prive' : ''); if ($dir == 'rtl') $p .= '_rtl'; if (!isset($GLOBALS[$p])) { $img = find_in_path($p.'.gif'); list(,,,$size) = @getimagesize($img); $GLOBALS[$p] = '-'; } return $GLOBALS[$p]; } // XHTML - Preserver les balises-bloc : on liste ici tous les elements // dont on souhaite qu'ils provoquent un saut de paragraphe define('_BALISES_BLOCS', 'div|pre|ul|ol|li|blockquote|h[1-6r]|' .'t(able|[rdh]|body|foot|extarea)|' .'form|object|center|marquee|address|' .'d[ltd]|script|noscript|map|button|fieldset'); // // Echapper les les elements perilleux en les passant en base64 // // Creer un bloc base64 correspondant a $rempl ; au besoin en marquant // une $source differente ; le script detecte automagiquement si ce qu'on // echappe est un div ou un span // http://doc.spip.org/@code_echappement function code_echappement($rempl, $source='', $no_transform=false) { if (!strlen($rempl)) return ''; // Tester si on echappe en span ou en div $mode = preg_match(',[:space:]],iS', $rempl) ? 'div' : 'span'; $return = ''; // Decouper en morceaux, base64 a des probleme selon la taille de la pile $taille = 30000; for($i = 0; $i < strlen($rempl); $i += $taille) { // Convertir en base64 $base64 = base64_encode(substr($rempl, $i, $taille)); $return .= inserer_attribut("<$mode class=\"base64$source\">", 'title', $base64) .""; } return $return . ((!$no_transform AND $mode == 'div') ? "\n\n" : '' ); ; } // Echapper les ... // http://doc.spip.org/@traiter_echap_html_dist function traiter_echap_html_dist($regs) { return $regs[3]; } // Echapper les ... // http://doc.spip.org/@traiter_echap_code_dist function traiter_echap_code_dist($regs) { $echap = htmlspecialchars($regs[3]); // il ne faut pas passer dans entites_html, ne pas transformer les &#xxx; du code ! // ne pas mettre le s'il n'y a qu'une ligne if (is_int(strpos($echap,"\n"))) { // supprimer les sauts de ligne debut/fin // (mais pas les espaces => ascii art). $echap = preg_replace("/^[\n\r]+|[\n\r]+$/s", "", $echap); $echap = nl2br($echap); $echap = "

    " .$echap."
    "; } else { $echap = "".$echap.""; } $echap = str_replace("\t", "        ", $echap); $echap = str_replace(" ", "  ", $echap); return $echap; } // Echapper les ... aka ... // http://doc.spip.org/@traiter_echap_cadre_dist function traiter_echap_cadre_dist($regs) { $echap = trim(entites_html($regs[3])); // compter les lignes un peu plus finement qu'avec les \n $lignes = explode("\n",trim($echap)); $n = 0; foreach($lignes as $l) $n+=floor(strlen($l)/60)+1; $n = max($n,2); $echap = "\n"; return generer_form_ecrire('', $echap, " method='get'"); } // http://doc.spip.org/@traiter_echap_frame_dist function traiter_echap_frame_dist($regs) { return traiter_echap_cadre_dist($regs); } // http://doc.spip.org/@traiter_echap_script_dist function traiter_echap_script_dist($regs) { // rendre joli (et inactif) si c'est un script language=php if (preg_match(',]+php,ims', $regs[0])) return highlight_string($regs[0],true); // Cas normal : le script passe tel quel return $regs[0]; } define('_PROTEGE_BLOCS', ',<(html|code|cadre|frame|script)(\s[^>]*)?>(.*),UimsS'); // - pour $source voir commentaire infra (echappe_retour) // - pour $no_transform voir le filtre post_autobr dans inc/filtres // http://doc.spip.org/@echappe_html function echappe_html($letexte, $source='', $no_transform=false, $preg='') { if (!is_string($letexte) or !strlen($letexte)) return $letexte; if (preg_match_all($preg ? $preg : _PROTEGE_BLOCS, $letexte, $matches, PREG_SET_ORDER)) foreach ($matches as $regs) { // echappements tels quels ? if ($no_transform) { $echap = $regs[0]; } // sinon les traiter selon le cas else if (function_exists($f = 'traiter_echap_'.strtolower($regs[1]))) $echap = $f($regs); else if (function_exists($f = $f.'_dist')) $echap = $f($regs); $letexte = str_replace($regs[0], code_echappement($echap, $source, $no_transform), $letexte); } if ($no_transform) return $letexte; // Gestion du TeX if (strpos($letexte, "") !== false) { include_spip('inc/math'); $letexte = traiter_math($letexte, $source); } // Echapper le php pour faire joli (ici, c'est pas pour la securite) if (preg_match_all(',<[?].*($|[?]>),UisS', $letexte, $matches, PREG_SET_ORDER)) foreach ($matches as $regs) { $letexte = str_replace($regs[0], code_echappement(highlight_string($regs[0],true), $source), $letexte); } return $letexte; } // // Traitement final des echappements // Rq: $source sert a faire des echappements "a soi" qui ne sont pas nettoyes // par propre() : exemple dans ecrire/inc_articles_ortho.php, $source='ORTHO' // ou encore dans typo() // http://doc.spip.org/@echappe_retour function echappe_retour($letexte, $source='', $filtre = "") { if (strpos($letexte,"base64$source")) { # spip_log(htmlspecialchars($letexte)); ## pour les curieux if (preg_match_all(',<(span|div) class=[\'"]base64'.$source.'[\'"]\s.*>\s*,UmsS', $letexte, $regs, PREG_SET_ORDER)) { foreach ($regs as $reg) { $rempl = base64_decode(extraire_attribut($reg[0], 'title')); if ($filtre) $rempl = $filtre($rempl); $letexte = str_replace($reg[0], $rempl, $letexte); } } } return $letexte; } // Reinserer le javascript de confiance (venant des modeles) // http://doc.spip.org/@echappe_retour_modeles function echappe_retour_modeles($letexte, $interdire_scripts=false) { $letexte = echappe_retour($letexte); // Dans les appels directs hors squelette, securiser aussi ici if ($interdire_scripts) $letexte = interdire_scripts($letexte,true); return trim($letexte); } // http://doc.spip.org/@couper function couper($texte, $taille=50, $suite = ' (...)') { if (!($length=strlen($texte)) OR $taille <= 0) return ''; $offset = 400 + 2*$taille; while ($offset<$length AND strlen(preg_replace(",<[^>]+>,Uims","",substr($texte,0,$offset)))<$taille) $offset = 2*$offset; if ( $offset<$length && ($p_tag_ouvrant = strpos($texte,'<',$offset))!==NULL){ $p_tag_fermant = strpos($texte,'>',$offset); if ($p_tag_fermant<$p_tag_ouvrant) $offset = $p_tag_fermant+1; // prolonger la coupe jusqu'au tag fermant suivant eventuel } $texte = substr($texte, 0, $offset); /* eviter de travailler sur 10ko pour extraire 150 caracteres */ // on utilise les \r pour passer entre les gouttes $texte = str_replace("\r\n", "\n", $texte); $texte = str_replace("\r", "\n", $texte); // sauts de ligne et paragraphes $texte = preg_replace("/\n\n+/", "\r", $texte); $texte = preg_replace("/<(p|br)( [^>]*)?".">/", "\r", $texte); // supprimer les traits, lignes etc $texte = preg_replace("/(^|\r|\n)(-[-#\*]*|_ )/", "\r", $texte); // supprimer les tags $texte = supprimer_tags($texte); $texte = trim(str_replace("\n"," ", $texte)); $texte .= "\n"; // marquer la fin // travailler en accents charset $texte = unicode2charset(html2unicode($texte, /* secure */ true)); $texte = nettoyer_raccourcis_typo($texte); // corriger la longueur de coupe // en fonction de la presence de caracteres utf if ($GLOBALS['meta']['charset']=='utf-8'){ $long = charset2unicode($texte); $long = spip_substr($long, 0, max($taille,1)); $nbcharutf = preg_match_all('/(&#[0-9]{3,5};)/S', $long, $matches); $taille += $nbcharutf; } // couper au mot precedent $long = spip_substr($texte, 0, max($taille-4,1)); $u = $GLOBALS['meta']['pcre_u']; $court = preg_replace("/([^\s][\s]+)[^\s]*\n?$/".$u, "\\1", $long); $points = $suite; // trop court ? ne pas faire de (...) if (spip_strlen($court) < max(0.75 * $taille,2)) { $points = ''; $long = spip_substr($texte, 0, $taille); $texte = preg_replace("/([^\s][\s]+)[^\s]*\n?$/".$u, "\\1", $long); // encore trop court ? couper au caractere if (spip_strlen($texte) < 0.75 * $taille) $texte = $long; } else $texte = $court; if (strpos($texte, "\n")) // la fin est encore la : c'est qu'on n'a pas de texte de suite $points = ''; // remettre les paragraphes $texte = preg_replace("/\r+/", "\n\n", $texte); // supprimer l'eventuelle entite finale mal coupee $texte = preg_replace('/&#?[a-z0-9]*$/S', '', $texte); return quote_amp(trim($texte)).$points; } // // Les elements de propre() // // afficher joliment les ', $t); return $t; } // http://doc.spip.org/@protege_js_modeles function protege_js_modeles($t) { if (isset($GLOBALS['visiteur_session'])){ if (preg_match_all(',),isS', $t, $r, PREG_SET_ORDER)){ if (!defined('_PROTEGE_PHP_MODELES')){ include_spip('inc/acces'); define('_PROTEGE_PHP_MODELES',creer_uniqid()); } foreach ($r as $regs) $t = str_replace($regs[0],code_echappement($regs[0],'php'._PROTEGE_PHP_MODELES),$t); } } return $t; } // Securite : empecher l'execution de code PHP, en le transformant en joli code // dans l'espace prive, cette fonction est aussi appelee par propre et typo // si elles sont appelees en direct // il ne faut pas desactiver globalement la fonction dans l'espace prive car elle protege // aussi les balises des squelettes qui ne passent pas forcement par propre ou typo apres // http://doc.spip.org/@interdire_scripts function interdire_scripts($t) { // rien ? if (!$t OR !strstr($t, '<')) return $t; // echapper les tags asp/php $t = str_replace('<'.'%', '<%', $t); // echapper le php $t = str_replace('<'.'?', '<?', $t); // echapper le < script language=php > $t = preg_replace(',<(script\b[^>]+\blanguage\b[^\w>]+php\b),UimsS', '<\1', $t); // Pour le js, trois modes : parano (-1), prive (0), ok (1) switch($GLOBALS['filtrer_javascript']) { case 0: if (!_DIR_RESTREINT) $t = echappe_js($t,' style="color:red"'); break; case -1: $t = echappe_js($t); break; } // pas de svp ! $t = preg_replace(',<(base\b),iS', '<\1', $t); // Reinserer les echappements des modeles if (defined('_PROTEGE_JS_MODELES')) $t = echappe_retour($t,"javascript"._PROTEGE_JS_MODELES); if (defined('_PROTEGE_PHP_MODELES')) $t = echappe_retour($t,"php"._PROTEGE_PHP_MODELES); return $t; } // Securite : utiliser SafeHTML s'il est present dans ecrire/safehtml/ // http://doc.spip.org/@safehtml function safehtml($t) { static $safehtml; # attention safehtml nettoie deux ou trois caracteres de plus. A voir if (strpos($t,'<')===false) return str_replace("\x00", '', $t); $t = interdire_scripts($t); // jolifier le php $t = echappe_js($t); if (!isset($safehtml)) $safehtml = charger_fonction('safehtml', 'inc'); if ($safehtml) $t = $safehtml($t); return interdire_scripts($t); // interdire le php (2 precautions) } // Typographie generale // avec protection prealable des balises HTML et SPIP // http://doc.spip.org/@typo function typo($letexte, $echapper=true, $connect=null) { // Plus vite ! if (!$letexte) return $letexte; // les appels directs a cette fonction depuis le php de l'espace // prive etant historiquement ecrit sans argment $connect // on utilise la presence de celui-ci pour distinguer les cas // ou il faut passer interdire_script explicitement // les appels dans les squelettes (de l'espace prive) fournissant un $connect // ne seront pas perturbes $interdire_script = false; if (is_null($connect)){ $connect = ''; $interdire_script = true; } // Echapper les codes etc if ($echapper) $letexte = echappe_html($letexte, 'TYPO'); // // Installer les modeles, notamment images et documents ; // // NOTE : propre() ne passe pas par ici mais directement par corriger_typo // cf. inc/lien $letexte = traiter_modeles($mem = $letexte, false, $echapper ? 'TYPO' : '', $connect); if ($letexte != $mem) $echapper = true; unset($mem); $letexte = corriger_typo($letexte); // reintegrer les echappements if ($echapper) $letexte = echappe_retour($letexte, 'TYPO'); // Dans les appels directs hors squelette, securiser ici aussi if ($interdire_script) $letexte = interdire_scripts($letexte); return $letexte; } // Correcteur typographique // http://doc.spip.org/@corriger_typo function corriger_typo($letexte) { // Plus vite ! if (!$letexte) return $letexte; $letexte = pipeline('pre_typo', $letexte); // Caracteres de controle "illegaux" $letexte = corriger_caracteres($letexte); // Charger & appliquer la fonction de typographie if ($typographie = charger_fonction(lang_typo(), 'typographie')) { // Proteger les caracteres typographiques a l'interieur des tags html $protege = "!':;?~%-"; $illegal = "\x1\x2\x3\x4\x5\x6\x7\x8"; if (preg_match_all(',]*['.preg_quote($protege).'][^<>]*>,imsS', $letexte, $regs, PREG_SET_ORDER)) { foreach ($regs as $reg) { $insert = $reg[0]; // hack: on transforme les caracteres a proteger en les remplacant // par des caracteres "illegaux". (cf corriger_caracteres()) $insert = strtr($insert, $protege, $illegal); $letexte = str_replace($reg[0], $insert, $letexte); } } $letexte = $typographie($letexte); // Retablir les caracteres proteges $letexte = strtr($letexte, $illegal, $protege); } $letexte = pipeline('post_typo', $letexte); # un message pour abs_url - on est passe en mode texte $GLOBALS['mode_abs_url'] = 'texte'; return $letexte; } // // Tableaux // define('_RACCOURCI_TH_SPAN', '\s*(:?{{[^{}]+}}\s*)?|<'); // http://doc.spip.org/@traiter_tableau function traiter_tableau($bloc) { // Decouper le tableau en lignes preg_match_all(',([|].*)[|]\n,UmsS', $bloc, $regs, PREG_PATTERN_ORDER); $lignes = array(); $debut_table = $summary = ''; $l = 0; $numeric = true; // Traiter chaque ligne $reg_line1 = ',^(\|(' . _RACCOURCI_TH_SPAN . '))+$,sS'; $reg_line_all = ',^' . _RACCOURCI_TH_SPAN . '$,sS'; foreach ($regs[1] as $ligne) { $l ++; // Gestion de la premiere ligne : if ($l == 1) { // - et summary dans la premiere ligne : // || caption | summary || (|summary est optionnel) if (preg_match(',^\|\|([^|]*)(\|(.*))?$,sS', rtrim($ligne,'|'), $cap)) { $l = 0; if ($caption = trim($cap[1])) $debut_table .= "".$caption."\n"; $summary = ' summary="'.entites_html(trim($cap[3])).'"'; } // - sous la forme |{{titre}}|{{titre}}| // Attention thead oblige a avoir tbody else if (preg_match($reg_line1, $ligne, $thead)) { preg_match_all('/\|([^|]*)/S', $ligne, $cols); $ligne='';$cols= $cols[1]; $colspan=1; for($c=count($cols)-1; $c>=0; $c--) { $attr=''; if($cols[$c]=='<') { $colspan++; } else { if($colspan>1) { $attr= " colspan='$colspan'"; $colspan=1; } $ligne= "$cols[$c]$ligne"; } } $debut_table .= "". $ligne."\n"; $l = 0; } } // Sinon ligne normale if ($l) { // Gerer les listes a puce dans les cellules if (strpos($ligne,"\n-*")!==false OR strpos($ligne,"\n-#")!==false) $ligne = traiter_listes($ligne); // Pas de paragraphes dans les cellules $ligne = preg_replace("/\n{2,}/", "
    \n", $ligne); // tout mettre dans un tableau 2d preg_match_all('/\|([^|]*)/S', $ligne, $cols); $lignes[]= $cols[1]; } } // maintenant qu'on a toutes les cellules // on prepare une liste de rowspan par defaut, a partir // du nombre de colonnes dans la premiere ligne. // Reperer egalement les colonnes numeriques pour les cadrer a droite $rowspans = $numeric = array(); $n = count($lignes[0]); $k = count($lignes); for($i=0;$i<$n;$i++) { $align = true; for ($j=0;$j<$k;$j++) $rowspans[$j][$i] = 1; for ($j=0;$j<$k;$j++) { $cell = trim($lignes[$j][$i]); if (preg_match($reg_line_all, $cell)) { if (!preg_match('/^\d+([.,]?)\d*$/', $cell, $r)) { $align = ''; break;} else if ($r[1]) $align = $r[1]; } } $numeric[$i] = !$align ? '' : (" style='text-align: " . // http://www.w3.org/TR/REC-CSS2/tables.html#column-alignment // specifie text-align: "," pour cadrer le long de la virgule // mais les navigateurs ne l'implementent pas ou mal (/* $align !== true ?"\"$align\"" : */ 'right') . "'"); } // et on parcourt le tableau a l'envers pour ramasser les // colspan et rowspan en passant $html = ''; for($l=count($lignes)-1; $l>=0; $l--) { $cols= $lignes[$l]; $colspan=1; $ligne=''; for($c=count($cols)-1; $c>=0; $c--) { $attr= $numeric[$c]; $cell = trim($cols[$c]); if($cell=='<') { $colspan++; } elseif($cell=='^') { $rowspans[$l-1][$c]+=$rowspans[$l][$c]; } else { if($colspan>1) { $attr .= " colspan='$colspan'"; $colspan=1; } if(($x=$rowspans[$l][$c])>1) { $attr.= " rowspan='$x'"; } $ligne= "\n'.$cols[$c].''.$ligne; } } // ligne complete $class = alterner($l+1, 'even', 'odd'); $html = "$ligne\n$html"; } return "\n\n\n" . $debut_table . "\n" . $html . "\n" . "\n\n"; } // // Traitement des listes (merci a Michael Parienti) // // http://doc.spip.org/@traiter_listes function traiter_listes ($texte) { global $class_spip, $class_spip_plus; $parags = preg_split(",\n[[:space:]]*\n,S", $texte); $texte =''; // chaque paragraphe est traite a part while (list(,$para) = each($parags)) { $niveau = 0; $lignes = explode("\n-", "\n" . $para); // ne pas toucher a la premiere ligne list(,$debut) = each($lignes); $texte .= $debut; // chaque item a sa profondeur = nb d'etoiles $type =''; while (list(,$item) = each($lignes)) { preg_match(",^([*]*|[#]*)([^*#].*)$,sS", $item, $regs); $profond = strlen($regs[1]); if ($profond > 0) { $ajout=''; // changement de type de liste au meme niveau : il faut // descendre un niveau plus bas, fermer ce niveau, et // remonter $nouv_type = (substr($item,0,1) == '*') ? 'ul' : 'ol'; $change_type = ($type AND ($type <> $nouv_type) AND ($profond == $niveau)) ? 1 : 0; $type = $nouv_type; // d'abord traiter les descentes while ($niveau > $profond - $change_type) { $ajout .= $pile_li[$niveau]; $ajout .= $pile_type[$niveau]; if (!$change_type) unset ($pile_li[$niveau]); $niveau --; } // puis les identites (y compris en fin de descente) if ($niveau == $profond && !$change_type) { $ajout .= $pile_li[$niveau]; } // puis les montees (y compris apres une descente un cran trop bas) while ($niveau < $profond) { if ($niveau == 0) $ajout .= "\n\n"; $niveau ++; $ajout .= "<$type$class_spip_plus>"; $pile_type[$niveau] = ""; } $ajout .= ""; $pile_li[$profond] = ""; } else { $ajout = "\n-"; // puce normale ou
    } $texte .= $ajout . $regs[2]; } // retour sur terre $ajout = ''; while ($niveau > 0) { $ajout .= $pile_li[$niveau]; $ajout .= $pile_type[$niveau]; $niveau --; } $texte .= $ajout; // paragraphe $texte .= "\n\n"; } // sucrer les deux derniers \n return substr($texte, 0, -2); } // fonction en cas de texte extrait d'un serveur distant: // on ne sait pas (encore) rapatrier les documents joints // Sert aussi a nettoyer un texte qu'on veut mettre dans un etc. // TODO: gerer les modeles ? // http://doc.spip.org/@supprime_img function supprime_img($letexte, $message=NULL) { if ($message===NULL) $message = '(' . _T('img_indisponible') . ')'; return preg_replace(',<(img|doc|emb)([0-9]+)(\|([^>]*))?'.'\s*/?'.'>,i', $message, $letexte); } // // Une fonction pour fermer les paragraphes ; on essaie de preserver // des paragraphes indiques a la main dans le texte // (par ex: on ne modifie pas un

    ) // // deuxieme argument : forcer les

    meme pour un seul paragraphe // // http://doc.spip.org/@paragrapher function paragrapher($letexte, $forcer=true) { global $class_spip; $letexte = trim($letexte); if (!strlen($letexte)) return ''; if ($forcer OR ( strstr($letexte,'<') AND preg_match(', et un "STOP P" // transformer aussi les

    existants en

    , nettoyes ensuite $letexte = preg_replace(',,UiS', '

    ', '

    '.$letexte.''); // Fermer les paragraphes (y compris sur "STOP P") $letexte = preg_replace(',([:space:]]),UimsS', "\n\\1

    \n\\2", $letexte); // Supprimer les marqueurs "STOP P" $letexte = str_replace('', '', $letexte); // Reduire les blancs dans les

    $u = @$GLOBALS['meta']['pcre_u']; $letexte = preg_replace(',()\s*,UiS'.$u, '\1',$letexte); $letexte = preg_replace(',\s*(),UiS'.$u, '\1',$letexte); // Supprimer les

    vides $letexte = preg_replace(',]*>

    \s*,iS'.$u, '', $letexte); // Renommer les paragraphes normaux $letexte = str_replace('

    ', "", $letexte); } return $letexte; } // http://doc.spip.org/@traiter_poesie function traiter_poesie($letexte) { if (preg_match_all(",<(poesie|poetry)>(.*)<\/(poesie|poetry)>,UimsS", $letexte, $regs, PREG_SET_ORDER)) { $u = "/\n[\s]*\n/S" . $GLOBALS['meta']['pcre_u']; foreach ($regs as $reg) { $lecode = preg_replace(",\r\n?,S", "\n", $reg[2]); $lecode = preg_replace($u, "\n \n",$lecode); $lecode = "

    \n
    " .preg_replace("/\n+/", "
    \n
    ", trim($lecode)) ."
    \n
    \n\n"; $letexte = str_replace($reg[0], $lecode, $letexte); } } return $letexte; } // Harmonise les retours chariots et mange les paragraphes html // http://doc.spip.org/@traiter_retours_chariots function traiter_retours_chariots($letexte) { $letexte = preg_replace(",\r\n?,S", "\n", $letexte); $letexte = preg_replace(",[:space:]],iS", "\n\n\\0", $letexte); $letexte = preg_replace(",[:space:]],iS", "\\0\n\n", $letexte); return $letexte; } // Ces deux constantes permettent de proteger certains caracteres // en les remplacanat par des caracteres "illegaux". (cf corriger_caracteres) define('_RACCOURCI_PROTEGER', "{}_-"); define('_RACCOURCI_PROTECTEUR', "\x1\x2\x3\x4"); define('_RACCOURCI_BALISE', ",]*[".preg_quote(_RACCOURCI_PROTEGER)."][^<>]*>,imsS"); // Nettoie un texte, traite les raccourcis autre qu'URL, la typo, etc. // http://doc.spip.org/@traiter_raccourcis function traiter_raccourcis($letexte) { // Appeler les fonctions de pre_traitement $letexte = pipeline('pre_propre', $letexte); // Gerer les notes (ne passe pas dans le pipeline) $notes = charger_fonction('notes', 'inc'); list($letexte, $mes_notes) = $notes($letexte); // // Tableaux // // ne pas oublier les tableaux au debut ou a la fin du texte $letexte = preg_replace(",^\n?[|],S", "\n\n|", $letexte); $letexte = preg_replace(",\n\n+[|],S", "\n\n\n\n|", $letexte); $letexte = preg_replace(",[|](\n\n+|\n?$),S", "|\n\n\n\n", $letexte); if (preg_match_all(',[^|](\n[|].*[|]\n)[^|],UmsS', $letexte, $regs, PREG_SET_ORDER)) foreach ($regs as $t) { $letexte = str_replace($t[1], traiter_tableau($t[1]), $letexte); } $letexte = "\n".trim($letexte); // les listes if (strpos($letexte,"\n-*")!==false OR strpos($letexte,"\n-#")!==false) $letexte = traiter_listes($letexte); // Proteger les caracteres actifs a l'interieur des tags html if (preg_match_all(_RACCOURCI_BALISE, $letexte, $regs, PREG_SET_ORDER)) { foreach ($regs as $reg) { $insert = strtr($reg[0], _RACCOURCI_PROTEGER, _RACCOURCI_PROTECTEUR); $letexte = str_replace($reg[0], $insert, $letexte); } } // Traitement des alineas list($a,$b) = definir_raccourcis_alineas(); $letexte = preg_replace($a, $b, $letexte); // Introduction des attributs class_spip* et autres raccourcis list($a,$b) = $GLOBALS['spip_raccourcis_typo']; $letexte = preg_replace($a, $b, $letexte); $letexte = preg_replace('@^\n
    @S', '', $letexte); // Retablir les caracteres proteges $letexte = strtr($letexte, _RACCOURCI_PROTECTEUR, _RACCOURCI_PROTEGER); // Fermer les paragraphes ; mais ne pas en creer si un seul $letexte = paragrapher($letexte, $GLOBALS['toujours_paragrapher']); // Appeler les fonctions de post-traitement $letexte = pipeline('post_propre', $letexte); if ($mes_notes) $notes($mes_notes); return $letexte; } // Filtre a appliquer aux champs du type #TEXTE* // http://doc.spip.org/@propre function propre($t, $connect=null) { // les appels directs a cette fonction depuis le php de l'espace // prive etant historiquement ecrits sans argment $connect // on utilise la presence de celui-ci pour distinguer les cas // ou il faut passer interdire_script explicitement // les appels dans les squelettes (de l'espace prive) fournissant un $connect // ne seront pas perturbes $interdire_script = false; if (is_null($connect)){ $connect = ''; $interdire_script = true; } return !$t ? strval($t) : echappe_retour_modeles( traiter_raccourcis( expanser_liens(echappe_html($t),$connect)),$interdire_script); } ?> spip/spip/ecrire/inc/forum.php0000766000000000000000000004705011236524730017570 0ustar adminadministrators $pas) { if ($date) { preg_match('/^\w+/', $query['ORDER BY'], $m); $debut = navigation_trouve_date($date, $m[0], $pas, $query); } if ($total <= $debut) $debut = $total-$pas; $max = min($total, $debut+$enplus); $tranche = $debut; while (($tranche + $enplus) >= $max) $tranche -= $pas; if ($tranche <0) $tranche = 0; $h = generer_url_ecrire($script, $args); $nav = (!$tranche ? '' : "
    0| ... |\n"); $e = (_SPIP_AJAX === 1 ); for (;$tranche<$max;$tranche+=$pas){ if ($tranche == $debut) $nav .= "$tranche |\n"; else { $h = "$args&debut=$tranche"; $h = generer_url_ecrire($script, $h); if ($e) $e = "\nonclick=" . ajax_action_declencheur($h,$script); $nav .= "$tranche |\n"; } } if ($tranche < $total) { $h = generer_url_ecrire($script, $args . "&debut=" . $total); if ($e) { $e = "\nonclick=" . ajax_action_declencheur($h,$script); } $nav .= "... | $total"; } } $query['LIMIT'] = "$debut, $pas"; return $nav; } // http://doc.spip.org/@navigation_trouve_date function navigation_trouve_date($date, $nom_date, $pas, $query) { $debut = 0; if (!is_numeric($date)) { include_spip('inc/filtres'); list($a,$m,$j,$h,$n,$s) = recup_date($date); $date = mktime($h,$n,$s,$m ? $m : 1,$j ? $j : 1,$a); } $q = sql_select($query['SELECT'], $query['FROM'], $query['WHERE'], $query['GROUP BY'], $query['ORDER BY']); while ($r = sql_fetch($q)) { if ($r[$nom_date] <= $date) break; $debut++; } $debut -= ($debut%$pas); return $debut; } // tous les boutons de controle d'un forum // nb : les forums prives (privrac ou prive), une fois effaces // (privoff), ne sont pas revalidables ; le forum d'admin (privadm) // n'est pas effacable // http://doc.spip.org/@boutons_controle_forum function boutons_controle_forum($id_forum, $forum_stat, $forum_id_auteur=0, $ref, $forum_ip, $script, $args) { $controle = $original = $spam = ''; // selection du logo et des boutons correspondant a l'etat du forum switch ($forum_stat) { # forum sous un article dans l'espace prive case "prive": $logo = "forum-interne-24.gif"; $valider = false; $valider_repondre = false; $suppression = 'privoff'; break; # forum des administrateurs case "privadmin": $logo = "forum-admin-24.gif"; $valider = false; $valider_repondre = false; $suppression = false; break; # forum de l'espace prive, supprime (non revalidable, # d'ailleurs on ne sait plus a quel type de forum il appartenait) case "privoff": $logo = "forum-interne-24.gif"; $valider = false; $valider_repondre = false; $suppression = false; break; # forum general de l'espace prive case "privrac": $logo = "forum-interne-24.gif"; $valider = false; $valider_repondre = false; $suppression = 'privoff'; break; # forum publie sur le site public case "publie": $logo = "forum-public-24.gif"; $valider = false; $valider_repondre = false; $suppression = 'off'; break; # forum supprime sur le site public case "off": $logo = "forum-public-24.gif"; $valider = 'publie'; $valider_repondre = false; $suppression = false; $controle = "
    "._T('info_message_supprime')." $forum_ip"; if($forum_id_auteur) $controle .= " - " ._T('lien_voir_auteur'). ""; break; # forum propose (a moderer) sur le site public case "prop": $logo = "forum-public-24.gif"; $valider = 'publie'; $valider_repondre = true; $suppression = 'off'; break; # forum signale comme spam sur le site public case "spam": $logo = "forum-public-24.gif"; $valider = 'publie'; $valider_repondre = false; $suppression = false; $spam = true; break; # forum original (reponse a un forum modifie) sur le site public case "original": $logo = "forum-public-24.gif"; $original = true; break; default: return; } $lien = generer_url_ecrire($script, $args, true, true) . "#forum$id_forum"; $boutons =''; if ($suppression) $boutons .= icone_inline(_T('icone_supprimer_message'), generer_action_auteur('instituer_forum',"$id_forum-$suppression", $lien), $logo, "supprimer.gif", 'right', 'non'); if ($valider) $boutons .= icone_inline(_T('icone_valider_message'), generer_action_auteur('instituer_forum',"$id_forum-$valider", $lien), $logo, "creer.gif", 'right', 'non'); if ($valider_repondre) { $dblret = rawurlencode(_DIR_RESTREINT_ABS . $lien); $boutons .= icone_inline(_T('icone_valider_message') . " & " . _T('lien_repondre_message'), generer_action_auteur('instituer_forum',"$id_forum-$valider", _DIR_RACINE . generer_url_public('forum', "$ref&id_forum=$id_forum&retour=$dblret", true, true)), $logo, "creer.gif", 'right', 'non'); } if ($boutons) $controle .= "
    ". $boutons . "
    "; // TODO: un bouton retablir l'original ? if ($original) { $controle .= "
    " ."(" ._T('forum_info_original') .")
    "; } if ($spam) { $controle .= "
    " ."(" ._T('spam') // Marque' comme spam ? .")
    "; } return $controle; } // recuperer le critere SQL qui selectionne nos forums // http://doc.spip.org/@critere_statut_controle_forum function critere_statut_controle_forum($type, $id_rubrique=0, $recherche='') { if (is_array($id_rubrique)) $id_rubrique = join(',',$id_rubrique); if (!$id_rubrique) { $from = 'spip_forum AS F'; $where = ""; $and = ""; } else { if (strpos($id_rubrique,',')) $eq = " IN ($id_rubrique)"; else $eq = "=$id_rubrique"; $from = 'spip_forum AS F, spip_articles AS A'; $where = "A.id_secteur$eq AND F.id_article=A.id_article"; $and = ' AND '; } switch ($type) { case 'public': $and .= "F.statut IN ('publie', 'off', 'prop', 'spam') AND F.texte!=''"; break; case 'prop': $and .= "F.statut='prop'"; break; case 'spam': $and .= "F.statut='spam'"; break; case 'interne': $and .= "F.statut IN ('prive', 'privrac', 'privoff', 'privadm') AND F.texte!=''"; break; case 'vide': $and .= "F.statut IN ('publie', 'off', 'prive', 'privrac', 'privoff', 'privadm') AND F.texte=''"; break; default: $where = '0=1'; $and =''; break; } if ($recherche) { include_spip('inc/rechercher'); if ($a = recherche_en_base($recherche, 'forum')) $and .= " AND ".sql_in('id_forum', array_keys(array_pop($a))); else $and .= " 0=1"; } return array($from, "$where$and"); } // Index d'invalidation des forums // http://doc.spip.org/@calcul_index_forum function calcul_index_forum($id_article, $id_breve, $id_rubrique, $id_syndic) { if ($id_article) return 'a'.$id_article; if ($id_breve) return 'b'.$id_breve; if ($id_rubrique) return 'r'.$id_rubrique; if ($id_syndic) return 's'.$id_syndic; } // // Recalculer tous les threads // // http://doc.spip.org/@calculer_threads function calculer_threads() { // fixer les id_thread des debuts de discussion sql_update('spip_forum', array('id_thread'=>'id_forum'), "id_parent=0"); // reparer les messages qui n'ont pas l'id_secteur de leur parent do { $discussion = "0"; $precedent = 0; $r = sql_select("fille.id_forum AS id, maman.id_thread AS thread", 'spip_forum AS fille, spip_forum AS maman', "fille.id_parent = maman.id_forum AND fille.id_thread <> maman.id_thread",'', "thread"); while ($row = sql_fetch($r)) { if ($row['thread'] == $precedent) $discussion .= "," . $row['id']; else { if ($precedent) sql_updateq("spip_forum", array("id_thread" => $precedent), "id_forum IN ($discussion)"); $precedent = $row['thread']; $discussion = $row['id']; } } sql_updateq("spip_forum", array("id_thread" => $precedent), "id_forum IN ($discussion)"); } while ($discussion != "0"); } // Calculs des URLs des forums (pour l'espace public) // http://doc.spip.org/@racine_forum function racine_forum($id_forum){ if (!$id_forum = intval($id_forum)) return false; $row = sql_fetsel("id_parent, id_rubrique, id_article, id_breve, id_syndic, id_message, id_thread", "spip_forum", "id_forum=".$id_forum); if (!$row) return false; if ($row['id_parent'] AND $row['id_thread'] != $id_forum) // eviter boucle infinie return racine_forum($row['id_thread']); if ($row['id_message']) return array('message', $row['id_message'], $id_forum); if ($row['id_rubrique']) return array('rubrique', $row['id_rubrique'], $id_forum); if ($row['id_article']) return array('article', $row['id_article'], $id_forum); if ($row['id_breve']) return array('breve', $row['id_breve'], $id_forum); if ($row['id_syndic']) return array('site', $row['id_syndic'], $id_forum); // On ne devrait jamais arriver ici, mais prevoir des cas de forums // poses sur autre chose que les objets prevus... spip_log("erreur racine_forum $id_forum"); return array(); } // http://doc.spip.org/@parent_forum function parent_forum($id_forum) { if (!$id_forum = intval($id_forum)) return; $row = sql_fetsel("id_parent, id_rubrique, id_article, id_breve, id_syndic", "spip_forum", "id_forum=".$id_forum); if(!$row) return array(); if($row['id_parent']) return array('forum', $row['id_parent']); if($row['id_article']) return array('article', $row['id_article']); if($row['id_breve']) return array('breve', $row['id_breve']); if($row['id_rubrique']) return array('rubrique', $row['id_rubrique']); if($row['id_syndic']) return array('site', $row['id_syndic']); } // http://doc.spip.org/@generer_url_forum_dist function generer_url_forum_dist($id_forum, $args='', $ancre='') { if ($id_forum = intval($id_forum)) { list($type, $id,) = racine_forum($id_forum); if ($type) { if (!$ancre) $ancre = "forum$id_forum"; return generer_url_entite($id, $type, $args, $ancre); } } return ''; } // http://doc.spip.org/@generer_url_forum_parent function generer_url_forum_parent($id_forum) { if ($id_forum = intval($id_forum)) { list($type, $id) = parent_forum($id_forum); if ($type) return generer_url_entite($id, $type); } return ''; } // Quand on edite un forum, on tient a conserver l'original // sous forme d'un forum en reponse, de statut 'original' // http://doc.spip.org/@conserver_original function conserver_original($id_forum) { $s = sql_fetsel("id_forum", "spip_forum", "id_parent=".sql_quote($id_forum)." AND statut='original'"); if ($s) return ''; // pas d'erreur // recopier le forum $t = sql_fetsel("*", "spip_forum", "id_forum=".sql_quote($id_forum)); if ($t) { unset($t['id_forum']); $id_copie = sql_insertq('spip_forum', $t); if ($id_copie) { sql_updateq('spip_forum', array('id_parent'=> $id_forum, 'statut'=>'original'), "id_forum=$id_copie"); return ''; // pas d'erreur } } return '&erreur'; } // appelle conserver_original(), puis modifie le contenu via l'API inc/modifier // http://doc.spip.org/@enregistre_et_modifie_forum function enregistre_et_modifie_forum($id_forum, $c=false) { if ($err = conserver_original($id_forum)) { spip_log("erreur de sauvegarde de l'original, $err"); return; } include_spip('inc/modifier'); return revision_forum($id_forum, $c); } // // Afficher les forums // // http://doc.spip.org/@afficher_forum function afficher_forum($query, $retour, $arg, $controle_id_article = false, $script='', $argscript='') { global $spip_display; static $compteur_forum = 0; static $nb_forum = array(); static $thread = array(); $request = sql_allfetsel($query['SELECT'], $query['FROM'], $query['WHERE'], $query['GROUP BY'], $query['ORDER BY'], $query['LIMIT']); $compteur_forum++; $nb_forum[$compteur_forum] = count($request); $thread[$compteur_forum] = 1; $res = ''; foreach($request as $row) { $statut=$row['statut']; $id_parent=$row['id_parent']; if (($controle_id_article) ? ($statut!="perso") : (($statut=="prive" OR $statut=="privrac" OR $statut=="privadm" OR $statut=="perso") OR ($statut=="publie" AND $id_parent > 0))) { $query = array('SELECT' => "*", 'FROM' => "spip_forum", 'WHERE' => "id_parent='" . $row['id_forum'] . "'" . ($controle_id_article ? '':" AND statut<>'off'"), 'ORDER BY' => "date_heure"); $bloc = afficher_forum_thread($row, $controle_id_article, $compteur_forum, $nb_forum, $thread, $retour, $arg, $script, $argscript) . afficher_forum($query, $retour, $arg, $controle_id_article, $script, $argscript); $res .= ajax_action_greffe('poster_forum_prive', $row['id_forum'], $bloc); } $thread[$compteur_forum]++; } $compteur_forum--; if ($spip_display == 4 AND $res) $res = "
      $res
    "; return $res; } // Construit une Div comportant un unique message, // plus les lignes verticales de conduite // http://doc.spip.org/@afficher_forum_thread function afficher_forum_thread($row, $controle_id_article, $compteur_forum, $nb_forum, $i, $retour, $arg, $script, $argscript) { global $spip_lang_right, $spip_display; static $voir_logo = array(); // pour ne calculer qu'une fois if (is_array($voir_logo)) { $voir_logo = (($spip_display != 1 AND $spip_display != 4 AND $GLOBALS['meta']['image_process'] != "non") ? "position: absolute; $spip_lang_right: 0px; margin: 0px; margin-top: -3px; margin-$spip_lang_right: 0px;" : ''); } $id_forum=$row['id_forum']; $id_parent=$row['id_parent']; $id_rubrique=$row['id_rubrique']; $id_article=$row['id_article']; $id_breve=$row['id_breve']; $id_message=$row['id_message']; $id_syndic=$row['id_syndic']; $id_auteur=$row["id_auteur"]; $titre=$row['titre']; $texte=$row['texte']; $nom_site=$row['nom_site']; $url_site=$row['url_site']; $statut=$row['statut']; $ip=$row["ip"]; $h = (!$id_article ? '' : generer_url_entite($id_article, 'article')) . "#forum$id_forum"; $titre_boite = "" . typo($titre) . ''; if ($spip_display == 4) { $res = $titre_boite ."
    "; } else { if ($id_auteur AND $voir_logo) { $chercher_logo = charger_fonction('chercher_logo', 'inc'); if ($logo = $chercher_logo($id_auteur, 'id_auteur', 'on')) { list($fid, $dir, $nom, $format) = $logo; include_spip('inc/filtres_images_mini'); $logo = image_reduire("", 48, 48); if ($logo) $titre_boite = "\n
    $logo
    $titre_boite" ; } } $res = "" . afficher_forum_4($compteur_forum, $nb_forum, $i) . "\n" . (($compteur_forum == 1) ? debut_cadre_forum(forum_logo($statut), true, "", $titre_boite) : debut_cadre_thread_forum("", true, "", $titre_boite)); } // Si refuse, cadre rouge if ($statut=="off") { $style =" style='border: 2px dashed red; padding: 5px;'"; } // Si propose, cadre jaune else if ($statut=="prop") { $style = " style='border: 1px solid yellow; padding: 5px;'"; } // Si original, cadre vert else if ($statut=="original") { $style = " style='border: 1px solid green; padding: 5px;'"; } else $style = ''; $mots = afficher_forum_mots($id_forum); $res .= "\n" . afficher_forum_auteur($row) . (!$controle_id_article ? '' : boutons_controle_forum($id_forum, $statut, $id_auteur, "id_article=$id_article", $ip, $script, $argscript)) . "
    " . safehtml(justifier(propre($texte))) . "
    \n" . (!$nom_site ? '' : ((strlen($url_site) > 10) ? "\n" : "$nom_site")) . ($controle_id_article ? '' : repondre_forum($row, $titre, $statut, "$retour?$arg", _T('lien_repondre_message'))) . $mots . ""; if ($spip_display == 4) return "\n
  • $res
  • \n"; if ($compteur_forum == 1) $res .= fin_cadre_forum(true); else $res .= fin_cadre_thread_forum(true); $res .= ""; return "$res
    \n"; } // http://doc.spip.org/@repondre_forum function repondre_forum($row, $titre, $statut, $retour, $clic) { $id_forum = $row['id_forum']; $id_thread = $row['id_thread']; $ancre = "poster_forum_prive-$id_thread"; $lien = generer_url_ecrire("poster_forum_prive", "statut=$statut&id_parent=$id_forum&titre_message=" . rawurlencode($titre) . "&script=" . urlencode($retour)) . '#formulaire'; return "\n"; } // http://doc.spip.org/@afficher_forum_auteur function afficher_forum_auteur($row) { $titre=$row['titre']; $id_auteur=$row["id_auteur"]; $date_heure=$row['date_heure']; $email_auteur=$row['email_auteur']; $auteur= extraire_multi($row['auteur']); if ($id_auteur) { $formater_auteur = charger_fonction('formater_auteur', 'inc'); $res = join(' ',$formater_auteur($id_auteur)); } else { if ($email_auteur) { if (email_valide($email_auteur)) $email_auteur = "".$email_auteur .""; $auteur .= " — $email_auteur"; } $res = safehtml(" / $auteur"); } return "
    " . date_interface($date_heure) . "  $res
    "; } // http://doc.spip.org/@afficher_forum_mots function afficher_forum_mots($id_forum) { if ($GLOBALS['meta']["mots_cles_forums"] <> "oui") return ''; $mots = sql_allfetsel("titre, type", "spip_mots AS M LEFT JOIN spip_mots_forum AS L ON L.id_mot=M.id_mot", "L.id_forum=" . intval($id_forum)); foreach ($mots as $k => $r) { $mots[$k] = propre('' . $r['type'] . ' :') . ' ' . propre($r['titre']); } if (!$mots) return ''; return ("\n
    • " . join("
    • \n
    • ", $mots) . "
    \n"); } // affiche les traits de liaisons entre les reponses // http://doc.spip.org/@afficher_forum_4 function afficher_forum_4($compteur_forum, $nb_forum, $thread) { global $spip_lang_rtl; $fleche2="forum-droite$spip_lang_rtl.gif"; $fleche='rien.gif'; $vertical = chemin_image('forum-vert.gif'); $rien = chemin_image('rien.gif'); $res = ''; for ($j=2;$j<=$compteur_forum AND $j<20;$j++){ $res .= "" . http_img_pack(($j==$compteur_forum) ? $fleche2 : $fleche, "", "width='10' height='13'") . "\n"; } return $res; } ?> spip/spip/ecrire/inc/selectionner_auteur.php0000766000000000000000000000526611236524730022522 0ustar adminadministrators doivent etre au premier niveau // et se suivrent pour que changerhighligth fonctionne // De plus, leur zone doit avoir une balise et une seule // autour de la valeur pertinente pour que aff_selection // fonctionne (faudrait concentrer tout ca). $res .= "" . $nom . ""; } return $res; } ?> spip/spip/ecrire/inc/filtres_mini.php0000766000000000000000000000770511236524730021127 0ustar adminadministrators nouvelle adresse // // suivre_lien('http://rezo.net/sous/dir/../ect/ory/fi.html..s#toto', // 'a/../../titi.coco.html/tata#titi'); // http://doc.spip.org/@suivre_lien function suivre_lien($url, $lien) { if (preg_match(',^(mailto|javascript):,iS', $lien)) return $lien; if (preg_match(',^([a-z0-9]+://.*?)(/.*)?$,iS', $lien, $r)) return $r[1].resolve_path($r[2]); # L'url site spip est un lien absolu aussi if ($lien == $GLOBALS['meta']['adresse_site']){ return $lien; } # lien relatif, il faut verifier l'url de base # commencer par virer la chaine de get de l'url de base if (preg_match(',^(.*?://[^/]+)(/.*?/?)?([^/#?]*)([?][^#]*)?(#.*)?$,S', $url, $regs)) { $debut = $regs[1]; $dir = !strlen($regs[2]) ? '/' : $regs[2]; $mot = $regs[3]; $get = isset($regs[4])?$regs[4]:""; $hash = isset($regs[5])?$regs[5]:""; } #var_dump(array('url'=>$url,'debut'=>$debut,'dir'=>$dir,'mot'=>$mot,'get'=>$get,'hash'=>$hash)); switch (substr($lien,0,1)) { case '/': return $debut . resolve_path($lien); case '#': return $debut . resolve_path($dir.$mot.$get.$lien); case '': return $debut . resolve_path($dir.$mot.$get.$hash); default: return $debut . resolve_path($dir.$lien); } } // un filtre pour transformer les URLs relatives en URLs absolues ; // ne s'applique qu'aux #URL_XXXX // http://doc.spip.org/@url_absolue function url_absolue($url, $base='') { if (strlen($url = trim($url)) == 0) return ''; if (!$base) $base = url_de_base() . (_DIR_RACINE ? _DIR_RESTREINT_ABS : ''); return suivre_lien($base, $url); } // un filtre pour transformer les URLs relatives en URLs absolues ; // ne s'applique qu'aux textes contenant des liens // http://doc.spip.org/@liens_absolus function liens_absolus($texte, $base='') { if (preg_match_all(',(<(a|link)[[:space:]]+[^<>]*href=["\']?)([^"\' ><[:space:]]+)([^<>]*>),imsS', $texte, $liens, PREG_SET_ORDER)) { foreach ($liens as $lien) { $abs = url_absolue($lien[3], $base); if ($abs <> $lien[3] and !preg_match('/^#/',$lien[3])) $texte = str_replace($lien[0], $lien[1].$abs.$lien[4], $texte); } } if (preg_match_all(',(<(img|script)[[:space:]]+[^<>]*src=["\']?)([^"\' ><[:space:]]+)([^<>]*>),imsS', $texte, $liens, PREG_SET_ORDER)) { foreach ($liens as $lien) { $abs = url_absolue($lien[3], $base); if ($abs <> $lien[3]) $texte = str_replace($lien[0], $lien[1].$abs.$lien[4], $texte); } } return $texte; } // // Ce filtre public va traiter les URL ou les // // http://doc.spip.org/@abs_url function abs_url($texte, $base='') { if ($GLOBALS['mode_abs_url'] == 'url') return url_absolue($texte, $base); else return liens_absolus($texte, $base); } ?> spip/spip/ecrire/inc/couleurs.php0000766000000000000000000001002111236524730020265 0ustar adminadministrators array ( "couleur_foncee" => "#9DBA00", "couleur_claire" => "#C5E41C", "couleur_lien" => "#657701", "couleur_lien_off" => "#A6C113" ), // Violet clair 2 => array ( "couleur_foncee" => "#eb68b3", "couleur_claire" => "#ffa9e6", "couleur_lien" => "#8F004D", "couleur_lien_off" => "#BE6B97" ), // Orange 3 => array ( "couleur_foncee" => "#fa9a00", "couleur_claire" => "#ffc000", "couleur_lien" => "#FF5B00", "couleur_lien_off" => "#B49280" ), // Saumon 4 => array ( "couleur_foncee" => "#CDA261", "couleur_claire" => "#FFDDAA", "couleur_lien" => "#AA6A09", "couleur_lien_off" => "#B79562" ), // Bleu pastel 5 => array ( "couleur_foncee" => "#5da7c5", "couleur_claire" => "#97d2e1", "couleur_lien" => "#116587", "couleur_lien_off" => "#81B7CD" ), // Gris 6 => array ( "couleur_foncee" => "#85909A", "couleur_claire" => "#C0CAD4", "couleur_lien" => "#3B5063", "couleur_lien_off" => "#6D8499" ), ); if (is_numeric($choix)) { // Compatibilite ascendante (plug-ins notamment) $GLOBALS["couleur_claire"] = $couleurs_spip[$choix]['couleur_claire']; $GLOBALS["couleur_foncee"] = $couleurs_spip[$choix]['couleur_foncee']; $GLOBALS["couleur_lien"] = $couleurs_spip[$choix]['couleur_lien']; $GLOBALS["couleur_lien_off"] = $couleurs_spip[$choix]['couleur_lien_off']; return "couleur_claire=" . substr($couleurs_spip[$choix]['couleur_claire'],1). '&couleur_foncee=' . substr($couleurs_spip[$choix]['couleur_foncee'],1); } else { if (is_array($choix)) { if ($ajouter) { return $couleurs_spip = array_merge($couleurs_spip, $choix); } else { return $couleurs_spip = $choix; } } $evt = ' onmouseover="changestyle(\'bandeauinterface\');" onfocus="changestyle(\'bandeauinterface\');" onblur="changestyle(\'bandeauinterface\');"'; $bloc = ''; $ret = self('&'); foreach ($couleurs_spip as $key => $val) { $bloc .= '' . http_img_pack("rien.gif", _T('choix_couleur_interface') . $key, "width='8' height='8' style='margin: 1px; background-color: " . $val['couleur_claire'] . ";'") . ""; } // Ce js permet de changer de couleur sans recharger la page return '' . $bloc . "\n" . '\n"; } } ?> spip/spip/ecrire/inc/legender.php0000766000000000000000000003107511236524730020225 0ustar adminadministrators".vignette_formulaire_legender($id_document, $document, $script, $type, $id, $ancre).""; } $s = ($ancre =='documents' ? '': '-'); $corps = legender_corps($ancre, $flag, $id, $id_document, $script, $type, $document, $label, $taille) . $vignette . "\n\n" . legender_suppression($id, $id_document, $ancre, $s, $script, $supp, $type); // ne pas afficher le bouton de changement dans le portfolio ? // mais tout cela n'est pas trs extensible et declenchera d'autres bugs plus tard... if (preg_match(",_edit,",$script)) $corps .= legender_image_doc($document, $id_document, $id, $type, $s, $script, $ancre); $corps = block_parfois_visible("legender-aff-$id_document", legender_entete($document), $corps, "text-align:center;", $flag); return ajax_action_greffe("legender", $id_document, $corps); } function legender_entete($document) { $titre = $document['titre']; $entete = basename($document['fichier']); if (($n=strlen($entete)) > 20) $entete = substr($entete, 0, 7)."...".substr($entete, $n-7, $n); if (strlen($titre)) $entete = "". lignes_longues(typo($titre),25) . ""; return sinon($entete,_T('info_sans_titre')); } function legender_suppression($id, $id_document, $ancre, $s, $script, $supp, $type) { // le cas $id<0 correspond a un doc charge dans un article pas encore cree, // et ca buggue si on propose de supprimer => on ne propose pas // Le cas id = 0 correspond au cas d'une mediatheque : l'action est alors // sans doute a revoir car le document serait alors peut-etre orphelin if ($id <= 0) return ''; // la fonction 'supprimer_document' ne fait que de-associer si un document est utilise par ailleurs $texte = _T('icone_supprimer_document'); if (preg_match('/_edit$/', $script)) { $action = ajax_action_auteur('documenter', "$s$id/$type/$id_document", $script, "id_$type=$id&type=$type&s=$s#$ancre", array($texte), '', 'function() {jQuery(this).remove()}'); } else { if (test_espace_prive()) $action = ajax_action_auteur('documenter', "$s$id/$type/$id_document", $script, "id_$type=$id&type=$type&s=$s#$ancre", array($texte)); else{ $redirect = str_replace('&','&',$script); $action = generer_action_auteur('documenter', "$s$id/$type/$id_document", $redirect); $action = "$texte"; } } return icone_horizontale($texte, $action, $supp, "supprimer.gif", false); } function legender_corps($ancre, $flag, $id, $id_document, $script, $type, $document, $label, $taille) { include_spip('inc/editer'); $contenu = ''; $descriptif = $document['descriptif']; if ($descriptif) $contenu .= "

    ".PtoBR(lignes_longues(propre($descriptif),25)) . "

    \n"; if ($document['largeur'] OR $document['hauteur']) $contenu .= _T('info_largeur_vignette', array('largeur_vignette' => $document['largeur'], 'hauteur_vignette' => $document['hauteur'])) . ' — '; $contenu .= taille_en_octets($document['taille']); $date = $document['date']; if ($date AND ($GLOBALS['meta']["documents_date"] == 'oui')) $contenu .= "
    \n" . affdate($date); $corps = (!$contenu ? '' : "
    $contenu
    ") . "
    • \n" . "
    • \n" . (($GLOBALS['meta']["documents_date"] == 'oui') ? "
    • ".date_formulaire_legender($date, $id_document)."
    • " :'' ) . "
    • \n" . "
    \n" . $taille .controles_md5($document); $att_bouton = " class='fondo spip_xx-small'"; $att_span = " id='valider_doc$id_document' " . ($flag == 'ajax' ? '' : "class='display_au_chargement'") . " style='text-align:" . $GLOBALS['spip_lang_right'] . ($flag == 'ajax' ? ';display:block' : "") . "'"; if (test_espace_prive()) return ajax_action_post("legender", $id_document, $script, "show_docs=$id_document&id_$type=$id#legender-$id_document", $corps, _T('bouton_enregistrer'), $att_bouton, $att_span, "&id_document=$id_document&id=$id&type=$type&ancre=$ancre") . "
    "; else { $corps = "
    " . $corps . "
    "; $redirect = parametre_url($script,'show_docs',$id_document,'&'); $redirect = parametre_url($redirect,"id_$type",$id,'&'); $redirect = parametre_url($redirect,"id_$type",$id,'&'); $redirect = ancre_url($redirect,"legender-$id_document"); return generer_action_auteur("legender", $id_document, $redirect, $corps, "\nmethod='post'"); } } // // Changement de mode image/document // function legender_image_doc($document, $id_document, $id, $type, $s, $script, $ancre) { define('_INTERFACE_DOCUMENTS', true); define('_BOUTON_MODE_IMAGE', true); if (!_INTERFACE_DOCUMENTS) return ''; if (!_BOUTON_MODE_IMAGE OR !in_array($document['extension'], array('jpg', 'gif', 'png'))) return ''; if ($document['mode'] == 'image') { $texte = _T('upload_info_mode_document'); $mode = 'document'; $logo = 'doc-24.gif'; } else { $texte = _T('upload_info_mode_image'); $mode = 'image'; $logo = 'image-24.gif'; } $action = redirige_action_auteur('changer_mode_document', "$id_document/$mode", $script, (($id>0) ? "id_$type=$id" : "new=oui" ) . "&type=$type&s=$s#$ancre"); return icone_horizontale($texte, $action, $logo, '', false," onclick=\"jQuery('#document$id_document').parent().animeajax().load(this.href+'&afficher_case=$id-$type-$script&var_noajax=1');return false;\""); } // http://doc.spip.org/@vignette_formulaire_legender function vignette_formulaire_legender($id_document, $document, $script, $type, $id, $ancre) { $id_vignette = $document['id_vignette']; $texte = _T('info_supprimer_vignette'); $s = ($ancre =='documents' ? '': '-'); if (preg_match('/_edit$/', $script)) { $iframe_redirect = generer_url_ecrire("documents_colonne","id=$id&type=$type",true); $action = redirige_action_auteur('documenter', "$s$id/$type/$id_vignette", $script, "id_$type=$id&show_docs=$id_document#$ancre"); } else { $iframe_redirect = generer_url_ecrire("documenter","id_$type=$id&type=$type",true); $f = (!$s AND $id_vignette) ? "/$id_document" : ''; $action = ajax_action_auteur('documenter', "$s$id/$type/$id_vignette$f", $script, "id_$type=$id&type=$type&s=$s&show_docs=$id_document#$ancre", array($texte),'',"function(r,noeud) {noeud.innerHTML = r; \$('form.form_upload',noeud).async_upload(async_upload_portfolio_documents);}"); } $joindre = charger_fonction('joindre', 'inc'); $supprimer = icone_horizontale($texte, $action, "vignette-24.png", "supprimer.gif", false); if ($id<0) $supprimer = ''; // cf. ci-dessus, article pas encore cree return "
    " . (!$id_vignette ? $joindre(array( 'script' => $script, 'args' => "id_$type=$id", 'id' => $id, 'intitule' => _T('info_vignette_personnalisee'), 'mode' => 'vignette', 'type' => $type, 'ancre' => $ancre, 'id_document' => $id_document, 'titre' => '', 'iframe_script' => $iframe_redirect )) : $supprimer ); } // Bloc d'edition de la taille du doc (pour embed) // http://doc.spip.org/@formulaire_taille function formulaire_taille($document) { // (on ne le propose pas pour les images qu'on sait // lire : gif jpg png), sauf bug, ou document distant if (in_array($document['extension'], array('gif','jpg','png')) AND $document['hauteur'] AND $document['largeur'] AND $document['distant']!='oui') return ''; $id_document = $document['id_document']; // Donnees sur le type de document $extension = $document['extension']; $t = sql_fetsel('inclus','spip_types_documents', "extension=".sql_quote($extension)); $type_inclus = $t['inclus']; # TODO -- pour le MP3 "l x h pixels" ne va pas if (($type_inclus == "embed" OR $type_inclus == "image") AND ( // documents dont la taille est definie ($document['largeur'] * $document['hauteur']) // ou distants OR $document['distant'] == 'oui' // ou tous les formats qui s'affichent en embed OR $type_inclus == "embed" )) { return "\n

    \n" . "" . " × "._T('info_pixels'); } } // http://doc.spip.org/@date_formulaire_legender function date_formulaire_legender($date, $id_document) { if (preg_match(",([0-9]{4})-([0-9]{2})-([0-9]{2}) ([0-9]{2}):([0-9]{2}),", $date, $regs)){ $mois = $regs[2]; $jour = $regs[3]; $annee = $regs[1]; $heure = $regs[4]; $minute = $regs[5]; } return "
    "._T('info_mise_en_ligne')."
    \n" . afficher_jour($jour, "name='jour_doc' id='jour_doc$id_document' size='1' class='fondl spip_xx-small'\n\tonchange=\"changeVisible(true, 'valider_doc$id_document', 'block', 'block');\"") . afficher_mois($mois, "name='mois_doc' id='mois_doc$id_document' size='1' class='fondl spip_xx-small'\n\tonchange=\"changeVisible(true, 'valider_doc$id_document', 'block', 'block');\"") . afficher_annee($annee, "name='annee_doc' id='annee_doc$id_document' size='1' class='fondl spip_xx-small'\n\tonchange=\"changeVisible(true, 'valider_doc$id_document', 'block', 'block')\"") . "
    ". afficher_heure($heure, "name='heure_doc' size='1' class='fondl spip_xx-small'\n\tonchange=\"changeVisible(true, 'valider_doc$id_document', 'block', 'block')\"") . " : ". afficher_minute($minute, "name='minute_doc' size='1' class='fondl spip_xx-small'\n\tonchange=\"changeVisible(true, 'valider_doc$id_document', 'block', 'block')\"") . "

    \n"; } ?> spip/spip/ecrire/inc/documenter.php0000766000000000000000000001336011236524730020602 0ustar adminadministrators Nouveau : au lieu de les ignorer, on affiche desormais avec un fond gris // les documents et images inclus dans le texte. // http://doc.spip.org/@inc_documenter_dist function inc_documenter_dist( $doc, # tableau des documents ou numero de l'objet attachant $type = "article", # article ou rubrique ? $ancre = 'portfolio', # album d'images ou de documents ? $ignore_flag = false, # IGNORE, remplace par autoriser(modifier,document) $couleur='', # IGNORE couleur des cases du tableau $appelant ='' # pour le rappel (cf plugin) ) { if (is_int($doc)) { $prim = 'id_' . $type; $img = ($ancre == 'portfolio') ? '' : " NOT"; $select = "D.id_document, D.id_vignette, D.extension, D.titre, D.date, D.descriptif, D.fichier, D.taille, D.largeur, D.hauteur, D.mode, D.distant, L.vu, L.id_objet, L.id_objet as $prim"; $from = "spip_documents AS D LEFT JOIN spip_documents_liens AS L ON L.id_document=D.id_document"; $where = "L.id_objet=$doc AND L.objet='$type' AND D.mode='document' AND D.extension $img IN ('gif', 'jpg', 'png')"; $order = "0+D.titre, D.date"; $docs = sql_allfetsel($select, $from, $where, '', $order); $opt = array('objet'=>$type, 'id_objet' => $doc); } else { $docs = $doc; $opt = array(); } if (!$docs) return ''; // On passe &$tous dans la boucle pour verifier si on a bien // le droit de supprimer tous les documents $tous = (count($docs) > 3); $s = ($ancre =='documents' ? '': '-'); if (preg_match('/_edit$/', _request('script'))) { $res = " "; } else { $res = documenter_boucle($docs, $type, $ancre, $tous, $appelant, $opt); if (is_int($doc)) $res = documenter_bloc($doc, $res, $s, $appelant, $ancre, $tous, $type); } return ajax_action_greffe("documenter", "$s$doc", $res); } // http://doc.spip.org/@documenter_bloc function documenter_bloc($id, $res, $s, $script, $ancre, $tous, $type) { // seulement s'il y a au moins un document dedans if (!$res) return ""; if ($tous) { $tous = "
    " . ajax_action_auteur('documenter', "$s$id/$type", $appelant ? $appelant : _request('exec'), "id_$type=$id&s=$s&type=$type",array(_T('lien_tout_supprimer'))) . "
    \n"; } else $tous = ''; $bouton = bouton_block_depliable(majuscules(_T("info_$ancre")),true,"portfolio_$ancre"); return debut_cadre("$ancre","","",$bouton) . debut_block_depliable(true,"portfolio_$ancre") . $tous . $res . fin_block() . fin_cadre(); } // http://doc.spip.org/@documenter_boucle function documenter_boucle($documents, $type, $ancre, &$tous_autorises, $appelant, $opt=array()) { // la derniere case d'une rangee $bord_droit = ($ancre == 'portfolio' ? 2 : 1); $case = 0; $res = ''; $tourner = charger_fonction('tourner', 'inc'); $legender = charger_fonction('legender', 'inc'); // Pour les doublons d'article et en mode ajax, il faut faire propre() /*if ($type=='article' AND !isset($GLOBALS['doublons_documents_inclus']) AND is_int($doc)) { $r = sql_fetsel("chapo,texte", "spip_articles", "id_article=".sql_quote($doc)); propre(join(" ",$r)); }*/ $show_docs = explode(',', _request('show_docs')); foreach ($documents as $document) { $id_document = $document['id_document']; // $opt : options pour l'autorisation (type d'objet parent, et id de l'objet parent) if (!autoriser('voir', 'document', $id_document, null, $opt)) continue; if (isset($document['script'])) $script = $document['script']; # pour plugin Cedric else // ref a $exec inutilise en standard $script = $appelant ? $appelant : $GLOBALS['exec']; if (!$case) $res .= ""; $flag = autoriser('modifier', 'document', $id_document); $tous_autorises &= $flag; $vu = ($document['vu']=='oui') ? ' vu':''; $vue_document = $tourner($id_document, $document, $script, $flag, $type); $editer_document = (!$flag ? '' : $legender($id_document, $document, $script, $type, $document["id_$type"], $ancre, in_array($id_document, $show_docs))) . (!isset($document['info']) ? '' : ("
    ".$document['info']."
    ")); // Prevoir le passage de la vue et de l'edition sous forme de squelettes separes // Ces pipelines seront alors inutiles, car integres dans l'appel des squelettes $vue_document = pipeline('afficher_contenu_objet', array( 'args' => array( 'type'=> 'case_document', 'id'=>$id_document ), 'data'=> $vue_document ) ); $editer_document = pipeline('editer_contenu_objet', array( 'args' => array( 'type'=> 'case_document', 'id'=>$id_document ), 'data'=> $editer_document ) ); $res .= "\n" . $vue_document . $editer_document . "\n"; $case++; if ($case > $bord_droit) { $case = 0; $res .= "\n"; } } // fermer la derniere ligne if ($case) { $res .= ""; $res .= ""; } // pas de contenu, pas de tableau if (!$res) return ""; return "\n" . $res . "
    "; } ?> spip/spip/ecrire/inc/import_insere.php0000766000000000000000000004143411236524730021317 0ustar adminadministrators "VARCHAR(16) NOT NULL", "ajout" => "integer NOT NULL", // en fait booleen "titre" => "text NOT NULL", "id_old" => "bigint (21) DEFAULT '0' NOT NULL", "id_new" => "bigint (21) DEFAULT '0' NOT NULL"); $key = array( "PRIMARY KEY" => "id_old, id_new, type", "KEY id_old" => "id_old"); $v = sql_create('spip_translate', $field, $key, true); if (!$v) { spip_log("echec de la creation de la table de fusion"); return false; } // au cas ou la derniere fois ce serait terminee anormalement sql_delete("spip_translate"); // pour PG $GLOBALS['tables_principales']['spip_translate'] = array('field' => $field, 'key' => $key); return insere_1bis_init($request); } // http://doc.spip.org/@insere_1bis_init function insere_1bis_init($request) { // l'insertion porte sur les tables principales ... $t = array_keys($GLOBALS['tables_principales']); // ... mais pas cette table a cause de la duplication des login unset($t[array_search('spip_auteurs', $t)]); // ni celle-ci, les qui est liee implicitement a la precedente unset($t[array_search('spip_messages', $t)]); // et pour celles-ci restent a programmer les regles unset($t[array_search('spip_forum', $t)]); unset($t[array_search('spip_syndic', $t)]); unset($t[array_search('spip_signatures', $t)]); return $t; } // En passe 2, relire les tables principales et les tables auxiliaires // sur les mots et les documents car on sait les identifier // http://doc.spip.org/@insere_2_init function insere_2_init($request) { $t = insere_1bis_init($request); // ne pas importer cette table, son homologue est prioritaire unset($t[array_search('spip_types_documents', $t)]); $t[]= 'spip_mots_articles'; $t[]= 'spip_mots_breves'; $t[]= 'spip_mots_rubriques'; $t[]= 'spip_mots_syndic'; $t[]= 'spip_mots_forum'; $t[]= 'spip_mots_documents'; $t[]= 'spip_documents_liens'; return $t; } // construire le tableau PHP de la table spip_translate // (mis en table pour pouvoir reprendre apres interruption) // http://doc.spip.org/@translate_init function translate_init($request) { include_spip('inc/texte'); // pour les Regexp des raccourcis include_spip('inc/chercher_logo'); // pour les noms des logos include_spip('inc/distant'); // pour recuperer les logos $q = sql_select('*', "spip_translate"); $trans = array(); while ($r = sql_fetch($q)) { $trans[$r['type']][$r['id_old']] = array($r['id_new'], $r['titre'], $r['ajout']); } return $trans; } // http://doc.spip.org/@import_insere function import_insere($values, $table, $desc, $request, $atts) { static $jesais = array(); $type_id = $desc['key']["PRIMARY KEY"]; // reserver une place dans les tables principales si nouveau $ajout = 0; if ((!function_exists($f = 'import_identifie_' . $type_id)) OR (!($n = $f($values, $table, $desc, $request)))) { // pas d'importation de types_doc (a revoir) if ($table == 'spip_types_documents') return; $n = sql_insertq($table); $ajout=1; } if (is_array($n)) list($id, $titre) = $n; else {$id = $n; $titre = "";} sql_insertq('spip_translate', array( 'id_old' => $values[$type_id], 'id_new' => $id, 'titre' => $titre, 'type' => $type_id, 'ajout' => $ajout)); } // Renumerotation des entites collectees // Appelle la fonction specifique a la table, ou a defaut la std. // Le tableau de correspondance est global, et permet qu'un numero // d'une entite soit calcule une seule fois, a sa premiere occurrence. // (Mais des requetes avec jointures eviteraient sa construction. A voir) // http://doc.spip.org/@import_translate function import_translate($values, $table, $desc, $request, $atts) { if (!function_exists($f = 'import_translate_' . $table)) $f = 'import_translate_std'; $f($values, $table, $desc, $request, $atts); } // La fonction d'insertion apres renumerotation. // Afin qu'inserer une 2e fois la meme sauvegarde ne change pas la base, // chaque entree de la sauvegarde est ignoree s'il existe une entree // de meme titre avec le meme contexte (parent etc) dans la base installee. // Une synchronisation plus fine serait preferable, cf [8004] // http://doc.spip.org/@import_inserer_translate function import_inserer_translate($values, $table, $desc, $request, $atts) { global $trans; $p = $desc['key']["PRIMARY KEY"]; $v = $values[$p]; if (!isset($trans[$p]) OR !isset($trans[$p][$v]) OR $trans[$p][$v][2]){ sql_replace($table, $values); $on = isset($atts['on']) ? ($atts['on']) : ''; $off = isset($atts['off']) ? ($atts['off']) : ''; if ($on OR $off) { $t = type_du_logo($p); $url = $request['url_site']; if (!$url) $url = $atts['adresse_site']; if (substr($url,-1) !='/') $url .='/'; $url .= $atts['dir_logos']; $new = $trans[$p][$v][0]; if ($on) { if ($logo = recuperer_page($url . $t . "on$v." . $on)) ecrire_fichier(_DIR_LOGOS. $t . "on$new." . $on, $logo); } if ($off) { if ($logo = recuperer_page($url . $t . "off$v." . $off)) ecrire_fichier(_DIR_LOGOS. $t . "off$new." . $off, $logo); } } } } // Insertion avec renumerotation, y compris des raccourcis. // http://doc.spip.org/@import_translate_std function import_translate_std($values, $table, $desc, $request, $atts) { foreach ($values as $k => $v) { if ($k=='id_parent' OR $k=='id_secteur') $type = 'id_rubrique'; else $type = $k; $values[$k]= importe_raccourci(importe_translate_maj($type, $v)); } import_inserer_translate($values, $table, $desc, $request, $atts); } // http://doc.spip.org/@import_translate_spip_articles function import_translate_spip_articles($values, $table, $desc, $request, $atts) { $v = $values['chapo']; if ($v[0]=='=' AND preg_match(_RACCOURCI_CHAPO, substr($v,1))) $values['chapo'] = '=[->' . substr($v,1) . ']'; if ($request['statut'] == 'on' AND $values['statut'] == 'publie') $values['statut'] = 'prop'; import_translate_std($values, $table, $desc, $request, $atts); } // http://doc.spip.org/@import_translate_spip_breves function import_translate_spip_breves($values, $table, $desc, $request, $atts) { if ($request['statut'] == 'on' AND $values['statut'] == 'publie') $values['statut'] = 'prop'; import_translate_std($values, $table, $desc, $request, $atts); } // Les doc importes deviennent distants, a fortiori s'ils etaient deja // Gerer les vieilles sauvegardes o le Path etait en dur // http://doc.spip.org/@import_translate_spip_documents function import_translate_spip_documents($values, $table, $desc, $request, $atts) { if ($values['distant'] === 'oui') { $url = ''; } else { $values['distant'] = 'oui'; $url = $request['url_site']; if (!$url) $url = $atts['adresse_site']; if (substr($url,-1) !='/') $url .='/'; // deja dans la BD avant cette epoque if ($atts['version_base'] >= '1.934') $url .= $atts['dir_img']; } $url .= $values['fichier']; unset($values['fichier']); foreach ($values as $k => $v) { $values[$k]= importe_raccourci(importe_translate_maj($k, $v)); } $values['fichier'] = $url; import_inserer_translate($values, $table, $desc, $request, $atts); } function import_translate_spip_documents_liens($values, $table, $desc, $request, $atts) { $values['id_document']= (importe_translate_maj('id_document', $values['id_document'])); $values['id_objet']= (importe_translate_maj('id_' .$values['objet'], $values['id_objet'])); sql_replace($table, $values); } // Fonction de renumerotation, par delegation aux fonction specialisees // Si une allocation est finalement necessaire, celles-ci doivent repercuter // la renumerotation sur la table SQL temporaire pour qu'en cas de reprise // sur Time-Out il n'y ait pas reallocation. // En l'absence d'allocation, cet acces SQL peut etre omis, quitte a // recalculer le nouveau numero si une autre occurrence est rencontree // a la reprise. Pas dramatique. // http://doc.spip.org/@importe_translate_maj function importe_translate_maj($k, $v) { global $trans; if (!(isset($trans[$k]) AND isset($trans[$k][$v]))) return $v; list($g, $titre, $ajout) = $trans[$k][$v]; if ($g <= 0) { $f = 'import_identifie_parent_' . $k; if (function_exists($f)) { $g = $f($g, $titre, $v); if ($g > 0) // memoriser qu'on insere $trans[$k][$v][2]=1; else $g = (0-$g); $trans[$k][$v][0] = $g; } else spip_log("$f manquante"); } return $g; } define('_RACCOURCI_MODELE_ALL', '@' . _RACCOURCI_MODELE .'@isS'); // http://doc.spip.org/@importe_raccourci function importe_raccourci($v) { if (preg_match_all(_RACCOURCI_LIEN, $v, $m, PREG_SET_ORDER)) { foreach ($m as $regs) { // supprimer 'http://' ou 'mailto:' $lien = vider_url($regs[count($regs)-1]); if ($match = typer_raccourci($lien)) { list($f,$objet,$id,$params,$ancre) = $match; $k = 'id_' . $f; $g = importe_translate_maj($k, $id); if ($g != $id) { $rac = '[' . $regs[1] . '->' . $regs[2] . $objet . $g . $params . $ancre .']'; $v = str_replace($regs[0], $rac, $v); } } } } if (preg_match_all(_RACCOURCI_MODELE_ALL, $v, $m, PREG_SET_ORDER)) { foreach ($m as $regs) { $g = importe_translate_maj('id_document', $regs[3]); if ($g != $regs[3]) { $rac = '<' . $regs[2] . $g . $regs[4] . '>' . $regs[5]; $v = str_replace($regs[0], $rac, $v); } } } return $v; } // un document importe est considere comme identique a un document local // s'ils ont meme taille et meme nom et que le present n'est pas detruit // Et ne pas importer les incoherences (docs sans extension) // http://doc.spip.org/@import_identifie_id_document function import_identifie_id_document($values, $table, $desc, $request) { if (!$values['extension']) return false; $t = $values['taille']; $f = $values['fichier']; $h = $request['url_site'] . $f; $r = sql_fetsel("id_document AS id, fichier AS titre, distant", "spip_documents", "taille=" . sql_quote($t) . " AND (fichier=" . sql_quote($f) . " OR fichier= " . sql_quote($h) . ')'); if (!$r) return false; if (($r['distant'] != 'oui') AND !file_exists(_DIR_IMG . $r['titre'])) return false; return array($r['id'], $r['titre']); } // un type de document importe est considere comme identique a un type present // s'ils ont meme extension et meme titre // Sinon il ne sera PAS importe // http://doc.spip.org/@import_identifie_id_type function import_identifie_id_type($values, $table, $desc, $request) { $e = $values['extension']; $t = $values['titre']; $r = sql_fetsel("id_type AS id, titre", "spip_types_documents", "extension=" . sql_quote($e) . " AND titre=" . sql_quote($t)); return $r ? array($r['id'], $r['titre']) : false; } // deux groupes de mots ne peuvent avoir le meme titre ==> identification // http://doc.spip.org/@import_identifie_id_groupe function import_identifie_id_groupe($values, $table, $desc, $request) { $r = sql_fetsel("id_groupe AS id, titre", "spip_groupes_mots", "titre=" . sql_quote($values['titre'])); return $r ? array($r['id'], $r['titre']) : false; } // pour un mot le titre est insuffisant, il faut aussi l'identite du groupe. // Memoriser ces 2 infos et le signaler a import_translate grace a 1 negatif // http://doc.spip.org/@import_identifie_id_mot function import_identifie_id_mot($values, $table, $desc, $request) { return array((0 - $values['id_groupe']), $values['titre']); } // Passe 2: mot de meme titre et de meme groupe ==> identification // http://doc.spip.org/@import_identifie_parent_id_mot function import_identifie_parent_id_mot($id_groupe, $titre, $v) { global $trans; $titre = sql_quote($titre); $id_groupe = 0-$id_groupe; if (isset($trans['id_groupe']) AND isset($trans['id_groupe'][$id_groupe])) { $new = $trans['id_groupe'][$id_groupe][0]; $r = sql_fetsel("id_mot", "spip_mots", "titre=$titre AND id_groupe=$new" ); if ($r) return (0 - $r['id_mot']); } if ($r = sql_insertq('spip_mots')) sql_replace('spip_translate', array( 'id_old' => $v, 'id_new' => $r, 'titre' => $titre, 'type' => 'id_mot', 'ajout' => 1)); else spip_log("Impossible d'inserer dans spip_mots"); return $r; } // idem pour les articles // http://doc.spip.org/@import_identifie_id_article function import_identifie_id_article($values, $table, $desc, $request) { return array((0 - $values['id_rubrique']), $values['titre']); } // Passe 2 des articles comme pour les mots // http://doc.spip.org/@import_identifie_parent_id_article function import_identifie_parent_id_article($id_parent, $titre, $v) { $id_parent = importe_translate_maj('id_rubrique', (0 - $id_parent)); $titre = sql_quote($titre); $r = sql_fetsel("id_article", "spip_articles", "titre=$titre AND id_rubrique=$id_parent AND statut<>'poubelle'" ); if ($r) return (0 - $r['id_article']); if ($r = sql_insertq('spip_articles')) sql_replace('spip_translate', array( 'id_old' => $v, 'id_new' => $r, 'titre' => $titre, 'type' => 'id_article', 'ajout' => 1), $GLOBALS['tables_principales']['spip_translate'] ); else spip_log("Impossible d'inserer dans spip_articles"); return $r; } // idem pour les breves // http://doc.spip.org/@import_identifie_id_breve function import_identifie_id_breve($values, $table, $desc, $request) { return array((0 - $values['id_rubrique']), $values['titre']); } // Passe 2 des breves comme pour les mots // http://doc.spip.org/@import_identifie_parent_id_breve function import_identifie_parent_id_breve($id_parent, $titre, $v) { $id_parent = importe_translate_maj('id_rubrique', (0 - $id_parent)); $titre = sql_quote($titre); $r = sql_fetsel("id_breve", "spip_breves", "titre=$titre AND id_rubrique=$id_parent AND statut<>'refuse'" ); if ($r) return (0 - $r['id_breve']); if ($r = sql_insertq('spip_breves')) sql_replace('spip_translate', array( 'id_old' => $v, 'id_new' => $r, 'titre' => $titre, 'type' => 'id_breve', 'ajout' => 1), $GLOBALS['tables_principales']['spip_translate'] ); else spip_log("Impossible d'inserer dans spip_breves"); return $r; } // pour une rubrique le titre est insuffisant, il faut l'identite du parent // Memoriser ces 2 infos et le signaler a import_translate grace a 1 negatif // http://doc.spip.org/@import_identifie_id_rubrique function import_identifie_id_rubrique($values, $table, $desc, $request) { return array((0 - $values['id_parent']), $values['titre']); } // Passe 2 des rubriques, renumerotation en cascade. // rubrique de meme titre et de meme parent ==> identification // http://doc.spip.org/@import_identifie_parent_id_rubrique function import_identifie_parent_id_rubrique($id_parent, $titre, $v) { global $trans; if (isset($trans['id_rubrique'])) { if ($id_parent < 0) { $id_parent = (0 - $id_parent); $gparent = $trans['id_rubrique'][$id_parent][0]; // parent deja renumerote depuis le debut la passe 2 if ($gparent >= 0) $id_parent = $gparent; else { // premiere occurrence du parent $pitre = $trans['id_rubrique'][$id_parent][1]; $n = import_identifie_parent_id_rubrique($gparent, $pitre, $id_parent); $trans['id_rubrique'][$id_parent][0] = ($n>0) ? $n: (0-$n); // parent tout neuf, // pas la peine de chercher un titre homonyme if ($n > 0) { $trans['id_rubrique'][$id_parent][2]=1; // nouvelle rub. return import_alloue_id_rubrique($n, $titre, $v); } else $id_parent = (0 - $n); } } $r = sql_fetsel("id_rubrique", "spip_rubriques", "titre=" . sql_quote($titre) . " AND id_parent=" . intval($id_parent)); if ($r) { return (0 - $r['id_rubrique']); } return import_alloue_id_rubrique($id_parent, $titre, $v); } } // reserver la place en mettant titre et parent tout de suite // pour que le SELECT ci-dessus fonctionne a la prochaine occurrence // http://doc.spip.org/@import_alloue_id_rubrique function import_alloue_id_rubrique($id_parent, $titre, $v) { if ($r = sql_insertq('spip_rubriques', array('titre' => $titre, id_parent => $id_parent))) sql_replace('spip_translate', array( 'id_old' => $v, 'id_new' => $r, 'titre' => $titre, 'type' => 'id_rubrique', 'ajout' => 1), $GLOBALS['tables_principales']['spip_translate']); else spip_log("Impossible d'inserer dans spip_rubriques"); return $r; } ?> spip/spip/ecrire/inc/commencer_page.php0000766000000000000000000002153111236524730021400 0ustar adminadministrators" . ($alertes?alertes_auteur($connect_id_auteur):'') . auteurs_recemment_connectes($connect_id_auteur); } // envoi du doctype et du ...</head> // http://doc.spip.org/@init_entete function init_entete($titre='', $id_rubrique=0, $minipres=false) { include_spip('inc/gadgets'); if (!$nom_site_spip = textebrut(typo($GLOBALS['meta']["nom_site"]))) $nom_site_spip= _T('info_mon_site_spip'); $head = "<title>[" . $nom_site_spip . "] " . textebrut(typo($titre)) . "\n" . "\n" . envoi_link($nom_site_spip,$minipres); // anciennement verifForm $head .= ' '; return _DOCTYPE_ECRIRE . html_lang_attributes() . "\n" . pipeline('header_prive', $head) . "\n"; } // fonction envoyant la double serie d'icones de redac // http://doc.spip.org/@init_body function init_body($rubrique='accueil', $sous_rubrique='accueil', $id_rubrique='',$menu=true) { global $connect_id_auteur, $auth_can_disconnect; global $spip_display, $spip_ecran; if ($spip_ecran == "large") $largeur = 974; else $largeur = 750; $res = pipeline('body_prive',"'); if ($spip_display == "4") { $res .= ""; return $res; } if (!$menu) return $res; $items = "
    "; //
    pour la barre des gadgets // (elements invisibles qui s'ouvrent sous la barre precedente) $items .= bandeau_gadgets($largeur, true, $id_rubrique); $bandeau = charger_fonction('bandeau', 'inc'); return $res . "" . "
    \n" . $bandeau($rubrique, $sous_rubrique, $largeur) . "\n
    " . $items . "
    \n"; } // http://doc.spip.org/@avertissement_messagerie function avertissement_messagerie($id_auteur) { $result_messages = sql_allfetsel("lien.id_message", "spip_messages AS messages, spip_auteurs_messages AS lien", "lien.id_auteur=".sql_quote($id_auteur)." AND vu='non' AND statut='publie' AND type='normal' AND lien.id_message=messages.id_message",'',''); $total_messages = count($result_messages); if ($total_messages == 1) { $row = $result_messages[0]; $ze_message=$row['id_message']; return ""._T('info_nouveau_message').""; } elseif ($total_messages > 1) return ""._T('info_nouveaux_messages', array('total_messages' => $total_messages)).""; else return ''; } // http://doc.spip.org/@alertes_auteur function alertes_auteur($id_auteur) { $alertes = array(); if (isset($GLOBALS['meta']['message_crash_tables']) AND autoriser('detruire', null, null, $id_auteur)) { include_spip('genie/maintenance'); if ($msg = message_crash_tables()) $alertes[] = $msg; } if (isset($GLOBALS['meta']['message_crash_plugins']) AND autoriser('configurer', 'plugins', null, $id_auteur)) { include_spip('inc/plugin'); if ($msg = message_crash_plugins()) $alertes[] = $msg; } if (isset($GLOBALS['meta']['plugin_erreur_activation']) AND autoriser('configurer', 'plugins', null, $id_auteur)) { $alertes[] = $GLOBALS['meta']['plugin_erreur_activation']; effacer_meta('plugin_erreur_activation'); // pas normal que ce soit ici } $alertes[] = avertissement_messagerie($id_auteur); if ($alertes = array_filter($alertes)) return "
    ". join('
    ', $alertes) ."
    "; } // http://doc.spip.org/@auteurs_recemment_connectes function auteurs_recemment_connectes($id_auteur) { $result = sql_allfetsel("*", "spip_auteurs", "id_auteur!=" .intval($id_auteur) . " AND en_ligne>DATE_SUB(".sql_quote(date('Y-m-d H:i:s')).",INTERVAL 15 MINUTE) AND " . sql_in('statut', array('1comite', '0minirezo'))); if (!$result) return ''; $formater_auteur = charger_fonction('formater_auteur', 'inc'); $res = ''; foreach ($result as $row) { $id = $row['id_auteur']; $mail = formater_auteur_mail($row, $id); $auteurs = "" . typo($row['nom']) . ""; $res .= "$mail $auteurs" . ", "; } return "
    " . ""._T('info_en_ligne'). " " . substr($res,0,-2) . "
    "; } // http://doc.spip.org/@lien_change_var function lien_change_var($lien, $set, $couleur, $coords, $titre, $mouseOver="") { $lien = parametre_url($lien, $set, $couleur); return "\n\"$titre\""; } ?> spip/spip/ecrire/inc/math.php0000766000000000000000000000657411236524730017377 0ustar adminadministrators... en client-serveur // // http://doc.spip.org/@image_math function image_math($tex) { global $traiter_math; switch ($traiter_math) { // Attention: mathml desactiv'e pour l'instant case 'mathml': $ext = '.xhtml'; $server = $GLOBALS['mathml_server']; break; case 'tex': $ext = '.png'; $server = $GLOBALS['tex_server']; break; default: return $tex; } // Regarder dans le repertoire local des images TeX et blocs MathML if (!@is_dir($dir_tex = _DIR_VAR.'cache-TeX/')) @mkdir ($dir_tex, _SPIP_CHMOD); $fichier = $dir_tex .md5(trim($tex)).$ext; if (!@file_exists($fichier)) { // Aller chercher l'image sur le serveur if ($server) { spip_log($url = $server.'?'.rawurlencode($tex)); include_spip('inc/distant'); recuperer_page($url,$fichier); } } // Composer la reponse selon presence ou non de l'image $tex = entites_html($tex); if (@file_exists($fichier)) { // MathML if ($traiter_math == 'mathml') { return join(file("$fichier"),""); } // TeX else { list(,,,$size) = @getimagesize($fichier); $alt = "alt=\"$tex\" title=\"$tex\""; return ""; } } else // pas de fichier return "$tex"; } // Fonction appelee par propre() s'il repere un mode // http://doc.spip.org/@traiter_math function traiter_math($letexte, $source='') { $texte_a_voir = $letexte; while (($debut = strpos($texte_a_voir, "")) !== false) { if (!$fin = strpos($texte_a_voir,"")) $fin = strlen($texte_a_voir); $texte_debut = substr($texte_a_voir, 0, $debut); $texte_milieu = substr($texte_a_voir, $debut+strlen(""), $fin-$debut-strlen("")); $texte_fin = substr($texte_a_voir, $fin+strlen(""), strlen($texte_a_voir)); // Les doubles $$x^2$$ en mode 'div' while((preg_match(",[$][$]([^$]+)[$][$],",$texte_milieu, $regs))) { $echap = "\n

    ".image_math($regs[1])."

    \n"; $pos = strpos($texte_milieu, $regs[0]); $texte_milieu = substr($texte_milieu,0,$pos) . code_echappement($echap, $source) . substr($texte_milieu,$pos+strlen($regs[0])); } // Les simples $x^2$ en mode 'span' while((preg_match(",[$]([^$]+)[$],",$texte_milieu, $regs))) { $echap = image_math($regs[1]); $pos = strpos($texte_milieu, $regs[0]); $texte_milieu = substr($texte_milieu,0,$pos) . code_echappement($echap, $source) . substr($texte_milieu,$pos+strlen($regs[0])); } $texte_a_voir = $texte_debut.$texte_milieu.$texte_fin; } return $texte_a_voir; } ?> spip/spip/ecrire/inc/meme_rubrique.php0000766000000000000000000000632711236524730021303 0ustar adminadministrators'articles','breve'=>'breves_voir','syndic'=>'sites'); $where = (($GLOBALS['visiteur_session']['statut'] == '0minirezo') ? '' : "(statut = 'publie' OR statut = 'prop') AND ") . "id_rubrique=$id_rubrique AND ($prim != $id)"; $select = "$prim AS id, $titre AS titre, statut"; $n = sql_countsel($table, $where); if (!$n) return ''; $voss = sql_select($select, $table, $where, '', "$order DESC", $limit); $limit = $n - $limit; $retour = ''; $puce_statut = charger_fonction('puce_statut', 'inc'); $idom = 'rubrique_' . $type; while($row = sql_fetch($voss)) { $id = $row['id']; $num = afficher_numero_edit($id, $prim, $type); $statut = $row['statut']; // Exception pour les meme-rubrique de sites if ($type == "syndic") $type_statut = "site"; else $type_statut = $type; $statut = $puce_statut($id, $statut, $id_rubrique, $type_statut); $href = "" . sinon(typo($row['titre']), _T('info_sans_titre')) . ""; // Todo: refaire en css plus sains $retour .= "\n
    " . "\n
    " . $num . "
    " . "
    ".$statut ."
    " . "
    ".$href."
    " . "
    " . "
    "; } $icone = '' . _T('info_meme_rubrique') . ''; $bouton = bouton_block_depliable(_T('info_meme_rubrique'),true,'memerub'); $retour = debut_cadre('meme-rubriques',"article-24.gif",'',$bouton) . debut_block_depliable(true,'memerub') . $retour; // $retour .= (($limit <= 0) ? '' : "+ $limit"); $retour .= fin_block() . fin_cadre('meme-rubriques'); if ($ajax) return $retour; // id utilise dans puce_statut_article return "\n
    $retour
    "; } ?> spip/spip/ecrire/inc/informer.php0000766000000000000000000000535511236524730020263 0ustar adminadministrators", 100, 48); if ($res) $res = "
    $res
    "; } } $rac = htmlentities($rac); # ce lien provoque la selection (directe) de la rubrique cliquee # et l'affichage de son titre dans le bandeau $titre = strtr(str_replace("'", "’", str_replace('"', """, textebrut($titre))), "\n\r", " "); $js_func = $do . '_selection_titre'; return "
    " . "" . "" . "
    " . "
    " . (!$res ? '' : $res) . "

    ".safehtml($titre)."

    " . (!$descriptif ? '' : "
    ".safehtml($descriptif)."
    ") . "
    " . "" . "
    " . "
    "; } ?> spip/spip/ecrire/inc/instituer_article.php0000766000000000000000000000427211236524730022170 0ustar adminadministrators 'publie' AND $GLOBALS['meta']['post_dates'] == 'non' AND function_exists('menu_postdates')) list($postdates,$postdates_js) = menu_postdates(); else $postdates = $postdates_js = '';*/ // cf autorisations dans action/editer_article if (!autoriser('modifier', 'article', $id_article)) return ''; $res = ''; $etats = $GLOBALS['liste_des_etats']; if (!autoriser('publierdans', 'rubrique', $id_rubrique)) { unset($etats[array_search('publie', $etats)]); unset($etats[array_search('refuse', $etats)]); if ($statut == 'prepa') $res = supprimer_tags(_T('texte_proposer_publication')); } $res .= "
      " . "
    • " . _T('texte_article_statut') . aide("artstatut") ."
        "; $href = redirige_action_auteur('instituer_article',$id_article,'articles', "id_article=$id_article"); foreach($etats as $affiche => $s){ $puce = puce_statut($s) . _T($affiche); if ($s==$statut) $class=' selected'; else { $class=''; $puce = "$puce"; } $res .= "
      • $puce
      • "; } $res .= "
    "; return $res; } ?> spip/spip/ecrire/inc/distant.php0000766000000000000000000005037711236524730020114 0ustar adminadministrators array( 'operation' => 'copie_locale', 'source' => $source, 'fichier' => $local ), 'data' => null ) ); } } return $local; } // http://doc.spip.org/@prepare_donnees_post function prepare_donnees_post($donnees, $boundary = '') { // permettre a la fonction qui a demande le post de formater elle meme ses donnees // pour un appel soap par exemple // l'entete est separe des donnees par un double retour a la ligne // on s'occupe ici de passer tous les retours lignes (\r\n, \r ou \n) en \r\n if (is_string($donnees) && strlen($donnees)){ $entete = ""; // on repasse tous les \r\n et \r en simples \n $donnees = str_replace("\r\n","\n",$donnees); $donnees = str_replace("\r","\n",$donnees); // un double retour a la ligne signifie la fin de l'entete et le debut des donnees $p = strpos($donnees,"\n\n"); if ($p!==FALSE){ $entete = str_replace("\n","\r\n",substr($donnees,0,$p+1)); $donnees = substr($donnees,$p+2); } $chaine = str_replace("\n","\r\n",$donnees); } else { /* boundary automatique */ // Si on a plus de 500 octects de donnees, on "boundarise" if($boundary == '') { $taille = 0; foreach ($donnees as $cle => $valeur) { if (is_array($valeur)) { foreach ($valeur as $val2) { $taille += strlen($val2); } } else { // faut-il utiliser spip_strlen() dans inc/charsets ? $taille += strlen($valeur); } } if($taille>500) { $boundary = substr(md5(rand().'spip'), 0, 8); } } if($boundary) { // fabrique une chaine HTTP pour un POST avec boundary $entete = "Content-Type: multipart/form-data; boundary=$boundary\r\n"; $chaine = ''; if (is_array($donnees)) { foreach ($donnees as $cle => $valeur) { $chaine .= "\r\n--$boundary\r\n"; $chaine .= "Content-Disposition: form-data; name=\"$cle\"\r\n"; $chaine .= "\r\n"; $chaine .= $valeur; } $chaine .= "\r\n--$boundary\r\n"; } } else { // fabrique une chaine HTTP simple pour un POST $entete = 'Content-Type: application/x-www-form-urlencoded'."\r\n"; $chaine = array(); if (is_array($donnees)) { foreach ($donnees as $cle => $valeur) { if (is_array($valeur)) { foreach ($valeur as $val2) { $chaine[] = rawurlencode($cle).'='.rawurlencode($val2); } } else { $chaine[] = rawurlencode($cle).'='.rawurlencode($valeur); } } $chaine = implode('&', $chaine); } else { $chaine = $donnees; } } } return array($entete, $chaine); } // // Recupere une page sur le net // et au besoin l'encode dans le charset local // // options : get_headers si on veut recuperer les entetes // taille_max : arreter le contenu au-dela (0 = seulement les entetes ==>HEAD) // Par defaut taille_max = 1Mo. // datas, une chaine ou un tableau pour faire un POST de donnees // boundary, pour forcer l'envoi par cette methode // et refuser_gz pour forcer le refus de la compression (cas des serveurs orthographiques) // date_verif, un timestamp unix pour arreter la recuperation si la page distante n'a pas ete modifiee depuis une date donnee // uri_referer, preciser un referer different // Le second argument ($trans) : // * si c'est une chaine longue, alors c'est un nom de fichier // dans lequel on ecrit directement la page // * si c'est true/null ca correspond a une demande d'encodage/charset // http://doc.spip.org/@recuperer_page function recuperer_page($url, $trans=false, $get_headers=false, $taille_max = null, $datas='', $boundary='', $refuser_gz = false, $date_verif = '', $uri_referer = '') { $gz = false; // $copy = copier le fichier ? $copy = (is_string($trans) AND strlen($trans) > 5); // eviter "false" :-) if (is_null($taille_max)) $taille_max = $copy ? _COPIE_LOCALE_MAX_SIZE : 1048576; // Accepter les URLs au format feed:// ou qui ont oublie le http:// $url = preg_replace(',^feed://,i', 'http://', $url); if (!preg_match(',^[a-z]+://,i', $url)) $url = 'http://'.$url; if ($taille_max == 0) $get = 'HEAD'; else $get = 'GET'; if (!empty($datas)) { $get = 'POST'; list($type, $postdata) = prepare_donnees_post($datas); $datas = $type . 'Content-Length: '.strlen($postdata)."\r\n\r\n".$postdata; } // dix tentatives maximum en cas d'entetes 301... for ($i=0;$i<10;$i++) { $url = recuperer_lapage($url, $trans, $get, $taille_max, $datas, $boundary, $refuser_gz, $date_verif, $uri_referer); if (!$url) return false; if (is_array($url)) { list($headers, $result) = $url; return ($get_headers ? $headers."\n" : '').$result; } else spip_log("recuperer page recommence sur $url"); } } // args comme ci-dessus (presque) // retourne l'URL en cas de 301, un tableau (entete, corps) si ok, false sinon // si $trans est null -> on ne veut que les headers // si $trans est une chaine, c'est un nom de fichier pour ecrire directement dedans // http://doc.spip.org/@recuperer_lapage function recuperer_lapage($url, $trans=false, $get='GET', $taille_max = 1048576, $datas='', $boundary='', $refuser_gz = false, $date_verif = '', $uri_referer = '') { // $copy = copier le fichier ? $copy = (is_string($trans) AND strlen($trans) > 5); // eviter "false" :-) // si on ecrit directement dans un fichier, pour ne pas manipuler // en memoire refuser gz if ($copy) $refuser_gz = true; // ouvrir la connexion et envoyer la requete et ses en-tetes list($f, $fopen) = init_http($get, $url, $refuser_gz, $uri_referer, $datas); if (!$f) { spip_log("ECHEC init_http $url"); return false; } // Sauf en fopen, envoyer le flux d'entree // et recuperer les en-tetes de reponses if ($fopen) $headers = ''; else { $headers = recuperer_entetes($f, $date_verif); if (is_numeric($headers)) { spip_log("HTTP status $headers pour $url"); fclose($f); return false; } if (!is_array($headers)) { // cas Location fclose($f); include_spip('inc/filtres'); return suivre_lien($url, $headers); } $headers = join('', $headers); } # spip_log("recup $headers" ); if ($trans === NULL) return array($headers, ''); $result = recuperer_body($f, $taille_max, $copy ? $trans : ''); fclose($f); if (!$result) return array($headers, $result); // Decompresser au besoin if (preg_match(",\bContent-Encoding: .*gzip,i", $headers)) { $result = spip_gzinflate_body($result); } // Faut-il l'importer dans notre charset local ? if ($trans === true) { include_spip('inc/charsets'); $result = transcoder_page ($result, $headers); } return array($headers, $result); } // Certaines decompressions gz sont subtiles // cf. http://fr2.php.net/manual/fr/function.gzinflate.php#77336 // (cas de http://files.spip.org/spip-zone/paquets.xml.gz qui ne pouvait etre recupere) // http://doc.spip.org/@spip_gzinflate_body function spip_gzinflate_body($gzData){ // return gzinflate(substr($gzData,10)); if(substr($gzData,0,3)=="\x1f\x8b\x08"){ $i=10; $flg=ord(substr($gzData,3,1)); if($flg>0){ if($flg&4){ list($xlen)=unpack('v',substr($gzData,$i,2)); $i=$i+2+$xlen; } if($flg&8) $i=strpos($gzData,"\0",$i)+1; if($flg&16) $i=strpos($gzData,"\0",$i)+1; if($flg&2) $i=$i+2; } return gzinflate(substr($gzData,$i,-8)); } else return false; } // http://doc.spip.org/@recuperer_body function recuperer_body($f, $taille_max=1048576, $fichier='') { $taille = 0; $result = ''; if ($fichier){ $fp = spip_fopen_lock($fichier, 'w',LOCK_EX); if (!$fp) return false; $result = 0; // on renvoie la taille du fichier } while (!feof($f) AND $taille<$taille_max){ $res = fread($f, 16384); $taille += strlen($res); if ($fp){ fwrite($fp,$res); $result = $taille; } else $result .= $res; } if ($fp) spip_fclose_unlock($fp); return $result; } // Lit les entetes de reponse HTTP sur la socket $f et retourne: // la valeur (chaine) de l'en-tete Location si on l'a trouvee // la valeur (numerique) du statut si different de 200, notamment Not-Modified // le tableau des entetes dans tous les autres cas // http://doc.spip.org/@recuperer_entetes function recuperer_entetes($f, $date_verif='') { $s = @trim(fgets($f, 16384)); if (!preg_match(',^HTTP/[0-9]+\.[0-9]+ ([0-9]+),', $s, $r)) { return 0; } $status = intval($r[1]); $headers = array(); $not_modif = false; while ($s = trim(fgets($f, 16384))) { $headers[]= $s."\n"; preg_match(',^([^:]*): *(.*)$,i', $s, $r); list(,$d, $v) = $r; if (strtolower(trim($d)) == 'location' AND $status >= 300 AND $status < 400) { $location = $v; } elseif ($date_verif AND ($d == 'Last-Modified')) { if ($date_verif>=strtotime($v)) { //Cas ou la page distante n'a pas bouge depuis //la derniere visite $not_modif = true; } } } if ($location) return $location; if ($status != 200 or $not_modif) return $status; return $headers; } // Si on doit conserver une copie locale des fichiers distants, autant que ca // soit a un endroit canonique -- si ca peut etre bijectif c'est encore mieux, // mais la tout de suite je ne trouve pas l'idee, etant donne les limitations // des filesystems // http://doc.spip.org/@nom_fichier_copie_locale function nom_fichier_copie_locale($source, $extension) { include_spip('inc/getdocument'); $d = creer_repertoire_documents('distant'); # IMG/distant/ $d = sous_repertoire($d, $extension); # IMG/distant/pdf/ // on se place tout le temps comme si on etait a la racine if (_DIR_RACINE) $d = preg_replace(',^'.preg_quote(_DIR_RACINE).',', '', $d); $m = md5($source); return $d . substr(preg_replace(',[^\w-],', '', basename($source)).'-'.$m,0,12) . substr($m,0,4) . ".$extension"; } // // Donne le nom de la copie locale de la source // // http://doc.spip.org/@fichier_copie_locale function fichier_copie_locale($source) { // Si c'est deja local pas de souci if (!preg_match(',^\w+://,', $source)) { if (_DIR_RACINE) $source = preg_replace(',^'.preg_quote(_DIR_RACINE).',', '', $source); return $source; } // optimisation : on regarde si on peut deviner l'extension dans l'url et si le fichier // a deja ete copie en local avec cette extension // dans ce cas elle est fiable, pas la peine de requeter en base $path_parts = pathinfo($source); $ext = $path_parts ? $path_parts['extension'] : ''; if ($ext AND preg_match(',^\w+$,',$ext) // pas de php?truc=1&... AND $f=nom_fichier_copie_locale($source, $ext) AND file_exists(_DIR_RACINE . $f)) return $f; // Si c'est deja dans la table des documents, // ramener le nom de sa copie potentielle $ext = sql_getfetsel("extension", "spip_documents", "fichier=" . sql_quote($source) . " AND distant='oui' AND extension <> ''"); if ($ext) return nom_fichier_copie_locale($source, $ext); // voir si l'extension indiquee dans le nom du fichier est ok // et si il n'aurait pas deja ete rapatrie $ext = $path_parts ? $path_parts['extension'] : ''; if ($ext AND sql_getfetsel("extension", "spip_types_documents", "extension=".sql_quote($ext))) { $f = nom_fichier_copie_locale($source, $ext); if (file_exists(_DIR_RACINE . $f)) return $f; } // Ping pour voir si son extension est connue et autorisee $path_parts = recuperer_infos_distantes($source,0,false) ; $ext = $path_parts ? $path_parts['extension'] : ''; if ($ext AND sql_getfetsel("extension", "spip_types_documents", "extension=".sql_quote($ext))) { return nom_fichier_copie_locale($source, $ext); } spip_log("pas de copie locale pour $source"); } // Recuperer les infos d'un document distant, sans trop le telecharger #$a['body'] = chaine #$a['type_image'] = booleen #$a['titre'] = chaine #$a['largeur'] = intval #$a['hauteur'] = intval #$a['taille'] = intval #$a['extension'] = chaine #$a['fichier'] = chaine // http://doc.spip.org/@recuperer_infos_distantes function recuperer_infos_distantes($source, $max=0, $charger_si_petite_image = true) { # charger les alias des types mime include_spip('base/typedoc'); global $mime_alias; $a = array(); $mime_type = ''; // On va directement charger le debut des images et des fichiers html, // de maniere a attrapper le maximum d'infos (titre, taille, etc). Si // ca echoue l'utilisateur devra les entrer... if ($headers = recuperer_page($source, false, true, $max, '', '', true)) { list($headers, $a['body']) = split("\n\n", $headers, 2); if (preg_match(",\nContent-Type: *([^[:space:];]*),i", "\n$headers", $regs)) $mime_type = (trim($regs[1])); else $mime_type = ''; // inconnu // Appliquer les alias while (isset($mime_alias[$mime_type])) $mime_type = $mime_alias[$mime_type]; // Si on a text/plain, c'est peut-etre que le serveur ne sait pas // ce qu'il sert ; on va tenter de detecter via l'extension de l'url $t = null; if (($mime_type == 'text/plain' OR $mime_type == '') AND preg_match(',\.([a-z0-9]+)(\?.*)?$,', $source, $rext)) { $t = sql_fetsel("extension", "spip_types_documents", "extension=" . sql_quote($rext[1])); } // Autre mime/type (ou text/plain avec fichier d'extension inconnue) if (!$t) $t = sql_fetsel("extension", "spip_types_documents", "mime_type=" . sql_quote($mime_type)); // Toujours rien ? (ex: audio/x-ogg au lieu de application/ogg) // On essaie de nouveau avec l'extension if (!$t AND $mime_type != 'text/plain' AND preg_match(',\.([a-z0-9]+)(\?.*)?$,', $source, $rext)) { $t = sql_fetsel("extension", "spip_types_documents", "extension=" . sql_quote($rext[1])); } if ($t) { spip_log("mime-type $mime_type ok, extension ".$t['extension']); $a['extension'] = $t['extension']; } else { # par defaut on retombe sur '.bin' si c'est autorise spip_log("mime-type $mime_type inconnu"); $t = sql_fetsel("extension", "spip_types_documents", "extension='bin'"); if (!$t) return false; $a['extension'] = $t['extension']; } if (preg_match(",\nContent-Length: *([^[:space:]]*),i", "\n$headers", $regs)) $a['taille'] = intval($regs[1]); } // Echec avec HEAD, on tente avec GET if (!$a AND !$max) { spip_log("tenter GET $source"); $a = recuperer_infos_distantes($source, 1024*1024); } // S'il s'agit d'une image pas trop grosse ou d'un fichier html, on va aller // recharger le document en GET et recuperer des donnees supplementaires... if (preg_match(',^image/(jpeg|gif|png|swf),', $mime_type)) { if ($max == 0 AND $a['taille'] < 1024*1024 AND (strpos($GLOBALS['meta']['formats_graphiques'],$a['extension'])!==false) AND $charger_si_petite_image) { $a = recuperer_infos_distantes($source, 1024*1024); } else if ($a['body']) { $a['fichier'] = _DIR_RACINE . nom_fichier_copie_locale($source, $a['extension']); ecrire_fichier($a['fichier'], $a['body']); $size_image = @getimagesize($a['fichier']); $a['largeur'] = intval($size_image[0]); $a['hauteur'] = intval($size_image[1]); $a['type_image'] = true; } } // Fichier swf, si on n'a pas la taille, on va mettre 425x350 par defaut // ce sera mieux que 0x0 if ($a['extension'] == 'swf' AND !$a['largeur']) { $a['largeur'] = 425; $a['hauteur'] = 350; } if ($mime_type == 'text/html') { include_spip('inc/filtres'); $page = recuperer_page($source, true, false, 1024*1024); if(preg_match(',(.*?),ims', $page, $regs)) $a['titre'] = corriger_caracteres(trim($regs[1])); if (!$a['taille']) $a['taille'] = strlen($page); # a peu pres } return $a; } // http://doc.spip.org/@need_proxy function need_proxy($host) { $http_proxy = $GLOBALS['meta']["http_proxy"]; $http_noproxy = $GLOBALS['meta']["http_noproxy"]; $domain = substr($host,strpos($host,'.')); return ($http_proxy AND (strpos(" $http_noproxy ", " $host ") === false AND (strpos(" $http_noproxy ", " $domain ") === false))) ? $http_proxy : ''; } // // Lance une requete HTTP avec entetes // retourne le descripteur sur lequel lire la reponse // // http://doc.spip.org/@init_http function init_http($method, $url, $refuse_gz=false, $referer = '', $datas="", $vers="HTTP/1.0") { $via_proxy = ''; $proxy_user = ''; $fopen = false; $t = @parse_url($url); $host = $t['host']; if ($t['scheme'] == 'http') { $scheme = 'http'; $noproxy = ''; } elseif ($t['scheme'] == 'https') { $scheme = 'ssl'; $noproxy = 'ssl://'; if (!isset($t['port']) || !($port = $t['port'])) $t['port'] = 443; } else { $scheme = $t['scheme']; $noproxy = $scheme.'://'; } if (isset($t['user'])) $user = array($t['user'], $t['pass']); if (!isset($t['port']) || !($port = $t['port'])) $port = 80; if (!isset($t['path']) || !($path = $t['path'])) $path = "/"; if ($t['query']) $path .= "?" .$t['query']; $f = lance_requete($method, $scheme, $user, $host, $path, $port, $noproxy, $refuse_gz, $referer, $datas, $vers); if (!$f) { // fallback : fopen if (!$GLOBALS['tester_proxy']) { $f = @fopen($url, "rb"); spip_log("connexion vers $url par simple fopen"); $fopen = true; } else $f = false;// echec total } return array($f, $fopen); } // http://doc.spip.org/@lance_requete function lance_requete($method, $scheme, $user, $host, $path, $port, $noproxy, $refuse_gz=false, $referer = '', $datas="", $vers="HTTP/1.0") { $http_proxy = need_proxy($host); if ($http_proxy) { $path = "$scheme://" . (!$user ? '' : urlencode($user[0]).":".urlencode($user[1])."@") . "$host" . (($port != 80) ? ":$port" : "") . $path; $t2 = @parse_url($http_proxy); $proxy_user = $t2['user']; $proxy_pass = $t2['pass']; $first_host = $t2['host']; if (!($port = $t2['port'])) $port = 80; } else $first_host = $noproxy.$host; $f = @fsockopen($first_host, $port); spip_log("Recuperer $path sur $first_host:$port par $f"); if (!$f) return false; $site = $GLOBALS['meta']["adresse_site"]; $req = "$method $path $vers\r\n" . "Host: $host\r\n" . "User-Agent: SPIP-".$GLOBALS['spip_version_affichee']." (http://www.spip.net/)\r\n" . ($refuse_gz ? '' : "Accept-Encoding: gzip\r\n") . (!$site ? '' : "Referer: $site/$referer\r\n") . (!$user ? '' : "Authorization: Basic " . base64_encode(urlencode($user[0]).":".urlencode($user[1])) ."\r\n") . (!$proxy_user ? '' : ("Proxy-Authorization: Basic " . base64_encode($proxy_user . ":" . $proxy_pass) . "\r\n")); # spip_log("Requete\n$req"); fputs($f, $req); fputs($f, $datas ? $datas : "\r\n"); return $f; } ?> spip/spip/ecrire/inc/import.php0000766000000000000000000004673011236524730017756 0ustar adminadministrators' de cette balise. // Si le 2e argument (passe par reference) est non vide // ce qui precede cette balise y est mis. // Les balises commencant par ','<','&'); while (($b=strpos($buf,'<'))===false) { if (!($x = $_fread($f, 1024))) return ''; if ($before) $buf .= $x; else { if (_DEBUG_IMPORT) $GLOBALS['debug_import_avant'] .= $buf; $abs_pos += strlen($buf); $buf = $x; } } if ($before) $before = str_replace($ent,$brut,substr($buf,0,$b)); # else { spip_log("position: $abs_pos" . substr($buf,0,12));flush();} // $b pour ignorer un > de raccourci Spip avant un < de balise XML while (($e=strpos($buf,'>', $b))===false) { if (!($x = $_fread($f, 1024))) return ''; $buf .= $x; } if ($buf[++$b]!=$skip) { if (_DEBUG_IMPORT){ $GLOBALS['debug_import_avant'] .= substr($buf,0,$e+1); $GLOBALS['debug_import_avant'] = substr($GLOBALS['debug_import_avant'],-1024); } $tag = substr($buf, $b, $e-$b); $buf = substr($buf,++$e); if (_DEBUG_IMPORT) $GLOBALS['debug_import_apres'] = $buf; $abs_pos += $e; return $tag; } if (_DEBUG_IMPORT) $GLOBALS['debug_import_avant'] .= substr($buf,0,$e+1); $buf = substr($buf,++$e); if (_DEBUG_IMPORT) $GLOBALS['debug_import_apres'] = $buf; $abs_pos += $e; return xml_fetch_tag($f,$before,$_fread,$skip); } // http://doc.spip.org/@xml_parse_tag function xml_parse_tag($t) { preg_match(',^([\w[?!%.;:-]*),s', $t, $res); $t = substr($t,strlen($res[0])); $res[1] = array(); // pourquoi on ne peut pas mettre \3 entre crochets ? if (preg_match_all(',\s*(--.*?--)?\s*([^=]*)\s*=\s*([\'"])([^"]*)\3,sS', $t, $m, PREG_SET_ORDER)) { foreach($m as $r) $res[1][$r[2]] = $r[4]; } return $res; } // Balise ouvrante: // 'SPIP' si fait par spip, nom de la base source si fait par phpmyadmin // http://doc.spip.org/@import_debut function import_debut($f, $gz='fread') { // Pour les anciennes archives, indiquer le charset par defaut: $charset = 'iso-8859-1'; // les + recentes l'ont en debut de ce fichier $flag_phpmyadmin = false; $b = false; while ($t = xml_fetch_tag($f, $b, $gz, '')) { $r = xml_parse_tag($t); if ($r[0] == '?xml' AND $r[1]['encoding']) $charset = strtolower($r[1]['encoding']); elseif ($r[0] == "SPIP") {$r[2] = $charset; return $r;} if (($r[0] == "!--") && (preg_match(",phpmyadmin\sxml\sdump,is",$r[1]))){ // c'est un dump xml phpmyadmin // on interprete le commentaire pour recuperer la version de phpmydadmin $version = preg_replace(",(.*?)version\s*([0-9a-z\.\-]*)\s(.*),is","\\2",$r[1]); $flag_phpmyadmin = true; } if (($r[0] != "!--") && ($flag_phpmyadmin == true)){ $r[1] = array('version_archive'=>"phpmyadmin::$version"); $r[2] = $charset; return $r; } } } // on conserve ce tableau pour faire des translations // de table eventuelles $tables_trans = array( ); // http://doc.spip.org/@import_init_tables function import_init_tables($request) { global $IMPORT_tables_noerase, $connect_id_auteur; // grand menage // on vide toutes les tables dont la restauration est demandee $tables = import_table_choix($request); $tables = array_diff($tables,$IMPORT_tables_noerase); foreach($tables as $table){ // regarder si il y a au moins un champ impt='non' if (($table!='spip_auteurs')){ $desc = description_table($table); if (isset($desc['field']['impt'])) sql_delete($table, "impt='oui'"); else sql_delete($table); } } // Bidouille pour garder l'acces admin actuel pendant toute la restauration sql_delete("spip_auteurs", "id_auteur=0"); sql_updateq('spip_auteurs', array('id_auteur'=>0, 'extra'=>$connect_id_auteur), "id_auteur=$connect_id_auteur"); sql_delete("spip_auteurs", "id_auteur!=0"); return $tables; } // Effacement de la bidouille ci-dessus // Toutefois si la table des auteurs ne contient plus qu'elle // c'est que la sauvegarde etait incomplete et on restaure le compte // pour garder la connection au site (mais il doit pas etre bien beau) // http://doc.spip.org/@detruit_restaurateur function detruit_restaurateur() { if (sql_countsel("spip_auteurs", "id_auteur<>0")) sql_delete("spip_auteurs", "id_auteur=0"); else { sql_update('spip_auteurs', array('id_auteur'=>'extra'), "id_auteur=0"); } } // http://doc.spip.org/@import_tables function import_tables($request, $archive) { global $import_ok, $abs_pos, $affiche_progression_pourcent; // regarder si on est pas en train d'importer dans une copie des tables if (isset($GLOBALS['meta']['restauration_table_prefix'])) { $charger = charger_fonction('charger','maj/vieille_base'); $charger($GLOBALS['meta']['vieille_version_installee']); $GLOBALS['serveur_vieille_base'] = 0; $prefix = $GLOBALS['connexions'][$GLOBALS['serveur_vieille_base']]['prefixe']; $GLOBALS['connexions'][$GLOBALS['serveur_vieille_base']]['prefixe'] = $GLOBALS['meta']['restauration_table_prefix']; // verifier qu'une table meta existe bien // sinon c'est une restauration anterieure echouee if (!sql_getfetsel('valeur','spip_meta','','','','0,1')){ $GLOBALS['connexions'][$GLOBALS['serveur_vieille_base']]['prefixe'] = $prefix; return; } // recharger les metas lire_metas(); } $abs_pos = (!isset($GLOBALS['meta']["restauration_status"])) ? 0 : $GLOBALS['meta']["restauration_status"]; // au premier appel destruction des tables a restaurer // ou initialisation de la table des translations, // mais pas lors d'une reprise. if ($request['insertion']=='on') { include_spip('inc/import_insere'); $request['init'] = (!$abs_pos) ? 'insere_1_init' : 'insere_1bis_init'; $request['boucle'] = 'import_insere'; } elseif ($request['insertion']=='passe2') { $request['init'] = 'insere_2_init'; $request['boucle'] = 'import_translate'; } else { $request['init'] = (!$abs_pos) ? 'import_init_tables' : 'import_table_choix'; $request['boucle'] = 'import_replace'; } if (strncmp(".gz", substr($archive,-3),3)==0) { $size = false; $taille = taille_en_octets($abs_pos); $file = gzopen($archive, 'rb'); $gz = 'gzread'; } else { $size = @filesize($archive); $taille = @floor(100 * $abs_pos / $size)." %"; $file = fopen($archive, 'rb'); $gz = 'fread'; } if ($abs_pos==0) { list($tag, $atts, $charset) = import_debut($file, $gz); // improbable: fichier correct avant debut_admin et plus apres if (!$tag) return !($import_ok = true); $version_archive = import_init_meta($tag, $atts, $charset, $request); } else { $version_archive = $GLOBALS['meta']['restauration_version_archive']; $atts = unserialize($GLOBALS['meta']['restauration_attributs_archive']); spip_log("Reprise de l'importation interrompue en $abs_pos"); $_fseek = ($gz=='gzread') ? 'gzseek' : 'fseek'; $_fseek($file, $abs_pos); } // placer la connexion sql dans le bon charset if (isset($GLOBALS['meta']['restauration_charset_sql_connexion'])) sql_set_charset($GLOBALS['meta']['restauration_charset_sql_connexion']); @define('_DEBUG_IMPORT',false); if (_DEBUG_IMPORT) ecrire_fichier(_DIR_TMP."debug_import.log","#####".date('Y-m-d H:i:s')."\n",false,false); $fimport = import_charge_version($version_archive); if ($request['insertion'] !== 'passe2') import_affiche_javascript($taille); if (function_exists('ob_flush')) @ob_flush(); flush(); $oldtable =''; $cpt = 0; $pos = $abs_pos; while ($table = $fimport($file, $request, $gz, $atts)) { // memoriser pour pouvoir reprendre en cas d'interrupt, // mais pas d'ecriture sur fichier, ca ralentit trop ecrire_meta("restauration_status", "$abs_pos",'non'); if ($oldtable != $table) { if (_DEBUG_IMPORT){ ecrire_fichier(_DIR_TMP."debug_import.log","----\n".$GLOBALS['debug_import_avant']."\n<<<<\n$table\n>>>>\n".$GLOBALS['debug_import_apres']."\n----\n",false,false); } if ($oldtable) spip_log("$cpt entrees"); spip_log("Analyse de $table (commence en $pos)"); affiche_progression_javascript($abs_pos,$size,$table); $oldtable = $table; $cpt = 0; $pos = $abs_pos; } $cpt++; } spip_log("$cpt entrees"); spip_log("fin de l'archive, statut: " .($import_ok ? 'ok' : 'alert')); if (!$import_ok) return _T('avis_archive_invalide') . ' ' . _T('taille_octets', array('taille' => $pos)) ; if ($GLOBALS['spip_version_base'] != (str_replace(',','.',$GLOBALS['meta']['version_installee']))){ // il FAUT recharger les bonnes desc serial/aux avant ... include_spip('base/serial'); $GLOBALS['tables_principales']=array(); base_serial($GLOBALS['tables_principales']); include_spip('base/auxiliaires'); $GLOBALS['tables_auxiliaires']=array(); base_auxiliaires($GLOBALS['tables_auxiliaires']); $GLOBALS['tables_jointures']=array(); include_spip('public/interfaces'); declarer_interfaces(); include_spip('base/upgrade'); maj_base(); // upgrade jusqu'a la version courante } // regarder si on est pas en train d'importer dans une copie des tables if (isset($GLOBALS['meta']['restauration_table_prefix_source'])){ $prefixe_source = $GLOBALS['meta']['restauration_table_prefix_source']; $GLOBALS['connexions']['-1'] = $GLOBALS['connexions'][0]; // rebasculer le serveur sur les bonnes tables pour finir proprement $GLOBALS['connexions'][0]['prefixe'] = $prefixe_source; // et relire les meta de la bonne base lire_metas(); $tables_recopiees = isset($GLOBALS['meta']['restauration_recopie_tables'])?unserialize($GLOBALS['meta']['restauration_recopie_tables']):array(); spip_log("charge tables_recopiees ".serialize($tables_recopiees),'dbdump'); // recopier les tables l'une sur l'autre // il FAUT recharger les bonnes desc serial/aux avant ... include_spip('base/serial'); $GLOBALS['tables_principales']=array(); base_serial($GLOBALS['tables_principales']); include_spip('base/auxiliaires'); $GLOBALS['tables_auxiliaires']=array(); base_auxiliaires($GLOBALS['tables_auxiliaires']); $GLOBALS['tables_jointures']=array(); include_spip('public/interfaces'); declarer_interfaces(); // puis relister les tables a importer // et les vider si besoin, au moment du premier passage ici // (et seulement si ce n'est pas une fusion, comment le dit-on ?) $initialisation_copie = (!isset($GLOBALS['meta']["restauration_status_copie"])) ? 0 : $GLOBALS['meta']["restauration_status_copie"]; if (!$initialisation_copie) { // vide et liste les tables $tables = import_init_tables($request); ecrire_meta("restauration_status_copie", "ok",'non'); } else $tables = import_table_choix($request); # var_dump($tables);die(); if (in_array('spip_auteurs',$tables)){ $tables = array_diff($tables,array('spip_auteurs')); $tables[] = 'spip_auteurs'; } if (in_array('spip_meta',$tables)){ $tables = array_diff($tables,array('spip_meta')); $tables[] = 'spip_meta'; } sql_drop_table('spip_test','','-1'); foreach ($tables as $table){ if (sql_showtable($table,false,-1)){ if (!isset($tables_recopiees[$table])) $tables_recopiees[$table] = 0; if ($tables_recopiees[$table]!==-1){ affiche_progression_javascript(0,0,$table); while (true) { $n = intval($tables_recopiees[$table]); $res = sql_select('*',$table,'','','',"$n,400",'','-1'); while ($row = sql_fetch($res,'-1')){ array_walk($row,'sql_quote'); sql_replace($table,$row); $tables_recopiees[$table]++; } if ($n == $tables_recopiees[$table]) break; spip_log("recopie $table ".$tables_recopiees[$table],'dbdump'); affiche_progression_javascript($tables_recopiees[$table],0,$table); ecrire_meta('restauration_recopie_tables',serialize($tables_recopiees)); } sql_drop_table($table,'','-1'); spip_log("drop $table",'dbdump'); $tables_recopiees[$table]=-1; ecrire_meta('restauration_recopie_tables',serialize($tables_recopiees)); spip_log("tables_recopiees ".serialize($tables_recopiees),'dbdump'); } } } } #die(); return '' ; } // http://doc.spip.org/@import_init_meta function import_init_meta($tag, $atts, $charset, $request) { $version_archive = $atts['version_archive']; $version_base = $atts['version_base']; $insert = $request['insertion'] ; $old = (!$insert && version_compare($version_base,$GLOBALS['spip_version_base'],'<') && !isset($GLOBALS['meta']['restauration_table_prefix'])); if ($old) { // creer une base avec les tables dans l'ancienne version // et changer de contexte $creer_base_anterieure = charger_fonction('create','maj/vieille_base'); $creer_base_anterieure($version_base); } if ($old OR $insert) { $init = $request['init']; spip_log("import_init_meta lance $init"); $init($request); } ecrire_meta('restauration_attributs_archive', serialize($atts),'non'); ecrire_meta('restauration_version_archive', $version_archive,'non'); ecrire_meta('restauration_tag_archive', $tag,'non'); // trouver le charset de la connexion sql qu'il faut utiliser pour la restauration // ou si le charset de la base est iso-xx // (on ne peut garder une connexion utf dans ce cas) // on laisse sql gerer la conversion de charset ! if (isset($GLOBALS['meta']['charset_sql_connexion']) OR (strncmp($charset,'iso-',4)==0) ){ include_spip('base/abstract_sql'); if ($sql_char = sql_get_charset($charset)){ $sql_char = $sql_char['charset']; ecrire_meta('restauration_charset_sql_connexion',$sql_char); } else { // faire la conversion de charset en php :( effacer_meta('restauration_charset_sql_connexion'); # precaution spip_log("charset de restauration inconnu de sql : $charset"); if ($insert) ecrire_meta('charset_insertion', $charset,'non'); else ecrire_meta('charset_restauration', $charset,'non'); } } $i = $insert ? ("insertion $insert") : ''; spip_log("Debut de l'importation (charset: $charset, format: $version_archive) $i"); return $version_archive; } // http://doc.spip.org/@import_affiche_javascript function import_affiche_javascript($taille) { $max_time = ini_get('max_execution_time')*1000; $t = _T('info_recharger_page'); $t = " "; echo debut_boite_alerte(), "", _T('info_base_restauration'), "", generer_form_ecrire('', $t, " style='text-align: center' name='progression' id='progression' method='get' "), fin_boite_alerte(); } // http://doc.spip.org/@affiche_progression_javascript function affiche_progression_javascript($abs_pos,$size, $table="") { include_spip('inc/charsets'); echo "\n\n"; if (function_exists('ob_flush')) @ob_flush(); flush(); } // http://doc.spip.org/@import_table_choix function import_table_choix($request) { // construction de la liste des tables pour le dump : // toutes les tables principales // + toutes les tables auxiliaires hors relations // + les tables relations dont les deux tables liees sont dans la liste $tables_for_dump = array(); $tables_pointees = array(); global $IMPORT_tables_noimport; global $tables_principales; global $tables_auxiliaires; global $tables_jointures; if (!isset($IMPORT_tables_noimport)) $IMPORT_tables_noimport=array(); // on construit un index des tables de liens // pour les ajouter SI les deux tables qu'ils connectent sont sauvegardees $tables_for_link = array(); foreach($tables_jointures as $table=>$liste_relations) if (is_array($liste_relations)) { $nom = $table; if (!isset($tables_auxiliaires[$nom])&&!isset($tables_principales[$nom])) $nom = "spip_$table"; if (isset($tables_auxiliaires[$nom])||isset($tables_principales[$nom])){ foreach($liste_relations as $link_table){ if (isset($tables_auxiliaires[$link_table])/*||isset($tables_principales[$link_table])*/){ $tables_for_link[$link_table][] = $nom; } else if (isset($tables_auxiliaires["spip_$link_table"])/*||isset($tables_principales["spip_$link_table"])*/){ $tables_for_link["spip_$link_table"][] = $nom; } } } } $liste_tables = array_merge(array_keys($tables_principales),array_keys($tables_auxiliaires)); foreach($liste_tables as $table){ $name = preg_replace("{^spip_}","",$table); if ( !isset($tables_pointees[$table]) && !in_array($table,$IMPORT_tables_noimport) && !isset($tables_for_link[$table])){ $tables_for_dump[] = $table; $tables_pointees[$table] = 1; } } foreach ($tables_for_link as $link_table =>$liste){ $connecte = true; foreach($liste as $connect_table) if (!in_array($connect_table,$tables_for_dump)) $connecte = false; if ($connecte) # on ajoute les liaisons en premier # si une restauration est interrompue, cela se verra mieux si il manque des objets # que des liens array_unshift($tables_for_dump,$link_table); } spip_log(count($tables_for_dump) . " tables importees " . join(', ', $tables_for_dump)); return $tables_for_dump; } ?> spip/spip/ecrire/inc/cookie.php0000766000000000000000000000506211236524730017706 0ustar adminadministrators $value) { if (substr($name,0,5)=='spip_' && substr($name,0,$prefix_long)!=$cookie_prefix) { unset($_COOKIE[$name]); unset($GLOBALS[$name]); } } foreach ($_COOKIE as $name => $value) { if (substr($name,0,$prefix_long)==$cookie_prefix) { $spipname = preg_replace ('/^'.$cookie_prefix.'_/', 'spip_', $name); $_COOKIE[$spipname] = $value; $GLOBALS[$spipname] = $value; } } } // Idem faudrait creer exec/test_ajax, mais c'est si court. // Tester si Ajax fonctionne pour ce brouteur // (si on arrive la c'est que c'est bon, donc poser le cookie) // http://doc.spip.org/@exec_test_ajax_dist function exec_test_ajax_dist() { switch (_request('js')) { // on est appele par
    "; } $form = "\n" . $form; $form = generer_action_auteur("editer_$type", $id, self(), $form, " method='post' class='submit_plongeur'"); } if ($retour_sans_cadre) return $form; include_spip('inc/presentation'); return debut_cadre_couleur($logo, true, "", $msg) . $form .fin_cadre_couleur(true); } // http://doc.spip.org/@barre_typo function barre_typo($id,$lang='',$forum=false){ include_spip('inc/barre'); return '
    ' . afficher_barre("document.getElementById('$id')",$forum,$lang) . '
    '; } // http://doc.spip.org/@puce_changement_statut function puce_changement_statut($id_objet, $statut, $id_rubrique, $type, $ajax=false){ $puce_statut = charger_fonction('puce_statut','inc'); return $puce_statut($id_objet, $statut, $id_rubrique, $type, $ajax=false); } // Encoder un contexte pour l'ajax, le signer avec une cle, le crypter // avec le secret du site, le gziper si possible... // l'entree peut etre serialisee (le #ENV** des fonds ajax et ajax_stat) // http://doc.spip.org/@encoder_contexte_ajax function encoder_contexte_ajax($c,$form='', $emboite=NULL) { if (is_string($c) AND !is_null(@unserialize($c))) $c = unserialize($c); // supprimer les parametres debut_x // pour que la pagination ajax ne soit pas plantee // si on charge la page &debut_x=1 : car alors en cliquant sur l'item 0, // le debut_x=0 n'existe pas, et on resterait sur 1 foreach ($c as $k => $v) if (strpos($k,'debut_') === 0) unset($c[$k]); include_spip("inc/securiser_action"); $cle = calculer_cle_action($form.(is_array($c)?serialize($c):$c)); $c = serialize(array($c,$cle)); if (function_exists('gzdeflate') && function_exists('gzinflate')) $c = gzdeflate($c); $c = _xor($c); $c = base64_encode($c); if ($emboite === NULL) return $c; return !trim($emboite) ? '' : "
    \n$emboite
    \n"; } // la procedure inverse de encoder_contexte_ajax() // http://doc.spip.org/@decoder_contexte_ajax function decoder_contexte_ajax($c,$form='') { include_spip("inc/securiser_action"); $c = @base64_decode($c); $c = _xor($c); if (function_exists('gzdeflate') && function_exists('gzinflate')) $c = @gzinflate($c); list($env, $cle) = @unserialize($c); if ($cle == calculer_cle_action($form.(is_array($env)?serialize($env):$env))) return $env; return false; } // encrypter/decrypter un message // http://www.php.net/manual/fr/language.operators.bitwise.php#81358 // http://doc.spip.org/@_xor function _xor($message, $key=null){ if (is_null($key)) { include_spip("inc/securiser_action"); $key = pack("H*", calculer_cle_action('_xor')); } $keylen = strlen($key); $messagelen = strlen($message); for($i=0; $i<$messagelen; $i++) $message[$i] = ~($message[$i]^$key[$i%$keylen]); return $message; } /** * filtre explode pour les squelettes permettant d'ecrire * #GET{truc}|explode{-} * * @param strong $a * @param string $b * @return array */ function filtre_explode_dist($a,$b){return explode($b,$a);} /** * filtre implode pour les squelettes permettant d'ecrire * #GET{truc}|implode{-} * * @param array $a * @param string $b * @return string */ function filtre_implode_dist($a,$b){return implode($b,$a);} /* * Deux verrues pour que le pipeline de revisions soit correct * elles vont sauter quand ca passera en plugin */ function premiere_revision($x) { include_spip('inc/revisions'); return enregistrer_premiere_revision($x); } function nouvelle_revision($x) { include_spip('inc/revisions'); return enregistrer_nouvelle_revision($x); } ?> spip/spip/ecrire/inc/diff.php0000766000000000000000000002471711236524730017355 0ustar adminadministrators $c) { for ($len = $max_len; $len > 0; $len--) { if ($paths_ymin[$len] < $y) { $paths_ymin[$len + 1] = $y; $paths[$len + 1] = $paths[$len]; $paths[$len + 1][$y] = $c; break; } } if ($len == 0) { $paths_ymin[1] = $y; $paths[1] = array($y => $c); } if ($len + 1 > $max_len) $max_len = $len + 1; } return $paths[$max_len]; } // Version normale : les deux chaines n'ont pas ete traitees au prealable // par la fonction d'appariement // http://doc.spip.org/@lcs function lcs($s, $t) { $n = count($s); $p = count($t); if (!$n || !$p) return array(0 => array(), 1 => array()); $paths = array(); $paths_ymin = array(); $max_len = 0; $s_pos = $t_pos = array(); // Insertion des points foreach ($t as $y => $c) $t_pos[trim($c)][] = $y; foreach ($s as $x => $c) { $c = trim($c); if (!isset($t_pos[$c])) continue; krsort($t_pos[$c]); foreach ($t_pos[$c] as $y) { for ($len = $max_len; $len > 0; $len--) { if ($paths_ymin[$len] < $y) { $paths_ymin[$len + 1] = $y; // On construit le resultat sous forme de chaine d'abord, // car les tableaux de PHP sont dispendieux en taille memoire $paths[$len + 1] = $paths[$len]." $x,$y"; break; } } if ($len + 1 > $max_len) $max_len = $len + 1; if ($len == 0) { $paths_ymin[1] = $y; $paths[1] = "$x,$y"; } } } if ($paths[$max_len]) { $path = explode(" ", $paths[$max_len]); $u = $v = array(); foreach ($path as $p) { list($x, $y) = explode(",", $p); $u[$x] = $y; $v[$y] = $x; } return array($u, $v); } return array(0 => array(), 1 => array()); } // // Generation de diff a plusieurs etages // // http://doc.spip.org/@Diff class Diff { var $diff; var $fuzzy; // http://doc.spip.org/@Diff function Diff($diff) { $this->diff = $diff; $this->fuzzy = true; } // http://doc.spip.org/@comparer function comparer($new, $old) { $paras = $this->diff->segmenter($new); $paras_old = $this->diff->segmenter($old); if ($this->diff->fuzzy()) { list($trans_rev, $trans) = apparier_paras($paras_old, $paras); $lcs = lcs_opt($trans); $lcs_rev = array_flip($lcs); } else { list($trans_rev, $trans) = lcs($paras_old, $paras); $lcs = $trans; $lcs_rev = $trans_rev; } reset($paras_old); reset($paras); reset($lcs); unset($i_old); $fin_old = false; foreach ($paras as $i => $p) { if (!isset($trans[$i])) { // Paragraphe ajoute $this->diff->ajouter($p); continue; } $j = $trans[$i]; if (!isset($lcs[$i])) { // Paragraphe deplace $this->diff->deplacer($p, $paras_old[$j]); continue; } if (!$fin_old) { // Paragraphes supprimes jusqu'au paragraphe courant if (!isset($i_old)) { list($i_old, $p_old) = each($paras_old); if (!$p_old) $fin_old = true; } while (!$fin_old && $i_old < $j) { if (!isset($trans_rev[$i_old])) { $this->diff->supprimer($p_old); } unset($i_old); list($i_old, $p_old) = each($paras_old); if (!$p_old) $fin_old = true; } } // Paragraphe n'ayant pas change de place $this->diff->comparer($p, $paras_old[$j]); } // Paragraphes supprimes a la fin du texte if (!$fin_old) { if (!isset($i_old)) { list($i_old, $p_old) = each($paras_old); if (!strlen($p_old)) $fin_old = true; } while (!$fin_old) { if (!isset($trans_rev[$i_old])) { $this->diff->supprimer($p_old); } list($i_old, $p_old) = each($paras_old); if (!$p_old) $fin_old = true; } } if (isset($i_old)) { if (!isset($trans_rev[$i_old])) { $this->diff->supprimer($p_old); } } return $this->diff->resultat(); } } // http://doc.spip.org/@DiffTexte class DiffTexte { var $r; // http://doc.spip.org/@DiffTexte function DiffTexte() { $this->r = ""; } // http://doc.spip.org/@_diff function _diff($p, $p_old) { $diff = new Diff(new DiffPara); return $diff->comparer($p, $p_old); } // http://doc.spip.org/@fuzzy function fuzzy() { return true; } // http://doc.spip.org/@segmenter function segmenter($texte) { return separer_paras($texte); } // NB : rem=\"diff-\" est un signal pour la fonction "afficher_para_modifies" // http://doc.spip.org/@ajouter function ajouter($p) { $p = trim($p); $this->r .= "\n\n\n
    ".$p."
    "; } // http://doc.spip.org/@supprimer function supprimer($p_old) { $p_old = trim($p_old); $this->r .= "\n\n\n
    ".$p_old."
    "; } // http://doc.spip.org/@deplacer function deplacer($p, $p_old) { $this->r .= "\n\n\n
    "; $this->r .= trim($this->_diff($p, $p_old)); $this->r .= "
    "; } // http://doc.spip.org/@comparer function comparer($p, $p_old) { $this->r .= "\n\n\n".$this->_diff($p, $p_old); } // http://doc.spip.org/@resultat function resultat() { return $this->r; } } // http://doc.spip.org/@DiffPara class DiffPara { var $r; // http://doc.spip.org/@DiffPara function DiffPara() { $this->r = ""; } // http://doc.spip.org/@_diff function _diff($p, $p_old) { $diff = new Diff(new DiffPhrase); return $diff->comparer($p, $p_old); } // http://doc.spip.org/@fuzzy function fuzzy() { return true; } // http://doc.spip.org/@segmenter function segmenter($texte) { $paras = array(); $texte = trim($texte); while (preg_match('/[\.!\?\]]+\s*/u', $texte, $regs)) { $p = strpos($texte, $regs[0]) + strlen($regs[0]); $paras[] = substr($texte, 0, $p); $texte = substr($texte, $p); } if ($texte) $paras[] = $texte; return $paras; } // http://doc.spip.org/@ajouter function ajouter($p) { $this->r .= "".$p.""; } // http://doc.spip.org/@supprimer function supprimer($p_old) { $this->r .= "".$p_old.""; } // http://doc.spip.org/@deplacer function deplacer($p, $p_old) { $this->r .= "".$this->_diff($p, $p_old).""; } // http://doc.spip.org/@comparer function comparer($p, $p_old) { $this->r .= $this->_diff($p, $p_old); } // http://doc.spip.org/@resultat function resultat() { return $this->r; } } // http://doc.spip.org/@DiffPhrase class DiffPhrase { var $r; // http://doc.spip.org/@DiffPhrase function DiffPhrase() { $this->r = ""; } // http://doc.spip.org/@fuzzy function fuzzy() { return false; } // http://doc.spip.org/@segmenter function segmenter($texte) { $paras = array(); if (test_pcre_unicode()) { $punct = '([[:punct:]]|'.plage_punct_unicode().')'; $mode = 'u'; } else { // Plages de poncutation pour preg_match bugge (ha ha) $punct = '([^\w\s\x80-\xFF]|'.plage_punct_unicode().')'; $mode = ''; } $preg = '/('.$punct.'+)(\s+|$)|(\s+)('.$punct.'*)/'.$mode; while (preg_match($preg, $texte, $regs)) { $p = strpos($texte, $regs[0]); $l = strlen($regs[0]); $punct = $regs[1] ? $regs[1] : $regs[6]; $milieu = ""; if ($punct) { // notes if ($punct == '[[') { $avant = substr($texte, 0, $p) . $regs[5] . $punct; $texte = $regs[4] . substr($texte, $p + $l); } else if ($punct == ']]') { $avant = substr($texte, 0, $p) . $regs[5] . $punct; $texte = substr($texte, $p + $l); } // Attacher les raccourcis fermants au mot precedent else if (preg_match(',^[\]}]+$,', $punct)) { $avant = substr($texte, 0, $p) . $regs[5] . $punct; $texte = $regs[4] . substr($texte, $p + $l); } // Attacher les raccourcis ouvrants au mot suivant else if ($regs[5] && preg_match(',^[\[{]+$,', $punct)) { $avant = substr($texte, 0, $p) . $regs[5]; $texte = $punct . substr($texte, $p + $l); } // Les autres signes de ponctuation sont des mots a part entiere else { $avant = substr($texte, 0, $p); $milieu = $regs[0]; $texte = substr($texte, $p + $l); } } else { $avant = substr($texte, 0, $p + $l); $texte = substr($texte, $p + $l); } if ($avant) $paras[] = $avant; if ($milieu) $paras[] = $milieu; } if ($texte) $paras[] = $texte; return $paras; } // http://doc.spip.org/@ajouter function ajouter($p) { $this->r .= "".$p." "; } // http://doc.spip.org/@supprimer function supprimer($p_old) { $this->r .= "".$p_old." "; } // http://doc.spip.org/@comparer function comparer($p, $p_old) { $this->r .= $p; } // http://doc.spip.org/@resultat function resultat() { return $this->r; } } // http://doc.spip.org/@preparer_diff function preparer_diff($texte) { include_spip('inc/charsets'); $charset = $GLOBALS['meta']['charset']; if ($charset == 'utf-8') return unicode_to_utf_8(html2unicode($texte)); return unicode_to_utf_8(html2unicode(charset2unicode($texte, $charset, true))); } // http://doc.spip.org/@afficher_diff function afficher_diff($texte) { $charset = $GLOBALS['meta']['charset']; if ($charset == 'utf-8') return $texte; return charset2unicode($texte, 'utf-8'); } ?> spip/spip/ecrire/inc/instituer_site.php0000766000000000000000000000347411236524730021514 0ustar adminadministrators array(titre,image) 'prop' => array(_T('info_statut_site_3'),''), 'publie' => array(_T('info_statut_site_2'),''), 'refuse' => array(_T('info_statut_site_4'),'') ); if (!in_array($statut, array_keys($liste_statuts))) $liste_statuts[$statut] = array($statut,''); $res = "
      " . "
    • " . _T('info_statut_site_1') ."
        "; $href = redirige_action_auteur('editer_site',$id_syndic,'sites', "id_syndic=$id_syndic" /*"&id_parent=$id_rubrique"*/); foreach($liste_statuts as $s=>$affiche){ $href = parametre_url($href,'statut',$s); if ($s==$statut) $res .= "
      • " . puce_statut($s) . $affiche[0] . '
      • '; else $res .= "
      • " . puce_statut($s) . $affiche[0] . '
      • '; } $res .= "
    "; return $res; } ?> spip/spip/ecrire/inc/headers.php0000766000000000000000000001357111236524730020054 0ustar adminadministrators"; } include_spip('inc/lang'); if ($status!=302) http_status($status); echo '',"\n", html_lang_attributes(),' ', $equiv,' HTTP '.$status.'

    HTTP '.$status.'

    ', _T('navigateur_pas_redirige'), ''; spip_log("redirige $status: $url"); exit; } // http://doc.spip.org/@redirige_formulaire function redirige_formulaire($url, $equiv = '', $format='message') { if (!_AJAX AND !headers_sent() AND !_request('var_ajax')) { redirige_par_entete(str_replace('&','&',$url), $equiv); } // si c'est une ancre, fixer simplement le window.location.hash elseif($format=='ajaxform' AND preg_match(',^#[0-9a-z\-_]+$,i',$url)) { return array( // on renvoie un lien masque qui sera traite par ajaxCallback.js "anchor", // et rien dans le message ok ''); } else { // ne pas laisser passer n'importe quoi dans l'url $url = str_replace(array('<','"'),array('<','"'),$url); $url = strtr($url, "\n\r", " "); # en theorie on devrait faire ca tout le temps, mais quand la chaine # commence par ? c'est imperatif, sinon l'url finale n'est pas la bonne if ($url[0]=='?') $url = url_de_base().$url; $url = str_replace('&','&',$url); spip_log("redirige formulaire ajax: $url"); include_spip('inc/filtres'); if ($format=='ajaxform') return array( // on renvoie un lien masque qui sera traite par ajaxCallback.js ''._T('navigateur_pas_redirige').'', // et un message au cas ou '
    '._T('navigateur_pas_redirige').'' ); else // format message texte, tout en js inline return // ie poste les formulaires dans une iframe, il faut donc rediriger son parent "" . http_img_pack('searching.gif','') . '
    ' . ''._T('navigateur_pas_redirige').''; } } // http://doc.spip.org/@redirige_url_ecrire function redirige_url_ecrire($script='', $args='', $equiv='') { return redirige_par_entete(generer_url_ecrire($script, $args, true), $equiv); } // http://doc.spip.org/@http_status function http_status($status) { global $REDIRECT_STATUS, $flag_sapi_name; static $status_string = array( 200 => '200 OK', 204 => '204 No Content', 301 => '301 Moved Permanently', 302 => '302 Found', 304 => '304 Not Modified', 401 => '401 Unauthorized', 403 => '403 Forbidden', 404 => '404 Not Found' ); if ($REDIRECT_STATUS && $REDIRECT_STATUS == $status) return; $php_cgi = ($flag_sapi_name AND preg_match(",cgi,i", @php_sapi_name())); if ($php_cgi) header("Status: ".$status_string[$status]); else header("HTTP/1.0 ".$status_string[$status]); } // Retourne ce qui va bien pour que le navigateur ne mette pas la page en cache // http://doc.spip.org/@http_no_cache function http_no_cache() { if (headers_sent()) { spip_log("http_no_cache arrive trop tard"); return;} $charset = empty($GLOBALS['meta']['charset']) ? 'utf-8' : $GLOBALS['meta']['charset']; // selon http://developer.apple.com/internet/safari/faq.html#anchor5 // il faudrait aussi pour Safari // header("Cache-Control: post-check=0, pre-check=0", false) // mais ca ne respecte pas // http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html#sec14.9 header("Content-Type: text/html; charset=$charset"); header("Expires: 0"); header("Last-Modified: " .gmdate("D, d M Y H:i:s"). " GMT"); header("Cache-Control: no-store, no-cache, must-revalidate"); header("Pragma: no-cache"); } ?> spip/spip/ecrire/inc/referenceurs.php0000766000000000000000000001754511236524730021136 0ustar adminadministrators 18) $tmp = "/".substr($tmp, 0, 15)."..."; else if (strlen($tmp) > 0) $tmp = "/$tmp"; } if ($tmp) { $lesreferers[$numero][] = "".quote_amp(urldecode($tmp))."" . (($visites > 1)?" ($visites)":""). ($id_article ? '' : referes($referermd5)); } else $lesliensracine[$numero] += $visites; } } if (!count($nbvisites)) return array(); arsort($nbvisites); return referers_group($nbvisites, $id_article, $lesliensracine, $lesreferermd5, $lesreferers, $lesurls); } function referers_group($nbvisites, $id_article, $lesliensracine, $lesreferermd5, $lesreferers, $lesurls) { global $spip_lang_right, $source_vignettes; $vign = ((strlen($source_vignettes) > 0) && $GLOBALS['meta']["activer_captures_referers"]!='non'); $aff = array(); foreach($nbvisites as $numero => $visites) { if (!$numero) next; $referermd5 = $lesreferermd5[$numero]; $bouton = $ret = ""; if ($vign) $ret = "\n"; if ($visites > 5) $bouton .= "$visites "._T('info_visites')." "; else if ($visites > 1) $bouton .= "$visites "._T('info_visites')." "; else $bouton .= "$visites "._T('info_visite')." "; if ($numero == "(email)") { $ret .= $bouton . "".$numero.""; } else { $n = count($lesreferers[$numero]); if (($n > 1) || ($n > 0 && substr(supprimer_tags($lesreferers[$numero][0]),0,1) != '/')) { $rac = $lesliensracine[$numero]; $bouton .= "".$numero."" . (!$rac ? '': (" (" . $rac .")")); $ret .= bouton_block_depliable($bouton,false) . debut_block_depliable(false) . "\n
    • " . join ("
    • ",$lesreferers[$numero]) . "
    " . fin_block(); } else { $ret .= $bouton; $lien = $n ? $lesreferers[$numero][0] : ''; if (preg_match(",^(]+>)([^ ]*)( \([0-9]+\))?,i", $lien, $regs)) { $lien = quote_amp($regs[1]).$numero.$regs[2]; if (!strpos($lien, '')) $lien .= ''; } else $lien = "".$numero.""; $ret .= "".quote_amp($lien)."" . ($id_article ? '' : referes($referermd5)); } } $aff[]= $ret; } return $aff; } // Les deux fonctions suivantes sont adaptees du code des "Visiteurs", // par Jean-Paul Dezelus (http://www.phpinfo.net/applis/visiteurs/) // http://doc.spip.org/@stats_load_engines function stats_load_engines() { $arr_engines = Array(); lire_fichier(find_in_path('engines-list.txt'), $moteurs); foreach (array_filter(preg_split("/([\r\n]|#.*)+/", $moteurs)) as $ligne) { $ligne = trim($ligne); if (preg_match(',^\[([^][]*)\]$,S', $ligne, $regs)) { $moteur = $regs[1]; $query = ''; } else if (preg_match(',=$,', $ligne, $regs)) $query = $ligne; else $arr_engines[] = array($moteur,$query,$ligne); } return $arr_engines; } // http://doc.spip.org/@stats_show_keywords function stats_show_keywords($kw_referer, $kw_referer_host) { static $arr_engines = ''; static $url_site; if (!is_array($arr_engines)) { // Charger les moteurs de recherche $arr_engines = stats_load_engines(); // initialiser la recherche interne $url_site = $GLOBALS['meta']['adresse_site']; $url_site = preg_replace(",^((https?|ftp):?/?/?)?(www\.)?,", "", strtolower($url_site)); } if ($url = @parse_url( $kw_referer )) { $query = isset($url['query'])?$url['query']:""; $host = strtolower($url['host']); $path = $url['path']; } else $query = $host = $path =''; // Cette fonction affecte directement les variables selon la query-string ! parse_str($query); $keywords = ''; $found = false; if (!empty($url_site)) { if (strpos('-'.$kw_referer, $url_site)!==false) { if (preg_match(",(s|search|r|recherche)=([^&]+),i", $kw_referer, $regs)) $keywords = urldecode($regs[2]); else return array('host' => ''); } else for ($cnt = 0; $cnt < sizeof($arr_engines) && !$found; $cnt++) { if ( $found = preg_match(','.$arr_engines[$cnt][2].',', $host) OR $found = preg_match(','.$arr_engines[$cnt][2].',', $path)) { $kw_referer_host = $arr_engines[$cnt][0]; if (strpos($arr_engines[$cnt][1],'=')!==false) { // Fonctionnement simple: la variable existe $v = str_replace('=', '', $arr_engines[$cnt][1]); $keywords = isset($$v)?$$v:""; // Si on a defini le nom de la variable en expression reguliere, chercher la bonne variable if (! strlen($keywords) > 0) { if (preg_match(",".$arr_engines[$cnt][1]."([^\&]*),", $query, $vals)) { $keywords = urldecode($vals[2]); } } } else { $keywords = ""; } if (( ($kw_referer_host == "Google") || ($kw_referer_host == "AOL" && strpos($query,'enc=iso')===false) || ($kw_referer_host == "MSN") )) { include_spip('inc/charsets'); if (!isset($ie) OR !$cset = $ie) $cset = 'utf-8'; $keywords = importer_charset($keywords,$cset); } $buffer["hostname"] = $kw_referer_host; } } } $buffer["host"] = $host; if (!isset($buffer["hostname"]) OR !$buffer["hostname"]) $buffer["hostname"] = $host; $buffer["path"] = substr($path, 1, strlen($path)); $buffer["query"] = $query; if ($keywords != '') { if (strlen($keywords) > 150) { $keywords = spip_substr($keywords, 0, 148); // supprimer l'eventuelle entite finale mal coupee $keywords = preg_replace('/&#?[a-z0-9]*$/', '', $keywords); } $buffer["keywords"] = trim(entites_html(urldecode(stripslashes($keywords)))); } return $buffer; } // // Recherche des articles pointes par le referer // // http://doc.spip.org/@referes function referes($referermd5, $serveur='') { $retarts = sql_allfetsel('J2.id_article, J2.titre', 'spip_referers_articles AS J1 LEFT JOIN spip_articles AS J2 ON J1.id_article = J2.id_article', "(referer_md5='$referermd5' AND J1.maj>=DATE_SUB(".sql_quote(date('Y-m-d H:i:s')).", INTERVAL 2 DAY))", '', "titre",'','',$serveur); foreach ($retarts as $k => $rowart) { $titre = typo($rowart['titre']); $url = generer_url_entite($rowart['id_article'], 'article'); $retarts[$k] = "$titre"; } if (count($retarts) > 1) return '
    → '.join(',
    → ',$retarts); if (count($retarts) == 1) return '
    → '. array_shift($retarts); return ''; } ?> spip/spip/ecrire/inc/safehtml.php0000766000000000000000000000343011236524730020235 0ustar adminadministratorsdeleteTags[] = 'param'; // sinon bug Firefox } if ($process) $test = 1; # ok else $test = -1; # se rabattre sur une fonction de securite basique } if ($test > 0) { # reset ($process->clear() ne vide que _xhtml...), # on doit pouvoir programmer ca plus propremement $process->_counter = array(); $process->_stack = array(); $process->_dcCounter = array(); $process->_dcStack = array(); $process->_listScope = 0; $process->_liStack = array(); # $process->parse(''); # cas particulier ? $process->clear(); $t = $process->parse($t); } else $t = entites_html($t); // tres laid, en cas d'erreur return $t; } ?> spip/spip/ecrire/inc/mail.php0000766000000000000000000000215511236524730017357 0ustar adminadministrators spip/spip/ecrire/inc/msiefix.php0000766000000000000000000000417011236524730020100 0ustar adminadministrators\n"; // Si jQuery n'est pas la on ne fixe pas les PNG // -> en fait, si: avec le compactage, jquery.js n'apparait plus if (strpos($texte, '.png') AND true /* ... autres tests si on veut affiner ... */ AND lire_fichier(_DIR_RACINE.'prive/javascript/jquery.ifixpng.js', $ifixpng) ) { $texte .= "\n"; } return $texte; } // http://doc.spip.org/@presentation_msiefix function presentation_msiefix() { lire_fichier(_DIR_RACINE.'prive/javascript/jquery.ifixpng.js', $ifixpng); return ""; } ?> spip/spip/ecrire/inc/acces.php0000766000000000000000000001675111236524730017522 0ustar adminadministrators $low_sec), "id_auteur = $id_auteur"); } } return $low_sec; } // Inclure les arguments significatifs pour le hachage // cas particulier du statut pour compatibilite ancien rss/suivi_revisions function param_low_sec($op, $args=array(), $lang='', $mime='rss') { $a = $b = ''; foreach ($args as $val => $var) if ($var) { if ($val<>'statut') $a .= ':' . $val.'-'.$var; $b .= $val.'='.$var . '&'; } $a = substr($a,1); $id = intval(@$GLOBALS['connect_id_auteur']); return $b . "op=" . $op . "&id=" . $id . "&cle=" . afficher_low_sec($id, "$mime $op $a") . (!$a ? '' : "&args=$a") . (!$lang ? '' : "&lang=$lang"); } // http://doc.spip.org/@afficher_low_sec function afficher_low_sec ($id_auteur, $action='') { return substr(md5($action.low_sec($id_auteur)),0,8); } // http://doc.spip.org/@verifier_low_sec function verifier_low_sec ($id_auteur, $cle, $action='') { return ($cle == afficher_low_sec($id_auteur, $action)); } // http://doc.spip.org/@effacer_low_sec function effacer_low_sec($id_auteur) { if (!$id_auteur = intval($id_auteur)) return; // jamais trop prudent ;) sql_updateq("spip_auteurs", array("low_sec" => ''), "id_auteur = $id_auteur"); } // http://doc.spip.org/@initialiser_sel function initialiser_sel() { global $htsalt; if (CRYPT_MD5) $htsalt = '$1$'.creer_pass_aleatoire(); else return ""; } // Cette fonction ne sert qu'a la connexion en mode http_auth.non LDAP // Son role est de creer le fichier htpasswd // Voir le plugin "acces restreint" // http://doc.spip.org/@ecrire_acces function ecrire_acces() { $htaccess = _DIR_RESTREINT . _ACCESS_FILE_NAME; $htpasswd = _DIR_TMP . _AUTH_USER_FILE; // Cette variable de configuration peut etre posee par un plugin // par exemple acces_restreint ; // si .htaccess existe, outrepasser spip_meta if (($GLOBALS['meta']['creer_htpasswd'] != 'oui') AND !@file_exists($htaccess)) { spip_unlink($htpasswd); spip_unlink($htpasswd."-admin"); return; } # remarque : ici on laisse passer les "nouveau" de maniere a leur permettre # de devenir redacteur le cas echeant (auth http)... a nettoyer // attention, il faut au prealable se connecter a la base (necessaire car utilise par install) if (spip_connect_ldap()) return; $p1 = ''; // login:htpass pour tous $p2 = ''; // login:htpass pour les admins $s = sql_select("login, htpass, statut", "spip_auteurs", sql_in("statut", array('1comite','0minirezo','nouveau'))); while ($t = sql_fetch($s)) { if (strlen($t['login']) AND strlen($t['htpass'])) { $p1 .= $t['login'].':'.$t['htpass']."\n"; if ($t['statut'] == '0minirezo') $p2 .= $t['login'].':'.$t['htpass']."\n"; } } if ($p1) { ecrire_fichier($htpasswd, $p1); ecrire_fichier($htpasswd.'-admin', $p2); spip_log("Ecriture de $htpasswd et $htpasswd-admin"); } } // http://doc.spip.org/@generer_htpass function generer_htpass($pass) { global $htsalt; if (function_exists('crypt')) return crypt($pass, $htsalt); } // // Verifier la presence des .htaccess // // http://doc.spip.org/@verifier_htaccess function verifier_htaccess($rep) { $htaccess = "$rep/" . _ACCESS_FILE_NAME; if ((!@file_exists($htaccess)) AND !defined('_ECRIRE_INSTALL') AND !defined('_TEST_DIRS')) { spip_log("demande de creation de $htaccess"); if ($_SERVER['SERVER_ADMIN'] != 'www@nexenservices.com'){ if (!$f = @fopen($htaccess, "w")) { spip_log("ECHEC DE LA CREATION DE $htaccess"); # ne pas traduire } else { fputs($f, "deny from all\n"); fclose($f); } } else { echo "IMPORTANT : "; echo "Votre hébergeur est Nexen Services.
    "; echo "La protection du répertoire $rep/ doit se faire par l'intermédiaire de "; echo "l'espace webmestres."; echo "Veuillez créer manuellement la protection pour ce répertoire (un couple login/mot de passe est nécessaire).
    "; } } } // http://doc.spip.org/@gerer_htaccess function gerer_htaccess() { // Cette variable de configuration peut etre posee par un plugin // par exemple acces_restreint $f = ($GLOBALS['meta']['creer_htaccess'] === 'oui'); $dirs = sql_allfetsel('extension', 'spip_types_documents'); $dirs[] = array('extension' => 'distant'); foreach($dirs as $e) { if (is_dir($dir = _DIR_IMG . $e['extension'])) { if ($f) verifier_htaccess($dir); else spip_unlink($dir . '/' . _ACCESS_FILE_NAME); } } return $GLOBALS['meta']['creer_htaccess']; } initialiser_sel(); ?> spip/spip/ecrire/inc/pclzip.php0000766000000000000000000074044311236524730017747 0ustar adminadministratorszipname = $p_zipname; $this->zip_fd = 0; $this->magic_quotes_status = -1; // ----- Return //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, 1); return; } // -------------------------------------------------------------------------------- // -------------------------------------------------------------------------------- // Function : // create($p_filelist, $p_add_dir="", $p_remove_dir="") // create($p_filelist, $p_option, $p_option_value, ...) // Description : // This method supports two different synopsis. The first one is historical. // This method creates a Zip Archive. The Zip file is created in the // filesystem. The files and directories indicated in $p_filelist // are added in the archive. See the parameters description for the // supported format of $p_filelist. // When a directory is in the list, the directory and its content is added // in the archive. // In this synopsis, the function takes an optional variable list of // options. See bellow the supported options. // Parameters : // $p_filelist : An array containing file or directory names, or // a string containing one filename or one directory name, or // a string containing a list of filenames and/or directory // names separated by spaces. // $p_add_dir : A path to add before the real path of the archived file, // in order to have it memorized in the archive. // $p_remove_dir : A path to remove from the real path of the file to archive, // in order to have a shorter path memorized in the archive. // When $p_add_dir and $p_remove_dir are set, $p_remove_dir // is removed first, before $p_add_dir is added. // Options : // PCLZIP_OPT_ADD_PATH : // PCLZIP_OPT_REMOVE_PATH : // PCLZIP_OPT_REMOVE_ALL_PATH : // PCLZIP_OPT_COMMENT : // PCLZIP_CB_PRE_ADD : // PCLZIP_CB_POST_ADD : // Return Values : // 0 on failure, // The list of the added files, with a status of the add action. // (see PclZip::listContent() for list entry format) // -------------------------------------------------------------------------------- // http://doc.spip.org/@create function create($p_filelist) { //--(MAGIC-PclTrace)--//PclTraceFctStart(__FILE__, __LINE__, 'PclZip::create', "filelist='$p_filelist', ..."); $v_result=1; // ----- Reset the error handler $this->privErrorReset(); // ----- Set default values $v_options = array(); $v_options[PCLZIP_OPT_NO_COMPRESSION] = FALSE; // ----- Look for variable options arguments $v_size = func_num_args(); //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 4, "$v_size arguments passed to the method"); // ----- Look for arguments if ($v_size > 1) { // ----- Get the arguments $v_arg_list = func_get_args(); // ----- Remove from the options list the first argument array_shift($v_arg_list); $v_size--; // ----- Look for first arg if ((is_integer($v_arg_list[0])) && ($v_arg_list[0] > 77000)) { //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Variable list of options detected"); // ----- Parse the options $v_result = $this->privParseOptions($v_arg_list, $v_size, $v_options, array (PCLZIP_OPT_REMOVE_PATH => 'optional', PCLZIP_OPT_REMOVE_ALL_PATH => 'optional', PCLZIP_OPT_ADD_PATH => 'optional', PCLZIP_CB_PRE_ADD => 'optional', PCLZIP_CB_POST_ADD => 'optional', PCLZIP_OPT_NO_COMPRESSION => 'optional', PCLZIP_OPT_COMMENT => 'optional' //, PCLZIP_OPT_CRYPT => 'optional' )); if ($v_result != 1) { //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, 0); return 0; } } // ----- Look for 2 args // Here we need to support the first historic synopsis of the // method. else { //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Static synopsis"); // ----- Get the first argument $v_options[PCLZIP_OPT_ADD_PATH] = $v_arg_list[0]; // ----- Look for the optional second argument if ($v_size == 2) { $v_options[PCLZIP_OPT_REMOVE_PATH] = $v_arg_list[1]; } else if ($v_size > 2) { PclZip::privErrorLog(PCLZIP_ERR_INVALID_PARAMETER, "Invalid number / type of arguments"); //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, PclZip::errorCode(), PclZip::errorInfo()); return 0; } } } // ----- Init $v_string_list = array(); $v_att_list = array(); $v_filedescr_list = array(); $p_result_list = array(); // ----- Look if the $p_filelist is really an array if (is_array($p_filelist)) { // ----- Look if the first element is also an array // This will mean that this is a file description entry if (isset($p_filelist[0]) && is_array($p_filelist[0])) { $v_att_list = $p_filelist; } // ----- The list is a list of string names else { $v_string_list = $p_filelist; } } // ----- Look if the $p_filelist is a string else if (is_string($p_filelist)) { // ----- Create a list from the string $v_string_list = explode(PCLZIP_SEPARATOR, $p_filelist); } // ----- Invalid variable type for $p_filelist else { PclZip::privErrorLog(PCLZIP_ERR_INVALID_PARAMETER, "Invalid variable type p_filelist"); //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, 0); return 0; } // ----- Reformat the string list if (sizeof($v_string_list) != 0) { foreach ($v_string_list as $v_string) { if ($v_string != '') { $v_att_list[][PCLZIP_ATT_FILE_NAME] = $v_string; } else { //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Ignore an empty filename"); } } } // ----- For each file in the list check the attributes $v_supported_attributes = array ( PCLZIP_ATT_FILE_NAME => 'mandatory' ,PCLZIP_ATT_FILE_NEW_SHORT_NAME => 'optional' ,PCLZIP_ATT_FILE_NEW_FULL_NAME => 'optional' ); foreach ($v_att_list as $v_entry) { $v_result = $this->privFileDescrParseAtt($v_entry, $v_filedescr_list[], $v_options, $v_supported_attributes); if ($v_result != 1) { //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, 0); return 0; } } // ----- Expand the filelist (expand directories) $v_result = $this->privFileDescrExpand($v_filedescr_list, $v_options); if ($v_result != 1) { //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, 0); return 0; } // ----- Call the create fct $v_result = $this->privCreate($v_filedescr_list, $p_result_list, $v_options); if ($v_result != 1) { //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, 0); return 0; } // ----- Return //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $p_result_list); return $p_result_list; } // -------------------------------------------------------------------------------- // -------------------------------------------------------------------------------- // Function : // add($p_filelist, $p_add_dir="", $p_remove_dir="") // add($p_filelist, $p_option, $p_option_value, ...) // Description : // This method supports two synopsis. The first one is historical. // This methods add the list of files in an existing archive. // If a file with the same name already exists, it is added at the end of the // archive, the first one is still present. // If the archive does not exist, it is created. // Parameters : // $p_filelist : An array containing file or directory names, or // a string containing one filename or one directory name, or // a string containing a list of filenames and/or directory // names separated by spaces. // $p_add_dir : A path to add before the real path of the archived file, // in order to have it memorized in the archive. // $p_remove_dir : A path to remove from the real path of the file to archive, // in order to have a shorter path memorized in the archive. // When $p_add_dir and $p_remove_dir are set, $p_remove_dir // is removed first, before $p_add_dir is added. // Options : // PCLZIP_OPT_ADD_PATH : // PCLZIP_OPT_REMOVE_PATH : // PCLZIP_OPT_REMOVE_ALL_PATH : // PCLZIP_OPT_COMMENT : // PCLZIP_OPT_ADD_COMMENT : // PCLZIP_OPT_PREPEND_COMMENT : // PCLZIP_CB_PRE_ADD : // PCLZIP_CB_POST_ADD : // Return Values : // 0 on failure, // The list of the added files, with a status of the add action. // (see PclZip::listContent() for list entry format) // -------------------------------------------------------------------------------- // http://doc.spip.org/@add function add($p_filelist) { //--(MAGIC-PclTrace)--//PclTraceFctStart(__FILE__, __LINE__, 'PclZip::add', "filelist='$p_filelist', ..."); $v_result=1; // ----- Reset the error handler $this->privErrorReset(); // ----- Set default values $v_options = array(); $v_options[PCLZIP_OPT_NO_COMPRESSION] = FALSE; // ----- Look for variable options arguments $v_size = func_num_args(); //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 4, "$v_size arguments passed to the method"); // ----- Look for arguments if ($v_size > 1) { // ----- Get the arguments $v_arg_list = func_get_args(); // ----- Remove form the options list the first argument array_shift($v_arg_list); $v_size--; // ----- Look for first arg if ((is_integer($v_arg_list[0])) && ($v_arg_list[0] > 77000)) { //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Variable list of options detected"); // ----- Parse the options $v_result = $this->privParseOptions($v_arg_list, $v_size, $v_options, array (PCLZIP_OPT_REMOVE_PATH => 'optional', PCLZIP_OPT_REMOVE_ALL_PATH => 'optional', PCLZIP_OPT_ADD_PATH => 'optional', PCLZIP_CB_PRE_ADD => 'optional', PCLZIP_CB_POST_ADD => 'optional', PCLZIP_OPT_NO_COMPRESSION => 'optional', PCLZIP_OPT_COMMENT => 'optional', PCLZIP_OPT_ADD_COMMENT => 'optional', PCLZIP_OPT_PREPEND_COMMENT => 'optional' //, PCLZIP_OPT_CRYPT => 'optional' )); if ($v_result != 1) { //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, 0); return 0; } } // ----- Look for 2 args // Here we need to support the first historic synopsis of the // method. else { //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Static synopsis"); // ----- Get the first argument $v_options[PCLZIP_OPT_ADD_PATH] = $v_add_path = $v_arg_list[0]; // ----- Look for the optional second argument if ($v_size == 2) { $v_options[PCLZIP_OPT_REMOVE_PATH] = $v_arg_list[1]; } else if ($v_size > 2) { // ----- Error log PclZip::privErrorLog(PCLZIP_ERR_INVALID_PARAMETER, "Invalid number / type of arguments"); // ----- Return //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, PclZip::errorCode(), PclZip::errorInfo()); return 0; } } } // ----- Init $v_string_list = array(); $v_att_list = array(); $v_filedescr_list = array(); $p_result_list = array(); // ----- Look if the $p_filelist is really an array if (is_array($p_filelist)) { // ----- Look if the first element is also an array // This will mean that this is a file description entry if (isset($p_filelist[0]) && is_array($p_filelist[0])) { $v_att_list = $p_filelist; } // ----- The list is a list of string names else { $v_string_list = $p_filelist; } } // ----- Look if the $p_filelist is a string else if (is_string($p_filelist)) { // ----- Create a list from the string $v_string_list = explode(PCLZIP_SEPARATOR, $p_filelist); } // ----- Invalid variable type for $p_filelist else { PclZip::privErrorLog(PCLZIP_ERR_INVALID_PARAMETER, "Invalid variable type '".gettype($p_filelist)."' for p_filelist"); //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, 0); return 0; } // ----- Reformat the string list if (sizeof($v_string_list) != 0) { foreach ($v_string_list as $v_string) { $v_att_list[][PCLZIP_ATT_FILE_NAME] = $v_string; } } // ----- For each file in the list check the attributes $v_supported_attributes = array ( PCLZIP_ATT_FILE_NAME => 'mandatory' ,PCLZIP_ATT_FILE_NEW_SHORT_NAME => 'optional' ,PCLZIP_ATT_FILE_NEW_FULL_NAME => 'optional' ); foreach ($v_att_list as $v_entry) { $v_result = $this->privFileDescrParseAtt($v_entry, $v_filedescr_list[], $v_options, $v_supported_attributes); if ($v_result != 1) { //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, 0); return 0; } } // ----- Expand the filelist (expand directories) $v_result = $this->privFileDescrExpand($v_filedescr_list, $v_options); if ($v_result != 1) { //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, 0); return 0; } // ----- Call the create fct $v_result = $this->privAdd($v_filedescr_list, $p_result_list, $v_options); if ($v_result != 1) { //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, 0); return 0; } // ----- Return //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $p_result_list); return $p_result_list; } // -------------------------------------------------------------------------------- // -------------------------------------------------------------------------------- // Function : listContent() // Description : // This public method, gives the list of the files and directories, with their // properties. // The properties of each entries in the list are (used also in other functions) : // filename : Name of the file. For a create or add action it is the filename // given by the user. For an extract function it is the filename // of the extracted file. // stored_filename : Name of the file / directory stored in the archive. // size : Size of the stored file. // compressed_size : Size of the file's data compressed in the archive // (without the headers overhead) // mtime : Last known modification date of the file (UNIX timestamp) // comment : Comment associated with the file // folder : true | false // index : index of the file in the archive // status : status of the action (depending of the action) : // Values are : // ok : OK ! // filtered : the file / dir is not extracted (filtered by user) // already_a_directory : the file can not be extracted because a // directory with the same name already exists // write_protected : the file can not be extracted because a file // with the same name already exists and is // write protected // newer_exist : the file was not extracted because a newer file exists // path_creation_fail : the file is not extracted because the folder // does not exists and can not be created // write_error : the file was not extracted because there was a // error while writing the file // read_error : the file was not extracted because there was a error // while reading the file // invalid_header : the file was not extracted because of an archive // format error (bad file header) // Note that each time a method can continue operating when there // is an action error on a file, the error is only logged in the file status. // Return Values : // 0 on an unrecoverable failure, // The list of the files in the archive. // -------------------------------------------------------------------------------- // http://doc.spip.org/@listContent function listContent() { //--(MAGIC-PclTrace)--//PclTraceFctStart(__FILE__, __LINE__, 'PclZip::listContent', ""); $v_result=1; // ----- Reset the error handler $this->privErrorReset(); // ----- Check archive if (!$this->privCheckFormat()) { //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, 0); return(0); } // ----- Call the extracting fct $p_list = array(); if (($v_result = $this->privList($p_list)) != 1) { unset($p_list); //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, 0, PclZip::errorInfo()); return(0); } // ----- Return //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $p_list); return $p_list; } // -------------------------------------------------------------------------------- // -------------------------------------------------------------------------------- // Function : // extract($p_path="./", $p_remove_path="") // extract([$p_option, $p_option_value, ...]) // Description : // This method supports two synopsis. The first one is historical. // This method extract all the files / directories from the archive to the // folder indicated in $p_path. // If you want to ignore the 'root' part of path of the memorized files // you can indicate this in the optional $p_remove_path parameter. // By default, if a newer file with the same name already exists, the // file is not extracted. // // If both PCLZIP_OPT_PATH and PCLZIP_OPT_ADD_PATH aoptions // are used, the path indicated in PCLZIP_OPT_ADD_PATH is append // at the end of the path value of PCLZIP_OPT_PATH. // Parameters : // $p_path : Path where the files and directories are to be extracted // $p_remove_path : First part ('root' part) of the memorized path // (if any similar) to remove while extracting. // Options : // PCLZIP_OPT_PATH : // PCLZIP_OPT_ADD_PATH : // PCLZIP_OPT_REMOVE_PATH : // PCLZIP_OPT_REMOVE_ALL_PATH : // PCLZIP_CB_PRE_EXTRACT : // PCLZIP_CB_POST_EXTRACT : // Return Values : // 0 or a negative value on failure, // The list of the extracted files, with a status of the action. // (see PclZip::listContent() for list entry format) // -------------------------------------------------------------------------------- // http://doc.spip.org/@extract function extract() { //--(MAGIC-PclTrace)--//PclTraceFctStart(__FILE__, __LINE__, "PclZip::extract", ""); $v_result=1; // ----- Reset the error handler $this->privErrorReset(); // ----- Check archive if (!$this->privCheckFormat()) { //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, 0); return(0); } // ----- Set default values $v_options = array(); // $v_path = "./"; $v_path = ''; $v_remove_path = ""; $v_remove_all_path = false; // ----- Look for variable options arguments $v_size = func_num_args(); //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 4, "$v_size arguments passed to the method"); // ----- Default values for option $v_options[PCLZIP_OPT_EXTRACT_AS_STRING] = FALSE; // ----- Look for arguments if ($v_size > 0) { // ----- Get the arguments $v_arg_list = func_get_args(); // ----- Look for first arg if ((is_integer($v_arg_list[0])) && ($v_arg_list[0] > 77000)) { //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Variable list of options"); // ----- Parse the options $v_result = $this->privParseOptions($v_arg_list, $v_size, $v_options, array (PCLZIP_OPT_PATH => 'optional', PCLZIP_OPT_REMOVE_PATH => 'optional', PCLZIP_OPT_REMOVE_ALL_PATH => 'optional', PCLZIP_OPT_ADD_PATH => 'optional', PCLZIP_CB_PRE_EXTRACT => 'optional', PCLZIP_CB_POST_EXTRACT => 'optional', PCLZIP_OPT_SET_CHMOD => 'optional', PCLZIP_OPT_BY_NAME => 'optional', PCLZIP_OPT_BY_EREG => 'optional', PCLZIP_OPT_BY_PREG => 'optional', PCLZIP_OPT_BY_INDEX => 'optional', PCLZIP_OPT_EXTRACT_AS_STRING => 'optional', PCLZIP_OPT_EXTRACT_IN_OUTPUT => 'optional', PCLZIP_OPT_REPLACE_NEWER => 'optional' ,PCLZIP_OPT_STOP_ON_ERROR => 'optional' ,PCLZIP_OPT_EXTRACT_DIR_RESTRICTION => 'optional' )); if ($v_result != 1) { //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, 0); return 0; } // ----- Set the arguments if (isset($v_options[PCLZIP_OPT_PATH])) { $v_path = $v_options[PCLZIP_OPT_PATH]; } if (isset($v_options[PCLZIP_OPT_REMOVE_PATH])) { $v_remove_path = $v_options[PCLZIP_OPT_REMOVE_PATH]; } if (isset($v_options[PCLZIP_OPT_REMOVE_ALL_PATH])) { $v_remove_all_path = $v_options[PCLZIP_OPT_REMOVE_ALL_PATH]; } if (isset($v_options[PCLZIP_OPT_ADD_PATH])) { // ----- Check for '/' in last path char if ((strlen($v_path) > 0) && (substr($v_path, -1) != '/')) { $v_path .= '/'; } $v_path .= $v_options[PCLZIP_OPT_ADD_PATH]; } } // ----- Look for 2 args // Here we need to support the first historic synopsis of the // method. else { //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Static synopsis"); // ----- Get the first argument $v_path = $v_arg_list[0]; // ----- Look for the optional second argument if ($v_size == 2) { $v_remove_path = $v_arg_list[1]; } else if ($v_size > 2) { // ----- Error log PclZip::privErrorLog(PCLZIP_ERR_INVALID_PARAMETER, "Invalid number / type of arguments"); // ----- Return //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, 0, PclZip::errorInfo()); return 0; } } } // ----- Trace //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "path='$v_path', remove_path='$v_remove_path', remove_all_path='".($v_remove_path?'true':'false')."'"); // ----- Call the extracting fct $p_list = array(); $v_result = $this->privExtractByRule($p_list, $v_path, $v_remove_path, $v_remove_all_path, $v_options); if ($v_result < 1) { unset($p_list); //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, 0, PclZip::errorInfo()); return(0); } // ----- Return //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $p_list); return $p_list; } // -------------------------------------------------------------------------------- // -------------------------------------------------------------------------------- // Function : // extractByIndex($p_index, $p_path="./", $p_remove_path="") // extractByIndex($p_index, [$p_option, $p_option_value, ...]) // Description : // This method supports two synopsis. The first one is historical. // This method is doing a partial extract of the archive. // The extracted files or folders are identified by their index in the // archive (from 0 to n). // Note that if the index identify a folder, only the folder entry is // extracted, not all the files included in the archive. // Parameters : // $p_index : A single index (integer) or a string of indexes of files to // extract. The form of the string is "0,4-6,8-12" with only numbers // and '-' for range or ',' to separate ranges. No spaces or ';' // are allowed. // $p_path : Path where the files and directories are to be extracted // $p_remove_path : First part ('root' part) of the memorized path // (if any similar) to remove while extracting. // Options : // PCLZIP_OPT_PATH : // PCLZIP_OPT_ADD_PATH : // PCLZIP_OPT_REMOVE_PATH : // PCLZIP_OPT_REMOVE_ALL_PATH : // PCLZIP_OPT_EXTRACT_AS_STRING : The files are extracted as strings and // not as files. // The resulting content is in a new field 'content' in the file // structure. // This option must be used alone (any other options are ignored). // PCLZIP_CB_PRE_EXTRACT : // PCLZIP_CB_POST_EXTRACT : // Return Values : // 0 on failure, // The list of the extracted files, with a status of the action. // (see PclZip::listContent() for list entry format) // -------------------------------------------------------------------------------- //function extractByIndex($p_index, options...) // http://doc.spip.org/@extractByIndex function extractByIndex($p_index) { //--(MAGIC-PclTrace)--//PclTraceFctStart(__FILE__, __LINE__, "PclZip::extractByIndex", "index='$p_index', ..."); $v_result=1; // ----- Reset the error handler $this->privErrorReset(); // ----- Check archive if (!$this->privCheckFormat()) { //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, 0); return(0); } // ----- Set default values $v_options = array(); // $v_path = "./"; $v_path = ''; $v_remove_path = ""; $v_remove_all_path = false; // ----- Look for variable options arguments $v_size = func_num_args(); //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 4, "$v_size arguments passed to the method"); // ----- Default values for option $v_options[PCLZIP_OPT_EXTRACT_AS_STRING] = FALSE; // ----- Look for arguments if ($v_size > 1) { // ----- Get the arguments $v_arg_list = func_get_args(); // ----- Remove form the options list the first argument array_shift($v_arg_list); $v_size--; // ----- Look for first arg if ((is_integer($v_arg_list[0])) && ($v_arg_list[0] > 77000)) { //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Variable list of options"); // ----- Parse the options $v_result = $this->privParseOptions($v_arg_list, $v_size, $v_options, array (PCLZIP_OPT_PATH => 'optional', PCLZIP_OPT_REMOVE_PATH => 'optional', PCLZIP_OPT_REMOVE_ALL_PATH => 'optional', PCLZIP_OPT_EXTRACT_AS_STRING => 'optional', PCLZIP_OPT_ADD_PATH => 'optional', PCLZIP_CB_PRE_EXTRACT => 'optional', PCLZIP_CB_POST_EXTRACT => 'optional', PCLZIP_OPT_SET_CHMOD => 'optional', PCLZIP_OPT_REPLACE_NEWER => 'optional' ,PCLZIP_OPT_STOP_ON_ERROR => 'optional' ,PCLZIP_OPT_EXTRACT_DIR_RESTRICTION => 'optional' )); if ($v_result != 1) { //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, 0); return 0; } // ----- Set the arguments if (isset($v_options[PCLZIP_OPT_PATH])) { $v_path = $v_options[PCLZIP_OPT_PATH]; } if (isset($v_options[PCLZIP_OPT_REMOVE_PATH])) { $v_remove_path = $v_options[PCLZIP_OPT_REMOVE_PATH]; } if (isset($v_options[PCLZIP_OPT_REMOVE_ALL_PATH])) { $v_remove_all_path = $v_options[PCLZIP_OPT_REMOVE_ALL_PATH]; } if (isset($v_options[PCLZIP_OPT_ADD_PATH])) { // ----- Check for '/' in last path char if ((strlen($v_path) > 0) && (substr($v_path, -1) != '/')) { $v_path .= '/'; } $v_path .= $v_options[PCLZIP_OPT_ADD_PATH]; } if (!isset($v_options[PCLZIP_OPT_EXTRACT_AS_STRING])) { $v_options[PCLZIP_OPT_EXTRACT_AS_STRING] = FALSE; //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 4, "Option PCLZIP_OPT_EXTRACT_AS_STRING not set."); } else { //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 4, "Option PCLZIP_OPT_EXTRACT_AS_STRING set."); } } // ----- Look for 2 args // Here we need to support the first historic synopsis of the // method. else { //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Static synopsis"); // ----- Get the first argument $v_path = $v_arg_list[0]; // ----- Look for the optional second argument if ($v_size == 2) { $v_remove_path = $v_arg_list[1]; } else if ($v_size > 2) { // ----- Error log PclZip::privErrorLog(PCLZIP_ERR_INVALID_PARAMETER, "Invalid number / type of arguments"); // ----- Return //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, PclZip::errorCode(), PclZip::errorInfo()); return 0; } } } // ----- Trace //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "index='$p_index', path='$v_path', remove_path='$v_remove_path', remove_all_path='".($v_remove_path?'true':'false')."'"); // ----- Trick // Here I want to reuse extractByRule(), so I need to parse the $p_index // with privParseOptions() $v_arg_trick = array (PCLZIP_OPT_BY_INDEX, $p_index); $v_options_trick = array(); $v_result = $this->privParseOptions($v_arg_trick, sizeof($v_arg_trick), $v_options_trick, array (PCLZIP_OPT_BY_INDEX => 'optional' )); if ($v_result != 1) { //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, 0); return 0; } $v_options[PCLZIP_OPT_BY_INDEX] = $v_options_trick[PCLZIP_OPT_BY_INDEX]; // ----- Call the extracting fct if (($v_result = $this->privExtractByRule($p_list, $v_path, $v_remove_path, $v_remove_all_path, $v_options)) < 1) { //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, 0, PclZip::errorInfo()); return(0); } // ----- Return //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $p_list); return $p_list; } // -------------------------------------------------------------------------------- // -------------------------------------------------------------------------------- // Function : // delete([$p_option, $p_option_value, ...]) // Description : // This method removes files from the archive. // If no parameters are given, then all the archive is emptied. // Parameters : // None or optional arguments. // Options : // PCLZIP_OPT_BY_INDEX : // PCLZIP_OPT_BY_NAME : // PCLZIP_OPT_BY_EREG : // PCLZIP_OPT_BY_PREG : // Return Values : // 0 on failure, // The list of the files which are still present in the archive. // (see PclZip::listContent() for list entry format) // -------------------------------------------------------------------------------- // http://doc.spip.org/@delete function delete() { //--(MAGIC-PclTrace)--//PclTraceFctStart(__FILE__, __LINE__, "PclZip::delete", ""); $v_result=1; // ----- Reset the error handler $this->privErrorReset(); // ----- Check archive if (!$this->privCheckFormat()) { //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, 0); return(0); } // ----- Set default values $v_options = array(); // ----- Look for variable options arguments $v_size = func_num_args(); //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 4, "$v_size arguments passed to the method"); // ----- Look for arguments if ($v_size > 0) { // ----- Get the arguments $v_arg_list = func_get_args(); // ----- Parse the options $v_result = $this->privParseOptions($v_arg_list, $v_size, $v_options, array (PCLZIP_OPT_BY_NAME => 'optional', PCLZIP_OPT_BY_EREG => 'optional', PCLZIP_OPT_BY_PREG => 'optional', PCLZIP_OPT_BY_INDEX => 'optional' )); if ($v_result != 1) { //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, 0); return 0; } } // ----- Magic quotes trick $this->privDisableMagicQuotes(); // ----- Call the delete fct $v_list = array(); if (($v_result = $this->privDeleteByRule($v_list, $v_options)) != 1) { $this->privSwapBackMagicQuotes(); unset($v_list); //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, 0, PclZip::errorInfo()); return(0); } // ----- Magic quotes trick $this->privSwapBackMagicQuotes(); // ----- Return //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_list); return $v_list; } // -------------------------------------------------------------------------------- // -------------------------------------------------------------------------------- // Function : deleteByIndex() // Description : // ***** Deprecated ***** // delete(PCLZIP_OPT_BY_INDEX, $p_index) should be prefered. // -------------------------------------------------------------------------------- // http://doc.spip.org/@deleteByIndex function deleteByIndex($p_index) { //--(MAGIC-PclTrace)--//PclTraceFctStart(__FILE__, __LINE__, "PclZip::deleteByIndex", "index='$p_index'"); $p_list = $this->delete(PCLZIP_OPT_BY_INDEX, $p_index); // ----- Return //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $p_list); return $p_list; } // -------------------------------------------------------------------------------- // -------------------------------------------------------------------------------- // Function : properties() // Description : // This method gives the properties of the archive. // The properties are : // nb : Number of files in the archive // comment : Comment associated with the archive file // status : not_exist, ok // Parameters : // None // Return Values : // 0 on failure, // An array with the archive properties. // -------------------------------------------------------------------------------- // http://doc.spip.org/@properties function properties() { //--(MAGIC-PclTrace)--//PclTraceFctStart(__FILE__, __LINE__, "PclZip::properties", ""); // ----- Reset the error handler $this->privErrorReset(); // ----- Magic quotes trick $this->privDisableMagicQuotes(); // ----- Check archive if (!$this->privCheckFormat()) { $this->privSwapBackMagicQuotes(); //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, 0); return(0); } // ----- Default properties $v_prop = array(); $v_prop['comment'] = ''; $v_prop['nb'] = 0; $v_prop['status'] = 'not_exist'; // ----- Look if file exists if (@is_file($this->zipname)) { // ----- Open the zip file //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Open file in binary read mode"); if (($this->zip_fd = @fopen($this->zipname, 'rb')) == 0) { $this->privSwapBackMagicQuotes(); // ----- Error log PclZip::privErrorLog(PCLZIP_ERR_READ_OPEN_FAIL, 'Unable to open archive \''.$this->zipname.'\' in binary read mode'); // ----- Return //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, PclZip::errorCode(), 0); return 0; } // ----- Read the central directory informations $v_central_dir = array(); if (($v_result = $this->privReadEndCentralDir($v_central_dir)) != 1) { $this->privSwapBackMagicQuotes(); //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, 0); return 0; } // ----- Close the zip file $this->privCloseFd(); // ----- Set the user attributes $v_prop['comment'] = $v_central_dir['comment']; $v_prop['nb'] = $v_central_dir['entries']; $v_prop['status'] = 'ok'; } // ----- Magic quotes trick $this->privSwapBackMagicQuotes(); // ----- Return //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_prop); return $v_prop; } // -------------------------------------------------------------------------------- // -------------------------------------------------------------------------------- // Function : duplicate() // Description : // This method creates an archive by copying the content of an other one. If // the archive already exist, it is replaced by the new one without any warning. // Parameters : // $p_archive : The filename of a valid archive, or // a valid PclZip object. // Return Values : // 1 on success. // 0 or a negative value on error (error code). // -------------------------------------------------------------------------------- // http://doc.spip.org/@duplicate function duplicate($p_archive) { //--(MAGIC-PclTrace)--//PclTraceFctStart(__FILE__, __LINE__, "PclZip::duplicate", ""); $v_result = 1; // ----- Reset the error handler $this->privErrorReset(); // ----- Look if the $p_archive is a PclZip object if ((is_object($p_archive)) && (get_class($p_archive) == 'pclzip')) { //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "The parameter is valid PclZip object '".$p_archive->zipname."'"); // ----- Duplicate the archive $v_result = $this->privDuplicate($p_archive->zipname); } // ----- Look if the $p_archive is a string (so a filename) else if (is_string($p_archive)) { //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "The parameter is a filename '$p_archive'"); // ----- Check that $p_archive is a valid zip file // TBC : Should also check the archive format if (!is_file($p_archive)) { // ----- Error log PclZip::privErrorLog(PCLZIP_ERR_MISSING_FILE, "No file with filename '".$p_archive."'"); $v_result = PCLZIP_ERR_MISSING_FILE; } else { // ----- Duplicate the archive $v_result = $this->privDuplicate($p_archive); } } // ----- Invalid variable else { // ----- Error log PclZip::privErrorLog(PCLZIP_ERR_INVALID_PARAMETER, "Invalid variable type p_archive_to_add"); $v_result = PCLZIP_ERR_INVALID_PARAMETER; } // ----- Return //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result); return $v_result; } // -------------------------------------------------------------------------------- // -------------------------------------------------------------------------------- // Function : merge() // Description : // This method merge the $p_archive_to_add archive at the end of the current // one ($this). // If the archive ($this) does not exist, the merge becomes a duplicate. // If the $p_archive_to_add archive does not exist, the merge is a success. // Parameters : // $p_archive_to_add : It can be directly the filename of a valid zip archive, // or a PclZip object archive. // Return Values : // 1 on success, // 0 or negative values on error (see below). // -------------------------------------------------------------------------------- // http://doc.spip.org/@merge function merge($p_archive_to_add) { //--(MAGIC-PclTrace)--//PclTraceFctStart(__FILE__, __LINE__, "PclZip::merge", ""); $v_result = 1; // ----- Reset the error handler $this->privErrorReset(); // ----- Check archive if (!$this->privCheckFormat()) { //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, 0); return(0); } // ----- Look if the $p_archive_to_add is a PclZip object if ((is_object($p_archive_to_add)) && (get_class($p_archive_to_add) == 'pclzip')) { //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "The parameter is valid PclZip object"); // ----- Merge the archive $v_result = $this->privMerge($p_archive_to_add); } // ----- Look if the $p_archive_to_add is a string (so a filename) else if (is_string($p_archive_to_add)) { //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "The parameter is a filename"); // ----- Create a temporary archive $v_object_archive = new PclZip($p_archive_to_add); // ----- Merge the archive $v_result = $this->privMerge($v_object_archive); } // ----- Invalid variable else { // ----- Error log PclZip::privErrorLog(PCLZIP_ERR_INVALID_PARAMETER, "Invalid variable type p_archive_to_add"); $v_result = PCLZIP_ERR_INVALID_PARAMETER; } // ----- Return //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result); return $v_result; } // -------------------------------------------------------------------------------- // -------------------------------------------------------------------------------- // Function : errorCode() // Description : // Parameters : // -------------------------------------------------------------------------------- // http://doc.spip.org/@errorCode function errorCode() { if (PCLZIP_ERROR_EXTERNAL == 1) { return(PclErrorCode()); } else { return($this->error_code); } } // -------------------------------------------------------------------------------- // -------------------------------------------------------------------------------- // Function : errorName() // Description : // Parameters : // -------------------------------------------------------------------------------- // http://doc.spip.org/@errorName function errorName($p_with_code=false) { $v_name = array ( PCLZIP_ERR_NO_ERROR => 'PCLZIP_ERR_NO_ERROR', PCLZIP_ERR_WRITE_OPEN_FAIL => 'PCLZIP_ERR_WRITE_OPEN_FAIL', PCLZIP_ERR_READ_OPEN_FAIL => 'PCLZIP_ERR_READ_OPEN_FAIL', PCLZIP_ERR_INVALID_PARAMETER => 'PCLZIP_ERR_INVALID_PARAMETER', PCLZIP_ERR_MISSING_FILE => 'PCLZIP_ERR_MISSING_FILE', PCLZIP_ERR_FILENAME_TOO_LONG => 'PCLZIP_ERR_FILENAME_TOO_LONG', PCLZIP_ERR_INVALID_ZIP => 'PCLZIP_ERR_INVALID_ZIP', PCLZIP_ERR_BAD_EXTRACTED_FILE => 'PCLZIP_ERR_BAD_EXTRACTED_FILE', PCLZIP_ERR_DIR_CREATE_FAIL => 'PCLZIP_ERR_DIR_CREATE_FAIL', PCLZIP_ERR_BAD_EXTENSION => 'PCLZIP_ERR_BAD_EXTENSION', PCLZIP_ERR_BAD_FORMAT => 'PCLZIP_ERR_BAD_FORMAT', PCLZIP_ERR_DELETE_FILE_FAIL => 'PCLZIP_ERR_DELETE_FILE_FAIL', PCLZIP_ERR_RENAME_FILE_FAIL => 'PCLZIP_ERR_RENAME_FILE_FAIL', PCLZIP_ERR_BAD_CHECKSUM => 'PCLZIP_ERR_BAD_CHECKSUM', PCLZIP_ERR_INVALID_ARCHIVE_ZIP => 'PCLZIP_ERR_INVALID_ARCHIVE_ZIP', PCLZIP_ERR_MISSING_OPTION_VALUE => 'PCLZIP_ERR_MISSING_OPTION_VALUE', PCLZIP_ERR_INVALID_OPTION_VALUE => 'PCLZIP_ERR_INVALID_OPTION_VALUE', PCLZIP_ERR_UNSUPPORTED_COMPRESSION => 'PCLZIP_ERR_UNSUPPORTED_COMPRESSION', PCLZIP_ERR_UNSUPPORTED_ENCRYPTION => 'PCLZIP_ERR_UNSUPPORTED_ENCRYPTION' ,PCLZIP_ERR_INVALID_ATTRIBUTE_VALUE => 'PCLZIP_ERR_INVALID_ATTRIBUTE_VALUE' ,PCLZIP_ERR_DIRECTORY_RESTRICTION => 'PCLZIP_ERR_DIRECTORY_RESTRICTION' ); if (isset($v_name[$this->error_code])) { $v_value = $v_name[$this->error_code]; } else { $v_value = 'NoName'; } if ($p_with_code) { return($v_value.' ('.$this->error_code.')'); } else { return($v_value); } } // -------------------------------------------------------------------------------- // -------------------------------------------------------------------------------- // Function : errorInfo() // Description : // Parameters : // -------------------------------------------------------------------------------- // http://doc.spip.org/@errorInfo function errorInfo($p_full=false) { if (PCLZIP_ERROR_EXTERNAL == 1) { return(PclErrorString()); } else { if ($p_full) { return($this->errorName(true)." : ".$this->error_string); } else { return($this->error_string." [code ".$this->error_code."]"); } } } // -------------------------------------------------------------------------------- // -------------------------------------------------------------------------------- // ***** UNDER THIS LINE ARE DEFINED PRIVATE INTERNAL FUNCTIONS ***** // ***** ***** // ***** THESES FUNCTIONS MUST NOT BE USED DIRECTLY ***** // -------------------------------------------------------------------------------- // -------------------------------------------------------------------------------- // Function : privCheckFormat() // Description : // This method check that the archive exists and is a valid zip archive. // Several level of check exists. (futur) // Parameters : // $p_level : Level of check. Default 0. // 0 : Check the first bytes (magic codes) (default value)) // 1 : 0 + Check the central directory (futur) // 2 : 1 + Check each file header (futur) // Return Values : // true on success, // false on error, the error code is set. // -------------------------------------------------------------------------------- // http://doc.spip.org/@privCheckFormat function privCheckFormat($p_level=0) { //--(MAGIC-PclTrace)--//PclTraceFctStart(__FILE__, __LINE__, "PclZip::privCheckFormat", ""); $v_result = true; // ----- Reset the file system cache clearstatcache(); // ----- Reset the error handler $this->privErrorReset(); // ----- Look if the file exits if (!is_file($this->zipname)) { // ----- Error log PclZip::privErrorLog(PCLZIP_ERR_MISSING_FILE, "Missing archive file '".$this->zipname."'"); //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, false, PclZip::errorInfo()); return(false); } // ----- Check that the file is readeable if (!is_readable($this->zipname)) { // ----- Error log PclZip::privErrorLog(PCLZIP_ERR_READ_OPEN_FAIL, "Unable to read archive '".$this->zipname."'"); //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, false, PclZip::errorInfo()); return(false); } // ----- Check the magic code // TBC // ----- Check the central header // TBC // ----- Check each file header // TBC // ----- Return //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result); return $v_result; } // -------------------------------------------------------------------------------- // -------------------------------------------------------------------------------- // Function : privParseOptions() // Description : // This internal methods reads the variable list of arguments ($p_options_list, // $p_size) and generate an array with the options and values ($v_result_list). // $v_requested_options contains the options that can be present and those that // must be present. // $v_requested_options is an array, with the option value as key, and 'optional', // or 'mandatory' as value. // Parameters : // See above. // Return Values : // 1 on success. // 0 on failure. // -------------------------------------------------------------------------------- // http://doc.spip.org/@privParseOptions function privParseOptions(&$p_options_list, $p_size, &$v_result_list, $v_requested_options=false) { //--(MAGIC-PclTrace)--//PclTraceFctStart(__FILE__, __LINE__, "PclZip::privParseOptions", ""); $v_result=1; // ----- Read the options $i=0; while ($i<$p_size) { //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 4, "Looking for table index $i, option = '".PclZipUtilOptionText($p_options_list[$i])."(".$p_options_list[$i].")'"); // ----- Check if the option is supported if (!isset($v_requested_options[$p_options_list[$i]])) { // ----- Error log PclZip::privErrorLog(PCLZIP_ERR_INVALID_PARAMETER, "Invalid optional parameter '".$p_options_list[$i]."' for this method"); // ----- Return //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, PclZip::errorCode(), PclZip::errorInfo()); return PclZip::errorCode(); } // ----- Look for next option switch ($p_options_list[$i]) { // ----- Look for options that request a path value case PCLZIP_OPT_PATH : case PCLZIP_OPT_REMOVE_PATH : case PCLZIP_OPT_ADD_PATH : // ----- Check the number of parameters if (($i+1) >= $p_size) { // ----- Error log PclZip::privErrorLog(PCLZIP_ERR_MISSING_OPTION_VALUE, "Missing parameter value for option '".PclZipUtilOptionText($p_options_list[$i])."'"); // ----- Return //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, PclZip::errorCode(), PclZip::errorInfo()); return PclZip::errorCode(); } // ----- Get the value $v_result_list[$p_options_list[$i]] = PclZipUtilTranslateWinPath($p_options_list[$i+1], false); //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "".PclZipUtilOptionText($p_options_list[$i])." = '".$v_result_list[$p_options_list[$i]]."'"); $i++; break; case PCLZIP_OPT_EXTRACT_DIR_RESTRICTION : // ----- Check the number of parameters if (($i+1) >= $p_size) { // ----- Error log PclZip::privErrorLog(PCLZIP_ERR_MISSING_OPTION_VALUE, "Missing parameter value for option '".PclZipUtilOptionText($p_options_list[$i])."'"); // ----- Return //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, PclZip::errorCode(), PclZip::errorInfo()); return PclZip::errorCode(); } // ----- Get the value if ( is_string($p_options_list[$i+1]) && ($p_options_list[$i+1] != '')) { $v_result_list[$p_options_list[$i]] = PclZipUtilTranslateWinPath($p_options_list[$i+1], false); //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "".PclZipUtilOptionText($p_options_list[$i])." = '".$v_result_list[$p_options_list[$i]]."'"); $i++; } else { //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "".PclZipUtilOptionText($p_options_list[$i])." set with an empty value is ignored."); } break; // ----- Look for options that request an array of string for value case PCLZIP_OPT_BY_NAME : // ----- Check the number of parameters if (($i+1) >= $p_size) { // ----- Error log PclZip::privErrorLog(PCLZIP_ERR_MISSING_OPTION_VALUE, "Missing parameter value for option '".PclZipUtilOptionText($p_options_list[$i])."'"); // ----- Return //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, PclZip::errorCode(), PclZip::errorInfo()); return PclZip::errorCode(); } // ----- Get the value if (is_string($p_options_list[$i+1])) { $v_result_list[$p_options_list[$i]][0] = $p_options_list[$i+1]; } else if (is_array($p_options_list[$i+1])) { $v_result_list[$p_options_list[$i]] = $p_options_list[$i+1]; } else { // ----- Error log PclZip::privErrorLog(PCLZIP_ERR_INVALID_OPTION_VALUE, "Wrong parameter value for option '".PclZipUtilOptionText($p_options_list[$i])."'"); // ----- Return //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, PclZip::errorCode(), PclZip::errorInfo()); return PclZip::errorCode(); } ////--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "".PclZipUtilOptionText($p_options_list[$i])." = '".$v_result_list[$p_options_list[$i]]."'"); $i++; break; // ----- Look for options that request an EREG or PREG expression case PCLZIP_OPT_BY_EREG : case PCLZIP_OPT_BY_PREG : //case PCLZIP_OPT_CRYPT : // ----- Check the number of parameters if (($i+1) >= $p_size) { // ----- Error log PclZip::privErrorLog(PCLZIP_ERR_MISSING_OPTION_VALUE, "Missing parameter value for option '".PclZipUtilOptionText($p_options_list[$i])."'"); // ----- Return //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, PclZip::errorCode(), PclZip::errorInfo()); return PclZip::errorCode(); } // ----- Get the value if (is_string($p_options_list[$i+1])) { $v_result_list[$p_options_list[$i]] = $p_options_list[$i+1]; } else { // ----- Error log PclZip::privErrorLog(PCLZIP_ERR_INVALID_OPTION_VALUE, "Wrong parameter value for option '".PclZipUtilOptionText($p_options_list[$i])."'"); // ----- Return //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, PclZip::errorCode(), PclZip::errorInfo()); return PclZip::errorCode(); } //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "".PclZipUtilOptionText($p_options_list[$i])." = '".$v_result_list[$p_options_list[$i]]."'"); $i++; break; // ----- Look for options that takes a string case PCLZIP_OPT_COMMENT : case PCLZIP_OPT_ADD_COMMENT : case PCLZIP_OPT_PREPEND_COMMENT : // ----- Check the number of parameters if (($i+1) >= $p_size) { // ----- Error log PclZip::privErrorLog(PCLZIP_ERR_MISSING_OPTION_VALUE, "Missing parameter value for option '" .PclZipUtilOptionText($p_options_list[$i]) ."'"); // ----- Return //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, PclZip::errorCode(), PclZip::errorInfo()); return PclZip::errorCode(); } // ----- Get the value if (is_string($p_options_list[$i+1])) { $v_result_list[$p_options_list[$i]] = $p_options_list[$i+1]; } else { // ----- Error log PclZip::privErrorLog(PCLZIP_ERR_INVALID_OPTION_VALUE, "Wrong parameter value for option '" .PclZipUtilOptionText($p_options_list[$i]) ."'"); // ----- Return //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, PclZip::errorCode(), PclZip::errorInfo()); return PclZip::errorCode(); } //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "".PclZipUtilOptionText($p_options_list[$i])." = '".$v_result_list[$p_options_list[$i]]."'"); $i++; break; // ----- Look for options that request an array of index case PCLZIP_OPT_BY_INDEX : // ----- Check the number of parameters if (($i+1) >= $p_size) { // ----- Error log PclZip::privErrorLog(PCLZIP_ERR_MISSING_OPTION_VALUE, "Missing parameter value for option '".PclZipUtilOptionText($p_options_list[$i])."'"); // ----- Return //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, PclZip::errorCode(), PclZip::errorInfo()); return PclZip::errorCode(); } // ----- Get the value $v_work_list = array(); if (is_string($p_options_list[$i+1])) { //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 4, "Index value is a string '".$p_options_list[$i+1]."'"); // ----- Remove spaces $p_options_list[$i+1] = strtr($p_options_list[$i+1], ' ', ''); // ----- Parse items $v_work_list = explode(",", $p_options_list[$i+1]); } else if (is_integer($p_options_list[$i+1])) { //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 4, "Index value is an integer '".$p_options_list[$i+1]."'"); $v_work_list[0] = $p_options_list[$i+1].'-'.$p_options_list[$i+1]; } else if (is_array($p_options_list[$i+1])) { //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 4, "Index value is an array"); $v_work_list = $p_options_list[$i+1]; } else { // ----- Error log PclZip::privErrorLog(PCLZIP_ERR_INVALID_OPTION_VALUE, "Value must be integer, string or array for option '".PclZipUtilOptionText($p_options_list[$i])."'"); // ----- Return //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, PclZip::errorCode(), PclZip::errorInfo()); return PclZip::errorCode(); } // ----- Reduce the index list // each index item in the list must be a couple with a start and // an end value : [0,3], [5-5], [8-10], ... // ----- Check the format of each item $v_sort_flag=false; $v_sort_value=0; for ($j=0; $j= $p_size) { // ----- Error log PclZip::privErrorLog(PCLZIP_ERR_MISSING_OPTION_VALUE, "Missing parameter value for option '".PclZipUtilOptionText($p_options_list[$i])."'"); // ----- Return //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, PclZip::errorCode(), PclZip::errorInfo()); return PclZip::errorCode(); } // ----- Get the value $v_result_list[$p_options_list[$i]] = $p_options_list[$i+1]; //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "".PclZipUtilOptionText($p_options_list[$i])." = '".$v_result_list[$p_options_list[$i]]."'"); $i++; break; // ----- Look for options that request a call-back case PCLZIP_CB_PRE_EXTRACT : case PCLZIP_CB_POST_EXTRACT : case PCLZIP_CB_PRE_ADD : case PCLZIP_CB_POST_ADD : /* for futur use case PCLZIP_CB_PRE_DELETE : case PCLZIP_CB_POST_DELETE : case PCLZIP_CB_PRE_LIST : case PCLZIP_CB_POST_LIST : */ // ----- Check the number of parameters if (($i+1) >= $p_size) { // ----- Error log PclZip::privErrorLog(PCLZIP_ERR_MISSING_OPTION_VALUE, "Missing parameter value for option '".PclZipUtilOptionText($p_options_list[$i])."'"); // ----- Return //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, PclZip::errorCode(), PclZip::errorInfo()); return PclZip::errorCode(); } // ----- Get the value $v_function_name = $p_options_list[$i+1]; //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "call-back ".PclZipUtilOptionText($p_options_list[$i])." = '".$v_function_name."'"); // ----- Check that the value is a valid existing function if (!function_exists($v_function_name)) { // ----- Error log PclZip::privErrorLog(PCLZIP_ERR_INVALID_OPTION_VALUE, "Function '".$v_function_name."()' is not an existing function for option '".PclZipUtilOptionText($p_options_list[$i])."'"); // ----- Return //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, PclZip::errorCode(), PclZip::errorInfo()); return PclZip::errorCode(); } // ----- Set the attribute $v_result_list[$p_options_list[$i]] = $v_function_name; $i++; break; default : // ----- Error log PclZip::privErrorLog(PCLZIP_ERR_INVALID_PARAMETER, "Unknown parameter '" .$p_options_list[$i]."'"); // ----- Return //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, PclZip::errorCode(), PclZip::errorInfo()); return PclZip::errorCode(); } // ----- Next options $i++; } // ----- Look for mandatory options if ($v_requested_options !== false) { for ($key=reset($v_requested_options); $key=key($v_requested_options); $key=next($v_requested_options)) { // ----- Look for mandatory option if ($v_requested_options[$key] == 'mandatory') { //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 4, "Detect a mandatory option : ".PclZipUtilOptionText($key)."(".$key.")"); // ----- Look if present if (!isset($v_result_list[$key])) { // ----- Error log PclZip::privErrorLog(PCLZIP_ERR_INVALID_PARAMETER, "Missing mandatory parameter ".PclZipUtilOptionText($key)."(".$key.")"); // ----- Return //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, PclZip::errorCode(), PclZip::errorInfo()); return PclZip::errorCode(); } } } } // ----- Return //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result); return $v_result; } // -------------------------------------------------------------------------------- // -------------------------------------------------------------------------------- // Function : privFileDescrParseAtt() // Description : // Parameters : // Return Values : // 1 on success. // 0 on failure. // -------------------------------------------------------------------------------- // http://doc.spip.org/@privFileDescrParseAtt function privFileDescrParseAtt(&$p_file_list, &$p_filedescr, $v_options, $v_requested_options=false) { //--(MAGIC-PclTrace)--//PclTraceFctStart(__FILE__, __LINE__, "PclZip::privFileDescrParseAtt", ""); $v_result=1; // ----- For each file in the list check the attributes foreach ($p_file_list as $v_key => $v_value) { // ----- Check if the option is supported if (!isset($v_requested_options[$v_key])) { // ----- Error log PclZip::privErrorLog(PCLZIP_ERR_INVALID_PARAMETER, "Invalid file attribute '".$v_key."' for this file"); // ----- Return //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, PclZip::errorCode(), PclZip::errorInfo()); return PclZip::errorCode(); } // ----- Look for attribute switch ($v_key) { case PCLZIP_ATT_FILE_NAME : if (!is_string($v_value)) { PclZip::privErrorLog(PCLZIP_ERR_INVALID_ATTRIBUTE_VALUE, "Invalid type ".gettype($v_value).". String expected for attribute '".PclZipUtilOptionText($v_key)."'"); //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, PclZip::errorCode(), PclZip::errorInfo()); return PclZip::errorCode(); } $p_filedescr['filename'] = PclZipUtilPathReduction($v_value); //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "".PclZipUtilOptionText($v_key)." = '".$v_value."'"); if ($p_filedescr['filename'] == '') { PclZip::privErrorLog(PCLZIP_ERR_INVALID_ATTRIBUTE_VALUE, "Invalid empty filename for attribute '".PclZipUtilOptionText($v_key)."'"); //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, PclZip::errorCode(), PclZip::errorInfo()); return PclZip::errorCode(); } break; case PCLZIP_ATT_FILE_NEW_SHORT_NAME : if (!is_string($v_value)) { PclZip::privErrorLog(PCLZIP_ERR_INVALID_ATTRIBUTE_VALUE, "Invalid type ".gettype($v_value).". String expected for attribute '".PclZipUtilOptionText($v_key)."'"); //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, PclZip::errorCode(), PclZip::errorInfo()); return PclZip::errorCode(); } $p_filedescr['new_short_name'] = PclZipUtilPathReduction($v_value); //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "".PclZipUtilOptionText($v_key)." = '".$v_value."'"); if ($p_filedescr['new_short_name'] == '') { PclZip::privErrorLog(PCLZIP_ERR_INVALID_ATTRIBUTE_VALUE, "Invalid empty short filename for attribute '".PclZipUtilOptionText($v_key)."'"); //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, PclZip::errorCode(), PclZip::errorInfo()); return PclZip::errorCode(); } break; case PCLZIP_ATT_FILE_NEW_FULL_NAME : if (!is_string($v_value)) { PclZip::privErrorLog(PCLZIP_ERR_INVALID_ATTRIBUTE_VALUE, "Invalid type ".gettype($v_value).". String expected for attribute '".PclZipUtilOptionText($v_key)."'"); //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, PclZip::errorCode(), PclZip::errorInfo()); return PclZip::errorCode(); } $p_filedescr['new_full_name'] = PclZipUtilPathReduction($v_value); //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "".PclZipUtilOptionText($v_key)." = '".$v_value."'"); if ($p_filedescr['new_full_name'] == '') { PclZip::privErrorLog(PCLZIP_ERR_INVALID_ATTRIBUTE_VALUE, "Invalid empty full filename for attribute '".PclZipUtilOptionText($v_key)."'"); //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, PclZip::errorCode(), PclZip::errorInfo()); return PclZip::errorCode(); } break; default : // ----- Error log PclZip::privErrorLog(PCLZIP_ERR_INVALID_PARAMETER, "Unknown parameter '".$v_key."'"); // ----- Return //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, PclZip::errorCode(), PclZip::errorInfo()); return PclZip::errorCode(); } // ----- Look for mandatory options if ($v_requested_options !== false) { for ($key=reset($v_requested_options); $key=key($v_requested_options); $key=next($v_requested_options)) { // ----- Look for mandatory option if ($v_requested_options[$key] == 'mandatory') { //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 4, "Detect a mandatory option : ".PclZipUtilOptionText($key)."(".$key.")"); // ----- Look if present if (!isset($p_file_list[$key])) { PclZip::privErrorLog(PCLZIP_ERR_INVALID_PARAMETER, "Missing mandatory parameter ".PclZipUtilOptionText($key)."(".$key.")"); //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, PclZip::errorCode(), PclZip::errorInfo()); return PclZip::errorCode(); } } } } // end foreach } // ----- Return //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result); return $v_result; } // -------------------------------------------------------------------------------- // -------------------------------------------------------------------------------- // Function : privFileDescrExpand() // Description : // Parameters : // Return Values : // 1 on success. // 0 on failure. // -------------------------------------------------------------------------------- // http://doc.spip.org/@privFileDescrExpand function privFileDescrExpand(&$p_filedescr_list, &$p_options) { //--(MAGIC-PclTrace)--//PclTraceFctStart(__FILE__, __LINE__, "PclZip::privFileDescrExpand", ""); $v_result=1; // ----- Create a result list $v_result_list = array(); // ----- Look each entry for ($i=0; $iprivCalculateStoredFilename($v_descr, $p_options); // ----- Add the descriptor in result list $v_result_list[sizeof($v_result_list)] = $v_descr; // ----- Look for folder if ($v_descr['type'] == 'folder') { // ----- List of items in folder $v_dirlist_descr = array(); $v_dirlist_nb = 0; if ($v_folder_handler = @opendir($v_descr['filename'])) { while (($v_item_handler = @readdir($v_folder_handler)) !== false) { //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "Looking for '".$v_item_handler."' in the directory"); // ----- Skip '.' and '..' if (($v_item_handler == '.') || ($v_item_handler == '..')) { continue; } // ----- Compose the full filename $v_dirlist_descr[$v_dirlist_nb]['filename'] = $v_descr['filename'].'/'.$v_item_handler; // ----- Look for different stored filename // Because the name of the folder was changed, the name of the // files/sub-folders also change if ($v_descr['stored_filename'] != $v_descr['filename']) { $v_dirlist_descr[$v_dirlist_nb]['new_full_name'] = $v_descr['stored_filename'].'/'.$v_item_handler; } $v_dirlist_nb++; } } else { //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "Unable to open dir '".$v_descr['filename']."' in read mode. Skipped."); // TBC : unable to open folder in read mode } // ----- Expand each element of the list if ($v_dirlist_nb != 0) { // ----- Expand if (($v_result = $this->privFileDescrExpand($v_dirlist_descr, $p_options)) != 1) { //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result); return $v_result; } // ----- Concat the resulting list //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "Merging result list (size '".sizeof($v_result_list)."') with dirlist (size '".sizeof($v_dirlist_descr)."')"); $v_result_list = array_merge($v_result_list, $v_dirlist_descr); //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "merged result list is size '".sizeof($v_result_list)."'"); } else { //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "Nothing in this folder to expand."); } // ----- Free local array unset($v_dirlist_descr); } } // ----- Get the result list $p_filedescr_list = $v_result_list; // ----- Return //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result); return $v_result; } // -------------------------------------------------------------------------------- // -------------------------------------------------------------------------------- // Function : privCreate() // Description : // Parameters : // Return Values : // -------------------------------------------------------------------------------- // http://doc.spip.org/@privCreate function privCreate($p_filedescr_list, &$p_result_list, &$p_options) { //--(MAGIC-PclTrace)--//PclTraceFctStart(__FILE__, __LINE__, "PclZip::privCreate", "list"); $v_result=1; $v_list_detail = array(); // ----- Magic quotes trick $this->privDisableMagicQuotes(); // ----- Open the file in write mode if (($v_result = $this->privOpenFd('wb')) != 1) { // ----- Return //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result); return $v_result; } // ----- Add the list of files $v_result = $this->privAddList($p_filedescr_list, $p_result_list, $p_options); // ----- Close $this->privCloseFd(); // ----- Magic quotes trick $this->privSwapBackMagicQuotes(); // ----- Return //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result); return $v_result; } // -------------------------------------------------------------------------------- // -------------------------------------------------------------------------------- // Function : privAdd() // Description : // Parameters : // Return Values : // -------------------------------------------------------------------------------- // http://doc.spip.org/@privAdd function privAdd($p_filedescr_list, &$p_result_list, &$p_options) { //--(MAGIC-PclTrace)--//PclTraceFctStart(__FILE__, __LINE__, "PclZip::privAdd", "list"); $v_result=1; $v_list_detail = array(); // ----- Look if the archive exists or is empty if ((!is_file($this->zipname)) || (filesize($this->zipname) == 0)) { //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Archive does not exist, or is empty, create it."); // ----- Do a create $v_result = $this->privCreate($p_filedescr_list, $p_result_list, $p_options); // ----- Return //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result); return $v_result; } // ----- Magic quotes trick $this->privDisableMagicQuotes(); // ----- Open the zip file //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Open file in binary read mode"); if (($v_result=$this->privOpenFd('rb')) != 1) { // ----- Magic quotes trick $this->privSwapBackMagicQuotes(); // ----- Return //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result); return $v_result; } // ----- Read the central directory informations $v_central_dir = array(); if (($v_result = $this->privReadEndCentralDir($v_central_dir)) != 1) { $this->privCloseFd(); $this->privSwapBackMagicQuotes(); //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result); return $v_result; } // ----- Go to beginning of File //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 5, "Position in file : ".ftell($this->zip_fd)."'"); @rewind($this->zip_fd); //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 5, "Position in file : ".ftell($this->zip_fd)."'"); // ----- Creates a temporay file $v_zip_temp_name = PCLZIP_TEMPORARY_DIR.uniqid('pclzip-').'.tmp'; // ----- Open the temporary file in write mode //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Open file in binary read mode"); if (($v_zip_temp_fd = @fopen($v_zip_temp_name, 'wb')) == 0) { $this->privCloseFd(); $this->privSwapBackMagicQuotes(); PclZip::privErrorLog(PCLZIP_ERR_READ_OPEN_FAIL, 'Unable to open temporary file \''.$v_zip_temp_name.'\' in binary write mode'); // ----- Return //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, PclZip::errorCode(), PclZip::errorInfo()); return PclZip::errorCode(); } // ----- Copy the files from the archive to the temporary file // TBC : Here I should better append the file and go back to erase the central dir $v_size = $v_central_dir['offset']; while ($v_size != 0) { $v_read_size = ($v_size < PCLZIP_READ_BLOCK_SIZE ? $v_size : PCLZIP_READ_BLOCK_SIZE); //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 4, "Read $v_read_size bytes"); $v_buffer = fread($this->zip_fd, $v_read_size); @fwrite($v_zip_temp_fd, $v_buffer, $v_read_size); $v_size -= $v_read_size; } // ----- Swap the file descriptor // Here is a trick : I swap the temporary fd with the zip fd, in order to use // the following methods on the temporary fil and not the real archive $v_swap = $this->zip_fd; $this->zip_fd = $v_zip_temp_fd; $v_zip_temp_fd = $v_swap; // ----- Add the files $v_header_list = array(); if (($v_result = $this->privAddFileList($p_filedescr_list, $v_header_list, $p_options)) != 1) { fclose($v_zip_temp_fd); $this->privCloseFd(); spip_unlink($v_zip_temp_name); $this->privSwapBackMagicQuotes(); // ----- Return //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result); return $v_result; } // ----- Store the offset of the central dir $v_offset = @ftell($this->zip_fd); //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 4, "New offset of central dir : $v_offset"); // ----- Copy the block of file headers from the old archive $v_size = $v_central_dir['size']; while ($v_size != 0) { $v_read_size = ($v_size < PCLZIP_READ_BLOCK_SIZE ? $v_size : PCLZIP_READ_BLOCK_SIZE); //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 4, "Read $v_read_size bytes"); $v_buffer = @fread($v_zip_temp_fd, $v_read_size); @fwrite($this->zip_fd, $v_buffer, $v_read_size); $v_size -= $v_read_size; } // ----- Create the Central Dir files header for ($i=0, $v_count=0; $iprivWriteCentralFileHeader($v_header_list[$i])) != 1) { fclose($v_zip_temp_fd); $this->privCloseFd(); spip_unlink($v_zip_temp_name); $this->privSwapBackMagicQuotes(); // ----- Return //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result); return $v_result; } $v_count++; } // ----- Transform the header to a 'usable' info $this->privConvertHeader2FileInfo($v_header_list[$i], $p_result_list[$i]); } // ----- Zip file comment $v_comment = $v_central_dir['comment']; if (isset($p_options[PCLZIP_OPT_COMMENT])) { $v_comment = $p_options[PCLZIP_OPT_COMMENT]; } if (isset($p_options[PCLZIP_OPT_ADD_COMMENT])) { $v_comment = $v_comment.$p_options[PCLZIP_OPT_ADD_COMMENT]; } if (isset($p_options[PCLZIP_OPT_PREPEND_COMMENT])) { $v_comment = $p_options[PCLZIP_OPT_PREPEND_COMMENT].$v_comment; } // ----- Calculate the size of the central header $v_size = @ftell($this->zip_fd)-$v_offset; // ----- Create the central dir footer if (($v_result = $this->privWriteCentralHeader($v_count+$v_central_dir['entries'], $v_size, $v_offset, $v_comment)) != 1) { // ----- Reset the file list unset($v_header_list); $this->privSwapBackMagicQuotes(); // ----- Return //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result); return $v_result; } // ----- Swap back the file descriptor $v_swap = $this->zip_fd; $this->zip_fd = $v_zip_temp_fd; $v_zip_temp_fd = $v_swap; // ----- Close $this->privCloseFd(); // ----- Close the temporary file @fclose($v_zip_temp_fd); // ----- Magic quotes trick $this->privSwapBackMagicQuotes(); // ----- Delete the zip file // TBC : I should test the result ... spip_unlink($this->zipname); // ----- Rename the temporary file // TBC : I should test the result ... //@rename($v_zip_temp_name, $this->zipname); PclZipUtilRename($v_zip_temp_name, $this->zipname); // ----- Return //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result); return $v_result; } // -------------------------------------------------------------------------------- // -------------------------------------------------------------------------------- // Function : privOpenFd() // Description : // Parameters : // -------------------------------------------------------------------------------- // http://doc.spip.org/@privOpenFd function privOpenFd($p_mode) { //--(MAGIC-PclTrace)--//PclTraceFctStart(__FILE__, __LINE__, "PclZip::privOpenFd", 'mode='.$p_mode); $v_result=1; // ----- Look if already open if ($this->zip_fd != 0) { // ----- Error log PclZip::privErrorLog(PCLZIP_ERR_READ_OPEN_FAIL, 'Zip file \''.$this->zipname.'\' already open'); // ----- Return //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, PclZip::errorCode(), PclZip::errorInfo()); return PclZip::errorCode(); } // ----- Open the zip file //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, 'Open file in '.$p_mode.' mode'); if (($this->zip_fd = @fopen($this->zipname, $p_mode)) == 0) { // ----- Error log PclZip::privErrorLog(PCLZIP_ERR_READ_OPEN_FAIL, 'Unable to open archive \''.$this->zipname.'\' in '.$p_mode.' mode'); // ----- Return //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, PclZip::errorCode(), PclZip::errorInfo()); return PclZip::errorCode(); } // ----- Return //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result); return $v_result; } // -------------------------------------------------------------------------------- // -------------------------------------------------------------------------------- // Function : privCloseFd() // Description : // Parameters : // -------------------------------------------------------------------------------- // http://doc.spip.org/@privCloseFd function privCloseFd() { //--(MAGIC-PclTrace)--//PclTraceFctStart(__FILE__, __LINE__, "PclZip::privCloseFd", ""); $v_result=1; if ($this->zip_fd != 0) @fclose($this->zip_fd); $this->zip_fd = 0; // ----- Return //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result); return $v_result; } // -------------------------------------------------------------------------------- // -------------------------------------------------------------------------------- // Function : privAddList() // Description : // $p_add_dir and $p_remove_dir will give the ability to memorize a path which is // different from the real path of the file. This is usefull if you want to have PclTar // running in any directory, and memorize relative path from an other directory. // Parameters : // $p_list : An array containing the file or directory names to add in the tar // $p_result_list : list of added files with their properties (specially the status field) // $p_add_dir : Path to add in the filename path archived // $p_remove_dir : Path to remove in the filename path archived // Return Values : // -------------------------------------------------------------------------------- // function privAddList($p_list, &$p_result_list, $p_add_dir, $p_remove_dir, $p_remove_all_dir, &$p_options) // http://doc.spip.org/@privAddList function privAddList($p_filedescr_list, &$p_result_list, &$p_options) { //--(MAGIC-PclTrace)--//PclTraceFctStart(__FILE__, __LINE__, "PclZip::privAddList", "list"); $v_result=1; // ----- Add the files $v_header_list = array(); if (($v_result = $this->privAddFileList($p_filedescr_list, $v_header_list, $p_options)) != 1) { // ----- Return //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result); return $v_result; } // ----- Store the offset of the central dir $v_offset = @ftell($this->zip_fd); // ----- Create the Central Dir files header for ($i=0,$v_count=0; $iprivWriteCentralFileHeader($v_header_list[$i])) != 1) { // ----- Return //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result); return $v_result; } $v_count++; } // ----- Transform the header to a 'usable' info $this->privConvertHeader2FileInfo($v_header_list[$i], $p_result_list[$i]); } // ----- Zip file comment $v_comment = ''; if (isset($p_options[PCLZIP_OPT_COMMENT])) { $v_comment = $p_options[PCLZIP_OPT_COMMENT]; } // ----- Calculate the size of the central header $v_size = @ftell($this->zip_fd)-$v_offset; // ----- Create the central dir footer if (($v_result = $this->privWriteCentralHeader($v_count, $v_size, $v_offset, $v_comment)) != 1) { // ----- Reset the file list unset($v_header_list); // ----- Return //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result); return $v_result; } // ----- Return //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result); return $v_result; } // -------------------------------------------------------------------------------- // -------------------------------------------------------------------------------- // Function : privAddFileList() // Description : // Parameters : // $p_filedescr_list : An array containing the file description // or directory names to add in the zip // $p_result_list : list of added files with their properties (specially the status field) // Return Values : // -------------------------------------------------------------------------------- // http://doc.spip.org/@privAddFileList function privAddFileList($p_filedescr_list, &$p_result_list, &$p_options) { //--(MAGIC-PclTrace)--//PclTraceFctStart(__FILE__, __LINE__, "PclZip::privAddFileList", "filedescr_list"); $v_result=1; $v_header = array(); // ----- Recuperate the current number of elt in list $v_nb = sizeof($p_result_list); //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 4, "Before add, list have ".$v_nb." elements"); // ----- Loop on the files for ($j=0; ($jprivAddFile($p_filedescr_list[$j], $v_header, $p_options); if ($v_result != 1) { //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result); return $v_result; } // ----- Store the file infos $p_result_list[$v_nb++] = $v_header; } } //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 4, "After add, list have ".$v_nb." elements"); // ----- Return //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result); return $v_result; } // -------------------------------------------------------------------------------- // -------------------------------------------------------------------------------- // Function : privAddFile() // Description : // Parameters : // Return Values : // -------------------------------------------------------------------------------- // http://doc.spip.org/@privAddFile function privAddFile($p_filedescr, &$p_header, &$p_options) { //--(MAGIC-PclTrace)--//PclTraceFctStart(__FILE__, __LINE__, "PclZip::privAddFile", "filename='".$p_filedescr['filename']."'"); $v_result=1; // ----- Working variable $p_filename = $p_filedescr['filename']; // TBC : Already done in the fileAtt check ... ? if ($p_filename == "") { // ----- Error log PclZip::privErrorLog(PCLZIP_ERR_INVALID_PARAMETER, "Invalid file list parameter (invalid or empty list)"); // ----- Return //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, PclZip::errorCode(), PclZip::errorInfo()); return PclZip::errorCode(); } // ----- Look for a stored different filename if (isset($p_filedescr['stored_filename'])) { $v_stored_filename = $p_filedescr['stored_filename']; //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, 'Stored filename is NOT the same "'.$v_stored_filename.'"'); } else { $v_stored_filename = $p_filedescr['stored_filename']; //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, 'Stored filename is the same'); } // ----- Set the file properties clearstatcache(); $p_header['version'] = 20; $p_header['version_extracted'] = 10; $p_header['flag'] = 0; $p_header['compression'] = 0; $p_header['mtime'] = filemtime($p_filename); $p_header['crc'] = 0; $p_header['compressed_size'] = 0; $p_header['size'] = filesize($p_filename); $p_header['filename_len'] = strlen($p_filename); $p_header['extra_len'] = 0; $p_header['comment_len'] = 0; $p_header['disk'] = 0; $p_header['internal'] = 0; // $p_header['external'] = (is_file($p_filename)?0xFE49FFE0:0x41FF0010); $p_header['external'] = (is_file($p_filename)?0x00000000:0x00000010); //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 5, "Header external extension '".sprintf("0x%X",$p_header['external'])."'"); $p_header['offset'] = 0; $p_header['filename'] = $p_filename; $p_header['stored_filename'] = $v_stored_filename; $p_header['extra'] = ''; $p_header['comment'] = ''; $p_header['status'] = 'ok'; $p_header['index'] = -1; // ----- Look for pre-add callback if (isset($p_options[PCLZIP_CB_PRE_ADD])) { //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "A pre-callback '".$p_options[PCLZIP_CB_PRE_ADD]."()') is defined for the extraction"); // ----- Generate a local information $v_local_header = array(); $this->privConvertHeader2FileInfo($p_header, $v_local_header); // ----- Call the callback // Here I do not use call_user_func() because I need to send a reference to the // header. eval('$v_result = '.$p_options[PCLZIP_CB_PRE_ADD].'(PCLZIP_CB_PRE_ADD, $v_local_header);'); if ($v_result == 0) { // ----- Change the file status $p_header['status'] = "skipped"; $v_result = 1; } // ----- Update the informations // Only some fields can be modified if ($p_header['stored_filename'] != $v_local_header['stored_filename']) { $p_header['stored_filename'] = PclZipUtilPathReduction($v_local_header['stored_filename']); //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "New stored filename is '".$p_header['stored_filename']."'"); } } // ----- Look for empty stored filename if ($p_header['stored_filename'] == "") { $p_header['status'] = "filtered"; } // ----- Check the path length if (strlen($p_header['stored_filename']) > 0xFF) { $p_header['status'] = 'filename_too_long'; } // ----- Look if no error, or file not skipped if ($p_header['status'] == 'ok') { // ----- Look for a file if (is_file($p_filename)) { //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "'".$p_filename."' is a file"); // ----- Open the source file if (($v_file = @fopen($p_filename, "rb")) == 0) { PclZip::privErrorLog(PCLZIP_ERR_READ_OPEN_FAIL, "Unable to open file '$p_filename' in binary read mode"); //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, PclZip::errorCode(), PclZip::errorInfo()); return PclZip::errorCode(); } if ($p_options[PCLZIP_OPT_NO_COMPRESSION]) { //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "File will not be compressed"); // ----- Read the file content $v_content_compressed = @fread($v_file, $p_header['size']); // ----- Calculate the CRC $p_header['crc'] = @crc32($v_content_compressed); // ----- Set header parameters $p_header['compressed_size'] = $p_header['size']; $p_header['compression'] = 0; } else { //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "File will be compressed"); // ----- Read the file content $v_content = @fread($v_file, $p_header['size']); // ----- Calculate the CRC $p_header['crc'] = @crc32($v_content); // ----- Compress the file $v_content_compressed = @gzdeflate($v_content); // ----- Set header parameters $p_header['compressed_size'] = strlen($v_content_compressed); $p_header['compression'] = 8; } // ----- Look for encryption /* if ((isset($p_options[PCLZIP_OPT_CRYPT])) && ($p_options[PCLZIP_OPT_CRYPT] != "")) { //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "File need to be crypted ...."); // Should be a random header $v_header = 'xxxxxxxxxxxx'; $v_content_compressed = PclZipUtilZipEncrypt($v_content_compressed, $p_header['compressed_size'], $v_header, $p_header['crc'], "test"); $p_header['compressed_size'] += 12; $p_header['flag'] = 1; // ----- Add the header to the data $v_content_compressed = $v_header.$v_content_compressed; //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "Size after header : ".strlen($v_content_compressed).""); } */ // ----- Call the header generation if (($v_result = $this->privWriteFileHeader($p_header)) != 1) { @fclose($v_file); //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result); return $v_result; } // ----- Write the compressed (or not) content @fwrite($this->zip_fd, $v_content_compressed, $p_header['compressed_size']); // ----- Close the file @fclose($v_file); } // ----- Look for a directory else { //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "'".$p_filename."' is a folder"); // ----- Look for directory last '/' if (@substr($p_header['stored_filename'], -1) != '/') { $p_header['stored_filename'] .= '/'; } // ----- Set the file properties $p_header['size'] = 0; //$p_header['external'] = 0x41FF0010; // Value for a folder : to be checked $p_header['external'] = 0x00000010; // Value for a folder : to be checked // ----- Call the header generation if (($v_result = $this->privWriteFileHeader($p_header)) != 1) { //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result); return $v_result; } } } // ----- Look for post-add callback if (isset($p_options[PCLZIP_CB_POST_ADD])) { //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "A post-callback '".$p_options[PCLZIP_CB_POST_ADD]."()') is defined for the extraction"); // ----- Generate a local information $v_local_header = array(); $this->privConvertHeader2FileInfo($p_header, $v_local_header); // ----- Call the callback // Here I do not use call_user_func() because I need to send a reference to the // header. eval('$v_result = '.$p_options[PCLZIP_CB_POST_ADD].'(PCLZIP_CB_POST_ADD, $v_local_header);'); if ($v_result == 0) { // ----- Ignored $v_result = 1; } // ----- Update the informations // Nothing can be modified } // ----- Return //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result); return $v_result; } // -------------------------------------------------------------------------------- // -------------------------------------------------------------------------------- // Function : privCalculateStoredFilename() // Description : // Based on file descriptor properties and global options, this method // calculate the filename that will be stored in the archive. // Parameters : // Return Values : // -------------------------------------------------------------------------------- // http://doc.spip.org/@privCalculateStoredFilename function privCalculateStoredFilename(&$p_filedescr, &$p_options) { //--(MAGIC-PclTrace)--//PclTraceFctStart(__FILE__, __LINE__, "PclZip::privCalculateStoredFilename", "filename='".$p_filedescr['filename']."'"); $v_result=1; // ----- Working variables $p_filename = $p_filedescr['filename']; if (isset($p_options[PCLZIP_OPT_ADD_PATH])) { $p_add_dir = $p_options[PCLZIP_OPT_ADD_PATH]; } else { $p_add_dir = ''; } if (isset($p_options[PCLZIP_OPT_REMOVE_PATH])) { $p_remove_dir = $p_options[PCLZIP_OPT_REMOVE_PATH]; } else { $p_remove_dir = ''; } if (isset($p_options[PCLZIP_OPT_REMOVE_ALL_PATH])) { $p_remove_all_dir = $p_options[PCLZIP_OPT_REMOVE_ALL_PATH]; } else { $p_remove_all_dir = 0; } // ----- Look for full name change if (isset($p_filedescr['new_full_name'])) { $v_stored_filename = $p_filedescr['new_full_name']; //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 4, "Changing full name of '".$p_filename."' for '".$v_stored_filename."'"); } // ----- Look for path and/or short name change else { // ----- Look for short name change if (isset($p_filedescr['new_short_name'])) { $v_path_info = pathinfo($p_filename); $v_dir = ''; if ($v_path_info['dirname'] != '') { $v_dir = $v_path_info['dirname'].'/'; } $v_stored_filename = $v_dir.$p_filedescr['new_short_name']; //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 4, "Changing short name of '".$p_filename."' for '".$v_stored_filename."'"); } else { // ----- Calculate the stored filename $v_stored_filename = $p_filename; } // ----- Look for all path to remove if ($p_remove_all_dir) { $v_stored_filename = basename($p_filename); //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 4, "Remove all path selected change '".$p_filename."' for '".$v_stored_filename."'"); } // ----- Look for partial path remove else if ($p_remove_dir != "") { if (substr($p_remove_dir, -1) != '/') $p_remove_dir .= "/"; if ( (substr($p_filename, 0, 2) == "./") || (substr($p_remove_dir, 0, 2) == "./")) { if ( (substr($p_filename, 0, 2) == "./") && (substr($p_remove_dir, 0, 2) != "./")) { $p_remove_dir = "./".$p_remove_dir; } if ( (substr($p_filename, 0, 2) != "./") && (substr($p_remove_dir, 0, 2) == "./")) { $p_remove_dir = substr($p_remove_dir, 2); } } $v_compare = PclZipUtilPathInclusion($p_remove_dir, $v_stored_filename); if ($v_compare > 0) { if ($v_compare == 2) { $v_stored_filename = ""; //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 4, "Path to remove is the current folder"); } else { //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 4, "Remove path '$p_remove_dir' in file '$v_stored_filename'"); $v_stored_filename = substr($v_stored_filename, strlen($p_remove_dir)); //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 4, "Result is '$v_stored_filename'"); } } } // ----- Look for path to add if ($p_add_dir != "") { if (substr($p_add_dir, -1) == "/") $v_stored_filename = $p_add_dir.$v_stored_filename; else $v_stored_filename = $p_add_dir."/".$v_stored_filename; //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Add path '$p_add_dir' in file '$p_filename' = '$v_stored_filename'"); } } // ----- Filename (reduce the path of stored name) $v_stored_filename = PclZipUtilPathReduction($v_stored_filename); $p_filedescr['stored_filename'] = $v_stored_filename; //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "Stored filename will be '".$p_filedescr['stored_filename']."', strlen ".strlen($p_filedescr['stored_filename'])); // ----- Return //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result); return $v_result; } // -------------------------------------------------------------------------------- // -------------------------------------------------------------------------------- // Function : privWriteFileHeader() // Description : // Parameters : // Return Values : // -------------------------------------------------------------------------------- // http://doc.spip.org/@privWriteFileHeader function privWriteFileHeader(&$p_header) { //--(MAGIC-PclTrace)--//PclTraceFctStart(__FILE__, __LINE__, "PclZip::privWriteFileHeader", 'file="'.$p_header['filename'].'", stored as "'.$p_header['stored_filename'].'"'); $v_result=1; // ----- Store the offset position of the file $p_header['offset'] = ftell($this->zip_fd); //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, 'File offset of the header :'.$p_header['offset']); // ----- Transform UNIX mtime to DOS format mdate/mtime //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, 'Date : \''.date("d/m/y H:i:s", $p_header['mtime']).'\''); $v_date = getdate($p_header['mtime']); $v_mtime = ($v_date['hours']<<11) + ($v_date['minutes']<<5) + $v_date['seconds']/2; $v_mdate = (($v_date['year']-1980)<<9) + ($v_date['mon']<<5) + $v_date['mday']; // ----- Packed data $v_binary_data = pack("VvvvvvVVVvv", 0x04034b50, $p_header['version_extracted'], $p_header['flag'], $p_header['compression'], $v_mtime, $v_mdate, $p_header['crc'], $p_header['compressed_size'], $p_header['size'], strlen($p_header['stored_filename']), $p_header['extra_len']); // ----- Write the first 148 bytes of the header in the archive fputs($this->zip_fd, $v_binary_data, 30); // ----- Write the variable fields if (strlen($p_header['stored_filename']) != 0) { fputs($this->zip_fd, $p_header['stored_filename'], strlen($p_header['stored_filename'])); } if ($p_header['extra_len'] != 0) { fputs($this->zip_fd, $p_header['extra'], $p_header['extra_len']); } // ----- Return //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result); return $v_result; } // -------------------------------------------------------------------------------- // -------------------------------------------------------------------------------- // Function : privWriteCentralFileHeader() // Description : // Parameters : // Return Values : // -------------------------------------------------------------------------------- // http://doc.spip.org/@privWriteCentralFileHeader function privWriteCentralFileHeader(&$p_header) { //--(MAGIC-PclTrace)--//PclTraceFctStart(__FILE__, __LINE__, "PclZip::privWriteCentralFileHeader", 'file="'.$p_header['filename'].'", stored as "'.$p_header['stored_filename'].'"'); $v_result=1; // TBC //for(reset($p_header); $key = key($p_header); next($p_header)) { // //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "header[$key] = ".$p_header[$key]); //} // ----- Transform UNIX mtime to DOS format mdate/mtime //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, 'Date : \''.date("d/m/y H:i:s", $p_header['mtime']).'\''); $v_date = getdate($p_header['mtime']); $v_mtime = ($v_date['hours']<<11) + ($v_date['minutes']<<5) + $v_date['seconds']/2; $v_mdate = (($v_date['year']-1980)<<9) + ($v_date['mon']<<5) + $v_date['mday']; // ----- Packed data $v_binary_data = pack("VvvvvvvVVVvvvvvVV", 0x02014b50, $p_header['version'], $p_header['version_extracted'], $p_header['flag'], $p_header['compression'], $v_mtime, $v_mdate, $p_header['crc'], $p_header['compressed_size'], $p_header['size'], strlen($p_header['stored_filename']), $p_header['extra_len'], $p_header['comment_len'], $p_header['disk'], $p_header['internal'], $p_header['external'], $p_header['offset']); // ----- Write the 42 bytes of the header in the zip file fputs($this->zip_fd, $v_binary_data, 46); // ----- Write the variable fields if (strlen($p_header['stored_filename']) != 0) { fputs($this->zip_fd, $p_header['stored_filename'], strlen($p_header['stored_filename'])); } if ($p_header['extra_len'] != 0) { fputs($this->zip_fd, $p_header['extra'], $p_header['extra_len']); } if ($p_header['comment_len'] != 0) { fputs($this->zip_fd, $p_header['comment'], $p_header['comment_len']); } // ----- Return //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result); return $v_result; } // -------------------------------------------------------------------------------- // -------------------------------------------------------------------------------- // Function : privWriteCentralHeader() // Description : // Parameters : // Return Values : // -------------------------------------------------------------------------------- // http://doc.spip.org/@privWriteCentralHeader function privWriteCentralHeader($p_nb_entries, $p_size, $p_offset, $p_comment) { //--(MAGIC-PclTrace)--//PclTraceFctStart(__FILE__, __LINE__, "PclZip::privWriteCentralHeader", 'nb_entries='.$p_nb_entries.', size='.$p_size.', offset='.$p_offset.', comment="'.$p_comment.'"'); $v_result=1; // ----- Packed data $v_binary_data = pack("VvvvvVVv", 0x06054b50, 0, 0, $p_nb_entries, $p_nb_entries, $p_size, $p_offset, strlen($p_comment)); // ----- Write the 22 bytes of the header in the zip file fputs($this->zip_fd, $v_binary_data, 22); // ----- Write the variable fields if (strlen($p_comment) != 0) { fputs($this->zip_fd, $p_comment, strlen($p_comment)); } // ----- Return //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result); return $v_result; } // -------------------------------------------------------------------------------- // -------------------------------------------------------------------------------- // Function : privList() // Description : // Parameters : // Return Values : // -------------------------------------------------------------------------------- // http://doc.spip.org/@privList function privList(&$p_list) { //--(MAGIC-PclTrace)--//PclTraceFctStart(__FILE__, __LINE__, "PclZip::privList", "list"); $v_result=1; // ----- Magic quotes trick $this->privDisableMagicQuotes(); // ----- Open the zip file //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Open file in binary read mode"); if (($this->zip_fd = @fopen($this->zipname, 'rb')) == 0) { // ----- Magic quotes trick $this->privSwapBackMagicQuotes(); // ----- Error log PclZip::privErrorLog(PCLZIP_ERR_READ_OPEN_FAIL, 'Unable to open archive \''.$this->zipname.'\' in binary read mode'); // ----- Return //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, PclZip::errorCode(), PclZip::errorInfo()); return PclZip::errorCode(); } // ----- Read the central directory informations $v_central_dir = array(); if (($v_result = $this->privReadEndCentralDir($v_central_dir)) != 1) { $this->privSwapBackMagicQuotes(); //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result); return $v_result; } // ----- Go to beginning of Central Dir //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Offset : ".$v_central_dir['offset']."'"); //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Position in file : ".ftell($this->zip_fd)."'"); @rewind($this->zip_fd); //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Position in file : ".ftell($this->zip_fd)."'"); if (@fseek($this->zip_fd, $v_central_dir['offset'])) { $this->privSwapBackMagicQuotes(); // ----- Error log PclZip::privErrorLog(PCLZIP_ERR_INVALID_ARCHIVE_ZIP, 'Invalid archive size'); // ----- Return //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, PclZip::errorCode(), PclZip::errorInfo()); return PclZip::errorCode(); } //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Position in file : ".ftell($this->zip_fd)."'"); // ----- Read each entry for ($i=0; $i<$v_central_dir['entries']; $i++) { // ----- Read the file header if (($v_result = $this->privReadCentralFileHeader($v_header)) != 1) { $this->privSwapBackMagicQuotes(); //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result); return $v_result; } $v_header['index'] = $i; // ----- Get the only interesting attributes $this->privConvertHeader2FileInfo($v_header, $p_list[$i]); unset($v_header); } // ----- Close the zip file $this->privCloseFd(); // ----- Magic quotes trick $this->privSwapBackMagicQuotes(); // ----- Return //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result); return $v_result; } // -------------------------------------------------------------------------------- // -------------------------------------------------------------------------------- // Function : privConvertHeader2FileInfo() // Description : // This function takes the file informations from the central directory // entries and extract the interesting parameters that will be given back. // The resulting file infos are set in the array $p_info // $p_info['filename'] : Filename with full path. Given by user (add), // extracted in the filesystem (extract). // $p_info['stored_filename'] : Stored filename in the archive. // $p_info['size'] = Size of the file. // $p_info['compressed_size'] = Compressed size of the file. // $p_info['mtime'] = Last modification date of the file. // $p_info['comment'] = Comment associated with the file. // $p_info['folder'] = true/false : indicates if the entry is a folder or not. // $p_info['status'] = status of the action on the file. // Parameters : // Return Values : // -------------------------------------------------------------------------------- // http://doc.spip.org/@privConvertHeader2FileInfo function privConvertHeader2FileInfo($p_header, &$p_info) { //--(MAGIC-PclTrace)--//PclTraceFctStart(__FILE__, __LINE__, "PclZip::privConvertHeader2FileInfo", "Filename='".$p_header['filename']."'"); $v_result=1; // ----- Get the interesting attributes $p_info['filename'] = $p_header['filename']; $p_info['stored_filename'] = $p_header['stored_filename']; $p_info['size'] = $p_header['size']; $p_info['compressed_size'] = $p_header['compressed_size']; $p_info['mtime'] = $p_header['mtime']; $p_info['comment'] = $p_header['comment']; $p_info['folder'] = (($p_header['external']&0x00000010)==0x00000010); $p_info['index'] = $p_header['index']; $p_info['status'] = $p_header['status']; // ----- Return //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result); return $v_result; } // -------------------------------------------------------------------------------- // -------------------------------------------------------------------------------- // Function : privExtractByRule() // Description : // Extract a file or directory depending of rules (by index, by name, ...) // Parameters : // $p_file_list : An array where will be placed the properties of each // extracted file // $p_path : Path to add while writing the extracted files // $p_remove_path : Path to remove (from the file memorized path) while writing the // extracted files. If the path does not match the file path, // the file is extracted with its memorized path. // $p_remove_path does not apply to 'list' mode. // $p_path and $p_remove_path are commulative. // Return Values : // 1 on success,0 or less on error (see error code list) // -------------------------------------------------------------------------------- // http://doc.spip.org/@privExtractByRule function privExtractByRule(&$p_file_list, $p_path, $p_remove_path, $p_remove_all_path, &$p_options) { //--(MAGIC-PclTrace)--//PclTraceFctStart(__FILE__, __LINE__, "PclZip::privExtractByRule", "path='$p_path', remove_path='$p_remove_path', remove_all_path='".($p_remove_all_path?'true':'false')."'"); $v_result=1; // ----- Magic quotes trick $this->privDisableMagicQuotes(); // ----- Check the path if ( ($p_path == "") || ( (substr($p_path, 0, 1) != "/") && (substr($p_path, 0, 3) != "../") && (substr($p_path,1,2)!=":/"))) $p_path = "./".$p_path; // ----- Reduce the path last (and duplicated) '/' if (($p_path != "./") && ($p_path != "/")) { // ----- Look for the path end '/' while (substr($p_path, -1) == "/") { //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Destination path [$p_path] ends by '/'"); $p_path = substr($p_path, 0, strlen($p_path)-1); //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Modified to [$p_path]"); } } // ----- Look for path to remove format (should end by /) if (($p_remove_path != "") && (substr($p_remove_path, -1) != '/')) { $p_remove_path .= '/'; } $p_remove_path_size = strlen($p_remove_path); // ----- Open the zip file //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Open file in binary read mode"); if (($v_result = $this->privOpenFd('rb')) != 1) { $this->privSwapBackMagicQuotes(); //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result); return $v_result; } // ----- Read the central directory informations $v_central_dir = array(); if (($v_result = $this->privReadEndCentralDir($v_central_dir)) != 1) { // ----- Close the zip file $this->privCloseFd(); $this->privSwapBackMagicQuotes(); //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result); return $v_result; } // ----- Start at beginning of Central Dir $v_pos_entry = $v_central_dir['offset']; // ----- Read each entry $j_start = 0; for ($i=0, $v_nb_extracted=0; $i<$v_central_dir['entries']; $i++) { //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Read next file header entry : '$i'"); // ----- Read next Central dir entry //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 4, "Position before rewind : ".ftell($this->zip_fd)."'"); @rewind($this->zip_fd); //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 4, "Position after rewind : ".ftell($this->zip_fd)."'"); if (@fseek($this->zip_fd, $v_pos_entry)) { // ----- Close the zip file $this->privCloseFd(); $this->privSwapBackMagicQuotes(); // ----- Error log PclZip::privErrorLog(PCLZIP_ERR_INVALID_ARCHIVE_ZIP, 'Invalid archive size'); // ----- Return //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, PclZip::errorCode(), PclZip::errorInfo()); return PclZip::errorCode(); } //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Position after fseek : ".ftell($this->zip_fd)."'"); // ----- Read the file header $v_header = array(); if (($v_result = $this->privReadCentralFileHeader($v_header)) != 1) { // ----- Close the zip file $this->privCloseFd(); $this->privSwapBackMagicQuotes(); //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result); return $v_result; } // ----- Store the index $v_header['index'] = $i; // ----- Store the file position $v_pos_entry = ftell($this->zip_fd); // ----- Look for the specific extract rules $v_extract = false; // ----- Look for extract by name rule if ( (isset($p_options[PCLZIP_OPT_BY_NAME])) && ($p_options[PCLZIP_OPT_BY_NAME] != 0)) { //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Extract with rule 'ByName'"); // ----- Look if the filename is in the list for ($j=0; ($j strlen($p_options[PCLZIP_OPT_BY_NAME][$j])) && (substr($v_header['stored_filename'], 0, strlen($p_options[PCLZIP_OPT_BY_NAME][$j])) == $p_options[PCLZIP_OPT_BY_NAME][$j])) { //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "The directory is in the file path"); $v_extract = true; } } // ----- Look for a filename elseif ($v_header['stored_filename'] == $p_options[PCLZIP_OPT_BY_NAME][$j]) { //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "The file is the right one."); $v_extract = true; } } } // ----- Look for extract by ereg rule else if ( (isset($p_options[PCLZIP_OPT_BY_EREG])) && ($p_options[PCLZIP_OPT_BY_EREG] != "")) { //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Extract by ereg '".$p_options[PCLZIP_OPT_BY_EREG]."'"); if (ereg($p_options[PCLZIP_OPT_BY_EREG], $v_header['stored_filename'])) { //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Filename match the regular expression"); $v_extract = true; } } // ----- Look for extract by preg rule else if ( (isset($p_options[PCLZIP_OPT_BY_PREG])) && ($p_options[PCLZIP_OPT_BY_PREG] != "")) { //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Extract with rule 'ByEreg'"); if (preg_match($p_options[PCLZIP_OPT_BY_PREG], $v_header['stored_filename'])) { //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Filename match the regular expression"); $v_extract = true; } } // ----- Look for extract by index rule else if ( (isset($p_options[PCLZIP_OPT_BY_INDEX])) && ($p_options[PCLZIP_OPT_BY_INDEX] != 0)) { //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Extract with rule 'ByIndex'"); // ----- Look if the index is in the list for ($j=$j_start; ($j=$p_options[PCLZIP_OPT_BY_INDEX][$j]['start']) && ($i<=$p_options[PCLZIP_OPT_BY_INDEX][$j]['end'])) { //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Found as part of an index range"); $v_extract = true; } if ($i>=$p_options[PCLZIP_OPT_BY_INDEX][$j]['end']) { //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Do not look this index range for next loop"); $j_start = $j+1; } if ($p_options[PCLZIP_OPT_BY_INDEX][$j]['start']>$i) { //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Index range is greater than index, stop loop"); break; } } } // ----- Look for no rule, which means extract all the archive else { //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Extract with no rule (extract all)"); $v_extract = true; } // ----- Check compression method if ( ($v_extract) && ( ($v_header['compression'] != 8) && ($v_header['compression'] != 0))) { //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "Unsupported compression method (".$v_header['compression'].")"); $v_header['status'] = 'unsupported_compression'; // ----- Look for PCLZIP_OPT_STOP_ON_ERROR if ( (isset($p_options[PCLZIP_OPT_STOP_ON_ERROR])) && ($p_options[PCLZIP_OPT_STOP_ON_ERROR]===true)) { //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "PCLZIP_OPT_STOP_ON_ERROR is selected, extraction will be stopped"); $this->privSwapBackMagicQuotes(); PclZip::privErrorLog(PCLZIP_ERR_UNSUPPORTED_COMPRESSION, "Filename '".$v_header['stored_filename']."' is " ."compressed by an unsupported compression " ."method (".$v_header['compression'].") "); //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, PclZip::errorCode(), PclZip::errorInfo()); return PclZip::errorCode(); } } // ----- Check encrypted files if (($v_extract) && (($v_header['flag'] & 1) == 1)) { //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "Unsupported file encryption"); $v_header['status'] = 'unsupported_encryption'; // ----- Look for PCLZIP_OPT_STOP_ON_ERROR if ( (isset($p_options[PCLZIP_OPT_STOP_ON_ERROR])) && ($p_options[PCLZIP_OPT_STOP_ON_ERROR]===true)) { //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "PCLZIP_OPT_STOP_ON_ERROR is selected, extraction will be stopped"); $this->privSwapBackMagicQuotes(); PclZip::privErrorLog(PCLZIP_ERR_UNSUPPORTED_ENCRYPTION, "Unsupported encryption for " ." filename '".$v_header['stored_filename'] ."'"); //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, PclZip::errorCode(), PclZip::errorInfo()); return PclZip::errorCode(); } } // ----- Look for real extraction if (($v_extract) && ($v_header['status'] != 'ok')) { //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "No need for extract"); $v_result = $this->privConvertHeader2FileInfo($v_header, $p_file_list[$v_nb_extracted++]); if ($v_result != 1) { $this->privCloseFd(); $this->privSwapBackMagicQuotes(); //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result); return $v_result; } $v_extract = false; } // ----- Look for real extraction if ($v_extract) { //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "Extracting file '".$v_header['filename']."', index '$i'"); // ----- Go to the file position //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 5, "Position before rewind : ".ftell($this->zip_fd)."'"); @rewind($this->zip_fd); //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 5, "Position after rewind : ".ftell($this->zip_fd)."'"); if (@fseek($this->zip_fd, $v_header['offset'])) { // ----- Close the zip file $this->privCloseFd(); $this->privSwapBackMagicQuotes(); // ----- Error log PclZip::privErrorLog(PCLZIP_ERR_INVALID_ARCHIVE_ZIP, 'Invalid archive size'); // ----- Return //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, PclZip::errorCode(), PclZip::errorInfo()); return PclZip::errorCode(); } //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 5, "Position after fseek : ".ftell($this->zip_fd)."'"); // ----- Look for extraction as string if ($p_options[PCLZIP_OPT_EXTRACT_AS_STRING]) { // ----- Extracting the file $v_result1 = $this->privExtractFileAsString($v_header, $v_string); if ($v_result1 < 1) { $this->privCloseFd(); $this->privSwapBackMagicQuotes(); //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result1); return $v_result1; } // ----- Get the only interesting attributes if (($v_result = $this->privConvertHeader2FileInfo($v_header, $p_file_list[$v_nb_extracted])) != 1) { // ----- Close the zip file $this->privCloseFd(); $this->privSwapBackMagicQuotes(); //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result); return $v_result; } // ----- Set the file content $p_file_list[$v_nb_extracted]['content'] = $v_string; // ----- Next extracted file $v_nb_extracted++; // ----- Look for user callback abort if ($v_result1 == 2) { break; } } // ----- Look for extraction in standard output elseif ( (isset($p_options[PCLZIP_OPT_EXTRACT_IN_OUTPUT])) && ($p_options[PCLZIP_OPT_EXTRACT_IN_OUTPUT])) { // ----- Extracting the file in standard output $v_result1 = $this->privExtractFileInOutput($v_header, $p_options); if ($v_result1 < 1) { $this->privCloseFd(); $this->privSwapBackMagicQuotes(); //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result1); return $v_result1; } // ----- Get the only interesting attributes if (($v_result = $this->privConvertHeader2FileInfo($v_header, $p_file_list[$v_nb_extracted++])) != 1) { $this->privCloseFd(); $this->privSwapBackMagicQuotes(); //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result); return $v_result; } // ----- Look for user callback abort if ($v_result1 == 2) { break; } } // ----- Look for normal extraction else { // ----- Extracting the file $v_result1 = $this->privExtractFile($v_header, $p_path, $p_remove_path, $p_remove_all_path, $p_options); if ($v_result1 < 1) { $this->privCloseFd(); $this->privSwapBackMagicQuotes(); //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result1); return $v_result1; } // ----- Get the only interesting attributes if (($v_result = $this->privConvertHeader2FileInfo($v_header, $p_file_list[$v_nb_extracted++])) != 1) { // ----- Close the zip file $this->privCloseFd(); $this->privSwapBackMagicQuotes(); //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result); return $v_result; } // ----- Look for user callback abort if ($v_result1 == 2) { break; } } } } // ----- Close the zip file $this->privCloseFd(); $this->privSwapBackMagicQuotes(); // ----- Return //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result); return $v_result; } // -------------------------------------------------------------------------------- // -------------------------------------------------------------------------------- // Function : privExtractFile() // Description : // Parameters : // Return Values : // // 1 : ... ? // PCLZIP_ERR_USER_ABORTED(2) : User ask for extraction stop in callback // -------------------------------------------------------------------------------- // http://doc.spip.org/@privExtractFile function privExtractFile(&$p_entry, $p_path, $p_remove_path, $p_remove_all_path, &$p_options) { //--(MAGIC-PclTrace)--//PclTraceFctStart(__FILE__, __LINE__, 'PclZip::privExtractFile', "path='$p_path', remove_path='$p_remove_path', remove_all_path='".($p_remove_all_path?'true':'false')."'"); $v_result=1; // ----- Read the file header if (($v_result = $this->privReadFileHeader($v_header)) != 1) { // ----- Return //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result); return $v_result; } //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "Found file '".$v_header['filename']."', size '".$v_header['size']."'"); // ----- Check that the file header is coherent with $p_entry info if ($this->privCheckFileHeaders($v_header, $p_entry) != 1) { // TBC } // ----- Look for all path to remove if ($p_remove_all_path == true) { // ----- Look for folder entry that not need to be extracted if (($p_entry['external']&0x00000010)==0x00000010) { //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "The entry is a folder : need to be filtered"); $p_entry['status'] = "filtered"; //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result); return $v_result; } //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "All path is removed"); // ----- Get the basename of the path $p_entry['filename'] = basename($p_entry['filename']); } // ----- Look for path to remove else if ($p_remove_path != "") { //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Look for some path to remove"); if (PclZipUtilPathInclusion($p_remove_path, $p_entry['filename']) == 2) { //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "The folder is the same as the removed path '".$p_entry['filename']."'"); // ----- Change the file status $p_entry['status'] = "filtered"; // ----- Return //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result); return $v_result; } $p_remove_path_size = strlen($p_remove_path); if (substr($p_entry['filename'], 0, $p_remove_path_size) == $p_remove_path) { //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Found path '$p_remove_path' to remove in file '".$p_entry['filename']."'"); // ----- Remove the path $p_entry['filename'] = substr($p_entry['filename'], $p_remove_path_size); //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Resulting file is '".$p_entry['filename']."'"); } } // ----- Add the path if ($p_path != '') { $p_entry['filename'] = $p_path."/".$p_entry['filename']; } // ----- Check a base_dir_restriction if (isset($p_options[PCLZIP_OPT_EXTRACT_DIR_RESTRICTION])) { //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "Check the extract directory restriction"); $v_inclusion = PclZipUtilPathInclusion($p_options[PCLZIP_OPT_EXTRACT_DIR_RESTRICTION], $p_entry['filename']); if ($v_inclusion == 0) { //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "PCLZIP_OPT_EXTRACT_DIR_RESTRICTION is selected, file is outside restriction"); PclZip::privErrorLog(PCLZIP_ERR_DIRECTORY_RESTRICTION, "Filename '".$p_entry['filename']."' is " ."outside PCLZIP_OPT_EXTRACT_DIR_RESTRICTION"); //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, PclZip::errorCode(), PclZip::errorInfo()); return PclZip::errorCode(); } } // ----- Look for pre-extract callback if (isset($p_options[PCLZIP_CB_PRE_EXTRACT])) { //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "A pre-callback '".$p_options[PCLZIP_CB_PRE_EXTRACT]."()') is defined for the extraction"); // ----- Generate a local information $v_local_header = array(); $this->privConvertHeader2FileInfo($p_entry, $v_local_header); // ----- Call the callback // Here I do not use call_user_func() because I need to send a reference to the // header. eval('$v_result = '.$p_options[PCLZIP_CB_PRE_EXTRACT].'(PCLZIP_CB_PRE_EXTRACT, $v_local_header);'); if ($v_result == 0) { // ----- Change the file status $p_entry['status'] = "skipped"; $v_result = 1; } // ----- Look for abort result if ($v_result == 2) { //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "User callback abort the extraction"); // ----- This status is internal and will be changed in 'skipped' $p_entry['status'] = "aborted"; $v_result = PCLZIP_ERR_USER_ABORTED; } // ----- Update the informations // Only some fields can be modified $p_entry['filename'] = $v_local_header['filename']; //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "New filename is '".$p_entry['filename']."'"); } //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "Extracting file (with path) '".$p_entry['filename']."', size '$v_header[size]'"); // ----- Look if extraction should be done if ($p_entry['status'] == 'ok') { // ----- Look for specific actions while the file exist if (file_exists($p_entry['filename'])) { //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "File '".$p_entry['filename']."' already exists"); // ----- Look if file is a directory if (is_dir($p_entry['filename'])) { //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "Existing file '".$p_entry['filename']."' is a directory"); // ----- Change the file status $p_entry['status'] = "already_a_directory"; // ----- Look for PCLZIP_OPT_STOP_ON_ERROR // For historical reason first PclZip implementation does not stop // when this kind of error occurs. if ( (isset($p_options[PCLZIP_OPT_STOP_ON_ERROR])) && ($p_options[PCLZIP_OPT_STOP_ON_ERROR]===true)) { //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "PCLZIP_OPT_STOP_ON_ERROR is selected, extraction will be stopped"); PclZip::privErrorLog(PCLZIP_ERR_ALREADY_A_DIRECTORY, "Filename '".$p_entry['filename']."' is " ."already used by an existing directory"); //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, PclZip::errorCode(), PclZip::errorInfo()); return PclZip::errorCode(); } } // ----- Look if file is write protected else if (!is_writeable($p_entry['filename'])) { //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "Existing file '".$p_entry['filename']."' is write protected"); // ----- Change the file status $p_entry['status'] = "write_protected"; // ----- Look for PCLZIP_OPT_STOP_ON_ERROR // For historical reason first PclZip implementation does not stop // when this kind of error occurs. if ( (isset($p_options[PCLZIP_OPT_STOP_ON_ERROR])) && ($p_options[PCLZIP_OPT_STOP_ON_ERROR]===true)) { //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "PCLZIP_OPT_STOP_ON_ERROR is selected, extraction will be stopped"); PclZip::privErrorLog(PCLZIP_ERR_WRITE_OPEN_FAIL, "Filename '".$p_entry['filename']."' exists " ."and is write protected"); //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, PclZip::errorCode(), PclZip::errorInfo()); return PclZip::errorCode(); } } // ----- Look if the extracted file is older else if (filemtime($p_entry['filename']) > $p_entry['mtime']) { //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "Existing file '".$p_entry['filename']."' is newer (".date("l dS of F Y h:i:s A", filemtime($p_entry['filename'])).") than the extracted file (".date("l dS of F Y h:i:s A", $p_entry['mtime']).")"); // ----- Change the file status if ( (isset($p_options[PCLZIP_OPT_REPLACE_NEWER])) && ($p_options[PCLZIP_OPT_REPLACE_NEWER]===true)) { //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "PCLZIP_OPT_REPLACE_NEWER is selected, file will be replaced"); } else { //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "File will not be replaced"); $p_entry['status'] = "newer_exist"; // ----- Look for PCLZIP_OPT_STOP_ON_ERROR // For historical reason first PclZip implementation does not stop // when this kind of error occurs. if ( (isset($p_options[PCLZIP_OPT_STOP_ON_ERROR])) && ($p_options[PCLZIP_OPT_STOP_ON_ERROR]===true)) { //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "PCLZIP_OPT_STOP_ON_ERROR is selected, extraction will be stopped"); PclZip::privErrorLog(PCLZIP_ERR_WRITE_OPEN_FAIL, "Newer version of '".$p_entry['filename']."' exists " ."and option PCLZIP_OPT_REPLACE_NEWER is not selected"); //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, PclZip::errorCode(), PclZip::errorInfo()); return PclZip::errorCode(); } } } else { //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "Existing file '".$p_entry['filename']."' is older than the extrated one - will be replaced by the extracted one (".date("l dS of F Y h:i:s A", filemtime($p_entry['filename'])).") than the extracted file (".date("l dS of F Y h:i:s A", $p_entry['mtime']).")"); } } // ----- Check the directory availability and create it if necessary else { if ((($p_entry['external']&0x00000010)==0x00000010) || (substr($p_entry['filename'], -1) == '/')) $v_dir_to_check = $p_entry['filename']; else if (!strstr($p_entry['filename'], "/")) $v_dir_to_check = ""; else $v_dir_to_check = dirname($p_entry['filename']); if (($v_result = $this->privDirCheck($v_dir_to_check, (($p_entry['external']&0x00000010)==0x00000010))) != 1) { //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "Unable to create path for '".$p_entry['filename']."'"); // ----- Change the file status $p_entry['status'] = "path_creation_fail"; // ----- Return ////--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result); //return $v_result; $v_result = 1; } } } // ----- Look if extraction should be done if ($p_entry['status'] == 'ok') { // ----- Look for chmod option if (is_dir($p_entry['filename']) AND isset($p_options[PCLZIP_OPT_SET_CHMOD])) { //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "chmod option activated '".$p_options[PCLZIP_OPT_SET_CHMOD]."'"); // ----- Change the mode of the file @chmod($p_entry['filename'], $p_options[PCLZIP_OPT_SET_CHMOD]); } // ----- Do the extraction (if not a folder) if (!(($p_entry['external']&0x00000010)==0x00000010)) { // ----- Look for not compressed file if ($p_entry['compression'] == 0) { //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "Extracting an un-compressed file"); // ----- Opening destination file if (($v_dest_file = @fopen($p_entry['filename'], 'wb')) == 0) { //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "Error while opening '".$p_entry['filename']."' in write binary mode"); // ----- Change the file status $p_entry['status'] = "write_error"; // ----- Return //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result); return $v_result; } //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "Read '".$p_entry['size']."' bytes"); // ----- Read the file by PCLZIP_READ_BLOCK_SIZE octets blocks $v_size = $p_entry['compressed_size']; while ($v_size != 0) { $v_read_size = ($v_size < PCLZIP_READ_BLOCK_SIZE ? $v_size : PCLZIP_READ_BLOCK_SIZE); //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "Read $v_read_size bytes"); $v_buffer = @fread($this->zip_fd, $v_read_size); /* Try to speed up the code $v_binary_data = pack('a'.$v_read_size, $v_buffer); @fwrite($v_dest_file, $v_binary_data, $v_read_size); */ @fwrite($v_dest_file, $v_buffer, $v_read_size); $v_size -= $v_read_size; } // ----- Closing the destination file fclose($v_dest_file); // ----- Change the file mtime touch($p_entry['filename'], $p_entry['mtime']); } else { //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "Extracting a compressed file (Compression method ".$p_entry['compression'].")"); // ----- TBC // Need to be finished if (($p_entry['flag'] & 1) == 1) { //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "File is encrypted"); /* // ----- Read the encryption header //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 5, "Read 12 encryption header bytes"); $v_encryption_header = @fread($this->zip_fd, 12); // ----- Read the encrypted & compressed file in a buffer //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 5, "Read '".($p_entry['compressed_size']-12)."' compressed & encrypted bytes"); $v_buffer = @fread($this->zip_fd, $p_entry['compressed_size']-12); // ----- Decrypt the buffer $this->privDecrypt($v_encryption_header, $v_buffer, $p_entry['compressed_size']-12, $p_entry['crc']); //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 5, "Buffer is '".$v_buffer."'"); */ } else { //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 5, "Read '".$p_entry['compressed_size']."' compressed bytes"); // ----- Read the compressed file in a buffer (one shot) $v_buffer = @fread($this->zip_fd, $p_entry['compressed_size']); } // ----- Decompress the file $v_file_content = @gzinflate($v_buffer); unset($v_buffer); if ($v_file_content === FALSE) { //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "Unable to inflate compressed file"); // ----- Change the file status // TBC $p_entry['status'] = "error"; //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result); return $v_result; } // ----- Opening destination file if (($v_dest_file = @fopen($p_entry['filename'], 'wb')) == 0) { //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "Error while opening '".$p_entry['filename']."' in write binary mode"); // ----- Change the file status $p_entry['status'] = "write_error"; //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result); return $v_result; } // ----- Write the uncompressed data @fwrite($v_dest_file, $v_file_content, $p_entry['size']); unset($v_file_content); // ----- Closing the destination file @fclose($v_dest_file); // ----- Change the file mtime @touch($p_entry['filename'], $p_entry['mtime']); } // ----- Look for chmod option if (isset($p_options[PCLZIP_OPT_SET_CHMOD])) { //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "chmod option activated '".$p_options[PCLZIP_OPT_SET_CHMOD]."'"); // ----- Change the mode of the file @chmod($p_entry['filename'], $p_options[PCLZIP_OPT_SET_CHMOD] & ~0111); } //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "Extraction done"); } } // ----- Change abort status if ($p_entry['status'] == "aborted") { $p_entry['status'] = "skipped"; } // ----- Look for post-extract callback elseif (isset($p_options[PCLZIP_CB_POST_EXTRACT])) { //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "A post-callback '".$p_options[PCLZIP_CB_POST_EXTRACT]."()') is defined for the extraction"); // ----- Generate a local information $v_local_header = array(); $this->privConvertHeader2FileInfo($p_entry, $v_local_header); // ----- Call the callback // Here I do not use call_user_func() because I need to send a reference to the // header. eval('$v_result = '.$p_options[PCLZIP_CB_POST_EXTRACT].'(PCLZIP_CB_POST_EXTRACT, $v_local_header);'); // ----- Look for abort result if ($v_result == 2) { //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "User callback abort the extraction"); $v_result = PCLZIP_ERR_USER_ABORTED; } } // ----- Return //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result); return $v_result; } // -------------------------------------------------------------------------------- // -------------------------------------------------------------------------------- // Function : privExtractFileInOutput() // Description : // Parameters : // Return Values : // -------------------------------------------------------------------------------- // http://doc.spip.org/@privExtractFileInOutput function privExtractFileInOutput(&$p_entry, &$p_options) { //--(MAGIC-PclTrace)--//PclTraceFctStart(__FILE__, __LINE__, 'PclZip::privExtractFileInOutput', ""); $v_result=1; // ----- Read the file header if (($v_result = $this->privReadFileHeader($v_header)) != 1) { //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result); return $v_result; } //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "Found file '".$v_header['filename']."', size '".$v_header['size']."'"); // ----- Check that the file header is coherent with $p_entry info if ($this->privCheckFileHeaders($v_header, $p_entry) != 1) { // TBC } // ----- Look for pre-extract callback if (isset($p_options[PCLZIP_CB_PRE_EXTRACT])) { //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "A pre-callback '".$p_options[PCLZIP_CB_PRE_EXTRACT]."()') is defined for the extraction"); // ----- Generate a local information $v_local_header = array(); $this->privConvertHeader2FileInfo($p_entry, $v_local_header); // ----- Call the callback // Here I do not use call_user_func() because I need to send a reference to the // header. eval('$v_result = '.$p_options[PCLZIP_CB_PRE_EXTRACT].'(PCLZIP_CB_PRE_EXTRACT, $v_local_header);'); if ($v_result == 0) { // ----- Change the file status $p_entry['status'] = "skipped"; $v_result = 1; } // ----- Look for abort result if ($v_result == 2) { //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "User callback abort the extraction"); // ----- This status is internal and will be changed in 'skipped' $p_entry['status'] = "aborted"; $v_result = PCLZIP_ERR_USER_ABORTED; } // ----- Update the informations // Only some fields can be modified $p_entry['filename'] = $v_local_header['filename']; //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "New filename is '".$p_entry['filename']."'"); } // ----- Trace //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "Extracting file (with path) '".$p_entry['filename']."', size '$v_header[size]'"); // ----- Look if extraction should be done if ($p_entry['status'] == 'ok') { // ----- Do the extraction (if not a folder) if (!(($p_entry['external']&0x00000010)==0x00000010)) { // ----- Look for not compressed file if ($p_entry['compressed_size'] == $p_entry['size']) { //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "Extracting an un-compressed file"); //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "Reading '".$p_entry['size']."' bytes"); // ----- Read the file in a buffer (one shot) $v_buffer = @fread($this->zip_fd, $p_entry['compressed_size']); // ----- Send the file to the output echo $v_buffer; unset($v_buffer); } else { //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "Extracting a compressed file"); //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 5, "Reading '".$p_entry['size']."' bytes"); // ----- Read the compressed file in a buffer (one shot) $v_buffer = @fread($this->zip_fd, $p_entry['compressed_size']); // ----- Decompress the file $v_file_content = gzinflate($v_buffer); unset($v_buffer); // ----- Send the file to the output echo $v_file_content; unset($v_file_content); } //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "Extraction done"); } } // ----- Change abort status if ($p_entry['status'] == "aborted") { $p_entry['status'] = "skipped"; } // ----- Look for post-extract callback elseif (isset($p_options[PCLZIP_CB_POST_EXTRACT])) { //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "A post-callback '".$p_options[PCLZIP_CB_POST_EXTRACT]."()') is defined for the extraction"); // ----- Generate a local information $v_local_header = array(); $this->privConvertHeader2FileInfo($p_entry, $v_local_header); // ----- Call the callback // Here I do not use call_user_func() because I need to send a reference to the // header. eval('$v_result = '.$p_options[PCLZIP_CB_POST_EXTRACT].'(PCLZIP_CB_POST_EXTRACT, $v_local_header);'); // ----- Look for abort result if ($v_result == 2) { //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "User callback abort the extraction"); $v_result = PCLZIP_ERR_USER_ABORTED; } } //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result); return $v_result; } // -------------------------------------------------------------------------------- // -------------------------------------------------------------------------------- // Function : privExtractFileAsString() // Description : // Parameters : // Return Values : // -------------------------------------------------------------------------------- // http://doc.spip.org/@privExtractFileAsString function privExtractFileAsString(&$p_entry, &$p_string) { //--(MAGIC-PclTrace)--//PclTraceFctStart(__FILE__, __LINE__, 'PclZip::privExtractFileAsString', "p_entry['filename']='".$p_entry['filename']."'"); $v_result=1; // ----- Read the file header $v_header = array(); if (($v_result = $this->privReadFileHeader($v_header)) != 1) { // ----- Return //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result); return $v_result; } //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "Found file '".$v_header['filename']."', size '".$v_header['size']."'"); // ----- Check that the file header is coherent with $p_entry info if ($this->privCheckFileHeaders($v_header, $p_entry) != 1) { // TBC } //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "Extracting file in string (with path) '".$p_entry['filename']."', size '$v_header[size]'"); // ----- Do the extraction (if not a folder) if (!(($p_entry['external']&0x00000010)==0x00000010)) { // ----- Look for not compressed file // if ($p_entry['compressed_size'] == $p_entry['size']) if ($p_entry['compression'] == 0) { //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "Extracting an un-compressed file"); //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "Reading '".$p_entry['size']."' bytes"); // ----- Reading the file $p_string = @fread($this->zip_fd, $p_entry['compressed_size']); } else { //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "Extracting a compressed file (compression method '".$p_entry['compression']."')"); // ----- Reading the file $v_data = @fread($this->zip_fd, $p_entry['compressed_size']); // ----- Decompress the file if (($p_string = @gzinflate($v_data)) === FALSE) { // TBC } } // ----- Trace //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "Extraction done"); } else { // TBC : error : can not extract a folder in a string } // ----- Return //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result); return $v_result; } // -------------------------------------------------------------------------------- // -------------------------------------------------------------------------------- // Function : privReadFileHeader() // Description : // Parameters : // Return Values : // -------------------------------------------------------------------------------- // http://doc.spip.org/@privReadFileHeader function privReadFileHeader(&$p_header) { //--(MAGIC-PclTrace)--//PclTraceFctStart(__FILE__, __LINE__, "PclZip::privReadFileHeader", ""); $v_result=1; // ----- Read the 4 bytes signature $v_binary_data = @fread($this->zip_fd, 4); //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Binary data is : '".sprintf("%08x", $v_binary_data)."'"); $v_data = unpack('Vid', $v_binary_data); //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Binary signature is : '".sprintf("0x%08x", $v_data['id'])."'"); // ----- Check signature if ($v_data['id'] != 0x04034b50) { //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Invalid File header"); // ----- Error log PclZip::privErrorLog(PCLZIP_ERR_BAD_FORMAT, 'Invalid archive structure'); // ----- Return //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, PclZip::errorCode(), PclZip::errorInfo()); return PclZip::errorCode(); } // ----- Read the first 42 bytes of the header $v_binary_data = fread($this->zip_fd, 26); // ----- Look for invalid block size if (strlen($v_binary_data) != 26) { $p_header['filename'] = ""; $p_header['status'] = "invalid_header"; //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "Invalid block size : ".strlen($v_binary_data)); // ----- Error log PclZip::privErrorLog(PCLZIP_ERR_BAD_FORMAT, "Invalid block size : ".strlen($v_binary_data)); // ----- Return //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, PclZip::errorCode(), PclZip::errorInfo()); return PclZip::errorCode(); } // ----- Extract the values //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "Header : '".$v_binary_data."'"); //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "Header (Hex) : '".bin2hex($v_binary_data)."'"); $v_data = unpack('vversion/vflag/vcompression/vmtime/vmdate/Vcrc/Vcompressed_size/Vsize/vfilename_len/vextra_len', $v_binary_data); // ----- Get filename //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "File name length : ".$v_data['filename_len']); $p_header['filename'] = fread($this->zip_fd, $v_data['filename_len']); //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, 'Filename : \''.$p_header['filename'].'\''); // ----- Get extra_fields //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Extra field length : ".$v_data['extra_len']); if ($v_data['extra_len'] != 0) { $p_header['extra'] = fread($this->zip_fd, $v_data['extra_len']); } else { $p_header['extra'] = ''; } //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, 'Extra field : \''.bin2hex($p_header['extra']).'\''); // ----- Extract properties $p_header['version_extracted'] = $v_data['version']; //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 4, 'Version need to extract : ('.$p_header['version_extracted'].') \''.($p_header['version_extracted']/10).'.'.($p_header['version_extracted']%10).'\''); $p_header['compression'] = $v_data['compression']; //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, 'Compression method : \''.$p_header['compression'].'\''); $p_header['size'] = $v_data['size']; //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, 'Size : \''.$p_header['size'].'\''); $p_header['compressed_size'] = $v_data['compressed_size']; //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, 'Compressed Size : \''.$p_header['compressed_size'].'\''); $p_header['crc'] = $v_data['crc']; //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, 'CRC : \''.sprintf("0x%X", $p_header['crc']).'\''); $p_header['flag'] = $v_data['flag']; //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, 'Flag : \''.$p_header['flag'].'\''); $p_header['filename_len'] = $v_data['filename_len']; //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, 'Filename_len : \''.$p_header['filename_len'].'\''); // ----- Recuperate date in UNIX format $p_header['mdate'] = $v_data['mdate']; $p_header['mtime'] = $v_data['mtime']; if ($p_header['mdate'] && $p_header['mtime']) { // ----- Extract time $v_hour = ($p_header['mtime'] & 0xF800) >> 11; $v_minute = ($p_header['mtime'] & 0x07E0) >> 5; $v_seconde = ($p_header['mtime'] & 0x001F)*2; // ----- Extract date $v_year = (($p_header['mdate'] & 0xFE00) >> 9) + 1980; $v_month = ($p_header['mdate'] & 0x01E0) >> 5; $v_day = $p_header['mdate'] & 0x001F; // ----- Get UNIX date format $p_header['mtime'] = mktime($v_hour, $v_minute, $v_seconde, $v_month, $v_day, $v_year); //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, 'Date : \''.date("d/m/y H:i:s", $p_header['mtime']).'\''); } else { $p_header['mtime'] = time(); //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, 'Date is actual : \''.date("d/m/y H:i:s", $p_header['mtime']).'\''); } // TBC //for(reset($v_data); $key = key($v_data); next($v_data)) { // //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Attribut[$key] = ".$v_data[$key]); //} // ----- Set the stored filename $p_header['stored_filename'] = $p_header['filename']; // ----- Set the status field $p_header['status'] = "ok"; // ----- Return //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result); return $v_result; } // -------------------------------------------------------------------------------- // -------------------------------------------------------------------------------- // Function : privReadCentralFileHeader() // Description : // Parameters : // Return Values : // -------------------------------------------------------------------------------- // http://doc.spip.org/@privReadCentralFileHeader function privReadCentralFileHeader(&$p_header) { //--(MAGIC-PclTrace)--//PclTraceFctStart(__FILE__, __LINE__, "PclZip::privReadCentralFileHeader", ""); $v_result=1; // ----- Read the 4 bytes signature $v_binary_data = @fread($this->zip_fd, 4); //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Binary data is : '".sprintf("%08x", $v_binary_data)."'"); $v_data = unpack('Vid', $v_binary_data); //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Binary signature is : '".sprintf("0x%08x", $v_data['id'])."'"); // ----- Check signature if ($v_data['id'] != 0x02014b50) { //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Invalid Central Dir File signature"); // ----- Error log PclZip::privErrorLog(PCLZIP_ERR_BAD_FORMAT, 'Invalid archive structure'); // ----- Return //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, PclZip::errorCode(), PclZip::errorInfo()); return PclZip::errorCode(); } // ----- Read the first 42 bytes of the header $v_binary_data = fread($this->zip_fd, 42); // ----- Look for invalid block size if (strlen($v_binary_data) != 42) { $p_header['filename'] = ""; $p_header['status'] = "invalid_header"; //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "Invalid block size : ".strlen($v_binary_data)); // ----- Error log PclZip::privErrorLog(PCLZIP_ERR_BAD_FORMAT, "Invalid block size : ".strlen($v_binary_data)); // ----- Return //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, PclZip::errorCode(), PclZip::errorInfo()); return PclZip::errorCode(); } // ----- Extract the values //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 5, "Header : '".$v_binary_data."'"); //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 5, "Header (Hex) : '".bin2hex($v_binary_data)."'"); $p_header = unpack('vversion/vversion_extracted/vflag/vcompression/vmtime/vmdate/Vcrc/Vcompressed_size/Vsize/vfilename_len/vextra_len/vcomment_len/vdisk/vinternal/Vexternal/Voffset', $v_binary_data); // ----- Get filename //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 4, "File name length : ".$p_header['filename_len']); if ($p_header['filename_len'] != 0) $p_header['filename'] = fread($this->zip_fd, $p_header['filename_len']); else $p_header['filename'] = ''; //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 4, 'Filename : \''.$p_header['filename'].'\''); // ----- Get extra //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 4, "Extra length : ".$p_header['extra_len']); if ($p_header['extra_len'] != 0) $p_header['extra'] = fread($this->zip_fd, $p_header['extra_len']); else $p_header['extra'] = ''; //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 4, 'Extra : \''.$p_header['extra'].'\''); // ----- Get comment //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 4, "Comment length : ".$p_header['comment_len']); if ($p_header['comment_len'] != 0) $p_header['comment'] = fread($this->zip_fd, $p_header['comment_len']); else $p_header['comment'] = ''; //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 4, 'Comment : \''.$p_header['comment'].'\''); // ----- Extract properties //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 4, 'Version : \''.($p_header['version']/10).'.'.($p_header['version']%10).'\''); //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 4, 'Version need to extract : \''.($p_header['version_extracted']/10).'.'.($p_header['version_extracted']%10).'\''); //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 4, 'Size : \''.$p_header['size'].'\''); //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 4, 'Compressed Size : \''.$p_header['compressed_size'].'\''); //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 4, 'CRC : \''.sprintf("0x%X", $p_header['crc']).'\''); //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 4, 'Flag : \''.$p_header['flag'].'\''); //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 4, 'Offset : \''.$p_header['offset'].'\''); // ----- Recuperate date in UNIX format if ($p_header['mdate'] && $p_header['mtime']) { // ----- Extract time $v_hour = ($p_header['mtime'] & 0xF800) >> 11; $v_minute = ($p_header['mtime'] & 0x07E0) >> 5; $v_seconde = ($p_header['mtime'] & 0x001F)*2; // ----- Extract date $v_year = (($p_header['mdate'] & 0xFE00) >> 9) + 1980; $v_month = ($p_header['mdate'] & 0x01E0) >> 5; $v_day = $p_header['mdate'] & 0x001F; // ----- Get UNIX date format $p_header['mtime'] = mktime($v_hour, $v_minute, $v_seconde, $v_month, $v_day, $v_year); //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 4, 'Date : \''.date("d/m/y H:i:s", $p_header['mtime']).'\''); } else { $p_header['mtime'] = time(); //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 4, 'Date is actual : \''.date("d/m/y H:i:s", $p_header['mtime']).'\''); } // ----- Set the stored filename $p_header['stored_filename'] = $p_header['filename']; // ----- Set default status to ok $p_header['status'] = 'ok'; // ----- Look if it is a directory //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 5, "Internal (Hex) : '".sprintf("Ox%04X", $p_header['internal'])."'"); //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 4, "External (Hex) : '".sprintf("Ox%04X", $p_header['external'])."' (".(($p_header['external']&0x00000010)==0x00000010?'is a folder':'is a file').')'); if (substr($p_header['filename'], -1) == '/') { //$p_header['external'] = 0x41FF0010; $p_header['external'] = 0x00000010; //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 4, 'Force folder external : \''.sprintf("Ox%04X", $p_header['external']).'\''); } //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, 'Header of filename : \''.$p_header['filename'].'\''); // ----- Return //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result); return $v_result; } // -------------------------------------------------------------------------------- // -------------------------------------------------------------------------------- // Function : privCheckFileHeaders() // Description : // Parameters : // Return Values : // 1 on success, // 0 on error; // -------------------------------------------------------------------------------- // http://doc.spip.org/@privCheckFileHeaders function privCheckFileHeaders(&$p_local_header, &$p_central_header) { //--(MAGIC-PclTrace)--//PclTraceFctStart(__FILE__, __LINE__, "PclZip::privCheckFileHeaders", ""); $v_result=1; // ----- Check the static values // TBC if ($p_local_header['filename'] != $p_central_header['filename']) { //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, 'Bad check "filename" : TBC To Be Completed'); } if ($p_local_header['version_extracted'] != $p_central_header['version_extracted']) { //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, 'Bad check "version_extracted" : TBC To Be Completed'); } if ($p_local_header['flag'] != $p_central_header['flag']) { //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, 'Bad check "flag" : TBC To Be Completed'); } if ($p_local_header['compression'] != $p_central_header['compression']) { //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, 'Bad check "compression" : TBC To Be Completed'); } if ($p_local_header['mtime'] != $p_central_header['mtime']) { //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, 'Bad check "mtime" : TBC To Be Completed'); } if ($p_local_header['filename_len'] != $p_central_header['filename_len']) { //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, 'Bad check "filename_len" : TBC To Be Completed'); } // ----- Look for flag bit 3 if (($p_local_header['flag'] & 8) == 8) { //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, 'Purpose bit flag bit 3 set !'); //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, 'File size, compression size and crc found in central header'); $p_local_header['size'] = $p_central_header['size']; //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, 'Size : \''.$p_local_header['size'].'\''); $p_local_header['compressed_size'] = $p_central_header['compressed_size']; //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, 'Compressed Size : \''.$p_local_header['compressed_size'].'\''); $p_local_header['crc'] = $p_central_header['crc']; //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, 'CRC : \''.sprintf("0x%X", $p_local_header['crc']).'\''); } // ----- Return //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result); return $v_result; } // -------------------------------------------------------------------------------- // -------------------------------------------------------------------------------- // Function : privReadEndCentralDir() // Description : // Parameters : // Return Values : // -------------------------------------------------------------------------------- // http://doc.spip.org/@privReadEndCentralDir function privReadEndCentralDir(&$p_central_dir) { //--(MAGIC-PclTrace)--//PclTraceFctStart(__FILE__, __LINE__, "PclZip::privReadEndCentralDir", ""); $v_result=1; // ----- Go to the end of the zip file $v_size = filesize($this->zipname); //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "Size of the file :$v_size"); @fseek($this->zip_fd, $v_size); //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 4, 'Position at end of zip file : \''.ftell($this->zip_fd).'\''); if (@ftell($this->zip_fd) != $v_size) { // ----- Error log PclZip::privErrorLog(PCLZIP_ERR_BAD_FORMAT, 'Unable to go to the end of the archive \''.$this->zipname.'\''); // ----- Return //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, PclZip::errorCode(), PclZip::errorInfo()); return PclZip::errorCode(); } // ----- First try : look if this is an archive with no commentaries (most of the time) // in this case the end of central dir is at 22 bytes of the file end $v_found = 0; if ($v_size > 26) { //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 4, 'Look for central dir with no comment'); @fseek($this->zip_fd, $v_size-22); //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 4, 'Position after min central position : \''.ftell($this->zip_fd).'\''); if (($v_pos = @ftell($this->zip_fd)) != ($v_size-22)) { // ----- Error log PclZip::privErrorLog(PCLZIP_ERR_BAD_FORMAT, 'Unable to seek back to the middle of the archive \''.$this->zipname.'\''); // ----- Return //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, PclZip::errorCode(), PclZip::errorInfo()); return PclZip::errorCode(); } // ----- Read for bytes $v_binary_data = @fread($this->zip_fd, 4); //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 5, "Binary data is : '".sprintf("%08x", $v_binary_data)."'"); $v_data = @unpack('Vid', $v_binary_data); //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Binary signature is : '".sprintf("0x%08x", $v_data['id'])."'"); // ----- Check signature if ($v_data['id'] == 0x06054b50) { //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "Found central dir at the default position."); $v_found = 1; } $v_pos = ftell($this->zip_fd); } // ----- Go back to the maximum possible size of the Central Dir End Record if (!$v_found) { //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 4, 'Start extended search of end central dir'); $v_maximum_size = 65557; // 0xFFFF + 22; if ($v_maximum_size > $v_size) $v_maximum_size = $v_size; @fseek($this->zip_fd, $v_size-$v_maximum_size); if (@ftell($this->zip_fd) != ($v_size-$v_maximum_size)) { // ----- Error log PclZip::privErrorLog(PCLZIP_ERR_BAD_FORMAT, 'Unable to seek back to the middle of the archive \''.$this->zipname.'\''); // ----- Return //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, PclZip::errorCode(), PclZip::errorInfo()); return PclZip::errorCode(); } //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 4, 'Position after max central position : \''.ftell($this->zip_fd).'\''); // ----- Read byte per byte in order to find the signature $v_pos = ftell($this->zip_fd); $v_bytes = 0x00000000; while ($v_pos < $v_size) { // ----- Read a byte $v_byte = @fread($this->zip_fd, 1); // ----- Add the byte $v_bytes = ($v_bytes << 8) | Ord($v_byte); // ----- Compare the bytes if ($v_bytes == 0x504b0506) { //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 4, 'Found End Central Dir signature at position : \''.ftell($this->zip_fd).'\''); $v_pos++; break; } $v_pos++; } // ----- Look if not found end of central dir if ($v_pos == $v_size) { //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "Unable to find End of Central Dir Record signature"); // ----- Error log PclZip::privErrorLog(PCLZIP_ERR_BAD_FORMAT, "Unable to find End of Central Dir Record signature"); // ----- Return //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, PclZip::errorCode(), PclZip::errorInfo()); return PclZip::errorCode(); } } // ----- Read the first 18 bytes of the header $v_binary_data = fread($this->zip_fd, 18); // ----- Look for invalid block size if (strlen($v_binary_data) != 18) { //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "Invalid End of Central Dir Record size : ".strlen($v_binary_data)); // ----- Error log PclZip::privErrorLog(PCLZIP_ERR_BAD_FORMAT, "Invalid End of Central Dir Record size : ".strlen($v_binary_data)); // ----- Return //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, PclZip::errorCode(), PclZip::errorInfo()); return PclZip::errorCode(); } // ----- Extract the values ////--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 4, "Central Dir Record : '".$v_binary_data."'"); ////--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 4, "Central Dir Record (Hex) : '".bin2hex($v_binary_data)."'"); $v_data = unpack('vdisk/vdisk_start/vdisk_entries/ventries/Vsize/Voffset/vcomment_size', $v_binary_data); // ----- Check the global size //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Comment length : ".$v_data['comment_size']); if (($v_pos + $v_data['comment_size'] + 18) != $v_size) { //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "The central dir is not at the end of the archive. Some trailing bytes exists after the archive."); // ----- Removed in release 2.2 see readme file // The check of the file size is a little too strict. // Some bugs where found when a zip is encrypted/decrypted with 'crypt'. // While decrypted, zip has training 0 bytes if (0) { // ----- Error log PclZip::privErrorLog(PCLZIP_ERR_BAD_FORMAT, 'The central dir is not at the end of the archive.' .' Some trailing bytes exists after the archive.'); // ----- Return //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, PclZip::errorCode(), PclZip::errorInfo()); return PclZip::errorCode(); } } // ----- Get comment if ($v_data['comment_size'] != 0) $p_central_dir['comment'] = fread($this->zip_fd, $v_data['comment_size']); else $p_central_dir['comment'] = ''; //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, 'Comment : \''.$p_central_dir['comment'].'\''); $p_central_dir['entries'] = $v_data['entries']; //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, 'Nb of entries : \''.$p_central_dir['entries'].'\''); $p_central_dir['disk_entries'] = $v_data['disk_entries']; //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, 'Nb of entries for this disk : \''.$p_central_dir['disk_entries'].'\''); $p_central_dir['offset'] = $v_data['offset']; //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, 'Offset of Central Dir : \''.$p_central_dir['offset'].'\''); $p_central_dir['size'] = $v_data['size']; //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, 'Size of Central Dir : \''.$p_central_dir['size'].'\''); $p_central_dir['disk'] = $v_data['disk']; //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, 'Disk number : \''.$p_central_dir['disk'].'\''); $p_central_dir['disk_start'] = $v_data['disk_start']; //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, 'Start disk number : \''.$p_central_dir['disk_start'].'\''); // TBC //for(reset($p_central_dir); $key = key($p_central_dir); next($p_central_dir)) { // //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "central_dir[$key] = ".$p_central_dir[$key]); //} // ----- Return //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result); return $v_result; } // -------------------------------------------------------------------------------- // -------------------------------------------------------------------------------- // Function : privDeleteByRule() // Description : // Parameters : // Return Values : // -------------------------------------------------------------------------------- // http://doc.spip.org/@privDeleteByRule function privDeleteByRule(&$p_result_list, &$p_options) { //--(MAGIC-PclTrace)--//PclTraceFctStart(__FILE__, __LINE__, "PclZip::privDeleteByRule", ""); $v_result=1; $v_list_detail = array(); // ----- Open the zip file //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Open file in binary read mode"); if (($v_result=$this->privOpenFd('rb')) != 1) { // ----- Return //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result); return $v_result; } // ----- Read the central directory informations $v_central_dir = array(); if (($v_result = $this->privReadEndCentralDir($v_central_dir)) != 1) { $this->privCloseFd(); //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result); return $v_result; } // ----- Go to beginning of File //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 5, "Position in file : ".ftell($this->zip_fd)."'"); @rewind($this->zip_fd); //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 5, "Position in file : ".ftell($this->zip_fd)."'"); // ----- Scan all the files // ----- Start at beginning of Central Dir $v_pos_entry = $v_central_dir['offset']; //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 5, "Position before rewind : ".ftell($this->zip_fd)."'"); @rewind($this->zip_fd); //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 5, "Position after rewind : ".ftell($this->zip_fd)."'"); if (@fseek($this->zip_fd, $v_pos_entry)) { // ----- Close the zip file $this->privCloseFd(); // ----- Error log PclZip::privErrorLog(PCLZIP_ERR_INVALID_ARCHIVE_ZIP, 'Invalid archive size'); // ----- Return //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, PclZip::errorCode(), PclZip::errorInfo()); return PclZip::errorCode(); } //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 5, "Position after fseek : ".ftell($this->zip_fd)."'"); // ----- Read each entry $v_header_list = array(); $j_start = 0; for ($i=0, $v_nb_extracted=0; $i<$v_central_dir['entries']; $i++) { //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Read next file header entry (index '$i')"); // ----- Read the file header $v_header_list[$v_nb_extracted] = array(); if (($v_result = $this->privReadCentralFileHeader($v_header_list[$v_nb_extracted])) != 1) { // ----- Close the zip file $this->privCloseFd(); //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result); return $v_result; } //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Filename (index '$i') : '".$v_header_list[$v_nb_extracted]['stored_filename']."'"); // ----- Store the index $v_header_list[$v_nb_extracted]['index'] = $i; // ----- Look for the specific extract rules $v_found = false; // ----- Look for extract by name rule if ( (isset($p_options[PCLZIP_OPT_BY_NAME])) && ($p_options[PCLZIP_OPT_BY_NAME] != 0)) { //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Extract with rule 'ByName'"); // ----- Look if the filename is in the list for ($j=0; ($j strlen($p_options[PCLZIP_OPT_BY_NAME][$j])) && (substr($v_header_list[$v_nb_extracted]['stored_filename'], 0, strlen($p_options[PCLZIP_OPT_BY_NAME][$j])) == $p_options[PCLZIP_OPT_BY_NAME][$j])) { //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "The directory is in the file path"); $v_found = true; } elseif ( (($v_header_list[$v_nb_extracted]['external']&0x00000010)==0x00000010) /* Indicates a folder */ && ($v_header_list[$v_nb_extracted]['stored_filename'].'/' == $p_options[PCLZIP_OPT_BY_NAME][$j])) { //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "The entry is the searched directory"); $v_found = true; } } // ----- Look for a filename elseif ($v_header_list[$v_nb_extracted]['stored_filename'] == $p_options[PCLZIP_OPT_BY_NAME][$j]) { //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "The file is the right one."); $v_found = true; } } } // ----- Look for extract by ereg rule else if ( (isset($p_options[PCLZIP_OPT_BY_EREG])) && ($p_options[PCLZIP_OPT_BY_EREG] != "")) { //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Extract by ereg '".$p_options[PCLZIP_OPT_BY_EREG]."'"); if (ereg($p_options[PCLZIP_OPT_BY_EREG], $v_header_list[$v_nb_extracted]['stored_filename'])) { //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Filename match the regular expression"); $v_found = true; } } // ----- Look for extract by preg rule else if ( (isset($p_options[PCLZIP_OPT_BY_PREG])) && ($p_options[PCLZIP_OPT_BY_PREG] != "")) { //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Extract with rule 'ByEreg'"); if (preg_match($p_options[PCLZIP_OPT_BY_PREG], $v_header_list[$v_nb_extracted]['stored_filename'])) { //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Filename match the regular expression"); $v_found = true; } } // ----- Look for extract by index rule else if ( (isset($p_options[PCLZIP_OPT_BY_INDEX])) && ($p_options[PCLZIP_OPT_BY_INDEX] != 0)) { //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Extract with rule 'ByIndex'"); // ----- Look if the index is in the list for ($j=$j_start; ($j=$p_options[PCLZIP_OPT_BY_INDEX][$j]['start']) && ($i<=$p_options[PCLZIP_OPT_BY_INDEX][$j]['end'])) { //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Found as part of an index range"); $v_found = true; } if ($i>=$p_options[PCLZIP_OPT_BY_INDEX][$j]['end']) { //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Do not look this index range for next loop"); $j_start = $j+1; } if ($p_options[PCLZIP_OPT_BY_INDEX][$j]['start']>$i) { //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Index range is greater than index, stop loop"); break; } } } else { //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "No argument mean remove all file"); $v_found = true; } // ----- Look for deletion if ($v_found) { //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "File '".$v_header_list[$v_nb_extracted]['stored_filename']."', index '$i' need to be deleted"); unset($v_header_list[$v_nb_extracted]); } else { //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "File '".$v_header_list[$v_nb_extracted]['stored_filename']."', index '$i' will not be deleted"); $v_nb_extracted++; } } // ----- Look if something need to be deleted if ($v_nb_extracted > 0) { // ----- Creates a temporay file $v_zip_temp_name = PCLZIP_TEMPORARY_DIR.uniqid('pclzip-').'.tmp'; // ----- Creates a temporary zip archive $v_temp_zip = new PclZip($v_zip_temp_name); // ----- Open the temporary zip file in write mode //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Open file in binary write mode"); if (($v_result = $v_temp_zip->privOpenFd('wb')) != 1) { $this->privCloseFd(); // ----- Return //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result); return $v_result; } // ----- Look which file need to be kept for ($i=0; $izip_fd)."'"); @rewind($this->zip_fd); //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 5, "Position after rewind : ".ftell($this->zip_fd)."'"); if (@fseek($this->zip_fd, $v_header_list[$i]['offset'])) { // ----- Close the zip file $this->privCloseFd(); $v_temp_zip->privCloseFd(); spip_unlink($v_zip_temp_name); // ----- Error log PclZip::privErrorLog(PCLZIP_ERR_INVALID_ARCHIVE_ZIP, 'Invalid archive size'); // ----- Return //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, PclZip::errorCode(), PclZip::errorInfo()); return PclZip::errorCode(); } //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 5, "Position after fseek : ".ftell($this->zip_fd)."'"); // ----- Read the file header $v_local_header = array(); if (($v_result = $this->privReadFileHeader($v_local_header)) != 1) { // ----- Close the zip file $this->privCloseFd(); $v_temp_zip->privCloseFd(); spip_unlink($v_zip_temp_name); // ----- Return //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result); return $v_result; } // ----- Check that local file header is same as central file header if ($this->privCheckFileHeaders($v_local_header, $v_header_list[$i]) != 1) { // TBC } unset($v_local_header); // ----- Write the file header if (($v_result = $v_temp_zip->privWriteFileHeader($v_header_list[$i])) != 1) { // ----- Close the zip file $this->privCloseFd(); $v_temp_zip->privCloseFd(); spip_unlink($v_zip_temp_name); // ----- Return //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result); return $v_result; } //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 5, "Offset for this file is '".$v_header_list[$i]['offset']."'"); // ----- Read/write the data block if (($v_result = PclZipUtilCopyBlock($this->zip_fd, $v_temp_zip->zip_fd, $v_header_list[$i]['compressed_size'])) != 1) { // ----- Close the zip file $this->privCloseFd(); $v_temp_zip->privCloseFd(); spip_unlink($v_zip_temp_name); // ----- Return //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result); return $v_result; } } // ----- Store the offset of the central dir $v_offset = @ftell($v_temp_zip->zip_fd); //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 5, "New offset of central dir : $v_offset"); // ----- Re-Create the Central Dir files header //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Creates the new central directory"); for ($i=0; $iprivWriteCentralFileHeader($v_header_list[$i])) != 1) { $v_temp_zip->privCloseFd(); $this->privCloseFd(); spip_unlink($v_zip_temp_name); // ----- Return //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result); return $v_result; } // ----- Transform the header to a 'usable' info $v_temp_zip->privConvertHeader2FileInfo($v_header_list[$i], $p_result_list[$i]); } //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Creates the central directory footer"); // ----- Zip file comment $v_comment = ''; if (isset($p_options[PCLZIP_OPT_COMMENT])) { $v_comment = $p_options[PCLZIP_OPT_COMMENT]; } // ----- Calculate the size of the central header $v_size = @ftell($v_temp_zip->zip_fd)-$v_offset; // ----- Create the central dir footer if (($v_result = $v_temp_zip->privWriteCentralHeader(sizeof($v_header_list), $v_size, $v_offset, $v_comment)) != 1) { // ----- Reset the file list unset($v_header_list); $v_temp_zip->privCloseFd(); $this->privCloseFd(); spip_unlink($v_zip_temp_name); // ----- Return //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result); return $v_result; } // ----- Close $v_temp_zip->privCloseFd(); $this->privCloseFd(); // ----- Delete the zip file // TBC : I should test the result ... spip_unlink($this->zipname); // ----- Rename the temporary file // TBC : I should test the result ... //@rename($v_zip_temp_name, $this->zipname); PclZipUtilRename($v_zip_temp_name, $this->zipname); // ----- Destroy the temporary archive unset($v_temp_zip); } // ----- Remove every files : reset the file else if ($v_central_dir['entries'] != 0) { $this->privCloseFd(); if (($v_result = $this->privOpenFd('wb')) != 1) { //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result); return $v_result; } if (($v_result = $this->privWriteCentralHeader(0, 0, 0, '')) != 1) { //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result); return $v_result; } $this->privCloseFd(); } // ----- Return //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result); return $v_result; } // -------------------------------------------------------------------------------- // -------------------------------------------------------------------------------- // Function : privDirCheck() // Description : // Check if a directory exists, if not it creates it and all the parents directory // which may be useful. // Parameters : // $p_dir : Directory path to check. // Return Values : // 1 : OK // -1 : Unable to create directory // -------------------------------------------------------------------------------- // http://doc.spip.org/@privDirCheck function privDirCheck($p_dir, $p_is_dir=false) { $v_result = 1; //--(MAGIC-PclTrace)--//PclTraceFctStart(__FILE__, __LINE__, "PclZip::privDirCheck", "entry='$p_dir', is_dir='".($p_is_dir?"true":"false")."'"); // ----- Remove the final '/' if (($p_is_dir) && (substr($p_dir, -1)=='/')) { $p_dir = substr($p_dir, 0, strlen($p_dir)-1); } //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Looking for entry '$p_dir'"); // ----- Check the directory availability if ((is_dir($p_dir)) || ($p_dir == "")) { //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, "'$p_dir' is a directory"); return 1; } // ----- Extract parent directory $p_parent_dir = dirname($p_dir); //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Parent directory is '$p_parent_dir'"); // ----- Just a check if ($p_parent_dir != $p_dir) { // ----- Look for parent directory if ($p_parent_dir != "") { if (($v_result = $this->privDirCheck($p_parent_dir)) != 1) { //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result); return $v_result; } } } // ----- Create the directory //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Create directory '$p_dir'"); if (!@mkdir($p_dir, 0777)) { // ----- Error log PclZip::privErrorLog(PCLZIP_ERR_DIR_CREATE_FAIL, "Unable to create directory '$p_dir'"); // ----- Return //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, PclZip::errorCode(), PclZip::errorInfo()); return PclZip::errorCode(); } // ----- Return //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result, "Directory '$p_dir' created"); return $v_result; } // -------------------------------------------------------------------------------- // -------------------------------------------------------------------------------- // Function : privMerge() // Description : // If $p_archive_to_add does not exist, the function exit with a success result. // Parameters : // Return Values : // -------------------------------------------------------------------------------- // http://doc.spip.org/@privMerge function privMerge(&$p_archive_to_add) { //--(MAGIC-PclTrace)--//PclTraceFctStart(__FILE__, __LINE__, "PclZip::privMerge", "archive='".$p_archive_to_add->zipname."'"); $v_result=1; // ----- Look if the archive_to_add exists if (!is_file($p_archive_to_add->zipname)) { //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Archive to add does not exist. End of merge."); // ----- Nothing to merge, so merge is a success $v_result = 1; // ----- Return //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result); return $v_result; } // ----- Look if the archive exists if (!is_file($this->zipname)) { //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Archive does not exist, duplicate the archive_to_add."); // ----- Do a duplicate $v_result = $this->privDuplicate($p_archive_to_add->zipname); // ----- Return //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result); return $v_result; } // ----- Open the zip file //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Open file in binary read mode"); if (($v_result=$this->privOpenFd('rb')) != 1) { // ----- Return //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result); return $v_result; } // ----- Read the central directory informations $v_central_dir = array(); if (($v_result = $this->privReadEndCentralDir($v_central_dir)) != 1) { $this->privCloseFd(); //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result); return $v_result; } // ----- Go to beginning of File //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 5, "Position in zip : ".ftell($this->zip_fd)."'"); @rewind($this->zip_fd); //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 5, "Position in zip : ".ftell($this->zip_fd)."'"); // ----- Open the archive_to_add file //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Open archive_to_add in binary read mode"); if (($v_result=$p_archive_to_add->privOpenFd('rb')) != 1) { $this->privCloseFd(); // ----- Return //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result); return $v_result; } // ----- Read the central directory informations $v_central_dir_to_add = array(); if (($v_result = $p_archive_to_add->privReadEndCentralDir($v_central_dir_to_add)) != 1) { $this->privCloseFd(); $p_archive_to_add->privCloseFd(); //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result); return $v_result; } // ----- Go to beginning of File //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 5, "Position in archive_to_add : ".ftell($p_archive_to_add->zip_fd)."'"); @rewind($p_archive_to_add->zip_fd); //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 5, "Position in archive_to_add : ".ftell($p_archive_to_add->zip_fd)."'"); // ----- Creates a temporay file $v_zip_temp_name = PCLZIP_TEMPORARY_DIR.uniqid('pclzip-').'.tmp'; // ----- Open the temporary file in write mode //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Open file in binary read mode"); if (($v_zip_temp_fd = @fopen($v_zip_temp_name, 'wb')) == 0) { $this->privCloseFd(); $p_archive_to_add->privCloseFd(); PclZip::privErrorLog(PCLZIP_ERR_READ_OPEN_FAIL, 'Unable to open temporary file \''.$v_zip_temp_name.'\' in binary write mode'); // ----- Return //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, PclZip::errorCode(), PclZip::errorInfo()); return PclZip::errorCode(); } // ----- Copy the files from the archive to the temporary file // TBC : Here I should better append the file and go back to erase the central dir $v_size = $v_central_dir['offset']; while ($v_size != 0) { $v_read_size = ($v_size < PCLZIP_READ_BLOCK_SIZE ? $v_size : PCLZIP_READ_BLOCK_SIZE); //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 4, "Read $v_read_size bytes"); $v_buffer = fread($this->zip_fd, $v_read_size); @fwrite($v_zip_temp_fd, $v_buffer, $v_read_size); $v_size -= $v_read_size; } // ----- Copy the files from the archive_to_add into the temporary file $v_size = $v_central_dir_to_add['offset']; while ($v_size != 0) { $v_read_size = ($v_size < PCLZIP_READ_BLOCK_SIZE ? $v_size : PCLZIP_READ_BLOCK_SIZE); //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 4, "Read $v_read_size bytes"); $v_buffer = fread($p_archive_to_add->zip_fd, $v_read_size); @fwrite($v_zip_temp_fd, $v_buffer, $v_read_size); $v_size -= $v_read_size; } // ----- Store the offset of the central dir $v_offset = @ftell($v_zip_temp_fd); //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 4, "New offset of central dir : $v_offset"); // ----- Copy the block of file headers from the old archive $v_size = $v_central_dir['size']; while ($v_size != 0) { $v_read_size = ($v_size < PCLZIP_READ_BLOCK_SIZE ? $v_size : PCLZIP_READ_BLOCK_SIZE); //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 4, "Read $v_read_size bytes"); $v_buffer = @fread($this->zip_fd, $v_read_size); @fwrite($v_zip_temp_fd, $v_buffer, $v_read_size); $v_size -= $v_read_size; } // ----- Copy the block of file headers from the archive_to_add $v_size = $v_central_dir_to_add['size']; while ($v_size != 0) { $v_read_size = ($v_size < PCLZIP_READ_BLOCK_SIZE ? $v_size : PCLZIP_READ_BLOCK_SIZE); //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 4, "Read $v_read_size bytes"); $v_buffer = @fread($p_archive_to_add->zip_fd, $v_read_size); @fwrite($v_zip_temp_fd, $v_buffer, $v_read_size); $v_size -= $v_read_size; } // ----- Merge the file comments $v_comment = $v_central_dir['comment'].' '.$v_central_dir_to_add['comment']; // ----- Calculate the size of the (new) central header $v_size = @ftell($v_zip_temp_fd)-$v_offset; // ----- Swap the file descriptor // Here is a trick : I swap the temporary fd with the zip fd, in order to use // the following methods on the temporary fil and not the real archive fd $v_swap = $this->zip_fd; $this->zip_fd = $v_zip_temp_fd; $v_zip_temp_fd = $v_swap; // ----- Create the central dir footer if (($v_result = $this->privWriteCentralHeader($v_central_dir['entries']+$v_central_dir_to_add['entries'], $v_size, $v_offset, $v_comment)) != 1) { $this->privCloseFd(); $p_archive_to_add->privCloseFd(); @fclose($v_zip_temp_fd); $this->zip_fd = null; // ----- Reset the file list unset($v_header_list); // ----- Return //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result); return $v_result; } // ----- Swap back the file descriptor $v_swap = $this->zip_fd; $this->zip_fd = $v_zip_temp_fd; $v_zip_temp_fd = $v_swap; // ----- Close $this->privCloseFd(); $p_archive_to_add->privCloseFd(); // ----- Close the temporary file @fclose($v_zip_temp_fd); // ----- Delete the zip file // TBC : I should test the result ... spip_unlink($this->zipname); // ----- Rename the temporary file // TBC : I should test the result ... //@rename($v_zip_temp_name, $this->zipname); PclZipUtilRename($v_zip_temp_name, $this->zipname); // ----- Return //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result); return $v_result; } // -------------------------------------------------------------------------------- // -------------------------------------------------------------------------------- // Function : privDuplicate() // Description : // Parameters : // Return Values : // -------------------------------------------------------------------------------- // http://doc.spip.org/@privDuplicate function privDuplicate($p_archive_filename) { //--(MAGIC-PclTrace)--//PclTraceFctStart(__FILE__, __LINE__, "PclZip::privDuplicate", "archive_filename='$p_archive_filename'"); $v_result=1; // ----- Look if the $p_archive_filename exists if (!is_file($p_archive_filename)) { //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Archive to duplicate does not exist. End of duplicate."); // ----- Nothing to duplicate, so duplicate is a success. $v_result = 1; // ----- Return //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result); return $v_result; } // ----- Open the zip file //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Open file in binary read mode"); if (($v_result=$this->privOpenFd('wb')) != 1) { // ----- Return //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result); return $v_result; } // ----- Open the temporary file in write mode //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Open file in binary read mode"); if (($v_zip_temp_fd = @fopen($p_archive_filename, 'rb')) == 0) { $this->privCloseFd(); PclZip::privErrorLog(PCLZIP_ERR_READ_OPEN_FAIL, 'Unable to open archive file \''.$p_archive_filename.'\' in binary write mode'); // ----- Return //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, PclZip::errorCode(), PclZip::errorInfo()); return PclZip::errorCode(); } // ----- Copy the files from the archive to the temporary file // TBC : Here I should better append the file and go back to erase the central dir $v_size = filesize($p_archive_filename); while ($v_size != 0) { $v_read_size = ($v_size < PCLZIP_READ_BLOCK_SIZE ? $v_size : PCLZIP_READ_BLOCK_SIZE); //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 5, "Read $v_read_size bytes"); $v_buffer = fread($v_zip_temp_fd, $v_read_size); @fwrite($this->zip_fd, $v_buffer, $v_read_size); $v_size -= $v_read_size; } // ----- Close $this->privCloseFd(); // ----- Close the temporary file @fclose($v_zip_temp_fd); // ----- Return //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result); return $v_result; } // -------------------------------------------------------------------------------- // -------------------------------------------------------------------------------- // Function : privErrorLog() // Description : // Parameters : // -------------------------------------------------------------------------------- // http://doc.spip.org/@privErrorLog function privErrorLog($p_error_code=0, $p_error_string='') { if (PCLZIP_ERROR_EXTERNAL == 1) { PclError($p_error_code, $p_error_string); } else { $this->error_code = $p_error_code; $this->error_string = $p_error_string; } } // -------------------------------------------------------------------------------- // -------------------------------------------------------------------------------- // Function : privErrorReset() // Description : // Parameters : // -------------------------------------------------------------------------------- // http://doc.spip.org/@privErrorReset function privErrorReset() { if (PCLZIP_ERROR_EXTERNAL == 1) { PclErrorReset(); } else { $this->error_code = 0; $this->error_string = ''; } } // -------------------------------------------------------------------------------- // -------------------------------------------------------------------------------- // Function : privDecrypt() // Description : // Parameters : // Return Values : // -------------------------------------------------------------------------------- // http://doc.spip.org/@privDecrypt function privDecrypt($p_encryption_header, &$p_buffer, $p_size, $p_crc) { //--(MAGIC-PclTrace)--//PclTraceFctStart(__FILE__, __LINE__, 'PclZip::privDecrypt', "size=".$p_size.""); $v_result=1; // ----- To Be Modified ;-) $v_pwd = "test"; $p_buffer = PclZipUtilZipDecrypt($p_buffer, $p_size, $p_encryption_header, $p_crc, $v_pwd); // ----- Return //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result); return $v_result; } // -------------------------------------------------------------------------------- // -------------------------------------------------------------------------------- // Function : privDisableMagicQuotes() // Description : // Parameters : // Return Values : // -------------------------------------------------------------------------------- // http://doc.spip.org/@privDisableMagicQuotes function privDisableMagicQuotes() { //--(MAGIC-PclTrace)--//PclTraceFctStart(__FILE__, __LINE__, 'PclZip::privDisableMagicQuotes', ""); $v_result=1; // ----- Look if function exists if ( (!function_exists("get_magic_quotes_runtime")) || (!function_exists("set_magic_quotes_runtime"))) { //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Functions *et_magic_quotes_runtime are not supported"); //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result); return $v_result; } // ----- Look if already done if ($this->magic_quotes_status != -1) { //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "magic_quote already disabled"); //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result); return $v_result; } // ----- Get and memorize the magic_quote value $this->magic_quotes_status = @get_magic_quotes_runtime(); //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Current magic_quotes_runtime status is '".($this->magic_quotes_status==0?'disable':'enable')."'"); // ----- Disable magic_quotes if ($this->magic_quotes_status == 1) { //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Disable magic_quotes"); @set_magic_quotes_runtime(0); } // ----- Return //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result); return $v_result; } // -------------------------------------------------------------------------------- // -------------------------------------------------------------------------------- // Function : privSwapBackMagicQuotes() // Description : // Parameters : // Return Values : // -------------------------------------------------------------------------------- // http://doc.spip.org/@privSwapBackMagicQuotes function privSwapBackMagicQuotes() { //--(MAGIC-PclTrace)--//PclTraceFctStart(__FILE__, __LINE__, 'PclZip::privSwapBackMagicQuotes', ""); $v_result=1; // ----- Look if function exists if ( (!function_exists("get_magic_quotes_runtime")) || (!function_exists("set_magic_quotes_runtime"))) { //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Functions *et_magic_quotes_runtime are not supported"); //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result); return $v_result; } // ----- Look if something to do if ($this->magic_quotes_status != -1) { //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "magic_quote not modified"); //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result); return $v_result; } // ----- Swap back magic_quotes if ($this->magic_quotes_status == 1) { //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Enable back magic_quotes"); @set_magic_quotes_runtime($this->magic_quotes_status); } // ----- Return //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result); return $v_result; } // -------------------------------------------------------------------------------- } // End of class // -------------------------------------------------------------------------------- // -------------------------------------------------------------------------------- // Function : PclZipUtilPathReduction() // Description : // Parameters : // Return Values : // -------------------------------------------------------------------------------- // http://doc.spip.org/@PclZipUtilPathReduction function PclZipUtilPathReduction($p_dir) { //--(MAGIC-PclTrace)--//PclTraceFctStart(__FILE__, __LINE__, "PclZipUtilPathReduction", "dir='$p_dir'"); $v_result = ""; // ----- Look for not empty path if ($p_dir != "") { // ----- Explode path by directory names $v_list = explode("/", $p_dir); // ----- Study directories from last to first $v_skip = 0; for ($i=sizeof($v_list)-1; $i>=0; $i--) { // ----- Look for current path if ($v_list[$i] == ".") { // ----- Ignore this directory // Should be the first $i=0, but no check is done } else if ($v_list[$i] == "..") { $v_skip++; } else if ($v_list[$i] == "") { // ----- First '/' i.e. root slash if ($i == 0) { $v_result = "/".$v_result; if ($v_skip > 0) { // ----- It is an invalid path, so the path is not modified // TBC $v_result = $p_dir; //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Invalid path is unchanged"); $v_skip = 0; } } // ----- Last '/' i.e. indicates a directory else if ($i == (sizeof($v_list)-1)) { $v_result = $v_list[$i]; } // ----- Double '/' inside the path else { // ----- Ignore only the double '//' in path, // but not the first and last '/' } } else { // ----- Look for item to skip if ($v_skip > 0) { $v_skip--; } else { $v_result = $v_list[$i].($i!=(sizeof($v_list)-1)?"/".$v_result:""); } } } // ----- Look for skip if ($v_skip > 0) { while ($v_skip > 0) { $v_result = '../'.$v_result; $v_skip--; } } } // ----- Return //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result); return $v_result; } // -------------------------------------------------------------------------------- // -------------------------------------------------------------------------------- // Function : PclZipUtilPathInclusion() // Description : // This function indicates if the path $p_path is under the $p_dir tree. Or, // said in an other way, if the file or sub-dir $p_path is inside the dir // $p_dir. // The function indicates also if the path is exactly the same as the dir. // This function supports path with duplicated '/' like '//', but does not // support '.' or '..' statements. // Parameters : // Return Values : // 0 if $p_path is not inside directory $p_dir // 1 if $p_path is inside directory $p_dir // 2 if $p_path is exactly the same as $p_dir // -------------------------------------------------------------------------------- // http://doc.spip.org/@PclZipUtilPathInclusion function PclZipUtilPathInclusion($p_dir, $p_path) { //--(MAGIC-PclTrace)--//PclTraceFctStart(__FILE__, __LINE__, "PclZipUtilPathInclusion", "dir='$p_dir', path='$p_path'"); $v_result = 1; // ----- Look for path beginning by ./ if ( ($p_dir == '.') || ((strlen($p_dir) >=2) && (substr($p_dir, 0, 2) == './'))) { $p_dir = PclZipUtilTranslateWinPath(getcwd(), FALSE).'/'.substr($p_dir, 1); //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 5, "Replacing ./ by full path in p_dir '".$p_dir."'"); } if ( ($p_path == '.') || ((strlen($p_path) >=2) && (substr($p_path, 0, 2) == './'))) { $p_path = PclZipUtilTranslateWinPath(getcwd(), FALSE).'/'.substr($p_path, 1); //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 5, "Replacing ./ by full path in p_path '".$p_path."'"); } // ----- Explode dir and path by directory separator $v_list_dir = explode("/", $p_dir); $v_list_dir_size = sizeof($v_list_dir); $v_list_path = explode("/", $p_path); $v_list_path_size = sizeof($v_list_path); // ----- Study directories paths $i = 0; $j = 0; while (($i < $v_list_dir_size) && ($j < $v_list_path_size) && ($v_result)) { //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 5, "Working on dir($i)='".$v_list_dir[$i]."' and path($j)='".$v_list_path[$j]."'"); // ----- Look for empty dir (path reduction) if ($v_list_dir[$i] == '') { $i++; continue; } if ($v_list_path[$j] == '') { $j++; continue; } // ----- Compare the items if (($v_list_dir[$i] != $v_list_path[$j]) && ($v_list_dir[$i] != '') && ( $v_list_path[$j] != '')) { //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 5, "Items ($i,$j) are different"); $v_result = 0; } // ----- Next items $i++; $j++; } // ----- Look if everything seems to be the same if ($v_result) { //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 5, "Look for tie break"); // ----- Skip all the empty items while (($j < $v_list_path_size) && ($v_list_path[$j] == '')) $j++; while (($i < $v_list_dir_size) && ($v_list_dir[$i] == '')) $i++; //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 5, "Looking on dir($i)='".($i < $v_list_dir_size?$v_list_dir[$i]:'')."' and path($j)='".($j < $v_list_path_size?$v_list_path[$j]:'')."'"); if (($i >= $v_list_dir_size) && ($j >= $v_list_path_size)) { // ----- There are exactly the same $v_result = 2; } else if ($i < $v_list_dir_size) { // ----- The path is shorter than the dir $v_result = 0; } } // ----- Return //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result); return $v_result; } // -------------------------------------------------------------------------------- // -------------------------------------------------------------------------------- // Function : PclZipUtilCopyBlock() // Description : // Parameters : // $p_mode : read/write compression mode // 0 : src & dest normal // 1 : src gzip, dest normal // 2 : src normal, dest gzip // 3 : src & dest gzip // Return Values : // -------------------------------------------------------------------------------- // http://doc.spip.org/@PclZipUtilCopyBlock function PclZipUtilCopyBlock($p_src, $p_dest, $p_size, $p_mode=0) { //--(MAGIC-PclTrace)--//PclTraceFctStart(__FILE__, __LINE__, "PclZipUtilCopyBlock", "size=$p_size, mode=$p_mode"); $v_result = 1; if ($p_mode==0) { //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 5, "Src offset before read :".(@ftell($p_src))); //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 5, "Dest offset before write :".(@ftell($p_dest))); while ($p_size != 0) { $v_read_size = ($p_size < PCLZIP_READ_BLOCK_SIZE ? $p_size : PCLZIP_READ_BLOCK_SIZE); //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 4, "Read $v_read_size bytes"); $v_buffer = @fread($p_src, $v_read_size); @fwrite($p_dest, $v_buffer, $v_read_size); $p_size -= $v_read_size; } //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 5, "Src offset after read :".(@ftell($p_src))); //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 5, "Dest offset after write :".(@ftell($p_dest))); } else if ($p_mode==1) { while ($p_size != 0) { $v_read_size = ($p_size < PCLZIP_READ_BLOCK_SIZE ? $p_size : PCLZIP_READ_BLOCK_SIZE); //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 4, "Read $v_read_size bytes"); $v_buffer = @gzread($p_src, $v_read_size); @fwrite($p_dest, $v_buffer, $v_read_size); $p_size -= $v_read_size; } } else if ($p_mode==2) { while ($p_size != 0) { $v_read_size = ($p_size < PCLZIP_READ_BLOCK_SIZE ? $p_size : PCLZIP_READ_BLOCK_SIZE); //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 4, "Read $v_read_size bytes"); $v_buffer = @fread($p_src, $v_read_size); @gzwrite($p_dest, $v_buffer, $v_read_size); $p_size -= $v_read_size; } } else if ($p_mode==3) { while ($p_size != 0) { $v_read_size = ($p_size < PCLZIP_READ_BLOCK_SIZE ? $p_size : PCLZIP_READ_BLOCK_SIZE); //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 4, "Read $v_read_size bytes"); $v_buffer = @gzread($p_src, $v_read_size); @gzwrite($p_dest, $v_buffer, $v_read_size); $p_size -= $v_read_size; } } // ----- Return //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result); return $v_result; } // -------------------------------------------------------------------------------- // -------------------------------------------------------------------------------- // Function : PclZipUtilRename() // Description : // This function tries to do a simple rename() function. If it fails, it // tries to copy the $p_src file in a new $p_dest file and then unlink the // first one. // Parameters : // $p_src : Old filename // $p_dest : New filename // Return Values : // 1 on success, 0 on failure. // -------------------------------------------------------------------------------- // http://doc.spip.org/@PclZipUtilRename function PclZipUtilRename($p_src, $p_dest) { //--(MAGIC-PclTrace)--//PclTraceFctStart(__FILE__, __LINE__, "PclZipUtilRename", "source=$p_src, destination=$p_dest"); $v_result = 1; // ----- Try to rename the files if (!@rename($p_src, $p_dest)) { //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 5, "Fail to rename file, try copy+unlink"); // ----- Try to copy & unlink the src if (!@copy($p_src, $p_dest)) { //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 5, "Fail to copy file"); $v_result = 0; } else if (!spip_unlink($p_src)) { //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 5, "Fail to unlink old filename"); $v_result = 0; } } // ----- Return //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result); return $v_result; } // -------------------------------------------------------------------------------- // -------------------------------------------------------------------------------- // Function : PclZipUtilOptionText() // Description : // Translate option value in text. Mainly for debug purpose. // Parameters : // $p_option : the option value. // Return Values : // The option text value. // -------------------------------------------------------------------------------- // http://doc.spip.org/@PclZipUtilOptionText function PclZipUtilOptionText($p_option) { //--(MAGIC-PclTrace)--//PclTraceFctStart(__FILE__, __LINE__, "PclZipUtilOptionText", "option='".$p_option."'"); $v_list = get_defined_constants(); for (reset($v_list); $v_key = key($v_list); next($v_list)) { $v_prefix = substr($v_key, 0, 10); if (( ($v_prefix == 'PCLZIP_OPT') || ($v_prefix == 'PCLZIP_CB_') || ($v_prefix == 'PCLZIP_ATT')) && ($v_list[$v_key] == $p_option)) { //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_key); return $v_key; } } $v_result = 'Unknown'; //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result); return $v_result; } // -------------------------------------------------------------------------------- // -------------------------------------------------------------------------------- // Function : PclZipUtilTranslateWinPath() // Description : // Translate windows path by replacing '\' by '/' and optionally removing // drive letter. // Parameters : // $p_path : path to translate. // $p_remove_disk_letter : true | false // Return Values : // The path translated. // -------------------------------------------------------------------------------- // http://doc.spip.org/@PclZipUtilTranslateWinPath function PclZipUtilTranslateWinPath($p_path, $p_remove_disk_letter=true) { if (stristr(php_uname(), 'windows')) { // ----- Look for potential disk letter if (($p_remove_disk_letter) && (($v_position = strpos($p_path, ':')) != false)) { $p_path = substr($p_path, $v_position+1); } // ----- Change potential windows directory separator if ((strpos($p_path, '\\') > 0) || (substr($p_path, 0,1) == '\\')) { $p_path = strtr($p_path, '\\', '/'); } } return $p_path; } // -------------------------------------------------------------------------------- ?> spip/spip/ecrire/inc/charger_plugin.php0000766000000000000000000003532111236524730021427 0ustar adminadministrators
  • '._T('plugin_info_automatique2',array('rep'=>joli_repertoire(_DIR_PLUGINS_AUTO))).'
  • ' .'
  • '._T('plugin_info_automatique3').aide("install0")."
  • " ."\n

    "._T('plugin_info_automatique_lib')."

    "; } if (!$auto) $auto = interface_plugins_auto($retour); } $message = _T('plugin_info_automatique_ftp',array('rep'=>joli_repertoire(_DIR_PLUGINS))); if (!@is_dir(_DIR_PLUGINS)) $message .= " — "._T('plugin_info_automatique_creer'); return debut_cadre_trait_couleur("spip-pack-24.png", true, "", _T('plugin_titre_automatique_ajouter')) . "

    "._T('plugin_titre_automatique')."

    " . "

    ".$message."

    \n" . $auto . fin_cadre_trait_couleur(true); } // http://doc.spip.org/@interface_plugins_auto function interface_plugins_auto($retour) { $res = "
    "; if ($retour) { $res .= "
    $retour
    \n"; } $liste = liste_plugins_distants(); $message .= '
    '._T('plugin_zip_adresse') . '
    '._T('plugin_info_automatique_exemples').'
      '; $les_urls = array('http://plugins.spip.net/rss-+-selection-2-+','http://www.spip-contrib.net/spip.php?page=rss_plugins_spip_2'); if (isset($GLOBALS['chargeur_urls_rss']) AND is_array($GLOBALS['chargeur_urls_rss'])) $les_urls = array_merge($les_urls,$GLOBALS['chargeur_urls_rss']); foreach($les_urls as $url) $message .= "
    • " .$url ."
    • "; $message .= "
    "; $form = ""; $form .= "
    • "; $form .= ""; $form .= $message; $form .= " "; $form .= "
    "; $form .= "
    \n" . "
    \n"; $form = redirige_action_post('charger_plugin', '', // arg = 'plugins' / 'lib', a priori '', '', $form); $res .= "
    "; $res .= $form; $res .= "
    \n"; $res .= "
    \n"; $res .= afficher_liste_listes_plugins(); if ($liste) { $res .= '

    '._T('plugin_info_automatique_select',array('rep'=>joli_repertoire(_DIR_PLUGINS_AUTO))).'

    '; $menu = array(); $compte = 0; foreach ($liste as $url => $info) { $compte += 1; $titre = $info[0]; $url_doc = $info[1]; $titre = typo(''.$titre.''); // recuperer les blocs multi du flux de la zone (temporaire?) if ($url_doc) $titre = "$titre"; $nick = strtolower(basename($url, '.zip')); $menu[$nick] = '
    | ".$titre."
    \n"; } ksort($menu); $form = "
    \n"; $form .= join("\n",$menu); $form .= "
    \n"; $form .= "\n
    \n"; $form .= "
    \n" . "
    \n"; $res .= "

    "._T('plugins_compte',array('count' => count($menu)))."

    " . "
    " //debut_cadre_enfonce('', true, '', '') . redirige_action_post('charger_plugin', '', // arg = 'plugins' / 'lib', a priori '', '', $form) // . fin_cadre_enfonce(true) // . "
    "; . "
    "; $res .= http_script(" // charger en ajax le descriptif si on click une div jQuery('#bouton_charger_plugin').hide(); jQuery('#liste_plug .desc_plug').click(function(e) { jQuery('#desc').animeajax().load('".generer_url_ecrire('charger_plugin_descr', 'url=', '\\x26')."'+jQuery('input', this).attr('value'),function(){ jQuery('#bouton_charger_plugin').show(); }); }); "); } return $res; } // http://doc.spip.org/@chargeur_charger_zip function chargeur_charger_zip($quoi = array()) { if (!$quoi) { return true; } if (is_scalar($quoi)) { $quoi = array('zip' => $quoi); } if (isset($quoi['depot']) || isset($quoi['nom'])) { $quoi['zip'] = $quoi['depot'] . $quoi['nom'] . '.zip'; } foreach (array( 'remove' => 'spip', 'arg' => 'lib', 'plugin' => null, 'cache_cache' => null, 'rename' => array(), 'edit' => array(), 'root_extract' => false, # extraire a la racine de dest ? 'tmp' => sous_repertoire(_DIR_CACHE, 'chargeur') ) as $opt=>$def) { isset($quoi[$opt]) || ($quoi[$opt] = $def); } # destination finale des fichiers switch($quoi['arg']) { case 'lib': $quoi['dest'] = _DIR_RACINE.'lib/'; break; case 'plugins': $quoi['dest'] = _DIR_PLUGINS_AUTO; break; default: $quoi['dest'] = ''; break; } if (!@file_exists($fichier = $quoi['fichier'])) return 0; include_spip('inc/pclzip'); $zip = new PclZip($fichier); $list = $zip->listContent(); // on cherche la plus longue racine commune a tous les fichiers foreach($list as $n) { $p = array(); foreach(explode('/', $n['filename']) as $n => $x) { $sofar = join('/',$p); $paths[$n][$sofar]++; $p[] = $x; } } $total = $paths[0]['']; $i = 0; while (isset($paths[$i]) AND count($paths[$i]) <= 1 AND array_values($paths[$i]) == array($total)) $i++; $racine = $i ? array_pop(array_keys($paths[$i-1])).'/' : ''; $quoi['remove'] = $racine; if (!strlen($nom = basename($racine))) $nom = basename($fichier, '.zip'); $dir_export = $quoi['root_extract'] ? $quoi['dest'] : $quoi['dest'] . $nom.'/'; $tmpname = $quoi['tmp'].$nom.'/'; // On extrait, mais dans tmp/ si on ne veut pas vraiment le faire $ok = $zip->extract( PCLZIP_OPT_PATH, $quoi['extract'] ? $dir_export : $tmpname , PCLZIP_OPT_SET_CHMOD, _SPIP_CHMOD, PCLZIP_OPT_REPLACE_NEWER, PCLZIP_OPT_REMOVE_PATH, $quoi['remove'] ); if ($zip->error_code < 0) { spip_log('charger_decompresser erreur zip ' . $zip->error_code . ' pour paquet: ' . $quoi['zip']); return //$zip->error_code $zip->errorName(true); } /* * desactive pour l'instant * * if (!$quoi['cache_cache']) { chargeur_montre_tout($quoi); } if ($quoi['rename']) { chargeur_rename($quoi); } if ($quoi['edit']) { chargeur_edit($dir_export, $quoi['edit']); } if ($quoi['plugin']) { chargeur_activer_plugin($quoi['plugin']); } */ spip_log('charger_decompresser OK pour paquet: ' . $quoi['zip']); $size = $compressed_size = 0; $removex = ',^'.preg_quote($quoi['remove'], ',').','; foreach ($list as $a => $f) { $size += $f['size']; $compressed_size += $f['compressed_size']; $list[$a] = preg_replace($removex,'',$f['filename']); } // Indiquer par un fichier install.log // a la racine que c'est chargeur qui a installe ce plugin ecrire_fichier($tmpname.'/install.log', "installation: charger_plugin\n" ."date: ".gmdate('Y-m-d\TH:i:s\Z', time())."\n" ."source: ".$quoi['zip']."\n" ); return array( 'files' => $list, 'size' => $size, 'compressed_size' => $compressed_size, 'dirname' => $dir_export, 'tmpname' => $tmpname ); } // pas de fichiers caches et preg_files() les ignore (*sigh*) // http://doc.spip.org/@chargeur_montre_tout function chargeur_montre_tout($quoi) { # echo($quoi['dest']); if (!($d = @opendir($quoi['dest']))) { return; } while (($f = readdir($d)) !== false) { if ($f == '.' || $f == '..' || $f[0] != '.') { continue; } rename($quoi['dest'] . '/' . $f, $quoi['dest'] . '/'. substr($f, 1)); } } // renommer des morceaux // http://doc.spip.org/@chargeur_edit function chargeur_edit($dir, $edit) { if (!($d = @opendir($dir))) { return; } while (($f = readdir($d)) !== false) { if ($f == '.' || $f == '..') { continue; } if (is_dir($f = $dir . '/' . $f)) { chargeur_edit($f, $edit); } $contenu = file_get_contents($f); if (($change = preg_replace( array_keys($edit), array_values($edit), $contenu)) == $contenu) { continue; } $fw = fopen($f, 'w'); fwrite($fw, $change); fclose($fw); } } // renommer des morceaux // http://doc.spip.org/@chargeur_rename function chargeur_rename($quoi) { /* preg_files() est deficiante pour les fichiers caches, ca aurait pu etre bien pourtant ... */ spip_log($quoi); foreach ($quoi['rename'] as $old => $new) { !is_writable($file = $quoi['dest'] . '/' . $old) || rename($file, $quoi['dest'] . '/'. $new); } } // juste activer le plugin du repertoire $plugin // http://doc.spip.org/@chargeur_activer_plugin function chargeur_activer_plugin($plugin) { spip_log('charger_decompresser activer plugin: ' . $plugin); include_spip('inc/plugin'); ecrire_plugin_actifs(array($plugin), false, 'ajoute'); } // http://doc.spip.org/@liste_fichiers_pclzip function liste_fichiers_pclzip($status) { $list = $status['files']; $ret = ''._T('plugin_zip_content',array('taille'=>taille_en_octets($status['size']), 'rep'=>$status['dirname'])).''; $l .= "
      \n"; foreach ($list as $f) { if (basename($f) == 'svn.revision') lire_fichier($status['tmpname'].'/'.$f,$svn); if ($joli = preg_replace(',^(.*/)([^/]+/?)$,', '\1\2', $f)) { if (!$vu[dirname($f.'x')]++) $l .= "
    • ".$f."
    • \n"; else $l .= "
    • ".$joli."
    • \n"; } } $l .= "
    \n"; include_spip('inc/filtres'); if (preg_match(',([^<]+)<,', $svn, $t)) $rev = '
    revision '.$t[1].'
    '; if (preg_match(',([^<]+),', $svn, $t)) $date = '
    ' . affdate($t[1]) .'
    '; return $ret . $rev . $date . $l; } // Attention on ne sait pas ce que vaut cette URL // http://doc.spip.org/@essaie_ajouter_liste_plugins function essaie_ajouter_liste_plugins($url) { if (!preg_match(',^https?://[^.]+\.[^.]+.*/.*[^/]$,', $url)) return; include_spip('inc/distant'); if (!$rss = recuperer_page($url) OR !preg_match(', titre // si $desc on ramene aussi le descriptif du paquet desc // http://doc.spip.org/@chercher_enclosures_zip function chercher_enclosures_zip($rss, $desc = '') { $liste = array(); include_spip('inc/syndic'); foreach(analyser_backend($rss) as $item) if ($item['enclosures'] AND $zips = extraire_balises($item['enclosures'], 'a')) foreach ($zips as $zip) if (extraire_attribut($zip, 'type') == 'application/zip') { if ($url = extraire_attribut($zip, 'href')) { $liste[$url] = array($item['titre'], $item['url']); if ($desc == $url) $liste[$url][] = $item; } } spip_log(count($liste).' enclosures au format zip'); return $liste; } // Renvoie la liste des plugins distants (accessibles a travers // l'une des listes de plugins) // Si on passe desc = un url, ramener le descriptif de ce paquet // http://doc.spip.org/@liste_plugins_distants function liste_plugins_distants($desc = false) { // TODO une liste multilingue a telecharger $liste = array(); if (is_array($flux = @unserialize($GLOBALS['meta']['syndic_plug']))) { foreach ($flux as $url => $c) { if (file_exists($cache=_DIR_TMP.'syndic_plug_'.md5($url).'.xml') AND lire_fichier($cache, $rss)) $liste = array_merge(chercher_enclosures_zip($rss, $desc),$liste); } } return $liste; } // http://doc.spip.org/@afficher_liste_listes_plugins function afficher_liste_listes_plugins() { if (!is_array($flux = @unserialize($GLOBALS['meta']['syndic_plug']))) return ''; if (count($flux)){ $ret = '

    '._T('plugin_info_automatique_liste').'

      '; //$ret .= '
    • '._T('plugin_info_automatique_liste_officielle').'
    • '; foreach ($flux as $url => $c) { $a = '['._T('lien_supprimer').']'; $ret .= '
    • '.inserer_attribut(PtoBR(propre("[->$url]")),'title',$url).' ('._T('plugins_compte',array('count' => $c)).') '.$a.'
    • '; } $ret .= '
    '; $ret .= ''; } return $ret; } // Si le chargement auto est autorise, un bouton // sinon on donne l'url du zip // http://doc.spip.org/@bouton_telechargement_plugin function bouton_telechargement_plugin($url, $rep) { if (($rep == 'lib')? is_dir(_DIR_RACINE . 'lib'): (_DIR_PLUGINS_AUTO AND @is_dir(_DIR_PLUGINS_AUTO)) ) $bouton = redirige_action_post('charger_plugin', $rep, // arg = 'lib' ou 'plugins' '', '', "" ."", 'class="noajax"'); return _T('plugin_info_telecharger',array('url'=>$url,'rep'=>$rep.'/')).$bouton; } ?> spip/spip/ecrire/inc/bandeau.php0000766000000000000000000003573311236524730020044 0ustar adminadministrators forcement admin complet (ou webmestre) if (autoriser('configurer')) { $boutons_admin['configuration']= new Bouton('administration-48.png', 'icone_configuration_site'); } // autres admins (restreints ou non webmestres) peuvent aller sur les backups else if (autoriser('sauvegarder', 'admin_tech')) { $boutons_admin['admin_tech']= new Bouton('administration-48.png', 'texte_sauvegarde_base'); } $boutons_admin['espacement']=null; $urlAide= generer_url_ecrire('aide_index')."&var_lang=$spip_lang"; $boutons_admin['aide_index']= new Bouton('aide-48'.$spip_lang_rtl.'.png', 'icone_aide_ligne', $urlAide, null, "javascript:window.open('$urlAide', 'spip_aide', 'scrollbars=yes,resizable=yes,width=740,height=580');", 'aide_spip'); $boutons_admin['visiter']= new Bouton("visiter-48$spip_lang_rtl.png", 'icone_visiter_site', url_de_base()); // les sous menu des boutons, que si on est admin if ($GLOBALS['connect_statut'] == '0minirezo' AND $GLOBALS['connect_toutes_rubriques']) { // sous menu edition $sousmenu=array(); $nombre_articles = sql_fetsel('id_article', 'spip_auteurs_articles', "id_auteur=".$GLOBALS['connect_id_auteur']); if ($nombre_articles > 0) { $sousmenu['articles_page']= new Bouton('article-24.gif', 'icone_tous_articles'); } if ($GLOBALS['meta']["activer_breves"] != "non") { $sousmenu['breves']= new Bouton('breve-24.gif', 'icone_breves'); } $articles_mots = $GLOBALS['meta']['articles_mots']; if ($articles_mots != "non") { $sousmenu['mots_tous']= new Bouton('mot-cle-24.gif', 'icone_mots_cles'); } $activer_sites = $GLOBALS['meta']['activer_sites']; if ($activer_sites<>'non') $sousmenu['sites_tous']= new Bouton('site-24.gif', 'icone_sites_references'); $n = sql_countsel('spip_documents_liens', 'id_objet>0 AND objet=\'rubrique\''); if ($n) { $sousmenu['documents_liste']= new Bouton('doc-24.gif', 'icone_doc_rubrique'); } $boutons_admin['naviguer']->sousmenu= $sousmenu; // sous menu forum $sousmenu=array(); if ($GLOBALS['meta']['forum_prive_admin'] == 'oui') $sousmenu['forum_admin']= new Bouton('forum-admin-24.gif', 'icone_forum_administrateur'); if (sql_countsel('spip_forum')) $sousmenu['controle_forum']= new Bouton("suivi-forum-24.gif", "icone_suivi_forums"); if (sql_countsel('spip_signatures')) $sousmenu['controle_petition']= new Bouton("suivi-petition-24.gif", "icone_suivi_pettions"); // Si le forum a ete desactive, mais qu'il y a un sous-menu de suivi // des forums ou des petitions, on colle ce suivi sous le menu "a suivre" if ($sousmenu) { if (isset($boutons_admin['forum'])) $boutons_admin['forum']->sousmenu= $sousmenu; else $boutons_admin['accueil']->sousmenu= $sousmenu; } // sous menu auteurs $sousmenu=array(); if (avoir_visiteurs(true)) $sousmenu['auteurs'] = new Bouton("fiche-perso.png", 'icone_afficher_visiteurs', null, "statut=!1comite,0minirezo,nouveau"); $sousmenu['auteur_infos']= new Bouton("auteur-24.gif", "icone_creer_nouvel_auteur", null, 'new=oui'); $boutons_admin['auteurs']->sousmenu= $sousmenu; // sous menu statistiques if (isset($boutons_admin['statistiques_visites'])) { $sousmenu=array( //'espacement' => null,// les espacements debloquent si on a des icones sur 2 lignes 'statistiques_repartition' => new Bouton("rubrique-24.gif", "icone_repartition_visites") ); if ($GLOBALS['meta']['multi_articles'] == 'oui' OR $GLOBALS['meta']['multi_rubriques'] == 'oui') $sousmenu['statistiques_lang']= new Bouton("langues-24.gif", "onglet_repartition_lang"); $sousmenu['statistiques_referers']= new Bouton("referers-24.gif", "titre_liens_entrants"); $boutons_admin['statistiques_visites']->sousmenu= $sousmenu; } // sous menu configuration $sousmenu = array(); if (autoriser('configurer', 'lang')) { $sousmenu['config_lang'] = new Bouton("langues-24.gif", "icone_gestion_langues"); //$sousmenu['espacement'] = null; // les espacements debloquent si on a des icones sur 2 lignes } if (autoriser('sauvegarder')) { $sousmenu['admin_tech']= new Bouton("base-24.gif", "icone_maintenance_site"); } if (autoriser('configurer', 'admin_vider')) { $sousmenu['admin_vider']= new Bouton("cache-24.gif", "onglet_vider_cache"); } // Si _DIR_PLUGINS est definie a '', pas de bouton if (_DIR_PLUGINS AND autoriser('configurer', 'admin_plugin')) { $sousmenu['admin_plugin']= new Bouton("plugin-24.gif", "icone_admin_plugin"); } if ($sousmenu) $boutons_admin['configuration']->sousmenu= $sousmenu; } // fin si admin // ajouter les boutons issus des plugin via plugin.xml if (function_exists('boutons_plugins') AND is_array($liste_boutons_plugins = boutons_plugins())){ foreach($liste_boutons_plugins as $id => $infos){ if (autoriser('bouton',$id)){ if (($parent = $infos['parent']) && isset($boutons_admin[$parent])) $boutons_admin[$parent]->sousmenu[$id]= new Bouton( find_in_path($infos['icone']), // icone $infos['titre'], // titre $infos['url']?$infos['url']:null, $infos['args']?$infos['args']:null ); if (!$parent) { $boutons_admin = array_slice($boutons_admin,0,-3,true) +array($id=> new Bouton( find_in_path($infos['icone']), // icone $infos['titre'], // titre $infos['url']?generer_url_ecrire($infos['url'],$infos['args']?$infos['args']:''):null )) + array_slice($boutons_admin,-3,3,true); } } } } $boutons_admin = pipeline('ajouter_boutons', $boutons_admin); } // http://doc.spip.org/@bandeau_creer_url function bandeau_creer_url($url, $args=""){ if (preg_match(',[\/\?],',$url)) return $url; else return generer_url_ecrire($url,$args); } // http://doc.spip.org/@bandeau_principal function bandeau_principal($rubrique, $sous_rubrique, $largeur) { $res = ''; $decal = 0; //cherche les espacement pour determiner leur largeur $num_espacements = 0; foreach($GLOBALS['boutons_admin'] as $page => $detail) { if ($page=='espacement') $num_espacements++; } $larg_espacements = ($largeur-(count($GLOBALS['boutons_admin'])-$num_espacements)*_LARGEUR_ICONES_BANDEAU)/$num_espacements; foreach($GLOBALS['boutons_admin'] as $page => $detail) { if ($page=='espacement') { $res .= "
  •  
  • "; } else { if ($detail->url) $lien_noscript = bandeau_creer_url($detail->url); else $lien_noscript = generer_url_ecrire($page); if ($detail->url2) $lien = bandeau_creer_url($detail->url2); else $lien = $lien_noscript; $res .= icone_bandeau_principal( $detail, $lien, $page, $rubrique, $lien_noscript, $page, $sous_rubrique, $largeur,$decal); } $decal += _LARGEUR_ICONES_BANDEAU; } return "
      \n$res
    "; } // http://doc.spip.org/@icone_bandeau_principal function icone_bandeau_principal($detail, $lien, $rubrique_icone = "vide", $rubrique = "", $lien_noscript = "", $sous_rubrique_icone = "", $sous_rubrique = "",$largeur,$decal){ global $spip_display, $menu_accesskey, $compteur_survol; $alt = $accesskey = $title = ''; $texte = _T($detail->libelle); if ($spip_display == 3){ $title = " title=\"$texte\""; } if (!$menu_accesskey = intval($menu_accesskey)) $menu_accesskey = 1; if ($menu_accesskey < 10) { $accesskey = " accesskey='$menu_accesskey'"; $menu_accesskey++; } else if ($menu_accesskey == 10) { $accesskey = " accesskey='0'"; $menu_accesskey++; } $class_select = " style='width:"._LARGEUR_ICONES_BANDEAU."px' class='menu-item boutons_admin".($sous_rubrique_icone == $sous_rubrique ? " selection" : "")."'"; if (strncasecmp("javascript:",$lien,11)==0) { $a_href = "\nonclick=\"$lien; return false;\" href='$lien_noscript' "; } else { $a_href = "\nhref=\"$lien\""; } $compteur_survol ++; if ($spip_display != 1 AND $spip_display != 4) { $class ='cellule48'; $texte = "icone).">".($spip_display == 3 ? '' : "$texte"); } else { $class = 'cellule-texte'; } return "
  • " . $texte . "\n" . bandeau_principal2($detail->sousmenu,$rubrique, $sous_rubrique, $largeur, $decal) . "
  • \n"; } // http://doc.spip.org/@bandeau_principal2 function bandeau_principal2($sousmenu,$rubrique, $sous_rubrique, $largeur, $decal) { $res = ''; $coeff_decalage = 0; if ($GLOBALS['browser_name']=="MSIE") $coeff_decalage = 1.0; $largeur_maxi_menu = $largeur-100; $largitem_moy = 85; // if (($rubrique == $page) AND (!_SPIP_AJAX)) { $page ?????? if ((!_SPIP_AJAX)) { $class = "visible_au_chargement"; } else { $class = "invisible_au_chargement"; } if($sousmenu) { //offset is not necessary when javascript is active. It can be usefull when js is disabled $offset = (int)round($decal-$coeff_decalage*max(0,($decal+count($sousmenu)*$largitem_moy-$largeur_maxi_menu))); if ($offset<0){ $offset = 0; } $width=0; $max_width=0; foreach($sousmenu as $souspage => $sousdetail) { if ($width+1.25*$largitem_moy>$largeur_maxi_menu){ $res .= "
      \n"; if($width>$max_width) $max_width=$width; $width=0; } $largitem = 0; if($souspage=='espacement') { if ($width>0){ $res .= "
    • \n"; } } else { list($html,$largitem) = icone_bandeau_secondaire (_T($sousdetail->libelle), bandeau_creer_url($sousdetail->url?$sousdetail->url:$souspage, $sousdetail->urlArg), $sousdetail->icone, $souspage, $sous_rubrique ); $res .= $html; } $width+=$largitem+10; if($width>$max_width) $max_width+=$largitem; } $res .= "
    \n"; $res = "
      ".$res; } return $res; } //script to show the submenus in IE6, not supporting :hover on li elements define('_JS_ADMIN_IE6', " "); // http://doc.spip.org/@icone_bandeau_secondaire function icone_bandeau_secondaire($texte, $lien, $fond, $rubrique_icone = "vide", $rubrique, $aide=""){ global $spip_display; global $menu_accesskey, $compteur_survol; $alt = ''; $title = ''; $accesskey = ''; if ($spip_display == 1) { //$hauteur = 20; $largeur = 80; } else if ($spip_display == 3){ //$hauteur = 26; $largeur = 40; $title = "title=\"$texte\""; $alt = $texte; } else { //$hauteur = 68; if (count(explode(" ", $texte)) > 1) $largeur = 80; else $largeur = 70; $alt = ""; } if ($aide AND $spip_display != 3) { $largeur += 50; //$texte .= aide($aide); } if ($spip_display != 3 AND strlen($texte)>16) $largeur += 20; if (!$menu_accesskey = intval($menu_accesskey)) $menu_accesskey = 1; if ($menu_accesskey < 10) { $accesskey = " accesskey='$menu_accesskey'"; $menu_accesskey++; } else if ($menu_accesskey == 10) { $accesskey = " accesskey='0'"; $menu_accesskey++; } if ($spip_display == 3) $accesskey_icone = $accesskey; $class_select = " class='menu-item".($rubrique_icone != $rubrique ? "" : " selection")."'"; $compteur_survol ++; $a_href = ""; if ($spip_display != 1) { $res = "
    • "; $res .= $a_href . http_img_pack("$fond", $alt, "$title"); if ($aide AND $spip_display != 3) $res .= aide($aide)." "; if ($spip_display != 3) { $res .= "$texte"; } $res .= "
    • \n"; } else $res = "
    • $a_href". $texte . "
    • \n"; return array($res, $largeur); } function inc_bandeau_dist($rubrique, $sous_rubrique, $largeur) { definir_barre_boutons(); return "
      \n" . bandeau_principal($rubrique, $sous_rubrique, $largeur) . "
      " . _JS_ADMIN_IE6; } ?> spip/spip/ecrire/inc/xml.php0000766000000000000000000001300711236524730017233 0ustar adminadministrators][^>]*?)>}sS"); // http://doc.spip.org/@spip_xml_parse function spip_xml_parse(&$texte, $strict=true, $clean=true, $profondeur = -1){ $out = array(); // enlever les commentaires $charset = 'AUTO'; if ($clean===true){ if (preg_match(",<\?xml\s(.*?)encoding=['\"]?(.*?)['\"]?(\s(.*))?\?>,im",$texte,$regs)) $charset = $regs[2]; $texte = preg_replace(',,is','',$texte); $texte = preg_replace(',<\?(.*?)\?>,is','',$texte); include_spip('inc/charsets'); $clean = $charset; //$texte = importer_charset($texte,$charset); } if (is_string($clean)) $charset = $clean; $txt = $texte; // tant qu'il y a des tags $chars = preg_split(_SPIP_XML_TAG_SPLIT,$txt,2,PREG_SPLIT_DELIM_CAPTURE); while(count($chars)>=2){ // tag ouvrant //$chars = preg_split("{<([^>]*?)>}s",$txt,2,PREG_SPLIT_DELIM_CAPTURE); // $before doit etre vide ou des espaces uniquements! $before = trim($chars[0]); if (strlen($before)>0) return importer_charset($texte,$charset);//$texte; // before non vide, donc on est dans du texte $tag = rtrim($chars[1]); $txt = $chars[2]; if (strncmp($tag,'"); $p = strpos($txt,""); if ($p!==FALSE AND (strpos($txt,"<")<$p)){ $nclose =0; $nopen = 0; $d = 0; while ( $p!==FALSE AND ($morceau = substr($txt,$d,$p-$d)) AND (($nopen+=preg_match_all("{<".preg_quote($closing_tag)."(\s*>|\s[^>]*[^/>]>)}is",$morceau,$matches,PREG_SET_ORDER))>$nclose) ){ $nclose++; $d=$p+$ncclos; $p = strpos($txt,"",$d); } } if ($p===FALSE){ if ($strict){ $out[$tag][]="erreur : tag fermant $tag manquant::$txt"; return $out; } else return importer_charset($texte,$charset);//$texte // un tag qui constitue du texte a reporter dans $before } $content = substr($txt,0,$p); $txt = substr($txt,$p+$ncclos); if ($profondeur==0 OR strpos($content,"<")===FALSE) // eviter une recursion si pas utile $out[$tag][] = importer_charset($content,$charset);//$content; else $out[$tag][]=spip_xml_parse($content, $strict, $clean, $profondeur-1); } $chars = preg_split(_SPIP_XML_TAG_SPLIT,$txt,2,PREG_SPLIT_DELIM_CAPTURE); } if (count($out)&&(strlen(trim($txt))==0)) return $out; else return importer_charset($texte,$charset);//$texte; } // http://doc.spip.org/@spip_xml_aplatit function spip_xml_aplatit($arbre,$separateur = " "){ $s = ""; if (is_array($arbre)) foreach($arbre as $tag=>$feuille){ if (is_array($feuille)){ if ($tag!==intval($tag)){ $f = spip_xml_aplatit($feuille, $separateur); if (strlen($f)) { $tagf = explode(" ",$tag); $tagf = $tagf[0]; $s.="<$tag>$f"; } else $s.="<$tag />"; } else $s.=spip_xml_aplatit($feuille); $s .= $separateur; } else $s.="$feuille$separateur"; } return strlen($separateur)?substr($s,0,-strlen($separateur)):$s; } // http://doc.spip.org/@spip_xml_tagname function spip_xml_tagname($tag){ if (preg_match(',^([a-z][\w:]*),i',$tag,$reg)) return $reg[1]; return ""; } // http://doc.spip.org/@spip_xml_decompose_tag function spip_xml_decompose_tag($tag){ $tagname = spip_xml_tagname($tag); $liste = array(); $p=strpos($tag,' '); $tag = substr($tag,$p); $p=strpos($tag,'='); while($p!==false){ $attr = trim(substr($tag,0,$p)); $tag = ltrim(substr($tag,$p+1)); $quote = $tag{0}; $p=strpos($tag,$quote,1); $cont = substr($tag,1,$p-1); $liste[$attr] = $cont; $tag = substr($tag,$p+1); $p=strpos($tag,'='); } return array($tagname,$liste); } // http://doc.spip.org/@spip_xml_match_nodes function spip_xml_match_nodes($regexp,&$arbre,&$matches){ if(is_array($arbre) && count($arbre)) foreach(array_keys($arbre) as $tag){ if (preg_match($regexp,$tag)) $matches[$tag] = &$arbre[$tag]; if (is_array($arbre[$tag])) foreach(array_keys($arbre[$tag]) as $occurences) spip_xml_match_nodes($regexp,$arbre[$tag][$occurences],$matches); } return (count($matches)); } ?> spip/spip/ecrire/inc/chercher_rubrique.php0000766000000000000000000001766611236524730022153 0ustar adminadministrators 0 AND $root == $exclus) return ''; // en fonction du niveau faire un affichage plus ou moins kikoo // selected ? $selected = ($root == $id_rubrique) ? ' selected="selected"' : ''; // le style en fonction de la profondeur list($class, $style, $espace) = style_menu_rubriques($niv); // class='selec_rub' sauf pour contourner le bug MSIE / MacOs 9.0 if (!($browser_name == "MSIE" AND floor($browser_version) == "5")) $class .= " selec_rub"; // creer l''."\n"; } else $r = ''; // et le sous-menu pour ses enfants $sous = ''; if (isset($enfants[$root])) foreach ($enfants[$root] as $sousrub) $sous .= sous_menu_rubriques($id_rubrique, $sousrub, $niv+1, $data, $enfants, $exclus, $restreint, $type); // si l'objet a deplacer est publie, verifier qu'on a acces aux rubriques if ($restreint AND !autoriser('publierdans','rubrique',$root)) return $sous; // sauter un cran pour les secteurs (sauf premier) if ($niv == 1 AND $decalage_secteur++ AND $type != 'breve') $r = "\n".$r; // et voila le travail return $r.$sous; } // Le selecteur de rubriques en mode classique (menu) // http://doc.spip.org/@selecteur_rubrique_html function selecteur_rubrique_html($id_rubrique, $type, $restreint, $idem=0) { $data = array(); if ($type == 'rubrique') $data[0] = _T('info_racine_site'); if ($type == 'auteur') $data[0] = ' '; # premier choix = neant (rubriques restreintes) // // creer une structure contenant toute l'arborescence // include_spip('base/abstract_sql'); $q = sql_select("id_rubrique, id_parent, titre, statut, lang, langue_choisie", "spip_rubriques", ($type == 'breve' ? ' id_parent=0 ' : ''), '', "0+titre,titre"); while ($r = sql_fetch($q)) { if (autoriser('voir','rubrique',$r['id_rubrique'])){ // titre largeur maxi a 50 $titre = couper(supprimer_tags(typo(extraire_multi($r['titre'] )))." ", 50); if ($GLOBALS['meta']['multi_rubriques'] == 'oui' AND ($r['langue_choisie'] == "oui" OR $r['id_parent'] == 0)) $titre .= ' ['.traduire_nom_langue($r['lang']).']'; $data[$r['id_rubrique']] = $titre; $enfants[$r['id_parent']][] = $r['id_rubrique']; if ($id_rubrique == $r['id_rubrique']) $id_parent = $r['id_parent']; } } $opt = sous_menu_rubriques($id_rubrique,0, 0,$data,$enfants,$idem, $restreint, $type); $att = " id='id_parent' name='id_parent'\nclass='selecteur_parent verdana1'"; if (preg_match(',^]*value=.(\d*).[^<>]*>([^<]*)$,',$opt,$r)) $r = "" . $r[2] ; else $r = "\n$opt\n"; # message pour neuneus (a supprimer ?) # if ($type != 'auteur' AND $type != 'breve') # $r .= "\n
      "._T('texte_rappel_selection_champs'); return $r; } // http://doc.spip.org/@selecteur_rubrique_ajax function selecteur_rubrique_ajax($id_rubrique, $type, $restreint, $idem=0, $do) { ## $restreint indique qu'il faut limiter les rubriques affichees ## aux rubriques editables par l'admin restreint... or, ca ne marche pas. ## Pour la version HTML c'est bon (cf. ci-dessus), mais pour l'ajax... ## je laisse ca aux specialistes de l'ajax & des admins restreints ## note : toutefois c'est juste un pb d'interface, car question securite ## la verification est faite a l'arrivee des donnees (Fil) if ($id_rubrique) { $titre = sql_fetsel("titre", "spip_rubriques", "id_rubrique=$id_rubrique"); $titre = $titre['titre']; } else if ($type == 'auteur') $titre = ' '; else $titre = _T('info_racine_site'); $titre = str_replace('&', '&', entites_html(textebrut(typo($titre)))); $init = " disabled='disabled' type='text' value=\"" . $titre . "\"\nstyle='width:300px;'"; $url = generer_url_ecrire('selectionner',"id=$id_rubrique&type=$type&do=$do" . (!$idem ? '' : ("&exclus=$idem&racine=" . ($restreint ? 'non' : 'oui'))) . (isset($GLOBALS['var_profile']) ? '&var_profile=1' : '')); return construire_selecteur($url, '', 'selection_rubrique', 'id_parent', $init, $id_rubrique); } // construit un bloc comportant une icone clicable avec image animee a cote // pour charger en Ajax du code a mettre sous cette icone. // Attention: changer le onclick si on change le code Html. // (la fonction JS charger_node ignore l'attribut id qui ne sert en fait pas; // getElement en mode Ajax est trop couteux). // http://doc.spip.org/@construire_selecteur function construire_selecteur($url, $js, $idom, $name, $init='', $id=0) { $icone = (strpos($idom, 'auteur')!==false) ? 'message.gif' : 'loupe.png'; return "
       *" . "" . "
      "; } ?> spip/spip/ecrire/inc/surligne.php0000766000000000000000000000767411236524730020300 0ustar adminadministrators\\\\){2})*)('),","$1\\\\$2",$surcharge_surligne); $surcharge_surligne = str_replace("\\","\\\\",$surcharge_surligne); if($GLOBALS['meta']['charset']=='utf-8') { include_spip('inc/charsets'); if(!is_utf8($surcharge_surligne)) $surcharge_surligne = utf8_encode($surcharge_surligne); } } foreach($surlignejs_engines as $engine) if($surcharge_surligne || (preg_match($engine[0],$ref) && preg_match($engine[1],$ref))) { //good referrer found or var_recherche is not null include_spip('inc/filtres'); $script = " "; // on l'insere juste avant , sinon tout en bas if (is_null($l = strpos($page,''))) $l = strlen($page); $page = substr_replace($page, $script, $l,0); break; } return $page; } ?> spip/spip/ecrire/inc/charsets.php0000766000000000000000000005457011236524730020261 0ustar adminadministrators= 4.0.6) // et que le charset interne est connu de mb_string if (!$mb) { if (function_exists('mb_internal_encoding') AND function_exists('mb_detect_order') AND function_exists('mb_substr') AND function_exists('mb_strlen') AND function_exists('mb_encode_mimeheader') AND function_exists('mb_encode_numericentity') AND function_exists('mb_decode_numericentity') AND mb_detect_order($GLOBALS['meta']['charset']) ) { mb_internal_encoding('utf-8'); $mb = 1; } else $mb = -1; } return ($mb == 1); } // Detecter les versions buggees d'iconv // http://doc.spip.org/@test_iconv function test_iconv() { static $iconv_ok; if (!$iconv_ok) { if (!function_exists('iconv')) $iconv_ok = -1; else { if (utf_32_to_unicode(@iconv('utf-8', 'utf-32', 'chaine de test')) == 'chaine de test') $iconv_ok = 1; else $iconv_ok = -1; } } return ($iconv_ok == 1); } // Test de fonctionnement du support UTF-8 dans PCRE // (contournement bug Debian Woody) // http://doc.spip.org/@test_pcre_unicode function test_pcre_unicode() { static $pcre_ok = 0; if (!$pcre_ok) { $s = " ".chr(195).chr(169)."t".chr(195).chr(169)." "; if (preg_match(',\W...\W,u', $s)) $pcre_ok = 1; else $pcre_ok = -1; } return $pcre_ok == 1; } // Plages alphanumeriques (incomplet...) // http://doc.spip.org/@pcre_lettres_unicode function pcre_lettres_unicode() { static $plage_unicode; if (!$plage_unicode) { if (test_pcre_unicode()) { // cf. http://www.unicode.org/charts/ $plage_unicode = '\w' // iso-latin . '\x{100}-\x{24f}' // europeen etendu . '\x{300}-\x{1cff}' // des tas de trucs ; } else { // fallback a trois sous $plage_unicode = '\w'; } } return $plage_unicode; } // Plage ponctuation de 0x2000 a 0x206F // (i.e. de 226-128-128 a 226-129-176) // http://doc.spip.org/@plage_punct_unicode function plage_punct_unicode() { return '\xE2(\x80[\x80-\xBF]|\x81[\x80-\xAF])'; } // corriger caracteres non-conformes : 128-159 // cf. charsets/iso-8859-1.php (qu'on recopie ici pour aller plus vite) // on peut passer un charset cible en parametre pour accelerer le passage iso-8859-1 -> autre charset // http://doc.spip.org/@corriger_caracteres_windows function corriger_caracteres_windows($texte, $charset='AUTO', $charset_cible='unicode') { static $trans; if ($charset=='AUTO') $charset = $GLOBALS['meta']['charset']; if ($charset == 'utf-8') { $p = chr(194); } else if ($charset == 'iso-8859-1') { $p = ''; } else return $texte; if (!isset($trans[$charset][$charset_cible])) { $trans[$charset][$charset_cible] = array( $p.chr(128) => "€", $p.chr(129) => ' ', # pas affecte $p.chr(130) => "‚", $p.chr(131) => "ƒ", $p.chr(132) => "„", $p.chr(133) => "…", $p.chr(134) => "†", $p.chr(135) => "‡", $p.chr(136) => "ˆ", $p.chr(137) => "‰", $p.chr(138) => "Š", $p.chr(139) => "‹", $p.chr(140) => "Œ", $p.chr(141) => ' ', # pas affecte $p.chr(142) => "Ž", $p.chr(143) => ' ', # pas affecte $p.chr(144) => ' ', # pas affecte $p.chr(145) => "‘", $p.chr(146) => "’", $p.chr(147) => "“", $p.chr(148) => "”", $p.chr(149) => "•", $p.chr(150) => "–", $p.chr(151) => "—", $p.chr(152) => "˜", $p.chr(153) => "™", $p.chr(154) => "š", $p.chr(155) => "›", $p.chr(156) => "œ", $p.chr(157) => ' ', # pas affecte $p.chr(158) => "ž", $p.chr(159) => "Ÿ", ); if ($charset_cible!='unicode'){ foreach($trans[$charset][$charset_cible] as $k=>$c) $trans[$charset][$charset_cible][$k] = unicode2charset($c, $charset_cible); } } return @str_replace(array_keys($trans[$charset][$charset_cible]), array_values($trans[$charset][$charset_cible]),$texte); } // // Transformer les é en { // $secure = true pour *ne pas convertir* les caracteres malins < & etc. // // http://doc.spip.org/@html2unicode function html2unicode($texte, $secure=false) { if (strpos($texte,'&') === false) return $texte; static $trans = array(); if (!$trans) { global $CHARSET; load_charset('html'); foreach ($CHARSET['html'] as $key => $val) { $trans["&$key;"] = $val; } } if ($secure) return str_replace(array_keys($trans),array_values($trans),$texte); else return str_replace(array('&', '"', '<', '>'),array('&', '"', '<', '>'), str_replace(array_keys($trans),array_values($trans),$texte) ); } // // Transformer les é en { // // http://doc.spip.org/@mathml2unicode function mathml2unicode($texte) { static $trans; if (!$trans) { global $CHARSET; load_charset('mathml'); foreach ($CHARSET['mathml'] as $key => $val) $trans["&$key;"] = $val; } return str_replace(array_keys($trans),array_values($trans),$texte); } // // Transforme une chaine en entites unicode  // // Note: l'argument $forcer est obsolete : il visait a ne pas // convertir les accents iso-8859-1 // http://doc.spip.org/@charset2unicode function charset2unicode($texte, $charset='AUTO' /* $forcer: obsolete*/) { static $trans; if ($charset == 'AUTO') $charset = $GLOBALS['meta']['charset']; if ($charset == '') $charset = 'iso-8859-1'; $charset = strtolower($charset); switch ($charset) { case 'utf-8': case 'utf8': return utf_8_to_unicode($texte); case 'iso-8859-1': $texte = corriger_caracteres_windows($texte, 'iso-8859-1'); // pas de break; ici, on suit sur default: default: // mbstring presente ? if (init_mb_string()) { if ($order = mb_detect_order() # mb_string connait-il $charset? AND mb_detect_order($charset)) { $s = mb_convert_encoding($texte, 'utf-8', $charset); if ($s && $s != $texte) return utf_8_to_unicode($s); } mb_detect_order($order); # remettre comme precedemment } // Sinon, peut-etre connaissons-nous ce charset ? if (!isset($trans[$charset])) { global $CHARSET; if ($cset = load_charset($charset) AND is_array($CHARSET[$cset])) foreach ($CHARSET[$cset] as $key => $val) { $trans[$charset][chr($key)] = '&#'.$val.';'; } } if (count($trans[$charset])) return str_replace(array_keys($trans[$charset]),array_values($trans[$charset]),$texte); // Sinon demander a iconv (malgre le fait qu'il coupe quand un // caractere n'appartient pas au charset, mais c'est un probleme // surtout en utf-8, gere ci-dessus) if (test_iconv()) { $s = iconv($charset, 'utf-32le', $texte); if ($s) return utf_32_to_unicode($s); } // Au pire ne rien faire spip_log("erreur charset '$charset' non supporte"); return $texte; } } // // Transforme les entites unicode  dans le charset specifie // Attention on ne transforme pas les entites < € car si elles // ont ete encodees ainsi c'est a dessein // http://doc.spip.org/@unicode2charset function unicode2charset($texte, $charset='AUTO') { static $CHARSET_REVERSE; static $trans = array(); if ($charset == 'AUTO') $charset = $GLOBALS['meta']['charset']; switch($charset) { case 'utf-8': return unicode_to_utf_8($texte); break; default: $charset = load_charset($charset); if (!is_array($CHARSET_REVERSE[$charset])) { $CHARSET_REVERSE[$charset] = array_flip($GLOBALS['CHARSET'][$charset]); } if (!isset($trans[$charset])){ $trans[$charset]=array(); $t = &$trans[$charset]; for($e=128;$e<255;$e++){ $h = dechex($e); if ($s = isset($CHARSET_REVERSE[$charset][$e])){ $s = $CHARSET_REVERSE[$charset][$e]; $t['&#'.$e.';'] = $t['�'.$e.';'] = $t['�'.$e.';'] = chr($s); $t['&#x'.$h.';'] = $t['�'.$h.';'] = $t['�'.$h.';'] = chr($s); } else{ $t['&#'.$e.';'] = $t['�'.$e.';'] = $t['�'.$e.';'] = chr($e); $t['&#x'.$h.';'] = $t['�'.$h.';'] = $t['�'.$h.';'] = chr($e); } } } $texte = str_replace(array_keys($trans[$charset]),array_values($trans[$charset]),$texte); return $texte; } } // Importer un texte depuis un charset externe vers le charset du site // (les caracteres non resolus sont transformes en {) // http://doc.spip.org/@importer_charset function importer_charset($texte, $charset = 'AUTO') { // on traite le cas le plus frequent iso-8859-1 vers utf directement pour aller plus vite ! if (($charset == 'iso-8859-1') && ($GLOBALS['meta']['charset']=='utf-8') && function_exists('utf8_encode')){ $texte = corriger_caracteres_windows($texte, 'iso-8859-1','unicode'); $texte = utf8_encode($texte); return $texte; } return unicode2charset(charset2unicode($texte, $charset)); } // UTF-8 // http://doc.spip.org/@utf_8_to_unicode function utf_8_to_unicode($source) { // mb_string : methode rapide if (init_mb_string()) { $convmap = array(0x7F, 0xFFFFFF, 0x0, 0xFFFFFF); return mb_encode_numericentity($source, $convmap, 'UTF-8'); } // Sinon methode pas a pas static $decrement; static $shift; // Cf. php.net, par Ronen. Adapte pour compatibilite < php4 if (!is_array($decrement)) { // array used to figure what number to decrement from character order value // according to number of characters used to map unicode to ascii by utf-8 $decrement[4] = 240; $decrement[3] = 224; $decrement[2] = 192; $decrement[1] = 0; // the number of bits to shift each charNum by $shift[1][0] = 0; $shift[2][0] = 6; $shift[2][1] = 0; $shift[3][0] = 12; $shift[3][1] = 6; $shift[3][2] = 0; $shift[4][0] = 18; $shift[4][1] = 12; $shift[4][2] = 6; $shift[4][3] = 0; } $pos = 0; $len = strlen ($source); $encodedString = ''; while ($pos < $len) { $char = ''; $ischar = false; $asciiPos = ord (substr ($source, $pos, 1)); if (($asciiPos >= 240) && ($asciiPos <= 255)) { // 4 chars representing one unicode character $thisLetter = substr ($source, $pos, 4); $pos += 4; } else if (($asciiPos >= 224) && ($asciiPos <= 239)) { // 3 chars representing one unicode character $thisLetter = substr ($source, $pos, 3); $pos += 3; } else if (($asciiPos >= 192) && ($asciiPos <= 223)) { // 2 chars representing one unicode character $thisLetter = substr ($source, $pos, 2); $pos += 2; } else { // 1 char (lower ascii) $thisLetter = substr ($source, $pos, 1); $pos += 1; $char = $thisLetter; $ischar = true; } if ($ischar) $encodedString .= $char; else { // process the string representing the letter to a unicode entity $thisLen = strlen ($thisLetter); $thisPos = 0; $decimalCode = 0; while ($thisPos < $thisLen) { $thisCharOrd = ord (substr ($thisLetter, $thisPos, 1)); if ($thisPos == 0) { $charNum = intval ($thisCharOrd - $decrement[$thisLen]); $decimalCode += ($charNum << $shift[$thisLen][$thisPos]); } else { $charNum = intval ($thisCharOrd - 128); $decimalCode += ($charNum << $shift[$thisLen][$thisPos]); } $thisPos++; } $encodedLetter = "&#". preg_replace('/^0+/', '', $decimalCode) . ';'; $encodedString .= $encodedLetter; } } return $encodedString; } // UTF-32 ne sert plus que si on passe par iconv, c'est-a-dire quand // mb_string est absente ou ne connait pas notre charset // mais on l'optimise quand meme par mb_string // => tout ca sera osolete quand on sera surs d'avoir mb_string // http://doc.spip.org/@utf_32_to_unicode function utf_32_to_unicode($source) { // mb_string : methode rapide if (init_mb_string()) { $convmap = array(0x7F, 0xFFFFFF, 0x0, 0xFFFFFF); $source = mb_encode_numericentity($source, $convmap, 'UTF-32LE'); return str_replace(chr(0), '', $source); } // Sinon methode lente $texte = ''; while ($source) { $words = unpack("V*", substr($source, 0, 1024)); $source = substr($source, 1024); foreach ($words as $word) { if ($word < 128) $texte .= chr($word); // ignorer le BOM - http://www.unicode.org/faq/utf_bom.html else if ($word != 65279) $texte .= '&#'.$word.';'; } } return $texte; } // Ce bloc provient de php.net, auteur Ronen // http://doc.spip.org/@caractere_utf_8 function caractere_utf_8($num) { if($num<128) return chr($num); if($num<2048) return chr(($num>>6)+192).chr(($num&63)+128); if($num<65536) return chr(($num>>12)+224).chr((($num>>6)&63)+128).chr(($num&63)+128); if($num<1114112) return chr($num>>18+240).chr((($num>>12)&63)+128).chr(($num>>6)&63+128). chr($num&63+128); return ''; } // http://doc.spip.org/@unicode_to_utf_8 function unicode_to_utf_8($texte) { // 1. Entites € et suivantes $vu = array(); if (preg_match_all(',�*([1-9][0-9][0-9]+);,S', $texte, $regs, PREG_SET_ORDER)) foreach ($regs as $reg) { if ($reg[1]>127 AND !isset($vu[$reg[0]])) $vu[$reg[0]] = caractere_utf_8($reg[1]); } //$texte = str_replace(array_keys($vu), array_values($vu), $texte); // 2. Entites > ÿ //$vu = array(); if (preg_match_all(',�*([1-9a-f][0-9a-f][0-9a-f]+);,iS', $texte, $regs, PREG_SET_ORDER)) foreach ($regs as $reg) { if (!isset($vu[$reg[0]])) $vu[$reg[0]] = caractere_utf_8(hexdec($reg[1])); } return str_replace(array_keys($vu), array_values($vu), $texte); } // convertit les Ĉ en \u0108 // http://doc.spip.org/@unicode_to_javascript function unicode_to_javascript($texte) { $vu = array(); while (preg_match(',�*([0-9]+);,S', $texte, $regs) AND !isset($vu[$regs[1]])) { $num = $regs[1]; $vu[$num] = true; $s = '\u'.sprintf("%04x", $num); $texte = str_replace($regs[0], $s, $texte); } return $texte; } // convertit les %uxxxx (envoyes par javascript) // http://doc.spip.org/@javascript_to_unicode function javascript_to_unicode ($texte) { while (preg_match(",%u([0-9A-F][0-9A-F][0-9A-F][0-9A-F]),", $texte, $regs)) $texte = str_replace($regs[0],"&#".hexdec($regs[1]).";", $texte); return $texte; } // convertit les %E9 (envoyes par le browser) en chaine du charset du site (binaire) // http://doc.spip.org/@javascript_to_binary function javascript_to_binary ($texte) { while (preg_match(",%([0-9A-F][0-9A-F]),", $texte, $regs)) $texte = str_replace($regs[0],chr(hexdec($regs[1])), $texte); return $texte; } // http://doc.spip.org/@translitteration_rapide function translitteration_rapide($texte, $charset='AUTO', $complexe='') { static $trans; if ($charset == 'AUTO') $charset = $GLOBALS['meta']['charset']; if (!strlen($texte)) return $texte; $table_translit ='translit'.$complexe; // 2. Translitterer grace a la table predefinie if (!$trans[$complexe]) { global $CHARSET; load_charset($table_translit); foreach ($CHARSET[$table_translit] as $key => $val) $trans[$complexe][caractere_utf_8($key)] = $val; } return str_replace(array_keys($trans[$complexe]),array_values($trans[$complexe]),$texte); } // // Translitteration charset => ascii (pour l'indexation) // Attention les caracteres non reconnus sont renvoyes en utf-8 // // http://doc.spip.org/@translitteration function translitteration($texte, $charset='AUTO', $complexe='') { // 0. Supprimer les caracteres illegaux include_spip('inc/filtres'); $texte = corriger_caracteres($texte); // 1. Passer le charset et les é en utf-8 $texte = unicode_to_utf_8(html2unicode(charset2unicode($texte, $charset, true))); return translitteration_rapide($texte,$charset,$complexe); } // à est retourne sous la forme "a`" et pas "a" // mais si $chiffre=true, on retourne "a8" (vietnamien) // http://doc.spip.org/@translitteration_complexe function translitteration_complexe($texte, $chiffres=false) { $texte = translitteration($texte,'AUTO','complexe'); if ($chiffres) { $texte = preg_replace("/[aeiuoyd]['`?~.^+(-]{1,2}/eS", "translitteration_chiffree('\\0')", $texte); } return $texte; } // http://doc.spip.org/@translitteration_chiffree function translitteration_chiffree($car) { return strtr($car, "'`?~.^+(-", "123456789"); } // Reconnaitre le BOM utf-8 (0xEFBBBF) // http://doc.spip.org/@bom_utf8 function bom_utf8($texte) { return (substr($texte, 0,3) == chr(0xEF).chr(0xBB).chr(0xBF)); } // Verifie qu'un document est en utf-8 valide // http://us2.php.net/manual/fr/function.mb-detect-encoding.php#50087 // http://w3.org/International/questions/qa-forms-utf-8.html // note: preg_replace permet de contourner un "stack overflow" sur PCRE // http://doc.spip.org/@is_utf8 function is_utf8($string) { return !strlen( preg_replace( ',[\x09\x0A\x0D\x20-\x7E]' # ASCII . '|[\xC2-\xDF][\x80-\xBF]' # non-overlong 2-byte . '|\xE0[\xA0-\xBF][\x80-\xBF]' # excluding overlongs . '|[\xE1-\xEC\xEE\xEF][\x80-\xBF]{2}' # straight 3-byte . '|\xED[\x80-\x9F][\x80-\xBF]' # excluding surrogates . '|\xF0[\x90-\xBF][\x80-\xBF]{2}' # planes 1-3 . '|[\xF1-\xF3][\x80-\xBF]{3}' # planes 4-15 . '|\xF4[\x80-\x8F][\x80-\xBF]{2}' # plane 16 . ',sS', '', $string)); } // http://doc.spip.org/@is_ascii function is_ascii($string) { return !strlen( preg_replace( ',[\x09\x0A\x0D\x20-\x7E],sS', '', $string)); } // Transcode une page (attrapee sur le web, ou un squelette) en essayant // par tous les moyens de deviner son charset (y compris headers HTTP) // http://doc.spip.org/@transcoder_page function transcoder_page($texte, $headers='') { // Si tout est < 128 pas la peine d'aller plus loin if (is_ascii($texte)) { #spip_log('charset: ascii'); return $texte; } // Reconnaitre le BOM utf-8 (0xEFBBBF) if (bom_utf8($texte)) { $charset = 'utf-8'; $texte = substr($texte,3); } // charset precise par le contenu (xml) else if (preg_match( ',<[?]xml[^>]*encoding[^>]*=[^>]*([-_a-z0-9]+?),UimsS', $texte, $regs)) $charset = trim(strtolower($regs[1])); // charset precise par le contenu (html) else if (preg_match( ',<(meta|html|body)[^>]*charset[^>]*=[^>]*([-_a-z0-9]+?),UimsS', $texte, $regs) # eviter #CHARSET des squelettes AND (($tmp = trim(strtolower($regs[2]))) != 'charset')) $charset = $tmp; // charset de la reponse http else if (preg_match(',charset=([-_a-z0-9]+),i', $headers, $regs)) $charset = trim(strtolower($regs[1])); else $charset = ''; // normaliser les noms du shif-jis japonais if (preg_match(',^(x|shift)[_-]s?jis$,i', $charset)) $charset = 'shift-jis'; if ($charset) { spip_log("charset: $charset"); } else { // valeur par defaut if (is_utf8($texte)) $charset = 'utf-8'; else $charset = 'iso-8859-1'; spip_log("charset probable: $charset"); } return importer_charset($texte, $charset); } // // Gerer les outils mb_string // // http://doc.spip.org/@spip_substr function spip_substr($c, $start=0, $length = NULL) { // Si ce n'est pas utf-8, utiliser substr if ($GLOBALS['meta']['charset'] != 'utf-8') { if ($length) return substr($c, $start, $length); else substr($c, $start); } // Si utf-8, voir si on dispose de mb_string if (init_mb_string()) { if ($length) return mb_substr($c, $start, $length); else return mb_substr($c, $start); } // Version manuelle (cf. ci-dessous) return spip_substr_manuelle($c, $start, $length); } // version manuelle de substr utf8, pour php vieux et/ou mal installe // http://doc.spip.org/@spip_substr_manuelle function spip_substr_manuelle($c, $start, $length = NULL) { // Cas pathologique if ($length === 0) return ''; // S'il y a un demarrage, on se positionne if ($start > 0) $c = substr($c, strlen(spip_substr_manuelle($c, 0, $start))); elseif ($start < 0) return spip_substr_manuelle($c, spip_strlen($c)+$start, $length); if (!$length) return $c; if ($length > 0) { // on prend n fois la longueur desiree, pour etre surs d'avoir tout // (un caractere utf-8 prenant au maximum n bytes) $n = 0; while (preg_match(',[\x80-\xBF]{'.(++$n).'},', $c)); $c = substr($c, 0, $n*$length); // puis, tant qu'on est trop long, on coupe... while (($l = spip_strlen($c)) > $length) $c = substr($c, 0, $length - $l); return $c; } // $length < 0 return spip_substr_manuelle($c, 0, spip_strlen($c)+$length); } // http://doc.spip.org/@spip_strlen function spip_strlen($c) { // Si ce n'est pas utf-8, utiliser strlen if ($GLOBALS['meta']['charset'] != 'utf-8') return strlen($c); // Sinon, utiliser mb_strlen() si disponible if (init_mb_string()) return mb_strlen($c); // Methode manuelle : on supprime les bytes 10......, // on compte donc les ascii (0.......) et les demarrages // de caracteres utf-8 (11......) return strlen(preg_replace(',[\x80-\xBF],S', '', $c)); } // Initialisation $GLOBALS['CHARSET'] = Array(); // noter a l'occasion dans la meta pcre_u notre capacite a utiliser le flag /u // dans les preg_replace pour ne pas casser certaines lettres accentuees : // en utf-8 chr(195).chr(160) = a` alors qu'en iso-latin chr(160) = nbsp if (!isset($GLOBALS['meta']['pcre_u']) OR isset($_GET['var_mode'])) { include_spip('inc/meta'); ecrire_meta('pcre_u', $u = ($GLOBALS['meta']['charset'] == 'utf-8' AND test_pcre_unicode()) ? 'u' :'' ); } ?> spip/spip/ecrire/inc/nfslock.php0000766000000000000000000002555111236524730020101 0ustar adminadministrators * rewritten by: Alexis Rosen * rewritten by: Cedric Morin for php&SPIP * * (Excerpts from Chuck's notes: * this becomes complex, due to our dear friend, the NFS mounted mail spool. * the netbsd code didn't do this properly, as far as I could tell. * * - you can't trust exclusive creating opens over NFS, the protocol * just doesn't support it. so to do a lock you have to create * a tmp file and then try and hard link it to your lock file. * - to detect a stale lock file you have to see how old it is, but * you can't use time(0) because that is the time on the local system * and the file gets the times of the NFS server. when is a lock * file stale? people seem to like 120 or 300 seconds.) * * NB: It is _critical_ that nfslock()ed files be unlocked by nfsunlock(). * Simply unlinking the lock file is a good way to trash someone else's lock * file. All it takes is for the process doing the unlink to get hung for * a few minutes when it doesn't expect it. Meanwhile, its lock expires and * a second process forces the lock and creates its own. Then the first * process comes along and kills the second process' lock while it's still * valid. * * Security considerations: * If we're root, be very careful to see that the temp file we opened is * what we think it is. The problem is that we could lose a race with * someone who takes our tmp file and replaces it with, say, a hard * link to /etc/passwd. Then, if the first lock attempt fails, we'll * write a char to the file (see 4. below); this would truncate the * passwd file. So we make sure that the link count is 1. We don't really * care about any other screwing around since we don't write anything * sensitive to the lock file, nor do we change its owner or mode. If * someone beats us on a race and replaces our temp file with anything * else, it's no big deal- the file may get truncated, but there's no * possible security breach. ...Actually the possibility of the race * ever happening, given the random name of the file, is virtually nil. * * args: path = path to directory of lock file (/net/u/1/a/alexis/.mailspool) * namelock = file name of lock file (alexis.lock) * max_age = age of lockfile, in seconds, after which the lock is stale. * stale locks are always broken. Defaults to DEFAULT_LOCKTIME * if zero. Panix mail locks go stale at 300 seconds, the default. * notify = 1 if we should tell stdout that we're sleeping on a lock * * Returns the time that the lock was created on the other system. This is * important for nfsunlock(). If the lock already exists, returns NFSL_LOCKED. * If there is some other failure, return NFSL_SYSF. If NFSL_LOCKED is * returned, errno is also set to EEXIST. If we're root and the link count * on the tmp file is wrong, return NFSL_SECV. * * Mods of 7/13/95: Change a bit of code to re-stat the lockfile after * closing it. This is to work around a bug in SunOS that appears to to affect * some SunOS 4.1.3 machines (but not all). The bug is that close() updates * the stat st_ctime field for that file. So use lstat on fullpath instead * of fstat on tmpfd. This alteration applies to both nfslock and nfslock1. * * Mod of 5/4/95: Change printf's to fprintf(stderr... in nfslock and nfslock1. * * Mods of 4/29/95: Fix freeing memory before use if a stat fails. Remove * code that forbids running as root; instead, if root, check link count on * tmp file after opening it. * * Mods of 4/27/95: Return the create time instead of the lockfile's fd, which * is useless. Added new routines nfsunlock(), nfslock_test(), nfslock_renew(). * * Mods of 1/8/95: Eliminate some security checks since this code never * runs as root. In particular, we completely eliminate the safeopen * routine. But add one check: if we _are_ root, fail immediately. * * Change arguments: take a path and a filename. Don't assume a global or * macro pointing to a mailspool. * * Add notify argument; if 1, tell user when we're waiting for a lock. * * Add max_age argument and DEFAULT_LOCKTIME. * * Change comments drastically. * */ if (!defined("_ECRIRE_INC_VERSION")) return; include_spip('inc/acces'); define('_DEFAULT_LOCKTIME',60); define('_NAME_LOCK','spip_nfs_lock'); // http://doc.spip.org/@spip_nfslock function spip_nfslock($fichier,$max_age=0) { $tries = 0; if (!$max_age) $max_age = _DEFAULT_LOCKTIME; $lock_file = _DIR_TMP . _NAME_LOCK . "-" . substr(md5($fichier),0,8); /* * 1. create a tmp file with a psuedo random file name. we also make * tpath which is a buffer to store the full pathname of the tmp file. */ $id = creer_uniqid(); $tpath = _DIR_TMP."slock.$id"; $tmpfd = @fopen($tpath, 'w'); // hum, le 'x' necessite php4,3,2 ... if (!$tmpfd) { /* open failed */ @fclose($tmpfd); spip_unlink($tpath); return false; //NFSL_SYSF } /* * 2. make fullpath, a buffer for the full pathname of the lock file. * then start looping trying to lock it */ while ($tries < 10) { /* * 3. link tmp file to lock file. if it goes, we win and we clean * up and return the st_ctime of the lock file. */ if (link($tpath, $lock_file) == 1) { spip_unlink($tpath); /* got it! */ @fclose($tmpfd); if (($our_tmp = lstat($lock_file))==false) { /* stat failed... shouldn't happen */ spip_unlink($lock_file); return false; // (NFSL_SYSF); } return($our_tmp['ctime']); } /* * 4. the lock failed. check for a stale lock file, being mindful * of NFS and the fact the time is set from the NFS server. we * do a write on the tmp file to update its time to the server's * idea of "now." */ $old_stat = lstat($lock_file); if (@fputs($tmpfd, "zz", 2)!=2 || !$our_tmp=fstat($tmpfd)) break; /* something bogus is going on */ if ($old_stat!=false && (($old_stat['ctime'] + $max_age) < $our_tmp['ctime'])) { spip_unlink($lock_file); /* break the stale lock */ $tries++; /* It is CRITICAL that we sleep after breaking * the lock. Otherwise, we could race with * another process and unlink it's newly- * created file. */ sleep(1+rand(0,4)); continue; } /* * 5. try again */ $tries++; sleep(1+rand(0,4)); } /* * 6. give up, failure. */ spip_unlink($tpath); @fclose($tmpfd); return false; //(NFSL_LOCKED); } /* * function: nfsunlock * author: Alexis Rosen * * Unlock an nfslock()ed file. * * This can get tricky because the lock may have expired (perhaps even * during a process that should be "atomic"). We have to make sure we don't * unlock some other process' lock, and return a panic code if we think our * lock file has been broken illegally. What's done in reaction to that panic * (of anything) is up to the caller. See the comments on nfslock()! * * args: path = path to directory of lock file (/net/u/1/a/alexis/.mailspool) * namelock = file name of lock file (alexis.lock) * max_age = age of lockfile, in seconds, after which the lock is stale. * stale locks are always broken. Defaults to DEFAULT_LOCKTIME * if zero. Panix mail locks go stale at 300 seconds, the default. * birth = time the lock was created (as returned by nfslock()). * * Returns NFSL_OK if successful, NFSL_LOST if the lock has been lost * legitimately (because more than max_age has passed since the lock was * created), and NFSL_STOLEN if it's been tampered with illegally (i.e. * while this program is within the expiry period). Returns NFSL_SYSF if * another system failure prevents it from even trying to unlock the file. * * Note that for many programs, a return code of NFSL_LOST or NFSL_STOLEN is * equally disastrous; a NFSL_STOLEN means that some other program may have * trashed your file, but a NFSL_LOST may mean that _you_ have trashed someone * else's file (if in fact you wrote the file that you locked after you lost * the lock) or that you read inconsistent information. * * In practice, a return code of NFSL_LOST or NFSL_STOLEN will virtually never * happen unless someone is violating the locking protocol. * */ // http://doc.spip.org/@spip_nfsunlock function spip_nfsunlock($fichier, $birth, $max_age=0, $test = false) { $id = creer_uniqid(); if (!$max_age) $max_age = _DEFAULT_LOCKTIME; /* * 1. Build a temp file and stat that to get an idea of what the server * thinks the current time is (our_tmp.st_ctime).. */ $tpath = _DIR_TMP."stime.$id"; $tmpfd = @fopen($tpath,'w'); if ((!$tmpfd) OR (@fputs($tmpfd, "zz", 2) != 2) OR !($our_tmp = fstat($tmpfd))) { /* The open failed, or we can't write the file, or we can't stat it */ @fclose($tmpfd); spip_unlink($tpath); return false; //(NFSL_SYSF); } @fclose($tmpfd); /* We don't need this once we have our_tmp.st_ctime. */ spip_unlink($tpath); /* * 2. make fullpath, a buffer for the full pathname of the lock file */ $lock_file = _DIR_TMP . _NAME_LOCK . "-" . substr(md5($fichier),0,8); /* * 3. If the ctime hasn't been modified, unlink the file and return. If the * lock has expired, sleep the usual random interval before returning. * If we didn't sleep, there could be a race if the caller immediately * tries to relock the file. */ if ( ($old_stat=@lstat($lock_file)) /* stat succeeds so file is there */ && ($old_stat['ctime'] == $birth)) { /* hasn't been modified since birth */ if (!$test) spip_unlink($lock_file); /* so the lock is ours to remove */ if ($our_tmp['ctime'] >= $birth + $max_age){ /* the lock has expired */ if (!$test) return false; //(NFSL_LOST); sleep(1+(random(0,4))); /* so sleep a bit */ } return true;//(NFSL_OK); /* success */ } /* * 4. Either ctime has been modified, or the entire lock file is missing. * If the lock should still be ours, based on the ctime of the temp * file, return with NFSL_STOLEN. If not, then our lock is expired and * someone else has grabbed the file, so return NFSL_LOST. */ if ($our_tmp['ctime'] < $birth + $max_age) /* lock was stolen */ return false; //(NFSL_STOLEN); return false; //(NFSL_LOST); /* The lock must have expired first. */ } /* * function: nfslock_test * author: Alexis Rosen * * Test a lock to see if it's still valid. * * See the comments in nfsunlock() about lost and stolen locks. * * Args, return codes, and behavior are identical to nfsunlock except * that nfslock_test doesn't remove the lock. NFSL_OK means the lock is * good, NFLS_LOST and NFSL_STOLEN means it's bad, and NFSL_SYSF means * we couldn't tell due to system failure. * * The source for this routine is almost identical to nfsunlock(), but it's * coded separately to make things as clear as possible. */ // http://doc.spip.org/@spip_nfslock_test function spip_nfslock_test($fichier, $birth, $max_age=0) { return spip_nfsunlock($fichier, $birth, $max_age, true); } ?> spip/spip/ecrire/inc/php3.php0000766000000000000000000000625111236524730017310 0ustar adminadministrators $val) { if (!isset($GLOBALS[$var]) # indispensable securite AND isset($GLOBALS[$_table][$var]) AND ($_table == '_SERVER' OR !in_array($var, $refuse_gpc)) AND ($_table <> '_COOKIE' OR !in_array($var, $refuse_c))) $GLOBALS[$var] = $val; } } } } ?> spip/spip/ecrire/inc/lien.php0000766000000000000000000004163511236524730017372 0ustar adminadministratorsurl] etc. // Note : complique car c'est ici qu'on applique typo(), // et en plus on veut pouvoir les passer en pipeline // // http://doc.spip.org/@traiter_raccourci_lien_lang function inc_lien_dist($lien, $texte='', $class='', $title='', $hlang='', $rel='', $connect='') { $mode = ($texte AND $class) ? 'url' : 'tout'; $lien = calculer_url($lien, $texte, $mode, $connect); if ($mode === 'tout') { $texte = $lien['titre']; if (!$class AND isset($lien['class'])) $class = $lien['class']; $lang = isset($lien['lang']) ?$lien['lang'] : ''; $lien = $lien['url']; } if (substr($lien,0,1) == '#') # ancres pures (internes a la page) $class = 'spip_ancre'; elseif (preg_match('/^\s*mailto:/',$lien)) # pseudo URL de mail $class = "spip_mail"; elseif (preg_match('/^/',$lien)) # cf traiter_lien_explicite $class = "spip_url spip_out"; elseif (!$class) $class = "spip_out"; # si pas spip_in|spip_glossaire // Si l'objet n'est pas de la langue courante, on ajoute hreflang if (!$hlang AND $lang!==$GLOBALS['spip_lang']) $hlang = $lang; $lang = ($hlang ? " hreflang='$hlang'" : ''); if ($title) $title = ' title="'.texte_backend($title).'"'; if ($rel) $rel = " rel='$rel'"; $lien = "$texte"; # ceci s'execute heureusement avant les tableaux et leur "|". # Attention, le texte initial est deja echappe mais pas forcement # celui retourne par calculer_url. # Penser au cas [->URL], qui exige typo('...') return typo($lien, true, $connect); } // Regexp des raccouris, aussi utilisee pour la fusion de sauvegarde Spip // Laisser passer des paires de crochets pour la balise multi // mais refuser plus d'imbrications ou de mauvaises imbrications // sinon les crochets ne peuvent plus servir qu'a ce type de raccourci define('_RACCOURCI_LIEN', "/\[([^][]*?([[]\w*[]][^][]*)*)->(>?)([^]]*)\]/msS"); // http://doc.spip.org/@expanser_liens function expanser_liens($texte, $connect='') { $texte = pipeline('pre_liens', $texte); $inserts = $regs = array(); if (preg_match_all(_RACCOURCI_LIEN, $texte, $regs, PREG_SET_ORDER)) { $lien = charger_fonction('lien', 'inc'); foreach ($regs as $k => $reg) { $inserts[$k] = '@@SPIP_ECHAPPE_LIEN_' . $k . '@@'; $texte = str_replace($reg[0], $inserts[$k], $texte); list($titre, $bulle, $hlang) = traiter_raccourci_lien_atts($reg[1]); $r = $reg[count($reg)-1]; $regs[$k] = $lien($r, $titre, '', $bulle, $hlang, '', $connect); } } $texte = traiter_modeles($texte, false, false, $connect); $texte = corriger_typo($texte); $texte = str_replace($inserts, $regs, $texte); return $texte; } // Meme analyse mais pour eliminer les liens // et ne laisser que leur titre, a expliciter si ce n'est fait // http://doc.spip.org/@nettoyer_raccourcis_typo function nettoyer_raccourcis_typo($texte, $connect='') { $texte = pipeline('nettoyer_raccourcis_typo',$texte); if (preg_match_all(_RACCOURCI_LIEN, $texte, $regs, PREG_SET_ORDER)) foreach ($regs as $reg) { list ($titre,,)= traiter_raccourci_lien_atts($reg[1]); if (!$titre) { $match = typer_raccourci($reg[count($reg)-1]); @list($type,,$id,,,,) = $match; $titre = traiter_raccourci_titre($id, $type, $connect); $titre = $titre ? $titre['titre'] : $match[0]; } $titre = corriger_typo(supprimer_tags($titre)); $texte = str_replace($reg[0], $titre, $texte); } // supprimer les notes $texte = preg_replace(",[[][[]([^]]|[]][^]])*[]][]],UimsS","",$texte); // supprimer les codes typos $texte = str_replace(array('}','{'), '', $texte); // supprimer les tableaux $texte = preg_replace(",(^|\r)\|.*\|\r,s", "\r", $texte); return $texte; } // Repere dans la partie texte d'un raccourci [texte->...] // la langue et la bulle eventuelles define('_RACCOURCI_ATTRIBUTS', '/^(.*?)([|]([^<>]*?))?([{]([a-z_]*)[}])?$/'); // http://doc.spip.org/@traiter_raccourci_lien_atts function traiter_raccourci_lien_atts($texte) { $bulle = $hlang = ''; // title et hreflang donnes par le raccourci ? if (preg_match(_RACCOURCI_ATTRIBUTS, $texte, $m)) { $n =count($m); // |infobulle ? if ($n > 2) { $bulle = $m[3]; // {hreflang} ? if ($n > 4) { // si c'est un code de langue connu, on met un hreflang if (traduire_nom_langue($m[5]) <> $m[5]) { $hlang = $m[5]; } elseif (!$m[5]) { $hlang = test_espace_prive() ? $GLOBALS['lang_objet'] : $GLOBALS['spip_lang']; // sinon c'est un italique } else { $m[1] .= $m[4]; } // S'il n'y a pas de hreflang sous la forme {}, ce qui suit le | // est peut-etre une langue } else if (preg_match('/^[a-z_]+$/', $m[3])) { // si c'est un code de langue connu, on met un hreflang // mais on laisse le title (c'est arbitraire tout ca...) if (traduire_nom_langue($m[3]) <> $m[3]) { $hlang = $m[3]; } } } $texte = $m[1]; } return array(trim($texte), $bulle, $hlang); } define('_EXTRAIRE_DOMAINE', '/^(?:[^\W_]((?:[^\W_]|-){0,61}[^\W_,])?\.)+[a-z]{2,6}\b/Si'); // callback pour la fonction traiter_raccourci_liens() // http://doc.spip.org/@autoliens_callback function traiter_autoliens($r) { if (count($r)<2) return reset($r); list($tout, $l) = $r; if (!$l) return $tout; // reperer le protocole if (preg_match(',^(https?):/*,S', $l, $m)) { $l = substr($l, strlen($m[0])); $protocol = $m[1]; } else $protocol = 'http'; // valider le nom de domaine if (!preg_match(_EXTRAIRE_DOMAINE, $l)) return $tout; // supprimer les ponctuations a la fin d'une URL preg_match('/^(.*?)([,.;?]?)$/', $l, $k); $url = $protocol.'://'.$k[1]; $lien = charger_fonction('lien', 'inc'); $r = $lien($url,'','','','','nofollow') . $k[2]; // si l'original ne contenait pas le 'http:' on le supprime du clic return $m ? $r : str_replace('>http://', '>', $r); } define('_EXTRAIRE_LIENS', ',' . '\[[^\[\]]*(?:<-|->).*?\]' . '|' . '|((?:https?:/|www\.)[^"\'\s\[\]\}\)<>]*)' .',imsS'); // Les URLs brutes sont converties en url // http://doc.spip.org/@traiter_raccourci_liens function traiter_raccourci_liens($t) { return preg_replace_callback(_EXTRAIRE_LIENS, 'traiter_autoliens', $t); } // Fonction pour les champs chapo commencant par =, redirection qui peut etre: // 1. un raccourci Spip habituel (premier If) [texte->TYPEnnn] // 2. un ultra raccourci TYPEnnn voire nnn (article) (deuxieme If) // 3. une URL std // renvoie une tableau structure comme ci-dessus mais sans calcul d'URL // (cf fusion de sauvegardes) define('_RACCOURCI_CHAPO', '/^(\W*)(\W*)(\w*\d+([?#].*)?)$/'); // http://doc.spip.org/@chapo_redirige function chapo_redirige($chapo, $url=false) { if (!preg_match(_RACCOURCI_LIEN, $chapo, $m)) if (!preg_match(_RACCOURCI_CHAPO, $chapo, $m)) return $chapo; return !$url ? $m[3] : traiter_lien_implicite($m[3]); } // Ne pas afficher le chapo si article virtuel // http://doc.spip.org/@nettoyer_chapo function nettoyer_chapo($chapo){ return (substr($chapo,0,1) == "=") ? '' : $chapo; } // http://doc.spip.org/@chapo_redirigetil function chapo_redirigetil($chapo) { return $chapo && $chapo[0] == '=';} // Cherche un lien du type [->raccourci 123] // associe a une fonction generer_url_raccourci() definie explicitement // ou implicitement par le jeu de type_urls courant. // // Valeur retournee selon le parametre $pour: // 'tout' : tableau d'index url,class,titre,lang (vise T) // 'titre': seulement T ci-dessus (i.e. le TITRE ci-dessus ou dans table SQL) // 'url': seulement U (i.e. generer_url_RACCOURCI) // http://doc.spip.org/@calculer_url function calculer_url ($ref, $texte='', $pour='url', $connect='') { $r = traiter_lien_implicite($ref, $texte, $pour, $connect); return $r ? $r : traiter_lien_explicite($ref, $texte, $pour, $connect); } define('_EXTRAIRE_LIEN', ",^\s*(http:?/?/?|mailto:?)\s*$,iS"); // http://doc.spip.org/@traiter_lien_explicite function traiter_lien_explicite ($ref, $texte='', $pour='url', $connect='') { if (preg_match(_EXTRAIRE_LIEN, $ref)) return ($pour != 'tout') ? '' : array('','','',''); $lien = entites_html(trim($ref)); // petites corrections d'URL if (preg_match('/^www\.[^@]+$/S',$lien)) $lien = "http://".$lien; else if (strpos($lien, "@") && email_valide($lien)) { if (!$texte) $texte = $lien; $lien = "mailto:".$lien; } if ($pour == 'url') return $lien; // Liens explicites if (!$texte) { $texte = str_replace('"', '', $lien); if (strlen($texte)>40) $texte = substr($texte,0,35).'...'; $texte = "".quote_amp($texte).""; } if ($pour == 'titre') return $texte; return array('url' => $lien, 'titre' => $texte); } // http://doc.spip.org/@traiter_lien_implicite function traiter_lien_implicite ($ref, $texte='', $pour='url', $connect='') { if (!($match = typer_raccourci($ref))) return false; @list($type,,$id,,$args,,$ancre) = $match; # attention dans le cas des sites le lien doit pointer non pas sur # la page locale du site, mais directement sur le site lui-meme if ($type == 'site') $url = sql_getfetsel('url_site', 'spip_syndic', "id_syndic=$id",'','','','',$connect); elseif ($type == 'glose') { if (function_exists($f = 'glossaire_' . $ancre)) $url = $f($texte, $id); else $url = glossaire_std($texte); } else $url = generer_url_entite($id,$type,$args,$ancre,$connect ? $connect : NULL); if (!$url) return false; if (is_array($url)) { @list($type,$id) = $url; $url = generer_url_entite($id,$type,$args,$ancre,$connect ? $connect : NULL); } if ($pour === 'url') return $url; $r = traiter_raccourci_titre($id, $type, $connect); if ($r) $r['class'] = 'spip_in'; if ($texte = trim($texte)) $r['titre'] = $texte; if (!@$r['titre']) $r['titre'] = _T($type) . " $id"; if ($pour=='titre') return $r['titre']; $r['url'] = $url; return $r; } // analyse des raccourcis issus de [TITRE->RACCOURCInnn] et connexes define('_RACCOURCI_URL', '/^\s*(\w*?)\s*(\d+)(\?(.*?))?(#([^\s]*))?\s*$/S'); // http://doc.spip.org/@typer_raccourci function typer_raccourci ($lien) { if (!preg_match(_RACCOURCI_URL, $lien, $match)) return array(); $f = $match[1]; // valeur par defaut et alias historiques if (!$f) $f = 'article'; else if ($f == 'art') $f = 'article'; else if ($f == 'br') $f = 'breve'; else if ($f == 'rub') $f = 'rubrique'; else if ($f == 'aut') $f = 'auteur'; else if ($f == 'doc' OR $f == 'im' OR $f == 'img' OR $f == 'image' OR $f == 'emb') $f = 'document'; else if (preg_match('/^br..?ve$/S', $f)) $f = 'breve'; # accents :( $match[0] = $f; $match[2] = entites_html($match[2]); return $match; } // Retourne le champ textuel associe a une cle primaire, et sa langue function traiter_raccourci_titre($id, $type, $connect=NULL) { $trouver_table = charger_fonction('trouver_table', 'base'); $desc = $trouver_table(table_objet($type)); if (!($desc AND $s = $desc['titre'])) return array(); $_id = $desc['key']['PRIMARY KEY']; $r = sql_fetsel($s, $desc['table'], "$_id=$id", '','','','',$connect); if (!$r) return array(); $r['titre'] = supprimer_numero($r['titre']); if (!$r['titre']) $r['titre'] = $r['surnom']; if (!isset($r['lang'])) $r['lang'] = ''; return $r; } // traite les modeles (dans la fonction typo), en remplacant // le raccourci par la page calculee a // partir du squelette modeles/modele.html // Le nom du modele doit faire au moins trois caracteres (evite

      ) // Si $doublons==true, on repere les documents sans calculer les modeles // mais on renvoie les params (pour l'indexation par le moteur de recherche) // http://doc.spip.org/@traiter_modeles define('_RACCOURCI_MODELE', '(<([a-z_-]{3,})' # ]*>|[^>])*?)?' # |arguments (y compris des tags <...>) .'\s*/?'.'>)' # fin du modele > .'\s*(<\/a>)?' # eventuel ); define('_RACCOURCI_MODELE_DEBUT', '@^' . _RACCOURCI_MODELE .'@is'); // http://doc.spip.org/@traiter_modeles function traiter_modeles($texte, $doublons=false, $echap='', $connect='') { // preserver la compatibilite : true = recherche des documents if ($doublons===true) $doublons = array('documents'=>array('doc','emb','img')); // detecter les modeles (rapide) if (preg_match_all('/<[a-z_-]{3,}\s*[0-9|]+/iS', $texte, $matches, PREG_SET_ORDER)) { include_spip('public/assembler'); foreach ($matches as $match) { // Recuperer l'appel complet (y compris un eventuel lien) $a = strpos($texte,$match[0]); preg_match(_RACCOURCI_MODELE_DEBUT, substr($texte, $a), $regs); $regs[]=""; // s'assurer qu'il y a toujours un 5e arg, eventuellement vide list(,$mod, $type, $id, $params, $fin) = $regs; if ($fin AND preg_match('/]*>\s*$/i', substr($texte, 0, $a), $r)) { $lien = array( extraire_attribut($r[0],'href'), extraire_attribut($r[0],'class') ); $n = strlen($r[0]); $a -= $n; $cherche = $n + strlen($regs[0]); } else { $lien = false; $cherche = strlen($mod); } // calculer le modele # hack articles_edit, breves_edit, indexation if ($doublons) $texte .= preg_replace(',[|][^|=]*,s',' ',$params); # version normale else { $modele = inclure_modele($type, $id, $params, $lien); // en cas d'echec, // si l'objet demande a une url, // creer un petit encadre vers elle if ($modele === false) { if (!$lien) $lien = traiter_lien_implicite("$type$id", '', 'tout', $connect); if ($lien) $modele = '' .sinon($lien['titre'], _T('ecrire:info_sans_titre')) .""; } // le remplacer dans le texte if ($modele !== false) { $modele = protege_js_modeles($modele); $rempl = code_echappement($modele, $echap); $texte = substr($texte, 0, $a) . $rempl . substr($texte, $a+$cherche); } } // hack pour tout l'espace prive if (((!_DIR_RESTREINT) OR ($doublons)) AND ($id)){ foreach($doublons?$doublons:array('documents'=>array('doc','emb','img')) as $quoi=>$modeles) if (in_array($type,$modeles)) $GLOBALS["doublons_{$quoi}_inclus"][] = $id; } } } return $texte; } // // Raccourcis ancre [#ancre<-] // define('_RACCOURCI_ANCRE', "/\[#?([^][]*)<-\]/S"); // http://doc.spip.org/@traiter_raccourci_ancre function traiter_raccourci_ancre($letexte) { if (preg_match_all(_RACCOURCI_ANCRE, $letexte, $m, PREG_SET_ORDER)) foreach ($m as $regs) $letexte = str_replace($regs[0], '', $letexte); return $letexte; } // // Raccourcis automatiques [?SPIP] vers un glossaire // Wikipedia par defaut, avec ses contraintes techniques // cf. http://fr.wikipedia.org/wiki/Wikip%C3%A9dia:Conventions_sur_les_titres define('_RACCOURCI_GLOSSAIRE', "/\[\?+\s*([^][<>]+)\]/S"); define('_RACCOURCI_GLOSES', '/^([^|#{]*\w[^|#{]*)([^#]*)(#([^|{}]*))?(.*)$/'); // http://doc.spip.org/@traiter_raccourci_glossaire function traiter_raccourci_glossaire($texte) { if (!preg_match_all(_RACCOURCI_GLOSSAIRE, $texte, $matches, PREG_SET_ORDER)) return $texte; include_spip('inc/charsets'); $lien = charger_fonction('lien', 'inc'); foreach ($matches as $regs) { // Eviter les cas particulier genre "[?!?]" // et isoler le lexeme a gloser de ses accessoires // (#:url du glossaire, | bulle d'aide, {} hreflang) // Transformation en pseudo-raccourci pour passer dans inc_lien if (preg_match(_RACCOURCI_GLOSES, $regs[1], $r)) { preg_match('/^(.*?)(\d*)$/', $r[4], $m); $_n = intval($m[2]); $gloss = $m[1] ? ('#' . $m[1]) : ''; $t = $r[1] . $r[2] . $r[5]; list($t, $bulle, $hlang) = traiter_raccourci_lien_atts($t); $t = unicode2charset(charset2unicode($t), 'utf-8'); $ref = $lien("glose$_n$gloss", $t, 'spip_glossaire', $bulle, $hlang); $texte = str_replace($regs[0], $ref, $texte); } } return $texte; } // http://doc.spip.org/@glossaire_std function glossaire_std($terme) { global $url_glossaire_externe; static $pcre = NULL; if ($pcre === NULL) { $pcre = isset($GLOBALS['meta']['pcre_u']) ? $GLOBALS['meta']['pcre_u'] : ''; if (strpos($url_glossaire_externe, "%s") === false) $url_glossaire_externe .= '%s'; } $glosateur = str_replace("@lang@", $GLOBALS['spip_lang'], $GLOBALS['url_glossaire_externe']); $terme = rawurlencode(preg_replace(',\s+,'.$pcre, '_', $terme)); return str_replace("%s", $terme, $glosateur); } ?> spip/spip/ecrire/inc/revisions.php0000766000000000000000000005630711236524730020466 0ustar adminadministrators intval($id_article), 'id_fragment' => intval($id_fragment), 'version_min' => intval($version_min), 'version_max' => intval($version_max), 'compress' => $compress, 'fragment' => $fragment); } // http://doc.spip.org/@envoi_replace_fragments function envoi_replace_fragments($replaces) { $desc = $GLOBALS['tables_auxiliaires']['spip_versions_fragments']; foreach($replaces as $r) sql_replace('spip_versions_fragments', $r, $desc); } // http://doc.spip.org/@envoi_delete_fragments function envoi_delete_fragments($id_article, $deletes) { if (count($deletes)) { sql_delete("spip_versions_fragments", "id_article=$id_article AND ((". join(") OR (", $deletes)."))"); } } // // Ajouter les fragments de la derniere version (tableau associatif id_fragment => texte) // // http://doc.spip.org/@ajouter_fragments function ajouter_fragments($id_article, $id_version, $fragments) { global $flag_gz, $agregation_versions; $replaces = array(); foreach ($fragments as $id_fragment => $texte) { $nouveau = true; // Recuperer la version la plus recente $row = sql_fetsel("compress, fragment, version_min, version_max", "spip_versions_fragments", "id_article=$id_article AND id_fragment=$id_fragment AND version_min<=$id_version", "", "version_min DESC", "1"); if ($row) { $fragment = $row['fragment']; $version_min = $row['version_min']; if ($row['compress'] > 0) $fragment = @gzuncompress($fragment); $fragment = unserialize($fragment); if (is_array($fragment)) { unset($fragment[$id_version]); // Si le fragment n'est pas trop gros, prolonger celui-ci $nouveau = count($fragment) >= $agregation_versions && strlen($row['fragment']) > 1000; } } if ($nouveau) { $fragment = array($id_version => $texte); $version_min = $id_version; } else { // Ne pas dupliquer les fragments non modifies $modif = true; for ($i = $id_version - 1; $i >= $version_min; $i--) { if (isset($fragment[$i])) { $modif = ($fragment[$i] != $texte); break; } } if ($modif) $fragment[$id_version] = $texte; } // Preparer l'enregistrement du fragment $replaces[] = replace_fragment($id_article, $version_min, $id_version, $id_fragment, $fragment); } envoi_replace_fragments($replaces); } // // Supprimer tous les fragments d'un article lies a un intervalle de versions // (essaie d'eviter une trop grande fragmentation) // // http://doc.spip.org/@supprimer_fragments function supprimer_fragments($id_article, $version_debut, $version_fin) { global $flag_gz, $agregation_versions; $replaces = array(); $deletes = array(); // D'abord, vider les fragments inutiles sql_delete("spip_versions_fragments", "id_article=$id_article AND version_min>=$version_debut AND version_max<=$version_fin"); // Fragments chevauchant l'ensemble de l'intervalle, s'ils existent $result = sql_select("id_fragment, compress, fragment, version_min, version_max", "spip_versions_fragments", "id_article=$id_article AND version_min<$version_debut AND version_max>$version_fin"); while ($row = sql_fetch($result)) { $id_fragment = $row['id_fragment']; $fragment = $row['fragment']; if ($row['compress'] > 0) $fragment = gzuncompress($fragment); $fragment = unserialize($fragment); for ($i = $version_fin; $i >= $version_debut; $i--) { if (isset($fragment[$i])) { // Recopier le dernier fragment si implicite if (!isset($fragment[$version_fin + 1])) $fragment[$version_fin + 1] = $fragment[$i]; unset($fragment[$i]); } } $replaces[] = replace_fragment($id_article, $row['version_min'], $row['version_max'], $id_fragment, $fragment); } // Fragments chevauchant le debut de l'intervalle, s'ils existent $result = sql_select("id_fragment, compress, fragment, version_min, version_max", "spip_versions_fragments", "id_article=$id_article AND version_min<$version_debut AND version_max>=$version_debut AND version_max<=$version_fin"); $deb_fragment = array(); while ($row = sql_fetch($result)) { $id_fragment = $row['id_fragment']; $fragment = $row['fragment']; $version_min = $row['version_min']; $version_max = $row['version_max']; if ($row['compress'] > 0) $fragment = gzuncompress($fragment); $fragment = unserialize($fragment); for ($i = $version_debut; $i <= $version_max; $i++) { if (isset($fragment[$i])) unset($fragment[$i]); } // Stocker temporairement le fragment pour agregation $deb_fragment[$id_fragment] = $fragment; // Ajuster l'intervalle des versions $deb_version_min[$id_fragment] = $version_min; $deb_version_max[$id_fragment] = $version_debut - 1; } // Fragments chevauchant la fin de l'intervalle, s'ils existent $result = sql_select("id_fragment, compress, fragment, version_min, version_max", "spip_versions_fragments", "id_article=$id_article AND version_max>$version_fin AND version_min>=$version_debut AND version_min<=$version_fin"); while ($row = sql_fetch($result)) { $id_fragment = $row['id_fragment']; $fragment = $row['fragment']; $version_min = $row['version_min']; $version_max = $row['version_max']; if ($row['compress'] > 0) $fragment = gzuncompress($fragment); $fragment = unserialize($fragment); for ($i = $version_fin; $i >= $version_min; $i--) { if (isset($fragment[$i])) { // Recopier le dernier fragment si implicite if (!isset($fragment[$version_fin + 1])) $fragment[$version_fin + 1] = $fragment[$i]; unset($fragment[$i]); } } // Virer l'ancien enregistrement (la cle primaire va changer) $deletes[] = "id_fragment=$id_fragment AND version_min=$version_min"; // Essayer l'agregation $agreger = false; if (isset($deb_fragment[$id_fragment])) { $agreger = (count($deb_fragment[$id_fragment]) + count($fragment) <= $agregation_versions); if ($agreger) { $fragment = $deb_fragment[$id_fragment] + $fragment; $version_min = $deb_version_min[$id_fragment]; } else { $replaces[] = replace_fragment($id_article, $deb_version_min[$id_fragment], $deb_version_max[$id_fragment], $id_fragment, $deb_fragment[$id_fragment]); } unset($deb_fragment[$id_fragment]); } if (!$agreger) { // Ajuster l'intervalle des versions $version_min = $version_fin + 1; } $replaces[] = replace_fragment($id_article, $version_min, $version_max, $id_fragment, $fragment); } // Ajouter fragments restants if (is_array($deb_fragment) && count($deb_fragment) > 0) { foreach ($deb_fragment as $id_fragment => $fragment) { $replaces[] = replace_fragment($id_article, $deb_version_min[$id_fragment], $deb_version_max[$id_fragment], $id_fragment, $deb_fragment[$id_fragment]); } } envoi_replace_fragments($replaces); envoi_delete_fragments($id_article, $deletes); } // // Recuperer les fragments d'une version donnee // renvoie un tableau associatif (id_fragment => texte) // // http://doc.spip.org/@recuperer_fragments function recuperer_fragments($id_article, $id_version) { $fragments = array(); if ($id_version == 0) return array(); $result = sql_select("id_fragment, version_min, version_max, compress, fragment", "spip_versions_fragments", "id_article=$id_article AND version_min<=$id_version AND version_max>=$id_version"); while ($row = sql_fetch($result)) { $id_fragment = $row['id_fragment']; $version_min = $row['version_min']; $fragment = $row['fragment']; if ($row['compress'] > 0){ $fragment_ = @gzuncompress($fragment); if (strlen($fragment) && $fragment_===false) $fragment=serialize(array($row['version_max']=>"["._T('forum_titre_erreur').$id_fragment."]")); else $fragment = $fragment_; } $fragment_ = unserialize($fragment); if (strlen($fragment) && $fragment_===false) $fragment=array($row['version_max']=>"["._T('forum_titre_erreur').$id_fragment."]"); else $fragment = $fragment_; for ($i = $id_version; $i >= $version_min; $i--) { if (isset($fragment[$i])) { ## hack destine a sauver les archives des sites iso-8859-1 ## convertis en utf-8 (les archives ne sont pas converties ## mais ce code va les nettoyer ; pour les autres charsets ## la situation n'est pas meilleure ni pire qu'avant) if ($GLOBALS['meta']['charset'] == 'utf-8' AND include_spip('inc/charsets') AND !is_utf8($fragment[$i])) { $fragment[$i] = importer_charset($fragment[$i], 'iso-8859-1'); } $fragments[$id_fragment] = $fragment[$i]; break; } } } return $fragments; } // // Apparier des paragraphes deux a deux entre une version originale // et une version modifiee // // http://doc.spip.org/@apparier_paras function apparier_paras($src, $dest, $flou = true) { $src_dest = array(); $dest_src = array(); $t1 = $t2 = array(); $md1 = $md2 = array(); $gz_min1 = $gz_min2 = array(); $gz_trans1 = $gz_trans2 = array(); $l1 = $l2 = array(); // Nettoyage de la ponctuation pour faciliter l'appariement foreach($src as $key => $val) { $t1[$key] = strval(preg_replace("/[[:punct:][:space:]]+/", " ", $val)); } foreach($dest as $key => $val) { $t2[$key] = strval(preg_replace("/[[:punct:][:space:]]+/", " ", $val)); } // Premiere passe : chercher les correspondance exactes foreach($t1 as $key => $val) $md1[$key] = md5($val); foreach($t2 as $key => $val) $md2[md5($val)][$key] = $key; foreach($md1 as $key1 => $h) { if (isset($md2[$h])) { $key2 = reset($md2[$h]); if ($t1[$key1] == $t2[$key2]) { $src_dest[$key1] = $key2; $dest_src[$key2] = $key1; unset($t1[$key1]); unset($t2[$key2]); unset($md2[$h][$key2]); } } } if ($flou) { // Deuxieme passe : recherche de correlation par test de compressibilite foreach($t1 as $key => $val) { $l1[$key] = strlen(gzcompress($val)); } foreach($t2 as $key => $val) { $l2[$key] = strlen(gzcompress($val)); } foreach($t1 as $key1 => $s1) { foreach($t2 as $key2 => $s2) { $r = strlen(gzcompress($s1.$s2)); $taux = 1.0 * $r / ($l1[$key1] + $l2[$key2]); if (!$gz_min1[$key1] || $gz_min1[$key1] > $taux) { $gz_min1[$key1] = $taux; $gz_trans1[$key1] = $key2; } if (!$gz_min2[$key2] || $gz_min2[$key2] > $taux) { $gz_min2[$key2] = $taux; $gz_trans2[$key2] = $key1; } } } // Depouiller les resultats de la deuxieme passe : // ne retenir que les correlations reciproques foreach($gz_trans1 as $key1 => $key2) { if ($gz_trans2[$key2] == $key1 && $gz_min1[$key1] < 0.9) { $src_dest[$key1] = $key2; $dest_src[$key2] = $key1; } } } // Retourner les mappings return array($src_dest, $dest_src); } // // Recuperer les champs d'une version donnee // // http://doc.spip.org/@recuperer_version function recuperer_version($id_article, $id_version) { $champs = sql_getfetsel("champs", "spip_versions", "id_article=" . intval($id_article) . " AND id_version=" . intval($id_version)); if (!$champs OR !is_array($champs = unserialize($champs))) return array(); else return reconstuire_version($champs, recuperer_fragments($id_article, $id_version)); } // http://doc.spip.org/@reconstuire_version function reconstuire_version($champs, $fragments, $res=array()) { static $msg; if (!$msg) $msg = _T('forum_titre_erreur'); foreach ($champs as $nom => $code) { if (!isset($res[$nom])) { $t = ''; foreach (array_filter(explode(' ', $code)) as $id) { $t .= isset($fragments[$id]) ? $fragments[$id] : "[$msg$id]"; } $res[$nom] = $t; } } return $res; } // http://doc.spip.org/@supprimer_versions function supprimer_versions($id_article, $version_min, $version_max) { sql_delete("spip_versions", "id_article=$id_article AND id_version>=$version_min AND id_version<=$version_max"); supprimer_fragments($id_article, $version_min, $version_max); } // // Ajouter une version a un article // // http://doc.spip.org/@ajouter_version function ajouter_version($id_article, $champs, $titre_version = "", $id_auteur) { $paras = $paras_old = $paras_champ = $fragments = array(); // Attention a une edition anonyme (type wiki): id_auteur n'est pas // definie, on enregistre alors le numero IP $str_auteur = intval($id_auteur) ? intval($id_auteur) : $GLOBALS['ip']; $permanent = empty($titre_version) ? 'non' : 'oui'; // Detruire les tentatives d'archivages non abouties en 1 heure sql_delete('spip_versions', "id_article=$id_article AND id_version <= 0 AND date < DATE_SUB(".sql_quote(date('Y-m-d H:i:s')).", INTERVAL "._INTERVALLE_REVISIONS." SECOND)"); // Signaler qu'on opere en mettant un numero de version negatif // distinctif (pour eviter la violation d'unicite) // et un titre contenant en fait le moment de l'insertion list($ms, $sec) = explode(' ', microtime()); $date = $sec . substr($ms,1); $datediff = ($sec - mktime(0,0,0,9,1,2007)) * 1000000 + substr($ms,2, strlen($ms)-4); $valeurs = array('id_article' => $id_article, 'id_version' => (0 - $datediff), 'date' => date('Y-m-d H:i:s'), 'id_auteur' => $str_auteur, // varchar ici! 'titre_version' => $date); sql_insertq('spip_versions', $valeurs); // Eviter les validations entremelees en s'endormant s'il existe // une version <0 plus recente mais pas plus vieille que 10s // Une <0 encore plus vieille est une operation avortee, // on passe outre (vaut mieux archiver mal que pas du tout). // Pour tester: // 0. mettre le delai a 30 // 1. decommenter le premier sleep(15) // 2. enregistrer une modif // 3. recommenter le premier sleep(15), decommenter le second. // 4. enregistrer une autre modif dans les 15 secondes # sleep(15); $delai = $sec-10; while (sql_countsel('spip_versions', "id_article=$id_article AND id_version < 0 AND 0.0+titre_version < $date AND 0.0+titre_version > $delai")) { spip_log("version $id_article :insertion en cours avant $date ($delai)"); sleep(1); $delai++; } # sleep(15); spip_log("sortie $sec $delai"); // Determiner le numero du prochain fragment $next = sql_fetsel("id_fragment", "spip_versions_fragments", "id_article=$id_article", "", "id_fragment DESC", "1"); $onlylock = ''; // Examiner la derniere version $row = sql_fetsel("id_version, champs, id_auteur, date, permanent", "spip_versions", "id_article=$id_article AND id_version > 0", '', "id_version DESC", "1"); // le champ id_auteur est un varchar dans cette table if ($row) { $id_version = $row['id_version']; $paras_old = recuperer_fragments($id_article, $id_version); $champs_old = $row['champs']; if ($row['id_auteur']!= $str_auteur OR $row['permanent']=='oui' OR strtotime($row['date']) < (time()-_INTERVALLE_REVISIONS)) { $id_version++; // version precedente recente, on va la mettre a jour // avec les nouveaux arrivants si presents } else { $champs = reconstuire_version(unserialize($champs_old), $paras_old, $champs); $onlylock = 're'; } } else $id_version = 1; $next = !$next ? 1 : ($next['id_fragment'] + 1); // Generer les nouveaux fragments $codes = array(); foreach ($champs as $nom => $texte) { $codes[$nom] = array(); $paras = separer_paras($texte, $paras); $paras_champ[$nom] = count($paras); } // Apparier les fragments de maniere optimale $n = count($paras); if ($n) { // Tables d'appariement dans les deux sens list(,$trans) = apparier_paras($paras_old, $paras); reset($champs); $nom = ''; for ($i = 0; $i < $n; $i++) { while ($i >= $paras_champ[$nom]) list($nom, ) = each($champs); // Lier au fragment existant si possible, sinon creer un nouveau fragment $id_fragment = isset($trans[$i]) ? $trans[$i] : $next++; $codes[$nom][] = $id_fragment; $fragments[$id_fragment] = $paras[$i]; } } foreach ($champs as $nom => $t) { $codes[$nom] = join(' ', $codes[$nom]); # avec la ligne qui suit, un champ qu'on vide ne s'enregistre pas # if (!strlen($codes[$nom])) unset($codes[$nom]); } // Enregistrer les modifications ajouter_fragments($id_article, $id_version, $fragments); sql_updateq("spip_articles", array("id_version" => $id_version), "id_article=$id_article"); // Si l'insertion ne servait que de verrou, // la detruire apres mise a jour de l'ancienne entree, // sinon la mise a jour efface en fait le verrou. if (!$onlylock) { sql_updateq('spip_versions', array('id_version'=>$id_version, 'date'=>date('Y-m-d H:i:s'), 'champs'=> serialize($codes), 'permanent'=>$permanent, 'titre_version'=> $titre_version), "id_article=$id_article AND id_version < 0 AND titre_version='$date'"); } else { sql_updateq('spip_versions', array('date'=>date('Y-m-d H:i:s'), 'champs'=>serialize($codes), 'permanent'=>$permanent, 'titre_version'=> $titre_version), "id_article=$id_article AND id_version=$id_version"); sql_delete("spip_versions", "id_article=$id_article AND id_version < 0 AND titre_version ='$date'"); } spip_log($onlylock . "memorise la version $id_version de l'article $id_article $titre_version"); return $id_version; } // les textes "diff" ne peuvent pas passer dans propre directement, // car ils contiennent des et
      parfois mal places // http://doc.spip.org/@propre_diff function propre_diff($texte) { $span_diff = array(); if (preg_match_all(',<(/)?(span|div) (class|rem)="diff-[^>]*>,', $texte, $regs, PREG_SET_ORDER)) { foreach ($regs as $c => $reg) { $texte = str_replace($reg[0], '@@@SPIP_DIFF'.$c.'@@@', $texte); } } // [ ... -> lien ] // < tag > $texte = preg_replace(',<([^>]*?@@@SPIP_DIFF[0-9]+@@@),', '<\1', $texte); # attention ici astuce seulement deux @@ finals car on doit eviter # deux patterns a suivre, afin de pouvoir prendre [ mais eviter [[ $texte = preg_replace(',(^|[^[])[[]([^[\]]*@@@SPIP_DIFF[0-9]+@@),', '\1[\2', $texte); // desactiver TeX & toujours-paragrapher $tex = $GLOBALS['traiter_math']; $GLOBALS['traiter_math'] = ''; $mem = $GLOBALS['toujours_paragrapher']; $GLOBALS['toujours_paragrapher'] = false; $texte = propre($texte); // retablir $GLOBALS['traiter_math'] = $tex; $GLOBALS['toujours_paragrapher'] = $mem; // un blockquote mal ferme peut gener l'affichage, et title plante safari $texte = preg_replace(',<(/?(blockquote|title)[^>]*)>,i', '<\1>', $texte); // Dans les c'est un peu plus complique if (preg_match_all(',