function action($item = null) { if (Core::$client->ip != "CLI") { Http::redirect("403"); } $node = Core::lib("ClusterCli"); echo chr(27) . "[96mThis node is: " . chr(27) . "[0m" . $node->id . " " . (!empty($node->loadbalancer) ? "LOADBALANCER" : "WORKER") . "\n"; }
function edit() { $m = Core::lib("CMS")->metas; $v = is_array($this->value) ? $this->value : json_decode($this->value, true); $r = ""; foreach ($m as $k) { $r .= "<div style='width:20%;'><span><i>" . ucfirst(L($k)) . "</i></span></div><div style='width:80%;'><input class='input form-control' name='" . $this->fld . "[" . $k . "]' value='" . htmlspecialchars(!empty($v[$k]) ? $v[$k] : '') . "'></div>"; } return $r; }
function edit() { $m = Core::lib("CMS")->metas; $v = is_array($this->value) ? $this->value : json_decode($this->value, true); $r = "<div class='infobox' style='padding:5px;overflow:auto;'>"; foreach ($m as $k) { $r .= "<b>" . ucfirst(L($k)) . "</b><br><input class='input form-control' name='" . $this->fld . "[" . $k . "]' value='" . htmlspecialchars(!empty($v[$k]) ? $v[$k] : '') . "'>"; } $r .= "</div>"; return $r; }
function edit() { if (!Core::isTry()) { $page = new Page(); $page->template = "simple"; View::assign("page", $page); } $quickhelp = !Core::lib("CMS")->expert; View::assign("quickhelp", $quickhelp); return View::template("cms_pageinfo"); }
public function testLib() { $libs = Core::lib(); $this->assertNotEmpty($libs["Developer"], "Autoloading"); $this->assertEquals($libs["Developer"], Core::lib("Developer"), "Instance"); Core::lib("TestLib1", new Extension()); $libs2 = Core::lib(); $this->assertGreaterThan(count($libs), count($libs2), "Loaded manually"); $this->assertTrue(Core::isInst("TestLib1"), "isInst"); Core::lib("TestLib2", new Client(), "TestLib1"); $this->assertNotNull(Core::lib("TestLib2"), "Dependency"); $this->assertNull(Core::lib("TestLib3"), "No extension"); $this->assertInstanceOf("\\PHPPE\\Extension", Core::lib("TestLib1"), "Classof 1"); $this->assertInstanceOf("\\PHPPE\\Client", Core::lib("TestLib2"), "Classof 2"); $this->assertEquals("PHPPE\\Extension", Core::lib("TestLib1"), "Extension toString"); }
/** * default action */ function action($item) { //! page history enabled? $this->revert = Core::lib("CMS")->revert; //! delete a page with all versions if (!empty($_REQUEST['pagedel'])) { Page::delete($_REQUEST['pagedel']); unset($_SESSION['cms_url']); Http::redirect(); } //! publicate a page if (isset($_REQUEST['publish']) && $this->revert) { $this->ispublish = true; $publish = array_keys(Core::req2arr('publish')); if (!empty($publish)) { Page::publish($publish); Http::redirect("cms/pages"); } } //! load languages $this->langs[''] = "*"; foreach (!empty($_SESSION['pe_ls']) ? $_SESSION['pe_ls'] : ['en' => 1] as $l => $v) { $this->langs[$l] = $l . " " . L($l); } //! unlock old pages for this user if any Page::unLock(Core::$user->id); //! get list of pages $pages = Page::getPages(intval(@$_REQUEST['order'])); $needcleanup = false; foreach ($pages as $p) { if ($this->ispublish && ($p['publishid'] != 0 || $p['ownerid'] != 0)) { continue; } if ($this->revert && $p['publishid'] == 0) { $this->needpublish = true; } if (!$this->revert && $p['versions'] > 1) { $needcleanup = true; } $this->pages[empty($_REQUEST['order']) ? 0 : (empty($p['template']) ? $p['tid'] : $p['template'])][] = $p; } //! this is required once after page history turned off if ($needcleanup) { Page::cleanUp($pages); } }
function edit() { $quickhelp = !Core::lib("CMS")->expert; View::assign("quickhelp", $quickhelp); return View::template("cms_layoutadd"); }
* PHP Portal Engine v3.0.0 * https://github.com/bztsrc/phppe3/ * * Copyright LGPL 2016 bzt * * PHPPE Extension Manager * */ pe.extensions = { /*PRIVATE VARS*/ installed:[ <?php echo Core::lib("Extensions")->getInstalled(); ?> ], pkgs:[ <?php echo Core::lib("Extensions")->getPkgs(); ?> ], licenses:[], tmr:null, me:false, lastcmd:"", param:"",return:"",url:"", /*PUBLIC METHODS*/ search:function(str,installed) { var t="",up=false,down=false; if(str==""||str==null||str==undefined)str=document.getElementById("search").value; if(str=="<?php echo L("installed"); ?> "<?php echo L("installed") != "installed" ? "||str==\"installed\"" : "";
if ($_FILES['upload']['type'] == "text/plain") { $choose = @file_get_contents($_FILES['upload']['tmp_name']); } elseif ($_FILES['upload']['type'] == "text/html") { $d = @file_get_contents($_FILES['upload']['tmp_name']); preg_match_all("|<body[^>]*>(.*?)<\\/body|ims", $d, $b, PREG_SET_ORDER); $choose = !empty($b[0][1]) ? $b[0][1] : $d; } else { $err = L("wyswyg_htmlonly"); } } die("<html><head><meta charset='utf-8'/></head><body>" . ($choose ? "<div>" . $choose . "</div><script type='text/javascript'>parent.pe.wyswyg.importdone(\"" . $_REQUEST['impform'] . "\");</script>" : View::_t("<!form>") . "<input type='hidden' name='impform' value='" . $_REQUEST['impform'] . "'>" . "<input type='file' name='upload' onchange='this.form.submit();' id='" . $_REQUEST['impform'] . ":import'>" . ($err ? "alert('" . $err . "');" : "") . "</form>") . "</body></html>"); } $bs = Core::isInst("bootstrap"); //! get toolbars $toolbar = []; $libs = Core::lib(); foreach ($libs as $l) { if (!empty($l->wyswyg_toolbar)) { $toolbar = array_merge($toolbar, $l->wyswyg_toolbar); } } ?> pe.wyswyg = { <?php if ($bs) { ?> classes: { "toggle": "glyphicon glyphicon-eye", "import": "glyphicon glyphicon-open", "font": "glyphicon glyphicon-font", //L("wyswyg_font") L("wyswyg_style") L("wyswyg_style<h2>") L("wyswyg_style<h3>") L("wyswyg_style<h4>") L("wyswyg_style<h5>") L("wyswyg_style<pre>") "bold": "glyphicon glyphicon-bold", //L("wyswyg_bold")
/** * Action handler */ function action($item) { setlocale(LC_NUMERIC, "C"); $lib = Core::lib("ClusterSrv"); $nodes = DS::query("*", self::$_table, "", "", "type,load DESC,id"); $master = DS::field("id", self::$_table, "type='master' AND modifyd>CURRENT_TIMESTAMP-120"); //! check if executed from CLI if (Core::$client->ip != "CLI") { header("Content-type:application/json"); $loadavg = 0.0; $waspeek = 0; $minSync = ""; if (!empty($nodes)) { $minSync = reset($nodes)['syncd']; foreach ($nodes as $k => $node) { unset($nodes[$k]["cmd"]); $loadavg += floatval($node['load']); if ($node['load'] >= 0.5) { $waspeek = 1; } if ($node['load'] >= 0.75) { $waspeek = 2; } if ($node['syncd'] < $minSync) { $minSync = $node['syncd']; } } $loadavg /= count($nodes); } date_default_timezone_set('UTC'); $minSync = strtotime($minSync); $D = []; $d = $lib->_skeleton; if (substr($d, -1) != "/") { $d .= "/"; } foreach (['vendor/*', 'vendor/*/*', 'vendor/*/*/*', 'vendor/*/*/*/*', 'vendor/*/*/*/*/*'] as $v) { $D += array_fill_keys(@glob($d . $v, GLOB_NOSORT), 0); } $newfiles = 0; foreach ($D as $d => $v) { $t = filemtime($d); if ($t != 0 && $t > $minSync) { $newfiles = 1; break; } } die(json_encode(["status" => $loadavg < 0.1 ? "idle" : ($loadavg > 0.5 || $waspeek ? $loadavg > 0.75 || $waspeek == 2 ? "error" : "warn" : "ok"), "loadavg" => $loadavg, "peek" => $waspeek, "master" => $master, "newfiles" => $newfiles, "id" => Core::lib("ClusterSrv")->id, "nodes" => $nodes])); } else { echo chr(27) . "[96mThis node is: " . chr(27) . "[0m" . $lib->id . " " . chr(27) . "[" . (strtolower(trim($lib->id)) == strtolower(trim($master)) ? "91mMASTER" : "92mSLAVE") . chr(27) . "[0m\n" . chr(27) . "[96mCluster nodes:\n"; echo chr(27) . "[96m Id Type Load Last seen Last viewed Name\n -------------- --------- ----- ------------------- ------------------- -----------------------------" . chr(27) . "[0m\n"; foreach ($nodes as $node) { echo sprintf("%s%-16s%-8s%8s", strtolower(trim($node['id'])) == strtolower(trim($master)) ? chr(27) . "[93m*" : " ", $node['id'], $node['type'], $node['load']) . " " . (!empty($node['modifyd']) ? $node['modifyd'] : sprintf("%-19s", L("booting"))) . " " . (!empty($node['viewd']) ? $node['viewd'] : "????-??-?? ??:??:??") . " " . $node['name'] . chr(27) . "[0m\n"; } echo "\n"; if (Core::$core->action == "action") { $this->help(); } } }