]> git.nbdom.net Git - nb.git/commitdiff
mime.php
authorNicolas Boisselier <nicolas.boisselier@gmail.com>
Tue, 20 Dec 2016 00:43:56 +0000 (00:43 +0000)
committerNicolas Boisselier <nicolas.boisselier@gmail.com>
Tue, 20 Dec 2016 00:43:56 +0000 (00:43 +0000)
lib/php/http.php
lib/php/mime.php [new file with mode: 0644]
lib/php/nb.php
lib/php/page.php
www/dbq/dbq.php

index 832549a6d2ef5e7aee1467d359447ac3377d08c4..9b1ff0e6253a611a81b8ac57a251bb1a0a1a54df 100644 (file)
@@ -1,8 +1,7 @@
 <?php
 class Http {
   const Status = [
-#>SHELL_REPLACE dbq t="SELECT id,name FROM http_status" format=csv sep=" => " quote="'" eol=",\n"
-'id' => 'name',
+#>SHELL_REPLACE dbq t="SELECT id,name FROM http_status" header=0 format=csv sep=" => " quote="'" eol=",\n"
 '100' => 'Continue',
 '101' => 'Switching Protocols',
 '102' => 'Processing',
diff --git a/lib/php/mime.php b/lib/php/mime.php
new file mode 100644 (file)
index 0000000..e13183b
--- /dev/null
@@ -0,0 +1,707 @@
+<?php
+class Mime {
+  const Types = [
+#>SHELL_REPLACE dbq t="SELECT type,ext FROM mime_type ORDER BY ext,length(type)" header=0 format=csv sep=" => " quote="'" eol=",\n"
+'application/vnd.lotus-1-2-3' => '123',
+'text/vnd.in3d.3dml' => '3dml',
+'video/3gpp2' => '3g2',
+'video/3gpp' => '3gp',
+'application/x-7z-compressed' => '7z',
+'application/x-authorware-bin' => 'aab',
+'audio/x-aac' => 'aac',
+'application/x-authorware-map' => 'aam',
+'application/x-authorware-seg' => 'aas',
+'application/x-abiword' => 'abw',
+'application/pkix-attr-cert' => 'ac',
+'application/vnd.americandynamics.acc' => 'acc',
+'application/x-ace-compressed' => 'ace',
+'application/vnd.acucobol' => 'acu',
+'audio/adpcm' => 'adp',
+'application/vnd.audiograph' => 'aep',
+'application/vnd.ibm.modcap' => 'afp',
+'application/vnd.ahead.space' => 'ahead',
+'application/postscript' => 'ai',
+'audio/x-aiff' => 'aif',
+'application/vnd.adobe.air-application-installer-package+zip' => 'air',
+'application/vnd.dvb.ait' => 'ait',
+'application/vnd.amiga.ami' => 'ami',
+'application/vnd.android.package-archive' => 'apk',
+'application/x-ms-application' => 'application',
+'application/vnd.lotus-approach' => 'apr',
+'video/x-ms-asf' => 'asf',
+'application/vnd.accpac.simply.aso' => 'aso',
+'application/vnd.acucorp' => 'atc',
+'application/atom+xml' => 'atom xml',
+'application/atomcat+xml' => 'atomcat',
+'application/atomsvc+xml' => 'atomsvc',
+'application/vnd.antix.game-component' => 'atx',
+'audio/basic' => 'au',
+'video/x-msvideo' => 'avi',
+'application/applixware' => 'aw',
+'application/vnd.airzip.filesecure.azf' => 'azf',
+'application/vnd.airzip.filesecure.azs' => 'azs',
+'application/vnd.amazon.ebook' => 'azw',
+'application/x-bcpio' => 'bcpio',
+'application/x-font-bdf' => 'bdf',
+'application/vnd.syncml.dm+wbxml' => 'bdm',
+'application/vnd.realvnc.bed' => 'bed',
+'application/vnd.fujitsu.oasysprs' => 'bh2',
+'application/octet-stream' => 'bin',
+'application/vnd.bmi' => 'bmi',
+'image/bmp' => 'bmp',
+'application/vnd.previewsystems.box' => 'box',
+'image/prs.btif' => 'btif',
+'application/x-bzip' => 'bz',
+'application/x-bzip2' => 'bz2',
+'text/x-c' => 'c',
+'application/vnd.cluetrust.cartomobile-config' => 'c11amc',
+'application/vnd.cluetrust.cartomobile-config-pkg' => 'c11amz',
+'application/vnd.clonk.c4group' => 'c4g',
+'application/vnd.ms-cab-compressed' => 'cab',
+'application/vnd.curl.car' => 'car',
+'application/vnd.ms-pki.seccat' => 'cat',
+'application/ccxml+xml,' => 'ccxml',
+'application/vnd.contact.cmsg' => 'cdbcmsg',
+'application/vnd.mediastation.cdkey' => 'cdkey',
+'application/cdmi-capability' => 'cdmia',
+'application/cdmi-container' => 'cdmic',
+'application/cdmi-domain' => 'cdmid',
+'application/cdmi-object' => 'cdmio',
+'application/cdmi-queue' => 'cdmiq',
+'chemical/x-cdx' => 'cdx',
+'application/vnd.chemdraw+xml' => 'cdxml',
+'application/vnd.cinderella' => 'cdy',
+'application/pkix-cert' => 'cer',
+'image/cgm' => 'cgm',
+'application/x-chat' => 'chat',
+'application/vnd.ms-htmlhelp' => 'chm',
+'application/vnd.kde.kchart' => 'chrt',
+'chemical/x-cif' => 'cif',
+'application/vnd.anser-web-certificate-issue-initiation' => 'cii',
+'application/vnd.ms-artgalry' => 'cil',
+'application/vnd.claymore' => 'cla',
+'application/java-vm' => 'class',
+'application/vnd.crick.clicker.keyboard' => 'clkk',
+'application/vnd.crick.clicker.palette' => 'clkp',
+'application/vnd.crick.clicker.template' => 'clkt',
+'application/vnd.crick.clicker.wordbank' => 'clkw',
+'application/vnd.crick.clicker' => 'clkx',
+'application/x-msclip' => 'clp',
+'application/vnd.cosmocaller' => 'cmc',
+'chemical/x-cmdf' => 'cmdf',
+'chemical/x-cml' => 'cml',
+'application/vnd.yellowriver-custom-menu' => 'cmp',
+'image/x-cmx' => 'cmx',
+'application/vnd.rim.cod' => 'cod',
+'application/x-cpio' => 'cpio',
+'application/mac-compactpro' => 'cpt',
+'application/x-mscardfile' => 'crd',
+'application/pkix-crl' => 'crl',
+'application/vnd.rig.cryptonote' => 'cryptonote',
+'application/x-csh' => 'csh',
+'chemical/x-csml' => 'csml',
+'application/vnd.commonspace' => 'csp',
+'text/css' => 'css',
+'text/csv' => 'csv',
+'application/cu-seeme' => 'cu',
+'text/vnd.curl' => 'curl',
+'application/prs.cww' => 'cww',
+'model/vnd.collada+xml' => 'dae',
+'application/vnd.mobius.daf' => 'daf',
+'application/davmount+xml' => 'davmount',
+'text/vnd.curl.dcurl' => 'dcurl',
+'application/vnd.oma.dd2+xml' => 'dd2',
+'application/vnd.fujixerox.ddd' => 'ddd',
+'application/x-debian-package' => 'deb',
+'application/x-x509-ca-cert' => 'der',
+'application/vnd.dreamfactory' => 'dfac',
+'application/x-director' => 'dir',
+'application/vnd.mobius.dis' => 'dis',
+'image/vnd.djvu' => 'djvu',
+'application/vnd.dna' => 'dna',
+'application/msword' => 'doc',
+'application/vnd.ms-word.document.macroenabled.12' => 'docm',
+'application/vnd.openxmlformats-officedocument.wordprocessingml.document' => 'docx',
+'application/vnd.ms-word.template.macroenabled.12' => 'dotm',
+'application/vnd.openxmlformats-officedocument.wordprocessingml.template' => 'dotx',
+'application/vnd.osgi.dp' => 'dp',
+'application/vnd.dpgraph' => 'dpg',
+'audio/vnd.dra' => 'dra',
+'text/prs.lines.tag' => 'dsc',
+'application/dssc+der' => 'dssc',
+'application/x-dtbook+xml' => 'dtb',
+'application/xml-dtd' => 'dtd',
+'audio/vnd.dts' => 'dts',
+'audio/vnd.dts.hd' => 'dtshd',
+'application/x-dvi' => 'dvi',
+'model/vnd.dwf' => 'dwf',
+'image/vnd.dwg' => 'dwg',
+'image/vnd.dxf' => 'dxf',
+'application/vnd.spotfire.dxp' => 'dxp',
+'audio/vnd.nuera.ecelp4800' => 'ecelp4800',
+'audio/vnd.nuera.ecelp7470' => 'ecelp7470',
+'audio/vnd.nuera.ecelp9600' => 'ecelp9600',
+'application/vnd.novadigm.edm' => 'edm',
+'application/vnd.novadigm.edx' => 'edx',
+'application/vnd.picsel' => 'efif',
+'application/vnd.pg.osasli' => 'ei6',
+'message/rfc822' => 'eml',
+'application/emma+xml' => 'emma',
+'audio/vnd.digital-winds' => 'eol',
+'application/vnd.ms-fontobject' => 'eot',
+'application/epub+zip' => 'epub',
+'application/ecmascript' => 'es',
+'application/vnd.eszigno3+xml' => 'es3',
+'application/vnd.epson.esf' => 'esf',
+'text/x-setext' => 'etx',
+'application/x-msdownload' => 'exe',
+'application/exi' => 'exi',
+'application/vnd.novadigm.ext' => 'ext',
+'application/vnd.ezpix-album' => 'ez2',
+'application/vnd.ezpix-package' => 'ez3',
+'text/x-fortran' => 'f',
+'video/x-f4v' => 'f4v',
+'image/vnd.fastbidsheet' => 'fbs',
+'application/vnd.isac.fcs' => 'fcs',
+'application/vnd.fdf' => 'fdf',
+'application/vnd.denovo.fcselayout-link' => 'fe_launch',
+'application/vnd.fujitsu.oasysgp' => 'fg5',
+'image/x-freehand' => 'fh',
+'application/x-xfig' => 'fig',
+'video/x-fli' => 'fli',
+'application/vnd.micrografx.flo' => 'flo',
+'video/x-flv' => 'flv',
+'application/vnd.kde.kivio' => 'flw',
+'text/vnd.fmi.flexstor' => 'flx',
+'text/vnd.fly' => 'fly',
+'application/vnd.framemaker' => 'fm',
+'application/vnd.frogans.fnc' => 'fnc',
+'image/vnd.fpx' => 'fpx',
+'application/vnd.fsc.weblaunch' => 'fsc',
+'image/vnd.fst' => 'fst',
+'application/vnd.fluxtime.clip' => 'ftc',
+'application/vnd.anser-web-funds-transfer-initiation' => 'fti',
+'video/vnd.fvt' => 'fvt',
+'application/vnd.adobe.fxp' => 'fxp',
+'application/vnd.fuzzysheet' => 'fzs',
+'application/vnd.geoplan' => 'g2w',
+'image/g3fax' => 'g3',
+'application/vnd.geospace' => 'g3w',
+'application/vnd.groove-account' => 'gac',
+'model/vnd.gdl' => 'gdl',
+'application/vnd.dynageo' => 'geo',
+'application/vnd.geometry-explorer' => 'gex',
+'application/vnd.geogebra.file' => 'ggb',
+'application/vnd.geogebra.tool' => 'ggt',
+'application/vnd.groove-help' => 'ghf',
+'image/gif' => 'gif',
+'application/vnd.groove-identity-message' => 'gim',
+'application/vnd.gmx' => 'gmx',
+'application/x-gnumeric' => 'gnumeric',
+'application/vnd.flographit' => 'gph',
+'application/vnd.grafeq' => 'gqf',
+'application/srgs' => 'gram',
+'application/vnd.groove-injector' => 'grv',
+'application/srgs+xml' => 'grxml',
+'application/x-font-ghostscript' => 'gsf',
+'application/x-gtar' => 'gtar',
+'application/vnd.groove-tool-message' => 'gtm',
+'model/vnd.gtw' => 'gtw',
+'text/vnd.graphviz' => 'gv',
+'application/vnd.geonext' => 'gxt',
+'video/h261' => 'h261',
+'video/h263' => 'h263',
+'video/h264' => 'h264',
+'application/vnd.hal+xml' => 'hal',
+'application/vnd.hbci' => 'hbci',
+'application/x-hdf' => 'hdf',
+'application/winhlp' => 'hlp',
+'application/vnd.hp-hpgl' => 'hpgl',
+'application/vnd.hp-hpid' => 'hpid',
+'application/vnd.hp-hps' => 'hps',
+'application/mac-binhex40' => 'hqx',
+'application/vnd.kenameaapp' => 'htke',
+'text/html' => 'html',
+'application/vnd.yamaha.hv-dic' => 'hvd',
+'application/vnd.yamaha.hv-voice' => 'hvp',
+'application/vnd.yamaha.hv-script' => 'hvs',
+'application/vnd.intergeo' => 'i2g',
+'application/vnd.iccprofile' => 'icc',
+'x-conference/x-cooltalk' => 'ice',
+'image/x-icon' => 'ico',
+'text/calendar' => 'ics',
+'image/ief' => 'ief',
+'application/vnd.shana.informed.formdata' => 'ifm',
+'application/vnd.igloader' => 'igl',
+'application/vnd.insors.igm' => 'igm',
+'model/iges' => 'igs',
+'application/vnd.micrografx.igx' => 'igx',
+'application/vnd.shana.informed.interchange' => 'iif',
+'application/vnd.accpac.simply.imp' => 'imp',
+'application/vnd.ms-ims' => 'ims',
+'application/ipfix' => 'ipfix',
+'application/vnd.shana.informed.package' => 'ipk',
+'application/vnd.ibm.rights-management' => 'irm',
+'application/vnd.irepository.package+xml' => 'irp',
+'application/vnd.shana.informed.formtemplate' => 'itp',
+'application/vnd.immervision-ivp' => 'ivp',
+'application/vnd.immervision-ivu' => 'ivu',
+'text/vnd.sun.j2me.app-descriptor' => 'jad',
+'application/vnd.jam' => 'jam',
+'application/java-archive' => 'jar',
+'text/x-java-source,java' => 'java',
+'application/vnd.jisp' => 'jisp',
+'application/vnd.hp-jlyt' => 'jlt',
+'application/x-java-jnlp-file' => 'jnlp',
+'application/vnd.joost.joda-archive' => 'joda',
+'image/jpeg' => 'jpeg jpg',
+'video/jpeg' => 'jpgv',
+'video/jpm' => 'jpm',
+'application/javascript' => 'js',
+'text/json' => 'json',
+'application/json' => 'json',
+'application/vnd.kde.karbon' => 'karbon',
+'application/vnd.kde.kformula' => 'kfo',
+'application/vnd.kidspiration' => 'kia',
+'application/vnd.google-earth.kml+xml' => 'kml',
+'application/vnd.google-earth.kmz' => 'kmz',
+'application/vnd.kinar' => 'kne',
+'application/vnd.kde.kontour' => 'kon',
+'application/vnd.kde.kpresenter' => 'kpr',
+'application/vnd.kde.kspread' => 'ksp',
+'image/ktx' => 'ktx',
+'application/vnd.kahootz' => 'ktz',
+'application/vnd.kde.kword' => 'kwd',
+'application/vnd.las.las+xml' => 'lasxml',
+'application/x-latex' => 'latex',
+'application/vnd.llamagraphics.life-balance.desktop' => 'lbd',
+'application/vnd.llamagraphics.life-balance.exchange+xml' => 'lbe',
+'application/vnd.hhe.lesson-player' => 'les',
+'application/vnd.route66.link66+xml' => 'link66',
+'application/vnd.ms-lrm' => 'lrm',
+'application/vnd.frogans.ltf' => 'ltf',
+'audio/vnd.lucent.voice' => 'lvp',
+'application/vnd.lotus-wordpro' => 'lwp',
+'application/mp21' => 'm21',
+'audio/x-mpegurl' => 'm3u',
+'application/vnd.apple.mpegurl' => 'm3u8',
+'video/x-m4v' => 'm4v',
+'application/mathematica' => 'ma',
+'application/mads+xml' => 'mads',
+'application/vnd.ecowin.chart' => 'mag',
+'application/mathml+xml' => 'mathml',
+'application/vnd.mobius.mbk' => 'mbk',
+'application/mbox' => 'mbox',
+'application/vnd.medcalcdata' => 'mc1',
+'application/vnd.mcd' => 'mcd',
+'text/vnd.curl.mcurl' => 'mcurl',
+'text/x-markdown' => 'md',
+'application/x-msaccess' => 'mdb',
+'image/vnd.ms-modi' => 'mdi',
+'application/metalink4+xml' => 'meta4',
+'application/mets+xml' => 'mets',
+'application/vnd.mfmp' => 'mfm',
+'application/vnd.osgeo.mapguide.package' => 'mgp',
+'application/vnd.proteus.magazine' => 'mgz',
+'audio/midi' => 'mid',
+'application/vnd.mif' => 'mif',
+'video/mj2' => 'mj2',
+'application/vnd.dolby.mlp' => 'mlp',
+'application/vnd.chipnuts.karaoke-mmd' => 'mmd',
+'application/vnd.smaf' => 'mmf',
+'image/vnd.fujixerox.edmics-mmr' => 'mmr',
+'application/x-msmoney' => 'mny',
+'application/mods+xml' => 'mods',
+'video/x-sgi-movie' => 'movie',
+'video/mp4' => 'mp4',
+'application/mp4' => 'mp4',
+'audio/mp4' => 'mp4a',
+'application/vnd.mophun.certificate' => 'mpc',
+'video/mpeg' => 'mpeg',
+'audio/mpeg' => 'mpga',
+'application/vnd.apple.installer+xml' => 'mpkg',
+'application/vnd.blueice.multipass' => 'mpm',
+'application/vnd.mophun.application' => 'mpn',
+'application/vnd.ms-project' => 'mpp',
+'application/vnd.ibm.minipay' => 'mpy',
+'application/vnd.mobius.mqy' => 'mqy',
+'application/marc' => 'mrc',
+'application/marcxml+xml' => 'mrcx',
+'application/mediaservercontrol+xml' => 'mscml',
+'application/vnd.mseq' => 'mseq',
+'application/vnd.epson.msf' => 'msf',
+'model/mesh' => 'msh',
+'application/vnd.mobius.msl' => 'msl',
+'application/vnd.muvee.style' => 'msty',
+'model/vnd.mts' => 'mts',
+'application/vnd.musician' => 'mus',
+'application/vnd.recordare.musicxml+xml' => 'musicxml',
+'application/x-msmediaview' => 'mvb',
+'application/vnd.mfer' => 'mwf',
+'application/mxf' => 'mxf',
+'application/vnd.recordare.musicxml' => 'mxl',
+'application/xv+xml' => 'mxml',
+'application/vnd.triscape.mxs' => 'mxs',
+'video/vnd.mpegurl' => 'mxu',
+'application/vnd.nokia.n-gage.symbian.install' => 'n-gage',
+'text/n3' => 'n3',
+'application/vnd.wolfram.player' => 'nbp',
+'application/x-netcdf' => 'nc',
+'application/x-dtbncx+xml' => 'ncx',
+'application/vnd.nokia.n-gage.data' => 'ngdat',
+'application/vnd.neurolanguage.nlu' => 'nlu',
+'application/vnd.enliven' => 'nml',
+'application/vnd.noblenet-directory' => 'nnd',
+'application/vnd.noblenet-sealer' => 'nns',
+'application/vnd.noblenet-web' => 'nnw',
+'image/vnd.net-fpx' => 'npx',
+'application/vnd.lotus-notes' => 'nsf',
+'application/vnd.fujitsu.oasys2' => 'oa2',
+'application/vnd.fujitsu.oasys3' => 'oa3',
+'application/vnd.fujitsu.oasys' => 'oas',
+'application/x-msbinder' => 'obd',
+'application/oda' => 'oda',
+'application/vnd.oasis.opendocument.database' => 'odb',
+'application/vnd.oasis.opendocument.chart' => 'odc',
+'application/vnd.oasis.opendocument.formula' => 'odf',
+'application/vnd.oasis.opendocument.formula-template' => 'odft',
+'application/vnd.oasis.opendocument.graphics' => 'odg',
+'application/vnd.oasis.opendocument.image' => 'odi',
+'application/vnd.oasis.opendocument.text-master' => 'odm',
+'application/vnd.oasis.opendocument.presentation' => 'odp',
+'application/vnd.oasis.opendocument.spreadsheet' => 'ods',
+'application/vnd.oasis.opendocument.text' => 'odt',
+'audio/ogg' => 'oga',
+'video/ogg' => 'ogv',
+'application/ogg' => 'ogx',
+'application/onenote' => 'onetoc',
+'application/oebps-package+xml' => 'opf',
+'application/vnd.lotus-organizer' => 'org',
+'application/vnd.yamaha.openscoreformat' => 'osf',
+'application/vnd.yamaha.openscoreformat.osfpvg+xml' => 'osfpvg',
+'application/vnd.oasis.opendocument.chart-template' => 'otc',
+'application/x-font-otf' => 'otf',
+'application/vnd.oasis.opendocument.graphics-template' => 'otg',
+'application/vnd.oasis.opendocument.text-web' => 'oth',
+'application/vnd.oasis.opendocument.image-template' => 'oti',
+'application/vnd.oasis.opendocument.presentation-template' => 'otp',
+'application/vnd.oasis.opendocument.spreadsheet-template' => 'ots',
+'application/vnd.oasis.opendocument.text-template' => 'ott',
+'application/vnd.openofficeorg.extension' => 'oxt',
+'text/x-pascal' => 'p',
+'application/pkcs10' => 'p10',
+'application/x-pkcs12' => 'p12',
+'application/x-pkcs7-certificates' => 'p7b',
+'application/pkcs7-mime' => 'p7m',
+'application/x-pkcs7-certreqresp' => 'p7r',
+'application/pkcs7-signature' => 'p7s',
+'application/pkcs8' => 'p8',
+'text/plain-bas' => 'par',
+'application/vnd.pawaafile' => 'paw',
+'application/vnd.powerbuilder6' => 'pbd',
+'image/x-portable-bitmap' => 'pbm',
+'application/x-font-pcf' => 'pcf',
+'application/vnd.hp-pcl' => 'pcl',
+'application/vnd.hp-pclxl' => 'pclxl',
+'application/vnd.curl.pcurl' => 'pcurl',
+'image/x-pcx' => 'pcx',
+'application/vnd.palm' => 'pdb',
+'application/pdf' => 'pdf',
+'application/x-font-type1' => 'pfa',
+'application/font-tdpfr' => 'pfr',
+'image/x-portable-graymap' => 'pgm',
+'application/x-chess-pgn' => 'pgn',
+'application/pgp-signature' => 'pgp',
+'image/x-pict' => 'pic',
+'application/pkixcmp' => 'pki',
+'application/pkix-pkipath' => 'pkipath',
+'application/vnd.3gpp.pic-bw-large' => 'plb',
+'application/vnd.mobius.plc' => 'plc',
+'application/vnd.pocketlearn' => 'plf',
+'application/pls+xml' => 'pls',
+'application/vnd.ctc-posml' => 'pml',
+'image/png' => 'png',
+'image/x-portable-anymap' => 'pnm',
+'application/vnd.macports.portpkg' => 'portpkg',
+'application/vnd.ms-powerpoint.template.macroenabled.12' => 'potm',
+'application/vnd.openxmlformats-officedocument.presentationml.template' => 'potx',
+'application/vnd.ms-powerpoint.addin.macroenabled.12' => 'ppam',
+'application/vnd.cups-ppd' => 'ppd',
+'image/x-portable-pixmap' => 'ppm',
+'application/vnd.ms-powerpoint.slideshow.macroenabled.12' => 'ppsm',
+'application/vnd.openxmlformats-officedocument.presentationml.slideshow' => 'ppsx',
+'application/vnd.ms-powerpoint' => 'ppt',
+'application/vnd.ms-powerpoint.presentation.macroenabled.12' => 'pptm',
+'application/vnd.openxmlformats-officedocument.presentationml.presentation' => 'pptx',
+'application/x-mobipocket-ebook' => 'prc',
+'application/vnd.lotus-freelance' => 'pre',
+'application/pics-rules' => 'prf',
+'application/vnd.3gpp.pic-bw-small' => 'psb',
+'image/vnd.adobe.photoshop' => 'psd',
+'application/x-font-linux-psf' => 'psf',
+'application/pskc+xml' => 'pskcxml',
+'application/vnd.pvi.ptid1' => 'ptid',
+'application/x-mspublisher' => 'pub',
+'application/vnd.3gpp.pic-bw-var' => 'pvb',
+'application/vnd.3m.post-it-notes' => 'pwn',
+'audio/vnd.ms-playready.media.pya' => 'pya',
+'video/vnd.ms-playready.media.pyv' => 'pyv',
+'application/vnd.epson.quickanime' => 'qam',
+'application/vnd.intu.qbo' => 'qbo',
+'application/vnd.intu.qfx' => 'qfx',
+'application/vnd.publishare-delta-tree' => 'qps',
+'video/quicktime' => 'qt',
+'application/vnd.quark.quarkxpress' => 'qxd',
+'audio/x-pn-realaudio' => 'ram',
+'application/x-rar-compressed' => 'rar',
+'image/x-cmu-raster' => 'ras',
+'application/vnd.ipunplugged.rcprofile' => 'rcprofile',
+'application/rdf+xml' => 'rdf',
+'application/vnd.data-vision.rdz' => 'rdz',
+'application/vnd.businessobjects' => 'rep',
+'application/x-dtbresource+xml' => 'res',
+'image/x-rgb' => 'rgb',
+'application/reginfo+xml' => 'rif',
+'audio/vnd.rip' => 'rip',
+'application/resource-lists+xml' => 'rl',
+'image/vnd.fujixerox.edmics-rlc' => 'rlc',
+'application/resource-lists-diff+xml' => 'rld',
+'application/vnd.rn-realmedia' => 'rm',
+'audio/x-pn-realaudio-plugin' => 'rmp',
+'application/vnd.jcp.javame.midlet-rms' => 'rms',
+'application/relax-ng-compact-syntax' => 'rnc',
+'application/vnd.cloanto.rp9' => 'rp9',
+'application/vnd.nokia.radio-presets' => 'rpss',
+'application/vnd.nokia.radio-preset' => 'rpst',
+'application/sparql-query' => 'rq',
+'application/rls-services+xml' => 'rs',
+'application/rsd+xml' => 'rsd',
+'application/rss+xml' => 'rss',
+'application/rtf' => 'rtf',
+'text/richtext' => 'rtx',
+'text/x-asm' => 's',
+'application/vnd.yamaha.smaf-audio' => 'saf',
+'application/sbml+xml' => 'sbml',
+'application/vnd.ibm.secure-container' => 'sc',
+'application/x-msschedule' => 'scd',
+'application/vnd.lotus-screencam' => 'scm',
+'application/scvp-cv-request' => 'scq',
+'application/scvp-cv-response' => 'scs',
+'text/vnd.curl.scurl' => 'scurl',
+'application/vnd.stardivision.draw' => 'sda',
+'application/vnd.stardivision.calc' => 'sdc',
+'application/vnd.stardivision.impress' => 'sdd',
+'application/vnd.solent.sdkm+xml' => 'sdkm',
+'application/sdp' => 'sdp',
+'application/vnd.stardivision.writer' => 'sdw',
+'application/vnd.seemail' => 'see',
+'application/vnd.fdsn.seed' => 'seed',
+'application/vnd.sema' => 'sema',
+'application/vnd.semd' => 'semd',
+'application/vnd.semf' => 'semf',
+'application/java-serialized-object' => 'ser',
+'application/set-payment-initiation' => 'setpay',
+'application/set-registration-initiation' => 'setreg',
+'application/vnd.hydrostatix.sof-data' => 'sfd-hdstx',
+'application/vnd.spotfire.sfs' => 'sfs',
+'application/vnd.stardivision.writer-global' => 'sgl',
+'text/sgml' => 'sgml',
+'application/x-sh' => 'sh',
+'application/x-shar' => 'shar',
+'application/shf+xml' => 'shf',
+'application/vnd.symbian.install' => 'sis',
+'application/x-stuffit' => 'sit',
+'application/x-stuffitx' => 'sitx',
+'application/vnd.koan' => 'skp',
+'application/vnd.ms-powerpoint.slide.macroenabled.12' => 'sldm',
+'application/vnd.openxmlformats-officedocument.presentationml.slide' => 'sldx',
+'application/vnd.epson.salt' => 'slt',
+'application/vnd.stepmania.stepchart' => 'sm',
+'application/vnd.stardivision.math' => 'smf',
+'application/smil+xml' => 'smi',
+'application/x-font-snf' => 'snf',
+'application/vnd.yamaha.smaf-phrase' => 'spf',
+'application/x-futuresplash' => 'spl',
+'text/vnd.in3d.spot' => 'spot',
+'application/scvp-vp-response' => 'spp',
+'application/scvp-vp-request' => 'spq',
+'application/x-wais-source' => 'src',
+'application/sru+xml' => 'sru',
+'application/sparql-results+xml' => 'srx',
+'application/vnd.kodak-descriptor' => 'sse',
+'application/vnd.epson.ssf' => 'ssf',
+'application/ssml+xml' => 'ssml',
+'application/vnd.sailingtracker.track' => 'st',
+'application/vnd.sun.xml.calc.template' => 'stc',
+'application/vnd.sun.xml.draw.template' => 'std',
+'application/vnd.wt.stf' => 'stf',
+'application/vnd.sun.xml.impress.template' => 'sti',
+'application/hyperstudio' => 'stk',
+'application/vnd.ms-pki.stl' => 'stl',
+'application/vnd.pg.format' => 'str',
+'application/vnd.sun.xml.writer.template' => 'stw',
+'image/vnd.dvb.subtitle' => 'sub',
+'application/vnd.sus-calendar' => 'sus',
+'application/x-sv4cpio' => 'sv4cpio',
+'application/x-sv4crc' => 'sv4crc',
+'application/vnd.dvb.service' => 'svc',
+'application/vnd.svd' => 'svd',
+'image/svg+xml' => 'svg',
+'application/x-shockwave-flash' => 'swf',
+'application/vnd.aristanetworks.swi' => 'swi',
+'application/vnd.sun.xml.calc' => 'sxc',
+'application/vnd.sun.xml.draw' => 'sxd',
+'application/vnd.sun.xml.writer.global' => 'sxg',
+'application/vnd.sun.xml.impress' => 'sxi',
+'application/vnd.sun.xml.math' => 'sxm',
+'application/vnd.sun.xml.writer' => 'sxw',
+'text/troff' => 't',
+'application/vnd.tao.intent-module-archive' => 'tao',
+'application/x-tar' => 'tar',
+'application/vnd.3gpp2.tcap' => 'tcap',
+'application/x-tcl' => 'tcl',
+'application/vnd.smart.teacher' => 'teacher',
+'application/tei+xml' => 'tei',
+'application/x-tex' => 'tex',
+'application/x-texinfo' => 'texinfo',
+'application/thraud+xml' => 'tfi',
+'application/x-tex-tfm' => 'tfm',
+'application/vnd.ms-officetheme' => 'thmx',
+'image/tiff' => 'tiff',
+'application/vnd.tmobile-livetv' => 'tmo',
+'application/x-bittorrent' => 'torrent',
+'application/vnd.groove-tool-template' => 'tpl',
+'application/vnd.trid.tpt' => 'tpt',
+'application/vnd.trueapp' => 'tra',
+'application/x-msterminal' => 'trm',
+'application/timestamped-data' => 'tsd',
+'text/tab-separated-values' => 'tsv',
+'application/x-font-ttf' => 'ttf',
+'text/turtle' => 'ttl',
+'application/vnd.simtech-mindmapper' => 'twd',
+'application/vnd.genomatix.tuxedo' => 'txd',
+'application/vnd.mobius.txf' => 'txf',
+'text/plain' => 'txt',
+'application/vnd.ufdl' => 'ufd',
+'application/vnd.umajin' => 'umj',
+'application/vnd.unity' => 'unityweb',
+'application/vnd.uoml+xml' => 'uoml',
+'text/uri-list' => 'uri',
+'application/x-ustar' => 'ustar',
+'application/vnd.uiq.theme' => 'utz',
+'text/x-uuencode' => 'uu',
+'audio/vnd.dece.audio' => 'uva',
+'video/vnd.dece.hd' => 'uvh',
+'image/vnd.dece.graphic' => 'uvi',
+'video/vnd.dece.mobile' => 'uvm',
+'video/vnd.dece.pd' => 'uvp',
+'video/vnd.dece.sd' => 'uvs',
+'video/vnd.uvvu.mp4' => 'uvu',
+'video/vnd.dece.video' => 'uvv',
+'application/x-cdlink' => 'vcd',
+'text/x-vcard' => 'vcf',
+'application/vnd.groove-vcard' => 'vcg',
+'text/x-vcalendar' => 'vcs',
+'application/vnd.vcx' => 'vcx',
+'application/vnd.visionary' => 'vis',
+'video/vnd.vivo' => 'viv',
+'application/vnd.visio' => 'vsd',
+'application/vnd.vsf' => 'vsf',
+'model/vnd.vtu' => 'vtu',
+'application/voicexml+xml' => 'vxml',
+'application/x-doom' => 'wad',
+'audio/x-wav' => 'wav',
+'audio/x-ms-wax' => 'wax',
+'image/vnd.wap.wbmp' => 'wbmp',
+'application/vnd.criticaltools.wbs+xml' => 'wbs',
+'application/vnd.wap.wbxml' => 'wbxml',
+'audio/webm' => 'weba',
+'video/webm' => 'webm',
+'image/webp' => 'webp',
+'application/vnd.pmi.widget' => 'wg',
+'application/widget' => 'wgt',
+'video/x-ms-wm' => 'wm',
+'audio/x-ms-wma' => 'wma',
+'application/x-ms-wmd' => 'wmd',
+'application/x-msmetafile' => 'wmf',
+'text/vnd.wap.wml' => 'wml',
+'application/vnd.wap.wmlc' => 'wmlc',
+'text/vnd.wap.wmlscript' => 'wmls',
+'application/vnd.wap.wmlscriptc' => 'wmlsc',
+'video/x-ms-wmv' => 'wmv',
+'video/x-ms-wmx' => 'wmx',
+'application/x-ms-wmz' => 'wmz',
+'application/x-font-woff' => 'woff',
+'application/vnd.wordperfect' => 'wpd',
+'application/vnd.ms-wpl' => 'wpl',
+'application/vnd.ms-works' => 'wps',
+'application/vnd.wqd' => 'wqd',
+'application/x-mswrite' => 'wri',
+'model/vrml' => 'wrl',
+'application/wsdl+xml' => 'wsdl',
+'application/wspolicy+xml' => 'wspolicy',
+'application/vnd.webturbo' => 'wtb',
+'video/x-ms-wvx' => 'wvx',
+'application/vnd.hzn-3d-crossword' => 'x3d',
+'application/x-silverlight-app' => 'xap',
+'application/vnd.xara' => 'xar',
+'application/x-ms-xbap' => 'xbap',
+'application/vnd.fujixerox.docuworks.binder' => 'xbd',
+'image/x-xbitmap' => 'xbm',
+'application/xcap-diff+xml' => 'xdf',
+'application/vnd.syncml.dm+xml' => 'xdm',
+'application/vnd.adobe.xdp+xml' => 'xdp',
+'application/dssc+xml' => 'xdssc',
+'application/vnd.fujixerox.docuworks' => 'xdw',
+'application/xenc+xml' => 'xenc',
+'application/patch-ops-error+xml' => 'xer',
+'application/vnd.adobe.xfdf' => 'xfdf',
+'application/vnd.xfdl' => 'xfdl',
+'application/xhtml+xml' => 'xhtml',
+'image/vnd.xiff' => 'xif',
+'application/vnd.ms-excel.addin.macroenabled.12' => 'xlam',
+'application/vnd.ms-excel' => 'xls',
+'application/vnd.ms-excel.sheet.binary.macroenabled.12' => 'xlsb',
+'application/vnd.ms-excel.sheet.macroenabled.12' => 'xlsm',
+'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet' => 'xlsx',
+'application/vnd.ms-excel.template.macroenabled.12' => 'xltm',
+'application/vnd.openxmlformats-officedocument.spreadsheetml.template' => 'xltx',
+'application/xml' => 'xml',
+'application/vnd.olpc-sugar' => 'xo',
+'application/xop+xml' => 'xop',
+'application/x-xpinstall' => 'xpi',
+'image/x-xpixmap' => 'xpm',
+'application/vnd.is-xpr' => 'xpr',
+'application/vnd.ms-xpsdocument' => 'xps',
+'application/vnd.intercon.formnet' => 'xpw',
+'application/xslt+xml' => 'xslt',
+'application/vnd.syncml+xml' => 'xsm',
+'application/xspf+xml' => 'xspf',
+'application/vnd.mozilla.xul+xml' => 'xul',
+'image/x-xwindowdump' => 'xwd',
+'chemical/x-xyz' => 'xyz',
+'text/yaml' => 'yaml',
+'application/yang' => 'yang',
+'application/yin+xml' => 'yin',
+'application/vnd.zzazz.deck+xml' => 'zaz',
+'application/zip' => 'zip',
+'application/vnd.zul' => 'zir',
+'application/vnd.handheld-entertainment+xml' => 'zmm',
+#<SHELL_REPLACE
+  ];
+
+  public static function fromExt($ext) {
+    foreach (self::Types as $t => $e) {
+      if ($ext == $e) return $t;
+    }
+    return null;
+  }
+
+  public static function toExt($type) {
+    if (empty(self::Types[$type])) return null;
+    return self::Types[$type];
+  }
+}
+
+#var_export(Http::msg(500));
+?>
index 8d68e2f5f4b4634cbdf68cc2f827a72c6e9fedde..a0b151de3a871678007dc9a8fe5f08efe88ccb3f 100644 (file)
@@ -149,8 +149,12 @@ class NB {
 
   public static function mime2ext($mime) {
 
-    static $aliases = null; if ($aliases === null) $aliases = array_combine(array_values(self::$content_types_aliases),array_keys(self::$content_types_aliases));
-    #static $v = array_combine(array_values(self::$content_types_aliases),array_keys(self::$content_types_aliases));
+    static $aliases = null;
+    if ($aliases === null) $aliases = array_combine(
+      array_values(self::$content_types_aliases),
+      array_keys(self::$content_types_aliases)
+    );
+
     foreach (self::$content_types as $e => $c) {
       if ($mime == $c) return $e;
     }
@@ -232,9 +236,9 @@ class NB {
         $header = getallheaders();
 
       } else {
-        foreach ($_SERVER as $name => $value) {
-          if (substr($name, 0, 5) == 'HTTP_') {
-            $header[str_replace(' ', '-', ucwords(strtolower(str_replace('_', ' ', substr($name, 5)))))] = $value;
+        foreach ($_SERVER as $key => $value) {
+          if (substr($key, 0, 5) == 'HTTP_') {
+            $header[str_replace(' ', '-', ucwords(strtolower(str_replace('_', ' ', substr($key, 5)))))] = $value;
           }
         }
     #bye( [$name,$header] ); # argcs ????
@@ -547,7 +551,25 @@ class NB {
 
   public static function no_accent($str){
     return strtr($str,array(
-      'À' => 'A', 'Á' => 'A', 'Â' => 'A', 'Ã' => 'A', 'Ä' => 'A', 'Å' => 'A', 'à' => 'a', 'á' => 'a', 'â' => 'a', 'ã' => 'a', 'ä' => 'a', 'å' => 'a', 'Ā' => 'A', 'ā' => 'a', 'Ă' => 'A', 'ă' => 'a', 'Ą' => 'A', 'ą' => 'a', 'Ç' => 'C', 'ç' => 'c', 'Ć' => 'C', 'ć' => 'c', 'Ĉ' => 'C', 'ĉ' => 'c', 'Ċ' => 'C', 'ċ' => 'c', 'Č' => 'C', 'č' => 'c', 'Ð' => 'D', 'ð' => 'd', 'Ď' => 'D', 'ď' => 'd', 'Đ' => 'D', 'đ' => 'd', 'È' => 'E', 'É' => 'E', 'Ê' => 'E', 'Ë' => 'E', 'è' => 'e', 'é' => 'e', 'ê' => 'e', 'ë' => 'e', 'Ē' => 'E', 'ē' => 'e', 'Ĕ' => 'E', 'ĕ' => 'e', 'Ė' => 'E', 'ė' => 'e', 'Ę' => 'E', 'ę' => 'e', 'Ě' => 'E', 'ě' => 'e', 'Ĝ' => 'G', 'ĝ' => 'g', 'Ğ' => 'G', 'ğ' => 'g', 'Ġ' => 'G', 'ġ' => 'g', 'Ģ' => 'G', 'ģ' => 'g', 'Ĥ' => 'H', 'ĥ' => 'h', 'Ħ' => 'H', 'ħ' => 'h', 'Ì' => 'I', 'Í' => 'I', 'Î' => 'I', 'Ï' => 'I', 'ì' => 'i', 'í' => 'i', 'î' => 'i', 'ï' => 'i', 'Ĩ' => 'I', 'ĩ' => 'i', 'Ī' => 'I', 'ī' => 'i', 'Ĭ' => 'I', 'ĭ' => 'i', 'Į' => 'I', 'į' => 'i', 'İ' => 'I', 'ı' => 'i', 'Ĵ' => 'J', 'ĵ' => 'j', 'Ķ' => 'K', 'ķ' => 'k', 'ĸ' => 'k', 'Ĺ' => 'L', 'ĺ' => 'l', 'Ļ' => 'L', 'ļ' => 'l', 'Ľ' => 'L', 'ľ' => 'l', 'Ŀ' => 'L', 'ŀ' => 'l', 'Ł' => 'L', 'ł' => 'l', 'Ñ' => 'N', 'ñ' => 'n', 'Ń' => 'N', 'ń' => 'n', 'Ņ' => 'N', 'ņ' => 'n', 'Ň' => 'N', 'ň' => 'n', 'ʼn' => 'n', 'Ŋ' => 'N', 'ŋ' => 'n', 'Ò' => 'O', 'Ó' => 'O', 'Ô' => 'O', 'Õ' => 'O', 'Ö' => 'O', 'Ø' => 'O', 'ò' => 'o', 'ó' => 'o', 'ô' => 'o', 'õ' => 'o', 'ö' => 'o', 'ø' => 'o', 'Ō' => 'O', 'ō' => 'o', 'Ŏ' => 'O', 'ŏ' => 'o', 'Ő' => 'O', 'ő' => 'o', 'Ŕ' => 'R', 'ŕ' => 'r', 'Ŗ' => 'R', 'ŗ' => 'r', 'Ř' => 'R', 'ř' => 'r', 'Ś' => 'S', 'ś' => 's', 'Ŝ' => 'S', 'ŝ' => 's', 'Ş' => 'S', 'ş' => 's', 'Š' => 'S', 'š' => 's', 'ſ' => 's', 'Ţ' => 'T', 'ţ' => 't', 'Ť' => 'T', 'ť' => 't', 'Ŧ' => 'T', 'ŧ' => 't', 'Ù' => 'U', 'Ú' => 'U', 'Û' => 'U', 'Ü' => 'U', 'ù' => 'u', 'ú' => 'u', 'û' => 'u', 'ü' => 'u', 'Ũ' => 'U', 'ũ' => 'u', 'Ū' => 'U', 'ū' => 'u', 'Ŭ' => 'U', 'ŭ' => 'u', 'Ů' => 'U', 'ů' => 'u', 'Ű' => 'U', 'ű' => 'u', 'Ų' => 'U', 'ų' => 'u', 'Ŵ' => 'W', 'ŵ' => 'w', 'Ý' => 'Y', 'ý' => 'y', 'ÿ' => 'y', 'Ŷ' => 'Y', 'ŷ' => 'y', 'Ÿ' => 'Y', 'Ź' => 'Z', 'ź' => 'z', 'Ż' => 'Z', 'ż' => 'z', 'Ž' => 'Z', 'ž' => 'z'
+      'À' => 'A', 'Á' => 'A', 'Â' => 'A', 'Ã' => 'A', 'Ä' => 'A', 'Å' => 'A', 'à' => 'a', 'á' => 'a', 'â' => 'a', 'ã' => 'a', 'ä' => 'a', 'å' => 'a', 'Ā' => 'A', 'ā' => 'a', 'Ă' => 'A', 'ă' => 'a', 'Ą' => 'A', 'ą' => 'a',
+      'Ç' => 'C', 'ç' => 'c', 'Ć' => 'C', 'ć' => 'c', 'Ĉ' => 'C', 'ĉ' => 'c', 'Ċ' => 'C', 'ċ' => 'c', 'Č' => 'C', 'č' => 'c',
+      'Ð' => 'D', 'ð' => 'd', 'Ď' => 'D', 'ď' => 'd', 'Đ' => 'D', 'đ' => 'd',
+      'È' => 'E', 'É' => 'E', 'Ê' => 'E', 'Ë' => 'E', 'è' => 'e', 'é' => 'e', 'ê' => 'e', 'ë' => 'e', 'Ē' => 'E', 'ē' => 'e', 'Ĕ' => 'E', 'ĕ' => 'e', 'Ė' => 'E', 'ė' => 'e', 'Ę' => 'E', 'ę' => 'e', 'Ě' => 'E', 'ě' => 'e',
+      'Ĝ' => 'G', 'ĝ' => 'g', 'Ğ' => 'G', 'ğ' => 'g', 'Ġ' => 'G', 'ġ' => 'g', 'Ģ' => 'G', 'ģ' => 'g',
+      'Ĥ' => 'H', 'ĥ' => 'h', 'Ħ' => 'H', 'ħ' => 'h',
+      'Ì' => 'I', 'Í' => 'I', 'Î' => 'I', 'Ï' => 'I', 'ì' => 'i', 'í' => 'i', 'î' => 'i', 'ï' => 'i', 'Ĩ' => 'I', 'ĩ' => 'i', 'Ī' => 'I', 'ī' => 'i', 'Ĭ' => 'I', 'ĭ' => 'i', 'Į' => 'I', 'į' => 'i', 'İ' => 'I', 'ı' => 'i',
+      'Ĵ' => 'J', 'ĵ' => 'j',
+      'Ķ' => 'K', 'ķ' => 'k', 'ĸ' => 'k',
+      'Ĺ' => 'L', 'ĺ' => 'l', 'Ļ' => 'L', 'ļ' => 'l', 'Ľ' => 'L', 'ľ' => 'l', 'Ŀ' => 'L', 'ŀ' => 'l', 'Ł' => 'L', 'ł' => 'l',
+      'Ñ' => 'N', 'ñ' => 'n', 'Ń' => 'N', 'ń' => 'n', 'Ņ' => 'N', 'ņ' => 'n', 'Ň' => 'N', 'ň' => 'n', 'ʼn' => 'n', 'Ŋ' => 'N', 'ŋ' => 'n',
+      'Ò' => 'O', 'Ó' => 'O', 'Ô' => 'O', 'Õ' => 'O', 'Ö' => 'O', 'Ø' => 'O', 'ò' => 'o', 'ó' => 'o', 'ô' => 'o', 'õ' => 'o', 'ö' => 'o', 'ø' => 'o', 'Ō' => 'O', 'ō' => 'o', 'Ŏ' => 'O', 'ŏ' => 'o', 'Ő' => 'O', 'ő' => 'o',
+      'Ŕ' => 'R', 'ŕ' => 'r', 'Ŗ' => 'R', 'ŗ' => 'r', 'Ř' => 'R', 'ř' => 'r',
+      'Ś' => 'S', 'ś' => 's', 'Ŝ' => 'S', 'ŝ' => 's', 'Ş' => 'S', 'ş' => 's', 'Š' => 'S', 'š' => 's', 'ſ' => 's',
+      'Ţ' => 'T', 'ţ' => 't', 'Ť' => 'T', 'ť' => 't', 'Ŧ' => 'T', 'ŧ' => 't',
+      'Ù' => 'U', 'Ú' => 'U', 'Û' => 'U', 'Ü' => 'U', 'ù' => 'u', 'ú' => 'u', 'û' => 'u', 'ü' => 'u', 'Ũ' => 'U', 'ũ' => 'u', 'Ū' => 'U', 'ū' => 'u', 'Ŭ' => 'U', 'ŭ' => 'u', 'Ů' => 'U', 'ů' => 'u', 'Ű' => 'U', 'ű' => 'u', 'Ų' => 'U', 'ų' => 'u',
+      'Ŵ' => 'W', 'ŵ' => 'w',
+      'Ý' => 'Y', 'ý' => 'y', 'ÿ' => 'y', 'Ŷ' => 'Y', 'ŷ' => 'y', 'Ÿ' => 'Y',
+      'Ź' => 'Z', 'ź' => 'z', 'Ż' => 'Z', 'ż' => 'z', 'Ž' => 'Z', 'ž' => 'z'
     ));
   }
 
@@ -813,14 +835,16 @@ class NB {
    * Function client_content_type
    * Return the head Accept from the client
    */
-  public static function client_content_type() {
-    $headers = self::client_header();
-    if (0
-      or !isset($headers['Accept'])
-      or $headers['Accept'] == '*/*'
-    ) return '';
-    $v = explode(',', $headers['Accept']);
-    return $v ? $v[0] : '';
+  public static function client_content_type($default='') {
+    $v = explode(',', self::client_header('Accept'));
+    return ( ($v and $v[0] != '*/*') ? $v[0] : $default );
+# NB 19.12.16     $headers = self::client_header();
+# NB 19.12.16     if (0
+# NB 19.12.16       or !isset($headers['Accept'])
+# NB 19.12.16       or $headers['Accept'] == '*/*'
+# NB 19.12.16     ) return '';
+# NB 19.12.16     $v = explode(',', $headers['Accept']);
+# NB 19.12.16     return $v ? $v[0] : '';
   }
 
   public static function array_fill_assoc($rows) {
index 4c65d97426868d1a4c1ea09557dacdb45b2f29c8..49efa09660b29b6d4f15e6761a4302a5c13c12f5 100644 (file)
@@ -28,6 +28,8 @@ class Page extends nb {
   public static $html5 = true;
   public static $expires; # Seconds to cache, no cache if 0, no head if null
 
+  public $nav = '';
+
   public $title = '';
   public $css = [];
   public $head = [];
@@ -69,11 +71,11 @@ class Page extends nb {
     if (!$this->content_type()) $this->content_type($this->client_content_type());
 
     // Nav
-    list($title,$html) = [[],[]];
-    if (isset($opt['nav'])) {
-      list($title,$html) = self::nav_parse($opt['nav']);
-      unset($opt['nav']);
-    }
+# NB 19.12.16     list($title,$html) = [[],[]];
+# NB 19.12.16     if (isset($opt['nav_'])) {
+# NB 19.12.16       list($title,$html) = self::nav_parse($opt['nav']);
+# NB 19.12.16       unset($opt['nav']);
+# NB 19.12.16     }
 # NB 06.12.16     if ( empty($this->title) ) $this->title = !empty($title) ? join($this->sep,$title) : $this->filename2title();
 
     // Statics
@@ -90,11 +92,11 @@ class Page extends nb {
     parent::__construct($opt);
 
     // Defaults
-    if ( empty($this->title) and !empty($title) ) $this->title = join($this->sep,$title);
-    if ( empty($this->h1) and !empty($html) ) $this->h1 = join($this->sep,$html);
-    #if ( !empty($title) and empty($this->title) ) $this->title = join($this->sep,$title);
-    #if ( empty($this->title) ) $this->title = $this->filename2title();
-    if ( empty($this->h1) and ! empty($this->title) ) $this->h1 = $this->title;
+# NB 19.12.16     if ( empty($this->title) and !empty($title) ) $this->title = join($this->sep,$title);
+# NB 19.12.16     if ( empty($this->h1) and !empty($html) ) $this->h1 = join($this->sep,$html);
+# NB 19.12.16     #if ( !empty($title) and empty($this->title) ) $this->title = join($this->sep,$title);
+# NB 19.12.16     #if ( empty($this->title) ) $this->title = $this->filename2title();
+# NB 19.12.16     if ( empty($this->h1) and ! empty($this->title) ) $this->h1 = $this->title;
 
     // Call / Print
     if (!empty($this->call)) $this->call($this->call);
@@ -186,6 +188,7 @@ class Page extends nb {
    * Return html code for a tag
    */
   public static function tag($tag,$content='',$attrs='') {
+    #bye('zaza');
     static $is_html = null;
     if ($is_html === null) $is_html = preg_match('/ml$/',self::content_type()) ? true : false;
     
@@ -306,6 +309,12 @@ class Page extends nb {
     }
 
 
+
+    // Nav
+    list($title,$html) = empty($this->nav) ? ['',''] : self::nav_parse($this->nav);
+    if ( empty($this->title) and !empty($title) ) $this->title = join($this->sep,$title);
+    if ( empty($this->h1) and !empty($html) ) $this->h1 = join($this->sep,$html);
+    if ( empty($this->h1) and !empty($this->title) ) $this->h1 = $this->title;
     if (preg_match('/ml$/',self::$content_type)) {
 
       echo $this->head(); 
@@ -505,7 +514,8 @@ class Page extends nb {
     return [$title,$nav,$hash];
   }
 
-  public static function phpinfo() {
+  public static function phpinfo($text=null) {
+    if ($text===null) $text = self::php_cli();
     ob_start();
     phpinfo(INFO_ALL - INFO_LICENSE);
     $phpinfo = ob_get_contents();
@@ -527,7 +537,7 @@ class Page extends nb {
     # Pretty h2
     $phpinfo =  preg_replace_callback ('@(<h2>(?:<[^>]+>)?)([^<]+)@',function($m){return $m[1].prettyText($m[2]);},$phpinfo);
 
-    if (self::php_cli()) return $phpinfo;
+    if ($text) return $phpinfo;
     if (!preg_match_all('@(<h2.*?</table>)@s',$phpinfo,$m)) return '';
     return join("\n",$m[0]);
   }
index 90fbbe2be9707e8675776a35cfd68d750eb4dc16..16dd16c2889f9e3bafae0fa76ad8eff175cb98c4 100644 (file)
@@ -1,21 +1,28 @@
 <?php
 require_once(realpath(dirname(__FILE__).'/../../lib/php/nb.php'));
 require_once(NB_ROOT.'/lib/php/http.php');
+require_once(NB_ROOT.'/lib/php/mime.php');
 
 # Minimum permission access 0 = readonly
 define('DBQ_PERM',(int)(isset($_SERVER['DBQ_PERM']) ? $_SERVER['DBQ_PERM'] : 9));
 
+define('DBQ_HUMAN_UA_EXP',(string)(isset($_SERVER['DBQ_HUMAN_UA_EXP'])
+  ? $_SERVER['DBQ_HUMAN_UA_EXP']
+  : '/^\S+\s+.Windows|iPhone|Android|Macintosh|Linux/')
+);
+
 define('DBQ_PARAM_DEFAULT',(string)(isset($_SERVER['DBQ_PARAM_DEFAULT']) ? $_SERVER['DBQ_PARAM_DEFAULT'] : 'ls'));
-define('DBQ_PARAM_FORMAT',(string)(isset($_SERVER['DBQ_PARAM_FORMAT']) ? $_SERVER['DBQ_PARAM_FORMAT'] :
-    (!empty($_SERVER['HTTP_USER_AGENT']) and
-      preg_match('/^\S+\s+.Windows|iPhone|Android|Macintosh|Linux/',$_SERVER['HTTP_USER_AGENT'])
-    )
-      ? 'html'
-      : 'human'
-));
+define('DBQ_PARAM_FORMAT',(string)(isset($_SERVER['DBQ_PARAM_FORMAT']) ? $_SERVER['DBQ_PARAM_FORMAT'] : ''));
+
+define('DBQ_CSS',(string)(isset($_SERVER['DBQ_CSS'])
+  ? $_SERVER['DBQ_CSS']
+  : '/default.css')
+);
 
-define('DBQ_CSS',(string)(isset($_SERVER['DBQ_CSS']) ? $_SERVER['DBQ_CSS'] : '/default.css'));
-define('DBQ_TITLE',(string)(isset($_SERVER['DBQ_TITLE']) ? $_SERVER['DBQ_TITLE'] : 'Dbq'));
+define('DBQ_TITLE',(string)(isset($_SERVER['DBQ_TITLE'])
+  ? $_SERVER['DBQ_TITLE']
+  : 'Dbq')
+);
 
 class DbQ extends nb {
 
@@ -87,8 +94,6 @@ class DbQ extends nb {
     // Post defaults values
     if (empty($this->ext)) $this->ext = $this->params['format'];
 
-    if ($this->params['format'] == 'html') $this->params['format'] = 'table';
-
     //
     // Page
     require_once(NB_ROOT.'/lib/php/page.php');
@@ -138,12 +143,7 @@ table.rows th, table.rows td { border-color: '.$this->colors['body-border'].'; }
   public function page($obj,$meth=null,$head=[],$fct=null) {
 
     if (empty($this->_nopage)) {
-      $this->page_colors();
-      $this->page->content_type($this->page->ext2mime($this->params['format']) ? $this->page->ext2mime($this->params['format']) : 'text/plain');
-      if ($this->page->is('text') and !$this->page->is('html')) $this->page->content_type('text/plain');
-
-      $this->page->headers_no_cache();
-      $this->page->begin();
+      $this->init();
     }
 
     #die($obj);
@@ -157,6 +157,7 @@ table.rows th, table.rows td { border-color: '.$this->colors['body-border'].'; }
     } else {
       $out = $obj->$meth();
       if (!empty($out)) {
+    #bye([$this->params['format'],$this->page->content_type()]);
         $this->db->out($out,$head,['row_parse_post'=>$fct]);
       }
     }
@@ -209,7 +210,6 @@ table.rows th, table.rows td { border-color: '.$this->colors['body-border'].'; }
       require_once(NB_ROOT.'/lib/php/db/config.php');
     }
     $this->db = new Db(['conf'=>$DB_CONFS]);
-    $this->db->format = $this->params['format'];
     $this->db->base = '/';
     return $this->db;
   }
@@ -407,6 +407,77 @@ table.rows th, table.rows td { border-color: '.$this->colors['body-border'].'; }
     exit;
   }
 
+  public function status() {
+    $rows = [];
+
+    //
+    $rows[] = [ 'name' => $this->page->tag('h4','*APP'), 'value' => '' ];
+    //
+    $rows[] = [
+      'name' => 'dbq.client_content_type',
+      'value' => $this->client_content_type(),
+    ];
+    $rows[] = [
+      'name' => 'dbq.params.format',
+      'value' => $this->params['format'],
+    ];
+
+    //
+    $rows[] = [ 'name' => $this->page->tag('h4','*CLIENT HEADERS'), 'value' => '' ];
+    //
+    foreach ($this->client_header() as $k=>$v) $rows[] = [
+      'name' => $k,
+      'value' => ( is_scalar($v) ? $v : json_encode($v) ),
+    ];
+
+    //
+    $rows[] = [ 'name' => $this->page->tag('h4','*SERVER HEADERS'), 'value' => '' ];
+    //
+    foreach (headers_list() as $v) {
+      list($k,$v) = explode(': ',$v);
+      $rows[] = [
+        'name' => $k,
+        'value' => ( is_scalar($v) ? $v : json_encode($v) ),
+      ];
+    }
+    return $rows;
+  }
+
+  public function init() {
+
+    // Format first !
+    if (!empty(DBQ_PARAM_FORMAT)) {
+      $format = DBQ_PARAM_FORMAT;
+
+    } else if ($this->params['format']) {
+      $format = $this->params['format'];
+
+    } else if ($content_type = self::client_content_type() and ( $format=Mime::toExt($content_type) )) {
+      #$format = $format;
+
+    } else {
+      $format = 
+        (!empty($_SERVER['HTTP_USER_AGENT']) and preg_match(DBQ_HUMAN_UA_EXP,$_SERVER['HTTP_USER_AGENT']))
+          ? 'html'
+          : 'human'
+      ;
+
+    }
+
+    if ($format == 'html') $format = 'table';
+    $this->params['format'] = $format;
+    $this->db->format = $format;
+
+    // Then content type
+    if (empty($content_type)) $content_type = Mime::fromExt($format=='human' ? 'txt' : $format);
+    if ($content_type) $this->page->content_type($content_type);
+
+    // Write output
+    $this->page_colors();
+    $this->page->headers_no_cache();
+    $this->page->begin();
+  }
+
   public function run() {
 
     #
@@ -437,19 +508,25 @@ table.rows th, table.rows td { border-color: '.$this->colors['body-border'].'; }
     } elseif ($action == 'cryptkey') {
       $this->page($this->db,'cryptkey',['key']);
 
-    } elseif ($action == 'headers' and $this->perm >= self::ADMIN) {
-  # NB 14.12.16: TODO NOT STABLE 
-    $rows = [];
-    foreach ($this->page->client_header() as $k=>$v) {
-      $rows[] = [ 'name'=>$k, 'value'=>$v ];
-    }
-    #throw new Exception(var_export('hi',1));
-      #$this->bye($this->page->client_header());
-      $this->page($rows);
+    } elseif ($action == 'status') {
+      $this->page($this,'status');
 
-    } elseif ($action == 'phpinfo' and $this->perm >= self::ADMIN) {
+    } elseif ($this->perm < self::ADMIN) {
+      // NOW ONLY FOR ADMIN !
+    } elseif ($action == 'phpinfo') {
+      #$this->page(['phpinfo'=>$this->page->phpinfo(true)]);
       $this->page($this->page->phpinfo());
 
+    } elseif (0
+      or $action == '_SERVER'
+      or $action == '_REQUEST'
+    ) {
+      $rows = []; foreach ($GLOBALS[$action] as $k=>$v) $rows[] = [
+        'name' => $k,
+        'value' => ( is_scalar($v) ? $v : json_encode($v) ),
+      ];
+      $this->page($rows);
+
     }
 
     #