]> CyberLeo.Net >> Repos - Github/YOURLS.git/blob - user/plugins/random-bg/plugin.php
Prevent full path disclosure in case of direct calls. Fixes issue 646.
[Github/YOURLS.git] / user / plugins / random-bg / plugin.php
1 <?php\r
2 /*\r
3 Plugin Name: Random Backgrounds\r
4 Plugin URI: http://yourls.org/\r
5 Description: Pretty random background patterns\r
6 Version: 1.0\r
7 Author: Ozh\r
8 Author URI: http://ozh.org/\r
9 */\r
10 \r
11 // No direct call\r
12 if( !defined( 'YOURLS_ABSPATH' ) ) die();\r
13 \r
14 // Add the inline style\r
15 yourls_add_action( 'html_head', 'ozh_yourls_randombg' );\r
16 function ozh_yourls_randombg() {\r
17         $bg = glob( dirname( __FILE__ ).'/img/*png' );\r
18         $url = yourls_plugin_url( dirname( __FILE__ ) );\r
19         $rnd = yourls_plugin_url( $bg[ mt_rand( 0, count( $bg ) - 1 ) ] );\r
20         echo <<<CSS\r
21 <style type="text/css">\r
22                 body {background:#e3f3ff url($rnd) repeat;}\r
23         </style>\r
24 \r
25 CSS;\r
26 }\r
27 \r