Пример #1
0
function BB_SavePage()
{
    global $bb_dir, $bb_file, $bb_relroot, $bb_page, $bb_writeperms;
    // Calculate the number of languages - allow for faster cache selection.
    $bb_page["onelang"] = true;
    $numlang = 0;
    foreach ($bb_page["langs"] as $langmap) {
        if (is_array($langmap)) {
            $numlang++;
            if ($numlang > 1) {
                $bb_page["onelang"] = false;
                break;
            }
        }
    }
    // Generate and write out the final page.
    $data = "<" . "?php\n";
    $data .= "\tdefine(\"BB_FILE\", 1);\n";
    $data .= "\trequire_once \"" . $bb_file . "_page.php\";\n";
    if ($bb_relroot != "") {
        $data .= "\tchdir(\$bb_relroot);\n";
    }
    $data .= "\trequire_once \"main.php\";\n";
    $data .= "?" . ">";
    if (BB_WriteFile($bb_dir . "/" . $bb_file . ".php", $data) === false) {
        return false;
    }
    $data = "<" . "?php\n";
    $data .= "\t\$bb_dir = \"" . $bb_dir . "\";\n";
    $data .= "\t\$bb_file = \"" . $bb_file . "\";\n";
    $data .= "\t\$bb_relroot = \"" . $bb_relroot . "\";\n";
    $data .= "\t\$bb_page = " . BB_CreatePHPStorageData($bb_page) . ";\n";
    $data .= "?" . ">";
    if (BB_WriteFile($bb_dir . "/" . $bb_file . "_page.php", $data) === false) {
        return false;
    }
    if (function_exists("BB_RunPluginAction")) {
        BB_RunPluginAction("post_bb_savepage");
    }
    return true;
}
Пример #2
0
    public function ProcessBBAction()
    {
        global $bb_widget, $bb_widget_id, $bb_account, $bb_revision_num, $g_bb_content_shortcodes, $g_bb_content_security, $g_bb_content_security_path;
        if (!BB_IsMemberOfPageGroup("_p")) {
            exit;
        }
        if ($bb_account["type"] == "dev" && $_REQUEST["bb_action"] == "bb_content_configure_security_submit") {
            BB_RunPluginAction("pre_bb_content_configure_security_submit");
            // Rebuild the security context array.
            $g_bb_content_security = array();
            foreach ($g_bb_content_shortcodes as $sname => $info) {
                if (isset($info["security"])) {
                    foreach ($info["security"] as $key => $desc) {
                        $key2 = $sname . "|" . $key;
                        if (isset($_REQUEST[$key2]) && $_REQUEST[$key2] != "" && ($_REQUEST[$key2] == "content" || $_REQUEST[$key2] == "design" || $_REQUEST[$key2] == "dev")) {
                            if (!isset($g_bb_content_security[$sname])) {
                                $g_bb_content_security[$sname] = array();
                            }
                            $g_bb_content_security[$sname][$key] = $_REQUEST[$key2];
                        }
                    }
                }
            }
            // Save security contexts.
            $data = "<" . "?php\n\t\$g_bb_content_security = " . BB_CreatePHPStorageData($g_bb_content_security) . ";\n?" . ">";
            if (BB_WriteFile($g_bb_content_security_path, $data) === false) {
                BB_PropertyFormError("Unable to save the shortcode security options.");
            }
            ?>
<div class="success"><?php 
            echo htmlspecialchars(BB_Translate("Global shortcode security options updated."));
            ?>
</div>
<script type="text/javascript">
window.parent.CloseProperties();
window.parent.ReloadIFrame();
</script>
<?php 
            BB_RunPluginAction("post_bb_content_configure_security_submit");
        } else {
            if ($bb_account["type"] == "dev" && $_REQUEST["bb_action"] == "bb_content_configure_security") {
                BB_RunPluginAction("pre_bb_content_configure_security");
                $options = array("title" => "Configure Global Shortcode Security", "desc" => "Configure the global shortcode display options based on login account type.", "fields" => array(), "submit" => "Save", "focus" => true);
                foreach ($g_bb_content_shortcodes as $sname => $info) {
                    if (isset($info["security"])) {
                        foreach ($info["security"] as $key => $desc) {
                            if ($key == "") {
                                $options["fields"][] = array("title" => $desc[0], "type" => "select", "name" => $sname . "|" . $key, "options" => array("dev" => "Developers only", "design" => "Developers and Web Designers", "content" => "Everyone"), "select" => isset($g_bb_content_security[$sname]) && isset($g_bb_content_security[$sname][$key]) ? $g_bb_content_security[$sname][$key] : "", "desc" => $desc[1]);
                            } else {
                                $options["fields"][] = array("title" => $desc[0], "type" => "select", "name" => $sname . "|" . $key, "options" => array("" => "None", "content" => "Content Editors only", "design" => "Web Designers and Content Editors", "dev" => "Everyone"), "select" => isset($g_bb_content_security[$sname]) && isset($g_bb_content_security[$sname][$key]) ? $g_bb_content_security[$sname][$key] : "", "desc" => $desc[1]);
                            }
                        }
                    }
                }
                BB_RunPluginActionInfo("bb_content_configure_security_options", $options);
                BB_PropertyForm($options);
                BB_RunPluginAction("post_bb_content_configure_security");
            } else {
                if ($_REQUEST["bb_action"] == "bb_content_edit_load") {
                    BB_RunPluginAction("pre_bb_content_edit_load");
                    if (isset($bb_widget->body)) {
                        echo rawurlencode(UTF8::ConvertToHTML($bb_widget->body));
                    } else {
                        echo rawurlencode("<p></p>");
                    }
                    BB_RunPluginAction("post_bb_content_edit_load");
                } else {
                    if ($_REQUEST["bb_action"] == "bb_content_edit_save") {
                        BB_RunPluginAction("pre_bb_content_edit_save");
                        $options = array("shortcodes" => true, "shortcode_placeholder" => "bb_content_shortcode_placeholder", "shortcode_ids" => array());
                        $shortcodes = $bb_widget->shortcodes;
                        $base = "wid_" . htmlspecialchars($bb_widget_id) . "_";
                        foreach ($shortcodes as $num => $shortcode) {
                            $options["shortcode_ids"][$base . $num] = isset($shortcode["_sn"]) && isset($g_bb_content_shortcodes[$shortcode["_sn"]]) ? htmlspecialchars($g_bb_content_shortcodes[$shortcode["_sn"]]["mainicon"]) : "";
                        }
                        $bb_widget->body = BB_HTMLPurifyForWYMEditor($_REQUEST["content"], $options);
                        if (!$this->RegenerateContent(true)) {
                            echo htmlspecialchars(BB_Translate("Unable to save content.  Try again."));
                        } else {
                            echo "OK\n";
                            echo "<script type=\"text/javascript\">ReloadIFrame();</script>";
                        }
                        BB_RunPluginAction("post_bb_content_edit_save");
                    } else {
                        if ($_REQUEST["bb_action"] == "bb_content_edit_add_shortcode" && BB_IsSecExtraOpt("sname")) {
                            BB_RunPluginAction("pre_bb_content_edit_add_shortcode");
                            if (!isset($_REQUEST["sname"]) || !isset($g_bb_content_shortcodes[$_REQUEST["sname"]])) {
                                ?>
<script type="text/javascript">
alert('<?php 
                                echo htmlspecialchars(BB_JSSafe(BB_Translate("Shortcode handler not found.")));
                                ?>
');
</script>
<?php 
                            } else {
                                if (!$this->IsShortcodeAllowed($_REQUEST["sname"], "")) {
                                    ?>
<script type="text/javascript">
alert('<?php 
                                    echo htmlspecialchars(BB_JSSafe(BB_Translate("Shortcode access denied.")));
                                    ?>
');
</script>
<?php 
                                } else {
                                    $sname = $_REQUEST["sname"];
                                    $sid = count($bb_widget->shortcodes);
                                    $bb_widget->shortcodes[] = array("_sn" => $sname, "_id" => $sid);
                                    if (!BB_SaveLangPage($bb_revision_num)) {
                                        ?>
<script type="text/javascript">
alert('<?php 
                                        echo htmlspecialchars(BB_JSSafe(BB_Translate("Unable to add a new %s.", $g_bb_content_shortcodes[$sname]["name"])));
                                        ?>
');
</script>
<?php 
                                    } else {
                                        ?>
<script type="text/javascript">
InsertWYMEditorContent('contenteditor', 'wid_<?php 
                                        echo BB_JSSafe($bb_widget_id);
                                        ?>
', '<img id="wid_<?php 
                                        echo BB_JSSafe($bb_widget_id);
                                        ?>
_<?php 
                                        echo $sid;
                                        ?>
" class="bb_content_shortcode_placeholder" src="<?php 
                                        echo htmlspecialchars(BB_JSSafe($g_bb_content_shortcodes[$sname]["mainicon"]));
                                        ?>
" />');
</script>
<?php 
                                    }
                                }
                            }
                            BB_RunPluginAction("post_bb_content_edit_add_shortcode");
                        } else {
                            if ($_REQUEST["bb_action"] == "bb_content_edit_edit_shortcode" && (!isset($_REQUEST["sc_action"]) || BB_IsSecExtraOpt("sid") && BB_IsSecExtraOpt("sc_action"))) {
                                BB_RunPluginAction("pre_bb_content_edit_edit_shortcode");
                                if (!isset($_REQUEST["sid"])) {
                                    BB_PropertyFormLoadError("Shortcode ID not specified.");
                                }
                                $sid = $_REQUEST["sid"];
                                $pos = strrpos($sid, "_");
                                if ($pos !== false) {
                                    $sid = substr($sid, $pos + 1);
                                }
                                $sid = (int) $sid;
                                if (!isset($bb_widget->shortcodes[$sid]) || !isset($bb_widget->shortcodes[$sid]["_sn"])) {
                                    BB_PropertyFormLoadError("Invalid shortcode ID.");
                                }
                                $sname = $bb_widget->shortcodes[$sid]["_sn"];
                                if (!isset($g_bb_content_shortcodes[$sname])) {
                                    BB_PropertyFormLoadError("Shortcode handler not found.");
                                }
                                if (!$this->IsShortcodeAllowed($sname, "")) {
                                    BB_PropertyFormLoadError("Shortcode access denied.");
                                }
                                if (!isset($_REQUEST["sc_action"])) {
                                    $_REQUEST["sc_action"] = $sname . "_configure";
                                }
                                $shortcode = "bb_content_shortcode_" . $sname;
                                $shortcode = new $shortcode();
                                $this->currsid = $sid;
                                $shortcode->ProcessShortcodeBBAction($this);
                                BB_RunPluginAction("post_bb_content_edit_edit_shortcode");
                            } else {
                                if ($_REQUEST["bb_action"] == "bb_content_edit") {
                                    BB_RunPluginAction("pre_bb_content_edit");
                                    ?>
<script type="text/javascript">
html = '<style type="text/css">\n';
<?php 
                                    foreach ($g_bb_content_shortcodes as $sname => $info) {
                                        $sname2 = preg_replace('/[^A-Za-z0-9_]/', "_", trim($sname));
                                        ?>
html += '.wym_skin_barebones .wym_buttons li.wym_tools_custom_<?php 
                                        echo htmlspecialchars(BB_JSSafe($sname2));
                                        ?>
 a  { background-image: url(<?php 
                                        echo htmlspecialchars(BB_JSSafe($info["toolbaricon"]));
                                        ?>
); background-repeat: no-repeat; }\n';
<?php 
                                    }
                                    ?>
html += '</style>\n';
$("head").append(html);

window.bb_content_WYMEditorPostInit = function(eid, id, wym) {
<?php 
                                    foreach ($g_bb_content_shortcodes as $sname => $info) {
                                        if ($this->IsShortcodeAllowed($sname, "")) {
                                            $sname2 = preg_replace('/[^A-Za-z0-9_]/', "_", trim($sname));
                                            ?>
	var html = '<li class="wym_tools_custom_<?php 
                                            echo htmlspecialchars(BB_JSSafe($sname2));
                                            ?>
"><a name="<?php 
                                            echo htmlspecialchars(BB_JSSafe($info["name"]));
                                            ?>
" href="#"><?php 
                                            echo htmlspecialchars(BB_JSSafe($info["name"]));
                                            ?>
</a></li>';
	$(wym._box).find(wym._options.toolsSelector + wym._options.toolsListSelector).append(html);
	$(wym._box).find('li.wym_tools_custom_<?php 
                                            echo BB_JSSafe($sname2);
                                            ?>
 a').click(function() {
		$('#' + eid + '_loader').load(Gx__URLBase, <?php 
                                            echo BB_CreateWidgetPropertiesJS("bb_content_edit_add_shortcode", array("sname" => $sname), true);
                                            ?>
);

		return false;
	});
<?php 
                                        }
                                    }
                                    ?>

	$(wym._doc).bind('dblclick', function(e) {
		if (e.target.tagName == 'IMG' && $(e.target).hasClass('bb_content_shortcode_placeholder') && typeof(e.target.id) == 'string' && e.target.id != '')
		{
			window.parent.LoadProperties({ 'bb_action' : 'bb_content_edit_edit_shortcode', 'wid' : '<?php 
                                    echo BB_JSSafe($bb_widget_id);
                                    ?>
', 'sid' : e.target.id, 'bbt' : '<?php 
                                    echo BB_JSSafe(BB_CreateSecurityToken("bb_content_edit_edit_shortcode", $bb_widget_id));
                                    ?>
' });
		}
	});
}

if (typeof(window.parent.CreateWYMEditorInstance) != 'function')
{
	window.bb_content_ClosedAllContent = function(eid) {
		setTimeout(function() { DestroyWYMEditorInstance(eid);  $('#' + eid).hide(); }, 250);
	}
}

window.parent.LoadConditionalScript(Gx__RootURL + '/' + Gx__SupportPath + '/editcontent.js?_=20090725', true, function(loaded) {
		return ((!loaded && typeof(window.CreateWYMEditorInstance) == 'function') || (loaded && !IsConditionalScriptLoading()));
	}, function(params) {
		$('#contenteditor').show();

		var fileopts = {
			loadurl : Gx__URLBase,
			loadparams : <?php 
                                    echo BB_CreateWidgetPropertiesJS("bb_content_edit_load", array(), true);
                                    ?>
,
			id : 'wid_<?php 
                                    echo BB_JSSafe($bb_widget_id);
                                    ?>
',
			display : '<?php 
                                    echo BB_JSSafe($bb_widget->_f);
                                    ?>
',
			saveurl : Gx__URLBase,
			saveparams : <?php 
                                    echo BB_CreateWidgetPropertiesJS("bb_content_edit_save", array(), true);
                                    ?>
,
			wymtoolbar : 'bold,italic,superscript,subscript,pasteword,undo,redo,createlink,unlink,insertorderedlist,insertunorderedlist,indent,outdent',
			wymeditorpostinit : bb_content_WYMEditorPostInit
		};

		var editopts = {
			ismulti : true,
			closelast : bb_content_ClosedAllContent,
			width : '100%',
			height : '300px'
		};

		CreateWYMEditorInstance('contenteditor', fileopts, editopts);
});
window.parent.CloseProperties2(false);
</script>
<?php 
                                    BB_RunPluginAction("post_bb_content_edit");
                                } else {
                                    if (isset($_REQUEST["action"])) {
                                        // Pass other requests onto the shortcode action handler.
                                        if (isset($_REQUEST["sid"])) {
                                            $sid = (int) $_REQUEST["sid"];
                                            if (isset($bb_widget->shortcodes[$sid]) && isset($bb_widget->shortcodes[$sid]["_sn"])) {
                                                $sname = $bb_widget->shortcodes[$sid]["_sn"];
                                                if (isset($g_bb_content_shortcodes[$sname])) {
                                                    $shortcode = "bb_content_shortcode_" . $sname;
                                                    $shortcode = new $shortcode();
                                                    $this->currsid = $sid;
                                                    $shortcode->ProcessShortcodeAction($this);
                                                }
                                            }
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
            }
        }
    }
Пример #3
0
    public function ProcessShortcodeBBAction($parent)
    {
        global $bb_dir, $bb_pref_lang, $bb_revision_num, $bb_writeperms;
        $info = $this->GetInfo($parent->GetSID());
        if ($_REQUEST["sc_action"] == "bb_image_upload_ajaxupload") {
            BB_RunPluginAction("pre_bb_content_shortcode_bb_image_upload_ajaxupload");
            $msg = BB_ValidateAJAXUpload();
            if ($msg != "") {
                echo htmlspecialchars(BB_Translate($msg));
                exit;
            }
            // Use official magic numbers for each format to determine the real content type.
            $data = file_get_contents($_FILES["Filedata"]["tmp_name"]);
            $type = BB_GetImageType($data);
            if ($type != "gif" && $type != "jpg" && $type != "png") {
                echo htmlspecialchars(BB_Translate("Uploaded file is not a valid web image.  Must be PNG, JPG, or GIF."));
                exit;
            }
            if (!is_dir($bb_dir . "/images")) {
                mkdir($bb_dir . "/images", 0777, true);
            }
            $dirfile = preg_replace('/\\.+/', ".", preg_replace('/[^A-Za-z0-9_.\\-]/', "_", $bb_pref_lang . "_" . ($bb_revision_num > -1 ? $bb_revision_num . "_" : "") . trim($_FILES["Filedata"]["name"])));
            if ($dirfile == ".") {
                $dirfile = "";
            }
            if ($dirfile == "") {
                echo htmlspecialchars(BB_Translate("A filename was not specified."));
                exit;
            }
            $pos = strrpos($dirfile, ".");
            if ($pos === false || substr($dirfile, $pos + 1) != $type) {
                $dirfile .= "." . $type;
            }
            if (!@move_uploaded_file($_FILES["Filedata"]["tmp_name"], $bb_dir . "/images/" . $dirfile)) {
                echo htmlspecialchars(BB_Translate("Unable to move temporary file to final location.  Check the permissions of the target directory and destination file."));
                exit;
            }
            @chmod($bb_dir . "/images/" . $dirfile, 0444 | $bb_writeperms);
            $info["src"] = "images/" . $dirfile;
            if (!$parent->SaveShortcode($info)) {
                echo htmlspecialchars(BB_Translate("Unable to save the shortcode."));
                exit;
            }
            echo "OK";
            BB_RunPluginAction("post_bb_content_shortcode_bb_image_upload_ajaxupload");
        } else {
            if ($_REQUEST["sc_action"] == "bb_image_upload_submit") {
                BB_RunPluginAction("pre_bb_content_shortcode_bb_image_upload_submit");
                $imginfo = BB_IsValidHTMLImage($_REQUEST["url"], array("protocol" => "http"));
                if (!$imginfo["success"]) {
                    BB_PropertyFormError($imginfo["error"]);
                }
                $dirfile = preg_replace('/\\.+/', ".", preg_replace('/[^A-Za-z0-9_.\\-]/', "_", $_REQUEST["destfile"]));
                if ($dirfile == ".") {
                    $dirfile = "";
                }
                // Automatically calculate the new filename based on the URL.
                if ($dirfile == "") {
                    $dirfile = $bb_pref_lang . "_" . ($bb_revision_num > -1 ? $bb_revision_num . "_" : "") . BB_MakeFilenameFromURL($imginfo["url"], $imginfo["type"]);
                }
                if (!is_dir($bb_dir . "/images")) {
                    mkdir($bb_dir . "/images", 0777, true);
                }
                if (BB_WriteFile($bb_dir . "/images/" . $dirfile, $imginfo["data"]) === false) {
                    BB_PropertyFormError("Unable to save the image.");
                }
                $info["src"] = "images/" . $dirfile;
                if (!$parent->SaveShortcode($info)) {
                    BB_PropertyFormError("Unable to save the shortcode.");
                }
                ?>
<div class="success"><?php 
                echo htmlspecialchars(BB_Translate("Image transferred."));
                ?>
</div>
<script type="text/javascript">
LoadProperties(<?php 
                echo $parent->CreateShortcodePropertiesJS("");
                ?>
);
ReloadIFrame();
</script>
<?php 
                BB_RunPluginAction("post_bb_content_shortcode_bb_image_upload_submit");
            } else {
                if ($_REQUEST["sc_action"] == "bb_image_upload") {
                    $parent->CreateShortcodeUploader("", array(), "Configure Image", "Image", "image", "*.png;*.jpg;*.gif", "Web Image Files");
                } else {
                    if ($_REQUEST["sc_action"] == "bb_image_configure_submit") {
                        BB_RunPluginAction("pre_bb_content_shortcode_bb_image_configure_submit");
                        $src = trim($_REQUEST["src"]);
                        if ($info["src"] != $src) {
                            if ($src != "") {
                                $imginfo = BB_IsValidHTMLImage($src, array("protocol" => "http"));
                                if (!$imginfo["success"] && function_exists("fsockopen")) {
                                    BB_PropertyFormError("'Image URL' field does not point to a valid image file.");
                                }
                            }
                            $info["src"] = $src;
                        }
                        $info["alt"] = $_REQUEST["alt"];
                        $info["opt-caption"] = $_REQUEST["opt-caption"] == "enable";
                        $info["opt-caption-width"] = (int) $_REQUEST["opt-caption-width"];
                        if ($info["opt-caption-width"] < 0) {
                            $info["opt-caption-width"] = 0;
                        }
                        if (!$parent->SaveShortcode($info)) {
                            BB_PropertyFormError("Unable to save the shortcode.");
                        }
                        ?>
<div class="success"><?php 
                        echo htmlspecialchars(BB_Translate("Options saved."));
                        ?>
</div>
<script type="text/javascript">
CloseProperties();
ReloadIFrame();
</script>
<?php 
                        BB_RunPluginAction("post_bb_content_shortcode_bb_image_configure_submit");
                    } else {
                        if ($_REQUEST["sc_action"] == "bb_image_configure") {
                            BB_RunPluginAction("pre_bb_content_shortcode_bb_image_configure");
                            $desc = "<br />";
                            $desc .= $parent->CreateShortcodePropertiesLink(BB_Translate("Upload/Transfer Image"), "bb_image_upload");
                            $options = array("title" => "Configure Image", "desc" => "Configure the image or upload/transfer a new image.", "htmldesc" => $desc, "bb_action" => $_REQUEST["bb_action"], "hidden" => array("sid" => $parent->GetSID(), "sc_action" => "bb_image_configure_submit"), "fields" => array(array("title" => "Image URL", "type" => "text", "name" => "src", "value" => $info["src"], "desc" => "The URL of this image."), array("title" => "Alternate Text", "type" => "text", "name" => "alt", "value" => $info["alt"], "desc" => "The alternate text to display if images are not able to be seen (e.g. visually impaired visitors)."), array("title" => "Display Caption", "type" => "select", "name" => "opt-caption", "options" => array("enable" => "Enable", "disable" => "Disable"), "select" => $info["opt-caption"] ? "enable" : "disable", "desc" => "Display the alternate text as a caption below the image."), array("title" => "Caption Width", "type" => "text", "name" => "opt-caption-width", "value" => $info["opt-caption-width"], "desc" => "The width in pixels to constrain the caption to.  Typically the width of the image.")), "submit" => "Save", "focus" => true);
                            BB_RunPluginActionInfo("bb_content_shortcode_bb_image_configure_options", $options);
                            BB_PropertyForm($options);
                            BB_RunPluginAction("post_bb_content_shortcode_bb_image_configure");
                        }
                    }
                }
            }
        }
    }
Пример #4
0
     $pos = strrpos($dirfile, ".");
     if ($pos === false) {
         echo htmlspecialchars(BB_Translate("File extension not found."));
         exit;
     }
     $ext = substr($dirfile, $pos);
     if ($bb_account["type"] == "design" && !isset($designextmap[$ext])) {
         echo htmlspecialchars(BB_Translate("Unable to save contents.  Invalid extension permissions."));
         exit;
     }
     $dirfile = ROOT_PATH . "/" . $dirfile;
     $isfile = is_file($dirfile) || !file_exists($dirfile);
     if (!$isfile) {
         echo htmlspecialchars(BB_Translate("Invalid filename."));
     } else {
         if (BB_WriteFile($dirfile, $_REQUEST["content"]) !== false && BB_WidgetStatusUpdate()) {
             echo "OK\n";
             echo "<script type=\"text/javascript\">ReloadIFrame();</script>";
         } else {
             echo htmlspecialchars(BB_Translate("Unable to save contents.  Possible cause:  Incorrect permissions."));
         }
     }
     BB_RunPluginAction("post_bb_main_edit_site_opt_file_explorer_edit_save");
 } else {
     if ($bb_account["type"] == "dev" && $_REQUEST["bb_action"] == "bb_main_edit_site_opt_file_explorer_rename_submit" && BB_IsSecExtraOpt("dir") && BB_IsSecExtraOpt("srcfile")) {
         BB_RunPluginAction("pre_bb_main_edit_site_opt_file_explorer_rename_submit");
         $destfile = preg_replace('/\\.+/', ".", preg_replace('/[^A-Za-z0-9_.\\-]/', "_", $_REQUEST["destfile"]));
         if ($destfile == ".") {
             $destfile = "";
         }
         if ($destfile == "") {
Пример #5
0
// Make sure the main page data is loaded.
require_once $bb_dir . "/" . $bb_file . "_" . $bb_pref_lang . "_page.php";
// Load initialization functions.
require_once ROOT_PATH . "/" . SUPPORT_PATH . "/bb_init_functions.php";
// Manage the page.
if (isset($_REQUEST["bb_action"])) {
    require_once "edit.php";
} else {
    if (isset($_REQUEST["action"])) {
        // Find the widget.  Can't be a widget master and must exist.
        if (isset($_REQUEST["wid"]) && isset($bb_langpage["widgets"][$_REQUEST["wid"]])) {
            $bb_widget->SetID($_REQUEST["wid"]);
            if ($bb_widget->_m === false && $bb_widget->_a !== false && file_exists(ROOT_PATH . "/" . WIDGET_PATH . "/" . $bb_widget->_file)) {
                // Load widgets.
                BB_LoadWidgets();
                $bb_widget->SetID($_REQUEST["wid"]);
                $bb_widget_instances[$_REQUEST["wid"]]->ProcessAction();
            }
        }
    } else {
        // Load widgets.
        BB_LoadWidgets();
        $bb_widget->SetID("");
        $data = BB_ProcessPage($bb_page["cachetime"] != 0, true, true);
        if ($bb_page["cachetime"] != 0) {
            $bb_page["langs"][$bb_pref_lang][$bb_profile] = array(time(), gmdate("D, d M Y H:i:s") . " GMT");
            BB_WriteFile($bb_dir . "/" . $bb_file . "_" . $bb_pref_lang . ($bb_profile != "" ? "." . $bb_profile : "") . ".html", $data);
            BB_SavePage();
        }
    }
}
Пример #6
0
function BB_SaveExtensionsCache()
{
    global $bb_extensions_info, $bb_paths;
    $data = "<" . "?php\n\t\$bb_extensions_info = " . BB_CreatePHPStorageData($bb_extensions_info) . ";\n?" . ">";
    if (BB_WriteFile((isset($bb_paths) ? $bb_paths["ROOT_PATH"] : ROOT_PATH) . "/extensions_cache.php", $data) === false) {
        return false;
    }
    BB_RunPluginAction("post_bb_saveextensionscache");
    return true;
}
Пример #7
0
        $data .= "\tdefine(\"LANG_PATH\", " . var_export(LANG_PATH, true) . ");\n";
        $data .= "\tdefine(\"DEFAULT_LANG\", " . var_export(DEFAULT_LANG, true) . ");\n";
        $data .= "\tdefine(\"DEFAULT_PAGE_LANG\", " . var_export(DEFAULT_PAGE_LANG, true) . ");\n";
        $data .= "\tdefine(\"BASE_RAND_SEED\", " . var_export(BASE_RAND_SEED, true) . ");\n";
        $data .= "\tdefine(\"BASE_RAND_SEED2\", " . var_export(BASE_RAND_SEED2, true) . ");\n";
        $data .= "\tdefine(\"DEV_SESSION_TIMEOUT\", " . GetTimeoutInSeconds($_REQUEST["dev_timeout"]) . ");\n";
        $data .= "\tdefine(\"DESIGN_SESSION_TIMEOUT\", " . GetTimeoutInSeconds($_REQUEST["design_timeout"]) . ");\n";
        $data .= "\tdefine(\"CONTENT_SESSION_TIMEOUT\", " . GetTimeoutInSeconds($_REQUEST["content_timeout"]) . ");\n";
        $data .= "\tdefine(\"STO_LOGIN\", " . var_export($_REQUEST["sto_login"] > 0, true) . ");\n";
        $data .= "\tdefine(\"WRITE_PERMS\", " . var_export($_REQUEST["write_perms"], true) . ");\n";
        $data .= "\tdefine(\"USE_LESS_SAFE_STORAGE\", " . var_export($_REQUEST["use_less_safe_storage"] == "yes", true) . ");\n";
        $data .= "?" . ">";
        if (BB_WriteFile("config.php", $data) === false) {
            InstallError("Unable to create the configuration file.");
        }
        if ($_REQUEST["sto_login"] > 0 && BB_WriteFile(ROOT_PATH . "/" . $logindir . "/config.php", $data) === false) {
            InstallError("Unable to create the configuration file clone in the admin subdirectory.");
        }
        InstallSuccess("Successfully created the configuration file.");
        InstallSuccess("The installation completed successfully.");
        ?>
		<br />
		Next:  <a href="<?php 
        echo htmlspecialchars($loginurl);
        ?>
">Start using Barebones</a><br />
		(Don't forget to bookmark the login screen.)<br />
<?php 
    } else {
        ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
Пример #8
0
    public function ProcessBBAction()
    {
        global $bb_widget, $bb_account, $bb_revision_num;
        $basepath = BB_GetRealPath(Str::ExtractPathname($bb_widget->_file) . "/base");
        if (($bb_account["type"] == "dev" || $bb_account["type"] == "design") && $_REQUEST["bb_action"] == "bb_layout_configure_widget_new_layout_submit") {
            BB_RunPluginAction("pre_bb_layout_configure_widget_new_layout_submit");
            $found = false;
            $dirlist = BB_GetDirectoryList(ROOT_PATH . "/" . WIDGET_PATH . "/" . $basepath);
            foreach ($dirlist["files"] as $name) {
                $pos = strrpos($name, ".");
                if ($pos !== false && substr($name, $pos) == ".html" && substr($name, 0, $pos) == $_REQUEST["pattern"]) {
                    $found = true;
                    break;
                }
            }
            if (!$found) {
                BB_PropertyFormError("Invalid pattern specified.");
            }
            $name = $_REQUEST["name"];
            if ($name == "") {
                BB_PropertyFormError("Name field not filled out.");
            }
            $dirfile = preg_replace('/[^A-Za-z0-9_\\-]/', "_", $name);
            if (file_exists(ROOT_PATH . "/" . WIDGET_PATH . "/" . $this->layoutpath . "/" . $dirfile . ".html")) {
                BB_PropertyFormError("A layout with that name already exists.");
            }
            if (file_exists(ROOT_PATH . "/" . WIDGET_PATH . "/" . $this->layoutpath . "/" . $dirfile . ".css")) {
                BB_PropertyFormError("A layout with that name already exists.");
            }
            $data = file_get_contents(ROOT_PATH . "/" . WIDGET_PATH . "/" . $basepath . "/" . $_REQUEST["pattern"] . ".html");
            $data = str_replace(htmlspecialchars($_REQUEST["pattern"]), htmlspecialchars($dirfile), $data);
            if (BB_WriteFile(ROOT_PATH . "/" . WIDGET_PATH . "/" . $this->layoutpath . "/" . $dirfile . ".html", $data) === false) {
                BB_PropertyFormError("Unable to create layout HTML.");
            }
            if (!copy(ROOT_PATH . "/" . WIDGET_PATH . "/" . $basepath . "/" . $_REQUEST["pattern"] . ".css", ROOT_PATH . "/" . WIDGET_PATH . "/" . $this->layoutpath . "/" . $dirfile . ".css")) {
                BB_PropertyFormError("Unable to create layout CSS.");
            }
            ?>
<div class="success"><?php 
            echo htmlspecialchars(BB_Translate("Layout created."));
            ?>
</div>
<script type="text/javascript">
window.parent.LoadProperties(<?php 
            echo BB_CreateWidgetPropertiesJS("bb_layout_configure_widget");
            ?>
);
</script>
<?php 
            BB_RunPluginAction("post_bb_layout_configure_widget_new_layout_submit");
        } else {
            if (($bb_account["type"] == "dev" || $bb_account["type"] == "design") && $_REQUEST["bb_action"] == "bb_layout_configure_widget_new_layout") {
                BB_RunPluginAction("pre_bb_layout_configure_widget_new_layout");
                $desc = "<br />";
                $desc .= BB_CreateWidgetPropertiesLink(BB_Translate("Back"), "bb_layout_configure_widget");
                $patterns = array();
                $dirlist = BB_GetDirectoryList(ROOT_PATH . "/" . WIDGET_PATH . "/" . $basepath);
                foreach ($dirlist["files"] as $name) {
                    $pos = strrpos($name, ".");
                    if ($pos !== false && substr($name, $pos) == ".html") {
                        $info = $this->ExtractFileInfo(ROOT_PATH . "/" . WIDGET_PATH . "/" . $basepath . "/" . $name);
                        if ($info !== false) {
                            $patterns[substr($name, 0, $pos)] = $info[""]["info"][0];
                        }
                    }
                }
                $options = array("title" => BB_Translate("Configure %s - New Layout", $bb_widget->_f), "desc" => "Create a new layout.", "htmldesc" => $desc, "fields" => array(array("title" => "Pattern", "type" => "select", "name" => "pattern", "options" => $patterns, "desc" => "The pattern to use for the new layout."), array("title" => "Name", "type" => "text", "name" => "name", "value" => "", "desc" => "The name of the new layout.")), "submit" => "Create", "focus" => true);
                BB_RunPluginActionInfo("bb_layout_configure_widget_new_layout_options", $options);
                BB_PropertyForm($options);
                BB_RunPluginAction("post_bb_layout_configure_widget_new_layout");
            } else {
                if (($bb_account["type"] == "dev" || $bb_account["type"] == "design") && $_REQUEST["bb_action"] == "bb_layout_configure_widget_activate_layout" && BB_IsSecExtraOpt("file")) {
                    BB_RunPluginAction("pre_bb_layout_configure_widget_activate_layout");
                    $found = false;
                    $dirlist = BB_GetDirectoryList(ROOT_PATH . "/" . WIDGET_PATH . "/" . $this->layoutpath);
                    foreach ($dirlist["files"] as $name) {
                        $pos = strrpos($name, ".");
                        if ($pos !== false && substr($name, $pos) == ".html" && $name == $_REQUEST["file"]) {
                            $info = $this->ExtractFileInfo(ROOT_PATH . "/" . WIDGET_PATH . "/" . $this->layoutpath . "/" . $name);
                            if ($info !== false) {
                                $bb_widget->layout = $name;
                                $found = true;
                                break;
                            }
                        }
                    }
                    if (!$found) {
                        BB_PropertyFormLoadError("Invalid layout specified.");
                    }
                    if (!BB_SaveLangPage($bb_revision_num)) {
                        BB_PropertyFormError("Unable to save the layout activation.");
                    }
                    ?>
<div class="success"><?php 
                    echo htmlspecialchars(BB_Translate("Layout activated."));
                    ?>
</div>
<script type="text/javascript">
window.parent.LoadProperties(<?php 
                    echo BB_CreateWidgetPropertiesJS("bb_layout_configure_widget");
                    ?>
);
window.parent.ReloadIFrame();
</script>
<?php 
                    BB_RunPluginAction("post_bb_layout_configure_widget_activate_layout");
                } else {
                    if (($bb_account["type"] == "dev" || $bb_account["type"] == "design") && $_REQUEST["bb_action"] == "bb_layout_configure_widget_deactivate_layout") {
                        BB_RunPluginAction("pre_bb_layout_configure_widget_deactivate_layout");
                        $bb_widget->layout = "";
                        if (!BB_SaveLangPage($bb_revision_num)) {
                            BB_PropertyFormError("Unable to save the layout deactivation.");
                        }
                        ?>
<div class="success"><?php 
                        echo htmlspecialchars(BB_Translate("Layout deactivated."));
                        ?>
</div>
<script type="text/javascript">
window.parent.LoadProperties(<?php 
                        echo BB_CreateWidgetPropertiesJS("bb_layout_configure_widget");
                        ?>
);
window.parent.ReloadIFrame();
</script>
<?php 
                        BB_RunPluginAction("post_bb_layout_configure_widget_deactivate_layout");
                    } else {
                        if (($bb_account["type"] == "dev" || $bb_account["type"] == "design") && $_REQUEST["bb_action"] == "bb_layout_configure_widget_delete_layout" && BB_IsSecExtraOpt("file")) {
                            BB_RunPluginAction("pre_bb_layout_configure_widget_delete_layout");
                            $found = false;
                            $dirlist = BB_GetDirectoryList(ROOT_PATH . "/" . WIDGET_PATH . "/" . $this->layoutpath);
                            foreach ($dirlist["files"] as $name) {
                                $pos = strrpos($name, ".");
                                if ($pos !== false && substr($name, $pos) == ".html" && $name == $_REQUEST["file"]) {
                                    $info = $this->ExtractFileInfo(ROOT_PATH . "/" . WIDGET_PATH . "/" . $this->layoutpath . "/" . $name);
                                    if ($info !== false) {
                                        if (!unlink(ROOT_PATH . "/" . WIDGET_PATH . "/" . $this->layoutpath . "/" . $name)) {
                                            BB_PropertyFormLoadError("Unable to delete the layout HTML.");
                                        }
                                        foreach ($info as $profile => $data) {
                                            $filename = ROOT_PATH . "/" . WIDGET_PATH . "/" . $this->layoutpath . "/" . substr($name, 0, $pos) . ($profile != "" ? "." . $profile : "") . ".css";
                                            if (file_exists($filename)) {
                                                @unlink($filename);
                                            }
                                        }
                                        if (file_exists(ROOT_PATH . "/" . WIDGET_PATH . "/" . $this->layoutpath . "/" . $name . ".dat")) {
                                            @unlink(ROOT_PATH . "/" . WIDGET_PATH . "/" . $this->layoutpath . "/" . $name . ".dat");
                                        }
                                        if (isset($bb_widget->layout) && $bb_widget->layout == $name) {
                                            unset($bb_widget->layout);
                                        }
                                        $found = true;
                                        break;
                                    }
                                }
                            }
                            if (!$found) {
                                BB_PropertyFormLoadError("Invalid layout specified.");
                            }
                            if (!BB_SaveLangPage($bb_revision_num)) {
                                BB_PropertyFormLoadError("Unable to save the layout activation status.");
                            }
                            ?>
<div class="success"><?php 
                            echo htmlspecialchars(BB_Translate("Layout deleted."));
                            ?>
</div>
<script type="text/javascript">
window.parent.LoadProperties(<?php 
                            echo BB_CreateWidgetPropertiesJS("bb_layout_configure_widget");
                            ?>
);
window.parent.ReloadIFrame();
</script>
<?php 
                            BB_RunPluginAction("post_bb_layout_configure_widget_delete_layout");
                        } else {
                            if (($bb_account["type"] == "dev" || $bb_account["type"] == "design") && $_REQUEST["bb_action"] == "bb_layout_configure_widget") {
                                global $editmap, $extmap;
                                BB_RunPluginAction("pre_bb_layout_configure_widget");
                                $editmap = array("ea_html" => array("<a href=\"#\" onclick=\"return EditFile('%%HTML_JS_DIR%%', '%%HTML_JS_FILE%%', '%%HTML_JS_syntax%%', '%%HTML_JS_LOADTOKEN%%', '%%HTML_JS_SAVETOKEN%%');\">" . htmlspecialchars(BB_Translate("Edit HTML")) . "</a>", "syntax"), "ea_css" => array("<a href=\"#\" onclick=\"return EditFile('%%HTML_JS_DIR%%', '%%HTML_JS_FILE%%', '%%HTML_JS_syntax%%', '%%HTML_JS_LOADTOKEN%%', '%%HTML_JS_SAVETOKEN%%');\">" . htmlspecialchars(BB_Translate("Edit CSS")) . "</a>", "syntax"));
                                $extmap = array(".html" => array("edit" => "ea_html", "syntax" => "html"), ".css" => array("edit" => "ea_css", "syntax" => "css"));
                                BB_RunPluginAction("bb_layout_configure_widget_exteditmaps");
                                $desc = "<br />";
                                $desc .= BB_CreateWidgetPropertiesLink(BB_Translate("New Layout"), "bb_layout_configure_widget_new_layout");
                                if ($bb_widget->layout != "") {
                                    $desc .= " | " . BB_CreateWidgetPropertiesLink(BB_Translate("Deactivate Current Layout"), "bb_layout_configure_widget_deactivate_layout");
                                }
                                $rows = array();
                                $dirlist = BB_GetDirectoryList(ROOT_PATH . "/" . WIDGET_PATH . "/" . $this->layoutpath);
                                foreach ($dirlist["files"] as $name) {
                                    $pos = strrpos($name, ".");
                                    if ($pos !== false && substr($name, $pos) == ".html") {
                                        $info = $this->ExtractFileInfo(ROOT_PATH . "/" . WIDGET_PATH . "/" . $this->layoutpath . "/" . $name);
                                        if ($info !== false) {
                                            $rows[] = array("<a href=\"" . htmlspecialchars(ROOT_URL . "/" . WIDGET_PATH . "/" . $this->layoutpath . "/" . $name) . "\" target=\"_blank\">" . htmlspecialchars($name) . "</a>", BB_FileExplorer_GetActionStr(WIDGET_PATH . "/" . $this->layoutpath, $name) . " | " . BB_FileExplorer_GetActionStr(WIDGET_PATH . "/" . $this->layoutpath, substr($name, 0, $pos) . ".css") . " | " . ($bb_widget->layout != $name ? BB_CreateWidgetPropertiesLink(BB_Translate("Activate"), "bb_layout_configure_widget_activate_layout", array("file" => $name)) : BB_CreateWidgetPropertiesLink(BB_Translate("Deactivate"), "bb_layout_configure_widget_deactivate_layout")) . " | " . BB_CreateWidgetPropertiesLink(BB_Translate("Delete"), "bb_layout_configure_widget_delete_layout", array("file" => $name), BB_Translate("Deleting the '%s' layout will immediately affect any pages that utilize the layout.  Continue?", $name)));
                                        } else {
                                            if (file_exists(ROOT_PATH . "/" . WIDGET_PATH . "/" . $this->layoutpath . "/" . $name)) {
                                                $rows[] = array(BB_Translate("%s (Broken layout)", "<a href=\"" . htmlspecialchars(ROOT_URL . "/" . WIDGET_PATH . "/" . $this->layoutpath . "/" . $name) . "\" target=\"_blank\">" . htmlspecialchars($name) . "</a>"), BB_FileExplorer_GetActionStr(WIDGET_PATH . "/" . $this->layoutpath, $name));
                                            }
                                        }
                                    }
                                }
                                $options = array("title" => BB_Translate("Configure %s", $bb_widget->_f), "desc" => "Select an existing layout or create a new layout.", "htmldesc" => $desc);
                                if (count($rows)) {
                                    $options["fields"] = array(array("type" => "table", "cols" => array("Layout", "Options"), "rows" => $rows));
                                }
                                BB_RunPluginActionInfo("bb_layout_configure_widget_options", $options);
                                BB_PropertyForm($options);
                                BB_RunPluginAction("post_bb_layout_configure_widget");
                            }
                        }
                    }
                }
            }
        }
    }