├── package.json ├── support └── swfobject │ ├── expressInstall.swf │ └── swfobject.js ├── widgets └── bb_content │ └── shortcodes │ ├── bb_flash_large.png │ ├── bb_flash_small.png │ └── bb_flash.php └── README.md /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "id" : "1", 3 | "version" : "1.3", 4 | "files" : { 5 | "support/*" : "support", 6 | "widgets/*" : "widgets" 7 | } 8 | } 9 | -------------------------------------------------------------------------------- /support/swfobject/expressInstall.swf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cubiclesoft/barebones-cms-shortcode-bb_flash/master/support/swfobject/expressInstall.swf -------------------------------------------------------------------------------- /widgets/bb_content/shortcodes/bb_flash_large.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cubiclesoft/barebones-cms-shortcode-bb_flash/master/widgets/bb_content/shortcodes/bb_flash_large.png -------------------------------------------------------------------------------- /widgets/bb_content/shortcodes/bb_flash_small.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cubiclesoft/barebones-cms-shortcode-bb_flash/master/widgets/bb_content/shortcodes/bb_flash_small.png -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | Barebones CMS - Flash Object (SWF) shortcode 2 | ============================================ 3 | 4 | Adds a new Shortcode to the content editor that makes it easy to embed Flash objects (SWF). 5 | 6 | This is a very general-purpose Shortcode and can insert screencasts, advertisements, videos, and anything else that is pure Flash content. To mix Flash and Javascript, combine this Shortcode with the Code widget. 7 | 8 | Leverages the third-party library SWFObject (ver 2.2). (http://code.google.com/p/swfobject/) 9 | 10 | License 11 | ------- 12 | 13 | Same as Barebones CMS. MIT or LGPL (your choice). 14 | 15 | Automated Installation 16 | ---------------------- 17 | 18 | To install this shortcode, use the built-in Barebones CMS extension installer. 19 | 20 | Once installed, click "Configure Security" from within the content widget options list to set up the new shortcode's security options. 21 | 22 | Manual Installation 23 | ------------------- 24 | 25 | Upload the 'support' and 'widgets' subdirectories to your Barebones CMS installation. 26 | 27 | Once installed, click "Configure Security" from within the content widget options list to set up the new shortcode's security options. 28 | -------------------------------------------------------------------------------- /support/swfobject/swfobject.js: -------------------------------------------------------------------------------- 1 | /* SWFObject v2.2 2 | is released under the MIT License 3 | */ 4 | var swfobject=function(){var D="undefined",r="object",S="Shockwave Flash",W="ShockwaveFlash.ShockwaveFlash",q="application/x-shockwave-flash",R="SWFObjectExprInst",x="onreadystatechange",O=window,j=document,t=navigator,T=false,U=[h],o=[],N=[],I=[],l,Q,E,B,J=false,a=false,n,G,m=true,M=function(){var aa=typeof j.getElementById!=D&&typeof j.getElementsByTagName!=D&&typeof j.createElement!=D,ah=t.userAgent.toLowerCase(),Y=t.platform.toLowerCase(),ae=Y?/win/.test(Y):/win/.test(ah),ac=Y?/mac/.test(Y):/mac/.test(ah),af=/webkit/.test(ah)?parseFloat(ah.replace(/^.*webkit\/(\d+(\.\d+)?).*$/,"$1")):false,X=!+"\v1",ag=[0,0,0],ab=null;if(typeof t.plugins!=D&&typeof t.plugins[S]==r){ab=t.plugins[S].description;if(ab&&!(typeof t.mimeTypes!=D&&t.mimeTypes[q]&&!t.mimeTypes[q].enabledPlugin)){T=true;X=false;ab=ab.replace(/^.*\s+(\S+\s+\S+$)/,"$1");ag[0]=parseInt(ab.replace(/^(.*)\..*$/,"$1"),10);ag[1]=parseInt(ab.replace(/^.*\.(.*)\s.*$/,"$1"),10);ag[2]=/[a-zA-Z]/.test(ab)?parseInt(ab.replace(/^.*[a-zA-Z]+(.*)$/,"$1"),10):0}}else{if(typeof O.ActiveXObject!=D){try{var ad=new ActiveXObject(W);if(ad){ab=ad.GetVariable("$version");if(ab){X=true;ab=ab.split(" ")[1].split(",");ag=[parseInt(ab[0],10),parseInt(ab[1],10),parseInt(ab[2],10)]}}}catch(Z){}}}return{w3:aa,pv:ag,wk:af,ie:X,win:ae,mac:ac}}(),k=function(){if(!M.w3){return}if((typeof j.readyState!=D&&j.readyState=="complete")||(typeof j.readyState==D&&(j.getElementsByTagName("body")[0]||j.body))){f()}if(!J){if(typeof j.addEventListener!=D){j.addEventListener("DOMContentLoaded",f,false)}if(M.ie&&M.win){j.attachEvent(x,function(){if(j.readyState=="complete"){j.detachEvent(x,arguments.callee);f()}});if(O==top){(function(){if(J){return}try{j.documentElement.doScroll("left")}catch(X){setTimeout(arguments.callee,0);return}f()})()}}if(M.wk){(function(){if(J){return}if(!/loaded|complete/.test(j.readyState)){setTimeout(arguments.callee,0);return}f()})()}s(f)}}();function f(){if(J){return}try{var Z=j.getElementsByTagName("body")[0].appendChild(C("span"));Z.parentNode.removeChild(Z)}catch(aa){return}J=true;var X=U.length;for(var Y=0;Y0){for(var af=0;af0){var ae=c(Y);if(ae){if(F(o[af].swfVersion)&&!(M.wk&&M.wk<312)){w(Y,true);if(ab){aa.success=true;aa.ref=z(Y);ab(aa)}}else{if(o[af].expressInstall&&A()){var ai={};ai.data=o[af].expressInstall;ai.width=ae.getAttribute("width")||"0";ai.height=ae.getAttribute("height")||"0";if(ae.getAttribute("class")){ai.styleclass=ae.getAttribute("class")}if(ae.getAttribute("align")){ai.align=ae.getAttribute("align")}var ah={};var X=ae.getElementsByTagName("param");var ac=X.length;for(var ad=0;ad'}}aa.outerHTML='"+af+"";N[N.length]=ai.id;X=c(ai.id)}else{var Z=C(r);Z.setAttribute("type",q);for(var ac in ai){if(ai[ac]!=Object.prototype[ac]){if(ac.toLowerCase()=="styleclass"){Z.setAttribute("class",ai[ac])}else{if(ac.toLowerCase()!="classid"){Z.setAttribute(ac,ai[ac])}}}}for(var ab in ag){if(ag[ab]!=Object.prototype[ab]&&ab.toLowerCase()!="movie"){e(Z,ab,ag[ab])}}aa.parentNode.replaceChild(Z,aa);X=Z}}return X}function e(Z,X,Y){var aa=C("param");aa.setAttribute("name",X);aa.setAttribute("value",Y);Z.appendChild(aa)}function y(Y){var X=c(Y);if(X&&X.nodeName=="OBJECT"){if(M.ie&&M.win){X.style.display="none";(function(){if(X.readyState==4){b(Y)}else{setTimeout(arguments.callee,10)}})()}else{X.parentNode.removeChild(X)}}}function b(Z){var Y=c(Z);if(Y){for(var X in Y){if(typeof Y[X]=="function"){Y[X]=null}}Y.parentNode.removeChild(Y)}}function c(Z){var X=null;try{X=j.getElementById(Z)}catch(Y){}return X}function C(X){return j.createElement(X)}function i(Z,X,Y){Z.attachEvent(X,Y);I[I.length]=[Z,X,Y]}function F(Z){var Y=M.pv,X=Z.split(".");X[0]=parseInt(X[0],10);X[1]=parseInt(X[1],10)||0;X[2]=parseInt(X[2],10)||0;return(Y[0]>X[0]||(Y[0]==X[0]&&Y[1]>X[1])||(Y[0]==X[0]&&Y[1]==X[1]&&Y[2]>=X[2]))?true:false}function v(ac,Y,ad,ab){if(M.ie&&M.mac){return}var aa=j.getElementsByTagName("head")[0];if(!aa){return}var X=(ad&&typeof ad=="string")?ad:"screen";if(ab){n=null;G=null}if(!n||G!=X){var Z=C("style");Z.setAttribute("type","text/css");Z.setAttribute("media",X);n=aa.appendChild(Z);if(M.ie&&M.win&&typeof j.styleSheets!=D&&j.styleSheets.length>0){n=j.styleSheets[j.styleSheets.length-1]}G=X}if(M.ie&&M.win){if(n&&typeof n.addRule==r){n.addRule(ac,Y)}}else{if(n&&typeof j.createTextNode!=D){n.appendChild(j.createTextNode(ac+" {"+Y+"}"))}}}function w(Z,X){if(!m){return}var Y=X?"visible":"hidden";if(J&&c(Z)){c(Z).style.visibility=Y}else{v("#"+Z,"visibility:"+Y)}}function L(Y){var Z=/[\\\"<>\.;]/;var X=Z.exec(Y)!=null;return X&&typeof encodeURIComponent!=D?encodeURIComponent(Y):Y}var d=function(){if(M.ie&&M.win){window.attachEvent("onunload",function(){var ac=I.length;for(var ab=0;ab "Flash", 10 | "toolbaricon" => $g_fullurl . "/bb_flash_small.png", 11 | "mainicon" => $g_fullurl . "/bb_flash_large.png", 12 | "cache" => true, 13 | "security" => array( 14 | "" => array("Flash", "Defines who can add and edit Flash Objects (SWF)."), 15 | "local" => array("Local Flash", "Defines who can preview Flash Objects on the local server."), 16 | "remote" => array("Remote Flash", "Defines who can preview Flash Objects on remote servers.") 17 | ), 18 | "nextinstance" => 1 19 | ); 20 | 21 | // 'movie' and 'swliveconnect' don't make sense in this context. 22 | global $g_bb_content_shortcode_bb_flash_params; 23 | 24 | $g_bb_content_shortcode_bb_flash_params = array( 25 | "allowfullscreen" => array("" => true, "true" => true, "false" => true), 26 | "allownetworking" => array("" => true, "all" => true, "internal" => true, "none" => true), 27 | "allowscriptaccess" => array("" => true, "samedomain" => true, "always" => true, "never" => true), 28 | "base" => "", 29 | "bgcolor" => "", 30 | "devicefont" => array("" => true, "true" => true, "false" => true), 31 | "flashvars" => "", 32 | "loop" => array("" => true, "true" => true, "false" => true), 33 | "menu" => array("" => true, "true" => true, "false" => true), 34 | "play" => array("" => true, "true" => true, "false" => true), 35 | "quality" => array("" => true, "autolow" => true, "autohigh" => true, "low" => true, "medium" => true, "high" => true, "best" => true), 36 | "salign" => array("" => true, "t" => true, "l" => true, "r" => true, "b" => true, "tl" => true, "tr" => true, "bl" => true, "br" => true), 37 | "scale" => array("" => true, "showall" => true, "noborder" => true, "exactfit" => true), 38 | "seamlesstabbing" => array("" => true, "true" => true, "false" => true), 39 | "wmode" => array("" => true, "window" => true, "opaque" => true, "transparent" => true) 40 | ); 41 | 42 | class bb_content_shortcode_bb_flash extends BB_ContentShortcodeBase 43 | { 44 | private function GetInfo($sid) 45 | { 46 | global $bb_widget, $g_bb_content_shortcode_bb_flash_params; 47 | 48 | $info = $bb_widget->shortcodes[$sid]; 49 | if (!isset($info["src"])) $info["src"] = ""; 50 | if (!isset($info["width"])) $info["width"] = 0; 51 | if (!isset($info["height"])) $info["height"] = 0; 52 | if (!isset($info["minflashver"])) $info["minflashver"] = 5; 53 | if (!isset($info["alt"])) $info["alt"] = ""; 54 | if (!isset($info["opt-embed"])) $info["opt-embed"] = "static"; 55 | if (!isset($info["opt-expressinstall"])) $info["opt-expressinstall"] = true; 56 | foreach ($g_bb_content_shortcode_bb_flash_params as $param => $vals) 57 | { 58 | if (!isset($info["opt-param-" . $param])) $info["opt-param-" . $param] = ""; 59 | } 60 | if (!isset($info["opt-caption"])) $info["opt-caption"] = ""; 61 | if (!isset($info["opt-caption-width"])) $info["opt-caption-width"] = 0; 62 | if (!isset($info["opt-image"])) $info["opt-image"] = ""; 63 | if (!isset($info["opt-image-alt"])) $info["opt-image-alt"] = ""; 64 | 65 | return $info; 66 | } 67 | 68 | private function IsValidSWF($data, &$info) 69 | { 70 | if (substr($data, 0, 3) != "CWS" && substr($data, 0, 3) != "FWS") return false; 71 | 72 | // Attempt to automatically extract useful information. 73 | // [F|C]WS, Flash version, decompressed file size, (compressed data starts here) rectangle in twips (20 twips = 1 pixel). 74 | $info["minflashver"] = (string)ord(substr($data, 3, 1)); 75 | if (substr($data, 0, 3) == "FWS") 76 | { 77 | $data = substr($data, 8); 78 | } 79 | else if (substr($data, 0, 3) == "CWS" && function_exists("gzuncompress")) 80 | { 81 | $data = @gzuncompress(substr($data, 8)); 82 | if ($data === false) $data = ""; 83 | } 84 | else $data = ""; 85 | 86 | if ($data != "") 87 | { 88 | require_once ROOT_PATH . "/" . SUPPORT_PATH . "/bits.php"; 89 | 90 | $sbs = new StringBitStream; 91 | $sbs->Init($data); 92 | $numbits = $sbs->ReadBits(5); 93 | $x = $sbs->ReadBits($numbits); 94 | $x2 = $sbs->ReadBits($numbits); 95 | $y = $sbs->ReadBits($numbits); 96 | $y2 = $sbs->ReadBits($numbits); 97 | 98 | $info["width"] = (int)(($x2 - $x) / 20); 99 | $info["height"] = (int)(($y2 - $y) / 20); 100 | } 101 | 102 | return true; 103 | } 104 | 105 | public function GenerateShortcode($parent, $sid, $depth) 106 | { 107 | global $bb_widget, $g_bb_content_shortcodes, $g_bb_content_shortcode_bb_flash_params, $bb_page; 108 | 109 | $info = $this->GetInfo($sid); 110 | if ($info["src"] == "") return ""; 111 | 112 | $data = ""; 113 | if ($info["opt-caption"] != "") $data .= '
'; 114 | if ($parent !== false && (!$parent->IsShortcodeAllowed("bb_flash", BB_IsLocalURL($info["src"]) ? "local" : "remote") || ($info["opt-image"] != "" && !$parent->IsShortcodeAllowed("bb_flash", BB_IsLocalURL($info["opt-image"]) ? "local" : "remote")))) 115 | { 116 | $data .= '' . htmlspecialchars($info['; 117 | } 118 | else 119 | { 120 | $objectid = "flash-object-instance-" . $g_bb_content_shortcodes["bb_flash"]["nextinstance"]; 121 | $g_bb_content_shortcodes["bb_flash"]["nextinstance"]++; 122 | 123 | $bb_widget->use_premainjs = true; 124 | 125 | $js = $bb_widget->js; 126 | $js[ROOT_URL . "/" . SUPPORT_PATH . "/swfobject/swfobject.js"] = ROOT_PATH . "/" . SUPPORT_PATH . "/swfobject/swfobject.js"; 127 | if ($info["opt-image"] != "") 128 | { 129 | $js[ROOT_URL . "/" . SUPPORT_PATH . "/jquery-1.11.0.min.js"] = ROOT_PATH . "/" . SUPPORT_PATH . "/jquery-1.11.0.min.js"; 130 | $data .= "\""\n"; 131 | $data .= "
\n"; 132 | } 133 | $bb_widget->js = $js; 134 | 135 | if ($info["opt-embed"] == "static") 136 | { 137 | // Static publishing. 138 | $data .= "\n"; 139 | $data .= "\n"; 140 | $data .= "\n"; 141 | foreach ($g_bb_content_shortcode_bb_flash_params as $param => $vals) 142 | { 143 | if ($info["opt-param-" . $param] != "") $data .= "\n"; 144 | } 145 | $data .= "\n"; 146 | $data .= "\n"; 147 | $data .= "\n"; 148 | foreach ($g_bb_content_shortcode_bb_flash_params as $param => $vals) 149 | { 150 | if ($info["opt-param-" . $param] != "") $data .= "\n"; 151 | } 152 | $options = array( 153 | "doctype" => $bb_page["doctype"] 154 | ); 155 | $data .= "
\n" . BB_HTMLTransformForWYMEditor($info["alt"], $options) . "
\n"; 156 | $data .= "\n"; 157 | $data .= "
\n"; 158 | $data .= "\n"; 159 | $data .= "
\n"; 160 | } 161 | else if ($info["opt-embed"] == "dynamic") 162 | { 163 | // Dynamic publishing. 164 | $params = array(); 165 | foreach ($g_bb_content_shortcode_bb_flash_params as $param => $vals) 166 | { 167 | if ($info["opt-param-" . $param] != "") $params[] = "'" . BB_JSSafe($param) . "' : '" . BB_JSSafe($info["opt-param-" . $param]) . "'"; 168 | } 169 | $params = implode(", ", $params); 170 | 171 | $data .= "\n"; 172 | $data .= "
\n"; 173 | $options = array( 174 | "doctype" => $bb_page["doctype"] 175 | ); 176 | $data .= "
\n" . BB_HTMLTransformForWYMEditor($info["alt"], $options) . "
\n"; 177 | $data .= "
\n"; 178 | } 179 | 180 | if ($info["opt-image"] != "") $data .= "
\n"; 181 | } 182 | if ($info["opt-caption"] != "") $data .= '
' . htmlspecialchars($info["opt-caption"]) . '
'; 183 | 184 | return $data; 185 | } 186 | 187 | public function ProcessShortcodeBBAction($parent) 188 | { 189 | global $bb_widget, $bb_widget_id, $bb_dir, $bb_pref_lang, $bb_revision_num, $bb_writeperms, $g_bb_content_shortcode_bb_flash_params; 190 | 191 | $info = $this->GetInfo($parent->GetSID()); 192 | 193 | if ($_REQUEST["sc_action"] == "bb_flash_upload_ajaxupload") 194 | { 195 | BB_RunPluginAction("pre_bb_content_shortcode_bb_flash_upload_ajaxupload"); 196 | 197 | // Confusing in this context but is the AJAX upload upload handler. 198 | $msg = BB_ValidateAJAXUpload(); 199 | if ($msg != "") 200 | { 201 | echo htmlspecialchars(BB_Translate($msg)); 202 | exit(); 203 | } 204 | 205 | // Use official magic numbers for the SWF format to determine the real content type. 206 | $data = file_get_contents($_FILES["Filedata"]["tmp_name"]); 207 | if (!$this->IsValidSWF($data, $info)) 208 | { 209 | echo htmlspecialchars(BB_Translate("Uploaded file is not a valid Flash Object file. Must be a SWF.")); 210 | exit(); 211 | } 212 | 213 | if (!is_dir($bb_dir . "/flash")) mkdir($bb_dir . "/flash", 0777, true); 214 | $dirfile = preg_replace('/\.+/', ".", preg_replace('/[^A-Za-z0-9_.\-]/', "_", $bb_pref_lang . "_" . ($bb_revision_num > -1 ? $bb_revision_num . "_" : "") . trim($_FILES["Filedata"]["name"]))); 215 | if ($dirfile == ".") $dirfile = ""; 216 | 217 | if ($dirfile == "") 218 | { 219 | echo htmlspecialchars(BB_Translate("A filename was not specified.")); 220 | exit(); 221 | } 222 | 223 | $pos = strrpos($dirfile, "."); 224 | if ($pos === false || substr($dirfile, $pos + 1) != "swf") $dirfile .= ".swf"; 225 | if (!@move_uploaded_file($_FILES["Filedata"]["tmp_name"], $bb_dir . "/flash/" . $dirfile)) 226 | { 227 | echo htmlspecialchars(BB_Translate("Unable to move temporary file to final location. Check the permissions of the target directory and destination file.")); 228 | exit(); 229 | } 230 | 231 | @chmod($bb_dir . "/flash/" . $dirfile, 0444 | $bb_writeperms); 232 | 233 | $info["src"] = "flash/" . $dirfile; 234 | if (!$parent->SaveShortcode($info)) 235 | { 236 | echo htmlspecialchars(BB_Translate("Unable to save the shortcode.")); 237 | exit(); 238 | } 239 | 240 | echo "OK"; 241 | 242 | BB_RunPluginAction("post_bb_content_shortcode_bb_flash_upload_ajaxupload"); 243 | } 244 | else if ($_REQUEST["sc_action"] == "bb_flash_upload_submit") 245 | { 246 | BB_RunPluginAction("pre_bb_content_shortcode_bb_flash_upload_submit"); 247 | 248 | $swfinfo = BB_IsValidURL($_REQUEST["url"], array("protocol" => "http")); 249 | if (!$swfinfo["success"]) BB_PropertyFormError($swfinfo["error"]); 250 | if (!$this->IsValidSWF($swfinfo["data"], $info)) BB_PropertyFormError("Uploaded file is not a valid Flash Object file. Must be a SWF."); 251 | 252 | $dirfile = preg_replace('/\.+/', ".", preg_replace('/[^A-Za-z0-9_.\-]/', "_", $_REQUEST["destfile"])); 253 | if ($dirfile == ".") $dirfile = ""; 254 | 255 | // Automatically calculate the new filename based on the URL. 256 | if ($dirfile == "") $dirfile = $bb_pref_lang . "_" . ($bb_revision_num > -1 ? $bb_revision_num . "_" : "") . BB_MakeFilenameFromURL($swfinfo["url"], "swf", false); 257 | 258 | if (!is_dir($bb_dir . "/flash")) mkdir($bb_dir . "/flash", 0777, true); 259 | if (BB_WriteFile($bb_dir . "/flash/" . $dirfile, $swfinfo["data"]) === false) BB_PropertyFormError("Unable to save the Flash file."); 260 | 261 | $info["src"] = "flash/" . $dirfile; 262 | if (!$parent->SaveShortcode($info)) BB_PropertyFormError("Unable to save the shortcode."); 263 | 264 | ?> 265 |
266 | 270 | CreateShortcodeUploader("", array(), "Configure Flash Object", "Flash Object", "Flash object", "*.swf", "Flash Files"); 277 | } 278 | else if ($_REQUEST["sc_action"] == "bb_flash_swap_image_upload_swfupload") 279 | { 280 | BB_RunPluginAction("pre_bb_content_shortcode_bb_flash_swap_image_upload_swfupload"); 281 | 282 | // Confusing in this context but is the SWFUpload upload handler. 283 | $msg = BB_ValidateSWFUpload(); 284 | if ($msg != "") 285 | { 286 | echo htmlspecialchars(BB_Translate($msg)); 287 | exit(); 288 | } 289 | 290 | // Use official magic numbers for each format to determine the real content type. 291 | $data = file_get_contents($_FILES["Filedata"]["tmp_name"]); 292 | $type = BB_GetImageType($data); 293 | if ($type != "gif" && $type != "jpg" && $type != "png") 294 | { 295 | echo htmlspecialchars(BB_Translate("Uploaded file is not a valid web image. Must be PNG, JPG, or GIF.")); 296 | exit(); 297 | } 298 | 299 | if (!is_dir($bb_dir . "/images")) mkdir($bb_dir . "/images", 0777, true); 300 | $dirfile = preg_replace('/\.+/', ".", preg_replace('/[^A-Za-z0-9_.\-]/', "_", $bb_pref_lang . "_" . ($bb_revision_num > -1 ? $bb_revision_num . "_" : "") . trim($_FILES["Filedata"]["name"]))); 301 | if ($dirfile == ".") $dirfile = ""; 302 | 303 | if ($dirfile == "") 304 | { 305 | echo htmlspecialchars(BB_Translate("A filename was not specified.")); 306 | exit(); 307 | } 308 | 309 | $pos = strrpos($dirfile, "."); 310 | if ($pos === false || substr($dirfile, $pos + 1) != $type) $dirfile .= "." . $type; 311 | if (!@move_uploaded_file($_FILES["Filedata"]["tmp_name"], $bb_dir . "/images/" . $dirfile)) 312 | { 313 | echo htmlspecialchars(BB_Translate("Unable to move temporary file to final location. Check the permissions of the target directory and destination file.")); 314 | exit(); 315 | } 316 | 317 | @chmod($bb_dir . "/images/" . $dirfile, 0444 | $bb_writeperms); 318 | 319 | $info["opt-image"] = "images/" . $dirfile; 320 | if (!$parent->SaveShortcode($info)) 321 | { 322 | echo htmlspecialchars(BB_Translate("Unable to save the shortcode.")); 323 | exit(); 324 | } 325 | 326 | echo "OK"; 327 | 328 | BB_RunPluginAction("post_bb_content_shortcode_bb_flash_swap_image_upload_swfupload"); 329 | } 330 | else if ($_REQUEST["sc_action"] == "bb_flash_swap_image_upload_submit") 331 | { 332 | BB_RunPluginAction("pre_bb_content_shortcode_bb_flash_swap_image_upload_submit"); 333 | 334 | $imginfo = BB_IsValidHTMLImage($_REQUEST["url"], array("protocol" => "http")); 335 | if (!$imginfo["success"]) BB_PropertyFormError($imginfo["error"]); 336 | 337 | $dirfile = preg_replace('/\.+/', ".", preg_replace('/[^A-Za-z0-9_.\-]/', "_", $_REQUEST["destfile"])); 338 | if ($dirfile == ".") $dirfile = ""; 339 | 340 | // Automatically calculate the new filename based on the URL. 341 | if ($dirfile == "") $dirfile = $bb_pref_lang . "_" . ($bb_revision_num > -1 ? $bb_revision_num . "_" : "") . BB_MakeFilenameFromURL($imginfo["url"], $imginfo["type"], false); 342 | 343 | if (!is_dir($bb_dir . "/images")) mkdir($bb_dir . "/images", 0777, true); 344 | if (BB_WriteFile($bb_dir . "/images/" . $dirfile, $imginfo["data"]) === false) BB_PropertyFormError("Unable to save the image."); 345 | 346 | $info["opt-image"] = "images/" . $dirfile; 347 | if (!$parent->SaveShortcode($info)) BB_PropertyFormError("Unable to save the shortcode."); 348 | 349 | ?> 350 |
351 | 355 | CreateShortcodeUploader("", array(), "Configure Flash Object Swap Image", "Image", "image", "*.png;*.jpg;*.gif", "Web Image Files"); 362 | } 363 | else if ($_REQUEST["sc_action"] == "bb_flash_alt_edit_load") 364 | { 365 | BB_RunPluginAction("pre_bb_content_shortcode_bb_flash_alt_edit_load"); 366 | 367 | echo rawurlencode(UTF8::ConvertToHTML($info["alt"])); 368 | 369 | BB_RunPluginAction("post_bb_content_shortcode_bb_flash_alt_edit_load"); 370 | } 371 | else if ($_REQUEST["sc_action"] == "bb_flash_alt_edit_save") 372 | { 373 | BB_RunPluginAction("pre_bb_content_shortcode_bb_flash_alt_edit_save"); 374 | 375 | $info["alt"] = BB_HTMLPurifyForWYMEditor($_REQUEST["content"], array()); 376 | 377 | if (!$parent->SaveShortcode($info)) echo htmlspecialchars(BB_Translate("Unable to save content. Try again.")); 378 | else 379 | { 380 | echo "OK\n"; 381 | echo ""; 382 | } 383 | 384 | BB_RunPluginAction("post_bb_content_shortcode_bb_flash_alt_edit_save"); 385 | } 386 | else if ($_REQUEST["sc_action"] == "bb_flash_alt_edit") 387 | { 388 | BB_RunPluginAction("pre_bb_content_shortcode_bb_flash_alt_edit"); 389 | 390 | ?> 391 | 418 | "http")); 436 | if ((!$swfinfo["success"] && function_exists("fsockopen")) || ($swfinfo["success"] && !$this->IsValidSWF($swfinfo["data"], $info))) BB_PropertyFormError("'Flash Object URL' field does not point to a valid Flash object file."); 437 | $info["src"] = $src; 438 | } 439 | 440 | // Handle the basic options. 441 | foreach ($g_bb_content_shortcode_bb_flash_params as $param => $vals) 442 | { 443 | $info["opt-param-" . $param] = (isset($_REQUEST["opt-param-" . $param]) && (is_string($vals) || isset($vals[$_REQUEST["opt-param-" . $param]])) ? $_REQUEST["opt-param-" . $param] : ""); 444 | } 445 | 446 | if (isset($_REQUEST["opt-param-flashvars"])) 447 | { 448 | $flashvars = explode("\n", Str::ReplaceNewlines("\n", $_REQUEST["opt-param-flashvars"])); 449 | foreach ($flashvars as $x => $flashvar) 450 | { 451 | $pos = strpos($flashvar, "="); 452 | if ($pos !== false) $flashvars[$x] = urlencode(str_replace("%3D", "=", substr($flashvar, 0, $pos))) . "=" . urlencode(substr($flashvar, $pos + 1)); 453 | else $flashvars[$x] = urlencode(str_replace("%3D", "=", $flashvar)); 454 | } 455 | $info["opt-param-flashvars"] = implode("&", $flashvars); 456 | } 457 | 458 | // Handle quick configuration. 459 | $data = $_REQUEST["quickconfig"]; 460 | if ($data != "") 461 | { 462 | require_once ROOT_PATH . "/" . SUPPORT_PATH . "/simple_html_dom.php"; 463 | 464 | $html = new simple_html_dom(); 465 | $html->load($data); 466 | $object = $html->find('object', 0); 467 | if (is_object($object)) 468 | { 469 | if (isset($object->codebase)) 470 | { 471 | $pos = strpos($object->codebase, "#version="); 472 | if ($pos !== false) $info["minflashver"] = str_replace(",", ".", substr($object->codebase, $pos + strlen("#version="))); 473 | } 474 | if (isset($object->width)) 475 | { 476 | $info["width"] = (int)$object->width; 477 | if ($info["width"] < 0) $info["width"] = 0; 478 | } 479 | if (isset($object->height)) 480 | { 481 | $info["height"] = (int)$object->height; 482 | if ($info["height"] < 0) $info["height"] = 0; 483 | } 484 | $rows = $object->children(); 485 | foreach ($rows as $row) 486 | { 487 | if ($row->tag == "param" && isset($row->name) && isset($row->value)) 488 | { 489 | $param = strtolower($row->name); 490 | $val = html_entity_decode($row->value); 491 | if ($param == "flashvars" || (isset($g_bb_content_shortcode_bb_flash_params[$param]) && (is_string($g_bb_content_shortcode_bb_flash_params[$param]) || isset($g_bb_content_shortcode_bb_flash_params[$param][$val])))) 492 | { 493 | $info["opt-param-" . $param] = $val; 494 | } 495 | } 496 | } 497 | } 498 | } 499 | 500 | $info["opt-embed"] = ($_REQUEST["opt-embed"] == "dynamic" ? "dynamic" : "static"); 501 | $info["opt-expressinstall"] = ($_REQUEST["opt-expressinstall"] == "enable"); 502 | $info["opt-caption"] = $_REQUEST["opt-caption"]; 503 | $info["opt-caption-width"] = (int)$_REQUEST["opt-caption-width"]; 504 | if ($info["opt-caption-width"] < 0) $info["opt-caption-width"] = 0; 505 | $src = $_REQUEST["opt-image"]; 506 | if ($info["opt-image"] != $src) 507 | { 508 | $imginfo = BB_IsValidHTMLImage($src, array("protocol" => "http")); 509 | if (!$imginfo["success"] && function_exists("fsockopen")) BB_PropertyFormError("'Swap Image URL' field does not point to a valid image file."); 510 | $info["opt-image"] = $src; 511 | } 512 | $info["opt-image-alt"] = $_REQUEST["opt-image-alt"]; 513 | 514 | if (!$parent->SaveShortcode($info)) BB_PropertyFormError("Unable to save the shortcode."); 515 | 516 | ?> 517 |
518 | 522 | "; 531 | $desc .= $parent->CreateShortcodePropertiesLink(BB_Translate("Upload/Transfer Flash File"), "bb_flash_upload"); 532 | $desc .= " | " . $parent->CreateShortcodePropertiesLink(BB_Translate("Upload/Transfer Swap Image"), "bb_flash_swap_image_upload"); 533 | $desc .= " | " . $parent->CreateShortcodePropertiesLink(BB_Translate("Edit Alternate Content"), "bb_flash_alt_edit", array(), "", true); 534 | 535 | $flashvars = explode("&", $info["opt-param-flashvars"]); 536 | foreach ($flashvars as $x => $flashvar) 537 | { 538 | $pos = strpos($flashvar, "="); 539 | if ($pos !== false) $flashvars[$x] = str_replace("=", "%3D", urldecode(substr($flashvar, 0, $pos))) . "=" . urldecode(substr($flashvar, $pos + 1)); 540 | else $flashvars[$x] = str_replace("=", "%3D", urldecode($flashvar)); 541 | } 542 | $flashvars = implode("\n", $flashvars); 543 | 544 | $options = array( 545 | "title" => "Configure Flash Object", 546 | "desc" => "Configure the Flash object or upload/transfer a new Flash file.", 547 | "htmldesc" => $desc, 548 | "bb_action" => $_REQUEST["bb_action"], 549 | "hidden" => array( 550 | "sid" => $parent->GetSID(), 551 | "sc_action" => "bb_flash_configure_submit" 552 | ), 553 | "fields" => array( 554 | array( 555 | "title" => "Flash Object URL", 556 | "type" => "text", 557 | "name" => "src", 558 | "value" => $info["src"], 559 | "desc" => "The URL of this Flash Object." 560 | ), 561 | array( 562 | "title" => "Quick Configure", 563 | "type" => "textarea", 564 | "name" => "quickconfig", 565 | "value" => "", 566 | "desc" => "Copy and paste the HTML (object tag) that Flash generated to quickly configure these options." 567 | ), 568 | array( 569 | "title" => "Width", 570 | "type" => "text", 571 | "name" => "width", 572 | "value" => $info["width"], 573 | "desc" => "The width (in pixels) of the Flash object." 574 | ), 575 | array( 576 | "title" => "Height", 577 | "type" => "text", 578 | "name" => "height", 579 | "value" => $info["height"], 580 | "desc" => "The height (in pixels) of the Flash object." 581 | ), 582 | array( 583 | "title" => "Minimum Flash Version", 584 | "type" => "text", 585 | "name" => "minflashver", 586 | "value" => $info["minflashver"], 587 | "desc" => "The minimum Flash Player version required." 588 | ), 589 | array( 590 | "title" => "Publishing Method/Embed Type", 591 | "type" => "select", 592 | "name" => "opt-embed", 593 | "options" => array( 594 | "static" => "Static", 595 | "dynamic" => "Dynamic" 596 | ), 597 | "select" => $info["opt-embed"], 598 | "desc" => "Static publishing/embedding is generally better." 599 | ), 600 | array( 601 | "title" => "Express Install", 602 | "type" => "select", 603 | "name" => "opt-expressinstall", 604 | "options" => array( 605 | "enable" => "Enable", 606 | "disable" => "Disable" 607 | ), 608 | "select" => ($info["opt-expressinstall"] ? "enable" : "disable"), 609 | "desc" => "Express Install begins the upgrade process if the minimum Flash version is not installed but Flash 6 or later is installed." 610 | ), 611 | array( 612 | "title" => "Parameter: allowfullscreen", 613 | "type" => "select", 614 | "name" => "opt-param-allowfullscreen", 615 | "options" => array( 616 | "" => "Default", 617 | "true" => "Yes", 618 | "false" => "No" 619 | ), 620 | "select" => $info["opt-param-allowfullscreen"], 621 | "desc" => "Specifies whether or not the Flash object can use the whole screen." 622 | ), 623 | array( 624 | "title" => "Parameter: allownetworking", 625 | "type" => "select", 626 | "name" => "opt-param-allownetworking", 627 | "options" => array( 628 | "" => "Default", 629 | "all" => "All", 630 | "internal" => "Internal", 631 | "none" => "None" 632 | ), 633 | "select" => $info["opt-param-allownetworking"], 634 | "desc" => "Specifies what Flash networking APIs are allowed." 635 | ), 636 | array( 637 | "title" => "Parameter: allowscriptaccess", 638 | "type" => "select", 639 | "name" => "opt-param-allowscriptaccess", 640 | "options" => array( 641 | "" => "Default", 642 | "samedomain" => "Same Domain", 643 | "always" => "Always", 644 | "never" => "Never" 645 | ), 646 | "select" => $info["opt-param-allowscriptaccess"], 647 | "desc" => "Specifies what Flash outbound scripting APIs are allowed." 648 | ), 649 | array( 650 | "title" => "Parameter: base", 651 | "type" => "text", 652 | "name" => "opt-param-base", 653 | "value" => $info["opt-param-base"], 654 | "desc" => "The base directory or URL used to resolve relative path statements in ActionScript." 655 | ), 656 | array( 657 | "title" => "Parameter: bgcolor", 658 | "type" => "text", 659 | "name" => "opt-param-bgcolor", 660 | "value" => $info["opt-param-bgcolor"], 661 | "desc" => "Overrides the background color specified in the Flash object." 662 | ), 663 | array( 664 | "title" => "Parameter: devicefont", 665 | "type" => "select", 666 | "name" => "opt-param-devicefont", 667 | "options" => array( 668 | "" => "Default", 669 | "true" => "Yes", 670 | "false" => "No" 671 | ), 672 | "select" => $info["opt-param-devicefont"], 673 | "desc" => "Specifies whether static text objects are drawn using a device font, regardless of setting, if available." 674 | ), 675 | array( 676 | "title" => "Parameter: flashvars", 677 | "type" => "textarea", 678 | "name" => "opt-param-flashvars", 679 | "value" => $flashvars, 680 | "desc" => "Specify name=value pairs, one per line, to pass to the Flash object. Do NOT URL encode." 681 | ), 682 | array( 683 | "title" => "Parameter: loop", 684 | "type" => "select", 685 | "name" => "opt-param-loop", 686 | "options" => array( 687 | "" => "Default", 688 | "true" => "Yes", 689 | "false" => "No" 690 | ), 691 | "select" => $info["opt-param-loop"], 692 | "desc" => "Specifies whether the Flash object loops when it reaches the end of the movie." 693 | ), 694 | array( 695 | "title" => "Parameter: menu", 696 | "type" => "select", 697 | "name" => "opt-param-menu", 698 | "options" => array( 699 | "" => "Default", 700 | "true" => "Full right-click menu", 701 | "false" => "Partial right-click menu" 702 | ), 703 | "select" => $info["opt-param-menu"], 704 | "desc" => "Specifies whether right-clicking shows the whole menu or just the 'About' and 'Settings' options." 705 | ), 706 | array( 707 | "title" => "Parameter: play", 708 | "type" => "select", 709 | "name" => "opt-param-play", 710 | "options" => array( 711 | "" => "Default", 712 | "true" => "Yes", 713 | "false" => "No" 714 | ), 715 | "select" => $info["opt-param-play"], 716 | "desc" => "Specifies whether the Flash object begins playing automatically once loaded." 717 | ), 718 | array( 719 | "title" => "Parameter: quality", 720 | "type" => "select", 721 | "name" => "opt-param-quality", 722 | "options" => array( 723 | "" => "Default", 724 | "autolow" => "Start with low quality (speed preferred)", 725 | "autohigh" => "Start with high quality (appearance preferred)", 726 | "low" => "Low", 727 | "medium" => "Medium", 728 | "high" => "High", 729 | "best" => "Best" 730 | ), 731 | "select" => $info["opt-param-quality"], 732 | "desc" => "Specifies the default quality setting of the Flash object." 733 | ), 734 | array( 735 | "title" => "Parameter: salign", 736 | "type" => "select", 737 | "name" => "opt-param-salign", 738 | "options" => array( 739 | "" => "Default", 740 | "t" => "Top", 741 | "l" => "Left", 742 | "r" => "Right", 743 | "b" => "Bottom", 744 | "tl" => "Top left", 745 | "tr" => "Top right", 746 | "bl" => "Bottom left", 747 | "br" => "Bottom right" 748 | ), 749 | "select" => $info["opt-param-salign"], 750 | "desc" => "Specifies the position of the Flash object." 751 | ), 752 | array( 753 | "title" => "Parameter: scale", 754 | "type" => "select", 755 | "name" => "opt-param-scale", 756 | "options" => array( 757 | "" => "Default", 758 | "showall" => "Show all (Entirely visible with no distortion)", 759 | "noborder" => "No border (Fills entire area with no distortion but may be cropped)", 760 | "exactfit" => "Exact fit (Entirely visible but may be distorted)" 761 | ), 762 | "select" => $info["opt-param-scale"], 763 | "desc" => "Specifies how Flash fills the browser area with the Flash object." 764 | ), 765 | array( 766 | "title" => "Parameter: seamlesstabbing", 767 | "type" => "select", 768 | "name" => "opt-param-seamlesstabbing", 769 | "options" => array( 770 | "" => "Default", 771 | "true" => "Yes", 772 | "false" => "No" 773 | ), 774 | "select" => $info["opt-param-seamlesstabbing"], 775 | "desc" => "Specifies whether pressing tab while in the Flash object moves to the next page element." 776 | ), 777 | array( 778 | "title" => "Parameter: wmode", 779 | "type" => "select", 780 | "name" => "opt-param-wmode", 781 | "options" => array( 782 | "" => "Default", 783 | "window" => "Window", 784 | "opaque" => "Opaque", 785 | "transparent" => "Transparent" 786 | ), 787 | "select" => $info["opt-param-wmode"], 788 | "desc" => "Specifies the window mode of the Flash object. Opaque and transparent usually work with iframe menu hacks." 789 | ), 790 | array( 791 | "title" => "Caption", 792 | "type" => "text", 793 | "name" => "opt-caption", 794 | "value" => $info["opt-caption"], 795 | "desc" => "The text to use for a caption below the Flash object." 796 | ), 797 | array( 798 | "title" => "Caption Width", 799 | "type" => "text", 800 | "name" => "opt-caption-width", 801 | "value" => $info["opt-caption-width"], 802 | "desc" => "The width in pixels to constrain the caption to. Typically the width of the Flash object." 803 | ), 804 | array( 805 | "title" => "Swap Image URL", 806 | "type" => "text", 807 | "name" => "opt-image", 808 | "value" => $info["opt-image"], 809 | "desc" => "The URL of an image to show before displaying the Flash object. This option imports jQuery." 810 | ), 811 | array( 812 | "title" => "Alternate Image Text", 813 | "type" => "text", 814 | "name" => "opt-image-alt", 815 | "value" => $info["opt-image-alt"], 816 | "desc" => "The alternate text to display if the image is not able to be seen (e.g. visually impaired visitors)." 817 | ) 818 | ), 819 | "submit" => "Save", 820 | "focus" => true 821 | ); 822 | 823 | BB_RunPluginActionInfo("bb_content_shortcode_bb_flash_configure_options", $options); 824 | 825 | BB_PropertyForm($options); 826 | 827 | BB_RunPluginAction("post_bb_content_shortcode_bb_flash_configure"); 828 | } 829 | } 830 | } 831 | ?> --------------------------------------------------------------------------------