Example #1
0
 /**
  * Get the view based on the request
  */
 private static function arcGetView()
 {
     $uri_parts = explode('?', $_SERVER['REQUEST_URI'], 2);
     $uri = $uri_parts[0];
     // set session if it exists.
     if (self::arcGetPostData("arcsid") != null) {
         self::arcSetSession(self::arcGetPostData("arcsid"));
     }
     //stop impersonating user
     if ($uri == "/arcsiu") {
         self::arcStopImpersonatingUser();
         $uri = "/";
     }
     if (self::arcIsAjaxRequest() == false) {
         // get page
         if ($uri == "/") {
             $defaultPage = \SystemSetting::getByKey("ARC_DEFAULT_PAGE");
             $uri = $defaultPage->value;
         }
         $uri = trim($uri, '/');
         $page = \Page::getBySEOURL($uri);
         // does page exist
         if ($page->id == 0) {
             $page = \Page::getBySEOURL("error");
             unset(self::$arc["post"]);
             self::$arc["post"]["error"] = "404";
             self::$arc["post"]["path"] = $_SERVER["REQUEST_URI"];
         }
     } else {
         // new get
         if (self::arcGetPostData("action") == "getarcstatusmessages") {
             self::arcGetStatusMessages();
             return;
         }
     }
     // expired session - check for actual user because guests don't need to timeout.
     if (ARCSESSIONTIMEOUT > 0) {
         $timeout = ARCSESSIONTIMEOUT * 60;
         if (isset($_SESSION["LAST_ACTIVITY"]) && time() - $_SESSION["LAST_ACTIVITY"] > $timeout && isset($_SESSION["arc_user"])) {
             session_unset();
             session_destroy();
             $page = \Page::getBySEOURL("error");
             unset(self::$arc["post"]);
             self::$arc["post"]["error"] = "401";
             self::$arc["post"]["path"] = $_SERVER["REQUEST_URI"];
         }
     } else {
         self::arcAddFooter("js", self::arcGetPath() . "js/arckeepalive.min.js");
     }
     // update last activity time stamp
     $_SESSION["LAST_ACTIVITY"] = time();
     if (self::arcIsAjaxRequest() == false) {
         // get the current theme
         $theme = \SystemSetting::getByKey("ARC_THEME");
         // setup page
         self::arcAddHeader("title", $page->title);
         if (!empty($page->metadescription)) {
             self::arcAddHeader("description", $page->metadescription);
         }
         if (!empty($page->metakeywords)) {
             self::arcAddHeader("keywords", $page->metakeywords);
         }
         // Check the theme in config exists.
         if (!file_exists(self::arcGetPath(true) . "themes/" . $theme->value)) {
             $name = $theme->value;
             $theme->value = "default";
             $theme->update();
             die("Unable to find theme '" . $name . "'. Selected theme reset to 'default'.");
         }
         // If page has theme set, use it.
         if ($page->theme != "none") {
             $theme->value = $page->theme;
             // If page theme is not present, switch to global theme.
             if (!file_exists(self::arcGetPath(true) . "themes/" . $theme->value)) {
                 $theme = \SystemSetting::getByKey("ARC_THEME");
             }
         }
         // Check if the theme has a controller and include it if it does.
         if (file_exists(self::arcGetPath(true) . "themes/" . $theme->value . "/controller/controller.php")) {
             include_once self::arcGetPath(true) . "themes/" . $theme->value . "/controller/controller.php";
         }
     }
     $groups[] = \UserGroup::getByName("Guests");
     if (self::arcIsUserLoggedIn() == true) {
         $groups = array_merge($groups, self::arcGetUser()->getGroups());
     }
     if (self::arcIsAjaxRequest() == false) {
         if (!\UserPermission::hasPermission($groups, $page->seourl)) {
             $page = \Page::getBySEOURL("error");
             unset(self::$arc["post"]);
             self::$arc["post"]["error"] = "403";
             self::$arc["post"]["path"] = $_SERVER["REQUEST_URI"];
         }
         // template
         if (!file_exists(self::arcGetPath(true) . "themes/" . $theme->value . "/template.php")) {
             die("Unable to find template.php for theme '" . $theme->value . "'.");
         }
         $content = file_get_contents(self::arcGetPath(true) . "themes/" . $theme->value . "/template.php");
         // custom menu
         if (file_exists(self::arcGetThemePath(true) . "menu.php")) {
             ob_start();
             include self::arcGetThemePath(true) . "menu.php";
             $newContent = ob_get_contents();
             ob_end_clean();
             $content = str_replace("{{arc:menu}}", $newContent, $content);
         }
         // header
         if ($page->showtitle == "1") {
             $content = str_replace("{{arc:title}}", "{$page->title}", $content);
         } else {
             $content = str_replace("{{arc:title}}", "", $content);
         }
         //template modules
         $content = self::arcProcessModuleTags($content);
         // impersonating
         if (isset($_SESSION["arc_imposter"])) {
             $content = str_replace("{{arc:impersonate}}", "<div class=\"alert alert-info\">Impersonating " . self::arcGetUser()->getFullname() . ". <a href=\"/arcsiu\">Stop impersonating user</a></div>", $content);
         } else {
             $content = str_replace("{{arc:impersonate}}", "", $content);
         }
         // body
         $content = str_replace("{{arc:content}}", self::arcProcessModuleTags(html_entity_decode($page->content)), $content);
         // page icon
         $content = str_replace("{{arc:pageicon}}", "<i class=\"" . $page->iconclass . "\"></i> ", $content);
         $content = self::arcProcessTags($content);
         echo $content;
     } else {
         $data = explode("/", $uri);
         if (isset($data[1]) && isset($data[2])) {
             include self::arcGetModuleControllerPath($data[1], $data[2], true);
         } else {
             \Log::createLog("danger", "Ajax", "Invalid url: '{$uri}'");
         }
     }
     self::$arc["modulepath"] = "";
 }
