From 789d49359510f10c68be61eaa56d77b3ab428328 Mon Sep 17 00:00:00 2001 From: Marc Alexander Date: Wed, 23 Oct 2013 18:34:06 +0200 Subject: [ticket/11912] Integrate mimetype guesser with plupload PHPBB3-11912 --- phpBB/phpbb/plupload/plupload.php | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) (limited to 'phpBB/phpbb') diff --git a/phpBB/phpbb/plupload/plupload.php b/phpBB/phpbb/plupload/plupload.php index 6eb5adf864..29a4aff39b 100644 --- a/phpBB/phpbb/plupload/plupload.php +++ b/phpBB/phpbb/plupload/plupload.php @@ -49,6 +49,11 @@ class plupload */ protected $php_ini; + /** + * @var \phpbb\mimetype\guesser + */ + protected $mimetype_guesser; + /** * Final destination for uploaded files, i.e. the "files" directory. * @var string @@ -69,16 +74,18 @@ class plupload * @param \phpbb\request\request_interface $request * @param \phpbb\user $user * @param \phpbb\php\ini $php_ini + * @param \phpbb\mimetype\guesser $mimetype_guesser * * @return null */ - public function __construct($phpbb_root_path, \phpbb\config\config $config, \phpbb\request\request_interface $request, \phpbb\user $user, \phpbb\php\ini $php_ini) + public function __construct($phpbb_root_path, \phpbb\config\config $config, \phpbb\request\request_interface $request, \phpbb\user $user, \phpbb\php\ini $php_ini, \phpbb\mimetype\guesser $mimetype_guesser) { $this->phpbb_root_path = $phpbb_root_path; $this->config = $config; $this->request = $request; $this->user = $user; $this->php_ini = $php_ini; + $this->mimetype_guesser = $mimetype_guesser; $this->upload_directory = $this->phpbb_root_path . $this->config['upload_path']; $this->temporary_directory = $this->upload_directory . '/plupload'; @@ -128,7 +135,7 @@ class plupload 'tmp_name' => $file_path, 'name' => $this->request->variable('real_filename', ''), 'size' => filesize($file_path), - 'type' => $file_info->getMimeType($file_path), + 'type' => $this->mimetype_guesser->guess($file_path), ); } else -- cgit v1.2.1 From 36d314e032757fc8d86f8f0daddc596e0e95ca8e Mon Sep 17 00:00:00 2001 From: Marc Alexander Date: Wed, 23 Oct 2013 18:34:35 +0200 Subject: [ticket/11912] Add phpbb mimetype guesser Mimetype guesser will be used as front-end file for mimetype guessing. PHPBB3-11912 --- phpBB/phpbb/mimetype/guesser.php | 105 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 105 insertions(+) create mode 100644 phpBB/phpbb/mimetype/guesser.php (limited to 'phpBB/phpbb') diff --git a/phpBB/phpbb/mimetype/guesser.php b/phpBB/phpbb/mimetype/guesser.php new file mode 100644 index 0000000000..5ae094cd63 --- /dev/null +++ b/phpBB/phpbb/mimetype/guesser.php @@ -0,0 +1,105 @@ +register_guessers($mimetype_guessers); + } + + /** + * Register MimeTypeGuessers + * + * @param array $mimetype_guessers Mimetype guesser service collection + * + * @throws \LogicException If incorrect or not mimetype guessers have + * been supplied to class + */ + protected function register_guessers($mimetype_guessers) + { + foreach ($mimetype_guessers as $guesser) + { + $is_supported = (method_exists($guesser, 'is_supported')) ? 'is_supported' : ''; + $is_supported = (method_exists($guesser, 'isSupported')) ? 'isSupported' : $is_supported; + + if (empty($is_supported)) + { + throw new \LogicException('Incorrect mimetype guesser supplied.'); + } + + if ($guesser->$is_supported()) + { + $this->guessers[] = $guesser; + } + } + + if (empty($this->guessers)) + { + throw new \LogicException('No mimetype guesser supplied.'); + } + } + + /** + * Guess mimetype of supplied file + * + * @param string $file Path to file + * + * @return string Guess for mimetype of file + */ + public function guess($file) + { + if (!is_file($file)) + { + return false; + } + + if (!is_readable($file)) + { + return false; + } + + foreach ($this->guessers as $guesser) + { + $mimetype = $guesser->guess($file); + + // Try to guess something that is not the fallback application/octet-stream + if ($mimetype !== null && $mimetype !== 'application/octet-stream') + { + return $mimetype; + } + } + // Return any mimetype if we got a result or the fallback value + return (!empty($mimetype)) ? $mimetype : 'application/octet-stream'; + } +} -- cgit v1.2.1 From 63945f3687f57fc341c6c28c7b8940805efa99b7 Mon Sep 17 00:00:00 2001 From: Marc Alexander Date: Wed, 23 Oct 2013 23:11:33 +0200 Subject: [ticket/11912] Add content_guesser The content_guesser will try to use the function mime_content_type() if it's available. If that is not the case, the content_guesser will try to guess the mimetype using the file extension of the supplied file. Since this guesser will be registered after the other guessers, it will be only used if the other guessers are not available. PHPBB3-11912 --- phpBB/phpbb/mimetype/content_guesser.php | 548 +++++++++++++++++++++++++++++++ 1 file changed, 548 insertions(+) create mode 100644 phpBB/phpbb/mimetype/content_guesser.php (limited to 'phpBB/phpbb') diff --git a/phpBB/phpbb/mimetype/content_guesser.php b/phpBB/phpbb/mimetype/content_guesser.php new file mode 100644 index 0000000000..4eeac75499 --- /dev/null +++ b/phpBB/phpbb/mimetype/content_guesser.php @@ -0,0 +1,548 @@ + 'x-world/x-3dmf', + '3dmf' => 'x-world/x-3dmf', + 'a' => 'application/octet-stream', + 'aab' => 'application/x-authorware-bin', + 'aam' => 'application/x-authorware-map', + 'aas' => 'application/x-authorware-seg', + 'abc' => 'text/vnd.abc', + 'acgi' => 'text/html', + 'afl' => 'video/animaflex', + 'ai' => 'application/postscript', + 'aif' => 'audio/aiff', + 'aifc' => 'audio/aiff', + 'aiff' => 'audio/aiff', + 'aim' => 'application/x-aim', + 'aip' => 'text/x-audiosoft-intra', + 'ani' => 'application/x-navi-animation', + 'aos' => 'application/x-nokia-9000-communicator-add-on-software', + 'aps' => 'application/mime', + 'arc' => 'application/octet-stream', + 'arj' => 'application/arj', + 'art' => 'image/x-jg', + 'asf' => 'video/x-ms-asf', + 'asm' => 'text/x-asm', + 'asp' => 'text/asp', + 'asx' => 'application/x-mplayer2', + 'au' => 'audio/basic', + 'avi' => 'application/x-troff-msvideo', + 'avs' => 'video/avs-video', + 'bcpio' => 'application/x-bcpio', + 'bin' => 'application/mac-binary', + 'bm' => 'image/bmp', + 'bmp' => 'image/bmp', + 'boo' => 'application/book', + 'book' => 'application/book', + 'boz' => 'application/x-bzip2', + 'bsh' => 'application/x-bsh', + 'bz' => 'application/x-bzip', + 'bz2' => 'application/x-bzip2', + 'c' => 'text/plain', + 'c++' => 'text/plain', + 'cat' => 'application/vnd.ms-pki.seccat', + 'cc' => 'text/plain', + 'ccad' => 'application/clariscad', + 'cco' => 'application/x-cocoa', + 'cdf' => 'application/cdf', + 'cer' => 'application/pkix-cert', + 'cha' => 'application/x-chat', + 'chat' => 'application/x-chat', + 'class' => 'application/java', + 'com' => 'application/octet-stream', + 'conf' => 'text/plain', + 'cpio' => 'application/x-cpio', + 'cpp' => 'text/x-c', + 'cpt' => 'application/mac-compactpro', + 'crl' => 'application/pkcs-crl', + 'crt' => 'application/pkix-cert', + 'csh' => 'application/x-csh', + 'css' => 'application/x-pointplus', + 'cxx' => 'text/plain', + 'dcr' => 'application/x-director', + 'deepv' => 'application/x-deepv', + 'def' => 'text/plain', + 'der' => 'application/x-x509-ca-cert', + 'dif' => 'video/x-dv', + 'dir' => 'application/x-director', + 'dl' => 'video/dl', + 'doc' => 'application/msword', + 'dot' => 'application/msword', + 'dp' => 'application/commonground', + 'drw' => 'application/drafting', + 'dump' => 'application/octet-stream', + 'dv' => 'video/x-dv', + 'dvi' => 'application/x-dvi', + 'dwf' => 'drawing/x-dwf (old)', + 'dwg' => 'application/acad', + 'dxf' => 'application/dxf', + 'dxr' => 'application/x-director', + 'el' => 'text/x-script.elisp', + 'elc' => 'application/x-bytecode.elisp (compiled elisp)', + 'env' => 'application/x-envoy', + 'eps' => 'application/postscript', + 'es' => 'application/x-esrehber', + 'etx' => 'text/x-setext', + 'evy' => 'application/envoy', + 'exe' => 'application/octet-stream', + 'f' => 'text/plain', + 'f77' => 'text/x-fortran', + 'f90' => 'text/plain', + 'fdf' => 'application/vnd.fdf', + 'fif' => 'application/fractals', + 'fli' => 'video/fli', + 'flo' => 'image/florian', + 'flx' => 'text/vnd.fmi.flexstor', + 'fmf' => 'video/x-atomic3d-feature', + 'for' => 'text/plain', + 'fpx' => 'image/vnd.fpx', + 'frl' => 'application/freeloader', + 'funk' => 'audio/make', + 'g' => 'text/plain', + 'g3' => 'image/g3fax', + 'gif' => 'image/gif', + 'gl' => 'video/gl', + 'gsd' => 'audio/x-gsm', + 'gsm' => 'audio/x-gsm', + 'gsp' => 'application/x-gsp', + 'gss' => 'application/x-gss', + 'gtar' => 'application/x-gtar', + 'gz' => 'application/x-compressed', + 'gzip' => 'application/x-gzip', + 'h' => 'text/plain', + 'hdf' => 'application/x-hdf', + 'help' => 'application/x-helpfile', + 'hgl' => 'application/vnd.hp-hpgl', + 'hh' => 'text/plain', + 'hlb' => 'text/x-script', + 'hlp' => 'application/hlp', + 'hpg' => 'application/vnd.hp-hpgl', + 'hpgl' => 'application/vnd.hp-hpgl', + 'hqx' => 'application/binhex', + 'hta' => 'application/hta', + 'htc' => 'text/x-component', + 'htm' => 'text/html', + 'html' => 'text/html', + 'htmls' => 'text/html', + 'htt' => 'text/webviewhtml', + 'htx' => 'text/html', + 'ice' => 'x-conference/x-cooltalk', + 'ico' => 'image/x-icon', + 'idc' => 'text/plain', + 'ief' => 'image/ief', + 'iefs' => 'image/ief', + 'iges' => 'application/iges', + 'igs' => 'application/iges', + 'ima' => 'application/x-ima', + 'imap' => 'application/x-httpd-imap', + 'inf' => 'application/inf', + 'ins' => 'application/x-internett-signup', + 'ip' => 'application/x-ip2', + 'isu' => 'video/x-isvideo', + 'it' => 'audio/it', + 'iv' => 'application/x-inventor', + 'ivr' => 'i-world/i-vrml', + 'ivy' => 'application/x-livescreen', + 'jam' => 'audio/x-jam', + 'jav' => 'text/plain', + 'java' => 'text/plain', + 'jcm' => 'application/x-java-commerce', + 'jfif' => 'image/jpeg', + 'jfif-tbnl' => 'image/jpeg', + 'jpe' => 'image/jpeg', + 'jpeg' => 'image/jpeg', + 'jpg' => 'image/jpeg', + 'jps' => 'image/x-jps', + 'js' => 'application/x-javascript', + 'jut' => 'image/jutvision', + 'kar' => 'audio/midi', + 'ksh' => 'application/x-ksh', + 'la' => 'audio/nspaudio', + 'lam' => 'audio/x-liveaudio', + 'latex' => 'application/x-latex', + 'lha' => 'application/lha', + 'lhx' => 'application/octet-stream', + 'list' => 'text/plain', + 'lma' => 'audio/nspaudio', + 'log' => 'text/plain', + 'lsp' => 'application/x-lisp', + 'lst' => 'text/plain', + 'lsx' => 'text/x-la-asf', + 'ltx' => 'application/x-latex', + 'lzh' => 'application/octet-stream', + 'lzx' => 'application/lzx', + 'm' => 'text/plain', + 'm1v' => 'video/mpeg', + 'm2a' => 'audio/mpeg', + 'm2v' => 'video/mpeg', + 'm3u' => 'audio/x-mpequrl', + 'man' => 'application/x-troff-man', + 'map' => 'application/x-navimap', + 'mar' => 'text/plain', + 'mbd' => 'application/mbedlet', + 'mc$' => 'application/x-magic-cap-package-1.0', + 'mcd' => 'application/mcad', + 'mcf' => 'image/vasa', + 'mcp' => 'application/netmc', + 'me' => 'application/x-troff-me', + 'mht' => 'message/rfc822', + 'mhtml' => 'message/rfc822', + 'mid' => 'application/x-midi', + 'midi' => 'application/x-midi', + 'mif' => 'application/x-frame', + 'mime' => 'message/rfc822', + 'mjf' => 'audio/x-vnd.audioexplosion.mjuicemediafile', + 'mjpg' => 'video/x-motion-jpeg', + 'mm' => 'application/base64', + 'mme' => 'application/base64', + 'mod' => 'audio/mod', + 'moov' => 'video/quicktime', + 'mov' => 'video/quicktime', + 'movie' => 'video/x-sgi-movie', + 'mp2' => 'audio/mpeg', + 'mp3' => 'audio/mpeg3', + 'mpa' => 'audio/mpeg', + 'mpc' => 'application/x-project', + 'mpe' => 'video/mpeg', + 'mpeg' => 'video/mpeg', + 'mpg' => 'audio/mpeg', + 'mpga' => 'audio/mpeg', + 'mpp' => 'application/vnd.ms-project', + 'mpt' => 'application/x-project', + 'mpv' => 'application/x-project', + 'mpx' => 'application/x-project', + 'mrc' => 'application/marc', + 'ms' => 'application/x-troff-ms', + 'mv' => 'video/x-sgi-movie', + 'my' => 'audio/make', + 'mzz' => 'application/x-vnd.audioexplosion.mzz', + 'nap' => 'image/naplps', + 'naplps' => 'image/naplps', + 'nc' => 'application/x-netcdf', + 'ncm' => 'application/vnd.nokia.configuration-message', + 'nif' => 'image/x-niff', + 'niff' => 'image/x-niff', + 'nix' => 'application/x-mix-transfer', + 'nsc' => 'application/x-conference', + 'nvd' => 'application/x-navidoc', + 'o' => 'application/octet-stream', + 'oda' => 'application/oda', + 'omc' => 'application/x-omc', + 'omcd' => 'application/x-omcdatamaker', + 'omcr' => 'application/x-omcregerator', + 'p' => 'text/x-pascal', + 'p10' => 'application/pkcs10', + 'p12' => 'application/pkcs-12', + 'p7a' => 'application/x-pkcs7-signature', + 'p7c' => 'application/pkcs7-mime', + 'p7m' => 'application/pkcs7-mime', + 'p7r' => 'application/x-pkcs7-certreqresp', + 'p7s' => 'application/pkcs7-signature', + 'part' => 'application/pro_eng', + 'pas' => 'text/pascal', + 'pbm' => 'image/x-portable-bitmap', + 'pcl' => 'application/vnd.hp-pcl', + 'pct' => 'image/x-pict', + 'pcx' => 'image/x-pcx', + 'pdb' => 'chemical/x-pdb', + 'pdf' => 'application/pdf', + 'pfunk' => 'audio/make', + 'pgm' => 'image/x-portable-graymap', + 'pic' => 'image/pict', + 'pict' => 'image/pict', + 'pkg' => 'application/x-newton-compatible-pkg', + 'pko' => 'application/vnd.ms-pki.pko', + 'pl' => 'text/plain', + 'plx' => 'application/x-pixclscript', + 'pm' => 'image/x-xpixmap', + 'pm4' => 'application/x-pagemaker', + 'pm5' => 'application/x-pagemaker', + 'png' => 'image/png', + 'pnm' => 'application/x-portable-anymap', + 'pot' => 'application/mspowerpoint', + 'pov' => 'model/x-pov', + 'ppa' => 'application/vnd.ms-powerpoint', + 'ppm' => 'image/x-portable-pixmap', + 'pps' => 'application/mspowerpoint', + 'ppt' => 'application/mspowerpoint', + 'ppz' => 'application/mspowerpoint', + 'pre' => 'application/x-freelance', + 'prt' => 'application/pro_eng', + 'ps' => 'application/postscript', + 'psd' => 'application/octet-stream', + 'pvu' => 'paleovu/x-pv', + 'pwz' => 'application/vnd.ms-powerpoint', + 'py' => 'text/x-script.phyton', + 'pyc' => 'applicaiton/x-bytecode.python', + 'qcp' => 'audio/vnd.qcelp', + 'qd3' => 'x-world/x-3dmf', + 'qd3d' => 'x-world/x-3dmf', + 'qif' => 'image/x-quicktime', + 'qt' => 'video/quicktime', + 'qtc' => 'video/x-qtc', + 'qti' => 'image/x-quicktime', + 'qtif' => 'image/x-quicktime', + 'ra' => 'audio/x-pn-realaudio', + 'ram' => 'audio/x-pn-realaudio', + 'ras' => 'application/x-cmu-raster', + 'rast' => 'image/cmu-raster', + 'rexx' => 'text/x-script.rexx', + 'rf' => 'image/vnd.rn-realflash', + 'rgb' => 'image/x-rgb', + 'rm' => 'application/vnd.rn-realmedia', + 'rmi' => 'audio/mid', + 'rmm' => 'audio/x-pn-realaudio', + 'rmp' => 'audio/x-pn-realaudio', + 'rng' => 'application/ringing-tones', + 'rnx' => 'application/vnd.rn-realplayer', + 'roff' => 'application/x-troff', + 'rp' => 'image/vnd.rn-realpix', + 'rpm' => 'audio/x-pn-realaudio-plugin', + 'rt' => 'text/richtext', + 'rtf' => 'application/rtf', + 'rtx' => 'application/rtf', + 'rv' => 'video/vnd.rn-realvideo', + 's' => 'text/x-asm', + 's3m' => 'audio/s3m', + 'saveme' => 'application/octet-stream', + 'sbk' => 'application/x-tbook', + 'scm' => 'application/x-lotusscreencam', + 'sdml' => 'text/plain', + 'sdp' => 'application/sdp', + 'sdr' => 'application/sounder', + 'sea' => 'application/sea', + 'set' => 'application/set', + 'sgm' => 'text/sgml', + 'sgml' => 'text/sgml', + 'sh' => 'application/x-bsh', + 'shar' => 'application/x-bsh', + 'shtml' => 'text/html', + 'sid' => 'audio/x-psid', + 'sit' => 'application/x-sit', + 'skd' => 'application/x-koan', + 'skm' => 'application/x-koan', + 'skp' => 'application/x-koan', + 'skt' => 'application/x-koan', + 'sl' => 'application/x-seelogo', + 'smi' => 'application/smil', + 'smil' => 'application/smil', + 'snd' => 'audio/basic', + 'sol' => 'application/solids', + 'spc' => 'application/x-pkcs7-certificates', + 'spl' => 'application/futuresplash', + 'spr' => 'application/x-sprite', + 'sprite' => 'application/x-sprite', + 'src' => 'application/x-wais-source', + 'ssi' => 'text/x-server-parsed-html', + 'ssm' => 'application/streamingmedia', + 'sst' => 'application/vnd.ms-pki.certstore', + 'step' => 'application/step', + 'stl' => 'application/sla', + 'stp' => 'application/step', + 'sv4cpio' => 'application/x-sv4cpio', + 'sv4crc' => 'application/x-sv4crc', + 'svf' => 'image/vnd.dwg', + 'svr' => 'application/x-world', + 'swf' => 'application/x-shockwave-flash', + 't' => 'application/x-troff', + 'talk' => 'text/x-speech', + 'tar' => 'application/x-tar', + 'tbk' => 'application/toolbook', + 'tcl' => 'application/x-tcl', + 'tcsh' => 'text/x-script.tcsh', + 'tex' => 'application/x-tex', + 'texi' => 'application/x-texinfo', + 'texinfo' => 'application/x-texinfo', + 'text' => 'application/plain', + 'tgz' => 'application/gnutar', + 'tif' => 'image/tiff', + 'tiff' => 'image/tiff', + 'tr' => 'application/x-troff', + 'tsi' => 'audio/tsp-audio', + 'tsp' => 'application/dsptype', + 'tsv' => 'text/tab-separated-values', + 'turbot' => 'image/florian', + 'txt' => 'text/plain', + 'uil' => 'text/x-uil', + 'uni' => 'text/uri-list', + 'unis' => 'text/uri-list', + 'unv' => 'application/i-deas', + 'uri' => 'text/uri-list', + 'uris' => 'text/uri-list', + 'ustar' => 'application/x-ustar', + 'uu' => 'application/octet-stream', + 'uue' => 'text/x-uuencode', + 'vcd' => 'application/x-cdlink', + 'vcs' => 'text/x-vcalendar', + 'vda' => 'application/vda', + 'vdo' => 'video/vdo', + 'vew' => 'application/groupwise', + 'viv' => 'video/vivo', + 'vivo' => 'video/vivo', + 'vmd' => 'application/vocaltec-media-desc', + 'vmf' => 'application/vocaltec-media-file', + 'voc' => 'audio/voc', + 'vos' => 'video/vosaic', + 'vox' => 'audio/voxware', + 'vqe' => 'audio/x-twinvq-plugin', + 'vqf' => 'audio/x-twinvq', + 'vql' => 'audio/x-twinvq-plugin', + 'vrml' => 'application/x-vrml', + 'vrt' => 'x-world/x-vrt', + 'vsd' => 'application/x-visio', + 'vst' => 'application/x-visio', + 'vsw' => 'application/x-visio', + 'w60' => 'application/wordperfect6.0', + 'w61' => 'application/wordperfect6.1', + 'w6w' => 'application/msword', + 'wav' => 'audio/wav', + 'wb1' => 'application/x-qpro', + 'wbmp' => 'image/vnd.wap.wbmp', + 'web' => 'application/vnd.xara', + 'wiz' => 'application/msword', + 'wk1' => 'application/x-123', + 'wmf' => 'windows/metafile', + 'wml' => 'text/vnd.wap.wml', + 'wmlc' => 'application/vnd.wap.wmlc', + 'wmls' => 'text/vnd.wap.wmlscript', + 'wmlsc' => 'application/vnd.wap.wmlscriptc', + 'word' => 'application/msword', + 'wp' => 'application/wordperfect', + 'wp5' => 'application/wordperfect', + 'wp6' => 'application/wordperfect', + 'wpd' => 'application/wordperfect', + 'wq1' => 'application/x-lotus', + 'wri' => 'application/mswrite', + 'wrl' => 'application/x-world', + 'wrz' => 'model/vrml', + 'wsc' => 'text/scriplet', + 'wsrc' => 'application/x-wais-source', + 'wtk' => 'application/x-wintalk', + 'xbm' => 'image/x-xbitmap', + 'xdr' => 'video/x-amt-demorun', + 'xgz' => 'xgl/drawing', + 'xif' => 'image/vnd.xiff', + 'xl' => 'application/excel', + 'xla' => 'application/excel', + 'xlb' => 'application/excel', + 'xlc' => 'application/excel', + 'xld' => 'application/excel', + 'xlk' => 'application/excel', + 'xll' => 'application/excel', + 'xlm' => 'application/excel', + 'xls' => 'application/excel', + 'xlt' => 'application/excel', + 'xlv' => 'application/excel', + 'xlw' => 'application/excel', + 'xm' => 'audio/xm', + 'xml' => 'application/xml', + 'xmz' => 'xgl/movie', + 'xpix' => 'application/x-vnd.ls-xpix', + 'xpm' => 'image/x-xpixmap', + 'x-png' => 'image/png', + 'xsr' => 'video/x-amt-showrun', + 'xwd' => 'image/x-xwd', + 'xyz' => 'chemical/x-pdb', + 'z' => 'application/x-compress', + 'zip' => 'application/x-compressed', + 'zoo' => 'application/octet-stream', + 'zsh' => 'text/x-script.zsh', + ); + + /** + * @const mime_magic_file + */ + const mime_magic_file = 'phpbb/mimetype/fixture/magic.mgc'; + + /** + * Construct a content_guesser object + * + * @param string $phpbb_root_path phpBB root path + * @param \phpbb\php\ini $php_ini + */ + public function __construct($phpbb_root_path, \phpbb\php\ini $php_ini) + { + $this->phpbb_root_path = $phpbb_root_path; + $this->php_ini = $php_ini; + } + + /** + * + */ + public function is_supported() + { + return true; + } + + /** + * Guess mimetype of supplied file + * + * @param string $file Path to file + * + * @return string Guess for mimetype of file + */ + public function guess($file) + { + $mimetype = null; + if (function_exists('mime_content_type')) + { + $mimetype = mime_content_type($file); + } + else + { + $mimetype = $this->map_extension_to_type($file); + } + return $mimetype; + } + + protected function map_extension_to_type($file) + { + $extension = pathinfo($file, PATHINFO_EXTENSION); + + if (isset($this->extension_map[$extension])) + { + return $this->extension_map[$extension]; + } + else + { + return null; + } + } +} -- cgit v1.2.1 From 4af6270d0fb90a918841d63186497888ffb92bbb Mon Sep 17 00:00:00 2001 From: Marc Alexander Date: Thu, 24 Oct 2013 11:28:49 +0200 Subject: [ticket/11912] Improve extension map in content_guesser PHPBB3-11912 --- phpBB/phpbb/mimetype/content_guesser.php | 181 ++++++++++++++++--------------- 1 file changed, 91 insertions(+), 90 deletions(-) (limited to 'phpBB/phpbb') diff --git a/phpBB/phpbb/mimetype/content_guesser.php b/phpBB/phpbb/mimetype/content_guesser.php index 4eeac75499..e6554666fc 100644 --- a/phpBB/phpbb/mimetype/content_guesser.php +++ b/phpBB/phpbb/mimetype/content_guesser.php @@ -61,12 +61,12 @@ class content_guesser 'asf' => 'video/x-ms-asf', 'asm' => 'text/x-asm', 'asp' => 'text/asp', - 'asx' => 'application/x-mplayer2', - 'au' => 'audio/basic', - 'avi' => 'application/x-troff-msvideo', + 'asx' => 'video/x-ms-asf', + 'au' => 'audio/x-au', + 'avi' => 'video/avi', 'avs' => 'video/avs-video', 'bcpio' => 'application/x-bcpio', - 'bin' => 'application/mac-binary', + 'bin' => 'application/x-binary', 'bm' => 'image/bmp', 'bmp' => 'image/bmp', 'boo' => 'application/book', @@ -75,14 +75,14 @@ class content_guesser 'bsh' => 'application/x-bsh', 'bz' => 'application/x-bzip', 'bz2' => 'application/x-bzip2', - 'c' => 'text/plain', - 'c++' => 'text/plain', + 'c' => 'text/x-c', + 'c++' => 'text/x-c', 'cat' => 'application/vnd.ms-pki.seccat', 'cc' => 'text/plain', 'ccad' => 'application/clariscad', 'cco' => 'application/x-cocoa', 'cdf' => 'application/cdf', - 'cer' => 'application/pkix-cert', + 'cer' => 'application/x-x509-ca-cert', 'cha' => 'application/x-chat', 'chat' => 'application/x-chat', 'class' => 'application/java', @@ -90,11 +90,11 @@ class content_guesser 'conf' => 'text/plain', 'cpio' => 'application/x-cpio', 'cpp' => 'text/x-c', - 'cpt' => 'application/mac-compactpro', - 'crl' => 'application/pkcs-crl', - 'crt' => 'application/pkix-cert', + 'cpt' => 'application/x-cpt', + 'crl' => 'application/pkix-crl', + 'crt' => 'application/x-x509-ca-cert', 'csh' => 'application/x-csh', - 'css' => 'application/x-pointplus', + 'css' => 'text/css', 'cxx' => 'text/plain', 'dcr' => 'application/x-director', 'deepv' => 'application/x-deepv', @@ -110,52 +110,52 @@ class content_guesser 'dump' => 'application/octet-stream', 'dv' => 'video/x-dv', 'dvi' => 'application/x-dvi', - 'dwf' => 'drawing/x-dwf (old)', - 'dwg' => 'application/acad', - 'dxf' => 'application/dxf', + 'dwf' => 'model/vnd.dwf', + 'dwg' => 'image/x-dwg', + 'dxf' => 'image/x-dwg', 'dxr' => 'application/x-director', 'el' => 'text/x-script.elisp', - 'elc' => 'application/x-bytecode.elisp (compiled elisp)', + 'elc' => 'application/x-elc', 'env' => 'application/x-envoy', 'eps' => 'application/postscript', 'es' => 'application/x-esrehber', 'etx' => 'text/x-setext', - 'evy' => 'application/envoy', + 'evy' => 'application/x-envoy', 'exe' => 'application/octet-stream', - 'f' => 'text/plain', + 'f' => 'text/x-fortran', 'f77' => 'text/x-fortran', - 'f90' => 'text/plain', + 'f90' => 'text/x-fortran', 'fdf' => 'application/vnd.fdf', - 'fif' => 'application/fractals', - 'fli' => 'video/fli', + 'fif' => 'image/fif', + 'fli' => 'video/x-fli', 'flo' => 'image/florian', 'flx' => 'text/vnd.fmi.flexstor', 'fmf' => 'video/x-atomic3d-feature', - 'for' => 'text/plain', + 'for' => 'text/x-fortran', 'fpx' => 'image/vnd.fpx', 'frl' => 'application/freeloader', 'funk' => 'audio/make', 'g' => 'text/plain', 'g3' => 'image/g3fax', 'gif' => 'image/gif', - 'gl' => 'video/gl', + 'gl' => 'video/x-gl', 'gsd' => 'audio/x-gsm', 'gsm' => 'audio/x-gsm', 'gsp' => 'application/x-gsp', 'gss' => 'application/x-gss', 'gtar' => 'application/x-gtar', - 'gz' => 'application/x-compressed', + 'gz' => 'application/x-gzip', 'gzip' => 'application/x-gzip', - 'h' => 'text/plain', + 'h' => 'text/x-h', 'hdf' => 'application/x-hdf', 'help' => 'application/x-helpfile', 'hgl' => 'application/vnd.hp-hpgl', - 'hh' => 'text/plain', + 'hh' => 'text/x-h', 'hlb' => 'text/x-script', 'hlp' => 'application/hlp', 'hpg' => 'application/vnd.hp-hpgl', 'hpgl' => 'application/vnd.hp-hpgl', - 'hqx' => 'application/binhex', + 'hqx' => 'application/x-binhex40', 'hta' => 'application/hta', 'htc' => 'text/x-component', 'htm' => 'text/html', @@ -182,7 +182,8 @@ class content_guesser 'ivy' => 'application/x-livescreen', 'jam' => 'audio/x-jam', 'jav' => 'text/plain', - 'java' => 'text/plain', + 'jav' => 'text/x-java-source', + 'java' => 'text/x-java-source', 'jcm' => 'application/x-java-commerce', 'jfif' => 'image/jpeg', 'jfif-tbnl' => 'image/jpeg', @@ -193,22 +194,22 @@ class content_guesser 'js' => 'application/x-javascript', 'jut' => 'image/jutvision', 'kar' => 'audio/midi', - 'ksh' => 'application/x-ksh', - 'la' => 'audio/nspaudio', + 'ksh' => 'text/x-script.ksh', + 'la' => 'audio/x-nspaudio', 'lam' => 'audio/x-liveaudio', 'latex' => 'application/x-latex', - 'lha' => 'application/lha', + 'lha' => 'application/x-lha', 'lhx' => 'application/octet-stream', 'list' => 'text/plain', - 'lma' => 'audio/nspaudio', + 'lma' => 'audio/x-nspaudio', 'log' => 'text/plain', - 'lsp' => 'application/x-lisp', + 'lsp' => 'text/x-script.lisp', 'lst' => 'text/plain', 'lsx' => 'text/x-la-asf', 'ltx' => 'application/x-latex', - 'lzh' => 'application/octet-stream', - 'lzx' => 'application/lzx', - 'm' => 'text/plain', + 'lzh' => 'application/x-lzh', + 'lzx' => 'application/x-lzx', + 'm' => 'text/x-m', 'm1v' => 'video/mpeg', 'm2a' => 'audio/mpeg', 'm2v' => 'video/mpeg', @@ -218,31 +219,31 @@ class content_guesser 'mar' => 'text/plain', 'mbd' => 'application/mbedlet', 'mc$' => 'application/x-magic-cap-package-1.0', - 'mcd' => 'application/mcad', - 'mcf' => 'image/vasa', + 'mcd' => 'application/x-mathcad', + 'mcf' => 'text/mcf', 'mcp' => 'application/netmc', 'me' => 'application/x-troff-me', 'mht' => 'message/rfc822', 'mhtml' => 'message/rfc822', - 'mid' => 'application/x-midi', - 'midi' => 'application/x-midi', - 'mif' => 'application/x-frame', - 'mime' => 'message/rfc822', + 'mid' => 'audio/x-midi', + 'midi' => 'audio/x-midi', + 'mif' => 'application/x-mif', + 'mime' => 'www/mime', 'mjf' => 'audio/x-vnd.audioexplosion.mjuicemediafile', 'mjpg' => 'video/x-motion-jpeg', - 'mm' => 'application/base64', + 'mm' => 'application/x-meme', 'mme' => 'application/base64', - 'mod' => 'audio/mod', + 'mod' => 'audio/x-mod', 'moov' => 'video/quicktime', 'mov' => 'video/quicktime', 'movie' => 'video/x-sgi-movie', - 'mp2' => 'audio/mpeg', - 'mp3' => 'audio/mpeg3', + 'mp2' => 'audio/x-mpeg', + 'mp3' => 'audio/x-mpeg-3', 'mpa' => 'audio/mpeg', 'mpc' => 'application/x-project', 'mpe' => 'video/mpeg', 'mpeg' => 'video/mpeg', - 'mpg' => 'audio/mpeg', + 'mpg' => 'video/mpeg', 'mpga' => 'audio/mpeg', 'mpp' => 'application/vnd.ms-project', 'mpt' => 'application/x-project', @@ -268,34 +269,34 @@ class content_guesser 'omcd' => 'application/x-omcdatamaker', 'omcr' => 'application/x-omcregerator', 'p' => 'text/x-pascal', - 'p10' => 'application/pkcs10', - 'p12' => 'application/pkcs-12', + 'p10' => 'application/x-pkcs10', + 'p12' => 'application/x-pkcs12', 'p7a' => 'application/x-pkcs7-signature', - 'p7c' => 'application/pkcs7-mime', - 'p7m' => 'application/pkcs7-mime', + 'p7c' => 'application/x-pkcs7-mime', + 'p7m' => 'application/x-pkcs7-mime', 'p7r' => 'application/x-pkcs7-certreqresp', 'p7s' => 'application/pkcs7-signature', 'part' => 'application/pro_eng', 'pas' => 'text/pascal', 'pbm' => 'image/x-portable-bitmap', - 'pcl' => 'application/vnd.hp-pcl', + 'pcl' => 'application/x-pcl', 'pct' => 'image/x-pict', 'pcx' => 'image/x-pcx', 'pdb' => 'chemical/x-pdb', 'pdf' => 'application/pdf', - 'pfunk' => 'audio/make', - 'pgm' => 'image/x-portable-graymap', + 'pfunk' => 'audio/make.my.funk', + 'pgm' => 'image/x-portable-greymap', 'pic' => 'image/pict', 'pict' => 'image/pict', 'pkg' => 'application/x-newton-compatible-pkg', 'pko' => 'application/vnd.ms-pki.pko', - 'pl' => 'text/plain', + 'pl' => 'text/x-script.perl', 'plx' => 'application/x-pixclscript', - 'pm' => 'image/x-xpixmap', + 'pm' => 'text/x-script.perl-module', 'pm4' => 'application/x-pagemaker', 'pm5' => 'application/x-pagemaker', 'png' => 'image/png', - 'pnm' => 'application/x-portable-anymap', + 'pnm' => 'image/x-portable-anymap', 'pot' => 'application/mspowerpoint', 'pov' => 'model/x-pov', 'ppa' => 'application/vnd.ms-powerpoint', @@ -319,43 +320,43 @@ class content_guesser 'qtc' => 'video/x-qtc', 'qti' => 'image/x-quicktime', 'qtif' => 'image/x-quicktime', - 'ra' => 'audio/x-pn-realaudio', + 'ra' => 'audio/x-realaudio', 'ram' => 'audio/x-pn-realaudio', - 'ras' => 'application/x-cmu-raster', + 'ras' => 'image/x-cmu-raster', 'rast' => 'image/cmu-raster', 'rexx' => 'text/x-script.rexx', 'rf' => 'image/vnd.rn-realflash', 'rgb' => 'image/x-rgb', - 'rm' => 'application/vnd.rn-realmedia', + 'rm' => 'audio/x-pn-realaudio', 'rmi' => 'audio/mid', 'rmm' => 'audio/x-pn-realaudio', 'rmp' => 'audio/x-pn-realaudio', - 'rng' => 'application/ringing-tones', + 'rng' => 'application/vnd.nokia.ringing-tone', 'rnx' => 'application/vnd.rn-realplayer', 'roff' => 'application/x-troff', 'rp' => 'image/vnd.rn-realpix', 'rpm' => 'audio/x-pn-realaudio-plugin', 'rt' => 'text/richtext', - 'rtf' => 'application/rtf', - 'rtx' => 'application/rtf', + 'rtf' => 'text/richtext', + 'rtx' => 'text/richtext', 'rv' => 'video/vnd.rn-realvideo', 's' => 'text/x-asm', 's3m' => 'audio/s3m', 'saveme' => 'application/octet-stream', 'sbk' => 'application/x-tbook', - 'scm' => 'application/x-lotusscreencam', + 'scm' => 'video/x-scm', 'sdml' => 'text/plain', - 'sdp' => 'application/sdp', + 'sdp' => 'application/x-sdp', 'sdr' => 'application/sounder', - 'sea' => 'application/sea', + 'sea' => 'application/x-sea', 'set' => 'application/set', - 'sgm' => 'text/sgml', - 'sgml' => 'text/sgml', - 'sh' => 'application/x-bsh', - 'shar' => 'application/x-bsh', - 'shtml' => 'text/html', + 'sgm' => 'text/x-sgml', + 'sgml' => 'text/x-sgml', + 'sh' => 'text/x-script.sh', + 'shar' => 'application/x-shar', + 'shtml' => 'text/x-server-parsed-html', 'sid' => 'audio/x-psid', - 'sit' => 'application/x-sit', + 'sit' => 'application/x-stuffit', 'skd' => 'application/x-koan', 'skm' => 'application/x-koan', 'skp' => 'application/x-koan', @@ -363,9 +364,9 @@ class content_guesser 'sl' => 'application/x-seelogo', 'smi' => 'application/smil', 'smil' => 'application/smil', - 'snd' => 'audio/basic', + 'snd' => 'audio/x-adpcm', 'sol' => 'application/solids', - 'spc' => 'application/x-pkcs7-certificates', + 'spc' => 'text/x-speech', 'spl' => 'application/futuresplash', 'spr' => 'application/x-sprite', 'sprite' => 'application/x-sprite', @@ -374,29 +375,29 @@ class content_guesser 'ssm' => 'application/streamingmedia', 'sst' => 'application/vnd.ms-pki.certstore', 'step' => 'application/step', - 'stl' => 'application/sla', + 'stl' => 'application/vnd.ms-pki.stl', 'stp' => 'application/step', 'sv4cpio' => 'application/x-sv4cpio', 'sv4crc' => 'application/x-sv4crc', - 'svf' => 'image/vnd.dwg', + 'svf' => 'image/x-dwg', 'svr' => 'application/x-world', 'swf' => 'application/x-shockwave-flash', 't' => 'application/x-troff', 'talk' => 'text/x-speech', 'tar' => 'application/x-tar', - 'tbk' => 'application/toolbook', - 'tcl' => 'application/x-tcl', + 'tbk' => 'application/x-tbook', + 'tcl' => 'text/x-script.tcl', 'tcsh' => 'text/x-script.tcsh', 'tex' => 'application/x-tex', 'texi' => 'application/x-texinfo', 'texinfo' => 'application/x-texinfo', - 'text' => 'application/plain', - 'tgz' => 'application/gnutar', + 'text' => 'text/plain', + 'tgz' => 'application/x-compressed', 'tif' => 'image/tiff', 'tiff' => 'image/tiff', 'tr' => 'application/x-troff', 'tsi' => 'audio/tsp-audio', - 'tsp' => 'application/dsptype', + 'tsp' => 'audio/tsplayer', 'tsv' => 'text/tab-separated-values', 'turbot' => 'image/florian', 'txt' => 'text/plain', @@ -406,8 +407,8 @@ class content_guesser 'unv' => 'application/i-deas', 'uri' => 'text/uri-list', 'uris' => 'text/uri-list', - 'ustar' => 'application/x-ustar', - 'uu' => 'application/octet-stream', + 'ustar' => 'multipart/x-ustar', + 'uu' => 'text/x-uuencode', 'uue' => 'text/x-uuencode', 'vcd' => 'application/x-cdlink', 'vcs' => 'text/x-vcalendar', @@ -450,18 +451,18 @@ class content_guesser 'wpd' => 'application/wordperfect', 'wq1' => 'application/x-lotus', 'wri' => 'application/mswrite', - 'wrl' => 'application/x-world', + 'wrl' => 'model/vrml', 'wrz' => 'model/vrml', 'wsc' => 'text/scriplet', 'wsrc' => 'application/x-wais-source', 'wtk' => 'application/x-wintalk', - 'xbm' => 'image/x-xbitmap', + 'xbm' => 'image/xbm', 'xdr' => 'video/x-amt-demorun', 'xgz' => 'xgl/drawing', 'xif' => 'image/vnd.xiff', 'xl' => 'application/excel', 'xla' => 'application/excel', - 'xlb' => 'application/excel', + 'xlb' => 'application/excel',, 'xlc' => 'application/excel', 'xld' => 'application/excel', 'xlk' => 'application/excel', @@ -472,16 +473,16 @@ class content_guesser 'xlv' => 'application/excel', 'xlw' => 'application/excel', 'xm' => 'audio/xm', - 'xml' => 'application/xml', + 'xml' => 'text/xml', 'xmz' => 'xgl/movie', 'xpix' => 'application/x-vnd.ls-xpix', - 'xpm' => 'image/x-xpixmap', + 'xpm' => 'image/xpm', 'x-png' => 'image/png', 'xsr' => 'video/x-amt-showrun', - 'xwd' => 'image/x-xwd', + 'xwd' => 'image/x-xwindowdump', 'xyz' => 'chemical/x-pdb', - 'z' => 'application/x-compress', - 'zip' => 'application/x-compressed', + 'z' => 'application/x-compressed', + 'zip' => 'application/x-zip-compressed', 'zoo' => 'application/octet-stream', 'zsh' => 'text/x-script.zsh', ); -- cgit v1.2.1 From 973682cb2ddba8022622bdccc870925ea6a7237c Mon Sep 17 00:00:00 2001 From: Marc Alexander Date: Thu, 24 Oct 2013 12:02:40 +0200 Subject: =?UTF-8?q?[=C5=A7icket/11912]=20Get=20rid=20of=20obsolete=20varia?= =?UTF-8?q?bles=20in=20content=5Fguesser?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit PHPBB3-11912 --- phpBB/phpbb/mimetype/content_guesser.php | 29 +---------------------------- 1 file changed, 1 insertion(+), 28 deletions(-) (limited to 'phpBB/phpbb') diff --git a/phpBB/phpbb/mimetype/content_guesser.php b/phpBB/phpbb/mimetype/content_guesser.php index e6554666fc..65c4703e2a 100644 --- a/phpBB/phpbb/mimetype/content_guesser.php +++ b/phpBB/phpbb/mimetype/content_guesser.php @@ -23,16 +23,6 @@ if (!defined('IN_PHPBB')) class content_guesser { - /** - * @var phpbb_root_path - */ - protected $phpbb_root_path; - - /** - * @var \phpbb\php\ini - */ - protected $php_ini; - /** * @var file extension map */ @@ -488,24 +478,7 @@ class content_guesser ); /** - * @const mime_magic_file - */ - const mime_magic_file = 'phpbb/mimetype/fixture/magic.mgc'; - - /** - * Construct a content_guesser object - * - * @param string $phpbb_root_path phpBB root path - * @param \phpbb\php\ini $php_ini - */ - public function __construct($phpbb_root_path, \phpbb\php\ini $php_ini) - { - $this->phpbb_root_path = $phpbb_root_path; - $this->php_ini = $php_ini; - } - - /** - * + * @inheritdoc */ public function is_supported() { -- cgit v1.2.1 From 24099583a32608c2350bdb10d018d6c8a0551e6c Mon Sep 17 00:00:00 2001 From: Marc Alexander Date: Thu, 24 Oct 2013 12:03:46 +0200 Subject: [ticket/11912] Remove typo in content_guesser PHPBB3-11912 --- phpBB/phpbb/mimetype/content_guesser.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'phpBB/phpbb') diff --git a/phpBB/phpbb/mimetype/content_guesser.php b/phpBB/phpbb/mimetype/content_guesser.php index 65c4703e2a..6bdd410af4 100644 --- a/phpBB/phpbb/mimetype/content_guesser.php +++ b/phpBB/phpbb/mimetype/content_guesser.php @@ -452,7 +452,7 @@ class content_guesser 'xif' => 'image/vnd.xiff', 'xl' => 'application/excel', 'xla' => 'application/excel', - 'xlb' => 'application/excel',, + 'xlb' => 'application/excel', 'xlc' => 'application/excel', 'xld' => 'application/excel', 'xlk' => 'application/excel', -- cgit v1.2.1 From bc7ff47537bae4f6db9de781cf8ba3487e28a30b Mon Sep 17 00:00:00 2001 From: Marc Alexander Date: Thu, 24 Oct 2013 12:05:00 +0200 Subject: [ticket/11912] Supply filename to content_guesser for guessing on windows The filename of the files sent to the guesser by plupload do not contain the file extension. Therefore, it's impossible to guess the mimetype if only the content_guesser is available and the function mime_content_type() doesn't exist. By supplying the filename we can circumvent this issue. PHPBB3-11912 --- phpBB/phpbb/mimetype/content_guesser.php | 16 ++++++++++++---- phpBB/phpbb/mimetype/guesser.php | 4 ++-- phpBB/phpbb/plupload/plupload.php | 2 +- 3 files changed, 15 insertions(+), 7 deletions(-) (limited to 'phpBB/phpbb') diff --git a/phpBB/phpbb/mimetype/content_guesser.php b/phpBB/phpbb/mimetype/content_guesser.php index 6bdd410af4..6326bf73fa 100644 --- a/phpBB/phpbb/mimetype/content_guesser.php +++ b/phpBB/phpbb/mimetype/content_guesser.php @@ -492,7 +492,7 @@ class content_guesser * * @return string Guess for mimetype of file */ - public function guess($file) + public function guess($file, $file_name = '') { $mimetype = null; if (function_exists('mime_content_type')) @@ -501,14 +501,22 @@ class content_guesser } else { - $mimetype = $this->map_extension_to_type($file); + $file_name = (empty($file_name)) ? $file : $file_name; + $mimetype = $this->map_extension_to_type($file_name); } return $mimetype; } - protected function map_extension_to_type($file) + /** + * Map extension of supplied file_name to mime type + * + * @param string $file_name Path to file or filename + * + * @return string|null Mimetype if known or null if not + */ + protected function map_extension_to_type($file_name) { - $extension = pathinfo($file, PATHINFO_EXTENSION); + $extension = pathinfo($file_name, PATHINFO_EXTENSION); if (isset($this->extension_map[$extension])) { diff --git a/phpBB/phpbb/mimetype/guesser.php b/phpBB/phpbb/mimetype/guesser.php index 5ae094cd63..231b75f604 100644 --- a/phpBB/phpbb/mimetype/guesser.php +++ b/phpBB/phpbb/mimetype/guesser.php @@ -77,7 +77,7 @@ class guesser * * @return string Guess for mimetype of file */ - public function guess($file) + public function guess($file, $file_name = '') { if (!is_file($file)) { @@ -91,7 +91,7 @@ class guesser foreach ($this->guessers as $guesser) { - $mimetype = $guesser->guess($file); + $mimetype = $guesser->guess($file, $file_name); // Try to guess something that is not the fallback application/octet-stream if ($mimetype !== null && $mimetype !== 'application/octet-stream') diff --git a/phpBB/phpbb/plupload/plupload.php b/phpBB/phpbb/plupload/plupload.php index 29a4aff39b..dedc3cbcd4 100644 --- a/phpBB/phpbb/plupload/plupload.php +++ b/phpBB/phpbb/plupload/plupload.php @@ -135,7 +135,7 @@ class plupload 'tmp_name' => $file_path, 'name' => $this->request->variable('real_filename', ''), 'size' => filesize($file_path), - 'type' => $this->mimetype_guesser->guess($file_path), + 'type' => $this->mimetype_guesser->guess($file_path, $file_name), ); } else -- cgit v1.2.1 From d25ab02ef34c5e20deb278e4379a6a3a365a93a0 Mon Sep 17 00:00:00 2001 From: Marc Alexander Date: Thu, 24 Oct 2013 12:07:26 +0200 Subject: [ticket/11912] Introduce guesser_interface This will contain proper documentation of the required methods if anyone would implement a newer guesser. PHPBB3-11912 --- phpBB/phpbb/mimetype/content_guesser.php | 8 ++---- phpBB/phpbb/mimetype/guesser_interface.php | 41 ++++++++++++++++++++++++++++++ 2 files changed, 43 insertions(+), 6 deletions(-) create mode 100644 phpBB/phpbb/mimetype/guesser_interface.php (limited to 'phpBB/phpbb') diff --git a/phpBB/phpbb/mimetype/content_guesser.php b/phpBB/phpbb/mimetype/content_guesser.php index 6326bf73fa..f5be9cd44b 100644 --- a/phpBB/phpbb/mimetype/content_guesser.php +++ b/phpBB/phpbb/mimetype/content_guesser.php @@ -21,7 +21,7 @@ if (!defined('IN_PHPBB')) * @package mimetype */ -class content_guesser +class content_guesser implements guesser_interface { /** * @var file extension map @@ -486,11 +486,7 @@ class content_guesser } /** - * Guess mimetype of supplied file - * - * @param string $file Path to file - * - * @return string Guess for mimetype of file + * @inheritdoc */ public function guess($file, $file_name = '') { diff --git a/phpBB/phpbb/mimetype/guesser_interface.php b/phpBB/phpbb/mimetype/guesser_interface.php new file mode 100644 index 0000000000..a9b238d7aa --- /dev/null +++ b/phpBB/phpbb/mimetype/guesser_interface.php @@ -0,0 +1,41 @@ + Date: Thu, 24 Oct 2013 13:55:23 +0200 Subject: [ticket/11525] Only remove group or user prefix from given avatar data Until now, the user data had both user_id and group_id keys in the avatar data. As both group_ and user_ prefixes were removed the group_id was collapsed onto the user_id and therefore all users in the same group had the same prefix for their uploaded avatars. This patch will make sure that the correct id is used depending on whether it's a group's or user's avatar data. PHPBB3-11525 --- phpBB/phpbb/avatar/manager.php | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) (limited to 'phpBB/phpbb') diff --git a/phpBB/phpbb/avatar/manager.php b/phpBB/phpbb/avatar/manager.php index c28380a401..f2bb1a5dbe 100644 --- a/phpBB/phpbb/avatar/manager.php +++ b/phpBB/phpbb/avatar/manager.php @@ -178,14 +178,15 @@ class manager } /** - * Strip out user_ and group_ prefixes from keys + * Strip out user_, group_, or other prefixes from array keys * * @param array $row User data or group data + * @param string $prefix Prefix of data keys * * @return array User data or group data with keys that have been * stripped from the preceding "user_" or "group_" */ - static public function clean_row($row) + static public function clean_row($row, $prefix = '') { // Upon creation of a user/group $row might be empty if (empty($row)) @@ -196,7 +197,7 @@ class manager $keys = array_keys($row); $values = array_values($row); - $keys = array_map(array('\phpbb\avatar\manager', 'strip_prefix'), $keys); + array_walk($keys, array('\phpbb\avatar\manager', 'strip_prefix'), $prefix); return array_combine($keys, $values); } @@ -205,11 +206,12 @@ class manager * Strip prepending user_ or group_ prefix from key * * @param string Array key - * @return string Key that has been stripped from its prefix + * @return void */ - static protected function strip_prefix($key) + static protected function strip_prefix(&$key, $null, $prefix) { - return preg_replace('#^(?:user_|group_)#', '', $key); + $regex = ($prefix !== '') ? "#^(?:{$prefix}_)#" : '#^(?:user_|group_)#'; + $key = preg_replace($regex, '', $key); } /** -- cgit v1.2.1 From 743a0560c3cced8c37b5ae840e449a60a0b51a33 Mon Sep 17 00:00:00 2001 From: Andreas Fischer Date: Sun, 3 Nov 2013 04:14:36 +0100 Subject: [ticket/11998] Add console command for recalculating email hash. PHPBB3-11998 --- .../command/fixup/recalculate_email_hash.php | 72 ++++++++++++++++++++++ 1 file changed, 72 insertions(+) create mode 100644 phpBB/phpbb/console/command/fixup/recalculate_email_hash.php (limited to 'phpBB/phpbb') diff --git a/phpBB/phpbb/console/command/fixup/recalculate_email_hash.php b/phpBB/phpbb/console/command/fixup/recalculate_email_hash.php new file mode 100644 index 0000000000..b788fe5631 --- /dev/null +++ b/phpBB/phpbb/console/command/fixup/recalculate_email_hash.php @@ -0,0 +1,72 @@ +db = $db; + + parent::__construct(); + } + + protected function configure() + { + $this + ->setName('fixup:recalculate-email-hash') + ->setDescription('Recalculates the user_email_hash column of the users table.') + ; + } + + protected function execute(InputInterface $input, OutputInterface $output) + { + $sql = 'SELECT user_id, user_email, user_email_hash + FROM ' . USERS_TABLE . ' + WHERE user_type <> ' . USER_IGNORE . " + AND user_email <> ''"; + $result = $this->db->sql_query($sql); + + while ($row = $this->db->sql_fetchrow($result)) + { + $user_email_hash = phpbb_email_hash($row['user_email']); + if ($user_email_hash !== $row['user_email_hash']) + { + $sql_ary = array( + 'user_email_hash' => $user_email_hash, + ); + + $sql = 'UPDATE ' . USERS_TABLE . ' + SET ' . $this->db->sql_build_array('UPDATE', $sql_ary) . ' + WHERE user_id = ' . (int) $row['user_id']; + $this->db->sql_query($sql); + + if ($output->getVerbosity() >= OutputInterface::VERBOSITY_DEBUG) + { + $output->writeln(sprintf( + 'user_id %d, email %s => %s', + $row['user_id'], + $row['user_email'], + $user_email_hash + )); + } + } + } + $this->db->sql_freeresult($result); + + $output->writeln('Successfully recalculated all email hashes.'); + } +} -- cgit v1.2.1 From b49d3a1851330d64009c8050132e50b093172559 Mon Sep 17 00:00:00 2001 From: Nathan Guse Date: Mon, 4 Nov 2013 12:21:12 -0600 Subject: [ticket/11943] Do not quote the value when it is exactly true, false, or null Quoting these can change the meaning of the value (e.g. 'false' == true) PHPBB3-11943 --- phpBB/phpbb/template/twig/lexer.php | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'phpBB/phpbb') diff --git a/phpBB/phpbb/template/twig/lexer.php b/phpBB/phpbb/template/twig/lexer.php index be53b3eb5b..8c52fa65b2 100644 --- a/phpBB/phpbb/template/twig/lexer.php +++ b/phpBB/phpbb/template/twig/lexer.php @@ -129,6 +129,14 @@ class lexer extends \Twig_Lexer // Replace template variables with start/end to parse variables (' ~ TEST ~ '.html) $matches[2] = preg_replace('#{([a-zA-Z0-9_\.$]+)}#', "'~ \$1 ~'", $matches[2]); + // If the second item is exactly one of a few key words, + // do not quote it as it changes the meaning + // http://tracker.phpbb.com/browse/PHPBB3-11943 + if (in_array($matches[2], array('false', 'true', 'null'))) + { + return ""; + } + // Surround the matches in single quotes ('' ~ TEST ~ '.html') return ""; }; -- cgit v1.2.1 From 73ea5daf97bf5447b9bb2ff912cce4a9ea21c58e Mon Sep 17 00:00:00 2001 From: Andreas Fischer Date: Tue, 5 Nov 2013 19:42:34 +0100 Subject: [ticket/11998] Add phpBB abstraction for application and command. PHPBB3-11998 --- phpBB/phpbb/console/application.php | 23 ++++++++++++++++++++++ phpBB/phpbb/console/command/command.php | 14 +++++++++++++ .../command/fixup/recalculate_email_hash.php | 3 +-- 3 files changed, 38 insertions(+), 2 deletions(-) create mode 100644 phpBB/phpbb/console/application.php create mode 100644 phpBB/phpbb/console/command/command.php (limited to 'phpBB/phpbb') diff --git a/phpBB/phpbb/console/application.php b/phpBB/phpbb/console/application.php new file mode 100644 index 0000000000..fdcd9d42f6 --- /dev/null +++ b/phpBB/phpbb/console/application.php @@ -0,0 +1,23 @@ +findTaggedServiceIds($tag) as $id => $void) + { + $this->add($container->get($id)); + } + } +} diff --git a/phpBB/phpbb/console/command/command.php b/phpBB/phpbb/console/command/command.php new file mode 100644 index 0000000000..6abbdd203c --- /dev/null +++ b/phpBB/phpbb/console/command/command.php @@ -0,0 +1,14 @@ + Date: Tue, 5 Nov 2013 21:40:42 +0100 Subject: [ticket/11998] Turn develop/extensions.php into console commands. PHPBB3-11998 --- phpBB/phpbb/console/command/extension/command.php | 22 +++++++++ phpBB/phpbb/console/command/extension/disable.php | 47 ++++++++++++++++++ phpBB/phpbb/console/command/extension/enable.php | 47 ++++++++++++++++++ phpBB/phpbb/console/command/extension/purge.php | 47 ++++++++++++++++++ phpBB/phpbb/console/command/extension/show.php | 58 +++++++++++++++++++++++ 5 files changed, 221 insertions(+) create mode 100644 phpBB/phpbb/console/command/extension/command.php create mode 100644 phpBB/phpbb/console/command/extension/disable.php create mode 100644 phpBB/phpbb/console/command/extension/enable.php create mode 100644 phpBB/phpbb/console/command/extension/purge.php create mode 100644 phpBB/phpbb/console/command/extension/show.php (limited to 'phpBB/phpbb') diff --git a/phpBB/phpbb/console/command/extension/command.php b/phpBB/phpbb/console/command/extension/command.php new file mode 100644 index 0000000000..edde7ce2e2 --- /dev/null +++ b/phpBB/phpbb/console/command/extension/command.php @@ -0,0 +1,22 @@ +manager = $manager; + + parent::__construct(); + } +} diff --git a/phpBB/phpbb/console/command/extension/disable.php b/phpBB/phpbb/console/command/extension/disable.php new file mode 100644 index 0000000000..e4de70ca34 --- /dev/null +++ b/phpBB/phpbb/console/command/extension/disable.php @@ -0,0 +1,47 @@ +setName('extension:disable') + ->setDescription('Disables the specified extension.') + ->addArgument( + 'extension-name', + InputArgument::REQUIRED, + 'Name of the extension' + ) + ; + } + + protected function execute(InputInterface $input, OutputInterface $output) + { + $name = $input->getArgument('extension-name'); + $this->manager->disable($name); + $this->manager->load_extensions(); + + if ($this->manager->enabled($name)) + { + $output->writeln("Could not disable extension $name"); + return 1; + } + else + { + $output->writeln("Successfully disabled extension $name"); + return 0; + } + } +} diff --git a/phpBB/phpbb/console/command/extension/enable.php b/phpBB/phpbb/console/command/extension/enable.php new file mode 100644 index 0000000000..ee7dae76aa --- /dev/null +++ b/phpBB/phpbb/console/command/extension/enable.php @@ -0,0 +1,47 @@ +setName('extension:enable') + ->setDescription('Enables the specified extension.') + ->addArgument( + 'extension-name', + InputArgument::REQUIRED, + 'Name of the extension' + ) + ; + } + + protected function execute(InputInterface $input, OutputInterface $output) + { + $name = $input->getArgument('extension-name'); + $this->manager->enable($name); + $this->manager->load_extensions(); + + if ($this->manager->enabled($name)) + { + $output->writeln("Successfully enabled extension $name"); + return 0; + } + else + { + $output->writeln("Could not enable extension $name"); + return 1; + } + } +} diff --git a/phpBB/phpbb/console/command/extension/purge.php b/phpBB/phpbb/console/command/extension/purge.php new file mode 100644 index 0000000000..c2e1d2928c --- /dev/null +++ b/phpBB/phpbb/console/command/extension/purge.php @@ -0,0 +1,47 @@ +setName('extension:purge') + ->setDescription('Purges the specified extension.') + ->addArgument( + 'extension-name', + InputArgument::REQUIRED, + 'Name of the extension' + ) + ; + } + + protected function execute(InputInterface $input, OutputInterface $output) + { + $name = $input->getArgument('extension-name'); + $this->manager->purge($name); + $this->manager->load_extensions(); + + if ($this->manager->enabled($name)) + { + $output->writeln("Could not purge extension $name"); + return 1; + } + else + { + $output->writeln("Successfully purge extension $name"); + return 0; + } + } +} diff --git a/phpBB/phpbb/console/command/extension/show.php b/phpBB/phpbb/console/command/extension/show.php new file mode 100644 index 0000000000..0f48ac2379 --- /dev/null +++ b/phpBB/phpbb/console/command/extension/show.php @@ -0,0 +1,58 @@ +setName('extension:show') + ->setDescription('Lists all extensions in the database and on the filesystem.') + ; + } + + protected function execute(InputInterface $input, OutputInterface $output) + { + $this->manager->load_extensions(); + $all = array_keys($this->manager->all_available()); + + if (empty($all)) + { + $output->writeln('No extensions were found.'); + return 3; + } + + $enabled = array_keys($this->manager->all_enabled()); + $this->print_extension_list($output, 'Enabled', $enabled); + + $output->writeln(''); + + $disabled = array_keys($this->manager->all_disabled()); + $this->print_extension_list($output, 'Disabled', $disabled); + + $output->writeln(''); + + $purged = array_diff($all, $enabled, $disabled); + $this->print_extension_list($output, 'Available', $purged); + } + + protected function print_extension_list(OutputInterface $output, $type, array $extensions) + { + $output->writeln("$type:"); + + foreach ($extensions as $extension) + { + $output->writeln(" - $extension"); + } + } +} -- cgit v1.2.1 From 6f33954757a05044c8700a70051ae25e3a5cc627 Mon Sep 17 00:00:00 2001 From: Joas Schilling Date: Fri, 8 Nov 2013 17:37:52 +0100 Subject: [ticket/11922] Drop all keys before trying to delete columns to avoid issues On MSSQL columns that have an index can not be dropped. PHPBB3-11922 --- phpBB/phpbb/db/migration/data/v310/softdelete_p2.php | 6 +++++- phpBB/phpbb/db/migration/data/v310/style_update_p2.php | 16 ++++++++++++++++ 2 files changed, 21 insertions(+), 1 deletion(-) (limited to 'phpBB/phpbb') diff --git a/phpBB/phpbb/db/migration/data/v310/softdelete_p2.php b/phpBB/phpbb/db/migration/data/v310/softdelete_p2.php index 0c32e474f4..38b190c766 100644 --- a/phpBB/phpbb/db/migration/data/v310/softdelete_p2.php +++ b/phpBB/phpbb/db/migration/data/v310/softdelete_p2.php @@ -34,7 +34,10 @@ class softdelete_p2 extends \phpbb\db\migration\migration ), 'drop_keys' => array( $this->table_prefix . 'posts' => array('post_approved'), - $this->table_prefix . 'topics' => array('forum_appr_last'), + $this->table_prefix . 'topics' => array( + 'forum_appr_last', + 'topic_approved', + ), ), ); } @@ -63,6 +66,7 @@ class softdelete_p2 extends \phpbb\db\migration\migration ), $this->table_prefix . 'topics' => array( 'forum_appr_last' => array('forum_id', 'topic_approved', 'topic_last_post_id'), + 'topic_approved' => array('topic_approved'), ), ), ); diff --git a/phpBB/phpbb/db/migration/data/v310/style_update_p2.php b/phpBB/phpbb/db/migration/data/v310/style_update_p2.php index c5b45d9dc9..40d6a4dbbd 100644 --- a/phpBB/phpbb/db/migration/data/v310/style_update_p2.php +++ b/phpBB/phpbb/db/migration/data/v310/style_update_p2.php @@ -24,6 +24,14 @@ class style_update_p2 extends \phpbb\db\migration\migration public function update_schema() { return array( + 'drop_keys' => array( + $this->table_prefix . 'styles' => array( + 'imageset_id', + 'template_id', + 'theme_id', + ), + ), + 'drop_columns' => array( $this->table_prefix . 'styles' => array( 'imageset_id', @@ -53,6 +61,14 @@ class style_update_p2 extends \phpbb\db\migration\migration ), ), + 'add_index' => array( + $this->table_prefix . 'styles' => array( + 'imageset_id' => array('imageset_id'), + 'template_id' => array('template_id'), + 'theme_id' => array('theme_id'), + ), + ), + 'add_tables' => array( $this->table_prefix . 'styles_imageset' => array( 'COLUMNS' => array( -- cgit v1.2.1 From 1173adfe87f4622cbf3bfb53393166616c04b25f Mon Sep 17 00:00:00 2001 From: Dhruv Date: Fri, 8 Nov 2013 23:34:49 +0530 Subject: [ticket/12007] Default last_result to 0 instead of false PostgreSQL does not map null/false to 0 and thus this variable causes an error. PHPBB3-12007 --- phpBB/phpbb/db/migrator.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'phpBB/phpbb') diff --git a/phpBB/phpbb/db/migrator.php b/phpBB/phpbb/db/migrator.php index 3b966b7fe3..8186493800 100644 --- a/phpBB/phpbb/db/migrator.php +++ b/phpBB/phpbb/db/migrator.php @@ -375,7 +375,7 @@ class migrator foreach ($steps as $step_identifier => $step) { - $last_result = false; + $last_result = 0; if ($state) { // Continue until we reach the step that matches the last step called @@ -436,7 +436,7 @@ class migrator * @param bool $reverse False to install, True to attempt uninstallation by reversing the call * @return null */ - protected function run_step($step, $last_result = false, $reverse = false) + protected function run_step($step, $last_result = 0, $reverse = false) { $callable_and_parameters = $this->get_callable_from_step($step, $last_result, $reverse); @@ -459,7 +459,7 @@ class migrator * @param bool $reverse False to install, True to attempt uninstallation by reversing the call * @return array Array with parameters for call_user_func_array(), 0 is the callable, 1 is parameters */ - protected function get_callable_from_step(array $step, $last_result = false, $reverse = false) + protected function get_callable_from_step(array $step, $last_result = 0, $reverse = false) { $type = $step[0]; $parameters = $step[1]; -- cgit v1.2.1 From 65fbf87ce717b50b5d14babbd264a64640f5c7b6 Mon Sep 17 00:00:00 2001 From: Lukasz Date: Thu, 7 Nov 2013 19:53:54 +0100 Subject: [ticket/12005] Remove PM popup PHPBB3-12005 --- phpBB/phpbb/user.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'phpBB/phpbb') diff --git a/phpBB/phpbb/user.php b/phpBB/phpbb/user.php index ce0dc3c1df..b2ab187a70 100644 --- a/phpBB/phpbb/user.php +++ b/phpBB/phpbb/user.php @@ -36,7 +36,7 @@ class user extends \phpbb\session var $img_array = array(); // Able to add new options (up to id 31) - var $keyoptions = array('viewimg' => 0, 'viewflash' => 1, 'viewsmilies' => 2, 'viewsigs' => 3, 'viewavatars' => 4, 'viewcensors' => 5, 'attachsig' => 6, 'bbcode' => 8, 'smilies' => 9, 'popuppm' => 10, 'sig_bbcode' => 15, 'sig_smilies' => 16, 'sig_links' => 17); + var $keyoptions = array('viewimg' => 0, 'viewflash' => 1, 'viewsmilies' => 2, 'viewsigs' => 3, 'viewavatars' => 4, 'viewcensors' => 5, 'attachsig' => 6, 'bbcode' => 8, 'smilies' => 9, 'sig_bbcode' => 15, 'sig_smilies' => 16, 'sig_links' => 17); /** * Constructor to set the lang path -- cgit v1.2.1 From a353673e7c3e5a5a4720bea008e1df60c1401ae2 Mon Sep 17 00:00:00 2001 From: Lukasz Date: Thu, 7 Nov 2013 22:06:48 +0100 Subject: [ticket/12005] Remove PM popup module from DB PHPBB3-12005 --- .../db/migration/data/v310/ucp_popuppm_module.php | 42 ++++++++++++++++++++++ 1 file changed, 42 insertions(+) create mode 100644 phpBB/phpbb/db/migration/data/v310/ucp_popuppm_module.php (limited to 'phpBB/phpbb') diff --git a/phpBB/phpbb/db/migration/data/v310/ucp_popuppm_module.php b/phpBB/phpbb/db/migration/data/v310/ucp_popuppm_module.php new file mode 100644 index 0000000000..f8ada6c6f5 --- /dev/null +++ b/phpBB/phpbb/db/migration/data/v310/ucp_popuppm_module.php @@ -0,0 +1,42 @@ +db->sql_query($sql); + $module_id = $this->db->sql_fetchfield('module_id'); + $this->db->sql_freeresult($result); + + return $module_id == false; + } + + static public function depends_on() + { + return array('\phpbb\db\migration\data\v310\dev'); + } + + public function update_data() + { + return array( + array('module.remove', array( + 'ucp', + 'UCP_PM', + 'UCP_PM_POPUP_TITLE', + )), + ); + } +} -- cgit v1.2.1 From da332aa0a5cbeabbcce5551ee955c701fc2a1d73 Mon Sep 17 00:00:00 2001 From: Nathan Guse Date: Fri, 8 Nov 2013 19:55:16 -0600 Subject: [ticket/11943] Require stricter DEFINE statements for templates PHPBB3-11943 --- phpBB/phpbb/template/twig/lexer.php | 10 +--------- 1 file changed, 1 insertion(+), 9 deletions(-) (limited to 'phpBB/phpbb') diff --git a/phpBB/phpbb/template/twig/lexer.php b/phpBB/phpbb/template/twig/lexer.php index 8c52fa65b2..efd6a0bd84 100644 --- a/phpBB/phpbb/template/twig/lexer.php +++ b/phpBB/phpbb/template/twig/lexer.php @@ -69,7 +69,7 @@ class lexer extends \Twig_Lexer // Fix tokens that may have inline variables (e.g. "; - } - // Surround the matches in single quotes ('' ~ TEST ~ '.html') return ""; }; -- cgit v1.2.1 From 6370970f13d58f617379da64efb1f88a522f3f03 Mon Sep 17 00:00:00 2001 From: Nathan Guse Date: Fri, 8 Nov 2013 22:30:58 -0600 Subject: [ticket/11943] Split fix_inline_variable_tokens into 3 steps DEFINE shouldn't add/remove surrounding quotes, but must have the inline variable tokens fixed PHPBB3-11943 --- phpBB/phpbb/template/twig/lexer.php | 60 ++++++++++++++++++++++++++++++------- 1 file changed, 50 insertions(+), 10 deletions(-) (limited to 'phpBB/phpbb') diff --git a/phpBB/phpbb/template/twig/lexer.php b/phpBB/phpbb/template/twig/lexer.php index efd6a0bd84..f4efc58540 100644 --- a/phpBB/phpbb/template/twig/lexer.php +++ b/phpBB/phpbb/template/twig/lexer.php @@ -68,8 +68,20 @@ class lexer extends \Twig_Lexer ); // Fix tokens that may have inline variables (e.g. #', '', $code); + } + /** * Fix tokens that may have inline variables * - * E.g. "; + return ""; }; return preg_replace_callback('##', $callback, $code); } + /** + * Add surrounding quotes + * + * Last step to fix tokens that may have inline variables + * E.g. #', '', $code); + } + /** * Fix begin tokens (convert our BEGIN to Twig for) * -- cgit v1.2.1 From 31e60f0c8d5e248bbf318cec410b27cff6dbee74 Mon Sep 17 00:00:00 2001 From: Joas Schilling Date: Sat, 9 Nov 2013 17:06:38 +0100 Subject: [ticket/11949] Do not prepend leading backslash to cache class name The container seems to prepend the leading \ itself, so we get an InvalidArgumentException with message '"'\\phpbb\\cache\\driver\\file'" is not a valid class name for the "cache.driver" service.' PHPBB3-11949 --- phpBB/phpbb/di/extension/config.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'phpBB/phpbb') diff --git a/phpBB/phpbb/di/extension/config.php b/phpBB/phpbb/di/extension/config.php index 5fcb2d6f10..2603e7b358 100644 --- a/phpBB/phpbb/di/extension/config.php +++ b/phpBB/phpbb/di/extension/config.php @@ -70,7 +70,7 @@ class config extends Extension { if (preg_match('#^[a-z]+$#', $acm_type)) { - return '\\phpbb\cache\driver\\'.$acm_type; + return 'phpbb\\cache\\driver\\' . $acm_type; } return $acm_type; -- cgit v1.2.1 From 2e5117a71eb64c734e5738235c44ef92818ca33b Mon Sep 17 00:00:00 2001 From: Nathan Guse Date: Sat, 9 Nov 2013 11:14:55 -0600 Subject: [ticket/11943] Throw an exception if DEFINE is setup improperly PHPBB3-11943 --- phpBB/phpbb/template/twig/tokenparser/defineparser.php | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'phpBB/phpbb') diff --git a/phpBB/phpbb/template/twig/tokenparser/defineparser.php b/phpBB/phpbb/template/twig/tokenparser/defineparser.php index 21add0c17c..8484f2e81a 100644 --- a/phpBB/phpbb/template/twig/tokenparser/defineparser.php +++ b/phpBB/phpbb/template/twig/tokenparser/defineparser.php @@ -30,6 +30,13 @@ class defineparser extends \Twig_TokenParser $stream->next(); $value = $this->parser->getExpressionParser()->parseExpression(); + if ($value instanceof \Twig_Node_Expression_Name) + { + // This would happen if someone improperly formed their DEFINE syntax + // e.g. + throw new \Twig_Error_Syntax('Invalid DEFINE', $token->getLine(), $this->parser->getFilename()); + } + $stream->expect(\Twig_Token::BLOCK_END_TYPE); } else { $capture = true; -- cgit v1.2.1 From 47f2caff6b3f05f6703e359bf4712bd69d23c04c Mon Sep 17 00:00:00 2001 From: Joas Schilling Date: Sun, 10 Nov 2013 22:19:06 +0100 Subject: [ticket/11525] Fix doc blocks PHPBB3-11525 --- phpBB/phpbb/avatar/manager.php | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) (limited to 'phpBB/phpbb') diff --git a/phpBB/phpbb/avatar/manager.php b/phpBB/phpbb/avatar/manager.php index f2bb1a5dbe..90cd83898f 100644 --- a/phpBB/phpbb/avatar/manager.php +++ b/phpBB/phpbb/avatar/manager.php @@ -180,8 +180,8 @@ class manager /** * Strip out user_, group_, or other prefixes from array keys * - * @param array $row User data or group data - * @param string $prefix Prefix of data keys + * @param array $row User data or group data + * @param string $prefix Prefix of data keys (e.g. user), should not include the trailing underscore * * @return array User data or group data with keys that have been * stripped from the preceding "user_" or "group_" @@ -205,8 +205,11 @@ class manager /** * Strip prepending user_ or group_ prefix from key * - * @param string Array key - * @return void + * @param string $key Array key + * @param string $null Parameter is ignored by the function, just required by the array_walk + * @param string $prefix Prefix that should be stripped off from the keys (e.g. user) + * Should not include the trailing underscore + * @return null */ static protected function strip_prefix(&$key, $null, $prefix) { -- cgit v1.2.1 From aa84f7de04b0efdf871d75694aee60e5ecf37f56 Mon Sep 17 00:00:00 2001 From: Joas Schilling Date: Sun, 10 Nov 2013 23:07:07 +0100 Subject: [ticket/11525] Prefix id parameter with 'g' again when its a group avatar PHPBB3-11525 --- phpBB/phpbb/avatar/manager.php | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) (limited to 'phpBB/phpbb') diff --git a/phpBB/phpbb/avatar/manager.php b/phpBB/phpbb/avatar/manager.php index 90cd83898f..9f6a5fb089 100644 --- a/phpBB/phpbb/avatar/manager.php +++ b/phpBB/phpbb/avatar/manager.php @@ -183,8 +183,9 @@ class manager * @param array $row User data or group data * @param string $prefix Prefix of data keys (e.g. user), should not include the trailing underscore * - * @return array User data or group data with keys that have been - * stripped from the preceding "user_" or "group_" + * @return array User or group data with keys that have been + * stripped from the preceding "user_" or "group_" + * Also the group id is prefixed with g, when the prefix group is removed. */ static public function clean_row($row, $prefix = '') { @@ -198,8 +199,14 @@ class manager $values = array_values($row); array_walk($keys, array('\phpbb\avatar\manager', 'strip_prefix'), $prefix); + $row = array_combine($keys, $values); - return array_combine($keys, $values); + if ($prefix == 'group') + { + $row['id'] = 'g' . $row['id']; + } + + return $row; } /** -- cgit v1.2.1 From b1719db47df4f3089f90bbfac2ca0bec24dcf027 Mon Sep 17 00:00:00 2001 From: Marc Alexander Date: Mon, 11 Nov 2013 20:15:28 +0100 Subject: [ticket/11912] Add extension_guesser for guessing mimetype by extension The content_guesser now only guesses the mimetype with the function mime_content_type() while the guessing by extension is done using the extension_guesser. PHPBB3-11912 --- phpBB/phpbb/mimetype/content_guesser.php | 481 +-------------------------- phpBB/phpbb/mimetype/extension_guesser.php | 517 +++++++++++++++++++++++++++++ 2 files changed, 518 insertions(+), 480 deletions(-) create mode 100644 phpBB/phpbb/mimetype/extension_guesser.php (limited to 'phpBB/phpbb') diff --git a/phpBB/phpbb/mimetype/content_guesser.php b/phpBB/phpbb/mimetype/content_guesser.php index f5be9cd44b..21631ae6d3 100644 --- a/phpBB/phpbb/mimetype/content_guesser.php +++ b/phpBB/phpbb/mimetype/content_guesser.php @@ -23,460 +23,6 @@ if (!defined('IN_PHPBB')) class content_guesser implements guesser_interface { - /** - * @var file extension map - */ - protected $extension_map = array( - '3dm' => 'x-world/x-3dmf', - '3dmf' => 'x-world/x-3dmf', - 'a' => 'application/octet-stream', - 'aab' => 'application/x-authorware-bin', - 'aam' => 'application/x-authorware-map', - 'aas' => 'application/x-authorware-seg', - 'abc' => 'text/vnd.abc', - 'acgi' => 'text/html', - 'afl' => 'video/animaflex', - 'ai' => 'application/postscript', - 'aif' => 'audio/aiff', - 'aifc' => 'audio/aiff', - 'aiff' => 'audio/aiff', - 'aim' => 'application/x-aim', - 'aip' => 'text/x-audiosoft-intra', - 'ani' => 'application/x-navi-animation', - 'aos' => 'application/x-nokia-9000-communicator-add-on-software', - 'aps' => 'application/mime', - 'arc' => 'application/octet-stream', - 'arj' => 'application/arj', - 'art' => 'image/x-jg', - 'asf' => 'video/x-ms-asf', - 'asm' => 'text/x-asm', - 'asp' => 'text/asp', - 'asx' => 'video/x-ms-asf', - 'au' => 'audio/x-au', - 'avi' => 'video/avi', - 'avs' => 'video/avs-video', - 'bcpio' => 'application/x-bcpio', - 'bin' => 'application/x-binary', - 'bm' => 'image/bmp', - 'bmp' => 'image/bmp', - 'boo' => 'application/book', - 'book' => 'application/book', - 'boz' => 'application/x-bzip2', - 'bsh' => 'application/x-bsh', - 'bz' => 'application/x-bzip', - 'bz2' => 'application/x-bzip2', - 'c' => 'text/x-c', - 'c++' => 'text/x-c', - 'cat' => 'application/vnd.ms-pki.seccat', - 'cc' => 'text/plain', - 'ccad' => 'application/clariscad', - 'cco' => 'application/x-cocoa', - 'cdf' => 'application/cdf', - 'cer' => 'application/x-x509-ca-cert', - 'cha' => 'application/x-chat', - 'chat' => 'application/x-chat', - 'class' => 'application/java', - 'com' => 'application/octet-stream', - 'conf' => 'text/plain', - 'cpio' => 'application/x-cpio', - 'cpp' => 'text/x-c', - 'cpt' => 'application/x-cpt', - 'crl' => 'application/pkix-crl', - 'crt' => 'application/x-x509-ca-cert', - 'csh' => 'application/x-csh', - 'css' => 'text/css', - 'cxx' => 'text/plain', - 'dcr' => 'application/x-director', - 'deepv' => 'application/x-deepv', - 'def' => 'text/plain', - 'der' => 'application/x-x509-ca-cert', - 'dif' => 'video/x-dv', - 'dir' => 'application/x-director', - 'dl' => 'video/dl', - 'doc' => 'application/msword', - 'dot' => 'application/msword', - 'dp' => 'application/commonground', - 'drw' => 'application/drafting', - 'dump' => 'application/octet-stream', - 'dv' => 'video/x-dv', - 'dvi' => 'application/x-dvi', - 'dwf' => 'model/vnd.dwf', - 'dwg' => 'image/x-dwg', - 'dxf' => 'image/x-dwg', - 'dxr' => 'application/x-director', - 'el' => 'text/x-script.elisp', - 'elc' => 'application/x-elc', - 'env' => 'application/x-envoy', - 'eps' => 'application/postscript', - 'es' => 'application/x-esrehber', - 'etx' => 'text/x-setext', - 'evy' => 'application/x-envoy', - 'exe' => 'application/octet-stream', - 'f' => 'text/x-fortran', - 'f77' => 'text/x-fortran', - 'f90' => 'text/x-fortran', - 'fdf' => 'application/vnd.fdf', - 'fif' => 'image/fif', - 'fli' => 'video/x-fli', - 'flo' => 'image/florian', - 'flx' => 'text/vnd.fmi.flexstor', - 'fmf' => 'video/x-atomic3d-feature', - 'for' => 'text/x-fortran', - 'fpx' => 'image/vnd.fpx', - 'frl' => 'application/freeloader', - 'funk' => 'audio/make', - 'g' => 'text/plain', - 'g3' => 'image/g3fax', - 'gif' => 'image/gif', - 'gl' => 'video/x-gl', - 'gsd' => 'audio/x-gsm', - 'gsm' => 'audio/x-gsm', - 'gsp' => 'application/x-gsp', - 'gss' => 'application/x-gss', - 'gtar' => 'application/x-gtar', - 'gz' => 'application/x-gzip', - 'gzip' => 'application/x-gzip', - 'h' => 'text/x-h', - 'hdf' => 'application/x-hdf', - 'help' => 'application/x-helpfile', - 'hgl' => 'application/vnd.hp-hpgl', - 'hh' => 'text/x-h', - 'hlb' => 'text/x-script', - 'hlp' => 'application/hlp', - 'hpg' => 'application/vnd.hp-hpgl', - 'hpgl' => 'application/vnd.hp-hpgl', - 'hqx' => 'application/x-binhex40', - 'hta' => 'application/hta', - 'htc' => 'text/x-component', - 'htm' => 'text/html', - 'html' => 'text/html', - 'htmls' => 'text/html', - 'htt' => 'text/webviewhtml', - 'htx' => 'text/html', - 'ice' => 'x-conference/x-cooltalk', - 'ico' => 'image/x-icon', - 'idc' => 'text/plain', - 'ief' => 'image/ief', - 'iefs' => 'image/ief', - 'iges' => 'application/iges', - 'igs' => 'application/iges', - 'ima' => 'application/x-ima', - 'imap' => 'application/x-httpd-imap', - 'inf' => 'application/inf', - 'ins' => 'application/x-internett-signup', - 'ip' => 'application/x-ip2', - 'isu' => 'video/x-isvideo', - 'it' => 'audio/it', - 'iv' => 'application/x-inventor', - 'ivr' => 'i-world/i-vrml', - 'ivy' => 'application/x-livescreen', - 'jam' => 'audio/x-jam', - 'jav' => 'text/plain', - 'jav' => 'text/x-java-source', - 'java' => 'text/x-java-source', - 'jcm' => 'application/x-java-commerce', - 'jfif' => 'image/jpeg', - 'jfif-tbnl' => 'image/jpeg', - 'jpe' => 'image/jpeg', - 'jpeg' => 'image/jpeg', - 'jpg' => 'image/jpeg', - 'jps' => 'image/x-jps', - 'js' => 'application/x-javascript', - 'jut' => 'image/jutvision', - 'kar' => 'audio/midi', - 'ksh' => 'text/x-script.ksh', - 'la' => 'audio/x-nspaudio', - 'lam' => 'audio/x-liveaudio', - 'latex' => 'application/x-latex', - 'lha' => 'application/x-lha', - 'lhx' => 'application/octet-stream', - 'list' => 'text/plain', - 'lma' => 'audio/x-nspaudio', - 'log' => 'text/plain', - 'lsp' => 'text/x-script.lisp', - 'lst' => 'text/plain', - 'lsx' => 'text/x-la-asf', - 'ltx' => 'application/x-latex', - 'lzh' => 'application/x-lzh', - 'lzx' => 'application/x-lzx', - 'm' => 'text/x-m', - 'm1v' => 'video/mpeg', - 'm2a' => 'audio/mpeg', - 'm2v' => 'video/mpeg', - 'm3u' => 'audio/x-mpequrl', - 'man' => 'application/x-troff-man', - 'map' => 'application/x-navimap', - 'mar' => 'text/plain', - 'mbd' => 'application/mbedlet', - 'mc$' => 'application/x-magic-cap-package-1.0', - 'mcd' => 'application/x-mathcad', - 'mcf' => 'text/mcf', - 'mcp' => 'application/netmc', - 'me' => 'application/x-troff-me', - 'mht' => 'message/rfc822', - 'mhtml' => 'message/rfc822', - 'mid' => 'audio/x-midi', - 'midi' => 'audio/x-midi', - 'mif' => 'application/x-mif', - 'mime' => 'www/mime', - 'mjf' => 'audio/x-vnd.audioexplosion.mjuicemediafile', - 'mjpg' => 'video/x-motion-jpeg', - 'mm' => 'application/x-meme', - 'mme' => 'application/base64', - 'mod' => 'audio/x-mod', - 'moov' => 'video/quicktime', - 'mov' => 'video/quicktime', - 'movie' => 'video/x-sgi-movie', - 'mp2' => 'audio/x-mpeg', - 'mp3' => 'audio/x-mpeg-3', - 'mpa' => 'audio/mpeg', - 'mpc' => 'application/x-project', - 'mpe' => 'video/mpeg', - 'mpeg' => 'video/mpeg', - 'mpg' => 'video/mpeg', - 'mpga' => 'audio/mpeg', - 'mpp' => 'application/vnd.ms-project', - 'mpt' => 'application/x-project', - 'mpv' => 'application/x-project', - 'mpx' => 'application/x-project', - 'mrc' => 'application/marc', - 'ms' => 'application/x-troff-ms', - 'mv' => 'video/x-sgi-movie', - 'my' => 'audio/make', - 'mzz' => 'application/x-vnd.audioexplosion.mzz', - 'nap' => 'image/naplps', - 'naplps' => 'image/naplps', - 'nc' => 'application/x-netcdf', - 'ncm' => 'application/vnd.nokia.configuration-message', - 'nif' => 'image/x-niff', - 'niff' => 'image/x-niff', - 'nix' => 'application/x-mix-transfer', - 'nsc' => 'application/x-conference', - 'nvd' => 'application/x-navidoc', - 'o' => 'application/octet-stream', - 'oda' => 'application/oda', - 'omc' => 'application/x-omc', - 'omcd' => 'application/x-omcdatamaker', - 'omcr' => 'application/x-omcregerator', - 'p' => 'text/x-pascal', - 'p10' => 'application/x-pkcs10', - 'p12' => 'application/x-pkcs12', - 'p7a' => 'application/x-pkcs7-signature', - 'p7c' => 'application/x-pkcs7-mime', - 'p7m' => 'application/x-pkcs7-mime', - 'p7r' => 'application/x-pkcs7-certreqresp', - 'p7s' => 'application/pkcs7-signature', - 'part' => 'application/pro_eng', - 'pas' => 'text/pascal', - 'pbm' => 'image/x-portable-bitmap', - 'pcl' => 'application/x-pcl', - 'pct' => 'image/x-pict', - 'pcx' => 'image/x-pcx', - 'pdb' => 'chemical/x-pdb', - 'pdf' => 'application/pdf', - 'pfunk' => 'audio/make.my.funk', - 'pgm' => 'image/x-portable-greymap', - 'pic' => 'image/pict', - 'pict' => 'image/pict', - 'pkg' => 'application/x-newton-compatible-pkg', - 'pko' => 'application/vnd.ms-pki.pko', - 'pl' => 'text/x-script.perl', - 'plx' => 'application/x-pixclscript', - 'pm' => 'text/x-script.perl-module', - 'pm4' => 'application/x-pagemaker', - 'pm5' => 'application/x-pagemaker', - 'png' => 'image/png', - 'pnm' => 'image/x-portable-anymap', - 'pot' => 'application/mspowerpoint', - 'pov' => 'model/x-pov', - 'ppa' => 'application/vnd.ms-powerpoint', - 'ppm' => 'image/x-portable-pixmap', - 'pps' => 'application/mspowerpoint', - 'ppt' => 'application/mspowerpoint', - 'ppz' => 'application/mspowerpoint', - 'pre' => 'application/x-freelance', - 'prt' => 'application/pro_eng', - 'ps' => 'application/postscript', - 'psd' => 'application/octet-stream', - 'pvu' => 'paleovu/x-pv', - 'pwz' => 'application/vnd.ms-powerpoint', - 'py' => 'text/x-script.phyton', - 'pyc' => 'applicaiton/x-bytecode.python', - 'qcp' => 'audio/vnd.qcelp', - 'qd3' => 'x-world/x-3dmf', - 'qd3d' => 'x-world/x-3dmf', - 'qif' => 'image/x-quicktime', - 'qt' => 'video/quicktime', - 'qtc' => 'video/x-qtc', - 'qti' => 'image/x-quicktime', - 'qtif' => 'image/x-quicktime', - 'ra' => 'audio/x-realaudio', - 'ram' => 'audio/x-pn-realaudio', - 'ras' => 'image/x-cmu-raster', - 'rast' => 'image/cmu-raster', - 'rexx' => 'text/x-script.rexx', - 'rf' => 'image/vnd.rn-realflash', - 'rgb' => 'image/x-rgb', - 'rm' => 'audio/x-pn-realaudio', - 'rmi' => 'audio/mid', - 'rmm' => 'audio/x-pn-realaudio', - 'rmp' => 'audio/x-pn-realaudio', - 'rng' => 'application/vnd.nokia.ringing-tone', - 'rnx' => 'application/vnd.rn-realplayer', - 'roff' => 'application/x-troff', - 'rp' => 'image/vnd.rn-realpix', - 'rpm' => 'audio/x-pn-realaudio-plugin', - 'rt' => 'text/richtext', - 'rtf' => 'text/richtext', - 'rtx' => 'text/richtext', - 'rv' => 'video/vnd.rn-realvideo', - 's' => 'text/x-asm', - 's3m' => 'audio/s3m', - 'saveme' => 'application/octet-stream', - 'sbk' => 'application/x-tbook', - 'scm' => 'video/x-scm', - 'sdml' => 'text/plain', - 'sdp' => 'application/x-sdp', - 'sdr' => 'application/sounder', - 'sea' => 'application/x-sea', - 'set' => 'application/set', - 'sgm' => 'text/x-sgml', - 'sgml' => 'text/x-sgml', - 'sh' => 'text/x-script.sh', - 'shar' => 'application/x-shar', - 'shtml' => 'text/x-server-parsed-html', - 'sid' => 'audio/x-psid', - 'sit' => 'application/x-stuffit', - 'skd' => 'application/x-koan', - 'skm' => 'application/x-koan', - 'skp' => 'application/x-koan', - 'skt' => 'application/x-koan', - 'sl' => 'application/x-seelogo', - 'smi' => 'application/smil', - 'smil' => 'application/smil', - 'snd' => 'audio/x-adpcm', - 'sol' => 'application/solids', - 'spc' => 'text/x-speech', - 'spl' => 'application/futuresplash', - 'spr' => 'application/x-sprite', - 'sprite' => 'application/x-sprite', - 'src' => 'application/x-wais-source', - 'ssi' => 'text/x-server-parsed-html', - 'ssm' => 'application/streamingmedia', - 'sst' => 'application/vnd.ms-pki.certstore', - 'step' => 'application/step', - 'stl' => 'application/vnd.ms-pki.stl', - 'stp' => 'application/step', - 'sv4cpio' => 'application/x-sv4cpio', - 'sv4crc' => 'application/x-sv4crc', - 'svf' => 'image/x-dwg', - 'svr' => 'application/x-world', - 'swf' => 'application/x-shockwave-flash', - 't' => 'application/x-troff', - 'talk' => 'text/x-speech', - 'tar' => 'application/x-tar', - 'tbk' => 'application/x-tbook', - 'tcl' => 'text/x-script.tcl', - 'tcsh' => 'text/x-script.tcsh', - 'tex' => 'application/x-tex', - 'texi' => 'application/x-texinfo', - 'texinfo' => 'application/x-texinfo', - 'text' => 'text/plain', - 'tgz' => 'application/x-compressed', - 'tif' => 'image/tiff', - 'tiff' => 'image/tiff', - 'tr' => 'application/x-troff', - 'tsi' => 'audio/tsp-audio', - 'tsp' => 'audio/tsplayer', - 'tsv' => 'text/tab-separated-values', - 'turbot' => 'image/florian', - 'txt' => 'text/plain', - 'uil' => 'text/x-uil', - 'uni' => 'text/uri-list', - 'unis' => 'text/uri-list', - 'unv' => 'application/i-deas', - 'uri' => 'text/uri-list', - 'uris' => 'text/uri-list', - 'ustar' => 'multipart/x-ustar', - 'uu' => 'text/x-uuencode', - 'uue' => 'text/x-uuencode', - 'vcd' => 'application/x-cdlink', - 'vcs' => 'text/x-vcalendar', - 'vda' => 'application/vda', - 'vdo' => 'video/vdo', - 'vew' => 'application/groupwise', - 'viv' => 'video/vivo', - 'vivo' => 'video/vivo', - 'vmd' => 'application/vocaltec-media-desc', - 'vmf' => 'application/vocaltec-media-file', - 'voc' => 'audio/voc', - 'vos' => 'video/vosaic', - 'vox' => 'audio/voxware', - 'vqe' => 'audio/x-twinvq-plugin', - 'vqf' => 'audio/x-twinvq', - 'vql' => 'audio/x-twinvq-plugin', - 'vrml' => 'application/x-vrml', - 'vrt' => 'x-world/x-vrt', - 'vsd' => 'application/x-visio', - 'vst' => 'application/x-visio', - 'vsw' => 'application/x-visio', - 'w60' => 'application/wordperfect6.0', - 'w61' => 'application/wordperfect6.1', - 'w6w' => 'application/msword', - 'wav' => 'audio/wav', - 'wb1' => 'application/x-qpro', - 'wbmp' => 'image/vnd.wap.wbmp', - 'web' => 'application/vnd.xara', - 'wiz' => 'application/msword', - 'wk1' => 'application/x-123', - 'wmf' => 'windows/metafile', - 'wml' => 'text/vnd.wap.wml', - 'wmlc' => 'application/vnd.wap.wmlc', - 'wmls' => 'text/vnd.wap.wmlscript', - 'wmlsc' => 'application/vnd.wap.wmlscriptc', - 'word' => 'application/msword', - 'wp' => 'application/wordperfect', - 'wp5' => 'application/wordperfect', - 'wp6' => 'application/wordperfect', - 'wpd' => 'application/wordperfect', - 'wq1' => 'application/x-lotus', - 'wri' => 'application/mswrite', - 'wrl' => 'model/vrml', - 'wrz' => 'model/vrml', - 'wsc' => 'text/scriplet', - 'wsrc' => 'application/x-wais-source', - 'wtk' => 'application/x-wintalk', - 'xbm' => 'image/xbm', - 'xdr' => 'video/x-amt-demorun', - 'xgz' => 'xgl/drawing', - 'xif' => 'image/vnd.xiff', - 'xl' => 'application/excel', - 'xla' => 'application/excel', - 'xlb' => 'application/excel', - 'xlc' => 'application/excel', - 'xld' => 'application/excel', - 'xlk' => 'application/excel', - 'xll' => 'application/excel', - 'xlm' => 'application/excel', - 'xls' => 'application/excel', - 'xlt' => 'application/excel', - 'xlv' => 'application/excel', - 'xlw' => 'application/excel', - 'xm' => 'audio/xm', - 'xml' => 'text/xml', - 'xmz' => 'xgl/movie', - 'xpix' => 'application/x-vnd.ls-xpix', - 'xpm' => 'image/xpm', - 'x-png' => 'image/png', - 'xsr' => 'video/x-amt-showrun', - 'xwd' => 'image/x-xwindowdump', - 'xyz' => 'chemical/x-pdb', - 'z' => 'application/x-compressed', - 'zip' => 'application/x-zip-compressed', - 'zoo' => 'application/octet-stream', - 'zsh' => 'text/x-script.zsh', - ); - /** * @inheritdoc */ @@ -495,32 +41,7 @@ class content_guesser implements guesser_interface { $mimetype = mime_content_type($file); } - else - { - $file_name = (empty($file_name)) ? $file : $file_name; - $mimetype = $this->map_extension_to_type($file_name); - } - return $mimetype; - } - - /** - * Map extension of supplied file_name to mime type - * - * @param string $file_name Path to file or filename - * - * @return string|null Mimetype if known or null if not - */ - protected function map_extension_to_type($file_name) - { - $extension = pathinfo($file_name, PATHINFO_EXTENSION); - if (isset($this->extension_map[$extension])) - { - return $this->extension_map[$extension]; - } - else - { - return null; - } + return $mimetype; } } diff --git a/phpBB/phpbb/mimetype/extension_guesser.php b/phpBB/phpbb/mimetype/extension_guesser.php new file mode 100644 index 0000000000..8cca974efc --- /dev/null +++ b/phpBB/phpbb/mimetype/extension_guesser.php @@ -0,0 +1,517 @@ + 'x-world/x-3dmf', + '3dmf' => 'x-world/x-3dmf', + 'a' => 'application/octet-stream', + 'aab' => 'application/x-authorware-bin', + 'aam' => 'application/x-authorware-map', + 'aas' => 'application/x-authorware-seg', + 'abc' => 'text/vnd.abc', + 'acgi' => 'text/html', + 'afl' => 'video/animaflex', + 'ai' => 'application/postscript', + 'aif' => 'audio/aiff', + 'aifc' => 'audio/aiff', + 'aiff' => 'audio/aiff', + 'aim' => 'application/x-aim', + 'aip' => 'text/x-audiosoft-intra', + 'ani' => 'application/x-navi-animation', + 'aos' => 'application/x-nokia-9000-communicator-add-on-software', + 'aps' => 'application/mime', + 'arc' => 'application/octet-stream', + 'arj' => 'application/arj', + 'art' => 'image/x-jg', + 'asf' => 'video/x-ms-asf', + 'asm' => 'text/x-asm', + 'asp' => 'text/asp', + 'asx' => 'video/x-ms-asf', + 'au' => 'audio/x-au', + 'avi' => 'video/avi', + 'avs' => 'video/avs-video', + 'bcpio' => 'application/x-bcpio', + 'bin' => 'application/x-binary', + 'bm' => 'image/bmp', + 'bmp' => 'image/bmp', + 'boo' => 'application/book', + 'book' => 'application/book', + 'boz' => 'application/x-bzip2', + 'bsh' => 'application/x-bsh', + 'bz' => 'application/x-bzip', + 'bz2' => 'application/x-bzip2', + 'c' => 'text/x-c', + 'c++' => 'text/x-c', + 'cat' => 'application/vnd.ms-pki.seccat', + 'cc' => 'text/plain', + 'ccad' => 'application/clariscad', + 'cco' => 'application/x-cocoa', + 'cdf' => 'application/cdf', + 'cer' => 'application/x-x509-ca-cert', + 'cha' => 'application/x-chat', + 'chat' => 'application/x-chat', + 'class' => 'application/java', + 'com' => 'application/octet-stream', + 'conf' => 'text/plain', + 'cpio' => 'application/x-cpio', + 'cpp' => 'text/x-c', + 'cpt' => 'application/x-cpt', + 'crl' => 'application/pkix-crl', + 'crt' => 'application/x-x509-ca-cert', + 'csh' => 'application/x-csh', + 'css' => 'text/css', + 'cxx' => 'text/plain', + 'dcr' => 'application/x-director', + 'deepv' => 'application/x-deepv', + 'def' => 'text/plain', + 'der' => 'application/x-x509-ca-cert', + 'dif' => 'video/x-dv', + 'dir' => 'application/x-director', + 'dl' => 'video/dl', + 'doc' => 'application/msword', + 'dot' => 'application/msword', + 'dp' => 'application/commonground', + 'drw' => 'application/drafting', + 'dump' => 'application/octet-stream', + 'dv' => 'video/x-dv', + 'dvi' => 'application/x-dvi', + 'dwf' => 'model/vnd.dwf', + 'dwg' => 'image/x-dwg', + 'dxf' => 'image/x-dwg', + 'dxr' => 'application/x-director', + 'el' => 'text/x-script.elisp', + 'elc' => 'application/x-elc', + 'env' => 'application/x-envoy', + 'eps' => 'application/postscript', + 'es' => 'application/x-esrehber', + 'etx' => 'text/x-setext', + 'evy' => 'application/x-envoy', + 'exe' => 'application/octet-stream', + 'f' => 'text/x-fortran', + 'f77' => 'text/x-fortran', + 'f90' => 'text/x-fortran', + 'fdf' => 'application/vnd.fdf', + 'fif' => 'image/fif', + 'fli' => 'video/x-fli', + 'flo' => 'image/florian', + 'flx' => 'text/vnd.fmi.flexstor', + 'fmf' => 'video/x-atomic3d-feature', + 'for' => 'text/x-fortran', + 'fpx' => 'image/vnd.fpx', + 'frl' => 'application/freeloader', + 'funk' => 'audio/make', + 'g' => 'text/plain', + 'g3' => 'image/g3fax', + 'gif' => 'image/gif', + 'gl' => 'video/x-gl', + 'gsd' => 'audio/x-gsm', + 'gsm' => 'audio/x-gsm', + 'gsp' => 'application/x-gsp', + 'gss' => 'application/x-gss', + 'gtar' => 'application/x-gtar', + 'gz' => 'application/x-gzip', + 'gzip' => 'application/x-gzip', + 'h' => 'text/x-h', + 'hdf' => 'application/x-hdf', + 'help' => 'application/x-helpfile', + 'hgl' => 'application/vnd.hp-hpgl', + 'hh' => 'text/x-h', + 'hlb' => 'text/x-script', + 'hlp' => 'application/hlp', + 'hpg' => 'application/vnd.hp-hpgl', + 'hpgl' => 'application/vnd.hp-hpgl', + 'hqx' => 'application/x-binhex40', + 'hta' => 'application/hta', + 'htc' => 'text/x-component', + 'htm' => 'text/html', + 'html' => 'text/html', + 'htmls' => 'text/html', + 'htt' => 'text/webviewhtml', + 'htx' => 'text/html', + 'ice' => 'x-conference/x-cooltalk', + 'ico' => 'image/x-icon', + 'idc' => 'text/plain', + 'ief' => 'image/ief', + 'iefs' => 'image/ief', + 'iges' => 'application/iges', + 'igs' => 'application/iges', + 'ima' => 'application/x-ima', + 'imap' => 'application/x-httpd-imap', + 'inf' => 'application/inf', + 'ins' => 'application/x-internett-signup', + 'ip' => 'application/x-ip2', + 'isu' => 'video/x-isvideo', + 'it' => 'audio/it', + 'iv' => 'application/x-inventor', + 'ivr' => 'i-world/i-vrml', + 'ivy' => 'application/x-livescreen', + 'jam' => 'audio/x-jam', + 'jav' => 'text/plain', + 'jav' => 'text/x-java-source', + 'java' => 'text/x-java-source', + 'jcm' => 'application/x-java-commerce', + 'jfif' => 'image/jpeg', + 'jfif-tbnl' => 'image/jpeg', + 'jpe' => 'image/jpeg', + 'jpeg' => 'image/jpeg', + 'jpg' => 'image/jpeg', + 'jps' => 'image/x-jps', + 'js' => 'application/x-javascript', + 'jut' => 'image/jutvision', + 'kar' => 'audio/midi', + 'ksh' => 'text/x-script.ksh', + 'la' => 'audio/x-nspaudio', + 'lam' => 'audio/x-liveaudio', + 'latex' => 'application/x-latex', + 'lha' => 'application/x-lha', + 'lhx' => 'application/octet-stream', + 'list' => 'text/plain', + 'lma' => 'audio/x-nspaudio', + 'log' => 'text/plain', + 'lsp' => 'text/x-script.lisp', + 'lst' => 'text/plain', + 'lsx' => 'text/x-la-asf', + 'ltx' => 'application/x-latex', + 'lzh' => 'application/x-lzh', + 'lzx' => 'application/x-lzx', + 'm' => 'text/x-m', + 'm1v' => 'video/mpeg', + 'm2a' => 'audio/mpeg', + 'm2v' => 'video/mpeg', + 'm3u' => 'audio/x-mpequrl', + 'man' => 'application/x-troff-man', + 'map' => 'application/x-navimap', + 'mar' => 'text/plain', + 'mbd' => 'application/mbedlet', + 'mc$' => 'application/x-magic-cap-package-1.0', + 'mcd' => 'application/x-mathcad', + 'mcf' => 'text/mcf', + 'mcp' => 'application/netmc', + 'me' => 'application/x-troff-me', + 'mht' => 'message/rfc822', + 'mhtml' => 'message/rfc822', + 'mid' => 'audio/x-midi', + 'midi' => 'audio/x-midi', + 'mif' => 'application/x-mif', + 'mime' => 'www/mime', + 'mjf' => 'audio/x-vnd.audioexplosion.mjuicemediafile', + 'mjpg' => 'video/x-motion-jpeg', + 'mm' => 'application/x-meme', + 'mme' => 'application/base64', + 'mod' => 'audio/x-mod', + 'moov' => 'video/quicktime', + 'mov' => 'video/quicktime', + 'movie' => 'video/x-sgi-movie', + 'mp2' => 'audio/x-mpeg', + 'mp3' => 'audio/x-mpeg-3', + 'mpa' => 'audio/mpeg', + 'mpc' => 'application/x-project', + 'mpe' => 'video/mpeg', + 'mpeg' => 'video/mpeg', + 'mpg' => 'video/mpeg', + 'mpga' => 'audio/mpeg', + 'mpp' => 'application/vnd.ms-project', + 'mpt' => 'application/x-project', + 'mpv' => 'application/x-project', + 'mpx' => 'application/x-project', + 'mrc' => 'application/marc', + 'ms' => 'application/x-troff-ms', + 'mv' => 'video/x-sgi-movie', + 'my' => 'audio/make', + 'mzz' => 'application/x-vnd.audioexplosion.mzz', + 'nap' => 'image/naplps', + 'naplps' => 'image/naplps', + 'nc' => 'application/x-netcdf', + 'ncm' => 'application/vnd.nokia.configuration-message', + 'nif' => 'image/x-niff', + 'niff' => 'image/x-niff', + 'nix' => 'application/x-mix-transfer', + 'nsc' => 'application/x-conference', + 'nvd' => 'application/x-navidoc', + 'o' => 'application/octet-stream', + 'oda' => 'application/oda', + 'omc' => 'application/x-omc', + 'omcd' => 'application/x-omcdatamaker', + 'omcr' => 'application/x-omcregerator', + 'p' => 'text/x-pascal', + 'p10' => 'application/x-pkcs10', + 'p12' => 'application/x-pkcs12', + 'p7a' => 'application/x-pkcs7-signature', + 'p7c' => 'application/x-pkcs7-mime', + 'p7m' => 'application/x-pkcs7-mime', + 'p7r' => 'application/x-pkcs7-certreqresp', + 'p7s' => 'application/pkcs7-signature', + 'part' => 'application/pro_eng', + 'pas' => 'text/pascal', + 'pbm' => 'image/x-portable-bitmap', + 'pcl' => 'application/x-pcl', + 'pct' => 'image/x-pict', + 'pcx' => 'image/x-pcx', + 'pdb' => 'chemical/x-pdb', + 'pdf' => 'application/pdf', + 'pfunk' => 'audio/make.my.funk', + 'pgm' => 'image/x-portable-greymap', + 'pic' => 'image/pict', + 'pict' => 'image/pict', + 'pkg' => 'application/x-newton-compatible-pkg', + 'pko' => 'application/vnd.ms-pki.pko', + 'pl' => 'text/x-script.perl', + 'plx' => 'application/x-pixclscript', + 'pm' => 'text/x-script.perl-module', + 'pm4' => 'application/x-pagemaker', + 'pm5' => 'application/x-pagemaker', + 'png' => 'image/png', + 'pnm' => 'image/x-portable-anymap', + 'pot' => 'application/mspowerpoint', + 'pov' => 'model/x-pov', + 'ppa' => 'application/vnd.ms-powerpoint', + 'ppm' => 'image/x-portable-pixmap', + 'pps' => 'application/mspowerpoint', + 'ppt' => 'application/mspowerpoint', + 'ppz' => 'application/mspowerpoint', + 'pre' => 'application/x-freelance', + 'prt' => 'application/pro_eng', + 'ps' => 'application/postscript', + 'psd' => 'application/octet-stream', + 'pvu' => 'paleovu/x-pv', + 'pwz' => 'application/vnd.ms-powerpoint', + 'py' => 'text/x-script.phyton', + 'pyc' => 'applicaiton/x-bytecode.python', + 'qcp' => 'audio/vnd.qcelp', + 'qd3' => 'x-world/x-3dmf', + 'qd3d' => 'x-world/x-3dmf', + 'qif' => 'image/x-quicktime', + 'qt' => 'video/quicktime', + 'qtc' => 'video/x-qtc', + 'qti' => 'image/x-quicktime', + 'qtif' => 'image/x-quicktime', + 'ra' => 'audio/x-realaudio', + 'ram' => 'audio/x-pn-realaudio', + 'ras' => 'image/x-cmu-raster', + 'rast' => 'image/cmu-raster', + 'rexx' => 'text/x-script.rexx', + 'rf' => 'image/vnd.rn-realflash', + 'rgb' => 'image/x-rgb', + 'rm' => 'audio/x-pn-realaudio', + 'rmi' => 'audio/mid', + 'rmm' => 'audio/x-pn-realaudio', + 'rmp' => 'audio/x-pn-realaudio', + 'rng' => 'application/vnd.nokia.ringing-tone', + 'rnx' => 'application/vnd.rn-realplayer', + 'roff' => 'application/x-troff', + 'rp' => 'image/vnd.rn-realpix', + 'rpm' => 'audio/x-pn-realaudio-plugin', + 'rt' => 'text/richtext', + 'rtf' => 'text/richtext', + 'rtx' => 'text/richtext', + 'rv' => 'video/vnd.rn-realvideo', + 's' => 'text/x-asm', + 's3m' => 'audio/s3m', + 'saveme' => 'application/octet-stream', + 'sbk' => 'application/x-tbook', + 'scm' => 'video/x-scm', + 'sdml' => 'text/plain', + 'sdp' => 'application/x-sdp', + 'sdr' => 'application/sounder', + 'sea' => 'application/x-sea', + 'set' => 'application/set', + 'sgm' => 'text/x-sgml', + 'sgml' => 'text/x-sgml', + 'sh' => 'text/x-script.sh', + 'shar' => 'application/x-shar', + 'shtml' => 'text/x-server-parsed-html', + 'sid' => 'audio/x-psid', + 'sit' => 'application/x-stuffit', + 'skd' => 'application/x-koan', + 'skm' => 'application/x-koan', + 'skp' => 'application/x-koan', + 'skt' => 'application/x-koan', + 'sl' => 'application/x-seelogo', + 'smi' => 'application/smil', + 'smil' => 'application/smil', + 'snd' => 'audio/x-adpcm', + 'sol' => 'application/solids', + 'spc' => 'text/x-speech', + 'spl' => 'application/futuresplash', + 'spr' => 'application/x-sprite', + 'sprite' => 'application/x-sprite', + 'src' => 'application/x-wais-source', + 'ssi' => 'text/x-server-parsed-html', + 'ssm' => 'application/streamingmedia', + 'sst' => 'application/vnd.ms-pki.certstore', + 'step' => 'application/step', + 'stl' => 'application/vnd.ms-pki.stl', + 'stp' => 'application/step', + 'sv4cpio' => 'application/x-sv4cpio', + 'sv4crc' => 'application/x-sv4crc', + 'svf' => 'image/x-dwg', + 'svr' => 'application/x-world', + 'swf' => 'application/x-shockwave-flash', + 't' => 'application/x-troff', + 'talk' => 'text/x-speech', + 'tar' => 'application/x-tar', + 'tbk' => 'application/x-tbook', + 'tcl' => 'text/x-script.tcl', + 'tcsh' => 'text/x-script.tcsh', + 'tex' => 'application/x-tex', + 'texi' => 'application/x-texinfo', + 'texinfo' => 'application/x-texinfo', + 'text' => 'text/plain', + 'tgz' => 'application/x-compressed', + 'tif' => 'image/tiff', + 'tiff' => 'image/tiff', + 'tr' => 'application/x-troff', + 'tsi' => 'audio/tsp-audio', + 'tsp' => 'audio/tsplayer', + 'tsv' => 'text/tab-separated-values', + 'turbot' => 'image/florian', + 'txt' => 'text/plain', + 'uil' => 'text/x-uil', + 'uni' => 'text/uri-list', + 'unis' => 'text/uri-list', + 'unv' => 'application/i-deas', + 'uri' => 'text/uri-list', + 'uris' => 'text/uri-list', + 'ustar' => 'multipart/x-ustar', + 'uu' => 'text/x-uuencode', + 'uue' => 'text/x-uuencode', + 'vcd' => 'application/x-cdlink', + 'vcs' => 'text/x-vcalendar', + 'vda' => 'application/vda', + 'vdo' => 'video/vdo', + 'vew' => 'application/groupwise', + 'viv' => 'video/vivo', + 'vivo' => 'video/vivo', + 'vmd' => 'application/vocaltec-media-desc', + 'vmf' => 'application/vocaltec-media-file', + 'voc' => 'audio/voc', + 'vos' => 'video/vosaic', + 'vox' => 'audio/voxware', + 'vqe' => 'audio/x-twinvq-plugin', + 'vqf' => 'audio/x-twinvq', + 'vql' => 'audio/x-twinvq-plugin', + 'vrml' => 'application/x-vrml', + 'vrt' => 'x-world/x-vrt', + 'vsd' => 'application/x-visio', + 'vst' => 'application/x-visio', + 'vsw' => 'application/x-visio', + 'w60' => 'application/wordperfect6.0', + 'w61' => 'application/wordperfect6.1', + 'w6w' => 'application/msword', + 'wav' => 'audio/wav', + 'wb1' => 'application/x-qpro', + 'wbmp' => 'image/vnd.wap.wbmp', + 'web' => 'application/vnd.xara', + 'wiz' => 'application/msword', + 'wk1' => 'application/x-123', + 'wmf' => 'windows/metafile', + 'wml' => 'text/vnd.wap.wml', + 'wmlc' => 'application/vnd.wap.wmlc', + 'wmls' => 'text/vnd.wap.wmlscript', + 'wmlsc' => 'application/vnd.wap.wmlscriptc', + 'word' => 'application/msword', + 'wp' => 'application/wordperfect', + 'wp5' => 'application/wordperfect', + 'wp6' => 'application/wordperfect', + 'wpd' => 'application/wordperfect', + 'wq1' => 'application/x-lotus', + 'wri' => 'application/mswrite', + 'wrl' => 'model/vrml', + 'wrz' => 'model/vrml', + 'wsc' => 'text/scriplet', + 'wsrc' => 'application/x-wais-source', + 'wtk' => 'application/x-wintalk', + 'xbm' => 'image/xbm', + 'xdr' => 'video/x-amt-demorun', + 'xgz' => 'xgl/drawing', + 'xif' => 'image/vnd.xiff', + 'xl' => 'application/excel', + 'xla' => 'application/excel', + 'xlb' => 'application/excel', + 'xlc' => 'application/excel', + 'xld' => 'application/excel', + 'xlk' => 'application/excel', + 'xll' => 'application/excel', + 'xlm' => 'application/excel', + 'xls' => 'application/excel', + 'xlt' => 'application/excel', + 'xlv' => 'application/excel', + 'xlw' => 'application/excel', + 'xm' => 'audio/xm', + 'xml' => 'text/xml', + 'xmz' => 'xgl/movie', + 'xpix' => 'application/x-vnd.ls-xpix', + 'xpm' => 'image/xpm', + 'x-png' => 'image/png', + 'xsr' => 'video/x-amt-showrun', + 'xwd' => 'image/x-xwindowdump', + 'xyz' => 'chemical/x-pdb', + 'z' => 'application/x-compressed', + 'zip' => 'application/x-zip-compressed', + 'zoo' => 'application/octet-stream', + 'zsh' => 'text/x-script.zsh', + ); + + /** + * @inheritdoc + */ + public function is_supported() + { + return true; + } + + /** + * @inheritdoc + */ + public function guess($file, $file_name = '') + { + $file_name = (empty($file_name)) ? $file : $file_name; + return $this->map_extension_to_type($file_name); + } + + /** + * Map extension of supplied file_name to mime type + * + * @param string $file_name Path to file or filename + * + * @return string|null Mimetype if known or null if not + */ + protected function map_extension_to_type($file_name) + { + $extension = pathinfo($file_name, PATHINFO_EXTENSION); + + if (isset($this->extension_map[$extension])) + { + return $this->extension_map[$extension]; + } + else + { + return null; + } + } +} -- cgit v1.2.1 From bef6a5a6401314da7e5688907f4ebfc06ef83f2b Mon Sep 17 00:00:00 2001 From: Marc Alexander Date: Mon, 11 Nov 2013 21:18:23 +0100 Subject: [ticket/11912] Introduce guesser priority to mimetype guessers The mimetype guesser priority can now be set through the service definition. Mimetypes will be guessed from the guesser with the highest priority to the one with the lowest priority. Standard priority types have been added to the service definition file. Any integer value can be used though. Standard mimetype guessers that do not have the methods get_priority and set_priority implemented, like the standard MimeTypeGuessers of symfony, will have the default priority with the value of 0. Lower priority guessers have values lower than 0 while high priority ones can be added with values higher than 0. PHPBB3-11912 --- phpBB/phpbb/mimetype/content_guesser.php | 2 +- phpBB/phpbb/mimetype/extension_guesser.php | 2 +- phpBB/phpbb/mimetype/guesser.php | 35 ++++++++++++++++++++++- phpBB/phpbb/mimetype/guesser_base.php | 46 ++++++++++++++++++++++++++++++ phpBB/phpbb/mimetype/guesser_interface.php | 16 +++++++++++ 5 files changed, 98 insertions(+), 3 deletions(-) create mode 100644 phpBB/phpbb/mimetype/guesser_base.php (limited to 'phpBB/phpbb') diff --git a/phpBB/phpbb/mimetype/content_guesser.php b/phpBB/phpbb/mimetype/content_guesser.php index 21631ae6d3..ffaed9136a 100644 --- a/phpBB/phpbb/mimetype/content_guesser.php +++ b/phpBB/phpbb/mimetype/content_guesser.php @@ -21,7 +21,7 @@ if (!defined('IN_PHPBB')) * @package mimetype */ -class content_guesser implements guesser_interface +class content_guesser extends guesser_base { /** * @inheritdoc diff --git a/phpBB/phpbb/mimetype/extension_guesser.php b/phpBB/phpbb/mimetype/extension_guesser.php index 8cca974efc..f9459c84ec 100644 --- a/phpBB/phpbb/mimetype/extension_guesser.php +++ b/phpBB/phpbb/mimetype/extension_guesser.php @@ -21,7 +21,7 @@ if (!defined('IN_PHPBB')) * @package mimetype */ -class extension_guesser implements guesser_interface +class extension_guesser extends guesser_base { /** * @var file extension map diff --git a/phpBB/phpbb/mimetype/guesser.php b/phpBB/phpbb/mimetype/guesser.php index 231b75f604..753fd65b0d 100644 --- a/phpBB/phpbb/mimetype/guesser.php +++ b/phpBB/phpbb/mimetype/guesser.php @@ -23,6 +23,11 @@ if (!defined('IN_PHPBB')) class guesser { + /** + * @const Default priority for mimetype guessers + */ + const PRIORITY_DEFAULT = 0; + /** * @var mimetype guessers */ @@ -39,7 +44,7 @@ class guesser } /** - * Register MimeTypeGuessers + * Register MimeTypeGuessers and sort them by priority * * @param array $mimetype_guessers Mimetype guesser service collection * @@ -68,6 +73,34 @@ class guesser { throw new \LogicException('No mimetype guesser supplied.'); } + + // Sort guessers by priority + usort($this->guessers, array($this, 'sort_priority')); + } + + /** + * Sort the priority of supplied guessers + * This is a compare function for usort. A guesser with higher priority + * should be used first and vice versa. usort() orders the array values + * from low to high depending on what the comparison function returns + * to it. Return value should be smaller than 0 if value a is smaller + * than value b. This has been reversed in the comparision function in + * order to sort the guessers from high to low. + * Method has been set to public in order to allow proper testing. + * + * @param object $guesser_a Mimetype guesser a + * @param object $guesser_b Mimetype guesser b + * + * @return int If both guessers have the same priority 0, bigger + * than 0 if first guesser has lower priority, and lower + * than 0 if first guesser has higher priority + */ + public function sort_priority($guesser_a, $guesser_b) + { + $priority_a = (int) (method_exists($guesser_a, 'get_priority')) ? $guesser_a->get_priority() : self::PRIORITY_DEFAULT; + $priority_b = (int) (method_exists($guesser_b, 'get_priority')) ? $guesser_b->get_priority() : self::PRIORITY_DEFAULT; + + return $priority_b - $priority_a; } /** diff --git a/phpBB/phpbb/mimetype/guesser_base.php b/phpBB/phpbb/mimetype/guesser_base.php new file mode 100644 index 0000000000..b35badea54 --- /dev/null +++ b/phpBB/phpbb/mimetype/guesser_base.php @@ -0,0 +1,46 @@ +priority; + } + + /** + * @inheritdoc + */ + public function set_priority($priority) + { + $this->priority = $priority; + } +} diff --git a/phpBB/phpbb/mimetype/guesser_interface.php b/phpBB/phpbb/mimetype/guesser_interface.php index a9b238d7aa..defff90654 100644 --- a/phpBB/phpbb/mimetype/guesser_interface.php +++ b/phpBB/phpbb/mimetype/guesser_interface.php @@ -38,4 +38,20 @@ interface guesser_interface * @return string Guess for mimetype of file */ public function guess($file, $file_name = ''); + + /** + * Get the guesser priority + * + * @return int Guesser priority + */ + public function get_priority(); + + /** + * Set the guesser priority + * + * @param int Guesser priority + * + * @return void + */ + public function set_priority($priority); } -- cgit v1.2.1 From 81caa35955b696e1ffdcafe4ccdd72a83700b773 Mon Sep 17 00:00:00 2001 From: Marc Alexander Date: Mon, 11 Nov 2013 21:24:44 +0100 Subject: [ticket/11912] Remove obsolete $file_info from plupload PHPBB3-11912 --- phpBB/phpbb/plupload/plupload.php | 2 -- 1 file changed, 2 deletions(-) (limited to 'phpBB/phpbb') diff --git a/phpBB/phpbb/plupload/plupload.php b/phpBB/phpbb/plupload/plupload.php index dedc3cbcd4..f9f2fdd812 100644 --- a/phpBB/phpbb/plupload/plupload.php +++ b/phpBB/phpbb/plupload/plupload.php @@ -128,8 +128,6 @@ class plupload { rename("{$file_path}.part", $file_path); - $file_info = new \Symfony\Component\HttpFoundation\File\File($file_path); - // Need to modify some of the $_FILES values to reflect the new file return array( 'tmp_name' => $file_path, -- cgit v1.2.1 From 9d4893b04760e3e1bff023e3615ad19beb699068 Mon Sep 17 00:00:00 2001 From: Marc Alexander Date: Mon, 11 Nov 2013 21:29:11 +0100 Subject: [ticket/11912] Remove IN_PHPBB checks from mimetype guesser files PHPBB3-11912 --- phpBB/phpbb/mimetype/content_guesser.php | 8 -------- phpBB/phpbb/mimetype/extension_guesser.php | 8 -------- phpBB/phpbb/mimetype/guesser.php | 8 -------- phpBB/phpbb/mimetype/guesser_base.php | 8 -------- phpBB/phpbb/mimetype/guesser_interface.php | 8 -------- 5 files changed, 40 deletions(-) (limited to 'phpBB/phpbb') diff --git a/phpBB/phpbb/mimetype/content_guesser.php b/phpBB/phpbb/mimetype/content_guesser.php index ffaed9136a..ea15393b94 100644 --- a/phpBB/phpbb/mimetype/content_guesser.php +++ b/phpBB/phpbb/mimetype/content_guesser.php @@ -9,14 +9,6 @@ namespace phpbb\mimetype; -/** -* @ignore -*/ -if (!defined('IN_PHPBB')) -{ - exit; -} - /** * @package mimetype */ diff --git a/phpBB/phpbb/mimetype/extension_guesser.php b/phpBB/phpbb/mimetype/extension_guesser.php index f9459c84ec..f6f4ae0138 100644 --- a/phpBB/phpbb/mimetype/extension_guesser.php +++ b/phpBB/phpbb/mimetype/extension_guesser.php @@ -9,14 +9,6 @@ namespace phpbb\mimetype; -/** -* @ignore -*/ -if (!defined('IN_PHPBB')) -{ - exit; -} - /** * @package mimetype */ diff --git a/phpBB/phpbb/mimetype/guesser.php b/phpBB/phpbb/mimetype/guesser.php index 753fd65b0d..3499b3b0f7 100644 --- a/phpBB/phpbb/mimetype/guesser.php +++ b/phpBB/phpbb/mimetype/guesser.php @@ -9,14 +9,6 @@ namespace phpbb\mimetype; -/** -* @ignore -*/ -if (!defined('IN_PHPBB')) -{ - exit; -} - /** * @package mimetype */ diff --git a/phpBB/phpbb/mimetype/guesser_base.php b/phpBB/phpbb/mimetype/guesser_base.php index b35badea54..082b098028 100644 --- a/phpBB/phpbb/mimetype/guesser_base.php +++ b/phpBB/phpbb/mimetype/guesser_base.php @@ -9,14 +9,6 @@ namespace phpbb\mimetype; -/** -* @ignore -*/ -if (!defined('IN_PHPBB')) -{ - exit; -} - /** * @package mimetype */ diff --git a/phpBB/phpbb/mimetype/guesser_interface.php b/phpBB/phpbb/mimetype/guesser_interface.php index defff90654..103689765e 100644 --- a/phpBB/phpbb/mimetype/guesser_interface.php +++ b/phpBB/phpbb/mimetype/guesser_interface.php @@ -9,14 +9,6 @@ namespace phpbb\mimetype; -/** -* @ignore -*/ -if (!defined('IN_PHPBB')) -{ - exit; -} - /** * @package mimetype */ -- cgit v1.2.1 From e380eed78e6f3076c5d7cb3df3a016165781e73d Mon Sep 17 00:00:00 2001 From: Marc Alexander Date: Tue, 12 Nov 2013 00:35:52 +0100 Subject: [ticket/11912] Remove obsolete variable $mimetype from content_guesser PHPBB3-11912 --- phpBB/phpbb/mimetype/content_guesser.php | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) (limited to 'phpBB/phpbb') diff --git a/phpBB/phpbb/mimetype/content_guesser.php b/phpBB/phpbb/mimetype/content_guesser.php index ea15393b94..623438ee0b 100644 --- a/phpBB/phpbb/mimetype/content_guesser.php +++ b/phpBB/phpbb/mimetype/content_guesser.php @@ -28,12 +28,11 @@ class content_guesser extends guesser_base */ public function guess($file, $file_name = '') { - $mimetype = null; if (function_exists('mime_content_type')) { - $mimetype = mime_content_type($file); + return mime_content_type($file); } - return $mimetype; + return null; // optional } } -- cgit v1.2.1 From d3f9a51709d538824f4ec7afe8a2d6934dabb13c Mon Sep 17 00:00:00 2001 From: Joas Schilling Date: Wed, 13 Nov 2013 17:34:06 +0100 Subject: [ticket/12016] Use a service provider for event listeners This allows them to use dependency injection PHPBB3-12016 --- phpBB/phpbb/event/extension_subscriber_loader.php | 20 ++++++++------------ 1 file changed, 8 insertions(+), 12 deletions(-) (limited to 'phpBB/phpbb') diff --git a/phpBB/phpbb/event/extension_subscriber_loader.php b/phpBB/phpbb/event/extension_subscriber_loader.php index df8e093f4a..6408f93e2a 100644 --- a/phpBB/phpbb/event/extension_subscriber_loader.php +++ b/phpBB/phpbb/event/extension_subscriber_loader.php @@ -14,26 +14,22 @@ use Symfony\Component\EventDispatcher\EventDispatcherInterface; class extension_subscriber_loader { private $dispatcher; - private $extension_manager; + private $listener_collection; - public function __construct(EventDispatcherInterface $dispatcher, \phpbb\extension\manager $extension_manager) + public function __construct(EventDispatcherInterface $dispatcher, \phpbb\di\service_collection $listener_collection) { $this->dispatcher = $dispatcher; - $this->extension_manager = $extension_manager; + $this->listener_collection = $listener_collection; } public function load() { - $finder = $this->extension_manager->get_finder(); - $subscriber_classes = $finder - ->extension_directory('/event') - ->core_path('event/') - ->get_classes(); - - foreach ($subscriber_classes as $class) + if (!empty($this->listener_collection)) { - $subscriber = new $class(); - $this->dispatcher->addSubscriber($subscriber); + foreach ($this->listener_collection as $listener) + { + $this->dispatcher->addSubscriber($listener); + } } } } -- cgit v1.2.1 From 13a4ceedb18ba938d3cd18e2f68707385bc9283a Mon Sep 17 00:00:00 2001 From: Marc Alexander Date: Wed, 13 Nov 2013 18:27:40 +0100 Subject: [ticket/11525] Use foreach instead of array_walk in method clean_row() This approach is cleaner and probably even faster the previous ways that included using array_walk() or array_map() and other helper functions and methods. PHPBB3-11525 --- phpBB/phpbb/avatar/manager.php | 32 +++++++++----------------------- 1 file changed, 9 insertions(+), 23 deletions(-) (limited to 'phpBB/phpbb') diff --git a/phpBB/phpbb/avatar/manager.php b/phpBB/phpbb/avatar/manager.php index 9f6a5fb089..12d7861cdf 100644 --- a/phpBB/phpbb/avatar/manager.php +++ b/phpBB/phpbb/avatar/manager.php @@ -195,33 +195,19 @@ class manager return self::$default_row; } - $keys = array_keys($row); - $values = array_values($row); - - array_walk($keys, array('\phpbb\avatar\manager', 'strip_prefix'), $prefix); - $row = array_combine($keys, $values); - - if ($prefix == 'group') + $output = array(); + foreach ($row as $key => $value) { - $row['id'] = 'g' . $row['id']; + $key = preg_replace("#^(?:{$prefix}_)#", '', $key); + $output[$key] = $value; } - return $row; - } + if ($prefix === 'group' && isset($output['id'])) + { + $output['id'] = 'g' . $output['id']; + } - /** - * Strip prepending user_ or group_ prefix from key - * - * @param string $key Array key - * @param string $null Parameter is ignored by the function, just required by the array_walk - * @param string $prefix Prefix that should be stripped off from the keys (e.g. user) - * Should not include the trailing underscore - * @return null - */ - static protected function strip_prefix(&$key, $null, $prefix) - { - $regex = ($prefix !== '') ? "#^(?:{$prefix}_)#" : '#^(?:user_|group_)#'; - $key = preg_replace($regex, '', $key); + return $output; } /** -- cgit v1.2.1 From 50896305fa9b5b0db733ae4a401c9bd0a85cabe9 Mon Sep 17 00:00:00 2001 From: Cesar G Date: Wed, 13 Nov 2013 23:57:39 -0800 Subject: [ticket/12008] The read_notification_last_gc config setting should be dynamic. PHPBB3-12008 --- .../migration/data/v310/notifications_cron_p2.php | 27 ++++++++++++++++++++++ 1 file changed, 27 insertions(+) create mode 100644 phpBB/phpbb/db/migration/data/v310/notifications_cron_p2.php (limited to 'phpBB/phpbb') diff --git a/phpBB/phpbb/db/migration/data/v310/notifications_cron_p2.php b/phpBB/phpbb/db/migration/data/v310/notifications_cron_p2.php new file mode 100644 index 0000000000..050e679cc0 --- /dev/null +++ b/phpBB/phpbb/db/migration/data/v310/notifications_cron_p2.php @@ -0,0 +1,27 @@ + Date: Wed, 13 Nov 2013 23:58:21 -0800 Subject: [ticket/12008] Update the run time value for the prune notifications cron task PHPBB3-12008 --- phpBB/phpbb/notification/manager.php | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) (limited to 'phpBB/phpbb') diff --git a/phpBB/phpbb/notification/manager.php b/phpBB/phpbb/notification/manager.php index d77a936413..2e8652771b 100644 --- a/phpBB/phpbb/notification/manager.php +++ b/phpBB/phpbb/notification/manager.php @@ -27,6 +27,9 @@ class manager /** @var \phpbb\user_loader */ protected $user_loader; + /** @var \phpbb\config\config */ + protected $config; + /** @var \phpbb\db\driver\driver */ protected $db; @@ -58,6 +61,7 @@ class manager * @param array $notification_methods * @param ContainerBuilder $phpbb_container * @param \phpbb\user_loader $user_loader + * @param \phpbb\config\config $config * @param \phpbb\db\driver\driver $db * @param \phpbb\user $user * @param string $phpbb_root_path @@ -67,13 +71,14 @@ class manager * @param string $user_notifications_table * @return \phpbb\notification\manager */ - public function __construct($notification_types, $notification_methods, $phpbb_container, \phpbb\user_loader $user_loader, \phpbb\db\driver\driver $db, \phpbb\cache\service $cache, $user, $phpbb_root_path, $php_ext, $notification_types_table, $notifications_table, $user_notifications_table) + public function __construct($notification_types, $notification_methods, $phpbb_container, \phpbb\user_loader $user_loader, \phpbb\config\config $config, \phpbb\db\driver\driver $db, \phpbb\cache\service $cache, $user, $phpbb_root_path, $php_ext, $notification_types_table, $notifications_table, $user_notifications_table) { $this->notification_types = $notification_types; $this->notification_methods = $notification_methods; $this->phpbb_container = $phpbb_container; $this->user_loader = $user_loader; + $this->config = $config; $this->db = $db; $this->cache = $cache; $this->user = $user; @@ -797,6 +802,8 @@ class manager WHERE notification_time < ' . (int) $timestamp . (($only_read) ? ' AND notification_read = 1' : ''); $this->db->sql_query($sql); + + $this->config->set('read_notification_last_gc', time(), false); } /** -- cgit v1.2.1 From df6e03266fbe13e64a1f889136b6b1244b9111ae Mon Sep 17 00:00:00 2001 From: Marc Alexander Date: Thu, 14 Nov 2013 15:12:42 +0100 Subject: [ticket/11912] Remove obsolete "return null" in content_guesser PHPBB3-11912 --- phpBB/phpbb/mimetype/content_guesser.php | 2 -- 1 file changed, 2 deletions(-) (limited to 'phpBB/phpbb') diff --git a/phpBB/phpbb/mimetype/content_guesser.php b/phpBB/phpbb/mimetype/content_guesser.php index 623438ee0b..60e5a905e2 100644 --- a/phpBB/phpbb/mimetype/content_guesser.php +++ b/phpBB/phpbb/mimetype/content_guesser.php @@ -32,7 +32,5 @@ class content_guesser extends guesser_base { return mime_content_type($file); } - - return null; // optional } } -- cgit v1.2.1 From 23e2f920f5ed52cf9b354f61fcff548a03335ecc Mon Sep 17 00:00:00 2001 From: Marc Alexander Date: Thu, 14 Nov 2013 15:55:04 +0100 Subject: [ticket/12018] Use path_helper for admin style CSS in sql report The path to the admin style CSS is currently created with $phpbb_admin_path. We should however use the path_helper to correctly link to this file in order to have a correct link on pages like extensions PHPBB3-12018 --- phpBB/phpbb/db/driver/driver.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'phpBB/phpbb') diff --git a/phpBB/phpbb/db/driver/driver.php b/phpBB/phpbb/db/driver/driver.php index 58d0b61519..d721ed2eb7 100644 --- a/phpBB/phpbb/db/driver/driver.php +++ b/phpBB/phpbb/db/driver/driver.php @@ -816,7 +816,7 @@ class driver */ function sql_report($mode, $query = '') { - global $cache, $starttime, $phpbb_root_path, $phpbb_admin_path, $user; + global $cache, $starttime, $phpbb_root_path, $phpbb_path_helper, $user; global $request; if (is_object($request) && !$request->variable('explain', false)) @@ -846,7 +846,7 @@ class driver SQL Report - +
-- cgit v1.2.1 From 7678186b0907e0852eabcd1f4ed2041a8a45060d Mon Sep 17 00:00:00 2001 From: Joas Schilling Date: Wed, 13 Nov 2013 23:19:47 +0100 Subject: [prep-release-3.1.0-a2] Add migration for 3.1.0-a2 --- phpBB/phpbb/db/migration/data/v310/alpha2.php | 28 +++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) create mode 100644 phpBB/phpbb/db/migration/data/v310/alpha2.php (limited to 'phpBB/phpbb') diff --git a/phpBB/phpbb/db/migration/data/v310/alpha2.php b/phpBB/phpbb/db/migration/data/v310/alpha2.php new file mode 100644 index 0000000000..3c0853f924 --- /dev/null +++ b/phpBB/phpbb/db/migration/data/v310/alpha2.php @@ -0,0 +1,28 @@ + Date: Wed, 20 Nov 2013 17:07:53 +0100 Subject: [ticket/11842] Add migration file for updating avatar type in database PHPBB3-11842 --- .../phpbb/db/migration/data/v310/avatar_types.php | 65 ++++++++++++++++++++++ 1 file changed, 65 insertions(+) create mode 100644 phpBB/phpbb/db/migration/data/v310/avatar_types.php (limited to 'phpBB/phpbb') diff --git a/phpBB/phpbb/db/migration/data/v310/avatar_types.php b/phpBB/phpbb/db/migration/data/v310/avatar_types.php new file mode 100644 index 0000000000..439e20889c --- /dev/null +++ b/phpBB/phpbb/db/migration/data/v310/avatar_types.php @@ -0,0 +1,65 @@ +table_prefix . "users + SET user_avatar_type = 'avatar.driver.upload' + WHERE user_avatar_type = " . AVATAR_UPLOAD; + $this->db->sql_query($sql); + + $sql = 'UPDATE ' . $this->table_prefix . "users + SET user_avatar_type = 'avatar.driver.remote' + WHERE user_avatar_type = " . AVATAR_REMOTE; + $this->db->sql_query($sql); + + $sql = 'UPDATE ' . $this->table_prefix . "users + SET user_avatar_type = 'avatar.driver.local' + WHERE user_avatar_type = " . AVATAR_GALLERY; + $this->db->sql_query($sql); + } + + public function update_group_avatar_type() + { + $sql = 'UPDATE ' . $this->table_prefix . "groups + SET group_avatar_type = 'avatar.driver.upload' + WHERE group_avatar_type = " . AVATAR_UPLOAD; + $this->db->sql_query($sql); + + $sql = 'UPDATE ' . $this->table_prefix . "groups + SET group_avatar_type = 'avatar.driver.remote' + WHERE group_avatar_type = " . AVATAR_REMOTE; + $this->db->sql_query($sql); + + $sql = 'UPDATE ' . $this->table_prefix . "groups + SET group_avatar_type = 'avatar.driver.local' + WHERE group_avatar_type = " . AVATAR_GALLERY; + $this->db->sql_query($sql); + } +} -- cgit v1.2.1 From 44b6f45759485cc33bb71ff50a715f39a8d60089 Mon Sep 17 00:00:00 2001 From: Cesar G Date: Thu, 21 Nov 2013 08:11:17 -0800 Subject: [ticket/11484] Display login box for users following email notification link. The link used for the latest post now uses view=unread so redirecting the user using the value for the e parameter is no longer necessary. PHPBB3-11484 --- phpBB/phpbb/notification/type/post.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'phpBB/phpbb') diff --git a/phpBB/phpbb/notification/type/post.php b/phpBB/phpbb/notification/type/post.php index 9d5c7b0a4c..c0ef184a19 100644 --- a/phpBB/phpbb/notification/type/post.php +++ b/phpBB/phpbb/notification/type/post.php @@ -234,7 +234,7 @@ class post extends \phpbb\notification\type\base 'TOPIC_TITLE' => htmlspecialchars_decode(censor_text($this->get_data('topic_title'))), 'U_VIEW_POST' => generate_board_url() . "/viewtopic.{$this->php_ext}?p={$this->item_id}#p{$this->item_id}", - 'U_NEWEST_POST' => generate_board_url() . "/viewtopic.{$this->php_ext}?f={$this->get_data('forum_id')}&t={$this->item_parent_id}&view=unread#unread", + 'U_NEWEST_POST' => generate_board_url() . "/viewtopic.{$this->php_ext}?f={$this->get_data('forum_id')}&t={$this->item_parent_id}&e=1&view=unread#unread", 'U_TOPIC' => generate_board_url() . "/viewtopic.{$this->php_ext}?f={$this->get_data('forum_id')}&t={$this->item_parent_id}", 'U_VIEW_TOPIC' => generate_board_url() . "/viewtopic.{$this->php_ext}?f={$this->get_data('forum_id')}&t={$this->item_parent_id}", 'U_FORUM' => generate_board_url() . "/viewforum.{$this->php_ext}?f={$this->get_data('forum_id')}", -- cgit v1.2.1 From bcf347420e4fe400d02a6ee58e63839f18a86362 Mon Sep 17 00:00:00 2001 From: Cesar G Date: Thu, 21 Nov 2013 13:02:26 -0800 Subject: [ticket/11959] Trim the list of users from post notifications. PHPBB3-11959 --- phpBB/phpbb/notification/type/post.php | 31 +++++++++++++++++++++++++++++-- 1 file changed, 29 insertions(+), 2 deletions(-) (limited to 'phpBB/phpbb') diff --git a/phpBB/phpbb/notification/type/post.php b/phpBB/phpbb/notification/type/post.php index 9d5c7b0a4c..0d07df8adf 100644 --- a/phpBB/phpbb/notification/type/post.php +++ b/phpBB/phpbb/notification/type/post.php @@ -183,6 +183,10 @@ class post extends \phpbb\notification\type\base 'username' => $this->get_data('post_username'), )), $responders); + $responders_cnt = sizeof($responders); + $responders = $this->trim_user_ary($responders); + $extra_cnt = $responders_cnt - sizeof($responders); + foreach ($responders as $responder) { if ($responder['username']) @@ -194,11 +198,18 @@ class post extends \phpbb\notification\type\base $usernames[] = $this->user_loader->get_username($responder['poster_id'], 'no_profile'); } } + $lang_key = $this->language_key; + + if ($responders_cnt > 4) + { + $lang_key .= '_TRIMMED'; + } return $this->user->lang( - $this->language_key, + $lang_key, implode(', ', $usernames), - censor_text($this->get_data('topic_title')) + censor_text($this->get_data('topic_title')), + $extra_cnt ); } @@ -272,6 +283,22 @@ class post extends \phpbb\notification\type\base } } + return $this->trim_user_ary($users); + } + + /** + * Trim the user array passed down to 3 users if the array contains + * more than 4 users. + * + * @param array $users Array of users + * @return array Trimmed array of user_ids + */ + public function trim_user_ary($users) + { + if (sizeof($users) > 4) + { + array_splice($users, 3); + } return $users; } -- cgit v1.2.1 From 43f454a6c6347827a01a1e31478a846ad05bc7f4 Mon Sep 17 00:00:00 2001 From: Cesar G Date: Thu, 21 Nov 2013 13:15:08 -0800 Subject: [ticket/11959] Use COMMA_SEPARATOR to join the user list. PHPBB3-11959 --- phpBB/phpbb/notification/type/post.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'phpBB/phpbb') diff --git a/phpBB/phpbb/notification/type/post.php b/phpBB/phpbb/notification/type/post.php index 0d07df8adf..e9f9d48978 100644 --- a/phpBB/phpbb/notification/type/post.php +++ b/phpBB/phpbb/notification/type/post.php @@ -207,7 +207,7 @@ class post extends \phpbb\notification\type\base return $this->user->lang( $lang_key, - implode(', ', $usernames), + implode($this->user->lang['COMMA_SEPARATOR'], $usernames), censor_text($this->get_data('topic_title')), $extra_cnt ); -- cgit v1.2.1 From e3a28e5e2a451794b322be90e1aef9ad4aee256b Mon Sep 17 00:00:00 2001 From: Cesar G Date: Thu, 21 Nov 2013 13:18:28 -0800 Subject: [ticket/11959] Rename $extra_cnt to something more descriptive. PHPBB3-11959 --- phpBB/phpbb/notification/type/post.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'phpBB/phpbb') diff --git a/phpBB/phpbb/notification/type/post.php b/phpBB/phpbb/notification/type/post.php index e9f9d48978..87bd4331b6 100644 --- a/phpBB/phpbb/notification/type/post.php +++ b/phpBB/phpbb/notification/type/post.php @@ -185,7 +185,7 @@ class post extends \phpbb\notification\type\base $responders_cnt = sizeof($responders); $responders = $this->trim_user_ary($responders); - $extra_cnt = $responders_cnt - sizeof($responders); + $trimmed_responders_cnt = $responders_cnt - sizeof($responders); foreach ($responders as $responder) { @@ -200,7 +200,7 @@ class post extends \phpbb\notification\type\base } $lang_key = $this->language_key; - if ($responders_cnt > 4) + if ($trimmed_responders_cnt) { $lang_key .= '_TRIMMED'; } @@ -209,7 +209,7 @@ class post extends \phpbb\notification\type\base $lang_key, implode($this->user->lang['COMMA_SEPARATOR'], $usernames), censor_text($this->get_data('topic_title')), - $extra_cnt + $trimmed_responders_cnt ); } -- cgit v1.2.1 From e108418824857e670a92f516285455f79bf6e12a Mon Sep 17 00:00:00 2001 From: Marc Alexander Date: Sat, 23 Nov 2013 00:51:29 +0100 Subject: [ticket/11912] Check if content_guesser is supported with function_exists PHPBB3-11912 --- phpBB/phpbb/mimetype/content_guesser.php | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) (limited to 'phpBB/phpbb') diff --git a/phpBB/phpbb/mimetype/content_guesser.php b/phpBB/phpbb/mimetype/content_guesser.php index 60e5a905e2..2d74582a21 100644 --- a/phpBB/phpbb/mimetype/content_guesser.php +++ b/phpBB/phpbb/mimetype/content_guesser.php @@ -20,7 +20,7 @@ class content_guesser extends guesser_base */ public function is_supported() { - return true; + return function_exists('mime_content_type'); } /** @@ -28,9 +28,6 @@ class content_guesser extends guesser_base */ public function guess($file, $file_name = '') { - if (function_exists('mime_content_type')) - { - return mime_content_type($file); - } + return mime_content_type($file); } } -- cgit v1.2.1 From 0d4bf3ff45a76dcb763c76502944aa7bf78b690b Mon Sep 17 00:00:00 2001 From: Marc Alexander Date: Mon, 25 Nov 2013 13:12:08 +0100 Subject: [ticket/11842] Use type map for updating avatar types in database PHPBB3-11842 --- .../phpbb/db/migration/data/v310/avatar_types.php | 51 ++++++++++------------ 1 file changed, 23 insertions(+), 28 deletions(-) (limited to 'phpBB/phpbb') diff --git a/phpBB/phpbb/db/migration/data/v310/avatar_types.php b/phpBB/phpbb/db/migration/data/v310/avatar_types.php index 439e20889c..5750a43ddd 100644 --- a/phpBB/phpbb/db/migration/data/v310/avatar_types.php +++ b/phpBB/phpbb/db/migration/data/v310/avatar_types.php @@ -11,6 +11,15 @@ namespace phpbb\db\migration\data\v310; class avatar_types extends \phpbb\db\migration\migration { + /** + * @var avatar type map + */ + protected $avatar_type_map = array( + AVATAR_UPLOAD => 'avatar.driver.upload', + AVATAR_REMOTE => 'avatar.driver.remote', + AVATAR_GALLERY => 'avatar.driver.local', + ); + static public function depends_on() { return array( @@ -29,37 +38,23 @@ class avatar_types extends \phpbb\db\migration\migration public function update_user_avatar_type() { - $sql = 'UPDATE ' . $this->table_prefix . "users - SET user_avatar_type = 'avatar.driver.upload' - WHERE user_avatar_type = " . AVATAR_UPLOAD; - $this->db->sql_query($sql); - - $sql = 'UPDATE ' . $this->table_prefix . "users - SET user_avatar_type = 'avatar.driver.remote' - WHERE user_avatar_type = " . AVATAR_REMOTE; - $this->db->sql_query($sql); - - $sql = 'UPDATE ' . $this->table_prefix . "users - SET user_avatar_type = 'avatar.driver.local' - WHERE user_avatar_type = " . AVATAR_GALLERY; - $this->db->sql_query($sql); + foreach ($this->avatar_type_map as $old => $new) + { + $sql = 'UPDATE ' . $this->table_prefix . "users + SET user_avatar_type = '$new' + WHERE user_avatar_type = $old"; + $this->db->sql_query($sql); + } } public function update_group_avatar_type() { - $sql = 'UPDATE ' . $this->table_prefix . "groups - SET group_avatar_type = 'avatar.driver.upload' - WHERE group_avatar_type = " . AVATAR_UPLOAD; - $this->db->sql_query($sql); - - $sql = 'UPDATE ' . $this->table_prefix . "groups - SET group_avatar_type = 'avatar.driver.remote' - WHERE group_avatar_type = " . AVATAR_REMOTE; - $this->db->sql_query($sql); - - $sql = 'UPDATE ' . $this->table_prefix . "groups - SET group_avatar_type = 'avatar.driver.local' - WHERE group_avatar_type = " . AVATAR_GALLERY; - $this->db->sql_query($sql); + foreach ($this->avatar_type_map as $old => $new) + { + $sql = 'UPDATE ' . $this->table_prefix . "groups + SET group_avatar_type = '$new' + WHERE group_avatar_type = $old"; + $this->db->sql_query($sql); + } } } -- cgit v1.2.1 From 53be0a4432aa04b916c7e9d08785f97d8e6eb355 Mon Sep 17 00:00:00 2001 From: Marc Alexander Date: Wed, 4 Dec 2013 23:40:38 +0100 Subject: [ticket/12058] Add missing apostrophe to avatar_types migration queries PHPBB3-12058 --- phpBB/phpbb/db/migration/data/v310/avatar_types.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'phpBB/phpbb') diff --git a/phpBB/phpbb/db/migration/data/v310/avatar_types.php b/phpBB/phpbb/db/migration/data/v310/avatar_types.php index 5750a43ddd..bdbdccf0c5 100644 --- a/phpBB/phpbb/db/migration/data/v310/avatar_types.php +++ b/phpBB/phpbb/db/migration/data/v310/avatar_types.php @@ -42,7 +42,7 @@ class avatar_types extends \phpbb\db\migration\migration { $sql = 'UPDATE ' . $this->table_prefix . "users SET user_avatar_type = '$new' - WHERE user_avatar_type = $old"; + WHERE user_avatar_type = '$old'"; $this->db->sql_query($sql); } } @@ -53,7 +53,7 @@ class avatar_types extends \phpbb\db\migration\migration { $sql = 'UPDATE ' . $this->table_prefix . "groups SET group_avatar_type = '$new' - WHERE group_avatar_type = $old"; + WHERE group_avatar_type = '$old'"; $this->db->sql_query($sql); } } -- cgit v1.2.1