public function historyAction() { $historylimit = $this->config['history']; $historykey = "phpredmin:terminal:history"; $historylen = $this->db->lLen($historykey); $command = ''; $reset = false; if ($historylimit > 0 && $historylen > 0) { $navigation = $this->inputs->get('navigation', self::NAVIGATION_UP); $start = $this->inputs->get('start'); $pointer = $this->db->get("phpredmin:terminal:history:pointer"); if ($historylen > $historylimit) { $this->db->lTrim($historykey, $historylimit * -1, -1); $historylen = $historylimit; } if ($navigation == self::NAVIGATION_UP) { if ($historylen <= $pointer * -1) { $pointer = $historylen * -1; } elseif (!isset($start)) { $pointer--; } } elseif ($pointer != -1) { $pointer++; } else { $reset = true; } $command = $this->db->lRange($historykey, $pointer, $pointer); $this->db->set("phpredmin:terminal:history:pointer", $pointer); } Template::factory('json')->render(array('command' => $command, 'reset' => $reset)); }
public function email($email) { if (is_array($this->emails)) { foreach ($this->emails as $settings) { $send = TRUE; if ($settings['to_element'] !== 'manual') { // replace to_email with value from form $settings['to_email'] = $this->_form->value($settings['to_element']); } // replace text in body $settings['body'] = Template::factory($settings['body'], $this->_form->values())->render(); // check if email is ok if (filter_var($settings['to_email'], FILTER_VALIDATE_EMAIL) === FALSE) { $send = FALSE; } //if it's ok to send: do it if ($send) { // feed the settings to the mailer $email->settings($settings); // send it out try { $email->send(); } catch (Exception $e) { Kohana::$log->add(Log::ERROR, 'Failed sending email: ' . var_export($settings, TRUE) . ' with exception: ' . var_export($e, TRUE)); } } } } }
public function viewAction($key, $page = 0) { $count = $this->db->lSize(urldecode($key)); $start = $page * 30; $values = $this->db->lRange(urldecode($key), $start, $start + 29); Template::factory()->render('lists/view', array('count' => $count, 'values' => $values, 'key' => urldecode($key), 'page' => $page)); }
function Poll($id, $question, $answer1 = 'Yes', $answer2 = 'No') { // values $id = isset($id) ? $id : ''; $question = isset($question) ? $question : ''; $answer1 = isset($answer1) ? $answer1 : ''; $answer2 = isset($answer2) ? $answer2 : ''; // json dir $dir = PLUGINS_PATH . '/poll/db/db.json'; // clear vars init $db = ''; $data = ''; // check if exists file if not make one if (File::exists($dir)) { $db = File::getContent($dir); $data = json_decode($db, true); if (!$data[$id]) { // array of data $data[$id] = array('question' => '', 'yes' => '', 'no' => ''); File::setContent($dir, json_encode($data)); // redirect Request::redirect(Url::getCurrent()); } } else { File::setContent($dir, '[]'); } // check session if exists show answer only if (Session::get('user_poll' . $id)) { $template = Template::factory(PLUGINS_PATH . '/poll/template/'); return $template->fetch('answer.tpl', ['id' => trim($id), 'question' => trim($question), 'answer1' => trim($answer1), 'answer2' => trim($answer2), 'yes' => $data[$id]['yes'], 'no' => $data[$id]['no']]); } else { // form post if (Request::post('sendData_' . $id)) { // check token if (Request::post('token')) { if (Request::post('answer') == 1) { $good = $data[$id]['yes'] + 1; $bad = $data[$id]['no']; } elseif (Request::post('answer') == 0) { $bad = $data[$id]['no'] + 1; $good = $data[$id]['yes']; } // array of data $data[$id] = array('question' => $question, 'yes' => $good, 'no' => $bad); // set content File::setContent($dir, json_encode($data)); // set session cookie Session::set('user_poll' . $id, uniqid($id)); // redirect Request::redirect(Url::getCurrent()); } else { die('crsf detect !'); } } // show template form $template = Template::factory(PLUGINS_PATH . '/poll/template/'); return $template->fetch('poll.tpl', ['id' => trim($id), 'question' => trim($question), 'answer1' => trim($answer1), 'answer2' => trim($answer2), 'yes' => $data[$id]['yes'], 'no' => $data[$id]['no']]); } }
/** * Description: add Shortcode. */ function short($attributes) { extract($attributes); $text = isset($text) ? $text : 'Start Collab'; $end = isset($end) ? $end : 'End Collab'; $class = isset($class) ? $class : 'btn btn-default'; $icon = isset($icon) ? '<i class="' . $icon . '"></i> ' : ''; $template = Template::factory(PLUGINS_PATH . '/togetherjs/template/'); return $template->fetch('btn.tpl', ['text' => $text, 'end' => $end, 'class' => $class, 'icon' => $icon]); }
public function addAction() { $added = false; if ($this->router->method == Router::POST) { $value = $this->inputs->post('value', null); $key = $this->inputs->post('key', null); if (isset($value) && trim($value) != '' && isset($key) && trim($key) != '') { $added = $this->db->set($key, $value); } } Template::factory('json')->render($added); }
public function delallAction() { if ($this->router->method == Router::POST) { $results = array(); $values = $this->inputs->post('values', array()); $keyinfo = $this->inputs->post('keyinfo', null); foreach ($values as $key => $value) { $results[$value] = $this->db->zDelete($keyinfo, $value); } Template::factory('json')->render($results); } }
public function moveallAction() { if ($this->router->method == Router::POST) { $results = array(); $values = $this->inputs->post('values', array()); $destination = $this->inputs->post('destination'); $keyinfo = $this->inputs->post('keyinfo'); foreach ($values as $key => $value) { $results[$value] = $this->db->sMove($value, $keyinfo, $destination); } Template::factory('json')->render($results); } }
public function slowlogAction() { $support = false; $slowlogs = array(); $serverInfo = $this->db->info('server'); $count = $this->inputs->post('count', null); $count = isset($count) ? $count : 10; if (!preg_match('/^(0|1)/', $serverInfo['redis_version']) && !preg_match('/^2\\.[0-5]/', $serverInfo['redis_version'])) { $slowlogs = $this->db->eval("return redis.call('slowlog', 'get', {$count})"); $support = true; } Template::factory()->render('welcome/slowlog', array('slowlogs' => $slowlogs, 'support' => $support, 'version' => $serverInfo['redis_version'], 'count' => $count)); }
/** * Constructor. * * @access protected */ protected function __construct() { // Get Theme Templates static::$current_template = Template::factory(THEMES_PATH . '/' . Config::get('system.theme')); // Get Current Page static::$current_page = static::getPage(Url::getUriString()); // Send default header header('Content-Type: text/html; charset=' . Config::get('system.charset')); // Run actions before page rendered Action::run('before_page_rendered'); // Display page for current requested url static::display(static::$current_page); // Run actions after page rendered Action::run('after_page_rendered'); }
public function editAction($key, $member) { $edited = null; if ($this->router->method == Router::POST) { $newvalue = $this->inputs->post('newvalue', null); $member = $this->inputs->post('member', null); $key = $this->inputs->post('key', null); if (!isset($newvalue) || trim($newvalue) == '' || !isset($key) || trim($key) == '' || !isset($member) || trim($member) == '') { $edited = false; } elseif ($this->db->hDel($key, $member)) { $edited = $this->db->hSet($key, $member, $newvalue); } } $value = $this->db->hGet(urldecode($key), urldecode($member)); Template::factory()->render('hashes/edit', array('member' => urldecode($member), 'key' => urldecode($key), 'value' => $value, 'edited' => $edited)); }
<?php /** * Youtube for Fansoro CMS * Based on https://togetherjs.com/#tryitout-section. * * @author Moncho Varela * * @version 1.0.0 * * @license MIT */ Action::add('theme_footer', function () { echo '<script type="text/javascript" src="' . Url::getBase() . '/plugins/channel/assets/channel-dist.js"></script>'; }); ShortCode::add('Channel', function ($attr) { extract($attr); //{Channel name="nakome" limit="50"} $name = isset($name) ? $name : Config::get('plugins.channel.username'); $limit = isset($limit) ? $limit : 1; $quality = isset($quality) ? $quality : 'false'; $quantity = isset($quantity) ? $quantity : 8; // template factory $template = Template::factory(PLUGINS_PATH . '/' . Config::get('plugins.channel.name') . '/templates/'); $template->setOptions(['strip' => false]); return $template->fetch('gallery.tpl', ['name' => $name, 'limit' => $limit, 'quality' => $quality, 'quantity' => $quantity, 'apikey' => Config::get('plugins.channel.apikey')]); });
<?php /** * Breadcrumb Plugin * Based on idea from https://github.com/tovic/breadcrumb-plugin-for-fansoro-cms * * @package Fansoro * @subpackage Plugins * @author Pavel Belousov / pafnuty * @version 1.1.0 * @license https://github.com/pafnuty-fansoro-plugins/fansoro-plugin-breadcrumb/blob/master/LICENSE MIT */ Action::add('breadcrumb', function () { // Configuration data $config = Config::get('plugins.breadcrumb'); // Get current URI segments $paths = Url::getUriSegments(); // Count total paths $total_paths = count($paths); // Path lifter $lift = ''; // Breadcrumb's data $data = []; for ($i = 0; $i < $total_paths; $i++) { $lift .= '/' . $paths[$i]; $page = Pages::getPage(file_exists(STORAGE_PATH . '/pages/' . $lift . '/index.md') || file_exists(STORAGE_PATH . '/pages/' . $lift . '.md') ? $lift : '404'); $data[Url::getBase() . $lift] = ['title' => $page['title'], 'current' => rtrim(Url::getCurrent(), '/') === rtrim(Url::getBase() . $lift, '/')]; } $template = Template::factory(THEMES_PATH . '/' . Config::get('system.theme')); $template->display('/plugins/breadcrumb/breadcrumb.tpl', ['home' => rtrim(Url::getCurrent(), '/') === rtrim(Url::getBase(), '/') ? true : Url::getBase(), 'config' => $config, 'branch' => $data]); });
public function deleteAction($key) { Template::factory('json')->render($this->db->del(urldecode($key))); }
public function route() { $class = $this->controller . '_Controller'; $method = $this->action . 'Action'; if (class_exists($class)) { $controller = new $class(array('serverId' => $this->serverId, 'dbId' => $this->dbId)); if (method_exists($controller, $method)) { call_user_func_array(array($controller, $method), $this->_params); } return; } header("HTTP/1.0 404 Not Found"); Template::factory()->render('404'); }
public static function init() { // login vars $user = trim(Config::get('plugins.gallery.email')); $password = trim(Config::get('plugins.gallery.password')); $token = trim(Config::get('plugins.gallery.token')); $hash = md5($token . $password); // get plugin info //var_dump(json_encode(Config::get('plugins.gallery'),true)); $template = Template::factory(PLUGINS_PATH . '/gallery/templates/'); $template->setOptions(['strip' => false]); $jsonFile = ''; $format = ''; $thumbnails_path = ''; $photos_path = ''; $json = ''; $info = ''; // check if dir exists if not create if (!Dir::exists(ROOT_DIR . '/public/gallery')) { Dir::create(ROOT_DIR . '/public/gallery'); } if (!Dir::exists(ROOT_DIR . '/public/gallery/thumbnails')) { Dir::create(ROOT_DIR . '/public/gallery/thumbnails'); } if (!Dir::exists(ROOT_DIR . '/public/gallery/galleries')) { Dir::create(ROOT_DIR . '/public/gallery/galleries'); } if (!File::exists(ROOT_DIR . '/public/gallery/gallery.json')) { File::setContent(ROOT_DIR . '/public/gallery/gallery.json', '[]'); } else { $jsonFile = ROOT_DIR . '/public/gallery/gallery.json'; $format = array('jpg', 'jpeg', 'png', 'gif', 'bmp', 'JPG', 'JPEG'); $thumbnails_path = ROOT_DIR . '/public/gallery/thumbnails/'; $photos_path = ROOT_DIR . '/public/gallery/galleries/'; // decode json $json = json_decode(File::getContent($jsonFile), true); } // show loginbtn if (Session::exists(Config::get('plugins.gallery.name') . '_user')) { // logout if (Request::post('access_logout')) { Session::delete(Config::get('plugins.gallery.name') . '_user'); Request::redirect(Url::getBase() . '/' . strtolower(Config::get('plugins.gallery.name'))); } // create gallery if (Request::post('createGallery')) { if (Request::post('token')) { // id $id = time(); // json array remenber encode $json[$id] = array('id' => $id, 'title' => Request::post('title') ? Request::post('title') : 'No title', 'desc' => Request::post('desc') ? Request::post('desc') : 'No desc', 'thumbnail' => '/public/gallery/thumbnails/' . $id . '.png', 'photos' => ROOT_DIR . '/public/gallery/galleries/' . $id . '/'); Dir::create($photos_path . $id); // save content if (File::setContent($jsonFile, json_encode($json))) { self::upload('thumbnail', 'thumbnail', $format, $thumbnails_path, $id); self::upload('photos', 'photos', $format, $photos_path, $id); return self::set_msg('Success The gallery has been created'); } } else { die('Crsf detect!'); } } // update gallery if (Request::post('updateGallery')) { if (Request::post('token')) { // json array remenber encode $id = Request::post('update_id'); $json[$id] = array('id' => $id, 'title' => Request::post('update_title') ? Request::post('update_title') : 'No title', 'desc' => Request::post('update_desc') ? Request::post('update_desc') : 'No desc', 'thumbnail' => '/public/gallery/thumbnails/' . $id . '.png', 'photos' => ROOT_DIR . '/public/gallery/galleries/' . $id . '/'); // save content if (File::setContent($jsonFile, json_encode($json))) { //upload images self::upload('thumbnail', 'update_thumbnail', $format, $thumbnails_path, $id); self::upload('photos', 'update_photos', $format, $photos_path, $id); return self::set_msg('Success The gallery has been updated'); } } else { die('Crsf detect!'); } } // resize gallery if (Request::post('resizeGallery')) { if (Request::post('token')) { $uid = Request::post('gallery_id'); $w = Request::post('gallery_w'); $h = Request::post('gallery_h'); $files = File::scan($photos_path . $uid); foreach ($files as $file) { // Load the original image $image = new SimpleImage($file); $image->resize($w, $h, true); $image->save($file); } return self::set_msg('Success The gallery Photos, has been resized'); } } // resize thumbnail if (Request::post('resizeThumbnail')) { if (Request::post('token')) { $uid = Request::post('gallery_id'); $tw = Request::post('gallery_tw'); $th = Request::post('gallery_th'); $dir = ROOT_DIR . '/public/gallery/thumbnails/' . $uid . '.png'; // Load the original image $image = new SimpleImage($dir); $image->resize($tw, $th, true); $image->save($dir); return self::set_msg('Success The gallery Thumbnail, has been created'); } } // remove file if (Request::get('rem')) { $file = base64_decode(Request::get('rem')); $uid = Request::get('id'); File::delete($file); self::set_msg('Success The Image has been deleted'); } // remove gallery if (Request::get('del')) { $id_of_gallery = Request::get('del'); unset($json[$id_of_gallery]); if (File::setContent($jsonFile, json_encode($json))) { File::delete(ROOT_DIR . '/public/gallery/thumbnails/' . $id_of_gallery . '.png'); Dir::delete($photos_path . $id_of_gallery); self::set_msg('Success The Gallery ' . $id_of_gallery . ' has been deleted'); Request::redirect(Url::getBase() . '/gallery'); } } // show template return $template->display('admin.tpl', ['info' => self::get_msg(), 'title' => Config::get('plugins.gallery.name') . ' Admin Area', 'root_dir' => ROOT_DIR, 'info' => $info, 'content' => $json ? array_reverse($json) : '']); } else { // login access if (Request::post('access_login')) { if (Request::post('token')) { if (Request::post('password') == $password && Request::post('email') == $user) { @Session::start(); Session::set(Config::get('plugins.gallery.name') . '_user', $hash); // show admin template Request::redirect(Url::getBase() . '/gallery'); } else { // password not correct show error $template->display('partials/error.tpl', ['title' => 'Access Error', 'content' => Config::get('plugins.gallery.errorPassword')]); } } else { // crsf die('crsf detect'); } } // template return $template->display('home.tpl', ['root_dir' => ROOT_DIR, 'content' => $json ? array_reverse($json) : '']); } }
<?php /** * Fansoro Fluidbox Plugin * * (c) Romanenko Sergey / Awilum <*****@*****.**> * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ Action::add('theme_header', function () { echo '<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/fluidbox/2.0.0/css/fluidbox.min.css" type="text/css" />'; echo '<style>.fluidbox__wrap { display: inline-block; }</style>'; }); Action::add('theme_footer', function () { echo '<script type="text/javascript" src="//cdnjs.cloudflare.com/ajax/libs/jquery-throttle-debounce/1.1/jquery.ba-throttle-debounce.min.js"></script>'; echo '<script src="https://cdnjs.cloudflare.com/ajax/libs/fluidbox/2.0.0/js/jquery.fluidbox.min.js"></script>'; $template = Template::factory(PLUGINS_PATH . '/fluidbox/templates/'); $template->setOptions(["strip" => false]); $types = ''; foreach (Config::get('plugins.fluidbox.types') as $type) { $types .= 'a[href$=".' . $type . '"],'; } $types = rtrim($types, ","); return $template->display('fluidbox.tpl', ['types' => $types]); });
/** * @param string $title * @param string $url * @param array|string $classes */ public static function buttons($title = '', $url = '', $classes = '') { $classes = is_array($classes) ? implode(' ', $classes) : $classes; $template = Template::factory(PLUGINS_PATH . '/likely/templates/'); $template->display('likely.tpl', compact('title', 'url', 'classes')); }
/** * Display Page * * <code> * Pages::display($page); * </code> * * @access public * @param array $page Page array * @return string */ public static function display($page) { $template = Template::factory(THEMES_PATH . '/' . Config::get('system.theme')); $template->display((!empty($page['template']) ? $page['template'] : 'index') . '.tpl', $page); }
/** * Description: Producto Details Shortcode * Shortcode to get details of product item. */ public static function item_detail($attributes, $content) { // Extract attributes extract($attributes); if (isset($id)) { $id = $id; } else { $id = ''; } if (isset($url)) { $url = $url; } else { $url = ''; } if (isset($title)) { $title = $title; } else { $title = ''; } if (isset($description)) { $description = $description; } else { $description = ''; } if (isset($image)) { $image = $image; } else { $image = ''; } if (isset($price)) { $price = $price; } else { $price = ''; } $template = Template::factory(PLUGINS_PATH . '/shipcart/templates/'); $template->setOptions(['strip' => false]); // show template return $template->fetch('item_detail.tpl', ['id' => $id, 'url' => Url::getBase() . $url, 'title' => $title, 'description' => $description, 'image' => Url::getBase() . $image, 'price' => $price, 'content' => Filter::apply('content', $content)]); }
public static function comments() { $template = Template::factory(PLUGINS_PATH . '/disqus/templates/'); $template->display('disqus.tpl'); }
/** * compile the widget and store the results * */ public function compile() { if ($this->view != NULL && $this->view != '') { // no need to compile : template is not used return; } $this->check_template(); if ($this->error == 1) { $this->compiled = ''; // set compiletime to now $this->time_compiled = date('Y-m-d H:i:s', time()); } else { // get compiled $this->compiled = Template::factory($this->template)->compiled(); // set compiletime to now $this->time_compiled = date('Y-m-d H:i:s', time()); } // save $this->save(); }
public function __construct($config) { parent::__construct($config); $this->statsModel = new Stats_Model($this->app->current); $this->template = Template::factory('json'); }