Example #1
0
function doLogin($user)
{
    system\Helper::arcSetUser($user);
    Log::createLog("success", "user", "User logged in: " . $user->email);
    system\Helper::arcCheckSettingExists("ARC_LOGIN_URL", "/");
    $url = SystemSetting::getByKey("ARC_LOGIN_URL");
    system\Helper::arcReturnJSON(["redirect" => $url->value]);
    system\Helper::arcAddMessage("success", "Login successful.");
}
Example #2
0
<?php

if (system\Helper::arcIsAjaxRequest() == true) {
    $permission = UserPermission::getByID($_POST["id"]);
    $data = "<div class=\"form-group\"><label for=\"module\">Module</label>" . "<select id=\"module\" class=\"form-control\">";
    $pages = Page::getAllPages();
    foreach ($pages as $page) {
        $data .= "<option value=\"" . $page->seourl . "\"";
        if ($page->seourl == $permission->permission) {
            $data .= " selected";
        }
        $data .= ">" . $page->seourl . "</option>";
    }
    $data .= "</select></div>";
    system\Helper::arcReturnJSON(["data" => $data]);
}
Example #3
0
<?php

if (system\Helper::arcIsAjaxRequest()) {
    $user = User::getByID($_POST["id"]);
    $data = "";
    foreach ($user->getGroups() as $group) {
        $data .= "<li class=\"list-group-item\"><a class=\"btn btn-danger btn-xs\" onclick=\"removeFromGroupBtn('{$group->name}')\"><i class=\"fa fa-close\"></i></a> {$group->name}</li>";
    }
    $companies = $user->getCompanies();
    $company = "";
    foreach ($companies as $comp) {
        $company .= "<li class=\"list-group-item\"><a class=\"btn btn-danger btn-xs\" onclick=\"removeCompanyUser({$comp->id})\"><i class=\"fa fa-close\"></i></a> {$comp->name}</li>";
    }
    system\Helper::arcReturnJSON(["firstname" => $user->firstname, "lastname" => $user->lastname, "email" => $user->email, "group" => $data, "enabled" => boolval($user->enabled), "company" => $company]);
}
Example #4
0
<?php

if (system\Helper::arcIsAjaxRequest()) {
    $users = User::getAllUsers();
    $table = "<table class=\"table table-hover table-condensed\">";
    $table .= "<thead><tr><th>Name</th><th>Status</th><th>Email</th><th>Auth</th><th></th></tr></thead><tbody>";
    foreach ($users as $user) {
        $table .= "<tr><td>" . $user->getFullname() . "</td><td>";
        if ($user->enabled == true) {
            $table .= "<div class=\"label label-success\"><i class=\"fa fa-check\"></i> Enabled</div>";
        } else {
            $table .= "<div class=\"label label-danger\"><i class=\"fa fa-remove\"></i> Disabled</div>";
        }
        $table .= "</td><td>" . $user->email . "</td>" . "<td>";
        $ad = SystemSetting::getByKey("ARC_USER_AD", $user->id);
        if ($ad->id == 0) {
            $table .= "<i class=\"fa fa-user\"></i> Local";
        } else {
            $table .= "<i class=\"fa fa-cloud-download\"></i> LDAP";
        }
        $table .= "</td>" . "<td class=\"text-right\">" . "<div class=\"btn-group\" role=\"group\">" . "<a class=\"btn btn-primary btn-xs\" onclick=\"impersonateUser(" . $user->id . ")\"><i class=\"fa fa-user-secret\"></i> Impersonate</a>" . "<a class=\"btn btn-success btn-xs\" onclick=\"editUser(" . $user->id . ")\"><i class=\"fa fa-pencil\"></i> Edit</a>" . "<a class=\"btn btn-danger btn-xs\" onclick=\"removeUser(" . $user->id . ")\"><i class=\"fa fa-remove\"></i> Remove</a>" . "</div>" . "</td></tr>";
    }
    $table .= "</tbody></table>";
    system\Helper::arcReturnJSON(["html" => $table]);
}
Example #5
0
<?php

if (system\Helper::arcIsAjaxRequest()) {
    $company = Company::getByID($_POST["id"]);
    system\Helper::arcReturnJSON(["name" => $company->name]);
}
Example #6
0
<?php

