public function __construct(TESTReader &$reader, OPTIONS &$opts, &$items, INTERVAL &$ivl, $resample) { $period = $opts->Get('period'); $this->multiplier = $reader->GetFractionalMultiplier($period); $this->period = $this->multiplier * $period; $this->resample = $this->multiplier * $resample; $from = $this->multiplier * $ivl->GetWindowStart(); $ifrom = ceil($from); $rem = $ifrom % $this->period; if ($rem) { $this->from = $ifrom + ($this->period - $rem); } else { $this->from = $ifrom; } $this->to = $this->multiplier * $ivl->GetWindowEnd(); $limit = $ivl->GetItemLimit(); if ($limit) { if ($limit > 0) { $to = $this->from + $this->period * $limit; if ($to < $this->to) { $this->to = $to; } } else { $from = $this->to + $this->period * $limit; if ($from > $this->from) { $this->from = $from; } } } $this->items =& $items; $limit = $opts->GetDateLimit(TESTData::DEFAULT_START, time()); $this->start = $limit[0]; }
public static function prefered($type, $name, $identifier = 0) { $prefered = ''; if (USER::is_logged()) { $identifier = $identifier == 0 ? USER::get('id') : $identifier; $check = OPTIONS::get($type, $name, $identifier); if ($check === false) { $prefered = OPTIONS::get($type, $name); } else { $prefered = $check; } } else { $prefered = OPTIONS::get($type, $name); } return $prefered; }
<?php if (OPTIONS::website('service_minify') == 1) { EVENTS::add_action("before_render", function () { if (!URL::routed()) { $r = URL::check('^extender/(.*).min.(css|js)$', true); if ($r !== false) { $path = FOLDER_BASE . "extender/" . $r[1] . "." . $r[2]; if (file_exists($path)) { // minify $minify = HELPERS::load("minify"); $minify->addSource($path); $minify->exec(); // redirect to the new file redirect(BASE_URL . $r[0]); } } } }); }
} TPL::assign("maintenance_mode", OPTIONS::website("maintenance_mode")); TPL::render("v_settings/settings_maintenance"); break; case "backend": if (isset($_POST['new_background'])) { // change image $new_image = replace_cards($_POST['new_background'], array(), true); OPTIONS::set('admin', 'background', $new_image, USER::get('id')); // return result die('ok'); } if (isset($_POST['new_color'])) { // change color scheme $color_scheme = substr(substr($_POST['new_color'], 5), 0, -1); OPTIONS::set('admin', 'color_scheme', $color_scheme, USER::get('id')); // return result die('ok'); } // get backgrounds list ---------------------------------------- $backgrounds = array(); foreach (glob(FOLDER_ADMIN . "template/assets/backgrounds/*.{jpg,png}", GLOB_BRACE) as $bg) { $infos = array("link" => str_replace(array(FOLDER_BASE, DS), array(BASE_URL, "/"), $bg), "img" => basename($bg), "thumb" => str_replace(array(FOLDER_BASE, DS), array(BASE_URL, "/"), $bg)); $infos['current'] = $infos['link'] == admin_get_background(true) ? true : false; $backgrounds[] = $infos; } TPL::assign("backgrounds", $backgrounds); // ------------------------------------------------------------- // set render TPL::render("v_settings/settings_backend"); break;
*/ case "templates_list": TPL::assign("templates_list", DRAWLINE::templates_list()); TPL::render('v_design/templates_list'); break; /* * install a template */ /* * install a template */ case "template_install": if (isset($_GET['package'])) { $package = str_replace(array("/", ".."), "", $_GET['package']); if (file_exists(FOLDER_EXTENDER . "templates" . DS . $package . DS . "index.php")) { if (OPTIONS::set("website", "frontend_template", $package)) { TPL::message("The template was changed successfuly.", "success"); } else { TPL::message("We encounted an error. Please try again!"); } } else { TPL::message("I can't find this template on the server."); } } else { redirect(ADMIN_URL); } TPL::assign("templates_list", DRAWLINE::templates_list()); TPL::render('v_design/templates_list'); break; } }
<?php // color schemes ----------------------------------------------- $color_scheme_1 = OPTIONS::prefered('admin', 'color_scheme'); if (trim($color_scheme_1) != '') { $c2 = explode(",", $color_scheme_1); $c2[3] = " " . ($c2[3] + 0.1); $color_scheme_2 = implode(",", $c2); } else { $color_scheme_1 = '#fff'; $color_scheme_2 = '#000'; } TPL::assign('color_scheme_1', $color_scheme_1); TPL::assign('color_scheme_2', $color_scheme_2); // ------------------------------------------------------------- // background image -------------------------------------------- // -------------------------------------------------------------
public static function service_thumbs_remove_allow($size) { // arrange allowed sizes if (!is_array($size)) { $size = array($size); } $current = explode(",", OPTIONS::website("service_thumbs_allowed_sizes")); foreach ($current as $i => $v) { if (in_array($v, $size)) { unset($current[$i]); } } $current = implode(",", $current); // update OPTIONS::set('website', 'service_thumbs_allowed_sizes', $current); // return return true; }
<?php if (OPTIONS::website('service_error_reporting') == 1) { //set errors handler error_reporting(0); function drawline_handle_error($errno, $errstr, $error_file, $error_line) { echo "<b>Error:</b> [{$errno}] {$errstr} - {$error_file}:{$error_line}"; die; } function drawline_handle_fatal() { $error = error_get_last(); if ($error !== NULL) { print_array($error); } } set_error_handler("drawline_handle_error"); register_shutdown_function("drawline_handle_fatal"); }
function admin_get_background($return = false) { $template = replace_cards(OPTIONS::prefered('admin', 'background')); if (!filter_var($template, FILTER_VALIDATE_URL)) { $template = FOLDER_ADMIN . "template/assets/backgrounds/" . $template; $template = str_replace(array(FOLDER_BASE, DS), array(BASE_URL, "/"), $template); } // output the result if ($return) { return $template; } else { echo $template; } }
<?php if (OPTIONS::website('service_sitemap') == 1) { }
<?php if (OPTIONS::website('service_thumbs') == 1) { $r = URL::check('^content/[any]/[any]-thumb[num]x[num].[alpha]$', true); if ($r !== false) { $path = FOLDER_CONTENT . $r[1] . DS . $r[2] . "." . $r[5]; if (file_exists($path)) { $allowed_sizes = explode(",", OPTIONS::website("service_thumbs_allowed_sizes")); if (in_array($r[3] . "x" . $r[4], $allowed_sizes)) { // the new name of the image $new_name = FOLDER_CONTENT . $r[1] . DS . $r[2] . "-thumb" . $r[3] . "x" . $r[4] . "." . $r[5]; // load base image $img = HELPERS::load("images")->load($path); // resize, save and show $img->thumbnail($r[3], $r[4])->save($new_name)->output($new_name); // prevent execution die; } } } }
public static function remove_page_type($type_name) { global $db; $actual = array(); $current = self::get_page_types(); foreach ($current as $c) { if ($c['type_name'] != $type_name) { $actual[] = $c; } } $actual = json_encode($actual); return OPTIONS::set("website", "page_types", $actual) ? true : false; }
} // general assign TPL::assign("admin_url", ADMIN_URL); TPL::assign("base_url", BASE_URL); // run plugins foreach (DRAWLINE::plugins_list(true) as $plugin) { if (file_exists(FOLDER_PLUGINS . $plugin . DS . "index.php")) { include_once FOLDER_PLUGINS . $plugin . DS . "index.php"; EVENTS::do_action("run_plugin_" . $plugin); } else { LOGS::write("Not found plugin " . $plugin . " on the server."); } } EVENTS::do_action("before_render"); // start render if (OPTIONS::website("maintenance_mode") == '1' && !on_admin() && !PERMISSIONS::check("access_admin")) { if (TPL::check_template("page_maintenance")) { TPL::render("page_maintenance"); TPL::draw(true); } else { echo '<h1>This website is in maintenance!</h1>'; } } elseif (TPL::render() != "") { TPL::draw(true); } else { if (!URL::routed()) { show_404(); } } EVENTS::do_action("after_render"); //print_array(LOGS::export("html"));
public function __construct(RRDReader &$reader, OPTIONS &$opts, &$items, INTERVAL &$ivl, $resample) { parent::__construct($props); $data_start = $opts->Get('data_start'); $data_start = date("F j, Y", $data_start); $this->period = $opts->Get('step'); $this->file = $reader->rrd_folder . "/" . $reader->rrd_prefix . $opts->Get('file') . ".rrd"; $this->info = $reader::GetRRDInfo($opts->Get('file'), $reader); //get information on the rrd and its archives $this->resample = $resample; $from = $ivl->GetWindowStart(); $ifrom = ceil($from); //get start point as integer $rem = $ifrom % $this->period; //checks whether start point as integer is a multiple of period if ($rem) { $this->from = $ifrom + ($this->period - $rem); } else { $this->from = $ifrom; } //if yes, from is ifrom $this->pos = $this->from; $this->to = $ivl->GetWindowEnd(); $limit = $ivl->GetItemLimit(); //get interval's item limit, if any (defines how many datapoints to show and adjusts to or from based on that?) if ($limit) { if ($limit > 0) { $to = $this->from + $this->period * $limit; if ($to < $this->to) { $this->to = $to; } } else { $from = $this->to + $this->period * $limit; if ($from > $this->from) { $this->from = $from; } } } $this->items =& $items; //items to show (rra:s in this case) //this sets the caching starting point based on the longest rra:s datapoints $limit = $opts->GetDateLimit($data_start, time()); //$limit = $opts->GetDateLimit($this::DEFAULT_START, time());//gets the window limits (as in, the first and last possible timestamp values) $this->start = $limit[0]; }