WordPress.org

Plugin Directory

Changeset 556497


Ignore:
Timestamp:
06/12/12 06:04:29 (23 months ago)
Author:
coffee2code
Message:
  • Update to v1.7
  • Use DIRECTORY_SEPARATOR instead of hardcoding '/' when determining absolute path
  • Properly escape the attributes for the link markup
  • preg_quote() the extensions
  • Cast $exclusions arg to array before use
  • Re-license as GPLv2 or later (from X11)
  • Add 'License' and 'License URI' header tags to readme.txt and plugin file
  • Minor code reformatting (spacing)
  • Remove ending PHP close tag
  • Note compatibility through WP 3.4+
  • Drop support for versions of WP older than 2.8
Location:
random-file
Files:
2 edited
3 copied

Legend:

Unmodified
Added
Removed
  • random-file/tags/1.7/random-file.php

    r475202 r556497  
    33 * @package Random_File 
    44 * @author Scott Reilly 
    5  * @version 1.6.2 
     5 * @version 1.7 
    66 */ 
    77/* 
    88Plugin Name: Random File 
    9 Version: 1.6.2 
     9Version: 1.7 
    1010Plugin URI: http://coffee2code.com/wp-plugins/random-file/ 
    1111Author: Scott Reilly 
    12 Author URI: http://coffee2code.com 
     12Author URI: http://coffee2code.com/ 
     13License: GPLv2 or later 
     14License URI: http://www.gnu.org/licenses/gpl-2.0.html 
    1315Description: Retrieve the name, path, or link to a randomly chosen file or files in a specified directory. 
    1416 
    15 Compatible with WordPress 1.5+, 2.0+, 2.1+, 2.2+, 2.3+, 2.5+, 2.6+, 2.7+, 2.8+, 2.9+, 3.0+, 3.1+, 3.2+, 3.3+. 
     17Compatible with WordPress 2.8 through 3.4+. 
    1618 
    1719=>> Read the accompanying readme.txt file for instructions and documentation. 
     
    2830 
    2931/* 
    30 Copyright (c) 2004-2012 by Scott Reilly (aka coffee2code) 
     32    Copyright (c) 2004-2012 by Scott Reilly (aka coffee2code) 
    3133 
    32 Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation 
    33 files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, 
    34 modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the 
    35 Software is furnished to do so, subject to the following conditions: 
     34    This program is free software; you can redistribute it and/or 
     35    modify it under the terms of the GNU General Public License 
     36    as published by the Free Software Foundation; either version 2 
     37    of the License, or (at your option) any later version. 
    3638 
    37 The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. 
     39    This program is distributed in the hope that it will be useful, 
     40    but WITHOUT ANY WARRANTY; without even the implied warranty of 
     41    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the 
     42    GNU General Public License for more details. 
    3843 
    39 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES 
    40 OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE 
    41 LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR 
    42 IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 
     44    You should have received a copy of the GNU General Public License 
     45    along with this program; if not, write to the Free Software 
     46    Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA. 
    4347*/ 
    4448 
     
    8387 
    8488    if ( ! empty( $extensions ) ) 
    85         $pattern .= '\.(' . implode( '|', explode( ' ', $extensions ) ) . ')'; 
     89        $pattern .= '\.(' . preg_quote( implode( '|', explode( ' ', $extensions ) ), '/' ) . ')'; 
    8690    $pattern .= '$/i'; 
    8791 
     
    9599        return; 
    96100 
    97     $exclusions = empty( $exclusions ) ? array() : array_map( 'basename', $exclusions ); 
     101    $exclusions = empty( $exclusions ) ? array() : array_map( 'basename', (array) $exclusions ); 
    98102 
    99103    while ( false != ( $file = readdir( $handle ) ) ) { 
     
    121125 
    122126    if ( 'absolute' == $reftype ) 
    123         return $abs_dir . '/' . $random_file;   /* could also do realpath($random_file); */ 
     127        return $abs_dir . DIRECTORY_SEPARATOR . $random_file;   /* could also do realpath($random_file); */ 
    124128 
    125129    if ( 'filename' == $reftype ) 
     
    127131 
    128132    if ( 'hyperlink' == $reftype ) { 
    129         $url = get_option('siteurl') . '/' . $dir . $random_file; 
    130         return "<a href='$url' title='$random_filename'>$random_file</a>"; 
     133        $url = get_option( 'siteurl' ) . '/' . $dir . $random_file; 
     134        return '<a href="' . esc_url( $url ) . '" title="' . esc_attr( $random_filename ) . '">' . $random_file . '</a>'; 
    131135    } 
    132136 
     
    134138    preg_match( "/^(https?:\/\/)?([^\/]+)\/?(.+)?$/", get_option( 'siteurl' ), $matches ); 
    135139    $relpath = isset( $matches[3] ) ? '/' . $matches[3] : ''; 
     140 
    136141    return $relpath . '/' . $dir . $random_file; 
    137142} //end c2c_random_file() 
     
    174179add_filter( 'c2c_random_files', 'c2c_random_files', 10, 5 ); 
    175180endif; 
    176 ?> 
  • random-file/tags/1.7/readme.txt

    r475202 r556497  
    33Donate link: http://coffee2code.com/donate 
    44Tags: random, file, coffee2code 
    5 Requires at least: 1.5 
    6 Tested up to: 3.3 
    7 Stable tag: 1.6.2 
    8 Version: 1.6.2 
     5License: GPLv2 or later 
     6License URI: http://www.gnu.org/licenses/gpl-2.0.html 
     7Requires at least: 2.8 
     8Tested up to: 3.4 
     9Stable tag: 1.7 
     10Version: 1.7 
    911 
    1012Retrieve the name, path, or link to a randomly chosen file or files in a specified directory. 
     
    181183 
    182184== Changelog == 
     185 
     186= 1.7 = 
     187* Use DIRECTORY_SEPARATOR instead of hardcoding '/' when determining absolute path 
     188* Properly escape the attributes for the link markup 
     189* preg_quote() the extensions 
     190* Cast $exclusions arg to array before use 
     191* Re-license as GPLv2 or later (from X11) 
     192* Add 'License' and 'License URI' header tags to readme.txt and plugin file 
     193* Minor code reformatting (spacing) 
     194* Remove ending PHP close tag 
     195* Note compatibility through WP 3.4+ 
     196* Drop support for versions of WP older than 2.8 
    183197 
    184198= 1.6.2 = 
     
    239253== Upgrade Notice == 
    240254 
     255= 1.7 = 
     256Recommended minor update: improved compatibility and data sanitization; noted compatibility through WP 3.4+; explicitly stated license 
     257 
    241258= 1.6.2 = 
    242259Trivial update: noted compatibility through WP 3.3+ 
  • random-file/trunk/random-file.php

    r475202 r556497  
    33 * @package Random_File 
    44 * @author Scott Reilly 
    5  * @version 1.6.2 
     5 * @version 1.7 
    66 */ 
    77/* 
    88Plugin Name: Random File 
    9 Version: 1.6.2 
     9Version: 1.7 
    1010Plugin URI: http://coffee2code.com/wp-plugins/random-file/ 
    1111Author: Scott Reilly 
    12 Author URI: http://coffee2code.com 
     12Author URI: http://coffee2code.com/ 
     13License: GPLv2 or later 
     14License URI: http://www.gnu.org/licenses/gpl-2.0.html 
    1315Description: Retrieve the name, path, or link to a randomly chosen file or files in a specified directory. 
    1416 
    15 Compatible with WordPress 1.5+, 2.0+, 2.1+, 2.2+, 2.3+, 2.5+, 2.6+, 2.7+, 2.8+, 2.9+, 3.0+, 3.1+, 3.2+, 3.3+. 
     17Compatible with WordPress 2.8 through 3.4+. 
    1618 
    1719=>> Read the accompanying readme.txt file for instructions and documentation. 
     
    2830 
    2931/* 
    30 Copyright (c) 2004-2012 by Scott Reilly (aka coffee2code) 
     32    Copyright (c) 2004-2012 by Scott Reilly (aka coffee2code) 
    3133 
    32 Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation 
    33 files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, 
    34 modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the 
    35 Software is furnished to do so, subject to the following conditions: 
     34    This program is free software; you can redistribute it and/or 
     35    modify it under the terms of the GNU General Public License 
     36    as published by the Free Software Foundation; either version 2 
     37    of the License, or (at your option) any later version. 
    3638 
    37 The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. 
     39    This program is distributed in the hope that it will be useful, 
     40    but WITHOUT ANY WARRANTY; without even the implied warranty of 
     41    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the 
     42    GNU General Public License for more details. 
    3843 
    39 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES 
    40 OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE 
    41 LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR 
    42 IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 
     44    You should have received a copy of the GNU General Public License 
     45    along with this program; if not, write to the Free Software 
     46    Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA. 
    4347*/ 
    4448 
     
    8387 
    8488    if ( ! empty( $extensions ) ) 
    85         $pattern .= '\.(' . implode( '|', explode( ' ', $extensions ) ) . ')'; 
     89        $pattern .= '\.(' . preg_quote( implode( '|', explode( ' ', $extensions ) ), '/' ) . ')'; 
    8690    $pattern .= '$/i'; 
    8791 
     
    9599        return; 
    96100 
    97     $exclusions = empty( $exclusions ) ? array() : array_map( 'basename', $exclusions ); 
     101    $exclusions = empty( $exclusions ) ? array() : array_map( 'basename', (array) $exclusions ); 
    98102 
    99103    while ( false != ( $file = readdir( $handle ) ) ) { 
     
    121125 
    122126    if ( 'absolute' == $reftype ) 
    123         return $abs_dir . '/' . $random_file;   /* could also do realpath($random_file); */ 
     127        return $abs_dir . DIRECTORY_SEPARATOR . $random_file;   /* could also do realpath($random_file); */ 
    124128 
    125129    if ( 'filename' == $reftype ) 
     
    127131 
    128132    if ( 'hyperlink' == $reftype ) { 
    129         $url = get_option('siteurl') . '/' . $dir . $random_file; 
    130         return "<a href='$url' title='$random_filename'>$random_file</a>"; 
     133        $url = get_option( 'siteurl' ) . '/' . $dir . $random_file; 
     134        return '<a href="' . esc_url( $url ) . '" title="' . esc_attr( $random_filename ) . '">' . $random_file . '</a>'; 
    131135    } 
    132136 
     
    134138    preg_match( "/^(https?:\/\/)?([^\/]+)\/?(.+)?$/", get_option( 'siteurl' ), $matches ); 
    135139    $relpath = isset( $matches[3] ) ? '/' . $matches[3] : ''; 
     140 
    136141    return $relpath . '/' . $dir . $random_file; 
    137142} //end c2c_random_file() 
     
    174179add_filter( 'c2c_random_files', 'c2c_random_files', 10, 5 ); 
    175180endif; 
    176 ?> 
  • random-file/trunk/readme.txt

    r475202 r556497  
    33Donate link: http://coffee2code.com/donate 
    44Tags: random, file, coffee2code 
    5 Requires at least: 1.5 
    6 Tested up to: 3.3 
    7 Stable tag: 1.6.2 
    8 Version: 1.6.2 
     5License: GPLv2 or later 
     6License URI: http://www.gnu.org/licenses/gpl-2.0.html 
     7Requires at least: 2.8 
     8Tested up to: 3.4 
     9Stable tag: 1.7 
     10Version: 1.7 
    911 
    1012Retrieve the name, path, or link to a randomly chosen file or files in a specified directory. 
     
    181183 
    182184== Changelog == 
     185 
     186= 1.7 = 
     187* Use DIRECTORY_SEPARATOR instead of hardcoding '/' when determining absolute path 
     188* Properly escape the attributes for the link markup 
     189* preg_quote() the extensions 
     190* Cast $exclusions arg to array before use 
     191* Re-license as GPLv2 or later (from X11) 
     192* Add 'License' and 'License URI' header tags to readme.txt and plugin file 
     193* Minor code reformatting (spacing) 
     194* Remove ending PHP close tag 
     195* Note compatibility through WP 3.4+ 
     196* Drop support for versions of WP older than 2.8 
    183197 
    184198= 1.6.2 = 
     
    239253== Upgrade Notice == 
    240254 
     255= 1.7 = 
     256Recommended minor update: improved compatibility and data sanitization; noted compatibility through WP 3.4+; explicitly stated license 
     257 
    241258= 1.6.2 = 
    242259Trivial update: noted compatibility through WP 3.3+ 
Note: See TracChangeset for help on using the changeset viewer.