if (system\Helper::arcIsAjaxRequest()) {
    $group = UserGroup::getByID($_POST["id"]);
    system\Helper::arcReturnJSON(["name" => $group->name, "description" => $group->description]);
}
Example #7
0
            Log::createLog("info", "arc", "Valid image type detected.");
            //$name = md5(uniqid(rand(), true));
            //$ext = explode('.', $_FILES['file']['name']);
            //$filename = $name . '.' . $ext[1];
            $filename = $_FILES['file']['name'];
            // force lowercase names
            $filename = strtolower($filename);
            $destination = system\Helper::arcGetPath(true) . "assets/pagemanager/" . $filename;
            if (!file_exists(system\Helper::arcGetPath(true) . "assets/pagemanager")) {
                mkdir(system\Helper::arcGetPath(true) . "assets/pagemanager");
            }
            Log::createLog("info", "arc", "Destination: '" . $destination . "'");
            $location = $_FILES["file"]["tmp_name"];
            Log::createLog("info", "arc", "Source: '" . $location . "'");
            $size = getimagesize($location);
            Log::createLog("info", "arc", "Size: " . $size[0]);
            if ($size == 0) {
                system\Helper::arcAddMessage("danger", "Invalid image uploaded");
                Log::createLog("danger", "arc", "Invalid image size.");
                return;
            }
            move_uploaded_file($location, $destination);
            Log::createLog("info", "arc", "Image moved to image folder.");
            system\Helper::arcReturnJSON(["path" => system\Helper::arcGetPath() . "assets/pagemanager/" . $filename]);
            Log::createLog("success", "arc", "Upload complete.");
        } else {
            Log::createLog("danger", "arc", "Upload error " . $_FILES['file']['error']);
            system\Helper::arcAddMessage("danger", "Error occured while uploading image");
        }
    }
}
Example #8
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 #9
0
        }
        $backUrl = rtrim($backUrl, "/");
        $html .= " <a class=\"btn btn-default btn-sm\" onclick=\"getFolderPath('" . $backUrl . "')\"><i class=\"fa fa-level-up\"></i> Up</a>";
    }
    $html .= "</td><td class=\"text-right\" colspan=\"4\">";
    // path
    $html .= "<i class=\"fa fa-home\"></i> ";
    if ($_POST["path"] == "") {
        $html .= "/";
    } else {
        $html .= $_POST["path"];
    }
    $html .= "</td></tr>";
    // get files/folders
    $html .= GetPath($_POST["path"]) . "</table>";
    system\Helper::arcReturnJSON(["html" => $html]);
}
function GetPath($path)
{
    $fullPath = system\Helper::arcGetPath(true) . "assets/" . $path . "/";
    $webPath = system\Helper::arcGetPath() . "assets" . $path;
    $files = scandir($fullPath);
    $html = "";
    foreach ($files as $file) {
        if ($file != "." && $file != "..") {
            $html .= "<tr>" . "<td style=\"width: 10px;\"><input type=\"checkbox\" id=\"{$file}\" onchange=\"mark('{$path}/{$file}')\"><label for=\"{$file}\"></label></td>";
            if (is_dir($fullPath . $file)) {
                // folder
                $fi = new FilesystemIterator($fullPath . $file, FilesystemIterator::SKIP_DOTS);
                $html .= "<td><i class=\"fa fa-folder-o\"></i> <a class=\"clickable\" onclick=\"getFolderPath('{$path}/{$file}')\">{$file}</a></td>" . "<td style=\"width: 10px;\">folder</td>" . "<td style=\"width: 10px;\">-</td>" . "<td style=\"width: 100px;\">" . iterator_count($fi) . ngettext(" item", " items", iterator_count($fi)) . "</td>" . "<td style=\"width: 100px;\">" . date("d M Y", filectime($fullPath . $file)) . "</td>";
            } else {
Example #10
0
<?php

if (system\Helper::arcIsAjaxRequest()) {
    $user = User::getByID($_POST["id"]);
    if ($user->id != system\Helper::arcGetUser()->id) {
        system\Helper::arcImpersonateUser($user);
        system\Helper::arcAddMessage("success", "Impersonation mode enabled");
        Log::createLog("warning", "user", "Is impersonating " . $user->getFullname());
        system\Helper::arcReturnJSON(["status" => "success"]);
    } else {
        system\Helper::arcAddMessage("danger", "You cannot impersonate yourself");
        system\Helper::arcReturnJSON(["status" => "failed"]);
    }
}
Example #11
0
<?php

if (system\Helper::arcIsAjaxRequest()) {
    $marked = json_decode($_POST['items']);
    $path = system\Helper::arcGetPath() . "assets";
    $links = "";
    foreach ($marked as $item) {
        $links .= $path . $item . "\n\r";
    }
    system\Helper::arcReturnJSON(["links" => $links]);
}
Example #12
0
<?php

if (system\Helper::arcIsAjaxRequest() == true) {
    $page = Page::getByID($_POST["id"]);
    system\Helper::arcReturnJSON(["title" => $page->title, "seourl" => $page->seourl, "metadescription" => $page->metadescription, "metakeywords" => $page->metakeywords, "seourl" => $page->seourl, "html" => html_entity_decode($page->content), "sortorder" => $page->sortorder, "iconclass" => $page->iconclass, "showtitle" => $page->showtitle, "hidelogin" => $page->hideonlogin, "hidemenu" => $page->hidefrommenu, "theme" => $page->theme]);
}
Example #13
0
<?php

$users = User::getAllUsers();
$users_json = array();
foreach ($users as $user) {
    $usr = array();
    $usr["firstname"] = $user->firstname;
    $usr["lastname"] = $user->lastname;
    $usr["email"] = $user->email;
    $usr["enabled"] = $user->enabled;
    $usr["groups"] = $user->groups;
    $users_json[] = $usr;
}
system\Helper::arcReturnJSON(["message" => "OK", "Users" => $users_json]);
Example #14
0
        system\Helper::arcAddMessage("danger", "User already exists with that email address");
        return;
    }
    $user->firstname = ucfirst(strtolower($_POST["firstname"]));
    $user->lastname = ucfirst(strtolower($_POST["lastname"]));
    $user->email = strtolower($_POST["emailr"]);
    if (empty($user->email)) {
        system\Helper::arcAddMessage("danger", "Please specifiy an email address");
        return;
    }
    $user->setPassword($_POST["passwordr"]);
    // save user
    $user->update();
    $company = SystemSetting::getByKey("ARC_REQUIRECOMPANY");
    if (!empty($_POST["company"]) && $company->value == "true") {
        $comp = Company::getByName(ucwords($_POST["company"]));
        if ($comp->id == 0) {
            $comp = new Company();
            $comp->name = ucwords($_POST["company"]);
            $comp->update();
        }
        $user->addToCompany($comp->id);
    }
    system\Helper::arcSetUser($user);
    system\Helper::arcAddMessage("success", "Your details have been registered");
    system\Helper::arcCheckSettingExists("ARC_LOGIN_URL", "/");
    $url = SystemSetting::getByKey("ARC_LOGIN_URL");
    system\Helper::arcReturnJSON(["redirect" => $url->value]);
} else {
    system\Helper::arcAddFooter("js", system\Helper::arcGetModulePath() . "js/register.js");
}