Example #2
0
    <li>
        <a href="<?php 
echo system\Helper::arcGetPath();
?>
">Home</a>
    </li>

    <?php 
$path = system\Helper::arcGetPath();
$parts = "";
$uri_parts = explode('?', $_SERVER['REQUEST_URI'], 2);
$url = explode("/", $uri_parts[0]);
foreach ($url as $part) {
    if (!empty($part)) {
        $parts .= $part;
        $page = Page::getBySEOURL($parts);
        $parts .= "/";
        if ($page->id != 0) {
            ?>
                <li>
                    <a href="<?php 
            echo $path . $parts;
            ?>
"><?php 
            echo $page->title;
            ?>
</a>
                </li>
                <?php 
        } else {
            ?>
Example #3
0
    // trim / from start
    $page->seourl = ltrim($page->seourl, "/");
    if (empty($page->seourl)) {
        system\Helper::arcAddMessage("danger", "SEO url is a required field");
        system\Helper::arcReturnJSON(["status" => "failed"]);
        return;
    }
    $page->metadescription = $_POST["metadescription"];
    $page->metakeywords = $_POST["metakeywords"];
    $page->sortorder = $_POST["sortorder"];
    $page->iconclass = $_POST["iconclass"];
    $page->title = $_POST["title"];
    if ($page->title == "") {
        system\Helper::arcAddMessage("danger", "Page must have a title");
        system\Helper::arcReturnJSON(["status" => "failed"]);
        return;
    }
    $page->showtitle = $_POST["showtitle"];
    $page->hideonlogin = $_POST["hidelogin"];
    $page->hidefrommenu = $_POST["hidemenu"];
    $page->theme = $_POST["theme"];
    $seo = Page::getBySEOURL($_POST["seourl"]);
    if ($seo->id != 0 && $seo->id != $page->id) {
        system\Helper::arcAddMessage("danger", "Duplicate SEO Url found, please choose another");
        system\Helper::arcReturnJSON(["status" => "failed"]);
        return;
    }
    $page->update();
    system\Helper::arcAddMessage("success", "Page saved");
    system\Helper::arcReturnJSON(["status" => "success"]);
}
Example #4
0
<?php

if (system\Helper::arcIsAjaxRequest() == true) {
    $groups = UserGroup::getAllGroups();
    $table = "<table class=\"table table-hover table-condensed\">";
    $table .= "<thead><tr><th>Module</th><th>Status</th><th></th></tr></thead><tbody>";
    foreach ($groups as $group) {
        $permissions = UserPermission::getByGroupID($group->id);
        $table .= "<tr class=\"active\"><td colspan=\"2\"><strong>" . $group->name . "</strong></td><td class=\"text-right\"><a class=\"btn btn-primary btn-xs\" onclick=\"editPermission(" . $group->id . ",0);\"><i class=\"fa fa-plus\"></i> Create</a></td></tr>";
        foreach ($permissions as $permission) {
            $table .= "<tr><td>" . $permission->permission . "</td><td>";
            $page = Page::getBySEOURL($permission->permission);
            if ($page->id != 0) {
                $table .= "<div class=\"label label-success\"><i class=\"fa fa-check\"></i> Valid</div>";
            } else {
                $table .= "<div class=\"label label-danger\"><i class=\"fa fa-close\"></i> Invalid</div>";
            }
            $table .= "</td>" . "<td class=\"text-right\"><div class=\"btn-group\"><a class=\"btn btn-success btn-xs\" onclick=\"editPermission({$group->id},{$permission->id});\"><i class=\"fa fa-pencil\"></i> Edit<a/><a onclick=\"deletePermission({$permission->id});\" class=\"btn btn-danger btn-xs\"><i class=\"fa fa-remove\"></i> Remove<a/></div></td>" . "</tr>";
        }
    }
    $table .= "</tbody></table>";
    system\Helper::arcReturnJSON(["html" => $table]);
}