PluginProbe
Advanced iFrame / 1.3
Advanced iFrame v1.3
trunk 1.3 2.1 2024.5 2025.10 2025.2 2025.6 2026.0 3.0
advanced-iframe / advanced-iframe.php

advanced-iframe.php in Advanced iFrame 1.3, at advanced-iframe.php

203 lines 10.1 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 /*
3 Plugin Name: Advanced iframe
4 Plugin URI: http://www.tinywebgallery.com/blog/advanced-iframe
5 Version: 1.3
6 Author: Michael Dempfle
7 Author URI: http://www.tinywebgallery.com
8 Description: This plugin includes any webpage as shortcode in an advanced iframe.
9 This program is free software; you can redistribute it and/or modify
10 it under the terms of the GNU General Public License as published by
11 the Free Software Foundation; either version 2 of the License, or
12 (at your option) any later version.
13 This program is distributed in the hope that it will be useful,
14 but WITHOUT ANY WARRANTY; without even the implied warranty of
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 GNU General Public License for more details.
17 You should have received a copy of the GNU General Public License
18 along with this program; if not, write to the Free Software
19 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
20 */
21 if (!class_exists("advancediFrame")) {
22 class advancediFrame {
23 var $adminOptionsName = "advancediFrameAdminOptions";
24
25 //
26 // class constructor
27 //
28 function advancediFrame() {
29 }
30
31 function init() {
32 $this->getAdminOptions();
33 }
34
35 function activate() {
36 $this->getAdminOptions();
37 }
38
39 function iframe_defaults() {
40 $iframeAdminOptions = array(
41 'securitykey' => sha1(session_id()),
42 'src' => 'http://www.tinywebgallery.com', 'width' => '100%',
43 'height' => '600', 'scrolling' => 'no', 'marginwidth' => '0', 'marginheight' => '0',
44 'frameborder' => '0', 'transparency' => 'true', 'content_id' => '', 'content_styles' => '',
45 'hide_elements' => '', 'class' => '', 'shortcode_attributes' => 'true', 'url_forward_parameter' => '');
46 return $iframeAdminOptions;
47 }
48
49 function getAdminOptions() {
50 $iframeAdminOptions = advancediFrame::iframe_defaults();
51 $devOptions = get_option("advancediFrameAdminOptions");
52 if (!empty($devOptions)) {
53 foreach ($devOptions as $key => $option)
54 $iframeAdminOptions[$key] = $option;
55 }
56 update_option("advancediFrameAdminOptions", $iframeAdminOptions);
57 return $iframeAdminOptions;
58 }
59
60 function loadLanguage() {
61 load_plugin_textdomain('advanced-iframe', false, dirname(plugin_basename(__FILE__)) . '/languages/');
62 wp_enqueue_script('jquery');
63 }
64
65 /* CSS for the admin area */
66 function addAdminHeaderCode() {
67 echo '<link type="text/css" rel="stylesheet" href="' . get_bloginfo('wpurl') . '/wp-content/plugins/advanced-iframe/css/twg.css" />' . "\n";
68
69 }
70
71 function param($param, $content = null) {
72 $value = isset($_GET[$param]) ? $_GET[$param] : '';
73 return esc_html($value);
74 }
75
76 function do_iframe_script($atts) {
77 $options = get_option("advancediFrameAdminOptions");
78 // defaults
79 extract(array('securitykey' => 'not set',
80 'src' => $options['src'], 'height' => $options['height'], 'width' => $options['width'], 'frameborder' => $options['frameborder'],
81 'scrolling' => $options['scrolling'], 'marginheight' => $options['marginheight'], 'marginwidth' => $options['marginwidth'],
82 'transparency' => $options['transparency'], 'content_id' => $options['content_id'],
83 'content_styles' => $options['content_styles'], 'hide_elements' => $options['hide_elements'],
84 'class' => $options['class'], 'url_forward_parameter' => $options['url_forward_parameter'], $atts));
85 // read the shortcode attributes
86 if ($options['shortcode_attributes'] == 'true') {
87 extract(shortcode_atts(array('securitykey' => 'not set',
88 'src' => $options['src'], 'height' => $options['height'], 'width' => $options['width'], 'frameborder' => $options['frameborder'],
89 'scrolling' => $options['scrolling'], 'marginheight' => $options['marginheight'], 'marginwidth' => $options['marginwidth'],
90 'transparency' => $options['transparency'], 'content_id' => $options['content_id'],
91 'content_styles' => $options['content_styles'], 'hide_elements' => $options['hide_elements'],
92 'class' => $options['class'], 'url_forward_parameter' => $options['url_forward_parameter']), $atts));
93 } else {
94
95 // only the secrity key is read.
96 extract(shortcode_atts(array('securitykey' => 'not set'), $atts));
97 }
98
99 echo '<link type="text/css" rel="stylesheet" href="' . get_bloginfo('wpurl') . '/wp-content/plugins/advanced-iframe/css/ai.css" />' . "\n";
100 if ($options['securitykey'] != $securitykey) {
101 echo '<div class="errordiv">' . __('An invalid security key was specified. Please use at least the following shortcode:<br>[advanced_iframe securitykey="&lt;your security key - see settings&gt;"]', 'advanced-iframe') . '</div>';
102 return;
103 } else {
104
105 // add parameters
106 if ($url_forward_parameter != '') {
107 $sep = "&amp;";
108 if (strpos($src, '?') === false) {
109 $sep = '?';
110 }
111 $parameters = explode(",", $url_forward_parameter);
112 foreach ($parameters as $parameter) {
113 $read_param_esc = $this->param($parameter);
114 if ($read_param_esc != '') {
115 $src .= $sep . $parameter . "=" . $read_param_esc;
116 $sep = "&amp;";
117 }
118 }
119 }
120
121 $html = '';
122
123 if ((!empty($content_id) && !empty($content_styles))
124 || !empty($hide_elements)) {
125 $html .= "<script>
126 jQuery(document).ready(function() {";
127 if (!empty($hide_elements)) {
128 $html .= "jQuery('" . esc_html($hide_elements) . "').css('display', 'none');";
129 }
130 if (!empty($content_id)) {
131 $elements = esc_html($content_id); // this field should not have a problem if they are encoded.
132 $values = esc_html($content_styles); // this field style should not have a problem if they are encoded.
133 $elementArray = explode("|", $elements);
134 $valuesArray = explode("|", $values);
135 if (count($elementArray) != count($valuesArray)) {
136 echo '<div class="errordiv">' . __('Configuration error: The attributes content_id and content_styles have to have the amount of value sets separated by |.', 'advanced-iframe') . '</div>';
137 return;
138 } else {
139 for ($x = 0; $x < count($elementArray); ++$x) {
140 $valuesArrayPairs = explode(";", trim($valuesArray[$x], " ;:"));
141 for ($y = 0; $y < count($valuesArrayPairs); ++$y) {
142 $elements = explode(":", $valuesArrayPairs[$y]);
143 $html .= "jQuery('" . $elementArray[$x] . "').css('" . $elements[0] . "', '" . $elements[1] . "');";
144 }
145 }
146 }
147 }
148 $html .= " });
149 </script>";
150 }
151 $html .= "<iframe id='advanced_iframe' src='" . $src . "' width='" . esc_html($width) . "' height='" . esc_html($height) . "' scrolling='" . esc_html($scrolling) . "' ";
152 if (!empty ($marginwidth)) {
153 $html .= " marginwidth='" . esc_html($marginwidth) . "' ";
154 }
155 if (!empty ($marginheight)) {
156 $html .= " marginheight='" . esc_html($marginheight) . "' ";
157 }
158 if ($frameborder != '') {
159 $html .= " frameborder='" . esc_html($frameborder) . "' ";
160 }
161 if (!empty ($transparency)) {
162 $html .= " allowtransparency='" . esc_html($transparency) . "' ";
163 }
164 if (!empty ($class)) {
165 $html .= " class='" . esc_html($class) . "' ";
166 }
167
168 $html .= "></iframe>\n ";
169 }
170 return $html;
171 }
172
173 function printAdminPage() {
174 require_once('advanced-iframe-admin-page.php');
175 }
176 }
177 }
178 // setup new instance of plugin
179 if (class_exists("advancediFrame")) {
180 $cons_advancediFrame = new advancediFrame();
181 }
182 //Actions and Filters
183 if (isset($cons_advancediFrame)) {
184 //Initialize the admin panel
185 if (!function_exists("advancediFrame_ap")) {
186 function advancediFrame_ap() {
187 global $cons_advancediFrame;
188 if (!isset($cons_advancediFrame)) {
189 return;
190 }
191 $options = $cons_advancediFrame->getAdminOptions();
192 if (function_exists('add_options_page')) {
193 add_options_page('Advanced iFrame', 'Advanced iFrame', 'manage_options', basename(__FILE__), array(&$cons_advancediFrame, 'printAdminPage'));
194 }
195 }
196 }
197 add_action('admin_menu', 'advancediFrame_ap', 1); //admin page
198 add_action('init', array(&$cons_advancediFrame, 'loadLanguage'), 1); // add languages
199 add_action('admin_head', array(&$cons_advancediFrame, 'addAdminHeaderCode'), 99); // load css
200 add_shortcode('advanced_iframe', array(&$cons_advancediFrame, 'do_iframe_script'), 1); // setup shortcode [twg]
201 register_activation_hook(__FILE__, array(&$cons_advancediFrame, 'activate'));
202 }
203 ?>